Patches for wxTreeListCtrl from Alberto
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_4_BRANCH@20953 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -530,6 +530,10 @@ public:
|
|||||||
unsigned int GetSpacing() const;
|
unsigned int GetSpacing() const;
|
||||||
void SetSpacing(unsigned int spacing);
|
void SetSpacing(unsigned int spacing);
|
||||||
|
|
||||||
|
// line spacing is the space above and below the text on each line
|
||||||
|
unsigned int GetLineSpacing() const;
|
||||||
|
void SetLineSpacing(unsigned int spacing);
|
||||||
|
|
||||||
// image list: these functions allow to associate an image list with
|
// image list: these functions allow to associate an image list with
|
||||||
// the control and retrieve it. Note that when assigned with
|
// the control and retrieve it. Note that when assigned with
|
||||||
// SetImageList, the control does _not_ delete
|
// SetImageList, the control does _not_ delete
|
||||||
@@ -583,6 +587,12 @@ public:
|
|||||||
void SetColumn(size_t column, const wxTreeListColumnInfo& info);
|
void SetColumn(size_t column, const wxTreeListColumnInfo& info);
|
||||||
wxTreeListColumnInfo& GetColumn(size_t column);
|
wxTreeListColumnInfo& GetColumn(size_t column);
|
||||||
|
|
||||||
|
// other column-related methods
|
||||||
|
void SetColumnAlignment(size_t column, wxTreeListColumnAlign align);
|
||||||
|
wxTreeListColumnAlign GetColumnAlignment(size_t column) const;
|
||||||
|
|
||||||
|
void SetColumnImage(size_t column, int image);
|
||||||
|
int GetColumnImage(size_t column) const;
|
||||||
|
|
||||||
|
|
||||||
%addmethods {
|
%addmethods {
|
||||||
@@ -675,8 +685,10 @@ public:
|
|||||||
void SetItemFont(const wxTreeItemId& item, const wxFont& font);
|
void SetItemFont(const wxTreeItemId& item, const wxFont& font);
|
||||||
|
|
||||||
|
|
||||||
// TODO: Where are the Getters for item colour, font, etc?
|
bool GetItemBold(const wxTreeItemId& item) const;
|
||||||
|
wxColour GetItemTextColour(const wxTreeItemId& item) const;
|
||||||
|
wxColour GetItemBackgroundColour(const wxTreeItemId& item) const;
|
||||||
|
wxFont GetItemFont(const wxTreeItemId& item) const;
|
||||||
|
|
||||||
// is the item visible (it might be outside the view or not expanded)?
|
// is the item visible (it might be outside the view or not expanded)?
|
||||||
bool IsVisible(const wxTreeItemId& item) const;
|
bool IsVisible(const wxTreeItemId& item) const;
|
||||||
|
@@ -76,6 +76,9 @@ static const int NO_IMAGE = -1;
|
|||||||
|
|
||||||
const wxChar* wxTreeListCtrlNameStr = wxT("treelistctrl");
|
const wxChar* wxTreeListCtrlNameStr = wxT("treelistctrl");
|
||||||
|
|
||||||
|
static wxTreeListColumnInfo wxInvalidTreeListColumnInfo;
|
||||||
|
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
// private classes
|
// private classes
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
@@ -140,14 +143,14 @@ public:
|
|||||||
void RemoveColumn(size_t column);
|
void RemoveColumn(size_t column);
|
||||||
|
|
||||||
void SetColumn(size_t column, const wxTreeListColumnInfo& info);
|
void SetColumn(size_t column, const wxTreeListColumnInfo& info);
|
||||||
const wxTreeListColumnInfo GetColumn(size_t column) const
|
const wxTreeListColumnInfo& GetColumn(size_t column) const
|
||||||
{
|
{
|
||||||
wxCHECK_MSG(column < GetColumnCount(), wxTreeListColumnInfo(), wxT("Invalid column"));
|
wxCHECK_MSG(column < GetColumnCount(), wxInvalidTreeListColumnInfo, wxT("Invalid column"));
|
||||||
return m_columns[column];
|
return m_columns[column];
|
||||||
}
|
}
|
||||||
wxTreeListColumnInfo GetColumn(size_t column)
|
wxTreeListColumnInfo& GetColumn(size_t column)
|
||||||
{
|
{
|
||||||
wxCHECK_MSG(column < GetColumnCount(), wxTreeListColumnInfo(), wxT("Invalid column"));
|
wxCHECK_MSG(column < GetColumnCount(), wxInvalidTreeListColumnInfo, wxT("Invalid column"));
|
||||||
return m_columns[column];
|
return m_columns[column];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -231,6 +234,10 @@ public:
|
|||||||
unsigned int GetSpacing() const { return m_spacing; }
|
unsigned int GetSpacing() const { return m_spacing; }
|
||||||
void SetSpacing(unsigned int spacing);
|
void SetSpacing(unsigned int spacing);
|
||||||
|
|
||||||
|
// see wxTreeListCtrl for the meaning
|
||||||
|
unsigned int GetLineSpacing() const { return m_linespacing; }
|
||||||
|
void SetLineSpacing(unsigned int spacing);
|
||||||
|
|
||||||
// image list: these functions allow to associate an image list with
|
// image list: these functions allow to associate an image list with
|
||||||
// the control and retrieve it. Note that when assigned with
|
// the control and retrieve it. Note that when assigned with
|
||||||
// SetImageList, the control does _not_ delete
|
// SetImageList, the control does _not_ delete
|
||||||
@@ -270,6 +277,11 @@ public:
|
|||||||
// get the data associated with the item
|
// get the data associated with the item
|
||||||
wxTreeItemData *GetItemData(const wxTreeItemId& item) const;
|
wxTreeItemData *GetItemData(const wxTreeItemId& item) const;
|
||||||
|
|
||||||
|
bool GetItemBold(const wxTreeItemId& item) const;
|
||||||
|
wxColour GetItemTextColour(const wxTreeItemId& item) const;
|
||||||
|
wxColour GetItemBackgroundColour(const wxTreeItemId& item) const;
|
||||||
|
wxFont GetItemFont(const wxTreeItemId& item) const;
|
||||||
|
|
||||||
// modifiers
|
// modifiers
|
||||||
// ---------
|
// ---------
|
||||||
|
|
||||||
@@ -547,6 +559,7 @@ protected:
|
|||||||
unsigned short m_indent;
|
unsigned short m_indent;
|
||||||
unsigned short m_spacing;
|
unsigned short m_spacing;
|
||||||
int m_lineHeight;
|
int m_lineHeight;
|
||||||
|
unsigned short m_linespacing;
|
||||||
wxPen m_dottedPen;
|
wxPen m_dottedPen;
|
||||||
wxBrush *m_hilightBrush,
|
wxBrush *m_hilightBrush,
|
||||||
*m_hilightUnfocusedBrush;
|
*m_hilightUnfocusedBrush;
|
||||||
@@ -1151,7 +1164,7 @@ void wxTreeListHeaderWindow::OnPaint( wxPaintEvent &WXUNUSED(event) )
|
|||||||
int numColumns = GetColumnCount();
|
int numColumns = GetColumnCount();
|
||||||
for ( int i = 0; i < numColumns && x < w; i++ )
|
for ( int i = 0; i < numColumns && x < w; i++ )
|
||||||
{
|
{
|
||||||
wxTreeListColumnInfo column = GetColumn(i);
|
wxTreeListColumnInfo& column = GetColumn(i);
|
||||||
int wCol = column.GetWidth();
|
int wCol = column.GetWidth();
|
||||||
|
|
||||||
// the width of the rect to draw: make it smaller to fit entirely
|
// the width of the rect to draw: make it smaller to fit entirely
|
||||||
@@ -1732,6 +1745,7 @@ void wxTreeListMainWindow::Init()
|
|||||||
m_lineHeight = 10;
|
m_lineHeight = 10;
|
||||||
m_indent = 9;
|
m_indent = 9;
|
||||||
m_spacing = 9;
|
m_spacing = 9;
|
||||||
|
m_linespacing = 4;
|
||||||
|
|
||||||
m_hilightBrush = new wxBrush
|
m_hilightBrush = new wxBrush
|
||||||
(
|
(
|
||||||
@@ -1864,6 +1878,14 @@ void wxTreeListMainWindow::SetSpacing(unsigned int spacing)
|
|||||||
m_dirty = TRUE;
|
m_dirty = TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline
|
||||||
|
void wxTreeListMainWindow::SetLineSpacing(unsigned int spacing)
|
||||||
|
{
|
||||||
|
m_linespacing = spacing;
|
||||||
|
m_dirty = TRUE;
|
||||||
|
CalculateLineHeight();
|
||||||
|
}
|
||||||
|
|
||||||
inline
|
inline
|
||||||
size_t wxTreeListMainWindow::GetChildrenCount(const wxTreeItemId& item,
|
size_t wxTreeListMainWindow::GetChildrenCount(const wxTreeItemId& item,
|
||||||
bool recursively)
|
bool recursively)
|
||||||
@@ -1904,6 +1926,44 @@ wxTreeItemData *wxTreeListMainWindow::GetItemData(const wxTreeItemId& item)
|
|||||||
return ((wxTreeListItem*) item.m_pItem)->GetData();
|
return ((wxTreeListItem*) item.m_pItem)->GetData();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline
|
||||||
|
bool wxTreeListMainWindow::GetItemBold(const wxTreeItemId& item) const
|
||||||
|
{
|
||||||
|
wxCHECK_MSG(item.IsOk(), FALSE, wxT("invalid tree item"));
|
||||||
|
return ((wxTreeListItem *)item.m_pItem)->IsBold();
|
||||||
|
}
|
||||||
|
|
||||||
|
inline
|
||||||
|
wxColour wxTreeListMainWindow::GetItemTextColour(const wxTreeItemId& item)
|
||||||
|
const
|
||||||
|
{
|
||||||
|
wxCHECK_MSG( item.IsOk(), wxNullColour, wxT("invalid tree item") );
|
||||||
|
|
||||||
|
wxTreeListItem *pItem = (wxTreeListItem*) item.m_pItem;
|
||||||
|
return pItem->Attr().GetTextColour();
|
||||||
|
}
|
||||||
|
|
||||||
|
inline
|
||||||
|
wxColour wxTreeListMainWindow::GetItemBackgroundColour(
|
||||||
|
const wxTreeItemId& item) const
|
||||||
|
{
|
||||||
|
wxCHECK_MSG( item.IsOk(), wxNullColour, wxT("invalid tree item") );
|
||||||
|
|
||||||
|
wxTreeListItem *pItem = (wxTreeListItem*) item.m_pItem;
|
||||||
|
return pItem->Attr().GetBackgroundColour();
|
||||||
|
}
|
||||||
|
|
||||||
|
inline
|
||||||
|
wxFont wxTreeListMainWindow::GetItemFont(const wxTreeItemId& item) const
|
||||||
|
{
|
||||||
|
wxCHECK_MSG( item.IsOk(), wxNullFont, wxT("invalid tree item") );
|
||||||
|
|
||||||
|
wxTreeListItem *pItem = (wxTreeListItem*) item.m_pItem;
|
||||||
|
return pItem->Attr().GetFont();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
inline
|
inline
|
||||||
void wxTreeListMainWindow::SetItemImage(const wxTreeItemId& item,
|
void wxTreeListMainWindow::SetItemImage(const wxTreeItemId& item,
|
||||||
size_t column,
|
size_t column,
|
||||||
@@ -2854,7 +2914,9 @@ static int LINKAGEMODE tree_ctrl_compare_func(wxTreeListItem **item1,
|
|||||||
int wxTreeListMainWindow::OnCompareItems(const wxTreeItemId& item1,
|
int wxTreeListMainWindow::OnCompareItems(const wxTreeItemId& item1,
|
||||||
const wxTreeItemId& item2)
|
const wxTreeItemId& item2)
|
||||||
{
|
{
|
||||||
return wxStrcmp(GetItemText(item1), GetItemText(item2));
|
// ALB: delegate to m_owner, to let the user overrride the comparison
|
||||||
|
//return wxStrcmp(GetItemText(item1), GetItemText(item2));
|
||||||
|
return m_owner->OnCompareItems(item1, item2);
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxTreeListMainWindow::SortChildren(const wxTreeItemId& itemId)
|
void wxTreeListMainWindow::SortChildren(const wxTreeItemId& itemId)
|
||||||
@@ -2899,7 +2961,7 @@ wxImageList *wxTreeListMainWindow::GetStateImageList() const
|
|||||||
void wxTreeListMainWindow::CalculateLineHeight()
|
void wxTreeListMainWindow::CalculateLineHeight()
|
||||||
{
|
{
|
||||||
wxClientDC dc(this);
|
wxClientDC dc(this);
|
||||||
m_lineHeight = (int)(dc.GetCharHeight() + 4);
|
m_lineHeight = (int)(dc.GetCharHeight() + m_linespacing*2);
|
||||||
|
|
||||||
if ( m_imageListNormal )
|
if ( m_imageListNormal )
|
||||||
{
|
{
|
||||||
@@ -4329,6 +4391,12 @@ unsigned int wxTreeListCtrl::GetSpacing() const
|
|||||||
void wxTreeListCtrl::SetSpacing(unsigned int spacing)
|
void wxTreeListCtrl::SetSpacing(unsigned int spacing)
|
||||||
{ m_main_win->SetSpacing(spacing); }
|
{ m_main_win->SetSpacing(spacing); }
|
||||||
|
|
||||||
|
unsigned int wxTreeListCtrl::GetLineSpacing() const
|
||||||
|
{ return m_main_win->GetLineSpacing(); }
|
||||||
|
|
||||||
|
void wxTreeListCtrl::SetLineSpacing(unsigned int spacing)
|
||||||
|
{ m_main_win->SetLineSpacing(spacing); }
|
||||||
|
|
||||||
wxImageList* wxTreeListCtrl::GetImageList() const
|
wxImageList* wxTreeListCtrl::GetImageList() const
|
||||||
{ return m_main_win->GetImageList(); }
|
{ return m_main_win->GetImageList(); }
|
||||||
|
|
||||||
@@ -4367,6 +4435,20 @@ int wxTreeListCtrl::GetItemImage(const wxTreeItemId& item, size_t column,
|
|||||||
wxTreeItemData* wxTreeListCtrl::GetItemData(const wxTreeItemId& item) const
|
wxTreeItemData* wxTreeListCtrl::GetItemData(const wxTreeItemId& item) const
|
||||||
{ return m_main_win->GetItemData(item); }
|
{ return m_main_win->GetItemData(item); }
|
||||||
|
|
||||||
|
bool wxTreeListCtrl::GetItemBold(const wxTreeItemId& item) const
|
||||||
|
{ return m_main_win->GetItemBold(item); }
|
||||||
|
|
||||||
|
wxColour wxTreeListCtrl::GetItemTextColour(const wxTreeItemId& item) const
|
||||||
|
{ return m_main_win->GetItemTextColour(item); }
|
||||||
|
|
||||||
|
wxColour wxTreeListCtrl::GetItemBackgroundColour(const wxTreeItemId& item)
|
||||||
|
const
|
||||||
|
{ return m_main_win->GetItemBackgroundColour(item); }
|
||||||
|
|
||||||
|
wxFont wxTreeListCtrl::GetItemFont(const wxTreeItemId& item) const
|
||||||
|
{ return m_main_win->GetItemFont(item); }
|
||||||
|
|
||||||
|
|
||||||
void wxTreeListCtrl::SetItemText(const wxTreeItemId& item, size_t column,
|
void wxTreeListCtrl::SetItemText(const wxTreeItemId& item, size_t column,
|
||||||
const wxString& text)
|
const wxString& text)
|
||||||
{ m_main_win->SetItemText(item, column, text); }
|
{ m_main_win->SetItemText(item, column, text); }
|
||||||
@@ -4573,7 +4655,12 @@ void wxTreeListCtrl::Edit(const wxTreeItemId& item)
|
|||||||
|
|
||||||
int wxTreeListCtrl::OnCompareItems(const wxTreeItemId& item1,
|
int wxTreeListCtrl::OnCompareItems(const wxTreeItemId& item1,
|
||||||
const wxTreeItemId& item2)
|
const wxTreeItemId& item2)
|
||||||
{ return m_main_win->OnCompareItems(item1, item2); }
|
{
|
||||||
|
// ALB: do the comparison here, and not delegate to m_main_win, in order
|
||||||
|
// to let the user override it
|
||||||
|
//return m_main_win->OnCompareItems(item1, item2);
|
||||||
|
return wxStrcmp(GetItemText(item1), GetItemText(item2));
|
||||||
|
}
|
||||||
|
|
||||||
void wxTreeListCtrl::SortChildren(const wxTreeItemId& item)
|
void wxTreeListCtrl::SortChildren(const wxTreeItemId& item)
|
||||||
{ m_main_win->SortChildren(item); }
|
{ m_main_win->SortChildren(item); }
|
||||||
@@ -4621,12 +4708,33 @@ void wxTreeListCtrl::RemoveColumn(size_t column)
|
|||||||
void wxTreeListCtrl::SetColumn(size_t column, const wxTreeListColumnInfo& col)
|
void wxTreeListCtrl::SetColumn(size_t column, const wxTreeListColumnInfo& col)
|
||||||
{ m_header_win->SetColumn(column, col); }
|
{ m_header_win->SetColumn(column, col); }
|
||||||
|
|
||||||
const wxTreeListColumnInfo wxTreeListCtrl::GetColumn(size_t column) const
|
const wxTreeListColumnInfo& wxTreeListCtrl::GetColumn(size_t column) const
|
||||||
{ return m_header_win->GetColumn(column); }
|
{ return m_header_win->GetColumn(column); }
|
||||||
|
|
||||||
wxTreeListColumnInfo wxTreeListCtrl::GetColumn(size_t column)
|
wxTreeListColumnInfo& wxTreeListCtrl::GetColumn(size_t column)
|
||||||
{ return m_header_win->GetColumn(column); }
|
{ return m_header_win->GetColumn(column); }
|
||||||
|
|
||||||
|
void wxTreeListCtrl::SetColumnImage(size_t column, int image)
|
||||||
|
{
|
||||||
|
m_header_win->SetColumn(column, GetColumn(column).SetImage(image));
|
||||||
|
}
|
||||||
|
|
||||||
|
int wxTreeListCtrl::GetColumnImage(size_t column) const
|
||||||
|
{
|
||||||
|
return m_header_win->GetColumn(column).GetImage();
|
||||||
|
}
|
||||||
|
|
||||||
|
void wxTreeListCtrl::SetColumnAlignment(size_t column,
|
||||||
|
wxTreeListColumnAlign align)
|
||||||
|
{
|
||||||
|
m_header_win->SetColumn(column, GetColumn(column).SetAlignment(align));
|
||||||
|
}
|
||||||
|
|
||||||
|
wxTreeListColumnAlign wxTreeListCtrl::GetColumnAlignment(size_t column) const
|
||||||
|
{
|
||||||
|
return m_header_win->GetColumn(column).GetAlignment();
|
||||||
|
}
|
||||||
|
|
||||||
void wxTreeListCtrl::Refresh(bool erase, const wxRect* rect)
|
void wxTreeListCtrl::Refresh(bool erase, const wxRect* rect)
|
||||||
{
|
{
|
||||||
m_main_win->Refresh(erase, rect);
|
m_main_win->Refresh(erase, rect);
|
||||||
|
@@ -156,6 +156,10 @@ public:
|
|||||||
unsigned int GetSpacing() const;
|
unsigned int GetSpacing() const;
|
||||||
void SetSpacing(unsigned int spacing);
|
void SetSpacing(unsigned int spacing);
|
||||||
|
|
||||||
|
// line spacing is the space above and below the text on each line
|
||||||
|
unsigned int GetLineSpacing() const;
|
||||||
|
void SetLineSpacing(unsigned int spacing);
|
||||||
|
|
||||||
// image list: these functions allow to associate an image list with
|
// image list: these functions allow to associate an image list with
|
||||||
// the control and retrieve it. Note that when assigned with
|
// the control and retrieve it. Note that when assigned with
|
||||||
// SetImageList, the control does _not_ delete
|
// SetImageList, the control does _not_ delete
|
||||||
@@ -210,9 +214,15 @@ public:
|
|||||||
wxString GetColumnText(size_t column) const;
|
wxString GetColumnText(size_t column) const;
|
||||||
|
|
||||||
void SetColumn(size_t column, const wxTreeListColumnInfo& info);
|
void SetColumn(size_t column, const wxTreeListColumnInfo& info);
|
||||||
wxTreeListColumnInfo GetColumn(size_t column);
|
wxTreeListColumnInfo& GetColumn(size_t column);
|
||||||
const wxTreeListColumnInfo GetColumn(size_t column) const;
|
const wxTreeListColumnInfo& GetColumn(size_t column) const;
|
||||||
|
|
||||||
|
// other column-related methods
|
||||||
|
void SetColumnAlignment(size_t column, wxTreeListColumnAlign align);
|
||||||
|
wxTreeListColumnAlign GetColumnAlignment(size_t column) const;
|
||||||
|
|
||||||
|
void SetColumnImage(size_t column, int image);
|
||||||
|
int GetColumnImage(size_t column) const;
|
||||||
|
|
||||||
// Functions to work with tree list ctrl items.
|
// Functions to work with tree list ctrl items.
|
||||||
|
|
||||||
@@ -235,6 +245,11 @@ public:
|
|||||||
// get the data associated with the item
|
// get the data associated with the item
|
||||||
wxTreeItemData *GetItemData(const wxTreeItemId& item) const;
|
wxTreeItemData *GetItemData(const wxTreeItemId& item) const;
|
||||||
|
|
||||||
|
bool GetItemBold(const wxTreeItemId& item) const;
|
||||||
|
wxColour GetItemTextColour(const wxTreeItemId& item) const;
|
||||||
|
wxColour GetItemBackgroundColour(const wxTreeItemId& item) const;
|
||||||
|
wxFont GetItemFont(const wxTreeItemId& item) const;
|
||||||
|
|
||||||
// modifiers
|
// modifiers
|
||||||
// ---------
|
// ---------
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user