1 
2 ///////////////////////////////////////////////////////////
3 //                                                       //
4 //                         SAGA                          //
5 //                                                       //
6 //      System for Automated Geoscientific Analyses      //
7 //                                                       //
8 //                    User Interface                     //
9 //                                                       //
10 //                    Program: SAGA                      //
11 //                                                       //
12 //-------------------------------------------------------//
13 //                                                       //
14 //                 VIEW_Table_Control.h                  //
15 //                                                       //
16 //          Copyright (C) 2005 by Olaf Conrad            //
17 //                                                       //
18 //-------------------------------------------------------//
19 //                                                       //
20 // This file is part of 'SAGA - System for Automated     //
21 // Geoscientific Analyses'. SAGA is free software; you   //
22 // can redistribute it and/or modify it under the terms  //
23 // of the GNU General Public License as published by the //
24 // Free Software Foundation, either version 2 of the     //
25 // License, or (at your option) any later version.       //
26 //                                                       //
27 // SAGA is distributed in the hope that it will be       //
28 // useful, but WITHOUT ANY WARRANTY; without even the    //
29 // implied warranty of MERCHANTABILITY or FITNESS FOR A  //
30 // PARTICULAR PURPOSE. See the GNU General Public        //
31 // License for more details.                             //
32 //                                                       //
33 // You should have received a copy of the GNU General    //
34 // Public License along with this program; if not, see   //
35 // <http://www.gnu.org/licenses/>.                       //
36 //                                                       //
37 //-------------------------------------------------------//
38 //                                                       //
39 //    contact:    Olaf Conrad                            //
40 //                Institute of Geography                 //
41 //                University of Hamburg                  //
42 //                Germany                                //
43 //                                                       //
44 //    e-mail:     oconrad@saga-gis.org                   //
45 //                                                       //
46 ///////////////////////////////////////////////////////////
47 
48 //---------------------------------------------------------
49 #ifndef _HEADER_INCLUDED__SAGA_GUI__VIEW_Table_Control_H
50 #define _HEADER_INCLUDED__SAGA_GUI__VIEW_Table_Control_H
51 
52 
53 ///////////////////////////////////////////////////////////
54 //														 //
55 //														 //
56 //														 //
57 ///////////////////////////////////////////////////////////
58 
59 //---------------------------------------------------------
60 #include <wx/grid.h>
61 
62 
63 ///////////////////////////////////////////////////////////
64 //														 //
65 //														 //
66 //														 //
67 ///////////////////////////////////////////////////////////
68 
69 //---------------------------------------------------------
70 class CVIEW_Table_Control : public wxGrid
71 {
72 	DECLARE_CLASS(CVIEW_Table_Control)
73 
74 public:
75 	CVIEW_Table_Control(wxWindow *pParent, class CSG_Table *pTable, int Constraint);
76 	virtual ~CVIEW_Table_Control(void);
77 
78 	bool						Load				(const wxString &File_Name);
79 	bool						Save				(const wxString &File_Name, int Format = 0);
80 
81 	bool						Update_Table		(void);
82 	bool						Update_Selection	(void);
83 
84 	bool						Update_Float_Format	(void);
85 
86 
87 protected:
88 
89 	void						On_Selecting		(wxGridRangeSelectEvent &event);
90 	void						On_Selected			(wxGridRangeSelectEvent &event);
91 
92 	void						On_Changed			(wxGridEvent      &event);
93 
94 	void						On_LClick			(wxGridEvent      &event);
95 	void						On_LDClick			(wxGridEvent      &event);
96 	void						On_LClick_Label		(wxGridEvent      &event);
97 	void						On_LDClick_Label	(wxGridEvent      &event);
98 
99 	void						On_RClick			(wxGridEvent      &event);
100 	void						On_RClick_Label		(wxGridEvent      &event);
101 
102 	void						On_Sel_Only			(wxCommandEvent   &event);
103 	void						On_Sel_Only_UI		(wxUpdateUIEvent  &event);
104 	void						On_Sel_Clear		(wxCommandEvent   &event);
105 	void						On_Sel_Clear_UI		(wxUpdateUIEvent  &event);
106 
107 	void						On_Autosize_Cols	(wxCommandEvent   &event);
108 	void						On_Autosize_Rows	(wxCommandEvent   &event);
109 
110 	void						On_Cell_Open		(wxCommandEvent   &event);
111 
112 	void						On_ToClipboard		(wxCommandEvent   &event);
113 
114 	void						On_Field_Add		(wxCommandEvent   &event);
115 	void						On_Field_Add_UI		(wxUpdateUIEvent  &event);
116 	void						On_Field_Move		(wxCommandEvent   &event);
117 	void						On_Field_Move_UI	(wxUpdateUIEvent  &event);
118 	void						On_Field_Del		(wxCommandEvent   &event);
119 	void						On_Field_Del_UI		(wxUpdateUIEvent  &event);
120 	void						On_Field_Hide		(wxCommandEvent   &event);
121 	void						On_Field_Hide_UI	(wxUpdateUIEvent  &event);
122 	void						On_Field_Sort		(wxCommandEvent   &event);
123 	void						On_Field_Sort_UI	(wxUpdateUIEvent  &event);
124 	void						On_Field_Rename		(wxCommandEvent   &event);
125 	void						On_Field_Rename_UI	(wxUpdateUIEvent  &event);
126 	void						On_Field_Type		(wxCommandEvent   &event);
127 	void						On_Field_Type_UI	(wxUpdateUIEvent  &event);
128 	void						On_Field_Calc		(wxCommandEvent   &event);
129 	void						On_Field_Calc_UI	(wxUpdateUIEvent  &event);
130 
131 	void						On_Record_Add		(wxCommandEvent   &event);
132 	void						On_Record_Add_UI	(wxUpdateUIEvent  &event);
133 	void						On_Record_Ins		(wxCommandEvent   &event);
134 	void						On_Record_Ins_UI	(wxUpdateUIEvent  &event);
135 	void						On_Record_Del		(wxCommandEvent   &event);
136 	void						On_Record_Del_UI	(wxUpdateUIEvent  &event);
137 	void						On_Record_Clr		(wxCommandEvent   &event);
138 	void						On_Record_Clr_UI	(wxUpdateUIEvent  &event);
139 
140 
141 private:
142 
143 	int							m_Cursor;
144 
145 	CSG_Table					*m_pTable;
146 
147 	class CVIEW_Table_Data		*m_pData;
148 
149 	CSG_Parameters				m_Field_Calc;
150 
151 
152 	bool						_Update_Records		(void);
153 
154 	bool						_Update_Selection	(bool bViews);
155 
156 	static int					_Parameter_Callback	(CSG_Parameter *pParameter, int Flags);
157 
158 
159 	DECLARE_EVENT_TABLE()
160 };
161 
162 
163 ///////////////////////////////////////////////////////////
164 //														 //
165 //														 //
166 //														 //
167 ///////////////////////////////////////////////////////////
168 
169 //---------------------------------------------------------
170 #endif // #ifndef _HEADER_INCLUDED__SAGA_GUI__VIEW_Table_Control_H
171