OpendTect-6_4  6.4
uilistbox.h
Go to the documentation of this file.
1 #ifndef uilistbox_h
2 #define uilistbox_h
3 
4 /*+
5 ________________________________________________________________________
6 
7  (C) dGB Beheer B.V.; (LICENSE) http://opendtect.org/OpendTect_license.txt
8  Author: Nanne Hemstra
9  Date: 16/05/2000
10  RCS: $Id$
11 ________________________________________________________________________
12 
13 -*/
14 
15 #include "uibasemod.h"
16 #include "uigroup.h"
17 #include "uistrings.h"
18 #include "keyenum.h"
19 #include "draw.h"
20 
21 class BufferStringSet;
22 class uiCheckBox;
23 class uiLabel;
24 class uiListBoxBody;
25 class uiMenu;
26 class uiString;
27 
28 mFDQtclass(QListWidgetItem)
29 
30 
31 
32 
60 mExpClass(uiBase) uiListBoxObj : public uiObject
61 {
62 public:
63  uiListBoxObj(uiParent*,const char* nm,OD::ChoiceMode);
64  ~uiListBoxObj();
65 
66  uiListBoxBody& body() { return *body_; }
67 
68 private:
69  uiListBoxBody* body_;
70  uiListBoxBody& mkbody(uiParent*,const char*,OD::ChoiceMode);
71 };
72 
73 
74 
75 mExpClass(uiBase) uiListBox : public uiGroup
77 friend class i_listMessenger;
78 friend class uiListBoxBody;
79 public:
80  enum LblPos { LeftTop, RightTop, LeftMid, RightMid,
81  AboveLeft, AboveMid, AboveRight,
82  BelowLeft, BelowMid, BelowRight };
83 
84  mExpClass(uiBase) Setup
85  {
86  public:
90  : lbl_(l)
91  , cm_(icm)
92  , prefnrlines_(0)
93  , prefwidth_(0)
94  , lblpos_(lp)
95  {}
96 
99  mDefSetupMemb(int,prefnrlines)
100  mDefSetupMemb(int,prefwidth)
102 
103  };
104 
105  uiListBox(uiParent*,const char* nm=0,
107  uiListBox(uiParent*,const Setup&,const char* nm=0);
108  virtual ~uiListBox();
109 
110  uiListBoxObj* box() { return lb_; }
111  uiGroup* checkGroup() { return checkgrp_; }
112  uiCheckBox* masterCheckBox() { return cb_; }
113  int nrLabels() const { return lbls_.size(); }
114  uiLabel* label( int nr=0 ) { return lbls_[nr]; }
115  void setLabelText(const uiString&,int nr=0);
116 
117  inline OD::ChoiceMode choiceMode() const { return choicemode_; }
118  inline bool isMultiChoice() const
119  { return ::isMultiChoice(choicemode_); }
120  void setChoiceMode(OD::ChoiceMode);
121  void setMultiChoice(bool yn=true);
122  void setAllowNoneChosen(bool);
123  void setNotSelectable();
124 
125  int size() const;
126  inline bool isEmpty() const { return size() == 0; }
127  bool validIdx(int) const;
128  bool isPresent(const char*) const;
129  int maxNrOfChoices() const;
130 
131  Alignment::HPos alignment() const { return alignment_; }
132  void setAlignment(Alignment::HPos);
133  void setNrLines(int);
134  void setFieldWidth(int);
135  void setHSzPol(uiObject::SzPolicy);
136  void setVSzPol(uiObject::SzPolicy);
137 
138  void setEmpty();
139  void removeItem(int);
140  void removeItem(const char*);
141  void removeItem( const FixedString& fs )
142  { removeItem( fs.str() ); }
143  void setAllowDuplicates(bool yn);
144  void addItem(const uiString&,bool marked=false,int id=-1);
145  void addItem(const uiString&,const uiPixmap&,int id=-1);
146  void addItem(const uiString&,const Color&,int id=-1);
147  void addItems(const char**);
148  void addItems(const BufferStringSet&);
149  void addItems(const uiStringSet&);
150  void insertItem(const uiString&,int idx=-1,
151  bool marked=false,int id=-1);
152  void insertItem(const uiString&,const uiPixmap&,
153  int idx=-1,int id=-1);
154  void insertItem(const uiString&,const Color&,
155  int idx=-1,int id=-1);
156  void setPixmap(int,const Color&);
157  void setPixmap(int,const uiPixmap&);
158  void setIcon(int,const char* icon_identifier);
159  void setColor(int,const Color&);
160  Color getColor(int) const;
161 
162  void sortItems(bool asc=true);
163 
164  int indexOf(const char*) const;
165  const char* textOfItem(int) const;
166  void setItemText(int,const uiString&);
167  void getItems(BufferStringSet&) const;
168 
169  int currentItem() const;
170  const char* getText() const { return textOfItem(currentItem()); }
171  void setCurrentItem(int);
172  void setCurrentItem(const char*);
173  void setCurrentItem( const FixedString& fs )
174  { setCurrentItem( fs.str() ); }
175  void setItemSelectable(int,bool);
176 
177  int nrChosen() const;
178  bool isChoosable(int) const;
179  bool isChosen(int) const;
180  int firstChosen() const;
181  int nextChosen(int prev=-1) const;
182  void getChosen(BufferStringSet&) const;
183  void getChosen(TypeSet<int>&) const;
184  void setChoosable(int,bool yn);
185  void setChosen(int,bool yn=true);
186  void setChosen(Interval<int>,bool yn=true);
187  void chooseAll(bool yn=true);
188  void setChosen(const BufferStringSet&);
189  void setChosen(const TypeSet<int>&);
190 
191  bool isMarked(int) const;
192  void setMarked(int,bool);
193 
194  void setItemID(int idx,int id);
195  int currentItemID() const;
196  int getItemID(int idx) const;
197  int getItemIdx(int id) const;
198 
199  void scrollToTop();
200  void scrollToBottom();
201  bool handleLongTabletPress();
202  void disableRightClick(bool yn);
203  void blockScrolling(bool yn) { scrollingblocked_ = yn; }
204 
206  CNotifier<uiListBox,int> itemChosen; /*< if itmidx==-1, many items were
207  chosen at once */
212 
214  const CallBack& wcb )
215  { retrievecb_ = rcb; savecb_ = wcb; }
216 
217 private:
218 
219  void translateText();
220 
230 
231  void menuCB(CallBacker*);
232  void handleCheckChange(mQtclass(QListWidgetItem*));
233  void usrChooseAll(bool yn=true);
234 
235  bool isNone() const { return choicemode_ == OD::ChooseNone;}
236  int optimumFieldWidth(int minwdth=20,int maxwdth=40) const;
237  static int cDefNrLines();
238 
239  void updateFields2ChoiceMode();
240  void initNewItem(int);
241  void setItemCheckable(int,bool);
242 
243  void setItemsCheckable( bool yn ) { setMultiChoice(yn); }
244  void setAllItemsChecked(bool);
245  void setItemChecked(int,bool);
246  void setItemChecked(const char*,bool);
247  bool isItemChecked(const char*) const;
248  int nrChecked() const;
249  void setCheckedItems(const BufferStringSet&);
250  void setCheckedItems(const TypeSet<int>&);
251  void getCheckedItems(BufferStringSet&) const;
252  void getCheckedItems(TypeSet<int>&) const;
253 
254 protected:
255  uiListBoxObj* lb_;
257  uiGroup* checkgrp_;
259 
260  void mkLabel(const uiString&,LblPos);
261  void mkCheckGroup();
262  void checkCB(CallBacker*);
263  void updateCheckState();
264  void addItemNoUpdate(const uiString&,bool marked=false,
265  int id=-1);
266 
267 public:
269  bool isItemChecked(int) const;
270 
271 // Deprecated. Don't use in new code
273  const char* nm=0);
275  const char* nm,OD::ChoiceMode cm,
276  int prefNrLines=0,int prefFieldWidth=0);
278  const char* nm,OD::ChoiceMode cm,
279  int prefNrLines=0,int prefFieldWidth=0);
280 };
281 
282 
287 {
288 public:
289 
290  enum LblPos { LeftTop, RightTop, LeftMid, RightMid,
291  AboveLeft, AboveMid, AboveRight,
292  BelowLeft, BelowMid, BelowRight };
293 
294  uiLabeledListBox(uiParent*,const uiString& lbltxt);
295  uiLabeledListBox(uiParent*,const uiString& lbltxt,
296  OD::ChoiceMode,LblPos p=LeftMid);
298  const uiString& lbltxt,
299  OD::ChoiceMode,LblPos p=LeftMid);
300 
301  uiListBox* box() { return this; }
302 
303 protected:
304 
305 };
306 
307 
308 #endif
void blockScrolling(bool yn)
Definition: uilistbox.h:203
Definition: uigroup.h:54
#define mExpClass(module)
Definition: commondefs.h:160
To be able to send and/or receive CallBacks, inherit from this class.
Definition: callback.h:272
ChoiceMode
What to choose from any list-type UI object.
Definition: oduicommon.h:42
BufferString rettxt_
Definition: uilistbox.h:225
Definition: uilistbox.h:84
const char * str() const
Definition: odstring.h:48
#define mQtclass(cls)
Definition: commondefs.h:229
bool isNone() const
Definition: uilistbox.h:235
#define mODTextTranslationClass(clss)
Definition: uistring.h:38
bool scrollingblocked_
Definition: uilistbox.h:229
Definition: uilistbox.h:290
OD::String that holds an existing text string.
Definition: fixedstring.h:29
Definition: uilistbox.h:291
Definition: oduicommon.h:45
Definition: uilistbox.h:81
Definition: uilistbox.h:80
LblPos
Definition: uilistbox.h:80
ObjectSet< uiLabel > lbls_
Definition: uilistbox.h:256
The base class for most UI elements.
Definition: uiobj.h:38
uiGroup * checkgrp_
Definition: uilistbox.h:257
CallBack savecb_
Definition: uilistbox.h:227
Definition: uistring.h:89
Definition: uiparent.h:26
Set of BufferString objects.
Definition: bufstringset.h:28
ObjectSet< T >::size_type indexOf(const ObjectSet< T > &os, const S &val)
Locate object in set.
Definition: objectset.h:169
Definition: uilistbox.h:80
uiCheckBox * cb_
Definition: uilistbox.h:258
bool allowduplicates_
Definition: uilistbox.h:223
List Box.
Definition: uilistbox.h:75
Notifier< uiListBox > rightButtonClicked
Definition: uilistbox.h:209
OD::ChoiceMode choiceMode() const
Definition: uilistbox.h:117
ButtonState
Definition: keyenum.h:20
SzPolicy
How should the object&#39;s size behave? Undef : use default. Small : 1 base sz. Medium : 2* base sz + 1...
Definition: uiobj.h:58
uiLabeledListBox. Deprecated. Don&#39;t use in new code
Definition: uilistbox.h:286
OD::ChoiceMode choicemode_
Definition: uilistbox.h:221
uiMenu & rightclickmnu_
Definition: uilistbox.h:224
uiListBoxObj * box()
Definition: uilistbox.h:110
int nrLabels() const
Definition: uilistbox.h:113
CNotifier< uiListBox, int > itemChosen
Definition: uilistbox.h:206
HPos
Definition: draw.h:26
#define mDefSetupMemb(typ, memb)
Definition: commondefs.h:137
#define mFDQtclass(cls)
Definition: commondefs.h:228
Definition: uimenu.h:65
Notifier< uiListBox > deleteButtonPressed
Definition: uilistbox.h:211
Off-screen pixel-based paint device.
Definition: uipixmap.h:34
OD::ButtonState buttonstate_
Definition: uilistbox.h:226
Definition: oduicommon.h:44
bool isMultiChoice() const
Definition: uilistbox.h:118
Notifier< uiListBox > leftButtonClicked
Definition: uilistbox.h:210
OD::String with its own variable length buffer. The buffer has a guaranteed minimum size...
Definition: bufstring.h:40
uiLabel * label(int nr=0)
Definition: uilistbox.h:114
void setCurrentItem(const FixedString &fs)
Definition: uilistbox.h:173
bool isEmpty() const
Definition: uilistbox.h:126
Definition: uilabel.h:24
uiCheckBox * masterCheckBox()
Definition: uilistbox.h:112
Notifier< uiListBox > selectionChanged
Definition: uilistbox.h:205
void setItemsCheckable(bool yn)
Definition: uilistbox.h:243
const char * getText() const
Definition: uilistbox.h:170
uiGroup * checkGroup()
Definition: uilistbox.h:111
Alignment::HPos alignment() const
Definition: uilistbox.h:131
Color is an RGB color object, with a transparancy. The storage is in a 4-byte integer, similar to Qt.
Definition: color.h:26
Alignment::HPos alignment_
Definition: uilistbox.h:222
Definition: uistring.h:218
static uiString sEmptyString()
Definition: uistrings.h:286
void offerReadWriteSelection(const CallBack &rcb, const CallBack &wcb)
Definition: uilistbox.h:213
bool isMultiChoice(OD::ChoiceMode cm)
Definition: oduicommon.h:90
uiListBox * box()
Definition: uilistbox.h:301
CallBacks object-oriented (object + method).
Definition: callback.h:57
Setup(OD::ChoiceMode icm=OD::ChooseOnlyOne, const uiString &l=uiStrings::sEmptyString(), uiListBox::LblPos lp=uiListBox::LeftTop)
Definition: uilistbox.h:87
Definition: uibutton.h:134
Notifier< uiListBox > doubleClicked
Definition: uilistbox.h:208
Helper class for uiListBox to relay Qt&#39;s messages.
Definition: i_qlistbox.h:27
void removeItem(const FixedString &fs)
Definition: uilistbox.h:141
CallBack retrievecb_
Definition: uilistbox.h:228
uiListBoxObj * lb_
Definition: uilistbox.h:255

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