[wxTreeCtrl] what add my image from disk?
M Nealon
malcolm.nealon at gmail.com
Fri Nov 16 08:09:51 PST 2007
On Nov 16, 2007 1:21 PM, zeroDwa <trace02 at wupe.pl> wrote:
>
> What i can add image in wxTreeCtrl?
>
> I need a list?
> What I can change this image to other?
Instead of asking these questions (which are getting dangerously close
to "I want a program that does ... Can someone develop it for me?") it
would be an idea to take a long look at the TreeList example. It
already does what you want (in any case wrt images) and you could in
essence simply adapt that sample to do what you want.
Don't get the impression we/I don't want to help, you'll find that we
are a pretty aggreeable bunch here, almost always willing to help (I
have helped and been helped here personally) but if you'll pardon me
for saying so, this is a question that you should be able to figure
out for yourself by looking at the aforementioned sample, or (Deity
forbid) reading the help files.
You might also care to take a browse of the forum
(http://www.wxforum.shadonet.com), where there may be a quicker
response.
In any case take a look at the function
void MyTreeCtrl::CreateImageList(int size)
{
if ( size == -1 )
{
SetImageList(NULL);
return;
}
if ( size == 0 )
size = m_imageSize;
else
m_imageSize = size;
// Make an image list containing small icons
wxImageList *images = new wxImageList(size, size, true);
// should correspond to TreeCtrlIcon_xxx enum
wxBusyCursor wait;
wxIcon icons[5];
icons[0] = wxIcon(icon1_xpm);
icons[1] = wxIcon(icon2_xpm);
icons[2] = wxIcon(icon3_xpm);
icons[3] = wxIcon(icon4_xpm);
icons[4] = wxIcon(icon5_xpm);
int sizeOrig = icons[0].GetWidth();
for ( size_t i = 0; i < WXSIZEOF(icons); i++ )
{
if ( size == sizeOrig )
{
images->Add(icons[i]);
}
else
{
images->Add(wxBitmap(wxBitmap(icons[i]).ConvertToImage().Rescale(size,
size)));
}
}
AssignImageList(images);
}
within the treectrl sample. This shows how to implement an image list
for use by the treectrl. It might make a little more sense if
youchange the names of the images being used to reflect their purpose
(open_folder, closed_folder, file, selected_file,
selected_file_secondary_icon).
I hope this helps
Mal
More information about the wx-users
mailing list