|
@@ -66,53 +66,53 @@ struct GraphLegendWindow : Window {
|
|
|
}
|
|
|
|
|
|
virtual void DrawWidget(const Rect &r, int widget) const
|
|
|
{
|
|
|
if (!IsInsideMM(widget, GLW_FIRST_COMPANY, MAX_COMPANIES + GLW_FIRST_COMPANY)) return;
|
|
|
|
|
|
CompanyID cid = (CompanyID)(widget - GLW_FIRST_COMPANY);
|
|
|
|
|
|
if (!Company::IsValidID(cid)) return;
|
|
|
|
|
|
DrawCompanyIcon(cid, r.left + 2, r.top + 2);
|
|
|
|
|
|
SetDParam(0, cid);
|
|
|
SetDParam(1, cid);
|
|
|
DrawString(r.left + 19, r.right - 2, r.top + 1, STR_COMPANY_NAME_COMPANY_NUM, HasBit(_legend_excluded_companies, cid) ? TC_BLACK : TC_WHITE);
|
|
|
}
|
|
|
|
|
|
virtual void OnClick(Point pt, int widget)
|
|
|
{
|
|
|
if (!IsInsideMM(widget, GLW_FIRST_COMPANY, MAX_COMPANIES + GLW_FIRST_COMPANY)) return;
|
|
|
|
|
|
ToggleBit(_legend_excluded_companies, widget - GLW_FIRST_COMPANY);
|
|
|
this->ToggleWidgetLoweredState(widget);
|
|
|
this->SetDirty();
|
|
|
InvalidateWindow(WC_INCOME_GRAPH, 0);
|
|
|
InvalidateWindow(WC_OPERATING_PROFIT, 0);
|
|
|
InvalidateWindow(WC_DELIVERED_CARGO, 0);
|
|
|
InvalidateWindow(WC_PERFORMANCE_HISTORY, 0);
|
|
|
InvalidateWindow(WC_COMPANY_VALUE, 0);
|
|
|
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.
|
|
|
*/
|
|
|
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, 12);
|
|
@@ -382,49 +382,49 @@ protected:
|
|
|
GfxFillRect(x - 1, y - 1, x + 1, y + 1, colour);
|
|
|
|
|
|
/* Draw the line connected to the previous point. */
|
|
|
if (prev_x != INVALID_DATAPOINT_POS) GfxDrawLine(prev_x, prev_y, x, y, colour);
|
|
|
|
|
|
prev_x = x;
|
|
|
prev_y = y;
|
|
|
} else {
|
|
|
prev_x = INVALID_DATAPOINT_POS;
|
|
|
prev_y = INVALID_DATAPOINT_POS;
|
|
|
}
|
|
|
|
|
|
x += GRAPH_X_POSITION_SEPARATION;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
BaseGraphWindow(const WindowDesc *desc, WindowNumber window_number, int left,
|
|
|
int top, int height, bool has_negative_values, StringID format_str_y_axis) :
|
|
|
Window(desc, window_number), has_negative_values(has_negative_values),
|
|
|
format_str_y_axis(format_str_y_axis)
|
|
|
{
|
|
|
InvalidateWindow(WC_GRAPH_LEGEND, 0);
|
|
|
SetWindowDirty(WC_GRAPH_LEGEND, 0);
|
|
|
this->num_vert_lines = 24;
|
|
|
|
|
|
this->graph_location.left = left;
|
|
|
this->graph_location.right = left + GRAPH_X_POSITION_BEGINNING + this->num_vert_lines * GRAPH_X_POSITION_SEPARATION - 1;
|
|
|
|
|
|
this->graph_location.top = top;
|
|
|
this->graph_location.bottom = top + height - 1;
|
|
|
}
|
|
|
|
|
|
void InitializeWindow(const WindowDesc *desc)
|
|
|
{
|
|
|
this->FindWindowPlacementAndResize(desc);
|
|
|
|
|
|
/* Initialise the dataset */
|
|
|
this->UpdateStatistics(true);
|
|
|
}
|
|
|
|
|
|
public:
|
|
|
virtual void OnPaint()
|
|
|
{
|
|
|
this->DrawWidgets();
|
|
|
|
|
|
this->DrawGraph(this->graph_location);
|
|
|
}
|