ActionCode LayerColourAction::Init( UndoableOperation* pOp, ActionList* pActionList, OpChangeLayerColourParam EntryParam) { UINT32 ActSize = sizeof(LayerColourAction); LayerColourAction* pNewAction; ActionCode Ac = Action::Init(pOp,pActionList,ActSize,CC_RUNTIME_CLASS(LayerColourAction),(Action**)&pNewAction); if (Ac != AC_FAIL && pNewAction != NULL) { OpChangeLayerColourParam& Param = ((LayerColourAction*)pNewAction)->Param; Document* pDoc = EntryParam.pDoc; Layer* pLayer = EntryParam.pLayer; Param.pDoc = pDoc; Param.pLayer = pLayer; if (pDoc != NULL && pLayer != NULL) { DocColour* pDocColour = pLayer->GetGuideColour(); Param.pColour = pDocColour->FindParentIndexedColour(); pLayer->SetGuideColour(EntryParam.pColour); LayerSGallery::ForceRedrawLayer(pDoc,pLayer); BROADCAST_TO_ALL(LayerMsg(pLayer,LayerMsg::GUIDELINES_CHANGED)); } ERROR3IF(pDoc == NULL, "pDoc is NULL"); ERROR3IF(pLayer == NULL,"pLayer is NULL"); } return Ac; }
DocColour VectorFileRenderRegion::AlphaBlend( DocColour &Foreground, DocColour &Background, UINT32 Transp ) { // Step 1: Declare local variables. DocColour Result; INT32 FGColour [3]; INT32 BGColour [3]; INT32 ResultColour [3]; // Step 2: Extract the colours from the DocColour class. Foreground.GetRGBValue( &( FGColour [0] ), &( FGColour [1] ), &( FGColour [2] ) ); Background.GetRGBValue( &( BGColour [0] ), &( BGColour [1] ), &( BGColour [2] ) ); // Step 3: Cycle through the list of colours, perform the alpha blend, and pass the // result out. for ( INT32 i = 0; i < 3; i++ ) { // Perform the alpha blend. ResultColour [i] = ( ( ( 255 - Transp ) * FGColour [i] ) + ( Transp * BGColour [i] ) ) / 255; } // Step 4: Set the colour value. Result.SetRGBValue( ResultColour [0], ResultColour [1], ResultColour [2] ); // Step 5: And return it. return Result; }
BOOL PrintComponent::ExportColourPlate(BaseCamelotFilter *pFilter, ColourPlate *pPlate) { ERROR3IF(pPlate == NULL, "Illegal NULL params"); BOOL ok = TRUE; #if !defined(EXCLUDE_FROM_RALPH) // --- Save any referenced spot colour IndexedColour *pCol = pPlate->GetSpotColour(); INT32 SpotRecordNumber = 0; if (pCol != NULL) { DocColour Fred; Fred.MakeRefToIndexedColour(pCol); SpotRecordNumber = pFilter->WriteRecord(&Fred); ok = (SpotRecordNumber > 0); } // -- Now save the ColourPlate CXaraFileRecord Rec(TAG_COLOURPLATE, TAG_COLOURPLATE_SIZE); if (ok) ok = Rec.Init(); BYTE Type = 0; switch(pPlate->GetType()) { case COLOURPLATE_CYAN: Type = 1; break; case COLOURPLATE_MAGENTA: Type = 2; break; case COLOURPLATE_YELLOW: Type = 3; break; case COLOURPLATE_KEY: Type = 4; break; case COLOURPLATE_SPOT: Type = 5; break; default: break; } // Size Total if (ok) ok = Rec.WriteBYTE(Type); // 1 1 if (ok) ok = Rec.WriteReference(SpotRecordNumber); // 4 5 double temp = pPlate->GetScreenAngle(); if (ok) ok = Rec.WriteDOUBLE(temp); // 8 13 temp = pPlate->GetScreenFrequency(); if (ok) ok = Rec.WriteDOUBLE(temp); // 8 21 // BYTE Flags = 0x00; // 1 22 if (!pPlate->IsDisabled()) Flags |= 0x01; if (pPlate->Overprints()) Flags |= 0x02; if (ok) ok = Rec.WriteBYTE(Flags); if (ok) pFilter->Write(&Rec); #endif // EXCLUDE_FROM_RALPH return(ok); }
BOOL LoadBrushDirect::OnLoadDocument(Document* pDoc) { ERROR3IF(pDoc==NULL,"No doc pointer during PrintMarksMan::ConvertAllDocColours!"); Node *CurNode = Node::DocFindFirstDepthFirst(pDoc); Node *NextNode; while (CurNode !=NULL) { // We may be about to chop this node out of the tree, so get the next node now NextNode = CurNode->DocFindNextDepthFirst(); // Use to scan the colour fields of the attribute. UINT32 Context = 0; DocColour *pColour; if (CurNode->IsAnAttribute()) { NodeAttribute *pNodeAttr = (NodeAttribute *) CurNode; // Get the next colour field from the attribute pColour = pNodeAttr->EnumerateColourFields(Context++); while (pColour != NULL) { // For each colour field, make sure the colour is a local DocColour so that // the sub-tree is entirely stand-alone if (pColour->FindParentIndexedColour() != NULL) { ColourGeneric ColDef; ColourContext *cc = ColourManager::GetColourContext(pColour->GetColourModel()); ERROR3IF(cc == NULL, "Can't find colour context?!"); // Get the IndexedColour definition as a standalone colour definition cc->ConvertColour(pColour->FindParentIndexedColour(), &ColDef); // Make the DocColour into a simple standalone "lookalike" of the parent colour *pColour = DocColour(pColour->GetColourModel(), &ColDef); } pColour = pNodeAttr->EnumerateColourFields(Context++); } } CurNode = NextNode; } // All is well we hope. return TRUE; }
IndexedColour *ColourDragInformation::GetColourForDocument(Document *pDestDoc) { // If no document supplied, assume the selected docuemnt is the destination if (pDestDoc == NULL) pDestDoc = Document::GetSelected(); // If there is no destination document, or if the colour is transparent, return NULL if (pDestDoc == NULL || TheColour.IsTransparent()) return(NULL); // If it's a document colour and already in the destination document, return it if (pParentDoc == pDestDoc) return(TheColour.FindParentIndexedColour()); // Copy the dragged colour into a temporary DocColour DocColour Temp = TheColour; IndexedColour *TempIxCol = NULL; // Check if we've got an IndexedColour to use... if (Temp.FindParentIndexedColour() == NULL) { // It's a library colour, so we must create a new IndexedColour to use TempIxCol = new IndexedColour(Temp); if (TempIxCol == NULL) return(NULL); // Failure - return "no colour" TempIxCol->SetName(ColourName); if (LibColIsSpot) // If a spot colour, make it so TempIxCol->SetLinkedParent(TempIxCol->FindLastLinkedParent(), COLOURTYPE_SPOT); // And make the DocColour reference it Temp.MakeRefToIndexedColour(TempIxCol); } // Ensure the colour (or a safe equivalent) is in the dest doc, by copying/merging it ColourManager::EnsureColourIsInDocument(pParentDoc, pDestDoc, &Temp); // And delete any temporary IndexedColour we created if (TempIxCol != NULL) delete TempIxCol; // And finally, return the resulting colour return(Temp.FindParentIndexedColour()); }
void ColourGallery::DoApplyItem(ListItem *ItemToApply) { if (ItemToApply == NULL) // Check for stupidity just in case return; // Fill colour selected so create a fill colour attribute NodeAttribute *Attrib = new AttrColourChange; if (Attrib == NULL) return; DocColour Ref = *((AttrColourChange *)Attrib)->GetStartColour(); Ref.MakeRefToIndexedColour((IndexedColour *) ItemToApply); ((AttrColourChange *)Attrib)->SetStartColour(&Ref); // AttributeSelected knows what to do with a selected attribute AttributeManager::AttributeSelected(NULL, Attrib); }
BOOL GuidesPropertiesTab::ShowColours() { if (pColourDropDown != NULL) { IndexedColour* pIndexedColour = NULL; Layer* pLayer = GetGuideLayer(); if (pLayer != NULL) { DocColour* pDocColour = pLayer->GetGuideColour(); if (pDocColour != NULL) { pIndexedColour = pDocColour->FindParentIndexedColour(); if (pIndexedColour->IsDeleted()) { pLayer->SetGuideColour(NULL); pIndexedColour = NULL; } } } pColourDropDown->ClearAllSpecialEntries(); if (pIndexedColour != NULL) { if (!pIndexedColour->IsNamed()) { String_256 LocalColourText(_R(IDS_LOCALCOLOUR)); DocColour LocalColour; LocalColour.MakeRefToIndexedColour(pIndexedColour); pColourDropDown->AddSpecialEntry(&LocalColourText,&LocalColour); } pColourDropDown->FillInColourList(pIndexedColour); } else pColourDropDown->FillInColourList(NULL,0); } return TRUE; }
BOOL CDRFilter::SetLineAttr(cdrfOffsetHeader *Object) { if(Version == CDRVERSION_3) { return SetLineAttr3(Object); } // find the reference... DWORD *pReference = (DWORD *)FindDataInObject(Object, cdrfOBJOFFSETTYPE_LINE); // if the pointer to the reference is zero, then the reference is probably // within some random style definition if(pReference == 0) { // OK, try and find a style number within the style reference WORD *pStyleReference = (WORD *)FindDataInObject(Object, cdrfOBJOFFSETTYPE_STYLE); if(pStyleReference != 0) { // OK, see if we can find a the style... cdrfStyle *pStyle; INT32 StyleSize; if((pStyle = (cdrfStyle *)Styles.Find(*pStyleReference, &StyleSize)) != 0) { // OK, got a style... now find a fill reference within it pReference = (DWORD *)FindDataInObject(&pStyle->Header, cdrfSTYLEOFFSETTYPE_OUTLINE); } } } cdrfOutline *Out; INT32 OutSize; if(pReference == 0 || (Out = (cdrfOutline *)Outlines.Find(*pReference, &OutSize)) == 0 || OutSize < sizeof(cdrfOutline)) { // if no outline data, or outline definitions couldn't be found, or outline // definition is too small, set up the default line attributes if(!SetLineWidth(cdrfOUTLINE_DEFAULT_WIDTH)) return FALSE; PColourCMYK cmyk; cmyk.Cyan = cmyk.Magenta = cmyk.Yellow = 0; cmyk.Key = 255; DocColour Col; Col.SetCMYKValue(&cmyk); if(!SetLineColour(Col)) return FALSE; return TRUE; } // check that this thingy should have an outline if((CDRDATA_WORD(Out->Flags) & cdrfOUTLINEFLAGS_NOOUTLINE) != 0) { if (!SetLineColour(DocColour(COLOUR_TRANS))) return FALSE; return TRUE; } // convert the line colour DocColour Col; ConvertColour(&Out->Colour, &Col); // find the line width INT32 LineWidth = CDRDATA_WORD(Out->LineThickness) * CDRCOORDS_TO_MILLIPOINTS; if(LineWidth > MAX_LINE_WIDTH) LineWidth = MAX_LINE_WIDTH; // find the join type JointType JType; switch(CDRDATA_WORD(Out->JoinStyle)) { case cdrfJOINSTYLE_SQUARE: JType = MitreJoin; break; case cdrfJOINSTYLE_ROUNDED: JType = RoundJoin; break; default: case cdrfJOINSTYLE_BEVEL: JType = BevelledJoin; break; } // set the cap style LineCapType CType; switch(CDRDATA_WORD(Out->EndStyle)) { case cdrfENDSTYLE_BUTT: CType = LineCapButt; break; case cdrfENDSTYLE_ROUNDED: CType = LineCapRound; break; default: case cdrfENDSTYLE_SQUARE: CType = LineCapSquare; break; } // set the dash pattern DashRec Dash; DashElement DashArray[cdrfMAX_DASH_ELEMENTS]; if(CDRDATA_WORD(Out->NDashSegments) > 0 && (CDRDATA_WORD(Out->Flags) & cdrfOUTLINEFLAGS_NODASH) == 0) { // set a dash pattern INT32 NSeg = CDRDATA_WORD(Out->NDashSegments); if(NSeg > cdrfMAX_DASH_ELEMENTS) NSeg = cdrfMAX_DASH_ELEMENTS; INT32 l; for(l = 0; l < NSeg; l++) { DashArray[l] = CDRDATA_WORD(Out->DashSegments[l]) * LineWidth; } Dash.Elements = NSeg; Dash.DashStart = 0; Dash.ElementData = DashArray; Dash.LineWidth = LineWidth; Dash.ScaleWithLineWidth = TRUE; Dash.DashID = -1; } else { // no dash pattern Dash = SD_SOLID; } // set the attributes if(!SetLineWidth(LineWidth) || !SetLineColour(Col) || !SetJoinType(JType) || !SetLineCap(CType) || !SetDashPattern(Dash)) return FALSE; // check for arrowheads if(CDRDATA_DWORD(Out->StartArrowReference) != 0 || CDRDATA_DWORD(Out->EndArrowReference) != 0) { // apply the attributes to the object // If not filled, then set the ignore bit on the fill attribute. if (ObjFilled == FALSE) CurrentAttrs[ATTR_FILLGEOMETRY].Ignore = TRUE; // Add attributes to the path, if they are different from the default... AttributeManager::ApplyBasedOnDefaults(pMadeNode, CurrentAttrs); // DeleteCurrentAttrs(); // SetUpCurrentAttrs(); // Enable the fill attribute again CurrentAttrs[ATTR_FILLGEOMETRY].Ignore = FALSE; // ensure that the attributes won't be applied again AttrsAlreadyApplied = TRUE; // apply arrow heads to the path AddArrowheadsToPath(CDRDATA_DWORD(Out->StartArrowReference), CDRDATA_DWORD(Out->EndArrowReference), &Col, LineWidth, CType, JType); } return TRUE; }
BOOL CDRFilter::SetLineAttr3(cdrfOffsetHeader *Object) { cdrfOutlineV3 *Out = (cdrfOutlineV3 *)FindDataInObject(Object, cdrfOBJOFFSETTYPE_LINE); if(Out == 0) { // if no outline data, or outline definitions couldn't be found, or outline // definition is too small, set up the default line attributes if(!SetLineWidth(cdrfOUTLINE_DEFAULT_WIDTH)) return FALSE; PColourCMYK cmyk; cmyk.Cyan = cmyk.Magenta = cmyk.Yellow = 0; cmyk.Key = 255; DocColour Col; Col.SetCMYKValue(&cmyk); if(!SetLineColour(Col)) return FALSE; return TRUE; } // check that this thingy should have an outline if((Out->Flags & cdrfOUTLINEFLAGSV3_STROKED) == 0) { if (!SetLineColour(DocColour(COLOUR_TRANS))) return FALSE; return TRUE; } // convert the line colour DocColour Col; ConvertColour((cdrfColour *)&Out->Colour, &Col); // find the line width INT32 LineWidth = CDRDATA_WORD(Out->LineThickness) * CDRCOORDS_TO_MILLIPOINTS; if(LineWidth > MAX_LINE_WIDTH) LineWidth = MAX_LINE_WIDTH; // find the join type JointType JType; switch(CDRDATA_WORD(Out->JoinStyle)) { case cdrfJOINSTYLE_SQUARE: JType = MitreJoin; break; case cdrfJOINSTYLE_ROUNDED: JType = RoundJoin; break; default: case cdrfJOINSTYLE_BEVEL: JType = BevelledJoin; break; } // set the cap style LineCapType CType; switch(Out->EndStyle) // byte { case cdrfENDSTYLE_BUTT: CType = LineCapButt; break; case cdrfENDSTYLE_ROUNDED: CType = LineCapRound; break; default: case cdrfENDSTYLE_SQUARE: CType = LineCapSquare; break; } // set the dash pattern /* DashRec Dash; DashElement DashArray[cdrfMAX_DASH_ELEMENTS]; if((ObjectFlagsV3 & cdrfOBJFLAGSV3_NODASH) == 0 && Out->NDashSegments > 0) // byte { // set a dash pattern INT32 NSeg = CDRDATA_WORD(Out->NDashSegments); if(NSeg > cdrfMAX_DASH_ELEMENTS) NSeg = cdrfMAX_DASH_ELEMENTS; INT32 l; for(l = 0; l < NSeg; l++) { DashArray[l] = Out->DashSegments[l] * LineWidth; // byte } Dash.Elements = NSeg; Dash.DashStart = 0; Dash.ElementData = DashArray; Dash.LineWidth = LineWidth; Dash.ScaleWithLineWidth = TRUE; Dash.DashID = -1; } else { // no dash pattern Dash = SD_SOLID; } */ // set the attributes if(!SetLineWidth(LineWidth) || !SetLineColour(Col) || !SetJoinType(JType) || !SetLineCap(CType)/* || !SetDashPattern(Dash)*/) return FALSE; // check for arrowheads if(CDRDATA_DWORD(Out->StartArrowReference) != 0 || CDRDATA_DWORD(Out->EndArrowReference) != 0) { // apply the attributes to the object // If not filled, then set the ignore bit on the fill attribute. if (ObjFilled == FALSE) CurrentAttrs[ATTR_FILLGEOMETRY].Ignore = TRUE; // Add attributes to the path, if they are different from the default... AttributeManager::ApplyBasedOnDefaults(pMadeNode, CurrentAttrs); // Enable the fill attribute again CurrentAttrs[ATTR_FILLGEOMETRY].Ignore = FALSE; // ensure that the attributes won't be applied again AttrsAlreadyApplied = TRUE; // apply arrow heads to the path AddArrowheadsToPath(CDRDATA_DWORD(Out->StartArrowReference), CDRDATA_DWORD(Out->EndArrowReference), &Col, LineWidth, CType, JType); } return TRUE; }
void PrintComponent::ImportColourPlate(CXaraFileRecord* Rec, CamelotRecordHandler *pHandler) { #if !defined(EXCLUDE_FROM_RALPH) BOOL ok = TRUE; PORTNOTETRACE("print","PrintComponent::ImportColourPlate - do nothing"); TypesetInfo *TInfo = GetPrintControl()->GetTypesetInfo(); if (TInfo == NULL) return; ColourPlate *NewPlate = TInfo->CreateColourPlate(); if (NewPlate == NULL) return; BYTE Type; if (ok) ok = Rec->ReadBYTE(&Type); ColourPlateType PlateType = COLOURPLATE_NONE; if (ok) { switch(Type) { case 1: PlateType = COLOURPLATE_CYAN; break; case 2: PlateType = COLOURPLATE_MAGENTA; break; case 3: PlateType = COLOURPLATE_YELLOW; break; case 4: PlateType = COLOURPLATE_KEY; break; case 5: PlateType = COLOURPLATE_SPOT; break; } } IndexedColour *pCol = NULL; if (ok) { INT32 ColRecordNum; ok = Rec->ReadINT32(&ColRecordNum); if (ok && PlateType == COLOURPLATE_SPOT) { DocColour SpotCol; ok = pHandler->GetDocColour(ColRecordNum, &SpotCol); if (ok) pCol = SpotCol.FindParentIndexedColour(); } } // If this is a spot plate, it must reference a valid spot colour if (PlateType == COLOURPLATE_SPOT && (pCol == NULL || pCol->GetType() != COLOURTYPE_SPOT || pCol->IsDeleted()) ) { // Poohs. No point in keeping this plate around delete NewPlate; return; } NewPlate->SetType(NULL, PlateType, pCol); if (ok) { double Angle = 0.0; double Frequency = 60.0; ok = Rec->ReadDOUBLE(&Angle); if (ok) ok = Rec->ReadDOUBLE(&Frequency); if (ok) NewPlate->SetScreenInfo(Angle, Frequency); } BYTE Flags; if (ok) ok = Rec->ReadBYTE(&Flags); if (ok) { NewPlate->SetDisabled( (Flags & 0x01) == 0); // NOTE Flag is ENabled state! NewPlate->SetOverprint((Flags & 0x02) != 0); } if (ok) { // Now, it'll be quite handy if we add the new plate to the plate list! TInfo->AddPlate(NewPlate); } #endif }
BOOL ColourGallery::DoRedefineItem(ListItem *ItemToRedefine) { // Bring up the colour editor on the new colour if (ItemToRedefine != NULL) DoSpecialClick(ItemToRedefine); return(TRUE); #if FALSE ColourList *ColList = ColourManager::GetColourList(); if (ColList == NULL) return(FALSE); DocColour *SourceColour = NULL; if (ColourManager::GetCurrentLineAndFillColours(NULL, &SourceColour)) SourceColour = NULL; // Sourcecolour returned was current attr - don't use if (SourceColour == NULL) { // Nothing to copy to redefine the colour. Report this to the user InformError(_R(IDE_COLGAL_NOSOURCE), _R(IDS_OK)); return(FALSE); } // We have a colour to copy... INT32 Result; IndexedColour *ParentColour = SourceColour->FindParentIndexedColour(); if (ParentColour == NULL) { Result = AskQuestion(_R(IDS_COLGAL_QREDEFINE), _R(IDS_COLGAL_YREDEFINE), _R(IDS_CANCEL)); if (Result == 1) // The user said to go ahead... { // Source is an immediate colour - generate an IndexedColour from its definition ColourGeneric Bob; SourceColour->GetSourceColour(&Bob); *((IndexedColour *)ItemToRedefine) = IndexedColour(SourceColour->GetColourModel(), &Bob); return(TRUE); } return(FALSE); // The user cancelled } if (ParentColour == (IndexedColour *) ItemToRedefine) { InformError(_R(IDE_COLGAL_SAMEITEM)); return(FALSE); } Result = 3; // Default to making a copy of the colour { IndexedColour *NewCol = (IndexedColour *)ItemToRedefine; *NewCol = *ParentColour; if (ParentColour->IsNamed()) { String_128 NewName; // Accomodate overflow- SetName clips this to String_64 NewName.MakeMsg(_R(IDS_COPYOFCOLOUR), (TCHAR *) (*ParentColour->GetName())); ((IndexedColour *)ItemToRedefine)->SetName(NewName); // If the parent was named, then remember it as the 'parent' colour, even // if it was not tint/linked. This will allow the colour editor to default // to linking to a useful colour if tint/link is turned on at a later date. NewCol->SetLinkedParent(ParentColour, NewCol->GetType()); } } if (Result != 0) // Finally, inform the world if this item has changed ColourManager::ColourHasChanged(GetGalleryDocument(), ColList, (IndexedColour *) ItemToRedefine); return(Result != 0); // if Cancelled, return FALSE (no change), else TRUE #endif }