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
00104 #ifndef EXCLUDE_GALS
00105 #include "sgfonts.h"
00106
00107
00108
00109
00110 #include "ccdc.h"
00111
00112 #include "grnddib.h"
00113
00114 #include "bitmpinf.h"
00115 #include "nodebmp.h"
00116 #include "progress.h"
00117
00118
00119
00120
00121
00122
00123 #include "sgscanf.h"
00124 #include "sglib.h"
00125
00126 #include "thumbmsg.h"
00127 #include "fontpgen.h"
00128 #include "sginit.h"
00129
00130
00131 #include "sgliboil.h"
00132 #include "dlgmgr.h"
00133 #include "camelot.h"
00134 #include "sgindgen.h"
00135 #include "product.h"
00136 #include "fontman.h"
00137 #include "sgmenu.h"
00138 #include "fontbase.h"
00139
00140
00141
00142 #include "textinfo.h"
00143 #include "nodetext.h"
00144 #include "dragmgr.h"
00145 #include "sglbase.h"
00146 #include "sgdfonts.h"
00147 #include "fontlist.h"
00148
00149
00150 #include "keypress.h"
00151
00152
00153
00154
00155
00156 #include "helpuser.h"
00157
00158
00159
00160
00161 #include "ndoptmz.h"
00162
00163 using namespace InetUtils;
00164
00165
00166 CC_IMPLEMENT_DYNCREATE(FontsSGallery, LibraryGallery)
00167 CC_IMPLEMENT_DYNAMIC(SGDisplayPreviewFonts, SGDisplayItem)
00168 CC_IMPLEMENT_DYNAMIC(SGTTFItem, SGDisplayPreviewFonts)
00169 CC_IMPLEMENT_DYNAMIC(SGATMItem, SGDisplayPreviewFonts)
00170 CC_IMPLEMENT_DYNCREATE(OpDisplayFontsGallery, Operation)
00171 CC_IMPLEMENT_DYNAMIC(SGFontsGroup, SGDisplayGroup)
00172 CC_IMPLEMENT_DYNAMIC(SGLibFontItem, SGLibDisplayItem)
00173
00174
00175 #define new CAM_DEBUG_NEW
00176
00177
00178
00179
00180
00181
00182
00183
00184
00185
00186
00187
00188
00189
00190 const INT32 SGF_NORMAL_X = 180;
00191 const INT32 SGF_NORMAL_Y = 26;
00192
00193 const INT32 SGF_FULL_X = 160;
00194 const INT32 SGF_FULL_Y = 12;
00195
00196 const INT32 SGF_SMALL_X = 28;
00197 const INT32 SGF_SMALL_Y = 16;
00198
00199
00200 const INT32 SGF_TYPE_WIDTH = 14;
00201
00202
00203 const INT32 SGF_BPP = 8;
00204
00205
00206
00207 const INT32 SGF_SURROUND = 3;
00208
00209
00210
00211
00212
00213
00214 #ifdef _DEBUG
00215
00216 String_256 FontsSGallery::DefaultLibraryPath = TEXT("\\\\jimpc\\corelxra\\fonts");
00217 #else
00218 String_256 FontsSGallery::DefaultLibraryPath = TEXT("D:\\fonts");
00219 #endif
00220
00221
00222 INT32 SGDisplayPreviewFonts::DMode = 0;
00223
00224
00225 FontsSGallery *FontsSGallery::ThisGallery = NULL;
00226
00227
00228 BOOL FontsSGallery::AddedFonts = FALSE;
00229
00230
00231 BOOL FontsSGallery::DontUpdate = FALSE;
00232
00233
00234 INT32 FontsSGallery::DefaultDisplayMode = 0;
00235
00236
00237
00238
00239
00240
00241
00242
00243 UINT32 FontsSGallery::DefaultSortKeys = 1;
00244
00245
00246 SGFontsGroup *FontsSGallery::InsGroup = NULL;
00247
00248
00249 BOOL FontsSGallery::DeleteTTFandFOTfiles = TRUE;
00250
00251
00252
00253 String_256 FontsSGallery::LargeDisplayString=String_256();
00254
00255
00256 FontClass FontsSGallery::EnumFontClass = FC_UNDEFINED;
00257
00258
00259 BOOL FontsSGallery::QuietStatus = FALSE;
00260
00261
00262 BOOL FontsSGallery::WarnAboutSectionDragging = FALSE;
00263
00264
00265 BOOL FontsSGallery::WarnAboutMultipleATMDragging = FALSE;
00266
00267
00268
00269
00270
00271
00272
00273
00274
00275
00276
00277
00278
00279
00280
00281
00282
00283
00284
00285
00286
00287
00288
00289
00290
00291
00292 SGFontsGroup::SGFontsGroup(SuperGallery *ParentGal,
00293 Document *ParentDoc, Library *ParentLib, String_64 *TText)
00294 : SGDisplayGroup(ParentGal, ParentDoc, ParentLib)
00295 {
00296 if(TText != NULL)
00297 TitleText = *TText;
00298 else
00299 TitleText.MakeMsg(_R(IDS_FONTS_GROUP));
00300
00301 SetVirtualisedState(FALSE);
00302 }
00303
00304
00305
00306
00307
00308
00309
00310
00311
00312
00313
00314
00315
00316
00317 void SGFontsGroup::ReadGroupTitle(void)
00318 {
00319 }
00320
00321
00322
00323
00324
00325
00326
00327
00328
00329
00330
00331
00332
00333
00334
00335
00336
00337
00338
00339
00340
00341
00342
00343
00344
00345
00346
00347
00348
00349
00350
00351
00352
00353
00354
00355 BOOL SGFontsGroup::HandleEvent(SGEventType EventType, void *EventInfo, SGMiscInfo *MiscInfo)
00356 {
00357 switch (EventType)
00358 {
00359 case SGEVENT_THUMBMSG:
00360 {
00361 ThumbMessage *Msg = (ThumbMessage *) EventInfo;
00362 if(Msg != NULL)
00363 {
00364 switch (Msg->State)
00365 {
00366
00367 case ThumbMessage::CACHESIZECHANGED:
00368 {
00369
00370 FontsSGallery *TheGal = (FontsSGallery *)GetParentGallery();
00371
00372 if(TheGal == NULL)
00373 {
00374 ERROR3("SGFontsGroup::HandleEvent Library == NULL for installed fonts group - bad !!!");
00375 }
00376 else
00377 {
00378
00379 SGThumbs *Thumbs = TheGal->InsCache;
00380
00381 if(Thumbs != NULL)
00382 {
00383
00384 SGThumbSize OldSize;
00385 Thumbs->GetSize(&OldSize);
00386
00387
00388 SGThumbs::MaxThumbnails = Msg->NewSize;
00389
00390
00391 delete Thumbs;
00392
00393
00394
00395 Thumbs = new SGThumbs(NULL, SGLib_Font, OldSize);
00396
00397
00398 TheGal->InsCache = Thumbs;
00399 }
00400 }
00401 }
00402
00403 break;
00404
00405 case ThumbMessage::KILLCACHE:
00406 {
00407
00408 FontsSGallery *TheGal = (FontsSGallery *)GetParentGallery();
00409
00410 if(TheGal == NULL)
00411 {
00412 ERROR3("SGFontsGroup::HandleEvent Library == NULL for installed fonts group - bad !!!");
00413 }
00414 else
00415 {
00416
00417 SGThumbs *Thumbs = TheGal->InsCache;
00418
00419 if(Thumbs != NULL)
00420 {
00421 if(Msg->Type == SGLib_Font)
00422 {
00423
00424 Thumbs->DeleteThumbnails();
00425 }
00426 }
00427 }
00428 }
00429 break;
00430
00431 default:
00432 break;
00433 }
00434 }
00435 }
00436 break;
00437 default:
00438 break;
00439 }
00440
00441
00442 return SGDisplayGroup::HandleEvent(EventType, EventInfo, MiscInfo);
00443 }
00444
00445
00446
00447
00448
00449
00450
00451
00452
00453
00454
00455
00456
00457
00458
00459
00460
00461
00462
00463
00464
00465
00466
00467
00468
00469
00470
00471
00472
00473
00474
00475 BOOL SGFontsGroup::GetBubbleHelp(DocCoord *MousePos, String_256 *Result)
00476 {
00477 ERROR3IF(MousePos == NULL || Result == NULL, "Invalid NULL params");
00478
00479 return FALSE;
00480 }
00481
00482
00483
00484
00485
00486
00487
00488
00489
00490
00491
00492
00493
00494
00495
00496
00497
00498
00499
00500
00501
00502
00503
00504
00505
00506
00507
00508
00509
00510
00511 BOOL SGFontsGroup::GetStatusLineHelp(DocCoord *MousePos, String_256 *Result)
00512 {
00513 ERROR3IF(MousePos == NULL || Result == NULL, "Invalid NULL params");
00514
00515 if(MousePos->x <= 16500)
00516 {
00517 if(Flags.Folded)
00518
00519 Result->MakeMsg(_R(IDS_LIBRARY_FOLDER_CLICK_TO_OPEN));
00520 else
00521
00522 Result->MakeMsg(_R(IDS_LIBRARY_FOLDER_CLICK_TO_CLOSE));
00523 }
00524 else
00525 {
00526 if(Flags.Selected)
00527 {
00528
00529 Result->MakeMsg(_R(IDS_LIBRARY_SECTION_CLICK_SELECTED));
00530 *Result += String_8(_R(IDS_SGFONTS_STATUS_LINE_SEP));
00531 }
00532 else if(Flags.CanSelect)
00533 {
00534
00535 Result->MakeMsg(_R(IDS_LIBRARY_SECTION_CLICK_DESELECTED));
00536 *Result += String_8(_R(IDS_SGFONTS_STATUS_LINE_SEP));
00537 }
00538
00539 String_256 DClick;
00540 if(Flags.Folded)
00541
00542 DClick.MakeMsg(_R(IDS_LIBRARY_SECTION_DCLICK_TO_OPEN));
00543 else
00544
00545 DClick.MakeMsg(_R(IDS_LIBRARY_SECTION_DCLICK_TO_CLOSE));
00546
00547 *Result += DClick;
00548 }
00549
00550 return(TRUE);
00551 }
00552
00553
00554
00555
00556
00557
00558
00559
00560
00561
00562
00563
00564
00565
00566
00567 BOOL SGFontsGroup::CanVirtualise(void)
00568 {
00569 return FALSE;
00570 }
00571
00572
00573
00574
00575
00576
00577
00578
00579
00580
00581
00582
00583
00584
00585
00586
00587
00588
00589
00590
00591 SGDisplayPreviewFonts::SGDisplayPreviewFonts()
00592 {
00593 FontBitmap = NULL;
00594 FontDescription = _T("");
00595 CachedLogFont = NULL;
00596 ID = 0;
00597 IntLeading = 0;
00598 Type = FC_UNDEFINED;
00599 Invalid = FALSE;
00600 }
00601
00602
00603
00604
00605
00606
00607
00608
00609
00610
00611
00612
00613
00614
00615
00616 SGDisplayPreviewFonts::~SGDisplayPreviewFonts()
00617 {
00618
00619
00620 FontBitmap = NULL;
00621 FontDescription = _T("");
00622
00623 if(CachedLogFont != NULL)
00624 {
00625 delete CachedLogFont;
00626 CachedLogFont = NULL;
00627 }
00628
00629 ID = 0;
00630 IntLeading = 0;
00631 }
00632
00633
00634
00635
00636
00637
00638
00639
00640
00641
00642
00643
00644
00645
00646
00647
00648
00649
00650
00651
00652
00653
00654 KernelBitmap *SGDisplayPreviewFonts::GetDisplayedKernelBitmap(SGMiscInfo *MiscInfo, BOOL Background)
00655 {
00656
00657 if(Invalid)
00658 return NULL;
00659
00660 LibDisplayType DType = GetDisplayType(MiscInfo);
00661
00662 if(DType == LibDisplay_JustText)
00663 return NULL;
00664
00665 FontsSGallery *FSGallery = FontsSGallery::ThisGallery;
00666 ERROR3IF(FSGallery == NULL, "SGDisplayPreviewFonts::GetDisplayedKernelBitmap, FontsSGallery::ThisGallery is NULL");
00667
00668
00669 FontBitmap = NULL;
00670
00671 if(FSGallery->InsCache != NULL)
00672 {
00673
00674
00675 FSGallery->InsCache->SetSize((SGThumbSize)MiscInfo->DisplayMode);
00676 if(!FSGallery->InsCache->GetThumbnail(ID, Background, &FontBitmap, NULL, (LP_SGTHUMBS_MOREINFO)this))
00677 FontBitmap = NULL;
00678 }
00679
00680 return FontBitmap;
00681 }
00682
00683
00684
00685
00686
00687
00688
00689
00690
00691
00692
00693
00694
00695
00696
00697
00698
00699
00700
00701
00702
00703
00704
00705
00706
00707
00708 void SGDisplayPreviewFonts::CalculateMyRect(SGFormatInfo *FormatInfo, SGMiscInfo *MiscInfo)
00709 {
00710 UINT32 XSize = SG_InfiniteWidth;
00711 UINT32 YSize = SG_DefaultLargeIcon;
00712
00713 DMode = MiscInfo->DisplayMode;
00714
00715
00716 GetThumbnailDetails(DMode, &XSize, &YSize, NULL);
00717
00718 INT32 OnePixel = (INT32) DevicePixels(MiscInfo, 1);
00719
00720
00721 switch(DMode)
00722 {
00723 case 1:
00724
00725
00726 XSize = (XSize * OnePixel) + (SG_DefaultNameText * 2);
00727 break;
00728
00729 case 3:
00730
00731 XSize = (XSize * OnePixel) + (SGF_SURROUND * OnePixel * 2) + (SGF_TYPE_WIDTH * OnePixel);
00732 break;
00733
00734 case 4:
00735
00736 YSize = GridLock(MiscInfo, 18 * OnePixel);
00737 XSize = GridLock(MiscInfo, SG_DefaultNameText);
00738 CalculateFormatRect(FormatInfo, MiscInfo, XSize, YSize);
00739 return;
00740
00741 default:
00742
00743 XSize = (XSize * OnePixel) + (INT32)((float) SG_DefaultNameText * 1.1);
00744 break;
00745 }
00746
00747 YSize = (YSize + (SGF_SURROUND * 2)) * OnePixel;
00748
00749
00750 XSize = GridLock(MiscInfo, XSize);
00751 YSize = GridLock(MiscInfo, YSize);
00752
00753 CalculateFormatRect(FormatInfo, MiscInfo, XSize, YSize);
00754 }
00755
00756
00757
00758
00759
00760
00761
00762
00763
00764
00765
00766
00767
00768
00769
00770
00771
00772
00773
00774 LibDisplayType SGDisplayPreviewFonts::GetDisplayType(SGMiscInfo *MiscInfo)
00775 {
00776 switch(MiscInfo->DisplayMode)
00777 {
00778 case 4:
00779 return LibDisplay_JustText;
00780 break;
00781 case 3:
00782 return LibDisplay_MediumThumb;
00783 break;
00784 case 2:
00785 return LibDisplay_SmallThumbText;
00786 break;
00787 case 1:
00788
00789 return LibDisplay_SingleLineFullInfo;
00790 break;
00791 case 0:
00792 default:
00793 return LibDisplay_LargeThumbText;
00794 break;
00795 }
00796
00797 return LibDisplay_LargeThumbTextUnder;
00798 }
00799
00800
00801
00802
00803
00804
00805
00806
00807
00808
00809
00810
00811
00812
00813
00814
00815
00816
00817
00818
00819
00820
00821
00822
00823 void SGDisplayPreviewFonts::DrawItemText(RenderRegion *Renderer, SGRedrawInfo *RedrawInfo,
00824 SGMiscInfo *MiscInfo, DocRect *Rectangle, DocRect *BmpRect, BOOL Selected)
00825 {
00826 LibDisplayType DType = GetDisplayType(MiscInfo);
00827
00828 switch(DType)
00829 {
00830 case LibDisplay_SmallThumb:
00831 case LibDisplay_MediumThumb:
00832 case LibDisplay_LargeThumb:
00833 return;
00834 default:
00835 break;
00836 }
00837
00838 INT32 OnePixel = (INT32) DevicePixels(MiscInfo, 1);
00839
00840
00841 DocRect TextRect(*Rectangle);
00842 TextRect.lo.x = BmpRect->hi.x + SG_GapBeforeText;
00843
00844 GridLockRect(MiscInfo, &TextRect);
00845
00846 Renderer->SetLineWidth(0);
00847 Renderer->SetLineColour(RedrawInfo->Transparent);
00848
00849
00850 if (Selected)
00851 {
00852 Renderer->SetFillColour(RedrawInfo->SelBackground);
00853
00854 DocRect SelRect(TextRect);
00855
00856
00857 if(TextRect.lo.x > Rectangle->hi.x) return;
00858
00859 SelRect.hi.y = TextRect.lo.y + TextRect.Height()/2 - (OnePixel * 2);
00860 SelRect.lo.y = TextRect.lo.y + TextRect.Height()/2 + (OnePixel * 2);
00861 SelRect.hi.y += SG_DefaultLargeIcon/2;
00862 SelRect.lo.y -= (SG_DefaultLargeIcon/2 + OnePixel);
00863 SelRect.hi.x = TextRect.hi.x;
00864
00865 GridLockRect(MiscInfo, &SelRect);
00866
00867 Renderer->DrawRect(&SelRect);
00868
00869 Renderer->SetFixedSystemTextColours(&RedrawInfo->SelForeground, &RedrawInfo->SelBackground);
00870 }
00871 else
00872 Renderer->SetFixedSystemTextColours(&RedrawInfo->Foreground, &RedrawInfo->Background);
00873
00874 Renderer->SetFillColour(RedrawInfo->Foreground);
00875
00876
00877 if(TextRect.lo.x + (OnePixel * 4) > Rectangle->hi.x)
00878 return;
00879
00880
00881 String_256 DisplayText;
00882
00883 if(DMode == 1)
00884 GetFullInfoText(&DisplayText);
00885 else
00886 GetNameText(&DisplayText);
00887
00888
00889 TextRect.lo.x += (OnePixel * 4);
00890 Renderer->DrawFixedSystemText(&DisplayText, TextRect);
00891 }
00892
00893
00894
00895
00896
00897
00898
00899
00900
00901
00902
00903
00904
00905
00906
00907
00908
00909
00910
00911
00912
00913
00914
00915
00916
00917
00918 BOOL SGDisplayPreviewFonts::DrawThumb(RenderRegion *Renderer, SGRedrawInfo *RedrawInfo,
00919 SGMiscInfo *MiscInfo, DocRect *Rectangle, BOOL Background)
00920 {
00921 LibDisplayType DType = GetDisplayType(MiscInfo);
00922
00923 if(DType == LibDisplay_JustText)
00924 return TRUE;
00925
00926 FontBitmap = GetDisplayedKernelBitmap(MiscInfo, Background);
00927
00928
00929 if(FontBitmap == NULL)
00930 return FALSE;
00931
00932 if(FontBitmap->ActualBitmap == NULL)
00933 return FALSE;
00934
00935 DMode = MiscInfo->DisplayMode;
00936
00937
00938 DocRect BmpRect(*Rectangle);
00939
00940 INT32 OnePixel = (INT32) DevicePixels(MiscInfo, 1);
00941
00942 UINT32 XSize = 0;
00943 UINT32 YSize = 0;
00944
00945 Renderer->SetLineWidth(0);
00946 DocColour trans(COLOUR_TRANS);
00947 Renderer->SetLineColour(trans);
00948
00949 BOOL ThumbnailOK = TRUE;
00950
00951 BitmapInfo Info;
00952
00953 BOOL InfoOK = FontBitmap->ActualBitmap->GetInfo( &Info );
00954
00955 if(InfoOK)
00956 {
00957
00958 XSize = (UINT32)Info.PixelWidth;
00959 YSize = (UINT32)Info.PixelHeight;
00960 ThumbnailOK = TRUE;
00961 }
00962 else
00963 {
00964
00965 GetThumbnailDetails(DMode, &XSize, &YSize, NULL);
00966 ThumbnailOK = FALSE;
00967 }
00968
00969 XSize *= OnePixel;
00970
00971
00972
00973 BmpRect.lo.x += (3 * OnePixel);
00974 BmpRect.hi.x = BmpRect.lo.x + XSize ;
00975 BmpRect.Inflate(0, -(3 * OnePixel));
00976 GridLockRect(MiscInfo, &BmpRect);
00977
00978 NodeBitmap* DummyBmp = NULL;
00979
00980 if(Invalid)
00981 return FALSE;
00982
00983 if(ThumbnailOK)
00984 {
00985
00986 DummyBmp = new NodeBitmap();
00987 if (DummyBmp == NULL)
00988 {
00989 ThumbnailOK = FALSE;
00990 }
00991 else
00992 {
00993
00994 DummyBmp->SetUpPath();
00995 DummyBmp->CreateShape(BmpRect);
00996 DummyBmp->GetBitmapRef()->SetBitmap(FontBitmap);
00997
00998
00999 DummyBmp->Render(Renderer);
01000
01001
01002
01003
01004 delete DummyBmp;
01005 }
01006 }
01007
01008
01009
01010 if(!ThumbnailOK)
01011 {
01012
01013 DocColour NullBitmapColour(230L, 230L, 230L);
01014
01015
01016 Renderer->SetFillColour(NullBitmapColour);
01017
01018 GridLockRect(MiscInfo, &BmpRect);
01019 Renderer->DrawRect(&BmpRect);
01020 }
01021
01022
01023 return TRUE;
01024 }
01025
01026
01027
01028
01029
01030
01031
01032
01033
01034
01035
01036
01037
01038
01039
01040
01041
01042
01043
01044
01045
01046
01047
01048
01049
01050
01051 void SGDisplayPreviewFonts::HandleRedraw(SGRedrawInfo *RedrawInfo, SGMiscInfo *MiscInfo)
01052 {
01053
01054 StartRendering(RedrawInfo, MiscInfo);
01055
01056 RenderRegion *Renderer = RedrawInfo->Renderer;
01057 INT32 OnePixel = (INT32) DevicePixels(MiscInfo, 1);
01058 Renderer->SetLineWidth(0);
01059 Renderer->SetLineColour(RedrawInfo->Transparent);
01060
01061 LibDisplayType DType = GetDisplayType(MiscInfo);
01062
01063
01064 DocRect NewFormatRect(FormatRect);
01065
01066
01067 NewFormatRect.lo.x += (SGF_TYPE_WIDTH * OnePixel);
01068
01069 GridLockRect(MiscInfo, &NewFormatRect);
01070
01071 DocRect TypeRect(FormatRect);
01072 TypeRect.hi.x = NewFormatRect.lo.x;
01073
01074 DrawTypeIcon(RedrawInfo, MiscInfo, &TypeRect, Type);
01075
01076
01077 DocRect BmpRect(NewFormatRect);
01078 DocRect UnscaledRect(NewFormatRect);
01079
01080 if(DType == LibDisplay_JustText)
01081 {
01082
01083 BmpRect.hi.x = BmpRect.lo.x + OnePixel;
01084 }
01085 else
01086 {
01087
01088 UINT32 XSize = 0;
01089 UINT32 YSize = 0;
01090 DMode = MiscInfo->DisplayMode;
01091
01092
01093 GetThumbnailDetails(DMode, &XSize, &YSize, NULL);
01094
01095
01096 XSize *= OnePixel;
01097
01098
01099 BmpRect.hi.x = BmpRect.lo.x + XSize + (6 * OnePixel);
01100
01101
01102 BmpRect.Inflate(-(OnePixel * 3));
01103
01104
01105 GridLockRect(MiscInfo, &BmpRect);
01106
01107
01108 if (Flags.Selected)
01109 {
01110 if(BmpRect.hi.x > UnscaledRect.hi.x) BmpRect.hi.x = UnscaledRect.hi.x;
01111
01112 BmpRect.Inflate(OnePixel * 3);
01113 GridLockRect(MiscInfo, &BmpRect);
01114 DrawSelectionOutline(RedrawInfo, MiscInfo, &BmpRect);
01115
01116 BmpRect.Inflate(-(OnePixel * 3));
01117 }
01118
01119
01120 BOOL DrawnBitmap = FALSE;
01121
01122
01123 if(Library::BackgroundRedraw && DType != LibDisplay_JustText)
01124 {
01125
01126
01127
01128 DrawnBitmap = DrawThumb(Renderer, RedrawInfo, MiscInfo, &UnscaledRect, FALSE);
01129
01130 if (ShouldIDrawForeground(DrawnBitmap))
01131 {
01132 if (!DrawnBitmap)
01133 {
01134
01135
01136 if (!DrawThumb(Renderer, RedrawInfo, MiscInfo, &UnscaledRect, TRUE))
01137 SGLibDisplayItem::DrawNullBitmapRect(Renderer, MiscInfo, &BmpRect, FALSE);
01138 }
01139 }
01140 else
01141 {
01142 if (!DrawnBitmap)
01143 {
01144
01145 SGLibDisplayItem::DrawNullBitmapRect(Renderer, MiscInfo, &BmpRect, TRUE);
01146 }
01147 }
01148 }
01149 else
01150 {
01151
01152 if (!DrawThumb(Renderer, RedrawInfo, MiscInfo, &UnscaledRect, TRUE))
01153 SGLibDisplayItem::DrawNullBitmapRect(Renderer, MiscInfo, &BmpRect, FALSE);
01154 }
01155 }
01156
01157
01158 DrawItemText(Renderer, RedrawInfo, MiscInfo, &UnscaledRect, &BmpRect, Flags.Selected);
01159
01160
01161 StopRendering(RedrawInfo, MiscInfo);
01162
01163 }
01164
01165
01166
01167
01168
01169
01170
01171
01172
01173
01174
01175
01176
01177
01178
01179
01180
01181
01182 void SGDisplayPreviewFonts::DrawTypeIcon(SGRedrawInfo *RedrawInfo, SGMiscInfo *MiscInfo, DocRect *TypeRect, FontClass Type)
01183 {
01184 INT32 BitmapID = 0;
01185 if(Type == FC_ATM)
01186 BitmapID = _R(IDB_ATM_SYMBOL);
01187 else if(Type == FC_TRUETYPE)
01188 BitmapID = _R(IDB_TTF_SYMBOL);
01189 else return;
01190
01191 DocRect GlyphRect(*TypeRect);
01192
01193 INT32 OnePixel = (INT32) MiscInfo->PixelSize;
01194 INT32 Centre = GlyphRect.lo.y + ((GlyphRect.hi.y - GlyphRect.lo.y) / 2);
01195 GlyphRect.lo.y = Centre - ((SGF_TYPE_WIDTH / 2) * OnePixel);
01196 GlyphRect.hi.y = Centre + (((SGF_TYPE_WIDTH / 2) + 1) * OnePixel);
01197
01198
01199 LibDisplayType DType = SGDisplayPreviewFonts::GetDisplayType(MiscInfo);
01200
01201 if(DType == LibDisplay_JustText)
01202 GlyphRect.lo.x += (6 * OnePixel);
01203
01204 RedrawInfo->Renderer->DrawBitmap(GlyphRect.lo, BitmapID);
01205 }
01206
01207
01208
01209
01210
01211
01212
01213
01214
01215
01216
01217
01218
01219
01220
01221
01222
01223
01224
01225 void SGDisplayPreviewFonts::GetNameText(String_256 *Result)
01226 {
01227 ERROR3IF(Result == NULL, "SGDisplayPreviewFonts::GetNameText given null ptr");
01228
01229 *Result = (String_256)FontDescription;
01230 }
01231
01232
01233
01234
01235
01236
01237
01238
01239
01240
01241
01242
01243
01244
01245
01246
01247
01248
01249
01250 void SGDisplayPreviewFonts::GetFullInfoText(String_256 *Result)
01251 {
01252 ERROR3IF(Result == NULL, "SGDisplayPreviewFonts::GetFullInfoText given null ptr");
01253
01254
01255 *Result = (String_256)FontDescription;
01256 }
01257
01258
01259
01260
01261
01262
01263
01264
01265
01266
01267
01268
01269
01270
01271
01272
01273
01274
01275
01276
01277
01278
01279
01280
01281
01282
01283
01284
01285 INT32 SGDisplayPreviewFonts::CompareTo(SGDisplayNode *Other, INT32 SortKey)
01286 {
01287 switch(SortKey)
01288 {
01289 case 1:
01290
01291 {
01292 String_256 MyName;
01293 String_256 ItsName;
01294
01295 GetNameText(&MyName);
01296 MyName.toLower();
01297 Other->GetNameText(&ItsName);
01298 ItsName.toLower();
01299
01300 return(MyName.CompareTo(ItsName, FALSE));
01301 }
01302
01303 case 2:
01304
01305
01306 return 0;
01307
01308 case 3:
01309 {
01310 String_256 MyName;
01311 String_256 ItsName;
01312
01313 GetNameText(&MyName);
01314 Other->GetNameText(&ItsName);
01315
01316 return (MyName.Length() - ItsName.Length());
01317 }
01318 break;
01319
01320 case 4:
01321 {
01322 SGDisplayPreviewFonts *OtherFont = (SGDisplayPreviewFonts *)Other;
01323
01324 if(Type == OtherFont->Type)
01325 return 0;
01326 if(Type == FC_ATM && OtherFont->Type == FC_TRUETYPE)
01327 return -1;
01328 return 1;
01329 break;
01330 }
01331
01332 }
01333
01334 return (SGDisplayNode::CompareTo(Other, SortKey));
01335 }
01336
01337
01338
01339
01340
01341
01342
01343
01344
01345
01346
01347
01348
01349
01350
01351
01352
01353
01354
01355 BOOL SGDisplayPreviewFonts::CreateThumbnail(KernelBitmap **Bitmap)
01356 {
01357 ERROR3("SGDisplayPreviewFonts::CreateThumbnail should be overridden");
01358
01359
01360 return TRUE;
01361 }
01362
01363
01364
01365
01366
01367
01368
01369
01370
01371
01372
01373
01374
01375
01376
01377
01378
01379
01380
01381
01382
01383
01384
01385
01386
01387
01388
01389
01390
01391
01392
01393
01394
01395
01396
01397
01398
01399
01400
01401
01402
01403
01404
01405
01406
01407
01408
01409
01410
01411 BOOL SGDisplayPreviewFonts::HandleEvent(SGEventType EventType, void *EventInfo, SGMiscInfo *MiscInfo)
01412 {
01413 switch (EventType)
01414 {
01415 case SGEVENT_FORMAT:
01416 {
01417 SGFormatInfo *FormatInfo = GetFormatInfo(EventType, EventInfo);
01418 CalculateMyRect(FormatInfo, MiscInfo);
01419 }
01420 break;
01421
01422
01423 case SGEVENT_REDRAW:
01424 {
01425 DocRect MyRect(FormatRect);
01426 SGRedrawInfo *RedrawInfo = GetRedrawInfo(EventType, EventInfo);
01427
01428 RedrawInfo->Renderer->SaveContext();
01429
01430 if (IMustRedraw(RedrawInfo))
01431 HandleRedraw(RedrawInfo, MiscInfo);
01432
01433 RedrawInfo->Renderer->RestoreContext();
01434 }
01435 break;
01436
01437
01438 case SGEVENT_MOUSECLICK:
01439 {
01440 SGMouseInfo *Mouse = GetMouseInfo(EventType, EventInfo);
01441
01442 if (FormatRect.ContainsCoord(Mouse->Position))
01443 {
01444 if(Mouse->DoubleClick)
01445 DefaultClickHandler(Mouse, MiscInfo);
01446 else
01447 {
01448 DefaultPreDragHandler(Mouse, MiscInfo);
01449
01450
01451 GalleryFontsDragInfo *DragFont;
01452 KernelBitmap *DispBmp = GetDisplayedKernelBitmap(MiscInfo, TRUE);
01453 if(DispBmp)
01454 {
01455 LibraryGallery::TmpDraggingBitmap = DIBUtil::CopyKernelBitmap(DispBmp, TRUE);
01456 DragFont = new GalleryFontsDragInfo(this, Mouse, MiscInfo,
01457 Mouse->MenuClick, 0, 0);
01458 }
01459 else
01460 {
01461
01462 LibraryGallery::TmpDraggingBitmap = NULL;
01463
01464
01465 UINT32 XSize = SG_InfiniteWidth;
01466 UINT32 YSize = SG_DefaultLargeIcon;
01467 INT32 DisplayMode = MiscInfo->DisplayMode;
01468 SGDisplayPreviewFonts::GetThumbnailDetails(DisplayMode, &XSize, &YSize, NULL);
01469
01470 if(XSize == 0 || YSize == 0)
01471 {
01472 XSize = SGF_SMALL_X;
01473 YSize = SGF_SMALL_Y;
01474 }
01475
01476
01477 DragFont = new GalleryFontsDragInfo(this, Mouse, MiscInfo,
01478 Mouse->MenuClick, XSize, YSize);
01479 }
01480
01481 if (DragFont != NULL)
01482 DragManagerOp::StartDrag(DragFont, GetListWindow());
01483 }
01484 return(TRUE);
01485 }
01486 }
01487 break;
01488
01489 default:
01490 return SGDisplayItem::HandleEvent(EventType, EventInfo, MiscInfo);
01491 }
01492
01493
01494 return FALSE;
01495 }
01496
01497
01498
01499
01500
01501
01502
01503
01504
01505
01506
01507
01508
01509
01510
01511
01512
01513
01514
01515
01516 void SGDisplayPreviewFonts::DragWasReallyAClick(SGMouseInfo *Mouse, SGMiscInfo *MiscInfo)
01517 {
01518
01519 DefaultClickHandler(Mouse, MiscInfo, TRUE);
01520 }
01521
01522
01523
01524
01525
01526
01527
01528
01529
01530
01531
01532
01533
01534
01535
01536
01537
01538
01539 BOOL SGDisplayPreviewFonts::GetThumbnailDetails(INT32 Mode, UINT32 *X, UINT32 *Y, String_256 *Text)
01540 {
01541 if(X == NULL || Y == NULL) return FALSE;
01542
01543 switch(Mode)
01544 {
01545 case 0:
01546 *X = SGF_NORMAL_X;
01547 *Y = SGF_NORMAL_Y;
01548 if(Text != NULL)
01549 *Text = _R(IDS_LARGEFONTDISPLAYSTRING);
01550 break;
01551
01552 case 1:
01553 *X = SGF_FULL_X;
01554 *Y = SGF_FULL_Y;
01555
01556
01557 break;
01558
01559 case 2:
01560 *X = SGF_SMALL_X;
01561 *Y = SGF_SMALL_Y;
01562 if(Text != NULL) *Text = _R(IDS_FONTS_GALLERY_SMALL_TEXT);
01563 break;
01564
01565 case 3:
01566 *X = SGF_FULL_X;
01567 *Y = SGF_FULL_Y;
01568
01569 break;
01570
01571 case 4:
01572 *X = 0;
01573 *Y = 0;
01574 break;
01575
01576 }
01577
01578 return TRUE;
01579 }
01580
01581
01582
01583
01584
01585
01586
01587
01588
01589
01590
01591
01592
01593
01594
01595
01596
01597
01598
01599
01600
01601
01602
01603 void SGDisplayPreviewFonts::GetKeyWords(String_256 *Result)
01604 {
01605 ERROR3IF(Result == NULL, "SGDisplayPreviewFonts::GetKeywords given a NULL param");
01606 if(Result == NULL)
01607 return;
01608
01609
01610 *Result = "";
01611 }
01612
01613
01614
01615
01616
01617
01618
01619
01620
01621
01622
01623
01624
01625
01626
01627
01628
01629
01630
01631
01632
01633
01634
01635
01636
01637
01638
01639
01640
01641
01642
01643
01644
01645
01646
01647 void SGDisplayPreviewFonts::MoveAfter(SGDisplayNode *NodeToMove)
01648 {
01649 SGDisplayNode::MoveAfter(NodeToMove);
01650 }
01651
01652
01653
01654
01655
01656
01657
01658
01659
01660
01661
01662
01663
01664
01665
01666
01667
01668
01669
01670
01671
01672
01673
01674
01675
01676
01677
01678
01679
01680
01681
01682
01683
01684
01685 void SGDisplayPreviewFonts::MoveBefore(SGDisplayNode *NodeToMove)
01686 {
01687 SGDisplayNode::MoveBefore(NodeToMove);
01688 }
01689
01690
01691
01692
01693
01694
01695
01696
01697
01698
01699
01700
01701
01702
01703
01704
01705
01706
01707
01708
01709
01710
01711
01712
01713
01714
01715
01716
01717
01718
01719 BOOL SGDisplayPreviewFonts::GetBubbleHelp(DocCoord *MousePos, String_256 *Result)
01720 {
01721 ERROR3IF(MousePos == NULL || Result == NULL, "Invalid NULL params");
01722
01723 *Result = *GetDisplayedTextDescription();
01724
01725 return(TRUE);
01726 }
01727
01728
01729
01730
01731
01732
01733
01734
01735
01736
01737
01738
01739
01740
01741
01742
01743
01744
01745
01746
01747
01748
01749
01750
01751
01752
01753
01754
01755
01756
01757 BOOL SGDisplayPreviewFonts::GetStatusLineHelp(DocCoord *MousePos, String_256 *Result)
01758 {
01759 ERROR3IF(MousePos == NULL || Result == NULL, "Invalid NULL params");
01760
01761
01762 Result->MakeMsg(_R(IDS_FONTS_INSTALLED_STATUS), ((TCHAR *)(*GetDisplayedTextDescription())));
01763
01764 return(TRUE);
01765 }
01766
01767
01768
01769
01770
01771
01772
01773
01774
01775
01776
01777
01778
01779 SGTTFItem::SGTTFItem()
01780 {
01781 ERROR3("Illegal call on default SGTTFItem constructor - call the other one!");
01782 CachedLogFont = NULL;
01783 IntLeading = 0;
01784 Type = FC_TRUETYPE;
01785 }
01786
01787
01788
01789
01790
01791
01792
01793
01794
01795
01796 SGTTFItem::~SGTTFItem()
01797 {
01798 if(CachedLogFont != NULL)
01799 {
01800 delete CachedLogFont;
01801 CachedLogFont = NULL;
01802 }
01803 }
01804
01805
01806
01807
01808
01809
01810
01811
01812
01813
01814
01815
01816
01817
01818
01819
01820
01821
01822
01823
01824
01825
01826
01827 SGTTFItem::SGTTFItem(KernelBitmap *PreviewFontsToDisplay, String_64 *FontName, INT32 IL, PLOGFONT lplf, UINT32 TheID)
01828 {
01829
01830 ERROR3IF(PreviewFontsToDisplay != NULL, "SGTTFItem::SGTTFItem PreviewFontsToDisplay - This should now be NULL since the font bitmaps are handled by the thumb cache");
01831
01832 FontBitmap = NULL;
01833
01834 if(FontName != NULL)
01835 FontDescription = *FontName;
01836
01837 CachedLogFont = NULL;
01838 if(lplf != NULL)
01839 CachedLogFont = new LOGFONT;
01840 if(CachedLogFont != NULL)
01841 *CachedLogFont = *lplf;
01842
01843 ID = TheID;
01844 IntLeading = IL;
01845 Type = FC_TRUETYPE;
01846 Invalid = FALSE;
01847 }
01848
01849
01850
01851
01852
01853
01854
01855
01856
01857
01858
01859
01860
01861
01862
01863
01864
01865
01866
01867 void SGTTFItem::GetFullInfoText(String_256 *Result)
01868 {
01869 ERROR3IF(Result == NULL, "SGTTFItem::GetFullInfoText given null ptr");
01870
01871 *Result = (String_256)FontDescription;
01872
01873 #ifdef SGFONTS_FULLINFO_FOR_INSTALLED_FONTS
01874
01875 PathName FOTFile;
01876 GetFOTNameFromRegistry(FontDescription, &FOTFile);
01877
01878 *Result += " '";
01879 *Result += TEXT(FOTFile.GetPath());
01880 *Result += "' - ";
01881
01882 switch((CachedLogFont->lfPitchAndFamily & 0xf0))
01883 {
01884 case FF_DONTCARE:
01885 *Result += String_64(_R(IDS_FONTS_FF_DONTCARE));
01886 break;
01887 case FF_MODERN:
01888 *Result += String_64(_R(IDS_FONTS_FF_MODERN));
01889 break;
01890 case FF_ROMAN:
01891 *Result += String_64(_R(IDS_FONTS_FF_ROMAN));
01892 break;
01893 case FF_SCRIPT:
01894 *Result += String_64(_R(IDS_FONTS_FF_SCRIPT));
01895 break;
01896 case FF_SWISS:
01897 *Result += String_64(_R(IDS_FONTS_FF_SWISS));
01898 break;
01899 case FF_DECORATIVE:
01900 *Result += String_64(_R(IDS_FONTS_FF_DECORATIVE));
01901 break;
01902 default:
01903 *Result += String_64(_R(IDS_FONTS_UNRECOGNISED));
01904 break;
01905 }
01906
01907 *Result += " - ";
01908
01909 switch((CachedLogFont->lfPitchAndFamily & 0x0f))
01910 {
01911 case DEFAULT_PITCH:
01912 *Result += String_64(_R(IDS_FONTS_DEFAULT_PITCH));
01913 break;
01914 case FIXED_PITCH:
01915 *Result += String_64(_R(IDS_FONTS_FIXED_PITCH));
01916 break;
01917 case VARIABLE_PITCH:
01918 *Result += String_64(_R(IDS_FONTS_VARIABLE_PITCH));
01919 break;
01920 }
01921
01922 *Result += " - ";
01923
01924 switch(CachedLogFont->lfWeight)
01925 {
01926 case FW_DONTCARE:
01927 *Result += String_64(_R(IDS_FONTS_FW_DONTCARE));
01928 break;
01929 case FW_THIN:
01930 *Result += String_64(_R(IDS_FONTS_FW_THIN));
01931 break;
01932 case FW_EXTRALIGHT:
01933 *Result += String_64(_R(IDS_FONTS_FW_EXTRALIGHT));
01934 break;
01935 case FW_LIGHT:
01936 *Result += String_64(_R(IDS_FONTS_FW_LIGHT));
01937 break;
01938 case FW_NORMAL:
01939 *Result += String_64(_R(IDS_FONTS_FW_NORMAL));
01940 break;
01941 case FW_MEDIUM:
01942 *Result += String_64(_R(IDS_FONTS_FW_MEDIUM));
01943 break;
01944 case FW_SEMIBOLD:
01945 *Result += String_64(_R(IDS_FONTS_FW_SEMIBOLD));
01946 break;
01947 case FW_BOLD:
01948 *Result += String_64(_R(IDS_FONTS_FW_BOLD));
01949 break;
01950 case FW_EXTRABOLD:
01951 *Result += String_64(_R(IDS_FONTS_FW_EXTRABOLD));
01952 break;
01953 case FW_HEAVY:
01954 *Result += String_64(_R(IDS_FONTS_FW_HEAVY));
01955 break;
01956 }
01957
01958 *Result += " - ";
01959
01960 switch((CachedLogFont->lfCharSet))
01961 {
01962 case ANSI_CHARSET:
01963 *Result += String_64(_R(IDS_FONTS_ANSI_CHARSET));
01964 break;
01965 case DEFAULT_CHARSET:
01966 *Result += String_64(_R(IDS_FONTS_DEFAULT_CHARSET));
01967 break;
01968 case SYMBOL_CHARSET:
01969 *Result += String_64(_R(IDS_FONTS_SYMBOL_CHARSET));
01970 break;
01971 case SHIFTJIS_CHARSET:
01972 *Result += String_64(_R(IDS_FONTS_SHIFTJIS_CHARSET));
01973 break;
01974 case HANGEUL_CHARSET:
01975 *Result += String_64(_R(IDS_FONTS_HANGEUL_CHARSET));
01976 break;
01977 case GB2312_CHARSET:
01978 *Result += String_64(_R(IDS_FONTS_GB2312_CHARSET));
01979 break;
01980 case CHINESEBIG5_CHARSET:
01981 *Result += String_64(_R(IDS_FONTS_CHINESEBIG5_CHARSET));
01982 break;
01983 case OEM_CHARSET:
01984 *Result += String_64(_R(IDS_FONTS_OEM_CHARSET));
01985 break;
01986 }
01987 #endif
01988
01989 }
01990
01991
01992
01993
01994
01995
01996
01997
01998
01999
02000
02001
02002
02003
02004
02005
02006
02007
02008
02009
02010
02011
02012
02013 BOOL SGTTFItem::CreateThumbnail(KernelBitmap** Bitmap)
02014 {
02015 if(Bitmap == NULL)
02016 {
02017 ERROR3("SGTTFItem::CreateThumbnail given a NULL bitmap ptr");
02018 return FALSE;
02019 }
02020
02021
02022 StringToBitmap S2BMP;
02023
02024
02025 PathName* ThePath = NULL;
02026
02027
02028 #ifdef _DEBUG
02029
02030
02031
02032 if (FALSE)
02033 {
02034 INT32 LibID = -1;
02035
02036
02037 String_256 tmp;
02038
02039
02040
02041 SuperGallery *SGal = GetParentGallery();
02042 if(SGal != NULL)
02043 {
02044 SGDisplayRoot *DispTree = SGal->GetDisplayTree();
02045 if(DispTree != NULL)
02046 {
02047
02048 SGDisplayNode *Item = DispTree->FindNextSelectedItem(NULL);
02049
02050 while (Item != NULL)
02051 {
02052 if(Item->Flags.Selected)
02053 {
02054 if(Item->IsKindOf(CC_RUNTIME_CLASS(SGLibFontItem)))
02055 {
02056 SGLibFontItem *FontItem = (SGLibFontItem *) Item;
02057 if(FontItem->GetType() == FC_TRUETYPE)
02058 {
02059 String_256 Result;
02060 ((SGLibFontItem *)FontItem)->GetNameText(&Result);
02061
02062 String_32 Result32;
02063 String_32 FontDesc32;
02064 Result.Left(&Result32, 31);
02065 FontDescription.Left(&FontDesc32, 31);
02066
02067 if(Result32 == FontDesc32)
02068 {
02069 if(LibID != -1)
02070 {
02071 ERROR3("Bad... Two identical text strings in the fonts...");
02072 }
02073 else
02074 {
02075 LibID = ((SGLibFontItem *)FontItem)->GetFontID();
02076 }
02077 }
02078 }
02079 }
02080 }
02081
02082 Item = SGDisplayRoot::FindNextItemInTree(Item);
02083 }
02084 }
02085 }
02086
02087
02088
02089 if (LibID != -1)
02090 {
02091
02092 if (Library::MaxFieldCacheEntries <= 25)
02093 {
02094 switch(DMode)
02095 {
02096 case 0:
02097 camSprintf(tmp, TEXT("c:\\fonts\\TrueType\\XaraInfo\\F%05dL.bmp"), LibID);
02098 break;
02099 case 2:
02100 camSprintf(tmp, TEXT("c:\\fonts\\TrueType\\XaraInfo\\F%05dS.bmp"), LibID);
02101 break;
02102 case 1:
02103 case 3:
02104 default:
02105 camSprintf(tmp, TEXT("c:\\fonts\\TrueType\\XaraInfo\\F%05dM.bmp"), LibID);
02106 break;
02107 }
02108 ThePath = new PathName(tmp);
02109
02110 if(ThePath != NULL)
02111 {
02112 if(!ThePath->IsValid())
02113 {
02114 delete ThePath;
02115 ThePath = NULL;
02116 }
02117 }
02118 }
02119 else
02120 {
02121 switch(DMode)
02122 {
02123 case 0:
02124 camSprintf(tmp, TEXT("d:\\fonts\\TrueType\\XaraInfo\\F%05dL.bmp"), LibID);
02125 break;
02126 case 2:
02127 camSprintf(tmp, TEXT("d:\\fonts\\TrueType\\XaraInfo\\F%05dS.bmp"), LibID);
02128 break;
02129 case 1:
02130 case 3:
02131 default:
02132 camSprintf(tmp, TEXT("d:\\fonts\\TrueType\\XaraInfo\\F%05dM.bmp"), LibID);
02133 break;
02134 }
02135 ThePath = new PathName(tmp);
02136
02137 if(ThePath != NULL)
02138 {
02139 if(!ThePath->IsValid())
02140 {
02141 delete ThePath;
02142 ThePath = NULL;
02143 }
02144 }
02145 }
02146 }
02147 }
02148
02149 #endif
02150
02151
02152
02153
02154
02155 UINT32 XDPI = 90;
02156 CDC Screen;
02157 if(Screen.CreateIC(TEXT("DISPLAY"), 0, 0, 0))
02158 {
02159 XDPI = GetDeviceCaps(Screen.m_hDC, LOGPIXELSX);
02160 Screen.DeleteDC();
02161 }
02162 else
02163 {
02164 ERROR3("SGTTFItem::CreateThumbnail Unable to create screen DC");
02165 return FALSE;
02166 }
02167
02168 BOOL ok = TRUE;
02169 UINT32 Xsize = 128;
02170 UINT32 Ysize = 32;
02171 String_256 text(FontDescription);
02172
02173
02174 GetThumbnailDetails(DMode, &Xsize, &Ysize, &text);
02175
02176
02177 ok = S2BMP.MakeBitmap(&text, Xsize, Ysize, SGF_BPP, XDPI, CachedLogFont, IntLeading, Bitmap, FC_TRUETYPE, ThePath);
02178
02179 if(!ok)
02180 Invalid = TRUE;
02181
02182 #if _DEBUG
02183
02184 if(!ok) TRACEUSER( "Richard", _T("SGTTFItem::CreateBitmap: failed to create the bitmap\n"));
02185
02186 if(ThePath != NULL)
02187 {
02188 delete ThePath;
02189 ThePath = NULL;
02190 }
02191
02192 #endif
02193
02194
02195 return TRUE;
02196 }
02197
02198
02199
02200
02201
02202
02203
02204
02205
02206
02207
02208
02209
02210
02211 SGATMItem::SGATMItem()
02212 {
02213 ERROR3("Illegal call on default SGATMItem constructor - call the other one!");
02214 CachedLogFont = NULL;
02215 IntLeading = 0;
02216 Type = FC_ATM;
02217 }
02218
02219
02220
02221
02222
02223
02224
02225
02226
02227
02228 SGATMItem::~SGATMItem()
02229 {
02230 if(CachedLogFont != NULL)
02231 {
02232 delete CachedLogFont;
02233 CachedLogFont = NULL;
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 SGATMItem::SGATMItem(KernelBitmap *PreviewFontsToDisplay, String_64 *FontName, INT32 IL, PLOGFONT lplf, UINT32 TheID)
02260 {
02261
02262 ERROR3IF(PreviewFontsToDisplay != NULL, "SGATMItem::SGATMItem PreviewFontsToDisplay - This should now be NULL since the font bitmaps are handled by the thumb cache");
02263
02264 FontBitmap = NULL;
02265
02266 if(FontName != NULL)
02267 FontDescription = *FontName;
02268
02269 CachedLogFont = NULL;
02270 if(lplf != NULL)
02271 CachedLogFont = new LOGFONT;
02272 if(CachedLogFont != NULL)
02273 *CachedLogFont = *lplf;
02274
02275 ID = TheID;
02276 IntLeading = IL;
02277 Type = FC_ATM;
02278 Invalid = FALSE;
02279 }
02280
02281
02282
02283
02284
02285
02286
02287
02288
02289
02290
02291
02292
02293
02294
02295
02296
02297
02298 void SGATMItem::GetFullInfoText(String_256 *Result)
02299 {
02300 ERROR3IF(Result == NULL, "SGATMItem::GetFullInfoText given null ptr");
02301
02302 *Result = (String_256)FontDescription;
02303
02304 #ifdef SGFONTS_FULLINFO_FOR_INSTALLED_FONTS
02305
02306 #endif
02307 }
02308
02309
02310
02311
02312
02313
02314
02315
02316
02317
02318
02319
02320
02321
02322
02323
02324
02325
02326
02327
02328
02329
02330 BOOL SGATMItem::CreateThumbnail(KernelBitmap **Bitmap)
02331 {
02332 if(Bitmap == NULL)
02333 {
02334 ERROR3("SGATMItem::CreateThumbnail given a NULL bitmap ptr");
02335 return FALSE;
02336 }
02337
02338
02339 StringToBitmap S2BMP;
02340
02341
02342 PathName *ThePath = NULL;
02343
02344
02345 #ifdef _DEBUG
02346
02347
02348
02349 if (FALSE)
02350 {
02351 INT32 LibID = -1;
02352
02353
02354 String_256 tmp;
02355
02356
02357
02358 SuperGallery *SGal = GetParentGallery();
02359 if(SGal != NULL)
02360 {
02361 SGDisplayRoot *DispTree = SGal->GetDisplayTree();
02362 if(DispTree != NULL)
02363 {
02364
02365 SGDisplayNode *Item = DispTree->FindNextSelectedItem(NULL);
02366
02367 while (Item != NULL)
02368 {
02369 if(Item->Flags.Selected)
02370 {
02371 if(Item->IsKindOf(CC_RUNTIME_CLASS(SGLibFontItem)))
02372 {
02373 SGLibFontItem *FontItem = (SGLibFontItem *) Item;
02374 if(FontItem->GetType() == FC_ATM)
02375 {
02376 String_256 Result;
02377 ((SGLibFontItem *)FontItem)->GetNameText(&Result);
02378
02379 String_32 Result32;
02380 String_32 FontDesc32;
02381 Result.Left(&Result32, 31);
02382 FontDescription.Left(&FontDesc32, 31);
02383
02384 if(Result32 == FontDesc32)
02385 {
02386 if(LibID != -1)
02387 {
02388 ERROR3("Bad... Two identical text strings in the fonts...");
02389 }
02390 else
02391 {
02392 LibID = ((SGLibFontItem *)FontItem)->GetFontID();
02393 }
02394 }
02395 }
02396 }
02397 }
02398
02399 Item = SGDisplayRoot::FindNextItemInTree(Item);
02400 }
02401 }
02402 }
02403
02404
02405
02406 if(LibID != -1)
02407 {
02408
02409 if(Library::MaxFieldCacheEntries <= 25)
02410 {
02411 switch(DMode)
02412 {
02413 case 0:
02414 camSprintf(tmp, _T("c:\\fonts\\ATM\\XaraInfo\\F%05dL.bmp"), LibID);
02415 break;
02416 case 2:
02417 camSprintf(tmp, _T("c:\\fonts\\ATM\\XaraInfo\\F%05dS.bmp"), LibID);
02418 break;
02419 case 1:
02420 case 3:
02421 default:
02422 camSprintf(tmp, _T("c:\\fonts\\ATM\\XaraInfo\\F%05dM.bmp"), LibID);
02423 break;
02424 }
02425 ThePath = new PathName(tmp);
02426
02427 if(ThePath != NULL)
02428 {
02429 if(!ThePath->IsValid())
02430 {
02431 delete ThePath;
02432 ThePath = NULL;
02433 }
02434 }
02435 }
02436 else
02437 {
02438 switch(DMode)
02439 {
02440 case 0:
02441 camSprintf(tmp, _T("d:\\fonts\\ATM\\XaraInfo\\F%05dL.bmp"), LibID);
02442 break;
02443 case 2:
02444 camSprintf(tmp, _T("d:\\fonts\\ATM\\XaraInfo\\F%05dS.bmp"), LibID);
02445 break;
02446 case 1:
02447 case 3:
02448 default:
02449 camSprintf(tmp, _T("d:\\fonts\\ATM\\XaraInfo\\F%05dM.bmp"), LibID);
02450 break;
02451 }
02452 ThePath = new PathName(tmp);
02453
02454 if(ThePath != NULL)
02455 {
02456 if(!ThePath->IsValid())
02457 {
02458 delete ThePath;
02459 ThePath = NULL;
02460 }
02461 }
02462 }
02463 }
02464 }
02465
02466 #endif
02467
02468
02469 UINT32 XDPI = 90;
02470 CDC Screen;
02471 if(Screen.CreateIC(TEXT("DISPLAY"), 0, 0, 0))
02472 {
02473 XDPI = GetDeviceCaps(Screen.m_hDC, LOGPIXELSX);
02474 Screen.DeleteDC();
02475 }
02476 else
02477 {
02478 ERROR3("SGATMItem::CreateThumbnail Unable to create screen DC");
02479 return FALSE;
02480 }
02481
02482 BOOL ok = TRUE;
02483 UINT32 Xsize = 128;
02484 UINT32 Ysize = 32;
02485 String_256 text(FontDescription);
02486
02487
02488 GetThumbnailDetails(DMode, &Xsize, &Ysize, &text);
02489
02490
02491 ok = S2BMP.MakeBitmap(&text, Xsize, Ysize, SGF_BPP, XDPI, CachedLogFont, IntLeading, Bitmap, FC_ATM, ThePath);
02492
02493 if(!ok)
02494 Invalid = TRUE;
02495
02496
02497
02498
02499 return TRUE;
02500 }
02501
02502
02503
02504
02505
02506
02507
02508
02509
02510
02511
02512
02513
02514
02515 FontsSGallery::FontsSGallery()
02516 {
02517 DlgResID = _R(IDD_FONTSGALLERY);
02518
02519 InsGroup = NULL;
02520
02521
02522 InsCache = new SGThumbs(NULL, SGLib_Font, SGThumb_Large);
02523
02524 ThisGallery = this;
02525
02526 IDCount = 0;
02527
02528
02529 CSize Size(380, 256);
02530 SetGallerySize(Size);
02531
02532 WarnAboutSectionDragging = FALSE;
02533 WarnAboutMultipleATMDragging = FALSE;
02534 if (!OpAsynchFontInstall::Init())
02535 {
02536 ERROR3("Failed to init operation");
02537 }
02538 }
02539
02540
02541
02542
02543
02544
02545
02546
02547
02548
02549
02550
02551
02552 FontsSGallery::~FontsSGallery()
02553 {
02554 if(InsGroup != NULL) InsGroup = NULL;
02555
02556 if(InsCache != NULL)
02557 {
02558 delete InsCache;
02559 InsCache = NULL;
02560 }
02561
02562 ThisGallery = NULL;
02563 IDCount = 0;
02564
02565 OpenLibFiles.DeleteAll();
02566
02567 WarnAboutSectionDragging = FALSE;
02568 WarnAboutMultipleATMDragging = FALSE;
02569 }
02570
02571
02572
02573
02574
02575
02576
02577
02578
02579
02580
02581
02582
02583
02584
02585
02586
02587
02588
02589
02590
02591
02592
02593
02594
02595
02596 INT32 CALLBACK FontsSGallery::EnumInstalledFamily(ENUMLOGFONT FAR *lplf,
02597 NEWTEXTMETRIC FAR *lpntm, INT32 FontType, LPARAM handle)
02598 {
02599 FontsSGallery::AddedFonts = TRUE;
02600
02601 ERROR3IF(ThisGallery == NULL, "There's no gallery in EnumInstalledFonts...");
02602 if(ThisGallery == NULL) return 0;
02603
02604
02605 if((FontsSGallery::EnumFontClass == FC_ATM) && !(FontType & DEVICE_FONTTYPE))
02606 return TRUE;
02607
02608 if((FontsSGallery::EnumFontClass == FC_TRUETYPE) && !(FontType & TRUETYPE_FONTTYPE))
02609 return TRUE;
02610
02611
02612 if((FontType & DEVICE_FONTTYPE) && !OILFontMan::IsOkToCall(FC_ATM))
02613 return TRUE;
02614
02615
02616 if((FontType & TRUETYPE_FONTTYPE) || (FontType & DEVICE_FONTTYPE)) {
02617
02618
02619
02620
02621 ThisGallery->IDCount++;
02622
02623
02624 KernelBitmap *pBitmap = NULL;
02625
02626
02627 pBitmap = NULL;
02628
02629
02630
02631
02632
02633 SGFontsGroup* DisplayGroup = (SGFontsGroup*) handle;
02634
02635
02636 if (FontType & TRUETYPE_FONTTYPE)
02637 {
02638 SGTTFItem* NewItem;
02639 String_64 FontName = (TCHAR*) lplf->elfFullName;
02640
02641
02642 String_64 strFaceName = (LPCTSTR) lplf->elfLogFont.lfFaceName;
02643 if (FontName.Length() < strFaceName.Length()) FontName = strFaceName;
02644
02645
02646 if (((LPCTSTR) FontName)[0] != TEXT('@'))
02647 {
02648
02649 BOOL fAlreadyExists = FALSE;
02650 for (SGDisplayPreviewFonts* pItem = (SGDisplayPreviewFonts*) DisplayGroup->GetChild();
02651 pItem != 0;
02652 pItem = (SGDisplayPreviewFonts*) pItem->GetNext())
02653 if (pItem->FontDescription == FontName)
02654 {
02655 fAlreadyExists = TRUE;
02656 break;
02657 }
02658
02659
02660 if (!fAlreadyExists)
02661 {
02662
02663 NewItem = new SGTTFItem(pBitmap, &FontName, lpntm->tmInternalLeading,
02664 &lplf->elfLogFont, ThisGallery->IDCount);
02665
02666
02667 if (NewItem != 0) DisplayGroup->AddItem(NewItem);
02668 }
02669 }
02670 }
02671 else
02672 {
02673
02674 if (FontType & DEVICE_FONTTYPE)
02675 {
02676 SGATMItem* NewItem;
02677
02678
02679
02680
02681 String_64 FontName = (TCHAR*) lplf->elfLogFont.lfFaceName;
02682 if (lplf->elfLogFont.lfWeight >= FW_BOLD) FontName += String_16(_R(IDS_FONTS_SPACE_BOLD));
02683 if (lplf->elfLogFont.lfItalic) FontName += String_16(_R(IDS_FONTS_SPACE_ITALIC));
02684
02685
02686 NewItem = new SGATMItem(pBitmap, &FontName, lpntm->tmInternalLeading,
02687 &lplf->elfLogFont, ThisGallery->IDCount);
02688
02689
02690 if (NewItem != 0) DisplayGroup->AddItem(NewItem);
02691 }
02692 }
02693 }
02694 return TRUE;
02695 }
02696
02697
02698
02699
02700
02701
02702
02703
02704
02705
02706
02707
02708
02709
02710
02711
02712
02713
02714
02715
02716
02717
02718
02719
02720
02721 INT32 CALLBACK FontsSGallery::EnumInstalledFonts(ENUMLOGFONT FAR *lplf,
02722 NEWTEXTMETRIC FAR *lpntm, INT32 FontType, LPARAM handle)
02723 {
02724 ERROR3IF(ThisGallery == NULL, "There's no gallery in EnumInstalledFonts...");
02725 if(ThisGallery == NULL) return 0;
02726
02727
02728 if((FontType & DEVICE_FONTTYPE) && !OILFontMan::IsOkToCall(FC_ATM))
02729 return TRUE;
02730
02731
02732 if((FontType & TRUETYPE_FONTTYPE) || (FontType & DEVICE_FONTTYPE))
02733 {
02734 BOOL ok = TRUE;
02735 FontsSGallery::AddedFonts = FALSE;
02736
02737
02738 if(!((FontType & DEVICE_FONTTYPE) && ATMInstall::IsFontAlias(lplf->elfLogFont.lfFaceName)))
02739 {
02740 HDC ScreenDC = CreateCompatibleDC(NULL);
02741 if (ScreenDC == NULL)
02742 {
02743 ERROR3("FontsSGallery::EnumInstalledFontsSGDisplay: Unable to create screen DC");
02744 return TRUE;
02745 }
02746 else
02747 {
02748 FontsSGallery::EnumFontClass = FC_UNDEFINED;
02749
02750 if(FontType & TRUETYPE_FONTTYPE)
02751 FontsSGallery::EnumFontClass = FC_TRUETYPE;
02752
02753 if(FontType & DEVICE_FONTTYPE)
02754 FontsSGallery::EnumFontClass = FC_ATM;
02755
02756 ok = EnumFontFamilies(ScreenDC, (LPCSTR) lplf->elfLogFont.lfFaceName,
02757 (FONTENUMPROC) EnumInstalledFamily, handle);
02758
02759
02760
02761 if (!AddedFonts) EnumInstalledFamily(lplf, lpntm, FontType, handle);
02762 }
02763
02764 DeleteDC(ScreenDC);
02765 }
02766 }
02767
02768 return TRUE;
02769 }
02770
02771
02772
02773
02774
02775
02776
02777
02778
02779
02780
02781
02782
02783
02784
02785
02786
02787
02788
02789
02790
02791
02792
02793
02794
02795
02796
02797
02798
02799 SGDisplayItem *FontsSGallery::AddLibraryItem(SGDisplayGroup *LibraryGroup,
02800 Library *ParentLib,
02801 LibraryIndex ItemIndex, BOOL bNew)
02802 {
02803 ERROR3IF(LibraryGroup == NULL || ParentLib == NULL,
02804 "SuperGallery::AddLibraryItem - NULL params are illegal");
02805
02806 ERROR3IF(LibraryGroup->GetParentLibrary() != ParentLib,
02807 "SuperGallery::AddLibraryitem - The DisplayGroup is not for the same library!");
02808
02809
02810 SGLibFontItem *NewItem = new SGLibFontItem(ItemIndex, bNew);
02811
02812 #if 0
02813
02814 SGSortKey SortKeys[MaxSGSortKeys];
02815 for (INT32 i = 0; i < MaxSGSortKeys; i++)
02816 {
02817 SortKeys[i].SortKey = 0;
02818 SortKeys[i].Reversed = FALSE;
02819 }
02820
02821 SortKeys[0].SortKey = 1;
02822 #endif
02823
02824 if (NewItem != NULL)
02825 LibraryGroup->AddItem(NewItem);
02826
02827 return(NewItem);
02828 }
02829
02830
02831
02832
02833
02834
02835
02836
02837
02838
02839
02840
02841
02842
02843
02844
02845
02846
02847
02848
02849
02850
02851
02852
02853 void FontsSGallery::CreateNewSubtreeForInstalledFonts(SGFontsGroup *ExistingGroup)
02854 {
02855 ERROR3IF(DisplayTree==NULL, "No display tree!");
02856
02857 if(DisplayTree == NULL) return;
02858 if(ThisGallery == NULL) return;
02859
02860 ERROR3IF(ExistingGroup == NULL, "FontsSGallery::CreateNewSubtreeForInstalledFonts - NULL parameter given");
02861 if(ExistingGroup == NULL) return;
02862
02863 if(InsCache != NULL)
02864 InsCache->DeleteThumbnails();
02865
02866
02867 ExistingGroup->DestroySubtree(FALSE);
02868
02869 String_64 Description(_R(IDS_FONTS_SCANNING_FONTS));
02870 BeginSlowJob(-1, FALSE, &Description);
02871
02872
02873 BOOL ok=TRUE;
02874
02875 HDC ScreenDC = CreateCompatibleDC(NULL);
02876 if (ScreenDC == NULL)
02877 {
02878 ERROR3("FontSGallery::CreateNewSubtreeForInstalledFonts Unable to create screen DC");
02879 EndSlowJob();
02880 return;
02881 }
02882 else
02883 {
02884 IDCount = 0;
02885 ok=EnumFontFamilies(ScreenDC, NULL, (FONTENUMPROC)EnumInstalledFonts, (void *)ExistingGroup);
02886 }
02887 DeleteDC(ScreenDC);
02888
02889 EndSlowJob();
02890 }
02891
02892
02893
02894
02895
02896
02897
02898
02899
02900
02901
02902
02903
02904
02905
02906
02907
02908
02909
02910
02911
02912 BOOL FontsSGallery::CreateNewSubtreeForLibraryFonts(PathName *LibPath, BOOL WipeOld)
02913 {
02914
02915 return AddNewLibrary(LibPath, WipeOld, SGLib_Font, FALSE);
02916 }
02917
02918
02919
02920
02921
02922
02923
02924
02925
02926
02927
02928
02929
02930
02931
02932
02933
02934
02935
02936 BOOL FontsSGallery::InitMenuCommands(void)
02937 {
02938 static BOOL MenusInitialised = FALSE;
02939
02940 BOOL ok = TRUE;
02941
02942 if (!MenusInitialised)
02943 {
02944
02945
02946
02947 ok = ok && InitMenuCommand((StringBase *) &SGCmd_Find, _R(IDS_SGMENU_FIND));
02948 ok = ok && InitMenuCommand((StringBase *) &SGCmd_Sort, _R(IDS_SGMENU_SORT));
02949 ok = ok && InitMenuCommand((StringBase *) &SGCmd_Properties, _R(IDS_SGMENU_PROPERTIES));
02950
02951
02952 ok = ok && InitMenuCommand((StringBase *) &SGCmd_Add, _R(IDS_SGMENU_ADDFONT));
02953 ok = ok && InitMenuCommand((StringBase *) &SGCmd_EmptyFontsCache, _R(IDS_SGMENU_EMPTYFONTCACHE));
02954
02955
02956 ok = ok && InitMenuCommand((StringBase *) &SGCmd_Apply, _R(IDS_SGMENU_APPLY));
02957 ok = ok && InitMenuCommand((StringBase *) &SGCmd_Install, _R(IDS_SGMENU_INSTALL));
02958 ok = ok && InitMenuCommand((StringBase *) &SGCmd_Deinstall, _R(IDS_SGMENU_DEINSTALL));
02959 ok = ok && InitMenuCommand((StringBase *) &SGCmd_Remove, _R(IDS_SGMENU_REMOVE));
02960
02961
02962 ok = ok && InitMenuCommand((StringBase *) &SGCmd_FoldGroup, _R(IDS_SGMENU_FOLD));
02963 ok = ok && InitMenuCommand((StringBase *) &SGCmd_UnfoldGroup, _R(IDS_SGMENU_UNFOLD));
02964
02965 ok = ok && InitMenuCommand((StringBase *) &SGCmd_NextGroup, _R(IDS_SGMENU_NEXTGROUP));
02966 ok = ok && InitMenuCommand((StringBase *) &SGCmd_PrevGroup, _R(IDS_SGMENU_PREVGROUP));
02967
02968 MenusInitialised = TRUE;
02969 }
02970
02971 return(ok);
02972 }
02973
02974
02975
02976
02977
02978
02979
02980
02981
02982
02983
02984
02985
02986
02987
02988
02989
02990
02991
02992
02993
02994 BOOL FontsSGallery::BuildCommandMenu(GalleryContextMenu *TheMenu, SGMenuID MenuID)
02995 {
02996 BOOL ok = TRUE;
02997
02998 if (MenuID == SGMENU_OPTIONS)
02999 {
03000
03001 ok = ok && AddCommand(TheMenu, (StringBase *) &SGCmd_Add);
03002 ok = ok && AddCommand(TheMenu, (StringBase *) &SGCmd_EmptyFontsCache, TRUE);
03003 ok = ok && AddCommand(TheMenu, (StringBase *) &SGCmd_Find);
03004 ok = ok && AddCommand(TheMenu, (StringBase *) &SGCmd_Sort);
03005 ok = ok && AddCommand(TheMenu, (StringBase *) &SGCmd_Properties);
03006 }
03007 else
03008 {
03009
03010 ok = ok && AddCommand(TheMenu, (StringBase *) &SGCmd_Apply);
03011 ok = ok && AddCommand(TheMenu, (StringBase *) &SGCmd_Install);
03012 ok = ok && AddCommand(TheMenu, (StringBase *) &SGCmd_Deinstall);
03013 ok = ok && AddCommand(TheMenu, (StringBase *) &SGCmd_Remove, TRUE);
03014
03015 SGDisplayGroup *TheGroup = FindCommandGroup();
03016 if (TheGroup == NULL || !TheGroup->Flags.Folded)
03017 ok = ok && AddCommand(TheMenu, (StringBase *) &SGCmd_FoldGroup);
03018 else
03019 ok = ok && AddCommand(TheMenu, (StringBase *) &SGCmd_UnfoldGroup);
03020
03021 ok = ok && AddCommand(TheMenu, (StringBase *) &SGCmd_PrevGroup);
03022 ok = ok && AddCommand(TheMenu, (StringBase *) &SGCmd_NextGroup);
03023 }
03024
03025 return(ok);
03026 }
03027
03028
03029
03030
03031
03032
03033
03034
03035
03036
03037
03038
03039
03040
03041
03042
03043
03044
03045
03046
03047
03048
03049
03050
03051
03052
03053
03054
03055
03056 OpState FontsSGallery::GetCommandState(StringBase *CommandID, String_256 *ShadeReason)
03057 {
03058 OpState State;
03059
03060 if (*CommandID == SGCmd_Add)
03061 return(State);
03062
03063 if (*CommandID == SGCmd_EmptyFontsCache)
03064 {
03065 if (m_bDiscardWebFolders)
03066 State.Greyed = TRUE;
03067 return (State);
03068 }
03069
03070
03071 if (*CommandID == SGCmd_Apply)
03072 {
03073 if (GetSelectedItemCount() != 1)
03074 {
03075 State.Greyed = TRUE;
03076 ShadeReason->MakeMsg(_R(IDS_SGSHADE_NOSEL));
03077 }
03078 else
03079 {
03080 SGLibFontItem* pItem = (SGLibFontItem*) DisplayTree->FindNextSelectedItem(NULL);
03081 if (pItem)
03082 {
03083 String_256 Desc256;
03084 pItem->GetNameText(&Desc256);
03085
03086 if (!IsFontAlreadyInstalled(&Desc256, pItem->GetType()) && pItem->GetParentLibrary() && pItem->GetParentLibrary()->IsWebLibrary())
03087 {
03088 State.Greyed = TRUE;
03089 ShadeReason->MakeMsg(_R(IDS_SGSHADE_WEBFONT));
03090 }
03091 }
03092 }
03093 }
03094 else if (*CommandID == SGCmd_Install)
03095 {
03096 #ifdef STOP_WINDOWS95_FONT_INSTALLS
03097
03098 if (LibraryFontsSelected() < 1 || IsWin32c())
03099 #else
03100
03101 if (LibraryFontsSelected() < 1)
03102 #endif
03103 {
03104 State.Greyed = TRUE;
03105 ShadeReason->MakeMsg(_R(IDS_SGSHADE_NOSEL));
03106 }
03107 }
03108 else if (*CommandID == SGCmd_Deinstall)
03109 {
03110 #ifdef STOP_WINDOWS95_FONT_INSTALLS
03111
03112 if (!InstalledFontsSelected() || IsWin32c())
03113 #else
03114
03115 if (!InstalledFontsSelected())
03116 #endif
03117 {
03118 State.Greyed = TRUE;
03119 ShadeReason->MakeMsg(_R(IDS_SGSHADE_NOSEL));
03120 }
03121 }
03122 else if (*CommandID == SGCmd_Remove)
03123 {
03124 SGDisplayGroup *TheGroup = FindCommandGroup();
03125 if (TheGroup == NULL || (GetSelectedGroupCount() == 1 && TheGroup == InsGroup))
03126 {
03127
03128 State.Greyed = TRUE;
03129 ShadeReason->MakeMsg(_R(IDS_SGSHADE_NOSELGROUP));
03130 }
03131 }
03132 else
03133 return(SuperGallery::GetCommandState(CommandID, ShadeReason));
03134
03135 return(State);
03136 }
03137
03138
03139
03140
03141
03142
03143
03144
03145
03146
03147
03148
03149
03150
03151
03152
03153
03154
03155
03156
03157
03158
03159
03160
03161
03162 void FontsSGallery::DoCommand(StringBase *CommandID)
03163 {
03164 if (*CommandID == SGCmd_Add)
03165 BrowseClicked();
03166 else if (*CommandID == SGCmd_EmptyFontsCache)
03167 RemoveWebFolders(SGLib_Font);
03168 else if (*CommandID == SGCmd_Apply)
03169 {
03170 ApplyAction(SGACTION_APPLY);
03171 SelectionHasChanged();
03172 }
03173 else if (*CommandID == SGCmd_Install)
03174 {
03175 InstallFonts(TRUE);
03176 SelectionHasChanged();
03177 }
03178 else if (*CommandID == SGCmd_Deinstall)
03179 {
03180 DeinstallFonts(FontsSGallery::DeleteTTFandFOTfiles);
03181 SelectionHasChanged();
03182 }
03183 else if (*CommandID == SGCmd_Remove)
03184 {
03185 RemoveSelectedLibraries(TRUE);
03186 UpdateGRMFile();
03187 }
03188 else
03189 SuperGallery::DoCommand(CommandID);
03190 }
03191
03192
03193
03194
03195
03196
03197
03198
03199
03200
03201
03202
03203
03204
03205
03206
03207
03208
03209
03210 void FontsSGallery::SortInstalledFonts(void)
03211 {
03212 CurrentSortGallery = this;
03213
03214
03215 SGDisplayNode *CurrentGroup = InsGroup;
03216 if (CurrentGroup == NULL)
03217 return;
03218
03219 SGDisplayNode *Ptr = CurrentGroup;
03220
03221
03222 INT32 NumItemsToSort = 0;
03223 SGDisplayNode *Item = Ptr->GetChild();
03224 while (Item != NULL)
03225 {
03226 NumItemsToSort++;
03227 Item = Item->GetNext();
03228 }
03229
03230
03231 if (NumItemsToSort < 2 || (DefaultSortKeys & 0x7f == 0))
03232 return;
03233
03234
03235 SGSortKey TmpSortKeys[MaxSGSortKeys];
03236
03237 INT32 j;
03238
03239 for(j=0; j<MaxSGSortKeys; j++)
03240 TmpSortKeys[j] = SortKeys[j];
03241
03242
03243 SortKeys[0].SortKey = DefaultSortKeys & 0x7f;
03244 SortKeys[0].Reversed = (((DefaultSortKeys>>7) & 0x1) == 1);
03245 SortKeys[1].SortKey = (DefaultSortKeys>>8) & 0x7f;
03246 SortKeys[1].Reversed = (((DefaultSortKeys>>15) & 0x1) == 1);
03247
03248
03249
03250 String_64 Description(_R(IDS_SGOPTS_SORTING));
03251 BeginSlowJob(NumItemsToSort * 2, FALSE, &Description);
03252
03253 INT32 NumItems = NumItemsToSort;
03254 NumItemsToSort = 0;
03255 INT32 i = 0;
03256
03257
03258 Ptr = CurrentGroup->GetChild();
03259 ERROR3IF(!Ptr->IsKindOf(CC_RUNTIME_CLASS(SGDisplayItem)),
03260 "Sort hasn't found items! Hideous failure imminent!" );
03261
03262
03263 SGDisplayNode **SortArray = (SGDisplayNode **)CCMalloc(NumItems * sizeof(SGDisplayNode *));
03264 if (SortArray == NULL)
03265 {
03266 CurrentSortGallery = NULL;
03267 EndSlowJob();
03268 InformError();
03269 return;
03270 }
03271
03272
03273 i = 0;
03274 Ptr = CurrentGroup->GetChild();
03275 while (Ptr != NULL)
03276 {
03277 SortArray[i++] = Ptr;
03278 Ptr = Ptr->GetNext();
03279 }
03280
03281
03282 qsort(SortArray, NumItems, sizeof(SGDisplayNode *), SuperGallery::SortComparator);
03283
03284 NumItemsToSort += NumItems;
03285 ContinueSlowJob(NumItemsToSort);
03286
03287
03288
03289 if (SortArray[0]->GetPrevious() != NULL)
03290 {
03291 SortArray[1]->MoveBefore(SortArray[0]);
03292 }
03293
03294
03295 for (i = 1; i < NumItems; i++)
03296 {
03297 if (SortArray[i]->GetPrevious() != SortArray[i-1])
03298 {
03299 SortArray[i-1]->MoveAfter(SortArray[i]);
03300 }
03301 }
03302
03303
03304 CCFree(SortArray);
03305
03306
03307 AllItemsCopied((SGDisplayGroup *)CurrentGroup);
03308
03309 NumItemsToSort += NumItems;
03310 ContinueSlowJob(NumItemsToSort);
03311
03312 CurrentSortGallery = NULL;
03313
03314
03315 for(j=0; j<MaxSGSortKeys; j++)
03316 {
03317 SortKeys[j] = TmpSortKeys[j];
03318 }
03319
03320 EndSlowJob();
03321
03322 InvalidateCachedFormat();
03323 ReformatAndRedrawIfNecessary();
03324 }
03325
03326
03327
03328
03329
03330
03331
03332
03333
03334
03335
03336
03337
03338
03339
03340
03341
03342
03343
03344 BOOL FontsSGallery::PreCreate(void)
03345 {
03346
03347 if (DisplayTree == NULL)
03348 {
03349 DisplayTree = new SGDisplayRootScroll(this);
03350 if (DisplayTree == NULL)
03351 return FALSE;
03352 }
03353
03354 BOOL Sort = FALSE;
03355
03356
03357 if (InsGroup == NULL)
03358 {
03359
03360 String_64 tstr(_R(IDS_FONTS_GALLERY_INSTALLED_FONTS));
03361 InsGroup = new SGFontsGroup(this, NULL, NULL, &tstr);
03362 if (InsGroup != NULL)
03363 {
03364 InsGroup->Flags.CanSelect = TRUE;
03365
03366
03367 DisplayTree->AddItem(InsGroup);
03368
03369
03370 CreateNewSubtreeForInstalledFonts(InsGroup);
03371
03372
03373 ForceGroupFolded(InsGroup, TRUE);
03374
03375 Sort = TRUE;
03376 }
03377 }
03378
03379 PORTNOTE("other", "Disabled font libraries")
03380 #ifndef EXCLUDE_FROM_XARALX
03381
03382 if(OpenLibFiles.IsEmpty())
03383 {
03384 String_256 sLoc = DefaultLibraryPath;
03385
03386
03387 if(CResDll::GetExecutablePath((TCHAR*)DefaultLibraryPath))
03388 {
03389
03390 String_256 LibDirName;
03391 GetLibraryDirectoryName(&LibDirName);
03392 DefaultLibraryPath += "\\";
03393 DefaultLibraryPath += LibDirName;
03394 PathName ThisPath(DefaultLibraryPath);
03395 if(!SGLibOil::FileExists(&ThisPath))
03396 {
03397
03398 if(!ScanForLocation(SGLib_Font, NULL))
03399 {
03400
03401
03402 DefaultLibraryPath = sLoc;
03403 }
03404 }
03405 }
03406
03407 LibraryGallery::AddLibraryGroups(SGLib_Font, &DefaultLibraryPath);
03408 }
03409 #endif
03410
03411
03412 DisplayMode = FontsSGallery::DefaultDisplayMode;
03413
03414
03415 if(Sort)
03416 SortGallery();
03417
03418 return TRUE;
03419 }
03420
03421
03422
03423
03424
03425
03426
03427
03428
03429
03430
03431
03432
03433
03434
03435
03436
03437
03438 void FontsSGallery::SortGallery(void)
03439 {
03440
03441
03442 SortInstalledFonts();
03443 return;
03444
03445
03446 SGSortKey TmpSortKeys[MaxSGSortKeys];
03447 INT32 i;
03448 for (i = 0; i < MaxSGSortKeys; i++)
03449 TmpSortKeys[i] = SortKeys[i];
03450
03451
03452 SortKeys[0].SortKey = DefaultSortKeys & 0x7f;
03453 SortKeys[0].Reversed = (((DefaultSortKeys>>7) & 0x1) == 1);
03454 SortKeys[1].SortKey = (DefaultSortKeys>>8) & 0x7f;
03455 SortKeys[1].Reversed = (((DefaultSortKeys>>15) & 0x1) == 1);
03456
03457 ApplySortNow(TRUE);
03458
03459 for (i = 0; i < MaxSGSortKeys; i++)
03460 SortKeys[i] = TmpSortKeys[i];
03461 }
03462
03463
03464
03465
03466
03467
03468
03469
03470
03471
03472
03473
03474
03475
03476
03477
03478
03479 BOOL FontsSGallery::BrowseClicked(void)
03480 {
03481 return (LibraryGallery::BrowseClicked(&DefaultLibraryPath, SGLib_Font, _R(IDS_REMOVE_OLD_GOUPS_FONTS)));
03482 #if 0
03483 PathName ThePath(DefaultLibraryPath);
03484
03485
03486 if(SGLibOil::GetLibPath(&ThePath, GenerateIndexFile::CreateFontIndexes, SGLib_Font))
03487 {
03488 if(ThePath.IsValid())
03489 {
03490
03491 INT32 ButtonPressed = 2;
03492
03493 if(LibraryGroupsInGallery() > 0 && LibraryGallery::AskAboutRemoving)
03494 {
03495
03496 ButtonPressed = InformMessage(_R(IDS_REMOVE_OLD_GOUPS_FONTS), _R(IDS_REMOVE), _R(IDS_KEEP), _R(IDS_CANCEL));
03497 Error::ClearError();
03498
03499 if(ButtonPressed == 3)
03500 return FALSE;
03501 }
03502
03503
03504 if(CreateNewSubtreeForLibraryFonts(&ThePath, ButtonPressed == 1))
03505 {
03506
03507 DefaultLibraryPath = ThePath.GetPath();
03508 }
03509
03510
03511 SortGallery();
03512
03513 ReformatAndRedrawIfNecessary();
03514
03515 return TRUE;
03516 }
03517 }
03518 return FALSE;
03519 #endif
03520 }
03521
03522
03523
03524
03525
03526
03527
03528
03529
03530
03531
03532
03533
03534
03535
03536
03537 BOOL FontsSGallery::CanCreateIndexes(void)
03538 {
03539 return GenerateIndexFile::CreateFontIndexes;
03540 }
03541
03542
03543
03544
03545
03546
03547
03548
03549
03550
03551
03552
03553
03554
03555
03556
03557
03558
03559
03560
03561 BOOL FontsSGallery::GetDefaults(String_256 *DefaultIndex, String_256 *IndexDesc, SGLibType *Type)
03562 {
03563 if(DefaultIndex != NULL)
03564 *DefaultIndex = _R(IDS_LIBRARIES_FONTS_FILENAME);
03565
03566 if(IndexDesc != NULL)
03567 *IndexDesc = _R(IDS_LIBRARIES_FONTS_DESC);
03568
03569 if(Type != NULL)
03570 *Type = SGLib_Font;
03571
03572 return TRUE;
03573 }
03574
03575
03576
03577
03578
03579
03580
03581
03582
03583
03584
03585
03586
03587
03588
03589 BOOL FontsSGallery::GetLibraryDirectoryName(String_256 *LibDirName)
03590 {
03591 LibDirName->MakeMsg(_R(IDS_LIBRARIES_FONTS_DIRNAME));
03592 return TRUE;
03593 }
03594
03595
03596
03597
03598
03599
03600
03601
03602
03603
03604
03605
03606
03607
03608
03609 BOOL FontsSGallery::CheckForIndexMatch(StringBase *Txt)
03610 {
03611 BOOL Match = FALSE;
03612
03613
03614 if(((Txt->Sub(String_8(_T("F")))!=-1) || (Txt->Sub(String_8(_T("f")))!=-1)) ) Match = TRUE;
03615
03616 return Match;
03617 }
03618
03619
03620
03621
03622
03623
03624
03625
03626
03627
03628
03629
03630 BOOL FontsSGallery::GetQuietStatus(void)
03631 {
03632 return FontsSGallery::QuietStatus;
03633 }
03634
03635
03636
03637
03638
03639
03640
03641
03642
03643
03644
03645
03646
03647 void FontsSGallery::SetQuietStatus(BOOL Status)
03648 {
03649 FontsSGallery::QuietStatus = Status;
03650 }
03651
03652
03653
03654
03655
03656
03657
03658
03659
03660
03661
03662
03663
03664
03665
03666
03667
03668
03669
03670
03671 BOOL FontsSGallery::ScanForLocation(SGLibType Type, StringBase *Result)
03672 {
03673 #ifndef STANDALONE
03674
03675 String_256 DriveName;
03676 BOOL AreWeXara = FALSE;
03677 String_256 XaraDrive;
03678
03679 BOOL Adjust = KeyPress::IsAdjustPressed();
03680 #ifndef _DEBUG
03681 Adjust = FALSE;
03682 #endif
03683
03684 if(SGLibOil::LocateCDROMDrive(this, Type, &DriveName, &AreWeXara, &XaraDrive, Adjust))
03685 {
03686 if(AreWeXara)
03687 DriveName = XaraDrive;
03688
03689 switch(Type)
03690 {
03691 case SGLib_Font:
03692 {
03693 FontsSGallery::DefaultLibraryPath = DriveName;
03694 #ifdef _DEBUG
03695 if(Adjust)
03696 {
03697 FontsSGallery::DefaultLibraryPath += TEXT("Fonts");
03698 }
03699 else
03700 #endif
03701 {
03702 String_256 LibDirName;
03703 GetLibraryDirectoryName(&LibDirName);
03704 FontsSGallery::DefaultLibraryPath += LibDirName;
03705 }
03706
03707 if(Result)
03708 *Result = FontsSGallery::DefaultLibraryPath;
03709
03710 return TRUE;
03711 }
03712 default:
03713 break;
03714 }
03715 }
03716 #endif
03717 return FALSE;
03718 }
03719
03720
03721
03722
03723
03724
03725
03726
03727
03728
03729
03730
03731
03732
03733
03734
03735
03736
03737
03738
03739
03740
03741
03742
03743
03744 BOOL FontsSGallery::ApplyAction(SGActionType Action)
03745 {
03746
03747 if (DisplayTree == NULL)
03748 return FALSE;
03749
03750 switch(Action)
03751 {
03752 case SGACTION_APPLY:
03753 #ifndef STANDALONE
03754
03755 ApplyFont(FALSE, DisplayTree->FindNextSelectedItem(NULL));
03756 #endif
03757 break;
03758
03759 case SGACTION_DISPLAYMODECHANGED:
03760
03761 FlushBackgroundRedraws();
03762
03763 if(InsGroup != NULL)
03764 {
03765
03766
03767
03768
03769 ForceRedrawOfList();
03770 }
03771 FontsSGallery::DefaultDisplayMode = DisplayMode;
03772
03773 return OK;
03774
03775 case SGACTION_SETOPTIONS:
03776 {
03777 if (CurrentOptionsDlg == NULL)
03778 return(FALSE);
03779
03780 CurrentOptionsDlg->AddDisplayModeName(_R(IDS_GALLERYDM_LARGE));
03781 CurrentOptionsDlg->AddDisplayModeName(_R(IDS_GALLERYDM_FULLINFO));
03782 CurrentOptionsDlg->AddDisplayModeName(_R(IDS_GALLERYDM_SMALL));
03783 CurrentOptionsDlg->AddDisplayModeName(_R(IDS_GALLERYDM_ICONONLY));
03784 CurrentOptionsDlg->AddDisplayModeName(_R(IDS_GALLERYDM_TEXTONLY));
03785 }
03786 break;
03787
03788 case SGACTION_SETSORTMODE:
03789 {
03790 if (CurrentSortDlg == NULL)
03791 return(FALSE);
03792
03793 CurrentSortDlg->AddSortKeyName(_R(IDS_SORTBY_NAME));
03794 CurrentSortDlg->AddSortKeyName(_R(IDS_SORTBY_MEMORY));
03795 CurrentSortDlg->AddSortKeyName(_R(IDS_SORTBY_NAMELENGTH));
03796 CurrentSortDlg->AddSortKeyName(_R(IDS_SORTBY_FONTTYPE));
03797 }
03798 break;
03799
03800 default:
03801 return(SuperGallery::ApplyAction(Action));
03802 break;
03803 }
03804
03805 return(TRUE);
03806 }
03807
03808
03809
03810
03811
03812
03813
03814
03815
03816
03817
03818
03819
03820
03821
03822
03823
03824
03825 void FontsSGallery::ApplySortNow(BOOL ApplyToEntireList)
03826 {
03827
03828 DefaultSortKeys = ((SortKeys[0].SortKey & 0x7f))
03829 + ((SortKeys[0].Reversed & 0x1) << 7)
03830 + ((SortKeys[1].SortKey & 0x7f) << 8)
03831 + ((SortKeys[1].Reversed & 0x1) << 15);
03832
03833 SuperGallery::ApplySortNow(ApplyToEntireList);
03834 }
03835
03836
03837
03838
03839
03840
03841
03842
03843
03844
03845
03846
03847
03848
03849
03850
03851
03852
03853
03854
03855
03856
03857
03858
03859
03860
03861
03862
03863
03864
03865
03866 MsgResult FontsSGallery::Message(Msg* Message)
03867 {
03868
03869 static HANDLE handle = NULL;
03870 CString mutexName = "autorunMutex";
03871
03872
03873
03874
03875 if (DisplayTree == NULL)
03876 return(LibraryGallery::Message(Message));
03877
03878 if (IS_OUR_DIALOG_MSG(Message))
03879 {
03880 DialogMsg* Msg = (DialogMsg*)Message;
03881
03882 switch (Msg->DlgMsg)
03883 {
03884 case DIM_CREATE:
03885
03886
03887
03888
03889
03890
03891 handle = CreateMutex(NULL,TRUE,mutexName);
03892
03893
03894 SGInit::UpdateGalleryButton(_R(OPTOKEN_DISPLAYFONTSGALLERY), TRUE);
03895 GalleryAboutToReOpen();
03896 break;
03897
03898 case DIM_CANCEL:
03899
03900 if(handle != NULL)
03901 {
03902 CloseHandle(handle);
03903 }
03904
03905
03906 SGInit::UpdateGalleryButton(_R(OPTOKEN_DISPLAYFONTSGALLERY), FALSE);
03907 BROADCAST_TO_CLASS(ThumbMessage(ThumbMessage::KILLCACHE, SGLib_Font), DialogOp);
03908
03909 GalleryAboutToClose();
03910 break;
03911
03912 case DIM_LFT_BN_CLICKED:
03913 if (FALSE) {}
03914 else if ((Msg->GadgetID == _R(IDC_LIBGAL_BROWSE)) ||
03915 (Msg->GadgetID == _R(IDC_LIBGAL_ADD_FONTS)))
03916 {
03917 BrowseClicked();
03918 return OK;
03919 }
03920 else if (Msg->GadgetID == _R(IDC_LIBGAL_BROWSE))
03921 {
03922 InstallFonts(TRUE);
03923 SelectionHasChanged();
03924 return OK;
03925 }
03926 else if (Msg->GadgetID == _R(IDC_LIBGAL_DEINSTALL))
03927 {
03928 DeinstallFonts(FontsSGallery::DeleteTTFandFOTfiles);
03929 SelectionHasChanged();
03930 return OK;
03931 }
03932 else if (Msg->GadgetID == _R(IDC_GALLERY_HELP))
03933 {
03934 HelpUserTopic(_R(IDS_HELPPATH_Gallery_Font));
03935 return OK;
03936 }
03937 else if (Msg->GadgetID == _R(IDC_BMPGAL_SAVE))
03938 {
03939 #ifdef _DEBUG
03940 SGDisplayNode *Item = DisplayTree->FindNextSelectedItem(NULL);
03941 if(Item != NULL && Item->IsKindOf(CC_RUNTIME_CLASS(SGLibDisplayItem)))
03942 {
03943 SGLibDisplayItem *LibItem = (SGLibDisplayItem *)Item;
03944
03945 Library *Parent = LibItem->GetParentLibrary();
03946 if(Parent != NULL)
03947 {
03948 PathName *Source = Parent->ReturnIndexLocation();
03949 PathName Dest(*Source);
03950 Dest.SetType((String_256)"BAK");
03951 SGLibOil::FileCopy(Source, &Dest);
03952
03953 Parent->SaveIndexInDisplayedOrder(Source, FALSE);
03954 }
03955 }
03956 #endif
03957 return OK;
03958 }
03959 break;
03960
03961 case DIM_FONTCHANGE:
03962 FontsSGallery::DoFontChange();
03963 break;
03964
03965 default:
03966 break;
03967
03968 }
03969 }
03970 else if (MESSAGE_IS_A(Message, DocChangingMsg))
03971 {
03972 DocChangingMsg *Msg = (DocChangingMsg *) Message;
03973 switch (Msg->State)
03974 {
03975 case DocChangingMsg::SELCHANGED:
03976 if (Msg->pNewDoc == NULL)
03977 {
03978
03979
03980 SuperGallery::ShadeGallery(TRUE);
03981 }
03982 else
03983 {
03984
03985 SuperGallery::ShadeGallery(FALSE);
03986 SelectionHasChanged();
03987 }
03988 break;
03989
03990 default:
03991 break;
03992 }
03993 }
03994 else if (MESSAGE_IS_A(Message, ThumbMessage) && DisplayTree != NULL)
03995 {
03996 ThumbMessage *Msg = (ThumbMessage *) Message;
03997
03998
03999 if(Msg->State == ThumbMessage::CACHESIZECHANGED
04000 || Msg->State == ThumbMessage::KILLCACHE)
04001 {
04002 FlushBackgroundRedraws();
04003 ForceRedrawOfList();
04004 }
04005 }
04006
04007 return(LibraryGallery::Message(Message));
04008 }
04009
04010
04011
04012
04013
04014
04015
04016
04017
04018
04019
04020
04021
04022 void FontsSGallery::DoFontChange(void)
04023 {
04024
04025 if(ThisGallery == NULL || DontUpdate)
04026 return;
04027
04028
04029 if(ThisGallery->DisplayTree == NULL)
04030 return;
04031
04032
04033 ThisGallery->CreateNewSubtreeForInstalledFonts(InsGroup);
04034
04035
04036 ThisGallery->SortInstalledFonts();
04037
04038
04039 ThisGallery->ForceRedrawOfList();
04040 }
04041
04042
04043
04044
04045
04046
04047
04048
04049
04050
04051
04052
04053
04054
04055
04056
04057
04058
04059
04060
04061 void FontsSGallery::HandleDragStart(DragMessage *DragMsg)
04062 {
04063
04064
04065 if (DragMsg->pInfo->IsKindOf(CC_RUNTIME_CLASS(GalleryFontsDragInfo)) ||
04066 DragMsg->pInfo->IsKindOf(CC_RUNTIME_CLASS(GalleryLibFontsDragInfo)) )
04067 {
04068 SGFontsDragTarget *NewTarget = new SGFontsDragTarget(this, GetListGadgetID());
04069 }
04070 else
04071 SuperGallery::HandleDragStart(DragMsg);
04072 }
04073
04074
04075
04076
04077
04078
04079
04080
04081
04082
04083
04084
04085
04086
04087
04088
04089
04090
04091
04092
04093
04094
04095
04096
04097
04098 BOOL FontsSGallery::ApplyFont(BOOL Dropping, SGDisplayNode *TheNode, NodeRenderableInk* pObjectHit)
04099 {
04100
04101 BOOL FoundFont = FALSE;
04102
04103
04104 String_64 Desc;
04105
04106
04107 BOOL Italic = FALSE;
04108
04109
04110 INT32 Weight = FW_NORMAL;
04111
04112
04113 FontClass Type = FC_UNDEFINED;
04114
04115 if(TheNode == NULL)
04116 {
04117
04118 InformError(_R(IDS_FONTS_CANT_FIND_SELECTED_FONT), _R(IDS_OK));
04119 return FALSE;
04120 }
04121
04122 if(TheNode->IsKindOf(CC_RUNTIME_CLASS(SGTTFItem)))
04123 {
04124
04125 if(((SGTTFItem *)TheNode)->Invalid)
04126 {
04127 InformError(_R(IDS_FONTS_INVALID_APPLY));
04128 Error::ClearError();
04129 return FALSE;
04130 }
04131
04132
04133 LOGFONT *lplf = ((SGTTFItem *)TheNode)->CachedLogFont;
04134 if(lplf != NULL)
04135 {
04136 Desc = (TCHAR *)lplf->lfFaceName;
04137
04138 Italic = lplf->lfItalic;
04139 if(Italic)
04140 Italic = TRUE;
04141
04142 Weight = lplf->lfWeight;
04143
04144 FoundFont = TRUE;
04145
04146 Type = FC_TRUETYPE;
04147 }
04148 else
04149 {
04150 FoundFont = FALSE;
04151 }
04152 }
04153 else
04154 if(TheNode->IsKindOf(CC_RUNTIME_CLASS(SGATMItem)))
04155 {
04156
04157 LOGFONT *lplf = ((SGATMItem *)TheNode)->CachedLogFont;
04158 if(lplf != NULL)
04159 {
04160 Desc = (TCHAR *)lplf->lfFaceName;
04161
04162 Italic = lplf->lfItalic;
04163 if(Italic)
04164 Italic = TRUE;
04165
04166 Weight = lplf->lfWeight;
04167
04168 FoundFont = TRUE;
04169
04170 Type = FC_ATM;
04171 }
04172 else
04173 {
04174 FoundFont = FALSE;
04175 }
04176 }
04177 else
04178 {
04179 if(TheNode->IsKindOf(CC_RUNTIME_CLASS(SGLibDisplayItem)))
04180 {
04181 if(ThisGallery == NULL)
04182 {
04183 ERROR3("Can't find the font gallery to install a font to");
04184 return FALSE;
04185 }
04186
04187
04188 FontClass Class = ((SGLibFontItem *)TheNode)->GetType();
04189 if(Class == FC_ATM)
04190 {
04191 if(!OILFontMan::IsOkToCall(FC_ATM))
04192 {
04193 InformWarning(_R(IDS_ATM_NOT_RUNNING), _R(IDS_OK));
04194 Error::ClearError();
04195 return FALSE;
04196 }
04197 }
04198
04199
04200 String_256 Desc256;
04201 ((SGLibFontItem *)TheNode)->GetNameText(&Desc256);
04202
04203 FoundFont = IsFontAlreadyInstalled(&Desc256, ((SGLibFontItem *)TheNode)->GetType());
04204 Desc = (String_64)Desc256;
04205
04206
04207 if(!FoundFont)
04208 FoundFont = InstallDraggedLibFont(ThisGallery, (SGLibDisplayItem *)TheNode, &Desc);
04209
04210 if(FoundFont)
04211 {
04212
04213 LOGFONT *lplf = NULL;
04214 BOOL FoundLogFont = FindLogFont(&Desc256, &lplf, ((SGLibFontItem *)TheNode)->GetType());
04215
04216 if(lplf != NULL)
04217 {
04218
04219 Desc = (TCHAR *)lplf->lfFaceName;
04220
04221 Italic = lplf->lfItalic;
04222 if(Italic)
04223 Italic = TRUE;
04224
04225 Weight = lplf->lfWeight;
04226
04227 Type = ((SGLibFontItem *)TheNode)->GetType();
04228 }
04229 else
04230 {
04231 FoundFont = FALSE;
04232 }
04233 }
04234 }
04235 else
04236 {
04237 ERROR3("It's not a library font and it's not an installed font ! What is it ???");
04238 FoundFont = FALSE;
04239 }
04240 }
04241
04242 #ifndef STANDALONE
04243
04244 if(FoundFont)
04245 {
04246
04247 if ( FONTMANAGER->CacheNamedFont(&Desc, Type) != ILLEGALFHANDLE )
04248 {
04249
04250 AttrTxtFontTypeface *TypeFaceAttrib = new AttrTxtFontTypeface;
04251 if(TypeFaceAttrib != NULL)
04252 {
04253 TypeFaceAttrib->Value.HTypeface = FONTMANAGER->GetFontHandle(&Desc, Type);
04254
04255
04256 TypeFaceAttrib->SetBold(FALSE);
04257 TypeFaceAttrib->SetItalic(FALSE);
04258 }
04259
04260 AttrTxtBold* BoldAttrib = new AttrTxtBold;
04261 if (BoldAttrib)
04262 BoldAttrib->Value.BoldOn = (Weight > FW_MEDIUM);
04263
04264 AttrTxtItalic* ItalicAttrib = new AttrTxtItalic;
04265 if (ItalicAttrib)
04266 ItalicAttrib->Value.ItalicOn = Italic;
04267
04268 if(Dropping)
04269 {
04270
04271
04272 if (TypeFaceAttrib != NULL)
04273 AttributeManager::ApplyAttribToNode(pObjectHit, (NodeAttribute *)TypeFaceAttrib);
04274
04275 if (BoldAttrib != NULL)
04276 AttributeManager::ApplyAttribToNode(pObjectHit, (NodeAttribute *)BoldAttrib);
04277
04278 if (ItalicAttrib != NULL)
04279 AttributeManager::ApplyAttribToNode(pObjectHit, (NodeAttribute *)ItalicAttrib);
04280 }
04281 else
04282 {
04283
04284
04285
04286
04287 List AttrList;
04288 NodeAttributePtrItem* pItem;
04289 if (TypeFaceAttrib)
04290 {
04291 pItem = new NodeAttributePtrItem;
04292 if (pItem)
04293 {
04294 pItem->NodeAttribPtr = TypeFaceAttrib;
04295 AttrList.AddHead(pItem);
04296 }
04297 }
04298 if (BoldAttrib)
04299 {
04300 pItem = new NodeAttributePtrItem;
04301 if (pItem)
04302 {
04303 pItem->NodeAttribPtr = BoldAttrib;
04304 AttrList.AddHead(pItem);
04305 }
04306 }
04307 if (ItalicAttrib)
04308 {
04309 pItem = new NodeAttributePtrItem;
04310 if (pItem)
04311 {
04312 pItem->NodeAttribPtr = ItalicAttrib;
04313 AttrList.AddHead(pItem);
04314 }
04315 }
04316
04317 if (!AttrList.IsEmpty())
04318 AttributeManager::AttributesSelected(AttrList, _R(IDS_FONTAPPLY_UNDO));
04319
04320
04321 NodeAttributePtrItem* pAttrItem = (NodeAttributePtrItem*)AttrList.GetHead();
04322 while (pAttrItem)
04323 {
04324 delete (pAttrItem->NodeAttribPtr);
04325 pAttrItem->NodeAttribPtr = NULL;
04326 pAttrItem = (NodeAttributePtrItem*)AttrList.GetNext(pAttrItem);
04327 }
04328 AttrList.DeleteAll();
04329 }
04330
04331
04332 TextInfoBarOp::Update();
04333 }
04334 }
04335 #endif
04336
04337 return FoundFont;
04338 }
04339
04340
04341
04342
04343
04344
04345
04346
04347
04348
04349
04350
04351
04352
04353
04354
04355
04356
04357
04358
04359 BOOL FontsSGallery::InstallFonts(BOOL Copy)
04360 {
04361 if (DisplayTree == NULL)
04362 {
04363 ERROR3("FontsSGallery::InstallFonts No display tree - bad !");
04364 return FALSE;
04365 }
04366
04367
04368
04369 SGDisplayNode *Item = DisplayTree->FindNextSelectedItem(NULL);
04370 BOOL InstalledFonts = FALSE;
04371
04372 INT32 ButtonPressed = 0;
04373
04374
04375 DontUpdate = TRUE;
04376
04377 INT32 SelectedFontCount = LibraryFontsSelected();
04378 BOOL WarnedThatATMIsntPresent = FALSE;
04379 BOOL ATMInstalled = OILFontMan::IsOkToCall(FC_ATM);
04380
04381 while (Item != NULL && ButtonPressed != 4)
04382 {
04383 if(Item->IsKindOf(CC_RUNTIME_CLASS(SGLibFontItem)))
04384 {
04385 if(Item->Flags.Selected)
04386 {
04387 SGLibDisplayItem *FontItem = (SGLibDisplayItem *) Item;
04388 PathName FileName;
04389 BOOL ok = FontItem->GetFileName(&FileName);
04390
04391 if(ok)
04392 {
04393 String_256 Desc;
04394 ok = FontItem->GetDisplayedTextDescription(&Desc);
04395
04396 if(ok)
04397 {
04398
04399
04400 String_8 Ending;
04401 Ending += FileName.GetType();
04402 Ending.toLower();
04403 BOOL ThisFontIsATM = (Ending.Sub((String_8)_T("pfb")) != -1);
04404
04405 if(ThisFontIsATM && !ATMInstalled && !WarnedThatATMIsntPresent)
04406 {
04407 InformWarning(_R(IDS_ATM_NOT_RUNNING), _R(IDS_OK));
04408 Error::ClearError();
04409 WarnedThatATMIsntPresent = TRUE;
04410 }
04411
04412 if(!ThisFontIsATM || ATMInstalled)
04413 {
04414 if(ButtonPressed != 2)
04415 {
04416
04417 String_256 WarnMsg;
04418
04419
04420
04421 String_256 ProperDisplayName;
04422 FontItem->GetNameText(&ProperDisplayName);
04423
04424 WarnMsg.MakeMsg(_R(IDS_FONTS_GALLERY_SURE_INSTALL), (TCHAR *)ProperDisplayName);
04425 Error::SetError(0, WarnMsg, 0);
04426 if(SelectedFontCount > 1)
04427 ButtonPressed = InformWarning(0, _R(IDS_INSTALL), _R(IDS_ALL_SELECTED) , _R(IDS_SKIP), _R(IDS_CANCEL));
04428 else
04429 {
04430 ButtonPressed = InformWarning(0, _R(IDS_INSTALL), _R(IDS_CANCEL));
04431
04432
04433
04434 if(ButtonPressed == 2) ButtonPressed = 4;
04435 }
04436 Error::ClearError();
04437 }
04438
04439 if (ButtonPressed == 1 || ButtonPressed == 2)
04440 {
04441
04442 Library* pFontLib = FontItem->GetParentLibrary();
04443 if (!pFontLib)
04444 {
04445 ERROR3("Illegal NULL pointer");
04446 return FALSE;
04447 }
04448 if (pFontLib->IsWebLibrary())
04449 {
04450 String_256 strFileURL = FileName.GetPath(FALSE);
04451 pFontLib->LocalPath2URL(&strFileURL);
04452 OpDescriptor* pOpDesc = OpDescriptor::FindOpDescriptor(CC_RUNTIME_CLASS(OpAsynchFontInstall));
04453 if (pOpDesc != NULL)
04454 {
04455 WebFontInstallParam* Param = new WebFontInstallParam;
04456 ERROR2IF(!Param, FALSE, "Memory allocation error");
04457
04458 Param->type = TYPE_FONT;
04459 Param->priority = AsynchDownload::PRIORITY_HIGH;
04460 Param->pGallery = this;
04461 Param->file = FileName;
04462 FontItem->GetDisplayedTextDescription(&Param->strDescription);
04463 FontItem->GetNameText(&Param->strAltDescription);
04464 Param->strURL = strFileURL;
04465 Param->bIsTemp = FALSE;
04466 Param->Output = &ok;
04467
04468 pOpDesc->Invoke((OpParam*) Param);
04469 }
04470 else
04471 {
04472 ERROR3("Can't find Op descriptor");
04473 }
04474 }
04475 else
04476 {
04477 String_64 SlowJob;
04478 SlowJob.MakeMsg(_R(IDS_FONTS_INSTALLING), (TCHAR *)Desc);
04479 BeginSlowJob(-1, FALSE, &SlowJob);
04480 ok = InstallFont(&FileName, &Desc, FALSE);
04481 InstalledFonts = TRUE;
04482 EndSlowJob();
04483 }
04484 }
04485 }
04486 }
04487
04488 if(!ok)
04489 {
04490
04491 String_256 ErrMsg;
04492 ErrMsg.MakeMsg(_R(IDS_PROBLEMS_INSTALLING), (TCHAR *)Desc);
04493 Error::SetError(0, ErrMsg, 0);
04494 InformError();
04495 Error::ClearError();
04496 }
04497 }
04498 else
04499 {
04500 GetLastError();
04501 ERROR3("FontsSGallery::InstallFonts Error getting library filename");
04502 }
04503 }
04504 }
04505
04506 Item = SGDisplayRoot::FindNextItemInTree(Item);
04507 }
04508
04509
04510 DontUpdate = FALSE;
04511
04512 if (InstalledFonts)
04513 {
04514
04515 SendMessage(HWND_BROADCAST, WM_FONTCHANGE, 0, 0);
04516 }
04517 return TRUE;
04518 }
04519
04520
04521
04522
04523
04524
04525
04526
04527
04528
04529
04530
04531
04532
04533
04534
04535
04536
04537
04538
04539
04540
04541 BOOL FontsSGallery::DeinstallFonts(BOOL Delete)
04542 {
04543 TRACEUSER( "Richard", _T("Deinstall Font\n"));
04544
04545 if(InsGroup == NULL)
04546 {
04547 ERROR3("No installed fonts group detected");
04548 return FALSE;
04549 }
04550
04551
04552 INT32 ButtonPressed = 0;
04553 BOOL DeinstalledFonts = FALSE;
04554 SGDisplayPreviewFonts *Selected = NULL;
04555
04556
04557 DontUpdate = TRUE;
04558
04559 if (InsGroup != NULL)
04560 Selected = (SGDisplayPreviewFonts *) InsGroup->FindNextSelectedItem(NULL);
04561
04562 INT32 SelectedFontCount = InsGroup->GetSelectedItemCount();
04563
04564 while (Selected != NULL && ButtonPressed != 4)
04565 {
04566 String_256 Desc(Selected->FontDescription);
04567
04568
04569 if(Selected->Type == FC_TRUETYPE)
04570 Desc += String_16(_R(IDS_FONTS_SPACE_TRUETYPE));
04571
04572
04573
04574 if(Selected->IsFontBeingUsed())
04575 {
04576 String_256 WarnMsg;
04577 WarnMsg.MakeMsg(_R(IDS_DEINSTALL_FONT_IN_USE), (TCHAR *)Selected->FontDescription);
04578 Error::SetError(0, WarnMsg, 0);
04579 INT32 Button = InformWarning(0, _R(IDS_DEINSTALL), _R(IDS_SKIP), _R(IDS_CANCEL));
04580 Error::ClearError();
04581
04582
04583 if(Button == 1 && ButtonPressed != 2) ButtonPressed = 1;
04584
04585
04586 if(Button == 2) ButtonPressed = 3;
04587
04588
04589 if(Button == 3) ButtonPressed = 4;
04590 }
04591 else
04592 {
04593 if(ButtonPressed != 2)
04594 {
04595
04596 String_256 WarnMsg;
04597 WarnMsg.MakeMsg(_R(IDS_FONTS_GALLERY_SURE_DEINSTALL), (TCHAR *)Selected->FontDescription);
04598 Error::SetError(0, WarnMsg, 0);
04599
04600 if(SelectedFontCount > 1)
04601 ButtonPressed = InformWarning(0, _R(IDS_DEINSTALL), _R(IDS_ALL_SELECTED) , _R(IDS_SKIP), _R(IDS_CANCEL));
04602 else
04603 {
04604 ButtonPressed = InformWarning(0, _R(IDS_DEINSTALL), _R(IDS_CANCEL));
04605
04606
04607
04608 if(ButtonPressed == 2) ButtonPressed = 4;
04609 }
04610
04611 Error::ClearError();
04612 }
04613 }
04614
04615 if (ButtonPressed == 1 || ButtonPressed == 2)
04616 {
04617 String_64 SlowJob;
04618 SlowJob.MakeMsg(_R(IDS_FONTS_DEINSTALLING), (TCHAR *)Desc);
04619 BeginSlowJob(-1, FALSE, &SlowJob);
04620
04621 if(DeinstallFont(&Desc, Delete, Selected->CachedLogFont))
04622 {
04623 DeinstalledFonts = TRUE;
04624
04625
04626
04627 if(SelectedFontCount > 1)
04628 {
04629 MonotonicTime PauseClock;
04630 while ( !PauseClock.Elapsed( 800 ) ) ;
04631 }
04632 }
04633 EndSlowJob();
04634 }
04635 Selected = (SGDisplayPreviewFonts *) InsGroup->FindNextSelectedItem(Selected);
04636 }
04637
04638
04639 DontUpdate = FALSE;
04640
04641 if (DeinstalledFonts)
04642 {
04643
04644 SendMessage(HWND_BROADCAST, WM_FONTCHANGE, 0, 0);
04645 }
04646 return TRUE;
04647 }
04648
04649
04650
04651
04652
04653
04654
04655
04656
04657
04658
04659
04660
04661
04662
04663
04664
04665
04666
04667
04668
04669
04670
04671
04672
04673
04674
04675
04676
04677
04678 BOOL FontsSGallery::InstallFont(PathName *FontFile, String_256 *Description, BOOL Temp)
04679 {
04680 ERROR3IF(!DontUpdate, "If you're calling install font or deinstall font, you MUST set DontUpdate to TRUE beforehand !");
04681 if(!DontUpdate) return FALSE;
04682
04683 String_8 Ending;
04684 Ending += FontFile->GetType();
04685 Ending.toLower();
04686
04687 if(Ending.Sub((String_8)_T("ttf")) != -1)
04688 {
04689 if(FontsSGallery::IsFontAlreadyInstalled(Description, FC_ATM))
04690 {
04691 InformError(_R(IDS_FONTS_INSTALL_TTF_SAME_NAME));
04692 Error::ClearError();
04693 }
04694 else
04695 {
04696 if (InstallTTFFont(FontFile, Description, Temp))
04697 {
04698 return TRUE;
04699 }
04700 else
04701 {
04702 return FALSE;
04703 }
04704 }
04705 }
04706
04707 if(Ending.Sub((String_8)_T("pfb")) != -1)
04708 {
04709 String_256 Result(*Description);
04710
04711
04712 FontsSGallery::MakeBoldItalicReadable(&Result);
04713
04714
04715
04716
04717
04718
04719
04720
04721
04722
04723
04724
04725 if(FontsSGallery::IsFontAlreadyInstalled(&Result, FC_TRUETYPE))
04726 {
04727 InformError(_R(IDS_FONTS_INSTALL_ATM_SAME_NAME));
04728 Error::ClearError();
04729 }
04730 else
04731 {
04732 if (ATMInstall::InstallFont(FontFile, Description, Temp))
04733 {
04734 return TRUE;
04735 }
04736 else
04737 {
04738 return FALSE;
04739 }
04740 }
04741 }
04742
04743 return FALSE;
04744 }
04745
04746
04747
04748
04749
04750
04751
04752
04753
04754
04755
04756
04757
04758
04759
04760
04761
04762
04763
04764
04765
04766
04767
04768
04769
04770
04771
04772
04773
04774
04775
04776
04777
04778
04779
04780
04781
04782 BOOL FontsSGallery::DeinstallFont(String_256 *FontDesc, BOOL Delete, LOGFONT *LogFnt)
04783 {
04784 ERROR3IF(!DontUpdate, "If you're calling install font or deinstall font, you MUST set DontUpdate to TRUE beforehand !");
04785 if(!DontUpdate) return FALSE;
04786
04787 if(FontDesc->Sub(String_16(_R(IDS_FONTS_SPACE_TRUETYPE))) != -1)
04788 {
04789 if (DeinstallTTFFont(FontDesc, Delete))
04790 {
04791 return TRUE;
04792 }
04793 else
04794 {
04795 return FALSE;
04796 }
04797 }
04798 else
04799 {
04800 if (ATMInstall::DeinstallFont(FontDesc, TRUE, LogFnt))
04801 {
04802 return TRUE;
04803 }
04804 else
04805 {
04806 return FALSE;
04807 }
04808 }
04809 return FALSE;
04810 }
04811
04812
04813
04814
04815
04816
04817
04818
04819
04820
04821
04822
04823
04824
04825 BOOL FontsSGallery::UseWin95FontInstallMethod()
04826 {
04827 return CCamApp::IsNewWindowsUI();
04828 }
04829
04830
04831
04832
04833
04834
04835
04836
04837
04838
04839
04840
04841
04842
04843
04844
04845
04846
04847
04848
04849
04850
04851
04852
04853
04854
04855
04856
04857
04858
04859
04860
04861
04862
04863
04864
04865 BOOL FontsSGallery::InstallTTFFont(PathName *FontFile, String_256 *Description, BOOL Temp)
04866 {
04867 ERROR3IF(FontFile == NULL || Description == NULL, "FontsSGallery::InstallTTFFont null params are bad");
04868 ERROR3IF(!FontFile->IsValid(), "FontsSGallery::InstallTTFFont FontFile is invalid");
04869 ERROR3IF(!DontUpdate, "If you're calling install font or deinstall font, you MUST set DontUpdate to TRUE beforehand !");
04870 if(FontFile == NULL || Description == NULL || !FontFile->IsValid() || !DontUpdate)
04871 return FALSE;
04872
04873
04874
04875
04876 String_256 FontDir;
04877
04878 if(!GetWindowsFontDirectory(&FontDir))
04879 {
04880 GetLastError();
04881 ERROR3("FontsSGallery::InstallTTFFont Problems getting the system dir");
04882 return FALSE;
04883 }
04884
04885 BOOL ok = TRUE;
04886 PathName LibTTFPath(*FontFile);
04887
04888 String_256 SysTTF(FontDir);
04889 SGLibOil::AppendSlashIfNotPresent(&SysTTF);
04890 SysTTF += LibTTFPath.GetFileName();
04891 PathName TTFPath(SysTTF);
04892
04893 PathName FOTPath(TTFPath);
04894 FOTPath.SetType((String_256)"FOT");
04895
04896 String_256 KeyName(*Description);
04897 KeyName += String_16(_R(IDS_FONTS_SPACE_TRUETYPE));
04898
04899
04900
04901
04902
04903
04904
04905
04906 if(!SGLibOil::FileExists(&TTFPath))
04907 {
04908 if(!SGLibOil::FileCopy(&LibTTFPath, &TTFPath))
04909 {
04910 ERROR3("FontsSGallery::InstallTTFFont Failed to copy TTF file into system directory");
04911 return FALSE;
04912 }
04913 }
04914
04915
04916
04917
04918 if(UseWin95FontInstallMethod())
04919 {
04920
04921
04922 if(!AddFontResource((const TCHAR *)TTFPath.GetFileName()))
04923 {
04924 DWORD f = GetLastError();
04925 ERROR3_PF(("FontsSGallery::InstllTTFFont Couldn't AddFontResource (W95) - %d", f));
04926 return FALSE;
04927 }
04928
04929
04930 ok = SetFOTNameInRegistry(&KeyName, &TTFPath);
04931
04932 if(!ok)
04933 ERROR3("FontsSGallery::InstallTTFFont setting win95 registry failed");
04934 }
04935 else
04936 {
04937
04938 if(!SGLibOil::FileExists(&FOTPath))
04939 {
04940
04941 String_256 TheFontDir(FontDir);
04942 SGLibOil::AppendSlashIfNotPresent(&TheFontDir);
04943
04944
04945 String_256 FOTStr(FOTPath.GetPath());
04946 String_256 TTFStr(TTFPath.GetFileName());
04947
04948 if(!CreateScalableFontResource(0,
04949 (TCHAR *)FOTStr,
04950 (TCHAR *)TTFStr,
04951 (TCHAR *)TheFontDir))
04952 {
04953 DWORD f = GetLastError();
04954 ERROR3_PF(("FontsSGallery::InstallTTFFont Couldn't create scalablefontresource - %d", f));
04955 return FALSE;
04956 }
04957 }
04958
04959
04960
04961 if(!AddFontResource((const TCHAR *)FOTPath.GetFileName()))
04962 {
04963 DWORD f = GetLastError();
04964 ERROR3("FontsSGallery::InstallTTFFont Couldn't AddFontResource");
04965 return FALSE;
04966 }
04967
04968
04969
04970
04971 ok = SetFOTNameInRegistry(&KeyName, &FOTPath);
04972 }
04973
04974 if(ok)
04975 {
04976
04977 SendMessage(HWND_BROADCAST, WM_WININICHANGE, 0, (LPARAM) (LPCTSTR)"Fonts");
04978
04979
04980
04981 SendMessage(HWND_BROADCAST, WM_FONTCHANGE, 0, 0);
04982 }
04983 else
04984 {
04985 ERROR3("FontsSGallery::InstallTTFFont problems setting registry entries");
04986 return FALSE;
04987 }
04988
04989
04990 return TRUE;
04991 }
04992
04993
04994
04995
04996
04997
04998
04999
05000
05001
05002
05003
05004
05005
05006
05007
05008
05009
05010
05011
05012
05013
05014
05015
05016
05017
05018
05019
05020
05021
05022
05023
05024
05025
05026 BOOL FontsSGallery::DeinstallTTFFont(String_256 *FontDesc, BOOL Delete)
05027 {
05028 ERROR3IF(FontDesc == NULL, "FontsSGallery::DeinstallTTFFont FontDesc == NULL");
05029 ERROR3IF(DontUpdate == FALSE, "FontsSGallery::DeinstallTTFFont called with TRUE DontUpdate");
05030
05031 if(!DontUpdate || FontDesc == NULL) return FALSE;
05032
05033 PathName FOTFile;
05034 BOOL ok = GetFOTNameFromRegistry(FontDesc, &FOTFile);
05035
05036 if(ok)
05037 {
05038
05039
05040
05041
05042
05043
05044
05045
05046
05047
05048
05049
05050
05051
05052
05053
05054
05055
05056
05057
05058 ok = RemoveFontResource((const TCHAR *)FOTFile.GetFileName());
05059
05060 #ifdef _DEBUG
05061 String_256 GLErrMsgF;
05062
05063 if(!ok)
05064 {
05065 GetLastError();
05066 camSprintf(GLErrMsgF,
05067 TEXT("Problems with remove font resource (file) - GetLastError returned %d '%s'"),
05068 LastErr, (const TCHAR *)FOTFile.GetPath());
05069 }
05070 #endif
05071
05072 BOOL ok2 = RemoveFontResource((const TCHAR *)FOTFile.GetPath());
05073
05074 if(!ok && !ok2)
05075 {
05076 #ifdef _DEBUG
05077
05078 GetLastError();
05079 String_256 GLErrMsgP;
05080 camSprintf(GLErrMsgP,
05081 TEXT("Problems with remove font resource (path) - GetLastError returned %d '%s'"),
05082 LastErr, (const TCHAR *)FOTFile.GetPath());
05083 ERROR3((TCHAR*) GLErrMsgF);
05084 ERROR3((TCHAR*) GLErrMsgP);
05085 #endif
05086 }
05087
05088
05089 if(!ok && ok2)
05090 ok = TRUE;
05091
05092 if(ok)
05093 {
05094
05095 ok = SetFOTNameInRegistry(FontDesc, NULL);
05096
05097 if(ok && Delete)
05098 {
05099
05100 if(!UseWin95FontInstallMethod())
05101 SGLibOil::FileDelete(&FOTFile);
05102
05103 if(FOTFile.SetType("TTF"))
05104 SGLibOil::FileDelete(&FOTFile);
05105 }
05106
05107
05108 SendMessage(HWND_BROADCAST, WM_WININICHANGE, 0, (LPARAM) (LPCTSTR)"Fonts");
05109 }
05110
05111
05112 SendMessage(HWND_BROADCAST, WM_FONTCHANGE, 0, 0);
05113 }
05114
05115 if(!ok)
05116 {
05117
05118 String_256 ErrMsg;
05119 ErrMsg.MakeMsg(_R(IDS_PROBLEMS_DEINSTALLING), (TCHAR *)*FontDesc);
05120 Error::SetError(0, ErrMsg, 0);
05121 InformError();
05122 Error::ClearError();
05123 }
05124
05125 return ok;
05126 }
05127
05128
05129
05130
05131
05132
05133
05134
05135
05136
05137
05138
05139
05140
05141
05142
05143
05144
05145
05146
05147
05148
05149
05150 BOOL FontsSGallery::InstallDraggedLibFont(FontsSGallery *FontGallery, SGLibDisplayItem *FontItem, String_64 *Desc)
05151 {
05152 BOOL ok = TRUE;
05153
05154 if(ThisGallery == NULL || FontItem == NULL || Desc == NULL)
05155 {
05156 ERROR3("FontsSGallery::InstallDraggedLibFont - null params are BAD !!!");
05157 return FALSE;
05158 }
05159
05160
05161 FontClass Class = ((SGLibFontItem *)FontItem)->GetType();
05162 if(Class == FC_ATM)
05163 {
05164 if(!OILFontMan::IsOkToCall(FC_ATM))
05165 {
05166 if(!WarnAboutMultipleATMDragging)
05167 {
05168 InformWarning(_R(IDS_ATM_NOT_RUNNING), _R(IDS_OK));
05169 Error::ClearError();
05170 WarnAboutMultipleATMDragging = TRUE;
05171 }
05172 return FALSE;
05173 }
05174 }
05175
05176 *Desc = (String_64)_T("");
05177
05178 #ifdef STOP_WINDOWS95_FONT_INSTALLS
05179 if(IsWin32c())
05180 {
05181 ERROR3("Still problems installing on win95");
05182 return FALSE;
05183 }
05184 #endif
05185
05186 String_256 OurDesc;
05187
05188
05189 if(FontItem->IsKindOf(CC_RUNTIME_CLASS(SGLibFontItem)))
05190 ((SGLibFontItem *)FontItem)->GetNameText(&OurDesc);
05191 else
05192 {
05193 if(!FontItem->GetDisplayedTextDescription(&OurDesc))
05194 return FALSE;
05195 }
05196
05197 if(OurDesc.Length() == 0)
05198 return FALSE;
05199
05200 if(IsFontAlreadyInstalled(&OurDesc, ((SGLibFontItem *)FontItem)->GetType()))
05201 {
05202
05203 *Desc = (String_64)OurDesc;
05204 return TRUE;
05205 }
05206
05207 PathName FileName;
05208 ok = (FontItem->GetFileName(&FileName));
05209
05210 if(ok)
05211 {
05212
05213 String_256 WarnMsg;
05214 WarnMsg.MakeMsg(_R(IDS_FONTS_GALLERY_SURE_INSTALL), (TCHAR *)OurDesc);
05215 Error::SetError(0, WarnMsg, 0);
05216 INT32 ButtonPressed = InformWarning(0, _R(IDS_INSTALL), _R(IDS_CANCEL));
05217 Error::ClearError();
05218
05219
05220 if (ButtonPressed == 1)
05221 {
05222
05223 Library* pFontLib = FontItem->GetParentLibrary();
05224 if (!pFontLib)
05225 {
05226 ERROR3("Illegal NULL pointer");
05227 return FALSE;
05228 }
05229 if (pFontLib->IsWebLibrary())
05230 {
05231 String_256 strFileURL = FileName.GetPath(FALSE);
05232 pFontLib->LocalPath2URL(&strFileURL);
05233 OpDescriptor* pOpDesc = OpDescriptor::FindOpDescriptor(CC_RUNTIME_CLASS(OpAsynchFontInstall));
05234 if (pOpDesc != NULL)
05235 {
05236 WebFontInstallParam* Param = new WebFontInstallParam;
05237 ERROR2IF(!Param, FALSE, "Memory allocation error");
05238
05239 Param->type = TYPE_FONT;
05240 Param->priority = AsynchDownload::PRIORITY_HIGH;
05241 Param->pGallery = FontGallery;
05242 Param->file = FileName;
05243 FontItem->GetDisplayedTextDescription(&Param->strDescription);
05244 FontItem->GetNameText(&Param->strAltDescription);
05245 Param->strURL = strFileURL;
05246 Param->bIsTemp = FALSE;
05247 Param->Output = &ok;
05248
05249 pOpDesc->Invoke((OpParam*) Param);
05250 }
05251 else
05252 {
05253 ERROR3("Can't find Op descriptor");
05254 }
05255 }
05256 else
05257 {
05258
05259 String_64 SlowJob;
05260 SlowJob.MakeMsg(_R(IDS_FONTS_INSTALLING), (TCHAR *)OurDesc);
05261 BeginSlowJob(-1, FALSE, &SlowJob);
05262 DontUpdate = TRUE;
05263
05264 String_256 ProperName;
05265 FontItem->GetDisplayedTextDescription(&ProperName);
05266 ok = ThisGallery->InstallFont(&FileName, &ProperName, FALSE);
05267
05268 DontUpdate = FALSE;
05269 EndSlowJob();
05270 if (ok)
05271 SendMessage(HWND_BROADCAST, WM_FONTCHANGE, 0, 0);
05272 }
05273 if(!ok)
05274 {
05275
05276 String_256 ErrMsg;
05277 ErrMsg.MakeMsg(_R(IDS_PROBLEMS_INSTALLING), (TCHAR *)OurDesc);
05278 Error::SetError(0, ErrMsg, 0);
05279 InformError();
05280 Error::ClearError();
05281 }
05282 }
05283 }
05284
05285
05286 *Desc = (String_64)OurDesc;
05287
05288 return ok;
05289 }
05290
05291
05292
05293
05294
05295
05296
05297
05298
05299
05300
05301
05302
05303
05304
05305
05306
05307
05308
05309
05310
05311
05312 BOOL FontsSGallery::FindLogFont(String_256 *FontDesc, LOGFONT **lplplf, FontClass Class)
05313 {
05314 if(FontDesc == NULL || lplplf == NULL)
05315 {
05316 ERROR3("FontsSGallery::FindLogFont given null params");
05317 return FALSE;
05318 }
05319
05320 if(InsGroup == NULL)
05321 {
05322 ERROR3("You don't seem to have an installed font group. This is rather bad !");
05323 return FALSE;
05324 }
05325
05326 *lplplf = NULL;
05327
05328
05329 SGDisplayNode *Item = InsGroup->GetChild();
05330
05331
05332 String_256 ItemName;
05333
05334
05335 String_256 FontDescLower(*FontDesc);
05336 FontDescLower.toLower();
05337
05338
05339 while (Item != NULL)
05340 {
05341
05342 if(Item->IsKindOf(CC_RUNTIME_CLASS(SGDisplayPreviewFonts)))
05343 {
05344 SGDisplayPreviewFonts *FontItem = (SGDisplayPreviewFonts *) Item;
05345
05346 if((Class == FontItem->Type) || (Class == FC_UNDEFINED))
05347 {
05348
05349 FontItem->GetNameText(&ItemName);
05350 ItemName.toLower();
05351
05352
05353 if(ItemName == FontDescLower)
05354 {
05355 *lplplf = FontItem->CachedLogFont;
05356 return TRUE;
05357 }
05358 }
05359 }
05360
05361
05362 Item = Item->GetNext();
05363 }
05364
05365 return FALSE;
05366 }
05367
05368
05369
05370
05371
05372
05373
05374
05375
05376
05377
05378
05379
05380
05381
05382
05383
05384
05385
05386
05387
05388 BOOL FontsSGallery::IsFontAlreadyInstalled(String_256 *FontDesc, FontClass Class)
05389 {
05390 LOGFONT *lplf = NULL;
05391 return FindLogFont(FontDesc, &lplf, Class);
05392 }
05393
05394
05395
05396
05397
05398
05399
05400
05401
05402
05403
05404
05405
05406
05407
05408 void FontsSGallery::WorkOutSectionName(String_256 *Section)
05409 {
05410 if(Section)
05411 Section->MakeMsg(_R(IDS_FONTS_GALLERY));
05412 }
05413
05414
05415
05416
05417
05418
05419
05420
05421
05422
05423
05424
05425
05426
05427
05428
05429
05430
05431
05432
05433
05434
05435
05436
05437 BOOL FontsSGallery::GetWindowsFontDirectory(String_256* Result)
05438 {
05439 if (Result == NULL)
05440 {
05441 ERROR3("FontsSGallery::GetWindowsFontDirectory given a NULL string to return to");
05442 return FALSE;
05443 }
05444
05445 String_256 WindowsDir;
05446 String_256 FontDir;
05447
05448 BOOL RecognisedWindows = FALSE;
05449
05450 *Result = TEXT("");
05451
05452 if (GetWindowsDirectory((TCHAR*) WindowsDir, 255) != 0)
05453 {
05454 if (IsWindows31())
05455 {
05456 camSprintf((TCHAR*) FontDir, TEXT("%s\\System"), (LPCTSTR) WindowsDir);
05457 RecognisedWindows = TRUE;
05458 }
05459
05460 if (UseWin95FontInstallMethod())
05461 {
05462 camSprintf((TCHAR*) FontDir, TEXT("%s\\Fonts"), (LPCTSTR) WindowsDir);
05463 RecognisedWindows = TRUE;
05464 }
05465
05466 if (!UseWin95FontInstallMethod() && IsWindowsNT())
05467 {
05468 camSprintf((TCHAR*) FontDir, TEXT("%s\\System"), (LPCTSTR) WindowsDir);
05469 RecognisedWindows = TRUE;
05470 }
05471 }
05472
05473 if (RecognisedWindows)
05474 {
05475 *Result = FontDir;
05476 return TRUE;
05477 }
05478
05479 return FALSE;
05480 }
05481
05482
05483
05484
05485
05486
05487
05488
05489
05490
05491
05492
05493
05494
05495
05496
05497
05498
05499
05500
05501
05502
05503
05504
05505
05506
05507
05508
05509
05510
05511
05512
05513
05514
05515
05516
05517
05518 BOOL FontsSGallery::GetFOTNameFromRegistry(String_256 *Desc, PathName *FOTFile)
05519 {
05520 if (Desc == NULL || FOTFile == NULL)
05521 {
05522 ERROR3("FontsSGallery::GetFOTNameFromRegistry given NULL params - bad !");
05523 return FALSE;
05524 }
05525
05526 String_256 Description(*Desc);
05527 String_256 FOTBuf(TEXT(""));
05528
05529 BOOL ok = FALSE;
05530
05531
05532 if (IsWindows31())
05533 {
05534 String_8 Fonts(TEXT("Fonts"));
05535 String_32 Default(TEXT(""));
05536 ok = GetProfileString((TCHAR *)Fonts, (TCHAR *)Description, (TCHAR *)Default, (TCHAR *)FOTBuf, 256);
05537 }
05538
05539
05540 if (IsWindows95() || IsWindowsNT())
05541 {
05542 String_256 Value(TEXT(""));
05543 DWORD Length = 255;
05544 HKEY KeyHandle = 0;
05545 DWORD dwType = 0;
05546 INT32 lResult = ERROR_SUCCESS;
05547
05548 String_256 FontKey;
05549 ok = GetFontsKey(&FontKey);
05550
05551 if (ok)
05552 {
05553
05554 lResult = RegOpenKeyEx(HKEY_LOCAL_MACHINE, (TCHAR *)FontKey, 0, KEY_READ, &KeyHandle);
05555 if (lResult != ERROR_SUCCESS)
05556 {
05557 ERROR3("FontsSGallery::GetFOTNameFromRegistry had a problem with the registry - 1");
05558 return FALSE;
05559 }
05560
05561
05562 lResult = RegQueryValueEx(KeyHandle, (TCHAR *)Description, NULL,
05563 &dwType, (unsigned char *)((TCHAR *)Value), &Length);
05564 if (lResult != ERROR_SUCCESS)
05565 {
05566 ERROR3("FontsSGallery::GetFOTNameFromRegistry had a problem with the registry - 3");
05567 return FALSE;
05568 }
05569
05570 FOTBuf = Value;
05571 ok = TRUE;
05572 }
05573 }
05574
05575 if (ok)
05576 {
05577
05578 PathName FOTBufPath(FOTBuf);
05579 ok = FOTBufPath.IsValid();
05580
05581
05582 String_256 Location(FOTBufPath.GetLocation());
05583 if(Location.Length() != 0)
05584 {
05585 TRACEUSER( "Richard", _T("Registry contained entire path for fot file -> %s\n"), (LPCTSTR) FOTBuf);
05586 ok = FOTFile->SetPathName(FOTBuf);
05587 if (ok) ok = FOTFile->IsValid();
05588 return ok;
05589 }
05590
05591
05592 String_256 FontDir;
05593 ok = GetWindowsFontDirectory(&FontDir);
05594
05595 if (ok)
05596 {
05597 String_256 SysTTF;
05598 camSprintf((TCHAR*) SysTTF, TEXT("%s\\%s"),
05599 (LPCTSTR) FontDir, (LPCTSTR) FOTBufPath.GetFileName());
05600 ok = FOTFile->SetPathName(SysTTF);
05601 if (ok) ok = FOTFile->IsValid();
05602 }
05603 }
05604 return ok;
05605 }
05606
05607
05608
05609
05610
05611
05612
05613
05614
05615
05616
05617
05618
05619
05620
05621
05622
05623
05624
05625
05626
05627
05628 BOOL FontsSGallery::SetFOTNameInRegistry(String_256 *Desc, PathName *FOTFile)
05629 {
05630 if(Desc == NULL)
05631 {
05632 ERROR3("FontsSGallery::GetFOTNameFromRegistry given NULL params - bad !");
05633 return FALSE;
05634 }
05635
05636 BOOL ok = FALSE;
05637
05638 String_256 Description(*Desc);
05639
05640
05641 if(IsWindows31())
05642 {
05643 if(FOTFile == NULL)
05644 ok = WriteProfileString((TCHAR *)"Fonts", (TCHAR *)Description, NULL);
05645 else
05646 ok = WriteProfileString((TCHAR *)"Fonts", (TCHAR *)Description, (const TCHAR *)FOTFile->GetFileName(TRUE));
05647 }
05648
05649
05650 if(IsWindows95() || IsWindowsNT())
05651 {
05652 HKEY KeyHandle = 0;
05653 INT32 lResult = ERROR_SUCCESS;
05654
05655 String_256 FontKey;
05656 ok = GetFontsKey(&FontKey);
05657
05658 if(ok)
05659 {
05660
05661 lResult = RegOpenKeyEx(HKEY_LOCAL_MACHINE, (TCHAR *)FontKey, 0, KEY_ALL_ACCESS, &KeyHandle);
05662 if(lResult != ERROR_SUCCESS)
05663 {
05664 ERROR3("FontsSGallery::SetFOTNameInRegistry had a problem with the registry - 1");
05665 if(FOTFile != NULL)
05666 {
05667 ERROR3_PF(("Show these to Richard: (Ins) FontKey = %s, lResult = %d, Fotpath = %s",(TCHAR *)FontKey, lResult, (const TCHAR *)FOTFile->GetPath()));
05668 }
05669 else
05670 {
05671 ERROR3_PF(("Show these to Richard: (Del) FontKey = %s, lResult = %d, Desc = %s",(TCHAR *)FontKey, lResult, (TCHAR *)Description));
05672 }
05673 return FALSE;
05674 }
05675
05676 if(FOTFile == NULL)
05677 {
05678
05679 lResult = RegDeleteValue(KeyHandle, (TCHAR *)Description);
05680
05681 if(lResult != ERROR_SUCCESS)
05682 {
05683 ERROR3("FontsSGallery::SetFOTNameInRegistry had a problem deleting the font key in the registry");
05684 return FALSE;
05685 }
05686
05687 ok = TRUE;
05688 }
05689 else
05690 {
05691
05692 String_256 Value;
05693
05694
05695 if(IsWindows95())
05696 Value = (const TCHAR *)FOTFile->GetPath();
05697 else
05698 Value = (const TCHAR *)FOTFile->GetFileName(TRUE);
05699
05700
05701 lResult = RegSetValueEx(
05702 KeyHandle,
05703 (TCHAR *)Description,
05704 NULL,
05705 REG_SZ,
05706 (CONST BYTE *) ((TCHAR *)Value),
05707 (DWORD) Value.Length()+1
05708 );
05709
05710 if(lResult != ERROR_SUCCESS)
05711 {
05712 ERROR3("FontsSGallery::SetFOTNameInRegistry had a problem writing to the registry");
05713 return FALSE;
05714 }
05715
05716
05717 ok = (RegFlushKey(KeyHandle) == ERROR_SUCCESS);
05718 }
05719 }
05720 }
05721 return ok;
05722 }
05723
05724
05725
05726
05727
05728
05729
05730
05731
05732
05733
05734
05735
05736
05737
05738
05739
05740
05741 BOOL FontsSGallery::GetFontsKey(String_256 *Key)
05742 {
05743 *Key = (TCHAR *)"";
05744
05745 if(IsWindowsNT())
05746 {
05747 *Key = TEXT("Software\\Microsoft\\Windows NT\\CurrentVersion\\Fonts");
05748 return TRUE;
05749 }
05750
05751 if(IsWindows95())
05752 {
05753 *Key = TEXT("Software\\Microsoft\\Windows\\CurrentVersion\\Fonts");
05754 return TRUE;
05755 }
05756
05757 return FALSE;
05758 }
05759
05760
05761
05762
05763
05764
05765
05766
05767
05768
05769
05770
05771
05772
05773
05774 void FontsSGallery::SelectionHasChanged(void)
05775 {
05776 if (DisplayTree == NULL)
05777 return;
05778
05779
05780
05781
05782 if (!IsVisible())
05783 return;
05784
05785 #ifdef STOP_WINDOWS95_FONT_INSTALLS
05786
05787 EnableGadget(_R(IDC_GALLERY_INSTALL), (LibraryFontsSelected() > 0) && !IsWin32c());
05788
05789
05790 EnableGadget(_R(IDC_GALLERY_DEINSTALL), InstalledFontsSelected() && !IsWin32c());
05791 #else
05792
05793 EnableGadget(_R(IDC_GALLERY_INSTALL), (LibraryFontsSelected() > 0));
05794
05795
05796 EnableGadget(_R(IDC_GALLERY_DEINSTALL), InstalledFontsSelected());
05797 #endif
05798
05799 #ifdef STANDALONE
05800
05801 EnableGadget(_R(IDC_GALLERY_APPLY), FALSE);
05802 #else
05803
05804 SGLibFontItem* pItem = (SGLibFontItem*) DisplayTree->FindNextSelectedItem(NULL);
05805 if (pItem)
05806 {
05807 String_256 Desc256;
05808 pItem->GetNameText(&Desc256);
05809 if (!IsFontAlreadyInstalled(&Desc256, pItem->GetType()) && pItem->GetParentLibrary() && pItem->GetParentLibrary()->IsWebLibrary())
05810 SetStringGadgetValue(_R(IDC_GALLERY_APPLY), _R(IDS_SGMENU_DOWNLOAD));
05811 else
05812 SetStringGadgetValue(_R(IDC_GALLERY_APPLY), _R(IDS_SGMENU_APPLY));
05813 }
05814 EnableGadget(_R(IDC_GALLERY_APPLY), (DisplayTree->GetSelectedItemCount() == 1) && Document::GetSelected() != NULL);
05815 #endif
05816
05817 EnableGadget(_R(IDC_LIBGAL_ADD_FONTS), TRUE);
05818
05819
05820 LibraryGallery::SelectionHasChanged();
05821 }
05822
05823
05824
05825
05826
05827
05828
05829
05830
05831
05832
05833
05834
05835
05836
05837
05838
05839 void FontsSGallery::DoShadeGallery(BOOL ShadeIt)
05840 {
05841 if (DisplayTree == NULL)
05842 return;
05843
05844
05845 SelectionHasChanged();
05846
05847 if(ShadeIt)
05848 {
05849 EnableGadget(_R(IDC_GALLERY_APPLY), FALSE);
05850 }
05851
05852 EnableGadget(_R(IDC_LIBGAL_ADD_FONTS), TRUE);
05853
05854
05855 LibraryGallery::DoShadeGallery(ShadeIt);
05856 }
05857
05858
05859
05860
05861
05862
05863
05864
05865
05866
05867
05868
05869
05870
05871
05872 BOOL FontsSGallery::InstalledFontsSelected(void)
05873 {
05874 if(InsGroup == NULL)
05875 {
05876 ERROR3("No installed fonts group detected");
05877 return FALSE;
05878 }
05879
05880 SGDisplayPreviewFonts *Selected = NULL;
05881
05882 if (InsGroup != NULL)
05883 Selected = (SGDisplayPreviewFonts *) InsGroup->FindNextSelectedItem(NULL);
05884
05885
05886 return (Selected != NULL);
05887 }
05888
05889
05890
05891
05892
05893
05894
05895
05896
05897
05898
05899
05900
05901
05902
05903
05904 INT32 FontsSGallery::LibraryFontsSelected(void)
05905 {
05906 if (DisplayTree == NULL)
05907 {
05908 ERROR3("FontsSGallery::LibraryFontsSelected No display tree - bad !");
05909 return 0;
05910 }
05911
05912 INT32 Count = 0;
05913
05914 SGDisplayNode *Item = DisplayTree->FindNextSelectedItem(NULL);
05915
05916 while (Item != NULL)
05917 {
05918 if(Item->IsKindOf(CC_RUNTIME_CLASS(SGLibFontItem)))
05919 {
05920
05921 if(Item->Flags.Selected)
05922 Count ++;
05923 }
05924
05925 Item = SGDisplayRoot::FindNextItemInTree(Item);
05926 }
05927
05928 return Count;
05929 }
05930
05931
05932
05933
05934
05935
05936
05937
05938
05939
05940
05941
05942
05943
05944
05945 BOOL FontsSGallery::CanSearchKeywords(void)
05946 {
05947 return(FALSE);
05948 }
05949
05950
05951
05952
05953
05954
05955
05956
05957
05958
05959
05960
05961
05962
05963
05964
05965
05966
05967
05968
05969
05970
05971
05972
05973
05974
05975 INT32 FontsSGallery::GetDragFontOffset(KernelBitmap *Bmp)
05976 {
05977 if(Bmp == NULL || Bmp->ActualBitmap == NULL)
05978 return 0;
05979
05980 BitmapInfo TmpInfo;
05981 Bmp->ActualBitmap->GetInfo(&TmpInfo);
05982
05983 INT32 XSize = TmpInfo.PixelWidth;
05984 INT32 YSize = TmpInfo.PixelHeight;
05985 INT32 BPP = TmpInfo.PixelDepth;
05986 INT32 LargestXFound = 0;
05987
05988 if(BPP == 8 && XSize > 0 && YSize > 0)
05989 {
05990 for(INT32 y = 0; y < YSize; y++)
05991 {
05992 for(INT32 x = LargestXFound; x < XSize; x++)
05993 {
05994 PixelGreyscale Pixel = Bmp->ReadPixelGreyscale(x, y);
05995
05996 if(Pixel < 250)
05997 LargestXFound = x;
05998 }
05999 }
06000 }
06001
06002 if(LargestXFound == 0)
06003 return 0;
06004 else
06005 {
06006
06007 return ((XSize / 2) - (LargestXFound / 2));
06008 }
06009 }
06010
06011
06012
06013
06014
06015
06016
06017
06018
06019
06020
06021
06022
06023
06024
06025
06026
06027
06028
06029
06030
06031
06032
06033
06034
06035
06036
06037
06038 SGDisplayGroup *FontsSGallery::AddLibraryGroup(Library *LibraryToDisplay, INT32 NumItems)
06039 {
06040 ERROR3IF(LibraryToDisplay == NULL, "FontsSGallery::AddLibraryGroup - NULL parameter is illegal");
06041
06042 if (DisplayTree == NULL)
06043 {
06044 ERROR3("FontsSGallery::AddLibraryGroup called before the DisplayTree was initialised!");
06045 return(NULL);
06046 }
06047
06048 SGLibGroup *TheGroup = (SGLibGroup *)DisplayTree->FindSubtree(this, NULL, LibraryToDisplay);
06049
06050 if (TheGroup == NULL)
06051 {
06052
06053 TheGroup = new SGLibGroup(this, NULL, LibraryToDisplay);
06054
06055 if (TheGroup == NULL)
06056 return(NULL);
06057
06058
06059 DisplayTree->AddItem(TheGroup);
06060 }
06061 else
06062 TheGroup->DestroySubtree(FALSE);
06063
06064 return(TheGroup);
06065 }
06066
06067
06068
06069
06070
06071
06072
06073
06074
06075
06076
06077
06078
06079
06080
06081
06082
06083
06084
06085
06086
06087
06088
06089
06090
06091
06092
06093
06094
06095
06096
06097
06098
06099
06100
06101
06102
06103
06104
06105
06106
06107 SGDisplayItem *FontsSGallery::CopyDisplayItem(SGDisplayItem *SourceItem,
06108 SGDisplayGroup *DestGroup, SGDisplayItem *TargetPosition)
06109 {
06110 if(SourceItem == NULL || DestGroup == NULL)
06111 {
06112 ERROR3("FontsSGallery::CopyDisplayItem -> Illegal NULL param");
06113 return NULL;
06114 }
06115
06116 if(DestGroup->IsKindOf(CC_RUNTIME_CLASS(SGFontsGroup)))
06117 {
06118 if(SourceItem->IsKindOf(CC_RUNTIME_CLASS(SGLibFontItem)))
06119 {
06120
06121 String_64 Desc;
06122 FontsSGallery::InstallDraggedLibFont(FontsSGallery::ThisGallery, (SGLibDisplayItem *)SourceItem, &Desc);
06123 TRACEUSER( "Richard", _T("%s installed\n"), (TCHAR *)Desc);
06124 }
06125 else
06126 {
06127
06128 }
06129 }
06130
06131 if(DestGroup->IsKindOf(CC_RUNTIME_CLASS(SGLibGroup)))
06132 {
06133 if(SourceItem->IsKindOf(CC_RUNTIME_CLASS(SGLibFontItem)))
06134 {
06135
06136 SGDisplayNode *SourceGroup = SourceItem->GetParent();
06137 if((SGDisplayGroup *)SourceGroup != DestGroup)
06138 {
06139
06140 FontsSGallery::WarnAboutSectionDragging = TRUE;
06141
06142
06143 }
06144 }
06145 else
06146 {
06147
06148 }
06149 }
06150
06151 return(NULL);
06152 }
06153
06154
06155
06156
06157
06158
06159
06160
06161
06162
06163
06164
06165
06166
06167
06168 void FontsSGallery::AllItemsCopied(SGDisplayGroup *DestGroup)
06169 {
06170
06171 if(WarnAboutSectionDragging)
06172 InformWarning(_R(IDS_FONTS_BETWEEN_GROUPS));
06173
06174 WarnAboutMultipleATMDragging = FALSE;
06175 WarnAboutSectionDragging = FALSE;
06176 }
06177
06178
06179
06180
06181
06182
06183
06184
06185
06186
06187
06188
06189
06190
06191
06192
06193
06194 void FontsSGallery::MakeBoldItalicReadable(String_256 *Desc)
06195 {
06196
06197 if(Desc->Sub(String_8(_R(IDS_FONTS_ATM_EFFECT_SEPARATOR))) != -1)
06198 {
06199 String_256 TmpResult(*Desc);
06200 TmpResult.Left(Desc, TmpResult.Sub(String_8(_R(IDS_FONTS_ATM_EFFECT_SEPARATOR))));
06201
06202 if(TmpResult.Sub(String_16(_R(IDS_FONTS_CAPITAL_BOLD))) != -1)
06203 *Desc += String_16(_R(IDS_FONTS_SPACE_BOLD));
06204
06205 if(TmpResult.Sub(String_16(_R(IDS_FONTS_CAPITAL_ITALIC))) != -1)
06206 *Desc += String_16(_R(IDS_FONTS_SPACE_ITALIC));
06207 }
06208 }
06209
06210
06211
06212
06213
06214
06215
06216
06217
06218
06219
06220
06221
06222
06223
06224
06225
06226
06227
06228
06229
06230
06231
06232
06233 BOOL OpDisplayFontsGallery::Init()
06234 {
06235
06236 return (RegisterOpDescriptor(
06237 0,
06238 _R(IDS_DISPLAY_FONTS_GALLERY),
06239 CC_RUNTIME_CLASS(OpDisplayFontsGallery),
06240 OPTOKEN_DISPLAYFONTSGALLERY,
06241 OpDisplayFontsGallery::GetState,
06242 0,
06243 _R(IDBBL_DISPLAY_FONTS_GALLERY),
06244 0 ));
06245
06246
06247
06248 }
06249
06250
06251
06252
06253
06254
06255
06256
06257
06258
06259
06260
06261
06262
06263
06264
06265 OpState OpDisplayFontsGallery::GetState(String_256* UIDescription, OpDescriptor*)
06266 {
06267 OpState OpSt;
06268
06269
06270 SuperGallery* pSuperGallery = SuperGallery::FindSuperGallery(_R(IDD_FONTSGALLERY));
06271
06272 if (pSuperGallery != NULL)
06273 {
06274 if (pSuperGallery->GetRuntimeClass() == CC_RUNTIME_CLASS(FontsSGallery))
06275 OpSt.Ticked = pSuperGallery->IsVisible();
06276 }
06277
06278 return(OpSt);
06279 }
06280
06281
06282
06283
06284
06285
06286
06287
06288
06289
06290
06291
06292
06293
06294
06295
06296 void OpDisplayFontsGallery::Do(OpDescriptor*)
06297 {
06298 SuperGallery* pSuperGallery = SuperGallery::FindSuperGallery(_R(IDD_FONTSGALLERY));
06299
06300 if (pSuperGallery != NULL)
06301 {
06302
06303 pSuperGallery->SetVisibility( !pSuperGallery->IsVisible() );
06304
06305
06306 SGInit::UpdateGalleryButton(_R(OPTOKEN_DISPLAYFONTSGALLERY), pSuperGallery->IsVisible());
06307
06308
06309 if(pSuperGallery->IsVisible() == FALSE)
06310 {
06311 BROADCAST_TO_CLASS(ThumbMessage(ThumbMessage::KILLCACHE, SGLib_Font), DialogOp);
06312
06313
06314 if(FontsSGallery::ThisGallery != NULL)
06315 {
06316 FontsSGallery::ThisGallery->GalleryAboutToClose();
06317 }
06318 }
06319 }
06320
06321 End();
06322 }
06323
06324
06325
06326
06327
06328
06329
06330
06331
06332
06333
06334
06335
06336
06337
06338
06339
06340 SGLibFontItem::SGLibFontItem(LibraryIndex LibraryIndexToDisplay, BOOL bNew) :
06341 SGLibDisplayItem(LibraryIndexToDisplay, bNew)
06342 {
06343 }
06344
06345
06346
06347 SGLibFontItem::SGLibFontItem()
06348 {
06349 }
06350
06351 SGLibFontItem::~SGLibFontItem()
06352 {
06353 }
06354
06355
06356
06357
06358
06359
06360
06361
06362
06363
06364
06365
06366
06367
06368
06369
06370
06371
06372
06373 LibDisplayType SGLibFontItem::GetDisplayType(SGMiscInfo *MiscInfo)
06374 {
06375
06376 return SGDisplayPreviewFonts::GetDisplayType(MiscInfo);
06377 }
06378
06379
06380
06381
06382
06383
06384
06385
06386
06387
06388
06389
06390
06391
06392
06393
06394
06395
06396
06397 void SGLibFontItem::GetNameText(String_256 *Result)
06398 {
06399 GetDisplayedTextDescription(Result);
06400
06401
06402 FontsSGallery::MakeBoldItalicReadable(Result);
06403
06404
06405
06406
06407
06408
06409
06410
06411
06412
06413
06414 }
06415
06416
06417
06418
06419
06420
06421
06422
06423
06424
06425
06426
06427
06428
06429
06430
06431
06432
06433
06434
06435 BOOL SGLibFontItem::GetNameTextPtr(TCHAR **Result)
06436 {
06437 ERROR3IF(Result == NULL, "SGLibDisplayItem::GetNameText given a NULL param");
06438
06439
06440 Library *Lib = GetParentLibrary();
06441
06442 if (Lib != NULL)
06443 return (Lib->GetTextname(TheLibraryIndex, Result));
06444
06445 return FALSE;
06446 }
06447
06448
06449
06450
06451
06452
06453
06454
06455
06456
06457
06458
06459
06460
06461
06462
06463
06464
06465
06466
06467
06468 void SGLibFontItem::GetFullInfoText(String_256* Result)
06469 {
06470 *Result = TEXT("");
06471
06472
06473 Library* Lib = GetParentLibrary();
06474
06475 if (Lib != NULL)
06476 {
06477 String_256 ItemPath;
06478 Lib->GetFilename(TheLibraryIndex, &ItemPath, FALSE);
06479 INT32 FileSize = GetFileSize(NULL);
06480
06481 String_256 Desc;
06482 GetDisplayedTextDescription(&Desc);
06483
06484
06485 FontsSGallery::MakeBoldItalicReadable(&Desc);
06486
06487
06488
06489
06490
06491
06492
06493
06494
06495
06496
06497
06498 String_32 FileLength;
06499 BOOL FileSizeOK = FALSE;
06500 if(FileSize != 0)
06501 {
06502 FileSizeOK = Convert::BytesToString(&FileLength, (UINT32)FileSize);
06503 }
06504
06505 if(FileSizeOK)
06506 {
06507
06508 Result->MakeMsg(_R(IDS_SGFONTS_FULLINFO1), (LPCTSTR) Desc, (LPCTSTR) ItemPath, (LPCTSTR) FileLength);
06509 }
06510 else
06511 {
06512
06513 Result->MakeMsg(_R(IDS_SGFONTS_FULLINFO2), (LPCTSTR) Desc, (LPCTSTR) ItemPath);
06514 }
06515 }
06516 }
06517
06518
06519
06520
06521
06522
06523
06524
06525
06526
06527
06528
06529
06530
06531
06532
06533
06534
06535 UINT32 SGLibFontItem::GetFontID(void)
06536 {
06537
06538 Library *Lib = GetParentLibrary();
06539
06540 if (Lib != NULL)
06541 return(Lib->GetID(TheLibraryIndex));
06542
06543 return 0;
06544 }
06545
06546
06547
06548
06549
06550
06551
06552
06553
06554
06555
06556
06557
06558
06559
06560
06561
06562 INT32 SGLibFontItem::GetTextWidth(SGFormatInfo *FormatInfo, SGMiscInfo *MiscInfo)
06563 {
06564 INT32 XSize = SG_InfiniteWidth;
06565 INT32 OnePixel = (INT32) DevicePixels(MiscInfo, 1);
06566
06567
06568 LibDisplayType DType = GetDisplayType(MiscInfo);
06569
06570
06571 switch(DType)
06572 {
06573 case LibDisplay_SmallThumbTextUnder:
06574 case LibDisplay_MediumThumbTextUnder:
06575 case LibDisplay_LargeThumbTextUnder:
06576
06577 XSize = (SGF_SURROUND * OnePixel * 2);
06578 break;
06579
06580 case LibDisplay_SmallThumb:
06581 case LibDisplay_MediumThumb:
06582 case LibDisplay_LargeThumb:
06583
06584 XSize = (SGF_SURROUND * OnePixel * 2);
06585 break;
06586
06587 case LibDisplay_SmallThumbText:
06588 case LibDisplay_MediumThumbText:
06589 case LibDisplay_LargeThumbText:
06590 XSize = (INT32)((float) SG_DefaultNameText * 1.1);
06591 break;
06592
06593 case LibDisplay_JustText:
06594
06595 XSize = GridLock(MiscInfo, SG_DefaultNameText);
06596 break;
06597
06598 case LibDisplay_SingleLineFullInfo:
06599 default:
06600
06601 XSize = (INT32)((float) SG_DefaultNameText * 2);
06602
06603 break;
06604 }
06605
06606
06607 XSize = GridLock(MiscInfo, XSize);
06608
06609 return XSize;
06610 }
06611
06612
06613
06614
06615
06616
06617
06618
06619
06620
06621
06622
06623
06624
06625
06626
06627
06628
06629
06630
06631
06632
06633
06634
06635
06636
06637
06638
06639
06640
06641
06642
06643
06644
06645
06646
06647
06648
06649
06650
06651
06652
06653
06654
06655
06656
06657
06658
06659 BOOL SGLibFontItem::HandleEvent(SGEventType EventType, void *EventInfo,
06660 SGMiscInfo *MiscInfo)
06661 {
06662 switch (EventType)
06663 {
06664 case SGEVENT_MOUSECLICK:
06665 {
06666 SGMouseInfo *Mouse = GetMouseInfo(EventType, EventInfo);
06667
06668 if (FormatRect.ContainsCoord(Mouse->Position))
06669 {
06670 if(Mouse->DoubleClick)
06671 DefaultClickHandler(Mouse, MiscInfo);
06672 else
06673 {
06674 DefaultPreDragHandler(Mouse, MiscInfo);
06675 GalleryLibFontsDragInfo *DragFont;
06676
06677
06678 KernelBitmap *DispBmp = GetDisplayedKernelBitmap(MiscInfo, TRUE);
06679 if(DispBmp)
06680 {
06681 LibraryGallery::TmpDraggingBitmap = DIBUtil::CopyKernelBitmap(DispBmp, TRUE);
06682 DragFont = new GalleryLibFontsDragInfo(this, Mouse, MiscInfo,
06683 Mouse->MenuClick, 0, 0);
06684 }
06685 else
06686 {
06687
06688 LibraryGallery::TmpDraggingBitmap = NULL;
06689
06690
06691 UINT32 XSize = SG_InfiniteWidth;
06692 UINT32 YSize = SG_DefaultLargeIcon;
06693 INT32 DisplayMode = MiscInfo->DisplayMode;
06694 SGDisplayPreviewFonts::GetThumbnailDetails(DisplayMode, &XSize, &YSize, NULL);
06695
06696 if(XSize == 0 || YSize == 0)
06697 {
06698 XSize = SGF_SMALL_X;
06699 YSize = SGF_SMALL_Y;
06700 }
06701
06702
06703 DragFont = new GalleryLibFontsDragInfo(this, Mouse, MiscInfo,
06704 Mouse->MenuClick, XSize, YSize);
06705 }
06706
06707 if (DragFont != NULL)
06708 DragManagerOp::StartDrag(DragFont, GetListWindow());
06709 }
06710 return TRUE;
06711 }
06712 }
06713 break;
06714
06715 default:
06716 return(SGLibDisplayItem::HandleEvent(EventType, EventInfo, MiscInfo));
06717 break;
06718 }
06719
06720
06721 return FALSE;
06722 }
06723
06724
06725
06726
06727
06728
06729
06730
06731
06732
06733
06734
06735
06736
06737
06738
06739
06740
06741
06742
06743
06744
06745
06746
06747
06748
06749
06750
06751
06752
06753
06754
06755 void SGLibFontItem::MoveAfter(SGDisplayNode *NodeToMove)
06756 {
06757 SGDisplayNode::MoveAfter(NodeToMove);
06758 }
06759
06760
06761
06762
06763
06764
06765
06766
06767
06768
06769
06770
06771
06772
06773
06774
06775
06776
06777
06778
06779
06780
06781
06782
06783
06784
06785
06786
06787
06788
06789
06790
06791
06792
06793 void SGLibFontItem::MoveBefore(SGDisplayNode *NodeToMove)
06794 {
06795 SGDisplayNode::MoveBefore(NodeToMove);
06796 }
06797
06798
06799
06800
06801
06802
06803
06804
06805
06806
06807
06808
06809
06810
06811
06812
06813
06814
06815
06816
06817
06818
06819
06820
06821
06822
06823
06824
06825
06826
06827 BOOL SGLibFontItem::GetBubbleHelp(DocCoord *MousePos, String_256 *Result)
06828 {
06829 ERROR3IF(MousePos == NULL || Result == NULL, "Invalid NULL params");
06830
06831 GetNameText(Result);
06832
06833 return(TRUE);
06834 }
06835
06836
06837
06838
06839
06840
06841
06842
06843
06844
06845
06846
06847
06848
06849
06850
06851
06852
06853
06854
06855
06856
06857
06858
06859
06860
06861
06862
06863
06864
06865 BOOL SGLibFontItem::GetStatusLineHelp(DocCoord *MousePos, String_256 *Result)
06866 {
06867 ERROR3IF(MousePos == NULL || Result == NULL, "Invalid NULL params");
06868
06869 String_256 FontName;
06870 GetNameText(&FontName);
06871
06872
06873 Result->MakeMsg(_R(IDS_FONTS_DEINSTALLED_STATUS), (TCHAR *)FontName);
06874
06875 return(TRUE);
06876 }
06877
06878
06879
06880
06881
06882
06883
06884
06885
06886
06887
06888
06889
06890
06891
06892
06893
06894
06895
06896
06897
06898
06899
06900 void SGLibFontItem::CalculateMyRect(SGFormatInfo *FormatInfo, SGMiscInfo *MiscInfo)
06901 {
06902
06903 LibDisplayType DType = GetDisplayType(MiscInfo);
06904 INT32 OnePixel = (INT32) DevicePixels(MiscInfo, 1);
06905 Library *ParentLib = GetParentLibrary();
06906
06907 INT32 XSize = GetTextWidth(FormatInfo, MiscInfo);
06908 INT32 YSize = 0;
06909
06910
06911 YSize = GridLock(MiscInfo, YSize);
06912
06913
06914 YSize += (3 * 2 * OnePixel);
06915
06916
06917 switch(DType)
06918 {
06919 case LibDisplay_MediumThumb:
06920 YSize += GridLock(MiscInfo, ParentLib->PreviewBMPHeight(SGThumb_Medium) * OnePixel);
06921 XSize += GridLock(MiscInfo, (ParentLib->PreviewBMPWidth(SGThumb_Medium) * OnePixel) + (SGF_TYPE_WIDTH * OnePixel));
06922 break;
06923
06924 default:
06925 SGLibDisplayItem::CalculateMyRect(FormatInfo, MiscInfo);
06926 return;
06927
06928 }
06929
06930
06931 CalculateFormatRect(FormatInfo, MiscInfo, XSize, YSize);
06932 }
06933
06934
06935
06936
06937
06938
06939
06940
06941
06942
06943
06944
06945
06946
06947
06948
06949
06950
06951
06952
06953
06954 void SGLibFontItem::HandleRedraw(SGRedrawInfo *RedrawInfo, SGMiscInfo *MiscInfo)
06955 {
06956
06957 StartRendering(RedrawInfo, MiscInfo);
06958
06959
06960 Library *ParentLib = GetParentLibrary();
06961
06962
06963 StartRendering(RedrawInfo, MiscInfo);
06964
06965 RenderRegion *Renderer = RedrawInfo->Renderer;
06966 INT32 OnePixel = (INT32) DevicePixels(MiscInfo, 1);
06967 INT32 TwoPixels = (INT32) DevicePixels(MiscInfo, 2);
06968
06969 Renderer->SetLineWidth(0);
06970 Renderer->SetLineColour(RedrawInfo->Transparent);
06971
06972
06973 DocRect NewFormatRect(FormatRect);
06974
06975
06976 NewFormatRect.lo.x += (SGF_TYPE_WIDTH * OnePixel);
06977 GridLockRect(MiscInfo, &NewFormatRect);
06978
06979 DocRect TypeRect(FormatRect);
06980 TypeRect.hi.x = NewFormatRect.lo.x;
06981
06982 SGDisplayPreviewFonts::DrawTypeIcon(RedrawInfo, MiscInfo, &TypeRect, GetType());
06983
06984
06985 DocRect BmpRect(NewFormatRect);
06986 DocRect UnscaledRect(NewFormatRect);
06987
06988 LibDisplayType DType = GetDisplayType(MiscInfo);
06989
06990 if(DType == LibDisplay_JustText)
06991 BmpRect.hi.x = BmpRect.lo.x + OnePixel;
06992 else
06993 {
06994 INT32 XSize = 0;
06995
06996 switch(DType)
06997 {
06998 case LibDisplay_MediumThumbTextUnder:
06999 case LibDisplay_MediumThumbText:
07000 case LibDisplay_MediumThumb:
07001 case LibDisplay_FullInfo:
07002 case LibDisplay_SingleLineFullInfo:
07003 XSize = ParentLib->PreviewBMPWidth(SGThumb_Medium);
07004 break;
07005
07006 case LibDisplay_SmallThumbText:
07007 case LibDisplay_SmallThumbTextUnder:
07008 case LibDisplay_SmallThumb:
07009 XSize = ParentLib->PreviewBMPWidth(SGThumb_Small);
07010 break;
07011
07012 case LibDisplay_Default:
07013 case LibDisplay_LargeThumbText:
07014 case LibDisplay_LargeThumb:
07015 case LibDisplay_LargeThumbTextUnder:
07016 default:
07017
07018 XSize = ParentLib->PreviewBMPWidth(SGThumb_Large);
07019 break;
07020 }
07021
07022
07023 XSize *= OnePixel;
07024
07025
07026 BmpRect.hi.x = BmpRect.lo.x + XSize + (6 * OnePixel);
07027
07028
07029 BmpRect.Inflate(-(TwoPixels+OnePixel));
07030
07031
07032 GridLockRect(MiscInfo, &BmpRect);
07033
07034
07035 if (Flags.Selected)
07036 {
07037 if(BmpRect.hi.x > UnscaledRect.hi.x) BmpRect.hi.x = UnscaledRect.hi.x;
07038
07039 BmpRect.Inflate(TwoPixels+OnePixel);
07040 GridLockRect(MiscInfo, &BmpRect);
07041 DrawSelectionOutline(RedrawInfo, MiscInfo, &BmpRect);
07042
07043 BmpRect.Inflate(-(TwoPixels+OnePixel));
07044 }
07045
07046 DrawItemThumbnail(RedrawInfo, MiscInfo, &BmpRect);
07047 }
07048
07049 DrawItemText(Renderer, RedrawInfo, MiscInfo, &UnscaledRect, &BmpRect, Flags.Selected);
07050
07051
07052 StopRendering(RedrawInfo, MiscInfo);
07053 }
07054
07055
07056
07057
07058
07059
07060
07061
07062
07063
07064
07065
07066
07067
07068
07069
07070
07071
07072
07073
07074
07075
07076
07077
07078
07079
07080
07081
07082
07083
07084
07085
07086
07087 INT32 SGLibFontItem::CompareTo(SGDisplayNode *Other, INT32 SortKey)
07088 {
07089 return(SGLibDisplayItem::CompareTo(Other, SortKey));
07090 }
07091
07092
07093
07094
07095
07096
07097
07098
07099
07100
07101
07102
07103
07104
07105
07106
07107
07108
07109 BOOL SGLibFontItem::GetThumbFileName(String_256* path)
07110 {
07111 PathName filePath;
07112 GetFileName(&filePath);
07113 Library* pLibrary = GetParentLibrary();
07114 if (!pLibrary)
07115 {
07116 ERROR3("Ilegal NULL pointer!");
07117 return FALSE;
07118 }
07119 if (!pLibrary->IsWebLibrary())
07120 {
07121 ERROR3("This function should only be called for web folders");
07122 return FALSE;
07123 }
07124 PathName indexPath(*(pLibrary->ReturnIndexLocation()));
07125 String_256 thumbPath(indexPath.GetLocation());
07126 String_32 strFilename;
07127 TCHAR tchType = _T('F');
07128 TCHAR tchSize;
07129 LibDisplayType DType;
07130 SGThumbSize Size = SGThumb_Large;
07131 SuperGallery* pGallery = GetParentGallery();
07132 if (!pGallery)
07133 {
07134 ERROR3("Ilegal NULL pointer!");
07135 return FALSE;
07136 }
07137 switch (pGallery->GetDisplayMode())
07138 {
07139 case 4:
07140 DType = LibDisplay_JustText;
07141 break;
07142 case 3:
07143 DType = LibDisplay_MediumThumb;
07144 break;
07145 case 2:
07146 DType = LibDisplay_SmallThumbText;
07147 break;
07148 case 1:
07149 DType = LibDisplay_SingleLineFullInfo;
07150 break;
07151 case 0:
07152 default:
07153 DType = LibDisplay_LargeThumbText;
07154 }
07155 switch(DType)
07156 {
07157 case LibDisplay_MediumThumbText:
07158 case LibDisplay_MediumThumb:
07159 case LibDisplay_SingleLineFullInfo:
07160 Size = SGThumb_Medium;
07161 break;
07162
07163 case LibDisplay_SmallThumbText:
07164 Size = SGThumb_Small;
07165 break;
07166
07167 case LibDisplay_JustText:
07168 return FALSE;
07169
07170 default:
07171 Size = SGThumb_Large;
07172 }
07173 switch (Size)
07174 {
07175 case SGThumb_Small:
07176 tchSize = _T('S');
07177 break;
07178 case SGThumb_Medium:
07179 tchSize = _T('M');
07180 break;
07181 case SGThumb_Large:
07182 tchSize = _T('L');
07183 break;
07184 default:
07185 tchSize = _T(' ');
07186 }
07187 camSnprintf(strFilename, _MAX_PATH, _T("%c%05d%c"), tchType, pLibrary->GetID(TheLibraryIndex), tchSize);
07188 thumbPath += strFilename;
07189 thumbPath += _T(".png");
07190 *path = thumbPath;
07191 return TRUE;
07192 }
07193
07194
07195
07196
07197
07198
07199
07200
07201
07202
07203
07204
07205
07206
07207
07208 FontClass SGLibFontItem::GetType(void)
07209 {
07210 Library *Lib = GetParentLibrary();
07211
07212 if (Lib != NULL)
07213 {
07214 TCHAR *pFName;
07215 BOOL ok = Lib->GetFilename(TheLibraryIndex, &pFName);
07216 if(ok)
07217 {
07218 if(camStrstr(pFName, _T(".ttf")) != NULL || camStrstr(pFName, _T(".TTF")) != NULL)
07219 return FC_TRUETYPE;
07220
07221 if(camStrstr(pFName, _T(".pfb")) != NULL || camStrstr(pFName, _T(".PFB")) != NULL)
07222 return FC_ATM;
07223 }
07224 else
07225 {
07226 String_256 FName;
07227 ok = Lib->GetFilename(TheLibraryIndex, &FName, FALSE);
07228 if(ok)
07229 {
07230 FName.toLower();
07231 if(FName.Sub((String_8)_T(".ttf")) != -1)
07232 return FC_TRUETYPE;
07233
07234 if(FName.Sub((String_8)_T(".pfb")) != -1)
07235 return FC_ATM;
07236 }
07237 }
07238 }
07239
07240 return FC_UNDEFINED;
07241 }
07242
07243
07244
07245
07246
07247
07248
07249
07250
07251
07252
07253
07254
07255
07256
07257 BOOL SGDisplayPreviewFonts::IsFontBeingUsed(void)
07258 {
07259
07260 Document *WorkDoc = (Document *)GetApplication()->Documents.GetHead();
07261 if(WorkDoc == NULL)
07262 return FALSE;
07263
07264 if(CachedLogFont == NULL)
07265 return FALSE;
07266
07267 String_64 SlowJob(_R(IDS_FONTS_SCANNING_DOCUMENTS));
07268 BeginSlowJob(-1, TRUE, &SlowJob);
07269
07270
07271 String_64 TypeFace(CachedLogFont->lfFaceName);
07272 TypeFace.toUpper();
07273 INT32 Style = 0;
07274 if(CachedLogFont->lfWeight > FW_MEDIUM)
07275 Style |= 1;
07276 if(CachedLogFont->lfItalic)
07277 Style |= 2;
07278
07279 while(WorkDoc != NULL)
07280 {
07281
07282 FontList DocFonts;
07283 DocFonts.Build(WorkDoc);
07284
07285 FontListItem* FontItem = DocFonts.GetFirstItem();
07286 if(FontItem!=NULL)
07287 {
07288
07289 while(FontItem)
07290 {
07291
07292
07293 if((FontItem->GetFontStyle() & 3) == Style)
07294 {
07295
07296 String_64 Name = FontItem->GetFontName();
07297 Name.toUpper();
07298
07299
07300 if(Name == TypeFace)
07301 {
07302 EndSlowJob();
07303 return TRUE;
07304 }
07305 }
07306 FontItem = DocFonts.GetNextItem(FontItem);
07307 }
07308 }
07309
07310
07311 Document *LastWorkDoc = WorkDoc;
07312 WorkDoc = (Document *)GetApplication()->Documents.GetNext(LastWorkDoc);
07313 }
07314
07315 EndSlowJob();
07316
07317
07318 return FALSE;
07319 }
07320 #endif