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 » TreeCtrl » Missing callback trigger in OptionTree? [SOLVED/FIXED]
Missing callback trigger in OptionTree? [SOLVED/FIXED] [message #3549] Thu, 01 June 2006 11:29 Go to next message
James Thomas is currently offline  James Thomas
Messages: 26
Registered: June 2006
Promising Member
I've got an OptionTree in my application and I would like to dynamically repond to state changes (ie: an option being checked).

This cannot be accomplished by assigning a callback to each Option control because OptionTree used this callback to implement it's hierarchical checking (when you check a parent option it also checks it's children).

Now, OptionTree has a Callback called WhenOption that is never triggered. I suspect that this was intended to be used for the purpose of allowing a response to a state change but was forgotten.

I believe it should be put into OptionCtrl::SetOption as follows:
void OptionTree::SetOption(int id)
{
	Option *opt = option[id];
	ASSERT(opt);
	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(); <<-------- This is the addition
}


With the extra line the control now works as I would expect. I can't see any other reason for WhenOption, so is this how it should work?

[Updated on: Fri, 02 June 2006 12:15]

Report message to a moderator

Re: Missing callback trigger in OptionTree? [message #3564 is a reply to message #3549] Thu, 01 June 2006 21:09 Go to previous message
mirek is currently offline  mirek
Messages: 11993
Registered: November 2005
Ultimate Member
James Thomas wrote on Thu, 01 June 2006 05:29

I've got an OptionTree in my application and I would like to dynamically repond to state changes (ie: an option being checked).

This cannot be accomplished by assigning a callback to each Option control because OptionTree used this callback to implement it's hierarchical checking (when you check a parent option it also checks it's children).

Now, OptionTree has a Callback called WhenOption that is never triggered. I suspect that this was intended to be used for the purpose of allowing a response to a state change but was forgotten.

I believe it should be put into OptionCtrl::SetOption as follows:
void OptionTree::SetOption(int id)
{
	Option *opt = option[id];
	ASSERT(opt);
	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(); <<-------- This is the addition
}


With the extra line the control now works as I would expect. I can't see any other reason for WhenOption, so is this how it should work?


You are right! Thanks!

Mirek
Previous Topic: TreeCtrl - how to change images dynamically? [SOLVED + FIXED]
Next Topic: Where can I store 32 bit data
Goto Forum:
  


Current Time: Fri Aug 23 07:49:18 CEST 2019

Total time taken to generate the page: 0.00796 seconds