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
This commit is contained in:
Robert Roebling 1998-09-07 12:29:07 +00:00
parent a6d7030871
commit b4071e913e
31 changed files with 351 additions and 235 deletions

View File

@ -73,6 +73,7 @@ class wxChoice: public wxControl
void SetColumns( int n = 1 ); void SetColumns( int n = 1 );
void SetSelection( int n ); void SetSelection( int n );
void SetStringSelection( const wxString &string ); void SetStringSelection( const wxString &string );
void SetFont( const wxFont &font ); void SetFont( const wxFont &font );
}; };

View File

@ -94,6 +94,7 @@ class wxComboBox: public wxControl
void SetEditable(bool editable); void SetEditable(bool editable);
void SetFont( const wxFont &font ); void SetFont( const wxFont &font );
void OnSize( wxSizeEvent &event );
// implementation // implementation
@ -102,8 +103,11 @@ class wxComboBox: public wxControl
private: private:
wxList m_clientData; wxList m_clientData;
GtkWidget* GetConnectWidget(void);
bool IsOwnGtkWindow( GdkWindow *window );
GtkWidget* GetConnectWidget(void); DECLARE_EVENT_TABLE()
}; };
#endif // __GTKCOMBOBOXH__ #endif // __GTKCOMBOBOXH__

View File

@ -84,16 +84,16 @@ class wxListBox: public wxControl
void SetStringSelection( const wxString &string, bool select = TRUE ); void SetStringSelection( const wxString &string, bool select = TRUE );
void SetFont( const wxFont &font ); void SetFont( const wxFont &font );
virtual GtkWidget *GetConnectWidget(void); // implementation
int GetIndex( GtkWidget *item ) const;
GtkWidget *GetConnectWidget(void);
private: private:
GtkList *m_list; GtkList *m_list;
wxList m_clientData; wxList m_clientData;
public:
int GetIndex( GtkWidget *item ) const;
}; };
#endif // __GTKLISTBOXH__ #endif // __GTKLISTBOXH__

View File

@ -84,6 +84,8 @@ class wxRadioBox: public wxControl
// implementation // implementation
bool IsOwnGtkWindow( GdkWindow *window );
bool m_alreadySent; bool m_alreadySent;
private: private:

View File

@ -77,7 +77,9 @@ class wxScrollBar: public wxControl
void SetObjectLength( int objectLength ); void SetObjectLength( int objectLength );
void SetViewLength( int viewLength ); void SetViewLength( int viewLength );
public: // implementation
bool IsOwnGtkWindow( GdkWindow *window );
GtkAdjustment *m_adjust; GtkAdjustment *m_adjust;
float m_oldPos; float m_oldPos;

View File

@ -84,8 +84,10 @@ class wxSlider: public wxControl
int GetThumbLength(void) const; int GetThumbLength(void) const;
void SetTick( int tickPos ); void SetTick( int tickPos );
public: // implementation
bool IsOwnGtkWindow( GdkWindow *window );
GtkAdjustment *m_adjust; GtkAdjustment *m_adjust;
float m_oldPos; float m_oldPos;

View File

@ -105,8 +105,8 @@ class wxTextCtrl: public wxControl, public streambuf
// implementation // implementation
virtual GtkWidget* GetConnectWidget(void); GtkWidget* GetConnectWidget(void);
virtual bool IsOwnGtkWindow( GdkWindow *window ); bool IsOwnGtkWindow( GdkWindow *window );
private: private:

View File

@ -236,6 +236,7 @@ public: // cannot get private going yet
void PreCreation( wxWindow *parent, wxWindowID id, const wxPoint &pos, void PreCreation( wxWindow *parent, wxWindowID id, const wxPoint &pos,
const wxSize &size, long style, const wxString &name ); const wxSize &size, long style, const wxString &name );
void PostCreation(); void PostCreation();
void ConnectWidget( GtkWidget *widget );
bool HasVMT(); bool HasVMT();
virtual void ImplementSetSize(); virtual void ImplementSetSize();
virtual void ImplementSetPosition(); virtual void ImplementSetPosition();

View File

@ -73,6 +73,7 @@ class wxChoice: public wxControl
void SetColumns( int n = 1 ); void SetColumns( int n = 1 );
void SetSelection( int n ); void SetSelection( int n );
void SetStringSelection( const wxString &string ); void SetStringSelection( const wxString &string );
void SetFont( const wxFont &font ); void SetFont( const wxFont &font );
}; };

