LibClipartSGallery Class Reference

The LibClipart SuperGallery class. More...

#include <sglcart.h>

Inheritance diagram for LibClipartSGallery:

LibraryGallery SuperGallery DialogOp Operation MessageHandler ListItem CCObject SimpleCCObject List of all members.

Public Member Functions

 LibClipartSGallery ()
 LibClipartSGallery default constructor.
 ~LibClipartSGallery ()
 LibClipartSGallery destructor.
INT32 GetClipTheme () const
INT32 SetClipTheme (INT32 nNewIndex)
virtual BOOL IsLibraryGalleryWithNonLibraryGroups (void)
 To check if we're a dedicated library gallery, or a half+half (like the font gallery).
virtual MsgResult Message (Msg *Message)
 A standard message handler, really.
void ProfileRedraw (ReDrawInfoType *Param)
virtual BOOL CanSearchKeywords (void)
 Used to determine if this type of gallery supports keyword searching. This one does.
virtual SGDisplayGroupAddLibraryGroup (Library *LibraryToDisplay, INT32 NumItems)
 Create a library group, as opposed to a display group Notes:.
virtual BOOL CanCreateIndexes (void)
 To determine if this gallery can generate indexes or not.
virtual BOOL GetDefaults (String_256 *DefaultIndex, String_256 *IndexDesc, SGLibType *Type)
 To determine various library gallery default properties.
virtual BOOL GetLibraryDirectoryName (String_256 *LibDirName)
 Get the default CD directory name for the gallery.
virtual BOOL CheckForIndexMatch (StringBase *Txt)
 To see whether we should add this line of the index.txt file to this gallery.
virtual void WorkOutSectionName (String_256 *Section)
 Returns the section name to use in the grm file.
virtual BOOL GetQuietStatus (void)
 Get the Quiet status of the gallery.
virtual void SetQuietStatus (BOOL Status)
 Set the Quiet status of the gallery.
virtual BOOL ScanForLocation (SGLibType Type, StringBase *Result)
 Searches all the drives for a CDROM drive. If it finds the Camelot CD mount here at Xara HQ, we point to that instead. Notes:.
virtual BOOL InitMenuCommands (void)
 Initialises any menu commands that this gallery needs.
virtual BOOL BuildCommandMenu (GalleryContextMenu *TheMenu, SGMenuID MenuID)
 To build a menu of commands to be popped up over the gallery.
virtual OpState GetCommandState (StringBase *CommandID, String_256 *ShadeReason)
 To determine the state of a given menu item. This method is an exact parallel to an Op's GetState method (in fact, it is called by an Op's GetState).
virtual void DoCommand (StringBase *CommandID)
 To apply a given command when it is chosen from the menu.
virtual SGLibType GetGalleryType ()
virtual String_256GetDefaultLibraryPath ()
void SelectionHasChanged (void)
 To inform the gallery that the selection has changed in some way. We need to grey different buttons on different occasions Notes:.
void ModeHasChanged (void)
 To toggle the visible/selectable items of this gallery between clipart and web themes Notes:.
virtual BOOL PreCreate (void)
 The LibClipartSGallery PreCreate handler. This overrides the base class PreCreate function. It is called at the very beginning of the SuperGallery::Create method, before the window has been created.
virtual BOOL OnGetButtonClicked (void)
 Attempts to download the main web resource index file from our web site, parse it and create corresponding gallery folders.
virtual BOOL RemoveWebFolders (SGLibType type)
 Reclaims space taken up by downloaded files of a certain type on the local machine.

Static Public Member Functions

static LibClipartSGalleryInstance ()
static BOOL Init (void)
static BOOL ImportClipart (BOOL NewDocument, LibraryGallery *pSourceGallery)
 To load/import all the selected clipart items one by one into camelot. Notes:.

Public Attributes

bool m_bRedraw
bool m_bRestore

Static Public Attributes

static String_256 DefaultLibraryPath = ClipartPath
static String_256 ClipartPath = TEXT("D:\\clipart")
static String_256 WebThemePath = TEXT("D:\\themes")
static INT32 DefaultDisplayMode = 0
static UINT32 DefaultSortKeys = 1
static String_256 BatchSaveLocation = ""
static BOOL DoSounds = TRUE
static LibClipartSGalleryThisGallery = NULL
static BOOL QuietStatus = FALSE

Protected Member Functions

void DoShadeGallery (BOOL ShadeIt)
 To un-grey the options... button when there are no docs Notes:.
virtual BOOL ApplyAction (SGActionType Action)
 Applies certain conventional gallery actions (usually associated with gallery buttons, for new, edit, delete, etc).
virtual SGDisplayItemAddLibraryItem (SGDisplayGroup *LibraryGroup, Library *ParentLib, LibraryIndex ItemIndex, BOOL bNew=FALSE)
 Called by the Library class to create a display item for every item in a newly-scanned library file. It is essentially a callback to the gallery which requested that the library be scanned.
BOOL LoadAndSave (void)
 To load all the selected clipart items one by one into camelot and then to save them out again - useful for updating documents.
void HandleDragStart (DragMessage *DragMsg)
 Checks a DragMessage to see if it is a colour drag. If it is, then it creates a drag target for this gallerys listbox.
SGDisplayItemCopyDisplayItem (SGDisplayItem *SourceItem, SGDisplayGroup *DestGroup, SGDisplayItem *TargetPosition)
 "Copies" the existing node in the tree in an appropriate fashion.
BOOL BrowseClicked (void)
 Pops up the browse box and lets a new location be set for the clipart directory.
void SortGallery (void)
 Sorts the contents of the gallery in an alphabetical fashion, whilst keeping the old sort key status... Notes:.

Private Attributes

INT32 m_nClipTheme

Static Private Attributes

static LibClipartSGallerym_pInstance = 0

Detailed Description

The LibClipart SuperGallery class.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com> (Based on template code by Jason)
Date:
27/1/95 (Based on the Colour SGallery code)
Notes: SuperGalleries are specced in a number of docs including specs.doc ("super" gallery extensions) specs.doc (gallery basic ui) There is also howtouse.doc which describes creating a supergallery

See also:
SuperGallery; SGDisplayLibClipart; LibraryGallery

Definition at line 130 of file sglcart.h.


Constructor & Destructor Documentation

LibClipartSGallery::LibClipartSGallery  ) 
 

LibClipartSGallery default constructor.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
27/1/95 (base generated in sgbase.cpp)

Definition at line 249 of file sglcart.cpp.

00250 {
00251     LibClipartSGallery::ThisGallery = this;
00252     m_bDiscardWebFolders = FALSE;
00253     // Default gallery size
00254     CSize Size(((333 * 2) - 32) - 32, 256);
00255     SetGallerySize(Size);
00256     m_pInstance = this;
00257     m_nClipTheme = 0;
00258     m_bRedraw = false;
00259 }

LibClipartSGallery::~LibClipartSGallery  ) 
 

LibClipartSGallery destructor.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
27/1/95 (base generated in sgbase.cpp)

Definition at line 273 of file sglcart.cpp.

00274 {
00275     TRACEUSER( "Matt", _T("~LibClipartSGallery\n"));
00276 
00277     OpenLibFiles.DeleteAll();       // Ensure all open libraries are closed
00278     LibClipartSGallery::ThisGallery = NULL;
00279     m_pInstance = 0;
00280 }


Member Function Documentation

SGDisplayGroup * LibClipartSGallery::AddLibraryGroup Library LibraryToDisplay,
INT32  NumItems
[virtual]
 

Create a library group, as opposed to a display group Notes:.

Author:
Richard_Millican (Xara Group Ltd) <camelotdev@xara.com>
Date:
20/4/95
Parameters:
LibraryToDisplay - Pointer to the library associated with the group [INPUTS] NumItems - Number of items in the group
Returns:
The newly created library group, or NULL if there were problems

Reimplemented from LibraryGallery.

Definition at line 2044 of file sglcart.cpp.

02045 {
02046     TRACEUSER( "Matt", _T("Add library group called in clipart gallery\n"));
02047     ERROR3IF(LibraryToDisplay == NULL, "LibClipartSGallery::AddLibraryGroup - NULL parameter is illegal");
02048 
02049     if (DisplayTree == NULL)
02050     {
02051         ERROR3("LibClipartSGallery::AddLibraryGroup called before the DisplayTree was initialised!");
02052         return(NULL);
02053     }
02054 
02055     //Flag the gallery to redraw and check the group against the state of the web themes / clipart box
02056     m_bRedraw = true;
02057     SGLibGroup *TheGroup = (SGLibGroup *)DisplayTree->FindSubtree(this, NULL, LibraryToDisplay);
02058 
02059     if (TheGroup == NULL)
02060     {
02061         // No existing group for that library, so create a new one
02062         TheGroup = new SGLibGroup(this, NULL, LibraryToDisplay);
02063 
02064         if (TheGroup == NULL)               // Failed!
02065             return(NULL);
02066         
02067         // And add it to our display tree
02068         if (((GetClipTheme() == 0) && (LibraryToDisplay->Type == SGLib_ClipArt_WebThemes)) || ((GetClipTheme() == 1) && (LibraryToDisplay->Type == SGLib_ClipArt)))
02069         {
02070             TheGroup->Flags.Invisible = true;
02071             TheGroup->Flags.CanSelect = false;
02072         }
02073         DisplayTree->AddItem(TheGroup);
02074         TRACEUSER( "Matt", _T("...Add library group has just added the item to the display tree\n"));
02075     }
02076     else
02077     {
02078         if (((GetClipTheme() == 0) && (LibraryToDisplay->Type == SGLib_ClipArt_WebThemes)) || ((GetClipTheme() == 1) && (LibraryToDisplay->Type == SGLib_ClipArt)))
02079         {
02080             TheGroup->Flags.Invisible = true;
02081             TheGroup->Flags.CanSelect = false;
02082         }
02083 
02084         TheGroup->DestroySubtree(FALSE);    // Delete all items in the group
02085     }
02086 
02087     return(TheGroup);
02088 }

SGDisplayItem * LibClipartSGallery::AddLibraryItem SGDisplayGroup LibraryGroup,
Library ParentLib,
LibraryIndex  ItemIndex,
BOOL  bNew = FALSE
[protected, virtual]
 

Called by the Library class to create a display item for every item in a newly-scanned library file. It is essentially a callback to the gallery which requested that the library be scanned.

Parameters:
LibraryGroup - The group to add the item into [INPUTS] ParentLib - (For cross checking inputs) the library you allege the above group is for. ItemIndex - The Library generated index for this item
Returns:
NULL, or a pointer to the created item
Notes: This method MUST BE OVERRIDDEN by the derived gallery that opens the library, in order to create appropriate SGDisplayItem-derived nodes for the things in the library (e.g. a clipart library gallery will have to create items that display clipart thumbnails)

See also:
SuperGallery::AddLibraryGroup; SuperGallery::RemoveLibraryGroup

Reimplemented from LibraryGallery.

Definition at line 1802 of file sglcart.cpp.

01803 {
01804     TRACEUSER( "Matt", _T("Add library item called in clipart gallery\n"));
01805     ERROR3IF(LibraryGroup == NULL || ParentLib == NULL,
01806                 "SuperGallery::AddLibraryItem - NULL params are illegal");
01807 
01808     ERROR3IF(LibraryGroup->GetParentLibrary() != ParentLib,
01809                 "SuperGallery::AddLibraryitem - The DisplayGroup is not for the same library!");
01810 
01811     // Create a clipart library item
01812 
01813     SGClipartItem *NewItem = new SGClipartItem(ItemIndex, bNew);
01814 
01815     // Check for, and don't include if found in the Studio group, the line:
01816     // Rolex.art,Rather expensive watch,36,Rolex,Object|Time|Watch|Machine,113852
01817     if((ParentLib->Title != NULL) && (ParentLib->Title->Sub((String_8)"Studio") == 0))
01818     {
01819         String_256 TmpPath;
01820         BOOL ok = ParentLib->GetFilename(ItemIndex, &TmpPath, FALSE);
01821 
01822         if(ok)
01823         {
01824             INT32 Size = NewItem->GetFileSize(ParentLib);
01825             if(Size == 113852)
01826             {
01827                 String_256 TmpPath;
01828                 BOOL ok = ParentLib->GetFilename(ItemIndex, &TmpPath, FALSE);
01829 
01830                 if(TmpPath == (String_16)"Rolex.art")
01831                 {
01832                     delete NewItem;
01833                     NewItem = FALSE;
01834                 }
01835             }
01836         }
01837     }
01838 
01839 /*  SGSortKey SortKeys[MaxSGSortKeys];
01840     for (INT32 i = 0; i < MaxSGSortKeys; i++)
01841     {
01842         SortKeys[i].SortKey  = 0;
01843         SortKeys[i].Reversed = FALSE;
01844     }
01845 
01846     SortKeys[0].SortKey  = 1;*/
01847 
01848     if (NewItem != NULL)
01849         LibraryGroup->AddItem(NewItem/*, (SGSortKey *)SortKeys*/);
01850 
01851     return(NewItem);
01852 }

