summaryrefslogtreecommitdiffstats
path: root/Mac/Modules/ctl
diff options
context:
space:
mode:
authorJust van Rossum <just@letterror.com>2001-12-13 21:24:37 (GMT)
committerJust van Rossum <just@letterror.com>2001-12-13 21:24:37 (GMT)
commit7ec1c85d7a87e1aff699421d741be8dfca2adee9 (patch)
tree92adb66b6f484d5a3950f0e68e1e6633d1169d41 /Mac/Modules/ctl
parentf36cfef1ae513a5b123a3dc3c06e5a0271fb10ed (diff)
downloadcpython-7ec1c85d7a87e1aff699421d741be8dfca2adee9.zip
cpython-7ec1c85d7a87e1aff699421d741be8dfca2adee9.tar.gz
cpython-7ec1c85d7a87e1aff699421d741be8dfca2adee9.tar.bz2
- "manage" controls created by CreateXxxXxxControl() functions.
- FindControlUnderMouse() returns an existing control, not a new one.
Diffstat (limited to 'Mac/Modules/ctl')
-rw-r--r--Mac/Modules/ctl/_Ctlmodule.c96
-rw-r--r--Mac/Modules/ctl/ctledit.py18
-rw-r--r--Mac/Modules/ctl/ctlscan.py1
3 files changed, 67 insertions, 48 deletions
diff --git a/Mac/Modules/ctl/_Ctlmodule.c b/Mac/Modules/ctl/_Ctlmodule.c
index 3c6ba5e..70bdb3e 100644
--- a/Mac/Modules/ctl/_Ctlmodule.c
+++ b/Mac/Modules/ctl/_Ctlmodule.c
@@ -4035,29 +4035,6 @@ static PyObject *Ctl_FindControl(PyObject *_self, PyObject *_args)
return _res;
}
-static PyObject *Ctl_FindControlUnderMouse(PyObject *_self, PyObject *_args)
-{
- PyObject *_res = NULL;
- ControlHandle _rv;
- Point inWhere;
- WindowPtr inWindow;
- SInt16 outPart;
-#ifndef FindControlUnderMouse
- PyMac_PRECHECK(FindControlUnderMouse);
-#endif
- if (!PyArg_ParseTuple(_args, "O&O&",
- PyMac_GetPoint, &inWhere,
- WinObj_Convert, &inWindow))
- return NULL;
- _rv = FindControlUnderMouse(inWhere,
- inWindow,
- &outPart);
- _res = Py_BuildValue("O&h",
- CtlObj_New, _rv,
- outPart);
- return _res;
-}
-
static PyObject *Ctl_IdleControls(PyObject *_self, PyObject *_args)
{
PyObject *_res = NULL;
@@ -4137,7 +4114,7 @@ static PyObject *Ctl_CreateRootControl(PyObject *_self, PyObject *_args)
&outControl);
if (_err != noErr) return PyMac_Error(_err);
_res = Py_BuildValue("O&",
- CtlObj_WhichControl, outControl);
+ CtlObj_New, outControl);
return _res;
}
@@ -4340,7 +4317,7 @@ static PyObject *Ctl_CreateDisclosureTriangleControl(PyObject *_self, PyObject *
&outControl);
if (_err != noErr) return PyMac_Error(_err);
_res = Py_BuildValue("O&",
- CtlObj_WhichControl, outControl);
+ CtlObj_New, outControl);
return _res;
}
@@ -4375,7 +4352,7 @@ static PyObject *Ctl_CreateProgressBarControl(PyObject *_self, PyObject *_args)
&outControl);
if (_err != noErr) return PyMac_Error(_err);
_res = Py_BuildValue("O&",
- CtlObj_WhichControl, outControl);
+ CtlObj_New, outControl);
return _res;
}
@@ -4410,7 +4387,7 @@ static PyObject *Ctl_CreateLittleArrowsControl(PyObject *_self, PyObject *_args)
&outControl);
if (_err != noErr) return PyMac_Error(_err);
_res = Py_BuildValue("O&",
- CtlObj_WhichControl, outControl);
+ CtlObj_New, outControl);
return _res;
}
@@ -4433,7 +4410,7 @@ static PyObject *Ctl_CreateChasingArrowsControl(PyObject *_self, PyObject *_args
&outControl);
if (_err != noErr) return PyMac_Error(_err);
_res = Py_BuildValue("O&",
- CtlObj_WhichControl, outControl);
+ CtlObj_New, outControl);
return _res;
}
@@ -4456,7 +4433,7 @@ static PyObject *Ctl_CreateSeparatorControl(PyObject *_self, PyObject *_args)
&outControl);
if (_err != noErr) return PyMac_Error(_err);
_res = Py_BuildValue("O&",
- CtlObj_WhichControl, outControl);
+ CtlObj_New, outControl);
return _res;
}
@@ -4485,7 +4462,7 @@ static PyObject *Ctl_CreateGroupBoxControl(PyObject *_self, PyObject *_args)
&outControl);
if (_err != noErr) return PyMac_Error(_err);
_res = Py_BuildValue("O&",
- CtlObj_WhichControl, outControl);
+ CtlObj_New, outControl);
return _res;
}
@@ -4520,7 +4497,7 @@ static PyObject *Ctl_CreateCheckGroupBoxControl(PyObject *_self, PyObject *_args
&outControl);
if (_err != noErr) return PyMac_Error(_err);
_res = Py_BuildValue("O&",
- CtlObj_WhichControl, outControl);
+ CtlObj_New, outControl);
return _res;
}
@@ -4564,7 +4541,7 @@ static PyObject *Ctl_CreatePopupGroupBoxControl(PyObject *_self, PyObject *_args
&outControl);
if (_err != noErr) return PyMac_Error(_err);
_res = Py_BuildValue("O&",
- CtlObj_WhichControl, outControl);
+ CtlObj_New, outControl);
return _res;
}
@@ -4593,7 +4570,7 @@ static PyObject *Ctl_CreatePopupArrowControl(PyObject *_self, PyObject *_args)
&outControl);
if (_err != noErr) return PyMac_Error(_err);
_res = Py_BuildValue("O&",
- CtlObj_WhichControl, outControl);
+ CtlObj_New, outControl);
return _res;
}
@@ -4616,7 +4593,7 @@ static PyObject *Ctl_CreatePlacardControl(PyObject *_self, PyObject *_args)
&outControl);
if (_err != noErr) return PyMac_Error(_err);
_res = Py_BuildValue("O&",
- CtlObj_WhichControl, outControl);
+ CtlObj_New, outControl);
return _res;
}
@@ -4645,7 +4622,7 @@ static PyObject *Ctl_CreateClockControl(PyObject *_self, PyObject *_args)
&outControl);
if (_err != noErr) return PyMac_Error(_err);
_res = Py_BuildValue("O&",
- CtlObj_WhichControl, outControl);
+ CtlObj_New, outControl);
return _res;
}
@@ -4671,7 +4648,7 @@ static PyObject *Ctl_CreateUserPaneControl(PyObject *_self, PyObject *_args)
&outControl);
if (_err != noErr) return PyMac_Error(_err);
_res = Py_BuildValue("O&",
- CtlObj_WhichControl, outControl);
+ CtlObj_New, outControl);
return _res;
}
@@ -4706,7 +4683,7 @@ static PyObject *Ctl_CreateEditTextControl(PyObject *_self, PyObject *_args)
&outControl);
if (_err != noErr) return PyMac_Error(_err);
_res = Py_BuildValue("O&",
- CtlObj_WhichControl, outControl);
+ CtlObj_New, outControl);
return _res;
}
@@ -4735,7 +4712,7 @@ static PyObject *Ctl_CreateStaticTextControl(PyObject *_self, PyObject *_args)
&outControl);
if (_err != noErr) return PyMac_Error(_err);
_res = Py_BuildValue("O&",
- CtlObj_WhichControl, outControl);
+ CtlObj_New, outControl);
return _res;
}
@@ -4761,7 +4738,7 @@ static PyObject *Ctl_CreateWindowHeaderControl(PyObject *_self, PyObject *_args)
&outControl);
if (_err != noErr) return PyMac_Error(_err);
_res = Py_BuildValue("O&",
- CtlObj_WhichControl, outControl);
+ CtlObj_New, outControl);
return _res;
}
@@ -4787,7 +4764,7 @@ static PyObject *Ctl_CreatePushButtonControl(PyObject *_self, PyObject *_args)
&outControl);
if (_err != noErr) return PyMac_Error(_err);
_res = Py_BuildValue("O&",
- CtlObj_WhichControl, outControl);
+ CtlObj_New, outControl);
return _res;
}
@@ -4819,7 +4796,7 @@ static PyObject *Ctl_CreateRadioButtonControl(PyObject *_self, PyObject *_args)
&outControl);
if (_err != noErr) return PyMac_Error(_err);
_res = Py_BuildValue("O&",
- CtlObj_WhichControl, outControl);
+ CtlObj_New, outControl);
return _res;
}
@@ -4851,7 +4828,7 @@ static PyObject *Ctl_CreateCheckBoxControl(PyObject *_self, PyObject *_args)
&outControl);
if (_err != noErr) return PyMac_Error(_err);
_res = Py_BuildValue("O&",
- CtlObj_WhichControl, outControl);
+ CtlObj_New, outControl);
return _res;
}
@@ -4892,7 +4869,7 @@ static PyObject *Ctl_CreatePopupButtonControl(PyObject *_self, PyObject *_args)
&outControl);
if (_err != noErr) return PyMac_Error(_err);
_res = Py_BuildValue("O&",
- CtlObj_WhichControl, outControl);
+ CtlObj_New, outControl);
return _res;
}
@@ -4915,7 +4892,7 @@ static PyObject *Ctl_CreateRadioGroupControl(PyObject *_self, PyObject *_args)
&outControl);
if (_err != noErr) return PyMac_Error(_err);
_res = Py_BuildValue("O&",
- CtlObj_WhichControl, outControl);
+ CtlObj_New, outControl);
return _res;
}
@@ -4953,7 +4930,7 @@ static PyObject *Ctl_CreateScrollingTextBoxControl(PyObject *_self, PyObject *_a
&outControl);
if (_err != noErr) return PyMac_Error(_err);
_res = Py_BuildValue("O&",
- CtlObj_WhichControl, outControl);
+ CtlObj_New, outControl);
return _res;
}
@@ -4979,7 +4956,30 @@ static PyObject *Ctl_CreateDataBrowserControl(PyObject *_self, PyObject *_args)
&outControl);
if (_err != noErr) return PyMac_Error(_err);
_res = Py_BuildValue("O&",
- CtlObj_WhichControl, outControl);
+ CtlObj_New, outControl);
+ return _res;
+}
+
+static PyObject *Ctl_FindControlUnderMouse(PyObject *_self, PyObject *_args)
+{
+ PyObject *_res = NULL;
+ ControlHandle _rv;
+ Point inWhere;
+ WindowPtr inWindow;
+ SInt16 outPart;
+#ifndef FindControlUnderMouse
+ PyMac_PRECHECK(FindControlUnderMouse);
+#endif
+ if (!PyArg_ParseTuple(_args, "O&O&",
+ PyMac_GetPoint, &inWhere,
+ WinObj_Convert, &inWindow))
+ return NULL;
+ _rv = FindControlUnderMouse(inWhere,
+ inWindow,
+ &outPart);
+ _res = Py_BuildValue("O&h",
+ CtlObj_WhichControl, _rv,
+ outPart);
return _res;
}
@@ -5011,8 +5011,6 @@ static PyMethodDef Ctl_methods[] = {
"(WindowPtr theWindow, RgnHandle updateRegion) -> None"},
{"FindControl", (PyCFunction)Ctl_FindControl, 1,
"(Point testPoint, WindowPtr theWindow) -> (ControlPartCode _rv, ControlHandle theControl)"},
- {"FindControlUnderMouse", (PyCFunction)Ctl_FindControlUnderMouse, 1,
- "(Point inWhere, WindowPtr inWindow) -> (ControlHandle _rv, SInt16 outPart)"},
{"IdleControls", (PyCFunction)Ctl_IdleControls, 1,
"(WindowPtr inWindow) -> None"},
@@ -5090,6 +5088,8 @@ static PyMethodDef Ctl_methods[] = {
"(WindowPtr window, Rect boundsRect, SInt16 contentResID, Boolean autoScroll, UInt32 delayBeforeAutoScroll, UInt32 delayBetweenAutoScroll, UInt16 autoScrollAmount) -> (ControlHandle outControl)"},
{"CreateDataBrowserControl", (PyCFunction)Ctl_CreateDataBrowserControl, 1,
"(WindowPtr window, Rect boundsRect, OSType style) -> (ControlHandle outControl)"},
+ {"FindControlUnderMouse", (PyCFunction)Ctl_FindControlUnderMouse, 1,
+ "(Point inWhere, WindowPtr inWindow) -> (ControlHandle _rv, SInt16 outPart)"},
{"as_Control", (PyCFunction)Ctl_as_Control, 1,
"(Handle h) -> (ControlHandle _rv)"},
{NULL, NULL, 0}
diff --git a/Mac/Modules/ctl/ctledit.py b/Mac/Modules/ctl/ctledit.py
index 992612c..6ba024b 100644
--- a/Mac/Modules/ctl/ctledit.py
+++ b/Mac/Modules/ctl/ctledit.py
@@ -1,3 +1,12 @@
+# FindControlUnderMouse() returns an existing control, not a new one,
+# so create this one by hand.
+f = Function(ExistingControlHandle, 'FindControlUnderMouse',
+ (Point, 'inWhere', InMode),
+ (WindowRef, 'inWindow', InMode),
+ (SInt16, 'outPart', OutMode),
+)
+functions.append(f)
+
f = Function(ControlHandle, 'as_Control',
(Handle, 'h', InMode))
functions.append(f)
@@ -25,3 +34,12 @@ f = ManualGenerator("DisposeControl", DisposeControl_body)
f.docstring = lambda : "() -> None"
methods.append(f)
+
+# All CreateXxxXxxControl() functions return a new object in an output
+# parameter; these should however be managed by us (we're creating them
+# after all), so set the type to ControlRef.
+for f in functions:
+ if f.name.startswith("Create"):
+ v = f.argumentList[-1]
+ if v.type == ExistingControlHandle:
+ v.type = ControlRef
diff --git a/Mac/Modules/ctl/ctlscan.py b/Mac/Modules/ctl/ctlscan.py
index de7353c..d78cb5f 100644
--- a/Mac/Modules/ctl/ctlscan.py
+++ b/Mac/Modules/ctl/ctlscan.py
@@ -45,6 +45,7 @@ class MyScanner(Scanner):
def makeblacklistnames(self):
return [
+ 'FindControlUnderMouse', # Generated manually, returns an existing control, not a new one.
'DisposeControl', # Generated manually
'KillControls', # Implied by close of dialog
'SetCtlAction',