]> git.saurik.com Git - wxWidgets.git/blobdiff - src/msw/headerctrl.cpp
Define wxUSE_CAIRO in wx/chkconf.h to ensure that it's always defined.
[wxWidgets.git] / src / msw / headerctrl.cpp
index 15a690a729113e04b336ec8a9d8013b139f309df..9144513d5b7d4d695c1353d448d0ba43370a1d95 100644 (file)
 #include "wx/msw/wrapcctl.h"
 #include "wx/msw/private.h"
 
+#ifndef HDM_SETBITMAPMARGIN
+    #define HDM_SETBITMAPMARGIN 0x1234
+#endif
+
+#ifndef Header_SetBitmapMargin
+    #define Header_SetBitmapMargin(hwnd, margin) \
+            ::SendMessage((hwnd), HDM_SETBITMAPMARGIN, (WPARAM)(margin), 0)
+#endif
+
 // from src/msw/listctrl.cpp
 extern int WXDLLIMPEXP_CORE wxMSWGetColumnClicked(NMHDR *nmhdr, POINT *ptClick);
 
@@ -71,7 +80,7 @@ bool wxHeaderCtrl::Create(wxWindow *parent,
     if ( !CreateControl(parent, id, pos, size, style, wxDefaultValidator, name) )
         return false;
 
-    if ( !MSWCreateControl(WC_HEADER, _T(""), pos, size) )
+    if ( !MSWCreateControl(WC_HEADER, wxT(""), pos, size) )
         return false;
 
     // special hack for margins when using comctl32.dll v6 or later: the
@@ -97,7 +106,9 @@ WXDWORD wxHeaderCtrl::MSWGetStyle(long style, WXDWORD *exstyle) const
     // the control looks nicer with these styles and there doesn't seem to be
     // any reason to not use them so we always do (as for HDS_HORZ it is 0
     // anyhow but include it for clarity)
-    msStyle |= HDS_HORZ | HDS_BUTTONS | HDS_FLAT | HDS_FULLDRAG | HDS_HOTTRACK;
+    // NOTE: don't use however HDS_FLAT because it makes the control look
+    //       non-native when running WinXP in classic mode
+    msStyle |= HDS_HORZ | HDS_BUTTONS | HDS_FULLDRAG | HDS_HOTTRACK;
 
     return msStyle;
 }
@@ -145,7 +156,7 @@ wxSize wxHeaderCtrl::DoGetBestSize() const
     HDLAYOUT layout = { &rc, &wpos };
     if ( !Header_Layout(GetHwnd(), &layout) )
     {
-        wxLogLastError(_T("Header_Layout"));
+        wxLogLastError(wxT("Header_Layout"));
         return wxControl::DoGetBestSize();
     }
 
@@ -185,7 +196,7 @@ void wxHeaderCtrl::DoSetCount(unsigned int count)
     {
         if ( !Header_DeleteItem(GetHwnd(), 0) )
         {
-            wxLogLastError(_T("Header_DeleteItem"));
+            wxLogLastError(wxT("Header_DeleteItem"));
         }
     }
 
@@ -274,6 +285,7 @@ void wxHeaderCtrl::DoInsertItem(const wxHeaderColumn& col, unsigned int idx)
             if ( !m_imageList )
             {
                 m_imageList = new wxImageList(bmpWidth, bmpHeight);
+                (void) // suppress mingw32 warning about unused computed value
                 Header_SetImageList(GetHwnd(), GetHimagelistOf(m_imageList));
             }
             else // already have an image list
@@ -337,7 +349,7 @@ void wxHeaderCtrl::DoInsertItem(const wxHeaderColumn& col, unsigned int idx)
     if ( ::SendMessage(GetHwnd(), HDM_INSERTITEM,
                        MSWToNativeIdx(idx), (LPARAM)&hdi) == -1 )
     {
-        wxLogLastError(_T("Header_InsertItem()"));
+        wxLogLastError(wxT("Header_InsertItem()"));
     }
 }
 
@@ -355,7 +367,7 @@ void wxHeaderCtrl::DoSetColumnsOrder(const wxArrayInt& order)
 
     if ( !Header_SetOrderArray(GetHwnd(), orderShown.size(), &orderShown[0]) )
     {
-        wxLogLastError(_T("Header_GetOrderArray"));
+        wxLogLastError(wxT("Header_GetOrderArray"));
     }
 
     m_colIndices = order;
@@ -526,7 +538,12 @@ bool wxHeaderCtrl::MSWOnNotify(int idCtrl, WXLPARAM lParam, WXLPARAM *result)
                 if ( idx != wxNOT_FOUND )
                 {
                     idx = MSWFromNativeIdx(idx);
-                    evtType = GetClickEventType(code == NM_RDBLCLK, 1);
+
+                    // due to a bug in mingw32 headers NM_RDBLCLK is signed
+                    // there so we need a cast to avoid warnings about signed/
+                    // unsigned comparison
+                    evtType = GetClickEventType(
+                                code == static_cast<UINT>(NM_RDBLCLK), 1);
                 }
                 //else: ignore clicks outside any column
             }
@@ -640,22 +657,24 @@ bool wxHeaderCtrl::MSWOnNotify(int idCtrl, WXLPARAM lParam, WXLPARAM *result)
         if ( order != -1 )
             event.SetNewOrder(order);
 
-        if ( GetEventHandler()->ProcessEvent(event) )
-        {
-            if ( event.IsAllowed() )
-                return true;    // skip default message handling below
+        const bool processed = GetEventHandler()->ProcessEvent(event);
 
-            // we need to veto the default handling of this message, don't
-            // return to execute the code in the "if veto" branch below
+        if ( processed && !event.IsAllowed() )
             veto = true;
-        }
-        else // not processed
+
+        if ( !veto )
         {
             // special post-processing for HDN_ENDDRAG: we need to update the
             // internal column indices array if this is allowed to go ahead as
             // the native control is going to reorder its columns now
             if ( evtType == wxEVT_COMMAND_HEADER_END_REORDER )
                 MoveColumnInOrderArray(m_colIndices, idx, order);
+
+            if ( processed )
+            {
+                // skip default processing below
+                return true;
+            }
         }
     }