BOOL LibClipartSGallery::ApplyAction SGActionType  Action  )  [protected, virtual]
 

Applies certain conventional gallery actions (usually associated with gallery buttons, for new, edit, delete, etc).

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
27/1/95 (base generated in sgbase.cpp)
Parameters:
Action - Indicates what action to apply [INPUTS]
Returns:
TRUE to indicate successful handling of the action, or FALSE to indicate failure
See also:
SGActionType

Reimplemented from LibraryGallery.

Definition at line 489 of file sglcart.cpp.

00490 {
00491     // No display tree? Better forget about it then!
00492     if (DisplayTree == NULL)
00493         return(FALSE);
00494 
00495     switch(Action)
00496     {
00497         case SGACTION_REDEFINE:
00498             break;
00499 
00500         case SGACTION_APPLY:
00501             ImportClipart(TRUE, this);
00502             break;
00503         
00504 /*      case SGACTION_APPLYADJUST:
00505             ImportClipart(FALSE);
00506             break;*/
00507 
00508         case SGACTION_EDIT:
00509             // Ignored - libraries are currently read-only
00510             break;
00511 
00512         case SGACTION_DELETE:
00513             // Ignored - libraries are currently read-only
00514             break;
00515 
00516         case SGACTION_SETOPTIONS:   // Set values in the options dialogue as it is opened
00517             {
00518                 if (CurrentOptionsDlg == NULL)
00519                     return(FALSE);
00520             
00521                 CurrentOptionsDlg->AddDisplayModeName(_R(IDS_GALLERYDM_LARGE));     // 0
00522                 CurrentOptionsDlg->AddDisplayModeName(_R(IDS_GALLERYDM_FULLINFO));  // 1
00523                 CurrentOptionsDlg->AddDisplayModeName(_R(IDS_GALLERYDM_SMALL));     // 2
00524             }
00525             break;
00526 
00527         case SGACTION_SETSORTMODE:
00528             {
00529                 if (CurrentSortDlg == NULL)
00530                     return(FALSE);
00531 
00532                 CurrentSortDlg->AddSortKeyName(_R(IDS_SORTBY_NAME));
00533                 CurrentSortDlg->AddSortKeyName(_R(IDS_SORTBY_MEMORY));
00534                 CurrentSortDlg->AddSortKeyName(_R(IDS_SORTBY_NAMELENGTH));
00535                 CurrentSortDlg->AddSortKeyName(_R(IDS_SORTBY_FILETYPE));
00536             }
00537                                     
00538             break;
00539 
00540 
00541         case SGACTION_DISPLAYMODECHANGED:
00542             if(DisplayMode >= 3) DisplayMode = 0;
00543             LibClipartSGallery::DefaultDisplayMode = DisplayMode;
00544             InvalidateCachedFormat();
00545             ReformatAndRedrawIfNecessary();
00546             //ForceRedrawOfList();
00547             break;
00548     
00549         default:
00550             return(SuperGallery::ApplyAction(Action));
00551             break;
00552     }
00553 
00554     return(TRUE);
00555 }

BOOL LibClipartSGallery::BrowseClicked void   )  [protected, virtual]
 

Pops up the browse box and lets a new location be set for the clipart directory.

Author:
Richard_Millican (Xara Group Ltd) <camelotdev@xara.com>
Date:
2/5/95
Parameters:
[INPUTS] 
Returns:
TRUE if the gallery has new stuff in it (FALSE if cancel clicked, etc)...

Reimplemented from LibraryGallery.

Definition at line 761 of file sglcart.cpp.

00762 {
00763     if (GetClipTheme() == 0)
00764     {
00765         return (LibraryGallery::BrowseClicked(&DefaultLibraryPath, SGLib_ClipArt, _R(IDS_REMOVE_OLD_GOUPS_CLIPART)));
00766     }
00767     else
00768     {
00769         return (LibraryGallery::BrowseClicked(&DefaultLibraryPath, SGLib_ClipArt_WebThemes, _R(IDS_REMOVE_OLD_GOUPS_CLIPART)));
00770     }
00771 }

BOOL LibClipartSGallery::BuildCommandMenu GalleryContextMenu TheMenu,
SGMenuID  MenuID
[virtual]
 

To build a menu of commands to be popped up over the gallery.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
15/9/95
Parameters:
TheMenu - The menu to add commands to [INPUTS] MenuID - The type of menu (over-list or from-options-button) to create
Returns:
TRUE if it succeeded
Notes: Override this method to stop the default menus being built

Reimplemented from SuperGallery.

Definition at line 2234 of file sglcart.cpp.

02235 {
02236     BOOL ok = TRUE;
02237 
02238     if (MenuID == SGMENU_OPTIONS)
02239     {
02240         // Options menu
02241         ok = ok && AddCommand(TheMenu, (StringBase *) &SGCmd_Add);  
02242         ok = ok && AddCommand(TheMenu, (StringBase *) &SGCmd_EmptyClipartCache, TRUE);
02243 
02244         ok = ok && AddCommand(TheMenu, (StringBase *) &SGCmd_Find);
02245         ok = ok && AddCommand(TheMenu, (StringBase *) &SGCmd_Sort);
02246         ok = ok && AddCommand(TheMenu, (StringBase *) &SGCmd_Properties);
02247     }
02248     else
02249     {
02250         // Over-list menu
02251         ok = ok && AddCommand(TheMenu, (StringBase *) &SGCmd_Open);
02252         ok = ok && AddCommand(TheMenu, (StringBase *) &SGCmd_Import);
02253         ok = ok && AddCommand(TheMenu, (StringBase *) &SGCmd_Remove, TRUE);     // With separator
02254 
02255         SGDisplayGroup *TheGroup = FindCommandGroup();      // Fold or unfold as appropriate
02256         if (TheGroup == NULL || !TheGroup->Flags.Folded)
02257             ok = ok && AddCommand(TheMenu, (StringBase *) &SGCmd_FoldGroup);
02258         else
02259             ok = ok && AddCommand(TheMenu, (StringBase *) &SGCmd_UnfoldGroup);
02260 
02261         ok = ok && AddCommand(TheMenu, (StringBase *) &SGCmd_PrevGroup);
02262         ok = ok && AddCommand(TheMenu, (StringBase *) &SGCmd_NextGroup);
02263     }
02264 
02265     return(ok);
02266 }

BOOL LibClipartSGallery::CanCreateIndexes void   )  [virtual]
 

To determine if this gallery can generate indexes or not.

Author:
Richard_Millican (Xara Group Ltd) <camelotdev@xara.com>
Date:
18/12/95
Returns:
TRUE to if index generation is possible

Reimplemented from LibraryGallery.

Definition at line 787 of file sglcart.cpp.

00788 {
00789     return TRUE;
00790 }

BOOL LibClipartSGallery::CanSearchKeywords void   )  [virtual]
 

Used to determine if this type of gallery supports keyword searching. This one does.

Author:
Richard_Millican (Xara Group Ltd) <camelotdev@xara.com>
Date:
30/3/95
Returns:
TRUE

Reimplemented from LibraryGallery.

Definition at line 2001 of file sglcart.cpp.

02002 {
02003     return(TRUE);
02004 }

BOOL LibClipartSGallery::CheckForIndexMatch StringBase Txt  )  [virtual]
 

To see whether we should add this line of the index.txt file to this gallery.

Author:
Richard_Millican (Xara Group Ltd) <camelotdev@xara.com>
Date:
18/12/95
Parameters:
Txt - Last column entry in the index.txt file (" A") [INPUTS]
Returns:
TRUE if this signifies the gallery in question...

Reimplemented from LibraryGallery.

Definition at line 889 of file sglcart.cpp.

00890 {
00891     BOOL Match = FALSE;
00892 
00893     // Artwork, and Bitmaps...
00894     if(((Txt->Sub(String_8("A"))!=-1) || (Txt->Sub(String_8("a"))!=-1)) ) Match = TRUE;
00895     if(((Txt->Sub(String_8("B"))!=-1) || (Txt->Sub(String_8("b"))!=-1)) ) Match = TRUE;             
00896 
00897     return Match;
00898 }

SGDisplayItem * LibClipartSGallery::CopyDisplayItem SGDisplayItem SourceItem,
SGDisplayGroup DestGroup,
SGDisplayItem TargetPosition
[protected, virtual]
 

"Copies" the existing node in the tree in an appropriate fashion.

Parameters:
SourceItem - The item to copy elsewhere in the tree (see below) [INPUTS]
DestGroup - The group into which the item should be inserted

TargetPosition - NULL (to add the copied item to the end of the sibling list), or points to an item BEFORE which the copied item will be inserted.

Returns:
NULL (failed) or a pointer to the new (copied) display item
This method is normally called when a gallery-organising drag completes, and it is discovered that the dragged item(s) have been dragged to a different display group.

Notes: This method should be overridden by derived galleries to provide appropriate behaviour (some galleries (e.g colour) will copy the real-item that the given display-item references to the new group (document), while other galleries (layer) may just move the item after all).

Note the handy InsertCopiedItem and MoveBefore/After methods which are available to take all of the hard work out of copying/moving items!

See the body of this method in the source code for example pseudocode. For real code, see the Colour Gallery (sgcolour.cpp)

See also:
SuperGallery::InsertCopiedItem; SGDisplayItem::MoveBefore; SGDisplayItem::MoveAfter; ColourSGallery::CopyDisplayItem

Reimplemented from LibraryGallery.

Definition at line 2132 of file sglcart.cpp.

02134 {
02135     TRACEUSER( "Matt", _T("Copy display item called in clipart gallery\n"));
02136     if(SourceItem == NULL || DestGroup == NULL)
02137     {
02138         ERROR3("LibClipartSGallery::CopyDisplayItem -> Illegal NULL param");
02139         return NULL;
02140     }
02141 
02142     // Check if we've dragged from one group to another and warn if that's the case
02143     if(DestGroup->IsKindOf(CC_RUNTIME_CLASS(SGLibGroup)))
02144     {
02145         SGDisplayNode *SourceGroup = SourceItem->GetParent();
02146         if((SGDisplayGroup *)SourceGroup != DestGroup)
02147         {
02148             // "Can't move clipart between groups."
02149             InformError(_R(IDS_CLIPART_BETWEEN_GROUPS), _R(IDS_OK));
02150             Error::ClearError();
02151         }
02152     }
02153 
02154     return(NULL);
02155 }

void LibClipartSGallery::DoCommand StringBase CommandID  )  [virtual]
 

To apply a given command when it is chosen from the menu.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
15/9/95
Parameters:
CommandID - The String ID of the command [INPUTS]
Notes: Override this method to provide handling for your special commands. Call the base class if you don't recognise the command, so that it can handle standard commands.

The base class handles all of these (maybe more - see the base class help) Properties, Sort, Find; New, Edit, Delete, Redefine; (it calls ApplyAction as appropriate) NextGroup, PrevGroup, FoldGroup, UnfoldGroup;

Reimplemented from SuperGallery.

Definition at line 2364 of file sglcart.cpp.

