OpendTect  6.6
uilineedit.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: 21/9/2000
9  RCS: $Id$
10 ________________________________________________________________________
11 
12 -*/
13 
14 #include "uibasemod.h"
15 #include "uiobj.h"
16 #include "userinputobj.h"
17 
18 #include "bufstringset.h"
19 
20 class uiLineEditBody;
21 
22 #define mDefTextValidator "^[^'!'].+$"
23 #define mTextVlAllCharsAccepted "^.+$"
24 
26 {
27 public:
29  : bottom_(-mUdf(int)), top_(mUdf(int)) {}
30  uiIntValidator( int bot, int top )
31  : bottom_(bot), top_(top) {}
32 
33  int bottom_;
34  int top_;
35 };
36 
37 
39 {
40 public:
42  : bottom_(-mUdf(float)), top_(mUdf(float))
43  , nrdecimals_(1000), scnotation_(true) {}
44  uiFloatValidator( float bot, float top )
45  : bottom_(bot), top_(top)
46  , nrdecimals_(1000), scnotation_(true) {}
47 
48  float bottom_;
49  float top_;
51  bool scnotation_; // If true, ScientificNotation is used
52 };
53 
54 
56 {
57 public:
59  : leastnrocc_(mUdf(int))
60  , maxnrocc_(mUdf(int))
61  , excludfirstocconly_(true)
62  {
63  regexchars_.setEmpty();
64  }
65  uiTextValidator(const BufferStringSet& regexchars,
66  const int leastnrocc=mUdf(int),
67  const int maxnrocc=mUdf(int),
68  bool excludfirstocconly=true)
69  : regexchars_(regexchars)
70  , leastnrocc_(leastnrocc)
71  , maxnrocc_(maxnrocc)
72  , excludfirstocconly_(excludfirstocconly)
73  {}
75  : regexchars_(textvl.regexchars_)
76  , leastnrocc_(textvl.leastnrocc_)
77  , maxnrocc_(textvl.maxnrocc_)
78  , excludfirstocconly_(textvl.excludfirstocconly_)
79  {}
80 
83  int maxnrocc_;
85 
87 };
88 
89 
90 #define mUseDefaultTextValidatorOnField(fld) \
91  BufferStringSet regchars; \
92  regchars.add( "!" ); \
93  uiTextValidator txtvl( regchars ); \
94  fld->setTextValidator( txtvl ); \
95 
96 
97 
99  public uiObject
100 {
101 public:
103  // insted of undefined value, when line edit is empty.
104  uiLineEdit(uiParent*,const char* nm);
105  uiLineEdit(uiParent*,const DataInpSpec&,const char* nm);
106 
107  void setEdited(bool=true);
108  bool isEdited() const;
109 
111  bool casesensitive=false);
113 
114  virtual void setReadOnly(bool=true);
115  virtual bool isReadOnly() const;
116  virtual bool update_(const DataInpSpec&);
117 
122 
123  void setMaxLength(int);
124  int maxLength() const;
125  void setNrDecimals( int nrdec ) { nrdecimals_ = nrdec; }
126 
128  void home();
130  void end();
131 
132  void backspace();
133  void del();
134  void cursorBackward(bool mark,int steps=1);
135  void cursorForward(bool mark,int steps=1);
136  int cursorPosition() const;
137  void insert( const char* );
138 
139  int selectionStart() const;
140  const char* selectedText() const;
141  void setSelection(int start,int length);
142 
144  void popupVirtualKeyboard(int globalx=-1,int globaly=-1);
145 
150 
151 
152  virtual const char* getvalue_() const;
153  virtual void setvalue_( const char* );
154 
155  void setToolTip( const uiString& tt )
156  { uiObject::setToolTip(tt); }
157 
158 protected:
159 
160  virtual bool notifyValueChanging_( const CallBack& cb )
161  { textChanged.notify( cb ); return true;}
162  virtual bool notifyValueChanged_( const CallBack& cb )
163  { editingFinished.notify( cb ); return true;}
164  virtual bool notifyUpdateRequested_( const CallBack& cb )
165  { returnPressed.notify( cb ); return true; }
166 
167 private:
168 
169  uiLineEditBody* body_;
170  uiLineEditBody& mkbody(uiParent*, const char*);
171 
174 
175 public:
176  mDeprecated ("Use uiString")
177  void setToolTip( const char* tt )
179 
180 };
181 
uiIntValidator::uiIntValidator
uiIntValidator()
Definition: uilineedit.h:28
uiLineEdit::insert
void insert(const char *)
uiLineEdit::setPasswordMode
void setPasswordMode()
uiLineEdit::notifyValueChanged_
virtual bool notifyValueChanged_(const CallBack &cb)
return false if not available
Definition: uilineedit.h:162
uiLineEdit
Definition: uilineedit.h:100
uiLineEdit::setSelection
void setSelection(int start, int length)
uiTextValidator::leastnrocc_
int leastnrocc_
Definition: uilineedit.h:82
uiIntValidator::bottom_
int bottom_
Definition: uilineedit.h:33
BufferStringSet
Set of BufferString objects.
Definition: bufstringset.h:26
File::toUiString
Export_Basic uiString toUiString(ViewStyle)
uiLineEdit::selectedText
const char * selectedText() const
uiLineEdit::setCompleter
void setCompleter(const BufferStringSet &bs, bool casesensitive=false)
uiLineEdit::setNrDecimals
void setNrDecimals(int nrdec)
Definition: uilineedit.h:125
uiLineEdit::selectionChanged
Notifier< uiLineEdit > selectionChanged
Definition: uilineedit.h:149
uiTextValidator::uiTextValidator
uiTextValidator(const BufferStringSet &regexchars, const int leastnrocc=mUdf(int), const int maxnrocc=mUdf(int), bool excludfirstocconly=true)
Definition: uilineedit.h:65
uiLineEdit::selectionStart
int selectionStart() const
mExpClass
#define mExpClass(module)
Definition: commondefs.h:177
uiLineEdit::setToolTip
void setToolTip(const uiString &tt)
Definition: uilineedit.h:155
uiLineEdit::popupVirtualKeyboard
void popupVirtualKeyboard(int globalx=-1, int globaly=-1)
uiObject::setToolTip
void setToolTip(const uiString &)
uiLineEdit::result_
BufferString result_
Definition: uilineedit.h:172
uiLineEdit::nrdecimals_
int nrdecimals_
Definition: uilineedit.h:173
UserInputObjImpl< const char * >
uiFloatValidator::nrdecimals_
int nrdecimals_
Definition: uilineedit.h:50
uiLineEdit::mDeprecated
mDeprecated("Use uiString") void setToolTip(const char *tt)
Definition: uilineedit.h:176
uiLineEdit::textChanged
Notifier< uiLineEdit > textChanged
Definition: uilineedit.h:148
uiLineEdit::update_
virtual bool update_(const DataInpSpec &)
uiTextValidator::uiTextValidator
uiTextValidator(const uiTextValidator &textvl)
Definition: uilineedit.h:74
uiFloatValidator
Definition: uilineedit.h:39
uiIntValidator
Definition: uilineedit.h:26
uiLineEdit::body_
uiLineEditBody * body_
Definition: uilineedit.h:169
uiLineEdit::editingFinished
Notifier< uiLineEdit > editingFinished
Definition: uilineedit.h:146
uiLineEdit::end
void end()
Moves the text cursor to the end of the line.
uiFloatValidator::uiFloatValidator
uiFloatValidator(float bot, float top)
Definition: uilineedit.h:44
uiLineEdit::uiLineEdit
uiLineEdit(uiParent *, const DataInpSpec &, const char *nm)
uiFloatValidator::uiFloatValidator
uiFloatValidator()
Definition: uilineedit.h:41
CallBack
CallBacks object-oriented (object + method).
Definition: callback.h:62
uiLineEdit::returnPressed
Notifier< uiLineEdit > returnPressed
Definition: uilineedit.h:147
uiFloatValidator::top_
float top_
Definition: uilineedit.h:49
uiLineEdit::maxLength
int maxLength() const
uiLineEdit::uiLineEdit
uiLineEdit(uiParent *, const char *nm)
pref_empty : return empty string/ null value
uiLineEdit::setEdited
void setEdited(bool=true)
Notifier< uiLineEdit >
DataInpSpec
Specification of input characteristics.
Definition: datainpspec.h:90
uiLineEdit::notifyValueChanging_
virtual bool notifyValueChanging_(const CallBack &cb)
return false if not available
Definition: uilineedit.h:160
uiLineEdit::mkbody
uiLineEditBody & mkbody(uiParent *, const char *)
uiLineEdit::setTextValidator
void setTextValidator(const uiTextValidator &)
uiIntValidator::top_
int top_
Definition: uilineedit.h:34
userinputobj.h
uiTextValidator::excludfirstocconly_
bool excludfirstocconly_
Definition: uilineedit.h:84
uiTextValidator::getRegExString
BufferString getRegExString() const
BufferString
OD::String with its own variable length buffer. The buffer has a guaranteed minimum size.
Definition: bufstring.h:40
uiLineEdit::cursorForward
void cursorForward(bool mark, int steps=1)
uiLineEdit::getvalue_
virtual const char * getvalue_() const
uiLineEdit::setMaxLength
void setMaxLength(int)
bufstringset.h
uiLineEdit::isReadOnly
virtual bool isReadOnly() const
uiObject
The base class for most UI elements.
Definition: uiobj.h:38
uiFloatValidator::scnotation_
bool scnotation_
Definition: uilineedit.h:51
uiLineEdit::setvalue_
virtual void setvalue_(const char *)
uiLineEdit::setReadOnly
virtual void setReadOnly(bool=true)
uiString
String that is able to hold international (UTF-8) strings for the user interface.
Definition: uistring.h:121
uiLineEdit::cursorPosition
int cursorPosition() const
mUdf
#define mUdf(type)
Use this macro to get the undefined for simple types.
Definition: undefval.h:274
uiIntValidator::uiIntValidator
uiIntValidator(int bot, int top)
Definition: uilineedit.h:30
uiLineEdit::backspace
void backspace()
uiParent
Definition: uiparent.h:26
uiTextValidator::regexchars_
BufferStringSet regexchars_
Definition: uilineedit.h:81
uiLineEdit::setValidator
void setValidator(const uiFloatValidator &)
uiTextValidator::uiTextValidator
uiTextValidator()
Definition: uilineedit.h:58
uiLineEdit::setValidator
void setValidator(const uiIntValidator &)
uiLineEdit::setPlaceholderText
void setPlaceholderText(const uiString &)
uiLineEdit::isEdited
bool isEdited() const
NotifierAccess::notify
void notify(const CallBack &, bool first=false) const
uiFloatValidator::bottom_
float bottom_
Definition: uilineedit.h:48
uiTextValidator::maxnrocc_
int maxnrocc_
Definition: uilineedit.h:83
uiLineEdit::notifyUpdateRequested_
virtual bool notifyUpdateRequested_(const CallBack &cb)
Definition: uilineedit.h:164
uiLineEdit::home
void home()
Moves the text cursor to the beginning of the line.
uiTextValidator
Definition: uilineedit.h:56
uiobj.h
uiLineEdit::cursorBackward
void cursorBackward(bool mark, int steps=1)
uiLineEdit::handleLongTabletPress
bool handleLongTabletPress()
uiLineEdit::del
void del()

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