Ejemplo n.º 1
0
    void addCheckboxWidget(Layout* aTargetLayout)
    {
        VerticalLayout* betaWrapper = new VerticalLayout();
        betaWrapper->fillSpaceHorizontally();
        betaWrapper->wrapContentVertically();
        betaWrapper->setPaddingTop(int(mFontSize * 0.5));

        VerticalLayout* betaContainer = new VerticalLayout();
        betaContainer->fillSpaceHorizontally();
        betaContainer->wrapContentVertically();
        betaContainer->setBackgroundColor(AUX_COLOR);
        setRoundPadding(aTargetLayout);

        HorizontalLayout* subSettingsContainer = new HorizontalLayout();
        subSettingsContainer->fillSpaceHorizontally();
        subSettingsContainer->wrapContentVertically();
        subSettingsContainer->setChildVerticalAlignment(MAW_ALIGNMENT_CENTER);
        subSettingsContainer->setChildHorizontalAlignment(MAW_ALIGNMENT_RIGHT);

        Label* betaText = new Label();
        betaText->setText("This is a checkBox");
        betaText->setFontColor(LABEL_FONT_COLOR);
        betaText->setFontSize(mFontSize);
        betaText->fillSpaceHorizontally();
        betaText->wrapContentVertically();
        betaText->setTextHorizontalAlignment(MAW_ALIGNMENT_LEFT);

        CheckBox* betaCB = new CheckBox();
        betaCB->wrapContentHorizontally();
        betaCB->wrapContentVertically();
        betaCB->setState(true);

        subSettingsContainer->addChild(betaText);
        subSettingsContainer->addChild(betaCB);

        betaContainer->addChild(subSettingsContainer);

        betaWrapper->addChild(betaContainer);
        aTargetLayout->addChild(betaWrapper);
    }
Ejemplo n.º 2
0
/**
 * Creates and adds main layout to the screen.
 */