02365 {
02366     if (*CommandID == SGCmd_Open)                                           // --- Open
02367         ImportClipart(TRUE, this);
02368     else if (*CommandID == SGCmd_Import)                                    // --- Import
02369         ImportClipart(FALSE, this);
02370     else if (*CommandID == SGCmd_Add)                                       // --- Add clipart
02371         BrowseClicked();
02372     else if (*CommandID == SGCmd_EmptyClipartCache)                 // --- Remove web folders
02373     {
02374         RemoveWebFolders(SGLib_ClipArt); //This will actually remove both clipart and web themes!
02375     }
02376     else if (*CommandID == SGCmd_Remove)                                    // --- Remove
02377     {
02378         RemoveSelectedLibraries(TRUE);
02379         UpdateGRMFile();
02380     }
02381     else
02382         SuperGallery::DoCommand(CommandID);     // Unknown command- pass to the base class
02383 }

void LibClipartSGallery::DoShadeGallery BOOL  ShadeIt  )  [protected, virtual]
 

To un-grey the options... button when there are no docs Notes:.

Author:
Richard_Millican (Xara Group Ltd) <camelotdev@xara.com> (based on Jason code)
Date:
28/3/95

Reimplemented from LibraryGallery.

Definition at line 1968 of file sglcart.cpp.

01969 {
01970     if (DisplayTree == NULL)
01971         return;
01972 
01973     // Keep this here always
01974     EnableGadget(_R(IDC_GALLERY_MENU), TRUE);
01975 
01976     if(ShadeIt)
01977     {
01978         EnableGadget(_R(IDC_LIBGAL_IMPORT), FALSE);
01979     }
01980 
01981     EnableGadget(_R(IDC_LIBGAL_ADD_CLIPART), TRUE);
01982 
01983     // Standard library buttons
01984     LibraryGallery::DoShadeGallery(ShadeIt);
01985 }

INT32 LibClipartSGallery::GetClipTheme  )  const
 

Author:
Priestley (Xara Group Ltd) <camelotdev@xara.com>
Date:
18/09/2000
Returns:
The index of the theme/clipart currently shown in the selector.
See also:
LibClipartSGallery::SetPropertyIndex

Definition at line 2395 of file sglcart.cpp.

02396 {
02397     return m_nClipTheme;
02398 }

OpState LibClipartSGallery::GetCommandState StringBase CommandID,
String_256 ShadeReason
[virtual]
 

To determine the state of a given menu item. This method is an exact parallel to an Op's GetState method (in fact, it is called by an Op's GetState).

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
15/9/95
Parameters:
CommandID - TheString ID of the command [INPUTS]
ShadeReason - If you return (OpState.Greyed == TRUE) then this should be filled [OUTPUTS] ion with the reason that the item is shaded/greyed.
Returns:
An OpState indicating the current menu item state.
Notes: Override this method to provide state info for your special commands Call the base class for unknown commands to allow it to handle them for you

The base class handles all of these (maybe more - see the base class help) Properties, Sort, Find; New, Edit, Delete, Redefine; NextGroup, PrevGroup, FoldGroup, UnfoldGroup;

Reimplemented from SuperGallery.

Definition at line 2296 of file sglcart.cpp.

02297 {
02298     OpState State;
02299 
02300     if (*CommandID == SGCmd_Add)                                            // --- Add (always available)
02301         return(State);
02302 
02303     if (*CommandID == SGCmd_EmptyClipartCache)
02304     {
02305         if (m_bDiscardWebFolders)
02306             State.Greyed = TRUE;
02307         return (State);
02308     }
02309 
02310     if (*CommandID == SGCmd_Open || *CommandID == SGCmd_Import)             // --- Open/Import
02311     {
02312         if (GetSelectedItemCount() < 1)
02313         {
02314             State.Greyed = TRUE;
02315             ShadeReason->MakeMsg(_R(IDS_SGSHADE_NOSEL));
02316         }
02317     }
02318     else if (*CommandID == SGCmd_Remove)                                    // --- Remove
02319     {
02320         if (GetSelectedGroupCount() < 1)
02321         {
02322             State.Greyed = TRUE;
02323             ShadeReason->MakeMsg(_R(IDS_SGSHADE_NOSELGROUP));
02324         }
02325     }
02326     else if (*CommandID == SGCmd_Properties)                                    // --- Properties - disabled if the gallery is currently downloading thumnails
02327     {
02328         if (!m_lstPendingThumbs.empty())
02329         {
02330             State.Greyed = TRUE;
02331             ShadeReason->MakeMsg(_R(IDS_SGSHADE_DOWNLOADING));
02332         }
02333     }
02334     else
02335         return(SuperGallery::GetCommandState(CommandID, ShadeReason));      // Unknown command- pass to baseclass
02336 
02337     return(State);
02338 }

virtual String_256* LibClipartSGallery::GetDefaultLibraryPath  )  [inline, virtual]
 

Reimplemented from LibraryGallery.

Definition at line 219 of file sglcart.h.

00219 {return &DefaultLibraryPath;}

BOOL LibClipartSGallery::GetDefaults String_256 DefaultIndex,
String_256 IndexDesc,
SGLibType *  Type
[virtual]
 

To determine various library gallery default properties.

Author:
Richard_Millican (Xara Group Ltd) <camelotdev@xara.com>
Date:
18/12/95
Parameters:
DefaultIndex - The filename for the default index file (Xaraclip.txt) [OUTPUTS] IndexDesc - Description of the index / gallery (Clipart) Type - Default library type associated with this gallery
Returns:
TRUE if this was overridden successfully

Reimplemented from LibraryGallery.

Definition at line 810 of file sglcart.cpp.

00811 {
00812     TRACEUSER( "Matt", _T("Getting defaults for clipart gallery\n"));
00813     if(DefaultIndex != NULL)
00814     {
00815         //Set the correct info filename for the current gallery style
00816         if (GetClipTheme() == 0)
00817         {
00818             *DefaultIndex = _R(IDS_LIBRARIES_CLIPART_FILENAME); // "XaraClip.txt";
00819         }
00820         else
00821         {
00822             *DefaultIndex = _R(IDS_LIBRARIES_WEBTHEMES_FILENAME);   // "XaraThem.txt";
00823         }
00824     }
00825 
00826     if(IndexDesc != NULL)
00827         *IndexDesc = _R(IDS_LIBRARIES_CLIPART_DESC);        // "Clipart";
00828 
00829     if(Type != NULL)
00830     {
00831         //Set the type of the gallery to be 'Clipart' or 'Web Themes'
00832         //so that the base classes attempt to load file info from the
00833         //correct URL - real handy...
00834         if (GetClipTheme() == 0)
00835         {
00836             *Type = SGLib_ClipArt;
00837         }
00838         else
00839         {
00840             *Type = SGLib_ClipArt_WebThemes;
00841         }
00842     }
00843 
00844     return TRUE;
00845 }

virtual SGLibType LibClipartSGallery::GetGalleryType  )  [inline, virtual]
 

Reimplemented from LibraryGallery.

Definition at line 207 of file sglcart.h.

00208     {
00209         if (GetClipTheme() == 0)
00210         {
00211             return SGLib_ClipArt;
00212         }
00213         else
00214         {
00215             return SGLib_ClipArt_WebThemes;
00216         }
00217     }

BOOL LibClipartSGallery::GetLibraryDirectoryName String_256 LibDirName  )  [virtual]
 

Get the default CD directory name for the gallery.

Author:
Richard_Millican (Xara Group Ltd) <camelotdev@xara.com>
Date:
19/12/95
Parameters:
LibDirName - Returns the Default directory (on the clipart CD) for the gallery [OUTPUTS]
Returns:
TRUE if overridden and directory obtained...

Reimplemented from LibraryGallery.

Definition at line 861 of file sglcart.cpp.

00862 {
00863     TRACEUSER( "Matt", _T("Getting library directory name for clipart gallery\n"));
00864     if (GetClipTheme() == 0)
00865     {
00866         LibDirName->MakeMsg(_R(IDS_LIBRARIES_CLIPART_DIRNAME));
00867     }
00868     else
00869     {
00870         LibDirName->MakeMsg(_R(IDS_LIBRARIES_WEBTHEMES_DIRNAME));
00871     }
00872     return TRUE;
00873 }

BOOL LibClipartSGallery::GetQuietStatus void   )  [virtual]
 

Get the Quiet status of the gallery.

Author:
Richard_Millican (Xara Group Ltd) <camelotdev@xara.com>
Date:
19/12/95
Returns:
TRUE if Quiet has been pressed (SetQuiet status called with TRUE)

Reimplemented from LibraryGallery.

Definition at line 912 of file sglcart.cpp.

00913 {
00914     return LibClipartSGallery::QuietStatus;
00915 }

void LibClipartSGallery::HandleDragStart DragMessage DragMsg  )  [protected, virtual]
 

Checks a DragMessage to see if it is a colour drag. If it is, then it creates a drag target for this gallerys listbox.

Author:
Will_Cowling (Xara Group Ltd) <camelotdev@xara.com>
Date:
25/3/95
Parameters:
DragMsg - The DRAGSTARTED message that we've just recieved, indicating [INPUTS] the type of drag being started
Notes: Overrides the default base-class action. Calls down to the base class if it is not a colour drag, so that dragging of gallery groups is allowed

Reimplemented from LibraryGallery.

Definition at line 1030 of file sglcart.cpp.

01031 {
01032     // If it's a bitmap drag, add a target for our window. If not, let the base class
01033     // have a look at it (to see if it is a gallery item being dragged)
01034     if (DragMsg->pInfo->IsKindOf(CC_RUNTIME_CLASS(GalleryClipartDragInfo)))
01035         SGClipartDragTarget *NewTarget = new SGClipartDragTarget(this, GetListGadgetID());
01036     else
01037         SuperGallery::HandleDragStart(DragMsg);
01038 }

BOOL LibClipartSGallery::ImportClipart BOOL  NewDocument,
LibraryGallery pSourceGallery
[static]
 

To load/import all the selected clipart items one by one into camelot. Notes:.

Author:
Richard_Millican (Xara Group Ltd) <camelotdev@xara.com>
Date:
19/3/95 Asynchronous import code added by Adrian, 12/96
Parameters:
NewDocument - Set to TRUE if you don't want the import to be added ontopof [INPUTS] the currently selected document.
[OUTPUTS] 
Returns:
TRUE if things went OK, false otherwise
See also:

Definition at line 1068 of file sglcart.cpp.

