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 » U++ TheIDE » U++ TheIDE: Layout (Forms) Designer » GUI with Menu bar and 5 Labels/Text Boxes
Re: GUI with Menu bar and 5 Labels/Text Boxes [message #24649 is a reply to message #24646] Tue, 26 January 2010 12:17 Go to previous messageGo to previous message
nlneilson is currently offline  nlneilson
Messages: 644
Registered: January 2010
Location: U.S. California. Mojave &...
Contributor
This is Gui07 modified
#include <CtrlLib/CtrlLib.h>

using namespace Upp;

#define LAYOUTFILE <Gui16/dlg.lay>
#include <CtrlCore/lay.h>

struct MyApp : public WithDlgLayout<TopWindow> {
	MenuBar menu;
	MyApp() {
		AddFrame(menu);
		CtrlLayout(*this, "MyDialog");
	}
	
	void GetP1() {
		PromptOK("GetP1 activated!");
	}

	void GetP2() {
		PromptOK("GetP2 activated!");
	}

	void Exit() {
		if(PromptOKCancel("Exit MyApp?"))
			Break();
	}

	void FileMenu(Bar& bar) {
		bar.Add("Open File", THISBACK(Exit));
		bar.Add("Clear File", THISBACK(Exit));
		bar.Add("Exit", THISBACK(Exit));
	}

	void PointsMenu(Bar& bar) {
		bar.Add("Get Point 1", THISBACK(GetP1));
		bar.Add("Get Point 2", THISBACK(GetP2));
		bar.Add("GoTo Point 1", THISBACK(Exit));
		bar.Add("GoTo Point 2", THISBACK(Exit));
	}

	void SubMenu(Bar& bar) {
		bar.Add("Exit", THISBACK(Exit));
	}

	void MainMenu(Bar& bar) {
		bar.Add("File", THISBACK(FileMenu));
		bar.Add("Settings", THISBACK(SubMenu));
		bar.Add("Points", THISBACK(PointsMenu));
		bar.Add("Calculate", THISBACK(SubMenu));
	}


};

GUI_APP_MAIN
{
	MyApp().Run();
}


This is Gui16 modified, it worked with the Labels/Text boxes until I added the Menu code
#include <CtrlLib/CtrlLib.h>

using namespace Upp;

struct MyAppWindow : TopWindow {
	MenuBar menu;

	void GetP1() {
		PromptOK("GetP1 activated!");
	}

	void GetP2() {
		PromptOK("GetP2 activated!");
	}

	void Exit() {
		if(PromptOKCancel("Exit MyApp?"))
			Break();
	}

	void FileMenu(Bar& bar) {
		bar.Add("Open File", THISBACK(Exit));
		bar.Add("Clear File", THISBACK(Exit));
		bar.Add("Exit", THISBACK(Exit));
	}

	void PointsMenu(Bar& bar) {
		bar.Add("Get Point 1", THISBACK(GetP1));
		bar.Add("Get Point 2", THISBACK(GetP2));
		bar.Add("GoTo Point 1", THISBACK(Exit));
		bar.Add("GoTo Point 2", THISBACK(Exit));
	}

	void SubMenu(Bar& bar) {
		bar.Add("Exit", THISBACK(Exit));
	}

	void MainMenu(Bar& bar) {
		bar.Add("File", THISBACK(FileMenu));
		bar.Add("Settings", THISBACK(SubMenu));
		bar.Add("Points", THISBACK(PointsMenu));
		bar.Add("Calculate", THISBACK(SubMenu));
	}

	typedef MyAppWindow CLASSNAME;

	MyAppWindow() {
		Title("Neilson"); //.Sizeable();
		AddFrame(menu);
		menu.Set(THISBACK(MainMenu));
	}
};

GUI_APP_MAIN
{
	MyAppWindow app;
	app.SetRect(0, 0, 260, 120);
	app.Run();
}

and the .lay file
LAYOUT(DlgLayout, 208, 132)
	ITEM(Label, dv___0, SetLabel(t_("Point 1")).LeftPosZ(8, 40).TopPosZ(8, 19))
	ITEM(EditField, dv___1, LeftPosZ(48, 156).TopPosZ(76, 19))
	ITEM(EditString, text, LeftPosZ(48, 156).TopPosZ(8, 19))
	ITEM(Option, option, SetLabel(t_("Option")).LeftPosZ(8, 108).TopPosZ(104, 15))
	ITEM(LineEdit, dv___4, LeftPosZ(48, 156).TopPosZ(28, 19))
	ITEM(LineEdit, dv___5, LeftPosZ(48, 156).TopPosZ(52, 19))
	ITEM(Label, dv___6, SetLabel(t_("Point 2")).LeftPosZ(8, 40).TopPosZ(28, 19))
	ITEM(Label, dv___7, SetLabel(t_("Distance")).LeftPosZ(8, 40).VSizePosZ(52, 61))
END_LAYOUT


I also tried from examples Puzzles and EyeCare that have both a menu and addid graphics.
With Puzzles after stripping some of the code there were errors re "unresolved externals".
With EyeCare I am still removing code so I can understand it.
 
Read Message
Read Message
Read Message
Read Message icon13.gif
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: How to make Layout Sizeable & Zoomable
Next Topic: Layout editor problem with Ctrl &
Goto Forum:
  


Current Time: Sun May 05 21:24:35 CEST 2024

Total time taken to generate the page: 0.02593 seconds