hackathon-dev #1

Merged
amy merged 101 commits from hackathon-dev into develop 2019-12-12 13:56:11 -07:00
2 changed files with 11 additions and 7 deletions
Showing only changes of commit 0dd8d45898 - Show all commits

View File

@ -7,13 +7,10 @@ LTGRAY = upiwin.rgb(204, 204, 204)
YELLOW = upiwin.rgb(255, 255, 0) YELLOW = upiwin.rgb(255, 255, 0)
# Get the stock bitmaps. # Get the stock bitmaps.
print('GOT HERE 1')
bmp_freehand = upiwin.Bitmap(stock='freehand') bmp_freehand = upiwin.Bitmap(stock='freehand')
print('GOT HERE 1A')
bmp_line = upiwin.Bitmap(stock='line') bmp_line = upiwin.Bitmap(stock='line')
bmp_rect = upiwin.Bitmap(stock='rect') bmp_rect = upiwin.Bitmap(stock='rect')
bmp_fillrect = upiwin.Bitmap(stock='fillrect') bmp_fillrect = upiwin.Bitmap(stock='fillrect')
print('GOT HERE 2')
hdc = upiwin.DevCtxt(type='screen') hdc = upiwin.DevCtxt(type='screen')
hdc_bits = upiwin.DevCtxt(type='memory') hdc_bits = upiwin.DevCtxt(type='memory')
@ -110,11 +107,11 @@ 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 3') print('GOT HERE 1')
hdc_bits.select_object(bmp_freehand) hdc_bits.select_object(bmp_freehand)
print('GOT HERE 4') 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 5') print('GOT HERE 3')
# Main message loop # Main message loop
msg = {} msg = {}

View File

@ -144,15 +144,19 @@ 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);
if (!old_bitmap) if (!old_bitmap)
{ {
@ -162,6 +166,7 @@ static PyObject *devctxt_select_bitmap(DevCtxtObject *self, BitmapObject *newbmp
else else
Py_INCREF(old_bitmap); Py_INCREF(old_bitmap);
} }
Log(LDEBUG, "replacement sequence");
Py_DECREF(self->selected_bitmap); Py_DECREF(self->selected_bitmap);
self->selected_bitmap = newbmp; self->selected_bitmap = newbmp;
Py_INCREF(self->selected_bitmap); Py_INCREF(self->selected_bitmap);
@ -171,7 +176,8 @@ static PyObject *devctxt_select_bitmap(DevCtxtObject *self, BitmapObject *newbmp
static PyObject *devctxt_select_object(DevCtxtObject *self, PyObject *args) 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)
@ -179,6 +185,7 @@ 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");