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 #if !defined(__sgi)
00051 class SoMFUInt32;
00052 #endif
00053
00054 struct ColorEditorCBData;
00055
00056
00061 typedef void SoWinColorEditorCB(void *userData, const SbColor *color);
00062
00063 #ifdef _WIN32
00064 class CBitButton ;
00065 #endif
00066
00068
00069
00070
00071
00072
00074
00097 class SoWinColorEditor : public SoWinComponent {
00098
00099 public:
00104 enum Sliders {
00108 NONE,
00112 INTENSITY,
00116 RGB,
00120 HSV,
00124 RGB_V,
00128 RGB_HSV,
00129 };
00130
00135 enum UpdateFrequency {
00139 CONTINUOUS,
00143 AFTER_ACCEPT,
00144 };
00145
00149 SoWinColorEditor(
00150 SoWidget parent = NULL,
00151 const char *name = NULL,
00152 SbBool buildInsideParent = TRUE);
00156 ~SoWinColorEditor();
00157
00172 void attach(SoSFColor *color, SoBase *node);
00177 void attach(SoMFColor *color, int index, SoBase *node);
00178
00179 #if !defined(__sgi)
00180
00183 void attach(SoMFUInt32 *color, int index, SoBase *node);
00184 #endif
00185
00191 void detach();
00195 SbBool isAttached() { return attached; }
00196
00203 inline void addColorChangedCallback(
00204 SoWinColorEditorCB *f,
00205 void *userData = NULL);
00210 inline void removeColorChangedCallback(
00211 SoWinColorEditorCB *f,
00212 void *userData = NULL);
00213
00218 void setColor(const SbColor &color);
00222 const SbColor & getColor() { return baseRGB; }
00223
00238 void setWYSIWYG(SbBool trueOrFalse);
00242 SbBool isWYSIWYG() { return WYSIWYGmode; }
00243
00247 void setCurrentSliders(SoWinColorEditor::Sliders whichSliders);
00251 SoWinColorEditor::Sliders getCurrentSliders() { return whichSliders; }
00252
00256 void setUpdateFrequency(SoWinColorEditor::UpdateFrequency freq);
00260 SoWinColorEditor::UpdateFrequency getUpdateFrequency()
00261 { return updateFreq; }
00262
00263
00264 SbBool alwaysOnTop;
00265 private:
00266
00267
00268
00269
00270
00271 SoEXTENDER
00272 SoWinColorEditor(
00273 SoWidget parent,
00274 const char *name,
00275 SbBool buildInsideParent,
00276 SbBool buildNow);
00277
00278
00279 virtual SbString getDefaultWidgetName() const;
00280 virtual SbString getDefaultTitle() const;
00281 virtual SbString getDefaultIconTitle() const;
00282
00283 private:
00284
00285 #ifdef _WIN32
00286 POINT sliderPos[6] ;
00287 POINT sliderLabPos[6] ;
00288 POINT sliderValPos[6] ;
00289 RECT areaPos[6] ;
00290 RECT rcDlg ;
00291
00292 unsigned long sliderId[6] ;
00293 unsigned long sliderLabId[6] ;
00294 unsigned long sliderValId[6] ;
00295 unsigned long areaId[6] ;
00296 unsigned long nCurrSliderId ;
00297 unsigned long nCurrEditId ;
00298
00299 HMENU menubar ;
00300 HGLOBAL hDlgTemplate;
00301
00302 CBitButton *lpleftButton ;
00303 CBitButton *lprightButton ;
00304 CBitButton *lpswitchButton ;
00305
00306 void finishBuild() ;
00307 void getControlPositions() ;
00308 void hideAllSliders() ;
00309 void showAllSliders() ;
00310 void moveSlider(int nSlider,int nPos) ;
00311 void showSlider(int nSlider) ;
00312 void hideSlider(int nSlider) ;
00313 void showControl(int nId) ;
00314 void hideControl(int nId) ;
00315 void sizeToArea(int n) ;
00316 void layoutAccept(WBOOL nReduceOk) ;
00317 void showArea0() ;
00318 void showArea1() ;
00319 void showArea2() ;
00320 void showArea3() ;
00321 void showArea4() ;
00322 void showArea5() ;
00323
00324 static WBOOL CALLBACK mgrDlgProc( Hwnd hdlg, UINT message,
00325 WPARAM wParam, LPARAM lParam );
00326 static void onCommand(
00327 Hwnd hdlg,
00328 int id,
00329 Hwnd hCtrl,
00330 UINT codeNotify ) ;
00331
00332 void handleEdit(
00333 int nSlider,
00334 Hwnd hEdit,
00335 UINT codeNotify) ;
00336
00337 WBOOL handleDrawItem(
00338 WPARAM wParam,
00339 LPARAM lParam ) ;
00340
00341
00342 #endif
00343
00344
00345 SoWidget buildWidget(SoWidget parent);
00346 static void visibilityChangeCB(void *pt, SbBool visible);
00347
00348
00349 SoWidget mgrWidget;
00350 SbBool WYSIWYGmode;
00351 Sliders whichSliders;
00352 SbColor baseRGB;
00353 float baseHSV[3];
00354 SbBool ignoreCallback;
00355 SoWinColorSlider *sliders[6];
00356 SoWinColorWheel *wheel;
00357 SoWinColorPatch *current, *previous;
00358 ColorEditorCBData *dataId;
00359 SbPList menuItems;
00360 SoWinColorEditor::UpdateFrequency updateFreq;
00361
00362
00363 SbBool attached;
00364 SoBase *editNode;
00365 SoSFColor *colorSF;
00366 SoMFColor *colorMF;
00367 SoNodeSensor *colorSensor;
00368 SoCallbackList *callbackList;
00369 int index;
00370
00371 #if !defined(__sgi)
00372
00373 SoMFUInt32 *colorUInt32MF;
00374 float transparency;
00375 #endif
00376
00377
00378 SoWinClipboard *clipboard;
00379 void copy(Time eventTime);
00380 void paste(Time eventTime);
00381
00382 void pasteDone(SoPathList *pathList);
00383 static void pasteDoneCB(void *userData, SoPathList *pathList);
00384
00385
00386 SoWidget acceptButton, slidersForm, buttonsForm, wheelForm;
00387
00388
00389 SoWidget buildPulldownMenu(SoWidget parent);
00390 SoWidget buildControls(SoWidget parent);
00391 SoWidget buildSlidersForm(SoWidget parent);
00392
00393 void doSliderLayout();
00394 void doDynamicTopLevelLayout();
00395 int numberOfSliders(SoWinColorEditor::Sliders slider);
00396
00397
00398
00399 void doUpdates();
00400
00401
00402 void fieldChanged();
00403 static void fieldChangedCB(void *, SoSensor *);
00404
00405
00406 static void wheelCallback(void *, const float hsv[3]);
00407 void wheelChanged(const float hsv[3]);
00408 static void sliderCallback(void *, float);
00409 void sliderChanged(short id, float value);
00410
00411 #ifdef _WIN32
00412 void buttonsCallback(int id);
00413 #else
00414 static void buttonsCallback(SoWidget, ColorEditorCBData *, XtPointer);
00415 #endif
00416 void buttonPressed(short id);
00417
00418 #ifdef _WIN32
00419 void editMenuCallback(int id);
00420 void sliderMenuCallback(int id);
00421 #else
00422 static void editMenuCallback(SoWidget, ColorEditorCBData *, XmAnyCallbackStruct *);
00423 static void sliderMenuCallback(SoWidget, ColorEditorCBData *, XtPointer);
00424 #endif
00425
00426 static void menuDisplay(SoWidget, SoWinColorEditor *editor, XtPointer);
00427
00428
00429 void constructorCommon(SbBool buildNow);
00430
00431 };
00432
00433
00434 void
00435 SoWinColorEditor::addColorChangedCallback(
00436 SoWinColorEditorCB *f,
00437 void *userData)
00438 { callbackList->addCallback((SoCallbackListCB *) f, userData); }
00439
00440 void
00441 SoWinColorEditor::removeColorChangedCallback(
00442 SoWinColorEditorCB *f,
00443 void *userData)
00444 { callbackList->removeCallback((SoCallbackListCB *) f, userData); }
00445
00446
00447 #ifdef _WIN32
00448 #include <Inventor/Win/SoWinEndStrict.h>
00449 #endif
00450 #endif
00451
00452