LibraryGallery Class Reference

A base library gallery class with common library gallery stuff in. More...

#include <sglbase.h>

Inheritance diagram for LibraryGallery:

SuperGallery DialogOp Operation MessageHandler ListItem CCObject SimpleCCObject FontsSGallery LibClipartSGallery LibFillsSGallery List of all members.

Public Member Functions

 LibraryGallery ()
 A base library gallery class with common library gallery stuff in.
 ~LibraryGallery ()
virtual BOOL IsLibraryGallery (void)
 To check if we're a library gallery.
virtual BOOL IsLibraryGalleryWithNonLibraryGroups (void)
 To check if we're a dedicated library gallery, or a half+half (like the font gallery).
virtual BOOL CanCreateIndexes (void)
 To determine if this gallery can generate indexes or not If you want to create indexes, override and return TRUE.
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)
 Works out which library gallery we are and returns a section name as appropriate.
virtual void WorkOutDescriptionSectionName (String_256 *Section)
 Works out which library gallery we are and returns a description section name as appropriate.
virtual void WorkOutLibraryTypeSectionName (String_256 *Section)
 Works out which library gallery we are and returns a library type section name as appropriate.
virtual SGDisplayGroupAddLibraryGroup (Library *LibraryToDisplay, INT32 NumItems)
 Create a library group, as opposed to a display group.
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 CanSearchKeywords (void)
 Used to determine if this type of gallery supports keyword searching. At the moment, all except the fonts gallery do.
virtual MsgResult Message (Msg *Message)
 Standard library gallery message handler.
virtual void SelectionHasChanged (void)
 To inform the gallery that the selection has changed in some way. This function handles the default library gallery buttons.
BOOL AddLibraryGroups (SGLibType LibType, String_256 *DefaultLibraryPath)
 Creates all teh library groups described in the GRM file, or passed in if non were in the GRM...
BOOL AddGRMGroups (SGLibType LibType)
 Creates all the library groups described in the GRM file.
BOOL ActuallyAddGRMGroups (List *TypeList, List *PathList, List *DescList, BOOL DescPresent, String_256 *SectionName, String_256 *DescriptionSectionName)
 Given two lists, create all the groups in the gallery from them. If the lists are null, then we go through the grmfile itself, slowly...
BOOL GoAndAddGRMGroups (List *TypeList, List *PathList, List *DescList, BOOL DescPresent, String_256 *SectionName, String_256 *DescriptionSectionName)
 Given two lists, create all the groups in the gallery from them. Same as ActuallyAddGRMGroups but if the lists are null, then it doesn't go through the grmfile itself, slowly... as this is no longer relevent.
INT32 GetDisplayMode (void)
 Get the current gallery display mode as passing in miscinfo structures...
void RemoveSelectedLibraries (BOOL Warn)
 Removes all the selected groups in the library.
void UpdateGRMFile (void)
 Updates the GRM file to reflect the status of the gallery (all the groups).
INT32 LibraryGroupsInGallery (void)
 Count the number of library groups in the gallery.
void GalleryAboutToClose (void)
 The gallery is about to close, so free any excess memory taken up by the indexes and things...
void GalleryAboutToReOpen (void)
 The gallery is about to reopen, so recache any indexes or other information that we might need...
INT32 RemoveSimilarLibraryGroups (PathName *FilesPath, String_256 *IndexFileName, BOOL RemoveFirstOne=TRUE, BOOL Redraw=TRUE, Library *DontKill=NULL)
 Removes all the groups with the same Index path...
virtual void SuspendThumbnailDownloading ()
 Prevents further thumbnail downloading and cancels the downloads already queued up. Used in response to a user cancel or a serious error.
virtual void ResumeThumbnailDownloading ()
 Restarts thumbnail downloading and clears all previous download erorrs.
BOOL IsThumbDownloadingSuspended ()
virtual SGLibType GetGalleryType ()
virtual String_256GetDefaultLibraryPath ()
LibraryFindLibrary (const String_256 &rLibPath)
virtual BOOL OnGetButtonClicked ()
 Attempts to download the main web resource index file from our web site, parse it and create corresponding gallery folders.

Static Public Member Functions

static BOOL WipeGallerySettings (void)
 Function to remove all the current gallery settings.

Public Attributes

List OpenLibFiles
std::list< OpThumbDownload * > m_lstPendingThumbs
BOOL m_bDiscardWebFolders
BOOL bThumbDownloading

Static Public Attributes

static BOOL AskAboutRemoving = FALSE
static INT32 OffsetOfFirstGroupRemoved = -1
static BOOL FirstGroupRemovedSelectionState = FALSE
static KernelBitmapTmpDraggingBitmap = NULL

Protected Member Functions

virtual void DoShadeGallery (BOOL ShadeIt)
 Handles the standard library gallery button shading in the gallery Notes:.
virtual BOOL PreCreate (void)
 The LibraryGallery 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 ApplyAction (SGActionType Action)
 Applies certain conventional gallery actions (usually associated with gallery buttons, for new, edit, delete, etc).
