]> git.saurik.com Git - wxWidgets.git/blobdiff - src/generic/treectrl.cpp
Changed to use current wxSocket flag names instead of old ones
[wxWidgets.git] / src / generic / treectrl.cpp
index 57475faf269fdc678d557f58365abd033dfce77d..09a31f1449a76f048cafb219a83afc01350be3ef 100644 (file)
@@ -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));
 }
 
 // -----------------------------------------------------------------------------
@@ -607,7 +607,8 @@ void wxTreeCtrl::Init()
 
     m_dragCount = 0;
     m_isDragging = FALSE;
-    m_dropTarget = (wxGenericTreeItem *)NULL;
+    m_dropTarget =
+    m_oldSelection = (wxGenericTreeItem *)NULL;
 
     m_renameTimer = new wxTreeRenameTimer( this );
 
@@ -1825,8 +1826,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 '+':
@@ -2143,6 +2154,22 @@ void wxTreeCtrl::OnMouse( wxMouseEvent &event )
             // we're going to drag this item
             m_isDragging = TRUE;
 
+            // remember the old cursor because we will change it while
+            // dragging
+            m_oldCursor = m_cursor;
+
+            // in a single selection control, hide the selection temporarily
+            if ( !(GetWindowStyleFlag() & wxTR_MULTIPLE) )
+            {
+                m_oldSelection = GetSelection().m_pItem;
+
+                if ( m_oldSelection )
+                {
+                    m_oldSelection->SetHilight(FALSE);
+                    RefreshLine(m_oldSelection);
+                }
+            }
+
             CaptureMouse();
         }
     }
@@ -2178,9 +2205,16 @@ void wxTreeCtrl::OnMouse( wxMouseEvent &event )
         m_isDragging = FALSE;
         m_dropTarget = (wxGenericTreeItem *)NULL;
 
+        if ( m_oldSelection )
+        {
+            m_oldSelection->SetHilight(TRUE);
+            RefreshLine(m_oldSelection);
+            m_oldSelection = (wxGenericTreeItem *)NULL;
+        }
+
         ReleaseMouse();
 
-        SetCursor(wxCURSOR_DEFAULT);
+        SetCursor(m_oldCursor);
 
         wxYield();
     }
@@ -2213,7 +2247,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 )
             {
@@ -2253,8 +2287,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);