Home » U++ Library support » TreeCtrl » TreeCtrl - changing plus/minus images
TreeCtrl - changing plus/minus images [message #16971] |
Wed, 23 July 2008 22:45  |
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 #28249 is a reply to message #28242] |
Wed, 25 August 2010 09:27  |
cbpporter
Messages: 1427 Registered: September 2007
|
Ultimate 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.
|
|
|
Goto Forum:
Current Time: Fri Apr 25 20:30:14 CEST 2025
Total time taken to generate the page: 0.00917 seconds
|