cleanup - fixed warnings, reformatting

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@38088 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
David Surovell
2006-03-15 06:22:36 +00:00
parent 74af7bcf4f
commit c18353e561
2 changed files with 175 additions and 161 deletions

View File

@@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////////////
// Name: checklst.cpp
// Name: src/mac/carbon/checklst.cpp
// Purpose: implementation of wxCheckListBox class
// Author: Stefan Csomor
// Modified by:
@@ -8,10 +8,9 @@
// Copyright: (c) Stefan Csomor
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
//
// new DataBrowser-based version
// ============================================================================
// headers & declarations
// ============================================================================
#include "wx/wxprec.h"
@@ -21,14 +20,11 @@
#include "wx/arrstr.h"
#include "wx/mac/uma.h"
#ifndef __DARWIN__
#include <Appearance.h>
#endif
// ============================================================================
// implementation of wxCheckListBox
// ============================================================================
IMPLEMENT_DYNAMIC_CLASS(wxCheckListBox, wxListBox)
BEGIN_EVENT_TABLE(wxCheckListBox, wxListBox)
@@ -37,14 +33,13 @@ END_EVENT_TABLE()
const short kTextColumnId = 1024;
const short kCheckboxColumnId = 1025;
// new databrowser based version
// Listbox item
void wxCheckListBox::Init()
{
}
bool wxCheckListBox::Create(wxWindow *parent,
bool wxCheckListBox::Create(
wxWindow *parent,
wxWindowID id,
const wxPoint &pos,
const wxSize &size,
@@ -55,41 +50,47 @@ bool wxCheckListBox::Create(wxWindow *parent,
{
wxCArrayString chs( choices );
return Create(parent, id, pos, size, chs.GetCount(), chs.GetStrings(),
style, validator, name);
return Create( parent, id, pos, size, chs.GetCount(), chs.GetStrings(), style, validator, name );
}
#if TARGET_API_MAC_OSX
static pascal void DataBrowserItemNotificationProc(ControlRef browser, DataBrowserItemID itemID,
DataBrowserItemNotification message, DataBrowserItemDataRef itemData)
static pascal void DataBrowserItemNotificationProc(
ControlRef browser,
DataBrowserItemID itemID,
DataBrowserItemNotification message,
DataBrowserItemDataRef itemData )
#else
static pascal void DataBrowserItemNotificationProc(ControlRef browser, DataBrowserItemID itemID,
static pascal void DataBrowserItemNotificationProc(
ControlRef browser,
DataBrowserItemID itemID,
DataBrowserItemNotification message )
#endif
{
long ref = GetControlReference( browser );
if ( ref )
if (ref != 0)
{
wxCheckListBox* list = wxDynamicCast( (wxObject*)ref, wxCheckListBox );
int i = itemID - 1;
if (i >= 0 && i < list->GetCount() )
if ((i >= 0) && (i < (int)list->GetCount()))
{
bool trigger = false;
wxCommandEvent event(
wxEVT_COMMAND_LISTBOX_SELECTED, list->GetId() );
wxCommandEvent event( wxEVT_COMMAND_LISTBOX_SELECTED, list->GetId() );
switch ( message )
{
case kDataBrowserItemDeselected:
if ( list->HasMultipleSelection() )
trigger = true;
break;
case kDataBrowserItemSelected:
trigger = true;
break;
case kDataBrowserItemDoubleClicked:
event.SetEventType( wxEVT_COMMAND_LISTBOX_DOUBLECLICKED );
trigger = true;
break;
default:
break;
}
@@ -103,19 +104,22 @@ static pascal void DataBrowserItemNotificationProc(ControlRef browser, DataBrow
event.SetClientData( list->GetClientData( i ) );
event.SetString( list->GetString( i ) );
event.SetInt( i );
event.SetExtraLong( list->HasMultipleSelection() ? message == kDataBrowserItemSelected : TRUE );
event.SetExtraLong( list->HasMultipleSelection() ? message == kDataBrowserItemSelected : true );
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 sync with event
// list->GetEventHandler()->ProcessEvent( event );
}
}
}
}
static pascal OSStatus ListBoxGetSetItemData(ControlRef browser,
DataBrowserItemID itemID, DataBrowserPropertyID property,
DataBrowserItemDataRef itemData, Boolean changeValue)
static pascal OSStatus ListBoxGetSetItemData(
ControlRef browser,
DataBrowserItemID itemID,
DataBrowserPropertyID property,
DataBrowserItemDataRef itemData,
Boolean changeValue )
{
OSStatus err = errDataBrowserPropertyNotSupported;
@@ -123,15 +127,14 @@ static pascal OSStatus ListBoxGetSetItemData(ControlRef browser,
{
switch (property)
{
case kTextColumnId:
{
long ref = GetControlReference( browser );
if ( ref )
if (ref != 0)
{
wxCheckListBox* list = wxDynamicCast( (wxObject*) ref, wxCheckListBox );
int i = itemID - 1;
if (i >= 0 && i < list->GetCount() )
if ((i >= 0) && (i < (int)list->GetCount()))
{
wxMacCFStringHolder cf( list->GetString( i ), list->GetFont().GetEncoding() );
verify_noerr( ::SetDataBrowserItemDataText( itemData, cf ) );
@@ -140,14 +143,15 @@ static pascal OSStatus ListBoxGetSetItemData(ControlRef browser,
}
}
break;
case kCheckboxColumnId:
{
long ref = GetControlReference( browser );
if ( ref )
if (ref != 0)
{
wxCheckListBox* list = wxDynamicCast( (wxObject*)ref, wxCheckListBox );
int i = itemID - 1;
if (i >= 0 && i < list->GetCount() )
if ((i >= 0) && (i < (int)list->GetCount()))
{
verify_noerr( ::SetDataBrowserItemDataButtonValue( itemData, list->IsChecked( i ) ? kThemeButtonOn : kThemeButtonOff ) );
err = noErr;
@@ -155,6 +159,7 @@ static pascal OSStatus ListBoxGetSetItemData(ControlRef browser,
}
}
break;
case kDataBrowserItemIsEditableProperty:
{
err = ::SetDataBrowserItemDataBooleanValue( itemData, true );
@@ -172,11 +177,11 @@ static pascal OSStatus ListBoxGetSetItemData(ControlRef browser,
case kCheckboxColumnId:
{
long ref = GetControlReference( browser );
if ( ref )
if (ref != 0)
{
wxCheckListBox* list = wxDynamicCast( (wxObject*) ref, wxCheckListBox );
int i = itemID - 1;
if (i >= 0 && i < list->GetCount() )
if ((i >= 0) && (i < (int)list->GetCount()))
{
// we have to change this behind the back, since Check() would be triggering another update round
bool newVal = !list->IsChecked( i );
@@ -190,7 +195,6 @@ static pascal OSStatus ListBoxGetSetItemData(ControlRef browser,
list->GetEventHandler()->ProcessEvent( event );
}
}
}
break;
@@ -201,10 +205,14 @@ static pascal OSStatus ListBoxGetSetItemData(ControlRef browser,
return err;
}
bool wxCheckListBox::Create(wxWindow *parent, wxWindowID id,
bool wxCheckListBox::Create(
wxWindow *parent,
wxWindowID id,
const wxPoint& pos,
const wxSize& size,
int n, const wxString choices[],
int n,
const wxString choices[],
long style,
const wxValidator& validator,
const wxString& name )
@@ -212,24 +220,27 @@ bool wxCheckListBox::Create(wxWindow *parent, wxWindowID id,
m_macIsUserPane = false;
wxASSERT_MSG( !(style & wxLB_MULTIPLE) || !(style & wxLB_EXTENDED),
_T("only one of listbox selection modes can be specified") );
wxT("only one of listbox selection modes can be specified") );
if ( !wxListBoxBase::Create( parent, id, pos, size, style & ~(wxHSCROLL | wxVSCROLL), validator, name ) )
return false;
m_noItems = 0 ; // this will be increased by our append command
// this will be increased by our Append command
m_noItems = 0;
m_selected = 0;
Rect bounds = wxMacGetBoundsForControl( this, pos, size );
m_peer = new wxMacControl( this );
verify_noerr( ::CreateDataBrowserControl( MAC_WXHWND(parent->MacGetTopLevelWindowRef()), &bounds, kDataBrowserListView , m_peer->GetControlRefAddr() ) );
OSStatus err = ::CreateDataBrowserControl(
MAC_WXHWND(parent->MacGetTopLevelWindowRef()),
&bounds, kDataBrowserListView, m_peer->GetControlRefAddr() );
verify_noerr( err );
DataBrowserSelectionFlags options = kDataBrowserDragSelect;
if ( style & wxLB_MULTIPLE )
{
options += kDataBrowserAlwaysExtendSelection + kDataBrowserCmdTogglesSelection ;
options |= kDataBrowserAlwaysExtendSelection | kDataBrowserCmdTogglesSelection;
}
else if ( style & wxLB_EXTENDED )
{
@@ -237,9 +248,11 @@ bool wxCheckListBox::Create(wxWindow *parent, wxWindowID id,
}
else
{
options += kDataBrowserSelectOnlyOne ;
options |= kDataBrowserSelectOnlyOne;
}
verify_noerr(m_peer->SetSelectionFlags( options ) );
err = m_peer->SetSelectionFlags( options );
verify_noerr( err );
DataBrowserListViewColumnDesc columnDesc;
columnDesc.headerBtnDesc.titleOffset = 0;
@@ -261,9 +274,12 @@ bool wxCheckListBox::Create(wxWindow *parent, wxWindowID id,
columnDesc.propertyDesc.propertyID = kCheckboxColumnId;
columnDesc.propertyDesc.propertyType = kDataBrowserCheckboxType;
columnDesc.propertyDesc.propertyFlags = kDataBrowserPropertyIsMutable | kDataBrowserTableViewSelectionColumn |
kDataBrowserDefaultPropertyFlags;
verify_noerr( m_peer->AddListViewColumn( &columnDesc, kDataBrowserListViewAppendColumn) ) ;
columnDesc.propertyDesc.propertyFlags =
kDataBrowserPropertyIsMutable
| kDataBrowserTableViewSelectionColumn
| kDataBrowserDefaultPropertyFlags;
err = m_peer->AddListViewColumn( &columnDesc, kDataBrowserListViewAppendColumn );
verify_noerr( err );
// text column
@@ -278,7 +294,6 @@ bool wxCheckListBox::Create(wxWindow *parent, wxWindowID id,
#endif
;
verify_noerr( m_peer->AddListViewColumn( &columnDesc, kDataBrowserListViewAppendColumn ) );
verify_noerr( m_peer->AutoSizeListViewColumns() );
@@ -289,12 +304,12 @@ bool wxCheckListBox::Create(wxWindow *parent, wxWindowID id,
DataBrowserCallbacks callbacks;
callbacks.version = kDataBrowserLatestCallbacks;
InitDataBrowserCallbacks( &callbacks );
callbacks.u.v1.itemDataCallback = NewDataBrowserItemDataUPP(ListBoxGetSetItemData);
callbacks.u.v1.itemDataCallback = NewDataBrowserItemDataUPP( &ListBoxGetSetItemData );
callbacks.u.v1.itemNotificationCallback =
#if TARGET_API_MAC_OSX
(DataBrowserItemNotificationUPP) NewDataBrowserItemNotificationWithItemUPP(DataBrowserItemNotificationProc) ;
(DataBrowserItemNotificationUPP) NewDataBrowserItemNotificationWithItemUPP( &DataBrowserItemNotificationProc );
#else
NewDataBrowserItemNotificationUPP(DataBrowserItemNotificationProc) ;
NewDataBrowserItemNotificationUPP( &DataBrowserItemNotificationProc );
#endif
m_peer->SetCallbacks( &callbacks );
@@ -311,7 +326,8 @@ bool wxCheckListBox::Create(wxWindow *parent, wxWindowID id,
Append( choices[i] );
}
SetBestSize(size); // Needed because it is a wxControlWithItems
// Needed because it is a wxControlWithItems
SetBestSize( size );
return true;
}
@@ -323,7 +339,7 @@ bool wxCheckListBox::Create(wxWindow *parent, wxWindowID id,
bool wxCheckListBox::IsChecked(size_t item) const
{
wxCHECK_MSG( item < m_checks.GetCount(), false,
_T("invalid index in wxCheckListBox::IsChecked") );
wxT("invalid index in wxCheckListBox::IsChecked") );
return m_checks[item] != 0;
}
@@ -331,14 +347,17 @@ bool wxCheckListBox::IsChecked(size_t item) const
void wxCheckListBox::Check(size_t item, bool check)
{
wxCHECK_RET( item < m_checks.GetCount(),
_T("invalid index in wxCheckListBox::Check") );
wxT("invalid index in wxCheckListBox::Check") );
bool isChecked = m_checks[item] != 0;
if ( check != isChecked )
{
m_checks[item] = check;
UInt32 id = item + 1;
verify_noerr( m_peer->UpdateItems(kDataBrowserNoItem , 1 , &id , kDataBrowserItemNoProperty , kDataBrowserItemNoProperty ) ) ;
OSStatus err = m_peer->UpdateItems(
kDataBrowserNoItem, 1, &id,
kDataBrowserItemNoProperty, kDataBrowserItemNoProperty );
verify_noerr( err );
}
}
@@ -348,10 +367,9 @@ void wxCheckListBox::Check(size_t item, bool check)
void wxCheckListBox::Delete(int n)
{
wxCHECK_RET( n < GetCount(), _T("invalid index in wxCheckListBox::Delete") );
wxCHECK_RET( (size_t)n < GetCount(), wxT("invalid index in wxCheckListBox::Delete") );
wxListBox::Delete( n );
m_checks.RemoveAt( n );
}

View File

@@ -9,10 +9,6 @@
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
//-------------------------------------------------------------------------------------
// headers
//-------------------------------------------------------------------------------------
#include "wx/wxprec.h"
#if wxUSE_RADIOBOX
@@ -433,7 +429,7 @@ void wxRadioBox::DoSetSize(int x, int y, int width, int height, int sizeFlags)
y_offset = y_start;
current = m_radioButtonCycle;
for ( i = 0 ; i < m_noItems; i++)
for (i = 0 ; i < (int)m_noItems; i++)
{
// not to do for the zero button!
if ((i > 0) && ((i % GetMajorDim()) == 0))