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