replace m_insertCallback with a virtual function, contrary to the old comments a virtual works just fine
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@55354 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -70,6 +70,7 @@ public: // used by GTK callbacks
|
||||
|
||||
private:
|
||||
void OnSize(wxSizeEvent&);
|
||||
virtual void AddChildGTK(wxWindowGTK* child);
|
||||
|
||||
DECLARE_DYNAMIC_CLASS(wxCollapsiblePane)
|
||||
DECLARE_EVENT_TABLE()
|
||||
|
@@ -431,6 +431,7 @@ private:
|
||||
wxDataViewCtrlInternal *m_internal;
|
||||
wxDataViewColumnList m_cols;
|
||||
|
||||
virtual void AddChildGTK(wxWindowGTK* child);
|
||||
void GtkEnableSelectionEvents();
|
||||
void GtkDisableSelectionEvents();
|
||||
|
||||
|
@@ -62,6 +62,7 @@ protected:
|
||||
private:
|
||||
void OnFakeOk( wxCommandEvent &event );
|
||||
void OnSize(wxSizeEvent&);
|
||||
virtual void AddChildGTK(wxWindowGTK* child);
|
||||
|
||||
wxGtkFileChooser m_fc;
|
||||
|
||||
|
@@ -183,6 +183,8 @@ public:
|
||||
virtual bool CreateClient( wxMDIParentFrame *parent, long style = wxVSCROLL | wxHSCROLL );
|
||||
|
||||
private:
|
||||
virtual void AddChildGTK(wxWindowGTK* child);
|
||||
|
||||
DECLARE_DYNAMIC_CLASS(wxMDIClientWindow)
|
||||
};
|
||||
|
||||
|
@@ -8,8 +8,8 @@
|
||||
// Licence: wxWindows licence
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef __GTKNOTEBOOKH__
|
||||
#define __GTKNOTEBOOKH__
|
||||
#ifndef _WX_GTKNOTEBOOK_H_
|
||||
#define _WX_GTKNOTEBOOK_H_
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// internal class
|
||||
@@ -135,9 +135,10 @@ private:
|
||||
// the padding set by SetPadding()
|
||||
int m_padding;
|
||||
|
||||
virtual void AddChildGTK(wxWindowGTK* child);
|
||||
|
||||
DECLARE_DYNAMIC_CLASS(wxNotebook)
|
||||
DECLARE_EVENT_TABLE()
|
||||
};
|
||||
|
||||
#endif
|
||||
// __GTKNOTEBOOKH__
|
||||
#endif // _WX_GTKNOTEBOOK_H_
|
||||
|
@@ -41,6 +41,8 @@ protected:
|
||||
virtual void DoMoveWindow(int x, int y, int width, int height);
|
||||
|
||||
private:
|
||||
virtual void AddChildGTK(wxWindowGTK* child);
|
||||
|
||||
#ifdef __WXUNIVERSAL__
|
||||
DECLARE_EVENT_TABLE()
|
||||
#endif
|
||||
|
@@ -86,6 +86,7 @@ private:
|
||||
void Init();
|
||||
void GtkSetStyle();
|
||||
GSList* GetRadioGroup(size_t pos);
|
||||
virtual void AddChildGTK(wxWindowGTK* child);
|
||||
|
||||
GtkToolbar* m_toolbar;
|
||||
GtkTooltips* m_tooltips;
|
||||
|
@@ -139,9 +139,7 @@ public:
|
||||
bool PreCreation( wxWindowGTK *parent, const wxPoint &pos, const wxSize &size );
|
||||
void PostCreation();
|
||||
|
||||
// Internal addition of child windows. differs from class
|
||||
// to class not by using virtual functions but by using
|
||||
// the m_insertCallback.
|
||||
// Internal addition of child windows
|
||||
void DoAddChild(wxWindowGTK *child);
|
||||
|
||||
// This methods sends wxPaintEvents to the window. It reads the
|
||||
@@ -303,12 +301,6 @@ public:
|
||||
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
|
||||
// different methods of inserting a child window into a wxFrame,
|
||||
// wxMDIFrame, wxNotebook etc. this is the callback that will get used.
|
||||
typedef void (*InsertChildFunction)(wxWindowGTK*, wxWindowGTK*);
|
||||
InsertChildFunction m_insertCallback;
|
||||
|
||||
// implement the base class pure virtuals
|
||||
virtual void DoClientToScreen( int *x, int *y ) const;
|
||||
virtual void DoScreenToClient( int *x, int *y ) const;
|
||||
@@ -384,6 +376,7 @@ private:
|
||||
// return true if we scrolled, false otherwise (on error or simply if we
|
||||
// are already at the end)
|
||||
bool DoScrollByUnits(ScrollDir dir, ScrollUnit unit, int units);
|
||||
virtual void AddChildGTK(wxWindowGTK* child);
|
||||
|
||||
|
||||
DECLARE_DYNAMIC_CLASS(wxWindowGTK)
|
||||
|
@@ -148,15 +148,14 @@ gtk_collapsiblepane_expanded_callback(GObject * WXUNUSED(object),
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_collapsiblepane_insert_callback(wxWindowGTK* parent, wxWindowGTK* child)
|
||||
void wxCollapsiblePane::AddChildGTK(wxWindowGTK* child)
|
||||
{
|
||||
// this callback should be used only once to insert the "pane" into the
|
||||
// should be used only once to insert the "pane" into the
|
||||
// GtkExpander widget. wxGenericCollapsiblePane::DoAddChild() will check if
|
||||
// it has been called only once (and in any case we would get a warning
|
||||
// from the following call as GtkExpander is a GtkBin and can contain only
|
||||
// a single child!).
|
||||
gtk_container_add (GTK_CONTAINER (parent->m_widget), child->m_widget);
|
||||
gtk_container_add(GTK_CONTAINER(m_widget), child->m_widget);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
@@ -197,10 +196,6 @@ bool wxCollapsiblePane::Create(wxWindow *parent,
|
||||
g_signal_connect(m_widget, "notify::expanded",
|
||||
G_CALLBACK(gtk_collapsiblepane_expanded_callback), this);
|
||||
|
||||
// before creating m_pPane, we need to makesure our own insert callback
|
||||
// will be used
|
||||
m_insertCallback = gtk_collapsiblepane_insert_callback;
|
||||
|
||||
// this the real "pane"
|
||||
m_pPane = new wxPanel(this, wxID_ANY, wxDefaultPosition, wxDefaultSize,
|
||||
wxTAB_TRAVERSAL|wxNO_BORDER);
|
||||
|
@@ -3439,14 +3439,9 @@ wxdataview_row_collapsed_callback( GtkTreeView* WXUNUSED(treeview), GtkTreeIter*
|
||||
// wxDataViewCtrl
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// InsertChild for wxDataViewCtrl
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
static void wxInsertChildInDataViewCtrl( wxWindowGTK* parent, wxWindowGTK* child )
|
||||
void wxDataViewCtrl::AddChildGTK(wxWindowGTK* child)
|
||||
{
|
||||
wxDataViewCtrl * dvc = (wxDataViewCtrl*) parent;
|
||||
GtkWidget *treeview = dvc->GtkGetTreeView();
|
||||
GtkWidget* treeview = GtkGetTreeView();
|
||||
|
||||
// Insert widget in GtkTreeView
|
||||
if (GTK_WIDGET_REALIZED(treeview))
|
||||
@@ -3607,8 +3602,6 @@ bool wxDataViewCtrl::Create(wxWindow *parent, wxWindowID id,
|
||||
return false;
|
||||
}
|
||||
|
||||
m_insertCallback = wxInsertChildInDataViewCtrl;
|
||||
|
||||
m_widget = gtk_scrolled_window_new (NULL, NULL);
|
||||
g_object_ref(m_widget);
|
||||
|
||||
|
@@ -145,12 +145,12 @@ static void extra_widget_size_request(GtkWidget*, GtkRequisition* req, wxWindow*
|
||||
}
|
||||
}
|
||||
|
||||
static void wxInsertChildInFileDialog(wxWindow* parent, wxWindow* child)
|
||||
void wxFileDialog::AddChildGTK(wxWindowGTK* child)
|
||||
{
|
||||
g_signal_connect_after(child->m_widget, "size_request",
|
||||
G_CALLBACK(extra_widget_size_request), child);
|
||||
gtk_file_chooser_set_extra_widget(
|
||||
GTK_FILE_CHOOSER(parent->m_widget), child->m_widget);
|
||||
GTK_FILE_CHOOSER(m_widget), child->m_widget);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
@@ -173,7 +173,6 @@ wxFileDialog::wxFileDialog(wxWindow *parent, const wxString& message,
|
||||
const wxString& name)
|
||||
: wxFileDialogBase()
|
||||
{
|
||||
m_insertCallback = wxInsertChildInFileDialog;
|
||||
parent = GetParentForModalDialog(parent);
|
||||
|
||||
if (!wxFileDialogBase::Create(parent, message, defaultDir, defaultFileName,
|
||||
|
@@ -402,11 +402,7 @@ void wxMDIChildFrame::SetTitle( const wxString &title )
|
||||
gtk_notebook_set_tab_label_text(notebook, m_widget, wxGTK_CONV( title ) );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// InsertChild callback for wxMDIClientWindow
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
static void wxInsertChildInMDI(wxWindow* parent, wxWindow* child)
|
||||
void wxMDIClientWindow::AddChildGTK(wxWindowGTK* child)
|
||||
{
|
||||
wxMDIChildFrame* child_frame = wx_static_cast(wxMDIChildFrame*, child);
|
||||
wxString s = child_frame->GetTitle();
|
||||
@@ -415,13 +411,13 @@ static void wxInsertChildInMDI(wxWindow* parent, wxWindow* child)
|
||||
GtkWidget *label_widget = gtk_label_new( s.mbc_str() );
|
||||
gtk_misc_set_alignment( GTK_MISC(label_widget), 0.0, 0.5 );
|
||||
|
||||
GtkNotebook *notebook = GTK_NOTEBOOK(parent->m_widget);
|
||||
GtkNotebook* notebook = GTK_NOTEBOOK(m_widget);
|
||||
|
||||
gtk_notebook_append_page( notebook, child->m_widget, label_widget );
|
||||
|
||||
child_frame->m_page = (GtkNotebookPage*) (g_list_last(notebook->children)->data);
|
||||
|
||||
wxMDIParentFrame *parent_frame = wx_static_cast(wxMDIParentFrame*, parent->GetParent());
|
||||
wxMDIParentFrame* parent_frame = wx_static_cast(wxMDIParentFrame*, GetParent());
|
||||
parent_frame->m_justInserted = true;
|
||||
}
|
||||
|
||||
@@ -447,8 +443,6 @@ wxMDIClientWindow::~wxMDIClientWindow()
|
||||
|
||||
bool wxMDIClientWindow::CreateClient( wxMDIParentFrame *parent, long style )
|
||||
{
|
||||
m_insertCallback = wxInsertChildInMDI;
|
||||
|
||||
if (!PreCreation( parent, wxDefaultPosition, wxDefaultSize ) ||
|
||||
!CreateBase( parent, wxID_ANY, wxDefaultPosition, wxDefaultSize, style, wxDefaultValidator, wxT("wxMDIClientWindow") ))
|
||||
{
|
||||
|
@@ -104,7 +104,7 @@ static void event_after(GtkNotebook* widget, GdkEvent*, wxNotebook* win)
|
||||
// InsertChild callback for wxNotebook
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
static void wxInsertChildInNotebook(wxWindow* parent, wxWindow* child)
|
||||
void wxNotebook::AddChildGTK(wxWindowGTK* 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
|
||||
@@ -114,7 +114,7 @@ static void wxInsertChildInNotebook(wxWindow* parent, wxWindow* child)
|
||||
// incorrect sizes since the widget's style context is not fully known.
|
||||
// See bug #901694 for details
|
||||
// (http://sourceforge.net/tracker/?func=detail&aid=901694&group_id=9863&atid=109863)
|
||||
gtk_widget_set_parent(child->m_widget, parent->m_widget);
|
||||
gtk_widget_set_parent(child->m_widget, m_widget);
|
||||
|
||||
// NOTE: This should be considered a temporary workaround until we can
|
||||
// work out the details and implement delaying the setting of the initial
|
||||
@@ -160,8 +160,6 @@ bool wxNotebook::Create(wxWindow *parent, wxWindowID id,
|
||||
const wxPoint& pos, const wxSize& size,
|
||||
long style, const wxString& name )
|
||||
{
|
||||
m_insertCallback = wxInsertChildInNotebook;
|
||||
|
||||
if ( (style & wxBK_ALIGN_MASK) == wxBK_DEFAULT )
|
||||
style |= wxBK_TOP;
|
||||
|
||||
@@ -377,7 +375,7 @@ bool wxNotebook::InsertPage( size_t position,
|
||||
wxCHECK_MSG( position <= GetPageCount(), false,
|
||||
_T("invalid page index in wxNotebookPage::InsertPage()") );
|
||||
|
||||
// Hack Alert! (Part II): See above in wxInsertChildInNotebook callback
|
||||
// Hack Alert! (Part II): See above in wxNotebook::AddChildGTK
|
||||
// why this has to be done.
|
||||
gtk_widget_unparent(win->m_widget);
|
||||
|
||||
|
@@ -98,27 +98,18 @@ gtk_dialog_realized_callback( GtkWidget * WXUNUSED(widget), wxPopupWindow *win )
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// InsertChild for wxPopupWindow
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
/* Callback for wxFrame. 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 wxInsertChildInPopupWin(wxWindowGTK* parent, wxWindowGTK* child)
|
||||
void wxPopupWindow::AddChildGTK(wxWindowGTK* child)
|
||||
{
|
||||
gtk_widget_set_size_request(
|
||||
child->m_widget, child->m_width, child->m_height);
|
||||
gtk_fixed_put(
|
||||
GTK_FIXED(parent->m_wxwindow), child->m_widget, child->m_x, child->m_y);
|
||||
GTK_FIXED(m_wxwindow), child->m_widget, child->m_x, child->m_y);
|
||||
|
||||
if (parent->HasFlag(wxTAB_TRAVERSAL))
|
||||
if (HasFlag(wxTAB_TRAVERSAL))
|
||||
{
|
||||
/* we now allow a window to get the focus as long as it
|
||||
doesn't have any children. */
|
||||
GTK_WIDGET_UNSET_FLAGS( parent->m_wxwindow, GTK_CAN_FOCUS );
|
||||
GTK_WIDGET_UNSET_FLAGS(m_wxwindow, GTK_CAN_FOCUS);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -151,8 +142,6 @@ bool wxPopupWindow::Create( wxWindow *parent, int style )
|
||||
// All dialogs should really have this style
|
||||
m_windowStyle |= wxTAB_TRAVERSAL;
|
||||
|
||||
m_insertCallback = wxInsertChildInPopupWin;
|
||||
|
||||
m_widget = gtk_window_new( GTK_WINDOW_POPUP );
|
||||
g_object_ref(m_widget);
|
||||
|
||||
|
@@ -242,20 +242,15 @@ arrow_button_press_event(GtkToggleButton* button, GdkEventButton* event, wxToolB
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// InsertChild callback for wxToolBar
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
static void wxInsertChildInToolBar(wxWindow* parent, wxWindow* child)
|
||||
void wxToolBar::AddChildGTK(wxWindowGTK* child)
|
||||
{
|
||||
GtkWidget* align = gtk_alignment_new(0.5, 0.5, 0, 0);
|
||||
gtk_widget_show(align);
|
||||
gtk_container_add(GTK_CONTAINER(align), child->m_widget);
|
||||
GtkToolItem* item = gtk_tool_item_new();
|
||||
gtk_container_add(GTK_CONTAINER(item), align);
|
||||
wxToolBar* tbar = static_cast<wxToolBar*>(parent);
|
||||
// position will be corrected in DoInsertTool if necessary
|
||||
gtk_toolbar_insert(GTK_TOOLBAR(GTK_BIN(tbar->m_widget)->child), item, -1);
|
||||
gtk_toolbar_insert(GTK_TOOLBAR(GTK_BIN(m_widget)->child), item, -1);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
@@ -370,8 +365,6 @@ bool wxToolBar::Create( wxWindow *parent,
|
||||
long style,
|
||||
const wxString& name )
|
||||
{
|
||||
m_insertCallback = wxInsertChildInToolBar;
|
||||
|
||||
if ( !PreCreation( parent, pos, size ) ||
|
||||
!CreateBase( parent, id, pos, size, style, wxDefaultValidator, name ))
|
||||
{
|
||||
@@ -532,7 +525,7 @@ bool wxToolBar::DoInsertTool(size_t pos, wxToolBarToolBase *toolBase)
|
||||
case wxTOOL_STYLE_CONTROL:
|
||||
wxWindow* control = tool->GetControl();
|
||||
if (control->m_widget->parent == NULL)
|
||||
wxInsertChildInToolBar(this, control);
|
||||
AddChildGTK(control);
|
||||
tool->m_item = GTK_TOOL_ITEM(control->m_widget->parent->parent);
|
||||
if (gtk_toolbar_get_item_index(m_toolbar, tool->m_item) != int(pos))
|
||||
{
|
||||
|
@@ -1905,29 +1905,18 @@ wxWindow *wxWindowBase::DoFindFocus()
|
||||
return wx_static_cast(wxWindow*, focus);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// InsertChild for wxWindowGTK.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
/* Callback for wxWindowGTK. 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 wxNotebook requires a different way to insert
|
||||
* a child in it. I had opted for creating a wxNotebookPage window class
|
||||
* which would have made this superfluous (such in the MDI window system),
|
||||
* but no-one was listening to me... */
|
||||
|
||||
static void wxInsertChildInWindow( wxWindowGTK* parent, wxWindowGTK* child )
|
||||
void wxWindowGTK::AddChildGTK(wxWindowGTK* child)
|
||||
{
|
||||
/* the window might have been scrolled already, do we
|
||||
have to adapt the position */
|
||||
wxPizza* pizza = WX_PIZZA(parent->m_wxwindow);
|
||||
wxPizza* pizza = WX_PIZZA(m_wxwindow);
|
||||
child->m_x += pizza->m_scroll_x;
|
||||
child->m_y += pizza->m_scroll_y;
|
||||
|
||||
gtk_widget_set_size_request(
|
||||
child->m_widget, child->m_width, child->m_height);
|
||||
gtk_fixed_put(
|
||||
GTK_FIXED(parent->m_wxwindow), child->m_widget, child->m_x, child->m_y);
|
||||
GTK_FIXED(m_wxwindow), child->m_widget, child->m_x, child->m_y);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
@@ -2012,8 +2001,6 @@ void wxWindowGTK::Init()
|
||||
m_oldClientWidth =
|
||||
m_oldClientHeight = 0;
|
||||
|
||||
m_insertCallback = wxInsertChildInWindow;
|
||||
|
||||
m_clipPaintRegion = false;
|
||||
|
||||
m_needsStyleChange = false;
|
||||
@@ -3100,13 +3087,8 @@ bool wxWindowGTK::Reparent( wxWindowBase *newParentBase )
|
||||
|
||||
wxASSERT( GTK_IS_WIDGET(m_widget) );
|
||||
|
||||
/* prevent GTK from deleting the widget arbitrarily */
|
||||
gtk_widget_ref( m_widget );
|
||||
|
||||
if (oldParent)
|
||||
{
|
||||
gtk_container_remove( GTK_CONTAINER(m_widget->parent), m_widget );
|
||||
}
|
||||
|
||||
wxASSERT( GTK_IS_WIDGET(m_widget) );
|
||||
|
||||
@@ -3117,14 +3099,10 @@ bool wxWindowGTK::Reparent( wxWindowBase *newParentBase )
|
||||
m_showOnIdle = true;
|
||||
gtk_widget_hide( m_widget );
|
||||
}
|
||||
|
||||
/* insert GTK representation */
|
||||
(*(newParent->m_insertCallback))(newParent, this);
|
||||
newParent->AddChildGTK(this);
|
||||
}
|
||||
|
||||
/* reverse: prevent GTK from deleting the widget arbitrarily */
|
||||
gtk_widget_unref( m_widget );
|
||||
|
||||
SetLayoutDirection(wxLayout_Default);
|
||||
|
||||
return true;
|
||||
@@ -3139,7 +3117,7 @@ void wxWindowGTK::DoAddChild(wxWindowGTK *child)
|
||||
AddChild( child );
|
||||
|
||||
/* insert GTK representation */
|
||||
(*m_insertCallback)(this, child);
|
||||
AddChildGTK(child);
|
||||
}
|
||||
|
||||
void wxWindowGTK::AddChild(wxWindowBase *child)
|
||||
|
Reference in New Issue
Block a user