X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/38400bb46b1477680ec08ed04f2bcafa8de5e3bf..fb8d7eb7a880f1f2e32d8830f9c5e12b2536e05f:/src/os2/checklst.cpp?ds=sidebyside diff --git a/src/os2/checklst.cpp b/src/os2/checklst.cpp index bda47bb7d1..cd093e16e5 100644 --- a/src/os2/checklst.cpp +++ b/src/os2/checklst.cpp @@ -39,6 +39,12 @@ #define INCL_PM #include +// ---------------------------------------------------------------------------- +// 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(); @@ -208,7 +214,7 @@ void wxCheckListBoxItem::Check( bool bCheck ) } - wxCommandEvent vEvent( wxEVT_COMMAND_CHECKLISTBOX_TOGGLED,m_pParent->GetId()); + wxCommandEvent vEvent( wxEVT_CHECKLISTBOX,m_pParent->GetId()); vEvent.SetInt(m_nIndex); vEvent.SetEventObject(m_pParent); @@ -287,29 +293,6 @@ void wxCheckListBox::Delete(unsigned int n) m_aItems.RemoveAt(n); } // end of wxCheckListBox::Delete -int wxCheckListBox::DoInsertItems(const wxArrayStringsAdapter& items, - unsigned int pos, - void **clientData, - wxClientDataType type) -{ - // pos is validated in wxListBox - int result = wxListBox::DoInsertItems( items, pos, clientData, type ); - 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) - ); - } - return result; -} // end of wxCheckListBox::DoInsertItems - bool wxCheckListBox::SetFont ( const wxFont& rFont ) { for (unsigned int i = 0; i < m_aItems.GetCount(); i++) @@ -356,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; @@ -397,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;