OpenCPN Partial API docs
Loading...
Searching...
No Matches
toolbar.cpp
1/***************************************************************************
2 *
3 * Project: OpenCPN
4 * Purpose: OpenCPN Toolbar
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#include <wx/wxprec.h>
27
28#ifndef WX_PRECOMP
29#include <wx/wx.h>
30#endif
31
32#include <vector>
33
34#include "config.h"
36#include "model/ocpn_types.h"
37#include "navutil.h"
38#include "styles.h"
39#include "toolbar.h"
40#include "pluginmanager.h"
41#include "FontMgr.h"
42#include "OCPNPlatform.h"
43#include "chcanv.h"
44#include "gui_lib.h"
45#include "model/svg_utils.h"
46#include "model/idents.h"
47#include "ocpn_frame.h"
48
49#ifdef __OCPN__ANDROID__
50#include "androidUTIL.h"
51#endif
52
53#ifdef ocpnUSE_GL
54#include "glChartCanvas.h"
55#endif
56
57extern bool g_bTransparentToolbar;
58extern bool g_bTransparentToolbarInOpenGLOK;
59extern bool g_bopengl;
60extern ocpnStyle::StyleManager *g_StyleManager;
61extern MyFrame *gFrame;
62extern PlugInManager *g_pi_manager;
63extern bool g_bPermanentMOBIcon;
64extern bool g_bsmoothpanzoom;
65extern OCPNPlatform *g_Platform;
66extern bool g_bmasterToolbarFull;
67extern bool g_useMUI;
68extern wxString g_toolbarConfig;
69extern double g_plus_minus_zoom_factor;
70extern int g_maintoolbar_x;
71extern int g_maintoolbar_y;
72extern bool g_disable_main_toolbar;
73
74#ifdef ocpnUSE_GL
75extern GLenum g_texture_rectangle_format;
76#endif
77
78ocpnFloatingToolbarDialog *g_MainToolbar;
79
80class ocpnToolBarTool : public wxToolBarToolBase {
81public:
82 ocpnToolBarTool(ocpnToolBarSimple *tbar, int id, const wxString &label,
83 const wxBitmap &bmpNormal, const wxBitmap &bmpRollover,
84 wxItemKind kind, wxObject *clientData,
85 const wxString &shortHelp, const wxString &longHelp)
86 : wxToolBarToolBase((wxToolBarBase *)tbar, id, label, bmpNormal,
87 bmpRollover, kind, clientData, shortHelp, longHelp) {
88 m_enabled = true;
89 m_toggled = false;
90 rollover = false;
91 bitmapOK = false;
92 m_btooltip_hiviz = false;
93
94 toolname = g_pi_manager->GetToolOwnerCommonName(id);
95 if (toolname == "") {
96 isPluginTool = false;
97 toolname = label;
98 iconName = label;
99
100 } else {
101 isPluginTool = true;
102 pluginNormalIcon = bmpNormal;
103 pluginRolloverIcon = bmpRollover;
104 }
105 }
106
107 ocpnToolBarTool(ocpnToolBarSimple *tbar, int id, const wxBitmap &bmpNormal,
108 const wxBitmap &bmpRollover, wxItemKind kind,
109 wxObject *clientData, const wxString &shortHelp,
110 const wxString &longHelp)
111 : wxToolBarToolBase((wxToolBarBase *)tbar, id, "", bmpNormal, bmpRollover,
112 kind, clientData, shortHelp, longHelp) {
113 m_enabled = true;
114 m_toggled = false;
115 rollover = false;
116 m_btooltip_hiviz = false;
117 isPluginTool = false;
118
119 m_bmpNormal = bmpNormal;
120 bitmapOK = true;
121 }
122
123 void SetSize(const wxSize &size) {
124 m_width = size.x;
125 m_height = size.y;
126 }
127
128 wxCoord GetWidth() const { return m_width; }
129
130 wxCoord GetHeight() const { return m_height; }
131
132 wxString GetToolname() { return toolname; }
133
134 void SetIconName(wxString name) { iconName = name; }
135 wxString GetIconName() { return iconName; }
136
137 void SetTooltipHiviz(bool enable) { m_btooltip_hiviz = enable; }
138
139 wxCoord m_x;
140 wxCoord m_y;
141 wxCoord m_width;
142 wxCoord m_height;
143 wxRect trect;
144 wxString toolname;
145 wxString iconName;
146 wxBitmap pluginNormalIcon;
147 wxBitmap pluginRolloverIcon;
148 const wxBitmap *pluginToggledIcon;
149 bool firstInLine;
150 bool lastInLine;
151 bool rollover;
152 bool bitmapOK;
153 bool isPluginTool;
154 bool b_hilite;
155 bool m_btooltip_hiviz;
156 wxRect last_rect;
157 wxString pluginNormalIconSVG;
158 wxString pluginRolloverIconSVG;
159 wxString pluginToggledIconSVG;
160 wxBitmap m_activeBitmap;
161};
162
163//---------------------------------------------------------------------------------------
164// ocpnFloatingToolbarDialog Implementation
165//---------------------------------------------------------------------------------------
166
167ocpnFloatingToolbarDialog::ocpnFloatingToolbarDialog(wxWindow *parent,
168 wxPoint position,
169 long orient,
170 float size_factor) {
171 m_pparent = parent;
172 m_ptoolbar = NULL;
173
174 m_opacity = 255;
175 m_position = position;
176 m_orient = orient;
177 m_sizefactor = size_factor;
178 m_cornerRadius = 0;
179
180 m_bAutoHideToolbar = false;
181 m_nAutoHideToolbar = 5;
182 m_toolbar_scale_tools_shown = false;
183 m_backcolorString = "GREY3";
184 m_toolShowMask = "XXXXXXXXXXXXXXXX";
185 n_toolbarHideMethod = TOOLBAR_HIDE_TO_GRABBER;
186 b_canToggleOrientation = true;
187 m_enableRolloverBitmaps = true;
188 m_auxOffsetY = 0;
189
190 m_ptoolbar = CreateNewToolbar();
191 if (m_ptoolbar) m_ptoolbar->SetBackgroundColour(GetGlobalColor("GREY3"));
192 m_cs = (ColorScheme)-1;
193
194 m_style = g_StyleManager->GetCurrentStyle();
195 SetULDockPosition(wxPoint(4, 4));
196
197 SetGeometry(false, wxRect());
198
199 // Set initial "Dock" parameters
200 m_dock_x = 0;
201 m_dock_y = 0;
202 m_block = false;
203
204 m_texture = 0;
205
206 m_marginsInvisible = m_style->marginsInvisible;
207
208 m_FloatingToolbarConfigMenu = NULL;
209
210 m_fade_timer.SetOwner(this);
211 this->Connect(wxEVT_TIMER,
212 wxTimerEventHandler(ocpnFloatingToolbarDialog::FadeTimerEvent),
213 NULL, this);
214
215 if (m_bAutoHideToolbar && (m_nAutoHideToolbar > 0))
216 m_fade_timer.Start(m_nAutoHideToolbar * 1000);
217
218 m_bsubmerged = false;
219 m_benableSubmerge = true;
220}
221
222ocpnFloatingToolbarDialog::~ocpnFloatingToolbarDialog() {
223 delete m_FloatingToolbarConfigMenu;
224
225 DestroyToolBar();
226}
227
228void ocpnFloatingToolbarDialog::FadeTimerEvent(wxTimerEvent &event) {
229 if (n_toolbarHideMethod == TOOLBAR_HIDE_TO_FIRST_TOOL) {
230 if (g_bmasterToolbarFull) {
231 if (m_bAutoHideToolbar && (m_nAutoHideToolbar > 0) /*&& !m_bsubmerged*/) {
232 // Double check the mouse position
233 wxPoint mp =
234 gFrame->GetPrimaryCanvas()->ScreenToClient(::wxGetMousePosition());
235 // in the toolbar?
236 wxRect r = GetToolbarRect();
237 if (r.Contains(mp)) return;
238
239 wxCommandEvent event;
240 event.SetId(ID_MASTERTOGGLE);
241 gFrame->OnToolLeftClick(event);
242 }
243 }
244 }
245}
246
247void ocpnFloatingToolbarDialog::AddToolItem(ToolbarItemContainer *item) {
248 m_Items.push_back(item);
249}
250
251int ocpnFloatingToolbarDialog::RebuildToolbar() {
252 ocpnToolBarSimple *tb = GetToolbar();
253 if (!tb) return 0;
254
255 // Iterate over the array of items added,
256 // Creating the toolbar from enabled items.
257 int i_count = 0;
258 for (auto it = m_Items.cbegin(); it != m_Items.cend(); it++) {
259 ToolbarItemContainer *tic = *it;
260 if (!tic) continue;
261
262 bool bEnabled = _toolbarConfigMenuUtil(tic);
263
264 if (bEnabled) {
265 wxToolBarToolBase *tool =
266 tb->AddTool(tic->m_ID, tic->m_label, tic->m_bmpNormal,
267 tic->m_bmpDisabled, tic->m_toolKind, tic->m_tipString);
268 tic->m_tool = tool;
269
270 // Plugin tools may have prescribed their own SVG toolbars as file
271 // locations.
272 if (!tic->m_NormalIconSVG.IsEmpty()) {
273 tb->SetToolBitmapsSVG(tic->m_ID, tic->m_NormalIconSVG,
274 tic->m_RolloverIconSVG, tic->m_ToggledIconSVG);
275 }
276 }
277
278 i_count++;
279 }
280
281 return i_count;
282}
283
284void ocpnFloatingToolbarDialog::SetULDockPosition(wxPoint position) {
285 if (position.x >= 0) m_dock_min_x = position.x;
286 if (position.y >= 0) m_dock_min_y = position.y;
287}
288
289size_t ocpnFloatingToolbarDialog::GetToolCount() {
290 if (m_ptoolbar)
291 return m_ptoolbar->GetToolsCount();
292 else
293 return 0;
294}
295
296void ocpnFloatingToolbarDialog::SetToolShowMask(wxString mask) {}
297
298void ocpnFloatingToolbarDialog::SetToolShowCount(int count) {
299 if (m_ptoolbar) {
300 m_ptoolbar->SetToolShowCount(count);
301 m_ptoolbar->SetDirty(true);
302 }
303}
304
305int ocpnFloatingToolbarDialog::GetToolShowCount(void) {
306 if (m_ptoolbar)
307 return m_ptoolbar->GetToolShowCount();
308 else
309 return 0;
310}
311
312void ocpnFloatingToolbarDialog::SetBackGroundColorString(wxString colorRef) {
313 m_backcolorString = colorRef;
314 SetColorScheme(m_cs); // Causes a reload of background color
315}
316
317void ocpnFloatingToolbarDialog::OnKeyDown(wxKeyEvent &event) { event.Skip(); }
318
319void ocpnFloatingToolbarDialog::OnKeyUp(wxKeyEvent &event) { event.Skip(); }
320
321void ocpnFloatingToolbarDialog::CreateConfigMenu() {
322 if (m_FloatingToolbarConfigMenu) delete m_FloatingToolbarConfigMenu;
323 m_FloatingToolbarConfigMenu = new wxMenu();
324}
325
326bool ocpnFloatingToolbarDialog::_toolbarConfigMenuUtil(
328 if (m_FloatingToolbarConfigMenu) {
329 wxMenuItem *menuitem;
330
331 if (tic->m_ID == ID_MOB && g_bPermanentMOBIcon) return true;
332
333 if (tic->m_bRequired) return true;
334 if (tic->m_bPlugin) return true;
335
336 // Item ID trickery is needed because the wxCommandEvents for menu item
337 // clicked and toolbar button clicked are 100% identical, so if we use same
338 // id's we can't tell the events apart.
339
340 int idOffset = 100; // Hopefully no more than 100 total icons...
341 int menuItemId = tic->m_ID + idOffset;
342
343 menuitem = m_FloatingToolbarConfigMenu->FindItem(menuItemId);
344
345 if (menuitem) {
346 return menuitem->IsChecked();
347 }
348
349 menuitem = m_FloatingToolbarConfigMenu->AppendCheckItem(menuItemId,
350 tic->m_tipString);
351 size_t n = m_FloatingToolbarConfigMenu->GetMenuItemCount();
352 menuitem->Check(m_configString.Len() >= n
353 ? m_configString.GetChar(n - 1) == _T('X')
354 : true);
355 return menuitem->IsChecked();
356 } else
357 return true;
358}
359
360void ocpnFloatingToolbarDialog::EnableTool(int toolid, bool enable) {
361 if (m_ptoolbar) m_ptoolbar->EnableTool(toolid, enable);
362}
363
364void ocpnFloatingToolbarDialog::SetColorScheme(ColorScheme cs) {
365 m_cs = cs;
366 wxColour back_color = GetGlobalColor(m_backcolorString);
367
368 if (m_ptoolbar) {
369 m_ptoolbar->SetToggledBackgroundColour(GetGlobalColor("GREY1"));
370 m_ptoolbar->SetColorScheme(cs);
371 }
372}
373
374wxSize ocpnFloatingToolbarDialog::GetToolSize() {
375 wxSize style_tool_size;
376 if (m_ptoolbar) {
377 style_tool_size = m_style->GetToolSize();
378
379 style_tool_size.x *= m_sizefactor;
380 style_tool_size.y *= m_sizefactor;
381 } else {
382 style_tool_size.x = 32;
383 style_tool_size.y = 32;
384 }
385
386 return style_tool_size;
387}
388
389void ocpnFloatingToolbarDialog::SetGeometry(bool bAvoid, wxRect rectAvoid) {
390 if (m_ptoolbar) {
391 wxSize style_tool_size = m_style->GetToolSize();
392
393 style_tool_size.x *= m_sizefactor;
394 style_tool_size.y *= m_sizefactor;
395
396 m_ptoolbar->SetToolBitmapSize(style_tool_size);
397
398 wxSize tool_size = m_ptoolbar->GetToolBitmapSize();
399 int grabber_width = m_style->GetIcon("grabber").GetWidth();
400
401 int max_rows = 10;
402 int max_cols = 100;
403
404 if (m_pparent) {
405 int avoid_start =
406 m_pparent->GetClientSize().x -
407 (tool_size.x + m_style->GetToolSeparation()) * 2; // default
408 if (bAvoid && !rectAvoid.IsEmpty()) {
409 avoid_start = m_pparent->GetClientSize().x - rectAvoid.width -
410 10; // this is compass window, if shown
411 }
412
413 max_rows = (m_pparent->GetClientSize().y /
414 (tool_size.y + m_style->GetToolSeparation())) -
415 2;
416
417 max_cols = (avoid_start - grabber_width) /
418 (tool_size.x + m_style->GetToolSeparation());
419 max_cols -= 1;
420
421 if (m_orient == wxTB_VERTICAL)
422 max_rows = wxMax(max_rows, 2); // at least two rows
423 else
424 max_cols = wxMax(max_cols, 2); // at least two columns
425 }
426
427 if (m_orient == wxTB_VERTICAL)
428 m_ptoolbar->SetMaxRowsCols(max_rows, 100);
429 else
430 m_ptoolbar->SetMaxRowsCols(100, max_cols);
431 m_ptoolbar->SetSizeFactor(m_sizefactor);
432 }
433}
434
435void ocpnFloatingToolbarDialog::SetDefaultPosition() {
436 if (m_block) return;
437
438 if (m_pparent && m_ptoolbar) {
439 wxSize cs = m_pparent->GetClientSize();
440 if (-1 == m_dock_x)
441 m_position.x = m_dock_min_x;
442 else if (1 == m_dock_x)
443 m_position.x = cs.x - m_ptoolbar->m_maxWidth;
444
445 if (-1 == m_dock_y)
446 m_position.y = m_dock_min_y;
447 else if (1 == m_dock_y)
448 m_position.y = cs.y - m_ptoolbar->m_maxHeight;
449
450 m_position.x = wxMin(cs.x - m_ptoolbar->m_maxWidth, m_position.x);
451 m_position.y = wxMin(cs.y - m_ptoolbar->m_maxHeight, m_position.y);
452
453 m_position.x = wxMax(m_dock_min_x, m_position.x);
454 m_position.y = wxMax(m_dock_min_y, m_position.y);
455
456 m_position.y += m_auxOffsetY;
457
458 g_maintoolbar_x = m_position.x;
459 g_maintoolbar_y = m_position.y;
460
461 // take care of left docked instrument windows and don't blast the main
462 // toolbar on top of them, hinding instruments this positions the main
463 // toolbar directly right of the left docked instruments onto the chart
464 // wxPoint screen_pos = m_pparent->ClientToScreen( m_position );
465 // wxPoint screen_pos =
466 // gFrame->GetPrimaryCanvas()->ClientToScreen(m_position);
467
468 // GTK sometimes has trouble with ClientToScreen() if executed in the
469 // context of an event handler The position of the window is calculated
470 // incorrectly if a deferred Move() has not been processed yet. So work
471 // around this here... Discovered with a Dashboard window left-docked,
472 // toggled on and off by toolbar tool.
473
474 // But this causes another problem. If a toolbar is NOT left docked, it
475 // will walk left by two pixels on each call to Reposition().
476 // TODO
477 }
478}
479
480void ocpnFloatingToolbarDialog::Submerge() {
481 m_bsubmerged = true;
482 // Hide();
483 if (m_ptoolbar) m_ptoolbar->KillTooltip();
484}
485
486void ocpnFloatingToolbarDialog::HideTooltip() {
487#ifndef __OCPN__ANDROID__
488 if (m_ptoolbar) m_ptoolbar->HideTooltip();
489#endif
490}
491
492void ocpnFloatingToolbarDialog::ShowTooltips() {
493#ifndef __OCPN__ANDROID__
494 if (m_ptoolbar) m_ptoolbar->EnableTooltips();
495#endif
496}
497
498void ocpnFloatingToolbarDialog::ToggleOrientation() {}
499
500wxRect ocpnFloatingToolbarDialog::GetToolbarRect() {
501 return wxRect(m_position.x, m_position.y, m_ptoolbar->m_maxWidth,
502 m_ptoolbar->m_maxHeight);
503}
504
505wxSize ocpnFloatingToolbarDialog::GetToolbarSize() {
506 return wxSize(m_ptoolbar->m_maxWidth, m_ptoolbar->m_maxHeight);
507}
508
509wxPoint ocpnFloatingToolbarDialog::GetToolbarPosition() {
510 return wxPoint(m_position.x, m_position.y);
511}
512
513bool ocpnFloatingToolbarDialog::MouseEvent(wxMouseEvent &event) {
514 if (g_disable_main_toolbar) return false;
515 if (m_ptoolbar) {
516 bool bproc = m_ptoolbar->OnMouseEvent(event, m_position);
517 if (bproc) m_ptoolbar->CreateBitmap();
518 return bproc;
519 } else
520 return false;
521}
522
523void ocpnFloatingToolbarDialog::RefreshToolbar() {
524 if (m_ptoolbar) {
525 if (m_ptoolbar->IsDirty()) {
526 Realize();
527 gFrame->GetPrimaryCanvas()->Refresh();
528 }
529 }
530}
531
532void ocpnFloatingToolbarDialog::SetAutoHideTimer(int time) {
533 m_nAutoHideToolbar = time;
534 if (m_bAutoHideToolbar) {
535 m_fade_timer.Stop();
536 m_fade_timer.Start(m_nAutoHideToolbar * 1000);
537 }
538}
539
540void ocpnFloatingToolbarDialog::RefreshFadeTimer() {
541 if (m_bAutoHideToolbar && (m_nAutoHideToolbar > 0)) {
542 m_fade_timer.Start(m_nAutoHideToolbar * 1000);
543 }
544}
545
546void ocpnFloatingToolbarDialog::SetToolShortHelp(int id, const wxString &help) {
547 if (m_ptoolbar) m_ptoolbar->SetToolShortHelp(id, help);
548}
549
550void ocpnFloatingToolbarDialog::Realize() {
551 if (m_ptoolbar) {
552 m_ptoolbar->Realize();
553 m_ptoolbar->CreateBitmap();
554 m_toolbar_image.Destroy();
555 }
556}
557
558void ocpnFloatingToolbarDialog::DrawDC(ocpnDC &dc, double displayScale) {
559 if (m_ptoolbar) {
560 m_ptoolbar->CreateBitmap();
561 if (m_ptoolbar->GetBitmap().IsOk()) {
562 dc.DrawBitmap(m_ptoolbar->GetBitmap(), m_position.x, m_position.y, false);
563 m_ptoolbar->SetDirty(false);
564 }
565 }
566}
567
568void ocpnFloatingToolbarDialog::DrawGL(ocpnDC &gldc, double displayScale) {
569 if (g_disable_main_toolbar) return;
570
571#ifdef ocpnUSE_GL
572 if (!m_ptoolbar) return;
573
574 wxColour backColor = GetGlobalColor("GREY3");
575 gldc.SetBrush(wxBrush(backColor));
576 gldc.SetPen(wxPen(backColor));
577
578 wxRect r = GetToolbarRect();
579 int m_end_margin = wxMin(GetToolSize().x, GetToolSize().y) / 8;
580
581 if (m_orient == wxHORIZONTAL)
582 gldc.DrawRoundedRectangle(
583 (r.x - m_end_margin / 2) * displayScale, (r.y - 1) * displayScale,
584 (r.width + m_end_margin) * displayScale, (r.height + 2) * displayScale,
585 (m_end_margin * 1) * displayScale);
586 else
587 gldc.DrawRoundedRectangle(
588 (r.x - 1) * displayScale, (r.y - m_end_margin / 2) * displayScale,
589 (r.width + 2) * displayScale, (r.height + m_end_margin) * displayScale,
590 (m_end_margin * 1.5) * displayScale);
591
592 int width = GetToolbarSize().x;
593 int height = GetToolbarSize().y;
594
595 m_ptoolbar->CreateBitmap(displayScale);
596
597 // Make a GL texture
598 if (!m_texture) {
599 glGenTextures(1, &m_texture);
600
601 glBindTexture(g_texture_rectangle_format, m_texture);
602 glTexParameterf(g_texture_rectangle_format, GL_TEXTURE_MIN_FILTER,
603 GL_NEAREST);
604 glTexParameteri(g_texture_rectangle_format, GL_TEXTURE_MAG_FILTER,
605 GL_NEAREST);
606 glTexParameteri(g_texture_rectangle_format, GL_TEXTURE_WRAP_S,
607 GL_CLAMP_TO_EDGE);
608 glTexParameteri(g_texture_rectangle_format, GL_TEXTURE_WRAP_T,
609 GL_CLAMP_TO_EDGE);
610 } else {
611 glBindTexture(g_texture_rectangle_format, m_texture);
612 }
613
614 if (!m_toolbar_image.IsOk()) {
615 // fill texture data
616 m_toolbar_image = m_ptoolbar->GetBitmap().ConvertToImage();
617
618 unsigned char *d = m_toolbar_image.GetData();
619 unsigned char *e = new unsigned char[4 * width * height];
620 for (int y = 0; y < height; y++)
621 for (int x = 0; x < width; x++) {
622 int i = y * width + x;
623 memcpy(e + 4 * i, d + 3 * i, 3);
624 e[4 * i + 3] = 255; // d[3*i + 2] == 255 ? 0:255; //255 - d[3 * i + 2];
625 }
626 glTexImage2D(g_texture_rectangle_format, 0, GL_RGBA, width, height, 0,
627 GL_RGBA, GL_UNSIGNED_BYTE, e);
628 delete[] e;
629 glDisable(g_texture_rectangle_format);
630 glDisable(GL_BLEND);
631 }
632
633 // Render the texture
634 if (m_texture) {
635 glEnable(g_texture_rectangle_format);
636 glBindTexture(g_texture_rectangle_format, m_texture);
637 glEnable(GL_BLEND);
638
639 int x0 = GetToolbarPosition().x, x1 = x0 + width;
640 int y0 = GetToolbarPosition().y - 0, y1 = y0 + height;
641 x0 *= displayScale;
642 x1 *= displayScale;
643 y0 *= displayScale;
644 y1 *= displayScale;
645
646 float tx, ty;
647 if (GL_TEXTURE_RECTANGLE_ARB == g_texture_rectangle_format)
648 tx = width, ty = height;
649 else
650 tx = ty = 1;
651
652 float coords[8];
653 float uv[8];
654
655 // normal uv
656 uv[0] = 0;
657 uv[1] = 0;
658 uv[2] = tx;
659 uv[3] = 0;
660 uv[4] = tx;
661 uv[5] = ty;
662 uv[6] = 0;
663 uv[7] = ty;
664
665 // pixels
666 coords[0] = x0;
667 coords[1] = y0;
668 coords[2] = x1;
669 coords[3] = y0;
670 coords[4] = x1;
671 coords[5] = y1;
672 coords[6] = x0;
673 coords[7] = y1;
674
675 auto canvas = gFrame->GetPrimaryCanvas();
676 canvas->GetglCanvas()->RenderTextures(gldc, coords, uv, 4,
677 canvas->GetpVP());
678
679 glDisable(g_texture_rectangle_format);
680 glBindTexture(g_texture_rectangle_format, 0);
681 glDisable(GL_BLEND);
682 }
683#endif
684
685 return;
686}
687
688void ocpnFloatingToolbarDialog::OnToolLeftClick(wxCommandEvent &event) {
689 // Since Dialog events don't propagate automatically, we send it explicitly
690 // (instead of relying on event.Skip()). Send events up the window hierarchy
691
692 m_pparent->GetEventHandler()->AddPendingEvent(event);
693#ifndef __WXQT__
694 gFrame->Raise();
695#endif
696}
697
698ocpnToolBarSimple *ocpnFloatingToolbarDialog::GetToolbar() {
699 if (!m_ptoolbar) {
700 m_ptoolbar = CreateNewToolbar();
701 }
702
703 return m_ptoolbar;
704}
705
706ocpnToolBarSimple *ocpnFloatingToolbarDialog::CreateNewToolbar() {
707 long winstyle = wxNO_BORDER | wxTB_FLAT;
708 winstyle |= m_orient;
709
710 m_ptoolbar = new ocpnToolBarSimple(this, -1, wxPoint(-1, -1), wxSize(-1, -1),
711 winstyle, m_orient);
712
713 // m_ptoolbar->SetBackgroundColour(GetGlobalColor("GREY2"));
714 // m_ptoolbar->ClearBackground();
715 m_ptoolbar->SetToggledBackgroundColour(GetGlobalColor("GREY1"));
716 m_ptoolbar->SetColorScheme(m_cs);
717 m_ptoolbar->EnableRolloverBitmaps(GetEnableRolloverBitmaps());
718
719 return m_ptoolbar;
720}
721
722void ocpnFloatingToolbarDialog::DestroyToolBar() {
723 g_toolbarConfig = GetToolConfigString();
724
725 if (m_ptoolbar) {
726 m_ptoolbar->ClearTools();
727 delete m_ptoolbar; //->Destroy();
728 m_ptoolbar = NULL;
729 }
730
731 for (auto it = m_Items.cbegin(); it != m_Items.cend(); it++) {
732 delete *it;
733 }
734 m_Items.clear();
735}
736
737#include "s52plib.h"
738#include "compass.h"
739#include "chartdb.h"
740
741extern bool g_bTrackActive;
742extern s52plib *ps52plib;
743
744bool ocpnFloatingToolbarDialog::CheckAndAddPlugInTool(ocpnToolBarSimple *tb) {
745 if (!g_pi_manager) return false;
746
747 bool bret = false;
748 int n_tools = tb->GetToolsCount();
749
750 // Walk the PlugIn tool spec array, checking the requested position
751 // If a tool has been requested by a plugin at this position, add it
752 ArrayOfPlugInToolbarTools tool_array =
753 g_pi_manager->GetPluginToolbarToolArray();
754
755 for (unsigned int i = 0; i < tool_array.GetCount(); i++) {
756 PlugInToolbarToolContainer *pttc = tool_array.Item(i);
757 if (pttc->position == n_tools) {
758 wxBitmap *ptool_bmp;
759
760 switch (m_cs) {
761 case GLOBAL_COLOR_SCHEME_DAY:
762 ptool_bmp = pttc->bitmap_day;
763 ;
764 break;
765 case GLOBAL_COLOR_SCHEME_DUSK:
766 ptool_bmp = pttc->bitmap_dusk;
767 break;
768 case GLOBAL_COLOR_SCHEME_NIGHT:
769 ptool_bmp = pttc->bitmap_night;
770 break;
771 default:
772 ptool_bmp = pttc->bitmap_day;
773 ;
774 break;
775 }
776
777 wxToolBarToolBase *tool =
778 tb->AddTool(pttc->id, wxString(pttc->label), *(ptool_bmp),
779 wxString(pttc->shortHelp), pttc->kind);
780
781 tb->SetToolBitmapsSVG(pttc->id, pttc->pluginNormalIconSVG,
782 pttc->pluginRolloverIconSVG,
783 pttc->pluginToggledIconSVG);
784
785 bret = true;
786 }
787 }
788
789 // If we added a tool, call again (recursively) to allow for adding
790 // adjacent tools
791 if (bret)
792 while (CheckAndAddPlugInTool(tb)) { /* nothing to do */
793 }
794
795 return bret;
796}
797
798void ocpnFloatingToolbarDialog::EnableRolloverBitmaps(bool bEnable) {
799 m_enableRolloverBitmaps = bEnable;
800 if (m_ptoolbar) m_ptoolbar->EnableRolloverBitmaps(bEnable);
801}
802
803//----------------------------------------------------------------------------
804// Toolbar Tooltip Popup Window Definition
805//----------------------------------------------------------------------------
806class ToolTipWin : public wxFrame {
807public:
808 ToolTipWin(wxWindow *parent);
809 ~ToolTipWin();
810
811 void OnPaint(wxPaintEvent &event);
812
813 void SetColorScheme(ColorScheme cs);
814 void SetString(wxString &s) { m_string = s; }
815 void SetPosition(wxPoint pt) { m_position = pt; }
816 void SetBitmap(void);
817
818 void SetHiviz(bool hiviz) { m_hiviz = hiviz; }
819
820 wxSize GetRenderedSize(void);
821
822private:
823 wxString m_string;
824 wxSize m_size;
825 wxPoint m_position;
826 wxBitmap *m_pbm;
827 wxColour m_back_color;
828 wxColour m_text_color;
829 ColorScheme m_cs;
830 bool m_hiviz;
831
832 DECLARE_EVENT_TABLE()
833};
834//-----------------------------------------------------------------------
835//
836// Toolbar Tooltip window implementation
837//
838//-----------------------------------------------------------------------
839BEGIN_EVENT_TABLE(ToolTipWin, wxFrame)
840EVT_PAINT(ToolTipWin::OnPaint)
841
842END_EVENT_TABLE()
843
844// Define a constructor
845ToolTipWin::ToolTipWin(wxWindow *parent)
846 : wxFrame(parent, wxID_ANY, "", wxPoint(0, 0), wxSize(1, 1),
847 wxNO_BORDER | wxFRAME_FLOAT_ON_PARENT | wxFRAME_NO_TASKBAR) {
848 m_pbm = NULL;
849
850 m_back_color =
851 GetDimedColor(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW));
852 m_text_color =
853 GetDimedColor(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT));
854
855 SetBackgroundStyle(wxBG_STYLE_CUSTOM);
856 SetBackgroundColour(m_back_color);
857 m_cs = GLOBAL_COLOR_SCHEME_RGB;
858
859 Hide();
860}
861
862ToolTipWin::~ToolTipWin() { delete m_pbm; }
863
864void ToolTipWin::SetColorScheme(ColorScheme cs) {
865 m_back_color =
866 GetDimedColor(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW));
867 m_text_color =
868 GetDimedColor(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT));
869
870#ifndef __WXOSX__
871 m_text_color = GetDimedColor(FontMgr::Get().GetFontColor(_("ToolTips")));
872#endif
873
874 m_cs = cs;
875}
876
877wxSize ToolTipWin::GetRenderedSize(void) {
878 int h, w;
879 wxSize sz;
880
881 wxScreenDC cdc;
882
883 wxFont *plabelFont = FontMgr::Get().GetFont(_("ToolTips"));
884 cdc.GetTextExtent(m_string, &w, &h, NULL, NULL, plabelFont);
885
886 sz.x = w + 8;
887 sz.y = h + 4;
888
889 return sz;
890}
891
892void ToolTipWin::SetBitmap() {
893 int h, w;
894
895 wxScreenDC cdc;
896 double scaler = g_Platform->GetDisplayDIPMult(this);
897
898 wxFont *plabelFont = FontMgr::Get().GetFont(_("ToolTips"));
899 wxFont sFont = plabelFont->Scaled(1.0 / scaler);
900
901 cdc.GetTextExtent(m_string, &w, &h, NULL, NULL, &sFont);
902
903 m_size.x = w + GetCharWidth() * 2;
904 m_size.y = h + GetCharHeight() / 2;
905
906 m_size.x *= scaler;
907 m_size.y *= scaler;
908
909 wxMemoryDC mdc;
910
911 delete m_pbm;
912 m_pbm = new wxBitmap(m_size.x, m_size.y, -1);
913 mdc.SelectObject(*m_pbm);
914
915 wxPen pborder(m_text_color);
916 wxBrush bback(m_back_color);
917 mdc.SetPen(pborder);
918 mdc.SetBrush(bback);
919
920 if (m_hiviz) {
921 if ((m_cs == GLOBAL_COLOR_SCHEME_DUSK) ||
922 (m_cs == GLOBAL_COLOR_SCHEME_NIGHT)) {
923 wxBrush hv_back(wxColour(200, 200, 200));
924 mdc.SetBrush(hv_back);
925 }
926 }
927 mdc.DrawRectangle(0, 0, m_size.x, m_size.y);
928
929 // Draw the text
930 mdc.SetFont(sFont);
931 mdc.SetTextForeground(m_text_color);
932 mdc.SetTextBackground(m_back_color);
933
934 int offx = GetCharWidth();
935 int offy = GetCharHeight() / 4;
936 offx *= scaler;
937 offy *= scaler;
938 mdc.DrawText(m_string, offx, offy);
939
940 SetClientSize(m_size.x, m_size.y);
941 SetSize(m_position.x, m_position.y, m_size.x, m_size.y);
942}
943
944void ToolTipWin::OnPaint(wxPaintEvent &event) {
945 int width, height;
946 GetClientSize(&width, &height);
947 wxPaintDC dc(this);
948
949 if (m_string.Len()) {
950 wxMemoryDC mdc;
951 mdc.SelectObject(*m_pbm);
952 dc.Blit(0, 0, width, height, &mdc, 0, 0);
953 }
954}
955
956// ----------------------------------------------------------------------------
957
958// ============================================================================
959// implementation
960// ============================================================================
961// ----------------------------------------------------------------------------
962BEGIN_EVENT_TABLE(ocpnToolBarSimple, wxEvtHandler)
963EVT_TIMER(TOOLTIPON_TIMER, ocpnToolBarSimple::OnToolTipTimerEvent)
964EVT_TIMER(TOOLTIPOFF_TIMER, ocpnToolBarSimple::OnToolTipOffTimerEvent)
965END_EVENT_TABLE()
966
967// ----------------------------------------------------------------------------
968// tool bar tools creation
969// ----------------------------------------------------------------------------
970
971wxToolBarToolBase *ocpnToolBarSimple::CreateTool(
972 int id, const wxString &label, const wxBitmap &bmpNormal,
973 const wxBitmap &bmpDisabled, wxItemKind kind, wxObject *clientData,
974 const wxString &shortHelp, const wxString &longHelp) {
975 if (m_style->NativeToolIconExists(label)) {
976 return new ocpnToolBarTool(this, id, label, bmpNormal, bmpDisabled, kind,
977 clientData, shortHelp, longHelp);
978 } else {
979 wxString testToolname = g_pi_manager->GetToolOwnerCommonName(id);
980
981 if (testToolname == "") { // Not a PlugIn tool...
982 return new ocpnToolBarTool(this, id, bmpNormal, bmpDisabled, kind,
983 clientData, shortHelp, longHelp);
984 } else {
985 return new ocpnToolBarTool(this, id, label, bmpNormal, bmpDisabled, kind,
986 clientData, shortHelp, longHelp);
987 }
988 }
989}
990
991// ----------------------------------------------------------------------------
992// ocpnToolBarSimple creation
993// ----------------------------------------------------------------------------
994
995void ocpnToolBarSimple::Init() {
996 m_currentRowsOrColumns = 0;
997
998 m_lastX = m_lastY = 0;
999
1000 m_maxWidth = m_maxHeight = 0;
1001
1002 m_pressedTool = m_currentTool = -1;
1003
1004 m_xPos = m_yPos = wxDefaultCoord;
1005
1006 m_style = g_StyleManager->GetCurrentStyle();
1007
1008 m_defaultWidth = 16;
1009 m_defaultHeight = 15;
1010
1011 m_toggle_bg_color = wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE);
1012 m_toolOutlineColour.Set("BLACK");
1013 m_pToolTipWin = NULL;
1014 m_last_ro_tool = NULL;
1015
1016 m_btoolbar_is_zooming = false;
1017 m_sizefactor = 1.0f;
1018
1019 m_last_plugin_down_id = -1;
1020 m_leftDown = false;
1021 m_nShowTools = 0;
1022 m_btooltip_show = false;
1023#ifndef __OCPN__ANDROID__
1024 EnableTooltips();
1025#endif
1026 m_tbenableRolloverBitmaps = false;
1027}
1028
1029wxToolBarToolBase *ocpnToolBarSimple::DoAddTool(
1030 int id, const wxString &label, const wxBitmap &bitmap,
1031 const wxBitmap &bmpDisabled, wxItemKind kind, const wxString &shortHelp,
1032 const wxString &longHelp, wxObject *clientData, wxCoord xPos,
1033 wxCoord yPos) {
1034 // rememeber the position for DoInsertTool()
1035 m_xPos = xPos;
1036 m_yPos = yPos;
1037
1038 // InvalidateBestSize();
1039 return InsertTool(GetToolsCount(), id, label, bitmap, bmpDisabled, kind,
1040 shortHelp, longHelp, clientData);
1041}
1042
1044
1045wxToolBarToolBase *ocpnToolBarSimple::AddTool(
1046 int toolid, const wxString &label, const wxBitmap &bitmap,
1047 const wxBitmap &bmpDisabled, wxItemKind kind, const wxString &shortHelp,
1048 const wxString &longHelp, wxObject *data) {
1049 // InvalidateBestSize();
1050 ocpnToolBarTool *tool = (ocpnToolBarTool *)InsertTool(
1051 GetToolsCount(), toolid, label, bitmap, bmpDisabled, kind, shortHelp,
1052 longHelp, data);
1053 return tool;
1054}
1055
1056wxToolBarToolBase *ocpnToolBarSimple::InsertTool(
1057 size_t pos, int id, const wxString &label, const wxBitmap &bitmap,
1058 const wxBitmap &bmpDisabled, wxItemKind kind, const wxString &shortHelp,
1059 const wxString &longHelp, wxObject *clientData) {
1060 wxCHECK_MSG(pos <= GetToolsCount(), (wxToolBarToolBase *)NULL,
1061 "invalid position in wxToolBar::InsertTool()");
1062
1063 wxToolBarToolBase *tool = CreateTool(id, label, bitmap, bmpDisabled, kind,
1064 clientData, shortHelp, longHelp);
1065
1066 if (!InsertTool(pos, tool)) {
1067 delete tool;
1068
1069 return NULL;
1070 }
1071
1072 return tool;
1073}
1074
1075wxToolBarToolBase *ocpnToolBarSimple::InsertTool(size_t pos,
1076 wxToolBarToolBase *tool) {
1077 wxCHECK_MSG(pos <= GetToolsCount(), (wxToolBarToolBase *)NULL,
1078 "invalid position in wxToolBar::InsertTool()");
1079
1080 if (!tool || !DoInsertTool(pos, tool)) {
1081 return NULL;
1082 }
1083
1084 m_tools.Insert(pos, tool);
1085 m_nShowTools++;
1086
1087 return tool;
1088}
1089
1090bool ocpnToolBarSimple::DoInsertTool(size_t WXUNUSED(pos),
1091 wxToolBarToolBase *toolBase) {
1092 ocpnToolBarTool *tool = (ocpnToolBarTool *)toolBase;
1093
1094 // Check if the plugin is inserting same-named tools. Make sure they have
1095 // different names, otherwise the style manager cannot differentiate between
1096 // them.
1097 if (tool->isPluginTool) {
1098 for (unsigned int i = 0; i < GetToolsCount(); i++) {
1099 if (tool->GetToolname() ==
1100 ((ocpnToolBarTool *)m_tools.Item(i)->GetData())->GetToolname()) {
1101 tool->toolname << "1";
1102 }
1103 }
1104 }
1105
1106 tool->m_x = m_xPos;
1107 if (tool->m_x == wxDefaultCoord) tool->m_x = m_style->GetLeftMargin();
1108
1109 tool->m_y = m_yPos;
1110 if (tool->m_y == wxDefaultCoord) tool->m_y = m_style->GetTopMargin();
1111
1112 if (tool->IsButton()) {
1113 tool->SetSize(GetToolSize());
1114
1115 // Calculate reasonable max size in case Layout() not called
1116 if ((tool->m_x + tool->GetNormalBitmap().GetWidth() +
1117 m_style->GetLeftMargin()) > m_maxWidth)
1118 m_maxWidth =
1119 (wxCoord)((tool->m_x + tool->GetWidth() + m_style->GetLeftMargin()));
1120
1121 if ((tool->m_y + tool->GetNormalBitmap().GetHeight() +
1122 m_style->GetTopMargin()) > m_maxHeight)
1123 m_maxHeight =
1124 (wxCoord)((tool->m_y + tool->GetHeight() + m_style->GetTopMargin()));
1125 }
1126
1127 else if (tool->IsControl()) {
1128 tool->SetSize(tool->GetControl()->GetSize());
1129 }
1130
1131 tool->b_hilite = false;
1132
1133 return true;
1134}
1135
1136bool ocpnToolBarSimple::DoDeleteTool(size_t WXUNUSED(pos),
1137 wxToolBarToolBase *tool) {
1138 // VZ: didn't test whether it works, but why not...
1139 tool->Detach();
1140
1141 if (m_last_ro_tool == tool) m_last_ro_tool = NULL;
1142
1143 // Refresh(false);
1144
1145 return true;
1146}
1147
1148bool ocpnToolBarSimple::Create(ocpnFloatingToolbarDialog *parent, wxWindowID id,
1149 const wxPoint &pos, const wxSize &size,
1150 long style, int orient) {
1151 m_parentContainer = parent;
1152 m_orient = orient;
1153
1154 if (IsVertical()) {
1155 m_lastX = 7;
1156 m_lastY = 3;
1157
1158 m_maxRows = 32000; // a lot
1159 m_maxCols = 1;
1160 } else {
1161 m_lastX = 3;
1162 m_lastY = 7;
1163
1164 m_maxRows = 1;
1165 m_maxCols = 32000; // a lot
1166 }
1167
1168 // SetCursor(*wxSTANDARD_CURSOR);
1169
1170 m_tooltip_timer.SetOwner(this, TOOLTIPON_TIMER);
1171 m_tooltipoff_timer.SetOwner(this, TOOLTIPOFF_TIMER);
1172 m_tooltip_off = 3000;
1173
1174 m_tbenableRolloverBitmaps = false;
1175
1176 return true;
1177}
1178
1179ocpnToolBarSimple::~ocpnToolBarSimple() {
1180 if (m_pToolTipWin) {
1181 m_pToolTipWin->Destroy();
1182 m_pToolTipWin = NULL;
1183 }
1184}
1185
1186void ocpnToolBarSimple::EnableTooltips() {
1187#ifndef __OCPN__ANDROID__
1188 m_btooltip_show = true;
1189#endif
1190}
1191
1192void ocpnToolBarSimple::DisableTooltips() {
1193#ifndef __OCPN__ANDROID__
1194 ocpnToolBarSimple::m_btooltip_show = false;
1195#endif
1196}
1197
1198void ocpnToolBarSimple::KillTooltip() {
1199 m_btooltip_show = false;
1200
1201 if (m_pToolTipWin) {
1202 m_pToolTipWin->Hide();
1203 m_pToolTipWin->Destroy();
1204 m_pToolTipWin = NULL;
1205 }
1206 m_tooltip_timer.Stop();
1207
1208 gFrame->Raise();
1209 gFrame->GetFocusCanvas()->TriggerDeferredFocus();
1210}
1211
1212void ocpnToolBarSimple::HideTooltip() {
1213#ifndef __OCPN__ANDROID__
1214 if (m_pToolTipWin) {
1215 m_pToolTipWin->Hide();
1216 }
1217#endif
1218}
1219
1220void ocpnToolBarSimple::SetColorScheme(ColorScheme cs) {
1221#ifndef __OCPN__ANDROID__
1222 if (m_pToolTipWin) {
1223 m_pToolTipWin->Destroy();
1224 m_pToolTipWin = NULL;
1225 }
1226#endif
1227 m_toolOutlineColour = GetGlobalColor("UIBDR");
1228
1229 m_currentColorScheme = cs;
1230}
1231
1232bool ocpnToolBarSimple::Realize() {
1233 if (IsVertical())
1234 m_style->SetOrientation(wxTB_VERTICAL);
1235 else
1236 m_style->SetOrientation(wxTB_HORIZONTAL);
1237
1238 wxSize toolSize = wxSize(-1, -1);
1239 int separatorSize = m_style->GetToolSeparation() * m_sizefactor;
1240 int topMargin = m_style->GetTopMargin() * m_sizefactor;
1241 int leftMargin = m_style->GetLeftMargin() * m_sizefactor;
1242
1243 m_currentRowsOrColumns = 0;
1244 m_LineCount = 1;
1245 m_lastX = leftMargin;
1246 m_lastY = topMargin;
1247 m_maxWidth = 0;
1248 m_maxHeight = 0;
1249
1250 ocpnToolBarTool *lastTool = NULL;
1251 bool firstNode = true;
1252 wxToolBarToolsList::compatibility_iterator node = m_tools.GetFirst();
1253
1254 int iNode = 0;
1255
1256 while (node) {
1257 if (iNode >= m_nShowTools) break;
1258
1259 ocpnToolBarTool *tool = (ocpnToolBarTool *)node->GetData();
1260
1261 // Set the tool size to be the size of the first non-separator tool, usually
1262 // the first one
1263 if (toolSize.x == -1) {
1264 if (!tool->IsSeparator()) {
1265 toolSize.x = tool->m_width;
1266 toolSize.y = tool->m_height;
1267 }
1268 }
1269
1270 tool->firstInLine = firstNode;
1271 tool->lastInLine = false;
1272 firstNode = false;
1273
1274 tool->last_rect.width = 0; // mark it invalid
1275
1276 if (tool->IsSeparator()) {
1277 // if (GetWindowStyleFlag() & wxTB_HORIZONTAL) {
1278 // if (m_currentRowsOrColumns >= m_maxCols)
1279 // m_lastY += separatorSize;
1280 // else
1281 // m_lastX += separatorSize;
1282 //}
1283 // else
1284 {
1285 if (m_currentRowsOrColumns >= m_maxRows)
1286 m_lastX += separatorSize;
1287 else
1288 m_lastY += separatorSize;
1289 }
1290 } else if (tool->IsButton()) {
1291 if (!IsVertical()) {
1292 if (m_currentRowsOrColumns >= m_maxCols) {
1293 tool->firstInLine = true;
1294 if (lastTool && m_LineCount > 1) lastTool->lastInLine = true;
1295 m_LineCount++;
1296 m_currentRowsOrColumns = 0;
1297 m_lastX = leftMargin;
1298 m_lastY += toolSize.y + topMargin;
1299 }
1300 tool->m_x = (wxCoord)m_lastX;
1301 tool->m_y = (wxCoord)m_lastY;
1302
1303 tool->trect = wxRect(tool->m_x, tool->m_y, toolSize.x, toolSize.y);
1304 tool->trect.Inflate(separatorSize / 2, topMargin);
1305
1306 m_lastX += toolSize.x + separatorSize;
1307 } else {
1308 if (m_currentRowsOrColumns >= m_maxRows) {
1309 tool->firstInLine = true;
1310 if (lastTool) lastTool->lastInLine = true;
1311 m_LineCount++;
1312 m_currentRowsOrColumns = 0;
1313 m_lastX += toolSize.x + leftMargin;
1314 m_lastY = topMargin;
1315 }
1316 tool->m_x = (wxCoord)m_lastX;
1317 tool->m_y = (wxCoord)m_lastY;
1318
1319 tool->trect = wxRect(tool->m_x, tool->m_y, toolSize.x, toolSize.y);
1320 tool->trect.Inflate((separatorSize / 2), topMargin);
1321
1322 m_lastY += toolSize.y + separatorSize;
1323 }
1324 m_currentRowsOrColumns++;
1325 }
1326 // else
1327 // if (tool->IsControl()) {
1328 // tool->m_x = (wxCoord)(m_lastX);
1329 // tool->m_y = (wxCoord)(m_lastY - (topMargin / 2));
1330
1331 // tool->trect =
1332 // wxRect(tool->m_x, tool->m_y, tool->GetWidth(), tool->GetHeight());
1333 // tool->trect.Inflate(separatorSize / 2, topMargin);
1334
1335 // wxSize s = tool->GetControl()->GetSize();
1336 // m_lastX += s.x + separatorSize;
1337 //}
1338
1339 if (m_lastX > m_maxWidth) m_maxWidth = m_lastX;
1340 if (m_lastY > m_maxHeight) m_maxHeight = m_lastY;
1341
1342 lastTool = tool;
1343 node = node->GetNext();
1344 iNode++;
1345 }
1346 if (lastTool && (m_LineCount > 1 || IsVertical()))
1347 lastTool->lastInLine = true;
1348
1349 if (!IsVertical()) {
1350 m_maxHeight += toolSize.y;
1351 m_maxHeight += m_style->GetBottomMargin();
1352 } else {
1353 m_maxWidth += toolSize.x;
1354 m_maxWidth += m_style->GetRightMargin() * m_sizefactor;
1355 }
1356
1357 m_bitmap = wxNullBitmap;
1358
1359 return true;
1360}
1361
1362wxBitmap &ocpnToolBarSimple::CreateBitmap(double display_scale) {
1363 if (m_bitmap.IsOk()) return m_bitmap;
1364
1365 // Make the bitmap
1366 int width = m_maxWidth;
1367 int height = m_maxHeight;
1368
1369 wxMemoryDC mdc;
1370 wxBitmap bm(width, height);
1371 mdc.SelectObject(bm);
1372 mdc.SetBackground(wxBrush(GetBackgroundColour()));
1373 mdc.Clear();
1374
1375 // In a loop, draw the tools
1376 for (wxToolBarToolsList::compatibility_iterator node = m_tools.GetFirst();
1377 node; node = node->GetNext()) {
1378 wxToolBarToolBase *tool = node->GetData();
1379 ocpnToolBarTool *tools = (ocpnToolBarTool *)tool;
1380 wxRect toolRect = tools->trect;
1381 CreateToolBitmap(tool);
1382
1383 if (tools->m_activeBitmap.IsOk()) {
1384 mdc.DrawBitmap(tools->m_activeBitmap, tools->m_x, tools->m_y, false);
1385 }
1386 int yyp = 5;
1387 }
1388
1389 mdc.SelectObject(wxNullBitmap);
1390
1391 m_bitmap = bm;
1392 return m_bitmap;
1393}
1394
1395void ocpnToolBarSimple::OnToolTipTimerEvent(wxTimerEvent &event) {
1396 if (!gFrame) // In case gFrame was already destroyed, but the toolbar still
1397 // exists (Which should not happen, ever.)
1398 return;
1399
1400 if (m_btooltip_show /*&& IsShown()*/ && m_pToolTipWin &&
1401 (!m_pToolTipWin->IsShown())) {
1402 if (m_last_ro_tool) {
1403 wxString s = m_last_ro_tool->GetShortHelp();
1404
1405 if (s.Len()) {
1406 m_pToolTipWin->SetString(s);
1407 m_pToolTipWin->SetHiviz(m_last_ro_tool->m_btooltip_hiviz);
1408
1409 wxPoint pos_in_toolbar(m_last_ro_tool->m_x, m_last_ro_tool->m_y);
1410 pos_in_toolbar.x += m_last_ro_tool->m_width + 2;
1411
1412 m_pToolTipWin->Move(
1413 0, 0); // workaround for gtk autocentre dialog behavior
1414
1415 wxPoint screenPosition =
1416 gFrame->GetPrimaryCanvas()->ClientToScreen(pos_in_toolbar);
1417 wxSize tipSize = m_pToolTipWin->GetRenderedSize();
1418
1419 m_pToolTipWin->SetPosition(screenPosition);
1420 m_pToolTipWin->SetBitmap();
1421 m_pToolTipWin->Show();
1422#ifndef __WXOSX__
1423 gFrame->Raise();
1424#endif
1425
1426#ifndef __OCPN__ANDROID__
1427 if (g_btouch) m_tooltipoff_timer.Start(m_tooltip_off, wxTIMER_ONE_SHOT);
1428#endif
1429 }
1430 }
1431 }
1432}
1433
1434void ocpnToolBarSimple::OnToolTipOffTimerEvent(wxTimerEvent &event) {
1435 HideTooltip();
1436}
1437
1438bool ocpnToolBarSimple::OnMouseEvent(wxMouseEvent &event, wxPoint &position) {
1439 wxCoord x, y;
1440 event.GetPosition(&x, &y);
1441
1442 // in the toolbar?
1443 wxRect r = wxRect(position, wxSize(m_maxWidth, m_maxHeight));
1444 if (!r.Contains(x, y)) {
1445 HideTooltip();
1446 return false;
1447 }
1448
1449 m_parentContainer->RefreshFadeTimer();
1450
1451 ocpnToolBarTool *tool =
1452 (ocpnToolBarTool *)FindToolForPosition(x - position.x, y - position.y);
1453 if (tool == NULL) {
1454 m_tooltipoff_timer.Start(m_tooltip_off, wxTIMER_ONE_SHOT);
1455 return true;
1456 } else
1457 m_tooltipoff_timer.Stop();
1458
1459 // tooltips
1460 if (tool && tool->IsButton() /*&& IsShown()*/) {
1461 if (m_btooltip_show) {
1462 // ToolTips
1463 if (NULL == m_pToolTipWin) {
1464 m_pToolTipWin = new ToolTipWin(gFrame /*GetParent()*/);
1465 m_pToolTipWin->SetColorScheme(m_currentColorScheme);
1466 m_pToolTipWin->Hide();
1467 }
1468
1469 if (tool != m_last_ro_tool) {
1470 m_pToolTipWin->Hide();
1471 }
1472
1473#ifndef __OCPN__ANDROID__
1474 if (!m_pToolTipWin->IsShown()) {
1475 if (!m_tooltip_timer.IsRunning()) {
1476 m_tooltip_timer.Start(m_one_shot, wxTIMER_ONE_SHOT);
1477 }
1478 }
1479#endif
1480 }
1481 }
1482
1483 m_last_ro_tool = tool;
1484
1485 // Left button pressed.
1486 if (event.LeftIsDown()) m_leftDown = true; // trigger on
1487
1488 if (event.LeftDown() && tool->IsEnabled()) {
1489 if (tool->CanBeToggled()) {
1490 tool->Toggle();
1491 tool->bitmapOK = false;
1492 SetDirty(true);
1493 m_bitmap = wxNullBitmap;
1494 }
1495
1496 // Look for PlugIn tools
1497 // If found, make the callback.
1498 if (g_pi_manager) {
1499 ArrayOfPlugInToolbarTools tool_array =
1500 g_pi_manager->GetPluginToolbarToolArray();
1501 for (unsigned int i = 0; i < tool_array.GetCount(); i++) {
1502 PlugInToolbarToolContainer *pttc = tool_array[i];
1503 if (tool->GetId() == pttc->id) {
1504 opencpn_plugin_113 *ppi =
1505 dynamic_cast<opencpn_plugin_113 *>(pttc->m_pplugin);
1506 if (ppi) {
1507 ppi->OnToolbarToolDownCallback(pttc->id);
1508 m_last_plugin_down_id = pttc->id;
1509 }
1510 }
1511 }
1512 }
1513 } else if (event.RightDown()) {
1514 OnRightClick(tool->GetId(), x, y);
1515 }
1516
1517 // Left Button Released. Only this action confirms selection.
1518 // If the button is enabled and it is not a toggle tool and it is
1519 // in the pressed state, then raise the button and call OnLeftClick.
1520 //
1521 // Unfortunately, some touch screen drivers do not send "LeftIsDown" events.
1522 // Nor do they report "LeftIsDown" in any state.
1523 // c.f rPI "official" 7" panel.
1524
1525 // So, for this logic, assume in touch mode that the m_leftDown flag may not
1526 // be set, and process the left-up event anyway.
1527 if (event.LeftUp() && tool->IsEnabled() && (m_leftDown || g_btouch)) {
1528 // Pass the OnLeftClick event to tool
1529 if (!OnLeftClick(tool->GetId(), tool->IsToggled()) &&
1530 tool->CanBeToggled()) {
1531 // If it was a toggle, and OnLeftClick says No Toggle allowed,
1532 // then change it back
1533 tool->Toggle();
1534 tool->bitmapOK = false;
1535 }
1536
1537 DoPluginToolUp();
1538 m_leftDown = false;
1539 return true;
1540 }
1541
1542 return true;
1543}
1544
1545// ----------------------------------------------------------------------------
1546// drawing
1547// ----------------------------------------------------------------------------
1548
1549void ocpnToolBarSimple::CreateToolBitmap(wxToolBarToolBase *toolBase) {
1550 ocpnToolBarTool *tool = (ocpnToolBarTool *)toolBase;
1551
1552 wxBitmap bmp = wxNullBitmap;
1553
1554 bool bNeedClear = !tool->bitmapOK;
1555
1556 if (tool->bitmapOK) {
1557 if (tool->IsEnabled()) {
1558 bmp = tool->GetNormalBitmap();
1559 if (!bmp.IsOk()) {
1560 bmp =
1561 m_style->GetToolIcon(tool->GetToolname(), TOOLICON_NORMAL,
1562 tool->rollover, tool->m_width, tool->m_height);
1563 tool->SetNormalBitmap(bmp);
1564 tool->bitmapOK = true;
1565 }
1566 } else {
1567 bmp = tool->GetDisabledBitmap();
1568 if (!bmp.IsOk()) {
1569 bmp = m_style->GetToolIcon(tool->GetToolname(), TOOLICON_DISABLED,
1570 false, tool->m_width, tool->m_height);
1571 tool->SetDisabledBitmap(bmp);
1572 tool->bitmapOK = true;
1573 }
1574 }
1575 } else {
1576 if (tool->isPluginTool) {
1577 int toggleFlag = tool->IsToggled() ? TOOLICON_TOGGLED : TOOLICON_NORMAL;
1578
1579 // First try getting the icon from an SVG definition.
1580 // If it is not found, try to see if it is available in the style
1581 // If not there, we build a new icon from the style BG and the (default)
1582 // plugin icon.
1583
1584 wxString svgFile = tool->pluginNormalIconSVG;
1585 if (toggleFlag) {
1586 if (tool->pluginToggledIconSVG.Length())
1587 svgFile = tool->pluginToggledIconSVG;
1588 }
1589 if (tool->rollover) {
1590 if (tool->pluginRolloverIconSVG.Length())
1591 svgFile = tool->pluginRolloverIconSVG;
1592 }
1593
1594 if (!svgFile.IsEmpty()) { // try SVG
1595#ifdef ocpnUSE_SVG
1596 bmp = LoadSVG(svgFile, tool->m_width, tool->m_height);
1597 if (bmp.IsOk()) {
1598 bmp = m_style->BuildPluginIcon(bmp, toggleFlag, m_sizefactor);
1599 } else
1600 bmp =
1601 m_style->BuildPluginIcon(tool->pluginNormalIcon, TOOLICON_NORMAL);
1602#endif
1603 }
1604
1605 if (!bmp.IsOk() || bmp.IsNull()) {
1606 if (m_style->NativeToolIconExists(tool->GetToolname())) {
1607 bmp = m_style->GetToolIcon(tool->GetToolname(), toggleFlag,
1608 tool->rollover, tool->m_width,
1609 tool->m_height);
1610 } else {
1611 bmp = wxNullBitmap;
1612 }
1613
1614 if (bmp.IsNull()) { // Tool icon not found in style definition
1615 // bmp = m_style->BuildPluginIcon(tool->pluginNormalIcon, toggleFlag);
1616 bmp = tool->pluginNormalIcon;
1617 if (fabs(m_sizefactor - 1.0) > 0.01) {
1618 if (tool->m_width && tool->m_height) {
1619 wxImage scaled_image = bmp.ConvertToImage();
1620 bmp = wxBitmap(scaled_image.Scale(tool->m_width, tool->m_height,
1621 wxIMAGE_QUALITY_HIGH));
1622 }
1623 }
1624 }
1625 }
1626 tool->SetNormalBitmap(bmp);
1627 tool->bitmapOK = true;
1628 } else { // Not a plugin tool
1629 bmp = tool->GetNormalBitmap();
1630 if (tool->IsEnabled()) {
1631 if (tool->IsToggled()) {
1632 if (!tool->bitmapOK) {
1633 if (m_style->NativeToolIconExists(tool->GetToolname())) {
1634 bmp = m_style->GetToolIcon(tool->GetToolname(), TOOLICON_TOGGLED,
1635 tool->rollover, tool->m_width,
1636 tool->m_height);
1637 tool->SetNormalBitmap(bmp);
1638 }
1639 }
1640 }
1641
1642 else {
1643 if (!tool->bitmapOK) {
1644 if (m_style->NativeToolIconExists(tool->GetToolname())) {
1645 bmp = m_style->GetToolIcon(tool->GetIconName(), TOOLICON_NORMAL,
1646 tool->rollover, tool->m_width,
1647 tool->m_height);
1648 tool->SetNormalBitmap(bmp);
1649 }
1650 }
1651 }
1652
1653 tool->bitmapOK = true;
1654 } else {
1655 bmp = m_style->GetToolIcon(tool->GetToolname(), TOOLICON_DISABLED,
1656 false, tool->m_width, tool->m_height);
1657 tool->SetDisabledBitmap(bmp);
1658 tool->bitmapOK = true;
1659 }
1660 }
1661 }
1662 tool->m_activeBitmap = bmp;
1663}
1664
1665// NB! The current DrawTool code assumes that plugin tools are never disabled
1666// when they are present on the toolbar, since disabled plugins are removed.
1667
1668void ocpnToolBarSimple::DrawTool(wxDC &dc, wxToolBarToolBase *toolBase) {
1669 ocpnToolBarTool *tool = (ocpnToolBarTool *)toolBase;
1670 // PrepareDC(dc);
1671
1672 wxPoint drawAt(tool->m_x, tool->m_y);
1673 wxBitmap bmp = wxNullBitmap;
1674
1675 bool bNeedClear = !tool->bitmapOK;
1676
1677 if (tool->bitmapOK) {
1678 if (tool->IsEnabled()) {
1679 bmp = tool->GetNormalBitmap();
1680 if (!bmp.IsOk()) {
1681 bmp =
1682 m_style->GetToolIcon(tool->GetToolname(), TOOLICON_NORMAL,
1683 tool->rollover, tool->m_width, tool->m_height);
1684 tool->SetNormalBitmap(bmp);
1685 tool->bitmapOK = true;
1686 }
1687 } else {
1688 bmp = tool->GetDisabledBitmap();
1689 if (!bmp.IsOk()) {
1690 bmp = m_style->GetToolIcon(tool->GetToolname(), TOOLICON_DISABLED,
1691 false, tool->m_width, tool->m_height);
1692 tool->SetDisabledBitmap(bmp);
1693 tool->bitmapOK = true;
1694 }
1695 }
1696 } else {
1697 if (tool->isPluginTool) {
1698 int toggleFlag = tool->IsToggled() ? TOOLICON_TOGGLED : TOOLICON_NORMAL;
1699
1700 // First try getting the icon from an SVG definition.
1701 // If it is not found, try to see if it is available in the style
1702 // If not there, we build a new icon from the style BG and the (default)
1703 // plugin icon.
1704
1705 wxString svgFile = tool->pluginNormalIconSVG;
1706 if (toggleFlag) {
1707 if (tool->pluginToggledIconSVG.Length())
1708 svgFile = tool->pluginToggledIconSVG;
1709 }
1710 if (tool->rollover) {
1711 if (tool->pluginRolloverIconSVG.Length())
1712 svgFile = tool->pluginRolloverIconSVG;
1713 }
1714
1715 if (!svgFile.IsEmpty()) { // try SVG
1716#ifdef ocpnUSE_SVG
1717 bmp = LoadSVG(svgFile, tool->m_width, tool->m_height);
1718 if (bmp.IsOk()) {
1719 bmp = m_style->BuildPluginIcon(bmp, toggleFlag, m_sizefactor);
1720 } else
1721 bmp =
1722 m_style->BuildPluginIcon(tool->pluginNormalIcon, TOOLICON_NORMAL);
1723#endif
1724 }
1725
1726 if (!bmp.IsOk() || bmp.IsNull()) {
1727 if (m_style->NativeToolIconExists(tool->GetToolname())) {
1728 bmp = m_style->GetToolIcon(tool->GetToolname(), toggleFlag,
1729 tool->rollover, tool->m_width,
1730 tool->m_height);
1731 } else {
1732 bmp = wxNullBitmap;
1733 }
1734
1735 if (bmp.IsNull()) { // Tool icon not found
1736 if (tool->rollover) {
1737 bmp =
1738 m_style->BuildPluginIcon(tool->pluginRolloverIcon, toggleFlag);
1739 if (!bmp.IsOk()) {
1740 bmp =
1741 m_style->BuildPluginIcon(tool->pluginNormalIcon, toggleFlag);
1742 }
1743 } else {
1744 bmp = m_style->BuildPluginIcon(tool->pluginNormalIcon, toggleFlag);
1745 }
1746 if (fabs(m_sizefactor - 1.0) > 0.01) {
1747 if (tool->m_width && tool->m_height) {
1748 wxImage scaled_image = bmp.ConvertToImage();
1749 bmp = wxBitmap(scaled_image.Scale(tool->m_width, tool->m_height,
1750 wxIMAGE_QUALITY_HIGH));
1751 }
1752 }
1753 }
1754 }
1755 tool->SetNormalBitmap(bmp);
1756 tool->bitmapOK = true;
1757 } else { // Not a plugin tool
1758 bmp = tool->GetNormalBitmap();
1759 if (tool->IsEnabled()) {
1760 if (tool->IsToggled()) {
1761 if (!tool->bitmapOK) {
1762 if (m_style->NativeToolIconExists(tool->GetToolname())) {
1763 bmp = m_style->GetToolIcon(tool->GetToolname(), TOOLICON_TOGGLED,
1764 tool->rollover, tool->m_width,
1765 tool->m_height);
1766 tool->SetNormalBitmap(bmp);
1767 }
1768 }
1769 }
1770
1771 else {
1772 if (!tool->bitmapOK) {
1773 if (m_style->NativeToolIconExists(tool->GetToolname())) {
1774 bmp = m_style->GetToolIcon(tool->GetIconName(), TOOLICON_NORMAL,
1775 tool->rollover, tool->m_width,
1776 tool->m_height);
1777 tool->SetNormalBitmap(bmp);
1778 }
1779 }
1780 }
1781
1782 tool->bitmapOK = true;
1783 } else {
1784 bmp = m_style->GetToolIcon(tool->GetToolname(), TOOLICON_DISABLED,
1785 false, tool->m_width, tool->m_height);
1786 tool->SetDisabledBitmap(bmp);
1787 tool->bitmapOK = true;
1788 }
1789 }
1790 }
1791
1792 if (tool->firstInLine) {
1793 m_style->DrawToolbarLineStart(bmp, m_sizefactor);
1794 }
1795 if (tool->lastInLine) {
1796 m_style->DrawToolbarLineEnd(bmp, m_sizefactor);
1797 }
1798
1799 if (bmp.GetWidth() != m_style->GetToolSize().x ||
1800 bmp.GetHeight() != m_style->GetToolSize().y) {
1801 // drawAt.x -= ( bmp.GetWidth() - m_style->GetToolSize().x ) / 2;
1802 // drawAt.y -= ( bmp.GetHeight() - m_style->GetToolSize().y ) / 2;
1803 }
1804
1805 // Clear the last drawn tool if necessary
1806 if ((tool->last_rect.width &&
1807 (tool->last_rect.x != drawAt.x || tool->last_rect.y != drawAt.y)) ||
1808 bNeedClear) {
1809 wxBrush bb(GetGlobalColor("GREY3"));
1810 dc.SetBrush(bb);
1811 dc.SetPen(*wxTRANSPARENT_PEN);
1812 dc.DrawRectangle(tool->last_rect.x, tool->last_rect.y,
1813 tool->last_rect.width, tool->last_rect.height);
1814 }
1815
1816 // could cache this in the tool...
1817 // A bit of a hack here. We only scale tools if they are to be magnified
1818 // globally
1819 if (0 /*m_sizefactor > 1.0*/) {
1820 wxImage scaled_image = bmp.ConvertToImage();
1821 wxBitmap sbmp = wxBitmap(scaled_image.Scale(tool->m_width, tool->m_height,
1822 wxIMAGE_QUALITY_HIGH));
1823 dc.DrawBitmap(sbmp, drawAt);
1824 tool->last_rect =
1825 wxRect(drawAt.x, drawAt.y, sbmp.GetWidth(), sbmp.GetHeight());
1826
1827 } else {
1828 dc.DrawBitmap(bmp, drawAt);
1829 tool->last_rect =
1830 wxRect(drawAt.x, drawAt.y, bmp.GetWidth(), bmp.GetHeight());
1831 }
1832}
1833
1834// ----------------------------------------------------------------------------
1835// toolbar geometry
1836// ----------------------------------------------------------------------------
1837
1838wxToolBarToolBase *ocpnToolBarSimple::FindToolForPosition(wxCoord x,
1839 wxCoord y) {
1840 wxToolBarToolsList::compatibility_iterator node = m_tools.GetFirst();
1841 while (node) {
1842 ocpnToolBarTool *tool = (ocpnToolBarTool *)node->GetData();
1843 if ((x >= tool->m_x) && (y >= tool->m_y) &&
1844 (x < (tool->m_x + tool->GetWidth())) &&
1845 (y < (tool->m_y + tool->GetHeight()))) {
1846 return tool;
1847 }
1848
1849 node = node->GetNext();
1850 }
1851
1852 return (wxToolBarToolBase *)NULL;
1853}
1854
1855void ocpnToolBarSimple::InvalidateBitmaps() {
1856 wxToolBarToolsList::compatibility_iterator node = m_tools.GetFirst();
1857 while (node) {
1858 ocpnToolBarTool *tool = (ocpnToolBarTool *)node->GetData();
1859 tool->bitmapOK = false;
1860 node = node->GetNext();
1861 }
1862 m_bitmap = wxNullBitmap;
1863}
1864
1865wxRect ocpnToolBarSimple::GetToolRect(int tool_id) {
1866 wxRect rect;
1867 wxToolBarToolBase *tool = FindById(tool_id);
1868 if (tool) {
1869 ocpnToolBarTool *otool = (ocpnToolBarTool *)tool;
1870 if (otool) rect = otool->trect;
1871 }
1872
1873 return rect;
1874}
1875
1876// ----------------------------------------------------------------------------
1877// tool state change handlers
1878// ----------------------------------------------------------------------------
1879
1880void ocpnToolBarSimple::DoEnableTool(wxToolBarToolBase *tool,
1881 bool WXUNUSED(enable)) {
1882 ocpnToolBarTool *t = (ocpnToolBarTool *)tool;
1883 t->bitmapOK = false;
1884}
1885
1886void ocpnToolBarSimple::DoToggleTool(wxToolBarToolBase *tool,
1887 bool WXUNUSED(toggle)) {
1888 ocpnToolBarTool *t = (ocpnToolBarTool *)tool;
1889 t->bitmapOK = false;
1890 SetDirty(true);
1891}
1892
1893// ----------------------------------------------------------------------------
1894// scrolling implementation
1895// ----------------------------------------------------------------------------
1896
1897wxString ocpnToolBarSimple::GetToolShortHelp(int id) const {
1898 wxToolBarToolBase *tool = FindById(id);
1899 wxCHECK_MSG(tool, wxEmptyString, "no such tool");
1900
1901 return tool->GetShortHelp();
1902}
1903
1904wxString ocpnToolBarSimple::GetToolLongHelp(int id) const {
1905 wxToolBarToolBase *tool = FindById(id);
1906 wxCHECK_MSG(tool, wxEmptyString, "no such tool");
1907
1908 return tool->GetLongHelp();
1909}
1910
1911void ocpnToolBarSimple::SetToolShortHelp(int id, const wxString &help) {
1912 wxToolBarToolBase *tool = FindById(id);
1913 if (tool) {
1914 (void)tool->SetShortHelp(help);
1915 }
1916}
1917
1918void ocpnToolBarSimple::SetToolLongHelp(int id, const wxString &help) {
1919 wxToolBarToolBase *tool = FindById(id);
1920 if (tool) {
1921 (void)tool->SetLongHelp(help);
1922 }
1923}
1924
1925int ocpnToolBarSimple::GetToolPos(int id) const {
1926 size_t pos = 0;
1927 wxToolBarToolsList::compatibility_iterator node;
1928
1929 for (node = m_tools.GetFirst(); node; node = node->GetNext()) {
1930 if (node->GetData()->GetId() == id) return pos;
1931
1932 pos++;
1933 }
1934
1935 return wxNOT_FOUND;
1936}
1937bool ocpnToolBarSimple::GetToolState(int id) const {
1938 wxToolBarToolBase *tool = FindById(id);
1939 wxCHECK_MSG(tool, false, "no such tool");
1940
1941 return tool->IsToggled();
1942}
1943
1944bool ocpnToolBarSimple::GetToolEnabled(int id) const {
1945 wxToolBarToolBase *tool = FindById(id);
1946 wxCHECK_MSG(tool, false, "no such tool");
1947
1948 return tool->IsEnabled();
1949}
1950
1951void ocpnToolBarSimple::ToggleTool(int id, bool toggle) {
1952 wxToolBarToolBase *tool = FindById(id);
1953
1954 if (tool && tool->CanBeToggled() && tool->Toggle(toggle)) {
1955 DoToggleTool(tool, toggle);
1956 InvalidateBitmaps();
1957 gFrame->GetPrimaryCanvas()->Refresh(true);
1958 }
1959}
1960
1961wxObject *ocpnToolBarSimple::GetToolClientData(int id) const {
1962 wxToolBarToolBase *tool = FindById(id);
1963 return tool ? tool->GetClientData() : (wxObject *)NULL;
1964}
1965
1966void ocpnToolBarSimple::SetToolClientData(int id, wxObject *clientData) {
1967 wxToolBarToolBase *tool = FindById(id);
1968
1969 wxCHECK_RET(tool, "no such tool in wxToolBar::SetToolClientData");
1970
1971 tool->SetClientData(clientData);
1972}
1973
1974void ocpnToolBarSimple::EnableTool(int id, bool enable) {
1975 wxToolBarToolBase *tool = FindById(id);
1976 if (tool) {
1977 if (tool->Enable(enable)) {
1978 DoEnableTool(tool, enable);
1979 }
1980 }
1981
1982 ocpnFloatingToolbarDialog *parent = m_parentContainer;
1983 if (parent && parent->m_FloatingToolbarConfigMenu) {
1984 wxMenuItem *configItem = parent->m_FloatingToolbarConfigMenu->FindItem(id);
1985 if (configItem) configItem->Check(true);
1986 }
1987}
1988
1989void ocpnToolBarSimple::SetToolTooltipHiViz(int id, bool b_hiviz) {
1990 ocpnToolBarTool *tool = (ocpnToolBarTool *)FindById(id);
1991 if (tool) {
1992 tool->SetTooltipHiviz(b_hiviz);
1993 }
1994}
1995
1996void ocpnToolBarSimple::ClearTools() {
1997 while (GetToolsCount()) {
1998 DeleteToolByPos(0);
1999 }
2000}
2001
2002int ocpnToolBarSimple::GetVisibleToolCount() {
2003 int counter = 0;
2004 wxToolBarToolsList::compatibility_iterator node = m_tools.GetFirst();
2005 while (node) {
2006 ocpnToolBarTool *tool = (ocpnToolBarTool *)node->GetData();
2007 counter++;
2008 node = node->GetNext();
2009 }
2010 return counter;
2011}
2012
2013bool ocpnToolBarSimple::DeleteToolByPos(size_t pos) {
2014 wxCHECK_MSG(pos < GetToolsCount(), false,
2015 "invalid position in wxToolBar::DeleteToolByPos()");
2016
2017 wxToolBarToolsList::compatibility_iterator node = m_tools.Item(pos);
2018
2019 if (!DoDeleteTool(pos, node->GetData())) {
2020 return false;
2021 }
2022
2023 delete node->GetData();
2024 m_tools.Erase(node);
2025
2026 return true;
2027}
2028
2029bool ocpnToolBarSimple::DeleteTool(int id) {
2030 size_t pos = 0;
2031 wxToolBarToolsList::compatibility_iterator node;
2032 for (node = m_tools.GetFirst(); node; node = node->GetNext()) {
2033 if (node->GetData()->GetId() == id) break;
2034
2035 pos++;
2036 }
2037
2038 if (!node || !DoDeleteTool(pos, node->GetData())) {
2039 return false;
2040 }
2041
2042 delete node->GetData();
2043 m_tools.Erase(node);
2044
2045 return true;
2046}
2047
2048wxToolBarToolBase *ocpnToolBarSimple::AddSeparator() {
2049 return InsertSeparator(GetToolsCount());
2050}
2051
2052wxToolBarToolBase *ocpnToolBarSimple::InsertSeparator(size_t pos) {
2053 wxCHECK_MSG(pos <= GetToolsCount(), (wxToolBarToolBase *)NULL,
2054 "invalid position in wxToolBar::InsertSeparator()");
2055
2056 wxToolBarToolBase *tool = CreateTool(
2057 wxID_SEPARATOR, wxEmptyString, wxNullBitmap, wxNullBitmap,
2058 wxITEM_SEPARATOR, (wxObject *)NULL, wxEmptyString, wxEmptyString);
2059
2060 if (!tool || !DoInsertTool(pos, tool)) {
2061 delete tool;
2062
2063 return NULL;
2064 }
2065
2066 m_tools.Insert(pos, tool);
2067 m_nShowTools++;
2068
2069 return tool;
2070}
2071
2072wxToolBarToolBase *ocpnToolBarSimple::RemoveTool(int id) {
2073 size_t pos = 0;
2074 wxToolBarToolsList::compatibility_iterator node;
2075 for (node = m_tools.GetFirst(); node; node = node->GetNext()) {
2076 if (node->GetData()->GetId() == id) break;
2077
2078 pos++;
2079 }
2080
2081 if (!node) {
2082 // don't give any error messages - sometimes we might call RemoveTool()
2083 // without knowing whether the tool is or not in the toolbar
2084 return (wxToolBarToolBase *)NULL;
2085 }
2086
2087 wxToolBarToolBase *tool = node->GetData();
2088 if (!DoDeleteTool(pos, tool)) {
2089 return (wxToolBarToolBase *)NULL;
2090 }
2091
2092 m_tools.Erase(node);
2093
2094 return tool;
2095}
2096
2097wxControl *ocpnToolBarSimple::FindControl(int id) {
2098 for (wxToolBarToolsList::compatibility_iterator node = m_tools.GetFirst();
2099 node; node = node->GetNext()) {
2100 const wxToolBarToolBase *const tool = node->GetData();
2101 if (tool->IsControl()) {
2102 wxControl *const control = tool->GetControl();
2103
2104 if (!control) {
2105 wxFAIL_MSG("NULL control in toolbar?");
2106 } else if (control->GetId() == id) {
2107 // found
2108 return control;
2109 }
2110 }
2111 }
2112
2113 return NULL;
2114}
2115
2116wxToolBarToolBase *ocpnToolBarSimple::FindById(int id) const {
2117 wxToolBarToolBase *tool = (wxToolBarToolBase *)NULL;
2118
2119 for (wxToolBarToolsList::compatibility_iterator node = m_tools.GetFirst();
2120 node; node = node->GetNext()) {
2121 tool = node->GetData();
2122 if (tool->GetId() == id) {
2123 // found
2124 break;
2125 }
2126
2127 tool = NULL;
2128 }
2129
2130 return tool;
2131}
2132
2133// ----------------------------------------------------------------------------
2134// event processing
2135// ----------------------------------------------------------------------------
2136
2137// Only allow toggle if returns true
2138
2139bool ocpnToolBarSimple::OnLeftClick(int id, bool toggleDown) {
2140 wxCommandEvent event(wxEVT_COMMAND_TOOL_CLICKED, id);
2141 // event.SetEventObject(this);
2142
2143 // we use SetInt() to make wxCommandEvent::IsChecked() return toggleDown
2144 event.SetInt((int)toggleDown);
2145
2146 // and SetExtraLong() for backwards compatibility
2147 event.SetExtraLong((long)toggleDown);
2148
2149 gFrame->GetEventHandler()->AddPendingEvent(event);
2150
2151 return true;
2152}
2153
2154// Call when right button down.
2155void ocpnToolBarSimple::OnRightClick(int id, long WXUNUSED(x),
2156 long WXUNUSED(y)) {
2157 HideTooltip();
2158
2159 if (m_parentContainer) {
2160 if (m_parentContainer->m_FloatingToolbarConfigMenu) {
2162 new ToolbarChoicesDialog(NULL, m_parentContainer, -1, "OpenCPN",
2163 wxDefaultPosition, wxSize(100, 100));
2164 int rc = dlg->ShowModal();
2165 delete dlg;
2166
2167 if (rc == wxID_OK) {
2168 wxCommandEvent event(wxEVT_COMMAND_TOOL_RCLICKED, id);
2169 event.SetEventObject(this);
2170 event.SetInt(id);
2171
2172 gFrame->GetEventHandler()->AddPendingEvent(event);
2173 }
2174 }
2175 }
2176}
2177
2178void ocpnToolBarSimple::DoPluginToolUp() {
2179 // Look for PlugIn tools
2180 // If found, make the callback.
2181 if (!g_pi_manager) return;
2182
2183 ArrayOfPlugInToolbarTools tool_array =
2184 g_pi_manager->GetPluginToolbarToolArray();
2185 for (unsigned int i = 0; i < tool_array.GetCount(); i++) {
2186 PlugInToolbarToolContainer *pttc = tool_array[i];
2187 if (m_last_plugin_down_id == pttc->id) {
2188 opencpn_plugin_113 *ppi =
2189 dynamic_cast<opencpn_plugin_113 *>(pttc->m_pplugin);
2190 if (ppi) ppi->OnToolbarToolUpCallback(pttc->id);
2191 }
2192 }
2193
2194 m_last_plugin_down_id = -1;
2195}
2196
2197void ocpnToolBarSimple::SetToolNormalBitmapEx(wxToolBarToolBase *tool,
2198 const wxString &iconName) {
2199 if (tool) {
2200 ocpnToolBarTool *otool = (ocpnToolBarTool *)tool;
2201 if (otool) {
2202 ocpnStyle::Style *style = g_StyleManager->GetCurrentStyle();
2203
2204 wxBitmap bmp = style->GetToolIcon(iconName, TOOLICON_NORMAL, false,
2205 otool->m_width, otool->m_height);
2206 tool->SetNormalBitmap(bmp);
2207 otool->SetIconName(iconName);
2208 }
2209 }
2210}
2211
2212void ocpnToolBarSimple::SetToolNormalBitmapSVG(wxToolBarToolBase *tool,
2213 wxString fileSVG) {
2214 if (tool) {
2215 ocpnToolBarTool *otool = (ocpnToolBarTool *)tool;
2216 if (otool) {
2217 otool->pluginNormalIconSVG = fileSVG;
2218 }
2219 }
2220}
2221
2222void ocpnToolBarSimple::SetToolBitmaps(int id, wxBitmap *bmp,
2223 wxBitmap *bmpRollover) {
2224 ocpnToolBarTool *tool = (ocpnToolBarTool *)FindById(id);
2225 if (tool) {
2226 if (tool->isPluginTool) {
2227 if (bmp->GetWidth() != tool->GetWidth()) {
2228 if (bmp->IsOk()) {
2229 wxImage ibmp = bmp->ConvertToImage();
2230 ibmp.Rescale(tool->GetWidth(), tool->GetHeight(),
2231 wxIMAGE_QUALITY_HIGH);
2232 wxBitmap sbmp = wxBitmap(ibmp);
2233 tool->pluginNormalIcon = sbmp;
2234 }
2235 } else {
2236 tool->pluginNormalIcon = *bmp;
2237 }
2238
2239 if (bmpRollover->GetWidth() != tool->GetWidth()) {
2240 if (bmpRollover->IsOk()) {
2241 wxImage ibmp = bmpRollover->ConvertToImage();
2242 ibmp.Rescale(tool->GetWidth(), tool->GetHeight(),
2243 wxIMAGE_QUALITY_HIGH);
2244 wxBitmap sbmp = wxBitmap(ibmp);
2245 tool->pluginRolloverIcon = sbmp;
2246 }
2247 } else {
2248 tool->pluginRolloverIcon = *bmpRollover;
2249 }
2250 tool->bitmapOK = false;
2251
2252 } else {
2253 tool->SetNormalBitmap(*bmp);
2254 tool->bitmapOK = true;
2255 }
2256 InvalidateBitmaps();
2257 }
2258}
2259
2260void ocpnToolBarSimple::SetToolBitmapsSVG(int id, wxString fileSVGNormal,
2261 wxString fileSVGRollover,
2262 wxString fileSVGToggled) {
2263 ocpnToolBarTool *tool = (ocpnToolBarTool *)FindById(id);
2264 if (tool) {
2265 tool->pluginNormalIconSVG = fileSVGNormal;
2266 tool->pluginRolloverIconSVG = fileSVGRollover;
2267 tool->pluginToggledIconSVG = fileSVGToggled;
2268 tool->bitmapOK = false;
2269 InvalidateBitmaps();
2270 }
2271}
2272
2273//-------------------------------------------------------------------------------------
2274
2275ToolbarMOBDialog::ToolbarMOBDialog(wxWindow *parent)
2276 : wxDialog(parent, wxID_ANY, _("OpenCPN Alert"), wxDefaultPosition,
2277 wxSize(250, 230)) {
2278 wxBoxSizer *topSizer = new wxBoxSizer(wxVERTICAL);
2279
2280 wxBoxSizer *sizer = new wxBoxSizer(wxVERTICAL);
2281 topSizer->Add(sizer, 0, wxALIGN_CENTER_HORIZONTAL | wxALL, 5);
2282
2283 choices.push_back(
2284 new wxRadioButton(this, 0, _("No, I don't want to hide it."),
2285 wxDefaultPosition, wxDefaultSize, wxRB_GROUP));
2286
2287 choices.push_back(new wxRadioButton(
2288 this, 1, _("No, and permanently remove the option to hide it."),
2289 wxDefaultPosition));
2290
2291 choices.push_back(
2292 new wxRadioButton(this, 2, _("Yes, hide it."), wxDefaultPosition));
2293
2294 wxStdDialogButtonSizer *buttonSizer =
2295 CreateStdDialogButtonSizer(wxOK | wxCANCEL);
2296
2297 wxStaticText *textCtrl =
2298 new wxStaticText(this, wxID_ANY,
2299 _("The Man Over Board button could be an important "
2300 "safety feature.\nAre you sure you want to hide it?"));
2301
2302 sizer->Add(textCtrl, 0, wxEXPAND | wxALL, 5);
2303 sizer->Add(choices[0], 0, wxEXPAND | wxALL, 5);
2304 sizer->Add(choices[1], 0, wxEXPAND | wxALL, 5);
2305 sizer->Add(choices[2], 0, wxEXPAND | wxALL, 5);
2306 sizer->Add(buttonSizer, 0, wxEXPAND | wxTOP, 5);
2307
2308 topSizer->SetSizeHints(this);
2309 SetSizer(topSizer);
2310}
2311
2312int ToolbarMOBDialog::GetSelection() {
2313 for (unsigned int i = 0; i < choices.size(); i++) {
2314 if (choices[i]->GetValue()) return choices[i]->GetId();
2315 }
2316 return 0;
2317}
2318
2322BEGIN_EVENT_TABLE(ToolbarChoicesDialog, wxDialog)
2323END_EVENT_TABLE()
2324
2325
2330
2333 wxWindowID id,
2334 const wxString &caption,
2335 const wxPoint &pos,
2336 const wxSize &size, long style) {
2337 long wstyle = wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER;
2338 wxDialog::Create(parent, id, caption, pos, size, wstyle);
2339
2340 m_configMenu = NULL;
2341 m_ToolbarDialogAncestor = sponsor;
2342
2343 if (m_ToolbarDialogAncestor)
2344 m_configMenu = m_ToolbarDialogAncestor->m_FloatingToolbarConfigMenu;
2345
2347 GetSizer()->Fit(this);
2348
2349 RecalculateSize();
2350}
2351
2352ToolbarChoicesDialog::~ToolbarChoicesDialog() {}
2353
2359 wxBoxSizer *itemBoxSizer1 = new wxBoxSizer(wxVERTICAL);
2360 SetSizer(itemBoxSizer1);
2361
2362 wxScrolledWindow *itemDialog1 = new wxScrolledWindow(
2363 this, wxID_ANY, wxDefaultPosition, wxSize(-1, -1), wxHSCROLL | wxVSCROLL);
2364 itemDialog1->SetScrollRate(2, 2);
2365
2366#ifdef __OCPN__ANDROID__
2367
2368 // Set Dialog Font by custom crafted Qt Stylesheet.
2369 wxFont *qFont = GetOCPNScaledFont(_("Dialog"));
2370
2371 wxString wqs = getFontQtStylesheet(qFont);
2372 wxCharBuffer sbuf = wqs.ToUTF8();
2373 QString qsb = QString(sbuf.data());
2374
2375 QString qsbq = getQtStyleSheet(); // basic scrollbars, etc
2376
2377 this->GetHandle()->setStyleSheet(qsb + qsbq); // Concatenated style sheets
2378
2379#endif
2380 itemBoxSizer1->Add(itemDialog1, 2, wxEXPAND | wxALL, 0);
2381
2382 wxBoxSizer *itemBoxSizer2 = new wxBoxSizer(wxVERTICAL);
2383 itemDialog1->SetSizer(itemBoxSizer2);
2384
2385 wxStaticBox *itemStaticBoxSizer3Static =
2386 new wxStaticBox(itemDialog1, wxID_ANY, _("Choose Toolbar Icons"));
2387 wxStaticBoxSizer *itemStaticBoxSizer3 =
2388 new wxStaticBoxSizer(itemStaticBoxSizer3Static, wxVERTICAL);
2389 itemBoxSizer2->Add(itemStaticBoxSizer3, 0, wxEXPAND | wxALL, 5);
2390
2391 int nitems = 0;
2392 int max_width = -1;
2393 if (m_configMenu) {
2394 nitems = m_configMenu->GetMenuItemCount();
2395
2396 cboxes.clear();
2397 for (int i = 0; i < nitems; i++) {
2398 if (i + ID_ZOOMIN == ID_MOB && g_bPermanentMOBIcon) continue;
2399 wxMenuItem *item = m_configMenu->FindItemByPosition(i);
2400
2401 wxString label = item->GetItemLabel();
2402 int l = label.Len();
2403 max_width = wxMax(max_width, l);
2404
2405 wxString windowName = "";
2406 if (item->GetId() == ID_MOB + 100) windowName = "MOBCheck";
2407
2408 wxCheckBox *cb =
2409 new wxCheckBox(itemDialog1, -1, label, wxDefaultPosition,
2410 wxDefaultSize, 0, wxDefaultValidator, windowName);
2411 // wxCheckBox *cb = new wxCheckBox(itemDialog1, -1, label);
2412 itemStaticBoxSizer3->Add(cb, 0, wxALL | wxEXPAND, 2);
2413 cb->SetValue(item->IsChecked());
2414
2415 cboxes.push_back(cb);
2416 }
2417 }
2418
2419 itemBoxSizer1->SetMinSize((max_width + 20) * GetCharWidth(),
2420 (nitems + 4) * GetCharHeight() * 2);
2421
2422 wxBoxSizer *itemBoxSizerBottom = new wxBoxSizer(wxHORIZONTAL);
2423 itemBoxSizer1->Add(itemBoxSizerBottom, 0, wxALL | wxEXPAND, 5);
2424
2425 wxBoxSizer *itemBoxSizerAux = new wxBoxSizer(wxHORIZONTAL);
2426 itemBoxSizerBottom->Add(itemBoxSizerAux, 1, wxALL, 3);
2427
2428 wxBoxSizer *itemBoxSizer16 = new wxBoxSizer(wxHORIZONTAL);
2429 itemBoxSizerBottom->Add(itemBoxSizer16, 0, wxALL, 3);
2430
2431 m_CancelButton =
2432 new wxButton(this, -1, _("Cancel"), wxDefaultPosition, wxDefaultSize, 0);
2433 itemBoxSizer16->Add(m_CancelButton, 0, wxALIGN_CENTER_VERTICAL | wxALL, 1);
2434
2435 m_OKButton =
2436 new wxButton(this, -1, _("OK"), wxDefaultPosition, wxDefaultSize, 0);
2437 itemBoxSizer16->Add(m_OKButton, 0, wxALIGN_CENTER_VERTICAL | wxALL, 1);
2438 m_OKButton->SetDefault();
2439
2440 m_CancelButton->Connect(
2441 wxEVT_COMMAND_BUTTON_CLICKED,
2442 wxCommandEventHandler(ToolbarChoicesDialog::OnCancelClick), NULL, this);
2443 m_OKButton->Connect(wxEVT_COMMAND_BUTTON_CLICKED,
2444 wxCommandEventHandler(ToolbarChoicesDialog::OnOkClick),
2445 NULL, this);
2446
2447 SetColorScheme((ColorScheme)0);
2448}
2449
2450void ToolbarChoicesDialog::SetColorScheme(ColorScheme cs) { DimeControl(this); }
2451
2452void ToolbarChoicesDialog::OnCancelClick(wxCommandEvent &event) {
2453 EndModal(wxID_CANCEL);
2454}
2455
2456void ToolbarChoicesDialog::OnOkClick(wxCommandEvent &event) {
2457 unsigned int ncheck = 0;
2458
2459 wxString toolbarConfigSave = m_ToolbarDialogAncestor->GetToolConfigString();
2460 wxString new_toolbarConfig = toolbarConfigSave;
2461
2462 for (unsigned int i = 0; i < cboxes.size(); i++) {
2463 wxCheckBox *cb = cboxes[i];
2464 wxString cbName = cb->GetName(); // Special flag passed into checkbox ctor
2465 // to find the "MOB" item
2466 if (cbName.IsSameAs("MOBCheck") && !cb->IsChecked()) {
2467 // Ask if really want to disable MOB button
2468 ToolbarMOBDialog mdlg(this);
2469 int dialog_ret = mdlg.ShowModal();
2470 int answer = mdlg.GetSelection();
2471 if (dialog_ret == wxID_OK) {
2472 if (answer == 1) {
2473 g_bPermanentMOBIcon = true;
2474 cb->SetValue(true);
2475 } else if (answer == 0) {
2476 cb->SetValue(true);
2477 }
2478 } else { // wxID_CANCEL
2479 new_toolbarConfig = toolbarConfigSave;
2480 return;
2481 }
2482 }
2483 if (m_configMenu) {
2484 wxMenuItem *item = m_configMenu->FindItemByPosition(i);
2485 if (new_toolbarConfig.Len() > i) {
2486 new_toolbarConfig.SetChar(i, cb->IsChecked() ? _T('X') : _T('.'));
2487 } else {
2488 new_toolbarConfig.Append(cb->IsChecked() ? _T('X') : _T('.'));
2489 }
2490 item->Check(cb->IsChecked());
2491 if (cb->IsChecked()) ncheck++;
2492 }
2493 }
2494
2495#if 0
2496 // We always must have one Tool enabled. Make it the Options tool....
2497 if( 0 == ncheck){
2498 new_toolbarConfig.SetChar( ID_SETTINGS -ID_ZOOMIN , _T('X') );
2499
2500 int idOffset = ID_PLUGIN_BASE - ID_ZOOMIN + 100;
2501
2502 if(m_configMenu){
2503 wxMenuItem *item = m_configMenu->FindItem(ID_SETTINGS + idOffset);
2504 if(item)
2505 item->Check( true );
2506 }
2507 }
2508#endif
2509 m_ToolbarDialogAncestor->SetToolConfigString(new_toolbarConfig);
2510
2511 EndModal(wxID_OK);
2512}
2513
2514void ToolbarChoicesDialog::RecalculateSize(void) {
2515 wxSize esize = GetSize();
2516
2517 if (GetParent()) {
2518 wxSize dsize = GetParent()->GetClientSize();
2519 esize.y = wxMin(esize.y, dsize.y - (4 * GetCharHeight()));
2520 esize.x = wxMin(esize.x, dsize.x - (2 * GetCharHeight()));
2521 SetSize(esize);
2522 Centre();
2523
2524 } else {
2525 wxSize fsize = g_Platform->getDisplaySize();
2526 fsize.y = wxMin(esize.y, fsize.y - (4 * GetCharHeight()));
2527 fsize.x = wxMin(esize.x, fsize.x - (2 * GetCharHeight()));
2528 SetSize(fsize);
2529 CentreOnScreen();
2530#ifdef __OCPN__ANDROID__
2531 Move(GetPosition().x, 10);
2532#endif
2533 }
2534}
Global state for AIS decoder.
Charts database management
Generic Chart canvas base.
double GetDisplayDIPMult(wxWindow *win)
Get the display scaling factor for DPI-aware rendering.
wxFont * GetFont(const wxString &TextElement, int requested_font_size=0)
Gets a font object for a UI element.
Definition FontMgr.cpp:200
Main application frame.
Definition ocpn_frame.h:138
Provides platform-specific support utilities for OpenCPN.
wxSize getDisplaySize()
Get the display size in logical pixels.
ToolbarChoicesDialog()
Constructors.
Definition toolbar.cpp:2329
Container for toolbar item properties.
Definition toolbar.h:40
Device context class that can use either wxDC or OpenGL for drawing.
Definition ocpndc.h:60
Floating toolbar dialog for OpenCPN.
Definition toolbar.h:386
Generic toolbar implementation in pure wxWidgets adapted from wxToolBarSimple (deprecated).
Definition toolbar.h:103
virtual void OnToolbarToolDownCallback(int id)
Handles toolbar button press.
virtual void OnToolbarToolUpCallback(int id)
Handles toolbar button release.
bool g_bsmoothpanzoom
Controls how the chart panning and zooming smoothing is done during user interactions.
wxFont * GetOCPNScaledFont(wxString item, int default_size)
Retrieves a font from FontMgr, optionally scaled for physical readability.
Definition gui_lib.cpp:56
General purpose GUI support.
PlugInManager and helper classes – Mostly gui parts (dialogs) and plugin API stuff.
SVG utilities.