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 #include "camtypes.h"
00102 #include "sglfills.h"
00103
00104
00105
00106
00107 #include "sginit.h"
00108 #include "sglfills.h"
00109 #include "sglib.h"
00110 #include "sgmenu.h"
00111
00112 #include "thumbmsg.h"
00113
00114
00115 #include "grnddib.h"
00116
00117
00118
00119 #include "sgliboil.h"
00120
00121
00122
00123
00124
00125
00126 #include "progress.h"
00127 #include "camelot.h"
00128
00129 #include "dragmgr.h"
00130
00131
00132
00133
00134 #include "nodebmp.h"
00135
00136
00137 #include "sglbase.h"
00138
00139
00140 #include "sgscanf.h"
00141
00142
00143 #include "keypress.h"
00144 #include "backgrnd.h"
00145 #include <io.h>
00146 #include "inetop.h"
00147 #include "helpuser.h"
00148
00149
00150 #include "resdll.h"
00151
00152
00153
00154 CC_IMPLEMENT_DYNCREATE(LibFillsSGallery, LibraryGallery)
00155 CC_IMPLEMENT_DYNCREATE(OpDisplayLibFillsGallery, Operation)
00156 CC_IMPLEMENT_DYNCREATE(SGFillsItem, SGLibDisplayItem)
00157
00158 CC_IMPLEMENT_DYNCREATE(GalleryFillsDragInfo, BitmapDragInformation)
00159 CC_IMPLEMENT_DYNAMIC(SGFillsDragTarget, SGListDragTarget)
00160
00161
00162 #define new CAM_DEBUG_NEW
00163
00164 using namespace InetUtils;
00165
00166
00167 #ifdef _DEBUG
00168
00169
00170 String_256 LibFillsSGallery::DefaultLibraryPath = TEXT("D:\\fills");
00171 #else
00172 String_256 LibFillsSGallery::DefaultLibraryPath = TEXT("D:\\fills");
00173 #endif
00174
00175
00176 INT32 LibFillsSGallery::DefaultDisplayMode = 0;
00177
00178
00179
00180
00181
00182
00183
00184
00185 UINT32 LibFillsSGallery::DefaultSortKeys = 1;
00186
00187
00188 LibFillsSGallery *LibFillsSGallery::ThisGallery = NULL;
00189
00190
00191 BOOL LibFillsSGallery::QuietStatus = FALSE;
00192
00193
00194
00195
00196
00197
00198
00199
00200
00201
00202
00203 LibFillsSGallery::LibFillsSGallery()
00204 {
00205 LibFillsSGallery::ThisGallery = this;
00206
00207
00208 CSize Size(((333 * 2) - 32) - 32, 256);
00209 SetGallerySize(Size);
00210 }
00211
00212
00213
00214
00215
00216
00217
00218
00219
00220
00221
00222
00223
00224 LibFillsSGallery::~LibFillsSGallery()
00225 {
00226 OpenLibFiles.DeleteAll();
00227 LibFillsSGallery::ThisGallery = NULL;
00228 }
00229
00230
00231
00232
00233
00234
00235
00236
00237
00238
00239
00240
00241
00242
00243
00244 BOOL LibFillsSGallery::Init(void)
00245 {
00246 return(TRUE);
00247 }
00248
00249
00250
00251
00252
00253
00254
00255
00256
00257
00258
00259
00260
00261
00262
00263
00264
00265
00266
00267
00268
00269
00270
00271
00272 BOOL LibFillsSGallery::PreCreate(void)
00273 {
00274
00275 if (DisplayTree == NULL)
00276 {
00277 DisplayTree = new SGDisplayRootScroll(this);
00278 if (DisplayTree == NULL)
00279 return(FALSE);
00280 }
00281
00282
00283 if(OpenLibFiles.IsEmpty())
00284 {
00285 String_256 sLoc = DefaultLibraryPath;
00286
00287
00288 if(CResDll::GetExecutablePath((TCHAR*)DefaultLibraryPath))
00289 {
00290
00291 String_256 LibDirName;
00292 GetLibraryDirectoryName(&LibDirName);
00293 DefaultLibraryPath += "\\";
00294 DefaultLibraryPath += LibDirName;
00295 PathName ThisPath(DefaultLibraryPath);
00296 if(!SGLibOil::FileExists(&ThisPath))
00297 {
00298
00299 if(!ScanForLocation(SGLib_Texture, NULL))
00300 {
00301
00302
00303 DefaultLibraryPath = sLoc;
00304 }
00305 }
00306 }
00307
00308 LibraryGallery::AddLibraryGroups(SGLib_Texture, &DefaultLibraryPath);
00309 }
00310
00311
00312 DisplayMode = LibFillsSGallery::DefaultDisplayMode;
00313
00314 return TRUE;
00315 }
00316
00317
00318
00319
00320
00321
00322
00323
00324
00325
00326
00327
00328
00329
00330
00331
00332
00333
00334 void LibFillsSGallery::SortGallery(void)
00335 {
00336 LibraryGallery::SortGallery();
00337 }
00338
00339
00340
00341
00342
00343
00344
00345
00346
00347
00348
00349
00350
00351
00352
00353 BOOL LibFillsSGallery::BrowseClicked(void)
00354 {
00355 return (LibraryGallery::BrowseClicked(&DefaultLibraryPath, SGLib_Texture, _R(IDS_REMOVE_OLD_GOUPS_FILLS)));
00356 }
00357
00358
00359
00360
00361
00362
00363
00364
00365
00366
00367
00368
00369
00370
00371 BOOL LibFillsSGallery::CanCreateIndexes(void)
00372 {
00373 return TRUE;
00374 }
00375
00376
00377
00378
00379
00380
00381
00382
00383
00384
00385
00386
00387
00388
00389
00390
00391
00392
00393 BOOL LibFillsSGallery::GetDefaults(String_256 *DefaultIndex, String_256 *IndexDesc, SGLibType *Type)
00394 {
00395 if(DefaultIndex != NULL)
00396 *DefaultIndex = _R(IDS_LIBRARIES_FILLS_FILENAME);
00397
00398 if(IndexDesc != NULL)
00399 *IndexDesc = _R(IDS_LIBRARIES_FILLS_DESC);
00400
00401 if(Type != NULL)
00402 *Type = SGLib_Texture;
00403
00404 return TRUE;
00405 }
00406
00407
00408
00409
00410
00411
00412
00413
00414
00415
00416
00417
00418
00419
00420
00421
00422 BOOL LibFillsSGallery::GetLibraryDirectoryName(String_256 *LibDirName)
00423 {
00424 LibDirName->MakeMsg(_R(IDS_LIBRARIES_FILLS_DIRNAME));
00425 return TRUE;
00426 }
00427
00428
00429
00430
00431
00432
00433
00434
00435
00436
00437
00438
00439 BOOL LibFillsSGallery::GetQuietStatus(void)
00440 {
00441 return LibFillsSGallery::QuietStatus;
00442 }
00443
00444
00445
00446
00447
00448
00449
00450
00451
00452
00453
00454
00455
00456 void LibFillsSGallery::SetQuietStatus(BOOL Status)
00457 {
00458 LibFillsSGallery::QuietStatus = Status;
00459 }
00460
00461
00462
00463
00464
00465
00466
00467
00468
00469
00470
00471
00472
00473
00474
00475
00476
00477
00478
00479 BOOL LibFillsSGallery::ScanForLocation(SGLibType Type, StringBase *Result)
00480 {
00481 #ifndef STANDALONE
00482
00483 String_256 DriveName;
00484 BOOL AreWeXara = FALSE;
00485 String_256 XaraDrive;
00486
00487 BOOL Adjust = KeyPress::IsAdjustPressed();
00488 #ifndef _DEBUG
00489 Adjust = FALSE;
00490 #endif
00491
00492 if(SGLibOil::LocateCDROMDrive(this, Type, &DriveName, &AreWeXara, &XaraDrive, Adjust))
00493 {
00494 if(AreWeXara)
00495 DriveName = XaraDrive;
00496
00497 switch(Type)
00498 {
00499 case SGLib_Texture:
00500 case SGLib_Fractal:
00501 LibFillsSGallery::DefaultLibraryPath = DriveName;
00502 #ifdef _DEBUG
00503 if(Adjust)
00504 {
00505 LibFillsSGallery::DefaultLibraryPath += TEXT("Graphics\\Fills");
00506 }
00507 else
00508 #endif
00509 {
00510 String_256 LibDirName;
00511 GetLibraryDirectoryName(&LibDirName);
00512 LibFillsSGallery::DefaultLibraryPath += LibDirName;
00513 }
00514
00515 if(Result)
00516 *Result = LibFillsSGallery::DefaultLibraryPath;
00517
00518 return TRUE;
00519 }
00520 }
00521 #endif
00522 return FALSE;
00523 }
00524
00525
00526
00527
00528
00529
00530
00531
00532
00533
00534
00535
00536
00537
00538
00539
00540 BOOL LibFillsSGallery::CheckForIndexMatch(StringBase *Txt)
00541 {
00542 BOOL Match = FALSE;
00543
00544
00545 if(((Txt->Sub(String_8("T"))!=-1) || (Txt->Sub(String_8("t"))!=-1)) ) Match = TRUE;
00546
00547 return Match;
00548 }
00549
00550
00551
00552
00553
00554
00555
00556
00557
00558
00559
00560
00561
00562
00563
00564
00565
00566
00567
00568
00569
00570 BOOL LibFillsSGallery::ApplyAction(SGActionType Action)
00571 {
00572
00573 if (DisplayTree == NULL)
00574 return(FALSE);
00575
00576
00577 switch(Action)
00578 {
00579 case SGACTION_APPLYADJUST:
00580
00581
00582 case SGACTION_APPLY:
00583
00584 if(Document::GetSelected() == NULL)
00585 return FALSE;
00586
00587 if(!FillUsingFillGallerySelection(ApplyToObject))
00588 return FALSE;
00589
00590 break;
00591
00592 case SGACTION_SETOPTIONS:
00593 {
00594 if (CurrentOptionsDlg == NULL)
00595 return(FALSE);
00596
00597 CurrentOptionsDlg->AddDisplayModeName(_R(IDS_GALLERYDM_LARGE));
00598 CurrentOptionsDlg->AddDisplayModeName(_R(IDS_GALLERYDM_FULLINFO));
00599 CurrentOptionsDlg->AddDisplayModeName(_R(IDS_GALLERYDM_SMALL));
00600 }
00601 break;
00602
00603 case SGACTION_SETSORTMODE:
00604 {
00605 if (CurrentSortDlg == NULL)
00606 return(FALSE);
00607
00608 CurrentSortDlg->AddSortKeyName(_R(IDS_SORTBY_NAME));
00609 CurrentSortDlg->AddSortKeyName(_R(IDS_SORTBY_MEMORY));
00610 CurrentSortDlg->AddSortKeyName(_R(IDS_SORTBY_NAMELENGTH));
00611 CurrentSortDlg->AddSortKeyName(_R(IDS_SORTBY_FILETYPE));
00612 }
00613 break;
00614
00615
00616 case SGACTION_DISPLAYMODECHANGED:
00617 if(DisplayMode >= 3) DisplayMode = 0;
00618 DefaultDisplayMode = DisplayMode;
00619 InvalidateCachedFormat();
00620 ReformatAndRedrawIfNecessary();
00621 break;
00622
00623 default:
00624 return(SuperGallery::ApplyAction(Action));
00625 break;
00626 }
00627
00628 return(TRUE);
00629 }
00630
00631
00632
00633
00634
00635
00636
00637
00638
00639
00640
00641
00642
00643
00644
00645
00646
00647
00648
00649
00650
00651
00652
00653
00654
00655
00656
00657
00658 MsgResult LibFillsSGallery::Message(Msg* Message)
00659 {
00660
00661 static HANDLE handle = NULL;
00662 CString mutexName = "autorunMutex";
00663
00664
00665
00666
00667 if (DisplayTree == NULL)
00668 return(LibraryGallery::Message(Message));
00669
00670 KernelBitmap *SelectedBitmap = NULL;
00671
00672 if (IS_OUR_DIALOG_MSG(Message))
00673 {
00674 DialogMsg* Msg = (DialogMsg*)Message;
00675
00676 switch (Msg->DlgMsg)
00677 {
00678 case DIM_CREATE:
00679
00680
00681
00682
00683
00684
00685 handle = CreateMutex(NULL,TRUE,mutexName);
00686
00687
00688 SGInit::UpdateGalleryButton(OPTOKEN_DISPLAYFILLSGALLERY, TRUE);
00689 LibFillsSGallery::ThisGallery->GalleryAboutToReOpen();
00690 break;
00691
00692 case DIM_CANCEL:
00693
00694 if(handle != NULL)
00695 {
00696 CloseHandle(handle);
00697 }
00698
00699
00700 SGInit::UpdateGalleryButton(OPTOKEN_DISPLAYFILLSGALLERY, FALSE);
00701
00702
00703 BROADCAST_TO_CLASS(ThumbMessage(ThumbMessage::ThumbState::KILLCACHE, SGLib_Texture), DialogOp);
00704 BROADCAST_TO_CLASS(ThumbMessage(ThumbMessage::ThumbState::KILLCACHE, SGLib_Fractal), DialogOp);
00705 GalleryAboutToClose();
00706 break;
00707
00708 case DIM_LFT_BN_CLICKED:
00709 switch (Msg->GadgetID)
00710 {
00711 case _R(IDC_LIBGAL_OPEN):
00712 if(Document::GetSelected() != NULL)
00713 FillUsingFillGallerySelection(AddToPage);
00714 break;
00715
00716 case _R(IDC_LIBGAL_IMPORT):
00717 FillUsingFillGallerySelection(AddToPage);
00718 break;
00719
00720 case _R(IDC_LIBGAL_BROWSE):
00721 case _R(IDC_LIBGAL_ADD_FILLS):
00722 BrowseClicked();
00723 break;
00724
00725 case _R(IDC_BMPGAL_FILL):
00726 if(!FillUsingFillGallerySelection(ApplyToObject))
00727 {
00728 return(SuperGallery::Message(Message));
00729 }
00730 break;
00731
00732 case _R(IDC_BMPGAL_TEXTURE):
00733 if(Document::GetSelected() != NULL)
00734 if(!FillUsingFillGallerySelection(ApplyToObjectAsTransp))
00735 {
00736 return(SuperGallery::Message(Message));
00737 }
00738 break;
00739
00740 case _R(IDC_BMPGAL_BACKGROUND):
00741 if(Document::GetSelected() != NULL)
00742 if(!FillUsingFillGallerySelection(SetBackground))
00743 {
00744 return(SuperGallery::Message(Message));
00745 }
00746 break;
00747
00748 case _R(IDC_BMPGAL_SAVE):
00749 #ifdef _DEBUG
00750 {
00751 SGDisplayNode *Item = DisplayTree->FindNextSelectedItem(NULL);
00752 if(Item != NULL && Item->IsKindOf(CC_RUNTIME_CLASS(SGLibDisplayItem)))
00753 {
00754 SGLibDisplayItem *LibItem = (SGLibDisplayItem *)Item;
00755
00756 Library *Parent = LibItem->GetParentLibrary();
00757 if(Parent != NULL)
00758 {
00759 PathName *Source = Parent->ReturnIndexLocation();
00760 PathName Dest(*Source);
00761 Dest.SetType((String_256)"BAK");
00762 SGLibOil::FileCopy(Source, &Dest);
00763
00764 Parent->SaveIndexInDisplayedOrder(Source, TRUE);
00765 }
00766 }
00767 }
00768 #endif
00769 break;
00770
00771 case _R(IDC_GALLERY_HELP):
00772 HelpUserTopic(_R(IDS_HELPPATH_Gallery_Fill));
00773 break;
00774
00775
00776
00777 default:
00778 break;
00779 }
00780 }
00781 }
00782 else if (MESSAGE_IS_A(Message, DocChangingMsg))
00783 {
00784 DocChangingMsg *Msg = (DocChangingMsg *) Message;
00785 switch (Msg->State)
00786 {
00787 case DocChangingMsg::DocState::SELCHANGED:
00788 if (Msg->pNewDoc == NULL)
00789 {
00790
00791
00792 DoShadeGallery(TRUE);
00793 SuperGallery::ShadeGallery(TRUE);
00794 }
00795 else
00796 {
00797
00798 DoShadeGallery(FALSE);
00799 SuperGallery::ShadeGallery(FALSE);
00800 SelectionHasChanged();
00801 }
00802 break;
00803 }
00804 }
00805 else if (MESSAGE_IS_A(Message, ThumbMessage) && DisplayTree != NULL)
00806 {
00807 ThumbMessage *Msg = (ThumbMessage *) Message;
00808
00809
00810 if(Msg->State == ThumbMessage::ThumbState::CACHESIZECHANGED)
00811 {
00812 FlushBackgroundRedraws();
00813 ForceRedrawOfList();
00814 }
00815 }
00816
00817 return(LibraryGallery::Message(Message));
00818 }
00819
00820
00821
00822
00823
00824
00825
00826
00827
00828
00829
00830
00831
00832
00833
00834 void LibFillsSGallery::SelectionHasChanged(void)
00835 {
00836 if (DisplayTree == NULL)
00837 return;
00838
00839
00840
00841
00842 if (!IsVisible())
00843 return;
00844
00845 INT32 Count = DisplayTree->GetSelectedItemCount();
00846 BOOL Documents = (Document::GetSelected() != NULL);
00847
00848
00849
00850
00851 EnableGadget(_R(IDC_LIBGAL_IMPORT), (Count > 0) && Documents);
00852
00853 String_256 strCommand, strDummy;
00854
00855 BOOL bEnable = Count == 1 && Documents;
00856
00857
00858 strCommand = SGCmd_Import;
00859 EnableGadget(_R(IDC_LIBGAL_IMPORT), bEnable && !((GetCommandState(&strCommand, &strDummy)).Greyed));
00860
00861
00862 strCommand = SGCmd_Fill;
00863 EnableGadget(_R(IDC_BMPGAL_FILL), bEnable && !((GetCommandState(&strCommand, &strDummy)).Greyed));
00864
00865
00866 strCommand = SGCmd_Transp;
00867 EnableGadget(_R(IDC_BMPGAL_TEXTURE), bEnable && !((GetCommandState(&strCommand, &strDummy)).Greyed));
00868
00869
00870 strCommand = SGCmd_SetBackground;
00871 EnableGadget(_R(IDC_BMPGAL_BACKGROUND), bEnable && !((GetCommandState(&strCommand, &strDummy)).Greyed));
00872
00873 EnableGadget(_R(IDC_LIBGAL_ADD_FILLS), TRUE);
00874
00875 LibraryGallery::SelectionHasChanged();
00876 }
00877
00878
00879
00880
00881
00882
00883
00884
00885
00886
00887
00888
00889
00890 void LibFillsSGallery::DoShadeGallery(BOOL ShadeIt)
00891 {
00892 if (DisplayTree == NULL)
00893 return;
00894
00895
00896 EnableGadget(_R(IDC_GALLERY_MENU), TRUE);
00897
00898 EnableGadget(_R(IDC_LIBGAL_IMPORT), !ShadeIt);
00899 EnableGadget(_R(IDC_BMPGAL_FILL), !ShadeIt);
00900 EnableGadget(_R(IDC_BMPGAL_TEXTURE), !ShadeIt);
00901
00902 EnableGadget(_R(IDC_BMPGAL_BACKGROUND), !ShadeIt);
00903
00904 EnableGadget(_R(IDC_LIBGAL_ADD_FILLS), TRUE);
00905
00906 LibraryGallery::DoShadeGallery(ShadeIt);
00907 }
00908
00909
00910
00911
00912
00913
00914
00915
00916
00917
00918
00919
00920
00921
00922 bool LibFillsSGallery::FillUsingFillGallerySelection(FillTypeEnum FillType)
00923 {
00924 PathName FileName;
00925
00926 UINT32 TagObjectToFill = 0;
00927
00928
00929 if (GetSelectedItemCount() != 1 && FillType != AddToPage)
00930 {
00931 TRACEUSER( "Jonathan", _T("Fills: FillUsingGallerySelection failing due to multiple selection\n"));
00932 return false;
00933 }
00934
00935 SGLibDisplayItem *FillItem = static_cast<SGLibDisplayItem *>(DisplayTree->FindNextSelectedItem());
00936
00937 if (!FillItem->GetFileName(&FileName))
00938 return false;
00939
00940 if (!FileName.IsValid(FileName.GetPath()))
00941 {
00942 ERROR3("Filename is invalid");
00943 return false;
00944 }
00945
00946 bool NeedToDownload;
00947 if (_taccess(FileName.GetPath(), 0) == -1)
00948 NeedToDownload = true;
00949 else
00950 NeedToDownload = false;
00951
00952 if (FillType == ApplyToObject || FillType == ApplyToObjectAsTransp)
00953 {
00954 SelRange* Sel = GetApplication()->FindSelection();
00955 if (Sel==0)
00956 {
00957 ERROR3("Can't find SelRange!");
00958 return false;
00959 }
00960 if (NeedToDownload)
00961 {
00962 Node *NodeToFill = Sel->FindFirst();
00963 if (Sel->FindNext(NodeToFill) != 0)
00964 {
00965
00966
00967 InformError(_R(IDE_SGLFILLS_NOMULTI_DL_FILL));
00968 return false;
00969 }
00970 if (NodeToFill)
00971 TagObjectToFill = NodeToFill->GetTag();
00972 else
00973 {
00974
00975
00976
00977
00978
00979
00980 TagObjectToFill = 0;
00981 }
00982 }
00983 }
00984
00985 DocCoord DropPos;
00986 DocRect PageRect;
00987 Spread *s;
00988 if ((s = Document::GetSelectedSpread()) != 0)
00989 {
00990 if (s->GetPagesRect(&PageRect))
00991 DropPos = PageRect.Centre();
00992 else
00993 return false;
00994 }
00995 else
00996 return false;
00997
00998 if (!NeedToDownload)
00999
01000 {
01001 TRACEUSER( "Jonathan", _T("Fills: File in cache\n"));
01002 OpDescriptor* pOpDesc = OpDescriptor::FindOpDescriptor(CC_RUNTIME_CLASS(OpBitmapImport));
01003
01004 if (pOpDesc != 0)
01005 {
01006 BitmapImportParam Param;
01007
01008 Param.File = &FileName;
01009 Param.Result = TRUE;
01010 Param.pTargetDoc = Document::GetSelected();
01011 Param.FillType = FillType;
01012 Param.pSpread = Document::GetSelectedSpread();
01013 Param.DropPos = DropPos;
01014 Param.TagObjectValid = false;
01015 Param.pObjectValid = false;
01016
01017
01018 pOpDesc->Invoke((OpParam *) &Param);
01019
01020 if (!Param.Result)
01021 {
01022 ERROR3("Problem importing file from cache");
01023 return false;
01024 }
01025 }
01026 }
01027 else
01028
01029 {
01030 TRACEUSER( "Jonathan", _T("Fills: File not in cache : downloading\n"));
01031 OpDescriptor* pOpDesc = OpDescriptor::FindOpDescriptor(CC_RUNTIME_CLASS(OpAsynchBitmapImport));
01032
01033 if (pOpDesc != 0)
01034 {
01035 AsynchBitmapImportParam* Param = new AsynchBitmapImportParam;
01036
01037 if (!Param)
01038 return false;
01039 Library* pLibrary = FillItem->GetParentLibrary();
01040 String_256 strFileURL = FileName.GetPath();
01041 pLibrary->LocalPath2URL(&strFileURL);
01042 Param->file = FileName;
01043 Param->pTargetDoc = Document::GetSelected();
01044 Param->strURL = strFileURL;
01045 String_256 strDescription;
01046 FillItem->GetNameText(&strDescription);
01047 Param->strDescription = _T("'");
01048 Param->strDescription += strDescription;
01049 Param->strDescription += _T("'");
01050 Param->type = TYPE_FILL;
01051 Param->FillType = FillType;
01052 Param->priority = AsynchDownload::PRIORITY_HIGH;
01053 Param->pSpread = Document::GetSelectedSpread();
01054 Param->DropPos = DropPos;
01055 Param->TagObjectToFill = TagObjectToFill;
01056 Param->pObjectValid = false;
01057
01058
01059
01060
01061 if (TagObjectToFill)
01062 Param->TagObjectValid = true;
01063 else
01064 Param->TagObjectValid = false;
01065
01066
01067 pOpDesc->Invoke((OpParam *) Param);
01068 }
01069 }
01070 return true;
01071 }
01072
01073
01074
01075
01076
01077
01078
01079
01080
01081
01082
01083
01084
01085
01086
01087
01088
01089
01090
01091
01092
01093
01094
01095
01096
01097
01098
01099
01100
01101
01102 SGDisplayItem *LibFillsSGallery::AddLibraryItem(SGDisplayGroup *LibraryGroup,
01103 Library *ParentLib,
01104 LibraryIndex ItemIndex, BOOL bNew)
01105 {
01106 ERROR3IF(LibraryGroup == NULL || ParentLib == NULL,
01107 "LibFillsSGallery::AddLibraryItem - NULL params are illegal");
01108
01109 ERROR3IF(LibraryGroup->GetParentLibrary() != ParentLib,
01110 "LibFillsSGallery::AddLibraryitem - The DisplayGroup is not for the same library!");
01111
01112
01113 SGFillsItem *NewItem = new SGFillsItem(ItemIndex, bNew);
01114
01115
01116
01117
01118
01119
01120
01121
01122
01123
01124
01125 if (NewItem != NULL)
01126 LibraryGroup->AddItem(NewItem);
01127
01128 return(NewItem);
01129 }
01130
01131
01132
01133
01134
01135
01136
01137
01138
01139
01140
01141
01142
01143
01144
01145
01146 BOOL LibFillsSGallery::CanSearchKeywords(void)
01147 {
01148 return(TRUE);
01149 }
01150
01151
01152
01153
01154
01155
01156
01157
01158
01159
01160
01161
01162
01163
01164
01165
01166
01167
01168
01169
01170 void LibFillsSGallery::HandleDragStart(DragMessage *DragMsg)
01171 {
01172
01173
01174 if (DragMsg->pInfo->IsKindOf(CC_RUNTIME_CLASS(GalleryFillsDragInfo)))
01175 SGFillsDragTarget *NewTarget = new SGFillsDragTarget(this, GetListGadgetID());
01176 else
01177 SuperGallery::HandleDragStart(DragMsg);
01178 }
01179
01180
01181
01182
01183
01184
01185
01186
01187
01188
01189
01190
01191
01192
01193 void LibFillsSGallery::WorkOutSectionName(String_256 *Section)
01194 {
01195 if(Section)
01196 *Section = _R(IDS_SGLFILLS_SECTION_NAME);
01197 }
01198
01199
01200
01201
01202
01203
01204
01205
01206
01207
01208
01209
01210
01211
01212
01213
01214
01215
01216
01217 BOOL LibFillsSGallery::InitMenuCommands(void)
01218 {
01219 static BOOL MenusInitialised = FALSE;
01220
01221 BOOL ok = TRUE;
01222
01223 if (!MenusInitialised)
01224 {
01225
01226
01227
01228 ok = ok && InitMenuCommand((StringBase *) &SGCmd_Find, _R(IDS_SGMENU_FIND));
01229 ok = ok && InitMenuCommand((StringBase *) &SGCmd_Sort, _R(IDS_SGMENU_SORT));
01230 ok = ok && InitMenuCommand((StringBase *) &SGCmd_Properties, _R(IDS_SGMENU_PROPERTIES));
01231
01232
01233 ok = ok && InitMenuCommand((StringBase *) &SGCmd_Add, _R(IDS_SGMENU_ADDFILL));
01234 ok = ok && InitMenuCommand((StringBase *) &SGCmd_EmptyFillsCache, _R(IDS_SGMENU_EMPTYFILLCACHE));
01235
01236
01237
01238 ok = ok && InitMenuCommand((StringBase *) &SGCmd_Import, _R(IDS_SGMENU_IMPORT));
01239 ok = ok && InitMenuCommand((StringBase *) &SGCmd_Fill, _R(IDS_SGMENU_FILL));
01240 ok = ok && InitMenuCommand((StringBase *) &SGCmd_Transp, _R(IDS_SGMENU_TRANSP));
01241 ok = ok && InitMenuCommand((StringBase *) &SGCmd_SetBackground, _R(IDS_SGMENU_SETBACKGROUND));
01242 ok = ok && InitMenuCommand((StringBase *) &SGCmd_Download, _R(IDS_SGMENU_DOWNLOAD));
01243 ok = ok && InitMenuCommand((StringBase *) &SGCmd_Remove, _R(IDS_SGMENU_REMOVE));
01244
01245
01246 ok = ok && InitMenuCommand((StringBase *) &SGCmd_FoldGroup, _R(IDS_SGMENU_FOLD));
01247 ok = ok && InitMenuCommand((StringBase *) &SGCmd_UnfoldGroup, _R(IDS_SGMENU_UNFOLD));
01248
01249 ok = ok && InitMenuCommand((StringBase *) &SGCmd_NextGroup, _R(IDS_SGMENU_NEXTGROUP));
01250 ok = ok && InitMenuCommand((StringBase *) &SGCmd_PrevGroup, _R(IDS_SGMENU_PREVGROUP));
01251
01252 MenusInitialised = TRUE;
01253 }
01254
01255 return(ok);
01256 }
01257
01258
01259
01260
01261
01262
01263
01264
01265
01266
01267
01268
01269
01270
01271
01272
01273
01274
01275
01276
01277 BOOL LibFillsSGallery::BuildCommandMenu(GalleryContextMenu *TheMenu, SGMenuID MenuID)
01278 {
01279 BOOL ok = TRUE;
01280
01281 if (MenuID == SGMENU_OPTIONS)
01282 {
01283
01284 ok = ok && AddCommand(TheMenu, (StringBase *) &SGCmd_Add);
01285 ok = ok && AddCommand(TheMenu, (StringBase *) &SGCmd_EmptyFillsCache, TRUE);
01286
01287
01288 ok = ok && AddCommand(TheMenu, (StringBase *) &SGCmd_Find);
01289 ok = ok && AddCommand(TheMenu, (StringBase *) &SGCmd_Sort);
01290 ok = ok && AddCommand(TheMenu, (StringBase *) &SGCmd_Properties);
01291 }
01292 else
01293 {
01294
01295 ok = ok && AddCommand(TheMenu, (StringBase *) &SGCmd_Import);
01296 ok = ok && AddCommand(TheMenu, (StringBase *) &SGCmd_Fill);
01297 ok = ok && AddCommand(TheMenu, (StringBase *) &SGCmd_Transp,TRUE);
01298
01299 ok = ok && AddCommand(TheMenu, (StringBase *) &SGCmd_Remove, TRUE);
01300
01301 ok = ok && AddCommand(TheMenu, (StringBase *) &SGCmd_SetBackground,TRUE);
01302
01303 SGDisplayGroup *TheGroup = FindCommandGroup();
01304 if (TheGroup == NULL || !TheGroup->Flags.Folded)
01305 ok = ok && AddCommand(TheMenu, (StringBase *) &SGCmd_FoldGroup);
01306 else
01307 ok = ok && AddCommand(TheMenu, (StringBase *) &SGCmd_UnfoldGroup);
01308
01309 ok = ok && AddCommand(TheMenu, (StringBase *) &SGCmd_PrevGroup);
01310 ok = ok && AddCommand(TheMenu, (StringBase *) &SGCmd_NextGroup);
01311 }
01312
01313 return(ok);
01314 }
01315
01316
01317
01318
01319
01320
01321
01322
01323
01324
01325
01326
01327
01328
01329
01330
01331
01332
01333
01334
01335
01336
01337
01338
01339
01340
01341
01342
01343
01344 OpState LibFillsSGallery::GetCommandState(StringBase *CommandID, String_256 *ShadeReason)
01345 {
01346 TRACEUSER( "Jonathan", _T("Fills::GetCommandState called for "));
01347 TRACEUSER("Jonathan", *CommandID);
01348 TRACEUSER( "Jonathan", _T("\n"));
01349 OpState State;
01350
01351 if (*CommandID == SGCmd_Add)
01352 {
01353 return(State);
01354 }
01355 else if (*CommandID == SGCmd_EmptyFillsCache)
01356 {
01357 if (m_bDiscardWebFolders)
01358 State.Greyed = TRUE;
01359 return (State);
01360 }
01361 else if (*CommandID == SGCmd_Fill || *CommandID == SGCmd_Transp ||
01362 *CommandID == SGCmd_SetBackground || *CommandID == SGCmd_Import)
01363 {
01364 if (GetSelectedItemCount() != 1)
01365 {
01366 State.Greyed = TRUE;
01367 ShadeReason->MakeMsg(_R(IDS_SGSHADE_SINGLE));
01368 }
01369 }
01370 else if (*CommandID == SGCmd_Remove)
01371 {
01372 if (GetSelectedGroupCount() < 1)
01373 {
01374 State.Greyed = TRUE;
01375 ShadeReason->MakeMsg(_R(IDS_SGSHADE_NOSELGROUP));
01376 }
01377 }
01378 else
01379 return(SuperGallery::GetCommandState(CommandID, ShadeReason));
01380
01381 return(State);
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 void LibFillsSGallery::DoCommand(StringBase *CommandID)
01409 {
01410 if (*CommandID == SGCmd_Import)
01411 {
01412 if (Document::GetSelected() != NULL)
01413 FillUsingFillGallerySelection(AddToPage);
01414 }
01415 else if (*CommandID == SGCmd_Fill)
01416 {
01417 if (Document::GetSelected() != NULL)
01418 FillUsingFillGallerySelection(ApplyToObject);
01419 }
01420 else if (*CommandID == SGCmd_EmptyFillsCache)
01421 {
01422 RemoveWebFolders(SGLib_Fractal);
01423 }
01424 else if (*CommandID == SGCmd_Transp)
01425 {
01426 if (Document::GetSelected() != NULL)
01427 FillUsingFillGallerySelection(ApplyToObjectAsTransp);
01428 }
01429 else if (*CommandID == SGCmd_Add)
01430 BrowseClicked();
01431 else if (*CommandID == SGCmd_Remove)
01432 {
01433 RemoveSelectedLibraries(TRUE);
01434 UpdateGRMFile();
01435 }
01436 else if (*CommandID == SGCmd_SetBackground)
01437 {
01438 if (Document::GetSelected() != NULL)
01439 FillUsingFillGallerySelection(SetBackground);
01440 }
01441 else
01442 SuperGallery::DoCommand(CommandID);
01443 }
01444
01445
01446
01447
01448
01449
01450
01451
01452
01453
01454
01455
01456
01457
01458
01459
01460
01461
01462
01463
01464
01465 SGDisplayGroup *LibFillsSGallery::AddLibraryGroup(Library *LibraryToDisplay, INT32 NumItems)
01466 {
01467 ERROR3IF(LibraryToDisplay == NULL, "LibFillsSGallery::AddLibraryGroup - NULL parameter is illegal");
01468
01469 if (DisplayTree == NULL)
01470 {
01471 ERROR3("LibFillsSGallery::AddLibraryGroup called before the DisplayTree was initialised!");
01472 return(NULL);
01473 }
01474
01475 SGLibGroup *TheGroup = (SGLibGroup *)DisplayTree->FindSubtree(this, NULL, LibraryToDisplay);
01476
01477 if (TheGroup == NULL)
01478 {
01479
01480 TheGroup = new SGLibGroup(this, NULL, LibraryToDisplay);
01481
01482 if (TheGroup == NULL)
01483 return(NULL);
01484
01485
01486 DisplayTree->AddItem(TheGroup);
01487 }
01488 else
01489 TheGroup->DestroySubtree(FALSE);
01490
01491 return(TheGroup);
01492 }
01493
01494
01495
01496
01497
01498
01499
01500
01501
01502
01503
01504
01505
01506
01507
01508
01509
01510
01511
01512
01513
01514
01515
01516
01517
01518
01519
01520
01521
01522
01523
01524
01525
01526
01527
01528
01529
01530
01531
01532
01533 SGDisplayItem *LibFillsSGallery::CopyDisplayItem(SGDisplayItem *SourceItem,
01534 SGDisplayGroup *DestGroup, SGDisplayItem *TargetPosition)
01535 {
01536 if(SourceItem == NULL || DestGroup == NULL)
01537 {
01538 ERROR3("LibFillsSGallery::CopyDisplayItem -> Illegal NULL param");
01539 return NULL;
01540 }
01541
01542
01543 if(DestGroup->IsKindOf(CC_RUNTIME_CLASS(SGLibGroup)))
01544 {
01545 SGDisplayNode *SourceGroup = SourceItem->GetParent();
01546 if((SGDisplayGroup *)SourceGroup != DestGroup)
01547 {
01548
01549 InformError(_R(IDS_FILLS_BETWEEN_GROUPS), _R(IDS_OK));
01550 Error::ClearError();
01551 }
01552 }
01553
01554 return(NULL);
01555 }
01556
01557
01558
01559
01560
01561
01562
01563
01564
01565
01566
01567
01568
01569
01570
01571
01572
01573
01574
01575
01576 BOOL OpDisplayLibFillsGallery::Init()
01577 {
01578
01579
01580
01581
01582
01583 return (RegisterOpDescriptor(
01584 0,
01585 _R(IDS_DISPLAY_FILLS_GALLERY),
01586 CC_RUNTIME_CLASS(OpDisplayLibFillsGallery),
01587 OPTOKEN_DISPLAYFILLSGALLERY,
01588 OpDisplayLibFillsGallery::GetState,
01589 0,
01590 _R(IDBBL_DISPLAY_FILLS_GALLERY),
01591 0 ));
01592 }
01593
01594
01595
01596
01597
01598
01599
01600
01601
01602
01603
01604
01605
01606
01607
01608
01609 OpState OpDisplayLibFillsGallery::GetState(String_256* UIDescription, OpDescriptor*)
01610 {
01611 OpState OpSt;
01612
01613
01614 DialogBarOp* pDialogBarOp = FindGallery();
01615 if (pDialogBarOp != NULL)
01616 OpSt.Ticked = pDialogBarOp->IsVisible();
01617
01618
01619 return(OpSt);
01620 }
01621
01622
01623
01624
01625
01626
01627
01628
01629
01630
01631
01632
01633
01634
01635
01636
01637
01638
01639
01640
01641 void OpDisplayLibFillsGallery::Do(OpDescriptor*)
01642 {
01643 DialogBarOp *pDialogBarOp = FindGallery();
01644
01645 if (pDialogBarOp != NULL)
01646 {
01647
01648 pDialogBarOp->SetVisibility( !pDialogBarOp->IsVisible() );
01649
01650
01651 SGInit::UpdateGalleryButton(OPTOKEN_DISPLAYFILLSGALLERY, pDialogBarOp->IsVisible());
01652
01653
01654 if(pDialogBarOp->IsVisible() == FALSE)
01655 {
01656
01657 BROADCAST_TO_CLASS(ThumbMessage(ThumbMessage::ThumbState::KILLCACHE, SGLib_Texture), DialogOp);
01658 BROADCAST_TO_CLASS(ThumbMessage(ThumbMessage::ThumbState::KILLCACHE, SGLib_Fractal), DialogOp);
01659
01660
01661 if(LibFillsSGallery::ThisGallery != NULL)
01662 {
01663
01664 LibFillsSGallery::ThisGallery->GalleryAboutToClose();
01665 }
01666
01667 }
01668 }
01669
01670 End();
01671 }
01672
01673
01674
01675
01676
01677
01678
01679
01680
01681
01682
01683
01684
01685
01686
01687
01688
01689
01690
01691
01692
01693 DialogBarOp *OpDisplayLibFillsGallery::FindGallery(void)
01694 {
01695 String_32 Name = _R(IDS_SGLFILLS_GALLERY_NAME);
01696 DialogBarOp* pDialogBarOp = DialogBarOp::FindDialogBarOp(Name);
01697
01698 if (pDialogBarOp != NULL)
01699 {
01700 if (pDialogBarOp->GetRuntimeClass() == CC_RUNTIME_CLASS(LibFillsSGallery))
01701 return(pDialogBarOp);
01702
01703 ERROR3("Got the Fills gallery but it's not of the LibFillsSGallery class");
01704 }
01705 else
01706 {
01707 ERROR3("Can't find the Fills gallery in bars.ini!\n");
01708 }
01709
01710 return(NULL);
01711 }
01712
01713
01714
01715
01716
01717
01718
01719
01720
01721
01722
01723
01724
01725
01726
01727
01728
01729
01730
01731 LibDisplayType SGFillsItem::GetDisplayType(SGMiscInfo *MiscInfo)
01732 {
01733 switch(MiscInfo->DisplayMode)
01734 {
01735 case 2:
01736 return LibDisplay_SmallThumbText;
01737 break;
01738 case 1:
01739 return LibDisplay_FullInfo;
01740 break;
01741 case 0:
01742 default:
01743 return LibDisplay_LargeThumbTextUnder;
01744 break;
01745 }
01746
01747 return LibDisplay_LargeThumbTextUnder;
01748 }
01749
01750
01751
01752
01753
01754
01755
01756
01757
01758
01759
01760
01761
01762
01763
01764
01765 SGFillsItem::SGFillsItem(LibraryIndex LibraryIndexToDisplay, BOOL bNew) :
01766 SGLibDisplayItem(LibraryIndexToDisplay, bNew)
01767 {
01768 }
01769
01770
01771
01772 SGFillsItem::SGFillsItem()
01773 {
01774 }
01775
01776 SGFillsItem::~SGFillsItem()
01777 {
01778 }
01779
01780
01781
01782
01783
01784
01785
01786
01787
01788
01789
01790
01791
01792
01793
01794
01795
01796
01797
01798
01799
01800
01801
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
01828
01829
01830
01831
01832
01833
01834 BOOL SGFillsItem::HandleEvent(SGEventType EventType, void *EventInfo, SGMiscInfo *MiscInfo)
01835 {
01836 switch (EventType)
01837 {
01838 case SGEVENT_MOUSECLICK:
01839 {
01840 SGMouseInfo *Mouse = GetMouseInfo(EventType, EventInfo);
01841
01842 if (Mouse != NULL && FormatRect.ContainsCoord(Mouse->Position))
01843 {
01844 INT32 XSize=0, YSize=0;
01845 if(SGLibDisplayItem::StartDrag(EventType, EventInfo, MiscInfo, &XSize, &YSize))
01846 {
01847 GalleryFillsDragInfo *DragFill;
01848
01849 DragFill = new GalleryFillsDragInfo(this, Mouse, MiscInfo,
01850 Mouse->MenuClick, XSize, YSize);
01851 if (DragFill != NULL)
01852 DragManagerOp::StartDrag(DragFill, GetListWindow());
01853 else
01854 if(LibraryGallery::TmpDraggingBitmap != NULL)
01855 {
01856 delete LibraryGallery::TmpDraggingBitmap;
01857 LibraryGallery::TmpDraggingBitmap = NULL;
01858 }
01859 }
01860 return TRUE;
01861 }
01862 }
01863 }
01864
01865 return(SGLibDisplayItem::HandleEvent(EventType, EventInfo, MiscInfo));
01866 }
01867
01868
01869
01870
01871
01872
01873
01874
01875
01876
01877
01878
01879
01880
01881
01882 SGFillsDragTarget::SGFillsDragTarget(DialogOp *TheDialog, CGadgetID TheGadget)
01883 : SGListDragTarget(TheDialog, TheGadget)
01884 {
01885 ERROR3IF(!TheDialog->IsKindOf(CC_RUNTIME_CLASS(LibFillsSGallery)),
01886 "You can only use SGFillsDragTargets with LibFillsSGallery dialogues!");
01887 }
01888
01889
01890
01891
01892
01893
01894
01895
01896
01897
01898
01899
01900
01901
01902
01903
01904
01905
01906
01907
01908
01909
01910
01911
01912 BOOL SGFillsDragTarget::ProcessEvent(DragEventType Event, DragInformation *pDragInfo,
01913 OilCoord *pMousePos, KeyPress* pKeyPress)
01914 {
01915 if (!pDragInfo->IsKindOf(CC_RUNTIME_CLASS(BitmapDragInformation)))
01916 return(FALSE);
01917
01918 SGDisplayNode *DraggedNode = NULL;
01919 BOOL IsSimpleBitmapDrag = TRUE;
01920
01921
01922 if (IS_A(pDragInfo, GalleryFillsDragInfo))
01923 {
01924 DraggedNode = ((GalleryFillsDragInfo *)pDragInfo)->GetDraggedFill();
01925 IsSimpleBitmapDrag = FALSE;
01926 }
01927
01928 if (DraggedNode != NULL)
01929 {
01930 switch(Event)
01931 {
01932 case DRAGEVENT_COMPLETED:
01933
01934 HandleDragCompleted((SuperGallery *) TargetDialog,
01935 DraggedNode, pMousePos, IsSimpleBitmapDrag);
01936 return(TRUE);
01937
01938
01939 case DRAGEVENT_MOUSESTOPPED:
01940 case DRAGEVENT_MOUSEMOVED:
01941 case DRAGEVENT_MOUSEIDLE:
01942 {
01943
01944
01945 SuperGallery *ParentGallery = (SuperGallery *) TargetDialog;
01946 if (ParentGallery != NULL && pMousePos != NULL && DraggedNode != NULL)
01947 {
01948
01949 DocCoord MousePos(pMousePos->x, pMousePos->y);
01950 SGDisplayNode *DestNode = ParentGallery->FindNodeUnderPointer(&MousePos);
01951
01952 if(DestNode != NULL)
01953 {
01954 SGDisplayNode *DestGroup = DestNode->GetParent();
01955 SGDisplayNode *SourceGroup = DraggedNode->GetParent();
01956
01957 if(DestGroup != NULL && SourceGroup != NULL)
01958 {
01959
01960 if(SourceGroup == DestGroup)
01961 return(DetermineCursorShape(ParentGallery, DraggedNode, pMousePos));
01962 }
01963 }
01964 }
01965 }
01966
01967
01968 CurrentCursorID = _R(IDC_DRAGGING_COLOUR);
01969 return TRUE;
01970 }
01971 }
01972
01973
01974 return(FALSE);
01975 }
01976
01977
01978
01979
01980
01981
01982
01983
01984
01985
01986
01987
01988 GalleryFillsDragInfo::GalleryFillsDragInfo()
01989 {
01990 ERROR3("Default GalleryFillsDragInfo constructor called");
01991 }
01992
01993
01994
01995
01996
01997
01998
01999
02000
02001
02002
02003
02004 GalleryFillsDragInfo::~GalleryFillsDragInfo()
02005 {
02006 if(LibraryGallery::TmpDraggingBitmap != NULL)
02007 {
02008 delete LibraryGallery::TmpDraggingBitmap;
02009 LibraryGallery::TmpDraggingBitmap = NULL;
02010 }
02011 }
02012
02013
02014
02015
02016
02017
02018
02019
02020
02021
02022
02023
02024
02025
02026
02027
02028
02029
02030
02031
02032
02033
02034 GalleryFillsDragInfo::GalleryFillsDragInfo(SGFillsItem *pSourceItem,
02035 SGMouseInfo *pMouseInfo, SGMiscInfo *pMiscInfo,
02036 BOOL IsAdjust, INT32 XSize, INT32 YSize)
02037 : BitmapDragInformation(LibraryGallery::TmpDraggingBitmap,
02038 XSize, YSize, 0, 0, IsAdjust)
02039 {
02040 SourceItem = pSourceItem;
02041
02042 MouseInfo = *pMouseInfo;
02043 MiscInfo = *pMiscInfo;
02044 }
02045
02046
02047
02048
02049
02050
02051
02052
02053
02054
02055
02056
02057
02058
02059
02060
02061
02062
02063
02064
02065 void GalleryFillsDragInfo::OnClick(INT32 Flags ,POINT Point)
02066 {
02067 if (SourceItem != NULL)
02068 SourceItem->DragWasReallyAClick(&MouseInfo, &MiscInfo);
02069 }
02070
02071
02072
02073
02074
02075
02076
02077
02078
02079
02080
02081
02082 UINT32 GalleryFillsDragInfo::GetCursorID(DragTarget* pDragTarget)
02083 {
02084 if (pDragTarget && pDragTarget->IS_KIND_OF(ViewDragTarget))
02085 {
02086 PageDropInfo PageDropInfo;
02087 ((ViewDragTarget*)pDragTarget)->GetDropInfo(&PageDropInfo);
02088
02089
02090 NodeRenderableInk* pObjectHit = PageDropInfo.pObjectHit;
02091 ObjectDragTarget TargetHit = PageDropInfo.TargetHit;
02092
02093
02094
02095
02096
02097
02098
02099
02100 if (pObjectHit && pObjectHit->IS_KIND_OF(NodeBitmap))
02101 TargetHit = NO_TARGET;
02102
02103 ClickModifiers ClickMods = ClickModifiers::GetClickModifiers();
02104 BOOL IsInside = ClickMods.Constrain;
02105
02106 if (!IsInside && pObjectHit && pObjectHit->IsCompound())
02107 {
02108 TargetHit = MANY_TARGET;
02109 }
02110
02111 UINT32 CanFill = IsInside ? _R(IDC_DROPINSIDEONFILL) : _R(IDC_CANDROPONFILL);
02112
02113 switch (TargetHit)
02114 {
02115 case FILL_TARGET:
02116 case LINE_TARGET:
02117 case STARTCOL_TARGET:
02118 case ENDCOL_TARGET:
02119 case ENDCOL2_TARGET:
02120 case ENDCOL3_TARGET:
02121 case MANY_TARGET:
02122 return CanFill;
02123
02124 case NO_TARGET:
02125
02126 return IsInside ? _R(IDC_CANFILLPAGE) : _R(IDC_CANDROPONPAGE);
02127
02128 };
02129
02130 return _R(IDC_CANDROPONPAGE);
02131 }
02132
02133 return _R(IDC_CANTDROP);
02134 }
02135
02136
02137
02138
02139
02140
02141
02142
02143
02144
02145
02146
02147 BOOL GalleryFillsDragInfo::GetStatusLineText(String_256 * TheText, DragTarget* pDragTarget)
02148 {
02149 ERROR2IF(TheText==NULL,FALSE,"NULL string in GetStatusLineText()");
02150
02151
02152
02153
02154 String_256 DragString;
02155 String_256 ItemName;
02156 SourceItem->GetNameText(&ItemName);
02157 PageDropInfo PageDropInfo;
02158 NodeRenderableInk* pObjectHit = NULL;
02159 ObjectDragTarget TargetHit;
02160 if (pDragTarget && pDragTarget->IS_KIND_OF(ViewDragTarget))
02161 {
02162 ((ViewDragTarget*)pDragTarget)->GetDropInfo(&PageDropInfo);
02163 pObjectHit = PageDropInfo.pObjectHit;
02164 TargetHit = PageDropInfo.TargetHit;
02165 }
02166
02167
02168 PathName fillPath;
02169 SourceItem->GetFileName(&fillPath);
02170
02171
02172 DragString.MakeMsg(_R(IDS_FILLS_DRAGGING), (TCHAR *)ItemName);
02173
02174 if (pDragTarget && pDragTarget->IS_KIND_OF(ViewDragTarget))
02175 {
02176 DragString += String_8(_R(IDS_SGDFONTS_STAT_COLON_SEP));
02177
02178 String_256 ObjectDesc = _R(IDS_SGLFILLS_THIS_OBJECT);
02179
02180 if (pObjectHit)
02181 {
02182 ObjectDesc = pObjectHit->Describe(FALSE);
02183 }
02184
02185 if (pObjectHit && pObjectHit->IS_KIND_OF(NodeBitmap))
02186 TargetHit = NO_TARGET;
02187
02188 ClickModifiers ClickMods = ClickModifiers::GetClickModifiers();
02189 BOOL IsInside = ClickMods.Constrain;
02190
02191 if (!IsInside && pObjectHit && pObjectHit->IsCompound())
02192 {
02193 TargetHit = MANY_TARGET;
02194 }
02195
02196 switch (TargetHit)
02197 {
02198 case FILL_TARGET:
02199 case LINE_TARGET:
02200 case STARTCOL_TARGET:
02201 case ENDCOL_TARGET:
02202 case ENDCOL2_TARGET:
02203 case ENDCOL3_TARGET:
02204 DragString += String_64(_R(IDS_SGLFILLS_DROP_TO_APPLY));
02205 DragString += ObjectDesc;
02206 if (IsInside)
02207 DragString += String_64(_R(IDS_SGLFILLS_ALONE));
02208 break;
02209 case MANY_TARGET:
02210 DragString += String_64(_R(IDS_SGLFILLS_DROP_TO_APPLY));
02211 DragString += ObjectDesc;
02212 DragString += String_64(_R(IDS_SGLFILLS_DROP_INSIDE));
02213 break;
02214
02215 case NO_TARGET:
02216 {
02217 if (IsInside)
02218 {
02219 DragString += String_256(_R(IDS_DRAGBMP_DROP_SETPAGEBACKGROUND));
02220 }
02221 else
02222 {
02223
02224 String_64 DropToThis(_R(IDS_FILLS_INSERT_BITMAP_TO_PAGE));
02225 DragString += DropToThis;
02226 }
02227 break;
02228 }
02229 }
02230
02231 *TheText = DragString;
02232 return TRUE;
02233 }
02234
02235 *TheText = DragString;
02236
02237 return TRUE;
02238 }
02239
02240
02241
02242
02243
02244
02245
02246
02247
02248
02249
02250
02251
02252
02253
02254 BOOL GalleryFillsDragInfo::OnPageDrop(ViewDragTarget* pDragTarget)
02255 {
02256 enum FillTypeEnum FillType;
02257
02258 PageDropInfo ThePageDropInfo;
02259 ((ViewDragTarget*)pDragTarget)->GetDropInfo(&ThePageDropInfo);
02260 NodeRenderableInk* pObjectHit = ThePageDropInfo.pObjectHit;
02261
02262 PathName FileName;
02263 SGLibDisplayItem *FillItem = SourceItem;
02264
02265 if (!FillItem->GetFileName(&FileName))
02266 return FALSE;
02267
02268 if (!FileName.IsValid(FileName.GetPath()))
02269 {
02270 ERROR3("LibFillsSGallery::ImportFills - Filename is invalid");
02271 return FALSE;
02272 }
02273
02274 BOOL NeedToDownload;
02275 if (_taccess(FileName.GetPath(), 0) == -1)
02276 NeedToDownload = TRUE;
02277 else
02278 NeedToDownload = FALSE;
02279
02280 BOOL Constrain = KeyPress::IsConstrainPressed();
02281 if (Constrain && !pObjectHit)
02282 FillType = SetBackground;
02283 else if (pObjectHit && !pObjectHit->IS_KIND_OF(NodeBitmap))
02284 FillType = ApplyToObject;
02285 else
02286 FillType = AddToPage;
02287
02288 if (!NeedToDownload)
02289
02290 {
02291 TRACEUSER( "Jonathan", _T("Fills: File in cache\n"));
02292 OpDescriptor* pOpDesc = OpDescriptor::FindOpDescriptor(CC_RUNTIME_CLASS(OpBitmapImport));
02293
02294 if (pOpDesc != 0)
02295 {
02296 BitmapImportParam Param;
02297
02298 Param.File = &FileName;
02299 Param.Result = TRUE;
02300 Param.pTargetDoc = Document::GetSelected();
02301 Param.FillType = FillType;
02302 Param.pSpread = ThePageDropInfo.pSpread;
02303 Param.DropPos = ThePageDropInfo.DropPos;
02304 Param.TagObjectValid = false;
02305 Param.pObject = pObjectHit;
02306 Param.pObjectValid = true;
02307
02308
02309 pOpDesc->Invoke((OpParam *) &Param);
02310
02311 if (!Param.Result)
02312 {
02313 ERROR3("Problem importing file from cache");
02314 return FALSE;
02315 }
02316 }
02317 }
02318 else
02319
02320 {
02321 TRACEUSER( "Jonathan", _T("Fills: File not in cache : downloading\n"));
02322 OpDescriptor* pOpDesc = OpDescriptor::FindOpDescriptor(CC_RUNTIME_CLASS(OpAsynchBitmapImport));
02323
02324 if (pOpDesc != 0)
02325 {
02326 AsynchBitmapImportParam* Param = new AsynchBitmapImportParam;
02327
02328 if (!Param)
02329 return FALSE;
02330 Library* pLibrary = SourceItem->GetParentLibrary();
02331 String_256 strFileURL = FileName.GetPath();
02332 pLibrary->LocalPath2URL(&strFileURL);
02333 Param->file = FileName;
02334 Param->pTargetDoc = Document::GetSelected();
02335 Param->strURL = strFileURL;
02336 String_256 strDescription;
02337 SourceItem->GetNameText(&strDescription);
02338 Param->strDescription = _T("'");
02339 Param->strDescription += strDescription;
02340 Param->strDescription += _T("'");
02341 Param->type = TYPE_FILL;
02342 Param->FillType = FillType;
02343 Param->priority = AsynchDownload::PRIORITY_HIGH;
02344 Param->pSpread = ThePageDropInfo.pSpread;
02345 Param->DropPos = ThePageDropInfo.DropPos;
02346 Param->pObjectValid = false;
02347 if (FillType == ApplyToObject || FillType == ApplyToObjectAsTransp)
02348 {
02349 Param->TagObjectToFill = pObjectHit->GetTag();
02350 Param->TagObjectValid = true;
02351 }
02352
02353
02354 pOpDesc->Invoke((OpParam *) Param);
02355 }
02356 }
02357 return TRUE;
02358 }