01069 {
01070     TRACEUSER( "Matt", _T("Importing clipart in clipart gallery\n"));
01071     if (pSourceGallery->DisplayTree == NULL)
01072     {
01073         ERROR3("LibClipartSGallery::ImportClipart No display tree - bad !");
01074         return FALSE;
01075     }
01076 
01077     if(Document::GetSelected() == NULL && !NewDocument)
01078     {
01079         return FALSE;
01080     }
01081                                       
01082     BOOL ok = TRUE;
01083 
01084 
01085     // Find the first selected item (if any) and get the next item to start searching from
01086     // If there is no selection, then get the first item
01087     SGDisplayNode *Item = pSourceGallery->DisplayTree->FindNextSelectedItem(NULL);
01088     String_256 ItemText;
01089 
01090     while (Item != NULL)
01091     {
01092         if(Item->IsKindOf(CC_RUNTIME_CLASS(SGClipartItem)) || Item->IsKindOf(CC_RUNTIME_CLASS(SGFillsItem)))
01093         {
01094             Item->GetNameText(&ItemText);
01095 
01096             if(Item->Flags.Selected)
01097             {
01098                 PathName FileName;      
01099                 SGLibDisplayItem *ClipItem = (SGLibDisplayItem *) Item;
01100             
01101                 //if (Lib != NULL)
01102                 ok = ClipItem->GetFileName(&FileName);
01103 
01104                 if(ok)
01105                 {
01106                     // Bodge for clipart CD - 'Cow' in LScape should point to "Moo.tif", not just "Moo"
01107                     if(FileName.GetFileName(FALSE) == (String_256)"Moo")
01108                     {
01109                         INT32 Size = ClipItem->GetFileSize(NULL);
01110                         if(Size == 1080904)
01111                             FileName.SetType("TIF");
01112                     }
01113 
01114                     if(!FileName.IsValid(FileName.GetPath()))
01115                     {
01116                         ERROR3("LibClipartSGallery::ImportClipart - Filename is invalid");
01117                         return FALSE;
01118                     }
01119 
01120                     // Check if file has a long filename, and use that if it does...
01121                     String_256 FilePath((const TCHAR *)FileName.GetPath());
01122                     String_256 LongFileName;
01123                     BOOL LongPath = FileUtil::GetLongFileName((LPTSTR)FilePath, (LPTSTR)LongFileName, 255);
01124                     if(LongPath)
01125                     {
01126                         FilePath = FileName.GetLocation(TRUE);
01127                         FilePath += LongFileName;
01128                     }
01129 
01130                     // Check if the file really exists on the local drive
01131                     Library* pLibrary = ClipItem->GetParentLibrary();
01132                     if (!pLibrary)
01133                     {
01134                         ERROR3("Illegal NULL pointer");
01135                         return FALSE;
01136                     }
01137                     BOOL bIsLocalFile;
01138                     if (!pLibrary->IsWebLibrary())
01139                         bIsLocalFile = TRUE;
01140                     else 
01141                         bIsLocalFile = (_access((TCHAR*) FilePath, 0) != -1);
01142                         
01143                     if(NewDocument)
01144                     {
01145                         if (bIsLocalFile)
01146                         {
01147                             CWinApp* pApp = AfxGetApp();
01148                             BaseFileDialog::SelectedFilter = 0;
01149             
01150                             // Open a document
01151                             CCamDoc* pDoc = (CCamDoc*) pApp->OpenDocumentFile((TCHAR *)FilePath);
01152 
01153                             // And redraw the imported document
01154                             if(pDoc) pDoc->GetKernelDoc()->ForceRedraw();
01155                         }
01156                         else // do an asynch import
01157                         {
01158                             goto ASYNCH_IMPORT;
01159                         }
01160                     }
01161                     else
01162                     {
01163                         // Invoke the clipart import operation so that we get Undo.
01164                         if (bIsLocalFile) // if the file is local we do a normal import Op
01165                         {
01166 
01167                             OpDescriptor* pOpDesc = OpDescriptor::FindOpDescriptor(CC_RUNTIME_CLASS(OpClipartImport));
01168 
01169                             if (pOpDesc != NULL)
01170                             {
01171                                 ClipartImportParam Param;
01172 
01173                                 PathName FullPathName(FilePath);
01174 
01175                                 // Set up the parameters which we require to do the import operation
01176                                 Param.File = &FullPathName;
01177                                 Param.Import = !NewDocument;
01178                                 Param.Result = TRUE;
01179 
01180                                 // Import the specified file
01181                                 pOpDesc->Invoke((OpParam *) &Param);
01182 
01183                                 ok = Param.Result;
01184                                 if(!ok)
01185                                 {
01186                                     ERROR3("LibClipartSGallery::ImportClipart - Problem importing file");
01187                                     return FALSE;
01188                                 }
01189                             }
01190                         }
01191                         else // try an asynch import
01192                         {
01193 ASYNCH_IMPORT:
01194                             String_256 strFileURL = FilePath;
01195                             pLibrary->LocalPath2URL(&strFileURL);
01196                             OpDescriptor* pOpDesc = OpDescriptor::FindOpDescriptor(CC_RUNTIME_CLASS(OpAsynchClipartImport));
01197 
01198                             if (pOpDesc != NULL)
01199                             {
01200                                 AsynchClipartImportParam* Param = new AsynchClipartImportParam;
01201                                 ERROR2IF(!Param, FALSE, "Memory allocation error");
01202                                 // Set up the parameters which we require to import the clipart
01203                                 Param->File.SetPathName((TCHAR *)FilePath);
01204                                 String_256 strDescription;
01205                                 ClipItem->GetNameText(&strDescription);
01206                                 Param->strDescription = _T("'");
01207                                 Param->strDescription += strDescription;
01208                                 Param->strDescription += _T("'");
01209                                 Param->strURL = strFileURL;
01210                                 Param->Import = !NewDocument;
01211                                 Param->bDropped = FALSE;
01212                                 // Invoke the operation
01213                                 pOpDesc->Invoke((OpParam*) Param);
01214                             }
01215                         }
01216                     }
01217                 }
01218             }
01219         }
01220         Item = SGDisplayRoot::FindNextItemInTree(Item);
01221     }
01222 
01223     return TRUE;
01224 }

BOOL LibClipartSGallery::Init void   )  [static]
 

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
23/2/95
Returns:
TRUE if the sgallery initialised successfully FALSE if it failed to initialise

Reimplemented from SimpleCCObject.

Definition at line 312 of file sglcart.cpp.

00313 {
00314     TRACEUSER( "Matt", _T("Init clipart gallery\n"));
00315 #ifdef _BATCHING
00316         
00317     GetApplication()->DeclareSection(TEXT("Batching"), 6);
00318     GetApplication()->DeclarePref(TEXT("Batching"), TEXT("OutputDirectory"), &LibClipartSGallery::BatchSaveLocation);
00319 
00320 #endif
00321 
00322     if (!OpClipartImport::Init())
00323         return(FALSE);
00324 
00325     if (!OpAsynchClipartImport::Init())
00326         return(FALSE);
00327 
00328 
00329     return(TRUE);
00330 }

BOOL LibClipartSGallery::InitMenuCommands void   )  [virtual]
 

Initialises any menu commands that this gallery needs.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
18/9/95
Returns:
TRUE for success
Notes: Will only create the menu commands once - further calls in the future will return TRUE immediately wihtout doing anything.

Reimplemented from SuperGallery.

Definition at line 2175 of file sglcart.cpp.

02176 {
02177     TRACEUSER( "Matt", _T("Clipart Gallery InitMenuCommands() called\n"));
02178     static BOOL MenusInitialised = FALSE;
02179 
02180     BOOL ok = TRUE;
02181 
02182     if (!MenusInitialised)
02183     {
02184         // Initialise menu command Ops
02185 
02186         // "Standard" entries for options menu
02187         ok = ok && InitMenuCommand((StringBase *) &SGCmd_Find, _R(IDS_SGMENU_FIND));
02188         ok = ok && InitMenuCommand((StringBase *) &SGCmd_Sort, _R(IDS_SGMENU_SORT));
02189         ok = ok && InitMenuCommand((StringBase *) &SGCmd_Properties, _R(IDS_SGMENU_PROPERTIES));
02190 
02191         // "Special" entries for options menu
02192         ok = ok && InitMenuCommand((StringBase *) &SGCmd_Add, _R(IDS_SGMENU_ADDCLIPART));
02193         ok = ok && InitMenuCommand((StringBase *) &SGCmd_EmptyClipartCache, _R(IDS_SGMENU_EMPTYCLIPARTCACHE));
02194 
02195         // "Special" entries for over-list menu
02196         ok = ok && InitMenuCommand((StringBase *) &SGCmd_Open, _R(IDS_SGMENU_OPEN));
02197         ok = ok && InitMenuCommand((StringBase *) &SGCmd_Import, _R(IDS_SGMENU_IMPORT));
02198         ok = ok && InitMenuCommand((StringBase *) &SGCmd_Remove, _R(IDS_SGMENU_REMOVE));
02199 
02200         // "Standard" commands for over-list menu
02201         ok = ok && InitMenuCommand((StringBase *) &SGCmd_FoldGroup, _R(IDS_SGMENU_FOLD));
02202         ok = ok && InitMenuCommand((StringBase *) &SGCmd_UnfoldGroup, _R(IDS_SGMENU_UNFOLD));
02203 
02204         ok = ok && InitMenuCommand((StringBase *) &SGCmd_NextGroup, _R(IDS_SGMENU_NEXTGROUP));
02205         ok = ok && InitMenuCommand((StringBase *) &SGCmd_PrevGroup, _R(IDS_SGMENU_PREVGROUP));
02206 
02207 
02208         MenusInitialised = TRUE;
02209     }
02210 
02211     return(ok);
02212 }

LibClipartSGallery * LibClipartSGallery::Instance  )  [static]
 

Author:
Priestley (Xara Group Ltd) <camelotdev@xara.com>
Date:
18/09/2000
Returns:
The current LibClipartSGallery object.

Definition at line 291 of file sglcart.cpp.

00292 {
00293     ERROR3IF(m_pInstance == 0, "LibClipartSGallery::Instance: no gallery");
00294     return m_pInstance;
00295 }

virtual BOOL LibClipartSGallery::IsLibraryGalleryWithNonLibraryGroups void   )  [inline, virtual]
 

To check if we're a dedicated library gallery, or a half+half (like the font gallery).

Author:
Richard_Millican (Xara Group Ltd) <camelotdev@xara.com>
Date:
19/12/95
Returns:
TRUE if the SuperGallery is a LibraryGallery, yet also can contain non-library groups

Reimplemented from LibraryGallery.

Definition at line 145 of file sglcart.h.

00145 {return TRUE;};

BOOL LibClipartSGallery::LoadAndSave void   )  [protected]
 

To load all the selected clipart items one by one into camelot and then to save them out again - useful for updating documents.

Author:
Richard_Millican (Xara Group Ltd) <camelotdev@xara.com>
Date:
19/3/95
Parameters:
[INPUTS] 
[OUTPUTS] 
Returns:
TRUE if things went OK, false otherwise
Notes: Code for this should only be compiled in DEBUG, and calling this is not guaranteed to leave XS in a stable state on exit.
See also:

Definition at line 1245 of file sglcart.cpp.

