当前位置: 首页>>代码示例>>C++>>正文


C++ DropDownList::push_back方法代码示例

本文整理汇总了C++中DropDownList::push_back方法的典型用法代码示例。如果您正苦于以下问题:C++ DropDownList::push_back方法的具体用法?C++ DropDownList::push_back怎么用?C++ DropDownList::push_back使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DropDownList的用法示例。


在下文中一共展示了DropDownList::push_back方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: ShowDateDropDown

	/**
	 * Helper function to construct the dropdown.
	 * @param widget the dropdown widget to create the dropdown for
	 */
	void ShowDateDropDown(int widget)
	{
		int selected;
		DropDownList *list = new DropDownList();

		switch (widget) {
			default: NOT_REACHED();

			case WID_SD_DAY:
				for (uint i = 0; i < 31; i++) {
					list->push_back(new DropDownListStringItem(STR_ORDINAL_NUMBER_1ST + i, i + 1, false));
				}
				selected = this->date.day;
				break;

			case WID_SD_MONTH:
				for (uint i = 0; i < 12; i++) {
					list->push_back(new DropDownListStringItem(STR_MONTH_JAN + i, i, false));
				}
				selected = this->date.month;
				break;

			case WID_SD_YEAR:
				for (Year i = this->min_year; i <= this->max_year; i++) {
					DropDownListParamStringItem *item = new DropDownListParamStringItem(STR_JUST_INT, i, false);
					item->SetParam(0, i);
					list->push_back(item);
				}
				selected = this->date.year;
				break;
		}

		ShowDropDownList(this, list, selected, widget);
	}
开发者ID:Ayutac,项目名称:OpenTTD,代码行数:38,代码来源:date_gui.cpp

示例2: ShowGroupActionDropdown

/**
 * Update/redraw the group action dropdown
 * @param w   the window the dropdown belongs to
 * @param gid the currently selected group in the window
 */
static void ShowGroupActionDropdown(Window *w, GroupID gid)
{
	DropDownList *list = new DropDownList();

	list->push_back(new DropDownListStringItem(STR_VEHICLE_LIST_REPLACE_VEHICLES,    GALF_REPLACE, false));
	list->push_back(new DropDownListStringItem(STR_VEHICLE_LIST_SEND_FOR_SERVICING,  GALF_SERVICE, false));
	list->push_back(new DropDownListStringItem(STR_VEHICLE_LIST_SEND_TRAIN_TO_DEPOT, GALF_DEPOT,   false));

	if (Group::IsValidID(gid)) {
		list->push_back(new DropDownListStringItem(STR_GROUP_ADD_SHARED_VEHICLE,  GALF_ADD_SHARED, false));
		list->push_back(new DropDownListStringItem(STR_GROUP_REMOVE_ALL_VEHICLES, GALF_REMOVE_ALL, false));
	}

	ShowDropDownList(w, list, 0, GRP_WIDGET_MANAGE_VEHICLES_DROPDOWN);
}
开发者ID:Voxar,项目名称:OpenTTD,代码行数:20,代码来源:group_gui.cpp

示例3: DropDownList

	/** Build a dropdown list of available airport classes */
	static DropDownList *BuildAirportClassDropDown()
	{
		DropDownList *list = new DropDownList();

		for (uint i = 0; i < AirportClass::GetCount(); i++) {
			list->push_back(new DropDownListStringItem(AirportClass::GetName((AirportClassID)i), i, false));
		}

		return list;
	}
开发者ID:a7omic,项目名称:OpenTTD,代码行数:11,代码来源:airport_gui.cpp

示例4: ShowDropDownMenu

/**
 * Show a dropdown menu window near a widget of the parent window.
 * The result code of the items is their index in the #strings list.
 * @param w             Parent window that wants the dropdown menu.
 * @param strings       Menu list, end with #INVALID_STRING_ID
 * @param selected      Index of initial selected item.
 * @param button        Button widget number of the parent window #w that wants the dropdown menu.
 * @param disabled_mask Bitmask for diabled items (items with their bit set are not copied to the dropdown list).
 * @param hidden_mask   Bitmask for hidden items (items with their bit set are displayed, but not selectable in the dropdown list).
 * @param width         Width of the dropdown menu. If \c 0, use the width of parent widget #button.
 */
