X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/16cba29d3a5a0a95b367382311a4a7a9a9833210..5536310df931fcbe8d2c169d1adaa9f7b26175e0:/include/wx/gdicmn.h?ds=sidebyside diff --git a/include/wx/gdicmn.h b/include/wx/gdicmn.h index a454155616..b6faf8900d 100644 --- a/include/wx/gdicmn.h +++ b/include/wx/gdicmn.h @@ -5,7 +5,7 @@ // Modified by: // Created: 01/02/97 // RCS-ID: $Id$ -// Copyright: (c) +// Copyright: (c) Julian Smart // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -16,15 +16,12 @@ // headers // --------------------------------------------------------------------------- -#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) - #pragma interface "gdicmn.h" -#endif - -#include "wx/setup.h" +#include "wx/defs.h" #include "wx/list.h" #include "wx/string.h" #include "wx/fontenc.h" #include "wx/hashmap.h" +#include "wx/math.h" // --------------------------------------------------------------------------- // forward declarations @@ -217,10 +214,10 @@ public: bool operator==(const wxSize& sz) const { return x == sz.x && y == sz.y; } bool operator!=(const wxSize& sz) const { return x != sz.x || y != sz.y; } - wxSize operator+(const wxSize& sz) { return wxSize(x + sz.x, y + sz.y); } - wxSize operator-(const wxSize& sz) { return wxSize(x - sz.x, y - sz.y); } - wxSize operator/(const int i) { return wxSize(x / i, y / i); } - wxSize operator*(const int i) { return wxSize(x * i, y * i); } + wxSize operator+(const wxSize& sz) const { return wxSize(x + sz.x, y + sz.y); } + wxSize operator-(const wxSize& sz) const { return wxSize(x - sz.x, y - sz.y); } + wxSize operator/(int i) const { return wxSize(x / i, y / i); } + wxSize operator*(int i) const { return wxSize(x * i, y * i); } wxSize& operator+=(const wxSize& sz) { x += sz.x; y += sz.y; return *this; } wxSize& operator-=(const wxSize& sz) { x -= sz.x; y -= sz.y; return *this; } @@ -273,10 +270,14 @@ public: wxRealPoint operator+(const wxRealPoint& pt) const { return wxRealPoint(x + pt.x, y + pt.y); } wxRealPoint operator-(const wxRealPoint& pt) const { return wxRealPoint(x - pt.x, y - pt.y); } - bool operator==(const wxRealPoint& pt) const { return x == pt.x && y == pt.y; } - bool operator!=(const wxRealPoint& pt) const { return x != pt.x || y != pt.y; } + bool operator==(const wxRealPoint& pt) const + { + return wxIsSameDouble(x, pt.x) && wxIsSameDouble(y, pt.y); + } + bool operator!=(const wxRealPoint& pt) const { return !(*this == pt); } }; + class WXDLLEXPORT wxPoint { public: @@ -346,6 +347,8 @@ public: wxSize GetSize() const { return wxSize(width, height); } void SetSize( const wxSize &s ) { width = s.GetWidth(); height = s.GetHeight(); } + bool IsEmpty() const { return (width <= 0) || (height <= 0); } + wxPoint GetTopLeft() const { return GetPosition(); } wxPoint GetLeftTop() const { return GetTopLeft(); } void SetTopLeft(const wxPoint &p) { SetPosition(p); } @@ -425,6 +428,20 @@ public: } + // centre this rectangle in the given (usually, but not necessarily, + // larger) one + wxRect CentreIn(const wxRect& r, int dir = wxBOTH) const + { + return wxRect(dir & wxHORIZONTAL ? r.x + (r.width - width)/2 : x, + dir & wxVERTICAL ? r.y + (r.height - height)/2 : y, + width, height); + } + + wxRect CenterIn(const wxRect& r, int dir = wxBOTH) const + { + return CentreIn(r, dir); + } + public: int x, y, width, height; }; @@ -454,7 +471,7 @@ public: void AddBrush(wxBrush *brush); void RemoveBrush(wxBrush *brush); - wxBrush *FindOrCreateBrush(const wxColour& colour, int style); + wxBrush *FindOrCreateBrush(const wxColour& colour, int style = wxSOLID); }; class WXDLLEXPORT wxFontList : public wxList @@ -587,7 +604,7 @@ extern WXDLLEXPORT_DATA(wxCursor*) wxCROSS_CURSOR; extern WXDLLEXPORT_DATA(wxColourDatabase*) wxTheColourDatabase; -extern WXDLLEXPORT_DATA(const wxChar*) wxPanelNameStr; +extern WXDLLEXPORT_DATA(const wxChar) wxPanelNameStr[]; extern WXDLLEXPORT_DATA(const wxSize) wxDefaultSize; extern WXDLLEXPORT_DATA(const wxPoint) wxDefaultPosition;