View File

@ -94,6 +94,7 @@ class wxComboBox: public wxControl
void SetEditable(bool editable); void SetEditable(bool editable);
void SetFont( const wxFont &font ); void SetFont( const wxFont &font );
void OnSize( wxSizeEvent &event );
// implementation // implementation
@ -102,8 +103,11 @@ class wxComboBox: public wxControl
private: private:
wxList m_clientData; wxList m_clientData;
GtkWidget* GetConnectWidget(void);
bool IsOwnGtkWindow( GdkWindow *window );
GtkWidget* GetConnectWidget(void); DECLARE_EVENT_TABLE()
}; };
#endif // __GTKCOMBOBOXH__ #endif // __GTKCOMBOBOXH__

View File

@ -84,16 +84,16 @@ class wxListBox: public wxControl
void SetStringSelection( const wxString &string, bool select = TRUE ); void SetStringSelection( const wxString &string, bool select = TRUE );
void SetFont( const wxFont &font ); void SetFont( const wxFont &font );
virtual GtkWidget *GetConnectWidget(void); // implementation
int GetIndex( GtkWidget *item ) const;
GtkWidget *GetConnectWidget(void);
private: private:
GtkList *m_list; GtkList *m_list;
wxList m_clientData; wxList m_clientData;
public:
int GetIndex( GtkWidget *item ) const;
}; };
#endif // __GTKLISTBOXH__ #endif // __GTKLISTBOXH__

View File

@ -84,6 +84,8 @@ class wxRadioBox: public wxControl
// implementation // implementation
bool IsOwnGtkWindow( GdkWindow *window );
bool m_alreadySent; bool m_alreadySent;
private: private:

View File

@ -77,7 +77,9 @@ class wxScrollBar: public wxControl
void SetObjectLength( int objectLength ); void SetObjectLength( int objectLength );
void SetViewLength( int viewLength ); void SetViewLength( int viewLength );
public: // implementation
bool IsOwnGtkWindow( GdkWindow *window );
GtkAdjustment *m_adjust; GtkAdjustment *m_adjust;
float m_oldPos; float m_oldPos;

View File

@ -84,8 +84,10 @@ class wxSlider: public wxControl
int GetThumbLength(void) const; int GetThumbLength(void) const;
void SetTick( int tickPos ); void SetTick( int tickPos );
public: // implementation
bool IsOwnGtkWindow( GdkWindow *window );
GtkAdjustment *m_adjust; GtkAdjustment *m_adjust;
float m_oldPos; float m_oldPos;

View File

@ -105,8 +105,8 @@ class wxTextCtrl: public wxControl, public streambuf
// implementation // implementation
virtual GtkWidget* GetConnectWidget(void); GtkWidget* GetConnectWidget(void);
virtual bool IsOwnGtkWindow( GdkWindow *window ); bool IsOwnGtkWindow( GdkWindow *window );
private: private:

View File

@ -236,6 +236,7 @@ public: // cannot get private going yet
void PreCreation( wxWindow *parent, wxWindowID id, const wxPoint &pos, void PreCreation( wxWindow *parent, wxWindowID id, const wxPoint &pos,
const wxSize &size, long style, const wxString &name ); const wxSize &size, long style, const wxString &name );
void PostCreation(); void PostCreation();
void ConnectWidget( GtkWidget *widget );
bool HasVMT(); bool HasVMT();
virtual void ImplementSetSize(); virtual void ImplementSetSize();
virtual void ImplementSetPosition(); virtual void ImplementSetPosition();

View File

@ -270,7 +270,7 @@ MyPanel::MyPanel( wxFrame *frame, int x, int y, int w, int h ) :
m_notebook->AddPage(panel, "wxChoice", FALSE, Image_Choice); m_notebook->AddPage(panel, "wxChoice", FALSE, Image_Choice);
panel = new wxPanel(m_notebook); 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_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_SEL_STR, "Select 'This'", wxPoint(340,30), wxSize(140,30) );
(void)new wxButton( panel, ID_COMBO_CLEAR, "Clear", wxPoint(180,80), wxSize(140,30) ); (void)new wxButton( panel, ID_COMBO_CLEAR, "Clear", wxPoint(180,80), wxSize(140,30) );

View File

