expbmp.cpp

Go to the documentation of this file.
00001 // $Id: expbmp.cpp 1282 2006-06-09 09:46:49Z alex $
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 
00099 // Encapsulates a set of bitmaps exported to a file.
00100 
00101 /*
00102 */
00103 
00104 #include "camtypes.h"
00105 
00106 #include "expbmp.h"
00107 //#include "bitmap.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00108 
00109 DECLARE_SOURCE("$Revision: 1282 $");
00110 
00111 CC_IMPLEMENT_MEMDUMP(ExportBitmap, ListItem)
00112 CC_IMPLEMENT_MEMDUMP(ExportBitmapList, List)
00113 CC_IMPLEMENT_MEMDUMP(ExportedBitmaps, CCObject)
00114 
00115 #define new CAM_DEBUG_NEW
00116 
00117 /********************************************************************************************
00118 
00119 >   ExportBitmap::ExportBitmap(KernelBitmap *pNewBmp, INT32 NewRecordNumber)
00120 
00121     Author:     Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
00122     Created:    11/6/96
00123     Inputs:     pNewBmp         - the Bitmap to put in the list.
00124                 RecordNumber    - the number of the record that this Bitmap definition has been
00125                                   saved in.
00126     Purpose:    Create a new export Bitmap list item from the given indexed Bitmap.
00127     SeeAlso:    ExportBitmapList;
00128 
00129 ********************************************************************************************/
00130 
00131 ExportBitmap::ExportBitmap(KernelBitmap *pNewBmp, INT32 NewRecordNumber)
00132 {
00133     ERROR3IF(pNewBmp->HasBeenDeleted(), "Trying to export a deleted bitmap");
00134 
00135     // Initialise our class variables to these specified values.
00136     pBmp = pNewBmp;
00137     RecordNumber = NewRecordNumber;
00138 }
00139 
00140 /********************************************************************************************
00141 
00142 >   ExportBitmapList::~ExportBitmapList()
00143 
00144     Author:     Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
00145     Created:    11/6/96
00146     Inputs:     -
00147     Outputs:    -
00148     Returns:    -
00149     Purpose:    Destroy the list of exported Bitmaps.
00150     SeeAlso:    ExportedBitmaps
00151 
00152 ********************************************************************************************/
00153 
00154 ExportBitmapList::~ExportBitmapList()
00155 {
00156     // Destroy the list of Bitmaps which we may have
00157     //ExportBitmap* pExportedBitmap = (ExportBitmap *)GetHead();
00158     //while (pExportedBitmap)
00159     //{
00160     //  delete pExportedBitmap;
00161 
00162         // Try the next Bitmap in the list
00163 //      pExportedBitmap = (ExportBitmap *)Bitmaps.GetNext(pExportedBitmap);
00164 //  }
00165     
00166     DeleteAll();
00167 }
00168 
00169 /********************************************************************************************
00170 
00171 >   ExportBitmap *ExportBitmapList::AddBitmap(KernelBitmap *pBmp, INT32 NewRecordNumber)
00172 
00173     Author:     Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
00174     Created:    11/6/96
00175     Inputs:     pNewBmp         - the Bitmap to put in the list.
00176                 RecordNumber    - the number of the record that this Bitmap definition has been
00177                                   saved in.
00178     Returns:    Pointer to the newly added Bitmap, or 
00179                 NULL if out of memory => ERROR1
00180     Purpose:    Add a new Bitmap to the list of exported Bitmaps.
00181     Errors:     Out of memory => ERROR1
00182     SeeAlso:    ExportBitmap
00183 
00184 ********************************************************************************************/
00185 
00186 ExportBitmap *ExportBitmapList::AddBitmap(KernelBitmap *pBmp, INT32 NewRecordNumber)
00187 {
00188     ERROR2IF(pBmp->HasBeenDeleted(), NULL, "Trying to add a deleted bitmap to the export list");
00189 
00190     ExportBitmap *pNewBmp = new ExportBitmap(pBmp, NewRecordNumber);
00191 
00192     // Check for out of memory
00193     if (pNewBmp == NULL)
00194         return NULL;
00195 
00196     // Add to the list and return success
00197     AddTail(pNewBmp);
00198     return pNewBmp;
00199 }
00200 
00201 /********************************************************************************************
00202 
00203 >   ExportedBitmaps::ExportedBitmaps()
00204 
00205     Author:     Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
00206     Created:    23/5/96
00207     Inputs:     -
00208     Outputs:    -
00209     Returns:    -
00210     Purpose:    Construct the class which encapsulates a list of exported Bitmaps.
00211     SeeAlso:    ExportedBitmaps
00212 
00213 ********************************************************************************************/
00214 
00215 ExportedBitmaps::ExportedBitmaps()
00216 {
00217 }
00218 
00219 /********************************************************************************************
00220 
00221 >   ExportedBitmaps::~ExportedBitmaps()
00222 
00223     Author:     Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
00224     Created:    11/6/96
00225     Inputs:     -
00226     Outputs:    -
00227     Returns:    -
00228     Purpose:    Destroy the class which encapsulates a list of exported Bitmaps.
00229     SeeAlso:    ExportedBitmaps
00230 
00231 ********************************************************************************************/
00232 
00233 ExportedBitmaps::~ExportedBitmaps()
00234 {
00235 }
00236 
00237 /********************************************************************************************
00238 
00239 >   BOOL ExportedBitmaps::AddBitmap(KernelBitmap *pBmp, INT32 RecordNumber)
00240 
00241     Author:     Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
00242     Created:    11/6/96
00243     Inputs:     pNewBmp         - the Bitmap to put in the list.
00244                 RecordNumber    - the number of the record that this Bitmap definition has been
00245                                   saved in.
00246     Returns:    TRUE if the Bitmap could be added;
00247                 FALSE if not
00248     Purpose:    Add the specified Bitmap to the list of already exported Bitmaps.
00249     Errors:     -
00250     SeeAlso:    ExportBitmapList;
00251 
00252 ********************************************************************************************/
00253 
00254 BOOL ExportedBitmaps::AddBitmap(KernelBitmap *pBmp, INT32 RecordNumber)
00255 {
00256     ERROR2IF(pBmp->HasBeenDeleted(), FALSE, "Trying to add a deleted bitmap to the export list");
00257 
00258     // Add the Bitmap onto our list
00259     ExportBitmap * pNewBmp = Bitmaps.AddBitmap(pBmp, RecordNumber);
00260     if (pNewBmp)
00261         return TRUE;
00262     
00263     return FALSE;
00264 }
00265 
00266 /********************************************************************************************
00267 
00268 >   ExportBitmap *ExportedBitmaps::GetBitmap(KernelBitmap *pSearchBmp)
00269 
00270     Author:     Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
00271     Created:    11/6/96
00272     Inputs:     pSearchBmp          - the Bitmap to search for in the list.
00273     Returns:    if the item is found then returns       - Pointer to the exported Bitmap list item
00274                 if the item is not found then returns   - NULL.
00275     Purpose:    Find an indexed Bitmap in the exported list.
00276     SeeAlso:    ExportBitmapList
00277 
00278 ********************************************************************************************/
00279 
00280 ExportBitmap *ExportedBitmaps::GetBitmap(KernelBitmap *pSearchBmp)
00281 {
00282     if (pSearchBmp == NULL)
00283     {
00284         ERROR3("ExportedBitmaps::GetBitmap - searching for a null indexed Bitmap!");
00285     }
00286 
00287     ERROR2IF(pSearchBmp->HasBeenDeleted(), NULL, "Why am I looking for a deleted bitmap ?");
00288 
00289     ExportBitmap* pExportedBitmap = (ExportBitmap *)Bitmaps.GetHead();
00290     while (pExportedBitmap)
00291     {
00292         // Compare the indexed Bitmap pointers and return the match if they are the same
00293         if (pExportedBitmap->pBmp == pSearchBmp)
00294             return pExportedBitmap;
00295         
00296         // Try the next Bitmap in the list
00297         pExportedBitmap = (ExportBitmap *)Bitmaps.GetNext(pExportedBitmap);
00298     }
00299 
00300     // No - return failure.
00301     return NULL;
00302 }
00303 
00304 
00305 /********************************************************************************************
00306 
00307 >   ExportBitmap* ExportedBitmaps::EnumerateBitmaps(ExportBitmap* pExpBmp)
00308 
00309     Author:     Will_Cowling (Xara Group Ltd) <camelotdev@xara.com>
00310     Created:    16/8/96
00311     Inputs:     -
00312     Returns:    if the item is found then returns       - Pointer to the exported Bitmap list item
00313                 if the item is not found then returns   - NULL.
00314     Purpose:    -
00315     SeeAlso:    ExportBitmapList
00316 
00317 ********************************************************************************************/
00318 
00319 ExportBitmap* ExportedBitmaps::EnumerateBitmaps(ExportBitmap* pExpBmp)
00320 {
00321     if (pExpBmp == NULL)
00322         return (ExportBitmap *)Bitmaps.GetHead();
00323 
00324     return (ExportBitmap *)Bitmaps.GetNext(pExpBmp);
00325 }

Generated on Sat Nov 10 03:45:07 2007 for Camelot by  doxygen 1.4.4