BitmapSGallery Class Reference

The Bitmap SuperGallery class. More...

#include <sgbitmap.h>

Inheritance diagram for BitmapSGallery:

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

Public Member Functions

 BitmapSGallery ()
 BitmapSGallery default constructor.
 ~BitmapSGallery ()
 BitmapSGallery destructor.
virtual MsgResult Message (Msg *Message)
 A standard message handler, really.
virtual void SelectionHasChanged (void)
 To inform the gallery that the selection has changed in some way. The base gallery class will do the following things:.
virtual SGDisplayItemCopyDisplayItem (SGDisplayItem *SourceItem, SGDisplayGroup *DestGroup, SGDisplayItem *TargetPosition=NULL)
 "Copies" the existing node in the tree in an appropriate fashion.
virtual BOOL PreContextMenu (void)
 Give the gallery a chance to do something before popping up the context menu. Called before the context menu is popped up on a right click. At present, used by the bitmap gallery to ensure that the plug-ins have all been parsed.
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.
BOOL HasDelayValueChanged ()
BOOL IsJPEG (KernelBitmap **pList, UINT32 ListSize, BmpDlgParam *Param, INT32 *pBytes)
 To determine whether an imported bitmap is a compressed JPEG.

Static Public Attributes

static BOOL IgnoreBmpListChange = FALSE

Protected Member Functions

virtual BOOL PreCreate (void)
 The BitmapSGallery PreCreate handler. This overrides the base class PreCreate function. It is called at the very end of the SuperGallery::Create method, after 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 void HandleDragStart (DragMessage *DragMsg)
 Checks a DragMessage to see if it is a bitmap drag. If it is, then it creates a drag target for this gallerys listbox.
virtual RenderRegionCreateRenderRegion (DocRect *VirtualSize, ReDrawInfoType *DlgRedrawInfo)
 An overridable veneer to the DialogOp CreateOSRenderRegion method. This can be overriden to use a different type of renderregion for all of your rendering.
virtual void DestroyRenderRegion (RenderRegion *pRender)
 An overridable veneer to the DialogOp DestroyOSRenderRegion method. This can be overriden to use a different type of renderregion for all of your rendering.
virtual void DoShadeGallery (BOOL ShadeIt)
 Called by the base class whenever the shaded status of the gallery is changed, to allow derived galleries to shade/unshade any extra controls that they provide in the window. ONLY called if the gallery is actually open/visible.
void CreateNewSubtree (Document *ParentDoc, SGDisplayGroup *ExistingGroup=NULL)
 Internal call. This takes the KernelBitmap list of the given document and creates a DisplayTree subtree from it. This subtree is then added to the DisplayTree. Note that this does not force a redraw of the list - after making this call, you should also call ForceRedrawOfList.
KernelBitmapGetSelectedBitmap ()
BOOL GetSelectedBitmaps (KernelBitmap ***pOutputArray, UINT32 *pOutputCount)
 Generates a list of all the selected bitmaps in the gallery. Note that the generated array becomes the callers responsibility if TRUE is returned; the caller must CCFree it.
BOOL DeleteSelection ()
 Deletes the selected bitmaps.
KernelBitmapCheckTextureBitmap (KernelBitmap *pBitmap)
 Checks a bitmap to see if can be applied as a texture, and gives the option to create a grey level version if not.
BOOL FindCentreInsertionPosition (Spread **Spread, DocCoord *Position)
 Finds the centre insertion position for clipboard objects.
void SetSelectionFromDocument (BOOL AlwaysScroll=FALSE)
 Sets the bitmap gallery listbox selection state based upon the currently selected object(s) in the document.
BOOL GetBmpInfo (BmpDlgParam *Param)
 Retrieves inforamtion from Bitmaps selected in the Bitmaps Gallery.
BOOL SetBmpInfo (BmpDlgParam *Param)
 Stores info, retrieved from the Bitmap Properties Dialog, in an OILBitmap.

Detailed Description

The Bitmap SuperGallery class.

Author:
Will_Cowling (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; SGDisplayBitmap

Definition at line 296 of file sgbitmap.h.


Constructor & Destructor Documentation

BitmapSGallery::BitmapSGallery  ) 
 

BitmapSGallery default constructor.

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

Definition at line 1635 of file sgbitmap.cpp.

01636 {
01637     DlgResID = _R(IDD_BITMAPSGALLERY);
01638 
01639     // WEBSTER - markn 9/12/96
01640     // Default gallery size
01641 #ifdef WEBSTER
01642     CSize Size(333, 256);
01643     SetGallerySize(Size);
01644 #endif
01645 } 

BitmapSGallery::~BitmapSGallery  ) 
 

BitmapSGallery destructor.

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

Definition at line 1659 of file sgbitmap.cpp.

01660 {
01661 }


Member Function Documentation

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

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

