sgbitmap.cpp

Go to the documentation of this file.
00001 // $Id: sgbitmap.cpp 1664 2006-08-04 10:06:16Z gerry $
00002 /* @@tag:xara-cn@@ DO NOT MODIFY THIS LINE
00003 ================================XARAHEADERSTART===========================
00004  
00005                Xara LX, a vector drawing and manipulation program.
00006                     Copyright (C) 1993-2006 Xara Group Ltd.
00007        Copyright on certain contributions may be held in joint with their
00008               respective authors. See AUTHORS file for details.
00009 
00010 LICENSE TO USE AND MODIFY SOFTWARE
00011 ----------------------------------
00012 
00013 This file is part of Xara LX.
00014 
00015 Xara LX is free software; you can redistribute it and/or modify it
00016 under the terms of the GNU General Public License version 2 as published
00017 by the Free Software Foundation.
00018 
00019 Xara LX and its component source files are distributed in the hope
00020 that it will be useful, but WITHOUT ANY WARRANTY; without even the
00021 implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
00022 See the GNU General Public License for more details.
00023 
00024 You should have received a copy of the GNU General Public License along
00025 with Xara LX (see the file GPL in the root directory of the
00026 distribution); if not, write to the Free Software Foundation, Inc., 51
00027 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
00028 
00029 
00030 ADDITIONAL RIGHTS
00031 -----------------
00032 
00033 Conditional upon your continuing compliance with the GNU General Public
00034 License described above, Xara Group Ltd grants to you certain additional
00035 rights. 
00036 
00037 The additional rights are to use, modify, and distribute the software
00038 together with the wxWidgets library, the wxXtra library, and the "CDraw"
00039 library and any other such library that any version of Xara LX relased
00040 by Xara Group Ltd requires in order to compile and execute, including
00041 the static linking of that library to XaraLX. In the case of the
00042 "CDraw" library, you may satisfy obligation under the GNU General Public
00043 License to provide source code by providing a binary copy of the library
00044 concerned and a copy of the license accompanying it.
00045 
00046 Nothing in this section restricts any of the rights you have under
00047 the GNU General Public License.
00048 
00049 
00050 SCOPE OF LICENSE
00051 ----------------
00052 
00053 This license applies to this program (XaraLX) and its constituent source
00054 files only, and does not necessarily apply to other Xara products which may
00055 in part share the same code base, and are subject to their own licensing
00056 terms.
00057 
00058 This license does not apply to files in the wxXtra directory, which
00059 are built into a separate library, and are subject to the wxWindows
00060 license contained within that directory in the file "WXXTRA-LICENSE".
00061 
00062 This license does not apply to the binary libraries (if any) within
00063 the "libs" directory, which are subject to a separate license contained
00064 within that directory in the file "LIBS-LICENSE".
00065 
00066 
00067 ARRANGEMENTS FOR CONTRIBUTION OF MODIFICATIONS
00068 ----------------------------------------------
00069 
00070 Subject to the terms of the GNU Public License (see above), you are
00071 free to do whatever you like with your modifications. However, you may
00072 (at your option) wish contribute them to Xara's source tree. You can
00073 find details of how to do this at:
00074   http://www.xaraxtreme.org/developers/
00075 
00076 Prior to contributing your modifications, you will need to complete our
00077 contributor agreement. This can be found at:
00078   http://www.xaraxtreme.org/developers/contribute/
00079 
00080 Please note that Xara will not accept modifications which modify any of
00081 the text between the start and end of this header (marked
00082 XARAHEADERSTART and XARAHEADEREND).
00083 
00084 
00085 MARKS
00086 -----
00087 
00088 Xara, Xara LX, Xara X, Xara X/Xtreme, Xara Xtreme, the Xtreme and Xara
00089 designs are registered or unregistered trademarks, design-marks, and/or
00090 service marks of Xara Group Ltd. All rights in these marks are reserved.
00091 
00092 
00093       Xara Group Ltd, Gaddesden Place, Hemel Hempstead, HP2 6EX, UK.
00094                         http://www.xara.com/
00095 
00096 =================================XARAHEADEREND============================
00097  */
00098 // SGBitmap.cpp - Bitmap SuperGallery classes - BitmapSGallery and SGDisplayBitmap
00099 
00100 #include "camtypes.h"
00101 
00102 //#include "app.h"      // For GetApplication() - in camtypes.h [AUTOMATICALLY REMOVED]
00103 //nclude "gallery.h"    // For _R(IDC_GALLERY_LISTBOX)
00104 //#include "galstr.h"
00105 //#include "galres.h"
00106 #include "sgbitmap.h"   
00107 #include "sginit.h" 
00108 #include "sgmenu.h"
00109 
00110 //nclude "ccdc.h"       // For render-into-dialogue support
00111 //nclude "fillval.h"
00112 //nclude "grnddib.h"
00113 //#include "will.h"     // For OpShowBitmapGallery ID's
00114 //nclude "bitmap.h" 
00115 #include "bitmpinf.h"   
00116 //#include "fillattr.h"  - in camtypes.h [AUTOMATICALLY REMOVED]
00117 //nclude "attrmgr.h"    
00118 #include "nodebmp.h"    
00119 //nclude "convert.h"    
00120 //#include "resource.h" // For _R(IDS_CANCEL)
00121 
00122 #include "dragmgr.h"
00123 #include "dragbmp.h"
00124 //nclude "viewrc.h"     // FOR _R(IDC_CANDROPONPAGE)
00125 
00126 //#include "docview.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00127 //#include "spread.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00128 #include "tracedlg.h"
00129 #include "bfxdlg.h"
00130 //nclude "bfxalu.h"
00131 //nclude "bitmapfx.h"
00132 #include "impexpop.h"   // Import/Export ops
00133 //#include "scrcamvw.h"
00134 //#include "fixmem.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00135 
00136 //nclude "sglib.h"
00137 
00138 //#include "richard2.h" // extra resource strings
00139 #include "bmpcomp.h"    
00140 //#include "will3.h"    
00141 //#include "phil.h"
00142 
00143 #include "comattrmsg.h"
00144 #include "bmpsdlg.h"
00145 //#include "bmpdlgr.h"
00146 //#include "bmpsdlgr.h"
00147 #include "giffiltr.h"
00148 #include "bmpsrc.h"
00149 
00150 #include "plugop.h"     // PlugInsContextMenu
00151 #include "backgrnd.h"   // OpBackground
00152 #include "keypress.h"   // KeyPress
00153 #include "impexpop.h"   // BitmapExportParam
00154 #include "prevwdlg.h"   // PreviewDialog::Init()
00155 #include "bmpexprw.h"   // BitmapExportPreviewDialog::Init()
00156 
00157 #include "helpuser.h"       //For the help button
00158 //#include "xshelpid.h"     //For the help button
00159 //#include "helppath.h"
00160 //#include "xpehost.h"      // For OPTOKEN_XPE_EDIT
00161 #include "qualattr.h"
00162 #include "bfxop.h"          // useful BFX plug-in related operations
00163 #include "fillattr2.h"
00164 
00165 #ifdef PHOTOSHOPPLUGINS
00166 #include "plugmngr.h"   // CheckHaveDetailsOnPlugIns
00167 #endif //PHOTOSHOPPLUGINS
00168 
00169 #include "camview.h"
00170 
00171 // Implement the dynamic class bits...
00172 CC_IMPLEMENT_DYNCREATE(BitmapSGallery, SuperGallery)
00173 CC_IMPLEMENT_DYNAMIC(SGDisplayKernelBitmap, SGDisplayItem)
00174 CC_IMPLEMENT_DYNCREATE(OpDisplayBitmapGallery,Operation);
00175 CC_IMPLEMENT_DYNAMIC(SGBitmapDragTarget, SGListDragTarget);
00176 
00177 CC_IMPLEMENT_DYNCREATE(GalleryBitmapDragInfo, BitmapDragInformation)
00178 
00179 // Enable Background redraw in the bitmap gallery...
00180 //#define SGBITMAP_BACKGROUND_REDRAW
00181 
00182 // This line mustn't go before any CC_IMPLEMENT_... macros
00183 #define new CAM_DEBUG_NEW
00184 
00185 
00186 BOOL BitmapSGallery::IgnoreBmpListChange = FALSE;
00187 
00188 
00189 /********************************************************************************************
00190 
00191 >   SGBitmapDragTarget::SGBitmapDragTarget(DialogOp *TheDialog, CGadgetID TheGadget = NULL)
00192      
00193     Author:     Will_Cowling (Xara Group Ltd) <camelotdev@xara.com>
00194     Created:    25/3/95
00195     Inputs:     TheDialog - The kernel dialog in which the target exists
00196                 TheGadget - The gadget within that dialogue which is the target
00197 
00198     Purpose:    Constructor
00199 
00200 ********************************************************************************************/
00201 
00202 SGBitmapDragTarget::SGBitmapDragTarget(DialogOp *TheDialog, CGadgetID TheGadget)
00203                     : SGListDragTarget(TheDialog, TheGadget)
00204 {
00205     ERROR3IF(!TheDialog->IsKindOf(CC_RUNTIME_CLASS(BitmapSGallery)),
00206             "You can only use SGBitmapDragTargets with BitmapSGallery dialogues!");
00207 }
00208 
00209 
00210 
00211 /********************************************************************************************
00212 
00213     BOOL SGBitmapDragTarget::ProcessEvent(DragEventType Event, DragInformation *pDragInfo,
00214                                             OilCoord *pMousePos, KeyPress* pKeyPress)
00215 
00216     Author:     Will_Cowling (Xara Group Ltd) <camelotdev@xara.com>
00217     Created:    25/3/95
00218     Inputs:     Event - Indicates what has happened
00219                 pDragInfo - points to drag information describing this drag. This
00220                 should be a BitmapDragInformation or derivation thereof
00221                 pMousePos - points to information on the current mouse position, in OIL coords
00222                 pKeyPress - NULL, or if for a keypress event, keypress information
00223 
00224     Returns:    TRUE to claim the event, FALSE to let it through to other targets
00225 
00226     Purpose:    Event Handler for SuperGallery listitem drag events. Overrides the
00227                 base class handler to enable it to sort out the node being dragged
00228                 for Bitmap drags.
00229 
00230 ********************************************************************************************/
00231 
00232 BOOL SGBitmapDragTarget::ProcessEvent(DragEventType Event, DragInformation *pDragInfo,
00233                                         OilCoord *pMousePos, KeyPress* pKeyPress)
00234 {
00235     if (!pDragInfo->IsKindOf(CC_RUNTIME_CLASS(BitmapDragInformation)))
00236         return(FALSE);
00237 
00238     SGDisplayNode *DraggedNode = NULL;
00239     BOOL IsSimpleBitmapDrag = TRUE;         // Only one bitmap is being dragged
00240 
00241     if (IS_A(pDragInfo, GalleryBitmapDragInfo))
00242     {
00243         DraggedNode = ((GalleryBitmapDragInfo *)pDragInfo)->GetDraggedBitmap();
00244 
00245         IsSimpleBitmapDrag = FALSE;         // We started the drag, so we will accept multiple
00246                                             // bitmaps being dragged in a single operation
00247     }
00248 
00249     if (DraggedNode != NULL)
00250     {
00251         switch(Event)
00252         {
00253             case DRAGEVENT_COMPLETED:
00254                 HandleDragCompleted((SuperGallery *) TargetDialog,
00255                                     DraggedNode, pMousePos, IsSimpleBitmapDrag);
00256                 return(TRUE);
00257 
00258 
00259             case DRAGEVENT_MOUSESTOPPED:
00260             case DRAGEVENT_MOUSEMOVED:
00261             case DRAGEVENT_MOUSEIDLE:
00262                 // Call a subroutine to work out and set our current cursor shape
00263                 return(DetermineCursorShape((SuperGallery *) TargetDialog,
00264                                             DraggedNode, pMousePos));
00265             default:
00266                 break;
00267         }
00268     }
00269     // Otherwise, we aren't interested in the event, so we don't claim it
00270     return(FALSE);
00271 }
00272 
00273 /********************************************************************************************
00274 
00275 >   void GalleryBitmapDragInfo::GalleryBitmapDragInfo() 
00276      
00277     Author:     Will_Cowling (Xara Group Ltd) <camelotdev@xara.com>
00278     Created:    19/3/95       
00279 
00280     Purpose:    Default constructor - do not call this constructor
00281 
00282 ********************************************************************************************/
00283 
00284 GalleryBitmapDragInfo::GalleryBitmapDragInfo()
00285 {
00286     ERROR3("Default GalleryBitmapDragInfo constructor called"); 
00287 }
00288 
00289 
00290 
00291 /********************************************************************************************
00292 
00293 >   GalleryBitmapDragInfo::GalleryBitmapDragInfo(SGDisplayKernelBitmap *pSourceItem,
00294                                             SGMouseInfo *pMouseInfo, SGMiscInfo *pMiscInfo,
00295                                             BOOL IsAdjust = FALSE)
00296      
00297     Author:     Will_Cowling (Xara Group Ltd) <camelotdev@xara.com>
00298     Created:    19/3/95       
00299 
00300     Inputs:     pSourceItem - The gallery item from which the drag originated
00301                 pMouseInfo  - The mouse info which made the item start the drag
00302                 pMiscInfo   - The MiscInfo which accompanied the mouse event
00303                 IsAdjust    - TRUE if this is an adjust (line-Bitmap) drag
00304 
00305     Purpose:    Constructor
00306 
00307 ********************************************************************************************/
00308 
00309 GalleryBitmapDragInfo::GalleryBitmapDragInfo(SGDisplayKernelBitmap *pSourceItem,
00310                                             SGMouseInfo *pMouseInfo, SGMiscInfo *pMiscInfo,
00311                                             BOOL IsAdjust)
00312                     : BitmapDragInformation(pSourceItem->GetDisplayedKernelBitmap(),
00313                                             120, 0, 0, 0, IsAdjust)
00314 {
00315     SourceItem  = pSourceItem;  // Copy the source item pointer
00316 
00317     MouseInfo   = *pMouseInfo;  // Duplicate the structures (they may cease to exist
00318     MiscInfo    = *pMiscInfo;   // soon after the drag is started)
00319 }
00320 
00321 /********************************************************************************************
00322 
00323 >   GalleryBitmapDragInfo::~GalleryBitmapDragInfo()
00324  
00325     Author:     Will_Cowling (Xara Group Ltd) <camelotdev@xara.com>
00326     Created:    19/3/95       
00327 
00328     Purpose:    Destructor
00329 
00330 ********************************************************************************************/
00331 
00332 GalleryBitmapDragInfo::~GalleryBitmapDragInfo()
00333 {
00334 }
00335 
00336 
00337 /********************************************************************************************
00338 
00339 >   void GalleryBitmapDragInfo::OnClick(INT32 Flags,POINT Point) 
00340      
00341     Author:     Will_Cowling (Xara Group Ltd) <camelotdev@xara.com>
00342     Created:    19/3/95       
00343     Inputs:     -
00344     Outputs:    -
00345     Returns:    -
00346     Purpose:    This is called if a drag was attempted but never started because it was a 
00347                 click all along. It calls back the SourceItem SGDisplayBitmap, to get it
00348                 to handle the click.
00349     Errors:     -
00350     SeeAlso:    -
00351 
00352 ********************************************************************************************/
00353 
00354 void GalleryBitmapDragInfo::OnClick(INT32 Flags ,POINT Point)
00355 {
00356     if (SourceItem != NULL)
00357         SourceItem->DragWasReallyAClick(&MouseInfo, &MiscInfo);
00358 }
00359 
00360 /********************************************************************************************
00361 
00362 >   void GalleryBitmapDragInfo::GetCursorID(DragTarget* pDragTarget)
00363 
00364     Author:     Will_Cowling (Xara Group Ltd) <camelotdev@xara.com>
00365     Created:    25/3/95
00366     Purpose:    Set cursor over this target
00367 
00368 
00369 ********************************************************************************************/
00370 
00371 UINT32 GalleryBitmapDragInfo::GetCursorID(DragTarget* pDragTarget)
00372 {
00373     if (pDragTarget && pDragTarget->IS_KIND_OF(ViewDragTarget))
00374     {
00375         PageDropInfo PageDropInfo;
00376         ((ViewDragTarget*)pDragTarget)->GetDropInfo(&PageDropInfo);
00377 
00378         NodeRenderableInk* pObjectHit   = PageDropInfo.pObjectHit;
00379         ObjectDragTarget TargetHit      = PageDropInfo.TargetHit;
00380 
00381         if (pObjectHit && pObjectHit->IS_KIND_OF(NodeBitmap))
00382             TargetHit = NO_TARGET;              // Ignore NodeBitmap objects
00383 
00384         ClickModifiers ClickMods = ClickModifiers::GetClickModifiers();
00385         BOOL IsInside = ClickMods.Constrain;
00386 
00387         if (!IsInside && pObjectHit && pObjectHit->IsCompound())
00388         {
00389             TargetHit = MANY_TARGET;
00390         }
00391 
00392         UINT32 CanFill = IsInside ? _R(IDC_DROPINSIDEONFILL) : _R(IDC_CANDROPONFILL);
00393 
00394         switch (TargetHit)
00395         {
00396             case FILL_TARGET:
00397             case LINE_TARGET:
00398             case STARTCOL_TARGET:
00399             case ENDCOL_TARGET:
00400             case ENDCOL2_TARGET:
00401             case ENDCOL3_TARGET:
00402             case MANY_TARGET:
00403                 return CanFill;
00404 
00405             case NO_TARGET:
00406                 // bitmap gallery - drop = add bitmap, CTRL + drop = page fill
00407                 return IsInside ? _R(IDC_CANFILLPAGE) : _R(IDC_CANDROPONPAGE);
00408                 //return _R(IDC_CANDROPONPAGE);
00409         };
00410 
00411         return _R(IDC_CANDROPONPAGE);
00412     }
00413 
00414     return _R(IDC_CANTDROP);
00415 }
00416 
00417 /********************************************************************************************
00418 
00419 >   virtual BOOL GalleryBitmapDragInfo::GetStatusLineText(String_256 * TheText, DragTarget* pDragTarget)
00420 
00421     Author:     Will_Cowling (Xara Group Ltd) <camelotdev@xara.com>
00422     Created:    25/3/95
00423     Returns:    Whether String is valid
00424     Purpose:    provide status line text for this target
00425    
00426 ********************************************************************************************/
00427 
00428 BOOL GalleryBitmapDragInfo::GetStatusLineText(String_256 * TheText, DragTarget* pDragTarget)
00429 {
00430     ERROR2IF(TheText==NULL,FALSE,"NULL string in GetStatusLineText()");
00431 
00432     if (TheBitmap == NULL || TheBitmap->ActualBitmap == NULL)
00433         return FALSE;
00434 
00435     String_256 DragString;
00436     String_256 BmpName(TheBitmap->ActualBitmap->GetName());
00437     DragString.MakeMsg(_R(IDS_SGBITMAP_DRAGGING_BITMAP), (TCHAR *)BmpName); // "Dragging Bitmap 'Bitmap' : ");
00438 
00439     if (pDragTarget && pDragTarget->IS_KIND_OF(ViewDragTarget))
00440     {
00441         PageDropInfo PageDropInfo;
00442         ((ViewDragTarget*)pDragTarget)->GetDropInfo(&PageDropInfo);
00443 
00444         NodeRenderableInk* pObjectHit   = PageDropInfo.pObjectHit;
00445         ObjectDragTarget TargetHit      = PageDropInfo.TargetHit;
00446 
00447         String_256 ObjectDesc = String_32(_R(IDS_SGBITMAP_THIS_OBJECT)); // " this object";
00448 
00449         if (pObjectHit)
00450         {
00451             ObjectDesc = pObjectHit->Describe(FALSE);
00452         }
00453 
00454         if (pObjectHit && pObjectHit->IS_KIND_OF(NodeBitmap))
00455             TargetHit = NO_TARGET;              // Ignore NodeBitmap objects
00456 
00457         ClickModifiers ClickMods = ClickModifiers::GetClickModifiers();
00458         BOOL IsInside = ClickMods.Constrain;
00459 
00460         if (!IsInside && pObjectHit && pObjectHit->IsCompound())
00461         {
00462             TargetHit = MANY_TARGET;
00463         }
00464 
00465         switch (TargetHit)
00466         {
00467             case FILL_TARGET:
00468             case LINE_TARGET:
00469             case STARTCOL_TARGET:
00470             case ENDCOL_TARGET:
00471             case ENDCOL2_TARGET:
00472             case ENDCOL3_TARGET:
00473                 DragString += String_256(_R(IDS_SGBITMAP_DROP_APPLY_FILL)); // "Drop to apply a Bitmap fill to this ";
00474                 DragString += ObjectDesc;
00475                 if (IsInside)
00476                     DragString += String_16(_R(IDS_SGBITMAP_ALONE)); // " alone";
00477                 break;
00478             case MANY_TARGET:
00479                 DragString += String_256(_R(IDS_SGBITMAP_DROP_APPLY_FILL)); // "Drop to apply a Bitmap fill to this ";
00480                 DragString += ObjectDesc;
00481                 DragString += String_256(_R(IDS_SGBITMAP_CONTROL_DROP_INSIDE)); // "; Press 'Control' to drop 'Inside'";
00482                 break;
00483             case NO_TARGET:
00484                 if (IsInside)
00485                 {
00486                     DragString += String_256(_R(IDS_DRAGBMP_DROP_SETPAGEBACKGROUND)); // "Drop to set the Bitmap fill of the page background";
00487                 }
00488                 else
00489                 {
00490                     DragString += String_256(_R(IDS_SGBITMAP_DROP_INSERT_BITMAP)); // "Drop to Insert a new Bitmap object on the Page";
00491                 }
00492                 break;
00493         };
00494 
00495         *TheText = DragString;
00496         return TRUE;
00497     }
00498     
00499     return FALSE;
00500 }
00501 
00502 /********************************************************************************************
00503 
00504 >   BOOL GalleryBitmapDragInfo::OnPageDrop(ViewDragTarget* pDragTarget)
00505  
00506     Author:     Will_Cowling (Xara Group Ltd) <camelotdev@xara.com>
00507     Created:    19/3/95       
00508     Inputs:     -
00509     Outputs:    -
00510     Returns:    -
00511     Purpose:    Called when a bitmap is dropped onto the page.
00512     Errors:     -
00513     SeeAlso:    -
00514 
00515 ********************************************************************************************/
00516 
00517 BOOL GalleryBitmapDragInfo::OnPageDrop(ViewDragTarget* pDragTarget)
00518 {
00519     PageDropInfo ThePageDropInfo;
00520     ((ViewDragTarget*)pDragTarget)->GetDropInfo(&ThePageDropInfo);
00521     NodeRenderableInk* pObjectHit = ThePageDropInfo.pObjectHit;
00522 
00523     // Find the bitmap to apply
00524     KernelBitmap* BitmapToApply = TheBitmap;
00525     TheBitmap = NULL;
00526 
00527     if(BitmapToApply == NULL)
00528         return FALSE;
00529 
00530     // See if the user dropped the bitmap onto an object(s) on the page
00531     // If so then try and apply that bitmap as a fill to that object(s).
00532     if (pObjectHit && !pObjectHit->IS_KIND_OF(NodeBitmap)) 
00533     {
00534         // Fill the object(s) with the dropped bitmap
00535         AttrBitmapColourFill* Attrib = new AttrBitmapColourFill;
00536         if (Attrib == NULL)
00537             return FALSE;
00538 
00539         Attrib->AttachBitmap(BitmapToApply);
00540 
00541         AttributeManager::ApplyAttribToNode(pObjectHit, Attrib);
00542     }
00543     else
00544     {
00545         // Not dropped onto an object on the page
00546         // See if the control key is pressed
00547         BOOL Constrain = KeyPress::IsConstrainPressed();
00548         if (Constrain)
00549         {
00550             // If the control key is pressed then apply the bitmap as a new background
00551             // We should use the document given to us by the page info class
00552             Document * pDocument = ThePageDropInfo.pDoc;
00553             if (pDocument == NULL)
00554                 return FALSE;
00555             OpBackgroundParam Param;
00556             Param.pBitmap = BitmapToApply;
00557             Param.pDoc = pDocument;         
00558             Param.pSpread = ThePageDropInfo.pSpread;
00559             
00560             // Obtain a pointer to the op descriptor for the create operation 
00561             OpDescriptor* pOpDesc = OpDescriptor::FindOpDescriptor(OPTOKEN_BACKGROUND);
00562 
00563             // Invoke the operation, passing in our parameters
00564             if (pOpDesc)
00565                 pOpDesc->Invoke(&Param);         
00566         }
00567         else
00568         {
00569             // Create a new bitmap on the page at the drop point
00570 
00571             // Obtain a pointer to the op descriptor for the create operation 
00572             OpDescriptor* OpDesc = OpDescriptor::FindOpDescriptor(CC_RUNTIME_CLASS(OpCreateNodeBitmap));
00573 
00574             if (OpDesc)
00575             {
00576                 // Invoke the operation, passing DocView and Pos as parameters
00577                 OpParam param((void *)BitmapToApply,(void *)&ThePageDropInfo);
00578                 OpDesc->Invoke(&param);      
00579             }
00580         }
00581     }
00582 
00583     return TRUE;
00584 }
00585 
00586 
00587 /***********************************************************************************************
00588 
00589 >   SGDisplayKernelBitmap::SGDisplayKernelBitmap()
00590 
00591     Author:     Will_Cowling (Xara Group Ltd) <camelotdev@xara.com>
00592     Created:    27/1/95 (base generated in sgbase.cpp)
00593 
00594     Purpose:    SGDisplayKernelBitmap constructor
00595                 DON'T call this constructor. It ERROR3's. Call the other constructor
00596 
00597 ***********************************************************************************************/
00598 
00599 SGDisplayKernelBitmap::SGDisplayKernelBitmap()
00600 {
00601     ERROR3("Illegal call on default SGDisplayKernelBitmap constructor - call the other one!");
00602     TheKernelBitmap = NULL;
00603 }
00604 
00605 
00606 /***********************************************************************************************
00607 
00608 >   SGDisplayKernelBitmap::SGDisplayKernelBitmap(KernelBitmap *KernelBitmapToDisplay)
00609 
00610     Author:     Will_Cowling (Xara Group Ltd) <camelotdev@xara.com>
00611     Created:    27/1/95 (base generated in sgbase.cpp)
00612 
00613     Inputs:     KernelBitmapToDisplay - The KernelBitmap this item will display
00614 
00615     Purpose:    SGDisplayKernelBitmap constructor
00616 
00617 ***********************************************************************************************/
00618 
00619 SGDisplayKernelBitmap::SGDisplayKernelBitmap(KernelBitmap *KernelBitmapToDisplay)
00620 {
00621     ERROR3IF(KernelBitmapToDisplay == NULL,
00622                 "SGDisplayKernelBitmap - trying to construct me with a NULL parameter is bad");
00623 
00624     TheKernelBitmap = KernelBitmapToDisplay;
00625 }
00626 
00627 
00628 
00629 /***********************************************************************************************
00630 
00631 >   virtual void SGDisplayKernelBitmap::CalculateMyRect(SGFormatInfo *FormatInfo,
00632                                                 SGMiscInfo *MiscInfo)
00633 
00634     Author:     Will_Cowling (Xara Group Ltd) <camelotdev@xara.com>
00635     Created:    27/1/95 (base generated in sgbase.cpp)
00636 
00637     Inputs:     FormatInfo - The formatting info from which to calculate my position/size
00638                 MiscInfo - As usual, the useful misc info struct
00639 
00640     Outputs:    member variable FormatRect - is returned filled in with the size/position of
00641                 this KernelBitmap item's display area. This is dependent upon the current display
00642                 mode and format state
00643 
00644                 FormatInfo will be updated as a result of the formatting operation
00645 
00646     Purpose:    Shared code for KernelBitmap items to calculate where they will appear in the
00647                 grand scheme of things
00648 
00649     Notes:      KernelBitmaps supply only one display mode ("full info")
00650 
00651     Scope:      private (for use of SGDisplayKernelBitmap class only)
00652 
00653 ***********************************************************************************************/
00654 
00655 void SGDisplayKernelBitmap::CalculateMyRect(SGFormatInfo *FormatInfo, SGMiscInfo *MiscInfo)
00656 {
00657     INT32 XSize;
00658     INT32 YSize;
00659 
00660     switch (MiscInfo->DisplayMode)
00661     {
00662         case 1:                     // 1 - Small full info
00663             XSize = GridLock(MiscInfo, SG_InfiniteWidth);
00664             YSize = GridLock(MiscInfo, SG_DefaultSmallBmp);
00665             break;
00666 
00667         case 2:                     // 2 - Large icon with name
00668             XSize = GridLock(MiscInfo, SG_DefaultLargeBmpText);
00669             YSize = GridLock(MiscInfo, SG_DefaultLargeBmp);
00670             break;
00671 
00672         default:                    // 0 - Full Info
00673             XSize = GridLock(MiscInfo, SG_InfiniteWidth);
00674             YSize = GridLock(MiscInfo, SG_DefaultLargeBmp);
00675             break;
00676     }
00677 
00678     BitmapInfo Info;
00679     INT32 MaxYSize = YSize;
00680 
00681     if (TheKernelBitmap->ActualBitmap &&
00682         TheKernelBitmap->ActualBitmap->GetInfo( &Info )
00683         )
00684     {
00685         // We will adjust the Height of the format rect
00686         // according to the Height of the bitmap.
00687 
00688         double BitmapWidth  = Info.RecommendedWidth;
00689         double BitmapHeight = Info.RecommendedHeight;
00690 
00691         // Calculate the spect ratio of the bitmap
00692         double Ratio = BitmapHeight/BitmapWidth;
00693 
00694         YSize = INT32(YSize * Ratio);
00695 
00696         // ... set a minimum height for each item
00697         INT32 SelHeight = 16000;
00698 
00699         if (YSize < SelHeight*3)
00700             YSize = SelHeight*3;
00701 
00702         if (YSize > MaxYSize)
00703             YSize = MaxYSize;
00704     }
00705 
00706     CalculateFormatRect(FormatInfo, MiscInfo, XSize, YSize);
00707 }
00708 
00709 
00710 
00711 /***********************************************************************************************
00712 
00713 >   virtual void SGDisplayKernelBitmap::HandleRedraw(SGRedrawInfo *RedrawInfo,
00714                                                 SGFormatInfo *FormatInfo)
00715 
00716     Author:     Will_Cowling (Xara Group Ltd) <camelotdev@xara.com>
00717     Created:    27/1/95 (base generated in sgbase.cpp)
00718 
00719     Inputs:     RedrawInfo  - The information on the kernel-rendered redraw area
00720                 FormatInfo  - The formatting information structure
00721 
00722                 member variable FormatRect should be set up (before calling this method)
00723                 to be the rectangle in which to draw this item
00724 
00725     Purpose:    SGDisplayKernelBitmap item redraw method - removed from the main HandleEvent
00726                 method merely to make the code tidier.
00727 
00728     Scope:      private
00729 
00730 ***********************************************************************************************/
00731 
00732 void SGDisplayKernelBitmap::HandleRedraw(SGRedrawInfo *RedrawInfo, SGMiscInfo *MiscInfo)
00733 {
00734     if (TheKernelBitmap == NULL || TheKernelBitmap->ActualBitmap == NULL)
00735         return;
00736 
00737     StartRendering(RedrawInfo, MiscInfo);
00738 
00739     DocRect MyRect(FormatRect);     // Get my redraw position from the cached FormatRect
00740 
00741 
00742     // Is this a valid format rectangle ?
00743     if (MyRect.IsEmpty() || !MyRect.IsValid())
00744     {
00745         // No, so just ignore it
00746         // Erroring here is not good, as we are in the middle of a redraw loop
00747         StopRendering(RedrawInfo, MiscInfo);
00748         return;
00749     }
00750 
00751     // Check the rectangle is at least our minimum height,
00752     // and adjust it if not
00753     //INT32 SelHeight = 16000; 
00754     // Changed to allow a third line of text.
00755     INT32 SelHeight = 23000; 
00756 
00757     if (MyRect.Height() < SelHeight*3)
00758     {
00759         INT32 diff = SelHeight*3 - MyRect.Height();
00760         MyRect.Inflate(0, diff);
00761     }
00762 
00763     RenderRegion *Renderer = RedrawInfo->Renderer;
00764 
00765     INT32 OnePixel          = (INT32) DevicePixels(MiscInfo, 1);
00766     INT32 TwoPixels         = (INT32) DevicePixels(MiscInfo, 2);
00767     INT32 ThreePixels   = (INT32) DevicePixels(MiscInfo, 3);
00768 
00769     Renderer->SetLineWidth(0);
00770     Renderer->SetLineColour(RedrawInfo->Transparent);
00771 
00772     // Now calculate the rectangle to plot the bitmap into
00773     DocRect IconRect(MyRect);
00774 
00775     BitmapInfo Info;
00776 
00777     BOOL bScaleDown = FALSE;
00778 
00779     if (TheKernelBitmap->ActualBitmap &&
00780         TheKernelBitmap->ActualBitmap->GetInfo( &Info ))
00781     {
00782         // We will try and make all the bitmaps the same width on screen.
00783         double BitmapWidth  = Info.RecommendedWidth;
00784         double BitmapHeight = Info.RecommendedHeight;
00785 
00786         // Calculate the spect ratio of the bitmap
00787         double Ratio = BitmapWidth/BitmapHeight;
00788 
00789         INT32 IconWidth = INT32(IconRect.Height() * Ratio);
00790 
00791         INT32 YSize;
00792         switch (MiscInfo->DisplayMode)
00793         {
00794             case 1:                     // 1 - Small full info
00795                 YSize = GridLock(MiscInfo, SG_DefaultSmallBmp);
00796                 break;
00797 
00798             case 2:                     // 2 - Large icon with name
00799                 YSize = GridLock(MiscInfo, SG_DefaultLargeBmp);
00800                 break;
00801 
00802             default:                    // 0 - Full Info
00803                 YSize = GridLock(MiscInfo, SG_DefaultLargeBmp);
00804                 break;
00805         }
00806         
00807         // If the bitmap is very Wide and Thin, then we need to scale it
00808         // so it fits into out maximum icon width
00809         if (IconWidth > YSize)
00810         {
00811             Matrix Scale;
00812             Ratio = double(IconWidth)/double(YSize);
00813 
00814             Scale = Matrix(FIXED16(1)/Ratio, FIXED16(1)/Ratio);
00815 
00816             DocCoord Centre;
00817             Centre.x = IconRect.lo.x;
00818             Centre.y = IconRect.lo.y + IconRect.Height()/2;
00819 
00820             // Scale the bitmap rectangle about the Left Middle so
00821             // that it is always 'YSize' in Width
00822             IconRect.Translate(-Centre.x, -Centre.y);
00823             Scale.transform(&IconRect.lo);
00824             Scale.transform(&IconRect.hi);
00825             IconRect.Translate(Centre.x, Centre.y);
00826 
00827             IconWidth = YSize;
00828             bScaleDown = TRUE;
00829         }
00830 
00831         INT32 RightSpace = 0;
00832 
00833         if (IconWidth < YSize)
00834         {
00835             INT32 LeftSpace = TwoPixels * 4;
00836             RightSpace = YSize - IconWidth - LeftSpace;
00837             IconRect.Translate(LeftSpace, 0);   // Move it over a bit
00838         }
00839 
00840         // Now setup the IconRect
00841         IconRect.hi.x = IconRect.lo.x + IconWidth;
00842 
00843         MyRect.lo.x = IconRect.hi.x + RightSpace + TwoPixels;   // And exclude it from 'MyRect'
00844         MyRect.lo.x += TwoPixels;
00845 
00846         // Now check the Icon isn't too tall
00847 
00848         INT32 MaxYSize = YSize;
00849         INT32 IconHeight = IconRect.Height();
00850         if (IconHeight > MaxYSize)
00851         {
00852             Matrix Scale;
00853             Ratio = double(IconHeight)/double(YSize);
00854 
00855             Scale = Matrix(FIXED16(1)/Ratio, FIXED16(1)/Ratio);
00856 
00857             DocCoord Centre;
00858             Centre.x = IconRect.lo.x + IconRect.Width()/2;
00859             Centre.y = IconRect.hi.y;
00860 
00861             // Scale the bitmap rectangle about the Middle so
00862             // that it is always 'YSize' in Height
00863             IconRect.Translate(-Centre.x, -Centre.y);
00864             Scale.transform(&IconRect.lo);
00865             Scale.transform(&IconRect.hi);
00866             IconRect.Translate(Centre.x, Centre.y);
00867 
00868             MyRect.lo.y = IconRect.lo.y;
00869             MyRect.hi.y = IconRect.hi.y;
00870             bScaleDown = TRUE;
00871         }
00872     }
00873 
00874     // This section doesn't currently do anything special as we 
00875     // have gone back to using an OSRenderRegion
00876     // If the display quality is too bad then we should modify 
00877     // this code to render a high quality thumbnail and store it 
00878     // for future use, rendering the thumbnail into an OSRenderRegion
00879 /*  Renderer->SetUsingSmoothedBitmaps(bScaleDown);
00880     if (bScaleDown)
00881     {
00882         Quality qual;
00883         qual.SetQuality(QUALITY_MAX);
00884         QualityAttribute *pQuality = new QualityAttribute(qual);
00885         Renderer->SetQuality(pQuality, TRUE);           // Temp
00886     }
00887     else
00888     {
00889         Quality qual;   // QUALITY_DEFAULT is implied
00890         QualityAttribute *pQuality = new QualityAttribute(qual);
00891         Renderer->SetQuality(pQuality, TRUE);           // Temp
00892     }*/
00893 
00894     GridLockRect(MiscInfo, &MyRect);    // Ensure the new 'MyRect' is pixel-grid-aligned
00895 
00896     // If we can, we need to leave a little space around the
00897     // edges of the bitmap rect, so we can see the 'Selected' rectangle
00898     // behind it.  We only try this if the rectangle is big enough
00899     // otherwise the Inflate routine will create an invalid rectangle.
00900 
00901     if (IconRect.Height() > ThreePixels * 2)
00902         IconRect.Inflate(0, -ThreePixels);      // Leave a bit of space around the edge
00903 
00904     if (IconRect.Width() > ThreePixels * 2)
00905         IconRect.Inflate(-ThreePixels, 0);      // Leave a bit of space around the edge
00906     
00907     GridLockRect(MiscInfo, &IconRect);  // Ensure it maps exactly to specific pixels
00908 
00909     // Need to remember the icon rect size before the selection rectangle takes over...
00910     DocRect ThumbnailRect(IconRect);
00911 
00912     // In the bitmap gallery, it's better to show something than nothing
00913     // So if the thumbnail has become so thin as to be invisible
00914     // We will bodge it back into shape even if that distorts things a bit
00915     if (ThumbnailRect.Width()==0)
00916         ThumbnailRect.hi.x = ThumbnailRect.lo.x + OnePixel;
00917     if (ThumbnailRect.Height()==0)
00918         ThumbnailRect.hi.y = ThumbnailRect.lo.y + OnePixel;
00919 
00920     // Set up the colours for rendering our text, and fill the background if selected
00921     if (Flags.Selected)
00922     {
00923         // This Item is Selected
00924 
00925         // Fill the entire background with the 'selected' colour, so we don't
00926         // get gaps between bits of text or uneven rectangles in multiple selections
00927         Renderer->SetFillColour(RedrawInfo->SelBackground);
00928 
00929         Renderer->SetFillColour(COLOUR_BLACK);
00930         IconRect.Inflate(ThreePixels);
00931 
00932         // Draw a Three Pixel wide rectangle around the edge of the bitmap
00933         // (Actually we're plotting a filled rectangle which is three pixels
00934         //  bigger than the bitmap rectangle)
00935         Renderer->DrawRect(&IconRect);
00936 
00937         // If the icon rect is wider than the gallery, then MyRect could have become invalid,
00938         // so we only try to draw the selection background if any of it is actually visible
00939         if (MyRect.IsValid())
00940         {
00941             DocRect SelRect(MyRect);
00942             if (SelHeight > MyRect.Height()/2)
00943                 SelHeight = MyRect.Height()/2;
00944 
00945             SelRect.hi.y = MyRect.lo.y + MyRect.Height()/2 + SelHeight;
00946             SelRect.lo.y = MyRect.lo.y + MyRect.Height()/2 - SelHeight;
00947             SelRect.lo.x += ThreePixels;
00948             GridLockRect(MiscInfo, &SelRect);   // Ensure it maps exactly to specific pixels
00949 
00950             Renderer->SetFillColour(RedrawInfo->SelBackground);
00951             Renderer->DrawRect(&SelRect);
00952         }
00953 
00954         Renderer->SetFixedSystemTextColours(&RedrawInfo->SelForeground, &RedrawInfo->SelBackground);
00955     }
00956     else
00957     {
00958         // This Item is Not Selected
00959         Renderer->SetFixedSystemTextColours(&RedrawInfo->Foreground, &RedrawInfo->Background);
00960     }
00961 
00962 
00963 #ifdef SGBITMAP_BACKGROUND_REDRAW
00964 
00965     BOOL DrawnBitmap = FALSE;
00966 
00967     if (ShouldIDrawForeground(DrawnBitmap))
00968     {
00969         if(!DrawnBitmap)
00970         {
00971             // Now we need to create a temporary NodeBitmap, which we will
00972             // use to render the bitmap preview.
00973             NodeBitmap* DummyBmp = new NodeBitmap();
00974             if (DummyBmp == NULL)
00975             {
00976                 // Just exit if we're out of memory
00977                 SGLibDisplayItem::DrawNullBitmapRect(Renderer, MiscInfo, &ThumbnailRect, FALSE);
00978                 StopRendering(RedrawInfo, MiscInfo);
00979                 return;
00980             }
00981 
00982             // Set the NodeBitmap path to be our IconRect, 
00983             // and attach the Bitmap to it.
00984             DummyBmp->SetUpPath();
00985             DummyBmp->CreateShape(ThumbnailRect);
00986             DummyBmp->GetBitmapRef()->SetBitmap(TheKernelBitmap);
00987 
00988             // Now render the bitmap preview
00989             DummyBmp->Render(Renderer);
00990 
00991             delete DummyBmp;
00992         }
00993     }
00994     else
00995     {
00996         // We should background render, so we just draw a blank grey box
00997         if(!DrawnBitmap)
00998             SGLibDisplayItem::DrawNullBitmapRect(Renderer, MiscInfo, &ThumbnailRect, TRUE);
00999     }
01000 
01001 #else
01002 
01003     // Now we need to create a temporary NodeBitmap, which we will
01004     // use to render the bitmap preview.
01005     NodeBitmap* DummyBmp = new NodeBitmap();
01006     if (DummyBmp == NULL)
01007     {
01008         // Just exit if we're out of memory
01009         StopRendering(RedrawInfo, MiscInfo);
01010         return;
01011     }
01012 
01013     // Set the NodeBitmap path to be our IconRect, 
01014     // and attach the Bitmap to it.
01015     DummyBmp->SetUpPath();
01016     DummyBmp->CreateShape(ThumbnailRect);
01017     DummyBmp->GetBitmapRef()->SetBitmap(TheKernelBitmap);
01018 
01019     // Now render the bitmap preview
01020     DummyBmp->Render(Renderer);
01021 
01022     delete DummyBmp;
01023 
01024 #endif
01025 
01026     // Leave a small gap before text begins
01027     MyRect.lo.x += SG_GapBeforeText*2;
01028 
01029     // And now render the text describing the bitmap
01030     // ...but only if there is any space left (i.e. MyRect is still valid)
01031     if (MyRect.IsValid())
01032     {
01033         // First get the name of the bitmap
01034         String_256 BitmapName = TheKernelBitmap->ActualBitmap->GetName();
01035 
01036         // Now find how many colours it has
01037         String_256 BitmapCols;
01038         INT32 bpp = TheKernelBitmap->GetBPP();
01039 
01040         BOOL HasTransparency = FALSE;
01041         
01042         if (bpp <= 8)
01043         {
01044             // Check to see if this is a masked bitmap
01045             INT32 Index;
01046 
01047             if (TheKernelBitmap->GetTransparencyIndex(&Index))
01048                 HasTransparency = TRUE;
01049         }
01050 
01051         switch (bpp)
01052         {
01053             case 1:
01054                 if (HasTransparency)
01055                     BitmapCols = _R(IDS_SGBITMAP_MONOCHROME_T); // "Monochrome, transparent";
01056                 else
01057                     BitmapCols = _R(IDS_SGBITMAP_MONOCHROME);   // "Monochrome";
01058                 break;
01059 
01060             case 2:
01061                 if (HasTransparency)
01062                     BitmapCols = _R(IDS_SGBITMAP_4COLOURS_T);   // "3 colours, transparent";
01063                 else
01064                     BitmapCols = _R(IDS_SGBITMAP_4COLOURS);     // "4 colours";
01065                 break;
01066 
01067             case 4:
01068                 if (HasTransparency)
01069                     BitmapCols = _R(IDS_SGBITMAP_16COLOURS_T);  // "15 colours, transparent";
01070                 else
01071                     BitmapCols = _R(IDS_SGBITMAP_16COLOURS);    // "16 colours";
01072                 break;
01073 
01074             case 8:
01075                 if (HasTransparency)
01076                     BitmapCols = _R(IDS_SGBITMAP_256COLOURS_T); // "255 colours, transparent";
01077                 else
01078                     BitmapCols = _R(IDS_SGBITMAP_256COLOURS);   // "256 colours";
01079                 break;
01080 
01081             case 16:
01082                 BitmapCols = _R(IDS_SGBITMAP_65COLOURS);        // "65K colours";
01083                 break;
01084 
01085             case 24:
01086                 BitmapCols = _R(IDS_SGBITMAP_MILLIONS_COLOURS); // "Millions of colours";
01087                 break;
01088 
01089             case 32:
01090                 BitmapCols = _R(IDS_SGBITMAP_32_BIT); // "Millions of colours";
01091                 break;
01092 
01093             default:
01094                 BitmapCols = "";
01095                 break;
01096         }
01097 
01098         // Now get its pixel Width and Height
01099         String_256 BitmapWidth;
01100         Convert::LongToString(Info.PixelWidth, &BitmapWidth);
01101         
01102         String_256 BitmapHeight;
01103         Convert::LongToString(Info.PixelHeight, &BitmapHeight);
01104 
01105         // Find the delay value;
01106         UINT32 BitmapDelay = TheKernelBitmap->ActualBitmap->GetBitmapAnimDelay();
01107         String_256 Delay;
01108         Convert::LongToString(BitmapDelay, &Delay);
01109 
01110         // And finally, work out how much memory it is using
01111         // The memory size depends on whether this is a bitmap or JPEG.
01112 
01113         INT32 Bytes = 0;
01114         BitmapSource* pSource = NULL;
01115         BaseBitmapFilter* pDummyFilter;
01116 
01117 PORTNOTE("other", "Removed XPE hook")
01118 #ifndef EXCLUDE_FROM_XARALX
01119         KernelBitmap* pMaster = NULL;
01120         IXMLDOMDocumentPtr pEdits = NULL;
01121         TheKernelBitmap->GetXPEInfo(pMaster, pEdits);
01122         BOOL bIsXPE = (pMaster!=NULL && pEdits!=NULL);
01123 #else
01124         BOOL bIsXPE = FALSE;
01125 #endif
01126 
01127         BOOL OriginalSourcePresent = TheKernelBitmap->GetOriginalSource(&pSource, &pDummyFilter);
01128         String_256 BitmapFormat;
01129         if(OriginalSourcePresent)
01130         {
01131             if (pSource != NULL)
01132             {
01133                 if (pSource->IsJPEG())
01134                 {
01135                     Bytes = pSource->GetSize();
01136                     BitmapFormat = _R(IDS_FORMAT_JPEG);
01137                 }
01138             }
01139         }
01140         else if (bIsXPE)
01141         {
01142             BitmapFormat = _R(IDS_FORMAT_XPE);
01143         }
01144         else
01145         {
01146             Bytes = (Info.PixelWidth * Info.PixelHeight * bpp)/8;
01147             BitmapFormat = _R(IDS_FORMAT_BITMAP);
01148         }
01149 
01150         String_256 MemoryUsed;
01151         Convert::BytesToString(&MemoryUsed, Bytes);
01152 
01153         if (!BaseCamelotFilter::ShouldSaveXPEBitmaps() && bIsXPE)
01154         {
01155             // If the bitmap is generated from a Master and edit list
01156             // Then don't show size in bytes 'cos it's meaningless
01157             MemoryUsed.Load(_R(IDS_SGBITMAP_XPE));
01158         }
01159 
01160         // Now we are going to plot all that information
01161         // split into two lines of text
01162         DocRect TopRect(MyRect);
01163         DocRect MiddleRect(MyRect);
01164         DocRect BottomRect(MyRect);
01165 
01166         //TopRect.lo.y  += 11000;
01167         TopRect.lo.y    += 18000;
01168         MiddleRect.hi.y     -= 5000;
01169         //MiddleRect.hi.y   -= 16000; Down
01170         BottomRect.hi.y -= 26000; 
01171 
01172         // Plot the Name and Memory used on the Top Line
01173         String_256 TopLine; // = "'"+BitmapName+"', "+BitmapFormat", "+MemoryUsed;
01174         TopLine.MakeMsg(_R(IDS_SGBITMAP_FULLINFO_TOPLINE),(TCHAR *)BitmapName,(TCHAR*)BitmapFormat,(TCHAR *)MemoryUsed);
01175         Renderer->DrawFixedSystemText(&TopLine, TopRect);               
01176 
01177 
01178         // Plot the Dimensions and Colours on the Bottom Line
01179         String_256 MiddleLine; //  = BitmapWidth+" by "+BitmapHeight+" pixels,  "+BitmapCols;
01180 
01181         // Calculate the dpi of the original winbitmap...
01182         UINT32 hdpi = TheKernelBitmap->ActualBitmap->GetHorizontalDPI();
01183         UINT32 vdpi = TheKernelBitmap->ActualBitmap->GetVerticalDPI();
01184 
01185         if (hdpi == vdpi)
01186         {
01187             String_256 dpitext;
01188             Convert::LongToString(hdpi, &dpitext);
01189             MiddleLine.MakeMsg(_R(IDS_SGBITMAP_FULLINFO_BOTTOMLINE), (TCHAR *)BitmapWidth, (TCHAR *)BitmapHeight, (TCHAR *)BitmapCols, (TCHAR *)dpitext);
01190         }
01191         else
01192         {
01193             String_256 dpitext;
01194             camSnprintf(dpitext, 256, _T("%u x %u"), hdpi, vdpi);
01195             MiddleLine.MakeMsg(_R(IDS_SGBITMAP_FULLINFO_BOTTOMLINE), (TCHAR *)BitmapWidth, (TCHAR *)BitmapHeight, (TCHAR *)BitmapCols, (TCHAR *)dpitext);
01196         }
01197         Renderer->DrawFixedSystemText(&MiddleLine, MiddleRect);             
01198 
01199 
01200         // Find the Restore type 
01201         GIFDisposalMethod RestoreType = TheKernelBitmap->ActualBitmap->GetAnimationRestoreType();
01202         
01203         switch(RestoreType)
01204         {
01205             case GDM_NONE:
01206             {
01207                 String_256 BottomLine;
01208                 String_256 Nothing(_R(IDS_NOTHING));
01209                 BottomLine.MakeMsg(_R(IDS_SGBITMAP_DELAY_RESTORE_BOTTOMLINE), (TCHAR*)Delay, (TCHAR*)Nothing);
01210                 Renderer->DrawFixedSystemText(&BottomLine, BottomRect); 
01211             }
01212             break;
01213             case  GDM_LEAVE:
01214             {
01215                 String_256 BottomLine;
01216                 String_256 Leave(_R(IDS_LEAVE));
01217                 BottomLine.MakeMsg(_R(IDS_SGBITMAP_DELAY_RESTORE_BOTTOMLINE), (TCHAR*)Delay, (TCHAR*)Leave);
01218                 Renderer->DrawFixedSystemText(&BottomLine, BottomRect);             
01219             }
01220             break;
01221             case GDM_BACKTOBACK:
01222             {
01223                 String_256 BottomLine;
01224                 String_256 Back(_R(IDS_BACKGROUND));
01225                 BottomLine.MakeMsg(_R(IDS_SGBITMAP_DELAY_RESTORE_BOTTOMLINE), (TCHAR*)Delay, (TCHAR*)Back);
01226                 Renderer->DrawFixedSystemText(&BottomLine, BottomRect);             
01227             }
01228             break;
01229             case GDM_PREVIOUS:
01230             {
01231                 String_256 BottomLine;
01232                 String_256 Previous(_R(IDS_PREVIOUS));
01233                 BottomLine.MakeMsg(_R(IDS_SGBITMAP_DELAY_RESTORE_BOTTOMLINE), (TCHAR*)Delay, (TCHAR*)Previous);
01234                 Renderer->DrawFixedSystemText(&BottomLine, BottomRect);             
01235             }
01236             break;
01237 
01238             default:
01239                 break;
01240         }
01241     }
01242 
01243     StopRendering(RedrawInfo, MiscInfo);
01244 }
01245 
01246 
01247 /***********************************************************************************************
01248 
01249 >   virtual void SGDisplayKernelBitmap::DragWasReallyAClick(SGMouseInfo *Mouse, SGMiscInfo *MiscInfo)
01250 
01251     Author:     Will_Cowling (Xara Group Ltd) <camelotdev@xara.com>
01252     Created:    19/3/95
01253 
01254     Inputs:     Mouse - The mouse info passed to the original click handler
01255                 MiscInfo - The misc info passed to the original click handler
01256 
01257     Purpose:    Handles a mouse click event. This is a callback function - drags of
01258                 bitmaps from galleries will call this function back if the drag turns
01259                 out to just be a click.
01260 
01261     SeeAlso:    SGDisplayKernelBitmap::HandleEvent; GalleryBitmapDragInfo::OnClick
01262 
01263 ***********************************************************************************************/
01264 
01265 void SGDisplayKernelBitmap::DragWasReallyAClick(SGMouseInfo *Mouse, SGMiscInfo *MiscInfo)
01266 {
01267     // Just get default selection action to be applied for this click
01268     DefaultClickHandler(Mouse, MiscInfo, TRUE);
01269 }
01270 
01271 /***********************************************************************************************
01272 
01273 >   virtual BOOL SGDisplayKernelBitmap::HandleEvent(SGEventType EventType, void *EventInfo,
01274                                              SGMiscInfo *MiscInfo)
01275 
01276     Author:     Will_Cowling (Xara Group Ltd) <camelotdev@xara.com>
01277     Created:    27/1/95 (base generated in sgbase.cpp)
01278 
01279     Inputs:     EventType - An enumerated value describing what type of event is to be processed
01280 
01281                 EventInfo - A structure describing the event (may be NULL). The exact thing
01282                             pointed at by this pointer depends upon the event type:
01283 
01284                             MonoOn
01285                             Event               Thing EventInfo points at
01286                             SGEVENT_FORMAT      (SGFormatInfo *)
01287                             SGEVENT_REDRAW      (SGRedrawInfo *)
01288                             SGEVENT_MOUSECLICK  (SGMouseInfo *)
01289                             MonoOff
01290                 Use the provided SGDisplayNode::Get[Format]Info() inlines to retrieve this
01291                 information - they provide useful error/type checking, and hide the cast
01292 
01293                 MiscInfo - always provided. Contains a few useful bits of info that may be
01294                 needed for all event types.
01295 
01296     Outputs:    FormatInfo is updated as appropriate
01297 
01298     Returns:    TRUE if the event was handled successfully
01299                 FALSE if it was not
01300 
01301     Purpose:    Handles a SuperGallery DisplayTree event
01302 
01303     Notes:      This overrides the pure virtual SGDisplayNode::HandleEvent method
01304 
01305                 A node need not handle a specific event - if it does not handle it, it
01306                 should return FALSE.
01307 
01308                 Redraw and Formatting handlers should never return TRUE, as this will
01309                 prevent the event from continuing through the tree.
01310 
01311                 Non-leaf-nodes must call SGDisplayNode::GiveEventToMyChildren in order
01312                 to pass the event dow the tree. THIS node is a leaf-node, so it doesn't.
01313 
01314     SeeAlso:    SGDisplayNode::HandleEvent
01315 
01316 ***********************************************************************************************/
01317 
01318 BOOL SGDisplayKernelBitmap::HandleEvent(SGEventType EventType, void *EventInfo,
01319                                   SGMiscInfo *MiscInfo)
01320 {
01321     switch (EventType)
01322     {
01323         case SGEVENT_FORMAT:
01324             {
01325                 SGFormatInfo *FormatInfo = GetFormatInfo(EventType, EventInfo);
01326                 CalculateMyRect(FormatInfo, MiscInfo);      // Cache our FormatRect for later use
01327             }
01328             break;
01329 
01330 
01331         case SGEVENT_REDRAW:
01332             {
01333                 DocRect MyRect(FormatRect);     // Rely on FormatRect being cached from above
01334                 SGRedrawInfo *RedrawInfo = GetRedrawInfo(EventType, EventInfo);
01335 
01336                 if (IMustRedraw(RedrawInfo))    // only redraw if we intersect the clip rect
01337                      HandleRedraw(RedrawInfo, MiscInfo);
01338             }
01339             break;      // exit and return FALSE to pass the redraw event on
01340 
01341 
01342         case SGEVENT_MOUSECLICK:
01343             {
01344                 SGMouseInfo *Mouse = GetMouseInfo(EventType, EventInfo);
01345 
01346                 if (FormatRect.ContainsCoord(Mouse->Position))
01347                 {
01348                     // If the colour is in the selected document, then it is safe to
01349                     // do a colour drag - for now, it will only allow drags for the
01350                     // selected doc.
01351                     // Otherwise, the normal click action takes place.
01352                     // If the drag fails (turns into a click) then the normal click action
01353                     // takes place, passed on by the GalleryColourDragInfo::OnClick handler
01354 //                  SGDisplayGroup *Parent = (SGDisplayGroup *) GetParent();
01355 
01356                     if (Mouse->DoubleClick) // || Parent->GetParentDocument() != Document::GetSelected())
01357                     {
01358                         // Send bitmap to Xara Photo Editor
01359 /*                      OpDescriptor* pOpDesc = OpDescriptor::FindOpDescriptor(OPTOKEN_XPE_EDIT);
01360                         if (pOpDesc)
01361                         {
01362                             pOpDesc->Invoke();
01363                             return TRUE;
01364                         }
01365                         else
01366 */
01367                             DefaultClickHandler(Mouse, MiscInfo);
01368                     }
01369                     else
01370                     {
01371                         DefaultPreDragHandler(Mouse, MiscInfo);
01372 
01373                         GalleryBitmapDragInfo *DragBmp;
01374                         DragBmp = new GalleryBitmapDragInfo(this, Mouse, MiscInfo,
01375                                                             Mouse->MenuClick);
01376                         if (DragBmp != NULL)
01377                             DragManagerOp::StartDrag(DragBmp, GetListWindow());
01378                     }
01379 
01380                     return(TRUE);       // Claim this event - nobody else can own this click
01381                 }
01382             }
01383             break;
01384 
01385         default:
01386             return(SGDisplayItem::HandleEvent(EventType, EventInfo, MiscInfo));
01387     }
01388 
01389     // Default return value: We do not claim this event, so it will be passed on to others
01390     return(FALSE);
01391 }
01392 
01393 /********************************************************************************************
01394 
01395 >   virtual void SGDisplayKernelBitmap::GetNameText(String_256 *Result)
01396 
01397     Author:     Will_Cowling (Xara Group Ltd) <camelotdev@xara.com>
01398     Created:    19/3/95
01399 
01400     Outputs:    On exit, the string pointed at by Result will contain either a blank
01401                 string, or the name text associated with this item (if any)
01402 
01403     Purpose:    To determine a name string for this node. Generally, this is used for
01404                 a simple mechanism which searches for display items whose names match
01405                 given search parameters in some way. It is also used in libraries to
01406                 provide default redraw methods.
01407 
01408     SeeAlso:    SGDisplayKernelBitmap::GetFullInfoText
01409 
01410 ********************************************************************************************/
01411 
01412 void SGDisplayKernelBitmap::GetNameText(String_256 *Result)
01413 {
01414     ERROR3IF(Result == NULL, "Illegal NULL param");
01415 
01416     *Result = TheKernelBitmap->ActualBitmap->GetName();
01417 }
01418 
01419 
01420 
01421 /********************************************************************************************
01422 
01423 >   virtual void SGDisplayKernelBitmap::GetFullInfoText(String_256 *Result)
01424 
01425     Author:     Will_Cowling (Xara Group Ltd) <camelotdev@xara.com>
01426     Created:    19/3/95
01427 
01428     Outputs:    On exit, the string pointed at by Result will contain either a blank
01429                 string, or the full-information text associated with this item (if any)
01430 
01431     Purpose:    To determine a full-info string for this node. Generally, this is used for
01432                 a simple mechanism which searches for display items whose info matches
01433                 given search parameters in some way. It is also used in libraries to
01434                 provide default redraw methods.
01435 
01436     SeeAlso:    SGDisplayKernelBitmap::GetNameText
01437 
01438 ********************************************************************************************/
01439 
01440 void SGDisplayKernelBitmap::GetFullInfoText(String_256 *Result)
01441 {
01442     ERROR3IF(Result == NULL, "Illegal NULL param");
01443 
01444     *Result = TheKernelBitmap->ActualBitmap->GetName();
01445 }
01446 
01447 /***********************************************************************************************
01448 
01449 >   virtual void SGDisplayKernelBitmap::MoveAfter(SGDisplayNode *NodeToMove)
01450 
01451     Author:     Will_Cowling (Xara Group Ltd) <camelotdev@xara.com>
01452     Created:    30/3/95
01453 
01454     Inputs:     NodeToMove - the node to move
01455 
01456     Purpose:    MOVES the given node (to a different position in the DisplayTree) as the
01457                 previous (left) sibling of this node. If the node is not linked into
01458                 a tree, it is effectively just inserted.
01459 
01460     Notes:      This base class method simply delinks the item and relinks it elsewhere
01461                 in the display tree. However, derived classes will override this method
01462                 so that moving display items can have a further effect of also rearranging
01463                 the displayed "real" items. Before/After moving the real item, the
01464                 derived class can then call this baseclass method to complete the action.
01465         
01466                 Take care when moving items between groups (e.g. if an item is "moved"
01467                 from one docuemnt to another, it could be a bad thing, so be very
01468                 careful in derived classes to take appropriate action)
01469 
01470                 Any attempt to move an item after *itself* is queitly ignored
01471 
01472     Errors:     ERROR3 and quiet exit if NodeToMove == NULL
01473 
01474     SeeAlso:    SGDisplayKernelBitmap::MoveBefore
01475 
01476 ***********************************************************************************************/
01477 
01478 void SGDisplayKernelBitmap::MoveAfter(SGDisplayNode *NodeToMove)
01479 {
01480     ERROR3IF(NodeToMove == NULL, "Illegal NULL param");
01481 
01482     if (NodeToMove == this)
01483         return;
01484 
01485     KernelBitmap *BitmapToMove = ((SGDisplayKernelBitmap *) NodeToMove)->GetDisplayedKernelBitmap();
01486     ERROR3IF(BitmapToMove == NULL, "NULL displayed bitmap?!");
01487 
01488     Document *ScopeDoc = ((SGDisplayGroup *) GetParent())->GetParentDocument();
01489     ERROR3IF(ScopeDoc == NULL, "No parent document?!");
01490 
01491     if ( ((SGDisplayGroup *) ( ((SGDisplayKernelBitmap *)NodeToMove)->GetParent() ) )->GetParentDocument() !=
01492             ScopeDoc)
01493     {
01494         ERROR2RAW("Attempt to MOVE a bitmap between documents!");
01495         return;
01496     }
01497 
01498     BitmapSGallery::IgnoreBmpListChange = TRUE; 
01499 
01500     // And get the bitmap list
01501     BitmapList* BmpList = ScopeDoc->GetBitmapList();
01502     ERROR3IF(BmpList == NULL, "A document with no bitmap list?!");
01503     
01504     BmpList->MoveAfter(GetDisplayedKernelBitmap(), BitmapToMove);
01505     SGDisplayNode::MoveAfter(NodeToMove);
01506 
01507     BitmapSGallery::IgnoreBmpListChange = FALSE;    
01508 }
01509 
01510 /***********************************************************************************************
01511 
01512 >   virtual void SGDisplayKernelBitmap::MoveBefore(SGDisplayNode *NodeToMove)
01513 
01514     Author:     Will_Cowling (Xara Group Ltd) <camelotdev@xara.com>
01515     Created:    30/3/95
01516 
01517     Inputs:     NodeToMove - the node to move
01518 
01519     Purpose:    MOVES the given node (to a different position in the DisplayTree) as the
01520                 previous (left) sibling of this node. If the node is not linked into
01521                 a tree, it is effectively just inserted.
01522 
01523     Notes:      This base class method simply delinks the item and relinks it elsewhere
01524                 in the display tree. However, derived classes will override this method
01525                 so that moving display items can have a further effect of also rearranging
01526                 the displayed "real" items. Before/After moving the real item, the
01527                 derived class can then call this baseclass method to complete the action.
01528         
01529                 Take care when moving items between groups (e.g. if an item is "moved"
01530                 from one docuemnt to another, it could be a bad thing, so be very
01531                 careful in derived classes to take appropriate action)
01532 
01533                 Any attempt to move an item Before *itself* is queitly ignored
01534 
01535     Errors:     ERROR3 and quiet exit if NodeToMove == NULL
01536 
01537     SeeAlso:    SGDisplayKernelBitmap::MoveBefore
01538 
01539 ***********************************************************************************************/
01540 
01541 void SGDisplayKernelBitmap::MoveBefore(SGDisplayNode *NodeToMove)
01542 {
01543     ERROR3IF(NodeToMove == NULL, "Illegal NULL param");
01544 
01545     if (NodeToMove == this)
01546         return;
01547 
01548     KernelBitmap *BitmapToMove = ((SGDisplayKernelBitmap *) NodeToMove)->GetDisplayedKernelBitmap();
01549     ERROR3IF(BitmapToMove == NULL, "NULL displayed bitmap?!");
01550 
01551     Document *ScopeDoc = ((SGDisplayGroup *) GetParent())->GetParentDocument();
01552     ERROR3IF(ScopeDoc == NULL, "No parent document?!");
01553 
01554     if ( ((SGDisplayGroup *) ( ((SGDisplayKernelBitmap *)NodeToMove)->GetParent() ) )->GetParentDocument() !=
01555             ScopeDoc)
01556     {
01557         ERROR2RAW("Attempt to MOVE a bitmap between documents!");
01558         return;
01559     }
01560 
01561     BitmapSGallery::IgnoreBmpListChange = TRUE; 
01562 
01563     // And get the bitmap list
01564     BitmapList* BmpList = ScopeDoc->GetBitmapList();
01565     ERROR3IF(BmpList == NULL, "A document with no bitmap list?!");
01566     
01567     BmpList->MoveBefore(GetDisplayedKernelBitmap(), BitmapToMove);
01568 
01569     SGDisplayNode::MoveBefore(NodeToMove);
01570 
01571     BitmapSGallery::IgnoreBmpListChange = FALSE;    
01572 }
01573 
01574 /********************************************************************************************
01575 
01576 >   virtual BOOL SGDisplayKernelBitmap::GetStatusLineHelp(DocCoord *MousePos, String_256 *Result)
01577 
01578     Author:     Will_Cowling (Xara Group Ltd) <camelotdev@xara.com>
01579     Created:    9/7/95
01580 
01581     Inputs:     MousePos - The current mouse position. This will generally be expected
01582                 to lie inside this item's FormatRect. With it, this item can provide
01583                 help on specific areas of an item.
01584 
01585     Outputs:    On exit, if the return value is TRUE, the string pointed at by Result
01586                 will contain a status line help string for this item
01587 
01588     Returns:    TRUE if it filled in the string, FALSE if it did not
01589                 
01590     Purpose:    Called by the parent gallery when status line help is needed. The parent
01591                 gallery will do a hit test to determine which node contains the pointer,
01592                 and will then ask that node to supply bubble/status-line help.
01593                 
01594     Notes:      The base class returns FALSE (i.e. provides no help)
01595                 If you can provide help, then override the base class method to do so.
01596 
01597 ********************************************************************************************/
01598 
01599 BOOL SGDisplayKernelBitmap::GetStatusLineHelp(DocCoord *MousePos, String_256 *Result)
01600 {
01601     ERROR3IF(MousePos == NULL || Result == NULL, "Invalid NULL params");
01602 
01603     String_256 Name;
01604     GetNameText(&Name);
01605 
01606     // "'Bitmapname'"
01607     Result->MakeMsg(_R(IDS_SGBITMAP_STATLINE), (TCHAR *)Name);
01608 
01609     /* Double click, or drag and drop to apply as a fill*/
01610     *Result += String_256(_R(IDS_SGBITMAP_DOUBLE_CLICK)); //"; Double click, or drag and drop to apply this bitmap");
01611 
01612     return(TRUE);
01613 }
01614 
01615 
01616 
01617 
01618 
01619 
01620 
01621 
01622 
01623 
01624 
01625 /********************************************************************************************
01626 
01627 >   BitmapSGallery::BitmapSGallery()
01628                                                  
01629     Author:     Will_Cowling (Xara Group Ltd) <camelotdev@xara.com>
01630     Created:    27/1/95 (base generated in sgbase.cpp)
01631     Purpose:    BitmapSGallery default constructor
01632 
01633 ********************************************************************************************/
01634 
01635 BitmapSGallery::BitmapSGallery()
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 } 
01646 
01647 
01648 
01649 /********************************************************************************************
01650 
01651 >   BitmapSGallery::~BitmapSGallery()
01652 
01653     Author:     Will_Cowling (Xara Group Ltd) <camelotdev@xara.com>
01654     Created:    27/1/95 (base generated in sgbase.cpp)
01655     Purpose:    BitmapSGallery destructor.
01656 
01657 ********************************************************************************************/
01658 
01659 BitmapSGallery::~BitmapSGallery()
01660 {
01661 }
01662 
01663 
01664 
01665 /********************************************************************************************
01666 
01667 >   void BitmapSGallery::CreateNewSubtree(Document *ParentDoc, SGDisplayGroup *ExistingGroup)
01668 
01669     Author:     Will_Cowling (Xara Group Ltd) <camelotdev@xara.com>
01670     Created:    27/1/95 (base generated in sgbase.cpp)
01671 
01672     Inputs:     ParentDoc - The document to create a display subtree for
01673                 ExistingGroup - NULL (creates a new group for this document), or
01674                 a pointer to the existing group-node for this document (in which case
01675                 it clears all displayitems from the group and rebuilds it in place - this
01676                 stops the display group moving around the tree at random!)
01677 
01678     Purpose:    Internal call. This takes the KernelBitmap list of the given document and 
01679                 creates a DisplayTree subtree from it. This subtree is then added to
01680                 the DisplayTree. Note that this does not force a redraw of the list - 
01681                 after making this call, you should also call ForceRedrawOfList
01682 
01683     Notes:      Passing in a NULL parent document pointer results in an ERROR3 -
01684                 the function returns without doing anything in retail builds
01685 
01686     SeeAlso:    SuperGallery::ForceRedrawOfList
01687 
01688 ********************************************************************************************/
01689 
01690 void BitmapSGallery::CreateNewSubtree(Document *ParentDoc, SGDisplayGroup *ExistingGroup)
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 }
01737 
01738 
01739 
01740 /********************************************************************************************
01741 
01742 >   BOOL BitmapSGallery::PreCreate(void)
01743 
01744     Author:     Will_Cowling (Xara Group Ltd) <camelotdev@xara.com>
01745     Created:    27/1/95 (base generated in sgbase.cpp)
01746 
01747     Returns:    TRUE if the Gallery initialised successfully
01748                 FALSE if it should not be opened due to a failure to initialise
01749 
01750     Purpose:    The BitmapSGallery PreCreate handler. This overrides the base class
01751                 PreCreate function. It is called at the very end of the
01752                 SuperGallery::Create method, after the window has been created.
01753 
01754 ********************************************************************************************/
01755 
01756 BOOL BitmapSGallery::PreCreate(void)
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 }
01788 
01789 /********************************************************************************************
01790 
01791 >   void BitmapSGallery::SetSelectionFromDocument(BOOL AlwaysScroll = FALSE)
01792 
01793     Author:     Will_Cowling (Xara Group Ltd) <camelotdev@xara.com>
01794     Created:    30/8/96 (copied from ColourGallery)
01795 
01796     Inputs:     AlwaysScroll - TRUE if you always want to autoscroll, regardless of the
01797                 preference setting. (This is used when opening the gallery, as there is no
01798                 point in not auto-scrolling somewhere useful)
01799 
01800     Purpose:    Sets the bitmap gallery listbox selection state based upon the currently
01801                 selected object(s) in the document.
01802 
01803     Scope:      private
01804 
01805 ********************************************************************************************/
01806 
01807 void BitmapSGallery::SetSelectionFromDocument(BOOL AlwaysScroll)
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 }
01849 
01850 /********************************************************************************************
01851 
01852 >   virtual SGDisplayItem *BitmapSGallery::CopyDisplayItem(SGDisplayItem *SourceItem, 
01853                                     SGDisplayGroup *DestGroup,
01854                                     SGDisplayItem *TargetPosition = NULL)
01855     Author:     Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
01856     Created:    14/3/95
01857 
01858     Inputs:     SourceItem - The item to copy elsewhere in the tree (see below)
01859 
01860                 DestGroup - The group into which the item should be inserted
01861 
01862                 TargetPosition - NULL (to add the copied item to the end of the sibling
01863                 list), or points to an item BEFORE which the copied item will be inserted.
01864 
01865     Returns:    NULL (failed) or a pointer to the new (copied) display item
01866 
01867     Purpose:    "Copies" the existing node in the tree in an appropriate fashion.
01868                 
01869                 This method is normally called when a gallery-organising drag completes,
01870                 and it is discovered that the dragged item(s) have been dragged to a 
01871                 different display group.
01872 
01873     Notes:      This method should be overridden by derived galleries to provide
01874                 appropriate behaviour (some galleries (e.g colour) will copy the real-item
01875                 that the given display-item references to the new group (document), while
01876                 other galleries (layer) may just move the item after all).
01877 
01878                 Note the handy InsertCopiedItem and MoveBefore/After methods which
01879                 are available to take all of the hard work out of copying/moving items!
01880 
01881                 See the body of this method in the source code for example pseudocode.
01882                 For real code, see the Colour Gallery (sgcolour.cpp)
01883 
01884     SeeAlso:    SuperGallery::InsertCopiedItem; SGDisplayItem::MoveBefore;
01885                 SGDisplayItem::MoveAfter; SGColour::CopyDisplayItem
01886 
01887 ********************************************************************************************/
01888 
01889 SGDisplayItem *BitmapSGallery::CopyDisplayItem(SGDisplayItem *SourceItem, 
01890                         SGDisplayGroup *DestGroup, SGDisplayItem *TargetPosition)
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 }
01948 
01949 
01950 
01951 KernelBitmap* BitmapSGallery::GetSelectedBitmap()
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 }
01980 
01981 /********************************************************************************************
01982 
01983 >   virtual BOOL BitmapSGallery::ApplyAction(SGActionType Action)
01984 
01985     Author:     Will_Cowling (Xara Group Ltd) <camelotdev@xara.com>
01986     Created:    27/1/95 (base generated in sgbase.cpp)
01987 
01988     Inputs:     Action - Indicates what action to apply
01989 
01990     Returns:    TRUE to indicate successful handling of the action, or
01991                 FALSE to indicate failure (NOTE that this is not necessarily an error, but
01992                 may simply be that we don't support the given action. e.g. if we don't
01993                 handle APPLYADJUST, we'll be called again with a normal APPLY call)
01994 
01995     Purpose:    Applies certain conventional gallery actions (usually associated with
01996                 gallery buttons, for new, edit, delete, etc)
01997 
01998     SeeAlso:    SGActionType
01999 
02000 ********************************************************************************************/
02001 
02002 BOOL BitmapSGallery::ApplyAction(SGActionType Action)
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 }
02073 
02074 /********************************************************************************************
02075 
02076 >   BOOL BitmapSGallery::DeleteSelection()
02077 
02078     Author:     Will_Cowling (Xara Group Ltd) <camelotdev@xara.com>
02079     Created:    16/2/95
02080     Purpose:    Deletes the selected bitmaps.
02081 
02082 ********************************************************************************************/
02083 
02084 BOOL BitmapSGallery::DeleteSelection()
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 }
02172 
02173 /********************************************************************************************
02174 
02175 >   KernelBitmap* BitmapSGallery::CheckTextureBitmap(KernelBitmap* pBitmap)
02176 
02177     Author:     Will_Cowling (Xara Group Ltd) <camelotdev@xara.com>
02178     Created:    16/2/95
02179     Purpose:    Checks a bitmap to see if can be applied as a texture,
02180                 and gives the option to create a grey level version if not.
02181 
02182 ********************************************************************************************/
02183 
02184 KernelBitmap* BitmapSGallery::CheckTextureBitmap(KernelBitmap* pBitmap)
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 }
02269 
02270 /********************************************************************************************
02271 
02272 >   virtual void BitmapSGallery::SelectionHasChanged(void);
02273 
02274     Author:     Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
02275     Created:    27/1/95
02276 
02277     Purpose:    To inform the gallery that the selection has changed in some way.
02278                 The base gallery class will do the following things:
02279 
02280                 MonoOn
02281                 - If the selection is not exactly one item, the following standard
02282                 buttons are shaded:
02283                     Apply, Redefine, Edit
02284 
02285                 - If the selection is greater than 1 item, the New button will shade
02286 
02287                 - If the selection is zero items, then the Delete button will shade
02288                 MonoOff
02289 
02290     Notes:      If this default action is unsuitable, derived galleries may override it.
02291                 If they add their own special buttons, they may need to override this
02292                 method to ensure that their buttons also behave correctly on sel change.
02293 
02294                 This method is called after creation of the window (immediately after
02295                 the PostCreate upcall) to ensure the window state is correct
02296 
02297 ********************************************************************************************/
02298 
02299 void BitmapSGallery::SelectionHasChanged(void)
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 }
02344 
02345 /***********************************************************************************************
02346 
02347 >   void BitmapSGallery::DoShadeGallery(BOOL ShadeIt)
02348 
02349     Author:     Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
02350     Created:    4/7/97
02351     Inputs:     ShadeIt -   TRUE if the gallery is being shaded
02352                             FALSE if the gallery is being unshaded
02353     Purpose:    Called by the base class whenever the shaded status of the gallery
02354                 is changed, to allow derived galleries to shade/unshade any extra
02355                 controls that they provide in the window. ONLY called if the gallery
02356                 is actually open/visible.
02357 
02358     Notes:      Need not be overridden - the default action is to do nothing extra
02359                 to the normal shade/unshade operation.
02360     SeeAlso:    Gallery::ShadeGallery; Gallery::UnshadeGallery
02361 
02362 ***********************************************************************************************/
02363 
02364 void BitmapSGallery::DoShadeGallery(BOOL ShadeIt)
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 }
02387 
02388 /********************************************************************************************
02389 
02390 >   virtual MsgResult BitmapSGallery::Message(Msg* Message)
02391 
02392     Author:     Will_Cowling (Xara Group Ltd) <camelotdev@xara.com>
02393     Created:    27/1/95 (base generated in sgbase.cpp)
02394     Inputs:     Message - The message to handle
02395 
02396     Purpose:    A standard message handler, really.
02397 
02398     Notes:      Any messages that this does not handle must be passed down to the
02399                 SuperGallery base class message handler.
02400 
02401                 NOTE WELL that the SuperGallery base class handler does some funky things
02402                 for us - see SuperGallery::Message - such as deleting our display subtree
02403                 for any document which dies (which, uncannily, would explain why they go
02404                 away like that when you close documents ;-), and shading the gallery when
02405                 there are no documents present. [To override this behaviour in these cases,
02406                 you should respond to the message, and return OK rather than calling the
02407                 base class message handler]
02408 
02409     SeeAlso:    SuperGallery::Message
02410 
02411 ********************************************************************************************/
02412 
02413 MsgResult BitmapSGallery::Message(Msg* Message)
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 }    
02839 
02840 
02841 /********************************************************************************************
02842 
02843 >   virtual void BitmapSGallery::HandleDragStart(DragMessage *DragMsg)
02844 
02845     Author:     Will_Cowling (Xara Group Ltd) <camelotdev@xara.com>
02846     Created:    25/3/95
02847 
02848     Inputs:     DragMsg - The DRAGSTARTED message that we've just recieved, indicating
02849                 the type of drag being started
02850 
02851     Purpose:    Checks a DragMessage to see if it is a bitmap drag.
02852                 If it is, then it creates a drag target for this gallerys listbox.
02853 
02854     Notes:      Overrides the default base-class action. Calls down to the base class
02855                 if it is not a colour drag, so that dragging of gallery groups is allowed
02856 
02857 ********************************************************************************************/
02858 
02859 void BitmapSGallery::HandleDragStart(DragMessage *DragMsg)
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 }
02868 
02869 
02870 
02871 /********************************************************************************************
02872 
02873 >   BOOL BitmapSGallery::FindCentreInsertionPosition(Spread** Spread, DocCoord* Position)
02874 
02875     Author:     Simon_Maneggio (Xara Group Ltd) <camelotdev@xara.com>
02876     Created:    28/7/94
02877     Inputs:     -
02878     Outputs:    Spread:  The spread to place the clipboard objects on
02879                 Position:The centre of the view (Spread coords)
02880     Returns:    -
02881     Purpose:    Finds the centre insertion position for clipboard objects
02882     Errors:     -
02883     Scope:      private
02884     SeeAlso:    -
02885 
02886 ********************************************************************************************/
02887 
02888 BOOL BitmapSGallery::FindCentreInsertionPosition(Spread** Spread, DocCoord* Position)
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 }
02953 
02954 
02955 /********************************************************************************************
02956 
02957 >   virtual RenderRegion *BitmapSGallery::CreateRenderRegion(DocRect *VirtualSize,
02958                                                             ReDrawInfoType *DlgRedrawInfo)
02959 
02960     Author:     Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
02961     Created:    29/3/95
02962 
02963     Purpose:    An overridable veneer to the DialogOp CreateOSRenderRegion method.
02964                 This can be overriden to use a different type of renderregion for
02965                 all of your rendering.
02966 
02967                 If you override this, you MUST also override DestroyRenderRegion!
02968 
02969     SeeAlso:    SuperGallery::DestroyRenderRegion
02970 
02971 ********************************************************************************************/
02972 
02973 RenderRegion *BitmapSGallery::CreateRenderRegion(DocRect *VirtualSize, ReDrawInfoType *DlgRedrawInfo)
02974 {
02975     return(CreateOSRenderRegion(VirtualSize, DlgRedrawInfo));
02976 }
02977 
02978 
02979 
02980 /********************************************************************************************
02981 
02982 >   virtual void BitmapSGallery::DestroyRenderRegion(RenderRegion *pRender)
02983 
02984     Author:     Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
02985     Created:    29/3/95
02986 
02987     Purpose:    An overridable veneer to the DialogOp DestroyOSRenderRegion method.
02988                 This can be overriden to use a different type of renderregion for
02989                 all of your rendering.
02990 
02991                 If you override this, you MUST also override CreateRenderRegion!
02992 
02993     SeeAlso:    SuperGallery::CreateRenderRegion
02994 
02995 ********************************************************************************************/
02996 
02997 void BitmapSGallery::DestroyRenderRegion(RenderRegion *pRender)
02998 {
02999     DestroyOSRenderRegion(pRender);
03000 }
03001 
03002 
03003 /********************************************************************************************
03004 
03005 >   virtual BOOL BitmapSGallery::PreContextMenu(void)
03006                                                  
03007     Author:     Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
03008     Created:    28/10/97
03009     Returns:    TRUE for success
03010     Purpose:    Give the gallery a chance to do something before popping up the context menu.
03011                 Called before the context menu is popped up on a right click.
03012                 At present, used by the bitmap gallery to ensure that the plug-ins have all
03013                 been parsed.
03014 
03015 ********************************************************************************************/
03016 
03017 BOOL BitmapSGallery::PreContextMenu(void)
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 }
03033 
03034 /********************************************************************************************
03035 
03036 >   virtual BOOL BitmapSGallery::InitMenuCommands(void)
03037                                                  
03038     Author:     Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
03039     Created:    18/9/95
03040 
03041     Returns:    TRUE for success
03042 
03043     Purpose:    Initialises any menu commands that this gallery needs.
03044 
03045     Notes:      Will only create the menu commands once - further calls in the future
03046                 will return TRUE immediately without doing anything.
03047 
03048 ********************************************************************************************/
03049 
03050 BOOL BitmapSGallery::InitMenuCommands(void)
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 }
03101 
03102 
03103 
03104 /********************************************************************************************
03105 
03106 >   virtual BOOL BitmapSGallery::BuildCommandMenu(GalleryContextMenu *TheMenu, SGMenuID MenuID)
03107 
03108     Author:     Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
03109     Created:    15/9/95
03110 
03111     Inputs:     TheMenu - The menu to add commands to
03112                 MenuID  - The type of menu (over-list or from-options-button) to create
03113 
03114     Returns:    TRUE if it succeeded
03115 
03116     Purpose:    To build a menu of commands to be popped up over the gallery.
03117     
03118     Notes:      Override this method to stop the default menus being built
03119 
03120 ********************************************************************************************/
03121 
03122 BOOL BitmapSGallery::BuildCommandMenu(GalleryContextMenu *TheMenu, SGMenuID MenuID)
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 }
03191 
03192 
03193 
03194 /********************************************************************************************
03195 
03196 >   virtual OpState BitmapSGallery::GetCommandState(StringBase *CommandID, String_256 *ShadeReason)
03197 
03198     Author:     Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
03199     Created:    15/9/95
03200 
03201     Inputs:     CommandID - TheString ID of the command
03202     Outputs:    ShadeReason - If you return (OpState.Greyed == TRUE) then this should be filled
03203                 in with the reason that the item is shaded/greyed.
03204 
03205     Returns:    An OpState indicating the current menu item state.
03206 
03207     Purpose:    To determine the state of a given menu item. This method is an exact
03208                 parallel to an Op's GetState method (in fact, it is called by an Op's GetState)
03209     
03210     Notes:      Override this method to provide state info for your special commands
03211                 Call the base class for unknown commands to allow it to handle them for you
03212 
03213                 The base class handles all of these (maybe more - see the base class help)
03214                     Properties, Sort, Find;
03215                     New, Edit, Delete, Redefine;
03216                     NextGroup, PrevGroup, FoldGroup, UnfoldGroup;
03217 
03218 ********************************************************************************************/
03219 
03220 OpState BitmapSGallery::GetCommandState(StringBase *CommandID, String_256 *ShadeReason)
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 }
03291 
03292 
03293 
03294 /********************************************************************************************
03295 
03296 >   virtual void BitmapSGallery::DoCommand(StringBase *CommandID)
03297 
03298     Author:     Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
03299     Created:    15/9/95
03300 
03301     Inputs:     CommandID - The String ID of the command
03302 
03303     Purpose:    To apply a given command when it is chosen from the menu.
03304     
03305     Notes:      Override this method to provide handling for your special commands.
03306                 Call the base class if you don't recognise the command, so that it can
03307                 handle standard commands.
03308 
03309                 The base class handles all of these (maybe more - see the base class help)
03310                     Properties, Sort, Find;
03311                     New, Edit, Delete, Redefine; (it calls ApplyAction as appropriate)
03312                     NextGroup, PrevGroup, FoldGroup, UnfoldGroup;
03313 
03314 ********************************************************************************************/
03315 
03316 void BitmapSGallery::DoCommand(StringBase *CommandID)
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 }
03399 
03400 
03401 
03402 
03403 
03404 
03405 
03406 //-----------------------------------------------------------------------------------------------
03407 
03408 // OpDisplayBitmapGallery - the operation that is used to display the bitmap gallery
03409 
03410 /********************************************************************************************
03411 
03412 >   BOOL OpDisplayBitmapGallery::Init()
03413 
03414     Author:     Will_Cowling (Xara Group Ltd) <camelotdev@xara.com>
03415     Created:    31/1/95
03416     Inputs:     -
03417     Outputs:    -
03418     Returns:    TRUE if the operation could be successfully initialised 
03419                 FALSE if no more memory could be allocated 
03420                 
03421     Purpose:    OpDisplayBitmapGallery initialiser method
03422     Errors:     ERROR will be called if there was insufficient memory to allocate the 
03423                 operation.
03424     SeeAlso:    -
03425 
03426 ********************************************************************************************/
03427 
03428 BOOL OpDisplayBitmapGallery::Init()
03429 {
03430     return (
03431             RegisterOpDescriptor(
03432                                 0,
03433                                 _R(IDS_DISPLAY_BITMAP_GALLERY),
03434                                 CC_RUNTIME_CLASS(OpDisplayBitmapGallery),
03435                                 OPTOKEN_DISPLAYBITMAPGALLERY,
03436                                 OpDisplayBitmapGallery::GetState,
03437                                 0,  /* help ID */
03438                                 _R(IDBBL_DISPLAY_BITMAP_GALLERY),
03439                                 _R(IDC_BTN_SGBITMAP), // UINT32 resourceID = 0, // resource ID
03440                                 _R(IDC_BTN_SGBITMAP), // UINT32 controlID = 0,  // control ID
03441                                 SYSTEMBAR_ILLEGAL,    // SystemBarType GroupBarID = SYSTEMBAR_ILLEGAL,  // group bar ID
03442                                 TRUE,     // BOOL ReceiveMessages = TRUE,   // BODGE
03443                                 FALSE,    // BOOL Smart = FALSE,
03444                                 TRUE,     // BOOL Clean = TRUE,   
03445                                 NULL,     // OpDescriptor *pVertOpDesc = NULL,
03446                                 0,    // UINT32 OneOpenInstID = 0,      
03447                                 0,    // UINT32 AutoStateFlags = 0,
03448                                 TRUE      // BOOL fCheckable = FALSE
03449                                 )
03450             
03451 PORTNOTE("other", "Removed BitmapExportPreviewDialog")
03452 #ifndef EXCLUDE_FROM_XARALX
03453 //#if _DEBUG
03454             && BitmapExportPreviewDialog::Init()
03455 //#endif
03456 #endif
03457             && PreviewDialog::Init()
03458             );
03459 }               
03460     
03461 /********************************************************************************************
03462 
03463 >   OpState OpDisplayBitmapGallery::GetState(String_256*, OpDescriptor*)
03464 
03465     Author:     Will_Cowling (Xara Group Ltd) <camelotdev@xara.com>
03466     Created:    31/1/95
03467     Inputs:     -
03468     Outputs:    -
03469     Returns:    The state of the OpDisplayBitmapGallery operation
03470     Purpose:    For finding the OpDisplayBitmapGallery's state. 
03471     Errors:     -
03472     SeeAlso:    -
03473 
03474 ********************************************************************************************/
03475 
03476 OpState OpDisplayBitmapGallery::GetState(String_256* UIDescription, OpDescriptor*)
03477 {
03478     OpState OpSt;
03479 
03480     // If the gallery is currenty open, then the menu item should be ticked
03481     SuperGallery* pSuperGallery = SuperGallery::FindSuperGallery(_R(IDD_BITMAPSGALLERY));
03482 
03483     if (pSuperGallery != NULL)
03484     {
03485         if (pSuperGallery->GetRuntimeClass() == CC_RUNTIME_CLASS(BitmapSGallery))
03486             OpSt.Ticked = pSuperGallery->IsVisible();
03487     }
03488 
03489     // If there are no open documents, you can't toggle the gallery
03490     OpSt.Greyed = (Document::GetSelected() == NULL);
03491 
03492     return(OpSt);
03493 }
03494 
03495 /********************************************************************************************
03496 
03497 >   void OpDisplayBitmapGallery::Do(OpDescriptor*)
03498 
03499     Author:     Will_Cowling (Xara Group Ltd) <camelotdev@xara.com>
03500     Created:    31/1/95
03501     Inputs:     -
03502     Outputs:    -
03503     Returns:    -
03504     Purpose:    Displays the bitmap gallery
03505     Errors:     -
03506     SeeAlso:    -
03507 
03508 ********************************************************************************************/
03509 
03510 void OpDisplayBitmapGallery::Do(OpDescriptor*)
03511 {
03512     SuperGallery* pSuperGallery = SuperGallery::FindSuperGallery(_R(IDD_BITMAPSGALLERY));
03513 
03514     if (!pSuperGallery)
03515         pSuperGallery = new BitmapSGallery();
03516 
03517     if (pSuperGallery != NULL)
03518     {
03519         if (pSuperGallery->GetRuntimeClass() == CC_RUNTIME_CLASS(BitmapSGallery))
03520         {
03521             // Toggle the visibility of the gallery window
03522             pSuperGallery->SetVisibility( !pSuperGallery->IsVisible() );
03523 
03524             // And update the gallery button state
03525             SGInit::UpdateGalleryButton(_R(OPTOKEN_DISPLAYBITMAPGALLERY),
03526                                         pSuperGallery->IsVisible());
03527         }
03528 #if _DEBUG
03529         else
03530             ERROR3("The Bitmap Gallery isn't a BitmapSGallery! Woss goin' on?");
03531 #endif
03532     }
03533 
03534     ERROR3IF(pSuperGallery == NULL,"Couldn't find the bitmap gallery bar");
03535 
03536     End();
03537 }
03538 
03539 
03540 
03541 /********************************************************************************************
03542 >   BOOL BitmapSGallery::GetSelectedBitmaps(KernelBitmap** pOutputArray, UINT32* pOutputCount)
03543 
03544     Author:     Peter_Arnold (Xara Group Ltd) <camelotdev@xara.com>
03545     Created:    11/6/96
03546     Inputs:     see Outputs
03547     Outputs:    pOutputArray - list of selected KernelBitmaps
03548                 pOutputCount - the length of the list
03549     Returns:    TRUE/FALSE for success/error
03550     Purpose:    Generates a list of all the selected bitmaps in the gallery.  Note that the
03551                 generated array becomes the callers responsibility if TRUE is returned; the
03552                 caller must CCFree it.
03553     SeeAlso:    BitmapSGallery::GetSelectedBitmap
03554 ********************************************************************************************/
03555 BOOL BitmapSGallery::GetSelectedBitmaps(KernelBitmap*** pOutputArray, UINT32* pOutputCount)
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 }
03616 
03617 
03618 
03619 
03620 /********************************************************************************************
03621 
03622     BOOL BitmapSGallery::GetBmpInfo(BmpDlgPara Param)
03623 
03624     Author:     Ranbir_Rana (Xara Group Ltd) <camelotdev@xara.com>
03625     Created:    05/01/96
03626     Inputs:     Param - Allows the transfer of data to and from the bitmap poperties dialog.
03627     Outputs:    -
03628     Returns:    TRUE if Successful, else FALSE. 
03629     Purpose:    Retrieves inforamtion from Bitmaps selected in the Bitmaps Gallery.
03630     SeeAlso:    -
03631 
03632 ********************************************************************************************/
03633 
03634 BOOL BitmapSGallery::GetBmpInfo(BmpDlgParam* Param)
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 }
03865 
03866 /*************************************************************************************************
03867 
03868 >   BOOL BitmapSGallery::SetBmpInfo(BmpDlgPara* Param)
03869 
03870     Author:     Ranbir_Rana (Xara Group Ltd) <camelotdev@xara.com>
03871     Created:    05/01/96
03872     Inputs:     Param - Allows the transfer of data to and from the bitmap poperties dialog.   
03873     Outputs:    -
03874     Returns:    TRUE if Successful, FALSE otherwise.
03875     Purpose:    Stores info, retrieved from the Bitmap Properties Dialog, in an OILBitmap.
03876     SeeAlso:    -
03877 
03878 **************************************************************************************************/
03879 
03880 BOOL BitmapSGallery::SetBmpInfo(BmpDlgParam* Param)
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 }
03954 
03955 
03956 /************************************************************************************************************
03957 
03958 >   BOOL BitmapSGallery::IsJPEG()
03959 
03960     Author:     Ranbir_Rana (Xara Group Ltd) <camelotdev@xara.com>
03961     Created:    05/01/96
03962     Inputs:     pList    - A ptr to a Kernel bitmap. 
03963                 ListSize - The number of bitmaps selected in the bitmap gallery. 
03964                 Param    - Allows data to be passed to and from the bitmap properties dialog.
03965                 pBytes   - If it is a JPEG, the memory (bytes), is returned to the caller. 
03966     Outputs:    -
03967     Returns:    True if the selected bitmap is a compressed JPEG, false otherwise
03968     Purpose:    To determine whether an imported bitmap is a compressed JPEG.
03969     SeeAlso:    -
03970 
03971 ***************************************************************************************************************/
03972 
03973 BOOL BitmapSGallery::IsJPEG(KernelBitmap** pList,UINT32 ListSize, BmpDlgParam* Param, INT32* pBytes)
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 }
04004 
04005 /******************************************************************************************
04006 
04007     BOOL BitmapSGallery::AreDelayValuesSame ()
04008 
04009     Author:     Ranbir_Rana (Xara Group Ltd) <camelotdev@xara.com>
04010     Created:    05/01/96
04011     Inputs:     -
04012     Outputs:    -
04013     Returns:    TRUE if values are the same , FALSE otherwise.
04014     Purpose:    To find if the Animation delay values of selected Bitmaps are the same.
04015     SeeAlso:    -
04016 
04017 ********************************************************************************************/
04018 /*
04019 BOOL BitmapSGallery::AreDelayValuesSame()
04020 {
04021 
04022     
04023     UINT32 ListSize = 0;                
04024     KernelBitmap** pList = NULL;    
04025     BOOL DelayValuesDiffer = FALSE;
04026     UINT32 i =0;
04027     UINT32 e=0;
04028     UINT32 Value =0;
04029     
04030     if (!GetSelectedBitmaps(&pList, &ListSize))
04031         return FALSE;
04032 
04033     UINT32 TempListSize = ListSize;
04034     UINT32* Delay = new UINT32[ListSize];
04035 
04036     if (!Delay)
04037         return FALSE;
04038 
04039     // Get each bitmaps delay value
04040     while (ListSize>0)
04041     {
04042         ListSize--;
04043         Value = pList[ListSize]->GetDelay();
04044         Delay[i] = Value;
04045         i++;
04046     }
04047 
04048     // Compare the values.      
04049     for(i=0; i<TempListSize; i++)
04050     {
04051         for(UINT32 e=0; e<TempListSize; e++)
04052         {
04053             if (Delay[i] != Delay[e])
04054                 return FALSE;
04055         }
04056     }
04057 
04058     if (ListSize != NULL)
04059         CCFree(pList);
04060         delete [] Delay;
04061 
04062     return TRUE;
04063 }
04064 */
04065 /********************************************************************************************
04066 >   UINT32 BitmapSGallery::GetBitmapAnimDelay()
04067 
04068     Author:     Ranbir_Rana (Xara Group Ltd) <camelotdev@xara.com>
04069     Created:    05/01/96
04070     Inputs:      
04071     Outputs:    -
04072     Returns:    The Delay value stored in a Bitmap.
04073     Purpose:    
04074     SeeAlso:    -
04075 ********************************************************************************************/
04076 /*
04077 UINT32 BitmapSGallery::GetBitmapDelay()
04078 {
04079     UINT32 ListSize = 0;
04080     KernelBitmap** pList = NULL;    
04081     UINT32 i =0;
04082     
04083     if (!GetSelectedBitmaps(&pList, &ListSize))
04084         InformError();
04085 
04086     return  pList[i]->GetActualBitmap()->GetBitmapAnimDelay();
04087 }
04088 */
04089 
04090 
04091 

Generated on Sat Nov 10 03:46:50 2007 for Camelot by  doxygen 1.4.4