]> git.saurik.com Git - wxWidgets.git/commitdiff
applied patch that adds wxTR_FULL_ROW_HIGHLIGHT to wxTreeCtrl
authorVáclav Slavík <vslavik@fastmail.fm>
Mon, 17 Dec 2001 00:30:23 +0000 (00:30 +0000)
committerVáclav Slavík <vslavik@fastmail.fm>
Mon, 17 Dec 2001 00:30:23 +0000 (00:30 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@13046 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

docs/latex/wx/treectrl.tex
include/wx/treebase.h
src/generic/treectlg.cpp
src/msw/treectrl.cpp

index 1b057afcd4a6d8df95449f1607838b2e71f49651..3af18623f5987a73437f5cd6e1262668daa9dff7 100644 (file)
@@ -32,6 +32,10 @@ If both wxTR\_HAS\_BUTTONS and wxTR\_TWIST\_BUTTONS are given,
 twister buttons are generated.  Generic only.}
 \twocolitem{\windowstyle{wxTR\_NO\_LINES}}{Use this style
 to hide vertical level connectors.}
+\twocolitem{\windowstyle{wxTR\_FULL\_ROW\_HIGHLIGHT}}{Use this style to have the background
+colour and the selection highlight extend over the entire horizontal
+row of the tree control window. (This flag is ignored under Windows unless you 
+specified wxTR\_NO\_LINES as well.) }
 \twocolitem{\windowstyle{wxTR\_LINES\_AT\_ROOT}}{Use this style
 to show lines between root nodes.
 Only applicable if wxTR\_HIDE\_ROOT is set and wxTR\_NO\_LINES is not set.}
index fcc8c30811eecca66ea2eb6baad310410cf27b6b..7a78957235b1c69d0cc1a59a343405e6222abe9e 100644 (file)
@@ -114,22 +114,23 @@ enum wxTreeItemIcon
  * wxTreeCtrl flags
  */
 // TODO: maybe renumber these?
-#define wxTR_NO_BUTTONS      0x0000     // for convenience
-#define wxTR_HAS_BUTTONS     0x0001     // generates a +/- button
-#define wxTR_TWIST_BUTTONS   0x0002     // generates a twister button
-#define wxTR_NO_LINES        0x0004     // don't generate level connectors
-#define wxTR_LINES_AT_ROOT   0x0008     // connect top-level nodes
-#define wxTR_MAC_BUTTONS     wxTR_TWIST_BUTTONS  // backward compatibility
-#define wxTR_AQUA_BUTTONS    0x0010     // used internally
-
-#define wxTR_SINGLE          0x0000     // for convenience
-#define wxTR_MULTIPLE        0x0020     // can select multiple items
-#define wxTR_EXTENDED        0x0040     // TODO: allow extended selection
-
-#define wxTR_EDIT_LABELS     0x0200     // can edit item labels
-#define wxTR_ROW_LINES       0x0400     // put border around items
-#define wxTR_HIDE_ROOT       0x0800     // don't display root node
-#define wxTR_HAS_VARIABLE_ROW_HEIGHT 0x0080 // what it says
+#define wxTR_NO_BUTTONS              0x0000     // for convenience
+#define wxTR_HAS_BUTTONS             0x0001     // generates a +/- button
+#define wxTR_TWIST_BUTTONS           0x0002     // generates a twister button
+#define wxTR_NO_LINES                0x0004     // don't generate level connectors
+#define wxTR_LINES_AT_ROOT           0x0008     // connect top-level nodes
+#define wxTR_MAC_BUTTONS             wxTR_TWIST_BUTTONS // backward compatibility
+#define wxTR_AQUA_BUTTONS            0x0010     // used internally
+
+#define wxTR_SINGLE                  0x0000     // for convenience
+#define wxTR_MULTIPLE                0x0020     // can select multiple items
+#define wxTR_EXTENDED                0x0040     // TODO: allow extended selection
+#define wxTR_FULL_ROW_HIGHLIGHT      0x2000     // highlight full horizontal space
+
+#define wxTR_EDIT_LABELS             0x0200     // can edit item labels
+#define wxTR_ROW_LINES               0x0400     // put border around items
+#define wxTR_HIDE_ROOT               0x0800     // don't display root node
+#define wxTR_HAS_VARIABLE_ROW_HEIGHT 0x0080     // what it says
 
 // TODO: different default styles for wxGTK, wxMotif, whatever?
 #ifdef __WXMAC__
index 2a2e7c814ded8db12e7db1b974981a9dc583ca26..0b23a9cd099b7ba0603327ba41cef08f039f8b3b 100644 (file)
@@ -1883,18 +1883,29 @@ void wxGenericTreeCtrl::PaintItem(wxGenericTreeItem *item, wxDC& dc)
 
     int offset = HasFlag(wxTR_ROW_LINES) ? 1 : 0;
 
-    if ( item->IsSelected() && image != NO_IMAGE )
+    if ( HasFlag(wxTR_FULL_ROW_HIGHLIGHT) )
     {
-        // If it's selected, and there's an image, then we should
-        // take care to leave the area under the image painted in the
-        // background colour.
-        dc.DrawRectangle( item->GetX() + image_w - 2, item->GetY()+offset,
-                          item->GetWidth() - image_w + 2, total_h-offset );
+        int x, y, w, h;
+
+        DoGetPosition(&x, &y);
+        DoGetSize(&w, &h);
+        dc.DrawRectangle(x, item->GetY()+offset, w, total_h-offset);
     }
     else
     {
-        dc.DrawRectangle( item->GetX()-2, item->GetY()+offset,
-                          item->GetWidth()+2, total_h-offset );
+        if ( item->IsSelected() && image != NO_IMAGE )
+        {
+            // If it's selected, and there's an image, then we should
+            // take care to leave the area under the image painted in the
+            // background colour.
+            dc.DrawRectangle( item->GetX() + image_w - 2, item->GetY()+offset,
+                              item->GetWidth() - image_w + 2, total_h-offset );
+        }
+        else
+        {
+            dc.DrawRectangle( item->GetX()-2, item->GetY()+offset,
+                              item->GetWidth()+2, total_h-offset );
+        }
     }
 
     if ( image != NO_IMAGE )