Author:
Will_Cowling (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 (NOTE that this is not necessarily an error, but may simply be that we don't support the given action. e.g. if we don't handle APPLYADJUST, we'll be called again with a normal APPLY call)
See also:
SGActionType

Reimplemented from SuperGallery.

Definition at line 2002 of file sgbitmap.cpp.

02003 {
02004     // No display tree? Better forget about it then!
02005     if (DisplayTree == NULL)
02006         return(FALSE);
02007 
02008     // Determine useful info - this is usually needed for most actions, so always get it
02009     Document        *SelectedDoc = Document::GetSelected();
02010     /*SGDisplayGroup    *DocumentGroup =*/ DisplayTree->FindSubtree(this, SelectedDoc, NULL);
02011     SGDisplayKernelBitmap   *FirstSelected = NULL;
02012     
02013     // Lets see if any of our Items are selected
02014     Document *ParentDoc = (Document *) GetApplication()->Documents.GetHead();
02015     while (ParentDoc != NULL)
02016     {
02017         SGDisplayGroup *DocGroup = DisplayTree->FindSubtree(this, ParentDoc, NULL);
02018         if (DocGroup != NULL)
02019             FirstSelected = (SGDisplayKernelBitmap *) DocGroup->FindNextSelectedItem(NULL);
02020 
02021         if (FirstSelected)
02022             break;
02023 
02024         ParentDoc = (Document *) GetApplication()->Documents.GetNext(ParentDoc);
02025     }
02026 
02027     KernelBitmap *SelectedBitmap = NULL;
02028     if (FirstSelected != NULL)
02029     {
02030         SelectedBitmap = FirstSelected->GetDisplayedKernelBitmap();
02031     }
02032 
02033     // Now, process the action  TO DO! - see Colour gallery for examples
02034     switch(Action)
02035     {
02036         case SGACTION_APPLY:
02037             if (SelectedBitmap != NULL)
02038             {
02039                 // Fill colour selected so create a fill colour attribute
02040                 NodeAttribute *Attrib = new AttrBitmapColourFill;
02041                 if (Attrib == NULL)
02042                     return(FALSE);
02043 
02044                 ((AttrBitmapColourFill *)Attrib)->AttachBitmap(SelectedBitmap);
02045 
02046                 // AttributeSelected knows what to do with a selected attribute
02047                 AttributeManager::AttributeSelected(NULL, Attrib);
02048             }
02049             break;
02050 
02051         case SGACTION_DELETE:
02052             return DeleteSelection();
02053             break;
02054 
02055         case SGACTION_SETOPTIONS:   // Set values in the options dialogue as it is opened
02056             if (CurrentOptionsDlg == NULL)
02057                 return(FALSE);
02058                                                                         // Display Modes
02059             CurrentOptionsDlg->AddDisplayModeName(_R(IDS_GALLERYDM_FULLINFO));  // 0
02060             break;
02061 
02062         case SGACTION_DISPLAYMODECHANGED:
02063             if (DisplayMode < 0 || DisplayMode > 1)
02064                 DisplayMode = 0;
02065             break;
02066 
02067         default:        // Unknown/unsupported command (e.g. CREATE, APPLYADJUST), so we failed to do it
02068             return(FALSE);
02069     }
02070 
02071     return(TRUE);
02072 }

BOOL BitmapSGallery::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 3122 of file sgbitmap.cpp.

03123 {
03124     BOOL ok = TRUE;
03125 
03126     if (MenuID == SGMENU_OPTIONS)
03127     {
03128         // Options menu
03129         ok = ok && AddCommand(TheMenu, (StringBase *) &SGCmd_Find);
03130 //      ok = ok && AddCommand(TheMenu, (StringBase *) &SGCmd_Sort);
03131 //      ok = ok && AddCommand(TheMenu, (StringBase *) &SGCmd_Properties);
03132     }
03133     else
03134     {
03135         // Over-list menu
03136         ok = ok && AddCommand(TheMenu, (StringBase *) &SGCmd_Insert);
03137         ok = ok && AddCommand(TheMenu, (StringBase *) &SGCmd_Fill);
03138         ok = ok && AddCommand(TheMenu, (StringBase *) &SGCmd_Transp,TRUE);
03139 
03140         ok = ok && AddCommand(TheMenu, (StringBase *) &SGCmd_Delete);
03141         ok = ok && AddCommand(TheMenu, (StringBase *) &SGCmd_Save);
03142 //#if _DEBUG
03143         ok = ok && AddCommand(TheMenu, (StringBase *) &SGCmd_Preview);
03144 //#endif
03145 //  WEBSTER-ranbirr-22/11/96
03146 #ifndef WEBSTER
03147         ok = ok && AddCommand(TheMenu, (StringBase *) &SGCmd_XPE_Edit);
03148         ok = ok && AddCommand(TheMenu, (StringBase *) &SGCmd_Trace);
03149 //      ok = ok && AddCommand(TheMenu, (StringBase *) &SGCmd_Effects);      
03150 #endif //webster
03151 
03152 #ifdef PHOTOSHOPPLUGINS
03153 // Only add in if required - general plug-in removal at present
03154         // Need to say which document and more importantly which bitmap we
03155         // want the menu to apply to.
03156         KernelBitmap * pSelectedBitmap = GetSelectedBitmap();
03157         // Now find out what the selected group is, which will be the document group
03158         SGDisplayNode * FirstSelected = DisplayTree->FindNextSelectedItem(NULL);
03159         Document *pDocument = NULL;
03160         if (FirstSelected == NULL)
03161             pDocument = Document::GetSelected();
03162         else
03163             pDocument = ((SGDisplayGroup *) FirstSelected->GetParent())->GetParentDocument();
03164         ERROR3IF(pDocument == NULL, "No parent document?!");
03165 
03166         // Add plug-in ("Special Effects" is the only one still used since Live Effects) to the 
03167         // main menu, not a submenu. Fixes #11376
03168         // Well, in fact we will ask the PlugInsContextMenu to do it for us!
03169         ok = ok && PlugInsContextMenu::BuildMenu(pSelectedBitmap, pDocument, TheMenu, NULL, TRUE);
03170 
03171 #endif
03172         //  WEBSTER-ranbirr-22/11/96
03173         ok = ok && AddCommand(TheMenu, (StringBase *) &SGCmd_Props,TRUE);
03174 
03175         // This is the set background menu option
03176         ok = ok && AddCommand(TheMenu, (StringBase *) &SGCmd_SetBackground, TRUE);  // With separator
03177 
03178         // Add the fold and unfold group items
03179         SGDisplayGroup *TheGroup = FindCommandGroup();      // Fold or unfold as appropriate
03180         if (TheGroup == NULL || !TheGroup->Flags.Folded)
03181             ok = ok && AddCommand(TheMenu, (StringBase *) &SGCmd_FoldGroup);
03182         else
03183             ok = ok && AddCommand(TheMenu, (StringBase *) &SGCmd_UnfoldGroup);
03184 
03185         ok = ok && AddCommand(TheMenu, (StringBase *) &SGCmd_PrevGroup);
03186         ok = ok && AddCommand(TheMenu, (StringBase *) &SGCmd_NextGroup);
03187     }
03188 
03189     return(ok);
03190 }

KernelBitmap * BitmapSGallery::CheckTextureBitmap KernelBitmap pBitmap  )  [protected]
 

Checks a bitmap to see if can be applied as a texture, and gives the option to create a grey level version if not.

Author:
Will_Cowling (Xara Group Ltd) <camelotdev@xara.com>
Date:
16/2/95

Definition at line 2184 of file sgbitmap.cpp.

02185 {
02186     return NodeBitmap::CheckGreyscaleBitmap(pBitmap, _R(IDS_BMPGAL_MAKEGREY),
02187                                                      _R(IDS_BMPGAL_DOGREY));
02188 
02189 /*
02190     if (!BfxALU::IsGreyscaleBitmap(pBitmap))    // Should do proper Grey Level check here
02191     {
02192         INT32 ButtonPressed = 1;
02193 
02194         ButtonPressed = AskQuestion(_R(IDS_BMPGAL_MAKEGREY),
02195                                     _R(IDS_BMPGAL_DOGREY), _R(IDS_CANCEL), 0,   0,
02196                                     1, 1);  // CANCEL=default, CANCEL=cancel
02197 
02198         if (ButtonPressed == 2)     // Apply was cancelled - return NULL
02199             return NULL;
02200 
02201         if (ButtonPressed == 1)
02202         {
02203             // Make a new grey level version of the bitmap, and apply that instead
02204             ABFXMakeGreyscale GSBfx;
02205             KernelBitmap* pNewBitmap = GSBfx.GetProcessedBitmap(pBitmap);
02206 
02207             if (pNewBitmap == NULL)
02208             {
02209                 InformError();
02210                 return NULL;
02211             }
02212 
02213             // We need to check the Document bitmap list to see if
02214             // there is already a grey-level version.
02215 
02216             BitmapList* pBmpList = pBitmap->GetParentBitmapList();
02217             ListItem* pItem = pBmpList->GetHead();
02218 
02219             while (pItem != NULL)
02220             {
02221                 KernelBitmap* pBmp = (KernelBitmap*)pItem;
02222 
02223                 if (pBmp->ActualBitmap != pNewBitmap->ActualBitmap &&
02224                     *pBmp->ActualBitmap == *pNewBitmap->ActualBitmap)
02225                 {
02226                     pNewBitmap->ActualBitmap->Detach();
02227                     delete pNewBitmap;
02228 
02229                     return pBmp;
02230                 }
02231 
02232                 pItem = pBmpList->GetNext(pItem);
02233             }
02234 
02235             // There is no grey level version in this document,
02236             // but there might be one in another document somewhere
02237             // so we'll have a look in the global list.
02238 
02239             GlobalBitmapList* pGlobalBmpList = GetApplication()->GetGlobalBitmapList();
02240             pItem = pGlobalBmpList->GetHead();
02241 
02242             while (pItem != NULL)
02243             {
02244                 OILBitmap* pBmp = (OILBitmap*)pItem;
02245 
02246                 if (pBmp != pNewBitmap->ActualBitmap &&
02247                     *pBmp == *pNewBitmap->ActualBitmap)
02248                 {
02249                     pNewBitmap->ActualBitmap->Detach();
02250                     delete pNewBitmap;
02251 
02252                     return new KernelBitmap(pBmp);
02253                 }
02254 
02255                 pItem = pGlobalBmpList->GetNext(pItem);
02256             }
02257 
02258             String_256 NewName = pBitmap->ActualBitmap->GetName();
02259             NewName += " (Greyscale)";
02260             pNewBitmap->ActualBitmap->SetName(NewName);
02261 
02262             return pNewBitmap;
02263         }
02264     }
02265 
02266     return pBitmap;
02267 */
02268 }

SGDisplayItem * BitmapSGallery::CopyDisplayItem SGDisplayItem SourceItem,
SGDisplayGroup DestGroup,
SGDisplayItem TargetPosition = NULL
[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; SGColour::CopyDisplayItem
Example psuedocode ****

Find the real item (Thingy) to be moved/copied Thingy *ThingyToCopy = ((SGDisplayThingy *)SourceItem)->GetDisplayedThingy();

if (we really want to copy the items, rather than just move them) { Just copy the items...

First, copy the real-item associated with the display item ThingyType *NewThingy = new ThingyType(ThingyToCopy);

Add the copied item to your 'real item' list or whatever. DocThingyList = DestGroup->GetParentDocument()->FindThingyList();

if (TargetPosition == NULL) DocThingyList->AddTail(NewThingy); else { Thingy *TargetPos = ((SGDisplayThingy *)TargetPosition)->GetDisplayedThingy(); if (TargetPos == NULL) DocThingyList->AddTail(NewThingy); else DocThingyList->InsertBefore(TargetPos, NewThingy); }

Now, create a new display item for the copied Thingy, and call the base class helper method to insert it as appropriate. SGDisplayThingy *NewThingyDisplayItem = new SGDisplayThingy(NewThingy); if (NewThingyDisplayItem != NULL) SuperGallery::InsertCopiedItem(NewThingyDisplayItem, DestGroup, TargetPosition);

return(NewThingyDisplayItem); } else { Just move the items

This code will be much the same as the above, but instead of copying the real-item, you will have to move it as appropriate. Instead of making a new DisplayItem to pass on to InsertCopiedItem, simply delink it from the DisplayTree, and then pass it to InsertCopiedItem as follows:

SourceItem->RemoveFromTree(); // Delink from current displaytree position SuperGallery::InsertCopiedItem(SourceItem, DestGroup, TargetPosition);

return(SourceItem); }

Reimplemented from SuperGallery.

Definition at line 1889 of file sgbitmap.cpp.

01891 {
01892     ERROR3IF(SourceItem == NULL || DestGroup == NULL, "Illegal NULL param");
01893 
01894     return(NULL);
01895 
01896 /**** Example psuedocode ****
01897 
01898     // Find the real item (Thingy) to be moved/copied
01899     Thingy *ThingyToCopy = ((SGDisplayThingy *)SourceItem)->GetDisplayedThingy();
01900 
01901     if (we really want to copy the items, rather than just move them)
01902     {
01903         // Just copy the items...
01904         
01905         // First, copy the real-item associated with the display item
01906         ThingyType *NewThingy = new ThingyType(ThingyToCopy);
01907 
01908         // Add the copied item to your 'real item' list or whatever.
01909         DocThingyList = DestGroup->GetParentDocument()->FindThingyList();
01910 
01911         if (TargetPosition == NULL)
01912             DocThingyList->AddTail(NewThingy);
01913         else
01914         {
01915             Thingy *TargetPos = ((SGDisplayThingy *)TargetPosition)->GetDisplayedThingy();
01916             if (TargetPos == NULL)
01917                 DocThingyList->AddTail(NewThingy);
01918             else
01919                 DocThingyList->InsertBefore(TargetPos, NewThingy);
01920         }
01921 
01922         // Now, create a new display item for the copied Thingy, and call the
01923         // base class helper method to insert it as appropriate.
01924         SGDisplayThingy *NewThingyDisplayItem = new SGDisplayThingy(NewThingy);
01925         if (NewThingyDisplayItem != NULL)
01926             SuperGallery::InsertCopiedItem(NewThingyDisplayItem, DestGroup, TargetPosition);
01927 
01928         return(NewThingyDisplayItem);
01929     }
01930     else
01931     {
01932         // Just move the items
01933         
01934         // This code will be much the same as the above, but instead of copying the
01935         // real-item, you will have to move it as appropriate. Instead of making
01936         // a new DisplayItem to pass on to InsertCopiedItem, simply delink it from the
01937         // DisplayTree, and then pass it to InsertCopiedItem as follows:
01938 
01939         SourceItem->RemoveFromTree();       // Delink from current displaytree position
01940         SuperGallery::InsertCopiedItem(SourceItem, DestGroup, TargetPosition);
01941 
01942         return(SourceItem);
01943     }
01944 
01945 ****/
01946 
01947 }

void BitmapSGallery::CreateNewSubtree Document ParentDoc,
SGDisplayGroup ExistingGroup = NULL
[protected]
 

Internal call. This takes the KernelBitmap list of the given document and creates a DisplayTree subtree from it. This subtree is then added to the DisplayTree. Note that this does not force a redraw of the list - after making this call, you should also call ForceRedrawOfList.

Author:
Will_Cowling (Xara Group Ltd) <camelotdev@xara.com>
Date:
27/1/95 (base generated in sgbase.cpp)
Parameters:
ParentDoc - The document to create a display subtree for [INPUTS] ExistingGroup - NULL (creates a new group for this document), or a pointer to the existing group-node for this document (in which case it clears all displayitems from the group and rebuilds it in place - this stops the display group moving around the tree at random!)
Notes: Passing in a NULL parent document pointer results in an ERROR3 - the function returns without doing anything in retail builds

See also:
SuperGallery::ForceRedrawOfList

Definition at line 1690 of file sgbitmap.cpp.

01691 {
01692     ERROR3IF(ParentDoc == NULL, "BitmapSGallery::CreateNewSubtree - NULL parameter passed in");
01693     if (ParentDoc == NULL || DisplayTree == NULL)
01694         return;
01695 
01696     SGDisplayGroup  *DisplayDocument;
01697     SGDisplayKernelBitmap *DisplayKernelBitmap;
01698 
01699     if (ExistingGroup != NULL)
01700     {
01701         ERROR3IF(ExistingGroup->GetParentDocument() != ParentDoc, 
01702                  "This group is not for that document! What's going down, dude?");
01703         DisplayDocument = ExistingGroup;                            // Use existing group
01704         DisplayDocument->DestroySubtree(FALSE); // Wipe any existing KernelBitmap display items
01705     }
01706     else
01707     {
01708         DisplayDocument = new SGDisplayGroup(this, ParentDoc,NULL); // Create new Group
01709 
01710         if (DisplayDocument == NULL)                                // Total failure - abort
01711             return;
01712 
01713         DisplayDocument->Flags.CanSelect = TRUE;                    // Groups are selectable
01714         DisplayTree->AddItem(DisplayDocument);                      // Add new group to tree
01715     }
01716 
01717     // Lets generate some SGDisplayKernelBitmaps to be displayed ...
01718 
01719     // Get the bitmap list
01720     BitmapList* Bitmaps = ParentDoc->GetBitmapList();
01721 
01722     // now iterate though the list, creating display items for each bitmap
01723     KernelBitmap* Ptr = (KernelBitmap*)Bitmaps->GetHead();
01724     while (Ptr != NULL)
01725     {
01726         // Ignore bitmaps that have been deleted
01727         if (!Ptr->GetActualBitmap()->IsHiddenInGallery())
01728         {
01729             DisplayKernelBitmap = new SGDisplayKernelBitmap(Ptr);
01730             if (DisplayKernelBitmap != NULL)
01731                 DisplayDocument->AddItem(DisplayKernelBitmap);
01732         }
01733 
01734         Ptr = (KernelBitmap*)Bitmaps->GetNext(Ptr);
01735     }
01736 }

RenderRegion * BitmapSGallery::CreateRenderRegion DocRect VirtualSize,
ReDrawInfoType DlgRedrawInfo
[protected, virtual]
 

An overridable veneer to the DialogOp CreateOSRenderRegion method. This can be overriden to use a different type of renderregion for all of your rendering.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
29/3/95
If you override this, you MUST also override DestroyRenderRegion!

See also:
SuperGallery::DestroyRenderRegion

Reimplemented from SuperGallery.

Definition at line 2973 of file sgbitmap.cpp.

02974 {
02975     return(CreateOSRenderRegion(VirtualSize, DlgRedrawInfo));
02976 }

BOOL BitmapSGallery::DeleteSelection  )  [protected]
 

Deletes the selected bitmaps.

Author:
Will_Cowling (Xara Group Ltd) <camelotdev@xara.com>
Date:
16/2/95

Definition at line 2084 of file sgbitmap.cpp.

02085 {
02086     INT32 ButtonPressed = 2;
02087 
02088     ButtonPressed = AskQuestion(_R(IDS_BMPGAL_BMPINUSE),
02089                                 _R(IDS_BMPGAL_KILL), _R(IDS_CANCEL), 0, 0,
02090                                 2, 2);  // CANCEL=default, CANCEL=cancel
02091 
02092     if (ButtonPressed == 2)     // Delete was cancelled - return FALSE
02093         return(FALSE);
02094 
02095     if (ButtonPressed == 1)     // Force-delete all items, so go ahead and delete
02096     {
02097         BOOL DeletedBitmaps = FALSE;
02098         IgnoreBmpListChange = TRUE;
02099 
02100         GlobalBitmapList* pGlobalBmpList = GetApplication()->GetGlobalBitmapList();
02101 
02102         Document *ParentDoc = (Document *) GetApplication()->Documents.GetHead();
02103         while (ParentDoc != NULL)
02104         {
02105             // Get the bitmap list
02106             BitmapList* pDocBitmaps = ParentDoc->GetBitmapList();
02107 
02108             SGDisplayKernelBitmap* Selected = NULL;
02109 
02110             SGDisplayGroup *DocGroup = DisplayTree->FindSubtree(this, ParentDoc, NULL);
02111             if (DocGroup != NULL)
02112                 Selected = (SGDisplayKernelBitmap *) DocGroup->FindNextSelectedItem(NULL);
02113 
02114             while (Selected != NULL)
02115             {
02116                 KernelBitmap* SelectedBitmap = Selected->GetDisplayedKernelBitmap();
02117 
02118                 // Get the next one before we delete this one
02119                 Selected = (SGDisplayKernelBitmap*)DocGroup->FindNextSelectedItem(Selected);
02120 
02121                 // Is this Kernel bitmap pointer still valid ?
02122                 if (!pDocBitmaps->IsEmpty() &&
02123                     pDocBitmaps->FindPosition(SelectedBitmap) != NOT_IN_LIST)
02124                 {
02125                     if (SelectedBitmap->ActualBitmap != OILBitmap::Default)
02126                     {
02127                         // Is this Actual bitmap pointer still valid ?
02128                         if (!pGlobalBmpList->IsEmpty() &&
02129                             pGlobalBmpList->FindPosition(SelectedBitmap->ActualBitmap) != NOT_IN_LIST)
02130                         {
02131                             OpDeleteBitmap* pOp = new OpDeleteBitmap();
02132                             if (pOp)
02133                             {
02134                                 pOp->DoDelete(SelectedBitmap->ActualBitmap);
02135                                 DeletedBitmaps = TRUE;
02136                             }
02137                         }
02138                     }
02139                     else
02140                     {
02141                         // Shouldn't we be using an error from the resource file here??
02142                         Error::SetError(0, _T("You cannot delete the Default Bitmap"),0);
02143                         InformError();
02144                     }
02145                 }
02146             }
02147 
02148             ParentDoc = (Document *) GetApplication()->Documents.GetNext(ParentDoc);
02149         }
02150         
02151         IgnoreBmpListChange = FALSE;
02152 
02153         if (DeletedBitmaps)
02154         {
02155             Document *ParentDoc = (Document *) GetApplication()->Documents.GetHead();
02156             while (ParentDoc != NULL)
02157             {
02158                 SGDisplayNode *Ptr = DisplayTree->FindSubtree(this, ParentDoc, NULL);
02159                 CreateNewSubtree(ParentDoc, (SGDisplayGroup *) Ptr);
02160 
02161                 ParentDoc = (Document *) GetApplication()->Documents.GetNext(ParentDoc);
02162             }
02163 
02164             // And force a redraw of the entire list
02165             ForceRedrawOfList();
02166             SelectionHasChanged();
02167         }
02168     }
02169 
02170     return TRUE;
02171 }

void BitmapSGallery::DestroyRenderRegion RenderRegion pRender  )  [protected, virtual]
 

