wxTreeCtrl has colours and fonts too now
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@4839 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -20,7 +20,9 @@ all (GUI):
|
|||||||
- wxMenu(Bar)::Insert() and Remove() functions for dynamic menu menagament
|
- wxMenu(Bar)::Insert() and Remove() functions for dynamic menu menagament
|
||||||
- wxToolBar supports arbitrary controls (not only buttons) and can be
|
- wxToolBar supports arbitrary controls (not only buttons) and can be
|
||||||
dynamically changed (Delete/Insert functions)
|
dynamically changed (Delete/Insert functions)
|
||||||
- wxListCtrl allows setting colour/fonts for individual items
|
- wxTreeCtrl and wxListCtrl allow setting colour/fonts for individual items
|
||||||
|
- "file open" dialog allows selecting multiple files at once (contributed by
|
||||||
|
John Norris)
|
||||||
- wxDC::DrawRotatedText() (contributed by Hans-Joachim Baader, limited to
|
- wxDC::DrawRotatedText() (contributed by Hans-Joachim Baader, limited to
|
||||||
+/-90 degrees for now - contributions to improve it are welcome!)
|
+/-90 degrees for now - contributions to improve it are welcome!)
|
||||||
|
|
||||||
@@ -28,6 +30,7 @@ wxMSW:
|
|||||||
|
|
||||||
- wxTreeCtrl::IsVisible() bug fixed (thanks to Gary Chessun)
|
- wxTreeCtrl::IsVisible() bug fixed (thanks to Gary Chessun)
|
||||||
- tooltips work with wxRadioBox
|
- tooltips work with wxRadioBox
|
||||||
|
- returning FALSE from OnPrintPage() aborts printing
|
||||||
|
|
||||||
wxGTK:
|
wxGTK:
|
||||||
|
|
||||||
|
@@ -530,6 +530,12 @@ Sets the indentation for the tree control.
|
|||||||
|
|
||||||
Sets the normal image list.
|
Sets the normal image list.
|
||||||
|
|
||||||
|
\membersection{wxTreeCtrl::SetItemBackgroundColour}\label{wxtreectrlsetitembackgroundcolour}
|
||||||
|
|
||||||
|
\func{void}{SetItemBackgroundColour}{\param{const wxTreeItemId\&}{ item}, \param{const wxColour\& }{col}}
|
||||||
|
|
||||||
|
Sets the colour of the items background.
|
||||||
|
|
||||||
\membersection{wxTreeCtrl::SetItemBold}\label{wxtreectrlsetitembold}
|
\membersection{wxTreeCtrl::SetItemBold}\label{wxtreectrlsetitembold}
|
||||||
|
|
||||||
\func{void}{SetItemBold}{\param{const wxTreeItemId\& }{item}, \param{bool}{ bold = TRUE}}
|
\func{void}{SetItemBold}{\param{const wxTreeItemId\& }{item}, \param{bool}{ bold = TRUE}}
|
||||||
@@ -552,6 +558,18 @@ Object with the wxTreeItemData for the given item Id.}
|
|||||||
\end{twocollist}}
|
\end{twocollist}}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
\membersection{wxTreeCtrl::SetItemFont}\label{wxtreectrlsetitemfont}
|
||||||
|
|
||||||
|
\func{void}{SetItemFont}{\param{const wxTreeItemId\&}{ item}, \param{const wxFont\& }{font}}
|
||||||
|
|
||||||
|
Sets the items font. All items in the tree should have the same height to avoid
|
||||||
|
text clipping, so the fonts height should be the same for all of them,
|
||||||
|
although font attributes may vary.
|
||||||
|
|
||||||
|
\wxheading{See also}
|
||||||
|
|
||||||
|
\helpref{SetItemBold}{wxtreectrlsetitembold}
|
||||||
|
|
||||||
\membersection{wxTreeCtrl::SetItemHasChildren}\label{wxtreectrlsetitemhaschildren}
|
\membersection{wxTreeCtrl::SetItemHasChildren}\label{wxtreectrlsetitemhaschildren}
|
||||||
|
|
||||||
\func{void}{SetItemHasChildren}{\param{const wxTreeItemId\&}{ item}, \param{bool }{hasChildren = TRUE}}
|
\func{void}{SetItemHasChildren}{\param{const wxTreeItemId\&}{ item}, \param{bool }{hasChildren = TRUE}}
|
||||||
@@ -583,6 +601,12 @@ Sets the selected item image (this function is obsolete, use
|
|||||||
|
|
||||||
Sets the item label.
|
Sets the item label.
|
||||||
|
|
||||||
|
\membersection{wxTreeCtrl::SetItemTextColour}\label{wxtreectrlsetitemtextcolour}
|
||||||
|
|
||||||
|
\func{void}{SetItemTextColour}{\param{const wxTreeItemId\&}{ item}, \param{const wxColour\& }{col}}
|
||||||
|
|
||||||
|
Sets the colour of the items text.
|
||||||
|
|
||||||
\membersection{wxTreeCtrl::SetStateImageList}\label{wxtreectrlsetstateimagelist}
|
\membersection{wxTreeCtrl::SetStateImageList}\label{wxtreectrlsetstateimagelist}
|
||||||
|
|
||||||
\func{void}{SetStateImageList}{\param{wxImageList*}{ imageList}}
|
\func{void}{SetStateImageList}{\param{wxImageList*}{ imageList}}
|
||||||
|
@@ -16,12 +16,6 @@
|
|||||||
#pragma interface "treectrl.h"
|
#pragma interface "treectrl.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef __WXMSW__
|
|
||||||
WXDLLEXPORT_DATA(extern const char*) wxTreeCtrlNameStr;
|
|
||||||
#else
|
|
||||||
#define wxTreeCtrlNameStr "wxTreeCtrl"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "wx/defs.h"
|
#include "wx/defs.h"
|
||||||
#include "wx/string.h"
|
#include "wx/string.h"
|
||||||
#include "wx/object.h"
|
#include "wx/object.h"
|
||||||
@@ -32,51 +26,6 @@ WXDLLEXPORT_DATA(extern const char*) wxTreeCtrlNameStr;
|
|||||||
#include "wx/dynarray.h"
|
#include "wx/dynarray.h"
|
||||||
#include "wx/timer.h"
|
#include "wx/timer.h"
|
||||||
|
|
||||||
//those defines should only be done in generic/treectrl.h,
|
|
||||||
//because wxMSW doesn't allow mutiple selection
|
|
||||||
|
|
||||||
#ifndef wxTR_SINGLE
|
|
||||||
#define wxTR_SINGLE 0x0000
|
|
||||||
#define wxTR_MULTIPLE 0x0020
|
|
||||||
#define wxTR_EXTENDED 0x0040
|
|
||||||
#define wxTR_HAS_VARIABLE_ROW_HIGHT 0x0080
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
|
||||||
// constants
|
|
||||||
// -----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
// values for the `flags' parameter of wxTreeCtrl::HitTest() which determine
|
|
||||||
// where exactly the specified point is situated:
|
|
||||||
|
|
||||||
static const int wxTREE_HITTEST_ABOVE = 0x0001;
|
|
||||||
static const int wxTREE_HITTEST_BELOW = 0x0002;
|
|
||||||
static const int wxTREE_HITTEST_NOWHERE = 0x0004;
|
|
||||||
// on the button associated with an item.
|
|
||||||
static const int wxTREE_HITTEST_ONITEMBUTTON = 0x0008;
|
|
||||||
// on the bitmap associated with an item.
|
|
||||||
static const int wxTREE_HITTEST_ONITEMICON = 0x0010;
|
|
||||||
// on the ident associated with an item.
|
|
||||||
static const int wxTREE_HITTEST_ONITEMIDENT = 0x0020;
|
|
||||||
// on the label (string) associated with an item.
|
|
||||||
static const int wxTREE_HITTEST_ONITEMLABEL = 0x0040;
|
|
||||||
// on the right of the label associated with an item.
|
|
||||||
static const int wxTREE_HITTEST_ONITEMRIGHT = 0x0080;
|
|
||||||
// on the label (string) associated with an item.
|
|
||||||
//static const int wxTREE_HITTEST_ONITEMSTATEICON = 0x0100;
|
|
||||||
// on the left of the wxTreeCtrl.
|
|
||||||
static const int wxTREE_HITTEST_TOLEFT = 0x0200;
|
|
||||||
// on the right of the wxTreeCtrl.
|
|
||||||
static const int wxTREE_HITTEST_TORIGHT = 0x0400;
|
|
||||||
// on the upper part (first half) of the item.
|
|
||||||
static const int wxTREE_HITTEST_ONITEMUPPERPART = 0x0800;
|
|
||||||
// on the lower part (second half) of the item.
|
|
||||||
static const int wxTREE_HITTEST_ONITEMLOWERPART = 0x1000;
|
|
||||||
|
|
||||||
// anywhere on the item
|
|
||||||
static const int wxTREE_HITTEST_ONITEM = wxTREE_HITTEST_ONITEMICON |
|
|
||||||
wxTREE_HITTEST_ONITEMLABEL;
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
// forward declaration
|
// forward declaration
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
@@ -181,8 +130,9 @@ class WXDLLEXPORT wxTreeTextCtrl: public wxTextCtrl
|
|||||||
bool *accept, wxString *res, wxTreeCtrl *owner,
|
bool *accept, wxString *res, wxTreeCtrl *owner,
|
||||||
const wxString &value = wxEmptyString,
|
const wxString &value = wxEmptyString,
|
||||||
const wxPoint &pos = wxDefaultPosition, const wxSize &size = wxDefaultSize,
|
const wxPoint &pos = wxDefaultPosition, const wxSize &size = wxDefaultSize,
|
||||||
|
int style = 0,
|
||||||
#if wxUSE_VALIDATORS
|
#if wxUSE_VALIDATORS
|
||||||
int style = 0, const wxValidator& validator = wxDefaultValidator,
|
const wxValidator& validator = wxDefaultValidator,
|
||||||
#endif
|
#endif
|
||||||
const wxString &name = wxTextCtrlNameStr );
|
const wxString &name = wxTextCtrlNameStr );
|
||||||
void OnChar( wxKeyEvent &event );
|
void OnChar( wxKeyEvent &event );
|
||||||
@@ -290,6 +240,15 @@ public:
|
|||||||
// the item will be shown in bold
|
// the item will be shown in bold
|
||||||
void SetItemBold(const wxTreeItemId& item, bool bold = TRUE);
|
void SetItemBold(const wxTreeItemId& item, bool bold = TRUE);
|
||||||
|
|
||||||
|
// set the items text colour
|
||||||
|
void SetItemTextColour(const wxTreeItemId& item, const wxColour& col);
|
||||||
|
|
||||||
|
// set the items background colour
|
||||||
|
void SetItemBackgroundColour(const wxTreeItemId& item, const wxColour& col);
|
||||||
|
|
||||||
|
// set the items font (should be of the same height for all items)
|
||||||
|
void SetItemFont(const wxTreeItemId& item, const wxFont& font);
|
||||||
|
|
||||||
// item status inquiries
|
// item status inquiries
|
||||||
// ---------------------
|
// ---------------------
|
||||||
|
|
||||||
|
@@ -41,39 +41,6 @@ struct WXDLLEXPORT wxTreeViewItem;
|
|||||||
// they're equivalent
|
// they're equivalent
|
||||||
class wxTreeItemData;
|
class wxTreeItemData;
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
|
||||||
// constants
|
|
||||||
// ----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
// values for the `flags' parameter of wxTreeCtrl::HitTest() which determine
|
|
||||||
// where exactly the specified point is situated:
|
|
||||||
// above the client area.
|
|
||||||
static const int wxTREE_HITTEST_ABOVE = 0x0001;
|
|
||||||
// below the client area.
|
|
||||||
static const int wxTREE_HITTEST_BELOW = 0x0002;
|
|
||||||
// in the client area but below the last item.
|
|
||||||
static const int wxTREE_HITTEST_NOWHERE = 0x0004;
|
|
||||||
// on the button associated with an item.
|
|
||||||
static const int wxTREE_HITTEST_ONITEMBUTTON = 0x0010;
|
|
||||||
// on the bitmap associated with an item.
|
|
||||||
static const int wxTREE_HITTEST_ONITEMICON = 0x0020;
|
|
||||||
// in the indentation associated with an item.
|
|
||||||
static const int wxTREE_HITTEST_ONITEMINDENT = 0x0040;
|
|
||||||
// on the label (string) associated with an item.
|
|
||||||
static const int wxTREE_HITTEST_ONITEMLABEL = 0x0080;
|
|
||||||
// in the area to the right of an item.
|
|
||||||
static const int wxTREE_HITTEST_ONITEMRIGHT = 0x0100;
|
|
||||||
// on the state icon for a tree view item that is in a user-defined state.
|
|
||||||
static const int wxTREE_HITTEST_ONITEMSTATEICON = 0x0200;
|
|
||||||
// to the right of the client area.
|
|
||||||
static const int wxTREE_HITTEST_TOLEFT = 0x0400;
|
|
||||||
// to the left of the client area.
|
|
||||||
static const int wxTREE_HITTEST_TORIGHT = 0x0800;
|
|
||||||
// anywhere on the item
|
|
||||||
static const int wxTREE_HITTEST_ONITEM = wxTREE_HITTEST_ONITEMICON |
|
|
||||||
wxTREE_HITTEST_ONITEMLABEL |
|
|
||||||
wxTREE_HITTEST_ONITEMSTATEICON;
|
|
||||||
|
|
||||||
// NB: all the following flags are for compatbility only and will be removed in the
|
// NB: all the following flags are for compatbility only and will be removed in the
|
||||||
// next versions
|
// next versions
|
||||||
|
|
||||||
@@ -253,6 +220,15 @@ public:
|
|||||||
// the item will be shown with a drop highlight
|
// the item will be shown with a drop highlight
|
||||||
void SetItemDropHighlight(const wxTreeItemId& item, bool highlight = TRUE);
|
void SetItemDropHighlight(const wxTreeItemId& item, bool highlight = TRUE);
|
||||||
|
|
||||||
|
// set the items text colour
|
||||||
|
void SetItemTextColour(const wxTreeItemId& item, const wxColour& col);
|
||||||
|
|
||||||
|
// set the items background colour
|
||||||
|
void SetItemBackgroundColour(const wxTreeItemId& item, const wxColour& col);
|
||||||
|
|
||||||
|
// set the items font (should be of the same height for all items)
|
||||||
|
void SetItemFont(const wxTreeItemId& item, const wxFont& font);
|
||||||
|
|
||||||
// item status inquiries
|
// item status inquiries
|
||||||
// ---------------------
|
// ---------------------
|
||||||
|
|
||||||
|
@@ -22,12 +22,74 @@ enum wxTreeItemIcon
|
|||||||
wxTreeItemIcon_Max
|
wxTreeItemIcon_Max
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// values for the `flags' parameter of wxTreeCtrl::HitTest() which determine
|
||||||
|
// where exactly the specified point is situated:
|
||||||
|
|
||||||
|
static const int wxTREE_HITTEST_ABOVE = 0x0001;
|
||||||
|
static const int wxTREE_HITTEST_BELOW = 0x0002;
|
||||||
|
static const int wxTREE_HITTEST_NOWHERE = 0x0004;
|
||||||
|
// on the button associated with an item.
|
||||||
|
static const int wxTREE_HITTEST_ONITEMBUTTON = 0x0008;
|
||||||
|
// on the bitmap associated with an item.
|
||||||
|
static const int wxTREE_HITTEST_ONITEMICON = 0x0010;
|
||||||
|
// on the ident associated with an item.
|
||||||
|
static const int wxTREE_HITTEST_ONITEMIDENT = 0x0020;
|
||||||
|
// on the label (string) associated with an item.
|
||||||
|
static const int wxTREE_HITTEST_ONITEMLABEL = 0x0040;
|
||||||
|
// on the right of the label associated with an item.
|
||||||
|
static const int wxTREE_HITTEST_ONITEMRIGHT = 0x0080;
|
||||||
|
// on the label (string) associated with an item.
|
||||||
|
//static const int wxTREE_HITTEST_ONITEMSTATEICON = 0x0100;
|
||||||
|
// on the left of the wxTreeCtrl.
|
||||||
|
static const int wxTREE_HITTEST_TOLEFT = 0x0200;
|
||||||
|
// on the right of the wxTreeCtrl.
|
||||||
|
static const int wxTREE_HITTEST_TORIGHT = 0x0400;
|
||||||
|
// on the upper part (first half) of the item.
|
||||||
|
static const int wxTREE_HITTEST_ONITEMUPPERPART = 0x0800;
|
||||||
|
// on the lower part (second half) of the item.
|
||||||
|
static const int wxTREE_HITTEST_ONITEMLOWERPART = 0x1000;
|
||||||
|
|
||||||
|
// anywhere on the item
|
||||||
|
static const int wxTREE_HITTEST_ONITEM = wxTREE_HITTEST_ONITEMICON |
|
||||||
|
wxTREE_HITTEST_ONITEMLABEL;
|
||||||
|
|
||||||
// tree ctrl default name
|
// tree ctrl default name
|
||||||
#ifdef __WXMSW__
|
WXDLLEXPORT_DATA(extern const char*) wxTreeCtrlNameStr;
|
||||||
WXDLLEXPORT_DATA(extern const char*) wxTreeCtrlNameStr;
|
|
||||||
#else
|
// ----------------------------------------------------------------------------
|
||||||
#define wxTreeCtrlNameStr "wxTreeCtrl"
|
// wxTreeItemAttr: a structure containing the visual attributes of an item
|
||||||
#endif
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
class WXDLLEXPORT wxTreeItemAttr
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
// ctors
|
||||||
|
wxTreeItemAttr() { }
|
||||||
|
wxTreeItemAttr(const wxColour& colText,
|
||||||
|
const wxColour& colBack,
|
||||||
|
const wxFont& font)
|
||||||
|
: m_colText(colText), m_colBack(colBack), m_font(font) { }
|
||||||
|
|
||||||
|
// setters
|
||||||
|
void SetTextColour(const wxColour& colText) { m_colText = colText; }
|
||||||
|
void SetBackgroundColour(const wxColour& colBack) { m_colBack = colBack; }
|
||||||
|
void SetFont(const wxFont& font) { m_font = font; }
|
||||||
|
|
||||||
|
// accessors
|
||||||
|
bool HasTextColour() const { return m_colText.Ok(); }
|
||||||
|
bool HasBackgroundColour() const { return m_colBack.Ok(); }
|
||||||
|
bool HasFont() const { return m_font.Ok(); }
|
||||||
|
|
||||||
|
const wxColour& GetTextColour() const { return m_colText; }
|
||||||
|
const wxColour& GetBackgroundColour() const { return m_colBack; }
|
||||||
|
const wxFont& GetFont() const { return m_font; }
|
||||||
|
|
||||||
|
private:
|
||||||
|
wxColour m_colText,
|
||||||
|
m_colBack;
|
||||||
|
wxFont m_font;
|
||||||
|
};
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
// include the platform-dependent wxTreeCtrl class
|
// include the platform-dependent wxTreeCtrl class
|
||||||
|
@@ -565,6 +565,18 @@ void MyTreeCtrl::AddTestItemsToTree(size_t numChildren,
|
|||||||
SetItemImage(rootId, TreeCtrlIcon_FolderOpened, wxTreeItemIcon_Expanded);
|
SetItemImage(rootId, TreeCtrlIcon_FolderOpened, wxTreeItemIcon_Expanded);
|
||||||
|
|
||||||
AddItemsRecursively(rootId, numChildren, depth, 0);
|
AddItemsRecursively(rootId, numChildren, depth, 0);
|
||||||
|
|
||||||
|
// set some colours/fonts for testing
|
||||||
|
SetItemFont(rootId, *wxITALIC_FONT);
|
||||||
|
|
||||||
|
long cookie;
|
||||||
|
wxTreeItemId id = GetFirstChild(rootId, cookie);
|
||||||
|
SetItemTextColour(id, *wxBLUE);
|
||||||
|
|
||||||
|
id = GetNextChild(rootId, cookie);
|
||||||
|
id = GetNextChild(rootId, cookie);
|
||||||
|
SetItemTextColour(id, *wxRED);
|
||||||
|
SetItemBackgroundColour(id, *wxLIGHT_GREY);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MyTreeCtrl::GetItemsRecursively(const wxTreeItemId& idParent, long cookie)
|
void MyTreeCtrl::GetItemsRecursively(const wxTreeItemId& idParent, long cookie)
|
||||||
|
@@ -691,6 +691,9 @@
|
|||||||
/* Define if you have strtok_r function. */
|
/* Define if you have strtok_r function. */
|
||||||
#undef HAVE_STRTOK_R
|
#undef HAVE_STRTOK_R
|
||||||
|
|
||||||
|
/* Define if you have thr_setconcurrency function */
|
||||||
|
#undef HaVE_THR_SETCONCURRENCY
|
||||||
|
|
||||||
/* Define if you have the uname function. */
|
/* Define if you have the uname function. */
|
||||||
#undef HAVE_UNAME
|
#undef HAVE_UNAME
|
||||||
|
|
||||||
|
@@ -61,106 +61,121 @@ static const int NO_IMAGE = -1;
|
|||||||
class WXDLLEXPORT wxGenericTreeItem
|
class WXDLLEXPORT wxGenericTreeItem
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
// ctors & dtor
|
// ctors & dtor
|
||||||
wxGenericTreeItem() { m_data = NULL; }
|
wxGenericTreeItem() { m_data = NULL; }
|
||||||
wxGenericTreeItem( wxGenericTreeItem *parent,
|
wxGenericTreeItem( wxGenericTreeItem *parent,
|
||||||
const wxString& text,
|
const wxString& text,
|
||||||
wxDC& dc,
|
wxDC& dc,
|
||||||
int image, int selImage,
|
int image, int selImage,
|
||||||
wxTreeItemData *data );
|
wxTreeItemData *data );
|
||||||
|
|
||||||
~wxGenericTreeItem();
|
~wxGenericTreeItem();
|
||||||
|
|
||||||
// trivial accessors
|
// trivial accessors
|
||||||
wxArrayGenericTreeItems& GetChildren() { return m_children; }
|
wxArrayGenericTreeItems& GetChildren() { return m_children; }
|
||||||
|
|
||||||
const wxString& GetText() const { return m_text; }
|
const wxString& GetText() const { return m_text; }
|
||||||
int GetImage(wxTreeItemIcon which = wxTreeItemIcon_Normal) const
|
int GetImage(wxTreeItemIcon which = wxTreeItemIcon_Normal) const
|
||||||
{ return m_images[which]; }
|
{ return m_images[which]; }
|
||||||
wxTreeItemData *GetData() const { return m_data; }
|
wxTreeItemData *GetData() const { return m_data; }
|
||||||
|
|
||||||
// returns the current image for the item (depending on its
|
// returns the current image for the item (depending on its
|
||||||
// selected/expanded/whatever state)
|
// selected/expanded/whatever state)
|
||||||
int GetCurrentImage() const;
|
int GetCurrentImage() const;
|
||||||
|
|
||||||
void SetText( const wxString &text );
|
void SetText( const wxString &text );
|
||||||
void SetImage(int image, wxTreeItemIcon which) { m_images[which] = image; }
|
void SetImage(int image, wxTreeItemIcon which) { m_images[which] = image; }
|
||||||
void SetData(wxTreeItemData *data) { m_data = data; }
|
void SetData(wxTreeItemData *data) { m_data = data; }
|
||||||
|
|
||||||
void SetHasPlus(bool has = TRUE) { m_hasPlus = has; }
|
void SetHasPlus(bool has = TRUE) { m_hasPlus = has; }
|
||||||
|
|
||||||
void SetBold(bool bold) { m_isBold = bold; }
|
void SetBold(bool bold) { m_isBold = bold; }
|
||||||
|
|
||||||
int GetX() const { return m_x; }
|
int GetX() const { return m_x; }
|
||||||
int GetY() const { return m_y; }
|
int GetY() const { return m_y; }
|
||||||
|
|
||||||
void SetX(int x) { m_x = x; }
|
void SetX(int x) { m_x = x; }
|
||||||
void SetY(int y) { m_y = y; }
|
void SetY(int y) { m_y = y; }
|
||||||
|
|
||||||
int GetHeight() const { return m_height; }
|
int GetHeight() const { return m_height; }
|
||||||
int GetWidth() const { return m_width; }
|
int GetWidth() const { return m_width; }
|
||||||
|
|
||||||
void SetHeight(int h) { m_height = h; }
|
void SetHeight(int h) { m_height = h; }
|
||||||
void SetWidth(int w) { m_width = w; }
|
void SetWidth(int w) { m_width = w; }
|
||||||
|
|
||||||
|
|
||||||
wxGenericTreeItem *GetParent() const { return m_parent; }
|
wxGenericTreeItem *GetParent() const { return m_parent; }
|
||||||
|
|
||||||
// operations
|
// operations
|
||||||
// deletes all children notifying the treectrl about it if !NULL pointer
|
// deletes all children notifying the treectrl about it if !NULL
|
||||||
// given
|
// pointer given
|
||||||
void DeleteChildren(wxTreeCtrl *tree = NULL);
|
void DeleteChildren(wxTreeCtrl *tree = NULL);
|
||||||
// FIXME don't know what is it for
|
// FIXME don't know what is it for
|
||||||
void Reset();
|
void Reset();
|
||||||
|
|
||||||
// get count of all children (and grand children if 'recursively')
|
// get count of all children (and grand children if 'recursively')
|
||||||
size_t GetChildrenCount(bool recursively = TRUE) const;
|
size_t GetChildrenCount(bool recursively = TRUE) const;
|
||||||
|
|
||||||
void Insert(wxGenericTreeItem *child, size_t index)
|
void Insert(wxGenericTreeItem *child, size_t index)
|
||||||
{ m_children.Insert(child, index); }
|
{ m_children.Insert(child, index); }
|
||||||
|
|
||||||
void SetCross( int x, int y );
|
void SetCross( int x, int y );
|
||||||
void GetSize( int &x, int &y, const wxTreeCtrl* );
|
void GetSize( int &x, int &y, const wxTreeCtrl* );
|
||||||
|
|
||||||
// return the item at given position (or NULL if no item), onButton is TRUE
|
// return the item at given position (or NULL if no item), onButton is
|
||||||
// if the point belongs to the item's button, otherwise it lies on the
|
// TRUE if the point belongs to the item's button, otherwise it lies
|
||||||
// button's label
|
// on the button's label
|
||||||
wxGenericTreeItem *HitTest( const wxPoint& point, const wxTreeCtrl *, int &flags);
|
wxGenericTreeItem *HitTest( const wxPoint& point, const wxTreeCtrl *, int &flags);
|
||||||
|
|
||||||
void Expand() { m_isCollapsed = FALSE; }
|
void Expand() { m_isCollapsed = FALSE; }
|
||||||
void Collapse() { m_isCollapsed = TRUE; }
|
void Collapse() { m_isCollapsed = TRUE; }
|
||||||
|
|
||||||
void SetHilight( bool set = TRUE ) { m_hasHilight = set; }
|
void SetHilight( bool set = TRUE ) { m_hasHilight = set; }
|
||||||
|
|
||||||
// status inquiries
|
// status inquiries
|
||||||
bool HasChildren() const { return !m_children.IsEmpty(); }
|
bool HasChildren() const { return !m_children.IsEmpty(); }
|
||||||
bool IsSelected() const { return m_hasHilight; }
|
bool IsSelected() const { return m_hasHilight; }
|
||||||
bool IsExpanded() const { return !m_isCollapsed; }
|
bool IsExpanded() const { return !m_isCollapsed; }
|
||||||
bool HasPlus() const { return m_hasPlus || HasChildren(); }
|
bool HasPlus() const { return m_hasPlus || HasChildren(); }
|
||||||
bool IsBold() const { return m_isBold; }
|
bool IsBold() const { return m_isBold; }
|
||||||
|
|
||||||
|
// attributes
|
||||||
|
// get them - may be NULL
|
||||||
|
wxTreeItemAttr *GetAttributes() const { return m_attr; }
|
||||||
|
// get them ensuring that the pointer is not NULL
|
||||||
|
wxTreeItemAttr& Attr()
|
||||||
|
{
|
||||||
|
if ( !m_attr )
|
||||||
|
m_attr = new wxTreeItemAttr;
|
||||||
|
|
||||||
|
return *m_attr;
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
wxString m_text;
|
wxString m_text;
|
||||||
|
|
||||||
// tree ctrl images for the normal, selected, expanded and expanded+selected
|
// tree ctrl images for the normal, selected, expanded and
|
||||||
// states
|
// expanded+selected states
|
||||||
int m_images[wxTreeItemIcon_Max];
|
int m_images[wxTreeItemIcon_Max];
|
||||||
|
|
||||||
wxTreeItemData *m_data;
|
wxTreeItemData *m_data;
|
||||||
|
|
||||||
// use bitfields to save size
|
// use bitfields to save size
|
||||||
int m_isCollapsed :1;
|
int m_isCollapsed :1;
|
||||||
int m_hasHilight :1; // same as focused
|
int m_hasHilight :1; // same as focused
|
||||||
int m_hasPlus :1; // used for item which doesn't have
|
int m_hasPlus :1; // used for item which doesn't have
|
||||||
// children but still has a [+] button
|
// children but has a [+] button
|
||||||
int m_isBold :1; // render the label in bold font
|
int m_isBold :1; // render the label in bold font
|
||||||
|
|
||||||
int m_x, m_y;
|
int m_x, m_y;
|
||||||
long m_height, m_width;
|
long m_height, m_width;
|
||||||
int m_xCross, m_yCross;
|
int m_xCross, m_yCross;
|
||||||
int m_level;
|
int m_level;
|
||||||
wxArrayGenericTreeItems m_children;
|
|
||||||
wxGenericTreeItem *m_parent;
|
wxArrayGenericTreeItems m_children;
|
||||||
|
wxGenericTreeItem *m_parent;
|
||||||
|
|
||||||
|
wxTreeItemAttr *m_attr;
|
||||||
};
|
};
|
||||||
|
|
||||||
// =============================================================================
|
// =============================================================================
|
||||||
@@ -281,6 +296,8 @@ wxGenericTreeItem::wxGenericTreeItem(wxGenericTreeItem *parent,
|
|||||||
|
|
||||||
m_parent = parent;
|
m_parent = parent;
|
||||||
|
|
||||||
|
m_attr = (wxTreeItemAttr *)NULL;
|
||||||
|
|
||||||
dc.GetTextExtent( m_text, &m_width, &m_height );
|
dc.GetTextExtent( m_text, &m_width, &m_height );
|
||||||
// TODO : Add the width of the image
|
// TODO : Add the width of the image
|
||||||
// PB : We don't know which image is shown (image, selImage)
|
// PB : We don't know which image is shown (image, selImage)
|
||||||
@@ -292,6 +309,8 @@ wxGenericTreeItem::~wxGenericTreeItem()
|
|||||||
{
|
{
|
||||||
delete m_data;
|
delete m_data;
|
||||||
|
|
||||||
|
delete m_attr;
|
||||||
|
|
||||||
wxASSERT_MSG( m_children.IsEmpty(),
|
wxASSERT_MSG( m_children.IsEmpty(),
|
||||||
wxT("please call DeleteChildren() before deleting the item") );
|
wxT("please call DeleteChildren() before deleting the item") );
|
||||||
}
|
}
|
||||||
@@ -659,15 +678,44 @@ void wxTreeCtrl::SetItemHasChildren(const wxTreeItemId& item, bool has)
|
|||||||
|
|
||||||
void wxTreeCtrl::SetItemBold(const wxTreeItemId& item, bool bold)
|
void wxTreeCtrl::SetItemBold(const wxTreeItemId& item, bool bold)
|
||||||
{
|
{
|
||||||
wxCHECK_RET( item.IsOk(), wxT("invalid tree item") );
|
wxCHECK_RET( item.IsOk(), wxT("invalid tree item") );
|
||||||
|
|
||||||
// avoid redrawing the tree if no real change
|
// avoid redrawing the tree if no real change
|
||||||
wxGenericTreeItem *pItem = item.m_pItem;
|
wxGenericTreeItem *pItem = item.m_pItem;
|
||||||
if ( pItem->IsBold() != bold )
|
if ( pItem->IsBold() != bold )
|
||||||
{
|
{
|
||||||
pItem->SetBold(bold);
|
pItem->SetBold(bold);
|
||||||
|
RefreshLine(pItem);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void wxTreeCtrl::SetItemTextColour(const wxTreeItemId& item,
|
||||||
|
const wxColour& col)
|
||||||
|
{
|
||||||
|
wxCHECK_RET( item.IsOk(), wxT("invalid tree item") );
|
||||||
|
|
||||||
|
wxGenericTreeItem *pItem = item.m_pItem;
|
||||||
|
pItem->Attr().SetTextColour(col);
|
||||||
|
RefreshLine(pItem);
|
||||||
|
}
|
||||||
|
|
||||||
|
void wxTreeCtrl::SetItemBackgroundColour(const wxTreeItemId& item,
|
||||||
|
const wxColour& col)
|
||||||
|
{
|
||||||
|
wxCHECK_RET( item.IsOk(), wxT("invalid tree item") );
|
||||||
|
|
||||||
|
wxGenericTreeItem *pItem = item.m_pItem;
|
||||||
|
pItem->Attr().SetBackgroundColour(col);
|
||||||
|
RefreshLine(pItem);
|
||||||
|
}
|
||||||
|
|
||||||
|
void wxTreeCtrl::SetItemFont(const wxTreeItemId& item, const wxFont& font)
|
||||||
|
{
|
||||||
|
wxCHECK_RET( item.IsOk(), wxT("invalid tree item") );
|
||||||
|
|
||||||
|
wxGenericTreeItem *pItem = item.m_pItem;
|
||||||
|
pItem->Attr().SetFont(font);
|
||||||
RefreshLine(pItem);
|
RefreshLine(pItem);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
@@ -1409,7 +1457,10 @@ int wxTreeCtrl::GetLineHeight(wxGenericTreeItem *item) const
|
|||||||
|
|
||||||
void wxTreeCtrl::PaintItem(wxGenericTreeItem *item, wxDC& dc)
|
void wxTreeCtrl::PaintItem(wxGenericTreeItem *item, wxDC& dc)
|
||||||
{
|
{
|
||||||
if (item->IsBold())
|
wxTreeItemAttr *attr = item->GetAttributes();
|
||||||
|
if ( attr && attr->HasFont() )
|
||||||
|
dc.SetFont(attr->GetFont());
|
||||||
|
else if (item->IsBold())
|
||||||
dc.SetFont(m_boldFont);
|
dc.SetFont(m_boldFont);
|
||||||
|
|
||||||
long text_w = 0;
|
long text_w = 0;
|
||||||
@@ -1439,7 +1490,10 @@ void wxTreeCtrl::PaintItem(wxGenericTreeItem *item, wxDC& dc)
|
|||||||
dc.DestroyClippingRegion();
|
dc.DestroyClippingRegion();
|
||||||
}
|
}
|
||||||
|
|
||||||
dc.SetBackgroundMode(wxTRANSPARENT);
|
bool hasBgCol = attr && attr->HasBackgroundColour();
|
||||||
|
dc.SetBackgroundMode(hasBgCol ? wxSOLID : wxTRANSPARENT);
|
||||||
|
if ( hasBgCol )
|
||||||
|
dc.SetTextBackground(attr->GetBackgroundColour());
|
||||||
dc.DrawText( item->GetText(), image_w + item->GetX(), item->GetY()
|
dc.DrawText( item->GetText(), image_w + item->GetX(), item->GetY()
|
||||||
+ ((total_h > text_h) ? (total_h - text_h)/2 : 0));
|
+ ((total_h > text_h) ? (total_h - text_h)/2 : 0));
|
||||||
|
|
||||||
@@ -1488,32 +1542,43 @@ void wxTreeCtrl::PaintLevel( wxGenericTreeItem *item, wxDC &dc, int level, int &
|
|||||||
dc.SetPen( m_dottedPen );
|
dc.SetPen( m_dottedPen );
|
||||||
}
|
}
|
||||||
|
|
||||||
if (item->IsSelected())
|
wxPen *pen = wxTRANSPARENT_PEN;
|
||||||
|
wxBrush *brush; // FIXME is this really needed?
|
||||||
|
wxColour colText;
|
||||||
|
|
||||||
|
if ( item->IsSelected() )
|
||||||
{
|
{
|
||||||
dc.SetTextForeground( wxSystemSettings::GetSystemColour( wxSYS_COLOUR_HIGHLIGHTTEXT ) );
|
colText = wxSystemSettings::GetSystemColour( wxSYS_COLOUR_HIGHLIGHTTEXT );
|
||||||
|
|
||||||
dc.SetBrush( *m_hilightBrush );
|
brush = m_hilightBrush;
|
||||||
|
|
||||||
if (m_hasFocus)
|
if ( m_hasFocus )
|
||||||
dc.SetPen( *wxBLACK_PEN );
|
pen = wxBLACK_PEN;
|
||||||
else
|
|
||||||
dc.SetPen( *wxTRANSPARENT_PEN );
|
|
||||||
|
|
||||||
PaintItem(item, dc);
|
|
||||||
|
|
||||||
dc.SetPen( m_dottedPen );
|
|
||||||
dc.SetTextForeground( *wxBLACK );
|
|
||||||
dc.SetBrush( *wxWHITE_BRUSH );
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
dc.SetBrush( *wxWHITE_BRUSH );
|
wxTreeItemAttr *attr = item->GetAttributes();
|
||||||
dc.SetPen( *wxTRANSPARENT_PEN );
|
if ( attr && attr->HasTextColour() )
|
||||||
|
colText = attr->GetTextColour();
|
||||||
|
else
|
||||||
|
colText = *wxBLACK;
|
||||||
|
|
||||||
PaintItem(item, dc);
|
brush = wxWHITE_BRUSH;
|
||||||
|
|
||||||
dc.SetPen( m_dottedPen );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// prepare to draw
|
||||||
|
dc.SetTextForeground(colText);
|
||||||
|
dc.SetPen(*pen);
|
||||||
|
dc.SetBrush(*brush);
|
||||||
|
|
||||||
|
// draw
|
||||||
|
PaintItem(item, dc);
|
||||||
|
|
||||||
|
// restore DC objects
|
||||||
|
dc.SetBrush( *wxWHITE_BRUSH );
|
||||||
|
dc.SetPen( m_dottedPen );
|
||||||
|
dc.SetTextForeground( *wxBLACK );
|
||||||
}
|
}
|
||||||
|
|
||||||
y = oldY+GetLineHeight(item);
|
y = oldY+GetLineHeight(item);
|
||||||
@@ -1521,7 +1586,7 @@ void wxTreeCtrl::PaintLevel( wxGenericTreeItem *item, wxDC &dc, int level, int &
|
|||||||
if (item->IsExpanded())
|
if (item->IsExpanded())
|
||||||
{
|
{
|
||||||
oldY+=GetLineHeight(item)/2;
|
oldY+=GetLineHeight(item)/2;
|
||||||
int semiOldY=y; // (=y) for stupid compilator
|
int semiOldY=0;
|
||||||
|
|
||||||
wxArrayGenericTreeItems& children = item->GetChildren();
|
wxArrayGenericTreeItems& children = item->GetChildren();
|
||||||
size_t n, count = children.Count();
|
size_t n, count = children.Count();
|
||||||
@@ -1535,10 +1600,10 @@ void wxTreeCtrl::PaintLevel( wxGenericTreeItem *item, wxDC &dc, int level, int &
|
|||||||
// delete all its children for example) - don't draw the vertical line
|
// delete all its children for example) - don't draw the vertical line
|
||||||
// in this case
|
// in this case
|
||||||
if (count > 0)
|
if (count > 0)
|
||||||
{
|
{
|
||||||
semiOldY+=GetLineHeight(children[--n])/2;
|
semiOldY+=GetLineHeight(children[--n])/2;
|
||||||
dc.DrawLine( horizX+m_indent, oldY+5, horizX+m_indent, semiOldY );
|
dc.DrawLine( horizX+m_indent, oldY+5, horizX+m_indent, semiOldY );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -174,6 +174,7 @@ const wxChar *wxInternalErrorStr = wxT("wxWindows Internal Error");
|
|||||||
const wxChar *wxFatalErrorStr = wxT("wxWindows Fatal Error");
|
const wxChar *wxFatalErrorStr = wxT("wxWindows Fatal Error");
|
||||||
const wxChar *wxDirDialogNameStr = wxT("wxDirCtrl");
|
const wxChar *wxDirDialogNameStr = wxT("wxDirCtrl");
|
||||||
const wxChar *wxDirDialogDefaultFolderStr = wxT("/");
|
const wxChar *wxDirDialogDefaultFolderStr = wxT("/");
|
||||||
|
const wxChar *wxTreeCtrlNameStr = wxT("wxTreeCtrl");
|
||||||
|
|
||||||
/* See wx/utils.h */
|
/* See wx/utils.h */
|
||||||
const wxChar *wxFloatToStringStr = wxT("%.2f");
|
const wxChar *wxFloatToStringStr = wxT("%.2f");
|
||||||
|
@@ -174,6 +174,7 @@ const wxChar *wxInternalErrorStr = wxT("wxWindows Internal Error");
|
|||||||
const wxChar *wxFatalErrorStr = wxT("wxWindows Fatal Error");
|
const wxChar *wxFatalErrorStr = wxT("wxWindows Fatal Error");
|
||||||
const wxChar *wxDirDialogNameStr = wxT("wxDirCtrl");
|
const wxChar *wxDirDialogNameStr = wxT("wxDirCtrl");
|
||||||
const wxChar *wxDirDialogDefaultFolderStr = wxT("/");
|
const wxChar *wxDirDialogDefaultFolderStr = wxT("/");
|
||||||
|
const wxChar *wxTreeCtrlNameStr = wxT("wxTreeCtrl");
|
||||||
|
|
||||||
/* See wx/utils.h */
|
/* See wx/utils.h */
|
||||||
const wxChar *wxFloatToStringStr = wxT("%.2f");
|
const wxChar *wxFloatToStringStr = wxT("%.2f");
|
||||||
|
Reference in New Issue
Block a user