Nav dialog Q's and A's

Member
Posts: 277
Joined: 2004.10
Post: #1
I'm making a map editor which is crossed between ObjC (interface/nib) and C++ (OpenGL, memory managment).

The upsides are having a very simple interface control. When I create a save navigation dialog it creates one. Now when I NavDialogRun it displays the dialog and user can input stuff and click the save button... The problem is that there is no title bar.

The user cannot drag the window and it looks horribly bad...

I'm not sure but setting a name for the window might help... but the name is CFStringRef...

(I'm a total Neapolian Dynomite when it comes to CoreFoundation)


That's all fine and dandy... I mean it actualy works... but how do I get the actual folder it want's to save my map at?

Remember... Carbon, C++, Navagation Services.

Here's some laughing ninja's just to make fun of them. (Annoyed)
NinjaLOLNinja
Wacko

called by saveMap: action in BZController subclass of NSObject.
Code:
void SaveMap(void)
{
    NavDialogCreationOptions dialogOptions;
    NavDialogRef dialogRun;
    NavReplyRecord dialogReply;
    OSStatus err = NavGetDefaultDialogCreationOptions (&dialogOptions);
    if (err != noErr)
        cout << "\n" << err << "\n" << endl;
    
    err = NavCreatePutFileDialog (&dialogOptions, 'ibzw', 'ibze', NULL, NULL, &dialogRun); // ibzw stands for BZW on ibzedit and ibze stands for iBZE...dit
    if (err != noErr)
        cout << "\n" << err << "\n" << endl;


err = NavDialogRun (dialogRun);
    if (err != noErr)
        cout << "\n" << err << "\n" << endl;
        
err = NavDialogGetReply (dialogRun, &dialogReply);
    if (err != noErr)
        cout << "\n" << err << "\n" << endl;


    // this is where we handle the user input... after they close the dialog...


err = NavDisposeReply (&dialogReply);
    if (err != noErr)
        cout << "\n" << err << "\n" << endl;


NavDialogDispose (dialogRun); // returns void


}

Global warming is caused by hobos and mooses
Quote this message in a reply
Sage
Posts: 1,199
Joined: 2004.10
Post: #2
I can't say much without seeing more code, but I'd recommend you use *more* cocoa. Looks like you're trying to get too low and Carbony without a full understanding of carbon, and it looks like you've got a lot of mixing between cocoa and carbon going on. But then, I can't tell without seeing more code.

For what it's worth, I was able to write this: [Image: PANSISim.png] after only a couple months learning Cocoa. For reference, the engine is 100% portable C++. I originally wrote the engine under linux...

Cocoa is your friend! NSSavePanel is so easy you could do it falling down a flight of steps.

P.S. I notice your SaveMap function takes a void. This implies to me that your map data is... GLOBAL?! This will pretty much make multi-document editing a disaster. I'd start over again writing a document-based Cocoa app and let each document internally represent the document state. It's easier than it sounds. I did a couple document-based app tuts, and was able to write my own quickly afterwards.
Quote this message in a reply
Member
Posts: 277
Joined: 2004.10
Post: #3
Ok, whatever....

Does anybody know why my title bar does not apear?
And, how would I find out what directory the user picked to save the map?
(In classic I could use Apple Events Manager to get an FSRef... I haven't been able to find anything like that in Carbon since I began using it about... two years ago)

And, can anybody find a great online tutorial on ObjC and Cocoa?

Global warming is caused by hobos and mooses
Quote this message in a reply
Member
Posts: 277
Joined: 2004.10
Post: #4
I actualy have data to put where my map is going... just wondering how to get an FSRef from a titless nav bar... :'(

Global warming is caused by hobos and mooses
Quote this message in a reply
Sage
Posts: 1,199
Joined: 2004.10
Post: #5
Spend a few bucks and get a Cocoa Book. Hillegass's, or anything from O'Reilly.

Here's where I first cut my teeth:

http://developer.apple.com/documentation...TP30001163

Anyway, unless you're doing low level Quicktime you probably shouldn't be dealing with this stuff in 2005. Unless you think it's neat and retro to code like it's 1992. Cocoa is your friend. If you spend a couple weekends you'll see the light.
Quote this message in a reply
Member
Posts: 277
Joined: 2004.10
Post: #6
Quote:Here's where I first cut my teeth:

http://developer.apple.com/documentation...TP30001163

I flipped through the first few pages... but it's better then that converter tutorial...

Quote:Anyway, unless you're doing low level Quicktime you probably shouldn't be dealing with this stuff in 2005. Unless you think it's neat and retro to code like it's 1992. Cocoa is your friend. If you spend a couple weekends you'll see the light.

weekends... I'm gona try to learn this by friday... tomorrow...

And why is Carbon so bad?
The app I'm working on is for a windows/linux/mac game...
A basic interface copy from the windows version...

I still have no idea how to get the badly needed FSRef... Annoyed

Global warming is caused by hobos and mooses
Quote this message in a reply
Moderator
Posts: 3,577
Joined: 2003.06
Post: #7
BinarySpike Wrote:And why is Carbon so bad?
Because with Carbon you have to take care of handling little details like showing the window, then handling individual events in each button, setting up a modal loop, interacting with other unneeded BS, then tearing it all down step by step in reverse fashion.

With Cocoa - show the user a save dialog and give me the file path when you're done, thanks.

If you still don't understand why Carbon is so yucky to work with, you really need to heed TomorrowPlusX and get Hillegass's book. I started in an afternoon here. You have to start at the bottom of the page if you wanna jump right in. In the middle of the page is a series for more basic learning starting with "C is for Cocoa". There is also a book called Learning Cocoa with Objective-C from O'Reilly that I found very helpful in the beginning.
Quote this message in a reply
Member
Posts: 277
Joined: 2004.10
Post: #8
I found why my save dialog has no title bar...
http://developer.apple.com/documentation...ion_1.html
Look at the pretty pictures... :-P

You can see the save dialog has no title because it's part of the window.
But because our window is in Cocoa it doesn't link to the window....

So either I'm gona have to create my own nav dialog... or mess around with the parameters for the dialog.

Global warming is caused by hobos and mooses
Quote this message in a reply
Member
Posts: 257
Joined: 2004.06
Post: #9
BinarySpike Wrote:I flipped through the first few pages... but it's better then that converter tutorial...



weekends... I'm gona try to learn this by friday... tomorrow...

And why is Carbon so bad?
The app I'm working on is for a windows/linux/mac game...
A basic interface copy from the windows version...

I still have no idea how to get the badly needed FSRef... Annoyed

If you're working on a cross-platform app like that, might I recommend wxWidgets instead? It's not as nice as say, working with Cocoa and Interface Builder; I'd say it's more reminiscent of using Java and its layout objects. But it's literally taken me minutes to make a Mac wxWidgets project compile under Win32. And it's probably a lot better than working with Carbon.

Just my $0.02, though.

The brains and fingers behind Malarkey Software (plus caretaker of the world's two brattiest felines).
Quote this message in a reply
Member
Posts: 277
Joined: 2004.10
Post: #10
No the app ain't cross platform... It works on mac but 70% of the users are building thier maps on windows... so I don't want much of a change for them to mac... the current windows map editor is super old.

Global warming is caused by hobos and mooses
Quote this message in a reply
Member
Posts: 257
Joined: 2004.06
Post: #11
Oh. So if you're just doing a Mac version of the app, go Cocoa all the way. It'll be so much easier and faster.

The brains and fingers behind Malarkey Software (plus caretaker of the world's two brattiest felines).
Quote this message in a reply
Sage
Posts: 1,199
Joined: 2004.10
Post: #12
Malarkey Wrote:Oh. So if you're just doing a Mac version of the app, go Cocoa all the way. It'll be so much easier and faster.

Exactly. And if the app is well-structured, there's literally no reason at all why you can't have a cross-platform C++ core, with a thin Cocoa layer on top. That's why I posted the screenshot of my app -- that app's literally 60kloc of C++ with about 10 kloc of Cocoa acting as the GUI ( if I were writing it today, it might be smaller since I'm a better Cocoa programmer now ). Regardless, it was easy as pie.

Objective-C++ is good, and make this stuff pretty straightforward.

Finally, I have to say, there's *nothing* wrong, per se with Carbon. It's just that Cocoa is SO much easier to learn, and quite frankly, to truly grok.

And as a side note, I jabbed about programming like it's 1992. That was low, particularly since Cocoa dates back to the 80's! It's just that Cocoa was designed from square-one to be a modern, extensible object-oriented framework. It was *well* designed, and it's aged gracefully. It's the best GUI api I've ever worked with, and I've done win32, BeOS, GTK, Qt and Swing. Cocoa smacks them all around like the little b*tches they are.
Quote this message in a reply
Member
Posts: 277
Joined: 2004.10
Post: #13
Ok, I know how to get the FSRef I need but the code ain't working... "EXC_BAD_ACCES" for the few of you who don't know what that is it's means I accessed a pointer pointing to 0x00 or something similar.

I remove this code and it works without error...
(although I don't know where the error is because it's not generated when I debug... it just freezez and I have to stop the debugger...Huh)
Code:
// here are ALL my local variable's
    NavDialogCreationOptions dialogOptions;
    NavDialogRef dialogRun;
    NavReplyRecord dialogReply;
    OSStatus err = NavGetDefaultDialogCreationOptions (&dialogOptions);
    AEDesc  actualDesc;
    FSRef SaveFile;

...
          if ((err = AECoerceDesc( &dialogReply.selection, typeFSRef, &actualDesc )) == noErr)
          {  
            if ((err = AEGetDescData (&dialogReply.selection, &SaveFile, AEGetDescDataSize (&dialogReply.selection))));
                {
                    outputSaveData(&SaveFile);
                }
            
            AEDisposeDesc( &actualDesc );
          }
...

Global warming is caused by hobos and mooses
Quote this message in a reply
Member
Posts: 277
Joined: 2004.10
Post: #14
Ok, I'm getting really ticked off with this nav dialog no title bar thing...

I've tryed giving it the "FrontWindow()" and it does nothing... what's up with that?

No matter what i do with the title, parent window, or anything it continues to have no title bar...

I just think I'm gona scrap it for now and export to .app/contents/macos/../../../
But that is freaking frustrating and requires the same amount of code...

My mind is fried...

Global warming is caused by hobos and mooses
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  Dialog box for key StevenPeeler 1 2,239 May 1, 2009 06:40 AM
Last Post: StevenPeeler