]> git.saurik.com Git - wxWidgets.git/blobdiff - wxPython/src/_stockobjs.i
handle mouse capture lost event in grid windows and reset the grid to normal state...
[wxWidgets.git] / wxPython / src / _stockobjs.i
index 7ae7546af4a3a74cf7ce59cdf08e1f81b346f426..8eb9289ffa9c46308590df88e46961c51b51ba68 100644 (file)
 %newgroup
 
 
-// See also wxPy_ReinitStockObjects in helpers.cpp
-%immutable;
+class wxStockGDI
+{
+public:
+    enum Item {
+        BRUSH_BLACK,
+        BRUSH_BLUE,
+        BRUSH_CYAN,
+        BRUSH_GREEN,
+        BRUSH_GREY,
+        BRUSH_LIGHTGREY,
+        BRUSH_MEDIUMGREY,
+        BRUSH_RED,
+        BRUSH_TRANSPARENT,
+        BRUSH_WHITE,
+        COLOUR_BLACK,
+        COLOUR_BLUE,
+        COLOUR_CYAN,
+        COLOUR_GREEN,
+        COLOUR_LIGHTGREY,
+        COLOUR_RED,
+        COLOUR_WHITE,
+        CURSOR_CROSS,
+        CURSOR_HOURGLASS,
+        CURSOR_STANDARD,
+        FONT_ITALIC,
+        FONT_NORMAL,
+        FONT_SMALL,
+        FONT_SWISS,
+        PEN_BLACK,
+        PEN_BLACKDASHED,
+        PEN_CYAN,
+        PEN_GREEN,
+        PEN_GREY,
+        PEN_LIGHTGREY,
+        PEN_MEDIUMGREY,
+        PEN_RED,
+        PEN_TRANSPARENT,
+        PEN_WHITE,
+        ITEMCOUNT
+    };
+
+    wxStockGDI();
+    virtual ~wxStockGDI();
+    static void DeleteAll();
+
+    static wxStockGDI& instance();
+
+    static const wxBrush* GetBrush(Item item);
+    static const wxColour* GetColour(Item item);
+    static const wxCursor* GetCursor(Item item);
+    static const wxPen* GetPen(Item item);
+
+    virtual const wxFont* GetFont(Item item);
+
+    %pythoncode {
+    def _initStockObjects():
+        import wx
+        wx.ITALIC_FONT.this  = StockGDI.instance().GetFont(StockGDI.FONT_ITALIC).this
+        wx.NORMAL_FONT.this  = StockGDI.instance().GetFont(StockGDI.FONT_NORMAL).this
+        wx.SMALL_FONT.this   = StockGDI.instance().GetFont(StockGDI.FONT_SMALL).this
+        wx.SWISS_FONT.this   = StockGDI.instance().GetFont(StockGDI.FONT_SWISS).this
+                                              
+        wx.BLACK_DASHED_PEN.this  = StockGDI.GetPen(StockGDI.PEN_BLACKDASHED).this
+        wx.BLACK_PEN.this         = StockGDI.GetPen(StockGDI.PEN_BLACK).this
+        wx.CYAN_PEN.this          = StockGDI.GetPen(StockGDI.PEN_CYAN).this
+        wx.GREEN_PEN.this         = StockGDI.GetPen(StockGDI.PEN_GREEN).this
+        wx.GREY_PEN.this          = StockGDI.GetPen(StockGDI.PEN_GREY).this
+        wx.LIGHT_GREY_PEN.this    = StockGDI.GetPen(StockGDI.PEN_LIGHTGREY).this
+        wx.MEDIUM_GREY_PEN.this   = StockGDI.GetPen(StockGDI.PEN_MEDIUMGREY).this
+        wx.RED_PEN.this           = StockGDI.GetPen(StockGDI.PEN_RED).this
+        wx.TRANSPARENT_PEN.this   = StockGDI.GetPen(StockGDI.PEN_TRANSPARENT).this
+        wx.WHITE_PEN.this         = StockGDI.GetPen(StockGDI.PEN_WHITE).this
+
+        wx.BLACK_BRUSH.this        = StockGDI.GetBrush(StockGDI.BRUSH_BLACK).this
+        wx.BLUE_BRUSH.this         = StockGDI.GetBrush(StockGDI.BRUSH_BLUE).this
+        wx.CYAN_BRUSH.this         = StockGDI.GetBrush(StockGDI.BRUSH_CYAN).this
+        wx.GREEN_BRUSH.this        = StockGDI.GetBrush(StockGDI.BRUSH_GREEN).this
+        wx.GREY_BRUSH.this         = StockGDI.GetBrush(StockGDI.BRUSH_GREY).this
+        wx.LIGHT_GREY_BRUSH.this   = StockGDI.GetBrush(StockGDI.BRUSH_LIGHTGREY).this
+        wx.MEDIUM_GREY_BRUSH.this  = StockGDI.GetBrush(StockGDI.BRUSH_MEDIUMGREY).this
+        wx.RED_BRUSH.this          = StockGDI.GetBrush(StockGDI.BRUSH_RED).this
+        wx.TRANSPARENT_BRUSH.this  = StockGDI.GetBrush(StockGDI.BRUSH_TRANSPARENT).this
+        wx.WHITE_BRUSH.this        = StockGDI.GetBrush(StockGDI.BRUSH_WHITE).this
+
+        wx.BLACK.this       = StockGDI.GetColour(StockGDI.COLOUR_BLACK).this
+        wx.BLUE.this        = StockGDI.GetColour(StockGDI.COLOUR_BLUE).this
+        wx.CYAN.this        = StockGDI.GetColour(StockGDI.COLOUR_CYAN).this
+        wx.GREEN.this       = StockGDI.GetColour(StockGDI.COLOUR_GREEN).this
+        wx.LIGHT_GREY.this  = StockGDI.GetColour(StockGDI.COLOUR_LIGHTGREY).this
+        wx.RED.this         = StockGDI.GetColour(StockGDI.COLOUR_RED).this
+        wx.WHITE.this       = StockGDI.GetColour(StockGDI.COLOUR_WHITE).this
+    
+        wx.CROSS_CURSOR.this      = StockGDI.GetCursor(StockGDI.CURSOR_CROSS).this
+        wx.HOURGLASS_CURSOR.this  = StockGDI.GetCursor(StockGDI.CURSOR_HOURGLASS).this
+        wx.STANDARD_CURSOR.this   = StockGDI.GetCursor(StockGDI.CURSOR_STANDARD).this
+
+        wx.TheFontList.this       = _wxPyInitTheFontList().this
+        wx.ThePenList.this        = _wxPyInitThePenList().this
+        wx.TheBrushList.this      = _wxPyInitTheBrushList().this
+        wx.TheColourDatabase.this = _wxPyInitTheColourDatabase().this
+
+        
+    _initStockObjects = staticmethod(_initStockObjects)
+    }
+};
 
