From a2053b27b318fe81918a72c838944d1e8cd1524f Mon Sep 17 00:00:00 2001 From: Robert Roebling Date: Mon, 10 May 1999 11:02:43 +0000 Subject: [PATCH] Small modifications to Vadims changes git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@2387 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/gtk/window.h | 25 +- include/wx/gtk1/window.h | 25 +- include/wx/window.h | 5 +- src/common/wincmn.cpp | 2 +- src/gtk/bmpbuttn.cpp | 10 +- src/gtk/button.cpp | 2 +- src/gtk/checkbox.cpp | 2 +- src/gtk/choice.cpp | 2 +- src/gtk/combobox.cpp | 4 +- src/gtk/dcclient.cpp | 8 +- src/gtk/dialog.cpp | 18 +- src/gtk/dnd.cpp | 12 +- src/gtk/filedlg.cpp | 2 +- src/gtk/frame.cpp | 76 ++--- src/gtk/listbox.cpp | 6 +- src/gtk/mdi.cpp | 38 +-- src/gtk/minifram.cpp | 28 +- src/gtk/notebook.cpp | 16 +- src/gtk/radiobox.cpp | 10 +- src/gtk/radiobut.cpp | 2 +- src/gtk/scrolbar.cpp | 2 +- src/gtk/slider.cpp | 2 +- src/gtk/spinbutt.cpp | 2 +- src/gtk/textctrl.cpp | 4 +- src/gtk/window.cpp | 613 +++++++++++++++++++++++---------------- src/gtk1/bmpbuttn.cpp | 10 +- src/gtk1/button.cpp | 2 +- src/gtk1/checkbox.cpp | 2 +- src/gtk1/choice.cpp | 2 +- src/gtk1/combobox.cpp | 4 +- src/gtk1/dcclient.cpp | 8 +- src/gtk1/dialog.cpp | 18 +- src/gtk1/dnd.cpp | 12 +- src/gtk1/filedlg.cpp | 2 +- src/gtk1/frame.cpp | 76 ++--- src/gtk1/listbox.cpp | 6 +- src/gtk1/mdi.cpp | 38 +-- src/gtk1/minifram.cpp | 28 +- src/gtk1/notebook.cpp | 16 +- src/gtk1/radiobox.cpp | 10 +- src/gtk1/radiobut.cpp | 2 +- src/gtk1/scrolbar.cpp | 2 +- src/gtk1/slider.cpp | 2 +- src/gtk1/spinbutt.cpp | 2 +- src/gtk1/textctrl.cpp | 4 +- src/gtk1/window.cpp | 613 +++++++++++++++++++++++---------------- 46 files changed, 969 insertions(+), 806 deletions(-) diff --git a/include/wx/gtk/window.h b/include/wx/gtk/window.h index 76fed1e089..0d38f748bd 100644 --- a/include/wx/gtk/window.h +++ b/include/wx/gtk/window.h @@ -110,34 +110,11 @@ public: // wxWindows callbacks void OnKeyDown( wxKeyEvent &event ); - // simple accessors - bool HasVMT() const { return m_hasVMT; } - - int GetX() const { return m_x; } - int GetY() const { return m_y; } - int GetWidth() const { return m_width; } - int GetHeight() const { return m_height; } - - GtkWidget *GetWxWindow() const { return m_wxwindow; } - GtkWidget *GetWidget() const { return GetHandle(); } - - GtkAdjustment *GetHAdjust() const { return m_hAdjust; } - GtkAdjustment *GetVAdjust() const { return m_vAdjust; } - - float GetOldHorizontalPos() const { return m_oldHorizontalPos; } - float GetOldVerticalPos() const { return m_oldVerticalPos; } - - void SetOldHorizontalPos(float fpos) { m_oldHorizontalPos = fpos; } - void SetOldVerticalPos(float fpos) { m_oldVerticalPos = fpos; } - - bool IsSizeSet() const { return m_sizeSet; } - // also sets the global flag void SetScrolling(bool scroll); bool HasScrolling() const { return m_hasScrolling; } bool IsScrolling() const { return m_isScrolling; } - bool IsStaticBox() const { return m_isStaticBox; } /* I don't want users to override what's done in idle so everything that has to be done in idle time in order for wxGTK to work is done in @@ -180,12 +157,12 @@ public: void InternalSetSize(int w, int h) { m_width = w; m_height = h; UpdateSize(); } -protected: // position and size of the window int m_x, m_y; int m_width, m_height; // see the docs in src/gtk/window.cpp + GtkWidget *m_widget; GtkWidget *m_wxwindow; // scrolling stuff diff --git a/include/wx/gtk1/window.h b/include/wx/gtk1/window.h index 76fed1e089..0d38f748bd 100644 --- a/include/wx/gtk1/window.h +++ b/include/wx/gtk1/window.h @@ -110,34 +110,11 @@ public: // wxWindows callbacks void OnKeyDown( wxKeyEvent &event ); - // simple accessors - bool HasVMT() const { return m_hasVMT; } - - int GetX() const { return m_x; } - int GetY() const { return m_y; } - int GetWidth() const { return m_width; } - int GetHeight() const { return m_height; } - - GtkWidget *GetWxWindow() const { return m_wxwindow; } - GtkWidget *GetWidget() const { return GetHandle(); } - - GtkAdjustment *GetHAdjust() const { return m_hAdjust; } - GtkAdjustment *GetVAdjust() const { return m_vAdjust; } - - float GetOldHorizontalPos() const { return m_oldHorizontalPos; } - float GetOldVerticalPos() const { return m_oldVerticalPos; } - - void SetOldHorizontalPos(float fpos) { m_oldHorizontalPos = fpos; } - void SetOldVerticalPos(float fpos) { m_oldVerticalPos = fpos; } - - bool IsSizeSet() const { return m_sizeSet; } - // also sets the global flag void SetScrolling(bool scroll); bool HasScrolling() const { return m_hasScrolling; } bool IsScrolling() const { return m_isScrolling; } - bool IsStaticBox() const { return m_isStaticBox; } /* I don't want users to override what's done in idle so everything that has to be done in idle time in order for wxGTK to work is done in @@ -180,12 +157,12 @@ public: void InternalSetSize(int w, int h) { m_width = w; m_height = h; UpdateSize(); } -protected: // position and size of the window int m_x, m_y; int m_width, m_height; // see the docs in src/gtk/window.cpp + GtkWidget *m_widget; GtkWidget *m_wxwindow; // scrolling stuff diff --git a/include/wx/window.h b/include/wx/window.h index 3150797ee2..c6d4e51be5 100644 --- a/include/wx/window.h +++ b/include/wx/window.h @@ -595,10 +595,12 @@ public: void OnSysColourChanged( wxSysColourChangedEvent& event ); void OnInitDialog( wxInitDialogEvent &event ); +/* + What is this doing in the platform independent part? + // accessors WXWidget GetHandle() const { return m_widget; } -protected: // the window handle (for the underlying windowing system) and the window // id - a number which uniquely identifies a window among its siblings // unless it is -1 @@ -609,6 +611,7 @@ protected: WXWidget m_widget; WXWidget m_hWnd; }; +*/ wxWindowID m_windowId; diff --git a/src/common/wincmn.cpp b/src/common/wincmn.cpp index 542345c472..7b710bd120 100644 --- a/src/common/wincmn.cpp +++ b/src/common/wincmn.cpp @@ -78,7 +78,7 @@ END_EVENT_TABLE() void wxWindowBase::InitBase() { // no window yet, no parent nor children - m_widget = (WXWidget)0; +// m_widget = (WXWidget)0; m_parent = (wxWindow *)NULL; m_windowId = -1; m_children.DeleteContents( FALSE ); // don't auto delete node data diff --git a/src/gtk/bmpbuttn.cpp b/src/gtk/bmpbuttn.cpp index abc9a9fea0..783d419baa 100644 --- a/src/gtk/bmpbuttn.cpp +++ b/src/gtk/bmpbuttn.cpp @@ -43,7 +43,7 @@ static void gtk_bmpbutton_clicked_callback( GtkWidget *WXUNUSED(widget), wxBitma { if (g_isIdle) wxapp_install_idle_handler(); - if (!button->HasVMT()) return; + if (!button->m_hasVMT) return; if (g_blockEventsOnDrag) return; wxCommandEvent event(wxEVT_COMMAND_BUTTON_CLICKED, button->GetId()); @@ -57,7 +57,7 @@ static void gtk_bmpbutton_clicked_callback( GtkWidget *WXUNUSED(widget), wxBitma static void gtk_bmpbutton_enter_callback( GtkWidget *WXUNUSED(widget), wxBitmapButton *button ) { - if (!button->HasVMT()) return; + if (!button->m_hasVMT) return; if (g_blockEventsOnDrag) return; button->HasFocus(); @@ -69,7 +69,7 @@ static void gtk_bmpbutton_enter_callback( GtkWidget *WXUNUSED(widget), wxBitmapB static void gtk_bmpbutton_leave_callback( GtkWidget *WXUNUSED(widget), wxBitmapButton *button ) { - if (!button->HasVMT()) return; + if (!button->m_hasVMT) return; if (g_blockEventsOnDrag) return; button->NotFocus(); @@ -81,7 +81,7 @@ static void gtk_bmpbutton_leave_callback( GtkWidget *WXUNUSED(widget), wxBitmapB static void gtk_bmpbutton_press_callback( GtkWidget *WXUNUSED(widget), wxBitmapButton *button ) { - if (!button->HasVMT()) return; + if (!button->m_hasVMT) return; if (g_blockEventsOnDrag) return; button->StartSelect(); @@ -93,7 +93,7 @@ static void gtk_bmpbutton_press_callback( GtkWidget *WXUNUSED(widget), wxBitmapB static void gtk_bmpbutton_release_callback( GtkWidget *WXUNUSED(widget), wxBitmapButton *button ) { - if (!button->HasVMT()) return; + if (!button->m_hasVMT) return; if (g_blockEventsOnDrag) return; button->EndSelect(); diff --git a/src/gtk/button.cpp b/src/gtk/button.cpp index 7e93cc3f92..254056d770 100644 --- a/src/gtk/button.cpp +++ b/src/gtk/button.cpp @@ -43,7 +43,7 @@ static void gtk_button_clicked_callback( GtkWidget *WXUNUSED(widget), wxButton * { if (g_isIdle) wxapp_install_idle_handler(); - if (!button->HasVMT()) return; + if (!button->m_hasVMT) return; if (g_blockEventsOnDrag) return; wxCommandEvent event(wxEVT_COMMAND_BUTTON_CLICKED, button->GetId()); diff --git a/src/gtk/checkbox.cpp b/src/gtk/checkbox.cpp index 258f26ac1a..09cdd98387 100644 --- a/src/gtk/checkbox.cpp +++ b/src/gtk/checkbox.cpp @@ -38,7 +38,7 @@ static void gtk_checkbox_clicked_callback( GtkWidget *WXUNUSED(widget), wxCheckB { if (g_isIdle) wxapp_install_idle_handler(); - if (!cb->HasVMT()) return; + if (!cb->m_hasVMT) return; if (cb->m_blockFirstEvent) { diff --git a/src/gtk/choice.cpp b/src/gtk/choice.cpp index 66f2f19bd7..f13d20eae3 100644 --- a/src/gtk/choice.cpp +++ b/src/gtk/choice.cpp @@ -38,7 +38,7 @@ static void gtk_choice_clicked_callback( GtkWidget *WXUNUSED(widget), wxChoice * { if (g_isIdle) wxapp_install_idle_handler(); - if (!choice->HasVMT()) return; + if (!choice->m_hasVMT) return; if (g_blockEventsOnDrag) return; diff --git a/src/gtk/combobox.cpp b/src/gtk/combobox.cpp index caf222a719..bec8f16668 100644 --- a/src/gtk/combobox.cpp +++ b/src/gtk/combobox.cpp @@ -41,7 +41,7 @@ gtk_combo_clicked_callback( GtkWidget *WXUNUSED(widget), wxComboBox *combo ) { if (g_isIdle) wxapp_install_idle_handler(); - if (!combo->HasVMT()) return; + if (!combo->m_hasVMT) return; if (g_blockEventsOnDrag) return; @@ -70,6 +70,8 @@ gtk_text_changed_callback( GtkWidget *WXUNUSED(widget), wxComboBox *combo ) { if (g_isIdle) wxapp_install_idle_handler(); + if (!combo->m_hasVMT) return; + wxCommandEvent event( wxEVT_COMMAND_TEXT_UPDATED, combo->GetId() ); event.SetString( combo->GetValue() ); event.SetEventObject( combo ); diff --git a/src/gtk/dcclient.cpp b/src/gtk/dcclient.cpp index ebd55de490..a5ee2b008c 100644 --- a/src/gtk/dcclient.cpp +++ b/src/gtk/dcclient.cpp @@ -110,7 +110,7 @@ wxWindowDC::wxWindowDC( wxWindow *window ) if (!window) return; - GtkWidget *widget = window->GetWxWindow(); + GtkWidget *widget = window->m_wxwindow; if (!widget) return; @@ -127,10 +127,10 @@ wxWindowDC::wxWindowDC( wxWindow *window ) /* still not realized ? */ if (!m_window) return; - if (window->GetWxWindow()) - m_cmap = gtk_widget_get_colormap( window->GetWxWindow() ); + if (window->m_wxwindow) + m_cmap = gtk_widget_get_colormap( window->m_wxwindow ); else - m_cmap = gtk_widget_get_colormap( window->GetHandle() ); + m_cmap = gtk_widget_get_colormap( window->m_widget ); m_isMemDC = FALSE; diff --git a/src/gtk/dialog.cpp b/src/gtk/dialog.cpp index 271c41ea99..596c4a5a9a 100644 --- a/src/gtk/dialog.cpp +++ b/src/gtk/dialog.cpp @@ -60,7 +60,7 @@ static void gtk_dialog_size_callback( GtkWidget *WXUNUSED(widget), GtkAllocation { if (g_isIdle) wxapp_install_idle_handler(); - if (!win->HasVMT()) return; + if (!win->m_hasVMT) return; /* printf( "OnDialogResize from " ); @@ -69,7 +69,7 @@ static void gtk_dialog_size_callback( GtkWidget *WXUNUSED(widget), GtkAllocation printf( ".\n" ); */ - if ((win->GetWidth() != alloc->width) || (win->GetHeight() != alloc->height)) + if ((win->m_width != alloc->width) || (win->m_height != alloc->height)) { win->InternalSetSize( alloc->width, alloc->height ); } @@ -83,11 +83,11 @@ static gint gtk_dialog_configure_callback( GtkWidget *WXUNUSED(widget), GdkEvent { if (g_isIdle) wxapp_install_idle_handler(); - if (!win->HasVMT()) return FALSE; + if (!win->m_hasVMT) return FALSE; win->InternalSetPosition(event->x, event->y); - wxMoveEvent mevent( wxPoint(win->GetX(),win->GetY()), win->GetId() ); + wxMoveEvent mevent( wxPoint(win->m_x,win->m_y), win->GetId() ); mevent.SetEventObject( win ); win->GetEventHandler()->ProcessEvent( mevent ); @@ -126,7 +126,7 @@ gtk_dialog_map_callback( GtkWidget *widget, wxDialog *win ) { /* I haven''t been able to set the position of the dialog before it is shown, so I do it here */ - gtk_widget_set_uposition( widget, win->GetX(), win->GetY() ); + gtk_widget_set_uposition( widget, win->m_x, win->m_y ); /* all this is for Motif Window Manager "hints" and is supposed to be recognized by other WM as well. not tested. */ @@ -155,14 +155,14 @@ gtk_dialog_map_callback( GtkWidget *widget, wxDialog *win ) func |= GDK_FUNC_RESIZE; decor |= GDK_DECOR_RESIZEH; } - gdk_window_set_decorations( win->GetHandle()->window, (GdkWMDecoration)decor); - gdk_window_set_functions( win->GetHandle()->window, (GdkWMFunction)func); + gdk_window_set_decorations( win->m_widget->window, (GdkWMDecoration)decor); + gdk_window_set_functions( win->m_widget->window, (GdkWMFunction)func); /* GTK's shrinking/growing policy */ if ((win->GetWindowStyle() & wxRESIZE_BORDER) == 0) - gtk_window_set_policy(GTK_WINDOW(win->GetHandle()), 0, 0, 1); + gtk_window_set_policy(GTK_WINDOW(win->m_widget), 0, 0, 1); else - gtk_window_set_policy(GTK_WINDOW(win->GetHandle()), 1, 1, 1); + gtk_window_set_policy(GTK_WINDOW(win->m_widget), 1, 1, 1); return FALSE; } diff --git a/src/gtk/dnd.cpp b/src/gtk/dnd.cpp index 5ca90425da..9596cf7d13 100644 --- a/src/gtk/dnd.cpp +++ b/src/gtk/dnd.cpp @@ -702,8 +702,8 @@ wxDropSource::wxDropSource( wxWindow *win, const wxIcon &go, const wxIcon &stop m_waiting = TRUE; m_window = win; - m_widget = win->GetWidget(); - if (win->GetWxWindow()) m_widget = win->GetWxWindow(); + m_widget = win->m_widget; + if (win->m_wxwindow) m_widget = win->m_wxwindow; m_data = (wxDataBroker*) NULL; m_retValue = wxDragCancel; @@ -722,8 +722,8 @@ wxDropSource::wxDropSource( wxDataObject *data, wxWindow *win, const wxIcon &go, m_waiting = TRUE; m_window = win; - m_widget = win->GetWidget(); - if (win->GetWxWindow()) m_widget = win->GetWxWindow(); + m_widget = win->m_widget; + if (win->m_wxwindow) m_widget = win->m_wxwindow; m_retValue = wxDragCancel; if (data) @@ -748,8 +748,8 @@ wxDropSource::wxDropSource( wxDataObject *data, wxWindow *win, const wxIcon &go, wxDropSource::wxDropSource( wxDataBroker *data, wxWindow *win ) { m_window = win; - m_widget = win->GetWidget(); - if (win->GetWxWindow()) m_widget = win->GetWxWindow(); + m_widget = win->m_widget; + if (win->m_wxwindow) m_widget = win->m_wxwindow; m_retValue = wxDragCancel; m_data = data; diff --git a/src/gtk/filedlg.cpp b/src/gtk/filedlg.cpp index e3b9952413..bd7d405395 100644 --- a/src/gtk/filedlg.cpp +++ b/src/gtk/filedlg.cpp @@ -57,7 +57,7 @@ void gtk_filedialog_ok_callback( GtkWidget *WXUNUSED(widget), wxFileDialog *dial int style = dialog->GetStyle(); - GtkFileSelection *filedlg = GTK_FILE_SELECTION(dialog->GetHandle()); + GtkFileSelection *filedlg = GTK_FILE_SELECTION(dialog->m_widget); char *filename = gtk_file_selection_get_filename(filedlg); if ( (style & wxSAVE) && ( style & wxOVERWRITE_PROMPT ) ) diff --git a/src/gtk/frame.cpp b/src/gtk/frame.cpp index 1a01040022..3065fbcdba 100644 --- a/src/gtk/frame.cpp +++ b/src/gtk/frame.cpp @@ -64,7 +64,7 @@ static void gtk_frame_size_callback( GtkWidget *WXUNUSED(widget), GtkAllocation* { if (g_isIdle) wxapp_install_idle_handler(); - if (!win->HasVMT()) return; + if (!win->m_hasVMT) return; /* printf( "OnFrameResize from " ); @@ -73,7 +73,7 @@ static void gtk_frame_size_callback( GtkWidget *WXUNUSED(widget), GtkAllocation* printf( ".\n" ); */ - if ((win->GetWidth() != alloc->width) || (win->GetHeight() != alloc->height)) + if ((win->m_width != alloc->width) || (win->m_height != alloc->height)) { win->InternalSetSize( alloc->width, alloc->height ); } @@ -107,7 +107,7 @@ static void gtk_menu_attached_callback( GtkWidget *WXUNUSED(widget), GtkWidget * { if (g_isIdle) wxapp_install_idle_handler(); - if (!win->HasVMT()) return; + if (!win->m_hasVMT) return; win->m_menuBarDetached = FALSE; win->UpdateSize(); @@ -121,7 +121,7 @@ static void gtk_menu_detached_callback( GtkWidget *WXUNUSED(widget), GtkWidget * { if (g_isIdle) wxapp_install_idle_handler(); - if (!win->HasVMT()) return; + if (!win->m_hasVMT) return; win->m_menuBarDetached = TRUE; win->UpdateSize(); @@ -135,7 +135,7 @@ static void gtk_toolbar_attached_callback( GtkWidget *WXUNUSED(widget), GtkWidge { if (g_isIdle) wxapp_install_idle_handler(); - if (!win->HasVMT()) return; + if (!win->m_hasVMT) return; win->m_toolBarDetached = FALSE; win->UpdateSize(); @@ -149,7 +149,7 @@ static void gtk_toolbar_detached_callback( GtkWidget *widget, GtkWidget *WXUNUSE { if (g_isIdle) wxapp_install_idle_handler(); - if (!win->HasVMT()) return; + if (!win->m_hasVMT) return; win->m_toolBarDetached = TRUE; win->UpdateSize(); @@ -163,11 +163,11 @@ static gint gtk_frame_configure_callback( GtkWidget *WXUNUSED(widget), GdkEventC { if (g_isIdle) wxapp_install_idle_handler(); - if (!win->HasVMT()) return FALSE; + if (!win->m_hasVMT) return FALSE; win->InternalSetPosition(event->x, event->y); - wxMoveEvent mevent( wxPoint(win->GetX(),win->GetY()), win->GetId() ); + wxMoveEvent mevent( wxPoint(win->m_x,win->m_y), win->GetId() ); mevent.SetEventObject( win ); win->GetEventHandler()->ProcessEvent( mevent ); @@ -215,14 +215,14 @@ gtk_frame_realized_callback( GtkWidget *widget, wxFrame *win ) } - gdk_window_set_decorations( win->GetHandle()->window, (GdkWMDecoration)decor); - gdk_window_set_functions( win->GetHandle()->window, (GdkWMFunction)func); + gdk_window_set_decorations( win->m_widget->window, (GdkWMDecoration)decor); + gdk_window_set_functions( win->m_widget->window, (GdkWMFunction)func); /* GTK's shrinking/growing policy */ if ((win->GetWindowStyle() & wxRESIZE_BORDER) == 0) - gtk_window_set_policy(GTK_WINDOW(win->GetHandle()), 0, 0, 1); + gtk_window_set_policy(GTK_WINDOW(win->m_widget), 0, 0, 1); else - gtk_window_set_policy(GTK_WINDOW(win->GetHandle()), 1, 1, 1); + gtk_window_set_policy(GTK_WINDOW(win->m_widget), 1, 1, 1); /* reset the icon */ if (win->m_icon != wxNullIcon) @@ -269,11 +269,11 @@ static void wxInsertChildInFrame( wxWindow* parent, wxWindow* child ) /* these are outside the client area */ wxFrame* frame = (wxFrame*) parent; gtk_myfixed_put( GTK_MYFIXED(frame->m_mainWidget), - GTK_WIDGET(child->GetHandle()), - child->GetX(), - child->GetY(), - child->GetWidth(), - child->GetHeight() ); + GTK_WIDGET(child->m_widget), + child->m_x, + child->m_y, + child->m_width, + child->m_height ); /* we connect to these events for recalculating the client area space when the toolbar is floating */ @@ -282,10 +282,10 @@ static void wxInsertChildInFrame( wxWindow* parent, wxWindow* child ) wxToolBar *toolBar = (wxToolBar*) child; if (toolBar->GetWindowStyle() & wxTB_DOCKABLE) { - gtk_signal_connect( GTK_OBJECT(toolBar->GetHandle()), "child_attached", + gtk_signal_connect( GTK_OBJECT(toolBar->m_widget), "child_attached", GTK_SIGNAL_FUNC(gtk_toolbar_attached_callback), (gpointer)parent ); - gtk_signal_connect( GTK_OBJECT(toolBar->GetHandle()), "child_detached", + gtk_signal_connect( GTK_OBJECT(toolBar->m_widget), "child_detached", GTK_SIGNAL_FUNC(gtk_toolbar_detached_callback), (gpointer)parent ); } } @@ -293,12 +293,12 @@ static void wxInsertChildInFrame( wxWindow* parent, wxWindow* child ) else { /* these are inside the client area */ - gtk_myfixed_put( GTK_MYFIXED(parent->GetWxWindow()), - GTK_WIDGET(child->GetHandle()), - child->GetX(), - child->GetY(), - child->GetWidth(), - child->GetHeight() ); + gtk_myfixed_put( GTK_MYFIXED(parent->m_wxwindow), + GTK_WIDGET(child->m_widget), + child->m_x, + child->m_y, + child->m_width, + child->m_height ); } /* resize on OnInternalIdle */ @@ -671,7 +671,7 @@ void wxFrame::GtkOnSize( int WXUNUSED(x), int WXUNUSED(y), int width, int height m_frameMenuBar->InternalSetPosition(xx, yy); m_frameMenuBar->InternalSetSize(ww, hh); gtk_myfixed_set_size( GTK_MYFIXED(m_mainWidget), - m_frameMenuBar->GetHandle(), + m_frameMenuBar->m_widget, xx, yy, ww, hh ); client_area_y_offset += hh; } @@ -688,7 +688,7 @@ void wxFrame::GtkOnSize( int WXUNUSED(x), int WXUNUSED(y), int width, int height yy += wxPLACE_HOLDER; } int ww = m_width - 2*m_miniEdge; - int hh = m_frameToolBar->GetHeight(); + 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) @@ -698,7 +698,7 @@ void wxFrame::GtkOnSize( int WXUNUSED(x), int WXUNUSED(y), int width, int height m_frameToolBar->InternalSetSize(ww, hh); gtk_myfixed_set_size( GTK_MYFIXED(m_mainWidget), - m_frameToolBar->GetHandle(), + m_frameToolBar->m_widget, xx, yy, ww, hh ); client_area_y_offset += hh; } @@ -726,7 +726,7 @@ void wxFrame::GtkOnSize( int WXUNUSED(x), int WXUNUSED(y), int width, int height m_frameStatusBar->InternalSetPosition(xx, yy); m_frameStatusBar->InternalSetSize(ww, hh); gtk_myfixed_set_size( GTK_MYFIXED(m_wxwindow), - m_frameStatusBar->GetHandle(), + m_frameStatusBar->m_widget, xx, yy, ww, hh ); } @@ -743,7 +743,7 @@ void wxFrame::GtkOnSize( int WXUNUSED(x), int WXUNUSED(y), int width, int height /* send size event to status bar */ if (m_frameStatusBar) { - wxSizeEvent event2( wxSize(m_frameStatusBar->GetWidth(),m_frameStatusBar->GetHeight()), m_frameStatusBar->GetId() ); + wxSizeEvent event2( wxSize(m_frameStatusBar->m_width,m_frameStatusBar->m_height), m_frameStatusBar->GetId() ); event2.SetEventObject( m_frameStatusBar ); m_frameStatusBar->GetEventHandler()->ProcessEvent( event2 ); } @@ -808,7 +808,7 @@ static void SetInvokingWindow( wxMenu *menu, wxWindow *win ) #if (GTK_MINOR_VERSION > 0) /* support for native hot keys */ - gtk_accel_group_attach( menu->m_accel, GTK_OBJECT(win->GetHandle())); + gtk_accel_group_attach( menu->m_accel, GTK_OBJECT(win->m_widget)); #endif wxNode *node = menu->GetItems().First(); @@ -847,18 +847,18 @@ void wxFrame::SetMenuBar( wxMenuBar *menuBar ) { m_frameMenuBar->SetParent(this); gtk_myfixed_put( GTK_MYFIXED(m_mainWidget), - m_frameMenuBar->GetHandle(), - m_frameMenuBar->GetX(), - m_frameMenuBar->GetY(), - m_frameMenuBar->GetWidth(), - m_frameMenuBar->GetHeight() ); + m_frameMenuBar->m_widget, + m_frameMenuBar->m_x, + m_frameMenuBar->m_y, + m_frameMenuBar->m_width, + m_frameMenuBar->m_height ); if (menuBar->GetWindowStyle() & wxMB_DOCKABLE) { - gtk_signal_connect( GTK_OBJECT(menuBar->GetHandle()), "child_attached", + gtk_signal_connect( GTK_OBJECT(menuBar->m_widget), "child_attached", GTK_SIGNAL_FUNC(gtk_menu_attached_callback), (gpointer)this ); - gtk_signal_connect( GTK_OBJECT(menuBar->GetHandle()), "child_detached", + gtk_signal_connect( GTK_OBJECT(menuBar->m_widget), "child_detached", GTK_SIGNAL_FUNC(gtk_menu_detached_callback), (gpointer)this ); } } diff --git a/src/gtk/listbox.cpp b/src/gtk/listbox.cpp index 4e6c9af4c4..10c1097045 100644 --- a/src/gtk/listbox.cpp +++ b/src/gtk/listbox.cpp @@ -76,7 +76,7 @@ gtk_listbox_button_press_callback( GtkWidget *widget, GdkEventButton *gdk_event, if (g_blockEventsOnDrag) return FALSE; if (g_blockEventsOnScroll) return FALSE; - if (!listbox->HasVMT()) return FALSE; + if (!listbox->m_hasVMT) return FALSE; int sel = listbox->GetIndex( widget ); @@ -130,7 +130,7 @@ gtk_listbox_key_press_callback( GtkWidget *widget, GdkEventKey *gdk_event, wxLis if (g_blockEventsOnDrag) return FALSE; - if (!listbox->HasVMT()) return FALSE; + if (!listbox->m_hasVMT) return FALSE; if (gdk_event->keyval != ' ') return FALSE; @@ -156,7 +156,7 @@ static void gtk_listitem_select_callback( GtkWidget *WXUNUSED(widget), wxListBox { if (g_isIdle) wxapp_install_idle_handler(); - if (!listbox->HasVMT()) return; + if (!listbox->m_hasVMT) return; if (g_blockEventsOnDrag) return; wxCommandEvent event(wxEVT_COMMAND_LISTBOX_SELECTED, listbox->GetId() ); diff --git a/src/gtk/mdi.cpp b/src/gtk/mdi.cpp index b82ab13b8d..a6e4317bcf 100644 --- a/src/gtk/mdi.cpp +++ b/src/gtk/mdi.cpp @@ -90,12 +90,12 @@ void wxMDIParentFrame::GtkOnSize( int x, int y, int width, int height ) wxMenuBar *menu_bar = child_frame->m_menuBar; if (!menu_bar) return; - if (!menu_bar->GetHandle()) return; + if (!menu_bar->m_widget) return; menu_bar->InternalSetPosition(0, 0); menu_bar->InternalSetSize(m_width, wxMENU_HEIGHT); gtk_myfixed_set_size( GTK_MYFIXED(m_mainWidget), - menu_bar->GetHandle(), + menu_bar->m_widget, 0, 0, m_width, wxMENU_HEIGHT ); } @@ -108,7 +108,7 @@ void wxMDIParentFrame::OnInternalIdle() if (m_justInserted) { - GtkNotebook *notebook = GTK_NOTEBOOK(m_clientWindow->GetHandle()); + GtkNotebook *notebook = GTK_NOTEBOOK(m_clientWindow->m_widget); gtk_notebook_set_page( notebook, g_list_length( notebook->children ) - 1 ); m_justInserted = FALSE; @@ -128,11 +128,11 @@ void wxMDIParentFrame::OnInternalIdle() { if (child_frame == active_child_frame) { - gtk_widget_show( child_frame->m_menuBar->GetHandle() ); + gtk_widget_show( child_frame->m_menuBar->m_widget ); visible_child_menu = TRUE; } else - gtk_widget_hide( child_frame->m_menuBar->GetHandle() ); + gtk_widget_hide( child_frame->m_menuBar->m_widget ); } node = node->Next(); } @@ -150,7 +150,7 @@ wxMDIChildFrame *wxMDIParentFrame::GetActiveChild() const { if (!m_clientWindow) return (wxMDIChildFrame*) NULL; - GtkNotebook *notebook = GTK_NOTEBOOK(m_clientWindow->GetHandle()); + GtkNotebook *notebook = GTK_NOTEBOOK(m_clientWindow->m_widget); if (!notebook) return (wxMDIChildFrame*) NULL; #if (GTK_MINOR_VERSION > 0) @@ -189,13 +189,13 @@ wxMDIClientWindow *wxMDIParentFrame::OnCreateClient() void wxMDIParentFrame::ActivateNext() { if (m_clientWindow) - gtk_notebook_next_page( GTK_NOTEBOOK(m_clientWindow->GetHandle()) ); + gtk_notebook_next_page( GTK_NOTEBOOK(m_clientWindow->m_widget) ); } void wxMDIParentFrame::ActivatePrevious() { if (m_clientWindow) - gtk_notebook_prev_page( GTK_NOTEBOOK(m_clientWindow->GetHandle()) ); + gtk_notebook_prev_page( GTK_NOTEBOOK(m_clientWindow->m_widget) ); } void wxMDIParentFrame::OnActivate( wxActivateEvent& WXUNUSED(event) ) @@ -293,12 +293,12 @@ void wxMDIChildFrame::SetMenuBar( wxMenuBar *menu_bar ) } /* the menu bar of the child window is shown in idle time as needed */ - gtk_widget_hide( m_menuBar->GetHandle() ); + gtk_widget_hide( m_menuBar->m_widget ); /* insert the invisible menu bar into the _parent_ mdi frame */ gtk_myfixed_put( GTK_MYFIXED(mdi_frame->m_mainWidget), - m_menuBar->GetHandle(), - 0, 0, mdi_frame->GetWidth(), wxMENU_HEIGHT ); + m_menuBar->m_widget, + 0, 0, mdi_frame->m_width, wxMENU_HEIGHT ); } } @@ -323,11 +323,11 @@ static void gtk_page_size_callback( GtkWidget *WXUNUSED(widget), GtkAllocation* { if (g_isIdle) wxapp_install_idle_handler(); - if ((win->GetX() == alloc->x) && - (win->GetY() == alloc->y) && - (win->GetWidth() == alloc->width) && - (win->GetHeight() == alloc->height) && - (win->IsSizeSet())) + if ((win->m_x == alloc->x) && + (win->m_y == alloc->y) && + (win->m_width == alloc->width) && + (win->m_height == alloc->height) && + (win->m_sizeSet)) { return; } @@ -347,12 +347,12 @@ static void wxInsertChildInMDI( wxMDIClientWindow* parent, wxMDIChildFrame* chil GtkWidget *label_widget = gtk_label_new( s.mbc_str() ); gtk_misc_set_alignment( GTK_MISC(label_widget), 0.0, 0.5 ); - gtk_signal_connect( GTK_OBJECT(child->GetHandle()), "size_allocate", + gtk_signal_connect( GTK_OBJECT(child->m_widget), "size_allocate", GTK_SIGNAL_FUNC(gtk_page_size_callback), (gpointer)child ); - GtkNotebook *notebook = GTK_NOTEBOOK(parent->GetHandle()); + GtkNotebook *notebook = GTK_NOTEBOOK(parent->m_widget); - gtk_notebook_append_page( notebook, child->GetHandle(), label_widget ); + gtk_notebook_append_page( notebook, child->m_widget, label_widget ); child->m_page = (GtkNotebookPage*) (g_list_last(notebook->children)->data); diff --git a/src/gtk/minifram.cpp b/src/gtk/minifram.cpp index 80a6a879b2..e4267e0a7f 100644 --- a/src/gtk/minifram.cpp +++ b/src/gtk/minifram.cpp @@ -65,7 +65,7 @@ static void gtk_window_own_expose_callback( GtkWidget *widget, GdkEventExpose *g { if (g_isIdle) wxapp_install_idle_handler(); - if (!win->HasVMT()) return; + if (!win->m_hasVMT) return; if (gdk_event->count > 0) return; gtk_draw_shadow( widget->style, @@ -73,7 +73,7 @@ static void gtk_window_own_expose_callback( GtkWidget *widget, GdkEventExpose *g GTK_STATE_NORMAL, GTK_SHADOW_OUT, 0, 0, - win->GetWidth(), win->GetHeight() ); + win->m_width, win->m_height ); if (!win->m_title.IsEmpty() && ((win->GetWindowStyle() & wxCAPTION) || @@ -89,7 +89,7 @@ static void gtk_window_own_expose_callback( GtkWidget *widget, GdkEventExpose *g gdk_draw_rectangle( widget->window, gc, TRUE, x, 3, - win->GetWidth() - 4 - x, + win->m_width - 4 - x, font->ascent + font->descent+1 ); gdk_gc_set_foreground( gc, &widget->style->white ); @@ -110,14 +110,14 @@ static void gtk_window_own_draw_callback( GtkWidget *widget, GdkRectangle *WXUNU { if (g_isIdle) wxapp_install_idle_handler(); - if (!win->HasVMT()) return; + if (!win->m_hasVMT) return; gtk_draw_shadow( widget->style, widget->window, GTK_STATE_NORMAL, GTK_SHADOW_OUT, 0, 0, - win->GetWidth(), win->GetHeight() ); + win->m_width, win->m_height ); if (!win->m_title.IsEmpty() && ((win->GetWindowStyle() & wxCAPTION) || @@ -133,7 +133,7 @@ static void gtk_window_own_draw_callback( GtkWidget *widget, GdkRectangle *WXUNU gdk_draw_rectangle( widget->window, gc, TRUE, x, 3, - win->GetWidth() - 4 - x, + win->m_width - 4 - x, font->ascent + font->descent+1 ); gdk_gc_set_foreground( gc, &widget->style->white ); @@ -154,7 +154,7 @@ static gint gtk_window_button_press_callback( GtkWidget *widget, GdkEventButton { if (g_isIdle) wxapp_install_idle_handler(); - if (!win->HasVMT()) return FALSE; + if (!win->m_hasVMT) return FALSE; if (g_blockEventsOnDrag) return TRUE; if (g_blockEventsOnScroll) return TRUE; @@ -174,7 +174,7 @@ static gint gtk_window_button_press_callback( GtkWidget *widget, GdkEventButton win->m_diffX = (int)gdk_event->x; win->m_diffY = (int)gdk_event->y; - DrawFrame( widget, 0, 0, win->GetWidth(), win->GetHeight() ); + DrawFrame( widget, 0, 0, win->m_width, win->m_height ); win->m_oldX = 0; win->m_oldY = 0; @@ -191,7 +191,7 @@ static gint gtk_window_button_release_callback( GtkWidget *widget, GdkEventButto { if (g_isIdle) wxapp_install_idle_handler(); - if (!win->HasVMT()) return FALSE; + if (!win->m_hasVMT) return FALSE; if (g_blockEventsOnDrag) return TRUE; if (g_blockEventsOnScroll) return TRUE; @@ -202,7 +202,7 @@ static gint gtk_window_button_release_callback( GtkWidget *widget, GdkEventButto int x = (int)gdk_event->x; int y = (int)gdk_event->y; - DrawFrame( widget, win->m_oldX, win->m_oldY, win->GetWidth(), win->GetHeight() ); + DrawFrame( widget, win->m_oldX, win->m_oldY, win->m_width, win->m_height ); gdk_pointer_ungrab ( GDK_CURRENT_TIME ); int org_x = 0; int org_y = 0; @@ -210,7 +210,7 @@ static gint gtk_window_button_release_callback( GtkWidget *widget, GdkEventButto x += org_x - win->m_diffX; y += org_y - win->m_diffY; win->InternalSetPosition(x, y); - gtk_widget_set_uposition( win->GetWidget(), x, y ); + gtk_widget_set_uposition( win->m_widget, x, y ); return TRUE; } @@ -223,7 +223,7 @@ static gint gtk_window_motion_notify_callback( GtkWidget *widget, GdkEventMotion { if (g_isIdle) wxapp_install_idle_handler(); - if (!win->HasVMT()) return FALSE; + if (!win->m_hasVMT) return FALSE; if (g_blockEventsOnDrag) return TRUE; if (g_blockEventsOnScroll) return TRUE; @@ -240,10 +240,10 @@ static gint gtk_window_motion_notify_callback( GtkWidget *widget, GdkEventMotion gdk_event->state = state; } - DrawFrame( widget, win->m_oldX, win->m_oldY, win->GetWidth(), win->GetHeight() ); + DrawFrame( widget, win->m_oldX, win->m_oldY, win->m_width, win->m_height ); win->m_oldX = (int)gdk_event->x - win->m_diffX; win->m_oldY = (int)gdk_event->y - win->m_diffY; - DrawFrame( widget, win->m_oldX, win->m_oldY, win->GetWidth(), win->GetHeight() ); + DrawFrame( widget, win->m_oldX, win->m_oldY, win->m_width, win->m_height ); return TRUE; } diff --git a/src/gtk/notebook.cpp b/src/gtk/notebook.cpp index 3ca57db3b0..ccb0e81623 100644 --- a/src/gtk/notebook.cpp +++ b/src/gtk/notebook.cpp @@ -125,10 +125,10 @@ static void gtk_page_size_callback( GtkWidget *WXUNUSED(widget), GtkAllocation* { if (g_isIdle) wxapp_install_idle_handler(); - if ((win->GetX() == alloc->x) && - (win->GetY() == alloc->y) && - (win->GetWidth() == alloc->width) && - (win->GetHeight() == alloc->height)) + if ((win->m_x == alloc->x) && + (win->m_y == alloc->y) && + (win->m_width == alloc->width) && + (win->m_height == alloc->height)) { return; } @@ -149,7 +149,7 @@ gtk_notebook_key_press_callback( GtkWidget *widget, GdkEventKey *gdk_event, wxNo if (g_blockEventsOnDrag) return FALSE; - if (!notebook->HasVMT()) return FALSE; + if (!notebook->m_hasVMT) return FALSE; /* this code makes jumping down from the handles of the notebooks to the actual items in the visible notebook page possible with @@ -188,16 +188,16 @@ static void wxInsertChildInNotebook( wxNotebook* parent, wxWindow* child ) page->m_box = gtk_hbox_new (FALSE, 0); gtk_container_border_width(GTK_CONTAINER(page->m_box), 2); - GtkNotebook *notebook = GTK_NOTEBOOK(parent->GetWidget()); + GtkNotebook *notebook = GTK_NOTEBOOK(parent->m_widget); page->m_client = child; - gtk_notebook_append_page( notebook, child->GetWidget(), page->m_box ); + gtk_notebook_append_page( notebook, child->m_widget, page->m_box ); page->m_page = (GtkNotebookPage*) (g_list_last(notebook->children)->data); page->m_parent = notebook; - gtk_signal_connect( GTK_OBJECT(child->GetWidget()), "size_allocate", + gtk_signal_connect( GTK_OBJECT(child->m_widget), "size_allocate", GTK_SIGNAL_FUNC(gtk_page_size_callback), (gpointer)child ); wxASSERT_MSG( page->m_page, _T("Notebook page creation error") ); diff --git a/src/gtk/radiobox.cpp b/src/gtk/radiobox.cpp index 3637dffb06..432496cd91 100644 --- a/src/gtk/radiobox.cpp +++ b/src/gtk/radiobox.cpp @@ -40,7 +40,7 @@ static void gtk_radiobutton_clicked_callback( GtkWidget *WXUNUSED(widget), wxRad { if (g_isIdle) wxapp_install_idle_handler(); - if (!rb->HasVMT()) return; + if (!rb->m_hasVMT) return; if (g_blockEventsOnDrag) return; if (rb->m_alreadySent) @@ -108,7 +108,7 @@ bool wxRadioBox::Create( wxWindow *parent, wxWindowID id, const wxString& title, gtk_signal_connect( GTK_OBJECT(m_radio), "clicked", GTK_SIGNAL_FUNC(gtk_radiobutton_clicked_callback), (gpointer*)this ); - gtk_myfixed_put( GTK_MYFIXED(m_parent->GetWxWindow()), + gtk_myfixed_put( GTK_MYFIXED(m_parent->m_wxwindow), GTK_WIDGET(m_radio), m_x+10, m_y+10+(i*24), 10, 10 ); } @@ -179,7 +179,7 @@ wxSize wxRadioBox::LayoutItems() int len = 22+gdk_string_measure( font, label->label ); if (len > max_len) max_len = len; - gtk_myfixed_move( GTK_MYFIXED(m_parent->GetWxWindow()), button, m_x+x, m_y+y ); + gtk_myfixed_move( GTK_MYFIXED(m_parent->m_wxwindow), button, m_x+x, m_y+y ); y += 20; node = node->Next(); @@ -193,7 +193,7 @@ wxSize wxRadioBox::LayoutItems() { GtkWidget *button = GTK_WIDGET( node->Data() ); - gtk_myfixed_resize( GTK_MYFIXED(m_parent->GetWxWindow()), button, max_len, 20 ); + gtk_myfixed_resize( GTK_MYFIXED(m_parent->m_wxwindow), button, max_len, 20 ); node = node->Next(); if (!node) break; @@ -229,7 +229,7 @@ wxSize wxRadioBox::LayoutItems() { GtkWidget *button = GTK_WIDGET( node->Data() ); - gtk_myfixed_set_size( GTK_MYFIXED(m_parent->GetWxWindow()), button, m_x+x, m_y+y, max, 20 ); + gtk_myfixed_set_size( GTK_MYFIXED(m_parent->m_wxwindow), button, m_x+x, m_y+y, max, 20 ); x += max; node = node->Next(); diff --git a/src/gtk/radiobut.cpp b/src/gtk/radiobut.cpp index 26c87fc583..a3446422f7 100644 --- a/src/gtk/radiobut.cpp +++ b/src/gtk/radiobut.cpp @@ -38,7 +38,7 @@ void gtk_radiobutton_clicked_callback( GtkWidget *WXUNUSED(widget), wxRadioButto { if (g_isIdle) wxapp_install_idle_handler(); - if (!rb->HasVMT()) return; + if (!rb->m_hasVMT) return; if (rb->m_blockFirstEvent) { diff --git a/src/gtk/scrolbar.cpp b/src/gtk/scrolbar.cpp index 6fd20ff176..84a46924ef 100644 --- a/src/gtk/scrolbar.cpp +++ b/src/gtk/scrolbar.cpp @@ -41,7 +41,7 @@ static void gtk_scrollbar_callback( GtkWidget *WXUNUSED(widget), wxScrollBar *wi { if (g_isIdle) wxapp_install_idle_handler(); - if (!win->HasVMT()) return; + if (!win->m_hasVMT) return; if (g_blockEventsOnDrag) return; float diff = win->m_adjust->value - win->m_oldPos; diff --git a/src/gtk/slider.cpp b/src/gtk/slider.cpp index 393dddf10c..c28fc43e1b 100644 --- a/src/gtk/slider.cpp +++ b/src/gtk/slider.cpp @@ -39,7 +39,7 @@ static void gtk_slider_callback( GtkWidget *WXUNUSED(widget), wxSlider *win ) { if (g_isIdle) wxapp_install_idle_handler(); - if (!win->HasVMT()) return; + if (!win->m_hasVMT) return; if (g_blockEventsOnDrag) return; float diff = win->m_adjust->value - win->m_oldPos; diff --git a/src/gtk/spinbutt.cpp b/src/gtk/spinbutt.cpp index 239a565cd7..7b3b204283 100644 --- a/src/gtk/spinbutt.cpp +++ b/src/gtk/spinbutt.cpp @@ -42,7 +42,7 @@ static void gtk_spinbutt_callback( GtkWidget *WXUNUSED(widget), wxSpinButton *wi { if (g_isIdle) wxapp_install_idle_handler(); - if (!win->HasVMT()) return; + if (!win->m_hasVMT) return; if (g_blockEventsOnDrag) return; float diff = win->m_adjust->value - win->m_oldPos; diff --git a/src/gtk/textctrl.cpp b/src/gtk/textctrl.cpp index 0d41807702..5033f179cc 100644 --- a/src/gtk/textctrl.cpp +++ b/src/gtk/textctrl.cpp @@ -46,7 +46,7 @@ gtk_text_changed_callback( GtkWidget *WXUNUSED(widget), wxTextCtrl *win ) { if (g_isIdle) wxapp_install_idle_handler(); - if (!win->HasVMT()) return; + if (!win->m_hasVMT) return; win->SetModified(); @@ -67,7 +67,7 @@ gtk_scrollbar_changed_callback( GtkWidget *WXUNUSED(widget), wxTextCtrl *win ) win->CalculateScrollbar(); - if (!win->HasVMT()) return; + if (!win->m_hasVMT) return; } //----------------------------------------------------------------------------- diff --git a/src/gtk/window.cpp b/src/gtk/window.cpp index 17b690e47b..dcf7519e32 100644 --- a/src/gtk/window.cpp +++ b/src/gtk/window.cpp @@ -176,25 +176,21 @@ void debug_focus_in( GtkWidget* widget, const wxChar* name, const wxChar *window #endif // Debug //----------------------------------------------------------------------------- -// local code (see below) +// idle system //----------------------------------------------------------------------------- -static void InitAdjustment(GtkAdjustment *adjust) -{ - adjust->lower = 0.0; - adjust->upper = 1.0; - adjust->value = 0.0; - adjust->step_increment = 1.0; - adjust->page_increment = 1.0; - adjust->page_size = 5.0; - gtk_signal_emit_by_name( GTK_OBJECT(adjust), "changed" ); -} +extern void wxapp_install_idle_handler(); +extern bool g_isIdle; + +//----------------------------------------------------------------------------- +// local code (see below) +//----------------------------------------------------------------------------- #if (GTK_MINOR_VERSION > 0) static void draw_frame( GtkWidget *widget, wxWindow *win ) { - if (!win->HasVMT()) + if (!win->m_hasVMT) return; int dw = 0; @@ -240,7 +236,7 @@ static void draw_frame( GtkWidget *widget, wxWindow *win ) GTK_STATE_NORMAL, GTK_SHADOW_OUT, dx, dy, - win->GetWidth()-dw, win->GetHeight()-dh ); + win->m_width-dw, win->m_height-dh ); return; } @@ -251,7 +247,7 @@ static void draw_frame( GtkWidget *widget, wxWindow *win ) GTK_STATE_NORMAL, GTK_SHADOW_IN, dx, dy, - win->GetWidth()-dw, win->GetHeight()-dh ); + win->m_width-dw, win->m_height-dh ); return; } } @@ -283,7 +279,7 @@ static void gtk_window_own_draw_callback( GtkWidget *widget, GdkRectangle *WXUNU static void gtk_window_expose_callback( GtkWidget *WXUNUSED(widget), GdkEventExpose *gdk_event, wxWindow *win ) { - if ( !win->HasVMT() ) + if ( !win->m_hasVMT ) return; win->GetUpdateRegion().Union( gdk_event->area.x, @@ -314,7 +310,10 @@ static void gtk_window_expose_callback( GtkWidget *WXUNUSED(widget), GdkEventExp static void gtk_window_draw_callback( GtkWidget *WXUNUSED(widget), GdkRectangle *rect, wxWindow *win ) { - if ( !win->HasVMT() ) + if (g_isIdle) + wxapp_install_idle_handler(); + + if (!win->m_hasVMT) return; win->GetUpdateRegion().Union( rect->x, rect->y, @@ -333,7 +332,10 @@ static void gtk_window_draw_callback( GtkWidget *WXUNUSED(widget), GdkRectangle static gint gtk_window_key_press_callback( GtkWidget *widget, GdkEventKey *gdk_event, wxWindow *win ) { - if (!win->HasVMT()) return FALSE; + if (g_isIdle) + wxapp_install_idle_handler(); + + if (!win->m_hasVMT) return FALSE; if (g_blockEventsOnDrag) return FALSE; /* @@ -478,7 +480,7 @@ static gint gtk_window_key_press_callback( GtkWidget *widget, GdkEventKey *gdk_e Damn, I forgot why this didn't work, but it didn't work. // win is a panel: up can be propagated to the panel - if ((!ret) && (win->GetWxWindow()) && (win->m_parent) && (win->m_parent->AcceptsFocus()) && + if ((!ret) && (win->m_wxwindow) && (win->m_parent) && (win->m_parent->AcceptsFocus()) && (gdk_event->keyval == GDK_Up)) { win->m_parent->SetFocus(); @@ -486,7 +488,7 @@ static gint gtk_window_key_press_callback( GtkWidget *widget, GdkEventKey *gdk_e } // win is a panel: left/right can be propagated to the panel - if ((!ret) && (win->GetWxWindow()) && + if ((!ret) && (win->m_wxwindow) && ((gdk_event->keyval == GDK_Right) || (gdk_event->keyval == GDK_Left) || (gdk_event->keyval == GDK_Up) || (gdk_event->keyval == GDK_Down))) { @@ -512,7 +514,10 @@ static gint gtk_window_key_press_callback( GtkWidget *widget, GdkEventKey *gdk_e static gint gtk_window_key_release_callback( GtkWidget *widget, GdkEventKey *gdk_event, wxWindow *win ) { - if (!win->HasVMT()) return FALSE; + if (g_isIdle) + wxapp_install_idle_handler(); + + if (!win->m_hasVMT) return FALSE; if (g_blockEventsOnDrag) return FALSE; /* @@ -628,33 +633,43 @@ static gint gtk_window_key_release_callback( GtkWidget *widget, GdkEventKey *gdk static gint gtk_window_button_press_callback( GtkWidget *widget, GdkEventButton *gdk_event, wxWindow *win ) { - if (!win->HasVMT()) return FALSE; + if (g_isIdle) + wxapp_install_idle_handler(); + +/* + wxPrintf( _T("1) OnButtonPress from ") ); + if (win->GetClassInfo() && win->GetClassInfo()->GetClassName()) + wxPrintf( win->GetClassInfo()->GetClassName() ); + wxPrintf( _T(".\n") ); +*/ + + if (!win->m_hasVMT) return FALSE; if (g_blockEventsOnDrag) return TRUE; if (g_blockEventsOnScroll) return TRUE; if (!win->IsOwnGtkWindow( gdk_event->window )) return FALSE; - if (win->GetWxWindow()) + if (win->m_wxwindow) { - if (GTK_WIDGET_CAN_FOCUS(win->GetWxWindow()) && !GTK_WIDGET_HAS_FOCUS (win->GetWxWindow()) ) + if (GTK_WIDGET_CAN_FOCUS(win->m_wxwindow) && !GTK_WIDGET_HAS_FOCUS (win->m_wxwindow) ) { - gtk_widget_grab_focus (win->GetWxWindow()); + gtk_widget_grab_focus (win->m_wxwindow); /* - printf( "GrabFocus from " ); + wxPrintf( _T("GrabFocus from ") ); if (win->GetClassInfo() && win->GetClassInfo()->GetClassName()) - printf( win->GetClassInfo()->GetClassName() ); - printf( ".\n" ); + wxPrintf( win->GetClassInfo()->GetClassName() ); + wxPrintf( _T(".\n") ); */ } } /* - printf( "OnButtonPress from " ); + wxPrintf( _T("2) OnButtonPress from ") ); if (win->GetClassInfo() && win->GetClassInfo()->GetClassName()) - printf( win->GetClassInfo()->GetClassName() ); - printf( ".\n" ); + wxPrintf( win->GetClassInfo()->GetClassName() ); + wxPrintf( _T(".\n") ); */ wxEventType event_type = wxEVT_LEFT_DOWN; @@ -709,17 +724,15 @@ static gint gtk_window_button_press_callback( GtkWidget *widget, GdkEventButton { wxWindow *child = (wxWindow*)node->Data(); - if ( child->IsStaticBox() ) + if (child->m_isStaticBox) { // wxStaticBox is transparent in the box itself - int x = event.m_x, - y = event.m_y; - - wxRect rectChild(child->GetRect()); - int xx1 = rectChild.GetLeft(), - yy1 = rectChild.GetTop(), - xx2 = rectChild.GetRight(), - yy2 = rectChild.GetBottom(); + int x = event.m_x; + int y = event.m_y; + int xx1 = child->m_x; + int yy1 = child->m_y; + int xx2 = child->m_x + child->m_width; + int yy2 = child->m_x + child->m_height; // left if (((x >= xx1) && (x <= xx1+10) && (y >= yy1) && (y <= yy2)) || @@ -731,23 +744,23 @@ static gint gtk_window_button_press_callback( GtkWidget *widget, GdkEventButton ((x >= xx1) && (x <= xx2) && (y >= yy2-1) && (y <= yy2))) { win = child; - event.m_x -= child->GetX(); - event.m_y -= child->GetY(); + event.m_x -= child->m_x; + event.m_y -= child->m_y; break; } } else { - if ((child->GetWxWindow() == (GtkWidget*) NULL) && - (child->GetX() <= event.m_x) && - (child->GetY() <= event.m_y) && - (child->GetX()+child->GetWidth() >= event.m_x) && - (child->GetY()+child->GetHeight() >= event.m_y)) + if ((child->m_wxwindow == (GtkWidget*) NULL) && + (child->m_x <= event.m_x) && + (child->m_y <= event.m_y) && + (child->m_x+child->m_width >= event.m_x) && + (child->m_y+child->m_height >= event.m_y)) { win = child; - event.m_x -= child->GetX(); - event.m_y -= child->GetY(); + event.m_x -= child->m_x; + event.m_y -= child->m_y; break; } } @@ -774,7 +787,10 @@ static gint gtk_window_button_press_callback( GtkWidget *widget, GdkEventButton static gint gtk_window_button_release_callback( GtkWidget *widget, GdkEventButton *gdk_event, wxWindow *win ) { - if (!win->HasVMT()) return FALSE; + if (g_isIdle) + wxapp_install_idle_handler(); + + if (!win->m_hasVMT) return FALSE; if (g_blockEventsOnDrag) return FALSE; if (g_blockEventsOnScroll) return FALSE; @@ -817,15 +833,15 @@ static gint gtk_window_button_release_callback( GtkWidget *widget, GdkEventButto { wxWindow *child = (wxWindow*)node->Data(); - if (child->IsStaticBox() ) + if (child->m_isStaticBox) { // wxStaticBox is transparent in the box itself int x = event.m_x; int y = event.m_y; - int xx1 = child->GetX(); - int yy1 = child->GetY(); - int xx2 = child->GetX() + child->GetWidth(); - int yy2 = child->GetX() + child->GetHeight(); + int xx1 = child->m_x; + int yy1 = child->m_y; + int xx2 = child->m_x + child->m_width; + int yy2 = child->m_x + child->m_height; // left if (((x >= xx1) && (x <= xx1+10) && (y >= yy1) && (y <= yy2)) || @@ -837,23 +853,23 @@ static gint gtk_window_button_release_callback( GtkWidget *widget, GdkEventButto ((x >= xx1) && (x <= xx2) && (y >= yy2-1) && (y <= yy2))) { win = child; - event.m_x -= child->GetX(); - event.m_y -= child->GetY(); + event.m_x -= child->m_x; + event.m_y -= child->m_y; break; } } else { - if ((child->GetWxWindow() == (GtkWidget*) NULL) && - (child->GetX() <= event.m_x) && - (child->GetY() <= event.m_y) && - (child->GetX()+child->GetWidth() >= event.m_x) && - (child->GetY()+child->GetHeight() >= event.m_y)) + if ((child->m_wxwindow == (GtkWidget*) NULL) && + (child->m_x <= event.m_x) && + (child->m_y <= event.m_y) && + (child->m_x+child->m_width >= event.m_x) && + (child->m_y+child->m_height >= event.m_y)) { win = child; - event.m_x -= child->GetX(); - event.m_y -= child->GetY(); + event.m_x -= child->m_x; + event.m_y -= child->m_y; break; } } @@ -878,7 +894,10 @@ static gint gtk_window_button_release_callback( GtkWidget *widget, GdkEventButto static gint gtk_window_motion_notify_callback( GtkWidget *widget, GdkEventMotion *gdk_event, wxWindow *win ) { - if (!win->HasVMT()) return FALSE; + if (g_isIdle) + wxapp_install_idle_handler(); + + if (!win->m_hasVMT) return FALSE; if (g_blockEventsOnDrag) return FALSE; if (g_blockEventsOnScroll) return FALSE; @@ -924,15 +943,15 @@ static gint gtk_window_motion_notify_callback( GtkWidget *widget, GdkEventMotion { wxWindow *child = (wxWindow*)node->Data(); - if ( child->IsStaticBox() ) + if (child->m_isStaticBox) { // wxStaticBox is transparent in the box itself int x = event.m_x; int y = event.m_y; - int xx1 = child->GetX(); - int yy1 = child->GetY(); - int xx2 = child->GetX() + child->GetWidth(); - int yy2 = child->GetX() + child->GetHeight(); + int xx1 = child->m_x; + int yy1 = child->m_y; + int xx2 = child->m_x + child->m_width; + int yy2 = child->m_x + child->m_height; // left if (((x >= xx1) && (x <= xx1+10) && (y >= yy1) && (y <= yy2)) || @@ -944,23 +963,23 @@ static gint gtk_window_motion_notify_callback( GtkWidget *widget, GdkEventMotion ((x >= xx1) && (x <= xx2) && (y >= yy2-1) && (y <= yy2))) { win = child; - event.m_x -= child->GetX(); - event.m_y -= child->GetY(); + event.m_x -= child->m_x; + event.m_y -= child->m_y; break; } } else { - if ((child->GetWxWindow() == (GtkWidget*) NULL) && - (child->GetX() <= event.m_x) && - (child->GetY() <= event.m_y) && - (child->GetX()+child->GetWidth() >= event.m_x) && - (child->GetY()+child->GetHeight() >= event.m_y)) + if ((child->m_wxwindow == (GtkWidget*) NULL) && + (child->m_x <= event.m_x) && + (child->m_y <= event.m_y) && + (child->m_x+child->m_width >= event.m_x) && + (child->m_y+child->m_height >= event.m_y)) { win = child; - event.m_x -= child->GetX(); - event.m_y -= child->GetY(); + event.m_x -= child->m_x; + event.m_y -= child->m_y; break; } } @@ -985,16 +1004,19 @@ static gint gtk_window_motion_notify_callback( GtkWidget *widget, GdkEventMotion static gint gtk_window_focus_in_callback( GtkWidget *widget, GdkEvent *WXUNUSED(event), wxWindow *win ) { - if (!win->HasVMT()) return FALSE; + if (g_isIdle) + wxapp_install_idle_handler(); + + if (!win->m_hasVMT) return FALSE; if (g_blockEventsOnDrag) return FALSE; g_focusWindow = win; - if (win->GetWxWindow()) + if (win->m_wxwindow) { - if (GTK_WIDGET_CAN_FOCUS(win->GetWxWindow())) + if (GTK_WIDGET_CAN_FOCUS(win->m_wxwindow)) { - GTK_WIDGET_SET_FLAGS (win->GetWxWindow(), GTK_HAS_FOCUS); + GTK_WIDGET_SET_FLAGS (win->m_wxwindow, GTK_HAS_FOCUS); /* printf( "SetFocus flag from " ); if (win->GetClassInfo() && win->GetClassInfo()->GetClassName()) @@ -1032,13 +1054,16 @@ static gint gtk_window_focus_in_callback( GtkWidget *widget, GdkEvent *WXUNUSED( static gint gtk_window_focus_out_callback( GtkWidget *widget, GdkEvent *WXUNUSED(event), wxWindow *win ) { - if (!win->HasVMT()) return FALSE; + if (g_isIdle) + wxapp_install_idle_handler(); + + if (!win->m_hasVMT) return FALSE; if (g_blockEventsOnDrag) return FALSE; - if (win->GetWxWindow()) + if (win->m_wxwindow) { - if (GTK_WIDGET_CAN_FOCUS(win->GetWxWindow())) - GTK_WIDGET_UNSET_FLAGS (win->GetWxWindow(), GTK_HAS_FOCUS); + if (GTK_WIDGET_CAN_FOCUS(win->m_wxwindow)) + GTK_WIDGET_UNSET_FLAGS (win->m_wxwindow, GTK_HAS_FOCUS); } /* @@ -1066,22 +1091,16 @@ static gint gtk_window_focus_out_callback( GtkWidget *widget, GdkEvent *WXUNUSED static gint gtk_window_enter_callback( GtkWidget *widget, GdkEventCrossing *gdk_event, wxWindow *win ) { - if ( !win->HasVMT() || g_blockEventsOnDrag ) - return FALSE; + if (g_isIdle) + wxapp_install_idle_handler(); - GdkWindow *window = widget->window; - if ( window != gdk_event->window ) - return FALSE; + if (!win->m_hasVMT) return FALSE; + if (g_blockEventsOnDrag) return FALSE; - if ( window && win->GetCursor().Ok() ) - gdk_window_set_cursor( window, win->GetCursor().GetCursor() ); + if (!win->IsOwnGtkWindow( gdk_event->window )) return FALSE; -/* - printf( "OnEnter from " ); - if (win->GetClassInfo() && win->GetClassInfo()->GetClassName()) - printf( win->GetClassInfo()->GetClassName() ); - printf( ".\n" ); -*/ + if (widget->window && win->GetCursor().Ok() ) + gdk_window_set_cursor( widget->window, win->GetCursor().GetCursor() ); wxMouseEvent event( wxEVT_ENTER_WINDOW ); event.SetEventObject( win ); @@ -1090,7 +1109,7 @@ static gint gtk_window_enter_callback( GtkWidget *widget, GdkEventCrossing *gdk_ int y = 0; GdkModifierType state = (GdkModifierType)0; - gdk_window_get_pointer( window, &x, &y, &state ); + gdk_window_get_pointer( widget->window, &x, &y, &state ); event.m_shiftDown = (state & GDK_SHIFT_MASK); event.m_controlDown = (state & GDK_CONTROL_MASK); @@ -1118,22 +1137,16 @@ static gint gtk_window_enter_callback( GtkWidget *widget, GdkEventCrossing *gdk_ static gint gtk_window_leave_callback( GtkWidget *widget, GdkEventCrossing *gdk_event, wxWindow *win ) { - if ( !win->HasVMT() || g_blockEventsOnDrag ) - return FALSE; + if (g_isIdle) + wxapp_install_idle_handler(); - GdkWindow *window = widget->window; - if ( window != gdk_event->window ) - return FALSE; - - if ( window && win->GetCursor().Ok() ) - gdk_window_set_cursor( window, wxSTANDARD_CURSOR->GetCursor() ); + if (!win->m_hasVMT) return FALSE; + if (g_blockEventsOnDrag) return FALSE; -/* - printf( "OnLeave from " ); - if (win->GetClassInfo() && win->GetClassInfo()->GetClassName()) - printf( win->GetClassInfo()->GetClassName() ); - printf( ".\n" ); -*/ + if (!win->IsOwnGtkWindow( gdk_event->window )) return FALSE; + + if (widget->window && win->GetCursor().Ok() ) + gdk_window_set_cursor( widget->window, wxSTANDARD_CURSOR->GetCursor() ); wxMouseEvent event( wxEVT_LEAVE_WINDOW ); event.SetEventObject( win ); @@ -1170,25 +1183,21 @@ static gint gtk_window_leave_callback( GtkWidget *widget, GdkEventCrossing *gdk_ static void gtk_window_vscroll_callback( GtkWidget *WXUNUSED(widget), wxWindow *win ) { - if (g_blockEventsOnDrag) return; + if (g_isIdle) + wxapp_install_idle_handler(); -/* - printf( "OnVScroll from " ); - if (win->GetClassInfo() && win->GetClassInfo()->GetClassName()) - printf( win->GetClassInfo()->GetClassName() ); - printf( ".\n" ); -*/ + if (g_blockEventsOnDrag) return; - if (!win->HasVMT()) return; + if (!win->m_hasVMT) return; - float diff = win->GetVAdjust()->value - win->GetOldVerticalPos(); + float diff = win->m_vAdjust->value - win->m_oldVerticalPos; if (fabs(diff) < 0.2) return; - win->SetOldVerticalPos(win->GetVAdjust()->value); + win->m_oldVerticalPos = win->m_vAdjust->value; wxEventType command = wxEVT_NULL; - float line_step = win->GetVAdjust()->step_increment; - float page_step = win->GetVAdjust()->page_increment; + float line_step = win->m_vAdjust->step_increment; + float page_step = win->m_vAdjust->page_increment; if (win->IsScrolling()) { @@ -1196,8 +1205,8 @@ static void gtk_window_vscroll_callback( GtkWidget *WXUNUSED(widget), wxWindow * } else { - if (fabs(win->GetVAdjust()->value-win->GetVAdjust()->lower) < 0.2) command = wxEVT_SCROLL_BOTTOM; - else if (fabs(win->GetVAdjust()->value-win->GetVAdjust()->upper) < 0.2) command = wxEVT_SCROLL_TOP; + if (fabs(win->m_vAdjust->value-win->m_vAdjust->lower) < 0.2) command = wxEVT_SCROLL_BOTTOM; + else if (fabs(win->m_vAdjust->value-win->m_vAdjust->upper) < 0.2) command = wxEVT_SCROLL_TOP; else if (fabs(diff-line_step) < 0.2) command = wxEVT_SCROLL_LINEDOWN; else if (fabs(diff+line_step) < 0.2) command = wxEVT_SCROLL_LINEUP; else if (fabs(diff-page_step) < 0.2) command = wxEVT_SCROLL_PAGEDOWN; @@ -1205,7 +1214,7 @@ static void gtk_window_vscroll_callback( GtkWidget *WXUNUSED(widget), wxWindow * else command = wxEVT_SCROLL_THUMBTRACK; } - int value = (int)(win->GetVAdjust()->value+0.5); + int value = (int)(win->m_vAdjust->value+0.5); wxScrollEvent event( command, win->GetId(), value, wxVERTICAL ); event.SetEventObject( win ); @@ -1218,25 +1227,20 @@ static void gtk_window_vscroll_callback( GtkWidget *WXUNUSED(widget), wxWindow * static void gtk_window_hscroll_callback( GtkWidget *WXUNUSED(widget), wxWindow *win ) { - if (g_blockEventsOnDrag) return; - -/* - printf( "OnHScroll from " ); - if (win->GetClassInfo() && win->GetClassInfo()->GetClassName()) - printf( win->GetClassInfo()->GetClassName() ); - printf( ".\n" ); -*/ + if (g_isIdle) + wxapp_install_idle_handler(); - if (!win->HasVMT()) return; + if (g_blockEventsOnDrag) return; + if (!win->m_hasVMT) return; - float diff = win->GetHAdjust()->value - win->GetOldHorizontalPos(); + float diff = win->m_hAdjust->value - win->m_oldHorizontalPos; if (fabs(diff) < 0.2) return; - win->SetOldHorizontalPos( win->GetHAdjust()->value ); + win->m_oldHorizontalPos = win->m_hAdjust->value; wxEventType command = wxEVT_NULL; - float line_step = win->GetHAdjust()->step_increment; - float page_step = win->GetHAdjust()->page_increment; + float line_step = win->m_hAdjust->step_increment; + float page_step = win->m_hAdjust->page_increment; if (win->IsScrolling()) { @@ -1244,8 +1248,8 @@ static void gtk_window_hscroll_callback( GtkWidget *WXUNUSED(widget), wxWindow * } else { - if (fabs(win->GetHAdjust()->value-win->GetHAdjust()->lower) < 0.2) command = wxEVT_SCROLL_BOTTOM; - else if (fabs(win->GetHAdjust()->value-win->GetHAdjust()->upper) < 0.2) command = wxEVT_SCROLL_TOP; + if (fabs(win->m_hAdjust->value-win->m_hAdjust->lower) < 0.2) command = wxEVT_SCROLL_BOTTOM; + else if (fabs(win->m_hAdjust->value-win->m_hAdjust->upper) < 0.2) command = wxEVT_SCROLL_TOP; else if (fabs(diff-line_step) < 0.2) command = wxEVT_SCROLL_LINEDOWN; else if (fabs(diff+line_step) < 0.2) command = wxEVT_SCROLL_LINEUP; else if (fabs(diff-page_step) < 0.2) command = wxEVT_SCROLL_PAGEDOWN; @@ -1253,7 +1257,7 @@ static void gtk_window_hscroll_callback( GtkWidget *WXUNUSED(widget), wxWindow * else command = wxEVT_SCROLL_THUMBTRACK; } - int value = (int)(win->GetHAdjust()->value+0.5); + int value = (int)(win->m_hAdjust->value+0.5); wxScrollEvent event( command, win->GetId(), value, wxHORIZONTAL ); event.SetEventObject( win ); @@ -1266,19 +1270,14 @@ static void gtk_window_hscroll_callback( GtkWidget *WXUNUSED(widget), wxWindow * static void gtk_window_vscroll_change_callback( GtkWidget *WXUNUSED(widget), wxWindow *win ) { - if (g_blockEventsOnDrag) return; + if (g_isIdle) + wxapp_install_idle_handler(); -/* - printf( "OnVScroll change from " ); - if (win->GetClassInfo() && win->GetClassInfo()->GetClassName()) - printf( win->GetClassInfo()->GetClassName() ); - printf( ".\n" ); -*/ - - if (!win->HasVMT()) return; + if (g_blockEventsOnDrag) return; + if (!win->m_hasVMT) return; wxEventType command = wxEVT_SCROLL_THUMBTRACK; - int value = (int)(win->GetVAdjust()->value+0.5); + int value = (int)(win->m_vAdjust->value+0.5); wxScrollEvent event( command, win->GetId(), value, wxVERTICAL ); event.SetEventObject( win ); @@ -1291,19 +1290,14 @@ static void gtk_window_vscroll_change_callback( GtkWidget *WXUNUSED(widget), wxW static void gtk_window_hscroll_change_callback( GtkWidget *WXUNUSED(widget), wxWindow *win ) { - if (g_blockEventsOnDrag) return; - -/* - printf( "OnHScroll change from " ); - if (win->GetClassInfo() && win->GetClassInfo()->GetClassName()) - printf( win->GetClassInfo()->GetClassName() ); - printf( ".\n" ); -*/ + if (g_isIdle) + wxapp_install_idle_handler(); - if (!win->HasVMT()) return; + if (g_blockEventsOnDrag) return; + if (!win->m_hasVMT) return; wxEventType command = wxEVT_SCROLL_THUMBTRACK; - int value = (int)(win->GetHAdjust()->value+0.5); + int value = (int)(win->m_hAdjust->value+0.5); wxScrollEvent event( command, win->GetId(), value, wxHORIZONTAL ); event.SetEventObject( win ); @@ -1318,6 +1312,9 @@ static gint gtk_scrollbar_button_press_callback( GtkRange *WXUNUSED(widget), GdkEventButton *WXUNUSED(gdk_event), wxWindow *win ) { + if (g_isIdle) + wxapp_install_idle_handler(); + // don't test here as we can release the mouse while being over // a different window then the slider // @@ -1342,12 +1339,12 @@ static gint gtk_scrollbar_button_release_callback( GtkRange *widget, // // if (gdk_event->window != widget->slider) return FALSE; - GtkScrolledWindow *scrolledWindow = GTK_SCROLLED_WINDOW(win->GetHandle()); + GtkScrolledWindow *scrolledWindow = GTK_SCROLLED_WINDOW(win->m_widget); if (widget == GTK_RANGE(scrolledWindow->vscrollbar)) - gtk_signal_emit_by_name( GTK_OBJECT(win->GetHAdjust()), "value_changed" ); + gtk_signal_emit_by_name( GTK_OBJECT(win->m_hAdjust), "value_changed" ); else - gtk_signal_emit_by_name( GTK_OBJECT(win->GetVAdjust()), "value_changed" ); + gtk_signal_emit_by_name( GTK_OBJECT(win->m_vAdjust), "value_changed" ); win->SetScrolling( FALSE ); @@ -1364,6 +1361,47 @@ wxWindow *wxWindowBase::FindFocus() return g_focusWindow; } +//----------------------------------------------------------------------------- +// "realize" from m_widget +//----------------------------------------------------------------------------- + +/* we cannot set colours, fonts and cursors before the widget has + been realized, so we do this directly after realization */ + +static gint +gtk_window_realized_callback( GtkWidget *widget, wxWindow *win ) +{ + if (g_isIdle) + wxapp_install_idle_handler(); + + if (win->m_font != *wxSWISS_FONT) + { + wxFont font( win->m_font ); + win->m_font = wxNullFont; + win->SetFont( font ); + } + + if (win->m_backgroundColour != wxSystemSettings::GetSystemColour( wxSYS_COLOUR_BTNFACE )) + { + wxColour bg( win->m_backgroundColour ); + win->m_backgroundColour = wxNullColour; + win->SetBackgroundColour( bg ); + } + + if (win->m_foregroundColour != *wxBLACK) + { + wxColour fg( win->m_foregroundColour ); + win->m_foregroundColour = wxNullColour; + win->SetForegroundColour( fg ); + } + + wxCursor cursor( win->m_cursor ); + win->m_cursor = wxNullCursor; + win->SetCursor( cursor ); + + return FALSE; +} + //----------------------------------------------------------------------------- // InsertChild for wxWindow. //----------------------------------------------------------------------------- @@ -1377,22 +1415,18 @@ wxWindow *wxWindowBase::FindFocus() static void wxInsertChildInWindow( wxWindow* parent, wxWindow* child ) { - gtk_myfixed_put( GTK_MYFIXED(parent->GetWxWindow()), - GTK_WIDGET(child->GetHandle()), - child->GetX(), - child->GetY(), - child->GetWidth(), - child->GetHeight() ); - - gtk_widget_set_usize( GTK_WIDGET(child->GetHandle()), - child->GetWidth(), - child->GetHeight() ); + gtk_myfixed_put( GTK_MYFIXED(parent->m_wxwindow), + GTK_WIDGET(child->m_widget), + child->m_x, + child->m_y, + child->m_width, + child->m_height ); if (parent->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->GetWxWindow(), GTK_CAN_FOCUS ); + GTK_WIDGET_UNSET_FLAGS( parent->m_wxwindow, GTK_CAN_FOCUS ); } } @@ -1421,12 +1455,13 @@ void wxWindow::Init() InitBase(); // GTK specific + m_widget = (GtkWidget *) NULL; m_wxwindow = (GtkWidget *) NULL; // position/size - m_x = - m_y = - m_width = + m_x = 0; + m_y = 0; + m_width = 0; m_height = 0; m_font = *wxSWISS_FONT; @@ -1436,12 +1471,12 @@ void wxWindow::Init() m_hasVMT = FALSE; m_needParent = TRUE; - m_hasScrolling = + m_hasScrolling = FALSE; m_isScrolling = FALSE; - m_hAdjust = + m_hAdjust = (GtkAdjustment*) NULL; m_vAdjust = (GtkAdjustment*) NULL; - m_oldHorizontalPos = + m_oldHorizontalPos = 0.0; m_oldVerticalPos = 0.0; m_resizing = FALSE; @@ -1556,8 +1591,20 @@ bool wxWindow::Create( wxWindow *parent, wxWindowID id, #endif // GTK_MINOR_VERSION == 0 // I _really_ don't want scrollbars in the beginning - InitAdjustment(m_vAdjust); - InitAdjustment(m_hAdjust); + m_vAdjust->lower = 0.0; + m_vAdjust->upper = 1.0; + m_vAdjust->value = 0.0; + m_vAdjust->step_increment = 1.0; + m_vAdjust->page_increment = 1.0; + m_vAdjust->page_size = 5.0; + gtk_signal_emit_by_name( GTK_OBJECT(m_vAdjust), "changed" ); + m_hAdjust->lower = 0.0; + m_hAdjust->upper = 1.0; + m_hAdjust->value = 0.0; + m_hAdjust->step_increment = 1.0; + m_hAdjust->page_increment = 1.0; + m_hAdjust->page_size = 5.0; + gtk_signal_emit_by_name( GTK_OBJECT(m_hAdjust), "changed" ); // these handlers block mouse events to any window during scrolling such as // motion events and prevent GTK and wxWindows from fighting over where the @@ -1608,20 +1655,34 @@ wxWindow::~wxWindow() if (m_widget) Show( FALSE ); + DestroyChildren(); + if (m_parent) m_parent->RemoveChild( this ); if (m_widgetStyle) + { gtk_style_unref( m_widgetStyle ); + m_widgetStyle = (GtkStyle*) NULL; + } if (m_scrollGC) + { gdk_gc_unref( m_scrollGC ); + m_scrollGC = (GdkGC*) NULL; + } if (m_wxwindow) + { gtk_widget_destroy( m_wxwindow ); + m_wxwindow = (GtkWidget*) NULL; + } if (m_widget) + { gtk_widget_destroy( m_widget ); + m_widget = (GtkWidget*) NULL; + } } void wxWindow::PreCreation( wxWindow *parent, @@ -1682,16 +1743,14 @@ void wxWindow::PostCreation() #endif } - ConnectWidget( GetConnectWidget() ); - - /* we force the creation of wxFrame and wxDialog in the respective code */ - if (m_parent) - gtk_widget_realize( m_widget ); + GtkWidget *connect_widget = GetConnectWidget(); - if (m_wxwindow) - gtk_widget_realize( m_wxwindow ); + ConnectWidget( connect_widget ); - SetCursor( *wxSTANDARD_CURSOR ); + /* we cannot set colours, fonts and cursors before the widget has + been realized, so we do this directly after realization */ + gtk_signal_connect( GTK_OBJECT(connect_widget), "realize", + GTK_SIGNAL_FUNC(gtk_window_realized_callback), (gpointer) this ); m_hasVMT = TRUE; } @@ -1743,7 +1802,7 @@ void wxWindow::DoSetSize( int x, int y, int width, int height, int sizeFlags ) if (m_resizing) return; /* I don't like recursions */ m_resizing = TRUE; - if (m_parent->GetWxWindow() == NULL) /* i.e. wxNotebook */ + if (m_parent->m_wxwindow == NULL) /* i.e. wxNotebook */ { /* don't set the size for children of wxNotebook, just take the values. */ m_x = x; @@ -1753,9 +1812,6 @@ void wxWindow::DoSetSize( int x, int y, int width, int height, int sizeFlags ) } else { - int old_width = m_width; - int old_height = m_height; - if ((sizeFlags & wxSIZE_USE_EXISTING) == wxSIZE_USE_EXISTING) { if (x != -1) m_x = x; @@ -1786,22 +1842,41 @@ void wxWindow::DoSetSize( int x, int y, int width, int height, int sizeFlags ) if ((m_maxWidth != -1) && (m_width > m_maxWidth)) m_width = m_maxWidth; if ((m_maxHeight != -1) && (m_height > m_maxHeight)) m_height = m_maxHeight; - if (GTK_WIDGET_HAS_DEFAULT(m_widget)) - { - /* the default button has a border around it */ - int border = 5; - - gtk_myfixed_move( GTK_MYFIXED(m_parent->GetWxWindow()), m_widget, m_x-border, m_y-border ); - - gtk_widget_set_usize( m_widget, m_width+2*border, m_height+2*border ); - } - else - { - gtk_myfixed_move( GTK_MYFIXED(m_parent->GetWxWindow()), m_widget, m_x, m_y ); + int border = 0; - if ((old_width != m_width) || (old_height != m_height)) - gtk_widget_set_usize( m_widget, m_width, m_height ); - } + if (GTK_WIDGET_HAS_DEFAULT(m_widget)) + { + /* the default button has a border around it */ + border = 5; + } + + /* this is the result of hours of debugging: the following code + means that if we have a m_wxwindow and we set the size of + m_widget, m_widget (which is a GtkScrolledWindow) does NOT + automatically propagate its size down to its m_wxwindow, + which is its client area. therefore, we have to tell the + client area directly that it has to resize itself. + this will lead to that m_widget (GtkScrolledWindow) will + calculate how much size it needs for scrollbars etc and + it will then call XXX_size_allocate of its child, which + is m_wxwindow. m_wxwindow in turn will do the same with its + children and so on. problems can arise if this happens + before all the children have been realized as some widgets + stupidy need to be realized during XXX_size_allocate (e.g. + GtkNotebook) and they will segv if called otherwise. this + emergency is tested in gtk_myfixed_size_allocate. Normally + this shouldn't be needed and only gtk_widget_queue_resize() + should be enough to provoke a resize at the next appropriate + moment, but this seems to fail, e.g. when a wxNotebook contains + a wxSplitterWindow: the splitter window's children won't + show up properly resized then. */ + + gtk_myfixed_set_size( GTK_MYFIXED(m_parent->m_wxwindow), + m_widget, + m_x-border, + m_y-border, + m_width+2*border, + m_height+2*border ); } m_sizeSet = TRUE; @@ -1965,6 +2040,8 @@ void wxWindow::ClientToScreen( int *x, int *y ) const { wxCHECK_RET( (m_widget != NULL), _T("invalid window") ); + if (!m_widget->window) return; + GdkWindow *source = (GdkWindow *) NULL; if (m_wxwindow) source = m_wxwindow->window; @@ -1992,6 +2069,8 @@ void wxWindow::ScreenToClient( int *x, int *y ) const { wxCHECK_RET( (m_widget != NULL), _T("invalid window") ); + if (!m_widget->window) return; + GdkWindow *source = (GdkWindow *) NULL; if (m_wxwindow) source = m_wxwindow->window; @@ -2125,11 +2204,11 @@ bool wxWindow::Reparent( wxWindow *newParent ) { wxCHECK_MSG( (m_widget != NULL), (wxWindow*) NULL, _T("invalid window") ); + gtk_widget_unparent( m_widget ); + if ( !wxWindowBase::Reparent(newParent) ) return FALSE; - gtk_widget_unparent( m_widget ); - return TRUE; } @@ -2137,6 +2216,8 @@ void wxWindow::Raise() { wxCHECK_RET( (m_widget != NULL), _T("invalid window") ); + if (!m_widget->window) return; + gdk_window_raise( m_widget->window ); } @@ -2144,6 +2225,8 @@ void wxWindow::Lower() { wxCHECK_RET( (m_widget != NULL), _T("invalid window") ); + if (!m_widget->window) return; + gdk_window_lower( m_widget->window ); } @@ -2153,6 +2236,8 @@ bool wxWindow::SetCursor( const wxCursor &cursor ) if ( wxWindowBase::SetCursor(cursor) ) { + if (!m_widget->window) return TRUE; + if ((m_widget) && (m_widget->window)) gdk_window_set_cursor( m_widget->window, GetCursor().GetCursor() ); @@ -2178,6 +2263,8 @@ void wxWindow::Refresh( bool eraseBackground, const wxRect *rect ) { wxCHECK_RET( (m_widget != NULL), _T("invalid window") ); + if (!m_widget->window) return; + if (eraseBackground && m_wxwindow && m_wxwindow->window) { if (rect) @@ -2218,6 +2305,8 @@ void wxWindow::Clear() { wxCHECK_RET( m_widget != NULL, _T("invalid window") ); + if (!m_widget->window) return; + if (m_wxwindow && m_wxwindow->window) { gdk_window_clear( m_wxwindow->window ); @@ -2243,13 +2332,16 @@ bool wxWindow::SetBackgroundColour( const wxColour &colour ) { wxCHECK_MSG( m_widget != NULL, FALSE, _T("invalid window") ); - if ( !wxWindowBase::SetBackgroundColour(colour) ) - return FALSE; + if (!colour.Ok()) return FALSE; + if (m_backgroundColour == colour) return FALSE; + + GtkWidget *connect_widget = GetConnectWidget(); + if (!connect_widget->window) return TRUE; if (m_wxwindow && m_wxwindow->window) { - // wxMSW doesn't clear the window here. I don't do that either to - // provide compatibility. call Clear() to do the job. + /* wxMSW doesn't clear the window here. I don't do that either to + provide compatibility. call Clear() to do the job. */ m_backgroundColour.CalcPixel( gdk_window_get_colormap( m_wxwindow->window ) ); gdk_window_set_background( m_wxwindow->window, m_backgroundColour.GetColor() ); @@ -2275,8 +2367,11 @@ bool wxWindow::SetForegroundColour( const wxColour &colour ) { wxCHECK_MSG( m_widget != NULL, FALSE, _T("invalid window") ); - if ( !wxWindowBase::SetForegroundColour(colour) ) - return FALSE; + if (!colour.Ok()) return FALSE; + if (m_backgroundColour == colour) return FALSE; + + GtkWidget *connect_widget = GetConnectWidget(); + if (!connect_widget->window) return TRUE; wxColour sysbg = wxSystemSettings::GetSystemColour( wxSYS_COLOUR_BTNFACE ); if ( sysbg == m_foregroundColour ) @@ -2419,13 +2514,13 @@ bool wxWindow::IsOwnGtkWindow( GdkWindow *window ) bool wxWindow::SetFont( const wxFont &font ) { - wxCHECK_MSG( m_widget != NULL, FALSE, _T("invalid window") ); + wxCHECK_MSG( m_widget != NULL, FALSE, _T( "invalid window") ); - if ( !wxWindowBase::SetFont(font) ) - { - // nothing to do - return FALSE; - } + if (!font.Ok()) return FALSE; + if (m_font == font) return FALSE; + + GtkWidget *connect_widget = GetConnectWidget(); + if (!connect_widget->window) return TRUE; wxColour sysbg = wxSystemSettings::GetSystemColour( wxSYS_COLOUR_BTNFACE ); if ( sysbg == m_backgroundColour ) @@ -2449,6 +2544,8 @@ void wxWindow::CaptureMouse() wxCHECK_RET( g_capturing == FALSE, _T("CaptureMouse called twice") ); GtkWidget *connect_widget = GetConnectWidget(); + if (!connect_widget->window) return; + gtk_grab_add( connect_widget ); gdk_pointer_grab( connect_widget->window, FALSE, (GdkEventMask) @@ -2468,6 +2565,8 @@ void wxWindow::ReleaseMouse() wxCHECK_RET( g_capturing == TRUE, _T("ReleaseMouse called twice") ); GtkWidget *connect_widget = GetConnectWidget(); + if (!connect_widget->window) return; + gtk_grab_remove( connect_widget ); gdk_pointer_ungrab ( GDK_CURRENT_TIME ); g_capturing = FALSE; @@ -2628,50 +2727,52 @@ void wxWindow::ScrollWindow( int dx, int dy, const wxRect* WXUNUSED(rect) ) wxCHECK_RET( m_wxwindow != NULL, _T("window needs client area for scrolling") ); - wxNode *node = m_children.First(); - while (node) + if (!m_scrollGC) { - wxWindow *child = (wxWindow*) node->Data(); - child->Move( child->GetX() + dx, child->GetY() + dy ); - node = node->Next(); + m_scrollGC = gdk_gc_new( m_wxwindow->window ); + gdk_gc_set_exposures( m_scrollGC, TRUE ); } int cw = 0; int ch = 0; GetClientSize( &cw, &ch ); - int w = cw - abs(dx); int h = ch - abs(dy); + if ((h < 0) || (w < 0)) { Refresh(); - return; } - int s_x = 0; - int s_y = 0; - if (dx < 0) s_x = -dx; - if (dy < 0) s_y = -dy; - int d_x = 0; - int d_y = 0; - if (dx > 0) d_x = dx; - if (dy > 0) d_y = dy; - - if (!m_scrollGC) + else { - m_scrollGC = gdk_gc_new( m_wxwindow->window ); - gdk_gc_set_exposures( m_scrollGC, TRUE ); - } + int s_x = 0; + int s_y = 0; + if (dx < 0) s_x = -dx; + if (dy < 0) s_y = -dy; + int d_x = 0; + int d_y = 0; + if (dx > 0) d_x = dx; + if (dy > 0) d_y = dy; - gdk_window_copy_area( m_wxwindow->window, m_scrollGC, d_x, d_y, - m_wxwindow->window, s_x, s_y, w, h ); + gdk_window_copy_area( m_wxwindow->window, m_scrollGC, d_x, d_y, + m_wxwindow->window, s_x, s_y, w, h ); - wxRect rect; - if (dx < 0) rect.x = cw+dx; else rect.x = 0; - if (dy < 0) rect.y = ch+dy; else rect.y = 0; - if (dy != 0) rect.width = cw; else rect.width = abs(dx); - if (dx != 0) rect.height = ch; else rect.height = abs(dy); + wxRect rect; + if (dx < 0) rect.x = cw+dx; else rect.x = 0; + if (dy < 0) rect.y = ch+dy; else rect.y = 0; + if (dy != 0) rect.width = cw; else rect.width = abs(dx); + if (dx != 0) rect.height = ch; else rect.height = abs(dy); - Refresh( TRUE, &rect ); + Refresh( TRUE, &rect ); + } + + wxNode *node = m_children.First(); + while (node) + { + wxWindow *child = (wxWindow*) node->Data(); + child->Move( child->m_x + dx, child->m_y + dy ); + node = node->Next(); + } } void wxWindow::SetScrolling(bool scroll) diff --git a/src/gtk1/bmpbuttn.cpp b/src/gtk1/bmpbuttn.cpp index abc9a9fea0..783d419baa 100644 --- a/src/gtk1/bmpbuttn.cpp +++ b/src/gtk1/bmpbuttn.cpp @@ -43,7 +43,7 @@ static void gtk_bmpbutton_clicked_callback( GtkWidget *WXUNUSED(widget), wxBitma { if (g_isIdle) wxapp_install_idle_handler(); - if (!button->HasVMT()) return; + if (!button->m_hasVMT) return; if (g_blockEventsOnDrag) return; wxCommandEvent event(wxEVT_COMMAND_BUTTON_CLICKED, button->GetId()); @@ -57,7 +57,7 @@ static void gtk_bmpbutton_clicked_callback( GtkWidget *WXUNUSED(widget), wxBitma static void gtk_bmpbutton_enter_callback( GtkWidget *WXUNUSED(widget), wxBitmapButton *button ) { - if (!button->HasVMT()) return; + if (!button->m_hasVMT) return; if (g_blockEventsOnDrag) return; button->HasFocus(); @@ -69,7 +69,7 @@ static void gtk_bmpbutton_enter_callback( GtkWidget *WXUNUSED(widget), wxBitmapB static void gtk_bmpbutton_leave_callback( GtkWidget *WXUNUSED(widget), wxBitmapButton *button ) { - if (!button->HasVMT()) return; + if (!button->m_hasVMT) return; if (g_blockEventsOnDrag) return; button->NotFocus(); @@ -81,7 +81,7 @@ static void gtk_bmpbutton_leave_callback( GtkWidget *WXUNUSED(widget), wxBitmapB static void gtk_bmpbutton_press_callback( GtkWidget *WXUNUSED(widget), wxBitmapButton *button ) { - if (!button->HasVMT()) return; + if (!button->m_hasVMT) return; if (g_blockEventsOnDrag) return; button->StartSelect(); @@ -93,7 +93,7 @@ static void gtk_bmpbutton_press_callback( GtkWidget *WXUNUSED(widget), wxBitmapB static void gtk_bmpbutton_release_callback( GtkWidget *WXUNUSED(widget), wxBitmapButton *button ) { - if (!button->HasVMT()) return; + if (!button->m_hasVMT) return; if (g_blockEventsOnDrag) return; button->EndSelect(); diff --git a/src/gtk1/button.cpp b/src/gtk1/button.cpp index 7e93cc3f92..254056d770 100644 --- a/src/gtk1/button.cpp +++ b/src/gtk1/button.cpp @@ -43,7 +43,7 @@ static void gtk_button_clicked_callback( GtkWidget *WXUNUSED(widget), wxButton * { if (g_isIdle) wxapp_install_idle_handler(); - if (!button->HasVMT()) return; + if (!button->m_hasVMT) return; if (g_blockEventsOnDrag) return; wxCommandEvent event(wxEVT_COMMAND_BUTTON_CLICKED, button->GetId()); diff --git a/src/gtk1/checkbox.cpp b/src/gtk1/checkbox.cpp index 258f26ac1a..09cdd98387 100644 --- a/src/gtk1/checkbox.cpp +++ b/src/gtk1/checkbox.cpp @@ -38,7 +38,7 @@ static void gtk_checkbox_clicked_callback( GtkWidget *WXUNUSED(widget), wxCheckB { if (g_isIdle) wxapp_install_idle_handler(); - if (!cb->HasVMT()) return; + if (!cb->m_hasVMT) return; if (cb->m_blockFirstEvent) { diff --git a/src/gtk1/choice.cpp b/src/gtk1/choice.cpp index 66f2f19bd7..f13d20eae3 100644 --- a/src/gtk1/choice.cpp +++ b/src/gtk1/choice.cpp @@ -38,7 +38,7 @@ static void gtk_choice_clicked_callback( GtkWidget *WXUNUSED(widget), wxChoice * { if (g_isIdle) wxapp_install_idle_handler(); - if (!choice->HasVMT()) return; + if (!choice->m_hasVMT) return; if (g_blockEventsOnDrag) return; diff --git a/src/gtk1/combobox.cpp b/src/gtk1/combobox.cpp index caf222a719..bec8f16668 100644 --- a/src/gtk1/combobox.cpp +++ b/src/gtk1/combobox.cpp @@ -41,7 +41,7 @@ gtk_combo_clicked_callback( GtkWidget *WXUNUSED(widget), wxComboBox *combo ) { if (g_isIdle) wxapp_install_idle_handler(); - if (!combo->HasVMT()) return; + if (!combo->m_hasVMT) return; if (g_blockEventsOnDrag) return; @@ -70,6 +70,8 @@ gtk_text_changed_callback( GtkWidget *WXUNUSED(widget), wxComboBox *combo ) { if (g_isIdle) wxapp_install_idle_handler(); + if (!combo->m_hasVMT) return; + wxCommandEvent event( wxEVT_COMMAND_TEXT_UPDATED, combo->GetId() ); event.SetString( combo->GetValue() ); event.SetEventObject( combo ); diff --git a/src/gtk1/dcclient.cpp b/src/gtk1/dcclient.cpp index ebd55de490..a5ee2b008c 100644 --- a/src/gtk1/dcclient.cpp +++ b/src/gtk1/dcclient.cpp @@ -110,7 +110,7 @@ wxWindowDC::wxWindowDC( wxWindow *window ) if (!window) return; - GtkWidget *widget = window->GetWxWindow(); + GtkWidget *widget = window->m_wxwindow; if (!widget) return; @@ -127,10 +127,10 @@ wxWindowDC::wxWindowDC( wxWindow *window ) /* still not realized ? */ if (!m_window) return; - if (window->GetWxWindow()) - m_cmap = gtk_widget_get_colormap( window->GetWxWindow() ); + if (window->m_wxwindow) + m_cmap = gtk_widget_get_colormap( window->m_wxwindow ); else - m_cmap = gtk_widget_get_colormap( window->GetHandle() ); + m_cmap = gtk_widget_get_colormap( window->m_widget ); m_isMemDC = FALSE; diff --git a/src/gtk1/dialog.cpp b/src/gtk1/dialog.cpp index 271c41ea99..596c4a5a9a 100644 --- a/src/gtk1/dialog.cpp +++ b/src/gtk1/dialog.cpp @@ -60,7 +60,7 @@ static void gtk_dialog_size_callback( GtkWidget *WXUNUSED(widget), GtkAllocation { if (g_isIdle) wxapp_install_idle_handler(); - if (!win->HasVMT()) return; + if (!win->m_hasVMT) return; /* printf( "OnDialogResize from " ); @@ -69,7 +69,7 @@ static void gtk_dialog_size_callback( GtkWidget *WXUNUSED(widget), GtkAllocation printf( ".\n" ); */ - if ((win->GetWidth() != alloc->width) || (win->GetHeight() != alloc->height)) + if ((win->m_width != alloc->width) || (win->m_height != alloc->height)) { win->InternalSetSize( alloc->width, alloc->height ); } @@ -83,11 +83,11 @@ static gint gtk_dialog_configure_callback( GtkWidget *WXUNUSED(widget), GdkEvent { if (g_isIdle) wxapp_install_idle_handler(); - if (!win->HasVMT()) return FALSE; + if (!win->m_hasVMT) return FALSE; win->InternalSetPosition(event->x, event->y); - wxMoveEvent mevent( wxPoint(win->GetX(),win->GetY()), win->GetId() ); + wxMoveEvent mevent( wxPoint(win->m_x,win->m_y), win->GetId() ); mevent.SetEventObject( win ); win->GetEventHandler()->ProcessEvent( mevent ); @@ -126,7 +126,7 @@ gtk_dialog_map_callback( GtkWidget *widget, wxDialog *win ) { /* I haven''t been able to set the position of the dialog before it is shown, so I do it here */ - gtk_widget_set_uposition( widget, win->GetX(), win->GetY() ); + gtk_widget_set_uposition( widget, win->m_x, win->m_y ); /* all this is for Motif Window Manager "hints" and is supposed to be recognized by other WM as well. not tested. */ @@ -155,14 +155,14 @@ gtk_dialog_map_callback( GtkWidget *widget, wxDialog *win ) func |= GDK_FUNC_RESIZE; decor |= GDK_DECOR_RESIZEH; } - gdk_window_set_decorations( win->GetHandle()->window, (GdkWMDecoration)decor); - gdk_window_set_functions( win->GetHandle()->window, (GdkWMFunction)func); + gdk_window_set_decorations( win->m_widget->window, (GdkWMDecoration)decor); + gdk_window_set_functions( win->m_widget->window, (GdkWMFunction)func); /* GTK's shrinking/growing policy */ if ((win->GetWindowStyle() & wxRESIZE_BORDER) == 0) - gtk_window_set_policy(GTK_WINDOW(win->GetHandle()), 0, 0, 1); + gtk_window_set_policy(GTK_WINDOW(win->m_widget), 0, 0, 1); else - gtk_window_set_policy(GTK_WINDOW(win->GetHandle()), 1, 1, 1); + gtk_window_set_policy(GTK_WINDOW(win->m_widget), 1, 1, 1); return FALSE; } diff --git a/src/gtk1/dnd.cpp b/src/gtk1/dnd.cpp index 5ca90425da..9596cf7d13 100644 --- a/src/gtk1/dnd.cpp +++ b/src/gtk1/dnd.cpp @@ -702,8 +702,8 @@ wxDropSource::wxDropSource( wxWindow *win, const wxIcon &go, const wxIcon &stop m_waiting = TRUE; m_window = win; - m_widget = win->GetWidget(); - if (win->GetWxWindow()) m_widget = win->GetWxWindow(); + m_widget = win->m_widget; + if (win->m_wxwindow) m_widget = win->m_wxwindow; m_data = (wxDataBroker*) NULL; m_retValue = wxDragCancel; @@ -722,8 +722,8 @@ wxDropSource::wxDropSource( wxDataObject *data, wxWindow *win, const wxIcon &go, m_waiting = TRUE; m_window = win; - m_widget = win->GetWidget(); - if (win->GetWxWindow()) m_widget = win->GetWxWindow(); + m_widget = win->m_widget; + if (win->m_wxwindow) m_widget = win->m_wxwindow; m_retValue = wxDragCancel; if (data) @@ -748,8 +748,8 @@ wxDropSource::wxDropSource( wxDataObject *data, wxWindow *win, const wxIcon &go, wxDropSource::wxDropSource( wxDataBroker *data, wxWindow *win ) { m_window = win; - m_widget = win->GetWidget(); - if (win->GetWxWindow()) m_widget = win->GetWxWindow(); + m_widget = win->m_widget; + if (win->m_wxwindow) m_widget = win->m_wxwindow; m_retValue = wxDragCancel; m_data = data; diff --git a/src/gtk1/filedlg.cpp b/src/gtk1/filedlg.cpp index e3b9952413..bd7d405395 100644 --- a/src/gtk1/filedlg.cpp +++ b/src/gtk1/filedlg.cpp @@ -57,7 +57,7 @@ void gtk_filedialog_ok_callback( GtkWidget *WXUNUSED(widget), wxFileDialog *dial int style = dialog->GetStyle(); - GtkFileSelection *filedlg = GTK_FILE_SELECTION(dialog->GetHandle()); + GtkFileSelection *filedlg = GTK_FILE_SELECTION(dialog->m_widget); char *filename = gtk_file_selection_get_filename(filedlg); if ( (style & wxSAVE) && ( style & wxOVERWRITE_PROMPT ) ) diff --git a/src/gtk1/frame.cpp b/src/gtk1/frame.cpp index 1a01040022..3065fbcdba 100644 --- a/src/gtk1/frame.cpp +++ b/src/gtk1/frame.cpp @@ -64,7 +64,7 @@ static void gtk_frame_size_callback( GtkWidget *WXUNUSED(widget), GtkAllocation* { if (g_isIdle) wxapp_install_idle_handler(); - if (!win->HasVMT()) return; + if (!win->m_hasVMT) return; /* printf( "OnFrameResize from " ); @@ -73,7 +73,7 @@ static void gtk_frame_size_callback( GtkWidget *WXUNUSED(widget), GtkAllocation* printf( ".\n" ); */ - if ((win->GetWidth() != alloc->width) || (win->GetHeight() != alloc->height)) + if ((win->m_width != alloc->width) || (win->m_height != alloc->height)) { win->InternalSetSize( alloc->width, alloc->height ); } @@ -107,7 +107,7 @@ static void gtk_menu_attached_callback( GtkWidget *WXUNUSED(widget), GtkWidget * { if (g_isIdle) wxapp_install_idle_handler(); - if (!win->HasVMT()) return; + if (!win->m_hasVMT) return; win->m_menuBarDetached = FALSE; win->UpdateSize(); @@ -121,7 +121,7 @@ static void gtk_menu_detached_callback( GtkWidget *WXUNUSED(widget), GtkWidget * { if (g_isIdle) wxapp_install_idle_handler(); - if (!win->HasVMT()) return; + if (!win->m_hasVMT) return; win->m_menuBarDetached = TRUE; win->UpdateSize(); @@ -135,7 +135,7 @@ static void gtk_toolbar_attached_callback( GtkWidget *WXUNUSED(widget), GtkWidge { if (g_isIdle) wxapp_install_idle_handler(); - if (!win->HasVMT()) return; + if (!win->m_hasVMT) return; win->m_toolBarDetached = FALSE; win->UpdateSize(); @@ -149,7 +149,7 @@ static void gtk_toolbar_detached_callback( GtkWidget *widget, GtkWidget *WXUNUSE { if (g_isIdle) wxapp_install_idle_handler(); - if (!win->HasVMT()) return; + if (!win->m_hasVMT) return; win->m_toolBarDetached = TRUE; win->UpdateSize(); @@ -163,11 +163,11 @@ static gint gtk_frame_configure_callback( GtkWidget *WXUNUSED(widget), GdkEventC { if (g_isIdle) wxapp_install_idle_handler(); - if (!win->HasVMT()) return FALSE; + if (!win->m_hasVMT) return FALSE; win->InternalSetPosition(event->x, event->y); - wxMoveEvent mevent( wxPoint(win->GetX(),win->GetY()), win->GetId() ); + wxMoveEvent mevent( wxPoint(win->m_x,win->m_y), win->GetId() ); mevent.SetEventObject( win ); win->GetEventHandler()->ProcessEvent( mevent ); @@ -215,14 +215,14 @@ gtk_frame_realized_callback( GtkWidget *widget, wxFrame *win ) } - gdk_window_set_decorations( win->GetHandle()->window, (GdkWMDecoration)decor); - gdk_window_set_functions( win->GetHandle()->window, (GdkWMFunction)func); + gdk_window_set_decorations( win->m_widget->window, (GdkWMDecoration)decor); + gdk_window_set_functions( win->m_widget->window, (GdkWMFunction)func); /* GTK's shrinking/growing policy */ if ((win->GetWindowStyle() & wxRESIZE_BORDER) == 0) - gtk_window_set_policy(GTK_WINDOW(win->GetHandle()), 0, 0, 1); + gtk_window_set_policy(GTK_WINDOW(win->m_widget), 0, 0, 1); else - gtk_window_set_policy(GTK_WINDOW(win->GetHandle()), 1, 1, 1); + gtk_window_set_policy(GTK_WINDOW(win->m_widget), 1, 1, 1); /* reset the icon */ if (win->m_icon != wxNullIcon) @@ -269,11 +269,11 @@ static void wxInsertChildInFrame( wxWindow* parent, wxWindow* child ) /* these are outside the client area */ wxFrame* frame = (wxFrame*) parent; gtk_myfixed_put( GTK_MYFIXED(frame->m_mainWidget), - GTK_WIDGET(child->GetHandle()), - child->GetX(), - child->GetY(), - child->GetWidth(), - child->GetHeight() ); + GTK_WIDGET(child->m_widget), + child->m_x, + child->m_y, + child->m_width, + child->m_height ); /* we connect to these events for recalculating the client area space when the toolbar is floating */ @@ -282,10 +282,10 @@ static void wxInsertChildInFrame( wxWindow* parent, wxWindow* child ) wxToolBar *toolBar = (wxToolBar*) child; if (toolBar->GetWindowStyle() & wxTB_DOCKABLE) { - gtk_signal_connect( GTK_OBJECT(toolBar->GetHandle()), "child_attached", + gtk_signal_connect( GTK_OBJECT(toolBar->m_widget), "child_attached", GTK_SIGNAL_FUNC(gtk_toolbar_attached_callback), (gpointer)parent ); - gtk_signal_connect( GTK_OBJECT(toolBar->GetHandle()), "child_detached", + gtk_signal_connect( GTK_OBJECT(toolBar->m_widget), "child_detached", GTK_SIGNAL_FUNC(gtk_toolbar_detached_callback), (gpointer)parent ); } } @@ -293,12 +293,12 @@ static void wxInsertChildInFrame( wxWindow* parent, wxWindow* child ) else { /* these are inside the client area */ - gtk_myfixed_put( GTK_MYFIXED(parent->GetWxWindow()), - GTK_WIDGET(child->GetHandle()), - child->GetX(), - child->GetY(), - child->GetWidth(), - child->GetHeight() ); + gtk_myfixed_put( GTK_MYFIXED(parent->m_wxwindow), + GTK_WIDGET(child->m_widget), + child->m_x, + child->m_y, + child->m_width, + child->m_height ); } /* resize on OnInternalIdle */ @@ -671,7 +671,7 @@ void wxFrame::GtkOnSize( int WXUNUSED(x), int WXUNUSED(y), int width, int height m_frameMenuBar->InternalSetPosition(xx, yy); m_frameMenuBar->InternalSetSize(ww, hh); gtk_myfixed_set_size( GTK_MYFIXED(m_mainWidget), - m_frameMenuBar->GetHandle(), + m_frameMenuBar->m_widget, xx, yy, ww, hh ); client_area_y_offset += hh; } @@ -688,7 +688,7 @@ void wxFrame::GtkOnSize( int WXUNUSED(x), int WXUNUSED(y), int width, int height yy += wxPLACE_HOLDER; } int ww = m_width - 2*m_miniEdge; - int hh = m_frameToolBar->GetHeight(); + 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) @@ -698,7 +698,7 @@ void wxFrame::GtkOnSize( int WXUNUSED(x), int WXUNUSED(y), int width, int height m_frameToolBar->InternalSetSize(ww, hh); gtk_myfixed_set_size( GTK_MYFIXED(m_mainWidget), - m_frameToolBar->GetHandle(), + m_frameToolBar->m_widget, xx, yy, ww, hh ); client_area_y_offset += hh; } @@ -726,7 +726,7 @@ void wxFrame::GtkOnSize( int WXUNUSED(x), int WXUNUSED(y), int width, int height m_frameStatusBar->InternalSetPosition(xx, yy); m_frameStatusBar->InternalSetSize(ww, hh); gtk_myfixed_set_size( GTK_MYFIXED(m_wxwindow), - m_frameStatusBar->GetHandle(), + m_frameStatusBar->m_widget, xx, yy, ww, hh ); } @@ -743,7 +743,7 @@ void wxFrame::GtkOnSize( int WXUNUSED(x), int WXUNUSED(y), int width, int height /* send size event to status bar */ if (m_frameStatusBar) { - wxSizeEvent event2( wxSize(m_frameStatusBar->GetWidth(),m_frameStatusBar->GetHeight()), m_frameStatusBar->GetId() ); + wxSizeEvent event2( wxSize(m_frameStatusBar->m_width,m_frameStatusBar->m_height), m_frameStatusBar->GetId() ); event2.SetEventObject( m_frameStatusBar ); m_frameStatusBar->GetEventHandler()->ProcessEvent( event2 ); } @@ -808,7 +808,7 @@ static void SetInvokingWindow( wxMenu *menu, wxWindow *win ) #if (GTK_MINOR_VERSION > 0) /* support for native hot keys */ - gtk_accel_group_attach( menu->m_accel, GTK_OBJECT(win->GetHandle())); + gtk_accel_group_attach( menu->m_accel, GTK_OBJECT(win->m_widget)); #endif wxNode *node = menu->GetItems().First(); @@ -847,18 +847,18 @@ void wxFrame::SetMenuBar( wxMenuBar *menuBar ) { m_frameMenuBar->SetParent(this); gtk_myfixed_put( GTK_MYFIXED(m_mainWidget), - m_frameMenuBar->GetHandle(), - m_frameMenuBar->GetX(), - m_frameMenuBar->GetY(), - m_frameMenuBar->GetWidth(), - m_frameMenuBar->GetHeight() ); + m_frameMenuBar->m_widget, + m_frameMenuBar->m_x, + m_frameMenuBar->m_y, + m_frameMenuBar->m_width, + m_frameMenuBar->m_height ); if (menuBar->GetWindowStyle() & wxMB_DOCKABLE) { - gtk_signal_connect( GTK_OBJECT(menuBar->GetHandle()), "child_attached", + gtk_signal_connect( GTK_OBJECT(menuBar->m_widget), "child_attached", GTK_SIGNAL_FUNC(gtk_menu_attached_callback), (gpointer)this ); - gtk_signal_connect( GTK_OBJECT(menuBar->GetHandle()), "child_detached", + gtk_signal_connect( GTK_OBJECT(menuBar->m_widget), "child_detached", GTK_SIGNAL_FUNC(gtk_menu_detached_callback), (gpointer)this ); } } diff --git a/src/gtk1/listbox.cpp b/src/gtk1/listbox.cpp index 4e6c9af4c4..10c1097045 100644 --- a/src/gtk1/listbox.cpp +++ b/src/gtk1/listbox.cpp @@ -76,7 +76,7 @@ gtk_listbox_button_press_callback( GtkWidget *widget, GdkEventButton *gdk_event, if (g_blockEventsOnDrag) return FALSE; if (g_blockEventsOnScroll) return FALSE; - if (!listbox->HasVMT()) return FALSE; + if (!listbox->m_hasVMT) return FALSE; int sel = listbox->GetIndex( widget ); @@ -130,7 +130,7 @@ gtk_listbox_key_press_callback( GtkWidget *widget, GdkEventKey *gdk_event, wxLis if (g_blockEventsOnDrag) return FALSE; - if (!listbox->HasVMT()) return FALSE; + if (!listbox->m_hasVMT) return FALSE; if (gdk_event->keyval != ' ') return FALSE; @@ -156,7 +156,7 @@ static void gtk_listitem_select_callback( GtkWidget *WXUNUSED(widget), wxListBox { if (g_isIdle) wxapp_install_idle_handler(); - if (!listbox->HasVMT()) return; + if (!listbox->m_hasVMT) return; if (g_blockEventsOnDrag) return; wxCommandEvent event(wxEVT_COMMAND_LISTBOX_SELECTED, listbox->GetId() ); diff --git a/src/gtk1/mdi.cpp b/src/gtk1/mdi.cpp index b82ab13b8d..a6e4317bcf 100644 --- a/src/gtk1/mdi.cpp +++ b/src/gtk1/mdi.cpp @@ -90,12 +90,12 @@ void wxMDIParentFrame::GtkOnSize( int x, int y, int width, int height ) wxMenuBar *menu_bar = child_frame->m_menuBar; if (!menu_bar) return; - if (!menu_bar->GetHandle()) return; + if (!menu_bar->m_widget) return; menu_bar->InternalSetPosition(0, 0); menu_bar->InternalSetSize(m_width, wxMENU_HEIGHT); gtk_myfixed_set_size( GTK_MYFIXED(m_mainWidget), - menu_bar->GetHandle(), + menu_bar->m_widget, 0, 0, m_width, wxMENU_HEIGHT ); } @@ -108,7 +108,7 @@ void wxMDIParentFrame::OnInternalIdle() if (m_justInserted) { - GtkNotebook *notebook = GTK_NOTEBOOK(m_clientWindow->GetHandle()); + GtkNotebook *notebook = GTK_NOTEBOOK(m_clientWindow->m_widget); gtk_notebook_set_page( notebook, g_list_length( notebook->children ) - 1 ); m_justInserted = FALSE; @@ -128,11 +128,11 @@ void wxMDIParentFrame::OnInternalIdle() { if (child_frame == active_child_frame) { - gtk_widget_show( child_frame->m_menuBar->GetHandle() ); + gtk_widget_show( child_frame->m_menuBar->m_widget ); visible_child_menu = TRUE; } else - gtk_widget_hide( child_frame->m_menuBar->GetHandle() ); + gtk_widget_hide( child_frame->m_menuBar->m_widget ); } node = node->Next(); } @@ -150,7 +150,7 @@ wxMDIChildFrame *wxMDIParentFrame::GetActiveChild() const { if (!m_clientWindow) return (wxMDIChildFrame*) NULL; - GtkNotebook *notebook = GTK_NOTEBOOK(m_clientWindow->GetHandle()); + GtkNotebook *notebook = GTK_NOTEBOOK(m_clientWindow->m_widget); if (!notebook) return (wxMDIChildFrame*) NULL; #if (GTK_MINOR_VERSION > 0) @@ -189,13 +189,13 @@ wxMDIClientWindow *wxMDIParentFrame::OnCreateClient() void wxMDIParentFrame::ActivateNext() { if (m_clientWindow) - gtk_notebook_next_page( GTK_NOTEBOOK(m_clientWindow->GetHandle()) ); + gtk_notebook_next_page( GTK_NOTEBOOK(m_clientWindow->m_widget) ); } void wxMDIParentFrame::ActivatePrevious() { if (m_clientWindow) - gtk_notebook_prev_page( GTK_NOTEBOOK(m_clientWindow->GetHandle()) ); + gtk_notebook_prev_page( GTK_NOTEBOOK(m_clientWindow->m_widget) ); } void wxMDIParentFrame::OnActivate( wxActivateEvent& WXUNUSED(event) ) @@ -293,12 +293,12 @@ void wxMDIChildFrame::SetMenuBar( wxMenuBar *menu_bar ) } /* the menu bar of the child window is shown in idle time as needed */ - gtk_widget_hide( m_menuBar->GetHandle() ); + gtk_widget_hide( m_menuBar->m_widget ); /* insert the invisible menu bar into the _parent_ mdi frame */ gtk_myfixed_put( GTK_MYFIXED(mdi_frame->m_mainWidget), - m_menuBar->GetHandle(), - 0, 0, mdi_frame->GetWidth(), wxMENU_HEIGHT ); + m_menuBar->m_widget, + 0, 0, mdi_frame->m_width, wxMENU_HEIGHT ); } } @@ -323,11 +323,11 @@ static void gtk_page_size_callback( GtkWidget *WXUNUSED(widget), GtkAllocation* { if (g_isIdle) wxapp_install_idle_handler(); - if ((win->GetX() == alloc->x) && - (win->GetY() == alloc->y) && - (win->GetWidth() == alloc->width) && - (win->GetHeight() == alloc->height) && - (win->IsSizeSet())) + if ((win->m_x == alloc->x) && + (win->m_y == alloc->y) && + (win->m_width == alloc->width) && + (win->m_height == alloc->height) && + (win->m_sizeSet)) { return; } @@ -347,12 +347,12 @@ static void wxInsertChildInMDI( wxMDIClientWindow* parent, wxMDIChildFrame* chil GtkWidget *label_widget = gtk_label_new( s.mbc_str() ); gtk_misc_set_alignment( GTK_MISC(label_widget), 0.0, 0.5 ); - gtk_signal_connect( GTK_OBJECT(child->GetHandle()), "size_allocate", + gtk_signal_connect( GTK_OBJECT(child->m_widget), "size_allocate", GTK_SIGNAL_FUNC(gtk_page_size_callback), (gpointer)child ); - GtkNotebook *notebook = GTK_NOTEBOOK(parent->GetHandle()); + GtkNotebook *notebook = GTK_NOTEBOOK(parent->m_widget); - gtk_notebook_append_page( notebook, child->GetHandle(), label_widget ); + gtk_notebook_append_page( notebook, child->m_widget, label_widget ); child->m_page = (GtkNotebookPage*) (g_list_last(notebook->children)->data); diff --git a/src/gtk1/minifram.cpp b/src/gtk1/minifram.cpp index 80a6a879b2..e4267e0a7f 100644 --- a/src/gtk1/minifram.cpp +++ b/src/gtk1/minifram.cpp @@ -65,7 +65,7 @@ static void gtk_window_own_expose_callback( GtkWidget *widget, GdkEventExpose *g { if (g_isIdle) wxapp_install_idle_handler(); - if (!win->HasVMT()) return; + if (!win->m_hasVMT) return; if (gdk_event->count > 0) return; gtk_draw_shadow( widget->style, @@ -73,7 +73,7 @@ static void gtk_window_own_expose_callback( GtkWidget *widget, GdkEventExpose *g GTK_STATE_NORMAL, GTK_SHADOW_OUT, 0, 0, - win->GetWidth(), win->GetHeight() ); + win->m_width, win->m_height ); if (!win->m_title.IsEmpty() && ((win->GetWindowStyle() & wxCAPTION) || @@ -89,7 +89,7 @@ static void gtk_window_own_expose_callback( GtkWidget *widget, GdkEventExpose *g gdk_draw_rectangle( widget->window, gc, TRUE, x, 3, - win->GetWidth() - 4 - x, + win->m_width - 4 - x, font->ascent + font->descent+1 ); gdk_gc_set_foreground( gc, &widget->style->white ); @@ -110,14 +110,14 @@ static void gtk_window_own_draw_callback( GtkWidget *widget, GdkRectangle *WXUNU { if (g_isIdle) wxapp_install_idle_handler(); - if (!win->HasVMT()) return; + if (!win->m_hasVMT) return; gtk_draw_shadow( widget->style, widget->window, GTK_STATE_NORMAL, GTK_SHADOW_OUT, 0, 0, - win->GetWidth(), win->GetHeight() ); + win->m_width, win->m_height ); if (!win->m_title.IsEmpty() && ((win->GetWindowStyle() & wxCAPTION) || @@ -133,7 +133,7 @@ static void gtk_window_own_draw_callback( GtkWidget *widget, GdkRectangle *WXUNU gdk_draw_rectangle( widget->window, gc, TRUE, x, 3, - win->GetWidth() - 4 - x, + win->m_width - 4 - x, font->ascent + font->descent+1 ); gdk_gc_set_foreground( gc, &widget->style->white ); @@ -154,7 +154,7 @@ static gint gtk_window_button_press_callback( GtkWidget *widget, GdkEventButton { if (g_isIdle) wxapp_install_idle_handler(); - if (!win->HasVMT()) return FALSE; + if (!win->m_hasVMT) return FALSE; if (g_blockEventsOnDrag) return TRUE; if (g_blockEventsOnScroll) return TRUE; @@ -174,7 +174,7 @@ static gint gtk_window_button_press_callback( GtkWidget *widget, GdkEventButton win->m_diffX = (int)gdk_event->x; win->m_diffY = (int)gdk_event->y; - DrawFrame( widget, 0, 0, win->GetWidth(), win->GetHeight() ); + DrawFrame( widget, 0, 0, win->m_width, win->m_height ); win->m_oldX = 0; win->m_oldY = 0; @@ -191,7 +191,7 @@ static gint gtk_window_button_release_callback( GtkWidget *widget, GdkEventButto { if (g_isIdle) wxapp_install_idle_handler(); - if (!win->HasVMT()) return FALSE; + if (!win->m_hasVMT) return FALSE; if (g_blockEventsOnDrag) return TRUE; if (g_blockEventsOnScroll) return TRUE; @@ -202,7 +202,7 @@ static gint gtk_window_button_release_callback( GtkWidget *widget, GdkEventButto int x = (int)gdk_event->x; int y = (int)gdk_event->y; - DrawFrame( widget, win->m_oldX, win->m_oldY, win->GetWidth(), win->GetHeight() ); + DrawFrame( widget, win->m_oldX, win->m_oldY, win->m_width, win->m_height ); gdk_pointer_ungrab ( GDK_CURRENT_TIME ); int org_x = 0; int org_y = 0; @@ -210,7 +210,7 @@ static gint gtk_window_button_release_callback( GtkWidget *widget, GdkEventButto x += org_x - win->m_diffX; y += org_y - win->m_diffY; win->InternalSetPosition(x, y); - gtk_widget_set_uposition( win->GetWidget(), x, y ); + gtk_widget_set_uposition( win->m_widget, x, y ); return TRUE; } @@ -223,7 +223,7 @@ static gint gtk_window_motion_notify_callback( GtkWidget *widget, GdkEventMotion { if (g_isIdle) wxapp_install_idle_handler(); - if (!win->HasVMT()) return FALSE; + if (!win->m_hasVMT) return FALSE; if (g_blockEventsOnDrag) return TRUE; if (g_blockEventsOnScroll) return TRUE; @@ -240,10 +240,10 @@ static gint gtk_window_motion_notify_callback( GtkWidget *widget, GdkEventMotion gdk_event->state = state; } - DrawFrame( widget, win->m_oldX, win->m_oldY, win->GetWidth(), win->GetHeight() ); + DrawFrame( widget, win->m_oldX, win->m_oldY, win->m_width, win->m_height ); win->m_oldX = (int)gdk_event->x - win->m_diffX; win->m_oldY = (int)gdk_event->y - win->m_diffY; - DrawFrame( widget, win->m_oldX, win->m_oldY, win->GetWidth(), win->GetHeight() ); + DrawFrame( widget, win->m_oldX, win->m_oldY, win->m_width, win->m_height ); return TRUE; } diff --git a/src/gtk1/notebook.cpp b/src/gtk1/notebook.cpp index 3ca57db3b0..ccb0e81623 100644 --- a/src/gtk1/notebook.cpp +++ b/src/gtk1/notebook.cpp @@ -125,10 +125,10 @@ static void gtk_page_size_callback( GtkWidget *WXUNUSED(widget), GtkAllocation* { if (g_isIdle) wxapp_install_idle_handler(); - if ((win->GetX() == alloc->x) && - (win->GetY() == alloc->y) && - (win->GetWidth() == alloc->width) && - (win->GetHeight() == alloc->height)) + if ((win->m_x == alloc->x) && + (win->m_y == alloc->y) && + (win->m_width == alloc->width) && + (win->m_height == alloc->height)) { return; } @@ -149,7 +149,7 @@ gtk_notebook_key_press_callback( GtkWidget *widget, GdkEventKey *gdk_event, wxNo if (g_blockEventsOnDrag) return FALSE; - if (!notebook->HasVMT()) return FALSE; + if (!notebook->m_hasVMT) return FALSE; /* this code makes jumping down from the handles of the notebooks to the actual items in the visible notebook page possible with @@ -188,16 +188,16 @@ static void wxInsertChildInNotebook( wxNotebook* parent, wxWindow* child ) page->m_box = gtk_hbox_new (FALSE, 0); gtk_container_border_width(GTK_CONTAINER(page->m_box), 2); - GtkNotebook *notebook = GTK_NOTEBOOK(parent->GetWidget()); + GtkNotebook *notebook = GTK_NOTEBOOK(parent->m_widget); page->m_client = child; - gtk_notebook_append_page( notebook, child->GetWidget(), page->m_box ); + gtk_notebook_append_page( notebook, child->m_widget, page->m_box ); page->m_page = (GtkNotebookPage*) (g_list_last(notebook->children)->data); page->m_parent = notebook; - gtk_signal_connect( GTK_OBJECT(child->GetWidget()), "size_allocate", + gtk_signal_connect( GTK_OBJECT(child->m_widget), "size_allocate", GTK_SIGNAL_FUNC(gtk_page_size_callback), (gpointer)child ); wxASSERT_MSG( page->m_page, _T("Notebook page creation error") ); diff --git a/src/gtk1/radiobox.cpp b/src/gtk1/radiobox.cpp index 3637dffb06..432496cd91 100644 --- a/src/gtk1/radiobox.cpp +++ b/src/gtk1/radiobox.cpp @@ -40,7 +40,7 @@ static void gtk_radiobutton_clicked_callback( GtkWidget *WXUNUSED(widget), wxRad { if (g_isIdle) wxapp_install_idle_handler(); - if (!rb->HasVMT()) return; + if (!rb->m_hasVMT) return; if (g_blockEventsOnDrag) return; if (rb->m_alreadySent) @@ -108,7 +108,7 @@ bool wxRadioBox::Create( wxWindow *parent, wxWindowID id, const wxString& title, gtk_signal_connect( GTK_OBJECT(m_radio), "clicked", GTK_SIGNAL_FUNC(gtk_radiobutton_clicked_callback), (gpointer*)this ); - gtk_myfixed_put( GTK_MYFIXED(m_parent->GetWxWindow()), + gtk_myfixed_put( GTK_MYFIXED(m_parent->m_wxwindow), GTK_WIDGET(m_radio), m_x+10, m_y+10+(i*24), 10, 10 ); } @@ -179,7 +179,7 @@ wxSize wxRadioBox::LayoutItems() int len = 22+gdk_string_measure( font, label->label ); if (len > max_len) max_len = len; - gtk_myfixed_move( GTK_MYFIXED(m_parent->GetWxWindow()), button, m_x+x, m_y+y ); + gtk_myfixed_move( GTK_MYFIXED(m_parent->m_wxwindow), button, m_x+x, m_y+y ); y += 20; node = node->Next(); @@ -193,7 +193,7 @@ wxSize wxRadioBox::LayoutItems() { GtkWidget *button = GTK_WIDGET( node->Data() ); - gtk_myfixed_resize( GTK_MYFIXED(m_parent->GetWxWindow()), button, max_len, 20 ); + gtk_myfixed_resize( GTK_MYFIXED(m_parent->m_wxwindow), button, max_len, 20 ); node = node->Next(); if (!node) break; @@ -229,7 +229,7 @@ wxSize wxRadioBox::LayoutItems() { GtkWidget *button = GTK_WIDGET( node->Data() ); - gtk_myfixed_set_size( GTK_MYFIXED(m_parent->GetWxWindow()), button, m_x+x, m_y+y, max, 20 ); + gtk_myfixed_set_size( GTK_MYFIXED(m_parent->m_wxwindow), button, m_x+x, m_y+y, max, 20 ); x += max; node = node->Next(); diff --git a/src/gtk1/radiobut.cpp b/src/gtk1/radiobut.cpp index 26c87fc583..a3446422f7 100644 --- a/src/gtk1/radiobut.cpp +++ b/src/gtk1/radiobut.cpp @@ -38,7 +38,7 @@ void gtk_radiobutton_clicked_callback( GtkWidget *WXUNUSED(widget), wxRadioButto { if (g_isIdle) wxapp_install_idle_handler(); - if (!rb->HasVMT()) return; + if (!rb->m_hasVMT) return; if (rb->m_blockFirstEvent) { diff --git a/src/gtk1/scrolbar.cpp b/src/gtk1/scrolbar.cpp index 6fd20ff176..84a46924ef 100644 --- a/src/gtk1/scrolbar.cpp +++ b/src/gtk1/scrolbar.cpp @@ -41,7 +41,7 @@ static void gtk_scrollbar_callback( GtkWidget *WXUNUSED(widget), wxScrollBar *wi { if (g_isIdle) wxapp_install_idle_handler(); - if (!win->HasVMT()) return; + if (!win->m_hasVMT) return; if (g_blockEventsOnDrag) return; float diff = win->m_adjust->value - win->m_oldPos; diff --git a/src/gtk1/slider.cpp b/src/gtk1/slider.cpp index 393dddf10c..c28fc43e1b 100644 --- a/src/gtk1/slider.cpp +++ b/src/gtk1/slider.cpp @@ -39,7 +39,7 @@ static void gtk_slider_callback( GtkWidget *WXUNUSED(widget), wxSlider *win ) { if (g_isIdle) wxapp_install_idle_handler(); - if (!win->HasVMT()) return; + if (!win->m_hasVMT) return; if (g_blockEventsOnDrag) return; float diff = win->m_adjust->value - win->m_oldPos; diff --git a/src/gtk1/spinbutt.cpp b/src/gtk1/spinbutt.cpp index 239a565cd7..7b3b204283 100644 --- a/src/gtk1/spinbutt.cpp +++ b/src/gtk1/spinbutt.cpp @@ -42,7 +42,7 @@ static void gtk_spinbutt_callback( GtkWidget *WXUNUSED(widget), wxSpinButton *wi { if (g_isIdle) wxapp_install_idle_handler(); - if (!win->HasVMT()) return; + if (!win->m_hasVMT) return; if (g_blockEventsOnDrag) return; float diff = win->m_adjust->value - win->m_oldPos; diff --git a/src/gtk1/textctrl.cpp b/src/gtk1/textctrl.cpp index 0d41807702..5033f179cc 100644 --- a/src/gtk1/textctrl.cpp +++ b/src/gtk1/textctrl.cpp @@ -46,7 +46,7 @@ gtk_text_changed_callback( GtkWidget *WXUNUSED(widget), wxTextCtrl *win ) { if (g_isIdle) wxapp_install_idle_handler(); - if (!win->HasVMT()) return; + if (!win->m_hasVMT) return; win->SetModified(); @@ -67,7 +67,7 @@ gtk_scrollbar_changed_callback( GtkWidget *WXUNUSED(widget), wxTextCtrl *win ) win->CalculateScrollbar(); - if (!win->HasVMT()) return; + if (!win->m_hasVMT) return; } //----------------------------------------------------------------------------- diff --git a/src/gtk1/window.cpp b/src/gtk1/window.cpp index 17b690e47b..dcf7519e32 100644 --- a/src/gtk1/window.cpp +++ b/src/gtk1/window.cpp @@ -176,25 +176,21 @@ void debug_focus_in( GtkWidget* widget, const wxChar* name, const wxChar *window #endif // Debug //----------------------------------------------------------------------------- -// local code (see below) +// idle system //----------------------------------------------------------------------------- -static void InitAdjustment(GtkAdjustment *adjust) -{ - adjust->lower = 0.0; - adjust->upper = 1.0; - adjust->value = 0.0; - adjust->step_increment = 1.0; - adjust->page_increment = 1.0; - adjust->page_size = 5.0; - gtk_signal_emit_by_name( GTK_OBJECT(adjust), "changed" ); -} +extern void wxapp_install_idle_handler(); +extern bool g_isIdle; + +//----------------------------------------------------------------------------- +// local code (see below) +//----------------------------------------------------------------------------- #if (GTK_MINOR_VERSION > 0) static void draw_frame( GtkWidget *widget, wxWindow *win ) { - if (!win->HasVMT()) + if (!win->m_hasVMT) return; int dw = 0; @@ -240,7 +236,7 @@ static void draw_frame( GtkWidget *widget, wxWindow *win ) GTK_STATE_NORMAL, GTK_SHADOW_OUT, dx, dy, - win->GetWidth()-dw, win->GetHeight()-dh ); + win->m_width-dw, win->m_height-dh ); return; } @@ -251,7 +247,7 @@ static void draw_frame( GtkWidget *widget, wxWindow *win ) GTK_STATE_NORMAL, GTK_SHADOW_IN, dx, dy, - win->GetWidth()-dw, win->GetHeight()-dh ); + win->m_width-dw, win->m_height-dh ); return; } } @@ -283,7 +279,7 @@ static void gtk_window_own_draw_callback( GtkWidget *widget, GdkRectangle *WXUNU static void gtk_window_expose_callback( GtkWidget *WXUNUSED(widget), GdkEventExpose *gdk_event, wxWindow *win ) { - if ( !win->HasVMT() ) + if ( !win->m_hasVMT ) return; win->GetUpdateRegion().Union( gdk_event->area.x, @@ -314,7 +310,10 @@ static void gtk_window_expose_callback( GtkWidget *WXUNUSED(widget), GdkEventExp static void gtk_window_draw_callback( GtkWidget *WXUNUSED(widget), GdkRectangle *rect, wxWindow *win ) { - if ( !win->HasVMT() ) + if (g_isIdle) + wxapp_install_idle_handler(); + + if (!win->m_hasVMT) return; win->GetUpdateRegion().Union( rect->x, rect->y, @@ -333,7 +332,10 @@ static void gtk_window_draw_callback( GtkWidget *WXUNUSED(widget), GdkRectangle static gint gtk_window_key_press_callback( GtkWidget *widget, GdkEventKey *gdk_event, wxWindow *win ) { - if (!win->HasVMT()) return FALSE; + if (g_isIdle) + wxapp_install_idle_handler(); + + if (!win->m_hasVMT) return FALSE; if (g_blockEventsOnDrag) return FALSE; /* @@ -478,7 +480,7 @@ static gint gtk_window_key_press_callback( GtkWidget *widget, GdkEventKey *gdk_e Damn, I forgot why this didn't work, but it didn't work. // win is a panel: up can be propagated to the panel - if ((!ret) && (win->GetWxWindow()) && (win->m_parent) && (win->m_parent->AcceptsFocus()) && + if ((!ret) && (win->m_wxwindow) && (win->m_parent) && (win->m_parent->AcceptsFocus()) && (gdk_event->keyval == GDK_Up)) { win->m_parent->SetFocus(); @@ -486,7 +488,7 @@ static gint gtk_window_key_press_callback( GtkWidget *widget, GdkEventKey *gdk_e } // win is a panel: left/right can be propagated to the panel - if ((!ret) && (win->GetWxWindow()) && + if ((!ret) && (win->m_wxwindow) && ((gdk_event->keyval == GDK_Right) || (gdk_event->keyval == GDK_Left) || (gdk_event->keyval == GDK_Up) || (gdk_event->keyval == GDK_Down))) { @@ -512,7 +514,10 @@ static gint gtk_window_key_press_callback( GtkWidget *widget, GdkEventKey *gdk_e static gint gtk_window_key_release_callback( GtkWidget *widget, GdkEventKey *gdk_event, wxWindow *win ) { - if (!win->HasVMT()) return FALSE; + if (g_isIdle) + wxapp_install_idle_handler(); + + if (!win->m_hasVMT) return FALSE; if (g_blockEventsOnDrag) return FALSE; /* @@ -628,33 +633,43 @@ static gint gtk_window_key_release_callback( GtkWidget *widget, GdkEventKey *gdk static gint gtk_window_button_press_callback( GtkWidget *widget, GdkEventButton *gdk_event, wxWindow *win ) { - if (!win->HasVMT()) return FALSE; + if (g_isIdle) + wxapp_install_idle_handler(); + +/* + wxPrintf( _T("1) OnButtonPress from ") ); + if (win->GetClassInfo() && win->GetClassInfo()->GetClassName()) + wxPrintf( win->GetClassInfo()->GetClassName() ); + wxPrintf( _T(".\n") ); +*/ + + if (!win->m_hasVMT) return FALSE; if (g_blockEventsOnDrag) return TRUE; if (g_blockEventsOnScroll) return TRUE; if (!win->IsOwnGtkWindow( gdk_event->window )) return FALSE; - if (win->GetWxWindow()) + if (win->m_wxwindow) { - if (GTK_WIDGET_CAN_FOCUS(win->GetWxWindow()) && !GTK_WIDGET_HAS_FOCUS (win->GetWxWindow()) ) + if (GTK_WIDGET_CAN_FOCUS(win->m_wxwindow) && !GTK_WIDGET_HAS_FOCUS (win->m_wxwindow) ) { - gtk_widget_grab_focus (win->GetWxWindow()); + gtk_widget_grab_focus (win->m_wxwindow); /* - printf( "GrabFocus from " ); + wxPrintf( _T("GrabFocus from ") ); if (win->GetClassInfo() && win->GetClassInfo()->GetClassName()) - printf( win->GetClassInfo()->GetClassName() ); - printf( ".\n" ); + wxPrintf( win->GetClassInfo()->GetClassName() ); + wxPrintf( _T(".\n") ); */ } } /* - printf( "OnButtonPress from " ); + wxPrintf( _T("2) OnButtonPress from ") ); if (win->GetClassInfo() && win->GetClassInfo()->GetClassName()) - printf( win->GetClassInfo()->GetClassName() ); - printf( ".\n" ); + wxPrintf( win->GetClassInfo()->GetClassName() ); + wxPrintf( _T(".\n") ); */ wxEventType event_type = wxEVT_LEFT_DOWN; @@ -709,17 +724,15 @@ static gint gtk_window_button_press_callback( GtkWidget *widget, GdkEventButton { wxWindow *child = (wxWindow*)node->Data(); - if ( child->IsStaticBox() ) + if (child->m_isStaticBox) { // wxStaticBox is transparent in the box itself - int x = event.m_x, - y = event.m_y; - - wxRect rectChild(child->GetRect()); - int xx1 = rectChild.GetLeft(), - yy1 = rectChild.GetTop(), - xx2 = rectChild.GetRight(), - yy2 = rectChild.GetBottom(); + int x = event.m_x; + int y = event.m_y; + int xx1 = child->m_x; + int yy1 = child->m_y; + int xx2 = child->m_x + child->m_width; + int yy2 = child->m_x + child->m_height; // left if (((x >= xx1) && (x <= xx1+10) && (y >= yy1) && (y <= yy2)) || @@ -731,23 +744,23 @@ static gint gtk_window_button_press_callback( GtkWidget *widget, GdkEventButton ((x >= xx1) && (x <= xx2) && (y >= yy2-1) && (y <= yy2))) { win = child; - event.m_x -= child->GetX(); - event.m_y -= child->GetY(); + event.m_x -= child->m_x; + event.m_y -= child->m_y; break; } } else { - if ((child->GetWxWindow() == (GtkWidget*) NULL) && - (child->GetX() <= event.m_x) && - (child->GetY() <= event.m_y) && - (child->GetX()+child->GetWidth() >= event.m_x) && - (child->GetY()+child->GetHeight() >= event.m_y)) + if ((child->m_wxwindow == (GtkWidget*) NULL) && + (child->m_x <= event.m_x) && + (child->m_y <= event.m_y) && + (child->m_x+child->m_width >= event.m_x) && + (child->m_y+child->m_height >= event.m_y)) { win = child; - event.m_x -= child->GetX(); - event.m_y -= child->GetY(); + event.m_x -= child->m_x; + event.m_y -= child->m_y; break; } } @@ -774,7 +787,10 @@ static gint gtk_window_button_press_callback( GtkWidget *widget, GdkEventButton static gint gtk_window_button_release_callback( GtkWidget *widget, GdkEventButton *gdk_event, wxWindow *win ) { - if (!win->HasVMT()) return FALSE; + if (g_isIdle) + wxapp_install_idle_handler(); + + if (!win->m_hasVMT) return FALSE; if (g_blockEventsOnDrag) return FALSE; if (g_blockEventsOnScroll) return FALSE; @@ -817,15 +833,15 @@ static gint gtk_window_button_release_callback( GtkWidget *widget, GdkEventButto { wxWindow *child = (wxWindow*)node->Data(); - if (child->IsStaticBox() ) + if (child->m_isStaticBox) { // wxStaticBox is transparent in the box itself int x = event.m_x; int y = event.m_y; - int xx1 = child->GetX(); - int yy1 = child->GetY(); - int xx2 = child->GetX() + child->GetWidth(); - int yy2 = child->GetX() + child->GetHeight(); + int xx1 = child->m_x; + int yy1 = child->m_y; + int xx2 = child->m_x + child->m_width; + int yy2 = child->m_x + child->m_height; // left if (((x >= xx1) && (x <= xx1+10) && (y >= yy1) && (y <= yy2)) || @@ -837,23 +853,23 @@ static gint gtk_window_button_release_callback( GtkWidget *widget, GdkEventButto ((x >= xx1) && (x <= xx2) && (y >= yy2-1) && (y <= yy2))) { win = child; - event.m_x -= child->GetX(); - event.m_y -= child->GetY(); + event.m_x -= child->m_x; + event.m_y -= child->m_y; break; } } else { - if ((child->GetWxWindow() == (GtkWidget*) NULL) && - (child->GetX() <= event.m_x) && - (child->GetY() <= event.m_y) && - (child->GetX()+child->GetWidth() >= event.m_x) && - (child->GetY()+child->GetHeight() >= event.m_y)) + if ((child->m_wxwindow == (GtkWidget*) NULL) && + (child->m_x <= event.m_x) && + (child->m_y <= event.m_y) && + (child->m_x+child->m_width >= event.m_x) && + (child->m_y+child->m_height >= event.m_y)) { win = child; - event.m_x -= child->GetX(); - event.m_y -= child->GetY(); + event.m_x -= child->m_x; + event.m_y -= child->m_y; break; } } @@ -878,7 +894,10 @@ static gint gtk_window_button_release_callback( GtkWidget *widget, GdkEventButto static gint gtk_window_motion_notify_callback( GtkWidget *widget, GdkEventMotion *gdk_event, wxWindow *win ) { - if (!win->HasVMT()) return FALSE; + if (g_isIdle) + wxapp_install_idle_handler(); + + if (!win->m_hasVMT) return FALSE; if (g_blockEventsOnDrag) return FALSE; if (g_blockEventsOnScroll) return FALSE; @@ -924,15 +943,15 @@ static gint gtk_window_motion_notify_callback( GtkWidget *widget, GdkEventMotion { wxWindow *child = (wxWindow*)node->Data(); - if ( child->IsStaticBox() ) + if (child->m_isStaticBox) { // wxStaticBox is transparent in the box itself int x = event.m_x; int y = event.m_y; - int xx1 = child->GetX(); - int yy1 = child->GetY(); - int xx2 = child->GetX() + child->GetWidth(); - int yy2 = child->GetX() + child->GetHeight(); + int xx1 = child->m_x; + int yy1 = child->m_y; + int xx2 = child->m_x + child->m_width; + int yy2 = child->m_x + child->m_height; // left if (((x >= xx1) && (x <= xx1+10) && (y >= yy1) && (y <= yy2)) || @@ -944,23 +963,23 @@ static gint gtk_window_motion_notify_callback( GtkWidget *widget, GdkEventMotion ((x >= xx1) && (x <= xx2) && (y >= yy2-1) && (y <= yy2))) { win = child; - event.m_x -= child->GetX(); - event.m_y -= child->GetY(); + event.m_x -= child->m_x; + event.m_y -= child->m_y; break; } } else { - if ((child->GetWxWindow() == (GtkWidget*) NULL) && - (child->GetX() <= event.m_x) && - (child->GetY() <= event.m_y) && - (child->GetX()+child->GetWidth() >= event.m_x) && - (child->GetY()+child->GetHeight() >= event.m_y)) + if ((child->m_wxwindow == (GtkWidget*) NULL) && + (child->m_x <= event.m_x) && + (child->m_y <= event.m_y) && + (child->m_x+child->m_width >= event.m_x) && + (child->m_y+child->m_height >= event.m_y)) { win = child; - event.m_x -= child->GetX(); - event.m_y -= child->GetY(); + event.m_x -= child->m_x; + event.m_y -= child->m_y; break; } } @@ -985,16 +1004,19 @@ static gint gtk_window_motion_notify_callback( GtkWidget *widget, GdkEventMotion static gint gtk_window_focus_in_callback( GtkWidget *widget, GdkEvent *WXUNUSED(event), wxWindow *win ) { - if (!win->HasVMT()) return FALSE; + if (g_isIdle) + wxapp_install_idle_handler(); + + if (!win->m_hasVMT) return FALSE; if (g_blockEventsOnDrag) return FALSE; g_focusWindow = win; - if (win->GetWxWindow()) + if (win->m_wxwindow) { - if (GTK_WIDGET_CAN_FOCUS(win->GetWxWindow())) + if (GTK_WIDGET_CAN_FOCUS(win->m_wxwindow)) { - GTK_WIDGET_SET_FLAGS (win->GetWxWindow(), GTK_HAS_FOCUS); + GTK_WIDGET_SET_FLAGS (win->m_wxwindow, GTK_HAS_FOCUS); /* printf( "SetFocus flag from " ); if (win->GetClassInfo() && win->GetClassInfo()->GetClassName()) @@ -1032,13 +1054,16 @@ static gint gtk_window_focus_in_callback( GtkWidget *widget, GdkEvent *WXUNUSED( static gint gtk_window_focus_out_callback( GtkWidget *widget, GdkEvent *WXUNUSED(event), wxWindow *win ) { - if (!win->HasVMT()) return FALSE; + if (g_isIdle) + wxapp_install_idle_handler(); + + if (!win->m_hasVMT) return FALSE; if (g_blockEventsOnDrag) return FALSE; - if (win->GetWxWindow()) + if (win->m_wxwindow) { - if (GTK_WIDGET_CAN_FOCUS(win->GetWxWindow())) - GTK_WIDGET_UNSET_FLAGS (win->GetWxWindow(), GTK_HAS_FOCUS); + if (GTK_WIDGET_CAN_FOCUS(win->m_wxwindow)) + GTK_WIDGET_UNSET_FLAGS (win->m_wxwindow, GTK_HAS_FOCUS); } /* @@ -1066,22 +1091,16 @@ static gint gtk_window_focus_out_callback( GtkWidget *widget, GdkEvent *WXUNUSED static gint gtk_window_enter_callback( GtkWidget *widget, GdkEventCrossing *gdk_event, wxWindow *win ) { - if ( !win->HasVMT() || g_blockEventsOnDrag ) - return FALSE; + if (g_isIdle) + wxapp_install_idle_handler(); - GdkWindow *window = widget->window; - if ( window != gdk_event->window ) - return FALSE; + if (!win->m_hasVMT) return FALSE; + if (g_blockEventsOnDrag) return FALSE; - if ( window && win->GetCursor().Ok() ) - gdk_window_set_cursor( window, win->GetCursor().GetCursor() ); + if (!win->IsOwnGtkWindow( gdk_event->window )) return FALSE; -/* - printf( "OnEnter from " ); - if (win->GetClassInfo() && win->GetClassInfo()->GetClassName()) - printf( win->GetClassInfo()->GetClassName() ); - printf( ".\n" ); -*/ + if (widget->window && win->GetCursor().Ok() ) + gdk_window_set_cursor( widget->window, win->GetCursor().GetCursor() ); wxMouseEvent event( wxEVT_ENTER_WINDOW ); event.SetEventObject( win ); @@ -1090,7 +1109,7 @@ static gint gtk_window_enter_callback( GtkWidget *widget, GdkEventCrossing *gdk_ int y = 0; GdkModifierType state = (GdkModifierType)0; - gdk_window_get_pointer( window, &x, &y, &state ); + gdk_window_get_pointer( widget->window, &x, &y, &state ); event.m_shiftDown = (state & GDK_SHIFT_MASK); event.m_controlDown = (state & GDK_CONTROL_MASK); @@ -1118,22 +1137,16 @@ static gint gtk_window_enter_callback( GtkWidget *widget, GdkEventCrossing *gdk_ static gint gtk_window_leave_callback( GtkWidget *widget, GdkEventCrossing *gdk_event, wxWindow *win ) { - if ( !win->HasVMT() || g_blockEventsOnDrag ) - return FALSE; + if (g_isIdle) + wxapp_install_idle_handler(); - GdkWindow *window = widget->window; - if ( window != gdk_event->window ) - return FALSE; - - if ( window && win->GetCursor().Ok() ) - gdk_window_set_cursor( window, wxSTANDARD_CURSOR->GetCursor() ); + if (!win->m_hasVMT) return FALSE; + if (g_blockEventsOnDrag) return FALSE; -/* - printf( "OnLeave from " ); - if (win->GetClassInfo() && win->GetClassInfo()->GetClassName()) - printf( win->GetClassInfo()->GetClassName() ); - printf( ".\n" ); -*/ + if (!win->IsOwnGtkWindow( gdk_event->window )) return FALSE; + + if (widget->window && win->GetCursor().Ok() ) + gdk_window_set_cursor( widget->window, wxSTANDARD_CURSOR->GetCursor() ); wxMouseEvent event( wxEVT_LEAVE_WINDOW ); event.SetEventObject( win ); @@ -1170,25 +1183,21 @@ static gint gtk_window_leave_callback( GtkWidget *widget, GdkEventCrossing *gdk_ static void gtk_window_vscroll_callback( GtkWidget *WXUNUSED(widget), wxWindow *win ) { - if (g_blockEventsOnDrag) return; + if (g_isIdle) + wxapp_install_idle_handler(); -/* - printf( "OnVScroll from " ); - if (win->GetClassInfo() && win->GetClassInfo()->GetClassName()) - printf( win->GetClassInfo()->GetClassName() ); - printf( ".\n" ); -*/ + if (g_blockEventsOnDrag) return; - if (!win->HasVMT()) return; + if (!win->m_hasVMT) return; - float diff = win->GetVAdjust()->value - win->GetOldVerticalPos(); + float diff = win->m_vAdjust->value - win->m_oldVerticalPos; if (fabs(diff) < 0.2) return; - win->SetOldVerticalPos(win->GetVAdjust()->value); + win->m_oldVerticalPos = win->m_vAdjust->value; wxEventType command = wxEVT_NULL; - float line_step = win->GetVAdjust()->step_increment; - float page_step = win->GetVAdjust()->page_increment; + float line_step = win->m_vAdjust->step_increment; + float page_step = win->m_vAdjust->page_increment; if (win->IsScrolling()) { @@ -1196,8 +1205,8 @@ static void gtk_window_vscroll_callback( GtkWidget *WXUNUSED(widget), wxWindow * } else { - if (fabs(win->GetVAdjust()->value-win->GetVAdjust()->lower) < 0.2) command = wxEVT_SCROLL_BOTTOM; - else if (fabs(win->GetVAdjust()->value-win->GetVAdjust()->upper) < 0.2) command = wxEVT_SCROLL_TOP; + if (fabs(win->m_vAdjust->value-win->m_vAdjust->lower) < 0.2) command = wxEVT_SCROLL_BOTTOM; + else if (fabs(win->m_vAdjust->value-win->m_vAdjust->upper) < 0.2) command = wxEVT_SCROLL_TOP; else if (fabs(diff-line_step) < 0.2) command = wxEVT_SCROLL_LINEDOWN; else if (fabs(diff+line_step) < 0.2) command = wxEVT_SCROLL_LINEUP; else if (fabs(diff-page_step) < 0.2) command = wxEVT_SCROLL_PAGEDOWN; @@ -1205,7 +1214,7 @@ static void gtk_window_vscroll_callback( GtkWidget *WXUNUSED(widget), wxWindow * else command = wxEVT_SCROLL_THUMBTRACK; } - int value = (int)(win->GetVAdjust()->value+0.5); + int value = (int)(win->m_vAdjust->value+0.5); wxScrollEvent event( command, win->GetId(), value, wxVERTICAL ); event.SetEventObject( win ); @@ -1218,25 +1227,20 @@ static void gtk_window_vscroll_callback( GtkWidget *WXUNUSED(widget), wxWindow * static void gtk_window_hscroll_callback( GtkWidget *WXUNUSED(widget), wxWindow *win ) { - if (g_blockEventsOnDrag) return; - -/* - printf( "OnHScroll from " ); - if (win->GetClassInfo() && win->GetClassInfo()->GetClassName()) - printf( win->GetClassInfo()->GetClassName() ); - printf( ".\n" ); -*/ + if (g_isIdle) + wxapp_install_idle_handler(); - if (!win->HasVMT()) return; + if (g_blockEventsOnDrag) return; + if (!win->m_hasVMT) return; - float diff = win->GetHAdjust()->value - win->GetOldHorizontalPos(); + float diff = win->m_hAdjust->value - win->m_oldHorizontalPos; if (fabs(diff) < 0.2) return; - win->SetOldHorizontalPos( win->GetHAdjust()->value ); + win->m_oldHorizontalPos = win->m_hAdjust->value; wxEventType command = wxEVT_NULL; - float line_step = win->GetHAdjust()->step_increment; - float page_step = win->GetHAdjust()->page_increment; + float line_step = win->m_hAdjust->step_increment; + float page_step = win->m_hAdjust->page_increment; if (win->IsScrolling()) { @@ -1244,8 +1248,8 @@ static void gtk_window_hscroll_callback( GtkWidget *WXUNUSED(widget), wxWindow * } else { - if (fabs(win->GetHAdjust()->value-win->GetHAdjust()->lower) < 0.2) command = wxEVT_SCROLL_BOTTOM; - else if (fabs(win->GetHAdjust()->value-win->GetHAdjust()->upper) < 0.2) command = wxEVT_SCROLL_TOP; + if (fabs(win->m_hAdjust->value-win->m_hAdjust->lower) < 0.2) command = wxEVT_SCROLL_BOTTOM; + else if (fabs(win->m_hAdjust->value-win->m_hAdjust->upper) < 0.2) command = wxEVT_SCROLL_TOP; else if (fabs(diff-line_step) < 0.2) command = wxEVT_SCROLL_LINEDOWN; else if (fabs(diff+line_step) < 0.2) command = wxEVT_SCROLL_LINEUP; else if (fabs(diff-page_step) < 0.2) command = wxEVT_SCROLL_PAGEDOWN; @@ -1253,7 +1257,7 @@ static void gtk_window_hscroll_callback( GtkWidget *WXUNUSED(widget), wxWindow * else command = wxEVT_SCROLL_THUMBTRACK; } - int value = (int)(win->GetHAdjust()->value+0.5); + int value = (int)(win->m_hAdjust->value+0.5); wxScrollEvent event( command, win->GetId(), value, wxHORIZONTAL ); event.SetEventObject( win ); @@ -1266,19 +1270,14 @@ static void gtk_window_hscroll_callback( GtkWidget *WXUNUSED(widget), wxWindow * static void gtk_window_vscroll_change_callback( GtkWidget *WXUNUSED(widget), wxWindow *win ) { - if (g_blockEventsOnDrag) return; + if (g_isIdle) + wxapp_install_idle_handler(); -/* - printf( "OnVScroll change from " ); - if (win->GetClassInfo() && win->GetClassInfo()->GetClassName()) - printf( win->GetClassInfo()->GetClassName() ); - printf( ".\n" ); -*/ - - if (!win->HasVMT()) return; + if (g_blockEventsOnDrag) return; + if (!win->m_hasVMT) return; wxEventType command = wxEVT_SCROLL_THUMBTRACK; - int value = (int)(win->GetVAdjust()->value+0.5); + int value = (int)(win->m_vAdjust->value+0.5); wxScrollEvent event( command, win->GetId(), value, wxVERTICAL ); event.SetEventObject( win ); @@ -1291,19 +1290,14 @@ static void gtk_window_vscroll_change_callback( GtkWidget *WXUNUSED(widget), wxW static void gtk_window_hscroll_change_callback( GtkWidget *WXUNUSED(widget), wxWindow *win ) { - if (g_blockEventsOnDrag) return; - -/* - printf( "OnHScroll change from " ); - if (win->GetClassInfo() && win->GetClassInfo()->GetClassName()) - printf( win->GetClassInfo()->GetClassName() ); - printf( ".\n" ); -*/ + if (g_isIdle) + wxapp_install_idle_handler(); - if (!win->HasVMT()) return; + if (g_blockEventsOnDrag) return; + if (!win->m_hasVMT) return; wxEventType command = wxEVT_SCROLL_THUMBTRACK; - int value = (int)(win->GetHAdjust()->value+0.5); + int value = (int)(win->m_hAdjust->value+0.5); wxScrollEvent event( command, win->GetId(), value, wxHORIZONTAL ); event.SetEventObject( win ); @@ -1318,6 +1312,9 @@ static gint gtk_scrollbar_button_press_callback( GtkRange *WXUNUSED(widget), GdkEventButton *WXUNUSED(gdk_event), wxWindow *win ) { + if (g_isIdle) + wxapp_install_idle_handler(); + // don't test here as we can release the mouse while being over // a different window then the slider // @@ -1342,12 +1339,12 @@ static gint gtk_scrollbar_button_release_callback( GtkRange *widget, // // if (gdk_event->window != widget->slider) return FALSE; - GtkScrolledWindow *scrolledWindow = GTK_SCROLLED_WINDOW(win->GetHandle()); + GtkScrolledWindow *scrolledWindow = GTK_SCROLLED_WINDOW(win->m_widget); if (widget == GTK_RANGE(scrolledWindow->vscrollbar)) - gtk_signal_emit_by_name( GTK_OBJECT(win->GetHAdjust()), "value_changed" ); + gtk_signal_emit_by_name( GTK_OBJECT(win->m_hAdjust), "value_changed" ); else - gtk_signal_emit_by_name( GTK_OBJECT(win->GetVAdjust()), "value_changed" ); + gtk_signal_emit_by_name( GTK_OBJECT(win->m_vAdjust), "value_changed" ); win->SetScrolling( FALSE ); @@ -1364,6 +1361,47 @@ wxWindow *wxWindowBase::FindFocus() return g_focusWindow; } +//----------------------------------------------------------------------------- +// "realize" from m_widget +//----------------------------------------------------------------------------- + +/* we cannot set colours, fonts and cursors before the widget has + been realized, so we do this directly after realization */ + +static gint +gtk_window_realized_callback( GtkWidget *widget, wxWindow *win ) +{ + if (g_isIdle) + wxapp_install_idle_handler(); + + if (win->m_font != *wxSWISS_FONT) + { + wxFont font( win->m_font ); + win->m_font = wxNullFont; + win->SetFont( font ); + } + + if (win->m_backgroundColour != wxSystemSettings::GetSystemColour( wxSYS_COLOUR_BTNFACE )) + { + wxColour bg( win->m_backgroundColour ); + win->m_backgroundColour = wxNullColour; + win->SetBackgroundColour( bg ); + } + + if (win->m_foregroundColour != *wxBLACK) + { + wxColour fg( win->m_foregroundColour ); + win->m_foregroundColour = wxNullColour; + win->SetForegroundColour( fg ); + } + + wxCursor cursor( win->m_cursor ); + win->m_cursor = wxNullCursor; + win->SetCursor( cursor ); + + return FALSE; +} + //----------------------------------------------------------------------------- // InsertChild for wxWindow. //----------------------------------------------------------------------------- @@ -1377,22 +1415,18 @@ wxWindow *wxWindowBase::FindFocus() static void wxInsertChildInWindow( wxWindow* parent, wxWindow* child ) { - gtk_myfixed_put( GTK_MYFIXED(parent->GetWxWindow()), - GTK_WIDGET(child->GetHandle()), - child->GetX(), - child->GetY(), - child->GetWidth(), - child->GetHeight() ); - - gtk_widget_set_usize( GTK_WIDGET(child->GetHandle()), - child->GetWidth(), - child->GetHeight() ); + gtk_myfixed_put( GTK_MYFIXED(parent->m_wxwindow), + GTK_WIDGET(child->m_widget), + child->m_x, + child->m_y, + child->m_width, + child->m_height ); if (parent->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->GetWxWindow(), GTK_CAN_FOCUS ); + GTK_WIDGET_UNSET_FLAGS( parent->m_wxwindow, GTK_CAN_FOCUS ); } } @@ -1421,12 +1455,13 @@ void wxWindow::Init() InitBase(); // GTK specific + m_widget = (GtkWidget *) NULL; m_wxwindow = (GtkWidget *) NULL; // position/size - m_x = - m_y = - m_width = + m_x = 0; + m_y = 0; + m_width = 0; m_height = 0; m_font = *wxSWISS_FONT; @@ -1436,12 +1471,12 @@ void wxWindow::Init() m_hasVMT = FALSE; m_needParent = TRUE; - m_hasScrolling = + m_hasScrolling = FALSE; m_isScrolling = FALSE; - m_hAdjust = + m_hAdjust = (GtkAdjustment*) NULL; m_vAdjust = (GtkAdjustment*) NULL; - m_oldHorizontalPos = + m_oldHorizontalPos = 0.0; m_oldVerticalPos = 0.0; m_resizing = FALSE; @@ -1556,8 +1591,20 @@ bool wxWindow::Create( wxWindow *parent, wxWindowID id, #endif // GTK_MINOR_VERSION == 0 // I _really_ don't want scrollbars in the beginning - InitAdjustment(m_vAdjust); - InitAdjustment(m_hAdjust); + m_vAdjust->lower = 0.0; + m_vAdjust->upper = 1.0; + m_vAdjust->value = 0.0; + m_vAdjust->step_increment = 1.0; + m_vAdjust->page_increment = 1.0; + m_vAdjust->page_size = 5.0; + gtk_signal_emit_by_name( GTK_OBJECT(m_vAdjust), "changed" ); + m_hAdjust->lower = 0.0; + m_hAdjust->upper = 1.0; + m_hAdjust->value = 0.0; + m_hAdjust->step_increment = 1.0; + m_hAdjust->page_increment = 1.0; + m_hAdjust->page_size = 5.0; + gtk_signal_emit_by_name( GTK_OBJECT(m_hAdjust), "changed" ); // these handlers block mouse events to any window during scrolling such as // motion events and prevent GTK and wxWindows from fighting over where the @@ -1608,20 +1655,34 @@ wxWindow::~wxWindow() if (m_widget) Show( FALSE ); + DestroyChildren(); + if (m_parent) m_parent->RemoveChild( this ); if (m_widgetStyle) + { gtk_style_unref( m_widgetStyle ); + m_widgetStyle = (GtkStyle*) NULL; + } if (m_scrollGC) + { gdk_gc_unref( m_scrollGC ); + m_scrollGC = (GdkGC*) NULL; + } if (m_wxwindow) + { gtk_widget_destroy( m_wxwindow ); + m_wxwindow = (GtkWidget*) NULL; + } if (m_widget) + { gtk_widget_destroy( m_widget ); + m_widget = (GtkWidget*) NULL; + } } void wxWindow::PreCreation( wxWindow *parent, @@ -1682,16 +1743,14 @@ void wxWindow::PostCreation() #endif } - ConnectWidget( GetConnectWidget() ); - - /* we force the creation of wxFrame and wxDialog in the respective code */ - if (m_parent) - gtk_widget_realize( m_widget ); + GtkWidget *connect_widget = GetConnectWidget(); - if (m_wxwindow) - gtk_widget_realize( m_wxwindow ); + ConnectWidget( connect_widget ); - SetCursor( *wxSTANDARD_CURSOR ); + /* we cannot set colours, fonts and cursors before the widget has + been realized, so we do this directly after realization */ + gtk_signal_connect( GTK_OBJECT(connect_widget), "realize", + GTK_SIGNAL_FUNC(gtk_window_realized_callback), (gpointer) this ); m_hasVMT = TRUE; } @@ -1743,7 +1802,7 @@ void wxWindow::DoSetSize( int x, int y, int width, int height, int sizeFlags ) if (m_resizing) return; /* I don't like recursions */ m_resizing = TRUE; - if (m_parent->GetWxWindow() == NULL) /* i.e. wxNotebook */ + if (m_parent->m_wxwindow == NULL) /* i.e. wxNotebook */ { /* don't set the size for children of wxNotebook, just take the values. */ m_x = x; @@ -1753,9 +1812,6 @@ void wxWindow::DoSetSize( int x, int y, int width, int height, int sizeFlags ) } else { - int old_width = m_width; - int old_height = m_height; - if ((sizeFlags & wxSIZE_USE_EXISTING) == wxSIZE_USE_EXISTING) { if (x != -1) m_x = x; @@ -1786,22 +1842,41 @@ void wxWindow::DoSetSize( int x, int y, int width, int height, int sizeFlags ) if ((m_maxWidth != -1) && (m_width > m_maxWidth)) m_width = m_maxWidth; if ((m_maxHeight != -1) && (m_height > m_maxHeight)) m_height = m_maxHeight; - if (GTK_WIDGET_HAS_DEFAULT(m_widget)) - { - /* the default button has a border around it */ - int border = 5; - - gtk_myfixed_move( GTK_MYFIXED(m_parent->GetWxWindow()), m_widget, m_x-border, m_y-border ); - - gtk_widget_set_usize( m_widget, m_width+2*border, m_height+2*border ); - } - else - { - gtk_myfixed_move( GTK_MYFIXED(m_parent->GetWxWindow()), m_widget, m_x, m_y ); + int border = 0; - if ((old_width != m_width) || (old_height != m_height)) - gtk_widget_set_usize( m_widget, m_width, m_height ); - } + if (GTK_WIDGET_HAS_DEFAULT(m_widget)) + { + /* the default button has a border around it */ + border = 5; + } + + /* this is the result of hours of debugging: the following code + means that if we have a m_wxwindow and we set the size of + m_widget, m_widget (which is a GtkScrolledWindow) does NOT + automatically propagate its size down to its m_wxwindow, + which is its client area. therefore, we have to tell the + client area directly that it has to resize itself. + this will lead to that m_widget (GtkScrolledWindow) will + calculate how much size it needs for scrollbars etc and + it will then call XXX_size_allocate of its child, which + is m_wxwindow. m_wxwindow in turn will do the same with its + children and so on. problems can arise if this happens + before all the children have been realized as some widgets + stupidy need to be realized during XXX_size_allocate (e.g. + GtkNotebook) and they will segv if called otherwise. this + emergency is tested in gtk_myfixed_size_allocate. Normally + this shouldn't be needed and only gtk_widget_queue_resize() + should be enough to provoke a resize at the next appropriate + moment, but this seems to fail, e.g. when a wxNotebook contains + a wxSplitterWindow: the splitter window's children won't + show up properly resized then. */ + + gtk_myfixed_set_size( GTK_MYFIXED(m_parent->m_wxwindow), + m_widget, + m_x-border, + m_y-border, + m_width+2*border, + m_height+2*border ); } m_sizeSet = TRUE; @@ -1965,6 +2040,8 @@ void wxWindow::ClientToScreen( int *x, int *y ) const { wxCHECK_RET( (m_widget != NULL), _T("invalid window") ); + if (!m_widget->window) return; + GdkWindow *source = (GdkWindow *) NULL; if (m_wxwindow) source = m_wxwindow->window; @@ -1992,6 +2069,8 @@ void wxWindow::ScreenToClient( int *x, int *y ) const { wxCHECK_RET( (m_widget != NULL), _T("invalid window") ); + if (!m_widget->window) return; + GdkWindow *source = (GdkWindow *) NULL; if (m_wxwindow) source = m_wxwindow->window; @@ -2125,11 +2204,11 @@ bool wxWindow::Reparent( wxWindow *newParent ) { wxCHECK_MSG( (m_widget != NULL), (wxWindow*) NULL, _T("invalid window") ); + gtk_widget_unparent( m_widget ); + if ( !wxWindowBase::Reparent(newParent) ) return FALSE; - gtk_widget_unparent( m_widget ); - return TRUE; } @@ -2137,6 +2216,8 @@ void wxWindow::Raise() { wxCHECK_RET( (m_widget != NULL), _T("invalid window") ); + if (!m_widget->window) return; + gdk_window_raise( m_widget->window ); } @@ -2144,6 +2225,8 @@ void wxWindow::Lower() { wxCHECK_RET( (m_widget != NULL), _T("invalid window") ); + if (!m_widget->window) return; + gdk_window_lower( m_widget->window ); } @@ -2153,6 +2236,8 @@ bool wxWindow::SetCursor( const wxCursor &cursor ) if ( wxWindowBase::SetCursor(cursor) ) { + if (!m_widget->window) return TRUE; + if ((m_widget) && (m_widget->window)) gdk_window_set_cursor( m_widget->window, GetCursor().GetCursor() ); @@ -2178,6 +2263,8 @@ void wxWindow::Refresh( bool eraseBackground, const wxRect *rect ) { wxCHECK_RET( (m_widget != NULL), _T("invalid window") ); + if (!m_widget->window) return; + if (eraseBackground && m_wxwindow && m_wxwindow->window) { if (rect) @@ -2218,6 +2305,8 @@ void wxWindow::Clear() { wxCHECK_RET( m_widget != NULL, _T("invalid window") ); + if (!m_widget->window) return; + if (m_wxwindow && m_wxwindow->window) { gdk_window_clear( m_wxwindow->window ); @@ -2243,13 +2332,16 @@ bool wxWindow::SetBackgroundColour( const wxColour &colour ) { wxCHECK_MSG( m_widget != NULL, FALSE, _T("invalid window") ); - if ( !wxWindowBase::SetBackgroundColour(colour) ) - return FALSE; + if (!colour.Ok()) return FALSE; + if (m_backgroundColour == colour) return FALSE; + + GtkWidget *connect_widget = GetConnectWidget(); + if (!connect_widget->window) return TRUE; if (m_wxwindow && m_wxwindow->window) { - // wxMSW doesn't clear the window here. I don't do that either to - // provide compatibility. call Clear() to do the job. + /* wxMSW doesn't clear the window here. I don't do that either to + provide compatibility. call Clear() to do the job. */ m_backgroundColour.CalcPixel( gdk_window_get_colormap( m_wxwindow->window ) ); gdk_window_set_background( m_wxwindow->window, m_backgroundColour.GetColor() ); @@ -2275,8 +2367,11 @@ bool wxWindow::SetForegroundColour( const wxColour &colour ) { wxCHECK_MSG( m_widget != NULL, FALSE, _T("invalid window") ); - if ( !wxWindowBase::SetForegroundColour(colour) ) - return FALSE; + if (!colour.Ok()) return FALSE; + if (m_backgroundColour == colour) return FALSE; + + GtkWidget *connect_widget = GetConnectWidget(); + if (!connect_widget->window) return TRUE; wxColour sysbg = wxSystemSettings::GetSystemColour( wxSYS_COLOUR_BTNFACE ); if ( sysbg == m_foregroundColour ) @@ -2419,13 +2514,13 @@ bool wxWindow::IsOwnGtkWindow( GdkWindow *window ) bool wxWindow::SetFont( const wxFont &font ) { - wxCHECK_MSG( m_widget != NULL, FALSE, _T("invalid window") ); + wxCHECK_MSG( m_widget != NULL, FALSE, _T( "invalid window") ); - if ( !wxWindowBase::SetFont(font) ) - { - // nothing to do - return FALSE; - } + if (!font.Ok()) return FALSE; + if (m_font == font) return FALSE; + + GtkWidget *connect_widget = GetConnectWidget(); + if (!connect_widget->window) return TRUE; wxColour sysbg = wxSystemSettings::GetSystemColour( wxSYS_COLOUR_BTNFACE ); if ( sysbg == m_backgroundColour ) @@ -2449,6 +2544,8 @@ void wxWindow::CaptureMouse() wxCHECK_RET( g_capturing == FALSE, _T("CaptureMouse called twice") ); GtkWidget *connect_widget = GetConnectWidget(); + if (!connect_widget->window) return; + gtk_grab_add( connect_widget ); gdk_pointer_grab( connect_widget->window, FALSE, (GdkEventMask) @@ -2468,6 +2565,8 @@ void wxWindow::ReleaseMouse() wxCHECK_RET( g_capturing == TRUE, _T("ReleaseMouse called twice") ); GtkWidget *connect_widget = GetConnectWidget(); + if (!connect_widget->window) return; + gtk_grab_remove( connect_widget ); gdk_pointer_ungrab ( GDK_CURRENT_TIME ); g_capturing = FALSE; @@ -2628,50 +2727,52 @@ void wxWindow::ScrollWindow( int dx, int dy, const wxRect* WXUNUSED(rect) ) wxCHECK_RET( m_wxwindow != NULL, _T("window needs client area for scrolling") ); - wxNode *node = m_children.First(); - while (node) + if (!m_scrollGC) { - wxWindow *child = (wxWindow*) node->Data(); - child->Move( child->GetX() + dx, child->GetY() + dy ); - node = node->Next(); + m_scrollGC = gdk_gc_new( m_wxwindow->window ); + gdk_gc_set_exposures( m_scrollGC, TRUE ); } int cw = 0; int ch = 0; GetClientSize( &cw, &ch ); - int w = cw - abs(dx); int h = ch - abs(dy); + if ((h < 0) || (w < 0)) { Refresh(); - return; } - int s_x = 0; - int s_y = 0; - if (dx < 0) s_x = -dx; - if (dy < 0) s_y = -dy; - int d_x = 0; - int d_y = 0; - if (dx > 0) d_x = dx; - if (dy > 0) d_y = dy; - - if (!m_scrollGC) + else { - m_scrollGC = gdk_gc_new( m_wxwindow->window ); - gdk_gc_set_exposures( m_scrollGC, TRUE ); - } + int s_x = 0; + int s_y = 0; + if (dx < 0) s_x = -dx; + if (dy < 0) s_y = -dy; + int d_x = 0; + int d_y = 0; + if (dx > 0) d_x = dx; + if (dy > 0) d_y = dy; - gdk_window_copy_area( m_wxwindow->window, m_scrollGC, d_x, d_y, - m_wxwindow->window, s_x, s_y, w, h ); + gdk_window_copy_area( m_wxwindow->window, m_scrollGC, d_x, d_y, + m_wxwindow->window, s_x, s_y, w, h ); - wxRect rect; - if (dx < 0) rect.x = cw+dx; else rect.x = 0; - if (dy < 0) rect.y = ch+dy; else rect.y = 0; - if (dy != 0) rect.width = cw; else rect.width = abs(dx); - if (dx != 0) rect.height = ch; else rect.height = abs(dy); + wxRect rect; + if (dx < 0) rect.x = cw+dx; else rect.x = 0; + if (dy < 0) rect.y = ch+dy; else rect.y = 0; + if (dy != 0) rect.width = cw; else rect.width = abs(dx); + if (dx != 0) rect.height = ch; else rect.height = abs(dy); - Refresh( TRUE, &rect ); + Refresh( TRUE, &rect ); + } + + wxNode *node = m_children.First(); + while (node) + { + wxWindow *child = (wxWindow*) node->Data(); + child->Move( child->m_x + dx, child->m_y + dy ); + node = node->Next(); + } } void wxWindow::SetScrolling(bool scroll) -- 2.45.2