Home » U++ Library support » Menus&Toolbars » General Menu Construction
General Menu Construction [message #3215] |
Sat, 13 May 2006 12:52 |
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
|
|
|
|
|
|
|
Goto Forum:
Current Time: Fri Sep 20 03:08:28 CEST 2024
Total time taken to generate the page: 0.02978 seconds
|