rcolour.h
上传用户:hzhsqp
上传日期:2007-01-06
资源大小:1600k
文件大小:5k
- /*
- * rcolour.h
- *
- * Realised colour description.
- *
- * 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: rcolour.h,v $
- * Revision 1.12 1999/03/10 03:49:53 robertj
- * More documentation adjustments.
- *
- * Revision 1.11 1999/03/09 08:01:49 robertj
- * Changed comments for doc++ support (more to come).
- *
- * Revision 1.10 1999/02/16 08:08:46 robertj
- * MSVC 6.0 compatibility changes.
- *
- * Revision 1.9 1998/09/23 06:28:35 robertj
- * Added open source copyright license.
- *
- * Revision 1.8 1995/04/25 10:58:00 robertj
- * Fixed incorrect type on color component virtual function parameters.
- *
- * Revision 1.7 1995/03/14 12:42:22 robertj
- * Updated documentation to use HTML codes.
- *
- * Revision 1.6 1995/01/14 06:19:27 robertj
- * Documentation
- *
- * Revision 1.5 1994/08/23 11:32:52 robertj
- * Oops
- *
- * Revision 1.4 1994/08/22 00:46:48 robertj
- * Added pragma fro GNU C++ compiler.
- *
- * Revision 1.3 1994/01/03 04:42:23 robertj
- * Mass changes to common container classes and interactors etc etc etc.
- *
- * Revision 1.2 1993/07/14 12:49:16 robertj
- * Fixed RCS keywords.
- *
- */
- #define _PREALCOLOUR
- #ifdef __GNUC__
- #pragma interface
- #endif
- class PCanvas;
- /**A class representing a colour specification that is representable on
- a specific Ref{PCanvas}.
-
- A canvas is always associated with a particular {it device}. This may be
- the screen as in Ref{PInteractorCanvas} or a printer as in
- Ref{PPrinterCanvas}. A particular device will only be able to render
- certain colours, eg a screen device may be able to display full 32 bit
- colours or only 8 bit palettised colours. A printer would typically only be
- able to render 2 colours, black and white.
- Thus when a user wishes to render a light shade of pastel pink, as defined
- by the RGB values in the Ref{PColour} object, the device, eg a dot matrix
- colour printer, may only be able to render solid red. The creation of a
- PRealColour from the canvas and PColour will yield the RGB values 255, 0,
- and 0 respectively.
- A further purpose of a realised colour is to reserve a particular RGB value
- for use in a palettised device. For example, if an 8 bit screen is used
- which provides 256 simultaneous colours, the realisation of a colour that
- is not currently in the palette for the screen, will add a new colour to
- the palette. If the colour was alreadyt in the palette then a reference
- count for it is incremented. That specific RGB colour is then reserved
- until all the relised colours that reference it are destroyed.
-
- Note that the above reservation does {bf not} occur if an explicit
- palette is provided by the user, ie an instance of Ref{PPalette} is
- created and attached to the device via the Ref{PCanvas::SetPalette()}
- function.
- */
- class PRealColour : public PColour
- {
- PCLASSINFO(PRealColour, PColour);
- public:
- /**Create a colour as close to the specified colour that is representable
- on the specified canvas.
- */
- PRealColour(
- PCanvas & canvas, /// Canvas to realise colour for.
- const PColour & colour /// Colour specification to realise.
- );
- /**@name Overrides from class PObject */
- /**Create a new copy of the real colour. Note that it is the
- responsibility of the caller to delete the new object.
- @return
- new colour object on heap.
- */
- virtual PObject * Clone() const;
- /**@name Overrides from class PColour */
- /**Set the red component of the colour.
- This is not allowed on a real colour and always asserts.
- */
- virtual void SetRed(BYTE r);
- /**Set the green component of the colour.
- This is not allowed on a real colour and always asserts.
- */
- virtual void SetGreen(BYTE g);
- /**Set the blue component of the colour.
- This is not allowed on a real colour and always asserts.
- */
- virtual void SetBlue(BYTE b);
- /**Set the alpha channel component of the colour.
- This is not allowed on a real colour and always asserts.
- */
- virtual void SetAlpha(BYTE a);
- #ifdef DOC_PLUS_PLUS
- };
- #endif
- // Class declaration continued in platform specific header file ///////////////