]> git.saurik.com Git - wxWidgets.git/blobdiff - src/generic/headerctrlg.cpp
Reflect changes in stc.cpp in stc.cpp.in from which it's generated.
[wxWidgets.git] / src / generic / headerctrlg.cpp
index 37d848fc184d9a4ddfef2ed873e1be3978494c02..6dcccfdce8a355d8dc87b98947bb199b3bc07a08 100644 (file)
@@ -3,7 +3,6 @@
 // Purpose:     generic wxHeaderCtrl implementation
 // Author:      Vadim Zeitlin
 // Created:     2008-12-03
 // Purpose:     generic wxHeaderCtrl implementation
 // Author:      Vadim Zeitlin
 // Created:     2008-12-03
-// RCS-ID:      $Id$
 // Copyright:   (c) 2008 Vadim Zeitlin <vadim@wxwidgets.org>
 // Licence:     wxWindows licence
 ///////////////////////////////////////////////////////////////////////////////
 // Copyright:   (c) 2008 Vadim Zeitlin <vadim@wxwidgets.org>
 // Licence:     wxWindows licence
 ///////////////////////////////////////////////////////////////////////////////
@@ -23,8 +22,7 @@
     #pragma hdrstop
 #endif
 
     #pragma hdrstop
 #endif
 
-#ifndef WX_PRECOMP
-#endif // WX_PRECOMP
+#if wxUSE_HEADERCTRL
 
 #include "wx/headerctrl.h"
 
 
 #include "wx/headerctrl.h"
 
@@ -40,8 +38,6 @@
 namespace
 {
 
 namespace
 {
 
-const unsigned NO_SORT = (unsigned)-1;
-
 const unsigned COL_NONE = (unsigned)-1;
 
 } // anonymous namespace
 const unsigned COL_NONE = (unsigned)-1;
 
 } // anonymous namespace
@@ -134,11 +130,14 @@ void wxHeaderCtrl::DoScrollHorz(int dx)
 
 wxSize wxHeaderCtrl::DoGetBestSize() const
 {
 
 wxSize wxHeaderCtrl::DoGetBestSize() const
 {
+    wxWindow *win = GetParent();
+    int height = wxRendererNative::Get().GetHeaderButtonHeight( win );
+
     // the vertical size is rather arbitrary but it looks better if we leave
     // some space around the text
     const wxSize size(IsEmpty() ? wxHeaderCtrlBase::DoGetBestSize().x
                                 : GetColEnd(GetColumnCount() - 1),
     // the vertical size is rather arbitrary but it looks better if we leave
     // some space around the text
     const wxSize size(IsEmpty() ? wxHeaderCtrlBase::DoGetBestSize().x
                                 : GetColEnd(GetColumnCount() - 1),
-                      (7*GetCharHeight())/4);
+                                height ); // (7*GetCharHeight())/4);
     CacheBestSize(size);
     return size;
 }
     CacheBestSize(size);
     return size;
 }
@@ -180,7 +179,7 @@ unsigned int wxHeaderCtrl::FindColumnAtPoint(int x, bool *onSeparator) const
 
         pos += col.GetWidth();
 
 
         pos += col.GetWidth();
 
-        // if the column is resizeable, check if we're approximatively over the
+        // if the column is resizable, check if we're approximatively over the
         // line separating it from the next column
         //
         // TODO: don't hardcode sensitivity
         // line separating it from the next column
         //
         // TODO: don't hardcode sensitivity
@@ -256,26 +255,14 @@ void wxHeaderCtrl::ClearMarkers()
     dcover.Clear();
 }
 
     dcover.Clear();
 }
 
