Minor Reparent() and SetToolBar() fix for wxFrame.

Corrected size reported by wxToolBar.


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@4078 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Robert Roebling 1999-10-20 15:30:42 +00:00
parent 280132e34e
commit 3017f78d67
12 changed files with 75 additions and 60 deletions

View File

@ -358,6 +358,8 @@ void MyTextCtrl::OnChar(wxKeyEvent& event)
{
LogEvent( _T("Char"), event);
/* How are we supposed to test wxTE_PROCESS_TAB with this code?
if ( event.KeyCode() == WXK_TAB )
{
WriteText("\t");
@ -366,6 +368,8 @@ void MyTextCtrl::OnChar(wxKeyEvent& event)
{
event.Skip();
}
*/
event.Skip();
}
void MyTextCtrl::OnKeyUp(wxKeyEvent& event)

View File

@ -85,6 +85,7 @@ static void gtk_frame_size_callback( GtkWidget *WXUNUSED(widget), GtkAllocation*
(int)alloc->width,
(int)alloc->height );
*/
win->m_width = alloc->width;
win->m_height = alloc->height;
win->UpdateSize();
@ -667,7 +668,7 @@ void wxFrame::DoSetClientSize( int width, int height )
}
#endif
wxWindow::DoSetClientSize( width + m_miniEdge*2, height + m_miniEdge*2 + m_miniTitle );
DoSetSize( -1, -1, width + m_miniEdge*2, height + m_miniEdge*2 + m_miniTitle, 0 );
}
void wxFrame::GtkOnSize( int WXUNUSED(x), int WXUNUSED(y), int width, int height )
@ -685,7 +686,7 @@ void wxFrame::GtkOnSize( int WXUNUSED(x), int WXUNUSED(y), int width, int height
m_width = width;
m_height = height;
/* space occupied by m_frameToolBar and m_frameMenuBar */
int client_area_y_offset = 0;
@ -979,16 +980,13 @@ void wxFrame::SetToolBar(wxToolBar *toolbar)
if (m_frameToolBar)
{
/* insert into toolbar area if not already there */
if (m_frameToolBar->m_widget->parent != m_mainWidget)
if ((m_frameToolBar->m_widget->parent) &&
(m_frameToolBar->m_widget->parent != m_mainWidget))
{
gtk_widget_ref( m_frameToolBar->m_widget );
gtk_widget_unparent( m_frameToolBar->m_widget );
m_insertInClientArea = TRUE;
wxInsertChildInFrame( this, m_frameToolBar );
m_insertInClientArea = FALSE;
gtk_widget_unref( m_frameToolBar->m_widget );
GetChildren().DeleteObject( m_frameToolBar );
gtk_widget_reparent( m_frameToolBar->m_widget, m_mainWidget );
UpdateSize();
}
}
}

View File

