Esempio n. 1
0
	void ListView::notifyListenersDeleteButtonClicked(
		const MAWidgetEventData& widgetEventData)
	{
		const int itemIndex = widgetEventData.listItemIndex;
		const int sectionIndex = widgetEventData.listSectionIndex;
		ListViewSection* section = NULL;
		ListViewItem* item = NULL;
		const int countListeners = mListViewListeners.size();
		bool isDefaultList = sectionIndex == MAW_RES_INVALID_INDEX;

		if (!isDefaultList)
		{
			section = (ListViewSection*) getChild(sectionIndex);
			item = (ListViewItem*) section->getChild(itemIndex);
		}
		else
		{
			item = (ListViewItem*) getChild(itemIndex);
		}

		for (int i = 0; i < countListeners; i++)
		{
			// deprecated
			mListViewListeners[i]->segmentedListViewItemDelete(
				this,
				section,
				item);

			// new method
			mListViewListeners[i]->listViewItemDelete(
				this,
				section,
				item);
		}
	}
Esempio n. 2
0
/**
 * Show currently used selection style for an list view item.
 * Works on iOS platform.
 */
void SettingsScreen::showSelectionStyleMessageBox()
{
	MAUtil::String textToShow;
	if (mListView->countChildWidgets() == 0)
	{
		textToShow = "The list view section does not have sections.";
	}
	else
	{
		ListViewSection* section = (ListViewSection*) mListView->getChild(0);
		if (section->countChildWidgets() == 0)
		{
			textToShow = "The list view section does not have items.";
		}
		else
		{
			ListViewItem* item = (ListViewItem*) section->getChild(0);
			ListViewItemSelectionStyle selectionStyle =
				item->getSelectionStyle();
			textToShow = "The selection style is: " +
				getSelectionStyleString(selectionStyle);
		}
	}
	maAlert("ListViewItem selection style", textToShow.c_str(), "OK", NULL, NULL);
}
Esempio n. 3
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);
    }
}
Esempio n. 4
0
	void ListView::notifyListenersItemClicked(
		const MAWidgetEventData& widgetEventData)
	{
		int itemIndex = widgetEventData.listItemIndex;
		int sectionIndex = widgetEventData.listSectionIndex;
		ListViewSection* section = NULL;
		ListViewItem* item = NULL;
		const int countListeners = mListViewListeners.size();
		bool isDefaultList = sectionIndex == MAW_RES_INVALID_INDEX;

		if (isDefaultList)
		{
			// Default list view. Does not contain sections.
			item = (ListViewItem*)getChild(itemIndex);
		}
		else
		{
			// Alphabetical or segmented list view.
			section = (ListViewSection*)getChild(sectionIndex);
			item = (ListViewItem*)section->getChild(itemIndex);
		}

		for (int i = 0; i < countListeners; i++)
		{
			// deprecated methods.
			mListViewListeners[i]->listViewItemClicked(
				this,
				item);
			mListViewListeners[i]->listViewItemClicked(
				this,
				itemIndex);

			// new methods.
			mListViewListeners[i]->listViewItemClicked(
				this,
				sectionIndex,
				itemIndex);
			mListViewListeners[i]->listViewItemClicked(
				this,
				section,
				item);
		}
	}
Esempio n. 5
0
/**
 * Change all the list view's items selection style to a given value.
 * @param style Style to set.
 */
void SettingsScreen::changeSelectionStyle(ListViewItemSelectionStyle style)
{
	int sectionIndex = 0;
	int countSections = mListView->countChildWidgets();

	while (sectionIndex < countSections)
	{
		ListViewSection* section = (ListViewSection*) mListView->getChild(sectionIndex);
		int itemIndex = 0;
		int countItems = section->countChildWidgets();

		while (itemIndex < countItems)
		{
			ListViewItem* item = (ListViewItem*) section->getChild(itemIndex);
			item->setSelectionStyle(style);

			itemIndex++;
		}

		sectionIndex++;
	}
}
Esempio n. 6
0
	/**
	 * Notify listeners when receiving #MAW_EVENT_SEGMENTED_LIST_ITEM_CLICKED.
	 * @deprecated
	 * @param widgetEventData Event's data.
	 */
	void ListView::notifyListenersSectionItemClicked(
		const MAWidgetEventData& widgetEventData)
	{
		int itemIndex = widgetEventData.sectionItemIndex;
		int sectionIndex = widgetEventData.sectionIndex;
		ListViewSection* section = NULL;
		ListViewItem* item = NULL;
		const int countListeners = mListViewListeners.size();
		section = (ListViewSection*)getChild(sectionIndex);
		item = (ListViewItem*)section->getChild(itemIndex);

		for (int i = 0; i < countListeners; i++)
		{
			mListViewListeners[i]->segmentedListViewItemClicked(
				this,
				sectionIndex,
				itemIndex);
			mListViewListeners[i]->segmentedListViewItemClicked(
				this,
				section,
				item);
		}
	}
Esempio n. 7
0
/**
 * This method is called if the touch-up event was inside the
 * bounds of the button.
 * Platform: iOS, Android and Windows Phone 7.
 * @param button The button object that generated the event.
 */
void ListScreen::buttonClicked(Widget* button)
{
	if (button == mReloadData)
	{
		mListView->reloadData();
	}
	else if (button == mRemoveFirstSection)
	{
		if (mListView->countChildWidgets() > 0)
		{
			mListView->removeChild(mListView->getChild(0));
		}
	}
	else if (button == mRemoveItem)
	{
		if (mListView->countChildWidgets() > 0)
		{
			ListViewSection* firstSection = (ListViewSection*)mListView->getChild(0);
			if (firstSection->countChildWidgets() > 0)
			{
				firstSection->removeItem(0);
			}
		}
	}
	else if (button == mAddItem)
	{
		if (mListView->countChildWidgets() > 0)
		{
			ListViewSection* firstSection = (ListViewSection*)mListView->getChild(0);
			ListViewItem* newItem = new ListViewItem();
			newItem->setText("testItem");
			newItem->setSubtitle("subtitle");
			firstSection->insertItem(newItem, 0);
		}
	}
}