]> git.saurik.com Git - wxWidgets.git/commitdiff
More ownerdrawn stuff
authorDavid Webster <Dave.Webster@bhmi.com>
Thu, 22 Mar 2001 04:41:37 +0000 (04:41 +0000)
committerDavid Webster <Dave.Webster@bhmi.com>
Thu, 22 Mar 2001 04:41:37 +0000 (04:41 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@9570 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

src/os2/ownerdrw.cpp
src/os2/window.cpp

index 7b25a242a717bd8f77f9872d8a3a537c5cfe8257..a270099a340e4c69bf4ffad246fcca9b6aac1fb2 100644 (file)
@@ -106,95 +106,110 @@ bool wxOwnerDrawn::OnDrawItem(
 {
     //
     // We do nothing on focus change
+    //
     if (eAction == wxODFocusChanged )
         return TRUE;
+
     //
-    // WxWinGdi_CColour <-> RGB
+    // Select the font and draw the text
+    // ---------------------------------
     //
-    #define   ToRGB(col)  OS2RGB(col.Red(), col.Green(), col.Blue())
-    #define   UnRGB(col)  GetRValue(col), GetGValue(col), GetBValue(col)
 
-    CHARBUNDLE                      vCbndText;
-    CHARBUNDLE                      vCbndBack;
+    CHARBUNDLE                      vCbnd;
     HPS                             hPS= rDC.GetHPS();
-    ULONG                           lColBack;
-    ULONG                           lColText;
+    wxColour                        vColBack;
+    wxColour                        vColText;
+    COLORREF                        vRef;
+    char                            zMsg[128];
 
+    //
+    // Use default font if no font set
+    //
+    if (m_font.Ok())
+    {
+        m_font.RealizeResource();
+    }
+    else
+    {
+        ::GpiSetCharSet(hPS, LCID_DEFAULT);
+    }
     if (eStatus & wxODSelected)
     {
-        lColBack = (ULONG)::WinQuerySysColor( HWND_DESKTOP
-                                             ,SYSCLR_MENUHILITEBGND // Light gray
-                                             ,0L
-                                            );
-        lColText = (ULONG)::WinQuerySysColor( HWND_DESKTOP
-                                             ,SYSCLR_MENUTEXT // Black
-                                             ,0L
-                                            );
+        vRef = (ULONG)::WinQuerySysColor( HWND_DESKTOP
+                                         ,SYSCLR_MENUHILITEBGND // Light gray
+                                         ,0L
+                                        );
+        vColBack.Set( GetRValue(vRef)
+                     ,GetGValue(vRef)
+                     ,GetBValue(vRef)
+                    );
+        vColText = wxSystemSettings::GetSystemColour(wxSYS_COLOUR_MENUTEXT);
     }
     else if (eStatus & wxODDisabled)
     {
-        lColBack = (ULONG)::WinQuerySysColor( HWND_DESKTOP
-                                             ,SYSCLR_MENU // Light gray
-                                             ,0L
-                                            );
-        lColText = (ULONG)::WinQuerySysColor( HWND_DESKTOP
-                                             ,SYSCLR_MENUDISABLEDTEXT // dark gray
-                                             ,0L
-                                            );
+        vRef = (ULONG)::WinQuerySysColor( HWND_DESKTOP
+                                         ,SYSCLR_MENU // Light gray
+                                         ,0L
+                                        );
+        vColBack.Set( GetRValue(vRef)
+                     ,GetGValue(vRef)
+                     ,GetBValue(vRef)
+                    );
+        vRef = (ULONG)::WinQuerySysColor( HWND_DESKTOP
+                                         ,SYSCLR_MENUDISABLEDTEXT // dark gray
+                                         ,0L
+                                        );
+        vColText.Set( GetRValue(vRef)
+                     ,GetGValue(vRef)
+                     ,GetBValue(vRef)
+                    );
     }
     else
     {
         //
         // Fall back to default colors if none explicitly specified
         //
-        lColBack = m_colBack.Ok() ? ToRGB(m_colBack) : ::WinQuerySysColor( HWND_DESKTOP
-                                                                          ,SYSCLR_MENU  // we are using gray for all our window backgrounds in wxWindows
-                                                                          ,0L
-                                                                         );
-        lColText = m_colText.Ok() ? ToRGB(m_colText) : ::WinQuerySysColor( HWND_DESKTOP
-                                                                          ,SYSCLR_WINDOWTEXT // Black
-                                                                          ,0L
-                                                                         );
+        vRef = ::WinQuerySysColor( HWND_DESKTOP
+                                  ,SYSCLR_MENU  // we are using gray for all our window backgrounds in wxWindows
+                                  ,0L
+                                 );
+        vColBack.Set( GetRValue(vRef)
+                     ,GetGValue(vRef)
+                     ,GetBValue(vRef)
+                    );
+        vRef = ::WinQuerySysColor( HWND_DESKTOP
+                                  ,SYSCLR_WINDOWTEXT // Black
+                                  ,0L
+                                 );
+        vColText.Set( GetRValue(vRef)
+                     ,GetGValue(vRef)
+                     ,GetBValue(vRef)
+                    );
     }
-    vCbndText.lColor = (LONG)lColText;
-    vCbndBack.lColor = (LONG)lColBack;
+    vRef = vColBack.GetPixel();
+    vCbnd.lBackColor = (LONG)vRef;
+
+    vRef = vColText.GetPixel();
+    vCbnd.lColor = (LONG)vRef;
+
+        sprintf(zMsg, "Color: %ld", vRef);
+        wxMessageBox( "wxWindows Menu Sample"
+                     ,zMsg
+                     ,wxICON_INFORMATION
+                    );
 
     ::GpiSetAttrs( hPS
                   ,PRIM_CHAR
-                  ,CBB_BACK_COLOR
-                  ,0
-                  ,&vCbndBack
-                 );
-    ::GpiSetAttrs( hPS
-                  ,PRIM_CHAR
-                  ,CBB_COLOR
+                  ,CBB_COLOR | CBB_BACK_COLOR
                   ,0
-                  ,&vCbndText
+                  ,&vCbnd
                  );
 
-
     //
     // Determine where to draw and leave space for a check-mark.
     //
     int                             nX = rRect.x + GetMarginWidth();
 
-    //
-    // Select the font and draw the text
-    // ---------------------------------
-    //
-
-    //
-    // Use default font if no font set
-    //
-    if (m_font.Ok())
-    {
-        m_font.RealizeResource();
-    }
-    else
-    {
-        ::GpiSetCharSet(hPS, LCID_DEFAULT);
-    }
-
     //
     // Unfortunately, unlike Win32, PM has no owner drawn specific text
     // drawing methods like ::DrawState that can cleanly handle accel
@@ -206,7 +221,7 @@ bool wxOwnerDrawn::OnDrawItem(
     // Manually replace the tab with spaces
     //
     wxString                        sTgt = "\t";
-    wxString                        sReplace = " ";
+    wxString                        sReplace = "           ";
     size_t                          nIndex;
 
     nIndex = m_strName.Find(sTgt.c_str());
@@ -217,10 +232,15 @@ bool wxOwnerDrawn::OnDrawItem(
     if (nIndex != -1)
         m_strName.Replace(sTgt.c_str(), "", TRUE);
 
-    rDC.DrawText( m_strName
-                 ,nX
-                 ,rRect.y + 4
-                );
+    POINTL                          vPoint;
+
+    vPoint.x = nX;
+    vPoint.y = rRect.y + 4;
+    ::GpiCharStringAt( hPS
+                      ,&vPoint
+                      ,m_strName.length()
+                      ,(PCH)m_strName.c_str()
+                     );
 
 #if 0
     //
index d5489b0daff80bd624197d058bc39c7d5c261522..e3b48ba2e7577b38f97488fdc0c13148b0d5e533 100644 (file)
@@ -1984,7 +1984,6 @@ MRESULT wxWindow::OS2WindowProc(
         case WM_MEASUREITEM:
             {
                 int                 nIdCtrl = (UINT)wParam;
-                char                zMsg[128];
 
                 if ( uMsg == WM_DRAWITEM )
                 {