@ -280,6 +280,8 @@ bool wxMiniFrame::Create( wxWindow *parent, wxWindowID id, const wxString &title
long style, const wxString &name )
{
style = style | wxSIMPLE_BORDER;
style = style | wxCAPTION;
style = style | wxSYSTEM_MENU;
if ((style & wxCAPTION) || (style & wxTINY_CAPTION_HORIZ) || (style & wxTINY_CAPTION_VERT))
m_miniTitle = 13;

View File

@ -71,11 +71,9 @@ bool wxStaticText::Create(wxWindow *parent,
justify = GTK_JUSTIFY_LEFT;
gtk_label_set_justify(GTK_LABEL(m_widget), justify);
//#if GTK_MINOR_VERSION == 2
// GTK_JUSTIFY_LEFT is 0, RIGHT 1 and CENTER 2
static const float labelAlignments[] = { 0.0, 1.0, 0.5 };
gtk_misc_set_alignment(GTK_MISC(m_widget), labelAlignments[justify], 0.0);
//#endif // GTK 1.2.x
GtkRequisition req;
(* GTK_WIDGET_CLASS( GTK_OBJECT(m_widget)->klass )->size_request ) (m_widget, &req );

View File

@ -309,6 +309,11 @@ wxToolBarTool *wxToolBar::AddTool( int toolIndex, const wxBitmap& bitmap,
tool->m_item = item;
GtkRequisition req;
(* GTK_WIDGET_CLASS( GTK_OBJECT(m_widget)->klass )->size_request ) (m_widget, &req );
m_width = req.width;
m_height = req.height;
gtk_signal_connect( GTK_OBJECT(tool->m_item),
"enter_notify_event",
GTK_SIGNAL_FUNC(gtk_toolbar_enter_callback),

View File

@ -132,7 +132,7 @@
clicking on a scrollbar belonging to scrolled window will inevitably move
the window. In wxWindows, the scrollbar will only emit an event, send this
to (normally) a wxScrolledWindow and that class will call ScrollWindow()
which actually move the window and its subchildren. Note that GtkMyFixed
which actually moves the window and its subchildren. Note that GtkMyFixed
memorizes how much it has been scrolled but that wxWindows forgets this
so that the two coordinates systems have to be kept in synch. This is done
in various places using the myfixed->xoffset and myfixed->yoffset values.
@ -148,7 +148,7 @@
and then iterates down the respective size events to all window. This has
the disadvantage, that windows might get size events before the GTK widget
actually has the reported size. This doesn't normally pose any problem, but
the OpenGl drawing routines rely in correct behaviour. Therefore, I have
the OpenGl drawing routines rely on correct behaviour. Therefore, I have
added the m_nativeSizeEvents flag, which is true only for the OpenGL canvas,
i.e. the wxGLCanvas will emit a size event, when (and not before) the X11
window that is used for OpenGl output really has that size (as reported by
@ -823,13 +823,12 @@ static gint gtk_window_key_press_callback( GtkWidget *widget, GdkEventKey *gdk_e
GdkModifierType state;
if (gdk_event->window) gdk_window_get_pointer(gdk_event->window, &x, &y, &state);
bool ret = FALSE;
long key_code = map_to_unmodified_wx_keysym( gdk_event->keyval );
/* sending unknown key events doesn't really make sense */
if (key_code == 0) return FALSE;
bool ret = FALSE;
wxKeyEvent event( wxEVT_KEY_DOWN );
event.SetTimestamp( gdk_event->time );
event.m_shiftDown = (gdk_event->state & GDK_SHIFT_MASK);
@ -843,8 +842,6 @@ static gint gtk_window_key_press_callback( GtkWidget *widget, GdkEventKey *gdk_e
event.SetEventObject( win );
ret = win->GetEventHandler()->ProcessEvent( event );
key_code = map_to_wx_keysym( gdk_event->keyval );
#if wxUSE_ACCEL
if (!ret)
{
@ -862,10 +859,14 @@ static gint gtk_window_key_press_callback( GtkWidget *widget, GdkEventKey *gdk_e
}
}
#endif // wxUSE_ACCEL
/* wxMSW doesn't send char events with Alt pressed */
/* Only send wxEVT_CHAR event if not processed yet. Thus, ALT-x
will only be sent if it is not a menu accelerator. */
if ((key_code != 0) && ! ret )
will only be sent if it is not in an accelerator table. */
key_code = map_to_wx_keysym( gdk_event->keyval );
if ( (!ret) &&
(key_code != 0))
{
wxKeyEvent event2( wxEVT_CHAR );
event2.SetTimestamp( gdk_event->time );
@ -878,7 +879,7 @@ static gint gtk_window_key_press_callback( GtkWidget *widget, GdkEventKey *gdk_e
event2.m_x = x;
event2.m_y = y;
event2.SetEventObject( win );
ret = (ret || win->GetEventHandler()->ProcessEvent( event2 ));
ret = win->GetEventHandler()->ProcessEvent( event2 );
}
/* win is a control: tab can be propagated up */
@ -906,6 +907,7 @@ static gint gtk_window_key_press_callback( GtkWidget *widget, GdkEventKey *gdk_e
#if (GTK_MINOR_VERSION > 0)
/* pressing F10 will activate the menu bar of the top frame */
/*
if ( (!ret) &&
(gdk_event->keyval == GDK_F10) )
{
@ -921,10 +923,9 @@ static gint gtk_window_key_press_callback( GtkWidget *widget, GdkEventKey *gdk_e
wxNode *node = menubar->GetMenus().First();
if (node)
{
// doesn't work correctly
// wxMenu *firstMenu = (wxMenu*) node->Data();
// gtk_menu_item_select( GTK_MENU_ITEM(firstMenu->m_owner) );
// ret = TRUE;
wxMenu *firstMenu = (wxMenu*) node->Data();
gtk_menu_item_select( GTK_MENU_ITEM(firstMenu->m_owner) );
ret = TRUE;
break;
}
}
@ -932,6 +933,7 @@ static gint gtk_window_key_press_callback( GtkWidget *widget, GdkEventKey *gdk_e
ancestor = ancestor->GetParent();
}
}
*/
#endif
/*
@ -2255,7 +2257,7 @@ void wxWindow::OnInternalIdle()
if (cursor.Ok())
{
/* I now set the cursor the anew in every OnInternalIdle call
/* I now set the cursor anew in every OnInternalIdle call
as setting the cursor in a parent window also effects the
windows above so that checking for the current cursor is
not possible. */
@ -2640,7 +2642,7 @@ bool wxWindow::Reparent( wxWindowBase *newParentBase )
if (oldParent)
{
gtk_container_remove( GTK_CONTAINER(oldParent->m_wxwindow), m_widget );
gtk_container_remove( GTK_CONTAINER(m_widget->parent), m_widget );
}
wxASSERT( GTK_IS_WIDGET(m_widget) );

View File

@ -85,6 +85,7 @@ static void gtk_frame_size_callback( GtkWidget *WXUNUSED(widget), GtkAllocation*
(int)alloc->width,
(int)alloc->height );
*/
win->m_width = alloc->width;
win->m_height = alloc->height;
win->UpdateSize();
@ -667,7 +668,7 @@ void wxFrame::DoSetClientSize( int width, int height )
}
#endif
wxWindow::DoSetClientSize( width + m_miniEdge*2, height + m_miniEdge*2 + m_miniTitle );
DoSetSize( -1, -1, width + m_miniEdge*2, height + m_miniEdge*2 + m_miniTitle, 0 );
}
void wxFrame::GtkOnSize( int WXUNUSED(x), int WXUNUSED(y), int width, int height )
@ -685,7 +686,7 @@ void wxFrame::GtkOnSize( int WXUNUSED(x), int WXUNUSED(y), int width, int height
m_width = width;
m_height = height;
/* space occupied by m_frameToolBar and m_frameMenuBar */
int client_area_y_offset = 0;
@ -979,16 +980,13 @@ void wxFrame::SetToolBar(wxToolBar *toolbar)
if (m_frameToolBar)
{
/* insert into toolbar area if not already there */
if (m_frameToolBar->m_widget->parent != m_mainWidget)
if ((m_frameToolBar->m_widget->parent) &&
(m_frameToolBar->m_widget->parent != m_mainWidget))
{
gtk_widget_ref( m_frameToolBar->m_widget );
gtk_widget_unparent( m_frameToolBar->m_widget );
m_insertInClientArea = TRUE;
wxInsertChildInFrame( this, m_frameToolBar );
m_insertInClientArea = FALSE;
gtk_widget_unref( m_frameToolBar->m_widget );
GetChildren().DeleteObject( m_frameToolBar );
gtk_widget_reparent( m_frameToolBar->m_widget, m_mainWidget );
UpdateSize();
}
}
}

View File

@ -280,6 +280,8 @@ bool wxMiniFrame::Create( wxWindow *parent, wxWindowID id, const wxString &title
long style, const wxString &name )
{
style = style | wxSIMPLE_BORDER;
style = style | wxCAPTION;
style = style | wxSYSTEM_MENU;
if ((style & wxCAPTION) || (style & wxTINY_CAPTION_HORIZ) || (style & wxTINY_CAPTION_VERT))
m_miniTitle = 13;

View File

@ -71,11 +71,9 @@ bool wxStaticText::Create(wxWindow *parent,
justify = GTK_JUSTIFY_LEFT;
gtk_label_set_justify(GTK_LABEL(m_widget), justify);
//#if GTK_MINOR_VERSION == 2
// GTK_JUSTIFY_LEFT is 0, RIGHT 1 and CENTER 2
static const float labelAlignments[] = { 0.0, 1.0, 0.5 };
gtk_misc_set_alignment(GTK_MISC(m_widget), labelAlignments[justify], 0.0);
//#endif // GTK 1.2.x
GtkRequisition req;
(* GTK_WIDGET_CLASS( GTK_OBJECT(m_widget)->klass )->size_request ) (m_widget, &req );

View File

@ -309,6 +309,11 @@ wxToolBarTool *wxToolBar::AddTool( int toolIndex, const wxBitmap& bitmap,
tool->m_item = item;
GtkRequisition req;
(* GTK_WIDGET_CLASS( GTK_OBJECT(m_widget)->klass )->size_request ) (m_widget, &req );
m_width = req.width;
m_height = req.height;
gtk_signal_connect( GTK_OBJECT(tool->m_item),
"enter_notify_event",
GTK_SIGNAL_FUNC(gtk_toolbar_enter_callback),

View File

@ -132,7 +132,7 @@
clicking on a scrollbar belonging to scrolled window will inevitably move
the window. In wxWindows, the scrollbar will only emit an event, send this
to (normally) a wxScrolledWindow and that class will call ScrollWindow()
which actually move the window and its subchildren. Note that GtkMyFixed
which actually moves the window and its subchildren. Note that GtkMyFixed
memorizes how much it has been scrolled but that wxWindows forgets this
so that the two coordinates systems have to be kept in synch. This is done
in various places using the myfixed->xoffset and myfixed->yoffset values.
@ -148,7 +148,7 @@
and then iterates down the respective size events to all window. This has
the disadvantage, that windows might get size events before the GTK widget
actually has the reported size. This doesn't normally pose any problem, but
the OpenGl drawing routines rely in correct behaviour. Therefore, I have
the OpenGl drawing routines rely on correct behaviour. Therefore, I have
added the m_nativeSizeEvents flag, which is true only for the OpenGL canvas,
i.e. the wxGLCanvas will emit a size event, when (and not before) the X11
window that is used for OpenGl output really has that size (as reported by
@ -823,13 +823,12 @@ static gint gtk_window_key_press_callback( GtkWidget *widget, GdkEventKey *gdk_e
GdkModifierType state;
if (gdk_event->window) gdk_window_get_pointer(gdk_event->window, &x, &y, &state);
bool ret = FALSE;
long key_code = map_to_unmodified_wx_keysym( gdk_event->keyval );
/* sending unknown key events doesn't really make sense */
if (key_code == 0) return FALSE;
bool ret = FALSE;
wxKeyEvent event( wxEVT_KEY_DOWN );
event.SetTimestamp( gdk_event->time );
event.m_shiftDown = (gdk_event->state & GDK_SHIFT_MASK);
@ -843,8 +842,6 @@ static gint gtk_window_key_press_callback( GtkWidget *widget, GdkEventKey *gdk_e
event.SetEventObject( win );
ret = win->GetEventHandler()->ProcessEvent( event );
key_code = map_to_wx_keysym( gdk_event->keyval );
#if wxUSE_ACCEL
if (!ret)
{
@ -862,10 +859,14 @@ static gint gtk_window_key_press_callback( GtkWidget *widget, GdkEventKey *gdk_e
}
}
#endif // wxUSE_ACCEL
/* wxMSW doesn't send char events with Alt pressed */
/* Only send wxEVT_CHAR event if not processed yet. Thus, ALT-x
will only be sent if it is not a menu accelerator. */
if ((key_code != 0) && ! ret )
will only be sent if it is not in an accelerator table. */
key_code = map_to_wx_keysym( gdk_event->keyval );
if ( (!ret) &&
(key_code != 0))
{
wxKeyEvent event2( wxEVT_CHAR );
event2.SetTimestamp( gdk_event->time );
@ -878,7 +879,7 @@ static gint gtk_window_key_press_callback( GtkWidget *widget, GdkEventKey *gdk_e
event2.m_x = x;
event2.m_y = y;
event2.SetEventObject( win );
ret = (ret || win->GetEventHandler()->ProcessEvent( event2 ));
ret = win->GetEventHandler()->ProcessEvent( event2 );
}
/* win is a control: tab can be propagated up */
@ -906,6 +907,7 @@ static gint gtk_window_key_press_callback( GtkWidget *widget, GdkEventKey *gdk_e
#if (GTK_MINOR_VERSION > 0)
/* pressing F10 will activate the menu bar of the top frame */
/*
if ( (!ret) &&
(gdk_event->keyval == GDK_F10) )
{
@ -921,10 +923,9 @@ static gint gtk_window_key_press_callback( GtkWidget *widget, GdkEventKey *gdk_e
wxNode *node = menubar->GetMenus().First();
if (node)
{
// doesn't work correctly
// wxMenu *firstMenu = (wxMenu*) node->Data();
// gtk_menu_item_select( GTK_MENU_ITEM(firstMenu->m_owner) );
// ret = TRUE;
wxMenu *firstMenu = (wxMenu*) node->Data();
gtk_menu_item_select( GTK_MENU_ITEM(firstMenu->m_owner) );
ret = TRUE;
break;
}
}
@ -932,6 +933,7 @@ static gint gtk_window_key_press_callback( GtkWidget *widget, GdkEventKey *gdk_e
ancestor = ancestor->GetParent();
}
}
*/
#endif
/*
@ -2255,7 +2257,7 @@ void wxWindow::OnInternalIdle()
if (cursor.Ok())
{
/* I now set the cursor the anew in every OnInternalIdle call
/* I now set the cursor anew in every OnInternalIdle call
as setting the cursor in a parent window also effects the
windows above so that checking for the current cursor is
not possible. */
@ -2640,7 +2642,7 @@ bool wxWindow::Reparent( wxWindowBase *newParentBase )
if (oldParent)
{
gtk_container_remove( GTK_CONTAINER(oldParent->m_wxwindow), m_widget );
gtk_container_remove( GTK_CONTAINER(m_widget->parent), m_widget );
}
wxASSERT( GTK_IS_WIDGET(m_widget) );

View File

@ -104,8 +104,9 @@ class wxFloatBar(wxToolBar):
self.floatframe.SetToolBar(self)
self.oldcolor = self.GetBackgroundColour()
barsize = self.GetSizeTuple()
self.floatframe.SetSize(wxSize(barsize[0], barsize[1] + self.titleheight))
self.floatframe.SetClientSize(wxSize(barsize[0], barsize[1]))
# self.floatframe.SetSize(wxSize(barsize[0], barsize[1] + self.titleheight))
# self.floatframe.SetClientSize(wxSize(barsize[0], barsize[1]))
self.floatframe.SetClientSize(wxSize(50,200))
newpos = self.parentframe.GetPosition()
newpos.y = newpos.y + self.titleheight
self.floatframe.SetPosition(newpos)