@ -46,29 +46,16 @@ static void gtk_combo_clicked_callback( GtkWidget *WXUNUSED(widget), wxComboBox
combo->GetEventHandler()->ProcessEvent(event); 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 // wxComboBox
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
IMPLEMENT_DYNAMIC_CLASS(wxComboBox,wxControl) 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, bool wxComboBox::Create(wxWindow *parent, wxWindowID id, const wxString& value,
const wxPoint& pos, const wxSize& size, const wxPoint& pos, const wxSize& size,
int n, const wxString choices[], int n, const wxString choices[],
@ -107,11 +94,8 @@ bool wxComboBox::Create(wxWindow *parent, wxWindowID id, const wxString& value,
PostCreation(); PostCreation();
/* ConnectWidget( GTK_COMBO(m_widget)->button );
gtk_signal_connect( GTK_OBJECT(m_widget), "size_allocate",
GTK_SIGNAL_FUNC(gtk_combo_size_callback), (gpointer)this );
*/
if (!value.IsNull()) SetValue( value ); if (!value.IsNull()) SetValue( value );
Show( TRUE ); Show( TRUE );
@ -375,10 +359,24 @@ void wxComboBox::Remove(long from, long to)
void wxComboBox::SetSelection( long WXUNUSED(from), long WXUNUSED(to) ) void wxComboBox::SetSelection( long WXUNUSED(from), long WXUNUSED(to) )
{ {
wxFAIL_MSG( "wxComboBox::SetSelection not implemented" );
} }
void wxComboBox::SetEditable( bool WXUNUSED(editable) ) 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 ) void wxComboBox::SetFont( const wxFont &font )
@ -404,10 +402,15 @@ void wxComboBox::SetFont( const wxFont &font )
child = child->next; child = child->next;
} }
} }
GtkWidget* wxComboBox::GetConnectWidget(void) GtkWidget* wxComboBox::GetConnectWidget(void)
{ {
return GTK_COMBO(m_widget)->entry; 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 ) );
}

View File

@ -25,7 +25,7 @@
extern bool g_blockEventsOnDrag; extern bool g_blockEventsOnDrag;
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// wxRadioBox // "clicked"
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
static void gtk_radiobutton_clicked_callback( GtkWidget *WXUNUSED(widget), wxRadioBox *rb ) 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); rb->GetEventHandler()->ProcessEvent(event);
} }
//-----------------------------------------------------------------------------
// wxRadioBox
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
IMPLEMENT_DYNAMIC_CLASS(wxRadioBox,wxControl) 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] ) ); 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 ); if (!i) gtk_toggle_button_set_state( GTK_TOGGLE_BUTTON(m_radio), TRUE );
gtk_signal_connect( GTK_OBJECT(m_radio), "clicked", gtk_signal_connect( GTK_OBJECT(m_radio), "clicked",
@ -122,8 +126,10 @@ bool wxRadioBox::Create( wxWindow *parent, wxWindowID id, const wxString& title,
return TRUE; return TRUE;
} }
void wxRadioBox::OnSize( wxSizeEvent &WXUNUSED(event) ) void wxRadioBox::OnSize( wxSizeEvent &event )
{ {
wxControl::OnSize( event );
int x = m_x+5; int x = m_x+5;
int y = m_y+15; int y = m_y+15;
@ -371,3 +377,18 @@ void wxRadioBox::SetFont( const wxFont &font )
item = item->next; 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;
}

View File

@ -23,7 +23,7 @@
extern bool g_blockEventsOnDrag; extern bool g_blockEventsOnDrag;
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// wxScrollBar // "value_changed"
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
static void gtk_scrollbar_callback( GtkWidget *WXUNUSED(widget), wxScrollBar *win ) 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) IMPLEMENT_DYNAMIC_CLASS(wxScrollBar,wxControl)
wxScrollBar::~wxScrollBar(void) wxScrollBar::~wxScrollBar(void)
@ -209,3 +213,12 @@ void wxScrollBar::SetViewLength( int viewLength )
SetScrollbar( pos, thumb, viewLength, page ); 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) );
}

View File

@ -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) );
}

View File

