1999-01-31 18:38:10 -05:00
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
2006-07-24 10:04:31 -04:00
|
|
|
// Name: wx/msw/tooltip.h
|
1999-01-31 18:38:10 -05:00
|
|
|
// Purpose: wxToolTip class - tooltip control
|
|
|
|
// Author: Vadim Zeitlin
|
|
|
|
// Modified by:
|
|
|
|
// Created: 31.01.99
|
|
|
|
// RCS-ID: $Id$
|
|
|
|
// Copyright: (c) 1999 Robert Roebling, Vadim Zeitlin
|
2004-05-23 16:53:33 -04:00
|
|
|
// Licence: wxWindows licence
|
1999-01-31 18:38:10 -05:00
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2005-09-25 16:49:40 -04:00
|
|
|
#ifndef _WX_MSW_TOOLTIP_H_
|
|
|
|
#define _WX_MSW_TOOLTIP_H_
|
|
|
|
|
2006-01-06 07:54:44 -05:00
|
|
|
#include "wx/object.h"
|
2009-04-28 05:39:52 -04:00
|
|
|
#include "wx/gdicmn.h"
|
2006-01-06 07:54:44 -05:00
|
|
|
|
2007-07-09 06:09:52 -04:00
|
|
|
class WXDLLIMPEXP_FWD_CORE wxWindow;
|
2010-11-07 08:12:16 -05:00
|
|
|
class wxToolTipOtherWindows;
|
2006-07-24 10:04:31 -04:00
|
|
|
|
2008-03-26 11:06:00 -04:00
|
|
|
class WXDLLIMPEXP_CORE wxToolTip : public wxObject
|
1999-01-31 18:38:10 -05:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
// ctor & dtor
|
|
|
|
wxToolTip(const wxString &tip);
|
|
|
|
virtual ~wxToolTip();
|
2009-08-21 06:41:26 -04:00
|
|
|
|
2009-04-26 09:37:16 -04:00
|
|
|
// ctor used by wxStatusBar to associate a tooltip to a portion of
|
|
|
|
// the status bar window:
|
2009-08-21 06:41:26 -04:00
|
|
|
wxToolTip(wxWindow* win, unsigned int id,
|
2009-04-26 09:37:16 -04:00
|
|
|
const wxString &tip, const wxRect& rc);
|
1999-01-31 18:38:10 -05:00
|
|
|
|
|
|
|
// accessors
|
|
|
|
// tip text
|
|
|
|
void SetTip(const wxString& tip);
|
|
|
|
const wxString& GetTip() const { return m_text; }
|
|
|
|
|
|
|
|
// the window we're associated with
|
|
|
|
void SetWindow(wxWindow *win);
|
|
|
|
wxWindow *GetWindow() const { return m_window; }
|
|
|
|
|
1999-02-14 16:59:48 -05:00
|
|
|
// controlling tooltip behaviour: globally change tooltip parameters
|
1999-01-31 18:38:10 -05:00
|
|
|
// enable or disable the tooltips globally
|
1999-02-14 16:59:48 -05:00
|
|
|
static void Enable(bool flag);
|
1999-01-31 18:38:10 -05:00
|
|
|
// set the delay after which the tooltip appears
|
1999-02-14 16:59:48 -05:00
|
|
|
static void SetDelay(long milliseconds);
|
2009-01-23 08:26:20 -05:00
|
|
|
// set the delay after which the tooltip disappears or how long the
|
|
|
|
// tooltip remains visible
|
2007-08-15 08:57:36 -04:00
|
|
|
static void SetAutoPop(long milliseconds);
|
|
|
|
// set the delay between subsequent tooltips to appear
|
|
|
|
static void SetReshow(long milliseconds);
|
2009-01-23 08:26:20 -05:00
|
|
|
// set maximum width for the new tooltips: -1 disables wrapping
|
|
|
|
// entirely, 0 restores the default behaviour
|
|
|
|
static void SetMaxWidth(int width);
|
1999-01-31 18:38:10 -05:00
|
|
|
|
2000-01-23 18:23:46 -05:00
|
|
|
// implementation only from now on
|
|
|
|
// -------------------------------
|
|
|
|
|
2009-04-26 09:37:16 -04:00
|
|
|
// should be called in response to WM_MOUSEMOVE
|
2006-05-04 11:58:29 -04:00
|
|
|
static void RelayEvent(WXMSG *msg);
|
1999-01-31 18:38:10 -05:00
|
|
|
|
2005-02-27 20:22:35 -05:00
|
|
|
// add a window to the tooltip control
|
|
|
|
void Add(WXHWND hwnd);
|
|
|
|
|
2006-05-04 11:51:38 -04:00
|
|
|
// remove any tooltip from the window
|
2009-04-26 09:37:16 -04:00
|
|
|
static void Remove(WXHWND hwnd, unsigned int id, const wxRect& rc);
|
|
|
|
|
2010-11-07 08:12:16 -05:00
|
|
|
// Set the rectangle we're associated with. This rectangle is only used for
|
|
|
|
// the main window, not any sub-windows added with Add() so in general it
|
|
|
|
// makes sense to use it for tooltips associated with a single window only.
|
2009-04-26 09:37:16 -04:00
|
|
|
void SetRect(const wxRect& rc);
|
2006-05-04 11:51:38 -04:00
|
|
|
|
1999-01-31 18:38:10 -05:00
|
|
|
private:
|
2010-11-07 08:12:16 -05:00
|
|
|
// Adds a window other than our main m_window to this tooltip.
|
|
|
|
void DoAddOtherWindow(WXHWND hWnd);
|
|
|
|
|
|
|
|
// Perform the specified operation for the given window only.
|
|
|
|
void DoSetTip(WXHWND hWnd);
|
|
|
|
void DoRemove(WXHWND hWnd);
|
|
|
|
|
|
|
|
// Call the given function for all windows we're associated with.
|
|
|
|
void DoForAllWindows(void (wxToolTip::*func)(WXHWND));
|
|
|
|
|
|
|
|
|
2000-01-23 18:23:46 -05:00
|
|
|
// the one and only one tooltip control we use - never access it directly
|
|
|
|
// but use GetToolTipCtrl() which will create it when needed
|
1999-11-25 18:28:41 -05:00
|
|
|
static WXHWND ms_hwndTT;
|
|
|
|
|
|
|
|
// create the tooltip ctrl if it doesn't exist yet and return its HWND
|
2000-01-23 18:23:46 -05:00
|
|
|
static WXHWND GetToolTipCtrl();
|
1999-01-31 18:38:10 -05:00
|
|
|
|
2009-01-23 08:26:20 -05:00
|
|
|
// new tooltip maximum width, defaults to min(display width, 400)
|
|
|
|
static int ms_maxWidth;
|
|
|
|
|
1999-01-31 18:38:10 -05:00
|
|
|
// remove this tooltip from the tooltip control
|
|
|
|
void Remove();
|
|
|
|
|
|
|
|
wxString m_text; // tooltip text
|
2010-11-07 08:12:16 -05:00
|
|
|
wxWindow* m_window; // main window we're associated with
|
|
|
|
wxToolTipOtherWindows *m_others; // other windows associated with it or NULL
|
2009-04-26 09:37:16 -04:00
|
|
|
wxRect m_rect; // the rect of the window for which this tooltip is shown
|
|
|
|
// (or a rect with width/height == 0 to show it for the entire window)
|
|
|
|
unsigned int m_id; // the id of this tooltip (ignored when m_rect width/height is 0)
|
2001-07-13 23:23:30 -04:00
|
|
|
|
|
|
|
DECLARE_ABSTRACT_CLASS(wxToolTip)
|
2009-02-08 06:45:59 -05:00
|
|
|
wxDECLARE_NO_COPY_CLASS(wxToolTip);
|
1999-01-31 18:38:10 -05:00
|
|
|
};
|
1999-09-13 15:19:57 -04:00
|
|
|
|
2005-09-25 16:49:40 -04:00
|
|
|
#endif // _WX_MSW_TOOLTIP_H_
|