-void wxHeaderCtrl::UpdateResizingMarker(int xPhysical)
-{
-    wxClientDC dc(this);
-
-    wxDCOverlay dcover(m_overlay, &dc);
-    dcover.Clear();
-
-    // unfortunately drawing the marker over the parent window doesn't work as
-    // it's usually covered by another window (the main control view) so just
-    // draw the marker over the header itself, even if it makes it not very
-    // useful
-    dc.SetPen(*wxLIGHT_GREY_PEN);
-    dc.DrawLine(xPhysical, 0, xPhysical, GetClientSize().y);
-}
-
 void wxHeaderCtrl::EndDragging()
 {
 void wxHeaderCtrl::EndDragging()
 {
-    ClearMarkers();
-
-    m_overlay.Reset();
+    // We currently only use markers for reordering, not for resizing
+    if (IsReordering())
+    {
+        ClearMarkers();
+        m_overlay.Reset();
+    }
 
     // don't use the special dragging cursor any more
     SetCursor(wxNullCursor);
 
     // don't use the special dragging cursor any more
     SetCursor(wxNullCursor);
@@ -290,7 +277,7 @@ void wxHeaderCtrl::CancelDragging()
 
     unsigned int& col = IsResizing() ? m_colBeingResized : m_colBeingReordered;
 
 
     unsigned int& col = IsResizing() ? m_colBeingResized : m_colBeingReordered;
 
-    wxHeaderCtrlEvent event(wxEVT_COMMAND_HEADER_DRAGGING_CANCELLED, GetId());
+    wxHeaderCtrlEvent event(wxEVT_HEADER_DRAGGING_CANCELLED, GetId());
     event.SetEventObject(this);
     event.SetColumn(col);
 
     event.SetEventObject(this);
     event.SetColumn(col);
 
@@ -315,8 +302,8 @@ int wxHeaderCtrl::ConstrainByMinWidth(unsigned int col, int& xPhysical)
 
 void wxHeaderCtrl::StartOrContinueResizing(unsigned int col, int xPhysical)
 {
 
 void wxHeaderCtrl::StartOrContinueResizing(unsigned int col, int xPhysical)
 {
-    wxHeaderCtrlEvent event(IsResizing() ? wxEVT_COMMAND_HEADER_RESIZING
-                                         : wxEVT_COMMAND_HEADER_BEGIN_RESIZE,
+    wxHeaderCtrlEvent event(IsResizing() ? wxEVT_HEADER_RESIZING
+                                         : wxEVT_HEADER_BEGIN_RESIZE,
                             GetId());
     event.SetEventObject(this);
     event.SetColumn(col);
                             GetId());
     event.SetEventObject(this);
     event.SetColumn(col);
@@ -342,7 +329,6 @@ void wxHeaderCtrl::StartOrContinueResizing(unsigned int col, int xPhysical)
         }
         //else: we had already done the above when we started
 
         }
         //else: we had already done the above when we started
 
-        UpdateResizingMarker(xPhysical);
     }
 }
 
     }
 }
 
@@ -354,7 +340,7 @@ void wxHeaderCtrl::EndResizing(int xPhysical)
 
     ReleaseMouse();
 
 
     ReleaseMouse();
 
-    wxHeaderCtrlEvent event(wxEVT_COMMAND_HEADER_END_RESIZE, GetId());
+    wxHeaderCtrlEvent event(wxEVT_HEADER_END_RESIZE, GetId());
     event.SetEventObject(this);
     event.SetColumn(m_colBeingResized);
     event.SetWidth(ConstrainByMinWidth(m_colBeingResized, xPhysical));
     event.SetEventObject(this);
     event.SetColumn(m_colBeingResized);
     event.SetWidth(ConstrainByMinWidth(m_colBeingResized, xPhysical));