An overridable veneer to the DialogOp DestroyOSRenderRegion method. This can be overriden to use a different type of renderregion for all of your rendering.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
29/3/95
If you override this, you MUST also override CreateRenderRegion!

See also:
SuperGallery::CreateRenderRegion

Reimplemented from SuperGallery.

Definition at line 2997 of file sgbitmap.cpp.

02998 {
02999     DestroyOSRenderRegion(pRender);
03000 }

void BitmapSGallery::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 3316 of file sgbitmap.cpp.

03317 {
03318     if (*CommandID == SGCmd_Insert)
03319     {
03320         // Fake a button click message to ourself
03321         DialogMsg Bob(WindowID, DIM_LFT_BN_CLICKED, _R(IDC_BMPGAL_CREATE));
03322         Message(&Bob);
03323     }
03324 
03325     else if (*CommandID == SGCmd_Fill)
03326     {
03327         // Fake a button click message to ourself
03328         DialogMsg Bob(WindowID, DIM_LFT_BN_CLICKED, _R(IDC_BMPGAL_FILL));
03329         Message(&Bob);
03330     }
03331 //  WEBSTER-ranbirr-22/11/96
03332 #ifndef WEBSTER
03333         else if (*CommandID == SGCmd_Transp)
03334     {
03335         // Fake a button click message to ourself
03336         DialogMsg Bob(WindowID, DIM_LFT_BN_CLICKED, _R(IDC_BMPGAL_TEXTURE));
03337         Message(&Bob);
03338     }
03339 #endif //webster
03340     else if (*CommandID == SGCmd_Save)
03341     {
03342         // Fake a button click message to ourself
03343         DialogMsg Bob(WindowID, DIM_LFT_BN_CLICKED, _R(IDC_BMPGAL_SAVE));
03344         Message(&Bob);
03345     }
03346     else if (*CommandID == SGCmd_Preview)
03347     {
03348         // Fake a button click message to ourself
03349         DialogMsg Bob(WindowID, DIM_LFT_BN_CLICKED, _R(IDC_BMPGAL_PREVIEW));
03350         Message(&Bob);
03351     }
03352     else if (*CommandID == SGCmd_XPE_Edit)
03353     {
03354         // Fake a button click message to ourself
03355         DialogMsg Bob(WindowID, DIM_LFT_BN_CLICKED, _R(IDC_BMPGAL_XPE_EDIT));
03356         Message(&Bob);
03357     }
03358 //  WEBSTER-ranbirr-22/11/96
03359 #ifndef WEBSTER
03360     else if (*CommandID == SGCmd_Trace)
03361     {
03362         // Fake a button click message to ourself
03363         DialogMsg Bob(WindowID, DIM_LFT_BN_CLICKED, _R(IDC_BMPGAL_TRACE));
03364         Message(&Bob);
03365     }
03366 /*  else if (*CommandID == SGCmd_Effects)
03367     {
03368         // Fake a button click message to ourself
03369         DialogMsg Bob(WindowID, DIM_LFT_BN_CLICKED, _R(IDC_BMPGAL_EFFECTS));
03370         Message(&Bob);
03371     } */
03372 #endif //webster
03373 #ifdef PHOTOSHOPPLUGINS
03374 // Only add in if required - general plug-in removal at present
03375     else if (*CommandID == SGCmd_PlugIns)
03376     {
03377         // Fake a button click message to ourself
03378         DialogMsg Bob(WindowID, DIM_LFT_BN_CLICKED, _R(IDC_BMPGAL_PLUGINS));
03379         Message(&Bob);
03380     }
03381 #endif
03382     else if (*CommandID == SGCmd_SetBackground)
03383     {
03384         // Fake a button click message to ourself
03385         DialogMsg Bob(WindowID, DIM_LFT_BN_CLICKED, _R(IDC_BMPGAL_BACKGROUND));
03386         Message(&Bob);
03387     }
03388 
03389     // WEBSTER-ranbirr-22/11/96
03390     else if (*CommandID == SGCmd_Props)
03391     {
03392         // Fake a button click message to ourself
03393         DialogMsg Bob(WindowID, DIM_LFT_BN_CLICKED, _R(IDC_BMPGAL_PROPS));
03394         Message(&Bob);
03395     }
03396     else
03397         SuperGallery::DoCommand(CommandID);     // Unknown command- pass to the base class
03398 }

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

Called by the base class whenever the shaded status of the gallery is changed, to allow derived galleries to shade/unshade any extra controls that they provide in the window. ONLY called if the gallery is actually open/visible.

Author:
Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
Date:
4/7/97
Parameters:
ShadeIt - TRUE if the gallery is being shaded [INPUTS] FALSE if the gallery is being unshaded
Notes: Need not be overridden - the default action is to do nothing extra to the normal shade/unshade operation.
See also:
Gallery::ShadeGallery; Gallery::UnshadeGallery

Reimplemented from SuperGallery.

Definition at line 2364 of file sgbitmap.cpp.

02365 {
02366     // Shade any non-standard buttons that we have on the gallery
02367     EnableGadget(_R(IDC_BMPGAL_SAVE),   !ShadeIt);
02368 
02369     EnableGadget(_R(IDC_BMPGAL_PROPS),  !ShadeIt);
02370     
02371     EnableGadget(_R(IDC_BMPGAL_BACKGROUND), !ShadeIt);
02372 #ifdef PHOTOSHOPPLUGINS
02373 // Only add in if required - general plug-in removal at present
02374     EnableGadget(_R(IDC_BMPGAL_PLUGINS),    !ShadeIt);
02375 #endif
02376 //#if _DEBUG
02377     EnableGadget(_R(IDC_BMPGAL_PREVIEW),    !ShadeIt);
02378 //#endif
02379     EnableGadget(_R(IDC_BMPGAL_CREATE), !ShadeIt);
02380 
02381     EnableGadget(_R(IDC_BMPGAL_FILL),   !ShadeIt);
02382     EnableGadget(_R(IDC_BMPGAL_TEXTURE),    !ShadeIt);
02383     EnableGadget(_R(IDC_BMPGAL_TRACE),  !ShadeIt);
02384     EnableGadget(_R(IDC_BMPGAL_XPE_EDIT),   !ShadeIt);
02385     //EnableGadget(_R(IDC_BMPGAL_EFFECTS),  !ShadeIt);
02386 }

BOOL BitmapSGallery::FindCentreInsertionPosition Spread **  Spread,
DocCoord Position
[protected]
 

Finds the centre insertion position for clipboard objects.

Author:
Simon_Maneggio (Xara Group Ltd) <camelotdev@xara.com>
Date:
28/7/94
Parameters:
- [INPUTS]
Spread,: The spread to place the clipboard objects on [OUTPUTS] Position:The centre of the view (Spread coords)
Returns:
-

Errors: - Scope: private

See also:
-

