Example #1
0
def addBaseVirtuals(c):
    # The overloading of SetData in wxDataObjectSimple and derived classes
    # really confuses things, so in case SetData is overridden in a Python
    # class then assume they want the one in DataObjectSimple without the
    # format arg, and make the base class version always call the C++
    # implementation instead of trying to call the Python method.
    c.addCppMethod('bool', 'SetData', '(const wxDataFormat& format, wxPyBuffer* buf)',
        cppSignature='bool (const wxDataFormat& format, size_t len, const void* buf)',
        isVirtual=True,
        doc="",
        body="return self->SetData(*format, buf->m_len, buf->m_ptr);",
        virtualCatcherCode="""\
            {0}* self = static_cast<{0}*>(wxPyGetCppPtr(sipPySelf));
            sipRes = self->{0}::SetData(format, len, buf);
            """.format(c.name))

    # We need to let SIP know that the pure virtuals in the base class have
    # implementations in C even though they will not be used much (if at
    # all.)
    if not c.findItem('GetFormatCount'):
        c.addItem(
            etgtools.WigCode(code="virtual size_t GetFormatCount(Direction dir = Get) const;"))

    c.addItem(etgtools.WigCode(code="""\
        virtual wxDataFormat GetPreferredFormat(Direction dir = Get) const;
        private:
        virtual size_t GetDataSize(const wxDataFormat& format) const;
        virtual bool   GetDataHere(const wxDataFormat& format, void* buf) const;
        """))
Example #2
0
def run():
    # Parse the XML file(s) building a collection of Extractor objects
    module = etgtools.ModuleDef(PACKAGE, MODULE, NAME, DOCSTRING)
    etgtools.parseDoxyXML(module, ITEMS)

    #-----------------------------------------------------------------
    # Tweak the parsed meta objects in the module object as needed for
    # customizing the generated code and docstrings.

    c = module.find('wxVarScrollHelperBase')
    assert isinstance(c, etgtools.ClassDef)
    c.find('OnGetUnitsSizeHint').ignore(False)
    c.find('EstimateTotalSize').ignore(False)
    c.find('OnGetUnitSize').ignore(False)

    # SIP apparently has some issues when generating code for calling
    # virtuals in the base class when there is diamond inheritance going on,
    # it seems to confuse the compiler. By telling SIP that the methods are
    # reimplemented in the branches of the diamond (which they are in this
    # case) then that version of the generated code works better. We'll add
    # this block of declarations to each of the two helper classes below.
    baseVirtuals = """\
    virtual void OnGetUnitsSizeHint(size_t unitMin, size_t unitMax) const;
    virtual wxCoord EstimateTotalSize() const;
    virtual int GetNonOrientationTargetSize() const;
    virtual wxOrientation GetOrientation() const;
    virtual int GetOrientationTargetSize() const;
    virtual wxCoord OnGetUnitSize(size_t unit) const;
    """

    c = module.find('wxVarVScrollHelper')
    c.find('EstimateTotalHeight').ignore(False)
    c.find('OnGetRowsHeightHint').ignore(False)
    c.find('OnGetRowHeight').ignore(False)
    c.addItem(etgtools.WigCode(baseVirtuals, protection='protected'))
    c.find('RefreshRows.from').name = 'from_'
    c.find('RefreshRows.to').name = 'to_'

    c = module.find('wxVarHScrollHelper')
    c.find('EstimateTotalWidth').ignore(False)
    c.find('OnGetColumnsWidthHint').ignore(False)
    c.find('OnGetColumnWidth').ignore(False)
    c.addItem(etgtools.WigCode(baseVirtuals, protection='protected'))
    c.find('RefreshColumns.from').name = 'from_'
    c.find('RefreshColumns.to').name = 'to_'

    c = module.find('wxVarHVScrollHelper')

    c = module.find('wxVScrolledWindow')
    tools.fixWindowClass(c)

    c = module.find('wxHScrolledWindow')
    tools.fixWindowClass(c)

    c = module.find('wxHVScrolledWindow')
    tools.fixWindowClass(c)

    #-----------------------------------------------------------------
    tools.doCommonTweaks(module)
    tools.runGenerators(module)
Example #3
0
    def _fixDrawObject(c, addMissingVirtuals=True):
        assert isinstance(c, etgtools.ClassDef)
        if c.findItem('HitTest'):
            c.find('HitTest.textPosition').out = True
            c.find('HitTest.obj').out = True
            c.find('HitTest.contextObj').out = True

        if c.findItem('FindPosition'):
            c.find('FindPosition.pt').out = True
            c.find('FindPosition.height').out = True

        if c.findItem('GetBoxRects'):
            c.find('GetBoxRects.marginRect').out = True
            c.find('GetBoxRects.borderRect').out = True
            c.find('GetBoxRects.contentRect').out = True
            c.find('GetBoxRects.paddingRect').out = True
            c.find('GetBoxRects.outlineRect').out = True

        if c.findItem('GetTotalMargin'):
            c.find('GetTotalMargin.leftMargin').out = True
            c.find('GetTotalMargin.rightMargin').out = True
            c.find('GetTotalMargin.topMargin').out = True
            c.find('GetTotalMargin.bottomMargin').out = True

        if c.findItem('CalculateRange'):
            c.find('CalculateRange.end').out = True  # TODO: should it be an inOut?

        if c.findItem('Clone'):
            c.find('Clone').factory = True
        else:
            c.addItem(etgtools.WigCode("""\
            virtual wxRichTextObject* Clone() const /Factory/;
            """))

        # These are the pure virtuals in the base class. SIP needs to see that
        # all the derived classes have an implementation, otherwise it will
        # consider them to be ABCs.
        if not c.findItem('Draw') and addMissingVirtuals:
            c.addItem(etgtools.WigCode("""\
                virtual bool Draw(wxDC& dc, wxRichTextDrawingContext& context,
                                  const wxRichTextRange& range,
                                  const wxRichTextSelection& selection,
                                  const wxRect& rect, int descent, int style);"""))
        if not c.findItem('Layout') and addMissingVirtuals:
            c.addItem(etgtools.WigCode("""\
                virtual bool Layout(wxDC& dc, wxRichTextDrawingContext& context,
                                    const wxRect& rect, const wxRect& parentRect,
                                    int style);"""))

        # TODO: Some of these args are output parameters.  How should they be dealt with?
        if not c.findItem('GetRangeSize') and addMissingVirtuals:
            c.addItem(etgtools.WigCode("""\
                virtual bool GetRangeSize(const wxRichTextRange& range, wxSize& size,
                              int& descent,
                              wxDC& dc, wxRichTextDrawingContext& context, int flags,
                              const wxPoint& position = wxPoint(0,0),
                              const wxSize& parentSize = wxDefaultSize,
                              wxArrayInt* partialExtents = NULL) const;"""))
