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. | |
virtual void | OnInvalidateData (int data) |
Some data on this window has become invalid. | |
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 () const |
Get the highest value of the graph's data. | |
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 168 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 170 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 266 of file graph_gui.cpp.
References _colour_gradient, abs(), cost, DrawString(), DrawStringMultiLine(), excluded_data, FindLastBit(), FS_SMALL, GetCharacterHeight(), GetHighestValue(), 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 507 of file graph_gui.cpp.
References DrawGraph().
int64 BaseGraphWindow::GetHighestValue | ( | ) | const [inline, protected] |
Get the highest value of the graph's data.
Excluded data is ignored to allow showing smaller values in better detail when disabling higher ones.
Definition at line 208 of file graph_gui.cpp.
References abs(), cost, excluded_data, GRAPH_NUM_LINES_Y, HasBit(), and max().
Referenced by 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 519 of file graph_gui.cpp.
virtual void BaseGraphWindow::OnInvalidateData | ( | int | data | ) | [inline, virtual] |
Some data on this window has become invalid.
data | information about the changed data. |
Reimplemented from Window.
Reimplemented in PaymentRatesGraphWindow.
Definition at line 530 of file graph_gui.cpp.
References UpdateStatistics().
virtual void BaseGraphWindow::OnPaint | ( | ) | [inline, virtual] |
The window must be repainted.
Reimplemented from Window.
Definition at line 466 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 539 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 OnInvalidateData(), and 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 471 of file graph_gui.cpp.
References FONT_HEIGHT_SMALL, GetStringBoundingBox(), max(), SetDParam(), and Window::width.