@@ -395,7 +381,7 @@ void wxHeaderCtrl::UpdateReorderingMarker(int xPhysical)
 
 void wxHeaderCtrl::StartReordering(unsigned int col, int xPhysical)
 {
 
 void wxHeaderCtrl::StartReordering(unsigned int col, int xPhysical)
 {
-    wxHeaderCtrlEvent event(wxEVT_COMMAND_HEADER_BEGIN_REORDER, GetId());
+    wxHeaderCtrlEvent event(wxEVT_HEADER_BEGIN_REORDER, GetId());
     event.SetEventObject(this);
     event.SetColumn(col);
 
     event.SetEventObject(this);
     event.SetColumn(col);
 
@@ -434,7 +420,7 @@ bool wxHeaderCtrl::EndReordering(int xPhysical)
 
     if ( colNew != colOld )
     {
 
     if ( colNew != colOld )
     {
-        wxHeaderCtrlEvent event(wxEVT_COMMAND_HEADER_END_REORDER, GetId());
+        wxHeaderCtrlEvent event(wxEVT_HEADER_END_REORDER, GetId());
         event.SetEventObject(this);
         event.SetColumn(colOld);
 
         event.SetEventObject(this);
         event.SetColumn(colOld);
 
@@ -494,6 +480,11 @@ void wxHeaderCtrl::OnPaint(wxPaintEvent& WXUNUSED(event))
     int w, h;
     GetClientSize(&w, &h);
 
     int w, h;
     GetClientSize(&w, &h);
 
+#ifdef __WXGTK__
+//    int vw;
+//    GetVirtualSize(&vw, NULL);
+#endif
+
     wxAutoBufferedPaintDC dc(this);
 
     dc.SetBackground(GetBackgroundColour());
     wxAutoBufferedPaintDC dc(this);
 
     dc.SetBackground(GetBackgroundColour());
@@ -511,7 +502,7 @@ void wxHeaderCtrl::OnPaint(wxPaintEvent& WXUNUSED(event))
         if ( col.IsHidden() )
             continue;
 
         if ( col.IsHidden() )
             continue;
 
-        const int colWidth = col.GetWidth();
+        int colWidth = col.GetWidth();
 
         wxHeaderSortIconType sortArrow;
         if ( col.IsSortKey() )
 
         wxHeaderSortIconType sortArrow;
         if ( col.IsSortKey() )
@@ -535,11 +526,22 @@ void wxHeaderCtrl::OnPaint(wxPaintEvent& WXUNUSED(event))
             state = wxCONTROL_DISABLED;
         }
 
             state = wxCONTROL_DISABLED;
         }
 
+        if (i == 0)
+           state |= wxCONTROL_SPECIAL;
+
         wxHeaderButtonParams params;
         params.m_labelText = col.GetTitle();
         params.m_labelBitmap = col.GetBitmap();
         params.m_labelAlignment = col.GetAlignment();
 
         wxHeaderButtonParams params;
         params.m_labelText = col.GetTitle();
         params.m_labelBitmap = col.GetBitmap();
         params.m_labelAlignment = col.GetAlignment();
 
+#ifdef __WXGTK__
+        if (i == count-1)
+        {
+//            colWidth = wxMax( colWidth, vw - xpos );
+            state |= wxCONTROL_DIRTY;
+        }
+#endif
+
         wxRendererNative::Get().DrawHeaderButton
                                 (
                                     this,
         wxRendererNative::Get().DrawHeaderButton
                                 (
                                     this,
@@ -677,23 +679,23 @@ void wxHeaderCtrl::OnMouse(wxMouseEvent& mevent)
                 // treat left double clicks on separator specially
                 if ( onSeparator && dblclk )
                 {
                 // treat left double clicks on separator specially
                 if ( onSeparator && dblclk )
                 {
-                    evtType = wxEVT_COMMAND_HEADER_SEPARATOR_DCLICK;
+                    evtType = wxEVT_HEADER_SEPARATOR_DCLICK;
                 }
                 else // not double click on separator
                 {
                 }
                 else // not double click on separator
                 {
-                    evtType = click ? wxEVT_COMMAND_HEADER_CLICK
-                                    : wxEVT_COMMAND_HEADER_DCLICK;
+                    evtType = click ? wxEVT_HEADER_CLICK
+                                    : wxEVT_HEADER_DCLICK;
                 }
                 break;
 
             case wxMOUSE_BTN_RIGHT:
                 }
                 break;
 
             case wxMOUSE_BTN_RIGHT:
-                evtType = click ? wxEVT_COMMAND_HEADER_RIGHT_CLICK
-                                : wxEVT_COMMAND_HEADER_RIGHT_DCLICK;
+                evtType = click ? wxEVT_HEADER_RIGHT_CLICK
+                                : wxEVT_HEADER_RIGHT_DCLICK;
                 break;
 
             case wxMOUSE_BTN_MIDDLE:
                 break;
 
             case wxMOUSE_BTN_MIDDLE:
-                evtType = click ? wxEVT_COMMAND_HEADER_MIDDLE_CLICK
-                                : wxEVT_COMMAND_HEADER_MIDDLE_DCLICK;
+                evtType = click ? wxEVT_HEADER_MIDDLE_CLICK
+                                : wxEVT_HEADER_MIDDLE_DCLICK;
                 break;
 
             default:
                 break;
 
             default:
@@ -714,3 +716,5 @@ void wxHeaderCtrl::OnMouse(wxMouseEvent& mevent)
 }
 
 #endif // wxHAS_GENERIC_HEADERCTRL
 }
 
 #endif // wxHAS_GENERIC_HEADERCTRL
+
+#endif // wxUSE_HEADERCTRL