OpenCPN Partial API docs
Loading...
Searching...
No Matches
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
25#ifndef GUI_LIB_H__
26#define GUI_LIB_H__
27
28#include <wx/font.h>
29#include <wx/html/htmlwin.h>
30#include <wx/msgdlg.h>
31#include <wx/textctrl.h>
32#include <wx/timer.h>
33#include <wx/window.h>
34#include <wx/utils.h>
35
37class CopyableText : public wxTextCtrl {
38public:
39 CopyableText(wxWindow* parent, const char* text);
40};
41
57wxFont* GetOCPNScaledFont(wxString item, int default_size = 0);
71wxFont GetOCPNGUIScaledFont(wxString item);
72
73extern int OCPNMessageBox(wxWindow* parent, const wxString& message,
74 const wxString& caption = _T("Message"),
75 int style = wxOK, int timout_sec = -1, int x = -1,
76 int y = -1);
77
78class OCPNMessageDialog : public wxDialog {
79public:
80 OCPNMessageDialog(wxWindow* parent, const wxString& message,
81 const wxString& caption = wxMessageBoxCaptionStr,
82 long style = wxOK | wxCENTRE,
83 const wxPoint& pos = wxDefaultPosition);
84
85 void OnYes(wxCommandEvent& event);
86 void OnNo(wxCommandEvent& event);
87 void OnCancel(wxCommandEvent& event);
88 void OnClose(wxCloseEvent& event);
89
90private:
91 int m_style;
92 DECLARE_EVENT_TABLE()
93};
94
95class TimedMessageBox : public wxEvtHandler {
96public:
97 TimedMessageBox(wxWindow* parent, const wxString& message,
98 const wxString& caption = _T("Message box"),
99 long style = wxOK | wxCANCEL, int timeout_sec = -1,
100 const wxPoint& pos = wxDefaultPosition);
102 int GetRetVal(void) { return ret_val; }
103 void OnTimer(wxTimerEvent& evt);
104
105 wxTimer m_timer;
107 int ret_val;
108
109 DECLARE_EVENT_TABLE()
110};
111
112class OCPN_TimedHTMLMessageDialog : public wxDialog {
113public:
114 OCPN_TimedHTMLMessageDialog(wxWindow* parent, const wxString& message,
115 const wxString& caption = wxMessageBoxCaptionStr,
116 int tSeconds = -1, long style = wxOK | wxCENTRE,
117 bool bFixedFont = false,
118 const wxPoint& pos = wxDefaultPosition);
119
120 void OnYes(wxCommandEvent& event);
121 void OnNo(wxCommandEvent& event);
122 void OnCancel(wxCommandEvent& event);
123 void OnClose(wxCloseEvent& event);
124 void OnTimer(wxTimerEvent& evt);
125 void RecalculateSize(void);
126 void OnHtmlLinkClicked(wxHtmlLinkEvent& event) {
127 wxLaunchDefaultBrowser(event.GetLinkInfo().GetHref());
128 }
129
130private:
131 int m_style;
132 wxTimer m_timer;
133 wxHtmlWindow* msgWindow;
134
135 DECLARE_EVENT_TABLE()
136};
137
138//----------------------------------------------------------------------------
139// Generic Auto Timed Window
140// Belongs to the creator, not deleted automatically on application close
141//----------------------------------------------------------------------------
142
143class TimedPopupWin : public wxWindow {
144public:
145 TimedPopupWin(wxWindow* parent, int timeout = -1);
147
148 void OnPaint(wxPaintEvent& event);
149
150 void SetBitmap(wxBitmap& bmp);
151 wxBitmap* GetBitmap() { return m_pbm; }
152 void OnTimer(wxTimerEvent& event);
153 bool IsActive() { return isActive; }
154 void IsActive(bool state) { isActive = state; }
155
156private:
157 wxBitmap* m_pbm;
158 wxTimer m_timer_timeout;
159 int m_timeout_sec;
160 bool isActive;
161
162 DECLARE_EVENT_TABLE()
163};
164
165#endif // GUI_LIB_H__
Non-editable TextCtrl, used like wxStaticText but is copyable.
Definition gui_lib.h:37
wxFont * GetOCPNScaledFont(wxString item, int default_size=0)
Retrieves a font from FontMgr, optionally scaled for physical readability.
Definition gui_lib.cpp:54
wxFont GetOCPNGUIScaledFont(wxString item)
Retrieves a font optimized for touch and high-resolution interfaces.
Definition gui_lib.cpp:83