- added support for UserPaneKeyDownProc and UserPaneFocusProc

- clear error after failing PyArg_Parse()
This commit is contained in:
Just van Rossum 2002-01-04 19:45:15 +00:00
parent a22a7b7a06
commit c4cf27e8e0
2 changed files with 96 additions and 4 deletions

View File

@ -132,6 +132,8 @@ DataBrowserListViewColumnDesc_Convert(PyObject *v, DataBrowserListViewColumnDesc
static PyObject *tracker; static PyObject *tracker;
static ControlActionUPP mytracker_upp; static ControlActionUPP mytracker_upp;
static ControlActionUPP myactionproc_upp; static ControlActionUPP myactionproc_upp;
static ControlUserPaneKeyDownUPP mykeydownproc_upp;
static ControlUserPaneFocusUPP myfocusproc_upp;
static ControlUserPaneDrawUPP mydrawproc_upp; static ControlUserPaneDrawUPP mydrawproc_upp;
static ControlUserPaneIdleUPP myidleproc_upp; static ControlUserPaneIdleUPP myidleproc_upp;
static ControlUserPaneHitTestUPP myhittestproc_upp; static ControlUserPaneHitTestUPP myhittestproc_upp;
@ -6513,6 +6515,10 @@ setcallback(PyObject *myself, OSType which, PyObject *callback, UniversalProcPtr
if ( which == kMyControlActionProcTag ) if ( which == kMyControlActionProcTag )
*uppp = (UniversalProcPtr)myactionproc_upp; *uppp = (UniversalProcPtr)myactionproc_upp;
else if ( which == kControlUserPaneKeyDownProcTag )
*uppp = (UniversalProcPtr)mykeydownproc_upp;
else if ( which == kControlUserPaneFocusProcTag )
*uppp = (UniversalProcPtr)myfocusproc_upp;
else if ( which == kControlUserPaneDrawProcTag ) else if ( which == kControlUserPaneDrawProcTag )
*uppp = (UniversalProcPtr)mydrawproc_upp; *uppp = (UniversalProcPtr)mydrawproc_upp;
else if ( which == kControlUserPaneIdleProcTag ) else if ( which == kControlUserPaneIdleProcTag )
@ -6570,6 +6576,42 @@ myactionproc(ControlHandle control, SInt16 part)
Py_XDECREF(rv); Py_XDECREF(rv);
} }
static pascal ControlPartCode
mykeydownproc(ControlHandle control, SInt16 keyCode, SInt16 charCode, SInt16 modifiers)
{
ControlObject *ctl_obj;
PyObject *arglist, *rv;
short c_rv = 0;
ctl_obj = (ControlObject *)CtlObj_WhichControl(control);
arglist = Py_BuildValue("Ohhh", ctl_obj, keyCode, charCode, modifiers);
rv = callcallback(ctl_obj, kControlUserPaneKeyDownProcTag, arglist);
Py_XDECREF(arglist);
if ( rv )
if (!PyArg_Parse(rv, "h", &c_rv))
PyErr_Clear();
Py_XDECREF(rv);
return (ControlPartCode)c_rv;
}
static pascal ControlPartCode
myfocusproc(ControlHandle control, ControlPartCode part)
{
ControlObject *ctl_obj;
PyObject *arglist, *rv;
short c_rv = kControlFocusNoPart;
ctl_obj = (ControlObject *)CtlObj_WhichControl(control);
arglist = Py_BuildValue("Oh", ctl_obj, part);
rv = callcallback(ctl_obj, kControlUserPaneFocusProcTag, arglist);
Py_XDECREF(arglist);
if ( rv )
if (!PyArg_Parse(rv, "h", &c_rv))
PyErr_Clear();
Py_XDECREF(rv);
return (ControlPartCode)c_rv;
}
static pascal void static pascal void
mydrawproc(ControlHandle control, SInt16 part) mydrawproc(ControlHandle control, SInt16 part)
{ {
@ -6609,7 +6651,8 @@ myhittestproc(ControlHandle control, Point where)
Py_XDECREF(arglist); Py_XDECREF(arglist);
/* Ignore errors, nothing we can do about them */ /* Ignore errors, nothing we can do about them */
if ( rv ) if ( rv )
PyArg_Parse(rv, "h", &c_rv); if (!PyArg_Parse(rv, "h", &c_rv))
PyErr_Clear();
Py_XDECREF(rv); Py_XDECREF(rv);
return (ControlPartCode)c_rv; return (ControlPartCode)c_rv;
} }
@ -6627,7 +6670,8 @@ mytrackingproc(ControlHandle control, Point startPt, ControlActionUPP actionProc
rv = callcallback(ctl_obj, kControlUserPaneTrackingProcTag, arglist); rv = callcallback(ctl_obj, kControlUserPaneTrackingProcTag, arglist);
Py_XDECREF(arglist); Py_XDECREF(arglist);
if ( rv ) if ( rv )
PyArg_Parse(rv, "h", &c_rv); if (!PyArg_Parse(rv, "h", &c_rv))
PyErr_Clear();
Py_XDECREF(rv); Py_XDECREF(rv);
return (ControlPartCode)c_rv; return (ControlPartCode)c_rv;
} }
@ -6642,6 +6686,8 @@ void init_Ctl(void)
mytracker_upp = NewControlActionUPP(mytracker); mytracker_upp = NewControlActionUPP(mytracker);
myactionproc_upp = NewControlActionUPP(myactionproc); myactionproc_upp = NewControlActionUPP(myactionproc);
mykeydownproc_upp = NewControlUserPaneKeyDownUPP(mykeydownproc);
myfocusproc_upp = NewControlUserPaneFocusUPP(myfocusproc);
mydrawproc_upp = NewControlUserPaneDrawUPP(mydrawproc); mydrawproc_upp = NewControlUserPaneDrawUPP(mydrawproc);
myidleproc_upp = NewControlUserPaneIdleUPP(myidleproc); myidleproc_upp = NewControlUserPaneIdleUPP(myidleproc);
myhittestproc_upp = NewControlUserPaneHitTestUPP(myhittestproc); myhittestproc_upp = NewControlUserPaneHitTestUPP(myhittestproc);

