1999-06-28 18:08:46 -04:00
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Name: tipdlg.h
|
|
|
|
// Purpose: declaration of wxTipDialog
|
|
|
|
// Author: Vadim Zeitlin
|
|
|
|
// Modified by:
|
|
|
|
// Created: 28.06.99
|
|
|
|
// RCS-ID: $Id$
|
|
|
|
// Copyright: (c) Vadim Zeitlin
|
2004-05-23 16:53:33 -04:00
|
|
|
// Licence: wxWindows licence
|
1999-06-28 18:08:46 -04:00
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
#ifndef _WX_TIPDLG_H_
|
|
|
|
#define _WX_TIPDLG_H_
|
|
|
|
|
2003-08-09 08:38:21 -04:00
|
|
|
#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
|
1999-06-28 18:08:46 -04:00
|
|
|
#pragma interface "tipdlg.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// headers which we must include here
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
#include "wx/defs.h"
|
|
|
|
|
|
|
|
#if wxUSE_STARTUP_TIPS
|
|
|
|
|
|
|
|
#include "wx/textfile.h"
|
|
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// wxTipProvider - a class which is used by wxTipDialog to get the text of the
|
|
|
|
// tips
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
// the abstract base class: it provides the tips, i.e. implements the GetTip()
|
|
|
|
// function which returns the new tip each time it's called. To support this,
|
|
|
|
// wxTipProvider evidently needs some internal state which is the tip "index"
|
|
|
|
// and which should be saved/restored by the program to not always show one and
|
|
|
|
// the same tip (of course, you may use random starting position as well...)
|
2003-08-01 21:04:55 -04:00
|
|
|
class WXDLLIMPEXP_ADV wxTipProvider
|
1999-06-28 18:08:46 -04:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
wxTipProvider(size_t currentTip) { m_currentTip = currentTip; }
|
|
|
|
|
|
|
|
// get the current tip and update the internal state to return the next tip
|
|
|
|
// when called for the next time
|
2004-09-23 14:20:56 -04:00
|
|
|
virtual wxString GetTip() = 0;
|
1999-06-28 18:08:46 -04:00
|
|
|
|
|
|
|
// get the current tip "index" (or whatever allows the tip provider to know
|
|
|
|
// from where to start the next time)
|
|
|
|
size_t GetCurrentTip() const { return m_currentTip; }
|
|
|
|
|
2004-09-23 14:20:56 -04:00
|
|
|
// Allows any user-derived class to optionally override this function to
|
|
|
|
// modify the tip as soon as it is read. If return wxEmptyString, then
|
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
|
|
|
// the tip is skipped, and the next one is read.
|
|
|
|
virtual wxString PreprocessTip(const wxString& tip) { return tip; }
|
|
|
|
|
1999-06-28 18:08:46 -04:00
|
|
|
// virtual dtor for the base class
|
|
|
|
virtual ~wxTipProvider() { }
|
|
|
|
|
|
|
|
protected:
|
|
|
|
size_t m_currentTip;
|
|
|
|
};
|
|
|
|
|
|
|
|
// a function which returns an implementation of wxTipProvider using the
|
|
|
|
// specified text file as the source of tips (each line is a tip).
|
|
|
|
//
|
|
|
|
// NB: the caller is responsible for deleting the pointer!
|
2003-08-01 21:04:55 -04:00
|
|
|
WXDLLIMPEXP_ADV wxTipProvider *wxCreateFileTipProvider(const wxString& filename,
|
|
|
|
size_t currentTip);
|
1999-06-28 18:08:46 -04:00
|
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// wxTipDialog
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
// A dialog which shows a "tip" - a short and helpful messages describing to
|
|
|
|
// the user some program characteristic. Many programs show the tips at
|
|
|
|
// startup, so the dialog has "Show tips on startup" checkbox which allows to
|
|
|
|
// the user to disable this (however, it's the program which should show, or
|
|
|
|
// not, the dialog on startup depending on its value, not this class).
|
|
|
|
//
|
2004-09-23 14:20:56 -04:00
|
|
|
// The function returns true if this checkbox is checked, false otherwise.
|
2003-08-01 21:04:55 -04:00
|
|
|
WXDLLIMPEXP_ADV bool wxShowTip(wxWindow *parent,
|
|
|
|
wxTipProvider *tipProvider,
|
2004-09-23 14:20:56 -04:00
|
|
|
bool showAtStartup = true);
|
1999-06-28 18:08:46 -04:00
|
|
|
|
|
|
|
#endif // wxUSE_STARTUP_TIPS
|
|
|
|
|
|
|
|
#endif // _WX_TIPDLG_H_
|