01246 {
01247 
01248 #ifdef _BATCHING
01249 
01250     if (DisplayTree == NULL)
01251     {
01252         ERROR3("LibClipartSGallery::LoadAndSave No display tree - bad !");
01253         return FALSE;
01254     }
01255 
01256     // For centering items...
01257     PageTab PTab;
01258     if(!PTab.Init())
01259     {
01260         ERROR3("Can't init page resizing stuff...");
01261         return FALSE;
01262     }
01263 
01264     // Find the first selected item (if any) and get the next item to start searching from
01265     // If there is no selection, then get the first item
01266     SGDisplayNode *Item = DisplayTree->FindNextSelectedItem(NULL);
01267 
01268     String_256 ItemText;
01269 
01270     while (Item != NULL)
01271     {
01272         if(Item->IsKindOf(CC_RUNTIME_CLASS(SGClipartItem)))
01273         {
01274             Item->GetNameText(&ItemText);
01275 
01276             // Update selected ones, or all after first selected ?
01277             if(Item->Flags.Selected || TRUE)
01278             {
01279                 PathName FileName;      
01280                 SGLibDisplayItem *ClipItem = (SGLibDisplayItem *) Item;
01281 
01282                 BOOL ok = TRUE;
01283             
01284                 //if (Lib != NULL)
01285                 ok = ClipItem->GetFileName(&FileName);
01286 
01287                 // Check if we're an ai file, don't do it if we're not !
01288                 String_8 Ending;
01289                 if(ok) Ending = FileName.GetType();
01290                 if(ok) Ending.toLower();
01291                 if(/*Ending == (String_8)"art" &&*/ ok)
01292                 {
01293                     // Load a file
01294                     CWinApp* pApp = AfxGetApp();
01295                     BaseFileDialog::SelectedFilter = 0;
01296 
01297                     if(!FileName.IsValid(FileName.GetPath()))
01298                     {
01299                         ERROR3("Filename is invalid");
01300                     }
01301 
01302                     String_256 Path(FileName.GetPath());
01303                     
01304                     // Batching system will use this directory to put its output in
01305                     String_256 OutputPath(LibClipartSGallery::BatchSaveLocation);
01306                     
01307                     // Unless it == "" of course...
01308                     if(OutputPath.Length() == 0)
01309                         OutputPath = Path;
01310                     else
01311                     {
01312                         if(OutputPath[OutputPath.Length()-1] != '\\')
01313                             OutputPath += TEXT("\\");
01314                         OutputPath += FileName.GetFileName(TRUE);
01315                     }
01316 
01317                     PathName OutputPathART(OutputPath);
01318                     OutputPathART.SetType((String_256)"XAR");
01319                     String_256 SavePath(OutputPathART.GetPath());
01320 
01321                     Error::ClearError();
01322     
01323                     // Only do it if there isn't an art file there already...
01324                 //  if(!SGLibOil::FileExists(&OutputPathART))
01325                 //  {           
01326                 
01327                         MonotonicTime Time;
01328                         INT32 OpenTime = Time.Sample();
01329                         INT32 InitialSize = SGLibOil::FileSize(&FileName);
01330 
01331 // If this is not defined, we just load each file in turn, and spool any problems to 'load.txt'
01332 //#define SAVEASWELL
01333 
01334 #ifndef SAVEASWELL
01335                         FILE *FP = _tfopen("C:\\load.txt", "a"); // Debug
01336                         if(FP != NULL)
01337                         {
01338                             _ftprintf(FP, "Loading: %s\r\n", (TCHAR *)Path); // Debug
01339                             fclose(FP);
01340                         }
01341 #endif
01342 
01343                         // Open a document
01344                         CCamDoc* pDoc = (CCamDoc*) pApp->OpenDocumentFile((TCHAR *)Path);
01345                         /*Document *CurDoc = Document::GetSelected();
01346                             CCamDoc* pDoc = CurDoc->GetOilDoc();*/
01347 #ifndef SAVEASWELL
01348 
01349                         if(pDoc == NULL)
01350                         {
01351                             FP = _tfopen("C:\\batch.txt", "a"); // Debug
01352                             if(FP != NULL)
01353                             {
01354                                 _ftprintf(FP, "Problems: %s\r\n", (TCHAR *)Path); // Debug
01355                                 fclose(FP);
01356                             }
01357                         }
01358                         else
01359                         {
01360                             Error::ClearError();
01361                             // Close a document
01362                             ((CCamDoc *) (((CMDIFrameWnd *)                                      
01363                                 ((AfxGetApp())->m_pMainWnd))->MDIGetActive()    //Get Active Child Window
01364                                 )->GetActiveDocument()                          //Get Active Document
01365                                 )->OnFileClose();                               //Close Active Document
01366                         }   
01367                         Error::ClearError();
01368 
01369 #else
01370                         OpenTime = Time.Sample() - OpenTime;
01371 
01372                         if (pDoc != NULL)
01373                         {
01374                             INT32 Pass = 0;
01375 
01376                             /*do {*/
01377                                 /*******************/
01378 
01379                                 // Remove empty layers and rename clipart layer to 'Clipart'
01380 
01381 #if 0
01382                                 Document* OurDocument = pDoc->GetKernelDoc();
01383                                 Spread* OurSpread = OurDocument->FindFirstSpread();
01384                                 Page* CurrentPage = OurSpread->FindFirstPageInSpread(); 
01385 
01386                                 if(OurDocument == NULL || OurSpread == NULL || CurrentPage == NULL)
01387                                 {
01388                                     Error::SetError(0, String_256("NULL Page/Spread/Doc in batcher..."), 0); // Debug
01389                                     InformWarning(0, _R(IDS_OK), NULL);
01390                                     Error::ClearError();
01391                                 }
01392                                 else
01393                                 {
01394                                     OurDocument->SetCurrent();
01395 
01396                                     /* remove messed up layers from tree */
01397                                     Layer* pLayer = OurSpread->FindFirstLayer();
01398 
01399                                     INT32 Count = 0;
01400                                     while(pLayer)
01401                                     {
01402                                         Node* pNode = pLayer->FindFirstChild();
01403                                         BOOL ChildFound = FALSE;
01404 
01405                                         while (pNode != NULL && !ChildFound)
01406                                         {
01407                                             ChildFound = pNode->IsBounded(); //IsKindOf(CC_RUNTIME_CLASS(NodeRenderableBounded));
01408                                             pNode = pNode->FindNext();
01409                                         }
01410 
01411                                         Layer *tLayer = pLayer->FindNextLayer();
01412 
01413                                         if(!ChildFound)
01414                                             pLayer->UnlinkNodeFromTree();
01415                                         else
01416                                         {
01417                                             pLayer->SetVisible(TRUE);
01418                                             pLayer->SetLocked(FALSE);
01419                                             Count ++;
01420                                         }
01421 
01422                                         pLayer = tLayer;
01423                                     }
01424 
01425 
01426                                     if(Count == 1)
01427                                     {
01428                                         Layer* pLayer = OurSpread->FindFirstLayer();
01429                                         if(pLayer)
01430                                             pLayer->SetLayerID(String_256("Clipart")); // Debug
01431                                     }
01432 
01433 
01434                                     /**************************************/
01435 
01436                                     // Sort the page orientation out, centre the clipart and zoom to it
01437         
01438                                     DocRect OurItemRect = OurSpread->GetBoundingRect();
01439                                     DocRect OurPageRect = CurrentPage->GetPageRect();
01440 
01441                                     if (AppPrefsDlg::pPageSizesList != NULL)
01442                                     {
01443                                         PageId PageChosen = A4;
01444                                         MILLIPOINT Width;
01445                                         MILLIPOINT Height;
01446                                         AppPrefsDlg::pPageSizesList->GetSizeFromPageId(PageChosen, &Width, &Height);
01447 
01448                                         // Bodge it to landscape / portrait...
01449                                         if(    ((OurItemRect.Width() > OurItemRect.Height()) && (OurPageRect.Width() < OurPageRect.Height())) 
01450                                             || ((OurItemRect.Width() < OurItemRect.Height()) && (OurPageRect.Width() > OurPageRect.Height())) )
01451                                         {
01452                                             MILLIPOINT Tmp = Width;
01453                                             Width = Height;
01454                                             Height = Tmp;
01455                                         }
01456 
01457                                         TRACEUSER( "Richard", _T("width %d height %d in MP\n"),Width,Height);
01458 
01459                                         // Set up the parameters which we require to do the page resizing operation 
01460                                         PageResizeInfo Param;
01461 
01462                                         // Set up the new page parameters that we want
01463                                         Param.Height = Height;
01464                                         Param.Width = Width;
01465 
01466                                         MILLIPOINT Margin = Width / 2;
01467                                         if(Height < Width)
01468                                             Margin = Height / 2;
01469 
01470                                         Param.Margin = Margin;
01471                                         Param.Bleed = 0; //Bleed;
01472                                         Param.Portrait = (Width < Height); //Portrait;
01473                                         Param.Dps = FALSE; //Dps;
01474                                         Param.ShowDropShadow = TRUE; //DropShadow;
01475                                         // Set up the new default grid settings that we want 
01476                                         //Param.GridSpacing = CM_MP_VAL;
01477                                         //Param.GridSubDivisions = 2;
01478                                         //Param.GridUnits = CENTIMETRES;
01479                                         //Param.TypeOfGrid = RECTANGULAR;
01480 
01481                                         Param.pSpread = OurSpread;
01482                                         OptionsTabs::SetCurrentDocAndSpread(OurDocument); // set up the spread that we are currently workign on
01483 
01484                                         // Invoke the page centre / resize function...
01485                                         PTab.InvokeResizeAndCentre(&Param);
01486 
01487                                         // BODGE BODGE BODGE to make fakeinvoke work when the spread's not in view...
01488                                         LibClipartSGallery::DefaultSortKeys = TRUE;
01489 
01490                                         //OpZoomDescriptor::FakeInvoke(OPTOKEN_ZOOMSPREAD);
01491                                         OpZoomDescriptor::FakeInvoke(OPTOKEN_ZOOMDRAWING);
01492 
01493                                         LibClipartSGallery::DefaultSortKeys = FALSE;
01494 
01495                                         OurDocument->ForceRedraw();
01496                                     }
01497                                 }
01498 /*                              Pass ++;
01499                             } while(Pass < 5);*/
01500 
01501                             /*Document**/ OurDocument = pDoc->GetKernelDoc();
01502                             /*Spread**/ OurSpread = OurDocument->FindFirstSpread();
01503                             /*Page* */ CurrentPage = OurSpread->FindFirstPageInSpread(); 
01504 
01505                             DocRect OurItemRect = OurSpread->GetBoundingRect();
01506                             DocRect OurPageRect = CurrentPage->GetPageRect();
01507 
01508                             BOOL PossiblyOutsidePage = FALSE;
01509                             /*if(    (OurItemRect.lo.x < OurPageRect.lo.x)
01510                                 || (OurItemRect.hi.x > OurPageRect.hi.x)
01511                                 || (OurItemRect.lo.y < OurPageRect.lo.y)
01512                                 || (OurItemRect.hi.y > OurPageRect.hi.y) )
01513                                 PossiblyOutsidePage = TRUE;*/
01514 
01515                             /*******************/
01516 
01517                             // Remove duplicate colours
01518 
01519                             Document *TheDoc = OurDocument;
01520 
01521                             ColourList *ParentList = TheDoc->GetIndexedColours();
01522 
01523                             INT32 TotalItems = ParentList->GetCount();
01524                             INT32 DeletedItems = 0;
01525 
01526                             IndexedColour **KillList = new IndexedColourPtr[TotalItems+1];
01527                             if (KillList != NULL)
01528                             {
01529 
01530                                 DWORD KillIndex = 0;
01531                                 IndexedColour *Ptr = ParentList->GetUndeletedHead();
01532 
01533                                 while (Ptr != NULL)
01534                                 {
01535                                     if(!Ptr->IsInUse())
01536                                     {
01537                                         DeletedItems++;
01538                                         KillList[KillIndex++] = Ptr;
01539                                     }
01540 
01541                                     Ptr = ParentList->GetUndeletedNext(Ptr);
01542                                 }
01543     
01544                                 KillList[KillIndex] = NULL;     // NULL terminate the list
01545 
01546                                 // Delete (hide, with undo actually) the given colours
01547                                 ColourManager::HideColours(ParentList, KillList, TRUE);
01548 
01549                                 // HideColours has made a copy of this list for itself, so we are responsible
01550                                 // for deleting our original list
01551                                 delete [] KillList;
01552                             }
01553 
01554                             // Only add a new palette if there are now no colours...
01555                             if(TotalItems == DeletedItems)
01556                             {
01557                                 /*******************/
01558 
01559                                 // Import a blank document containing the 'default' colours
01560 
01561                                 PathName FileName((String_256)"C:\\pal.art");
01562                                 if(SGLibOil::FileExists(&FileName))
01563                                 {
01564                                     // Invoke the clipart import operation so that we get Undo.
01565                                     OpDescriptor* pOpDesc = OpDescriptor::FindOpDescriptor(CC_RUNTIME_CLASS(OpClipartImport));
01566 
01567                                     if (pOpDesc != NULL)
01568                                     {
01569                                         ClipartImportParam Param;
01570 
01571                                         // Set up the parameters which we require to do the page resizing operation 
01572                                         Param.File = &FileName;
01573                                         Param.Import = TRUE;
01574                                         Param.Result = TRUE;
01575 
01576                                         // Go for it!
01577                                         pOpDesc->Invoke((OpParam *) &Param);
01578 
01579                                         ok = Param.Result;
01580 
01581                                         if(!ok)
01582                                         {
01583                                             ERROR3("Batching... Problem importing file");
01584                                             return FALSE;
01585                                         }
01586                                     }
01587                                 }
01588 
01589                                 /*******************/
01590                             }
01591     
01592 #endif
01593                             INT32 CloseTime = Time.Sample();
01594 
01595                             BOOL Worked = TRUE;
01596 #if 0   //#ifndef NEW_NATIVE_FILTER
01597         // Save a document
01598                             Worked = pDoc->OnSaveDocument((TCHAR *)SavePath) && Worked;
01599                             Error::ClearError();
01600 
01601                             INT32 FinalSize = SGLibOil::FileSize(&OutputPathART);
01602                             CloseTime = Time.Sample() - CloseTime;
01603 #endif
01604 #if 0   // Save a document, but ensure it is in the old format!
01605                             Worked = pDoc->OnSaveVersion1Document((TCHAR *)SavePath) && Worked;
01606                             Error::ClearError();
01607 
01608                             INT32 FinalSize = SGLibOil::FileSize(&OutputPathART);
01609                             CloseTime = Time.Sample() - CloseTime;
01610 
01611 #endif
01612 
01613                             PathName path(SavePath);
01614 
01615 #if 0   // Do an Export of the file as a version 2 Native file
01616                             path.SetType(TEXT("CXN"));
01617                             path.SetType(TEXT("xar"));  // new files have this extension now
01618                             CCDiskFile file(path, ios::out | ios::binary | ios::trunc);
01619                             BOOL NativeExportWorked = InvokeNativeFileOp(OPTOKEN_SAVEASNATIVEV2, &file, FILTERID_NATIVE);
01620                             Error::ClearError();
01621                             Worked = NativeExportWorked && Worked;
01622 #endif
01623 #if 0   // Do an Export of the file as a Web file
01624                             path.SetType(TEXT("web"));
01625                             CCDiskFile webfile(path, ios::out | ios::binary | ios::trunc);
01626                             BOOL WebExportWorked = InvokeNativeFileOp(OPTOKEN_NATIVESAVE, &webfile, FILTERID_WEB);
01627                             Error::ClearError();
01628                             Worked = WebExportWorked && Worked;
01629 #endif
01630 #if 1   // Rename the file as a munged 8.3 file if saving in the same place - none of this is wheat germ and shouldn't
01631         // be in the kernel, however it only apears in _BATCHING debug builds
01632                             if (LibClipartSGallery::BatchSaveLocation.Length() == 0)
01633                             {
01634                                 // To perform the rename is a bit tricky 'cos we don't know the long filename,
01635                                 // but we can reference the original file through its short name, renaming it
01636                                 // to a temporary name then renaming the temporary back to the short name. We
01637                                 // can not simply rename the long to the short 'cos the operating system will
01638                                 // complain that the short name (i.e. the long one) already exists.
01639                                 BOOL RenameWorked = FALSE;
01640                                 String_256 TempName = FileName.GetLocation();   // temp file in this location
01641                                 // create a temp filename with an obvious prefix
01642                                 char * temmmmmp = _tempnam( TempName, TEXT("~XARA") );
01643                                 if( temmmmmp != NULL )  // pointer returned by _tempnam
01644                                 {
01645                                     // copy the name we created
01646                                     TempName = temmmmmp;
01647                                     // free memory allocated by _tempnam
01648                                     free( temmmmmp );
01649                                     temmmmmp = NULL;
01650                                     // rename our original by referencing it through the munged name
01651                                     if ( 0 == rename( FileName.GetPath(), TempName ) )
01652                                     {
01653                                         // THIS DOESN'T WORK just get original name back
01654                                         // rename the temp file back to the munged (original) name
01655                                         RenameWorked = !rename( TempName, FileName.GetPath() );
01656                                     }
01657                                 }
01658                                 Worked = RenameWorked && Worked;
01659                             }
01660                             else
01661                             {
01662                                 // we are not saving in the same place so save as a web file like above
01663                                 path.SetType(TEXT("web"));
01664                                 CCDiskFile webfile(path, ios::out | ios::binary | ios::trunc);
01665                                 BOOL WebExportWorked = InvokeNativeFileOp(OPTOKEN_NATIVESAVE, &webfile, FILTERID_WEB);
01666                                 Error::ClearError();
01667                                 Worked = WebExportWorked && Worked;
01668                             }
01669 #endif
01670 #if 1   // Do an Export of the file as a png thumbnail file to the "XaraInfo" directory
01671 
01672                             Document* OurDocument = pDoc->GetKernelDoc();
01673 PORTNOTE("spread", "Multi-spread warning!")
01674                             Spread* OurSpread = OurDocument->FindFirstSpread();
01675                             Layer* pLayer = OurSpread->FindFirstLayer();
01676                             DocRect Bounds;
01677                             while (pLayer != NULL)
01678                             {
01679                                 Bounds = Bounds.Union(pLayer->GetBoundingRect());
01680                                 pLayer = pLayer->FindNextLayer();
01681                             }       
01682 
01683                             INT32 d = Bounds.Width();
01684                             if (Bounds.Height() > d)
01685                                 d = Bounds.Height();
01686 
01687                             if (d < (72000*2))
01688                             {
01689                                 CCamDoc* pCCamDoc = OurDocument->GetOilDoc();
01690                                 pCCamDoc->ScaleContents(5.0,5.0);
01691                             }
01692 
01693                             
01694                             String_256 ThumbPathStr = path.GetLocation();
01695                             ThumbPathStr += String_16(_R(IDS_LIBRARIES_XARAINFO_DIRNAME));
01696                             ThumbPathStr += TEXT("\\");
01697                             ThumbPathStr += path.GetFileName();
01698 
01699                             path = PathName(ThumbPathStr);
01700 
01701                             path.SetType(TEXT("png"));
01702                             CCDiskFile thumbfile(path, ios::out | ios::binary | ios::trunc);
01703                             BOOL ThumbExportWorked = InvokeNativeFileOp(OPTOKEN_NATIVESAVE, &thumbfile, FILTERID_PREVIEW_PNG);
01704                             Error::ClearError();
01705                             Worked = ThumbExportWorked && Worked;
01706 #endif
01707 
01708 
01709                             // Close a document
01710                             if(Worked)
01711                                 ((CCamDoc *) (((CMDIFrameWnd *)                                      
01712                                     ((AfxGetApp())->m_pMainWnd))->MDIGetActive()    //Get Active Child Window
01713                                     )->GetActiveDocument()                          //Get Active Document
01714                                     )->OnFileClose();                               //Close Active Document
01715     
01716                             Error::ClearError();
01717                             //ERROR3IF(!Worked, "Ok, so it didn't work...");
01718 
01719                             /*FILE *FP = _tfopen("C:\\times.txt", "a");
01720                             if(FP != NULL)
01721                             {
01722                                 _ftprintf(FP, "%s\tLoad - %d\tSave - %d\tSize - %d to %d (%d%%)\r\n", (TCHAR *)SavePath, OpenTime, CloseTime, InitialSize, FinalSize, (FinalSize / InitialSize)*100);
01723                                 fclose(FP);
01724                             } */
01725 
01726                             if(!Worked)
01727                             {
01728                                 FILE *FP = _tfopen("C:\\batch.txt", "a"); // Debug
01729                                 if(FP != NULL)
01730                                 {
01731                                     _ftprintf(FP, "Problems  saving: %s\r\n", (TCHAR *)Path); // Debug
01732                                     fclose(FP);
01733                                 }
01734                             }
01735                             else
01736                             {
01737 #if 0
01738                                 if(PossiblyOutsidePage)
01739                                 {
01740                                     FILE *FP = _tfopen("C:\\batch.txt", "a"); // Debug
01741                                     if(FP != NULL)
01742                                     {
01743                                         _ftprintf(FP, "Possibly outside: %s\r\n", (TCHAR *)Path); // Debug
01744                                         fclose(FP);
01745                                     }
01746                                 }
01747 #endif
01748                             }
01749                         }
01750                         else
01751                         {
01752                             FILE *FP = _tfopen("C:\\batch.txt", "a"); // Debug
01753                             if(FP != NULL)
01754                             {
01755                                 _ftprintf(FP, "Problems loading: %s\r\n", (TCHAR *)Path); // Debug
01756                                 fclose(FP);
01757                             }
01758                         }
01759 #endif  //SAVEASWELL
01760                 //  }
01761                 }
01762             }
01763 
01764         }
01765 
01766         Item = SGDisplayRoot::FindNextItemInTree(Item);
01767     }
01768 
01769 #endif
01770     return TRUE;
01771 }

