NumeRe v1.1.4
NumeRe: Framework für Numerische Rechnungen
tipdialog.hpp
Go to the documentation of this file.
1/*****************************************************************************
2 NumeRe: Framework fuer Numerische Rechnungen
3 Copyright (C) 2017 Erik Haenel et al.
4
5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation, either version 3 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
17******************************************************************************/
18
19#include <wx/wx.h>
20#include <wx/tipdlg.h>
21#include <vector>
22#include <string>
23#include <cmath>
24#include <ctime>
25
26
27class MyTipProvider : public wxTipProvider
28{
29 private:
30 std::vector<std::string> vTip;
31 unsigned int nth_tip;
32 public:
33 MyTipProvider(const std::vector<std::string>& vTipList);
34
35 virtual wxString GetTip()
36 {
37 nth_tip++;
38 if (nth_tip >= vTip.size())
39 nth_tip = 0;
40 return vTip[nth_tip];
41 }
42};
43
44class TipDialog : public wxDialog
45{
46 public:
47 /* text defines all strings:
48 * 0 = title, 1 = Did you know, 2 = &Next tip, 3 = &Show tips at startup
49 */
50 TipDialog(wxWindow *parent, wxTipProvider *tipProvider, const wxArrayString& text, bool showAtStartup);
51
52 // the tip dialog has "Show tips on startup" checkbox - return true if it
53 // was checked (or wasn't unchecked)
54 bool ShowTipsOnStartup() const { return m_checkbox->GetValue(); }
55
56 // sets the (next) tip text
57 void SetTipText() { m_text->SetValue(m_tipProvider->GetTip()); }
58
59 // "Next" button handler
60 void OnNextTip(wxCommandEvent& WXUNUSED(event)) { SetTipText(); }
61
62 private:
63 wxTipProvider *m_tipProvider;
64
65 wxTextCtrl *m_text;
66 wxCheckBox *m_checkbox;
67
68 DECLARE_EVENT_TABLE()
70};
71
72
73bool ShowTip(wxWindow* parent, wxTipProvider* tipProvider, const wxArrayString& text, bool showAtStartUp = true);
MyTipProvider(const std::vector< std::string > &vTipList)
Definition: tipdialog.cpp:150
unsigned int nth_tip
Definition: tipdialog.hpp:31
std::vector< std::string > vTip
Definition: tipdialog.hpp:30
virtual wxString GetTip()
Definition: tipdialog.hpp:35
wxTextCtrl * m_text
Definition: tipdialog.hpp:65
void OnNextTip(wxCommandEvent &WXUNUSED(event))
Definition: tipdialog.hpp:60
wxDECLARE_NO_COPY_CLASS(TipDialog)
wxTipProvider * m_tipProvider
Definition: tipdialog.hpp:63
void SetTipText()
Definition: tipdialog.hpp:57
TipDialog(wxWindow *parent, wxTipProvider *tipProvider, const wxArrayString &text, bool showAtStartup)
Definition: tipdialog.cpp:34
bool ShowTipsOnStartup() const
Definition: tipdialog.hpp:54
wxCheckBox * m_checkbox
Definition: tipdialog.hpp:66
bool ShowTip(wxWindow *parent, wxTipProvider *tipProvider, const wxArrayString &text, bool showAtStartUp=true)
Definition: tipdialog.cpp:141