Example #4
0
def run():
    # Parse the XML file(s) building a collection of Extractor objects
    module = etgtools.ModuleDef(PACKAGE, MODULE, NAME, DOCSTRING)
    etgtools.parseDoxyXML(module, ITEMS)

    #-----------------------------------------------------------------
    # Tweak the parsed meta objects in the module object as needed for
    # customizing the generated code and docstrings.

    module.addHeaderCode("#include <wx/htmllbox.h>")

    c = module.find('wxHtmlListBox')
    assert isinstance(c, etgtools.ClassDef)
    tools.fixWindowClass(c, False, False)
    tools.addWindowVirtuals(c)

    module.addGlobalStr('wxHtmlListBoxNameStr', c)

    # We only need one of these
    c.find('GetFileSystem').ignore()

    # let sip know that these pure virtuals have been implemented in this class
    c.addItem(
        etgtools.WigCode("""\
        protected:
        virtual void OnDrawItem(wxDC& dc, const wxRect& rect, size_t n) const;
        virtual wxCoord OnMeasureItem(size_t n) const;
        """))

    c = module.find('wxSimpleHtmlListBox')
    tools.fixWindowClass(c)

    # ignore the ctor and Create method taking the C array
    c.find('wxSimpleHtmlListBox').findOverload('int n').ignore()
    c.find('Create').findOverload('int n').ignore()

    c.find('wxSimpleHtmlListBox.choices').default = 'wxArrayString()'
    c.find('Create.choices').default = 'wxArrayString()'

    # let sip know that these pure virtuals have been implemented in this class
    c.addItem(
        etgtools.WigCode("""\
        virtual unsigned int GetCount() const;
        virtual wxString GetString(unsigned int n) const;
        virtual void SetString(unsigned int n, const wxString & string);
        virtual void SetSelection(int n);
        virtual int GetSelection() const;

        protected:
        virtual wxString OnGetItem(size_t n) const;
        """))

    module.addGlobalStr('wxSimpleHtmlListBoxNameStr', c)

    #-----------------------------------------------------------------
    tools.doCommonTweaks(module)
    tools.runGenerators(module)
Example #5
0
def run():
    # Parse the XML file(s) building a collection of Extractor objects
    module = etgtools.ModuleDef(PACKAGE, MODULE, NAME, DOCSTRING)
    etgtools.parseDoxyXML(module, ITEMS)

    #-----------------------------------------------------------------
    # Tweak the parsed meta objects in the module object as needed for
    # customizing the generated code and docstrings.

    module.addHeaderCode('#include <wx/odcombo.h>')

    c = module.find('wxOwnerDrawnComboBox')
    assert isinstance(c, etgtools.ClassDef)
    tools.fixWindowClass(c)

    # Ignore the old C array verison of the ctor and Create methods, and
    # fixup the remaining ctor and Create with the typical default values for
    # the args
    c.find('wxOwnerDrawnComboBox').findOverload('wxString choices').ignore()
    m = c.find('wxOwnerDrawnComboBox').findOverload('wxArrayString')
    m.find('value').default = 'wxEmptyString'
    m.find('choices').default = 'wxArrayString()'

    c.find('Create').ignore()
    c.find('Create').findOverload('wxString choices').ignore()
    m = c.find('Create').findOverload('wxArrayString')
    m.find('value').default = 'wxEmptyString'
    m.find('choices').default = 'wxArrayString()'

    # Unignore the protected methods that should be overridable in Python
    c.find('OnDrawBackground').ignore(False).isVirtual = True
    c.find('OnDrawItem').ignore(False).isVirtual = True
    c.find('OnMeasureItem').ignore(False).isVirtual = True
    c.find('OnMeasureItemWidth').ignore(False).isVirtual = True

    # wxItemContainer pure virtuals that have an implementation in this class
    c.addItem(
        etgtools.WigCode("""\
        virtual unsigned int GetCount() const;
        virtual wxString GetString(unsigned int n) const;
        virtual void SetString(unsigned int n, const wxString& s);
        virtual int GetSelection() const;
        virtual void SetSelection(int n);
        """))

    # wxComboCtrl virtuals that have an implementation in this class
    c.addItem(
        etgtools.WigCode("""\
        protected:
        virtual void DoSetPopupControl(wxComboPopup* popup);
        virtual void DoShowPopup(const wxRect& rect, int flags);
        """))

    #-----------------------------------------------------------------
    tools.doCommonTweaks(module)
    tools.runGenerators(module)
Example #6
0
 def _fixHandlerClass(klass):
     klass.addItem(etgtools.WigCode("""\
         virtual bool CanOpen(const wxString& location);
         virtual wxFSFile* OpenFile(wxFileSystem& fs, const wxString& location);
         virtual wxString FindFirst(const wxString& spec, int flags = 0);
         virtual wxString FindNext();
         """))
