Remove unneeded wxTLW child inserter function.

Simplify wxFrame child inserter.
Use the same signature for all the child inserters.


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@46206 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Paul Cornett 2007-05-25 05:08:18 +00:00
parent cc67d082f7
commit c821db16e6
9 changed files with 43 additions and 117 deletions

View File

@ -92,7 +92,6 @@ public:
int m_miniEdge, int m_miniEdge,
m_miniTitle; m_miniTitle;
GtkWidget *m_mainWidget; GtkWidget *m_mainWidget;
bool m_insertInClientArea; /* not from within OnCreateXXX */
bool m_fsIsShowing; /* full screen */ bool m_fsIsShowing; /* full screen */
long m_fsSaveGdkFunc, m_fsSaveGdkDecor; long m_fsSaveGdkFunc, m_fsSaveGdkDecor;

View File

@ -18,13 +18,6 @@ struct wxGtkIMData;
WX_DEFINE_EXPORTED_ARRAY_PTR(GdkWindow *, wxArrayGdkWindows); WX_DEFINE_EXPORTED_ARRAY_PTR(GdkWindow *, wxArrayGdkWindows);
//-----------------------------------------------------------------------------
// callback definition for inserting a window (internal)
//-----------------------------------------------------------------------------
class WXDLLIMPEXP_CORE wxWindowGTK;
typedef void (*wxInsertChildFunction)( wxWindowGTK*, wxWindowGTK* );
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// wxWindowGTK // wxWindowGTK
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
@ -61,7 +54,6 @@ public:
virtual void Lower(); virtual void Lower();
virtual bool Show( bool show = true ); virtual bool Show( bool show = true );
virtual void DoEnable( bool enable );
virtual void SetWindowStyleFlag( long style ); virtual void SetWindowStyleFlag( long style );
@ -312,12 +304,13 @@ public:
bool m_showOnIdle:1; // postpone showing the window until idle bool m_showOnIdle:1; // postpone showing the window until idle
protected:
// C++ has no virtual methods in the constrcutor of any class but we need // C++ has no virtual methods in the constrcutor of any class but we need
// different methods of inserting a child window into a wxFrame, // different methods of inserting a child window into a wxFrame,
// wxMDIFrame, wxNotebook etc. this is the callback that will get used. // wxMDIFrame, wxNotebook etc. this is the callback that will get used.
wxInsertChildFunction m_insertCallback; typedef void (*InsertChildFunction)(wxWindowGTK*, wxWindowGTK*);
InsertChildFunction m_insertCallback;
protected:
// implement the base class pure virtuals // implement the base class pure virtuals
virtual void DoClientToScreen( int *x, int *y ) const; virtual void DoClientToScreen( int *x, int *y ) const;
virtual void DoScreenToClient( int *x, int *y ) const; virtual void DoScreenToClient( int *x, int *y ) const;
@ -329,6 +322,7 @@ protected:
int sizeFlags = wxSIZE_AUTO); int sizeFlags = wxSIZE_AUTO);
virtual void DoSetClientSize(int width, int height); virtual void DoSetClientSize(int width, int height);
virtual void DoMoveWindow(int x, int y, int width, int height); virtual void DoMoveWindow(int x, int y, int width, int height);
virtual void DoEnable(bool enable);
#if wxUSE_MENUS_NATIVE #if wxUSE_MENUS_NATIVE
virtual bool DoPopupMenu( wxMenu *menu, int x, int y ); virtual bool DoPopupMenu( wxMenu *menu, int x, int y );

View File

