Select one of the symbols to view example projects that use it.
 
Outline
#include <gui/graph_screen/LegendEntry.hpp>
#include <touchgfx/Color.hpp>
#include <BitmapDatabase.hpp>
LegendEntry::LegendEntry()
LegendEntry::~LegendEntry()
LegendEntry::setBitmaps(BitmapId, BitmapId)
LegendEntry::setText(TEXTS)
LegendEntry::setValueText(int)
LegendEntry::setSelected(bool)
LegendEntry::buttonPressedHandler(const AbstractButton &)
Files
loading...
CodeScopeSTM32 Libraries and SamplesTouchGFXGui/gui/src/graph_screen/LegendEntry.cpp
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
/** ****************************************************************************** * This file is part of the TouchGFX 4.10.0 distribution. * * @attention * * Copyright (c) 2018 STMicroelectronics. * All rights reserved. * * This software is licensed under terms that can be found in the LICENSE file * in the root directory of this software component. * If no LICENSE file comes with this software, it is provided AS-IS. * ****************************************************************************** *//* ... */ #include <gui/graph_screen/LegendEntry.hpp> #include <touchgfx/Color.hpp> #include <BitmapDatabase.hpp> LegendEntry::LegendEntry() : onButtonPressed(this, &LegendEntry::buttonPressedHandler) { square.setBitmap(Bitmap(BITMAP_PIE_CHART_LEGEND_BLUE_ID)); square.setXY(0, 0); add(square); text.setColor(Color::getColorFrom24BitRGB(0xBE, 0xC0, 0xC4)); text.setPosition(square.getRect().right() + 6, 2, 80, 26); add(text); valueText.setWildcard(valueTextBuffer); valueText.setTypedText(TypedText(T_GRAPH_LEGEND_VALUE_TEXT)); valueText.setColor(text.getColor()); valueText.setPosition(text.getRect().right() + 6, text.getY(), 50, 26); add(valueText); setWidth(valueText.getRect().right()); setHeight(square.getRect().bottom() + 20); // Add a little extra height to make it easier to press // SelectButton is an invisible button selectButton.setPosition(0, 0, getWidth(), getHeight()); selectButton.setAction(onButtonPressed); add(selectButton); }{ ... } LegendEntry::~LegendEntry() { }{ ... } void LegendEntry::setBitmaps(BitmapId squareNotSelectedBmp, BitmapId squareSelectedBmp) { squareNotSelected = squareNotSelectedBmp; squareSelected = squareSelectedBmp; setSelected(false); }{ ... } void LegendEntry::setText(TEXTS textId) { text.setTypedText(TypedText(textId)); text.invalidate(); }{ ... } void LegendEntry::setValueText(int value) { Unicode::snprintf(valueTextBuffer, 6, "%i", value); valueText.invalidate(); }{ ... } void LegendEntry::setSelected(bool selected) { if (selected) { square.setBitmap(Bitmap(squareSelected)); text.setColor(Color::getColorFrom24BitRGB(0x0, 0x0, 0x0)); }if (selected) { ... } else { square.setBitmap(Bitmap(squareNotSelected)); text.setColor(Color::getColorFrom24BitRGB(0xBE, 0xC0, 0xC4)); }else { ... } valueText.setColor(text.getColor()); valueText.setVisible(selected); square.invalidate(); text.invalidate(); valueText.invalidate(); }{ ... } void LegendEntry::buttonPressedHandler(const AbstractButton& button) { if (selectionAction && selectionAction->isValid()) { selectionAction->execute(*this); }if (selectionAction && selectionAction->isValid()) { ... } }{ ... }