Example #7
0
def run():
    # Parse the XML file(s) building a collection of Extractor objects
    module = etgtools.ModuleDef(PACKAGE, MODULE, NAME, DOCSTRING)
    etgtools.parseDoxyXML(module, ITEMS)

    #-----------------------------------------------------------------
    # Tweak the parsed meta objects in the module object as needed for
    # customizing the generated code and docstrings.

    c = module.find('wxWizardPage')
    assert isinstance(c, etgtools.ClassDef)
    tools.fixWindowClass(c, False)
    module.addPyCode("PyWizardPage = wx.deprecated(WizardPage, 'Use WizardPage instead.')")


    c = module.find('wxWizardPageSimple')
    tools.fixWindowClass(c, False)
    c.addItem(etgtools.WigCode("""\
        virtual wxWizardPage* GetNext() const;
        virtual wxWizardPage* GetPrev() const;
        """))


    c = module.find('wxWizard')
    tools.fixWindowClass(c, False)

    # ShowPage is undocumented and labeled "implementation only" but it seems
    # too useful to ignore, so add a MethodDef for it here.
    m = MethodDef(name='ShowPage', type='bool', isVirtual=True,
            briefDoc="Show the given wizard page.",
            detailedDoc=["""\
                Calls TransferDataFromWindow on the current page first, and
                returns false without changing the page if it returned false.
                Returns True/False to indicate if the page was actually
                changed."""],
            items=[ParamDef(name='page', type='wxWizardPage*'),
                   ParamDef(name='goingForward', type='bool', default='true')])
    c.addItem(m)

    # Same for IsRunning
    m = MethodDef(name='IsRunning', type='bool', isConst=True)
    c.addItem(m)


    c = module.find('wxWizardEvent')
    tools.fixEventClass(c)
    module.addPyCode("""\
        EVT_WIZARD_BEFORE_PAGE_CHANGED  = wx.PyEventBinder( wxEVT_WIZARD_BEFORE_PAGE_CHANGED, 1)
        EVT_WIZARD_PAGE_CHANGED  = wx.PyEventBinder( wxEVT_WIZARD_PAGE_CHANGED, 1)
        EVT_WIZARD_PAGE_CHANGING = wx.PyEventBinder( wxEVT_WIZARD_PAGE_CHANGING, 1)
        EVT_WIZARD_CANCEL        = wx.PyEventBinder( wxEVT_WIZARD_CANCEL, 1)
        EVT_WIZARD_HELP          = wx.PyEventBinder( wxEVT_WIZARD_HELP, 1)
        EVT_WIZARD_FINISHED      = wx.PyEventBinder( wxEVT_WIZARD_FINISHED, 1)
        EVT_WIZARD_PAGE_SHOWN    = wx.PyEventBinder( wxEVT_WIZARD_PAGE_SHOWN, 1)
        """)


    #-----------------------------------------------------------------
    tools.doCommonTweaks(module)
    tools.runGenerators(module)
Example #8
0
def run():
    # Parse the XML file(s) building a collection of Extractor objects
    module = etgtools.ModuleDef(PACKAGE, MODULE, NAME, DOCSTRING)
    etgtools.parseDoxyXML(module, ITEMS)

    #-----------------------------------------------------------------
    # Tweak the parsed meta objects in the module object as needed for
    # customizing the generated code and docstrings.

    c = module.find('wxHtmlHelpController')
    assert isinstance(c, etgtools.ClassDef)
    c.mustHaveApp()
    c.addPrivateCopyCtor()

    c.find('CreateHelpDialog').ignore(False)
    c.find('CreateHelpFrame').ignore(False)

    c.addItem(etgtools.WigCode("""\
        // Add implementations for the pure virtuals in the base class
        virtual bool DisplayBlock(long blockNo);
        virtual bool DisplaySection(int sectionNo);
        virtual bool LoadFile(const wxString& file = wxEmptyString);
        virtual bool Quit();
        """))

    #-----------------------------------------------------------------
    tools.doCommonTweaks(module)
    tools.runGenerators(module)
Example #9
0
def run():
    # Parse the XML file(s) building a collection of Extractor objects
    module = etgtools.ModuleDef(PACKAGE, MODULE, NAME, DOCSTRING)
    etgtools.parseDoxyXML(module, ITEMS)

    #-----------------------------------------------------------------
    # Tweak the parsed meta objects in the module object as needed for
    # customizing the generated code and docstrings.

    c = module.find('wxContextHelpButton')
    assert isinstance(c, etgtools.ClassDef)
    tools.fixWindowClass(c)

    c = module.find('wxHelpProvider')
    c.abstract = True
    c.find('Set').transferBack = True
    c.find('Set.helpProvider').transfer = True

    c = module.find('wxSimpleHelpProvider')
    c.addItem(
        etgtools.WigCode(
            "virtual wxString GetHelp(const wxWindowBase* window);"))

    c = module.find('wxHelpControllerHelpProvider')
    c.addPrivateCopyCtor()

    #-----------------------------------------------------------------
    tools.doCommonTweaks(module)
    tools.runGenerators(module)
Example #10
0
def addSimpleVirtuals(c):
    # Same thing for classes derived from wxDataObjectSimple.
    c.addItem(etgtools.WigCode(code="""\
        virtual bool GetDataHere(void* buf) const;
        virtual size_t GetDataSize() const;
        virtual bool SetData(size_t len, const void *buf);
        """))
Example #11
0
def run():
    # Parse the XML file(s) building a collection of Extractor objects
    module = etgtools.ModuleDef(PACKAGE, MODULE, NAME, DOCSTRING)
    etgtools.parseDoxyXML(module, ITEMS)

    #-----------------------------------------------------------------
    # Tweak the parsed meta objects in the module object as needed for
    # customizing the generated code and docstrings.

    module.addHeaderCode('#include <wx/collheaderctrl.h>')

    c = module.find('wxCollapsibleHeaderCtrl')
    assert isinstance(c, etgtools.ClassDef)
    tools.fixWindowClass(c)
    c.find('wxCollapsibleHeaderCtrl.label').default = '""'
    c.find('Create.label').default = '""'

    module.addGlobalStr('wxCollapsibleHeaderCtrlNameStr', c)
    module.addItem(
        etgtools.WigCode(
            "wxEventType wxEVT_COLLAPSIBLEHEADER_CHANGED /PyName=wxEVT_COLLAPSIBLEHEADER_CHANGED/;"
        ))
    module.addPyCode("""\
        EVT_COLLAPSIBLEHEADER_CHANGED = PyEventBinder(wxEVT_COLLAPSIBLEHEADER_CHANGED, 1)
        """)

    #-----------------------------------------------------------------
    tools.doCommonTweaks(module)
    tools.runGenerators(module)
Example #12
0
def fixCellClass(klass):
    klass.addItem(etgtools.WigCode("""\
        virtual void Draw(wxDC& dc, int x, int y, int view_y1, int view_y2, wxHtmlRenderingInfo& info);
        virtual void DrawInvisible(wxDC& dc, int x , int y, wxHtmlRenderingInfo& info);
        virtual wxCursor GetMouseCursor(wxHtmlWindowInterface* window) const;
        virtual void Layout(int w);
        """))
