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 » 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 Go to previous messageGo to previous message
fudadmin is currently offline  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

 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Mouse over button example -"catch me if you can..."
Next Topic: "Forlano tabs" - how to reduce a headache by the proper use of the designer...
Goto Forum:
  


Current Time: Sun May 12 19:20:53 CEST 2024

Total time taken to generate the page: 0.02706 seconds