virtual BOOL AddNewLibrary (PathName *LibPath, BOOL WipeOld, SGLibType LibType, BOOL Update=FALSE)
 This call will optionally kill all the old library groups and then recreate library groups for the given libpath Notes:.
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.
virtual 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.
virtual SGDisplayItemCopyDisplayItem (SGDisplayItem *SourceItem, SGDisplayGroup *DestGroup, SGDisplayItem *TargetPosition)
 "Copies" the existing node in the tree in an appropriate fashion.
virtual void AllItemsCopied (SGDisplayGroup *DestGroup)
 This upcall method is called after one or more items have been copied or moved by a gallery drag. It allows the gallery to do update things like broadcasting a message or getting a related window (eg colour line) to redraw at the end of a move/copy operation. This allows thousands of items to be moved/copied with only a single redraw/message-broadcast, etc at the very end.
virtual BOOL BrowseClicked (void)
 Handle clicks on the browse button.
BOOL BrowseClicked (String_256 *DefaultPath, SGLibType Type, INT32 Message)
 Shared Library Gallery Browse Clicked procedure.
virtual void SortGallery (void)
 Sort the entire gallery alphabetically.
BOOL SortOutGroupsAfterLibraryAdd (LibraryFile *LibFile, BOOL Update)
 This call will scroll to and redraw the newly added groups. Also, if we've just updated the group which is being added, we'll work out where it should be placed in the gallery... Notes: We assume the last group added to the gallery was placed at the end of the list...
virtual void VirtualiseAllFoldedGroups ()
 Go through the gallery tree and virtualise all folded groups which can be virtualised.
BOOL RemoveWebFolders (SGLibType type)
 Reclaims space taken up by downloaded files of a certain type on the local machine.

Detailed Description

A base library gallery class with common library gallery stuff in.

Author:
Richard_Millican (Xara Group Ltd) <camelotdev@xara.com>
Date:
18/5/95 (Finally)
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

Definition at line 132 of file sglbase.h.


Constructor & Destructor Documentation

LibraryGallery::LibraryGallery  ) 
 

A base library gallery class with common library gallery stuff in.

Author:
Richard_Millican (Xara Group Ltd) <camelotdev@xara.com>
Date:
18/5/95 (Finally)
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

Definition at line 183 of file sglbase.cpp.

00184 {
00185     if (!OpAddWebFolders::Init() || !OpAddWebLibrary::Init() || !OpThumbDownload::Init())
00186     {
00187         ERROR3("Failed to init web operations");
00188     }
00189 
00190     // Initialising to true means Camelot will try and download thumbnails without you having to press the 'Get Fills' 
00191     // (or equivalent) button. Because downloading is now suspended when an error occurs, offline users (with a
00192     // partial thumb stock) no longer get continual popups when scrolling down a page of unloaded thumbnails.
00193     // Fixes, with inetop.cpp change, #10471
00194     bThumbDownloading = TRUE;
00195     m_bDiscardWebFolders = FALSE;
00196 }

LibraryGallery::~LibraryGallery  ) 
 

Definition at line 198 of file sglbase.cpp.

00199 {
00200     TRACEUSER( "Richard", _T("~LibraryGallery called\n"));
00201 }


Member Function Documentation

BOOL LibraryGallery::ActuallyAddGRMGroups List TypeList,
List PathList,
List DescList,
BOOL  DescPresent,
String_256 SectionName,
String_256 DescriptionSectionName
 

Given two lists, create all the groups in the gallery from them. If the lists are null, then we go through the grmfile itself, slowly...

Author:
Richard_Millican (Xara Group Ltd) <camelotdev@xara.com>
Date:
26/1/96
Parameters:
LibType - The type of library we're adding [INPUTS] PathList - List of Pathnames for the groups (optional, can be NULL, but slower...) DescList - List of Descriptions to display for the groups (optional, can be NULL, but slower...) DescPresent - Are descriptions present ? SectionName - Section name for the paths DescriptionSectionName - Section name for the descriptions
Returns:
TRUE if new groups added

Definition at line 2039 of file sglbase.cpp.

