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.
Dependents: F746_SD_GraphicEqualizer_ren0620
Fork of F746_GUI by
Diff: Label.cpp
- Revision:
- 0:a2686ef737c2
- Child:
- 1:d1655f3c8717
diff -r 000000000000 -r a2686ef737c2 Label.cpp
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Label.cpp Thu Mar 31 07:28:42 2016 +0000
@@ -0,0 +1,38 @@
+//-----------------------------------------------------------
+// Label class
+//
+// 2016/03/29, Copyright (c) 2016 MIKAMI, Naoki
+//-----------------------------------------------------------
+
+#include "Label.hpp"
+
+namespace Mikami
+{
+ // Constructor
+ Label::Label(uint16_t x, uint16_t y,
+ const string str, TextAlignMode mode, sFONT &fonts,
+ uint32_t textColor, uint32_t backColor)
+ : GuiBase(x, y, fonts, textColor, backColor),
+ MODE_(mode)
+ {
+ length_ = str.length();
+ lcd_.SetBackColor(backColor);
+ lcd_.SetTextColor(textColor);
+ lcd_.SetFont(&fonts);
+ DrawString(PosX(x), y, str);
+ }
+
+ void Label::Draw(const string str)
+ {
+ // Erase previously-drawn string
+ lcd_.SetTextColor(BACK_COLOR_);
+ length_ = (length_ > str.length()) ? length_ : str.length();
+ lcd_.FillRect(PosX(X_), Y_, FONTS_->Width*length_+1, FONTS_->Height);
+ lcd_.SetTextColor(TEXT_COLOR_);
+
+ // Draw new string
+ length_ = str.length();
+ lcd_.SetFont(FONTS_);
+ DrawString(PosX(X_), Y_, str);
+ }
+}