MsgResult LibClipartSGallery::Message Msg Message  )  [virtual]
 

A standard message handler, really.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
27/1/95 (base generated in sgbase.cpp)
Parameters:
Message - The message to handle [INPUTS]
Notes: Any messages that this does not handle must be passed down to the SuperGallery base class message handler.

NOTE WELL that the SuperGallery base class handler does some funky things for us - see SuperGallery::Message - such as deleting our display subtree for any document which dies (which, uncannily, would explain why they go away like that when you close documents ;-), and shading the gallery when there are no documents present. [To override this behaviour in these cases, you should respond to the message, and return OK rather than calling the base class message handler]

See also:
SuperGallery::Message

Reimplemented from LibraryGallery.

Definition at line 584 of file sglcart.cpp.

00585 {
00586     // Added by Craig Hamilton 18/1/01.
00587     static HANDLE   handle = NULL;
00588     CString         mutexName = "autorunMutex";
00589     // End added.
00590 
00591     // If we have no displaytree, then we have not been shown, or something terrible has
00592     // happened, so we don't bother handling any of these messages.
00593     if (DisplayTree == NULL)
00594         return(LibraryGallery::Message(Message));
00595 
00596     if (IS_OUR_DIALOG_MSG(Message))
00597     {
00598         DialogMsg* Msg = (DialogMsg*)Message;
00599 
00600         switch (Msg->DlgMsg)
00601         {
00602             case DIM_CREATE:
00603                 // Added by Craig Hamilton 18/1/01.
00604                 // This and the section of code of the same date in the DIM_CANCEL handler below
00605                 // deal with the creation and destruction of a kernel object that is recognised by
00606                 // the autorun. If this object exists then the autorun does not run. This is so
00607                 // that the user can enter their resources cd while the gallery is open and not be
00608                 // annoyed by the autorun appearing.
00609                 handle = CreateMutex(NULL,TRUE,mutexName);
00610                 // End added.
00611 
00612                 SGInit::UpdateGalleryButton(OPTOKEN_DISPLAYCLIPARTGALLERY, TRUE);
00613                 GalleryAboutToReOpen();
00614                 break;
00615 
00616             case DIM_CANCEL:
00617                 // Added by Craig Hamilton 18/1/01.
00618                 if(handle != NULL)
00619                 {
00620                     CloseHandle(handle);
00621                 }
00622                 // End added.
00623 
00624                 SGInit::UpdateGalleryButton(OPTOKEN_DISPLAYCLIPARTGALLERY, FALSE);
00625 
00626                 // Flush the thumbnail cache
00627                 BROADCAST_TO_CLASS(ThumbMessage(ThumbMessage::ThumbState::KILLCACHE, SGLib_ClipArt), DialogOp);
00628                 BROADCAST_TO_CLASS(ThumbMessage(ThumbMessage::ThumbState::KILLCACHE, SGLib_ClipArt_WebThemes), DialogOp);
00629                 BROADCAST_TO_CLASS(ThumbMessage(ThumbMessage::ThumbState::KILLCACHE, SGLib_Bitmap), DialogOp);
00630 
00631                 GalleryAboutToClose();
00632                 
00633                 break;
00634 
00635             case DIM_LFT_BN_CLICKED:
00636                 switch (Msg->GadgetID)
00637                 {
00638                     case _R(IDC_LIBGAL_OPEN):
00639                         ImportClipart(TRUE, this);
00640                         break;
00641 
00642                     case _R(IDC_GALLERY_HELP):      // Show help page
00643                         HelpUserTopic(_R(IDS_HELPPATH_Gallery_Clipart));
00644                         break;
00645 
00646 
00647                     case _R(IDC_LIBGAL_UPDATE):
00648 #ifdef _BATCHING     
00649                         LoadAndSave();
00650 #endif
00651                         break;
00652                     
00653                     case _R(IDC_LIBGAL_IMPORT):
00654                         ImportClipart(FALSE, this);
00655                         break;
00656 
00657                     case _R(IDC_LIBGAL_BROWSE):
00658                     case _R(IDC_LIBGAL_ADD_CLIPART):
00659                         BrowseClicked();
00660                         break;
00661 
00662                     case _R(IDC_BMPGAL_SAVE):
00663 #ifdef _DEBUG
00664                         {
00665                             SGDisplayNode *Item = DisplayTree->FindNextSelectedItem(NULL);
00666                             if(Item != NULL && Item->IsKindOf(CC_RUNTIME_CLASS(SGLibDisplayItem)))
00667                             {
00668                                 SGLibDisplayItem *LibItem = (SGLibDisplayItem *)Item;
00669 
00670                                 Library *Parent = LibItem->GetParentLibrary();
00671                                 if(Parent != NULL)
00672                                 {
00673                                     Error::SetError(0, TEXT("Renumber ID's ? (Doing this will mess external thumbnails up in a major way !)"), 0); // Debug
00674                                     INT32 ButtonPressed = InformWarning(0, _R(IDS_OK), _R(IDS_KEEP), _R(IDS_CANCEL), NULL);
00675 
00676                                     if(ButtonPressed != 3)
00677                                     {
00678                                         PathName *Source = Parent->ReturnIndexLocation();
00679                                         PathName Dest(*Source);
00680                                         Dest.SetType((String_256)"BAK");
00681                                         SGLibOil::FileCopy(Source, &Dest);
00682                                         Parent->SaveIndexInDisplayedOrder(Source, (ButtonPressed == 1));
00683                                     }
00684                                 }
00685                             }
00686                         }
00687 #endif
00688                         break;
00689                     
00690                     default:
00691                         break;
00692                 }
00693 
00694 #ifdef _PROFILE_REDRAW
00695             case DIM_REDRAW:
00696                 if (Msg->GadgetID == GetListGadgetID())
00697                 {
00698                     ProfileRedraw((ReDrawInfoType*) Msg->DlgMsgParam);
00699                     return(DialogBarOp::Message(Message));
00700                     break;
00701                 }
00702                 break;
00703 #endif
00704         }
00705     }
00706     else if (MESSAGE_IS_A(Message, DocChangingMsg))
00707     {
00708         DocChangingMsg *Msg = (DocChangingMsg *) Message;
00709         switch (Msg->State)
00710         {
00711             case DocChangingMsg::DocState::SELCHANGED:
00712                 if (Msg->pNewDoc == NULL)
00713                 {
00714                     // There is no selected doc - this can only mean there are no docs
00715                     // at all, so we had better shade the gallery
00716                     SuperGallery::ShadeGallery(TRUE);
00717                 }
00718                 else
00719                 {
00720                     // Possibly a new document
00721                     SuperGallery::ShadeGallery(FALSE);
00722                     SelectionHasChanged();
00723                 }
00724                 break;
00725         }
00726     }
00727     else if (MESSAGE_IS_A(Message, ThumbMessage) && DisplayTree != NULL)
00728     {
00729         ThumbMessage *Msg = (ThumbMessage *) Message;
00730 
00731         // If a library Thumb message comes around, flush the redraw stuff, etc
00732         if(Msg->State == ThumbMessage::ThumbState::CACHESIZECHANGED)
00733         {
00734             FlushBackgroundRedraws();
00735             ForceRedrawOfList();
00736         }
00737     }
00738 
00739     return(LibraryGallery::Message(Message));
00740 }    

