Added wxToolTip

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@1472 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Robert Roebling 1999-01-25 13:57:06 +00:00
parent d2f621342b
commit 90b1b133da
7 changed files with 248 additions and 0 deletions

44
include/wx/gtk/tooltip.h Normal file
View File

@ -0,0 +1,44 @@
/////////////////////////////////////////////////////////////////////////////
// Name: tooltip.h
// Purpose:
// Author: Robert Roebling
// Id: $Id$
// Copyright: (c) 1998 Robert Roebling, Julian Smart and Markus Holzem
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef __GTKTOOLTIPH__
#define __GTKTOOLTIPH__
#ifdef __GNUG__
#pragma interface
#endif
#include "wx/defs.h"
#include "wx/object.h"
#include "wx/window.h"
//-----------------------------------------------------------------------------
// classes
//-----------------------------------------------------------------------------
class wxToolTip;
//-----------------------------------------------------------------------------
// wxToolTip
//-----------------------------------------------------------------------------
class wxToolTip: public wxObject
{
public:
wxToolTip() {}
static void Add( wxWindow *tool, const wxString &tip );
static void Enable( bool flag );
static void SetDelay( long msecs );
};
#endif // __GTKTOOLTIPH__

44
include/wx/gtk1/tooltip.h Normal file
View File

@ -0,0 +1,44 @@
/////////////////////////////////////////////////////////////////////////////
// Name: tooltip.h
// Purpose:
// Author: Robert Roebling
// Id: $Id$
// Copyright: (c) 1998 Robert Roebling, Julian Smart and Markus Holzem
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef __GTKTOOLTIPH__
#define __GTKTOOLTIPH__
#ifdef __GNUG__
#pragma interface
#endif
#include "wx/defs.h"
#include "wx/object.h"
#include "wx/window.h"
//-----------------------------------------------------------------------------
// classes
//-----------------------------------------------------------------------------
class wxToolTip;
//-----------------------------------------------------------------------------
// wxToolTip
//-----------------------------------------------------------------------------
class wxToolTip: public wxObject
{
public:
wxToolTip() {}
static void Add( wxWindow *tool, const wxString &tip );
static void Enable( bool flag );
static void SetDelay( long msecs );
};
#endif // __GTKTOOLTIPH__

19
include/wx/tooltip.h Normal file
View File

@ -0,0 +1,19 @@
#ifndef _WX_TOOLTIP_H_BASE_
#define _WX_TOOLTIP_H_BASE_
#if defined(__WXMSW__)
#include "wx/msw/tooltip.h"
#elif defined(__WXMOTIF__)
#include "wx/motif/tooltip.h"
#elif defined(__WXGTK__)
#include "wx/gtk/tooltip.h"
#elif defined(__WXQT__)
#include "wx/qt/tooltip.h"
#elif defined(__WXMAC__)
#include "wx/mac/tooltip.h"
#elif defined(__WXSTUBS__)
#include "wx/stubs/tooltip.h"
#endif
#endif
// _WX_TOOLTIP_H_BASE_

View File

@ -28,6 +28,7 @@
#include "wx/imaglist.h"
#include "wx/spinbutt.h"
#include "wx/clipbrd.h"
#include "wx/tooltip.h"
#if defined(__WXGTK__) || defined(__WXMOTIF__)
#define USE_XPM
@ -336,6 +337,7 @@ 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) );
wxToolTip::Add( button, "Press here to set italic font" );
// button->SetForegroundColour( "red" );
m_checkbox = new wxCheckBox( panel, ID_LISTBOX_ENABLE, "Disable", wxPoint(20,130), wxSize(140,30) );
m_checkbox->SetValue(FALSE);

View File

@ -116,6 +116,7 @@ LIB_CPP_SRC=\
gtk/tbargtk.cpp \
gtk/textctrl.cpp \
gtk/timer.cpp \
gtk/tooltip.cpp \
gtk/utilsgtk.cpp \
gtk/utilsres.cpp \
gtk/window.cpp \

69
src/gtk/tooltip.cpp Normal file
View File

@ -0,0 +1,69 @@
/////////////////////////////////////////////////////////////////////////////
// Name: tooltip.cpp
// Purpose:
// Author: Robert Roebling
// Id: $Id$
// Copyright: (c) 1998 Robert Roebling
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifdef __GNUG__
#pragma implementation "tooltip.h"
#endif
#include "wx/tooltip.h"
#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 )
{
if (!gs_tooltips)
{
gs_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 );
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_tip( gs_tooltips, tool->GetConnectWidget(), tip, (gchar*) NULL );
}
void wxToolTip::Enable( bool flag )
{
if (!gs_tooltips) gs_tooltips = gtk_tooltips_new();
if (flag)
gtk_tooltips_enable( gs_tooltips );
else
gtk_tooltips_disable( gs_tooltips );
}
void wxToolTip::SetDelay( long msecs )
{
if (!gs_tooltips) gs_tooltips = gtk_tooltips_new();
gtk_tooltips_set_delay( gs_tooltips, msecs );
}

69
src/gtk1/tooltip.cpp Normal file
View File

@ -0,0 +1,69 @@
/////////////////////////////////////////////////////////////////////////////
// Name: tooltip.cpp
// Purpose:
// Author: Robert Roebling
// Id: $Id$
// Copyright: (c) 1998 Robert Roebling
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifdef __GNUG__
#pragma implementation "tooltip.h"
#endif
#include "wx/tooltip.h"
#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 )
{
if (!gs_tooltips)
{
gs_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 );
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_tip( gs_tooltips, tool->GetConnectWidget(), tip, (gchar*) NULL );
}
void wxToolTip::Enable( bool flag )
{
if (!gs_tooltips) gs_tooltips = gtk_tooltips_new();
if (flag)
gtk_tooltips_enable( gs_tooltips );
else
gtk_tooltips_disable( gs_tooltips );
}
void wxToolTip::SetDelay( long msecs )
{
if (!gs_tooltips) gs_tooltips = gtk_tooltips_new();
gtk_tooltips_set_delay( gs_tooltips, msecs );
}