]> granicus.if.org Git - python/commitdiff
Added a GetControlRect() method to controls which returns the bounding rectangle...
authorJack Jansen <jack.jansen@cwi.nl>
Tue, 21 Mar 2000 16:25:23 +0000 (16:25 +0000)
committerJack Jansen <jack.jansen@cwi.nl>
Tue, 21 Mar 2000 16:25:23 +0000 (16:25 +0000)
Mac/Modules/ctl/Ctlmodule.c
Mac/Modules/ctl/ctledit.py
Mac/Modules/ctl/ctlsupport.py

index 530904c92510a248ab7f6fada39e6622c190057c..32788bcdb7719298f1d597624587f8e37f035d7c 100644 (file)
@@ -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;
 }
 
index ea433e5802d28b0d12cd00f7dbbce8bd3d9122c2..992612c2a1aa5f4ad6bbaa6530f0ced561c98c5e 100644 (file)
@@ -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;
index ea9dcef20bf67b114e97dfa32a986ac4e9569abd..ac753327479c8953a616b8d30d0714326158382d 100644 (file)
@@ -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;
 }