OpenCPN Partial API docs
Loading...
Searching...
No Matches
ch_info_win.cpp
Go to the documentation of this file.
1/**************************************************************************
2 * Copyright (C) 2013 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
23
24#include <wx/wxprec.h>
25#include <wx/dcclient.h>
26
27#include "gl_headers.h" // Must come before anyting using GL stuff
28
29#include "model/config_vars.h"
30#include "ch_info_win.h"
31#include "color_handler.h"
32#include "font_mgr.h"
33#include "ocpn_platform.h"
34
35#ifdef __ANDROID__
36#include "androidUTIL.h"
37#endif
38
39BEGIN_EVENT_TABLE(ChInfoWin, wxPanel)
40EVT_PAINT(ChInfoWin::OnPaint)
41EVT_ERASE_BACKGROUND(ChInfoWin::OnEraseBackground)
42EVT_MOUSE_EVENTS(ChInfoWin::MouseEvent)
43END_EVENT_TABLE()
44
45// Define a constructor
46ChInfoWin::ChInfoWin(wxWindow* parent) {
47 long style = wxSIMPLE_BORDER | wxCLIP_CHILDREN | wxFRAME_FLOAT_ON_PARENT;
48
49 wxPanel::Create(parent, wxID_ANY, wxDefaultPosition, wxDefaultSize, style);
50
51 wxFont* dFont = FontMgr::Get().GetFont(_("Dialog"));
52 SetFont(*dFont);
53
54 int ststyle = wxALIGN_LEFT | wxST_NO_AUTORESIZE;
55 m_pInfoTextCtl =
56 new wxStaticText(this, -1, "", wxDefaultPosition, wxDefaultSize, ststyle);
57
58 dbIndex = -1;
59 Hide();
60}
61
62ChInfoWin::~ChInfoWin() { delete m_pInfoTextCtl; }
63
64void ChInfoWin::OnEraseBackground(wxEraseEvent& event) {}
65
66void ChInfoWin::MouseEvent(wxMouseEvent& event) {
67 if (g_btouch) {
68 if (event.LeftDown()) {
69 Hide();
70
71#ifdef __ANDROID__
72 androidForceFullRepaint();
73#endif
74 }
75 }
76}
77
78void ChInfoWin::OnPaint(wxPaintEvent& event) {
79 int width, height;
80 GetClientSize(&width, &height);
81 wxPaintDC dc(this);
82
83 dc.SetBrush(wxBrush(GetGlobalColor("UIBCK")));
84 dc.SetPen(wxPen(GetGlobalColor("UITX1")));
85 dc.DrawRectangle(0, 0, width, height);
86}
87
88void ChInfoWin::SetBitmap() {
89 SetBackgroundColour(GetGlobalColor("UIBCK"));
90
91 m_pInfoTextCtl->SetBackgroundColour(GetGlobalColor("UIBCK"));
92 m_pInfoTextCtl->SetForegroundColour(GetGlobalColor("UITX1"));
93
94 m_pInfoTextCtl->SetSize(GetCharWidth(), 1, m_size.x - 2 * GetCharWidth(),
95 m_size.y - 2);
96 m_pInfoTextCtl->SetLabel(m_string);
97
98 wxPoint top_position =
99 m_position; // GetParent()->ClientToScreen( m_position);
100 SetSize(top_position.x, top_position.y, m_size.x, m_size.y);
101 SetClientSize(m_size.x, m_size.y);
102}
103
104void ChInfoWin::FitToChars(int char_width, int char_height) {
105 wxSize size;
106
107 int adjust = 1;
108
109#ifdef __WXOSX__
110 adjust = 2;
111#endif
112
113#ifdef __ANDROID__
114 adjust = 4;
115#endif
116
117 size.x = GetCharWidth() * char_width;
118 size.y = GetCharHeight() * (char_height + adjust);
119 size.x = wxMin(size.x, g_Platform->getDisplaySize().x - 10);
120 SetWinSize(size);
121}
Chart info panel.
A custom panel for displaying chart information.
Definition ch_info_win.h:36
wxSize getDisplaySize()
Get the display size in logical pixels.
Global color handling by name.
Global variables stored in configuration file.
Font list manager.
Platform independent GL includes.
OCPNPlatform * g_Platform
Global instance.
OpenCPN Platform specific support utilities.