]> git.saurik.com Git - wxWidgets.git/blobdiff - src/os2/ownerdrw.cpp
fix for wxComboBox flicker on create (patch 598891)
[wxWidgets.git] / src / os2 / ownerdrw.cpp
index 46a4560cf4918ebb6d01383e111e4d042ece6e8a..9e9dd6568ded9ffd6356b58ed6f7e8dd715f9ad2 100644 (file)
@@ -111,6 +111,8 @@ bool wxOwnerDrawn::OnDrawItem(
     COLORREF                        vRef;
     RECTL                           vRect = {rRect.x + 4, rRect.y + 1, rRect.x + (rRect.width - 2), rRect.y + rRect.height};
 
+    memset(&vCbnd, 0, sizeof(CHARBUNDLE));
+
     //
     // Use default font if no font set
     //
@@ -176,9 +178,21 @@ bool wxOwnerDrawn::OnDrawItem(
                      ,GetBValue(vRef)
                     );
     }
+
     rDC.SetTextBackground(vColBack);
     rDC.SetTextForeground(vColText);
     rDC.SetBackgroundMode(wxTRANSPARENT);
+    vCbnd.lColor     = vColText.GetPixel();
+    vCbnd.lBackColor = vColBack.GetPixel();
+    ::GpiSetAttrs( hPS
+                  ,PRIM_CHAR
+                  ,CBB_BACK_COLOR | CBB_COLOR
+                  ,0
+                  ,&vCbnd
+                 );
+    ::GpiSetBackMix( hPS
+                    ,BM_LEAVEALONE
+                   );
 
     //
     // Paint the background
@@ -248,19 +262,23 @@ bool wxOwnerDrawn::OnDrawItem(
 
     //
     // Draw the main item text sans the accel text
-    rDC.DrawText( sFullString
-                 ,nX
-                 ,rRect.y + 4
-                );
+    //
+    POINTL                      vPntStart = {nX, rRect.y + 4};
+    ::GpiCharStringAt( rDC.GetHPS()
+                      ,&vPntStart
+                      ,sFullString.length()
+                      ,(PCH)sFullString.c_str()
+                     );
     if (bFoundMneumonic)
     {
         //
         // Underline the mneumonic -- still won't work, but at least it "looks" right
         //
         wxPen                       vPen;
-        POINTL                      vPntStart = {nX + nWidth - 1, rRect.y + 2}; // Make it look pretty!
         POINTL                      vPntEnd = {nX + nWidth + nCharWidth - 3, rRect.y + 2}; //CharWidth is bit wide
 
+        vPntStart.x = nX + nWidth - 1;
+        vPntStart.y = rRect.y + 2; // Make it look pretty!
         vPen = wxPen(vColText, 1, wxSOLID); // Assuming we are always black
         rDC.SetPen(vPen);
         ::GpiMove(hPS, &vPntStart);
@@ -282,10 +300,13 @@ bool wxOwnerDrawn::OnDrawItem(
         //
         // Back off the starting position from the right edge
         //
-        rDC.DrawText( sAccel
-                     ,rRect.width - (nWidth + 7) // this seems to mimic the default OS/2 positioning
-                     ,rRect.y + 4
-                    );
+        vPntStart.x = rRect.width - (nWidth + 7);
+        vPntStart.y = rRect.y + 4;
+        ::GpiCharStringAt( rDC.GetHPS()
+                          ,&vPntStart
+                          ,sAccel.length()
+                          ,(PCH)sAccel.c_str()
+                         );
     }
 
     //
@@ -323,8 +344,14 @@ bool wxOwnerDrawn::OnDrawItem(
 
         if (vBmp.Ok())
         {
+
             wxMemoryDC              vDCMem(&rDC);
+            wxMemoryDC*             pOldDC = (wxMemoryDC*)vBmp.GetSelectedInto();
 
+            if(pOldDC != NULL)
+            {
+                vBmp.SetSelectedInto(NULL);
+            }
             vDCMem.SelectObject(vBmp);
 
             //
@@ -338,11 +365,10 @@ bool wxOwnerDrawn::OnDrawItem(
             //
             wxASSERT((nBmpWidth <= rRect.width) && (nBmpHeight <= rRect.height));
 
-            //
-            //MT: blit with mask enabled.
-            //
+            int                     nHeightDiff = m_nHeight - nBmpHeight;
+
             rDC.Blit( rRect.x + (GetMarginWidth() - nBmpWidth) / 2
-                     ,rRect.y + (m_nHeight - nBmpHeight) /2
+                     ,rRect.y + nHeightDiff / 2
                      ,nBmpWidth
                      ,nBmpHeight
                      ,&vDCMem
@@ -356,11 +382,12 @@ bool wxOwnerDrawn::OnDrawItem(
             {
                 RECT                vRectBmp = { rRect.x
                                                 ,rRect.y
-                                                ,rRect.x + GetMarginWidth()
-                                                ,rRect.y + m_nHeight
+                                                ,rRect.x + GetMarginWidth() - 1
+                                                ,rRect.y + m_nHeight - 1
                                                };
-                POINTL              vPnt1 = {2, 4}; // Leave a little background border
+                POINTL              vPnt1 = {rRect.x + 1, rRect.y + 3}; // Leave a little background border
                 POINTL              vPnt2 = {rRect.x + GetMarginWidth(), rRect.y + m_nHeight - 3};
+
                 LINEBUNDLE          vLine;
 
                 vLine.lColor = vColBack.GetPixel();
@@ -378,6 +405,7 @@ bool wxOwnerDrawn::OnDrawItem(
                          ,0L
                         );
             }
+            vBmp.SetSelectedInto(NULL);
         }
     }
     return TRUE;