private:
void OnSize(wxSizeEvent&);
+ virtual void AddChildGTK(wxWindowGTK* child);
DECLARE_DYNAMIC_CLASS(wxCollapsiblePane)
DECLARE_EVENT_TABLE()
wxDataViewCtrlInternal *m_internal;
wxDataViewColumnList m_cols;
+ virtual void AddChildGTK(wxWindowGTK* child);
void GtkEnableSelectionEvents();
void GtkDisableSelectionEvents();
private:
void OnFakeOk( wxCommandEvent &event );
void OnSize(wxSizeEvent&);
+ virtual void AddChildGTK(wxWindowGTK* child);
wxGtkFileChooser m_fc;
virtual bool CreateClient( wxMDIParentFrame *parent, long style = wxVSCROLL | wxHSCROLL );
private:
+ virtual void AddChildGTK(wxWindowGTK* child);
+
DECLARE_DYNAMIC_CLASS(wxMDIClientWindow)
};
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
-#ifndef __GTKNOTEBOOKH__
-#define __GTKNOTEBOOKH__
+#ifndef _WX_GTKNOTEBOOK_H_
+#define _WX_GTKNOTEBOOK_H_
//-----------------------------------------------------------------------------
// internal class
// 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_
virtual void DoMoveWindow(int x, int y, int width, int height);
private:
+ virtual void AddChildGTK(wxWindowGTK* child);
+
#ifdef __WXUNIVERSAL__
DECLARE_EVENT_TABLE()
#endif
void Init();
void GtkSetStyle();
GSList* GetRadioGroup(size_t pos);
+ virtual void AddChildGTK(wxWindowGTK* child);
GtkToolbar* m_toolbar;
GtkTooltips* m_tooltips;
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
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;
// 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)
}
}
-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);
}
//-----------------------------------------------------------------------------
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);
// 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))
return false;
}
- m_insertCallback = wxInsertChildInDataViewCtrl;
-
m_widget = gtk_scrolled_window_new (NULL, NULL);
g_object_ref(m_widget);
}
}
-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);
}
//-----------------------------------------------------------------------------
const wxString& name)
: wxFileDialogBase()
{
- m_insertCallback = wxInsertChildInFileDialog;
parent = GetParentForModalDialog(parent);
if (!wxFileDialogBase::Create(parent, message, defaultDir, defaultFileName,
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();
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;
}
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") ))
{
// 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
// 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
const wxPoint& pos, const wxSize& size,
long style, const wxString& name )
{
- m_insertCallback = wxInsertChildInNotebook;
-
if ( (style & wxBK_ALIGN_MASK) == wxBK_DEFAULT )
style |= wxBK_TOP;
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);
}
}
-//-----------------------------------------------------------------------------
-// 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);
}
}
// 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);
}
}
-//-----------------------------------------------------------------------------
-// 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);
}
// ----------------------------------------------------------------------------
long style,
const wxString& name )
{
- m_insertCallback = wxInsertChildInToolBar;
-
if ( !PreCreation( parent, pos, size ) ||
!CreateBase( parent, id, pos, size, style, wxDefaultValidator, name ))
{
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))
{
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);
}
//-----------------------------------------------------------------------------
m_oldClientWidth =
m_oldClientHeight = 0;
- m_insertCallback = wxInsertChildInWindow;
-
m_clipPaintRegion = false;
m_needsStyleChange = false;
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) );
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;
AddChild( child );
/* insert GTK representation */
- (*m_insertCallback)(this, child);
+ AddChildGTK(child);
}
void wxWindowGTK::AddChild(wxWindowBase *child)