X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/ce43f9e11513c676775051e7cde150e1ef168092..9b49405777342458dc1666001865eef7309b6c30:/src/generic/treectlg.cpp?ds=inline diff --git a/src/generic/treectlg.cpp b/src/generic/treectlg.cpp index 2e18569c11..e63d023e05 100644 --- a/src/generic/treectlg.cpp +++ b/src/generic/treectlg.cpp @@ -86,7 +86,7 @@ public: private: wxGenericTreeCtrl *m_owner; - DECLARE_NO_COPY_CLASS(wxTreeRenameTimer) + wxDECLARE_NO_COPY_CLASS(wxTreeRenameTimer); }; // control used for in-place edit @@ -114,7 +114,7 @@ private: bool m_aboutToFinish; DECLARE_EVENT_TABLE() - DECLARE_NO_COPY_CLASS(wxTreeTextCtrl) + wxDECLARE_NO_COPY_CLASS(wxTreeTextCtrl); }; // timer used to clear wxGenericTreeCtrl::m_findPrefix if no key was pressed @@ -132,7 +132,7 @@ public: private: wxGenericTreeCtrl *m_owner; - DECLARE_NO_COPY_CLASS(wxTreeFindTimer) + wxDECLARE_NO_COPY_CLASS(wxTreeFindTimer); }; // a tree item @@ -355,7 +355,7 @@ private: unsigned int m_isBold :1; // render the label in bold font unsigned int m_ownsAttr :1; // delete attribute when done - DECLARE_NO_COPY_CLASS(wxGenericTreeItem) + wxDECLARE_NO_COPY_CLASS(wxGenericTreeItem); }; // ============================================================================= @@ -432,24 +432,24 @@ wxTreeTextCtrl::wxTreeTextCtrl(wxGenericTreeCtrl *owner, wxRect rect; m_owner->GetBoundingRect(m_itemEdited, rect, true); - // corrects possition and size for better apperance + // corrects position and size for better appearance #ifdef __WXMSW__ rect.x -= 5; rect.width += 10; -#elif __WXGTK__ +#elif defined(__WXGTK__) rect.x -= 5; rect.y -= 2; rect.width += 8; rect.height += 4; -#elif __WXMAC__ - wxSize bs = DoGetBestSize(); - // edit control height - if ( rect.height > bs.y - 8 ) - int diff = rect.height - ( bs.y - 8 ); +#elif defined(__WXMAC__) + int bestHeight = GetBestSize().y - 8; + if ( rect.height > bestHeight ) + { + int diff = rect.height - bestHeight; rect.height -= diff; rect.y += diff / 2; - } -#endif + } +#endif // platforms (void)Create(m_owner, wxID_ANY, m_startValue, rect.GetPosition(), rect.GetSize()); @@ -966,18 +966,14 @@ void wxGenericTreeCtrl::Init() m_findTimer = NULL; m_dropEffectAboveItem = false; - + m_dndEffect = NoEffect; m_dndEffectItem = NULL; m_lastOnSame = false; #if defined( __WXMAC__ ) -#if wxOSX_USE_ATSU_TEXT - m_normalFont.MacCreateFromThemeFont( kThemeViewsFont ) ; -#else - m_normalFont.MacCreateFromUIFont( kCTFontViewsFontType ) ; -#endif + m_normalFont.CreateSystemFont(wxOSX_SYSTEM_FONT_VIEWS); #else m_normalFont = wxSystemSettings::GetFont( wxSYS_DEFAULT_GUI_FONT ); #endif @@ -1004,8 +1000,16 @@ bool wxGenericTreeCtrl::Create(wxWindow *parent, if (major < 10) style |= wxTR_ROW_LINES; + + if (style & wxTR_HAS_BUTTONS) + style |= wxTR_NO_LINES; #endif // __WXMAC__ +#ifdef __WXGTK20__ + if (style & wxTR_HAS_BUTTONS) + style |= wxTR_NO_LINES; +#endif + if ( !wxControl::Create( parent, id, pos, size, style|wxHSCROLL|wxVSCROLL, validator, @@ -1775,6 +1779,16 @@ void wxGenericTreeCtrl::Delete(const wxTreeItemId& itemId) } wxGenericTreeItem *parent = item->GetParent(); + + // if the selected item will be deleted, select the parent ... + wxGenericTreeItem *to_be_selected = parent; + if (parent) + { + // .. unless there is a next sibling like wxMSW does it + int pos = parent->GetChildren().Index( item ); + if ((int)(parent->GetChildren().GetCount()) > pos+1) + to_be_selected = parent->GetChildren().Item( pos+1 ); + } // don't keep stale pointers around! if ( IsDescendantOf(item, m_key_current) ) @@ -1791,7 +1805,7 @@ void wxGenericTreeCtrl::Delete(const wxTreeItemId& itemId) // a different item, in idle time. if ( m_select_me && IsDescendantOf(item, m_select_me) ) { - m_select_me = parent; + m_select_me = to_be_selected; } if ( IsDescendantOf(item, m_current) ) @@ -1802,7 +1816,7 @@ void wxGenericTreeCtrl::Delete(const wxTreeItemId& itemId) // m_current = parent; m_current = NULL; - m_select_me = parent; + m_select_me = to_be_selected; } // remove the item from the tree @@ -2625,7 +2639,7 @@ void wxGenericTreeCtrl::PaintItem(wxGenericTreeItem *item, wxDC& dc) // restore normal font dc.SetFont( m_normalFont ); - + if (item == m_dndEffectItem) { dc.SetPen( *wxBLACK_PEN ); @@ -2905,7 +2919,7 @@ void wxGenericTreeCtrl::DrawBorder(const wxTreeItemId &item) m_dndEffect = NoEffect; m_dndEffectItem = NULL; } - + wxRect rect( i->GetX()-1, i->GetY()-1, i->GetWidth()+2, GetLineHeight(i)+2 ); CalcScrolledPosition( rect.x, rect.y, &rect.x, &rect.y ); RefreshRect( rect ); @@ -2930,7 +2944,7 @@ void wxGenericTreeCtrl::DrawLine(const wxTreeItemId &item, bool below) m_dndEffect = NoEffect; m_dndEffectItem = NULL; } - + wxRect rect( i->GetX()-1, i->GetY()-1, i->GetWidth()+2, GetLineHeight(i)+2 ); CalcScrolledPosition( rect.x, rect.y, &rect.x, &rect.y ); RefreshRect( rect ); @@ -3576,6 +3590,8 @@ void wxGenericTreeCtrl::OnMouse( wxMouseEvent &event ) #if defined(__WXMSW__) || defined(__WXMAC__) || defined(__WXGTK20__) Update(); #else + // TODO: remove this call or use wxEventLoopBase::GetActive()->YieldFor(wxEVT_CATEGORY_UI) + // instead (needs to be tested!) wxYieldIfNeeded(); #endif } @@ -3606,9 +3622,11 @@ void wxGenericTreeCtrl::OnMouse( wxMouseEvent &event ) SetCursor(m_oldCursor); -#if defined( __WXMSW__ ) || defined(__WXMAC__) +#if defined( __WXMSW__ ) || defined(__WXMAC__) || defined(__WXGTK20__) Update(); #else + // TODO: remove this call or use wxEventLoopBase::GetActive()->YieldFor(wxEVT_CATEGORY_UI) + // instead (needs to be tested!) wxYieldIfNeeded(); #endif }