cleanup - reformatting, pt 2

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@38648 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
David Surovell
2006-04-10 04:45:25 +00:00
parent cee24bf7ab
commit 520b09fcda

View File

@@ -35,8 +35,8 @@ END_EVENT_TABLE()
class wxMacListControl : public wxMacControl class wxMacListControl : public wxMacControl
{ {
public: public:
wxMacListControl( wxListBox *peer ) : wxMacListControl( wxListBox *peer )
wxMacControl( peer ) : wxMacControl( peer )
{ {
} }
@@ -47,22 +47,20 @@ public:
virtual void UpdateLine( int n ) = 0; virtual void UpdateLine( int n ) = 0;
virtual void MacDelete( int n ) = 0; virtual void MacDelete( int n ) = 0;
virtual void MacInsert( int n, const wxString& item) = 0; virtual void MacInsert( int n, const wxString& item ) = 0;
virtual void MacInsert( int n, const wxArrayString& items) = 0; virtual void MacInsert( int n, const wxArrayString& items ) = 0;
virtual void MacAppend( const wxString& item) = 0; virtual void MacAppend( const wxString& item ) = 0;
virtual void MacSet( int n, const wxString& item ) = 0; virtual void MacSet( int n, const wxString& item ) = 0;
virtual void MacClear() = 0; virtual void MacClear() = 0;
virtual void MacDeselectAll() = 0; virtual void MacDeselectAll() = 0;
virtual void MacSetSelection( int n, bool select ) = 0; virtual void MacSetSelection( int n, bool select ) = 0;
virtual int MacGetSelection() const = 0; virtual int MacGetSelection() const = 0;
virtual int MacGetSelections(wxArrayInt& aSelections) const = 0; virtual int MacGetSelections( wxArrayInt& aSelections ) const = 0;
virtual bool MacIsSelected( int n ) const= 0; virtual bool MacIsSelected( int n ) const = 0;
virtual void MacScrollTo( int n ) = 0; virtual void MacScrollTo( int n ) = 0;
wxListBox * GetPeer() const wxListBox * GetPeer() const
{ { return (wxListBox*)m_peer; }
return (wxListBox*)m_peer;
}
}; };
#if 0 #if 0
@@ -76,15 +74,15 @@ public:
~wxMacCustomHIViewListControl(); ~wxMacCustomHIViewListControl();
void MacDelete( int n ); void MacDelete( int n );
void MacInsert( int n, const wxString& item); void MacInsert( int n, const wxString& item );
void MacInsert( int n, const wxArrayString& items); void MacInsert( int n, const wxArrayString& items );
void MacAppend( const wxString& item); void MacAppend( const wxString& item );
void MacSet( int n, const wxString& item ); void MacSet( int n, const wxString& item );
void MacClear(); void MacClear();
void MacDeselectAll(); void MacDeselectAll();
void MacSetSelection( int n, bool select ); void MacSetSelection( int n, bool select );
int MacGetSelection() const; int MacGetSelection() const;
int MacGetSelections(wxArrayInt& aSelections) const; int MacGetSelections( wxArrayInt& aSelections ) const;
bool MacIsSelected( int n ) const; bool MacIsSelected( int n ) const;
void MacScrollTo( int n ); void MacScrollTo( int n );
}; };
@@ -101,15 +99,15 @@ public:
void UpdateLine( int n ); void UpdateLine( int n );
void MacDelete( int n ); void MacDelete( int n );
void MacInsert( int n, const wxString& item); void MacInsert( int n, const wxString& item );
void MacInsert( int n, const wxArrayString& items); void MacInsert( int n, const wxArrayString& items );
void MacAppend( const wxString& item); void MacAppend( const wxString& item );
void MacSet( int n, const wxString& item ); void MacSet( int n, const wxString& item );
void MacClear(); void MacClear();
void MacDeselectAll(); void MacDeselectAll();
void MacSetSelection( int n, bool select ); void MacSetSelection( int n, bool select );
int MacGetSelection() const; int MacGetSelection() const;
int MacGetSelections(wxArrayInt& aSelections) const; int MacGetSelections( wxArrayInt& aSelections ) const;
bool MacIsSelected( int n ) const; bool MacIsSelected( int n ) const;
void MacScrollTo( int n ); void MacScrollTo( int n );
@@ -119,8 +117,8 @@ public:
virtual OSStatus AutoSizeListViewColumns(); virtual OSStatus AutoSizeListViewColumns();
virtual OSStatus SetHasScrollBars( bool horiz, bool vert ); virtual OSStatus SetHasScrollBars( bool horiz, bool vert );
virtual OSStatus SetTableViewHiliteStyle( DataBrowserTableViewHiliteStyle hiliteStyle ); virtual OSStatus SetTableViewHiliteStyle( DataBrowserTableViewHiliteStyle hiliteStyle );
virtual OSStatus SetListViewHeaderBtnHeight(UInt16 height); virtual OSStatus SetListViewHeaderBtnHeight( UInt16 height );
virtual OSStatus SetCallbacks(const DataBrowserCallbacks *callbacks); virtual OSStatus SetCallbacks( const DataBrowserCallbacks *callbacks );
virtual OSStatus UpdateItems( DataBrowserItemID container, UInt32 numItems, virtual OSStatus UpdateItems( DataBrowserItemID container, UInt32 numItems,
const DataBrowserItemID *items, const DataBrowserItemID *items,
DataBrowserPropertyID preSortProperty, DataBrowserPropertyID preSortProperty,
@@ -136,7 +134,7 @@ public:
DataBrowserRevealOptions options ); DataBrowserRevealOptions options );
virtual OSStatus GetSelectionAnchor( DataBrowserItemID *first, DataBrowserItemID *last ) const; virtual OSStatus GetSelectionAnchor( DataBrowserItemID *first, DataBrowserItemID *last ) const;
virtual bool IsItemSelected( DataBrowserItemID item ) const; virtual bool IsItemSelected( DataBrowserItemID item ) const;
virtual OSStatus SetSelectedItems(UInt32 numItems, virtual OSStatus SetSelectedItems( UInt32 numItems,
const DataBrowserItemID *items, const DataBrowserItemID *items,
DataBrowserSetOption operation ); DataBrowserSetOption operation );
@@ -169,10 +167,10 @@ private:
const short kTextColumnId = 1024; const short kTextColumnId = 1024;
const short kCheckboxColumnId = 1025; const short kCheckboxColumnId = 1025;
// new databrowserbased version // new DataBrowser-based version
// because of the limited insert // because of the limited insert
// functionality of DataBrowser, // functionality of DataBrowser,
// we just introduce id s corresponding // we just introduce IDs corresponding
// to the line number // to the line number
DataBrowserItemDataUPP gDataBrowserItemDataUPP = NULL; DataBrowserItemDataUPP gDataBrowserItemDataUPP = NULL;
@@ -183,19 +181,19 @@ pascal void wxMacDataBrowserListControl::DataBrowserItemNotificationProc(
ControlRef browser, ControlRef browser,
DataBrowserItemID itemID, DataBrowserItemID itemID,
DataBrowserItemNotification message, DataBrowserItemNotification message,
DataBrowserItemDataRef itemData) DataBrowserItemDataRef itemData )
#else #else
pascal void wxMacDataBrowserListControl::DataBrowserItemNotificationProc( pascal void wxMacDataBrowserListControl::DataBrowserItemNotificationProc(
ControlRef browser, ControlRef browser,
DataBrowserItemID itemID, DataBrowserItemID itemID,
DataBrowserItemNotification message) DataBrowserItemNotification message )
#endif #endif
{ {
long ref = GetControlReference( browser ); long ref = GetControlReference( browser );
if ( ref != 0 ) if ( ref != 0 )
{ {
wxListBox *list = wxDynamicCast( (wxObject*)ref, wxListBox ); wxListBox *list = wxDynamicCast( (wxObject*)ref, wxListBox );
wxMacDataBrowserListControl* peer = (wxMacDataBrowserListControl*) list->GetPeer(); wxMacDataBrowserListControl *peer = (wxMacDataBrowserListControl*) list->GetPeer();
int i = itemID - 1; int i = itemID - 1;
if (i >= 0 && i < (int)list->GetCount()) if (i >= 0 && i < (int)list->GetCount())
@@ -233,6 +231,7 @@ pascal void wxMacDataBrowserListControl::DataBrowserItemNotificationProc(
event.SetInt( i ); event.SetInt( i );
event.SetExtraLong( list->HasMultipleSelection() ? message == kDataBrowserItemSelected : true ); event.SetExtraLong( list->HasMultipleSelection() ? message == kDataBrowserItemSelected : true );
wxPostEvent( list->GetEventHandler(), event ); wxPostEvent( list->GetEventHandler(), event );
// direct notification is not always having the listbox GetSelection() having in synch with event // direct notification is not always having the listbox GetSelection() having in synch with event
// list->GetEventHandler()->ProcessEvent(event); // list->GetEventHandler()->ProcessEvent(event);
} }
@@ -240,17 +239,20 @@ pascal void wxMacDataBrowserListControl::DataBrowserItemNotificationProc(
} }
} }
static pascal OSStatus ListBoxGetSetItemData(ControlRef browser, static pascal OSStatus ListBoxGetSetItemData(
DataBrowserItemID itemID, DataBrowserPropertyID property, ControlRef browser,
DataBrowserItemDataRef itemData, Boolean changeValue) DataBrowserItemID itemID,
DataBrowserPropertyID property,
DataBrowserItemDataRef itemData,
Boolean changeValue )
{ {
OSStatus err = errDataBrowserPropertyNotSupported; OSStatus err = errDataBrowserPropertyNotSupported;
long ref = GetControlReference( browser ); long ref = GetControlReference( browser );
if ( ! changeValue ) if ( !changeValue )
{ {
wxListBox* list = wxDynamicCast( (wxObject*) ref, wxListBox ); wxListBox *list = wxDynamicCast( (wxObject*)ref, wxListBox );
bool isCheckList = false; bool isCheckList = false;
if (list) if (list)
isCheckList = list->IsKindOf( CLASSINFO(wxCheckListBox) ); isCheckList = list->IsKindOf( CLASSINFO(wxCheckListBox) );
@@ -258,26 +260,28 @@ static pascal OSStatus ListBoxGetSetItemData(ControlRef browser,
switch (property) switch (property)
{ {
case kTextColumnId: case kTextColumnId:
if ( ref ) if ( ref != 0 )
{ {
int i = itemID - 1; int i = itemID - 1;
if (i >= 0 && i < (int)list->GetCount() ) if (i >= 0 && i < (int)list->GetCount())
{ {
wxMacCFStringHolder cf( list->GetString( i ), list->GetFont().GetEncoding() ); wxMacCFStringHolder cf( list->GetString( i ), list->GetFont().GetEncoding() );
verify_noerr( ::SetDataBrowserItemDataText( itemData, cf ) ); err = ::SetDataBrowserItemDataText( itemData, cf );
verify_noerr( err );
err = noErr; err = noErr;
} }
} }
break; break;
case kCheckboxColumnId: case kCheckboxColumnId:
if ( ref ) if ( ref != 0 )
{ {
wxCheckListBox* list = wxDynamicCast( (wxObject*) ref, wxCheckListBox ); wxCheckListBox *list = wxDynamicCast( (wxObject*)ref, wxCheckListBox );
int i = itemID - 1; int i = itemID - 1;
if (i >= 0 && (unsigned int) i < list->GetCount()) if (i >= 0 && (unsigned int) i < list->GetCount())
{ {
verify_noerr( ::SetDataBrowserItemDataButtonValue( itemData, list->IsChecked( i ) ? kThemeButtonOn : kThemeButtonOff ) ); err = ::SetDataBrowserItemDataButtonValue( itemData, list->IsChecked( i ) ? kThemeButtonOn : kThemeButtonOff );
verify_noerr( err );
err = noErr; err = noErr;
} }
} }
@@ -285,7 +289,7 @@ static pascal OSStatus ListBoxGetSetItemData(ControlRef browser,
case kDataBrowserItemIsEditableProperty: case kDataBrowserItemIsEditableProperty:
if ( isCheckList ) if ( isCheckList )
err = ::SetDataBrowserItemDataBooleanValue(itemData, true); err = ::SetDataBrowserItemDataBooleanValue( itemData, true );
break; break;
default: default:
@@ -297,22 +301,23 @@ static pascal OSStatus ListBoxGetSetItemData(ControlRef browser,
switch (property) switch (property)
{ {
case kCheckboxColumnId: case kCheckboxColumnId:
if ( ref ) if ( ref != 0 )
{ {
wxCheckListBox* list = wxDynamicCast( (wxObject*) ref, wxCheckListBox ); wxCheckListBox *list = wxDynamicCast( (wxObject*)ref, wxCheckListBox );
int i = itemID - 1; int i = itemID - 1;
if (i >= 0 && (unsigned int)i < list->GetCount() ) if (i >= 0 && (unsigned int)i < list->GetCount())
{ {
// we have to change this behind the back, since Check() would be triggering another update round // we have to change this behind the back, since Check() would be triggering another update round
bool newVal = !list->IsChecked( i ); bool newVal = !list->IsChecked( i );
verify_noerr( ::SetDataBrowserItemDataButtonValue( itemData, newVal ? kThemeButtonOn : kThemeButtonOff ) ); err = ::SetDataBrowserItemDataButtonValue( itemData, newVal ? kThemeButtonOn : kThemeButtonOff );
verify_noerr( err );
err = noErr; err = noErr;
list->m_checks[i] = newVal; list->m_checks[i] = newVal;
wxCommandEvent event(wxEVT_COMMAND_CHECKLISTBOX_TOGGLED, list->GetId()); wxCommandEvent event( wxEVT_COMMAND_CHECKLISTBOX_TOGGLED, list->GetId() );
event.SetInt(i); event.SetInt( i );
event.SetEventObject(list); event.SetEventObject( list );
list->GetEventHandler()->ProcessEvent(event); list->GetEventHandler()->ProcessEvent( event );
} }
} }
break; break;
@@ -403,7 +408,6 @@ wxMacDataBrowserListControl::wxMacDataBrowserListControl( wxListBox *peer, const
columnDesc.headerBtnDesc.minimumWidth = 0; columnDesc.headerBtnDesc.minimumWidth = 0;
columnDesc.headerBtnDesc.maximumWidth = 10000; columnDesc.headerBtnDesc.maximumWidth = 10000;
columnDesc.propertyDesc.propertyID = kTextColumnId; columnDesc.propertyDesc.propertyID = kTextColumnId;
columnDesc.propertyDesc.propertyType = kDataBrowserTextType; columnDesc.propertyDesc.propertyType = kDataBrowserTextType;
columnDesc.propertyDesc.propertyFlags = kDataBrowserTableViewSelectionColumn; columnDesc.propertyDesc.propertyFlags = kDataBrowserTableViewSelectionColumn;
@@ -773,26 +777,28 @@ static pascal void ListBoxDrawProc(
wxListBox::wxListBox() wxListBox::wxListBox()
{ {
m_noItems = 0; m_noItems = 0;
} }
bool wxListBox::Create(wxWindow *parent, bool wxListBox::Create(
wxWindow *parent,
wxWindowID id, wxWindowID id,
const wxPoint& pos, const wxPoint& pos,
const wxSize& size, const wxSize& size,
const wxArrayString& choices, const wxArrayString& choices,
long style, long style,
const wxValidator& validator, const wxValidator& validator,
const wxString& name) const wxString& name )
{ {
wxCArrayString chs(choices); wxCArrayString chs(choices);
return Create( return Create(
parent, id, pos, size, chs.GetCount(), chs.GetStrings(), parent, id, pos, size, chs.GetCount(), chs.GetStrings(),
style, validator, name); style, validator, name );
} }
bool wxListBox::Create(wxWindow *parent, bool wxListBox::Create(
wxWindow *parent,
wxWindowID id, wxWindowID id,
const wxPoint& pos, const wxPoint& pos,
const wxSize& size, const wxSize& size,
@@ -800,14 +806,14 @@ bool wxListBox::Create(wxWindow *parent,
const wxString choices[], const wxString choices[],
long style, long style,
const wxValidator& validator, const wxValidator& validator,
const wxString& name) const wxString& name )
{ {
m_macIsUserPane = false; m_macIsUserPane = false;
wxASSERT_MSG( !(style & wxLB_MULTIPLE) || !(style & wxLB_EXTENDED), wxASSERT_MSG( !(style & wxLB_MULTIPLE) || !(style & wxLB_EXTENDED),
_T("only one of listbox selection modes can be specified") ); wxT("only a single listbox selection mode can be specified") );
if ( !wxListBoxBase::Create(parent, id, pos, size, style & ~(wxHSCROLL | wxVSCROLL), validator, name) ) if ( !wxListBoxBase::Create( parent, id, pos, size, style & ~(wxHSCROLL | wxVSCROLL), validator, name ) )
return false; return false;
// this will be increased by our append command // this will be increased by our append command
@@ -920,7 +926,7 @@ void wxListBox::DoSetItems(const wxArrayString& choices, void** clientData)
{ {
#if wxUSE_OWNER_DRAWN #if wxUSE_OWNER_DRAWN
wxASSERT_MSG(clientData[i] == NULL, wxASSERT_MSG(clientData[i] == NULL,
wxT("Can't use client data with owner-drawn listboxes")); wxT("Cannot use client data with owner-drawn listboxes"));
#else #else
Append( choices[i], clientData[i] ); Append( choices[i], clientData[i] );
#endif #endif
@@ -958,7 +964,7 @@ int wxListBox::FindString(const wxString& s, bool bCase) const
{ {
for ( size_t i = 0; i < m_noItems; ++ i ) for ( size_t i = 0; i < m_noItems; ++ i )
{ {
if (s.IsSameAs(GetString(i), bCase)) if (s.IsSameAs( GetString( i ), bCase) )
return (int)i; return (int)i;
} }
@@ -996,14 +1002,14 @@ void *wxListBox::DoGetItemClientData(unsigned int n) const
{ {
wxCHECK_MSG( IsValid(n), NULL, wxT("invalid index in wxListBox::GetClientData")); wxCHECK_MSG( IsValid(n), NULL, wxT("invalid index in wxListBox::GetClientData"));
wxASSERT_MSG( m_dataArray.GetCount() >= (unsigned int) n, wxT("invalid client_data array") ); wxASSERT_MSG( m_dataArray.GetCount() >= (unsigned int)n, wxT("invalid client_data array") );
return (void *)m_dataArray[n]; return (void*)m_dataArray[n];
} }
wxClientData *wxListBox::DoGetItemClientObject(unsigned int n) const wxClientData *wxListBox::DoGetItemClientObject(unsigned int n) const
{ {
return (wxClientData *) DoGetItemClientData( n ); return (wxClientData*)DoGetItemClientData( n );
} }
void wxListBox::DoSetItemClientData(unsigned int n, void *clientData) void wxListBox::DoSetItemClientData(unsigned int n, void *clientData)
@@ -1015,13 +1021,13 @@ void wxListBox::DoSetItemClientData(unsigned int n, void *clientData)
{ {
// client data must be pointer to wxOwnerDrawn, otherwise we would crash // client data must be pointer to wxOwnerDrawn, otherwise we would crash
// in OnMeasure/OnDraw. // in OnMeasure/OnDraw.
wxFAIL_MSG(wxT("Can't use client data with owner-drawn listboxes")); wxFAIL_MSG(wxT("Cannot use client data with owner-drawn listboxes"));
} }
#endif #endif
wxASSERT_MSG( m_dataArray.GetCount() >= (unsigned int) n, wxT("invalid client_data array") ); wxASSERT_MSG( m_dataArray.GetCount() >= (unsigned int)n, wxT("invalid client_data array") );
if ( m_dataArray.GetCount() > (unsigned int) n ) if ( m_dataArray.GetCount() > (unsigned int)n )
m_dataArray[n] = (char*)clientData; m_dataArray[n] = (char*)clientData;
else else
m_dataArray.Add( (char*)clientData ); m_dataArray.Add( (char*)clientData );
@@ -1092,14 +1098,14 @@ wxSize wxListBox::DoGetBestSize() const
else else
{ {
::TextFont( kFontIDMonaco ); ::TextFont( kFontIDMonaco );
::TextSize( 9 ); ::TextSize( 9 );
::TextFace( 0 ); ::TextFace( 0 );
} }
// Find the widest line // Find the widest line
for (unsigned int i = 0; i < GetCount(); i++) for (unsigned int i = 0; i < GetCount(); i++)
{ {
wxString str(GetString(i)); wxString str( GetString( i ) );
#if wxUSE_UNICODE #if wxUSE_UNICODE
Point bounds = {0, 0}; Point bounds = {0, 0};
@@ -1122,7 +1128,7 @@ wxSize wxListBox::DoGetBestSize() const
} }
// Add room for the scrollbar // Add room for the scrollbar
lbWidth += wxSystemSettings::GetMetric(wxSYS_VSCROLL_X); lbWidth += wxSystemSettings::GetMetric( wxSYS_VSCROLL_X );
// And just a bit more // And just a bit more
int cy = 12; int cy = 12;
@@ -1164,7 +1170,7 @@ wxListBoxItem::wxListBoxItem(const wxString& str)
: wxOwnerDrawn(str, false) : wxOwnerDrawn(str, false)
{ {
// no bitmaps/checkmarks // no bitmaps/checkmarks
SetMarginWidth(0); SetMarginWidth( 0 );
} }
wxOwnerDrawn *wxListBox::CreateItem(size_t n) wxOwnerDrawn *wxListBox::CreateItem(size_t n)