Version: 0.6.0
commandbar.h
1 /******************************************************************************
2  * Project: wxGIS (GIS Catalog)
3  * Purpose: wxGISCommandBar class, and diferent implementation - wxGISMneu, wxGISToolBar
4  * Author: Dmitry Baryshnikov (aka Bishop), polimax@mail.ru
5  ******************************************************************************
6 * Copyright (C) 2009,2012,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 
23 #include "wxgis/framework/framework.h"
24 #include "wxgis/framework/statusbar.h"
25 #include "wxgis/framework/command.h"
26 #include "wxgis/core/pointer.h"
27 
28 #include <wx/aui/aui.h>
29 #include <wx/menu.h>
30 #include <wx/xml/xml.h>
31 
32 #define STANDARDSTR _("Standard")
33 #define LOCATIONSTR _("Location")
34 #define GEOGRAPHYSTR _("Geography")
35 #define MAPFRAMETOOLSTR _("Map Frame Tools")
36 #define TASKSTR _("Task")
37 
44 enum wxGISEnumCommandBars
45 {
46  enumGISCBNone = 0x0000,
47  enumGISCBMenubar = 0x0001,
48  enumGISCBContextmenu = 0x0002,
49  enumGISCBSubMenu = 0x0004,
50  enumGISCBToolbar = 0x0008
51 };
52 
60 class WXDLLIMPEXP_GIS_FRW wxGISCommandBar :
61  public wxObject,
62  public wxGISPointer
63 {
64  DECLARE_CLASS(wxGISCommandBar)
65 public:
66  wxGISCommandBar(const wxString& sName = NONAME, const wxString& sCaption = _("No Caption"), wxGISEnumCommandBars type = enumGISCBNone);
67  virtual ~wxGISCommandBar(void);
68  virtual void SetName(const wxString& sName);
69  virtual wxString GetName(void) const;
70  virtual void SetCaption(const wxString& sCaption);
71  virtual wxString GetCaption(void) const;
72  virtual void SetType(wxGISEnumCommandBars type);
73  virtual wxGISEnumCommandBars GetType(void);
74  virtual void AddCommand(wxGISCommand* pCmd);
75  virtual void AddMenu(wxMenu* pMenu, wxString sName){};
76  virtual void RemoveCommand(size_t nIndex);
77  virtual void MoveCommandLeft(size_t nIndex);
78  virtual void MoveCommandRight(size_t nIndex);
79  virtual size_t GetCommandCount(void);
80  virtual wxGISCommand* GetCommand(size_t nIndex) const;
81  virtual void Serialize(wxGISApplicationBase* pApp, wxXmlNode* pNode, bool bStore = false);
82 protected:
83  wxCommandPtrArray m_CommandArray;
84  wxString m_sName;
85  wxString m_sCaption;
86  wxGISEnumCommandBars m_type;
87 };
88 
95 WX_DEFINE_ARRAY_PTR(wxGISCommandBar*, wxGISCommandBarPtrArray);
96 
103 class WXDLLIMPEXP_GIS_FRW wxGISMenu :
104  public wxMenu,
105  public wxGISCommandBar
106 {
107  DECLARE_CLASS(wxGISMenu)
108 public:
109  wxGISMenu(const wxString& sName = NONAME, const wxString& sCaption = _("No Caption"), wxGISEnumCommandBars type = enumGISCBNone, const wxString& title = wxEmptyString, long style = 0);
110  virtual ~wxGISMenu(void);
111  virtual void AddCommand(wxGISCommand* pCmd);
112  virtual void RemoveCommand(size_t nIndex);
113  virtual void MoveCommandLeft(size_t nIndex);
114  virtual void MoveCommandRight(size_t nIndex);
115  virtual void AddMenu(wxMenu* pMenu, wxString sName);
116 protected:
117  typedef struct submenudata
118  {
119  wxMenuItem* pItem;
120  wxGISCommandBar* pBar;
121  } SUBMENUDATA;
122  wxVector<SUBMENUDATA> m_SubmenuArray;
123 };
124 
131 class WXDLLIMPEXP_GIS_FRW wxGISToolBar :
132  public wxAuiToolBar,
133  public wxGISCommandBar
134 {
135  DECLARE_CLASS(wxGISToolBar)
136 public:
137  wxGISToolBar(wxWindow* parent, wxWindowID id = -1, const wxPoint& position = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = wxAUI_TB_DEFAULT_STYLE, const wxString& sName = NONAME, const wxString& sCaption = _("No Caption"), wxGISEnumCommandBars type = enumGISCBNone );
138  virtual ~wxGISToolBar(void);
139  virtual void SetLeftDockable(bool bLDock);
140  virtual void SetRightDockable(bool bRDock);
141  virtual bool GetLeftDockable(void);
142  virtual bool GetRightDockable(void);
143  virtual void AddCommand(wxGISCommand* pCmd);
144  virtual void SetName(const wxString& sName);
145  virtual wxString GetName(void);
146  virtual void SetCaption(const wxString& sCaption);
147  virtual wxString GetCaption(void);
148  virtual void RemoveCommand(size_t nIndex);
149  virtual void MoveCommandLeft(size_t nIndex);
150  virtual void MoveCommandRight(size_t nIndex);
151  virtual void Serialize(wxGISApplicationBase* pApp, wxXmlNode* pNode, bool bStore = false);
152  virtual void AddMenu(wxMenu* pMenu, wxString sName);
153  virtual void Activate(wxGISApplicationBase* pApp);
154  virtual void Deactivate(void);
155  virtual void UpdateControls(void);
156 protected: // handlers
157  virtual void OnMotion(wxMouseEvent& evt);
158  virtual void OnToolDropDown(wxAuiToolBarEvent& event);
159  virtual void OnDropDownCommand(wxCommandEvent& event);
160 protected:
161  void ReAddCommand(wxGISCommand* pCmd);
162 protected:
163  wxGISStatusBar* m_pStatusBar;
164  bool m_bLDock;
165  bool m_bRDock;
166  bool m_bActive;
167  IDropDownCommand* m_pDropDownCommand;
168 
169  std::map<size_t, IToolBarControl*> m_RemControlMap;
170 private:
171  DECLARE_EVENT_TABLE()
172 };
Definition: applicationbase.h:65
Definition: pointer.h:55
Definition: commandbar.h:117
Definition: commandbar.h:103
Definition: command.h:53
Definition: commandbar.h:60
Definition: statusbar.h:58
Definition: command.h:151
Definition: commandbar.h:131