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++ Library support » U++ Widgets - General questions or Mixed problems » Can we get OptionTree:ManualMode?
Can we get OptionTree:ManualMode? [message #16679] Mon, 07 July 2008 16:34 Go to next message
cbpporter is currently offline  cbpporter
Messages: 1401
Registered: September 2007
Ultimate Contributor
So that OptionTree no longer check items for you when you click on other items. This is useful if you have a tree like A/B/C/D and check means process or similar operation, and unchecking C will only process A/B/D, with D processed even though C is skipped.

class OptionTree : public TreeCtrl {
	...
	bool manualMode;
	
	...
	OptionTree& ManualMode() 						{ manualMode = true; return *this; }




void OptionTree::SetOption(int id)
{
	Option *opt = option[id];
	ASSERT(opt);
	
	if (manualMode)
	{
		WhenOption();
		return;
	}
		
	SetChildren(id, opt->Get());
	for(;;) {
		id = GetParent(id);
		if(id < 0)
			break;
		bool t = false;
		bool f = false;
		bool n = false;
		for(int i = 0; i < GetChildCount(id); i++) {
			int chid = GetChild(id, i);
			Option *opt = option[chid];
			if(opt) {
				int x = opt->Get();
				if(x == 1)
					t = true;
				else
				if(x == 0)
					f = true;
				else
					n = true;
			}
		}
		opt = option[id];
		if(opt) {
			if(t && f || n) {
				opt->Set(Null);
			}
			else
				opt->Set(t);
		}
	}
	WhenOption();
}

OptionTree::OptionTree(): manualMode(false)  { aux.Add(); }
Re: Can we get OptionTree:ManualMode? [message #16726 is a reply to message #16679] Tue, 08 July 2008 18:23 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
cbpporter wrote on Mon, 07 July 2008 10:34

So that OptionTree no longer check items for you when you click on other items. This is useful if you have a tree like A/B/C/D and check means process or similar operation, and unchecking C will only process A/B/D, with D processed even though C is skipped.

class OptionTree : public TreeCtrl {
	...
	bool manualMode;
	
	...
	OptionTree& ManualMode() 						{ manualMode = true; return *this; }




void OptionTree::SetOption(int id)
{
	Option *opt = option[id];
	ASSERT(opt);
	
	if (manualMode)
	{
		WhenOption();
		return;
	}
		
	SetChildren(id, opt->Get());
	for(;;) {
		id = GetParent(id);
		if(id < 0)
			break;
		bool t = false;
		bool f = false;
		bool n = false;
		for(int i = 0; i < GetChildCount(id); i++) {
			int chid = GetChild(id, i);
			Option *opt = option[chid];
			if(opt) {
				int x = opt->Get();
				if(x == 1)
					t = true;
				else
				if(x == 0)
					f = true;
				else
					n = true;
			}
		}
		opt = option[id];
		if(opt) {
			if(t && f || n) {
				opt->Set(Null);
			}
			else
				opt->Set(t);
		}
	}
	WhenOption();
}

OptionTree::OptionTree(): manualMode(false)  { aux.Add(); }



OK, patch applied.

Mirek
Re: Can we get OptionTree:ManualMode? [message #16736 is a reply to message #16726] Tue, 08 July 2008 23:12 Go to previous message
cbpporter is currently offline  cbpporter
Messages: 1401
Registered: September 2007
Ultimate Contributor
Thank you!
Previous Topic: Error: Invalid UTF-8 sequence when reading txt file from hard disk
Next Topic: Exclamation doesnt show the text...
Goto Forum:
  


Current Time: Sun Apr 28 01:42:19 CEST 2024

Total time taken to generate the page: 0.04875 seconds