X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/2bda0e173844e8e0f8acf4e8ad8b5c26e5c6fe5d..16553659df1a8fee8b19cc9a8ff8321711fe983c:/src/msw/checklst.cpp diff --git a/src/msw/checklst.cpp b/src/msw/checklst.cpp index a04d7689aa..05b5b86c06 100644 --- a/src/msw/checklst.cpp +++ b/src/msw/checklst.cpp @@ -2,17 +2,13 @@ // Name: msw/checklst.cpp // Purpose: implementation of wxCheckListBox class // Author: Vadim Zeitlin -// Modified by: +// Modified by: // Created: 16.11.97 // RCS-ID: $Id$ // Copyright: (c) 1998 Vadim Zeitlin // Licence: wxWindows license /////////////////////////////////////////////////////////////////////////////// -// ============================================================================ -// headers & declarations -// ============================================================================ - #ifdef __GNUG__ #pragma implementation "checklst.h" #endif @@ -24,6 +20,8 @@ #pragma hdrstop #endif +#if wxUSE_OWNER_DRAWN + #include #include "wx/ownerdrw.h" @@ -45,7 +43,7 @@ class wxCheckListBoxItem : public wxOwnerDrawn { public: // ctor - wxCheckListBoxItem(wxCheckListBox *pParent, uint nIndex); + wxCheckListBoxItem(wxCheckListBox *pParent, size_t nIndex); // drawing functions virtual bool OnDrawItem(wxDC& dc, const wxRect& rc, wxODAction act, wxODStatus stat); @@ -58,10 +56,10 @@ public: private: bool m_bChecked; wxCheckListBox *m_pParent; - uint m_nIndex; + size_t m_nIndex; }; -wxCheckListBoxItem::wxCheckListBoxItem(wxCheckListBox *pParent, uint nIndex) +wxCheckListBoxItem::wxCheckListBoxItem(wxCheckListBox *pParent, size_t nIndex) : wxOwnerDrawn("", TRUE) // checkable { m_bChecked = FALSE; @@ -85,7 +83,7 @@ wxCheckListBoxItem::wxCheckListBoxItem(wxCheckListBox *pParent, uint nIndex) * check until you click to the right of it, which is OK for WIN32. */ -bool wxCheckListBoxItem::OnDrawItem(wxDC& dc, const wxRect& rc, +bool wxCheckListBoxItem::OnDrawItem(wxDC& dc, const wxRect& rc, wxODAction act, wxODStatus stat) { if ( IsChecked() ) @@ -93,10 +91,10 @@ bool wxCheckListBoxItem::OnDrawItem(wxDC& dc, const wxRect& rc, if ( wxOwnerDrawn::OnDrawItem(dc, rc, act, stat) ) { // ## using native API for performance and precision - uint nCheckWidth = GetDefaultMarginWidth(), + size_t nCheckWidth = GetDefaultMarginWidth(), nCheckHeight = m_pParent->GetItemHeight(); - - int x = rc.GetX(), + + int x = rc.GetX(), y = rc.GetY(); HDC hdc = (HDC)dc.GetHDC(); @@ -104,7 +102,7 @@ bool wxCheckListBoxItem::OnDrawItem(wxDC& dc, const wxRect& rc, // create pens HPEN hpenBack = CreatePen(PS_SOLID, 0, GetSysColor(COLOR_WINDOW)), hpenGray = CreatePen(PS_SOLID, 0, RGB(128, 128, 128)), - hpenPrev = SelectObject(hdc, hpenBack); + hpenPrev = (HPEN)SelectObject(hdc, hpenBack); // we erase the 1-pixel border Rectangle(hdc, x, y, x + nCheckWidth, y + nCheckHeight); @@ -116,7 +114,7 @@ bool wxCheckListBoxItem::OnDrawItem(wxDC& dc, const wxRect& rc, // first create a monochrome bitmap in a memory DC HDC hdcMem = CreateCompatibleDC(hdc); HBITMAP hbmpCheck = CreateBitmap(nCheckWidth, nCheckHeight, 1, 1, 0); - HBITMAP hbmpOld = SelectObject(hdcMem, hbmpCheck); + HBITMAP hbmpOld = (HBITMAP)SelectObject(hdcMem, hbmpCheck); // then draw a check mark into it RECT rect = { 0, 0, nCheckWidth, nCheckHeight }; @@ -141,7 +139,7 @@ bool wxCheckListBoxItem::OnDrawItem(wxDC& dc, const wxRect& rc, #endif // finally copy it to screen DC and clean up - BitBlt(hdc, x, y, nCheckWidth - 1, nCheckHeight, + BitBlt(hdc, x, y, nCheckWidth - 1, nCheckHeight, hdcMem, 0, 0, SRCCOPY); SelectObject(hdcMem, hbmpOld); @@ -156,7 +154,7 @@ bool wxCheckListBoxItem::OnDrawItem(wxDC& dc, const wxRect& rc, // draw hollow gray rectangle (void)SelectObject(hdc, hpenGray); - HBRUSH hbrPrev = SelectObject(hdc, GetStockObject(NULL_BRUSH)); + HBRUSH hbrPrev = (HBRUSH)SelectObject(hdc, GetStockObject(NULL_BRUSH)); Rectangle(hdc, x, y, x + nCheckWidth, y + nCheckHeight); // clean up @@ -183,11 +181,11 @@ bool wxCheckListBoxItem::OnDrawItem(wxDC& dc, const wxRect& rc, // change the state of the item and redraw it void wxCheckListBoxItem::Toggle() -{ +{ m_bChecked = !m_bChecked; - uint nHeight = m_pParent->GetItemHeight(); - uint y = m_nIndex * nHeight; + size_t nHeight = m_pParent->GetItemHeight(); + size_t y = m_nIndex * nHeight; RECT rcUpdate = { 0, y, GetDefaultMarginWidth(), y + nHeight}; InvalidateRect((HWND)m_pParent->GetHWND(), &rcUpdate, FALSE); @@ -217,10 +215,10 @@ wxCheckListBox::wxCheckListBox() : wxListBox() } // ctor which creates the associated control -wxCheckListBox::wxCheckListBox(wxWindow *parent, const wxWindowID id, +wxCheckListBox::wxCheckListBox(wxWindow *parent, wxWindowID id, const wxPoint& pos, const wxSize& size, - const int nStrings, const wxString choices[], - const long style, const wxValidator& val, + int nStrings, const wxString choices[], + long style, const wxValidator& val, const wxString& name) // , const wxFont& font) // don't use ctor with arguments! we must call Create() // ourselves from here. @@ -234,7 +232,7 @@ wxCheckListBox::wxCheckListBox(wxWindow *parent, const wxWindowID id, // -------------------- // create a check list box item -wxOwnerDrawn *wxCheckListBox::CreateItem(uint nIndex) +wxOwnerDrawn *wxCheckListBox::CreateItem(size_t nIndex) { wxCheckListBoxItem *pItem = new wxCheckListBoxItem(this, nIndex); if ( m_windowFont.Ok() ) @@ -268,12 +266,12 @@ bool wxCheckListBox::MSWOnMeasure(WXMEASUREITEMSTRUCT *item) // check items // ----------- -bool wxCheckListBox::IsChecked(uint uiIndex) const +bool wxCheckListBox::IsChecked(size_t uiIndex) const { return GetItem(uiIndex)->IsChecked(); } -void wxCheckListBox::Check(uint uiIndex, bool bCheck) +void wxCheckListBox::Check(size_t uiIndex, bool bCheck) { GetItem(uiIndex)->Check(bCheck); } @@ -292,10 +290,10 @@ void wxCheckListBox::OnChar(wxKeyEvent& event) void wxCheckListBox::OnLeftClick(wxMouseEvent& event) { // clicking on the item selects it, clicking on the checkmark toggles - if ( (uint)event.GetX() <= wxOwnerDrawn::GetDefaultMarginWidth() ) { + if ( event.GetX() <= wxOwnerDrawn::GetDefaultMarginWidth() ) { // # better use LB_ITEMFROMPOINT perhaps? - uint nItem = ((uint)event.GetY()) / m_nItemHeight; - if ( nItem < (uint)m_noItems ) + size_t nItem = ((size_t)event.GetY()) / m_nItemHeight; + if ( nItem < (size_t)m_noItems ) GetItem(nItem)->Toggle(); //else: it's not an error, just click outside of client zone } @@ -304,3 +302,6 @@ void wxCheckListBox::OnLeftClick(wxMouseEvent& event) event.Skip(); } } + +#endif +