Version: 0.6.0
gxlocationcombobox.h
1 /******************************************************************************
2  * Project: wxGIS (GIS Catalog)
3  * Purpose: wxGxLocationComboBox class
4  * Author: Dmitry Baryshnikov (aka Bishop), polimax@mail.ru
5  ******************************************************************************
6 * Copyright (C) 2009,2011,2012 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 #include "wxgis/catalogui/catalogui.h"
22 #include "wxgis/catalogui/gxapplication.h"
23 #include "wxgis/catalogui/gxeventui.h"
24 #include "wxgis/catalogui/gxcontentview.h"
25 
26 #include <wx/combo.h>
27 #include <wx/combobox.h>
28 #include <wx/popupwin.h>
29 
30 #define LISTVIEWPOPUPID 1306 //wxGxCatalog contents view
31 #define LISTPOPUSTYLE (wxBORDER_SIMPLE | wxLC_SORT_ASCENDING | wxLC_AUTOARRANGE | wxLC_REPORT | wxLC_NO_HEADER | wxLC_SINGLE_SEL)
32 //wxWANTS_CHARS
33 
42  public wxListCtrl
43 {
44  DECLARE_CLASS(wxGxPathsListView)
45 public:
46  wxGxPathsListView(void);
47  wxGxPathsListView(wxWindow* parent, wxWindowID id = LISTVIEWPOPUPID, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = LISTPOPUSTYLE);
48  virtual ~wxGxPathsListView(void);
49  virtual bool Create(wxWindow* parent, wxWindowID id = LISTVIEWPOPUPID, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = LISTPOPUSTYLE, const wxString& name = wxT("ListViewComboPopup"));
50  virtual void Append(const wxString& sFullName);
51  virtual void Deactivate(void);
52 
53  //events
54  // Do mouse hot-tracking (which is typical in list popups)
55  virtual void OnMouseMove(wxMouseEvent& event);
56  // On mouse left up, set the value and close the popup
57  virtual void OnMouseClick(wxMouseEvent& event);
58  virtual void OnChar(wxKeyEvent& event);
59  virtual void OnObjectDeleted(wxGxCatalogEvent& event);
60  virtual void OnObjectChanged(wxGxCatalogEvent& event);
61 
62  //structures
63  typedef struct _itemdata
64  {
65  long nObjectID;
66  int iImageIndex;
67  } ITEMDATA, *LPITEMDATA;
68  typedef struct _icondata
69  {
70  wxIcon oIcon;
71  int iImageIndex;
72  } ICONDATA;
73 protected:
74  wxVector<ICONDATA> m_IconsArray;
75  int GetIconPos(const wxIcon &icon_small);
76  virtual void Activate();
77  wxImageList m_ImageListSmall;
78  wxGxCatalogUI* m_pCatalog;
79  long m_HighLightItem;
80  long m_ConnectionPointCatalogCookie;
81 private:
82  DECLARE_EVENT_TABLE()
83 };
84 
85 
94  public wxGxPathsListView,
95  public wxComboPopup
96 {
97  DECLARE_CLASS(wxListViewComboPopup)
98 public:
99  // Initialize member variables
100  virtual void Init();
101  virtual void OnPopup();
102  virtual void OnDismiss();
103  // Create popup control
104  virtual bool Create(wxWindow* parent);
105  virtual bool Create(wxWindow* parent, wxWindowID id = LISTVIEWPOPUPID, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = LISTPOPUSTYLE, const wxString& name = wxT("ListViewComboPopup"));
106  // Return pointer to the created control
107  virtual wxWindow *GetControl() { return this; }
108  // Translate string into a list selection
109  virtual void SetStringValue(const wxString& s);
110  // Get list selection as a string
111  virtual wxString GetStringValue() const;
112  virtual wxSize GetAdjustedSize (int minWidth, int prefHeight, int maxHeight);
113  //events
114  virtual void OnMouseClick(wxMouseEvent& event);
115  virtual void OnChar(wxKeyEvent& event);
116 protected:
117  wxString m_sVal;
118 };
119 
121 
130 {
131 public:
133  virtual ~wxGxPathsListViewPopupParent(void);
134  virtual void SetControlText(const wxString &str, bool bFireEvents = false) = 0;
135  virtual wxString GetControlText(void) const = 0;
136  virtual void DestroyPathsPopup(void);
137  virtual wxRect GetControlRect() const = 0;
138  virtual wxSize GetControlSize() const = 0;
139  virtual void OnTextEnter(wxCommandEvent& event) = 0;
140  //
141  virtual void OnKillFocus(wxFocusEvent& event);
142  virtual void OnChar(wxKeyEvent& event);
143  virtual void OnMouseWheel(wxMouseEvent& event);
144 protected:
145  wxGxPathsListViewPopup* m_pProbablePathsPopup;
146 };
147 
156  public wxPopupWindow
157 {
158  DECLARE_CLASS(wxGxPathsListViewPopup)
159 public:
160  wxGxPathsListViewPopup(wxWindow* parent, int nMaxHeight = 500);
161  virtual ~wxGxPathsListViewPopup(void);
162  void Append(const wxString& sFullName);
163  //events
164  void OnSize(wxSizeEvent& WXUNUSED(event));
165  void OnMouseWheel(wxMouseEvent& event);
166  void OnChar(wxKeyEvent& event);
167  void OnMouseClick(wxMouseEvent& event);
168  //
169  wxRect GetViewRect() const;
170  void Show(const wxString &sPath);
171  void Update(const wxString &sPath);
172  bool IsSelected() const {return m_bSelected;};
173 protected:
174  wxGxPathsListView* m_pGxPathsListView;
175  int m_nItemHeight;
176  wxGxPathsListViewPopupParent* m_pParent;
177  int m_nMaxHeight;
178  bool m_bSelected;
179 private:
180  DECLARE_EVENT_TABLE()
181 };
182 
183 
192  public wxComboCtrl,
194  public IToolBarControl
195 {
196 public:
197  wxGxLocationComboBox(wxWindow* parent, wxWindowID id, const wxSize& size);
198  virtual ~wxGxLocationComboBox(void);
199  //wxGxPathsListViewPopupParent
200  virtual void SetControlText(const wxString &str, bool bFireEvents = false);
201  virtual wxString GetControlText(void) const;
202  virtual wxRect GetControlRect() const;
203  virtual wxSize GetControlSize() const;
204  //events
205  virtual void OnTextEnter(wxCommandEvent& event);
206  void OnText(wxCommandEvent& event);
207  //IToolBarControl
208  virtual void Activate(wxGISApplicationBase* pApp);
209  virtual void Deactivate(void);
210  //events
211  virtual void OnSelectionChanged(wxGxSelectionEvent& event);
212  virtual void OnKillFocus(wxFocusEvent& event);
213  virtual void OnChar(wxKeyEvent& event);
214  virtual void OnMouseWheel(wxMouseEvent& event);
215  virtual void OnMouseDblClick(wxMouseEvent& event);
216 protected:
217  wxGxApplication* m_pApp;
218  wxArrayString m_ValuesArr;
219  long m_ConnectionPointSelectionCookie;
220  wxGxSelection* m_pSelection;
221  wxGxCatalogUI* m_pCatalog;
222  wxListViewComboPopup* m_pListViewComboPopup;
223  wxWindow* m_pWnd;
224 private:
225  DECLARE_EVENT_TABLE()
226 };
Definition: gxlocationcombobox.h:63
The GxSelection class event.
Definition: gxeventui.h:37
Definition: applicationbase.h:65
The Network event.
Definition: gxevent.h:39
Definition: gxlocationcombobox.h:191
Definition: gxcatalogui.h:34
Definition: gxlocationcombobox.h:155
Definition: gxlocationcombobox.h:68
The GxObject Selection class.
Definition: gxselection.h:30
Definition: command.h:92
Definition: gxlocationcombobox.h:93
Definition: gxlocationcombobox.h:41
Definition: gxlocationcombobox.h:129
Definition: gxapplication.h:41