Numworks Epsilon  1.4.1
Graphing Calculator Operating System
shift_alpha_lock_view.cpp
Go to the documentation of this file.
2 
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 
12 }
13 
15  if (status != m_status) {
16  m_status = status;
17  switch (m_status) {
20  m_shiftAlphaView.setMessage(I18n::Message::Alpha);
21  break;
24  m_shiftAlphaView.setMessage(I18n::Message::CapitalAlpha);
25  break;
27  m_shiftAlphaView.setMessage(I18n::Message::Shift);
28  break;
30  m_shiftAlphaView.setMessage(I18n::Message::Default);
31  break;
32  }
34  return true;
35  }
36  return false;
37 }
38 
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) {
51  return 1;
54  return 2;
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() {
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 }
static constexpr KDColor YellowDark
Definition: palette.h:8
Definition: i18n.h:6
ShiftAlphaStatus
Definition: events.h:41
void setFrame(KDRect frame)
Definition: view.cpp:125
int16_t KDCoordinate
Definition: coordinate.h:6
constexpr KDCoordinate width() const
Definition: size.h:10
static KDSize stringSize(const char *text, FontSize size=FontSize::Large)
Definition: text.cpp:6
void markRectAsDirty(KDRect rect)
Definition: view.cpp:39
void drawRect(KDContext *ctx, KDRect rect) const override
Definition: text.h:8
Definition: size.h:6
KDSize minimalSizeForOptimalDisplay() const override
Definition: lock_view.cpp:22
enum Message uint16_t enum Language uint16_t const char * translate(Message m, Language l=(Language) 0)
Definition: i18n.cpp:5
constexpr KDColor KDColorWhite
Definition: color.h:42
bool setStatus(Ion::Events::ShiftAlphaStatus status)
KDSize minimalSizeForOptimalDisplay() const override
void setMessage(I18n::Message message)
Definition: rect.h:26
void fillRect(KDRect rect, KDColor color)
Definition: context_rect.cpp:8
Definition: view.h:23
constexpr Event Alpha
Definition: events.h:72
Definition: backlight.h:6
constexpr Event Shift
Definition: events.h:71
KDCoordinate height() const
Definition: rect.h:40
KDRect bounds() const
Definition: view.cpp:157
constexpr KDCoordinate height() const
Definition: size.h:11
Definition: palette.h:6