OpendTect-6_4  6.4
uitable.h
Go to the documentation of this file.
1 #ifndef uitable_h
2 #define uitable_h
3 
4 /*+
5 ________________________________________________________________________
6 
7  (C) dGB Beheer B.V.; (LICENSE) http://opendtect.org/OpendTect_license.txt
8  Author: A.H. Lammertink
9  Date: 12/02/2003
10  RCS: $Id$
11 ________________________________________________________________________
12 
13 -*/
14 
15 #include "uibasemod.h"
16 #include "uiobj.h"
17 
18 #include "color.h"
19 #include "keyenum.h"
20 #include "rowcol.h"
21 #include "draw.h"
22 
23 class BufferStringSet;
24 class uiPixmap;
25 class uiGroup;
26 class uiLabel;
27 class uiTableBody;
28 
29 
30 mExpClass(uiBase) uiTable : public uiObject
32 friend class i_tableMessenger;
33 friend class uiTableBody;
34 public:
35 
37  {
41  SingleRow
42  };
43 
45  {
46  SelectItems, SelectRows, SelectColumns
47  };
48 
50  {
51  Interactive, Fixed, Stretch, ResizeToContents
52  };
53 
54  mExpClass(uiBase) Setup
55  {
56  public:
57 
58  Setup(int nrrows=-1,int nrcols=-1)
59  : size_(nrrows,nrcols)
60  , rowdesc_("Row")
61  , coldesc_("Column")
62  , insertrowallowed_(true)
63  , removerowallowed_(true)
64  , rowgrow_(false)
65  , insertcolallowed_(true)
66  , removecolallowed_(true)
67  , colgrow_(false)
68  , fillrow_(false)
69  , fillcol_(false)
70  , minrowhgt_(1.f)
71  , maxrowhgt_(3.f)
72  , mincolwdt_(1.f*uiObject::baseFldSize())
74  , maxcolwdt_(2.3f*uiObject::baseFldSize())
76  , selmode_(NoSelection)
77  , removeselallowed_(true)
78  , snglclkedit_(true)
79  , defcollbl_(false)
80  , defrowlbl_(false)
81  , manualresize_(false)
83  , defrowstartidx_(1)
85  , rightclickdisabled_(false)
87  , enablecopytext_(false)
88  {}
89 
90  mDefSetupMemb(RowCol,size)
93  mDefSetupMemb(bool,rowgrow)
94  mDefSetupMemb(bool,colgrow)
95  mDefSetupMemb(bool,insertrowallowed)
96  mDefSetupMemb(bool,removerowallowed)
97  mDefSetupMemb(bool,insertcolallowed)
98  mDefSetupMemb(bool,removecolallowed)
99  mDefSetupMemb(bool,fillrow)
100  mDefSetupMemb(bool,fillcol)
101  mDefSetupMemb(float,maxrowhgt)
102  mDefSetupMemb(float,minrowhgt)
103  mDefSetupMemb(float,maxcolwdt)
104  mDefSetupMemb(float,mincolwdt)
106  mDefSetupMemb(bool,removeselallowed)
107  mDefSetupMemb(bool,snglclkedit)
108  mDefSetupMemb(bool,defrowlbl)
109  mDefSetupMemb(bool,defcollbl)
110  mDefSetupMemb(bool,manualresize)
111  mDefSetupMemb(int,defrowstartidx)
112  mDefSetupMemb(bool,rightclickdisabled)
113  mDefSetupMemb(bool,enablecopytext)
114 
115  Setup& sizesFixed( bool yn )
116  {
117  insertrowallowed_ = removerowallowed_ = rowgrow_ =
118  insertcolallowed_ = removecolallowed_ = colgrow_ = !yn;
119  return *this;
120  }
121  };
122 
123  uiTable(uiParent*,const Setup&,const char* nm);
124  virtual ~uiTable();
125 
126  const char* text(const RowCol&) const;
127  void setText(const RowCol&,const char*);
128  void setText(const RowCol&,const OD::String&);
129  void setText(const RowCol&,const uiString&);
130  void clearCell(const RowCol&);
131  void clearTable();
132  void showGrid(bool);
133  bool gridShown() const;
134  void setCurrentCell(const RowCol&,bool noselection=false);
135  void setCellObject(const RowCol&,uiObject*);
138  uiObject* getCellObject(const RowCol&) const;
139  void clearCellObject(const RowCol&);
140  RowCol getCell(uiObject*);
141  void setCellGroup(const RowCol&,uiGroup*);
144  uiGroup* getCellGroup(const RowCol&) const;
145  RowCol getCell(uiGroup*);
146  void setCellChecked(const RowCol&,bool yn);
147  bool isCellChecked(const RowCol&) const;
148 
149  int nrRows() const;
150  int nrCols() const;
151  void setNrRows(int);
152  void setNrCols(int);
153  void setPrefHeightInRows(int);
154 
155  int columnWidth(int) const;
156  int rowHeight(int) const;
157 
158  void setLeftMargin(int);
159  void setColumnWidth(int col,int w);
160  void setColumnWidthInChar(int col,float w);
161 
162  void setTopMargin(int);
163  void setRowHeight(int row,int h);
164  void setRowHeightInChar(int row,float h);
165 
166  void resizeHeaderToContents(bool hor);
167  void resizeColumnToContents(int);
168  void resizeColumnsToContents();
169  void resizeRowToContents(int);
170  void resizeRowsToContents();
171  void setColumnResizeMode(ResizeMode);
173  void setRowResizeMode(ResizeMode);
175  void setColumnStretchable(int,bool);
176  void setRowStretchable(int,bool);
177  bool isColumnStretchable(int) const;
178  bool isRowStretchable(int) const;
179 
180  void setTableReadOnly(bool);
181  bool isTableReadOnly() const;
182 
183  void setColumnReadOnly(int,bool);
184  bool isColumnReadOnly(int) const;
185  void setRowReadOnly(int,bool);
186  bool isRowReadOnly(int) const;
187 
188  void setCellReadOnly(const RowCol&,bool);
189  bool isCellReadOnly(const RowCol&) const;
190 
191  void hideColumn(int,bool);
192  void hideRow(int,bool);
193  bool isColumnHidden(int) const;
194  bool isRowHidden(int) const;
195 
196  bool isTopHeaderHidden() const;
197  bool isLeftHeaderHidden() const;
198  void setTopHeaderHidden(bool);
199  void setLeftHeaderHidden(bool);
200 
201  void insertRows(int row,int count);
202  inline void insertRows( const RowCol& rc, int count )
203  { insertRows( rc.row(), count ); }
204  void insertColumns(int col,int count);
205  inline void insertColumns( const RowCol& rc, int count )
206  { insertColumns( rc.col(), count ); }
207  void removeRow(int);
208  void removeRow( const RowCol& rc )
209  { removeRow( rc.row() ); }
210  void removeRows(const TypeSet<int>&);
211  void removeColumn(int);
212  void removeColumn( const RowCol& rc )
213  { removeColumn( rc.col() ); }
214  void removeColumns(const TypeSet<int>&);
215 
216  bool isSelected(const RowCol&) const;
217  bool isRowSelected(int) const;
218  bool isColumnSelected(int) const;
219  // next 3 return in selected order
220  bool getSelectedRows(TypeSet<int>&) const;
221  bool getSelectedCols(TypeSet<int>&) const;
222  bool getSelectedCells(TypeSet<RowCol>&) const;
223  int currentRow() const;
224  int currentCol() const;
226  { return RowCol( currentRow(), currentCol() ); }
227  void setSelected(const RowCol&,bool yn=true);
228  void selectRow(int row);
229  void selectColumn(int col);
230  void selectItems(const TypeSet<RowCol>&,bool);
231  void removeAllSelections();
232  void ensureCellVisible(const RowCol&);
233 
234  const char* rowLabel(int) const;
235  const char* rowLabel( const RowCol& rc ) const
236  { return rowLabel(rc.row()); }
237  void setRowLabel(int,const char*); // also sets tooltip
238  void setRowLabels(const char**);
239  void setRowLabels(const BufferStringSet&);
240  void setRowLabel( const RowCol& rc, const char* lbl )
241  { setRowLabel( rc.row(), lbl ); }
242  void setRowToolTip(int,const char*);
243  void setTopLeftCornerLabel(const uiString&);
244 
245  const char* columnLabel(int) const;
246  const char* columnLabel( const RowCol& rc ) const
247  { return columnLabel(rc.col()); }
248  void setColumnLabel(int,const uiString&); //also sets tooltip
249  void setColumnLabels(const char**);
250  void setColumnLabels(const BufferStringSet&);
251  void setColumnLabel( const RowCol& rc, const uiString& lbl )
252  { setColumnLabel( rc.col(), lbl ); }
253  void setColumnToolTip(int,const uiString&);
254 
255  void setCellToolTip(const RowCol&,const uiString&);
256 
257  void setDefaultRowLabels();
258  void setDefaultColLabels();
259  void setLabelAlignment(Alignment::HPos,bool cols);
260  void setLabelBGColor(int,Color,bool isrow);
261 
262 
263  Setup& setup() { return setup_; }
264  const Setup& setup() const { return setup_; }
265 
266  const RowCol& notifiedCell() const { return notifcell_; }
267  void setNotifiedCell(const RowCol& rc)
268  { notifcell_=rc; }
269  const TypeSet<int>& getNotifRCs() const
270  { return seliscols_ ? notifcols_ : notifrows_; }
271  const TypeSet<RowCol>& getNotifCells() const { return notifcells_; }
272 
278 
279  const RowCol& newCell() const { return newcell_; }
287 
288  void setPixmap(const RowCol&,const uiPixmap&);
289  void setColor(const RowCol&,const Color&);
290  Color getColor(const RowCol&) const;
291  void setHeaderBackground(int,const Color&,bool isrow);
292  Color getHeaderBackground(int,bool isrow) const;
293 
294  int getIntValue(const RowCol&) const;
295  double getDValue(const RowCol&) const;
296  float getFValue(const RowCol&) const;
297  void setValue(const RowCol&,int);
298  void setValue(const RowCol&,float);
299  void setValue(const RowCol&,float,int nrdec);
300  void setValue(const RowCol&,double);
301  void setValue(const RowCol&,double,int nrdec);
302 
303  void setSelectionMode(SelectionMode);
304  void setSelectionBehavior(SelectionBehavior);
305  void editCell(const RowCol&,bool replace=false);
306 
308  {
309  public:
311  : firstrow_(-1), lastrow_(-1)
312  , firstcol_(-1), lastcol_(-1) {}
313 
314  int nrRows() const { return lastrow_-firstrow_+1; }
315  int nrCols() const { return lastcol_-firstcol_+1; }
316 
318  int lastrow_;
319 
321  int lastcol_;
322  };
323 
324 
325  const ObjectSet<SelectionRange>& selectedRanges() const;
326 
327  SelectionBehavior getSelBehavior() const;
328  int maxNrOfSelections() const;
329 
330  bool handleLongTabletPress();
331  bool needOfVirtualKeyboard() const;
332  void popupVirtualKeyboard(int globalx=-1,int globaly=-1);
333 
334 protected:
335 
343 
344  mutable Setup setup_;
345 
346  virtual void popupMenu(CallBacker*);
348 
349  void geometrySet_(CallBacker*);
350  void updateCellSizes(const uiSize* sz=0);
351  void cellObjChangedCB(CallBacker*);
352 
353  bool getSelected();
354  void removeRCs(const TypeSet<int>&,bool col);
355  void update(bool row,int nr);
356 
358 
359 private:
360 
361  uiTableBody* body_;
362  uiTableBody& mkbody(uiParent*,const char*,int,int);
364 
365  mutable uiSize lastsz;
366 
367 public:
368  /*mDeprecated*/ double getdValue( const RowCol& rc ) const
369  { return getDValue( rc ); }
370  /*mDeprecated*/ float getfValue( const RowCol& rc ) const
371  { return getFValue( rc ); }
372 
373  void setPrefWidthInChars(int);
374 };
375 
376 #endif
Definition: uigroup.h:54
IdxType & row()
Definition: posidxpair.h:45
void removeColumn(const RowCol &rc)
Definition: uitable.h:212
#define mExpClass(module)
Definition: commondefs.h:160
uiTableBody * body_
Definition: uitable.h:361
Notifier< uiTable > rowInserted
Definition: uitable.h:280
To be able to send and/or receive CallBacks, inherit from this class.
Definition: callback.h:272
void insertColumns(const RowCol &rc, int count)
Definition: uitable.h:205
int lastcol_
Definition: uitable.h:321
TypeSet< RowCol > notifcells_
Definition: uitable.h:338
#define mODTextTranslationClass(clss)
Definition: uistring.h:38
Notifier< uiTable > rightClicked
Definition: uitable.h:275
void setRowLabel(const RowCol &rc, const char *lbl)
Definition: uitable.h:240
const RowCol & notifiedCell() const
Definition: uitable.h:266
double getdValue(const RowCol &rc) const
Definition: uitable.h:368
Definition: uitable.h:30
Notifier< uiTable > selectionDeleted
Definition: uitable.h:282
uiSize lastsz
Definition: uitable.h:365
The base class for most UI elements.
Definition: uiobj.h:38
CNotifier< uiTable, int > rowClicked
Definition: uitable.h:285
Definition: uistring.h:89
TypeSet< int > notifcols_
Definition: uitable.h:340
Definition: uiparent.h:26
Setup(int nrrows=-1, int nrcols=-1)
Definition: uitable.h:58
ResizeMode
Definition: uitable.h:49
Set of BufferString objects.
Definition: bufstringset.h:28
const RowCol & newCell() const
Definition: uitable.h:279
int firstrow_
Definition: uitable.h:317
void setNotifiedCell(const RowCol &rc)
Definition: uitable.h:267
Definition: uigeom.h:25
Set of pointers to objects.
Definition: commontypes.h:32
int nrCols() const
Definition: uitable.h:315
const char * rowLabel(const RowCol &rc) const
Definition: uitable.h:235
Notifier< uiTable > valueChanged
Definition: uitable.h:273
RowCol newcell_
Definition: uitable.h:342
ButtonState
Definition: keyenum.h:20
bool istablereadonly_
Definition: uitable.h:357
Notifier< uiTable > rowDeleted
Definition: uitable.h:281
OD::ButtonState buttonstate_
Definition: uitable.h:347
encapsulates the read-access-only part of strings in OD.
Definition: odstring.h:31
const char * columnLabel(const RowCol &rc) const
Definition: uitable.h:246
void insertRows(const RowCol &rc, int count)
Definition: uitable.h:202
HPos
Definition: draw.h:26
int lastrow_
Definition: uitable.h:318
Notifier< uiTable > colDeleted
Definition: uitable.h:284
Notifier< uiTable > colInserted
Definition: uitable.h:283
Helper class for uiTable to relay Qt&#39;s &#39;activated&#39; messages to uiAction.
Definition: i_qtable.h:31
#define mDefSetupMemb(typ, memb)
Definition: commondefs.h:137
CNotifier< uiTable, int > columnClicked
Definition: uitable.h:286
SelectionRange()
Definition: uitable.h:310
Definition: uitable.h:46
Off-screen pixel-based paint device.
Definition: uipixmap.h:34
uiLabel * cornerlabel_
Definition: uitable.h:363
const TypeSet< int > & getNotifRCs() const
Definition: uitable.h:269
Setup setup_
Definition: uitable.h:344
bool seliscols_
Definition: uitable.h:341
multiple ranges of cells.
Definition: uitable.h:40
No cell can be selected by the user.
Definition: uitable.h:38
IdxPair used for its row() and col().
Definition: rowcol.h:25
Setup & setup()
Definition: uitable.h:263
IdxType & col()
Definition: posidxpair.h:50
OD::String with its own variable length buffer. The buffer has a guaranteed minimum size...
Definition: bufstring.h:40
Notifier< uiTable > selectionChanged
Definition: uitable.h:277
int nrRows() const
Definition: uitable.h:314
const Setup & setup() const
Definition: uitable.h:264
Definition: uilabel.h:24
RowCol currentCell() const
Definition: uitable.h:225
float getfValue(const RowCol &rc) const
Definition: uitable.h:370
Notifier< uiTable > leftClicked
Definition: uitable.h:274
void removeRow(const RowCol &rc)
Definition: uitable.h:208
Definition: uitable.h:307
Color is an RGB color object, with a transparancy. The storage is in a 4-byte integer, similar to Qt.
Definition: color.h:26
int firstcol_
Definition: uitable.h:320
RowCol notifcell_
Definition: uitable.h:337
Definition: uitable.h:54
SelectionBehavior
Definition: uitable.h:44
a single range of cells.
Definition: uitable.h:39
TypeSet< int > notifrows_
Definition: uitable.h:339
SelectionMode
Definition: uitable.h:36
Definition: uitable.h:51
const TypeSet< RowCol > & getNotifCells() const
Definition: uitable.h:271
void setColumnLabel(const RowCol &rc, const uiString &lbl)
Definition: uitable.h:251
Notifier< uiTable > doubleClicked
Definition: uitable.h:276
ObjectSet< SelectionRange > selranges_
Definition: uitable.h:336

Generated at for the OpendTect seismic interpretation project. Copyright (C): dGB Beheer B. V. 2019