Numworks Epsilon  1.4.1
Graphing Calculator Operating System
apps_window.cpp
Go to the documentation of this file.
1 #include "apps_window.h"
2 #include <escher/metric.h>
3 extern "C" {
4 #include <assert.h>
5 }
6 
8  Window(),
9  m_titleBarView(),
10  m_hideTitleBarView(false)
11 {
12 }
13 
14 void AppsWindow::setTitle(I18n::Message title) {
15  m_titleBarView.setTitle(title);
16 }
17 
19  return m_titleBarView.setChargeState(Ion::Battery::level());
20 }
21 
23  return m_titleBarView.setIsCharging(Ion::Battery::isCharging());
24 }
25 
27  return m_titleBarView.setIsPlugged(Ion::USB::isPlugged());
28 }
29 
31  m_titleBarView.refreshPreferences();
32 }
33 
36 }
37 
39  if (m_hideTitleBarView != hide) {
40  m_hideTitleBarView = hide;
41  layoutSubviews();
42  }
43 }
44 
45 int AppsWindow::numberOfSubviews() const {
46  return (m_contentView == nullptr ? 1 : 2);
47 }
48 
49 View * AppsWindow::subviewAtIndex(int index) {
50  if (index == 0) {
51  return &m_titleBarView;
52  }
53  assert(m_contentView != nullptr && index == 1);
54  return m_contentView;
55 }
56 
57 void AppsWindow::layoutSubviews() {
58  KDCoordinate titleHeight = m_hideTitleBarView ? 0 : Metric::TitleBarHeight;
59  m_titleBarView.setFrame(KDRect(0, 0, bounds().width(), titleHeight));
60  if (m_contentView != nullptr) {
61  m_contentView->setFrame(KDRect(0, titleHeight, bounds().width(), bounds().height()-titleHeight));
62  }
63 }
64 
65 #if ESCHER_VIEW_LOGGING
66 const char * AppsWindow::className() const {
67  return "Window";
68 }
69 #endif
bool updateBatteryLevel()
Definition: apps_window.cpp:18
Charge level()
Definition: battery.cpp:20
bool isPlugged()
Definition: usb.cpp:12
void refreshPreferences()
void setTitle(I18n::Message title)
Definition: apps_window.cpp:14
#define assert(e)
Definition: assert.h:9
Definition: window.h:6
void setFrame(KDRect frame)
Definition: view.cpp:125
static constexpr KDCoordinate TitleBarHeight
Definition: metric.h:14
bool isCharging()
Definition: battery.cpp:16
int16_t KDCoordinate
Definition: coordinate.h:6
bool setChargeState(Ion::Battery::Charge chargeState)
bool updatePluggedState()
Definition: apps_window.cpp:26
bool setShiftAlphaLockStatus(Ion::Events::ShiftAlphaStatus status)
bool setIsCharging(bool isCharging)
ShiftAlphaStatus shiftAlphaStatus()
bool setIsPlugged(bool isPlugged)
bool updateIsChargingState()
Definition: apps_window.cpp:22
#define false
Definition: stdbool.h:9
void refreshPreferences()
Definition: apps_window.cpp:30
void setTitle(I18n::Message title)
bool updateAlphaLock()
Definition: apps_window.cpp:34
Definition: rect.h:26
Definition: view.h:23
View * m_contentView
Definition: window.h:18
KDRect bounds() const
Definition: view.cpp:157
void hideTitleBarView(bool hide)
Definition: apps_window.cpp:38