02041 {
02042     ListItem *TypeItem = NULL;
02043     ListItem *PathItem = NULL;
02044     ListItem *DescItem = NULL;
02045     String_256 Entry;
02046     INT32 LineCount = 0;
02047     INT32 Line = 1;
02048     BOOL ValidLine = TRUE;
02049     BOOL GroupsAdded = FALSE;
02050 
02051     // Work out the location of web folders so we can flag them as such
02052     String_256 strWebFoldersPath;
02053     GetAppCachePath(&strWebFoldersPath);
02054 
02055     if(PathList != NULL)
02056         LineCount = PathList->GetCount() + 1;
02057     else
02058         while(ValidLine)
02059         {
02060             ValidLine = LibSettings::GetEntry(SectionName, Line++, &Entry);
02061             LineCount ++;
02062         };
02063 
02064     if(LineCount > 0)
02065     {
02066         String_64 SlowJob(_R(IDS_LIBRARY_SCANNING));
02067         BeginSlowJob(LineCount, FALSE, &SlowJob);
02068 
02069         // Need to reset the Quiet status before a stream of Library::Init calls
02070         SetQuietStatus(FALSE);
02071 
02072         Line = 1;
02073         ValidLine = TRUE;
02074 
02075         BOOL EscapePressed = FALSE;
02076     
02077         while(ValidLine && !EscapePressed)
02078         {
02079             EscapePressed = !ContinueSlowJob(Line);
02080 
02081             if(PathList != NULL)
02082             {
02083                 if(PathItem == NULL)
02084                     PathItem = PathList->GetHead();
02085                 else
02086                     PathItem = PathList->GetNext(PathItem);
02087                 ValidLine = (PathItem != NULL && ((LibSettingsListItem *)PathItem)->Line != NULL);
02088                 if(ValidLine)
02089                     Entry = *((LibSettingsListItem *)PathItem)->Line;
02090                 Line ++;
02091             }
02092             else
02093                 ValidLine = LibSettings::GetEntry(SectionName, Line++, &Entry);
02094 
02095             if(ValidLine)
02096             {
02097                 // See if we've got descriptions as well
02098                 String_256 *pDescString = NULL;
02099                 String_256 DescString;
02100                 if(DescPresent)
02101                 {
02102                     if(DescList != NULL)
02103                     {
02104                         if(DescItem == NULL)
02105                             DescItem = DescList->GetHead();
02106                         else
02107                             DescItem = DescList->GetNext(DescItem);
02108 
02109                         if(DescItem != NULL && ((LibSettingsListItem *)DescItem)->Line != NULL)
02110                         {
02111                             DescString = *((LibSettingsListItem *)DescItem)->Line;
02112                             pDescString = &DescString;
02113                         }
02114                         Line ++;
02115                     }
02116                     else
02117                     {
02118                         if(LibSettings::GetEntry(DescriptionSectionName, (Line-1), &DescString))
02119                             pDescString = &DescString;
02120                     }
02121                 }
02122 
02123                 // See if we've got library types as well
02124                 SGLibType m_SGLibType;
02125                 String_256 TypeString;
02126                 INT32 TypeInt;
02127                 if(DescPresent)
02128                 {
02129                     if(TypeList != NULL)
02130                     {
02131                         if(TypeItem == NULL)
02132                             TypeItem = TypeList->GetHead();
02133                         else
02134                             TypeItem = TypeList->GetNext(DescItem);
02135 
02136                         if(TypeItem != NULL && ((LibSettingsListItem *)TypeItem)->Line != NULL)
02137                         {
02138                             INT32 pos = 0;
02139                             TypeString = *((LibSettingsListItem *)TypeItem)->Line;
02140                             TypeInt = TypeString.ConvertToInteger(pos);
02141                             m_SGLibType = (SGLibType)TypeInt;
02142                         }
02143                     }
02144                     else
02145                     {
02146                         String_256 LibraryTypesSectionName;
02147                         WorkOutLibraryTypeSectionName(&LibraryTypesSectionName);
02148                         if(LibSettings::GetEntry(&LibraryTypesSectionName, (Line-1), &TypeString))
02149                         {
02150                             INT32 pos = 0;
02151                             TypeInt = TypeString.ConvertToInteger(pos);
02152                             m_SGLibType = (SGLibType)TypeInt;
02153                         }
02154                     }
02155                 }
02156 
02157 
02158                 //>> webster (Adrian 3/01/96)
02159                 // Check if the catalog file still exists and is accessible - the web clipart folder
02160                 // might have been deleted in the meantime - in which case we'll skip it
02161                 BOOL bIsWebFolder = (camStrstr((TCHAR*) Entry, (TCHAR*) strWebFoldersPath) != NULL);
02162                 // BUT if it is a CD based folder and the CD ROM is not present then this test will fail.
02163                 // This is very very very bad. We need to only check this if we are in the web case.
02164                 // Otherwise, if the user opens the gallery without the CD ROM present, they loose all their
02165                 // CD gallery entries. Older versions always show the glalery entries and it is only when
02166                 // the user opens a section that it errors and tells them about the problem, giving them
02167                 // a chance to fix it.
02168                 // Neville 12/11/97
02169                 BOOL bIsIndexPresent = (_access((TCHAR*) Entry, 0) != -1);
02170                 if (!bIsWebFolder || (bIsWebFolder && bIsIndexPresent))
02171                 {
02172                     // open the library file
02173                     LibraryFile *LibFile = new LibraryFile;
02174                     if (LibFile != NULL)
02175                     {
02176                         // 'Entry' now points to a specific index file. We have to add this to the
02177                         // gallery...
02178                         PathName path(Entry);
02179                         if(!LibFile->AddSpecificIndex(this, &path, m_SGLibType, pDescString, 0, bIsWebFolder))
02180                             delete LibFile;                                         
02181                         else
02182                         {
02183                             OpenLibFiles.AddTail(LibFile);
02184                             GroupsAdded = TRUE;
02185                         }
02186                     }
02187                 }
02188             }   
02189         }
02190         EndSlowJob();
02191     }
02192 
02193     return GroupsAdded;
02194 }

