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

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

View File

@@ -16,6 +16,14 @@
#include "gtk/gtk.h"
#include "gdk/gdk.h"
//-----------------------------------------------------------------------------
// global data
//-----------------------------------------------------------------------------
static GtkTooltips *ss_tooltips = (GtkTooltips*) NULL;
static GdkColor ss_bg;
static GdkColor ss_fg;
//-----------------------------------------------------------------------------
// wxToolTip
//-----------------------------------------------------------------------------
@@ -23,62 +31,68 @@
wxToolTip::wxToolTip( const wxString &tip )
{
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;
m_window = (wxWindow*) NULL;
}
wxToolTip::~wxToolTip()
bool wxToolTip::Ok() const
{
gtk_object_unref( GTK_OBJECT(m_tooltips) );
delete m_fg;
delete m_bg;
return (m_window);
}
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 );
gdk_color_alloc( gtk_widget_get_colormap( tool ), m_bg );
ss_fg.red = 0;
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 )
{
if (!Ok()) return;
if (!ss_tooltips) return;
if (flag)
gtk_tooltips_enable( m_tooltips );
gtk_tooltips_enable( ss_tooltips );
else
gtk_tooltips_disable( m_tooltips );
gtk_tooltips_disable( ss_tooltips );
}
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 )
{
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 )
{
if (m_toolTip) delete m_toolTip;
if (m_toolTip)
{
m_toolTip->SetTip( (char*) NULL );
delete m_toolTip;
}
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)
wxLogError( "No tooltip set." );
return *m_toolTip;
gtk_tooltips_set_tip( tips, GetConnectWidget(), tip, (gchar*) NULL );
}
wxToolTip* wxWindow::GetToolTip()
{
return m_toolTip;
}
wxColour wxWindow::GetBackgroundColour() const