Definition at line 2888 of file sgbitmap.cpp.

02889 {
02890     // ---------------------------------------------------------------------------------
02891     // Find out which spread is in the centre of the view 
02892     // this is the spread that the pasted objects will be placed on
02893 
02894     // Obtain the current DocView
02895     DocView* CurDocView = DocView::GetCurrent();
02896 
02897     ENSURE(CurDocView != NULL, "The current DocView is NULL"); 
02898     if (CurDocView == NULL)
02899     {
02900         return FALSE; // No DocView
02901     }
02902 
02903     // Get the view rect
02904     WorkRect WrkViewRect = CurDocView->GetViewRect();
02905 
02906     if (WrkViewRect.IsEmpty() || (!WrkViewRect.IsValid()) )
02907     {
02908         return FALSE; // Defensive
02909     }
02910     
02911     // Determine the centre of the view
02912     WorkCoord WrkCentreOfView; 
02913     WrkCentreOfView.x = WrkViewRect.lo.x    + (WrkViewRect.Width()/2); 
02914     WrkCentreOfView.y = WrkViewRect.lo.y    + (WrkViewRect.Height()/2);
02915     
02916     // FindEnclosing spread requires an OilCoord
02917     OilCoord OilCentreOfView = WrkCentreOfView.ToOil(CurDocView->GetScrollOffsets()); 
02918 
02919     // Find out which spread to insert the pasteboard objects onto
02920     (*Spread) = CurDocView->FindEnclosingSpread(OilCentreOfView);
02921     if ((*Spread) == NULL)
02922     {
02923         // There is no spread
02924         return FALSE; 
02925     }
02926 
02927     // Phew
02928     // ---------------------------------------------------------------------------------
02929     // Now lets find the spread coordinate of the centre of the view
02930     DocRect DocViewRect = CurDocView->GetDocViewRect(*Spread);
02931     
02932     if ( DocViewRect.IsEmpty() || (!DocViewRect.IsValid()) )
02933     {
02934         return FALSE; // Defensive
02935     }
02936 
02937     ENSURE( ( (!DocViewRect.IsEmpty()) && DocViewRect.IsValid()), 
02938             "DocViewRect is invalid" );
02939 
02940     // Find the centre of the DocViewRect
02941     DocCoord DocCentreOfView; 
02942     DocCentreOfView.x = DocViewRect.lo.x    + (DocViewRect.Width()/2); 
02943     DocCentreOfView.y = DocViewRect.lo.y    + (DocViewRect.Height()/2);
02944 
02945     // Now convert from DocCoords to spread coords
02946     (*Spread)->DocCoordToSpreadCoord(&DocCentreOfView);
02947 
02948     // Finally, fill in the return value
02949     *Position = DocCentreOfView;
02950     
02951     return TRUE;  
02952 }

BOOL BitmapSGallery::GetBmpInfo BmpDlgParam Param  )  [protected]
 

Retrieves inforamtion from Bitmaps selected in the Bitmaps Gallery.

BOOL BitmapSGallery::GetBmpInfo(BmpDlgPara Param)

Author:
Ranbir_Rana (Xara Group Ltd) <camelotdev@xara.com>
Date:
05/01/96
Parameters:
Param - Allows the transfer of data to and from the bitmap poperties dialog. [INPUTS]
- [OUTPUTS]
Returns:
TRUE if Successful, else FALSE.
See also:
-

Definition at line 3634 of file sgbitmap.cpp.

03635 {
03636     ERROR2IF(Param == NULL,FALSE,"Param is NULL");
03637 
03638     UINT32 ListSize = 0;                
03639     KernelBitmap** pList = NULL;    
03640 //  BOOL Done = FALSE;
03641     
03642     if (!GetSelectedBitmaps(&pList, &ListSize))
03643         return FALSE;
03644 
03645     //Pass these values to our Param class, for use in the dialog code
03646     Param->SetBitmapList(pList);
03647     Param->SetListSize(ListSize);
03648 
03649     if (ListSize>1)
03650     {
03651         Param->SetMany(TRUE);
03652     }
03653     
03654         String_256* BitmapCols = new String_256[ListSize];
03655         String_256* Width = new String_256[ListSize];
03656         String_256* Height = new String_256[ListSize];
03657         String_256* BitmapFormat = new String_256[ListSize];
03658         UINT32* Delay   = new UINT32[ListSize];
03659         BOOL* Interpolation = new BOOL[ListSize];
03660         GIFDisposalMethod* DisposalMethod = new GIFDisposalMethod[ListSize];
03661         UINT32* TranspType = new UINT32[ListSize];
03662 
03663         if ( !BitmapCols || !Width || !Height ||
03664              !BitmapFormat  || !Delay  || !DisposalMethod || !TranspType ) 
03665             return FALSE;
03666 
03667             UINT32 i=0;                 // Loop index    
03668             UINT32 TempListSize=ListSize; // Keep a record of our list size.
03669             INT32 Bytes =0;             // Holds the bitmap Memory info.    
03670 
03671         while (ListSize>0)
03672         {
03673             ListSize--;
03674 
03675             KernelBitmap* pKernelBitmap = pList[ListSize];
03676             if (pKernelBitmap == NULL)
03677                 return FALSE;
03678                             
03679             OILBitmap* pOILBitmap = pKernelBitmap->GetActualBitmap();
03680             if (pOILBitmap == NULL)
03681                 return FALSE;
03682 
03683 PORTNOTE("other", "Removed XPE hooks")
03684 #ifndef EXCLUDE_FROM_XARALX
03685             IXMLDOMDocumentPtr pEditsList = NULL;
03686             KernelBitmap* pMaster = NULL;
03687             pKernelBitmap->GetXPEInfo(pMaster, pEditsList);
03688             BOOL bIsXPE = (pMaster!=NULL && pEditsList!=NULL);
03689 #else
03690             BOOL bIsXPE = FALSE;
03691 #endif
03692 
03693             //  Get the bitmap name details.
03694             Param->SetBitmapName(pOILBitmap->GetName());
03695 
03696             // Is this bitmap a compressed JPEG?
03697             IsJPEG(pList,ListSize,Param,&Bytes);
03698 
03699             // Set the format field - JPEG\Bitmap.
03700             if(Param->GetIsJPEG())
03701             {
03702                 Param->SetBitmapFormat(_R(IDS_FORMAT_JPEG));
03703             }
03704             else if (bIsXPE)
03705             {
03706                 Param->SetBitmapFormat(_R(IDS_FORMAT_XPE));
03707             }
03708             else
03709             {
03710                 Param->SetBitmapFormat(_R(IDS_FORMAT_BITMAP));
03711             }
03712 
03713             // Get the Delay for the selected bitmap.
03714             Param->SetAnimDelay(pKernelBitmap->GetDelay());
03715 
03716             // Get the 'smooth when scaled up?' setting
03717             Param->SetInterpolation(pKernelBitmap->GetInterpolation());
03718 
03719             // Now find how many colours it has?
03720             INT32 bpp = pKernelBitmap->GetBPP();
03721             Param->SetBitmapTranspType(_R(IDS_BITMAPTRANSPTYPE_NONE));
03722             UINT32 ttype = TT_NoTranspType;
03723 
03724             if (bpp <= 8)
03725             {
03726                 // Check to see if this is a masked bitmap.
03727                 INT32 Index=0;
03728 
03729                 if(pKernelBitmap->GetTransparencyIndex(&Index)) 
03730                 {
03731                     Param->SetBitmapTranspType(_R(IDS_BITMAPTRANSPTYPE_MASKED));
03732                     ttype = TT_Mix;
03733                 }
03734             }
03735             else if (bpp<32)
03736             {
03737                 Param->SetBitmapTranspType(_R(IDS_BITMAPTRANSPTYPE_NONE));
03738             }
03739             else
03740             {
03741                 Param->SetBitmapTranspType(_R(IDS_BITMAPTRANSPTYPE_ALPHA));
03742                 ttype = TT_StainGlass;
03743             }
03744 
03745             switch (bpp)
03746             {
03747                 case 1:
03748                         Param->SetBitmapCols(_R(IDS_SGBITMAP_MONOCHROME));  // "Monochrome";
03749                 break;
03750 
03751                 case 2:
03752                         Param->SetBitmapCols(_R(IDS_SGBITMAP_4COLOURS));    // "4 colours";
03753                 break;
03754 
03755                 case 4:
03756                         Param->SetBitmapCols(_R(IDS_SGBITMAP_16COLOURS));   // "16 colours";
03757                 break;
03758 
03759                 case 8:
03760                         Param->SetBitmapCols(_R(IDS_SGBITMAP_256COLOURS));  // "256 colours";
03761                 break;
03762     
03763                 case 16:
03764                         Param->SetBitmapCols(_R(IDS_SGBITMAP_65COLOURS));       // "65K colours";
03765                 break;
03766 
03767                 case 24:
03768                         Param->SetBitmapCols(_R(IDS_SGBITMAP_MILLIONS_COLOURS)); // "Millions of colours";
03769                 break;
03770 
03771                 case 32:
03772                         Param->SetBitmapCols(_R(IDS_SGBITMAP_32_BIT)); // "Millions of colours";
03773                 break;
03774 
03775                 default:
03776                         Param->SetBitmapCols ("");
03777                     break;
03778             }
03779         
03780             // Get the bitmap Dimensions.
03781             BitmapInfo Info;
03782 
03783             if(pOILBitmap->GetInfo(&Info))
03784             {
03785                 // Get its pixel Width and Height.
03786                 Convert::LongToString(Info.PixelWidth, &Param->GetBitmapWidth());
03787                 Convert::LongToString(Info.PixelHeight, &Param->GetBitmapHeight());
03788             
03789                 // If this bitmap is not have a compressed JPEG, then calculate the memeory used by the bitmap.
03790                 if(!Param->GetIsJPEG() && !bIsXPE)
03791                 {
03792                     // Work out how much memory it is using.
03793                     Bytes += (Info.PixelWidth * Info.PixelHeight * bpp)/8;
03794                 }
03795             }
03796 
03797             // Get the bitmap Animation Restore details.
03798             Param->SetRestoreType(pOILBitmap->GetAnimationRestoreType());
03799 
03800             // Keep a record of the details.
03801             BitmapCols[i]   = Param->GetBitmapCols();
03802             Width[i]        = Param->GetBitmapWidth();
03803             Height[i]       = Param->GetBitmapHeight();
03804             BitmapFormat[i] = Param->GetBitmapFormat();
03805             Delay[i]        = Param->GetAnimDelay();
03806             Interpolation[i]= Param->GetInterpolation();
03807             DisposalMethod[i] = Param->GetRestoreType();
03808             TranspType[i]   = ttype;
03809             i++;
03810         }   
03811 
03812         // ok, we have no more bitmaps\JPEGS, so convert the memory (Bytes), into a string.
03813         Convert::BytesToString(&Param->GetMemoryUsed(),(INT32)Bytes);
03814             
03815         // Compare the bitmap colors,Dimensions,Transparency and Format fields and set their flags appropriately.
03816         // i.e. If for any one field, all the bitmaps are not the same, then we output "-", instead of the details.
03817         // Only do this if more than one bitmap is selected..
03818 
03819         if (TempListSize>1)
03820         {
03821             for(i=0; i<TempListSize; i++)
03822             {
03823                 for(UINT32 e=i+1; e<TempListSize; e++)
03824                 {
03825                     if (BitmapCols[i] != BitmapCols[e])
03826                             Param->SetSameColors(FALSE);
03827                         
03828                     if (Width[i] != Width[e])
03829                             Param->SetSameDimensions(FALSE);
03830                         
03831                     if (Height[i] != Height[e])
03832                             Param->SetSameDimensions(FALSE);
03833 
03834                     if (BitmapFormat[i] != BitmapFormat[e])
03835                             Param->SetSameFormat(FALSE);
03836 
03837                     if  (DisposalMethod[i] != DisposalMethod[e])
03838                             Param->SetSameRestoreType(FALSE);
03839 
03840                     if  (Delay[i] != Delay[e])
03841                             Param->SetAreDelayValuesSame(FALSE);
03842 
03843                     if  (Interpolation[i] != Interpolation[e])
03844                             Param->SetAreInterpolationValuesSame(FALSE);
03845 
03846                     if (TranspType[i] != TranspType[e])
03847                             Param->SetSameTranspType(FALSE);
03848                 }
03849             }
03850         }
03851                             
03852         if (pList != NULL)
03853         CCFree(pList);
03854         delete [] BitmapCols;
03855         delete [] Width;
03856         delete [] Height;
03857         delete [] DisposalMethod;
03858         delete [] BitmapFormat;
03859         delete [] Delay;
03860         delete [] Interpolation;
03861         delete [] TranspType;
03862 
03863         return TRUE;
03864 }

