]> git.saurik.com Git - wxWidgets.git/blob - docs/latex/wx/ttips.tex
added wxEXPLICIT macro
[wxWidgets.git] / docs / latex / wx / ttips.tex
1 \section{wxTipProvider overview}\label{tipsoverview}
2
3 Many "modern" Windows programs have a feature (some would say annoyance) of
4 presenting the user tips at program startup. While this is probably useless to
5 the advanced users of the program, the experience shows that the tips may be
6 quite helpful for the novices and so more and more programs now do this.
7
8 For a wxWindows programmer, implementing this feature is extremely easy. To
9 show a tip, it is enough to just call \helpref{wxShowTip}{wxshowtip} function
10 like this:
11
12 \begin{verbatim}
13 if ( ...show tips at startup?... )
14 {
15 wxTipProvider *tipProvider = wxCreateFileTipProvider("tips.txt", 0);
16 wxShowTip(windowParent, tipProvider);
17 delete tipProvider;
18 }
19 \end{verbatim}
20
21 Of course, you need to get the text of the tips from somewhere - in the example
22 above, the text is supposed to be in the file tips.txt from where it is read by
23 the {\it tip provider}. The tip provider is just an object of a class deriving
24 from \helpref{wxTipProvider}{wxtipprovider}. It has to implement one pure
25 virtual function of the base class: \helpref{GetTip}{wxtipprovidergettip}.
26 In the case of the tip provider created by
27 \helpref{wxCreateFileTipProvider}{wxcreatefiletipprovider}, the tips are just
28 the lines of the text file.
29
30 If you want to implement your own tip provider (for example, if you wish to
31 hardcode the tips inside your program), you just have to derive another class
32 from wxTipProvider and pass a pointer to the object of this class to wxShowTip
33 - then you don't need wxCreateFileTipProvider at all.
34
35 Finally, you will probably want to save somewhere the index of the tip last
36 shown - so that the program doesn't always show the same tip on startup. As you
37 also need to remember whether to show tips or not (you shouldn't do it if the
38 user unchecked "Show tips on startup" checkbox in the dialog), you will
39 probably want to store both the index of the
40 last shown tip (as returned by
41 \helpref{wxTipProvider::GetCurrentTip}{wxtipprovidergetcurrenttip} and the flag
42 telling whether to show the tips at startup at all.
43