void ShowDropDownMenu(Window *w, const StringID *strings, int selected, int button, uint32 disabled_mask, uint32 hidden_mask, uint width)
{
	DropDownList *list = new DropDownList();

	for (uint i = 0; strings[i] != INVALID_STRING_ID; i++) {
		if (!HasBit(hidden_mask, i)) {
			list->push_back(new DropDownListStringItem(strings[i], i, HasBit(disabled_mask, i)));
		}
	}

	/* No entries in the list? */
	if (list->size() == 0) {
		DeleteDropDownList(list);
		return;
	}

	ShowDropDownList(w, list, selected, button, width);
}
开发者ID:,项目名称:,代码行数:29,代码来源:

示例5: OnClick

	virtual void OnClick(Point pt, int widget, int click_count)
	{
		switch (widget) {
			case SNGRFS_PRESET_LIST: {
				DropDownList *list = new DropDownList();

				/* Add 'None' option for clearing list */
				list->push_back(new DropDownListStringItem(STR_NONE, -1, false));

				for (uint i = 0; i < _grf_preset_list.Length(); i++) {
					if (_grf_preset_list[i] != NULL) {
						list->push_back(new DropDownListPresetItem(i));
					}
				}

				ShowDropDownList(this, list, this->preset, SNGRFS_PRESET_LIST);
				break;
			}

			case SNGRFS_PRESET_SAVE:
				this->query_widget = widget;
				ShowQueryString(STR_EMPTY, STR_NEWGRF_SETTINGS_PRESET_SAVE_QUERY, 32, 100, this, CS_ALPHANUMERAL, QSF_NONE);
				break;

			case SNGRFS_PRESET_DELETE:
				if (this->preset == -1) return;

				DeleteGRFPresetFromConfig(_grf_preset_list[this->preset]);
				GetGRFPresetList(&_grf_preset_list);
				this->preset = -1;
				this->InvalidateData();
				break;

			case SNGRFS_ADD: // Add GRF
				DeleteWindowByClass(WC_SAVELOAD);
				new NewGRFAddWindow(&_newgrf_add_dlg_desc, this, &this->list);
				break;

			case SNGRFS_REMOVE: { // Remove GRF
				GRFConfig **pc, *c, *newsel;

				/* Choose the next GRF file to be the selected file */
				newsel = this->sel->next;

				for (pc = &this->list; (c = *pc) != NULL; pc = &c->next) {
					/* If the new selection is empty (i.e. we're deleting the last item
					 * in the list, pick the file just before the selected file */
					if (newsel == NULL && c->next == this->sel) newsel = c;

					if (c == this->sel) {
						*pc = c->next;
						free(c);
						break;
					}
				}

				this->sel = newsel;
				this->preset = -1;
				this->InvalidateData(3);
				this->DeleteChildWindows(WC_QUERY_STRING); // Remove the parameter query window
				break;
			}

			case SNGRFS_MOVE_UP: { // Move GRF up
				GRFConfig **pc, *c;
				if (this->sel == NULL) break;

				int pos = 0;
				for (pc = &this->list; (c = *pc) != NULL; pc = &c->next, pos++) {
					if (c->next == this->sel) {
						c->next = this->sel->next;
						this->sel->next = c;
						*pc = this->sel;
						break;
					}
				}
				this->vscroll.ScrollTowards(pos);
				this->preset = -1;
				this->InvalidateData();
				break;
			}

			case SNGRFS_MOVE_DOWN: { // Move GRF down
				GRFConfig **pc, *c;
				if (this->sel == NULL) break;

				int pos = 1; // Start at 1 as we swap the selected newgrf with the next one
				for (pc = &this->list; (c = *pc) != NULL; pc = &c->next, pos++) {
					if (c == this->sel) {
						*pc = c->next;
						c->next = c->next->next;
						(*pc)->next = c;
						break;
					}
				}
				this->vscroll.ScrollTowards(pos);
				this->preset = -1;
				this->InvalidateData();
				break;
			}
//.........这里部分代码省略.........
开发者ID:andrew889,项目名称:OpenTTD,代码行数:101,代码来源:newgrf_gui.cpp


注:本文中的DropDownList::push_back方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。