UNIVERS  15.3
UNIVERS base processing software API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
ZmTableTool.H
1 /* ZmTableTool.H */
2 /* $Id: ZmTableTool.H,v 1.5 2005/03/01 14:44:32 vlad Exp $ */
3 #ifndef __ZmTableTool_H
4 #define __ZmTableTool_H
5 
6 #include <X11/Intrinsic.h>
7 
8 #include <mix/Types.h>
9 #include <mix/IntAr.H>
10 #include <mix/growbuf.h>
11 #include <zm/ZmSelection.H>
12 
13 
15 #define ZmTT_DEFAULT_COLUMN_WIDTH 10
16 
18 #define ZmTT_DEFAULT_RES_NAME "TableTool"
19 
21 #define ZmTT_DEFAULT_ROW_LABEL_WIDTH 6
22 
24 #define ZmTT_VECTOR_SEPARATOR "; "
25 
31 class ZmTableTool : public ZmSelection
32 {
33 public:
34 
36  ZmTableTool (Widget wParent, int nColumns,
37  const char* szResName = ZmTT_DEFAULT_RES_NAME);
38 
40  virtual ~ZmTableTool ();
41 
42  /*
43  * Common service operations.
44  */
45 
47  operator Widget () const;
48 
50  virtual void set_visible_rows_number (int nVisRows);
51 
53  virtual void limit_size ();
54 
58  virtual void refresh ();
59 
63  virtual void commit_changes ();
64 
66  void fix_left_column (Logic flag);
67  Logic is_left_column_fixed () const;
68 
70  void fix_rows_number (Logic flag);
71  Logic is_rows_number_fixed () const;
72 
74  void set_current_pos (int iRow, int iColumn);
75  void get_current_pos (int& iRow, int& iColumn) const;
76 
79  vdOK,
88  };
89 
91  ValueDiagnose verify_string (AtomType atype, int dim, const char* s);
92 
94  ValueDiagnose verify_int (AtomType atype, const char* s);
95 
97  ValueDiagnose verify_real (AtomType atype, const char* s);
98 
101  void scan_string (AtomType atype, const char* s, void* v);
102 
105  void scan_string (AtomType atype, int dim, const char* s, void* v);
106 
107  /*
108  * Virtual interface to overload in derived classes.
109  * Internal data representation only.
110  */
111 
112  /* *** Visual changes cause changes in internal data repres. *** */
113 
117  virtual void write_cell (int iRow, int iColumn, const char* s);
118 
120  virtual void delete_rows (int iRow, int nRows);
121 
123  virtual void insert_rows (int iRow, int nRows);
124 
126  virtual void add_row ();
127 
128 
129  /* *** Internal data changes cause changes in visual repres. *** */
130 
132  virtual int get_rows_count ();
133 
135  virtual char* draw_cell (int iRow, int iColumn);
136 
139  virtual char* get_column_label (int iColumn);
140 
143  virtual char* get_row_label (int iRow);
144 
145  /* sizes */
146 
148  virtual int get_column_width (int iColumn);
149 
151  virtual int get_column_length (int iColumn);
152 
154  virtual int get_row_labels_width ();
155 
156 
157  /* *** Virtual callbacks' stubs *** */
158 
161  virtual Logic start_modifying_cell (int iRow, int iColumn,
162  const char* szText);
163 
166  virtual Logic verify_cell (int iRow, int iColumn, const char* szText);
167 
169  virtual void popup_menu (int iRow, int iColumn);
170 
171 
172  /*
173  * Working with selection
174  */
175 
177  void select_all_rows ();
178 
180  void unselect_rows ();
181 
183  void select_row (int iRow);
184 
187  void select_till_row (int iRow);
188 
191  void get_selected_rows (IntAr& sRows) const;
192 
193 
195  void select_all_columns ();
196 
198  void unselect_columns ();
199 
203  void select_column (int iColumn, bool bForce = false);
204 
207  void get_selected_columns (IntAr& sCols) const;
208 
209 
210 
211  /*
212  * Working with clipboard
213  */
214 
218  virtual void highlight_data (bool flag);
219 
221  void copy_to_clipboard (Time timestamp);
222 
224  void paste_from_clipboard (Time timestamp);
225 
226 protected:
227 
229  Widget wMatrix;
230 
232  Widget wPopup;
233 
235  Widget wPopupItem[16];
236 #define POPUP_MENU_clipboard 0
237 #define POPUP_MENU_sep1 1
238 #define POPUP_MENU_COPY 2
239 #define POPUP_MENU_PASTE 3
240 #define POPUP_MENU_sep2 4
241 #define POPUP_MENU_sep3 5
242 #define POPUP_MENU_rows 6
243 #define POPUP_MENU_sep4 7
244 #define POPUP_MENU_INSERT_ROW 8
245 #define POPUP_MENU_INSERT_ROWS 9
246 #define POPUP_MENU_DELETE 10
247 #define POPUP_MENU_DUPLICATE 11
248 #define POPUP_MENU_SELECT_ROW 12
249 #define POPUP_MENU_SELECT_TILL 13
250 #define POPUP_MENU_SELECT_ALL 14
251 #define POPUP_MENU_UNSELECT_ALL 15
252 
253 
256  int rows_cnt, columns_cnt;
257 
259  int popup_row, popup_column;
260 
263 
266 
269 
272  Cell,
273  Rows,
274  Columns
275  };
276 
277  /* Last selected row; -1 means disabled. */
278  int last_sel_row;
279 
282 
285 
288 
291 
292 
294  Logic event_to_pos (XEvent* xev, int& iRow, int& iColumn);
295 
297  void set_row_labels ();
298 
300  void set_column_labels ();
301 
303  void set_column_widths ();
304 
306  void set_column_lengths ();
307 
309  void normalize_pos (int& iRow, int& iColumn);
310 
311  /*
312  * Own dialogs.
313  */
314 
316  Logic dialog_number_of_rows (int &nRows);
317 
318 
319  /*
320  * Callbacks.
321  */
322 
324  static void PostItCB (Widget w, XtPointer pUserData,
325  XEvent* event, Boolean* rc);
326 
328  static void DrawWriteCellCB (Widget w, XtPointer pUserData,
329  XtPointer pCallData);
330 
332  static void InsertRowCB (Widget w, XtPointer pUserData,
333  XtPointer pCallData);
334  static void InsertRowsCB (Widget w, XtPointer pUserData,
335  XtPointer pCallData);
336 
338  static void DeleteRowsCB (Widget w, XtPointer pUserData,
339  XtPointer pCallData);
340 
342  static void DuplicateRowsCB (Widget w, XtPointer pUserData,
343  XtPointer pCallData);
344 
346  static void SelectRowCB (Widget w, XtPointer pUserData,
347  XtPointer pCallData);
348 
350  static void SelectRowsHereCB (Widget w, XtPointer pUserData,
351  XtPointer pCallData);
352 
354  static void SelectAllRowsCB (Widget w, XtPointer pUserData,
355  XtPointer pCallData);
356 
358  static void UnselectAllRowsCB (Widget w, XtPointer pUserData,
359  XtPointer pCallData);
360 
362  static void EnterCellCB (Widget w, XtPointer pUserData,
363  XtPointer pCallData);
364 
366  static void ModifyCellCB (Widget w, XtPointer pUserData,
367  XtPointer pCallData);
368 
370  static void VerifyCellCB (Widget w, XtPointer pUserData,
371  XtPointer pCallData);
372 
374  static void TrackVisibleCellCB (Widget w, XtPointer pUserData,
375  XtPointer pCallData);
376 
378  static void LabelCB (Widget w, XtPointer pUserData,
379  XtPointer pCallData);
380 
381 
382 
383  /*
384  * Clipboard related callbacks
385  */
386 
389  static void ClipbCutCB (Widget w, XtPointer pUserData,
390  XtPointer pCallData);
391 
393  static void ClipbCopyCB (Widget w, XtPointer pUserData,
394  XtPointer pCallData);
395 
400  static void ClipbPasteCB (Widget w, XtPointer pUserData,
401  XtPointer pCallData);
402 
403 };
404 
405 
406 #endif /* ZmTableTool.H */
IntAr pubRows
Definition: ZmTableTool.H:287
static void SelectAllRowsCB(Widget w, XtPointer pUserData, XtPointer pCallData)
Widget wMatrix
Definition: ZmTableTool.H:229
void select_all_columns()
virtual Logic verify_cell(int iRow, int iColumn, const char *szText)
ValueDiagnose verify_real(AtomType atype, const char *s)
void set_current_pos(int iRow, int iColumn)
virtual void commit_changes()
virtual void set_visible_rows_number(int nVisRows)
virtual void highlight_data(bool flag)
ValueDiagnose verify_int(AtomType atype, const char *s)
static void DrawWriteCellCB(Widget w, XtPointer pUserData, XtPointer pCallData)
static void VerifyCellCB(Widget w, XtPointer pUserData, XtPointer pCallData)
Definition: ZmTableTool.H:31
void set_column_lengths()
virtual void refresh()
Widget wPopup
Definition: ZmTableTool.H:232
Definition: ZmTableTool.H:81
Definition: ZmTableTool.H:82
GrowingBuffer gb
Definition: ZmTableTool.H:265
Definition: IntAr.H:14
static void SelectRowsHereCB(Widget w, XtPointer pUserData, XtPointer pCallData)
void unselect_columns()
virtual char * draw_cell(int iRow, int iColumn)
void paste_from_clipboard(Time timestamp)
void copy_to_clipboard(Time timestamp)
void scan_string(AtomType atype, const char *s, void *v)
void set_row_labels()
static void TrackVisibleCellCB(Widget w, XtPointer pUserData, XtPointer pCallData)
static void ClipbPasteCB(Widget w, XtPointer pUserData, XtPointer pCallData)
virtual void limit_size()
Definition: ZmSelection.H:16
int popup_row
Definition: ZmTableTool.H:259
Definition: ZmTableTool.H:80
virtual void delete_rows(int iRow, int nRows)
virtual Logic start_modifying_cell(int iRow, int iColumn, const char *szText)
virtual ~ZmTableTool()
void unselect_rows()
ValueDiagnose verify_string(AtomType atype, int dim, const char *s)
Definition: ZmTableTool.H:84
Logic event_to_pos(XEvent *xev, int &iRow, int &iColumn)
IntAr selCols
Definition: ZmTableTool.H:284
void normalize_pos(int &iRow, int &iColumn)
void select_row(int iRow)
int rows_cnt
Definition: ZmTableTool.H:256
void select_all_rows()
IntAr selRows
Definition: ZmTableTool.H:281
virtual int get_row_labels_width()
virtual void popup_menu(int iRow, int iColumn)
virtual int get_rows_count()
Logic dialog_number_of_rows(int &nRows)
static void LabelCB(Widget w, XtPointer pUserData, XtPointer pCallData)
static void EnterCellCB(Widget w, XtPointer pUserData, XtPointer pCallData)
virtual void insert_rows(int iRow, int nRows)
Logic bFixedRowsNumber
Definition: ZmTableTool.H:262
void get_selected_columns(IntAr &sCols) const
Definition: ZmTableTool.H:85
virtual char * get_column_label(int iColumn)
Definition: ZmTableTool.H:87
void select_till_row(int iRow)
void select_column(int iColumn, bool bForce=false)
void get_selected_rows(IntAr &sRows) const
virtual void write_cell(int iRow, int iColumn, const char *s)
virtual int get_column_length(int iColumn)
Definition: ZmTableTool.H:79
DataDirection
Definition: ZmTableTool.H:271
static void SelectRowCB(Widget w, XtPointer pUserData, XtPointer pCallData)
void fix_left_column(Logic flag)
Definition: ZmTableTool.H:86
IntAr pubCols
Definition: ZmTableTool.H:290
GrowingBuffer gbClipboard
Definition: ZmTableTool.H:268
static void UnselectAllRowsCB(Widget w, XtPointer pUserData, XtPointer pCallData)
Definition: ZmTableTool.H:83
static void ClipbCutCB(Widget w, XtPointer pUserData, XtPointer pCallData)
void set_column_widths()
static void ModifyCellCB(Widget w, XtPointer pUserData, XtPointer pCallData)
Definition: growbuf.h:23
static void InsertRowCB(Widget w, XtPointer pUserData, XtPointer pCallData)
Widget wPopupItem[16]
Definition: ZmTableTool.H:235
virtual char * get_row_label(int iRow)
static void ClipbCopyCB(Widget w, XtPointer pUserData, XtPointer pCallData)
void set_column_labels()
virtual int get_column_width(int iColumn)
static void DeleteRowsCB(Widget w, XtPointer pUserData, XtPointer pCallData)
static void DuplicateRowsCB(Widget w, XtPointer pUserData, XtPointer pCallData)
static void PostItCB(Widget w, XtPointer pUserData, XEvent *event, Boolean *rc)
ZmTableTool(Widget wParent, int nColumns, const char *szResName=ZmTT_DEFAULT_RES_NAME)
virtual void add_row()
ValueDiagnose
Definition: ZmTableTool.H:78
void fix_rows_number(Logic flag)