]> git.saurik.com Git - wxWidgets.git/blobdiff - src/generic/treectlg.cpp
MinGW, Watcom and Borland warning fixes.
[wxWidgets.git] / src / generic / treectlg.cpp
index 5d23d010161fa521bb97848135966219d22bda7f..5f9fd71482aaa6cf8bd44d19380808588c8a4c93 100644 (file)
@@ -2255,7 +2255,7 @@ void wxGenericTreeCtrl::PaintItem(wxGenericTreeItem *item, wxDC& dc)
     }
 
     int total_h = GetLineHeight(item);
-    bool hasCustomBackground = false;
+    bool drawItemBackground = false;
 
     if ( item->IsSelected() )
     {
@@ -2273,13 +2273,14 @@ void wxGenericTreeCtrl::PaintItem(wxGenericTreeItem *item, wxDC& dc)
 #else
         dc.SetBrush(*(m_hasFocus ? m_hilightBrush : m_hilightUnfocusedBrush));
 #endif
+        drawItemBackground = true;
     }
     else
     {
         wxColour colBg;
         if ( attr && attr->HasBackgroundColour() )
        {
-           hasCustomBackground = true;
+           drawItemBackground = true;
             colBg = attr->GetBackgroundColour();
        }
         else
@@ -2310,7 +2311,7 @@ void wxGenericTreeCtrl::PaintItem(wxGenericTreeItem *item, wxDC& dc)
         // On GTK+ 2, drawing a 'normal' background is wrong for themes that
         // don't allow backgrounds to be customized. Not drawing the background,
         // except for custom item backgrounds, works for both kinds of theme.
-        else if (hasCustomBackground)
+        else if (drawItemBackground)
         {
             dc.DrawRectangle( item->GetX()-2, item->GetY()+offset,
                               item->GetWidth()+2, total_h-offset );
@@ -2692,8 +2693,15 @@ void wxGenericTreeCtrl::OnChar( wxKeyEvent &event )
 
         case WXK_MENU:
             {
+                // Use the item's bounding rectangle to determine position for the event
+                wxRect ItemRect;
+                GetBoundingRect(m_current, ItemRect, true);
+
                 wxTreeEvent event( wxEVT_COMMAND_TREE_ITEM_MENU, GetId() );
                 event.m_item = m_current;
+                // Use the left edge, vertical middle
+                event.m_pointDrag = wxPoint(ItemRect.GetX(),
+                                            ItemRect.GetY() + ItemRect.GetHeight() / 2);
                 event.SetEventObject( this );
                 GetEventHandler()->ProcessEvent( event );
                 break;
@@ -3225,6 +3233,14 @@ void wxGenericTreeCtrl::OnMouse( wxMouseEvent &event )
             nevent.m_pointDrag = CalcScrolledPosition(pt);
             nevent.SetEventObject(this);
             event.Skip(!GetEventHandler()->ProcessEvent(nevent));
+
+            // Consistent with MSW (for now), send the ITEM_MENU *after*
+            // the RIGHT_CLICK event. TODO: This behavior may change.
+            wxTreeEvent nevent2(wxEVT_COMMAND_TREE_ITEM_MENU, GetId());
+            nevent2.m_item = item;
+            nevent2.m_pointDrag = CalcScrolledPosition(pt);
+            nevent2.SetEventObject(this);
+            GetEventHandler()->ProcessEvent(nevent2);
         }
         else if ( event.LeftUp() )
         {