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 - changing plus/minus images
TreeCtrl - changing plus/minus images [message #16971] Wed, 23 July 2008 22:45 Go to next message
rsrado is currently offline  rsrado
Messages: 1
Registered: July 2008
Location: Bulgaria
Junior Member
I would like to be able to set the plus/minus images to something different than CtrlImg::treeplus() and CtrlImg::treeminus(), in order to achieve some different look and feel.

I tried to find an easy way to do it, but as I couldn't, I made a small modification to the class:

In TreeCtrl.h:
class TreeCtrl : public Ctrl {
...
private:
    Image plusimage, minusimage;
...
public:
     	TreeCtrl& PlusImage(const Image& img)    { plusimage = img; return *this; }
	TreeCtrl& MinusImage(const Image& img)   { minusimage = img; return *this; }
...
}


In TreeCtrl.cpp:
TreeCtrl::TreeCtrl() {
...
	plusimage = CtrlImg::treeplus();
	minusimage = CtrlImg::treeminus();
...
}
...
void TreeCtrl::Paint(Draw& w)
{
....
      //ORIGINAL CODE: Image im = m.isopen ? CtrlImg::treeminus() : CtrlImg::treeplus();
      //REPLACED WITH:
      Image im = m.isopen ? minusimage : plusimage;
...


That worked just fine for me. I would be glad, to know if there is a better way and even more, if this helps somebody in some way.


Re: TreeCtrl - changing plus/minus images [message #16972 is a reply to message #16971] Wed, 23 July 2008 22:55 Go to previous messageGo to next message
unodgs is currently offline  unodgs
Messages: 1353
Registered: November 2005
Location: Poland
Senior Contributor

I think it should be done via Style structure.
Re: TreeCtrl - changing plus/minus images [message #16974 is a reply to message #16972] Thu, 24 July 2008 00:16 Go to previous messageGo to next message
mrjt is currently offline  mrjt
Messages: 705
Registered: March 2007
Location: London
Contributor
You can do this with two lines anywhere in the App:
		CtrlImg::Set(CtrlImg::I_treeplus, Image::Arrow());
		CtrlImg::Set(CtrlImg::I_treeminus, Image::Arrow());

Obviously use some sort of sensible image instead Smile
Re: TreeCtrl - changing plus/minus images [message #17039 is a reply to message #16972] Sat, 26 July 2008 12:05 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 11700
Registered: November 2005
Ultimate Member
unodgs wrote on Wed, 23 July 2008 16:55

I think it should be done via Style structure.


Definitely..

Mirek
Re: TreeCtrl - changing plus/minus images [message #28242 is a reply to message #17039] Wed, 25 August 2010 07:13 Go to previous messageGo to next message
Novo is currently offline  Novo
Messages: 706
Registered: December 2006
Contributor
luzr wrote on Sat, 26 July 2008 06:05

unodgs wrote on Wed, 23 July 2008 16:55

I think it should be done via Style structure.


Definitely..

Mirek


I'm sorry, but where is Style located in the TreeCtrl?


Regards,
Novo

[Updated on: Wed, 25 August 2010 07:15]

Report message to a moderator

Re: TreeCtrl - changing plus/minus images [message #28249 is a reply to message #28242] Wed, 25 August 2010 09:27 Go to previous message
cbpporter is currently offline  cbpporter
Messages: 1336
Registered: September 2007
Senior Contributor
Novo wrote on Wed, 25 August 2010 08:13

luzr wrote on Sat, 26 July 2008 06:05

unodgs wrote on Wed, 23 July 2008 16:55

I think it should be done via Style structure.


Definitely..

Mirek


I'm sorry, but where is Style located in the TreeCtrl?


It is not located. It was just an idea that did not get implemented. You can use what mrjt said:
CtrlImg::Set(CtrlImg::I_treeplus, Image::Arrow());
CtrlImg::Set(CtrlImg::I_treeminus, Image::Arrow());

but this will replace the image for all the TreeCtrls.
Previous Topic: Drag'nDrop on an OptionTree
Next Topic: Basic query: id, key and value in a TreeCtrl.
Goto Forum:
  


Current Time: Sat Feb 16 12:07:05 CET 2019

Total time taken to generate the page: 0.00644 seconds