1999-11-22 07:13:55 -05:00
|
|
|
\section{wxTipProvider overview}\label{tipsoverview}
|
1999-06-28 17:39:49 -04:00
|
|
|
|
|
|
|
Many "modern" Windows programs have a feature (some would say annoyance) of
|
|
|
|
presenting the user tips at program startup. While this is probably useless to
|
|
|
|
the advanced users of the program, the experience shows that the tips may be
|
|
|
|
quite helpful for the novices and so more and more programs now do this.
|
|
|
|
|
2004-05-04 04:27:20 -04:00
|
|
|
For a wxWidgets programmer, implementing this feature is extremely easy. To
|
2000-07-15 15:51:35 -04:00
|
|
|
show a tip, it is enough to just call \helpref{wxShowTip}{wxshowtip} function
|
1999-06-28 17:39:49 -04:00
|
|
|
like this:
|
|
|
|
|
|
|
|
\begin{verbatim}
|
|
|
|
if ( ...show tips at startup?... )
|
|
|
|
{
|
|
|
|
wxTipProvider *tipProvider = wxCreateFileTipProvider("tips.txt", 0);
|
|
|
|
wxShowTip(windowParent, tipProvider);
|
|
|
|
delete tipProvider;
|
|
|
|
}
|
|
|
|
\end{verbatim}
|
|
|
|
|
|
|
|
Of course, you need to get the text of the tips from somewhere - in the example
|
2000-07-15 15:51:35 -04:00
|
|
|
above, the text is supposed to be in the file tips.txt from where it is read by
|
1999-06-28 17:39:49 -04:00
|
|
|
the {\it tip provider}. The tip provider is just an object of a class deriving
|
|
|
|
from \helpref{wxTipProvider}{wxtipprovider}. It has to implement one pure
|
|
|
|
virtual function of the base class: \helpref{GetTip}{wxtipprovidergettip}.
|
|
|
|
In the case of the tip provider created by
|
|
|
|
\helpref{wxCreateFileTipProvider}{wxcreatefiletipprovider}, the tips are just
|
|
|
|
the lines of the text file.
|
|
|
|
|
|
|
|
If you want to implement your own tip provider (for example, if you wish to
|
|
|
|
hardcode the tips inside your program), you just have to derive another class
|
|
|
|
from wxTipProvider and pass a pointer to the object of this class to wxShowTip
|
|
|
|
- then you don't need wxCreateFileTipProvider at all.
|
|
|
|
|
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 08:08:02 -04:00
|
|
|
You will probably want to save somewhere the index of the tip last
|
1999-06-28 17:39:49 -04:00
|
|
|
shown - so that the program doesn't always show the same tip on startup. As you
|
|
|
|
also need to remember whether to show tips or not (you shouldn't do it if the
|
|
|
|
user unchecked "Show tips on startup" checkbox in the dialog), you will
|
|
|
|
probably want to store both the index of the
|
|
|
|
last shown tip (as returned by
|
|
|
|
\helpref{wxTipProvider::GetCurrentTip}{wxtipprovidergetcurrenttip} and the flag
|
|
|
|
telling whether to show the tips at startup at all.
|
1999-08-05 18:05:15 -04:00
|
|
|
|
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 08:08:02 -04:00
|
|
|
In a tips.txt file, lines that begin with a \# character are considered comments
|
|
|
|
and are automatically skipped. Blank lines and lines only having spaces are also
|
|
|
|
skipped.
|
|
|
|
|
|
|
|
You can easily add runtime-translation capacity by placing each line of the
|
|
|
|
tips.txt file inside the usual translation macro. For example, your tips.txt
|
|
|
|
file would look like this:
|
Applied patch [ 600051 ] DDE and TCP improvements and fixes
By Michael Fielding
As discussed on wx-dev. some fixes and improvements for Interprocess Communication (IPC), using DDE and TCP.
1. DDE buffers were using a global buffer
2. TCP buffers were allocated each time needed, and Request would have caused memory leaks had it been used.
Fixed these both by using a self-resizing buffer in wxConnectionBase. Changed samples and docs to reflect the improved (but backward compatible) internal buffer management. wxConnectionBase could (in future) use wxMemoryBuffer.
3. IPC sample had trouble closing, causing crash, when closing server using window X button.
Because it was (effectively) trying to delete a window in OnExit, when that window was already destroyed. Fixed by making IPCDialog and MyConnection remember if they'd destroyed each other. It's not elegant, but either the connection or the window could be deleted first.
4. Docs for wxDDE... and wxTCP... duplicated eachother, supposed to have same API. Some parts unclear.
Patch removes dde and tcp-specific files (including from tipc.tex and classes.tex), and explains how ipc.h selects for you which one to use based on platform. Some other misc clarifications.
6. Client sample was suffering apparent memory leak because of not deleting connection object, and had a hack in there to do that.
In fact this was due to the derived OnDisconnect not deleting itself, as it does in base class. Mentioned need to do it in docs, fixed sample so that it does.
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@16907 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
2002-09-01 10:48:16 -04:00
|
|
|
|
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 08:08:02 -04:00
|
|
|
\begin{verbatim}
|
|
|
|
_("This is my first tip")
|
|
|
|
_("This is my second tip")
|
|
|
|
\end{verbatim}
|
Applied patch [ 600051 ] DDE and TCP improvements and fixes
By Michael Fielding
As discussed on wx-dev. some fixes and improvements for Interprocess Communication (IPC), using DDE and TCP.
1. DDE buffers were using a global buffer
2. TCP buffers were allocated each time needed, and Request would have caused memory leaks had it been used.
Fixed these both by using a self-resizing buffer in wxConnectionBase. Changed samples and docs to reflect the improved (but backward compatible) internal buffer management. wxConnectionBase could (in future) use wxMemoryBuffer.
3. IPC sample had trouble closing, causing crash, when closing server using window X button.
Because it was (effectively) trying to delete a window in OnExit, when that window was already destroyed. Fixed by making IPCDialog and MyConnection remember if they'd destroyed each other. It's not elegant, but either the connection or the window could be deleted first.
4. Docs for wxDDE... and wxTCP... duplicated eachother, supposed to have same API. Some parts unclear.
Patch removes dde and tcp-specific files (including from tipc.tex and classes.tex), and explains how ipc.h selects for you which one to use based on platform. Some other misc clarifications.
6. Client sample was suffering apparent memory leak because of not deleting connection object, and had a hack in there to do that.
In fact this was due to the derived OnDisconnect not deleting itself, as it does in base class. Mentioned need to do it in docs, fixed sample so that it does.
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@16907 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
2002-09-01 10:48:16 -04:00
|
|
|
|
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 08:08:02 -04:00
|
|
|
Now add your tips.txt file into the list of files that gettext searches
|
|
|
|
for translatable strings. The tips will thus get included into your
|
|
|
|
generated .po file catalog and be translated at runtime along with the rest of
|
2004-10-22 15:15:35 -04:00
|
|
|
your application's translatable strings.
|
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 08:08:02 -04:00
|
|
|
Note1: Each line in the tips.txt file needs to strictly begin with exactly the
|
|
|
|
3 characters of underscore-parenthesis-doublequote, and end with
|
|
|
|
doublequote-parenthesis, as shown above.
|
|
|
|
Note2: Remember to escape any doublequote characters within the tip string with
|
|
|
|
a backslash-doublequote.
|
|
|
|
|
|
|
|
See the dialogs program in your samples folder for a working example inside a
|
|
|
|
program.
|
Applied patch [ 600051 ] DDE and TCP improvements and fixes
By Michael Fielding
As discussed on wx-dev. some fixes and improvements for Interprocess Communication (IPC), using DDE and TCP.
1. DDE buffers were using a global buffer
2. TCP buffers were allocated each time needed, and Request would have caused memory leaks had it been used.
Fixed these both by using a self-resizing buffer in wxConnectionBase. Changed samples and docs to reflect the improved (but backward compatible) internal buffer management. wxConnectionBase could (in future) use wxMemoryBuffer.
3. IPC sample had trouble closing, causing crash, when closing server using window X button.
Because it was (effectively) trying to delete a window in OnExit, when that window was already destroyed. Fixed by making IPCDialog and MyConnection remember if they'd destroyed each other. It's not elegant, but either the connection or the window could be deleted first.
4. Docs for wxDDE... and wxTCP... duplicated eachother, supposed to have same API. Some parts unclear.
Patch removes dde and tcp-specific files (including from tipc.tex and classes.tex), and explains how ipc.h selects for you which one to use based on platform. Some other misc clarifications.
6. Client sample was suffering apparent memory leak because of not deleting connection object, and had a hack in there to do that.
In fact this was due to the derived OnDisconnect not deleting itself, as it does in base class. Mentioned need to do it in docs, fixed sample so that it does.
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@16907 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
2002-09-01 10:48:16 -04:00
|
|
|
|