예제 #1
0
/**
 * Creates and adds main layout to the screen.
 */
void ListScreen::createMainLayout() {
	// Create and add the main layout to the screen.
	mMainLayout = new VerticalLayout();
	Screen::setMainWidget(mMainLayout);

	mListView = new ListView(LIST_VIEW_TYPE_SEGMENTED);

	// the list view doesn't automatically sort its elements - the
	// developer has to handle the sorting
	for (int i = 0; i <= 5; i++)
	{
		ListViewSection* section = new ListViewSection(LIST_VIEW_SECTION_TYPE_SEGMENTED);
		MAUtil::String sectionTitle = "Header ";
		sectionTitle += MAUtil::integerToString(i);
		section->setTitle("H" + MAUtil::integerToString(i));
		section->setHeaderText(sectionTitle);
		section->setFooterText("Footer " + MAUtil::integerToString(i));

		mListView->addChild(section);
		for (int j = 0; j <= 6; j++)
		{
			ListViewItem* item = new ListViewItem();
			MAUtil::String itemText = "Item ";
			itemText += MAUtil::integerToString(j);
			item->setText(itemText);
			item->setSubtitle("subtitle " + MAUtil::integerToString(j));
			item->fillSpaceHorizontally();
			section->addItem(item);
		}

	}

	int result = mMainLayout->addChild(mListView);
    printf("add mListView result = %d", result);

    createListManipulationLayout();

    if (isIOS() || isAndroid())
    {
		mReloadData = new Button();
		mReloadData->setText("Reload data");
		mReloadData->fillSpaceHorizontally();
		mMainLayout->addChild(mReloadData);
    }
}
/**
 * Creates the input flag list view
 * @param mainLayout Widgets will be added to it.
 */
void EditBoxSettingsLayout::createInputFlagListView(ListView* aListView)
{
	mInputFlagListView = new ListView();
	mInputFlagListView->setHeight(PROPERTY_LINE_HEIGHT * 4);
	mInputFlagListView->setBackgroundColor(0xFFFFFF);

	for(int i = 0; i < INPUT_FLAGS_COUNT; i++)
	{
		ListViewItem* inputFlagItem = new ListViewItem();
		inputFlagItem->setText(inputFlags[i]);
		inputFlagItem->setBackgroundColor(0xFFFFFF);
		inputFlagItem->setFontColor(0x000000);
		inputFlagItem->fillSpaceHorizontally();
		mInputFlagListView->addChild(inputFlagItem);
	}

	mInputFlagListView->fillSpaceHorizontally();
	aListView->addChild(mInputFlagListView);
}
예제 #3
0
/**
 * Creates the input flag list view
 * @param mainLayout Widgets will be added to it.
 */
void MainScreen::createInputFlagListView(VerticalLayout* aVerticalLayout)
{
	mInputFlagListView = new ListView();
	mInputFlagListView->setHeight(mScreenHeight/3);
	mInputFlagListView->setBackgroundColor(0xFFFFFF);

	for(int i = 0; i < INPUT_FLAGS_COUNT; i++)
	{
		ListViewItem* inputFlagItem = new ListViewItem();
		inputFlagItem->setText(inputFlags[i]);
		inputFlagItem->setBackgroundColor(0xFFFFFF);
		inputFlagItem->setFontColor(0x000000);
		inputFlagItem->fillSpaceHorizontally();
		mInputFlagListView->addChild(inputFlagItem);
	}

	mInputFlagListView->fillSpaceHorizontally();
	aVerticalLayout->addChild(mInputFlagListView);
}
예제 #4
0
/**
 * Adds the server ip into the list view
 */
void ServersDialog::addServerToList(MAUtil::String serverIP)
{
	// check if already exists
	bool exists = false;
	int totalItems = mListView->countChildWidgets();

	for (int i = 0; i < totalItems; i++)
	{
		if (mListView->getChild(i)->getPropertyString("text") == serverIP)
		{
			exists = true;
		}
	}

	if(!exists)
	{
		ListViewItem * item = new ListViewItem();
		item->fillSpaceHorizontally();
		item->setHeight(80);
		item->setText(serverIP);

		mListView->addChild(item);
	}
}
예제 #5
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);

}