Changeset - r13944:3617e6825e88
[Not reviewed]
master
0 3 0
alberth - 14 years ago 2009-12-13 20:54:52
alberth@openttd.org
(svn r18490) -Doc: Fixed syntax of a few doxygen pre and post coditions.
3 files changed with 6 insertions and 6 deletions:
0 comments (0 inline, 0 general)
src/graph_gui.cpp
Show inline comments
 
@@ -86,49 +86,49 @@ struct GraphLegendWindow : Window {
 

	
 
		ToggleBit(_legend_excluded_companies, widget - GLW_FIRST_COMPANY);
 
		this->ToggleWidgetLoweredState(widget);
 
		this->SetDirty();
 
		SetWindowDirty(WC_INCOME_GRAPH, 0);
 
		SetWindowDirty(WC_OPERATING_PROFIT, 0);
 
		SetWindowDirty(WC_DELIVERED_CARGO, 0);
 
		SetWindowDirty(WC_PERFORMANCE_HISTORY, 0);
 
		SetWindowDirty(WC_COMPANY_VALUE, 0);
 
	}
 

	
 
	virtual void OnInvalidateData(int data)
 
	{
 
		if (Company::IsValidID(data)) return;
 

	
 
		SetBit(_legend_excluded_companies, data);
 
		this->RaiseWidget(data + GLW_FIRST_COMPANY);
 
	}
 
};
 

	
 
/**
 
 * Construct a vertical list of buttons, one for each company.
 
 * @param biggest_index Storage for collecting the biggest index used in the returned tree.
 
 * @return Panel with company buttons.
 
 * @postcond \c *biggest_index contains the largest used index in the tree.
 
 * @post \c *biggest_index contains the largest used index in the tree.
 
 */
 
static NWidgetBase *MakeNWidgetCompanyLines(int *biggest_index)
 
{
 
	NWidgetVertical *vert = new NWidgetVertical();
 

	
 
	for (int widnum = GLW_FIRST_COMPANY; widnum <= GLW_LAST_COMPANY; widnum++) {
 
		NWidgetBackground *panel = new NWidgetBackground(WWT_PANEL, COLOUR_GREY, widnum);
 
		panel->SetMinimalSize(246, FONT_HEIGHT_NORMAL + WD_FRAMERECT_TOP + WD_FRAMERECT_BOTTOM);
 
		panel->SetFill(1, 0);
 
		panel->SetDataTip(0x0, STR_GRAPH_KEY_COMPANY_SELECTION_TOOLTIP);
 
		vert->Add(panel);
 
	}
 
	*biggest_index = GLW_LAST_COMPANY;
 
	return vert;
 
}
 

	
 
static const NWidgetPart _nested_graph_legend_widgets[] = {
 
	NWidget(NWID_HORIZONTAL),
 
		NWidget(WWT_CLOSEBOX, COLOUR_GREY),
 
		NWidget(WWT_CAPTION, COLOUR_GREY), SetDataTip(STR_GRAPH_KEY_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
 
		NWidget(WWT_STICKYBOX, COLOUR_GREY),
 
	EndContainer(),
 
	NWidget(WWT_PANEL, COLOUR_GREY, GLW_BACKGROUND),
 
		NWidget(NWID_SPACER), SetMinimalSize(0, 2),
 
@@ -1354,83 +1354,83 @@ struct PerformanceRatingDetailWindow : W
 
		if (this->company != INVALID_COMPANY && !Company::IsValidID(this->company)) {
 
			/* Raise the widget for the previous selection. */
 
			this->RaiseWidget(this->company + PRW_COMPANY_FIRST);
 
			this->company = INVALID_COMPANY;
 
		}
 

	
 
		if (this->company == INVALID_COMPANY) {
 
			const Company *c;
 
			FOR_ALL_COMPANIES(c) {
 
				this->company = c->index;
 
				break;
 
			}
 
		}
 

	
 
		/* Make sure the widget is lowered */
 
		this->LowerWidget(this->company + PRW_COMPANY_FIRST);
 
	}
 
};
 

	
 
CompanyID PerformanceRatingDetailWindow::company = INVALID_COMPANY;
 

	
 
/** Make a vertical list of panels for outputting score details.
 
 * @param biggest_index Storage for collecting the biggest index used in the returned tree.
 
 * @return Panel with performance details.
 
 * @postcond \c *biggest_index contains the largest used index in the tree.
 
 * @post \c *biggest_index contains the largest used index in the tree.
 
 */
 
static NWidgetBase *MakePerformanceDetailPanels(int *biggest_index)
 
