The code in wxMac's listbox was too ambitious in filtering
out surplus events.s git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@12851 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -28,7 +28,7 @@
|
|||||||
IMPLEMENT_DYNAMIC_CLASS(wxListBox, wxControl)
|
IMPLEMENT_DYNAMIC_CLASS(wxListBox, wxControl)
|
||||||
|
|
||||||
BEGIN_EVENT_TABLE(wxListBox, wxControl)
|
BEGIN_EVENT_TABLE(wxListBox, wxControl)
|
||||||
EVT_SIZE( wxListBox::OnSize )
|
EVT_SIZE( wxListBox::OnSize )
|
||||||
END_EVENT_TABLE()
|
END_EVENT_TABLE()
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -43,85 +43,85 @@ typedef struct {
|
|||||||
extern "C"
|
extern "C"
|
||||||
{
|
{
|
||||||
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,
|
Cell cell, short dataOffset, short dataLength,
|
||||||
ListHandle listHandle ) ;
|
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,
|
Cell cell, short dataOffset, short dataLength,
|
||||||
ListHandle listHandle )
|
ListHandle listHandle )
|
||||||
{
|
{
|
||||||
FontInfo fontInfo;
|
FontInfo fontInfo;
|
||||||
GrafPtr savePort;
|
GrafPtr savePort;
|
||||||
GrafPtr grafPtr;
|
GrafPtr grafPtr;
|
||||||
RgnHandle savedClipRegion;
|
RgnHandle savedClipRegion;
|
||||||
SInt32 savedPenMode;
|
SInt32 savedPenMode;
|
||||||
wxListBox* list;
|
wxListBox* list;
|
||||||
GetPort(&savePort);
|
GetPort(&savePort);
|
||||||
SetPort((**listHandle).port);
|
SetPort((**listHandle).port);
|
||||||
grafPtr = (**listHandle).port ;
|
grafPtr = (**listHandle).port ;
|
||||||
// typecast our refCon
|
// typecast our refCon
|
||||||
list = (wxListBox*) GetControlReference( (ControlHandle) GetListRefCon(listHandle) );
|
list = (wxListBox*) GetControlReference( (ControlHandle) GetListRefCon(listHandle) );
|
||||||
|
|
||||||
// Calculate the cell rect.
|
// Calculate the cell rect.
|
||||||
|
|
||||||
switch( message ) {
|
switch( message ) {
|
||||||
case lInitMsg:
|
case lInitMsg:
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case lCloseMsg:
|
case lCloseMsg:
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case lDrawMsg:
|
case lDrawMsg:
|
||||||
{
|
{
|
||||||
const wxString text = list->m_stringArray[cell.v] ;
|
const wxString text = list->m_stringArray[cell.v] ;
|
||||||
|
|
||||||
// Save the current clip region, and set the clip region to the area we are about
|
// Save the current clip region, and set the clip region to the area we are about
|
||||||
// to draw.
|
// to draw.
|
||||||
|
|
||||||
savedClipRegion = NewRgn();
|
savedClipRegion = NewRgn();
|
||||||
GetClip( savedClipRegion );
|
GetClip( savedClipRegion );
|
||||||
|
|
||||||
ClipRect( drawRect );
|
ClipRect( drawRect );
|
||||||
EraseRect( drawRect );
|
EraseRect( drawRect );
|
||||||
|
|
||||||
MoveTo(drawRect->left + 4 , drawRect->top + 10 );
|
MoveTo(drawRect->left + 4 , drawRect->top + 10 );
|
||||||
::TextFont( kFontIDMonaco ) ;
|
::TextFont( kFontIDMonaco ) ;
|
||||||
::TextSize( 9 );
|
::TextSize( 9 );
|
||||||
::TextFace( 0 ) ;
|
::TextFace( 0 ) ;
|
||||||
|
|
||||||
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
|
// If the cell is hilited, do the hilite now. Paint the cell contents with the
|
||||||
// appropriate QuickDraw transform mode.
|
// appropriate QuickDraw transform mode.
|
||||||
|
|
||||||
if( isSelected ) {
|
if( isSelected ) {
|
||||||
savedPenMode = GetPortPenMode( grafPtr );
|
savedPenMode = GetPortPenMode( grafPtr );
|
||||||
SetPortPenMode( grafPtr, hilitetransfermode );
|
SetPortPenMode( grafPtr, hilitetransfermode );
|
||||||
PaintRect( drawRect );
|
PaintRect( drawRect );
|
||||||
SetPortPenMode( grafPtr, savedPenMode );
|
SetPortPenMode( grafPtr, savedPenMode );
|
||||||
}
|
}
|
||||||
|
|
||||||
// Restore the saved clip region.
|
// Restore the saved clip region.
|
||||||
|
|
||||||
SetClip( savedClipRegion );
|
SetClip( savedClipRegion );
|
||||||
DisposeRgn( savedClipRegion );
|
DisposeRgn( savedClipRegion );
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case lHiliteMsg:
|
case lHiliteMsg:
|
||||||
|
|
||||||
// Hilite or unhilite the cell. Paint the cell contents with the
|
// Hilite or unhilite the cell. Paint the cell contents with the
|
||||||
// appropriate QuickDraw transform mode.
|
// appropriate QuickDraw transform mode.
|
||||||
|
|
||||||
GetPort( &grafPtr );
|
GetPort( &grafPtr );
|
||||||
savedPenMode = GetPortPenMode( grafPtr );
|
savedPenMode = GetPortPenMode( grafPtr );
|
||||||
SetPortPenMode( grafPtr, hilitetransfermode );
|
SetPortPenMode( grafPtr, hilitetransfermode );
|
||||||
PaintRect( drawRect );
|
PaintRect( drawRect );
|
||||||
SetPortPenMode( grafPtr, savedPenMode );
|
SetPortPenMode( grafPtr, savedPenMode );
|
||||||
break;
|
break;
|
||||||
default :
|
default :
|
||||||
break ;
|
break ;
|
||||||
}
|
}
|
||||||
SetPort(savePort);
|
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) ;
|
||||||
@@ -163,7 +163,7 @@ bool wxListBox::Create(wxWindow *parent, wxWindowID id,
|
|||||||
{
|
{
|
||||||
macListDefUPP = NewListDefUPP( wxMacListDefinition );
|
macListDefUPP = NewListDefUPP( wxMacListDefinition );
|
||||||
}
|
}
|
||||||
listDef.u.userProc = macListDefUPP ;
|
listDef.u.userProc = macListDefUPP ;
|
||||||
#if TARGET_CARBON
|
#if TARGET_CARBON
|
||||||
Size asize;
|
Size asize;
|
||||||
|
|
||||||
@@ -178,13 +178,13 @@ bool wxListBox::Create(wxWindow *parent, wxWindowID id,
|
|||||||
SetControlVisibility(m_macControl, false, false);
|
SetControlVisibility(m_macControl, false, false);
|
||||||
|
|
||||||
#else
|
#else
|
||||||
long result ;
|
long result ;
|
||||||
|
|
||||||
m_macControl = ::NewControl( parent->GetMacRootWindow() , &bounds , title , false ,
|
m_macControl = ::NewControl( parent->GetMacRootWindow() , &bounds , title , false ,
|
||||||
kwxMacListWithVerticalScrollbar , 0 , 0,
|
kwxMacListWithVerticalScrollbar , 0 , 0,
|
||||||
kControlListBoxProc , (long) this ) ;
|
kControlListBoxProc , (long) this ) ;
|
||||||
::GetControlData( m_macControl , kControlNoPart , kControlListBoxListHandleTag ,
|
::GetControlData( m_macControl , kControlNoPart , kControlListBoxListHandleTag ,
|
||||||
sizeof( ListHandle ) , (char*) &m_macList , &result ) ;
|
sizeof( ListHandle ) , (char*) &m_macList , &result ) ;
|
||||||
|
|
||||||
HLock( (Handle) m_macList ) ;
|
HLock( (Handle) m_macList ) ;
|
||||||
ldefHandle ldef ;
|
ldefHandle ldef ;
|
||||||
@@ -221,7 +221,7 @@ bool wxListBox::Create(wxWindow *parent, wxWindowID id,
|
|||||||
|
|
||||||
for ( int i = 0 ; i < n ; i++ )
|
for ( int i = 0 ; i < n ; i++ )
|
||||||
{
|
{
|
||||||
Append( choices[i] ) ;
|
Append( choices[i] ) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
LSetDrawingMode( true , m_macList ) ;
|
LSetDrawingMode( true , m_macList ) ;
|
||||||
@@ -231,15 +231,15 @@ bool wxListBox::Create(wxWindow *parent, wxWindowID id,
|
|||||||
|
|
||||||
wxListBox::~wxListBox()
|
wxListBox::~wxListBox()
|
||||||
{
|
{
|
||||||
Free() ;
|
Free() ;
|
||||||
if ( m_macList )
|
if ( m_macList )
|
||||||
{
|
{
|
||||||
#if !TARGET_CARBON
|
#if !TARGET_CARBON
|
||||||
DisposeHandle( (**m_macList).listDefProc ) ;
|
DisposeHandle( (**m_macList).listDefProc ) ;
|
||||||
(**m_macList).listDefProc = NULL ;
|
(**m_macList).listDefProc = NULL ;
|
||||||
#endif
|
#endif
|
||||||
m_macList = NULL ;
|
m_macList = NULL ;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxListBox::Free()
|
void wxListBox::Free()
|
||||||
@@ -269,26 +269,26 @@ void wxListBox::DoSetSize(int x, int y,
|
|||||||
int width, int height,
|
int width, int height,
|
||||||
int sizeFlags )
|
int sizeFlags )
|
||||||
{
|
{
|
||||||
wxControl::DoSetSize( x , y , width , height , sizeFlags ) ;
|
wxControl::DoSetSize( x , y , width , height , sizeFlags ) ;
|
||||||
#if TARGET_CARBON
|
#if TARGET_CARBON
|
||||||
Rect bounds ;
|
Rect bounds ;
|
||||||
GetControlBounds( m_macControl , &bounds ) ;
|
GetControlBounds( m_macControl , &bounds ) ;
|
||||||
ControlRef control = GetListVerticalScrollBar( m_macList ) ;
|
ControlRef control = GetListVerticalScrollBar( m_macList ) ;
|
||||||
if ( control )
|
if ( control )
|
||||||
{
|
{
|
||||||
Rect scrollbounds ;
|
Rect scrollbounds ;
|
||||||
GetControlBounds( control , &scrollbounds ) ;
|
GetControlBounds( control , &scrollbounds ) ;
|
||||||
if( scrollbounds.right != bounds.right + 1 )
|
if( scrollbounds.right != bounds.right + 1 )
|
||||||
{
|
{
|
||||||
UMAMoveControl( control , bounds.right - (scrollbounds.right - scrollbounds.left) + 1 ,
|
UMAMoveControl( control , bounds.right - (scrollbounds.right - scrollbounds.left) + 1 ,
|
||||||
scrollbounds.top ) ;
|
scrollbounds.top ) ;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
void wxListBox::DoSetFirstItem(int N)
|
void wxListBox::DoSetFirstItem(int N)
|
||||||
{
|
{
|
||||||
MacScrollTo( N ) ;
|
MacScrollTo( N ) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxListBox::Delete(int N)
|
void wxListBox::Delete(int N)
|
||||||
@@ -305,30 +305,30 @@ void wxListBox::Delete(int N)
|
|||||||
delete GetClientObject(N);
|
delete GetClientObject(N);
|
||||||
}
|
}
|
||||||
#endif // wxUSE_OWNER_DRAWN/!wxUSE_OWNER_DRAWN
|
#endif // wxUSE_OWNER_DRAWN/!wxUSE_OWNER_DRAWN
|
||||||
m_stringArray.Remove( N ) ;
|
m_stringArray.Remove( N ) ;
|
||||||
m_dataArray.RemoveAt( N ) ;
|
m_dataArray.RemoveAt( N ) ;
|
||||||
m_noItems --;
|
m_noItems --;
|
||||||
|
|
||||||
MacDelete( N ) ;
|
MacDelete( N ) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
int wxListBox::DoAppend(const wxString& item)
|
int wxListBox::DoAppend(const wxString& item)
|
||||||
{
|
{
|
||||||
int index = m_noItems ;
|
int index = m_noItems ;
|
||||||
if( wxApp::s_macDefaultEncodingIsPC )
|
if( wxApp::s_macDefaultEncodingIsPC )
|
||||||
{
|
{
|
||||||
m_stringArray.Add( wxMacMakeMacStringFromPC( item ) ) ;
|
m_stringArray.Add( wxMacMakeMacStringFromPC( item ) ) ;
|
||||||
m_dataArray.Add( NULL );
|
m_dataArray.Add( NULL );
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
m_stringArray.Add( item ) ;
|
m_stringArray.Add( item ) ;
|
||||||
m_dataArray.Add( NULL );
|
m_dataArray.Add( NULL );
|
||||||
}
|
}
|
||||||
m_noItems ++;
|
m_noItems ++;
|
||||||
DoSetItemClientData( index , NULL ) ;
|
DoSetItemClientData( index , NULL ) ;
|
||||||
MacAppend( item ) ;
|
MacAppend( item ) ;
|
||||||
|
|
||||||
return index ;
|
return index ;
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxListBox::DoSetItems(const wxArrayString& choices, void** clientData)
|
void wxListBox::DoSetItems(const wxArrayString& choices, void** clientData)
|
||||||
@@ -339,17 +339,17 @@ void wxListBox::DoSetItems(const wxArrayString& choices, void** clientData)
|
|||||||
|
|
||||||
for( int i = 0 ; i < n ; ++i )
|
for( int i = 0 ; i < n ; ++i )
|
||||||
{
|
{
|
||||||
if ( clientData )
|
if ( 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("Can't use client data with owner-drawn listboxes"));
|
||||||
#else // !wxUSE_OWNER_DRAWN
|
#else // !wxUSE_OWNER_DRAWN
|
||||||
Append( choices[i] , clientData[i] ) ;
|
Append( choices[i] , clientData[i] ) ;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
Append( choices[i] ) ;
|
Append( choices[i] ) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if wxUSE_OWNER_DRAWN
|
#if wxUSE_OWNER_DRAWN
|
||||||
@@ -379,71 +379,71 @@ bool wxListBox::HasMultipleSelection() const
|
|||||||
|
|
||||||
int wxListBox::FindString(const wxString& st) const
|
int wxListBox::FindString(const wxString& st) const
|
||||||
{
|
{
|
||||||
wxString s ;
|
wxString s ;
|
||||||
if( wxApp::s_macDefaultEncodingIsPC )
|
if( wxApp::s_macDefaultEncodingIsPC )
|
||||||
{
|
{
|
||||||
s = wxMacMakeMacStringFromPC( st ) ;
|
s = wxMacMakeMacStringFromPC( st ) ;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
s = st ;
|
s = st ;
|
||||||
|
|
||||||
if ( s.Right(1) == "*" )
|
if ( s.Right(1) == "*" )
|
||||||
{
|
{
|
||||||
wxString search = s.Left( s.Length() - 1 ) ;
|
wxString search = s.Left( s.Length() - 1 ) ;
|
||||||
int len = search.Length() ;
|
int len = search.Length() ;
|
||||||
Str255 s1 , s2 ;
|
Str255 s1 , s2 ;
|
||||||
|
|
||||||
#if TARGET_CARBON
|
#if TARGET_CARBON
|
||||||
c2pstrcpy( (StringPtr) s2 , search.c_str() ) ;
|
c2pstrcpy( (StringPtr) s2 , search.c_str() ) ;
|
||||||
#else
|
#else
|
||||||
strcpy( (char *) s2 , search.c_str() ) ;
|
strcpy( (char *) s2 , search.c_str() ) ;
|
||||||
c2pstr( (char *) s2 ) ;
|
c2pstr( (char *) s2 ) ;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
for ( int i = 0 ; i < m_noItems ; ++ i )
|
for ( int i = 0 ; i < m_noItems ; ++ i )
|
||||||
{
|
{
|
||||||
#if TARGET_CARBON
|
#if TARGET_CARBON
|
||||||
c2pstrcpy( (StringPtr) s1 , m_stringArray[i].Left( len ).c_str() ) ;
|
c2pstrcpy( (StringPtr) s1 , m_stringArray[i].Left( len ).c_str() ) ;
|
||||||
#else
|
#else
|
||||||
strcpy( (char *) s1 , m_stringArray[i].Left( len ).c_str() ) ;
|
strcpy( (char *) s1 , m_stringArray[i].Left( len ).c_str() ) ;
|
||||||
c2pstr( (char *) s1 ) ;
|
c2pstr( (char *) s1 ) ;
|
||||||
#endif
|
#endif
|
||||||
if ( EqualString( s1 , s2 , false , false ) )
|
if ( EqualString( s1 , s2 , false , false ) )
|
||||||
return i ;
|
return i ;
|
||||||
}
|
}
|
||||||
if ( s.Left(1) == "*" && s.Length() > 1 )
|
if ( s.Left(1) == "*" && s.Length() > 1 )
|
||||||
{
|
{
|
||||||
s.MakeLower() ;
|
s.MakeLower() ;
|
||||||
for ( int i = 0 ; i < m_noItems ; ++i )
|
for ( int i = 0 ; i < m_noItems ; ++i )
|
||||||
{
|
{
|
||||||
if ( GetString(i).Lower().Matches(s) )
|
if ( GetString(i).Lower().Matches(s) )
|
||||||
return i ;
|
return i ;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Str255 s1 , s2 ;
|
Str255 s1 , s2 ;
|
||||||
|
|
||||||
#if TARGET_CARBON
|
#if TARGET_CARBON
|
||||||
c2pstrcpy( (StringPtr) s2 , s.c_str() ) ;
|
c2pstrcpy( (StringPtr) s2 , s.c_str() ) ;
|
||||||
#else
|
#else
|
||||||
strcpy( (char *) s2 , s.c_str() ) ;
|
strcpy( (char *) s2 , s.c_str() ) ;
|
||||||
c2pstr( (char *) s2 ) ;
|
c2pstr( (char *) s2 ) ;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
for ( int i = 0 ; i < m_noItems ; ++ i )
|
for ( int i = 0 ; i < m_noItems ; ++ i )
|
||||||
{
|
{
|
||||||
#if TARGET_CARBON
|
#if TARGET_CARBON
|
||||||
c2pstrcpy( (StringPtr) s1 , m_stringArray[i].c_str() ) ;
|
c2pstrcpy( (StringPtr) s1 , m_stringArray[i].c_str() ) ;
|
||||||
#else
|
#else
|
||||||
strcpy( (char *) s1 , m_stringArray[i].c_str() ) ;
|
strcpy( (char *) s1 , m_stringArray[i].c_str() ) ;
|
||||||
c2pstr( (char *) s1 ) ;
|
c2pstr( (char *) s1 ) ;
|
||||||
#endif
|
#endif
|
||||||
if ( EqualString( s1 , s2 , false , false ) )
|
if ( EqualString( s1 , s2 , false , false ) )
|
||||||
return i ;
|
return i ;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@@ -461,8 +461,8 @@ void wxListBox::SetSelection(int N, bool select)
|
|||||||
{
|
{
|
||||||
wxCHECK_RET( N >= 0 && N < m_noItems,
|
wxCHECK_RET( N >= 0 && N < m_noItems,
|
||||||
"invalid index in wxListBox::SetSelection" );
|
"invalid index in wxListBox::SetSelection" );
|
||||||
MacSetSelection( N , select ) ;
|
MacSetSelection( N , select ) ;
|
||||||
GetSelections( m_selectionPreImage ) ;
|
GetSelections( m_selectionPreImage ) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxListBox::IsSelected(int N) const
|
bool wxListBox::IsSelected(int N) const
|
||||||
@@ -470,7 +470,7 @@ bool wxListBox::IsSelected(int N) const
|
|||||||
wxCHECK_MSG( N >= 0 && N < m_noItems, FALSE,
|
wxCHECK_MSG( N >= 0 && N < m_noItems, FALSE,
|
||||||
"invalid index in wxListBox::Selected" );
|
"invalid index in wxListBox::Selected" );
|
||||||
|
|
||||||
return MacIsSelected( N ) ;
|
return MacIsSelected( N ) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
void *wxListBox::DoGetItemClientData(int N) const
|
void *wxListBox::DoGetItemClientData(int N) const
|
||||||
@@ -483,7 +483,7 @@ void *wxListBox::DoGetItemClientData(int N) const
|
|||||||
|
|
||||||
wxClientData *wxListBox::DoGetItemClientObject(int N) const
|
wxClientData *wxListBox::DoGetItemClientObject(int N) const
|
||||||
{
|
{
|
||||||
return (wxClientData *) DoGetItemClientData( N ) ;
|
return (wxClientData *) DoGetItemClientData( N ) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxListBox::DoSetItemClientData(int N, void *Client_data)
|
void wxListBox::DoSetItemClientData(int N, void *Client_data)
|
||||||
@@ -499,15 +499,15 @@ void wxListBox::DoSetItemClientData(int N, void *Client_data)
|
|||||||
wxFAIL_MSG(wxT("Can't use client data with owner-drawn listboxes"));
|
wxFAIL_MSG(wxT("Can't use client data with owner-drawn listboxes"));
|
||||||
}
|
}
|
||||||
#endif // wxUSE_OWNER_DRAWN
|
#endif // wxUSE_OWNER_DRAWN
|
||||||
wxASSERT_MSG( m_dataArray.GetCount() >= N , "invalid client_data array" ) ;
|
wxASSERT_MSG( m_dataArray.GetCount() >= N , "invalid client_data array" ) ;
|
||||||
|
|
||||||
if ( m_dataArray.GetCount() > N )
|
if ( m_dataArray.GetCount() > N )
|
||||||
{
|
{
|
||||||
m_dataArray[N] = (char*) Client_data ;
|
m_dataArray[N] = (char*) Client_data ;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
m_dataArray.Add( (char*) Client_data ) ;
|
m_dataArray.Add( (char*) Client_data ) ;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -519,24 +519,24 @@ void wxListBox::DoSetItemClientObject(int n, wxClientData* clientData)
|
|||||||
// Return number of selections and an array of selected integers
|
// Return number of selections and an array of selected integers
|
||||||
int wxListBox::GetSelections(wxArrayInt& aSelections) const
|
int wxListBox::GetSelections(wxArrayInt& aSelections) const
|
||||||
{
|
{
|
||||||
return MacGetSelections( aSelections ) ;
|
return MacGetSelections( aSelections ) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get single selection, for single choice list items
|
// Get single selection, for single choice list items
|
||||||
int wxListBox::GetSelection() const
|
int wxListBox::GetSelection() const
|
||||||
{
|
{
|
||||||
return MacGetSelection() ;
|
return MacGetSelection() ;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Find string for position
|
// Find string for position
|
||||||
wxString wxListBox::GetString(int N) const
|
wxString wxListBox::GetString(int N) const
|
||||||
{
|
{
|
||||||
if( wxApp::s_macDefaultEncodingIsPC )
|
if( wxApp::s_macDefaultEncodingIsPC )
|
||||||
{
|
{
|
||||||
return wxMacMakePCStringFromMac( m_stringArray[N] ) ;
|
return wxMacMakePCStringFromMac( m_stringArray[N] ) ;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
return m_stringArray[N] ;
|
return m_stringArray[N] ;
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxListBox::DoInsertItems(const wxArrayString& items, int pos)
|
void wxListBox::DoInsertItems(const wxArrayString& items, int pos)
|
||||||
@@ -546,27 +546,27 @@ void wxListBox::DoInsertItems(const wxArrayString& items, int pos)
|
|||||||
|
|
||||||
int nItems = items.GetCount();
|
int nItems = items.GetCount();
|
||||||
|
|
||||||
for ( int i = 0 ; i < nItems ; i++ )
|
for ( int i = 0 ; i < nItems ; i++ )
|
||||||
{
|
{
|
||||||
m_stringArray.Insert( items[i] , pos + i ) ;
|
m_stringArray.Insert( items[i] , pos + i ) ;
|
||||||
m_dataArray.Insert( NULL , pos + i ) ;
|
m_dataArray.Insert( NULL , pos + i ) ;
|
||||||
MacInsert( pos + i , items[i] ) ;
|
MacInsert( pos + i , items[i] ) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_noItems += nItems;
|
m_noItems += nItems;
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxListBox::SetString(int N, const wxString& s)
|
void wxListBox::SetString(int N, const wxString& s)
|
||||||
{
|
{
|
||||||
wxString str ;
|
wxString str ;
|
||||||
if( wxApp::s_macDefaultEncodingIsPC )
|
if( wxApp::s_macDefaultEncodingIsPC )
|
||||||
{
|
{
|
||||||
str = wxMacMakeMacStringFromPC( s ) ;
|
str = wxMacMakeMacStringFromPC( s ) ;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
str = s ;
|
str = s ;
|
||||||
m_stringArray[N] = str ;
|
m_stringArray[N] = str ;
|
||||||
MacSet( N , s ) ;
|
MacSet( N , s ) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxSize wxListBox::DoGetBestSize() const
|
wxSize wxListBox::DoGetBestSize() const
|
||||||
@@ -622,17 +622,17 @@ wxOwnerDrawn *wxListBox::CreateItem(size_t n)
|
|||||||
|
|
||||||
void MacDrawStringCell(Rect *cellRect, Cell lCell, ListHandle theList, long refCon)
|
void MacDrawStringCell(Rect *cellRect, Cell lCell, ListHandle theList, long refCon)
|
||||||
{
|
{
|
||||||
wxListBox* list;
|
wxListBox* list;
|
||||||
// typecast our refCon
|
// typecast our refCon
|
||||||
list = (wxListBox*)refCon;
|
list = (wxListBox*)refCon;
|
||||||
|
|
||||||
MoveTo(cellRect->left + 4 , cellRect->top + 10 );
|
MoveTo(cellRect->left + 4 , cellRect->top + 10 );
|
||||||
const wxString text = list->m_stringArray[lCell.v] ;
|
const wxString text = list->m_stringArray[lCell.v] ;
|
||||||
::TextFont( kFontIDMonaco ) ;
|
::TextFont( kFontIDMonaco ) ;
|
||||||
::TextSize( 9 );
|
::TextSize( 9 );
|
||||||
::TextFace( 0 ) ;
|
::TextFace( 0 ) ;
|
||||||
DrawText(text, 0 , text.Length());
|
DrawText(text, 0 , text.Length());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxListBox::MacDelete( int N )
|
void wxListBox::MacDelete( int N )
|
||||||
@@ -667,26 +667,26 @@ void wxListBox::MacClear()
|
|||||||
|
|
||||||
void wxListBox::MacSetSelection( int n , bool select )
|
void wxListBox::MacSetSelection( int n , bool select )
|
||||||
{
|
{
|
||||||
Cell cell = { 0 , 0 } ;
|
Cell cell = { 0 , 0 } ;
|
||||||
if ( ! (m_windowStyle & wxLB_MULTIPLE) )
|
if ( ! (m_windowStyle & wxLB_MULTIPLE) )
|
||||||
{
|
{
|
||||||
if ( LGetSelect( true , &cell , m_macList ) )
|
if ( LGetSelect( true , &cell , m_macList ) )
|
||||||
{
|
{
|
||||||
LSetSelect( false , cell , m_macList ) ;
|
LSetSelect( false , cell , m_macList ) ;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
cell.v = n ;
|
cell.v = n ;
|
||||||
LSetSelect( select , cell , m_macList ) ;
|
LSetSelect( select , cell , m_macList ) ;
|
||||||
LAutoScroll( m_macList ) ;
|
LAutoScroll( m_macList ) ;
|
||||||
Refresh();
|
Refresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxListBox::MacIsSelected( int n ) const
|
bool wxListBox::MacIsSelected( int n ) const
|
||||||
{
|
{
|
||||||
Cell cell = { 0 , 0 } ;
|
Cell cell = { 0 , 0 } ;
|
||||||
cell.v = n ;
|
cell.v = n ;
|
||||||
return LGetSelect( false , &cell , m_macList ) ;
|
return LGetSelect( false , &cell , m_macList ) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxListBox::MacDestroy()
|
void wxListBox::MacDestroy()
|
||||||
@@ -696,44 +696,44 @@ void wxListBox::MacDestroy()
|
|||||||
|
|
||||||
int wxListBox::MacGetSelection() const
|
int wxListBox::MacGetSelection() const
|
||||||
{
|
{
|
||||||
Cell cell = { 0 , 0 } ;
|
Cell cell = { 0 , 0 } ;
|
||||||
if ( LGetSelect( true , &cell , m_macList ) )
|
if ( LGetSelect( true , &cell , m_macList ) )
|
||||||
return cell.v ;
|
return cell.v ;
|
||||||
else
|
else
|
||||||
return -1 ;
|
return -1 ;
|
||||||
}
|
}
|
||||||
|
|
||||||
int wxListBox::MacGetSelections( wxArrayInt& aSelections ) const
|
int wxListBox::MacGetSelections( wxArrayInt& aSelections ) const
|
||||||
{
|
{
|
||||||
int no_sel = 0 ;
|
int no_sel = 0 ;
|
||||||
|
|
||||||
aSelections.Empty();
|
aSelections.Empty();
|
||||||
|
|
||||||
Cell cell = { 0 , 0 } ;
|
Cell cell = { 0 , 0 } ;
|
||||||
cell.v = 0 ;
|
cell.v = 0 ;
|
||||||
|
|
||||||
while ( LGetSelect( true , &cell , m_macList ) )
|
while ( LGetSelect( true , &cell , m_macList ) )
|
||||||
{
|
{
|
||||||
aSelections.Add( cell.v ) ;
|
aSelections.Add( cell.v ) ;
|
||||||
no_sel++ ;
|
no_sel++ ;
|
||||||
cell.v++ ;
|
cell.v++ ;
|
||||||
}
|
}
|
||||||
return no_sel ;
|
return no_sel ;
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxListBox::MacSet( int n , const char * text )
|
void wxListBox::MacSet( int n , const char * text )
|
||||||
{
|
{
|
||||||
// our implementation does not store anything in the list
|
// our implementation does not store anything in the list
|
||||||
// so we just have to redraw
|
// so we just have to redraw
|
||||||
Cell cell = { 0 , 0 } ;
|
Cell cell = { 0 , 0 } ;
|
||||||
cell.v = n ;
|
cell.v = n ;
|
||||||
// LSetCell(text, strlen(text), cell, m_macList);
|
// LSetCell(text, strlen(text), cell, m_macList);
|
||||||
Refresh();
|
Refresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxListBox::MacScrollTo( int n )
|
void wxListBox::MacScrollTo( int n )
|
||||||
{
|
{
|
||||||
// TODO implement scrolling
|
// TODO implement scrolling
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxListBox::OnSize( const wxSizeEvent &event)
|
void wxListBox::OnSize( const wxSizeEvent &event)
|
||||||
@@ -751,63 +751,67 @@ void wxListBox::OnSize( const wxSizeEvent &event)
|
|||||||
|
|
||||||
void wxListBox::MacHandleControlClick( ControlHandle control , SInt16 controlpart )
|
void wxListBox::MacHandleControlClick( ControlHandle control , SInt16 controlpart )
|
||||||
{
|
{
|
||||||
Boolean wasDoubleClick = false ;
|
Boolean wasDoubleClick = false ;
|
||||||
long result ;
|
long result ;
|
||||||
|
|
||||||
::GetControlData( m_macControl , kControlNoPart , kControlListBoxDoubleClickTag , sizeof( wasDoubleClick ) , (char*) &wasDoubleClick , &result ) ;
|
::GetControlData( m_macControl , kControlNoPart , kControlListBoxDoubleClickTag , sizeof( wasDoubleClick ) , (char*) &wasDoubleClick , &result ) ;
|
||||||
if ( !wasDoubleClick )
|
if ( !wasDoubleClick )
|
||||||
{
|
{
|
||||||
MacDoClick() ;
|
MacDoClick() ;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
MacDoDoubleClick() ;
|
MacDoDoubleClick() ;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxListBox::MacSetRedraw( bool doDraw )
|
void wxListBox::MacSetRedraw( bool doDraw )
|
||||||
{
|
{
|
||||||
LSetDrawingMode( doDraw , m_macList ) ;
|
LSetDrawingMode( doDraw , m_macList ) ;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxListBox::MacDoClick()
|
void wxListBox::MacDoClick()
|
||||||
{
|
{
|
||||||
wxArrayInt aSelections;
|
wxArrayInt aSelections;
|
||||||
int n, count = GetSelections(aSelections);
|
int n, count = GetSelections(aSelections);
|
||||||
|
|
||||||
if ( count == m_selectionPreImage.GetCount() )
|
if ( count == m_selectionPreImage.GetCount() )
|
||||||
{
|
{
|
||||||
bool hasChanged = false ;
|
bool hasChanged = false ;
|
||||||
for ( int i = 0 ; i < count ; ++i )
|
for ( int i = 0 ; i < count ; ++i )
|
||||||
{
|
{
|
||||||
if ( aSelections[i] != m_selectionPreImage[i] )
|
if ( aSelections[i] != m_selectionPreImage[i] )
|
||||||
{
|
{
|
||||||
hasChanged = true ;
|
hasChanged = true ;
|
||||||
break ;
|
break ;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ( !hasChanged )
|
if ( !hasChanged )
|
||||||
return ;
|
{
|
||||||
}
|
return ;
|
||||||
|
}
|
||||||
wxCommandEvent event(wxEVT_COMMAND_LISTBOX_SELECTED, m_windowId);
|
}
|
||||||
event.SetEventObject( this );
|
|
||||||
|
m_selectionPreImage = aSelections;
|
||||||
|
|
||||||
|
wxCommandEvent event(wxEVT_COMMAND_LISTBOX_SELECTED, m_windowId);
|
||||||
|
event.SetEventObject( this );
|
||||||
|
|
||||||
if ( count > 0 )
|
if ( count > 0 )
|
||||||
{
|
{
|
||||||
n = aSelections[0];
|
n = aSelections[0];
|
||||||
if ( HasClientObjectData() )
|
if ( HasClientObjectData() )
|
||||||
event.SetClientObject( GetClientObject(n) );
|
event.SetClientObject( GetClientObject(n) );
|
||||||
else if ( HasClientUntypedData() )
|
else if ( HasClientUntypedData() )
|
||||||
event.SetClientData( GetClientData(n) );
|
event.SetClientData( GetClientData(n) );
|
||||||
event.SetString( GetString(n) );
|
event.SetString( GetString(n) );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
n = -1;
|
n = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
event.m_commandInt = n;
|
event.m_commandInt = n;
|
||||||
|
|
||||||
GetEventHandler()->ProcessEvent(event);
|
GetEventHandler()->ProcessEvent(event);
|
||||||
@@ -817,5 +821,5 @@ void wxListBox::MacDoDoubleClick()
|
|||||||
{
|
{
|
||||||
wxCommandEvent event(wxEVT_COMMAND_LISTBOX_DOUBLECLICKED, m_windowId);
|
wxCommandEvent event(wxEVT_COMMAND_LISTBOX_DOUBLECLICKED, m_windowId);
|
||||||
event.SetEventObject( this );
|
event.SetEventObject( this );
|
||||||
GetEventHandler()->ProcessEvent(event) ;
|
GetEventHandler()->ProcessEvent(event) ;
|
||||||
}
|
}
|
||||||
|
@@ -28,7 +28,7 @@
|
|||||||
IMPLEMENT_DYNAMIC_CLASS(wxListBox, wxControl)
|
IMPLEMENT_DYNAMIC_CLASS(wxListBox, wxControl)
|
||||||
|
|
||||||
BEGIN_EVENT_TABLE(wxListBox, wxControl)
|
BEGIN_EVENT_TABLE(wxListBox, wxControl)
|
||||||
EVT_SIZE( wxListBox::OnSize )
|
EVT_SIZE( wxListBox::OnSize )
|
||||||
END_EVENT_TABLE()
|
END_EVENT_TABLE()
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -43,85 +43,85 @@ typedef struct {
|
|||||||
extern "C"
|
extern "C"
|
||||||
{
|
{
|
||||||
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,
|
Cell cell, short dataOffset, short dataLength,
|
||||||
ListHandle listHandle ) ;
|
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,
|
Cell cell, short dataOffset, short dataLength,
|
||||||
ListHandle listHandle )
|
ListHandle listHandle )
|
||||||
{
|
{
|
||||||
FontInfo fontInfo;
|
FontInfo fontInfo;
|
||||||
GrafPtr savePort;
|
GrafPtr savePort;
|
||||||
GrafPtr grafPtr;
|
GrafPtr grafPtr;
|
||||||
RgnHandle savedClipRegion;
|
RgnHandle savedClipRegion;
|
||||||
SInt32 savedPenMode;
|
SInt32 savedPenMode;
|
||||||
wxListBox* list;
|
wxListBox* list;
|
||||||
GetPort(&savePort);
|
GetPort(&savePort);
|
||||||
SetPort((**listHandle).port);
|
SetPort((**listHandle).port);
|
||||||
grafPtr = (**listHandle).port ;
|
grafPtr = (**listHandle).port ;
|
||||||
// typecast our refCon
|
// typecast our refCon
|
||||||
list = (wxListBox*) GetControlReference( (ControlHandle) GetListRefCon(listHandle) );
|
list = (wxListBox*) GetControlReference( (ControlHandle) GetListRefCon(listHandle) );
|
||||||
|
|
||||||
// Calculate the cell rect.
|
// Calculate the cell rect.
|
||||||
|
|
||||||
switch( message ) {
|
switch( message ) {
|
||||||
case lInitMsg:
|
case lInitMsg:
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case lCloseMsg:
|
case lCloseMsg:
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case lDrawMsg:
|
case lDrawMsg:
|
||||||
{
|
{
|
||||||
const wxString text = list->m_stringArray[cell.v] ;
|
const wxString text = list->m_stringArray[cell.v] ;
|
||||||
|
|
||||||
// Save the current clip region, and set the clip region to the area we are about
|
// Save the current clip region, and set the clip region to the area we are about
|
||||||
// to draw.
|
// to draw.
|
||||||
|
|
||||||
savedClipRegion = NewRgn();
|
savedClipRegion = NewRgn();
|
||||||
GetClip( savedClipRegion );
|
GetClip( savedClipRegion );
|
||||||
|
|
||||||
ClipRect( drawRect );
|
ClipRect( drawRect );
|
||||||
EraseRect( drawRect );
|
EraseRect( drawRect );
|
||||||
|
|
||||||
MoveTo(drawRect->left + 4 , drawRect->top + 10 );
|
MoveTo(drawRect->left + 4 , drawRect->top + 10 );
|
||||||
::TextFont( kFontIDMonaco ) ;
|
::TextFont( kFontIDMonaco ) ;
|
||||||
::TextSize( 9 );
|
::TextSize( 9 );
|
||||||
::TextFace( 0 ) ;
|
::TextFace( 0 ) ;
|
||||||
|
|
||||||
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
|
// If the cell is hilited, do the hilite now. Paint the cell contents with the
|
||||||
// appropriate QuickDraw transform mode.
|
// appropriate QuickDraw transform mode.
|
||||||
|
|
||||||
if( isSelected ) {
|
if( isSelected ) {
|
||||||
savedPenMode = GetPortPenMode( grafPtr );
|
savedPenMode = GetPortPenMode( grafPtr );
|
||||||
SetPortPenMode( grafPtr, hilitetransfermode );
|
SetPortPenMode( grafPtr, hilitetransfermode );
|
||||||
PaintRect( drawRect );
|
PaintRect( drawRect );
|
||||||
SetPortPenMode( grafPtr, savedPenMode );
|
SetPortPenMode( grafPtr, savedPenMode );
|
||||||
}
|
}
|
||||||
|
|
||||||
// Restore the saved clip region.
|
// Restore the saved clip region.
|
||||||
|
|
||||||
SetClip( savedClipRegion );
|
SetClip( savedClipRegion );
|
||||||
DisposeRgn( savedClipRegion );
|
DisposeRgn( savedClipRegion );
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case lHiliteMsg:
|
case lHiliteMsg:
|
||||||
|
|
||||||
// Hilite or unhilite the cell. Paint the cell contents with the
|
// Hilite or unhilite the cell. Paint the cell contents with the
|
||||||
// appropriate QuickDraw transform mode.
|
// appropriate QuickDraw transform mode.
|
||||||
|
|
||||||
GetPort( &grafPtr );
|
GetPort( &grafPtr );
|
||||||
savedPenMode = GetPortPenMode( grafPtr );
|
savedPenMode = GetPortPenMode( grafPtr );
|
||||||
SetPortPenMode( grafPtr, hilitetransfermode );
|
SetPortPenMode( grafPtr, hilitetransfermode );
|
||||||
PaintRect( drawRect );
|
PaintRect( drawRect );
|
||||||
SetPortPenMode( grafPtr, savedPenMode );
|
SetPortPenMode( grafPtr, savedPenMode );
|
||||||
break;
|
break;
|
||||||
default :
|
default :
|
||||||
break ;
|
break ;
|
||||||
}
|
}
|
||||||
SetPort(savePort);
|
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) ;
|
||||||
@@ -163,7 +163,7 @@ bool wxListBox::Create(wxWindow *parent, wxWindowID id,
|
|||||||
{
|
{
|
||||||
macListDefUPP = NewListDefUPP( wxMacListDefinition );
|
macListDefUPP = NewListDefUPP( wxMacListDefinition );
|
||||||
}
|
}
|
||||||
listDef.u.userProc = macListDefUPP ;
|
listDef.u.userProc = macListDefUPP ;
|
||||||
#if TARGET_CARBON
|
#if TARGET_CARBON
|
||||||
Size asize;
|
Size asize;
|
||||||
|
|
||||||
@@ -178,13 +178,13 @@ bool wxListBox::Create(wxWindow *parent, wxWindowID id,
|
|||||||
SetControlVisibility(m_macControl, false, false);
|
SetControlVisibility(m_macControl, false, false);
|
||||||
|
|
||||||
#else
|
#else
|
||||||
long result ;
|
long result ;
|
||||||
|
|
||||||
m_macControl = ::NewControl( parent->GetMacRootWindow() , &bounds , title , false ,
|
m_macControl = ::NewControl( parent->GetMacRootWindow() , &bounds , title , false ,
|
||||||
kwxMacListWithVerticalScrollbar , 0 , 0,
|
kwxMacListWithVerticalScrollbar , 0 , 0,
|
||||||
kControlListBoxProc , (long) this ) ;
|
kControlListBoxProc , (long) this ) ;
|
||||||
::GetControlData( m_macControl , kControlNoPart , kControlListBoxListHandleTag ,
|
::GetControlData( m_macControl , kControlNoPart , kControlListBoxListHandleTag ,
|
||||||
sizeof( ListHandle ) , (char*) &m_macList , &result ) ;
|
sizeof( ListHandle ) , (char*) &m_macList , &result ) ;
|
||||||
|
|
||||||
HLock( (Handle) m_macList ) ;
|
HLock( (Handle) m_macList ) ;
|
||||||
ldefHandle ldef ;
|
ldefHandle ldef ;
|
||||||
@@ -221,7 +221,7 @@ bool wxListBox::Create(wxWindow *parent, wxWindowID id,
|
|||||||
|
|
||||||
for ( int i = 0 ; i < n ; i++ )
|
for ( int i = 0 ; i < n ; i++ )
|
||||||
{
|
{
|
||||||
Append( choices[i] ) ;
|
Append( choices[i] ) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
LSetDrawingMode( true , m_macList ) ;
|
LSetDrawingMode( true , m_macList ) ;
|
||||||
@@ -231,15 +231,15 @@ bool wxListBox::Create(wxWindow *parent, wxWindowID id,
|
|||||||
|
|
||||||
wxListBox::~wxListBox()
|
wxListBox::~wxListBox()
|
||||||
{
|
{
|
||||||
Free() ;
|
Free() ;
|
||||||
if ( m_macList )
|
if ( m_macList )
|
||||||
{
|
{
|
||||||
#if !TARGET_CARBON
|
#if !TARGET_CARBON
|
||||||
DisposeHandle( (**m_macList).listDefProc ) ;
|
DisposeHandle( (**m_macList).listDefProc ) ;
|
||||||
(**m_macList).listDefProc = NULL ;
|
(**m_macList).listDefProc = NULL ;
|
||||||
#endif
|
#endif
|
||||||
m_macList = NULL ;
|
m_macList = NULL ;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxListBox::Free()
|
void wxListBox::Free()
|
||||||
@@ -269,26 +269,26 @@ void wxListBox::DoSetSize(int x, int y,
|
|||||||
int width, int height,
|
int width, int height,
|
||||||
int sizeFlags )
|
int sizeFlags )
|
||||||
{
|
{
|
||||||
wxControl::DoSetSize( x , y , width , height , sizeFlags ) ;
|
wxControl::DoSetSize( x , y , width , height , sizeFlags ) ;
|
||||||
#if TARGET_CARBON
|
#if TARGET_CARBON
|
||||||
Rect bounds ;
|
Rect bounds ;
|
||||||
GetControlBounds( m_macControl , &bounds ) ;
|
GetControlBounds( m_macControl , &bounds ) ;
|
||||||
ControlRef control = GetListVerticalScrollBar( m_macList ) ;
|
ControlRef control = GetListVerticalScrollBar( m_macList ) ;
|
||||||
if ( control )
|
if ( control )
|
||||||
{
|
{
|
||||||
Rect scrollbounds ;
|
Rect scrollbounds ;
|
||||||
GetControlBounds( control , &scrollbounds ) ;
|
GetControlBounds( control , &scrollbounds ) ;
|
||||||
if( scrollbounds.right != bounds.right + 1 )
|
if( scrollbounds.right != bounds.right + 1 )
|
||||||
{
|
{
|
||||||
UMAMoveControl( control , bounds.right - (scrollbounds.right - scrollbounds.left) + 1 ,
|
UMAMoveControl( control , bounds.right - (scrollbounds.right - scrollbounds.left) + 1 ,
|
||||||
scrollbounds.top ) ;
|
scrollbounds.top ) ;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
void wxListBox::DoSetFirstItem(int N)
|
void wxListBox::DoSetFirstItem(int N)
|
||||||
{
|
{
|
||||||
MacScrollTo( N ) ;
|
MacScrollTo( N ) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxListBox::Delete(int N)
|
void wxListBox::Delete(int N)
|
||||||
@@ -305,30 +305,30 @@ void wxListBox::Delete(int N)
|
|||||||
delete GetClientObject(N);
|
delete GetClientObject(N);
|
||||||
}
|
}
|
||||||
#endif // wxUSE_OWNER_DRAWN/!wxUSE_OWNER_DRAWN
|
#endif // wxUSE_OWNER_DRAWN/!wxUSE_OWNER_DRAWN
|
||||||
m_stringArray.Remove( N ) ;
|
m_stringArray.Remove( N ) ;
|
||||||
m_dataArray.RemoveAt( N ) ;
|
m_dataArray.RemoveAt( N ) ;
|
||||||
m_noItems --;
|
m_noItems --;
|
||||||
|
|
||||||
MacDelete( N ) ;
|
MacDelete( N ) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
int wxListBox::DoAppend(const wxString& item)
|
int wxListBox::DoAppend(const wxString& item)
|
||||||
{
|
{
|
||||||
int index = m_noItems ;
|
int index = m_noItems ;
|
||||||
if( wxApp::s_macDefaultEncodingIsPC )
|
if( wxApp::s_macDefaultEncodingIsPC )
|
||||||
{
|
{
|
||||||
m_stringArray.Add( wxMacMakeMacStringFromPC( item ) ) ;
|
m_stringArray.Add( wxMacMakeMacStringFromPC( item ) ) ;
|
||||||
m_dataArray.Add( NULL );
|
m_dataArray.Add( NULL );
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
m_stringArray.Add( item ) ;
|
m_stringArray.Add( item ) ;
|
||||||
m_dataArray.Add( NULL );
|
m_dataArray.Add( NULL );
|
||||||
}
|
}
|
||||||
m_noItems ++;
|
m_noItems ++;
|
||||||
DoSetItemClientData( index , NULL ) ;
|
DoSetItemClientData( index , NULL ) ;
|
||||||
MacAppend( item ) ;
|
MacAppend( item ) ;
|
||||||
|
|
||||||
return index ;
|
return index ;
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxListBox::DoSetItems(const wxArrayString& choices, void** clientData)
|
void wxListBox::DoSetItems(const wxArrayString& choices, void** clientData)
|
||||||
@@ -339,17 +339,17 @@ void wxListBox::DoSetItems(const wxArrayString& choices, void** clientData)
|
|||||||
|
|
||||||
for( int i = 0 ; i < n ; ++i )
|
for( int i = 0 ; i < n ; ++i )
|
||||||
{
|
{
|
||||||
if ( clientData )
|
if ( 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("Can't use client data with owner-drawn listboxes"));
|
||||||
#else // !wxUSE_OWNER_DRAWN
|
#else // !wxUSE_OWNER_DRAWN
|
||||||
Append( choices[i] , clientData[i] ) ;
|
Append( choices[i] , clientData[i] ) ;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
Append( choices[i] ) ;
|
Append( choices[i] ) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if wxUSE_OWNER_DRAWN
|
#if wxUSE_OWNER_DRAWN
|
||||||
@@ -379,71 +379,71 @@ bool wxListBox::HasMultipleSelection() const
|
|||||||
|
|
||||||
int wxListBox::FindString(const wxString& st) const
|
int wxListBox::FindString(const wxString& st) const
|
||||||
{
|
{
|
||||||
wxString s ;
|
wxString s ;
|
||||||
if( wxApp::s_macDefaultEncodingIsPC )
|
if( wxApp::s_macDefaultEncodingIsPC )
|
||||||
{
|
{
|
||||||
s = wxMacMakeMacStringFromPC( st ) ;
|
s = wxMacMakeMacStringFromPC( st ) ;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
s = st ;
|
s = st ;
|
||||||
|
|
||||||
if ( s.Right(1) == "*" )
|
if ( s.Right(1) == "*" )
|
||||||
{
|
{
|
||||||
wxString search = s.Left( s.Length() - 1 ) ;
|
wxString search = s.Left( s.Length() - 1 ) ;
|
||||||
int len = search.Length() ;
|
int len = search.Length() ;
|
||||||
Str255 s1 , s2 ;
|
Str255 s1 , s2 ;
|
||||||
|
|
||||||
#if TARGET_CARBON
|
#if TARGET_CARBON
|
||||||
c2pstrcpy( (StringPtr) s2 , search.c_str() ) ;
|
c2pstrcpy( (StringPtr) s2 , search.c_str() ) ;
|
||||||
#else
|
#else
|
||||||
strcpy( (char *) s2 , search.c_str() ) ;
|
strcpy( (char *) s2 , search.c_str() ) ;
|
||||||
c2pstr( (char *) s2 ) ;
|
c2pstr( (char *) s2 ) ;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
for ( int i = 0 ; i < m_noItems ; ++ i )
|
for ( int i = 0 ; i < m_noItems ; ++ i )
|
||||||
{
|
{
|
||||||
#if TARGET_CARBON
|
#if TARGET_CARBON
|
||||||
c2pstrcpy( (StringPtr) s1 , m_stringArray[i].Left( len ).c_str() ) ;
|
c2pstrcpy( (StringPtr) s1 , m_stringArray[i].Left( len ).c_str() ) ;
|
||||||
#else
|
#else
|
||||||
strcpy( (char *) s1 , m_stringArray[i].Left( len ).c_str() ) ;
|
strcpy( (char *) s1 , m_stringArray[i].Left( len ).c_str() ) ;
|
||||||
c2pstr( (char *) s1 ) ;
|
c2pstr( (char *) s1 ) ;
|
||||||
#endif
|
#endif
|
||||||
if ( EqualString( s1 , s2 , false , false ) )
|
if ( EqualString( s1 , s2 , false , false ) )
|
||||||
return i ;
|
return i ;
|
||||||
}
|
}
|
||||||
if ( s.Left(1) == "*" && s.Length() > 1 )
|
if ( s.Left(1) == "*" && s.Length() > 1 )
|
||||||
{
|
{
|
||||||
s.MakeLower() ;
|
s.MakeLower() ;
|
||||||
for ( int i = 0 ; i < m_noItems ; ++i )
|
for ( int i = 0 ; i < m_noItems ; ++i )
|
||||||
{
|
{
|
||||||
if ( GetString(i).Lower().Matches(s) )
|
if ( GetString(i).Lower().Matches(s) )
|
||||||
return i ;
|
return i ;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Str255 s1 , s2 ;
|
Str255 s1 , s2 ;
|
||||||
|
|
||||||
#if TARGET_CARBON
|
#if TARGET_CARBON
|
||||||
c2pstrcpy( (StringPtr) s2 , s.c_str() ) ;
|
c2pstrcpy( (StringPtr) s2 , s.c_str() ) ;
|
||||||
#else
|
#else
|
||||||
strcpy( (char *) s2 , s.c_str() ) ;
|
strcpy( (char *) s2 , s.c_str() ) ;
|
||||||
c2pstr( (char *) s2 ) ;
|
c2pstr( (char *) s2 ) ;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
for ( int i = 0 ; i < m_noItems ; ++ i )
|
for ( int i = 0 ; i < m_noItems ; ++ i )
|
||||||
{
|
{
|
||||||
#if TARGET_CARBON
|
#if TARGET_CARBON
|
||||||
c2pstrcpy( (StringPtr) s1 , m_stringArray[i].c_str() ) ;
|
c2pstrcpy( (StringPtr) s1 , m_stringArray[i].c_str() ) ;
|
||||||
#else
|
#else
|
||||||
strcpy( (char *) s1 , m_stringArray[i].c_str() ) ;
|
strcpy( (char *) s1 , m_stringArray[i].c_str() ) ;
|
||||||
c2pstr( (char *) s1 ) ;
|
c2pstr( (char *) s1 ) ;
|
||||||
#endif
|
#endif
|
||||||
if ( EqualString( s1 , s2 , false , false ) )
|
if ( EqualString( s1 , s2 , false , false ) )
|
||||||
return i ;
|
return i ;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@@ -461,8 +461,8 @@ void wxListBox::SetSelection(int N, bool select)
|
|||||||
{
|
{
|
||||||
wxCHECK_RET( N >= 0 && N < m_noItems,
|
wxCHECK_RET( N >= 0 && N < m_noItems,
|
||||||
"invalid index in wxListBox::SetSelection" );
|
"invalid index in wxListBox::SetSelection" );
|
||||||
MacSetSelection( N , select ) ;
|
MacSetSelection( N , select ) ;
|
||||||
GetSelections( m_selectionPreImage ) ;
|
GetSelections( m_selectionPreImage ) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxListBox::IsSelected(int N) const
|
bool wxListBox::IsSelected(int N) const
|
||||||
@@ -470,7 +470,7 @@ bool wxListBox::IsSelected(int N) const
|
|||||||
wxCHECK_MSG( N >= 0 && N < m_noItems, FALSE,
|
wxCHECK_MSG( N >= 0 && N < m_noItems, FALSE,
|
||||||
"invalid index in wxListBox::Selected" );
|
"invalid index in wxListBox::Selected" );
|
||||||
|
|
||||||
return MacIsSelected( N ) ;
|
return MacIsSelected( N ) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
void *wxListBox::DoGetItemClientData(int N) const
|
void *wxListBox::DoGetItemClientData(int N) const
|
||||||
@@ -483,7 +483,7 @@ void *wxListBox::DoGetItemClientData(int N) const
|
|||||||
|
|
||||||
wxClientData *wxListBox::DoGetItemClientObject(int N) const
|
wxClientData *wxListBox::DoGetItemClientObject(int N) const
|
||||||
{
|
{
|
||||||
return (wxClientData *) DoGetItemClientData( N ) ;
|
return (wxClientData *) DoGetItemClientData( N ) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxListBox::DoSetItemClientData(int N, void *Client_data)
|
void wxListBox::DoSetItemClientData(int N, void *Client_data)
|
||||||
@@ -499,15 +499,15 @@ void wxListBox::DoSetItemClientData(int N, void *Client_data)
|
|||||||
wxFAIL_MSG(wxT("Can't use client data with owner-drawn listboxes"));
|
wxFAIL_MSG(wxT("Can't use client data with owner-drawn listboxes"));
|
||||||
}
|
}
|
||||||
#endif // wxUSE_OWNER_DRAWN
|
#endif // wxUSE_OWNER_DRAWN
|
||||||
wxASSERT_MSG( m_dataArray.GetCount() >= N , "invalid client_data array" ) ;
|
wxASSERT_MSG( m_dataArray.GetCount() >= N , "invalid client_data array" ) ;
|
||||||
|
|
||||||
if ( m_dataArray.GetCount() > N )
|
if ( m_dataArray.GetCount() > N )
|
||||||
{
|
{
|
||||||
m_dataArray[N] = (char*) Client_data ;
|
m_dataArray[N] = (char*) Client_data ;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
m_dataArray.Add( (char*) Client_data ) ;
|
m_dataArray.Add( (char*) Client_data ) ;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -519,24 +519,24 @@ void wxListBox::DoSetItemClientObject(int n, wxClientData* clientData)
|
|||||||
// Return number of selections and an array of selected integers
|
// Return number of selections and an array of selected integers
|
||||||
int wxListBox::GetSelections(wxArrayInt& aSelections) const
|
int wxListBox::GetSelections(wxArrayInt& aSelections) const
|
||||||
{
|
{
|
||||||
return MacGetSelections( aSelections ) ;
|
return MacGetSelections( aSelections ) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get single selection, for single choice list items
|
// Get single selection, for single choice list items
|
||||||
int wxListBox::GetSelection() const
|
int wxListBox::GetSelection() const
|
||||||
{
|
{
|
||||||
return MacGetSelection() ;
|
return MacGetSelection() ;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Find string for position
|
// Find string for position
|
||||||
wxString wxListBox::GetString(int N) const
|
wxString wxListBox::GetString(int N) const
|
||||||
{
|
{
|
||||||
if( wxApp::s_macDefaultEncodingIsPC )
|
if( wxApp::s_macDefaultEncodingIsPC )
|
||||||
{
|
{
|
||||||
return wxMacMakePCStringFromMac( m_stringArray[N] ) ;
|
return wxMacMakePCStringFromMac( m_stringArray[N] ) ;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
return m_stringArray[N] ;
|
return m_stringArray[N] ;
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxListBox::DoInsertItems(const wxArrayString& items, int pos)
|
void wxListBox::DoInsertItems(const wxArrayString& items, int pos)
|
||||||
@@ -546,27 +546,27 @@ void wxListBox::DoInsertItems(const wxArrayString& items, int pos)
|
|||||||
|
|
||||||
int nItems = items.GetCount();
|
int nItems = items.GetCount();
|
||||||
|
|
||||||
for ( int i = 0 ; i < nItems ; i++ )
|
for ( int i = 0 ; i < nItems ; i++ )
|
||||||
{
|
{
|
||||||
m_stringArray.Insert( items[i] , pos + i ) ;
|
m_stringArray.Insert( items[i] , pos + i ) ;
|
||||||
m_dataArray.Insert( NULL , pos + i ) ;
|
m_dataArray.Insert( NULL , pos + i ) ;
|
||||||
MacInsert( pos + i , items[i] ) ;
|
MacInsert( pos + i , items[i] ) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_noItems += nItems;
|
m_noItems += nItems;
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxListBox::SetString(int N, const wxString& s)
|
void wxListBox::SetString(int N, const wxString& s)
|
||||||
{
|
{
|
||||||
wxString str ;
|
wxString str ;
|
||||||
if( wxApp::s_macDefaultEncodingIsPC )
|
if( wxApp::s_macDefaultEncodingIsPC )
|
||||||
{
|
{
|
||||||
str = wxMacMakeMacStringFromPC( s ) ;
|
str = wxMacMakeMacStringFromPC( s ) ;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
str = s ;
|
str = s ;
|
||||||
m_stringArray[N] = str ;
|
m_stringArray[N] = str ;
|
||||||
MacSet( N , s ) ;
|
MacSet( N , s ) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxSize wxListBox::DoGetBestSize() const
|
wxSize wxListBox::DoGetBestSize() const
|
||||||
@@ -622,17 +622,17 @@ wxOwnerDrawn *wxListBox::CreateItem(size_t n)
|
|||||||
|
|
||||||
void MacDrawStringCell(Rect *cellRect, Cell lCell, ListHandle theList, long refCon)
|
void MacDrawStringCell(Rect *cellRect, Cell lCell, ListHandle theList, long refCon)
|
||||||
{
|
{
|
||||||
wxListBox* list;
|
wxListBox* list;
|
||||||
// typecast our refCon
|
// typecast our refCon
|
||||||
list = (wxListBox*)refCon;
|
list = (wxListBox*)refCon;
|
||||||
|
|
||||||
MoveTo(cellRect->left + 4 , cellRect->top + 10 );
|
MoveTo(cellRect->left + 4 , cellRect->top + 10 );
|
||||||
const wxString text = list->m_stringArray[lCell.v] ;
|
const wxString text = list->m_stringArray[lCell.v] ;
|
||||||
::TextFont( kFontIDMonaco ) ;
|
::TextFont( kFontIDMonaco ) ;
|
||||||
::TextSize( 9 );
|
::TextSize( 9 );
|
||||||
::TextFace( 0 ) ;
|
::TextFace( 0 ) ;
|
||||||
DrawText(text, 0 , text.Length());
|
DrawText(text, 0 , text.Length());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxListBox::MacDelete( int N )
|
void wxListBox::MacDelete( int N )
|
||||||
@@ -667,26 +667,26 @@ void wxListBox::MacClear()
|
|||||||
|
|
||||||
void wxListBox::MacSetSelection( int n , bool select )
|
void wxListBox::MacSetSelection( int n , bool select )
|
||||||
{
|
{
|
||||||
Cell cell = { 0 , 0 } ;
|
Cell cell = { 0 , 0 } ;
|
||||||
if ( ! (m_windowStyle & wxLB_MULTIPLE) )
|
if ( ! (m_windowStyle & wxLB_MULTIPLE) )
|
||||||
{
|
{
|
||||||
if ( LGetSelect( true , &cell , m_macList ) )
|
if ( LGetSelect( true , &cell , m_macList ) )
|
||||||
{
|
{
|
||||||
LSetSelect( false , cell , m_macList ) ;
|
LSetSelect( false , cell , m_macList ) ;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
cell.v = n ;
|
cell.v = n ;
|
||||||
LSetSelect( select , cell , m_macList ) ;
|
LSetSelect( select , cell , m_macList ) ;
|
||||||
LAutoScroll( m_macList ) ;
|
LAutoScroll( m_macList ) ;
|
||||||
Refresh();
|
Refresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxListBox::MacIsSelected( int n ) const
|
bool wxListBox::MacIsSelected( int n ) const
|
||||||
{
|
{
|
||||||
Cell cell = { 0 , 0 } ;
|
Cell cell = { 0 , 0 } ;
|
||||||
cell.v = n ;
|
cell.v = n ;
|
||||||
return LGetSelect( false , &cell , m_macList ) ;
|
return LGetSelect( false , &cell , m_macList ) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxListBox::MacDestroy()
|
void wxListBox::MacDestroy()
|
||||||
@@ -696,44 +696,44 @@ void wxListBox::MacDestroy()
|
|||||||
|
|
||||||
int wxListBox::MacGetSelection() const
|
int wxListBox::MacGetSelection() const
|
||||||
{
|
{
|
||||||
Cell cell = { 0 , 0 } ;
|
Cell cell = { 0 , 0 } ;
|
||||||
if ( LGetSelect( true , &cell , m_macList ) )
|
if ( LGetSelect( true , &cell , m_macList ) )
|
||||||
return cell.v ;
|
return cell.v ;
|
||||||
else
|
else
|
||||||
return -1 ;
|
return -1 ;
|
||||||
}
|
}
|
||||||
|
|
||||||
int wxListBox::MacGetSelections( wxArrayInt& aSelections ) const
|
int wxListBox::MacGetSelections( wxArrayInt& aSelections ) const
|
||||||
{
|
{
|
||||||
int no_sel = 0 ;
|
int no_sel = 0 ;
|
||||||
|
|
||||||
aSelections.Empty();
|
aSelections.Empty();
|
||||||
|
|
||||||
Cell cell = { 0 , 0 } ;
|
Cell cell = { 0 , 0 } ;
|
||||||
cell.v = 0 ;
|
cell.v = 0 ;
|
||||||
|
|
||||||
while ( LGetSelect( true , &cell , m_macList ) )
|
while ( LGetSelect( true , &cell , m_macList ) )
|
||||||
{
|
{
|
||||||
aSelections.Add( cell.v ) ;
|
aSelections.Add( cell.v ) ;
|
||||||
no_sel++ ;
|
no_sel++ ;
|
||||||
cell.v++ ;
|
cell.v++ ;
|
||||||
}
|
}
|
||||||
return no_sel ;
|
return no_sel ;
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxListBox::MacSet( int n , const char * text )
|
void wxListBox::MacSet( int n , const char * text )
|
||||||
{
|
{
|
||||||
// our implementation does not store anything in the list
|
// our implementation does not store anything in the list
|
||||||
// so we just have to redraw
|
// so we just have to redraw
|
||||||
Cell cell = { 0 , 0 } ;
|
Cell cell = { 0 , 0 } ;
|
||||||
cell.v = n ;
|
cell.v = n ;
|
||||||
// LSetCell(text, strlen(text), cell, m_macList);
|
// LSetCell(text, strlen(text), cell, m_macList);
|
||||||
Refresh();
|
Refresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxListBox::MacScrollTo( int n )
|
void wxListBox::MacScrollTo( int n )
|
||||||
{
|
{
|
||||||
// TODO implement scrolling
|
// TODO implement scrolling
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxListBox::OnSize( const wxSizeEvent &event)
|
void wxListBox::OnSize( const wxSizeEvent &event)
|
||||||
@@ -751,63 +751,67 @@ void wxListBox::OnSize( const wxSizeEvent &event)
|
|||||||
|
|
||||||
void wxListBox::MacHandleControlClick( ControlHandle control , SInt16 controlpart )
|
void wxListBox::MacHandleControlClick( ControlHandle control , SInt16 controlpart )
|
||||||
{
|
{
|
||||||
Boolean wasDoubleClick = false ;
|
Boolean wasDoubleClick = false ;
|
||||||
long result ;
|
long result ;
|
||||||
|
|
||||||
::GetControlData( m_macControl , kControlNoPart , kControlListBoxDoubleClickTag , sizeof( wasDoubleClick ) , (char*) &wasDoubleClick , &result ) ;
|
::GetControlData( m_macControl , kControlNoPart , kControlListBoxDoubleClickTag , sizeof( wasDoubleClick ) , (char*) &wasDoubleClick , &result ) ;
|
||||||
if ( !wasDoubleClick )
|
if ( !wasDoubleClick )
|
||||||
{
|
{
|
||||||
MacDoClick() ;
|
MacDoClick() ;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
MacDoDoubleClick() ;
|
MacDoDoubleClick() ;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxListBox::MacSetRedraw( bool doDraw )
|
void wxListBox::MacSetRedraw( bool doDraw )
|
||||||
{
|
{
|
||||||
LSetDrawingMode( doDraw , m_macList ) ;
|
LSetDrawingMode( doDraw , m_macList ) ;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxListBox::MacDoClick()
|
void wxListBox::MacDoClick()
|
||||||
{
|
{
|
||||||
wxArrayInt aSelections;
|
wxArrayInt aSelections;
|
||||||
int n, count = GetSelections(aSelections);
|
int n, count = GetSelections(aSelections);
|
||||||
|
|
||||||
if ( count == m_selectionPreImage.GetCount() )
|
if ( count == m_selectionPreImage.GetCount() )
|
||||||
{
|
{
|
||||||
bool hasChanged = false ;
|
bool hasChanged = false ;
|
||||||
for ( int i = 0 ; i < count ; ++i )
|
for ( int i = 0 ; i < count ; ++i )
|
||||||
{
|
{
|
||||||
if ( aSelections[i] != m_selectionPreImage[i] )
|
if ( aSelections[i] != m_selectionPreImage[i] )
|
||||||
{
|
{
|
||||||
hasChanged = true ;
|
hasChanged = true ;
|
||||||
break ;
|
break ;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ( !hasChanged )
|
if ( !hasChanged )
|
||||||
return ;
|
{
|
||||||
}
|
return ;
|
||||||
|
}
|
||||||
wxCommandEvent event(wxEVT_COMMAND_LISTBOX_SELECTED, m_windowId);
|
}
|
||||||
event.SetEventObject( this );
|
|
||||||
|
m_selectionPreImage = aSelections;
|
||||||
|
|
||||||
|
wxCommandEvent event(wxEVT_COMMAND_LISTBOX_SELECTED, m_windowId);
|
||||||
|
event.SetEventObject( this );
|
||||||
|
|
||||||
if ( count > 0 )
|
if ( count > 0 )
|
||||||
{
|
{
|
||||||
n = aSelections[0];
|
n = aSelections[0];
|
||||||
if ( HasClientObjectData() )
|
if ( HasClientObjectData() )
|
||||||
event.SetClientObject( GetClientObject(n) );
|
event.SetClientObject( GetClientObject(n) );
|
||||||
else if ( HasClientUntypedData() )
|
else if ( HasClientUntypedData() )
|
||||||
event.SetClientData( GetClientData(n) );
|
event.SetClientData( GetClientData(n) );
|
||||||
event.SetString( GetString(n) );
|
event.SetString( GetString(n) );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
n = -1;
|
n = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
event.m_commandInt = n;
|
event.m_commandInt = n;
|
||||||
|
|
||||||
GetEventHandler()->ProcessEvent(event);
|
GetEventHandler()->ProcessEvent(event);
|
||||||
@@ -817,5 +821,5 @@ void wxListBox::MacDoDoubleClick()
|
|||||||
{
|
{
|
||||||
wxCommandEvent event(wxEVT_COMMAND_LISTBOX_DOUBLECLICKED, m_windowId);
|
wxCommandEvent event(wxEVT_COMMAND_LISTBOX_DOUBLECLICKED, m_windowId);
|
||||||
event.SetEventObject( this );
|
event.SetEventObject( this );
|
||||||
GetEventHandler()->ProcessEvent(event) ;
|
GetEventHandler()->ProcessEvent(event) ;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user