21 #if defined(__GNUG__) && !defined(__APPLE__)
22 #pragma implementation "treelistctrl.h"
26 #include "wx/wxprec.h"
34 #include <wx/treebase.h>
36 #include <wx/textctrl.h>
37 #include <wx/imaglist.h>
38 #include <wx/settings.h>
39 #include <wx/dcclient.h>
40 #include <wx/dcscreen.h>
41 #include <wx/scrolwin.h>
42 #include <wx/dcmemory.h>
43 #include <wx/renderer.h>
44 #include <wx/apptrait.h>
45 #include <wx/dcbuffer.h>
46 #include <wx/tooltip.h>
47 #include <wx/hashmap.h>
48 #include <wx/dynarray.h>
49 #include <wx/arrimpl.cpp>
50 #if wxCHECK_VERSION(3,1,1)
51 #include <wx/itemattr.h>
54 class wxTreeItemAttr :
public wxItemAttr
58 #if defined(__WXMAC__) && defined(__WXOSX__)
59 #include "wx/osx/private.h"
60 #elif defined(__WXMAC__)
61 #include "wx/mac/private.h"
67 #include <wx/msgdlg.h>
151 const wxPoint &pos = wxDefaultPosition,
152 const wxSize &size = wxDefaultSize,
154 const wxString &name = _T(
"wxtreelistctrlcolumntitles") );
158 void DoDrawRect( wxDC *dc,
int x,
int y,
int w,
int h );
162 void OnPaint( wxPaintEvent &event );
164 void OnMouse( wxMouseEvent &event );
194 wxEmptyString, _T(
"Invalid column"));
199 _T(
"Invalid column"));
205 wxALIGN_LEFT, _T(
"Invalid column"));
210 _T(
"Invalid column"));
216 -1, _T(
"Invalid column"));
223 false, _T(
"Invalid column"));
229 true, _T(
"Invalid column"));
243 DECLARE_EVENT_TABLE()
257 friend class wxEditTextCtrl;
265 const wxPoint& pos = wxDefaultPosition,
266 const wxSize& size = wxDefaultSize,
267 long style = wxTR_DEFAULT_STYLE,
268 const wxValidator &validator = wxDefaultValidator,
269 const wxString& name = _T(
"wxtreelistmainwindow"))
272 Create (parent,
id, pos, size, style, validator, name);
278 const wxPoint& pos = wxDefaultPosition,
279 const wxSize& size = wxDefaultSize,
280 long style = wxTR_DEFAULT_STYLE,
281 const wxValidator &validator = wxDefaultValidator,
282 const wxString& name = _T(
"wxtreelistctrl"));
291 size_t GetCount()
const;
297 void SetIndent(
unsigned int indent);
301 void SetLineSpacing(
unsigned int spacing);
319 void SetImageList(wxImageList *imageList);
320 void SetStateImageList(wxImageList *imageList);
321 void SetButtonsImageList(wxImageList *imageList);
322 void AssignImageList(wxImageList *imageList);
323 void AssignStateImageList(wxImageList *imageList);
324 void AssignButtonsImageList(wxImageList *imageList);
326 void SetToolTip(
const wxString& tip);
327 void SetToolTip(wxToolTip *tip);
328 void SetItemToolTip(
const wxTreeItemId& item,
const wxString &tip);
337 wxString GetItemText (
const wxTreeItemId& item,
int column)
const;
338 wxString GetItemText (wxTreeItemData* item,
int column)
const;
341 int GetItemImage (
const wxTreeItemId& item, wxTreeItemIcon which = wxTreeItemIcon_Normal)
const {
return GetItemImage (item, GetMainColumn(), which); }
342 int GetItemImage (
const wxTreeItemId& item,
int column, wxTreeItemIcon which = wxTreeItemIcon_Normal)
const;
345 wxTreeItemData *GetItemData(
const wxTreeItemId& item)
const;
346 wxTreeItemData *GetItemData(
const wxTreeItemId& item,
int column)
const;
348 bool GetItemBold(
const wxTreeItemId& item)
const;
349 bool GetItemBold(
const wxTreeItemId& item,
int column)
const;
351 wxColour GetItemTextColour(
const wxTreeItemId& item)
const;
352 wxColour GetItemTextColour(
const wxTreeItemId& item,
int column)
const;
354 wxColour GetItemBackgroundColour(
const wxTreeItemId& item)
const;
355 wxColour GetItemBackgroundColour(
const wxTreeItemId& item,
int column)
const;
357 wxFont GetItemFont(
const wxTreeItemId& item)
const;
358 wxFont GetItemFont(
const wxTreeItemId& item,
int column)
const;
369 void SetItemHasChildren(
const wxTreeItemId& item,
bool has =
true);
372 void SetItemText (
const wxTreeItemId& item,
int column,
const wxString& text);
375 void SetItemImage (
const wxTreeItemId& item,
int image, wxTreeItemIcon which = wxTreeItemIcon_Normal) {
SetItemImage (item, GetMainColumn(), image, which); }
376 void SetItemImage (
const wxTreeItemId& item,
int column,
int image, wxTreeItemIcon which = wxTreeItemIcon_Normal);
379 void SetItemData(
const wxTreeItemId& item, wxTreeItemData *
data);
380 void SetItemData(
const wxTreeItemId& item,
int column, wxTreeItemData *
data);
383 void SetItemBold(
const wxTreeItemId& item,
bool bold =
true);
384 void SetItemBold(
const wxTreeItemId& item,
int column,
bool bold =
true);
387 void SetItemTextColour(
const wxTreeItemId& item,
const wxColour& colour);
388 void SetItemTextColour(
const wxTreeItemId& item,
int column,
const wxColour& colour);
391 void SetItemBackgroundColour(
const wxTreeItemId& item,
const wxColour& colour);
392 void SetItemBackgroundColour(
const wxTreeItemId& item,
int column,
const wxColour& colour);
395 void SetItemFont(
const wxTreeItemId& item,
const wxFont& font);
396 void SetItemFont(
const wxTreeItemId& item,
int column,
const wxFont& font);
404 bool IsVisible(
const wxTreeItemId& item,
bool fullRow,
bool within =
true)
const;
406 bool HasChildren(
const wxTreeItemId& item)
const;
408 bool IsExpanded(
const wxTreeItemId& item)
const;
410 bool IsSelected(
const wxTreeItemId& item)
const;
412 bool IsBold(
const wxTreeItemId& item)
const;
413 bool IsBold(
const wxTreeItemId& item,
int column)
const;
418 virtual bool SetFont(
const wxFont &font );
422 void SetWindowStyle(
const long styles);
429 size_t GetChildrenCount(
const wxTreeItemId& item,
bool recursively =
true);
443 size_t GetSelections(wxArrayTreeItemIds&)
const;
446 wxTreeItemId GetItemParent(
const wxTreeItemId& item)
const;
456 wxTreeItemId GetFirstChild(
const wxTreeItemId& item, wxTreeItemIdValue& cookie)
const;
457 wxTreeItemId GetNextChild(
const wxTreeItemId& item, wxTreeItemIdValue& cookie)
const;
458 wxTreeItemId GetPrevChild(
const wxTreeItemId& item, wxTreeItemIdValue& cookie)
const;
459 wxTreeItemId GetLastChild(
const wxTreeItemId& item, wxTreeItemIdValue& cookie)
const;
462 wxTreeItemId GetNextSibling(
const wxTreeItemId& item)
const;
463 wxTreeItemId GetPrevSibling(
const wxTreeItemId& item)
const;
466 wxTreeItemId GetNext(
const wxTreeItemId& item,
bool fulltree =
true)
const;
467 wxTreeItemId GetPrev(
const wxTreeItemId& item,
bool fulltree =
true)
const;
470 wxTreeItemId GetFirstExpandedItem()
const;
471 wxTreeItemId GetNextExpanded(
const wxTreeItemId& item)
const;
472 wxTreeItemId GetPrevExpanded(
const wxTreeItemId& item)
const;
475 wxTreeItemId GetFirstVisible(
bool fullRow,
bool within)
const;
476 wxTreeItemId GetNextVisible (
const wxTreeItemId& item,
bool fullRow,
bool within)
const;
477 wxTreeItemId GetPrevVisible (
const wxTreeItemId& item,
bool fullRow,
bool within)
const;
478 wxTreeItemId GetLastVisible (
bool fullRow,
bool within)
const;
484 wxTreeItemId AddRoot (
const wxString& text,
485 int image = -1,
int selectedImage = -1,
486 wxTreeItemData *
data = NULL);
489 wxTreeItemId PrependItem(
const wxTreeItemId& parent,
490 const wxString& text,
491 int image = -1,
int selectedImage = -1,
492 wxTreeItemData *
data = NULL);
495 wxTreeItemId InsertItem(
const wxTreeItemId& parent,
496 const wxTreeItemId& idPrevious,
497 const wxString& text,
498 int image = -1,
int selectedImage = -1,
499 wxTreeItemData *
data = NULL);
502 wxTreeItemId InsertItem(
const wxTreeItemId& parent,
504 const wxString& text,
505 int image = -1,
int selectedImage = -1,
506 wxTreeItemData *
data = NULL);
509 wxTreeItemId AppendItem(
const wxTreeItemId& parent,
510 const wxString& text,
511 int image = -1,
int selectedImage = -1,
512 wxTreeItemData *
data = NULL);
515 void Delete(
const wxTreeItemId& item);
518 void DeleteChildren(
const wxTreeItemId& item);
523 void SetItemParent(
const wxTreeItemId& parent,
const wxTreeItemId& item);
526 void Expand(
const wxTreeItemId& item);
528 void ExpandAll(
const wxTreeItemId& item);
530 void Collapse(
const wxTreeItemId& item);
532 void CollapseAndReset(
const wxTreeItemId& item);
534 void Toggle(
const wxTreeItemId& item);
537 void SetCurrentItem(
const wxTreeItemId& item);
543 bool SelectItem(
const wxTreeItemId& item,
const wxTreeItemId& prev = (wxTreeItemId*)NULL,
544 bool unselect_others =
true);
548 void EnsureVisible(
const wxTreeItemId& item);
550 void ScrollTo(
const wxTreeItemId& item);
551 void AdjustMyScrollbars();
556 {
int flags;
int column;
return HitTest (point, flags, column); }
558 {
int column;
return HitTest (point, flags, column); }
559 wxTreeItemId HitTest (
const wxPoint& point,
int&
flags,
int& column);
563 bool GetBoundingRect(
const wxTreeItemId& item,
565 bool textOnly =
false)
const;
570 void EditLabel (
const wxTreeItemId& item,
int column);
571 void EndEdit(
bool isCancelled);
578 virtual int OnCompareItems(
const wxTreeItemId& item1,
579 const wxTreeItemId&
item2);
583 void SortChildren(
const wxTreeItemId& item,
int column,
bool reverseOrder);
586 bool MatchItemText (
const wxString &itemText,
const wxString &pattern,
int mode);
587 wxTreeItemId FindItem (
const wxTreeItemId& item,
int column,
const wxString& str,
int mode = 0);
592 virtual bool SetBackgroundColour(
const wxColour& colour);
593 virtual bool SetForegroundColour(
const wxColour& colour);
596 void SetDragItem (
const wxTreeItemId& item = (wxTreeItemId*)NULL);
599 void OnPaint( wxPaintEvent &event );
602 void OnKillFocus( wxFocusEvent &event );
603 void OnChar( wxKeyEvent &event );
604 void OnMouse( wxMouseEvent &event );
605 void OnIdle( wxIdleEvent &event );
606 void OnScroll(wxScrollWinEvent& event);
614 {
if ((column >= 0) && (column <
GetColumnCount())) m_main_column = column; }
619 int GetBestColumnWidth (
int column, wxTreeItemId parent = wxTreeItemId());
648 wxBrush *m_hilightBrush,
654 bool m_ownsImageListNormal,
656 m_ownsImageListButtons;
660 wxImageList *m_imageListNormal,
689 wxTreeItemId DoInsertItem(
const wxTreeItemId& parent,
691 const wxString& text,
692 int image,
int selectedImage,
693 wxTreeItemData *
data);
697 {
return (m_imageListButtons) || HasFlag (wxTR_TWIST_BUTTONS|wxTR_HAS_BUTTONS); }
699 void CalculateLineHeight();
701 void PaintLevel(
wxTreeListItem *item, wxDC& dc,
int level,
int &y,
705 void CalculateLevel(
wxTreeListItem *item, wxDC &dc,
int level,
int &y,
707 void CalculatePositions();
713 void RefreshSelected();
717 void OnRenameTimer();
718 void OnRenameAccept(
bool isCancelled);
724 bool SendEvent(wxEventType event_type,
wxTreeListItem *item = NULL, wxTreeEvent *event = NULL);
726 #if wxCHECK_VERSION(3,1,3)
727 void OnDpiChanged(wxDPIChangedEvent& e);
731 DECLARE_EVENT_TABLE()
754 class wxEditTextCtrl:
public wxTextCtrl
757 wxEditTextCtrl (wxWindow *parent,
762 const wxString &value = wxEmptyString,
763 const wxPoint &pos = wxDefaultPosition,
764 const wxSize &size = wxDefaultSize,
766 const wxValidator& validator = wxDefaultValidator,
767 const wxString &name = wxTextCtrlNameStr );
770 virtual bool Destroy();
771 void EndEdit(
bool isCancelled);
774 void OnChar( wxKeyEvent &event );
775 void OnKeyUp( wxKeyEvent &event );
776 void OnKillFocus( wxFocusEvent &event );
786 DECLARE_EVENT_TABLE()
808 if (m_ownsAttr)
delete m_attr;
812 wxTreeItemAttr *m_attr;
834 const wxArrayString& text,
837 wxTreeItemData *
data );
849 if ( IsVirtual() )
return m_owner->
GetItemText( m_props_row.m_data, column );
850 if (column < (
signed)m_text.GetCount())
return m_text[column];
851 return wxEmptyString;
854 int GetImage ( wxTreeItemIcon which = wxTreeItemIcon_Normal)
const {
return m_images[which]; };
855 int GetImage (
int column, wxTreeItemIcon which = wxTreeItemIcon_Normal)
const
858 if(column == m_owner->
GetMainColumn())
return m_images[which];
861 wxTreeListItemCellAttrHash::const_iterator entry = m_props_cell.find( column );
862 if (entry == m_props_cell.end())
return NO_IMAGE;
863 return entry->second->m_image;
867 wxTreeItemData *
GetData()
const {
return m_props_row.m_data; };
869 wxTreeListItemCellAttrHash::const_iterator entry = m_props_cell.find( column );
870 if (entry == m_props_cell.end())
return NULL;
871 return entry->second->m_data;
878 int GetCurrentImage()
const;
885 void SetText (
int column,
const wxString& text)
887 if (column < (
int)m_text.GetCount()) {
888 m_text[column] = text;
891 for (
int i = (
int)m_text.GetCount(); i < howmany; ++i)
893 m_text.Add(wxEmptyString);
896 m_text[column] = text;
899 void SetImage (
int image, wxTreeItemIcon which) { m_images[which] = image; };
900 void SetImage (
int column,
int image, wxTreeItemIcon which)
903 if (column == m_owner->
GetMainColumn()) m_images[which] = image;
906 wxTreeListItemCellAttrHash::const_iterator entry = m_props_cell.find( column );
907 if (entry == m_props_cell.end()) {
909 m_props_cell[column]->m_image = image;
911 entry->second->m_image = image;
920 wxTreeListItemCellAttrHash::const_iterator entry = m_props_cell.find( column );
921 if (entry == m_props_cell.end()) {
923 m_props_cell[column]->m_data =
data;
925 entry->second->m_data =
data;
929 void SetBold(
bool bold) { m_props_row.m_isBold = bold; }
932 wxTreeListItemCellAttrHash::const_iterator entry = m_props_cell.find( column );
933 if (entry == m_props_cell.end()) {
935 m_props_cell[column]->m_isBold = bold;
936 m_props_cell[column]->m_isBoldSet = 1;
938 entry->second->m_isBold = bold;
939 entry->second->m_isBoldSet = 1;
945 if (m_toolTip) {
delete m_toolTip; m_toolTip = NULL; }
946 if (tip.length() > 0) { m_toolTip =
new wxString(tip); }
955 bool HasPlus()
const {
return m_hasPlus || HasChildren(); }
956 bool IsBold()
const {
return m_props_row.m_isBold != 0; }
959 wxTreeListItemCellAttrHash::const_iterator entry = m_props_cell.find( column );
960 if (entry == m_props_cell.end() || ! entry->second->m_isBoldSet)
return IsBold();
961 return (entry->second->m_isBold != 0);
967 int GetX()
const {
return m_x; }
968 int GetY()
const {
return m_y; }
981 if (column >=0 && column < (
signed)m_text_x.GetCount())
983 return m_text_x[column];
987 void SetTextX (
int column,
int text_x) {
if (column >=0 && column < (
signed)m_text_x.GetCount()) m_text_x[column] = text_x; }
993 size_t GetChildrenCount(
bool recursively =
true)
const;
1002 int &
flags,
int& column,
int level);
1008 void DeleteChildren();
1011 { m_children.Insert(child, index); }
1026 wxTreeListItemCellAttrHash::const_iterator entry = m_props_cell.find( column );
1027 if (entry == m_props_cell.end())
return GetAttributes();
1028 return entry->second->m_attr;
1034 wxTreeListItemCellAttrHash::const_iterator entry = m_props_cell.find( column );
1035 if (entry == m_props_cell.end()) {
1037 m_props_cell[column]->m_attr =
new wxTreeItemAttr;
1038 m_props_cell[column]->m_ownsAttr = 1;
1039 return *(m_props_cell[column]->m_attr);
1041 return *(entry->second->m_attr);
1046 if ( !m_props_row.m_attr )
1048 m_props_row.m_attr =
new wxTreeItemAttr;
1049 m_props_row.m_ownsAttr = 1;
1051 return *m_props_row.m_attr;
1082 short m_images[wxTreeItemIcon_Max];
1087 int m_isCollapsed :1;
1088 int m_hasHilight :1;
1115 m_owner->OnRenameTimer();
1122 BEGIN_EVENT_TABLE (wxEditTextCtrl,wxTextCtrl)
1123 EVT_CHAR (wxEditTextCtrl::OnChar)
1124 EVT_KEY_UP (wxEditTextCtrl::OnKeyUp)
1125 EVT_KILL_FOCUS (wxEditTextCtrl::OnKillFocus)
1128 wxEditTextCtrl::wxEditTextCtrl (wxWindow *parent,
1129 const wxWindowID
id,
1133 const wxString &value,
1137 const wxValidator& validator,
1138 const wxString &name)
1139 : wxTextCtrl (parent,
id, value, pos, size, style | wxSIMPLE_BORDER | wxTE_PROCESS_ENTER, validator, name)
1144 (*m_accept) =
false;
1145 (*m_res) = wxEmptyString;
1146 m_startValue = value;
1155 if (m_finished)
return;
1159 (*m_accept) = ! isCancelled;
1160 (*m_res) = isCancelled ? m_startValue : GetValue();
1161 m_owner->OnRenameAccept(*m_res == m_startValue);
1162 m_owner->m_editControl = NULL;
1163 m_owner->m_editItem = NULL;
1173 wxTheApp->ScheduleForDestruction(
this);
1184 if (event.GetKeyCode() == WXK_RETURN)
1189 if (event.GetKeyCode() == WXK_ESCAPE)
1206 wxSize parentSize = m_owner->GetSize();
1207 wxPoint myPos = GetPosition();
1208 wxSize mySize = GetSize();
1210 GetTextExtent(GetValue() + _T(
"M"), &sx, &sy);
1211 if (myPos.x + sx > parentSize.x) sx = parentSize.x - myPos.x;
1212 if (mySize.x > sx) sx = mySize.x;
1246 m_isDragging =
false;
1252 SetBackgroundStyle(wxBG_STYLE_CUSTOM);
1269 const wxString &name )
1270 : wxWindow( win, id, pos, size, style, name )
1277 SetBackgroundColour (wxSystemSettings::GetColour (wxSYS_COLOUR_BTNFACE));
1287 wxPen pen (wxSystemSettings::GetColour (wxSYS_COLOUR_BTNSHADOW ), 1, wxPENSTYLE_SOLID);
1288 const int m_corner = 1;
1290 dc->SetBrush( *wxTRANSPARENT_BRUSH );
1291 #if defined( __WXMAC__ )
1294 dc->SetPen( *wxBLACK_PEN );
1296 dc->DrawLine( x+w-m_corner+1, y, x+w, y+h );
1297 dc->DrawRectangle( x, y+h, w+1, 1 );
1299 #if defined( __WXMAC__ )
1300 pen = wxPen( wxColour( 0x88 , 0x88 , 0x88 ), 1, wxSOLID );
1303 dc->DrawLine( x+w-m_corner, y, x+w-1, y+h );
1304 dc->DrawRectangle( x+1, y+h-1, w-2, 1 );
1306 dc->SetPen( *wxWHITE_PEN );
1307 dc->DrawRectangle( x, y, w-m_corner+1, 1 );
1308 dc->DrawRectangle( x, y, 1, h );
1309 dc->DrawLine( x, y+h-1, x+1, y+h-1 );
1310 dc->DrawLine( x+w-1, y, x+w-1, y+1 );
1318 m_owner->GetScrollPixelsPerUnit( &xpix, NULL );
1320 m_owner->GetViewStart( &x, NULL );
1323 dc.SetDeviceOrigin( -x * xpix, 0 );
1328 wxAutoBufferedPaintDC dc(
this );
1335 GetClientSize( &w, &h );
1336 m_owner->CalcUnscrolledPosition(w, 0, &w, NULL);
1337 dc.SetBackgroundMode(wxTRANSPARENT);
1340 for (
int i = 0; i < numColumns && x < w; i++ )
1344 wxHeaderButtonParams params;
1347 params.m_labelColour = wxSystemSettings::GetColour( wxSYS_COLOUR_WINDOWTEXT );
1348 params.m_labelFont = GetFont();
1353 wxRect rect(x, 0, wCol, h);
1357 flags |= wxCONTROL_CURRENT;
1359 params.m_labelText = column.
GetText();
1364 if ((image != -1) && imageList)
1365 params.m_labelBitmap = imageList->GetBitmap(image);
1367 wxRendererNative::Get().DrawHeaderButton(
this, dc, rect, flags, wxHDR_SORT_ICON_NONE, ¶ms);
1371 wxRect rect(x, 0, w-x, h);
1372 wxRendererNative::Get().DrawHeaderButton(
this, dc, rect);
1381 ClientToScreen (&x1, &y1);
1388 m_owner->GetClientSize( NULL, &y2 );
1389 m_owner->ClientToScreen( &x2, &y2 );
1392 dc.SetLogicalFunction (wxINVERT);
1393 dc.SetPen (wxPen (*wxBLACK, 2, wxPENSTYLE_SOLID));
1394 dc.SetBrush (*wxTRANSPARENT_BRUSH);
1397 dc.DrawLine (x1, y1, x2, y2);
1398 dc.SetLogicalFunction (wxCOPY);
1399 dc.SetPen (wxNullPen);
1400 dc.SetBrush (wxNullBrush);
1407 for (
int col = 0; col < numColumns; col++ )
1412 if ( x < (colLeft + column.
GetWidth()) )
1433 }
while (++idx <= col);
1435 m_owner->CalcScrolledPosition(x, 0, &x, NULL);
1436 RefreshRect(wxRect(x, 0, width, GetSize().GetHeight()));
1443 m_owner->CalcUnscrolledPosition(event.GetX(), 0, &x, NULL);
1445 const int col =
XToCol(x);
1448 SetToolTip(
m_columns[col].GetTooltip());
1452 SetToolTip(wxEmptyString);
1454 if ( event.Moving() )
1479 SendListEvent (wxEVT_COMMAND_LIST_COL_DRAGGING, event.GetPosition());
1484 GetClientSize( &w, NULL );
1485 m_owner->CalcUnscrolledPosition(w, 0, &w, NULL);
1491 if (event.ButtonUp()) {
1492 m_isDragging =
false;
1493 if (HasCapture()) ReleaseMouse();
1497 SendListEvent (wxEVT_COMMAND_LIST_COL_END_DRAG, event.GetPosition());
1508 bool hit_border =
false;
1515 for (
int column = 0; column < countCol; column++) {
1520 if (abs (x-xpos) < 3) {
1534 if (event.LeftDown() ||
event.RightUp()) {
1537 if (hit_border && event.LeftDown()) {
1538 m_isDragging =
true;
1542 SendListEvent (wxEVT_COMMAND_LIST_COL_BEGIN_DRAG, event.GetPosition());
1544 wxEventType evt =
event.LeftDown()? wxEVT_COMMAND_LIST_COL_CLICK:
1545 wxEVT_COMMAND_LIST_COL_RIGHT_CLICK;
1548 }
else if (event.LeftDClick() && hit_border) {
1552 }
else if (event.Moving()) {
1572 wxWindow *parent = GetParent();
1573 wxListEvent le (type, parent->GetId());
1574 le.SetEventObject (parent);
1575 le.m_pointDrag = pos;
1581 le.m_pointDrag.y -= GetSize().y;
1583 parent->GetEventHandler()->ProcessEvent (le);
1589 m_owner->AdjustMyScrollbars();
1590 m_owner->m_dirty =
true;
1594 wxCHECK_RET ((column >= 0) && (column <
GetColumnCount()), _T(
"Invalid column"));
1598 m_owner->AdjustMyScrollbars();
1599 m_owner->m_dirty =
true;
1603 wxCHECK_RET ((before >= 0) && (before <
GetColumnCount()), _T(
"Invalid column"));
1606 m_owner->AdjustMyScrollbars();
1607 m_owner->m_dirty =
true;
1611 wxCHECK_RET ((column >= 0) && (column <
GetColumnCount()), _T(
"Invalid column"));
1614 m_owner->AdjustMyScrollbars();
1615 m_owner->m_dirty =
true;
1619 wxCHECK_RET ((column >= 0) && (column <
GetColumnCount()), _T(
"Invalid column"));
1625 m_owner->AdjustMyScrollbars();
1627 m_owner->m_dirty =
true;
1636 const wxArrayString& text,
1637 int image,
int selImage,
1638 wxTreeItemData *
data)
1641 m_images[wxTreeItemIcon_Normal] = image;
1642 m_images[wxTreeItemIcon_Selected] = selImage;
1667 wxTreeListItemCellAttrHash::iterator entry =
m_props_cell.begin();
1669 if (entry->second)
delete entry->second;
1673 wxASSERT_MSG(
m_children.IsEmpty(), _T(
"please call DeleteChildren() before destructor"));
1682 if (!recursively)
return count;
1684 size_t total = count;
1685 for (
size_t n = 0; n < count; ++n) {
1693 if (y < bottomY) y = bottomY;
1695 if ( x < width ) x = width;
1699 for (
size_t n = 0; n < count; ++n ) {
1707 int &
flags,
int& column,
int level) {
1714 if (!theCtrl->HasFlag(wxTR_HIDE_ROOT) || (level > 0)) {
1724 if (point.x >= x && point.x < x+w) {
1733 if ((point.y >=
m_y) && (point.y <=
m_y + h)) {
1736 int y_mid =
m_y + h/2;
1737 if (point.y < y_mid) {
1738 flags |= wxTREE_HITTEST_ONITEMUPPERPART;
1740 flags |= wxTREE_HITTEST_ONITEMLOWERPART;
1747 if ((point.x >= bntX) && (point.x <= (bntX + theCtrl->
m_btnWidth)) &&
1748 (point.y >= bntY) && (point.y <= (bntY + theCtrl->
m_btnHeight))) {
1749 flags |= wxTREE_HITTEST_ONITEMBUTTON;
1758 if ((point.x >= imgX) && (point.x <= (imgX + theCtrl->
m_imgWidth)) &&
1759 (point.y >= imgY) && (point.y <= (imgY + theCtrl->
m_imgHeight))) {
1760 flags |= wxTREE_HITTEST_ONITEMICON;
1767 flags |= wxTREE_HITTEST_ONITEMLABEL;
1772 if (point.x <
m_x) {
1773 flags |= wxTREE_HITTEST_ONITEMINDENT;
1781 flags |= wxTREE_HITTEST_ONITEMRIGHT;
1803 for (
size_t n = 0; n < count; n++) {
1804 child =
m_children[n]->HitTest (point, theCtrl, flags, column, level+1);
1805 if (child)
return child;
1816 image =
GetImage (wxTreeItemIcon_SelectedExpanded);
1818 image =
GetImage (wxTreeItemIcon_Expanded);
1822 image =
GetImage (wxTreeItemIcon_Selected);
1824 image =
GetImage (wxTreeItemIcon_Normal);
1841 EVT_PAINT (wxTreeListMainWindow::OnPaint)
1843 EVT_MOUSE_EVENTS (wxTreeListMainWindow::OnMouse)
1844 EVT_CHAR (wxTreeListMainWindow::OnChar)
1845 EVT_SET_FOCUS (wxTreeListMainWindow::OnSetFocus)
1846 EVT_KILL_FOCUS (wxTreeListMainWindow::OnKillFocus)
1847 EVT_IDLE (wxTreeListMainWindow::OnIdle)
1848 EVT_SCROLLWIN (wxTreeListMainWindow::OnScroll)
1849 EVT_MOUSE_CAPTURE_LOST(wxTreeListMainWindow::OnCaptureLost)
1850 #if wxCHECK_VERSION(3,1,3)
1851 EVT_DPI_CHANGED(wxTreeListMainWindow::OnDpiChanged)
1861 void wxTreeListMainWindow::Init() {
1878 m_hilightBrush =
new wxBrush (wxSystemSettings::GetColour (wxSYS_COLOUR_HIGHLIGHT), wxBRUSHSTYLE_SOLID);
1879 m_hilightUnfocusedBrush =
new wxBrush (wxSystemSettings::GetColour (wxSYS_COLOUR_BTNSHADOW), wxBRUSHSTYLE_SOLID);
1881 m_imageListNormal = (wxImageList *) NULL;
1882 m_imageListButtons = (wxImageList *) NULL;
1883 m_imageListState = (wxImageList *) NULL;
1884 m_ownsImageListNormal = m_ownsImageListButtons =
1885 m_ownsImageListState =
false;
1887 m_imgWidth = 0, m_imgWidth2 = 0;
1888 m_imgHeight = 0, m_imgHeight2 = 0;
1889 m_btnWidth = 0, m_btnWidth2 = 0;
1890 m_btnHeight = 0, m_btnHeight2 = 0;
1892 m_isDragStarted = m_isDragging =
false;
1897 m_editControl = NULL;
1899 m_lastOnSame =
false;
1900 m_left_down_selection =
false;
1902 m_findTimer =
new wxTimer (
this, -1);
1904 #if defined( __WXMAC__ ) && defined(__WXMAC_CARBON__)
1905 m_normalFont.MacCreateThemeFont (kThemeViewsFont);
1907 m_normalFont = wxSystemSettings::GetFont (wxSYS_DEFAULT_GUI_FONT);
1909 m_boldFont = wxFont( m_normalFont.GetPointSize(),
1910 m_normalFont.GetFamily(),
1911 m_normalFont.GetStyle(),
1913 m_normalFont.GetUnderlined(),
1914 m_normalFont.GetFaceName(),
1915 m_normalFont.GetEncoding());
1918 m_isItemToolTip =
false;
1926 const wxValidator &validator,
1927 const wxString& name) {
1929 wxScrolledWindow::Create (parent,
id, pos, size, style|wxHSCROLL|wxVSCROLL, name);
1931 #if wxUSE_VALIDATORS
1932 SetValidator(validator);
1937 SetBackgroundStyle(wxBG_STYLE_CUSTOM);
1939 m_dottedPen = wxPen(wxSystemSettings::GetColour(wxSYS_COLOUR_GRAYTEXT), 0, wxPENSTYLE_DOT);
1957 if (m_editControl) {
1975 m_indent = wxMax ((
unsigned)
MININDENT, indent);
1980 m_linespacing = spacing;
1987 wxCHECK_MSG (item.IsOk(), 0u, _T(
"invalid tree item"));
1993 if ((styles ^ m_windowStyle) & wxTR_MULTIPLE) {
UnselectAll(); }
1997 m_windowStyle = styles;
2002 m_isItemToolTip =
false;
2007 m_isItemToolTip =
false;
2008 m_toolTip = (tip == NULL) ? wxString() : tip->GetTip();
2013 wxCHECK_RET (item.IsOk(), _T(
"invalid tree item"));
2014 m_isItemToolTip =
true;
2025 wxCHECK_MSG (item.IsOk(), -1, _T(
"invalid tree item"));
2026 return ((
wxTreeListItem*) item.m_pItem)->GetImage (column, which);
2030 wxCHECK_MSG (item.IsOk(), NULL, _T(
"invalid tree item"));
2034 wxCHECK_MSG (item.IsOk(), NULL, _T(
"invalid tree item"));
2039 wxCHECK_MSG(item.IsOk(),
false, _T(
"invalid tree item"));
2043 wxCHECK_MSG(item.IsOk(),
false, _T(
"invalid tree item"));
2048 wxCHECK_MSG (item.IsOk(), wxNullColour, _T(
"invalid tree item"));
2051 if (attr && attr->HasTextColour()) {
2052 return attr->GetTextColour();
2054 return GetForegroundColour();
2058 wxCHECK_MSG (item.IsOk(), wxNullColour, _T(
"invalid tree item"));
2061 if (attr && attr->HasTextColour()) {
2062 return attr->GetTextColour();
2069 wxCHECK_MSG (item.IsOk(), wxNullColour, _T(
"invalid tree item"));
2072 if (attr && attr->HasBackgroundColour()) {
2073 return attr->GetBackgroundColour();
2075 return GetBackgroundColour();
2079 wxCHECK_MSG (item.IsOk(), wxNullColour, _T(
"invalid tree item"));
2082 if (attr && attr->HasBackgroundColour()) {
2083 return attr->GetBackgroundColour();
2090 wxCHECK_MSG (item.IsOk(), wxNullFont, _T(
"invalid tree item"));
2093 if (attr && attr->HasFont()) {
2094 return attr->GetFont();
2095 }
else if (pItem->IsBold()) {
2102 wxCHECK_MSG (item.IsOk(), wxNullFont, _T(
"invalid tree item"));
2105 wxTreeItemAttr *attr_row = pItem->GetAttributes();
2106 if (attr_cell && attr_cell->HasFont()) {
2107 return attr_cell->GetFont();
2108 }
else if (attr_row && attr_row->HasFont()) {
2109 return attr_row->GetFont();
2110 }
else if (pItem->IsBold(column)) {
2118 wxCHECK_RET (item.IsOk(), _T(
"invalid tree item"));
2125 wxCHECK_RET (item.IsOk(), _T(
"invalid tree item"));
2127 if(pItem->GetImage(column, which) != image)
2129 pItem->
SetImage (column, image, which);
2132 wxClientDC dc (
this);
2140 wxCHECK_RET (item.IsOk(), _T(
"invalid tree item"));
2144 wxCHECK_RET (item.IsOk(), _T(
"invalid tree item"));
2149 wxCHECK_RET (item.IsOk(), _T(
"invalid tree item"));
2151 if (pItem->IsBold() != bold) {
2157 wxCHECK_RET (item.IsOk(), _T(
"invalid tree item"));
2160 pItem->
SetBold (column, bold);
2166 wxCHECK_RET (item.IsOk(), _T(
"invalid tree item"));
2168 pItem->
Attr().SetTextColour (colour);
2172 wxCHECK_RET (item.IsOk(), _T(
"invalid tree item"));
2174 pItem->
Attr(column).SetTextColour (colour);
2179 wxCHECK_RET (item.IsOk(), _T(
"invalid tree item"));
2181 pItem->
Attr().SetBackgroundColour (colour);
2185 wxCHECK_RET (item.IsOk(), _T(
"invalid tree item"));
2187 pItem->
Attr(column).SetBackgroundColour (colour);
2192 wxCHECK_RET (item.IsOk(), _T(
"invalid tree item"));
2194 pItem->
Attr().SetFont (font);
2198 wxCHECK_RET (item.IsOk(), _T(
"invalid tree item"));
2200 pItem->
Attr(column).SetFont (font);
2206 wxScrolledWindow::SetFont (font);
2207 m_normalFont = font;
2208 m_boldFont = wxFont (m_normalFont.GetPointSize(),
2209 m_normalFont.GetFamily(),
2210 m_normalFont.GetStyle(),
2212 m_normalFont.GetUnderlined(),
2213 m_normalFont.GetFaceName());
2224 wxCHECK_MSG (item.IsOk(),
false, _T(
"invalid tree item"));
2230 if (parent == m_rootItem && HasFlag(wxTR_HIDE_ROOT))
break;
2237 wxSize clientSize = GetClientSize();
2240 ((!fullRow && rect.GetWidth() == 0) || rect.GetHeight() == 0) ||
2241 (rect.GetTop() < 0 || rect.GetBottom() >= clientSize.y) ||
2242 (!fullRow && (rect.GetLeft() < 0 || rect.GetRight() >= clientSize.x)))
return false;
2249 wxCHECK_MSG (item.IsOk(),
false, _T(
"invalid tree item"));
2260 wxCHECK_MSG (item.IsOk(),
false, _T(
"invalid tree item"));
2265 wxCHECK_MSG (item.IsOk(),
false, _T(
"invalid tree item"));
2270 wxCHECK_MSG (item.IsOk(),
false, _T(
"invalid tree item"));
2279 wxCHECK_MSG (item.IsOk(), wxTreeItemId(), _T(
"invalid tree item"));
2284 wxTreeItemIdValue& cookie)
const {
2285 wxCHECK_MSG (item.IsOk(), wxTreeItemId(), _T(
"invalid tree item"));
2286 wxArrayTreeListItems& children = ((
wxTreeListItem*) item.m_pItem)->GetChildren();
2288 return (!children.IsEmpty())? wxTreeItemId(children.Item(0)): wxTreeItemId();
2292 wxTreeItemIdValue& cookie)
const {
2293 wxCHECK_MSG (item.IsOk(), wxTreeItemId(), _T(
"invalid tree item"));
2294 wxArrayTreeListItems& children = ((
wxTreeListItem*) item.m_pItem)->GetChildren();
2296 long *pIndex = ((
long*)&cookie);
2297 return ((*pIndex)+1 < (long)children.Count())? wxTreeItemId(children.Item(++(*pIndex))): wxTreeItemId();
2301 wxTreeItemIdValue& cookie)
const {
2302 wxCHECK_MSG (item.IsOk(), wxTreeItemId(), _T(
"invalid tree item"));
2303 wxArrayTreeListItems& children = ((
wxTreeListItem*) item.m_pItem)->GetChildren();
2305 long *pIndex = (
long*)&cookie;
2306 return ((*pIndex)-1 >= 0)? wxTreeItemId(children.Item(--(*pIndex))): wxTreeItemId();
2310 wxTreeItemIdValue& cookie)
const {
2311 wxCHECK_MSG (item.IsOk(), wxTreeItemId(), _T(
"invalid tree item"));
2312 wxArrayTreeListItems& children = ((
wxTreeListItem*) item.m_pItem)->GetChildren();
2314 long *pIndex = ((
long*)&cookie);
2315 (*pIndex) = (long)children.Count();
2316 return (!children.IsEmpty())? wxTreeItemId(children.Last()): wxTreeItemId();
2320 wxCHECK_MSG (item.IsOk(), wxTreeItemId(), _T(
"invalid tree item"));
2325 if (!parent)
return wxTreeItemId();
2328 wxArrayTreeListItems& siblings = parent->GetChildren();
2329 size_t index = siblings.Index (i);
2330 wxASSERT (index != (
size_t)wxNOT_FOUND);
2331 return (index < siblings.Count()-1)? wxTreeItemId(siblings[index+1]): wxTreeItemId();
2335 wxCHECK_MSG (item.IsOk(), wxTreeItemId(), _T(
"invalid tree item"));
2340 if (!parent)
return wxTreeItemId();
2343 wxArrayTreeListItems& siblings = parent->GetChildren();
2344 size_t index = siblings.Index(i);
2345 wxASSERT (index != (
size_t)wxNOT_FOUND);
2346 return (index >= 1)? wxTreeItemId(siblings[index-1]): wxTreeItemId();
2351 wxCHECK_MSG (item.IsOk(), wxTreeItemId(), _T(
"invalid tree item"));
2355 wxArrayTreeListItems& children = ((
wxTreeListItem*)item.m_pItem)->GetChildren();
2356 if (children.GetCount() > 0)
return children.Item (0);
2361 wxTreeItemId parent = item;
2365 }
while (!next.IsOk() && parent.IsOk());
2371 wxCHECK_MSG (item.IsOk(), wxTreeItemId(), _T(
"invalid tree item"));
2378 while (fulltree || ((
wxTreeListItem*)prev.m_pItem)->IsExpanded()) {
2379 wxArrayTreeListItems& children = ((
wxTreeListItem*)prev.m_pItem)->GetChildren();
2380 if (children.GetCount() == 0)
break;
2381 prev = children.Item (children.GetCount() - 1);
2392 wxCHECK_MSG (item.IsOk(), wxTreeItemId(), _T(
"invalid tree item"));
2397 wxCHECK_MSG (item.IsOk(), wxTreeItemId(), _T(
"invalid tree item"));
2410 wxCHECK_MSG (item.IsOk(), wxTreeItemId(), _T(
"invalid tree item"));
2411 wxTreeItemId
id =
GetNext (item,
false);
2413 if (
IsVisible (
id, fullRow, within))
return id;
2416 return wxTreeItemId();
2420 wxCHECK_MSG (
GetRootItem().IsOk(), wxTreeItemId(), _T(
"invalid tree item"));
2422 wxTreeItemId res = id;
2423 while ((
id =
GetNext (
id,
false)).IsOk()) {
2424 if (
IsVisible (
id, fullRow, within)) res = id;
2430 wxCHECK_MSG (item.IsOk(), wxTreeItemId(), _T(
"invalid tree item"));
2431 wxTreeItemId
id =
GetPrev (item,
true);
2433 if (
IsVisible (
id, fullRow, within))
return id;
2436 return wxTreeItemId();
2447 const wxString& text,
2448 int image,
int selImage,
2449 wxTreeItemData *
data) {
2451 wxCHECK_MSG (parent, wxTreeItemId(), _T(
"item must have a parent, at least root!") );
2456 for (
int i = 0; i < (int)
GetColumnCount(); ++i) arr.Add (wxEmptyString);
2462 parent->
Insert (item, previous);
2468 int image,
int selImage,
2469 wxTreeItemData *
data) {
2470 wxCHECK_MSG(!m_rootItem, wxTreeItemId(), _T(
"tree can have only one root"));
2471 wxCHECK_MSG(
GetColumnCount(), wxTreeItemId(), _T(
"Add column(s) before adding the root item"));
2476 for (
int i = 0; i < (int)
GetColumnCount(); ++i) arr.Add (wxEmptyString);
2480 data->SetId(m_rootItem);
2482 if (HasFlag(wxTR_HIDE_ROOT)) {
2486 wxTreeItemIdValue cookie = 0;
2493 const wxString& text,
2494 int image,
int selImage,
2495 wxTreeItemData *
data) {
2496 return DoInsertItem (parent, 0u, text, image, selImage, data);
2500 const wxTreeItemId& idPrevious,
2501 const wxString& text,
2502 int image,
int selImage,
2503 wxTreeItemData *
data) {
2505 wxCHECK_MSG (parent, wxTreeItemId(), _T(
"item must have a parent, at least root!") );
2508 wxASSERT_MSG( index != wxNOT_FOUND,
2509 _T(
"previous item in wxTreeListMainWindow::InsertItem() is not a sibling") );
2511 return DoInsertItem (parentId, ++index, text, image, selImage, data);
2516 const wxString& text,
2517 int image,
int selImage,
2518 wxTreeItemData *
data) {
2520 wxCHECK_MSG (parent, wxTreeItemId(), _T(
"item must have a parent, at least root!") );
2522 return DoInsertItem (parentId, before, text, image, selImage, data);
2526 const wxString& text,
2527 int image,
int selImage,
2528 wxTreeItemData *
data) {
2530 wxCHECK_MSG (parent, wxTreeItemId(), _T(
"item must have a parent, at least root!") );
2539 if (! itemId.IsOk())
return;
2542 wxCHECK_RET (item != m_rootItem, _T(
"invalid item, root may not be deleted this way!"));
2550 parent->GetChildren().Remove (item);
2556 if (! m_rootItem)
return;
2563 SendEvent(wxEVT_COMMAND_TREE_DELETE_ITEM, m_rootItem);
2569 if (! itemId.IsOk())
return;
2574 wxArrayTreeListItems& children = item->
GetChildren();
2575 for (
size_t n = children.GetCount(); n>0; n--) {
2579 children.RemoveAt(n-1);
2585 wxCHECK_RET (item, _T(
"invalid item for delete!"));
2591 if (m_editControl) { m_editControl->
EndEdit(
true); }
2594 if (item == m_dragItem) {
2596 m_isDragStarted = m_isDragging =
false;
2597 if (HasCapture()) ReleaseMouse();
2603 if (item == m_curItem) {
2606 wxArrayTreeListItems& siblings = m_curItem->
GetChildren();
2607 size_t index = siblings.Index (item);
2608 wxASSERT (index != (
size_t)wxNOT_FOUND);
2615 if (item == m_selectItem) {
2617 SelectItem(m_selectItem, (wxTreeItemId*)NULL,
true);
2622 wxArrayTreeListItems& children = item->
GetChildren();
2623 for (
size_t n = children.GetCount(); n>0; n--) {
2627 children.RemoveAt(n-1);
2636 SendEvent(wxEVT_COMMAND_TREE_DELETE_ITEM, item);
2646 wxCHECK_RET (item, _T(
"invalid item in wxTreeListMainWindow::SetItemParent") );
2647 wxCHECK_RET (parent_new, _T(
"invalid parent in wxTreeListMainWindow::SetItemParent") );
2648 wxCHECK_RET (item != m_rootItem, _T(
"invalid root as item in wxTreeListMainWindow::SetItemParent!") );
2654 parent_new->Insert(item, parent_new->
GetChildren().Count());
2657 if (parent_new->GetChildren().Count() == 1) parent_new->Expand();
2672 if (old_item != NULL && old_item != item) {
2682 wxCHECK_RET (item, _T(
"invalid item in wxTreeListMainWindow::Expand") );
2687 wxTreeEvent event(wxEVT_COMMAND_TREE_ITEM_EXPANDING, 0);
2688 event.SetInt(m_curColumn);
2689 if (
SendEvent(0, item, &event) && !event.IsAllowed())
return;
2695 event.SetEventType (wxEVT_COMMAND_TREE_ITEM_EXPANDED);
2700 wxCHECK_RET (itemId.IsOk(), _T(
"invalid tree item"));
2704 wxTreeItemIdValue cookie;
2706 while (child.IsOk()) {
2714 wxCHECK_RET (item, _T(
"invalid item in wxTreeListMainWindow::Collapse") );
2719 wxTreeEvent event (wxEVT_COMMAND_TREE_ITEM_COLLAPSING, 0 );
2720 event.SetInt(m_curColumn);
2721 if (
SendEvent(0, item, &event) && !event.IsAllowed())
return;
2727 event.SetEventType (wxEVT_COMMAND_TREE_ITEM_COLLAPSED);
2732 wxCHECK_RET (item.IsOk(), _T(
"invalid tree item"));
2739 wxCHECK_RET (itemId.IsOk(), _T(
"invalid tree item"));
2757 wxCHECK_RET (item, _T(
"invalid tree item"));
2763 if (item != m_curItem) m_lastOnSame =
false;
2766 wxArrayTreeListItems& children = item->
GetChildren();
2767 size_t count = children.Count();
2768 for (
size_t n = 0; n < count; ++n) {
2792 wxArrayTreeListItems& children = parent->
GetChildren();
2793 int index = children.Index(crt_item);
2794 wxASSERT (index != wxNOT_FOUND);
2798 size_t count = children.Count();
2799 for (
size_t n = (index+1); n < count; ++n) {
2812 if (crt_item==last_item)
return true;
2815 wxArrayTreeListItems& children = crt_item->
GetChildren();
2816 size_t count = children.Count();
2817 for (
size_t n = 0; n < count; ++n) {
2826 const wxTreeItemId& lastId,
2827 bool unselect_others) {
2832 wxTreeEvent event( wxEVT_COMMAND_TREE_SEL_CHANGING, 0);
2833 event.SetInt(m_curColumn);
2834 event.SetOldItem (m_curItem);
2835 if (
SendEvent(0, item, &event) && !event.IsAllowed())
return false;
2838 bool bUnselectedAll =
false;
2839 if (unselect_others) {
2840 if (HasFlag(wxTR_MULTIPLE)) {
2848 if (lastId.IsOk() && itemId.IsOk() && (itemId != lastId)) {
2868 }
else if (itemId.IsOk()) {
2873 if (unselect_others) {
2883 event.SetEventType(wxEVT_COMMAND_TREE_SEL_CHANGED);
2891 wxCHECK_RET (HasFlag(wxTR_MULTIPLE), _T(
"invalid tree style"));
2892 wxCHECK_RET (root.IsOk(), _T(
"no tree"));
2895 wxTreeEvent event (wxEVT_COMMAND_TREE_SEL_CHANGING, 0);
2896 event.SetOldItem (m_curItem);
2898 if (
SendEvent(0, m_rootItem, &event) && !event.IsAllowed())
return;
2900 wxTreeItemIdValue cookie = 0;
2908 event.SetEventType (wxEVT_COMMAND_TREE_SEL_CHANGED);
2913 wxArrayTreeItemIds &array)
const {
2914 if (item->
IsSelected()) array.Add (wxTreeItemId(item));
2917 wxArrayTreeListItems& children = item->
GetChildren();
2918 size_t count = children.GetCount();
2919 for (
size_t n = 0; n < count; ++n)
FillArray (children[n], array);
2927 return array.Count();
2931 if (!item.IsOk())
return;
2946 if (!item.IsOk())
return;
2954 int item_y = gitem->
GetY();
2957 GetScrollPixelsPerUnit (&xUnit, &yUnit);
2960 GetViewStart (&start_x, &start_y);
2965 GetClientSize (&client_w, &client_h);
2969 m_rootItem->
GetSize (x, y,
this);
2972 int x_pos = GetScrollPos( wxHORIZONTAL );
2974 if (item_y < start_y+3) {
2976 SetScrollbars (xUnit, yUnit, xUnit ? x/xUnit : 0, yUnit ? y/yUnit : 0, x_pos, yUnit ? item_y/yUnit : 0);
2979 item_y += yUnit + 2;
2980 SetScrollbars (xUnit, yUnit, xUnit ? x/xUnit : 0, yUnit ? y/yUnit : 0, x_pos, yUnit ? (item_y+
GetLineHeight(gitem)-client_h)/yUnit : 0 );
2989 wxCHECK_MSG (s_treeBeingSorted, 0, _T(
"bug in wxTreeListMainWindow::SortChildren()") );
2995 return (m_sortColumn == -1
2997 : (m_ReverseSortOrder
3005 wxCHECK_RET (itemId.IsOk(), _T(
"invalid tree item"));
3009 wxCHECK_RET (!s_treeBeingSorted,
3010 _T(
"wxTreeListMainWindow::SortChildren is not reentrant") );
3012 wxArrayTreeListItems& children = item->
GetChildren();
3013 if ( children.Count() > 1 ) {
3015 s_treeBeingSorted =
this;
3016 m_sortColumn = column;
3017 m_ReverseSortOrder = reverseOrder;
3019 s_treeBeingSorted = NULL;
3024 wxString searchText;
3027 searchText = itemText.Mid (0, pattern.Length());
3029 searchText = itemText;
3032 if (searchText.CmpNoCase (pattern) == 0)
return true;
3034 if (searchText.Cmp (pattern) == 0)
return true;
3042 wxTreeItemIdValue cookie = 0;
3043 wxTreeItemId next = item;
3047 int col, col_start, col_end;
3048 if (column >= 0) { col_start = col_end = column; }
3067 if (next.IsOk() && HasFlag(wxTR_HIDE_ROOT)) {
3072 if (! next.IsOk() || next == item)
return (wxTreeItemId*)NULL;
3074 for (col=col_start; col<=col_end; col++) {
3079 return (wxTreeItemId*)NULL;
3090 wxClientDC dc (
this);
3091 dc.SetFont (m_normalFont);
3094 if (m_imageListNormal) {
3098 int n = m_imageListNormal->GetImageCount();
3099 for (
int i = 0; i < n ; i++) {
3100 int width = 0, height = 0;
3101 m_imageListNormal->GetSize(i, width, height);
3102 if (height > m_lineHeight) m_lineHeight = height +
m_linespacing;
3106 if (m_imageListButtons) {
3110 int n = m_imageListButtons->GetImageCount();
3111 for (
int i = 0; i < n ; i++) {
3112 int width = 0, height = 0;
3113 m_imageListButtons->GetSize(i, width, height);
3114 if (height > m_lineHeight) m_lineHeight = height +
m_linespacing;
3118 if (m_lineHeight < 30) {
3121 m_lineHeight += m_lineHeight / 10;
3127 m_imageListNormal = imageList;
3128 m_ownsImageListNormal =
false;
3135 m_imageListState = imageList;
3136 m_ownsImageListState =
false;
3141 m_imageListButtons = imageList;
3142 m_ownsImageListButtons =
false;
3149 m_ownsImageListNormal =
true;
3154 m_ownsImageListState =
true;
3159 m_ownsImageListButtons =
true;
3169 GetScrollPixelsPerUnit (&xUnit, &yUnit);
3170 if (xUnit == 0) xUnit = GetCharWidth();
3173 m_rootItem->
GetSize (x, y,
this);
3175 int x_pos = GetScrollPos (wxHORIZONTAL);
3176 int y_pos = GetScrollPos (wxVERTICAL);
3178 if (x < GetClientSize().GetWidth()) x_pos = 0;
3179 SetScrollbars (xUnit, yUnit, x/xUnit, y/yUnit, x_pos, y_pos);
3181 SetScrollbars (0, 0, 0, 0);
3186 if (GetWindowStyleFlag() & wxTR_HAS_VARIABLE_ROW_HEIGHT) {
3198 wxColour colTextHilight = wxSystemSettings::GetColour (wxSYS_COLOUR_HIGHLIGHTTEXT);
3201 int off_h = HasFlag(wxTR_ROW_LINES) ? 1 : 0;
3203 wxDCClipper clipper (dc, 0, item->
GetY(), total_w, total_h);
3213 dc.SetBrush (wxBrush ( colBg, wxBRUSHSTYLE_SOLID));
3214 dc.SetPen (*wxTRANSPARENT_PEN);
3215 if (HasFlag (wxTR_FULL_ROW_HIGHLIGHT)) {
3217 if (! m_isDragging && m_hasFocus) {
3218 dc.SetBrush (*m_hilightBrush);
3219 #ifndef __WXMAC__ // don't draw rect outline if we already have the background color
3220 dc.SetPen (*wxBLACK_PEN);
3221 #endif // !__WXMAC__
3223 dc.SetBrush (*m_hilightUnfocusedBrush);
3224 #ifndef __WXMAC__ // don't draw rect outline if we already have the background color
3225 dc.SetPen (*wxTRANSPARENT_PEN);
3226 #endif // !__WXMAC__
3228 dc.SetTextForeground (colTextHilight);
3231 if (item == m_curItem) {
3232 dc.SetPen (m_hasFocus? *wxBLACK_PEN: *wxTRANSPARENT_PEN);
3235 dc.DrawRectangle (0, item->
GetY() + off_h, total_w, total_h - off_h);
3239 int text_extraH = (total_h > text_h) ? (total_h - text_h)/2 : 0;
3240 int img_extraH = (total_h >
m_imgHeight)? (total_h-m_imgHeight)/2: 0;
3245 if (col_w <= 0)
continue;
3246 wxDCClipper clipper (dc, x_colstart, item->
GetY(), col_w, total_h);
3272 int w = 0, text_w = 0;
3273 wxString text = item->
GetText(i);
3274 dc.GetTextExtent (text, &text_w, NULL);
3280 w = col_w - (image_w + text_w + off_w +
MARGIN);
3283 case wxALIGN_CENTER:
3284 w = (col_w - (image_w + text_w + off_w +
MARGIN))/2;
3288 int text_x = x + image_w;
3293 if ( ! HasFlag (wxTR_FULL_ROW_HIGHLIGHT)) {
3295 bool drawCursor =
false;
3296 #ifndef __WXMAC__ // don't draw rect outline if we already have the background color
3297 drawCursor = (item == m_curItem && i == m_curColumn && !m_isDragging &&
m_hasFocus);
3298 #endif // !__WXMAC__
3302 dc.SetPen (*wxTRANSPARENT_PEN);
3303 dc.SetBrush (wxBrush ( colBg, wxBRUSHSTYLE_SOLID));
3304 dc.DrawRectangle (x_colstart, item->
GetY() + off_h, col_w, total_h - off_h);
3306 dc.SetPen (drawCursor ? *wxBLACK_PEN : *wxTRANSPARENT_PEN);
3307 dc.SetBrush(!m_isDragging && m_hasFocus ? *m_hilightBrush : *m_hilightUnfocusedBrush);
3308 dc.SetTextForeground (colTextHilight);
3309 dc.DrawRectangle (text_x, item->
GetY() + off_h, text_w, total_h - off_h);
3313 dc.SetPen (drawCursor && i !=
GetMainColumn() ? *wxBLACK_PEN : *wxTRANSPARENT_PEN);
3314 dc.SetBrush (wxBrush ( colBg, wxBRUSHSTYLE_SOLID));
3315 dc.SetTextForeground (colText);
3316 dc.DrawRectangle (x_colstart, item->
GetY() + off_h, col_w, total_h - off_h);
3319 dc.SetPen (*wxBLACK_PEN);
3320 dc.SetBackgroundMode (wxTRANSPARENT);
3321 dc.DrawRectangle (text_x, item->
GetY() + off_h, text_w, total_h - off_h);
3328 wxPen pen (wxSystemSettings::GetColour (wxSYS_COLOUR_3DLIGHT ), 1, wxPENSTYLE_SOLID);
3329 dc.SetPen ((GetBackgroundColour() == *wxWHITE)? pen: *wxWHITE_PEN);
3330 dc.DrawLine (x_colstart+col_w-1, item->
GetY(), x_colstart+col_w-1, item->
GetY()+total_h);
3333 dc.SetBackgroundMode (wxTRANSPARENT);
3336 if (image !=
NO_IMAGE && m_imageListNormal && image < m_imageListNormal->GetImageCount()) {
3337 int y = item->
GetY() + img_extraH;
3338 m_imageListNormal->Draw (image, dc, x, y, wxIMAGELIST_DRAW_TRANSPARENT );
3342 int text_y = item->
GetY() + text_extraH;
3343 dc.DrawText (text, (wxCoord)text_x, (wxCoord)text_y);
3345 x_colstart += col_w;
3349 dc.SetFont( m_normalFont );
3354 int level,
int &y,
int x_maincol) {
3357 if (HasFlag(wxTR_HIDE_ROOT) && (level == 0)) {
3358 wxArrayTreeListItems& children = item->
GetChildren();
3359 for (
size_t n = 0; n < children.Count(); n++) {
3360 PaintLevel (children[n], dc, 1, y, x_maincol);
3367 int x = x_maincol +
MARGIN;
3368 if (HasFlag(wxTR_LINES_AT_ROOT)) x +=
LINEATROOT;
3372 x += (m_indent-m_indent/2);
3374 if (HasFlag(wxTR_HIDE_ROOT)) {
3375 x += m_indent * (level-1);
3377 x += m_indent * level;
3386 int y_mid = y_top + (h/2);
3389 int exposed_x = dc.LogicalToDeviceX(0);
3390 int exposed_y = dc.LogicalToDeviceY(y_top);
3392 if (IsExposed(exposed_x, exposed_y, 10000, h)) {
3394 if (HasFlag(wxTR_ROW_LINES)) {
3397 dc.SetPen(wxPen(wxSystemSettings::GetColour(wxSYS_COLOUR_3DLIGHT), 1, wxPENSTYLE_SOLID));
3398 dc.DrawLine (0, y_top, total_width, y_top);
3399 dc.DrawLine (0, y_top+h, total_width, y_top+h);
3406 dc.SetBrush(*wxWHITE_BRUSH);
3407 dc.SetPen(m_dottedPen);
3411 GetColumn(m_main_column).
GetWidth();
3412 wxDCClipper clipper(dc, x_maincol, y_top, clip_width, 10000);
3414 if (!HasFlag(wxTR_NO_LINES)) {
3417 dc.SetPen(m_dottedPen);
3419 if (x2 < (x_maincol + MARGIN)) x2 = x_maincol +
MARGIN;
3423 dc.DrawLine (x2, y_mid, x - m_btnWidth2, y_mid);
3424 dc.DrawLine (x3, y_mid, x3 +
LINEATROOT, y_mid);
3426 dc.DrawLine (x2, y_mid, x3 +
LINEATROOT, y_mid);
3429 dc.DrawLine (x2, y_mid, x - m_indent/2, y_mid);
3435 if (m_imageListButtons) {
3438 int image = wxTreeItemIcon_Normal;
3439 if (item->
IsExpanded()) image = wxTreeItemIcon_Expanded;
3440 if (item->
IsSelected()) image += wxTreeItemIcon_Selected - wxTreeItemIcon_Normal;
3441 int xx = x - m_btnWidth2 +
MARGIN;
3443 dc.SetClippingRegion(xx, yy, m_btnWidth, m_btnHeight);
3444 m_imageListButtons->Draw (image, dc, xx, yy, wxIMAGELIST_DRAW_TRANSPARENT);
3445 dc.DestroyClippingRegion();
3447 }
else if (HasFlag (wxTR_TWIST_BUTTONS)) {
3450 dc.SetPen(*wxBLACK_PEN);
3451 dc.SetBrush(*m_hilightBrush);
3454 button[0].x = x - (m_btnWidth2+1);
3455 button[0].y = y_mid - (m_btnHeight/3);
3456 button[1].x = x + (m_btnWidth2+1);
3457 button[1].y = button[0].y;
3459 button[2].y = button[0].y + (m_btnHeight2+1);
3461 button[0].x = x - (m_btnWidth/3);
3462 button[0].y = y_mid - (m_btnHeight2+1);
3463 button[1].x = button[0].x;
3464 button[1].y = y_mid + (m_btnHeight2+1);
3465 button[2].x = button[0].x + (m_btnWidth2+1);
3466 button[2].y = y_mid;
3468 dc.DrawPolygon(3, button);
3473 wxRect rect (x-m_btnWidth2, y_mid-m_btnHeight2, m_btnWidth, m_btnHeight);
3474 int flag = item->
IsExpanded()? wxCONTROL_EXPANDED: 0;
3475 wxRendererNative::Get().DrawTreeItemButton (
this, dc, rect, flag);
3483 dc.SetBrush(*wxWHITE_BRUSH);
3484 dc.SetPen(m_dottedPen);
3485 dc.SetTextForeground(*wxBLACK);
3489 wxArrayTreeListItems& children = item->
GetChildren();
3493 GetColumn(m_main_column).
GetWidth();
3497 if (m_imgWidth > 0) {
3503 for (
size_t n = 0; n < children.Count(); ++n) {
3506 PaintLevel (children[n], dc, level+1, y, x_maincol);
3509 wxDCClipper clipper(dc, x_maincol, y_top, clip_width, 10000);
3510 if (!HasFlag (wxTR_NO_LINES)) {
3512 dc.DrawLine (x, oldY, x, y2);
3527 wxAutoBufferedPaintDC dc (
this);
3528 wxBrush brush(GetBackgroundColour(), wxBRUSHSTYLE_SOLID);
3529 dc.SetBackground(brush);
3536 if (m_imageListButtons) {
3537 m_imageListButtons->GetSize (0, m_btnWidth, m_btnHeight);
3542 m_btnWidth2 = m_btnWidth/2;
3543 m_btnHeight2 = m_btnHeight/2;
3546 if (m_imageListNormal) {
3547 m_imageListNormal->GetSize (0, m_imgWidth, m_imgHeight);
3549 m_imgWidth2 = m_imgWidth/2;
3550 m_imgHeight2 = m_imgHeight/2;
3553 if (m_imageListButtons) {
3560 dc.SetFont( m_normalFont );
3561 dc.SetPen( m_dottedPen );
3571 PaintLevel (m_rootItem, dc, 0, y, x_maincol);
3591 wxTreeEvent nevent (wxEVT_COMMAND_TREE_KEY_DOWN, 0 );
3592 nevent.SetInt(m_curColumn);
3593 nevent.SetKeyEvent (event);
3595 nevent.SetExtraLong(event.GetModifiers());
3596 if (
SendEvent(0, NULL, &nevent))
return;
3599 bool curItemSet =
false;
3603 if (HasFlag(wxTR_HIDE_ROOT)) {
3604 wxTreeItemIdValue cookie = 0;
3607 SelectItem(m_curItem, (wxTreeItemId*)NULL,
true);
3612 if (HasFlag(wxTR_MULTIPLE) && event.ShiftDown()) {
3613 if (!m_shiftItem) m_shiftItem =
m_curItem;
3618 if (curItemSet)
return;
3621 wxTreeItemId newItem = (wxTreeItemId*)NULL;
3622 switch (event.GetKeyCode()) {
3632 case WXK_SUBTRACT: {
3638 case WXK_MULTIPLY: {
3641 }
else if (m_curItem->
HasPlus()) {
3653 if (!
SendEvent(wxEVT_COMMAND_TREE_ITEM_ACTIVATED, m_curItem)) {
3665 if ((newItem ==
GetRootItem()) && HasFlag(wxTR_HIDE_ROOT)) {
3679 wxPoint abs_p = CalcUnscrolledPosition (wxPoint(1,1));
3681 newItem = m_rootItem->
HitTest(abs_p,
this, flags, col, 0);
3684 if (newItem == m_curItem) {
3685 abs_p.y -= GetClientSize().GetHeight() - m_curItem->
GetHeight();
3686 if (abs_p.y < 0) abs_p.y = 0;
3687 newItem = m_rootItem->
HitTest(abs_p,
this, flags, col, 0);
3696 wxTreeItemIdValue cookie = 0;
3702 if ((newItem ==
GetRootItem()) && HasFlag(wxTR_HIDE_ROOT)) {
3703 newItem = (wxTreeItemId*)NULL;
3714 if ((newItem ==
GetRootItem()) && HasFlag(wxTR_HIDE_ROOT)) {
3726 wxTreeItemIdValue cookie = 0;
3735 wxTreeItemIdValue cookie = 0;
3743 }
while (!newItem && parent);
3748 case WXK_PAGEDOWN: {
3751 wxPoint abs_p = CalcUnscrolledPosition (wxPoint(1,GetClientSize().GetHeight() - m_curItem->
GetHeight()));
3753 newItem = m_rootItem->
HitTest(abs_p,
this, flags, col, 0);
3756 if (newItem == m_curItem) {
3757 abs_p.y += GetClientSize().GetHeight() - m_curItem->
GetHeight();
3759 newItem = m_rootItem->
HitTest(abs_p,
this, flags, col, 0);
3772 wxChar key =
event.GetUnicodeKey();
3773 if (key == WXK_NONE) key = (wxChar)event.GetKeyCode();
3777 if (!m_findTimer->IsRunning()) m_findStr.Clear();
3778 m_findStr.Append (key);
3780 wxTreeItemId prev = (wxTreeItemId*)NULL;
3783 prev = (wxTreeItemId*)m_curItem;
3791 newItem =
FindItem (prev, -1, m_findStr, mode);
3797 prev = (wxTreeItemId*)NULL;
3798 newItem =
FindItem (prev, -1, m_findStr, mode);
3801 if (! newItem) m_findStr.RemoveLast();
3809 if (!event.ControlDown()) {
3810 bool unselect_others = !((
event.ShiftDown() ||
event.ControlDown()) &&
3811 HasFlag(wxTR_MULTIPLE));
3812 SelectItem (newItem, m_shiftItem, unselect_others);
3828 if (point.x<0) flags |= wxTREE_HITTEST_TOLEFT;
3829 if (point.x>w) flags |= wxTREE_HITTEST_TORIGHT;
3830 if (point.y<0) flags |= wxTREE_HITTEST_ABOVE;
3831 if (point.y>h) flags |= wxTREE_HITTEST_BELOW;
3832 if (flags)
return wxTreeItemId();
3835 flags = wxTREE_HITTEST_NOWHERE;
3837 return wxTreeItemId();
3841 this, flags, column, 0);
3843 flags = wxTREE_HITTEST_NOWHERE;
3845 return wxTreeItemId();
3852 bool WXUNUSED(textOnly))
const {
3853 wxCHECK_MSG (itemId.IsOk(),
false, _T(
"invalid item in wxTreeListMainWindow::GetBoundingRect") );
3858 GetScrollPixelsPerUnit (&xUnit, &yUnit);
3860 GetViewStart(& startX, & startY);
3862 rect.x = item->GetX() - startX * xUnit;
3863 rect.y = item->GetY() - startY * yUnit;
3864 rect.width = item->GetWidth();
3875 if (!item.IsOk())
return;
3879 if (m_editControl) { m_editControl->
EndEdit(
true); }
3884 wxTreeEvent te( wxEVT_COMMAND_TREE_BEGIN_LABEL_EDIT, 0 );
3886 SendEvent(0, m_editItem, &te);
if (!te.IsAllowed())
return;
3897 int y = m_editItem->
GetY() + 1;
3901 x += m_editItem->
GetTextX(column) - 2;
3904 for (
int i = 0; i < column; ++i) {
3912 case wxALIGN_LEFT: {style = wxTE_LEFT; x -= 1;
break;}
3913 case wxALIGN_CENTER: {style = wxTE_CENTER; x -= 1;
break;}
3914 case wxALIGN_RIGHT: {style = wxTE_RIGHT; x += 0;
break;}
3921 wxClientDC dc (
this);
3923 x = dc.LogicalToDeviceX (x);
3924 y = dc.LogicalToDeviceY (y);
3928 m_editControl =
new wxEditTextCtrl (
this, -1, &m_editAccept, &m_editRes,
3929 this, m_editItem->
GetText (column),
3930 wxPoint (x, y), wxSize (w, h), style);
3931 m_editControl->SelectAll();
3932 m_editControl->SetFocus();
3942 wxTreeEvent le( wxEVT_COMMAND_TREE_END_LABEL_EDIT, 0 );
3943 le.SetLabel( m_editRes );
3944 le.SetEditCanceled(isCancelled);
3945 le.SetInt(m_editCol);
3946 SendEvent(0, m_editItem, &le);
if (! isCancelled && le.IsAllowed())
3948 SetItemText (m_editItem, le.GetInt(), le.GetLabel());
3953 if (m_editControl) { m_editControl->
EndEdit(
true); }
3957 bool mayDrag =
true;
3958 bool maySelect =
true;
3959 bool mayClick =
true;
3960 bool mayDoubleClick =
true;
3964 if (m_owner->GetEventHandler()->ProcessEvent(event))
return;
3965 if (!m_rootItem)
return;
3975 wxPoint p = wxPoint (event.GetX(),
event.GetY());
3978 this, flags, m_curColumn, 0);
3979 bool bCrosshair = (item && item->
HasPlus() && (flags & wxTREE_HITTEST_ONITEMBUTTON));
3982 maySelect = mayDoubleClick =
false;
3985 if (event.Dragging()) {
3986 maySelect = mayDoubleClick = mayClick =
false;
3991 if (event.LeftDown()) maySelect =
false;
3993 mayDoubleClick =
false;
3996 if (mayDoubleClick) mayDoubleClick = mayClick;
3998 if (maySelect) maySelect = mayClick;
4003 if (HasFlag(wxTR_MULTIPLE)) {
4007 if (event.ControlDown() ||
event.ShiftDown()) {
4008 maySelect = maySelect && (
event.LeftDown() ||
event.RightDown());
4009 m_lastOnSame =
false;
4014 }
else if ((item != NULL && item->
IsSelected())) {
4015 maySelect = maySelect &&
event.LeftUp();
4020 maySelect = maySelect && (
event.LeftDown() ||
event.RightDown());
4025 maySelect = maySelect && (
event.LeftDown() ||
event.RightDown());
4033 if (event.LeftDown() ||
event.MiddleDown() ||
event.RightDown())
SetFocus();
4036 if (item != m_toolTipItem) {
4040 m_toolTipItem = NULL;
4041 wxScrolledWindow::SetToolTip(m_toolTip);
4049 m_toolTipItem = item;
4050 wxScrolledWindow::SetToolTip(*tip);
4054 }
else if (m_isItemToolTip) {
4055 m_toolTipItem = item;
4056 wxScrolledWindow::SetToolTip(wxString());
4059 }
else if (m_toolTipItem != NULL) {
4060 m_toolTipItem = NULL;
4061 wxScrolledWindow::SetToolTip(m_toolTip);
4071 if (event.LeftDown()) m_lastOnSame = (item == m_curItem);
4074 if (bCrosshair && event.LeftDown()) {
4087 if (event.LeftDown() && HasFlag(wxTR_MULTIPLE) &&
event.ShiftDown()) {
4088 if (!m_shiftItem) m_shiftItem =
m_curItem;
4095 bool unselect_others = ! (HasFlag(wxTR_MULTIPLE) && (
4097 ||
event.ControlDown()
4101 if (
SelectItem(item, m_shiftItem, unselect_others)) {
4109 if (event.MiddleDown()) {
4111 wxTreeEvent nevent(0, 0);
4113 nevent.SetInt(m_curColumn);
4115 SendEvent(wxEVT_COMMAND_TREE_ITEM_MIDDLE_CLICK, item, &nevent);
4117 if (event.RightDown()) {
4119 wxTreeEvent nevent(0, 0);
4121 nevent.SetInt(m_curColumn);
4123 SendEvent(wxEVT_COMMAND_TREE_ITEM_RIGHT_CLICK, item, &nevent);
4125 if (event.RightUp()) {
4127 wxTreeEvent nevent(0, 0);
4129 nevent.SetInt(m_curColumn);
4130 SendEvent(wxEVT_COMMAND_TREE_ITEM_MENU, item, &nevent);
4134 if (m_lastOnSame && event.LeftUp()) {
4135 if ((item == m_curItem) && (m_curColumn != -1) &&
4142 m_lastOnSame =
false;
4148 if (mayDoubleClick && event.LeftDClick()) {
4153 m_editTimer->Stop();
4154 m_lastOnSame =
false;
4157 if (
SelectItem(item, (wxTreeItemId*)NULL,
true)) {
4160 if (!
SendEvent(wxEVT_COMMAND_TREE_ITEM_ACTIVATED, item)) {
4179 if (event.LeftDown() ||
event.MiddleDown() ||
event.RightDown()) {
4184 m_isDragStarted = m_isDragging =
false;
4185 if (HasCapture()) ReleaseMouse();
4189 }
else if (event.Dragging()) {
4199 m_isDragStarted = m_isDragging =
false;
4200 if (HasCapture()) ReleaseMouse();
4205 wxTreeEvent nevent(0, 0);
4207 nevent.SetInt(m_curColumn);
4208 SendEvent(wxEVT_COMMAND_TREE_END_DRAG, item, &nevent);
4212 }
else if (event.Dragging()) {
4215 if (m_isDragStarted) {
4216 const int tolerance = 3;
4217 int dx = abs(p.x - m_dragStartPos.x);
4218 int dy = abs(p.y - m_dragStartPos.y);
4219 if (dx <= tolerance && dy <= tolerance)
4226 m_isDragStarted =
true;
4233 m_isDragging =
true;
4237 wxTreeEvent nevent(0, 0);
4239 nevent.SetInt(m_dragCol);
4242 ? wxEVT_COMMAND_TREE_BEGIN_DRAG
4243 : wxEVT_COMMAND_TREE_BEGIN_RDRAG,
4249 if (bSkip)
event.Skip();
4257 if (!m_dirty)
return;
4269 if (m_owner->GetEventHandler()->ProcessEvent(event))
return;
4272 HandleOnScroll( event );
4274 if(event.GetOrientation() == wxHORIZONTAL) {
4285 dc.GetTextExtent (!item->
GetText(m_main_column).empty()
4286 ? item->
GetText (m_main_column)
4290 dc.SetFont (m_normalFont);
4292 int max_h = (m_imgHeight > text_h) ? m_imgHeight : text_h;
4296 max_h += max_h / 10;
4300 if (max_h > m_lineHeight) m_lineHeight = max_h;
4301 item->
SetWidth(m_imgWidth + text_w+2);
4306 int level,
int &y,
int x_colstart) {
4309 int x = x_colstart +
MARGIN;
4310 if (HasFlag(wxTR_LINES_AT_ROOT)) x +=
LINEATROOT;
4314 x += (m_indent-m_indent/2);
4316 if (HasFlag(wxTR_HIDE_ROOT)) {
4317 x += m_indent * (level-1);
4319 x += m_indent * level;
4323 if (HasFlag(wxTR_HIDE_ROOT) && (level == 0))
goto Recurse;
4336 wxArrayTreeListItems& children = item->
GetChildren();
4337 long n, count = (long)children.Count();
4339 for (n = 0; n < count; ++n) {
4345 if ( !m_rootItem )
return;
4347 wxClientDC dc(
this);
4350 dc.SetFont( m_normalFont );
4352 dc.SetPen( m_dottedPen );
4366 if (m_dirty)
return;
4368 wxClientDC dc(
this);
4373 GetVirtualSize( &cw, &ch );
4376 rect.x = dc.LogicalToDeviceX( 0 );
4378 rect.y = dc.LogicalToDeviceY( item->
GetY() - 2 );
4381 Refresh (
true, &rect );
4386 if (m_dirty)
return;
4388 wxClientDC dc(
this);
4393 GetVirtualSize( &cw, &ch );
4396 rect.x = dc.LogicalToDeviceX( 0 );
4397 rect.y = dc.LogicalToDeviceY( item->
GetY() );
4401 Refresh (
true, &rect);
4417 const wxArrayTreeListItems& children = item->
GetChildren();
4418 long count = (long)children.GetCount();
4419 for (
long n = 0; n < count; n++ ) {
4429 if (!wxWindow::SetBackgroundColour(colour))
return false;
4436 if (!wxWindow::SetForegroundColour(colour))
return false;
4443 wxCHECK_RET (itemId.IsOk(), _T(
"invalid tree item"));
4445 if (this->IsFrozen())
4453 wxClientDC dc(
this);
4462 wxCHECK_MSG (itemId.IsOk(), _T(
""), _T(
"invalid tree item") );
4465 else return ((
wxTreeListItem*) itemId.m_pItem)->GetText (column);
4469 wxASSERT_MSG(
IsVirtual(), _T(
"can be used only with virtual control") );
4474 wxWindow::SetFocus();
4479 if (!item)
return 0;
4484 GetTextExtent (item->
GetText (column), &w, &
h, NULL, NULL, font.Ok()? &font: NULL);
4488 int width = w + 2*
MARGIN;
4491 if (HasFlag(wxTR_LINES_AT_ROOT)) width +=
LINEATROOT;
4499 while (parent && (!HasFlag(wxTR_HIDE_ROOT) || (parent != root))) {
4503 if (level) width += level *
GetIndent();
4511 GetClientSize (&maxWidth, &h);
4518 if (!HasFlag(wxTR_HIDE_ROOT)) {
4520 if (width < w) width = w;
4521 if (width > maxWidth)
return maxWidth;
4524 wxTreeItemIdValue cookie = 0;
4526 while (item.IsOk()) {
4528 if (width < w) width = w;
4529 if (width > maxWidth)
return maxWidth;
4534 if (width < w) width = w;
4535 if (width > maxWidth)
return maxWidth;
4547 wxTreeEvent nevent (event_type, 0);
4549 if (event == NULL) {
4551 event->SetInt (m_curColumn);
4552 }
else if (event_type) {
4553 event->SetEventType(event_type);
4556 event->SetEventObject (m_owner);
4557 event->SetId(m_owner->GetId());
4559 event->SetItem (item);
4562 return m_owner->GetEventHandler()->ProcessEvent (*event);
4565 #if wxCHECK_VERSION(3,1,3)
4566 void wxTreeListMainWindow::OnDpiChanged(wxDPIChangedEvent& e)
4570 if (m_imageListNormal)
4584 BEGIN_EVENT_TABLE(wxTreeListCtrl, wxControl)
4585 EVT_SIZE(wxTreeListCtrl::OnSize)
4591 long style, const wxValidator &validator,
4592 const wxString& name)
4594 long main_style = style & ~(wxBORDER_SIMPLE | wxBORDER_SUNKEN | wxBORDER_DOUBLE |
4595 wxBORDER_RAISED | wxBORDER_STATIC);
4596 main_style |= wxWANTS_CHARS ;
4597 long ctrl_style = style & ~(wxVSCROLL|wxHSCROLL);
4599 if (!wxControl::Create(parent,
id, pos, size, ctrl_style, validator, name)) {
4602 m_main_win =
new wxTreeListMainWindow (
this, -1, wxPoint(0, 0), size,
4603 main_style, validator);
4605 wxPoint(0, 0), wxDefaultSize,
4607 CalculateAndSetHeaderHeight();
4618 h = (int)(wxRendererNative::Get().GetHeaderButtonHeight(
m_header_win) * 0.8) + 2;
4620 h = wxRendererNative::Get().GetHeaderButtonHeight(
m_header_win);
4634 GetClientSize(&w, &h);
4783 long main_style = style & ~(wxBORDER_SIMPLE | wxBORDER_SUNKEN | wxBORDER_DOUBLE | wxBORDER_RAISED | wxBORDER_STATIC);
4784 main_style |= wxWANTS_CHARS;
4787 m_windowStyle = style & ~(wxVSCROLL | wxHSCROLL);
4793 long style = m_windowStyle;
4827 wxTreeItemIdValue& cookie)
const
4831 wxTreeItemIdValue& cookie)
const
4835 wxTreeItemIdValue& cookie)
const
4839 wxTreeItemIdValue& cookie)
const
4879 int selectedImage, wxTreeItemData*
data)
4883 const wxString& text,
int image,
4885 wxTreeItemData*
data)
4889 const wxTreeItemId& previous,
4890 const wxString& text,
int image,
4892 wxTreeItemData*
data)
4895 selectedImage, data);
4900 const wxString& text,
int image,
4902 wxTreeItemData*
data)
4905 selectedImage, data);
4909 const wxString& text,
int image,
4911 wxTreeItemData*
data)
4945 bool unselect_others)
4964 bool textOnly)
const
5081 wxASSERT_MSG (column !=
GetMainColumn(), _T(
"The main column may not be hidden") );
5119 wxSize bestSizeMain =
m_main_win->GetBestSize();
5120 return wxSize (bestSizeHeader.x > bestSizeMain.x ? bestSizeHeader.x : bestSizeMain.x, bestSizeHeader.y + bestSizeMain.y);
5125 return wxEmptyString;
5157 wxTreeListCtrlXmlHandler::wxTreeListCtrlXmlHandler() : wxXmlResourceHandler() {
5159 #define wxTR_NO_BUTTONS 0x0000 // for convenience
5160 #define wxTR_HAS_BUTTONS 0x0001 // draw collapsed/expanded btns
5161 #define wxTR_NO_LINES 0x0004 // don't draw lines at all
5162 #define wxTR_LINES_AT_ROOT 0x0008 // connect top-level nodes
5163 #define wxTR_TWIST_BUTTONS 0x0010 // still used by wxTreeListCtrl
5165 #define wxTR_SINGLE 0x0000 // for convenience
5166 #define wxTR_MULTIPLE 0x0020 // can select multiple items
5167 #define wxTR_EXTENDED 0x0040 // TODO: allow extended selection
5168 #define wxTR_HAS_VARIABLE_ROW_HEIGHT 0x0080 // what it says
5170 #define wxTR_EDIT_LABELS 0x0200 // can edit item labels
5171 #define wxTR_ROW_LINES 0x0400 // put border around items
5172 #define wxTR_HIDE_ROOT 0x0800 // don't display root node
5174 #define wxTR_FULL_ROW_HIGHLIGHT 0x2000 // highlight full horz space
5177 #define wxTR_DEFAULT_STYLE (wxTR_HAS_BUTTONS | wxTR_NO_LINES)
5179 #define wxTR_DEFAULT_STYLE (wxTR_HAS_BUTTONS | wxTR_LINES_AT_ROOT)
5183 XRC_ADD_STYLE(wxTR_NO_BUTTONS);
5184 XRC_ADD_STYLE(wxTR_HAS_BUTTONS);
5185 XRC_ADD_STYLE(wxTR_NO_LINES);
5186 XRC_ADD_STYLE(wxTR_LINES_AT_ROOT);
5187 XRC_ADD_STYLE(wxTR_TWIST_BUTTONS);
5189 XRC_ADD_STYLE(wxTR_SINGLE);
5190 XRC_ADD_STYLE(wxTR_MULTIPLE);
5191 #if WXWIN_COMPATIBILITY_2_8
5193 XRC_ADD_STYLE(wxTR_EXTENDED);
5194 #endif // WXWIN_COMPATIBILITY_2_8
5195 XRC_ADD_STYLE(wxTR_HAS_VARIABLE_ROW_HEIGHT);
5197 XRC_ADD_STYLE(wxTR_EDIT_LABELS);
5198 XRC_ADD_STYLE(wxTR_ROW_LINES);
5199 XRC_ADD_STYLE(wxTR_HIDE_ROOT);
5201 XRC_ADD_STYLE(wxTR_FULL_ROW_HIGHLIGHT);
5203 XRC_ADD_STYLE(wxTR_DEFAULT_STYLE);
5213 wxObject *wxTreeListCtrlXmlHandler::DoCreateResource() {
5214 XRC_MAKE_INSTANCE(tlc, wxTreeListCtrl);
5215 tlc->Create(m_parentAsWindow, GetID(), GetPosition(), GetSize(), GetStyle(), wxDefaultValidator, GetName());
5220 bool wxTreeListCtrlXmlHandler::CanHandle(wxXmlNode * node) {
5221 return IsOfClass(node, wxT(
"TreeListCtrl"));
wxTreeListItem * m_dragItem
int GetImage(wxTreeItemIcon which=wxTreeItemIcon_Normal) const
bool TagNextChildren(wxTreeListItem *crt_item, wxTreeListItem *last_item)
wxFont GetItemFont(const wxTreeItemId &item) const
void PaintLevel(wxTreeListItem *item, wxDC &dc, int level, int &y, int x_maincol)
wxTreeListMainWindow * m_owner
void Refresh(bool erase=TRUE, const wxRect *rect=NULL)
void SetItemData(const wxTreeItemId &item, wxTreeItemData *data)
void CalculateAndSetHeaderHeight()
void SetItemFont(const wxTreeItemId &item, const wxFont &font)
wxTreeItemId InsertItem(const wxTreeItemId &parent, const wxTreeItemId &idPrevious, const wxString &text, int image=-1, int selectedImage=-1, wxTreeItemData *data=NULL)
void OnChar(wxKeyEvent &event)
static const int NO_IMAGE
void AssignButtonsImageList(wxImageList *imageList)
wxTreeListColumnInfo GetColumn(int column)
unsigned int GetLineSpacing() const
size_t GetChildrenCount(bool recursively=true) const
wxTreeListItem * GetItemParent() const
void SetBold(int column, bool bold)
void SetItemText(const wxTreeItemId &item, int column, const wxString &text)
WX_DEFINE_ARRAY_PTR(wxTreeListItem *, wxArrayTreeListItems)
void CollapseAndReset(const wxTreeItemId &item)
wxTreeItemId GetNextVisible(const wxTreeItemId &item, bool fullRow=false, bool within=true) const
void OnSize(wxSizeEvent &event)
bool GetBoundingRect(const wxTreeItemId &item, wxRect &rect, bool textOnly=false) const
void SetImage(int column, int image, wxTreeItemIcon which)
void EnsureVisible(const wxTreeItemId &item)
virtual long GetWindowStyleFlag() const
void Delete(const wxTreeItemId &item)
wxTreeItemId GetPrev(const wxTreeItemId &item) const
void RefreshSelectedUnder(wxTreeListItem *item)
size_t GetChildrenCount(const wxTreeItemId &item, bool recursively=true)
wxTreeItemId AppendItem(const wxTreeItemId &parent, const wxString &text, int image=-1, int selectedImage=-1, wxTreeItemData *data=NULL)
wxTreeItemData * GetData() const
const int wxTREE_HITTEST_ONITEMCOLUMN
wxTreeListMainWindow * m_owner
void SetItemBackgroundColour(const wxTreeItemId &item, const wxColour &colour)
wxTreeListRenameTimer(wxTreeListMainWindow *owner)
virtual bool SetForegroundColour(const wxColour &colour)
void EndEdit(bool isCancelled)
void ScrollTo(const wxTreeItemId &item)
bool SelectItem(const wxTreeItemId &item, const wxTreeItemId &prev=(wxTreeItemId *) NULL, bool unselect_others=true)
static const int RENAME_TIMER_TICKS
void AssignStateImageList(wxImageList *imageList)
void EnsureVisible(const wxTreeItemId &item)
void OnKeyUp(wxKeyEvent &event)
void SetColumnWidth(int column, int width)
const int wxTL_MODE_NAV_EXPANDED
WX_DEFINE_OBJARRAY(wxArrayTreeListColumnInfo)
size_t GetChildrenCount(const wxTreeItemId &item, bool recursively=true)
void SortChildren(const wxTreeItemId &item, int column, bool reverseOrder)
wxTreeItemId FindItem(const wxTreeItemId &item, const wxString &str, int mode=0)
friend class wxTreeListItem
wxTreeItemId GetRootItem() const
void Toggle(const wxTreeItemId &item)
void AdjustMyScrollbars()
void SetItemTextColour(const wxTreeItemId &item, const wxColour &colour)
wxColour GetItemBackgroundColour(const wxTreeItemId &item) const
void SetItemData(const wxTreeItemId &item, wxTreeItemData *data)
wxTreeItemId GetNextVisible(const wxTreeItemId &item, bool fullRow, bool within) const
static const int LINEHEIGHT
void SetColumnImage(int column, int image)
static const int DRAG_TIMER_TICKS
bool Create(wxTreeListCtrl *parent, wxWindowID id=-1, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxTR_DEFAULT_STYLE, const wxValidator &validator=wxDefaultValidator, const wxString &name=_T("wxtreelistctrl"))
virtual bool SetBackgroundColour(const wxColour &colour)
static wxTreeListColumnInfo wxInvalidTreeListColumnInfo
static const int HEADER_OFFSET_Y
void SortChildren(const wxTreeItemId &item, int column=-1, bool reverseOrder=false)
wxArrayTreeListItems & GetChildren()
void SetItemFont(const wxTreeItemId &item, const wxFont &font)
wxTreeItemId GetNextSibling(const wxTreeItemId &item) const
void SetLineSpacing(unsigned int spacing)
wxTreeItemId GetNextExpanded(const wxTreeItemId &item) const
void SetHeight(int height)
wxTreeItemId GetPrevSibling(const wxTreeItemId &item) const
void Collapse(const wxTreeItemId &item)
wxTreeItemId AppendItem(const wxTreeItemId &parent, const wxString &text, int image=-1, int selectedImage=-1, wxTreeItemData *data=NULL)
void SetItemBackgroundColour(const wxTreeItemId &item, const wxColour &colour)
bool SelectItem(const wxTreeItemId &item, const wxTreeItemId &last=(wxTreeItemId *) NULL, bool unselect_others=true)
wxTreeItemAttr * GetAttributes() const
void SetItemParent(const wxTreeItemId &parent, const wxTreeItemId &item)
void SetColumnShown(int column, bool shown=true)
void CalculateSize(wxTreeListItem *item, wxDC &dc)
wxTreeItemData * GetItemData(const wxTreeItemId &item) const
void EndEdit(bool isCancelled)
~wxTreeListItemCellAttr()
void OnRenameAccept(bool isCancelled)
wxTreeItemId AddRoot(const wxString &text, int image=-1, int selectedImage=-1, wxTreeItemData *data=NULL)
void SetColumnAlignment(int column, int flag)
void OnChar(wxKeyEvent &event)
wxTreeItemId GetItemParent(const wxTreeItemId &item) const
void DeleteChildren(const wxTreeItemId &item)
static const int HEADER_OFFSET_X
wxTreeItemId GetPrevExpanded(const wxTreeItemId &item) const
void SetToolTip(const wxString &tip)
const int wxTL_MODE_FIND_NOCASE
int GetMainColumn() const
void RefreshSubtree(wxTreeListItem *item)
void AssignImageList(wxImageList *imageList)
void EndEdit(bool isCancelled)
static const int EXTRA_WIDTH
void SetColumnEditable(int column, bool edit=true)
wxTreeItemId GetLastChild(const wxTreeItemId &item, wxTreeItemIdValue &cookie) const
wxTreeItemId GetItemParent(const wxTreeItemId &item) const
bool IsVisible(const wxTreeItemId &item, bool fullRow=false, bool within=true) const
unsigned short m_linespacing
wxTreeListItem * m_rootItem
wxTreeItemId GetNextSibling(const wxTreeItemId &item) const
wxTreeItemId GetFirstChild(const wxTreeItemId &item, wxTreeItemIdValue &cookie) const
bool IsColumnShown(int column) const
wxTreeItemId GetPrevSibling(const wxTreeItemId &item) const
void SetImageList(wxImageList *imageList)
void SetMainColumn(int column)
int GetColumnAlignment(int column) const
static const int BTNHEIGHT
bool GetItemBold(const wxTreeItemId &item) const
wxTreeItemId HitTest(const wxPoint &point)
const int wxTL_MODE_NAV_LEVEL
int GetCurrentColumn() const
wxTreeItemId GetFirstExpandedItem() const
void SetLineSpacing(unsigned int spacing)
void Collapse(const wxTreeItemId &item)
bool IsBold(const wxTreeItemId &item) const
size_t GetSelections(wxArrayTreeItemIds &) const
void SetItemHasChildren(const wxTreeItemId &item, bool has=true)
wxTreeItemId PrependItem(const wxTreeItemId &parent, const wxString &text, int image=-1, int selectedImage=-1, wxTreeItemData *data=NULL)
void GetSize(int &x, int &y, const wxTreeListMainWindow *)
bool m_left_down_selection
void SetItemBold(const wxTreeItemId &item, bool bold=true)
void AssignStateImageList(wxImageList *imageList)
void CalculateLineHeight()
wxImageList * GetButtonsImageList() const
wxTreeItemId GetLastVisible(bool fullRow, bool within) const
wxTreeItemId GetRootItem() const
virtual int OnCompareItems(const wxTreeItemId &item1, const wxTreeItemId &item2)
wxTreeListItemCellAttr m_props_row
void SetMainColumn(int column)
wxString GetItemText(const wxTreeItemId &item, int column) const
wxTreeItemId GetLastVisible(bool fullRow=false, bool within=true) const
void SetItemImage(const wxTreeItemId &item, int image, wxTreeItemIcon which=wxTreeItemIcon_Normal)
bool IsColumnEditable(int column) const
wxTreeItemId GetNext(const wxTreeItemId &item) const
void SetItemImage(const wxTreeItemId &item, int image, wxTreeItemIcon which=wxTreeItemIcon_Normal)
wxTreeListMainWindow(wxTreeListCtrl *parent, wxWindowID id=-1, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxTR_DEFAULT_STYLE, const wxValidator &validator=wxDefaultValidator, const wxString &name=_T("wxtreelistmainwindow"))
bool IsVisible(const wxTreeItemId &item, bool fullRow, bool within=true) const
wxTreeItemId AddRoot(const wxString &text, int image=-1, int selectedImage=-1, wxTreeItemData *data=NULL)
wxTreeItemId FindItem(const wxTreeItemId &item, int column, const wxString &str, int mode=0)
virtual ~wxTreeListMainWindow()
void FillArray(wxTreeListItem *, wxArrayTreeItemIds &) const
void SetItemParent(wxTreeListItem *parent)
wxTreeListItem * m_selectItem
short m_images[wxTreeItemIcon_Max]
wxTreeItemId GetLastChild(const wxTreeItemId &item, wxTreeItemIdValue &cookie) const
bool HasButtons(void) const
wxTreeListItem * m_shiftItem
void SetItemToolTip(const wxTreeItemId &item, const wxString &tip)
void Insert(wxTreeListItem *child, size_t index)
bool IsSelected(const wxTreeItemId &item) const
void PaintItem(wxTreeListItem *item, wxDC &dc)
void SetText(int column, const wxString &text)
void Expand(const wxTreeItemId &item)
void SetIndent(unsigned int indent)
void InsertColumn(int before, const wxString &text, int width=DEFAULT_COL_WIDTH, int flag=wxALIGN_LEFT, int image=-1, bool shown=true, bool edit=false, const wxString &tooltip=wxEmptyString)
void SetData(int column, wxTreeItemData *data)
void SetStateImageList(wxImageList *imageList)
bool SendEvent(wxEventType event_type, wxTreeListItem *item=NULL, wxTreeEvent *event=NULL)
void AssignButtonsImageList(wxImageList *imageList)
void SetImage(int image, wxTreeItemIcon which)
wxImageList * GetImageList() const
unsigned int GetLineSpacing() const
void EditLabel(const wxTreeItemId &item, int column)
wxTreeListItem * HitTest(const wxPoint &point, const wxTreeListMainWindow *, int &flags, int &column, int level)
wxTreeItemId PrependItem(const wxTreeItemId &parent, const wxString &text, int image=-1, int selectedImage=-1, wxTreeItemData *data=NULL)
wxTreeItemId GetFirstChild(const wxTreeItemId &item, wxTreeItemIdValue &cookie) const
void SetCurrentItem(const wxTreeItemId &item)
WX_DECLARE_OBJARRAY(wxTreeListColumnInfo, wxArrayTreeListColumnInfo)
wxTreeItemId GetPrev(const wxTreeItemId &item, bool fulltree=true) const
bool HasChildren(const wxTreeItemId &item) const
IMPLEMENT_DYNAMIC_CLASS(wxTreeListHeaderWindow, wxWindow)
static int LINKAGEMODE tree_ctrl_compare_func(wxTreeListItem **item1, wxTreeListItem **item2)
bool m_ownsImageListState
EVT_ERASE_BACKGROUND(wxTreeListHeaderWindow::OnEraseBackground) void wxTreeListHeaderWindow
virtual void SetWindowStyleFlag(long styles)
void SetItemBold(const wxTreeItemId &item, bool bold=true)
int GetImage(int column, wxTreeItemIcon which=wxTreeItemIcon_Normal) const
void AddColumn(const wxString &text, int width=DEFAULT_COL_WIDTH, int flag=wxALIGN_LEFT, int image=-1, bool shown=true, bool edit=false, const wxString &tooltip=wxEmptyString)
wxTreeItemAttr & Attr(int column)
int GetBestColumnWidth(int column, wxTreeItemId parent=wxTreeItemId())
wxTreeItemId HitTest(const wxPoint &point)
wxColour GetItemTextColour(const wxTreeItemId &item) const
void ExpandAll(const wxTreeItemId &item)
wxTreeItemId GetNextChild(const wxTreeItemId &item, wxTreeItemIdValue &cookie) const
void RefreshLine(wxTreeListItem *item)
void Expand(const wxTreeItemId &item)
static const int LINEATROOT
int GetItemWidth(int column, wxTreeListItem *item)
wxTreeItemId GetFirstVisible(bool fullRow=false, bool within=true) const
void AssignImageList(wxImageList *imageList)
void SetItemToolTip(const wxTreeItemId &item, const wxString &tip)
void OnKillFocus(wxFocusEvent &event)
int GetColumnCount() const
const wxChar * wxTreeListCtrlNameStr
bool GetItemBold(const wxTreeItemId &item) const
wxColour GetItemTextColour(const wxTreeItemId &item) const
static wxTreeListMainWindow * s_treeBeingSorted
wxColour GetItemBackgroundColour(const wxTreeItemId &item) const
int GetCurrentImage() const
void SetColumn(int column, const wxTreeListColumnInfo &colInfo)
wxTreeItemId InsertItem(const wxTreeItemId &parent, const wxTreeItemId &idPrevious, const wxString &text, int image=-1, int selectedImage=-1, wxTreeItemData *data=NULL)
int GetTextX(int column) const
void OnIdle(wxIdleEvent &event)
wxTreeItemId GetFirstExpandedItem() const
const int wxTL_MODE_FIND_PARTIAL
void SetColumnText(int column, const wxString &text)
void SetCurrentItem(const wxTreeItemId &item=(wxTreeItemId *) NULL)
void RemoveColumn(int column)
void SetItemParent(const wxTreeItemId &parent, const wxTreeItemId &item)
virtual wxString OnGetItemText(wxTreeItemData *item, long column) const
wxTreeListItem * m_parent
void SetItemTextColour(const wxTreeItemId &item, const wxColour &colour)
const wxString GetText(int column) const
int GetItemImage(const wxTreeItemId &item, wxTreeItemIcon which=wxTreeItemIcon_Normal) const
int GetColumnImage(int column) const
unsigned int GetIndent() const
wxTreeItemId HitTest(const wxPoint &point, int &flags)
bool IsSelected(const wxTreeItemId &item) const
void UnselectAllChildren(wxTreeListItem *item)
wxImageList * m_imageListButtons
virtual bool SetForegroundColour(const wxColour &colour)
void SetTextX(int column, int text_x)
wxArrayTreeListItems m_children
friend class wxEditTextCtrl
wxTreeItemId GetFirstVisible(bool fullRow, bool within) const
void SetOwner(wxTreeListMainWindow *owner)
bool IsExpanded(const wxTreeItemId &item) const
wxTreeItemId GetPrevChild(const wxTreeItemId &item, wxTreeItemIdValue &cookie) const
bool TagAllChildrenUntilLast(wxTreeListItem *crt_item, wxTreeListItem *last_item)
void SetHasPlus(bool has=true)
static const int EXTRA_HEIGHT
options wxIntPtr wxIntPtr sortData std::vector< PanoInfo > * data
wxTreeItemId GetNext(const wxTreeItemId &item, bool fulltree=true) const
#define wxTR_COLUMN_LINES
static const int MININDENT
int GetLineHeight(wxTreeListItem *item) const
virtual wxSize DoGetBestSize() const
static const int BTNWIDTH
wxTreeItemId GetFirstVisibleItem(bool fullRow=false) const
void SetDragItem(const wxTreeItemId &item=(wxTreeItemId *) NULL)
wxTreeItemId DoInsertItem(const wxTreeItemId &parent, size_t previous, const wxString &text, int image, int selectedImage, wxTreeItemData *data)
void SetToolTip(const wxString &tip)
void SetWindowStyle(const long styles)
int GetItemImage(const wxTreeItemId &item, wxTreeItemIcon which=wxTreeItemIcon_Normal) const
int GetColumnCount() const
wxImageList * GetStateImageList() const
wxTreeListMainWindow * m_main_win
wxTreeItemId GetSelection() const
wxString GetColumnText(int column) const
wxTreeItemId GetPrevExpanded(const wxTreeItemId &item) const
void OnScroll(wxScrollWinEvent &event)
void CollapseAndReset(const wxTreeItemId &item)
void OnKillFocus(wxFocusEvent &event)
wxTreeListItemCellAttrHash m_props_cell
wxImageList * m_imageListNormal
void SetHilight(bool set=true)
void ScrollTo(const wxTreeItemId &item)
size_t GetSelections(wxArrayTreeItemIds &) const
virtual bool SetFont(const wxFont &font)
wxFont GetItemFont(const wxTreeItemId &item) const
static void info(const char *fmt,...)
void SetImageList(wxImageList *imageList)
void ExpandAll(const wxTreeItemId &item)
wxImageList * m_imageListState
void SetItemHasChildren(const wxTreeItemId &item, bool has=true)
bool MatchItemText(const wxString &itemText, const wxString &pattern, int mode)
wxBrush * m_hilightUnfocusedBrush
void OnPaint(wxPaintEvent &event)
void SetDragItem(const wxTreeItemId &item=(wxTreeItemId *) NULL)
const int wxTL_MODE_NAV_VISIBLE
wxTreeItemId GetSelection() const
bool GetBoundingRect(const wxTreeItemId &item, wxRect &rect, bool textOnly=false) const
wxTreeItemId GetPrevVisible(const wxTreeItemId &item, bool fullRow=false, bool within=true) const
void Toggle(const wxTreeItemId &item)
void SetButtonsImageList(wxImageList *imageList)
wxTreeListMainWindow * GetMainWindow() const
wxTreeItemId GetNextChild(const wxTreeItemId &item, wxTreeItemIdValue &cookie) const
wxTreeItemId GetNextExpanded(const wxTreeItemId &item) const
void SetData(wxTreeItemData *data)
wxTreeItemData * GetData(int column) const
void OnCaptureLost(wxMouseCaptureLostEvent &WXUNUSED(event))
wxTreeItemId GetPrevVisible(const wxTreeItemId &item, bool fullRow, bool within) const
void OnMouse(wxMouseEvent &event)
virtual int OnCompareItems(const wxTreeItemId &item1, const wxTreeItemId &item2)
bool HasChildren(const wxTreeItemId &item) const
wxString GetItemText(const wxTreeItemId &item) const
wxImageList * GetStateImageList() const
void CalculateLevel(wxTreeListItem *item, wxDC &dc, int level, int &y, int x_maincol)
void SetIndent(unsigned int indent)
void CalculatePositions()
wxImageList * GetButtonsImageList() const
wxTreeListMainWindow * m_owner
wxTreeListItem * m_editItem
void DoDeleteItem(wxTreeListItem *item)
virtual bool SetBackgroundColour(const wxColour &colour)
wxEditTextCtrl * m_editControl
wxTreeListItem * m_curItem
unsigned int GetIndent() const
void SetButtonsImageList(wxImageList *imageList)
void DeleteChildren(const wxTreeItemId &item)
WX_DECLARE_HASH_MAP(int, wxTreeListItemCellAttr *, wxIntegerHash, wxIntegerEqual, wxTreeListItemCellAttrHash)
virtual bool SetFont(const wxFont &font)
wxTreeListHeaderWindow * GetHeaderWindow() const
bool IsExpanded(const wxTreeItemId &item) const
wxTreeItemId GetPrevChild(const wxTreeItemId &item, wxTreeItemIdValue &cookie) const
wxTreeItemAttr * GetAttributes(int column) const
wxTreeItemData * GetItemData(const wxTreeItemId &item) const
void SetItemText(const wxTreeItemId &item, const wxString &text)
void EditLabel(const wxTreeItemId &item)
wxImageList * GetImageList() const
void SetStateImageList(wxImageList *imageList)
wxTreeListHeaderWindow * m_header_win
void Delete(const wxTreeItemId &item)
const wxString * GetToolTip() const
bool IsBold(int column) const
int GetColumnWidth(int column) const
wxTreeListItem * m_toolTipItem
static const int FIND_TIMER_TICKS
void OnEraseBackground(wxEraseEvent &WXUNUSED(event))
int GetMainColumn() const
void SetToolTip(const wxString &tip)
void OnSetFocus(wxFocusEvent &event)