]> git.saurik.com Git - wxWidgets.git/blobdiff - wxPython/src/gdi.i
SWIGged updates for wxGTK
[wxWidgets.git] / wxPython / src / gdi.i
index 2bb79f4f7dd7fad25dc692505fb1f4078179d186..032a3b2947fb248b7f02b8604c433a9928975aa2 100644 (file)
@@ -20,6 +20,7 @@
 #include <wx/fontenc.h>
 #include <wx/fontmap.h>
 #include <wx/fontutil.h>
+#include <wx/dcbuffer.h>
 %}
 
 //----------------------------------------------------------------------
 %import _defs.i
 %import misc.i
 
+
+//---------------------------------------------------------------------------
 %{
-    static wxString wxPyEmptyStr("");
+    // Put some wx default wxChar* values into wxStrings.
+    static const wxString wxPyEmptyString(wxT(""));
 %}
-
 //---------------------------------------------------------------------------
 
 class wxGDIObject : public wxObject {
@@ -54,12 +57,12 @@ public:
 class wxBitmap : public wxGDIObject
 {
 public:
-    wxBitmap(const wxString& name, wxBitmapType type=wxBITMAP_TYPE_BMP);
+    wxBitmap(const wxString& name, wxBitmapType type=wxBITMAP_TYPE_ANY);
     ~wxBitmap();
 
     wxPalette* GetPalette();
     wxMask* GetMask();
-    bool LoadFile(const wxString& name, wxBitmapType type=wxBITMAP_TYPE_BMP);
+    bool LoadFile(const wxString& name, wxBitmapType type=wxBITMAP_TYPE_ANY);
     bool SaveFile(const wxString& name, wxBitmapType type, wxPalette* palette = NULL);
     void SetMask(wxMask* mask);
 #ifdef __WXMSW__
@@ -202,7 +205,9 @@ public:
            int desiredWidth = -1, int desiredHeight = -1);
     ~wxIcon();
 
+#ifndef __WXMAC__
     bool LoadFile(const wxString& name, long flags);
+#endif
 
     // wxGDIImage methods
 #ifdef __WXMSW__
@@ -235,6 +240,7 @@ public:
 // Declarations of some alternate "constructors"
 %new wxIcon* wxEmptyIcon();
 %new wxIcon* wxIconFromXPMData(PyObject* listOfStrings);
+%new wxIcon* wxIconFromBitmap(const wxBitmap& bmp);
 
 %{ // Implementations of some alternate "constructors"
     wxIcon* wxEmptyIcon() {
@@ -252,6 +258,12 @@ public:
         delete [] cArray;
         return icon;
     }
+
+    wxIcon* wxIconFromBitmap(const wxBitmap& bmp) {
+        wxIcon* icon = new wxIcon();
+        icon->CopyFromBitmap(bmp);
+        return icon;
+    }
 %}
 
 //---------------------------------------------------------------------------
@@ -300,7 +312,8 @@ enum wxFontFamily
     wxFONTFAMILY_SWISS = wxSWISS,
     wxFONTFAMILY_MODERN = wxMODERN,
     wxFONTFAMILY_TELETYPE = wxTELETYPE,
-    wxFONTFAMILY_MAX
+    wxFONTFAMILY_MAX,
+    wxFONTFAMILY_UNKNOWN
 };
 
 // font styles
@@ -398,8 +411,14 @@ struct wxNativeFontInfo
     // init the elements from an XLFD, return TRUE if ok
     bool FromXFontName(const wxString& xFontName);
 
+    // return false if we were never initialized with a valid XLFD
+    bool IsDefault() const;
+
     // generate an XLFD using the fontElements
     wxString GetXFontName() const;
+
+    // set the XFLD
+    void SetXFontName(const wxString& xFontName);
 #endif
 
     wxNativeFontInfo() { Init(); }
@@ -407,6 +426,7 @@ struct wxNativeFontInfo
     // reset to the default state
     void Init();
 
+#ifndef __WXGTK__
     // accessors and modifiers for the font elements
     int GetPointSize() const;
     wxFontStyle GetStyle() const;
@@ -423,6 +443,7 @@ struct wxNativeFontInfo
     void SetFaceName(wxString facename);
     void SetFamily(wxFontFamily family);
     void SetEncoding(wxFontEncoding encoding);
+#endif
 
     // it is important to be able to serialize wxNativeFontInfo objects to be
     // able to store them (in config file, for example)
@@ -466,7 +487,7 @@ public:
     // that can be used it wxFont ctor otherwise return FALSE
     //bool GetAltForEncoding(wxFontEncoding encoding,
     //                       wxFontEncoding *alt_encoding,
-    //                       const wxString& facename = wxEmptyString,
+    //                       const wxString& facename = wxPyEmptyString,
     //                       bool interactive = TRUE);
 
 
@@ -475,7 +496,7 @@ public:
     // returns None.
     %addmethods {
         PyObject* GetAltForEncoding(wxFontEncoding encoding,
-                                    const wxString& facename = wxEmptyString,
+                                    const wxString& facename = wxPyEmptyString,
                                     bool interactive = TRUE) {
             wxFontEncoding alt_enc;
             if (self->GetAltForEncoding(encoding, &alt_enc, facename, interactive))
@@ -491,7 +512,7 @@ public:
     // checks whether given encoding is available in given face or not.
     // If no facename is given,
     bool IsEncodingAvailable(wxFontEncoding encoding,
-                             const wxString& facename = wxEmptyString);
+                             const wxString& facename = wxPyEmptyString);
 
     // returns the encoding for the given charset (in the form of RFC 2046) or
     // wxFONTENCODING_SYSTEM if couldn't decode it
@@ -526,7 +547,7 @@ public:
     void SetConfigPath(const wxString& prefix);
 
     // return default config path
-    static const wxChar *GetDefaultConfigPath();
+    static wxString GetDefaultConfigPath();
 };
 
 