Example #13
0
def wxArrayPtrWrapperTemplate(ArrayClass, ItemClass, module):
    moduleName = module.module
    ArrayClass_pyName = removeWxPrefix(ArrayClass)

    # *** TODO: This can probably be done in a way that is not SIP-specfic.
    # Try creating extractor objects from scratch and attach cppMethods to
    # them as needed, etc..

    return extractors.WigCode('''\
class {ArrayClass}
{{
public:
    SIP_SSIZE_T __len__();
    %MethodCode
        sipRes = sipCpp->GetCount();
    %End

    {ItemClass}* __getitem__(ulong index);
    %MethodCode
        if (index < sipCpp->GetCount()) {{
            sipRes = sipCpp->Item(index);
        }}
        else {{
            wxPyErr_SetString(PyExc_IndexError, "sequence index out of range");
            sipError = sipErrorFail;
        }}
    %End

    int __contains__({ItemClass}* obj);
    %MethodCode
        int idx = sipCpp->Index(obj, false);
        sipRes = idx != wxNOT_FOUND;
    %End

    void append({ItemClass}* obj);
    %MethodCode
        sipCpp->Add(obj);
    %End

    // TODO:  add support for index(value, [start, [stop]])
    int index({ItemClass}* obj);
    %MethodCode
        int idx = sipCpp->Index(obj, false);
        if (idx == wxNOT_FOUND) {{
            sipError = sipErrorFail;
            wxPyErr_SetString(PyExc_ValueError,
                              "sequence.index(x): x not in sequence");
            }}
        sipRes = idx;
    %End
}};

%Extract(id=pycode{moduleName})
def _{ArrayClass_pyName}___repr__(self):
    return "{ArrayClass_pyName}: " + repr(list(self))
{ArrayClass_pyName}.__repr__ = _{ArrayClass_pyName}___repr__
del _{ArrayClass_pyName}___repr__
%End
'''.format(**locals()))
Example #14
0
def run():
    # Parse the XML file(s) building a collection of Extractor objects
    module = etgtools.ModuleDef(PACKAGE, MODULE, NAME, DOCSTRING)
    etgtools.parseDoxyXML(module, ITEMS)
    
    #-----------------------------------------------------------------
    # Tweak the parsed meta objects in the module object as needed for
    # customizing the generated code and docstrings.
    
    module.addHeaderCode("#include <wx/bmpcbox.h>")
    
    c = module.find('wxBitmapComboBox')
    assert isinstance(c, etgtools.ClassDef)
    module.addGlobalStr('wxBitmapComboBoxNameStr', c)
    tools.fixWindowClass(c)
    
    # The MSW and GTK version of this class derive from wxComboBox, but the
    # OSX version derives from wxOwnerDrawnCombo. To make all platforms happy
    # with the generated wrapper code switch the declared base with the bases
    # that both of those classes have in common.
    c.bases = ['wxControl', 'wxTextEntry', 'wxItemContainer']

    
    # Ignore the old C array verison of the ctor and Create methods, and
    # fixup the remaining ctor and Create with the typical default values for
    # the args
    c.find('wxBitmapComboBox').findOverload('wxString choices').ignore()
    m = c.find('wxBitmapComboBox').findOverload('wxArrayString')
    m.find('value').default = 'wxEmptyString'
    m.find('choices').default = 'wxArrayString()'
    m.find('style').default = '0'

    c.find('Create').findOverload('wxString choices').ignore()
    m = c.find('Create').findOverload('wxArrayString')
    m.find('value').default = 'wxEmptyString'
    m.find('choices').default = 'wxArrayString()'
    
    # Ignore the Append and Insert taking a void* for clientData
    c.find('Append').findOverload('void *').ignore()
    c.find('Insert').findOverload('void *').ignore()
    
    # And set the ownership transfer for the other one
    c.find('Append').findOverload('wxClientData *').find('clientData').transfer = True
    c.find('Insert').findOverload('wxClientData *').find('clientData').transfer = True
    
    
    # wxItemContainer pure virtuals that have an implementation in this class
    c.addItem(etgtools.WigCode("""\
        virtual unsigned int GetCount() const;
        virtual wxString GetString(unsigned int n) const;
        virtual void SetString(unsigned int n, const wxString& s);
        virtual int GetSelection() const;
        virtual void SetSelection(int n);
        """))
    
    #-----------------------------------------------------------------
    tools.doCommonTweaks(module)
    tools.runGenerators(module)
Example #15
0
def run():
    # Parse the XML file(s) building a collection of Extractor objects
    module = etgtools.ModuleDef(PACKAGE, MODULE, NAME, DOCSTRING)
    etgtools.parseDoxyXML(module, ITEMS)

    #-----------------------------------------------------------------
    # Tweak the parsed meta objects in the module object as needed for
    # customizing the generated code and docstrings.

    c = module.find('wxHtmlWindow')
    assert isinstance(c, etgtools.ClassDef)
    tools.fixWindowClass(c)
    c.bases = ['wxScrolledWindow']

    c.find('OnCellClicked').ignore(False)
    c.find('OnCellMouseHover').ignore(False)
    c.find('AddFilter.filter').transfer = True

    tools.fixHtmlSetFonts(c)

    # Pure virtuals inherited from wxHtmlWindowInterface
    c.addItem(etgtools.WigCode("""\
        virtual void SetHTMLWindowTitle(const wxString& title);
        virtual void OnHTMLLinkClicked(const wxHtmlLinkInfo& link);
        virtual wxHtmlOpeningStatus OnHTMLOpeningURL(wxHtmlURLType type,
                                                     const wxString& url,
                                                     wxString *redirect) const;
        virtual wxPoint HTMLCoordsToWindow(wxHtmlCell *cell,
                                           const wxPoint& pos) const;
        virtual wxWindow* GetHTMLWindow();
        virtual wxColour GetHTMLBackgroundColour() const;
        virtual void SetHTMLBackgroundColour(const wxColour& clr);
        virtual void SetHTMLBackgroundImage(const wxBitmap& bmpBg);
        virtual void SetHTMLStatusText(const wxString& text);
        virtual wxCursor GetHTMLCursor(wxHtmlWindowInterface::HTMLCursor type) const;
        """))

    c = module.find('wxHtmlLinkEvent')
    tools.fixEventClass(c)

    c = module.find('wxHtmlCellEvent')
    tools.fixEventClass(c)

    module.addPyCode("""\
        EVT_HTML_CELL_CLICKED = wx.PyEventBinder( wxEVT_HTML_CELL_CLICKED, 1 )
        EVT_HTML_CELL_HOVER   = wx.PyEventBinder( wxEVT_HTML_CELL_HOVER, 1 )
        EVT_HTML_LINK_CLICKED = wx.PyEventBinder( wxEVT_HTML_LINK_CLICKED, 1 )

        # deprecated wxEVT aliases
        wxEVT_COMMAND_HTML_CELL_CLICKED  = wxEVT_HTML_CELL_CLICKED
        wxEVT_COMMAND_HTML_CELL_HOVER    = wxEVT_HTML_CELL_HOVER
        wxEVT_COMMAND_HTML_LINK_CLICKED  = wxEVT_HTML_LINK_CLICKED
        """)


    #-----------------------------------------------------------------
    tools.doCommonTweaks(module)
    tools.runGenerators(module)
