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 previous 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
 
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: CtrlImg::new_doc()
Next Topic: Fast menu navigation
Goto Forum:
  


Current Time: Thu Apr 25 00:04:25 CEST 2024

Total time taken to generate the page: 0.02401 seconds