OpenCPN Partial API docs
gui_lib.h
Go to the documentation of this file.
1  /**************************************************************************
2  * Copyright (C) 2010 by David S. Register *
3  * *
4  * This program is free software; you can redistribute it and/or modify *
5  * it under the terms of the GNU General Public License as published by *
6  * the Free Software Foundation; either version 2 of the License, or *
7  * (at your option) any later version. *
8  * *
9  * This program is distributed in the hope that it will be useful, *
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
12  * GNU General Public License for more details. *
13  * *
14  * You should have received a copy of the GNU General Public License *
15  * along with this program; if not, write to the *
16  * Free Software Foundation, Inc., *
17  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
18  **************************************************************************/
19 
22 #ifndef GUI_LIB_H__
23 #define GUI_LIB_H__
24 
25 #include <wx/font.h>
26 #include <wx/html/htmlwin.h>
27 #include <wx/msgdlg.h>
28 #include <wx/textctrl.h>
29 #include <wx/timer.h>
30 #include <wx/window.h>
31 #include <wx/utils.h>
32 
34 class CopyableText : public wxTextCtrl {
35 public:
36  CopyableText(wxWindow* parent, const char* text);
37 };
38 
39 
40 wxFont* GetOCPNScaledFont(wxString item, int default_size = 0);
41 wxFont GetOCPNGUIScaledFont(wxString item);
42 
43 extern int OCPNMessageBox(wxWindow* parent, const wxString& message,
44  const wxString& caption = _T("Message"),
45  int style = wxOK, int timout_sec = -1, int x = -1,
46  int y = -1);
47 
48 class OCPNMessageDialog : public wxDialog {
49 public:
50  OCPNMessageDialog(wxWindow* parent, const wxString& message,
51  const wxString& caption = wxMessageBoxCaptionStr,
52  long style = wxOK | wxCENTRE,
53  const wxPoint& pos = wxDefaultPosition);
54 
55  void OnYes(wxCommandEvent& event);
56  void OnNo(wxCommandEvent& event);
57  void OnCancel(wxCommandEvent& event);
58  void OnClose(wxCloseEvent& event);
59 
60 private:
61  int m_style;
62  DECLARE_EVENT_TABLE()
63 };
64 
65 class TimedMessageBox : public wxEvtHandler {
66 public:
67  TimedMessageBox(wxWindow* parent, const wxString& message,
68  const wxString& caption = _T("Message box"),
69  long style = wxOK | wxCANCEL, int timeout_sec = -1,
70  const wxPoint& pos = wxDefaultPosition);
71  ~TimedMessageBox();
72  int GetRetVal(void) { return ret_val; }
73  void OnTimer(wxTimerEvent& evt);
74 
75  wxTimer m_timer;
76  OCPNMessageDialog* dlg;
77  int ret_val;
78 
79  DECLARE_EVENT_TABLE()
80 };
81 
82 class OCPN_TimedHTMLMessageDialog : public wxDialog {
83 public:
84  OCPN_TimedHTMLMessageDialog(wxWindow* parent, const wxString& message,
85  const wxString& caption = wxMessageBoxCaptionStr,
86  int tSeconds = -1, long style = wxOK | wxCENTRE,
87  bool bFixedFont = false,
88  const wxPoint& pos = wxDefaultPosition);
89 
90  void OnYes(wxCommandEvent& event);
91  void OnNo(wxCommandEvent& event);
92  void OnCancel(wxCommandEvent& event);
93  void OnClose(wxCloseEvent& event);
94  void OnTimer(wxTimerEvent& evt);
95  void RecalculateSize(void);
96  void OnHtmlLinkClicked( wxHtmlLinkEvent& event ) { wxLaunchDefaultBrowser(event.GetLinkInfo().GetHref()); }
97 
98 private:
99  int m_style;
100  wxTimer m_timer;
101  wxHtmlWindow* msgWindow;
102 
103  DECLARE_EVENT_TABLE()
104 };
105 
106 //----------------------------------------------------------------------------
107 // Generic Auto Timed Window
108 // Belongs to the creator, not deleted automatically on application close
109 //----------------------------------------------------------------------------
110 
111 class TimedPopupWin : public wxWindow {
112 public:
113  TimedPopupWin(wxWindow *parent, int timeout = -1);
114  ~TimedPopupWin();
115 
116  void OnPaint(wxPaintEvent &event);
117 
118  void SetBitmap(wxBitmap &bmp);
119  wxBitmap *GetBitmap() { return m_pbm; }
120  void OnTimer(wxTimerEvent &event);
121  bool IsActive() { return isActive; }
122  void IsActive(bool state) { isActive = state; }
123 
124 private:
125  wxBitmap *m_pbm;
126  wxTimer m_timer_timeout;
127  int m_timeout_sec;
128  bool isActive;
129 
130  DECLARE_EVENT_TABLE()
131 };
132 
133 
134 //-----------------------------------------------------------------------
135 // Dummy Text Control for global key events
136 //-----------------------------------------------------------------------
137 class DummyTextCtrl : public wxTextCtrl {
138 public:
139  DummyTextCtrl(wxWindow *parent, wxWindowID id);
140  void OnChar(wxKeyEvent &event);
141  void OnMouseEvent(wxMouseEvent &event);
142 
143  wxTimer m_MouseWheelTimer;
144  int m_mouse_wheel_oneshot;
145  int m_last_wheel_dir;
146 
147  DECLARE_EVENT_TABLE()
148 };
149 
150 
151 #endif // GUI_LIB_H__
Non-editable TextCtrl, used like wxStaticText but is copyable.
Definition: gui_lib.h:34