#include "gdk/gdk.h"
#include "gtk/gtk.h"
#include "wx/gtk/win_gtk.h"
+#include "gdk/gdkkeysyms.h"
//-----------------------------------------------------------------------------
// constants
static void gtk_frame_size_callback( GtkWidget *WXUNUSED(widget), GtkAllocation* alloc, wxFrame *win )
{
- if (g_isIdle) wxapp_install_idle_handler();
+ if (g_isIdle)
+ wxapp_install_idle_handler();
if (!win->m_hasVMT) return;
-/*
- printf( "OnFrameResize from " );
- if (win->GetClassInfo() && win->GetClassInfo()->GetClassName())
- printf( win->GetClassInfo()->GetClassName() );
- printf( ".\n" );
-*/
-
- if ((win->m_width != alloc->width) || (win->m_height != alloc->height))
- {
- win->InternalSetSize( alloc->width, alloc->height );
- }
+ if ((win->m_width != alloc->width) || (win->m_height != alloc->height))
+ {
+ win->m_width = alloc->width;
+ win->m_height = alloc->height;
+ win->UpdateSize();
+ }
}
//-----------------------------------------------------------------------------
static gint gtk_frame_delete_callback( GtkWidget *WXUNUSED(widget), GdkEvent *WXUNUSED(event), wxFrame *win )
{
- if (g_isIdle) wxapp_install_idle_handler();
-
-/*
- printf( "OnDelete from " );
- if (win->GetClassInfo() && win->GetClassInfo()->GetClassName())
- printf( win->GetClassInfo()->GetClassName() );
- printf( ".\n" );
-*/
+ if (g_isIdle)
+ wxapp_install_idle_handler();
win->Close();
static void gtk_menu_attached_callback( GtkWidget *WXUNUSED(widget), GtkWidget *WXUNUSED(child), wxFrame *win )
{
- if (g_isIdle) wxapp_install_idle_handler();
-
if (!win->m_hasVMT) return;
win->m_menuBarDetached = FALSE;
static void gtk_menu_detached_callback( GtkWidget *WXUNUSED(widget), GtkWidget *WXUNUSED(child), wxFrame *win )
{
- if (g_isIdle) wxapp_install_idle_handler();
-
if (!win->m_hasVMT) return;
win->m_menuBarDetached = TRUE;
static void gtk_toolbar_attached_callback( GtkWidget *WXUNUSED(widget), GtkWidget *WXUNUSED(child), wxFrame *win )
{
- if (g_isIdle) wxapp_install_idle_handler();
-
if (!win->m_hasVMT) return;
win->m_toolBarDetached = FALSE;
+
win->UpdateSize();
}
static void gtk_toolbar_detached_callback( GtkWidget *widget, GtkWidget *WXUNUSED(child), wxFrame *win )
{
- if (g_isIdle) wxapp_install_idle_handler();
+ if (g_isIdle)
+ wxapp_install_idle_handler();
if (!win->m_hasVMT) return;
static gint gtk_frame_configure_callback( GtkWidget *WXUNUSED(widget), GdkEventConfigure *event, wxFrame *win )
{
- if (g_isIdle) wxapp_install_idle_handler();
+ if (g_isIdle)
+ wxapp_install_idle_handler();
if (!win->m_hasVMT) return FALSE;
-
- win->InternalSetPosition(event->x, event->y);
+
+ win->m_x = event->x;
+ win->m_y = event->y;
wxMoveEvent mevent( wxPoint(win->m_x,win->m_y), win->GetId() );
mevent.SetEventObject( win );
static gint
gtk_frame_realized_callback( GtkWidget *widget, wxFrame *win )
{
- if (g_isIdle) wxapp_install_idle_handler();
+ if (g_isIdle)
+ wxapp_install_idle_handler();
/* all this is for Motif Window Manager "hints" and is supposed to be
recognized by other WM as well. not tested. */
* virtual function here as wxWindows requires different ways to insert
* a child in container classes. */
-static void wxInsertChildInFrame( wxWindow* parent, wxWindow* child )
+static void wxInsertChildInFrame( wxFrame* parent, wxWindow* child )
{
- if (wxIS_KIND_OF(child,wxToolBar) || wxIS_KIND_OF(child,wxMenuBar))
+ if (!parent->m_insertInClientArea)
{
- /* actually, menubars are never inserted here, but this
- may change one day */
-
/* these are outside the client area */
wxFrame* frame = (wxFrame*) parent;
gtk_myfixed_put( GTK_MYFIXED(frame->m_mainWidget),
m_mainWidget = (GtkWidget*) NULL;
m_menuBarDetached = FALSE;
m_toolBarDetached = FALSE;
- m_insertCallback = wxInsertChildInFrame;
+ m_insertCallback = (wxInsertChildFunction) NULL;
+ m_insertInClientArea = TRUE;
}
wxFrame::wxFrame( wxWindow *parent, wxWindowID id, const wxString &title,
m_mainWidget = (GtkWidget*) NULL;
m_menuBarDetached = FALSE;
m_toolBarDetached = FALSE;
- m_insertCallback = wxInsertChildInFrame;
+ m_insertCallback = (wxInsertChildFunction) NULL;
+ m_insertInClientArea = TRUE;
Create( parent, id, title, pos, size, style, name );
}
m_title = title;
- m_insertCallback = wxInsertChildInFrame;
+ m_insertCallback = (wxInsertChildFunction) wxInsertChildInFrame;
GtkWindowType win_type = GTK_WINDOW_TOPLEVEL;
if (style & wxSIMPLE_BORDER) win_type = GTK_WINDOW_POPUP;
wxFrame::~wxFrame()
{
+ m_isBeingDeleted = TRUE;
+
if (m_frameMenuBar) delete m_frameMenuBar;
m_frameMenuBar = (wxMenuBar *) NULL;
{
if ((m_x != old_x) || (m_y != old_y))
{
- /* we set the size here and in gtk_frame_map_callback */
gtk_widget_set_uposition( m_widget, m_x, m_y );
}
}
Move( x, y );
}
-void wxFrame::GetClientSize( int *width, int *height ) const
+void wxFrame::DoGetClientSize( int *width, int *height ) const
{
wxASSERT_MSG( (m_widget != NULL), _T("invalid frame") );
- wxWindow::GetClientSize( width, height );
+ wxWindow::DoGetClientSize( width, height );
if (height)
{
/* menu bar */
int ww = m_width - 2*m_miniEdge;
int hh = wxMENU_HEIGHT;
if (m_menuBarDetached) hh = wxPLACE_HOLDER;
- m_frameMenuBar->InternalSetPosition(xx, yy);
- m_frameMenuBar->InternalSetSize(ww, hh);
+ m_frameMenuBar->m_x = xx;
+ m_frameMenuBar->m_y = yy;
+ m_frameMenuBar->m_width = ww;
+ m_frameMenuBar->m_height = hh;
gtk_myfixed_set_size( GTK_MYFIXED(m_mainWidget),
m_frameMenuBar->m_widget,
xx, yy, ww, hh );
}
int ww = m_width - 2*m_miniEdge;
int hh = m_frameToolBar->m_height;
- // VZ: according to earlier comments in this file, the tbar height
- // shouldn't be changed, so I comment out the next line
- // (09.05.99)
- //if (m_toolBarDetached) hh = wxPLACE_HOLDER;
-
- m_frameToolBar->InternalSetPosition(xx, yy);
- m_frameToolBar->InternalSetSize(ww, hh);
-
+ if (m_toolBarDetached) hh = wxPLACE_HOLDER;
+ m_frameToolBar->m_x = xx;
+ m_frameToolBar->m_y = yy;
+ /* m_frameToolBar->m_height = hh; don't change the toolbar's height */
+ m_frameToolBar->m_width = ww;
gtk_myfixed_set_size( GTK_MYFIXED(m_mainWidget),
m_frameToolBar->m_widget,
xx, yy, ww, hh );
int yy = m_height - wxSTATUS_HEIGHT - m_miniEdge - client_area_y_offset;
int ww = m_width - 2*m_miniEdge;
int hh = wxSTATUS_HEIGHT;
- m_frameStatusBar->InternalSetPosition(xx, yy);
- m_frameStatusBar->InternalSetSize(ww, hh);
+ m_frameStatusBar->m_x = xx;
+ m_frameStatusBar->m_y = yy;
+ m_frameStatusBar->m_width = ww;
+ m_frameStatusBar->m_height = hh;
gtk_myfixed_set_size( GTK_MYFIXED(m_wxwindow),
m_frameStatusBar->m_widget,
xx, yy, ww, hh );
m_resizing = FALSE;
}
+void wxFrame::MakeModal( bool modal )
+{
+ if (modal)
+ {
+ gtk_grab_add( m_widget );
+ gtk_main();
+ gtk_grab_remove( m_widget );
+ }
+ else
+ {
+ gtk_main_quit();
+ }
+}
+
void wxFrame::OnInternalIdle()
{
if (!m_sizeSet && GTK_WIDGET_REALIZED(m_wxwindow))
GtkOnSize( m_x, m_y, m_width, m_height );
DoMenuUpdates();
+
+ if (m_frameMenuBar) m_frameMenuBar->OnInternalIdle();
+ if (m_frameToolBar) m_frameToolBar->OnInternalIdle();
+ if (m_frameStatusBar) m_frameStatusBar->OnInternalIdle();
}
-void wxFrame::OnCloseWindow( wxCloseEvent& event )
+void wxFrame::OnCloseWindow( wxCloseEvent& WXUNUSED(event) )
{
Destroy();
}
{
/* yes: set it's size to fill all the frame */
int client_x, client_y;
- GetClientSize( &client_x, &client_y );
+ DoGetClientSize( &client_x, &client_y );
child->SetSize( 1, 1, client_x-2, client_y-2 );
}
}
}
}
-wxToolBar* wxFrame::CreateToolBar(long style, wxWindowID id, const wxString& name)
+wxToolBar* wxFrame::CreateToolBar( long style, wxWindowID id, const wxString& name )
{
wxASSERT_MSG( (m_widget != NULL), _T("invalid frame") );
wxCHECK_MSG( m_frameToolBar == NULL, FALSE, _T("recreating toolbar in wxFrame") );
+ m_insertInClientArea = FALSE;
+
m_frameToolBar = OnCreateToolBar( style, id, name );
- GetChildren().DeleteObject( m_frameToolBar );
+ if (m_frameToolBar) GetChildren().DeleteObject( m_frameToolBar );
+
+ m_insertInClientArea = TRUE;
m_sizeSet = FALSE;