X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/ed0dd9c1f0e9a79b5110d59b903a5f1fd9ee6c42..5bdcb1f3248ebcac6c73e314e752c13dee8776c7:/include/wx/gdicmn.h diff --git a/include/wx/gdicmn.h b/include/wx/gdicmn.h index 898dce7642..e6368d8ff2 100644 --- a/include/wx/gdicmn.h +++ b/include/wx/gdicmn.h @@ -59,8 +59,10 @@ enum wxBitmapType wxBITMAP_TYPE_XBM_DATA, wxBITMAP_TYPE_XPM, wxBITMAP_TYPE_XPM_DATA, - wxBITMAP_TYPE_TIF, - wxBITMAP_TYPE_TIF_RESOURCE, + wxBITMAP_TYPE_TIFF, + wxBITMAP_TYPE_TIF = wxBITMAP_TYPE_TIFF, + wxBITMAP_TYPE_TIFF_RESOURCE, + wxBITMAP_TYPE_TIF_RESOURCE = wxBITMAP_TYPE_TIFF_RESOURCE, wxBITMAP_TYPE_GIF, wxBITMAP_TYPE_GIF_RESOURCE, wxBITMAP_TYPE_PNG, @@ -158,25 +160,26 @@ enum wxStockCursor // macros // --------------------------------------------------------------------------- +#if defined(__WINDOWS__) || defined(__WXPM__) + #define wxHAS_IMAGES_IN_RESOURCES +#endif + /* Useful macro for creating icons portably, for example: - wxIcon *icon = new wxICON(mondrian); + wxIcon *icon = new wxICON(sample); expands into: - wxIcon *icon = new wxIcon("mondrian"); // On wxMSW - wxIcon *icon = new wxIcon(mondrian_xpm); // On wxGTK + wxIcon *icon = new wxIcon("sample"); // On Windows + wxIcon *icon = new wxIcon(sample_xpm); // On wxGTK/Linux */ -#ifdef __WXMSW__ +#ifdef __WINDOWS__ // Load from a resource #define wxICON(X) wxIcon(wxT(#X)) #elif defined(__WXPM__) // Load from a resource #define wxICON(X) wxIcon(wxT(#X)) -#elif defined(__WXMGL__) - // Initialize from an included XPM - #define wxICON(X) wxIcon( X##_xpm ) #elif defined(__WXDFB__) // Initialize from an included XPM #define wxICON(X) wxIcon( X##_xpm ) @@ -201,13 +204,12 @@ enum wxStockCursor under Unix bitmaps live in XPMs and under Windows they're in ressources. */ -#if defined(__WXMSW__) || defined(__WXPM__) - #define wxBITMAP(name) wxBitmap(wxT(#name), wxBITMAP_TYPE_RESOURCE) +#if defined(__WINDOWS__) || defined(__WXPM__) + #define wxBITMAP(name) wxBitmap(wxT(#name), wxBITMAP_TYPE_BMP_RESOURCE) #elif defined(__WXGTK__) || \ defined(__WXMOTIF__) || \ defined(__WXX11__) || \ defined(__WXMAC__) || \ - defined(__WXMGL__) || \ defined(__WXDFB__) || \ defined(__WXCOCOA__) // Initialize from an included XPM @@ -255,10 +257,12 @@ public: { if ( sz.x < x ) x = sz.x; if ( sz.y < y ) y = sz.y; } void IncBy(int dx, int dy) { x += dx; y += dy; } + void IncBy(const wxPoint& pt); void IncBy(const wxSize& sz) { IncBy(sz.x, sz.y); } void IncBy(int d) { IncBy(d, d); } void DecBy(int dx, int dy) { IncBy(-dx, -dy); } + void DecBy(const wxPoint& pt); void DecBy(const wxSize& sz) { DecBy(sz.x, sz.y); } void DecBy(int d) { DecBy(d, d); } @@ -395,6 +399,16 @@ public: wxRealPoint() : x(0.0), y(0.0) { } wxRealPoint(double xx, double yy) : x(xx), y(yy) { } + wxRealPoint(const wxPoint& pt); + + // no copy ctor or assignment operator - the defaults are ok + + //assignment operators + wxRealPoint& operator+=(const wxRealPoint& p) { x += p.x; y += p.y; return *this; } + wxRealPoint& operator-=(const wxRealPoint& p) { x -= p.x; y -= p.y; return *this; } + + wxRealPoint& operator+=(const wxSize& s) { x += s.GetWidth(); y += s.GetHeight(); return *this; } + wxRealPoint& operator-=(const wxSize& s) { x -= s.GetWidth(); y -= s.GetHeight(); return *this; } }; @@ -403,13 +417,11 @@ inline bool operator==(const wxRealPoint& p1, const wxRealPoint& p2) return wxIsSameDouble(p1.x, p2.x) && wxIsSameDouble(p1.y, p2.y); } - inline bool operator!=(const wxRealPoint& p1, const wxRealPoint& p2) { return !(p1 == p2); } - inline wxRealPoint operator+(const wxRealPoint& p1, const wxRealPoint& p2) { return wxRealPoint(p1.x + p2.x, p1.y + p2.y); @@ -422,6 +434,77 @@ inline wxRealPoint operator-(const wxRealPoint& p1, const wxRealPoint& p2) } +inline wxRealPoint operator/(const wxRealPoint& s, int i) +{ + return wxRealPoint(s.x / i, s.y / i); +} + +inline wxRealPoint operator*(const wxRealPoint& s, int i) +{ + return wxRealPoint(s.x * i, s.y * i); +} + +inline wxRealPoint operator*(int i, const wxRealPoint& s) +{ + return wxRealPoint(s.x * i, s.y * i); +} + +inline wxRealPoint operator/(const wxRealPoint& s, unsigned int i) +{ + return wxRealPoint(s.x / i, s.y / i); +} + +inline wxRealPoint operator*(const wxRealPoint& s, unsigned int i) +{ + return wxRealPoint(s.x * i, s.y * i); +} + +inline wxRealPoint operator*(unsigned int i, const wxRealPoint& s) +{ + return wxRealPoint(s.x * i, s.y * i); +} + +inline wxRealPoint operator/(const wxRealPoint& s, long i) +{ + return wxRealPoint(s.x / i, s.y / i); +} + +inline wxRealPoint operator*(const wxRealPoint& s, long i) +{ + return wxRealPoint(s.x * i, s.y * i); +} + +inline wxRealPoint operator*(long i, const wxRealPoint& s) +{ + return wxRealPoint(s.x * i, s.y * i); +} + +inline wxRealPoint operator/(const wxRealPoint& s, unsigned long i) +{ + return wxRealPoint(s.x / i, s.y / i); +} + +inline wxRealPoint operator*(const wxRealPoint& s, unsigned long i) +{ + return wxRealPoint(s.x * i, s.y * i); +} + +inline wxRealPoint operator*(unsigned long i, const wxRealPoint& s) +{ + return wxRealPoint(s.x * i, s.y * i); +} + +inline wxRealPoint operator*(const wxRealPoint& s, double i) +{ + return wxRealPoint(int(s.x * i), int(s.y * i)); +} + +inline wxRealPoint operator*(double i, const wxRealPoint& s) +{ + return wxRealPoint(int(s.x * i), int(s.y * i)); +} + + // ---------------------------------------------------------------------------- // wxPoint: 2D point with integer coordinates // ---------------------------------------------------------------------------- @@ -433,6 +516,7 @@ public: wxPoint() : x(0), y(0) { } wxPoint(int xx, int yy) : x(xx), y(yy) { } + wxPoint(const wxRealPoint& pt) : x(int(pt.x)), y(int(pt.y)) { } // no copy ctor or assignment operator - the defaults are ok @@ -442,6 +526,18 @@ public: wxPoint& operator+=(const wxSize& s) { x += s.GetWidth(); y += s.GetHeight(); return *this; } wxPoint& operator-=(const wxSize& s) { x -= s.GetWidth(); y -= s.GetHeight(); return *this; } + + // check if both components are set/initialized + bool IsFullySpecified() const { return x != wxDefaultCoord && y != wxDefaultCoord; } + + // fill in the unset components with the values from the other point + void SetDefaults(const wxPoint& pt) + { + if ( x == wxDefaultCoord ) + x = pt.x; + if ( y == wxDefaultCoord ) + y = pt.y; + } }; @@ -631,7 +727,7 @@ public: wxPoint GetTopRight() const { return wxPoint(GetRight(), GetTop()); } wxPoint GetRightTop() const { return GetTopRight(); } void SetTopRight(const wxPoint &p) { SetRight(p.x); SetTop(p.y); } - void SetRightTop(const wxPoint &p) { SetTopLeft(p); } + void SetRightTop(const wxPoint &p) { SetTopRight(p); } wxPoint GetBottomLeft() const { return wxPoint(GetLeft(), GetBottom()); } wxPoint GetLeftBottom() const { return GetBottomLeft(); } @@ -747,6 +843,11 @@ inline bool wxRect::Inside(const wxRect& rect) const { return Contains(rect); } #endif // WXWIN_COMPATIBILITY_2_6 +// define functions which couldn't be defined above because of declarations +// order +inline void wxSize::IncBy(const wxPoint& pt) { IncBy(pt.x, pt.y); } +inline void wxSize::DecBy(const wxPoint& pt) { DecBy(pt.x, pt.y); } + // --------------------------------------------------------------------------- // Management of pens, brushes and fonts // --------------------------------------------------------------------------- @@ -801,7 +902,7 @@ class WXDLLIMPEXP_CORE wxResourceCache: public wxList { public: wxResourceCache() { } -#if !wxUSE_STL +#if !wxUSE_STD_CONTAINERS wxResourceCache(const unsigned int keyType) : wxList(keyType) { } #endif virtual ~wxResourceCache();