wxToolTip

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@1553 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Robert Roebling
1999-02-01 06:44:35 +00:00
parent f4f55a0146
commit 301cd871a2
14 changed files with 236 additions and 162 deletions

View File

@@ -3,7 +3,10 @@
# This script is creates a dir tree in ~/wxgtk_dist which # This script is creates a dir tree in ~/wxgtk_dist which
# can then be packed into an archive # can then be packed into an archive
echo This script will copy the wxGTK release files into ~/wxgtk_dist echo --------
echo This script will copy the wxGTK release files into ~/wxgtk_dist
echo --------
echo
mkdir ~/wxgtk_dist mkdir ~/wxgtk_dist
mkdir ~/wxgtk_dist/wxGTK mkdir ~/wxgtk_dist/wxGTK
@@ -668,9 +671,13 @@ cp Makefile ~/wxgtk_dist/wxGTK/samples/wxsocket
cp Makefile.in ~/wxgtk_dist/wxGTK/samples/wxsocket cp Makefile.in ~/wxgtk_dist/wxGTK/samples/wxsocket
cp *.cpp ~/wxgtk_dist/wxGTK/samples/wxsocket cp *.cpp ~/wxgtk_dist/wxGTK/samples/wxsocket
cp *.xpm ~/wxgtk_dist/wxGTK/samples/wxsocket cp *.xpm ~/wxgtk_dist/wxGTK/samples/wxsocket
cd .. cd ../..
echo LOCAL CORRECTCIONS
cd distrib/gtk
cp README.txt ~/wxgtk_dist/wxGTK/utils/wxPython
cp Setup ~/wxgtk_dist/wxGTK/utils/wxPython/src

View File

@@ -94,9 +94,6 @@ public:
#if wxUSE_DRAG_AND_DROP #if wxUSE_DRAG_AND_DROP
void SetDropTarget( wxDropTarget *dropTarget ); void SetDropTarget( wxDropTarget *dropTarget );
#endif #endif
void SetToolTip( wxToolTip *tip );
void SetToolTip( const wxString &tip );
// implementation // implementation
@@ -105,6 +102,7 @@ public:
GtkWidget *GetConnectWidget(); GtkWidget *GetConnectWidget();
bool IsOwnGtkWindow( GdkWindow *window ); bool IsOwnGtkWindow( GdkWindow *window );
void ApplyWidgetStyle(); void ApplyWidgetStyle();
void ApplyToolTip( GtkTooltips *tips, const char *tip );
GtkList *m_list; GtkList *m_list;
wxList m_clientDataList; wxList m_clientDataList;

View File

@@ -33,23 +33,21 @@ class wxToolTip: public wxObject
public: public:
wxToolTip( const wxString &tip ); wxToolTip( const wxString &tip );
~wxToolTip();
wxString GetTip(); void SetTip( const wxString &tip );
wxString GetTip() const;
wxWindow *GetWindow() const;
bool Ok() const;
void Enable( bool flag ); static void Enable( bool flag );
void SetDelay( long msecs ); static void SetDelay( long msecs );
bool Ok();
// implementation // implementation
wxString m_text; wxString m_text;
wxWindow *m_window;
GtkTooltips *m_tooltips; void Apply( wxWindow *win );
GdkColor *m_bg;
GdkColor *m_fg;
void Create( GtkWidget *tool );
}; };
#endif // __GTKTOOLTIPH__ #endif // __GTKTOOLTIPH__

View File

