X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/655719367ac5e131d9642e5783f3ecf64d1a3385..d5da0ce7cb746318511b3974b7882c72c0de45e2:/src/mac/classic/checklst.cpp diff --git a/src/mac/classic/checklst.cpp b/src/mac/classic/checklst.cpp index c442bbdfcb..96a18ed143 100644 --- a/src/mac/classic/checklst.cpp +++ b/src/mac/classic/checklst.cpp @@ -1,8 +1,8 @@ /////////////////////////////////////////////////////////////////////////////// -// Name: checklst.cpp +// Name: src/mac/classic/checklst.cpp // Purpose: implementation of wxCheckListBox class // Author: Stefan Csomor -// Modified by: +// Modified by: // Created: 1998-01-01 // RCS-ID: $Id$ // Copyright: (c) Stefan Csomor @@ -13,11 +13,7 @@ // headers & declarations // ============================================================================ -#ifdef __GNUG__ -#pragma implementation "checklst.h" -#endif - -#include "wx/defs.h" +#include "wx/wxprec.h" #if wxUSE_CHECKLISTBOX @@ -73,7 +69,7 @@ static pascal void wxMacCheckListDefinition( short message, Boolean isSelected, list = (wxCheckListBox*) GetControlReference( (ControlHandle) GetListRefCon(listHandle) ); if ( list == NULL ) return ; - + GrafPtr savePort; GrafPtr grafPtr; RgnHandle savedClipRegion; @@ -82,9 +78,9 @@ static pascal void wxMacCheckListDefinition( short message, Boolean isSelected, SetPort((**listHandle).port); grafPtr = (**listHandle).port ; // typecast our refCon - + // Calculate the cell rect. - + switch( message ) { case lInitMsg: break; @@ -99,13 +95,13 @@ static pascal void wxMacCheckListDefinition( short message, Boolean isSelected, // Save the current clip region, and set the clip region to the area we are about // to draw. - + savedClipRegion = NewRgn(); GetClip( savedClipRegion ); ClipRect( drawRect ); EraseRect( drawRect ); - + const wxFont& font = list->GetFont(); if ( font.Ok() ) { @@ -113,45 +109,45 @@ static pascal void wxMacCheckListDefinition( short message, Boolean isSelected, ::TextSize( font.GetMacFontSize()) ; ::TextFace( font.GetMacFontStyle() ) ; } - + ThemeButtonDrawInfo info ; info.state = kThemeStateActive ; info.value = checked ? kThemeButtonOn : kThemeButtonOff ; info.adornment = kThemeAdornmentNone ; Rect checkRect = *drawRect ; - - + + checkRect.left +=0 ; checkRect.top +=0 ; checkRect.right = checkRect.left + list->m_checkBoxWidth ; checkRect.bottom = checkRect.top + list->m_checkBoxHeight ; DrawThemeButton(&checkRect,kThemeCheckBox, &info,NULL,NULL, NULL,0); - + MoveTo(drawRect->left + 2 + list->m_checkBoxWidth+2, drawRect->top + list->m_TextBaseLineOffset ); - - DrawText(text, 0 , text.Length()); + + DrawText(text, 0 , text.length()); // If the cell is hilited, do the hilite now. Paint the cell contents with the // appropriate QuickDraw transform mode. - + if( isSelected ) { savedPenMode = GetPortPenMode( (CGrafPtr) grafPtr ); SetPortPenMode( (CGrafPtr) grafPtr, hilitetransfermode ); PaintRect( drawRect ); SetPortPenMode( (CGrafPtr) grafPtr, savedPenMode ); } - + // Restore the saved clip region. - + SetClip( savedClipRegion ); DisposeRgn( savedClipRegion ); } break; case lHiliteMsg: - + // Hilite or unhilite the cell. Paint the cell contents with the // appropriate QuickDraw transform mode. - + GetPort( &grafPtr ); savedPenMode = GetPortPenMode( (CGrafPtr) grafPtr ); SetPortPenMode( (CGrafPtr) grafPtr, hilitetransfermode ); @@ -161,7 +157,7 @@ static pascal void wxMacCheckListDefinition( short message, Boolean isSelected, default : break ; } - SetPort(savePort); + SetPort(savePort); } extern "C" void MacDrawStringCell(Rect *cellRect, Cell lCell, ListHandle theList, long refCon) ; @@ -207,13 +203,13 @@ bool wxCheckListBox::Create(wxWindow *parent, m_noItems = 0 ; // this will be increased by our append command m_selected = 0; - + m_checkBoxWidth = 12; m_checkBoxHeight= 10; - + long h = m_checkBoxHeight ; #if TARGET_CARBON - GetThemeMetric(kThemeMetricCheckBoxWidth,(long *)&m_checkBoxWidth); + GetThemeMetric(kThemeMetricCheckBoxWidth,(long *)&m_checkBoxWidth); GetThemeMetric(kThemeMetricCheckBoxHeight,&h); #endif @@ -221,26 +217,26 @@ bool wxCheckListBox::Create(wxWindow *parent, FontInfo finfo; FetchFontInfo(font.GetMacFontNum(),font.GetMacFontSize(),font.GetMacFontStyle(),&finfo); - + m_TextBaseLineOffset= finfo.leading+finfo.ascent; m_checkBoxHeight= finfo.leading+finfo.ascent+finfo.descent; - + if (m_checkBoxHeightMacGetRootWindow()) , &bounds , title , false , - kwxMacListWithVerticalScrollbar , 0 , 0, + m_macControl = (WXWidget) ::NewControl( MAC_WXHWND(parent->MacGetRootWindow()) , &bounds , title , false , + kwxMacListWithVerticalScrollbar , 0 , 0, kControlListBoxProc , (long) this ) ; ::GetControlData( (ControlHandle) m_macControl , kControlNoPart , kControlListBoxListHandleTag , sizeof( ListHandle ) , (char*) &m_macList , &result ) ; @@ -277,7 +273,7 @@ bool wxCheckListBox::Create(wxWindow *parent, (**ldef).function = (void(*)()) listDef.u.userProc; (**(ListHandle)m_macList).listDefProc = (Handle) ldef ; } - + Point pt = (**(ListHandle)m_macList).cellSize ; pt.v = 14 ; LCellSize( pt , (ListHandle)m_macList ) ; @@ -297,34 +293,34 @@ bool wxCheckListBox::Create(wxWindow *parent, options = (OptionBits) lOnlyOne ; } SetListSelectionFlags((ListHandle)m_macList, options); - + MacPostControlCreate() ; - + for ( int i = 0 ; i < n ; i++ ) { Append( choices[i] ) ; } - + LSetDrawingMode( true , (ListHandle) m_macList ) ; - return TRUE; + return true; } // ---------------------------------------------------------------------------- // wxCheckListBox functions // ---------------------------------------------------------------------------- -bool wxCheckListBox::IsChecked(size_t item) const +bool wxCheckListBox::IsChecked(unsigned int item) const { - wxCHECK_MSG( item < m_checks.GetCount(), FALSE, + wxCHECK_MSG( IsValid(item), false, _T("invalid index in wxCheckListBox::IsChecked") ); return m_checks[item] != 0; } -void wxCheckListBox::Check(size_t item, bool check) +void wxCheckListBox::Check(unsigned int item, bool check) { - wxCHECK_RET( item < m_checks.GetCount(), + wxCHECK_RET( IsValid(item), _T("invalid index in wxCheckListBox::Check") ); // intermediate var is needed to avoid compiler warning with VC++ @@ -341,9 +337,9 @@ void wxCheckListBox::Check(size_t item, bool check) // methods forwarded to wxListBox // ---------------------------------------------------------------------------- -void wxCheckListBox::Delete(int n) +void wxCheckListBox::Delete(unsigned int n) { - wxCHECK_RET( n < GetCount(), _T("invalid index in wxListBox::Delete") ); + wxCHECK_RET( IsValid(n), _T("invalid index in wxListBox::Delete") ); wxListBox::Delete(n); @@ -356,20 +352,20 @@ int wxCheckListBox::DoAppend(const wxString& item) int pos = wxListBox::DoAppend(item); // the item is initially unchecked - m_checks.Insert(FALSE, pos); + m_checks.Insert(false, pos); LSetDrawingMode( true , (ListHandle) m_macList ) ; return pos; } -void wxCheckListBox::DoInsertItems(const wxArrayString& items, int pos) +void wxCheckListBox::DoInsertItems(const wxArrayString& items, unsigned int pos) { wxListBox::DoInsertItems(items, pos); - size_t count = items.GetCount(); - for ( size_t n = 0; n < count; n++ ) + unsigned int count = items.GetCount(); + for ( unsigned int n = 0; n < count; n++ ) { - m_checks.Insert(FALSE, pos + n); + m_checks.Insert(false, pos + n); } } @@ -378,10 +374,10 @@ void wxCheckListBox::DoSetItems(const wxArrayString& items, void **clientData) // call it first as it does DoClear() wxListBox::DoSetItems(items, clientData); - size_t count = items.GetCount(); - for ( size_t n = 0; n < count; n++ ) + unsigned int count = items.GetCount(); + for ( unsigned int n = 0; n < count; n++ ) { - m_checks.Add(FALSE); + m_checks.Add(false); } } @@ -395,7 +391,7 @@ BEGIN_EVENT_TABLE(wxCheckListBox, wxListBox) EVT_LEFT_DOWN(wxCheckListBox::OnLeftClick) END_EVENT_TABLE() -// this will only work as soon as +// this will only work as soon as void wxCheckListBox::OnChar(wxKeyEvent& event) { @@ -433,8 +429,8 @@ void wxCheckListBox::OnLeftClick(wxMouseEvent& event) topcell = (**(ListHandle)m_macList).visible.top ; #endif size_t nItem = ((size_t)event.GetY()) / lineheight + topcell ; - - if ( nItem < (size_t)m_noItems ) + + if ( nItem < m_noItems ) { Check(nItem, !IsChecked(nItem) ) ; wxCommandEvent event(wxEVT_COMMAND_CHECKLISTBOX_TOGGLED, GetId());