]> git.saurik.com Git - wxWidgets.git/blobdiff - src/os2/checklst.cpp
speeding up rectangle drawing by using specific methods, needs 40% less time
[wxWidgets.git] / src / os2 / checklst.cpp
index f0a3ac723bc88e2b18527d57b4a673e2849e5885..6773983e9ff35bff453c7e92f7c0ba98d2b39b05 100644 (file)
 #define INCL_PM
 #include <os2.h>
 
+// ----------------------------------------------------------------------------
+// constants for base class
+// ----------------------------------------------------------------------------
+
+static const int CHECK_MARK_WIDTH = 15;
+
 // ----------------------------------------------------------------------------
 // private functions
 // ----------------------------------------------------------------------------
@@ -50,8 +56,6 @@
 // implementation
 // ============================================================================
 
-IMPLEMENT_DYNAMIC_CLASS(wxCheckListBox, wxListBox)
-
 // ----------------------------------------------------------------------------
 // declaration and implementation of wxCheckListBoxItem class
 // ----------------------------------------------------------------------------
@@ -81,6 +85,8 @@ public:
     void Check(bool bCheck);
     void Toggle(void) { Check(!IsChecked()); }
 
+    virtual wxString GetName() const { return m_pParent->GetString(m_nIndex); }
+
 private:
     bool            m_bChecked;
     wxCheckListBox* m_pParent;
@@ -101,7 +107,7 @@ wxCheckListBoxItem::wxCheckListBoxItem(wxCheckListBox* pParent, size_t nIndex)
     // done in OnMeasure while they are used only in OnDraw and we
     // know that there will always be OnMeasure before OnDraw
     //
-    SetMarginWidth(GetDefaultMarginWidth());
+    SetMarginWidth(CHECK_MARK_WIDTH);
 } // end of wxCheckListBoxItem::wxCheckListBoxItem
 
 
@@ -128,7 +134,7 @@ bool wxCheckListBoxItem::OnDrawItem ( wxDC& rDc,
     vRect.y -= 3;
     if (wxOwnerDrawn::OnDrawItem( rDc, vRect, eAct, eStat))
     {
-        size_t    nCheckWidth  = GetDefaultMarginWidth();
+        size_t    nCheckWidth  = CHECK_MARK_WIDTH;
         size_t    nCheckHeight = m_pParent->GetItemHeight();
         int       nParentHeight;
         int       nX = rRect.GetX();
@@ -333,7 +339,7 @@ long wxCheckListBox::OS2OnMeasure ( WXMEASUREITEMSTRUCT* pItem )
         //
         // Add place for the check mark
         //
-        pStruct->rclItem.xRight += wxOwnerDrawn::GetDefaultMarginWidth();
+        pStruct->rclItem.xRight += CHECK_MARK_WIDTH;
         return long(MRFROM2SHORT((USHORT)m_nItemHeight, (USHORT)(pStruct->rclItem.xRight - pStruct->rclItem.xLeft)));
     }
     return 0L;
@@ -374,7 +380,7 @@ void wxCheckListBox::OnLeftClick ( wxMouseEvent& rEvent )
     //
     // Clicking on the item selects it, clicking on the checkmark toggles
     //
-    if (rEvent.GetX() <= wxOwnerDrawn::GetDefaultMarginWidth())
+    if (rEvent.GetX() <= CHECK_MARK_WIDTH)
     {
         int                         nParentHeight;
         wxScreenDC                  vDc;