BaseGraphWindow Struct Reference

Inheritance diagram for BaseGraphWindow:
Window ZeroedMemoryAllocator CompanyValueGraphWindow DeliveredCargoGraphWindow IncomeGraphWindow OperatingProfitGraphWindow PaymentRatesGraphWindow PerformanceHistoryGraphWindow

Public Member Functions

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=0, bool gui_scope=true)
 Some data on this window has become invalid.
void UpdateStatistics (bool initialize)
 Update the statistics.

Protected Member Functions

ValuesInterval GetValuesInterval (int num_hori_lines) const
 Get the interval that contains the graph's data.
uint GetYLabelWidth (ValuesInterval current_interval, int num_hori_lines) const
 Get width for Y labels.
void DrawGraph (Rect r) const
 Actually draw the graph.
 BaseGraphWindow (int widget, 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
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 int GRAPH_MAX_DATASETS = 32
static const int GRAPH_AXIS_LINE_COLOUR = 215
static const int GRAPH_NUM_MONTHS = 24
 Number of months displayed in the graph.
static const int MIN_GRAPH_NUM_LINES_Y = 9
 Minimal number of horizontal lines to draw.
static const int MIN_GRID_PIXEL_SIZE = 20
 Minimum distance between graph lines.
static const TextColour graph_axis_label_colour = TC_BLACK
 colour of the graph axis label.

Detailed Description

Definition at line 177 of file graph_gui.cpp.


Member Function Documentation

void BaseGraphWindow::DrawGraph ( Rect  r  )  const [inline, protected]

Actually draw the graph.

Parameters:
r the rectangle of the data field of the graph

< Reused whenever x and y coordinates are needed.

< Interval that contains all of the graph data.

< Distance from the top of the graph to the x axis.

Definition at line 294 of file graph_gui.cpp.

References _colour_gradient, abs(), cost, DrawString(), DrawStringMultiLine(), excluded_data, FindLastBit(), FS_SMALL, GetCharacterHeight(), GetValuesInterval(), GetYLabelWidth(), GfxFillRect(), graph_axis_label_colour, HasBit(), Window::height, ValuesInterval::highest, ValuesInterval::lowest, max(), MAX_COMPANIES, MIN_GRID_PIXEL_SIZE, NUM_CARGO, Window::resize, SA_HOR_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.

Parameters:
r Rectangle occupied by the widget.
widget Number of the widget to draw.
Note:
This method may not change any state, it may only use drawing functions.

Reimplemented from Window.

Reimplemented in PaymentRatesGraphWindow.

Definition at line 529 of file graph_gui.cpp.

References DrawGraph().

ValuesInterval BaseGraphWindow::GetValuesInterval ( int  num_hori_lines  )  const [inline, protected]

Get the interval that contains the graph's data.

Excluded data is ignored to show smaller values in better detail when disabling higher ones.

Parameters:
num_hori_lines Number of horizontal lines to be drawn.
Returns:
Highest and lowest values of the graph (ignoring disabled data).

Definition at line 213 of file graph_gui.cpp.

References abs(), cost, excluded_data, HasBit(), ValuesInterval::highest, ValuesInterval::lowest, max(), and min().

Referenced by DrawGraph().

uint BaseGraphWindow::GetYLabelWidth ( ValuesInterval  current_interval,
int  num_hori_lines 
) const [inline, protected]

Get width for Y labels.

Parameters:
current_interval Interval that contains all of the graph data.
num_hori_lines Number of horizontal lines to be drawn.

Definition at line 270 of file graph_gui.cpp.

References GetStringBoundingBox(), ValuesInterval::highest, ValuesInterval::lowest, and SetDParam().

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.

Parameters:
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 541 of file graph_gui.cpp.

virtual void BaseGraphWindow::OnInvalidateData ( int  data = 0,
bool  gui_scope = true 
) [inline, virtual]

Some data on this window has become invalid.

Parameters:
data Information about the changed data.
gui_scope Whether the call is done from GUI scope. You may not do everything when not in GUI scope. See InvalidateWindowData() for details.

Reimplemented from Window.

Reimplemented in PaymentRatesGraphWindow.

Definition at line 557 of file graph_gui.cpp.

References UpdateStatistics().

void BaseGraphWindow::UpdateStatistics ( bool  initialize  )  [inline]
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.

Parameters:
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 493 of file graph_gui.cpp.

References FONT_HEIGHT_SMALL, GetStringBoundingBox(), max(), MIN_GRAPH_NUM_LINES_Y, SetDParam(), and Window::width.


The documentation for this struct was generated from the following file:

Generated on Wed Apr 13 00:48:28 2011 for OpenTTD by  doxygen 1.6.1