OpendTect-6_4  6.4
uitextfile.h
Go to the documentation of this file.
1 #ifndef uitextfile_h
2 #define uitextfile_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 "uitoolsmod.h"
16 #include "uidialog.h"
17 #include "file.h"
18 #include "uistring.h"
19 class uiTextEdit;
20 class uiTextBrowser;
21 class uiTable;
22 
23 
24 mExpClass(uiTools) uiTextFile : public CallBacker
26 public:
27 
29 
30  uiTextFile( uiParent* p, const char* fnm,
31  const Setup& s=Setup() )
32  : setup_(s)
33  , filename_(fnm)
34  , fileNmChg(this) { init(p); }
35 
36  const char* fileName() const { return filename_; }
37  bool isModified () const { return ismodified_; }
38  int maxLines() const { return setup_.maxnrlines_; }
39  virtual bool isEditable() const { return setup_.editable_; }
40  virtual bool isTable() const { return setup_.style_ ==
41  File::Table; }
42 
43  bool open(const char*);
44  bool reLoad();
45  bool save();
46  bool saveAs(const char*);
47 
48  int nrLines() const;
49  void toLine(int);
50 
51  const char* text() const;
52 
53  uiTextEdit* textEdit() { return txted_; }
54  uiTextBrowser* textBrowser() { return txtbr_; }
55  uiTable* tableEditor() { return tbl_; }
56  uiObject* uiObj();
57 
59 
60 protected:
61 
62  Setup setup_;
64  mutable bool ismodified_;
65 
69 
70  void init(uiParent*);
71  void setFileName(const char*);
72 
73  void valChg(CallBacker*);
74 
75 };
76 
77 
78 mExpClass(uiTools) uiTextFileDlg : public uiDialog
80 public:
81 
82  mExpClass(uiTools) Setup : public uiDialog::Setup
83  {
84  public:
85  Setup( const uiString& winttl = uiString::emptyString() )
86  : uiDialog::Setup(winttl.isSet() ? winttl : tr("File viewer"),
88  , scroll2bottom_(false)
89  , allowopen_(false)
90  , allowsave_(false)
91  {
92  oktext(uiStrings::sClose())
93  .canceltext( uiStrings::sReload() )
94  .separator(false).modal(false).menubar(true);
95  }
96 
97  mDefSetupMemb(bool, scroll2bottom)
98  mDefSetupMemb(bool, allowopen)
99  mDefSetupMemb(bool, allowsave)
100 
101  };
102 
103  uiTextFileDlg(uiParent* p,const char* fnm,
104  bool rdonly=false,bool tbl=false);
105  uiTextFileDlg( uiParent* p,const Setup&);
107  const Setup& s, const char* fnm )
108  : uiDialog(p,s) { init(s,ts,fnm); }
109 
110  uiTextFile* editor() { return editor_; }
111  void setFileName(const char*);
112  const char* fileName() const { return editor_->fileName(); }
113 
114 protected:
115 
118 
119  void open(CallBacker*);
120  void save(CallBacker*);
121  void saveAs(CallBacker*);
122  void dismiss(CallBacker*);
123  bool rejectOK(CallBacker*);
124  bool acceptOK(CallBacker*);
125  void finalizeCB(CallBacker*);
126 
127  void fileNmChgd(CallBacker*);
128  void init(const Setup&,const uiTextFile::Setup&,const char*);
129  bool okToExit();
130  int doMsg(const char*,bool iserr=true);
131 };
132 
133 
134 #endif
#define mExpClass(module)
Definition: commondefs.h:160
int maxLines() const
Definition: uitextfile.h:38
To be able to send and/or receive CallBacks, inherit from this class.
Definition: callback.h:272
Definition: uitextedit.h:74
#define mNoHelpKey
Definition: uidialog.h:39
FixedString Setup()
Definition: keystrs.h:116
Definition: file.h:99
static uiString sClose()
Definition: uistrings.h:246
uiTable * tbl_
Definition: uitextfile.h:68
Definition: uitextfile.h:78
uiTextFileDlg(uiParent *p, const uiTextFile::Setup &ts, const Setup &s, const char *fnm)
Definition: uitextfile.h:106
#define mODTextTranslationClass(clss)
Definition: uistring.h:38
static uiString sReload()
Definition: uistrings.h:416
uiTextFile(uiParent *p, const char *fnm, const Setup &s=Setup())
Definition: uitextfile.h:30
bool init()
Definition: uitable.h:30
static const uiString & emptyString()
Definition: uistring.h:109
The base class for most UI elements.
Definition: uiobj.h:38
Definition: uistring.h:89
#define mNoDlgTitle
Stand-alone dialog window with optional 'OK', 'Cancel' and 'Save defaults' button.
Definition: uidialog.h:37
Definition: uiparent.h:26
Setup(const uiString &winttl=uiString::emptyString())
Definition: uitextfile.h:85
const char * text(const RowCol &) const
Definition: uidialog.h:42
const char * fileName() const
Definition: uitextfile.h:36
bool ismodified_
Definition: uitextfile.h:64
uiTextBrowser * txtbr_
Definition: uitextfile.h:67
bool isModified() const
Definition: uitextfile.h:37
bool captionisfilename_
Definition: uitextfile.h:117
#define mDefSetupMemb(typ, memb)
Definition: commondefs.h:137
Setup setup_
Definition: uitable.h:344
const char * fileName() const
Definition: uitextfile.h:112
Definition: uitextedit.h:102
uiTextFile * editor_
Definition: uitextfile.h:116
BufferString filename_
Definition: uitextfile.h:63
uiTextEdit * textEdit()
Definition: uitextfile.h:53
OD::String with its own variable length buffer. The buffer has a guaranteed minimum size...
Definition: bufstring.h:40
File::ViewPars Setup
Definition: uitextfile.h:28
uiTextEdit * txted_
Definition: uitextfile.h:66
Notifier< uiTextFile > fileNmChg
Definition: uitextfile.h:58
uiTextFile * editor()
Definition: uitextfile.h:110
Definition: file.h:102
virtual bool isEditable() const
Definition: uitextfile.h:39
virtual bool isTable() const
Definition: uitextfile.h:40
uiTable * tableEditor()
Definition: uitextfile.h:55
Setup setup_
Definition: uitextfile.h:62
Definition: uitextfile.h:24
uiTextBrowser * textBrowser()
Definition: uitextfile.h:54

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