Numworks Epsilon
1.4.1
Graphing Calculator Operating System
shift_alpha_lock_view.cpp
Go to the documentation of this file.
1
#include "
shift_alpha_lock_view.h
"
2
3
ShiftAlphaLockView::ShiftAlphaLockView
() :
4
View
(),
5
m_shiftAlphaView(
KDText
::FontSize::Small,
I18n
::Message::Default, 1.0f, 0.5f,
KDColorWhite
,
Palette
::YellowDark),
6
m_status(
Ion
::Events::
ShiftAlphaStatus
::Default)
7
{
8
}
9
10
void
ShiftAlphaLockView::drawRect
(
KDContext
* ctx,
KDRect
rect)
const
{
11
ctx->
fillRect
(
bounds
(),
Palette::YellowDark
);
12
}
13
14
bool
ShiftAlphaLockView::setStatus
(
Ion::Events::ShiftAlphaStatus
status) {
15
if
(status != m_status) {
16
m_status = status;
17
switch
(m_status) {
18
case
Ion::Events::ShiftAlphaStatus::Alpha
:
19
case
Ion::Events::ShiftAlphaStatus::AlphaLock
:
20
m_shiftAlphaView.
setMessage
(
I18n::Message::Alpha
);
21
break
;
22
case
Ion::Events::ShiftAlphaStatus::ShiftAlpha
:
23
case
Ion::Events::ShiftAlphaStatus::ShiftAlphaLock
:
24
m_shiftAlphaView.
setMessage
(I18n::Message::CapitalAlpha);
25
break
;
26
case
Ion::Events::ShiftAlphaStatus::Shift
:
27
m_shiftAlphaView.
setMessage
(
I18n::Message::Shift
);
28
break
;
29
case
Ion::Events::ShiftAlphaStatus::Default
:
30
m_shiftAlphaView.
setMessage
(I18n::Message::Default);
31
break
;
32
}
33
markRectAsDirty
(
bounds
());
34
return
true
;
35
}
36
return
false
;
37
}
38
39
KDSize
ShiftAlphaLockView::minimalSizeForOptimalDisplay
()
const
{
40
KDSize
modifierSize =
KDText::stringSize
(
I18n::translate
(
I18n::Message::Alpha
),
KDText::FontSize::Small
);
41
KDSize
lockSize = m_lockView.
minimalSizeForOptimalDisplay
();
42
KDCoordinate
height = lockSize.
height
() > modifierSize.
height
() ? lockSize.
height
() : modifierSize.
height
();
43
return
KDSize
(modifierSize.
width
() + lockSize.
width
() + k_lockRightMargin, height);
44
}
45
46
int
ShiftAlphaLockView::numberOfSubviews()
const
{
47
switch
(m_status) {
48
case
Ion::Events::ShiftAlphaStatus::Alpha
:
49
case
Ion::Events::ShiftAlphaStatus::Shift
:
50
case
Ion::Events::ShiftAlphaStatus::ShiftAlpha
:
51
return
1;
52
case
Ion::Events::ShiftAlphaStatus::AlphaLock
:
53
case
Ion::Events::ShiftAlphaStatus::ShiftAlphaLock
:
54
return
2;
55
case
Ion::Events::ShiftAlphaStatus::Default
:
56
return
0;
57
}
58
return
0;
59
}
60
61
View
* ShiftAlphaLockView::subviewAtIndex(
int
index) {
62
if
(index == 0) {
63
return
&m_shiftAlphaView;
64
}
65
return
&m_lockView;
66
}
67
68
void
ShiftAlphaLockView::layoutSubviews() {
69
KDSize
modifierSize =
KDText::stringSize
(
I18n::translate
(
I18n::Message::Alpha
),
KDText::FontSize::Small
);
70
m_shiftAlphaView.
setFrame
(
KDRect
(
bounds
().width() - modifierSize.
width
(), (
bounds
().
height
()- modifierSize.
height
())/2, modifierSize));
71
72
KDSize
lockSize = m_lockView.
minimalSizeForOptimalDisplay
();
73
m_lockView.
setFrame
(
KDRect
(
bounds
().width() - modifierSize.
width
() - lockSize.
width
() - k_lockRightMargin, (
bounds
().
height
()- lockSize.
height
())/2, lockSize));
74
}
Palette::YellowDark
static constexpr KDColor YellowDark
Definition:
palette.h:8
I18n
Definition:
i18n.h:6
Ion::Events::ShiftAlphaStatus
ShiftAlphaStatus
Definition:
events.h:41
Ion::Events::ShiftAlphaStatus::ShiftAlpha
View::setFrame
void setFrame(KDRect frame)
Definition:
view.cpp:125
KDCoordinate
int16_t KDCoordinate
Definition:
coordinate.h:6
KDSize::width
constexpr KDCoordinate width() const
Definition:
size.h:10
Ion::Events::ShiftAlphaStatus::ShiftAlphaLock
KDText::stringSize
static KDSize stringSize(const char *text, FontSize size=FontSize::Large)
Definition:
text.cpp:6
View::markRectAsDirty
void markRectAsDirty(KDRect rect)
Definition:
view.cpp:39
Ion::Events::ShiftAlphaStatus::Default
ShiftAlphaLockView::drawRect
void drawRect(KDContext *ctx, KDRect rect) const override
Definition:
shift_alpha_lock_view.cpp:10
KDText
Definition:
text.h:8
ShiftAlphaLockView::ShiftAlphaLockView
ShiftAlphaLockView()
Definition:
shift_alpha_lock_view.cpp:3
KDSize
Definition:
size.h:6
LockView::minimalSizeForOptimalDisplay
KDSize minimalSizeForOptimalDisplay() const override
Definition:
lock_view.cpp:22
I18n::translate
enum Message uint16_t enum Language uint16_t const char * translate(Message m, Language l=(Language) 0)
Definition:
i18n.cpp:5
KDColorWhite
constexpr KDColor KDColorWhite
Definition:
color.h:42
ShiftAlphaLockView::setStatus
bool setStatus(Ion::Events::ShiftAlphaStatus status)
Definition:
shift_alpha_lock_view.cpp:14
ShiftAlphaLockView::minimalSizeForOptimalDisplay
KDSize minimalSizeForOptimalDisplay() const override
Definition:
shift_alpha_lock_view.cpp:39
MessageTextView::setMessage
void setMessage(I18n::Message message)
Definition:
message_text_view.cpp:19
KDText::FontSize::Small
KDContext
Definition:
context.h:8
KDRect
Definition:
rect.h:26
KDContext::fillRect
void fillRect(KDRect rect, KDColor color)
Definition:
context_rect.cpp:8
Ion::Events::ShiftAlphaStatus::Alpha
View
Definition:
view.h:23
shift_alpha_lock_view.h
Ion::Events::ShiftAlphaStatus::Shift
Ion::Events::ShiftAlphaStatus::AlphaLock
Ion::Events::Alpha
constexpr Event Alpha
Definition:
events.h:72
Ion
Definition:
backlight.h:6
Ion::Events::Shift
constexpr Event Shift
Definition:
events.h:71
KDRect::height
KDCoordinate height() const
Definition:
rect.h:40
View::bounds
KDRect bounds() const
Definition:
view.cpp:157
KDSize::height
constexpr KDCoordinate height() const
Definition:
size.h:11
Palette
Definition:
palette.h:6
epsilon
apps
shift_alpha_lock_view.cpp
Generated by
1.8.14