BOOL LibraryGallery::AddGRMGroups SGLibType  LibType  ) 
 

Creates all the library groups described in the GRM file.

Author:
Richard_Millican (Xara Group Ltd) <camelotdev@xara.com>
Date:
28/5/95
Parameters:
LibType - The type of library we're adding [INPUTS]
Returns:
TRUE if new groups added

Definition at line 1623 of file sglbase.cpp.

01624 {
01625     TRACEUSER( "Matt", _T("AddGRMGroups Called in base class\n"));
01626     String_256 SectionName;
01627     WorkOutSectionName(&SectionName);
01628 
01629     // The two lists we are going to use to keep track of the two section that we require
01630     // Errr.. now there's three lists... Sorry. (Matt 25/09/2000)
01631     List *PathList = NULL;
01632     List *DescList = NULL;
01633     List *TypeList = NULL;
01634 
01635     BOOL bRetVal = FALSE;
01636 
01637 #ifdef SAVE_PREFS_TO_REGISTRY
01638     // Check to see if we have the gallery settings section in the registry
01639     // if we do then use that.
01640     // Otherwise, use check for the older ini file version and if present use that
01641     
01642     // This is the main section name in the registry for gallery settings.
01643     String_256 KeySectionName(PRODUCT_REGISTRYKEY_GALLERY TEXT("\\"));
01644     // add in the required sub-section name that we are going to use
01645     KeySectionName += SectionName;
01646 
01647     BOOL SectionPresent = CheckForRegistryEntry(KeySectionName);
01648     if (SectionPresent)
01649     {
01650         // We need to read the data from the registry as the section is present
01651         
01652         // First do the pathnames list section
01653         LoadRegistryEntries Loader;
01654         BOOL StartedOk = Loader.StartLoading(&KeySectionName);
01655         ERROR3IF(!StartedOk,"LibraryGallery::UpdateGRMFile couldn't start saving the settings");
01656 
01657         PathList = new List;
01658 
01659         // read all the lines from that section
01660         BOOL AddedItems = FALSE;
01661         INT32 NumberSectionItems = 0;
01662         if (PathList && StartedOk)
01663         {
01664             String_256 Entry;
01665             while (Loader.LoadNextEntry(&Entry))
01666             {
01667                 LibSettingsListItem *LibSettingsItem = new LibSettingsListItem(&Entry);
01668                 PathList->AddTail((ListItem *)LibSettingsItem);
01669                 AddedItems = TRUE;
01670             }
01671             // remember how many items we got
01672             NumberSectionItems = Loader.GetNumberOfItemsLoaded();
01673             Loader.StopLoading();
01674         }
01675 
01676         // See if we've got descriptions section as well
01677         String_256 DescriptionSectionName;
01678         WorkOutDescriptionSectionName(&DescriptionSectionName);
01679         // This is the main section name in the registry for gallery settings.
01680         String_256 DescriptionKeySectionName(PRODUCT_REGISTRYKEY_GALLERY TEXT("\\"));
01681         // add in the required sub-section name that we are going to use
01682         DescriptionKeySectionName += DescriptionSectionName;
01683         BOOL DescriptionsPresent = FALSE;
01684         String_256 DescEntry;
01685 
01686         // First do the pathnames list section
01687         LoadRegistryEntries DescLoader;
01688         DescriptionsPresent = DescLoader.StartLoading(&DescriptionKeySectionName);
01689         ERROR3IF(!DescriptionsPresent,"LibraryGallery::UpdateGRMFile couldn't start saving the settings");
01690 
01691         // build up a list of the items in this section
01692         DescList = new List;
01693         INT32 NumberDescriptionItems = 0;
01694         if (DescList && DescriptionsPresent)
01695         {
01696             while (DescLoader.LoadNextEntry(&DescEntry))
01697             {
01698                 LibSettingsListItem *LibSettingsItem = new LibSettingsListItem(&DescEntry);
01699                 DescList->AddTail((ListItem *)LibSettingsItem);
01700                 AddedItems = TRUE;
01701             }
01702             // remember how many items we got
01703             NumberDescriptionItems = DescLoader.GetNumberOfItemsLoaded();
01704             DescLoader.StopLoading();
01705         }
01706 
01707 
01708         // See if we've got library types section as well
01709         String_256 LibraryTypesSectionName;
01710         WorkOutLibraryTypeSectionName(&LibraryTypesSectionName);
01711         // This is the main section name in the registry for gallery settings.
01712         String_256 LibraryTypesKeySectionName(PRODUCT_REGISTRYKEY_GALLERY TEXT("\\"));
01713         // add in the required sub-section name that we are going to use
01714         LibraryTypesKeySectionName += LibraryTypesSectionName;
01715         BOOL LibraryTypesPresent = FALSE;
01716         String_256 TypesEntry;
01717 
01718         // First do the pathnames list section
01719         LoadRegistryEntries TypesLoader;
01720         LibraryTypesPresent = TypesLoader.StartLoading(&LibraryTypesKeySectionName);
01721         ERROR3IF(!LibraryTypesPresent,"LibraryGallery::UpdateGRMFile couldn't start saving the LibraryTypes");
01722 
01723         // build up a list of the items in this section
01724         TypeList = new List;
01725         INT32 NumberLibraryTypesItems = 0;
01726         if (TypeList && LibraryTypesPresent)
01727         {
01728             while (TypesLoader.LoadNextEntry(&TypesEntry))
01729             {
01730                 LibSettingsListItem *LibSettingsItem = new LibSettingsListItem(&TypesEntry);
01731                 TypeList->AddTail((ListItem *)LibSettingsItem);
01732                 AddedItems = TRUE;
01733             }
01734             // remember how many items we got
01735             NumberLibraryTypesItems = TypesLoader.GetNumberOfItemsLoaded();
01736             TypesLoader.StopLoading();
01737         }
01738         
01739         
01740 // >>webster        
01741         // This is the main section name in the registry for gallery settings.
01742         String_256 RootURLKeySectionName(PRODUCT_REGISTRYKEY_GALLERY TEXT("\\"));
01743         // add in the required sub-section name that we are going to use
01744         RootURLKeySectionName += String_256(_R(IDS_ROOTURL));
01745         LoadRegistryEntries URLLoader;
01746         if (URLLoader.StartLoading(&RootURLKeySectionName)) 
01747             URLLoader.LoadNextEntry(&Library::URLBase);
01748         URLLoader.StopLoading();
01749     // <<webster
01750 
01751         // If we have a matching set of pathname and description sections then add those items
01752         // Otherwise, just leave the gallery blank
01753         if (NumberDescriptionItems == NumberSectionItems && 
01754             NumberSectionItems != 0 && NumberDescriptionItems != 0 &&
01755             PathList != NULL && DescList != NULL)
01756         {
01757             // Add the sections to the gallery
01758             bRetVal = GoAndAddGRMGroups(/*LibType*/TypeList , PathList, DescList, DescriptionsPresent, &SectionName, &DescriptionSectionName);
01759         }
01760     }
01761     else
01762 #endif
01763     {
01764         // read the data from the ini file
01765         String_256 Entry;
01766 
01767         // Right, only return false if the section wasn't found in the file
01768         // The contents of the section could be null, this would mean there are no libraries
01769         // shown, but if that's what they want then fair enough
01770         FilePos SectionNamePos = 0;
01771         if(!LibSettings::GetEntry(&SectionName, 0, &Entry, &SectionNamePos))
01772             return FALSE;
01773 
01774         // See if we've got descriptions as well
01775         String_256 DescriptionSectionName(SectionName);
01776         WorkOutDescriptionSectionName(&DescriptionSectionName);
01777         BOOL DescriptionsPresent = FALSE;
01778         String_256 DescEntry;
01779         FilePos DescriptionPos = 0;
01780         if(LibSettings::GetEntry(&DescriptionSectionName, 0, &DescEntry, &DescriptionPos))
01781             DescriptionsPresent = TRUE;
01782         
01783         // If the [SectionName] appears later than the [DescriptionSectionName] then the
01784         // [Description] one is invalid...
01785         // Perhaps in the future we should change the SectionNames so that old versions of Camelot
01786         // won't affect new things like this...
01787         if(DescriptionPos < SectionNamePos)
01788             DescriptionsPresent = FALSE;
01789 
01790         // See if we've got library types as well
01791         String_256 LibraryTypesSectionName(SectionName);
01792         WorkOutLibraryTypeSectionName(&LibraryTypesSectionName);
01793         BOOL LibraryTypesPresent = FALSE;
01794         String_256 TypeEntry;
01795         FilePos LibraryTypesPos = 0;
01796         if(LibSettings::GetEntry(&LibraryTypesSectionName, 0, &TypeEntry, &LibraryTypesPos))
01797             LibraryTypesPresent = TRUE;
01798 
01799 
01800         PathList = new List;
01801         if(PathList != NULL && !LibSettings::BuildList(&SectionName, PathList))
01802         {
01803             PathList->DeleteAll();
01804             delete PathList;
01805             PathList = NULL;
01806         }
01807 
01808         DescList = NULL;
01809         if(DescriptionsPresent)
01810         {
01811             DescList = new List;
01812             if(DescList != NULL && !LibSettings::BuildList(&DescriptionSectionName, DescList))
01813             {
01814                 DescList->DeleteAll();
01815                 delete DescList;
01816                 DescList = NULL;
01817             }
01818         }
01819 
01820         TypeList = new List;
01821         if(LibraryTypesPresent)
01822         {
01823             TypeList = new List;
01824             if(TypeList != NULL && !LibSettings::BuildList(&LibraryTypesSectionName, TypeList))
01825             {
01826                 TypeList->DeleteAll();
01827                 delete TypeList;
01828                 TypeList = NULL;
01829             }
01830         }
01831 
01832 
01833 
01834         //>> webster (Adrian 3/01/97)
01835         String_256 strURLBaseSectionName(_R(IDS_ROOTURL));
01836         String_256 strRootURL;
01837         if (LibSettings::GetEntry(&strURLBaseSectionName, 1, &strRootURL, NULL))    
01838             Library::URLBase = strRootURL;
01839         //<< webster
01840 
01841         bRetVal = ActuallyAddGRMGroups(TypeList /*LibType*/, PathList, DescList, DescriptionsPresent, &SectionName, &DescriptionSectionName);
01842 
01843     }
01844 
01845     // Free up memory entailed in lists
01846     if(PathList != NULL)
01847     {
01848         PathList->DeleteAll();
01849         delete PathList;
01850     }
01851 
01852     if(DescList != NULL)
01853     {
01854         DescList->DeleteAll();
01855         delete DescList;
01856     }
01857 
01858     if(TypeList != NULL)
01859     {
01860         TypeList->DeleteAll();
01861         delete TypeList;
01862     }
01863 
01864     return bRetVal;
01865 }

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

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

