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