Version: 0.6.0
drawingcmd.h
1 /******************************************************************************
2 * Project: wxGIS (GIS Catalog)
3 * Purpose: Carto Drawing Commands & tools class.
4 * Author: Dmitry Baryshnikov (aka Bishop), polimax@mail.ru
5 ******************************************************************************
6 * Copyright (C) 2014 Dmitry Baryshnikov
7 *
8 * This program is free software: you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation, either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20 ****************************************************************************/
21 #pragma once
22 #include "wxgis/framework/command.h"
23 #include "wxgis/framework/applicationbase.h"
24 #include "wxgis/cartoui/drawingmap.h"
25 #include "wxgis/cartoui/mxeventui.h"
26 
27 enum wxGISEnumDrawingToolType{
28  enumGISDrawingToolRectangle = 0,
29  enumGISDrawingToolPolygon,
30  enumGISDrawingToolCircle,
31  enumGISDrawingToolEllipse,
32  enumGISDrawingToolLine,
33 #ifdef wxGIS_USE_SPLINE
34  enumGISDrawingToolCurve,
35 #endif //wxGIS_USE_SPLINE
36  enumGISDrawingToolFreeHand,
37  enumGISDrawingToolMarker,
38  enumGISDrawingToolLayerSelector,
39  enumGISDrawingToolLayerClear,
40  enumGISDrawingToolMax
41 };
42 
51  public wxComboBox,
52  public IToolBarControl
53 {
54  DECLARE_CLASS(wxGISDrawingLayersComboBox)
55 public:
56  wxGISDrawingLayersComboBox(wxWindow* parent, wxWindowID id, const wxString& value, const wxPoint& pos, const wxSize& size, const wxArrayString& choices, long style = wxCB_READONLY, const wxValidator& validator = wxDefaultValidator, const wxString& name = wxT("DrawingLayersComboBox"));
57  virtual ~wxGISDrawingLayersComboBox(void);
58  virtual void UpdateLayersList(int nWinId);
59  //events
60  void OnLayerAdded(wxMxMapViewUIEvent& event);
61  void OnLayerRemoved(wxMxMapViewUIEvent& event);
62  //IToolBarControl
63  virtual void Activate(wxGISApplicationBase* pApp);
64  virtual void Deactivate(void);
65 protected:
66  wxVector< std::pair<wxWindowID, long> > m_anMapWinIDs;
67 private:
68  DECLARE_EVENT_TABLE()
69 };
70 
78 class WXDLLIMPEXP_GIS_CTU wxGISDrawingTool :
79  public ITool,
80  public IToolControl
81 {
82  DECLARE_DYNAMIC_CLASS(wxGISDrawingTool)
83 
84 public:
85  wxGISDrawingTool(void);
86  virtual ~wxGISDrawingTool(void);
87  //ICommand
88  virtual wxIcon GetBitmap(void);
89  virtual wxString GetCaption(void);
90  virtual wxString GetCategory(void);
91  virtual bool GetChecked(void);
92  virtual bool GetEnabled(void);
93  virtual wxString GetMessage(void);
94  virtual wxGISEnumCommandKind GetKind(void);
95  virtual void OnClick(void);
96  virtual bool OnCreate(wxGISApplicationBase* pApp);
97  virtual wxString GetTooltip(void);
98  virtual unsigned char GetCount(void);
99  //ITool
100  virtual wxCursor GetCursor(void);
101  virtual void SetChecked(bool bCheck);
102  virtual void OnMouseDown(wxMouseEvent& event);
103  virtual void OnMouseUp(wxMouseEvent& event);
104  virtual void OnMouseDoubleClick(wxMouseEvent& event);
105  virtual void OnMouseMove(wxMouseEvent& event);
106  //IToolControl
107  virtual IToolBarControl* GetControl(void);
108  virtual wxString GetToolLabel(void);
109  virtual bool HasToolLabel(void);
110 private:
111  wxGISApplicationBase* m_pApp;
112  wxIcon m_IconPolygon, m_IconLine, m_IconMarker, m_IconCircle, m_IconEllipse, m_IconCurve, m_IconRectangle, m_IconFreeHand;
113  wxIcon m_IconEditClear;
114  wxCursor m_CurDrawing;
115  wxGISDrawingMapView* m_pMapView;
116  WINDOWARRAY m_anMapWinIDs;
117  bool m_bCheck;
118 };
119 
120 enum wxGISEnumDrawingToolMenuType{
121  enumGISDrawingToolMenu = 0,
122  enumGISDrawingTextToolMenu
123 };
124 
125 
133 class WXDLLIMPEXP_GIS_CTU wxGISDrawingToolMenu :
134  public ITool,
135  public IDropDownCommand
136 {
137  DECLARE_DYNAMIC_CLASS(wxGISDrawingToolMenu)
138 public:
139  wxGISDrawingToolMenu(void);
140  virtual ~wxGISDrawingToolMenu(void);
141  //ICommand
142  virtual wxIcon GetBitmap(void);
143  virtual wxString GetCaption(void);
144  virtual wxString GetCategory(void);
145  virtual bool GetChecked(void);
146  virtual bool GetEnabled(void);
147  virtual wxString GetMessage(void);
148  virtual wxGISEnumCommandKind GetKind(void);
149  virtual void OnClick(void);
150  virtual bool OnCreate(wxGISApplicationBase* pApp);
151  virtual wxString GetTooltip(void);
152  virtual unsigned char GetCount(void);
153  //ITool
154  virtual wxCursor GetCursor(void);
155  virtual void SetChecked(bool bCheck);
156  virtual void OnMouseDown(wxMouseEvent& event);
157  virtual void OnMouseUp(wxMouseEvent& event);
158  virtual void OnMouseDoubleClick(wxMouseEvent& event);
159  virtual void OnMouseMove(wxMouseEvent& event);
160  //IDropDownCommand
161  virtual wxMenu* GetDropDownMenu(void);
162  virtual void OnDropDownCommand(int nID);
163 private:
164  wxGISApplicationBase* m_pApp;
165  wxGISDrawingTool* m_pCurrentTool;
166 };
Definition: mxeventui.h:54
Definition: command.h:110
Definition: applicationbase.h:65
virtual wxMenu * GetDropDownMenu(void)=0
Return DropDown Menu to show under button.
Definition: command.h:157
Definition: drawingcmd.h:133
Definition: command.h:128
Definition: drawingmap.h:34
Definition: drawingcmd.h:78
Definition: command.h:92
Definition: command.h:151
Definition: drawingcmd.h:50
virtual void OnDropDownCommand(int nID)=0
Execute the DropDown menu command.