-wxFont* const wxNORMAL_FONT;
-wxFont* const wxSMALL_FONT;
-wxFont* const wxITALIC_FONT;
-wxFont* const wxSWISS_FONT;
-
-wxPen* const wxRED_PEN;
-wxPen* const wxCYAN_PEN;
-wxPen* const wxGREEN_PEN;
-wxPen* const wxBLACK_PEN;
-wxPen* const wxWHITE_PEN;
-wxPen* const wxTRANSPARENT_PEN;
-wxPen* const wxBLACK_DASHED_PEN;
-wxPen* const wxGREY_PEN;
-wxPen* const wxMEDIUM_GREY_PEN;
-wxPen* const wxLIGHT_GREY_PEN;
-
-wxBrush* const wxBLUE_BRUSH;
-wxBrush* const wxGREEN_BRUSH;
-wxBrush* const wxWHITE_BRUSH;
-wxBrush* const wxBLACK_BRUSH;
-wxBrush* const wxTRANSPARENT_BRUSH;
-wxBrush* const wxCYAN_BRUSH;
-wxBrush* const wxRED_BRUSH;
-wxBrush* const wxGREY_BRUSH;
-wxBrush* const wxMEDIUM_GREY_BRUSH;
-wxBrush* const wxLIGHT_GREY_BRUSH;
-
-wxColour* const wxBLACK;
-wxColour* const wxWHITE;
-wxColour* const wxRED;
-wxColour* const wxBLUE;
-wxColour* const wxGREEN;
-wxColour* const wxCYAN;
-wxColour* const wxLIGHT_GREY;
-
-wxCursor* const wxSTANDARD_CURSOR;
-wxCursor* const wxHOURGLASS_CURSOR;
-wxCursor* const wxCROSS_CURSOR;
 
+%pythoncode {
+%# Create an uninitialized instance for the stock objects, they will
+%# be initialized later when the wx.App object is created.
+ITALIC_FONT  = Font.__new__(Font)
+NORMAL_FONT  = Font.__new__(Font)
+SMALL_FONT   = Font.__new__(Font)
+SWISS_FONT   = Font.__new__(Font)
+                                   
+BLACK_DASHED_PEN  = Pen.__new__(Pen)
+BLACK_PEN         = Pen.__new__(Pen)
+CYAN_PEN          = Pen.__new__(Pen)
+GREEN_PEN         = Pen.__new__(Pen)
+GREY_PEN          = Pen.__new__(Pen)
+LIGHT_GREY_PEN    = Pen.__new__(Pen)
+MEDIUM_GREY_PEN   = Pen.__new__(Pen)
+RED_PEN           = Pen.__new__(Pen)
+TRANSPARENT_PEN   = Pen.__new__(Pen)
+WHITE_PEN         = Pen.__new__(Pen)
+
+BLACK_BRUSH        = Brush.__new__(Brush)
+BLUE_BRUSH         = Brush.__new__(Brush)
+CYAN_BRUSH         = Brush.__new__(Brush)
+GREEN_BRUSH        = Brush.__new__(Brush)
+GREY_BRUSH         = Brush.__new__(Brush)
+LIGHT_GREY_BRUSH   = Brush.__new__(Brush)
+MEDIUM_GREY_BRUSH  = Brush.__new__(Brush)
+RED_BRUSH          = Brush.__new__(Brush)
+TRANSPARENT_BRUSH  = Brush.__new__(Brush)
+WHITE_BRUSH        = Brush.__new__(Brush)
+
+BLACK       = Colour.__new__(Colour)
+BLUE        = Colour.__new__(Colour)
+CYAN        = Colour.__new__(Colour)
+GREEN       = Colour.__new__(Colour)
+LIGHT_GREY  = Colour.__new__(Colour)
+RED         = Colour.__new__(Colour)
+WHITE       = Colour.__new__(Colour)
+
+CROSS_CURSOR      = Cursor.__new__(Cursor)
+HOURGLASS_CURSOR  = Cursor.__new__(Cursor)
+STANDARD_CURSOR   = Cursor.__new__(Cursor)
+}                                        
+
+
+%immutable;
+%threadWrapperOff;
 
 const wxBitmap wxNullBitmap;
 const wxIcon   wxNullIcon;