@ -124,14 +124,12 @@ static void gtk_toolbar_detached_callback( GtkWidget *WXUNUSED(widget), GtkWidge
* virtual function here as wxWidgets requires different ways to insert * virtual function here as wxWidgets requires different ways to insert
* a child in container classes. */ * a child in container classes. */
static void wxInsertChildInFrame( wxFrame* parent, wxWindow* child ) static void wxInsertChildInFrame(wxWindow* parent, wxWindow* child)
{ {
wxASSERT( GTK_IS_WIDGET(child->m_widget) ); wxASSERT( GTK_IS_WIDGET(child->m_widget) );
if (!parent->m_insertInClientArea)
{
// These are outside the client area // These are outside the client area
wxFrame* frame = (wxFrame*) parent; wxFrame* frame = wx_static_cast(wxFrame*, parent);
gtk_pizza_put( GTK_PIZZA(frame->m_mainWidget), gtk_pizza_put( GTK_PIZZA(frame->m_mainWidget),
child->m_widget, child->m_widget,
child->m_x, child->m_x,
@ -144,30 +142,18 @@ static void wxInsertChildInFrame( wxFrame* parent, wxWindow* child )
// space when the toolbar is floating // space when the toolbar is floating
if (wxIS_KIND_OF(child,wxToolBar)) if (wxIS_KIND_OF(child,wxToolBar))
{ {
wxToolBar *toolBar = (wxToolBar*) child; if (child->HasFlag(wxTB_DOCKABLE))
if (toolBar->GetWindowStyle() & wxTB_DOCKABLE)
{ {
g_signal_connect (toolBar->m_widget, "child_attached", g_signal_connect (child->m_widget, "child_attached",
G_CALLBACK (gtk_toolbar_attached_callback), G_CALLBACK (gtk_toolbar_attached_callback),
parent); parent);
g_signal_connect (toolBar->m_widget, "child_detached", g_signal_connect (child->m_widget, "child_detached",
G_CALLBACK (gtk_toolbar_detached_callback), G_CALLBACK (gtk_toolbar_detached_callback),
parent); parent);
} }
} }
#endif // wxUSE_TOOLBAR #endif // wxUSE_TOOLBAR
} }
else
{
// These are inside the client area
gtk_pizza_put( GTK_PIZZA(parent->m_wxwindow),
child->m_widget,
child->m_x,
child->m_y,
child->m_width,
child->m_height );
}
}
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// wxFrame creation // wxFrame creation
@ -188,11 +174,7 @@ bool wxFrame::Create( wxWindow *parent,
long style, long style,
const wxString &name ) const wxString &name )
{ {
bool rt = wxTopLevelWindow::Create(parent, id, title, pos, sizeOrig, return wxFrameBase::Create(parent, id, title, pos, sizeOrig, style, name);
style, name);
m_insertCallback = (wxInsertChildFunction) wxInsertChildInFrame;
return rt;
} }
wxFrame::~wxFrame() wxFrame::~wxFrame()
@ -583,11 +565,10 @@ wxToolBar* wxFrame::CreateToolBar( long style, wxWindowID id, const wxString& na
{ {
wxASSERT_MSG( (m_widget != NULL), wxT("invalid frame") ); wxASSERT_MSG( (m_widget != NULL), wxT("invalid frame") );
m_insertInClientArea = false; InsertChildFunction save = m_insertCallback;
m_insertCallback = wxInsertChildInFrame;
m_frameToolBar = wxFrameBase::CreateToolBar( style, id, name ); m_frameToolBar = wxFrameBase::CreateToolBar( style, id, name );
m_insertCallback = save;
m_insertInClientArea = true;
GtkUpdateSize(); GtkUpdateSize();

View File

@ -443,9 +443,10 @@ static void gtk_page_size_callback( GtkWidget *WXUNUSED(widget), GtkAllocation*
// InsertChild callback for wxMDIClientWindow // InsertChild callback for wxMDIClientWindow
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
static void wxInsertChildInMDI( wxMDIClientWindow* parent, wxMDIChildFrame* child ) static void wxInsertChildInMDI(wxWindow* parent, wxWindow* child)
{ {
wxString s = child->GetTitle(); wxMDIChildFrame* child_frame = wx_static_cast(wxMDIChildFrame*, child);
wxString s = child_frame->GetTitle();
if (s.IsNull()) s = _("MDI child"); if (s.IsNull()) s = _("MDI child");
GtkWidget *label_widget = gtk_label_new( s.mbc_str() ); GtkWidget *label_widget = gtk_label_new( s.mbc_str() );
@ -458,9 +459,9 @@ static void wxInsertChildInMDI( wxMDIClientWindow* parent, wxMDIChildFrame* chil
gtk_notebook_append_page( notebook, child->m_widget, label_widget ); gtk_notebook_append_page( notebook, child->m_widget, label_widget );
child->m_page = (GtkNotebookPage*) (g_list_last(notebook->children)->data); child_frame->m_page = (GtkNotebookPage*) (g_list_last(notebook->children)->data);
wxMDIParentFrame *parent_frame = (wxMDIParentFrame*) parent->GetParent(); wxMDIParentFrame *parent_frame = wx_static_cast(wxMDIParentFrame*, parent->GetParent());
parent_frame->m_justInserted = true; parent_frame->m_justInserted = true;
} }
@ -486,7 +487,7 @@ wxMDIClientWindow::~wxMDIClientWindow()
bool wxMDIClientWindow::CreateClient( wxMDIParentFrame *parent, long style ) bool wxMDIClientWindow::CreateClient( wxMDIParentFrame *parent, long style )
{ {
m_insertCallback = (wxInsertChildFunction)wxInsertChildInMDI; m_insertCallback = wxInsertChildInMDI;
if (!PreCreation( parent, wxDefaultPosition, wxDefaultSize ) || if (!PreCreation( parent, wxDefaultPosition, wxDefaultSize ) ||
!CreateBase( parent, wxID_ANY, wxDefaultPosition, wxDefaultSize, style, wxDefaultValidator, wxT("wxMDIClientWindow") )) !CreateBase( parent, wxID_ANY, wxDefaultPosition, wxDefaultSize, style, wxDefaultValidator, wxT("wxMDIClientWindow") ))

View File

@ -159,7 +159,7 @@ gtk_notebook_realized_callback( GtkWidget * WXUNUSED(widget), wxWindow *win )
// InsertChild callback for wxNotebook // InsertChild callback for wxNotebook
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
static void wxInsertChildInNotebook( wxNotebook* parent, wxWindow* child ) static void wxInsertChildInNotebook(wxWindow* parent, wxWindow* child)
{ {
// Hack Alert! (Part I): This sets the notebook as the parent of the child // Hack Alert! (Part I): This sets the notebook as the parent of the child
// widget, and takes care of some details such as updating the state and // widget, and takes care of some details such as updating the state and
@ -217,7 +217,7 @@ bool wxNotebook::Create(wxWindow *parent, wxWindowID id,
const wxPoint& pos, const wxSize& size, const wxPoint& pos, const wxSize& size,
long style, const wxString& name ) long style, const wxString& name )
{ {
m_insertCallback = (wxInsertChildFunction)wxInsertChildInNotebook; m_insertCallback = wxInsertChildInNotebook;
if ( (style & wxBK_ALIGN_MASK) == wxBK_DEFAULT ) if ( (style & wxBK_ALIGN_MASK) == wxBK_DEFAULT )
style |= wxBK_TOP; style |= wxBK_TOP;

View File

@ -110,7 +110,7 @@ gtk_dialog_realized_callback( GtkWidget * WXUNUSED(widget), wxPopupWindow *win )
* virtual function here as wxWidgets requires different ways to insert * virtual function here as wxWidgets requires different ways to insert
* a child in container classes. */ * a child in container classes. */
static void wxInsertChildInDialog( wxPopupWindow* parent, wxWindow* child ) static void wxInsertChildInPopupWin(wxWindow* parent, wxWindow* child)
{ {
gtk_pizza_put( GTK_PIZZA(parent->m_wxwindow), gtk_pizza_put( GTK_PIZZA(parent->m_wxwindow),
child->m_widget, child->m_widget,
@ -158,7 +158,7 @@ bool wxPopupWindow::Create( wxWindow *parent, int style )
// All dialogs should really have this style // All dialogs should really have this style
m_windowStyle |= wxTAB_TRAVERSAL; m_windowStyle |= wxTAB_TRAVERSAL;
m_insertCallback = (wxInsertChildFunction) wxInsertChildInDialog; m_insertCallback = wxInsertChildInPopupWin;
m_widget = gtk_window_new( GTK_WINDOW_POPUP ); m_widget = gtk_window_new( GTK_WINDOW_POPUP );

View File

@ -355,7 +355,7 @@ void gtktoolwidget_size_callback( GtkWidget *widget,
// InsertChild callback for wxToolBar // InsertChild callback for wxToolBar
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
static void wxInsertChildInToolBar( wxToolBar* WXUNUSED(parent), static void wxInsertChildInToolBar( wxWindow* WXUNUSED(parent),
wxWindow* WXUNUSED(child) ) wxWindow* WXUNUSED(child) )
{ {
// we don't do anything here // we don't do anything here
@ -413,7 +413,7 @@ bool wxToolBar::Create( wxWindow *parent,
long style, long style,
const wxString& name ) const wxString& name )
{ {
m_insertCallback = (wxInsertChildFunction)wxInsertChildInToolBar; m_insertCallback = wxInsertChildInToolBar;
if ( !PreCreation( parent, pos, size ) || if ( !PreCreation( parent, pos, size ) ||
!CreateBase( parent, id, pos, size, style, wxDefaultValidator, name )) !CreateBase( parent, id, pos, size, style, wxDefaultValidator, name ))

View File

@ -378,46 +378,6 @@ gtk_window_expose_callback( GtkWidget *widget,
} }
} }
// ----------------------------------------------------------------------------
// wxTopLevelWindowGTK itself
// ----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
// InsertChild for wxTopLevelWindowGTK
//-----------------------------------------------------------------------------
/* Callback for wxTopLevelWindowGTK. This very strange beast has to be used because
* C++ has no virtual methods in a constructor. We have to emulate a
* virtual function here as wxWidgets requires different ways to insert
* a child in container classes. */
static void wxInsertChildInTopLevelWindow( wxTopLevelWindowGTK* parent, wxWindow* child )
{
wxASSERT( GTK_IS_WIDGET(child->m_widget) );
if (!parent->m_insertInClientArea)
{
// these are outside the client area
wxTopLevelWindowGTK* frame = (wxTopLevelWindowGTK*) parent;
gtk_pizza_put( GTK_PIZZA(frame->m_mainWidget),
child->m_widget,
child->m_x,
child->m_y,
child->m_width,
child->m_height );
}
else
{
// these are inside the client area
gtk_pizza_put( GTK_PIZZA(parent->m_wxwindow),
child->m_widget,
child->m_x,
child->m_y,
child->m_width,
child->m_height );
}
}
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// wxTopLevelWindowGTK creation // wxTopLevelWindowGTK creation
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
@ -428,7 +388,6 @@ void wxTopLevelWindowGTK::Init()
m_miniEdge = 0; m_miniEdge = 0;
m_miniTitle = 0; m_miniTitle = 0;
m_mainWidget = (GtkWidget*) NULL; m_mainWidget = (GtkWidget*) NULL;
m_insertInClientArea = true;
m_isIconized = false; m_isIconized = false;
m_fsIsShowing = false; m_fsIsShowing = false;
m_fsSaveFlag = 0; m_fsSaveFlag = 0;
@ -464,8 +423,6 @@ bool wxTopLevelWindowGTK::Create( wxWindow *parent,
m_title = title; m_title = title;
m_insertCallback = (wxInsertChildFunction) wxInsertChildInTopLevelWindow;
// NB: m_widget may be !=NULL if it was created by derived class' Create, // NB: m_widget may be !=NULL if it was created by derived class' Create,
// e.g. in wxTaskBarIconAreaGTK // e.g. in wxTaskBarIconAreaGTK
if (m_widget == NULL) if (m_widget == NULL)

View File

@ -2272,7 +2272,7 @@ void wxWindowGTK::Init()
m_resizing = false; m_resizing = false;
m_insertCallback = (wxInsertChildFunction) NULL; m_insertCallback = wxInsertChildInWindow;
m_hasFocus = false; m_hasFocus = false;
@ -2317,9 +2317,6 @@ bool wxWindowGTK::Create( wxWindow *parent,
return false; return false;
} }
m_insertCallback = wxInsertChildInWindow;
if (!HasFlag(wxHSCROLL) && !HasFlag(wxVSCROLL)) if (!HasFlag(wxHSCROLL) && !HasFlag(wxVSCROLL))
{ {
m_wxwindow = gtk_pizza_new_no_scroll(); m_wxwindow = gtk_pizza_new_no_scroll();
@ -3305,11 +3302,8 @@ bool wxWindowGTK::Reparent( wxWindowBase *newParentBase )
void wxWindowGTK::DoAddChild(wxWindowGTK *child) void wxWindowGTK::DoAddChild(wxWindowGTK *child)
{ {
wxASSERT_MSG( (m_widget != NULL), wxT("invalid window") ); wxASSERT_MSG( (m_widget != NULL), wxT("invalid window") );
wxASSERT_MSG( (child != NULL), wxT("invalid child window") ); wxASSERT_MSG( (child != NULL), wxT("invalid child window") );
wxASSERT_MSG( (m_insertCallback != NULL), wxT("invalid child insertion function") );
/* add to list */ /* add to list */
AddChild( child ); AddChild( child );