{
 
	const StringID performance_tips[] = {
 
		STR_PERFORMANCE_DETAIL_VEHICLES_TOOLTIP,
 
		STR_PERFORMANCE_DETAIL_STATIONS_TOOLTIP,
 
		STR_PERFORMANCE_DETAIL_MIN_PROFIT_TOOLTIP,
 
		STR_PERFORMANCE_DETAIL_MIN_INCOME_TOOLTIP,
 
		STR_PERFORMANCE_DETAIL_MAX_INCOME_TOOLTIP,
 
		STR_PERFORMANCE_DETAIL_DELIVERED_TOOLTIP,
 
		STR_PERFORMANCE_DETAIL_CARGO_TOOLTIP,
 
		STR_PERFORMANCE_DETAIL_MONEY_TOOLTIP,
 
		STR_PERFORMANCE_DETAIL_LOAN_TOOLTIP,
 
		STR_PERFORMANCE_DETAIL_TOTAL_TOOLTIP,
 
	};
 

	
 
	assert_compile(lengthof(performance_tips) == SCORE_END - SCORE_BEGIN);
 

	
 
	NWidgetVertical *vert = new NWidgetVertical(NC_EQUALSIZE);
 
	for (int widnum = PRW_SCORE_FIRST; widnum <= PRW_SCORE_LAST; widnum++) {
 
		NWidgetBackground *panel = new NWidgetBackground(WWT_PANEL, COLOUR_GREY, widnum);
 
		panel->SetFill(1, 1);
 
		panel->SetDataTip(0x0, performance_tips[widnum - PRW_SCORE_FIRST]);
 
		vert->Add(panel);
 
	}
 
	*biggest_index = PRW_SCORE_LAST;
 
	return vert;
 
}
 

	
 
/**
 
 * Make a number of rows with button-like graphics, for enabling/disabling each company.
 
 * @param biggest_index Storage for collecting the biggest index used in the returned tree.
 
 * @return Panel with rows of company buttons.
 
 * @postcond \c *biggest_index contains the largest used index in the tree.
 
 * @post \c *biggest_index contains the largest used index in the tree.
 
 */
 
static NWidgetBase *MakeCompanyButtonRows(int *biggest_index)
 
