use wxWindowBase::Create() instead of duplicating its code in MacPreControlCreate()

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@23005 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2003-08-18 23:57:34 +00:00
parent 40fa47e0d3
commit b45ed7a273
36 changed files with 158 additions and 90 deletions

View File

@@ -29,6 +29,10 @@ bool wxBitmapButton::Create(wxWindow *parent, wxWindowID id, const wxBitmap& bit
const wxValidator& validator,
const wxString& name)
{
if ( !wxBitmapButtonBase::Create(parent, id, _T(""), pos, size,
style, validator, name) )
return false;
m_bmpNormal = bitmap;
m_marginX = 0;
@@ -39,16 +43,11 @@ bool wxBitmapButton::Create(wxWindow *parent, wxWindowID id, const wxBitmap& bit
int width = size.x;
int height = size.y;
if (id == -1)
m_windowId = NewControlId();
else
m_windowId = id;
if ( width == -1 && bitmap.Ok())
width = bitmap.GetWidth() + 2*m_marginX;
width = bitmap.GetWidth() + 2*m_marginX;
if ( height == -1 && bitmap.Ok())
height = bitmap.GetHeight() + 2*m_marginY;
height = bitmap.GetHeight() + 2*m_marginY;
Rect bounds ;
Str255 title ;

View File

@@ -34,6 +34,9 @@ bool wxButton::Create(wxWindow *parent, wxWindowID id, const wxString& label,
const wxValidator& validator,
const wxString& name)
{
if ( !wxButtonBase::Create(parent, id, pos, size, style, validator, name) )
return false;
Rect bounds ;
Str255 title ;

View File

@@ -29,6 +29,10 @@ bool wxBitmapButton::Create(wxWindow *parent, wxWindowID id, const wxBitmap& bit
const wxValidator& validator,
const wxString& name)
{
if ( !wxBitmapButtonBase::Create(parent, id, _T(""), pos, size,
style, validator, name) )
return false;
m_bmpNormal = bitmap;
m_marginX = 0;
@@ -39,16 +43,11 @@ bool wxBitmapButton::Create(wxWindow *parent, wxWindowID id, const wxBitmap& bit
int width = size.x;
int height = size.y;
if (id == -1)
m_windowId = NewControlId();
else
m_windowId = id;
if ( width == -1 && bitmap.Ok())
width = bitmap.GetWidth() + 2*m_marginX;
width = bitmap.GetWidth() + 2*m_marginX;
if ( height == -1 && bitmap.Ok())
height = bitmap.GetHeight() + 2*m_marginY;
height = bitmap.GetHeight() + 2*m_marginY;
Rect bounds ;
Str255 title ;

View File

@@ -34,6 +34,9 @@ bool wxButton::Create(wxWindow *parent, wxWindowID id, const wxString& label,
const wxValidator& validator,
const wxString& name)
{
if ( !wxButtonBase::Create(parent, id, pos, size, style, validator, name) )
return false;
Rect bounds ;
Str255 title ;

View File

@@ -31,6 +31,9 @@ bool wxCheckBox::Create(wxWindow *parent, wxWindowID id, const wxString& label,
const wxValidator& validator,
const wxString& name)
{
if ( !wxCheckBoxBase::Create(parent, id, pos, size, style, validator, name) )
return false;
Rect bounds ;
Str255 title ;

View File

@@ -183,6 +183,10 @@ bool wxCheckListBox::Create(wxWindow *parent,
const wxValidator& validator,
const wxString &name)
{
if ( !wxCheckListBoxBase::Create(parent, id, pos, size,
n, choices, style, validator, name) )
return false;
m_noItems = 0 ; // this will be increased by our append command
m_selected = 0;

View File

@@ -46,6 +46,9 @@ bool wxChoice::Create(wxWindow *parent, wxWindowID id,
const wxValidator& validator,
const wxString& name)
{
if ( !wxChoiceBase::Create(parent, id, pos, size, style, validator, name) )
return false;
Rect bounds ;
Str255 title ;

View File

@@ -300,23 +300,8 @@ void wxControl::MacPreControlCreate( wxWindow *parent, wxWindowID id, wxString l
const wxString& name , WXRECTPTR outBounds , unsigned char* maclabel )
{
m_label = label ;
SetName(name);
if ( &validator )
SetValidator(validator);
m_windowStyle = style;
parent->AddChild(this);
m_backgroundColour = parent->GetBackgroundColour() ;
m_foregroundColour = parent->GetForegroundColour() ;
if (id == -1)
m_windowId = NewControlId();
else
m_windowId = id;
// These sizes will be adjusted in MacPostControlCreate
// These sizes will be adjusted in MacPostControlCreate
m_width = size.x ;
m_height = size.y ;
m_x = pos.x ;

View File

@@ -29,6 +29,9 @@ bool wxGauge::Create(wxWindow *parent, wxWindowID id,
const wxValidator& validator,
const wxString& name)
{
if ( !wxGaugeBase::Create(parent, id, range, pos, s, style, validator, name) )
return false;
wxSize size = s ;
Rect bounds ;
Str255 title ;

View File

@@ -202,6 +202,9 @@ bool wxListBox::Create(wxWindow *parent, wxWindowID id,
const wxValidator& validator,
const wxString& name)
{
if ( !wxListBoxBase::Create(parent, id, pos, size, style, validator, name) )
return false;
m_noItems = 0 ; // this will be increased by our append command
m_selected = 0;

View File

@@ -175,6 +175,9 @@ bool wxNotebook::Create(wxWindow *parent,
long style,
const wxString& name)
{
if ( !wxNotebookBase::Create(parent, id, pos, size, style, name) )
return false;
Rect bounds ;
Str255 title ;

View File

@@ -102,6 +102,9 @@ bool wxRadioBox::Create(wxWindow *parent, wxWindowID id, const wxString& label,
int majorDim, long style,
const wxValidator& val, const wxString& name)
{
if ( !wxControl::Create(parent, id, pos, size, style, val, name) )
return false;
int i;
m_noItems = n;
@@ -124,8 +127,15 @@ bool wxRadioBox::Create(wxWindow *parent, wxWindowID id, const wxString& label,
for (i = 0; i < n; i++)
{
wxRadioButton *radBtn = new wxRadioButton(this, NewControlId(), wxStripMenuCodes(choices[i]),wxPoint(5,20*i+10),
wxDefaultSize , i == 0 ? wxRB_GROUP : 0 ) ;
wxRadioButton *radBtn = new wxRadioButton
(
this,
wxID_ANY,
wxStripMenuCodes(choices[i]),
wxPoint(5,20*i+10),
wxDefaultSize,
i == 0 ? wxRB_GROUP : 0
);
if ( i == 0 )
m_radioButtonCycle = radBtn ;
// m_radioButtonCycle=radBtn->AddInCycle(m_radioButtonCycle);

View File

@@ -30,6 +30,9 @@ bool wxRadioButton::Create(wxWindow *parent, wxWindowID id,
const wxValidator& validator,
const wxString& name)
{
if ( !wxControl::Create(parent, id, pos, size, style, validator, name) )
return false;
Rect bounds ;
Str255 title ;

View File

@@ -40,24 +40,25 @@ bool wxScrollBar::Create(wxWindow *parent, wxWindowID id,
const wxValidator& validator,
const wxString& name)
{
if (!parent)
return FALSE;
if ( !wxControl::Create(parent, id, pos, size, style, validator, name) )
return FALSE;
Rect bounds ;
Str255 title ;
MacPreControlCreate( parent , id , wxEmptyString , pos , size ,style, validator , name , &bounds , title ) ;
m_macControl = ::NewControl( MAC_WXHWND(parent->MacGetRootWindow()) , &bounds , title , true , 0 , 0 , 100,
kControlScrollBarLiveProc , (long) this ) ;
m_macControl = ::NewControl(MAC_WXHWND(parent->MacGetRootWindow()) ,
&bounds , title , true , 0 , 0 , 100,
kControlScrollBarLiveProc , (long) this) ;
wxASSERT_MSG( (ControlHandle) m_macControl != NULL , wxT("No valid mac control") ) ;
::SetControlAction( (ControlHandle) m_macControl , wxMacLiveScrollbarActionUPP ) ;
MacPostControlCreate() ;
return TRUE;
return TRUE;
}
wxScrollBar::~wxScrollBar()

View File

@@ -57,6 +57,9 @@ bool wxSlider::Create(wxWindow *parent, wxWindowID id,
const wxValidator& validator,
const wxString& name)
{
if ( !wxControl::Create(parent, id, pos, size, style, validator, name) )
return false;
Rect bounds ;
Str255 title ;
SInt16 procID;

View File

@@ -38,6 +38,10 @@ wxSpinButton::wxSpinButton()
bool wxSpinButton::Create(wxWindow *parent, wxWindowID id, const wxPoint& pos, const wxSize& size,
long style, const wxString& name)
{
if ( !wxSpinButtonBase::Create(parent, id, pos, size,
style, wxDefaultValidator, name) )
return false;
m_min = 0;
m_max = 100;

View File

@@ -38,6 +38,10 @@ bool wxStaticBox::Create(wxWindow *parent, wxWindowID id,
long style,
const wxString& name)
{
if ( !wxControl::Create(parent, id, pos, size,
style, wxDefaultValidator, name) )
return false;
Rect bounds ;
Str255 title ;

View File

@@ -49,6 +49,10 @@ bool wxStaticLine::Create( wxWindow *parent,
long style,
const wxString &name)
{
if ( !wxStaticLineBase::Create(parent, id, pos, size,
style, wxDefaultValidator, name) )
return false;
Rect bounds ;
Str255 title ;

View File

@@ -41,22 +41,17 @@ bool wxStaticText::Create(wxWindow *parent, wxWindowID id,
long style,
const wxString& name)
{
SetName(name);
m_backgroundColour = parent->GetBackgroundColour() ;
m_foregroundColour = parent->GetForegroundColour() ;
if ( id == -1 )
m_windowId = (int)NewControlId();
else
m_windowId = id;
m_windowStyle = style;
m_label = wxStripMenuCodes(label) ;
bool ret = wxControl::Create( parent, id, pos, size, style , wxDefaultValidator , name );
if ( !wxControl::Create( parent, id, pos, size, style,
wxDefaultValidator , name ) )
{
return false;
}
SetBestSize( size ) ;
return ret;
return true;
}
const wxString punct = wxT(" ,.-;:!?");

View File

@@ -34,6 +34,10 @@ wxTabCtrl::wxTabCtrl()
bool wxTabCtrl::Create(wxWindow *parent, wxWindowID id, const wxPoint& pos, const wxSize& size,
long style, const wxString& name)
{
if ( !wxControl::Create(parent, id, pos, size,
style, wxDefaultValidator, name) )
return false;
Rect bounds ;
Str255 title ;

View File

@@ -31,6 +31,9 @@ bool wxCheckBox::Create(wxWindow *parent, wxWindowID id, const wxString& label,
const wxValidator& validator,
const wxString& name)
{
if ( !wxCheckBoxBase::Create(parent, id, pos, size, style, validator, name) )
return false;
Rect bounds ;
Str255 title ;

View File

@@ -183,6 +183,10 @@ bool wxCheckListBox::Create(wxWindow *parent,
const wxValidator& validator,
const wxString &name)
{
if ( !wxCheckListBoxBase::Create(parent, id, pos, size,
n, choices, style, validator, name) )
return false;
m_noItems = 0 ; // this will be increased by our append command
m_selected = 0;

View File

@@ -46,6 +46,9 @@ bool wxChoice::Create(wxWindow *parent, wxWindowID id,
const wxValidator& validator,
const wxString& name)
{
if ( !wxChoiceBase::Create(parent, id, pos, size, style, validator, name) )
return false;
Rect bounds ;
Str255 title ;

View File

@@ -300,23 +300,8 @@ void wxControl::MacPreControlCreate( wxWindow *parent, wxWindowID id, wxString l
const wxString& name , WXRECTPTR outBounds , unsigned char* maclabel )
{
m_label = label ;
SetName(name);
if ( &validator )
SetValidator(validator);
m_windowStyle = style;
parent->AddChild(this);
m_backgroundColour = parent->GetBackgroundColour() ;
m_foregroundColour = parent->GetForegroundColour() ;
if (id == -1)
m_windowId = NewControlId();
else
m_windowId = id;
// These sizes will be adjusted in MacPostControlCreate
// These sizes will be adjusted in MacPostControlCreate
m_width = size.x ;
m_height = size.y ;
m_x = pos.x ;

View File

@@ -29,6 +29,9 @@ bool wxGauge::Create(wxWindow *parent, wxWindowID id,
const wxValidator& validator,
const wxString& name)
{
if ( !wxGaugeBase::Create(parent, id, range, pos, s, style, validator, name) )
return false;
wxSize size = s ;
Rect bounds ;
Str255 title ;

View File

@@ -202,6 +202,9 @@ bool wxListBox::Create(wxWindow *parent, wxWindowID id,
const wxValidator& validator,
const wxString& name)
{
if ( !wxListBoxBase::Create(parent, id, pos, size, style, validator, name) )
return false;
m_noItems = 0 ; // this will be increased by our append command
m_selected = 0;

View File

@@ -175,6 +175,9 @@ bool wxNotebook::Create(wxWindow *parent,
long style,
const wxString& name)
{
if ( !wxNotebookBase::Create(parent, id, pos, size, style, name) )
return false;
Rect bounds ;
Str255 title ;

View File

@@ -102,6 +102,9 @@ bool wxRadioBox::Create(wxWindow *parent, wxWindowID id, const wxString& label,
int majorDim, long style,
const wxValidator& val, const wxString& name)
{
if ( !wxControl::Create(parent, id, pos, size, style, val, name) )
return false;
int i;
m_noItems = n;
@@ -124,8 +127,15 @@ bool wxRadioBox::Create(wxWindow *parent, wxWindowID id, const wxString& label,
for (i = 0; i < n; i++)
{
wxRadioButton *radBtn = new wxRadioButton(this, NewControlId(), wxStripMenuCodes(choices[i]),wxPoint(5,20*i+10),
wxDefaultSize , i == 0 ? wxRB_GROUP : 0 ) ;
wxRadioButton *radBtn = new wxRadioButton
(
this,
wxID_ANY,
wxStripMenuCodes(choices[i]),
wxPoint(5,20*i+10),
wxDefaultSize,
i == 0 ? wxRB_GROUP : 0
);
if ( i == 0 )
m_radioButtonCycle = radBtn ;
// m_radioButtonCycle=radBtn->AddInCycle(m_radioButtonCycle);

View File

@@ -30,6 +30,9 @@ bool wxRadioButton::Create(wxWindow *parent, wxWindowID id,
const wxValidator& validator,
const wxString& name)
{
if ( !wxControl::Create(parent, id, pos, size, style, validator, name) )
return false;
Rect bounds ;
Str255 title ;

View File

@@ -40,24 +40,25 @@ bool wxScrollBar::Create(wxWindow *parent, wxWindowID id,
const wxValidator& validator,
const wxString& name)
{
if (!parent)
return FALSE;
if ( !wxControl::Create(parent, id, pos, size, style, validator, name) )
return FALSE;
Rect bounds ;
Str255 title ;
MacPreControlCreate( parent , id , wxEmptyString , pos , size ,style, validator , name , &bounds , title ) ;
m_macControl = ::NewControl( MAC_WXHWND(parent->MacGetRootWindow()) , &bounds , title , true , 0 , 0 , 100,
kControlScrollBarLiveProc , (long) this ) ;
m_macControl = ::NewControl(MAC_WXHWND(parent->MacGetRootWindow()) ,
&bounds , title , true , 0 , 0 , 100,
kControlScrollBarLiveProc , (long) this) ;
wxASSERT_MSG( (ControlHandle) m_macControl != NULL , wxT("No valid mac control") ) ;
::SetControlAction( (ControlHandle) m_macControl , wxMacLiveScrollbarActionUPP ) ;
MacPostControlCreate() ;
return TRUE;
return TRUE;
}
wxScrollBar::~wxScrollBar()

View File

@@ -57,6 +57,9 @@ bool wxSlider::Create(wxWindow *parent, wxWindowID id,
const wxValidator& validator,
const wxString& name)
{
if ( !wxControl::Create(parent, id, pos, size, style, validator, name) )
return false;
Rect bounds ;
Str255 title ;
SInt16 procID;

View File

@@ -38,6 +38,10 @@ wxSpinButton::wxSpinButton()
bool wxSpinButton::Create(wxWindow *parent, wxWindowID id, const wxPoint& pos, const wxSize& size,
long style, const wxString& name)
{
if ( !wxSpinButtonBase::Create(parent, id, pos, size,
style, wxDefaultValidator, name) )
return false;
m_min = 0;
m_max = 100;

View File

@@ -38,6 +38,10 @@ bool wxStaticBox::Create(wxWindow *parent, wxWindowID id,
long style,
const wxString& name)
{
if ( !wxControl::Create(parent, id, pos, size,
style, wxDefaultValidator, name) )
return false;
Rect bounds ;
Str255 title ;

View File

@@ -49,6 +49,10 @@ bool wxStaticLine::Create( wxWindow *parent,
long style,
const wxString &name)
{
if ( !wxStaticLineBase::Create(parent, id, pos, size,
style, wxDefaultValidator, name) )
return false;
Rect bounds ;
Str255 title ;

View File

@@ -41,22 +41,17 @@ bool wxStaticText::Create(wxWindow *parent, wxWindowID id,
long style,
const wxString& name)
{
SetName(name);
m_backgroundColour = parent->GetBackgroundColour() ;
m_foregroundColour = parent->GetForegroundColour() ;
if ( id == -1 )
m_windowId = (int)NewControlId();
else
m_windowId = id;
m_windowStyle = style;
m_label = wxStripMenuCodes(label) ;
bool ret = wxControl::Create( parent, id, pos, size, style , wxDefaultValidator , name );
if ( !wxControl::Create( parent, id, pos, size, style,
wxDefaultValidator , name ) )
{
return false;
}
SetBestSize( size ) ;
return ret;
return true;
}
const wxString punct = wxT(" ,.-;:!?");

View File

@@ -34,6 +34,10 @@ wxTabCtrl::wxTabCtrl()
bool wxTabCtrl::Create(wxWindow *parent, wxWindowID id, const wxPoint& pos, const wxSize& size,
long style, const wxString& name)
{
if ( !wxControl::Create(parent, id, pos, size,
style, wxDefaultValidator, name) )
return false;
Rect bounds ;
Str255 title ;