PDA

View Full Version : Changing window functionality when using SDL and Carbon


mrbannon
2006.07.17, 05:54 PM
Hello,

I'm porting a game from PC to Mac. The game uses SDL for events and display. The original authors decided to not allow a resizable window. As such, when the window appears, the zoom button is not there. However, I need it to appear (after which I will change the functionality, but getting it to appear is my first priority).

My problem is that I can't seem to successfully change any attributes of my window. I've tried the following code (I can provide a full example if requested):


// There would be my SDL initialization here...along with setting video mode.
// ...

// Next, get the window reference (is this even the right way to do it)?
// It's my understanding that GetWindowList() returns a list of windows for this process.
WindowRef window = GetWindowList();

// Change the attribute.
OSStatus error = ChangeWindowAttributes(window, kWindowResizableAttribute, kWindowNoAttributes);


When I first tried this, I would get an error saying that the attribute couldn't be applied to the window class. So, before the attribute change, I would change the class to "kFloatingWindowClass". That produced no errors, but no zoom button.

So, I'm clearly doing something wrong. And I'm sure it's more than just one thing. Any help is greatly appreciated.

Thanks,

Ryan

ps - If you're curious, I want the zoom button to act as a fullscreen button, but I don't want the app to be resizable.

OneSadCookie
2006.07.17, 05:57 PM
SDL doesn't use Carbon on Mac OS X, so there is almost certainly no WindowRef for the window. You're going to need to look at the Cocoa documentation.

mrbannon
2006.07.17, 06:00 PM
SDL doesn't use Carbon on Mac OS X, so there is almost certainly no WindowRef for the window. You're going to need to look at the Cocoa documentation.

Ouch, I was afraid of that. I know that SDL uses Cocoa, but I figured that I would be able to get window information via Carbon even if that window was created via Cocoa. (And, if you're wondering, yes, I am somewhat of a Mac noob.)

OK, thanks for the help. (And EXTREMELY fast reply!)

Ryan

OneSadCookie
2006.07.17, 06:07 PM
I have no idea whether this will work, or on what OS versions, but the documentation suggests it might...

NSWindow *window = [NSApp mainWindow];
WindowRef windowRef = [window windowRef];
// your code from before

Skorche
2006.07.17, 09:46 PM
SDL allows resizable windows by setting a flag when you open the window. Wouldn't using that be easier?

OneSadCookie
2006.07.17, 10:37 PM
ps - If you're curious, I want the zoom button to act as a fullscreen button, but I don't want the app to be resizable.

:p ;)

Skorche
2006.07.17, 11:23 PM
Oh. :\ Nevermind.

mrbannon
2006.07.18, 05:44 PM
Hello again,

I tried some stuff today that didn't quite work :(
Maybe somebody will have some ideas?

Right after the SDL_SetVideoMode call, I did the following:


NSWindow* window = [nsApp mainWindow];
NSButton* button = [window standardWindowButton:NSWindowZoomButton];
[button display];
[window setShowsResizeIndicator:YES]; // I don't really want this...just did it to test.


Unfortunately, like I said, this didn't change anything. Does anybody have any ideas? Am I even making the proper calls?

Thanks,

Ryan

OneSadCookie
2006.07.18, 06:44 PM
I couldn't see any way to do what you want from Cocoa. If it's possible, it'll involve making the window resizeable and zoomable, then overriding some methods in the window's delegate to make those functions work in the way you want.

I'd really suggest trying the Carbon route I suggested a few posts up.

mrbannon
2006.07.19, 10:14 AM
I couldn't see any way to do what you want from Cocoa. If it's possible, it'll involve making the window resizeable and zoomable, then overriding some methods in the window's delegate to make those functions work in the way you want.

I'd really suggest trying the Carbon route I suggested a few posts up.

Tried it as well...no go. Next I'll try making it resizeable then turning some stuff off.

mrbannon
2006.07.21, 10:19 AM
Tried it as well...no go. Next I'll try making it resizeable then turning some stuff off.

That didn't work either. It seems as if I can't make any changes to the window after SDL has created it.

Well, if anybody has any ideas, I'm all ears, although I understand if this thread dies :)