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
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104 #ifndef INC_COLDLOG
00105 #define INC_COLDLOG
00106
00107 #include "collist.h"
00108
00109 #include "colourix.h"
00110
00111
00112 #include "dragcol.h"
00113
00114
00115 struct ReDrawInfoType;
00116 class ColourDropDown;
00117 class OpColEditCommand;
00118 class Cursor;
00119 class KeyPress;
00120 class Layer;
00121 class ColourListComponent;
00122 class DialogColourInfo;
00123
00124
00125
00126
00127
00128
00129
00130
00131
00132
00133
00134
00135 typedef enum
00136 {
00137 CEDRAG_NONE,
00138
00139 CEDRAG_DEFAULT_COMPONENT1,
00140 CEDRAG_DEFAULT_COMPONENT2,
00141 CEDRAG_DEFAULT_COMPONENT3,
00142 CEDRAG_DEFAULT_COMPONENT4,
00143
00144 CEDRAG_HSVPICKER_HSWHEEL,
00145 CEDRAG_HSVPICKER_VSLIDER,
00146
00147 CEDRAG_HSVPICKER_HSLIDER,
00148 CEDRAG_HSVPICKER_VSSQUARE,
00149
00150 CEDRAG_RGBPICKER_XY,
00151 CEDRAG_RGBPICKER_Z,
00152 CEDRAG_RGBPICKER_BRIGHT,
00153
00154 CEDRAG_CMYKPICKER_XY,
00155 CEDRAG_CMYKPICKER_Z,
00156 CEDRAG_CMYKPICKER_KEY,
00157
00158 CEDRAG_TINTORSHADE
00159 } ColEditDragArea;
00160
00161
00162
00163 typedef struct
00164 {
00165 IndexedColourType ColType;
00166 INT32 Folded;
00167 ColourModel DisplayModel;
00168 IndexedColour *ResultColour;
00169 BOOL Initialised;
00170 BOOL ParentListOK;
00171 } ColEditState;
00172
00173
00174
00175 typedef enum
00176 {
00177 CROSSCONSTRAINED_NONE,
00178 CROSSCONSTRAINED_HORZ,
00179 CROSSCONSTRAINED_VERT,
00180 CROSSCONSTRAINED_BOTH
00181 } CrossConstraint;
00182
00183
00184
00185
00186 enum AbortColourState { SAVE_ABORTCOLOUR, SAVED_ABORTCOLOUR };
00187
00188
00189
00190
00191
00192
00193
00194
00195
00196
00197
00198
00199
00200
00201
00202
00203
00204
00205
00206
00207
00208
00209 #define OPTOKEN_COLOUREDITDLG _T("ColourPicker")
00210
00211 #define COLED_TIMER_ID 76
00212 #define COLED_TIMER_FREQUENCY 100
00213
00214 class ColourEditDlg: public DialogOp
00215 {
00216 friend class ColEditorDragTarget;
00217 friend class ColourPicker;
00218 friend class OpColEditCommand;
00219
00220 CC_DECLARE_DYNCREATE(ColourEditDlg)
00221
00222 public:
00223 ColourEditDlg();
00224 ~ColourEditDlg();
00225
00226
00227 public:
00228 static void InvokeDialog(ColourList *ParentList, IndexedColour *ColourToEdit);
00229
00230
00231
00232 static BOOL CanYouEditThis(ColourList *ParentList, IndexedColour *ColourToEdit,
00233 BOOL ForceNewMode = FALSE);
00234
00235
00236
00237
00238 static void ForceLineOrFillMode(BOOL PreferLineColour = FALSE);
00239
00240
00241
00242 public:
00243 MsgResult Message(Msg *Message);
00244
00245 void Do(OpDescriptor *MyOpDesc);
00246 void DoWithParam(OpDescriptor *MyOpDesc, OpParam *Param);
00247
00248 static BOOL Init();
00249 BOOL Create();
00250 static OpState GetState(String_256*, OpDescriptor*);
00251
00252 static const ResourceID IDD;
00253
00254 static const CDlgMode Mode;
00255
00256 virtual BOOL TimedProcessing(void);
00257 BOOL UpdateColourEditor ();
00258
00259 BOOL StartingPickerDrag();
00260 BOOL EndingPickerDrag();
00261
00262 private:
00263 BOOL MakeNewNColour(void);
00264 BOOL MakeColourASpot(void);
00265
00266
00267 protected:
00268 OpState GetCommandState(StringBase *Command, StringBase *ShadeReason);
00269
00270
00271 void DoCommand(StringBase *Command);
00272
00273
00274
00275 public:
00276 static BOOL OnKeyPress(KeyPress* pKeyPress);
00277
00278
00279
00280 protected:
00281 static INT32 DefaultDisplayModel;
00282 static INT32 DefaultDisplayModelN;
00283 static INT32 AutoModelChange;
00284 static INT32 AutoModelChangeN;
00285 static INT32 Folded;
00286 static INT32 SplitLineDisplay;
00287 static INT32 Use3DDisplay;
00288 static BOOL bHSVHueAtTop;
00289 static BOOL bUsePrintCMYK;
00290
00291 static BOOL SetUnitGroupDefaults(ColourModel ColModel);
00292
00293 static AbortColourState abortColourState;
00294
00295
00296 static BOOL EscapeKeyWasPressed;
00297
00298
00299 public:
00300
00301
00302
00303
00304
00305
00306
00307
00308
00309 static ColourEditDlg* GetColourEditDlg () { return (TheEditor); }
00310
00311 static void SetEditingColour (IndexedColour* newEditingColour, Node* pSourceNode = NULL);
00312 static void SetAbortColourState (AbortColourState state) { abortColourState = state; }
00313
00314 static void ApplyEditingColourNow (BOOL UseAbortColour = FALSE);
00315 static BOOL DoAbortColourNow (CWindowID colourPicker);
00316 static void DoHandleNamedcolour ();
00317
00318 static void SetDefaultDisplayModel (INT32 newDisplayModel);
00319
00320
00321
00322
00323 void CloseColourEditor ();
00324
00325 void SetDoTimerProcessing(BOOL Value);
00326 BOOL GetDoTimerProcessing();
00327
00328 static void AbortColourPickerDrag();
00329
00330
00331
00332
00333
00334
00335
00336 protected:
00337 static ColourEditDlg *TheEditor;
00338
00339 BOOL AmShaded;
00340
00341 IndexedColour OriginalColour;
00342 IndexedColour *ResultColour;
00343 IndexedColour *EditingColour;
00344 IndexedColour *OriginalEditingColour;
00345 ColourList *ParentList;
00346
00347 BOOL NoFillButtonDown;
00348 static BOOL EditingLineColour;
00349 BOOL FirstEdit;
00350
00351
00352 static BOOL UpdateOnNextIdle;
00353
00354
00355 static ColourModel DisplayModel;
00356 static INT32 ColourPickerMode;
00357
00358 BOOL ISentTheMessage;
00359
00360 ColourDropDown *NameDropDown;
00361 ColourDropDown *ParentDropDown;
00362
00363 static BOOL resetColPickPos;
00364
00365 static RECT colPickOrigRect;
00366
00367 static BOOL needColPickHidden;
00368 static BOOL colPickHidden;
00369
00370 protected:
00371 ColEditDragArea DragStartArea;
00372
00373 DocCoord LastDragPos;
00374
00375 DocCoord DragAnchor;
00376
00377
00378 BOOL DragUpdatedOnIdle;
00379 ColourGeneric ColourBeforeDrag;
00380
00381
00382 IndexedColour *AbortColour;
00383
00384
00385 protected:
00386 void CloseMyself(void);
00387
00388
00389 void ShadeMyself(BOOL UnShade = FALSE, BOOL OtherGadgetsOnly = FALSE);
00390
00391 void SetControls(void);
00392
00393 void SetColourNameList(void);
00394
00395 void RedrawColourNameList(void);
00396
00397
00398 void SetExtent(void);
00399
00400 void InvalidateAndSetControls(void);
00401
00402
00403 void InvalidatePatchGadget(ReDrawInfoType *Info = NULL);
00404
00405
00406 void SetColour(BOOL SetComponents = TRUE);
00407
00408
00409
00410 void SetComponentInfo(UINT32 ComponentID, UINT32 NameGadget,
00411 UINT32 WritableGadget, UINT32 InheritGadget);
00412
00413
00414 void SetAllHexComponentsInfo(UINT32 ComponentID, UINT32 NameGadget,
00415 UINT32 WritableGadget);
00416
00417
00418 void FindUsefulColourToEdit(BOOL WantLineColour = FALSE,
00419 BOOL TheWindowIsOpen = TRUE);
00420
00421
00422
00423 void ApplyNoColour(BOOL LineColour);
00424 void LimitTo216Only();
00425 FIXED24 Nearest20Percent(FIXED24 n);
00426
00427 void EditThisColour(ColourList *ParentList, IndexedColour *ColourToEdit,
00428 BOOL TheWindowIsOpen = TRUE);
00429
00430
00431 void EditingColourHasChanged(BOOL RedrawControls = TRUE, BOOL RedrawPicker = TRUE,
00432 BOOL FastTrackPicker = FALSE,
00433 Node* pSourceNode = NULL);
00434
00435
00436 void ApplyColourNow(IndexedColour *ColourToApply);
00437
00438
00439 IndexedColour *FindSafeParent(IndexedColour *SuggestedParent, BOOL ChildIsATint);
00440
00441
00442 void CompileParentColourList(CGadgetID TargetGadget);
00443
00444
00445
00446 IndexedColour *DecodeParentColourListSelection(INT32 Index);
00447
00448
00449 BOOL OnMakeLocalToFrame();
00450 BOOL ShouldUngrey(IndexedColour *pCol);
00451
00452 protected:
00453 void ResetState(void);
00454 ColEditState State;
00455
00456 BOOL IsSetGadgetValueCalled() const;
00457 BOOL EnteredSetGadgetValue();
00458 BOOL ExitedSetGadgetValue();
00459
00460 BOOL m_bDoingSetGadget;
00461
00462 protected:
00463
00464 static BOOL GetColourContext(ColourModel ColModel, ColourContext** ppContext);
00465
00466
00467 void RenderCross(RenderRegion *pRender, DocRect *CrossRect,
00468 INT32 PixelSize, BOOL Shaded = FALSE);
00469
00470
00471 void RenderParentCross(RenderRegion *pRender, DocRect *CrossRect, INT32 PixelSize);
00472
00473
00474 void RenderConstraint(RenderRegion *pRender, DocCoord End1, DocCoord End2);
00475
00476
00477 void RenderControl(UINT32 GadgetToRender, ReDrawInfoType* RedrawInfo);
00478
00479
00480 void RenderPickerHSV(RenderRegion *pRender, DocRect *VirtualSize,
00481 INT32 PixelSize, DialogColourInfo *RedrawColours,
00482 DocRect *pClipRect);
00483
00484 void RenderPickerRGB(RenderRegion *pRender, DocRect *VirtualSize,
00485 INT32 PixelSize, DialogColourInfo *RedrawColours);
00486
00487 void RenderPickerCMYK(RenderRegion *pRender, DocRect *VirtualSize,
00488 INT32 PixelSize, DialogColourInfo *RedrawColours);
00489
00490 void RenderPickerDefault(RenderRegion *pRender, DocRect *VirtualSize,
00491 INT32 PixelSize, DialogColourInfo *RedrawColours);
00492
00493 void RenderPickerTint(RenderRegion *pRender, DocRect *VirtualSize,
00494 INT32 PixelSize, DialogColourInfo *RedrawColours);
00495
00496 void RenderPickerShade(RenderRegion *pRender, DocRect *VirtualSize,
00497 INT32 PixelSize, DialogColourInfo *RedrawColours,
00498 DocRect *pClipRect);
00499
00500 void RenderPickerSliderH(RenderRegion *pRender, DocRect *SliderRect,
00501 INT32 PixelSize, FIXED24 DisplayValue,
00502 DocColour *LeftCol, DocColour *RightCol,
00503 DocColour *TopLeftCol, DocColour *TopRightCol,
00504 BOOL Shaded = FALSE);
00505
00506
00507 protected:
00508
00509
00510 void StartDrag(ReDrawInfoType *Info);
00511 void UpdateDrag(ReDrawInfoType *Info);
00512 void EndDrag(ReDrawInfoType *Info);
00513
00514
00515
00516 void SetNewValueFromMousePos(ReDrawInfoType *Info, BOOL StartingNewDrag);
00517
00518
00519 void SetNewValueHSV(ReDrawInfoType *Info, INT32 PixelSize, BOOL StartingNewDrag);
00520 void SetNewValueRGB(ReDrawInfoType *Info, INT32 PixelSize, BOOL StartingNewDrag);
00521 void SetNewValueCMYK(ReDrawInfoType *Info, INT32 PixelSize, BOOL StartingNewDrag);
00522 void SetNewValueDefault(ReDrawInfoType *Info, INT32 PixelSize, BOOL StartingNewDrag);
00523 void SetNewValueTint(ReDrawInfoType *Info, INT32 PixelSize, BOOL StartingNewDrag);
00524 void SetNewValueShade(ReDrawInfoType *Info, INT32 PixelSize, BOOL StartingNewDrag);
00525
00526
00527 BOOL HandleIdlePointer(ReDrawInfoType *Info, String_128 *BubbleHelp, String_256 *StatusHelp, UINT32 *ControlID);
00528 BOOL HandleIdlePointerHSV(ReDrawInfoType *Info, String_128 *BubbleHelp, String_256 *StatusHelp);
00529 BOOL HandleIdlePointerRGB(ReDrawInfoType *Info, String_128 *BubbleHelp, String_256 *StatusHelp);
00530 BOOL HandleIdlePointerCMYK(ReDrawInfoType *Info, String_128 *BubbleHelp, String_256 *StatusHelp);
00531 BOOL HandleIdlePointerDefault(ReDrawInfoType *Info, String_128 *BubbleHelp, String_256 *StatusHelp);
00532 BOOL HandleIdlePointerTint(ReDrawInfoType *Info, String_128 *BubbleHelp, String_256 *StatusHelp);
00533 BOOL HandleIdlePointerShade(ReDrawInfoType *Info, String_128 *BubbleHelp, String_256 *StatusHelp);
00534
00535
00536 CrossConstraint CalcCrossRectRGB(ColourRGBT *SourceColour, DocRect *SquareRect, INT32 PixelSize,
00537 DocRect *Result);
00538 CrossConstraint CalcCrossRectCMYK(ColourCMYK *SourceColour, DocRect *SquareRect, INT32 PixelSize,
00539 DocRect *Result);
00540
00541
00542
00543
00544 void SetCursor(UINT32 CursorResID);
00545
00546
00547 protected:
00548 void EndTimedProcessing();
00549 void BeginTimedProcessing();
00550 UINT32 CurrentCursorID;
00551 Cursor *CurrentCursor;
00552
00553 BOOL m_bDoTimerProcessing;
00554
00555 void HideGadgetList(CGadgetID * Gadgets, BOOL Hide=TRUE);
00556 void HideOrShowColourPicker();
00557 void CheckDialogSize();
00558
00559 BOOL m_NeedsResize;
00560 void NeedsResize() {m_NeedsResize = TRUE;}
00561
00562 virtual BOOL OnIdleEvent();
00563
00564 private:
00565 void LoseKeyboardFocus(void);
00566
00567 };
00568
00569
00570
00571
00572
00573
00574
00575
00576
00577
00578
00579
00580
00581
00582
00583
00584
00585
00586
00587
00588
00589
00590
00591
00592
00593
00594
00595 class ColEditorDragTarget : public KernelDragTarget
00596 {
00597 friend class DragManagerOp;
00598
00599 CC_DECLARE_DYNAMIC(ColEditorDragTarget)
00600
00601 public:
00602 ColEditorDragTarget(DialogOp *TheDialog, CGadgetID TheGadget = NULL);
00603
00604 virtual UINT32 GetCursorID();
00605 virtual BOOL GetStatusLineText(String_256 * TheText);
00606
00607 protected:
00608
00609 virtual BOOL ProcessEvent(DragEventType Event,
00610 DragInformation *pDragInfo,
00611 OilCoord *pMousePos, KeyPress* pKeyPress);
00612
00613
00614 BOOL CanDropHere(DragInformation *pDragInfo);
00615 };
00616
00617
00618
00619
00620
00621
00622
00623
00624
00625
00626
00627
00628
00629
00630 class ColEditorDragInfo : public ColourDragInformation
00631 {
00632 CC_DECLARE_DYNCREATE(ColEditorDragInfo)
00633
00634 public:
00635 ColEditorDragInfo();
00636 ColEditorDragInfo(IndexedColour *Colour, BOOL IsAdjust, Document* pParent);
00637 };
00638
00639
00640
00641
00642
00643
00644
00645
00646
00647
00648
00649
00650
00651
00652 class CCAPI OpMakeColourLocalToFrame: public UndoableOperation
00653 {
00654 CC_DECLARE_DYNCREATE( OpMakeColourLocalToFrame )
00655
00656 public:
00657 OpMakeColourLocalToFrame();
00658 ~OpMakeColourLocalToFrame();
00659
00660 static BOOL Init();
00661 static OpState GetState(String_256 *, OpDescriptor *);
00662 void Do(OpDescriptor *);
00663 void DoWithParam(OpDescriptor *, OpParam *);
00664 virtual void PerformMergeProcessing() ;
00665
00666 virtual BOOL Undo();
00667 virtual BOOL Redo();
00668
00669 protected:
00670 BOOL ReplaceColourOnActiveLayer(IndexedColour *pOld, IndexedColour *pNew);
00671 BOOL IsColourLocalToFrame(Layer *pTheLayer, IndexedColour *pCol);
00672 IndexedColour *MakeColourLocalToFrame(IndexedColour *pCol);
00673
00674 protected:
00675 ColourList *ParentList;
00676 Document *pOurDoc;
00677 Layer *pActiveLayer;
00678 ColourListComponent *ColComp;
00679 Operation *m_pPreviousOp;
00680 };
00681
00682
00683
00684
00685 #endif
00686