Home » Community » Newbie corner » menu Tree
Re: menu Tree [message #32393 is a reply to message #32386] |
Sun, 15 May 2011 19:36 |
Sender Ghost
Messages: 301 Registered: November 2008
|
Senior Member |
|
|
Well, with current implementation of MenuBar, I think, it also possible to do as follows:
#include <CtrlLib/CtrlLib.h>
using namespace Upp;
class App : public TopWindow {
private:
bool tac1L, tac1R;
public:
typedef App CLASSNAME;
App();
// Ctrls
MenuBar menu;
Label label_1L, label_1R;
// Bars
void MainBar(Bar& bar);
void FileBar(Bar& bar);
void TacMenu1L(Bar& bar);
void TacMenu1R(Bar& bar);
// Events
void OnCheck1L();
void OnCheck1R();
};
App::App() : tac1L(false), tac1R(true) {
Title("MenuBar test application");
CenterScreen().Sizeable().MinimizeBox().MaximizeBox();
SetRect(Size(320, 240));
AddFrame(menu);
AddFrame(TopSeparatorFrame());
menu.Set(THISBACK(MainBar));
label_1L.SetLabel("Atlanta\nBrownsville\nDallas-FtWorth\nDetroit\nOmaha\nPhoenix\nSaltLake").NoWantFocus();
label_1R.SetLabel("Other cities\n.\n..\n...").NoWantFocus();
}
// Bars
void App::MainBar(Bar& bar){
bar.Add("File", THISBACK(FileBar));
}
void App::FileBar(Bar& bar){
bar.Add("1L", THISBACK(TacMenu1L)).Check(tac1L);
bar.Add("1R", THISBACK(TacMenu1R)).Check(tac1R);
bar.Separator();
bar.Add("Exit", THISBACK(Close)).Key(K_CTRL_Q);
}
void App::TacMenu1L(Bar& bar) {
bar.Add(tac1L ? "Un&select" : "&Select", THISBACK(OnCheck1L)).Image(tac1L ? Null : CtrlImg::smallcheck());
bar.Separator();
bar.AddNC(label_1L);
}
void App::TacMenu1R(Bar& bar)
{
bar.Add(tac1R ? "Un&select" : "&Select", THISBACK(OnCheck1R)).Image(tac1R ? Null : CtrlImg::smallcheck());
bar.Separator();
bar.AddNC(label_1R);
}
// Events
void App::OnCheck1L()
{
tac1L = !tac1L;
}
void App::OnCheck1R()
{
tac1R = !tac1R;
}
GUI_APP_MAIN
{
App app;
app.Run();
}
Because, the checkbox, which you "would like to be able to click", is clicked, when you selected it to show next menu bar (according to source code, which you wrote).
Also, the same Label Ctrl, showed on the current menu bar, couldn't be added to the next bar (because it will be "moved", in this case). Instead, try to use specific Label Ctrl for specific menu bar.
|
|
|
Goto Forum:
Current Time: Sat May 18 23:44:46 CEST 2024
Total time taken to generate the page: 0.02340 seconds
|