wxWidgets/samples/dialogs/tips.txt
Julian Smart 70373b5a57 Applied patch [ 600500 ] Tip-of-day: comments, translatable
By Robert O'Connor

This is a patch to wxTip Provider classes used by the "Tip of the day" dialog.

See wx-dev archives August 2002 for discussion of the functionality design.

It does 5 things:
-Support for comments inside the tips file. The pound character (#) is used, as recommended by Vadim.
-Allows optional easy translation support to tips, by marking them as translatable for gettext, by enclosing them in a _(""). Program will translate these tips at runtime from the active catalog.
-Blank lines or lines with just spaces are automatically skipped (I had to put this in, I keep wondering why I get blank tips sometimes and it is because the text file had a empty blank line at the end of the text file).
-There is a pluggable virtual function to preprocess to modify the tip in a derived class, in case something specialized is desired, such as variable expansion, etc, as recommended by Julian and Vadim.
-Now resets the tip counter if the previous tip is past the end of the file (ie you removed some tips, or changed tip files), as discussed on wx-dev.

This patch updates:
-The classes.
-The class documentation and the Tip-of-the-day topic overview documentation.
-The dialogs example, placing some new strings for the tips.txt file which demonstrate how to use the Tip-of-the-day features for in practice.


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@16887 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
2002-08-31 12:08:02 +00:00

19 lines
2.2 KiB
Plaintext

Startup tips are documented in the "Startup tips overview" section of wxWindows documentation.
These tips are being read from the tips.txt text file in this directory. Each line of the file contains a single tip.
If you close and open this tips dialog, you will notice that the tip numbers start at the point you were at when you closed the dialog last time. This allows easy cycling through the entire list of tips, instead of always showing the initial tips over and over.
Often you will want to save to the application's wxConfig, the last tip that the user saw, as well as whether they want to see tips on startup.
Comments in the tips file have a # as the first character. Comments are automatically skipped over. See the tips.txt file in this directory for the example.
# This line is a comment since it started with a #, and is skipped.
Blank lines in the tip file are also automatically skipped over. Lines with only spaces are also considered empty.
The next line in this tip file is empty, so it will be automatically skipped.
The next line in this tip file is just empty spaces, so it is considered empty too, and is also automatically skipped.
You can easily add translations to your startup tips via the usual gettext methods by wrapping a string in a gettext macro, which is _(""). See next tip for example.
_("This tip is marked as a translatable string by wrapping it inside the usual gettext macro, so it can be collected by gettext and added to a translation catalog. Your application can then use this catalog and serve out a translated version of the tip.")
Translatable strings must strictly begin with _(", not _( " or wxGetTranslation(" or something else.
If you are using gettext translatable strings, don't forget to escape to replace any " characters within the tip with a \" instead
_("This is a translatable tip with the quoted words \"Escape me\" properly escaped.")
If you have very specialized needs, you can derive your own wxTipProvider and use that instead.
If you want to modify the tip content at runtime for purposes other than translation (for example, variable expansion), one easy option is to use a custom tip provider derived from wxFileTipProvider. Your custom tip provider would contain a single virtual function to override: PreprocessTip().