tipdlg.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. /////////////////////////////////////////////////////////////////////////////
  2. // Name: tipdlg.h
  3. // Purpose: interface of wxTipProvider
  4. // Author: wxWidgets team
  5. // Licence: wxWindows licence
  6. /////////////////////////////////////////////////////////////////////////////
  7. /**
  8. @class wxTipProvider
  9. This is the class used together with wxShowTip() function.
  10. It must implement wxTipProvider::GetTip function and return the
  11. current tip from it (different tip each time it is called).
  12. You will never use this class yourself, but you need it to show startup tips
  13. with wxShowTip. Also, if you want to get the tips text from elsewhere than a
  14. simple text file, you will want to derive a new class from wxTipProvider and
  15. use it instead of the one returned by wxCreateFileTipProvider().
  16. @library{wxadv}
  17. @category{misc}
  18. @see @ref overview_tips, ::wxShowTip
  19. */
  20. class wxTipProvider
  21. {
  22. public:
  23. /**
  24. Constructor.
  25. @param currentTip
  26. The starting tip index.
  27. */
  28. wxTipProvider(size_t currentTip);
  29. virtual ~wxTipProvider();
  30. /**
  31. Returns the index of the current tip (i.e.\ the one which would be returned by GetTip()).
  32. The program usually remembers the value returned by this function after calling
  33. wxShowTip(). Note that it is not the same as the value which was passed to
  34. wxShowTip + 1 because the user might have pressed the "Next" button in
  35. the tip dialog.
  36. */
  37. size_t GetCurrentTip() const;
  38. /**
  39. Return the text of the current tip and pass to the next one.
  40. This function is pure virtual, it should be implemented in the derived classes.
  41. */
  42. virtual wxString GetTip() = 0;
  43. /**
  44. Returns a modified tip.
  45. This function will be called immediately after read, and before being check
  46. whether it is a comment, an empty string or a string to translate.
  47. You can optionally override this in your custom user-derived class
  48. to optionally to modify the tip as soon as it is read. You can return any
  49. modification to the string. If you return wxEmptyString, then this tip is
  50. skipped, and the next one is read.
  51. */
  52. virtual wxString PreprocessTip(const wxString& tip);
  53. };
  54. // ============================================================================
  55. // Global functions/macros
  56. // ============================================================================
  57. /** @addtogroup group_funcmacro_dialog */
  58. //@{
  59. /**
  60. This function creates a wxTipProvider which may be used with wxShowTip().
  61. @param filename
  62. The name of the file containing the tips, one per line.
  63. @param currentTip
  64. The index of the first tip to show. Normally this index is remembered
  65. between the 2 program runs.
  66. @see @ref overview_tips
  67. @header{wx/tipdlg.h}
  68. */
  69. wxTipProvider* wxCreateFileTipProvider(const wxString& filename,
  70. size_t currentTip);
  71. /**
  72. This function shows a "startup tip" to the user. The return value is the
  73. state of the "Show tips at startup" checkbox.
  74. @param parent
  75. The parent window for the modal dialog.
  76. @param tipProvider
  77. An object which is used to get the text of the tips. It may be created
  78. with the wxCreateFileTipProvider() function.
  79. @param showAtStartup
  80. Should be true if startup tips are shown, false otherwise. This is
  81. used as the initial value for "Show tips at startup" checkbox which is
  82. shown in the tips dialog.
  83. @see @ref overview_tips
  84. @header{wx/tipdlg.h}
  85. */
  86. bool wxShowTip(wxWindow *parent,
  87. wxTipProvider *tipProvider,
  88. bool showAtStartup = true);
  89. //@}