[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Renaissance menus on OS X ?

From: Nicola Pero
Subject: Re: Renaissance menus on OS X ?
Date: Fri, 3 Jan 2003 02:48:34 +0000 (GMT)

> > The reason it is called apple is that there is a -setAppleMenu: method in
> > the Cocoa API.  Apparently (by trial and error) I found out that you need
> > to call setAppleMenu: on the first submenu to have it to work.  If that
> > method (name) is obscure, it's Apple's fault :-)
> ...as with so any things in the post-NeXT world :-) o.k., that makes sense
> now. I think what would be a good thing to have, however, would be a "base"
> set of gsmarkup files which do the same as a "new project" in Interface
> builder does - i.e. come with all the standard menus attached so you just
> add your own at the end. Alterting the example so that the gsmarkup
> file was loaded before application main rather than in a delegate might
> also be advantageous if you really wnat people to do it at that point, as I
> suspect that an awfull lot of code is written by taking an example and
> modifying it.

Yes.  Good idea!

I've been thinking about adding a 'template' application.

I really think I should.

> > I need feedback, so if you have comments or suggestions, please keep me
> > informed!
> I'm sure I can provide some of that - if I get annoying just tell me to shut
> up :-) I havent found any bugs at all so far you will be pleased to know!

> Anyway, heres 5 questions which have come up - I dont know if these are
> actually missing bits or if I just havent found the way to do thhem
> yet (though I did rummage through the source code before asking...)
> 1) How do I put an image into the interface ? I couldnt find any way of doing
>    this at all. I ended up attaching it to a button that does nothing as
>    a temporary fix.

I added a new <image> tag for this, and documented it.

Something like

<image name="GNUstep" />

should now do it.

> 2) How do I put a button onto a window but have it disabled ? An attribute
>    of enabled="no" would be useful to have. I went looking for this as a side
>    effect of my workaround to the Image problem :-)

I thought I had implemented this, but effectively I had confused editable
and enabled. :-(

I have now fixed the confusion, and implemented the enabled attribute.

<button enabled="no" title="click me!" action="terminate:" />

should now work.

> 3) How can I set the tag, action and taget for the individual menu elements
>    on a popup menu ? I can set a target and action for the popup as a whole
>    but not for the individual menu elements. Withough being able to set the 
> tag
>    on the menu elements then using a single action for the whole popup 
> becomes 
>    impossible as you cant differentiate between the items except by name 
> (which
>    may change due to translation).

Thanks - I have implemented tag, action and target attributes for

<popUpButtonItem tag="2" action="doSomething:" target="#NSOwner" title="Second 
Option" />
should now work.

> 4) I know that a proprotional vbox makes everything the same height, but how
>    do I create one where everything is the same width ? In this case I want
>    to 3 line box wth some text above and below, and a dividing line in the
>    middle, which stretches the whole way across the box.

I really need to document this.  You need to set the 'halign' flag of the
views in the vbox to 'wexpand' (I guess -- maybe, possibly, 'expand' is
right instead -- the difference is minimal).

Try the following example - 


   <button title="No" halign="wexpand" />
   <button title="Yes" halign="wexpand" />
   <button title="Cancel" halign="wexpand" />  


try with and without the halign="wexpand".  By default (without the
halign="wexpand"), buttons do not expand horizontally.  They are sized to
their comfortable widths, and are horizontally centered in the column.  
If you add a halign="wexpand", the buttons are expanded to fill all the
available space (that differs from halign="expand" only in that they don't
make the window resizable ... they are not 'pushing' for being expandable
- 'wexpand' is for 'weak-expand').

I definitely need to document all this stuff.  I will.

If it still doesn't work for you, can you send me an excerpt of the
.gsmarkup you are trying to build, with explanations of why it's not doing
what you want ?

> 5) How to embed a custom view inside something ? I can see how to create
>    a completely custom object, but does it intelligently work out if thats
>    a subclass of NSView and act on it approrpiately if I put it inside
>    a vbox for example ?

At the moment I've not implemented anything of this sort, but it should be
quite easy to do.

The simplest thing would be to have a <customView class="MyView" /> tag,
which adds a custom view.

But ... but since we are *not* decoding streamed objects to file, there is
no reason why *any* tag representing a view or control (or a window or
panel) should not be allowed to have a class="MySubClass" attribute.

When allocating the instance from the tag, the class="Xxx" attribute would
be used, if Xxx maps to an existing subclass of the class that the tag
represents: for example if you do

<window class="MyWindow" title="Hello" width="200" height="4000">
  <!-- some views here -->

then the system when decoding the <window> tag could plainly simply
allocate it of class MyWindow (assuming it exists and it is a subclass of
NSWindow) instead of simply NSWindow.

Everything after this would go on as usual, so all attributes recognized
by <window> would be used, and the MyWindow instance would receive
precisely all setup calls as a NSWindow would receive.

Even more savagely advanced, you can use arbitrary outlets which are set
via key-value coding to set arbitrary instance variables of your subclass,
if they point to objects.

For example, if your MyWindow instance has a 'setRepresentedLink:' method,
taking an object attribute, then you could have '-setRepresentedLink:
theFileOwner' be called by doing -

<window class="MyWindow" title="Hello" representedLink="#NSOwner" />

that will work out of the box with no need of any special stuff.  At run
time Renaissance will create the window of class MyWindow, then since
representedLink is an embedded outlet, look for a method
setRepresentedLink: of the object; it would find it, and call it setting
the #NSOwner object as the representedLink.

(of course by extending Renaissance with a palette or something it would
be possible to add new tags and new attributes etc, but the nice thing
here is that you don't need any extension, you can just use the standard
tag and the small extensions needed for a subclass are provided already!)

In practice, what I want to do is implement the attribute class="xxx" in
the <view> and <window> tags to check that the class xxx exists and is a
subclass of the class represented by the tag, and if so, allocate an
object of that class instead of an object of the tag class.

That would mean that every 'sub-tag' of <view> and <window> would support

You could for example do

<tableView class="MyTableViewSubclass">

and tableView would be treated exactly as a tableView, recognize all
tableView attributes, etc, but be allocated of MyTableViewSubclass rather
than of NSTableView.

Would that be enough for you ?  It means you could replace any object with
an object of a subclass.

I want to think a little bit about it, then I'll implement it.

> Thats all the issues I came across just converting one simple App (not
> yet finished). I'm sure more will come up, though they are fairly minor
> things really. I'll let you know :-)

Thanks - it's excellent to have such feedback, as that helps directly in
making a better product! :-)

reply via email to

[Prev in Thread] Current Thread [Next in Thread]