@ -39,11 +39,12 @@ bool wxStaticBox::Create( wxWindow *parent, wxWindowID id, const wxString &label
PreCreation( parent, id, pos, size, style, name ); PreCreation( parent, id, pos, size, style, name );
SetLabel(label);
m_widget = gtk_frame_new(m_label); m_widget = gtk_frame_new(m_label);
PostCreation(); PostCreation();
SetLabel(label);
Show( TRUE ); Show( TRUE );
return TRUE; return TRUE;

View File

@ -324,7 +324,6 @@ void wxTextCtrl::OnChar( wxKeyEvent &key_event )
{ {
wxCommandEvent event(wxEVT_COMMAND_TEXT_ENTER, m_windowId); wxCommandEvent event(wxEVT_COMMAND_TEXT_ENTER, m_windowId);
event.SetEventObject(this); event.SetEventObject(this);
printf( "Hallo.\n" );
if (GetEventHandler()->ProcessEvent(event)) return; if (GetEventHandler()->ProcessEvent(event)) return;
} }
else if (key_event.KeyCode() == WXK_TAB) else if (key_event.KeyCode() == WXK_TAB)

View File

@ -28,11 +28,12 @@
#include "wx/menu.h" #include "wx/menu.h"
#include "wx/notebook.h" #include "wx/notebook.h"
#include "wx/statusbr.h" #include "wx/statusbr.h"
#include <wx/intl.h> #include "wx/intl.h"
#include "gdk/gdkkeysyms.h"
#include <math.h>
#include "wx/gtk/win_gtk.h" #include "wx/gtk/win_gtk.h"
#include "gdk/gdkprivate.h" #include "gdk/gdkprivate.h"
#include "gdk/gdkkeysyms.h"
#include <math.h>
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// documentation on internals // documentation on internals
@ -591,6 +592,50 @@ static gint gtk_window_focus_out_callback( GtkWidget *widget, GdkEvent *WXUNUSED
return TRUE; 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 // "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 // wxWindow
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
@ -1019,11 +1028,6 @@ void wxWindow::PostCreation(void)
{ {
if (m_parent) m_parent->AddChild( this ); 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) if (m_wxwindow)
{ {
gtk_signal_connect( GTK_OBJECT(m_wxwindow), "expose_event", gtk_signal_connect( GTK_OBJECT(m_wxwindow), "expose_event",
@ -1033,40 +1037,7 @@ void wxWindow::PostCreation(void)
GTK_SIGNAL_FUNC(gtk_window_draw_callback), (gpointer)this ); GTK_SIGNAL_FUNC(gtk_window_draw_callback), (gpointer)this );
} }
gtk_signal_connect( GTK_OBJECT(connect_widget), "key_press_event", ConnectWidget( GetConnectWidget() );
GTK_SIGNAL_FUNC(gtk_window_key_press_callback), (gpointer)this );
gtk_signal_connect( GTK_OBJECT(connect_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_FUNC(gtk_window_button_release_callback), (gpointer)this );
gtk_signal_connect( GTK_OBJECT(connect_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_FUNC(gtk_window_focus_in_callback), (gpointer)this );
gtk_signal_connect( GTK_OBJECT(connect_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_FUNC(gtk_window_enter_callback), (gpointer)this );
gtk_signal_connect( GTK_OBJECT(m_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_widget && m_parent) gtk_widget_realize( m_widget );
@ -1081,6 +1052,33 @@ void wxWindow::PostCreation(void)
m_hasVMT = TRUE; 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(widget), "button_press_event",
GTK_SIGNAL_FUNC(gtk_window_button_press_callback), (gpointer)this );
gtk_signal_connect( GTK_OBJECT(widget), "button_release_event",
GTK_SIGNAL_FUNC(gtk_window_button_release_callback), (gpointer)this );
gtk_signal_connect( GTK_OBJECT(widget), "motion_notify_event",
GTK_SIGNAL_FUNC(gtk_window_motion_notify_callback), (gpointer)this );
gtk_signal_connect( GTK_OBJECT(widget), "focus_in_event",
GTK_SIGNAL_FUNC(gtk_window_focus_in_callback), (gpointer)this );
gtk_signal_connect( GTK_OBJECT(widget), "focus_out_event",
GTK_SIGNAL_FUNC(gtk_window_focus_out_callback), (gpointer)this );
gtk_signal_connect( GTK_OBJECT(widget), "enter_notify_event",
GTK_SIGNAL_FUNC(gtk_window_enter_callback), (gpointer)this );
gtk_signal_connect( GTK_OBJECT(widget), "leave_notify_event",
GTK_SIGNAL_FUNC(gtk_window_leave_callback), (gpointer)this );
}
bool wxWindow::HasVMT(void) bool wxWindow::HasVMT(void)
{ {
return m_hasVMT; return m_hasVMT;

View File

@ -46,29 +46,16 @@ static void gtk_combo_clicked_callback( GtkWidget *WXUNUSED(widget), wxComboBox
combo->GetEventHandler()->ProcessEvent(event); 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 // wxComboBox
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
IMPLEMENT_DYNAMIC_CLASS(wxComboBox,wxControl) 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, bool wxComboBox::Create(wxWindow *parent, wxWindowID id, const wxString& value,
const wxPoint& pos, const wxSize& size, const wxPoint& pos, const wxSize& size,
int n, const wxString choices[], int n, const wxString choices[],
@ -107,11 +94,8 @@ bool wxComboBox::Create(wxWindow *parent, wxWindowID id, const wxString& value,
PostCreation(); PostCreation();
/* ConnectWidget( GTK_COMBO(m_widget)->button );
gtk_signal_connect( GTK_OBJECT(m_widget), "size_allocate",
GTK_SIGNAL_FUNC(gtk_combo_size_callback), (gpointer)this );
*/
if (!value.IsNull()) SetValue( value ); if (!value.IsNull()) SetValue( value );
Show( TRUE ); Show( TRUE );
@ -375,10 +359,24 @@ void wxComboBox::Remove(long from, long to)
void wxComboBox::SetSelection( long WXUNUSED(from), long WXUNUSED(to) ) void wxComboBox::SetSelection( long WXUNUSED(from), long WXUNUSED(to) )
{ {
wxFAIL_MSG( "wxComboBox::SetSelection not implemented" );
} }
void wxComboBox::SetEditable( bool WXUNUSED(editable) ) 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 ) void wxComboBox::SetFont( const wxFont &font )
@ -404,10 +402,15 @@ void wxComboBox::SetFont( const wxFont &font )
child = child->next; child = child->next;
} }
} }
GtkWidget* wxComboBox::GetConnectWidget(void) GtkWidget* wxComboBox::GetConnectWidget(void)
{ {
return GTK_COMBO(m_widget)->entry; 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 ) );
}

View File

@ -25,7 +25,7 @@
extern bool g_blockEventsOnDrag; extern bool g_blockEventsOnDrag;
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// wxRadioBox // "clicked"
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
static void gtk_radiobutton_clicked_callback( GtkWidget *WXUNUSED(widget), wxRadioBox *rb ) 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); rb->GetEventHandler()->ProcessEvent(event);
} }
//-----------------------------------------------------------------------------
// wxRadioBox
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
IMPLEMENT_DYNAMIC_CLASS(wxRadioBox,wxControl) 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] ) ); 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 ); if (!i) gtk_toggle_button_set_state( GTK_TOGGLE_BUTTON(m_radio), TRUE );
gtk_signal_connect( GTK_OBJECT(m_radio), "clicked", gtk_signal_connect( GTK_OBJECT(m_radio), "clicked",
@ -122,8 +126,10 @@ bool wxRadioBox::Create( wxWindow *parent, wxWindowID id, const wxString& title,
return TRUE; return TRUE;
} }
void wxRadioBox::OnSize( wxSizeEvent &WXUNUSED(event) ) void wxRadioBox::OnSize( wxSizeEvent &event )
{ {
wxControl::OnSize( event );
int x = m_x+5; int x = m_x+5;
int y = m_y+15; int y = m_y+15;
@ -371,3 +377,18 @@ void wxRadioBox::SetFont( const wxFont &font )
item = item->next; 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;
}

View File

@ -23,7 +23,7 @@
extern bool g_blockEventsOnDrag; extern bool g_blockEventsOnDrag;
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// wxScrollBar // "value_changed"
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
static void gtk_scrollbar_callback( GtkWidget *WXUNUSED(widget), wxScrollBar *win ) 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) IMPLEMENT_DYNAMIC_CLASS(wxScrollBar,wxControl)
wxScrollBar::~wxScrollBar(void) wxScrollBar::~wxScrollBar(void)
@ -209,3 +213,12 @@ void wxScrollBar::SetViewLength( int viewLength )
SetScrollbar( pos, thumb, viewLength, page ); 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) );
}

