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
Widgets/BitmapWidget.cpp
- Committer:
- duncanFrance
- Date:
- 2016-05-21
- Revision:
- 15:e69fd74d42e4
- Parent:
- 14:e6515b19f5a0
- Child:
- 16:e9a771ecfdbe
File content as of revision 15:e69fd74d42e4:
#include "BitmapWidget.h"
BitmapWidget::BitmapWidget(GraphicsContext *context) : Widget(context), _monochrome(false)
{
}
BitmapWidget::BitmapWidget(GraphicsContext *context, bool monochrome) : Widget(context), _monochrome(monochrome)
{
}
void BitmapWidget::setMonochrome(bool enabled)
{
_monochrome = enabled;
dirty();
}
bool BitmapWidget::isMonochrome()
{
return _monochrome;
}
void BitmapWidget::setBitmap(unsigned char const * bitmap, int width, int height)
{
_bitmap = (unsigned char*)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()
{
Widget::_draw();
if(_monochrome) {
int fg = display()->getForeground();
int bg = display()->getBackground();
display()->setForeground(_fg);
display()->setBackground(_bg);
display()->Bitmap_FG_BG(_inner.x, _inner.y, _inner.width, _inner.height, _bitmap);
display()->setForeground(fg);
display()->setBackground(bg);
} else {
display()->Bitmap(_inner.x, _inner.y, _inner.width, _inner.height, _bitmap);
}
}