void WorkspaceLayout::createMainLayout() {

	// Create the main layout.
	HorizontalLayout *controlButtonsContainer = new HorizontalLayout();
	controlButtonsContainer->fillSpaceHorizontally();
	controlButtonsContainer->setHeight(mWidgetHeight);

	if(mOS == "iPhone OS")
	{

		mRefreshButton = new ImageButton();
		((ImageButton*)mRefreshButton)->addButtonListener(this);
		((ImageButton*)mRefreshButton)->setBackgroundImage(RELOAD_BG);
		mRefreshButton->setFontColor(0x000000);

		mDisconnectButton = new ImageButton();
		((ImageButton*)mDisconnectButton)->addButtonListener(this);
		((ImageButton*)mDisconnectButton)->setBackgroundImage(RELOAD_BG);
		mDisconnectButton->setFontColor(0x000000);

		mSaveButton = new ImageButton();
		((ImageButton*)mSaveButton)->addButtonListener(this);
		((ImageButton*)mSaveButton)->setBackgroundImage(RELOAD_BG);
		mSaveButton->setFontColor(0x000000);

		mReloadButton = new ImageButton();
		((ImageButton*)mReloadButton)->addButtonListener(this);
		((ImageButton*)mReloadButton)->setBackgroundImage(CONNECT_BG);
		mReloadButton->setFontColor(0x000000);
	}
	else
	{
		mRefreshButton = new Button();
		((Button*)mRefreshButton)->addButtonListener(this);

		mDisconnectButton = new Button();
		((Button*)mDisconnectButton)->addButtonListener(this);

		mSaveButton = new Button();
		((Button*)mSaveButton)->addButtonListener(this);

		mReloadButton = new Button();
		((Button*)mReloadButton)->addButtonListener(this);
	}

	mRefreshButton->setText(REFRESH_LIST_BUTTON_TEXT);
	mRefreshButton->setHeight(mWidgetHeight);
	mRefreshButton->fillSpaceHorizontally();

	mDisconnectButton->setText(DISCONNECT_BUTTON_TEXT);
	mDisconnectButton->setHeight(mWidgetHeight);
	mDisconnectButton->fillSpaceHorizontally();

	controlButtonsContainer->addChild(mDisconnectButton);
	controlButtonsContainer->addChild(mRefreshButton);

	// Create Project Control Buttons SAVE and RELOAD
	mSaveButton->setText(SAVE_BUTTON_TEXT);
	mSaveButton->setWidth((int)(mScreenWidth * mSaveButtonWidthRatio));

	mReloadButton->setText(RELOAD_BUTTON_TEXT);
	mReloadButton->setWidth((int)(mScreenWidth * mReloadButtonWidthRatio));

	mListView = new ListView();
	mListView->allowSelection(true);
	mListView->addListViewListener(this);
	if(mOS.find("iPhone") >= 0)
	{
		this->setBackgroundColor(0x000000);
		mListView->setProperty(MAW_WIDGET_BACKGROUND_COLOR,"00000000");
	}

	this->addChild(controlButtonsContainer);
	this->addChild(mListView);

	// Create the activity indicator widgets
	mActivityIndicatorContainer = new RelativeLayout();
	mActivityIndicatorContainer->fillSpaceHorizontally();
	mActivityIndicatorContainer->fillSpaceVertically();

	/**
	 * 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.
	 */
	//ActivityIndicator *loadingProjectsIndicator = new ActivityIndicator();
	//loadingProjectsIndicator->setSize(80,80);
	//loadingProjectsIndicator->setPosition((int)(mScreenWidth*0.5) - 40, (int)(mScreenHeight*0.5) - 80 );
	//mActivityIndicatorContainer->addChild(loadingProjectsIndicator);


}
Ejemplo n.º 3
0
void MainScreen::renderAlarm(AlarmMsg alarm, float ratio) {
	String s;

	HorizontalLayout *mainItemLayout = new HorizontalLayout();
	VerticalLayout *verticalTextLayout = new VerticalLayout();
	Label *lbDaysTo = new Label();
	Label *lbName = new Label();
	Label *lbsplitter = new Label();
	Label *lbMessage = new Label();

	s = "";
	String multi = "";
	int val = alarm.DaysTo;

	if (val > 99) {
		val /= 30;
		multi = Lang::getString(GS_LETTERMONTH);

		if (val > 24) {
			val /= 12;
			multi = Lang::getString(GS_LETTERYEAR);
		}
	}

	if (val == 0) {
		s += Lang::getString(GS_NOW);
	} else if (val == -1) {
		s += Lang::getString(GS_YESTERDAY);
	} else {
		s += Convert::toString(val);
		s += multi;
	}

	mainItemLayout->setChildVerticalAlignment(MAW_ALIGNMENT_CENTER);
	mainItemLayout->setBackgroundColor(Styler::getClBgMessage());
	mainItemLayout->fillSpaceHorizontally();
	mainItemLayout->wrapContentHorizontally();

	//DaysTo setup
	VerticalLayout* vlDaysTo = new VerticalLayout();
	vlDaysTo->fillSpaceHorizontally();
	vlDaysTo->wrapContentHorizontally();
	vlDaysTo->setBackgroundColor(Styler::getClBgDaysLeft());
	vlDaysTo->setChildVerticalAlignment(MAW_ALIGNMENT_CENTER);

	lbDaysTo->setText(s);

	int daysLeftFontSize = static_cast<int>(Styler::getSzFontDaysLeft()
			- ratio * (Styler::getSzFontDaysLeft() - Styler::getSzFontSize1()));
	if (val < 1) {
		daysLeftFontSize /= 2;
	}

	Styler::setLabelFont(lbDaysTo, Styler::fontnameDaysLeft, daysLeftFontSize);

	lbDaysTo->setFontSize(daysLeftFontSize);
	lbDaysTo->fillSpaceHorizontally();
	lbDaysTo->fillSpaceVertically();
	lbDaysTo->setWidth(Styler::getSzWidthDaysLeft());
	lbDaysTo->setFontColor(Styler::getClFcDaysLeft());
	lbDaysTo->setBackgroundColor(Styler::getClBgDaysLeft());
	lbDaysTo->setTextVerticalAlignment(MAW_ALIGNMENT_CENTER);
	lbDaysTo->setTextHorizontalAlignment(MAW_ALIGNMENT_CENTER);
	vlDaysTo->addChild(lbDaysTo);

	//name and message setup
	Styler::setLabelFont(lbName, Styler::fontnameEventName);
	lbName->setText(alarm.Name);
	lbName->setFontSize(Styler::getSzFontSize1());
	lbName->setFontColor(Styler::getClFcName());
	lbName->setTextHorizontalAlignment(MAW_ALIGNMENT_LEFT);
	lbMessage->setText(alarm.Message);
	lbMessage->setFontSize(Styler::szFontLittleMessage());
	lbMessage->setFontColor(Styler::getClFcMessage());
	lbMessage->setTextHorizontalAlignment(MAW_ALIGNMENT_LEFT);
	Label* lbAir = new Label();
	lbAir->setHeight(5);

	verticalTextLayout->addChild(lbName);
	verticalTextLayout->addChild(lbAir);
	verticalTextLayout->addChild(lbMessage);
	Styler::setLayoutPadding(verticalTextLayout, 3);
	verticalTextLayout->setPaddingLeft(Styler::getSzPadding() / 2);
	verticalTextLayout->setPaddingRight(Styler::getSzPadding() / 2);
	verticalTextLayout->wrapContentVertically();
	verticalTextLayout->fillSpaceHorizontally();

	mainItemLayout->addChild(vlDaysTo);
	mainItemLayout->addChild(lbsplitter);
	mainItemLayout->addChild(lbName);
	mainItemLayout->addChild(verticalTextLayout);
	mainItemLayout->wrapContentHorizontally();

	lvAlarms->addChild(mainItemLayout);
}
Ejemplo n.º 4
0
/**
 * 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);

}
Ejemplo n.º 5
0
/**
 * 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);
}