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 #include "camtypes.h"
00104
00105 #include "bfxdlg.h"
00106
00107
00108 #include "oilprog.h"
00109
00110 #include "ccdc.h"
00111 #include "dlgcol.h"
00112
00113 #include "grnddib.h"
00114
00115
00116
00117 #include "nodebmp.h"
00118 #include "bitmpinf.h"
00119
00120 #include "bmpcomp.h"
00121
00122 #include "bitmapfx.h"
00123
00124 #include "progress.h"
00125
00126 #include "chapter.h"
00127 #include "page.h"
00128
00129
00130
00131
00132
00133
00134 #include "wrkrect.h"
00135 #include "bubbleid.h"
00136
00137
00138
00139
00140
00141 DECLARE_SOURCE("$Revision: 1282 $");
00142
00143
00144
00145 CC_IMPLEMENT_DYNAMIC(BfxMsg, Msg)
00146 CC_IMPLEMENT_DYNCREATE(BfxDlg, DialogTabOp)
00147 CC_IMPLEMENT_DYNCREATE(BfxOp, UndoableOperation)
00148 CC_IMPLEMENT_MEMDUMP(BfxOpParam, OpParam)
00149
00150
00151
00152 #define new CAM_DEBUG_NEW
00153
00154 const CDlgMode BfxDlg::Mode = MODELESS;
00155 const UINT32 BfxDlg::IDD = _R(IDD_BFXDLG);
00156
00157 BOOL BfxDlg::InteractiveBCC = TRUE;
00158
00159
00160
00161
00162
00163
00164
00165
00166
00167
00168
00169
00170
00171
00172 BfxDlg::BfxDlg(): DialogTabOp(BfxDlg::IDD, BfxDlg::Mode)
00173 {
00174 OpenPage = 0;
00175 pOriginal = NULL;
00176 pDestination = NULL;
00177 pPrevOriginal=NULL;
00178 pOrigInfo = NULL;
00179 Clean = FALSE;
00180 pFX = NULL;
00181 SetParameters();
00182 for (INT32 i = 0; i<=8; i++) Matrix[i]=(i==4)?1.0:0.0;
00183 }
00184
00185
00186
00187
00188
00189
00190
00191
00192
00193
00194
00195 BfxDlg::~BfxDlg()
00196 {
00197 if (pFX) delete pFX;
00198 if (pDestination) {TRACEUSER( "Alex", _T("Destructor deleting destination\n"));delete pDestination;}
00199 if (pOrigInfo) delete pOrigInfo;
00200 }
00201
00202
00203
00204
00205
00206
00207
00208
00209
00210
00211
00212
00213
00214
00215
00216
00217 BOOL BfxDlg::OriginalChanged()
00218 {
00219 if (pPrevOriginal==pOriginal) return TRUE;
00220 pPrevOriginal=pOriginal;
00221
00222 if (!pOrigInfo)
00223 {
00224 pOrigInfo = new BitmapInfo;
00225 if (!pOrigInfo) return FALSE;
00226 }
00227
00228 pOrigInfo->PixelWidth = 100;
00229 pOrigInfo->PixelHeight = 100;
00230 pOrigInfo->PixelDepth = 24;
00231 if (pOriginal && pOrigInfo)
00232 {
00233 pOriginal->ActualBitmap->GetInfo(pOrigInfo);
00234 }
00235
00236 if (SetDirty() && (OpenPage != 0))
00237 {
00238 InvalidateGadget(_R(IDC_BFXDLG_ORIGREDRAW));
00239 }
00240
00241 BROADCAST_TO_CLASS(DialogMsg(WindowID, DIM_OUT_OF_SPACE, _R(IDC_BFXDLG_ORIGREDRAW),
00242 0, OpenPage) ,DialogOp);
00243
00244 return FixOriginalComboBox();
00245 }
00246
00247
00248
00249
00250
00251
00252
00253
00254
00255
00256
00257
00258
00259
00260
00261
00262 BOOL BfxDlg::SetEffect(CCRuntimeClass * Effect)
00263 {
00264 if (pFX)
00265 {
00266 if (pFX->GetRuntimeClass() == Effect) return TRUE;
00267 delete pFX;
00268 pFX = NULL;
00269 }
00270 if (Effect)
00271 {
00272 pFX = (AccusoftBitmapEffect *) (Effect->CreateObject());
00273 if (!pFX) return FALSE;
00274 return pFX->SetParameters(Param1, Param2, Param3, Matrix);
00275 }
00276 else return TRUE;
00277 }
00278
00279
00280
00281
00282
00283
00284
00285
00286
00287
00288
00289
00290
00291
00292
00293
00294 BOOL BfxDlg::SetDirty(BOOL Redraw)
00295 {
00296 if (!ClearDestination(Redraw)) return FALSE;
00297 Clean = FALSE;
00298 if (pFX)
00299 {
00300 delete pFX;
00301 pFX = NULL;
00302 }
00303 return TRUE;
00304 }
00305
00306
00307
00308
00309
00310
00311
00312
00313
00314
00315
00316
00317
00318
00319
00320
00321 BOOL BfxDlg::DestinationChanged()
00322 {
00323 if (OpenPage)
00324 {
00325 InvalidateGadget(_R(IDC_BFXDLG_ORIGREDRAW2));
00326 }
00327 return TRUE;
00328 }
00329
00330
00331
00332
00333
00334
00335
00336
00337
00338
00339
00340
00341
00342
00343
00344
00345 BOOL BfxDlg::ClearDestination(BOOL Redraw)
00346 {
00347 if (pDestination)
00348 {
00349 delete pDestination;
00350 pDestination = NULL;
00351 return ((!Redraw) || (DestinationChanged()));
00352 }
00353 return TRUE;
00354 }
00355
00356
00357
00358
00359
00360
00361
00362
00363
00364
00365
00366
00367
00368
00369
00370
00371 BOOL BfxDlg::FindBitmap()
00372 {
00373
00374
00375 Range Sel(*(GetApplication()->FindSelection()));
00376
00377 Node* FirstSelectedNode = Sel.FindFirst();
00378 if (FirstSelectedNode != NULL)
00379 {
00380 Node* CurrentNode = FirstSelectedNode;
00381 Node* NextCurrent;
00382
00383
00384 while (CurrentNode != NULL)
00385 {
00386 NextCurrent = Sel.FindNext(CurrentNode);
00387 if ( (CurrentNode->IsSelected()) && (CurrentNode->GetRuntimeClass() == CC_RUNTIME_CLASS(NodeBitmap)) )
00388 {
00389 pOriginal = ((NodeBitmap *)(CurrentNode))->GetBitmap();
00390 return CheckOriginalBitmap();
00391 }
00392 CurrentNode = NextCurrent;
00393 }
00394
00395 }
00396
00397
00398 AttrFillGeometry* pAttrNode = AttrFillGeometry::FindFirstSelectedAttr();
00399
00400 while (pAttrNode != NULL)
00401 {
00402 if (pAttrNode->IsKindOf(CC_RUNTIME_CLASS(AttrBitmapColourFill)))
00403 {
00404 pOriginal = pAttrNode->GetBitmap();
00405 return CheckOriginalBitmap();
00406 }
00407
00408
00409 pAttrNode = AttrFillGeometry::FindNextSelectedAttr();
00410 }
00411
00412 return CheckOriginalBitmap();
00413 }
00414
00415
00416
00417
00418
00419
00420
00421
00422
00423
00424
00425
00426
00427
00428
00429
00430
00431 BOOL BfxDlg::CheckOriginalBitmap()
00432 {
00433 Document * pDoc = Document::GetSelected();
00434
00435
00436 BitmapList* Bitmaps = NULL;
00437 if (pDoc) Bitmaps = pDoc->GetBitmapList();
00438
00439 if (Bitmaps == NULL)
00440 {
00441 pOriginal = NULL;
00442 return OriginalChanged();
00443 }
00444
00445 KernelBitmap * pBmp = (KernelBitmap *)(Bitmaps->GetHead());
00446
00447 while (pBmp != NULL)
00448 {
00449 if (pBmp == pOriginal) return OriginalChanged();
00450 pBmp = (KernelBitmap *) Bitmaps->GetNext(pBmp);
00451 }
00452
00453 pOriginal = (KernelBitmap *)(Bitmaps->GetHead());
00454 return OriginalChanged();
00455 }
00456
00457
00458
00459
00460
00461
00462
00463
00464
00465
00466
00467
00468
00469
00470
00471
00472
00473
00474 BOOL BfxDlg::FixOriginalComboBox()
00475 {
00476
00477 Document * pDoc = Document::GetSelected();
00478
00479
00480 BitmapList* Bitmaps = NULL;
00481 if (pDoc) Bitmaps = pDoc->GetBitmapList();
00482
00483 if (Bitmaps == NULL)
00484 return TRUE;
00485
00486 String_256 Str;
00487
00488 if (OpenPage)
00489 {
00490 DeleteAllValues(_R(IDC_BFXDLG_ORIGCOMBO));
00491 }
00492
00493 BOOL DoneMain = FALSE;
00494 INT32 SelIndex = 0;
00495
00496 if (Bitmaps->GetCount() > 0)
00497 {
00498 INT32 Index = 0;
00499
00500 ListItem* pBmp = Bitmaps->GetHead();
00501
00502 while (pBmp != NULL)
00503 {
00504 Str = ((KernelBitmap*)pBmp)->ActualBitmap->GetName();
00505 if (OpenPage)
00506 {
00507 if (((KernelBitmap*)(pBmp)) == pOriginal)
00508 {
00509 SetStringGadgetValue(_R(IDC_BFXDLG_ORIGCOMBO),&Str, FALSE, -1);
00510 DoneMain = TRUE;
00511 SelIndex=Index;
00512 }
00513 SetStringGadgetValue(_R(IDC_BFXDLG_ORIGCOMBO),&Str,FALSE, Index++);
00514 }
00515 pBmp = Bitmaps->GetNext(pBmp);
00516 }
00517 }
00518 else
00519 {
00520 Str.Load(_R(IDS_K_BFXDLG_DEFAULT));
00521 if (OpenPage) SetStringGadgetValue(_R(IDC_BFXDLG_ORIGCOMBO),&Str,TRUE, 0);
00522 }
00523
00524 if (OpenPage)
00525 {
00526 Str.Load(_R(IDS_K_BFXDLG_DEFAULT));
00527 SetComboListLength(_R(IDC_BFXDLG_ORIGCOMBO));
00528 if (!DoneMain)
00529 {
00530 SetStringGadgetValue(_R(IDC_BFXDLG_ORIGCOMBO),&Str, FALSE, -1);
00531 SetSelectedValueIndex(_R(IDC_BFXDLG_ORIGCOMBO), 0);
00532 }
00533 else
00534 {
00535 SetSelectedValueIndex(_R(IDC_BFXDLG_ORIGCOMBO), SelIndex);
00536 }
00537 }
00538 return TRUE;
00539 }
00540
00541
00542
00543
00544
00545
00546
00547
00548
00549
00550
00551
00552
00553
00554
00555
00556
00557
00558
00559 BOOL BfxDlg::ReadOriginalComboBox()
00560 {
00561 if (!OpenPage) return FALSE;
00562
00563 Document * pDoc = Document::GetSelected();
00564
00565
00566 BitmapList* Bitmaps = NULL;
00567 if (pDoc) Bitmaps = pDoc->GetBitmapList();
00568
00569 if (Bitmaps == NULL)
00570 return TRUE;
00571
00572 ListItem* pBmp = Bitmaps->GetHead();
00573
00574 WORD Index;
00575 GetValueIndex(_R(IDC_BFXDLG_ORIGCOMBO),&Index);
00576
00577 for (INT32 i = 0; i < Index; i++)
00578 {
00579 if (pBmp == NULL)
00580 break;
00581
00582 pBmp = Bitmaps->GetNext(pBmp);
00583 }
00584
00585 pOriginal = (KernelBitmap*)pBmp;
00586 return CheckOriginalBitmap();
00587 }
00588
00589
00590
00591
00592
00593
00594
00595
00596
00597
00598
00599
00600
00601
00602
00603
00604
00605 BOOL BfxDlg::RenderBitmap(ReDrawInfoType* ExtraInfo, KernelBitmap * BitmapToUse)
00606 {
00607
00608 DocRect VirtualSize(0, 0, ExtraInfo->dx, ExtraInfo->dy);
00609 RenderRegion* pRender = CreateGRenderRegion(&VirtualSize, ExtraInfo);
00610 if (pRender!=NULL)
00611 {
00612 DialogColourInfo RedrawColours;
00613
00614
00615 DocColour Grey(255,200,0);
00616
00617
00618 pRender->SaveContext();
00619 pRender->SetLineColour(COLOUR_TRANS);
00620
00621
00622 pRender->SetFillColour(RedrawColours.DialogBack());
00623 pRender->DrawRect(&VirtualSize);
00624
00625 if (BitmapToUse)
00626 {
00627
00628 NodeBitmap NB;
00629 NodeBitmap * pNodeBitmap = &NB;
00630
00631 if (!((pNodeBitmap == NULL) || (!pNodeBitmap->SetUpPath(12,12))))
00632 {
00633
00634 pNodeBitmap->GetBitmapRef()->SetBitmap(BitmapToUse);
00635
00636 ENSURE(pNodeBitmap->GetBitmap()->ActualBitmap != NULL, "No bitmap object found!");
00637
00638 DocRect BitmapSize(VirtualSize);
00639 BitmapInfo BMInfo;
00640 BitmapToUse->ActualBitmap->GetInfo(&BMInfo);
00641 if (BMInfo.PixelWidth==0) BMInfo.PixelWidth=1;
00642 if (BMInfo.PixelHeight==0) BMInfo.PixelHeight=1;
00643
00644 double BMAspect = ((double)(BMInfo.PixelWidth))/((double)(BMInfo.PixelHeight));
00645 double RedrawAspect = ((double)(ExtraInfo->dx))/((double)(ExtraInfo->dy));
00646
00647 if (BMAspect>RedrawAspect)
00648 {
00649
00650 INT32 NewHeight = (INT32)( 0.5 + ((double)(VirtualSize.Width()))/BMAspect);
00651 if (NewHeight<1) NewHeight = 1;
00652 BitmapSize.loy = (VirtualSize.Height()-NewHeight)/2;
00653 BitmapSize.hiy = BitmapSize.loy + NewHeight;
00654 }
00655 else
00656 {
00657
00658 INT32 NewWidth = (INT32)( 0.5 + ((double)(VirtualSize.Height()))*BMAspect);
00659 if (NewWidth<1) NewWidth = 1;
00660 BitmapSize.lox = (VirtualSize.Width()-NewWidth)/2;
00661 BitmapSize.hix = BitmapSize.lox + NewWidth;
00662 }
00663
00664
00665 pNodeBitmap->CreateShape(BitmapSize);
00666
00667 pNodeBitmap->Render(pRender);
00668 }
00669 }
00670
00671 pRender->RestoreContext();
00672
00673
00674 DestroyGRenderRegion(pRender);
00675 }
00676 return TRUE;
00677 }
00678
00679
00680
00681
00682
00683
00684
00685
00686
00687
00688
00689
00690
00691
00692
00693
00694
00695
00696
00697
00698
00699
00700
00701
00702 MsgResult BfxDlg::Message( Msg* Message)
00703 {
00704 if (IS_OUR_DIALOG_MSG(Message))
00705 {
00706 DialogMsg* Msg = ((DialogMsg*) Message);
00707
00708 BOOL EndDialog = FALSE;
00709 BOOL CommitValues = FALSE;
00710
00711 CDlgResID ThePage = Msg->PageID;
00712
00713 if (ThePage == 0) switch (Msg->DlgMsg)
00714 {
00715 case DIM_CREATE:
00716 OpenPage=0;
00717 pOriginal=NULL;
00718 TalkToPage(0);
00719 FindBitmap();
00720 FixOriginalComboBox();
00721 SetDirty();
00722 break;
00723
00724 case DIM_COMMIT:
00725 EndDialog = TRUE;
00726 CommitValues = TRUE;
00727 ThePage = OpenPage;
00728 break;
00729
00730 case DIM_SOFT_COMMIT:
00731 CommitValues = TRUE;
00732 ThePage = OpenPage;
00733 break;
00734
00735 case DIM_CANCEL:
00736 ThePage = OpenPage;
00737 EndDialog = TRUE;
00738 break;
00739
00740 }
00741
00742
00743 switch (Msg->DlgMsg)
00744 {
00745 case DIM_SET_ACTIVE:
00746 OpenPage = Msg->PageID;
00747 TalkToPage(Msg->PageID);
00748 CheckOriginalBitmap();
00749 FixOriginalComboBox();
00750 SetDirty();
00751 break;
00752
00753 case DIM_REDRAW :
00754
00755
00756
00757 TalkToPage(Msg->PageID);
00758 switch (Msg->GadgetID)
00759 {
00760
00761 case _R(IDC_BFXDLG_ORIGREDRAW) :
00762 {
00763 RenderBitmap((ReDrawInfoType*) Msg->DlgMsgParam, pOriginal);
00764 break;
00765 }
00766 case _R(IDC_BFXDLG_ORIGREDRAW2) :
00767 {
00768 RenderBitmap((ReDrawInfoType*) Msg->DlgMsgParam, pDestination);
00769 break;
00770 }
00771 }
00772 break;
00773
00774 case DIM_SELECTION_CHANGED:
00775 TalkToPage(Msg->PageID);
00776 switch (Msg->GadgetID)
00777 {
00778
00779 case _R(IDC_BFXDLG_ORIGCOMBO) :
00780 {
00781 ReadOriginalComboBox();
00782 break;
00783 }
00784 }
00785 break;
00786
00787 }
00788
00789
00790 if (ThePage) switch (ThePage)
00791 {
00792 case _R(IDD_BFXDLG_PG1):
00793 HandleFlipAndRotateMsg(Msg, &CommitValues, &EndDialog);
00794 break;
00795 case _R(IDD_BFXDLG_PG2):
00796 HandleResizeMsg(Msg, &CommitValues, &EndDialog);
00797 break;
00798 case _R(IDD_BFXDLG_PG3):
00799 HandleBrightnessAndContrastMsg(Msg, &CommitValues, &EndDialog);
00800 break;
00801 case _R(IDD_BFXDLG_PG4):
00802 HandleDitherMsg(Msg, &CommitValues, &EndDialog);
00803 break;
00804 case _R(IDD_BFXDLG_PG5):
00805 HandleSpecialEffectsMsg(Msg, &CommitValues, &EndDialog);
00806 break;
00807 case _R(IDD_BFXDLG_PG6):
00808 HandleAlchemistMsg(Msg, &CommitValues, &EndDialog);
00809 break;
00810 default:
00811 ERROR3("Message from unknown tab dialog page");
00812 }
00813
00814
00815 if (CommitValues)
00816 {
00817 if (pOriginal)
00818 {
00819 if (pFX)
00820 {
00821 if (!Clean)
00822 {
00823 ClearDestination();
00824 String_64 ProcessMessage(_R(IDS_BFXDLG_PROCESSING));
00825
00826 if (Msg->DlgMsg==DIM_COMMIT || Msg->DlgMsg==DIM_SOFT_COMMIT)
00827 {
00828 BeginSlowJob(100, FALSE, &ProcessMessage);
00829 ContinueSlowJob();
00830 }
00831 pFX->SetParameters(Param1, Param2, Param3, Matrix);
00832 pDestination = pFX->GetProcessedBitmap(pOriginal);
00833 if (Msg->DlgMsg==DIM_COMMIT || Msg->DlgMsg==DIM_SOFT_COMMIT)
00834 {
00835 ContinueSlowJob(99);
00836 EndSlowJob();
00837 }
00838 if (!pDestination) InformError(); else
00839 {
00840 DestinationChanged();
00841 Clean=TRUE;
00842 }
00843 }
00844 }
00845 else
00846 {
00847 TRACEUSER( "Alex", _T("Wierd - he didn't actually ask for an effect..."));
00848 }
00849 }
00850 }
00851
00852
00853 if (EndDialog)
00854 {
00855 if (pOriginal && CommitValues)
00856 {
00857 OpenPage = 0;
00858 TalkToPage(0);
00859
00860 BfxOpParam param;
00861 param.ppBitmap = &pDestination;
00862
00863 OpDescriptor* pOpDesc=OpDescriptor::FindOpDescriptor("BfxOp");
00864 ERROR3IF_PF(pOpDesc==NULL,("Couldn't find OPTOKEN_OPBFXOP op descriptor"));
00865 pOpDesc->Invoke((OpParam*)¶m);
00866
00867 }
00868
00869 ClearDestination();
00870
00871 Close();
00872
00873 End();
00874 }
00875
00876 } else if (MESSAGE_IS_A(Message, SelChangingMsg))
00877 {
00878 if (OpenPage) TalkToPage(OpenPage);
00879 SelChangingMsg *Msg = (SelChangingMsg *) Message;
00880 switch ( Msg->State )
00881 {
00882 case SelChangingMsg::SelectionState::SELECTIONCHANGED:
00883 case SelChangingMsg::SelectionState::NODECHANGED:
00884
00885 FindBitmap();
00886 break;
00887 }
00888 } else if (MESSAGE_IS_A(Message, BitmapListChangedMsg))
00889 {
00890 if (OpenPage) TalkToPage(OpenPage);
00891 CheckOriginalBitmap();
00892 FixOriginalComboBox();
00893 } else if (MESSAGE_IS_A(Message, BfxMsg))
00894 {
00895 if (OpenPage) TalkToPage(OpenPage);
00896 pOriginal=((BfxMsg*)(Message))->pBitmap;
00897 CheckOriginalBitmap();
00898 }
00899
00900 return DialogTabOp::Message(Message);
00901 }
00902
00903
00904
00905
00906
00907
00908
00909
00910
00911
00912
00913
00914
00915
00916
00917
00918
00919
00920
00921
00922
00923
00924 void BfxDlg::HandleFlipAndRotateMsg(DialogMsg* Msg, BOOL *pCommitValues, BOOL *pEndDialog)
00925 {
00926 TalkToPage(_R(IDD_BFXDLG_PG1));
00927 switch(Msg->DlgMsg)
00928 {
00929 case DIM_CREATE:
00930 SetLongGadgetValue(_R(IDC_BFXDLG_FLIPX), TRUE);
00931 SetLongGadgetValue(_R(IDC_BFXDLG_FLIPY), FALSE);
00932 SetLongGadgetValue(_R(IDC_BFXDLG_ROTATE90), FALSE);
00933 SetLongGadgetValue(_R(IDC_BFXDLG_ROTATE180), FALSE);
00934 SetLongGadgetValue(_R(IDC_BFXDLG_ROTATE270), FALSE);
00935 break;
00936
00937 case DIM_LFT_BN_CLICKED:
00938 case DIM_SELECTION_CHANGED:
00939 {
00940 switch (Msg->GadgetID)
00941 {
00942 case _R(IDC_BFXDLG_FLIPX):
00943 case _R(IDC_BFXDLG_FLIPY):
00944 case _R(IDC_BFXDLG_ROTATE90):
00945 case _R(IDC_BFXDLG_ROTATE180):
00946 case _R(IDC_BFXDLG_ROTATE270):
00947 SetDirty();
00948 break;
00949 default:
00950 break;
00951 }
00952 }
00953 break;
00954
00955 case DIM_COMMIT:
00956 case DIM_SOFT_COMMIT:
00957 {
00958 if (GetBoolGadgetSelected(_R(IDC_BFXDLG_FLIPX))) SetEffect(CC_RUNTIME_CLASS(ABFXFlipX));
00959 if (GetBoolGadgetSelected(_R(IDC_BFXDLG_FLIPY))) SetEffect(CC_RUNTIME_CLASS(ABFXFlipY));
00960 if (GetBoolGadgetSelected(_R(IDC_BFXDLG_ROTATE90) )) SetEffect(CC_RUNTIME_CLASS(ABFXRotate90 ));
00961 if (GetBoolGadgetSelected(_R(IDC_BFXDLG_ROTATE180))) SetEffect(CC_RUNTIME_CLASS(ABFXRotate180));
00962 if (GetBoolGadgetSelected(_R(IDC_BFXDLG_ROTATE270))) SetEffect(CC_RUNTIME_CLASS(ABFXRotate270));
00963 }
00964 break;
00965
00966 }
00967 }
00968
00969
00970
00971
00972
00973
00974
00975
00976
00977
00978
00979
00980
00981
00982
00983
00984
00985
00986 void BfxDlg::HandleResizeMsg(DialogMsg* Msg, BOOL *pCommitValues, BOOL *pEndDialog)
00987 {
00988 static BOOL ReEntered = FALSE;
00989 BOOL RescanSize = FALSE;
00990 TalkToPage(_R(IDD_BFXDLG_PG2));
00991 switch(Msg->DlgMsg)
00992 {
00993 case DIM_SET_ACTIVE:
00994 ReEntered = FALSE;
00995 break;
00996
00997 case DIM_CREATE:
00998 FindBitmap();
00999 SetLongGadgetValue(_R(IDC_BFXDLG_INTERP), TRUE);
01000 SetLongGadgetValue(_R(IDC_BFXDLG_ASPECT), TRUE);
01001 RescanSize=TRUE;
01002 break;
01003
01004 case DIM_OUT_OF_SPACE:
01005 if (Msg->GadgetID == _R(IDC_BFXDLG_ORIGREDRAW))
01006 RescanSize=TRUE;
01007 break;
01008
01009 case DIM_SELECTION_CHANGED:
01010 case DIM_SLIDER_POS_SET:
01011
01012 case DIM_LFT_BN_CLICKED:
01013 case DIM_TEXT_CHANGED:
01014 SetDirty();
01015 if ((GetLongGadgetValue(_R(IDC_BFXDLG_ASPECT),0,1)!=0) && !ReEntered)
01016 {
01017 INT32 NewX = GetLongGadgetValue(_R(IDC_BFXDLG_NEWXSIZE),0,10000000);
01018 INT32 NewY = GetLongGadgetValue(_R(IDC_BFXDLG_NEWYSIZE),0,10000000);
01019 switch (Msg->GadgetID)
01020 {
01021 case _R(IDC_BFXDLG_NEWXSIZE):
01022 if (pOrigInfo->PixelWidth)
01023 {
01024 ReEntered = TRUE;
01025 SetLongGadgetValue(_R(IDC_BFXDLG_NEWYSIZE), (INT32)(0.5+ (
01026 ((double)(pOrigInfo->PixelHeight))/((double)(pOrigInfo->PixelWidth))*((double)(NewX)) )));
01027 ReEntered = FALSE;
01028 }
01029 break;
01030
01031 case _R(IDC_BFXDLG_NEWYSIZE):
01032 if (pOrigInfo->PixelHeight)
01033 {
01034 ReEntered = TRUE;
01035 SetLongGadgetValue(_R(IDC_BFXDLG_NEWXSIZE), (INT32)(0.5+ (
01036 ((double)(pOrigInfo->PixelWidth))/((double)(pOrigInfo->PixelHeight))*((double)(NewY)) )));
01037 ReEntered = FALSE;
01038 }
01039 break;
01040
01041 default:
01042 break;
01043 }
01044 }
01045 break;
01046 case DIM_COMMIT:
01047 case DIM_SOFT_COMMIT:
01048 {
01049 SetEffect(CC_RUNTIME_CLASS(ABFXResize));
01050 INT32 NewX = GetLongGadgetValue(_R(IDC_BFXDLG_NEWXSIZE),0,10000000);
01051 INT32 NewY = GetLongGadgetValue(_R(IDC_BFXDLG_NEWYSIZE),0,10000000);
01052 if (NewX<2) NewX = 2;
01053 if (NewY<2) NewY = 2;
01054 SetParameters(NewX, NewY, (INT32)(BOOL)(GetLongGadgetValue(_R(IDC_BFXDLG_INTERP),0,1)!=0));
01055 }
01056 break;
01057 }
01058
01059 if (RescanSize && pOrigInfo)
01060 {
01061 ReEntered = TRUE;
01062 SetLongGadgetValue(_R(IDC_BFXDLG_ORIGXSIZE), pOrigInfo->PixelWidth);
01063 SetLongGadgetValue(_R(IDC_BFXDLG_NEWXSIZE), pOrigInfo->PixelWidth);
01064 SetLongGadgetValue(_R(IDC_BFXDLG_ORIGYSIZE), pOrigInfo->PixelHeight);
01065 SetLongGadgetValue(_R(IDC_BFXDLG_NEWYSIZE), pOrigInfo->PixelHeight);
01066 ReEntered = FALSE;
01067 }
01068 }
01069
01070
01071
01072
01073
01074
01075
01076
01077
01078
01079
01080
01081
01082
01083
01084
01085
01086 void BfxDlg::HandleBrightnessAndContrastMsg(DialogMsg* Msg, BOOL *pCommitValues, BOOL *pEndDialog)
01087 {
01088 TalkToPage(_R(IDD_BFXDLG_PG3));
01089 switch(Msg->DlgMsg)
01090 {
01091 case DIM_CREATE:
01092 SetGadgetRange(_R(IDC_BFXDLG_BRIGHTNESS), -127, 127, 1);
01093 SetGadgetBitmaps(_R(IDC_BFXDLG_BRIGHTNESS), _R(IDB_SLIDERBASE), _R(IDB_SLIDERSLIDER));
01094 SetGadgetRange(_R(IDC_BFXDLG_CONTRAST), -127, 127, 1);
01095 SetGadgetBitmaps(_R(IDC_BFXDLG_CONTRAST), _R(IDB_SLIDERBASE), _R(IDB_SLIDERSLIDER));
01096 SetGadgetRange(_R(IDC_BFXDLG_COLOUR), -127, 127, 1);
01097 SetGadgetBitmaps(_R(IDC_BFXDLG_COLOUR), _R(IDB_SLIDERBASE), _R(IDB_SLIDERSLIDER));
01098 SetLongGadgetValue(_R(IDC_BFXDLG_BRIGHTNESS), 0);
01099 SetLongGadgetValue(_R(IDC_BFXDLG_CONTRAST), 0);
01100 SetLongGadgetValue(_R(IDC_BFXDLG_COLOUR), 0);
01101 break;
01102
01103
01104 case DIM_LFT_BN_CLICKED:
01105 case DIM_SELECTION_CHANGED:
01106 {
01107 switch (Msg->GadgetID)
01108 {
01109 case _R(IDC_BFXDLG_BRIGHTNESS):
01110 case _R(IDC_BFXDLG_CONTRAST):
01111 case _R(IDC_BFXDLG_COLOUR):
01112 SetDirty();
01113 break;
01114 default:
01115 break;
01116 }
01117 }
01118 break;
01119
01120 case DIM_SLIDER_POS_SET:
01121 case DIM_SLIDER_POS_IDLE:
01122 case DIM_COMMIT:
01123 case DIM_SOFT_COMMIT:
01124 {
01125 INT32 Brightness = -GetLongGadgetValue(_R(IDC_BFXDLG_BRIGHTNESS),-127,127);
01126 INT32 Contrast = -GetLongGadgetValue(_R(IDC_BFXDLG_CONTRAST),-127,127);
01127 INT32 Colour = -GetLongGadgetValue(_R(IDC_BFXDLG_COLOUR),-127,127);
01128 if (Msg->DlgMsg == DIM_SLIDER_POS_SET || Msg->DlgMsg == DIM_SLIDER_POS_IDLE)
01129 {
01130 if (InteractiveBCC)
01131 {
01132 if ((!pFX) || (!pFX->IsKindOf(CC_RUNTIME_CLASS(ABFXBrightnessContrast))) ||
01133 (Brightness!=Param1) || (Contrast!=Param2) || (Colour!=Param3))
01134 {
01135 *pCommitValues = TRUE;
01136 *pEndDialog = FALSE;
01137 SetDirty(FALSE);
01138 }
01139 else break;
01140 }
01141 else
01142 {
01143 SetDirty();
01144 break;
01145 }
01146 }
01147 SetEffect(CC_RUNTIME_CLASS(ABFXBrightnessContrast));
01148 SetParameters(Brightness, Contrast, Colour);
01149 }
01150 break;
01151
01152 }
01153 }
01154
01155
01156
01157
01158
01159
01160
01161
01162
01163
01164
01165
01166
01167
01168
01169
01170
01171 void BfxDlg::HandleDitherMsg(DialogMsg* Msg, BOOL *pCommitValues, BOOL *pEndDialog)
01172 {
01173 TalkToPage(_R(IDD_BFXDLG_PG4));
01174 switch(Msg->DlgMsg)
01175 {
01176 case DIM_CREATE:
01177 SetLongGadgetValue(_R(IDC_BFXDLG_BAYERMONO), TRUE);
01178 SetLongGadgetValue(_R(IDC_BFXDLG_HALFTONEMONO), FALSE);
01179 SetLongGadgetValue(_R(IDC_BFXDLG_DIFFUSIONMONO), FALSE);
01180 SetLongGadgetValue(_R(IDC_BFXDLG_BAYERCOLOUR), FALSE);
01181 SetLongGadgetValue(_R(IDC_BFXDLG_DIFFUSIONCOLOUR), FALSE);
01182 SetLongGadgetValue(_R(IDC_BFXDLG_POPULARITY), FALSE);
01183 SetLongGadgetValue(_R(IDC_BFXDLG_MAKEGREYSCALE), FALSE);
01184 SetLongGadgetValue(_R(IDC_BFXDLG_OCTREECOLOUR), FALSE);
01185
01186
01187
01188
01189 break;
01190
01191 case DIM_LFT_BN_CLICKED:
01192 case DIM_SELECTION_CHANGED:
01193 {
01194 switch (Msg->GadgetID)
01195 {
01196 case _R(IDC_BFXDLG_BAYERMONO):
01197 case _R(IDC_BFXDLG_HALFTONEMONO):
01198 case _R(IDC_BFXDLG_DIFFUSIONMONO):
01199 case _R(IDC_BFXDLG_BAYERCOLOUR):
01200 case _R(IDC_BFXDLG_DIFFUSIONCOLOUR):
01201 case _R(IDC_BFXDLG_POPULARITY):
01202 case _R(IDC_BFXDLG_MAKEGREYSCALE):
01203 case _R(IDC_BFXDLG_OCTREECOLOUR):
01204 SetDirty();
01205 break;
01206 default:
01207 break;
01208 }
01209 }
01210 break;
01211
01212 case DIM_COMMIT:
01213 case DIM_SOFT_COMMIT:
01214 {
01215 if (GetBoolGadgetSelected(_R(IDC_BFXDLG_BAYERMONO) )) SetEffect(CC_RUNTIME_CLASS(ABFXBayerMono));
01216 if (GetBoolGadgetSelected(_R(IDC_BFXDLG_HALFTONEMONO) )) SetEffect(CC_RUNTIME_CLASS(ABFXHalftoneMono));
01217 if (GetBoolGadgetSelected(_R(IDC_BFXDLG_DIFFUSIONMONO) )) SetEffect(CC_RUNTIME_CLASS(ABFXDiffusionMono));
01218 if (GetBoolGadgetSelected(_R(IDC_BFXDLG_BAYERCOLOUR) )) SetEffect(CC_RUNTIME_CLASS(ABFXBayerColour));
01219 if (GetBoolGadgetSelected(_R(IDC_BFXDLG_DIFFUSIONCOLOUR))) SetEffect(CC_RUNTIME_CLASS(ABFXDiffusionColour));
01220 if (GetBoolGadgetSelected(_R(IDC_BFXDLG_POPULARITY) )) SetEffect(CC_RUNTIME_CLASS(ABFXPopularityColour));
01221 if (GetBoolGadgetSelected(_R(IDC_BFXDLG_MAKEGREYSCALE) )) SetEffect(CC_RUNTIME_CLASS(ABFXMakeGreyscale));
01222 if (GetBoolGadgetSelected(_R(IDC_BFXDLG_OCTREECOLOUR) )) SetEffect(CC_RUNTIME_CLASS(ABFXOctree));
01223 }
01224 break;
01225
01226 }
01227 }
01228
01229
01230
01231
01232
01233
01234
01235
01236
01237
01238
01239
01240
01241
01242
01243
01244
01245
01246 void BfxDlg::HandleSpecialEffectsMsg(DialogMsg* Msg, BOOL *pCommitValues, BOOL *pEndDialog)
01247 {
01248 TalkToPage(_R(IDD_BFXDLG_PG5));
01249 switch(Msg->DlgMsg)
01250 {
01251 case DIM_CREATE:
01252 {
01253 SetLongGadgetValue(_R(IDC_BFXDLG_EFFECTCOMBO), 0);
01254 SetLongGadgetValue(_R(IDC_BFXDLG_CUSTOM1), (INT32)(Matrix[0]+0.5));
01255 SetLongGadgetValue(_R(IDC_BFXDLG_CUSTOM2), (INT32)(Matrix[1]+0.5));
01256 SetLongGadgetValue(_R(IDC_BFXDLG_CUSTOM3), (INT32)(Matrix[2]+0.5));
01257 SetLongGadgetValue(_R(IDC_BFXDLG_CUSTOM4), (INT32)(Matrix[3]+0.5));
01258 SetLongGadgetValue(_R(IDC_BFXDLG_CUSTOM5), (INT32)(Matrix[4]+0.5));
01259 SetLongGadgetValue(_R(IDC_BFXDLG_CUSTOM6), (INT32)(Matrix[5]+0.5));
01260 SetLongGadgetValue(_R(IDC_BFXDLG_CUSTOM7), (INT32)(Matrix[6]+0.5));
01261 SetLongGadgetValue(_R(IDC_BFXDLG_CUSTOM8), (INT32)(Matrix[7]+0.5));
01262 SetLongGadgetValue(_R(IDC_BFXDLG_CUSTOM9), (INT32)(Matrix[8]+0.5));
01263 SetGadgetRange(_R(IDC_BFXDLG_AMOUNT), 0, 127, 1);
01264 SetGadgetBitmaps(_R(IDC_BFXDLG_AMOUNT), _R(IDB_QUALITYBASE), _R(IDB_QUALITYSLIDER));
01265 SetLongGadgetValue(_R(IDC_BFXDLG_AMOUNT), 64);
01266
01267 DeleteAllValues(_R(IDC_BFXDLG_EFFECTCOMBO));
01268
01269 String_256 Str0(_R(IDS_BFXDLG_EFFECTMENU0));
01270 String_256 Str1(_R(IDS_BFXDLG_EFFECTMENU1));
01271 String_256 Str2(_R(IDS_BFXDLG_EFFECTMENU2));
01272 String_256 Str3(_R(IDS_BFXDLG_EFFECTMENU3));
01273 String_256 Str4(_R(IDS_BFXDLG_EFFECTMENU4));
01274 String_256 Str5(_R(IDS_BFXDLG_EFFECTMENU5));
01275 String_256 Str6(_R(IDS_BFXDLG_EFFECTMENU6));
01276 String_256 Str7(_R(IDS_BFXDLG_EFFECTMENU7));
01277 String_256 Str8(_R(IDS_BFXDLG_EFFECTMENU8));
01278 String_256 Str9(_R(IDS_BFXDLG_EFFECTMENU9));
01279 String_256 Str10(_R(IDS_BFXDLG_EFFECTMENU10));
01280 String_256 Str11(_R(IDS_BFXDLG_EFFECTMENU11));
01281 String_256 Str12(_R(IDS_BFXDLG_EFFECTMENU12));
01282 String_256 Str13(_R(IDS_BFXDLG_EFFECTMENU13));
01283 String_256 Str14(_R(IDS_BFXDLG_EFFECTMENU14));
01284 String_256 Str15(_R(IDS_BFXDLG_EFFECTMENU15));
01285 String_256 Str16(_R(IDS_BFXDLG_EFFECTMENU16));
01286 String_256 Str17(_R(IDS_BFXDLG_EFFECTMENU17));
01287 String_256 Str18(_R(IDS_BFXDLG_EFFECTMENU18));
01288 String_256 Str19(_R(IDS_BFXDLG_EFFECTMENU19));
01289
01290 SetStringGadgetValue(_R(IDC_BFXDLG_EFFECTCOMBO),&Str0,FALSE, 0);
01291 SetStringGadgetValue(_R(IDC_BFXDLG_EFFECTCOMBO),&Str1,FALSE, 1);
01292 SetStringGadgetValue(_R(IDC_BFXDLG_EFFECTCOMBO),&Str2,FALSE, 2);
01293 SetStringGadgetValue(_R(IDC_BFXDLG_EFFECTCOMBO),&Str3,FALSE, 3);
01294 SetStringGadgetValue(_R(IDC_BFXDLG_EFFECTCOMBO),&Str4,FALSE, 4);
01295 SetStringGadgetValue(_R(IDC_BFXDLG_EFFECTCOMBO),&Str5,FALSE, 5);
01296 SetStringGadgetValue(_R(IDC_BFXDLG_EFFECTCOMBO),&Str6,FALSE, 6);
01297 SetStringGadgetValue(_R(IDC_BFXDLG_EFFECTCOMBO),&Str7,FALSE, 7);
01298 SetStringGadgetValue(_R(IDC_BFXDLG_EFFECTCOMBO),&Str8,FALSE, 8);
01299 SetStringGadgetValue(_R(IDC_BFXDLG_EFFECTCOMBO),&Str9,FALSE, 9);
01300 SetStringGadgetValue(_R(IDC_BFXDLG_EFFECTCOMBO),&Str10,FALSE, 10);
01301 SetStringGadgetValue(_R(IDC_BFXDLG_EFFECTCOMBO),&Str11,FALSE, 11);
01302 SetStringGadgetValue(_R(IDC_BFXDLG_EFFECTCOMBO),&Str12,FALSE, 12);
01303 SetStringGadgetValue(_R(IDC_BFXDLG_EFFECTCOMBO),&Str13,FALSE, 13);
01304 SetStringGadgetValue(_R(IDC_BFXDLG_EFFECTCOMBO),&Str14,FALSE, 14);
01305 SetStringGadgetValue(_R(IDC_BFXDLG_EFFECTCOMBO),&Str15,FALSE, 15);
01306 if (IsUserName("Alex"))
01307 {
01308 SetStringGadgetValue(_R(IDC_BFXDLG_EFFECTCOMBO),&Str16,FALSE, 16);
01309 SetStringGadgetValue(_R(IDC_BFXDLG_EFFECTCOMBO),&Str17,FALSE, 17);
01310 SetStringGadgetValue(_R(IDC_BFXDLG_EFFECTCOMBO),&Str18,FALSE, 18);
01311 SetStringGadgetValue(_R(IDC_BFXDLG_EFFECTCOMBO),&Str19,FALSE, 19);
01312 }
01313
01314
01315 SetStringGadgetValue(_R(IDC_BFXDLG_EFFECTCOMBO),&Str11, FALSE, -1);
01316 SetComboListLength(_R(IDC_BFXDLG_EFFECTCOMBO));
01317 SetSelectedValueIndex(_R(IDC_BFXDLG_EFFECTCOMBO), 11);
01318 }
01319
01320
01321 case DIM_SLIDER_POS_SET:
01322
01323 case DIM_LFT_BN_CLICKED:
01324 case DIM_SELECTION_CHANGED:
01325 case DIM_TEXT_CHANGED:
01326 {
01327 SetDirty();
01328 INT32 Choice = GetSelectedValueIndex(_R(IDC_BFXDLG_EFFECTCOMBO));
01329 BOOL GreyAmount = (Choice <= 9);
01330 BOOL GreyCustom = (Choice != 0);
01331 EnableGadget(_R(IDC_BFXDLG_CUSTOM1), !GreyCustom);
01332 EnableGadget(_R(IDC_BFXDLG_CUSTOM2), !GreyCustom);
01333 EnableGadget(_R(IDC_BFXDLG_CUSTOM3), !GreyCustom);
01334 EnableGadget(_R(IDC_BFXDLG_CUSTOM4), !GreyCustom);
01335 EnableGadget(_R(IDC_BFXDLG_CUSTOM5), !GreyCustom);
01336 EnableGadget(_R(IDC_BFXDLG_CUSTOM6), !GreyCustom);
01337 EnableGadget(_R(IDC_BFXDLG_CUSTOM7), !GreyCustom);
01338 EnableGadget(_R(IDC_BFXDLG_CUSTOM8), !GreyCustom);
01339 EnableGadget(_R(IDC_BFXDLG_CUSTOM9), !GreyCustom);
01340 EnableGadget(_R(IDC_BFXDLG_AMOUNT), !GreyAmount);
01341 EnableGadget(_R(IDC_BFXDLG_AMOUNTTXT), !GreyAmount);
01342 }
01343 break;
01344
01345 case DIM_COMMIT:
01346 case DIM_SOFT_COMMIT:
01347 {
01348 INT32 Choice = GetSelectedValueIndex(_R(IDC_BFXDLG_EFFECTCOMBO));
01349 Matrix[0]=GetDoubleGadgetValue(_R(IDC_BFXDLG_CUSTOM1),-255.0,255.0);
01350 Matrix[1]=GetDoubleGadgetValue(_R(IDC_BFXDLG_CUSTOM2),-255.0,255.0);
01351 Matrix[2]=GetDoubleGadgetValue(_R(IDC_BFXDLG_CUSTOM3),-255.0,255.0);
01352 Matrix[3]=GetDoubleGadgetValue(_R(IDC_BFXDLG_CUSTOM4),-255.0,255.0);
01353 Matrix[4]=GetDoubleGadgetValue(_R(IDC_BFXDLG_CUSTOM5),-255.0,255.0);
01354 Matrix[5]=GetDoubleGadgetValue(_R(IDC_BFXDLG_CUSTOM6),-255.0,255.0);
01355 Matrix[6]=GetDoubleGadgetValue(_R(IDC_BFXDLG_CUSTOM7),-255.0,255.0);
01356 Matrix[7]=GetDoubleGadgetValue(_R(IDC_BFXDLG_CUSTOM8),-255.0,255.0);
01357 Matrix[8]=GetDoubleGadgetValue(_R(IDC_BFXDLG_CUSTOM9),-255.0,255.0);
01358
01359 switch (Choice)
01360 {
01361 case 0:
01362 case 1:
01363 case 2:
01364 case 3:
01365 case 4:
01366 case 5:
01367 case 6:
01368 case 7:
01369 case 8:
01370 case 9:
01371 SetEffect(CC_RUNTIME_CLASS(ABFXSpecialEffect));
01372 SetParameters((INT32) Choice);
01373 break;
01374 case 10:
01375 SetEffect(CC_RUNTIME_CLASS(ABFXSharpenBlur));
01376 SetParameters(((INT32) 127-GetLongGadgetValue(_R(IDC_BFXDLG_AMOUNT),0,127)), 1);
01377 break;
01378 case 11:
01379 SetEffect(CC_RUNTIME_CLASS(ABFXSharpenBlur));
01380 SetParameters(((INT32) 127-GetLongGadgetValue(_R(IDC_BFXDLG_AMOUNT),0,127)), 2);
01381 break;
01382 case 12:
01383 SetEffect(CC_RUNTIME_CLASS(ABFXSharpenBlur));
01384 SetParameters(((INT32) 127-GetLongGadgetValue(_R(IDC_BFXDLG_AMOUNT),0,127)), 3);
01385 break;
01386 case 13:
01387 SetEffect(CC_RUNTIME_CLASS(ABFXSharpenBlur));
01388 SetParameters(((INT32) GetLongGadgetValue(_R(IDC_BFXDLG_AMOUNT),0,127))-127, 1);
01389 break;
01390 case 14:
01391 SetEffect(CC_RUNTIME_CLASS(ABFXSharpenBlur));
01392 SetParameters(((INT32) GetLongGadgetValue(_R(IDC_BFXDLG_AMOUNT),0,127))-127, 2);
01393 break;
01394 case 15:
01395 SetEffect(CC_RUNTIME_CLASS(ABFXSharpenBlur));
01396 SetParameters(((INT32) GetLongGadgetValue(_R(IDC_BFXDLG_AMOUNT),0,127))-127, 3);
01397 break;
01398 case 16:
01399 case 17:
01400 case 18:
01401 case 19:
01402 SetEffect(CC_RUNTIME_CLASS(ABFXRemoveDither));
01403 SetParameters((127-((INT32) GetLongGadgetValue(_R(IDC_BFXDLG_AMOUNT),0,127)))<<1, 30, Choice-16);
01404 break;
01405 }
01406 }
01407
01408 }
01409 }
01410
01411
01412
01413
01414
01415
01416
01417
01418
01419
01420
01421
01422
01423
01424
01425
01426
01427
01428 void BfxDlg::HandleAlchemistMsg(DialogMsg* Msg, BOOL *pCommitValues, BOOL *pEndDialog)
01429 {
01430 TalkToPage(_R(IDD_BFXDLG_PG6));
01431 switch(Msg->DlgMsg)
01432 {
01433 case DIM_CREATE:
01434 {
01435 SetLongGadgetValue(_R(IDC_BFXDLG_ALC_HUE_CHECK), TRUE);
01436 SetLongGadgetValue(_R(IDC_BFXDLG_ALC_SATURATION_CHECK), TRUE);
01437 SetLongGadgetValue(_R(IDC_BFXDLG_ALC_VALUE_CHECK), TRUE);
01438 SetLongGadgetValue(_R(IDC_BFXDLG_ALC_RAINBOW_CHECK), TRUE);
01439 SetLongGadgetValue(_R(IDC_BFXDLG_ALC_VARIATION_CHECK), TRUE);
01440 SetLongGadgetValue(_R(IDC_BFXDLG_ALC_SHAPES_CHECK), TRUE);
01441 SetLongGadgetValue(_R(IDC_BFXDLG_ALC_STYLE_CHECK), TRUE);
01442 SetLongGadgetValue(_R(IDC_BFXDLG_ALC_OPACITY_CHECK), TRUE);
01443 SetLongGadgetValue(_R(IDC_BFXDLG_ALC_GRAIN_CHECK), TRUE);
01444
01445 SetGadgetRange (_R(IDC_BFXDLG_ALC_HUE_SLIDER), 0, 127, 1);
01446 SetGadgetBitmaps (_R(IDC_BFXDLG_ALC_HUE_SLIDER), _R(IDB_QUALITYBASE), _R(IDB_QUALITYSLIDER));
01447 SetLongGadgetValue(_R(IDC_BFXDLG_ALC_HUE_SLIDER), 64);
01448 SetGadgetRange (_R(IDC_BFXDLG_ALC_SATURATION_SLIDER), 0, 127, 1);
01449 SetGadgetBitmaps (_R(IDC_BFXDLG_ALC_SATURATION_SLIDER), _R(IDB_QUALITYBASE), _R(IDB_QUALITYSLIDER));
01450 SetLongGadgetValue(_R(IDC_BFXDLG_ALC_SATURATION_SLIDER), 64);
01451 SetGadgetRange (_R(IDC_BFXDLG_ALC_VALUE_SLIDER), 0, 127, 1);
01452 SetGadgetBitmaps (_R(IDC_BFXDLG_ALC_VALUE_SLIDER), _R(IDB_QUALITYBASE), _R(IDB_QUALITYSLIDER));
01453 SetLongGadgetValue(_R(IDC_BFXDLG_ALC_VALUE_SLIDER), 64);
01454 SetGadgetRange (_R(IDC_BFXDLG_ALC_RAINBOW_SLIDER), 0, 127, 1);
01455 SetGadgetBitmaps (_R(IDC_BFXDLG_ALC_RAINBOW_SLIDER), _R(IDB_QUALITYBASE), _R(IDB_QUALITYSLIDER));
01456 SetLongGadgetValue(_R(IDC_BFXDLG_ALC_RAINBOW_SLIDER), 64);
01457 SetGadgetRange (_R(IDC_BFXDLG_ALC_VARIATION_SLIDER), 0, 127, 1);
01458 SetGadgetBitmaps (_R(IDC_BFXDLG_ALC_VARIATION_SLIDER), _R(IDB_QUALITYBASE), _R(IDB_QUALITYSLIDER));
01459 SetLongGadgetValue(_R(IDC_BFXDLG_ALC_VARIATION_SLIDER), 64);
01460 SetGadgetRange (_R(IDC_BFXDLG_ALC_SHAPES_SLIDER), 0, 127, 1);
01461 SetGadgetBitmaps (_R(IDC_BFXDLG_ALC_SHAPES_SLIDER), _R(IDB_QUALITYBASE), _R(IDB_QUALITYSLIDER));
01462 SetLongGadgetValue(_R(IDC_BFXDLG_ALC_SHAPES_SLIDER), 64);
01463 SetGadgetRange (_R(IDC_BFXDLG_ALC_STYLE_SLIDER), 0, 127, 1);
01464 SetGadgetBitmaps (_R(IDC_BFXDLG_ALC_STYLE_SLIDER), _R(IDB_QUALITYBASE), _R(IDB_QUALITYSLIDER));
01465 SetLongGadgetValue(_R(IDC_BFXDLG_ALC_STYLE_SLIDER), 64);
01466 SetGadgetRange (_R(IDC_BFXDLG_ALC_OPACITY_SLIDER), 0, 127, 1);
01467 SetGadgetBitmaps (_R(IDC_BFXDLG_ALC_OPACITY_SLIDER), _R(IDB_QUALITYBASE), _R(IDB_QUALITYSLIDER));
01468 SetLongGadgetValue(_R(IDC_BFXDLG_ALC_OPACITY_SLIDER), 64);
01469 SetGadgetRange (_R(IDC_BFXDLG_ALC_GRAIN_SLIDER), 0, 127, 1);
01470 SetGadgetBitmaps (_R(IDC_BFXDLG_ALC_GRAIN_SLIDER), _R(IDB_QUALITYBASE), _R(IDB_QUALITYSLIDER));
01471 SetLongGadgetValue(_R(IDC_BFXDLG_ALC_GRAIN_SLIDER), 64);
01472
01473 }
01474 break;
01475
01476 case DIM_SLIDER_POS_SET:
01477
01478 case DIM_LFT_BN_CLICKED:
01479 case DIM_SELECTION_CHANGED:
01480 case DIM_TEXT_CHANGED:
01481 {
01482 SetDirty();
01483 }
01484 break;
01485
01486 case DIM_COMMIT:
01487 case DIM_SOFT_COMMIT:
01488 {
01489 }
01490 break;
01491
01492 }
01493 }
01494
01495
01496
01497
01498
01499
01500
01501
01502
01503
01504
01505
01506
01507
01508
01509
01510
01511
01512
01513 OpState BfxDlg::GetState(String_256*, OpDescriptor*)
01514 {
01515 OpState OpSt;
01516 return(OpSt);
01517 }
01518
01519
01520
01521
01522
01523
01524
01525
01526
01527
01528
01529
01530
01531
01532
01533
01534
01535
01536 BOOL BfxDlg::Init()
01537 {
01538 GetApplication()->DeclareSection( "Bitmap Effects", 1);
01539 GetApplication()->DeclarePref( "Bitmap Effects", "Interactive Brightness & Contrast", &InteractiveBCC, FALSE, TRUE);
01540
01541 return (RegisterOpDescriptor(
01542 0,
01543 _R(IDS_BFXDLGM),
01544 CC_RUNTIME_CLASS(BfxDlg),
01545 OPTOKEN_BFXDLG,
01546 BfxDlg::GetState,
01547 0,
01548 _R(IDBBL_BITMAPEFFECTS),
01549 _R(IDD_BARCONTROLSTORE),
01550 _R(IDC_BITMAPEFFECTS),
01551 SYSTEMBAR_UTILITIES,
01552 TRUE,
01553 FALSE,
01554 TRUE,
01555 0,
01556 _R(IDS_BFXDLG_ONE),
01557 GREY_WHEN_NO_CURRENT_DOC | DONT_GREY_WHEN_SELECT_INSIDE
01558 )
01559
01560 && BfxOp::Init());
01561 }
01562
01563
01564
01565
01566
01567
01568
01569
01570
01571
01572
01573
01574
01575
01576
01577
01578 void BfxMsg::OpenOrUse(KernelBitmap * pBitmap)
01579 {
01580
01581 OpDescriptor* OpDesc = OpDescriptor::FindOpDescriptor(CC_RUNTIME_CLASS(BfxDlg));
01582 if (!OpDesc) return;
01583
01584
01585 if (!MessageHandler::MessageHandlerExists(CC_RUNTIME_CLASS(BfxDlg)))
01586 {
01587 OpDesc->Invoke(&OpParam((INT32)pBitmap,(INT32)NULL));
01588 }
01589 else
01590 {
01591 BROADCAST_TO_CLASS(BfxMsg(pBitmap),DialogOp);
01592 }
01593 return;
01594 }
01595
01596
01597
01598
01599
01600
01601
01602
01603
01604
01605
01606
01607
01608
01609
01610
01611 void BfxDlg::Do(OpDescriptor*)
01612 {
01613 String_256 Title(_R(IDS_BFXDLG));
01614 SetName(&Title);
01615 BOOL ok = Create();
01616 if (!ok)
01617 {
01618 ;
01619 OpenPage=0;
01620 End();
01621 }
01622 TalkToPage(0);
01623 SetStringGadgetValue(_R(ID_APPLY_NOW), _R(IDS_BFXDLG_TEST));
01624 SetStringGadgetValue(IDOK, _R(IDS_BFXDLG_INSERT));
01625 SetStringGadgetValue(IDCANCEL, _R(IDS_BFXDLG_CLOSE));
01626 }
01627
01628
01629
01630
01631
01632
01633
01634
01635
01636
01637
01638
01639
01640
01641
01642
01643
01644
01645 void BfxDlg::DoWithParam(OpDescriptor* pOp, OpParam* pParam)
01646 {
01647 Do(pOp);
01648 KernelBitmap * pBitmap = NULL;
01649 if (pParam) pBitmap = (KernelBitmap *)(void *)(pParam->Param1);
01650 if (pBitmap && pBitmap->IsKindOf(CC_RUNTIME_CLASS(KernelBitmap)))
01651 {
01652 pOriginal=pBitmap;
01653 TalkToPage(OpenPage);
01654 OriginalChanged();
01655 }
01656 return;
01657 }
01658
01659
01660
01661
01662
01663
01664
01665
01666
01667
01668
01669
01670
01671
01672
01673
01674
01675
01676
01677
01678
01679
01680
01681
01682
01683
01684
01685
01686
01687 BOOL BfxDlg::RegisterYourPagesInOrderPlease()
01688 {
01689 BOOL ok = AddAPage(_R(IDD_BFXDLG_PG1)) &&
01690 AddAPage(_R(IDD_BFXDLG_PG2)) &&
01691 AddAPage(_R(IDD_BFXDLG_PG3)) &&
01692 AddAPage(_R(IDD_BFXDLG_PG4)) &&
01693 AddAPage(_R(IDD_BFXDLG_PG5)) &&
01694 #ifdef _DEBUG
01695 ((!IsUserName("Alex")) || AddAPage(_R(IDD_BFXDLG_PG6))) &&
01696 #endif
01697 TRUE;
01698 return (ok);
01699 }
01700
01701
01702
01703
01704
01705
01706
01707
01708
01709
01710
01711
01712
01713
01714
01715
01716
01717
01718 BfxOp::BfxOp(): UndoableOperation()
01719 {
01720 }
01721
01722
01723
01724
01725
01726
01727
01728
01729
01730
01731
01732
01733
01734
01735
01736
01737
01738
01739
01740 BOOL BfxOp::Init()
01741 {
01742 return (UndoableOperation::RegisterOpDescriptor(
01743 0,
01744 _R(IDS_BFXOP),
01745 CC_RUNTIME_CLASS(BfxOp),
01746 OPTOKEN_BFXOP,
01747 BfxOp::GetState,
01748 0,
01749 0,
01750 0 ));
01751 }
01752
01753
01754
01755
01756
01757
01758
01759
01760
01761
01762
01763
01764
01765
01766
01767
01768 OpState BfxOp::GetState(String_256*, OpDescriptor*)
01769 {
01770 OpState OpSt;
01771 return(OpSt);
01772 }
01773
01774
01775
01776
01777
01778
01779
01780
01781
01782
01783
01784
01785
01786
01787
01788
01789
01790
01791 void BfxOp::DoWithParam(OpDescriptor* pOp, OpParam* pParam)
01792 {
01793 DocCoord DropPos;
01794 Spread * pSpread;
01795 BOOL ok=FALSE;
01796
01797 if (!GetWorkingDoc()) return;
01798
01799 if (!FindCentreInsertionPosition(&pSpread, &DropPos))
01800 {
01801 InformError();
01802 FailAndExecute();
01803 End();
01804 return;
01805 }
01806
01807
01808 NodeBitmap *pNodeBitmap = new NodeBitmap;
01809 if ((pNodeBitmap == NULL) || (!pNodeBitmap->SetUpPath(12,12)))
01810 {
01811 InformError();
01812 FailAndExecute();
01813 End();
01814 return;
01815 }
01816
01817 KernelBitmap* pKB = *(((BfxOpParam *)(pParam))->ppBitmap);
01818 if (pKB == NULL)
01819 {
01820
01821 delete pNodeBitmap;
01822 FailAndExecute();
01823 End();
01824 return;
01825 }
01826
01827
01828 BeginSlowJob(100, FALSE);
01829 *(((BfxOpParam *)(pParam))->ppBitmap) = NULL;
01830
01831
01832
01833 OILBitmap* pOILBmp = pKB->ExtractOILBitmap();
01834 pKB = KernelBitmap::MakeKernelBitmap(pOILBmp, GetWorkingDoc());
01835
01836 pNodeBitmap->GetBitmapRef()->Attach(pKB);
01837
01838 if (pNodeBitmap->GetBitmap() != pKB)
01839 {
01840
01841 delete pKB;
01842 }
01843
01844
01845 BitmapInfo Info;
01846 pNodeBitmap->GetBitmap()->ActualBitmap->GetInfo(&Info);
01847
01848 DocRect BoundsRect;
01849 BoundsRect.lo.x = DropPos.x - (Info.RecommendedWidth/2);
01850 BoundsRect.lo.y = DropPos.y - (Info.RecommendedHeight/2);
01851 BoundsRect.hi.x = BoundsRect.lo.x + Info.RecommendedWidth;
01852 BoundsRect.hi.y = BoundsRect.lo.y + Info.RecommendedHeight;
01853
01854
01855 pNodeBitmap->CreateShape(BoundsRect);
01856
01857
01858
01859 if (!pNodeBitmap->ApplyDefaultBitmapAttrs(this))
01860 {
01861 goto EndOp;
01862 }
01863
01864
01865 if (!DoInsertNewNode(pNodeBitmap, pSpread, TRUE))
01866 {
01867
01868 delete pNodeBitmap;
01869 goto EndOp;
01870 }
01871
01872 ok = TRUE;
01873
01874 EndOp:
01875 if (!ok)
01876 {
01877 FailAndExecute();
01878 InformError();
01879 }
01880
01881 EndSlowJob();
01882 End();
01883 }
01884
01885
01886
01887
01888
01889
01890
01891
01892
01893
01894
01895
01896
01897
01898
01899
01900
01901
01902 BOOL BfxOp::FindCentreInsertionPosition(Spread** Spread, DocCoord* Position)
01903 {
01904
01905 ERROR3IF(Spread == NULL || Position == NULL, "Illegal NULL params");
01906 *Spread = NULL;
01907 *Position = DocCoord(0,0);
01908
01909
01910
01911
01912
01913 ERROR2IF((!Spread)||(!Position),FALSE,"Invalid call to FindCentreInsertionPoint()");
01914
01915 DocView* CurDocView = GetWorkingDocView();
01916
01917 ERROR2IF(!CurDocView, FALSE, "The current DocView is NULL");
01918
01919 WorkRect WrkViewRect = CurDocView->GetViewRect();
01920
01921 ERROR2IF((WrkViewRect.IsEmpty() || (!WrkViewRect.IsValid()) ), FALSE, "Invalid WorkRect");
01922
01923
01924 WorkCoord WrkCentreOfView;
01925 WrkCentreOfView.x = WrkViewRect.lox + (WrkViewRect.Width()/2);
01926 WrkCentreOfView.y = WrkViewRect.loy + (WrkViewRect.Height()/2);
01927
01928
01929 OilCoord OilCentreOfView = WrkCentreOfView.ToOil(CurDocView->GetScrollOffsets());
01930
01931
01932 (*Spread) = CurDocView->FindEnclosingSpread(OilCentreOfView);
01933 ERROR2IF(!(*Spread), FALSE, "No spread?!");
01934
01935
01936
01937
01938 DocRect DocViewRect = CurDocView->GetDocViewRect(*Spread);
01939
01940 ERROR2IF( ( (DocViewRect.IsEmpty()) || !(DocViewRect.IsValid())), FALSE, "DocViewRect is invalid" );
01941
01942
01943 DocCoord DocCentreOfView;
01944 DocCentreOfView.x = DocViewRect.lox + (DocViewRect.Width()/2);
01945 DocCentreOfView.y = DocViewRect.loy + (DocViewRect.Height()/2);
01946
01947
01948 (*Spread)->DocCoordToSpreadCoord(&DocCentreOfView);
01949
01950
01951 *Position = DocCentreOfView;
01952
01953 return TRUE;
01954 }
01955
01956