@@ -535,7 +556,7 @@ public:
 class wxFont : public wxGDIObject {
 public:
     wxFont( int pointSize, int family, int style, int weight,
-            int underline=FALSE, char* faceName = "",
+            int underline=FALSE, const wxString& faceName = wxPyEmptyString,
             wxFontEncoding encoding=wxFONTENCODING_DEFAULT);
 
     %name(wxFontFromNativeInfo)wxFont(const wxNativeFontInfo& info);
@@ -550,6 +571,9 @@ public:
     bool GetUnderlined() const;
     wxString GetFaceName() const;
     wxFontEncoding GetEncoding() const;
+
+    bool IsFixedWidth();
+
     wxNativeFontInfo* GetNativeFontInfo() const;
     wxString GetNativeFontInfoDesc() const;
     wxString GetNativeFontInfoUserDesc() const;
@@ -580,7 +604,7 @@ public:
 
     void AddFont(wxFont* font);
     wxFont * FindOrCreateFont(int point_size, int family, int style, int weight,
-                              bool underline = FALSE, const char* facename = NULL,
+                              bool underline = FALSE, const wxString& facename = wxPyEmptyString,
                               wxFontEncoding encoding = wxFONTENCODING_DEFAULT);
     void RemoveFont(wxFont *font);
 
@@ -632,6 +656,25 @@ public:
 
     %addmethods {
         void Append(const wxString& name, int red, int green, int blue) {
+            // first see if the name is already there
+            wxString cName = name;
+            cName.MakeUpper();
+            wxString cName2 = cName;
+            if ( !cName2.Replace(wxT("GRAY"), wxT("GREY")) )
+                cName2.clear();
+
+            wxNode *node = self->First();
+            while ( node ) {
+                const wxChar *key = node->GetKeyString();
+                if ( cName == key || cName2 == key ) {
+                    wxColour* c = (wxColour *)node->Data();
+                    c->Set(red, green, blue);
+                    return;
+                }
+                node = node->Next();
+            }
+
+            // otherwise append the new colour
             self->Append(name.c_str(), new wxColour(red, green, blue));
         }
     }
@@ -783,6 +826,23 @@ public:
     void DrawEllipse(long x, long y, long width, long height);
     void DrawEllipticArc(long x, long y, long width, long height, long start, long end);
     void DrawIcon(const wxIcon& icon, long x, long y);
+
+    void DrawLabel(const wxString& text, const wxRect& rect,
+                   int alignment = wxALIGN_LEFT | wxALIGN_TOP,
+                   int indexAccel = -1);
+
+    %addmethods {
+        wxRect DrawImageLabel(const wxString& text,
+                              const wxBitmap& image,
+                              const wxRect& rect,
+                              int alignment = wxALIGN_LEFT | wxALIGN_TOP,
+                              int indexAccel = -1) {
+            wxRect rv;
+            self->DrawLabel(text, image, rect, alignment, indexAccel, &rv);
+            return rv;
+        }
+    }
+
     void DrawLine(long x1, long y1, long x2, long y2);
     void DrawLines(int PCOUNT, wxPoint* points, long xoffset=0, long yoffset=0);
     void DrawPolygon(int PCOUNT, wxPoint* points, long xoffset=0, long yoffset=0,
@@ -1085,6 +1145,26 @@ public:
 %}
 
 
+//---------------------------------------------------------------------------
+
+class wxBufferedDC : public wxMemoryDC {
+public:
+        // Construct a wxBufferedDC using a user supplied buffer.
+    wxBufferedDC( wxDC *dc, const wxBitmap &buffer );
+
+        // Construct a wxBufferedDC with an internal buffer of 'area'
+        // (where area is usually something like the size of the window
+        // being buffered)
+    %name(wxBufferedDCInternalBuffer)wxBufferedDC( wxDC *dc, const wxSize &area );
+};
+
+
+class wxBufferedPaintDC : public wxBufferedDC
+{
+public:
+    wxBufferedPaintDC( wxWindow *window, const wxBitmap &buffer = wxNullBitmap );
+};
+
 //---------------------------------------------------------------------------
 
 class wxScreenDC : public wxDC {
@@ -1128,7 +1208,7 @@ public:
 
 class wxMetaFile : public wxObject {
 public:
-    wxMetaFile(const wxString& filename = wxPyEmptyStr);
+    wxMetaFile(const wxString& filename = wxPyEmptyString);
     ~wxMetaFile();
 
     bool Ok();
@@ -1148,9 +1228,9 @@ public:
 
 class wxMetaFileDC : public wxDC {
 public:
-    wxMetaFileDC(const wxString& filename = wxPyEmptyStr,
+    wxMetaFileDC(const wxString& filename = wxPyEmptyString,
                  int width = 0, int height = 0,
-                 const wxString& description = wxPyEmptyStr);
+                 const wxString& description = wxPyEmptyString);
     wxMetaFile* Close();
 };
 
@@ -1220,6 +1300,10 @@ public:
     ~wxRegion();
 
     void Clear();
+#ifndef __WXMAC__
+    bool Offset(wxCoord x, wxCoord y);
+#endif
+
     wxRegionContain Contains(long x, long y);
     %name(ContainsPoint)wxRegionContain Contains(const wxPoint& pt);
     %name(ContainsRect)wxRegionContain Contains(const wxRect& rect);