#include "wx/app.h"
#include "wx/dc.h"
#include "wx/utils.h"
+#include "wx/settings.h"
#include "wx/log.h"
#include <string.h>
{
x = topLeft.x;
y = topLeft.y;
- width = bottomRight.x - topLeft.x;
- height = bottomRight.y - topLeft.y;
+ width = bottomRight.x - topLeft.x + 1;
+ height = bottomRight.y - topLeft.y + 1;
if (width < 0)
{
return wxRect(x1, y1, x2-x1, y2-y1);
}
+wxRect& wxRect::Inflate(wxCoord dx, wxCoord dy)
+{
+ x -= dx;
+ y -= dy;
+ width += 2*dx;
+ height += 2*dy;
+
+ // check that we didn't make the rectangle invalid by accident (you almost
+ // never want to have negative coords and never want negative size)
+ if ( x < 0 )
+ x = 0;
+ if ( y < 0 )
+ y = 0;
+
+ // what else can we do?
+ if ( width < 0 )
+ width = 0;
+ if ( height < 0 )
+ height = 0;
+
+ return *this;
+}
+
bool wxRect::Inside(int cx, int cy) const
{
return ( (cx >= x) && (cy >= y)
);
}
+wxRect& wxRect::Intersect(const wxRect& rect)
+{
+ int x2 = GetRight(),
+ y2 = GetBottom();
+
+ if ( x < rect.x )
+ x = rect.x;
+ if ( y < rect.y )
+ y = rect.y;
+ if ( x2 > rect.GetRight() )
+ x2 = rect.GetRight();
+ if ( y2 > rect.GetBottom() )
+ y2 = rect.GetBottom();
+
+ width = x2 - x + 1;
+ height = y2 - y + 1;
+
+ if ( width <= 0 || height <= 0 )
+ {
+ width =
+ height = 0;
+ }
+
+ return *this;
+}
+
+bool wxRect::Intersects(const wxRect& rect) const
+{
+ wxRect r = Intersect(rect);
+
+ // if there is no intersection, both width and height are 0
+ return r.width != 0;
+}
+
wxColourDatabase::wxColourDatabase (int type) : wxList (type)
{
}
delete col;
node = next;
}
+#ifdef __WXPM__
+ delete [] m_palTable;
+#endif
}
// Colour database stuff
{wxT("MEDIUM GREY"), 100, 100, 100},
};
- for ( size_t n = 0; n < WXSIZEOF(wxColourTable); n++ )
+ size_t n;
+
+ for ( n = 0; n < WXSIZEOF(wxColourTable); n++ )
{
const wxColourDesc& cc = wxColourTable[n];
Append(cc.name, new wxColour(cc.r,cc.g,cc.b));
}
+#ifdef __WXPM__
+ m_palTable = new long[n];
+ for ( n = 0; n < WXSIZEOF(wxColourTable); n++ )
+ {
+ const wxColourDesc& cc = wxColourTable[n];
+ m_palTable[n] = OS2RGB(cc.r,cc.g,cc.b);
+ }
+ m_nSize = n;
+#endif
}
/*
#ifdef __WXPM__
return NULL;
#endif
+#ifdef __WXMGL__
+ return NULL;
+#endif
// TODO for other implementations. This should really go into
// platform-specific directories.
#endif
// why under MSW fonts shouldn't have the standard system size?
+/*
#ifdef __WXMSW__
static const int sizeFont = 10;
#else
+#endif
+*/
+#if defined(__WXPM__) || defined(__WXMAC__)
static const int sizeFont = 12;
+ wxNORMAL_FONT = new wxFont (sizeFont, wxMODERN, wxNORMAL, wxNORMAL);
+#else
+ wxNORMAL_FONT = new wxFont(wxSystemSettings::GetSystemFont(wxSYS_DEFAULT_GUI_FONT));
+ static const int sizeFont = wxNORMAL_FONT->GetPointSize();
#endif
- wxNORMAL_FONT = new wxFont (sizeFont, wxMODERN, wxNORMAL, wxNORMAL);
wxSMALL_FONT = new wxFont (sizeFont - 2, wxSWISS, wxNORMAL, wxNORMAL);
wxITALIC_FONT = new wxFont (sizeFont, wxROMAN, wxITALIC, wxNORMAL);
wxSWISS_FONT = new wxFont (sizeFont, wxSWISS, wxNORMAL, wxNORMAL);
wxPen *wxPenList::FindOrCreatePen (const wxColour& colour, int width, int style)
{
- for (wxNode * node = First (); node; node = node->Next ())
+ for (wxNode * node = First (); node; node = node->Next ())
{
- wxPen *each_pen = (wxPen *) node->Data ();
- if (each_pen &&
- each_pen->GetVisible() &&
- each_pen->GetWidth () == width &&
- each_pen->GetStyle () == style &&
- each_pen->GetColour ().Red () == colour.Red () &&
- each_pen->GetColour ().Green () == colour.Green () &&
- each_pen->GetColour ().Blue () == colour.Blue ())
- return each_pen;
+ wxPen *each_pen = (wxPen *) node->Data ();
+ if (each_pen &&
+ each_pen->GetVisible() &&
+ each_pen->GetWidth () == width &&
+ each_pen->GetStyle () == style &&
+ each_pen->GetColour ().Red () == colour.Red () &&
+ each_pen->GetColour ().Green () == colour.Green () &&
+ each_pen->GetColour ().Blue () == colour.Blue ())
+ return each_pen;
}
- wxPen *pen = new wxPen (colour, width, style);
- // Yes, we can return a pointer to this in a later FindOrCreatePen call,
- // because we created it within FindOrCreatePen. Safeguards against
- // returning a pointer to an automatic variable and hanging on to it
- // (dangling pointer).
- pen->SetVisible(TRUE);
+ wxPen *pen = new wxPen (colour, width, style);
+ if ( !pen->Ok() )
+ {
+ // don't save the invalid pens in the list
+ delete pen;
+
+ return NULL;
+ }
- return pen;
+ // Yes, we can return a pointer to this in a later FindOrCreatePen call,
+ // because we created it within FindOrCreatePen. Safeguards against
+ // returning a pointer to an automatic variable and hanging on to it
+ // (dangling pointer).
+ pen->SetVisible(TRUE);
+
+ return pen;
}
wxBrushList::~wxBrushList ()
wxBrush *wxBrushList::FindOrCreateBrush (const wxColour& colour, int style)
{
- for (wxNode * node = First (); node; node = node->Next ())
+ for (wxNode * node = First (); node; node = node->Next ())
{
- wxBrush *each_brush = (wxBrush *) node->Data ();
- if (each_brush &&
- each_brush->GetVisible() &&
- each_brush->GetStyle () == style &&
- each_brush->GetColour ().Red () == colour.Red () &&
- each_brush->GetColour ().Green () == colour.Green () &&
- each_brush->GetColour ().Blue () == colour.Blue ())
- return each_brush;
+ wxBrush *each_brush = (wxBrush *) node->Data ();
+ if (each_brush &&
+ each_brush->GetVisible() &&
+ each_brush->GetStyle () == style &&
+ each_brush->GetColour ().Red () == colour.Red () &&
+ each_brush->GetColour ().Green () == colour.Green () &&
+ each_brush->GetColour ().Blue () == colour.Blue ())
+ return each_brush;
}
- // Yes, we can return a pointer to this in a later FindOrCreateBrush call,
- // because we created it within FindOrCreateBrush. Safeguards against
- // returning a pointer to an automatic variable and hanging on to it
- // (dangling pointer).
- wxBrush *brush = new wxBrush (colour, style);
+ wxBrush *brush = new wxBrush (colour, style);
- brush->SetVisible(TRUE);
+ if ( !brush->Ok() )
+ {
+ // don't put the brushes we failed to create into the list
+ delete brush;
+
+ return NULL;
+ }
- return brush;
+ brush->SetVisible(TRUE);
+
+ // Yes, we can return a pointer to this in a later FindOrCreateBrush call,
+ // because we created it within FindOrCreateBrush. Safeguards against
+ // returning a pointer to an automatic variable and hanging on to it
+ // (dangling pointer).
+ return brush;
}
void wxBrushList::RemoveBrush (wxBrush * brush)
return wxSize(x, y);
}
+wxRect wxGetClientDisplayRect()
+{
+ int x, y, width, height;
+ wxClientDisplayRect(&x, &y, &width, &height); // call plat-specific version
+ return wxRect(x, y, width, height);
+}
+
+wxSize wxGetDisplaySizeMM()
+{
+ int x, y;
+ wxDisplaySizeMM(& x, & y);
+ return wxSize(x, y);
+}
+
wxResourceCache::~wxResourceCache ()
{
wxNode *node = First ();