Example #16
0
def fixBookctrlClass(klass, treeBook=False):
    """
    Add declarations of the pure virtual methods from the base class.
    """
    klass.addItem(extractors.WigCode("""\
        virtual int GetPageImage(size_t nPage) const;
        virtual bool SetPageImage(size_t page, int image);
        virtual wxString GetPageText(size_t nPage) const;
        virtual bool SetPageText(size_t page, const wxString& text);
        virtual int SetSelection(size_t page);
        virtual int ChangeSelection(size_t page);
        """))
    if not treeBook:
        klass.addItem(extractors.WigCode("""\
        virtual int GetSelection() const;
        virtual bool InsertPage(size_t index, wxWindow * page, const wxString & text,
                                bool select = false, int imageId = NO_IMAGE);
        """))
Example #17
0
def run():
    # Parse the XML file(s) building a collection of Extractor objects
    module = etgtools.ModuleDef(PACKAGE, MODULE, NAME, DOCSTRING)
    etgtools.parseDoxyXML(module, ITEMS)

    #-----------------------------------------------------------------
    # Tweak the parsed meta objects in the module object as needed for
    # customizing the generated code and docstrings.

    c = module.find('wxPropertyGridPage')
    assert isinstance(c, etgtools.ClassDef)
    tools.ignoreConstOverloads(c)

    module.addGlobalStr('wxPropertyGridManagerNameStr', c)

    c = module.find('wxPropertyGridManager')
    tools.fixWindowClass(c, hideVirtuals=False, ignoreProtected=False)
    tools.ignoreConstOverloads(c)

    c.find('AddPage.pageObj').transfer = True

    # Add some extra Python code to be executed when a wxPropertyGridManager
    # is constructed. In Classic with SWIG we did this with %pythonAppend, is
    # there any better way to do it with sip than monkey-patching?
    c.addPyCode("""\
        _PropertyGridManager__init__orig = PropertyGridManager.__init__
        def _PropertyGridManager__init__(self, *args, **kw):
            _PropertyGridManager__init__orig(self, *args, **kw)
            self.DoDefaultTypeMappings()
            self.edited_objects = {}
            self.DoDefaultValueTypeMappings()
            if not hasattr(self.__class__, '_vt2setter'):
                self.__class__._vt2setter = {}
        PropertyGridManager.__init__ = _PropertyGridManager__init__
        """)

    # Make sure sip knows there is an implementation of this method
    c.addItem(
        etgtools.WigCode("""\
        virtual void RefreshProperty( wxPGProperty* p );
        """))

    # wxPGPropArg is a typedef for "const wxPGPropArgCls&" so having the
    # wrappers treat it as a normal type can be problematic. ("new cannot be
    # applied to a reference type", etc.) Let's just ignore it an replace it
    # everywhere for the real type.
    for item in module.allItems():
        if hasattr(item, 'type') and item.type == 'wxPGPropArg':
            item.type = 'const wxPGPropArgCls &'

    #-----------------------------------------------------------------
    tools.doCommonTweaks(module)
    tools.runGenerators(module)
Example #18
0
def run():
    # Parse the XML file(s) building a collection of Extractor objects
    module = etgtools.ModuleDef(PACKAGE, MODULE, NAME, DOCSTRING)
    etgtools.parseDoxyXML(module, ITEMS)

    #-----------------------------------------------------------------
    # Tweak the parsed meta objects in the module object as needed for
    # customizing the generated code and docstrings.

    c = module.find('wxTranslations')
    assert isinstance(c, etgtools.ClassDef)
    c.find('Set.t').transfer = True
    c.find('SetLoader.loader').transfer = True
    c.find('AddCatalog').findOverload('msgIdCharset').ignore()

    c = module.find('wxTranslationsLoader')
    c.abstract = True
    c.find('LoadCatalog').factory = True

    c = module.find('wxFileTranslationsLoader')
    c.addItem(
        etgtools.WigCode("""\
    virtual wxMsgCatalog *LoadCatalog(const wxString& domain, const wxString& lang);
    virtual wxArrayString GetAvailableTranslations(const wxString& domain) const;
    """))

    #c = module.find('wxMsgCatalog')
    #c.find('CreateFromFile').factory = True
    #c.find('CreateFromData').ignore()          # Needs wxScopedCharBuffer
    ##c.find('CreateFromData').factory = True
    #c.addPrivateCopyCtor()

    # Just add a forward declaration for now
    module.insertItem(0, etgtools.WigCode("class wxMsgCatalog;"))

    module.find('_').ignore()

    #-----------------------------------------------------------------
    tools.doCommonTweaks(module)
    tools.runGenerators(module)
