OpendTect-6_4  6.4
uitextedit.h
Go to the documentation of this file.
1 #ifndef uitextedit_h
2 #define uitextedit_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: 09/02/2001
10  RCS: $Id$
11 ________________________________________________________________________
12 
13 -*/
14 
15 #include "uibasemod.h"
16 #include "uiobj.h"
17 #include "undefval.h"
18 
19 class uiTextEditBody;
20 class uiTextBrowserBody;
21 mFDQtclass(QTextEdit)
22 class Timer;
24 
26 {
27 public:
28  void readFromFile(const char*,int linecutlen=0);
29  bool saveToFile(const char*,int linelen=0,bool newlns=true);
30 
31  const char* text() const;
32  int nrLines() const;
33  bool verticalSliderIsDown() const;
35 
36  int defaultWidth() { return defaultwidth_; }
37  void setDefaultWidth( int w ) { defaultwidth_ = w; }
38 
39  int defaultHeight() { return defaultheight_; }
40  void setDefaultHeight( int h ) { defaultheight_ = h; }
41 
42  bool isModified() const;
43  void allowTextSelection(bool);
44 
45  void hideFrame();
46  void hideScrollBar(bool vertical);
47  void scrollToBottom();
48 
53 
54 protected:
55  uiTextEditBase(uiParent*,const char*,uiObjectBody&);
56 
57  virtual mQtclass(QTextEdit&) qte() = 0;
58  const mQtclass(QTextEdit&) qte() const
59  { return const_cast<uiTextEditBase*>(this)->qte(); }
60 
63  virtual int maxLines() const { return -1; }
64 
66 
67 private:
68 
69  friend class ScrollBarMessenger;
70 };
71 
72 
73 
75 {
76 public:
77  uiTextEdit(uiParent* parnt,const char* nm="Text editor",
78  bool readonly=false);
79 
80  void setText(const char* txt) { setText( txt, false ); }
82  void setText(const OD::String& txt);
84  void setText(const uiString&);
87  void setText(const char*,bool trigger_notif);
88  void append(const char*);
89 
90 protected:
91 
92  virtual mQtclass(QTextEdit&) qte();
93 
94 private:
95 
96  uiTextEditBody* body_;
97  uiTextEditBody& mkbody(uiParent*,const char*,bool);
98 };
99 
100 
101 
104 friend class i_BrowserMessenger;
105 public:
106 
107  uiTextBrowser(uiParent*,const char* nm="File browser",
108  int maxlns=mUdf(int),
109  bool forceplaintext=true,
110  bool logmode=false);
111  ~uiTextBrowser();
112 
113  void setText(const char*);
114  void setHtmlText(const char*);
115  void getHtmlText(BufferString&) const;
116  const char* source() const;
117  void setSource(const char*);
118  void setMaxLines(int);
119 
120  enum LinkBehavior { None, FollowLocal, FollowAll };
121  void setLinkBehavior( LinkBehavior );
122 
123  void backward();
124  void forward();
125  void home();
126  void reload();
127  void showToolTip(const char*);
128  void recordScrollPos();
129  void restoreScrollPos();
130 
131  bool canGoForward() { return cangoforw_; }
132  bool canGoBackward() { return cangobackw_; }
133  const char* lastLink() { return lastlink_; }
134 
139 
140 protected:
141 
148 
149  virtual int maxLines() const { return maxlines_; }
150 
151  virtual mQtclass(QTextEdit&) qte();
152 
153  void readTailCB(CallBacker*);
154  void sliderPressedCB(CallBacker*);
155  void sliderReleasedCB(CallBacker*);
156  void copyAvailableCB(CallBacker*);
157  void enableTailRead(bool yn);
158 
163 
164 private:
165 
167  uiTextBrowserBody& mkbody(uiParent*,const char*,bool);
168 };
169 
170 #endif
#define mExpClass(module)
Definition: commondefs.h:160
To be able to send and/or receive CallBacks, inherit from this class.
Definition: callback.h:272
Definition: uitextedit.h:74
BufferString textsrc_
Definition: uitextedit.h:142
virtual int maxLines() const
Definition: uitextedit.h:63
Notifier< uiTextEditBase > textChanged
Definition: uitextedit.h:49
#define mQtclass(cls)
Definition: commondefs.h:229
void setText(const char *txt)
Does not trigger notification.
Definition: uitextedit.h:80
Notifier< uiTextEditBase > sliderReleased
Definition: uitextedit.h:51
#define mODTextTranslationClass(clss)
Definition: uistring.h:38
#define od_int64
Definition: plftypes.h:36
Notifier< uiTextBrowser > linkHighlighted
Definition: uitextedit.h:136
uiTextBrowserBody * body_
Definition: uitextedit.h:166
The base class for most UI elements.
Definition: uiobj.h:38
bool canGoForward()
Definition: uitextedit.h:131
Definition: uistring.h:89
Definition: uiparent.h:26
int maxlines_
Definition: uitextedit.h:147
void setDefaultWidth(int w)
Definition: uitextedit.h:37
bool cangobackw_
Definition: uitextedit.h:145
friend class uiTextBrowserBody
Definition: i_qtextedit.h:102
void setDefaultHeight(int h)
Definition: uitextedit.h:40
bool append(TypeSetBase< T, I > &to, const TypeSetBase< S, J > &from)
append allowing a different type to be merged into set
Definition: typeset.h:198
bool canGoBackward()
Definition: uitextedit.h:132
BufferString lastlink_
Definition: uitextedit.h:143
bool cangoforw_
Definition: uitextedit.h:144
mFDQtclass(QTextEdit) class Timer
#define mUdf(type)
Use this macro to get the undefined for simple types.
Definition: undefval.h:272
encapsulates the read-access-only part of strings in OD.
Definition: odstring.h:31
Definition: uitextedit.h:25
bool forceplaintxt_
Definition: uitextedit.h:146
Notifier< uiTextEditBase > sliderPressed
Definition: uitextedit.h:50
Definition: uitextedit.h:120
virtual int maxLines() const
Definition: uitextedit.h:149
int defaultwidth_
Definition: uitextedit.h:61
Definition: i_qtextedit.h:61
CNotifier< uiTextEditBase, bool > copyAvailable
Definition: uitextedit.h:52
Definition: uitextedit.h:102
Notifier< uiTextBrowser > linkClicked
Definition: uitextedit.h:137
OD::String with its own variable length buffer. The buffer has a guaranteed minimum size...
Definition: bufstring.h:40
int defaultHeight()
Definition: uitextedit.h:39
int defaultheight_
Definition: uitextedit.h:62
bool logviewmode_
Definition: uitextedit.h:160
Timer * timer_
Definition: uitextedit.h:159
BufferString result_
Definition: uitextedit.h:65
Helper class for uiTextBrowser to relay Qt&#39;s messages.
Definition: i_qtextedit.h:99
int defaultWidth()
Definition: uitextedit.h:36
uiTextEditBody * body_
Definition: uitextedit.h:96
Timer class.
Definition: timer.h:25
LinkBehavior
Definition: uitextedit.h:120
od_int64 lastlinestartpos_
Definition: uitextedit.h:161
const char * lastLink()
Definition: uitextedit.h:133
Notifier< uiTextBrowser > goneForwardOrBack
Definition: uitextedit.h:135
Notifier< uiTextBrowser > fileReOpened
Definition: uitextedit.h:138
BufferString lastline_
Definition: uitextedit.h:162

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