Foundation classes for a basic GUI implementing simple widgets and events
Dependents: TouchScreenGUIDemo
Widgets/BitmapWidget.cpp@8:a460cabc85ac, 2016-04-11 (annotated)
- Committer:
- duncanFrance
- Date:
- Mon Apr 11 16:54:02 2016 +0000
- Revision:
- 8:a460cabc85ac
- Parent:
- 7:303850a4b30c
- Child:
- 9:616a9686d5db
Added GUI for common defaults
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 | 8:a460cabc85ac | 3 | BitmapWidget::BitmapWidget(GUI* gui) : Widget(gui), _monochrome(false) |
duncanFrance | 4:27546fb8b670 | 4 | { |
duncanFrance | 4:27546fb8b670 | 5 | } |
duncanFrance | 4:27546fb8b670 | 6 | |
duncanFrance | 4:27546fb8b670 | 7 | void BitmapWidget::setMonochrome(bool enabled) |
duncanFrance | 4:27546fb8b670 | 8 | { |
duncanFrance | 4:27546fb8b670 | 9 | _monochrome = enabled; |
duncanFrance | 4:27546fb8b670 | 10 | } |
duncanFrance | 4:27546fb8b670 | 11 | |
duncanFrance | 4:27546fb8b670 | 12 | bool BitmapWidget::isMonochrome() |
duncanFrance | 4:27546fb8b670 | 13 | { |
duncanFrance | 4:27546fb8b670 | 14 | return _monochrome; |
duncanFrance | 4:27546fb8b670 | 15 | } |
duncanFrance | 4:27546fb8b670 | 16 | |
duncanFrance | 4:27546fb8b670 | 17 | |
duncanFrance | 4:27546fb8b670 | 18 | void BitmapWidget::setBitmap(unsigned char* bitmap) |
duncanFrance | 4:27546fb8b670 | 19 | { |
duncanFrance | 4:27546fb8b670 | 20 | _bitmap = bitmap; |
duncanFrance | 4:27546fb8b670 | 21 | } |
duncanFrance | 4:27546fb8b670 | 22 | |
duncanFrance | 8:a460cabc85ac | 23 | void BitmapWidget::_draw() |
duncanFrance | 4:27546fb8b670 | 24 | { |
duncanFrance | 4:27546fb8b670 | 25 | |
duncanFrance | 4:27546fb8b670 | 26 | if(_monochrome) { |
duncanFrance | 8:a460cabc85ac | 27 | _gui->display()->Bitmap_FG_BG(_x, _y, _width, _height, _bitmap); |
duncanFrance | 4:27546fb8b670 | 28 | } else { |
duncanFrance | 8:a460cabc85ac | 29 | _gui->display()->Bitmap(_x, _y, _width, _height, _bitmap); |
duncanFrance | 4:27546fb8b670 | 30 | } |
duncanFrance | 8:a460cabc85ac | 31 | } |
duncanFrance | 8:a460cabc85ac | 32 | |
duncanFrance | 8:a460cabc85ac | 33 | void BitmapWidget::_clear() { |
duncanFrance | 8:a460cabc85ac | 34 | _gui->display()->fillrect(_x, _y, _x+_width, _y+_height, _gui->display()->getBackground()); |
duncanFrance | 4:27546fb8b670 | 35 | } |