Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit b539406

Browse files
committed
Added support for cursors, and a way to get at the qd global 'arrow'
1 parent 7d1eba9 commit b539406

4 files changed

Lines changed: 57 additions & 2 deletions

File tree

Mac/Modules/qd/Qdmodule.c

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,9 @@ extern int GrafObj_Convert(PyObject *, GrafPtr *);
4040
extern PyObject *BMObj_New(BitMapPtr);
4141
extern int BMObj_Convert(PyObject *, BitMapPtr *);
4242

43+
extern PyObject *PMObj_New(PixMapHandle);
44+
extern int PMObj_Convert(PyObject *, PixMapHandle *);
45+
4346
extern PyObject *WinObj_WhichWindow(WindowPtr);
4447

4548
#include <QuickDraw.h>
@@ -425,6 +428,28 @@ static PyObject *Qd_InitCursor(_self, _args)
425428
return _res;
426429
}
427430

431+
static PyObject *Qd_SetCursor(_self, _args)
432+
PyObject *_self;
433+
PyObject *_args;
434+
{
435+
PyObject *_res = NULL;
436+
Cursor *crsr__in__;
437+
int crsr__in_len__;
438+
if (!PyArg_ParseTuple(_args, "s#",
439+
(char **)&crsr__in__, &crsr__in_len__))
440+
return NULL;
441+
if (crsr__in_len__ != sizeof(Cursor))
442+
{
443+
PyErr_SetString(PyExc_TypeError, "buffer length should be sizeof(Cursor)");
444+
goto crsr__error__;
445+
}
446+
SetCursor(crsr__in__);
447+
Py_INCREF(Py_None);
448+
_res = Py_None;
449+
crsr__error__: ;
450+
return _res;
451+
}
452+
428453
static PyObject *Qd_HideCursor(_self, _args)
429454
PyObject *_self;
430455
PyObject *_args;
@@ -3131,6 +3156,8 @@ static PyMethodDef Qd_methods[] = {
31313156
"(Rect r) -> None"},
31323157
{"InitCursor", (PyCFunction)Qd_InitCursor, 1,
31333158
"() -> None"},
3159+
{"SetCursor", (PyCFunction)Qd_SetCursor, 1,
3160+
"(Cursor crsr) -> None"},
31343161
{"HideCursor", (PyCFunction)Qd_HideCursor, 1,
31353162
"() -> None"},
31363163
{"ShowCursor", (PyCFunction)Qd_ShowCursor, 1,
@@ -3453,6 +3480,16 @@ void initQd()
34533480
if (Qd_Error == NULL ||
34543481
PyDict_SetItemString(d, "Error", Qd_Error) != 0)
34553482
Py_FatalError("can't initialize Qd.Error");
3483+
3484+
{
3485+
PyObject *o;
3486+
3487+
o = PyString_FromStringAndSize((char *)&qd.arrow, sizeof(qd.arrow));
3488+
if (o == NULL || PyDict_SetItemString(d, "arrow", o) != 0)
3489+
Py_FatalError("can't initialize Qd.arrow");
3490+
}
3491+
3492+
34563493
}
34573494

34583495
/* ========================= End module Qd ========================== */

Mac/Modules/qd/qdgen.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,11 @@
5757
)
5858
functions.append(f)
5959

60+
f = Function(void, 'SetCursor',
61+
(Cursor_ptr, 'crsr', InMode),
62+
)
63+
functions.append(f)
64+
6065
f = Function(void, 'HideCursor',
6166
)
6267
functions.append(f)

Mac/Modules/qd/qdscan.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ def makeblacklisttypes(self):
8787
'ConstPatternParam',
8888
'Pattern_ptr',
8989
'Pattern',
90-
'Cursor_ptr',
90+
## 'Cursor_ptr',
9191
'DeviceLoopDrawingProcPtr',
9292
'DeviceLoopFlags',
9393
'FontInfo',

Mac/Modules/qd/qdsupport.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ def getargsCheck(self, name):
4545
BitMap_ptr = OpaqueByValueType("BitMapPtr", "BMObj")
4646
RGBColor = OpaqueType('RGBColor', 'QdRGB')
4747
RGBColor_ptr = RGBColor
48+
Cursor = StructInputBufferType('Cursor')
49+
Cursor_ptr = Cursor
4850

4951
includestuff = includestuff + """
5052
#include <%s>""" % MACHEADERFILE + """
@@ -77,6 +79,17 @@ def getargsCheck(self, name):
7779
}
7880
7981
"""
82+
83+
variablestuff = """
84+
{
85+
PyObject *o;
86+
87+
o = PyString_FromStringAndSize((char *)&qd.arrow, sizeof(qd.arrow));
88+
if (o == NULL || PyDict_SetItemString(d, "arrow", o) != 0)
89+
Py_FatalError("can't initialize Qd.arrow");
90+
}
91+
"""
92+
8093
## not yet...
8194
##
8295
##class Region_ObjectDefinition(GlobalObjectDefinition):
@@ -147,7 +160,7 @@ def outputGetattrHook(self):
147160
""")
148161

149162
# Create the generator groups and link them
150-
module = MacModule(MODNAME, MODPREFIX, includestuff, finalstuff, initstuff)
163+
module = MacModule(MODNAME, MODPREFIX, includestuff, finalstuff, initstuff, variablestuff)
151164
##r_object = Region_ObjectDefinition('Region', 'QdRgn', 'RgnHandle')
152165
##po_object = Polygon_ObjectDefinition('Polygon', 'QdPgn', 'PolyHandle')
153166
##module.addobject(r_object)

0 commit comments

Comments
 (0)