/** * 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); } }
/** * Create ListView item properties layout */ void SettingsScreen::createListViewItemPropertiesLayout() { VerticalLayout* listViewItemPropertiesVerticalLayout = new VerticalLayout(); listViewItemPropertiesVerticalLayout->wrapContentVertically(); mCurrentListViewItemLabel = new Label(); mCurrentListViewItemLabel->setText("No item selected"); mCurrentListViewItemLabel->setFontSize(TITLE_FONT_SIZE); mCurrentListViewItemLabel->setFontColor(0xFF0000); listViewItemPropertiesVerticalLayout->addChild(mCurrentListViewItemLabel); createListViewItemTextLayout(listViewItemPropertiesVerticalLayout); createListViewItemFontColorLayout(listViewItemPropertiesVerticalLayout); createListViewItemFontSizeLayout(listViewItemPropertiesVerticalLayout); if (isIOS()) { listViewItemPropertiesVerticalLayout->wrapContentVertically(); createListViewItemEditModeLayout(listViewItemPropertiesVerticalLayout); createListViewItemDeleteButtonTextLayout(listViewItemPropertiesVerticalLayout); createListViewItemSelectedAnimationLayout(listViewItemPropertiesVerticalLayout); createListViewItemUnselectedAnimationLayout(listViewItemPropertiesVerticalLayout); createListViewItemHighlightedAnimationLayout(listViewItemPropertiesVerticalLayout); createListViewItemUnhighlightedAnimationLayout(listViewItemPropertiesVerticalLayout); createListViewItemAccessoryTypeIntLayout(listViewItemPropertiesVerticalLayout); createListViewItemAccessoryTypeEditModeLayout(listViewItemPropertiesVerticalLayout); createListViewItemEditStyleLayout(listViewItemPropertiesVerticalLayout); } ListViewItem* mListItemProperties = new ListViewItem(); mListItemProperties->setSelectionStyle(LIST_VIEW_ITEM_SELECTION_STYLE_NONE); mListItemProperties->addChild(listViewItemPropertiesVerticalLayout); mPropertiesListView->addChild(mListItemProperties); }
/** * Create ListView section properties layout */ void SettingsScreen::createListViewSectionPropertiesLayout() { VerticalLayout* listViewSectionPropertiesVerticalLayout = new VerticalLayout(); listViewSectionPropertiesVerticalLayout->wrapContentVertically(); mListViewSectionLabel = new Label(); mListViewSectionLabel->setText("No section in focus"); mListViewSectionLabel->setFontSize(TITLE_FONT_SIZE); mListViewSectionLabel->setFontColor(0xFF0000); listViewSectionPropertiesVerticalLayout->addChild(mListViewSectionLabel); // create the current section title layout HorizontalLayout* currentSectionTitleLayout = new HorizontalLayout(); currentSectionTitleLayout->wrapContentVertically(); mSetListViewSectionTitleButton = new Button(); mSetListViewSectionTitleButton->setText("Set title"); mSetListViewSectionTitleButton->fillSpaceHorizontally(); currentSectionTitleLayout->addChild(mSetListViewSectionTitleButton); mCurrentListViewSectionTitleEditBox = new EditBox(); mCurrentListViewSectionTitleEditBox->fillSpaceHorizontally(); currentSectionTitleLayout->addChild(mCurrentListViewSectionTitleEditBox); listViewSectionPropertiesVerticalLayout->addChild(currentSectionTitleLayout); // create the current section header text layout HorizontalLayout* currentSectionHeaderTextLayout = new HorizontalLayout(); currentSectionHeaderTextLayout->wrapContentVertically(); mSetListViewSectionHeaderButton = new Button(); mSetListViewSectionHeaderButton->setText("Set header"); mSetListViewSectionHeaderButton->fillSpaceHorizontally(); currentSectionHeaderTextLayout->addChild(mSetListViewSectionHeaderButton); mCurrentListViewSectionHeaderEditBox = new EditBox(); mCurrentListViewSectionHeaderEditBox->fillSpaceHorizontally(); currentSectionHeaderTextLayout->addChild(mCurrentListViewSectionHeaderEditBox); listViewSectionPropertiesVerticalLayout->addChild(currentSectionHeaderTextLayout); // create the current section footer text layout HorizontalLayout* currentSectionFooterTextLayout = new HorizontalLayout(); currentSectionFooterTextLayout->wrapContentVertically(); mSetListViewSectionFooterButton = new Button(); mSetListViewSectionFooterButton->setText("Set footer"); mSetListViewSectionFooterButton->fillSpaceHorizontally(); currentSectionFooterTextLayout->addChild(mSetListViewSectionFooterButton); mCurrentListViewSectionFooterEditBox = new EditBox(); mCurrentListViewSectionFooterEditBox->fillSpaceHorizontally(); currentSectionFooterTextLayout->addChild(mCurrentListViewSectionFooterEditBox); listViewSectionPropertiesVerticalLayout->addChild(currentSectionFooterTextLayout); if (isWindowsPhone() || isAndroid()) { listViewSectionPropertiesVerticalLayout->wrapContentVertically(); createListViewSectionHeaderPropertiesLayout(listViewSectionPropertiesVerticalLayout); createListViewSectionFooterPropertiesLayout(listViewSectionPropertiesVerticalLayout); } ListViewItem* mListSectionPropertiesItem = new ListViewItem(); mListSectionPropertiesItem->setSelectionStyle(LIST_VIEW_ITEM_SELECTION_STYLE_NONE); mListSectionPropertiesItem->addChild(listViewSectionPropertiesVerticalLayout); mPropertiesListView->addChild(mListSectionPropertiesItem); }
/** * Creates and adds main layout to the screen. */ void SettingsScreen::createMainLayout() { // Create and add the main layout to the screen. VerticalLayout* mainLayout = new VerticalLayout(); Screen::setMainWidget(mainLayout); ListView* listView = new ListView(); mainLayout->addChild(listView); // Add set duration option row. this->addSetDurationRow(listView); // Add get duration option row. this->addGetDurationRow(listView); // Add options for setting and getting the video quality value. this->addVideoQualityRows(listView); if ( isIOS()) { // Add options for setting and getting the flash mode value. this->addFlashModeRows(listView); // Add option for setting the camera roll flag. this->addCameraRollFlagRow(listView); // Add option for setting the camera controls flag. this->addCameraControlsFlagRow(listView); } // Add take picture button. mTakePictureBtn = new Button(); mTakePictureBtn->setText(TAKE_PICTURE_BTN_TEXT); this->addButtonToListView(mTakePictureBtn, listView); if (isAndroid()) { mTakenPicturePath = new Label(); ListViewItem* listItem = new ListViewItem(); listItem->addChild(mTakenPicturePath); listView->addChild(listItem); } // Add record video button. mRecordVideoBtn = new Button(); mRecordVideoBtn->setText(RECORD_VIDEO_BTN_TEXT); this->addButtonToListView(mRecordVideoBtn, listView); // Add show image button. mShowImageScreen = new Button(); mShowImageScreen->setText(SHOW_IMAGE_SCREEN_TEXT); this->addButtonToListView(mShowImageScreen, listView); // Add show video screen button. mShowVideoScreen = new Button(); mShowVideoScreen->setText(SHOW_VIDEO_SCREEN_TEXT); this->addButtonToListView(mShowVideoScreen, listView); }
/** * Adds two list rows for setting and getting the flash mode value. */ void SettingsScreen::addFlashModeRows(ListView* listView) { // Add set option for flash mode value. ListViewItem* listItem = new ListViewItem(); listView->addChild(listItem); mSetFlashModeBtn = new Button(); mSetFlashModeBtn->setText(SET_FLASH_MODE_BTN_TEXT); listItem->addChild(mSetFlashModeBtn); // Add get option for flash mode value. listItem = new ListViewItem(); listView->addChild(listItem); mGetFlashModeBtn = new Button(); mGetFlashModeBtn->setText(GET_FLASH_MODE_BTN_TEXT); mFlashModeLabel = new Label(); mFlashModeLabel->fillSpaceHorizontally(); listItem->addChild(this->createRow(mGetFlashModeBtn, mFlashModeLabel)); }
/** * Create ListView properties layout */ void SettingsScreen::createListViewPropertiesLayout() { VerticalLayout* listViewPropertiesVerticalLayout = new VerticalLayout(); listViewPropertiesVerticalLayout->wrapContentVertically(); Label* mListViewPropertiesLabel = new Label(); mListViewPropertiesLabel->setText("ListView properties"); mListViewPropertiesLabel->setFontSize(TITLE_FONT_SIZE); mListViewPropertiesLabel->setFontColor(0xFF0000); listViewPropertiesVerticalLayout->addChild(mListViewPropertiesLabel); // create the allow selection layout HorizontalLayout* allowSelectionLayout = new HorizontalLayout(); allowSelectionLayout->wrapContentVertically(); mListViewAllowSelectionCheckbox = new CheckBox(); mListViewAllowSelectionCheckbox->setState(true); Label* allowSelectionLabel = new Label(); allowSelectionLabel->setText("Allow selection"); allowSelectionLayout->addChild(mListViewAllowSelectionCheckbox); allowSelectionLayout->addChild(allowSelectionLabel); listViewPropertiesVerticalLayout->addChild(allowSelectionLayout); if (isIOS()) { listViewPropertiesVerticalLayout->wrapContentVertically(); // create the mode selection layout HorizontalLayout* modeSelectionLayout = new HorizontalLayout(); modeSelectionLayout->wrapContentVertically(); Label* setModeLabel = new Label(); setModeLabel->setText("Set mode: "); modeSelectionLayout->addChild(setModeLabel); mDisplayCheckBox = new CheckBox(); mDisplayCheckBox->setState(true); listViewPropertiesVerticalLayout->addChild(modeSelectionLayout); modeSelectionLayout = new HorizontalLayout(); Label* setDisplayLabel = new Label(); setDisplayLabel->setText("Display"); modeSelectionLayout->addChild(mDisplayCheckBox); modeSelectionLayout->addChild(setDisplayLabel); mEditCheckBox = new CheckBox(); mEditCheckBox->setState(false); Label* setEditLabel = new Label(); setEditLabel->setText("Edit"); modeSelectionLayout->addChild(mEditCheckBox); modeSelectionLayout->addChild(setEditLabel); listViewPropertiesVerticalLayout->addChild(modeSelectionLayout); createListViewItemSelectionStyleLayout(listViewPropertiesVerticalLayout); } ListViewItem* mListPropertiesItem = new ListViewItem(); mListPropertiesItem->setSelectionStyle(LIST_VIEW_ITEM_SELECTION_STYLE_NONE); mListPropertiesItem->addChild(listViewPropertiesVerticalLayout); mPropertiesListView->addChild(mListPropertiesItem); }
/** * Adds two list rows for setting and getting the video quality value. */ void SettingsScreen::addVideoQualityRows(ListView* listView) { ListViewItem* listItem; // Add set option for video quality value. listItem = new ListViewItem(); listView->addChild(listItem); mSetVideoQualityBtn = new Button(); mSetVideoQualityBtn->setText(SET_VIDEO_QUALITY_BTN_TEXT); listItem->addChild(mSetVideoQualityBtn); // Add get option for video quality value. listItem = new ListViewItem(); listView->addChild(listItem); mGetVideoQualityBtn = new Button(); mGetVideoQualityBtn->setText(GET_VIDEO_QUALITY_BTN_TEXT); mVideoQualityLabel = new Label(); mVideoQualityLabel->setText(VIDEO_QUALITY_LABEL_TEXT); mVideoQualityLabel->fillSpaceHorizontally(); listItem->addChild(this->createRow(mGetVideoQualityBtn, mVideoQualityLabel)); }
/** * Adds a list row that contains widgets for getting the current * maximum video duration. */ void SettingsScreen::addGetDurationRow(ListView* listView) { ListViewItem* listItem = new ListViewItem(); listView->addChild(listItem); mMaxDurationLabel = new Label(); mMaxDurationLabel->setText(MAX_DURATION_LABEL_TEXT); // mMaxDurationLabel->setFontColor(0x123456); mMaxDurationLabel->fillSpaceHorizontally(); mGetMaxDurationBtn = new Button(); mGetMaxDurationBtn->setText(MAX_DURATION_BTN_TEXT); listItem->addChild(this->createRow(mGetMaxDurationBtn, mMaxDurationLabel)); }
/** * Adds a list row that contains widgets for setting the current * maximum video duration. */ void SettingsScreen::addSetDurationRow(ListView* listView) { ListViewItem* listItem; Label* label; listItem = new ListViewItem(); listView->addChild(listItem); mMaxDurationEditBox = new EditBox(); mMaxDurationEditBox->setInputMode(EDIT_BOX_INPUT_MODE_NUMERIC); mMaxDurationEditBox->fillSpaceHorizontally(); label = new Label(); label->setText(VIDEO_MAX_DURATION_TEXT); listItem->addChild(this->createRow(label, mMaxDurationEditBox)); }
/** * Adds a list row for setting the camera controls flag. */ void SettingsScreen::addCameraControlsFlagRow(ListView* listView) { ListViewItem* listItem; Label* label; listItem = new ListViewItem(); listView->addChild(listItem); label = new Label(); label->setText(CAMERA_CONTROLS_LABEL_TEXT); mCameraControlsCheckBox = new CheckBox(); mCameraControlsCheckBox->setState(true); listItem->addChild(this->createRow(label, mCameraControlsCheckBox)); listView->addChild(label); }
/** * Helper function to create list view item with * specific label and edit/check box. */ ListViewItem* CreateNotificationScreen::createListViewItem(const MAUtil::String& labelText, Widget* widget)//EditBox* editBox) { ListViewItem* listItem; HorizontalLayout* hLayout; Widget* space; Label* label; hLayout = new HorizontalLayout(); label = new Label(); label->setText(labelText); hLayout->addChild(label); space = this->createSpacer(); hLayout->addChild(space); widget->fillSpaceHorizontally(); hLayout->addChild(widget); listItem = new ListViewItem(); listItem->addChild(hLayout); return listItem; }
/** * Add a button to a list view. * @param button The button that will be added. * @param listView The list view that will contain the button. */ void SettingsScreen::addButtonToListView(Button* button, ListView* listView) { ListViewItem* listItem = new ListViewItem(); listItem->addChild(button); listView->addChild(listItem); }
/** * If there is no list populates the List View Widget with the project data * from mProjects vector. Else destroys and deallocates previous list items * and creates new ones. */ void WorkspaceLayout::updateProjectList(MAUtil::Vector <reloadProject> * projects) { // Remove The ListView and add An Activity Indicator lprintfln("Updating Project List"); mListView->setVisible(false); /** * FIXME Removing listView and adding Activity indicator causes * the list view not getting events until some point, * when removing activity indicator to add the list again. */ //this->removeChild(mListView); //this->addChild(mActivityIndicatorContainer); // If there was a project Selected before update remove the // control buttons if(mSelectedProject != -1) { Widget *h = mListView->getChild(mSelectedProject)->getChild(0); h->removeChild(h->getChild(1)); h->removeChild(h->getChild(1)); } // ReInitialize selected project mSelectedProject = -1; mSelectedProjectName = ""; // Delete all the widgets from the ListView int prProjects = mListView->countChildWidgets(); if(prProjects != 0) { for(int i = 0; i < prProjects; i++) { Widget *listItemWidget = mListView->getChild(0); // list Item Widget Widget *hLayout = listItemWidget->getChild(0); // horizontal layout widget for( int j = 0; j < hLayout->countChildWidgets(); j++) { Widget * w = hLayout->getChild(0); hLayout->removeChild(w); delete w; } listItemWidget->removeChild(hLayout); delete hLayout; mListView->removeChild(listItemWidget); delete listItemWidget; } } // Re-populate the ListView with projects for (MAUtil::Vector <reloadProject>::iterator i = projects->begin(); i != projects->end(); i++) { // New List Itemprojects ListViewItem* item = new ListViewItem(); item->setHeight(mWidgetHeight); item->fillSpaceHorizontally(); // New Horizontal Layout HorizontalLayout *itemHorizontalLayout = new HorizontalLayout(); itemHorizontalLayout->fillSpaceHorizontally(); itemHorizontalLayout->setHeight(mWidgetHeight); // New Label Label* projectNameLabel = new Label(); projectNameLabel->setTextHorizontalAlignment(MAW_ALIGNMENT_LEFT); projectNameLabel->setTextVerticalAlignment(MAW_ALIGNMENT_CENTER); projectNameLabel->setText(i->name); projectNameLabel->fillSpaceHorizontally(); projectNameLabel->fillSpaceVertically(); if (mOS.find("iPhone") >= 0) { itemHorizontalLayout->setWidth(item->getWidth()); projectNameLabel->setFontColor(0xffffff); } itemHorizontalLayout->addChild(projectNameLabel); item->addChild(itemHorizontalLayout); mListView->addChild(item); } mListView->setVisible(true); // Remove Indicator and Add Project ListView //this->addChild(mListView); //this->removeChild(mActivityIndicatorContainer); }
/** * 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); }