00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #ifndef _SO_DIALOG_EDIT_TEXT_
00024 #define _SO_DIALOG_EDIT_TEXT_
00025
00026 #include <DialogViz/dialog/SoDialogComponent.h>
00027
00028 class SoDialogEditTextAuditor;
00029 class SoEventCallback;
00030 class SoClipPlane;
00031 class SbLineProjector;
00032
00117 class SoDialogEditText : public SoDialogComponent
00118 {
00119 SO_DG_HEADER(SoDialogEditText);
00120
00121 public:
00122
00126 SoSFString editText;
00127
00131 SoSFBool editable;
00132
00136 SoSFBool multiLine;
00137
00141 SoSFBool wrapLine;
00142
00148 SoSFBool trigOnEnter;
00149
00153 SoSFBool isNumeric;
00154
00158 SoDialogEditText();
00159
00163 void addAuditor(SoDialogEditTextAuditor* auditor);
00164
00168 void removeAuditor(SoDialogEditTextAuditor* auditor);
00169
00170
00171 private:
00172 virtual void buildWidget(SoWidget parent, SbVec2i32 &rSize, SbVec2i32 & pos, SbBool isActive2d);
00173 virtual void destroyWidget();
00174 virtual void eventNotify(unsigned int event, uintptr_t param);
00175 virtual SoWidget getLabelWidget();
00176 static void initClass();
00177 static void exitClass();
00178 virtual void updateFromSensor(SoSensor* sensor);
00179 void processEvent(SbBool force);
00180
00181 void updateLabelWidget();
00182 void updateEditTextWidget();
00183
00184 void applyDlgCptAuditor();
00185
00186 private:
00187 SoWidget m_editTextWidget;
00188
00189 virtual ~SoDialogEditText();
00190
00191 private:
00192 SbVec2i32 m_oeSize, m_olSize;
00193 SbBool m_fromSensor;
00194
00195 void createLabelWidget();
00196 void createEditTextWidget();
00197 virtual SbVec2i32 getComponentInitSize();
00198 virtual void getDefaultSize(SbVec2i32 &size, SbVec2i32 &min, SbVec2i32 &max);
00199
00200 virtual void changeEditable();
00201 virtual void changeMultiLine();
00202 virtual void changeWrapLine();
00203 virtual void changeEditText();
00204 virtual void changeEnable();
00205 virtual void changeWidgetEnable(SbBool state);
00206 virtual void changeLabel();
00207 virtual void changeLabelAlignment();
00208 virtual void changeLabelVisibility();
00209 virtual void changeEdgeStyle();
00210
00211 virtual void setFocus();
00212
00213
00214 FIELD_SENSOR(editText);
00215 FIELD_SENSOR(editable);
00216 FIELD_SENSOR(multiLine);
00217 FIELD_SENSOR(wrapLine);
00218
00220
00221 private:
00222 static char* DialogEditText;
00223 static void change3DSkin();
00224 static SbBool isSkinLoaded();
00225 static void setSkinLoaded(SbBool loaded);
00226 void insertCharTo3DText(char c);
00227 void removeCharIn3DText();
00228
00229 private:
00230 SO_DG_CATALOG_ENTRY_HEADER( labelSep );
00231 SO_DG_CATALOG_ENTRY_HEADER( labelSwitch );
00232 SO_DG_CATALOG_ENTRY_HEADER( labelProp );
00233
00234 SO_DG_CATALOG_ENTRY_HEADER( scrollVSwitch );
00235 SO_DG_CATALOG_ENTRY_HEADER( downSep );
00236 SO_DG_CATALOG_ENTRY_HEADER( downSwitch );
00237 SO_DG_CATALOG_ENTRY_HEADER( downPressed );
00238 SO_DG_CATALOG_ENTRY_HEADER( downReleased );
00239 SO_DG_CATALOG_ENTRY_HEADER( upSep );
00240 SO_DG_CATALOG_ENTRY_HEADER( upSwitch );
00241 SO_DG_CATALOG_ENTRY_HEADER( upPressed );
00242 SO_DG_CATALOG_ENTRY_HEADER( upReleased );
00243 SO_DG_CATALOG_ENTRY_HEADER( scrollVSep );
00244 SO_DG_CATALOG_ENTRY_HEADER( scrollVBack );
00245 SO_DG_CATALOG_ENTRY_HEADER( scrollVFrame );
00246 SO_DG_CATALOG_ENTRY_HEADER( cursorVSep );
00247 SO_DG_CATALOG_ENTRY_HEADER( cursorVFrame );
00248
00249 SO_DG_CATALOG_ENTRY_HEADER( scrollHSwitch );
00250 SO_DG_CATALOG_ENTRY_HEADER( leftSep );
00251 SO_DG_CATALOG_ENTRY_HEADER( leftSwitch );
00252 SO_DG_CATALOG_ENTRY_HEADER( leftPressed );
00253 SO_DG_CATALOG_ENTRY_HEADER( leftReleased );
00254 SO_DG_CATALOG_ENTRY_HEADER( rightSep );
00255 SO_DG_CATALOG_ENTRY_HEADER( rightSwitch );
00256 SO_DG_CATALOG_ENTRY_HEADER( rightPressed );
00257 SO_DG_CATALOG_ENTRY_HEADER( rightReleased );
00258 SO_DG_CATALOG_ENTRY_HEADER( scrollHSep );
00259 SO_DG_CATALOG_ENTRY_HEADER( scrollHBack );
00260 SO_DG_CATALOG_ENTRY_HEADER( scrollHFrame );
00261 SO_DG_CATALOG_ENTRY_HEADER( cursorHSep );
00262 SO_DG_CATALOG_ENTRY_HEADER( cursorHFrame );
00263
00264 SO_DG_CATALOG_ENTRY_HEADER( editSep );
00265 SO_DG_CATALOG_ENTRY_HEADER( frameSep );
00266 SO_DG_CATALOG_ENTRY_HEADER( frameSwitch );
00267 SO_DG_CATALOG_ENTRY_HEADER( frame );
00268 SO_DG_CATALOG_ENTRY_HEADER( editFrame );
00269 SO_DG_CATALOG_ENTRY_HEADER( textSep );
00270 SO_DG_CATALOG_ENTRY_HEADER( textProp );
00271
00272 SO_DG_CATALOG_ENTRY_HEADER( caretSep );
00273 SO_DG_CATALOG_ENTRY_HEADER( caretSwitch );
00274 SO_DG_CATALOG_ENTRY_HEADER( caretFrame );
00275
00276 private:
00277
00278 SoText3 *editTextText, *editTextLabel;
00279 SoTranslation *editTextLabelTranslation, *editTextFrameTranslation;
00280 SoTranslation *editTextTextTranslation, *scrollVCursorTranslation, *scrollHCursorTranslation;
00281 SoTranslation *editTextDownTranslation, *editTextUpTranslation;
00282 SoTranslation *editTextLeftTranslation, *editTextRightTranslation;
00283 SoTranslation *editTextScrollVTranslation, *scrollVCursorPosTranslation, *editTextCaretTranslation;
00284 SoTranslation *editTextScrollHTranslation, *scrollHCursorPosTranslation, *editTextScrollTextTranslation;
00285 SoScale *editTextFrameScale;
00286 SoScale *editTextButtonScale, *editTextScrollVScale, *editTextScrollHScale;
00287 SoScale *scrollVCursorScale, *scrollHCursorScale, *editTextCaretScale;
00288 SoTransform *editTextFrameTransform, *scrollVFrameTransform, *scrollHFrameTransform;
00289 SoClipPlane *editTextClipPlaneTop, *editTextClipPlaneBottom;
00290 SoClipPlane *editTextClipPlaneLeft, *editTextClipPlaneRight;
00291
00292 SoEventCallback* eventCB;
00293 SbBool m_isEditing;
00294 SbLineProjector* m_lineProj;
00295 SbVec3f m_initialVPos, m_initialHPos;
00296 int m_currentPos;
00297 int m_current3DLine;
00298 int m_current3DCaretPos;
00299
00300 SbBox3f m_textCachedBBox;
00301
00302 void create3DDialogEditText();
00303 void update3DEditText();
00304 void update3DLabel();
00305 void update3DCursors();
00306 void update3DScrollBars();
00307 void update3DTextPosition();
00308 void update3DTextScrollPosition();
00309 void move3DCursor(float inc);
00310 void move3DCaret(int line, int pos);
00311 void update3DTextCache(int prevLine);
00312 void apply3DEvent(SbString str);
00313
00314 void change3DEditText();
00315 virtual void change3DLabelVisibility();
00316 virtual void change3DLabel();
00317 virtual void change3DLabelAlignment();
00318 virtual void set3DInactive();
00319
00320 static void startCB3D( void *, SoDragger *inDragger );
00321 static void motionCB3D( void *, SoDragger *inDragger );
00322 static void finishCB3D( void *, SoDragger *inDragger );
00323 static void processKeyEvents(void *inDragger, SoEventCallback *cb);
00324 void draggerStartCallback3D();
00325 void draggerMotionCallback3D();
00326 void draggerFinishCallback3D();
00327
00328 void finish3DEditing();
00329
00330 static SbBool m_isSkinLoaded;
00331
00333
00334 };
00335
00336 #endif // _SO_DIALOG_EDIT_TEXT_
00337
00338
00339