From 7172b423aa146ab9b06e01605887b8deae263f87 Mon Sep 17 00:00:00 2001 From: David Webster Date: Thu, 22 Mar 2001 04:41:37 +0000 Subject: [PATCH] More ownerdrawn stuff git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@9570 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/os2/ownerdrw.cpp | 148 ++++++++++++++++++++++++------------------- src/os2/window.cpp | 1 - 2 files changed, 84 insertions(+), 65 deletions(-) diff --git a/src/os2/ownerdrw.cpp b/src/os2/ownerdrw.cpp index 7b25a242a7..a270099a34 100644 --- a/src/os2/ownerdrw.cpp +++ b/src/os2/ownerdrw.cpp @@ -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 // diff --git a/src/os2/window.cpp b/src/os2/window.cpp index d5489b0daf..e3b48ba2e7 100644 --- a/src/os2/window.cpp +++ b/src/os2/window.cpp @@ -1984,7 +1984,6 @@ MRESULT wxWindow::OS2WindowProc( case WM_MEASUREITEM: { int nIdCtrl = (UINT)wParam; - char zMsg[128]; if ( uMsg == WM_DRAWITEM ) { -- 2.45.2