Author:
Richard_Millican (Xara Group Ltd) <camelotdev@xara.com>
Date:
26/5/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 SuperGallery.

Reimplemented in LibClipartSGallery, LibFillsSGallery, and FontsSGallery.

Definition at line 301 of file sglbase.cpp.

00302 {
00303     return SuperGallery::AddLibraryGroup(LibraryToDisplay, NumItems);
00304 }

BOOL LibraryGallery::AddLibraryGroups SGLibType  LibType,
String_256 DefaultLibraryPath
 

Creates all teh library groups described in the GRM file, or passed in if non were in the GRM...

Author:
Richard_Millican (Xara Group Ltd) <camelotdev@xara.com>
Date:
28/5/95
Parameters:
LibType - The type of library we're adding [INPUTS] DefaultLibraryPath - Library path to use if non found in grm file
Returns:
TRUE if new groups added

Definition at line 1557 of file sglbase.cpp.

01558 {
01559     TRACEUSER( "Matt", _T("AddLibraryGroups called in Base Class\n"));
01560 //  ERROR3_PF(("LibraryGallery::AddLibraryGroups -> %s", (TCHAR *)*DefaultLibraryPath));
01561 
01562     BOOL AddedGroups = FALSE;
01563 
01564     if(AddGRMGroups(LibType))
01565     {
01566         AddedGroups = TRUE;
01567     }
01568     else
01569     {
01570 
01571 // Matt - 03/01/2001
01572 // This method is only ever called from derived classes and the check below is made in each one of them before calling...
01573 // Therefore, this change will not affect their operation - it DOES mean that we can now pre-create  a gallery with CD stuff
01574 // from multiple sources... used in the clipart/web themes precreation...
01575 
01576 //      if (OpenLibFiles.IsEmpty())     // We have no libraries, so open the default library
01577 //      {
01578             String_64 SlowJob(_R(IDS_LIBRARY_SCANNING));
01579             BeginSlowJob(-1, FALSE, &SlowJob);
01580 
01581             // open the library file
01582             LibraryFile *LibFile = new LibraryFile;
01583             if (LibFile != NULL)
01584             {
01585                 // OK. Lets initialise the library. This will call us back via base-class
01586                 // SuperGallery methods to add a group and items for each {sub}library
01587                 // found in the given library file.         
01588                 PathName ThePath(*DefaultLibraryPath);
01589                 if (!LibFile->Init(this, &ThePath, LibType))
01590                 {
01591                     // InformError if it returned FALSE? **** !!!!
01592                     delete LibFile;
01593                 }
01594                 else
01595                 {
01596                     OpenLibFiles.AddTail(LibFile);
01597                     AddedGroups = TRUE;
01598                     //SortGallery();
01599                 }
01600             }
01601 
01602             EndSlowJob();
01603 //      }
01604     }
01605 
01606     return AddedGroups;
01607 }

