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