From b11708106f93d28dbb47218b18e02674ad6c0cdb Mon Sep 17 00:00:00 2001 From: Robert Roebling Date: Wed, 27 Jan 1999 17:15:34 +0000 Subject: [PATCH] wxToolTip part II small change in tab traversal makefile corrections wxGLCanvas moved git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@1498 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- docs/latex/wx/image.tex | 8 +-- include/wx/defs.h | 1 + include/wx/gtk/listbox.h | 3 ++ include/wx/gtk/tooltip.h | 19 +++++-- include/wx/gtk/window.h | 10 +++- include/wx/gtk1/listbox.h | 3 ++ include/wx/gtk1/tooltip.h | 19 +++++-- include/wx/gtk1/window.h | 10 +++- samples/controls/controls.cpp | 14 +++-- samples/dde/ddesetup.h | 2 +- src/gtk/listbox.cpp | 27 ++++++++++ src/gtk/tooltip.cpp | 69 ++++++++++++++---------- src/gtk/window.cpp | 42 ++++++++++++--- src/gtk1/listbox.cpp | 27 ++++++++++ src/gtk1/tooltip.cpp | 69 ++++++++++++++---------- src/gtk1/window.cpp | 42 ++++++++++++--- utils/dialoged/src/Makefile | 13 +++++ utils/glcanvas/distrib/glcanvas.rsp | 13 +++-- utils/glcanvas/{src => gtk}/.cvsignore | 0 utils/glcanvas/{src => gtk}/glcanvas.cpp | 0 utils/glcanvas/{src => gtk}/glcanvas.h | 0 utils/glcanvas/samples/cube/Makefile | 19 +++++-- utils/glcanvas/samples/isosurf/Makefile | 19 +++++-- utils/glcanvas/samples/penguin/Makefile | 13 +++++ 24 files changed, 344 insertions(+), 98 deletions(-) rename utils/glcanvas/{src => gtk}/.cvsignore (100%) rename utils/glcanvas/{src => gtk}/glcanvas.cpp (100%) rename utils/glcanvas/{src => gtk}/glcanvas.h (100%) diff --git a/docs/latex/wx/image.tex b/docs/latex/wx/image.tex index a7808cd051..02cca80629 100644 --- a/docs/latex/wx/image.tex +++ b/docs/latex/wx/image.tex @@ -369,9 +369,9 @@ Depending on how wxWindows has been configured, not all formats may be available Returns a scaled version of the image. This is also useful for scaling bitmaps in general as the only other way to scale bitmaps -is do blit a wxMemoryDC into another wxMemoryDC. Windows can such scaling -itself, but on GTK scaling bitmaps is done using this routine -internally. +is to blit a wxMemoryDC into another wxMemoryDC. Windows can do such +scaling itself but in the GTK port, scaling bitmaps is done using +this routine internally. \membersection{wxImage::SetData}\label{wximagesetdata} @@ -391,7 +391,7 @@ Specifies whether there is a mask or not. The area of the mask is determined by \func{void}{SetMaskColour}{\param{unsigned char }{red}, \param{unsigned char }{blue}, \param{unsigned char }{green}} -Sets the mask colour for this image. +Sets the mask colour for this image (and tells the image to use the mask). \membersection{wxImage::SetRGB}\label{wximagesetrgb} diff --git a/include/wx/defs.h b/include/wx/defs.h index 2c3b71ec0c..55a54645ef 100644 --- a/include/wx/defs.h +++ b/include/wx/defs.h @@ -1030,6 +1030,7 @@ typedef struct _GtkStyle GtkStyle; typedef struct _GtkAdjustment GtkAdjustment; typedef struct _GtkList GtkList; typedef struct _GtkToolbar GtkToolbar; +typedef struct _GtkTooltips GtkTooltips; typedef struct _GtkNotebook GtkNotebook; typedef struct _GtkNotebookPage GtkNotebookPage; diff --git a/include/wx/gtk/listbox.h b/include/wx/gtk/listbox.h index 1b24d42c25..9d6cafe665 100644 --- a/include/wx/gtk/listbox.h +++ b/include/wx/gtk/listbox.h @@ -94,6 +94,9 @@ public: #if wxUSE_DRAG_AND_DROP void SetDropTarget( wxDropTarget *dropTarget ); #endif + void SetToolTip( wxToolTip *tip ); + void SetToolTip( const wxString &tip ); + // implementation diff --git a/include/wx/gtk/tooltip.h b/include/wx/gtk/tooltip.h index d8f7c0b8e3..a724074f56 100644 --- a/include/wx/gtk/tooltip.h +++ b/include/wx/gtk/tooltip.h @@ -32,13 +32,24 @@ class wxToolTip: public wxObject { public: - wxToolTip() {} + wxToolTip( const wxString &tip ); + ~wxToolTip(); - static void Add( wxWindow *tool, const wxString &tip ); - static void Enable( bool flag ); - static void SetDelay( long msecs ); + wxString GetTip(); + + void Enable( bool flag ); + void SetDelay( long msecs ); + bool Ok(); + // implementation + wxString m_text; + + GtkTooltips *m_tooltips; + GdkColor *m_bg; + GdkColor *m_fg; + + void Create( GtkWidget *tool ); }; #endif // __GTKTOOLTIPH__ diff --git a/include/wx/gtk/window.h b/include/wx/gtk/window.h index 046a6d6219..0031aa27a1 100644 --- a/include/wx/gtk/window.h +++ b/include/wx/gtk/window.h @@ -55,6 +55,7 @@ class wxItemResource; #if wxUSE_DRAG_AND_DROP class wxDropTarget; #endif +class wxToolTip; //----------------------------------------------------------------------------- // callback definition for inserting a window (internal) @@ -207,8 +208,8 @@ public: void PushEventHandler( wxEvtHandler *handler ); wxEvtHandler *PopEventHandler( bool deleteHandler = FALSE ); - virtual wxValidator *GetValidator(); virtual void SetValidator( const wxValidator &validator ); + virtual wxValidator *GetValidator(); virtual void SetClientObject( wxClientData *data ); virtual wxClientData *GetClientObject(); @@ -225,9 +226,13 @@ public: wxWindowID GetId() const; void SetCursor( const wxCursor &cursor ); - + void WarpPointer(int x, int y); + virtual void SetToolTip( const wxString &tip ); + virtual void SetToolTip( wxToolTip *tip ); + virtual wxToolTip& GetToolTip(); + virtual void Refresh( bool eraseBackground = TRUE, const wxRect *rect = (const wxRect *) NULL ); virtual void Clear(); @@ -359,6 +364,7 @@ public: wxAcceleratorTable m_acceleratorTable; wxClientData *m_clientObject; void *m_clientData; + wxToolTip *m_toolTip; GtkWidget *m_widget; GtkWidget *m_wxwindow; diff --git a/include/wx/gtk1/listbox.h b/include/wx/gtk1/listbox.h index 1b24d42c25..9d6cafe665 100644 --- a/include/wx/gtk1/listbox.h +++ b/include/wx/gtk1/listbox.h @@ -94,6 +94,9 @@ public: #if wxUSE_DRAG_AND_DROP void SetDropTarget( wxDropTarget *dropTarget ); #endif + void SetToolTip( wxToolTip *tip ); + void SetToolTip( const wxString &tip ); + // implementation diff --git a/include/wx/gtk1/tooltip.h b/include/wx/gtk1/tooltip.h index d8f7c0b8e3..a724074f56 100644 --- a/include/wx/gtk1/tooltip.h +++ b/include/wx/gtk1/tooltip.h @@ -32,13 +32,24 @@ class wxToolTip: public wxObject { public: - wxToolTip() {} + wxToolTip( const wxString &tip ); + ~wxToolTip(); - static void Add( wxWindow *tool, const wxString &tip ); - static void Enable( bool flag ); - static void SetDelay( long msecs ); + wxString GetTip(); + + void Enable( bool flag ); + void SetDelay( long msecs ); + bool Ok(); + // implementation + wxString m_text; + + GtkTooltips *m_tooltips; + GdkColor *m_bg; + GdkColor *m_fg; + + void Create( GtkWidget *tool ); }; #endif // __GTKTOOLTIPH__ diff --git a/include/wx/gtk1/window.h b/include/wx/gtk1/window.h index 046a6d6219..0031aa27a1 100644 --- a/include/wx/gtk1/window.h +++ b/include/wx/gtk1/window.h @@ -55,6 +55,7 @@ class wxItemResource; #if wxUSE_DRAG_AND_DROP class wxDropTarget; #endif +class wxToolTip; //----------------------------------------------------------------------------- // callback definition for inserting a window (internal) @@ -207,8 +208,8 @@ public: void PushEventHandler( wxEvtHandler *handler ); wxEvtHandler *PopEventHandler( bool deleteHandler = FALSE ); - virtual wxValidator *GetValidator(); virtual void SetValidator( const wxValidator &validator ); + virtual wxValidator *GetValidator(); virtual void SetClientObject( wxClientData *data ); virtual wxClientData *GetClientObject(); @@ -225,9 +226,13 @@ public: wxWindowID GetId() const; void SetCursor( const wxCursor &cursor ); - + void WarpPointer(int x, int y); + virtual void SetToolTip( const wxString &tip ); + virtual void SetToolTip( wxToolTip *tip ); + virtual wxToolTip& GetToolTip(); + virtual void Refresh( bool eraseBackground = TRUE, const wxRect *rect = (const wxRect *) NULL ); virtual void Clear(); @@ -359,6 +364,7 @@ public: wxAcceleratorTable m_acceleratorTable; wxClientData *m_clientObject; void *m_clientData; + wxToolTip *m_toolTip; GtkWidget *m_widget; GtkWidget *m_wxwindow; diff --git a/samples/controls/controls.cpp b/samples/controls/controls.cpp index d0f9bbb2d5..fe99c4266e 100644 --- a/samples/controls/controls.cpp +++ b/samples/controls/controls.cpp @@ -230,7 +230,7 @@ BEGIN_EVENT_TABLE(MyPanel, wxPanel) EVT_BUTTON (ID_CHOICE_DELETE, MyPanel::OnChoiceButtons) EVT_BUTTON (ID_CHOICE_FONT, MyPanel::OnChoiceButtons) EVT_CHECKBOX (ID_CHOICE_ENABLE, MyPanel::OnChoiceButtons) - EVT_CHOICE (ID_COMBO, MyPanel::OnCombo) + EVT_COMBOBOX (ID_COMBO, MyPanel::OnCombo) EVT_BUTTON (ID_COMBO_SEL_NUM, MyPanel::OnComboButtons) EVT_BUTTON (ID_COMBO_SEL_STR, MyPanel::OnComboButtons) EVT_BUTTON (ID_COMBO_CLEAR, MyPanel::OnComboButtons) @@ -333,6 +333,9 @@ MyPanel::MyPanel( wxFrame *frame, int x, int y, int w, int h ) : // panel->SetBackgroundColour("cadet blue"); // panel->SetForegroundColour("blue"); m_listbox = new wxListBox( panel, ID_LISTBOX, wxPoint(10,10), wxSize(120,70), 5, choices ); +#ifdef __WXGTK__ + m_listbox->SetToolTip( "This is a list box" ); +#endif // m_listbox->SetBackgroundColour("wheat"); (void)new wxButton( panel, ID_LISTBOX_SEL_NUM, "Select #2", wxPoint(180,30), wxSize(140,30) ); (void)new wxButton( panel, ID_LISTBOX_SEL_STR, "Select 'This'", wxPoint(340,30), wxSize(140,30) ); @@ -340,13 +343,16 @@ MyPanel::MyPanel( wxFrame *frame, int x, int y, int w, int h ) : (void)new wxButton( panel, ID_LISTBOX_APPEND, "Append 'Hi!'", wxPoint(340,80), wxSize(140,30) ); (void)new wxButton( panel, ID_LISTBOX_DELETE, "Delete selected item", wxPoint(180,130), wxSize(140,30) ); button = new wxButton( panel, ID_LISTBOX_FONT, "Set Italic font", wxPoint(340,130), wxSize(140,30) ); - #ifdef __WXGTK__ - wxToolTip::Add( button, "Press here to set italic font" ); + button->SetToolTip( "Press here to set italic font" ); #endif + // button->SetForegroundColour( "red" ); m_checkbox = new wxCheckBox( panel, ID_LISTBOX_ENABLE, "Disable", wxPoint(20,130), wxSize(140,30) ); m_checkbox->SetValue(FALSE); +#ifdef __WXGTK__ + m_checkbox->SetToolTip( "Click here to disable the listbox" ); +#endif m_notebook->AddPage(panel, "wxList", TRUE, Image_List); panel = new wxPanel(m_notebook); @@ -385,7 +391,7 @@ MyPanel::MyPanel( wxFrame *frame, int x, int y, int w, int h ) : // tc->SetBackgroundColour("wheat"); m_multitext = new wxTextCtrl( panel, ID_TEXT, "And here.", wxPoint(10,50), wxSize(320,160), wxTE_MULTILINE ); (*m_multitext) << " More text."; - m_multitext->SetBackgroundColour("wheat"); +// m_multitext->SetBackgroundColour("wheat"); (void)new wxStaticBox( panel, -1, "wxClipboard", wxPoint(345,50), wxSize(160,145) ); (void)new wxButton( panel, ID_COPY_TEXT, "Copy line 1", wxPoint(370,80), wxSize(110,30) ); (void)new wxButton( panel, ID_PASTE_TEXT, "Paste text", wxPoint(370,140), wxSize(110,30) ); diff --git a/samples/dde/ddesetup.h b/samples/dde/ddesetup.h index 7b674ecf54..00c6cc3b23 100644 --- a/samples/dde/ddesetup.h +++ b/samples/dde/ddesetup.h @@ -15,7 +15,7 @@ */ // If 1, use real DDE. If 0, use TCP/IP -#define wxUSE_DDE_FOR_SAMPLE 1 +#define wxUSE_DDE_FOR_SAMPLE 0 #if wxUSE_DDE_FOR_SAMPLE diff --git a/src/gtk/listbox.cpp b/src/gtk/listbox.cpp index 32cf66671e..6d6208d779 100644 --- a/src/gtk/listbox.cpp +++ b/src/gtk/listbox.cpp @@ -17,6 +17,7 @@ #include "wx/utils.h" #include "wx/intl.h" #include "wx/checklst.h" +#include "wx/tooltip.h" #if wxUSE_DRAG_AND_DROP #include "wx/dnd.h" @@ -345,6 +346,8 @@ void wxListBox::AppendCommon( const wxString &item ) if (m_dropTarget) m_dropTarget->RegisterWidget( list_item ); #endif #endif + + if (m_toolTip) m_toolTip->Create( list_item ); } void wxListBox::Append( const wxString &item ) @@ -673,6 +676,29 @@ int wxListBox::GetIndex( GtkWidget *item ) const return -1; } +void wxListBox::SetToolTip( const wxString &tip ) +{ + SetToolTip( new wxToolTip( tip ) ); +} + +void wxListBox::SetToolTip( wxToolTip *tip ) +{ + if (m_toolTip) delete m_toolTip; + + m_toolTip = tip; + + if (!tip) return; + + m_toolTip->Create( GTK_WIDGET(m_list) ); /* this has no effect */ + + GList *child = m_list->children; + while (child) + { + m_toolTip->Create( GTK_WIDGET( child->data ) ); + child = child->next; + } +} + #if wxUSE_DRAG_AND_DROP void wxListBox::SetDropTarget( wxDropTarget *dropTarget ) { @@ -750,3 +776,4 @@ void wxListBox::ApplyWidgetStyle() child = child->next; } } + diff --git a/src/gtk/tooltip.cpp b/src/gtk/tooltip.cpp index bc5df460c6..f3e3acb598 100644 --- a/src/gtk/tooltip.cpp +++ b/src/gtk/tooltip.cpp @@ -16,54 +16,69 @@ #include "gtk/gtk.h" #include "gdk/gdk.h" -//----------------------------------------------------------------------------- -// global data -//----------------------------------------------------------------------------- - -GtkTooltips *gs_tooltips = (GtkTooltips*) NULL; -GdkColor gs_tooltip_bg; -GdkColor gs_tooltip_fg; - //----------------------------------------------------------------------------- // wxToolTip //----------------------------------------------------------------------------- -void wxToolTip::Add( wxWindow *tool, const wxString &tip ) +wxToolTip::wxToolTip( const wxString &tip ) { - if (!gs_tooltips) + m_text = tip; + + m_tooltips = (GtkTooltips*) NULL; + + m_fg = new GdkColor; + m_fg->red = 0; + m_fg->green = 0; + m_fg->blue = 0; + + m_bg = new GdkColor; + m_bg->red = 65535; + m_bg->green = 65535; + m_bg->blue = 50000; +} + +wxToolTip::~wxToolTip() +{ + gtk_object_unref( GTK_OBJECT(m_tooltips) ); + + delete m_fg; + delete m_bg; +} + +bool wxToolTip::Ok() +{ + return (m_tooltips); +} + +void wxToolTip::Create( GtkWidget *tool ) +{ + if (!m_tooltips) { - gs_tooltips = gtk_tooltips_new(); + m_tooltips = gtk_tooltips_new(); - gs_tooltip_fg.red = 0; - gs_tooltip_fg.green = 0; - gs_tooltip_fg.blue = 0; - gdk_color_alloc( gtk_widget_get_colormap( tool->GetConnectWidget() ), &gs_tooltip_fg ); + gdk_color_alloc( gtk_widget_get_colormap( tool ), m_fg ); + gdk_color_alloc( gtk_widget_get_colormap( tool ), m_bg ); - gs_tooltip_bg.red = 65535; - gs_tooltip_bg.green = 65535; - gs_tooltip_bg.blue = 50000; - gdk_color_alloc( gtk_widget_get_colormap( tool->GetConnectWidget() ), &gs_tooltip_bg ); - - gtk_tooltips_set_colors( gs_tooltips, &gs_tooltip_bg, &gs_tooltip_fg ); + gtk_tooltips_set_colors( m_tooltips, m_bg, m_fg ); } - gtk_tooltips_set_tip( gs_tooltips, tool->GetConnectWidget(), tip, (gchar*) NULL ); + gtk_tooltips_set_tip( m_tooltips, tool, m_text, (gchar*) NULL ); } void wxToolTip::Enable( bool flag ) { - if (!gs_tooltips) gs_tooltips = gtk_tooltips_new(); + if (!Ok()) return; if (flag) - gtk_tooltips_enable( gs_tooltips ); + gtk_tooltips_enable( m_tooltips ); else - gtk_tooltips_disable( gs_tooltips ); + gtk_tooltips_disable( m_tooltips ); } void wxToolTip::SetDelay( long msecs ) { - if (!gs_tooltips) gs_tooltips = gtk_tooltips_new(); + if (!Ok()) return; - gtk_tooltips_set_delay( gs_tooltips, msecs ); + gtk_tooltips_set_delay( m_tooltips, msecs ); } diff --git a/src/gtk/window.cpp b/src/gtk/window.cpp index 54cc477208..3f46517907 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 ) { @@ -1342,6 +1343,8 @@ wxWindow::wxWindow() m_isStaticBox = FALSE; m_acceptsFocus = FALSE; + + m_toolTip = (wxToolTip*) NULL; } wxWindow::wxWindow( wxWindow *parent, wxWindowID id, @@ -1420,7 +1423,7 @@ bool wxWindow::Create( wxWindow *parent, wxWindowID id, if ((m_windowStyle & wxTAB_TRAVERSAL) != 0) { - GTK_WIDGET_UNSET_FLAGS( m_wxwindow, GTK_CAN_FOCUS ); + GTK_WIDGET_SET_FLAGS( m_wxwindow, GTK_CAN_FOCUS ); /* changed from UNSET */ m_acceptsFocus = FALSE; } else @@ -1500,6 +1503,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 +1634,7 @@ void wxWindow::PreCreation( wxWindow *parent, wxWindowID id, m_clientData = NULL; m_isStaticBox = FALSE; + m_toolTip = (wxToolTip*) NULL; } void wxWindow::PostCreation() @@ -2458,6 +2464,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; diff --git a/src/gtk1/listbox.cpp b/src/gtk1/listbox.cpp index 32cf66671e..6d6208d779 100644 --- a/src/gtk1/listbox.cpp +++ b/src/gtk1/listbox.cpp @@ -17,6 +17,7 @@ #include "wx/utils.h" #include "wx/intl.h" #include "wx/checklst.h" +#include "wx/tooltip.h" #if wxUSE_DRAG_AND_DROP #include "wx/dnd.h" @@ -345,6 +346,8 @@ void wxListBox::AppendCommon( const wxString &item ) if (m_dropTarget) m_dropTarget->RegisterWidget( list_item ); #endif #endif + + if (m_toolTip) m_toolTip->Create( list_item ); } void wxListBox::Append( const wxString &item ) @@ -673,6 +676,29 @@ int wxListBox::GetIndex( GtkWidget *item ) const return -1; } +void wxListBox::SetToolTip( const wxString &tip ) +{ + SetToolTip( new wxToolTip( tip ) ); +} + +void wxListBox::SetToolTip( wxToolTip *tip ) +{ + if (m_toolTip) delete m_toolTip; + + m_toolTip = tip; + + if (!tip) return; + + m_toolTip->Create( GTK_WIDGET(m_list) ); /* this has no effect */ + + GList *child = m_list->children; + while (child) + { + m_toolTip->Create( GTK_WIDGET( child->data ) ); + child = child->next; + } +} + #if wxUSE_DRAG_AND_DROP void wxListBox::SetDropTarget( wxDropTarget *dropTarget ) { @@ -750,3 +776,4 @@ void wxListBox::ApplyWidgetStyle() child = child->next; } } + diff --git a/src/gtk1/tooltip.cpp b/src/gtk1/tooltip.cpp index bc5df460c6..f3e3acb598 100644 --- a/src/gtk1/tooltip.cpp +++ b/src/gtk1/tooltip.cpp @@ -16,54 +16,69 @@ #include "gtk/gtk.h" #include "gdk/gdk.h" -//----------------------------------------------------------------------------- -// global data -//----------------------------------------------------------------------------- - -GtkTooltips *gs_tooltips = (GtkTooltips*) NULL; -GdkColor gs_tooltip_bg; -GdkColor gs_tooltip_fg; - //----------------------------------------------------------------------------- // wxToolTip //----------------------------------------------------------------------------- -void wxToolTip::Add( wxWindow *tool, const wxString &tip ) +wxToolTip::wxToolTip( const wxString &tip ) { - if (!gs_tooltips) + m_text = tip; + + m_tooltips = (GtkTooltips*) NULL; + + m_fg = new GdkColor; + m_fg->red = 0; + m_fg->green = 0; + m_fg->blue = 0; + + m_bg = new GdkColor; + m_bg->red = 65535; + m_bg->green = 65535; + m_bg->blue = 50000; +} + +wxToolTip::~wxToolTip() +{ + gtk_object_unref( GTK_OBJECT(m_tooltips) ); + + delete m_fg; + delete m_bg; +} + +bool wxToolTip::Ok() +{ + return (m_tooltips); +} + +void wxToolTip::Create( GtkWidget *tool ) +{ + if (!m_tooltips) { - gs_tooltips = gtk_tooltips_new(); + m_tooltips = gtk_tooltips_new(); - gs_tooltip_fg.red = 0; - gs_tooltip_fg.green = 0; - gs_tooltip_fg.blue = 0; - gdk_color_alloc( gtk_widget_get_colormap( tool->GetConnectWidget() ), &gs_tooltip_fg ); + gdk_color_alloc( gtk_widget_get_colormap( tool ), m_fg ); + gdk_color_alloc( gtk_widget_get_colormap( tool ), m_bg ); - gs_tooltip_bg.red = 65535; - gs_tooltip_bg.green = 65535; - gs_tooltip_bg.blue = 50000; - gdk_color_alloc( gtk_widget_get_colormap( tool->GetConnectWidget() ), &gs_tooltip_bg ); - - gtk_tooltips_set_colors( gs_tooltips, &gs_tooltip_bg, &gs_tooltip_fg ); + gtk_tooltips_set_colors( m_tooltips, m_bg, m_fg ); } - gtk_tooltips_set_tip( gs_tooltips, tool->GetConnectWidget(), tip, (gchar*) NULL ); + gtk_tooltips_set_tip( m_tooltips, tool, m_text, (gchar*) NULL ); } void wxToolTip::Enable( bool flag ) { - if (!gs_tooltips) gs_tooltips = gtk_tooltips_new(); + if (!Ok()) return; if (flag) - gtk_tooltips_enable( gs_tooltips ); + gtk_tooltips_enable( m_tooltips ); else - gtk_tooltips_disable( gs_tooltips ); + gtk_tooltips_disable( m_tooltips ); } void wxToolTip::SetDelay( long msecs ) { - if (!gs_tooltips) gs_tooltips = gtk_tooltips_new(); + if (!Ok()) return; - gtk_tooltips_set_delay( gs_tooltips, msecs ); + gtk_tooltips_set_delay( m_tooltips, msecs ); } diff --git a/src/gtk1/window.cpp b/src/gtk1/window.cpp index 54cc477208..3f46517907 100644 --- a/src/gtk1/window.cpp +++ b/src/gtk1/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 ) { @@ -1342,6 +1343,8 @@ wxWindow::wxWindow() m_isStaticBox = FALSE; m_acceptsFocus = FALSE; + + m_toolTip = (wxToolTip*) NULL; } wxWindow::wxWindow( wxWindow *parent, wxWindowID id, @@ -1420,7 +1423,7 @@ bool wxWindow::Create( wxWindow *parent, wxWindowID id, if ((m_windowStyle & wxTAB_TRAVERSAL) != 0) { - GTK_WIDGET_UNSET_FLAGS( m_wxwindow, GTK_CAN_FOCUS ); + GTK_WIDGET_SET_FLAGS( m_wxwindow, GTK_CAN_FOCUS ); /* changed from UNSET */ m_acceptsFocus = FALSE; } else @@ -1500,6 +1503,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 +1634,7 @@ void wxWindow::PreCreation( wxWindow *parent, wxWindowID id, m_clientData = NULL; m_isStaticBox = FALSE; + m_toolTip = (wxToolTip*) NULL; } void wxWindow::PostCreation() @@ -2458,6 +2464,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; diff --git a/utils/dialoged/src/Makefile b/utils/dialoged/src/Makefile index 05ad82cc43..d754615f73 100644 --- a/utils/dialoged/src/Makefile +++ b/utils/dialoged/src/Makefile @@ -1,3 +1,16 @@ +# +# File: Makefile +# Author: Robert Roebling +# Created: 1999 +# Updated: +# Copyright: (c) 1998 Robert Roebling +# +# Makefile for Dialog Editor (GTK version) +# +# This makefile requires wxWindows/GTK to be +# installed (possibly using "make install") +# on your system. +# CC = g++ diff --git a/utils/glcanvas/distrib/glcanvas.rsp b/utils/glcanvas/distrib/glcanvas.rsp index 045fa083bd..1c238e484d 100644 --- a/utils/glcanvas/distrib/glcanvas.rsp +++ b/utils/glcanvas/distrib/glcanvas.rsp @@ -2,15 +2,20 @@ docs/*.* win/*.cpp win/*.h win/make*.* -src/*.cpp -src/*.h -src/make*.* +gtk/*.cpp +gtk/*.h +gtk/make*.* +motif/*.cpp +motif/*.h +motif/*.txt +motif/make*.* samples/cube/*.cpp samples/cube/*.h samples/cube/*.rc samples/cube/*.ico samples/cube/*.xbm samples/cube/make*.* +samples/cube/Makefile samples/isosurf/*.cpp samples/isosurf/*.h samples/isosurf/*.rc @@ -19,6 +24,7 @@ samples/isosurf/*.xbm samples/isosurf/*.dat samples/isosurf/*.dat.gz samples/isosurf/make*.* +samples/isosurf/Makefile samples/penguin/*.cpp samples/penguin/*.c samples/penguin/*.h @@ -28,6 +34,7 @@ samples/penguin/*.xbm samples/penguin/*.xpm samples/penguin/make*.* samples/penguin/penguin.lwo +samples/penguin/Makefile diff --git a/utils/glcanvas/src/.cvsignore b/utils/glcanvas/gtk/.cvsignore similarity index 100% rename from utils/glcanvas/src/.cvsignore rename to utils/glcanvas/gtk/.cvsignore diff --git a/utils/glcanvas/src/glcanvas.cpp b/utils/glcanvas/gtk/glcanvas.cpp similarity index 100% rename from utils/glcanvas/src/glcanvas.cpp rename to utils/glcanvas/gtk/glcanvas.cpp diff --git a/utils/glcanvas/src/glcanvas.h b/utils/glcanvas/gtk/glcanvas.h similarity index 100% rename from utils/glcanvas/src/glcanvas.h rename to utils/glcanvas/gtk/glcanvas.h diff --git a/utils/glcanvas/samples/cube/Makefile b/utils/glcanvas/samples/cube/Makefile index f24f7eb8ef..6e852b2dd4 100644 --- a/utils/glcanvas/samples/cube/Makefile +++ b/utils/glcanvas/samples/cube/Makefile @@ -1,3 +1,16 @@ +# +# File: Makefile +# Author: Robert Roebling +# Created: 1999 +# Updated: +# Copyright: (c) 1998 Robert Roebling +# +# Makefile for OpenGl demo (GTK version) +# +# This makefile requires wxWindows/GTK to be +# installed (possibly using "make install") +# on your system. +# CC = g++ @@ -7,10 +20,10 @@ cube: cube.o glcanvas.o `wx-config --libs` -lMesaGL -lMesaGLU cube.o: cube.cpp - $(CC) `wx-config --cflags` -I../../src -c cube.cpp + $(CC) `wx-config --cflags` -I../../gtk -c cube.cpp -glcanvas.o: ../../src/glcanvas.cpp - $(CC) `wx-config --cflags` `gtk-config --cflags` -I../../src -c ../../src/glcanvas.cpp +glcanvas.o: ../../gtk/glcanvas.cpp + $(CC) `wx-config --cflags` `gtk-config --cflags` -I../../gtk -c ../../gtk/glcanvas.cpp clean: rm -f *.o cube diff --git a/utils/glcanvas/samples/isosurf/Makefile b/utils/glcanvas/samples/isosurf/Makefile index 7722db17b0..e004da7555 100644 --- a/utils/glcanvas/samples/isosurf/Makefile +++ b/utils/glcanvas/samples/isosurf/Makefile @@ -1,3 +1,16 @@ +# +# File: Makefile +# Author: Robert Roebling +# Created: 1999 +# Updated: +# Copyright: (c) 1998 Robert Roebling +# +# Makefile for OpenGl demo (GTK version) +# +# This makefile requires wxWindows/GTK to be +# installed (possibly using "make install") +# on your system. +# CC = g++ @@ -7,10 +20,10 @@ isosurf: isosurf.o glcanvas.o `wx-config --libs` -lMesaGL -lMesaGLU isosurf.o: isosurf.cpp - $(CC) `wx-config --cflags` -I../../src -c isosurf.cpp + $(CC) `wx-config --cflags` -I../../gtk -c isosurf.cpp -glcanvas.o: ../../src/glcanvas.cpp - $(CC) `wx-config --cflags` `gtk-config --cflags` -I../../src -c ../../src/glcanvas.cpp +glcanvas.o: ../..gtk/glcanvas.cpp + $(CC) `wx-config --cflags` `gtk-config --cflags` -I../../gtk -c ../../gtk/glcanvas.cpp clean: rm -f *.o cube diff --git a/utils/glcanvas/samples/penguin/Makefile b/utils/glcanvas/samples/penguin/Makefile index 013c6f0884..f874de9287 100644 --- a/utils/glcanvas/samples/penguin/Makefile +++ b/utils/glcanvas/samples/penguin/Makefile @@ -1,3 +1,16 @@ +# +# File: Makefile +# Author: Robert Roebling +# Created: 1999 +# Updated: +# Copyright: (c) 1998 Robert Roebling +# +# Makefile for OpenGL demo (GTK version) +# +# This makefile requires wxWindows/GTK to be +# installed (possibly using "make install") +# on your system. +# CPP = g++ CC = gcc