OpendTect-6_4  6.4
uigeninput_impl.h
Go to the documentation of this file.
1 #ifndef uigeninput_impl_h
2 #define uigeninput_impl_h
3 
4 /*+
5 ________________________________________________________________________
6 
7  (C) dGB Beheer B.V.; (LICENSE) http://opendtect.org/OpendTect_license.txt
8  Author: A.H. Lammertink / Bert
9  Date: 21/2/2002 / Sep 2011
10  RCS: $Id$
11 ________________________________________________________________________
12 
13 -*/
14 
15 #include "uigroup.h"
16 #include "uispinbox.h"
17 #include "userinputobj.h"
18 
19 class uiCheckBox;
20 class uiRadioButton;
21 
33 {
34 public:
36  virtual ~uiGenInputInputFld();
37  virtual int nElems() const { return 1; }
38 
39  virtual UserInputObj* element( int idx=0 ) = 0;
40  const UserInputObj* element(int idx=0) const;
41  virtual uiObject* mainObj() = 0;
42  virtual uiObject* elemObj(int idx=0);
43  const uiObject* elemObj(int idx=0) const;
44 
45  virtual bool isUndef(int) const;
46  const char* text(int) const;
47  int getIntValue(int) const;
48  float getFValue(int) const;
49  double getDValue(int) const;
50  bool getBoolValue(int) const;
51 
52  template <class T>
53  void setValue( T t, int idx )
54  {
55  UserInputObj* obj = element( idx );
56  if ( !obj )
57  {
59  if ( sb ) sb->setValue( t );
60  return;
61  }
62 
63  if ( mIsUdf(t) )
64  obj->setEmpty();
65  else
66  obj->setValue(t);
67  }
68 
69  virtual void setText(const char*,int);
70  void setValue(bool,int);
71 
72  void setEmpty();
73  void display(bool,int elemidx);
74  bool isReadOnly(int idx=0) const;
75  virtual void setReadOnly(bool yn=true,int idx=-1);
76  void setSensitive(bool yn,int elemidx=-1);
77 
78  DataInpSpec& spec() { return spec_; }
79  const DataInpSpec& spec() const { return spec_; }
80 
81  bool update(const DataInpSpec&);
82  virtual void updateSpec();
83 
87 
88 protected:
89 
92 
93  virtual bool update_(const DataInpSpec&);
94  void init();
95 
96 };
97 
98 
99 class uiGenInputBoolFld : public UserInputObjImpl<bool>, public uiGroup
101 public:
102 
104  const uiString& truetext=uiStrings::
105  sEmptyString(),
106  const uiString& falsetext=uiStrings::
107  sEmptyString(),
108  bool initval = true,
109  const char* nm="Bool Input");
110 
112  const DataInpSpec& spec,
113  const char* nm="Bool Input");
114 
115  virtual const char* text() const;
116  virtual void setText(const char* t);
117 
118  bool notifyValueChanged( const CallBack& cb )
119  { valueChanged.notify(cb); return true; }
120 
122 
123  virtual void setReadOnly(bool ro=true);
124  virtual bool isReadOnly() const;
125 
126  virtual bool update_(const DataInpSpec& spec);
127 
128  virtual void setToolTip(const uiString&);
129 
130 protected:
131 
132  void init(uiParent*,const uiString&,const uiString&,bool);
133 
134  virtual bool getvalue_() const { return yn_; }
135  virtual void setvalue_( bool );
136 
137  virtual bool notifyValueChanging_( const CallBack& ) { return false;}
138  virtual bool notifyValueChanged_( const CallBack& cb )
139  { valueChanged.notify(cb); return true; }
140  virtual bool notifyUpdateRequested_(const CallBack&) { return false;}
141 
142  void selected(CallBacker*);
143 
144  virtual uiObject* mainobject();
145 
148  bool yn_;
153 };
154 
155 
156 class uiGenInputIntFld : public UserInputObjImpl<int>, public uiSpinBox
157 {
158 public:
159  uiGenInputIntFld(uiParent*,int val=0,
160  const char* nm="Int Input");
162  const char* nm="Int Input");
163  virtual void setReadOnly(bool);
164  virtual bool isReadOnly() const;
165 
166  virtual bool update_(const DataInpSpec&);
167  virtual void setToolTip(const uiString&);
168 
169 protected:
170 
171  virtual int getvalue_() const;
172  virtual void setvalue_(int);
173 
174  virtual bool notifyValueChanging_(const CallBack&);
175  virtual bool notifyValueChanged_(const CallBack&);
176  virtual bool notifyUpdateRequested_(const CallBack&);
177 };
178 
179 #endif
Definition: uigeninput_impl.h:99
Definition: uigroup.h:54
#define mIsUdf(val)
Use mIsUdf to check for undefinedness of simple types.
Definition: undefval.h:287
To be able to send and/or receive CallBacks, inherit from this class.
Definition: callback.h:272
bool isReadOnly(int idx=0) const
DataInpSpec & spec_
Definition: uigeninput_impl.h:90
void setSensitive(bool yn, int elemidx=-1)
virtual uiObject * elemObj(int idx=0)
virtual ~uiGenInputInputFld()
virtual void setReadOnly(bool yn=true, int idx=-1)
float getFValue(int) const
#define mODTextTranslationClass(clss)
Definition: uistring.h:38
virtual bool notifyUpdateRequested_(const CallBack &)
Definition: uigeninput_impl.h:140
virtual UserInputObj * element(int idx=0)=0
Definition: uistrings.h:24
virtual bool update_(const DataInpSpec &)
The base class for most UI elements.
Definition: uiobj.h:38
bool yn_
Definition: uigeninput_impl.h:148
Definition: uistring.h:89
Definition: uiparent.h:26
virtual void updateSpec()
uiObject * butgrp_
Definition: uigeninput_impl.h:149
bool update(const DataInpSpec &)
DataInpSpec & spec()
Definition: uigeninput_impl.h:78
Specification of input characteristics.
Definition: datainpspec.h:89
void setValue(T t, int idx)
Definition: uigeninput_impl.h:53
bool notifyValueChanged(const CallBack &cb)
Definition: uigeninput_impl.h:118
uiRadioButton * rb1_
Definition: uigeninput_impl.h:151
General Input Element.
Definition: uigeninput.h:58
virtual uiObject * mainObj()=0
void notify(const CallBack &, bool first=false)
const char * text(int) const
virtual void setValue(const char *s)
void updateReqNotify(CallBacker *)
Definition: uigeninput_impl.h:156
Definition: uispinbox.h:24
#define mDynamicCastGet(typ, out, in)
Definition: commondefs.h:131
virtual void setEmpty()=0
const DataInpSpec & spec() const
Definition: uigeninput_impl.h:79
void valChangedNotify(CallBacker *)
Definition: uibutton.h:114
uiGenInput * p_
Definition: uigeninput_impl.h:91
virtual bool notifyValueChanging_(const CallBack &)
return false if not available
Definition: uigeninput_impl.h:137
double getDValue(int) const
void valChangingNotify(CallBacker *)
bool getBoolValue(int) const
virtual bool notifyValueChanged_(const CallBack &cb)
return false if not available
Definition: uigeninput_impl.h:138
uiString falsetxt_
Definition: uigeninput_impl.h:147
virtual int nElems() const
Definition: uigeninput_impl.h:37
virtual void setText(const char *, int)
void display(bool, int elemidx)
uiRadioButton * rb2_
Definition: uigeninput_impl.h:152
uiCheckBox * checkbox_
Definition: uigeninput_impl.h:150
Definition: userinputobj.h:25
int getIntValue(int) const
Generalised data input field.
Definition: uigeninput_impl.h:32
CallBacks object-oriented (object + method).
Definition: callback.h:57
uiGenInputInputFld(uiGenInput *, const DataInpSpec &)
Definition: uibutton.h:134
Notifier< uiGenInputBoolFld > valueChanged
Definition: uigeninput_impl.h:121
virtual bool isUndef(int) const
Definition: userinputobj.h:83
uiString truetxt_
Definition: uigeninput_impl.h:146
virtual bool getvalue_() const
Definition: uigeninput_impl.h:134

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