2004-01-27 03:39:01 +03:00
|
|
|
//------------------------------------------------------------------------------
|
2004-09-21 02:50:02 +04:00
|
|
|
// Copyright (c) 2001-2002, Haiku, Inc.
|
2004-01-27 03:39:01 +03:00
|
|
|
//
|
|
|
|
// Permission is hereby granted, free of charge, to any person obtaining a
|
|
|
|
// copy of this software and associated documentation files (the "Software"),
|
|
|
|
// to deal in the Software without restriction, including without limitation
|
|
|
|
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
|
|
// and/or sell copies of the Software, and to permit persons to whom the
|
|
|
|
// Software is furnished to do so, subject to the following conditions:
|
|
|
|
//
|
|
|
|
// The above copyright notice and this permission notice shall be included in
|
|
|
|
// all copies or substantial portions of the Software.
|
|
|
|
//
|
|
|
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
|
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
|
|
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
|
|
|
// DEALINGS IN THE SOFTWARE.
|
|
|
|
//
|
|
|
|
// File Name: LayerData.cpp
|
|
|
|
// Author: DarkWyrm <bpmagic@columbus.rr.com>
|
|
|
|
// Adi Oanca <adioanca@mymail.ro>
|
|
|
|
// Description: Data classes for working with BView states and draw parameters
|
|
|
|
//
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
#include "LayerData.h"
|
|
|
|
#include <Layer.h>
|
2004-04-03 19:01:10 +04:00
|
|
|
#include <stdio.h>
|
2004-01-27 03:39:01 +03:00
|
|
|
|
|
|
|
DrawData::DrawData(void)
|
|
|
|
{
|
|
|
|
pensize=1.0;
|
|
|
|
penlocation.Set(0,0);
|
|
|
|
highcolor.SetColor(0, 0, 0, 255);
|
|
|
|
lowcolor.SetColor(255, 255, 255, 255);
|
|
|
|
|
|
|
|
patt=pat_solidhigh;
|
|
|
|
draw_mode=B_OP_COPY;
|
|
|
|
|
|
|
|
lineCap =B_BUTT_CAP;
|
|
|
|
lineJoin=B_BEVEL_JOIN;
|
|
|
|
miterLimit=B_DEFAULT_MITER_LIMIT;
|
|
|
|
|
|
|
|
alphaSrcMode=B_PIXEL_ALPHA;
|
|
|
|
alphaFncMode=B_ALPHA_OVERLAY;
|
|
|
|
|
|
|
|
scale=1.0;
|
|
|
|
fontAliasing=true;
|
|
|
|
|
2004-11-24 23:07:41 +03:00
|
|
|
if(fontserver && fontserver->GetSystemPlain())
|
2004-01-27 03:39:01 +03:00
|
|
|
font=*(fontserver->GetSystemPlain());
|
|
|
|
|
2004-05-20 05:31:28 +04:00
|
|
|
clipReg=NULL;
|
2004-01-27 03:39:01 +03:00
|
|
|
|
|
|
|
edelta.space=0;
|
|
|
|
edelta.nonspace=0;
|
|
|
|
}
|
|
|
|
|
|
|
|
DrawData::~DrawData(void)
|
|
|
|
{
|
2004-05-20 05:31:28 +04:00
|
|
|
if (clipReg)
|
|
|
|
delete clipReg;
|
2004-01-27 03:39:01 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
DrawData::DrawData(const DrawData &data)
|
|
|
|
{
|
|
|
|
*this=data;
|
|
|
|
}
|
|
|
|
|
|
|
|
DrawData &DrawData::operator=(const DrawData &from)
|
|
|
|
{
|
|
|
|
pensize=from.pensize;
|
|
|
|
highcolor=from.highcolor;
|
|
|
|
lowcolor=from.lowcolor;
|
|
|
|
|
|
|
|
patt=from.patt;
|
|
|
|
draw_mode=from.draw_mode;
|
|
|
|
penlocation=from.penlocation;
|
|
|
|
|
|
|
|
lineCap=from.lineCap;
|
|
|
|
lineJoin=from.lineJoin;
|
|
|
|
miterLimit=from.miterLimit;
|
|
|
|
|
|
|
|
alphaSrcMode=from.alphaSrcMode;
|
|
|
|
alphaFncMode=from.alphaFncMode;
|
|
|
|
|
|
|
|
scale=from.scale;
|
|
|
|
fontAliasing=from.fontAliasing;
|
|
|
|
font=from.font;
|
|
|
|
|
2004-05-20 05:31:28 +04:00
|
|
|
if(from.clipReg)
|
2004-01-27 03:39:01 +03:00
|
|
|
{
|
2004-05-20 05:31:28 +04:00
|
|
|
if(clipReg)
|
|
|
|
*clipReg=*(from.clipReg);
|
2004-01-27 03:39:01 +03:00
|
|
|
else
|
2004-05-20 05:31:28 +04:00
|
|
|
clipReg=new BRegion(*(from.clipReg));
|
2004-01-27 03:39:01 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
edelta=from.edelta;
|
|
|
|
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
LayerData::LayerData(void)
|
|
|
|
{
|
|
|
|
coordOrigin.Set(0.0, 0.0);
|
|
|
|
viewcolor.SetColor(255,255,255,255);
|
|
|
|
|
|
|
|
background=NULL;
|
|
|
|
overlay=NULL;
|
|
|
|
prevState=NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
LayerData::LayerData(const LayerData &data)
|
|
|
|
{
|
|
|
|
*this=data;
|
|
|
|
}
|
|
|
|
|
|
|
|
LayerData::~LayerData(void)
|
|
|
|
{
|
|
|
|
if (prevState)
|
|
|
|
{
|
|
|
|
delete prevState;
|
|
|
|
prevState=NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
LayerData &LayerData::operator=(const LayerData &from)
|
|
|
|
{
|
|
|
|
// I'm not sure if the DrawData copy constructor will get called before this one is,
|
|
|
|
// so I'll just make sure the copy happens. :P
|
|
|
|
pensize=from.pensize;
|
|
|
|
highcolor=from.highcolor;
|
|
|
|
lowcolor=from.lowcolor;
|
|
|
|
|
|
|
|
patt=from.patt;
|
|
|
|
draw_mode=from.draw_mode;
|
2004-04-03 19:01:10 +04:00
|
|
|
penlocation=from.penlocation;
|
2004-01-27 03:39:01 +03:00
|
|
|
|
|
|
|
lineCap=from.lineCap;
|
|
|
|
lineJoin=from.lineJoin;
|
|
|
|
miterLimit=from.miterLimit;
|
|
|
|
|
|
|
|
alphaSrcMode=from.alphaSrcMode;
|
|
|
|
alphaFncMode=from.alphaFncMode;
|
|
|
|
|
|
|
|
scale=from.scale;
|
|
|
|
fontAliasing=from.fontAliasing;
|
|
|
|
font=from.font;
|
|
|
|
|
2004-05-20 05:31:28 +04:00
|
|
|
if(from.clipReg)
|
2004-01-27 03:39:01 +03:00
|
|
|
{
|
2004-05-20 05:31:28 +04:00
|
|
|
if(clipReg)
|
|
|
|
*clipReg=*(from.clipReg);
|
2004-01-27 03:39:01 +03:00
|
|
|
else
|
2004-05-20 05:31:28 +04:00
|
|
|
clipReg=new BRegion(*(from.clipReg));
|
2004-01-27 03:39:01 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
edelta=from.edelta;
|
|
|
|
|
|
|
|
// Stuff specific to LayerData
|
|
|
|
coordOrigin=from.coordOrigin;;
|
|
|
|
viewcolor=from.viewcolor;
|
|
|
|
|
|
|
|
background=from.background;
|
|
|
|
overlay=from.overlay;
|
|
|
|
|
|
|
|
prevState=from.prevState;
|
|
|
|
|
|
|
|
return *this;
|
|
|
|
}
|
2004-04-03 19:01:10 +04:00
|
|
|
|
|
|
|
void LayerData::PrintToStream() const{
|
|
|
|
printf("\t Pen Location and Size: (%f, %f) - %f\n", penlocation.x, penlocation.y, pensize);
|
|
|
|
printf("\t HighColor: "); highcolor.PrintToStream();
|
|
|
|
printf("\t LowColor: "); lowcolor.PrintToStream();
|
|
|
|
printf("\t ViewColor "); viewcolor.PrintToStream();
|
|
|
|
printf("\t Pattern: %llu\n", patt.GetInt64());
|
|
|
|
printf("\t DrawMode: %lu\n", (uint32)draw_mode);
|
|
|
|
printf("\t LineCap: %d\t LineJoin: %d\t MiterLimit: %f\n", (int16)lineCap, (int16)lineJoin, miterLimit);
|
|
|
|
printf("\t AlphaSrcMode: %ld\t AlphaFncMode: %ld\n", (int32)alphaSrcMode, (int32)alphaFncMode);
|
|
|
|
printf("\t Scale: %f\n", scale);
|
2004-05-20 05:31:28 +04:00
|
|
|
if (clipReg)
|
|
|
|
clipReg->PrintToStream();
|
2004-04-03 19:01:10 +04:00
|
|
|
|
|
|
|
printf("\t ===== Font Data =====\n");
|
|
|
|
printf("\t FontStyle: CURRENTLY NOT SET\n");
|
|
|
|
printf("\t FontSize: %f\n", font.Size());
|
|
|
|
printf("\t FontShear: %f\n", font.Shear());
|
|
|
|
printf("\t FontRotation: %f\n", font.Rotation());
|
|
|
|
printf("\t FontSpacing: %ld\n", font.Spacing());
|
|
|
|
printf("\t FontEncoding: %ld\n", font.Encoding());
|
|
|
|
printf("\t FontFace: %ld\n", font.Face());
|
|
|
|
printf("\t FontFlags: %lu\n", font.Flags());
|
|
|
|
}
|