34#include "DetailSlider.h"
36#include "OCPNPlatform.h"
39#include "ocpn_frame.h"
41extern bool g_bShowDetailSlider;
43extern int g_cm93_zoom_factor;
44extern int g_chart_zoom_modifier_raster;
45extern int g_chart_zoom_modifier_vector;
46extern int g_detailslider_dialog_x;
47extern int g_detailslider_dialog_y;
51EVT_KEY_DOWN(PopUpDSlide::OnKeyDown)
52EVT_MOVE(PopUpDSlide::OnMove)
53EVT_COMMAND_SCROLL_THUMBRELEASE(-1, PopUpDSlide::OnChangeValue)
54EVT_COMMAND_SCROLL_LINEUP(-1, PopUpDSlide::OnChangeValue)
55EVT_COMMAND_SCROLL_LINEDOWN(-1, PopUpDSlide::OnChangeValue)
56EVT_COMMAND_SCROLL_PAGEUP(-1, PopUpDSlide::OnChangeValue)
57EVT_COMMAND_SCROLL_PAGEDOWN(-1, PopUpDSlide::OnChangeValue)
58EVT_COMMAND_SCROLL_BOTTOM(-1, PopUpDSlide::OnChangeValue)
59EVT_COMMAND_SCROLL_TOP(-1, PopUpDSlide::OnChangeValue)
60EVT_CLOSE(PopUpDSlide::OnClose)
64 ChartFamilyEnum ChartF, const wxPoint& pos,
65 const wxSize& size,
long style,
66 const wxString& title) {
68 if (Create(parent, ID_CM93ZOOMG, ChartT, ChartF, pos, size, style, title)) {
69 m_p_DetailSlider->Connect(
70 wxEVT_KEY_DOWN, wxKeyEventHandler(PopUpDSlide::OnKeyDown), NULL,
this);
74PopUpDSlide::~PopUpDSlide() {
delete m_p_DetailSlider; }
76void PopUpDSlide::Init(
void) { m_p_DetailSlider = NULL; }
78bool PopUpDSlide::Create(wxWindow* parent, wxWindowID
id, ChartTypeEnum ChartT,
79 ChartFamilyEnum ChartF,
const wxPoint& pos,
80 const wxSize& size,
long style,
81 const wxString& title) {
86 if ((ChartType == CHART_TYPE_CM93COMP) || (ChartType == CHART_TYPE_CM93)) {
87 value = g_cm93_zoom_factor;
88 WindowText = _(
"CM93 Detail Level");
89 }
else if ((ChartType == CHART_TYPE_KAP) || (ChartType == CHART_TYPE_GEO) ||
90 (ChartFam == CHART_FAMILY_RASTER)) {
91 value = g_chart_zoom_modifier_raster;
92 WindowText = _(
"Rasterchart Zoom/Scale Weighting");
93 }
else if ((ChartType == CHART_TYPE_S57) ||
94 (ChartFam == CHART_FAMILY_VECTOR)) {
95 value = g_chart_zoom_modifier_vector;
96 WindowText = _(
"Vectorchart Zoom/Scale Weighting");
98 pPopupDetailSlider = NULL;
102 long wstyle = wxDEFAULT_DIALOG_STYLE | wxFRAME_FLOAT_ON_PARENT;
104 if (!wxFrame::Create(parent,
id, WindowText, pos, size, wstyle))
return false;
110 m_p_DetailSlider =
new wxSlider(
111 this,
id, value, minValue, maxValue, wxPoint(0, 0), wxDefaultSize,
112 wxSL_HORIZONTAL | wxSL_AUTOTICKS | wxSL_LABELS, wxDefaultValidator,
115 m_p_DetailSlider->SetSize(wxSize(350, -1));
117 m_p_DetailSlider->InvalidateBestSize();
118 wxSize bs = m_p_DetailSlider->GetBestSize();
120 m_p_DetailSlider->SetSize(wxSize(350, bs.y));
123 m_p_DetailSlider->SetValue(value);
130void PopUpDSlide::OnCancelClick(wxCommandEvent& event) {
131 g_bShowDetailSlider =
false;
135void PopUpDSlide::OnClose(wxCloseEvent& event) {
136 g_bShowDetailSlider =
false;
138 if (m_p_DetailSlider)
139 m_p_DetailSlider->Disconnect(
140 wxEVT_KEY_DOWN, wxKeyEventHandler(PopUpDSlide::OnKeyDown), NULL,
this);
142 pPopupDetailSlider = NULL;
145void PopUpDSlide::OnKeyDown(wxKeyEvent& event) {
146 int key_char =
event.GetKeyCode();
147 if (key_char == WXK_ESCAPE || key_char ==
'D') {
148 g_bShowDetailSlider =
false;
153void PopUpDSlide::OnMove(wxMoveEvent& event) {
155 wxPoint p =
event.GetPosition();
156 g_detailslider_dialog_x = p.x;
157 g_detailslider_dialog_y = p.y;
162void PopUpDSlide::OnChangeValue(wxScrollEvent& event)
165 ::wxBeginBusyCursor();
167 if ((ChartType == CHART_TYPE_CM93COMP) || (ChartType == CHART_TYPE_CM93)) {
168 g_cm93_zoom_factor = m_p_DetailSlider->GetValue();
171 parentCanvas->ReloadVP();
172 parentCanvas->Refresh();
177 if ((ChartType == CHART_TYPE_KAP) || (ChartType == CHART_TYPE_GEO) ||
178 (ChartFam == CHART_FAMILY_RASTER)) {
179 g_chart_zoom_modifier_raster = m_p_DetailSlider->GetValue();
182 if ((ChartType == CHART_TYPE_S57) || (ChartFam == CHART_FAMILY_VECTOR)) {
183 g_chart_zoom_modifier_vector = m_p_DetailSlider->GetValue();
186 gFrame->ProcessOptionsDialog(S52_CHANGED | FORCE_UPDATE, NULL);