Files
wxWidgets/docs/latex/wx/tipprov.tex
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

62 lines
2.3 KiB
TeX

\section{\class{wxTipProvider}}\label{wxtipprovider}
This is the class used together with \helpref{wxShowTip}{wxshowtip} function.
It must implement \helpref{GetTip}{wxtipprovidergettip} function and return the
current tip from it (different tip each time it is called).
You will never use this class yourself, but you need it to show startup tips
with wxShowTip. Also, if you want to get the tips text from elsewhere than a
simple text file, you will want to derive a new class from wxTipProvider and
use it instead of the one returned by \helpref{wxCreateFileTipProvider}{wxcreatefiletipprovider}.
\wxheading{Derived from}
None.
\wxheading{Include files}
<wx/tipdlg.h>
\wxheading{See also}
\helpref{Startup tips overview}{tipsoverview}, \helpref{::wxShowTip}{wxshowtip}
\latexignore{\rtfignore{\wxheading{Members}}}
\membersection{wxTipProvider::wxTipProvider}\label{wxtipproviderctor}
\func{}{wxTipProvider}{\param{size\_t }{currentTip}}
Constructor.
\docparam{currentTip}{The starting tip index.}
\membersection{wxTipProvider::GetTip}\label{wxtipprovidergettip}
\func{wxString}{GetTip}{\void}
Return the text of the current tip and pass to the next one. This function is
pure virtual, it should be implemented in the derived classes.
\membersection{wxTipProvider::PreprocessTip}\label{wxtipproviderpreprocesstip}
\funct{virtual wxString}{PreProcessTip}{\param{const wxString\&} {tip}}
Returns a modified tip. This function will be called immediately after read,
and before being check whether it is a comment, an empty string or a string
to translate. You can optionally override this in your custom user-derived class
to optionally to modify the tip as soon as it is read. You can return any
modification to the string. If you return wxEmptyString, then this tip is
skipped, and the next one is read.
\membersection{wxCurrentTipProvider::GetCurrentTip}\label{wxtipprovidergetcurrenttip}
\constfunc{size\_t}{GetCurrentTip}{\void}
Returns the index of the current tip (i.e. the one which would be returned by
GetTip).
The program usually remembers the value returned by this function after calling
\helpref{wxShowTip}{wxshowtip}. Note that it is not the same as the value which
was passed to wxShowTip $+ 1$ because the user might have pressed the "Next"
button in the tip dialog.