]> git.saurik.com Git - wxWidgets.git/blobdiff - src/msw/ownerdrw.cpp
wxITEM_FOO instead of wxItem_Foo, for the sake of consistency
[wxWidgets.git] / src / msw / ownerdrw.cpp
index 27c8d4f8601915850d50c1fb9aef8383411f6b93..fe811c55d6faaf2f6afcaca12bb058629e284f33 100644 (file)
@@ -23,7 +23,7 @@
 
 #ifndef WX_PRECOMP
   #include "wx/window.h"
-//  #include "wx/msw/private.h"
+  #include "wx/msw/private.h"
   #include "wx/font.h"
   #include "wx/bitmap.h"
   #include "wx/dcmemory.h"
@@ -94,13 +94,13 @@ bool wxOwnerDrawn::OnMeasureItem(size_t *pwidth, size_t *pheight)
   {
       // Is BMP height larger then text height?
       size_t adjustedHeight = m_bmpChecked.GetHeight() +
-                              wxSystemSettings::GetSystemMetric(wxSYS_EDGE_Y);
+                              wxSystemSettings::GetMetric(wxSYS_EDGE_Y);
       if (*pheight < adjustedHeight)
           *pheight = adjustedHeight;
 
       // Does BMP encroach on default check menu position?
       size_t adjustedWidth = m_bmpChecked.GetWidth() +
-                             (wxSystemSettings::GetSystemMetric(wxSYS_EDGE_X) * 2);
+                             (wxSystemSettings::GetMetric(wxSYS_EDGE_X) * 2);
       if (ms_nDefaultMarginWidth < adjustedWidth)
           *pwidth += adjustedWidth - ms_nDefaultMarginWidth;
 
@@ -127,14 +127,17 @@ bool wxOwnerDrawn::OnMeasureItem(size_t *pwidth, size_t *pheight)
 #endif
 
 // draw the item
-bool wxOwnerDrawn::OnDrawItem(wxDC& dc, const wxRect& rc, wxODAction act, wxODStatus st)
+bool wxOwnerDrawn::OnDrawItem(wxDC& dc,
+                              const wxRect& rc,
+                              wxODAction act,
+                              wxODStatus st)
 {
   // we do nothing on focus change
   if ( act == wxODFocusChanged )
     return TRUE;
 
   // wxColor <-> RGB
-  #define   ToRGB(col)  RGB(col.Red(), col.Green(), col.Blue())
+  #define   ToRGB(col)  PALETTERGB(col.Red(), col.Green(), col.Blue())
   #define   UnRGB(col)  GetRValue(col), GetGValue(col), GetBValue(col)
 
   // set the colors
@@ -187,10 +190,23 @@ bool wxOwnerDrawn::OnDrawItem(wxDC& dc, const wxRect& rc, wxODAction act, wxODSt
     }
 
     HFONT hPrevFont = (HFONT) ::SelectObject(hdc, hfont);
-    DrawState(hdc, NULL, NULL,
-              (LPARAM)(const wxChar *)m_strName, m_strName.Length(),
+   
+       DrawState(hdc, NULL, NULL,
+              (LPARAM)m_strName.c_str(), m_strName.length(),
               x, rc.y, rc.GetWidth(), rc.GetHeight(),
-              DST_PREFIXTEXT | ( st & wxODDisabled ? DSS_DISABLED : 0) );
+              DST_PREFIXTEXT | (st & wxODDisabled ? DSS_DISABLED : 0));
+
+    if ( !m_strAccel.empty() )
+    {
+        RECT r;
+        r.top = rc.GetTop();
+        r.left = rc.GetLeft();
+        r.right = rc.GetRight() - GetMarginWidth();
+        r.bottom = rc.GetBottom();
+
+        DrawText(hdc, m_strAccel, m_strAccel.length(), &r,
+                 DT_SINGLELINE | DT_RIGHT | DT_VCENTER);
+    }
 
     (void)SelectObject(hdc, hPrevBrush);
     (void)SelectObject(hdc, hPrevFont);