Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of SimpleGUI by
Diff: Widgets/BitmapWidget.cpp
- Revision:
- 12:63db16fea709
- Parent:
- 9:616a9686d5db
- Child:
- 14:e6515b19f5a0
--- a/Widgets/BitmapWidget.cpp Fri Apr 22 16:12:42 2016 +0000
+++ b/Widgets/BitmapWidget.cpp Sun May 08 14:42:08 2016 +0000
@@ -1,16 +1,17 @@
#include "BitmapWidget.h"
-BitmapWidget::BitmapWidget(GUI* gui) : Widget(gui), _monochrome(false)
+BitmapWidget::BitmapWidget(GraphicsContext *context) : Widget(context), _monochrome(false)
{
}
-BitmapWidget::BitmapWidget(GUI* gui, bool monochrome) : Widget(gui), _monochrome(monochrome)
+BitmapWidget::BitmapWidget(GraphicsContext *context, bool monochrome) : Widget(context), _monochrome(monochrome)
{
}
void BitmapWidget::setMonochrome(bool enabled)
{
_monochrome = enabled;
+ dirty();
}
bool BitmapWidget::isMonochrome()
@@ -19,24 +20,23 @@
}
-void BitmapWidget::setBitmap(unsigned char* bitmap)
+void BitmapWidget::setBitmap(unsigned char* bitmap, int width, int height)
{
_bitmap = bitmap;
+ // 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);
+ dirty();
}
void BitmapWidget::_draw()
{
-
- _gui->display()->setForeground(_fg);
- _gui->display()->setBackground(_bg);
+ display()->setForeground(_fg);
+ display()->setBackground(_bg);
if(_monochrome) {
- _gui->display()->Bitmap_FG_BG(_x, _y, _width, _height, _bitmap);
+ display()->Bitmap_FG_BG(_inner.x, _inner.y, _inner.width, _inner.height, _bitmap);
} else {
- _gui->display()->Bitmap(_x, _y, _width, _height, _bitmap);
+ display()->Bitmap(_inner.x, _inner.y, _inner.width, _inner.height, _bitmap);
}
-}
-
-void BitmapWidget::_clear() {
- _gui->display()->fillrect(_x, _y, _x+_width, _y+_height, _gui->display()->getBackground());
}
\ No newline at end of file
