palette.h
上传用户:hzhsqp
上传日期:2007-01-06
资源大小:1600k
文件大小:6k
- /*
- * palette.h
- *
- * Colour palette.
- *
- * Portable Windows Library
- *
- * Copyright (c) 1993-1998 Equivalence Pty. Ltd.
- *
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.0 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS"
- * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
- * the License for the specific language governing rights and limitations
- * under the License.
- *
- * The Original Code is Portable Windows Library.
- *
- * The Initial Developer of the Original Code is Equivalence Pty. Ltd.
- *
- * Portions are Copyright (C) 1993 Free Software Foundation, Inc.
- * All Rights Reserved.
- *
- * Contributor(s): ______________________________________.
- *
- * $Log: palette.h,v $
- * Revision 1.14 1999/03/10 03:49:52 robertj
- * More documentation adjustments.
- *
- * Revision 1.13 1999/03/09 08:01:49 robertj
- * Changed comments for doc++ support (more to come).
- *
- * Revision 1.12 1998/09/23 06:24:33 robertj
- * Added open source copyright license.
- *
- * Revision 1.11 1995/03/14 12:41:56 robertj
- * Updated documentation to use HTML codes.
- *
- * Revision 1.10 1995/01/06 10:31:04 robertj
- * Documentation.
- *
- * Revision 1.9 1994/08/23 11:32:52 robertj
- * Oops
- *
- * Revision 1.8 1994/08/22 00:46:48 robertj
- * Added pragma fro GNU C++ compiler.
- *
- * Revision 1.7 1994/04/03 08:34:18 robertj
- * Added help and focus functionality.
- *
- * Revision 1.6 1994/01/03 04:42:23 robertj
- * Mass changes to common container classes and interactors etc etc etc.
- *
- * Revision 1.5 1993/12/31 06:45:38 robertj
- * Made inlines optional for debugging purposes.
- *
- * Revision 1.4 1993/08/27 18:17:47 robertj
- * CFront compatibility.
- *
- * Revision 1.3 1993/08/21 01:50:33 robertj
- * Made Clone() function optional, default will assert if called.
- *
- * Revision 1.2 1993/07/14 12:49:16 robertj
- * Fixed RCS keywords.
- *
- */
- #define _PPALETTE
- #ifdef __GNUC__
- #pragma interface
- #endif
- /**A class representing a logical palette of colours.
- A palette is a look up table for converting an index into a full RGB colour
- specification. A palette typically has a small number of colours eg 16 or
- 256.
- */
- class PPalette : public PContainer
- {
- PCONTAINERINFO(PPalette, PContainer);
- public:
- /** Create a new empty palette. */
- PPalette();
- /**@name Overrides from class PObject */
- /**Compare two palette objects for equality. The two instances must
- reference the same actual palette. Thay cannot be two palettes that
- happen to have the same colours in them.
- @return
- #EqualTo# if the two objects reference to the same palette,
- otherwise #GreaterThan#.
- */
- virtual Comparison Compare(
- const PObject & obj /// Another palette object to compare against.
- ) const;
- /**@name Overrides from class PContainer */
- /**Get the current size of the palette, ie the total number of colours
- added to this logical palette.
- @return
- number of colours in palette.
- */
- virtual PINDEX GetSize() const;
- /**Set the new size of the palette. If the size was increased, all colours
- created between the old last colour and the new will be set to black.
- @return
- TRUE if the size was successfully changed. The value FALSE usually
- indicates failure due to insufficient memory.
- */
- virtual BOOL SetSize(
- PINDEX newSize /// New size of the palette
- );
- /**@name New functions for class */
- /**Add a colour specification into the palette, if the colour already
- exists in the palette, no new entry is added. Otherwise a new entry is
- appended.
-
- @return
- index for the colour added to the palette.
- */
- PINDEX AddColour(
- const PColour & colour /// New colour to add to the palette.
- );
- /**Remove from the palette the colour at the specified index or of the
- exact RGB value specified.
-
- Note when a colour is removed any indexes to colours after the remove
- one will correspond to a different colour that before, ie all colours
- are moved up one entry in the palettes "array" of colours.
- @return
- TRUE if the colour was in the palette and was removed.
- */
- BOOL RemoveColour(
- const PColour & colour /// Colour to remove from the palette.
- );
- BOOL RemoveColour(
- PINDEX idx /// Palette index to remove.
- );
- /**Determine if the palette contains an exact match for the colour
- @return
- TRUE if colour is in palette.
- */
- BOOL HasColour(
- const PColour & colour /// Colour to search for in palette.
- ) const;
- /**Locate the index in the palette of the nearest match to the specified
- colour that is in the palette.
-
- Note that of there is more than one colour that is identical to the
- one being searched for, the particular matching index that is returned
- is not defined, it could be any one of them.
- @return
- index of nearest colour in palette.
- */
- PINDEX GetIndex(
- const PColour & colour /// Colour to serarch for in palette.
- ) const;
- /**Get the colour specification for the specified index value.
-
- @return
- colour at index in palette.
- */
- PColour GetColour(
- PINDEX indx /// Index of colour in palette.
- ) const;
- /**Set a colour specification into the palette at the specified index. If
- this is beyond the end of the palette the palette is expanded to
- accommodate the new index. All colours created between the old last
- colour and the new will be set to black.
- @return
- TRUE if colour was successfully added to palette.
- */
- BOOL SetColour(
- PINDEX idx, /// Index of colour in palette.
- const PColour & colour /// New colour to set at index in palette.
- );
- private:
- #ifdef DOC_PLUS_PLUS
- };
- #endif
- // Class declaration continued in platform specific header file ///////////////