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