summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJack Jansen <jack.jansen@cwi.nl>2000-03-21 16:25:23 (GMT)
committerJack Jansen <jack.jansen@cwi.nl>2000-03-21 16:25:23 (GMT)
commit1a7d5b12c0dff4b4ec139612713ce713bd696157 (patch)
treeb1c2f658a63397986eff8540617e927bdd16d034
parent0e12bcd24333f8575a40b4fd525a5c029c9d217c (diff)
downloadcpython-1a7d5b12c0dff4b4ec139612713ce713bd696157.zip
cpython-1a7d5b12c0dff4b4ec139612713ce713bd696157.tar.gz
cpython-1a7d5b12c0dff4b4ec139612713ce713bd696157.tar.bz2
Added a GetControlRect() method to controls which returns the bounding rectangle. To my surprise this call is missing from the C API...
-rw-r--r--Mac/Modules/ctl/Ctlmodule.c19
-rw-r--r--Mac/Modules/ctl/ctledit.py3
-rw-r--r--Mac/Modules/ctl/ctlsupport.py2
3 files changed, 24 insertions, 0 deletions
diff --git a/Mac/Modules/ctl/Ctlmodule.c b/Mac/Modules/ctl/Ctlmodule.c
index 530904c..32788bc 100644
--- a/Mac/Modules/ctl/Ctlmodule.c
+++ b/Mac/Modules/ctl/Ctlmodule.c
@@ -46,6 +46,7 @@ extern PyObject *WinObj_WhichWindow(WindowPtr);
#define as_Control(h) ((ControlHandle)h)
#define as_Resource(ctl) ((Handle)ctl)
+#define GetControlRect(ctl, rectp) (*(rectp) = ((*(ctl))->contrlRect))
#define resNotFound -192 /* Can't include <Errors.h> because of Python's "errors.h" */
@@ -1021,6 +1022,21 @@ static PyObject *CtlObj_as_Resource(_self, _args)
return _res;
}
+static PyObject *CtlObj_GetControlRect(_self, _args)
+ ControlObject *_self;
+ PyObject *_args;
+{
+ PyObject *_res = NULL;
+ Rect rect;
+ if (!PyArg_ParseTuple(_args, ""))
+ return NULL;
+ GetControlRect(_self->ob_itself,
+ &rect);
+ _res = Py_BuildValue("O&",
+ PyMac_BuildRect, &rect);
+ return _res;
+}
+
static PyObject *CtlObj_DisposeControl(_self, _args)
ControlObject *_self;
PyObject *_args;
@@ -1442,6 +1458,8 @@ static PyMethodDef CtlObj_methods[] = {
"(ControlPartCode inPart, ResType inTagName) -> (Size outMaxSize)"},
{"as_Resource", (PyCFunction)CtlObj_as_Resource, 1,
"() -> (Handle _rv)"},
+ {"GetControlRect", (PyCFunction)CtlObj_GetControlRect, 1,
+ "() -> (Rect rect)"},
{"DisposeControl", (PyCFunction)CtlObj_DisposeControl, 1,
"() -> None"},
{"TrackControl", (PyCFunction)CtlObj_TrackControl, 1,
@@ -1890,6 +1908,7 @@ PyObject *CtlObj_NewUnmanaged(itself)
it = PyObject_NEW(ControlObject, &Control_Type);
if (it == NULL) return NULL;
it->ob_itself = itself;
+ it->ob_callbackdict = NULL;
return (PyObject *)it;
}
diff --git a/Mac/Modules/ctl/ctledit.py b/Mac/Modules/ctl/ctledit.py
index ea433e5..992612c 100644
--- a/Mac/Modules/ctl/ctledit.py
+++ b/Mac/Modules/ctl/ctledit.py
@@ -5,6 +5,9 @@ functions.append(f)
f = Method(Handle, 'as_Resource', (ControlHandle, 'ctl', InMode))
methods.append(f)
+f = Method(void, 'GetControlRect', (ControlHandle, 'ctl', InMode), (Rect, 'rect', OutMode))
+methods.append(f)
+
DisposeControl_body = """
if (!PyArg_ParseTuple(_args, ""))
return NULL;
diff --git a/Mac/Modules/ctl/ctlsupport.py b/Mac/Modules/ctl/ctlsupport.py
index ea9dcef..ac75332 100644
--- a/Mac/Modules/ctl/ctlsupport.py
+++ b/Mac/Modules/ctl/ctlsupport.py
@@ -46,6 +46,7 @@ includestuff = includestuff + """
#define as_Control(h) ((ControlHandle)h)
#define as_Resource(ctl) ((Handle)ctl)
+#define GetControlRect(ctl, rectp) (*(rectp) = ((*(ctl))->contrlRect))
#define resNotFound -192 /* Can't include <Errors.h> because of Python's "errors.h" */
@@ -100,6 +101,7 @@ PyObject *CtlObj_NewUnmanaged(itself)
it = PyObject_NEW(ControlObject, &Control_Type);
if (it == NULL) return NULL;
it->ob_itself = itself;
+ it->ob_callbackdict = NULL;
return (PyObject *)it;
}