OpenCPN Partial API docs
Loading...
Searching...
No Matches
thumbwin.cpp
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#include <stdlib.h>
25#include <math.h>
26#include <time.h>
27
28#include <wx/wxprec.h>
29
30#ifndef WX_PRECOMP
31#include <wx/wx.h>
32#endif // precompiled headers
33
34#include "thumbwin.h"
35
36#include "chartdb.h"
37#include "color_handler.h"
38#include "dychart.h"
39
41
42//------------------------------------------------------------------------------
43// Thumbwin Implementation
44//------------------------------------------------------------------------------
45BEGIN_EVENT_TABLE(ThumbWin, wxWindow)
46EVT_PAINT(ThumbWin::OnPaint)
47END_EVENT_TABLE()
48
49// Define a constructor
50
51ThumbWin::ThumbWin(wxWindow *parent)
52 : wxWindow(parent, wxID_ANY, wxPoint(20, 20), wxSize(5, 5),
53 wxSIMPLE_BORDER) {
54 pThumbChart = NULL;
55 m_max_size.x = m_max_size.y = 100;
56 Show(false);
57}
58
59ThumbWin::~ThumbWin() {}
60
61void ThumbWin::Resize() {
62 if (pThumbChart) {
63 if (pThumbChart->GetThumbData()->pDIBThumb) {
64 int newheight = std::min(
65 m_max_size.y, pThumbChart->GetThumbData()->pDIBThumb->GetHeight());
66 int newwidth = std::min(
67 m_max_size.x, pThumbChart->GetThumbData()->pDIBThumb->GetWidth());
68 SetSize(0, 0, newwidth, newheight);
69 }
70 }
71}
72
73void ThumbWin::SetMaxSize(wxSize const &max_size) { m_max_size = max_size; }
74
75void ThumbWin::OnPaint(wxPaintEvent &event) {
76 wxPaintDC dc(this);
77
78 if (pThumbChart) {
79 if (pThumbChart->GetThumbData()) {
80 if (pThumbChart->GetThumbData()->pDIBThumb)
81 dc.DrawBitmap(*(pThumbChart->GetThumbData()->pDIBThumb), 0, 0, false);
82
83 wxPen ppPen(GetGlobalColor("CHBLK"), 1, wxPENSTYLE_SOLID);
84 dc.SetPen(ppPen);
85 wxBrush yBrush(GetGlobalColor("CHYLW"), wxBRUSHSTYLE_SOLID);
86 dc.SetBrush(yBrush);
87 dc.DrawCircle(pThumbChart->GetThumbData()->ShipX,
88 pThumbChart->GetThumbData()->ShipY, 6);
89 }
90 }
91}
92
93const wxBitmap &ThumbWin::GetBitmap() {
94 if (pThumbChart) {
95 if (pThumbChart->GetThumbData()) {
96 if (pThumbChart->GetThumbData()->pDIBThumb)
97 m_bitmap = *(pThumbChart->GetThumbData()->pDIBThumb);
98 }
99 }
100
101 return m_bitmap;
102}
Charts database management
Window for displaying chart thumbnails.
Definition thumbwin.h:47
Global color handling by name.
ThumbWin * pthumbwin
Global instance.
Definition thumbwin.cpp:40
Chart thumbnail object.