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(