@@ -231,16 +231,16 @@ public:
virtual void SetToolTip( const wxString &tip ); virtual void SetToolTip( const wxString &tip );
virtual void SetToolTip( wxToolTip *tip ); virtual void SetToolTip( wxToolTip *tip );
virtual wxToolTip& GetToolTip(); virtual wxToolTip* GetToolTip();
virtual void Refresh( bool eraseBackground = TRUE, const wxRect *rect = (const wxRect *) NULL ); virtual void Refresh( bool eraseBackground = TRUE, const wxRect *rect = (const wxRect *) NULL );
virtual void Clear(); virtual void Clear();
virtual wxRegion GetUpdateRegion() const; virtual wxRegion GetUpdateRegion() const;
virtual bool IsExposed(int x, int y) const; virtual bool IsExposed( int x, int y ) const;
virtual bool IsExposed(int x, int y, int w, int h) const; virtual bool IsExposed( int x, int y, int w, int h ) const;
virtual bool IsExposed(const wxPoint& pt) const; virtual bool IsExposed( const wxPoint& pt ) const;
virtual bool IsExposed(const wxRect& rect) const; virtual bool IsExposed( const wxRect& rect ) const;
virtual wxColour GetBackgroundColour() const; virtual wxColour GetBackgroundColour() const;
virtual void SetBackgroundColour( const wxColour &colour ); virtual void SetBackgroundColour( const wxColour &colour );
@@ -320,24 +320,37 @@ public:
// implementation // implementation
virtual wxPoint GetClientAreaOrigin() const;
virtual void AdjustForParentClientOrigin( int& x, int& y, int sizeFlags );
bool HasVMT();
virtual void OnInternalIdle();
/* used by all classes in the widget creation process */
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();
/* the methods below are required because many native widgets
are composed of several subwidgets and setting a style for
the widget means setting it for all subwidgets as well.
also, it is nor clear, which native widget is the top
widget where (most of) the input goes. even tooltips have
to be applied to all subwidgets. */
virtual GtkWidget* GetConnectWidget(); virtual GtkWidget* GetConnectWidget();
virtual bool IsOwnGtkWindow( GdkWindow *window ); virtual bool IsOwnGtkWindow( GdkWindow *window );
void ConnectWidget( GtkWidget *widget ); void ConnectWidget( GtkWidget *widget );
bool HasVMT();
virtual wxPoint GetClientAreaOrigin() const;
virtual void AdjustForParentClientOrigin( int& x, int& y, int sizeFlags );
GtkStyle *GetWidgetStyle(); GtkStyle *GetWidgetStyle();
void SetWidgetStyle(); void SetWidgetStyle();
virtual void ApplyWidgetStyle(); virtual void ApplyWidgetStyle();
virtual void OnInternalIdle(); virtual void ApplyToolTip( GtkTooltips *tips, const char *tip );
/* private member variables */
wxWindow *m_parent; wxWindow *m_parent;
wxList m_children; wxList m_children;

View File

@@ -94,9 +94,6 @@ public:
#if wxUSE_DRAG_AND_DROP #if wxUSE_DRAG_AND_DROP
void SetDropTarget( wxDropTarget *dropTarget ); void SetDropTarget( wxDropTarget *dropTarget );
#endif #endif
void SetToolTip( wxToolTip *tip );
void SetToolTip( const wxString &tip );
// implementation // implementation
@@ -105,6 +102,7 @@ public:
GtkWidget *GetConnectWidget(); GtkWidget *GetConnectWidget();
bool IsOwnGtkWindow( GdkWindow *window ); bool IsOwnGtkWindow( GdkWindow *window );
void ApplyWidgetStyle(); void ApplyWidgetStyle();
void ApplyToolTip( GtkTooltips *tips, const char *tip );
GtkList *m_list; GtkList *m_list;
wxList m_clientDataList; wxList m_clientDataList;

View File

@@ -33,23 +33,21 @@ class wxToolTip: public wxObject
public: public:
wxToolTip( const wxString &tip ); wxToolTip( const wxString &tip );
~wxToolTip();
wxString GetTip(); void SetTip( const wxString &tip );
wxString GetTip() const;
wxWindow *GetWindow() const;
bool Ok() const;
void Enable( bool flag ); static void Enable( bool flag );
void SetDelay( long msecs ); static void SetDelay( long msecs );
bool Ok();
// implementation // implementation
wxString m_text; wxString m_text;
wxWindow *m_window;
GtkTooltips *m_tooltips; void Apply( wxWindow *win );
GdkColor *m_bg;
GdkColor *m_fg;
void Create( GtkWidget *tool );
}; };
#endif // __GTKTOOLTIPH__ #endif // __GTKTOOLTIPH__

