30 #include <wx/wxprec.h>
32 #include <wx/slider.h>
34 #include "DetailSlider.h"
36 #include "OCPNPlatform.h"
39 #include "ocpn_frame.h"
41 extern bool g_bShowDetailSlider;
43 extern int g_cm93_zoom_factor;
44 extern int g_chart_zoom_modifier_raster;
45 extern int g_chart_zoom_modifier_vector;
46 extern int g_detailslider_dialog_x;
47 extern int g_detailslider_dialog_y;
51 EVT_KEY_DOWN(PopUpDSlide::OnKeyDown)
52 EVT_MOVE(PopUpDSlide::OnMove)
53 EVT_COMMAND_SCROLL_THUMBRELEASE(-1, PopUpDSlide::OnChangeValue)
54 EVT_COMMAND_SCROLL_LINEUP(-1, PopUpDSlide::OnChangeValue)
55 EVT_COMMAND_SCROLL_LINEDOWN(-1, PopUpDSlide::OnChangeValue)
56 EVT_COMMAND_SCROLL_PAGEUP(-1, PopUpDSlide::OnChangeValue)
57 EVT_COMMAND_SCROLL_PAGEDOWN(-1, PopUpDSlide::OnChangeValue)
58 EVT_COMMAND_SCROLL_BOTTOM(-1, PopUpDSlide::OnChangeValue)
59 EVT_COMMAND_SCROLL_TOP(-1, PopUpDSlide::OnChangeValue)
60 EVT_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);
74 PopUpDSlide::~PopUpDSlide() {
delete m_p_DetailSlider; }
76 void PopUpDSlide::Init(
void) { m_p_DetailSlider = NULL; }
78 bool 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);
130 void PopUpDSlide::OnCancelClick(wxCommandEvent& event) {
131 g_bShowDetailSlider =
false;
135 void 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;
145 void PopUpDSlide::OnKeyDown(wxKeyEvent& event) {
146 int key_char =
event.GetKeyCode();
147 if (key_char == WXK_ESCAPE || key_char ==
'D') {
148 g_bShowDetailSlider =
false;
153 void PopUpDSlide::OnMove(wxMoveEvent& event) {
155 wxPoint p =
event.GetPosition();
156 g_detailslider_dialog_x = p.x;
157 g_detailslider_dialog_y = p.y;
162 void 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);