From b4071e913e85e35024ee5883a0a046f0fd6332bf Mon Sep 17 00:00:00 2001 From: Robert Roebling Date: Mon, 7 Sep 1998 12:29:07 +0000 Subject: [PATCH] Much more aggressive for intercepting events and (not) redirecting them to wxWindows or GTK All widgets work now in DialogEd git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@703 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/gtk/choice.h | 1 + include/wx/gtk/combobox.h | 6 +- include/wx/gtk/listbox.h | 10 +-- include/wx/gtk/radiobox.h | 2 + include/wx/gtk/scrolbar.h | 4 +- include/wx/gtk/slider.h | 6 +- include/wx/gtk/textctrl.h | 4 +- include/wx/gtk/window.h | 1 + include/wx/gtk1/choice.h | 1 + include/wx/gtk1/combobox.h | 6 +- include/wx/gtk1/listbox.h | 10 +-- include/wx/gtk1/radiobox.h | 2 + include/wx/gtk1/scrolbar.h | 4 +- include/wx/gtk1/slider.h | 6 +- include/wx/gtk1/textctrl.h | 4 +- include/wx/gtk1/window.h | 1 + samples/controls/controls.cpp | 2 +- src/gtk/combobox.cpp | 49 +++++------ src/gtk/radiobox.cpp | 25 +++++- src/gtk/scrolbar.cpp | 15 +++- src/gtk/slider.cpp | 11 +++ src/gtk/statbox.cpp | 3 +- src/gtk/textctrl.cpp | 1 - src/gtk/window.cpp | 148 +++++++++++++++++----------------- src/gtk1/combobox.cpp | 49 +++++------ src/gtk1/radiobox.cpp | 25 +++++- src/gtk1/scrolbar.cpp | 15 +++- src/gtk1/slider.cpp | 11 +++ src/gtk1/statbox.cpp | 3 +- src/gtk1/textctrl.cpp | 1 - src/gtk1/window.cpp | 148 +++++++++++++++++----------------- 31 files changed, 345 insertions(+), 229 deletions(-) diff --git a/include/wx/gtk/choice.h b/include/wx/gtk/choice.h index 6849cec905..9929a37fef 100644 --- a/include/wx/gtk/choice.h +++ b/include/wx/gtk/choice.h @@ -73,6 +73,7 @@ class wxChoice: public wxControl void SetColumns( int n = 1 ); void SetSelection( int n ); void SetStringSelection( const wxString &string ); + void SetFont( const wxFont &font ); }; diff --git a/include/wx/gtk/combobox.h b/include/wx/gtk/combobox.h index d810577372..c7d7b7064b 100644 --- a/include/wx/gtk/combobox.h +++ b/include/wx/gtk/combobox.h @@ -94,6 +94,7 @@ class wxComboBox: public wxControl void SetEditable(bool editable); void SetFont( const wxFont &font ); + void OnSize( wxSizeEvent &event ); // implementation @@ -102,8 +103,11 @@ class wxComboBox: public wxControl private: wxList m_clientData; + + GtkWidget* GetConnectWidget(void); + bool IsOwnGtkWindow( GdkWindow *window ); - GtkWidget* GetConnectWidget(void); + DECLARE_EVENT_TABLE() }; #endif // __GTKCOMBOBOXH__ diff --git a/include/wx/gtk/listbox.h b/include/wx/gtk/listbox.h index 44f4d5aa19..1a6b810396 100644 --- a/include/wx/gtk/listbox.h +++ b/include/wx/gtk/listbox.h @@ -84,16 +84,16 @@ class wxListBox: public wxControl void SetStringSelection( const wxString &string, bool select = TRUE ); void SetFont( const wxFont &font ); - virtual GtkWidget *GetConnectWidget(void); - + // implementation + + int GetIndex( GtkWidget *item ) const; + GtkWidget *GetConnectWidget(void); + private: GtkList *m_list; wxList m_clientData; - public: - - int GetIndex( GtkWidget *item ) const; }; #endif // __GTKLISTBOXH__ diff --git a/include/wx/gtk/radiobox.h b/include/wx/gtk/radiobox.h index 3ba68d40d9..5fb8792ba2 100644 --- a/include/wx/gtk/radiobox.h +++ b/include/wx/gtk/radiobox.h @@ -84,6 +84,8 @@ class wxRadioBox: public wxControl // implementation + bool IsOwnGtkWindow( GdkWindow *window ); + bool m_alreadySent; private: diff --git a/include/wx/gtk/scrolbar.h b/include/wx/gtk/scrolbar.h index 27941a616b..f4a50694d0 100644 --- a/include/wx/gtk/scrolbar.h +++ b/include/wx/gtk/scrolbar.h @@ -77,7 +77,9 @@ class wxScrollBar: public wxControl void SetObjectLength( int objectLength ); void SetViewLength( int viewLength ); - public: + // implementation + + bool IsOwnGtkWindow( GdkWindow *window ); GtkAdjustment *m_adjust; float m_oldPos; diff --git a/include/wx/gtk/slider.h b/include/wx/gtk/slider.h index 2915e8380f..f683919642 100644 --- a/include/wx/gtk/slider.h +++ b/include/wx/gtk/slider.h @@ -84,8 +84,10 @@ class wxSlider: public wxControl int GetThumbLength(void) const; void SetTick( int tickPos ); - public: - + // implementation + + bool IsOwnGtkWindow( GdkWindow *window ); + GtkAdjustment *m_adjust; float m_oldPos; diff --git a/include/wx/gtk/textctrl.h b/include/wx/gtk/textctrl.h index e477a54675..e4bdb022c3 100644 --- a/include/wx/gtk/textctrl.h +++ b/include/wx/gtk/textctrl.h @@ -105,8 +105,8 @@ class wxTextCtrl: public wxControl, public streambuf // implementation - virtual GtkWidget* GetConnectWidget(void); - virtual bool IsOwnGtkWindow( GdkWindow *window ); + GtkWidget* GetConnectWidget(void); + bool IsOwnGtkWindow( GdkWindow *window ); private: diff --git a/include/wx/gtk/window.h b/include/wx/gtk/window.h index a029a5dc16..ae7e532f27 100644 --- a/include/wx/gtk/window.h +++ b/include/wx/gtk/window.h @@ -236,6 +236,7 @@ public: // cannot get private going yet void PreCreation( wxWindow *parent, wxWindowID id, const wxPoint &pos, const wxSize &size, long style, const wxString &name ); void PostCreation(); + void ConnectWidget( GtkWidget *widget ); bool HasVMT(); virtual void ImplementSetSize(); virtual void ImplementSetPosition(); diff --git a/include/wx/gtk1/choice.h b/include/wx/gtk1/choice.h index 6849cec905..9929a37fef 100644 --- a/include/wx/gtk1/choice.h +++ b/include/wx/gtk1/choice.h @@ -73,6 +73,7 @@ class wxChoice: public wxControl void SetColumns( int n = 1 ); void SetSelection( int n ); void SetStringSelection( const wxString &string ); + void SetFont( const wxFont &font ); }; diff --git a/include/wx/gtk1/combobox.h b/include/wx/gtk1/combobox.h index d810577372..c7d7b7064b 100644 --- a/include/wx/gtk1/combobox.h +++ b/include/wx/gtk1/combobox.h @@ -94,6 +94,7 @@ class wxComboBox: public wxControl void SetEditable(bool editable); void SetFont( const wxFont &font ); + void OnSize( wxSizeEvent &event ); // implementation @@ -102,8 +103,11 @@ class wxComboBox: public wxControl private: wxList m_clientData; + + GtkWidget* GetConnectWidget(void); + bool IsOwnGtkWindow( GdkWindow *window ); - GtkWidget* GetConnectWidget(void); + DECLARE_EVENT_TABLE() }; #endif // __GTKCOMBOBOXH__ diff --git a/include/wx/gtk1/listbox.h b/include/wx/gtk1/listbox.h index 44f4d5aa19..1a6b810396 100644 --- a/include/wx/gtk1/listbox.h +++ b/include/wx/gtk1/listbox.h @@ -84,16 +84,16 @@ class wxListBox: public wxControl void SetStringSelection( const wxString &string, bool select = TRUE ); void SetFont( const wxFont &font ); - virtual GtkWidget *GetConnectWidget(void); - + // implementation + + int GetIndex( GtkWidget *item ) const; + GtkWidget *GetConnectWidget(void); + private: GtkList *m_list; wxList m_clientData; - public: - - int GetIndex( GtkWidget *item ) const; }; #endif // __GTKLISTBOXH__ diff --git a/include/wx/gtk1/radiobox.h b/include/wx/gtk1/radiobox.h index 3ba68d40d9..5fb8792ba2 100644 --- a/include/wx/gtk1/radiobox.h +++ b/include/wx/gtk1/radiobox.h @@ -84,6 +84,8 @@ class wxRadioBox: public wxControl // implementation + bool IsOwnGtkWindow( GdkWindow *window ); + bool m_alreadySent; private: diff --git a/include/wx/gtk1/scrolbar.h b/include/wx/gtk1/scrolbar.h index 27941a616b..f4a50694d0 100644 --- a/include/wx/gtk1/scrolbar.h +++ b/include/wx/gtk1/scrolbar.h @@ -77,7 +77,9 @@ class wxScrollBar: public wxControl void SetObjectLength( int objectLength ); void SetViewLength( int viewLength ); - public: + // implementation + + bool IsOwnGtkWindow( GdkWindow *window ); GtkAdjustment *m_adjust; float m_oldPos; diff --git a/include/wx/gtk1/slider.h b/include/wx/gtk1/slider.h index 2915e8380f..f683919642 100644 --- a/include/wx/gtk1/slider.h +++ b/include/wx/gtk1/slider.h @@ -84,8 +84,10 @@ class wxSlider: public wxControl int GetThumbLength(void) const; void SetTick( int tickPos ); - public: - + // implementation + + bool IsOwnGtkWindow( GdkWindow *window ); + GtkAdjustment *m_adjust; float m_oldPos; diff --git a/include/wx/gtk1/textctrl.h b/include/wx/gtk1/textctrl.h index e477a54675..e4bdb022c3 100644 --- a/include/wx/gtk1/textctrl.h +++ b/include/wx/gtk1/textctrl.h @@ -105,8 +105,8 @@ class wxTextCtrl: public wxControl, public streambuf // implementation - virtual GtkWidget* GetConnectWidget(void); - virtual bool IsOwnGtkWindow( GdkWindow *window ); + GtkWidget* GetConnectWidget(void); + bool IsOwnGtkWindow( GdkWindow *window ); private: diff --git a/include/wx/gtk1/window.h b/include/wx/gtk1/window.h index a029a5dc16..ae7e532f27 100644 --- a/include/wx/gtk1/window.h +++ b/include/wx/gtk1/window.h @@ -236,6 +236,7 @@ public: // cannot get private going yet void PreCreation( wxWindow *parent, wxWindowID id, const wxPoint &pos, const wxSize &size, long style, const wxString &name ); void PostCreation(); + void ConnectWidget( GtkWidget *widget ); bool HasVMT(); virtual void ImplementSetSize(); virtual void ImplementSetPosition(); diff --git a/samples/controls/controls.cpp b/samples/controls/controls.cpp index 04c892b4c3..64ef002f29 100644 --- a/samples/controls/controls.cpp +++ b/samples/controls/controls.cpp @@ -270,7 +270,7 @@ MyPanel::MyPanel( wxFrame *frame, int x, int y, int w, int h ) : m_notebook->AddPage(panel, "wxChoice", FALSE, Image_Choice); panel = new wxPanel(m_notebook); - m_combo = new wxComboBox( panel, ID_COMBO, "This", wxPoint(10,10), wxSize(170,-1), 4, choices ); + m_combo = new wxComboBox( panel, ID_COMBO, "This", wxPoint(10,10), wxSize(120,-1), 4, choices ); (void)new wxButton( panel, ID_COMBO_SEL_NUM, "Select #2", wxPoint(180,30), wxSize(140,30) ); (void)new wxButton( panel, ID_COMBO_SEL_STR, "Select 'This'", wxPoint(340,30), wxSize(140,30) ); (void)new wxButton( panel, ID_COMBO_CLEAR, "Clear", wxPoint(180,80), wxSize(140,30) ); diff --git a/src/gtk/combobox.cpp b/src/gtk/combobox.cpp index 11799f3b60..f6a53acda1 100644 --- a/src/gtk/combobox.cpp +++ b/src/gtk/combobox.cpp @@ -46,29 +46,16 @@ static void gtk_combo_clicked_callback( GtkWidget *WXUNUSED(widget), wxComboBox combo->GetEventHandler()->ProcessEvent(event); } -//----------------------------------------------------------------------------- -// size - -/* -static gint gtk_combo_size_callback( GtkCombo *widget, GtkAllocation* alloc, wxComboBox *win ) -{ - if (!win->HasVMT()) return FALSE; - if (g_blockEventsOnDrag) return FALSE; - if (!widget->button) return FALSE; - - widget->button->allocation.x = - alloc->width - widget->button->allocation.width; - - return FALSE; -} -*/ - //----------------------------------------------------------------------------- // wxComboBox //----------------------------------------------------------------------------- IMPLEMENT_DYNAMIC_CLASS(wxComboBox,wxControl) +BEGIN_EVENT_TABLE(wxComboBox, wxControl) + EVT_SIZE(wxComboBox::OnSize) +END_EVENT_TABLE() + bool wxComboBox::Create(wxWindow *parent, wxWindowID id, const wxString& value, const wxPoint& pos, const wxSize& size, int n, const wxString choices[], @@ -107,11 +94,8 @@ bool wxComboBox::Create(wxWindow *parent, wxWindowID id, const wxString& value, PostCreation(); -/* - gtk_signal_connect( GTK_OBJECT(m_widget), "size_allocate", - GTK_SIGNAL_FUNC(gtk_combo_size_callback), (gpointer)this ); -*/ - + ConnectWidget( GTK_COMBO(m_widget)->button ); + if (!value.IsNull()) SetValue( value ); Show( TRUE ); @@ -375,10 +359,24 @@ void wxComboBox::Remove(long from, long to) void wxComboBox::SetSelection( long WXUNUSED(from), long WXUNUSED(to) ) { + wxFAIL_MSG( "wxComboBox::SetSelection not implemented" ); } void wxComboBox::SetEditable( bool WXUNUSED(editable) ) { + wxFAIL_MSG( "wxComboBox::SetEditable not implemented" ); +} + +void wxComboBox::OnSize( wxSizeEvent &event ) +{ + wxControl::OnSize( event ); + + int w = 22; + + gtk_widget_set_usize( GTK_COMBO(m_widget)->entry, m_width-w-1, m_height ); + + gtk_widget_set_uposition( GTK_COMBO(m_widget)->button, m_x+m_width-w, m_y ); + gtk_widget_set_usize( GTK_COMBO(m_widget)->button, w, m_height ); } void wxComboBox::SetFont( const wxFont &font ) @@ -404,10 +402,15 @@ void wxComboBox::SetFont( const wxFont &font ) child = child->next; } } - + GtkWidget* wxComboBox::GetConnectWidget(void) { return GTK_COMBO(m_widget)->entry; } +bool wxComboBox::IsOwnGtkWindow( GdkWindow *window ) +{ + return ( (window == GTK_ENTRY( GTK_COMBO(m_widget)->entry )->text_area) || + (window == GTK_COMBO(m_widget)->button->window ) ); +} diff --git a/src/gtk/radiobox.cpp b/src/gtk/radiobox.cpp index 96e417570f..ec26307409 100644 --- a/src/gtk/radiobox.cpp +++ b/src/gtk/radiobox.cpp @@ -25,7 +25,7 @@ extern bool g_blockEventsOnDrag; //----------------------------------------------------------------------------- -// wxRadioBox +// "clicked" //----------------------------------------------------------------------------- static void gtk_radiobutton_clicked_callback( GtkWidget *WXUNUSED(widget), wxRadioBox *rb ) @@ -49,6 +49,8 @@ static void gtk_radiobutton_clicked_callback( GtkWidget *WXUNUSED(widget), wxRad rb->GetEventHandler()->ProcessEvent(event); } +//----------------------------------------------------------------------------- +// wxRadioBox //----------------------------------------------------------------------------- IMPLEMENT_DYNAMIC_CLASS(wxRadioBox,wxControl) @@ -90,6 +92,8 @@ bool wxRadioBox::Create( wxWindow *parent, wxWindowID id, const wxString& title, m_radio = GTK_RADIO_BUTTON( gtk_radio_button_new_with_label( radio_button_group, choices[i] ) ); + ConnectWidget( GTK_WIDGET(m_radio) ); + if (!i) gtk_toggle_button_set_state( GTK_TOGGLE_BUTTON(m_radio), TRUE ); gtk_signal_connect( GTK_OBJECT(m_radio), "clicked", @@ -122,8 +126,10 @@ bool wxRadioBox::Create( wxWindow *parent, wxWindowID id, const wxString& title, return TRUE; } -void wxRadioBox::OnSize( wxSizeEvent &WXUNUSED(event) ) +void wxRadioBox::OnSize( wxSizeEvent &event ) { + wxControl::OnSize( event ); + int x = m_x+5; int y = m_y+15; @@ -371,3 +377,18 @@ void wxRadioBox::SetFont( const wxFont &font ) item = item->next; } } + +bool wxRadioBox::IsOwnGtkWindow( GdkWindow *window ) +{ + if (window == m_widget->window) return TRUE; + + GSList *item = gtk_radio_button_group( m_radio ); + while (item) + { + GtkWidget *button = GTK_WIDGET( item->data ); + if (window == button->window) return TRUE; + item = item->next; + } + + return FALSE; +} diff --git a/src/gtk/scrolbar.cpp b/src/gtk/scrolbar.cpp index de1cb7a888..210b60fce7 100644 --- a/src/gtk/scrolbar.cpp +++ b/src/gtk/scrolbar.cpp @@ -23,7 +23,7 @@ extern bool g_blockEventsOnDrag; //----------------------------------------------------------------------------- -// wxScrollBar +// "value_changed" //----------------------------------------------------------------------------- static void gtk_scrollbar_callback( GtkWidget *WXUNUSED(widget), wxScrollBar *win ) @@ -61,6 +61,10 @@ static void gtk_scrollbar_callback( GtkWidget *WXUNUSED(widget), wxScrollBar *wi */ } +//----------------------------------------------------------------------------- +// wxScrollBar +//----------------------------------------------------------------------------- + IMPLEMENT_DYNAMIC_CLASS(wxScrollBar,wxControl) wxScrollBar::~wxScrollBar(void) @@ -209,3 +213,12 @@ void wxScrollBar::SetViewLength( int viewLength ) SetScrollbar( pos, thumb, viewLength, page ); } +bool wxScrollBar::IsOwnGtkWindow( GdkWindow *window ) +{ + GtkRange *range = GTK_RANGE(m_widget); + return ( (window == GTK_WIDGET(range)->window) || + (window == range->trough) || + (window == range->slider) || + (window == range->step_forw) || + (window == range->step_back) ); +} diff --git a/src/gtk/slider.cpp b/src/gtk/slider.cpp index 74449d7641..e9997178d2 100644 --- a/src/gtk/slider.cpp +++ b/src/gtk/slider.cpp @@ -238,3 +238,14 @@ void wxSlider::ClearSel(void) { } +bool wxSlider::IsOwnGtkWindow( GdkWindow *window ) +{ + GtkRange *range = GTK_RANGE(m_widget); + return ( (window == GTK_WIDGET(range)->window) || + (window == range->trough) || + (window == range->slider) || + (window == range->step_forw) || + (window == range->step_back) ); +} + + diff --git a/src/gtk/statbox.cpp b/src/gtk/statbox.cpp index abf8e8ce57..009f4a5865 100644 --- a/src/gtk/statbox.cpp +++ b/src/gtk/statbox.cpp @@ -39,11 +39,12 @@ bool wxStaticBox::Create( wxWindow *parent, wxWindowID id, const wxString &label PreCreation( parent, id, pos, size, style, name ); - SetLabel(label); m_widget = gtk_frame_new(m_label); PostCreation(); + SetLabel(label); + Show( TRUE ); return TRUE; diff --git a/src/gtk/textctrl.cpp b/src/gtk/textctrl.cpp index 7405f2df26..44c3429337 100644 --- a/src/gtk/textctrl.cpp +++ b/src/gtk/textctrl.cpp @@ -324,7 +324,6 @@ void wxTextCtrl::OnChar( wxKeyEvent &key_event ) { wxCommandEvent event(wxEVT_COMMAND_TEXT_ENTER, m_windowId); event.SetEventObject(this); - printf( "Hallo.\n" ); if (GetEventHandler()->ProcessEvent(event)) return; } else if (key_event.KeyCode() == WXK_TAB) diff --git a/src/gtk/window.cpp b/src/gtk/window.cpp index 70c53851a7..1d121ea4c0 100644 --- a/src/gtk/window.cpp +++ b/src/gtk/window.cpp @@ -28,11 +28,12 @@ #include "wx/menu.h" #include "wx/notebook.h" #include "wx/statusbr.h" -#include -#include "gdk/gdkkeysyms.h" -#include +#include "wx/intl.h" #include "wx/gtk/win_gtk.h" #include "gdk/gdkprivate.h" +#include "gdk/gdkkeysyms.h" + +#include //----------------------------------------------------------------------------- // documentation on internals @@ -591,6 +592,50 @@ static gint gtk_window_focus_out_callback( GtkWidget *widget, GdkEvent *WXUNUSED return TRUE; } +//----------------------------------------------------------------------------- +// "enter_notify_event" +//----------------------------------------------------------------------------- + +static gint gtk_window_enter_callback( GtkWidget *widget, GdkEventCrossing *gdk_event, wxWindow *win ) +{ + if (widget->window != gdk_event->window) return TRUE; + if (g_blockEventsOnDrag) return TRUE; + if (!win->HasVMT()) return TRUE; + + if (widget->window) + gdk_window_set_cursor( widget->window, win->m_cursor->GetCursor() ); + + wxMouseEvent event( wxEVT_ENTER_WINDOW ); + event.SetEventObject( win ); + + if (win->GetEventHandler()->ProcessEvent( event )) + gtk_signal_emit_stop_by_name( GTK_OBJECT(widget), "enter_notify_event" ); + + return TRUE; +} + +//----------------------------------------------------------------------------- +// "leave_notify_event" +//----------------------------------------------------------------------------- + +static gint gtk_window_leave_callback( GtkWidget *widget, GdkEventCrossing *gdk_event, wxWindow *win ) +{ + if (widget->window != gdk_event->window) return TRUE; + if (!win->HasVMT()) return TRUE; + if (g_blockEventsOnDrag) return TRUE; + + if (widget->window) + gdk_window_set_cursor( widget->window, wxSTANDARD_CURSOR->GetCursor() ); + + wxMouseEvent event( wxEVT_LEAVE_WINDOW ); + event.SetEventObject( win ); + + if (win->GetEventHandler()->ProcessEvent( event )) + gtk_signal_emit_stop_by_name( GTK_OBJECT(widget), "leave_notify_event" ); + + return TRUE; +} + //----------------------------------------------------------------------------- // "value_changed" from m_vAdjust //----------------------------------------------------------------------------- @@ -739,42 +784,6 @@ static void gtk_window_drop_callback( GtkWidget *widget, GdkEvent *event, wxWind */ } -//----------------------------------------------------------------------------- -// "enter_notify_event" -//----------------------------------------------------------------------------- - -static gint gtk_window_enter_callback( GtkWidget *widget, GdkEventCrossing *gdk_event, wxWindow *win ) -{ - if (widget->window != gdk_event->window) return TRUE; - if (g_blockEventsOnDrag) return TRUE; - if (!win->HasVMT()) return TRUE; - - if (widget->window) - gdk_window_set_cursor( widget->window, win->m_cursor->GetCursor() ); - - wxMouseEvent event( wxEVT_ENTER_WINDOW ); - event.SetEventObject( win ); - return win->GetEventHandler()->ProcessEvent( event ); -} - -//----------------------------------------------------------------------------- -// "leave_notify_event" -//----------------------------------------------------------------------------- - -static gint gtk_window_leave_callback( GtkWidget *widget, GdkEventCrossing *gdk_event, wxWindow *win ) -{ - if (widget->window != gdk_event->window) return TRUE; - if (!win->HasVMT()) return TRUE; - if (g_blockEventsOnDrag) return TRUE; - - if (widget->window) - gdk_window_set_cursor( widget->window, wxSTANDARD_CURSOR->GetCursor() ); - - wxMouseEvent event( wxEVT_LEAVE_WINDOW ); - event.SetEventObject( win ); - return win->GetEventHandler()->ProcessEvent( event ); -} - //----------------------------------------------------------------------------- // wxWindow //----------------------------------------------------------------------------- @@ -1019,11 +1028,6 @@ void wxWindow::PostCreation(void) { if (m_parent) m_parent->AddChild( this ); -// GtkStyle *style = m_widget->style; -// style->font = m_font.GetInternalFont( 1.0 ); // destroy old font ? - - GtkWidget *connect_widget = GetConnectWidget(); - if (m_wxwindow) { gtk_signal_connect( GTK_OBJECT(m_wxwindow), "expose_event", @@ -1033,52 +1037,46 @@ void wxWindow::PostCreation(void) GTK_SIGNAL_FUNC(gtk_window_draw_callback), (gpointer)this ); } - gtk_signal_connect( GTK_OBJECT(connect_widget), "key_press_event", + ConnectWidget( GetConnectWidget() ); + + if (m_widget && m_parent) gtk_widget_realize( m_widget ); + + if (m_wxwindow) + { + gtk_widget_realize( m_wxwindow ); + gdk_gc_set_exposures( m_wxwindow->style->fg_gc[0], TRUE ); + } + + SetCursor( wxSTANDARD_CURSOR ); + + m_hasVMT = TRUE; +} + +void wxWindow::ConnectWidget( GtkWidget *widget ) +{ + gtk_signal_connect( GTK_OBJECT(widget), "key_press_event", GTK_SIGNAL_FUNC(gtk_window_key_press_callback), (gpointer)this ); - gtk_signal_connect( GTK_OBJECT(connect_widget), "button_press_event", + gtk_signal_connect( GTK_OBJECT(widget), "button_press_event", GTK_SIGNAL_FUNC(gtk_window_button_press_callback), (gpointer)this ); - gtk_signal_connect( GTK_OBJECT(connect_widget), "button_release_event", + gtk_signal_connect( GTK_OBJECT(widget), "button_release_event", GTK_SIGNAL_FUNC(gtk_window_button_release_callback), (gpointer)this ); - gtk_signal_connect( GTK_OBJECT(connect_widget), "motion_notify_event", + gtk_signal_connect( GTK_OBJECT(widget), "motion_notify_event", GTK_SIGNAL_FUNC(gtk_window_motion_notify_callback), (gpointer)this ); - gtk_signal_connect( GTK_OBJECT(connect_widget), "focus_in_event", + gtk_signal_connect( GTK_OBJECT(widget), "focus_in_event", GTK_SIGNAL_FUNC(gtk_window_focus_in_callback), (gpointer)this ); - gtk_signal_connect( GTK_OBJECT(connect_widget), "focus_out_event", + gtk_signal_connect( GTK_OBJECT(widget), "focus_out_event", GTK_SIGNAL_FUNC(gtk_window_focus_out_callback), (gpointer)this ); - // Only for cursor handling - - gtk_signal_connect( GTK_OBJECT(m_widget), "enter_notify_event", + gtk_signal_connect( GTK_OBJECT(widget), "enter_notify_event", GTK_SIGNAL_FUNC(gtk_window_enter_callback), (gpointer)this ); - gtk_signal_connect( GTK_OBJECT(m_widget), "leave_notify_event", + gtk_signal_connect( GTK_OBJECT(widget), "leave_notify_event", GTK_SIGNAL_FUNC(gtk_window_leave_callback), (gpointer)this ); - - if (m_wxwindow) - { - gtk_signal_connect( GTK_OBJECT(m_wxwindow), "enter_notify_event", - GTK_SIGNAL_FUNC(gtk_window_enter_callback), (gpointer)this ); - - gtk_signal_connect( GTK_OBJECT(m_wxwindow), "leave_notify_event", - GTK_SIGNAL_FUNC(gtk_window_leave_callback), (gpointer)this ); - } - - if (m_widget && m_parent) gtk_widget_realize( m_widget ); - - if (m_wxwindow) - { - gtk_widget_realize( m_wxwindow ); - gdk_gc_set_exposures( m_wxwindow->style->fg_gc[0], TRUE ); - } - - SetCursor( wxSTANDARD_CURSOR ); - - m_hasVMT = TRUE; } bool wxWindow::HasVMT(void) diff --git a/src/gtk1/combobox.cpp b/src/gtk1/combobox.cpp index 11799f3b60..f6a53acda1 100644 --- a/src/gtk1/combobox.cpp +++ b/src/gtk1/combobox.cpp @@ -46,29 +46,16 @@ static void gtk_combo_clicked_callback( GtkWidget *WXUNUSED(widget), wxComboBox combo->GetEventHandler()->ProcessEvent(event); } -//----------------------------------------------------------------------------- -// size - -/* -static gint gtk_combo_size_callback( GtkCombo *widget, GtkAllocation* alloc, wxComboBox *win ) -{ - if (!win->HasVMT()) return FALSE; - if (g_blockEventsOnDrag) return FALSE; - if (!widget->button) return FALSE; - - widget->button->allocation.x = - alloc->width - widget->button->allocation.width; - - return FALSE; -} -*/ - //----------------------------------------------------------------------------- // wxComboBox //----------------------------------------------------------------------------- IMPLEMENT_DYNAMIC_CLASS(wxComboBox,wxControl) +BEGIN_EVENT_TABLE(wxComboBox, wxControl) + EVT_SIZE(wxComboBox::OnSize) +END_EVENT_TABLE() + bool wxComboBox::Create(wxWindow *parent, wxWindowID id, const wxString& value, const wxPoint& pos, const wxSize& size, int n, const wxString choices[], @@ -107,11 +94,8 @@ bool wxComboBox::Create(wxWindow *parent, wxWindowID id, const wxString& value, PostCreation(); -/* - gtk_signal_connect( GTK_OBJECT(m_widget), "size_allocate", - GTK_SIGNAL_FUNC(gtk_combo_size_callback), (gpointer)this ); -*/ - + ConnectWidget( GTK_COMBO(m_widget)->button ); + if (!value.IsNull()) SetValue( value ); Show( TRUE ); @@ -375,10 +359,24 @@ void wxComboBox::Remove(long from, long to) void wxComboBox::SetSelection( long WXUNUSED(from), long WXUNUSED(to) ) { + wxFAIL_MSG( "wxComboBox::SetSelection not implemented" ); } void wxComboBox::SetEditable( bool WXUNUSED(editable) ) { + wxFAIL_MSG( "wxComboBox::SetEditable not implemented" ); +} + +void wxComboBox::OnSize( wxSizeEvent &event ) +{ + wxControl::OnSize( event ); + + int w = 22; + + gtk_widget_set_usize( GTK_COMBO(m_widget)->entry, m_width-w-1, m_height ); + + gtk_widget_set_uposition( GTK_COMBO(m_widget)->button, m_x+m_width-w, m_y ); + gtk_widget_set_usize( GTK_COMBO(m_widget)->button, w, m_height ); } void wxComboBox::SetFont( const wxFont &font ) @@ -404,10 +402,15 @@ void wxComboBox::SetFont( const wxFont &font ) child = child->next; } } - + GtkWidget* wxComboBox::GetConnectWidget(void) { return GTK_COMBO(m_widget)->entry; } +bool wxComboBox::IsOwnGtkWindow( GdkWindow *window ) +{ + return ( (window == GTK_ENTRY( GTK_COMBO(m_widget)->entry )->text_area) || + (window == GTK_COMBO(m_widget)->button->window ) ); +} diff --git a/src/gtk1/radiobox.cpp b/src/gtk1/radiobox.cpp index 96e417570f..ec26307409 100644 --- a/src/gtk1/radiobox.cpp +++ b/src/gtk1/radiobox.cpp @@ -25,7 +25,7 @@ extern bool g_blockEventsOnDrag; //----------------------------------------------------------------------------- -// wxRadioBox +// "clicked" //----------------------------------------------------------------------------- static void gtk_radiobutton_clicked_callback( GtkWidget *WXUNUSED(widget), wxRadioBox *rb ) @@ -49,6 +49,8 @@ static void gtk_radiobutton_clicked_callback( GtkWidget *WXUNUSED(widget), wxRad rb->GetEventHandler()->ProcessEvent(event); } +//----------------------------------------------------------------------------- +// wxRadioBox //----------------------------------------------------------------------------- IMPLEMENT_DYNAMIC_CLASS(wxRadioBox,wxControl) @@ -90,6 +92,8 @@ bool wxRadioBox::Create( wxWindow *parent, wxWindowID id, const wxString& title, m_radio = GTK_RADIO_BUTTON( gtk_radio_button_new_with_label( radio_button_group, choices[i] ) ); + ConnectWidget( GTK_WIDGET(m_radio) ); + if (!i) gtk_toggle_button_set_state( GTK_TOGGLE_BUTTON(m_radio), TRUE ); gtk_signal_connect( GTK_OBJECT(m_radio), "clicked", @@ -122,8 +126,10 @@ bool wxRadioBox::Create( wxWindow *parent, wxWindowID id, const wxString& title, return TRUE; } -void wxRadioBox::OnSize( wxSizeEvent &WXUNUSED(event) ) +void wxRadioBox::OnSize( wxSizeEvent &event ) { + wxControl::OnSize( event ); + int x = m_x+5; int y = m_y+15; @@ -371,3 +377,18 @@ void wxRadioBox::SetFont( const wxFont &font ) item = item->next; } } + +bool wxRadioBox::IsOwnGtkWindow( GdkWindow *window ) +{ + if (window == m_widget->window) return TRUE; + + GSList *item = gtk_radio_button_group( m_radio ); + while (item) + { + GtkWidget *button = GTK_WIDGET( item->data ); + if (window == button->window) return TRUE; + item = item->next; + } + + return FALSE; +} diff --git a/src/gtk1/scrolbar.cpp b/src/gtk1/scrolbar.cpp index de1cb7a888..210b60fce7 100644 --- a/src/gtk1/scrolbar.cpp +++ b/src/gtk1/scrolbar.cpp @@ -23,7 +23,7 @@ extern bool g_blockEventsOnDrag; //----------------------------------------------------------------------------- -// wxScrollBar +// "value_changed" //----------------------------------------------------------------------------- static void gtk_scrollbar_callback( GtkWidget *WXUNUSED(widget), wxScrollBar *win ) @@ -61,6 +61,10 @@ static void gtk_scrollbar_callback( GtkWidget *WXUNUSED(widget), wxScrollBar *wi */ } +//----------------------------------------------------------------------------- +// wxScrollBar +//----------------------------------------------------------------------------- + IMPLEMENT_DYNAMIC_CLASS(wxScrollBar,wxControl) wxScrollBar::~wxScrollBar(void) @@ -209,3 +213,12 @@ void wxScrollBar::SetViewLength( int viewLength ) SetScrollbar( pos, thumb, viewLength, page ); } +bool wxScrollBar::IsOwnGtkWindow( GdkWindow *window ) +{ + GtkRange *range = GTK_RANGE(m_widget); + return ( (window == GTK_WIDGET(range)->window) || + (window == range->trough) || + (window == range->slider) || + (window == range->step_forw) || + (window == range->step_back) ); +} diff --git a/src/gtk1/slider.cpp b/src/gtk1/slider.cpp index 74449d7641..e9997178d2 100644 --- a/src/gtk1/slider.cpp +++ b/src/gtk1/slider.cpp @@ -238,3 +238,14 @@ void wxSlider::ClearSel(void) { } +bool wxSlider::IsOwnGtkWindow( GdkWindow *window ) +{ + GtkRange *range = GTK_RANGE(m_widget); + return ( (window == GTK_WIDGET(range)->window) || + (window == range->trough) || + (window == range->slider) || + (window == range->step_forw) || + (window == range->step_back) ); +} + + diff --git a/src/gtk1/statbox.cpp b/src/gtk1/statbox.cpp index abf8e8ce57..009f4a5865 100644 --- a/src/gtk1/statbox.cpp +++ b/src/gtk1/statbox.cpp @@ -39,11 +39,12 @@ bool wxStaticBox::Create( wxWindow *parent, wxWindowID id, const wxString &label PreCreation( parent, id, pos, size, style, name ); - SetLabel(label); m_widget = gtk_frame_new(m_label); PostCreation(); + SetLabel(label); + Show( TRUE ); return TRUE; diff --git a/src/gtk1/textctrl.cpp b/src/gtk1/textctrl.cpp index 7405f2df26..44c3429337 100644 --- a/src/gtk1/textctrl.cpp +++ b/src/gtk1/textctrl.cpp @@ -324,7 +324,6 @@ void wxTextCtrl::OnChar( wxKeyEvent &key_event ) { wxCommandEvent event(wxEVT_COMMAND_TEXT_ENTER, m_windowId); event.SetEventObject(this); - printf( "Hallo.\n" ); if (GetEventHandler()->ProcessEvent(event)) return; } else if (key_event.KeyCode() == WXK_TAB) diff --git a/src/gtk1/window.cpp b/src/gtk1/window.cpp index 70c53851a7..1d121ea4c0 100644 --- a/src/gtk1/window.cpp +++ b/src/gtk1/window.cpp @@ -28,11 +28,12 @@ #include "wx/menu.h" #include "wx/notebook.h" #include "wx/statusbr.h" -#include -#include "gdk/gdkkeysyms.h" -#include +#include "wx/intl.h" #include "wx/gtk/win_gtk.h" #include "gdk/gdkprivate.h" +#include "gdk/gdkkeysyms.h" + +#include //----------------------------------------------------------------------------- // documentation on internals @@ -591,6 +592,50 @@ static gint gtk_window_focus_out_callback( GtkWidget *widget, GdkEvent *WXUNUSED return TRUE; } +//----------------------------------------------------------------------------- +// "enter_notify_event" +//----------------------------------------------------------------------------- + +static gint gtk_window_enter_callback( GtkWidget *widget, GdkEventCrossing *gdk_event, wxWindow *win ) +{ + if (widget->window != gdk_event->window) return TRUE; + if (g_blockEventsOnDrag) return TRUE; + if (!win->HasVMT()) return TRUE; + + if (widget->window) + gdk_window_set_cursor( widget->window, win->m_cursor->GetCursor() ); + + wxMouseEvent event( wxEVT_ENTER_WINDOW ); + event.SetEventObject( win ); + + if (win->GetEventHandler()->ProcessEvent( event )) + gtk_signal_emit_stop_by_name( GTK_OBJECT(widget), "enter_notify_event" ); + + return TRUE; +} + +//----------------------------------------------------------------------------- +// "leave_notify_event" +//----------------------------------------------------------------------------- + +static gint gtk_window_leave_callback( GtkWidget *widget, GdkEventCrossing *gdk_event, wxWindow *win ) +{ + if (widget->window != gdk_event->window) return TRUE; + if (!win->HasVMT()) return TRUE; + if (g_blockEventsOnDrag) return TRUE; + + if (widget->window) + gdk_window_set_cursor( widget->window, wxSTANDARD_CURSOR->GetCursor() ); + + wxMouseEvent event( wxEVT_LEAVE_WINDOW ); + event.SetEventObject( win ); + + if (win->GetEventHandler()->ProcessEvent( event )) + gtk_signal_emit_stop_by_name( GTK_OBJECT(widget), "leave_notify_event" ); + + return TRUE; +} + //----------------------------------------------------------------------------- // "value_changed" from m_vAdjust //----------------------------------------------------------------------------- @@ -739,42 +784,6 @@ static void gtk_window_drop_callback( GtkWidget *widget, GdkEvent *event, wxWind */ } -//----------------------------------------------------------------------------- -// "enter_notify_event" -//----------------------------------------------------------------------------- - -static gint gtk_window_enter_callback( GtkWidget *widget, GdkEventCrossing *gdk_event, wxWindow *win ) -{ - if (widget->window != gdk_event->window) return TRUE; - if (g_blockEventsOnDrag) return TRUE; - if (!win->HasVMT()) return TRUE; - - if (widget->window) - gdk_window_set_cursor( widget->window, win->m_cursor->GetCursor() ); - - wxMouseEvent event( wxEVT_ENTER_WINDOW ); - event.SetEventObject( win ); - return win->GetEventHandler()->ProcessEvent( event ); -} - -//----------------------------------------------------------------------------- -// "leave_notify_event" -//----------------------------------------------------------------------------- - -static gint gtk_window_leave_callback( GtkWidget *widget, GdkEventCrossing *gdk_event, wxWindow *win ) -{ - if (widget->window != gdk_event->window) return TRUE; - if (!win->HasVMT()) return TRUE; - if (g_blockEventsOnDrag) return TRUE; - - if (widget->window) - gdk_window_set_cursor( widget->window, wxSTANDARD_CURSOR->GetCursor() ); - - wxMouseEvent event( wxEVT_LEAVE_WINDOW ); - event.SetEventObject( win ); - return win->GetEventHandler()->ProcessEvent( event ); -} - //----------------------------------------------------------------------------- // wxWindow //----------------------------------------------------------------------------- @@ -1019,11 +1028,6 @@ void wxWindow::PostCreation(void) { if (m_parent) m_parent->AddChild( this ); -// GtkStyle *style = m_widget->style; -// style->font = m_font.GetInternalFont( 1.0 ); // destroy old font ? - - GtkWidget *connect_widget = GetConnectWidget(); - if (m_wxwindow) { gtk_signal_connect( GTK_OBJECT(m_wxwindow), "expose_event", @@ -1033,52 +1037,46 @@ void wxWindow::PostCreation(void) GTK_SIGNAL_FUNC(gtk_window_draw_callback), (gpointer)this ); } - gtk_signal_connect( GTK_OBJECT(connect_widget), "key_press_event", + ConnectWidget( GetConnectWidget() ); + + if (m_widget && m_parent) gtk_widget_realize( m_widget ); + + if (m_wxwindow) + { + gtk_widget_realize( m_wxwindow ); + gdk_gc_set_exposures( m_wxwindow->style->fg_gc[0], TRUE ); + } + + SetCursor( wxSTANDARD_CURSOR ); + + m_hasVMT = TRUE; +} + +void wxWindow::ConnectWidget( GtkWidget *widget ) +{ + gtk_signal_connect( GTK_OBJECT(widget), "key_press_event", GTK_SIGNAL_FUNC(gtk_window_key_press_callback), (gpointer)this ); - gtk_signal_connect( GTK_OBJECT(connect_widget), "button_press_event", + gtk_signal_connect( GTK_OBJECT(widget), "button_press_event", GTK_SIGNAL_FUNC(gtk_window_button_press_callback), (gpointer)this ); - gtk_signal_connect( GTK_OBJECT(connect_widget), "button_release_event", + gtk_signal_connect( GTK_OBJECT(widget), "button_release_event", GTK_SIGNAL_FUNC(gtk_window_button_release_callback), (gpointer)this ); - gtk_signal_connect( GTK_OBJECT(connect_widget), "motion_notify_event", + gtk_signal_connect( GTK_OBJECT(widget), "motion_notify_event", GTK_SIGNAL_FUNC(gtk_window_motion_notify_callback), (gpointer)this ); - gtk_signal_connect( GTK_OBJECT(connect_widget), "focus_in_event", + gtk_signal_connect( GTK_OBJECT(widget), "focus_in_event", GTK_SIGNAL_FUNC(gtk_window_focus_in_callback), (gpointer)this ); - gtk_signal_connect( GTK_OBJECT(connect_widget), "focus_out_event", + gtk_signal_connect( GTK_OBJECT(widget), "focus_out_event", GTK_SIGNAL_FUNC(gtk_window_focus_out_callback), (gpointer)this ); - // Only for cursor handling - - gtk_signal_connect( GTK_OBJECT(m_widget), "enter_notify_event", + gtk_signal_connect( GTK_OBJECT(widget), "enter_notify_event", GTK_SIGNAL_FUNC(gtk_window_enter_callback), (gpointer)this ); - gtk_signal_connect( GTK_OBJECT(m_widget), "leave_notify_event", + gtk_signal_connect( GTK_OBJECT(widget), "leave_notify_event", GTK_SIGNAL_FUNC(gtk_window_leave_callback), (gpointer)this ); - - if (m_wxwindow) - { - gtk_signal_connect( GTK_OBJECT(m_wxwindow), "enter_notify_event", - GTK_SIGNAL_FUNC(gtk_window_enter_callback), (gpointer)this ); - - gtk_signal_connect( GTK_OBJECT(m_wxwindow), "leave_notify_event", - GTK_SIGNAL_FUNC(gtk_window_leave_callback), (gpointer)this ); - } - - if (m_widget && m_parent) gtk_widget_realize( m_widget ); - - if (m_wxwindow) - { - gtk_widget_realize( m_wxwindow ); - gdk_gc_set_exposures( m_wxwindow->style->fg_gc[0], TRUE ); - } - - SetCursor( wxSTANDARD_CURSOR ); - - m_hasVMT = TRUE; } bool wxWindow::HasVMT(void) -- 2.45.2