// implementation
virtual void GtkOnSize( int x, int y, int width, int height );
- virtual wxPoint GetClientAreaOrigin() const;
void DoMenuUpdates();
void DoMenuUpdates(wxMenu* menu, wxWindow* focusWin);
virtual void OnInternalIdle();
wxString m_title;
wxIcon m_icon;
int m_miniEdge,m_miniTitle;
+ GtkWidget *m_mainWidget;
protected:
virtual void DoSetSize(int x, int y,
wxString GetTitle() const { return m_title; }
// no maximize etc
- virtual void Maximize(void) {}
+ virtual void Maximize(bool WXUNUSED(maximize)) {}
virtual void Restore(void) {}
void OnActivate( wxActivateEvent &event );
// implementation
- virtual wxPoint GetClientAreaOrigin() const;
- virtual void AdjustForParentClientOrigin( int& x, int& y, int sizeFlags );
-
bool HasVMT();
+ /* I don't want users to override what's done in OnIdle */
virtual void OnInternalIdle();
- // For compatibility across platforms (not in event table)
+ /* For compatibility across platforms (not in event table) */
void OnIdle(wxIdleEvent& WXUNUSED(event)) {};
/* used by all classes in the widget creation process */
// implementation
virtual void GtkOnSize( int x, int y, int width, int height );
- virtual wxPoint GetClientAreaOrigin() const;
void DoMenuUpdates();
void DoMenuUpdates(wxMenu* menu, wxWindow* focusWin);
virtual void OnInternalIdle();
wxString m_title;
wxIcon m_icon;
int m_miniEdge,m_miniTitle;
+ GtkWidget *m_mainWidget;
protected:
virtual void DoSetSize(int x, int y,
wxString GetTitle() const { return m_title; }
// no maximize etc
- virtual void Maximize(void) {}
+ virtual void Maximize(bool WXUNUSED(maximize)) {}
virtual void Restore(void) {}
void OnActivate( wxActivateEvent &event );
// implementation
- virtual wxPoint GetClientAreaOrigin() const;
- virtual void AdjustForParentClientOrigin( int& x, int& y, int sizeFlags );
-
bool HasVMT();
+ /* I don't want users to override what's done in OnIdle */
virtual void OnInternalIdle();
- // For compatibility across platforms (not in event table)
+ /* For compatibility across platforms (not in event table) */
void OnIdle(wxIdleEvent& WXUNUSED(event)) {};
/* used by all classes in the widget creation process */
return FALSE;
}
+//-----------------------------------------------------------------------------
+// InsertChild for wxFrame
+//-----------------------------------------------------------------------------
+
+/* 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 wxWindows requires different ways to insert
+ * a child in container classes. */
+
+static void wxInsertChildInFrame( wxWindow* parent, wxWindow* child )
+{
+ if (wxIS_KIND_OF(child,wxToolBar) || wxIS_KIND_OF(child,wxMenuBar))
+ {
+ /* these are outside the client area */
+ wxFrame* frame = (wxFrame*) parent;
+ gtk_myfixed_put( GTK_MYFIXED(frame->m_mainWidget),
+ GTK_WIDGET(child->m_widget),
+ child->m_x,
+ child->m_y );
+ }
+ else
+ {
+ /* these are inside the client area */
+ gtk_myfixed_put( GTK_MYFIXED(parent->m_wxwindow),
+ GTK_WIDGET(child->m_widget),
+ child->m_x,
+ child->m_y );
+ }
+
+ gtk_widget_set_usize( GTK_WIDGET(child->m_widget),
+ child->m_width,
+ child->m_height );
+
+ /* resize on OnInternalIdle */
+ parent->m_sizeSet = FALSE;
+
+ if (parent->m_windowStyle & 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 );
+ }
+}
+
//-----------------------------------------------------------------------------
// wxFrame
//-----------------------------------------------------------------------------
PreCreation( parent, id, pos, size, style, name );
m_title = title;
+
+ m_insertCallback = wxInsertChildInFrame;
GtkWindowType win_type = GTK_WINDOW_TOPLEVEL;
if (style & wxSIMPLE_BORDER) win_type = GTK_WINDOW_POPUP;
gtk_signal_connect( GTK_OBJECT(m_widget), "delete_event",
GTK_SIGNAL_FUNC(gtk_frame_delete_callback), (gpointer)this );
+ /* m_mainWidget holds the toolbar, the menubar and the client area */
+ m_mainWidget = gtk_myfixed_new();
+ gtk_widget_show( m_mainWidget );
+ GTK_WIDGET_UNSET_FLAGS( m_mainWidget, GTK_CAN_FOCUS );
+ gtk_container_add( GTK_CONTAINER(m_widget), m_mainWidget );
+ gtk_widget_realize( m_mainWidget );
+
+ /* m_wxwindow only represents the client area without toolbar and menubar */
m_wxwindow = gtk_myfixed_new();
gtk_widget_show( m_wxwindow );
GTK_WIDGET_UNSET_FLAGS( m_wxwindow, GTK_CAN_FOCUS );
-
- gtk_container_add( GTK_CONTAINER(m_widget), m_wxwindow );
+ gtk_container_add( GTK_CONTAINER(m_mainWidget), m_wxwindow );
if (m_parent) m_parent->AddChild( this );
{
/* by calling GtkOnSize here, we don't have to call
either after showing the frame, which would entail
- much ugly flicker nor from within the size_allocate
+ much ugly flicker or from within the size_allocate
handler, because GTK 1.1.X forbids that. */
GtkOnSize( m_x, m_y, m_width, m_height );
return TRUE;
}
-wxPoint wxFrame::GetClientAreaOrigin() const
-{
- wxPoint pt( m_miniEdge, m_miniEdge + m_miniTitle );
- if (m_frameMenuBar)
- {
- int h = 0;
- m_frameMenuBar->GetSize( (int*)NULL, &h );
- pt.y += h;
- }
- if (m_frameToolBar)
- {
- int h = 0;
- m_frameToolBar->GetSize( (int*)NULL, &h );
- pt.y += h;
- }
- return pt;
-}
-
void wxFrame::DoSetSize( int x, int y, int width, int height, int sizeFlags )
{
wxASSERT_MSG( (m_widget != NULL), "invalid frame" );
if ((m_maxWidth != -1) && (m_width > m_maxWidth)) m_width = m_maxWidth;
if ((m_maxHeight != -1) && (m_height > m_maxHeight)) m_height = m_maxHeight;
- /* this emulates the new wxMSW behaviour of placing all
- * frame-subwindows (menu, toolbar..) on one native window
+ /* I revert back to wxGTK's original behaviour. m_mainWidget holds the
+ * menubar, the toolbar and the client area, which is represented by
+ * m_wxwindow.
* this hurts in the eye, but I don't want to call SetSize()
* because I don't want to call any non-native functions here. */
+
+ int client_area_y_offset = 0;
if (m_frameMenuBar)
{
m_frameMenuBar->m_width = ww;
m_frameMenuBar->m_height = hh;
- gtk_myfixed_move( GTK_MYFIXED(m_wxwindow), m_frameMenuBar->m_widget, xx, yy );
+ gtk_myfixed_move( GTK_MYFIXED(m_mainWidget), m_frameMenuBar->m_widget, xx, yy );
gtk_widget_set_usize( m_frameMenuBar->m_widget, ww, hh );
+
+ client_area_y_offset += hh;
}
if (m_frameToolBar)
m_frameToolBar->m_height = hh;
m_frameToolBar->m_width = ww;
- gtk_myfixed_move( GTK_MYFIXED(m_wxwindow), m_frameToolBar->m_widget, xx, yy );
+ gtk_myfixed_move( GTK_MYFIXED(m_mainWidget), m_frameToolBar->m_widget, xx, yy );
gtk_widget_set_usize( m_frameToolBar->m_widget, ww, hh );
+
+ client_area_y_offset += hh;
}
+
+ gtk_myfixed_move( GTK_MYFIXED(m_mainWidget), m_wxwindow, 0, client_area_y_offset );
+ gtk_widget_set_usize( m_wxwindow, m_width, m_height-client_area_y_offset );
if (m_frameStatusBar)
{
int xx = 0 + m_miniEdge;
- int yy = m_height - wxSTATUS_HEIGHT - m_miniEdge;
+ int yy = m_height - wxSTATUS_HEIGHT - m_miniEdge - client_area_y_offset;
int ww = m_width - 2*m_miniEdge;
int hh = wxSTATUS_HEIGHT;
if (m_frameMenuBar->m_parent != this)
{
m_frameMenuBar->m_parent = this;
- gtk_myfixed_put( GTK_MYFIXED(m_wxwindow),
+ gtk_myfixed_put( GTK_MYFIXED(m_mainWidget),
m_frameMenuBar->m_widget, m_frameMenuBar->m_x, m_frameMenuBar->m_y );
/* an mdi child menu bar might be underneath */
dx += widget->allocation.x;
dy += widget->allocation.y;
}
- else
- if (win->m_parent)
- {
- wxPoint pt(win->m_parent->GetClientAreaOrigin());
- dx += pt.x;
- dy += pt.y;
- }
if (win->m_windowStyle & wxRAISED_BORDER)
{
}
}
- wxPoint pt(win->GetClientAreaOrigin());
- event.m_x -= pt.x;
- event.m_y -= pt.y;
-
event.SetEventObject( win );
gs_timeLastClick = gdk_event->time;
}
}
- wxPoint pt(win->GetClientAreaOrigin());
- event.m_x -= pt.x;
- event.m_y -= pt.y;
-
event.SetEventObject( win );
if (win->GetEventHandler()->ProcessEvent( event ))
}
}
- wxPoint pt(win->GetClientAreaOrigin());
- event.m_x -= pt.x;
- event.m_y -= pt.y;
-
event.SetEventObject( win );
if (win->GetEventHandler()->ProcessEvent( event ))
event.m_x = (long)x;
event.m_y = (long)y;
- wxPoint pt(win->GetClientAreaOrigin());
- event.m_x -= pt.x;
- event.m_y -= pt.y;
-
if (win->GetEventHandler()->ProcessEvent( event ))
{
gtk_signal_emit_stop_by_name( GTK_OBJECT(widget), "enter_notify_event" );
event.m_x = (long)x;
event.m_y = (long)y;
- wxPoint pt(win->GetClientAreaOrigin());
- event.m_x -= pt.x;
- event.m_y -= pt.y;
-
if (win->GetEventHandler()->ProcessEvent( event ))
{
gtk_signal_emit_stop_by_name( GTK_OBJECT(widget), "leave_notify_event" );
child->m_width,
child->m_height );
- if (wxIS_KIND_OF(parent,wxFrame))
- {
- parent->m_sizeSet = FALSE;
- }
-
if (parent->m_windowStyle & wxTAB_TRAVERSAL)
{
/* we now allow a window to get the focus as long as it
// are we to set fonts here ?
}
-wxPoint wxWindow::GetClientAreaOrigin() const
-{
- return wxPoint(0,0);
-}
-
-void wxWindow::AdjustForParentClientOrigin( int& x, int& y, int sizeFlags )
-{
- if (((sizeFlags & wxSIZE_NO_ADJUSTMENTS) == 0) && GetParent())
- {
- wxPoint pt(GetParent()->GetClientAreaOrigin());
- x += pt.x;
- y += pt.y;
- }
-}
-
void wxWindow::DoSetSize( int x, int y, int width, int height, int sizeFlags )
{
wxASSERT_MSG( (m_widget != NULL), "invalid window" );
/* the default button has a border around it */
int border = 5;
- wxPoint pt( m_parent->GetClientAreaOrigin() );
- gtk_myfixed_move( GTK_MYFIXED(m_parent->m_wxwindow), m_widget, m_x+pt.x-border, m_y+pt.y-border );
+ gtk_myfixed_move( GTK_MYFIXED(m_parent->m_wxwindow), m_widget, m_x-border, m_y-border );
gtk_widget_set_usize( m_widget, m_width+2*border, m_height+2*border );
}
else
{
- wxPoint pt( m_parent->GetClientAreaOrigin() );
- gtk_myfixed_move( GTK_MYFIXED(m_parent->m_wxwindow), m_widget, m_x+pt.x, m_y+pt.y );
+ gtk_myfixed_move( GTK_MYFIXED(m_parent->m_wxwindow), m_widget, m_x, m_y );
if ((old_width != m_width) || (old_height != m_height))
gtk_widget_set_usize( m_widget, m_width, m_height );
}
}
- wxPoint pt(GetClientAreaOrigin());
- org_x += pt.x;
- org_y += pt.y;
-
if (x) *x += org_x;
if (y) *y += org_y;
}
}
}
- wxPoint pt(GetClientAreaOrigin());
- org_x -= pt.x;
- org_y -= pt.y;
-
if (x) *x -= org_x;
if (y) *y -= org_y;
}
return FALSE;
}
+//-----------------------------------------------------------------------------
+// InsertChild for wxFrame
+//-----------------------------------------------------------------------------
+
+/* 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 wxWindows requires different ways to insert
+ * a child in container classes. */
+
+static void wxInsertChildInFrame( wxWindow* parent, wxWindow* child )
+{
+ if (wxIS_KIND_OF(child,wxToolBar) || wxIS_KIND_OF(child,wxMenuBar))
+ {
+ /* these are outside the client area */
+ wxFrame* frame = (wxFrame*) parent;
+ gtk_myfixed_put( GTK_MYFIXED(frame->m_mainWidget),
+ GTK_WIDGET(child->m_widget),
+ child->m_x,
+ child->m_y );
+ }
+ else
+ {
+ /* these are inside the client area */
+ gtk_myfixed_put( GTK_MYFIXED(parent->m_wxwindow),
+ GTK_WIDGET(child->m_widget),
+ child->m_x,
+ child->m_y );
+ }
+
+ gtk_widget_set_usize( GTK_WIDGET(child->m_widget),
+ child->m_width,
+ child->m_height );
+
+ /* resize on OnInternalIdle */
+ parent->m_sizeSet = FALSE;
+
+ if (parent->m_windowStyle & 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 );
+ }
+}
+
//-----------------------------------------------------------------------------
// wxFrame
//-----------------------------------------------------------------------------
PreCreation( parent, id, pos, size, style, name );
m_title = title;
+
+ m_insertCallback = wxInsertChildInFrame;
GtkWindowType win_type = GTK_WINDOW_TOPLEVEL;
if (style & wxSIMPLE_BORDER) win_type = GTK_WINDOW_POPUP;
gtk_signal_connect( GTK_OBJECT(m_widget), "delete_event",
GTK_SIGNAL_FUNC(gtk_frame_delete_callback), (gpointer)this );
+ /* m_mainWidget holds the toolbar, the menubar and the client area */
+ m_mainWidget = gtk_myfixed_new();
+ gtk_widget_show( m_mainWidget );
+ GTK_WIDGET_UNSET_FLAGS( m_mainWidget, GTK_CAN_FOCUS );
+ gtk_container_add( GTK_CONTAINER(m_widget), m_mainWidget );
+ gtk_widget_realize( m_mainWidget );
+
+ /* m_wxwindow only represents the client area without toolbar and menubar */
m_wxwindow = gtk_myfixed_new();
gtk_widget_show( m_wxwindow );
GTK_WIDGET_UNSET_FLAGS( m_wxwindow, GTK_CAN_FOCUS );
-
- gtk_container_add( GTK_CONTAINER(m_widget), m_wxwindow );
+ gtk_container_add( GTK_CONTAINER(m_mainWidget), m_wxwindow );
if (m_parent) m_parent->AddChild( this );
{
/* by calling GtkOnSize here, we don't have to call
either after showing the frame, which would entail
- much ugly flicker nor from within the size_allocate
+ much ugly flicker or from within the size_allocate
handler, because GTK 1.1.X forbids that. */
GtkOnSize( m_x, m_y, m_width, m_height );
return TRUE;
}
-wxPoint wxFrame::GetClientAreaOrigin() const
-{
- wxPoint pt( m_miniEdge, m_miniEdge + m_miniTitle );
- if (m_frameMenuBar)
- {
- int h = 0;
- m_frameMenuBar->GetSize( (int*)NULL, &h );
- pt.y += h;
- }
- if (m_frameToolBar)
- {
- int h = 0;
- m_frameToolBar->GetSize( (int*)NULL, &h );
- pt.y += h;
- }
- return pt;
-}
-
void wxFrame::DoSetSize( int x, int y, int width, int height, int sizeFlags )
{
wxASSERT_MSG( (m_widget != NULL), "invalid frame" );
if ((m_maxWidth != -1) && (m_width > m_maxWidth)) m_width = m_maxWidth;
if ((m_maxHeight != -1) && (m_height > m_maxHeight)) m_height = m_maxHeight;
- /* this emulates the new wxMSW behaviour of placing all
- * frame-subwindows (menu, toolbar..) on one native window
+ /* I revert back to wxGTK's original behaviour. m_mainWidget holds the
+ * menubar, the toolbar and the client area, which is represented by
+ * m_wxwindow.
* this hurts in the eye, but I don't want to call SetSize()
* because I don't want to call any non-native functions here. */
+
+ int client_area_y_offset = 0;
if (m_frameMenuBar)
{
m_frameMenuBar->m_width = ww;
m_frameMenuBar->m_height = hh;
- gtk_myfixed_move( GTK_MYFIXED(m_wxwindow), m_frameMenuBar->m_widget, xx, yy );
+ gtk_myfixed_move( GTK_MYFIXED(m_mainWidget), m_frameMenuBar->m_widget, xx, yy );
gtk_widget_set_usize( m_frameMenuBar->m_widget, ww, hh );
+
+ client_area_y_offset += hh;
}
if (m_frameToolBar)
m_frameToolBar->m_height = hh;
m_frameToolBar->m_width = ww;
- gtk_myfixed_move( GTK_MYFIXED(m_wxwindow), m_frameToolBar->m_widget, xx, yy );
+ gtk_myfixed_move( GTK_MYFIXED(m_mainWidget), m_frameToolBar->m_widget, xx, yy );
gtk_widget_set_usize( m_frameToolBar->m_widget, ww, hh );
+
+ client_area_y_offset += hh;
}
+
+ gtk_myfixed_move( GTK_MYFIXED(m_mainWidget), m_wxwindow, 0, client_area_y_offset );
+ gtk_widget_set_usize( m_wxwindow, m_width, m_height-client_area_y_offset );
if (m_frameStatusBar)
{
int xx = 0 + m_miniEdge;
- int yy = m_height - wxSTATUS_HEIGHT - m_miniEdge;
+ int yy = m_height - wxSTATUS_HEIGHT - m_miniEdge - client_area_y_offset;
int ww = m_width - 2*m_miniEdge;
int hh = wxSTATUS_HEIGHT;
if (m_frameMenuBar->m_parent != this)
{
m_frameMenuBar->m_parent = this;
- gtk_myfixed_put( GTK_MYFIXED(m_wxwindow),
+ gtk_myfixed_put( GTK_MYFIXED(m_mainWidget),
m_frameMenuBar->m_widget, m_frameMenuBar->m_x, m_frameMenuBar->m_y );
/* an mdi child menu bar might be underneath */
dx += widget->allocation.x;
dy += widget->allocation.y;
}
- else
- if (win->m_parent)
- {
- wxPoint pt(win->m_parent->GetClientAreaOrigin());
- dx += pt.x;
- dy += pt.y;
- }
if (win->m_windowStyle & wxRAISED_BORDER)
{
}
}
- wxPoint pt(win->GetClientAreaOrigin());
- event.m_x -= pt.x;
- event.m_y -= pt.y;
-
event.SetEventObject( win );
gs_timeLastClick = gdk_event->time;
}
}
- wxPoint pt(win->GetClientAreaOrigin());
- event.m_x -= pt.x;
- event.m_y -= pt.y;
-
event.SetEventObject( win );
if (win->GetEventHandler()->ProcessEvent( event ))
}
}
- wxPoint pt(win->GetClientAreaOrigin());
- event.m_x -= pt.x;
- event.m_y -= pt.y;
-
event.SetEventObject( win );
if (win->GetEventHandler()->ProcessEvent( event ))
event.m_x = (long)x;
event.m_y = (long)y;
- wxPoint pt(win->GetClientAreaOrigin());
- event.m_x -= pt.x;
- event.m_y -= pt.y;
-
if (win->GetEventHandler()->ProcessEvent( event ))
{
gtk_signal_emit_stop_by_name( GTK_OBJECT(widget), "enter_notify_event" );
event.m_x = (long)x;
event.m_y = (long)y;
- wxPoint pt(win->GetClientAreaOrigin());
- event.m_x -= pt.x;
- event.m_y -= pt.y;
-
if (win->GetEventHandler()->ProcessEvent( event ))
{
gtk_signal_emit_stop_by_name( GTK_OBJECT(widget), "leave_notify_event" );
child->m_width,
child->m_height );
- if (wxIS_KIND_OF(parent,wxFrame))
- {
- parent->m_sizeSet = FALSE;
- }
-
if (parent->m_windowStyle & wxTAB_TRAVERSAL)
{
/* we now allow a window to get the focus as long as it
// are we to set fonts here ?
}
-wxPoint wxWindow::GetClientAreaOrigin() const
-{
- return wxPoint(0,0);
-}
-
-void wxWindow::AdjustForParentClientOrigin( int& x, int& y, int sizeFlags )
-{
- if (((sizeFlags & wxSIZE_NO_ADJUSTMENTS) == 0) && GetParent())
- {
- wxPoint pt(GetParent()->GetClientAreaOrigin());
- x += pt.x;
- y += pt.y;
- }
-}
-
void wxWindow::DoSetSize( int x, int y, int width, int height, int sizeFlags )
{
wxASSERT_MSG( (m_widget != NULL), "invalid window" );
/* the default button has a border around it */
int border = 5;
- wxPoint pt( m_parent->GetClientAreaOrigin() );
- gtk_myfixed_move( GTK_MYFIXED(m_parent->m_wxwindow), m_widget, m_x+pt.x-border, m_y+pt.y-border );
+ gtk_myfixed_move( GTK_MYFIXED(m_parent->m_wxwindow), m_widget, m_x-border, m_y-border );
gtk_widget_set_usize( m_widget, m_width+2*border, m_height+2*border );
}
else
{
- wxPoint pt( m_parent->GetClientAreaOrigin() );
- gtk_myfixed_move( GTK_MYFIXED(m_parent->m_wxwindow), m_widget, m_x+pt.x, m_y+pt.y );
+ gtk_myfixed_move( GTK_MYFIXED(m_parent->m_wxwindow), m_widget, m_x, m_y );
if ((old_width != m_width) || (old_height != m_height))
gtk_widget_set_usize( m_widget, m_width, m_height );
}
}
- wxPoint pt(GetClientAreaOrigin());
- org_x += pt.x;
- org_y += pt.y;
-
if (x) *x += org_x;
if (y) *y += org_y;
}
}
}
- wxPoint pt(GetClientAreaOrigin());
- org_x -= pt.x;
- org_y -= pt.y;
-
if (x) *x -= org_x;
if (y) *y -= org_y;
}