remove wxWindow::m_needParent and use GTKNeedsParent() which can be overridden in just wxMenuBar (and not set in each and every wxGTK control)

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@45602 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2007-04-23 15:16:06 +00:00
parent fbcb02294f
commit e8375af8ff
39 changed files with 49 additions and 96 deletions

View File

@@ -40,6 +40,10 @@ public:
void SetLayoutDirection(wxLayoutDirection dir);
wxLayoutDirection GetLayoutDirection() const;
// wxMenuBar is not a top level window but it still doesn't need a parent
// window
virtual bool GTKNeedsParent() const { return false; }
void Attach(wxFrame *frame);
// implementation only from now on

View File

@@ -181,6 +181,11 @@ public:
static wxLayoutDirection GTKGetLayout(GtkWidget *widget);
static void GTKSetLayout(GtkWidget *widget, wxLayoutDirection dir);
// return true if this window must have a non-NULL parent, false if it can
// be created without parent (normally only top level windows but in wxGTK
// there is also the exception of wxMenuBar)
virtual bool GTKNeedsParent() const { return !IsTopLevel(); }
protected:
// Override GTKWidgetNeedsMnemonic and return true if your
// needs to set its mnemonic widget, such as for a
@@ -292,7 +297,6 @@ public:
// extra (wxGTK-specific) flags
bool m_needParent:1; // ! wxFrame, wxDialog, wxNotebookPage ?
bool m_noExpose:1; // wxGLCanvas has its own redrawing
bool m_nativeSizeEvent:1; // wxGLCanvas sends wxSizeEvent upon "alloc_size"
bool m_hasScrolling:1;

View File

