/** * Creates and adds main layout to the screen. */ void SettingsScreen::createMainLayout() { VerticalLayout* mainLayout = new VerticalLayout(); Screen::setMainWidget(mainLayout); ListView* listView = new ListView(); listView->fillSpaceHorizontally(); listView->fillSpaceVertically(); mainLayout->addChild(listView); ListViewItem* listItem; // Add IP label and edit box mIPEditBox = new EditBox(); mIPEditBox->setInputMode(EDIT_BOX_INPUT_MODE_NUMERIC); listView->addChild(this->createListViewItem(IP_LABEL_TEXT, mIPEditBox)); // Add port label and edit box mPortEditBox = new EditBox(); mPortEditBox->setInputMode(EDIT_BOX_INPUT_MODE_NUMERIC); listView->addChild(this->createListViewItem(PORT_LABEL_TEXT, mPortEditBox)); if ( isAndroid() ) { mShowOnlyIfInBackground = new CheckBox(); mShowOnlyIfInBackground->setState(true); listView->addChild(createListViewItem(SHOW_ONLY_IF_NOT_RUNNING, mShowOnlyIfInBackground)); mTickerText = new EditBox(); mTickerText->setText(TICKER_DEFAULT); listView->addChild(createListViewItem(TICKER_LABEL, mTickerText)); mContentTitle = new EditBox(); mContentTitle->setText(TITLE_DEFAULT); listView->addChild(createListViewItem(TITLE_LABEL, mContentTitle)); } // Android: If the registrationID was already saved from previous launches, // do not connect again. MAHandle myStore = maOpenStore("MyStore", 0); if ( isAndroid() && myStore == STERR_NONEXISTENT || !isAndroid() ) { // Add connection status label. listItem = new ListViewItem; listView->addChild(listItem); mConnectionStatusLabel = new Label(); mConnectionStatusLabel->setText(CONNECTION_NOT_ESTABLISHED); listItem->addChild(mConnectionStatusLabel); listItem = new ListViewItem; listView->addChild(listItem); mConnectButton = new Button(); mConnectButton->setText(CONNECT_BUTTON_TEXT); listItem->addChild(mConnectButton); } }
/** * Creates and adds main layout to the screen. */ void CreateNotificationScreen::createMainLayout() { VerticalLayout* mainLayout = new VerticalLayout(); Screen::setMainWidget(mainLayout); ListView* listView = new ListView(); listView->fillSpaceHorizontally(); listView->fillSpaceVertically(); mainLayout->addChild(listView); ListViewItem* listItem; HorizontalLayout* hLayout; Widget* space; // ================ Content body ===================== mContentBody = new EditBox(); listView->addChild(createListViewItem(CONTENT_BODY_LABEL_TEXT,(Widget*) mContentBody)); if ( isAndroid() ) { // ================ Content title ===================== mContentTitle = new EditBox(); listView->addChild(createListViewItem(CONTENT_TITLE_LABEL_TEXT, mContentTitle)); // ================ Ticker text ===================== mTickerText = new EditBox(); listView->addChild(createListViewItem(TICKER_TEXT_LABEL_TEXT, mTickerText)); } else { // ================ Badge number ===================== mBadgeNumber = new EditBox(); mBadgeNumber->setWidth(NUMERIC_EDIT_BOX_WIDTH); mBadgeNumber->setInputMode(EDIT_BOX_INPUT_MODE_NUMERIC); mBadgeNumber->addEditBoxListener(this); listView->addChild(createListViewItem(BADGE_NUMBER_LABEL_TEXT, mBadgeNumber)); // ================ Alert action ===================== mAlertAction = new EditBox(); mAlertAction->addEditBoxListener(this); listView->addChild(createListViewItem(ALERT_ACTION_LABEL_TEXT, mAlertAction)); } // ================ Play sound ===================== mPlaySound = new CheckBox(); listView->addChild(createListViewItem(PLAY_SOUND_LABEL_TEXT, mPlaySound)); if ( isAndroid() ) { // ================ Sound path===================== mSoundPath = new EditBox(); listView->addChild(createListViewItem(SOUND_PATH_LABEL_TEXT, mSoundPath)); // ================ Vibrate ===================== mVibrate = new CheckBox(); listView->addChild(createListViewItem(VIBRATE_LABEL_TEXT, mVibrate)); mVibrateDuration = new EditBox(); mVibrateDuration->setInputMode(EDIT_BOX_INPUT_MODE_NUMERIC); listView->addChild(createListViewItem(VIBRATE_DURATION_LABEL_TEXT, mVibrateDuration)); // ================ Flashing LED ===================== mFlash = new CheckBox(); listView->addChild(createListViewItem(FLASH_LABEL_TEXT, mFlash)); // The pattern mFlashColor = new EditBox(); listView->addChild(createListViewItem(FLASH_COLOR_LABEL_TEXT, mFlashColor)); mFlashOnLength = new EditBox(); mFlashOnLength->setInputMode(EDIT_BOX_INPUT_MODE_NUMERIC); listView->addChild(createListViewItem(FLASH_ON_LABEL_TEXT, mFlashOnLength)); mFlashOffLength = new EditBox(); mFlashOffLength->setInputMode(EDIT_BOX_INPUT_MODE_NUMERIC); listView->addChild(createListViewItem(FLASH_OFF_LABEL_TEXT, mFlashOffLength)); } // ================ Fire time ===================== mTime = new EditBox(); mTime->setWidth(NUMERIC_EDIT_BOX_WIDTH); mTime->setInputMode(EDIT_BOX_INPUT_MODE_NUMERIC); listView->addChild(createListViewItem(FIRE_TIME_LABEL_TEXT, mTime)); // ================= Send image button ================ hLayout = new HorizontalLayout(); hLayout->fillSpaceHorizontally(); listItem = new ListViewItem(); listItem->addChild(hLayout); listView->addChild(listItem); mCreateNotificationButton = new ImageButton(); mCreateNotificationButton->setImage(RES_IMAGE); space = this->createSpacer(); hLayout->addChild(space); hLayout->addChild(mCreateNotificationButton); // Align the image button at the center of the layout. // Only after adding the image button widget to layout the widget's width // is available. int spacerWidth = hLayout->getWidth() / 2 - mCreateNotificationButton->getWidth() / 2; space->setWidth(spacerWidth); }