File: headerctrl.py

package info (click to toggle)
wxpython4.0 4.2.3%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 221,752 kB
  • sloc: cpp: 962,555; python: 230,573; ansic: 170,731; makefile: 51,756; sh: 9,342; perl: 1,564; javascript: 584; php: 326; xml: 200
file content (121 lines) | stat: -rw-r--r-- 5,543 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
#---------------------------------------------------------------------------
# Name:        etg/headerctrl.py
# Author:      Robin Dunn
#
# Created:     29-Jun-2012
# Copyright:   (c) 2012-2020 by Total Control Software
# License:     wxWindows License
#---------------------------------------------------------------------------

import etgtools
import etgtools.tweaker_tools as tools

PACKAGE   = "wx"
MODULE    = "_core"
NAME      = "headerctrl"   # Base name of the file to generate to for this script
DOCSTRING = ""

# The classes and/or the basename of the Doxygen XML files to be processed by
# this script.
ITEMS  = [ "wxHeaderCtrl",
           "wxHeaderCtrlSimple",
           "wxHeaderCtrlEvent",
           ]

#---------------------------------------------------------------------------

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('wxHeaderCtrl')
    assert isinstance(c, etgtools.ClassDef)
    tools.fixWindowClass(c)

    module.addGlobalStr('wxHeaderCtrlNameStr', c)
    module.addHeaderCode('#include <wx/headerctrl.h>')

    # Uningnore the protected virtuals that are intended to be overridden in
    # derived classes.
    for name in ['GetColumn', 'UpdateColumnVisibility', 'UpdateColumnsOrder',
                 'UpdateColumnWidthToFit', 'OnColumnCountChanging']:
        c.find(name).ignore(False)
        c.find(name).isVirtual = True
    c.find('GetColumn').isPureVirtual = True
    c.find('GetColumn')._virtualCatcherCode = """\
        PyObject *resObj = sipCallMethod(0,sipMethod,"u",idx);
        sipIsErr = (!resObj || sipParseResult(0,sipMethod,resObj,"H1",sipType_wxHeaderColumn,&sipRes) < 0);
        if (sipIsErr)
            PyErr_Print();
        Py_XDECREF(resObj);
        if (sipIsErr)
            return *(new wxHeaderColumnSimple(""));
        """

    #-------------------------------------------------------
    c = module.find('wxHeaderCtrlSimple')
    tools.fixWindowClass(c)

    # Uningnore the protected virtuals that are intended to be overridden in
    # derived classes.
    c.find('GetBestFittingWidth').ignore(False)
    c.find('GetBestFittingWidth').isVirtual = True

    # indicate the the base class virtuals have implementations here
    c.addItem(etgtools.WigCode("""\
        virtual const wxHeaderColumn& GetColumn(unsigned int idx) const;
        virtual void UpdateColumnVisibility(unsigned int idx, bool show);
        virtual void UpdateColumnsOrder(const wxArrayInt& order);
        virtual bool UpdateColumnWidthToFit(unsigned int idx, int widthTitle);
        virtual void OnColumnCountChanging(unsigned int count);
        """, protection='protected'))


    #-------------------------------------------------------
    c = module.find('wxHeaderCtrlEvent')
    tools.fixEventClass(c)

    module.addPyCode("""\
        EVT_HEADER_CLICK =              wx.PyEventBinder( wxEVT_HEADER_CLICK )
        EVT_HEADER_RIGHT_CLICK =        wx.PyEventBinder( wxEVT_HEADER_RIGHT_CLICK )
        EVT_HEADER_MIDDLE_CLICK =       wx.PyEventBinder( wxEVT_HEADER_MIDDLE_CLICK )
        EVT_HEADER_DCLICK =             wx.PyEventBinder( wxEVT_HEADER_DCLICK )
        EVT_HEADER_RIGHT_DCLICK =       wx.PyEventBinder( wxEVT_HEADER_RIGHT_DCLICK )
        EVT_HEADER_MIDDLE_DCLICK =      wx.PyEventBinder( wxEVT_HEADER_MIDDLE_DCLICK )
        EVT_HEADER_SEPARATOR_DCLICK =   wx.PyEventBinder( wxEVT_HEADER_SEPARATOR_DCLICK )
        EVT_HEADER_BEGIN_RESIZE =       wx.PyEventBinder( wxEVT_HEADER_BEGIN_RESIZE )
        EVT_HEADER_RESIZING =           wx.PyEventBinder( wxEVT_HEADER_RESIZING )
        EVT_HEADER_END_RESIZE =         wx.PyEventBinder( wxEVT_HEADER_END_RESIZE )
        EVT_HEADER_BEGIN_REORDER =      wx.PyEventBinder( wxEVT_HEADER_BEGIN_REORDER )
        EVT_HEADER_END_REORDER =        wx.PyEventBinder( wxEVT_HEADER_END_REORDER )
        EVT_HEADER_DRAGGING_CANCELLED = wx.PyEventBinder( wxEVT_HEADER_DRAGGING_CANCELLED )

        # deprecated wxEVT aliases
        wxEVT_COMMAND_HEADER_CLICK               = wxEVT_HEADER_CLICK
        wxEVT_COMMAND_HEADER_RIGHT_CLICK         = wxEVT_HEADER_RIGHT_CLICK
        wxEVT_COMMAND_HEADER_MIDDLE_CLICK        = wxEVT_HEADER_MIDDLE_CLICK
        wxEVT_COMMAND_HEADER_DCLICK              = wxEVT_HEADER_DCLICK
        wxEVT_COMMAND_HEADER_RIGHT_DCLICK        = wxEVT_HEADER_RIGHT_DCLICK
        wxEVT_COMMAND_HEADER_MIDDLE_DCLICK       = wxEVT_HEADER_MIDDLE_DCLICK
        wxEVT_COMMAND_HEADER_SEPARATOR_DCLICK    = wxEVT_HEADER_SEPARATOR_DCLICK
        wxEVT_COMMAND_HEADER_BEGIN_RESIZE        = wxEVT_HEADER_BEGIN_RESIZE
        wxEVT_COMMAND_HEADER_RESIZING            = wxEVT_HEADER_RESIZING
        wxEVT_COMMAND_HEADER_END_RESIZE          = wxEVT_HEADER_END_RESIZE
        wxEVT_COMMAND_HEADER_BEGIN_REORDER       = wxEVT_HEADER_BEGIN_REORDER
        wxEVT_COMMAND_HEADER_END_REORDER         = wxEVT_HEADER_END_REORDER
        wxEVT_COMMAND_HEADER_DRAGGING_CANCELLED  = wxEVT_HEADER_DRAGGING_CANCELLED
        """)

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


#---------------------------------------------------------------------------
if __name__ == '__main__':
    run()