OpState BitmapSGallery::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] in 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 3220 of file sgbitmap.cpp.

03221 {
03222     OpState State;
03223 
03224     if (*CommandID == SGCmd_Properties || *CommandID == SGCmd_Sort)
03225     {
03226         State.Greyed = TRUE;
03227         ShadeReason->MakeMsg(_R(IDS_SGSHADE_NOTSUPPORTED));
03228     }
03229     else if (*CommandID == SGCmd_Delete)
03230     {
03231         INT32 Count = GetSelectedItemCount();
03232         if (Count == 0)
03233         {
03234             State.Greyed = TRUE;
03235             ShadeReason->MakeMsg(_R(IDS_SGSHADE_NOSEL));
03236         }
03237         else if (Count == 1 && GetSelectedBitmap()->ActualBitmap == OILBitmap::Default)
03238         {
03239             State.Greyed = TRUE;
03240             ShadeReason->MakeMsg(_R(IDS_SGSHADE_NODELBITMAP));
03241         }
03242     }
03243         else if (*CommandID == SGCmd_Insert || *CommandID == SGCmd_Fill
03244 //  WEBSTER-ranbirr-22/11/96
03245 #ifndef WEBSTER
03246                  || *CommandID == SGCmd_Transp
03247                  || *CommandID == SGCmd_Trace || *CommandID == SGCmd_XPE_Edit || *CommandID == SGCmd_Effects
03248                  || *CommandID == SGCmd_SetBackground
03249 #endif //Webster
03250 #ifdef PHOTOSHOPPLUGINS
03251 // Only add in if required - general plug-in removal at present
03252                  || *CommandID == SGCmd_PlugIns
03253 #endif
03254                  )
03255     {
03256         if (GetSelectedItemCount() != 1)
03257         {
03258             State.Greyed = TRUE;
03259             ShadeReason->MakeMsg(_R(IDS_SGSHADE_SINGLE));
03260         }
03261     }
03262     else if (*CommandID == SGCmd_Save)
03263     {
03264         if (GetSelectedItemCount() == 0)
03265         {
03266             State.Greyed = TRUE;
03267             ShadeReason->MakeMsg(_R(IDS_SGSHADE_NOSEL));
03268         }
03269     }
03270     else if (*CommandID == SGCmd_Preview)
03271     {
03272         if (GetSelectedItemCount() == 0)
03273         {
03274             State.Greyed = TRUE;
03275             ShadeReason->MakeMsg(_R(IDS_SGSHADE_NOSEL));
03276         }
03277     }
03278     else if (*CommandID == SGCmd_Props)
03279     {
03280         if (GetSelectedItemCount() == 0)
03281         {
03282             State.Greyed = TRUE;
03283             ShadeReason->MakeMsg(_R(IDS_SGSHADE_NOSEL));
03284         }
03285     }
03286     else
03287         return(SuperGallery::GetCommandState(CommandID, ShadeReason));      // Unknown command- pass to baseclass
03288 
03289     return(State);
03290 }

KernelBitmap * BitmapSGallery::GetSelectedBitmap  )  [protected]
 

Definition at line 1951 of file sgbitmap.cpp.

01952 {
01953     // Determine useful info - this is usually needed for most actions, so always get it
01954     Document        *SelectedDoc = Document::GetSelected();
01955     /*SGDisplayGroup    *DocumentGroup =*/ DisplayTree->FindSubtree(this, SelectedDoc, NULL);
01956     SGDisplayKernelBitmap   *FirstSelected = NULL;
01957     
01958     // Lets see if any of our Items are selected
01959     Document *ParentDoc = (Document *) GetApplication()->Documents.GetHead();
01960     while (ParentDoc != NULL)
01961     {
01962         SGDisplayGroup *DocGroup = DisplayTree->FindSubtree(this, ParentDoc, NULL);
01963         if (DocGroup != NULL)
01964             FirstSelected = (SGDisplayKernelBitmap *) DocGroup->FindNextSelectedItem(NULL);
01965 
01966         if (FirstSelected)
01967             break;
01968 
01969         ParentDoc = (Document *) GetApplication()->Documents.GetNext(ParentDoc);
01970     }
01971 
01972     KernelBitmap *SelectedBitmap = NULL;
01973     if (FirstSelected != NULL)
01974     {
01975         SelectedBitmap = FirstSelected->GetDisplayedKernelBitmap();
01976     }
01977 
01978     return SelectedBitmap;
01979 }

BOOL BitmapSGallery::GetSelectedBitmaps KernelBitmap ***  pOutputArray,
UINT32 pOutputCount
[protected]
 

Generates a list of all the selected bitmaps in the gallery. Note that the generated array becomes the callers responsibility if TRUE is returned; the caller must CCFree it.

Author:
Peter_Arnold (Xara Group Ltd) <camelotdev@xara.com>
Date:
11/6/96
Parameters:
see Outputs [INPUTS]
pOutputArray - list of selected KernelBitmaps [OUTPUTS] pOutputCount - the length of the list
Returns:
TRUE/FALSE for success/error
See also:
BitmapSGallery::GetSelectedBitmap

Definition at line 3555 of file sgbitmap.cpp.

03556 {
03557     // Init vars
03558     ERROR2IF(pOutputArray==NULL || pOutputCount==NULL, FALSE, "NULL output param");
03559     KernelBitmap** pBuildingArray = NULL;
03560 //  UINT32 BuildingCount = 0;
03561     
03562     // Lets see if any of our items are selected
03563     Document* ParentDoc = (Document*) GetApplication()->Documents.GetHead();
03564     BOOL ok = TRUE;
03565     while (ParentDoc!=NULL && ok)
03566     {
03567         SGDisplayGroup *DocGroup = DisplayTree->FindSubtree(this, ParentDoc, NULL);
03568         if (DocGroup != NULL)
03569         {
03570             // Note the selected items in this group
03571             SGDisplayKernelBitmap* pCurrent = (SGDisplayKernelBitmap*)DocGroup->FindNextSelectedItem(NULL);
03572             while (pCurrent!=NULL && ok)
03573             {
03574                 if (pBuildingArray==NULL)
03575                 {
03576                     // Claim selected space
03577                     pBuildingArray = (KernelBitmap**) CCMalloc(sizeof(KernelBitmap*));
03578                     if (pBuildingArray == NULL)
03579                         ok = FALSE;
03580                     else
03581                         pBuildingArray[0] = pCurrent->GetDisplayedKernelBitmap();
03582                     *pOutputCount = 1;
03583                 }
03584                 else
03585                 {
03586                     // Add to end of selection
03587                     KernelBitmap** pTemp = (KernelBitmap**) CCRealloc(pBuildingArray, ((*pOutputCount)+1)*sizeof(KernelBitmap*));
03588                     if (pTemp == NULL)
03589                         ok = FALSE;
03590                     else
03591                     {
03592                         pBuildingArray = pTemp;
03593                         pBuildingArray[*pOutputCount] = pCurrent->GetDisplayedKernelBitmap();
03594                     }
03595                     (*pOutputCount)++;
03596                 }
03597     
03598                 pCurrent = (SGDisplayKernelBitmap*)DocGroup->FindNextSelectedItem(pCurrent);
03599             }
03600         }
03601 
03602         ParentDoc = (Document *) GetApplication()->Documents.GetNext(ParentDoc);
03603     }
03604 
03605     if (!ok)
03606     {
03607         CCFree(pBuildingArray);
03608         *pOutputArray = NULL;
03609         *pOutputCount = 0;
03610     }
03611     else
03612         *pOutputArray = pBuildingArray;
03613 
03614     return ok;
03615 }

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

Checks a DragMessage to see if it is a bitmap 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 SuperGallery.

Definition at line 2859 of file sgbitmap.cpp.

02860 {
02861     // If it's a bitmap drag, add a target for our window. If not, let the base class
02862     // have a look at it (to see if it is a gallery item being dragged)
02863     if (DragMsg->pInfo->IsKindOf(CC_RUNTIME_CLASS(GalleryBitmapDragInfo)))
02864         /* SGBitmapDragTarget *NewTarget =*/ new SGBitmapDragTarget(this, GetListGadgetID());
02865     else
02866         SuperGallery::HandleDragStart(DragMsg);
02867 }

BOOL BitmapSGallery::HasDelayValueChanged  ) 
 

BOOL BitmapSGallery::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 without doing anything.

Reimplemented from SuperGallery.

Definition at line 3050 of file sgbitmap.cpp.

03051 {
03052     static BOOL MenusInitialised = FALSE;
03053 
03054     BOOL ok = TRUE;
03055 
03056     if (!MenusInitialised)
03057     {
03058         // Initialise menu command Ops
03059 
03060         // "Standard" entries for options menu
03061         ok = ok && InitMenuCommand((StringBase *) &SGCmd_Find, _R(IDS_SGMENU_FIND));
03062         ok = ok && InitMenuCommand((StringBase *) &SGCmd_Sort, _R(IDS_SGMENU_SORT));
03063         ok = ok && InitMenuCommand((StringBase *) &SGCmd_Properties, _R(IDS_SGMENU_PROPERTIES));
03064 
03065         // "Special" entries for over-list menu
03066         ok = ok && InitMenuCommand((StringBase *) &SGCmd_Insert, _R(IDS_SGMENU_INSERT));
03067         ok = ok && InitMenuCommand((StringBase *) &SGCmd_Fill, _R(IDS_SGMENU_FILL));
03068         ok = ok && InitMenuCommand((StringBase *) &SGCmd_Transp, _R(IDS_SGMENU_TRANSP));
03069         ok = ok && InitMenuCommand((StringBase *) &SGCmd_XPE_Edit, _R(IDS_SGMENU_XPE_EDIT));
03070         ok = ok && InitMenuCommand((StringBase *) &SGCmd_Delete, _R(IDS_SGMENU_DELETE));
03071         ok = ok && InitMenuCommand((StringBase *) &SGCmd_Save, _R(IDS_SGMENU_SAVE));
03072 //#if _DEBUG
03073         ok = ok && InitMenuCommand((StringBase *) &SGCmd_Preview, _R(IDS_SGMENU_PREVIEW));
03074 //#endif
03075 //  WEBSTER-ranbirr-22/11/96
03076 #ifndef WEBSTER
03077         ok = ok && InitMenuCommand((StringBase *) &SGCmd_Trace, _R(IDS_SGMENU_TRACE));
03078         ok = ok && InitMenuCommand((StringBase *) &SGCmd_Effects, _R(IDS_SGMENU_EFFECTS));
03079 #endif //webster
03080 #ifdef PHOTOSHOPPLUGINS
03081 // Only add in if required - general plug-in removal at present
03082         ok = ok && InitMenuCommand((StringBase *) &SGCmd_PlugIns, _R(IDS_SGMENU_PLUGINS));
03083 #endif
03084         ok = ok && InitMenuCommand((StringBase *) &SGCmd_SetBackground, _R(IDS_SGMENU_SETBACKGROUND));
03085 
03086         //  WEBSTER-ranbirr-22/11/96
03087         ok = ok && InitMenuCommand((StringBase *) &SGCmd_Props, _R(IDS_SGMENU_PROPS));
03088 
03089         // "Standard" commands for over-list menu
03090         ok = ok && InitMenuCommand((StringBase *) &SGCmd_FoldGroup, _R(IDS_SGMENU_FOLD));
03091         ok = ok && InitMenuCommand((StringBase *) &SGCmd_UnfoldGroup, _R(IDS_SGMENU_UNFOLD));
03092 
03093         ok = ok && InitMenuCommand((StringBase *) &SGCmd_NextGroup, _R(IDS_SGMENU_NEXTGROUP));
03094         ok = ok && InitMenuCommand((StringBase *) &SGCmd_PrevGroup, _R(IDS_SGMENU_PREVGROUP));
03095 
03096         MenusInitialised = TRUE;
03097     }
03098 
03099     return(ok);
03100 }

