Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » Menus&Toolbars » General Menu Construction
General Menu Construction [message #3215] Sat, 13 May 2006 12:52 Go to next message
Werner is currently offline  Werner
Messages: 234
Registered: May 2006
Location: Cologne / Germany
Experienced Member
So far I have found 5 different menu construction patterns. Reducing the code to the crucial parts and unifying it yields:

#1 The MenuSet variant
(Used in: Bombs, CodeMetric, Puzzle, Scribble2, Scribble3, UWord, GUI Tutorial Menu, GUI Tutorial Adding Images, GUI Tutorial Toolbar, GUI Tutorial StatusBar And Decorative Frames, Menu)
• MenuBar menu;
• AddFrame(menu);
• menu.Set(THISBACK(A_Function));
• bar.Add("a_name", THISBACK(Another_Function));

#2 The MenuAdd variant
(Used in: HelloWorld)
• MenuBar menu;
• AddFrame(menu);
• menu.Add("a_name", THISBACK(A_Function));
• bar.Add("a_name", THISBACK(Another_Function));

#3 The ContextMenu variant
(Used in: GUI Tutorial Context Menu)
• MenuBar menu;
• MenuBar::Execute(THISBACK(A_Function));
• bar.Add("a_name", THISBACK(Another_Function));

#4 The ContextMenu Alternative variant
(Used in: GUI Tutorial Context Menu Alternative And Using CallbackArgTarget, Some More Stuff About Callbacks)
• MenuBar menu;
• CallbackArgTarget<int> result;
• menu.Add(AsString(i), result[i]);
• menu.Execute();

#5 The Layout variant
(Used in: AddressBook, AddressBookXML)
• LAYOUT(AddressBookLayout, width, height) // MenuBar var;
• ITEM(MenuBar, menu, Position()) // parent.Add(layout.menu;)
• menu.Set(THISBACK(A_Function));
• bar.Add("a_name", THISBACK(Another_Function));

Are there even more patterns?

When should I use “menu.Set” (#1) and when “menu.Add” (#2)?

Werner
Re: General Menu Construction [message #3217 is a reply to message #3215] Sat, 13 May 2006 13:46 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
Always use #1 instead of #2. Actually, we are investigating how to avoid #2 at interface level (which is OTOH quite difficult while preserving context menu system). The fact that it was left in HelloWorld is rather bug than anything else (now fixed).

The thing is that "Set" and "PopUp" do some additional actions to get menu ready (like automatic hotkey assignment).

As for "Layout" variant, it is in fact the same as #1 - it does not matter whether you use menu as frame or as view ctrl.

Also, the difference between both context variants is zero - all the difference is in CallbackArgTarget, not in MenuBar.

Mirek
Re: General Menu Construction [message #3220 is a reply to message #3217] Sat, 13 May 2006 14:11 Go to previous messageGo to next message
Werner is currently offline  Werner
Messages: 234
Registered: May 2006
Location: Cologne / Germany
Experienced Member
Thanks for your instantaneous answer.

lay.h is a very nice piece of software, by the way.

Werner
Re: General Menu Construction [message #10789 is a reply to message #3215] Sun, 29 July 2007 00:20 Go to previous messageGo to next message
Mark999 is currently offline  Mark999
Messages: 6
Registered: July 2007
Promising Member
I was wondering the same thing. I think you add from top down. For example:


CtrlLayout(*this, "This App");
AddFrame(menu);
AddFrame(TopSeparatorFrame());
AddFrame(toolbar);
AddFrame(statusbar);
// add to each frame
menubar.Set(THISBACK(MainMenu));
.
.

Is this correct?
Re: General Menu Construction [message #10859 is a reply to message #10789] Wed, 01 August 2007 18:11 Go to previous message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
Well, if the question is about Frame(s), the correct answer is perhaps "from outside to inside": each frame in order reduces the view size. E.g. menu normally occupies top part of window, scrollbar right etc...
Previous Topic: CtrlImg::new_doc()
Next Topic: Fast menu navigation
Goto Forum:
  


Current Time: Fri Mar 29 11:10:56 CET 2024

Total time taken to generate the page: 0.01048 seconds