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
00105 #include "camtypes.h"
00106
00107 #include "dlgmgr.h"
00108 #include "colcontx.h"
00109 #include "coldlog.h"
00110 #include "collist.h"
00111 #include "colormgr.h"
00112 #include "colourix.h"
00113 #include "colpick.h"
00114
00115 #include "scunit.h"
00116 #include "ctrlhelp.h"
00117
00118
00119
00120
00121
00122 wxSize ColourPicker::s_LastSize = wxDefaultSize;
00123 wxSize ColourPicker::s_UserSize = wxSize(245,245);
00124 wxSize ColourPicker::s_MinSize = wxSize(180,100);
00125 BOOL ColourPicker::s_InColourDialogLayout = FALSE;
00126 BOOL ColourPicker::s_JustCreated = FALSE;
00127 INT32 ColourPicker::s_IdleCounter = 0;
00128
00129 CC_IMPLEMENT_MEMDUMP(ColourPicker, CCObject)
00130
00131 #define new CAM_DEBUG_NEW
00132
00133
00134
00135
00136
00137
00138
00139
00140
00141
00142
00143
00144
00145
00146 static String_128 PickerBubbleBuffer("");
00147 static String_256 StatusHelpBuffer("");
00148
00149
00150
00151
00152
00153
00154
00155
00156
00157
00158
00159
00160
00161
00162
00163
00164
00165
00166 ColourPicker::ColourPicker()
00167 {
00168 }
00169
00170
00171
00172
00173
00174
00175
00176
00177
00178
00179
00180
00181
00182
00183
00184
00185
00186
00187
00188 ColourPicker::~ColourPicker()
00189 {
00190 }
00191
00192
00193
00194
00195
00196
00197
00198
00199
00200
00201
00202
00203
00204
00205
00206
00207
00208
00209
00210
00211
00212
00213
00214
00215
00216
00217
00218
00219
00220
00221
00222
00223
00224
00225
00226
00227
00228
00229
00230
00231
00232
00233
00234
00235
00236
00237
00238
00239
00240
00241
00242
00243
00244
00245
00246
00247
00248
00249
00250
00251
00252
00253
00254
00255
00256
00257
00258
00259
00260
00261
00262
00263
00264
00265
00266
00267
00268
00269
00270
00271
00272
00273
00274
00275 void ColourPicker::EditColour(ColourList *ParentList, IndexedColour *SourceAndResult,
00276 BOOL PreferLineColour)
00277 {
00278 #if FALSE
00279
00280
00281
00282
00283
00284
00285
00286
00287
00288
00289
00290
00291
00292
00293
00294
00295
00296
00297
00298
00299
00300
00301
00302
00303
00304
00305
00306
00307
00308
00309
00310
00311
00312
00313
00314
00315
00316
00317
00318
00319
00320
00321
00322
00323
00324
00325
00326
00327
00328
00329
00330
00331
00332
00333
00334
00335
00336
00337
00338
00339
00340
00341
00342
00343
00344
00345
00346
00347
00348
00349
00350
00351
00352
00353
00354
00355
00356
00357
00358
00359
00360
00361
00362
00363
00364
00365 #endif
00366 {
00367 #ifndef STANDALONE
00368
00369
00370 if (SourceAndResult == NULL)
00371 ColourEditDlg::ForceLineOrFillMode(PreferLineColour);
00372
00373 ColourEditDlg::InvokeDialog(ParentList, SourceAndResult);
00374 #endif
00375 }
00376 }
00377
00378
00379
00380
00381
00382
00383
00384
00385
00386
00387
00388
00389
00390
00391
00392
00393
00394
00395
00396
00397
00398
00399
00400
00401
00402
00403 BOOL ColourPicker::GetStatusLineText(ColourEditDlg *Editor, UINT32 GadgetID, String_256 *Result)
00404 {
00405 #ifndef STANDALONE
00406
00407 IndexedColour *Bob = Editor->EditingColour;
00408 if (Bob == NULL)
00409 {
00410 *Result = String_256(_R(IDS_EDITST_NOCOLOUR));
00411 return(TRUE);
00412 }
00413
00414 ColourContext *cc = ColourContext::GetGlobalDefault(ColourEditDlg::DisplayModel);
00415
00416
00417 *Result = String_256(_R(IDS_EDITST_DEFAULT));
00418
00419 if (FALSE) {}
00420
00421
00422
00423
00424 else if (GadgetID == _R(IDC_EDIT_DROPMENU))
00425 {
00426 *Result = String_256(_R(IDS_EDITST_MENU));
00427 }
00428 else if (GadgetID == _R(IDC_EDIT_COMPONENT1))
00429 {
00430 if (ColourEditDlg::DisplayModel == COLOURMODEL_HSVT)
00431 {
00432 *Result = String_256(_R(IDS_EDITST_COMP1));
00433 }
00434 else
00435 {
00436 if (cc != NULL)
00437 {
00438 String_64 CompName;
00439 cc->GetComponentName(1, &CompName, TRUE);
00440 Result->MakeMsg(_R(IDS_EDITST_COMP234), (TCHAR *)CompName);
00441 }
00442 }
00443 }
00444 else if (GadgetID == _R(IDC_EDIT_COMPONENT2))
00445 {
00446 if (cc != NULL)
00447 {
00448 String_64 CompName;
00449 cc->GetComponentName(2, &CompName, TRUE);
00450 Result->MakeMsg(_R(IDS_EDITST_COMP234), (TCHAR *)CompName);
00451 }
00452 }
00453 else if (GadgetID == _R(IDC_EDIT_COMPONENT3))
00454 {
00455 if (cc != NULL)
00456 {
00457 String_64 CompName;
00458 cc->GetComponentName(3, &CompName, TRUE);
00459 Result->MakeMsg(_R(IDS_EDITST_COMP234), (TCHAR *)CompName);
00460 }
00461 }
00462
00463 #ifndef WEBSTER
00464 else if (GadgetID == _R(IDC_EDIT_COMPONENT4))
00465 {
00466 if (cc != NULL)
00467 {
00468 String_64 CompName;
00469 cc->GetComponentName(4, &CompName, TRUE);
00470 Result->MakeMsg(_R(IDS_EDITST_COMP234), (TCHAR *)CompName);
00471 }
00472 }
00473 else if (GadgetID == _R(IDC_EDIT_COLMODEL))
00474 {
00475 *Result = String_256(_R(IDS_EDITST_COLMODEL));
00476 }
00477 else if (GadgetID == _R(IDC_EDIT_NAMEMENU))
00478 {
00479 *Result = String_256(_R(IDS_EDITST_NAME));
00480 }
00481 else if (GadgetID == _R(IDC_EDIT_COLTYPE))
00482 {
00483 *Result = String_256(_R(IDS_EDITST_COLTYPE));
00484 }
00485 else if ((GadgetID == _R(IDC_EDIT_INHERIT1)) ||
00486 (GadgetID == _R(IDC_EDIT_INHERIT2)) ||
00487 (GadgetID == _R(IDC_EDIT_INHERIT3)) ||
00488 (GadgetID == _R(IDC_EDIT_INHERIT4)))
00489 {
00490 *Result = String_256(_R(IDS_EDITST_INHERIT));
00491 }
00492
00493
00494
00495
00496
00497 else if ((GadgetID == _R(IDC_EDIT_PARENTCOL)) ||
00498 (GadgetID == _R(IDC_EDIT_PARENTNAME)))
00499 {
00500 *Result = String_256(_R(IDS_EDITST_PARENTCOL));
00501 }
00502 else if ((GadgetID == _R(IDC_EDIT_TINT)) ||
00503 (GadgetID == _R(IDC_EDIT_TINTSLIDER)))
00504 {
00505 if (Bob->GetType() == COLOURTYPE_TINT && !Bob->TintIsShade())
00506 *Result = String_256(_R(IDS_EDITST_TINT1));
00507 else
00508 *Result = String_256(_R(IDS_EDITST_TINT2));
00509 }
00510 else if (GadgetID == _R(IDC_EDIT_SHADE))
00511 {
00512 *Result = String_256(_R(IDS_EDITST_TINT2));
00513 }
00514 else if (GadgetID == _R(IDC_EDIT_ADVANCED))
00515 {
00516 if (Editor->Folded)
00517 *Result = String_256(_R(IDS_EDITST_ADVANCED1));
00518 else
00519 *Result = String_256(_R(IDS_EDITST_ADVANCED2));
00520 }
00521 else if (GadgetID == _R(IDC_EDIT_3D))
00522 {
00523 *Result = String_256(_R(IDS_EDITST_3D));
00524 }
00525 else if (GadgetID == _R(IDC_EDIT_MAKESTYLE))
00526 {
00527 *Result = String_256(_R(IDS_EDITST_MAKESTYLE));
00528 }
00529 #endif // WEBSTER
00530 else if (GadgetID == _R(IDC_EDIT_PICKER))
00531 {
00532 if (!StatusHelpBuffer.IsEmpty())
00533 *Result = StatusHelpBuffer;
00534 else
00535 {
00536 switch(Bob->GetType())
00537 {
00538
00539 #ifndef WEBSTER
00540 case COLOURTYPE_TINT:
00541 if (Editor->Folded)
00542 *Result = String_256(_R(IDS_EDITST_PICKER1));
00543 else
00544 *Result = String_256(_R(IDS_EDITST_PICKER2));
00545 break;
00546
00547 case COLOURTYPE_LINKED:
00548 *Result = String_256(_R(IDS_EDITST_PICKER3));
00549 break;
00550 #endif // WEBSTER
00551
00552 case COLOURTYPE_NORMAL:
00553 case COLOURTYPE_SPOT:
00554 default:
00555 *Result = String_256(_R(IDS_EDITST_PICKER4));
00556 break;
00557 }
00558 }
00559 }
00560 else if (GadgetID == _R(IDC_EDIT_216ONLY))
00561 {
00562 *Result = String_256(_R(IDS_EDITST_216ONLY));
00563 }
00564 else if (GadgetID == _R(IDC_COLOURPICKER))
00565 {
00566 *Result = String_256(_R(IDS_STATICCOLOURPICKERTOOLHELP));
00567 }
00568 else if (GadgetID == _R(IDC_MAKE_LOCAL))
00569 {
00570 *Result = String_256(_R(IDS_EDITST_MAKE_LOCAL));
00571 }
00572 else if (GadgetID == _R(IDC_EDIT_NOCOLOUR))
00573 {
00574 *Result = String_256(_R(IDS_EDITST_SETNOCOLOUR));
00575 }
00576 else if (GadgetID == _R(IDC_EDIT_RENAME))
00577 {
00578 *Result = String_256(_R(IDS_EDITST_RENAME));
00579 }
00580 else if (GadgetID == _R(IDC_EDIT_LINEFILL))
00581 {
00582 *Result = String_256(_R(IDS_EDITST_LINEFILL));
00583 }
00584 #endif
00585 return(TRUE);
00586 }
00587
00588
00589
00590
00591
00592
00593
00594
00595
00596
00597
00598
00599
00600
00601
00602
00603
00604
00605
00606
00607
00608
00609
00610
00611
00612
00613
00614
00615 #ifndef STANDALONE
00616 static UINT32 GadgetList[] =
00617 {
00618
00619 _R(IDC_EDIT_DROPMENU),
00620 _R(IDC_EDIT_COMPONENT1),
00621 _R(IDC_EDIT_COMPONENT2),
00622 _R(IDC_EDIT_COMPONENT3),
00623 _R(IDC_EDIT_COMPONENT4),
00624 _R(IDC_EDIT_COLMODEL),
00625 _R(IDC_EDIT_NAMEMENU),
00626 _R(IDC_EDIT_COLTYPE),
00627 _R(IDC_EDIT_INHERIT1),
00628 _R(IDC_EDIT_INHERIT2),
00629 _R(IDC_EDIT_INHERIT3),
00630 _R(IDC_EDIT_INHERIT4),
00631 _R(IDC_EDIT_PICKER),
00632 _R(IDC_EDIT_PATCH),
00633 _R(IDC_EDIT_PARENTPATCH),
00634 _R(IDC_EDIT_PARENTCOL),
00635 _R(IDC_EDIT_TINT),
00636 _R(IDC_EDIT_SHADE),
00637 _R(IDC_EDIT_ADVANCED),
00638 _R(IDC_EDIT_PARENTNAME),
00639
00640
00641 _R(IDC_EDIT_3D),
00642 _R(IDC_EDIT_MAKESTYLE),
00643
00644 _R(IDC_EDIT_NOCOLOUR),
00645 _R(IDC_EDIT_LINEFILL),
00646 _R(IDC_EDIT_216ONLY),
00647 _R(IDC_MAKE_LOCAL),
00648 _R(IDC_EDIT_RENAME),
00649 _R(IDC_COLOURPICKER),
00650 0
00651 };
00652 #endif
00653
00654
00655 BOOL ColourPicker::GetStatusLineText(String_256 *Result)
00656 {
00657 #ifndef STANDALONE
00658
00659 ERROR3IF(Result == NULL, "Illegal NULL param");
00660
00661 ColourEditDlg *Editor = ColourEditDlg::TheEditor;
00662 if (Editor == NULL)
00663 return(FALSE);
00664
00665
00666 CWindowID TheWindow = (CWindowID)Editor->WindowID;
00667 if (TheWindow == NULL)
00668 return(FALSE);
00669
00670 wxPoint mousepos = ::wxGetMousePosition();
00671 wxWindow * window=::wxChildWindowFromPoint(TheWindow, mousepos, FALSE, -1);
00672 if ((!window) || (window!=::wxChildWindowFromPoint(mousepos, FALSE, -1)))
00673 return FALSE;
00674
00675 return GetStatusLineText(Editor, window->GetId(), Result);
00676 #else
00677 return(TRUE);
00678 #endif
00679 }
00680
00681
00682
00683
00684
00685
00686
00687
00688
00689
00690
00691
00692
00693
00694
00695
00696
00697
00698
00699
00700
00701
00702 TCHAR *ColourPicker::HelpCallbackHandler(CWindowID Window, UINT32 Item, void *UserData)
00703 {
00704 #ifndef STANDALONE
00705 static String_256 HelpStringStore;
00706 BOOL ReturnVal = FALSE;
00707
00708 ColourEditDlg *Editor = ColourEditDlg::TheEditor;
00709 if (Editor == NULL)
00710 return(NULL);
00711
00712 IndexedColour *Bob = Editor->EditingColour;
00713
00714 ColourContext *cc = NULL;
00715 if (Bob != NULL)
00716 cc = ColourContext::GetGlobalDefault(ColourEditDlg::DisplayModel);
00717
00718 if (FALSE) {}
00719 else if (Item == _R(IDC_EDIT_DROPMENU))
00720 {
00721 HelpStringStore = String_256(_R(IDS_EDITBH_MENU));
00722 ReturnVal = TRUE;
00723 }
00724 else if ((Item == _R(IDC_EDIT_PATCH1)) ||
00725 (Item == _R(IDC_EDIT_PATCH2)) ||
00726 (Item == _R(IDC_EDIT_PATCH)) ||
00727 (Item == _R(IDC_EDIT_PICKER)))
00728 {
00729
00730
00731 HelpStringStore = PickerBubbleBuffer;
00732 ReturnVal = TRUE;
00733 }
00734
00735 else if (Item == _R(IDC_EDIT_COMPONENT1))
00736 {
00737 if (cc)
00738 ReturnVal = GetComponentHelp(cc, 1, HelpStringStore);
00739 }
00740 else if (Item == _R(IDC_EDIT_COMPONENT2))
00741 {
00742 if (cc)
00743 ReturnVal = GetComponentHelp(cc, 2, HelpStringStore);
00744 }
00745 else if (Item == _R(IDC_EDIT_COMPONENT3))
00746 {
00747 if (cc)
00748 ReturnVal = GetComponentHelp(cc, 3, HelpStringStore);
00749 }
00750 else if (Item == _R(IDC_EDIT_COMPONENT4))
00751 {
00752 if (cc)
00753 ReturnVal = GetComponentHelp(cc, 4, HelpStringStore);
00754 }
00755 #if 0
00756 {
00757 if (ColourEditDlg::DisplayModel == COLOURMODEL_HSVT)
00758 {
00759 HelpStringStore = String_256(_R(IDS_EDITBH_COMP1));
00760 ReturnVal = TRUE;
00761 }
00762 else
00763 {
00764 if (cc != NULL)
00765 {
00766 String_64 CompName;
00767 cc->GetComponentName(1, &CompName, TRUE);
00768 HelpStringStore.MakeMsg(_R(IDS_EDITBH_COMP234), (TCHAR *)CompName);
00769 ReturnVal = TRUE;
00770 }
00771 }
00772 }
00773
00774 else if (Item == _R(IDC_EDIT_COMPONENT2))
00775 {
00776 if (cc != NULL)
00777 {
00778 String_64 CompName;
00779 cc->GetComponentName(2, &CompName, TRUE);
00780 HelpStringStore.MakeMsg(_R(IDS_EDITBH_COMP234), (TCHAR *)CompName);
00781 ReturnVal = TRUE;
00782 }
00783 }
00784
00785 else if (Item == _R(IDC_EDIT_COMPONENT3))
00786 {
00787 if (cc != NULL)
00788 {
00789 String_64 CompName;
00790 cc->GetComponentName(3, &CompName, TRUE);
00791 HelpStringStore.MakeMsg(_R(IDS_EDITBH_COMP234), (TCHAR *)CompName);
00792 ReturnVal = TRUE;
00793 }
00794 }
00795
00796 else if (Item == _R(IDC_EDIT_COMPONENT4))
00797 {
00798 if (cc != NULL)
00799 {
00800 String_64 CompName;
00801 cc->GetComponentName(4, &CompName, TRUE);
00802 HelpStringStore.MakeMsg(_R(IDS_EDITBH_COMP234), (TCHAR *)CompName);
00803 ReturnVal = TRUE;
00804 }
00805 }
00806
00807 #endif
00808 else if (Item == _R(IDC_EDIT_COLMODEL))
00809 {
00810 HelpStringStore = String_256(_R(IDS_EDITBH_COLMODEL));
00811 ReturnVal = TRUE;
00812 }
00813 else if (Item == _R(IDC_EDIT_NAMEMENU))
00814 {
00815 HelpStringStore = String_256(_R(IDS_EDITBH_NAME));
00816 ReturnVal = TRUE;
00817 }
00818 else if (Item == _R(IDC_EDIT_WEBHEX))
00819 {
00820 HelpStringStore = String_256(_R(IDS_EDITBH_WEBHEX));
00821 ReturnVal = TRUE;
00822 }
00823 else if (Item == _R(IDC_EDIT_COLTYPE))
00824 {
00825 HelpStringStore = String_256(_R(IDS_EDITBH_COLTYPE));
00826 ReturnVal = TRUE;
00827 }
00828 else if ((Item == _R(IDC_EDIT_INHERIT1)) ||
00829 (Item == _R(IDC_EDIT_INHERIT2)) ||
00830 (Item == _R(IDC_EDIT_INHERIT3)) ||
00831 (Item == _R(IDC_EDIT_INHERIT4)) )
00832 {
00833 HelpStringStore = String_256(_R(IDS_EDITBH_INHERIT));
00834 ReturnVal = TRUE;
00835 }
00836 else if ((Item == _R(IDC_EDIT_PARENTCOL)) ||
00837 (Item == _R(IDC_EDIT_PARENTNAME)))
00838 {
00839 HelpStringStore = String_256(_R(IDS_EDITBH_PARENTCOL));
00840 ReturnVal = TRUE;
00841 }
00842 else if ((Item == _R(IDC_EDIT_TINT)) ||
00843 (Item == _R(IDC_EDIT_TINTSLIDER)))
00844 {
00845 if (Bob != NULL && Bob->GetType() == COLOURTYPE_TINT && !Bob->TintIsShade())
00846 HelpStringStore = String_256(_R(IDS_EDITBH_TINT1));
00847 else
00848 HelpStringStore = String_256(_R(IDS_EDITBH_TINT2));
00849 ReturnVal = TRUE;
00850 }
00851 else if (Item == _R(IDC_EDIT_SHADE))
00852 {
00853 HelpStringStore = String_256(_R(IDS_EDITBH_TINT2));
00854 ReturnVal = TRUE;
00855 }
00856 else if (Item == _R(IDC_EDIT_ADVANCED))
00857 {
00858 if (Editor->Folded)
00859 HelpStringStore = String_256(_R(IDS_EDITBH_ADVANCED1));
00860 else
00861 HelpStringStore = String_256(_R(IDS_EDITBH_ADVANCED2));
00862 ReturnVal = TRUE;
00863 }
00864 else if (Item == _R(IDC_EDIT_3D))
00865 {
00866 HelpStringStore = String_256(_R(IDS_EDITBH_3D));
00867 ReturnVal = TRUE;
00868 }
00869 else if (Item == _R(IDC_EDIT_MAKESTYLE))
00870 {
00871 HelpStringStore = String_256(_R(IDS_EDITBH_MAKESTYLE));
00872 ReturnVal = TRUE;
00873 }
00874 else if (Item == _R(IDC_EDIT_NOCOLOUR))
00875 {
00876 HelpStringStore = String_256(_R(IDS_COLBAR_HNOCOLOUR));
00877 ReturnVal = TRUE;
00878 }
00879 else if (Item == _R(IDC_MAKE_LOCAL))
00880 {
00881 HelpStringStore = String_256(_R(IDS_EDITBH_MAKE_LOCAL));
00882 ReturnVal = TRUE;
00883 }
00884 else if (Item == _R(IDC_EDIT_RENAME))
00885 {
00886 HelpStringStore = String_256(_R(IDS_EDITBH_RENAME));
00887 ReturnVal = TRUE;
00888 }
00889 else if (Item == _R(IDC_EDIT_LINEFILL))
00890 {
00891 HelpStringStore = String_256(_R(IDS_EDITBH_LINEFILL));
00892 ReturnVal = TRUE;
00893 }
00894 else if (Item == _R(IDC_EDIT_216ONLY))
00895 {
00896 HelpStringStore = String_256(_R(IDS_EDITBH_216ONLY));
00897 ReturnVal = TRUE;
00898 }
00899 else if (Item == _R(IDC_COLOURPICKER))
00900 {
00901 HelpStringStore = String_256(_R(IDS_STATICCOLOURPICKERTOOLHELP));
00902 ReturnVal = TRUE;
00903 }
00904
00905 if (ReturnVal)
00906 return((TCHAR *) HelpStringStore);
00907
00908 #endif
00909
00910 return(NULL);
00911 }
00912
00913
00914
00915
00916
00917
00918
00919
00920
00921
00922
00923
00924
00925
00926
00927
00928
00929
00930 void ColourPicker::SetBubbleHelp(CGadgetID * GadgetList)
00931 {
00932 ColourEditDlg *Editor = ColourEditDlg::TheEditor;
00933 if (Editor == NULL)
00934 return;
00935
00936 CGadgetID i;
00937 while ((i=*(GadgetList++)))
00938 {
00939 wxWindow * pGadget = DialogManager::GetGadget(Editor->WindowID, i);
00940 wxString s;
00941 if (pGadget)
00942 {
00943 if (pGadget->IsEnabled() && pGadget->IsShown())
00944 {
00945
00946 TCHAR * pHelp = HelpCallbackHandler(Editor->WindowID, i, NULL);
00947 if (pHelp)
00948 s=wxString(pHelp);
00949 }
00950 if (!s.IsEmpty())
00951 pGadget->SetToolTip(s);
00952 else
00953 pGadget->SetToolTip(NULL);
00954 }
00955 }
00956 }
00957
00958
00959
00960
00961
00962
00963
00964
00965
00966
00967
00968
00969
00970
00971
00972
00973
00974
00975
00976
00977
00978
00979 BOOL ColourPicker::GetComponentHelp(ColourContext* const pSourceContext, const UINT32 ComponentIndex, StringBase& HelpString)
00980 {
00981 ERROR2IF(pSourceContext == NULL, FALSE, "NULL parameters not allowed");
00982 ERROR3IF(!pSourceContext->IS_KIND_OF(ColourContext), "ColourPicker::GetComponentHelp() - pSourceContext isn't");
00983 ERROR2IF((ComponentIndex < 1) || (ComponentIndex > pSourceContext->GetComponentCount()), FALSE,
00984 "Component index out of bounds");
00985
00986
00987
00988 UnitGroup* pUnitGroup = pSourceContext->GetComponentUnitGroup(ComponentIndex);
00989 if (pUnitGroup == NULL)
00990 {
00991 ERROR3("ColourPicker::GetComponentHelp - Model has no units");
00992 return FALSE;
00993 }
00994 ERROR3IF(!pUnitGroup->IS_KIND_OF(UnitGroup), "ColourPicker::GetComponentHelp() - pUnitGroup isn't");
00995 ScaleUnit* pUnit = pUnitGroup->GetDefaultUnit();
00996 if (pUnit == NULL)
00997 {
00998 ERROR3("ColourPicker::GetComponentHelp - No default units");
00999 return FALSE;
01000 }
01001 ERROR3IF(!pUnit->IS_KIND_OF(ScaleUnit), "ColourPicker::GetComponentHelp() - pUnit isn't");
01002
01003 String_64 CompName;
01004 pSourceContext->GetComponentName(ComponentIndex, &CompName, TRUE);
01005
01006 String_32 LowerLimit;
01007 Convert::DoubleToString(pUnit->GetMin(), (StringBase*)&LowerLimit, pUnit->GetDPtoShow());
01008
01009 String_32 UpperLimit;
01010 Convert::DoubleToString(pUnit->GetMax(), (StringBase*)&UpperLimit, pUnit->GetDPtoShow());
01011
01012 String_32 QualifierToken;
01013 const Qualifier* pQualifier = pUnit->GetQualifier();
01014 if (pQualifier == NULL)
01015 {
01016 ERROR3("ColourPicker::GetComponentHelp - No qualifier");
01017 return FALSE;
01018 }
01019 ERROR3IF(!pQualifier->IS_KIND_OF(Qualifier), "ColourPicker::GetComponentHelp - Qualifier isn't");
01020
01021 if (pQualifier->IsShown())
01022 {
01023 QualifierToken = pQualifier->GetToken();
01024 }
01025
01026 HelpString.MakeMsg(_R(IDS_EDITBH_COMP234), (TCHAR *)CompName, (TCHAR *)LowerLimit, (TCHAR *)UpperLimit,
01027 (TCHAR *)QualifierToken);
01028
01029 return TRUE;
01030 }
01031
01032
01033
01034
01035
01036
01037
01038
01039
01040
01041
01042
01043
01044
01045
01046
01047
01048
01049
01050 void ColourPicker::UpdateBubbleHelpAndPointer(void)
01051 {
01052 PORTNOTE("other", "Disabled ColourPicker::UpdateBubbleHelpAndPointer()")
01053 #ifndef EXCLUDE_FROM_XARALX
01054 #ifndef STANDALONE
01055 ColourEditDlg *Editor = ColourEditDlg::TheEditor;
01056 if (Editor == NULL)
01057 return;
01058
01059 static CWindowID TheWindow = NULL;
01060
01061 if (TheWindow == NULL)
01062 TheWindow = (CWindowID)Editor->WindowID;
01063
01064 if (TheWindow == NULL)
01065 return;
01066
01067
01068
01069
01070
01071 static MonotonicTime LastUpdate;
01072 static UINT32 MousePos = 0;
01073
01074 if (LastUpdate.Elapsed(100))
01075 {
01076
01077 LastUpdate.Sample();
01078
01079
01080 TheWindow = (CWindowID)Editor->WindowID;
01081 MousePos = 0;
01082
01083 POINT MouseScreenPos;
01084 if (::GetCursorPos(&MouseScreenPos))
01085 {
01086
01087
01088
01089
01090
01091
01092 CWindowID WindowUnder = ::WindowFromPoint(MouseScreenPos);
01093
01094 if (WindowUnder != NULL &&
01095 (WindowUnder == TheWindow || ::GetParent(WindowUnder) == TheWindow))
01096 {
01097 POINT TempPos;
01098 TempPos.x = MouseScreenPos.x;
01099 TempPos.y = MouseScreenPos.y;
01100
01101
01102 ::ScreenToClient(TheWindow, &TempPos);
01103
01104 CPoint Pos(TempPos);
01105 CWindowID WindowUnderPointer = ::ChildWindowFromPoint(TheWindow, Pos);
01106 if (WindowUnderPointer != NULL && IsWindowVisible(WindowUnderPointer))
01107 {
01108
01109 INT32 WindowStyle = ::GetWindowLong(WindowUnderPointer, GWL_STYLE);
01110 if ((WindowStyle & WS_VISIBLE) != 0)
01111 {
01112 CWindowID hGadget;
01113 INT32 i = 0;
01114 while (GadgetList[i] && MousePos)
01115 {
01116 hGadget = DialogManager::GetGadget(TheWindow, GadgetList[i]);
01117 if (WindowUnderPointer == hGadget)
01118 {
01119 MousePos = (UINT32)GadgetList[i];
01120 TheWindow = hGadget;
01121 }
01122 i++;
01123 }
01124 }
01125 }
01126
01127
01128
01129
01130
01131
01132 if (MousePos == _R(IDC_EDIT_PICKER))
01133 {
01134 MousePos =0;
01135
01136
01137
01138 ReDrawInfoType ExtraInfo;
01139
01140 ExtraInfo.pDC = NULL;
01141 ExtraInfo.pClipRect = NULL;
01142
01143
01144 HDC ScreenDC = CreateCompatibleDC(NULL);
01145 if (ScreenDC == NULL)
01146 {
01147 ERROR3("ColourPicker: Unable to create screen DC");
01148 return;
01149 }
01150 ExtraInfo.Dpi = GetDeviceCaps(ScreenDC, LOGPIXELSY);
01151 DeleteDC(ScreenDC);
01152
01153
01154 RECT WindowSize;
01155 if (!GetClientRect(TheWindow, &WindowSize))
01156 {
01157 ERROR3("GetClientRect failed in ColourPicker");
01158 return;
01159 }
01160
01161 ExtraInfo.dx = (((INT32)WindowSize.right)*72000) / ExtraInfo.Dpi;
01162 ExtraInfo.dy = (((INT32)WindowSize.bottom)*72000) / ExtraInfo.Dpi;
01163
01164
01165
01166
01167 ScreenToClient(TheWindow, &MouseScreenPos);
01168
01169 INT32 XPos = (INT32) MouseScreenPos.x;
01170 INT32 YPos = (INT32) MouseScreenPos.y;
01171
01172 DocCoord MouseInfo;
01173 MouseInfo.x = (XPos * 72000) / ExtraInfo.Dpi;
01174 MouseInfo.y = ExtraInfo.dy - ((YPos * 72000) / ExtraInfo.Dpi);
01175 ExtraInfo.pMousePos = &MouseInfo;
01176
01177
01178
01179 PickerBubbleBuffer = String_128("");
01180 StatusHelpBuffer = String_256("");
01181 Editor->HandleIdlePointer(&ExtraInfo, &PickerBubbleBuffer, &StatusHelpBuffer, &MousePos);
01182
01183 if (MousePos)
01184 ControlHelper::BubbleHelpDisable();
01185 }
01186 }
01187 }
01188 }
01189
01190
01191 if (MousePos)
01192 {
01193
01194 ControlHelper::DoBubbleHelpOn(TheWindow, MousePos, ColourPicker::HelpCallbackHandler, NULL);
01195 }
01196 #endif
01197 #endif
01198 }
01199
01200
01201
01202
01203
01204
01205
01206
01207
01208
01209
01210
01211
01212
01213
01214
01215
01216
01217
01218
01219
01220
01221
01222
01223
01224
01225
01226
01227
01228
01229
01230
01231
01232
01233
01234
01235
01236
01237
01238 BOOL ColourPicker::GetComponentAsString(IndexedColour *Source,
01239 ColourContext *DestContext, INT32 ComponentIndex,
01240 String_8 *Result)
01241 {
01242 ERROR2IF(Source == NULL || DestContext == NULL || Result == NULL, FALSE,
01243 "NULL parameters are illegal");
01244
01245 ERROR2IF(ComponentIndex < 1 || (UINT32)ComponentIndex > DestContext->GetComponentCount(), FALSE,
01246 "ComponentIndex not in range");
01247
01248 BOOL OutOfGamut = FALSE;
01249 ColourGeneric Defn;
01250
01251 DestContext->ConvertColour(Source, &Defn);
01252
01253
01254
01255 ColourValue *CompPtr = (ColourValue *) &Defn;
01256 double CompValue = CompPtr[ComponentIndex-1].MakeDouble();
01257
01258 if (CompValue < 0.0)
01259 {
01260 CompValue = 0.0;
01261 OutOfGamut = TRUE;
01262 }
01263
01264 if (CompValue > 1.0)
01265 {
01266 CompValue = 1.0;
01267 OutOfGamut = TRUE;
01268 }
01269
01270
01271 UnitGroup* pPossibleUnits = DestContext->GetComponentUnitGroup(ComponentIndex);
01272 if (pPossibleUnits == NULL)
01273 {
01274 ERROR3("ColourPicker::GetComponentAsString - pPossibleUnits NULL");
01275 return FALSE;
01276 }
01277 ERROR3IF(!pPossibleUnits->IS_KIND_OF(UnitGroup), "pPossibleUnits aren't");
01278 ScaleUnit* pUnit = pPossibleUnits->GetDefaultUnit();
01279 if (pUnit == NULL)
01280 {
01281 ERROR3("ColourPicker::GetComponentAsString - Default units NULL");
01282 return FALSE;
01283 }
01284 ERROR3IF(!pUnit->IS_KIND_OF(ScaleUnit), "pUnits isn't");
01285 pUnit->StringFromScale(CompValue, Result, 6);
01286
01287
01288
01289
01290
01291
01292
01293
01294
01295
01296
01297
01298
01299
01300
01301 return(OutOfGamut);
01302 }
01303
01304
01305
01306
01307
01308
01309
01310
01311
01312
01313
01314
01315
01316
01317
01318
01319
01320
01321
01322
01323
01324
01325
01326
01327
01328
01329
01330
01331
01332
01333
01334
01335
01336
01337
01338 BOOL ColourPicker::GetComponentsAsHexString(IndexedColour *Source,
01339 ColourContext *DestContext, INT32 ComponentIndex,
01340 String_16 *Result)
01341 {
01342 ERROR2IF(Source == NULL || DestContext == NULL || Result == NULL, FALSE,
01343 "NULL parameters are illegal");
01344
01345
01346
01347 if (ComponentIndex == -1)
01348 {
01349 BOOL OutOfGamut = FALSE;
01350 ColourGeneric Defn;
01351
01352 DestContext->ConvertColour(Source, &Defn);
01353
01354
01355
01356
01357 ColourValue *CompPtr = (ColourValue *) &Defn;
01358
01359 String_8 ResultR, ResultG, ResultB;
01360
01361 for (INT32 i = 1; i < 4; i++)
01362 {
01363 double CompValue = CompPtr[i-1].MakeDouble();
01364
01365 if (CompValue < 0.0)
01366 {
01367 CompValue = 0.0;
01368 OutOfGamut = TRUE;
01369 }
01370
01371 if (CompValue > 1.0)
01372 {
01373 CompValue = 1.0;
01374 OutOfGamut = TRUE;
01375 }
01376
01377
01378 UnitGroup* pPossibleUnits = DestContext->GetComponentUnitGroup(i);
01379 if (pPossibleUnits == NULL)
01380 {
01381 ERROR3("ColourPicker::GetComponentAsString - pPossibleUnits NULL");
01382 return FALSE;
01383 }
01384 ERROR3IF(!pPossibleUnits->IS_KIND_OF(UnitGroup), "pPossibleUnits aren't");
01385 ScaleUnit* pUnit = pPossibleUnits->FindUnitFromIndex (1);
01386 if (pUnit == NULL)
01387 {
01388 ERROR3("ColourPicker::GetComponentAsString - Default units NULL");
01389 return FALSE;
01390 }
01391 ERROR3IF(!pUnit->IS_KIND_OF(ScaleUnit), "pUnits isn't");
01392
01393 switch (i)
01394 {
01395 case 1:
01396 pUnit->StringFromScale(CompValue, &ResultR, 6);
01397 break;
01398 case 2:
01399 pUnit->StringFromScale(CompValue, &ResultG, 6);
01400 break;
01401 case 3:
01402 pUnit->StringFromScale(CompValue, &ResultB, 6);
01403 break;
01404 }
01405 }
01406
01407
01408
01409 INT32 rVal = camAtoi ((const TCHAR*) ResultR);
01410 INT32 gVal = camAtoi ((const TCHAR*) ResultG);
01411 INT32 bVal = camAtoi ((const TCHAR*) ResultB);
01412
01413
01414
01415 camSprintf((TCHAR*)ResultR, _T("%X"), rVal);
01416 camSprintf((TCHAR*)ResultG, _T("%X"), gVal);
01417 camSprintf((TCHAR*)ResultB, _T("%X"), bVal);
01418
01419 String_8 Builder;
01420
01421
01422
01423
01424 if (ResultR.Length () == 1)
01425 {
01426 Builder += (String_8 (TEXT ("0"))) += ResultR;
01427 }
01428 else
01429 {
01430 Builder += ResultR;
01431 }
01432
01433 if (ResultG.Length () == 1)
01434 {
01435 Builder += (String_8 (TEXT ("0"))) += ResultG;
01436 }
01437 else
01438 {
01439 Builder += ResultG;
01440 }
01441
01442 if (ResultB.Length () == 1)
01443 {
01444 Builder += (String_8 (TEXT ("0"))) += ResultB;
01445 }
01446 else
01447 {
01448 Builder += ResultB;
01449 }
01450
01451 *Result = Builder;
01452
01453
01454
01455
01456
01457
01458
01459
01460
01461
01462 return(OutOfGamut);
01463 }
01464
01465 return (FALSE);
01466 }
01467
01468
01469
01470
01471
01472
01473
01474
01475
01476
01477
01478
01479
01480
01481
01482
01483
01484
01485
01486
01487
01488
01489
01490
01491
01492
01493
01494
01495
01496
01497
01498
01499
01500 BOOL ColourPicker::SetComponentFromString(IndexedColour *Dest,
01501 ColourContext *SourceContext, INT32 ComponentIndex,
01502 String_8 *NewValue)
01503 {
01504 ERROR2IF(Dest == NULL || SourceContext == NULL || NewValue == NULL, FALSE,
01505 "NULL Parameters are illegal");
01506 ERROR3IF(!Dest->IS_KIND_OF(IndexedColour) || !SourceContext->IS_KIND_OF(ColourContext),
01507 "Parameters incorrect classes");
01508 ERROR2IF(ComponentIndex < 1 || (UINT32)ComponentIndex > SourceContext->GetComponentCount(),
01509 FALSE, "ComponentIndex not in range");
01510
01511 UnitGroup* pPossibleUnits = SourceContext->GetComponentUnitGroup(ComponentIndex);
01512 if (pPossibleUnits == NULL)
01513 {
01514 ERROR3("ColourPicker::SetComponentFromString - SourceContext has NULL units");
01515 return FALSE;
01516 }
01517 ERROR3IF(!pPossibleUnits->IS_KIND_OF(UnitGroup), "ColourPicker::SetComponentFromString - pPossibleUnits aren't");
01518
01519 double dNewVal;
01520 if (pPossibleUnits->ScaleFromString(*NewValue, dNewVal) == FALSE)
01521 return FALSE;
01522
01523
01524 return(SetComponentFromDouble(Dest, SourceContext, ComponentIndex, dNewVal));
01525 }
01526
01527
01528
01529
01530
01531
01532
01533
01534
01535
01536
01537
01538
01539
01540
01541
01542
01543
01544
01545
01546
01547
01548
01549
01550
01551 BOOL ColourPicker::IsValidHexString (String_16 Hex)
01552 {
01553 for (INT32 i = 0; i < Hex.Length(); i++)
01554 {
01555 char x = Hex[i];
01556
01557 if (x >= '0' && x <= '9') {}
01558 else if (x >= 'A' && x <= 'F') {}
01559 else if (x >= 'a' && x <= 'f') {}
01560 else
01561 {
01562 return (FALSE);
01563 }
01564 }
01565 return (TRUE);
01566 }
01567
01568
01569
01570
01571
01572
01573
01574
01575
01576
01577
01578
01579
01580
01581
01582
01583
01584
01585
01586
01587
01588
01589
01590
01591
01592
01593
01594
01595
01596
01597
01598
01599
01600 BOOL ColourPicker::SetComponentsFromHexString(IndexedColour *Dest,
01601 ColourContext *SourceContext,
01602 String_16 *NewValue)
01603 {
01604 ERROR2IF(Dest == NULL || SourceContext == NULL || NewValue == NULL, FALSE,
01605 "NULL Parameters are illegal");
01606 ERROR3IF(!Dest->IS_KIND_OF(IndexedColour) || !SourceContext->IS_KIND_OF(ColourContext),
01607 "Parameters incorrect classes");
01608
01609
01610
01611
01612 String_16 CopyNewValue (*NewValue);
01613
01614 CopyNewValue.toLower ();
01615
01616 INT32 StringLength = CopyNewValue.Length ();
01617
01618 BOOL ValidStringParseSoFar = TRUE;
01619 BOOL Single0xPrefix = FALSE;
01620 BOOL SingleHashPrefix = FALSE;
01621 BOOL More0xPrefixs = FALSE;
01622 BOOL MoreHashPrefixs = FALSE;
01623
01624
01625
01626 const TCHAR* PtrPrefix = cc_lstrstr (CopyNewValue, _T("0x"));
01627 Single0xPrefix = (PtrPrefix != NULL) ? TRUE : FALSE;
01628 const TCHAR* PtrPrefix2 = cc_lstrstr (CopyNewValue, _T("#"));
01629 SingleHashPrefix = (PtrPrefix2 != NULL) ? TRUE : FALSE;
01630
01631 if (Single0xPrefix == TRUE)
01632 {
01633 CopyNewValue = PtrPrefix += 2;
01634
01635
01636
01637
01638 PtrPrefix = cc_lstrstr (CopyNewValue, _T("0x"));
01639 More0xPrefixs = (PtrPrefix != NULL) ? TRUE : FALSE;
01640
01641 ValidStringParseSoFar = More0xPrefixs ? FALSE : TRUE;
01642
01643 if (ValidStringParseSoFar)
01644 {
01645
01646
01647 PtrPrefix2 = cc_lstrstr ((const TCHAR*) CopyNewValue, _T("#"));
01648 SingleHashPrefix = (PtrPrefix2 != NULL) ? TRUE : FALSE;
01649 ValidStringParseSoFar = SingleHashPrefix ? FALSE : TRUE;
01650 }
01651
01652 if (!ValidStringParseSoFar)
01653 {
01654 return (FALSE);
01655 }
01656 }
01657 else if (SingleHashPrefix == TRUE)
01658 {
01659 CopyNewValue = PtrPrefix2 += 1;
01660
01661
01662
01663
01664 PtrPrefix2 = cc_lstrstr ((const TCHAR*) CopyNewValue, _T("#"));
01665 MoreHashPrefixs = (PtrPrefix2 != NULL) ? TRUE : FALSE;
01666
01667 ValidStringParseSoFar = MoreHashPrefixs ? FALSE : TRUE;
01668
01669 if (ValidStringParseSoFar)
01670 {
01671
01672
01673 PtrPrefix = cc_lstrstr ((const TCHAR*) CopyNewValue, _T("0x"));
01674 Single0xPrefix = (PtrPrefix != NULL) ? TRUE : FALSE;
01675 ValidStringParseSoFar = Single0xPrefix ? FALSE : TRUE;
01676 }
01677
01678 if (!ValidStringParseSoFar)
01679 {
01680 return (FALSE);
01681 }
01682 }
01683
01684 if (ValidStringParseSoFar == FALSE) return (FALSE);
01685
01686
01687
01688
01689
01690 String_16 No0xPrefixNewValue (CopyNewValue);
01691 StringLength = No0xPrefixNewValue.Length ();
01692
01693 BOOL rComponent = FALSE;
01694 BOOL bComponent = FALSE;
01695 BOOL gComponent = FALSE;
01696
01697 String_8 rValStr;
01698 String_8 gValStr;
01699 String_8 bValStr;
01700
01701 if ((StringLength <= 0) || (StringLength > 6)) return (FALSE);
01702
01703 switch (StringLength)
01704 {
01705 case 2: rComponent = TRUE; break;
01706 case 4: rComponent = TRUE; gComponent = TRUE; break;
01707 case 6: rComponent = TRUE; gComponent = TRUE; bComponent = TRUE; break;
01708 }
01709
01710 BOOL returnVal = FALSE;
01711
01712
01713
01714
01715
01716
01717
01718 if (IsValidHexString (No0xPrefixNewValue))
01719 {
01720 if (rComponent == TRUE)
01721 {
01722 No0xPrefixNewValue.Split (&rValStr, &No0xPrefixNewValue, 2, FALSE);
01723 INT32 convertedVal;
01724 camSscanf(rValStr, _T("%X"), &convertedVal);
01725 camSprintf(rValStr, _T("%d"), convertedVal);
01726
01727
01728
01729 UnitGroup* pPossibleUnits = SourceContext->GetComponentUnitGroup(1);
01730 if (pPossibleUnits == NULL)
01731 {
01732 ERROR3("ColourPicker::SetComponentFromString - SourceContext has NULL units");
01733 return FALSE;
01734 }
01735 ERROR3IF(!pPossibleUnits->IS_KIND_OF(UnitGroup), "ColourPicker::SetComponentFromString - pPossibleUnits aren't");
01736
01737 ScaleUnit* pUnit = pPossibleUnits->FindUnitFromIndex (1);
01738 if (pUnit == NULL)
01739 {
01740 ERROR3("ColourPicker::GetComponentAsString - Default units NULL");
01741 return FALSE;
01742 }
01743 ERROR3IF(!pUnit->IS_KIND_OF(ScaleUnit), "pUnits isn't");
01744
01745 double dNewVal;
01746 Convert::StringToDouble(rValStr, &dNewVal);
01747 pUnit->ConvertTo0to1 (dNewVal);
01748
01749
01750 returnVal = SetComponentFromDouble(Dest, SourceContext, 1, dNewVal);
01751 }
01752
01753 if (gComponent == TRUE)
01754 {
01755 No0xPrefixNewValue.Split (&gValStr, &No0xPrefixNewValue, 2, FALSE);
01756 INT32 convertedVal;
01757 camSscanf(gValStr, _T("%X"), &convertedVal);
01758 camSprintf(gValStr, _T("%d"), convertedVal);
01759
01760
01761
01762 UnitGroup* pPossibleUnits = SourceContext->GetComponentUnitGroup(2);
01763 if (pPossibleUnits == NULL)
01764 {
01765 ERROR3("ColourPicker::SetComponentFromString - SourceContext has NULL units");
01766 return FALSE;
01767 }
01768 ERROR3IF(!pPossibleUnits->IS_KIND_OF(UnitGroup), "ColourPicker::SetComponentFromString - pPossibleUnits aren't");
01769
01770 ScaleUnit* pUnit = pPossibleUnits->FindUnitFromIndex (1);
01771 if (pUnit == NULL)
01772 {
01773 ERROR3("ColourPicker::GetComponentAsString - Default units NULL");
01774 return FALSE;
01775 }
01776 ERROR3IF(!pUnit->IS_KIND_OF(ScaleUnit), "pUnits isn't");
01777
01778 double dNewVal;
01779 Convert::StringToDouble(gValStr, &dNewVal);
01780 pUnit->ConvertTo0to1 (dNewVal);
01781
01782
01783 returnVal = SetComponentFromDouble(Dest, SourceContext, 2, dNewVal);
01784 }
01785
01786 if (bComponent == TRUE)
01787 {
01788 No0xPrefixNewValue.Split (&bValStr, &No0xPrefixNewValue, 2, FALSE);
01789 INT32 convertedVal;
01790 camSscanf(bValStr, _T("%X"), &convertedVal);
01791 camSprintf(bValStr, _T("%d"), convertedVal);
01792
01793
01794
01795 UnitGroup* pPossibleUnits = SourceContext->GetComponentUnitGroup(3);
01796 if (pPossibleUnits == NULL)
01797 {
01798 ERROR3("ColourPicker::SetComponentFromString - SourceContext has NULL units");
01799 return FALSE;
01800 }
01801 ERROR3IF(!pPossibleUnits->IS_KIND_OF(UnitGroup), "ColourPicker::SetComponentFromString - pPossibleUnits aren't");
01802
01803 ScaleUnit* pUnit = pPossibleUnits->FindUnitFromIndex (1);
01804 if (pUnit == NULL)
01805 {
01806 ERROR3("ColourPicker::GetComponentAsString - Default units NULL");
01807 return FALSE;
01808 }
01809 ERROR3IF(!pUnit->IS_KIND_OF(ScaleUnit), "pUnits isn't");
01810
01811 double dNewVal;
01812 Convert::StringToDouble(bValStr, &dNewVal);
01813 pUnit->ConvertTo0to1 (dNewVal);
01814
01815
01816 returnVal = SetComponentFromDouble(Dest, SourceContext, 3, dNewVal);
01817 }
01818
01819 return (returnVal);
01820 }
01821 else
01822 {
01823 return (FALSE);
01824 }
01825 }
01826
01827
01828
01829
01830
01831
01832
01833
01834
01835
01836
01837
01838
01839
01840
01841
01842
01843
01844
01845
01846
01847
01848
01849
01850
01851
01852
01853
01854
01855
01856
01857
01858
01859
01860
01861
01862 BOOL ColourPicker::SetComponentFromDouble(IndexedColour *Dest,
01863 ColourContext *SourceContext, INT32 ComponentIndex,
01864 double NewValue)
01865 {
01866 BOOL OutOfGamut = FALSE;
01867
01868 ERROR3IF(Dest == NULL || SourceContext == NULL,
01869 "ColourPicker::SetComponentFromDouble - NULL Parameters are illegal");
01870
01871 ERROR3IF(ComponentIndex < 1 || ComponentIndex > 4,
01872 "ColourPicker::SetComponentFromDouble- Index should be in range 1..4!");
01873
01874
01875 ForceColourModel(Dest, SourceContext);
01876
01877
01878 NewValue += 1.0 / ((double) (1<<25));
01879
01880
01881 if (NewValue < 0.0)
01882 {
01883 NewValue = 0.0;
01884 OutOfGamut = TRUE;
01885 }
01886
01887 if (NewValue > 1.0)
01888 {
01889 NewValue = 1.0;
01890 OutOfGamut = TRUE;
01891 }
01892
01893
01894
01895 ColourValue *CompPtr = (ColourValue *) Dest->SourceColourPtr();
01896 CompPtr[ComponentIndex-1] = FIXED24(NewValue);
01897
01898 return(OutOfGamut);
01899 }
01900
01901
01902
01903
01904
01905
01906
01907
01908
01909
01910
01911
01912
01913
01914
01915
01916
01917
01918
01919
01920
01921
01922
01923
01924
01925
01926 void ColourPicker::ForceColourModel(IndexedColour *Dest, ColourContext *SourceContext)
01927 {
01928 ERROR3IF(Dest == NULL || SourceContext == NULL,
01929 "ColourPicker::ForceColourModel - NULL Parameters are illegal");
01930
01931
01932
01933
01934 Dest->InvalidateCache();
01935
01936 if (Dest->GetColourModel() != SourceContext->GetColourModel())
01937 {
01938 ColourContext *OldContext = ColourContext::GetGlobalDefault(Dest->GetColourModel());
01939 if (OldContext == NULL)
01940 {
01941 ERROR2RAW("Unable to get colour context for ForceColourModel");
01942 return;
01943 }
01944
01945
01946
01947 ColourGeneric NewDefn;
01948
01949 Dest->GetSourceColour(&NewDefn);
01950 SourceContext->ConvertColour(OldContext, &NewDefn, Dest->SourceColourPtr());
01951
01952 Dest->SetSourceColourModel(SourceContext->GetColourModel());
01953
01954
01955 Dest->InvalidateCache();
01956 }
01957 }
01958
01959
01960
01961
01962
01963
01964
01965
01966
01967
01968
01969
01970
01971
01972
01973
01974
01975
01976
01977
01978
01979
01980
01981
01982
01983
01984
01985
01986
01987
01988
01989 BOOL ColourPicker::GetTintAsString(IndexedColour *Source, StringBase *Result)
01990 {
01991 ERROR3IF(Source == NULL || Result == NULL,
01992 "ColourPicker::GetComponentAsString - NULL parameters are illegal");
01993
01994 if (Source->GetType() != COLOURTYPE_TINT)
01995 {
01996 ERROR3("ColourPicker::GetTintAsString: Source colour isn't a tint");
01997 *Result = String_8(_R(IDS_CONVERT_ZERO_CHAR));
01998 return(FALSE);
01999 }
02000
02001 BOOL OutOfGamut = FALSE;
02002
02003 double CompValue;
02004 if (Source->TintIsShade())
02005 CompValue = Source->GetShadeValueY().MakeDouble();
02006 else
02007 CompValue = Source->GetTintValue().MakeDouble();
02008
02009 if (CompValue < 0.0)
02010 {
02011 CompValue = 0.0;
02012 OutOfGamut = TRUE;
02013 }
02014
02015 if (CompValue > 1.0)
02016 {
02017 CompValue = 1.0;
02018 OutOfGamut = TRUE;
02019 }
02020
02021 CompValue *= 100.0;
02022
02023 String_32 TempString;
02024 Convert::DoubleToString(CompValue, (StringBase *) &TempString, 1);
02025
02026 TempString.Left(Result, 7);
02027
02028 return(OutOfGamut);
02029 }
02030
02031
02032
02033
02034
02035
02036
02037
02038
02039
02040
02041
02042
02043
02044
02045
02046
02047
02048
02049
02050
02051
02052
02053
02054
02055
02056
02057
02058 BOOL ColourPicker::SetTintFromString(IndexedColour *Dest, StringBase *NewValue)
02059 {
02060 ERROR3IF(Dest == NULL || NewValue == NULL,
02061 "ColourPicker::SetTintFromString - NULL Parameters are illegal");
02062
02063 if (Dest->GetType() != COLOURTYPE_TINT)
02064 {
02065 ERROR3("ColourPicker::SetTintFromString - colour isn't a tint");
02066 return(FALSE);
02067 }
02068
02069
02070 String_8 TempString;
02071 NewValue->Left(&TempString, 7);
02072 TempString.SwapChar(_T('%'), _T(' '));
02073
02074
02075
02076
02077 double NewVal;
02078 Convert::StringToDouble(TempString, &NewVal);
02079
02080
02081 NewVal /= 100.0;
02082
02083 BOOL OutOfGamut = FALSE;
02084
02085
02086 NewVal += 1.0 / ((double) (1<<25));
02087
02088
02089 if (NewVal < 0.0)
02090 {
02091 NewVal = 0.0;
02092 OutOfGamut = TRUE;
02093 }
02094
02095 if (NewVal > 1.0)
02096 {
02097 NewVal = 1.0;
02098 OutOfGamut = TRUE;
02099 }
02100
02101
02102 if (Dest->TintIsShade())
02103 {
02104
02105 }
02106 else
02107 Dest->SetTintValue(NewVal);
02108
02109 return(OutOfGamut);
02110 }
02111
02112
02113
02114
02115
02116
02117
02118
02119
02120
02121
02122
02123
02124
02125
02126
02127
02128
02129
02130
02131
02132
02133
02134
02135
02136
02137
02138
02139
02140
02141
02142
02143
02144 BOOL ColourPicker::GetShadeValueAsString(IndexedColour *Source, INT32 ValueIndex, StringBase *Result)
02145 {
02146 ERROR3IF(Source == NULL || Result == NULL,
02147 "ColourPicker::GetShadeValueAsString - NULL parameters are illegal");
02148
02149 ERROR3IF(ValueIndex != 1 && ValueIndex != 2, "ColourPicker::GetShadeValueAsString - Illegal ValueIndex parameter");
02150
02151 if (Source->GetType() != COLOURTYPE_TINT)
02152 {
02153 ERROR3("ColourPicker::GetShadeValueAsString - Source colour isn't a tint");
02154 *Result = String_8(_R(IDS_CONVERT_ZERO_CHAR));
02155 return(FALSE);
02156 }
02157
02158 BOOL OutOfGamut = FALSE;
02159
02160 double CompValue;
02161 if (ValueIndex == 1)
02162 CompValue = -Source->GetShadeValueX().MakeDouble();
02163 else
02164 CompValue = Source->GetShadeValueY().MakeDouble();
02165
02166 if (CompValue < -1.0)
02167 {
02168 CompValue = -1.0;
02169 OutOfGamut = TRUE;
02170 }
02171
02172 if (CompValue > 1.0)
02173 {
02174 CompValue = 1.0;
02175 OutOfGamut = TRUE;
02176 }
02177
02178 CompValue *= 100.0;
02179
02180 String_32 TempString;
02181 Convert::DoubleToString(CompValue, (StringBase *) &TempString, 1);
02182
02183 TempString.Left(Result, 7);
02184
02185 return(OutOfGamut);
02186 }
02187
02188
02189
02190
02191
02192
02193
02194
02195
02196
02197
02198
02199
02200
02201
02202
02203
02204
02205
02206
02207
02208
02209
02210
02211
02212
02213
02214
02215
02216 BOOL ColourPicker::SetShadeFromStrings(IndexedColour *Dest, StringBase *NewValueX, StringBase *NewValueY)
02217 {
02218 ERROR3IF(Dest == NULL || NewValueX == NULL || NewValueY == NULL,
02219 "ColourPicker::SetShadeFromStrings - NULL Parameters are illegal");
02220
02221 if (Dest->GetType() != COLOURTYPE_TINT)
02222 {
02223 ERROR3("ColourPicker::SetShadeFromStrings - colour isn't a tint/shade");
02224 return(FALSE);
02225 }
02226
02227
02228
02229 String_8 TempString;
02230 NewValueX->Left(&TempString, 7);
02231 TempString.SwapChar(_T('%'),_T(' '));
02232
02233
02234
02235
02236 double NewValX;
02237 Convert::StringToDouble(TempString, &NewValX);
02238
02239
02240 NewValX = (-NewValX) / 100.0;
02241
02242 BOOL OutOfGamut = FALSE;
02243
02244
02245 NewValX += 1.0 / ((double) (1<<25));
02246
02247
02248 if (NewValX < -1.0)
02249 {
02250 NewValX = -1.0;
02251 OutOfGamut = TRUE;
02252 }
02253
02254 if (NewValX > 1.0)
02255 {
02256 NewValX = 1.0;
02257 OutOfGamut = TRUE;
02258 }
02259
02260
02261
02262 NewValueY->Left(&TempString, 7);
02263 TempString.SwapChar(_T('%'),_T(' '));
02264
02265
02266
02267
02268 double NewValY;
02269 Convert::StringToDouble(TempString, &NewValY);
02270
02271
02272 NewValY /= 100.0;
02273
02274
02275 NewValY += 1.0 / ((double) (1<<25));
02276
02277
02278 if (NewValY < -1.0)
02279 {
02280 NewValY = -1.0;
02281 OutOfGamut = TRUE;
02282 }
02283
02284 if (NewValY > 1.0)
02285 {
02286 NewValY = 1.0;
02287 OutOfGamut = TRUE;
02288 }
02289
02290 Dest->SetShadeValues(FIXED24(NewValX), FIXED24(NewValY));
02291
02292 return(OutOfGamut);
02293 }
02294
02295
02296
02297
02298
02299
02300
02301
02302
02303
02304
02305
02306
02307
02308
02309
02310
02311
02312
02313
02314
02315
02316
02317
02318
02319
02320
02321 void ColourPicker::SetWindowExtent(CWindowID WindowID,
02322 CGadgetID XGadgetID, CGadgetID YGadgetID)
02323 {
02324 PORTNOTE("other", "Disable Colourpicker::SetWindowExtent")
02325 #ifndef EXCLUDE_FROM_XARALX
02326 CWindowID hXGadget = DialogManager::GetGadget((CWindowID)WindowID, (INT32)XGadgetID);
02327 CWindowID hYGadget = DialogManager::GetGadget((CWindowID)WindowID, (INT32)YGadgetID);
02328
02329 RECT MainWinPos;
02330 RECT XGadgetPos;
02331 RECT YGadgetPos;
02332 BOOL ok = TRUE;
02333
02334
02335
02336
02337
02338
02339
02340
02341
02342
02343
02344
02345
02346
02347 if (ok) ok = GetWindowRect((CWindowID)WindowID,&MainWinPos);
02348 if (ok) ok = GetWindowRect(hXGadget,&XGadgetPos);
02349 if (ok) ok = GetWindowRect(hYGadget,&YGadgetPos);
02350
02351 if (ok)
02352 {
02353
02354
02355 INT32 dx = MainWinPos.right - XGadgetPos.right;
02356 INT32 dy = MainWinPos.bottom - YGadgetPos.bottom;
02357
02358
02359 if (DialogManager::GetWindowPosition(WindowID, &MainWinPos))
02360 {
02361
02362 MainWinPos.right -= dx - 6;
02363 MainWinPos.bottom -= dy - 6;
02364
02365
02366 DialogManager::SetWindowPosition(WindowID, MainWinPos);
02367 }
02368 }
02369 #endif
02370 }
02371
02372
02373
02374
02375
02376
02377
02378
02379
02380
02381
02382
02383
02384
02385
02386
02387
02388
02389
02390
02391
02392
02393
02394
02395
02396
02397
02398
02399
02400
02401
02402
02403
02404
02405
02406
02407
02408
02409 void ColourPicker::SetGadgetPositions(CWindowID WindowID,
02410 CGadgetID *Gadgets, CGadgetID MoveUnder)
02411 {
02412 PORTNOTE("other", "Disabled ColourPicker::SetGadgetPositions");
02413 #ifndef EXCLUDE_FROM_XARALX
02414 if (Gadgets == NULL || !Gadgets[0])
02415 return;
02416
02417 CWindowID hGadget;
02418 RECT MoveRect;
02419 POINT TopLeft;
02420 INT32 YShift = 10000;
02421
02422 if (MoveUnder)
02423 {
02424
02425
02426
02427 hGadget = DialogManager::GetGadget((CWindowID)WindowID, (INT32)MoveUnder);
02428 if (!GetWindowRect(hGadget, &MoveRect))
02429 return;
02430
02431 TopLeft.x = MoveRect.left;
02432 TopLeft.y = MoveRect.bottom;
02433 ScreenToClient((CWindowID)WindowID, &TopLeft);
02434 YShift = -(TopLeft.y + 8);
02435
02436 hGadget = DialogManager::GetGadget((CWindowID)WindowID, (INT32)Gadgets[0]);
02437 if (!GetWindowRect(hGadget, &MoveRect))
02438 return;
02439
02440 TopLeft.x = MoveRect.left;
02441 TopLeft.y = MoveRect.top;
02442 ScreenToClient((CWindowID)WindowID, &TopLeft);
02443
02444 YShift += TopLeft.y;
02445 }
02446 else
02447 {
02448
02449
02450
02451 hGadget = DialogManager::GetGadget((CWindowID)WindowID, (INT32)Gadgets[0]);
02452 if (!GetWindowRect(hGadget, &MoveRect))
02453 return;
02454
02455 TopLeft.x = MoveRect.left;
02456 TopLeft.y = MoveRect.top;
02457 ScreenToClient((CWindowID)WindowID, &TopLeft);
02458
02459 if (abs(TopLeft.y) > 8000)
02460 YShift = 0;
02461 }
02462
02463 if (YShift == 0)
02464 return;
02465
02466 INT32 Index = 0;
02467 while (Gadgets[Index] != 0)
02468 {
02469 hGadget = DialogManager::GetGadget((CWindowID)WindowID, (INT32)Gadgets[Index]);
02470
02471 if (GetWindowRect(hGadget, &MoveRect))
02472 {
02473 TopLeft.x = MoveRect.left;
02474 TopLeft.y = MoveRect.top;
02475 ScreenToClient((CWindowID)WindowID, &TopLeft);
02476 TopLeft.y -= YShift;
02477
02478 SetWindowPos(hGadget, NULL,
02479 TopLeft.x, TopLeft.y, 0, 0,
02480 SWP_NOACTIVATE | SWP_NOSIZE | SWP_NOZORDER);
02481 }
02482
02483 Index++;
02484 }
02485 #endif
02486 }
02487
02488
02489
02490
02491
02492
02493
02494
02495
02496
02497
02498
02499
02500
02501
02502
02503
02504
02505
02506
02507
02508
02509
02510
02511
02512
02513
02514
02515
02516
02517
02518
02519
02520
02521
02522
02523
02524
02525
02526
02527
02528
02529
02530
02531
02532
02533 void ColourPicker::SetComponentGadgets(CWindowID WindowID, CGadgetID *Gadgets,
02534 CGadgetID PickerGadget,
02535 ColourModel ModelToDisplay)
02536 {
02537 PORTNOTE("other", "Disabled ColourPicker::SetComponentGadgets")
02538 #ifndef EXCLUDE_FROM_XARALX
02539
02540 ColourContext *cc = ColourContext::GetGlobalDefault(ModelToDisplay);
02541 INT32 NumComponents = 0;
02542 INT32 i;
02543 if (cc != NULL)
02544 {
02545 for (i = 1; i <= 4; i++)
02546 {
02547 if (cc->GetComponentName(i, NULL))
02548 NumComponents++;
02549 }
02550 }
02551
02552 if (NumComponents < 1)
02553 return;
02554
02555
02556 RECT TheRect;
02557
02558 CWindowID hGadget;
02559 INT32 Left = 8;
02560 INT32 MaxWidth = 0;
02561
02562 {
02563
02564 hGadget = DialogManager::GetGadget((CWindowID)WindowID, (INT32)PickerGadget);
02565 if (hGadget && GetWindowRect(hGadget, &TheRect))
02566 {
02567
02568 ::MapWindowPoints(NULL, (CWindowID)WindowID, (LPPOINT) &TheRect, 2);
02569
02570 MaxWidth = TheRect.right - TheRect.left;
02571 Left = TheRect.left;
02572 }
02573 }
02574
02575
02576
02577
02578
02579
02580
02581
02582
02583
02584
02585 if (MaxWidth < 1)
02586 return;
02587
02588
02589
02590 INT32 PairWidth = MaxWidth / NumComponents;
02591
02592
02593 static INT32 BaseWritableWidth = 0;
02594 hGadget = DialogManager::GetGadget((CWindowID)WindowID, (INT32)Gadgets[1]);
02595
02596 if (GetWindowRect(hGadget, &TheRect))
02597 {
02598
02599
02600 if (BaseWritableWidth == 0)
02601 BaseWritableWidth = TheRect.right - TheRect.left;
02602 }
02603
02604 INT32 WritableWidth = BaseWritableWidth;
02605 if (WritableWidth < 1)
02606 return;
02607
02608
02609
02610
02611 if (NumComponents < 4)
02612 WritableWidth += 4;
02613
02614
02615
02616
02617
02618
02619 if (ModelToDisplay == COLOURMODEL_RGBT || ModelToDisplay == COLOURMODEL_HSVT)
02620 WritableWidth += 8;
02621
02622
02623 const INT32 Gap = 3;
02624 if (PairWidth - (2*Gap + WritableWidth) > 64)
02625 {
02626
02627
02628 PairWidth = 64 + 2*Gap + WritableWidth;
02629
02630 Left += (MaxWidth - (NumComponents * PairWidth)) / 2;
02631 MaxWidth = NumComponents * PairWidth;
02632 }
02633
02634
02635
02636 ::MapWindowPoints(NULL, (CWindowID)WindowID, (LPPOINT) &TheRect, 2);
02637
02638
02639
02640 RECT TextRect;
02641 hGadget = DialogManager::GetGadget((CWindowID)WindowID, (INT32)Gadgets[0]);
02642 if (hGadget == NULL || !GetWindowRect(hGadget, &TextRect))
02643 return;
02644 ::MapWindowPoints(NULL, (CWindowID)WindowID, (LPPOINT) &TextRect, 2);
02645
02646
02647
02648 const INT32 NewWidth = PairWidth - (2*Gap + WritableWidth);
02649 const INT32 NewHeight = ABS(TheRect.bottom - TheRect.top);
02650 INT32 LeftEnd;
02651
02652 for (i = 0; i < NumComponents; i++)
02653 {
02654 LeftEnd = Left + (i * PairWidth);
02655
02656
02657 hGadget = DialogManager::GetGadget((CWindowID)WindowID, (INT32)Gadgets[i*2]);
02658 if (hGadget)
02659 {
02660 if (i < NumComponents)
02661 {
02662 SetWindowPos(hGadget, NULL,
02663 LeftEnd, TextRect.top, NewWidth, NewHeight,
02664 SWP_HIDEWINDOW | SWP_NOACTIVATE | SWP_NOZORDER |
02665 SWP_NOCOPYBITS | SWP_NOREDRAW);
02666 }
02667 else
02668 ShowWindow(hGadget, SW_HIDE);
02669 }
02670
02671 LeftEnd += NewWidth + Gap;
02672
02673
02674 hGadget = DialogManager::GetGadget((CWindowID)WindowID, (INT32)Gadgets[(i*2)+1]);
02675 if (hGadget)
02676 {
02677 if (i < NumComponents)
02678 {
02679 SetWindowPos(hGadget, NULL,
02680 LeftEnd, TheRect.top, WritableWidth, NewHeight,
02681 SWP_HIDEWINDOW | SWP_NOACTIVATE | SWP_NOZORDER |
02682 SWP_NOCOPYBITS | SWP_NOREDRAW);
02683 }
02684 else
02685 ShowWindow(hGadget, SW_HIDE);
02686 }
02687 }
02688
02689
02690 TheRect.left = 0;
02691 TheRect.right = 0x1000;
02692 ::InvalidateRect((CWindowID)WindowID, &TheRect, TRUE);
02693 #endif
02694 }
02695
02696
02697
02698
02699
02700
02701
02702
02703
02704
02705
02706
02707
02708
02709
02710
02711
02712
02713
02714
02715
02716
02717
02718
02719
02720
02721
02722
02723
02724
02725
02726
02727
02728
02729
02730
02731
02732
02733
02734
02735
02736
02737
02738
02739
02740
02741
02742 void ColourPicker::SetFixedComponentGadgets(CWindowID WindowID, CGadgetID *Gadgets,
02743 CGadgetID PickerGadget,
02744 ColourModel ModelToDisplay,
02745 INT32 TextWidth[],
02746 INT32 EditWidth[]
02747 )
02748 {
02749 PORTNOTE("other", "Disabled ColourPicker::SetFixedComponentGadgets")
02750 #ifndef EXCLUDE_FROM_XARALX
02751 RECT TheRect;
02752
02753 CWindowID hGadget;
02754 INT32 Left = 0;
02755 INT32 MaxWidth = 0;
02756
02757 {
02758
02759 hGadget = DialogManager::GetGadget((CWindowID)WindowID, (INT32)PickerGadget);
02760 if (hGadget && GetWindowRect(hGadget, &TheRect))
02761 {
02762
02763 ::MapWindowPoints(NULL, (CWindowID)WindowID, (LPPOINT) &TheRect, 2);
02764
02765 MaxWidth = TheRect.right - TheRect.left;
02766 Left = TheRect.left;
02767 }
02768 }
02769
02770
02771
02772
02773
02774
02775
02776
02777
02778
02779
02780
02781
02782
02783 RECT TextRect;
02784 hGadget = DialogManager::GetGadget((CWindowID)WindowID, (INT32)Gadgets[0]);
02785 if (hGadget == NULL || !GetWindowRect(hGadget, &TextRect))
02786 return;
02787 ::MapWindowPoints(NULL, (CWindowID)WindowID, (LPPOINT) &TextRect, 2);
02788 INT32 TextHeight = TextRect.bottom-TextRect.top;
02789
02790
02791 RECT EditRect;
02792 hGadget = DialogManager::GetGadget((CWindowID)WindowID, (INT32)Gadgets[1]);
02793 GetWindowRect(hGadget, &EditRect);
02794 ::MapWindowPoints(NULL, (CWindowID)WindowID, (LPPOINT) &EditRect, 2);
02795 INT32 EditHeight = EditRect.bottom-EditRect.top;
02796
02797
02798 INT32 LeftEnd = Left;
02799 INT32 i=0;
02800 const INT32 Gap = 4;
02801 const INT32 LabelGap = 1;
02802
02803 for (i = 0; i < 5; i++)
02804 {
02805
02806 hGadget = DialogManager::GetGadget((CWindowID)WindowID, (INT32)Gadgets[i*2]);
02807 if (hGadget)
02808 {
02809 if (TextWidth[i]!=0)
02810 {
02811 SetWindowPos(hGadget, NULL,
02812 LeftEnd, TextRect.top, TextWidth[i], TextHeight,
02813 SWP_HIDEWINDOW | SWP_NOACTIVATE | SWP_NOZORDER |
02814 SWP_NOCOPYBITS | SWP_NOREDRAW);
02815
02816 LeftEnd += TextWidth[i] + LabelGap;
02817 }
02818 else
02819 ShowWindow(hGadget, SW_HIDE);
02820
02821 }
02822
02823
02824 hGadget = DialogManager::GetGadget((CWindowID)WindowID, (INT32)Gadgets[(i*2)+1]);
02825 if (hGadget)
02826 {
02827 if (EditWidth[i]!=0)
02828 {
02829 SetWindowPos(hGadget, NULL,
02830 LeftEnd, EditRect.top, EditWidth[i], EditHeight,
02831 SWP_HIDEWINDOW | SWP_NOACTIVATE | SWP_NOZORDER |
02832 SWP_NOCOPYBITS | SWP_NOREDRAW);
02833
02834 LeftEnd += EditWidth[i] + Gap;
02835 }
02836 else
02837 ShowWindow(hGadget, SW_HIDE);
02838
02839 }
02840
02841 }
02842
02843
02844 EditRect.left = 0;
02845 EditRect.right = 0x1000;
02846 ::InvalidateRect((CWindowID)WindowID, &EditRect, TRUE);
02847 #endif
02848 }
02849
02850
02851
02852
02853
02854
02855
02856
02857
02858
02859
02860
02861
02862
02863
02864
02865
02866
02867 void ColourPicker::RecursiveBestSize(wxWindow * pwxWindow)
02868 {
02869 if (pwxWindow->IsShown())
02870 {
02871
02872 wxWindowList::Node * pNode = pwxWindow->GetChildren().GetFirst();
02873 while (pNode)
02874 {
02875 RecursiveBestSize(pNode->GetData());
02876 pNode = pNode->GetNext();
02877 }
02878 }
02879
02880 pwxWindow->InvalidateBestSize();
02881
02882 wxSizer * s=pwxWindow->GetSizer();
02883
02884
02885 pwxWindow->Layout();
02886 pwxWindow->Fit();
02887 if (s)
02888 s->SetSizeHints(pwxWindow);
02889
02890 if (pwxWindow->IsShown())
02891 if ((s_UserSize != wxDefaultSize) && ((ResourceID)(pwxWindow->GetId()) == _R(IDC_EDIT_PICKER)))
02892 pwxWindow->SetSize(s_UserSize);
02893 else
02894 pwxWindow->SetSize(pwxWindow->GetMinSize());
02895 else
02896 pwxWindow->SetSize(wxSize(1,1));
02897
02898 return;
02899 }
02900
02901
02902
02903
02904
02905
02906
02907
02908
02909
02910
02911
02912
02913 void ColourPicker::RelayoutDialog(CWindowID WindowID)
02914 {
02915 static INT32 flag=0;
02916
02917 if (s_InColourDialogLayout)
02918 {
02919 TRACEUSER("amb", _T("Recursive colour dialog layout"));
02920 return;
02921 }
02922
02923 s_InColourDialogLayout = TRUE;
02924
02925 wxWindow * pPicker=DialogManager::GetGadget(WindowID, _R(IDC_EDIT_PICKER));
02926 if (pPicker)
02927 pPicker->Freeze();
02928 WindowID->Freeze();
02929
02930 if (pPicker && (s_UserSize != wxDefaultSize))
02931 {
02932
02933 pPicker->SetSize(pPicker->GetSize().GetWidth()+1, pPicker->GetSize().GetHeight()+1);
02934 WindowID->Layout();
02935 WindowID->Fit();
02936 wxSizer * pSizer = WindowID->GetSizer();
02937 if (pSizer)
02938 pSizer->SetSizeHints(WindowID);
02939 pPicker->SetMinSize(s_UserSize);
02940 pPicker->SetMaxSize(s_UserSize);
02941 pPicker->SetSize(s_UserSize);
02942 }
02943
02944 RecursiveBestSize(WindowID);
02945
02946 ArtificialSizeEvents(WindowID);
02947 if (!flag)
02948 {
02949 flag++;
02950 wxPlatformDependent::Get()->RealYield();
02951 flag--;
02952 }
02953
02954
02955
02956
02957 if (pPicker && (s_UserSize != wxDefaultSize))
02958 {
02959
02960 pPicker->SetMinSize((s_JustCreated && (s_UserSize != wxDefaultSize))?s_UserSize:s_MinSize);
02961 pPicker->SetMaxSize(wxDefaultSize);
02962 }
02963
02964 RecursiveBestSize(WindowID);
02965
02966 ArtificialSizeEvents(WindowID);
02967 if (!flag)
02968 {
02969 flag++;
02970 wxPlatformDependent::Get()->RealYield();
02971 flag--;
02972 }
02973
02974 WindowID->Thaw();
02975 if (pPicker)
02976 {
02977 pPicker->Thaw();
02978 pPicker->Refresh();
02979 }
02980
02981
02982
02983
02984
02985 s_IdleCounter = 3;
02986 GetApplication()->NeedMoreIdles();
02987 s_InColourDialogLayout = FALSE;
02988 }
02989
02990
02991
02992
02993
02994
02995
02996
02997
02998
02999
03000
03001
03002
03003
03004
03005
03006 void ColourPicker::ArtificialSizeEvents(CWindowID WindowID)
03007 {
03008 if (!WindowID->IsShown())
03009 return;
03010
03011
03012 wxWindowList::Node * pNode = WindowID->GetChildren().GetFirst();
03013 while (pNode)
03014 {
03015 ArtificialSizeEvents(pNode->GetData());
03016 pNode = pNode->GetNext();
03017 }
03018
03019 wxSizeEvent event( WindowID->GetSize(), WindowID->GetId() );
03020 event.SetEventObject( WindowID );
03021 WindowID->GetEventHandler()->ProcessEvent( event );
03022 }
03023
03024
03025
03026
03027
03028
03029
03030
03031
03032
03033
03034
03035
03036 void ColourPicker::OnSize(CWindowID WindowID)
03037 {
03038 wxWindow * pGadget = DialogManager::GetGadget(WindowID, _R(IDC_EDIT_PICKER));
03039 if (pGadget)
03040 {
03041 wxSize NewSize = pGadget->GetSize();
03042
03043 if (s_LastSize != NewSize)
03044 {
03045
03046 s_LastSize = NewSize;
03047 if (!s_InColourDialogLayout && !s_IdleCounter && WindowID->IsShown())
03048 {
03049
03050 s_UserSize = NewSize;
03051 }
03052 }
03053 }
03054 }
03055
03056
03057
03058
03059
03060
03061
03062
03063
03064
03065
03066
03067
03068 BOOL ColourPicker::OnIdleEvent(CWindowID WindowID)
03069 {
03070 if (s_InColourDialogLayout)
03071 return FALSE;
03072
03073 if (s_IdleCounter>0)
03074 {
03075 s_IdleCounter--;
03076 }
03077
03078 if (s_JustCreated && !s_IdleCounter)
03079 {
03080
03081 s_JustCreated=FALSE;
03082 RelayoutDialog(WindowID);
03083 }
03084
03085 return (s_IdleCounter!=0);
03086 }
03087
03088
03089
03090
03091
03092
03093
03094
03095
03096
03097
03098
03099
03100 void ColourPicker::OnCreate(CWindowID WindowID)
03101 {
03102 s_IdleCounter=0;
03103 s_JustCreated=TRUE;
03104
03105
03106 wxWindow * pPicker=DialogManager::GetGadget(WindowID, _R(IDC_EDIT_PICKER));
03107 if (pPicker && (s_UserSize != wxDefaultSize))
03108 {
03109
03110 pPicker->SetSize(pPicker->GetSize().GetWidth()+1, pPicker->GetSize().GetHeight()+1);
03111 WindowID->Layout();
03112 WindowID->Fit();
03113 wxSizer *pSizer = WindowID->GetSizer();
03114 if (pSizer)
03115 pSizer->SetSizeHints(WindowID);
03116 pPicker->SetMinSize(s_UserSize);
03117 pPicker->SetMaxSize(s_UserSize);
03118 pPicker->SetSize(s_UserSize);
03119 }
03120 }