Example #19
0
def run():
    # Parse the XML file(s) building a collection of Extractor objects
    module = etgtools.ModuleDef(PACKAGE, MODULE, NAME, DOCSTRING)
    etgtools.parseDoxyXML(module, ITEMS)

    #-----------------------------------------------------------------
    # Tweak the parsed meta objects in the module object as needed for
    # customizing the generated code and docstrings.

    # Let the generator know about these intermediate classes even though they
    # are undocumented. wxTDIChildFrame is used elsewhere in the class hierarchy
    # so it needs to be available.
    module.insertItemBefore(
        module.find('wxMDIClientWindow'),
        etgtools.WigCode("""\
class wxMDIChildFrameBase : wxFrame
{
public:
    wxMDIChildFrameBase();
    virtual void Activate() = 0;
    wxMDIParentFrame *GetMDIParent() const;
    virtual bool IsTopLevel() const;
};

class wxTDIChildFrame : wxMDIChildFrameBase /Abstract/
{
public:
};
    """))

    c = module.find('wxMDIClientWindow')
    assert isinstance(c, etgtools.ClassDef)
    tools.fixWindowClass(c)
    c.find('CreateClient').isVirtual = True

    c = module.find('wxMDIParentFrame')
    tools.fixTopLevelWindowClass(c)
    c.find('OnCreateClient').isVirtual = True

    m = c.find('GetClientWindow')
    assert isinstance(m, etgtools.MethodDef)
    m.type = 'wxMDIClientWindow *'
    m.setCppCode(
        "return static_cast<wxMDIClientWindow*>(self->GetClientWindow());")

    c = module.find('wxMDIChildFrame')
    c.bases = ['wxMDIChildFrameBase']
    tools.fixTopLevelWindowClass(c)

    #-----------------------------------------------------------------
    tools.doCommonTweaks(module)
    tools.runGenerators(module)
Example #20
0
def run():
    # Parse the XML file(s) building a collection of Extractor objects
    module = etgtools.ModuleDef(PACKAGE, MODULE, NAME, DOCSTRING)
    etgtools.parseDoxyXML(module, ITEMS)

    #-----------------------------------------------------------------
    # Tweak the parsed meta objects in the module object as needed for
    # customizing the generated code and docstrings.

    module.addHeaderCode('#include <wx/ribbon/gallery.h>')
    module.insertItem(
        0,
        etgtools.WigCode("""\
        // forward declarations
        class wxRibbonGalleryItem;
        """))

    c = module.find('wxRibbonGallery')
    assert isinstance(c, etgtools.ClassDef)
    tools.fixWindowClass(c)

    # Ignore the methods setting and fetching client data as a void*.  We have
    # a mapped type for the wxClientData alternatives that work well and are
    # hack free.
    c.find('Append').findOverload('void *').ignore()
    c.find('SetItemClientData').ignore()
    c.find('GetItemClientData').ignore()

    # Methods assigning wxClientData objects need to transfer ownership
    c.find('SetItemClientObject.data').transfer = True
    c.find('Append').findOverload('wxClientData').find(
        'clientData').transfer = True

    # And let's change the names of the "Object" version of the methods
    c.find('SetItemClientObject').pyName = 'SetItemClientData'
    c.find('GetItemClientObject').pyName = 'GetItemClientData'

    c = module.find('wxRibbonGalleryEvent')
    tools.fixEventClass(c)

    module.addPyCode("""\
        EVT_RIBBONGALLERY_HOVER_CHANGED = wx.PyEventBinder( wxEVT_RIBBONGALLERY_HOVER_CHANGED, 1 )
        EVT_RIBBONGALLERY_SELECTED = wx.PyEventBinder( wxEVT_RIBBONGALLERY_SELECTED, 1 )
        EVT_RIBBONGALLERY_CLICKED = wx.PyEventBinder( wxEVT_RIBBONGALLERY_CLICKED, 1 )
        """)

    #-----------------------------------------------------------------
    tools.doCommonTweaks(module)
    tools.runGenerators(module)
Example #21
0
def fixWindowClass(klass, hideVirtuals=True, ignoreProtected=True):
    """
    Do common tweaks for a window class.
    """
    # NOTE: it may be okay to just do mustHaveApp for top-level windows
    # TODO: look into that possibility
    klass.mustHaveApp()

    # The ctor and Create method transfer ownership of the this pointer to the parent
    for func in klass.findAll(klass.name) + klass.findAll('Create'):
        if isinstance(func, extractors.MethodDef):
            # if a class has an empty ctor it might not have this
            parent = func.findItem('parent')
            if parent:
                parent.transferThis = True
            # if there is an id param give it a default
            id = func.findItem('id') or func.findItem('winid')
            if id and not id.default:
                id.default = 'wxID_ANY'

            # if there is a pos or size parameter without a default then give it one.
            p = func.findItem('pos')
            if p and not p.default:
                p.default = 'wxDefaultPosition'
            p = func.findItem('size')
            if p and not p.default:
                p.default = 'wxDefaultSize'

    if hideVirtuals:
        # There is no need to make all the C++ virtuals overridable in Python, and
        # hiding the fact that they are virtual from the backend generator will
        # greatly reduce the amount of code that needs to be generated. Remove all
        # the virtual flags, and then add it back to a select few.
        removeVirtuals(klass)
        addWindowVirtuals(klass)

    if not klass.findItem('GetClassDefaultAttributes'):
        klass.addItem(
            extractors.WigCode("""\
            static wxVisualAttributes
            GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL);
            """))

    if not ignoreProtected:
        for item in klass.allItems():
            if isinstance(
                    item,
                    extractors.MethodDef) and item.protection == 'protected':
                item.ignore(False)
Example #22
0
    def fixRendererClass(name):
        klass = module.find(name)
        assert isinstance(klass, etgtools.ClassDef)
        tools.addAutoProperties(klass)

        methods = [
            ('Clone',       "virtual wxGridCellRenderer* Clone() const /Factory/;"),
            ('Draw',        "virtual void Draw(wxGrid& grid, wxGridCellAttr& attr, wxDC& dc, "
                            "    const wxRect& rect, int row, int col, bool isSelected);"),
            ('GetBestSize', "virtual wxSize GetBestSize(wxGrid& grid, wxGridCellAttr& attr, "
                            "    wxDC& dc, int row, int col);"),
            ]
        for method, code in methods:
            if not klass.findItem(method):
                klass.addItem(etgtools.WigCode(code))
