el h / SimpleGUI

Fork of SimpleGUI by Duncan McIntyre

Revision:
16:e9a771ecfdbe
Parent:
15:e69fd74d42e4
diff -r e69fd74d42e4 -r e9a771ecfdbe Widgets/BitmapWidget.cpp
--- a/Widgets/BitmapWidget.cpp	Sat May 21 18:02:20 2016 +0000
+++ b/Widgets/BitmapWidget.cpp	Sun May 22 14:40:29 2016 +0000
@@ -1,10 +1,12 @@
 #include "BitmapWidget.h"
 
-BitmapWidget::BitmapWidget(GraphicsContext *context) : Widget(context), _monochrome(false)
+BitmapWidget::BitmapWidget(GraphicsContext *context) : 
+Widget(context), _monochrome(false), _bitmapWidth(0), _bitmapHeight(0)
 {
 }
 
-BitmapWidget::BitmapWidget(GraphicsContext *context, bool monochrome) : Widget(context), _monochrome(monochrome)
+BitmapWidget::BitmapWidget(GraphicsContext *context, bool monochrome) : 
+Widget(context), _monochrome(monochrome), _bitmapWidth(0), _bitmapHeight(0)
 {
 }
 
@@ -23,9 +25,18 @@
 void BitmapWidget::setBitmap(unsigned char const * bitmap, int width, int height)
 {
     _bitmap = (unsigned char*)bitmap;
+    _bitmapWidth = width;
+    _bitmapHeight = height;
     // Adjust overall size so that the inner window fits the bitmap
     // Really we should just clip, but that's too hard for now
-    setSize(((_padding + _borderWidth) * 2) + width, ((_padding + _borderWidth) * 2) + height);
+    setSize(((_padding + _borderWidth) * 2) + _bitmapWidth, ((_padding + _borderWidth) * 2) + _bitmapHeight);
+    dirty();
+}
+
+void BitmapWidget::setBorder(int width, uint16_t color)
+{
+    Widget::setBorder(width, color);
+    setSize(((_padding + _borderWidth) * 2) + _bitmapWidth, ((_padding + _borderWidth) * 2) + _bitmapHeight);
     dirty();
 }