Home » Extra libraries, Code snippets, applications etc. » U++ users applications in progress and useful code snippets, including reference examples! » How to combine two widget-class in the topwindow
Re: How to combine two widget-class in the topwindow [message #2039 is a reply to message #2038] |
Thu, 30 March 2006 15:06   |
 |
fudadmin
Messages: 1321 Registered: November 2005 Location: Kaunas, Lithuania
|
Ultimate Contributor Administrator |
|
|
#include <CtrlLib/CtrlLib.h>
//you can keep this (and more like this) class declarations in one yourApp.h file
class App : public TopWindow {
private:
bool numbers_enabled;
//declare your widgets by adding below...
MenuBar menu;
StatusBar status;
InfoCtrl info1;
public:
void Exit() {Close();}
void EnableNumbers() {numbers_enabled = !numbers_enabled;}
void ShowNumber(int n) {PromptOK(AsString(n));}
void TestEdit() {PromptOK("fromEdit");} //added No3 - your func
void Dummy() {PromptOK("your function needs to be implemented!");}
//useful to have one dummy function while work in progress...
//...to fill calling "gaps"
//add here more funcs to call from menus,,,
//bar declarations
void SubSubMenu(Bar& bar);
void FileMenu(Bar& bar);
void EditMenu(Bar& bar);
void HelpMenu(Bar& bar);
void TopMenus(Bar& bar);
typedef App CLASSNAME;
App();
};
//while all implementations below you can keep in one or more *.cpp files (split by classes)
void App::SubSubMenu(Bar& bar) {
for(int i = 0; i < 10; i++)
bar.Add(AsString(i), THISBACK1(ShowNumber, i));
}
void App::FileMenu(Bar& bar) { //confusing name changed from "Menu" to "File"...
bar.Add("Enable numbers", THISBACK(EnableNumbers)).Check(numbers_enabled);
bar.Add(numbers_enabled, "Numbers", THISBACK(SubSubMenu));
bar.Add("Exit", THISBACK(Exit)).Key(K_CTRL_E);
}
//added No2 - your extra menu item and subItems
void App::EditMenu(Bar& bar) {
bar.Add("EditMy_1", THISBACK(TestEdit)).Key(K_CTRL_D);
bar.Add("Copy", THISBACK(Dummy)).Key(K_CTRL_C);
bar.Add("Cut", THISBACK(Dummy)).Key(K_CTRL_X);
bar.Add("Paste", THISBACK(Dummy)).Key(K_CTRL_V);
//add more items here...
}
void App::HelpMenu(Bar& bar)
{
bar.Add("Help", THISBACK(Dummy)).Key(K_F1);
bar.Add("About...", THISBACK(Dummy));
}
void App::TopMenus(Bar& bar){ //row of top menu "labels" - what you see without opening menus...
bar.Add("File", THISBACK(FileMenu));
bar.Add("Edit", THISBACK(EditMenu)); //added Step1 - extra menu item on Main & callback
bar.Add("Help", THISBACK(HelpMenu));
}
App::App()
{
//initialize your members on App creation (constructor)
numbers_enabled = true;
AddFrame(menu);
menu.Set(THISBACK(TopMenus));
//status stuff
status.AddFrame(info1.Width(250));
AddFrame(status.Height(25));
info1="info1: Welcome to the Ultimate++ !";
}
GUI_APP_MAIN
{
App().Title("Forlano Menu and Status -v1").Zoomable().Sizeable().Run();
}
[Updated on: Thu, 30 March 2006 19:39] Report message to a moderator
|
|
|
 |
|
How to combine two widget-class in the topwindow
By: forlano on Thu, 30 March 2006 14:20
|
 |
|
Re: How to combine two widget-class in the topwindow
By: fudadmin on Thu, 30 March 2006 15:06
|
 |
|
Re: How to combine two widget-class in the topwindow
By: forlano on Thu, 30 March 2006 22:04
|
 |
|
Re: How to combine two widget-class in the topwindow
By: mirek on Thu, 30 March 2006 22:17
|
 |
|
Re: How to combine two widget-class in the topwindow
By: fudadmin on Fri, 31 March 2006 19:17
|
 |
|
Re: How to combine two widget-class in the topwindow
By: forlano on Fri, 31 March 2006 23:14
|
 |
|
Re: How to combine two widget-class in the topwindow
By: fudadmin on Fri, 31 March 2006 23:40
|
 |
|
Re: How to combine two widget-class in the topwindow
By: forlano on Fri, 31 March 2006 23:52
|
 |
|
Re: How to combine two widget-class in the topwindow
By: forlano on Sat, 01 April 2006 12:34
|
 |
|
Re: How to combine two widget-class in the topwindow
By: fudadmin on Sat, 01 April 2006 14:31
|
 |
|
Re: How to combine two widget-class in the topwindow
By: fudadmin on Sat, 01 April 2006 15:24
|
 |
|
Re: How to combine two widget-class in the topwindow
By: forlano on Sat, 01 April 2006 17:40
|
 |
|
Re: How to combine two widget-class in the topwindow
By: forlano on Sat, 01 April 2006 19:56
|
 |
|
Re: How to combine two widget-class in the topwindow
By: fudadmin on Sat, 01 April 2006 20:27
|
 |
|
Re: How to combine two widget-class in the topwindow
By: mirek on Sat, 01 April 2006 20:36
|
 |
|
Re: How to combine two widget-class in the topwindow
By: fudadmin on Sat, 01 April 2006 20:48
|
 |
|
Re: How to combine two widget-class in the topwindow
By: fudadmin on Sat, 01 April 2006 21:03
|
 |
|
Re: How to combine two widget-class in the topwindow
By: mirek on Sat, 01 April 2006 21:09
|
 |
|
Re: How to combine two widget-class in the topwindow
By: forlano on Sun, 02 April 2006 10:22
|
 |
|
Re: How to combine two widget-class in the topwindow
By: fudadmin on Sun, 02 April 2006 12:39
|
Goto Forum:
Current Time: Sat Apr 26 04:37:29 CEST 2025
Total time taken to generate the page: 0.00939 seconds
|