SGDisplayItem * LibraryGallery::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 SuperGallery.

Reimplemented in LibClipartSGallery, LibFillsSGallery, and FontsSGallery.

Definition at line 589 of file sglbase.cpp.

00590 {
00591     return SuperGallery::AddLibraryItem(LibraryGroup, ParentLib, ItemIndex, bNew);
00592 }

BOOL LibraryGallery::AddNewLibrary PathName LibPath,
BOOL  WipeOld,
SGLibType  LibType,
BOOL  Update = FALSE
[protected, virtual]
 

This call will optionally kill all the old library groups and then recreate library groups for the given libpath Notes:.

Author:
Richard_Millican (Xara Group Ltd) <camelotdev@xara.com>
Date:
11/4/95
Parameters:
LibPath - should be set to the new library location [INPUTS] WipeOld - will wipe the old groups from the gallery if TRUE LibType - should be set the the library type for adding Update - set to true if updating rather than adding a new library. This just causes the new group to keep the position where the old group was.
Returns:
TRUE if things went OK
See also:

Definition at line 423 of file sglbase.cpp.

00424 {
00425 /*  String_256 P(LibPath->GetPath());
00426     ERROR3_PF(("LibraryGallery::AddNewLibrary -> %s", (TCHAR *)P));*/
00427 
00428     ERROR3IF(DisplayTree==NULL, "No display tree!");
00429     if(DisplayTree == NULL) return FALSE;
00430 
00431     if(LibPath == NULL)
00432     {
00433         ERROR3("LibraryGallery::AddNewLibrary given null LibPath");
00434         return FALSE;
00435     }
00436 
00437     if(WipeOld)
00438     {
00439         // Kill all existing lib groups
00440         OpenLibFiles.DeleteAll();
00441         LibraryGallery::SelectionHasChanged();
00442     }
00443 
00444     // Open the new index and add it to the gallery
00445     LibraryFile *LibFile = new LibraryFile;
00446     if (LibFile != NULL)
00447     {
00448         // OK. Lets initialise the library. This will call us back via base-class
00449         // SuperGallery methods to add a group and items for each {sub}library
00450         // found in the given library file.
00451         if(!LibPath->IsValid())
00452         {
00453             ERROR3("LibraryGallery::AddNewLibrary given an invalid default library path");
00454             delete LibFile;
00455             InvalidateCachedFormat();
00456             ReformatAndRedrawIfNecessary();
00457             return FALSE;
00458         }
00459 
00460         String_64 SlowJob(_R(IDS_LIBRARY_SCANNING));
00461         BeginSlowJob(-1, FALSE, &SlowJob);
00462 
00463         InvalidateCachedFormat();
00464 
00465         // This will give the option of generating a new index file - Don't do the scroll redraw here...
00466         if (!LibFile->Init(this, LibPath, LibType, Update, FALSE))
00467         {
00468             // InformError if it returned FALSE? **** !!!!
00469             TRACEUSER( "Richard", _T("Problems with this new library... -> LibFile::Init returned false\n"));
00470             delete LibFile;
00471             EndSlowJob();
00472             // And force a redraw of the entire list
00473             ReformatAndRedrawIfNecessary();
00474             return FALSE;
00475         }
00476         else
00477         {
00478             SortOutGroupsAfterLibraryAdd(LibFile, Update);
00479         }
00480 
00481         EndSlowJob();
00482     }
00483     
00484     // And force a redraw of the entire list
00485     InvalidateCachedFormat();
00486     ReformatAndRedrawIfNecessary();
00487     return TRUE;
00488 }

