2004-01-27 03:39:41 +03:00
|
|
|
//------------------------------------------------------------------------------
|
2005-04-19 04:42:42 +04:00
|
|
|
// Copyright (c) 2001-2005, Haiku, Inc.
|
2004-01-27 03:39:41 +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.h
|
|
|
|
// Author: DarkWyrm <bpmagic@columbus.rr.com>
|
|
|
|
// Adi Oanca <adioanca@mymail.ro>
|
2005-04-19 04:42:42 +04:00
|
|
|
// Stephan Aßmus <superstippi@gmx.de>
|
2004-01-27 03:39:41 +03:00
|
|
|
// Description: Data classes for working with BView states and draw parameters
|
|
|
|
//
|
|
|
|
//------------------------------------------------------------------------------
|
2005-04-19 04:42:42 +04:00
|
|
|
#ifndef LAYER_DATA_H_
|
|
|
|
#define LAYER_DATA_H_
|
2003-01-20 23:38:49 +03:00
|
|
|
|
2003-09-25 16:12:58 +04:00
|
|
|
#include <GraphicsDefs.h>
|
|
|
|
#include <InterfaceDefs.h>
|
2005-04-19 04:42:42 +04:00
|
|
|
#include <Point.h>
|
|
|
|
#include <View.h> // for B_FONT_ALL
|
|
|
|
|
|
|
|
#include "RGBColor.h"
|
|
|
|
#include "FontServer.h"
|
|
|
|
#include "ServerFont.h"
|
|
|
|
#include "PatternHandler.h"
|
2003-01-20 23:38:49 +03:00
|
|
|
|
2005-04-19 04:42:42 +04:00
|
|
|
class BRegion;
|
|
|
|
class LinkMsgReader;
|
|
|
|
class LinkMsgSender;
|
2003-01-20 23:38:49 +03:00
|
|
|
class ServerBitmap;
|
|
|
|
|
2005-04-19 04:42:42 +04:00
|
|
|
class DrawData {
|
|
|
|
public:
|
|
|
|
DrawData();
|
|
|
|
DrawData(const DrawData& from);
|
|
|
|
virtual ~DrawData();
|
|
|
|
|
|
|
|
DrawData& operator=(const DrawData& from);
|
|
|
|
|
|
|
|
// coordinate transformation
|
|
|
|
void SetOrigin(const BPoint& origin);
|
|
|
|
inline const BPoint& Origin() const
|
|
|
|
{ return fOrigin; }
|
|
|
|
|
|
|
|
void SetScale(float scale);
|
|
|
|
inline float Scale() const
|
|
|
|
{ return fScale; }
|
|
|
|
|
|
|
|
// additional clipping as requested by client
|
|
|
|
void SetClippingRegion(const BRegion& region);
|
|
|
|
inline const BRegion* ClippingRegion() const
|
|
|
|
{ return fClippingRegion; }
|
|
|
|
/* inline int32 CountClippingRects() const
|
|
|
|
{ return fClippingRegion ? fClippingRegion.CountRects() : 0; }
|
|
|
|
inline BRect ClippingRectAt(int32 index) const;*/
|
|
|
|
|
|
|
|
// color
|
|
|
|
void SetHighColor(const RGBColor& color);
|
|
|
|
inline const RGBColor& HighColor() const
|
|
|
|
{ return fHighColor; }
|
|
|
|
|
|
|
|
void SetLowColor(const RGBColor& color);
|
|
|
|
inline const RGBColor& LowColor() const
|
|
|
|
{ return fLowColor; }
|
|
|
|
|
|
|
|
void SetPattern(const Pattern& pattern);
|
|
|
|
inline const Pattern& GetPattern() const
|
|
|
|
{ return fPattern; }
|
|
|
|
|
|
|
|
// drawing/blending mode
|
|
|
|
void SetDrawingMode(drawing_mode mode);
|
|
|
|
inline drawing_mode GetDrawingMode() const
|
|
|
|
{ return fDrawingMode; }
|
|
|
|
|
|
|
|
void SetBlendingMode(source_alpha srcMode,
|
|
|
|
alpha_function fncMode);
|
|
|
|
inline source_alpha AlphaSrcMode() const
|
|
|
|
{ return fAlphaSrcMode; }
|
|
|
|
inline alpha_function AlphaFncMode() const
|
|
|
|
{ return fAlphaFncMode; }
|
|
|
|
|
|
|
|
// pen
|
|
|
|
void SetPenLocation(const BPoint& location);
|
|
|
|
const BPoint& PenLocation() const;
|
|
|
|
|
|
|
|
void SetPenSize(float size);
|
|
|
|
float PenSize() const;
|
|
|
|
|
|
|
|
// font
|
|
|
|
void SetFont(const ServerFont& font,
|
|
|
|
uint32 flags = B_FONT_ALL);
|
|
|
|
inline const ServerFont& Font() const
|
|
|
|
{ return fFont; }
|
|
|
|
|
|
|
|
void SetFontAntiAliasing(bool antiAliasing);
|
|
|
|
inline bool FontAntiAliasing() const
|
|
|
|
{ return fFontAntiAliasing; }
|
|
|
|
|
|
|
|
void SetEscapementDelta(escapement_delta delta);
|
|
|
|
inline escapement_delta EscapementDelta() const
|
|
|
|
{ return fEscapementDelta; }
|
|
|
|
|
|
|
|
// postscript style settings
|
|
|
|
void SetLineCapMode(cap_mode mode);
|
|
|
|
inline cap_mode LineCapMode() const
|
|
|
|
{ return fLineCapMode; }
|
|
|
|
|
|
|
|
void SetLineJoinMode(join_mode mode);
|
|
|
|
inline join_mode LineJoinMode() const
|
|
|
|
{ return fLineJoinMode; }
|
|
|
|
|
|
|
|
void SetMiterLimit(float limit);
|
|
|
|
inline float MiterLimit() const
|
|
|
|
{ return fMiterLimit; }
|
|
|
|
|
|
|
|
// convenience functions
|
|
|
|
inline BPoint Transform(const BPoint& point) const;
|
|
|
|
inline BRect Transform(const BRect& rect) const;
|
|
|
|
|
|
|
|
|
|
|
|
protected:
|
|
|
|
BPoint fOrigin;
|
|
|
|
float fScale;
|
|
|
|
|
|
|
|
BRegion* fClippingRegion;
|
|
|
|
|
|
|
|
RGBColor fHighColor;
|
|
|
|
RGBColor fLowColor;
|
|
|
|
Pattern fPattern;
|
|
|
|
|
|
|
|
drawing_mode fDrawingMode;
|
|
|
|
source_alpha fAlphaSrcMode;
|
|
|
|
alpha_function fAlphaFncMode;
|
|
|
|
|
|
|
|
BPoint fPenLocation;
|
|
|
|
float fPenSize;
|
|
|
|
|
|
|
|
ServerFont fFont;
|
|
|
|
bool fFontAntiAliasing;
|
|
|
|
escapement_delta fEscapementDelta;
|
|
|
|
|
|
|
|
cap_mode fLineCapMode;
|
|
|
|
join_mode fLineJoinMode;
|
|
|
|
float fMiterLimit;
|
|
|
|
|
|
|
|
float fUnscaledFontSize;
|
2004-01-27 03:39:41 +03:00
|
|
|
};
|
2003-09-09 01:03:25 +04:00
|
|
|
|
2005-04-19 04:42:42 +04:00
|
|
|
class LayerData : public DrawData {
|
|
|
|
public:
|
|
|
|
LayerData();
|
2004-04-03 19:03:57 +04:00
|
|
|
LayerData(const LayerData &data);
|
2005-04-19 04:42:42 +04:00
|
|
|
virtual ~LayerData();
|
|
|
|
|
|
|
|
LayerData& operator=(const LayerData &from);
|
2004-04-03 19:03:57 +04:00
|
|
|
|
2005-04-19 04:42:42 +04:00
|
|
|
// automatic background blanking by app_server
|
|
|
|
void SetViewColor(const RGBColor& color);
|
|
|
|
inline const RGBColor& ViewColor() const
|
|
|
|
{ return fViewColor; }
|
|
|
|
|
|
|
|
void SetBackgroundBitmap(const ServerBitmap* bitmap);
|
|
|
|
inline const ServerBitmap* BackgroundBitmap() const
|
|
|
|
{ return fBackgroundBitmap; }
|
|
|
|
|
|
|
|
// overlay support
|
|
|
|
// TODO: This can't be all, what about color key?
|
|
|
|
void SetOverlayBitmap(const ServerBitmap* bitmap);
|
|
|
|
inline const ServerBitmap* OverlayBitmap() const
|
|
|
|
{ return fOverlayBitmap; }
|
|
|
|
|
|
|
|
// convenience functions
|
2004-04-03 19:03:57 +04:00
|
|
|
virtual void PrintToStream() const;
|
|
|
|
|
2005-04-19 04:42:42 +04:00
|
|
|
void ReadFontFromLink(LinkMsgReader& link);
|
|
|
|
// NOTE: ReadFromLink() does not read Font state!!
|
|
|
|
// It was separate in ServerWindow, and I didn't
|
|
|
|
// want to change it without knowing implications.
|
|
|
|
void ReadFromLink(LinkMsgReader& link);
|
|
|
|
void WriteToLink(LinkMsgSender& link) const;
|
2004-01-27 03:39:41 +03:00
|
|
|
|
2005-04-19 04:42:42 +04:00
|
|
|
protected:
|
2004-01-27 03:39:41 +03:00
|
|
|
|
2005-04-19 04:42:42 +04:00
|
|
|
RGBColor fViewColor;
|
2004-01-27 03:39:41 +03:00
|
|
|
|
2005-04-19 04:42:42 +04:00
|
|
|
// We have both because we are not going to suffer
|
|
|
|
// from the limitation that R5 places on us.
|
|
|
|
// We can have both. :)
|
|
|
|
const ServerBitmap* fBackgroundBitmap;
|
|
|
|
const ServerBitmap* fOverlayBitmap;
|
|
|
|
|
|
|
|
public:
|
2004-04-03 19:03:57 +04:00
|
|
|
// used for the state stack
|
|
|
|
LayerData* prevState;
|
2003-01-20 23:38:49 +03:00
|
|
|
};
|
2005-04-19 04:42:42 +04:00
|
|
|
|
|
|
|
// inline implementations
|
|
|
|
|
|
|
|
// Transform
|
|
|
|
BPoint
|
|
|
|
DrawData::Transform(const BPoint& point) const
|
|
|
|
{
|
|
|
|
BPoint p(point);
|
|
|
|
p += fOrigin;
|
|
|
|
p.x *= fScale;
|
|
|
|
p.y *= fScale;
|
|
|
|
return p;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Transform
|
|
|
|
BRect
|
|
|
|
DrawData::Transform(const BRect& rect) const
|
|
|
|
{
|
|
|
|
return BRect(Transform(rect.LeftTop()),
|
|
|
|
Transform(rect.LeftBottom()));
|
|
|
|
}
|
|
|
|
/*
|
|
|
|
// ClippingRectAt
|
|
|
|
BRect
|
|
|
|
DrawData::ClippingRectAt(int32 index) const
|
|
|
|
{
|
|
|
|
BRect r;
|
|
|
|
if (fClippingRegion) {
|
|
|
|
r = fClippingRegion.RectAt(index);
|
|
|
|
}
|
|
|
|
return r;
|
|
|
|
}*/
|
|
|
|
|
|
|
|
#endif // LAYER_DATA_H_
|