hackathon-dev #1
|
@ -107,11 +107,8 @@ hdc.rectangle(cmd2_rect[0], cmd2_rect[1], cmd2_rect[2], cmd2_rect[3])
|
||||||
hdc.rectangle(cmd3_rect[0], cmd3_rect[1], cmd3_rect[2], cmd3_rect[3])
|
hdc.rectangle(cmd3_rect[0], cmd3_rect[1], cmd3_rect[2], cmd3_rect[3])
|
||||||
hdc.rectangle(cmd4_rect[0], cmd4_rect[1], cmd4_rect[2], cmd4_rect[3])
|
hdc.rectangle(cmd4_rect[0], cmd4_rect[1], cmd4_rect[2], cmd4_rect[3])
|
||||||
|
|
||||||
print('GOT HERE 1')
|
|
||||||
hdc_bits.select_object(bmp_freehand)
|
hdc_bits.select_object(bmp_freehand)
|
||||||
print('GOT HERE 2')
|
|
||||||
hdc.bitblt(cmd1_rect[0] + 6, cmd1_rect[1] + 6, cmd1_rect[0] + 54, cmd1_rect[1] + 54, hdc_bits, 0, 0, 0)
|
hdc.bitblt(cmd1_rect[0] + 6, cmd1_rect[1] + 6, cmd1_rect[0] + 54, cmd1_rect[1] + 54, hdc_bits, 0, 0, 0)
|
||||||
print('GOT HERE 3')
|
|
||||||
|
|
||||||
# Main message loop
|
# Main message loop
|
||||||
msg = {}
|
msg = {}
|
||||||
|
|
|
@ -45,13 +45,11 @@ static int bitmap_init(BitmapObject *self, PyObject *args, PyObject *kwds)
|
||||||
const char *stock;
|
const char *stock;
|
||||||
int width = 0, height = 0;
|
int width = 0, height = 0;
|
||||||
|
|
||||||
Log(LDEBUG, "Bitmap init entry");
|
|
||||||
if (!PyArg_ParseTupleAndKeywords(args, kwds, "|$sii", kwlist, &stock, &width, &height))
|
if (!PyArg_ParseTupleAndKeywords(args, kwds, "|$sii", kwlist, &stock, &width, &height))
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
if (stock)
|
if (stock)
|
||||||
{
|
{
|
||||||
Log(LDEBUG, "stock bitmap");
|
|
||||||
self->pbmp = _BMP_GetStock(stock);
|
self->pbmp = _BMP_GetStock(stock);
|
||||||
if (!(self->pbmp))
|
if (!(self->pbmp))
|
||||||
{
|
{
|
||||||
|
@ -61,7 +59,6 @@ static int bitmap_init(BitmapObject *self, PyObject *args, PyObject *kwds)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Log(LDEBUG, "basic bitmap");
|
|
||||||
width = MAX(1, width);
|
width = MAX(1, width);
|
||||||
height = MAX(1, height);
|
height = MAX(1, height);
|
||||||
self->pbmp = BMP_Create(width, height, NULL);
|
self->pbmp = BMP_Create(width, height, NULL);
|
||||||
|
@ -119,16 +116,12 @@ PyObject *Epython_wrap_bitmap(PBITMAP pbmp)
|
||||||
kwargs = PyDict_New();
|
kwargs = PyDict_New();
|
||||||
if (kwargs)
|
if (kwargs)
|
||||||
{
|
{
|
||||||
Log(LDEBUG, "gonna create it");
|
|
||||||
rc = PyType_GenericNew(&BitmapType, args, kwargs);
|
rc = PyType_GenericNew(&BitmapType, args, kwargs);
|
||||||
Log(LDEBUG, "created it");
|
|
||||||
if (rc)
|
if (rc)
|
||||||
{
|
{
|
||||||
pbitmapobj = (BitmapObject *)rc;
|
pbitmapobj = (BitmapObject *)rc;
|
||||||
Log(LDEBUG, "gonna delete bitmap");
|
|
||||||
if (pbitmapobj->pbmp)
|
if (pbitmapobj->pbmp)
|
||||||
BMP_Delete(pbitmapobj->pbmp);
|
BMP_Delete(pbitmapobj->pbmp);
|
||||||
Log(LDEBUG, "deleted bitmap");
|
|
||||||
pbitmapobj->pbmp = pbmp;
|
pbitmapobj->pbmp = pbmp;
|
||||||
}
|
}
|
||||||
Py_DECREF(kwargs);
|
Py_DECREF(kwargs);
|
||||||
|
|
|
@ -144,24 +144,18 @@ static PyObject *devctxt_select_bitmap(DevCtxtObject *self, BitmapObject *newbmp
|
||||||
BitmapObject *old_bitmap = NULL;
|
BitmapObject *old_bitmap = NULL;
|
||||||
PBITMAP old_pbmp;
|
PBITMAP old_pbmp;
|
||||||
|
|
||||||
Log(LDEBUG, "select_bitmap entry");
|
|
||||||
if ((self->pdctxt->flags & DCFLG_TYPES) != DCFLG_IS_MEMORY)
|
if ((self->pdctxt->flags & DCFLG_TYPES) != DCFLG_IS_MEMORY)
|
||||||
{
|
{
|
||||||
PyErr_SetString(PyExc_RuntimeError, "must select bitmap into memory device context");
|
PyErr_SetString(PyExc_RuntimeError, "must select bitmap into memory device context");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
Log(LDEBUG, "verified 1");
|
|
||||||
old_bitmap = self->selected_bitmap;
|
old_bitmap = self->selected_bitmap;
|
||||||
old_pbmp = (PBITMAP)DC_SelectObject(self->pdctxt, (PGFXOBJECT)(newbmp->pbmp));
|
old_pbmp = (PBITMAP)DC_SelectObject(self->pdctxt, (PGFXOBJECT)(newbmp->pbmp));
|
||||||
Log(LDEBUG, "old_bitmap present=%d, old_pbmp present=%d", !!old_bitmap, !!old_pbmp);
|
|
||||||
if (!old_bitmap)
|
if (!old_bitmap)
|
||||||
{
|
{
|
||||||
Log(LDEBUG, "need to wrap old bitmap");
|
|
||||||
old_bitmap = (BitmapObject *)Epython_wrap_bitmap(old_pbmp);
|
old_bitmap = (BitmapObject *)Epython_wrap_bitmap(old_pbmp);
|
||||||
Log(LDEBUG, "wrapper finished");
|
|
||||||
if (!old_bitmap)
|
if (!old_bitmap)
|
||||||
{
|
{
|
||||||
Log(LDEBUG, "wrapper failed");
|
|
||||||
DC_SelectObject(self->pdctxt, (PGFXOBJECT)old_pbmp);
|
DC_SelectObject(self->pdctxt, (PGFXOBJECT)old_pbmp);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -171,7 +165,6 @@ static PyObject *devctxt_select_bitmap(DevCtxtObject *self, BitmapObject *newbmp
|
||||||
self->selected_bitmap = old_bitmap;
|
self->selected_bitmap = old_bitmap;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Log(LDEBUG, "replacement sequence");
|
|
||||||
ASSERT(old_bitmap);
|
ASSERT(old_bitmap);
|
||||||
ASSERT(self->selected_bitmap);
|
ASSERT(self->selected_bitmap);
|
||||||
ASSERT(newbmp);
|
ASSERT(newbmp);
|
||||||
|
@ -185,7 +178,6 @@ static PyObject *devctxt_select_object(DevCtxtObject *self, PyObject *args)
|
||||||
{
|
{
|
||||||
PyObject *obj;
|
PyObject *obj;
|
||||||
|
|
||||||
Log(LDEBUG, "select_object entry");
|
|
||||||
if (!PyArg_ParseTuple(args, "O", &obj))
|
if (!PyArg_ParseTuple(args, "O", &obj))
|
||||||
return NULL;
|
return NULL;
|
||||||
if (!obj)
|
if (!obj)
|
||||||
|
@ -193,7 +185,6 @@ static PyObject *devctxt_select_object(DevCtxtObject *self, PyObject *args)
|
||||||
PyErr_SetString(PyExc_RuntimeError, "bad object selected");
|
PyErr_SetString(PyExc_RuntimeError, "bad object selected");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
Log(LDEBUG, "ready to comb objects");
|
|
||||||
if (PyObject_TypeCheck(obj, &BitmapType))
|
if (PyObject_TypeCheck(obj, &BitmapType))
|
||||||
return devctxt_select_bitmap(self, (BitmapObject *)obj);
|
return devctxt_select_bitmap(self, (BitmapObject *)obj);
|
||||||
PyErr_SetString(PyExc_RuntimeError, "unknown type of object selected");
|
PyErr_SetString(PyExc_RuntimeError, "unknown type of object selected");
|
||||||
|
|
Loading…
Reference in New Issue
Block a user