void LibClipartSGallery::ModeHasChanged void   ) 
 

To toggle the visible/selectable items of this gallery between clipart and web themes Notes:.

Author:
Priestley (Xara Group Ltd) <camelotdev@xara.com>
Date:
21/09/2000

Definition at line 1868 of file sglcart.cpp.

01869 {
01870     TRACEUSER( "Matt", _T("MODE has changed called in clipart gallery\n"));
01871     if (DisplayTree == NULL)
01872     {
01873         return;
01874     }
01875 
01876     INT32 libindex = 0;
01877 
01878     //Search through our constructed library of clipart and themes...
01879     LibraryFile* pLibFile = (LibraryFile*) OpenLibFiles.GetHead();
01880     while (pLibFile)
01881     {
01882         Library* pLib = (Library*) pLibFile->Libraries.GetHead();
01883 
01884         while (pLib)
01885         {
01886             if ((pLib->Type == SGLib_ClipArt) && (GetClipTheme() != 0))
01887             {
01888                 pLib->ParentGroup->Flags.Invisible = true;
01889                 pLib->ParentGroup->Flags.CanSelect = false;
01890                 pLib->ParentGroup->Flags.Selected = false;
01891                 pLib->ParentGroup->Flags.Folded = true;
01892             }
01893             else if ((pLib->Type == SGLib_ClipArt_WebThemes) && (GetClipTheme() != 1))
01894             {
01895                 pLib->ParentGroup->Flags.Invisible = true;
01896                 pLib->ParentGroup->Flags.CanSelect = false;
01897                 pLib->ParentGroup->Flags.Selected = false;
01898                 pLib->ParentGroup->Flags.Folded = true;
01899             }
01900             else
01901             {
01902                 pLib->ParentGroup->Flags.Invisible = false;
01903                 pLib->ParentGroup->Flags.CanSelect = true;
01904             }
01905 
01906             pLib = (Library*) pLibFile->Libraries.GetNext(pLib);
01907         }
01908 
01909         pLibFile = (LibraryFile*) OpenLibFiles.GetNext(pLibFile);
01910     }
01911 
01912     ReformatNow(true);
01913 }

BOOL LibClipartSGallery::OnGetButtonClicked void   )  [virtual]
 

Attempts to download the main web resource index file from our web site, parse it and create corresponding gallery folders.

Author:
Priestley (Xara Group Ltd) <camelotdev@xara.com> - quite blatantly ripped from Adrian - then changed a lot...
Date:
19/09/2000
Parameters:
None [INPUTS]
Returns:
TRUE if web folders have been added successfully

Reimplemented from LibraryGallery.

Definition at line 3608 of file sglcart.cpp.

03609 {
03610     // Connect to the Net if not yet connected
03611     if (!InternetManager::AttemptConnection())
03612     {
03613         InformError(_R(IDS_NOTCONNECTED), _R(IDS_OK));
03614         return FALSE;
03615     }
03616 
03617     // (re)enable thumbnail downloading in case it has been stopped
03618     ResumeThumbnailDownloading();
03619     ForceRedrawOfList();
03620 
03621     if (OpAddWebFolders::Success[SGLib_ClipArt] && OpAddWebFolders::Success[SGLib_ClipArt_WebThemes] && !m_bDiscardWebFolders) // nothing else to do
03622     {
03623         //Now I've loaded ALL of the clipart and web themes... Redraw everything just in case...
03624         ModeHasChanged();
03625         SelectionHasChanged();
03626         ReformatAndRedrawIfNecessary();
03627         
03628 
03629         return TRUE;
03630     }
03631     m_bDiscardWebFolders = FALSE;
03632 
03633 
03634     //Now make a list of Clipart
03635     String_256 strIndexURL(GetStringField((UINT32) SGLib_ClipArt, _R(IDS_MAININDEXURL)));
03636 
03637     // We initiate the download of the web clipart index file to a temporary file in $WINDIR\Temporary Internet Files
03638     String_256 strTempFile;
03639     GetTempInetDir(&strTempFile);
03640     strTempFile += GetStringField((UINT32) SGLib_ClipArt, _R(IDS_TMPFILES));
03641 
03642     OpDescriptor* pOpDesc = OpDescriptor::FindOpDescriptor(CC_RUNTIME_CLASS(OpAddWebFolders));
03643     if (pOpDesc != NULL)
03644     {
03645         TRACEUSER( "Matt", _T("Starting Download of Clipart\n"));
03646         AddWebFoldersParam* Param = new AddWebFoldersParam;
03647         ERROR2IF(!Param, FALSE, "Memory allocation error");
03648         // Set up the op's param
03649         Param->localFile.SetPathName((TCHAR *) strTempFile); // local path of index file
03650         Param->strURL = strIndexURL; // URL of index file on our web server
03651         Param->pLibGal = this; // pointer to the gallery to add folders to
03652         Param->type = SGLib_ClipArt;
03653         // Invoke the operation - this will initiate the download of the index file
03654         // No result is returned, but the Op will report itself any error that might occur
03655         pOpDesc->Invoke((OpParam*) Param);
03656         TRACEUSER( "Matt", _T("Invoked Download of Clipart\n"));
03657     }
03658     else
03659     {
03660         ERROR3("OpAddWebFolders not found");
03661         return FALSE;
03662     }
03663 
03664     //Now make a list of Web Themes
03665     String_256 strIndexWebThemesURL(_R(IDS_CLIPART_WEBTHEMES_URL));
03666     String_256 strTempFileWebThemes;
03667     GetTempInetDir(&strTempFileWebThemes);
03668     strTempFileWebThemes += String_256(_R(IDS_CLIPART_WEBTHEMES_TEMPFILE));
03669 
03670     OpDescriptor* pOpDescWebThemes = OpDescriptor::FindOpDescriptor(CC_RUNTIME_CLASS(OpAddWebFolders));
03671     if (pOpDescWebThemes != NULL)
03672     {
03673         TRACEUSER( "Matt", _T("Starting Download of Web Themes\n"));
03674         AddWebFoldersParam* ParamWebThemes = new AddWebFoldersParam;
03675         ERROR2IF(!ParamWebThemes, FALSE, "Memory allocation error");
03676         // Set up the op's param
03677         ParamWebThemes->localFile.SetPathName((TCHAR *) strTempFileWebThemes); // local path of index file
03678         ParamWebThemes->strURL = strIndexWebThemesURL; // URL of index file on our web server
03679         ParamWebThemes->pLibGal = this; // pointer to the gallery to add folders to
03680         ParamWebThemes->type = SGLib_ClipArt_WebThemes;
03681         // Invoke the operation - this will initiate the download of the index file
03682         // No result is returned, but the Op will report itself any error that might occur
03683         pOpDescWebThemes->Invoke((OpParam*) ParamWebThemes);
03684         TRACEUSER( "Matt", _T("Invoked Download of Web Themes\n"));
03685     }
03686     else
03687     {
03688         ERROR3("OpAddWebFolders not found");
03689         return FALSE;
03690     }
03691 
03692 
03693     //All clipart and web themes now downloaded...
03694 
03695     return TRUE;
03696 }

BOOL LibClipartSGallery::PreCreate void   )  [virtual]
 

The LibClipartSGallery PreCreate handler. This overrides the base class PreCreate function. It is called at the very beginning of the SuperGallery::Create method, before the window has been created.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
27/1/95 (base generated in sgbase.cpp)
Returns:
TRUE if the Gallery initialised successfully FALSE if it should not be opened due to a failure to initialise
Notes: As this is called before the window is open, it must not attempt to touch any of the button gadgets in the window, or force redraws, etc. Also, events cannot be passed to the tree, as the tree formatting relies on knowing the window size - however, the tree will be reformatted and redrawn automatically when the window is opened - this will happen shortly.

Reimplemented from LibraryGallery.

Definition at line 356 of file sglcart.cpp.

00357 {
00358     TRACEUSER( "Matt", _T("Precreating clipart window\n"));
00359     // If there isn't already one, create a DisplayTree
00360     if (DisplayTree == NULL)
00361     {
00362         DisplayTree = new SGDisplayRootScroll(this);    // New root node, with a scrollbar
00363         if (DisplayTree == NULL)
00364             return(FALSE);
00365     }
00366 
00367     // Add the library groups to the gallery if they're not there already
00368     if(OpenLibFiles.IsEmpty())
00369     {
00370         if(!AddGRMGroups(SGLib_ClipArt))
00371         {
00372             String_256 sLoc = ClipartPath;
00373             String_256 sLoc2 = WebThemePath;
00374             // Set DefaultLibraryPath to <ExeLocation>\Fills - the user might have installed
00375             // the fills to his hard disk:
00376             String_256 sExePath;
00377             if(CResDll::GetExecutablePath((TCHAR*)sExePath))
00378             {
00379                 INT32 oldi = GetClipTheme();
00380 
00381                 String_256 LibDirName;
00382                 LibDirName.MakeMsg(_R(IDS_LIBRARIES_CLIPART_DIRNAME));
00383                 ClipartPath = sExePath;
00384                 ClipartPath += "\\";
00385                 ClipartPath += LibDirName;
00386 
00387                 PathName ThisPath(ClipartPath);
00388                 if(!SGLibOil::FileExists(&ThisPath))    // will also work for paths (not just paths with a filename on the end)
00389                 {
00390                     SetClipTheme(0);
00391                     // Fills not on hard disk. Try the CD location
00392                     if(!ScanForLocation(SGLib_ClipArt, NULL))
00393                     {
00394                         // hard drive and CD location not found
00395                         // put the original path back
00396                         ClipartPath = sLoc;
00397                     }
00398                 }
00399 
00400                 String_256 LibDirName2;
00401                 LibDirName2.MakeMsg(_R(IDS_LIBRARIES_WEBTHEMES_DIRNAME));
00402                 WebThemePath = sExePath;
00403                 WebThemePath += "\\";
00404                 WebThemePath += LibDirName2;
00405 
00406                 PathName ThisPath2(WebThemePath);
00407                 if(!SGLibOil::FileExists(&ThisPath2))   // will also work for paths (not just paths with a filename on the end)
00408                 {
00409                     SetClipTheme(0);
00410                     // Fills not on hard disk. Try the CD location
00411                     if(!ScanForLocation(SGLib_ClipArt_WebThemes, NULL))
00412                     {
00413                         // hard drive and CD location not found
00414                         // put the original path back
00415                         WebThemePath = sLoc;
00416                     }
00417                 }
00418                 // reset the ClipTheme value
00419                 SetClipTheme(oldi);
00420             }
00421 
00422             LibraryGallery::AddLibraryGroups(SGLib_ClipArt, &ClipartPath);
00423             LibraryGallery::AddLibraryGroups(SGLib_ClipArt_WebThemes, &WebThemePath);
00424         }
00425     }
00426 
00427     // Use last time's display mode
00428     DisplayMode = LibClipartSGallery::DefaultDisplayMode;
00429 
00430     return(TRUE);
00431 }

