Home » U++ Library support » Menus&Toolbars » beginner's questions about menu&bars [SOLVED]+[EXAMPLES]
beginner's questions about menu&bars [SOLVED]+[EXAMPLES] [message #1934] |
Tue, 28 March 2006 10:10 |
|
forlano
Messages: 1185 Registered: March 2006 Location: Italy
|
Senior Contributor |
|
|
Hello,
I'm learning this amazing library but I'm having some problem. Please forgive me if I'm posting a silly question. Unfortunatly I found no reference about menu in assist in theIDE and I am confused about class MenuBar and Bar and how to use them.
Below is the code for a menubar that I got in the documentation. It has 1 pulldown menu attached to 'File'. Now I want add another pulldown, lets say 'Edit', to the right of 'File' with just one item, let's say 'select'. Can somebody add two lines of code to show me how to perform this task? After it I am sure to be able to realize any menu.
Thanks a lot in advance.
Luigi
#include <CtrlLib/CtrlLib.h>
struct App : public TopWindow {
bool numbers_enabled;
void Exit()
{
Close();
}
void EnableNumbers()
{
numbers_enabled = !numbers_enabled;
}
void ShowNumber(int n)
{
PromptOK(AsString(n));
}
void SubMenu(Bar& bar)
{
for(int i = 0; i < 10; i++)
bar.Add(AsString(i), THISBACK1(ShowNumber, i));
}
void Menu(Bar& bar)
{
bar.Add("Enable numbers", THISBACK(EnableNumbers))
.Check(numbers_enabled);
bar.Add(numbers_enabled, "Numbers", THISBACK(SubMenu));
bar.Add("Exit", THISBACK(Exit))
.Key(K_CTRL_E);
}
void MainBar(Bar& bar)
{
bar.Add("Menu", THISBACK(Menu));
}
MenuBar menu;
typedef App CLASSNAME;
App()
{
numbers_enabled = false;
AddFrame(menu);
menu.Set(THISBACK(MainBar));
}
};
GUI_APP_MAIN
{
App().Run();
}
[Updated on: Mon, 01 May 2006 14:09] by Moderator Report message to a moderator
|
|
|
Goto Forum:
Current Time: Thu Apr 18 13:56:22 CEST 2024
Total time taken to generate the page: 0.02193 seconds
|