00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #ifndef _SO_WIN_COLOR_EDITOR_
00026 #define _SO_WIN_COLOR_EDITOR_
00027
00028 #include <Inventor/sys/port.h>
00029 #ifdef _WIN32
00030 # include <Inventor/Win/SoWinBeginStrict.h>
00031 #else
00032 # include <Xm/Xm.h>
00033 #endif
00034 #include <Inventor/SbColor.h>
00035 #include <Inventor/misc/SoCallbackList.h>
00036 #include <Inventor/Win/SoWinComponent.h>
00037
00038
00039 class SoBase;
00040 class SoNodeSensor;
00041 class SoMFColor;
00042 class SoPathList;
00043 class SoSFColor;
00044 class SoSensor;
00045 class SoWinClipboard;
00046 class SoWinColorPatch;
00047 class SoWinColorWheel;
00048 class SoWinColorSlider;
00049
00050 class SoMFUInt32;
00051
00052 struct ColorEditorCBData;
00053
00054
00059 typedef void SoWinColorEditorCB(void *userData, const SbColor *color);
00060
00061 #ifdef _WIN32
00062 class CBitButton ;
00063 #endif
00064
00066
00067
00068
00069
00070
00072
00094 class SoWinColorEditor : public SoWinComponent {
00095
00096 public:
00101 enum Sliders {
00105 NONE,
00109 INTENSITY,
00113 RGB,
00117 HSV,
00121 RGB_V,
00125 RGB_HSV,
00126 };
00127
00132 enum UpdateFrequency {
00136 CONTINUOUS,
00140 AFTER_ACCEPT,
00141 };
00142
00146 SoWinColorEditor(
00147 SoWidget parent = NULL,
00148 const char *name = NULL,
00149 SbBool buildInsideParent = TRUE);
00153 ~SoWinColorEditor();
00154
00169 void attach(SoSFColor *color, SoBase *node);
00174 void attach(SoMFColor *color, int index, SoBase *node);
00175
00179 void attach(SoMFUInt32 *color, int index, SoBase *node);
00180
00186 void detach();
00190 SbBool isAttached() { return attached; }
00191
00198 inline void addColorChangedCallback(
00199 SoWinColorEditorCB *f,
00200 void *userData = NULL);
00205 inline void removeColorChangedCallback(
00206 SoWinColorEditorCB *f,
00207 void *userData = NULL);
00208
00213 void setColor(const SbColor &color);
00217 const SbColor & getColor() { return baseRGB; }
00218
00233 void setWYSIWYG(SbBool trueOrFalse);
00237 SbBool isWYSIWYG() { return WYSIWYGmode; }
00238
00242 void setCurrentSliders(SoWinColorEditor::Sliders whichSliders);
00246 SoWinColorEditor::Sliders getCurrentSliders() { return whichSliders; }
00247
00251 void setUpdateFrequency(SoWinColorEditor::UpdateFrequency freq);
00255 SoWinColorEditor::UpdateFrequency getUpdateFrequency()
00256 { return updateFreq; }
00257
00258
00259 SbBool alwaysOnTop;
00260 private:
00261
00262
00263
00264
00265
00266 SoEXTENDER
00267 SoWinColorEditor(
00268 SoWidget parent,
00269 const char *name,
00270 SbBool buildInsideParent,
00271 SbBool buildNow);
00272
00273
00274 virtual SbString getDefaultWidgetName() const;
00275 virtual SbString getDefaultTitle() const;
00276 virtual SbString getDefaultIconTitle() const;
00277
00278 private:
00279
00280 #ifdef _WIN32
00281 POINT sliderPos[6] ;
00282 POINT sliderLabPos[6] ;
00283 POINT sliderValPos[6] ;
00284 RECT areaPos[6] ;
00285 RECT rcDlg ;
00286
00287 unsigned long sliderId[6] ;
00288 unsigned long sliderLabId[6] ;
00289 unsigned long sliderValId[6] ;
00290 unsigned long areaId[6] ;
00291 unsigned long nCurrSliderId ;
00292 unsigned long nCurrEditId ;
00293
00294 HMENU menubar ;
00295 HGLOBAL hDlgTemplate;
00296
00297 CBitButton *lpleftButton ;
00298 CBitButton *lprightButton ;
00299 CBitButton *lpswitchButton ;
00300
00301 void finishBuild() ;
00302 void getControlPositions() ;
00303 void hideAllSliders() ;
00304 void showAllSliders() ;
00305 void moveSlider(int nSlider,int nPos) ;
00306 void showSlider(int nSlider) ;
00307 void hideSlider(int nSlider) ;
00308 void showControl(int nId) ;
00309 void hideControl(int nId) ;
00310 void sizeToArea(int n) ;
00311 void layoutAccept(WBOOL nReduceOk) ;
00312 void showArea0() ;
00313 void showArea1() ;
00314 void showArea2() ;
00315 void showArea3() ;
00316 void showArea4() ;
00317 void showArea5() ;
00318
00319 static WBOOL CALLBACK mgrDlgProc( Hwnd hdlg, UINT message,
00320 WPARAM wParam, LPARAM lParam );
00321 static void onCommand(
00322 Hwnd hdlg,
00323 int id,
00324 Hwnd hCtrl,
00325 UINT codeNotify ) ;
00326
00327 void handleEdit(
00328 int nSlider,
00329 Hwnd hEdit,
00330 UINT codeNotify) ;
00331
00332 WBOOL handleDrawItem(
00333 WPARAM wParam,
00334 LPARAM lParam ) ;
00335
00336
00337 #endif
00338
00339
00340 SoWidget buildWidget(SoWidget parent);
00341 static void visibilityChangeCB(void *pt, SbBool visible);
00342
00343
00344 SoWidget mgrWidget;
00345 SbBool WYSIWYGmode;
00346 Sliders whichSliders;
00347 SbColor baseRGB;
00348 float baseHSV[3];
00349 SbBool ignoreCallback;
00350 SoWinColorSlider *sliders[6];
00351 SoWinColorWheel *wheel;
00352 SoWinColorPatch *current, *previous;
00353 ColorEditorCBData *dataId;
00354 SbPList menuItems;
00355 SoWinColorEditor::UpdateFrequency updateFreq;
00356
00357
00358 SbBool attached;
00359 SoBase *editNode;
00360 SoSFColor *colorSF;
00361 SoMFColor *colorMF;
00362 SoNodeSensor *colorSensor;
00363 SoCallbackList *callbackList;
00364 int index;
00365
00366
00367 SoMFUInt32 *colorUInt32MF;
00368 float transparency;
00369
00370
00371 SoWinClipboard *clipboard;
00372 void copy(Time eventTime);
00373 void paste(Time eventTime);
00374
00375 void pasteDone(SoPathList *pathList);
00376 static void pasteDoneCB(void *userData, SoPathList *pathList);
00377
00378
00379 SoWidget acceptButton, slidersForm, buttonsForm, wheelForm;
00380
00381
00382 SoWidget buildPulldownMenu(SoWidget parent);
00383 SoWidget buildControls(SoWidget parent);
00384 SoWidget buildSlidersForm(SoWidget parent);
00385
00386 void doSliderLayout();
00387 void doDynamicTopLevelLayout();
00388 int numberOfSliders(SoWinColorEditor::Sliders slider);
00389
00390
00391
00392 void doUpdates();
00393
00394
00395 void fieldChanged();
00396 static void fieldChangedCB(void *, SoSensor *);
00397
00398
00399 static void wheelCallback(void *, const float hsv[3]);
00400 void wheelChanged(const float hsv[3]);
00401 static void sliderCallback(void *, float);
00402 void sliderChanged(short id, float value);
00403
00404 #ifdef _WIN32
00405 void buttonsCallback(int id);
00406 #else
00407 static void buttonsCallback(SoWidget, ColorEditorCBData *, XtPointer);
00408 #endif
00409 void buttonPressed(short id);
00410
00411 #ifdef _WIN32
00412 void editMenuCallback(int id);
00413 void sliderMenuCallback(int id);
00414 #else
00415 static void editMenuCallback(SoWidget, ColorEditorCBData *, XmAnyCallbackStruct *);
00416 static void sliderMenuCallback(SoWidget, ColorEditorCBData *, XtPointer);
00417 #endif
00418
00419 static void menuDisplay(SoWidget, SoWinColorEditor *editor, XtPointer);
00420
00421
00422 void constructorCommon(SbBool buildNow);
00423
00424 };
00425
00426
00427 void
00428 SoWinColorEditor::addColorChangedCallback(
00429 SoWinColorEditorCB *f,
00430 void *userData)
00431 { callbackList->addCallback((SoCallbackListCB *) f, userData); }
00432
00433 void
00434 SoWinColorEditor::removeColorChangedCallback(
00435 SoWinColorEditorCB *f,
00436 void *userData)
00437 { callbackList->removeCallback((SoCallbackListCB *) f, userData); }
00438
00439
00440 #ifdef _WIN32
00441 #include <Inventor/Win/SoWinEndStrict.h>
00442 #endif
00443 #endif
00444
00445