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, see <https://www.gnu.org/licenses/>. *
16 **************************************************************************/
17
24#ifndef GUI_LIB_H__
25#define GUI_LIB_H__
26
27#include <wx/button.h>
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
35#include "model/std_icon.h"
36
38class CopyableText : public wxTextCtrl {
39public:
40 CopyableText(wxWindow* parent, const char* text);
41};
42
58wxFont* GetOCPNScaledFont(wxString item, int default_size = 0);
72wxFont GetOCPNGUIScaledFont(wxString item);
73
74extern int OCPNMessageBox(wxWindow* parent, const wxString& message,
75 const wxString& caption = "Message", int style = wxOK,
76 int timout_sec = -1, int x = -1, 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 = "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
112//----------------------------------------------------------------------------
113// Generic Auto Timed Window
114// Belongs to the creator, not deleted automatically on application close
115//----------------------------------------------------------------------------
116
117class TimedPopupWin : public wxWindow {
118public:
119 TimedPopupWin(wxWindow* parent, int timeout = -1);
121
122 void OnPaint(wxPaintEvent& event);
123
124 void SetBitmap(wxBitmap& bmp);
125 wxBitmap* GetBitmap() { return m_pbm; }
126 void OnTimer(wxTimerEvent& event);
127 bool IsActive() { return isActive; }
128 void IsActive(bool state) { isActive = state; }
129
130private:
131 wxBitmap* m_pbm;
132 wxTimer m_timer_timeout;
133 int m_timeout_sec;
134 bool isActive;
135
136 DECLARE_EVENT_TABLE()
137};
138
146class InfoButton : public wxButton {
147public:
148 InfoButton(wxWindow* parent, bool touch, const char* header,
149 const char* info);
150
151private:
152 class InfoFrame;
153
154 StdIcon m_icon;
155 InfoFrame* m_info_frame;
156};
157
158#endif // GUI_LIB_H__
Non-editable TextCtrl, used like wxStaticText but is copyable.
Definition gui_lib.h:38
Clickable, small info icon which displays a help text Typical usage:
Definition gui_lib.h:146
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:59
wxFont GetOCPNGUIScaledFont(wxString item)
Retrieves a font optimized for touch and high-resolution interfaces.
Definition gui_lib.cpp:88
Class StdIcon, typically a small monochrome svg icon.