From 4ca0218b2e8b9f207edb4bd4dc8b0f8604686008 Mon Sep 17 00:00:00 2001 From: DarkWyrm Date: Sat, 31 Aug 2002 20:51:21 +0000 Subject: [PATCH] Removed SRect and SPoint classes git-svn-id: file:///srv/svn/repos/haiku/trunk/current@946 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/prefs/appearance/DecView.cpp | 2 +- src/prefs/appearance/Decorator.cpp | 22 +-- src/prefs/appearance/Decorator.h | 28 ++-- src/prefs/appearance/DisplayDriver.h | 47 +++--- src/prefs/appearance/LayerData.h | 4 +- src/prefs/appearance/PreviewDriver.h | 46 +++--- src/prefs/appearance/SPoint.cpp | 92 ------------ src/prefs/appearance/SPoint.h | 80 ----------- src/prefs/appearance/SRect.cpp | 205 --------------------------- src/prefs/appearance/SRect.h | 187 ------------------------ 10 files changed, 74 insertions(+), 639 deletions(-) delete mode 100644 src/prefs/appearance/SPoint.cpp delete mode 100644 src/prefs/appearance/SPoint.h delete mode 100644 src/prefs/appearance/SRect.cpp delete mode 100644 src/prefs/appearance/SRect.h diff --git a/src/prefs/appearance/DecView.cpp b/src/prefs/appearance/DecView.cpp index da1a8bc01c..b1956f69e2 100644 --- a/src/prefs/appearance/DecView.cpp +++ b/src/prefs/appearance/DecView.cpp @@ -323,7 +323,7 @@ printf("LoadDecorator(): Deleting old decorator\n"); // unload_add_on(decorator_id); } decorator_id=addon; - decorator=pcreatefunc(SRect(50,50,150,150),WLOOK_TITLED,WFEEL_NORMAL,0); + decorator=pcreatefunc(BRect(50,50,150,150),WLOOK_TITLED,WFEEL_NORMAL,0); decorator->SetDriver(driver); decorator->SetFocus(true); // decorator->Draw(); diff --git a/src/prefs/appearance/Decorator.cpp b/src/prefs/appearance/Decorator.cpp index 68bb956394..eadb95dc59 100644 --- a/src/prefs/appearance/Decorator.cpp +++ b/src/prefs/appearance/Decorator.cpp @@ -1,7 +1,7 @@ #include "Decorator.h" #include -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; } diff --git a/src/prefs/appearance/Decorator.h b/src/prefs/appearance/Decorator.h index 8cec1d6d1c..6945357036 100644 --- a/src/prefs/appearance/Decorator.h +++ b/src/prefs/appearance/Decorator.h @@ -2,7 +2,7 @@ #define _DECORATOR_H_ #include -#include "SRect.h" +#include #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; @@ -115,6 +115,6 @@ private: }; typedef uint16 get_decorator_version(void); -typedef Decorator *create_decorator(SRect rect, int32 wlook, int32 wfeel, int32 wflags); +typedef Decorator *create_decorator(BRect rect, int32 wlook, int32 wfeel, int32 wflags); #endif diff --git a/src/prefs/appearance/DisplayDriver.h b/src/prefs/appearance/DisplayDriver.h index 251824eae4..8f4f9f667f 100644 --- a/src/prefs/appearance/DisplayDriver.h +++ b/src/prefs/appearance/DisplayDriver.h @@ -5,8 +5,7 @@ #include #include -#include "SRect.h" -#include "SPoint.h" +#include #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; diff --git a/src/prefs/appearance/LayerData.h b/src/prefs/appearance/LayerData.h index fee179b39c..6051aeb0ea 100644 --- a/src/prefs/appearance/LayerData.h +++ b/src/prefs/appearance/LayerData.h @@ -1,7 +1,7 @@ #ifndef LAYERDATA_H_ #define LAYERDATA_H_ -#include "SPoint.h" +#include class ServerBitmap; class LayerData @@ -22,7 +22,7 @@ LayerData(void) }; float pensize; -SPoint penlocation; +BPoint penlocation; int32 drawing_mode; ServerBitmap *bitmap_background; ServerBitmap *bitmap_overlay; diff --git a/src/prefs/appearance/PreviewDriver.h b/src/prefs/appearance/PreviewDriver.h index 731eb29cf5..e5ca6f0bee 100644 --- a/src/prefs/appearance/PreviewDriver.h +++ b/src/prefs/appearance/PreviewDriver.h @@ -37,30 +37,30 @@ public: virtual bool Initialize(void); virtual void Shutdown(void); - virtual void CopyBits(SRect src, SRect dest); - virtual void DrawBitmap(ServerBitmap *bmp, SRect src, SRect dest); - virtual void DrawChar(char c, SPoint pt); -// virtual void DrawPicture(SPicture *pic, SPoint pt); -// virtual void DrawString(const char *string, int32 length, SPoint pt, escapement_delta *delta=NULL); - virtual void InvertRect(SRect r); - virtual void StrokeBezier(SPoint *pts, LayerData *d, int8 *pat); - virtual void FillBezier(SPoint *pts, LayerData *d, int8 *pat); - virtual void StrokeEllipse(SRect r, LayerData *d, int8 *pat); - virtual void FillEllipse(SRect r, LayerData *d, int8 *pat); - virtual void StrokeArc(SRect r, float angle, float span, LayerData *d, int8 *pat); - virtual void FillArc(SRect r, float angle, float span, LayerData *d, int8 *pat); - virtual void StrokeLine(SPoint start, SPoint end, LayerData *d, int8 *pat); - virtual void StrokePolygon(SPoint *ptlist, int32 numpts, SRect rect, LayerData *d, int8 *pat, bool is_closed=true); - virtual void FillPolygon(SPoint *ptlist, int32 numpts, SRect rect, LayerData *d, int8 *pat); - virtual void StrokeRect(SRect r, LayerData *d, int8 *pat); - virtual void FillRect(SRect r, LayerData *d, int8 *pat); - virtual void StrokeRoundRect(SRect r, float xrad, float yrad, LayerData *d, int8 *pat); - virtual void FillRoundRect(SRect r, float xrad, float yrad, LayerData *d, int8 *pat); + virtual void CopyBits(BRect src, BRect dest); + virtual void DrawBitmap(ServerBitmap *bmp, BRect src, BRect dest); + virtual void DrawChar(char c, BPoint pt); +// virtual void DrawPicture(SPicture *pic, BPoint pt); +// virtual void DrawString(const char *string, int32 length, BPoint pt, escapement_delta *delta=NULL); + virtual void InvertRect(BRect r); + virtual void StrokeBezier(BPoint *pts, LayerData *d, int8 *pat); + virtual void FillBezier(BPoint *pts, LayerData *d, int8 *pat); + virtual void StrokeEllipse(BRect r, LayerData *d, int8 *pat); + virtual void FillEllipse(BRect r, LayerData *d, int8 *pat); + virtual void StrokeArc(BRect r, float angle, float span, LayerData *d, int8 *pat); + virtual void FillArc(BRect r, float angle, float span, LayerData *d, int8 *pat); + virtual void StrokeLine(BPoint start, BPoint end, LayerData *d, int8 *pat); + virtual void StrokePolygon(BPoint *ptlist, int32 numpts, BRect rect, LayerData *d, int8 *pat, bool is_closed=true); + virtual void FillPolygon(BPoint *ptlist, int32 numpts, BRect rect, LayerData *d, int8 *pat); + virtual void StrokeRect(BRect r, LayerData *d, int8 *pat); + virtual void FillRect(BRect r, LayerData *d, int8 *pat); + virtual void StrokeRoundRect(BRect r, float xrad, float yrad, LayerData *d, int8 *pat); + virtual void FillRoundRect(BRect r, float xrad, float yrad, LayerData *d, int8 *pat); // virtual void StrokeShape(SShape *sh, LayerData *d, int8 *pat); // virtual void FillShape(SShape *sh, LayerData *d, int8 *pat); - virtual void StrokeTriangle(SPoint *pts, SRect r, LayerData *d, int8 *pat); - virtual void FillTriangle(SPoint *pts, SRect r, LayerData *d, int8 *pat); - virtual void StrokeLineArray(SPoint *pts, int32 numlines, RGBColor *colors, LayerData *d); + virtual void StrokeTriangle(BPoint *pts, BRect r, LayerData *d, int8 *pat); + virtual void FillTriangle(BPoint *pts, BRect r, LayerData *d, int8 *pat); + virtual void StrokeLineArray(BPoint *pts, int32 numlines, RGBColor *colors, LayerData *d); virtual void SetMode(int32 mode); virtual bool DumpToFile(const char *path); @@ -74,6 +74,6 @@ protected: PVView *view; }; -extern SRect preview_bounds; +extern BRect preview_bounds; #endif \ No newline at end of file diff --git a/src/prefs/appearance/SPoint.cpp b/src/prefs/appearance/SPoint.cpp deleted file mode 100644 index 48b9135256..0000000000 --- a/src/prefs/appearance/SPoint.cpp +++ /dev/null @@ -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 -#include - -#include -#include -#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; -} diff --git a/src/prefs/appearance/SPoint.h b/src/prefs/appearance/SPoint.h deleted file mode 100644 index f147303440..0000000000 --- a/src/prefs/appearance/SPoint.h +++ /dev/null @@ -1,80 +0,0 @@ -#ifndef _SPOINT_H -#define _SPOINT_H - -#include -#include - -class SRect; - -#ifndef BE_SUPPORT -#define BE_SUPPORT -#endif - -#ifdef BE_SUPPORT -#include -#include -#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 diff --git a/src/prefs/appearance/SRect.cpp b/src/prefs/appearance/SRect.cpp deleted file mode 100644 index 403cc4cbef..0000000000 --- a/src/prefs/appearance/SRect.cpp +++ /dev/null @@ -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 -#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)); - } -} diff --git a/src/prefs/appearance/SRect.h b/src/prefs/appearance/SRect.h deleted file mode 100644 index 3550fc68cd..0000000000 --- a/src/prefs/appearance/SRect.h +++ /dev/null @@ -1,187 +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 -#include -#include "SPoint.h" - -#ifdef BE_SUPPORT -#include -#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