View File

@ -225,6 +225,8 @@ DataBrowserListViewColumnDesc_Convert(PyObject *v, DataBrowserListViewColumnDesc
static PyObject *tracker; static PyObject *tracker;
static ControlActionUPP mytracker_upp; static ControlActionUPP mytracker_upp;
static ControlActionUPP myactionproc_upp; static ControlActionUPP myactionproc_upp;
static ControlUserPaneKeyDownUPP mykeydownproc_upp;
static ControlUserPaneFocusUPP myfocusproc_upp;
static ControlUserPaneDrawUPP mydrawproc_upp; static ControlUserPaneDrawUPP mydrawproc_upp;
static ControlUserPaneIdleUPP myidleproc_upp; static ControlUserPaneIdleUPP myidleproc_upp;
static ControlUserPaneHitTestUPP myhittestproc_upp; static ControlUserPaneHitTestUPP myhittestproc_upp;
@ -313,6 +315,10 @@ setcallback(PyObject *myself, OSType which, PyObject *callback, UniversalProcPtr
if ( which == kMyControlActionProcTag ) if ( which == kMyControlActionProcTag )
*uppp = (UniversalProcPtr)myactionproc_upp; *uppp = (UniversalProcPtr)myactionproc_upp;
else if ( which == kControlUserPaneKeyDownProcTag )
*uppp = (UniversalProcPtr)mykeydownproc_upp;
else if ( which == kControlUserPaneFocusProcTag )
*uppp = (UniversalProcPtr)myfocusproc_upp;
else if ( which == kControlUserPaneDrawProcTag ) else if ( which == kControlUserPaneDrawProcTag )
*uppp = (UniversalProcPtr)mydrawproc_upp; *uppp = (UniversalProcPtr)mydrawproc_upp;
else if ( which == kControlUserPaneIdleProcTag ) else if ( which == kControlUserPaneIdleProcTag )
@ -370,6 +376,42 @@ myactionproc(ControlHandle control, SInt16 part)
Py_XDECREF(rv); Py_XDECREF(rv);
} }
static pascal ControlPartCode
mykeydownproc(ControlHandle control, SInt16 keyCode, SInt16 charCode, SInt16 modifiers)
{
ControlObject *ctl_obj;
PyObject *arglist, *rv;
short c_rv = 0;
ctl_obj = (ControlObject *)CtlObj_WhichControl(control);
arglist = Py_BuildValue("Ohhh", ctl_obj, keyCode, charCode, modifiers);
rv = callcallback(ctl_obj, kControlUserPaneKeyDownProcTag, arglist);
Py_XDECREF(arglist);
if ( rv )
if (!PyArg_Parse(rv, "h", &c_rv))
PyErr_Clear();
Py_XDECREF(rv);
return (ControlPartCode)c_rv;
}
static pascal ControlPartCode
myfocusproc(ControlHandle control, ControlPartCode part)
{
ControlObject *ctl_obj;
PyObject *arglist, *rv;
short c_rv = kControlFocusNoPart;
ctl_obj = (ControlObject *)CtlObj_WhichControl(control);
arglist = Py_BuildValue("Oh", ctl_obj, part);
rv = callcallback(ctl_obj, kControlUserPaneFocusProcTag, arglist);
Py_XDECREF(arglist);
if ( rv )
if (!PyArg_Parse(rv, "h", &c_rv))
PyErr_Clear();
Py_XDECREF(rv);
return (ControlPartCode)c_rv;
}
static pascal void static pascal void
mydrawproc(ControlHandle control, SInt16 part) mydrawproc(ControlHandle control, SInt16 part)
{ {
@ -409,7 +451,8 @@ myhittestproc(ControlHandle control, Point where)
Py_XDECREF(arglist); Py_XDECREF(arglist);
/* Ignore errors, nothing we can do about them */ /* Ignore errors, nothing we can do about them */
if ( rv ) if ( rv )
PyArg_Parse(rv, "h", &c_rv); if (!PyArg_Parse(rv, "h", &c_rv))
PyErr_Clear();
Py_XDECREF(rv); Py_XDECREF(rv);
return (ControlPartCode)c_rv; return (ControlPartCode)c_rv;
} }
@ -427,7 +470,8 @@ mytrackingproc(ControlHandle control, Point startPt, ControlActionUPP actionProc
rv = callcallback(ctl_obj, kControlUserPaneTrackingProcTag, arglist); rv = callcallback(ctl_obj, kControlUserPaneTrackingProcTag, arglist);
Py_XDECREF(arglist); Py_XDECREF(arglist);
if ( rv ) if ( rv )
PyArg_Parse(rv, "h", &c_rv); if (!PyArg_Parse(rv, "h", &c_rv))
PyErr_Clear();
Py_XDECREF(rv); Py_XDECREF(rv);
return (ControlPartCode)c_rv; return (ControlPartCode)c_rv;
} }
@ -436,6 +480,8 @@ mytrackingproc(ControlHandle control, Point startPt, ControlActionUPP actionProc
initstuff = initstuff + """ initstuff = initstuff + """
mytracker_upp = NewControlActionUPP(mytracker); mytracker_upp = NewControlActionUPP(mytracker);
myactionproc_upp = NewControlActionUPP(myactionproc); myactionproc_upp = NewControlActionUPP(myactionproc);
mykeydownproc_upp = NewControlUserPaneKeyDownUPP(mykeydownproc);
myfocusproc_upp = NewControlUserPaneFocusUPP(myfocusproc);
mydrawproc_upp = NewControlUserPaneDrawUPP(mydrawproc); mydrawproc_upp = NewControlUserPaneDrawUPP(mydrawproc);
myidleproc_upp = NewControlUserPaneIdleUPP(myidleproc); myidleproc_upp = NewControlUserPaneIdleUPP(myidleproc);
myhittestproc_upp = NewControlUserPaneHitTestUPP(myhittestproc); myhittestproc_upp = NewControlUserPaneHitTestUPP(myhittestproc);