]> git.saurik.com Git - wxWidgets.git/blame - docs/doxygen/overviews/tips.h
Use flat generic status bar by default and add wxSB_SUNKEN.
[wxWidgets.git] / docs / doxygen / overviews / tips.h
CommitLineData
15b6757b 1/////////////////////////////////////////////////////////////////////////////
2cd3cc94 2// Name: tips.h
15b6757b
FM
3// Purpose: topic overview
4// Author: wxWidgets team
5// RCS-ID: $Id$
526954c5 6// Licence: wxWindows licence
15b6757b
FM
7/////////////////////////////////////////////////////////////////////////////
8
880efa2a 9/**
36c9828f 10
2cd3cc94
BP
11@page overview_tips wxTipProvider Overview
12
831e1028
BP
13@tableofcontents
14
2cd3cc94
BP
15Many "modern" Windows programs have a feature (some would say annoyance) of
16presenting the user tips at program startup. While this is probably useless to
17the advanced users of the program, the experience shows that the tips may be
18quite helpful for the novices and so more and more programs now do this. For a
19wxWidgets programmer, implementing this feature is extremely easy. To show a
20tip, it is enough to just call wxShowTip function like this:
21
22@code
23if ( ...show tips at startup?... )
24{
25 wxTipProvider *tipProvider = wxCreateFileTipProvider("tips.txt", 0);
26 wxShowTip(windowParent, tipProvider);
27 delete tipProvider;
28}
29@endcode
30
31Of course, you need to get the text of the tips from somewhere - in the example
32above, the text is supposed to be in the file tips.txt from where it is read by
33the <em>tip provider</em>. The tip provider is just an object of a class
34deriving from wxTipProvider. It has to implement one pure virtual function of
35the base class: GetTip. In the case of the tip provider created by
36wxCreateFileTipProvider, the tips are just the lines of the text file.
37
38If you want to implement your own tip provider (for example, if you wish to
39hardcode the tips inside your program), you just have to derive another class
40from wxTipProvider and pass a pointer to the object of this class to
41wxShowTip - then you don't need wxCreateFileTipProvider at all.
42
43You will probably want to save somewhere the index of the tip last shown - so
44that the program doesn't always show the same tip on startup. As you also need
45to remember whether to show tips or not (you shouldn't do it if the user
46unchecked "Show tips on startup" checkbox in the dialog), you will probably
47want to store both the index of the last shown tip (as returned by
48wxTipProvider::GetCurrentTip and the flag telling whether to show the tips at
49startup at all.
50
51In a tips.txt file, lines that begin with a # character are considered comments
52and are automatically skipped. Blank lines and lines only having spaces are
53also skipped.
54
55You can easily add runtime-translation capacity by placing each line of the
56tips.txt file inside the usual translation macro. For example, your tips.txt
57file would look like this:
58
59@code
60_("This is my first tip")
61_("This is my second tip")
62@endcode
63
64Now add your tips.txt file into the list of files that gettext searches for
65translatable strings. The tips will thus get included into your generated .po
66file catalog and be translated at runtime along with the rest of your
67application's translatable strings.
68
69@note Each line in the tips.txt file needs to strictly begin with exactly the 3
70characters of underscore-parenthesis-doublequote, and end with
71doublequote-parenthesis, as shown above. Also, remember to escape any
72doublequote characters within the tip string with a backslash-doublequote.
73
74See the dialogs program in your samples folder for a working example inside a
75program.
76
77*/