corrected a bug in dc which resetted the port , exchanged the wxchoice implementation
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@10096 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -88,15 +88,11 @@ protected:
|
|||||||
virtual void DoSetItemClientObject( int n, wxClientData* clientData );
|
virtual void DoSetItemClientObject( int n, wxClientData* clientData );
|
||||||
virtual wxClientData* DoGetItemClientObject( int n ) const;
|
virtual wxClientData* DoGetItemClientObject( int n ) const;
|
||||||
|
|
||||||
virtual void DoSetSize(int x, int y,
|
|
||||||
int width, int height,
|
|
||||||
int sizeFlags = wxSIZE_AUTO);
|
|
||||||
|
|
||||||
// free all memory we have (used by Clear() and dtor)
|
// free all memory we have (used by Clear() and dtor)
|
||||||
void Free();
|
void Free();
|
||||||
|
|
||||||
wxArrayString m_strings;
|
wxArrayString m_strings;
|
||||||
wxChoiceDataArray m_dataArray ;
|
wxChoiceDataArray m_datas ;
|
||||||
MenuHandle m_macPopUpMenuHandle ;
|
MenuHandle m_macPopUpMenuHandle ;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -2586,7 +2586,7 @@ void AGAPortHelper::Setup( GrafPtr newport )
|
|||||||
GetPenState( &oldPenState ) ;
|
GetPenState( &oldPenState ) ;
|
||||||
GetBackColor( &oldBackColor ) ;
|
GetBackColor( &oldBackColor ) ;
|
||||||
GetForeColor( &oldForeColor ) ;
|
GetForeColor( &oldForeColor ) ;
|
||||||
|
wxASSERT( clip == NULL ) ;
|
||||||
clip = NewRgn() ;
|
clip = NewRgn() ;
|
||||||
GetClip( clip );
|
GetClip( clip );
|
||||||
font = GetPortTextFont( newport);
|
font = GetPortTextFont( newport);
|
||||||
@@ -2608,6 +2608,7 @@ AGAPortHelper::~AGAPortHelper()
|
|||||||
if ( clip )
|
if ( clip )
|
||||||
{
|
{
|
||||||
SetPort( nport ) ;
|
SetPort( nport ) ;
|
||||||
|
PenNormal() ;
|
||||||
SetClip( clip ) ;
|
SetClip( clip ) ;
|
||||||
DisposeRgn( clip ) ;
|
DisposeRgn( clip ) ;
|
||||||
RGBForeColor(&oldForeColor);
|
RGBForeColor(&oldForeColor);
|
||||||
|
@@ -2586,7 +2586,7 @@ void AGAPortHelper::Setup( GrafPtr newport )
|
|||||||
GetPenState( &oldPenState ) ;
|
GetPenState( &oldPenState ) ;
|
||||||
GetBackColor( &oldBackColor ) ;
|
GetBackColor( &oldBackColor ) ;
|
||||||
GetForeColor( &oldForeColor ) ;
|
GetForeColor( &oldForeColor ) ;
|
||||||
|
wxASSERT( clip == NULL ) ;
|
||||||
clip = NewRgn() ;
|
clip = NewRgn() ;
|
||||||
GetClip( clip );
|
GetClip( clip );
|
||||||
font = GetPortTextFont( newport);
|
font = GetPortTextFont( newport);
|
||||||
@@ -2608,6 +2608,7 @@ AGAPortHelper::~AGAPortHelper()
|
|||||||
if ( clip )
|
if ( clip )
|
||||||
{
|
{
|
||||||
SetPort( nport ) ;
|
SetPort( nport ) ;
|
||||||
|
PenNormal() ;
|
||||||
SetClip( clip ) ;
|
SetClip( clip ) ;
|
||||||
DisposeRgn( clip ) ;
|
DisposeRgn( clip ) ;
|
||||||
RGBForeColor(&oldForeColor);
|
RGBForeColor(&oldForeColor);
|
||||||
|
@@ -30,14 +30,6 @@ wxChoice::~wxChoice()
|
|||||||
DisposeMenu( m_macPopUpMenuHandle ) ;
|
DisposeMenu( m_macPopUpMenuHandle ) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
int wxChoice::GetCount() const {
|
|
||||||
return m_strings.Count() ;
|
|
||||||
}
|
|
||||||
|
|
||||||
void wxChoice::SetString( int n , const wxString& s ) {
|
|
||||||
m_strings[n] = s ;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool wxChoice::Create(wxWindow *parent, wxWindowID id,
|
bool wxChoice::Create(wxWindow *parent, wxWindowID id,
|
||||||
const wxPoint& pos,
|
const wxPoint& pos,
|
||||||
const wxSize& size,
|
const wxSize& size,
|
||||||
@@ -52,57 +44,156 @@ bool wxChoice::Create(wxWindow *parent, wxWindowID id,
|
|||||||
|
|
||||||
MacPreControlCreate( parent , id , "" , pos , size ,style, validator , name , &bounds , title ) ;
|
MacPreControlCreate( parent , id , "" , pos , size ,style, validator , name , &bounds , title ) ;
|
||||||
|
|
||||||
m_macPopUpMenuHandle = NewMenu( 1 , "\pPopUp Menu" ) ;
|
|
||||||
m_macControl = UMANewControl( parent->GetMacRootWindow() , &bounds , title , true , 0 , -12345 , 0 ,
|
m_macControl = UMANewControl( parent->GetMacRootWindow() , &bounds , title , true , 0 , -12345 , 0 ,
|
||||||
kControlPopupButtonProc + kControlPopupFixedWidthVariant , (long) this ) ;
|
kControlPopupButtonProc + kControlPopupFixedWidthVariant , (long) this ) ;
|
||||||
|
|
||||||
m_macPopUpMenuHandle = NewMenu( 1 , "\pPopUp Menu" ) ;
|
m_macPopUpMenuHandle = NewMenu( 1 , "\pPopUp Menu" ) ;
|
||||||
SetControlData( m_macControl , kControlNoPart , kControlPopupButtonMenuHandleTag , sizeof( MenuHandle ) , (char*) &m_macPopUpMenuHandle) ;
|
SetControlData( m_macControl , kControlNoPart , kControlPopupButtonMenuHandleTag , sizeof( MenuHandle ) , (char*) &m_macPopUpMenuHandle) ;
|
||||||
for ( int i = 0 ; i < n ; i++ )
|
|
||||||
{
|
|
||||||
Str255 label;
|
|
||||||
wxMenuItem::MacBuildMenuString( label , NULL , NULL , choices[i] ,false);
|
|
||||||
AppendMenu( m_macPopUpMenuHandle , label ) ;
|
|
||||||
m_strings.Add( choices[i] ) ;
|
|
||||||
m_dataArray.Add( NULL );
|
|
||||||
}
|
|
||||||
SetControlMinimum( m_macControl , 0 ) ;
|
SetControlMinimum( m_macControl , 0 ) ;
|
||||||
SetControlMaximum( m_macControl , Number()) ;
|
SetControlMaximum( m_macControl , 0) ;
|
||||||
if ( n > 0 )
|
if ( n > 0 )
|
||||||
SetControlValue( m_macControl , 1 ) ;
|
SetControlValue( m_macControl , 1 ) ;
|
||||||
|
|
||||||
MacPostControlCreate() ;
|
MacPostControlCreate() ;
|
||||||
|
|
||||||
|
for ( int i = 0; i < n; i++ )
|
||||||
|
{
|
||||||
|
Append(choices[i]);
|
||||||
|
}
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
// adding/deleting items to/from the list
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
int wxChoice::DoAppend(const wxString& item)
|
int wxChoice::DoAppend(const wxString& item)
|
||||||
{
|
{
|
||||||
Str255 label;
|
Str255 label;
|
||||||
wxMenuItem::MacBuildMenuString( label , NULL , NULL , item ,false);
|
wxMenuItem::MacBuildMenuString( label , NULL , NULL , item ,false);
|
||||||
AppendMenu( m_macPopUpMenuHandle , label ) ;
|
AppendMenu( m_macPopUpMenuHandle , label ) ;
|
||||||
m_strings.Add( item ) ;
|
m_strings.Add( item ) ;
|
||||||
m_dataArray.Add( NULL );
|
m_datas.Add( NULL ) ;
|
||||||
return m_strings.Count() ;
|
int index = m_strings.GetCount() - 1 ;
|
||||||
|
DoSetItemClientData( index , NULL ) ;
|
||||||
|
SetControlMaximum( m_macControl , Number()) ;
|
||||||
|
return index ;
|
||||||
|
}
|
||||||
|
|
||||||
|
void wxChoice::Delete(int n)
|
||||||
|
{
|
||||||
|
wxCHECK_RET( n < GetCount(), wxT("invalid item index in wxChoice::Delete") );
|
||||||
|
|
||||||
|
if ( HasClientObjectData() )
|
||||||
|
{
|
||||||
|
delete GetClientObject(n);
|
||||||
|
}
|
||||||
|
|
||||||
|
::DeleteMenuItem( m_macPopUpMenuHandle , n + 1) ;
|
||||||
|
m_strings.Remove( n ) ;
|
||||||
|
SetControlMaximum( m_macControl , Number()) ;
|
||||||
|
}
|
||||||
|
|
||||||
|
void wxChoice::Clear()
|
||||||
|
{
|
||||||
|
Free();
|
||||||
|
|
||||||
|
for ( int i = 0 ; i < GetCount() ; i++ )
|
||||||
|
{
|
||||||
|
::DeleteMenuItem( m_macPopUpMenuHandle , 1 ) ;
|
||||||
|
}
|
||||||
|
m_strings.Empty() ;
|
||||||
|
m_datas.Empty() ;
|
||||||
|
SetControlMaximum( m_macControl , 0 ) ;
|
||||||
|
}
|
||||||
|
|
||||||
|
void wxChoice::Free()
|
||||||
|
{
|
||||||
|
if ( HasClientObjectData() )
|
||||||
|
{
|
||||||
|
size_t count = GetCount();
|
||||||
|
for ( size_t n = 0; n < count; n++ )
|
||||||
|
{
|
||||||
|
delete GetClientObject(n);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
// selection
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
int wxChoice::GetSelection() const
|
||||||
|
{
|
||||||
|
return GetControlValue( m_macControl ) -1 ;
|
||||||
|
}
|
||||||
|
|
||||||
|
void wxChoice::SetSelection(int n)
|
||||||
|
{
|
||||||
|
SetControlValue( m_macControl , n + 1 ) ;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
// string list functions
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
int wxChoice::GetCount() const
|
||||||
|
{
|
||||||
|
return m_strings.GetCount() ;
|
||||||
|
}
|
||||||
|
|
||||||
|
int wxChoice::FindString(const wxString& s) const
|
||||||
|
{
|
||||||
|
for( int i = 0 ; i < GetCount() ; i++ )
|
||||||
|
{
|
||||||
|
if ( GetString( i ).IsSameAs(s, FALSE) )
|
||||||
|
return i ;
|
||||||
|
}
|
||||||
|
return wxNOT_FOUND ;
|
||||||
|
}
|
||||||
|
|
||||||
|
void wxChoice::SetString(int n, const wxString& s)
|
||||||
|
{
|
||||||
|
wxFAIL_MSG(wxT("not implemented"));
|
||||||
|
|
||||||
|
#if 0 // should do this, but no Insert() so far
|
||||||
|
Delete(n);
|
||||||
|
Insert(n + 1, s);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
wxString wxChoice::GetString(int n) const
|
||||||
|
{
|
||||||
|
return m_strings[n] ;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
// client data
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
void wxChoice::DoSetItemClientData( int n, void* clientData )
|
||||||
|
{
|
||||||
|
wxCHECK_RET( n >= 0 && n < m_datas.GetCount(),
|
||||||
|
"invalid index in wxChoice::SetClientData" );
|
||||||
|
wxASSERT_MSG( m_datas.GetCount() >= n , "invalid client_data array" ) ;
|
||||||
|
|
||||||
|
if ( m_datas.GetCount() > n )
|
||||||
|
{
|
||||||
|
m_datas[n] = (char*) clientData ;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
m_datas.Add( (char*) clientData ) ;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void *wxChoice::DoGetItemClientData(int N) const
|
void *wxChoice::DoGetItemClientData(int N) const
|
||||||
{
|
{
|
||||||
return (void *)m_dataArray[N];
|
wxCHECK_MSG( N >= 0 && N < m_datas.GetCount(), NULL,
|
||||||
}
|
"invalid index in wxChoice::GetClientData" );
|
||||||
|
|
||||||
void wxChoice::DoSetItemClientData( int N, void* Client_data )
|
return (void *)m_datas[N];
|
||||||
{
|
|
||||||
wxASSERT_MSG( m_dataArray.GetCount() >= N , "invalid client_data array" ) ;
|
|
||||||
|
|
||||||
if ( m_dataArray.GetCount() > N )
|
|
||||||
{
|
|
||||||
m_dataArray[N] = (char*) Client_data ;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
m_dataArray.Add( (char*) Client_data ) ;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxChoice::DoSetItemClientObject( int n, wxClientData* clientData )
|
void wxChoice::DoSetItemClientObject( int n, wxClientData* clientData )
|
||||||
@@ -110,33 +201,9 @@ void wxChoice::DoSetItemClientObject( int n, wxClientData* clientData )
|
|||||||
DoSetItemClientData(n, clientData);
|
DoSetItemClientData(n, clientData);
|
||||||
}
|
}
|
||||||
|
|
||||||
wxClientData* wxChoice::DoGetItemClientObject( int N ) const
|
wxClientData* wxChoice::DoGetItemClientObject( int n ) const
|
||||||
{
|
{
|
||||||
return (wxClientData *) DoGetItemClientData( N ) ;
|
return (wxClientData *)DoGetItemClientData(n);
|
||||||
}
|
|
||||||
|
|
||||||
void wxChoice::Delete(int n)
|
|
||||||
{
|
|
||||||
::DeleteMenuItem( m_macPopUpMenuHandle , n + 1) ;
|
|
||||||
m_strings.Remove( n ) ;
|
|
||||||
m_dataArray.Remove( n ) ;
|
|
||||||
SetControlMaximum( m_macControl , Number()) ;
|
|
||||||
}
|
|
||||||
|
|
||||||
void wxChoice::Clear()
|
|
||||||
{
|
|
||||||
for ( int i = 0 ; i < Number() ; i++ )
|
|
||||||
{
|
|
||||||
::DeleteMenuItem( m_macPopUpMenuHandle , 1 ) ;
|
|
||||||
}
|
|
||||||
m_strings.Clear() ;
|
|
||||||
m_dataArray.Empty() ;
|
|
||||||
SetControlMaximum( m_macControl , Number()) ;
|
|
||||||
}
|
|
||||||
|
|
||||||
int wxChoice::GetSelection() const
|
|
||||||
{
|
|
||||||
return GetControlValue( m_macControl ) -1 ;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxChoice::MacHandleControlClick( ControlHandle control , SInt16 controlpart )
|
void wxChoice::MacHandleControlClick( ControlHandle control , SInt16 controlpart )
|
||||||
@@ -147,30 +214,10 @@ void wxChoice::MacHandleControlClick( ControlHandle control , SInt16 controlpart
|
|||||||
event.SetString(GetStringSelection());
|
event.SetString(GetStringSelection());
|
||||||
ProcessCommand(event);
|
ProcessCommand(event);
|
||||||
}
|
}
|
||||||
|
/*
|
||||||
|
void wxChoice::Command(wxCommandEvent & event)
|
||||||
void wxChoice::SetSelection(int n)
|
|
||||||
{
|
{
|
||||||
SetControlValue( m_macControl , n + 1 ) ;
|
SetSelection (event.GetInt());
|
||||||
|
ProcessCommand (event);
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
int wxChoice::FindString(const wxString& s) const
|
|
||||||
{
|
|
||||||
for( int i = 0 ; i < Number() ; i++ )
|
|
||||||
{
|
|
||||||
if ( GetString( i ) == s )
|
|
||||||
return i ;
|
|
||||||
}
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
wxString wxChoice::GetString(int n) const
|
|
||||||
{
|
|
||||||
return m_strings[n] ;
|
|
||||||
}
|
|
||||||
|
|
||||||
void wxChoice::DoSetSize(int x, int y, int width, int height, int sizeFlags)
|
|
||||||
{
|
|
||||||
wxControl::SetSize( x,y,width,height,sizeFlags ) ;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
@@ -103,7 +103,7 @@ wxDC::~wxDC(void)
|
|||||||
|
|
||||||
void wxDC::MacSetupPort(AGAPortHelper* help) const
|
void wxDC::MacSetupPort(AGAPortHelper* help) const
|
||||||
{
|
{
|
||||||
help->Setup( m_macPort ) ;
|
// help->Setup( m_macPort ) ;
|
||||||
::SetOrigin(-m_macLocalOrigin.h, -m_macLocalOrigin.v);
|
::SetOrigin(-m_macLocalOrigin.h, -m_macLocalOrigin.v);
|
||||||
::ClipRect(&m_macClipRect);
|
::ClipRect(&m_macClipRect);
|
||||||
|
|
||||||
|
@@ -30,14 +30,6 @@ wxChoice::~wxChoice()
|
|||||||
DisposeMenu( m_macPopUpMenuHandle ) ;
|
DisposeMenu( m_macPopUpMenuHandle ) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
int wxChoice::GetCount() const {
|
|
||||||
return m_strings.Count() ;
|
|
||||||
}
|
|
||||||
|
|
||||||
void wxChoice::SetString( int n , const wxString& s ) {
|
|
||||||
m_strings[n] = s ;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool wxChoice::Create(wxWindow *parent, wxWindowID id,
|
bool wxChoice::Create(wxWindow *parent, wxWindowID id,
|
||||||
const wxPoint& pos,
|
const wxPoint& pos,
|
||||||
const wxSize& size,
|
const wxSize& size,
|
||||||
@@ -52,57 +44,156 @@ bool wxChoice::Create(wxWindow *parent, wxWindowID id,
|
|||||||
|
|
||||||
MacPreControlCreate( parent , id , "" , pos , size ,style, validator , name , &bounds , title ) ;
|
MacPreControlCreate( parent , id , "" , pos , size ,style, validator , name , &bounds , title ) ;
|
||||||
|
|
||||||
m_macPopUpMenuHandle = NewMenu( 1 , "\pPopUp Menu" ) ;
|
|
||||||
m_macControl = UMANewControl( parent->GetMacRootWindow() , &bounds , title , true , 0 , -12345 , 0 ,
|
m_macControl = UMANewControl( parent->GetMacRootWindow() , &bounds , title , true , 0 , -12345 , 0 ,
|
||||||
kControlPopupButtonProc + kControlPopupFixedWidthVariant , (long) this ) ;
|
kControlPopupButtonProc + kControlPopupFixedWidthVariant , (long) this ) ;
|
||||||
|
|
||||||
m_macPopUpMenuHandle = NewMenu( 1 , "\pPopUp Menu" ) ;
|
m_macPopUpMenuHandle = NewMenu( 1 , "\pPopUp Menu" ) ;
|
||||||
SetControlData( m_macControl , kControlNoPart , kControlPopupButtonMenuHandleTag , sizeof( MenuHandle ) , (char*) &m_macPopUpMenuHandle) ;
|
SetControlData( m_macControl , kControlNoPart , kControlPopupButtonMenuHandleTag , sizeof( MenuHandle ) , (char*) &m_macPopUpMenuHandle) ;
|
||||||
for ( int i = 0 ; i < n ; i++ )
|
|
||||||
{
|
|
||||||
Str255 label;
|
|
||||||
wxMenuItem::MacBuildMenuString( label , NULL , NULL , choices[i] ,false);
|
|
||||||
AppendMenu( m_macPopUpMenuHandle , label ) ;
|
|
||||||
m_strings.Add( choices[i] ) ;
|
|
||||||
m_dataArray.Add( NULL );
|
|
||||||
}
|
|
||||||
SetControlMinimum( m_macControl , 0 ) ;
|
SetControlMinimum( m_macControl , 0 ) ;
|
||||||
SetControlMaximum( m_macControl , Number()) ;
|
SetControlMaximum( m_macControl , 0) ;
|
||||||
if ( n > 0 )
|
if ( n > 0 )
|
||||||
SetControlValue( m_macControl , 1 ) ;
|
SetControlValue( m_macControl , 1 ) ;
|
||||||
|
|
||||||
MacPostControlCreate() ;
|
MacPostControlCreate() ;
|
||||||
|
|
||||||
|
for ( int i = 0; i < n; i++ )
|
||||||
|
{
|
||||||
|
Append(choices[i]);
|
||||||
|
}
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
// adding/deleting items to/from the list
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
int wxChoice::DoAppend(const wxString& item)
|
int wxChoice::DoAppend(const wxString& item)
|
||||||
{
|
{
|
||||||
Str255 label;
|
Str255 label;
|
||||||
wxMenuItem::MacBuildMenuString( label , NULL , NULL , item ,false);
|
wxMenuItem::MacBuildMenuString( label , NULL , NULL , item ,false);
|
||||||
AppendMenu( m_macPopUpMenuHandle , label ) ;
|
AppendMenu( m_macPopUpMenuHandle , label ) ;
|
||||||
m_strings.Add( item ) ;
|
m_strings.Add( item ) ;
|
||||||
m_dataArray.Add( NULL );
|
m_datas.Add( NULL ) ;
|
||||||
return m_strings.Count() ;
|
int index = m_strings.GetCount() - 1 ;
|
||||||
|
DoSetItemClientData( index , NULL ) ;
|
||||||
|
SetControlMaximum( m_macControl , Number()) ;
|
||||||
|
return index ;
|
||||||
|
}
|
||||||
|
|
||||||
|
void wxChoice::Delete(int n)
|
||||||
|
{
|
||||||
|
wxCHECK_RET( n < GetCount(), wxT("invalid item index in wxChoice::Delete") );
|
||||||
|
|
||||||
|
if ( HasClientObjectData() )
|
||||||
|
{
|
||||||
|
delete GetClientObject(n);
|
||||||
|
}
|
||||||
|
|
||||||
|
::DeleteMenuItem( m_macPopUpMenuHandle , n + 1) ;
|
||||||
|
m_strings.Remove( n ) ;
|
||||||
|
SetControlMaximum( m_macControl , Number()) ;
|
||||||
|
}
|
||||||
|
|
||||||
|
void wxChoice::Clear()
|
||||||
|
{
|
||||||
|
Free();
|
||||||
|
|
||||||
|
for ( int i = 0 ; i < GetCount() ; i++ )
|
||||||
|
{
|
||||||
|
::DeleteMenuItem( m_macPopUpMenuHandle , 1 ) ;
|
||||||
|
}
|
||||||
|
m_strings.Empty() ;
|
||||||
|
m_datas.Empty() ;
|
||||||
|
SetControlMaximum( m_macControl , 0 ) ;
|
||||||
|
}
|
||||||
|
|
||||||
|
void wxChoice::Free()
|
||||||
|
{
|
||||||
|
if ( HasClientObjectData() )
|
||||||
|
{
|
||||||
|
size_t count = GetCount();
|
||||||
|
for ( size_t n = 0; n < count; n++ )
|
||||||
|
{
|
||||||
|
delete GetClientObject(n);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
// selection
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
int wxChoice::GetSelection() const
|
||||||
|
{
|
||||||
|
return GetControlValue( m_macControl ) -1 ;
|
||||||
|
}
|
||||||
|
|
||||||
|
void wxChoice::SetSelection(int n)
|
||||||
|
{
|
||||||
|
SetControlValue( m_macControl , n + 1 ) ;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
// string list functions
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
int wxChoice::GetCount() const
|
||||||
|
{
|
||||||
|
return m_strings.GetCount() ;
|
||||||
|
}
|
||||||
|
|
||||||
|
int wxChoice::FindString(const wxString& s) const
|
||||||
|
{
|
||||||
|
for( int i = 0 ; i < GetCount() ; i++ )
|
||||||
|
{
|
||||||
|
if ( GetString( i ).IsSameAs(s, FALSE) )
|
||||||
|
return i ;
|
||||||
|
}
|
||||||
|
return wxNOT_FOUND ;
|
||||||
|
}
|
||||||
|
|
||||||
|
void wxChoice::SetString(int n, const wxString& s)
|
||||||
|
{
|
||||||
|
wxFAIL_MSG(wxT("not implemented"));
|
||||||
|
|
||||||
|
#if 0 // should do this, but no Insert() so far
|
||||||
|
Delete(n);
|
||||||
|
Insert(n + 1, s);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
wxString wxChoice::GetString(int n) const
|
||||||
|
{
|
||||||
|
return m_strings[n] ;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
// client data
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
void wxChoice::DoSetItemClientData( int n, void* clientData )
|
||||||
|
{
|
||||||
|
wxCHECK_RET( n >= 0 && n < m_datas.GetCount(),
|
||||||
|
"invalid index in wxChoice::SetClientData" );
|
||||||
|
wxASSERT_MSG( m_datas.GetCount() >= n , "invalid client_data array" ) ;
|
||||||
|
|
||||||
|
if ( m_datas.GetCount() > n )
|
||||||
|
{
|
||||||
|
m_datas[n] = (char*) clientData ;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
m_datas.Add( (char*) clientData ) ;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void *wxChoice::DoGetItemClientData(int N) const
|
void *wxChoice::DoGetItemClientData(int N) const
|
||||||
{
|
{
|
||||||
return (void *)m_dataArray[N];
|
wxCHECK_MSG( N >= 0 && N < m_datas.GetCount(), NULL,
|
||||||
}
|
"invalid index in wxChoice::GetClientData" );
|
||||||
|
|
||||||
void wxChoice::DoSetItemClientData( int N, void* Client_data )
|
return (void *)m_datas[N];
|
||||||
{
|
|
||||||
wxASSERT_MSG( m_dataArray.GetCount() >= N , "invalid client_data array" ) ;
|
|
||||||
|
|
||||||
if ( m_dataArray.GetCount() > N )
|
|
||||||
{
|
|
||||||
m_dataArray[N] = (char*) Client_data ;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
m_dataArray.Add( (char*) Client_data ) ;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxChoice::DoSetItemClientObject( int n, wxClientData* clientData )
|
void wxChoice::DoSetItemClientObject( int n, wxClientData* clientData )
|
||||||
@@ -110,33 +201,9 @@ void wxChoice::DoSetItemClientObject( int n, wxClientData* clientData )
|
|||||||
DoSetItemClientData(n, clientData);
|
DoSetItemClientData(n, clientData);
|
||||||
}
|
}
|
||||||
|
|
||||||
wxClientData* wxChoice::DoGetItemClientObject( int N ) const
|
wxClientData* wxChoice::DoGetItemClientObject( int n ) const
|
||||||
{
|
{
|
||||||
return (wxClientData *) DoGetItemClientData( N ) ;
|
return (wxClientData *)DoGetItemClientData(n);
|
||||||
}
|
|
||||||
|
|
||||||
void wxChoice::Delete(int n)
|
|
||||||
{
|
|
||||||
::DeleteMenuItem( m_macPopUpMenuHandle , n + 1) ;
|
|
||||||
m_strings.Remove( n ) ;
|
|
||||||
m_dataArray.Remove( n ) ;
|
|
||||||
SetControlMaximum( m_macControl , Number()) ;
|
|
||||||
}
|
|
||||||
|
|
||||||
void wxChoice::Clear()
|
|
||||||
{
|
|
||||||
for ( int i = 0 ; i < Number() ; i++ )
|
|
||||||
{
|
|
||||||
::DeleteMenuItem( m_macPopUpMenuHandle , 1 ) ;
|
|
||||||
}
|
|
||||||
m_strings.Clear() ;
|
|
||||||
m_dataArray.Empty() ;
|
|
||||||
SetControlMaximum( m_macControl , Number()) ;
|
|
||||||
}
|
|
||||||
|
|
||||||
int wxChoice::GetSelection() const
|
|
||||||
{
|
|
||||||
return GetControlValue( m_macControl ) -1 ;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxChoice::MacHandleControlClick( ControlHandle control , SInt16 controlpart )
|
void wxChoice::MacHandleControlClick( ControlHandle control , SInt16 controlpart )
|
||||||
@@ -147,30 +214,10 @@ void wxChoice::MacHandleControlClick( ControlHandle control , SInt16 controlpart
|
|||||||
event.SetString(GetStringSelection());
|
event.SetString(GetStringSelection());
|
||||||
ProcessCommand(event);
|
ProcessCommand(event);
|
||||||
}
|
}
|
||||||
|
/*
|
||||||
|
void wxChoice::Command(wxCommandEvent & event)
|
||||||
void wxChoice::SetSelection(int n)
|
|
||||||
{
|
{
|
||||||
SetControlValue( m_macControl , n + 1 ) ;
|
SetSelection (event.GetInt());
|
||||||
|
ProcessCommand (event);
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
int wxChoice::FindString(const wxString& s) const
|
|
||||||
{
|
|
||||||
for( int i = 0 ; i < Number() ; i++ )
|
|
||||||
{
|
|
||||||
if ( GetString( i ) == s )
|
|
||||||
return i ;
|
|
||||||
}
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
wxString wxChoice::GetString(int n) const
|
|
||||||
{
|
|
||||||
return m_strings[n] ;
|
|
||||||
}
|
|
||||||
|
|
||||||
void wxChoice::DoSetSize(int x, int y, int width, int height, int sizeFlags)
|
|
||||||
{
|
|
||||||
wxControl::SetSize( x,y,width,height,sizeFlags ) ;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
@@ -103,7 +103,7 @@ wxDC::~wxDC(void)
|
|||||||
|
|
||||||
void wxDC::MacSetupPort(AGAPortHelper* help) const
|
void wxDC::MacSetupPort(AGAPortHelper* help) const
|
||||||
{
|
{
|
||||||
help->Setup( m_macPort ) ;
|
// help->Setup( m_macPort ) ;
|
||||||
::SetOrigin(-m_macLocalOrigin.h, -m_macLocalOrigin.v);
|
::SetOrigin(-m_macLocalOrigin.h, -m_macLocalOrigin.v);
|
||||||
::ClipRect(&m_macClipRect);
|
::ClipRect(&m_macClipRect);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user