tipdlg.h 3.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. ///////////////////////////////////////////////////////////////////////////////
  2. // Name: wx/tipdlg.h
  3. // Purpose: declaration of wxTipDialog
  4. // Author: Vadim Zeitlin
  5. // Modified by:
  6. // Created: 28.06.99
  7. // Copyright: (c) Vadim Zeitlin
  8. // Licence: wxWindows licence
  9. ///////////////////////////////////////////////////////////////////////////////
  10. #ifndef _WX_TIPDLG_H_
  11. #define _WX_TIPDLG_H_
  12. // ----------------------------------------------------------------------------
  13. // headers which we must include here
  14. // ----------------------------------------------------------------------------
  15. #include "wx/defs.h"
  16. #if wxUSE_STARTUP_TIPS
  17. #include "wx/textfile.h"
  18. // ----------------------------------------------------------------------------
  19. // wxTipProvider - a class which is used by wxTipDialog to get the text of the
  20. // tips
  21. // ----------------------------------------------------------------------------
  22. // the abstract base class: it provides the tips, i.e. implements the GetTip()
  23. // function which returns the new tip each time it's called. To support this,
  24. // wxTipProvider evidently needs some internal state which is the tip "index"
  25. // and which should be saved/restored by the program to not always show one and
  26. // the same tip (of course, you may use random starting position as well...)
  27. class WXDLLIMPEXP_ADV wxTipProvider
  28. {
  29. public:
  30. wxTipProvider(size_t currentTip) { m_currentTip = currentTip; }
  31. // get the current tip and update the internal state to return the next tip
  32. // when called for the next time
  33. virtual wxString GetTip() = 0;
  34. // get the current tip "index" (or whatever allows the tip provider to know
  35. // from where to start the next time)
  36. size_t GetCurrentTip() const { return m_currentTip; }
  37. // Allows any user-derived class to optionally override this function to
  38. // modify the tip as soon as it is read. If return wxEmptyString, then
  39. // the tip is skipped, and the next one is read.
  40. virtual wxString PreprocessTip(const wxString& tip) { return tip; }
  41. // virtual dtor for the base class
  42. virtual ~wxTipProvider() { }
  43. protected:
  44. size_t m_currentTip;
  45. };
  46. // a function which returns an implementation of wxTipProvider using the
  47. // specified text file as the source of tips (each line is a tip).
  48. //
  49. // NB: the caller is responsible for deleting the pointer!
  50. #if wxUSE_TEXTFILE
  51. WXDLLIMPEXP_ADV wxTipProvider *wxCreateFileTipProvider(const wxString& filename,
  52. size_t currentTip);
  53. #endif // wxUSE_TEXTFILE
  54. // ----------------------------------------------------------------------------
  55. // wxTipDialog
  56. // ----------------------------------------------------------------------------
  57. // A dialog which shows a "tip" - a short and helpful messages describing to
  58. // the user some program characteristic. Many programs show the tips at
  59. // startup, so the dialog has "Show tips on startup" checkbox which allows to
  60. // the user to disable this (however, it's the program which should show, or
  61. // not, the dialog on startup depending on its value, not this class).
  62. //
  63. // The function returns true if this checkbox is checked, false otherwise.
  64. WXDLLIMPEXP_ADV bool wxShowTip(wxWindow *parent,
  65. wxTipProvider *tipProvider,
  66. bool showAtStartup = true);
  67. #endif // wxUSE_STARTUP_TIPS
  68. #endif // _WX_TIPDLG_H_