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
This commit is contained in:
Robert Roebling
1999-01-27 17:15:34 +00:00
parent 56b9c74101
commit b11708106f
24 changed files with 344 additions and 98 deletions

View File

@@ -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;
}
}

View File

@@ -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 );
}

View File

@@ -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;