X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/b3a7510d21b9d4f9646b32edf9fe6f453f2c6dc9..236a9de39afa090fdee3cf91cb5364ceca69e3f8:/src/generic/treectrl.cpp diff --git a/src/generic/treectrl.cpp b/src/generic/treectrl.cpp index dc7160f294..9a43e04af0 100644 --- a/src/generic/treectrl.cpp +++ b/src/generic/treectrl.cpp @@ -235,13 +235,13 @@ private: static void EventFlagsToSelType(long style, bool shiftDown, bool ctrlDown, - bool *is_multiple, - bool *extended_select, - bool *unselect_others) + bool &is_multiple, + bool &extended_select, + bool &unselect_others) { - *is_multiple = (style & wxTR_MULTIPLE) != 0; - *extended_select = shiftDown && is_multiple; - *unselect_others = !(extended_select || (ctrlDown && is_multiple)); + is_multiple = (style & wxTR_MULTIPLE) != 0; + extended_select = shiftDown && is_multiple; + unselect_others = !(extended_select || (ctrlDown && is_multiple)); } // ----------------------------------------------------------------------------- @@ -1496,10 +1496,12 @@ void wxTreeCtrl::SetImageList(wxImageList *imageList) { m_imageListNormal = imageList; + if ( !m_imageListNormal ) + return; + // Calculate a m_lineHeight value from the image sizes. // May be toggle off. Then wxTreeCtrl will spread when // necessary (which might look ugly). -#if 1 wxClientDC dc(this); m_lineHeight = (int)(dc.GetCharHeight() + 4); int width = 0, height = 0, @@ -1515,7 +1517,6 @@ void wxTreeCtrl::SetImageList(wxImageList *imageList) m_lineHeight += 2; // at least 2 pixels else m_lineHeight += m_lineHeight/10; // otherwise 10% extra spacing -#endif } void wxTreeCtrl::SetStateImageList(wxImageList *imageList) @@ -1571,8 +1572,15 @@ void wxTreeCtrl::PaintItem(wxGenericTreeItem *item, wxDC& dc) int image = item->GetCurrentImage(); if ( image != NO_IMAGE ) { - m_imageListNormal->GetSize( image, image_w, image_h ); - image_w += 4; + if ( m_imageListNormal ) + { + m_imageListNormal->GetSize( image, image_w, image_h ); + image_w += 4; + } + else + { + image = NO_IMAGE; + } } int total_h = GetLineHeight(item); @@ -1826,8 +1834,18 @@ void wxTreeCtrl::OnChar( wxKeyEvent &event ) EventFlagsToSelType(GetWindowStyleFlag(), event.ShiftDown(), event.ControlDown(), - &is_multiple, &extended_select, &unselect_others); - + is_multiple, extended_select, unselect_others); + + // + : Expand + // - : Collaspe + // * : Toggle Expand/Collapse + // ' ' | return : activate + // up : go up (not last children!) + // down : go down + // left : go to parent + // right : open if parent and go next + // home : go to root + // end : go to last item without opening parents switch (event.KeyCode()) { case '+': @@ -2052,8 +2070,15 @@ void wxTreeCtrl::Edit( const wxTreeItemId& item ) int image = m_currentEdit->GetCurrentImage(); if ( image != NO_IMAGE ) { - m_imageListNormal->GetSize( image, image_w, image_h ); - image_w += 4; + if ( m_imageListNormal ) + { + m_imageListNormal->GetSize( image, image_w, image_h ); + image_w += 4; + } + else + { + wxFAIL_MSG(_T("you must create an image list to use images!")); + } } x += image_w; w -= image_w + 4; // I don't know why +4 is needed @@ -2237,7 +2262,7 @@ void wxTreeCtrl::OnMouse( wxMouseEvent &event ) EventFlagsToSelType(GetWindowStyleFlag(), event.ShiftDown(), event.ControlDown(), - &is_multiple, &extended_select, &unselect_others); + is_multiple, extended_select, unselect_others); if ( onButton ) { @@ -2277,8 +2302,8 @@ void wxTreeCtrl::OnIdle( wxIdleEvent &WXUNUSED(event) ) void wxTreeCtrl::CalculateSize( wxGenericTreeItem *item, wxDC &dc ) { - int text_w = 0; - int text_h = 0; + wxCoord text_w = 0; + wxCoord text_h = 0; if (item->IsBold()) dc.SetFont(m_boldFont); @@ -2294,8 +2319,11 @@ void wxTreeCtrl::CalculateSize( wxGenericTreeItem *item, wxDC &dc ) int image = item->GetCurrentImage(); if ( image != NO_IMAGE ) { - m_imageListNormal->GetSize( image, image_w, image_h ); - image_w += 4; + if ( m_imageListNormal ) + { + m_imageListNormal->GetSize( image, image_w, image_h ); + image_w += 4; + } } int total_h = (image_h > text_h) ? image_h : text_h;