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:
Vadim Zeitlin 1999-12-06 13:18:14 +00:00
parent 70846f0a79
commit 9ec64fa758
10 changed files with 297 additions and 191 deletions

View File

@ -20,7 +20,9 @@ all (GUI):
- wxMenu(Bar)::Insert() and Remove() functions for dynamic menu menagament
- wxToolBar supports arbitrary controls (not only buttons) and can be
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
+/-90 degrees for now - contributions to improve it are welcome!)
@ -28,6 +30,7 @@ wxMSW:
- wxTreeCtrl::IsVisible() bug fixed (thanks to Gary Chessun)
- tooltips work with wxRadioBox
- returning FALSE from OnPrintPage() aborts printing
wxGTK:

View File

@ -530,6 +530,12 @@ Sets the indentation for the tree control.
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}
\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}}
}
\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}
\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.
\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}
\func{void}{SetStateImageList}{\param{wxImageList*}{ imageList}}

View File

@ -16,12 +16,6 @@
#pragma interface "treectrl.h"
#endif
#ifdef __WXMSW__
WXDLLEXPORT_DATA(extern const char*) wxTreeCtrlNameStr;
#else
#define wxTreeCtrlNameStr "wxTreeCtrl"
#endif
#include "wx/defs.h"
#include "wx/string.h"
#include "wx/object.h"
@ -32,51 +26,6 @@ WXDLLEXPORT_DATA(extern const char*) wxTreeCtrlNameStr;
#include "wx/dynarray.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
// -----------------------------------------------------------------------------
@ -181,8 +130,9 @@ class WXDLLEXPORT wxTreeTextCtrl: public wxTextCtrl
bool *accept, wxString *res, wxTreeCtrl *owner,
const wxString &value = wxEmptyString,
const wxPoint &pos = wxDefaultPosition, const wxSize &size = wxDefaultSize,
int style = 0,
#if wxUSE_VALIDATORS
int style = 0, const wxValidator& validator = wxDefaultValidator,
const wxValidator& validator = wxDefaultValidator,
#endif
const wxString &name = wxTextCtrlNameStr );
void OnChar( wxKeyEvent &event );
@ -290,6 +240,15 @@ public:
// the item will be shown in bold
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
// ---------------------

View File

@ -41,39 +41,6 @@ struct WXDLLEXPORT wxTreeViewItem;
// they're equivalent
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
// next versions
@ -253,6 +220,15 @@ public:
// the item will be shown with a drop highlight
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
// ---------------------

View File

@ -22,12 +22,74 @@ enum wxTreeItemIcon
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
#ifdef __WXMSW__
WXDLLEXPORT_DATA(extern const char*) wxTreeCtrlNameStr;
#else
#define wxTreeCtrlNameStr "wxTreeCtrl"
#endif
WXDLLEXPORT_DATA(extern const char*) wxTreeCtrlNameStr;
// ----------------------------------------------------------------------------
// wxTreeItemAttr: a structure containing the visual attributes of an item
// ----------------------------------------------------------------------------
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

View File

@ -565,6 +565,18 @@ void MyTreeCtrl::AddTestItemsToTree(size_t numChildren,
SetItemImage(rootId, TreeCtrlIcon_FolderOpened, wxTreeItemIcon_Expanded);
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)

View File

@ -691,6 +691,9 @@
/* Define if you have strtok_r function. */
#undef HAVE_STRTOK_R
/* Define if you have thr_setconcurrency function */
#undef HaVE_THR_SETCONCURRENCY
/* Define if you have the uname function. */
#undef HAVE_UNAME

View File

