summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoralberth <alberth@openttd.org>2009-04-09 11:42:24 +0000
committeralberth <alberth@openttd.org>2009-04-09 11:42:24 +0000
commitb5da02ac1cd67037a3521971bffab492ba4b6e3f (patch)
tree8c10d3b1f75b042e204e5202932662097e3a4e15
parent11f406c0a4b4470ce316f4de9938596be5cf993d (diff)
downloadopenttd-b5da02ac1cd67037a3521971bffab492ba4b6e3f.tar.xz
(svn r16003) -Codechange: Replaced magic widget number constant with enumerated value in graph legend window.
-rw-r--r--src/graph_gui.cpp19
1 files changed, 14 insertions, 5 deletions
diff --git a/src/graph_gui.cpp b/src/graph_gui.cpp
index a945f6342..16961bfc7 100644
--- a/src/graph_gui.cpp
+++ b/src/graph_gui.cpp
@@ -30,11 +30,20 @@ static const uint INVALID_DATAPOINT_POS = UINT_MAX; // Used to determine if the
/* GRAPH LEGEND */
/****************/
+/** Widget numbers of the graph legend window. */
+enum GraphLegendWidgetNumbers {
+ GLW_CLOSEBOX,
+ GLW_CAPTION,
+ GLW_BACKGROUND,
+
+ GLW_FIRST_COMPANY,
+};
+
struct GraphLegendWindow : Window {
GraphLegendWindow(const WindowDesc *desc, WindowNumber window_number) : Window(desc, window_number)
{
- for (uint i = 3; i < this->widget_count; i++) {
- if (!HasBit(_legend_excluded_companies, i - 3)) this->LowerWidget(i);
+ for (uint i = GLW_FIRST_COMPANY; i < this->widget_count; i++) {
+ if (!HasBit(_legend_excluded_companies, i - GLW_FIRST_COMPANY)) this->LowerWidget(i);
}
this->FindWindowPlacementAndResize(desc);
@@ -46,7 +55,7 @@ struct GraphLegendWindow : Window {
if (IsValidCompanyID(c)) continue;
SetBit(_legend_excluded_companies, c);
- this->RaiseWidget(c + 3);
+ this->RaiseWidget(c + GLW_FIRST_COMPANY);
}
this->DrawWidgets();
@@ -63,9 +72,9 @@ struct GraphLegendWindow : Window {
virtual void OnClick(Point pt, int widget)
{
- if (!IsInsideMM(widget, 3, MAX_COMPANIES + 3)) return;
+ if (!IsInsideMM(widget, GLW_FIRST_COMPANY, MAX_COMPANIES + GLW_FIRST_COMPANY)) return;
- ToggleBit(_legend_excluded_companies, widget - 3);
+ ToggleBit(_legend_excluded_companies, widget - GLW_FIRST_COMPANY);
this->ToggleWidgetLoweredState(widget);
this->SetDirty();
InvalidateWindow(WC_INCOME_GRAPH, 0);