1. Implemented support for different icons for different states (expanded,

selected, combination of them) for the tree control (and doc'd it)
2. removed code which was sending extra event if wxFrame::SetSize() was
   used
3. important changes to wxWizard interface
4. small compilation corrections


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@3756 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
1999-09-29 22:47:56 +00:00
parent 4f3ac40926
commit 74b31181b3
31 changed files with 936 additions and 353 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 246 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 318 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 318 B

After

Width:  |  Height:  |  Size: 318 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 246 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 318 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 246 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 318 B

View File

@@ -0,0 +1,45 @@
/* XPM */
static char *icon2_xpm[] = {
/* width height num_colors chars_per_pixel */
" 32 32 6 1",
/* colors */
". c #b2c0dc",
"# c #000000",
"a c #c0c0c0",
"b c #808080",
"c c #ffff00",
"d c #ffffff",
/* pixels */
"................................",
"................................",
"......bbbbbbbbbb................",
"......bbbbbbbbbb................",
"....bbccaaccaaccbb..............",
"....bbccaaccaaccbb..............",
"..bbccaaccaaccaaccbbbbbbbbbbbb..",
"..bbccaaccaaccaaccbbbbbbbbbbbb..",
"..bbddddddddddddddddddddddddbb##",
"..bbddddddddddddddddddddddddbb##",
"..bbddccaaccaaccaaccaaccaaccbb##",
"..bbddccaaccaaccaaccaaccaaccbb##",
"..bbddaaccaaccaaccaaccaaccaabb##",
"..bbddaaccaaccaaccaaccaaccaabb##",
"..bbddccaaccaaccaaccaaccaaccbb##",
"..bbddccaaccaaccaaccaaccaaccbb##",
"..bbddaaccaaccaaccaaccaaccaabb##",
"..bbddaaccaaccaaccaaccaaccaabb##",
"..bbddccaaccaaccaaccaaccaaccbb##",
"..bbddccaaccaaccaaccaaccaaccbb##",
"..bbddaaccaaccaaccaaccaaccaabb##",
"..bbddaaccaaccaaccaaccaaccaabb##",
"..bbddccaaccaaccaaccaaccaaccbb##",
"..bbddccaaccaaccaaccaaccaaccbb##",
"..bbbbbbbbbbbbbbbbbbbbbbbbbbbb##",
"..bbbbbbbbbbbbbbbbbbbbbbbbbbbb##",
"....############################",
"....############################",
"................................",
"................................",
"................................",
"................................"
};

View File

@@ -33,19 +33,19 @@
#include "math.h"
//#ifdef __WXMSW__
#ifdef __WXMSW__
#define NO_MULTIPLE_SELECTION
#define NO_VARIABLE_HEIGHT
//#endif
#endif
#include "treetest.h"
// under Windows the icons are in the .rc file
#ifndef __WXMSW__
#ifdef NO_VARIABLE_HEIGHT
#include "icon1.xpm"
#endif
#include "icon2.xpm"
#include "icon3.xpm"
#include "icon4.xpm"
#include "mondrian.xpm"
#endif
@@ -92,7 +92,9 @@ BEGIN_EVENT_TABLE(MyTreeCtrl, wxTreeCtrl)
EVT_TREE_BEGIN_LABEL_EDIT(TreeTest_Ctrl, MyTreeCtrl::OnBeginLabelEdit)
EVT_TREE_END_LABEL_EDIT(TreeTest_Ctrl, MyTreeCtrl::OnEndLabelEdit)
EVT_TREE_DELETE_ITEM(TreeTest_Ctrl, MyTreeCtrl::OnDeleteItem)
#if 0 // there are so many of those that logging them causes flicker
EVT_TREE_GET_INFO(TreeTest_Ctrl, MyTreeCtrl::OnGetInfo)
#endif
EVT_TREE_SET_INFO(TreeTest_Ctrl, MyTreeCtrl::OnSetInfo)
EVT_TREE_ITEM_EXPANDED(TreeTest_Ctrl, MyTreeCtrl::OnItemExpanded)
EVT_TREE_ITEM_EXPANDING(TreeTest_Ctrl, MyTreeCtrl::OnItemExpanding)
@@ -187,12 +189,12 @@ MyFrame::MyFrame(const wxString& title, int x, int y, int w, int h)
wxTR_HAS_BUTTONS |
wxTR_EDIT_LABELS |
#ifndef NO_MULTIPLE_SELECTION
wxTR_MULTIPLE |
wxTR_MULTIPLE |
#endif
#ifndef NO_VARIABLE_HEIGHT
wxTR_HAS_VARIABLE_ROW_HEIGHT |
wxTR_HAS_VARIABLE_ROW_HEIGHT |
#endif
wxSUNKEN_BORDER);
wxSUNKEN_BORDER);
wxTextCtrl *textCtrl = new wxTextCtrl(this, -1, "",
wxDefaultPosition, wxDefaultSize,
wxTE_MULTILINE | wxSUNKEN_BORDER);
@@ -440,6 +442,9 @@ MyTreeCtrl::MyTreeCtrl(wxWindow *parent, const wxWindowID id,
m_imageListNormal->Add(wxBitmap("bitmap1", wxBITMAP_TYPE_BMP_RESOURCE));
# endif
m_imageListNormal->Add(wxBitmap("bitmap2", wxBITMAP_TYPE_BMP_RESOURCE));
m_imageListNormal->Add(wxBitmap("bitmap3", wxBITMAP_TYPE_BMP_RESOURCE));
m_imageListNormal->Add(wxBitmap("bitmap4", wxBITMAP_TYPE_BMP_RESOURCE));
m_imageListNormal->Add(wxBitmap("bitmap5", wxBITMAP_TYPE_BMP_RESOURCE));
#else
# ifndef NO_VARIABLE_HEIGHT
m_imageListNormal->Add(image.ConvertToBitmap());
@@ -447,6 +452,9 @@ MyTreeCtrl::MyTreeCtrl(wxWindow *parent, const wxWindowID id,
m_imageListNormal->Add(wxICON(icon1));
# endif
m_imageListNormal->Add(wxICON(icon2));
m_imageListNormal->Add(wxICON(icon3));
m_imageListNormal->Add(wxICON(icon4));
m_imageListNormal->Add(wxICON(icon5));
#endif
SetImageList(m_imageListNormal);
@@ -481,21 +489,32 @@ void MyTreeCtrl::AddItemsRecursively(const wxTreeItemId& idParent,
{
if ( depth > 0 )
{
bool hasChildren = depth > 1;
wxString str;
for ( size_t n = 0; n < numChildren; n++ )
{
// at depth 1 elements won't have any more children
if (depth == 1)
str.Printf("%s child %d.%d", "File", folder, n + 1);
else
if ( hasChildren )
str.Printf("%s child %d", "Folder", n + 1);
else
str.Printf("%s child %d.%d", "File", folder, n + 1);
// here we pass to AppendItem() normal and selected item images (we
// suppose that selected image follows the normal one in the enum)
int image = depth == 1 ? TreeCtrlIcon_File : TreeCtrlIcon_Folder;
wxTreeItemId id = AppendItem(idParent, str, image, image,
wxTreeItemId id = AppendItem(idParent, str, image, image + 1,
new MyTreeItemData(str));
// and now we also set the expanded one (only for the folders)
if ( hasChildren )
{
SetItemImage(id, TreeCtrlIcon_FolderOpened,
wxTreeItemIcon_Expanded);
}
// remember the last child for OnEnsureVisible()
if ( depth == 1 && n == numChildren - 1 )
if ( !hasChildren && n == numChildren - 1 )
{
m_lastItem = id;
}
@@ -512,6 +531,7 @@ void MyTreeCtrl::AddTestItemsToTree(size_t numChildren,
wxTreeItemId rootId = AddRoot("Root",
TreeCtrlIcon_Folder, TreeCtrlIcon_Folder,
new MyTreeItemData("Root item"));
SetItemImage(rootId, TreeCtrlIcon_FolderOpened, wxTreeItemIcon_Expanded);
AddItemsRecursively(rootId, numChildren, depth, 0);
}

View File

@@ -34,7 +34,10 @@ public:
enum
{
TreeCtrlIcon_File,
TreeCtrlIcon_Folder
TreeCtrlIcon_FileSelected,
TreeCtrlIcon_Folder,
TreeCtrlIcon_FolderSelected,
TreeCtrlIcon_FolderOpened
};
MyTreeCtrl() { }

View File

@@ -1,10 +1,17 @@
mondrian ICON "mondrian.ico"
aaaa ICON "mondrian.ico"
#include "wx/msw/wx.rc"
icon1 ICON "bitmaps\\file1.ico"
icon2 ICON "bitmaps\\folder1.ico"
icon2 ICON "bitmaps\\file2.ico"
icon3 ICON "bitmaps\\folder1.ico"
icon4 ICON "bitmaps\\folder2.ico"
icon5 ICON "bitmaps\\folder3.ico"
bitmap1 BITMAP "bitmaps\\file1.bmp"
bitmap2 BITMAP "bitmaps\\folder1.bmp"
bitmap2 BITMAP "bitmaps\\file2.bmp"
bitmap3 BITMAP "bitmaps\\folder1.bmp"
bitmap4 BITMAP "bitmaps\\folder2.bmp"
bitmap5 BITMAP "bitmaps\\folder3.bmp"