Removed SRect and SPoint as per Erik

git-svn-id: file:///srv/svn/repos/haiku/trunk/current@991 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
DarkWyrm 2002-09-07 11:29:02 +00:00
parent 9f9f4b0c19
commit 9cf7b05e49
22 changed files with 197 additions and 1335 deletions

View File

@ -11,7 +11,7 @@
#include <stdio.h>
#endif
BeDecorator::BeDecorator(SRect rect, int32 wlook, int32 wfeel, int32 wflags)
BeDecorator::BeDecorator(BRect rect, int32 wlook, int32 wfeel, int32 wflags)
: Decorator(rect,wlook,wfeel,wflags)
{
#ifdef DEBUG_DECOR
@ -52,7 +52,7 @@ printf("~BeDecorator()\n");
#endif
}
click_type BeDecorator::Clicked(SPoint pt, int32 buttons, int32 modifiers)
click_type BeDecorator::Clicked(BPoint pt, int32 buttons, int32 modifiers)
{
if(closerect.Contains(pt))
{
@ -96,10 +96,10 @@ printf("BeDecorator():Clicked() - Resize thumb\n");
}
// We got this far, so user is clicking on the border?
SRect srect(frame);
srect.top+=19;
SRect clientrect(srect.InsetByCopy(3,3));
if(srect.Contains(pt) && !clientrect.Contains(pt))
BRect brect(frame);
brect.top+=19;
BRect clientrect(brect.InsetByCopy(3,3));
if(brect.Contains(pt) && !clientrect.Contains(pt))
{
#ifdef DEBUG_DECOR
printf("BeDecorator():Clicked() - Drag\n");
@ -170,10 +170,10 @@ printf("BeDecorator()::_DoLayout()"); rect.PrintToStream();
void BeDecorator::MoveBy(float x, float y)
{
MoveBy(SPoint(x,y));
MoveBy(BPoint(x,y));
}
void BeDecorator::MoveBy(SPoint pt)
void BeDecorator::MoveBy(BPoint pt)
{
// Move all internal rectangles the appropriate amount
frame.OffsetBy(pt);
@ -196,7 +196,7 @@ SRegion * BeDecorator::GetFootprint(void)
}
*/
void BeDecorator::_DrawTitle(SRect r)
void BeDecorator::_DrawTitle(BRect r)
{
// Designed simply to redraw the title when it has changed on
// the client side.
@ -204,7 +204,7 @@ void BeDecorator::_DrawTitle(SRect r)
rgb_color tmpcol=driver->HighColor();
driver->SetHighColor(textcol.red,textcol.green,textcol.blue);
driver->DrawString((char *)string,strlen(string),
SPoint(closerect.right+textoffset,closerect.bottom-1));
BPoint(closerect.right+textoffset,closerect.bottom-1));
driver->SetHighColor(tmpcol.red,tmpcol.green,tmpcol.blue);
driver->SetDrawingMode(B_OP_COPY);
*/
@ -236,7 +236,7 @@ void BeDecorator::_SetFocus(void)
}
void BeDecorator::Draw(SRect update)
void BeDecorator::Draw(BRect update)
{
// We need to draw a few things: the tab, the resize thumb, the borders,
// and the buttons
@ -271,11 +271,11 @@ void BeDecorator::Draw(void)
}
void BeDecorator::_DrawZoom(SRect r)
void BeDecorator::_DrawZoom(BRect r)
{
// If this has been implemented, then the decorator has a Zoom button
// which should be drawn based on the state of the member zoomstate
SRect zr=r;
BRect zr=r;
zr.left+=zr.Width()/3;
zr.top+=zr.Height()/3;
@ -283,13 +283,13 @@ void BeDecorator::_DrawZoom(SRect r)
DrawBlendedRect(zr.OffsetToCopy(r.LeftTop()),GetZoom());
}
void BeDecorator::_DrawClose(SRect r)
void BeDecorator::_DrawClose(BRect r)
{
// Just like DrawZoom, but for a close button
DrawBlendedRect(r,GetClose());
}
void BeDecorator::_DrawTab(SRect r)
void BeDecorator::_DrawTab(BRect r)
{
// If a window has a tab, this will draw it and any buttons which are
// in it.
@ -311,7 +311,7 @@ void BeDecorator::_DrawTab(SRect r)
_DrawZoom(zoomrect);
}
void BeDecorator::DrawBlendedRect(SRect r, bool down)
void BeDecorator::DrawBlendedRect(BRect r, bool down)
{
// This bad boy is used to draw a rectangle with a gradient.
// Note that it is not part of the Decorator API - it's specific
@ -348,16 +348,16 @@ void BeDecorator::DrawBlendedRect(SRect r, bool down)
uint8(startcol.green-(i*gstep)),
uint8(startcol.blue-(i*bstep)));
layerdata.highcolor=tmpcol;
driver->StrokeLine(SPoint(r.left,r.top+i),
SPoint(r.left+i,r.top),&layerdata,(int8*)&solidhigh);
driver->StrokeLine(BPoint(r.left,r.top+i),
BPoint(r.left+i,r.top),&layerdata,(int8*)&solidhigh);
SetRGBColor(&tmpcol, uint8(halfcol.red-(i*rstep)),
uint8(halfcol.green-(i*gstep)),
uint8(halfcol.blue-(i*bstep)));
layerdata.highcolor=tmpcol;
driver->StrokeLine(SPoint(r.left+steps,r.top+i),
SPoint(r.left+i,r.top+steps),&layerdata,(int8*)&solidhigh);
driver->StrokeLine(BPoint(r.left+steps,r.top+i),
BPoint(r.left+i,r.top+steps),&layerdata,(int8*)&solidhigh);
}
@ -367,40 +367,40 @@ void BeDecorator::DrawBlendedRect(SRect r, bool down)
driver->StrokeRect(r,&layerdata,(int8*)&solidhigh);
}
void BeDecorator::_DrawFrame(SRect rect)
void BeDecorator::_DrawFrame(BRect rect)
{
// Duh, draws the window frame, I think. ;)
if(look==WLOOK_NO_BORDER)
return;
SRect r=borderrect;
BRect r=borderrect;
layerdata.highcolor=frame_midcol;
driver->StrokeLine(SPoint(r.left,r.top),SPoint(r.right-1,r.top),
driver->StrokeLine(BPoint(r.left,r.top),BPoint(r.right-1,r.top),
&layerdata,(int8*)&solidhigh);
layerdata.highcolor=frame_lowcol;
driver->StrokeLine(SPoint(r.left,r.top),SPoint(r.left,r.bottom),
driver->StrokeLine(BPoint(r.left,r.top),BPoint(r.left,r.bottom),
&layerdata,(int8*)&solidhigh);
layerdata.highcolor=frame_lowercol;
driver->StrokeLine(SPoint(r.right,r.bottom),SPoint(r.right,r.top),
driver->StrokeLine(BPoint(r.right,r.bottom),BPoint(r.right,r.top),
&layerdata,(int8*)&solidhigh);
layerdata.highcolor=frame_lowercol;
driver->StrokeLine(SPoint(r.right,r.bottom),SPoint(r.left,r.bottom),
driver->StrokeLine(BPoint(r.right,r.bottom),BPoint(r.left,r.bottom),
&layerdata,(int8*)&solidhigh);
r.InsetBy(1,1);
layerdata.highcolor=frame_highercol;
driver->StrokeLine(SPoint(r.left,r.top),SPoint(r.right-1,r.top),
driver->StrokeLine(BPoint(r.left,r.top),BPoint(r.right-1,r.top),
&layerdata,(int8*)&solidhigh);
layerdata.highcolor=frame_highercol;
driver->StrokeLine(SPoint(r.left,r.top),SPoint(r.left,r.bottom),
driver->StrokeLine(BPoint(r.left,r.top),BPoint(r.left,r.bottom),
&layerdata,(int8*)&solidhigh);
layerdata.highcolor=frame_midcol;
driver->StrokeLine(SPoint(r.right,r.bottom),SPoint(r.right,r.top),
driver->StrokeLine(BPoint(r.right,r.bottom),BPoint(r.right,r.top),
&layerdata,(int8*)&solidhigh);
layerdata.highcolor=frame_midcol;
driver->StrokeLine(SPoint(r.right,r.bottom),SPoint(r.left,r.bottom),
driver->StrokeLine(BPoint(r.right,r.bottom),BPoint(r.left,r.bottom),
&layerdata,(int8*)&solidhigh);
r.InsetBy(1,1);
@ -409,16 +409,16 @@ void BeDecorator::_DrawFrame(SRect rect)
r.InsetBy(1,1);
layerdata.highcolor=frame_lowercol;
driver->StrokeLine(SPoint(r.left,r.top),SPoint(r.right-1,r.top),
driver->StrokeLine(BPoint(r.left,r.top),BPoint(r.right-1,r.top),
&layerdata,(int8*)&solidhigh);
layerdata.highcolor=frame_lowercol;
driver->StrokeLine(SPoint(r.left,r.top),SPoint(r.left,r.bottom),
driver->StrokeLine(BPoint(r.left,r.top),BPoint(r.left,r.bottom),
&layerdata,(int8*)&solidhigh);
layerdata.highcolor=frame_highercol;
driver->StrokeLine(SPoint(r.right,r.bottom),SPoint(r.right,r.top),
driver->StrokeLine(BPoint(r.right,r.bottom),BPoint(r.right,r.top),
&layerdata,(int8*)&solidhigh);
layerdata.highcolor=frame_highercol;
driver->StrokeLine(SPoint(r.right,r.bottom),SPoint(r.left,r.bottom),
driver->StrokeLine(BPoint(r.right,r.bottom),BPoint(r.left,r.bottom),
&layerdata,(int8*)&solidhigh);
driver->StrokeRect(borderrect,&layerdata,(int8*)&solidhigh);
@ -452,14 +452,14 @@ void BeDecorator::_DrawFrame(SRect rect)
uint8(startcol.green-(i*gstep)),
uint8(startcol.blue-(i*bstep)));
driver->StrokeLine(SPoint(r.left,r.top+i),
SPoint(r.left+i,r.top),&layerdata,(int8*)&solidhigh);
driver->StrokeLine(BPoint(r.left,r.top+i),
BPoint(r.left+i,r.top),&layerdata,(int8*)&solidhigh);
layerdata.highcolor.SetColor(uint8(halfcol.red-(i*rstep)),
uint8(halfcol.green-(i*gstep)),
uint8(halfcol.blue-(i*bstep)));
driver->StrokeLine(SPoint(r.left+steps,r.top+i),
SPoint(r.left+i,r.top+steps),&layerdata,(int8*)&solidhigh);
driver->StrokeLine(BPoint(r.left+steps,r.top+i),
BPoint(r.left+i,r.top+steps),&layerdata,(int8*)&solidhigh);
}
layerdata.highcolor=frame_lowercol;
driver->StrokeRect(r,&layerdata,(int8*)&solidhigh);
@ -467,9 +467,9 @@ void BeDecorator::_DrawFrame(SRect rect)
else
{
layerdata.highcolor=frame_lowercol;
driver->StrokeLine(SPoint(r.right,r.top),SPoint(r.right-3,r.top),
driver->StrokeLine(BPoint(r.right,r.top),BPoint(r.right-3,r.top),
&layerdata,(int8*)&solidhigh);
driver->StrokeLine(SPoint(r.left,r.bottom),SPoint(r.left,r.bottom-3),
driver->StrokeLine(BPoint(r.left,r.bottom),BPoint(r.left,r.bottom-3),
&layerdata,(int8*)&solidhigh);
}
}
@ -480,7 +480,7 @@ extern "C" float get_decorator_version(void)
return 1.00;
}
extern "C" Decorator *instantiate_decorator(SRect rect, int32 wlook, int32 wfeel, int32 wflags)
extern "C" Decorator *instantiate_decorator(BRect rect, int32 wlook, int32 wfeel, int32 wflags)
{
return new BeDecorator(rect,wlook,wfeel,wflags);
}

View File

@ -2,33 +2,31 @@
#define _BEOS_DECORATOR_H_
#include "Decorator.h"
#include "SRect.h"
#include "SPoint.h"
class BeDecorator: public Decorator
{
public:
BeDecorator(SRect frame, int32 wlook, int32 wfeel, int32 wflags);
BeDecorator(BRect frame, int32 wlook, int32 wfeel, int32 wflags);
~BeDecorator(void);
void MoveBy(float x, float y);
void MoveBy(SPoint pt);
void MoveBy(BPoint pt);
// void ResizeBy(float x, float y);
// void ResizeBy(SPoint pt);
void Draw(SRect r);
// void ResizeBy(BPoint pt);
void Draw(BRect r);
void Draw(void);
//SRegion GetFootprint(void);
click_type Clicked(SPoint pt, int32 buttons, int32 modifiers);
click_type Clicked(BPoint pt, int32 buttons, int32 modifiers);
protected:
void _DrawClose(SRect r);
void _DrawFrame(SRect r);
void _DrawTab(SRect r);
void _DrawTitle(SRect r);
void _DrawZoom(SRect r);
void _DrawClose(BRect r);
void _DrawFrame(BRect r);
void _DrawTab(BRect r);
void _DrawTitle(BRect r);
void _DrawZoom(BRect r);
void _DoLayout(void);
void _SetFocus(void);
void DrawBlendedRect(SRect r, bool down);
void DrawBlendedRect(BRect r, bool down);
uint32 taboffset;
RGBColor tab_highcol, tab_lowcol;

View File

@ -1,7 +1,7 @@
#include "Decorator.h"
#include <string.h>
Decorator::Decorator(SRect rect, int32 wlook, int32 wfeel, int32 wflags)
Decorator::Decorator(BRect rect, int32 wlook, int32 wfeel, int32 wflags)
{
close_state=false;
minimize_state=false;
@ -149,7 +149,7 @@ void Decorator::MoveBy(float x, float y)
{
}
void Decorator::MoveBy(SPoint pt)
void Decorator::MoveBy(BPoint pt)
{
}
@ -157,11 +157,11 @@ void Decorator::ResizeBy(float x, float y)
{
}
void Decorator::ResizeBy(SPoint pt)
void Decorator::ResizeBy(BPoint pt)
{
}
void Decorator::Draw(SRect r)
void Decorator::Draw(BRect r)
{
_DrawTab(r & tabrect);
_DrawFrame(r & frame);
@ -207,27 +207,27 @@ void Decorator::DrawZoom(void)
_DrawZoom(zoomrect);
}
void Decorator::_DrawClose(SRect r)
void Decorator::_DrawClose(BRect r)
{
}
void Decorator::_DrawFrame(SRect r)
void Decorator::_DrawFrame(BRect r)
{
}
void Decorator::_DrawMinimize(SRect r)
void Decorator::_DrawMinimize(BRect r)
{
}
void Decorator::_DrawTab(SRect r)
void Decorator::_DrawTab(BRect r)
{
}
void Decorator::_DrawTitle(SRect r)
void Decorator::_DrawTitle(BRect r)
{
}
void Decorator::_DrawZoom(SRect r)
void Decorator::_DrawZoom(BRect r)
{
}
/*
@ -235,7 +235,7 @@ SRegion Decorator::GetFootprint(void)
{
}
*/
click_type Decorator::Clicked(SPoint pt, int32 buttons, int32 modifiers)
click_type Decorator::Clicked(BPoint pt, int32 buttons, int32 modifiers)
{
return CLICK_NONE;
}

View File

@ -2,7 +2,7 @@
#define _DECORATOR_H_
#include <SupportDefs.h>
#include "SRect.h"
#include <Rect.h>
#include "ColorSet.h"
#include "LayerData.h"
@ -54,7 +54,7 @@ typedef enum { CLICK_NONE=0, CLICK_ZOOM, CLICK_CLOSE, CLICK_MINIMIZE,
class Decorator
{
public:
Decorator(SRect rect, int32 wlook, int32 wfeel, int32 wflags);
Decorator(BRect rect, int32 wlook, int32 wfeel, int32 wflags);
virtual ~Decorator(void);
void SetColors(ColorSet cset);
void SetDriver(DisplayDriver *d);
@ -79,10 +79,10 @@ public:
ColorSet GetColors(void) { if(colors) return *colors; else return ColorSet(); }
virtual void MoveBy(float x, float y);
virtual void MoveBy(SPoint pt);
virtual void MoveBy(BPoint pt);
virtual void ResizeBy(float x, float y);
virtual void ResizeBy(SPoint pt);
virtual void Draw(SRect r);
virtual void ResizeBy(BPoint pt);
virtual void Draw(BRect r);
virtual void Draw(void);
virtual void DrawClose(void);
virtual void DrawFrame(void);
@ -91,22 +91,22 @@ public:
virtual void DrawTitle(void);
virtual void DrawZoom(void);
//virtual SRegion GetFootprint(void);
virtual click_type Clicked(SPoint pt, int32 buttons, int32 modifiers);
virtual click_type Clicked(BPoint pt, int32 buttons, int32 modifiers);
protected:
virtual void _DrawClose(SRect r);
virtual void _DrawFrame(SRect r);
virtual void _DrawMinimize(SRect r);
virtual void _DrawTab(SRect r);
virtual void _DrawTitle(SRect r);
virtual void _DrawZoom(SRect r);
virtual void _DrawClose(BRect r);
virtual void _DrawFrame(BRect r);
virtual void _DrawMinimize(BRect r);
virtual void _DrawTab(BRect r);
virtual void _DrawTitle(BRect r);
virtual void _DrawZoom(BRect r);
virtual void _SetFocus(void)=0;
virtual void _DoLayout(void)=0;
ColorSet *colors;
int32 look, feel, flags;
DisplayDriver *driver;
LayerData layerdata;
SRect zoomrect,closerect,minimizerect,tabrect,frame,
BRect zoomrect,closerect,minimizerect,tabrect,frame,
resizerect,borderrect;
private:
bool close_state, zoom_state, minimize_state;

View File

@ -5,8 +5,7 @@
#include <SupportDefs.h>
#include <OS.h>
#include "SRect.h"
#include "SPoint.h"
#include <Rect.h>
#include "RGBColor.h"
class ServerBitmap;
@ -64,30 +63,30 @@ public:
virtual ~DisplayDriver(void);
virtual bool Initialize(void);
virtual void Shutdown(void)=0;
virtual void CopyBits(SRect src, SRect dest)=0;
virtual void DrawBitmap(ServerBitmap *bmp, SRect src, SRect dest)=0;
virtual void DrawChar(char c, SPoint pt)=0;
// virtual void DrawPicture(SPicture *pic, SPoint pt)=0;
// virtual void DrawString(const char *string, int32 length, SPoint pt, escapement_delta *delta=NULL)=0;
virtual void InvertRect(SRect r)=0;
virtual void StrokeBezier(SPoint *pts, LayerData *d, int8 *pat)=0;
virtual void FillBezier(SPoint *pts, LayerData *d, int8 *pat)=0;
virtual void StrokeEllipse(SRect r, LayerData *d, int8 *pat)=0;
virtual void FillEllipse(SRect r, LayerData *d, int8 *pat)=0;
virtual void StrokeArc(SRect r, float angle, float span, LayerData *d, int8 *pat)=0;
virtual void FillArc(SRect r, float angle, float span, LayerData *d, int8 *pat)=0;
virtual void StrokeLine(SPoint start, SPoint end, LayerData *d, int8 *pat)=0;
virtual void StrokePolygon(SPoint *ptlist, int32 numpts, SRect rect, LayerData *d, int8 *pat, bool is_closed=true)=0;
virtual void FillPolygon(SPoint *ptlist, int32 numpts, SRect rect, LayerData *d, int8 *pat)=0;
virtual void StrokeRect(SRect r, LayerData *d, int8 *pat)=0;
virtual void FillRect(SRect r, LayerData *d, int8 *pat)=0;
virtual void StrokeRoundRect(SRect r, float xrad, float yrad, LayerData *d, int8 *pat)=0;
virtual void FillRoundRect(SRect r, float xrad, float yrad, LayerData *d, int8 *pat)=0;
virtual void CopyBits(BRect src, BRect dest)=0;
virtual void DrawBitmap(ServerBitmap *bmp, BRect src, BRect dest)=0;
virtual void DrawChar(char c, BPoint pt)=0;
// virtual void DrawPicture(SPicture *pic, BPoint pt)=0;
// virtual void DrawString(const char *string, int32 length, BPoint pt, escapement_delta *delta=NULL)=0;
virtual void InvertRect(BRect r)=0;
virtual void StrokeBezier(BPoint *pts, LayerData *d, int8 *pat)=0;
virtual void FillBezier(BPoint *pts, LayerData *d, int8 *pat)=0;
virtual void StrokeEllipse(BRect r, LayerData *d, int8 *pat)=0;
virtual void FillEllipse(BRect r, LayerData *d, int8 *pat)=0;
virtual void StrokeArc(BRect r, float angle, float span, LayerData *d, int8 *pat)=0;
virtual void FillArc(BRect r, float angle, float span, LayerData *d, int8 *pat)=0;
virtual void StrokeLine(BPoint start, BPoint end, LayerData *d, int8 *pat)=0;
virtual void StrokePolygon(BPoint *ptlist, int32 numpts, BRect rect, LayerData *d, int8 *pat, bool is_closed=true)=0;
virtual void FillPolygon(BPoint *ptlist, int32 numpts, BRect rect, LayerData *d, int8 *pat)=0;
virtual void StrokeRect(BRect r, LayerData *d, int8 *pat)=0;
virtual void FillRect(BRect r, LayerData *d, int8 *pat)=0;
virtual void StrokeRoundRect(BRect r, float xrad, float yrad, LayerData *d, int8 *pat)=0;
virtual void FillRoundRect(BRect r, float xrad, float yrad, LayerData *d, int8 *pat)=0;
// virtual void StrokeShape(SShape *sh, LayerData *d, int8 *pat)=0;
// virtual void FillShape(SShape *sh, LayerData *d, int8 *pat)=0;
virtual void StrokeTriangle(SPoint *pts, SRect r, LayerData *d, int8 *pat)=0;
virtual void FillTriangle(SPoint *pts, SRect r, LayerData *d, int8 *pat)=0;
virtual void StrokeLineArray(SPoint *pts, int32 numlines, RGBColor *colors, LayerData *d)=0;
virtual void StrokeTriangle(BPoint *pts, BRect r, LayerData *d, int8 *pat)=0;
virtual void FillTriangle(BPoint *pts, BRect r, LayerData *d, int8 *pat)=0;
virtual void StrokeLineArray(BPoint *pts, int32 numlines, RGBColor *colors, LayerData *d)=0;
virtual void SetMode(int32 mode)=0;
virtual bool DumpToFile(const char *path)=0;

View File

@ -7,6 +7,4 @@ Addon BeDecorator : decorators :
Decorator.cpp
DisplayDriver.cpp
RGBColor.cpp
SPoint.cpp
SRect.cpp
;

View File

@ -1,6 +1,7 @@
#ifndef LAYERDATA_H_
#define LAYERDATA_H_
#include <Point.h>
class ServerBitmap;
class LayerData
@ -21,7 +22,7 @@ LayerData(void)
};
float pensize;
SPoint penlocation;
BPoint penlocation;
int32 drawing_mode;
ServerBitmap *bitmap_background;
ServerBitmap *bitmap_overlay;

View File

@ -1,92 +0,0 @@
/*
SPoint.cpp:
Point class which utilizes Frans van Nispen's original SPoint sources
and extends them slightly for app_server use.
*/
#include <math.h>
#include <stdio.h>
#include <BeBuild.h>
#include <SupportDefs.h>
#include "SPoint.h"
#include "SRect.h"
void SPoint::ConstrainTo(SRect r)
{
x = max_c(min_c(x, r.right), r.left);
y = max_c(min_c(y, r.bottom), r.top);
}
void SPoint::PrintToStream() const
{
printf("SPoint(x:%.0f, y:%.0f)\n", x, y);
}
SPoint SPoint::operator+(const SPoint& p) const
{
return SPoint(x + p.x, y + p.y);
}
SPoint SPoint::operator-(const SPoint& p) const
{
return SPoint(x - p.x, y - p.y);
}
SPoint SPoint::operator*(const SPoint& p) const
{
return SPoint(x * p.x, y * p.y);
}
SPoint SPoint::operator/(const SPoint& p) const
{
return SPoint((p.x!=0)?(x / p.x):0,(p.y!=0)?(y / p.y):0);
}
SPoint& SPoint::operator+=(const SPoint& p)
{
x += p.x;
y += p.y;
return *this;
}
SPoint& SPoint::operator-=(const SPoint& p)
{
x -= p.x;
y -= p.y;
return *this;
}
bool SPoint::operator!=(const SPoint& p) const
{
return x != p.x || y != p.y;
}
bool SPoint::operator==(const SPoint& p) const
{
return x == p.x && y == p.y;
}
bool SPoint::operator<=(const SPoint& p) const
{
return x <= p.x && y <= p.y;
}
bool SPoint::operator>=(const SPoint& p) const
{
return x >= p.x && y >= p.y;
}
bool SPoint::operator<(const SPoint& p) const
{
return x < p.x || y < p.y;
}
bool SPoint::operator>(const SPoint& p) const
{
return x > p.x && y > p.y;
}

View File

@ -1,80 +0,0 @@
#ifndef _SPOINT_H
#define _SPOINT_H
#include <BeBuild.h>
#include <SupportDefs.h>
class SRect;
/*
#ifndef BE_SUPPORT
#define BE_SUPPORT
#endif
*/
#ifdef BE_SUPPORT
#include <Rect.h>
#include <Point.h>
#endif
class SPoint
{
public:
float x;
float y;
SPoint();
SPoint(float X, float Y);
SPoint(const SPoint &p);
SPoint &operator=(const SPoint &p);
void Set(float X, float Y);
void ConstrainTo(SRect r);
void PrintToStream() const;
SPoint operator+(const SPoint &p) const;
SPoint operator-(const SPoint &p) const;
SPoint operator*(const SPoint &p) const;
SPoint operator/(const SPoint &p) const;
SPoint& operator+=(const SPoint &p);
SPoint& operator-=(const SPoint &p);
bool operator!=(const SPoint &p) const;
bool operator==(const SPoint &p) const;
bool operator>=(const SPoint &p) const;
bool operator<=(const SPoint &p) const;
bool operator>(const SPoint &p) const;
bool operator<(const SPoint &p) const;
#ifdef BE_SUPPORT
BPoint Point(void) { return BPoint(x,y); };
#endif
};
inline SPoint::SPoint()
{
x = y = 0;
}
inline SPoint::SPoint(float X, float Y)
{
x = X;
y = Y;
}
inline SPoint::SPoint(const SPoint& pt)
{
x = pt.x;
y = pt.y;
}
inline SPoint &SPoint::operator=(const SPoint& from)
{
x = from.x;
y = from.y;
return *this;
}
inline void SPoint::Set(float X, float Y)
{
x = X;
y = Y;
}
#endif

View File

@ -1,205 +0,0 @@
/*
SPoint.cpp:
Point class which utilizes Frans van Nispen's original SPoint sources
and extends them slightly for app_server use.
*/
#include <stdio.h>
#include "SRect.h"
bool TestLineIntersect(const SRect& r, float x1, float y1, float x2, float y2,
bool vertical = true);
void SRect::InsetBy(SPoint p)
{
left += p.x;
right -= p.x;
top += p.y;
bottom -= p.y;
}
void SRect::InsetBy(float dx, float dy)
{
left += dx;
right -= dx;
top += dy;
bottom -= dy;
}
SRect& SRect::InsetBySelf(SPoint p)
{
this->InsetBy(p);
return *this;
}
SRect& SRect::InsetBySelf(float dx, float dy)
{
this->InsetBy(dx, dy);
return *this;
}
SRect SRect::InsetByCopy(SPoint p)
{
SRect copy(*this);
copy.InsetBy(p);
return copy;
}
SRect SRect::InsetByCopy(float dx, float dy)
{
SRect copy(*this);
copy.InsetBy(dx, dy);
return copy;
}
void SRect::OffsetBy(SPoint p)
{
left += p.x;
right += p.x;
top += p.y;
bottom += p.y;
}
void SRect::OffsetBy(float dx, float dy)
{
left += dx;
right += dx;
top += dy;
bottom += dy;
}
SRect& SRect::OffsetBySelf(SPoint p)
{
this->OffsetBy(p);
return *this;
}
SRect& SRect::OffsetBySelf(float dx, float dy)
{
this->OffsetBy(dx, dy);
return *this;
}
SRect SRect::OffsetByCopy(SPoint p)
{
SRect copy(*this);
copy.OffsetBy(p);
return copy;
}
SRect SRect::OffsetByCopy(float dx, float dy)
{
SRect copy(*this);
copy.OffsetBy(dx, dy);
return copy;
}
void SRect::OffsetTo(SPoint p)
{
right = (right - left) + p.x;
left = p.x;
bottom = (bottom - top) + p.y;
top = p.y;
}
void SRect::OffsetTo(float x, float y)
{
right = (right - left) + x;
left = x;
bottom = (bottom - top) + y;
top=y;
}
SRect& SRect::OffsetToSelf(SPoint p)
{
this->OffsetTo(p);
return *this;
}
SRect& SRect::OffsetToSelf(float dx, float dy)
{
this->OffsetTo(dx, dy);
return *this;
}
SRect SRect::OffsetToCopy(SPoint p)
{
SRect copy(*this);
copy.OffsetTo(p);
return copy;
}
SRect SRect::OffsetToCopy(float dx, float dy)
{
SRect copy(*this);
copy.OffsetTo(dx, dy);
return copy;
}
void SRect::PrintToStream() const
{
printf("(l:%.1f t:%.1f r:%.1f b:%.1f)\n", left, top, right, bottom);
}
bool SRect::operator==(SRect r) const
{
return left == r.left && right == r.right &&
top == r.top && bottom == r.bottom;
}
bool SRect::operator!=(SRect r) const
{
return !(*this == r);
}
SRect SRect::operator&(SRect r) const
{
return SRect(max_c(left, r.left), max_c(top, r.top),
min_c(right, r.right), min_c(bottom, r.bottom));
}
SRect SRect::operator|(SRect r) const
{
return SRect(min_c(left, r.left), min_c(top, r.top),
max_c(right, r.right), max_c(bottom, r.bottom));
}
bool SRect::Intersects(SRect r) const
{
return TestLineIntersect(*this, r.left, r.top, r.left, r.bottom) ||
TestLineIntersect(*this, r.left, r.top, r.right, r.top, false) ||
TestLineIntersect(*this, r.right, r.top, r.right, r.bottom) ||
TestLineIntersect(*this, r.left, r.bottom, r.right, r.bottom, false);
}
bool SRect::Contains(SPoint p) const
{
return p.x >= left && p.x <= right && p.y >= top && p.y <= bottom;
}
bool SRect::Contains(SRect r) const
{
return r.left >= left && r.right <= right &&
r.top >= top && r.bottom <= bottom;
}
bool TestLineIntersect(const SRect& r, float x1, float y1, float x2, float y2,
bool vertical)
{
if (vertical)
{
return (x1 >= r.left && x1 <= r.right) &&
((y1 >= r.top && y1 <= r.bottom) ||
(y2 >= r.top && y2 <= r.bottom));
}
else
{
return (y1 >= r.top && y1 <= r.bottom) &&
((x1 >= r.left && x1 <= r.right) ||
(x2 >= r.left && x2 <= r.right));
}
}

View File

@ -1,188 +0,0 @@
#ifndef _SRECT_H_
#define _SRECT_H_
// define used when this class also needs to support BRects
/*
#ifndef BE_SUPPORT
#define BE_SUPPORT
#endif
*/
#include <math.h>
#include <SupportDefs.h>
#include "SPoint.h"
#ifdef BE_SUPPORT
#include <Rect.h>
#endif
class SRect
{
public:
float left;
float top;
float right;
float bottom;
SRect();
SRect(const SRect &r);
SRect(float l, float t, float r, float b);
SRect(SPoint lt, SPoint rb);
SRect &operator=(const SRect &r);
void Set(float l, float t, float r, float b);
void PrintToStream() const;
SPoint LeftTop() const;
SPoint RightBottom() const;
SPoint LeftBottom() const;
SPoint RightTop() const;
void SetLeftTop(const SPoint p);
void SetRightBottom(const SPoint p);
void SetLeftBottom(const SPoint p);
void SetRightTop(const SPoint p);
// transformation
void InsetBy(SPoint p);
void InsetBy(float dx, float dy);
void OffsetBy(SPoint p);
void OffsetBy(float dx, float dy);
void OffsetTo(SPoint p);
void OffsetTo(float x, float y);
// expression transformations
SRect & InsetBySelf(SPoint);
SRect & InsetBySelf(float dx, float dy);
SRect InsetByCopy(SPoint);
SRect InsetByCopy(float dx, float dy);
SRect & OffsetBySelf(SPoint);
SRect & OffsetBySelf(float dx, float dy);
SRect OffsetByCopy(SPoint);
SRect OffsetByCopy(float dx, float dy);
SRect & OffsetToSelf(SPoint);
SRect & OffsetToSelf(float dx, float dy);
SRect OffsetToCopy(SPoint);
SRect OffsetToCopy(float dx, float dy);
// comparison
bool operator==(SRect r) const;
bool operator!=(SRect r) const;
// intersection and union
SRect operator&(SRect r) const;
SRect operator|(SRect r) const;
bool Intersects(SRect r) const;
bool IsValid() const;
float Width() const;
int32 IntegerWidth() const;
float Height() const;
int32 IntegerHeight() const;
bool Contains(SPoint p) const;
bool Contains(SRect r) const;
#ifdef BE_SUPPORT
BRect Rect(void) { return BRect(left,top,right,bottom); };
#endif
};
// inline definitions ----------------------------------------------------------
inline SPoint SRect::LeftTop() const
{
return(*((const SPoint*)&left));
}
inline SPoint SRect::RightBottom() const
{
return(*((const SPoint*)&right));
}
inline SPoint SRect::LeftBottom() const
{
return(SPoint(left, bottom));
}
inline SPoint SRect::RightTop() const
{
return(SPoint(right, top));
}
inline SRect::SRect()
{
top = left = 0;
bottom = right = -1;
}
inline SRect::SRect(float l, float t, float r, float b)
{
left = l;
top = t;
right = r;
bottom = b;
}
inline SRect::SRect(const SRect &r)
{
left = r.left;
top = r.top;
right = r.right;
bottom = r.bottom;
}
inline SRect::SRect(SPoint leftTop, SPoint rightBottom)
{
left = leftTop.x;
top = leftTop.y;
right = rightBottom.x;
bottom = rightBottom.y;
}
inline SRect &SRect::operator=(const SRect& from)
{
left = from.left;
top = from.top;
right = from.right;
bottom = from.bottom;
return *this;
}
inline void SRect::Set(float l, float t, float r, float b)
{
left = l;
top = t;
right = r;
bottom = b;
}
inline bool SRect::IsValid() const
{
if (left <= right && top <= bottom)
return true;
else
return false;
}
inline int32 SRect::IntegerWidth() const
{
return((int32)ceil(right - left));
}
inline float SRect::Width() const
{
return(right - left);
}
inline int32 SRect::IntegerHeight() const
{
return((int32)ceil(bottom - top));
}
inline float SRect::Height() const
{
return(bottom - top);
}
#endif

View File

@ -1,7 +1,7 @@
#include "Decorator.h"
#include <string.h>
Decorator::Decorator(SRect rect, int32 wlook, int32 wfeel, int32 wflags)
Decorator::Decorator(BRect rect, int32 wlook, int32 wfeel, int32 wflags)
{
close_state=false;
minimize_state=false;
@ -149,7 +149,7 @@ void Decorator::MoveBy(float x, float y)
{
}
void Decorator::MoveBy(SPoint pt)
void Decorator::MoveBy(BPoint pt)
{
}
@ -157,11 +157,11 @@ void Decorator::ResizeBy(float x, float y)
{
}
void Decorator::ResizeBy(SPoint pt)
void Decorator::ResizeBy(BPoint pt)
{
}
void Decorator::Draw(SRect r)
void Decorator::Draw(BRect r)
{
_DrawTab(r & tabrect);
_DrawFrame(r & frame);
@ -207,27 +207,27 @@ void Decorator::DrawZoom(void)
_DrawZoom(zoomrect);
}
void Decorator::_DrawClose(SRect r)
void Decorator::_DrawClose(BRect r)
{
}
void Decorator::_DrawFrame(SRect r)
void Decorator::_DrawFrame(BRect r)
{
}
void Decorator::_DrawMinimize(SRect r)
void Decorator::_DrawMinimize(BRect r)
{
}
void Decorator::_DrawTab(SRect r)
void Decorator::_DrawTab(BRect r)
{
}
void Decorator::_DrawTitle(SRect r)
void Decorator::_DrawTitle(BRect r)
{
}
void Decorator::_DrawZoom(SRect r)
void Decorator::_DrawZoom(BRect r)
{
}
/*
@ -235,7 +235,7 @@ SRegion Decorator::GetFootprint(void)
{
}
*/
click_type Decorator::Clicked(SPoint pt, int32 buttons, int32 modifiers)
click_type Decorator::Clicked(BPoint pt, int32 buttons, int32 modifiers)
{
return CLICK_NONE;
}

View File

@ -2,7 +2,7 @@
#define _DECORATOR_H_
#include <SupportDefs.h>
#include "SRect.h"
#include <Rect.h>
#include "ColorSet.h"
#include "LayerData.h"
@ -54,7 +54,7 @@ typedef enum { CLICK_NONE=0, CLICK_ZOOM, CLICK_CLOSE, CLICK_MINIMIZE,
class Decorator
{
public:
Decorator(SRect rect, int32 wlook, int32 wfeel, int32 wflags);
Decorator(BRect rect, int32 wlook, int32 wfeel, int32 wflags);
virtual ~Decorator(void);
void SetColors(ColorSet cset);
void SetDriver(DisplayDriver *d);
@ -79,10 +79,10 @@ public:
ColorSet GetColors(void) { if(colors) return *colors; else return ColorSet(); }
virtual void MoveBy(float x, float y);
virtual void MoveBy(SPoint pt);
virtual void MoveBy(BPoint pt);
virtual void ResizeBy(float x, float y);
virtual void ResizeBy(SPoint pt);
virtual void Draw(SRect r);
virtual void ResizeBy(BPoint pt);
virtual void Draw(BRect r);
virtual void Draw(void);
virtual void DrawClose(void);
virtual void DrawFrame(void);
@ -91,22 +91,22 @@ public:
virtual void DrawTitle(void);
virtual void DrawZoom(void);
//virtual SRegion GetFootprint(void);
virtual click_type Clicked(SPoint pt, int32 buttons, int32 modifiers);
virtual click_type Clicked(BPoint pt, int32 buttons, int32 modifiers);
protected:
virtual void _DrawClose(SRect r);
virtual void _DrawFrame(SRect r);
virtual void _DrawMinimize(SRect r);
virtual void _DrawTab(SRect r);
virtual void _DrawTitle(SRect r);
virtual void _DrawZoom(SRect r);
virtual void _DrawClose(BRect r);
virtual void _DrawFrame(BRect r);
virtual void _DrawMinimize(BRect r);
virtual void _DrawTab(BRect r);
virtual void _DrawTitle(BRect r);
virtual void _DrawZoom(BRect r);
virtual void _SetFocus(void)=0;
virtual void _DoLayout(void)=0;
ColorSet *colors;
int32 look, feel, flags;
DisplayDriver *driver;
LayerData layerdata;
SRect zoomrect,closerect,minimizerect,tabrect,frame,
BRect zoomrect,closerect,minimizerect,tabrect,frame,
resizerect,borderrect;
private:
bool close_state, zoom_state, minimize_state;

View File

@ -5,8 +5,7 @@
#include <SupportDefs.h>
#include <OS.h>
#include "SRect.h"
#include "SPoint.h"
#include <Rect.h>
#include "RGBColor.h"
class ServerBitmap;
@ -64,30 +63,30 @@ public:
virtual ~DisplayDriver(void);
virtual bool Initialize(void);
virtual void Shutdown(void)=0;
virtual void CopyBits(SRect src, SRect dest)=0;
virtual void DrawBitmap(ServerBitmap *bmp, SRect src, SRect dest)=0;
virtual void DrawChar(char c, SPoint pt)=0;
// virtual void DrawPicture(SPicture *pic, SPoint pt)=0;
// virtual void DrawString(const char *string, int32 length, SPoint pt, escapement_delta *delta=NULL)=0;
virtual void InvertRect(SRect r)=0;
virtual void StrokeBezier(SPoint *pts, LayerData *d, int8 *pat)=0;
virtual void FillBezier(SPoint *pts, LayerData *d, int8 *pat)=0;
virtual void StrokeEllipse(SRect r, LayerData *d, int8 *pat)=0;
virtual void FillEllipse(SRect r, LayerData *d, int8 *pat)=0;
virtual void StrokeArc(SRect r, float angle, float span, LayerData *d, int8 *pat)=0;
virtual void FillArc(SRect r, float angle, float span, LayerData *d, int8 *pat)=0;
virtual void StrokeLine(SPoint start, SPoint end, LayerData *d, int8 *pat)=0;
virtual void StrokePolygon(SPoint *ptlist, int32 numpts, SRect rect, LayerData *d, int8 *pat, bool is_closed=true)=0;
virtual void FillPolygon(SPoint *ptlist, int32 numpts, SRect rect, LayerData *d, int8 *pat)=0;
virtual void StrokeRect(SRect r, LayerData *d, int8 *pat)=0;
virtual void FillRect(SRect r, LayerData *d, int8 *pat)=0;
virtual void StrokeRoundRect(SRect r, float xrad, float yrad, LayerData *d, int8 *pat)=0;
virtual void FillRoundRect(SRect r, float xrad, float yrad, LayerData *d, int8 *pat)=0;
virtual void CopyBits(BRect src, BRect dest)=0;
virtual void DrawBitmap(ServerBitmap *bmp, BRect src, BRect dest)=0;
virtual void DrawChar(char c, BPoint pt)=0;
// virtual void DrawPicture(SPicture *pic, BPoint pt)=0;
// virtual void DrawString(const char *string, int32 length, BPoint pt, escapement_delta *delta=NULL)=0;
virtual void InvertRect(BRect r)=0;
virtual void StrokeBezier(BPoint *pts, LayerData *d, int8 *pat)=0;
virtual void FillBezier(BPoint *pts, LayerData *d, int8 *pat)=0;
virtual void StrokeEllipse(BRect r, LayerData *d, int8 *pat)=0;
virtual void FillEllipse(BRect r, LayerData *d, int8 *pat)=0;
virtual void StrokeArc(BRect r, float angle, float span, LayerData *d, int8 *pat)=0;
virtual void FillArc(BRect r, float angle, float span, LayerData *d, int8 *pat)=0;
virtual void StrokeLine(BPoint start, BPoint end, LayerData *d, int8 *pat)=0;
virtual void StrokePolygon(BPoint *ptlist, int32 numpts, BRect rect, LayerData *d, int8 *pat, bool is_closed=true)=0;
virtual void FillPolygon(BPoint *ptlist, int32 numpts, BRect rect, LayerData *d, int8 *pat)=0;
virtual void StrokeRect(BRect r, LayerData *d, int8 *pat)=0;
virtual void FillRect(BRect r, LayerData *d, int8 *pat)=0;
virtual void StrokeRoundRect(BRect r, float xrad, float yrad, LayerData *d, int8 *pat)=0;
virtual void FillRoundRect(BRect r, float xrad, float yrad, LayerData *d, int8 *pat)=0;
// virtual void StrokeShape(SShape *sh, LayerData *d, int8 *pat)=0;
// virtual void FillShape(SShape *sh, LayerData *d, int8 *pat)=0;
virtual void StrokeTriangle(SPoint *pts, SRect r, LayerData *d, int8 *pat)=0;
virtual void FillTriangle(SPoint *pts, SRect r, LayerData *d, int8 *pat)=0;
virtual void StrokeLineArray(SPoint *pts, int32 numlines, RGBColor *colors, LayerData *d)=0;
virtual void StrokeTriangle(BPoint *pts, BRect r, LayerData *d, int8 *pat)=0;
virtual void FillTriangle(BPoint *pts, BRect r, LayerData *d, int8 *pat)=0;
virtual void StrokeLineArray(BPoint *pts, int32 numlines, RGBColor *colors, LayerData *d)=0;
virtual void SetMode(int32 mode)=0;
virtual bool DumpToFile(const char *path)=0;

View File

@ -7,6 +7,4 @@ Addon WinDecorator : decorators :
Decorator.cpp
DisplayDriver.cpp
RGBColor.cpp
SPoint.cpp
SRect.cpp
;

View File

@ -1,6 +1,7 @@
#ifndef LAYERDATA_H_
#define LAYERDATA_H_
#include <Point.h>
class ServerBitmap;
class LayerData
@ -21,7 +22,7 @@ LayerData(void)
};
float pensize;
SPoint penlocation;
BPoint penlocation;
int32 drawing_mode;
ServerBitmap *bitmap_background;
ServerBitmap *bitmap_overlay;

View File

@ -1,92 +0,0 @@
/*
SPoint.cpp:
Point class which utilizes Frans van Nispen's original SPoint sources
and extends them slightly for app_server use.
*/
#include <math.h>
#include <stdio.h>
#include <BeBuild.h>
#include <SupportDefs.h>
#include "SPoint.h"
#include "SRect.h"
void SPoint::ConstrainTo(SRect r)
{
x = max_c(min_c(x, r.right), r.left);
y = max_c(min_c(y, r.bottom), r.top);
}
void SPoint::PrintToStream() const
{
printf("SPoint(x:%.0f, y:%.0f)\n", x, y);
}
SPoint SPoint::operator+(const SPoint& p) const
{
return SPoint(x + p.x, y + p.y);
}
SPoint SPoint::operator-(const SPoint& p) const
{
return SPoint(x - p.x, y - p.y);
}
SPoint SPoint::operator*(const SPoint& p) const
{
return SPoint(x * p.x, y * p.y);
}
SPoint SPoint::operator/(const SPoint& p) const
{
return SPoint((p.x!=0)?(x / p.x):0,(p.y!=0)?(y / p.y):0);
}
SPoint& SPoint::operator+=(const SPoint& p)
{
x += p.x;
y += p.y;
return *this;
}
SPoint& SPoint::operator-=(const SPoint& p)
{
x -= p.x;
y -= p.y;
return *this;
}
bool SPoint::operator!=(const SPoint& p) const
{
return x != p.x || y != p.y;
}
bool SPoint::operator==(const SPoint& p) const
{
return x == p.x && y == p.y;
}
bool SPoint::operator<=(const SPoint& p) const
{
return x <= p.x && y <= p.y;
}
bool SPoint::operator>=(const SPoint& p) const
{
return x >= p.x && y >= p.y;
}
bool SPoint::operator<(const SPoint& p) const
{
return x < p.x || y < p.y;
}
bool SPoint::operator>(const SPoint& p) const
{
return x > p.x && y > p.y;
}

View File

@ -1,80 +0,0 @@
#ifndef _SPOINT_H
#define _SPOINT_H
#include <BeBuild.h>
#include <SupportDefs.h>
class SRect;
/*
#ifndef BE_SUPPORT
#define BE_SUPPORT
#endif
*/
#ifdef BE_SUPPORT
#include <Rect.h>
#include <Point.h>
#endif
class SPoint
{
public:
float x;
float y;
SPoint();
SPoint(float X, float Y);
SPoint(const SPoint &p);
SPoint &operator=(const SPoint &p);
void Set(float X, float Y);
void ConstrainTo(SRect r);
void PrintToStream() const;
SPoint operator+(const SPoint &p) const;
SPoint operator-(const SPoint &p) const;
SPoint operator*(const SPoint &p) const;
SPoint operator/(const SPoint &p) const;
SPoint& operator+=(const SPoint &p);
SPoint& operator-=(const SPoint &p);
bool operator!=(const SPoint &p) const;
bool operator==(const SPoint &p) const;
bool operator>=(const SPoint &p) const;
bool operator<=(const SPoint &p) const;
bool operator>(const SPoint &p) const;
bool operator<(const SPoint &p) const;
#ifdef BE_SUPPORT
BPoint Point(void) { return BPoint(x,y); };
#endif
};
inline SPoint::SPoint()
{
x = y = 0;
}
inline SPoint::SPoint(float X, float Y)
{
x = X;
y = Y;
}
inline SPoint::SPoint(const SPoint& pt)
{
x = pt.x;
y = pt.y;
}
inline SPoint &SPoint::operator=(const SPoint& from)
{
x = from.x;
y = from.y;
return *this;
}
inline void SPoint::Set(float X, float Y)
{
x = X;
y = Y;
}
#endif

View File

@ -1,205 +0,0 @@
/*
SPoint.cpp:
Point class which utilizes Frans van Nispen's original SPoint sources
and extends them slightly for app_server use.
*/
#include <stdio.h>
#include "SRect.h"
bool TestLineIntersect(const SRect& r, float x1, float y1, float x2, float y2,
bool vertical = true);
void SRect::InsetBy(SPoint p)
{
left += p.x;
right -= p.x;
top += p.y;
bottom -= p.y;
}
void SRect::InsetBy(float dx, float dy)
{
left += dx;
right -= dx;
top += dy;
bottom -= dy;
}
SRect& SRect::InsetBySelf(SPoint p)
{
this->InsetBy(p);
return *this;
}
SRect& SRect::InsetBySelf(float dx, float dy)
{
this->InsetBy(dx, dy);
return *this;
}
SRect SRect::InsetByCopy(SPoint p)
{
SRect copy(*this);
copy.InsetBy(p);
return copy;
}
SRect SRect::InsetByCopy(float dx, float dy)
{
SRect copy(*this);
copy.InsetBy(dx, dy);
return copy;
}
void SRect::OffsetBy(SPoint p)
{
left += p.x;
right += p.x;
top += p.y;
bottom += p.y;
}
void SRect::OffsetBy(float dx, float dy)
{
left += dx;
right += dx;
top += dy;
bottom += dy;
}
SRect& SRect::OffsetBySelf(SPoint p)
{
this->OffsetBy(p);
return *this;
}
SRect& SRect::OffsetBySelf(float dx, float dy)
{
this->OffsetBy(dx, dy);
return *this;
}
SRect SRect::OffsetByCopy(SPoint p)
{
SRect copy(*this);
copy.OffsetBy(p);
return copy;
}
SRect SRect::OffsetByCopy(float dx, float dy)
{
SRect copy(*this);
copy.OffsetBy(dx, dy);
return copy;
}
void SRect::OffsetTo(SPoint p)
{
right = (right - left) + p.x;
left = p.x;
bottom = (bottom - top) + p.y;
top = p.y;
}
void SRect::OffsetTo(float x, float y)
{
right = (right - left) + x;
left = x;
bottom = (bottom - top) + y;
top=y;
}
SRect& SRect::OffsetToSelf(SPoint p)
{
this->OffsetTo(p);
return *this;
}
SRect& SRect::OffsetToSelf(float dx, float dy)
{
this->OffsetTo(dx, dy);
return *this;
}
SRect SRect::OffsetToCopy(SPoint p)
{
SRect copy(*this);
copy.OffsetTo(p);
return copy;
}
SRect SRect::OffsetToCopy(float dx, float dy)
{
SRect copy(*this);
copy.OffsetTo(dx, dy);
return copy;
}
void SRect::PrintToStream() const
{
printf("(l:%.1f t:%.1f r:%.1f b:%.1f)\n", left, top, right, bottom);
}
bool SRect::operator==(SRect r) const
{
return left == r.left && right == r.right &&
top == r.top && bottom == r.bottom;
}
bool SRect::operator!=(SRect r) const
{
return !(*this == r);
}
SRect SRect::operator&(SRect r) const
{
return SRect(max_c(left, r.left), max_c(top, r.top),
min_c(right, r.right), min_c(bottom, r.bottom));
}
SRect SRect::operator|(SRect r) const
{
return SRect(min_c(left, r.left), min_c(top, r.top),
max_c(right, r.right), max_c(bottom, r.bottom));
}
bool SRect::Intersects(SRect r) const
{
return TestLineIntersect(*this, r.left, r.top, r.left, r.bottom) ||
TestLineIntersect(*this, r.left, r.top, r.right, r.top, false) ||
TestLineIntersect(*this, r.right, r.top, r.right, r.bottom) ||
TestLineIntersect(*this, r.left, r.bottom, r.right, r.bottom, false);
}
bool SRect::Contains(SPoint p) const
{
return p.x >= left && p.x <= right && p.y >= top && p.y <= bottom;
}
bool SRect::Contains(SRect r) const
{
return r.left >= left && r.right <= right &&
r.top >= top && r.bottom <= bottom;
}
bool TestLineIntersect(const SRect& r, float x1, float y1, float x2, float y2,
bool vertical)
{
if (vertical)
{
return (x1 >= r.left && x1 <= r.right) &&
((y1 >= r.top && y1 <= r.bottom) ||
(y2 >= r.top && y2 <= r.bottom));
}
else
{
return (y1 >= r.top && y1 <= r.bottom) &&
((x1 >= r.left && x1 <= r.right) ||
(x2 >= r.left && x2 <= r.right));
}
}

View File

@ -1,188 +0,0 @@
#ifndef _SRECT_H_
#define _SRECT_H_
// define used when this class also needs to support BRects
/*
#ifndef BE_SUPPORT
#define BE_SUPPORT
#endif
*/
#include <math.h>
#include <SupportDefs.h>
#include "SPoint.h"
#ifdef BE_SUPPORT
#include <Rect.h>
#endif
class SRect
{
public:
float left;
float top;
float right;
float bottom;
SRect();
SRect(const SRect &r);
SRect(float l, float t, float r, float b);
SRect(SPoint lt, SPoint rb);
SRect &operator=(const SRect &r);
void Set(float l, float t, float r, float b);
void PrintToStream() const;
SPoint LeftTop() const;
SPoint RightBottom() const;
SPoint LeftBottom() const;
SPoint RightTop() const;
void SetLeftTop(const SPoint p);
void SetRightBottom(const SPoint p);
void SetLeftBottom(const SPoint p);
void SetRightTop(const SPoint p);
// transformation
void InsetBy(SPoint p);
void InsetBy(float dx, float dy);
void OffsetBy(SPoint p);
void OffsetBy(float dx, float dy);
void OffsetTo(SPoint p);
void OffsetTo(float x, float y);
// expression transformations
SRect & InsetBySelf(SPoint);
SRect & InsetBySelf(float dx, float dy);
SRect InsetByCopy(SPoint);
SRect InsetByCopy(float dx, float dy);
SRect & OffsetBySelf(SPoint);
SRect & OffsetBySelf(float dx, float dy);
SRect OffsetByCopy(SPoint);
SRect OffsetByCopy(float dx, float dy);
SRect & OffsetToSelf(SPoint);
SRect & OffsetToSelf(float dx, float dy);
SRect OffsetToCopy(SPoint);
SRect OffsetToCopy(float dx, float dy);
// comparison
bool operator==(SRect r) const;
bool operator!=(SRect r) const;
// intersection and union
SRect operator&(SRect r) const;
SRect operator|(SRect r) const;
bool Intersects(SRect r) const;
bool IsValid() const;
float Width() const;
int32 IntegerWidth() const;
float Height() const;
int32 IntegerHeight() const;
bool Contains(SPoint p) const;
bool Contains(SRect r) const;
#ifdef BE_SUPPORT
BRect Rect(void) { return BRect(left,top,right,bottom); };
#endif
};
// inline definitions ----------------------------------------------------------
inline SPoint SRect::LeftTop() const
{
return(*((const SPoint*)&left));
}
inline SPoint SRect::RightBottom() const
{
return(*((const SPoint*)&right));
}
inline SPoint SRect::LeftBottom() const
{
return(SPoint(left, bottom));
}
inline SPoint SRect::RightTop() const
{
return(SPoint(right, top));
}
inline SRect::SRect()
{
top = left = 0;
bottom = right = -1;
}
inline SRect::SRect(float l, float t, float r, float b)
{
left = l;
top = t;
right = r;
bottom = b;
}
inline SRect::SRect(const SRect &r)
{
left = r.left;
top = r.top;
right = r.right;
bottom = r.bottom;
}
inline SRect::SRect(SPoint leftTop, SPoint rightBottom)
{
left = leftTop.x;
top = leftTop.y;
right = rightBottom.x;
bottom = rightBottom.y;
}
inline SRect &SRect::operator=(const SRect& from)
{
left = from.left;
top = from.top;
right = from.right;
bottom = from.bottom;
return *this;
}
inline void SRect::Set(float l, float t, float r, float b)
{
left = l;
top = t;
right = r;
bottom = b;
}
inline bool SRect::IsValid() const
{
if (left <= right && top <= bottom)
return true;
else
return false;
}
inline int32 SRect::IntegerWidth() const
{
return((int32)ceil(right - left));
}
inline float SRect::Width() const
{
return(right - left);
}
inline int32 SRect::IntegerHeight() const
{
return((int32)ceil(bottom - top));
}
inline float SRect::Height() const
{
return(bottom - top);
}
#endif

View File

@ -11,7 +11,7 @@
#include <stdio.h>
#endif
WinDecorator::WinDecorator(SRect rect, int32 wlook, int32 wfeel, int32 wflags)
WinDecorator::WinDecorator(BRect rect, int32 wlook, int32 wfeel, int32 wflags)
: Decorator(rect,wlook,wfeel,wflags)
{
#ifdef DEBUG_DECOR
@ -54,7 +54,7 @@ printf("~WinDecorator()\n");
#endif
}
click_type WinDecorator::Clicked(SPoint pt, int32 buttons, int32 modifiers)
click_type WinDecorator::Clicked(BPoint pt, int32 buttons, int32 modifiers)
{
if(closerect.Contains(pt))
{
@ -86,9 +86,9 @@ printf("WinDecorator():Clicked() - Zoom\n");
}
// We got this far, so user is clicking on the border?
SRect srect(frame);
BRect srect(frame);
srect.top+=19;
SRect clientrect(srect.InsetByCopy(3,3));
BRect clientrect(srect.InsetByCopy(3,3));
if(srect.Contains(pt) && !clientrect.Contains(pt))
{
#ifdef DEBUG_DECOR
@ -132,10 +132,10 @@ printf("WinDecorator()::_DoLayout()\n");
void WinDecorator::MoveBy(float x, float y)
{
MoveBy(SPoint(x,y));
MoveBy(BPoint(x,y));
}
void WinDecorator::MoveBy(SPoint pt)
void WinDecorator::MoveBy(BPoint pt)
{
// Move all internal rectangles the appropriate amount
frame.OffsetBy(pt);
@ -158,7 +158,7 @@ SRegion * WinDecorator::GetFootprint(void)
}
*/
void WinDecorator::_DrawTitle(SRect r)
void WinDecorator::_DrawTitle(BRect r)
{
// Designed simply to redraw the title when it has changed on
// the client side.
@ -192,7 +192,7 @@ void WinDecorator::_SetFocus(void)
}
}
void WinDecorator::Draw(SRect update)
void WinDecorator::Draw(BRect update)
{
#ifdef DEBUG_DECOR
printf("WinDecorator::Draw(): "); update.PrintToStream();
@ -226,7 +226,7 @@ printf("WinDecorator::Draw()\n");
DrawTab();
}
void WinDecorator::_DrawZoom(SRect r)
void WinDecorator::_DrawZoom(BRect r)
{
DrawBlendedRect(r,GetZoom());
@ -235,30 +235,30 @@ void WinDecorator::_DrawZoom(SRect r)
driver->StrokeRect(r.InsetByCopy(2,2),&layerdata,(int8*)&solidhigh);
}
void WinDecorator::_DrawClose(SRect r)
void WinDecorator::_DrawClose(BRect r)
{
// Just like DrawZoom, but for a close button
DrawBlendedRect(r,GetClose());
// Draw the X
layerdata.highcolor=textcol;
driver->StrokeLine(SPoint(closerect.left+2,closerect.top+2),SPoint(closerect.right-2,
driver->StrokeLine(BPoint(closerect.left+2,closerect.top+2),BPoint(closerect.right-2,
closerect.bottom-2),&layerdata,(int8*)&solidhigh);
driver->StrokeLine(SPoint(closerect.right-2,closerect.top+2),SPoint(closerect.left+2,
driver->StrokeLine(BPoint(closerect.right-2,closerect.top+2),BPoint(closerect.left+2,
closerect.bottom-2),&layerdata,(int8*)&solidhigh);
}
void WinDecorator::_DrawMinimize(SRect r)
void WinDecorator::_DrawMinimize(BRect r)
{
// Just like DrawZoom, but for a Minimize button
DrawBlendedRect(r,GetMinimize());
layerdata.highcolor=textcol;
driver->StrokeLine(SPoint(minimizerect.left+2,minimizerect.bottom-2),SPoint(minimizerect.right-2,
driver->StrokeLine(BPoint(minimizerect.left+2,minimizerect.bottom-2),BPoint(minimizerect.right-2,
minimizerect.bottom-2),&layerdata,(int8*)&solidhigh);
}
void WinDecorator::_DrawTab(SRect r)
void WinDecorator::_DrawTab(BRect r)
{
// If a window has a tab, this will draw it and any buttons which are
// in it.
@ -280,7 +280,7 @@ void WinDecorator::_DrawTab(SRect r)
_DrawZoom(zoomrect);
}
void WinDecorator::DrawBlendedRect(SRect r, bool down)
void WinDecorator::DrawBlendedRect(BRect r, bool down)
{
// This bad boy is used to draw a rectangle with a gradient.
// Note that it is not part of the Decorator API - it's specific
@ -317,16 +317,16 @@ void WinDecorator::DrawBlendedRect(SRect r, bool down)
uint8(startcol.green-(i*gstep)),
uint8(startcol.blue-(i*bstep)));
layerdata.highcolor=tmpcol;
driver->StrokeLine(SPoint(r.left,r.top+i),
SPoint(r.left+i,r.top),&layerdata,(int8*)&solidhigh);
driver->StrokeLine(BPoint(r.left,r.top+i),
BPoint(r.left+i,r.top),&layerdata,(int8*)&solidhigh);
SetRGBColor(&tmpcol, uint8(halfcol.red-(i*rstep)),
uint8(halfcol.green-(i*gstep)),
uint8(halfcol.blue-(i*bstep)));
layerdata.highcolor=tmpcol;
driver->StrokeLine(SPoint(r.left+steps,r.top+i),
SPoint(r.left+i,r.top+steps),&layerdata,(int8*)&solidhigh);
driver->StrokeLine(BPoint(r.left+steps,r.top+i),
BPoint(r.left+i,r.top+steps),&layerdata,(int8*)&solidhigh);
}
@ -336,38 +336,38 @@ void WinDecorator::DrawBlendedRect(SRect r, bool down)
driver->StrokeRect(r,&layerdata,(int8*)&solidhigh);
}
void WinDecorator::_DrawFrame(SRect rect)
void WinDecorator::_DrawFrame(BRect rect)
{
if(look==WLOOK_NO_BORDER)
return;
SRect r=borderrect;
BRect r=borderrect;
layerdata.highcolor=frame_midcol;
driver->StrokeLine(SPoint(r.left,r.top),SPoint(r.right-1,r.top),
driver->StrokeLine(BPoint(r.left,r.top),BPoint(r.right-1,r.top),
&layerdata,(int8*)&solidhigh);
layerdata.highcolor=frame_lowcol;
driver->StrokeLine(SPoint(r.left,r.top),SPoint(r.left,r.bottom),
driver->StrokeLine(BPoint(r.left,r.top),BPoint(r.left,r.bottom),
&layerdata,(int8*)&solidhigh);
layerdata.highcolor=frame_lowercol;
driver->StrokeLine(SPoint(r.right,r.bottom),SPoint(r.right,r.top),
driver->StrokeLine(BPoint(r.right,r.bottom),BPoint(r.right,r.top),
&layerdata,(int8*)&solidhigh);
layerdata.highcolor=frame_lowercol;
driver->StrokeLine(SPoint(r.right,r.bottom),SPoint(r.left,r.bottom),
driver->StrokeLine(BPoint(r.right,r.bottom),BPoint(r.left,r.bottom),
&layerdata,(int8*)&solidhigh);
r.InsetBy(1,1);
layerdata.highcolor=frame_highercol;
driver->StrokeLine(SPoint(r.left,r.top),SPoint(r.right-1,r.top),
driver->StrokeLine(BPoint(r.left,r.top),BPoint(r.right-1,r.top),
&layerdata,(int8*)&solidhigh);
layerdata.highcolor=frame_highercol;
driver->StrokeLine(SPoint(r.left,r.top),SPoint(r.left,r.bottom),
driver->StrokeLine(BPoint(r.left,r.top),BPoint(r.left,r.bottom),
&layerdata,(int8*)&solidhigh);
layerdata.highcolor=frame_midcol;
driver->StrokeLine(SPoint(r.right,r.bottom),SPoint(r.right,r.top),
driver->StrokeLine(BPoint(r.right,r.bottom),BPoint(r.right,r.top),
&layerdata,(int8*)&solidhigh);
layerdata.highcolor=frame_midcol;
driver->StrokeLine(SPoint(r.right,r.bottom),SPoint(r.left,r.bottom),
driver->StrokeLine(BPoint(r.right,r.bottom),BPoint(r.left,r.bottom),
&layerdata,(int8*)&solidhigh);
r.InsetBy(1,1);
@ -376,16 +376,16 @@ void WinDecorator::_DrawFrame(SRect rect)
r.InsetBy(1,1);
layerdata.highcolor=frame_lowercol;
driver->StrokeLine(SPoint(r.left,r.top),SPoint(r.right-1,r.top),
driver->StrokeLine(BPoint(r.left,r.top),BPoint(r.right-1,r.top),
&layerdata,(int8*)&solidhigh);
layerdata.highcolor=frame_lowercol;
driver->StrokeLine(SPoint(r.left,r.top),SPoint(r.left,r.bottom),
driver->StrokeLine(BPoint(r.left,r.top),BPoint(r.left,r.bottom),
&layerdata,(int8*)&solidhigh);
layerdata.highcolor=frame_highercol;
driver->StrokeLine(SPoint(r.right,r.bottom),SPoint(r.right,r.top),
driver->StrokeLine(BPoint(r.right,r.bottom),BPoint(r.right,r.top),
&layerdata,(int8*)&solidhigh);
layerdata.highcolor=frame_highercol;
driver->StrokeLine(SPoint(r.right,r.bottom),SPoint(r.left,r.bottom),
driver->StrokeLine(BPoint(r.right,r.bottom),BPoint(r.left,r.bottom),
&layerdata,(int8*)&solidhigh);
}
@ -394,7 +394,7 @@ extern "C" float get_decorator_version(void)
return 1.00;
}
extern "C" Decorator *instantiate_decorator(SRect rect, int32 wlook, int32 wfeel, int32 wflags)
extern "C" Decorator *instantiate_decorator(BRect rect, int32 wlook, int32 wfeel, int32 wflags)
{
return new WinDecorator(rect,wlook,wfeel,wflags);
}

View File

@ -2,34 +2,32 @@
#define _BEOS_DECORATOR_H_
#include "Decorator.h"
#include "SRect.h"
#include "SPoint.h"
class WinDecorator: public Decorator
{
public:
WinDecorator(SRect frame, int32 wlook, int32 wfeel, int32 wflags);
WinDecorator(BRect frame, int32 wlook, int32 wfeel, int32 wflags);
~WinDecorator(void);
void MoveBy(float x, float y);
void MoveBy(SPoint pt);
void MoveBy(BPoint pt);
// void ResizeBy(float x, float y);
// void ResizeBy(SPoint pt);
void Draw(SRect r);
// void ResizeBy(BPoint pt);
void Draw(BRect r);
void Draw(void);
//SRegion GetFootprint(void);
click_type Clicked(SPoint pt, int32 buttons, int32 modifiers);
click_type Clicked(BPoint pt, int32 buttons, int32 modifiers);
protected:
void _DrawClose(SRect r);
void _DrawFrame(SRect r);
void _DrawTab(SRect r);
void _DrawTitle(SRect r);
void _DrawZoom(SRect r);
void _DrawMinimize(SRect r);
void _DrawClose(BRect r);
void _DrawFrame(BRect r);
void _DrawTab(BRect r);
void _DrawTitle(BRect r);
void _DrawZoom(BRect r);
void _DrawMinimize(BRect r);
void _DoLayout(void);
void _SetFocus(void);
void DrawBlendedRect(SRect r, bool down);
void DrawBlendedRect(BRect r, bool down);
uint32 taboffset;
RGBColor tab_highcol, tab_lowcol;