virtual void LibraryGallery::AllItemsCopied SGDisplayGroup DestGroup  )  [inline, protected, virtual]
 

This upcall method is called after one or more items have been copied or moved by a gallery drag. It allows the gallery to do update things like broadcasting a message or getting a related window (eg colour line) to redraw at the end of a move/copy operation. This allows thousands of items to be moved/copied with only a single redraw/message-broadcast, etc at the very end.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
27/3/95
Parameters:
DestGroup - Indicates where the copy/move took place. [INPUTS]
An example where this methodis used is the colour gallery.

Notes: The caller automatically causes the appropriate things to be redrawn, so we just need to update other things. e.g. The colour gallery broadcasts a ColourChangingMsg to make sure that the colour line and other interested parties all update appropriately.

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

Reimplemented from SuperGallery.

Reimplemented in FontsSGallery.

Definition at line 203 of file sglbase.h.

00203 {};

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

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

Author:
Richard_Millican (Xara Group Ltd) <camelotdev@xara.com>
Date:
26/5/95
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 SuperGallery.

Reimplemented in LibClipartSGallery, LibFillsSGallery, and FontsSGallery.

Definition at line 395 of file sglbase.cpp.

00396 {
00397     return SuperGallery::ApplyAction(Action);
00398 }

BOOL LibraryGallery::BrowseClicked String_256 DefaultPath,
SGLibType  Type,
INT32  Message
[protected]
 

Shared Library Gallery Browse Clicked procedure.

Author:
Richard_Millican (Xara Group Ltd) <camelotdev@xara.com>
Date:
18/12/95
Parameters:
DefaultPath - Default path for Browse dialog to open up in [INPUTS] Type - Type of Browse dialog Message - Message to ask whether we should kill all the groups or not
DefaultPath - Updated if browse dialog added a new library [OUTPUTS]

Definition at line 696 of file sglbase.cpp.

