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 #include "camtypes.h"
00103 #include "sgdfonts.h"
00104 #include "sgfonts.h"
00105 #include "sgfonts.h"
00106
00107 #ifndef EXCLUDE_GALS
00108
00109
00110
00111
00112
00113 #include "grnddib.h"
00114
00115 #include "bitmpinf.h"
00116 #include "nodebmp.h"
00117
00118
00119
00120 #include "wbitmap.h"
00121
00122
00123 #include "sgscanf.h"
00124 #include "sglib.h"
00125
00126 #include "fontpgen.h"
00127
00128
00129 #include "sgliboil.h"
00130 #include "dlgmgr.h"
00131 #include "camelot.h"
00132 #include "keypress.h"
00133
00134
00135
00136
00137
00138
00139 #include "nodetext.h"
00140
00141 #include "dragmgr.h"
00142 #include "scrcamvw.h"
00143
00144
00145
00146
00147
00148 #include "grndbmp.h"
00149
00150
00151 #include "sglbase.h"
00152
00153
00154
00155
00156
00157 CC_IMPLEMENT_DYNCREATE(GalleryFontsDragInfo, BitmapDragInformation)
00158 CC_IMPLEMENT_DYNCREATE(GalleryLibFontsDragInfo, BitmapDragInformation)
00159 CC_IMPLEMENT_DYNAMIC(SGFontsDragTarget, SGListDragTarget)
00160
00161
00162 #define new CAM_DEBUG_NEW
00163
00164
00165
00166
00167
00168
00169
00170
00171
00172
00173
00174
00175
00176
00177
00178 SGFontsDragTarget::SGFontsDragTarget(DialogOp *TheDialog, CGadgetID TheGadget)
00179 : SGListDragTarget(TheDialog, TheGadget)
00180 {
00181 ERROR3IF(!TheDialog->IsKindOf(CC_RUNTIME_CLASS(FontsSGallery)),
00182 "You can only use SGFontsDragTargets with LibFontsSGallery dialogues!");
00183 }
00184
00185
00186
00187
00188
00189
00190
00191
00192
00193
00194
00195
00196
00197
00198
00199
00200
00201
00202
00203
00204
00205
00206
00207
00208 BOOL SGFontsDragTarget::ProcessEvent(DragEventType Event, DragInformation *pDragInfo,
00209 OilCoord *pMousePos, KeyPress* pKeyPress)
00210 {
00211 SGDisplayNode *DraggedNode = NULL;
00212 BOOL IsSimpleBitmapDrag = TRUE;
00213
00214 if (IS_A(pDragInfo, GalleryFontsDragInfo))
00215 {
00216
00217 DraggedNode = ((GalleryFontsDragInfo *)pDragInfo)->GetDraggedFont();
00218 TRACEUSER( "Richard", _T("We're Dragging an installed font\n"));
00219 IsSimpleBitmapDrag = FALSE;
00220 }
00221 else if (IS_A(pDragInfo, GalleryLibFontsDragInfo))
00222 {
00223
00224 DraggedNode = ((GalleryLibFontsDragInfo *)pDragInfo)->GetDraggedFont();
00225 TRACEUSER( "Richard", _T("We're Dragging a library font\n"));
00226 IsSimpleBitmapDrag = FALSE;
00227 }
00228 else
00229 return(FALSE);
00230
00231 if (DraggedNode != NULL)
00232 {
00233 switch(Event)
00234 {
00235 case DRAGEVENT_COMPLETED:
00236 HandleDragCompleted((SuperGallery *) TargetDialog,
00237 DraggedNode, pMousePos, IsSimpleBitmapDrag);
00238 return(TRUE);
00239
00240
00241 case DRAGEVENT_MOUSESTOPPED:
00242 case DRAGEVENT_MOUSEMOVED:
00243 case DRAGEVENT_MOUSEIDLE:
00244 {
00245
00246
00247 SuperGallery *ParentGallery = (SuperGallery *) TargetDialog;
00248 if (ParentGallery != NULL && pMousePos != NULL && DraggedNode != NULL)
00249 {
00250
00251 DocCoord MousePos(pMousePos->x, pMousePos->y);
00252 SGDisplayNode *DestNode = ParentGallery->FindNodeUnderPointer(&MousePos);
00253
00254 if(DestNode != NULL)
00255 {
00256 SGDisplayNode *DestGroup = DestNode->GetParent();
00257 SGDisplayNode *SourceGroup = DraggedNode->GetParent();
00258
00259 if(DestGroup != NULL && SourceGroup != NULL)
00260 {
00261
00262 if(SourceGroup == DestGroup)
00263 return(DetermineCursorShape(ParentGallery, DraggedNode, pMousePos));
00264
00265
00266 if(SourceGroup->IS_KIND_OF(SGLibGroup) && DestGroup->IS_KIND_OF(SGFontsGroup))
00267 return(DetermineCursorShape(ParentGallery, DraggedNode, pMousePos));
00268 }
00269 }
00270 }
00271 }
00272
00273
00274 CurrentCursorID = _R(IDC_DRAGGING_COLOUR);
00275 return TRUE;
00276 }
00277 }
00278
00279
00280 return(FALSE);
00281 }
00282
00283
00284
00285
00286
00287
00288
00289
00290
00291
00292
00293
00294 GalleryFontsDragInfo::GalleryFontsDragInfo()
00295 {
00296 ERROR3("Default GalleryFontsDragInfo constructor called");
00297 }
00298
00299
00300
00301
00302
00303
00304
00305
00306
00307
00308
00309
00310 GalleryFontsDragInfo::~GalleryFontsDragInfo()
00311 {
00312 if(LibraryGallery::TmpDraggingBitmap != NULL)
00313 {
00314 delete LibraryGallery::TmpDraggingBitmap;
00315 LibraryGallery::TmpDraggingBitmap = NULL;
00316 }
00317 }
00318
00319
00320
00321
00322
00323
00324
00325
00326
00327
00328
00329
00330
00331
00332
00333
00334
00335
00336
00337
00338
00339
00340
00341 GalleryFontsDragInfo::GalleryFontsDragInfo(SGDisplayPreviewFonts *pSourceItem,
00342 SGMouseInfo *pMouseInfo, SGMiscInfo *pMiscInfo,
00343 BOOL IsAdjust, INT32 XSize, INT32 YSize)
00344 : BitmapDragInformation(LibraryGallery::TmpDraggingBitmap, XSize, YSize,
00345 FontsSGallery::GetDragFontOffset(LibraryGallery::TmpDraggingBitmap), 0,
00346 IsAdjust)
00347 {
00348 SourceItem = pSourceItem;
00349
00350 MouseInfo = *pMouseInfo;
00351 MiscInfo = *pMiscInfo;
00352 }
00353
00354
00355
00356
00357
00358
00359
00360
00361
00362
00363
00364
00365
00366
00367
00368
00369
00370
00371
00372
00373 void GalleryFontsDragInfo::OnClick(INT32 Flags ,POINT Point)
00374 {
00375 if (SourceItem != NULL)
00376 SourceItem->DragWasReallyAClick(&MouseInfo, &MiscInfo);
00377 }
00378
00379
00380
00381
00382
00383
00384
00385
00386
00387
00388
00389
00390 UINT32 GalleryFontsDragInfo::GetCursorID(DragTarget* pDragTarget)
00391 {
00392 if (pDragTarget && pDragTarget->IS_KIND_OF(ViewDragTarget))
00393 {
00394 PageDropInfo PageDropInfo;
00395 ((ViewDragTarget*)pDragTarget)->GetDropInfo(&PageDropInfo);
00396
00397 NodeRenderableInk* pObjectHit = PageDropInfo.pObjectHit;
00398 ObjectDragTarget TargetHit = PageDropInfo.TargetHit;
00399
00400
00401 if (pObjectHit && pObjectHit->RequiresAttrib(CC_RUNTIME_CLASS(AttrTxtFontTypeface)))
00402 TargetHit = FILL_TARGET;
00403 else
00404 TargetHit = NO_TARGET;
00405
00406 switch (TargetHit)
00407 {
00408 case FILL_TARGET:
00409 return _R(IDC_CANDROPONFILL);
00410
00411 case NO_TARGET:
00412 return _R(IDC_CANDROPONPAGE);
00413 };
00414
00415 return _R(IDC_CANDROPONPAGE);
00416 }
00417
00418 return _R(IDC_CANTDROP);
00419 }
00420
00421
00422
00423
00424
00425
00426
00427
00428
00429
00430
00431
00432 BOOL GalleryFontsDragInfo::GetStatusLineText(String_256 * TheText, DragTarget* pDragTarget)
00433 {
00434 #ifdef STANDALONE
00435 return FALSE;
00436 #else
00437 ERROR2IF(TheText==NULL,FALSE,"NULL string in GetStatusLineText()");
00438
00439 if (TheBitmap == NULL || TheBitmap->ActualBitmap == NULL)
00440 return FALSE;
00441
00442
00443 String_256 DragString;
00444 String_256 ItemName;
00445 SourceItem->GetNameText(&ItemName);
00446
00447
00448 DragString.MakeMsg(_R(IDS_FONTS_DRAGGING), (TCHAR *)ItemName);
00449
00450
00451 if (pDragTarget && pDragTarget->IS_KIND_OF(ViewDragTarget))
00452 {
00453 DragString += String_8(_R(IDS_SGDFONTS_STAT_COLON_SEP));
00454
00455 PageDropInfo PageDropInfo;
00456 ((ViewDragTarget*)pDragTarget)->GetDropInfo(&PageDropInfo);
00457
00458 NodeRenderableInk* pObjectHit = PageDropInfo.pObjectHit;
00459 ObjectDragTarget TargetHit = PageDropInfo.TargetHit;
00460
00461
00462 if (pObjectHit && pObjectHit->RequiresAttrib(CC_RUNTIME_CLASS(AttrTxtFontTypeface)))
00463 TargetHit = FILL_TARGET;
00464 else
00465 TargetHit = NO_TARGET;
00466
00467 switch (TargetHit)
00468 {
00469 case FILL_TARGET:
00470 if (IS_A(pObjectHit,CaretNode))
00471 {
00472
00473 String_64 DropToCaret(_R(IDS_FONTS_DROP_TO_APPLY_CARET));
00474 DragString += DropToCaret;
00475 }
00476 else
00477 {
00478 if(pObjectHit->IsSelected())
00479 {
00480
00481 String_64 DropToText(_R(IDS_FONTS_DROP_TO_APPLY_SEL));
00482 DragString += DropToText;
00483 }
00484 else
00485 if (KeyPress::IsConstrainPressed())
00486 {
00487
00488 String_64 DropToText(_R(IDS_FONTS_DROP_TO_APPLY_CHAR));
00489 DragString += DropToText;
00490 }
00491 else
00492 {
00493
00494 String_64 DropToText(_R(IDS_FONTS_DROP_TO_APPLY_TEXT));
00495 DragString += DropToText;
00496 }
00497 }
00498 break;
00499
00500 case NO_TARGET:
00501 {
00502
00503 String_64 DropToCurrent(_R(IDS_FONTS_DROP_TO_APPLY_CURRENT));
00504 DragString += DropToCurrent;
00505 }
00506 break;
00507 };
00508
00509 *TheText = DragString;
00510 return TRUE;
00511 }
00512
00513 *TheText = DragString;
00514 return TRUE;
00515 #endif
00516 }
00517
00518
00519
00520
00521
00522
00523
00524
00525
00526
00527
00528
00529
00530
00531
00532
00533 BOOL GalleryFontsDragInfo::OnPageDrop(ViewDragTarget* pDragTarget)
00534 {
00535 #ifdef STANDALONE
00536 return FALSE;
00537 #else
00538 PageDropInfo PageDropInfo;
00539 ((ViewDragTarget*)pDragTarget)->GetDropInfo(&PageDropInfo);
00540 NodeRenderableInk* pObjectHit = PageDropInfo.pObjectHit;
00541 SGDisplayPreviewFonts* SelectedNode = SourceItem;
00542
00543 return(FontsSGallery::ApplyFont(TRUE, (SGDisplayNode *)SourceItem, pObjectHit));
00544 #endif
00545 }
00546
00547
00548
00549
00550
00551
00552
00553
00554
00555
00556
00557
00558
00559
00560 INT32 GalleryFontsDragInfo::GetDragTransparency()
00561 {
00562
00563 if(TheBitmap == NULL)
00564 return 50;
00565
00566
00567 return 0;
00568 }
00569
00570
00571
00572
00573
00574
00575
00576
00577
00578
00579
00580
00581
00582
00583
00584
00585
00586
00587 KernelBitmap* GalleryFontsDragInfo::GetSolidDragMask()
00588 {
00589 if(TheBitmap == NULL)
00590 {
00591 DragMask = NULL;
00592 return NULL;
00593 }
00594
00595 if (DragMask == NULL)
00596 {
00597
00598 Matrix ConvertMatrix;
00599 FIXED16 ViewScale = 1;
00600
00601 CDC* pDisplayDC = new CDC();
00602 if (pDisplayDC == NULL)
00603 return NULL;
00604
00605 pDisplayDC->CreateDC("DISPLAY", NULL, NULL, NULL);
00606
00607 double dpi = (double) GetDeviceCaps( pDisplayDC->m_hDC, LOGPIXELSX );
00608
00609
00610 INT32 PixelSize = (INT32)(72000.0/dpi);
00611 DocRect ClipRegion(0,0, SolidDragSize.cx*PixelSize, SolidDragSize.cy*PixelSize);
00612
00613 GRenderBitmap* pMaskRegion = new GRenderBitmap(ClipRegion, ConvertMatrix, ViewScale,
00614 1, dpi);
00615 if (pMaskRegion == NULL)
00616 {
00617 delete pDisplayDC;
00618 return NULL;
00619 }
00620
00621
00622 DocView *View = DocView::GetCurrent();
00623 if (View == NULL)
00624 {
00625 delete pMaskRegion;
00626 delete pDisplayDC;
00627 return NULL;
00628 }
00629
00630 Spread *pSpread = View->FindEnclosingSpread(OilCoord(0,0));
00631 if (pSpread == NULL)
00632 {
00633 delete pMaskRegion;
00634 delete pDisplayDC;
00635 return NULL;
00636 }
00637
00638 pMaskRegion->AttachDevice(View, pDisplayDC, pSpread);
00639
00640
00641
00642
00643
00644
00645
00646
00647
00648
00649
00650
00651 WinBitmap* WinBM = (WinBitmap*)TheBitmap->ActualBitmap;
00652
00653 RGBQUAD* Palette = WinBM->BMInfo->bmiColors;
00654 RGBQUAD OldPalette[256];
00655
00656
00657 for (INT32 i=0; i<256; i++)
00658 {
00659 OldPalette[i] = Palette[i];
00660 }
00661
00662
00663
00664 for (i=0; i<256; i++)
00665 {
00666 Palette[i].rgbBlue = ((i < 253) ? 0 : 255);
00667 Palette[i].rgbGreen = ((i < 253) ? 0 : 255);
00668 Palette[i].rgbRed = ((i < 253) ? 0 : 255);
00669 }
00670
00671
00672
00673
00674 pMaskRegion->StartRender();
00675 pMaskRegion->DrawBitmap(DocCoord(0,0), TheBitmap);
00676 pMaskRegion->StopRender();
00677
00678
00679
00680 for (i=0; i<256; i++)
00681 {
00682 Palette[i] = OldPalette[i];
00683 }
00684
00685
00686 OILBitmap* pOilMaskBmp = pMaskRegion->ExtractBitmap();
00687 DragMask = new KernelBitmap(pOilMaskBmp, TRUE);
00688
00689
00690 delete pMaskRegion;
00691 delete pDisplayDC;
00692 }
00693
00694 return DragMask;
00695 }
00696
00697
00698
00699
00700
00701
00702
00703
00704
00705
00706
00707
00708
00709
00710
00711
00712
00713 GalleryLibFontsDragInfo::GalleryLibFontsDragInfo()
00714 {
00715 ERROR3("Default GalleryLibFontsDragInfo constructor called");
00716 }
00717
00718
00719
00720
00721
00722
00723
00724
00725
00726
00727
00728
00729 GalleryLibFontsDragInfo::~GalleryLibFontsDragInfo()
00730 {
00731 if(LibraryGallery::TmpDraggingBitmap != NULL)
00732 {
00733 delete LibraryGallery::TmpDraggingBitmap;
00734 LibraryGallery::TmpDraggingBitmap = NULL;
00735 }
00736 }
00737
00738
00739
00740
00741
00742
00743
00744
00745
00746
00747
00748
00749
00750
00751
00752
00753
00754
00755
00756
00757
00758
00759
00760 GalleryLibFontsDragInfo::GalleryLibFontsDragInfo(SGLibFontItem *pSourceItem,
00761 SGMouseInfo *pMouseInfo, SGMiscInfo *pMiscInfo,
00762 BOOL IsAdjust, INT32 XSize, INT32 YSize)
00763 : BitmapDragInformation(LibraryGallery::TmpDraggingBitmap, XSize, YSize,
00764 FontsSGallery::GetDragFontOffset(LibraryGallery::TmpDraggingBitmap), 0,
00765 IsAdjust)
00766 {
00767 SourceItem = pSourceItem;
00768
00769 MouseInfo = *pMouseInfo;
00770 MiscInfo = *pMiscInfo;
00771 }
00772
00773
00774
00775
00776
00777
00778
00779
00780
00781
00782
00783
00784
00785
00786
00787
00788
00789
00790 void GalleryLibFontsDragInfo::OnClick(INT32 Flags ,POINT Point)
00791 {
00792 if (SourceItem != NULL)
00793 SourceItem->DragWasReallyAClick(&MouseInfo, &MiscInfo);
00794 }
00795
00796
00797
00798
00799
00800
00801
00802
00803
00804
00805
00806
00807 UINT32 GalleryLibFontsDragInfo::GetCursorID(DragTarget* pDragTarget)
00808 {
00809 if (pDragTarget && pDragTarget->IS_KIND_OF(ViewDragTarget))
00810 {
00811 PageDropInfo PageDropInfo;
00812 ((ViewDragTarget*)pDragTarget)->GetDropInfo(&PageDropInfo);
00813
00814 NodeRenderableInk* pObjectHit = PageDropInfo.pObjectHit;
00815 ObjectDragTarget TargetHit = PageDropInfo.TargetHit;
00816
00817 String_256 Desc256;
00818 SourceItem->GetNameText(&Desc256);
00819 if (pObjectHit && !FontsSGallery::IsFontAlreadyInstalled(&Desc256, SourceItem->GetType()) && SourceItem->GetParentLibrary() && SourceItem->GetParentLibrary()->IsWebLibrary())
00820 return _R(IDC_CANTDROP);
00821
00822
00823
00824 if (pObjectHit && pObjectHit->RequiresAttrib(CC_RUNTIME_CLASS(AttrTxtFontTypeface)))
00825 TargetHit = FILL_TARGET;
00826 else
00827 TargetHit = NO_TARGET;
00828
00829 switch (TargetHit)
00830 {
00831 case FILL_TARGET:
00832 return _R(IDC_CANDROPONFILL);
00833
00834 case NO_TARGET:
00835 return _R(IDC_CANDROPONPAGE);
00836 };
00837
00838 return _R(IDC_CANDROPONPAGE);
00839 }
00840
00841 return _R(IDC_CANTDROP);
00842 }
00843
00844
00845
00846
00847
00848
00849
00850
00851
00852
00853
00854
00855 BOOL GalleryLibFontsDragInfo::GetStatusLineText(String_256 * TheText, DragTarget* pDragTarget)
00856 {
00857 #ifdef STANDALONE
00858 return FALSE;
00859 #else
00860 ERROR2IF(TheText==NULL,FALSE,"NULL string in GetStatusLineText()");
00861
00862 if (TheBitmap == NULL || TheBitmap->ActualBitmap == NULL)
00863 return FALSE;
00864
00865 String_256 DragString;
00866 String_256 ItemName;
00867 SourceItem->GetNameText(&ItemName);
00868 NodeRenderableInk* pObjectHit = NULL;
00869 PageDropInfo PageDropInfo;
00870 ObjectDragTarget TargetHit;
00871 if (pDragTarget && pDragTarget->IS_KIND_OF(ViewDragTarget))
00872 {
00873 ((ViewDragTarget*)pDragTarget)->GetDropInfo(&PageDropInfo);
00874 pObjectHit = PageDropInfo.pObjectHit;
00875 TargetHit = PageDropInfo.TargetHit;
00876 }
00877 if (pObjectHit && !FontsSGallery::IsFontAlreadyInstalled(&ItemName, SourceItem->GetType()) && SourceItem->GetParentLibrary() && SourceItem->GetParentLibrary()->IsWebLibrary())
00878 DragString = String_256(_R(IDS_MUST_DOWNLOAD));
00879 else
00880 {
00881
00882 DragString.MakeMsg(_R(IDS_FONTS_DRAGGING), (TCHAR *)ItemName);
00883
00884 if (pDragTarget && pDragTarget->IS_KIND_OF(SGFontsDragTarget))
00885 {
00886 DragString += String_8(_R(IDS_SGDFONTS_STAT_COLON_SEP));
00887
00888
00889 String_64 DropToInstall(_R(IDS_FONTS_DROP_TO_INSTALL));
00890 DragString += DropToInstall;
00891
00892 *TheText = DragString;
00893 return TRUE;
00894 }
00895
00896 if (pDragTarget && pDragTarget->IS_KIND_OF(ViewDragTarget))
00897 {
00898 DragString += String_8(_R(IDS_SGDFONTS_STAT_COLON_SEP));
00899
00900
00901 if (pObjectHit && pObjectHit->RequiresAttrib(CC_RUNTIME_CLASS(AttrTxtFontTypeface)))
00902 TargetHit = FILL_TARGET;
00903 else
00904 TargetHit = NO_TARGET;
00905
00906 switch (TargetHit)
00907 {
00908 case FILL_TARGET:
00909
00910 if (IS_A(pObjectHit,CaretNode))
00911 {
00912
00913 String_64 DropToCaret(_R(IDS_FONTS_DROP_TO_APPLY_CARET));
00914 DragString += DropToCaret;
00915 }
00916 else
00917 {
00918 if(pObjectHit->IsSelected())
00919 {
00920
00921 String_64 DropToText(_R(IDS_FONTS_DROP_TO_APPLY_SEL));
00922 DragString += DropToText;
00923 }
00924 else
00925 if (KeyPress::IsConstrainPressed())
00926 {
00927
00928 String_64 DropToText(_R(IDS_FONTS_DROP_TO_APPLY_CHAR));
00929 DragString += DropToText;
00930 }
00931 else
00932 {
00933
00934 String_64 DropToText(_R(IDS_FONTS_DROP_TO_APPLY_TEXT));
00935 DragString += DropToText;
00936 }
00937 }
00938 break;
00939
00940 case NO_TARGET:
00941 {
00942
00943 String_64 DropToCurrent(_R(IDS_FONTS_DROP_TO_APPLY_CURRENT));
00944 DragString += DropToCurrent;
00945 }
00946 break;
00947 };
00948
00949 *TheText = DragString;
00950 return TRUE;
00951 }
00952 }
00953
00954 *TheText = DragString;
00955 return TRUE;
00956 #endif
00957 }
00958
00959
00960
00961
00962
00963
00964
00965
00966
00967
00968
00969
00970
00971
00972
00973
00974
00975 BOOL GalleryLibFontsDragInfo::OnPageDrop(ViewDragTarget* pDragTarget)
00976 {
00977 #ifdef STANDALONE
00978 return FALSE;
00979 #else
00980 PageDropInfo PageDropInfo;
00981 ((ViewDragTarget*)pDragTarget)->GetDropInfo(&PageDropInfo);
00982 NodeRenderableInk* pObjectHit = PageDropInfo.pObjectHit;
00983 SGLibFontItem *FontItem = SourceItem;
00984
00985
00986 return(FontsSGallery::ApplyFont(TRUE, (SGDisplayNode *)FontItem, pObjectHit));
00987 #endif
00988 }
00989
00990
00991
00992
00993
00994
00995
00996
00997
00998
00999
01000
01001
01002
01003 INT32 GalleryLibFontsDragInfo::GetDragTransparency()
01004 {
01005
01006 if(TheBitmap == NULL)
01007 return 50;
01008
01009
01010 return 0;
01011 }
01012
01013
01014
01015
01016
01017
01018
01019
01020
01021
01022
01023
01024
01025
01026
01027
01028
01029
01030 KernelBitmap* GalleryLibFontsDragInfo::GetSolidDragMask()
01031 {
01032 if(TheBitmap == NULL)
01033 {
01034 DragMask = NULL;
01035 return NULL;
01036 }
01037
01038 if (DragMask == NULL)
01039 {
01040
01041 Matrix ConvertMatrix;
01042 FIXED16 ViewScale = 1;
01043
01044 CDC* pDisplayDC = new CDC();
01045 if (pDisplayDC == NULL)
01046 return NULL;
01047
01048 pDisplayDC->CreateDC("DISPLAY", NULL, NULL, NULL);
01049
01050 INT32 dpi = GetDeviceCaps( pDisplayDC->m_hDC, LOGPIXELSX );
01051
01052
01053 INT32 PixelSize = 72000/dpi;
01054 DocRect ClipRegion(0,0, SolidDragSize.cx*PixelSize, SolidDragSize.cy*PixelSize);
01055
01056 GRenderBitmap* pMaskRegion = new GRenderBitmap(ClipRegion, ConvertMatrix, ViewScale,
01057 1, dpi);
01058 if (pMaskRegion == NULL)
01059 {
01060 delete pDisplayDC;
01061 return NULL;
01062 }
01063
01064
01065 DocView *View = DocView::GetCurrent();
01066 if (View == NULL)
01067 {
01068 delete pMaskRegion;
01069 delete pDisplayDC;
01070 return NULL;
01071 }
01072
01073 Spread *pSpread = View->FindEnclosingSpread(OilCoord(0,0));
01074 if (pSpread == NULL)
01075 {
01076 delete pMaskRegion;
01077 delete pDisplayDC;
01078 return NULL;
01079 }
01080
01081 pMaskRegion->AttachDevice(View, pDisplayDC, pSpread);
01082
01083
01084
01085
01086
01087
01088
01089
01090
01091
01092
01093 WinBitmap* WinBM = (WinBitmap*)TheBitmap->ActualBitmap;
01094
01095 RGBQUAD* Palette = WinBM->BMInfo->bmiColors;
01096 RGBQUAD OldPalette[256];
01097
01098
01099 for (INT32 i=0; i<256; i++)
01100 {
01101 OldPalette[i] = Palette[i];
01102 }
01103
01104
01105
01106 for (i=0; i<256; i++)
01107 {
01108 Palette[i].rgbBlue = ((i < 253) ? 0 : 255);
01109 Palette[i].rgbGreen = ((i < 253) ? 0 : 255);
01110 Palette[i].rgbRed = ((i < 253) ? 0 : 255);
01111 }
01112
01113
01114
01115
01116 pMaskRegion->StartRender();
01117 pMaskRegion->DrawBitmap(DocCoord(0,0), TheBitmap);
01118 pMaskRegion->StopRender();
01119
01120
01121
01122 for (i=0; i<256; i++)
01123 {
01124 Palette[i] = OldPalette[i];
01125 }
01126
01127
01128 OILBitmap* pOilMaskBmp = pMaskRegion->ExtractBitmap();
01129 DragMask = new KernelBitmap(pOilMaskBmp, TRUE);
01130
01131
01132 delete pMaskRegion;
01133 delete pDisplayDC;
01134 }
01135
01136 return DragMask;
01137 }
01138 #endif