Example #23
0
def run():
    # Parse the XML file(s) building a collection of Extractor objects
    module = etgtools.ModuleDef(PACKAGE, MODULE, NAME, DOCSTRING)
    etgtools.parseDoxyXML(module, ITEMS)

    #-----------------------------------------------------------------
    # Tweak the parsed meta objects in the module object as needed for
    # customizing the generated code and docstrings.

    module.addHeaderCode('#include <wx/notebook.h>')

    c = module.find('wxNotebook')
    c.find('OnSelChange').ignore()

    tools.fixWindowClass(c)

    # Let SIP know about other virtual methods that may be implemented here
    c.addItem(
        etgtools.WigCode("""\
        virtual bool DeleteAllPages();    
        """))

    module.addGlobalStr('wxNotebookNameStr', c)

    module.addPyCode("""\
        EVT_NOTEBOOK_PAGE_CHANGED  = wx.PyEventBinder( wxEVT_NOTEBOOK_PAGE_CHANGED, 1 )
        EVT_NOTEBOOK_PAGE_CHANGING = wx.PyEventBinder( wxEVT_NOTEBOOK_PAGE_CHANGING, 1 )
        """)

    module.addPyCode("""\
        # Aliases for the "best book" control as described in the overview
        BookCtrl =                       Notebook
        wxEVT_BOOKCTRL_PAGE_CHANGED =    wxEVT_NOTEBOOK_PAGE_CHANGED
        wxEVT_BOOKCTRL_PAGE_CHANGING =   wxEVT_NOTEBOOK_PAGE_CHANGING
        EVT_BOOKCTRL_PAGE_CHANGED =      EVT_NOTEBOOK_PAGE_CHANGED
        EVT_BOOKCTRL_PAGE_CHANGING =     EVT_NOTEBOOK_PAGE_CHANGING

        # deprecated wxEVT aliases
        wxEVT_COMMAND_BOOKCTRL_PAGE_CHANGED   = wxEVT_BOOKCTRL_PAGE_CHANGED
        wxEVT_COMMAND_BOOKCTRL_PAGE_CHANGING  = wxEVT_BOOKCTRL_PAGE_CHANGING
        wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED   = wxEVT_NOTEBOOK_PAGE_CHANGED
        wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGING  = wxEVT_NOTEBOOK_PAGE_CHANGING

        """)

    #-----------------------------------------------------------------
    tools.doCommonTweaks(module)
    tools.runGenerators(module)
Example #24
0
def run():
    # Parse the XML file(s) building a collection of Extractor objects
    module = etgtools.ModuleDef(PACKAGE, MODULE, NAME, DOCSTRING)
    etgtools.parseDoxyXML(module, ITEMS)

    #-----------------------------------------------------------------
    # Tweak the parsed meta objects in the module object as needed for
    # customizing the generated code and docstrings.

    c = module.find('wxLocale')
    assert isinstance(c, etgtools.ClassDef)
    c.addPrivateAssignOp()
    c.addPrivateCopyCtor()

    c.addCppMethod('int', '__nonzero__', '()', 'return self->IsOk();')
    c.addCppMethod('int', '__bool__', '()', "return self->IsOk();")

    c = module.find('wxLanguageInfo')
    c.find('WinLang').ignore()
    c.find('WinSublang').ignore()
    c.find('GetLCID').ignore()

    module.addItem(
        etgtools.WigCode("""\
        char* wxSetlocale(int category, const char *locale);
        char* wxSetlocale(int category, const wxString& locale);
        """))

    module.addPyCode("""\
    #----------------------------------------------------------------------------
    # Add the directory where the wxWidgets catalogs were installed
    # to the default catalog path, if they were put in the package dir.
    import os
    _localedir = os.path.join(os.path.dirname(__file__), "locale")
    if os.path.exists(_localedir):
        if isinstance(_localedir, (bytes, bytearray)):
            _localedir = _localedir.decode(_sys.getfilesystemencoding())
        Locale.AddCatalogLookupPathPrefix(_localedir)
    del os
    #----------------------------------------------------------------------------
    """)

    #-----------------------------------------------------------------
    tools.doCommonTweaks(module)
    tools.runGenerators(module)
Example #25
0
def fixBookctrlClass(klass):
    """
    Add declarations of the pure virtual methods from the base class.
    """
    methods = [
        ("GetPageImage", "virtual int GetPageImage(size_t nPage) const;"),
        ("SetPageImage", "virtual bool SetPageImage(size_t page, int image);"),
        ("GetPageText", "virtual wxString GetPageText(size_t nPage) const;"),
        ("SetPageText", "virtual bool SetPageText(size_t page, const wxString& text);"),
        ("GetSelection", "virtual int GetSelection() const;"),
        ("SetSelection", "virtual int SetSelection(size_t page);"),
        ("ChangeSelection", "virtual int ChangeSelection(size_t page);"),
        ("HitTest", "virtual int HitTest(const wxPoint& pt, long* flags /Out/ = NULL) const;"),
        ("InsertPage", "virtual bool InsertPage(size_t index, wxWindow * page, const wxString & text, bool select = false, int imageId = NO_IMAGE);"),
        ]

    for name, decl in methods:
        if not klass.findItem(name):
            klass.addItem(extractors.WigCode(decl))
def run():
    # Parse the XML file(s) building a collection of Extractor objects
    module = etgtools.ModuleDef(PACKAGE, MODULE, NAME, DOCSTRING)
    etgtools.parseDoxyXML(module, ITEMS)

    #-----------------------------------------------------------------
    # Tweak the parsed meta objects in the module object as needed for
    # customizing the generated code and docstrings.

    module.addHeaderCode('#include <wx/ribbon/toolbar.h>')
    module.insertItem(
        0,
        etgtools.WigCode("""\
        // forward declarations
        class wxRibbonToolBarToolBase;
        """))

    c = module.find('wxRibbonToolBar')
    assert isinstance(c, etgtools.ClassDef)
    tools.fixWindowClass(c)

    # Use wxPyUserData for the clientData values instead of a plain wxObject
    for item in c.allItems():
        if isinstance(item, etgtools.ParamDef) and item.name == 'clientData':
            item.type = 'wxPyUserData*'
            item.transfer = True
    meth = c.find('GetToolClientData')
    meth.type = 'wxPyUserData*'
    meth.setCppCode(
        'return dynamic_cast<wxPyUserData*>(self->GetToolClientData(tool_id));'
    )

    c = module.find('wxRibbonToolBarEvent')
    tools.fixEventClass(c)

    module.addPyCode("""\
        EVT_RIBBONTOOLBAR_CLICKED = wx.PyEventBinder( wxEVT_RIBBONTOOLBAR_CLICKED, 1 )
        EVT_RIBBONTOOLBAR_DROPDOWN_CLICKED = wx.PyEventBinder( wxEVT_RIBBONTOOLBAR_DROPDOWN_CLICKED, 1 )
        """)

    #-----------------------------------------------------------------
    tools.doCommonTweaks(module)
    tools.runGenerators(module)
