Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion Groups
General
GeneralPortable MacsHardwareNetworking
Applications
Mac ApplicationsEudoraFirefox / MozillaInternet ExplorerOutlook ExpressMS OfficeEntourageExcelPowerPointWordVirtual PCMedia PlayerOther MS Products
Programming
Mac ProgrammingCodeWarriorPerl
Country Specific
Australian Mac GroupUK Mac Group

Mac Forum / Programming / CodeWarrior / January 2004



Tip: Looking for answers? Try searching our database.

Adding .nib files to Codewarrior project?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Charles Thomas - 14 Jan 2004 18:17 GMT
I'm trying to add a menu bar that I've created in Project Builder and
stored as a .nib file to my Codewarrior project.

However, when I go to "add files to project" it sees my .nib file as a
directory and offers me the choice of adding "classes.nib" or "info.nib"
to my project.

What's the best way to add my MenuBar to my project?

I've tried adding both of them, but the code:

  // Search the bundle for a .nib file named 'classes'.
   err = CreateNibReference(CFSTR("info"), &nib_ref);
                                   // also tried "classes"
   if (err == noErr)
   {
       // We found it, now use it to make our menus
     OSStatus err = SetMenuBarFromNib(nib_ref, CFSTR("MenuBar"));
     if (err != noErr )
     {
        do_status_message("\pUnable to load MenuBar from nib!");
     }
       DisposeNibReference(nib_ref);
   }
   else
   {
     do_status_message("\pUnable to find MenuBar nib!");
   }

fails at the call to SetMenuBarFromNib().

Apparently it's not seeing my MenuBar inside either file.

Thanks for any help with this.

CT
Frederick Cheung - 14 Jan 2004 20:32 GMT
> I'm trying to add a menu bar that I've created in Project Builder and
> stored as a .nib file to my Codewarrior project.
>
> However, when I go to "add files to project" it sees my .nib file as a
> directory and offers me the choice of adding "classes.nib" or "info.nib"
> to my project.

You don't actually need to do this. I don't add nibs to my Carbon
projects. Just copy the nib (not the classes.nib/info.nib, those are both
part of the "real" nib)  to your resources folder (in the appropriate
language folder if necessary).

Fred

> What's the best way to add my MenuBar to my project?
>
[quoted text clipped - 25 lines]
>
> CT
Charles Thomas - 14 Jan 2004 20:58 GMT
In article
<Pine.LNX.4.44.0401142030410.26941-100000@kern.srcf.societies.cam.ac.uk>
,

> > I'm trying to add a menu bar that I've created in Project Builder and
> > stored as a .nib file to my Codewarrior project.
[quoted text clipped - 7 lines]
> part of the "real" nib)  to your resources folder (in the appropriate
> language folder if necessary).

I'm not sure what you mean by "my resources folder".  There are hundreds
of "resources" folders on my computer.  Which one do you mean?

Also, I'm not sure I want to add a .nib file to some remote folder not
associated with my Codewarrior project.  It seems very cluttered to have
a folder full of nib files from various projects all in a remote
location not associated with their projects.

Somewhere down the road that file is going to get lost.  I'd rather keep
it in the same folder as my project, or better still, add it to my
project.

CT
Charles Thomas - 14 Jan 2004 21:46 GMT
> In article
> <Pine.LNX.4.44.0401142030410.26941-100000@kern.srcf.societies.cam.ac.uk>
[quoted text clipped - 14 lines]
> I'm not sure what you mean by "my resources folder".  There are hundreds
> of "resources" folders on my computer.  Which one do you mean?

Never mind.  The application package contents:resources folder.

This works fine.  Many thanks!

CT
Jøhnny Fävòrítê (it means "genetic antagonism") - 14 Jan 2004 21:52 GMT
> I'm not sure what you mean by "my resources folder".  There are
> hundreds of "resources" folders on my computer.  Which one do you
[quoted text clipped - 4 lines]
> have a folder full of nib files from various projects all in a remote
> location not associated with their projects.

there will be a resources folder somewhere inside your project folder.
that resources folder gets copied inside your application bundle at the
time the app is built/linked.  it has to, because the app's .nibs are
needed at runtime.  if they're not there, the app won't work.

given what you wrote above, i'm guessing you don't know that what looks
like an application when viewed in the finder is really a folder with
some special properties.  it's called a bundle.  it contains the app's
binary executable and all its resources, like strings files, icons, and
nibs.  bundles are used for other things besides just packaging
applications.

> Somewhere down the road that file is going to get lost.

no it won't, because your app won't run without it.

an app's .nibs are accessible by end users, which has given rise to a
whole new class of app-hacking.  recently i ran across a hack for
netnewswire that rearranges the panes in its main window.
Frederick Cheung - 14 Jan 2004 22:05 GMT
> In article
> <Pine.LNX.4.44.0401142030410.26941-100000@kern.srcf.societies.cam.ac.uk>
[quoted text clipped - 14 lines]
> I'm not sure what you mean by "my resources folder".  There are hundreds
> of "resources" folders on my computer.  Which one do you mean?

If your application is bundled, then it has a Resources folder as part of
its bundle. If not, then you can put the nib wherever you want.
In any case, nibs are not built into the application in the same way that
a resource file is.

Fred

> Also, I'm not sure I want to add a .nib file to some remote folder not
> associated with my Codewarrior project.  It seems very cluttered to have
[quoted text clipped - 6 lines]
>
> CT
MW Ron - 14 Jan 2004 21:42 GMT
>I'm trying to add a menu bar that I've created in Project Builder and
>stored as a .nib file to my Codewarrior project.
[quoted text clipped - 4 lines]
>
>What's the best way to add my MenuBar to my project?

You don't add it to the files tab, open the package tab and drag and
drop it to there.

Ron

>I've tried adding both of them, but the code:
>
[quoted text clipped - 23 lines]
>
>CT

Signature

Metrowerks, maker of CodeWarrior   -  "Software Starts Here"  
Ron Liechty - MWRon@metrowerks.com - <http://www.metrowerks.com>

Charles Thomas - 14 Jan 2004 22:18 GMT
> You don't add it to the files tab, open the package tab and drag and
> drop it to there.

I opened the package itself and put it in the "contents:resources"
folder in there there and that seemed to work.

Just out of curiosity, I see "Files" "Link Order" "Frameworks" and
"Target" tabs, but don't see a "Package" tab.

Am I using an outdated version of CW?  It says IDE version 5.1.1 build
1108.

CT
MW Ron - 14 Jan 2004 23:39 GMT
>> You don't add it to the files tab, open the package tab and drag and
>> drop it to there.
[quoted text clipped - 7 lines]
>Am I using an outdated version of CW?  It says IDE version 5.1.1 build
>1108.

Right,  Packages was added with CW 9 to handle this stuff much better.

Ron

Signature

Metrowerks, maker of CodeWarrior   -  "Software Starts Here"  
Ron Liechty - MWRon@metrowerks.com - <http://www.metrowerks.com>

 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.