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