X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/0c77152e0de4e3851ee74e91e19c1394a28eb943..9f3362c440ef4c780d9a4bc8089de60a21d108bd:/src/gtk/window.cpp?ds=sidebyside diff --git a/src/gtk/window.cpp b/src/gtk/window.cpp index 54cc477208..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" @@ -1234,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 ) { @@ -1256,6 +1257,13 @@ static void wxInsertChildInWindow( wxWindow* parent, wxWindow* child ) { 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 ); + } } //----------------------------------------------------------------------------- @@ -1342,6 +1350,8 @@ wxWindow::wxWindow() m_isStaticBox = FALSE; m_acceptsFocus = FALSE; + + m_toolTip = (wxToolTip*) NULL; } wxWindow::wxWindow( wxWindow *parent, wxWindowID id, @@ -1418,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 @@ -1500,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 ); @@ -1629,6 +1643,7 @@ void wxWindow::PreCreation( wxWindow *parent, wxWindowID id, m_clientData = NULL; m_isStaticBox = FALSE; + m_toolTip = (wxToolTip*) NULL; } void wxWindow::PostCreation() @@ -2458,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;