View File

@@ -231,16 +231,16 @@ public:
virtual void SetToolTip( const wxString &tip ); virtual void SetToolTip( const wxString &tip );
virtual void SetToolTip( wxToolTip *tip ); virtual void SetToolTip( wxToolTip *tip );
virtual wxToolTip& GetToolTip(); virtual wxToolTip* GetToolTip();
virtual void Refresh( bool eraseBackground = TRUE, const wxRect *rect = (const wxRect *) NULL ); virtual void Refresh( bool eraseBackground = TRUE, const wxRect *rect = (const wxRect *) NULL );
virtual void Clear(); virtual void Clear();
virtual wxRegion GetUpdateRegion() const; virtual wxRegion GetUpdateRegion() const;
virtual bool IsExposed(int x, int y) const; virtual bool IsExposed( int x, int y ) const;
virtual bool IsExposed(int x, int y, int w, int h) const; virtual bool IsExposed( int x, int y, int w, int h ) const;
virtual bool IsExposed(const wxPoint& pt) const; virtual bool IsExposed( const wxPoint& pt ) const;
virtual bool IsExposed(const wxRect& rect) const; virtual bool IsExposed( const wxRect& rect ) const;
virtual wxColour GetBackgroundColour() const; virtual wxColour GetBackgroundColour() const;
virtual void SetBackgroundColour( const wxColour &colour ); virtual void SetBackgroundColour( const wxColour &colour );
@@ -320,24 +320,37 @@ public:
// implementation // implementation
virtual wxPoint GetClientAreaOrigin() const;
virtual void AdjustForParentClientOrigin( int& x, int& y, int sizeFlags );
bool HasVMT();
virtual void OnInternalIdle();
/* used by all classes in the widget creation process */
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();
/* the methods below are required because many native widgets
are composed of several subwidgets and setting a style for
the widget means setting it for all subwidgets as well.
also, it is nor clear, which native widget is the top
widget where (most of) the input goes. even tooltips have
to be applied to all subwidgets. */
virtual GtkWidget* GetConnectWidget(); virtual GtkWidget* GetConnectWidget();
virtual bool IsOwnGtkWindow( GdkWindow *window ); virtual bool IsOwnGtkWindow( GdkWindow *window );
void ConnectWidget( GtkWidget *widget ); void ConnectWidget( GtkWidget *widget );
bool HasVMT();
virtual wxPoint GetClientAreaOrigin() const;
virtual void AdjustForParentClientOrigin( int& x, int& y, int sizeFlags );
GtkStyle *GetWidgetStyle(); GtkStyle *GetWidgetStyle();
void SetWidgetStyle(); void SetWidgetStyle();
virtual void ApplyWidgetStyle(); virtual void ApplyWidgetStyle();
virtual void OnInternalIdle(); virtual void ApplyToolTip( GtkTooltips *tips, const char *tip );
/* private member variables */
wxWindow *m_parent; wxWindow *m_parent;
wxList m_children; wxList m_children;

View File

@@ -658,6 +658,13 @@ void MyPanel::OnListBoxButtons( wxCommandEvent &event )
case ID_LISTBOX_ENABLE: case ID_LISTBOX_ENABLE:
{ {
m_text->WriteText("Checkbox clicked.\n"); m_text->WriteText("Checkbox clicked.\n");
#ifdef __WXGTK__
wxCheckBox *cb = (wxCheckBox*)event.GetEventObject();
if (event.GetInt())
cb->SetToolTip( "Click to enable listbox" );
else
cb->SetToolTip( "Click to disable listbox" );
#endif
m_listbox->Enable( event.GetInt() == 0 ); m_listbox->Enable( event.GetInt() == 0 );
break; break;
} }

