OpenCPN Partial API docs
MarkInfo.h
1 /***************************************************************************
2  *
3  * Project: OpenCPN
4  * Purpose: Mark Properties Support
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 #ifndef _MARKINFO_H_
27 #define _MARKINFO_H_
28 
32 #include <wx/listctrl.h>
33 #include "ocpn_frame.h" //FIXME (dave ) // for ColorScheme
34 #include <wx/hyperlink.h> // toh, 2009.02.08
35 #include <wx/choice.h>
36 #include <wx/tglbtn.h>
37 #include <wx/bmpcbox.h>
38 #include <wx/notebook.h>
39 #include <wx/filesys.h>
40 #include <wx/clrpicker.h>
41 #include <wx/odcombo.h>
42 #include <wx/gbsizer.h>
43 #include <wx/spinctrl.h>
44 #include "LinkPropDlg.h"
45 #include "model/hyperlink.h"
46 #include <wx/htmllbox.h>
47 #include <wx/datectrl.h>
48 #include <wx/timectrl.h>
49 #include <wx/dateevt.h>
50 #include <wx/list.h>
51 #include <wx/combobox.h>
52 
53 #include <wx/dialog.h>
54 
55 #ifdef __WXGTK__
56 // wxTimePickerCtrl is completely broken in Gnome based desktop environments as
57 // of wxGTK 3.0
58 #include "time_textbox.h"
59 #endif
60 
61 #ifdef __WXOSX__
62 #define DIALOG_PARENT wxFrame
63 #else
64 #define DIALOG_PARENT wxDialog
65 #endif
66 
67 #define ID_WPT_RANGERINGS_NO 7507
68 #define ID_RCLK_MENU_COPY_TEXT 7013
69 #define ID_RCLK_MENU_DELETE 7015
70 #define ID_RCLK_MENU_COPY 7016
71 #define ID_RCLK_MENU_COPY_LL 7017
72 #define ID_RCLK_MENU_PASTE 7018
73 #define ID_RCLK_MENU_PASTE_LL 7019
74 #define ID_RCLK_MENU_DELETE_LINK 7023
75 #define ID_RCLK_MENU_EDIT_LINK 7024
76 #define ID_RCLK_MENU_ADD_LINK 7025
77 
78 #include "tcmgr.h"
79 #include "OCPNPlatform.h"
80 
85 class wxListCtrl;
86 class Route;
87 class RoutePoint;
88 class HyperlinkList;
89 class OCPNIconCombo;
90 
96 
97 #define ID_MARKPROP 8000
98 #define SYMBOL_MARKPROP_STYLE \
99  wxCAPTION | wxRESIZE_BORDER | wxSYSTEM_MENU | wxCLOSE_BOX
100 #define SYMBOL_MARKPROP_TITLE _("Waypoint Properties")
101 #define SYMBOL_MARKPROP_IDNAME ID_MARKPROP
102 #define SYMBOL_MARKPROP_SIZE wxSize(200, 300)
103 #define SYMBOL_MARKPROP_POSITION wxDefaultPosition
104 #define ID_MARKPROP_CANCEL 8001
105 #define ID_MARKPROP_OK 8002
106 #define ID_ICONCTRL 8003
107 #define ID_LATCTRL 8004
108 #define ID_LONCTRL 8005
109 #define ID_SHOWNAMECHECKBOXBASIC 8006
110 #define ID_BITMAPCOMBOCTRL 8007
111 #define ID_NAMECTRL 8008
112 #define wxID_HTMLLIST 8009
113 #define ID_DESCR_CTR_DESC 8010
114 #define ID_DESCR_CTR_BASIC 8011
115 #define ID_BTN_DESC_BASIC 8012
116 #define ID_ETA_DATEPICKERCTRL 8013
117 #define ID_ETA_TIMEPICKERCTRL 8014
118 #define ID_SHOWNAMECHECKBOX_EXT 8015
119 #define ID_CHECKBOX_VIS_EXT 8016
120 #define ID_CHECKBOX_SCAMIN_VIS 8017
121 #define ID_SET_DEFAULT_ICON 8018
122 #define ID_SET_DEFAULT_RANGERINGS 8019
123 #define ID_SET_DEFAULT_ARRIVALRADIUS 8020
124 #define ID_SET_DEFAULT_SCAMIN 8021
125 #define ID_SET_DEFAULT_NAMEVIS 8022
126 #define ID_SET_DEFAULT_ALL 8023
127 #define ID_BTN_LINK_MENU 8024
128 #define ID_DEFAULT 8025
129 #define ID_BTN_SHOW_TIDES 8026
130 
132 
137 #ifndef wxCLOSE_BOX
138 #define wxCLOSE_BOX 0x1000
139 #endif
140 #ifndef wxFIXED_MINSIZE
141 #define wxFIXED_MINSIZE 0
142 #endif
143 
144 WX_DECLARE_OBJARRAY(wxBitmap, ArrayOfBitmaps);
145 
146 class SaveDefaultsDialog;
147 
152 class OCPNIconCombo : public wxOwnerDrawnComboBox {
153 public:
154  OCPNIconCombo(wxWindow* parent, wxWindowID id, const wxString& value = _T(""),
155  const wxPoint& pos = wxDefaultPosition,
156  const wxSize& size = wxDefaultSize, int n = 0,
157  const wxString choices[] = NULL, long style = 0,
158  const wxValidator& validator = wxDefaultValidator,
159  const wxString& name = _T("OCPNIconCombo"));
160 
161  ~OCPNIconCombo();
162 
163  void OnDrawItem(wxDC& dc, const wxRect& rect, int item, int flags) const;
164  wxCoord OnMeasureItem(size_t item) const;
165  wxCoord OnMeasureItemWidth(size_t item) const;
166 
167  int Append(const wxString& item, wxBitmap bmp);
168  void Clear(void);
169 
170 private:
171  int itemHeight;
172  ArrayOfBitmaps bmpArray;
173 };
174 
175 // LatLonTextCtrl Specification
176 // We need a derived wxText control for lat/lon input in the MarkProp dialog
177 // Specifically, we need to catch loss-of-focus events and signal the parent
178 // dialog to update the mark's lat/lon dynamically.
179 
180 // DECLARE_EVENT_TYPE(EVT_LLCHANGE, -1)
181 extern /*expdecl*/ const wxEventType EVT_LLCHANGE;
182 
183 class LatLonTextCtrl : public wxTextCtrl {
184  // DECLARE_DYNAMIC_CLASS( LatLonTextCtrl )
185  DECLARE_EVENT_TABLE()
186 
187 public:
188  LatLonTextCtrl(wxWindow* parent, wxWindowID id,
189  const wxString& value = _T(""),
190  const wxPoint& pos = wxDefaultPosition,
191  const wxSize& size = wxDefaultSize, long style = 0,
192  const wxValidator& validator = wxDefaultValidator,
193  const wxString& name = wxTextCtrlNameStr);
194 
195  void OnKillFocus(wxFocusEvent& event);
196 
197  wxEvtHandler* m_pParentEventHandler;
198 };
199 
203 class MarkInfoDlg : public DIALOG_PARENT {
204  DECLARE_EVENT_TABLE()
205  friend class SaveDefaultsDialog;
206 
207 private:
208  RoutePoint* m_pRoutePoint;
209  std::vector<RoutePoint*> m_pRoutePoints;
210  static bool instanceFlag;
211  int i_htmlList_item;
212 
213  bool m_bShowName_save;
214  wxString m_Name_save;
215  wxString m_IconName_save;
216  int m_current_icon_Index;
217  double m_lat_save;
218  double m_lon_save;
219  wxString m_Description_save;
220  HyperlinkList* m_pMyLinkList;
221  bool m_bIsVisible_save;
222  bool m_bUseScaMin_save;
223  int m_iScaminVal_save;
224  bool m_bShowWaypointRangeRings_save;
225  int m_iWaypointRangeRingsNumber_save;
226  float m_fWaypointRangeRingsStep_save;
227  wxColour m_wxcWaypointRangeRingsColour_save;
228  double m_WaypointArrivalRadius_save;
229  float m_PlannedSpeed_save;
230  wxDateTime m_ArrETA_save;
231  std::map<double, const IDX_entry*> m_tss;
232  wxString m_lasttspos;
233  void SetRoutePoint(RoutePoint* pRP);
234 
235 protected:
236  OCPNIconCombo* m_bcomboBoxIcon;
237  wxBoxSizer* bSizerBasicProperties;
238  wxBoxSizer* bSizerLinks;
239  wxButton* m_buttonExtDescription;
240  wxButton* m_buttonLinksMenu;
241  wxBitmapButton* m_buttonShowTides;
242  wxButton* DefaultsBtn;
243  wxCheckBox* m_checkBoxScaMin;
244  wxCheckBox* m_checkBoxShowName;
245  wxCheckBox* m_checkBoxShowNameExt;
246  wxCheckBox* m_checkBoxVisible;
247  wxChoice* m_choiceWaypointRangeRingsUnits;
248  wxColourPickerCtrl* m_PickColor;
249  wxCheckBox* m_cbEtaPresent;
250  wxBoxSizer* bMainSizer;
251  wxFlexGridSizer* fSizerBasicProperties;
252  wxFlexGridSizer* waypointradarGrid;
253  wxFlexGridSizer* waypointrrSelect;
254  wxGridBagSizer* bGB_SizerProperties;
255  wxFlexGridSizer* gbSizerInnerProperties;
256  wxNotebook* m_notebookProperties;
257  wxObject* m_contextObject;
258  wxScrolledWindow* m_panelBasicProperties;
259  wxPanel* m_panelDescription;
260  wxScrolledWindow* m_panelExtendedProperties;
261  wxSimpleHtmlListBox* m_htmlList;
262  wxSize m_defaultClientSize;
263  wxChoice* m_ChoiceWaypointRangeRingsNumber;
264  wxStaticBitmap* m_bitmapIcon;
265  wxStaticBoxSizer* sbS_Description;
266  wxStaticBoxSizer* sbSizerExtProperties;
267  wxStaticBoxSizer* sbSizerLinks;
268  wxStaticBoxSizer* sbSizerBasicProperties;
269  wxStaticBoxSizer* sbRangeRingsExtProperties;
270  wxStaticBoxSizer* sbSizerDescription;
271  wxStaticText* m_staticTextArrivalRadius;
272  wxStaticText* m_staticTextDescription;
273  wxStaticText* m_staticTextEditEnabled;
274  wxStaticText* m_staticTextGpx;
275  wxStaticText* m_staticTextGuid;
276  wxStaticText* m_staticTextTideStation;
277  wxStaticText* m_staticTextIcon;
278  wxStaticText* m_staticTextLatitude;
279  wxStaticText* m_staticTextLayer;
280  wxStaticText* m_staticTextLongitude;
281  wxStaticText* m_staticTextName;
282  wxStaticText* m_staticTextScaMin;
283  wxStaticText* m_staticTextShowNameExt;
284  wxStaticText* m_staticTextRR1;
285  wxStaticText* m_staticTextRR2;
286  wxChoice* m_RangeRingUnits;
287  wxStaticText* m_staticTextRR4;
288  wxStaticText* m_staticTextArrivalUnits;
289  wxStaticText* m_staticTextPlSpeed;
290  wxStaticText* m_staticTextEta;
291  wxStaticText* m_staticTextPlSpeedUnits;
292  wxStdDialogButtonSizer* m_sdbSizerButtons;
293  wxTextCtrl* m_textArrivalRadius;
294  wxTextCtrl* m_textCtrlExtDescription;
295  wxTextCtrl* m_textCtrlGpx;
296  wxTextCtrl* m_textCtrlGuid;
297  wxScrolledWindow* m_scrolledWindowLinks;
298  wxHyperlinkCtrl* m_hyperlink17;
299  wxMenu* m_menuLink;
300  wxToggleButton* m_toggleBtnEdit;
301  wxButton* m_buttonAddLink;
302 
303 #ifdef __OCPN__ANDROID__
304  wxChoice* m_comboBoxTideStation;
305 #else
306  wxComboBox* m_comboBoxTideStation;
307 #endif
308  wxTextCtrl* m_textDescription;
309  wxTextCtrl* m_textLatitude;
310  wxTextCtrl* m_textLongitude;
311  wxTextCtrl* m_textName;
312  wxTextCtrl* m_textScaMin;
313  wxTextCtrl* m_textWaypointRangeRingsStep;
314  wxTextCtrl* m_textCtrlPlSpeed;
315  wxBitmap _img_MUI_settings_svg;
316  wxButton* m_sdbSizerButtonsCancel;
317  wxButton* m_sdbSizerButtonsOK;
318 
319  wxDatePickerCtrl* m_EtaDatePickerCtrl;
320 #ifdef __WXGTK__
321  TimeCtrl* m_EtaTimePickerCtrl;
322 #else
323  wxTimePickerCtrl* m_EtaTimePickerCtrl;
324 #endif
325  wxArrayString m_choiceTideChoices;
326  wxBitmap m_bmTide;
327  int m_sizeMetric;
328  wxHyperlinkCtrl* m_pEditedLink;
329 
330  void initialize_images(void);
331  void OnBitmapCombClick(wxCommandEvent& event);
332  void OnPositionCtlUpdated(wxCommandEvent& event);
333  void OnExtDescriptionClick(wxCommandEvent& event);
334  void OnDescChangedExt(wxCommandEvent& event);
335  void OnDescChangedBasic(wxCommandEvent& event);
336  void OnMarkInfoCancelClick(wxCommandEvent& event);
337  void OnMarkInfoOKClick(wxCommandEvent& event);
338  void OnShowWaypointNameSelectBasic(wxCommandEvent& event);
339  void OnShowWaypointNameSelectExt(wxCommandEvent& event);
340  void OnSelectScaMinExt(wxCommandEvent& event);
341  void OnWptRangeRingsNoChange(wxCommandEvent& event);
342  void OnCopyPasteLatLon(wxCommandEvent& event);
343  void OnWaypointRangeRingSelect(wxCommandEvent& event);
344  void m_htmlListContextMenuBtn(wxCommandEvent& event);
345  void m_htmlListContextMenu(wxMouseEvent& event);
346  void OnRightClickLatLon(wxCommandEvent& event);
347  void OnHtmlLinkClicked(wxHtmlLinkEvent& event);
348  void OnHyperLinkClick(wxHyperlinkEvent& event);
349 
350  void On_html_link_popupmenu_Click(wxCommandEvent& event);
351  void DefautlBtnClicked(wxCommandEvent& event);
352  void OnNotebookPageChanged(wxNotebookEvent& event);
353  void OnTimeChanged(wxDateEvent& event) { m_cbEtaPresent->SetValue(true); }
354  void OnTideStationCombobox(wxCommandEvent& event);
355  void OnClose(wxCloseEvent& event);
356  void ShowTidesBtnClicked(wxCommandEvent& event);
357  void OnAddLink(wxCommandEvent& event);
358 
359 public:
360  MarkInfoDlg(wxWindow* parent, wxWindowID id = wxID_ANY,
361  const wxString& title = _("Waypoint Properties"),
362  const wxPoint& pos = wxDefaultPosition,
363  const wxSize& size = wxSize(-1, -1),
364  long style = FRAME_WITH_LINKS_STYLE);
365  ~MarkInfoDlg();
366  void Create();
367  void InitialFocus(void);
368  void RecalculateSize(void);
369  RoutePoint* GetRoutePoint(void) { return m_pRoutePoint; }
370  void SetColorScheme(ColorScheme cs);
371  void SetRoutePoints(const std::vector<RoutePoint*> &);
372  void ClearData();
373  void SetBulkEdit(bool bBulkEdit);
374  void UpdateHtmlList();
375  void SetDialogTitle(const wxString& title) { SetTitle(title); }
376  bool UpdateProperties(bool positionOnly = false);
377  void ValidateMark(void);
378  bool SaveChanges();
379  void OnActivate(wxActivateEvent& event);
380 
381  wxSimpleHtmlListBox* GetSimpleBox() {
382  return wxDynamicCast(m_htmlList, wxSimpleHtmlListBox);
383  }
384  void OnHtmlCellClicked(wxHtmlCellEvent& event);
385 
386  SaveDefaultsDialog* m_SaveDefaultDlg;
387 };
388 
392 
393 class SaveDefaultsDialog : public wxDialog {
394  friend class MarkInfoDlg;
395 
396 protected:
397  //(*Declarations(SaveDefaultsDialog)
398  wxCheckBox* RangRingsCB;
399  wxCheckBox* ArrivalRCB;
400  wxCheckBox* IconCB;
401  wxCheckBox* NameCB;
402  wxCheckBox* ScaleCB;
403  wxStaticText* stRR;
404  wxStaticText* stArrivalR;
405  wxStaticText* stIcon;
406  wxStaticText* stName;
407  wxStaticText* stScale;
408  wxStaticText* StaticText1;
409  //*)
410 
411 public:
413 };
414 
415 #endif // _MARKINFO_H_
Class MarkInfoDef.
Definition: MarkInfo.h:203
Definition: route.h:75
Class SaveDefaultsDialog.
Definition: MarkInfo.h:393