-
- wxFontRefData * font = (wxFontRefData*) list->GetFont().GetRefData() ;
-
- if ( font )
- {
- ::TextFont( font->m_macFontNum ) ;
- ::TextSize( short(font->m_macFontSize) ) ;
- ::TextFace( font->m_macFontStyle ) ;
- }
- else
- {
- ::TextFont( kFontIDMonaco ) ;
- ::TextSize( 9 );
- ::TextFace( 0 ) ;
- }
-
+
+ wxFontRefData * font = (wxFontRefData*) list->GetFont().GetRefData() ;
+
+ if ( font )
+ {
+ ::TextFont( font->m_macFontNum ) ;
+ ::TextSize( short(font->m_macFontSize) ) ;
+ ::TextFace( font->m_macFontStyle ) ;
+ }
+ else
+ {
+ ::TextFont( kFontIDMonaco ) ;
+ ::TextSize( 9 );
+ ::TextFace( 0 ) ;
+ }
+
- bool useDrawThemeText = ( DrawThemeTextBox != (void*) kUnresolvedCFragSymbolAddress ) ;
-
- if ( useDrawThemeText )
- {
- Rect frame = { drawRect->top, drawRect->left + 4,
- drawRect->top + kwxMacListItemHeight, drawRect->right + 10000 } ;
+ bool useDrawThemeText = ( DrawThemeTextBox != (void*) kUnresolvedCFragSymbolAddress ) ;
+
+ if ( useDrawThemeText )
+ {
+ Rect frame = { drawRect->top, drawRect->left + 4,
+ drawRect->top + kwxMacListItemHeight, drawRect->right + 10000 } ;
CFStringRef sString = CFStringCreateWithBytes( NULL , (UInt8*) text.c_str(), text.Length(), CFStringGetSystemEncoding(), false ) ;
CFMutableStringRef mString = CFStringCreateMutableCopy( NULL , 0 , sString ) ;
CFStringRef sString = CFStringCreateWithBytes( NULL , (UInt8*) text.c_str(), text.Length(), CFStringGetSystemEncoding(), false ) ;
CFMutableStringRef mString = CFStringCreateMutableCopy( NULL , 0 , sString ) ;
- CFRelease( sString ) ;
- ::TruncateThemeText( mString , kThemeCurrentPortFont, kThemeStateActive, drawRect->right - drawRect->left , truncEnd , NULL ) ;
- ::DrawThemeTextBox( mString,
- kThemeCurrentPortFont,
- kThemeStateActive,
- false,
- &frame,
- teJustLeft,
- nil );
- CFRelease( mString ) ;
+ CFRelease( sString ) ;
+ ::TruncateThemeText( mString , kThemeCurrentPortFont, kThemeStateActive, drawRect->right - drawRect->left , truncEnd , NULL ) ;
+ ::DrawThemeTextBox( mString,
+ kThemeCurrentPortFont,
+ kThemeStateActive,
+ false,
+ &frame,
+ teJustLeft,
+ nil );
+ CFRelease( mString ) ;
- {
- MoveTo(drawRect->left + 4 , drawRect->top + 10 );
- DrawText(text, 0 , text.Length());
- }
-
+ {
+ MoveTo(drawRect->left + 4 , drawRect->top + 10 );
+ 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 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 );
}
if( isSelected ) {
savedPenMode = GetPortPenMode( (CGrafPtr) grafPtr );
SetPortPenMode( (CGrafPtr)grafPtr, hilitetransfermode );
PaintRect( drawRect );
SetPortPenMode( (CGrafPtr)grafPtr, savedPenMode );
}
- }
- 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 );
- PaintRect( drawRect );
- SetPortPenMode( (CGrafPtr)grafPtr, savedPenMode );
- break;
- default :
- break ;
+ }
+ 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 );
+ PaintRect( drawRect );
+ SetPortPenMode( (CGrafPtr)grafPtr, savedPenMode );
+ break;
+ default :
+ break ;
}
SetPort(savePort);
}
extern "C" void MacDrawStringCell(Rect *cellRect, Cell lCell, ListHandle theList, long refCon) ;
}
SetPort(savePort);
}
extern "C" void MacDrawStringCell(Rect *cellRect, Cell lCell, ListHandle theList, long refCon) ;
MacPreControlCreate( parent , id , "" , pos , size ,style, validator , name , &bounds , title ) ;
MacPreControlCreate( parent , id , "" , pos , size ,style, validator , name , &bounds , title ) ;
- GetThemeFont(kThemeViewsFont , GetApplicationScript() , fontName , &fontSize , &fontStyle ) ;
+ GetThemeFont(kThemeViewsFont , GetApplicationScript() , fontName , &fontSize , &fontStyle ) ;
#endif
CopyPascalStringToC( fontName , (char*) fontName ) ;
SetFont( wxFont (fontSize, wxSWISS, wxNORMAL, wxNORMAL , false , fontName ) ) ;
#endif
CopyPascalStringToC( fontName , (char*) fontName ) ;
SetFont( wxFont (fontSize, wxSWISS, wxNORMAL, wxNORMAL , false , fontName ) ) ;
- CreateListBoxControl( MAC_WXHWND(parent->MacGetRootWindow()), &bounds, false, 0, 1, false, true,
+ CreateListBoxControl( MAC_WXHWND(parent->MacGetRootWindow()), &bounds, false, 0, 1, (style & wxLB_HSCROLL), true,
kwxMacListItemHeight, kwxMacListItemHeight, false, &listDef, (ControlRef *)&m_macControl );
GetControlData( (ControlHandle) m_macControl, kControlNoPart, kControlListBoxListHandleTag,
kwxMacListItemHeight, kwxMacListItemHeight, false, &listDef, (ControlRef *)&m_macControl );
GetControlData( (ControlHandle) m_macControl, kControlNoPart, kControlListBoxListHandleTag,
long result ;
wxStAppResource resload ;
m_macControl = ::NewControl( MAC_WXHWND(parent->MacGetRootWindow()) , &bounds , title , false ,
long result ;
wxStAppResource resload ;
m_macControl = ::NewControl( MAC_WXHWND(parent->MacGetRootWindow()) , &bounds , title , false ,
- kwxMacListWithVerticalScrollbar , 0 , 0,
- kControlListBoxProc , (long) this ) ;
+ (style & wxLB_HSCROLL) ? kwxMacListWithVerticalAndHorizontalScrollbar : kwxMacListWithVerticalScrollbar ,
+ 0 , 0, kControlListBoxProc , (long) this ) ;
::GetControlData( (ControlHandle) m_macControl , kControlNoPart , kControlListBoxListHandleTag ,
sizeof( ListHandle ) , (char*) &m_macList , &result ) ;
::GetControlData( (ControlHandle) m_macControl , kControlNoPart , kControlListBoxListHandleTag ,
sizeof( ListHandle ) , (char*) &m_macList , &result ) ;
- MacSetRedraw( false ) ;
- Clear() ;
- int n = choices.GetCount();
-
- for( int i = 0 ; i < n ; ++i )
- {
- if ( clientData )
+ MacSetRedraw( false ) ;
+ Clear() ;
+ int n = choices.GetCount();
+
+ for( int i = 0 ; i < n ; ++i )
#if TARGET_CARBON
c2pstrcpy( (StringPtr) s2 , search.c_str() ) ;
#else
strcpy( (char *) s2 , search.c_str() ) ;
c2pstr( (char *) s2 ) ;
#endif
#if TARGET_CARBON
c2pstrcpy( (StringPtr) s2 , search.c_str() ) ;
#else
strcpy( (char *) s2 , search.c_str() ) ;
c2pstr( (char *) s2 ) ;
#endif
#if TARGET_CARBON
c2pstrcpy( (StringPtr) s2 , s.c_str() ) ;
#else
strcpy( (char *) s2 , s.c_str() ) ;
c2pstr( (char *) s2 ) ;
#endif
#if TARGET_CARBON
c2pstrcpy( (StringPtr) s2 , s.c_str() ) ;
#else
strcpy( (char *) s2 , s.c_str() ) ;
c2pstr( (char *) s2 ) ;
#endif
}
void wxListBox::SetSelection(int N, bool select)
{
wxCHECK_RET( N >= 0 && N < m_noItems,
}
void wxListBox::SetSelection(int N, bool select)
{
wxCHECK_RET( N >= 0 && N < m_noItems,
- "invalid index in wxListBox::SetSelection" );
- MacSetSelection( N , select ) ;
- GetSelections( m_selectionPreImage ) ;
+ "invalid index in wxListBox::SetSelection" );
+ MacSetSelection( N , select ) ;
+ GetSelections( m_selectionPreImage ) ;
}
bool wxListBox::IsSelected(int N) const
{
wxCHECK_MSG( N >= 0 && N < m_noItems, FALSE,
}
bool wxListBox::IsSelected(int N) const
{
wxCHECK_MSG( N >= 0 && N < m_noItems, FALSE,
}
void *wxListBox::DoGetItemClientData(int N) const
{
wxCHECK_MSG( N >= 0 && N < m_noItems, NULL,
}
void *wxListBox::DoGetItemClientData(int N) const
{
wxCHECK_MSG( N >= 0 && N < m_noItems, NULL,
void wxListBox::DoSetItemClientData(int N, void *Client_data)
{
wxCHECK_RET( N >= 0 && N < m_noItems,
void wxListBox::DoSetItemClientData(int N, void *Client_data)
{
wxCHECK_RET( N >= 0 && N < m_noItems,
}
#endif // wxUSE_OWNER_DRAWN
wxASSERT_MSG( m_dataArray.GetCount() >= (size_t) N , "invalid client_data array" ) ;
}
#endif // wxUSE_OWNER_DRAWN
wxASSERT_MSG( m_dataArray.GetCount() >= (size_t) N , "invalid client_data array" ) ;
void wxListBox::DoInsertItems(const wxArrayString& items, int pos)
{
wxCHECK_RET( pos >= 0 && pos <= m_noItems,
void wxListBox::DoInsertItems(const wxArrayString& items, int pos)
{
wxCHECK_RET( pos >= 0 && pos <= m_noItems,
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] ) ;
}
-
- {
- wxMacPortStateHelper st( UMAGetWindowPort( (WindowRef) MacGetRootWindow() ) ) ;
- Rect drawRect ;
-
- wxFontRefData * font = (wxFontRefData*) m_font.GetRefData() ;
-
- if ( font )
- {
- ::TextFont( font->m_macFontNum ) ;
- ::TextSize( short(font->m_macFontSize) ) ;
- ::TextFace( font->m_macFontStyle ) ;
- }
- else
- {
- ::TextFont( kFontIDMonaco ) ;
- ::TextSize( 9 );
- ::TextFace( 0 ) ;
- }
-
- // Find the widest line
- for(int i = 0; i < GetCount(); i++) {
- wxString str(GetString(i));
- wLine = ::TextWidth( str.c_str() , 0 , str.Length() ) ;
- lbWidth = wxMax(lbWidth, wLine);
- }
-
- // Add room for the scrollbar
- lbWidth += wxSystemSettings::GetMetric(wxSYS_VSCROLL_X);
-
- // And just a bit more
- int cy = 12 ;
- int cx = ::TextWidth( "X" , 0 , 1 ) ;
- lbWidth += cx ;
-
- // don't make the listbox too tall (limit height to around 10 items) but don't
- // make it too small neither
- lbHeight = (cy+4) * wxMin(wxMax(GetCount(), 3), 10);
- }
+
+ {
+ wxMacPortStateHelper st( UMAGetWindowPort( (WindowRef) MacGetRootWindow() ) ) ;
+
+ wxFontRefData * font = (wxFontRefData*) m_font.GetRefData() ;
+
+ if ( font )
+ {
+ ::TextFont( font->m_macFontNum ) ;
+ ::TextSize( short(font->m_macFontSize) ) ;
+ ::TextFace( font->m_macFontStyle ) ;
+ }
+ else
+ {
+ ::TextFont( kFontIDMonaco ) ;
+ ::TextSize( 9 );
+ ::TextFace( 0 ) ;
+ }
+
+ // Find the widest line
+ for(int i = 0; i < GetCount(); i++) {
+ wxString str(GetString(i));
+ wLine = ::TextWidth( str.c_str() , 0 , str.Length() ) ;
+ lbWidth = wxMax(lbWidth, wLine);
+ }
+
+ // Add room for the scrollbar
+ lbWidth += wxSystemSettings::GetMetric(wxSYS_VSCROLL_X);
+
+ // And just a bit more
+ int cy = 12 ;
+ int cx = ::TextWidth( "X" , 0 , 1 ) ;
+ lbWidth += cx ;
+
+ // don't make the listbox too tall (limit height to around 10 items) but don't
+ // make it too small neither
+ lbHeight = (cy+4) * wxMin(wxMax(GetCount(), 3), 10);
+ }
void wxListBox::Refresh(bool eraseBack, const wxRect *rect)
{
wxControl::Refresh( eraseBack , rect ) ;
void wxListBox::Refresh(bool eraseBack, const wxRect *rect)
{
wxControl::Refresh( eraseBack , rect ) ;
/*
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 } ;
cell.v = (**(ListHandle)m_macList).dataBounds.bottom ;
LAddRow( 1 , cell.v , (ListHandle)m_macList ) ;
Cell cell = { 0 , 0 } ;
cell.v = (**(ListHandle)m_macList).dataBounds.bottom ;
LAddRow( 1 , cell.v , (ListHandle)m_macList ) ;
cell.v = n ;
LSetSelect( select , cell , (ListHandle)m_macList ) ;
LAutoScroll( (ListHandle)m_macList ) ;
cell.v = n ;
LSetSelect( select , cell , (ListHandle)m_macList ) ;
LAutoScroll( (ListHandle)m_macList ) ;
while ( LGetSelect( true , &cell ,(ListHandle) m_macList ) )
{
aSelections.Add( cell.v ) ;
while ( LGetSelect( true , &cell ,(ListHandle) m_macList ) )
{
aSelections.Add( cell.v ) ;
::GetControlData( (ControlHandle) m_macControl , kControlNoPart , kControlListBoxDoubleClickTag , sizeof( wasDoubleClick ) , (char*) &wasDoubleClick , &result ) ;
if ( !wasDoubleClick )
{
::GetControlData( (ControlHandle) m_macControl , kControlNoPart , kControlListBoxDoubleClickTag , sizeof( wasDoubleClick ) , (char*) &wasDoubleClick , &result ) ;
if ( !wasDoubleClick )
{
void wxListBox::MacSetRedraw( bool doDraw )
{
LSetDrawingMode( doDraw , (ListHandle)m_macList ) ;
void wxListBox::MacSetRedraw( bool doDraw )
{
LSetDrawingMode( doDraw , (ListHandle)m_macList ) ;
wxCommandEvent event(wxEVT_COMMAND_LISTBOX_SELECTED, m_windowId);
event.SetEventObject( this );
wxCommandEvent event(wxEVT_COMMAND_LISTBOX_SELECTED, m_windowId);
event.SetEventObject( this );
{
wxCommandEvent event(wxEVT_COMMAND_LISTBOX_DOUBLECLICKED, m_windowId);
event.SetEventObject( this );
{
wxCommandEvent event(wxEVT_COMMAND_LISTBOX_DOUBLECLICKED, m_windowId);
event.SetEventObject( this );
- wxWindow* parent = GetParent() ;
- while( parent && !parent->IsTopLevel() && parent->GetDefaultItem() == NULL )
- parent = parent->GetParent() ;
-
- if ( parent && parent->GetDefaultItem() )
- {
- wxButton *def = wxDynamicCast(parent->GetDefaultItem(),
- wxButton);
- if ( def && def->IsEnabled() )
- {
- wxCommandEvent event(wxEVT_COMMAND_BUTTON_CLICKED, def->GetId() );
- event.SetEventObject(def);
- def->Command(event);
- return ;
- }
- }
- event.Skip() ;
+ wxWindow* parent = GetParent() ;
+ while( parent && !parent->IsTopLevel() && parent->GetDefaultItem() == NULL )
+ parent = parent->GetParent() ;
+
+ if ( parent && parent->GetDefaultItem() )
+ {
+ wxButton *def = wxDynamicCast(parent->GetDefaultItem(),
+ wxButton);
+ if ( def && def->IsEnabled() )
+ {
+ wxCommandEvent event(wxEVT_COMMAND_BUTTON_CLICKED, def->GetId() );
+ event.SetEventObject(def);
+ def->Command(event);
+ return ;
+ }
+ }
+ event.Skip() ;
wxCommandEvent new_event(wxEVT_COMMAND_BUTTON_CLICKED,wxID_CANCEL);
new_event.SetEventObject( win );
win->GetEventHandler()->ProcessEvent( new_event );
}
wxCommandEvent new_event(wxEVT_COMMAND_BUTTON_CLICKED,wxID_CANCEL);
new_event.SetEventObject( win );
win->GetEventHandler()->ProcessEvent( new_event );
}
new_event.SetWindowChange( event.ControlDown() );
new_event.SetCurrentFocus( this );
if ( !GetEventHandler()->ProcessEvent( new_event ) )
new_event.SetWindowChange( event.ControlDown() );
new_event.SetCurrentFocus( this );
if ( !GetEventHandler()->ProcessEvent( new_event ) )
- else if ( event.KeyCode() == WXK_DOWN || event.KeyCode() == WXK_UP )
- {
- // perform the default key handling first
- wxControl::OnKeyDown( event ) ;
-
+ else if ( event.GetKeyCode() == WXK_DOWN || event.GetKeyCode() == WXK_UP )
+ {
+ // perform the default key handling first
+ wxControl::OnKeyDown( event ) ;
+
wxCommandEvent event(wxEVT_COMMAND_LISTBOX_SELECTED, m_windowId);
event.SetEventObject( this );
wxCommandEvent event(wxEVT_COMMAND_LISTBOX_SELECTED, m_windowId);
event.SetEventObject( this );
- n = aSelections[0];
- if ( HasClientObjectData() )
- event.SetClientObject( GetClientObject(n) );
- else if ( HasClientUntypedData() )
- event.SetClientData( GetClientData(n) );
- event.SetString( GetString(n) );
+ n = aSelections[0];
+ if ( HasClientObjectData() )
+ event.SetClientObject( GetClientObject(n) );
+ else if ( HasClientUntypedData() )
+ event.SetClientData( GetClientData(n) );
+ event.SetString( GetString(n) );
- }
- else
- {
- if ( event.GetTimestamp() > m_lastTypeIn + 60 )
- {
- m_typeIn = "" ;
- }
- m_lastTypeIn = event.GetTimestamp() ;
- m_typeIn += (char) event.KeyCode() ;
- int line = FindString("*"+m_typeIn+"*") ;
- if ( line >= 0 )
- {
- if ( GetSelection() != line )
- {
- SetSelection(line) ;
- wxCommandEvent event(wxEVT_COMMAND_LISTBOX_SELECTED, m_windowId);
- event.SetEventObject( this );
-
- if ( HasClientObjectData() )
- event.SetClientObject( GetClientObject( line ) );
- else if ( HasClientUntypedData() )
- event.SetClientData( GetClientData(line) );
- event.SetString( GetString(line) );
-
- event.m_commandInt = line ;
-
- GetEventHandler()->ProcessEvent(event);
- }
- }
- }
+ }
+ else
+ {
+ if ( event.GetTimestamp() > m_lastTypeIn + 60 )
+ {
+ m_typeIn = "" ;
+ }
+ m_lastTypeIn = event.GetTimestamp() ;
+ m_typeIn += (char) event.GetKeyCode() ;
+ int line = FindString("*"+m_typeIn+"*") ;
+ if ( line >= 0 )
+ {
+ if ( GetSelection() != line )
+ {
+ SetSelection(line) ;
+ wxCommandEvent event(wxEVT_COMMAND_LISTBOX_SELECTED, m_windowId);
+ event.SetEventObject( this );
+
+ if ( HasClientObjectData() )
+ event.SetClientObject( GetClientObject( line ) );
+ else if ( HasClientUntypedData() )
+ event.SetClientData( GetClientData(line) );
+ event.SetString( GetString(line) );
+
+ event.m_commandInt = line ;
+
+ GetEventHandler()->ProcessEvent(event);
+ }
+ }
+ }