Example #27
0
def run():
    # Parse the XML file(s) building a collection of Extractor objects
    module = etgtools.ModuleDef(PACKAGE, MODULE, NAME, DOCSTRING)
    etgtools.parseDoxyXML(module, ITEMS)

    #-----------------------------------------------------------------
    # Tweak the parsed meta objects in the module object as needed for
    # customizing the generated code and docstrings.

    c = module.find('wxHtmlHelpController')
    assert isinstance(c, etgtools.ClassDef)
    c.mustHaveApp()
    c.addPrivateCopyCtor()

    c.find('CreateHelpDialog').ignore(False)
    c.find('CreateHelpFrame').ignore(False)

    c.addItem(
        etgtools.WigCode("""\
        public:
        // Add implementations for the pure virtuals in the base class
        virtual bool Initialize(const wxString& file, int server);
        virtual bool Initialize(const wxString& file);
        virtual void SetViewer(const wxString& viewer, long flags = 0);
        virtual bool LoadFile(const wxString& file = "");
        virtual bool DisplaySection(int sectionNo);
        virtual bool DisplaySection(const wxString& section);
        virtual bool DisplayBlock(long blockNo);
        virtual bool DisplayTextPopup(const wxString& text, const wxPoint& pos);
        virtual bool DisplayContextPopup(int contextId);
        virtual bool Quit();
        virtual void OnQuit();

        virtual void SetFrameParameters(const wxString& titleFormat,
                                        const wxSize& size,
                                        const wxPoint& pos = wxDefaultPosition,
                                        bool newFrameEachTime = false);
        """))

    #-----------------------------------------------------------------
    tools.doCommonTweaks(module)
    tools.runGenerators(module)
Example #28
0
def addSipConvertToSubClassCode(klass):
    """
    Teach SIP how to convert to specific subclass types
    """
    klass.addItem(extractors.WigCode("""\
    %ConvertToSubClassCode
        const wxClassInfo* info   = sipCpp->GetClassInfo();
        wxString           name   = info->GetClassName();
        bool               exists = sipFindType(name) != NULL;
        while (info && !exists) {
            info = info->GetBaseClass1();
            name = info->GetClassName();
            exists = sipFindType(name) != NULL;
        }
        if (info)
            sipType = sipFindType(name);
        else
            sipType = NULL;
    %End
    """))
Example #29
0
def run():
    # Parse the XML file(s) building a collection of Extractor objects
    module = etgtools.ModuleDef(PACKAGE, MODULE, NAME, DOCSTRING)
    etgtools.parseDoxyXML(module, ITEMS)

    #-----------------------------------------------------------------
    # Tweak the parsed meta objects in the module object as needed for
    # customizing the generated code and docstrings.

    c = module.find('wxHtmlDCRenderer')
    assert isinstance(c, etgtools.ClassDef)
    c.mustHaveApp()
    c.addPrivateCopyCtor()
    tools.fixHtmlSetFonts(c)

    c.find('Render.from').name = 'from_'
    c.find('Render.to').name = 'to_'

    c = module.find('wxHtmlEasyPrinting')
    c.mustHaveApp()
    c.addPrivateCopyCtor()
    tools.fixHtmlSetFonts(c)

    c = module.find('wxHtmlPrintout')
    c.mustHaveApp()
    c.addPrivateCopyCtor()
    tools.fixHtmlSetFonts(c)

    # Ensure sip knows these virtuals are present in this class.
    c.addItem(
        etgtools.WigCode("""\
        bool OnPrintPage(int page);
        bool HasPage(int page);
        void GetPageInfo(int *minPage, int *maxPage, int *selPageFrom, int *selPageTo);
        bool OnBeginDocument(int startPage, int endPage);
        void OnPreparePrinting();
        """))

    #-----------------------------------------------------------------
    tools.doCommonTweaks(module)
    tools.runGenerators(module)
Example #30
0
def run():
    # Parse the XML file(s) building a collection of Extractor objects
    module = etgtools.ModuleDef(PACKAGE, MODULE, NAME, DOCSTRING)
    etgtools.parseDoxyXML(module, ITEMS)

    #-----------------------------------------------------------------
    # Tweak the parsed meta objects in the module object as needed for
    # customizing the generated code and docstrings.

    c = module.find('wxWizardPage')
    assert isinstance(c, etgtools.ClassDef)
    tools.fixWindowClass(c, False)
    module.addPyCode(
        "PyWizardPage = wx.deprecated(WizardPage, 'Use WizardPage instead.')")

    c = module.find('wxWizardPageSimple')
    tools.fixWindowClass(c, False)
    c.addItem(
        etgtools.WigCode("""\
        virtual wxWizardPage* GetNext() const;
        virtual wxWizardPage* GetPrev() const;
        """))

    c = module.find('wxWizard')
    tools.fixWindowClass(c, False)

    c = module.find('wxWizardEvent')
    tools.fixEventClass(c)
    c.addPyCode("""\
        EVT_WIZARD_BEFORE_PAGE_CHANGED  = wx.PyEventBinder( wxEVT_WIZARD_BEFORE_PAGE_CHANGED, 1)
        EVT_WIZARD_PAGE_CHANGED  = wx.PyEventBinder( wxEVT_WIZARD_PAGE_CHANGED, 1)
        EVT_WIZARD_PAGE_CHANGING = wx.PyEventBinder( wxEVT_WIZARD_PAGE_CHANGING, 1)
        EVT_WIZARD_CANCEL        = wx.PyEventBinder( wxEVT_WIZARD_CANCEL, 1)
        EVT_WIZARD_HELP          = wx.PyEventBinder( wxEVT_WIZARD_HELP, 1)
        EVT_WIZARD_FINISHED      = wx.PyEventBinder( wxEVT_WIZARD_FINISHED, 1)
        EVT_WIZARD_PAGE_SHOWN    = wx.PyEventBinder( wxEVT_WIZARD_PAGE_SHOWN, 1)
        """)

    #-----------------------------------------------------------------
    tools.doCommonTweaks(module)
    tools.runGenerators(module)