View File

@@ -347,7 +347,7 @@ void wxListBox::AppendCommon( const wxString &item )
#endif #endif
#endif #endif
if (m_toolTip) m_toolTip->Create( list_item ); if (m_toolTip) m_toolTip->Apply( this );
} }
void wxListBox::Append( const wxString &item ) void wxListBox::Append( const wxString &item )
@@ -676,25 +676,12 @@ int wxListBox::GetIndex( GtkWidget *item ) const
return -1; return -1;
} }
void wxListBox::SetToolTip( const wxString &tip ) void wxListBox::ApplyToolTip( GtkTooltips *tips, const char *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; GList *child = m_list->children;
while (child) while (child)
{ {
m_toolTip->Create( GTK_WIDGET( child->data ) ); gtk_tooltips_set_tip( tips, GTK_WIDGET( child->data ), tip, (gchar*) NULL );
child = child->next; child = child->next;
} }
} }

View File

@@ -16,6 +16,14 @@
#include "gtk/gtk.h" #include "gtk/gtk.h"
#include "gdk/gdk.h" #include "gdk/gdk.h"
//-----------------------------------------------------------------------------
// global data
//-----------------------------------------------------------------------------
static GtkTooltips *ss_tooltips = (GtkTooltips*) NULL;
static GdkColor ss_bg;
static GdkColor ss_fg;
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// wxToolTip // wxToolTip
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
@@ -23,62 +31,68 @@
wxToolTip::wxToolTip( const wxString &tip ) wxToolTip::wxToolTip( const wxString &tip )
{ {
m_text = tip; m_text = tip;
m_window = (wxWindow*) NULL;
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() bool wxToolTip::Ok() const
{ {
gtk_object_unref( GTK_OBJECT(m_tooltips) ); return (m_window);
delete m_fg;
delete m_bg;
} }
bool wxToolTip::Ok() wxString wxToolTip::GetTip() const
{ {
return (m_tooltips); return m_text;
} }
void wxToolTip::Create( GtkWidget *tool ) void wxToolTip::SetTip( const wxString &tip )
{ {
if (!m_tooltips) m_text = tip;
Apply( m_window );
}
void wxToolTip::Apply( wxWindow *win )
{
if (!win) return;
if (!ss_tooltips)
{ {
m_tooltips = gtk_tooltips_new(); ss_tooltips = gtk_tooltips_new();
gdk_color_alloc( gtk_widget_get_colormap( tool ), m_fg ); ss_fg.red = 0;
gdk_color_alloc( gtk_widget_get_colormap( tool ), m_bg ); ss_fg.green = 0;
ss_fg.blue = 0;
gdk_color_alloc( gtk_widget_get_default_colormap(), &ss_fg );
gtk_tooltips_set_colors( m_tooltips, m_bg, m_fg ); ss_bg.red = 65535;
ss_bg.green = 65535;
ss_bg.blue = 50000;
gdk_color_alloc( gtk_widget_get_default_colormap(), &ss_bg );
gtk_tooltips_set_colors( ss_tooltips, &ss_bg, &ss_fg );
} }
gtk_tooltips_set_tip( m_tooltips, tool, m_text, (gchar*) NULL ); m_window = win;
if (m_text.IsEmpty())
m_window->ApplyToolTip( ss_tooltips, (char*) NULL );
else
m_window->ApplyToolTip( ss_tooltips, m_text );
} }
void wxToolTip::Enable( bool flag ) void wxToolTip::Enable( bool flag )
{ {
if (!Ok()) return; if (!ss_tooltips) return;
if (flag) if (flag)
gtk_tooltips_enable( m_tooltips ); gtk_tooltips_enable( ss_tooltips );
else else
gtk_tooltips_disable( m_tooltips ); gtk_tooltips_disable( ss_tooltips );
} }
void wxToolTip::SetDelay( long msecs ) void wxToolTip::SetDelay( long msecs )
{ {
if (!Ok()) return; if (!ss_tooltips) return;
gtk_tooltips_set_delay( m_tooltips, msecs ); gtk_tooltips_set_delay( ss_tooltips, msecs );
} }

View File

@@ -2475,24 +2475,44 @@ void wxWindow::Clear()
void wxWindow::SetToolTip( const wxString &tip ) void wxWindow::SetToolTip( const wxString &tip )
{ {
SetToolTip( new wxToolTip( tip ) ); if (m_toolTip)
{
m_toolTip->SetTip( tip );
}
else
{
m_toolTip = new wxToolTip( tip );
m_toolTip->Apply( this );
}
if (tip.IsEmpty())
{
delete m_toolTip;
m_toolTip = (wxToolTip*) NULL;
}
} }
void wxWindow::SetToolTip( wxToolTip *tip ) void wxWindow::SetToolTip( wxToolTip *tip )
{ {
if (m_toolTip) delete m_toolTip; if (m_toolTip)
{
m_toolTip->SetTip( (char*) NULL );
delete m_toolTip;
}
m_toolTip = tip; m_toolTip = tip;
if (m_toolTip) m_toolTip->Create( GetConnectWidget() ); if (m_toolTip) m_toolTip->Apply( this );
} }
wxToolTip& wxWindow::GetToolTip() void wxWindow::ApplyToolTip( GtkTooltips *tips, const char *tip )
{ {
if (!m_toolTip) gtk_tooltips_set_tip( tips, GetConnectWidget(), tip, (gchar*) NULL );
wxLogError( "No tooltip set." ); }
return *m_toolTip; wxToolTip* wxWindow::GetToolTip()
{
return m_toolTip;
} }
wxColour wxWindow::GetBackgroundColour() const wxColour wxWindow::GetBackgroundColour() const

View File

@@ -347,7 +347,7 @@ void wxListBox::AppendCommon( const wxString &item )
#endif #endif
#endif #endif
if (m_toolTip) m_toolTip->Create( list_item ); if (m_toolTip) m_toolTip->Apply( this );
} }
void wxListBox::Append( const wxString &item ) void wxListBox::Append( const wxString &item )
@@ -676,25 +676,12 @@ int wxListBox::GetIndex( GtkWidget *item ) const
return -1; return -1;
} }
void wxListBox::SetToolTip( const wxString &tip ) void wxListBox::ApplyToolTip( GtkTooltips *tips, const char *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; GList *child = m_list->children;
while (child) while (child)
{ {
m_toolTip->Create( GTK_WIDGET( child->data ) ); gtk_tooltips_set_tip( tips, GTK_WIDGET( child->data ), tip, (gchar*) NULL );
child = child->next; child = child->next;
} }
} }

