3 #include "../apps_container.h" 15 return &m_contentView;
19 m_contentView.setSelectedButton(0);
24 m_contentView.setSelectedButton(0);
28 m_contentView.setSelectedButton(1);
34 PopUpController::ContentView::ContentView(
Responder * parentResponder) :
36 m_cancelButton(this,
I18n::Message::Cancel,
Invocation([](void * context, void * sender) {
37 PopUpController::ContentView *
view = (PopUpController::ContentView *)context;
38 view->app()->dismissModalViewController();
40 m_okButton(
this, I18n::Message::Ok,
Invocation([](
void * context,
void * sender) {
41 PopUpController::ContentView * view = (PopUpController::ContentView *)context;
53 void PopUpController::ContentView::drawRect(
KDContext * ctx,
KDRect rect)
const {
57 void PopUpController::ContentView::setSelectedButton(
int selectedButton) {
58 m_cancelButton.setHighlighted(selectedButton == 0);
59 m_okButton.setHighlighted(selectedButton == 1);
60 if (selectedButton == 0) {
61 app()->setFirstResponder(&m_cancelButton);
63 app()->setFirstResponder(&m_okButton);
67 int PopUpController::ContentView::selectedButton() {
68 if (m_cancelButton.isHighlighted()) {
74 int PopUpController::ContentView::numberOfSubviews()
const {
78 View * PopUpController::ContentView::subviewAtIndex(
int index) {
81 return &m_warningTextView;
83 return &m_messageTextView1;
85 return &m_messageTextView2;
87 return &m_messageTextView3;
89 return &m_messageTextView4;
91 return &m_cancelButton;
100 void PopUpController::ContentView::layoutSubviews() {
104 m_warningTextView.setFrame(
KDRect(0, k_topMargin, width, textHeight));
105 m_messageTextView1.setFrame(
KDRect(0, k_topMargin+k_paragraphHeight+textHeight, width, textHeight));
106 m_messageTextView2.setFrame(
KDRect(0, k_topMargin+k_paragraphHeight+2*textHeight, width, textHeight));
107 m_messageTextView3.setFrame(
KDRect(0, k_topMargin+k_paragraphHeight+3*textHeight, width, textHeight));
108 m_messageTextView4.setFrame(
KDRect(0, k_topMargin+k_paragraphHeight+4*textHeight, width, textHeight));
109 m_cancelButton.setFrame(
KDRect(k_buttonMargin, height-k_buttonMargin-k_buttonHeight, (width-3*k_buttonMargin)/2, k_buttonHeight));
110 m_okButton.setFrame(
KDRect(2*k_buttonMargin+(width-3*k_buttonMargin)/2, height-k_buttonMargin-k_buttonHeight, (width-3*k_buttonMargin)/2, k_buttonHeight));
void switchTo(App::Snapshot *snapshot) override
bool handleEvent(Ion::Events::Event event) override
void didBecomeFirstResponder() override
constexpr KDColor KDColorWhite
App::Snapshot * hardwareTestAppSnapshot()
constexpr KDColor KDColorBlack
void fillRect(KDRect rect, KDColor color)
static constexpr KDSize charSize(FontSize size=FontSize::Large)
constexpr KDCoordinate height() const