@ -61,106 +61,121 @@ static const int NO_IMAGE = -1;
class WXDLLEXPORT wxGenericTreeItem
{
public:
// ctors & dtor
wxGenericTreeItem() { m_data = NULL; }
wxGenericTreeItem( wxGenericTreeItem *parent,
const wxString& text,
wxDC& dc,
int image, int selImage,
wxTreeItemData *data );
// ctors & dtor
wxGenericTreeItem() { m_data = NULL; }
wxGenericTreeItem( wxGenericTreeItem *parent,
const wxString& text,
wxDC& dc,
int image, int selImage,
wxTreeItemData *data );
~wxGenericTreeItem();
~wxGenericTreeItem();
// trivial accessors
wxArrayGenericTreeItems& GetChildren() { return m_children; }
// trivial accessors
wxArrayGenericTreeItems& GetChildren() { return m_children; }
const wxString& GetText() const { return m_text; }
int GetImage(wxTreeItemIcon which = wxTreeItemIcon_Normal) const
const wxString& GetText() const { return m_text; }
int GetImage(wxTreeItemIcon which = wxTreeItemIcon_Normal) const
{ 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
// selected/expanded/whatever state)
int GetCurrentImage() const;
// returns the current image for the item (depending on its
// selected/expanded/whatever state)
int GetCurrentImage() const;
void SetText( const wxString &text );
void SetImage(int image, wxTreeItemIcon which) { m_images[which] = image; }
void SetData(wxTreeItemData *data) { m_data = data; }
void SetText( const wxString &text );
void SetImage(int image, wxTreeItemIcon which) { m_images[which] = image; }
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 GetY() const { return m_y; }
int GetX() const { return m_x; }
int GetY() const { return m_y; }
void SetX(int x) { m_x = x; }
void SetY(int y) { m_y = y; }
void SetX(int x) { m_x = x; }
void SetY(int y) { m_y = y; }
int GetHeight() const { return m_height; }
int GetWidth() const { return m_width; }
int GetHeight() const { return m_height; }
int GetWidth() const { return m_width; }
void SetHeight(int h) { m_height = h; }
void SetWidth(int w) { m_width = w; }
void SetHeight(int h) { m_height = h; }
void SetWidth(int w) { m_width = w; }
wxGenericTreeItem *GetParent() const { return m_parent; }
wxGenericTreeItem *GetParent() const { return m_parent; }
// operations
// deletes all children notifying the treectrl about it if !NULL pointer
// given
void DeleteChildren(wxTreeCtrl *tree = NULL);
// FIXME don't know what is it for
void Reset();
// operations
// deletes all children notifying the treectrl about it if !NULL
// pointer given
void DeleteChildren(wxTreeCtrl *tree = NULL);
// FIXME don't know what is it for
void Reset();
// get count of all children (and grand children if 'recursively')
size_t GetChildrenCount(bool recursively = TRUE) const;
// get count of all children (and grand children if 'recursively')
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); }
void SetCross( int x, int y );
void GetSize( int &x, int &y, const wxTreeCtrl* );
void SetCross( int x, int y );
void GetSize( int &x, int &y, const wxTreeCtrl* );
// return the item at given position (or NULL if no item), onButton is TRUE
// if the point belongs to the item's button, otherwise it lies on the
// button's label
wxGenericTreeItem *HitTest( const wxPoint& point, const wxTreeCtrl *, int &flags);
// return the item at given position (or NULL if no item), onButton is
// TRUE if the point belongs to the item's button, otherwise it lies
// on the button's label
wxGenericTreeItem *HitTest( const wxPoint& point, const wxTreeCtrl *, int &flags);
void Expand() { m_isCollapsed = FALSE; }
void Collapse() { m_isCollapsed = TRUE; }
void Expand() { m_isCollapsed = FALSE; }
void Collapse() { m_isCollapsed = TRUE; }
void SetHilight( bool set = TRUE ) { m_hasHilight = set; }
void SetHilight( bool set = TRUE ) { m_hasHilight = set; }
// status inquiries
bool HasChildren() const { return !m_children.IsEmpty(); }
bool IsSelected() const { return m_hasHilight; }
bool IsExpanded() const { return !m_isCollapsed; }
bool HasPlus() const { return m_hasPlus || HasChildren(); }
bool IsBold() const { return m_isBold; }
// status inquiries
bool HasChildren() const { return !m_children.IsEmpty(); }
bool IsSelected() const { return m_hasHilight; }
bool IsExpanded() const { return !m_isCollapsed; }
bool HasPlus() const { return m_hasPlus || HasChildren(); }
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:
wxString m_text;
wxString m_text;
// tree ctrl images for the normal, selected, expanded and expanded+selected
// states
int m_images[wxTreeItemIcon_Max];
// tree ctrl images for the normal, selected, expanded and
// expanded+selected states
int m_images[wxTreeItemIcon_Max];
wxTreeItemData *m_data;
wxTreeItemData *m_data;
// use bitfields to save size
int m_isCollapsed :1;
int m_hasHilight :1; // same as focused
int m_hasPlus :1; // used for item which doesn't have
// children but still has a [+] button
int m_isBold :1; // render the label in bold font
// use bitfields to save size
int m_isCollapsed :1;
int m_hasHilight :1; // same as focused
int m_hasPlus :1; // used for item which doesn't have
// children but has a [+] button
int m_isBold :1; // render the label in bold font
int m_x, m_y;
long m_height, m_width;
int m_xCross, m_yCross;
int m_level;
wxArrayGenericTreeItems m_children;
wxGenericTreeItem *m_parent;
int m_x, m_y;
long m_height, m_width;
int m_xCross, m_yCross;
int m_level;
wxArrayGenericTreeItems m_children;
wxGenericTreeItem *m_parent;
wxTreeItemAttr *m_attr;
};
// =============================================================================
@ -281,6 +296,8 @@ wxGenericTreeItem::wxGenericTreeItem(wxGenericTreeItem *parent,
m_parent = parent;
m_attr = (wxTreeItemAttr *)NULL;
dc.GetTextExtent( m_text, &m_width, &m_height );
// TODO : Add the width of the image
// PB : We don't know which image is shown (image, selImage)
@ -292,6 +309,8 @@ wxGenericTreeItem::~wxGenericTreeItem()
{
delete m_data;
delete m_attr;
wxASSERT_MSG( m_children.IsEmpty(),
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)
{
wxCHECK_RET( item.IsOk(), wxT("invalid tree item") );
wxCHECK_RET( item.IsOk(), wxT("invalid tree item") );
// avoid redrawing the tree if no real change
wxGenericTreeItem *pItem = item.m_pItem;
if ( pItem->IsBold() != bold )
{
pItem->SetBold(bold);
// avoid redrawing the tree if no real change
wxGenericTreeItem *pItem = item.m_pItem;
if ( pItem->IsBold() != 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);
}
}
// -----------------------------------------------------------------------------
@ -1409,7 +1457,10 @@ int wxTreeCtrl::GetLineHeight(wxGenericTreeItem *item) const
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);
long text_w = 0;
@ -1439,7 +1490,10 @@ void wxTreeCtrl::PaintItem(wxGenericTreeItem *item, wxDC& dc)
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()
+ ((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 );
}
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)
dc.SetPen( *wxBLACK_PEN );
else
dc.SetPen( *wxTRANSPARENT_PEN );
if ( m_hasFocus )
pen = wxBLACK_PEN;
PaintItem(item, dc);
dc.SetPen( m_dottedPen );
dc.SetTextForeground( *wxBLACK );
dc.SetBrush( *wxWHITE_BRUSH );
}
else
{
dc.SetBrush( *wxWHITE_BRUSH );
dc.SetPen( *wxTRANSPARENT_PEN );
wxTreeItemAttr *attr = item->GetAttributes();
if ( attr && attr->HasTextColour() )
colText = attr->GetTextColour();
else
colText = *wxBLACK;
PaintItem(item, dc);
dc.SetPen( m_dottedPen );
brush = wxWHITE_BRUSH;
}
// 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);
@ -1521,7 +1586,7 @@ void wxTreeCtrl::PaintLevel( wxGenericTreeItem *item, wxDC &dc, int level, int &
if (item->IsExpanded())
{
oldY+=GetLineHeight(item)/2;
int semiOldY=y; // (=y) for stupid compilator
int semiOldY=0;
wxArrayGenericTreeItems& children = item->GetChildren();
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
// in this case
if (count > 0)
{
{
semiOldY+=GetLineHeight(children[--n])/2;
dc.DrawLine( horizX+m_indent, oldY+5, horizX+m_indent, semiOldY );
}
}
}
}

View File

@ -174,6 +174,7 @@ const wxChar *wxInternalErrorStr = wxT("wxWindows Internal Error");
const wxChar *wxFatalErrorStr = wxT("wxWindows Fatal Error");
const wxChar *wxDirDialogNameStr = wxT("wxDirCtrl");
const wxChar *wxDirDialogDefaultFolderStr = wxT("/");
const wxChar *wxTreeCtrlNameStr = wxT("wxTreeCtrl");
/* See wx/utils.h */
const wxChar *wxFloatToStringStr = wxT("%.2f");

View File

@ -174,6 +174,7 @@ const wxChar *wxInternalErrorStr = wxT("wxWindows Internal Error");
const wxChar *wxFatalErrorStr = wxT("wxWindows Fatal Error");
const wxChar *wxDirDialogNameStr = wxT("wxDirCtrl");
const wxChar *wxDirDialogDefaultFolderStr = wxT("/");
const wxChar *wxTreeCtrlNameStr = wxT("wxTreeCtrl");
/* See wx/utils.h */
const wxChar *wxFloatToStringStr = wxT("%.2f");