BOOL BitmapSGallery::IsJPEG KernelBitmap **  pList,
UINT32  ListSize,
BmpDlgParam Param,
INT32 *  pBytes
 

To determine whether an imported bitmap is a compressed JPEG.

Author:
Ranbir_Rana (Xara Group Ltd) <camelotdev@xara.com>
Date:
05/01/96
Parameters:
pList - A ptr to a Kernel bitmap. [INPUTS] ListSize - The number of bitmaps selected in the bitmap gallery. Param - Allows data to be passed to and from the bitmap properties dialog. pBytes - If it is a JPEG, the memory (bytes), is returned to the caller.
- [OUTPUTS]
Returns:
True if the selected bitmap is a compressed JPEG, false otherwise
See also:
-

Definition at line 3973 of file sgbitmap.cpp.

03974 {
03975     ERROR2IF(pList == NULL || Param == NULL || pBytes == NULL, FALSE, "NULL Parameters Passed");
03976 
03977     BitmapSource* pSource = NULL;
03978     BaseBitmapFilter* pDummyFilter;
03979 
03980     KernelBitmap* pKernelBitmap =  pList[ListSize];
03981 
03982     if (pKernelBitmap == NULL)
03983         return FALSE;
03984     
03985     BOOL OriginalSourcePresent = pKernelBitmap->GetOriginalSource(&pSource, &pDummyFilter);
03986     
03987     if(OriginalSourcePresent)
03988     {
03989         if (pSource != NULL)
03990         {
03991             if (pSource->IsJPEG())
03992             {
03993                 Param->SetIsJPEG(TRUE);
03994                 *pBytes += pSource->GetSize();
03995             }
03996         }
03997     }
03998     else
03999     {
04000         Param->SetIsJPEG(FALSE);
04001     }
04002     return Param->GetIsJPEG();
04003 }

MsgResult BitmapSGallery::Message Msg Message  )  [virtual]
 

A standard message handler, really.