View File

@@ -16,6 +16,14 @@
#include "gtk/gtk.h" #include "gtk/gtk.h"
#include "gdk/gdk.h" #include "gdk/gdk.h"
//-----------------------------------------------------------------------------
// global data
//-----------------------------------------------------------------------------
static GtkTooltips *ss_tooltips = (GtkTooltips*) NULL;
static GdkColor ss_bg;
static GdkColor ss_fg;
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// wxToolTip // wxToolTip
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
@@ -23,62 +31,68 @@
wxToolTip::wxToolTip( const wxString &tip ) wxToolTip::wxToolTip( const wxString &tip )
{ {
m_text = tip; m_text = tip;
m_window = (wxWindow*) NULL;
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() bool wxToolTip::Ok() const
{ {
gtk_object_unref( GTK_OBJECT(m_tooltips) ); return (m_window);
delete m_fg;
delete m_bg;
} }
bool wxToolTip::Ok() wxString wxToolTip::GetTip() const
{ {
return (m_tooltips); return m_text;
} }
void wxToolTip::Create( GtkWidget *tool ) void wxToolTip::SetTip( const wxString &tip )
{ {
if (!m_tooltips) m_text = tip;
Apply( m_window );
}
void wxToolTip::Apply( wxWindow *win )
{
if (!win) return;
if (!ss_tooltips)
{ {
m_tooltips = gtk_tooltips_new(); ss_tooltips = gtk_tooltips_new();
gdk_color_alloc( gtk_widget_get_colormap( tool ), m_fg ); ss_fg.red = 0;
gdk_color_alloc( gtk_widget_get_colormap( tool ), m_bg ); ss_fg.green = 0;
ss_fg.blue = 0;
gdk_color_alloc( gtk_widget_get_default_colormap(), &ss_fg );
gtk_tooltips_set_colors( m_tooltips, m_bg, m_fg ); ss_bg.red = 65535;
ss_bg.green = 65535;
ss_bg.blue = 50000;
gdk_color_alloc( gtk_widget_get_default_colormap(), &ss_bg );
gtk_tooltips_set_colors( ss_tooltips, &ss_bg, &ss_fg );
} }
gtk_tooltips_set_tip( m_tooltips, tool, m_text, (gchar*) NULL ); m_window = win;
if (m_text.IsEmpty())
m_window->ApplyToolTip( ss_tooltips, (char*) NULL );
else
m_window->ApplyToolTip( ss_tooltips, m_text );
} }
void wxToolTip::Enable( bool flag ) void wxToolTip::Enable( bool flag )
{ {
if (!Ok()) return; if (!ss_tooltips) return;
if (flag) if (flag)
gtk_tooltips_enable( m_tooltips ); gtk_tooltips_enable( ss_tooltips );
else else
gtk_tooltips_disable( m_tooltips ); gtk_tooltips_disable( ss_tooltips );
} }
void wxToolTip::SetDelay( long msecs ) void wxToolTip::SetDelay( long msecs )
{ {
if (!Ok()) return; if (!ss_tooltips) return;
gtk_tooltips_set_delay( m_tooltips, msecs ); gtk_tooltips_set_delay( ss_tooltips, msecs );
} }

View File

@@ -2475,24 +2475,44 @@ void wxWindow::Clear()
void wxWindow::SetToolTip( const wxString &tip ) void wxWindow::SetToolTip( const wxString &tip )
{ {
SetToolTip( new wxToolTip( tip ) ); if (m_toolTip)
{
m_toolTip->SetTip( tip );
}
else
{
m_toolTip = new wxToolTip( tip );
m_toolTip->Apply( this );
}
if (tip.IsEmpty())
{
delete m_toolTip;
m_toolTip = (wxToolTip*) NULL;
}
} }
void wxWindow::SetToolTip( wxToolTip *tip ) void wxWindow::SetToolTip( wxToolTip *tip )
{ {
if (m_toolTip) delete m_toolTip; if (m_toolTip)
{
m_toolTip->SetTip( (char*) NULL );
delete m_toolTip;
}
m_toolTip = tip; m_toolTip = tip;
if (m_toolTip) m_toolTip->Create( GetConnectWidget() ); if (m_toolTip) m_toolTip->Apply( this );
} }
wxToolTip& wxWindow::GetToolTip() void wxWindow::ApplyToolTip( GtkTooltips *tips, const char *tip )
{ {
if (!m_toolTip) gtk_tooltips_set_tip( tips, GetConnectWidget(), tip, (gchar*) NULL );
wxLogError( "No tooltip set." ); }
return *m_toolTip; wxToolTip* wxWindow::GetToolTip()
{
return m_toolTip;
} }
wxColour wxWindow::GetBackgroundColour() const wxColour wxWindow::GetBackgroundColour() const