@@ -199,8 +199,6 @@ bool wxAnimationCtrl::Create( wxWindow *parent, wxWindowID id,
long style,
const wxString& name)
{
m_needParent = true;
if (!PreCreation( parent, pos, size ) ||
!base_type::CreateBase(parent, id, pos, size, style & wxWINDOW_STYLE_MASK,
wxDefaultValidator, name))

View File

@@ -121,8 +121,6 @@ bool wxBitmapButton::Create( wxWindow *parent,
const wxValidator& validator,
const wxString &name )
{
m_needParent = true;
if (!PreCreation( parent, pos, size ) ||
!CreateBase( parent, id, pos, size, style, validator, name ))
{

View File

@@ -97,12 +97,15 @@ wxButton::~wxButton()
{
}
bool wxButton::Create( wxWindow *parent, wxWindowID id, const wxString &label,
const wxPoint &pos, const wxSize &size,
long style, const wxValidator& validator, const wxString &name )
bool wxButton::Create(wxWindow *parent,
wxWindowID id,
const wxString &label,
const wxPoint& pos,
const wxSize& size,
long style,
const wxValidator& validator,
const wxString& name)
{
m_needParent = true;
if (!PreCreation( parent, pos, size ) ||
!CreateBase( parent, id, pos, size, style, validator, name ))
{

View File

@@ -107,7 +107,6 @@ bool wxCheckBox::Create(wxWindow *parent,
const wxValidator& validator,
const wxString &name )
{
m_needParent = true;
m_blockEvent = false;
if (!PreCreation( parent, pos, size ) ||

View File

@@ -94,8 +94,6 @@ bool wxChoice::Create( wxWindow *parent, wxWindowID id,
int n, const wxString choices[],
long style, const wxValidator& validator, const wxString &name )
{
m_needParent = true;
if (!PreCreation( parent, pos, size ) ||
!CreateBase( parent, id, pos, size, style, validator, name ))
{

View File

@@ -61,8 +61,6 @@ bool wxColourButton::Create( wxWindow *parent, wxWindowID id,
{
if (!gtk_check_version(2,4,0))
{
m_needParent = true;
if (!PreCreation( parent, pos, size ) ||
!wxControl::CreateBase(parent, id, pos, size, style, validator, name))
{

View File

@@ -198,7 +198,6 @@ bool wxCollapsiblePane::Create(wxWindow *parent,
return wxGenericCollapsiblePane::Create(parent, id, label,
pos, size, style, val, name);
m_needParent = true;
m_bIgnoreNextChange = false;
if ( !PreCreation( parent, pos, size ) ||

View File

@@ -242,7 +242,6 @@ bool wxComboBox::Create( wxWindow *parent, wxWindowID id, const wxString& value,
const wxString& name )
{
m_ignoreNextUpdate = false;
m_needParent = true;
m_prevSelection = 0;
if (!PreCreation( parent, pos, size ) ||

View File

@@ -37,7 +37,6 @@ IMPLEMENT_DYNAMIC_CLASS(wxControl, wxWindow)
wxControl::wxControl()
{
m_needParent = true;
}
bool wxControl::Create( wxWindow *parent,

View File

@@ -1988,8 +1988,6 @@ bool wxDataViewCtrl::Create(wxWindow *parent, wxWindowID id,
{
Init();
m_needParent = true;
if (!PreCreation( parent, pos, size ) ||
!CreateBase( parent, id, pos, size, style, validator ))
{

View File

@@ -97,7 +97,6 @@ wxDirDialog::wxDirDialog(wxWindow* parent, const wxString& title,
if (!gtk_check_version(2,4,0))
{
m_message = title;
m_needParent = false;
parent = GetParentForModalDialog(parent);

View File

@@ -152,8 +152,6 @@ wxFileDialog::wxFileDialog(wxWindow *parent, const wxString& message,
return;
}
m_needParent = false;
parent = GetParentForModalDialog(parent);
if (!PreCreation(parent, pos, wxDefaultSize) ||

View File

@@ -46,8 +46,6 @@ bool wxFileButton::Create( wxWindow *parent, wxWindowID id,
// VERY IMPORTANT: this code is identic to relative code in wxDirButton;
// if you find a problem here, fix it also in wxDirButton !
m_needParent = true;
if (!PreCreation( parent, pos, size ) ||
!wxControl::CreateBase(parent, id, pos, size, style & wxWINDOW_STYLE_MASK,
validator, name))
@@ -195,8 +193,6 @@ bool wxDirButton::Create( wxWindow *parent, wxWindowID id,
// VERY IMPORTANT: this code is identic to relative code in wxFileButton;
// if you find a problem here, fix it also in wxFileButton !
m_needParent = true;
if (!PreCreation( parent, pos, size ) ||
!wxControl::CreateBase(parent, id, pos, size, style & wxWINDOW_STYLE_MASK,
validator, name))

View File

@@ -86,8 +86,6 @@ IMPLEMENT_DYNAMIC_CLASS(wxFontDialog, wxDialog)
bool wxFontDialog::DoCreate(wxWindow *parent)
{
m_needParent = false;
parent = GetParentForModalDialog(parent);
if (!PreCreation( parent, wxDefaultPosition, wxDefaultSize ) ||

View File

@@ -60,8 +60,6 @@ bool wxFontButton::Create( wxWindow *parent, wxWindowID id,
{
if (!gtk_check_version(2,4,0))
{
m_needParent = true;
if (!PreCreation( parent, pos, size ) ||
!wxControl::CreateBase(parent, id, pos, size, style, validator, name))
{

View File

@@ -31,8 +31,6 @@ bool wxGauge::Create( wxWindow *parent,
const wxValidator& validator,
const wxString& name )
{
m_needParent = true;
if (!PreCreation( parent, pos, size ) ||
!CreateBase( parent, id, pos, size, style, validator, name ))
{

View File

@@ -76,8 +76,6 @@ bool wxHyperlinkCtrl::Create(wxWindow *parent, wxWindowID id,
// do validation checks:
CheckParams(label, url, style);
m_needParent = true;
if (!PreCreation( parent, pos, size ) ||
!CreateBase( parent, id, pos, size, style, wxDefaultValidator, name ))
{

View File

@@ -303,7 +303,6 @@ bool wxListBox::Create( wxWindow *parent, wxWindowID id,
long style, const wxValidator& validator,
const wxString &name )
{
m_needParent = true;
m_blockEvent = false;
if (!PreCreation( parent, pos, size ) ||

View File

@@ -496,8 +496,6 @@ wxMDIClientWindow::~wxMDIClientWindow()
bool wxMDIClientWindow::CreateClient( wxMDIParentFrame *parent, long style )
{
m_needParent = true;
m_insertCallback = (wxInsertChildFunction)wxInsertChildInMDI;
if (!PreCreation( parent, wxDefaultPosition, wxDefaultSize ) ||
@@ -523,4 +521,4 @@ bool wxMDIClientWindow::CreateClient( wxMDIParentFrame *parent, long style )
return true;
}
#endif
#endif // wxUSE_MDI

View File

@@ -140,13 +140,11 @@ IMPLEMENT_DYNAMIC_CLASS(wxMenuBar,wxWindow)
void wxMenuBar::Init(size_t n, wxMenu *menus[], const wxString titles[], long style)
{
// the parent window is known after wxFrame::SetMenu()
m_needParent = false;
m_style = style;
m_invokingWindow = (wxWindow*) NULL;
m_invokingWindow = NULL;
if (!PreCreation( (wxWindow*) NULL, wxDefaultPosition, wxDefaultSize ) ||
!CreateBase( (wxWindow*) NULL, -1, wxDefaultPosition, wxDefaultSize, style, wxDefaultValidator, wxT("menubar") ))
if (!PreCreation( NULL, wxDefaultPosition, wxDefaultSize ) ||
!CreateBase( NULL, -1, wxDefaultPosition, wxDefaultSize, style, wxDefaultValidator, wxT("menubar") ))
{
wxFAIL_MSG( wxT("wxMenuBar creation failed") );
return;

View File

@@ -217,7 +217,6 @@ bool wxNotebook::Create(wxWindow *parent, wxWindowID id,
const wxPoint& pos, const wxSize& size,
long style, const wxString& name )
{
m_needParent = true;
m_insertCallback = (wxInsertChildFunction)wxInsertChildInNotebook;
if ( (style & wxBK_ALIGN_MASK) == wxBK_DEFAULT )

View File

@@ -143,8 +143,6 @@ wxPopupWindow::~wxPopupWindow()
bool wxPopupWindow::Create( wxWindow *parent, int style )
{
m_needParent = false;
if (!PreCreation( parent, wxDefaultPosition, wxDefaultSize ) ||
!CreateBase( parent, -1, wxDefaultPosition, wxDefaultSize, style, wxDefaultValidator, wxT("popup") ))
{

View File

@@ -212,8 +212,6 @@ IMPLEMENT_DYNAMIC_CLASS(wxRadioBox,wxControl)
void wxRadioBox::Init()
{
m_needParent = true;
m_hasFocus =
m_lostFocus = false;
}

View File

@@ -60,15 +60,13 @@ bool wxRadioButton::Create( wxWindow *parent,
const wxValidator& validator,
const wxString& name )
{
m_needParent = TRUE;
m_blockEvent = FALSE;
m_blockEvent = false;
if (!PreCreation( parent, pos, size ) ||
!CreateBase( parent, id, pos, size, style, validator, name ))
{
wxFAIL_MSG( wxT("wxRadioButton creation failed") );
return FALSE;
return false;
}
GSList* radioButtonGroup = NULL;

View File

@@ -129,8 +129,6 @@ bool wxScrollBar::Create(wxWindow *parent, wxWindowID id,
const wxPoint& pos, const wxSize& size,
long style, const wxValidator& validator, const wxString& name )
{
m_needParent = true;
if (!PreCreation( parent, pos, size ) ||
!CreateBase( parent, id, pos, size, style, validator, name ))
{

View File

@@ -281,13 +281,17 @@ wxSlider::wxSlider()
m_needThumbRelease = false;
}
bool wxSlider::Create(wxWindow *parent, wxWindowID id,
int value, int minValue, int maxValue,
const wxPoint& pos, const wxSize& size,
long style, const wxValidator& validator, const wxString& name )
bool wxSlider::Create(wxWindow *parent,
wxWindowID id,
int value,
int minValue,
int maxValue,
const wxPoint& pos,
const wxSize& size,
long style,
const wxValidator& validator,
const wxString& name)
{
m_needParent = true;
if (!PreCreation( parent, pos, size ) ||
!CreateBase( parent, id, pos, size, style, validator, name ))
{

View File

@@ -91,8 +91,6 @@ bool wxSpinButton::Create(wxWindow *parent,
long style,
const wxString& name)
{
m_needParent = true;
wxSize new_size = size,
sizeBest = DoGetBestSize();
new_size.x = sizeBest.x; // override width always

View File

@@ -97,8 +97,6 @@ bool wxSpinCtrl::Create(wxWindow *parent, wxWindowID id,
int min, int max, int initial,
const wxString& name)
{
m_needParent = true;
if (!PreCreation( parent, pos, size ) ||
!CreateBase( parent, id, pos, size, style, wxDefaultValidator, name ))
{

View File

@@ -38,8 +38,6 @@ bool wxStaticBitmap::Create( wxWindow *parent, wxWindowID id, const wxBitmap &bi
const wxPoint &pos, const wxSize &size,
long style, const wxString &name )
{
m_needParent = TRUE;
if (!PreCreation( parent, pos, size ) ||
!CreateBase( parent, id, pos, size, style, wxDefaultValidator, name ))
{

View File

@@ -90,13 +90,11 @@ bool wxStaticBox::Create( wxWindow *parent,
long style,
const wxString& name )
{
m_needParent = TRUE;
if (!PreCreation( parent, pos, size ) ||
!CreateBase( parent, id, pos, size, style, wxDefaultValidator, name ))
{
wxFAIL_MSG( wxT("wxStaticBox creation failed") );
return FALSE;
return false;
}
m_widget = GTKCreateFrame(label);

View File

@@ -38,8 +38,6 @@ bool wxStaticLine::Create( wxWindow *parent, wxWindowID id,
const wxPoint &pos, const wxSize &size,
long style, const wxString &name )
{
m_needParent = TRUE;
if (!PreCreation( parent, pos, size ) ||
!CreateBase( parent, id, pos, size, style, wxDefaultValidator, name ))
{

View File

@@ -52,13 +52,11 @@ bool wxStaticText::Create(wxWindow *parent,
long style,
const wxString &name )
{
m_needParent = TRUE;
if (!PreCreation( parent, pos, size ) ||
!CreateBase( parent, id, pos, size, style, wxDefaultValidator, name ))
{
wxFAIL_MSG( wxT("wxStaticText creation failed") );
return FALSE;
return false;
}
m_widget = gtk_label_new(NULL);

View File

@@ -293,7 +293,6 @@ bool wxToolBar::Create( wxWindow *parent,
long style,
const wxString& name )
{
m_needParent = true;
m_insertCallback = (wxInsertChildFunction)wxInsertChildInToolBar;
if ( !PreCreation( parent, pos, size ) ||

View File

@@ -685,8 +685,6 @@ bool wxTextCtrl::Create( wxWindow *parent,
const wxValidator& validator,
const wxString &name )
{
m_needParent = true;
if (!PreCreation( parent, pos, size ) ||
!CreateBase( parent, id, pos, size, style, validator, name ))
{

View File

@@ -55,8 +55,6 @@ bool wxToggleBitmapButton::Create(wxWindow *parent, wxWindowID id,
const wxValidator& validator,
const wxString &name)
{
m_needParent = true;
m_blockEvent = false;
if (!PreCreation(parent, pos, size) ||
@@ -197,8 +195,6 @@ bool wxToggleButton::Create(wxWindow *parent, wxWindowID id,
const wxValidator& validator,
const wxString &name)
{
m_needParent = true;
m_blockEvent = false;
if (!PreCreation(parent, pos, size) ||

View File

@@ -458,8 +458,6 @@ bool wxTopLevelWindowGTK::Create( wxWindow *parent,
wxTopLevelWindows.Append( this );
m_needParent = false;
if (!PreCreation( parent, pos, size ) ||
!CreateBase( parent, id, pos, size, style, wxDefaultValidator, name ))
{

View File

@@ -2229,7 +2229,6 @@ void wxWindowGTK::Init()
m_sizeSet = false;
m_hasVMT = false;
m_needParent = true;
m_isBeingDeleted = false;
m_showOnIdle= false;
@@ -2452,7 +2451,10 @@ wxWindowGTK::~wxWindowGTK()
bool wxWindowGTK::PreCreation( wxWindowGTK *parent, const wxPoint &pos, const wxSize &size )
{
wxCHECK_MSG( !m_needParent || parent, false, wxT("Need complete parent.") );
if ( GTKNeedsParent() )
{
wxCHECK_MSG( parent, false, wxT("Must have non-NULL parent") );
}
// Use either the given size, or the default if -1 is given.
// See wxWindowBase for these functions.