Changed wxFont, wxPen, wxBrush to not implicitly use the wxTheXXXList

behind the scenes, but to use normal ctor and dtors.

Exposed the wxTheXXXLists to wxPython.

Also wxTheColourDatabase and added a library module to load LOTS more
colour names into the colour database.


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@9526 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Robin Dunn
2001-03-14 08:05:03 +00:00
parent 83b18bab39
commit 0569df0fc9
17 changed files with 1531 additions and 56 deletions

View File

@@ -268,23 +268,15 @@ enum wxFontEncoding
wxFONTENCODING_MAX
};
class wxFont {
public:
// I'll do it this way to use long-lived objects and not have to
// worry about when python may delete the object.
%addmethods {
wxFont( int pointSize, int family, int style, int weight,
int underline=FALSE, char* faceName = "",
wxFontEncoding encoding=wxFONTENCODING_DEFAULT) {
return wxTheFontList->FindOrCreateFont(pointSize, family, style, weight,
underline, faceName, encoding);
}
// NO Destructor.
}
wxFont( int pointSize, int family, int style, int weight,
int underline=FALSE, char* faceName = "",
wxFontEncoding encoding=wxFONTENCODING_DEFAULT);
~wxFont();
bool Ok();
wxString GetFaceName();
int GetFamily();
#ifdef __WXMSW__
@@ -317,6 +309,18 @@ public:
}
%}
class wxFontList {
public:
void AddFont(wxFont* font);
wxFont * FindOrCreateFont(int point_size, int family, int style, int weight,
bool underline = FALSE, const char* facename = NULL,
wxFontEncoding encoding = wxFONTENCODING_DEFAULT);
void RemoveFont(wxFont *font);
};
//----------------------------------------------------------------------
class wxColour {
@@ -352,19 +356,28 @@ public:
%}
class wxColourDatabase {
public:
wxColour *FindColour(const wxString& colour);
wxString FindName(const wxColour& colour) const;
%addmethods {
void Append(const wxString& name, int red, int green, int blue) {
self->Append(name.c_str(), new wxColour(red, green, blue));
}
}
};
//----------------------------------------------------------------------
class wxPen {
public:
// I'll do it this way to use long-lived objects and not have to
// worry about when python may delete the object.
%addmethods {
wxPen(wxColour* colour, int width=1, int style=wxSOLID) {
return wxThePenList->FindOrCreatePen(*colour, width, style);
}
// NO Destructor.
}
wxPen(wxColour& colour, int width=1, int style=wxSOLID);
~wxPen();
int GetCap();
wxColour& GetColour();
@@ -389,20 +402,23 @@ public:
#endif
};
class wxPenList {
public:
void AddPen(wxPen* pen);
wxPen* FindOrCreatePen(const wxColour& colour, int width, int style);
void RemovePen(wxPen* pen);
};
//----------------------------------------------------------------------
class wxBrush {
public:
// I'll do it this way to use long-lived objects and not have to
// worry about when python may delete the object.
%addmethods {
wxBrush(const wxColour* colour, int style=wxSOLID) {
return wxTheBrushList->FindOrCreateBrush(*colour, style);
}
// NO Destructor.
}
// wxBrush(const wxColour& colour, int style=wxSOLID);
wxBrush(const wxColour& colour, int style=wxSOLID);
~wxBrush();
wxColour& GetColour();
wxBitmap * GetStipple();
@@ -413,6 +429,15 @@ public:
void SetStyle(int style);
};
class wxBrushList {
public:
void AddBrush(wxBrush *brush);
wxBrush * FindOrCreateBrush(const wxColour& colour, int style);
void RemoveBrush(wxBrush *brush);
};
//----------------------------------------------------------------------
@@ -659,6 +684,13 @@ extern wxPalette wxNullPalette;
extern wxFont wxNullFont;
extern wxColour wxNullColour;
extern wxFontList* wxTheFontList;
extern wxPenList* wxThePenList;
extern wxBrushlist* wxTheBrushList;
extern wxColourDatabase* wxTheColourDatabase;
%readwrite
%{
#endif