Public Member Functions | |
virtual void | OnPaint () |
The window must be repainted. | |
virtual void | UpdateWidgetSize (int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) |
Update size and resize step of a widget in the window. | |
virtual void | DrawWidget (const Rect &r, int widget) const |
Draw the contents of a nested widget. | |
virtual OverflowSafeInt64 | GetGraphData (const Company *c, int j) |
virtual void | OnClick (Point pt, int widget, int click_count) |
A click with the left mouse button has been made on the window. | |
virtual void | OnTick () |
Called once per (game) tick. | |
void | UpdateStatistics (bool initialize) |
Update the statistics. | |
Protected Types | |
enum | { GRAPH_MAX_DATASETS = 32, GRAPH_AXIS_LINE_COLOUR = 215, GRAPH_NUM_MONTHS = 24, GRAPH_NUM_LINES_Y = 9 } |
Protected Member Functions | |
int64 | GetHighestValue (int initial_highest_value) const |
uint | GetYLabelWidth (int64 highest_value) const |
void | DrawGraph (Rect r) const |
Actually draw the graph. | |
BaseGraphWindow (int widget, bool has_negative_values, StringID format_str_y_axis) | |
void | InitializeWindow (const WindowDesc *desc, WindowNumber number) |
Protected Attributes | |
uint | excluded_data |
bitmask of the datasets that shouldn't be displayed. | |
byte | num_dataset |
byte | num_on_x_axis |
bool | has_negative_values |
byte | num_vert_lines |
byte | month |
Year | year |
uint16 | x_values_start |
uint16 | x_values_increment |
int | graph_widget |
StringID | format_str_y_axis |
byte | colours [GRAPH_MAX_DATASETS] |
OverflowSafeInt64 | cost [GRAPH_MAX_DATASETS][GRAPH_NUM_MONTHS] |
Stored costs for the last GRAPH_NUM_MONTHS months. | |
Static Protected Attributes | |
static const TextColour | graph_axis_label_colour = TC_BLACK |
colour of the graph axis label. |
Definition at line 167 of file graph_gui.cpp.
anonymous enum [protected] |
GRAPH_NUM_MONTHS |
Number of months displayed in the graph. |
GRAPH_NUM_LINES_Y |
How many horizontal lines to draw. |
Definition at line 169 of file graph_gui.cpp.
void BaseGraphWindow::DrawGraph | ( | Rect | r | ) | const [inline, protected] |
Actually draw the graph.
r | the rectangle of the data field of the graph |
< Reused whenever x and y coordinates are needed.
< Highest value to be drawn.
< Distance from the top of the graph to the x axis.
Definition at line 257 of file graph_gui.cpp.
References _colour_gradient, abs(), cost, DrawString(), DrawStringMultiLine(), excluded_data, FindLastBit(), FS_SMALL, GetCharacterHeight(), GfxFillRect(), graph_axis_label_colour, HasBit(), Window::height, max(), MAX_COMPANIES, NUM_CARGO, SA_CENTER, SA_RIGHT, and SetDParam().
Referenced by DrawWidget().
virtual void BaseGraphWindow::DrawWidget | ( | const Rect & | r, | |
int | widget | |||
) | const [inline, virtual] |
Draw the contents of a nested widget.
r | Rectangle occupied by the widget. | |
widget | Number of the widget to draw. |
Reimplemented from Window.
Reimplemented in PaymentRatesGraphWindow.
Definition at line 504 of file graph_gui.cpp.
References DrawGraph().
virtual void BaseGraphWindow::OnClick | ( | Point | pt, | |
int | widget, | |||
int | click_count | |||
) | [inline, virtual] |
A click with the left mouse button has been made on the window.
pt | the point inside the window that has been clicked. | |
widget | the clicked widget. | |
click_count | Number of fast consecutive clicks at same position |
Reimplemented from Window.
Reimplemented in PerformanceHistoryGraphWindow, and PaymentRatesGraphWindow.
Definition at line 516 of file graph_gui.cpp.
virtual void BaseGraphWindow::OnPaint | ( | ) | [inline, virtual] |
The window must be repainted.
Reimplemented from Window.
Definition at line 463 of file graph_gui.cpp.
References Window::DrawWidgets().
void BaseGraphWindow::UpdateStatistics | ( | bool | initialize | ) | [inline] |
Update the statistics.
initialize | Initialize the data structure. |
Definition at line 531 of file graph_gui.cpp.
References _colour_gradient, _cur_month, _cur_year, COMPANY_FIRST, cost, excluded_data, Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tcache, Tzero >::PoolItem<&_company_pool >::GetIfValid(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tcache, Tzero >::PoolItem<&_company_pool >::IsValidID(), max(), MAX_COMPANIES, min(), and SetBit().
Referenced by OnTick().
virtual void BaseGraphWindow::UpdateWidgetSize | ( | int | widget, | |
Dimension * | size, | |||
const Dimension & | padding, | |||
Dimension * | fill, | |||
Dimension * | resize | |||
) | [inline, virtual] |
Update size and resize step of a widget in the window.
After retrieval of the minimal size and the resize-steps of a widget, this function is called to allow further refinement, typically by computing the real maximal size of the content. Afterwards, size is taken to be the minimal size of the widget and resize is taken to contain the resize steps. For the convenience of the callee, padding contains the amount of padding between the content and the edge of the widget. This should be added to the returned size.
widget | Widget number. | |
size | Size of the widget. | |
padding | Recommended amount of space between the widget content and the widget edge. | |
fill | Fill step of the widget. | |
resize | Resize step of the widget. |
Reimplemented from Window.
Reimplemented in PaymentRatesGraphWindow.
Definition at line 468 of file graph_gui.cpp.
References FONT_HEIGHT_SMALL, GetStringBoundingBox(), max(), SetDParam(), and Window::width.