tipwin.h 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. ///////////////////////////////////////////////////////////////////////////////
  2. // Name: wx/tipwin.h
  3. // Purpose: wxTipWindow is a window like the one typically used for
  4. // showing the tooltips
  5. // Author: Vadim Zeitlin
  6. // Modified by:
  7. // Created: 10.09.00
  8. // Copyright: (c) 2000 Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr>
  9. // Licence: wxWindows licence
  10. ///////////////////////////////////////////////////////////////////////////////
  11. #ifndef _WX_TIPWIN_H_
  12. #define _WX_TIPWIN_H_
  13. #if wxUSE_TIPWINDOW
  14. #if wxUSE_POPUPWIN
  15. #include "wx/popupwin.h"
  16. #define wxTipWindowBase wxPopupTransientWindow
  17. #else
  18. #include "wx/frame.h"
  19. #define wxTipWindowBase wxFrame
  20. #endif
  21. #include "wx/arrstr.h"
  22. class WXDLLIMPEXP_FWD_CORE wxTipWindowView;
  23. // ----------------------------------------------------------------------------
  24. // wxTipWindow
  25. // ----------------------------------------------------------------------------
  26. class WXDLLIMPEXP_CORE wxTipWindow : public wxTipWindowBase
  27. {
  28. public:
  29. // the mandatory ctor parameters are: the parent window and the text to
  30. // show
  31. //
  32. // optionally you may also specify the length at which the lines are going
  33. // to be broken in rows (100 pixels by default)
  34. //
  35. // windowPtr and rectBound are just passed to SetTipWindowPtr() and
  36. // SetBoundingRect() - see below
  37. wxTipWindow(wxWindow *parent,
  38. const wxString& text,
  39. wxCoord maxLength = 100,
  40. wxTipWindow** windowPtr = NULL,
  41. wxRect *rectBound = NULL);
  42. virtual ~wxTipWindow();
  43. // If windowPtr is not NULL the given address will be NULLed when the
  44. // window has closed
  45. void SetTipWindowPtr(wxTipWindow** windowPtr) { m_windowPtr = windowPtr; }
  46. // If rectBound is not NULL, the window will disappear automatically when
  47. // the mouse leave the specified rect: note that rectBound should be in the
  48. // screen coordinates!
  49. void SetBoundingRect(const wxRect& rectBound);
  50. // Hide and destroy the window
  51. void Close();
  52. protected:
  53. // called by wxTipWindowView only
  54. bool CheckMouseInBounds(const wxPoint& pos);
  55. // event handlers
  56. void OnMouseClick(wxMouseEvent& event);
  57. #if !wxUSE_POPUPWIN
  58. void OnActivate(wxActivateEvent& event);
  59. void OnKillFocus(wxFocusEvent& event);
  60. #else // wxUSE_POPUPWIN
  61. virtual void OnDismiss();
  62. #endif // wxUSE_POPUPWIN/!wxUSE_POPUPWIN
  63. private:
  64. wxArrayString m_textLines;
  65. wxCoord m_heightLine;
  66. wxTipWindowView *m_view;
  67. wxTipWindow** m_windowPtr;
  68. wxRect m_rectBound;
  69. DECLARE_EVENT_TABLE()
  70. friend class wxTipWindowView;
  71. wxDECLARE_NO_COPY_CLASS(wxTipWindow);
  72. };
  73. #endif // wxUSE_TIPWINDOW
  74. #endif // _WX_TIPWIN_H_