View File

@ -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) );
}

View File

@ -39,11 +39,12 @@ bool wxStaticBox::Create( wxWindow *parent, wxWindowID id, const wxString &label
PreCreation( parent, id, pos, size, style, name ); PreCreation( parent, id, pos, size, style, name );
SetLabel(label);
m_widget = gtk_frame_new(m_label); m_widget = gtk_frame_new(m_label);
PostCreation(); PostCreation();
SetLabel(label);
Show( TRUE ); Show( TRUE );
return TRUE; return TRUE;

View File

@ -324,7 +324,6 @@ void wxTextCtrl::OnChar( wxKeyEvent &key_event )
{ {
wxCommandEvent event(wxEVT_COMMAND_TEXT_ENTER, m_windowId); wxCommandEvent event(wxEVT_COMMAND_TEXT_ENTER, m_windowId);
event.SetEventObject(this); event.SetEventObject(this);
printf( "Hallo.\n" );
if (GetEventHandler()->ProcessEvent(event)) return; if (GetEventHandler()->ProcessEvent(event)) return;
} }
else if (key_event.KeyCode() == WXK_TAB) else if (key_event.KeyCode() == WXK_TAB)

View File

@ -28,11 +28,12 @@
#include "wx/menu.h" #include "wx/menu.h"
#include "wx/notebook.h" #include "wx/notebook.h"
#include "wx/statusbr.h" #include "wx/statusbr.h"
#include <wx/intl.h> #include "wx/intl.h"
#include "gdk/gdkkeysyms.h"
#include <math.h>
#include "wx/gtk/win_gtk.h" #include "wx/gtk/win_gtk.h"
#include "gdk/gdkprivate.h" #include "gdk/gdkprivate.h"
#include "gdk/gdkkeysyms.h"
#include <math.h>
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// documentation on internals // documentation on internals
@ -591,6 +592,50 @@ static gint gtk_window_focus_out_callback( GtkWidget *widget, GdkEvent *WXUNUSED
return TRUE; 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 // "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 // wxWindow
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
@ -1019,11 +1028,6 @@ void wxWindow::PostCreation(void)
{ {
if (m_parent) m_parent->AddChild( this ); 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) if (m_wxwindow)
{ {
gtk_signal_connect( GTK_OBJECT(m_wxwindow), "expose_event", gtk_signal_connect( GTK_OBJECT(m_wxwindow), "expose_event",
@ -1033,40 +1037,7 @@ void wxWindow::PostCreation(void)
GTK_SIGNAL_FUNC(gtk_window_draw_callback), (gpointer)this ); GTK_SIGNAL_FUNC(gtk_window_draw_callback), (gpointer)this );
} }
gtk_signal_connect( GTK_OBJECT(connect_widget), "key_press_event", ConnectWidget( GetConnectWidget() );
GTK_SIGNAL_FUNC(gtk_window_key_press_callback), (gpointer)this );
gtk_signal_connect( GTK_OBJECT(connect_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_FUNC(gtk_window_button_release_callback), (gpointer)this );
gtk_signal_connect( GTK_OBJECT(connect_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_FUNC(gtk_window_focus_in_callback), (gpointer)this );
gtk_signal_connect( GTK_OBJECT(connect_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_FUNC(gtk_window_enter_callback), (gpointer)this );
gtk_signal_connect( GTK_OBJECT(m_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_widget && m_parent) gtk_widget_realize( m_widget );
@ -1081,6 +1052,33 @@ void wxWindow::PostCreation(void)
m_hasVMT = TRUE; 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(widget), "button_press_event",
GTK_SIGNAL_FUNC(gtk_window_button_press_callback), (gpointer)this );
gtk_signal_connect( GTK_OBJECT(widget), "button_release_event",
GTK_SIGNAL_FUNC(gtk_window_button_release_callback), (gpointer)this );
gtk_signal_connect( GTK_OBJECT(widget), "motion_notify_event",
GTK_SIGNAL_FUNC(gtk_window_motion_notify_callback), (gpointer)this );
gtk_signal_connect( GTK_OBJECT(widget), "focus_in_event",
GTK_SIGNAL_FUNC(gtk_window_focus_in_callback), (gpointer)this );
gtk_signal_connect( GTK_OBJECT(widget), "focus_out_event",
GTK_SIGNAL_FUNC(gtk_window_focus_out_callback), (gpointer)this );
gtk_signal_connect( GTK_OBJECT(widget), "enter_notify_event",
GTK_SIGNAL_FUNC(gtk_window_enter_callback), (gpointer)this );
gtk_signal_connect( GTK_OBJECT(widget), "leave_notify_event",
GTK_SIGNAL_FUNC(gtk_window_leave_callback), (gpointer)this );
}
bool wxWindow::HasVMT(void) bool wxWindow::HasVMT(void)
{ {
return m_hasVMT; return m_hasVMT;