void LibClipartSGallery::ProfileRedraw ReDrawInfoType Param  ) 
 

Definition at line 1043 of file sglcart.cpp.

01044 {
01045 #ifdef _PROFILE_REDRAW
01046     RenderListBox(Param);
01047 #endif
01048 }

BOOL LibClipartSGallery::RemoveWebFolders SGLibType  type  )  [virtual]
 

Reclaims space taken up by downloaded files of a certain type on the local machine.

Author:
Priestley (Xara Group Ltd) <camelotdev@xara.com> - ripped from Adrian
Date:
20/09/2000
Parameters:
type - one of SGLib_ClipArt, SGLib_Font, SGLib_Fractal [INPUTS]
Returns:
TRUE if the folders are removed, FALSE otherwise

Reimplemented from LibraryGallery.

Definition at line 3713 of file sglcart.cpp.

03714 {
03715     TRACEUSER( "Matt", _T("REMOVING WEB FOLDERS! in Clipart gallery\n"));
03716     if (AskQuestion(_R(IDS_WARNREMOVE), _R(IDS_EMPTY), _R(IDS_CANCEL)) == _R(IDS_CANCEL))
03717         return FALSE;
03718 
03719     String_256 strLocation;
03720     GetAppDataPath(&strLocation);
03721     strLocation += GetStringField(SGLib_ClipArt, _R(IDS_CACHEDIR));
03722 
03723     BOOL ok = true;
03724 
03725     if (_access((TCHAR*) strLocation, 0) != -1) // found it
03726     {
03727         DownloadCache::Traverse(strLocation, TRUE);
03728         DownloadCache::Refresh();
03729         SelectionHasChanged();
03730     }
03731     else
03732     {
03733         ok = FALSE;
03734     }
03735 
03736     GetAppDataPath(&strLocation);
03737     strLocation += GetStringField(SGLib_ClipArt_WebThemes, _R(IDS_CACHEDIR));
03738     if (_access((TCHAR*) strLocation, 0) != -1) // found it
03739     {
03740         DownloadCache::Traverse(strLocation, TRUE);
03741         DownloadCache::Refresh();
03742         SelectionHasChanged();
03743     }
03744     else
03745     {
03746         ok = FALSE;
03747     }
03748 
03749     return ok;
03750 }

BOOL LibClipartSGallery::ScanForLocation SGLibType  Type,
StringBase Result
[virtual]
 

Searches all the drives for a CDROM drive. If it finds the Camelot CD mount here at Xara HQ, we point to that instead. Notes:.

Author:
Richard_Millican (Xara Group Ltd) <camelotdev@xara.com>
Date:
19/12/95
Parameters:
Type of library to scan for [INPUTS]
(We assume the library static strings exist and use them - bit yucky) [OUTPUTS] If a Result pointer if given then we copy this into there as well..
Returns:
FALSE if it fails; TRUE if we got a path

Reimplemented from LibraryGallery.

Definition at line 953 of file sglcart.cpp.

00954 {
00955     // Search for a CD ROM drive
00956     String_256 DriveName;
00957     BOOL AreWeXara = FALSE;
00958     String_256 XaraDrive;
00959 
00960     BOOL Adjust = KeyPress::IsAdjustPressed();
00961 #ifndef _DEBUG
00962     Adjust = FALSE;
00963 #endif
00964 
00965     if(SGLibOil::LocateCDROMDrive(this, Type, &DriveName, &AreWeXara, &XaraDrive, Adjust))
00966     {
00967         if(AreWeXara)
00968             DriveName = XaraDrive;
00969 
00970         switch(Type)
00971         {
00972             case SGLib_ClipArt:
00973             case SGLib_ClipArt_WebThemes:
00974             case SGLib_Bitmap:
00975             {
00976                 LibClipartSGallery::DefaultLibraryPath = DriveName;
00977 #ifdef _DEBUG
00978                 if(Adjust)
00979                 {
00980                     LibClipartSGallery::DefaultLibraryPath += TEXT("Graphics\\XaraSt~1");
00981                 }
00982                 else
00983 #endif
00984                 {
00985                     String_256 LibDirName;
00986                     GetLibraryDirectoryName(&LibDirName);
00987                     LibClipartSGallery::DefaultLibraryPath += LibDirName;
00988                 }
00989 
00990                 if(Result)
00991                     *Result = LibClipartSGallery::DefaultLibraryPath;
00992 
00993                 if (GetClipTheme() == 0)
00994                 {
00995                     LibClipartSGallery::ClipartPath = LibClipartSGallery::DefaultLibraryPath;
00996                 }
00997                 else
00998                 {
00999                     LibClipartSGallery::WebThemePath = LibClipartSGallery::DefaultLibraryPath;
01000                 }
01001 
01002                 return TRUE;
01003             }
01004 
01005         }
01006     }
01007     return FALSE;
01008 }

void LibClipartSGallery::SelectionHasChanged void   )  [virtual]
 

To inform the gallery that the selection has changed in some way. We need to grey different buttons on different occasions Notes:.

Author:
Richard_Millican (Xara Group Ltd) <camelotdev@xara.com> (based on Jason code)
Date:
28/3/95

Reimplemented from LibraryGallery.

Definition at line 1930 of file sglcart.cpp.

01931 {
01932     TRACEUSER( "Matt", _T("Selection has changed called in clipart gallery\n"));
01933     if (DisplayTree == NULL)
01934         return;
01935 
01936     INT32 Count = DisplayTree->GetSelectedItemCount();
01937 
01938     EnableGadget(_R(IDC_LIBGAL_OPEN), (Count > 0));
01939 #ifdef _BATCHING
01940     EnableGadget(_R(IDC_LIBGAL_UPDATE), (Count > 0));
01941 #endif
01942 
01943 #ifndef STANDALONE
01944     EnableGadget(_R(IDC_LIBGAL_IMPORT), (Count > 0) && Document::GetSelected() != NULL);
01945 #else
01946     EnableGadget(_R(IDC_LIBGAL_IMPORT), FALSE);
01947 #endif
01948 
01949     EnableGadget(_R(IDC_LIBGAL_ADD_CLIPART), TRUE);
01950 
01951 
01952     // Standard library buttons
01953     LibraryGallery::SelectionHasChanged();
01954 }

INT32 LibClipartSGallery::SetClipTheme INT32  nNewIndex  ) 
 

Author:
Priestley (Xara Group Ltd) <camelotdev@xara.com>
Date:
18/09/2000
Parameters:
nNewIndex --- the new index to show. [INPUTS]
Returns:
The old value of the index.
See also:
LibClipartSGallery::GetPropertyIndex

Definition at line 2412 of file sglcart.cpp.

02413 {
02414     ERROR3IF(0 > nNewIndex, "LibClipartSGallery::SetClipTheme: index out of range");
02415     INT32 n = m_nClipTheme;
02416     m_nClipTheme = nNewIndex;
02417     return n;
02418 }

void LibClipartSGallery::SetQuietStatus BOOL  Status  )  [virtual]
 

Set the Quiet status of the gallery.

Author:
Richard_Millican (Xara Group Ltd) <camelotdev@xara.com>
Date:
19/12/95
Parameters:
Status - Set to TRUE and call if Quiet has just been pressed on an 'adding [INPUTS] indexes' dialog

Reimplemented from LibraryGallery.

Definition at line 929 of file sglcart.cpp.

00930 {
00931     LibClipartSGallery::QuietStatus = Status;
00932 }

void LibClipartSGallery::SortGallery void   )  [protected, virtual]
 

Sorts the contents of the gallery in an alphabetical fashion, whilst keeping the old sort key status... Notes:.

Author:
Richard_Millican (Xara Group Ltd) <camelotdev@xara.com>
Date:
2/5/95
Parameters:
[INPUTS] 
Returns:
See also:

Reimplemented from LibraryGallery.

Definition at line 452 of file sglcart.cpp.

00453 {
00454     // Matt - 03/01/2001
00455     // Special case fix ('bodgeus horriblus')- when we are in the clipart gallery we need to remember the default paths for either the web themes or clipart
00456     // - this method is called just after the defaultlibrarypath is set in the base class, so now's a good time to remember them...
00457     if (GetClipTheme() == 0)
00458     {
00459         LibClipartSGallery::ClipartPath = LibClipartSGallery::DefaultLibraryPath;
00460     }
00461     else
00462     {
00463         LibClipartSGallery::WebThemePath = LibClipartSGallery::DefaultLibraryPath;
00464     }
00465 
00466     LibraryGallery::SortGallery();
00467 }

void LibClipartSGallery::WorkOutSectionName String_256 Section  )  [virtual]
 

Returns the section name to use in the grm file.

Author:
Richard_Millican (Xara Group Ltd) <camelotdev@xara.com>
Date:
28/5/95
Parameters:
Section - String used to return the section name [OUTPUTS]

Reimplemented from LibraryGallery.

Definition at line 2021 of file sglcart.cpp.

02022 {
02023     if(Section)
02024         *Section = _R(IDS_SGLCART_SECTION_NAME); // "ClipartGallery";
02025 }


Member Data Documentation

String_256 LibClipartSGallery::BatchSaveLocation = "" [static]
 

Definition at line 280 of file sglcart.h.

String_256 LibClipartSGallery::ClipartPath = TEXT("D:\\clipart") [static]
 

Definition at line 270 of file sglcart.h.

INT32 LibClipartSGallery::DefaultDisplayMode = 0 [static]
 

Definition at line 274 of file sglcart.h.

String_256 LibClipartSGallery::DefaultLibraryPath = ClipartPath [static]
 

Definition at line 269 of file sglcart.h.

UINT32 LibClipartSGallery::DefaultSortKeys = 1 [static]
 

Definition at line 277 of file sglcart.h.

BOOL LibClipartSGallery::DoSounds = TRUE [static]
 

Definition at line 283 of file sglcart.h.

bool LibClipartSGallery::m_bRedraw
 

Definition at line 293 of file sglcart.h.

bool LibClipartSGallery::m_bRestore
 

Definition at line 294 of file sglcart.h.

INT32 LibClipartSGallery::m_nClipTheme [private]
 

Definition at line 299 of file sglcart.h.

LibClipartSGallery * LibClipartSGallery::m_pInstance = 0 [static, private]
 

Definition at line 298 of file sglcart.h.

BOOL LibClipartSGallery::QuietStatus = FALSE [static]
 

Definition at line 292 of file sglcart.h.

LibClipartSGallery * LibClipartSGallery::ThisGallery = NULL [static]
 

Definition at line 289 of file sglcart.h.

String_256 LibClipartSGallery::WebThemePath = TEXT("D:\\themes") [static]
 

Definition at line 271 of file sglcart.h.


The documentation for this class was generated from the following files:
Generated on Sat Nov 10 03:55:49 2007 for Camelot by  doxygen 1.4.4