#if !USE_SHARED_LIBRARY
IMPLEMENT_DYNAMIC_CLASS(wxListBox, wxControl)
BEGIN_EVENT_TABLE(wxListBox, wxControl)
#if !USE_SHARED_LIBRARY
IMPLEMENT_DYNAMIC_CLASS(wxListBox, wxControl)
BEGIN_EVENT_TABLE(wxListBox, wxControl)
extern "C"
{
static pascal void wxMacListDefinition( short message, Boolean isSelected, Rect *drawRect,
extern "C"
{
static pascal void wxMacListDefinition( short message, Boolean isSelected, Rect *drawRect,
- Cell cell, short dataOffset, short dataLength,
- ListHandle listHandle ) ;
+ Cell cell, short dataOffset, short dataLength,
+ ListHandle listHandle ) ;
}
static pascal void wxMacListDefinition( short message, Boolean isSelected, Rect *drawRect,
}
static pascal void wxMacListDefinition( short message, Boolean isSelected, Rect *drawRect,
- Cell cell, short dataOffset, short dataLength,
- ListHandle listHandle )
-{
- FontInfo fontInfo;
- GrafPtr savePort;
- GrafPtr grafPtr;
- RgnHandle savedClipRegion;
- SInt32 savedPenMode;
- wxListBox* list;
+ Cell cell, short dataOffset, short dataLength,
+ ListHandle listHandle )
+{
+ FontInfo fontInfo;
+ GrafPtr savePort;
+ GrafPtr grafPtr;
+ RgnHandle savedClipRegion;
+ SInt32 savedPenMode;
+ wxListBox* list;
- // typecast our refCon
- list = (wxListBox*) GetControlReference( (ControlHandle) GetListRefCon(listHandle) );
-
- // Calculate the cell rect.
-
- switch( message ) {
- case lInitMsg:
- break;
-
- case lCloseMsg:
- break;
-
- case lDrawMsg:
- {
- const wxString text = list->m_stringArray[cell.v] ;
-
- // 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 );
-
-
- MoveTo(drawRect->left + 4 , drawRect->top + 10 );
- ::TextFont( kFontIDMonaco ) ;
- ::TextSize( 9 );
- ::TextFace( 0 ) ;
+ // typecast our refCon
+ list = (wxListBox*) GetControlReference( (ControlHandle) GetListRefCon(listHandle) );
+
+ // Calculate the cell rect.
+
+ switch( message ) {
+ case lInitMsg:
+ break;
+
+ case lCloseMsg:
+ break;
+
+ case lDrawMsg:
+ {
+ const wxString text = list->m_stringArray[cell.v] ;
+
+ // 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 );
+
+ MoveTo(drawRect->left + 4 , drawRect->top + 10 );
+ ::TextFont( kFontIDMonaco ) ;
+ ::TextSize( 9 );
+ ::TextFace( 0 ) ;
- 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( grafPtr );
- SetPortPenMode( grafPtr, hilitetransfermode );
- PaintRect( drawRect );
- SetPortPenMode( 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( grafPtr );
- SetPortPenMode( grafPtr, hilitetransfermode );
- PaintRect( drawRect );
- SetPortPenMode( grafPtr, savedPenMode );
- break;
- default :
- break ;
- }
- SetPort(savePort);
+ 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( grafPtr );
+ SetPortPenMode( grafPtr, hilitetransfermode );
+ PaintRect( drawRect );
+ SetPortPenMode( 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( grafPtr );
+ SetPortPenMode( grafPtr, hilitetransfermode );
+ PaintRect( drawRect );
+ SetPortPenMode( grafPtr, savedPenMode );
+ break;
+ default :
+ break ;
+ }
+ SetPort(savePort);
}
extern "C" void MacDrawStringCell(Rect *cellRect, Cell lCell, ListHandle theList, long refCon) ;
}
extern "C" void MacDrawStringCell(Rect *cellRect, Cell lCell, ListHandle theList, long refCon) ;
- CreateListBoxControl( parent->GetMacRootWindow(), &bounds, false, 0, 1, false, true,
+ CreateListBoxControl( parent->MacGetRootWindow(), &bounds, false, 0, 1, false, true,
14, 14, false, &listDef, &m_macControl );
GetControlData(m_macControl, kControlNoPart, kControlListBoxListHandleTag,
14, 14, false, &listDef, &m_macControl );
GetControlData(m_macControl, kControlNoPart, kControlListBoxListHandleTag,
- m_macControl = ::NewControl( parent->GetMacRootWindow() , &bounds , title , false ,
- kwxMacListWithVerticalScrollbar , 0 , 0,
- kControlListBoxProc , (long) this ) ;
+ m_macControl = ::NewControl( parent->MacGetRootWindow() , &bounds , title , false ,
+ kwxMacListWithVerticalScrollbar , 0 , 0,
+ kControlListBoxProc , (long) this ) ;
::GetControlData( m_macControl , kControlNoPart , kControlListBoxListHandleTag ,
::GetControlData( m_macControl , kControlNoPart , kControlListBoxListHandleTag ,
+void wxListBox::DoSetSize(int x, int y,
+ int width, int height,
+ int sizeFlags )
+{
+ wxControl::DoSetSize( x , y , width , height , sizeFlags ) ;
+#if TARGET_CARBON
+ Rect bounds ;
+ GetControlBounds( m_macControl , &bounds ) ;
+ ControlRef control = GetListVerticalScrollBar( m_macList ) ;
+ if ( control )
+ {
+ Rect scrollbounds ;
+ GetControlBounds( control , &scrollbounds ) ;
+ if( scrollbounds.right != bounds.right + 1 )
+ {
+ UMAMoveControl( control , bounds.right - (scrollbounds.right - scrollbounds.left) + 1 ,
+ scrollbounds.top ) ;
+ }
+ }
+#endif
+}
- int index = m_noItems ;
- if( wxApp::s_macDefaultEncodingIsPC )
- {
- m_stringArray.Add( wxMacMakeMacStringFromPC( item ) ) ;
- m_dataArray.Add( NULL );
- }
- else {
- m_stringArray.Add( item ) ;
- m_dataArray.Add( NULL );
- }
- m_noItems ++;
- DoSetItemClientData( index , NULL ) ;
- MacAppend( item ) ;
+ int index = m_noItems ;
+ if( wxApp::s_macDefaultEncodingIsPC )
+ {
+ m_stringArray.Add( wxMacMakeMacStringFromPC( item ) ) ;
+ m_dataArray.Add( NULL );
+ }
+ else {
+ m_stringArray.Add( item ) ;
+ m_dataArray.Add( NULL );
+ }
+ m_noItems ++;
+ DoSetItemClientData( index , NULL ) ;
+ MacAppend( item ) ;
#if wxUSE_OWNER_DRAWN
wxASSERT_MSG(clientData[i] == NULL,
wxT("Can't use client data with owner-drawn listboxes"));
#else // !wxUSE_OWNER_DRAWN
#if wxUSE_OWNER_DRAWN
wxASSERT_MSG(clientData[i] == NULL,
wxT("Can't use client data with owner-drawn listboxes"));
#else // !wxUSE_OWNER_DRAWN
- wxString s ;
- if( wxApp::s_macDefaultEncodingIsPC )
- {
- s = wxMacMakeMacStringFromPC( st ) ;
- }
- else
- s = st ;
-
- if ( s.Right(1) == "*" )
- {
- wxString search = s.Left( s.Length() - 1 ) ;
- int len = search.Length() ;
- Str255 s1 , s2 ;
+ wxString s ;
+ if( wxApp::s_macDefaultEncodingIsPC )
+ {
+ s = wxMacMakeMacStringFromPC( st ) ;
+ }
+ else
+ s = st ;
+
+ if ( s.Right(1) == "*" )
+ {
+ wxString search = s.Left( s.Length() - 1 ) ;
+ int len = search.Length() ;
+ Str255 s1 , s2 ;
- strcpy( (char *) s2 , search.c_str() ) ;
- c2pstr( (char *) s2 ) ;
+ strcpy( (char *) s2 , search.c_str() ) ;
+ c2pstr( (char *) s2 ) ;
- strcpy( (char *) s1 , m_stringArray[i].Left( len ).c_str() ) ;
- c2pstr( (char *) s1 ) ;
+ strcpy( (char *) s1 , m_stringArray[i].Left( len ).c_str() ) ;
+ c2pstr( (char *) s1 ) ;
- if ( EqualString( s1 , s2 , false , false ) )
- return i ;
- }
- if ( s.Left(1) == "*" && s.Length() > 1 )
- {
- s.MakeLower() ;
- for ( int i = 0 ; i < m_noItems ; ++i )
- {
- if ( GetString(i).Lower().Matches(s) )
- return i ;
- }
- }
-
- }
- else
- {
- Str255 s1 , s2 ;
+ if ( EqualString( s1 , s2 , false , false ) )
+ return i ;
+ }
+ if ( s.Left(1) == "*" && s.Length() > 1 )
+ {
+ s.MakeLower() ;
+ for ( int i = 0 ; i < m_noItems ; ++i )
+ {
+ if ( GetString(i).Lower().Matches(s) )
+ return i ;
+ }
+ }
+
+ }
+ else
+ {
+ Str255 s1 , s2 ;
- strcpy( (char *) s2 , s.c_str() ) ;
- c2pstr( (char *) s2 ) ;
+ strcpy( (char *) s2 , s.c_str() ) ;
+ c2pstr( (char *) s2 ) ;
- strcpy( (char *) s1 , m_stringArray[i].c_str() ) ;
- c2pstr( (char *) s1 ) ;
+ strcpy( (char *) s1 , m_stringArray[i].c_str() ) ;
+ c2pstr( (char *) s1 ) ;
- if ( EqualString( s1 , s2 , false , false ) )
- return i ;
- }
+ if ( EqualString( s1 , s2 , false , false ) )
+ return i ;
+ }
{
wxCHECK_RET( N >= 0 && N < m_noItems,
"invalid index in wxListBox::SetSelection" );
{
wxCHECK_RET( N >= 0 && N < m_noItems,
"invalid index in wxListBox::SetSelection" );
wxCHECK_MSG( N >= 0 && N < m_noItems, FALSE,
"invalid index in wxListBox::Selected" );
wxCHECK_MSG( N >= 0 && N < m_noItems, FALSE,
"invalid index in wxListBox::Selected" );
- wxASSERT_MSG( m_dataArray.GetCount() >= N , "invalid client_data array" ) ;
-
- if ( m_dataArray.GetCount() > N )
- {
- m_dataArray[N] = (char*) Client_data ;
+ wxASSERT_MSG( m_dataArray.GetCount() >= N , "invalid client_data array" ) ;
+
+ if ( m_dataArray.GetCount() > N )
+ {
+ m_dataArray[N] = (char*) Client_data ;
// Return number of selections and an array of selected integers
int wxListBox::GetSelections(wxArrayInt& aSelections) const
{
// Return number of selections and an array of selected integers
int wxListBox::GetSelections(wxArrayInt& aSelections) const
{
- return MacGetSelections( aSelections ) ;
-
-/* TODO
- if ((m_windowStyle & wxLB_MULTIMacE) || (m_windowStyle & wxLB_EXTENDED))
- {
- int no_sel = ??
- for ( int n = 0; n < no_sel; n++ )
- aSelections.Add(??);
-
- return no_sel;
- }
- else // single-selection listbox
- {
- aSelections.Add(??);
-
- return 1;
- }
-*/
+ return MacGetSelections( aSelections ) ;
}
// Get single selection, for single choice list items
int wxListBox::GetSelection() const
{
}
// Get single selection, for single choice list items
int wxListBox::GetSelection() const
{
- if( wxApp::s_macDefaultEncodingIsPC )
- {
- return wxMacMakePCStringFromMac( m_stringArray[N] ) ;
- }
- else
- return m_stringArray[N] ;
+ if( wxApp::s_macDefaultEncodingIsPC )
+ {
+ return wxMacMakePCStringFromMac( m_stringArray[N] ) ;
+ }
+ else
+ return m_stringArray[N] ;
- for ( int i = 0 ; i < nItems ; i++ )
- {
- m_stringArray.Insert( items[i] , pos + i ) ;
- m_dataArray.Insert( NULL , pos + i ) ;
- MacInsert( pos + i , items[i] ) ;
- }
+ for ( int i = 0 ; i < nItems ; i++ )
+ {
+ m_stringArray.Insert( items[i] , pos + i ) ;
+ m_dataArray.Insert( NULL , pos + i ) ;
+ MacInsert( pos + i , items[i] ) ;
+ }
- wxString str ;
- if( wxApp::s_macDefaultEncodingIsPC )
- {
- str = wxMacMakeMacStringFromPC( s ) ;
- }
- else
- str = s ;
- m_stringArray[N] = str ;
- MacSet( N , s ) ;
+ wxString str ;
+ if( wxApp::s_macDefaultEncodingIsPC )
+ {
+ str = wxMacMakeMacStringFromPC( s ) ;
+ }
+ else
+ str = s ;
+ m_stringArray[N] = str ;
+ MacSet( N , s ) ;
wxWindow* wxrootwindow = wxFindWinFromMacWindow( rootwindow ) ;
wxMacDrawingHelper focus( wxrootwindow );
wxWindow* wxrootwindow = wxFindWinFromMacWindow( rootwindow ) ;
wxMacDrawingHelper focus( wxrootwindow );
void MacDrawStringCell(Rect *cellRect, Cell lCell, ListHandle theList, long refCon)
{
void MacDrawStringCell(Rect *cellRect, Cell lCell, ListHandle theList, long refCon)
{
- wxListBox* list;
- // typecast our refCon
- list = (wxListBox*)refCon;
-
- MoveTo(cellRect->left + 4 , cellRect->top + 10 );
- const wxString text = list->m_stringArray[lCell.v] ;
- ::TextFont( kFontIDMonaco ) ;
- ::TextSize( 9 );
- ::TextFace( 0 ) ;
- DrawText(text, 0 , text.Length());
-
+ wxListBox* list;
+ // typecast our refCon
+ list = (wxListBox*)refCon;
+
+ MoveTo(cellRect->left + 4 , cellRect->top + 10 );
+ const wxString text = list->m_stringArray[lCell.v] ;
+ ::TextFont( kFontIDMonaco ) ;
+ ::TextSize( 9 );
+ ::TextFace( 0 ) ;
+ DrawText(text, 0 , text.Length());
+
- Cell cell = { 0 , 0 } ;
- if ( ! (m_windowStyle & wxLB_MULTIPLE) )
- {
- if ( LGetSelect( true , &cell , m_macList ) )
- {
- LSetSelect( false , cell , m_macList ) ;
- }
- }
-
- cell.v = n ;
- LSetSelect( select , cell , m_macList ) ;
- LAutoScroll( m_macList ) ;
- Refresh();
+ Cell cell = { 0 , 0 } ;
+ if ( ! (m_windowStyle & wxLB_MULTIPLE) )
+ {
+ if ( LGetSelect( true , &cell , m_macList ) )
+ {
+ LSetSelect( false , cell , m_macList ) ;
+ }
+ }
+
+ cell.v = n ;
+ LSetSelect( select , cell , m_macList ) ;
+ LAutoScroll( m_macList ) ;
+ Refresh();
- Cell cell = { 0 , 0 } ;
- cell.v = n ;
- return LGetSelect( false , &cell , m_macList ) ;
+ Cell cell = { 0 , 0 } ;
+ cell.v = n ;
+ return LGetSelect( false , &cell , m_macList ) ;
- Cell cell = { 0 , 0 } ;
- if ( LGetSelect( true , &cell , m_macList ) )
- return cell.v ;
- else
- return -1 ;
+ Cell cell = { 0 , 0 } ;
+ if ( LGetSelect( true , &cell , m_macList ) )
+ return cell.v ;
+ else
+ return -1 ;
- Cell cell = { 0 , 0 } ;
- cell.v = 0 ;
-
- while ( LGetSelect( true , &cell , m_macList ) )
- {
- aSelections.Add( cell.v ) ;
- no_sel++ ;
- cell.v++ ;
- }
- return no_sel ;
+ Cell cell = { 0 , 0 } ;
+ cell.v = 0 ;
+
+ while ( LGetSelect( true , &cell , m_macList ) )
+ {
+ aSelections.Add( cell.v ) ;
+ no_sel++ ;
+ cell.v++ ;
+ }
+ return no_sel ;
- // our implementation does not store anything in the list
- // so we just have to redraw
- Cell cell = { 0 , 0 } ;
- cell.v = n ;
-// LSetCell(text, strlen(text), cell, m_macList);
- Refresh();
+ // our implementation does not store anything in the list
+ // so we just have to redraw
+ Cell cell = { 0 , 0 } ;
+ cell.v = n ;
+// LSetCell(text, strlen(text), cell, m_macList);
+ Refresh();
- ::GetControlData( m_macControl , kControlNoPart , kControlListBoxDoubleClickTag , sizeof( wasDoubleClick ) , (char*) &wasDoubleClick , &result ) ;
- if ( !wasDoubleClick )
- {
- MacDoClick() ;
- }
- else
- {
- MacDoDoubleClick() ;
- }
+ ::GetControlData( m_macControl , kControlNoPart , kControlListBoxDoubleClickTag , sizeof( wasDoubleClick ) , (char*) &wasDoubleClick , &result ) ;
+ if ( !wasDoubleClick )
+ {
+ MacDoClick() ;
+ }
+ else
+ {
+ MacDoDoubleClick() ;
+ }
- wxCommandEvent event(wxEVT_COMMAND_LISTBOX_SELECTED, m_windowId);
+ wxArrayInt aSelections;
+ int n, count = GetSelections(aSelections);
+
+ if ( count == m_selectionPreImage.GetCount() )
+ {
+ bool hasChanged = false ;
+ for ( int i = 0 ; i < count ; ++i )
+ {
+ if ( aSelections[i] != m_selectionPreImage[i] )
+ {
+ hasChanged = true ;
+ break ;
+ }
+ }
+ if ( !hasChanged )
+ {
+ return ;
+ }
+ }
+
+ m_selectionPreImage = aSelections;
+
+ wxCommandEvent event(wxEVT_COMMAND_LISTBOX_SELECTED, m_windowId);
- wxArrayInt aSelections;
- int n, count = GetSelections(aSelections);
- if ( count > 0 )
- {
- n = aSelections[0];
- if ( HasClientObjectData() )
- event.SetClientObject( GetClientObject(n) );
- else if ( HasClientUntypedData() )
- event.SetClientData( GetClientData(n) );
- event.SetString( GetString(n) );
- }
- else
- {
+ if ( count > 0 )
+ {
+ n = aSelections[0];
+ if ( HasClientObjectData() )
+ event.SetClientObject( GetClientObject(n) );
+ else if ( HasClientUntypedData() )
+ event.SetClientData( GetClientData(n) );
+ event.SetString( GetString(n) );
+ }
+ else
+ {
{
wxCommandEvent event(wxEVT_COMMAND_LISTBOX_DOUBLECLICKED, m_windowId);
event.SetEventObject( this );
{
wxCommandEvent event(wxEVT_COMMAND_LISTBOX_DOUBLECLICKED, m_windowId);
event.SetEventObject( this );