CMXReferColour Class Reference

#include <cmxexdc.h>

Inheritance diagram for CMXReferColour:

CMXReferListItem ListItem CCObject SimpleCCObject List of all members.

Public Member Functions

 CMXReferColour (CMXExportDC *pDC)
BOOL SetColour (DocColour *pCol)
BOOL AreYouThisColour (DocColour *pCompareColour)
INT32 IsInWhichDesc (void)
BOOL WriteInDesc (CMXExportDC *pDC)
 writes the colour to the DC in a description list

Protected Attributes

DocColour Colour

Private Member Functions

 CC_DECLARE_DYNAMIC (CMXReferColour)

Detailed Description

Definition at line 550 of file cmxexdc.h.


Constructor & Destructor Documentation

CMXReferColour::CMXReferColour CMXExportDC pDC  )  [inline]
 

Definition at line 555 of file cmxexdc.h.

00555 : CMXReferListItem(pDC) {};


Member Function Documentation

BOOL CMXReferColour::AreYouThisColour DocColour pCompareColour  )  [inline]
 

Definition at line 558 of file cmxexdc.h.

00559         {return ((*pCompareColour) == (Colour))?TRUE:FALSE;};

CMXReferColour::CC_DECLARE_DYNAMIC CMXReferColour   )  [private]
 

INT32 CMXReferColour::IsInWhichDesc void   )  [inline, virtual]
 

Reimplemented from CMXReferListItem.

Definition at line 561 of file cmxexdc.h.

00561 {return cmxDESC_COLOUR;};

BOOL CMXReferColour::SetColour DocColour pCol  )  [inline]
 

Definition at line 557 of file cmxexdc.h.

00557 {Colour = *pCol; return TRUE;};

BOOL CMXReferColour::WriteInDesc CMXExportDC pDC  )  [virtual]
 

writes the colour to the DC in a description list

Author:
Ben_Summers (Xara Group Ltd) <camelotdev@xara.com>
Date:
26/06/96
Parameters:
export dc [INPUTS]
Returns:
none
See also:

Reimplemented from CMXReferListItem.

Definition at line 599 of file cmxexdc.cpp.

00600 {
00601     ColourModel OutputModel;
00602     struct {
00603         BYTE ColType;
00604         BYTE Palette;
00605     } ColH;
00606     ColH.Palette = 5;       // user palette
00607 
00608     // Work out which CMX colour type we will export as, and therefore which internal
00609     // colour model we should convert the colour to.
00610     switch (Colour.GetColourModel())
00611     {
00612         case COLOURMODEL_HSVT:
00613             OutputModel = COLOURMODEL_HSVT;
00614             ColH.ColType = cmxCOLMODEL_HSB;
00615             break;
00616 
00617         case COLOURMODEL_CMYK:
00618             OutputModel = COLOURMODEL_CMYK;
00619             ColH.ColType = cmxCOLMODEL_CMYK255;
00620             break;
00621 
00622         case COLOURMODEL_GREYT:
00623             OutputModel = COLOURMODEL_GREYT;
00624             ColH.ColType = cmxCOLMODEL_GREY;
00625             break;
00626         
00627         case COLOURMODEL_RGBT:
00628         default:
00629             // It's RGB, or we don't know the model, so we'll output it as RGB
00630             OutputModel = COLOURMODEL_RGBT;
00631             ColH.ColType = cmxCOLMODEL_RGB;
00632             break;
00633     }
00634 
00635     // write the header tag
00636     if(!pDC->WriteTag(cmxTAG_DescrSection_Color_Base, &ColH, sizeof(ColH)))
00637         return FALSE;
00638 
00639     // Find an appropriate colour context to convert the colour for output
00640     ColourContext *OutputCC = ColourManager::GetColourContext(OutputModel);
00641     ERROR3IF(OutputCC == NULL, "Can't find a colour context");
00642 
00643     // Convert the colour into a packed format
00644     ColourPacked Result;
00645     OutputCC->ConvertColour(&Colour, &Result);
00646 
00647     // start the tag
00648     if(!pDC->StartTag(cmxTAG_DescrSection_Color_ColorDescr))
00649         return FALSE;
00650 
00651     // Pull the converted colour out and export it to the CMX file
00652     switch (OutputModel)
00653     {
00654         case COLOURMODEL_HSVT:
00655             {
00656 /*TRACEUSER( "Ben", _T("HSV colour: hue %d, sat %d, val %d\n"), Result.HSVT.Hue, Result.HSVT.Saturation, Result.HSVT.Value);
00657             WORD Hue = Result.HSVT.Hue;
00658             pDC->WriteData(&Hue, sizeof(Hue));
00659             pDC->WriteByte(Result.HSVT.Saturation);
00660             pDC->WriteByte(Result.HSVT.Value); */
00661 
00662                 // BODGE because the colour system can't convert HSVT properly yet
00663             ColourHSVT GResult;
00664             OutputCC->ConvertColour(&Colour, (ColourGeneric *)&GResult);
00665 
00666             WORD Hue = (WORD)(360.0 * GResult.Hue.MakeDouble());
00667             pDC->WriteData(&Hue, sizeof(Hue));
00668             pDC->WriteByte((BYTE)(255.0 * GResult.Saturation.MakeDouble()));
00669             pDC->WriteByte((BYTE)(255.0 * GResult.Value.MakeDouble()));
00670             }
00671             break;
00672 
00673         case COLOURMODEL_CMYK:
00674 TRACEUSER( "Ben", _T("CMYK colour: cyan %d mag %d yel %d key %d\n"), Result.CMYK.Cyan, Result.CMYK.Magenta, Result.CMYK.Yellow, Result.CMYK.Key);
00675             pDC->WriteByte(Result.CMYK.Cyan);
00676             pDC->WriteByte(Result.CMYK.Magenta);
00677             pDC->WriteByte(Result.CMYK.Yellow);
00678             pDC->WriteByte(Result.CMYK.Key);
00679             break;
00680 
00681         case COLOURMODEL_GREYT:
00682 TRACEUSER( "Ben", _T("grey colour: grey %d\n"), Result.GreyT.Intensity);
00683             pDC->WriteByte(Result.GreyT.Intensity);
00684             break;
00685 
00686         case COLOURMODEL_RGBT:
00687         default:
00688 TRACEUSER( "Ben", _T("RGB colour: red %d green %d blue %d\n"), Result.RGBT.Red, Result.RGBT.Green, Result.RGBT.Blue);
00689             pDC->WriteByte(Result.RGBT.Red);
00690             pDC->WriteByte(Result.RGBT.Green);
00691             pDC->WriteByte(Result.RGBT.Blue);
00692             break;
00693     }
00694 
00695     // end the tag
00696     if(!pDC->EndTag())
00697         return FALSE;
00698 
00699     // write the end tag
00700     if(!pDC->WriteMinEndTag())
00701         return FALSE;
00702 
00703     return TRUE;
00704 }


Member Data Documentation

DocColour CMXReferColour::Colour [protected]
 

Definition at line 565 of file cmxexdc.h.


The documentation for this class was generated from the following files:
Generated on Sat Nov 10 03:52:42 2007 for Camelot by  doxygen 1.4.4