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 » TreeCtrl - how to change images dynamically? [SOLVED + FIXED]
TreeCtrl - how to change images dynamically? [SOLVED + FIXED] [message #2312] Fri, 07 April 2006 22:20 Go to next message
fudadmin is currently offline  fudadmin
Messages: 1321
Registered: November 2005
Location: Kaunas, Lithuania
Ultimate Contributor
Administrator
in TreeCtrl
There are methods:
	void   Set(int id, Value value);
	void   Set(int id, Value key, Value value);

but no for images...
How to change images dynamically?
(other than add or insert!!!)

[Updated on: Sun, 09 April 2006 04:39]

Report message to a moderator

Re: TreeCtrl - how to change images dynamically? [message #2314 is a reply to message #2312] Sat, 08 April 2006 01:14 Go to previous messageGo to next message
fudadmin is currently offline  fudadmin
Messages: 1321
Registered: November 2005
Location: Kaunas, Lithuania
Ultimate Contributor
Administrator
fudadmin wrote on Fri, 07 April 2006 21:20

in TreeCtrl
There are methods:
	void   Set(int id, Value value);
	void   Set(int id, Value key, Value value);

but no for images...
How to change images dynamically?
(other than add or insert!!!)


I haven't done a lot of thinking but this works for me:
void  TreeCtrl::Set(int id, const Image& img)
{
	Item& m = item[id];
//	if(m.ctrl) {    //Edit: in fact this dosn't work ?
		m.image = img;
		RefreshItem(id);
//	}
}


If there is no other way, maybe it would be good to have added something like above?
Also, question arises, how to add a series of images?

[Updated on: Sat, 08 April 2006 01:24]

Report message to a moderator

Re: TreeCtrl - how to change images dynamically? [message #2323 is a reply to message #2314] Sat, 08 April 2006 12:42 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 14105
Registered: November 2005
Ultimate Member
const Node& GetNode(int id) const;
void SetNode(int id, const Node& n);

What do you mean by "series of images"?

Mirek
Re: TreeCtrl - how to change images dynamically? [message #2331 is a reply to message #2323] Sat, 08 April 2006 13:00 Go to previous messageGo to next message
fudadmin is currently offline  fudadmin
Messages: 1321
Registered: November 2005
Location: Kaunas, Lithuania
Ultimate Contributor
Administrator
luzr wrote on Sat, 08 April 2006 11:42

const Node& GetNode(int id) const;
void SetNode(int id, const Node& n);

What do you mean by "series of images"?

Mirek


I had tried this unsuccessfully... That's why I asked.
	tree.SetNode(editid, tree.GetNode(editid).SetImage(CtrlImg::ImgEdit()));

E:\AriUppApps1\ideAris1\main.cpp(26) : error C2662: 'TreeCtrl::Node::SetImage' : cannot convert 'this' pointer from
'const TreeCtrl::Node' to 'TreeCtrl::Node &'
Re: TreeCtrl - how to change images dynamically? [message #2332 is a reply to message #2323] Sat, 08 April 2006 13:02 Go to previous messageGo to next message
fudadmin is currently offline  fudadmin
Messages: 1321
Registered: November 2005
Location: Kaunas, Lithuania
Ultimate Contributor
Administrator
luzr wrote on Sat, 08 April 2006 11:42


What do you mean by "series of images"?

Mirek


A row of images e.g Smile Smile Smile

[Updated on: Sat, 08 April 2006 13:02]

Report message to a moderator

Re: TreeCtrl - how to change images dynamically? [message #2335 is a reply to message #2331] Sat, 08 April 2006 14:05 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 14105
Registered: November 2005
Ultimate Member
fudadmin wrote on Sat, 08 April 2006 07:00

luzr wrote on Sat, 08 April 2006 11:42

const Node& GetNode(int id) const;
void SetNode(int id, const Node& n);

What do you mean by "series of images"?

Mirek


I had tried this unsuccessfully... That's why I asked.
	tree.SetNode(editid, tree.GetNode(editid).SetImage(CtrlImg::ImgEdit()));

E:\AriUppApps1\ideAris1\main.cpp(26) : error C2662: 'TreeCtrl::Node::SetImage' : cannot convert 'this' pointer from
'const TreeCtrl::Node' to 'TreeCtrl::Node &'



Ah... Well, one of rare cases when C++ does not play well...

Try

TreeCtrl::Node n = tree.GetNode(editid);
n.SetImage(CtrlImg::ImgEdit());
tree.SetNode(editid, n);


Thinking about it, it would probably be better here to return Node value instead of constant reference... what do you think? (Constant reference is faster, however in this case it is very likely you are about to change the value in most cases).

MIrek
Re: TreeCtrl - how to change images dynamically? [message #2337 is a reply to message #2335] Sat, 08 April 2006 15:09 Go to previous messageGo to next message
fudadmin is currently offline  fudadmin
Messages: 1321
Registered: November 2005
Location: Kaunas, Lithuania
Ultimate Contributor
Administrator
luzr wrote on Sat, 08 April 2006 13:05



I had tried this unsuccessfully... That's why I asked.
	tree.SetNode(editid, tree.GetNode(editid).SetImage(CtrlImg::ImgEdit()));

E:\AriUppApps1\ideAris1\main.cpp(26) : error C2662: 'TreeCtrl::Node::SetImage' : cannot convert 'this' pointer from
'const TreeCtrl::Node' to 'TreeCtrl::Node &'


Quote:


Ah... Well, one of rare cases when C++ does not play well...

Try

TreeCtrl::Node n = tree.GetNode(editid);
n.SetImage(CtrlImg::ImgEdit());
tree.SetNode(editid, n);


Thinking about it, it would probably be better here to return Node value instead of constant reference... what do you think? (Constant reference is faster, however in this case it is very likely you are about to change the value in most cases).

Mirek


It works this morning... I can't believe it didn't work yesterday Shocked ... Something magic. Maybe I was too tired and did a typo mistake once again somewhere. And I knew about that const... Smile
Anyway, thank you very much for confirming it because I was going mad and suspected bugs everywhere... Smile

And I couldn't understand the reason of not returning Node... but I have not much against const if it works... Laughing

[Updated on: Sat, 08 April 2006 15:11]

Report message to a moderator

Re: TreeCtrl - how to change images dynamically? [message #2339 is a reply to message #2337] Sat, 08 April 2006 16:33 Go to previous message
mirek is currently offline  mirek
Messages: 14105
Registered: November 2005
Ultimate Member
fudadmin wrote on Sat, 08 April 2006 09:09

luzr wrote on Sat, 08 April 2006 13:05



I had tried this unsuccessfully... That's why I asked.
	tree.SetNode(editid, tree.GetNode(editid).SetImage(CtrlImg::ImgEdit()));

E:\AriUppApps1\ideAris1\main.cpp(26) : error C2662: 'TreeCtrl::Node::SetImage' : cannot convert 'this' pointer from
'const TreeCtrl::Node' to 'TreeCtrl::Node &'


Quote:


Ah... Well, one of rare cases when C++ does not play well...

Try

TreeCtrl::Node n = tree.GetNode(editid);
n.SetImage(CtrlImg::ImgEdit());
tree.SetNode(editid, n);


Thinking about it, it would probably be better here to return Node value instead of constant reference... what do you think? (Constant reference is faster, however in this case it is very likely you are about to change the value in most cases).

Mirek


It works this morning... I can't believe it didn't work yesterday Shocked ... Something magic. Maybe I was too tired and did a typo mistake once again somewhere. And I knew about that const... Smile
Anyway, thank you very much for confirming it because I was going mad and suspected bugs everywhere... Smile

And I couldn't understand the reason of not returning Node... but I have not much against const if it works... Laughing


Well, I have changed it to return value instead of reference... so no more confusion there Smile

Mirek
Previous Topic: TreeCtrl - how to set horizontal grid? [NEEDS IMPLEMENTATION...]
Next Topic: Missing callback trigger in OptionTree? [SOLVED/FIXED]
Goto Forum:
  


Current Time: Fri Nov 01 00:35:42 CET 2024

Total time taken to generate the page: 0.01994 seconds