Author:
Will_Cowling (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 SuperGallery.

Definition at line 2413 of file sgbitmap.cpp.

02414 {
02415     if (IS_OUR_DIALOG_MSG(Message))
02416     {
02417         DialogMsg* Msg = (DialogMsg*)Message;
02418         KernelBitmap* SelectedBitmap;
02419 
02420         switch (Msg->DlgMsg)
02421         {
02422             case DIM_CREATE:
02423                 SGInit::UpdateGalleryButton(_R(OPTOKEN_DISPLAYBITMAPGALLERY), TRUE);
02424                 SetSelectionFromDocument(TRUE);
02425                 break;
02426 
02427             case DIM_CANCEL:
02428                 SGInit::UpdateGalleryButton(_R(OPTOKEN_DISPLAYBITMAPGALLERY), FALSE);
02429                 break;
02430 
02431             case DIM_LFT_BN_CLICKED:
02432                 if (FALSE) {}
02433                 else if (Msg->GadgetID == _R(IDC_BMPGAL_CREATE))
02434                 {   
02435                     SelectedBitmap = GetSelectedBitmap();
02436 
02437                     if (SelectedBitmap != NULL)
02438                     {
02439                         PageDropInfo DropInfo;
02440                         DropInfo.pDocView   = DocView::GetSelected();
02441                         DropInfo.pDoc       = Document::GetSelected();
02442                         DropInfo.pSpread    = Document::GetSelectedSpread();
02443 
02444                         FindCentreInsertionPosition(&DropInfo.pSpread, &DropInfo.DropPos);
02445 
02446                         // Obtain a pointer to the op descriptor for the create operation 
02447                         OpDescriptor* OpDesc = OpDescriptor::FindOpDescriptor(CC_RUNTIME_CLASS(OpCreateNodeBitmap));
02448 
02449                         // Invoke the operation, passing DocView and Pos as parameters
02450                         OpParam param((void *)SelectedBitmap,(void *)&DropInfo);
02451                         OpDesc->Invoke(&param);      
02452                     }
02453                 }
02454                 else if (Msg->GadgetID == _R(IDC_BMPGAL_FILL))
02455                 {   
02456                     SelectedBitmap = GetSelectedBitmap();
02457 
02458                     if (SelectedBitmap != NULL)
02459                     {
02460                         // Fill colour selected so create a fill colour attribute
02461                         NodeAttribute *Attrib = new AttrBitmapColourFill;
02462                         if (Attrib == NULL)
02463                             return(SuperGallery::Message(Message));
02464 
02465                         ((AttrBitmapColourFill *)Attrib)->AttachBitmap(SelectedBitmap);
02466 
02467                         // AttributeSelected knows what to do with a selected attribute
02468                         AttributeManager::AttributeSelected(NULL, Attrib);
02469                     }
02470                 }
02471                 else if (Msg->GadgetID == _R(IDC_BMPGAL_TEXTURE))
02472                 {   
02473                     SelectedBitmap = GetSelectedBitmap();
02474 
02475                     if (SelectedBitmap != NULL)
02476                     {
02477                         SelectedBitmap = CheckTextureBitmap(SelectedBitmap);
02478 
02479                         AttributeManager::HaveAskedAboutContoneColours = FALSE;
02480                         AttributeManager::UserCancelledContoneColours = FALSE;
02481 
02482                         if (SelectedBitmap == NULL)
02483                             return(SuperGallery::Message(Message));
02484 
02485                         // Fill colour selected so create a fill colour attribute
02486                         NodeAttribute *Attrib = new AttrBitmapTranspFill;
02487                         if (Attrib == NULL)
02488                             return(SuperGallery::Message(Message));
02489 
02490                         ((AttrBitmapTranspFill *)Attrib)->AttachBitmap(SelectedBitmap);
02491 
02492                         // AttributeSelected knows what to do with a selected attribute
02493                         AttributeManager::AttributeSelected(NULL, Attrib);
02494                     }
02495                 }
02496 PORTNOTE("other", "Remove XPE hooks")
02497 #ifndef EXCLUDE_FROM_XARALX
02498                 else if (Msg->GadgetID == _R(IDC_BMPGAL_XPE_EDIT))
02499                 {   
02500                     SelectedBitmap = GetSelectedBitmap();
02501                     if (SelectedBitmap != NULL)
02502                     {
02503                         // Obtain a pointer to the op descriptor for the create operation 
02504                         OpDescriptor* OpDesc = OpDescriptor::FindOpDescriptor(CC_RUNTIME_CLASS(XPEEditItemOp));
02505 
02506                         // Invoke the operation, passing DocView and Pos as parameters
02507                         OpParam param((void *)SelectedBitmap, NULL);
02508                         OpDesc->Invoke(&param);
02509                     }
02510                 }
02511 #endif
02512                 else if (Msg->GadgetID == _R(IDC_BMPGAL_TRACE))
02513                 {   
02514                     SelectedBitmap = GetSelectedBitmap();
02515                 // WEBSTER-Martin-09/01/97 we don't trace stuff
02516                 #ifndef WEBSTER
02517                     if (SelectedBitmap != NULL)
02518                     {
02519                         TraceMsg::OpenOrUse(SelectedBitmap);
02520                     }
02521                 #endif //webster
02522                 }
02523                 /* else if (Msg->GadgetID == _R(IDC_BMPGAL_EFFECTS))
02524                 {   
02525                     SelectedBitmap = GetSelectedBitmap();
02526                 // WEBSTER-Martin-09/01/97
02527                 #ifndef WEBSTER
02528                     if (SelectedBitmap != NULL)
02529                     {
02530                         BfxMsg::OpenOrUse(SelectedBitmap);
02531                     }
02532                 #endif //webster
02533                     break;
02534                 } */
02535                 else if (Msg->GadgetID == _R(IDC_BMPGAL_SAVE))
02536                 {   
02537                     // Generate a list of the selected bitmaps
02538                     UINT32 ListSize = 0;
02539                     KernelBitmap** pList = NULL;
02540                     if (!GetSelectedBitmaps(&pList, &ListSize))
02541                         InformError();
02542                     else
02543                     {
02544                         if (ListSize != 0)
02545                         {
02546                             BmpDlgParam BmpDlgParam;
02547 
02548                             GetBmpInfo(&BmpDlgParam);
02549                             // Save the Bitmap deatils for use in the bitmap export code.#
02550                             BmpDlgParam.SetBitmapList(pList);
02551                             BmpDlgParam.SetListSize(ListSize);
02552                             
02553                             BitmapExportParam ExportList(ListSize, pList, &BmpDlgParam);
02554                             // Invoke the export operation
02555                             OpDescriptor* OpDesc = OpDescriptor::FindOpDescriptor(CC_RUNTIME_CLASS(OpMenuExport));
02556                             OpDesc->Invoke(&ExportList);         
02557                             SetBmpInfo(&BmpDlgParam);
02558                             ForceRedrawOfList();
02559                         }
02560                         else
02561                             ERROR3("No bitmaps were selected - how come the option wasn't greyed");
02562                     }
02563                     if (pList != NULL)
02564                         CCFree(pList);
02565                 }
02566                 else if (Msg->GadgetID == _R(IDC_BMPGAL_HELP))
02567                 {   
02568                     // HelpUserTopic(_R(IDH_Gallery_Bitmap));
02569                     HelpUserTopic(_R(IDS_HELPPATH_Gallery_Bitmap));
02570                     break;
02571                 }
02572                 else if (Msg->GadgetID == _R(IDC_BMPGAL_PREVIEW))
02573                 {
02574                     // Generate a list of the selected bitmaps
02575                     UINT32 ListSize = 0;
02576                     KernelBitmap** pList = NULL;
02577                     if (!GetSelectedBitmaps(&pList, &ListSize))
02578                         InformError();
02579                     else
02580                     {
02581                         if (ListSize != 0)
02582                         {
02583                             BmpDlgParam BmpDlgParam;
02584                             GetBmpInfo(&BmpDlgParam);
02585                             // Save the Bitmap deatils for use in the bitmap export code.#
02586                             BmpDlgParam.SetBitmapList(pList);
02587                             BmpDlgParam.SetListSize(ListSize);
02588                             BitmapExportParam ExportList(ListSize, pList, &BmpDlgParam);
02589 
02590                             // Invoke the preview operation
02591                                                             // Check if there is a Preview Dialog present.
02592                             PreviewDialog* pPreviewDialog = PreviewDialog::GetPreviewDialog();
02593                             if (!pPreviewDialog)
02594                             {
02595                                 OpDescriptor* OpDesc;
02596                                 //if (KeyPress::IsAdjustPressed())
02597                                 //  OpDesc = OpDescriptor::FindOpDescriptor(OPTOKEN_BITMAPPREVIEWDIALOG);
02598                                 //else
02599                                 OpDesc = OpDescriptor::FindOpDescriptor(OPTOKEN_PREVIEWDIALOG);
02600 
02601                                 if (OpDesc)
02602                                 {
02603                                     PreviewDialog::ToggleViaBitmapGallery (TRUE);
02604                                     OpDesc->Invoke(&ExportList);
02605                                     pPreviewDialog->SetDelay (100);
02606                                     pPreviewDialog = PreviewDialog::GetPreviewDialog();
02607                                 //  pPreviewDialog->ToggleViaBitmapGallery (TRUE);
02608                                 }
02609                             }
02610                             else
02611                             {
02612                                 // If the animation is playing, stop the animation before we pass
02613                                 // it our new list of bitmaps.
02614                                 if(pPreviewDialog->GetPlayAnimation())
02615                                     pPreviewDialog->SetPlayAnimation(FALSE);
02616 
02617                                 PreviewDialog::ToggleViaBitmapGallery (TRUE);
02618 
02619                                 pPreviewDialog->SetBitmapList(&ExportList);
02620                             //  pPreviewDialog->ToggleViaBitmapGallery (TRUE);
02621                                 pPreviewDialog->SetDelay (100);
02622 
02623                                 // Call the dialog box so that it sets up the necessary states
02624                                 pPreviewDialog->ReInitDialog();
02625                             }
02626 
02627                             SetBmpInfo(&BmpDlgParam);
02628                             ForceRedrawOfList();
02629                         }
02630                         else
02631                             ERROR3("No bitmaps were selected - how come the option wasn't greyed");
02632                     }
02633                     if (pList != NULL)
02634                         CCFree(pList);
02635                 }
02636 #ifdef PHOTOSHOPPLUGINS
02637 // Only add in if required - general plug-in removal at present
02638                 else if (Msg->GadgetID == _R(IDC_BMPGAL_PLUGINS))
02639                 {   
02640                     // Need to say which document and more importantly which bitmap we
02641                     // want the menu to apply to.
02642                     SelectedBitmap = GetSelectedBitmap();
02643                     // Now find out what the selected group is, which will be the document group
02644                     SGDisplayNode * FirstSelected = DisplayTree->FindNextSelectedItem(NULL);
02645                     Document *pDocument = NULL;
02646                     if (FirstSelected == NULL)
02647                         pDocument = Document::GetSelected();
02648                     else
02649                         pDocument = ((SGDisplayGroup *) FirstSelected->GetParent())->GetParentDocument();
02650                     ERROR3IF(pDocument == NULL, "No parent document?!");
02651                     if (SelectedBitmap != NULL && pDocument != NULL)
02652                     {
02653                         // replaced menu with direct invocation of Bfx:Special Effects operation since this was 
02654                         // the only option left on menu - all the other plug-in options have been superseded
02655                         // by the new Live Effects implementation. Fixes #11376.
02656 
02657                         OpDescriptor *pOpDesc = OpDescriptor::FindOpDescriptor(OPTOKEN_BFX_SPECIALEFFECTS);
02658                         if(pOpDesc)
02659                         {
02660                             // Inform the Bfx operation what bitmap and document it will be working on
02661                             BfxPlugInOp::SetBitmapAndDocument(SelectedBitmap, pDocument);
02662                             // and invoke it immediately
02663                             pOpDesc->Invoke();
02664                         }
02665                         else
02666                         {
02667                             ERROR2RAW("Unable to find BFX:Special Effects operation");
02668                         }
02669                     }
02670                 }
02671 #endif
02672                 else if (Msg->GadgetID == _R(IDC_BMPGAL_BACKGROUND))
02673                 {   
02674                     // Need to say which document and more importantly which bitmap we
02675                     // want the menu to apply to.
02676                     SelectedBitmap = GetSelectedBitmap();
02677                     // Now find out what the selected group is, which will be the document group
02678                     SGDisplayNode * FirstSelected = DisplayTree->FindNextSelectedItem(NULL);
02679                     Document *pDocument = NULL;
02680                     if (FirstSelected == NULL)
02681                         pDocument = Document::GetSelected();
02682                     else
02683                         pDocument = ((SGDisplayGroup *) FirstSelected->GetParent())->GetParentDocument();
02684                     ERROR3IF(pDocument == NULL, "No parent document?!");
02685                     if (SelectedBitmap != NULL && pDocument != NULL)
02686                     {
02687                         // Apply the bitmap as the new background
02688                         OpBackgroundParam Param;
02689                         Param.pBitmap = SelectedBitmap;
02690                         Param.pDoc = pDocument;         
02691                         
02692                         // Obtain a pointer to the op descriptor for the create operation 
02693                         OpDescriptor* pOpDesc = OpDescriptor::FindOpDescriptor(OPTOKEN_BACKGROUND);
02694 
02695                         // Invoke the operation, passing in our parameters
02696                         pOpDesc->Invoke(&Param);         
02697                     }
02698                 }
02699                 else if (Msg->GadgetID == _R(IDC_BMPGAL_PROPS))
02700                 {   
02701                     // Generate a list of the selected bitmaps
02702                     UINT32 ListSize = 0;
02703                     KernelBitmap** pList = NULL;
02704                     if (!GetSelectedBitmaps(&pList, &ListSize))
02705                         InformError();
02706                     else
02707                     {
02708                         if (ListSize != 0)
02709                         {
02710                             //  Opens the Bitmap Properties Dialog, from the Bitmap Gallery.
02711                             BmpDlgParam BmpDlgParam;
02712                             GetBmpInfo(&BmpDlgParam);
02713                             BmpDlg::InvokeBmpDlg(&BmpDlgParam);
02714                             SetBmpInfo(&BmpDlgParam);
02715                             ForceRedrawOfList();
02716                         }
02717                         else
02718                             ERROR3("No bitmaps were selected - how come the option wasn't greyed");
02719                     }
02720                     if (pList != NULL)
02721                         CCFree(pList);
02722                 }
02723                 break;
02724             default:
02725                 break;
02726         }
02727 
02728         return(SuperGallery::Message(Message));
02729     }
02730 
02731     // If we have no displaytree, then we have not been shown, or something terrible has
02732     // happened, so we don't bother handling any of these messages.
02733     if (DisplayTree == NULL || !IsVisible())
02734         return(SuperGallery::Message(Message));
02735 
02736     if (IsVisible() && MESSAGE_IS_A(Message, DocChangingMsg))
02737     {
02738         DocChangingMsg *TheMsg = (DocChangingMsg *) Message;
02739 
02740         switch ( TheMsg->State )
02741         {
02742             case DocChangingMsg::BORN:                      // New document - add to display tree
02743                 {
02744                     INT32 Extent = GetDisplayExtent();      // Remember previous list extent
02745 
02746                     CreateNewSubtree(TheMsg->pChangingDoc); // Add a subtree for this doc
02747                     ShadeGallery(FALSE);                    // Unshade the gallery
02748 
02749                     InvalidateCachedFormat();               // And redraw what is necessary
02750                     RedrawEverythingBelow(-Extent);
02751                 }
02752                 break;      // Pass this message on to the base class as well
02753             default:
02754                 break;
02755         }
02756     }
02757 
02758     if (MESSAGE_IS_A(Message, BitmapListChangedMsg) && !IgnoreBmpListChange)
02759     {
02760         BitmapListChangedMsg *TheMsg = (BitmapListChangedMsg *) Message;
02761 
02762         // First, try to find the document which owns the changed list
02763         Document *ScopeDoc = (Document *)TheMsg->pChangedBmpList->GetParentDocument();
02764 
02765         // Just check that the bi-directional link is sane!
02766         ERROR3IF(ScopeDoc == NULL, "A Document bitmap list is invalid");
02767 
02768         // If we found it, recreate the display subtree for it
02769         if (ScopeDoc != NULL)
02770         {
02771             SGDisplayNode *Ptr = DisplayTree->FindSubtree(this, ScopeDoc, NULL);
02772 
02773             if (Ptr != NULL)
02774             {
02775                 CreateNewSubtree(ScopeDoc, (SGDisplayGroup *) Ptr);
02776 
02777                 // And force a redraw of the entire list
02778                 ForceRedrawOfList();
02779                 
02780                 // The above will loose the selection, so we can listen out for the special
02781                 // form of the message which says which bitmap to reselect.
02782                 if ((TheMsg->State == BitmapListChangedMsg::SELECTNEWBITMAP) &&
02783                     (TheMsg->pNewBitmap != NULL))
02784                 {
02785                     // We have been sent a message that a new bitmap has been added and
02786                     // this is the one we should go and select.
02787                     SelectItems(FALSE);                 // Clear the current selection
02788 
02789                     SGDisplayGroup *DocGroup = DisplayTree->FindSubtree(this, ScopeDoc, NULL);
02790                     SGDisplayKernelBitmap* pCurrentItem = NULL;
02791                     if (DocGroup != NULL)
02792                         pCurrentItem = (SGDisplayKernelBitmap *) DocGroup->GetChild();
02793                         //Selected = (SGDisplayKernelBitmap *) DocGroup->FindNextSelectedItem(NULL);
02794 
02795                     // Ensure the tree format information is up to date, ready for when we sample it
02796                     ReformatNow(TRUE);
02797                     BOOL HaveSelected = FALSE;
02798                     DocRect ScrollToRect;
02799 
02800                     while (pCurrentItem != NULL)
02801                     {
02802                         KernelBitmap* CurrentBitmap = pCurrentItem->GetDisplayedKernelBitmap();
02803                         if (CurrentBitmap == TheMsg->pNewBitmap)
02804                         {
02805                             pCurrentItem->SetSelected(TRUE);
02806                             HaveSelected = TRUE;
02807                             pCurrentItem->GetFormatRect(&ScrollToRect);
02808                             break;
02809                         }
02810 
02811                         // Get the next one in the list
02812                         pCurrentItem = (SGDisplayKernelBitmap *) pCurrentItem->GetNext();
02813                     }
02814 
02815                         
02816                     // Try and scroll to the selected item, if we have one
02817                     if (HaveSelected)
02818                     {
02819                         BOOL ScrollToBottom = TRUE;
02820                         ScrollToShow(&ScrollToRect, ScrollToBottom);
02821                     }
02822                 }
02823             
02824                 // Was not present before 20/12/96, safest to have it present as this action
02825                 // will lose the selection.
02826                 SelectionHasChanged();
02827             }
02828         }
02829     }
02830 
02831     if (MESSAGE_IS_A(Message, CommonAttrsChangedMsg))
02832     {
02833         if (!AmShaded)          // If we're open & active, set listbox selection
02834             SetSelectionFromDocument();
02835     }
02836 
02837     return(SuperGallery::Message(Message));
02838 }    

BOOL BitmapSGallery::PreContextMenu void   )  [virtual]
 

