OpendTect-6_4  6.4
cmddriverbasics.h
Go to the documentation of this file.
1 #ifndef cmddriverbasics_h
2 #define cmddriverbasics_h
3 
4 /*+
5 ________________________________________________________________________
6 
7  (C) dGB Beheer B.V.; (LICENSE) http://opendtect.org/OpendTect_license.txt
8  Author: Jaap Glas
9  Date: January 2009
10  RCS: $Id$
11  ________________________________________________________________________
12 
13 -*/
14 
15 #include "uicmddrivermod.h"
16 #include "separstr.h"
17 #include "bufstringset.h"
18 #include "mousecursor.h"
19 #include "uistring.h"
20 
21 class uiMainWin;
22 class CallBacker;
23 class uiObject;
24 class uiAction;
25 class uiParent;
26 class uiBaseObject;
27 class uiMenu;
28 
29 
30 namespace CmdDrive
31 {
32 
33 #define mAddCharToBufStr( bufstr, chr ) \
34 { char str[2]; str[0] = mCast(char,chr); str[1] = '\0'; bufstr += str; }
35 
36 #define mSepStrSize(fms) ( fms.isEmpty() ? 1 : fms.size() )
37 
38 #define mGetAmpFilteredStr( dest, src ) \
39  BufferString dest( src ); \
40  StringProcessor(dest).filterAmpersands();
41 
42 
43 #define mGetEscConvertedFMS( fms, str, removecmdfileescapes ) \
44 \
45  BufferString fms##bufstr( str ); \
46  StringProcessor( fms##bufstr ).addFileMultiStrEscapes(); \
47  if ( removecmdfileescapes ) \
48  StringProcessor( fms##bufstr ).removeCmdFileEscapes(); \
49 \
50  FileMultiString fms( fms##bufstr.buf() );
51 
52 
53 #define mStripOuterBrackets( name, context ) \
54  StringProcessor(name).stripOuterBrackets( \
55  StringProcessor::context##VoidBeginBrackets(), \
56  StringProcessor::context##VoidEndBrackets() )
57 
58 
59 #define mDressString( name, context, cleanup ) \
60 { \
61  if ( cleanup ) \
62  StringProcessor(name).cleanUp(); \
63  while ( mStripOuterBrackets(name, sDress) ) ; \
64  StringProcessor(name).addCmdFileEscapes( \
65  StringProcessor::context##EscSymbols() ); \
66 }
67 
68 #define mDressNameString( name, context ) \
69  mDressString( name, context, true );
70 
71 #define mDressUserInputString( name, context ) \
72  mDressString( name, context, false );
73 
74 
75 #define mIsSymbol(chr) ( !iswalnum(chr) && !iswspace(chr) )
76 
77 
78 #define mGetColorString( color, isvalid, colorstr ) \
79 \
80  FileMultiString colorstr; \
81  colorstr += isvalid ? (int) color.r() : 255; \
82  colorstr += isvalid ? (int) color.g() : 255; \
83  colorstr += isvalid ? (int) color.b() : 255; \
84  colorstr += isvalid ? (int) color.t() : 255; \
85 
86 
87 #define mUnscope( identstr, unscopedstr ) \
88  const char* unscopedstr = *identstr=='@' ? identstr+1 : identstr;
89 
90 
91 mExpClass(uiCmdDriver) StringProcessor // Parsing toolkit
92 {
93 public:
95  : constptr_(bs.buf()), bufstr_(&bs)
96  {}
97 
99  : constptr_(ss.buf()), bufstr_(&ss.rep())
100  {}
101 
102  StringProcessor(const char* str)
103  : constptr_(str), bufstr_(0)
104  {}
105 
106  const char* parseDQuoted(BufferString& unquotedstr) const;
107  int consecutiveDQuoted(const char** remnant=0) const;
108  int nrDQuotes() const;
109 
110  const char* parseBracketed(BufferString& unbracketedstr,
111  char begin='[',char end=']') const;
112 
113  int removeNumAppendix();
114  bool removeTokenAppendix(char token);
115 
116  const char* nextAction(BufferString&) const;
117  const char* findAssignment(const char* tokens="=") const;
118 
119  const char* parseIdentifier(BufferString&) const;
120  bool convertToInt(int* =0) const;
121  bool convertToDouble(double* =0) const;
122 
123  char /* missing */ preParseProcedure(FileMultiString& key,
124  FileMultiString& parameters) const;
125 
126  void makeDirSepIndep(int startpos=-1);
127 
128  void addCmdFileEscapes(const char* extraescapesymbols=0);
129  bool isEscapedSymbol(const char*) const;
130  void removeCmdFileEscapes();
131  void addFileMultiStrEscapes();
132 
133  const char* getCharElement(int idx) const;
134  int nrCharElements() const;
135  void appendCharElements(const char* tail);
136 
137  void filterAmpersands();
138  void capitalize(bool yn=true);
139 
140  void removeExtraSpace();
141  void removeTrailingDots();
142  void cleanUp();
143 
144  char stripOuterBrackets(const char* beginsymbols,
145  const char* endsymbols);
146 
147  const char* buf() const { return constptr_; }
148 
149  static const char* sWinAssertEscSymbols() { return "$*#[]"; }
150  static const char* sWinNameEscSymbols() { return "$*#\""; }
151  static const char* sKeyStrEscSymbols() { return "$*`#\""; }
152  static const char* sMenuPathEscSymbols() { return "$*`#\""; }
153  static const char* sTreePathEscSymbols() { return "$*`#<\""; }
154  static const char* sItemNameEscSymbols() { return "$*#\""; }
155  static const char* sInputStrEscSymbols() { return "$`\""; }
156  static const char* sAllEscSymbols() { return "$*`#[]<\""; }
157 
158  static const char* sMatchVoidBeginBrackets() { return ":`([{<>\"/"; }
159  static const char* sMatchVoidEndBrackets() { return ":')]}><\"\\"; }
160 
161  static const char* sDressVoidBeginBrackets() { return ">/"; }
162  static const char* sDressVoidEndBrackets() { return "<\\"; }
163 
164 protected:
165 
166  const char* constptr_;
168 };
169 
170 
171 mGlobal(uiCmdDriver) const char* windowTitle(const uiMainWin* applwin,
172  const uiMainWin* uimw,
173  int aliasnr=0);
174 mGlobal(uiCmdDriver) bool isCmdDriverWindow(const uiMainWin*);
175 mGlobal(uiCmdDriver) const char* controllerTitle();
176 
177 
178 mExpClass(uiCmdDriver) WindowStack
179 {
180 public:
182 
183  bool moveToTop(const uiMainWin*);
184  bool moveFrameToTop(const uiMainWin*);
185 
186  const uiMainWin* topWin(bool ignorecmddriverwins=false) const;
187  void synchronize();
188 
189 protected:
190 
191  bool moveToTopWithoutSync(const uiMainWin*);
192 
194 };
195 
196 
198 {
199 public:
200  InteractSpec(bool wait=true)
201  : wait_( wait )
202  , launchpad_( 0 )
203  , cursorshape_( MouseCursor::Forbidden )
204  {}
205 
206  bool wait_;
214 };
215 
216 
222 mExpClass(uiCmdDriver) UIEntity
223 {
224 public:
225  UIEntity(const CallBacker*);
226 
227  bool isValid() const { return uiobj_ || uiact_; }
228 
229  const uiObject* object() const { return uiobj_; }
230  const uiAction* action() const { return uiact_; }
231 
232  bool visible() const;
233  bool sensitive() const;
234 
235  const char* name() const;
236  const char* toolTip() const;
237 
238  const uiParent* parent() const;
239  const uiMenu* menu() const;
240 
241  const ObjectSet<uiBaseObject>* childList() const;
242 
243 protected:
244 
245  const uiObject* uiobj_;
246  const uiAction* uiact_;
247 };
248 
249 
250 }; // namespace CmdDrive
251 
252 #endif
bool wait_
Definition: cmddriverbasics.h:206
uiString infotext_
Definition: cmddriverbasics.h:212
#define mExpClass(module)
Definition: commondefs.h:160
User interface main window.
Definition: uimainwin.h:36
uiString cancelbuttext_
Definition: cmddriverbasics.h:211
To be able to send and/or receive CallBacks, inherit from this class.
Definition: callback.h:272
bool isCmdDriverWindow(const uiMainWin *)
Definition of a mouse cursor, can be either a predefined shape (from the enum, or a file...
Definition: mousecursor.h:26
uiString dlgtitle_
Definition: cmddriverbasics.h:209
StringProcessor(SeparString &ss)
Definition: cmddriverbasics.h:98
Command Drive
Definition: canvascommands.h:22
Shape
Definition: mousecursor.h:57
const char * constptr_
Definition: cmddriverbasics.h:166
#define mGlobal(module)
Definition: commondefs.h:163
InteractSpec(bool wait=true)
Definition: cmddriverbasics.h:200
static const char * sDressVoidEndBrackets()
Definition: cmddriverbasics.h:162
const char * controllerTitle()
StringProcessor(const char *str)
Definition: cmddriverbasics.h:102
uiString okbuttext_
Definition: cmddriverbasics.h:210
const char * buf() const
Definition: cmddriverbasics.h:147
const char * windowTitle(const uiMainWin *applwin, const uiMainWin *uimw, int aliasnr=0)
List encoded in a string.
Definition: separstr.h:33
The base class for most UI elements.
Definition: uiobj.h:38
static const char * sWinNameEscSymbols()
Definition: cmddriverbasics.h:150
Definition: uistring.h:89
Definition: uiparent.h:26
static const char * sMatchVoidBeginBrackets()
Definition: cmddriverbasics.h:158
SeparString with backquotes as separators, use in most ascii files.
Definition: separstr.h:119
static const char * sWinAssertEscSymbols()
Definition: cmddriverbasics.h:149
MouseCursor::Shape cursorshape_
Definition: cmddriverbasics.h:208
const uiMainWin * launchpad_
Definition: cmddriverbasics.h:207
static const char * sInputStrEscSymbols()
Definition: cmddriverbasics.h:155
Definition: cmddriverbasics.h:197
const uiAction * action() const
Definition: cmddriverbasics.h:230
static const char * sItemNameEscSymbols()
Definition: cmddriverbasics.h:154
const uiObject * uiobj_
Definition: cmddriverbasics.h:245
const uiAction * uiact_
Definition: cmddriverbasics.h:246
static const char * sMatchVoidEndBrackets()
Definition: cmddriverbasics.h:159
static const char * sMenuPathEscSymbols()
Definition: cmddriverbasics.h:152
const uiObject * object() const
Definition: cmddriverbasics.h:229
Definition: uimenu.h:65
static const char * sDressVoidBeginBrackets()
Definition: cmddriverbasics.h:161
Convenience class UIEntity offers access to shared functionality of uiAction and uiObject, given their base class CallBacker. Since toolbar buttons are no longer uiToolButtons but uiActions, unspecified UI objects have to be passed as CallBackers.
Definition: cmddriverbasics.h:222
OD::String with its own variable length buffer. The buffer has a guaranteed minimum size...
Definition: bufstring.h:40
BufferString * bufstr_
Definition: cmddriverbasics.h:167
bool isValid() const
Definition: cmddriverbasics.h:227
uiString resumetext_
Definition: cmddriverbasics.h:213
WindowStack()
Definition: cmddriverbasics.h:181
Definition: cmddriverbasics.h:178
static const char * sTreePathEscSymbols()
Definition: cmddriverbasics.h:153
Definition: cmddriverbasics.h:91
StringProcessor(BufferString &bs)
Definition: cmddriverbasics.h:94
static const char * sKeyStrEscSymbols()
Definition: cmddriverbasics.h:151
ObjectSet< const uiMainWin > winstack_
Definition: cmddriverbasics.h:193
static const char * sAllEscSymbols()
Definition: cmddriverbasics.h:156

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