Version: 0.6.0
gxcontentview.h
1 /******************************************************************************
2  * Project: wxGIS (GIS Catalog)
3  * Purpose: wxGxContentView class.
4  * Author: Dmitry Baryshnikov (aka Bishop), polimax@mail.ru
5  ******************************************************************************
6 * Copyright (C) 2009-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/catalogui/gxview.h"
24 #include "wxgis/catalogui/gxcatalogui.h"
25 #include "wxgis/catalog/gxevent.h"
26 #include "wxgis/catalogui/gxeventui.h"
27 #include "wxgis/catalogui/gxapplication.h"
28 
29 #include "wx/listctrl.h"
30 #include "wx/imaglist.h"
31 
32 class wxGxApplication;
33 
34 #define LISTSTYLE (wxLC_REPORT | wxBORDER_NONE | wxLC_EDIT_LABELS | wxLC_AUTOARRANGE) //wxLC_LIST|wxLC_SORT_ASCENDING
35 
36 #if defined(__WINDOWS__)
37  #define wxGISLIST_STATE_DROPHILITED wxLIST_STATE_DROPHILITED
38 #elif defined(__UNIX__)
39  #define wxGISLIST_STATE_DROPHILITED wxLIST_STATE_SELECTED
40 #else //MAC
41 #endif // defined
42 
49 typedef struct _sortdata
50 {
51  bool bSortAsc;
52  short currentSortCol;
54 
61 class WXDLLIMPEXP_GIS_CLU wxGxContentView :
62  public wxListCtrl,
63  public wxGxView,
64  public IGxContentsView,
65  public IViewDropTarget,
66  public wxThreadHelper
67 {
68  DECLARE_DYNAMIC_CLASS(wxGxContentView)
69 public:
70  wxGxContentView(void);
71  wxGxContentView(wxWindow* parent, wxWindowID id = LISTCTRLID, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = LISTSTYLE);
72  virtual ~wxGxContentView(void);
73  virtual void Serialize(wxXmlNode* pRootNode, bool bStore);
74  virtual bool AddObject(wxGxObject* const pObject);
75  virtual void ResetContents(void);
76  virtual wxGxObject* const GetParentGxObject(void) const;
77  virtual void SelectAll(void);
78  virtual bool Show(bool show = true);
79  virtual void RefreshAll(void);
80  virtual long HitTest( const wxPoint& point, int& flags, long *pSubItem = NULL ) const;
81 // wxGxView
82  virtual bool Create(wxWindow* parent, wxWindowID id = LISTCTRLID, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = LISTSTYLE, const wxString& name = wxT("ContentView"));
83  virtual bool Activate(IApplication* const pApplication, wxXmlNode* const pConf);
84  virtual void Deactivate(void);
85  virtual bool Applies(wxGxSelection* const pSelection);
86  virtual void BeginRename(long nObjectID = wxNOT_FOUND);
87 // IGxContentsView
88  virtual void SetStyle(wxGISEnumContentsViewStyle style);
89  virtual wxGISEnumContentsViewStyle GetStyle(void){return m_current_style;};
90  virtual bool CanSetStyle(void){return true;};
91 // IViewDropTarget
92  virtual wxDragResult OnDragOver(wxCoord x, wxCoord y, wxDragResult def);
93  virtual bool OnDropObjects(wxCoord x, wxCoord y, const wxArrayString& GxObjects, bool bIsControlOn);
94  virtual void OnLeave();
95  virtual bool CanPaste(void);
96 // events
97  virtual void OnColClick(wxListEvent& event);
98  virtual void OnContextMenu(wxContextMenuEvent& event);
99  virtual void ShowContextMenu(const wxPoint& pos);
100  virtual void SetColumnImage(int col, int image);
101  virtual void OnActivated(wxListEvent& event);
102  virtual void OnBeginLabelEdit(wxListEvent& event);
103  virtual void OnEndLabelEdit(wxListEvent& event);
104  virtual void OnSelected(wxListEvent& event);
105  virtual void OnDeselected(wxListEvent& event);
106  virtual void OnBeginDrag(wxListEvent& event);
107  virtual void OnChar(wxKeyEvent& event);
108  virtual void OnObjectRefreshed(wxGxCatalogEvent& event);
109  virtual void OnObjectAdded(wxGxCatalogEvent& event);
110  virtual void OnObjectChanged(wxGxCatalogEvent& event);
111  virtual void OnObjectDeleted(wxGxCatalogEvent& event);
112  virtual void OnSelectionChanged(wxGxSelectionEvent& event);
113 
114  typedef struct _itemdata
115  {
116  long nObjectID;
117  int iImageIndex;
118  } ITEMDATA, *LPITEMDATA;
119 
120  typedef struct _icondata
121  {
122  wxIcon oIcon;
123  int iImageIndex;
124  bool bLarge;
125  } ICONDATA;
126 
127 protected:
128  int GetIconPos(wxIcon icon_small, wxIcon icon_large);
129  virtual void InitColumns(void);
130  virtual void SelectItem(int nChar = WXK_DOWN, bool bShift = false);
131  virtual wxThread::ExitCode Entry();
132  virtual bool CreateAndRunFillMetaThread(void);
133  virtual void DestroyFillMetaThread(void);
134 protected:
135  bool m_bSortAsc;
136  short m_currentSortCol;
137  wxGISEnumContentsViewStyle m_current_style;
138  wxArrayInt m_anOrder, m_anWidth;
139  wxImageList m_ImageListSmall, m_ImageListLarge;
140 
141  long m_ConnectionPointCatalogCookie;
142 
143  wxGxSelection* m_pSelection;
144  wxGxCatalogUI* m_pCatalog;
145  wxGISApplicationBase* m_pApp;
146  wxGxApplication *m_pGxApp;
147  wxGISCommand* m_pDeleteCmd;
148 
149  long m_nParentGxObjectID;
150  bool m_bDragging;
151  wxVector<ICONDATA> m_IconsArray;
152  wxCriticalSection m_CritSect;
153  wxCriticalSection m_CritSectCont;
154  wxCriticalSection m_CritSectFillMeta;
155  long m_HighLightItem;
156  int m_bPrevChar;
157 
158  wxArrayLong m_anFillMetaIDs;
159 private:
160  DECLARE_EVENT_TABLE()
161 };
The GxSelection class event.
Definition: gxeventui.h:37
Definition: applicationbase.h:65
Definition: gxcontentview.h:49
Definition: gxcontentview.h:114
The Network event.
Definition: gxevent.h:39
Definition: command.h:53
Definition: gxview.h:35
Definition: gxcatalogui.h:34
The GxObject Selection class.
Definition: gxselection.h:30
Definition: gxcontentview.h:61
Definition: gxcontentview.h:120
Definition: framework.h:59
Definition: app.h:32
Definition: gxapplication.h:41
Definition: catalogui.h:112
Definition: gxobject.h:37