Give the gallery a chance to do something before popping up the context menu. Called before the context menu is popped up on a right click. At present, used by the bitmap gallery to ensure that the plug-ins have all been parsed.

Author:
Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
Date:
28/10/97
Returns:
TRUE for success

Reimplemented from SuperGallery.

Definition at line 3017 of file sgbitmap.cpp.

03018 {
03019 #ifdef PHOTOSHOPPLUGINS
03020 // Only add in if required - general plug-in removal at present
03021     // As we are just about to invoke UI, check that the plug-in manager has its list
03022     // of available plug-ins otherwise, go and get it now as we are just about to need it.
03023     // Must do it now before even the hint of a context menu is started as the context
03024     // menus stack the automatic menu id and then restore it after they are destroyed.
03025     // This is bad if our main menu ids are in this range!
03026     PlugInManager* pManager = GetApplication()->GetPlugInManager();
03027     if (pManager)
03028         pManager->CheckHaveDetailsOnPlugIns();
03029 #endif // PHOTOSHOPPLUGINS
03030 
03031     return(TRUE);
03032 }

BOOL BitmapSGallery::PreCreate void   )  [protected, virtual]
 

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

Author:
Will_Cowling (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

Reimplemented from SuperGallery.

Definition at line 1756 of file sgbitmap.cpp.

01757 {
01758     // If there isn't already one, create a DisplayTree
01759     if (DisplayTree == NULL)
01760     {
01761         DisplayTree = new SGDisplayRootScroll(this);    // New root node, with a scrollbar
01762         if (DisplayTree == NULL)
01763             return(FALSE);
01764     }
01765 
01766     // Next, call CreateNewSubtree to scan all the available documents and build a
01767     // display list for each of them.
01768     Document *ParentDoc = (Document *) GetApplication()->Documents.GetTail();
01769     while (ParentDoc != NULL)
01770     {
01771         SGDisplayNode *Ptr = DisplayTree->FindSubtree(this, ParentDoc, NULL);
01772         CreateNewSubtree(ParentDoc, (SGDisplayGroup *) Ptr);
01773         ParentDoc = (Document *) GetApplication()->Documents.GetPrev(ParentDoc);
01774     }
01775 
01776     // We're opening the window, so we fold all groups except that for the Selected document
01777     SGDisplayGroup *Group = (SGDisplayGroup *) DisplayTree->GetChild();
01778     while (Group != NULL)
01779     {
01780         // Set the group's folded state, but don't bother trying to redraw, because we know
01781         // that the window is not currently visible, and that we are doing this to multiple groups.
01782         Group->SetFoldedState((Group->GetParentDocument() != Document::GetSelected()), FALSE);      
01783         Group = (SGDisplayGroup *) Group->GetNext();
01784     }
01785 
01786     return(TRUE);
01787 }

void BitmapSGallery::SelectionHasChanged void   )  [virtual]
 

To inform the gallery that the selection has changed in some way. The base gallery class will do the following things:.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
27/1/95
MonoOn
  • If the selection is not exactly one item, the following standard buttons are shaded: Apply, Redefine, Edit

  • If the selection is greater than 1 item, the New button will shade

  • If the selection is zero items, then the Delete button will shade MonoOff

Notes: If this default action is unsuitable, derived galleries may override it. If they add their own special buttons, they may need to override this method to ensure that their buttons also behave correctly on sel change.

This method is called after creation of the window (immediately after the PostCreate upcall) to ensure the window state is correct

Reimplemented from SuperGallery.

Definition at line 2299 of file sgbitmap.cpp.

02300 {
02301     if (DisplayTree == NULL || AmShaded || !IsVisible())
02302         return;
02303 
02304     INT32 Count = DisplayTree->GetSelectedItemCount();
02305 
02306     EnableGadget(_R(IDC_BMPGAL_CREATE),     (Count == 1));
02307 
02308     EnableGadget(_R(IDC_BMPGAL_FILL),       (Count == 1));
02309 
02310     EnableGadget(_R(IDC_BMPGAL_TEXTURE),    (Count == 1));
02311 
02312     EnableGadget(_R(IDC_BMPGAL_XPE_EDIT),   (Count == 1));
02313     EnableGadget(_R(IDC_BMPGAL_TRACE),      (Count == 1));
02314 //  EnableGadget(_R(IDC_BMPGAL_EFFECTS),    (Count == 1));
02315 
02316 #ifdef PHOTOSHOPPLUGINS
02317 // Only add in if required - general plug-in removal at present
02318     EnableGadget(_R(IDC_BMPGAL_PLUGINS),    (Count == 1));
02319 #endif
02320 
02321     EnableGadget(_R(IDC_BMPGAL_BACKGROUND), (Count == 1));
02322 
02323     // Now that we handle multiple images we enable as long as there is a selection
02324     EnableGadget(_R(IDC_BMPGAL_SAVE), (Count > 0));
02325 
02326     EnableGadget(_R(IDC_BMPGAL_PROPS),(Count > 0));
02327 
02328 //#if _DEBUG
02329     // Now that we handle multiple images we enable as long as there is a selection
02330     EnableGadget(_R(IDC_BMPGAL_PREVIEW), (Count > 0));
02331 //#endif
02332 
02333     if (Count == 1 && GetSelectedBitmap()->ActualBitmap == OILBitmap::Default)
02334     {
02335         EnableGadget(_R(IDC_GALLERY_DELETE),    FALSE);
02336     }
02337     else
02338     {
02339         EnableGadget(_R(IDC_GALLERY_DELETE),    (Count > 0));
02340     }
02341 
02342     EnableGadget(_R(IDC_GALLERY_MENU),      TRUE);
02343 }

BOOL BitmapSGallery::SetBmpInfo BmpDlgParam Param  )  [protected]
 

Stores info, retrieved from the Bitmap Properties Dialog, in an OILBitmap.

Author:
Ranbir_Rana (Xara Group Ltd) <camelotdev@xara.com>
Date:
05/01/96
Parameters:
Param - Allows the transfer of data to and from the bitmap poperties dialog. [INPUTS]
- [OUTPUTS]
Returns:
TRUE if Successful, FALSE otherwise.
See also:
-

Definition at line 3880 of file sgbitmap.cpp.

03881 {
03882         ERROR2IF(Param == NULL,FALSE,"Param is NULL");
03883 
03884         // The user has entrered OK, so go through the list of selected bitmaps and set their Delay\Restore fields.
03885         UINT32 ListSize = 0;
03886         KernelBitmap** pList = NULL;
03887         Document* WorkDoc = Document::GetSelected();
03888 
03889 
03890         if (!GetSelectedBitmaps(&pList, &ListSize))
03891         return FALSE;
03892 
03893         if(Param->GetAreDelayValuesSame())
03894         {
03895             UINT32 ListCounter = ListSize;
03896 
03897             while (ListCounter>0)
03898             {
03899                 KernelBitmap* pKernelBitmap = pList[--ListCounter];
03900                 if (pKernelBitmap != NULL)
03901                 {
03902                     pKernelBitmap->SetDelay(Param->GetAnimDelay());
03903                 }
03904             }
03905         }
03906         if (Param->GetSameRestoreType())
03907         {
03908             UINT32 ListCounter = ListSize;
03909 
03910             while (ListCounter>0)
03911             {
03912                 KernelBitmap* pKernelBitmap = pList[--ListCounter];
03913                 if(pKernelBitmap != NULL)
03914                 {
03915                     OILBitmap* pOILBitmap = pKernelBitmap->GetActualBitmap();
03916                     if (pOILBitmap != NULL)
03917                     {
03918                         pOILBitmap->SetAnimationRestoreType(Param->GetRestoreType());
03919                     }
03920                 }
03921             }
03922         }
03923         // Andy Hills, 09-10-00
03924         // Record changes to the 'smooth when scaled up' tickbox
03925         if (Param->GetAreInterpolationValuesSame())
03926         {
03927             UINT32 ListCounter = ListSize;
03928 
03929             while (ListCounter>0)
03930             {
03931                 KernelBitmap* pKernelBitmap = pList[--ListCounter];
03932                 if(pKernelBitmap != NULL)
03933                 {
03934                     OILBitmap* pOILBitmap = pKernelBitmap->GetActualBitmap();
03935                     if (pOILBitmap != NULL)
03936                     {
03937                         // change the interpolation setting of each selected bitmap
03938                         pOILBitmap->SetInterpolation(Param->GetInterpolation());
03939 
03940                         // invalidate all uses of this bitmap, so that the screen is updated correctly
03941                         if (WorkDoc != NULL)
03942                         {
03943                             pOILBitmap->InvalidateAllReferences(WorkDoc);
03944                         }
03945                     }
03946                 }
03947             }
03948         }
03949         if (pList != NULL)
03950             CCFree(pList);
03951         
03952     return TRUE;
03953 }

void BitmapSGallery::SetSelectionFromDocument BOOL  AlwaysScroll = FALSE  )  [protected]
 

Sets the bitmap gallery listbox selection state based upon the currently selected object(s) in the document.

Author:
Will_Cowling (Xara Group Ltd) <camelotdev@xara.com>
Date:
30/8/96 (copied from ColourGallery)
Parameters:
AlwaysScroll - TRUE if you always want to autoscroll, regardless of the [INPUTS] preference setting. (This is used when opening the gallery, as there is no point in not auto-scrolling somewhere useful)
Scope: private

Definition at line 1807 of file sgbitmap.cpp.

01808 {
01809     if (DisplayTree == NULL || !IsVisible())
01810         return;
01811     
01812     SGDisplayGroup *DocGroup = DisplayTree->FindSubtree(this, Document::GetSelected(), NULL);
01813     SelectItems(FALSE);                 // Clear the current selection
01814 
01815     // This needs to be a preference if we ever make this gallery show the
01816     // currently selected bitmaps.
01817     BOOL AutoScrollSelection = FALSE;
01818 
01819     DocRect ScrollToRect;
01820     BOOL HaveSelected = FALSE;
01821     BOOL ScrollToBottom = FALSE;    // TRUE if it is more important that the bottom of
01822                                     // ScrollToRect, rather than the top, is visible
01823     if (DocGroup != NULL)
01824         ForceGroupFolded(DocGroup, FALSE);  // Ensure group is unfolded
01825 
01826     ReformatNow(TRUE);              // Ensure the tree format information is up to date
01827 
01828     if (AutoScrollSelection || AlwaysScroll)
01829     {
01830         if (AlwaysScroll && !HaveSelected && DocGroup != NULL)
01831         {
01832             // We didn't select anything in the gallery. In that case, scroll to the top
01833             // of the document display
01834             DocRect TempRect;
01835             //DocGroup->GetFormatRect(&TempRect);
01836             DocGroup->GetChildArea(&ScrollToRect);
01837             //ScrollToRect = ScrollToRect.Union(TempRect);
01838             HaveSelected = TRUE;
01839             ScrollToBottom = FALSE;
01840         }
01841 
01842         if (HaveSelected)
01843             ScrollToShow(&ScrollToRect, ScrollToBottom);
01844     }
01845                                                 // scroll to make seln visible on screen
01846 
01847     SelectionHasChanged();                      // Update for the new selection
01848 }


Member Data Documentation

BOOL BitmapSGallery::IgnoreBmpListChange = FALSE [static]
 

Definition at line 377 of file sgbitmap.h.


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