25 #include <wx/wxprec.h>
27 #include <wx/stattext.h>
28 #include <wx/button.h>
29 #include <wx/textctrl.h>
30 #include <wx/clipbrd.h>
32 #include "GoToPositionDialog.h"
33 #include "model/position_parser.h"
37 #include "ocpn_frame.h"
53 EVT_BUTTON(ID_GOTOPOS_CANCEL, GoToPositionDialog::OnGoToPosCancelClick)
54 EVT_BUTTON(ID_GOTOPOS_OK, GoToPositionDialog::OnGoToPosOkClick)
55 EVT_COMMAND(ID_LATCTRL, EVT_LLCHANGE, GoToPositionDialog::OnPositionCtlUpdated)
56 EVT_COMMAND(ID_LONCTRL, EVT_LLCHANGE, GoToPositionDialog::OnPositionCtlUpdated)
69 const wxString& caption,
70 const wxPoint& pos,
const wxSize& size,
73 wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER | wxFRAME_FLOAT_ON_PARENT;
75 Create(parent,
id, caption, pos, size, wstyle);
78 GoToPositionDialog::~GoToPositionDialog() {
88 const wxString& caption,
const wxPoint& pos,
89 const wxSize& size,
long style) {
90 SetExtraStyle(GetExtraStyle() | wxWS_EX_BLOCK_EVENTS);
91 wxDialog::Create(parent,
id, caption, pos, size, style);
96 GetSizer()->SetSizeHints(
this);
109 wxBoxSizer* itemBoxSizer2 =
new wxBoxSizer(wxVERTICAL);
110 itemDialog1->SetSizer(itemBoxSizer2);
112 wxStaticBox* itemStaticBoxSizer4Static =
113 new wxStaticBox(itemDialog1, wxID_ANY, _(
"Position"));
115 wxStaticBoxSizer* itemStaticBoxSizer4 =
116 new wxStaticBoxSizer(itemStaticBoxSizer4Static, wxVERTICAL);
117 itemBoxSizer2->Add(itemStaticBoxSizer4, 0, wxEXPAND | wxALL, 5);
119 wxStaticText* itemStaticText5 =
120 new wxStaticText(itemDialog1, wxID_STATIC, _(
"Latitude"),
121 wxDefaultPosition, wxDefaultSize, 0);
122 itemStaticBoxSizer4->Add(itemStaticText5, 0,
123 wxALIGN_LEFT | wxLEFT | wxRIGHT | wxTOP, 5);
125 m_MarkLatCtl =
new wxTextCtrl(itemDialog1, ID_LATCTRL, _T(
""),
126 wxDefaultPosition, wxSize(180, -1), 0);
127 itemStaticBoxSizer4->Add(
128 m_MarkLatCtl, 0, wxALIGN_LEFT | wxLEFT | wxRIGHT | wxBOTTOM | wxEXPAND,
131 wxStaticText* itemStaticText6 =
132 new wxStaticText(itemDialog1, wxID_STATIC, _(
"Longitude"),
133 wxDefaultPosition, wxDefaultSize, 0);
134 itemStaticBoxSizer4->Add(itemStaticText6, 0,
135 wxALIGN_LEFT | wxLEFT | wxRIGHT | wxTOP, 5);
137 m_MarkLonCtl =
new wxTextCtrl(itemDialog1, ID_LONCTRL, _T(
""),
138 wxDefaultPosition, wxSize(180, -1), 0);
139 itemStaticBoxSizer4->Add(
140 m_MarkLonCtl, 0, wxALIGN_LEFT | wxLEFT | wxRIGHT | wxBOTTOM | wxEXPAND,
143 wxBoxSizer* itemBoxSizer16 =
new wxBoxSizer(wxHORIZONTAL);
144 itemBoxSizer2->Add(itemBoxSizer16, 0, wxALIGN_RIGHT | wxALL, 5);
146 m_CancelButton =
new wxButton(itemDialog1, ID_GOTOPOS_CANCEL, _(
"Cancel"),
147 wxDefaultPosition, wxDefaultSize, 0);
148 itemBoxSizer16->Add(m_CancelButton, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5);
150 m_OKButton =
new wxButton(itemDialog1, ID_GOTOPOS_OK, _(
"OK"),
151 wxDefaultPosition, wxDefaultSize, 0);
152 itemBoxSizer16->Add(m_OKButton, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5);
153 m_OKButton->SetDefault();
155 SetColorScheme((ColorScheme)0);
158 void GoToPositionDialog::SetColorScheme(ColorScheme cs) { DimeControl(
this); }
162 void GoToPositionDialog::OnGoToPosCancelClick(wxCommandEvent& event) {
164 if (m_hostCanvas) m_hostCanvas->ReloadVP();
169 void GoToPositionDialog::OnGoToPosOkClick(wxCommandEvent& event) {
172 if (m_MarkLatCtl->GetValue().Length() == 0)
goto noGo;
173 if (m_MarkLonCtl->GetValue().Length() == 0)
goto noGo;
175 lat = fromDMM(m_MarkLatCtl->GetValue());
176 lon = fromDMM(m_MarkLonCtl->GetValue());
178 if (lat == 0.0 && lon == 0.0)
goto noGo;
179 if (lat > 80.0 || lat < -80.0)
goto noGo;
180 if (lon > 180.0 || lon < -180.0)
goto noGo;
183 gFrame->JumpToPosition(m_hostCanvas, lat, lon, m_hostCanvas->GetVPScale());
194 void GoToPositionDialog::CheckPasteBufferForPosition() {
195 if (wxTheClipboard->Open()) {
196 wxTextDataObject data;
197 wxTheClipboard->GetData(data);
198 wxString pasteBuf = data.GetText();
203 m_MarkLatCtl->SetValue(pparse.GetLatitudeString());
204 m_MarkLonCtl->SetValue(pparse.GetLongitudeString());
206 wxTheClipboard->Close();
210 void GoToPositionDialog::OnPositionCtlUpdated(wxCommandEvent& event) {
bool Create(wxWindow *parent, wxWindowID id=SYMBOL_GOTOPOS_IDNAME, const wxString &caption=SYMBOL_GOTOPOS_TITLE, const wxPoint &pos=SYMBOL_GOTOPOS_POSITION, const wxSize &size=SYMBOL_GOTOPOS_SIZE, long style=SYMBOL_GOTOPOS_STYLE)
Creation.
GoToPositionDialog()
Constructors.
static bool ShowToolTips()
Should we show tooltips?