@@ -1963,6 +1974,50 @@ void wxGenericTreeCtrl::PaintLevel( wxGenericTreeItem *item, wxDC &dc, int level
 
     if (IsExposed(exposed_x, exposed_y, 10000, h))  // 10000 = very much
     {
+        wxPen *pen =
+#ifndef __WXMAC__
+            // don't draw rect outline if we already have the
+            // background color under Mac
+            (item->IsSelected() && m_hasFocus) ? wxBLACK_PEN :
+#endif // !__WXMAC__
+            wxTRANSPARENT_PEN;
+
+        wxColour colText;
+        if ( item->IsSelected() )
+        {
+            colText = wxSystemSettings::GetSystemColour(wxSYS_COLOUR_HIGHLIGHTTEXT);
+        }
+        else
+        {
+            wxTreeItemAttr *attr = item->GetAttributes();
+            if (attr && attr->HasTextColour())
+                colText = attr->GetTextColour();
+            else
+                colText = wxSystemSettings::GetSystemColour(wxSYS_COLOUR_WINDOWTEXT);
+        }
+
+        // prepare to draw
+        dc.SetTextForeground(colText);
+        dc.SetPen(*pen);
+
+        // draw
+        PaintItem(item, dc);
+
+        if (HasFlag(wxTR_ROW_LINES))
+        {
+            // if the background colour is white, choose a
+            // contrasting color for the lines
+            dc.SetPen(*((GetBackgroundColour() == *wxWHITE)
+                         ? wxMEDIUM_GREY_PEN : wxWHITE_PEN));
+            dc.DrawLine(0, y_top, 10000, y_top);
+            dc.DrawLine(0, y, 10000, y);
+        }
+
+        // restore DC objects
+        dc.SetBrush(*wxWHITE_BRUSH);
+        dc.SetPen(m_dottedPen);
+        dc.SetTextForeground(*wxBLACK);
+
         if (item->HasPlus() && HasButtons())  // should the item show a button?
         {
             if (!HasFlag(wxTR_NO_LINES))
@@ -2069,50 +2124,6 @@ void wxGenericTreeCtrl::PaintLevel( wxGenericTreeItem *item, wxDC &dc, int level
                 x_start = 3;
             dc.DrawLine(x_start, y_mid, x + m_spacing, y_mid);
         }
-
-        wxPen *pen =
-#ifndef __WXMAC__
-            // don't draw rect outline if we already have the
-            // background color under Mac
-            (item->IsSelected() && m_hasFocus) ? wxBLACK_PEN :
-#endif // !__WXMAC__
-            wxTRANSPARENT_PEN;
-
-        wxColour colText;
-        if ( item->IsSelected() )
-        {
-            colText = wxSystemSettings::GetSystemColour(wxSYS_COLOUR_HIGHLIGHTTEXT);
-        }
-        else
-        {
-            wxTreeItemAttr *attr = item->GetAttributes();
-            if (attr && attr->HasTextColour())
-                colText = attr->GetTextColour();
-            else
-                colText = wxSystemSettings::GetSystemColour(wxSYS_COLOUR_WINDOWTEXT);
-        }
-
-        // prepare to draw
-        dc.SetTextForeground(colText);
-        dc.SetPen(*pen);
-
-        // draw
-        PaintItem(item, dc);
-
-        if (HasFlag(wxTR_ROW_LINES))
-        {
-            // if the background colour is white, choose a
-            // contrasting color for the lines
-            dc.SetPen(*((GetBackgroundColour() == *wxWHITE)
-                         ? wxMEDIUM_GREY_PEN : wxWHITE_PEN));
-            dc.DrawLine(0, y_top, 10000, y_top);
-            dc.DrawLine(0, y, 10000, y);
-        }
-
-        // restore DC objects
-        dc.SetBrush(*wxWHITE_BRUSH);
-        dc.SetPen(m_dottedPen);
-        dc.SetTextForeground(*wxBLACK);
     }
 
     if (item->IsExpanded())
index 69ff37efc2366f901da016a18737628d7aa90e94..a0713416ab5ac9ad518d8d530fe84f9afbabc35e 100644 (file)
@@ -47,6 +47,7 @@
 
 #if defined(__WIN95__)
 
+#include "wx/app.h"
 #include "wx/log.h"
 #include "wx/dynarray.h"
 #include "wx/imaglist.h"
@@ -546,6 +547,13 @@ bool wxTreeCtrl::Create(wxWindow *parent,
 
     if ( m_windowStyle & wxTR_LINES_AT_ROOT )
         wstyle |= TVS_LINESATROOT;
+    
+    if ( m_windowStyle & wxTR_FULL_ROW_HIGHLIGHT )
+    {    
+        if ( wxTheApp->GetComCtl32Version() >= 471 )
+            wstyle |= TVS_FULLROWSELECT;
+    }
+
 
     // using TVS_CHECKBOXES for emulation of a multiselection tree control
     // doesn't work without the new enough headers