{
 
	static const int MAX_LENGTH = 8; // Maximal number of company buttons in one row.
 
	NWidgetVertical *vert = NULL; // Storage for all rows.
 
	NWidgetHorizontal *hor = NULL; // Storage for buttons in one row.
 
	int hor_length = 0;
 

	
 
	Dimension sprite_size = GetSpriteSize(SPR_COMPANY_ICON);
 
	sprite_size.width  += WD_MATRIX_LEFT + WD_MATRIX_RIGHT;
 
	sprite_size.height += WD_MATRIX_TOP + WD_MATRIX_BOTTOM + 1; // 1 for the 'offset' of being pressed
 

	
 
	for (int widnum = PRW_COMPANY_FIRST; widnum <= PRW_COMPANY_LAST; widnum++) {
 
		/* Ensure there is room in 'hor' for another button. */
 
		if (hor_length == MAX_LENGTH) {
 
			if (vert == NULL) vert = new NWidgetVertical();
 
			vert->Add(hor);
 
			hor = NULL;
 
			hor_length = 0;
 
		}
 
		if (hor == NULL) {
 
			hor = new NWidgetHorizontal();
 
			hor_length = 0;
 
		}
src/widget.cpp
Show inline comments
 
@@ -2068,49 +2068,49 @@ bool NWidgetLeaf::ButtonHit(const Point 
 
	if (_dynlang.text_dir == TD_LTR) {
 
		int button_width = this->pos_x + this->current_x - 12;
 
		return pt.x < button_width;
 
	} else {
 
		int button_left = this->pos_x + 12;
 
		return pt.x >= button_left;
 
	}
 
}
 

	
 
/* == Conversion code from NWidgetPart array to NWidgetBase* tree == */
 

	
 
/**
 
 * Construct a single nested widget in \a *dest from its parts.
 
 *
 
 * Construct a NWidgetBase object from a #NWidget function, and apply all
 
 * settings that follow it, until encountering a #EndContainer, another
 
 * #NWidget, or the end of the parts array.
 
 *
 
 * @param parts Array with parts of the nested widget.
 
 * @param count Length of the \a parts array.
 
 * @param dest  Address of pointer to use for returning the composed widget.
 
 * @param fill_dest Fill the composed widget with child widgets.
 
 * @param biggest_index Pointer to biggest nested widget index in the tree encountered so far.
 
 * @return Number of widget part elements used to compose the widget.
 
 * @precond \c biggest_index != NULL.
 
 * @pre \c biggest_index != NULL.
 
 */
 
static int MakeNWidget(const NWidgetPart *parts, int count, NWidgetBase **dest, bool *fill_dest, int *biggest_index)
 
{
 
	int num_used = 0;
 

	
 
	*dest = NULL;
 
	*fill_dest = false;
 

	
 
	while (count > num_used) {
 
		switch (parts->type) {
 
			case NWID_SPACER:
 
				if (*dest != NULL) return num_used;
 
				*dest = new NWidgetSpacer(0, 0);
 
				break;
 

	
 
			case NWID_HORIZONTAL:
 
				if (*dest != NULL) return num_used;
 
				*dest = new NWidgetHorizontal(parts->u.cont_flags);
 
				*fill_dest = true;
 
				break;
 

	
 
			case NWID_HORIZONTAL_LTR:
 
				if (*dest != NULL) return num_used;
 
				*dest = new NWidgetHorizontalLTR(parts->u.cont_flags);
 
@@ -2216,49 +2216,49 @@ static int MakeNWidget(const NWidgetPart
 
				break;
 
			}
 

	
 
			default:
 
				if (*dest != NULL) return num_used;
 
				assert((parts->type & WWT_MASK) < WWT_LAST || parts->type == NWID_BUTTON_DROPDOWN || parts->type == NWID_BUTTON_ARROW);
 
				*dest = new NWidgetLeaf(parts->type, parts->u.widget.colour, parts->u.widget.index, 0x0, STR_NULL);
 
				*biggest_index = max(*biggest_index, (int)parts->u.widget.index);
 
				break;
 
		}
 
		num_used++;
 
		parts++;
 
	}
 

	
 
	return num_used;
 
}
 

	
 
/**
 
 * Build a nested widget tree by recursively filling containers with nested widgets read from their parts.
 
 * @param parts  Array with parts of the nested widgets.
 
 * @param count  Length of the \a parts array.
 
 * @param parent Container to use for storing the child widgets.
 
 * @param biggest_index Pointer to biggest nested widget index in the tree.
 
 * @return Number of widget part elements used to fill the container.
 
 * @postcond \c *biggest_index contains the largest widget index of the tree and \c -1 if no index is used.
 
 * @post \c *biggest_index contains the largest widget index of the tree and \c -1 if no index is used.
 
 */
 
static int MakeWidgetTree(const NWidgetPart *parts, int count, NWidgetBase *parent, int *biggest_index)
 
{
 
	/* Given parent must be either a #NWidgetContainer or a #NWidgetBackground object. */
 
	NWidgetContainer *nwid_cont = dynamic_cast<NWidgetContainer *>(parent);
 
	NWidgetBackground *nwid_parent = dynamic_cast<NWidgetBackground *>(parent);
 
	assert((nwid_cont != NULL && nwid_parent == NULL) || (nwid_cont == NULL && nwid_parent != NULL));
 

	
 
	int total_used = 0;
 
	while (true) {
 
		NWidgetBase *sub_widget = NULL;
 
		bool fill_sub = false;
 
		int num_used = MakeNWidget(parts, count - total_used, &sub_widget, &fill_sub, biggest_index);
 
		parts += num_used;
 
		total_used += num_used;
 

	
 
		/* Break out of loop when end reached */
 
		if (sub_widget == NULL) break;
 

	
 
		/* Add sub_widget to parent container. */
 
		if (nwid_cont) nwid_cont->Add(sub_widget);
 
		if (nwid_parent) nwid_parent->Add(sub_widget);
 

	
 
		/* If sub-widget is a container, recursively fill that container. */
src/widget_type.h
Show inline comments
 
@@ -536,49 +536,49 @@ struct NWidgetPartWidget {
 

	
 
/** Widget part for storing padding.
 
 * @ingroup NestedWidgetParts */
 
struct NWidgetPartPaddings {
 
	uint8 top, right, bottom, left; ///< Paddings for all directions.
 
};
 

	
 
/** Widget part for storing pre/inter/post spaces.
 
 * @ingroup NestedWidgetParts */
 
struct NWidgetPartPIP {
 
	uint8 pre, inter, post; ///< Amount of space before/between/after child widgets.
 
};
 

	
 
/** Widget part for storing minimal text line data.
 
 * @ingroup NestedWidgetParts */
 
struct NWidgetPartTextLines {
 
	uint8 lines;   ///< Number of text lines.
 
	uint8 spacing; ///< Extra spacing around lines.
 
	FontSize size; ///< Font size of text lines.
 
};
 

	
 
/** Pointer to function returning a nested widget.
 
 * @param biggest_index Pointer to storage for collecting the biggest index used in the nested widget.
 
 * @return Nested widget (tree).
 
 * @postcond \c *biggest_index must contain the value of the biggest index in the returned tree.
 
 * @post \c *biggest_index must contain the value of the biggest index in the returned tree.
 
 */
 
typedef NWidgetBase *NWidgetFunctionType(int *biggest_index);
 

	
 
/** Partial widget specification to allow NWidgets to be written nested.
 
 * @ingroup NestedWidgetParts */
 
struct NWidgetPart {
 
	WidgetType type;                         ///< Type of the part. @see NWidgetPartType.
 
	union {
 
		Point xy;                        ///< Part with an x/y size.
 
		NWidgetPartDataTip data_tip;     ///< Part with a data/tooltip.
 
		NWidgetPartWidget widget;        ///< Part with a start of a widget.
 
		NWidgetPartPaddings padding;     ///< Part with paddings.
 
		NWidgetPartPIP pip;              ///< Part with pre/inter/post spaces.
 
		NWidgetPartTextLines text_lines; ///< Part with text line data.
 
		NWidgetFunctionType *func_ptr;   ///< Part with a function call.
 
		NWidContainerFlags cont_flags;   ///< Part with container flags.
 
	} u;
 
};
 

	
 
/**
 
 * Widget part function for setting the resize step.
 
 * @param dx Horizontal resize step. 0 means no horizontal resizing.
 
 * @param dy Vertical resize step. 0 means no vertical resizing.
 
 * @ingroup NestedWidgetParts
0 comments (0 inline, 0 general)