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

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