GUI parts for DISCO-F746NG. GuiBase, Button, ButtonGroup, ResetButton, Label, BlinkLabel, NumericLabel, SeekBar, SeekbarGroup, NumericUpDown
Dependencies: Array_Matrix TS_DISCO_F746NG LCD_DISCO_F746NG BSP_DISCO_F746NG
Label.cpp@0:a2686ef737c2, 2016-03-31 (annotated)
- Committer:
- MikamiUitOpen
- Date:
- Thu Mar 31 07:28:42 2016 +0000
- Revision:
- 0:a2686ef737c2
- Child:
- 1:d1655f3c8717
1
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
MikamiUitOpen | 0:a2686ef737c2 | 1 | //----------------------------------------------------------- |
MikamiUitOpen | 0:a2686ef737c2 | 2 | // Label class |
MikamiUitOpen | 0:a2686ef737c2 | 3 | // |
MikamiUitOpen | 0:a2686ef737c2 | 4 | // 2016/03/29, Copyright (c) 2016 MIKAMI, Naoki |
MikamiUitOpen | 0:a2686ef737c2 | 5 | //----------------------------------------------------------- |
MikamiUitOpen | 0:a2686ef737c2 | 6 | |
MikamiUitOpen | 0:a2686ef737c2 | 7 | #include "Label.hpp" |
MikamiUitOpen | 0:a2686ef737c2 | 8 | |
MikamiUitOpen | 0:a2686ef737c2 | 9 | namespace Mikami |
MikamiUitOpen | 0:a2686ef737c2 | 10 | { |
MikamiUitOpen | 0:a2686ef737c2 | 11 | // Constructor |
MikamiUitOpen | 0:a2686ef737c2 | 12 | Label::Label(uint16_t x, uint16_t y, |
MikamiUitOpen | 0:a2686ef737c2 | 13 | const string str, TextAlignMode mode, sFONT &fonts, |
MikamiUitOpen | 0:a2686ef737c2 | 14 | uint32_t textColor, uint32_t backColor) |
MikamiUitOpen | 0:a2686ef737c2 | 15 | : GuiBase(x, y, fonts, textColor, backColor), |
MikamiUitOpen | 0:a2686ef737c2 | 16 | MODE_(mode) |
MikamiUitOpen | 0:a2686ef737c2 | 17 | { |
MikamiUitOpen | 0:a2686ef737c2 | 18 | length_ = str.length(); |
MikamiUitOpen | 0:a2686ef737c2 | 19 | lcd_.SetBackColor(backColor); |
MikamiUitOpen | 0:a2686ef737c2 | 20 | lcd_.SetTextColor(textColor); |
MikamiUitOpen | 0:a2686ef737c2 | 21 | lcd_.SetFont(&fonts); |
MikamiUitOpen | 0:a2686ef737c2 | 22 | DrawString(PosX(x), y, str); |
MikamiUitOpen | 0:a2686ef737c2 | 23 | } |
MikamiUitOpen | 0:a2686ef737c2 | 24 | |
MikamiUitOpen | 0:a2686ef737c2 | 25 | void Label::Draw(const string str) |
MikamiUitOpen | 0:a2686ef737c2 | 26 | { |
MikamiUitOpen | 0:a2686ef737c2 | 27 | // Erase previously-drawn string |
MikamiUitOpen | 0:a2686ef737c2 | 28 | lcd_.SetTextColor(BACK_COLOR_); |
MikamiUitOpen | 0:a2686ef737c2 | 29 | length_ = (length_ > str.length()) ? length_ : str.length(); |
MikamiUitOpen | 0:a2686ef737c2 | 30 | lcd_.FillRect(PosX(X_), Y_, FONTS_->Width*length_+1, FONTS_->Height); |
MikamiUitOpen | 0:a2686ef737c2 | 31 | lcd_.SetTextColor(TEXT_COLOR_); |
MikamiUitOpen | 0:a2686ef737c2 | 32 | |
MikamiUitOpen | 0:a2686ef737c2 | 33 | // Draw new string |
MikamiUitOpen | 0:a2686ef737c2 | 34 | length_ = str.length(); |
MikamiUitOpen | 0:a2686ef737c2 | 35 | lcd_.SetFont(FONTS_); |
MikamiUitOpen | 0:a2686ef737c2 | 36 | DrawString(PosX(X_), Y_, str); |
MikamiUitOpen | 0:a2686ef737c2 | 37 | } |
MikamiUitOpen | 0:a2686ef737c2 | 38 | } |