(svn r16003) -Codechange: Replaced magic widget number constant with enumerated value in graph legend window.

This commit is contained in:
alberth 2009-04-09 11:42:24 +00:00
parent 11f406c0a4
commit b5da02ac1c
1 changed files with 14 additions and 5 deletions

View File

@ -30,11 +30,20 @@ static const uint INVALID_DATAPOINT_POS = UINT_MAX; // Used to determine if the
/* GRAPH LEGEND */ /* GRAPH LEGEND */
/****************/ /****************/
/** Widget numbers of the graph legend window. */
enum GraphLegendWidgetNumbers {
GLW_CLOSEBOX,
GLW_CAPTION,
GLW_BACKGROUND,
GLW_FIRST_COMPANY,
};
struct GraphLegendWindow : Window { struct GraphLegendWindow : Window {
GraphLegendWindow(const WindowDesc *desc, WindowNumber window_number) : Window(desc, window_number) GraphLegendWindow(const WindowDesc *desc, WindowNumber window_number) : Window(desc, window_number)
{ {
for (uint i = 3; i < this->widget_count; i++) { for (uint i = GLW_FIRST_COMPANY; i < this->widget_count; i++) {
if (!HasBit(_legend_excluded_companies, i - 3)) this->LowerWidget(i); if (!HasBit(_legend_excluded_companies, i - GLW_FIRST_COMPANY)) this->LowerWidget(i);
} }
this->FindWindowPlacementAndResize(desc); this->FindWindowPlacementAndResize(desc);
@ -46,7 +55,7 @@ struct GraphLegendWindow : Window {
if (IsValidCompanyID(c)) continue; if (IsValidCompanyID(c)) continue;
SetBit(_legend_excluded_companies, c); SetBit(_legend_excluded_companies, c);
this->RaiseWidget(c + 3); this->RaiseWidget(c + GLW_FIRST_COMPANY);
} }
this->DrawWidgets(); this->DrawWidgets();
@ -63,9 +72,9 @@ struct GraphLegendWindow : Window {
virtual void OnClick(Point pt, int widget) 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->ToggleWidgetLoweredState(widget);
this->SetDirty(); this->SetDirty();
InvalidateWindow(WC_INCOME_GRAPH, 0); InvalidateWindow(WC_INCOME_GRAPH, 0);