]> git.saurik.com Git - wxWidgets.git/blobdiff - src/os2/checklst.cpp
fixing osx_carbon
[wxWidgets.git] / src / os2 / checklst.cpp
index 692eafb574dba1627251c35864dc0d5ec416fd29..6773983e9ff35bff453c7e92f7c0ba98d2b39b05 100644 (file)
 #ifndef WX_PRECOMP
     #include "wx/object.h"
     #include "wx/log.h"
+    #include "wx/window.h"
+    #include "wx/dcmemory.h"
+    #include "wx/dcscreen.h"
+    #include "wx/settings.h"
+    #include "wx/listbox.h"
+    #include "wx/bitmap.h"
+    #include "wx/colour.h"
+    #include "wx/font.h"
 #endif
 
-#include "wx/colour.h"
-#include "wx/font.h"
-#include "wx/bitmap.h"
-#include "wx/window.h"
-#include "wx/listbox.h"
+#include "wx/os2/dc.h"
 #include "wx/ownerdrw.h"
-#include "wx/settings.h"
-#include "wx/dcmemory.h"
-#include "wx/dcscreen.h"
 
 #define INCL_PM
 #include <os2.h>
 
+// ----------------------------------------------------------------------------
+// constants for base class
+// ----------------------------------------------------------------------------
+
+static const int CHECK_MARK_WIDTH = 15;
+
 // ----------------------------------------------------------------------------
 // private functions
 // ----------------------------------------------------------------------------
@@ -49,8 +56,6 @@
 // implementation
 // ============================================================================
 
-IMPLEMENT_DYNAMIC_CLASS(wxCheckListBox, wxListBox)
-
 // ----------------------------------------------------------------------------
 // declaration and implementation of wxCheckListBoxItem class
 // ----------------------------------------------------------------------------
@@ -80,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;
@@ -100,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
 
 
@@ -112,7 +119,9 @@ bool wxCheckListBoxItem::OnDrawItem ( wxDC& rDc,
 {
     wxRect vRect = rRect;
 
-    ::WinQueryWindowRect( m_pParent->GetHWND(), &rDc.m_vRclPaint );
+
+    wxPMDCImpl *impl = (wxPMDCImpl*) rDc.GetImpl();
+    ::WinQueryWindowRect( m_pParent->GetHWND(), &impl->m_vRclPaint );
     if (IsChecked())
         eStat = (wxOwnerDrawn::wxODStatus)(eStat | wxOwnerDrawn::wxODChecked);
 
@@ -125,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();
@@ -167,8 +176,8 @@ bool wxCheckListBoxItem::OnDrawItem ( wxDC& rDc,
             //
             HBITMAP hChkBmp = ::WinGetSysBitmap( HWND_DESKTOP, SBMP_MENUCHECK );
             POINTL  vPoint = {nX, nOldY + 3};
-
-            ::WinDrawBitmap( rDc.GetHPS(),
+            wxPMDCImpl *impl = (wxPMDCImpl*) rDc.GetImpl();
+            ::WinDrawBitmap( impl->GetHPS(),
                              hChkBmp,
                              NULL,
                              &vPoint,
@@ -284,25 +293,6 @@ void wxCheckListBox::Delete(unsigned int n)
     m_aItems.RemoveAt(n);
 } // end of wxCheckListBox::Delete
 
-void wxCheckListBox::DoInsertItems(const wxArrayString& items, unsigned int pos)
-{
-    // pos is validated in wxListBox
-    wxListBox::DoInsertItems( items, pos );
-    unsigned int n = items.GetCount();
-    for (unsigned int i = 0; i < n; i++)
-    {
-        wxOwnerDrawn* pNewItem = CreateItem((size_t)(pos + i));
-
-        pNewItem->SetName(items[i]);
-        m_aItems.Insert(pNewItem, (size_t)(pos + i));
-        ::WinSendMsg( (HWND)GetHWND(),
-                      LM_SETITEMHANDLE,
-                      (MPARAM)(i + pos),
-                      MPFROMP(pNewItem)
-                    );
-    }
-} // end of wxCheckListBox::InsertItems
-
 bool wxCheckListBox::SetFont ( const wxFont& rFont )
 {
     for (unsigned int i = 0; i < m_aItems.GetCount(); i++)
@@ -349,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;
@@ -390,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;