aboutsummaryrefslogtreecommitdiff
path: root/src/image.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/image.cc')
-rw-r--r--src/image.cc43
1 files changed, 37 insertions, 6 deletions
diff --git a/src/image.cc b/src/image.cc
index c499d977..9915023a 100644
--- a/src/image.cc
+++ b/src/image.cc
@@ -23,19 +23,20 @@
using namespace dw::core;
-// Image to Object-Image macro
-#define I2DW(Image) ((dw::Image*)(Image->dw))
+// Image to Object-ImgRenderer macro
+#define I2IR(Image) ((dw::core::ImgRenderer*)(Image->img_rndr))
/*
* Create and initialize a new image structure.
*/
-DilloImage *a_Image_new(const char *alt_text, int32_t bg_color)
+DilloImage *a_Image_new(void *layout, void *img_rndr, int32_t bg_color)
{
DilloImage *Image;
Image = dNew(DilloImage, 1);
- Image->dw = (void*) new dw::Image(alt_text);
+ Image->layout = layout;
+ Image->img_rndr = img_rndr;
Image->width = 0;
Image->height = 0;
Image->bg_color = bg_color;
@@ -49,6 +50,26 @@ DilloImage *a_Image_new(const char *alt_text, int32_t bg_color)
}
/*
+ * Create and initialize a new image structure with an image widget.
+ */
+DilloImage *a_Image_new_with_dw(void *layout, const char *alt_text,
+ int32_t bg_color)
+{
+ dw::Image *dw = new dw::Image(alt_text);
+ return a_Image_new(layout, (void*)(dw::core::ImgRenderer*)dw, bg_color);
+}
+
+/*
+ * Return the image renderer as a widget. This is somewhat tricky,
+ * since simple casting leads to wrong (and hard to debug) results,
+ * because of multiple inheritance. This function can be used from C
+ * code, where only access to void* is possible.
+ */
+void *a_Image_get_dw(DilloImage *Image)
+{
+ return (dw::Image*)(dw::core::ImgRenderer*)Image->img_rndr;
+}
+/*
* Deallocate an Image structure
*/
static void Image_free(DilloImage *Image)
@@ -88,7 +109,7 @@ void a_Image_set_parms(DilloImage *Image, void *v_imgbuf, DilloUrl *url,
_MSG("a_Image_set_parms: width=%d height=%d\n", width, height);
bool resize = (Image->width != width || Image->height != height);
- I2DW(Image)->setBuffer((Imgbuf*)v_imgbuf, resize);
+ I2IR(Image)->setBuffer((Imgbuf*)v_imgbuf, resize);
if (!Image->BitVec)
Image->BitVec = a_Bitvec_new(height);
@@ -106,7 +127,7 @@ void a_Image_write(DilloImage *Image, uint_t y)
dReturn_if_fail ( y < Image->height );
/* Update the row in DwImage */
- I2DW(Image)->drawRow(y);
+ I2IR(Image)->drawRow(y);
a_Bitvec_set_bit(Image->BitVec, y);
Image->State = IMG_Write;
}
@@ -117,5 +138,15 @@ void a_Image_write(DilloImage *Image, uint_t y)
void a_Image_close(DilloImage *Image)
{
_MSG("a_Image_close\n");
+ I2IR(Image)->finish();
+}
+
+/*
+ * Implement the abort method
+ */
+void a_Image_abort(DilloImage *Image)
+{
+ _MSG("a_Image_abort\n");
+ I2IR(Image)->fatal();
}