Version: 0.6.0
gxobjdialog.h
1 /******************************************************************************
2  * Project: wxGIS (GIS Catalog)
3  * Purpose: wxGxObjectDialog class.
4  * Author: Dmitry Baryshnikov (aka Bishop), polimax@mail.ru
5  ******************************************************************************
6 * Copyright (C) 2009-2013 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 <wx/intl.h>
24 
25 #include <wx/string.h>
26 #include <wx/stattext.h>
27 #include <wx/gdicmn.h>
28 #include <wx/font.h>
29 #include <wx/colour.h>
30 #include <wx/settings.h>
31 #include <wx/combo.h>
32 #include <wx/treectrl.h>
33 #include <wx/combobox.h>
34 #include <wx/bitmap.h>
35 #include <wx/image.h>
36 #include <wx/icon.h>
37 #include <wx/toolbar.h>
38 #include <wx/sizer.h>
39 #include <wx/listctrl.h>
40 #include <wx/textctrl.h>
41 #include <wx/button.h>
42 #include <wx/dialog.h>
43 #include <wx/aui/aui.h>
44 
45 #include "wxgis/core/config.h"
46 #include "wxgis/catalogui/gxcontentview.h"
47 #include "wxgis/catalogui/gxtreeview.h"
48 #include "wxgis/framework/applicationbase.h"
49 #include "wxgis/version.h"
50 #include "wxgis/catalog/gxfilters.h"
51 #include "wxgis/framework/accelerator.h"
52 
53 #define OBJDLG_NAME wxT("wxGISObjDialog")
54 
62 class wxGxToolBarArt : public wxAuiDefaultToolBarArt
63 {
64 public:
65  virtual void DrawBackground(wxDC& dc, wxWindow* wnd, const wxRect& rect)
66  {
67  dc.SetBackground(wxBrush(wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE )));
68  dc.Clear();
69  }
70 };
71 
79  public wxGxTreeViewBase,
80  public wxComboPopup
81 {
82  DECLARE_CLASS(wxTreeViewComboPopup)
83 public:
84 
85  // Initialize member variables
86  virtual void Init();
87  virtual void OnPopup();
88  virtual void OnDismiss();
89  // Create popup control
90  virtual bool Create(wxWindow* parent);
91  virtual bool Create(wxWindow* parent, wxWindowID id = TREECTRLID, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = wxBORDER_SIMPLE | wxTR_NO_BUTTONS | wxTR_NO_LINES | wxTR_SINGLE, const wxString& name = wxT("ViewComboPopup"));
92  // Return pointer to the created control
93  virtual wxWindow *GetControl() { return this; }
94  // Translate string into a list selection
95  virtual void SetStringValue(const wxString& s);
96  // Get list selection as a string
97  virtual wxString GetStringValue() const;
98  //
99 //events
100  // Do mouse hot-tracking (which is typical in list popups)
101  virtual void OnMouseMove(wxMouseEvent& event);
102  // On mouse left up, set the value and close the popup
103  virtual void OnMouseClick(wxMouseEvent& event);
104  virtual void OnDblClick(wxTreeEvent& event);
105  virtual void OnSelectionChanged(wxGxSelectionEvent& event);
106  //
107  virtual wxSize GetAdjustedSize(int minWidth, int prefHeight, int maxHeight);
108 //wxGxTreeViewBase
109  virtual void AddTreeItem(wxGxObject* pGxObject, wxTreeItemId hParent);
110  //
111  virtual wxGxSelection* const GetSelectedObjects(void);
112 protected:
113  wxTreeItemId m_PrewItemId;
114  bool m_bClicked;
115 private:
116  DECLARE_EVENT_TABLE()
117 };
118 
125 #define OBJDLGLISTCTRLID 1012 //wxGxObjectDialog contents view
126 
128 {
129  DECLARE_CLASS(wxGxDialogContentView)
130 public:
131  wxGxDialogContentView(wxWindow* parent, wxWindowID id = OBJDLGLISTCTRLID, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = wxLC_LIST | wxLC_EDIT_LABELS | wxLC_SORT_ASCENDING);
132  virtual ~wxGxDialogContentView();
133  virtual bool Create(wxWindow* parent, wxWindowID id = OBJDLGLISTCTRLID, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = wxLC_LIST | wxLC_EDIT_LABELS | wxLC_SORT_ASCENDING, const wxString& name = wxT("ContentView"));
134  //wxGxView
135  virtual bool Activate(wxGISApplicationBase* application, wxXmlNode* pConf);
136  virtual void Deactivate(void);
137  // events
138  virtual void OnActivated(wxListEvent& event);
139  //
140  virtual void SetFilters(const wxGxObjectFiltersArray &FiltersArray){m_FiltersArray = FiltersArray;};
141  virtual void SetCurrentFilter(size_t nFilterIndex);
142  virtual wxGxSelection* const GetSelectedObjects(void);
143  //wxGxContentView
144  virtual bool AddObject(wxGxObject* const pObject);
145 protected:
146  long m_ConnectionPointSelectionCookie;
147  wxGxObjectFiltersArray m_FiltersArray;
148  size_t m_nFilterIndex;
149 private:
150  DECLARE_EVENT_TABLE()
151 };
152 
160 class WXDLLIMPEXP_GIS_CLU wxGxObjectDialog :
161  public wxDialog,
162  public wxGISApplicationBase,
163  public wxGxApplicationBase
164 {
165  DECLARE_CLASS(wxGxObjectDialog)
166 public:
167  wxGxObjectDialog(wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Open"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER);
168  virtual ~wxGxObjectDialog();
169 //wxGISApplicationBase
170  virtual wxString GetAppName(void) const {return wxString(OBJDLG_NAME);};
171  virtual wxString GetAppDisplayName(void) const {return wxString(_("NextGIS Object Dialog"));};
172  virtual wxString GetAppDisplayNameShort(void) const {return wxString(_("Object Dialog"));};
173 //wxGxObjectDialog
174  virtual void SetButtonCaption(const wxString &sOkBtLabel);
175  virtual void SetStartingLocation(const wxString &sStartPath);
176  virtual void SetName(const wxString &sName);
177  virtual void SetAllowMultiSelect(bool bAllowMultiSelect);
178  virtual void SetOverwritePrompt(bool bOverwritePrompt);
179  virtual void SetAllFilters(bool bAllFilters);
180  virtual int ShowModalOpen();
181  virtual int ShowModalSave();
182  virtual void AddFilter(wxGxObjectFilter* pFilter, bool bDefault = false);
183  virtual void SetOwnsFilter(bool bOwnFilter){m_bOwnFilter = bOwnFilter;};
184  virtual void RemoveAllFilters(void);
185  const wxGxObjectList& GetChildren() const { return m_ObjectList; };
186  virtual wxString GetName(void) const;
187  virtual wxString GetFullName(void) const;
188  virtual CPLString GetPath(void) const;
189  virtual wxGxObject* const GetLocation(void) const;
190  virtual wxGxObjectFilter* GetCurrentFilter(void) const;
191  virtual size_t GetCurrentFilterId(void) const;
192 protected:
193 // events
194  virtual void OnCommand(wxCommandEvent& event);
195  virtual void OnCommandUI(wxUpdateUIEvent& event);
196  virtual void OnDropDownCommand(wxCommandEvent& event);
197  virtual void OnToolDropDown(wxAuiToolBarEvent& event);
198  virtual void OnItemSelected(wxListEvent& event);
199  virtual void OnFilterSelect(wxCommandEvent& event);
200  virtual void OnOK(wxCommandEvent& event);
201  virtual void OnOKUI(wxUpdateUIEvent& event);
202  virtual void Command(wxGISCommand* pCmd);
203 //wxGxObjectDialog
204  virtual void OnInit();
205  virtual void SerializeFramePos(bool bSave);
206  virtual bool DoSaveObject(wxGISEnumSaveObjectResults Result);
207 protected:
208  wxGISAcceleratorTable* m_pGISAcceleratorTable;
209  wxGxCatalogUI* m_pCatalog;
210  wxGxDialogContentView* m_pwxGxContentView;
211  wxTreeViewComboPopup* m_PopupCtrl;
212  IDropDownCommand* m_pDropDownCommand;
213  wxString m_sOkBtLabel;
214  wxString m_sStartPath;
215  wxString m_sName;
216  bool m_bAllowMultiSelect, m_bOverwritePrompt, m_bAllFilters;
217  bool m_bIsSaveDlg;
218  wxGxObjectFiltersArray m_FilterArray;
219  size_t m_nDefaultFilter;
220  wxGxObjectList m_ObjectList;
221  int m_nRetCode;
222  bool m_bOwnFilter;
223 protected:
224  wxBoxSizer* bMainSizer;
225  wxBoxSizer* bHeaderSizer;
226  wxStaticText* m_staticText1;
227  wxStaticText* m_staticText2;
228  wxComboCtrl* m_TreeCombo;
229  wxAuiToolBar* m_toolBar;
230  wxFlexGridSizer* fgCeilSizer;
231  wxStaticText* m_staticText4;
232  wxTextCtrl* m_NameTextCtrl;
233  wxButton* m_OkButton;
234  wxStaticText* m_staticText6;
235  wxComboBox* m_WildcardCombo;
236  wxButton* m_CancelButton;
237 private:
238  DECLARE_EVENT_TABLE()
239 };
240 
An Interface class for GxApplication.
Definition: gxselection.h:80
The GxSelection class event.
Definition: gxeventui.h:37
Definition: applicationbase.h:65
Definition: gxobjdialog.h:62
Definition: command.h:53
Definition: gxobjdialog.h:127
Definition: gxcatalogui.h:34
Definition: gxobjdialog.h:78
The base class for tree view of gxObjects.
Definition: gxtreeview.h:64
The GxObject Selection class.
Definition: gxselection.h:30
Definition: gxobjdialog.h:160
Definition: gxcontentview.h:61
Definition: gxfilters.h:33
Definition: command.h:151
Definition: accelerator.h:28
Definition: gxobject.h:37