@@ -69,39 +180,73 @@ const wxPalette wxNullPalette;
 const wxFont   wxNullFont;
 const wxColour wxNullColour;
 
+%threadWrapperOn;
 %mutable;
 
 
 //---------------------------------------------------------------------------
 
-class wxPenList : public wxObject {
+
+class wxGDIObjListBase {
+public:
+    wxGDIObjListBase();
+    ~wxGDIObjListBase();
+};
+
+
+class wxPenList : public wxGDIObjListBase {
 public:
 
-    void AddPen(wxPen* pen);
     wxPen* FindOrCreatePen(const wxColour& colour, int width, int style);
-    void RemovePen(wxPen* pen);
 
-    int GetCount();
+    void AddPen(wxPen* pen);
+    void RemovePen(wxPen* pen);
+    %pythoncode {
+        AddPen = wx._deprecated(AddPen)
+        RemovePen = wx._deprecated(RemovePen)
+    }            
+//    int GetCount();
 };
 
 
-//---------------------------------------------------------------------------
-
-class wxBrushList : public wxObject {
+class wxBrushList : public wxGDIObjListBase {
 public:
 
-    void AddBrush(wxBrush *brush);
     wxBrush * FindOrCreateBrush(const wxColour& colour, int style=wxSOLID);
+
+    void AddBrush(wxBrush *brush);
     void RemoveBrush(wxBrush *brush);
+    %pythoncode {
+        AddBrush = wx._deprecated(AddBrush)
+        RemoveBrush = wx._deprecated(RemoveBrush)
+    }
+//    int GetCount();
+};
 
-    int GetCount();
+
+class wxFontList : public wxGDIObjListBase {
+public:
+
+    wxFont * FindOrCreateFont(int point_size, int family, int style, int weight,
+                              bool underline = false,
+                              const wxString& facename = wxPyEmptyString,
+                              wxFontEncoding encoding = wxFONTENCODING_DEFAULT);
+
+    void AddFont(wxFont* font);
+    void RemoveFont(wxFont *font);
+    %pythoncode {
+        AddFont = wx._deprecated(AddFont)
+        RemoveFont = wx._deprecated(RemoveFont)
+    }
+
+//    int GetCount();
 };
 
 //---------------------------------------------------------------------------
 
 MustHaveApp(wxColourDatabase);
 
-class wxColourDatabase : public wxObject {
+class wxColourDatabase {
 public:
     wxColourDatabase();
     ~wxColourDatabase();
@@ -121,34 +266,26 @@ public:
     }
 };
 
-//---------------------------------------------------------------------------
-
-class wxFontList : public wxObject {
-public:
-
-    void AddFont(wxFont* font);
-    wxFont * FindOrCreateFont(int point_size, int family, int style, int weight,
-                              bool underline = false, const wxString& facename = wxPyEmptyString,
-                              wxFontEncoding encoding = wxFONTENCODING_DEFAULT);
-    void RemoveFont(wxFont *font);
-
-    int GetCount();
-};
 
 //---------------------------------------------------------------------------
 %newgroup
 
+%inline {
+    wxFontList* _wxPyInitTheFontList() { return wxTheFontList; }
+    wxPenList* _wxPyInitThePenList() { return wxThePenList; }
+    wxBrushList* _wxPyInitTheBrushList() { return wxTheBrushList; }
+    wxColourDatabase* _wxPyInitTheColourDatabase() { return wxTheColourDatabase; }
+}
 
-
-// See also wxPy_ReinitStockObjects in helpers.cpp
-%immutable;
-
-wxFontList*       const wxTheFontList;
-wxPenList*        const wxThePenList;
-wxBrushList*      const wxTheBrushList;
-wxColourDatabase* const wxTheColourDatabase;
-
-%mutable;
+%pythoncode {
+    
+%# Create an uninitialized instance for the stock objects, they will
+%# be initialized later when the wx.App object is created.
+TheFontList       = FontList.__new__(FontList)
+ThePenList        = PenList.__new__(PenList)
+TheBrushList      = BrushList.__new__(BrushList)
+TheColourDatabase = ColourDatabase.__new__(ColourDatabase)
+}
 
 
 //---------------------------------------------------------------------------