X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/b666df2c102d1e183532adf0c003e63b1a591e2f..9f3362c440ef4c780d9a4bc8089de60a21d108bd:/src/gtk/window.cpp?ds=sidebyside diff --git a/src/gtk/window.cpp b/src/gtk/window.cpp index 51302a0530..9b1cb42717 100644 --- a/src/gtk/window.cpp +++ b/src/gtk/window.cpp @@ -24,6 +24,7 @@ #if wxUSE_DRAG_AND_DROP #include "wx/dnd.h" #endif +#include "wx/tooltip.h" #include "wx/menu.h" #include "wx/statusbr.h" #include "wx/intl.h" @@ -631,6 +632,10 @@ static gint gtk_window_button_press_callback( GtkWidget *widget, GdkEventButton node = node->Next(); } } + + wxPoint pt(win->GetClientAreaOrigin()); + event.m_x -= pt.x; + event.m_y -= pt.y; event.SetEventObject( win ); @@ -736,6 +741,10 @@ static gint gtk_window_button_release_callback( GtkWidget *widget, GdkEventButto } } + wxPoint pt(win->GetClientAreaOrigin()); + event.m_x -= pt.x; + event.m_y -= pt.y; + event.SetEventObject( win ); if (win->GetEventHandler()->ProcessEvent( event )) @@ -841,6 +850,10 @@ static gint gtk_window_motion_notify_callback( GtkWidget *widget, GdkEventMotion } } + wxPoint pt(win->GetClientAreaOrigin()); + event.m_x -= pt.x; + event.m_y -= pt.y; + event.SetEventObject( win ); if (win->GetEventHandler()->ProcessEvent( event )) @@ -966,6 +979,10 @@ static gint gtk_window_enter_callback( GtkWidget *widget, GdkEventCrossing *gdk_ event.m_x = (long)x; event.m_y = (long)y; + wxPoint pt(win->GetClientAreaOrigin()); + event.m_x -= pt.x; + event.m_y -= pt.y; + if (win->GetEventHandler()->ProcessEvent( event )) gtk_signal_emit_stop_by_name( GTK_OBJECT(widget), "enter_notify_event" ); @@ -1014,6 +1031,10 @@ static gint gtk_window_leave_callback( GtkWidget *widget, GdkEventCrossing *gdk_ event.m_x = (long)x; event.m_y = (long)y; + wxPoint pt(win->GetClientAreaOrigin()); + event.m_x -= pt.x; + event.m_y -= pt.y; + if (win->GetEventHandler()->ProcessEvent( event )) gtk_signal_emit_stop_by_name( GTK_OBJECT(widget), "leave_notify_event" ); @@ -1214,12 +1235,12 @@ static gint gtk_scrollbar_button_release_callback( GtkRange *widget, // InsertChild for wxWindow. //----------------------------------------------------------------------------- -// Callback for wxWindow. This very strange beast has to be used because -// C++ has no virtual methods in a constructor. We have to emulate a -// virtual function here as wxNotebook requires a different way to insert -// a child in it. I had opted for creating a wxNotebookPage window class -// which would have made this superfluous (such in the MDI window system), -// but no-one was listening to me... +/* Callback for wxWindow. This very strange beast has to be used because + * C++ has no virtual methods in a constructor. We have to emulate a + * virtual function here as wxNotebook requires a different way to insert + * a child in it. I had opted for creating a wxNotebookPage window class + * which would have made this superfluous (such in the MDI window system), + * but no-one was listening to me... */ static void wxInsertChildInWindow( wxWindow* parent, wxWindow* child ) { @@ -1231,6 +1252,18 @@ static void wxInsertChildInWindow( wxWindow* parent, wxWindow* child ) gtk_widget_set_usize( GTK_WIDGET(child->m_widget), child->m_width, child->m_height ); + + if (wxIS_KIND_OF(parent,wxFrame)) + { + parent->m_sizeSet = FALSE; + } + + if (parent->m_windowStyle & 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->m_wxwindow, GTK_CAN_FOCUS ); + } } //----------------------------------------------------------------------------- @@ -1252,7 +1285,6 @@ BEGIN_EVENT_TABLE(wxWindow, wxEvtHandler) EVT_SIZE(wxWindow::OnSize) EVT_SYS_COLOUR_CHANGED(wxWindow::OnSysColourChanged) EVT_INIT_DIALOG(wxWindow::OnInitDialog) - EVT_IDLE(wxWindow::OnIdle) EVT_KEY_DOWN(wxWindow::OnKeyDown) END_EVENT_TABLE() @@ -1318,6 +1350,8 @@ wxWindow::wxWindow() m_isStaticBox = FALSE; m_acceptsFocus = FALSE; + + m_toolTip = (wxToolTip*) NULL; } wxWindow::wxWindow( wxWindow *parent, wxWindowID id, @@ -1394,9 +1428,11 @@ bool wxWindow::Create( wxWindow *parent, wxWindowID id, gtk_viewport_set_shadow_type( viewport, GTK_SHADOW_NONE ); } - if ((m_windowStyle & wxTAB_TRAVERSAL) != 0) + if (m_windowStyle & wxTAB_TRAVERSAL) { - GTK_WIDGET_UNSET_FLAGS( m_wxwindow, GTK_CAN_FOCUS ); + /* we now allow a window to get the focus as long as it + doesn't have any children. */ + GTK_WIDGET_SET_FLAGS( m_wxwindow, GTK_CAN_FOCUS ); m_acceptsFocus = FALSE; } else @@ -1476,6 +1512,8 @@ wxWindow::~wxWindow() if (m_dropTarget) delete m_dropTarget; #endif + if (m_toolTip) delete m_toolTip; + if (m_parent) m_parent->RemoveChild( this ); if (m_widget) Show( FALSE ); @@ -1605,6 +1643,7 @@ void wxWindow::PreCreation( wxWindow *parent, wxWindowID id, m_clientData = NULL; m_isStaticBox = FALSE; + m_toolTip = (wxToolTip*) NULL; } void wxWindow::PostCreation() @@ -1786,6 +1825,11 @@ void wxWindow::SetSize( int x, int y, int width, int height, int sizeFlags ) m_resizing = FALSE; } +void wxWindow::OnInternalIdle() +{ + UpdateWindowUI(); +} + void wxWindow::SetSize( int width, int height ) { SetSize( -1, -1, width, height, wxSIZE_USE_EXISTING ); @@ -2429,6 +2473,28 @@ void wxWindow::Clear() if (m_wxwindow && m_wxwindow->window) gdk_window_clear( m_wxwindow->window ); } +void wxWindow::SetToolTip( const wxString &tip ) +{ + SetToolTip( new wxToolTip( tip ) ); +} + +void wxWindow::SetToolTip( wxToolTip *tip ) +{ + if (m_toolTip) delete m_toolTip; + + m_toolTip = tip; + + if (m_toolTip) m_toolTip->Create( GetConnectWidget() ); +} + +wxToolTip& wxWindow::GetToolTip() +{ + if (!m_toolTip) + wxLogError( "No tooltip set." ); + + return *m_toolTip; +} + wxColour wxWindow::GetBackgroundColour() const { return m_backgroundColour; @@ -2626,21 +2692,35 @@ static void SetInvokingWindow( wxMenu *menu, wxWindow *win ) } } -bool wxWindow::PopupMenu( wxMenu *menu, int WXUNUSED(x), int WXUNUSED(y) ) +static gint gs_pop_x = 0; +static gint gs_pop_y = 0; + +static void pop_pos_callback( GtkMenu *menu, gint *x, gint *y, wxWindow *win ) +{ + win->ClientToScreen( &gs_pop_x, &gs_pop_y ); + *x = gs_pop_x; + *y = gs_pop_y; +} + +bool wxWindow::PopupMenu( wxMenu *menu, int x, int y ) { wxCHECK_MSG( m_widget != NULL, FALSE, "invalid window" ); wxCHECK_MSG( menu != NULL, FALSE, "invalid popup-menu" ); SetInvokingWindow( menu, this ); + + gs_pop_x = x; + gs_pop_y = y; + gtk_menu_popup( GTK_MENU(menu->m_menu), - (GtkWidget *)NULL, // parent menu shell - (GtkWidget *)NULL, // parent menu item - (GtkMenuPositionFunc)NULL, - NULL, // client data - 0, // button used to activate it - 0//gs_timeLastClick // the time of activation + (GtkWidget *) NULL, // parent menu shell + (GtkWidget *) NULL, // parent menu item + (GtkMenuPositionFunc) pop_pos_callback, + (gpointer) this, // client data + 0, // button used to activate it + 0 //gs_timeLastClick // the time of activation ); return TRUE; } @@ -3444,7 +3524,3 @@ void wxWindow::GetPositionConstraint(int *x, int *y) const GetPosition(x, y); } -void wxWindow::OnIdle(wxIdleEvent& WXUNUSED(event) ) -{ - UpdateWindowUI(); -}