ultimatepp/tutorial/Gui12/main.cpp
cxl 70d8b6d67a .tutorial
git-svn-id: svn://ultimatepp.org/upp/trunk@15651 f0d560ea-af0d-0410-9eb7-867de7ffcac7
2021-01-07 10:56:31 +00:00

51 lines
1.2 KiB
C++

#include <CtrlLib/CtrlLib.h>
using namespace Upp;
#define IMAGECLASS TutorialImg
#define IMAGEFILE <Gui12/images.iml>
#include <Draw/iml.h>
struct MyAppWindow : TopWindow {
MenuBar menu;
ToolBar tool;
StatusBar status;
typedef MyAppWindow CLASSNAME; // so that we can use THISFN shortcut
void SubBar(Bar& bar) {
bar.AddMenu("Function", TutorialImg::Fn(), [=] { // AddMenu - only in menu
PromptOK("Fn activated!");
}).Help("This invokes MenuFn method of tutorial example");
bar.Add(TutorialImg::Fn2(), [=] { // does not have image - not in toolbar
PromptOK("Fn2 activated!");
}).Help("This invokes BarFn method of tutorial example");
bar.Add("Exit", TutorialImg::Exit(), [=] { // in both toolbar and menu
if(PromptOKCancel("Exit MyApp?"))
Break();
});
}
void MainMenu(Bar& bar) {
bar.Sub("Menu", THISFN(SubBar));
}
MyAppWindow() {
Title("My application with bars").Sizeable();
AddFrame(menu);
AddFrame(TopSeparatorFrame());
AddFrame(tool);
AddFrame(status);
AddFrame(InsetFrame());
menu.Set(THISFN(MainMenu));
menu.WhenHelp = status;
tool.Set([=](Bar& bar) { SubBar(bar); }); // equivalent to THISFN(SubBar)
tool.WhenHelp = status;
}
};
GUI_APP_MAIN
{
MyAppWindow app;
app.Run();
}