expcol.cpp

Go to the documentation of this file.
00001 // $Id: expcol.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 colours exported to a file.
00100 
00101 /*
00102 */
00103 
00104 #include "camtypes.h"
00105 
00106 #include "expcol.h"
00107 #include "colourix.h"
00108 //#include "colmodel.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00109 
00110 DECLARE_SOURCE("$Revision: 1282 $");
00111 
00112 CC_IMPLEMENT_MEMDUMP(ExportColour, ListItem)
00113 CC_IMPLEMENT_MEMDUMP(ExportColourList, List)
00114 CC_IMPLEMENT_MEMDUMP(ExportedColours, CCObject)
00115 
00116 #define new CAM_DEBUG_NEW
00117 
00118 /********************************************************************************************
00119 
00120 >   ExportColour::ExportColour(IndexedColour *pNewCol, INT32 NewRecordNumber)
00121 
00122     Author:     Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
00123     Created:    23/5/96
00124     Inputs:     pNewCol         - the colour to put in the list.
00125                 RecordNumber    - the number of the record that this colour definition has been
00126                                   saved in.
00127     Purpose:    Create a new export colour list item from the given indexed colour.
00128     SeeAlso:    ExportColourList;
00129 
00130 ********************************************************************************************/
00131 
00132 ExportColour::ExportColour(IndexedColour *pNewCol, INT32 NewRecordNumber)
00133 {
00134     // Initialise our class variables to these specified values.
00135     pCol = pNewCol;
00136     RecordNumber = NewRecordNumber;
00137 }
00138 
00139 /********************************************************************************************
00140 
00141 >   ExportColour::ExportColour(PColourRGBT *pNewRGBCol, INT32 NewRecordNumber)
00142 
00143     Author:     Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
00144     Created:    3/6/96
00145     Inputs:     pNewRGBCol      - the simple RGB colour to put in the list.
00146                 RecordNumber    - the number of the record that this colour definition has been
00147                                   saved in.
00148     Purpose:    Create a new export colour list item from the given indexed colour.
00149     SeeAlso:    ExportColourList;
00150 
00151 ********************************************************************************************/
00152 
00153 ExportColour::ExportColour(PColourRGBT *pNewRGBCol, INT32 NewRecordNumber)
00154 {
00155     // Initialise our class variables to these specified values.
00156     // Indexed colour is NULL, which means use the simple colour in searching
00157     pCol = NULL;
00158     SimpleRGBColour = *pNewRGBCol;
00159     RecordNumber = NewRecordNumber;
00160 }
00161 
00162 /********************************************************************************************
00163 
00164 >   ExportColourList::~ExportColourList()
00165 
00166     Author:     Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
00167     Created:    23/5/96
00168     Inputs:     -
00169     Outputs:    -
00170     Returns:    -
00171     Purpose:    Destroy the list of exported colours.
00172     SeeAlso:    ExportedColours
00173 
00174 ********************************************************************************************/
00175 
00176 ExportColourList::~ExportColourList()
00177 {
00178     // Destroy the list of colours which we may have
00179     //ExportColour* pExportedColour = (ExportColour *)GetHead();
00180     //while (pExportedColour)
00181     //{
00182     //  delete pExportedColour;
00183 
00184         // Try the next colour in the list
00185 //      pExportedColour = (ExportColour *)Colours.GetNext(pExportedColour);
00186 //  }
00187     
00188     DeleteAll();
00189 }
00190 
00191 /********************************************************************************************
00192 
00193 >   ExportColour *ExportColourList::AddColour(IndexedColour *pCol, INT32 NewRecordNumber)
00194 
00195     Author:     Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
00196     Created:    23/5/96
00197     Inputs:     pNewCol         - the colour to put in the list.
00198                 RecordNumber    - the number of the record that this colour definition has been
00199                                   saved in.
00200     Returns:    Pointer to the newly added colour, or 
00201                 NULL if out of memory => ERROR1
00202     Purpose:    Add a new colour to the list of exported colours.
00203     Errors:     Out of memory => ERROR1
00204     SeeAlso:    ExportColour
00205 
00206 ********************************************************************************************/
00207 
00208 ExportColour *ExportColourList::AddColour(IndexedColour *pCol, INT32 NewRecordNumber)
00209 {
00210     ExportColour *pNewCol = new ExportColour(pCol, NewRecordNumber);
00211 
00212     // Check for out of memory
00213     if (pNewCol == NULL)
00214         return NULL;
00215 
00216     // Add to the list and return success
00217     AddTail(pNewCol);
00218     return pNewCol;
00219 }
00220 
00221 /********************************************************************************************
00222 
00223 >   ExportColour *ExportColourList::AddColour(PColourRGBT *pNewRGBCol, INT32 NewRecordNumber)
00224 
00225     Author:     Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
00226     Created:    3/6/96
00227     Inputs:     pNewRGBCol      - the simple RGB colour to put in the list.
00228                 RecordNumber    - the number of the record that this colour definition has been
00229                                   saved in.
00230     Returns:    Pointer to the newly added colour, or 
00231                 NULL if out of memory => ERROR1
00232     Purpose:    Add a new colour to the list of exported colours.
00233     Errors:     Out of memory => ERROR1
00234     SeeAlso:    ExportColour
00235 
00236 ********************************************************************************************/
00237 
00238 ExportColour *ExportColourList::AddColour(PColourRGBT *pNewRGBCol, INT32 NewRecordNumber)
00239 {
00240     ExportColour *pNewCol = new ExportColour(pNewRGBCol, NewRecordNumber);
00241 
00242     // Check for out of memory
00243     if (pNewCol == NULL)
00244         return NULL;
00245 
00246     // Add to the list and return success
00247     AddTail(pNewCol);
00248     return pNewCol;
00249 }
00250 
00251 /********************************************************************************************
00252 
00253 >   ExportedColours::ExportedColours()
00254 
00255     Author:     Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
00256     Created:    23/5/96
00257     Inputs:     -
00258     Outputs:    -
00259     Returns:    -
00260     Purpose:    Construct the class which encapsulates a list of exported colours.
00261     SeeAlso:    ExportedColours
00262 
00263 ********************************************************************************************/
00264 
00265 ExportedColours::ExportedColours()
00266 {
00267 }
00268 
00269 /********************************************************************************************
00270 
00271 >   ExportedColours::~ExportedColours()
00272 
00273     Author:     Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
00274     Created:    23/5/96
00275     Inputs:     -
00276     Outputs:    -
00277     Returns:    -
00278     Purpose:    Destroy the class which encapsulates a list of exported colours.
00279     SeeAlso:    ExportedColours
00280 
00281 ********************************************************************************************/
00282 
00283 ExportedColours::~ExportedColours()
00284 {
00285 }
00286 
00287 /********************************************************************************************
00288 
00289 >   BOOL ExportedColours::AddColour(IndexedColour *pNewCol, INT32 RecordNumber)
00290 
00291     Author:     Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
00292     Created:    23/5/96
00293     Inputs:     pNewCol         - the colour to put in the list.
00294                 RecordNumber    - the number of the record that this colour definition has been
00295                                   saved in.
00296     Returns:    TRUE if the colour could be added;
00297                 FALSE if not
00298     Purpose:    Add the specified colour to the list of already exported colours.
00299     Errors:     -
00300     SeeAlso:    ExportColourList;
00301 
00302 ********************************************************************************************/
00303 
00304 BOOL ExportedColours::AddColour(IndexedColour *pNewCol, INT32 RecordNumber)
00305 {
00306     // Add the colour onto our list
00307     ExportColour * pExpCol = Colours.AddColour(pNewCol, RecordNumber);
00308     if (pExpCol)
00309         return TRUE;
00310     
00311     return FALSE;
00312 }
00313 
00314 /********************************************************************************************
00315 
00316 >   BOOL ExportedColours::AddColour(PColourRGBT *pNewRGBCol, INT32 RecordNumber)
00317 
00318     Author:     Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
00319     Created:    3/6/96
00320     Inputs:     pNewRGBCol      - the simple RGB colour to put in the list.
00321                 RecordNumber    - the number of the record that this colour definition has been
00322                                   saved in.
00323     Returns:    TRUE if the colour could be added;
00324                 FALSE if not
00325     Purpose:    Add the specified colour to the list of already exported colours.
00326     Errors:     -
00327     SeeAlso:    ExportColourList;
00328 
00329 ********************************************************************************************/
00330 
00331 BOOL ExportedColours::AddColour(PColourRGBT *pNewRGBCol, INT32 RecordNumber)
00332 {
00333     // Add the colour onto our list
00334     ExportColour * pExpCol = Colours.AddColour(pNewRGBCol, RecordNumber);
00335     if (pExpCol)
00336         return TRUE;
00337     
00338     return FALSE;
00339 }
00340 
00341 /********************************************************************************************
00342 
00343 >   ExportColour *ExportedColours::GetColour(IndexedColour *pSearchCol)
00344 
00345     Author:     Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
00346     Created:    23/5/96
00347     Inputs:     pSearchCol          - the colour to search for in the list.
00348     Returns:    if the item is found then returns       - Pointer to the exported colour list item
00349                 if the item is not found then returns   - NULL.
00350     Purpose:    Find an indexed colour in the exported list.
00351     SeeAlso:    ExportColourList
00352 
00353 ********************************************************************************************/
00354 
00355 ExportColour *ExportedColours::GetColour(IndexedColour *pSearchCol)
00356 {
00357     if (pSearchCol == NULL)
00358     {
00359         ERROR3("ExportedColours::GetColour - searching for a null indexed colour!");
00360     }
00361 
00362     ExportColour* pExportedColour = (ExportColour *)Colours.GetHead();
00363     while (pExportedColour)
00364     {
00365         // Compare the indexed colour pointers and return the match if they are the same
00366         if (pExportedColour->pCol == pSearchCol)
00367             return pExportedColour;
00368         
00369         // Try the next colour in the list
00370         pExportedColour = (ExportColour *)Colours.GetNext(pExportedColour);
00371     }
00372 
00373     // No - return failure.
00374     return NULL;
00375 }
00376 
00377 /********************************************************************************************
00378 
00379 >   ExportColour *ExportedColours::GetColour(PColourRGBT *pSearchRGBCol)
00380 
00381     Author:     Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
00382     Created:    3/6/96
00383     Inputs:     pSearchRGBCol       - the simple RGB colour to search for in the list.
00384     Returns:    if the item is found then returns       - Pointer to the exported colour list item
00385                 if the item is not found then returns   - NULL.
00386     Purpose:    Find a simpple RGB colour in the exported list.
00387     SeeAlso:    ExportColourList
00388 
00389 ********************************************************************************************/
00390 
00391 ExportColour *ExportedColours::GetColour(PColourRGBT *pSearchRGBCol)
00392 {
00393     if (pSearchRGBCol == NULL)
00394     {
00395         ERROR3("ExportedColours::GetColour (Simple )- searching for a null indexed colour!");
00396     }
00397 
00398     ExportColour* pExportedColour = (ExportColour *)Colours.GetHead();
00399     while (pExportedColour)
00400     {
00401         // Only check if this is a simple colour
00402         if (pExportedColour->pCol == NULL)
00403         {
00404             // Compare the simple RGB colours and return the match if they are the same
00405             if (
00406                 pExportedColour->SimpleRGBColour.Red == pSearchRGBCol->Red &&
00407                 pExportedColour->SimpleRGBColour.Green == pSearchRGBCol->Green &&
00408                 pExportedColour->SimpleRGBColour.Blue == pSearchRGBCol->Blue &&
00409                 pExportedColour->SimpleRGBColour.Transparent == pSearchRGBCol->Transparent
00410                )
00411                 return pExportedColour;
00412         }
00413         
00414         // Try the next colour in the list
00415         pExportedColour = (ExportColour *)Colours.GetNext(pExportedColour);
00416     }
00417 
00418     // No - return failure.
00419     return NULL;
00420 }

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