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 » Community » Newbie corner » Selected option, show which is active
Selected option, show which is active [message #28311] Fri, 27 August 2010 01:03 Go to next message
nlneilson is currently offline  nlneilson
Messages: 644
Registered: January 2010
Location: U.S. California. Mojave &...
Contributor
How can you show which option is active?

It looks like there is a check box before each option, could an X be placed there?

Or remove the box and have the option highlighted or bold, preferred as it takes less space?

index.php?t=getfile&id=2760&private=0

This is the code I am using:
	void SettingsMenu(Bar& bar) {
		bar.Add("m meters", THISBACK(Setm));
		bar.Add("km kilometers", THISBACK(Setkm));
		bar.Add("ft feet", THISBACK(Setft));
		bar.Add("mi miles", THISBACK(Setmi));
		bar.Add("nmi naut mi", THISBACK(Setnmi));


[Updated on: Fri, 27 August 2010 01:11]

Report message to a moderator

Re: Selected option, show which is active [message #28318 is a reply to message #28311] Fri, 27 August 2010 11:47 Go to previous messageGo to next message
andrei_natanael is currently offline  andrei_natanael
Messages: 262
Registered: January 2009
Experienced Member
To have a checked item put Check after it.
	void SettingsMenu(Bar& bar) {
		bar.Add("m meters", THISBACK(Setm)).Check(true);
Re: Selected option, show which is active [message #28328 is a reply to message #28318] Fri, 27 August 2010 21:26 Go to previous messageGo to next message
nlneilson is currently offline  nlneilson
Messages: 644
Registered: January 2010
Location: U.S. California. Mojave &...
Contributor
That puts a check mark in the box, good.
How this is worked into the code is a problem.

I searched the examples and bazarr plus don't recall anything in any documentation that covers this.

	void SettingsMenu(Bar& bar) {
		bar.Add("m meters", THISBACK(Setm)).Check(true);
		bar.Add("km kilometers"THISBACK(Setkm)).Check(true);
...
...

	void Setm() {
		Distm<<=revDistance(~Distance, un);
		un = 0;	
		Cfg[0] = "0";
		units<<="m";
		Distance<<=formatDistance(s, un, dp);
	}
	void Setkm() {
		Distm<<=revDistance(~Distance, un);
		un = 1;	
		Cfg[0] = "1";
		units<<="km";
		Distance<<=formatDistance(s, un, dp);
	}
	void Setft() {
		Distm<<=revDistance(~Distance, un);
		un = 2;	
		Cfg[0] = "2";
		units<<="ft";
		Distance<<=formatDistance(s, un, dp);
	}


How would you include .Check(true) in the Setft() function?

Without an example I could spend a considerable amount of time tinkering. There may be something built into U++ that helps on this, like when one is picked/checked any other option in that section is unchecked.
Re: Selected option, show which is active [message #28329 is a reply to message #28328] Fri, 27 August 2010 22:43 Go to previous messageGo to next message
Sender Ghost is currently offline  Sender Ghost
Messages: 301
Registered: November 2008
Senior Member
Hello, Neil.

Here, the full example:
#include <CtrlLib/CtrlLib.h>

using namespace Upp;

class App : public TopWindow {
private:
	bool checkBox;
public:
	typedef App CLASSNAME;
	App();

	MenuBar menu;

	void MenuBar(Bar& bar);
	void FileBar(Bar& bar);

	void OnCheck();
};

App::App() : checkBox(false)
{
	Title("CheckBox test application");
	CenterScreen().Sizeable().MinimizeBox().MaximizeBox();
	SetRect(Size(320, 240));

	AddFrame(menu);
	AddFrame(TopSeparatorFrame());
	menu.Set(THISBACK(MenuBar));
}

void App::MenuBar(Bar& bar)
{
	bar.Add(t_("File"), THISBACK(FileBar));
}

void App::FileBar(Bar& bar)
{
	bar.Add(t_("Check"), THISBACK(OnCheck)).Check(checkBox).Key(K_CTRL_W);
	bar.Separator();
	bar.Add(t_("Exit"), THISBACK(Close)).Key(K_CTRL_Q);
}

void App::OnCheck()
{
	checkBox = !checkBox;
}

GUI_APP_MAIN
{
	App app;
	app.Run();
}
Re: Selected option, show which is active [message #28330 is a reply to message #28329] Fri, 27 August 2010 23:46 Go to previous message
nlneilson is currently offline  nlneilson
Messages: 644
Registered: January 2010
Location: U.S. California. Mojave &...
Contributor
Thanks for the example Sender Ghost.
I should be able to figure it out from that.
Previous Topic: Making applications more fancy
Next Topic: Query regarding PopUpTable
Goto Forum:
  


Current Time: Fri Apr 26 21:40:50 CEST 2024

Total time taken to generate the page: 0.02906 seconds