window.cpp
878 Bytes
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
#include <escher/window.h>
#include <ion.h>
extern "C" {
#include <assert.h>
}
Window::Window() :
m_contentView(nullptr)
{
}
void Window::redraw(bool force) {
if (force) {
markRectAsDirty(bounds());
}
Ion::Display::waitForVBlank();
View::redraw(bounds());
}
void Window::setContentView(View * contentView) {
m_contentView = contentView;
markRectAsDirty(bounds());
layoutSubviews();
}
const Window * Window::window() const {
return this;
}
int Window::numberOfSubviews() const {
return (m_contentView == nullptr ? 0 : 1);
}
View * Window::subviewAtIndex(int index) {
assert(m_contentView != nullptr && index == 0);
return m_contentView;
}
void Window::layoutSubviews() {
if (m_contentView != nullptr) {
m_contentView->setFrame(bounds());
}
}
#if ESCHER_VIEW_LOGGING
const char * Window::className() const {
return "Window";
}
#endif