00697 {
00698     BOOL Updated = FALSE;
00699     PathName ThePath(*DefaultPath); 
00700 
00701     // This returns FALSE if Cancel was hit, or an error occurred.
00702     if(SGLibOil::GetLibPath(this, &ThePath, CanCreateIndexes(), Type, &Updated))
00703     {
00704         if(!ThePath.IsValid())
00705         {
00706             String_256 Tmp(ThePath.GetPath());
00707             ERROR3_PF(("LibraryGallery::BrowseClicked GetLibPath returned an invalid pathname - '%s'", (TCHAR *)Tmp));
00708         }
00709         else
00710         {                           
00711             // Remove by default
00712             INT32 ButtonPressed = 2;
00713 
00714             if(LibraryGroupsInGallery() > 0 && LibraryGallery::AskAboutRemoving)
00715             {
00716                 // Find out whether we should kill all the other groups
00717                 ButtonPressed = InformMessage(Message, _R(IDS_REMOVE), _R(IDS_KEEP), _R(IDS_CANCEL)/*, _R(IDS_HELP)*/);
00718                 Error::ClearError();
00719 
00720                 if(ButtonPressed == 3)
00721                     return FALSE;
00722             }
00723 
00724             // Remove clicked if button pressed == 1
00725             if(AddNewLibrary(&ThePath, ButtonPressed == 1, Type, Updated))
00726             {                           
00727                 // Remember the new path for the next time
00728                 *DefaultPath = ThePath.GetPath();
00729             }
00730 
00731             // Sort the entire gallery alphabetically
00732             SortGallery();
00733 
00734             ReformatAndRedrawIfNecessary();
00735 
00736             return TRUE;
00737         }
00738     }
00739     return FALSE;
00740 }

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

Handle clicks on the browse button.

Author:
Richard_Millican (Xara Group Ltd) <camelotdev@xara.com>
Date:
26/5/95

Reimplemented in LibClipartSGallery, LibFillsSGallery, and FontsSGallery.

Definition at line 674 of file sglbase.cpp.

00675 {
00676     return FALSE;
00677 }

BOOL LibraryGallery::CanCreateIndexes void   )  [virtual]
 

To determine if this gallery can generate indexes or not If you want to create indexes, override and return TRUE.

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

Reimplemented in LibClipartSGallery, LibFillsSGallery, and FontsSGallery.

Definition at line 756 of file sglbase.cpp.

00757 {
00758     return FALSE;
00759 }

BOOL LibraryGallery::CanSearchKeywords void   )  [virtual]
 

Used to determine if this type of gallery supports keyword searching. At the moment, all except the fonts gallery do.

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

Reimplemented from SuperGallery.

Reimplemented in LibClipartSGallery, LibFillsSGallery, and FontsSGallery.

Definition at line 281 of file sglbase.cpp.

00282 {
00283     return SuperGallery::CanSearchKeywords();
00284 }

BOOL LibraryGallery::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:
Kind - Last column entry in the index.txt file (" F") [INPUTS]
Returns:
TRUE if this signifies the gallery in question...

Reimplemented in LibClipartSGallery, LibFillsSGallery, and FontsSGallery.

Definition at line 870 of file sglbase.cpp.

00871 {
00872 /*  if(Type == SGLib_ClipArt && ((Kind.Sub(String_8("A"))!=-1) || (Kind.Sub(String_8("a"))!=-1)) ) Match = TRUE;
00873     if(Type == SGLib_ClipArt && ((Kind.Sub(String_8("B"))!=-1) || (Kind.Sub(String_8("b"))!=-1)) ) Match = TRUE;                
00874     //if(Type == SGLib_Bitmap  && ((Kind.Sub(String_8("B"))!=-1) || (Kind.Sub(String_8("b"))!=-1)) ) Match = TRUE;
00875     if(Type == SGLib_Font    && ((Kind.Sub(String_8("F"))!=-1) || (Kind.Sub(String_8("f"))!=-1)) ) Match = TRUE;
00876     if(Type == SGLib_Texture && ((Kind.Sub(String_8("T"))!=-1) || (Kind.Sub(String_8("t"))!=-1)) ) Match = TRUE;
00877     if(Type == SGLib_Fractal && ((Kind.Sub(String_8("R"))!=-1) || (Kind.Sub(String_8("r"))!=-1)) ) Match = TRUE;
00878     if(Type == SGLib_Colour  && ((Kind.Sub(String_8("C"))!=-1) || (Kind.Sub(String_8("c"))!=-1)) ) Match = TRUE;*/
00879 
00880     return FALSE;
00881 }

SGDisplayItem * LibraryGallery::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 SuperGallery.

Reimplemented in LibClipartSGallery, LibFillsSGallery, and FontsSGallery.

Definition at line 657 of file sglbase.cpp.

00659 {
00660     return SuperGallery::CopyDisplayItem(SourceItem, DestGroup, TargetPosition);
00661 }

void LibraryGallery::DoShadeGallery