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 #include "camtypes.h"
00101
00102
00103
00104
00105
00106 #include "sgbitmap.h"
00107 #include "sginit.h"
00108 #include "sgmenu.h"
00109
00110
00111
00112
00113
00114
00115 #include "bitmpinf.h"
00116
00117
00118 #include "nodebmp.h"
00119
00120
00121
00122 #include "dragmgr.h"
00123 #include "dragbmp.h"
00124
00125
00126
00127
00128 #include "tracedlg.h"
00129 #include "bfxdlg.h"
00130
00131
00132 #include "impexpop.h"
00133
00134
00135
00136
00137
00138
00139 #include "bmpcomp.h"
00140
00141
00142
00143 #include "comattrmsg.h"
00144 #include "bmpsdlg.h"
00145
00146
00147 #include "giffiltr.h"
00148 #include "bmpsrc.h"
00149
00150 #include "plugop.h"
00151 #include "backgrnd.h"
00152 #include "keypress.h"
00153 #include "impexpop.h"
00154 #include "prevwdlg.h"
00155 #include "bmpexprw.h"
00156
00157 #include "helpuser.h"
00158
00159
00160
00161 #include "qualattr.h"
00162 #include "bfxop.h"
00163 #include "fillattr2.h"
00164
00165 #ifdef PHOTOSHOPPLUGINS
00166 #include "plugmngr.h"
00167 #endif //PHOTOSHOPPLUGINS
00168
00169 #include "camview.h"
00170
00171
00172 CC_IMPLEMENT_DYNCREATE(BitmapSGallery, SuperGallery)
00173 CC_IMPLEMENT_DYNAMIC(SGDisplayKernelBitmap, SGDisplayItem)
00174 CC_IMPLEMENT_DYNCREATE(OpDisplayBitmapGallery,Operation);
00175 CC_IMPLEMENT_DYNAMIC(SGBitmapDragTarget, SGListDragTarget);
00176
00177 CC_IMPLEMENT_DYNCREATE(GalleryBitmapDragInfo, BitmapDragInformation)
00178
00179
00180
00181
00182
00183 #define new CAM_DEBUG_NEW
00184
00185
00186 BOOL BitmapSGallery::IgnoreBmpListChange = FALSE;
00187
00188
00189
00190
00191
00192
00193
00194
00195
00196
00197
00198
00199
00200
00201
00202 SGBitmapDragTarget::SGBitmapDragTarget(DialogOp *TheDialog, CGadgetID TheGadget)
00203 : SGListDragTarget(TheDialog, TheGadget)
00204 {
00205 ERROR3IF(!TheDialog->IsKindOf(CC_RUNTIME_CLASS(BitmapSGallery)),
00206 "You can only use SGBitmapDragTargets with BitmapSGallery dialogues!");
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 BOOL SGBitmapDragTarget::ProcessEvent(DragEventType Event, DragInformation *pDragInfo,
00233 OilCoord *pMousePos, KeyPress* pKeyPress)
00234 {
00235 if (!pDragInfo->IsKindOf(CC_RUNTIME_CLASS(BitmapDragInformation)))
00236 return(FALSE);
00237
00238 SGDisplayNode *DraggedNode = NULL;
00239 BOOL IsSimpleBitmapDrag = TRUE;
00240
00241 if (IS_A(pDragInfo, GalleryBitmapDragInfo))
00242 {
00243 DraggedNode = ((GalleryBitmapDragInfo *)pDragInfo)->GetDraggedBitmap();
00244
00245 IsSimpleBitmapDrag = FALSE;
00246
00247 }
00248
00249 if (DraggedNode != NULL)
00250 {
00251 switch(Event)
00252 {
00253 case DRAGEVENT_COMPLETED:
00254 HandleDragCompleted((SuperGallery *) TargetDialog,
00255 DraggedNode, pMousePos, IsSimpleBitmapDrag);
00256 return(TRUE);
00257
00258
00259 case DRAGEVENT_MOUSESTOPPED:
00260 case DRAGEVENT_MOUSEMOVED:
00261 case DRAGEVENT_MOUSEIDLE:
00262
00263 return(DetermineCursorShape((SuperGallery *) TargetDialog,
00264 DraggedNode, pMousePos));
00265 default:
00266 break;
00267 }
00268 }
00269
00270 return(FALSE);
00271 }
00272
00273
00274
00275
00276
00277
00278
00279
00280
00281
00282
00283
00284 GalleryBitmapDragInfo::GalleryBitmapDragInfo()
00285 {
00286 ERROR3("Default GalleryBitmapDragInfo constructor called");
00287 }
00288
00289
00290
00291
00292
00293
00294
00295
00296
00297
00298
00299
00300
00301
00302
00303
00304
00305
00306
00307
00308
00309 GalleryBitmapDragInfo::GalleryBitmapDragInfo(SGDisplayKernelBitmap *pSourceItem,
00310 SGMouseInfo *pMouseInfo, SGMiscInfo *pMiscInfo,
00311 BOOL IsAdjust)
00312 : BitmapDragInformation(pSourceItem->GetDisplayedKernelBitmap(),
00313 120, 0, 0, 0, IsAdjust)
00314 {
00315 SourceItem = pSourceItem;
00316
00317 MouseInfo = *pMouseInfo;
00318 MiscInfo = *pMiscInfo;
00319 }
00320
00321
00322
00323
00324
00325
00326
00327
00328
00329
00330
00331
00332 GalleryBitmapDragInfo::~GalleryBitmapDragInfo()
00333 {
00334 }
00335
00336
00337
00338
00339
00340
00341
00342
00343
00344
00345
00346
00347
00348
00349
00350
00351
00352
00353
00354 void GalleryBitmapDragInfo::OnClick(INT32 Flags ,POINT Point)
00355 {
00356 if (SourceItem != NULL)
00357 SourceItem->DragWasReallyAClick(&MouseInfo, &MiscInfo);
00358 }
00359
00360
00361
00362
00363
00364
00365
00366
00367
00368
00369
00370
00371 UINT32 GalleryBitmapDragInfo::GetCursorID(DragTarget* pDragTarget)
00372 {
00373 if (pDragTarget && pDragTarget->IS_KIND_OF(ViewDragTarget))
00374 {
00375 PageDropInfo PageDropInfo;
00376 ((ViewDragTarget*)pDragTarget)->GetDropInfo(&PageDropInfo);
00377
00378 NodeRenderableInk* pObjectHit = PageDropInfo.pObjectHit;
00379 ObjectDragTarget TargetHit = PageDropInfo.TargetHit;
00380
00381 if (pObjectHit && pObjectHit->IS_KIND_OF(NodeBitmap))
00382 TargetHit = NO_TARGET;
00383
00384 ClickModifiers ClickMods = ClickModifiers::GetClickModifiers();
00385 BOOL IsInside = ClickMods.Constrain;
00386
00387 if (!IsInside && pObjectHit && pObjectHit->IsCompound())
00388 {
00389 TargetHit = MANY_TARGET;
00390 }
00391
00392 UINT32 CanFill = IsInside ? _R(IDC_DROPINSIDEONFILL) : _R(IDC_CANDROPONFILL);
00393
00394 switch (TargetHit)
00395 {
00396 case FILL_TARGET:
00397 case LINE_TARGET:
00398 case STARTCOL_TARGET:
00399 case ENDCOL_TARGET:
00400 case ENDCOL2_TARGET:
00401 case ENDCOL3_TARGET:
00402 case MANY_TARGET:
00403 return CanFill;
00404
00405 case NO_TARGET:
00406
00407 return IsInside ? _R(IDC_CANFILLPAGE) : _R(IDC_CANDROPONPAGE);
00408
00409 };
00410
00411 return _R(IDC_CANDROPONPAGE);
00412 }
00413
00414 return _R(IDC_CANTDROP);
00415 }
00416
00417
00418
00419
00420
00421
00422
00423
00424
00425
00426
00427
00428 BOOL GalleryBitmapDragInfo::GetStatusLineText(String_256 * TheText, DragTarget* pDragTarget)
00429 {
00430 ERROR2IF(TheText==NULL,FALSE,"NULL string in GetStatusLineText()");
00431
00432 if (TheBitmap == NULL || TheBitmap->ActualBitmap == NULL)
00433 return FALSE;
00434
00435 String_256 DragString;
00436 String_256 BmpName(TheBitmap->ActualBitmap->GetName());
00437 DragString.MakeMsg(_R(IDS_SGBITMAP_DRAGGING_BITMAP), (TCHAR *)BmpName);
00438
00439 if (pDragTarget && pDragTarget->IS_KIND_OF(ViewDragTarget))
00440 {
00441 PageDropInfo PageDropInfo;
00442 ((ViewDragTarget*)pDragTarget)->GetDropInfo(&PageDropInfo);
00443
00444 NodeRenderableInk* pObjectHit = PageDropInfo.pObjectHit;
00445 ObjectDragTarget TargetHit = PageDropInfo.TargetHit;
00446
00447 String_256 ObjectDesc = String_32(_R(IDS_SGBITMAP_THIS_OBJECT));
00448
00449 if (pObjectHit)
00450 {
00451 ObjectDesc = pObjectHit->Describe(FALSE);
00452 }
00453
00454 if (pObjectHit && pObjectHit->IS_KIND_OF(NodeBitmap))
00455 TargetHit = NO_TARGET;
00456
00457 ClickModifiers ClickMods = ClickModifiers::GetClickModifiers();
00458 BOOL IsInside = ClickMods.Constrain;
00459
00460 if (!IsInside && pObjectHit && pObjectHit->IsCompound())
00461 {
00462 TargetHit = MANY_TARGET;
00463 }
00464
00465 switch (TargetHit)
00466 {
00467 case FILL_TARGET:
00468 case LINE_TARGET:
00469 case STARTCOL_TARGET:
00470 case ENDCOL_TARGET:
00471 case ENDCOL2_TARGET:
00472 case ENDCOL3_TARGET:
00473 DragString += String_256(_R(IDS_SGBITMAP_DROP_APPLY_FILL));
00474 DragString += ObjectDesc;
00475 if (IsInside)
00476 DragString += String_16(_R(IDS_SGBITMAP_ALONE));
00477 break;
00478 case MANY_TARGET:
00479 DragString += String_256(_R(IDS_SGBITMAP_DROP_APPLY_FILL));
00480 DragString += ObjectDesc;
00481 DragString += String_256(_R(IDS_SGBITMAP_CONTROL_DROP_INSIDE));
00482 break;
00483 case NO_TARGET:
00484 if (IsInside)
00485 {
00486 DragString += String_256(_R(IDS_DRAGBMP_DROP_SETPAGEBACKGROUND));
00487 }
00488 else
00489 {
00490 DragString += String_256(_R(IDS_SGBITMAP_DROP_INSERT_BITMAP));
00491 }
00492 break;
00493 };
00494
00495 *TheText = DragString;
00496 return TRUE;
00497 }
00498
00499 return FALSE;
00500 }
00501
00502
00503
00504
00505
00506
00507
00508
00509
00510
00511
00512
00513
00514
00515
00516
00517 BOOL GalleryBitmapDragInfo::OnPageDrop(ViewDragTarget* pDragTarget)
00518 {
00519 PageDropInfo ThePageDropInfo;
00520 ((ViewDragTarget*)pDragTarget)->GetDropInfo(&ThePageDropInfo);
00521 NodeRenderableInk* pObjectHit = ThePageDropInfo.pObjectHit;
00522
00523
00524 KernelBitmap* BitmapToApply = TheBitmap;
00525 TheBitmap = NULL;
00526
00527 if(BitmapToApply == NULL)
00528 return FALSE;
00529
00530
00531
00532 if (pObjectHit && !pObjectHit->IS_KIND_OF(NodeBitmap))
00533 {
00534
00535 AttrBitmapColourFill* Attrib = new AttrBitmapColourFill;
00536 if (Attrib == NULL)
00537 return FALSE;
00538
00539 Attrib->AttachBitmap(BitmapToApply);
00540
00541 AttributeManager::ApplyAttribToNode(pObjectHit, Attrib);
00542 }
00543 else
00544 {
00545
00546
00547 BOOL Constrain = KeyPress::IsConstrainPressed();
00548 if (Constrain)
00549 {
00550
00551
00552 Document * pDocument = ThePageDropInfo.pDoc;
00553 if (pDocument == NULL)
00554 return FALSE;
00555 OpBackgroundParam Param;
00556 Param.pBitmap = BitmapToApply;
00557 Param.pDoc = pDocument;
00558 Param.pSpread = ThePageDropInfo.pSpread;
00559
00560
00561 OpDescriptor* pOpDesc = OpDescriptor::FindOpDescriptor(OPTOKEN_BACKGROUND);
00562
00563
00564 if (pOpDesc)
00565 pOpDesc->Invoke(&Param);
00566 }
00567 else
00568 {
00569
00570
00571
00572 OpDescriptor* OpDesc = OpDescriptor::FindOpDescriptor(CC_RUNTIME_CLASS(OpCreateNodeBitmap));
00573
00574 if (OpDesc)
00575 {
00576
00577 OpParam param((void *)BitmapToApply,(void *)&ThePageDropInfo);
00578 OpDesc->Invoke(¶m);
00579 }
00580 }
00581 }
00582
00583 return TRUE;
00584 }
00585
00586
00587
00588
00589
00590
00591
00592
00593
00594
00595
00596
00597
00598
00599 SGDisplayKernelBitmap::SGDisplayKernelBitmap()
00600 {
00601 ERROR3("Illegal call on default SGDisplayKernelBitmap constructor - call the other one!");
00602 TheKernelBitmap = NULL;
00603 }
00604
00605
00606
00607
00608
00609
00610
00611
00612
00613
00614
00615
00616
00617
00618
00619 SGDisplayKernelBitmap::SGDisplayKernelBitmap(KernelBitmap *KernelBitmapToDisplay)
00620 {
00621 ERROR3IF(KernelBitmapToDisplay == NULL,
00622 "SGDisplayKernelBitmap - trying to construct me with a NULL parameter is bad");
00623
00624 TheKernelBitmap = KernelBitmapToDisplay;
00625 }
00626
00627
00628
00629
00630
00631
00632
00633
00634
00635
00636
00637
00638
00639
00640
00641
00642
00643
00644
00645
00646
00647
00648
00649
00650
00651
00652
00653
00654
00655 void SGDisplayKernelBitmap::CalculateMyRect(SGFormatInfo *FormatInfo, SGMiscInfo *MiscInfo)
00656 {
00657 INT32 XSize;
00658 INT32 YSize;
00659
00660 switch (MiscInfo->DisplayMode)
00661 {
00662 case 1:
00663 XSize = GridLock(MiscInfo, SG_InfiniteWidth);
00664 YSize = GridLock(MiscInfo, SG_DefaultSmallBmp);
00665 break;
00666
00667 case 2:
00668 XSize = GridLock(MiscInfo, SG_DefaultLargeBmpText);
00669 YSize = GridLock(MiscInfo, SG_DefaultLargeBmp);
00670 break;
00671
00672 default:
00673 XSize = GridLock(MiscInfo, SG_InfiniteWidth);
00674 YSize = GridLock(MiscInfo, SG_DefaultLargeBmp);
00675 break;
00676 }
00677
00678 BitmapInfo Info;
00679 INT32 MaxYSize = YSize;
00680
00681 if (TheKernelBitmap->ActualBitmap &&
00682 TheKernelBitmap->ActualBitmap->GetInfo( &Info )
00683 )
00684 {
00685
00686
00687
00688 double BitmapWidth = Info.RecommendedWidth;
00689 double BitmapHeight = Info.RecommendedHeight;
00690
00691
00692 double Ratio = BitmapHeight/BitmapWidth;
00693
00694 YSize = INT32(YSize * Ratio);
00695
00696
00697 INT32 SelHeight = 16000;
00698
00699 if (YSize < SelHeight*3)
00700 YSize = SelHeight*3;
00701
00702 if (YSize > MaxYSize)
00703 YSize = MaxYSize;
00704 }
00705
00706 CalculateFormatRect(FormatInfo, MiscInfo, XSize, YSize);
00707 }
00708
00709
00710
00711
00712
00713
00714
00715
00716
00717
00718
00719
00720
00721
00722
00723
00724
00725
00726
00727
00728
00729
00730
00731
00732 void SGDisplayKernelBitmap::HandleRedraw(SGRedrawInfo *RedrawInfo, SGMiscInfo *MiscInfo)
00733 {
00734 if (TheKernelBitmap == NULL || TheKernelBitmap->ActualBitmap == NULL)
00735 return;
00736
00737 StartRendering(RedrawInfo, MiscInfo);
00738
00739 DocRect MyRect(FormatRect);
00740
00741
00742
00743 if (MyRect.IsEmpty() || !MyRect.IsValid())
00744 {
00745
00746
00747 StopRendering(RedrawInfo, MiscInfo);
00748 return;
00749 }
00750
00751
00752
00753
00754
00755 INT32 SelHeight = 23000;
00756
00757 if (MyRect.Height() < SelHeight*3)
00758 {
00759 INT32 diff = SelHeight*3 - MyRect.Height();
00760 MyRect.Inflate(0, diff);
00761 }
00762
00763 RenderRegion *Renderer = RedrawInfo->Renderer;
00764
00765 INT32 OnePixel = (INT32) DevicePixels(MiscInfo, 1);
00766 INT32 TwoPixels = (INT32) DevicePixels(MiscInfo, 2);
00767 INT32 ThreePixels = (INT32) DevicePixels(MiscInfo, 3);
00768
00769 Renderer->SetLineWidth(0);
00770 Renderer->SetLineColour(RedrawInfo->Transparent);
00771
00772
00773 DocRect IconRect(MyRect);
00774
00775 BitmapInfo Info;
00776
00777 BOOL bScaleDown = FALSE;
00778
00779 if (TheKernelBitmap->ActualBitmap &&
00780 TheKernelBitmap->ActualBitmap->GetInfo( &Info ))
00781 {
00782
00783 double BitmapWidth = Info.RecommendedWidth;
00784 double BitmapHeight = Info.RecommendedHeight;
00785
00786
00787 double Ratio = BitmapWidth/BitmapHeight;
00788
00789 INT32 IconWidth = INT32(IconRect.Height() * Ratio);
00790
00791 INT32 YSize;
00792 switch (MiscInfo->DisplayMode)
00793 {
00794 case 1:
00795 YSize = GridLock(MiscInfo, SG_DefaultSmallBmp);
00796 break;
00797
00798 case 2:
00799 YSize = GridLock(MiscInfo, SG_DefaultLargeBmp);
00800 break;
00801
00802 default:
00803 YSize = GridLock(MiscInfo, SG_DefaultLargeBmp);
00804 break;
00805 }
00806
00807
00808
00809 if (IconWidth > YSize)
00810 {
00811 Matrix Scale;
00812 Ratio = double(IconWidth)/double(YSize);
00813
00814 Scale = Matrix(FIXED16(1)/Ratio, FIXED16(1)/Ratio);
00815
00816 DocCoord Centre;
00817 Centre.x = IconRect.lo.x;
00818 Centre.y = IconRect.lo.y + IconRect.Height()/2;
00819
00820
00821
00822 IconRect.Translate(-Centre.x, -Centre.y);
00823 Scale.transform(&IconRect.lo);
00824 Scale.transform(&IconRect.hi);
00825 IconRect.Translate(Centre.x, Centre.y);
00826
00827 IconWidth = YSize;
00828 bScaleDown = TRUE;
00829 }
00830
00831 INT32 RightSpace = 0;
00832
00833 if (IconWidth < YSize)
00834 {
00835 INT32 LeftSpace = TwoPixels * 4;
00836 RightSpace = YSize - IconWidth - LeftSpace;
00837 IconRect.Translate(LeftSpace, 0);
00838 }
00839
00840
00841 IconRect.hi.x = IconRect.lo.x + IconWidth;
00842
00843 MyRect.lo.x = IconRect.hi.x + RightSpace + TwoPixels;
00844 MyRect.lo.x += TwoPixels;
00845
00846
00847
00848 INT32 MaxYSize = YSize;
00849 INT32 IconHeight = IconRect.Height();
00850 if (IconHeight > MaxYSize)
00851 {
00852 Matrix Scale;
00853 Ratio = double(IconHeight)/double(YSize);
00854
00855 Scale = Matrix(FIXED16(1)/Ratio, FIXED16(1)/Ratio);
00856
00857 DocCoord Centre;
00858 Centre.x = IconRect.lo.x + IconRect.Width()/2;
00859 Centre.y = IconRect.hi.y;
00860
00861
00862
00863 IconRect.Translate(-Centre.x, -Centre.y);
00864 Scale.transform(&IconRect.lo);
00865 Scale.transform(&IconRect.hi);
00866 IconRect.Translate(Centre.x, Centre.y);
00867
00868 MyRect.lo.y = IconRect.lo.y;
00869 MyRect.hi.y = IconRect.hi.y;
00870 bScaleDown = TRUE;
00871 }
00872 }
00873
00874
00875
00876
00877
00878
00879
00880
00881
00882
00883
00884
00885
00886
00887
00888
00889
00890
00891
00892
00893
00894 GridLockRect(MiscInfo, &MyRect);
00895
00896
00897
00898
00899
00900
00901 if (IconRect.Height() > ThreePixels * 2)
00902 IconRect.Inflate(0, -ThreePixels);
00903
00904 if (IconRect.Width() > ThreePixels * 2)
00905 IconRect.Inflate(-ThreePixels, 0);
00906
00907 GridLockRect(MiscInfo, &IconRect);
00908
00909
00910 DocRect ThumbnailRect(IconRect);
00911
00912
00913
00914
00915 if (ThumbnailRect.Width()==0)
00916 ThumbnailRect.hi.x = ThumbnailRect.lo.x + OnePixel;
00917 if (ThumbnailRect.Height()==0)
00918 ThumbnailRect.hi.y = ThumbnailRect.lo.y + OnePixel;
00919
00920
00921 if (Flags.Selected)
00922 {
00923
00924
00925
00926
00927 Renderer->SetFillColour(RedrawInfo->SelBackground);
00928
00929 Renderer->SetFillColour(COLOUR_BLACK);
00930 IconRect.Inflate(ThreePixels);
00931
00932
00933
00934
00935 Renderer->DrawRect(&IconRect);
00936
00937
00938
00939 if (MyRect.IsValid())
00940 {
00941 DocRect SelRect(MyRect);
00942 if (SelHeight > MyRect.Height()/2)
00943 SelHeight = MyRect.Height()/2;
00944
00945 SelRect.hi.y = MyRect.lo.y + MyRect.Height()/2 + SelHeight;
00946 SelRect.lo.y = MyRect.lo.y + MyRect.Height()/2 - SelHeight;
00947 SelRect.lo.x += ThreePixels;
00948 GridLockRect(MiscInfo, &SelRect);
00949
00950 Renderer->SetFillColour(RedrawInfo->SelBackground);
00951 Renderer->DrawRect(&SelRect);
00952 }
00953
00954 Renderer->SetFixedSystemTextColours(&RedrawInfo->SelForeground, &RedrawInfo->SelBackground);
00955 }
00956 else
00957 {
00958
00959 Renderer->SetFixedSystemTextColours(&RedrawInfo->Foreground, &RedrawInfo->Background);
00960 }
00961
00962
00963 #ifdef SGBITMAP_BACKGROUND_REDRAW
00964
00965 BOOL DrawnBitmap = FALSE;
00966
00967 if (ShouldIDrawForeground(DrawnBitmap))
00968 {
00969 if(!DrawnBitmap)
00970 {
00971
00972
00973 NodeBitmap* DummyBmp = new NodeBitmap();
00974 if (DummyBmp == NULL)
00975 {
00976
00977 SGLibDisplayItem::DrawNullBitmapRect(Renderer, MiscInfo, &ThumbnailRect, FALSE);
00978 StopRendering(RedrawInfo, MiscInfo);
00979 return;
00980 }
00981
00982
00983
00984 DummyBmp->SetUpPath();
00985 DummyBmp->CreateShape(ThumbnailRect);
00986 DummyBmp->GetBitmapRef()->SetBitmap(TheKernelBitmap);
00987
00988
00989 DummyBmp->Render(Renderer);
00990
00991 delete DummyBmp;
00992 }
00993 }
00994 else
00995 {
00996
00997 if(!DrawnBitmap)
00998 SGLibDisplayItem::DrawNullBitmapRect(Renderer, MiscInfo, &ThumbnailRect, TRUE);
00999 }
01000
01001 #else
01002
01003
01004
01005 NodeBitmap* DummyBmp = new NodeBitmap();
01006 if (DummyBmp == NULL)
01007 {
01008
01009 StopRendering(RedrawInfo, MiscInfo);
01010 return;
01011 }
01012
01013
01014
01015 DummyBmp->SetUpPath();
01016 DummyBmp->CreateShape(ThumbnailRect);
01017 DummyBmp->GetBitmapRef()->SetBitmap(TheKernelBitmap);
01018
01019
01020 DummyBmp->Render(Renderer);
01021
01022 delete DummyBmp;
01023
01024 #endif
01025
01026
01027 MyRect.lo.x += SG_GapBeforeText*2;
01028
01029
01030
01031 if (MyRect.IsValid())
01032 {
01033
01034 String_256 BitmapName = TheKernelBitmap->ActualBitmap->GetName();
01035
01036
01037 String_256 BitmapCols;
01038 INT32 bpp = TheKernelBitmap->GetBPP();
01039
01040 BOOL HasTransparency = FALSE;
01041
01042 if (bpp <= 8)
01043 {
01044
01045 INT32 Index;
01046
01047 if (TheKernelBitmap->GetTransparencyIndex(&Index))
01048 HasTransparency = TRUE;
01049 }
01050
01051 switch (bpp)
01052 {
01053 case 1:
01054 if (HasTransparency)
01055 BitmapCols = _R(IDS_SGBITMAP_MONOCHROME_T);
01056 else
01057 BitmapCols = _R(IDS_SGBITMAP_MONOCHROME);
01058 break;
01059
01060 case 2:
01061 if (HasTransparency)
01062 BitmapCols = _R(IDS_SGBITMAP_4COLOURS_T);
01063 else
01064 BitmapCols = _R(IDS_SGBITMAP_4COLOURS);
01065 break;
01066
01067 case 4:
01068 if (HasTransparency)
01069 BitmapCols = _R(IDS_SGBITMAP_16COLOURS_T);
01070 else
01071 BitmapCols = _R(IDS_SGBITMAP_16COLOURS);
01072 break;
01073
01074 case 8:
01075 if (HasTransparency)
01076 BitmapCols = _R(IDS_SGBITMAP_256COLOURS_T);
01077 else
01078 BitmapCols = _R(IDS_SGBITMAP_256COLOURS);
01079 break;
01080
01081 case 16:
01082 BitmapCols = _R(IDS_SGBITMAP_65COLOURS);
01083 break;
01084
01085 case 24:
01086 BitmapCols = _R(IDS_SGBITMAP_MILLIONS_COLOURS);
01087 break;
01088
01089 case 32:
01090 BitmapCols = _R(IDS_SGBITMAP_32_BIT);
01091 break;
01092
01093 default:
01094 BitmapCols = "";
01095 break;
01096 }
01097
01098
01099 String_256 BitmapWidth;
01100 Convert::LongToString(Info.PixelWidth, &BitmapWidth);
01101
01102 String_256 BitmapHeight;
01103 Convert::LongToString(Info.PixelHeight, &BitmapHeight);
01104
01105
01106 UINT32 BitmapDelay = TheKernelBitmap->ActualBitmap->GetBitmapAnimDelay();
01107 String_256 Delay;
01108 Convert::LongToString(BitmapDelay, &Delay);
01109
01110
01111
01112
01113 INT32 Bytes = 0;
01114 BitmapSource* pSource = NULL;
01115 BaseBitmapFilter* pDummyFilter;
01116
01117 PORTNOTE("other", "Removed XPE hook")
01118 #ifndef EXCLUDE_FROM_XARALX
01119 KernelBitmap* pMaster = NULL;
01120 IXMLDOMDocumentPtr pEdits = NULL;
01121 TheKernelBitmap->GetXPEInfo(pMaster, pEdits);
01122 BOOL bIsXPE = (pMaster!=NULL && pEdits!=NULL);
01123 #else
01124 BOOL bIsXPE = FALSE;
01125 #endif
01126
01127 BOOL OriginalSourcePresent = TheKernelBitmap->GetOriginalSource(&pSource, &pDummyFilter);
01128 String_256 BitmapFormat;
01129 if(OriginalSourcePresent)
01130 {
01131 if (pSource != NULL)
01132 {
01133 if (pSource->IsJPEG())
01134 {
01135 Bytes = pSource->GetSize();
01136 BitmapFormat = _R(IDS_FORMAT_JPEG);
01137 }
01138 }
01139 }
01140 else if (bIsXPE)
01141 {
01142 BitmapFormat = _R(IDS_FORMAT_XPE);
01143 }
01144 else
01145 {
01146 Bytes = (Info.PixelWidth * Info.PixelHeight * bpp)/8;
01147 BitmapFormat = _R(IDS_FORMAT_BITMAP);
01148 }
01149
01150 String_256 MemoryUsed;
01151 Convert::BytesToString(&MemoryUsed, Bytes);
01152
01153 if (!BaseCamelotFilter::ShouldSaveXPEBitmaps() && bIsXPE)
01154 {
01155
01156
01157 MemoryUsed.Load(_R(IDS_SGBITMAP_XPE));
01158 }
01159
01160
01161
01162 DocRect TopRect(MyRect);
01163 DocRect MiddleRect(MyRect);
01164 DocRect BottomRect(MyRect);
01165
01166
01167 TopRect.lo.y += 18000;
01168 MiddleRect.hi.y -= 5000;
01169
01170 BottomRect.hi.y -= 26000;
01171
01172
01173 String_256 TopLine;
01174 TopLine.MakeMsg(_R(IDS_SGBITMAP_FULLINFO_TOPLINE),(TCHAR *)BitmapName,(TCHAR*)BitmapFormat,(TCHAR *)MemoryUsed);
01175 Renderer->DrawFixedSystemText(&TopLine, TopRect);
01176
01177
01178
01179 String_256 MiddleLine;
01180
01181
01182 UINT32 hdpi = TheKernelBitmap->ActualBitmap->GetHorizontalDPI();
01183 UINT32 vdpi = TheKernelBitmap->ActualBitmap->GetVerticalDPI();
01184
01185 if (hdpi == vdpi)
01186 {
01187 String_256 dpitext;
01188 Convert::LongToString(hdpi, &dpitext);
01189 MiddleLine.MakeMsg(_R(IDS_SGBITMAP_FULLINFO_BOTTOMLINE), (TCHAR *)BitmapWidth, (TCHAR *)BitmapHeight, (TCHAR *)BitmapCols, (TCHAR *)dpitext);
01190 }
01191 else
01192 {
01193 String_256 dpitext;
01194 camSnprintf(dpitext, 256, _T("%u x %u"), hdpi, vdpi);
01195 MiddleLine.MakeMsg(_R(IDS_SGBITMAP_FULLINFO_BOTTOMLINE), (TCHAR *)BitmapWidth, (TCHAR *)BitmapHeight, (TCHAR *)BitmapCols, (TCHAR *)dpitext);
01196 }
01197 Renderer->DrawFixedSystemText(&MiddleLine, MiddleRect);
01198
01199
01200
01201 GIFDisposalMethod RestoreType = TheKernelBitmap->ActualBitmap->GetAnimationRestoreType();
01202
01203 switch(RestoreType)
01204 {
01205 case GDM_NONE:
01206 {
01207 String_256 BottomLine;
01208 String_256 Nothing(_R(IDS_NOTHING));
01209 BottomLine.MakeMsg(_R(IDS_SGBITMAP_DELAY_RESTORE_BOTTOMLINE), (TCHAR*)Delay, (TCHAR*)Nothing);
01210 Renderer->DrawFixedSystemText(&BottomLine, BottomRect);
01211 }
01212 break;
01213 case GDM_LEAVE:
01214 {
01215 String_256 BottomLine;
01216 String_256 Leave(_R(IDS_LEAVE));
01217 BottomLine.MakeMsg(_R(IDS_SGBITMAP_DELAY_RESTORE_BOTTOMLINE), (TCHAR*)Delay, (TCHAR*)Leave);
01218 Renderer->DrawFixedSystemText(&BottomLine, BottomRect);
01219 }
01220 break;
01221 case GDM_BACKTOBACK:
01222 {
01223 String_256 BottomLine;
01224 String_256 Back(_R(IDS_BACKGROUND));
01225 BottomLine.MakeMsg(_R(IDS_SGBITMAP_DELAY_RESTORE_BOTTOMLINE), (TCHAR*)Delay, (TCHAR*)Back);
01226 Renderer->DrawFixedSystemText(&BottomLine, BottomRect);
01227 }
01228 break;
01229 case GDM_PREVIOUS:
01230 {
01231 String_256 BottomLine;
01232 String_256 Previous(_R(IDS_PREVIOUS));
01233 BottomLine.MakeMsg(_R(IDS_SGBITMAP_DELAY_RESTORE_BOTTOMLINE), (TCHAR*)Delay, (TCHAR*)Previous);
01234 Renderer->DrawFixedSystemText(&BottomLine, BottomRect);
01235 }
01236 break;
01237
01238 default:
01239 break;
01240 }
01241 }
01242
01243 StopRendering(RedrawInfo, MiscInfo);
01244 }
01245
01246
01247
01248
01249
01250
01251
01252
01253
01254
01255
01256
01257
01258
01259
01260
01261
01262
01263
01264
01265 void SGDisplayKernelBitmap::DragWasReallyAClick(SGMouseInfo *Mouse, SGMiscInfo *MiscInfo)
01266 {
01267
01268 DefaultClickHandler(Mouse, MiscInfo, TRUE);
01269 }
01270
01271
01272
01273
01274
01275
01276
01277
01278
01279
01280
01281
01282
01283
01284
01285
01286
01287
01288
01289
01290
01291
01292
01293
01294
01295
01296
01297
01298
01299
01300
01301
01302
01303
01304
01305
01306
01307
01308
01309
01310
01311
01312
01313
01314
01315
01316
01317
01318 BOOL SGDisplayKernelBitmap::HandleEvent(SGEventType EventType, void *EventInfo,
01319 SGMiscInfo *MiscInfo)
01320 {
01321 switch (EventType)
01322 {
01323 case SGEVENT_FORMAT:
01324 {
01325 SGFormatInfo *FormatInfo = GetFormatInfo(EventType, EventInfo);
01326 CalculateMyRect(FormatInfo, MiscInfo);
01327 }
01328 break;
01329
01330
01331 case SGEVENT_REDRAW:
01332 {
01333 DocRect MyRect(FormatRect);
01334 SGRedrawInfo *RedrawInfo = GetRedrawInfo(EventType, EventInfo);
01335
01336 if (IMustRedraw(RedrawInfo))
01337 HandleRedraw(RedrawInfo, MiscInfo);
01338 }
01339 break;
01340
01341
01342 case SGEVENT_MOUSECLICK:
01343 {
01344 SGMouseInfo *Mouse = GetMouseInfo(EventType, EventInfo);
01345
01346 if (FormatRect.ContainsCoord(Mouse->Position))
01347 {
01348
01349
01350
01351
01352
01353
01354
01355
01356 if (Mouse->DoubleClick)
01357 {
01358
01359
01360
01361
01362
01363
01364
01365
01366
01367 DefaultClickHandler(Mouse, MiscInfo);
01368 }
01369 else
01370 {
01371 DefaultPreDragHandler(Mouse, MiscInfo);
01372
01373 GalleryBitmapDragInfo *DragBmp;
01374 DragBmp = new GalleryBitmapDragInfo(this, Mouse, MiscInfo,
01375 Mouse->MenuClick);
01376 if (DragBmp != NULL)
01377 DragManagerOp::StartDrag(DragBmp, GetListWindow());
01378 }
01379
01380 return(TRUE);
01381 }
01382 }
01383 break;
01384
01385 default:
01386 return(SGDisplayItem::HandleEvent(EventType, EventInfo, MiscInfo));
01387 }
01388
01389
01390 return(FALSE);
01391 }
01392
01393
01394
01395
01396
01397
01398
01399
01400
01401
01402
01403
01404
01405
01406
01407
01408
01409
01410
01411
01412 void SGDisplayKernelBitmap::GetNameText(String_256 *Result)
01413 {
01414 ERROR3IF(Result == NULL, "Illegal NULL param");
01415
01416 *Result = TheKernelBitmap->ActualBitmap->GetName();
01417 }
01418
01419
01420
01421
01422
01423
01424
01425
01426
01427
01428
01429
01430
01431
01432
01433
01434
01435
01436
01437
01438
01439
01440 void SGDisplayKernelBitmap::GetFullInfoText(String_256 *Result)
01441 {
01442 ERROR3IF(Result == NULL, "Illegal NULL param");
01443
01444 *Result = TheKernelBitmap->ActualBitmap->GetName();
01445 }
01446
01447
01448
01449
01450
01451
01452
01453
01454
01455
01456
01457
01458
01459
01460
01461
01462
01463
01464
01465
01466
01467
01468
01469
01470
01471
01472
01473
01474
01475
01476
01477
01478 void SGDisplayKernelBitmap::MoveAfter(SGDisplayNode *NodeToMove)
01479 {
01480 ERROR3IF(NodeToMove == NULL, "Illegal NULL param");
01481
01482 if (NodeToMove == this)
01483 return;
01484
01485 KernelBitmap *BitmapToMove = ((SGDisplayKernelBitmap *) NodeToMove)->GetDisplayedKernelBitmap();
01486 ERROR3IF(BitmapToMove == NULL, "NULL displayed bitmap?!");
01487
01488 Document *ScopeDoc = ((SGDisplayGroup *) GetParent())->GetParentDocument();
01489 ERROR3IF(ScopeDoc == NULL, "No parent document?!");
01490
01491 if ( ((SGDisplayGroup *) ( ((SGDisplayKernelBitmap *)NodeToMove)->GetParent() ) )->GetParentDocument() !=
01492 ScopeDoc)
01493 {
01494 ERROR2RAW("Attempt to MOVE a bitmap between documents!");
01495 return;
01496 }
01497
01498 BitmapSGallery::IgnoreBmpListChange = TRUE;
01499
01500
01501 BitmapList* BmpList = ScopeDoc->GetBitmapList();
01502 ERROR3IF(BmpList == NULL, "A document with no bitmap list?!");
01503
01504 BmpList->MoveAfter(GetDisplayedKernelBitmap(), BitmapToMove);
01505 SGDisplayNode::MoveAfter(NodeToMove);
01506
01507 BitmapSGallery::IgnoreBmpListChange = FALSE;
01508 }
01509
01510
01511
01512
01513
01514
01515
01516
01517
01518
01519
01520
01521
01522
01523
01524
01525
01526
01527
01528
01529
01530
01531
01532
01533
01534
01535
01536
01537
01538
01539
01540
01541 void SGDisplayKernelBitmap::MoveBefore(SGDisplayNode *NodeToMove)
01542 {
01543 ERROR3IF(NodeToMove == NULL, "Illegal NULL param");
01544
01545 if (NodeToMove == this)
01546 return;
01547
01548 KernelBitmap *BitmapToMove = ((SGDisplayKernelBitmap *) NodeToMove)->GetDisplayedKernelBitmap();
01549 ERROR3IF(BitmapToMove == NULL, "NULL displayed bitmap?!");
01550
01551 Document *ScopeDoc = ((SGDisplayGroup *) GetParent())->GetParentDocument();
01552 ERROR3IF(ScopeDoc == NULL, "No parent document?!");
01553
01554 if ( ((SGDisplayGroup *) ( ((SGDisplayKernelBitmap *)NodeToMove)->GetParent() ) )->GetParentDocument() !=
01555 ScopeDoc)
01556 {
01557 ERROR2RAW("Attempt to MOVE a bitmap between documents!");
01558 return;
01559 }
01560
01561 BitmapSGallery::IgnoreBmpListChange = TRUE;
01562
01563
01564 BitmapList* BmpList = ScopeDoc->GetBitmapList();
01565 ERROR3IF(BmpList == NULL, "A document with no bitmap list?!");
01566
01567 BmpList->MoveBefore(GetDisplayedKernelBitmap(), BitmapToMove);
01568
01569 SGDisplayNode::MoveBefore(NodeToMove);
01570
01571 BitmapSGallery::IgnoreBmpListChange = FALSE;
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 BOOL SGDisplayKernelBitmap::GetStatusLineHelp(DocCoord *MousePos, String_256 *Result)
01600 {
01601 ERROR3IF(MousePos == NULL || Result == NULL, "Invalid NULL params");
01602
01603 String_256 Name;
01604 GetNameText(&Name);
01605
01606
01607 Result->MakeMsg(_R(IDS_SGBITMAP_STATLINE), (TCHAR *)Name);
01608
01609
01610 *Result += String_256(_R(IDS_SGBITMAP_DOUBLE_CLICK));
01611
01612 return(TRUE);
01613 }
01614
01615
01616
01617
01618
01619
01620
01621
01622
01623
01624
01625
01626
01627
01628
01629
01630
01631
01632
01633
01634
01635 BitmapSGallery::BitmapSGallery()
01636 {
01637 DlgResID = _R(IDD_BITMAPSGALLERY);
01638
01639
01640
01641 #ifdef WEBSTER
01642 CSize Size(333, 256);
01643 SetGallerySize(Size);
01644 #endif
01645 }
01646
01647
01648
01649
01650
01651
01652
01653
01654
01655
01656
01657
01658
01659 BitmapSGallery::~BitmapSGallery()
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
01688
01689
01690 void BitmapSGallery::CreateNewSubtree(Document *ParentDoc, SGDisplayGroup *ExistingGroup)
01691 {
01692 ERROR3IF(ParentDoc == NULL, "BitmapSGallery::CreateNewSubtree - NULL parameter passed in");
01693 if (ParentDoc == NULL || DisplayTree == NULL)
01694 return;
01695
01696 SGDisplayGroup *DisplayDocument;
01697 SGDisplayKernelBitmap *DisplayKernelBitmap;
01698
01699 if (ExistingGroup != NULL)
01700 {
01701 ERROR3IF(ExistingGroup->GetParentDocument() != ParentDoc,
01702 "This group is not for that document! What's going down, dude?");
01703 DisplayDocument = ExistingGroup;
01704 DisplayDocument->DestroySubtree(FALSE);
01705 }
01706 else
01707 {
01708 DisplayDocument = new SGDisplayGroup(this, ParentDoc,NULL);
01709
01710 if (DisplayDocument == NULL)
01711 return;
01712
01713 DisplayDocument->Flags.CanSelect = TRUE;
01714 DisplayTree->AddItem(DisplayDocument);
01715 }
01716
01717
01718
01719
01720 BitmapList* Bitmaps = ParentDoc->GetBitmapList();
01721
01722
01723 KernelBitmap* Ptr = (KernelBitmap*)Bitmaps->GetHead();
01724 while (Ptr != NULL)
01725 {
01726
01727 if (!Ptr->GetActualBitmap()->IsHiddenInGallery())
01728 {
01729 DisplayKernelBitmap = new SGDisplayKernelBitmap(Ptr);
01730 if (DisplayKernelBitmap != NULL)
01731 DisplayDocument->AddItem(DisplayKernelBitmap);
01732 }
01733
01734 Ptr = (KernelBitmap*)Bitmaps->GetNext(Ptr);
01735 }
01736 }
01737
01738
01739
01740
01741
01742
01743
01744
01745
01746
01747
01748
01749
01750
01751
01752
01753
01754
01755
01756 BOOL BitmapSGallery::PreCreate(void)
01757 {
01758
01759 if (DisplayTree == NULL)
01760 {
01761 DisplayTree = new SGDisplayRootScroll(this);
01762 if (DisplayTree == NULL)
01763 return(FALSE);
01764 }
01765
01766
01767
01768 Document *ParentDoc = (Document *) GetApplication()->Documents.GetTail();
01769 while (ParentDoc != NULL)
01770 {
01771 SGDisplayNode *Ptr = DisplayTree->FindSubtree(this, ParentDoc, NULL);
01772 CreateNewSubtree(ParentDoc, (SGDisplayGroup *) Ptr);
01773 ParentDoc = (Document *) GetApplication()->Documents.GetPrev(ParentDoc);
01774 }
01775
01776
01777 SGDisplayGroup *Group = (SGDisplayGroup *) DisplayTree->GetChild();
01778 while (Group != NULL)
01779 {
01780
01781
01782 Group->SetFoldedState((Group->GetParentDocument() != Document::GetSelected()), FALSE);
01783 Group = (SGDisplayGroup *) Group->GetNext();
01784 }
01785
01786 return(TRUE);
01787 }
01788
01789
01790
01791
01792
01793
01794
01795
01796
01797
01798
01799
01800
01801
01802
01803
01804
01805
01806
01807 void BitmapSGallery::SetSelectionFromDocument(BOOL AlwaysScroll)
01808 {
01809 if (DisplayTree == NULL || !IsVisible())
01810 return;
01811
01812 SGDisplayGroup *DocGroup = DisplayTree->FindSubtree(this, Document::GetSelected(), NULL);
01813 SelectItems(FALSE);
01814
01815
01816
01817 BOOL AutoScrollSelection = FALSE;
01818
01819 DocRect ScrollToRect;
01820 BOOL HaveSelected = FALSE;
01821 BOOL ScrollToBottom = FALSE;
01822
01823 if (DocGroup != NULL)
01824 ForceGroupFolded(DocGroup, FALSE);
01825
01826 ReformatNow(TRUE);
01827
01828 if (AutoScrollSelection || AlwaysScroll)
01829 {
01830 if (AlwaysScroll && !HaveSelected && DocGroup != NULL)
01831 {
01832
01833
01834 DocRect TempRect;
01835
01836 DocGroup->GetChildArea(&ScrollToRect);
01837
01838 HaveSelected = TRUE;
01839 ScrollToBottom = FALSE;
01840 }
01841
01842 if (HaveSelected)
01843 ScrollToShow(&ScrollToRect, ScrollToBottom);
01844 }
01845
01846
01847 SelectionHasChanged();
01848 }
01849
01850
01851
01852
01853
01854
01855
01856
01857
01858
01859
01860
01861
01862
01863
01864
01865
01866
01867
01868
01869
01870
01871
01872
01873
01874
01875
01876
01877
01878
01879
01880
01881
01882
01883
01884
01885
01886
01887
01888
01889 SGDisplayItem *BitmapSGallery::CopyDisplayItem(SGDisplayItem *SourceItem,
01890 SGDisplayGroup *DestGroup, SGDisplayItem *TargetPosition)
01891 {
01892 ERROR3IF(SourceItem == NULL || DestGroup == NULL, "Illegal NULL param");
01893
01894 return(NULL);
01895
01896
01897
01898
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
01927
01928
01929
01930
01931
01932
01933
01934
01935
01936
01937
01938
01939
01940
01941
01942
01943
01944
01945
01946
01947 }
01948
01949
01950
01951 KernelBitmap* BitmapSGallery::GetSelectedBitmap()
01952 {
01953
01954 Document *SelectedDoc = Document::GetSelected();
01955 DisplayTree->FindSubtree(this, SelectedDoc, NULL);
01956 SGDisplayKernelBitmap *FirstSelected = NULL;
01957
01958
01959 Document *ParentDoc = (Document *) GetApplication()->Documents.GetHead();
01960 while (ParentDoc != NULL)
01961 {
01962 SGDisplayGroup *DocGroup = DisplayTree->FindSubtree(this, ParentDoc, NULL);
01963 if (DocGroup != NULL)
01964 FirstSelected = (SGDisplayKernelBitmap *) DocGroup->FindNextSelectedItem(NULL);
01965
01966 if (FirstSelected)
01967 break;
01968
01969 ParentDoc = (Document *) GetApplication()->Documents.GetNext(ParentDoc);
01970 }
01971
01972 KernelBitmap *SelectedBitmap = NULL;
01973 if (FirstSelected != NULL)
01974 {
01975 SelectedBitmap = FirstSelected->GetDisplayedKernelBitmap();
01976 }
01977
01978 return SelectedBitmap;
01979 }
01980
01981
01982
01983
01984
01985
01986
01987
01988
01989
01990
01991
01992
01993
01994
01995
01996
01997
01998
01999
02000
02001
02002 BOOL BitmapSGallery::ApplyAction(SGActionType Action)
02003 {
02004
02005 if (DisplayTree == NULL)
02006 return(FALSE);
02007
02008
02009 Document *SelectedDoc = Document::GetSelected();
02010 DisplayTree->FindSubtree(this, SelectedDoc, NULL);
02011 SGDisplayKernelBitmap *FirstSelected = NULL;
02012
02013
02014 Document *ParentDoc = (Document *) GetApplication()->Documents.GetHead();
02015 while (ParentDoc != NULL)
02016 {
02017 SGDisplayGroup *DocGroup = DisplayTree->FindSubtree(this, ParentDoc, NULL);
02018 if (DocGroup != NULL)
02019 FirstSelected = (SGDisplayKernelBitmap *) DocGroup->FindNextSelectedItem(NULL);
02020
02021 if (FirstSelected)
02022 break;
02023
02024 ParentDoc = (Document *) GetApplication()->Documents.GetNext(ParentDoc);
02025 }
02026
02027 KernelBitmap *SelectedBitmap = NULL;
02028 if (FirstSelected != NULL)
02029 {
02030 SelectedBitmap = FirstSelected->GetDisplayedKernelBitmap();
02031 }
02032
02033
02034 switch(Action)
02035 {
02036 case SGACTION_APPLY:
02037 if (SelectedBitmap != NULL)
02038 {
02039
02040 NodeAttribute *Attrib = new AttrBitmapColourFill;
02041 if (Attrib == NULL)
02042 return(FALSE);
02043
02044 ((AttrBitmapColourFill *)Attrib)->AttachBitmap(SelectedBitmap);
02045
02046
02047 AttributeManager::AttributeSelected(NULL, Attrib);
02048 }
02049 break;
02050
02051 case SGACTION_DELETE:
02052 return DeleteSelection();
02053 break;
02054
02055 case SGACTION_SETOPTIONS:
02056 if (CurrentOptionsDlg == NULL)
02057 return(FALSE);
02058
02059 CurrentOptionsDlg->AddDisplayModeName(_R(IDS_GALLERYDM_FULLINFO));
02060 break;
02061
02062 case SGACTION_DISPLAYMODECHANGED:
02063 if (DisplayMode < 0 || DisplayMode > 1)
02064 DisplayMode = 0;
02065 break;
02066
02067 default:
02068 return(FALSE);
02069 }
02070
02071 return(TRUE);
02072 }
02073
02074
02075
02076
02077
02078
02079
02080
02081
02082
02083
02084 BOOL BitmapSGallery::DeleteSelection()
02085 {
02086 INT32 ButtonPressed = 2;
02087
02088 ButtonPressed = AskQuestion(_R(IDS_BMPGAL_BMPINUSE),
02089 _R(IDS_BMPGAL_KILL), _R(IDS_CANCEL), 0, 0,
02090 2, 2);
02091
02092 if (ButtonPressed == 2)
02093 return(FALSE);
02094
02095 if (ButtonPressed == 1)
02096 {
02097 BOOL DeletedBitmaps = FALSE;
02098 IgnoreBmpListChange = TRUE;
02099
02100 GlobalBitmapList* pGlobalBmpList = GetApplication()->GetGlobalBitmapList();
02101
02102 Document *ParentDoc = (Document *) GetApplication()->Documents.GetHead();
02103 while (ParentDoc != NULL)
02104 {
02105
02106 BitmapList* pDocBitmaps = ParentDoc->GetBitmapList();
02107
02108 SGDisplayKernelBitmap* Selected = NULL;
02109
02110 SGDisplayGroup *DocGroup = DisplayTree->FindSubtree(this, ParentDoc, NULL);
02111 if (DocGroup != NULL)
02112 Selected = (SGDisplayKernelBitmap *) DocGroup->FindNextSelectedItem(NULL);
02113
02114 while (Selected != NULL)
02115 {
02116 KernelBitmap* SelectedBitmap = Selected->GetDisplayedKernelBitmap();
02117
02118
02119 Selected = (SGDisplayKernelBitmap*)DocGroup->FindNextSelectedItem(Selected);
02120
02121
02122 if (!pDocBitmaps->IsEmpty() &&
02123 pDocBitmaps->FindPosition(SelectedBitmap) != NOT_IN_LIST)
02124 {
02125 if (SelectedBitmap->ActualBitmap != OILBitmap::Default)
02126 {
02127
02128 if (!pGlobalBmpList->IsEmpty() &&
02129 pGlobalBmpList->FindPosition(SelectedBitmap->ActualBitmap) != NOT_IN_LIST)
02130 {
02131 OpDeleteBitmap* pOp = new OpDeleteBitmap();
02132 if (pOp)
02133 {
02134 pOp->DoDelete(SelectedBitmap->ActualBitmap);
02135 DeletedBitmaps = TRUE;
02136 }
02137 }
02138 }
02139 else
02140 {
02141
02142 Error::SetError(0, _T("You cannot delete the Default Bitmap"),0);
02143 InformError();
02144 }
02145 }
02146 }
02147
02148 ParentDoc = (Document *) GetApplication()->Documents.GetNext(ParentDoc);
02149 }
02150
02151 IgnoreBmpListChange = FALSE;
02152
02153 if (DeletedBitmaps)
02154 {
02155 Document *ParentDoc = (Document *) GetApplication()->Documents.GetHead();
02156 while (ParentDoc != NULL)
02157 {
02158 SGDisplayNode *Ptr = DisplayTree->FindSubtree(this, ParentDoc, NULL);
02159 CreateNewSubtree(ParentDoc, (SGDisplayGroup *) Ptr);
02160
02161 ParentDoc = (Document *) GetApplication()->Documents.GetNext(ParentDoc);
02162 }
02163
02164
02165 ForceRedrawOfList();
02166 SelectionHasChanged();
02167 }
02168 }
02169
02170 return TRUE;
02171 }
02172
02173
02174
02175
02176
02177
02178
02179
02180
02181
02182
02183
02184 KernelBitmap* BitmapSGallery::CheckTextureBitmap(KernelBitmap* pBitmap)
02185 {
02186 return NodeBitmap::CheckGreyscaleBitmap(pBitmap, _R(IDS_BMPGAL_MAKEGREY),
02187 _R(IDS_BMPGAL_DOGREY));
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
02217
02218
02219
02220
02221
02222
02223
02224
02225
02226
02227
02228
02229
02230
02231
02232
02233
02234
02235
02236
02237
02238
02239
02240
02241
02242
02243
02244
02245
02246
02247
02248
02249
02250
02251
02252
02253
02254
02255
02256
02257
02258
02259
02260
02261
02262
02263
02264
02265
02266
02267
02268 }
02269
02270
02271
02272
02273
02274
02275
02276
02277
02278
02279
02280
02281
02282
02283
02284
02285
02286
02287
02288
02289
02290
02291
02292
02293
02294
02295
02296
02297
02298
02299 void BitmapSGallery::SelectionHasChanged(void)
02300 {
02301 if (DisplayTree == NULL || AmShaded || !IsVisible())
02302 return;
02303
02304 INT32 Count = DisplayTree->GetSelectedItemCount();
02305
02306 EnableGadget(_R(IDC_BMPGAL_CREATE), (Count == 1));
02307
02308 EnableGadget(_R(IDC_BMPGAL_FILL), (Count == 1));
02309
02310 EnableGadget(_R(IDC_BMPGAL_TEXTURE), (Count == 1));
02311
02312 EnableGadget(_R(IDC_BMPGAL_XPE_EDIT), (Count == 1));
02313 EnableGadget(_R(IDC_BMPGAL_TRACE), (Count == 1));
02314
02315
02316 #ifdef PHOTOSHOPPLUGINS
02317
02318 EnableGadget(_R(IDC_BMPGAL_PLUGINS), (Count == 1));
02319 #endif
02320
02321 EnableGadget(_R(IDC_BMPGAL_BACKGROUND), (Count == 1));
02322
02323
02324 EnableGadget(_R(IDC_BMPGAL_SAVE), (Count > 0));
02325
02326 EnableGadget(_R(IDC_BMPGAL_PROPS),(Count > 0));
02327
02328
02329
02330 EnableGadget(_R(IDC_BMPGAL_PREVIEW), (Count > 0));
02331
02332
02333 if (Count == 1 && GetSelectedBitmap()->ActualBitmap == OILBitmap::Default)
02334 {
02335 EnableGadget(_R(IDC_GALLERY_DELETE), FALSE);
02336 }
02337 else
02338 {
02339 EnableGadget(_R(IDC_GALLERY_DELETE), (Count > 0));
02340 }
02341
02342 EnableGadget(_R(IDC_GALLERY_MENU), TRUE);
02343 }
02344
02345
02346
02347
02348
02349
02350
02351
02352
02353
02354
02355
02356
02357
02358
02359
02360
02361
02362
02363
02364 void BitmapSGallery::DoShadeGallery(BOOL ShadeIt)
02365 {
02366
02367 EnableGadget(_R(IDC_BMPGAL_SAVE), !ShadeIt);
02368
02369 EnableGadget(_R(IDC_BMPGAL_PROPS), !ShadeIt);
02370
02371 EnableGadget(_R(IDC_BMPGAL_BACKGROUND), !ShadeIt);
02372 #ifdef PHOTOSHOPPLUGINS
02373
02374 EnableGadget(_R(IDC_BMPGAL_PLUGINS), !ShadeIt);
02375 #endif
02376
02377 EnableGadget(_R(IDC_BMPGAL_PREVIEW), !ShadeIt);
02378
02379 EnableGadget(_R(IDC_BMPGAL_CREATE), !ShadeIt);
02380
02381 EnableGadget(_R(IDC_BMPGAL_FILL), !ShadeIt);
02382 EnableGadget(_R(IDC_BMPGAL_TEXTURE), !ShadeIt);
02383 EnableGadget(_R(IDC_BMPGAL_TRACE), !ShadeIt);
02384 EnableGadget(_R(IDC_BMPGAL_XPE_EDIT), !ShadeIt);
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
02410
02411
02412
02413 MsgResult BitmapSGallery::Message(Msg* Message)
02414 {
02415 if (IS_OUR_DIALOG_MSG(Message))
02416 {
02417 DialogMsg* Msg = (DialogMsg*)Message;
02418 KernelBitmap* SelectedBitmap;
02419
02420 switch (Msg->DlgMsg)
02421 {
02422 case DIM_CREATE:
02423 SGInit::UpdateGalleryButton(_R(OPTOKEN_DISPLAYBITMAPGALLERY), TRUE);
02424 SetSelectionFromDocument(TRUE);
02425 break;
02426
02427 case DIM_CANCEL:
02428 SGInit::UpdateGalleryButton(_R(OPTOKEN_DISPLAYBITMAPGALLERY), FALSE);
02429 break;
02430
02431 case DIM_LFT_BN_CLICKED:
02432 if (FALSE) {}
02433 else if (Msg->GadgetID == _R(IDC_BMPGAL_CREATE))
02434 {
02435 SelectedBitmap = GetSelectedBitmap();
02436
02437 if (SelectedBitmap != NULL)
02438 {
02439 PageDropInfo DropInfo;
02440 DropInfo.pDocView = DocView::GetSelected();
02441 DropInfo.pDoc = Document::GetSelected();
02442 DropInfo.pSpread = Document::GetSelectedSpread();
02443
02444 FindCentreInsertionPosition(&DropInfo.pSpread, &DropInfo.DropPos);
02445
02446
02447 OpDescriptor* OpDesc = OpDescriptor::FindOpDescriptor(CC_RUNTIME_CLASS(OpCreateNodeBitmap));
02448
02449
02450 OpParam param((void *)SelectedBitmap,(void *)&DropInfo);
02451 OpDesc->Invoke(¶m);
02452 }
02453 }
02454 else if (Msg->GadgetID == _R(IDC_BMPGAL_FILL))
02455 {
02456 SelectedBitmap = GetSelectedBitmap();
02457
02458 if (SelectedBitmap != NULL)
02459 {
02460
02461 NodeAttribute *Attrib = new AttrBitmapColourFill;
02462 if (Attrib == NULL)
02463 return(SuperGallery::Message(Message));
02464
02465 ((AttrBitmapColourFill *)Attrib)->AttachBitmap(SelectedBitmap);
02466
02467
02468 AttributeManager::AttributeSelected(NULL, Attrib);
02469 }
02470 }
02471 else if (Msg->GadgetID == _R(IDC_BMPGAL_TEXTURE))
02472 {
02473 SelectedBitmap = GetSelectedBitmap();
02474
02475 if (SelectedBitmap != NULL)
02476 {
02477 SelectedBitmap = CheckTextureBitmap(SelectedBitmap);
02478
02479 AttributeManager::HaveAskedAboutContoneColours = FALSE;
02480 AttributeManager::UserCancelledContoneColours = FALSE;
02481
02482 if (SelectedBitmap == NULL)
02483 return(SuperGallery::Message(Message));
02484
02485
02486 NodeAttribute *Attrib = new AttrBitmapTranspFill;
02487 if (Attrib == NULL)
02488 return(SuperGallery::Message(Message));
02489
02490 ((AttrBitmapTranspFill *)Attrib)->AttachBitmap(SelectedBitmap);
02491
02492
02493 AttributeManager::AttributeSelected(NULL, Attrib);
02494 }
02495 }
02496 PORTNOTE("other", "Remove XPE hooks")
02497 #ifndef EXCLUDE_FROM_XARALX
02498 else if (Msg->GadgetID == _R(IDC_BMPGAL_XPE_EDIT))
02499 {
02500 SelectedBitmap = GetSelectedBitmap();
02501 if (SelectedBitmap != NULL)
02502 {
02503
02504 OpDescriptor* OpDesc = OpDescriptor::FindOpDescriptor(CC_RUNTIME_CLASS(XPEEditItemOp));
02505
02506
02507 OpParam param((void *)SelectedBitmap, NULL);
02508 OpDesc->Invoke(¶m);
02509 }
02510 }
02511 #endif
02512 else if (Msg->GadgetID == _R(IDC_BMPGAL_TRACE))
02513 {
02514 SelectedBitmap = GetSelectedBitmap();
02515
02516 #ifndef WEBSTER
02517 if (SelectedBitmap != NULL)
02518 {
02519 TraceMsg::OpenOrUse(SelectedBitmap);
02520 }
02521 #endif //webster
02522 }
02523
02524
02525
02526
02527
02528
02529
02530
02531
02532
02533
02534
02535 else if (Msg->GadgetID == _R(IDC_BMPGAL_SAVE))
02536 {
02537
02538 UINT32 ListSize = 0;
02539 KernelBitmap** pList = NULL;
02540 if (!GetSelectedBitmaps(&pList, &ListSize))
02541 InformError();
02542 else
02543 {
02544 if (ListSize != 0)
02545 {
02546 BmpDlgParam BmpDlgParam;
02547
02548 GetBmpInfo(&BmpDlgParam);
02549
02550 BmpDlgParam.SetBitmapList(pList);
02551 BmpDlgParam.SetListSize(ListSize);
02552
02553 BitmapExportParam ExportList(ListSize, pList, &BmpDlgParam);
02554
02555 OpDescriptor* OpDesc = OpDescriptor::FindOpDescriptor(CC_RUNTIME_CLASS(OpMenuExport));
02556 OpDesc->Invoke(&ExportList);
02557 SetBmpInfo(&BmpDlgParam);
02558 ForceRedrawOfList();
02559 }
02560 else
02561 ERROR3("No bitmaps were selected - how come the option wasn't greyed");
02562 }
02563 if (pList != NULL)
02564 CCFree(pList);
02565 }
02566 else if (Msg->GadgetID == _R(IDC_BMPGAL_HELP))
02567 {
02568
02569 HelpUserTopic(_R(IDS_HELPPATH_Gallery_Bitmap));
02570 break;
02571 }
02572 else if (Msg->GadgetID == _R(IDC_BMPGAL_PREVIEW))
02573 {
02574
02575 UINT32 ListSize = 0;
02576 KernelBitmap** pList = NULL;
02577 if (!GetSelectedBitmaps(&pList, &ListSize))
02578 InformError();
02579 else
02580 {
02581 if (ListSize != 0)
02582 {
02583 BmpDlgParam BmpDlgParam;
02584 GetBmpInfo(&BmpDlgParam);
02585
02586 BmpDlgParam.SetBitmapList(pList);
02587 BmpDlgParam.SetListSize(ListSize);
02588 BitmapExportParam ExportList(ListSize, pList, &BmpDlgParam);
02589
02590
02591
02592 PreviewDialog* pPreviewDialog = PreviewDialog::GetPreviewDialog();
02593 if (!pPreviewDialog)
02594 {
02595 OpDescriptor* OpDesc;
02596
02597
02598
02599 OpDesc = OpDescriptor::FindOpDescriptor(OPTOKEN_PREVIEWDIALOG);
02600
02601 if (OpDesc)
02602 {
02603 PreviewDialog::ToggleViaBitmapGallery (TRUE);
02604 OpDesc->Invoke(&ExportList);
02605 pPreviewDialog->SetDelay (100);
02606 pPreviewDialog = PreviewDialog::GetPreviewDialog();
02607
02608 }
02609 }
02610 else
02611 {
02612
02613
02614 if(pPreviewDialog->GetPlayAnimation())
02615 pPreviewDialog->SetPlayAnimation(FALSE);
02616
02617 PreviewDialog::ToggleViaBitmapGallery (TRUE);
02618
02619 pPreviewDialog->SetBitmapList(&ExportList);
02620
02621 pPreviewDialog->SetDelay (100);
02622
02623
02624 pPreviewDialog->ReInitDialog();
02625 }
02626
02627 SetBmpInfo(&BmpDlgParam);
02628 ForceRedrawOfList();
02629 }
02630 else
02631 ERROR3("No bitmaps were selected - how come the option wasn't greyed");
02632 }
02633 if (pList != NULL)
02634 CCFree(pList);
02635 }
02636 #ifdef PHOTOSHOPPLUGINS
02637
02638 else if (Msg->GadgetID == _R(IDC_BMPGAL_PLUGINS))
02639 {
02640
02641
02642 SelectedBitmap = GetSelectedBitmap();
02643
02644 SGDisplayNode * FirstSelected = DisplayTree->FindNextSelectedItem(NULL);
02645 Document *pDocument = NULL;
02646 if (FirstSelected == NULL)
02647 pDocument = Document::GetSelected();
02648 else
02649 pDocument = ((SGDisplayGroup *) FirstSelected->GetParent())->GetParentDocument();
02650 ERROR3IF(pDocument == NULL, "No parent document?!");
02651 if (SelectedBitmap != NULL && pDocument != NULL)
02652 {
02653
02654
02655
02656
02657 OpDescriptor *pOpDesc = OpDescriptor::FindOpDescriptor(OPTOKEN_BFX_SPECIALEFFECTS);
02658 if(pOpDesc)
02659 {
02660
02661 BfxPlugInOp::SetBitmapAndDocument(SelectedBitmap, pDocument);
02662
02663 pOpDesc->Invoke();
02664 }
02665 else
02666 {
02667 ERROR2RAW("Unable to find BFX:Special Effects operation");
02668 }
02669 }
02670 }
02671 #endif
02672 else if (Msg->GadgetID == _R(IDC_BMPGAL_BACKGROUND))
02673 {
02674
02675
02676 SelectedBitmap = GetSelectedBitmap();
02677
02678 SGDisplayNode * FirstSelected = DisplayTree->FindNextSelectedItem(NULL);
02679 Document *pDocument = NULL;
02680 if (FirstSelected == NULL)
02681 pDocument = Document::GetSelected();
02682 else
02683 pDocument = ((SGDisplayGroup *) FirstSelected->GetParent())->GetParentDocument();
02684 ERROR3IF(pDocument == NULL, "No parent document?!");
02685 if (SelectedBitmap != NULL && pDocument != NULL)
02686 {
02687
02688 OpBackgroundParam Param;
02689 Param.pBitmap = SelectedBitmap;
02690 Param.pDoc = pDocument;
02691
02692
02693 OpDescriptor* pOpDesc = OpDescriptor::FindOpDescriptor(OPTOKEN_BACKGROUND);
02694
02695
02696 pOpDesc->Invoke(&Param);
02697 }
02698 }
02699 else if (Msg->GadgetID == _R(IDC_BMPGAL_PROPS))
02700 {
02701
02702 UINT32 ListSize = 0;
02703 KernelBitmap** pList = NULL;
02704 if (!GetSelectedBitmaps(&pList, &ListSize))
02705 InformError();
02706 else
02707 {
02708 if (ListSize != 0)
02709 {
02710
02711 BmpDlgParam BmpDlgParam;
02712 GetBmpInfo(&BmpDlgParam);
02713 BmpDlg::InvokeBmpDlg(&BmpDlgParam);
02714 SetBmpInfo(&BmpDlgParam);
02715 ForceRedrawOfList();
02716 }
02717 else
02718 ERROR3("No bitmaps were selected - how come the option wasn't greyed");
02719 }
02720 if (pList != NULL)
02721 CCFree(pList);
02722 }
02723 break;
02724 default:
02725 break;
02726 }
02727
02728 return(SuperGallery::Message(Message));
02729 }
02730
02731
02732
02733 if (DisplayTree == NULL || !IsVisible())
02734 return(SuperGallery::Message(Message));
02735
02736 if (IsVisible() && MESSAGE_IS_A(Message, DocChangingMsg))
02737 {
02738 DocChangingMsg *TheMsg = (DocChangingMsg *) Message;
02739
02740 switch ( TheMsg->State )
02741 {
02742 case DocChangingMsg::BORN:
02743 {
02744 INT32 Extent = GetDisplayExtent();
02745
02746 CreateNewSubtree(TheMsg->pChangingDoc);
02747 ShadeGallery(FALSE);
02748
02749 InvalidateCachedFormat();
02750 RedrawEverythingBelow(-Extent);
02751 }
02752 break;
02753 default:
02754 break;
02755 }
02756 }
02757
02758 if (MESSAGE_IS_A(Message, BitmapListChangedMsg) && !IgnoreBmpListChange)
02759 {
02760 BitmapListChangedMsg *TheMsg = (BitmapListChangedMsg *) Message;
02761
02762
02763 Document *ScopeDoc = (Document *)TheMsg->pChangedBmpList->GetParentDocument();
02764
02765
02766 ERROR3IF(ScopeDoc == NULL, "A Document bitmap list is invalid");
02767
02768
02769 if (ScopeDoc != NULL)
02770 {
02771 SGDisplayNode *Ptr = DisplayTree->FindSubtree(this, ScopeDoc, NULL);
02772
02773 if (Ptr != NULL)
02774 {
02775 CreateNewSubtree(ScopeDoc, (SGDisplayGroup *) Ptr);
02776
02777
02778 ForceRedrawOfList();
02779
02780
02781
02782 if ((TheMsg->State == BitmapListChangedMsg::SELECTNEWBITMAP) &&
02783 (TheMsg->pNewBitmap != NULL))
02784 {
02785
02786
02787 SelectItems(FALSE);
02788
02789 SGDisplayGroup *DocGroup = DisplayTree->FindSubtree(this, ScopeDoc, NULL);
02790 SGDisplayKernelBitmap* pCurrentItem = NULL;
02791 if (DocGroup != NULL)
02792 pCurrentItem = (SGDisplayKernelBitmap *) DocGroup->GetChild();
02793
02794
02795
02796 ReformatNow(TRUE);
02797 BOOL HaveSelected = FALSE;
02798 DocRect ScrollToRect;
02799
02800 while (pCurrentItem != NULL)
02801 {
02802 KernelBitmap* CurrentBitmap = pCurrentItem->GetDisplayedKernelBitmap();
02803 if (CurrentBitmap == TheMsg->pNewBitmap)
02804 {
02805 pCurrentItem->SetSelected(TRUE);
02806 HaveSelected = TRUE;
02807 pCurrentItem->GetFormatRect(&ScrollToRect);
02808 break;
02809 }
02810
02811
02812 pCurrentItem = (SGDisplayKernelBitmap *) pCurrentItem->GetNext();
02813 }
02814
02815
02816
02817 if (HaveSelected)
02818 {
02819 BOOL ScrollToBottom = TRUE;
02820 ScrollToShow(&ScrollToRect, ScrollToBottom);
02821 }
02822 }
02823
02824
02825
02826 SelectionHasChanged();
02827 }
02828 }
02829 }
02830
02831 if (MESSAGE_IS_A(Message, CommonAttrsChangedMsg))
02832 {
02833 if (!AmShaded)
02834 SetSelectionFromDocument();
02835 }
02836
02837 return(SuperGallery::Message(Message));
02838 }
02839
02840
02841
02842
02843
02844
02845
02846
02847
02848
02849
02850
02851
02852
02853
02854
02855
02856
02857
02858
02859 void BitmapSGallery::HandleDragStart(DragMessage *DragMsg)
02860 {
02861
02862
02863 if (DragMsg->pInfo->IsKindOf(CC_RUNTIME_CLASS(GalleryBitmapDragInfo)))
02864 new SGBitmapDragTarget(this, GetListGadgetID());
02865 else
02866 SuperGallery::HandleDragStart(DragMsg);
02867 }
02868
02869
02870
02871
02872
02873
02874
02875
02876
02877
02878
02879
02880
02881
02882
02883
02884
02885
02886
02887
02888 BOOL BitmapSGallery::FindCentreInsertionPosition(Spread** Spread, DocCoord* Position)
02889 {
02890
02891
02892
02893
02894
02895 DocView* CurDocView = DocView::GetCurrent();
02896
02897 ENSURE(CurDocView != NULL, "The current DocView is NULL");
02898 if (CurDocView == NULL)
02899 {
02900 return FALSE;
02901 }
02902
02903
02904 WorkRect WrkViewRect = CurDocView->GetViewRect();
02905
02906 if (WrkViewRect.IsEmpty() || (!WrkViewRect.IsValid()) )
02907 {
02908 return FALSE;
02909 }
02910
02911
02912 WorkCoord WrkCentreOfView;
02913 WrkCentreOfView.x = WrkViewRect.lo.x + (WrkViewRect.Width()/2);
02914 WrkCentreOfView.y = WrkViewRect.lo.y + (WrkViewRect.Height()/2);
02915
02916
02917 OilCoord OilCentreOfView = WrkCentreOfView.ToOil(CurDocView->GetScrollOffsets());
02918
02919
02920 (*Spread) = CurDocView->FindEnclosingSpread(OilCentreOfView);
02921 if ((*Spread) == NULL)
02922 {
02923
02924 return FALSE;
02925 }
02926
02927
02928
02929
02930 DocRect DocViewRect = CurDocView->GetDocViewRect(*Spread);
02931
02932 if ( DocViewRect.IsEmpty() || (!DocViewRect.IsValid()) )
02933 {
02934 return FALSE;
02935 }
02936
02937 ENSURE( ( (!DocViewRect.IsEmpty()) && DocViewRect.IsValid()),
02938 "DocViewRect is invalid" );
02939
02940
02941 DocCoord DocCentreOfView;
02942 DocCentreOfView.x = DocViewRect.lo.x + (DocViewRect.Width()/2);
02943 DocCentreOfView.y = DocViewRect.lo.y + (DocViewRect.Height()/2);
02944
02945
02946 (*Spread)->DocCoordToSpreadCoord(&DocCentreOfView);
02947
02948
02949 *Position = DocCentreOfView;
02950
02951 return TRUE;
02952 }
02953
02954
02955
02956
02957
02958
02959
02960
02961
02962
02963
02964
02965
02966
02967
02968
02969
02970
02971
02972
02973 RenderRegion *BitmapSGallery::CreateRenderRegion(DocRect *VirtualSize, ReDrawInfoType *DlgRedrawInfo)
02974 {
02975 return(CreateOSRenderRegion(VirtualSize, DlgRedrawInfo));
02976 }
02977
02978
02979
02980
02981
02982
02983
02984
02985
02986
02987
02988
02989
02990
02991
02992
02993
02994
02995
02996
02997 void BitmapSGallery::DestroyRenderRegion(RenderRegion *pRender)
02998 {
02999 DestroyOSRenderRegion(pRender);
03000 }
03001
03002
03003
03004
03005
03006
03007
03008
03009
03010
03011
03012
03013
03014
03015
03016
03017 BOOL BitmapSGallery::PreContextMenu(void)
03018 {
03019 #ifdef PHOTOSHOPPLUGINS
03020
03021
03022
03023
03024
03025
03026 PlugInManager* pManager = GetApplication()->GetPlugInManager();
03027 if (pManager)
03028 pManager->CheckHaveDetailsOnPlugIns();
03029 #endif // PHOTOSHOPPLUGINS
03030
03031 return(TRUE);
03032 }
03033
03034
03035
03036
03037
03038
03039
03040
03041
03042
03043
03044
03045
03046
03047
03048
03049
03050 BOOL BitmapSGallery::InitMenuCommands(void)
03051 {
03052 static BOOL MenusInitialised = FALSE;
03053
03054 BOOL ok = TRUE;
03055
03056 if (!MenusInitialised)
03057 {
03058
03059
03060
03061 ok = ok && InitMenuCommand((StringBase *) &SGCmd_Find, _R(IDS_SGMENU_FIND));
03062 ok = ok && InitMenuCommand((StringBase *) &SGCmd_Sort, _R(IDS_SGMENU_SORT));
03063 ok = ok && InitMenuCommand((StringBase *) &SGCmd_Properties, _R(IDS_SGMENU_PROPERTIES));
03064
03065
03066 ok = ok && InitMenuCommand((StringBase *) &SGCmd_Insert, _R(IDS_SGMENU_INSERT));
03067 ok = ok && InitMenuCommand((StringBase *) &SGCmd_Fill, _R(IDS_SGMENU_FILL));
03068 ok = ok && InitMenuCommand((StringBase *) &SGCmd_Transp, _R(IDS_SGMENU_TRANSP));
03069 ok = ok && InitMenuCommand((StringBase *) &SGCmd_XPE_Edit, _R(IDS_SGMENU_XPE_EDIT));
03070 ok = ok && InitMenuCommand((StringBase *) &SGCmd_Delete, _R(IDS_SGMENU_DELETE));
03071 ok = ok && InitMenuCommand((StringBase *) &SGCmd_Save, _R(IDS_SGMENU_SAVE));
03072
03073 ok = ok && InitMenuCommand((StringBase *) &SGCmd_Preview, _R(IDS_SGMENU_PREVIEW));
03074
03075
03076 #ifndef WEBSTER
03077 ok = ok && InitMenuCommand((StringBase *) &SGCmd_Trace, _R(IDS_SGMENU_TRACE));
03078 ok = ok && InitMenuCommand((StringBase *) &SGCmd_Effects, _R(IDS_SGMENU_EFFECTS));
03079 #endif //webster
03080 #ifdef PHOTOSHOPPLUGINS
03081
03082 ok = ok && InitMenuCommand((StringBase *) &SGCmd_PlugIns, _R(IDS_SGMENU_PLUGINS));
03083 #endif
03084 ok = ok && InitMenuCommand((StringBase *) &SGCmd_SetBackground, _R(IDS_SGMENU_SETBACKGROUND));
03085
03086
03087 ok = ok && InitMenuCommand((StringBase *) &SGCmd_Props, _R(IDS_SGMENU_PROPS));
03088
03089
03090 ok = ok && InitMenuCommand((StringBase *) &SGCmd_FoldGroup, _R(IDS_SGMENU_FOLD));
03091 ok = ok && InitMenuCommand((StringBase *) &SGCmd_UnfoldGroup, _R(IDS_SGMENU_UNFOLD));
03092
03093 ok = ok && InitMenuCommand((StringBase *) &SGCmd_NextGroup, _R(IDS_SGMENU_NEXTGROUP));
03094 ok = ok && InitMenuCommand((StringBase *) &SGCmd_PrevGroup, _R(IDS_SGMENU_PREVGROUP));
03095
03096 MenusInitialised = TRUE;
03097 }
03098
03099 return(ok);
03100 }
03101
03102
03103
03104
03105
03106
03107
03108
03109
03110
03111
03112
03113
03114
03115
03116
03117
03118
03119
03120
03121
03122 BOOL BitmapSGallery::BuildCommandMenu(GalleryContextMenu *TheMenu, SGMenuID MenuID)
03123 {
03124 BOOL ok = TRUE;
03125
03126 if (MenuID == SGMENU_OPTIONS)
03127 {
03128
03129 ok = ok && AddCommand(TheMenu, (StringBase *) &SGCmd_Find);
03130
03131
03132 }
03133 else
03134 {
03135
03136 ok = ok && AddCommand(TheMenu, (StringBase *) &SGCmd_Insert);
03137 ok = ok && AddCommand(TheMenu, (StringBase *) &SGCmd_Fill);
03138 ok = ok && AddCommand(TheMenu, (StringBase *) &SGCmd_Transp,TRUE);
03139
03140 ok = ok && AddCommand(TheMenu, (StringBase *) &SGCmd_Delete);
03141 ok = ok && AddCommand(TheMenu, (StringBase *) &SGCmd_Save);
03142
03143 ok = ok && AddCommand(TheMenu, (StringBase *) &SGCmd_Preview);
03144
03145
03146 #ifndef WEBSTER
03147 ok = ok && AddCommand(TheMenu, (StringBase *) &SGCmd_XPE_Edit);
03148 ok = ok && AddCommand(TheMenu, (StringBase *) &SGCmd_Trace);
03149
03150 #endif //webster
03151
03152 #ifdef PHOTOSHOPPLUGINS
03153
03154
03155
03156 KernelBitmap * pSelectedBitmap = GetSelectedBitmap();
03157
03158 SGDisplayNode * FirstSelected = DisplayTree->FindNextSelectedItem(NULL);
03159 Document *pDocument = NULL;
03160 if (FirstSelected == NULL)
03161 pDocument = Document::GetSelected();
03162 else
03163 pDocument = ((SGDisplayGroup *) FirstSelected->GetParent())->GetParentDocument();
03164 ERROR3IF(pDocument == NULL, "No parent document?!");
03165
03166
03167
03168
03169 ok = ok && PlugInsContextMenu::BuildMenu(pSelectedBitmap, pDocument, TheMenu, NULL, TRUE);
03170
03171 #endif
03172
03173 ok = ok && AddCommand(TheMenu, (StringBase *) &SGCmd_Props,TRUE);
03174
03175
03176 ok = ok && AddCommand(TheMenu, (StringBase *) &SGCmd_SetBackground, TRUE);
03177
03178
03179 SGDisplayGroup *TheGroup = FindCommandGroup();
03180 if (TheGroup == NULL || !TheGroup->Flags.Folded)
03181 ok = ok && AddCommand(TheMenu, (StringBase *) &SGCmd_FoldGroup);
03182 else
03183 ok = ok && AddCommand(TheMenu, (StringBase *) &SGCmd_UnfoldGroup);
03184
03185 ok = ok && AddCommand(TheMenu, (StringBase *) &SGCmd_PrevGroup);
03186 ok = ok && AddCommand(TheMenu, (StringBase *) &SGCmd_NextGroup);
03187 }
03188
03189 return(ok);
03190 }
03191
03192
03193
03194
03195
03196
03197
03198
03199
03200
03201
03202
03203
03204
03205
03206
03207
03208
03209
03210
03211
03212
03213
03214
03215
03216
03217
03218
03219
03220 OpState BitmapSGallery::GetCommandState(StringBase *CommandID, String_256 *ShadeReason)
03221 {
03222 OpState State;
03223
03224 if (*CommandID == SGCmd_Properties || *CommandID == SGCmd_Sort)
03225 {
03226 State.Greyed = TRUE;
03227 ShadeReason->MakeMsg(_R(IDS_SGSHADE_NOTSUPPORTED));
03228 }
03229 else if (*CommandID == SGCmd_Delete)
03230 {
03231 INT32 Count = GetSelectedItemCount();
03232 if (Count == 0)
03233 {
03234 State.Greyed = TRUE;
03235 ShadeReason->MakeMsg(_R(IDS_SGSHADE_NOSEL));
03236 }
03237 else if (Count == 1 && GetSelectedBitmap()->ActualBitmap == OILBitmap::Default)
03238 {
03239 State.Greyed = TRUE;
03240 ShadeReason->MakeMsg(_R(IDS_SGSHADE_NODELBITMAP));
03241 }
03242 }
03243 else if (*CommandID == SGCmd_Insert || *CommandID == SGCmd_Fill
03244
03245 #ifndef WEBSTER
03246 || *CommandID == SGCmd_Transp
03247 || *CommandID == SGCmd_Trace || *CommandID == SGCmd_XPE_Edit || *CommandID == SGCmd_Effects
03248 || *CommandID == SGCmd_SetBackground
03249 #endif
03250 #ifdef PHOTOSHOPPLUGINS
03251
03252 || *CommandID == SGCmd_PlugIns
03253 #endif
03254 )
03255 {
03256 if (GetSelectedItemCount() != 1)
03257 {
03258 State.Greyed = TRUE;
03259 ShadeReason->MakeMsg(_R(IDS_SGSHADE_SINGLE));
03260 }
03261 }
03262 else if (*CommandID == SGCmd_Save)
03263 {
03264 if (GetSelectedItemCount() == 0)
03265 {
03266 State.Greyed = TRUE;
03267 ShadeReason->MakeMsg(_R(IDS_SGSHADE_NOSEL));
03268 }
03269 }
03270 else if (*CommandID == SGCmd_Preview)
03271 {
03272 if (GetSelectedItemCount() == 0)
03273 {
03274 State.Greyed = TRUE;
03275 ShadeReason->MakeMsg(_R(IDS_SGSHADE_NOSEL));
03276 }
03277 }
03278 else if (*CommandID == SGCmd_Props)
03279 {
03280 if (GetSelectedItemCount() == 0)
03281 {
03282 State.Greyed = TRUE;
03283 ShadeReason->MakeMsg(_R(IDS_SGSHADE_NOSEL));
03284 }
03285 }
03286 else
03287 return(SuperGallery::GetCommandState(CommandID, ShadeReason));
03288
03289 return(State);
03290 }
03291
03292
03293
03294
03295
03296
03297
03298
03299
03300
03301
03302
03303
03304
03305
03306
03307
03308
03309
03310
03311
03312
03313
03314
03315
03316 void BitmapSGallery::DoCommand(StringBase *CommandID)
03317 {
03318 if (*CommandID == SGCmd_Insert)
03319 {
03320
03321 DialogMsg Bob(WindowID, DIM_LFT_BN_CLICKED, _R(IDC_BMPGAL_CREATE));
03322 Message(&Bob);
03323 }
03324
03325 else if (*CommandID == SGCmd_Fill)
03326 {
03327
03328 DialogMsg Bob(WindowID, DIM_LFT_BN_CLICKED, _R(IDC_BMPGAL_FILL));
03329 Message(&Bob);
03330 }
03331
03332 #ifndef WEBSTER
03333 else if (*CommandID == SGCmd_Transp)
03334 {
03335
03336 DialogMsg Bob(WindowID, DIM_LFT_BN_CLICKED, _R(IDC_BMPGAL_TEXTURE));
03337 Message(&Bob);
03338 }
03339 #endif //webster
03340 else if (*CommandID == SGCmd_Save)
03341 {
03342
03343 DialogMsg Bob(WindowID, DIM_LFT_BN_CLICKED, _R(IDC_BMPGAL_SAVE));
03344 Message(&Bob);
03345 }
03346 else if (*CommandID == SGCmd_Preview)
03347 {
03348
03349 DialogMsg Bob(WindowID, DIM_LFT_BN_CLICKED, _R(IDC_BMPGAL_PREVIEW));
03350 Message(&Bob);
03351 }
03352 else if (*CommandID == SGCmd_XPE_Edit)
03353 {
03354
03355 DialogMsg Bob(WindowID, DIM_LFT_BN_CLICKED, _R(IDC_BMPGAL_XPE_EDIT));
03356 Message(&Bob);
03357 }
03358
03359 #ifndef WEBSTER
03360 else if (*CommandID == SGCmd_Trace)
03361 {
03362
03363 DialogMsg Bob(WindowID, DIM_LFT_BN_CLICKED, _R(IDC_BMPGAL_TRACE));
03364 Message(&Bob);
03365 }
03366
03367
03368
03369
03370
03371
03372 #endif //webster
03373 #ifdef PHOTOSHOPPLUGINS
03374
03375 else if (*CommandID == SGCmd_PlugIns)
03376 {
03377
03378 DialogMsg Bob(WindowID, DIM_LFT_BN_CLICKED, _R(IDC_BMPGAL_PLUGINS));
03379 Message(&Bob);
03380 }
03381 #endif
03382 else if (*CommandID == SGCmd_SetBackground)
03383 {
03384
03385 DialogMsg Bob(WindowID, DIM_LFT_BN_CLICKED, _R(IDC_BMPGAL_BACKGROUND));
03386 Message(&Bob);
03387 }
03388
03389
03390 else if (*CommandID == SGCmd_Props)
03391 {
03392
03393 DialogMsg Bob(WindowID, DIM_LFT_BN_CLICKED, _R(IDC_BMPGAL_PROPS));
03394 Message(&Bob);
03395 }
03396 else
03397 SuperGallery::DoCommand(CommandID);
03398 }
03399
03400
03401
03402
03403
03404
03405
03406
03407
03408
03409
03410
03411
03412
03413
03414
03415
03416
03417
03418
03419
03420
03421
03422
03423
03424
03425
03426
03427
03428 BOOL OpDisplayBitmapGallery::Init()
03429 {
03430 return (
03431 RegisterOpDescriptor(
03432 0,
03433 _R(IDS_DISPLAY_BITMAP_GALLERY),
03434 CC_RUNTIME_CLASS(OpDisplayBitmapGallery),
03435 OPTOKEN_DISPLAYBITMAPGALLERY,
03436 OpDisplayBitmapGallery::GetState,
03437 0,
03438 _R(IDBBL_DISPLAY_BITMAP_GALLERY),
03439 _R(IDC_BTN_SGBITMAP),
03440 _R(IDC_BTN_SGBITMAP),
03441 SYSTEMBAR_ILLEGAL,
03442 TRUE,
03443 FALSE,
03444 TRUE,
03445 NULL,
03446 0,
03447 0,
03448 TRUE
03449 )
03450
03451 PORTNOTE("other", "Removed BitmapExportPreviewDialog")
03452 #ifndef EXCLUDE_FROM_XARALX
03453
03454 && BitmapExportPreviewDialog::Init()
03455
03456 #endif
03457 && PreviewDialog::Init()
03458 );
03459 }
03460
03461
03462
03463
03464
03465
03466
03467
03468
03469
03470
03471
03472
03473
03474
03475
03476 OpState OpDisplayBitmapGallery::GetState(String_256* UIDescription, OpDescriptor*)
03477 {
03478 OpState OpSt;
03479
03480
03481 SuperGallery* pSuperGallery = SuperGallery::FindSuperGallery(_R(IDD_BITMAPSGALLERY));
03482
03483 if (pSuperGallery != NULL)
03484 {
03485 if (pSuperGallery->GetRuntimeClass() == CC_RUNTIME_CLASS(BitmapSGallery))
03486 OpSt.Ticked = pSuperGallery->IsVisible();
03487 }
03488
03489
03490 OpSt.Greyed = (Document::GetSelected() == NULL);
03491
03492 return(OpSt);
03493 }
03494
03495
03496
03497
03498
03499
03500
03501
03502
03503
03504
03505
03506
03507
03508
03509
03510 void OpDisplayBitmapGallery::Do(OpDescriptor*)
03511 {
03512 SuperGallery* pSuperGallery = SuperGallery::FindSuperGallery(_R(IDD_BITMAPSGALLERY));
03513
03514 if (!pSuperGallery)
03515 pSuperGallery = new BitmapSGallery();
03516
03517 if (pSuperGallery != NULL)
03518 {
03519 if (pSuperGallery->GetRuntimeClass() == CC_RUNTIME_CLASS(BitmapSGallery))
03520 {
03521
03522 pSuperGallery->SetVisibility( !pSuperGallery->IsVisible() );
03523
03524
03525 SGInit::UpdateGalleryButton(_R(OPTOKEN_DISPLAYBITMAPGALLERY),
03526 pSuperGallery->IsVisible());
03527 }
03528 #if _DEBUG
03529 else
03530 ERROR3("The Bitmap Gallery isn't a BitmapSGallery! Woss goin' on?");
03531 #endif
03532 }
03533
03534 ERROR3IF(pSuperGallery == NULL,"Couldn't find the bitmap gallery bar");
03535
03536 End();
03537 }
03538
03539
03540
03541
03542
03543
03544
03545
03546
03547
03548
03549
03550
03551
03552
03553
03554
03555 BOOL BitmapSGallery::GetSelectedBitmaps(KernelBitmap*** pOutputArray, UINT32* pOutputCount)
03556 {
03557
03558 ERROR2IF(pOutputArray==NULL || pOutputCount==NULL, FALSE, "NULL output param");
03559 KernelBitmap** pBuildingArray = NULL;
03560
03561
03562
03563 Document* ParentDoc = (Document*) GetApplication()->Documents.GetHead();
03564 BOOL ok = TRUE;
03565 while (ParentDoc!=NULL && ok)
03566 {
03567 SGDisplayGroup *DocGroup = DisplayTree->FindSubtree(this, ParentDoc, NULL);
03568 if (DocGroup != NULL)
03569 {
03570
03571 SGDisplayKernelBitmap* pCurrent = (SGDisplayKernelBitmap*)DocGroup->FindNextSelectedItem(NULL);
03572 while (pCurrent!=NULL && ok)
03573 {
03574 if (pBuildingArray==NULL)
03575 {
03576
03577 pBuildingArray = (KernelBitmap**) CCMalloc(sizeof(KernelBitmap*));
03578 if (pBuildingArray == NULL)
03579 ok = FALSE;
03580 else
03581 pBuildingArray[0] = pCurrent->GetDisplayedKernelBitmap();
03582 *pOutputCount = 1;
03583 }
03584 else
03585 {
03586
03587 KernelBitmap** pTemp = (KernelBitmap**) CCRealloc(pBuildingArray, ((*pOutputCount)+1)*sizeof(KernelBitmap*));
03588 if (pTemp == NULL)
03589 ok = FALSE;
03590 else
03591 {
03592 pBuildingArray = pTemp;
03593 pBuildingArray[*pOutputCount] = pCurrent->GetDisplayedKernelBitmap();
03594 }
03595 (*pOutputCount)++;
03596 }
03597
03598 pCurrent = (SGDisplayKernelBitmap*)DocGroup->FindNextSelectedItem(pCurrent);
03599 }
03600 }
03601
03602 ParentDoc = (Document *) GetApplication()->Documents.GetNext(ParentDoc);
03603 }
03604
03605 if (!ok)
03606 {
03607 CCFree(pBuildingArray);
03608 *pOutputArray = NULL;
03609 *pOutputCount = 0;
03610 }
03611 else
03612 *pOutputArray = pBuildingArray;
03613
03614 return ok;
03615 }
03616
03617
03618
03619
03620
03621
03622
03623
03624
03625
03626
03627
03628
03629
03630
03631
03632
03633
03634 BOOL BitmapSGallery::GetBmpInfo(BmpDlgParam* Param)
03635 {
03636 ERROR2IF(Param == NULL,FALSE,"Param is NULL");
03637
03638 UINT32 ListSize = 0;
03639 KernelBitmap** pList = NULL;
03640
03641
03642 if (!GetSelectedBitmaps(&pList, &ListSize))
03643 return FALSE;
03644
03645
03646 Param->SetBitmapList(pList);
03647 Param->SetListSize(ListSize);
03648
03649 if (ListSize>1)
03650 {
03651 Param->SetMany(TRUE);
03652 }
03653
03654 String_256* BitmapCols = new String_256[ListSize];
03655 String_256* Width = new String_256[ListSize];
03656 String_256* Height = new String_256[ListSize];
03657 String_256* BitmapFormat = new String_256[ListSize];
03658 UINT32* Delay = new UINT32[ListSize];
03659 BOOL* Interpolation = new BOOL[ListSize];
03660 GIFDisposalMethod* DisposalMethod = new GIFDisposalMethod[ListSize];
03661 UINT32* TranspType = new UINT32[ListSize];
03662
03663 if ( !BitmapCols || !Width || !Height ||
03664 !BitmapFormat || !Delay || !DisposalMethod || !TranspType )
03665 return FALSE;
03666
03667 UINT32 i=0;
03668 UINT32 TempListSize=ListSize;
03669 INT32 Bytes =0;
03670
03671 while (ListSize>0)
03672 {
03673 ListSize--;
03674
03675 KernelBitmap* pKernelBitmap = pList[ListSize];
03676 if (pKernelBitmap == NULL)
03677 return FALSE;
03678
03679 OILBitmap* pOILBitmap = pKernelBitmap->GetActualBitmap();
03680 if (pOILBitmap == NULL)
03681 return FALSE;
03682
03683 PORTNOTE("other", "Removed XPE hooks")
03684 #ifndef EXCLUDE_FROM_XARALX
03685 IXMLDOMDocumentPtr pEditsList = NULL;
03686 KernelBitmap* pMaster = NULL;
03687 pKernelBitmap->GetXPEInfo(pMaster, pEditsList);
03688 BOOL bIsXPE = (pMaster!=NULL && pEditsList!=NULL);
03689 #else
03690 BOOL bIsXPE = FALSE;
03691 #endif
03692
03693
03694 Param->SetBitmapName(pOILBitmap->GetName());
03695
03696
03697 IsJPEG(pList,ListSize,Param,&Bytes);
03698
03699
03700 if(Param->GetIsJPEG())
03701 {
03702 Param->SetBitmapFormat(_R(IDS_FORMAT_JPEG));
03703 }
03704 else if (bIsXPE)
03705 {
03706 Param->SetBitmapFormat(_R(IDS_FORMAT_XPE));
03707 }
03708 else
03709 {
03710 Param->SetBitmapFormat(_R(IDS_FORMAT_BITMAP));
03711 }
03712
03713
03714 Param->SetAnimDelay(pKernelBitmap->GetDelay());
03715
03716
03717 Param->SetInterpolation(pKernelBitmap->GetInterpolation());
03718
03719
03720 INT32 bpp = pKernelBitmap->GetBPP();
03721 Param->SetBitmapTranspType(_R(IDS_BITMAPTRANSPTYPE_NONE));
03722 UINT32 ttype = TT_NoTranspType;
03723
03724 if (bpp <= 8)
03725 {
03726
03727 INT32 Index=0;
03728
03729 if(pKernelBitmap->GetTransparencyIndex(&Index))
03730 {
03731 Param->SetBitmapTranspType(_R(IDS_BITMAPTRANSPTYPE_MASKED));
03732 ttype = TT_Mix;
03733 }
03734 }
03735 else if (bpp<32)
03736 {
03737 Param->SetBitmapTranspType(_R(IDS_BITMAPTRANSPTYPE_NONE));
03738 }
03739 else
03740 {
03741 Param->SetBitmapTranspType(_R(IDS_BITMAPTRANSPTYPE_ALPHA));
03742 ttype = TT_StainGlass;
03743 }
03744
03745 switch (bpp)
03746 {
03747 case 1:
03748 Param->SetBitmapCols(_R(IDS_SGBITMAP_MONOCHROME));
03749 break;
03750
03751 case 2:
03752 Param->SetBitmapCols(_R(IDS_SGBITMAP_4COLOURS));
03753 break;
03754
03755 case 4:
03756 Param->SetBitmapCols(_R(IDS_SGBITMAP_16COLOURS));
03757 break;
03758
03759 case 8:
03760 Param->SetBitmapCols(_R(IDS_SGBITMAP_256COLOURS));
03761 break;
03762
03763 case 16:
03764 Param->SetBitmapCols(_R(IDS_SGBITMAP_65COLOURS));
03765 break;
03766
03767 case 24:
03768 Param->SetBitmapCols(_R(IDS_SGBITMAP_MILLIONS_COLOURS));
03769 break;
03770
03771 case 32:
03772 Param->SetBitmapCols(_R(IDS_SGBITMAP_32_BIT));
03773 break;
03774
03775 default:
03776 Param->SetBitmapCols ("");
03777 break;
03778 }
03779
03780
03781 BitmapInfo Info;
03782
03783 if(pOILBitmap->GetInfo(&Info))
03784 {
03785
03786 Convert::LongToString(Info.PixelWidth, &Param->GetBitmapWidth());
03787 Convert::LongToString(Info.PixelHeight, &Param->GetBitmapHeight());
03788
03789
03790 if(!Param->GetIsJPEG() && !bIsXPE)
03791 {
03792
03793 Bytes += (Info.PixelWidth * Info.PixelHeight * bpp)/8;
03794 }
03795 }
03796
03797
03798 Param->SetRestoreType(pOILBitmap->GetAnimationRestoreType());
03799
03800
03801 BitmapCols[i] = Param->GetBitmapCols();
03802 Width[i] = Param->GetBitmapWidth();
03803 Height[i] = Param->GetBitmapHeight();
03804 BitmapFormat[i] = Param->GetBitmapFormat();
03805 Delay[i] = Param->GetAnimDelay();
03806 Interpolation[i]= Param->GetInterpolation();
03807 DisposalMethod[i] = Param->GetRestoreType();
03808 TranspType[i] = ttype;
03809 i++;
03810 }
03811
03812
03813 Convert::BytesToString(&Param->GetMemoryUsed(),(INT32)Bytes);
03814
03815
03816
03817
03818
03819 if (TempListSize>1)
03820 {
03821 for(i=0; i<TempListSize; i++)
03822 {
03823 for(UINT32 e=i+1; e<TempListSize; e++)
03824 {
03825 if (BitmapCols[i] != BitmapCols[e])
03826 Param->SetSameColors(FALSE);
03827
03828 if (Width[i] != Width[e])
03829 Param->SetSameDimensions(FALSE);
03830
03831 if (Height[i] != Height[e])
03832 Param->SetSameDimensions(FALSE);
03833
03834 if (BitmapFormat[i] != BitmapFormat[e])
03835 Param->SetSameFormat(FALSE);
03836
03837 if (DisposalMethod[i] != DisposalMethod[e])
03838 Param->SetSameRestoreType(FALSE);
03839
03840 if (Delay[i] != Delay[e])
03841 Param->SetAreDelayValuesSame(FALSE);
03842
03843 if (Interpolation[i] != Interpolation[e])
03844 Param->SetAreInterpolationValuesSame(FALSE);
03845
03846 if (TranspType[i] != TranspType[e])
03847 Param->SetSameTranspType(FALSE);
03848 }
03849 }
03850 }
03851
03852 if (pList != NULL)
03853 CCFree(pList);
03854 delete [] BitmapCols;
03855 delete [] Width;
03856 delete [] Height;
03857 delete [] DisposalMethod;
03858 delete [] BitmapFormat;
03859 delete [] Delay;
03860 delete [] Interpolation;
03861 delete [] TranspType;
03862
03863 return TRUE;
03864 }
03865
03866
03867
03868
03869
03870
03871
03872
03873
03874
03875
03876
03877
03878
03879
03880 BOOL BitmapSGallery::SetBmpInfo(BmpDlgParam* Param)
03881 {
03882 ERROR2IF(Param == NULL,FALSE,"Param is NULL");
03883
03884
03885 UINT32 ListSize = 0;
03886 KernelBitmap** pList = NULL;
03887 Document* WorkDoc = Document::GetSelected();
03888
03889
03890 if (!GetSelectedBitmaps(&pList, &ListSize))
03891 return FALSE;
03892
03893 if(Param->GetAreDelayValuesSame())
03894 {
03895 UINT32 ListCounter = ListSize;
03896
03897 while (ListCounter>0)
03898 {
03899 KernelBitmap* pKernelBitmap = pList[--ListCounter];
03900 if (pKernelBitmap != NULL)
03901 {
03902 pKernelBitmap->SetDelay(Param->GetAnimDelay());
03903 }
03904 }
03905 }
03906 if (Param->GetSameRestoreType())
03907 {
03908 UINT32 ListCounter = ListSize;
03909
03910 while (ListCounter>0)
03911 {
03912 KernelBitmap* pKernelBitmap = pList[--ListCounter];
03913 if(pKernelBitmap != NULL)
03914 {
03915 OILBitmap* pOILBitmap = pKernelBitmap->GetActualBitmap();
03916 if (pOILBitmap != NULL)
03917 {
03918 pOILBitmap->SetAnimationRestoreType(Param->GetRestoreType());
03919 }
03920 }
03921 }
03922 }
03923
03924
03925 if (Param->GetAreInterpolationValuesSame())
03926 {
03927 UINT32 ListCounter = ListSize;
03928
03929 while (ListCounter>0)
03930 {
03931 KernelBitmap* pKernelBitmap = pList[--ListCounter];
03932 if(pKernelBitmap != NULL)
03933 {
03934 OILBitmap* pOILBitmap = pKernelBitmap->GetActualBitmap();
03935 if (pOILBitmap != NULL)
03936 {
03937
03938 pOILBitmap->SetInterpolation(Param->GetInterpolation());
03939
03940
03941 if (WorkDoc != NULL)
03942 {
03943 pOILBitmap->InvalidateAllReferences(WorkDoc);
03944 }
03945 }
03946 }
03947 }
03948 }
03949 if (pList != NULL)
03950 CCFree(pList);
03951
03952 return TRUE;
03953 }
03954
03955
03956
03957
03958
03959
03960
03961
03962
03963
03964
03965
03966
03967
03968
03969
03970
03971
03972
03973 BOOL BitmapSGallery::IsJPEG(KernelBitmap** pList,UINT32 ListSize, BmpDlgParam* Param, INT32* pBytes)
03974 {
03975 ERROR2IF(pList == NULL || Param == NULL || pBytes == NULL, FALSE, "NULL Parameters Passed");
03976
03977 BitmapSource* pSource = NULL;
03978 BaseBitmapFilter* pDummyFilter;
03979
03980 KernelBitmap* pKernelBitmap = pList[ListSize];
03981
03982 if (pKernelBitmap == NULL)
03983 return FALSE;
03984
03985 BOOL OriginalSourcePresent = pKernelBitmap->GetOriginalSource(&pSource, &pDummyFilter);
03986
03987 if(OriginalSourcePresent)
03988 {
03989 if (pSource != NULL)
03990 {
03991 if (pSource->IsJPEG())
03992 {
03993 Param->SetIsJPEG(TRUE);
03994 *pBytes += pSource->GetSize();
03995 }
03996 }
03997 }
03998 else
03999 {
04000 Param->SetIsJPEG(FALSE);
04001 }
04002 return Param->GetIsJPEG();
04003 }
04004
04005
04006
04007
04008
04009
04010
04011
04012
04013
04014
04015
04016
04017
04018
04019
04020
04021
04022
04023
04024
04025
04026
04027
04028
04029
04030
04031
04032
04033
04034
04035
04036
04037
04038
04039
04040
04041
04042
04043
04044
04045
04046
04047
04048
04049
04050
04051
04052
04053
04054
04055
04056
04057
04058
04059
04060
04061
04062
04063
04064
04065
04066
04067
04068
04069
04070
04071
04072
04073
04074
04075
04076
04077
04078
04079
04080
04081
04082
04083
04084
04085
04086
04087
04088
04089
04090
04091