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/button.h>
29#include <wx/font.h>
30#include <wx/html/htmlwin.h>
31#include <wx/msgdlg.h>
32#include <wx/textctrl.h>
33#include <wx/timer.h>
34#include <wx/window.h>
35
36#include "model/std_icon.h"
37
39class CopyableText : public wxTextCtrl {
40public:
41 CopyableText(wxWindow* parent, const char* text);
42};
43
59wxFont* GetOCPNScaledFont(wxString item, int default_size = 0);
73wxFont GetOCPNGUIScaledFont(wxString item);
74
75extern int OCPNMessageBox(wxWindow* parent, const wxString& message,
76 const wxString& caption = _T("Message"),
77 int style = wxOK, int timout_sec = -1, int x = -1,
78 int y = -1);
79
80class OCPNMessageDialog : public wxDialog {
81public:
82 OCPNMessageDialog(wxWindow* parent, const wxString& message,
83 const wxString& caption = wxMessageBoxCaptionStr,
84 long style = wxOK | wxCENTRE,
85 const wxPoint& pos = wxDefaultPosition);
86
87 void OnYes(wxCommandEvent& event);
88 void OnNo(wxCommandEvent& event);
89 void OnCancel(wxCommandEvent& event);
90 void OnClose(wxCloseEvent& event);
91
92private:
93 int m_style;
94 DECLARE_EVENT_TABLE()
95};
96
97class TimedMessageBox : public wxEvtHandler {
98public:
99 TimedMessageBox(wxWindow* parent, const wxString& message,
100 const wxString& caption = _T("Message box"),
101 long style = wxOK | wxCANCEL, int timeout_sec = -1,
102 const wxPoint& pos = wxDefaultPosition);
104 int GetRetVal(void) { return ret_val; }
105 void OnTimer(wxTimerEvent& evt);
106
107 wxTimer m_timer;
109 int ret_val;
110
111 DECLARE_EVENT_TABLE()
112};
113
114//----------------------------------------------------------------------------
115// Generic Auto Timed Window
116// Belongs to the creator, not deleted automatically on application close
117//----------------------------------------------------------------------------
118
119class TimedPopupWin : public wxWindow {
120public:
121 TimedPopupWin(wxWindow* parent, int timeout = -1);
123
124 void OnPaint(wxPaintEvent& event);
125
126 void SetBitmap(wxBitmap& bmp);
127 wxBitmap* GetBitmap() { return m_pbm; }
128 void OnTimer(wxTimerEvent& event);
129 bool IsActive() { return isActive; }
130 void IsActive(bool state) { isActive = state; }
131
132private:
133 wxBitmap* m_pbm;
134 wxTimer m_timer_timeout;
135 int m_timeout_sec;
136 bool isActive;
137
138 DECLARE_EVENT_TABLE()
139};
140
148class InfoButton : public wxButton {
149public:
150 InfoButton(wxWindow* parent, bool touch, const char* header,
151 const char* info);
152
153private:
154 class InfoFrame;
155
156 StdIcon m_icon;
157 InfoFrame* m_info_frame;
158};
159
160#endif // GUI_LIB_H__
Non-editable TextCtrl, used like wxStaticText but is copyable.
Definition gui_lib.h:39
Clickable, small info icon which displays a help text Typical usage:
Definition gui_lib.h:148
Small monochrome SVG icon scaled to the height of a char.
Definition std_icon.h:37
wxFont * GetOCPNScaledFont(wxString item, int default_size=0)
Retrieves a font from FontMgr, optionally scaled for physical readability.
Definition gui_lib.cpp:56
wxFont GetOCPNGUIScaledFont(wxString item)
Retrieves a font optimized for touch and high-resolution interfaces.
Definition gui_lib.cpp:85
Class StdIcon, typically a small monochrome svg icon.