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@15:e69fd74d42e4, 2016-05-21 (annotated)
- Committer:
- duncanFrance
- Date:
- Sat May 21 18:02:20 2016 +0000
- Revision:
- 15:e69fd74d42e4
- Parent:
- 14:e6515b19f5a0
- Child:
- 16:e9a771ecfdbe
Make attach and detach register/unregister event handlers if needed.; - need to move the event handling into widget so we can attach/detach
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| duncanFrance | 4:27546fb8b670 | 1 | #include "BitmapWidget.h" |
| duncanFrance | 4:27546fb8b670 | 2 | |
| duncanFrance | 12:63db16fea709 | 3 | BitmapWidget::BitmapWidget(GraphicsContext *context) : Widget(context), _monochrome(false) |
| duncanFrance | 4:27546fb8b670 | 4 | { |
| duncanFrance | 4:27546fb8b670 | 5 | } |
| duncanFrance | 4:27546fb8b670 | 6 | |
| duncanFrance | 12:63db16fea709 | 7 | BitmapWidget::BitmapWidget(GraphicsContext *context, bool monochrome) : Widget(context), _monochrome(monochrome) |
| duncanFrance | 9:616a9686d5db | 8 | { |
| duncanFrance | 9:616a9686d5db | 9 | } |
| duncanFrance | 9:616a9686d5db | 10 | |
| duncanFrance | 4:27546fb8b670 | 11 | void BitmapWidget::setMonochrome(bool enabled) |
| duncanFrance | 4:27546fb8b670 | 12 | { |
| duncanFrance | 4:27546fb8b670 | 13 | _monochrome = enabled; |
| duncanFrance | 12:63db16fea709 | 14 | dirty(); |
| duncanFrance | 4:27546fb8b670 | 15 | } |
| duncanFrance | 4:27546fb8b670 | 16 | |
| duncanFrance | 4:27546fb8b670 | 17 | bool BitmapWidget::isMonochrome() |
| duncanFrance | 4:27546fb8b670 | 18 | { |
| duncanFrance | 4:27546fb8b670 | 19 | return _monochrome; |
| duncanFrance | 4:27546fb8b670 | 20 | } |
| duncanFrance | 4:27546fb8b670 | 21 | |
| duncanFrance | 4:27546fb8b670 | 22 | |
| duncanFrance | 14:e6515b19f5a0 | 23 | void BitmapWidget::setBitmap(unsigned char const * bitmap, int width, int height) |
| duncanFrance | 4:27546fb8b670 | 24 | { |
| duncanFrance | 14:e6515b19f5a0 | 25 | _bitmap = (unsigned char*)bitmap; |
| duncanFrance | 12:63db16fea709 | 26 | // Adjust overall size so that the inner window fits the bitmap |
| duncanFrance | 12:63db16fea709 | 27 | // Really we should just clip, but that's too hard for now |
| duncanFrance | 12:63db16fea709 | 28 | setSize(((_padding + _borderWidth) * 2) + width, ((_padding + _borderWidth) * 2) + height); |
| duncanFrance | 12:63db16fea709 | 29 | dirty(); |
| duncanFrance | 4:27546fb8b670 | 30 | } |
| duncanFrance | 4:27546fb8b670 | 31 | |
| duncanFrance | 8:a460cabc85ac | 32 | void BitmapWidget::_draw() |
| duncanFrance | 4:27546fb8b670 | 33 | { |
| duncanFrance | 15:e69fd74d42e4 | 34 | Widget::_draw(); |
| duncanFrance | 9:616a9686d5db | 35 | |
| duncanFrance | 4:27546fb8b670 | 36 | if(_monochrome) { |
| duncanFrance | 15:e69fd74d42e4 | 37 | int fg = display()->getForeground(); |
| duncanFrance | 15:e69fd74d42e4 | 38 | int bg = display()->getBackground(); |
| duncanFrance | 15:e69fd74d42e4 | 39 | display()->setForeground(_fg); |
| duncanFrance | 15:e69fd74d42e4 | 40 | display()->setBackground(_bg); |
| duncanFrance | 15:e69fd74d42e4 | 41 | |
| duncanFrance | 12:63db16fea709 | 42 | display()->Bitmap_FG_BG(_inner.x, _inner.y, _inner.width, _inner.height, _bitmap); |
| duncanFrance | 15:e69fd74d42e4 | 43 | |
| duncanFrance | 15:e69fd74d42e4 | 44 | display()->setForeground(fg); |
| duncanFrance | 15:e69fd74d42e4 | 45 | display()->setBackground(bg); |
| duncanFrance | 4:27546fb8b670 | 46 | } else { |
| duncanFrance | 12:63db16fea709 | 47 | display()->Bitmap(_inner.x, _inner.y, _inner.width, _inner.height, _bitmap); |
| duncanFrance | 4:27546fb8b670 | 48 | } |
| duncanFrance | 4:27546fb8b670 | 49 | } |
