diff options
author | alberth <alberth@openttd.org> | 2009-05-31 20:33:09 +0000 |
---|---|---|
committer | alberth <alberth@openttd.org> | 2009-05-31 20:33:09 +0000 |
commit | 743f12fad01ddb13e2ea14d5e40f413c220a9e2a (patch) | |
tree | 76944f204b7c88ea217c790df52afc563cc7361a /src | |
parent | 292647b212007ed9f17029625881c4deb9601b4f (diff) | |
download | openttd-743f12fad01ddb13e2ea14d5e40f413c220a9e2a.tar.xz |
(svn r16488) -Codechange [FS#2941]: Use widget numbers of base grap window and cargo payment window in the window handling code (erikjanp)
Diffstat (limited to 'src')
-rw-r--r-- | src/graph_gui.cpp | 45 |
1 files changed, 23 insertions, 22 deletions
diff --git a/src/graph_gui.cpp b/src/graph_gui.cpp index 30ef53f56..94a1a5122 100644 --- a/src/graph_gui.cpp +++ b/src/graph_gui.cpp @@ -153,6 +153,14 @@ static void ShowGraphLegend() /* BASE OF GRAPHS */ /*****************/ +/** Widget numbers of a base graph window. */ +enum CompanyValueWidgets { + BGW_CLOSEBOX, + BGW_CAPTION, + BGW_KEY_BUTTON, + BGW_BACKGROUND, +}; + struct BaseGraphWindow : Window { protected: enum { @@ -449,18 +457,10 @@ public: virtual void OnClick(Point pt, int widget) { /* Clicked on legend? */ - if (widget == 2) ShowGraphLegend(); + if (widget == BGW_KEY_BUTTON) ShowGraphLegend(); } }; -/** Widget numbers of a base graph window. */ -enum CompanyValueWidgets { - BGW_CLOSEBOX, - BGW_CAPTION, - BGW_KEY_BUTTON, - BGW_BACKGROUND, -}; - /********************/ /* OPERATING PROFIT */ @@ -716,6 +716,14 @@ void ShowCompanyValueGraph() /* PAYMENT RATES */ /*****************/ +/** Widget numbers of the cargo payment rates. */ +enum CargoPaymentRatesWidgets { + CPW_CLOSEBOX, + CPW_CAPTION, + CPW_BACKGROUND, + CPW_CARGO_FIRST, +}; + struct PaymentRatesGraphWindow : BaseGraphWindow { PaymentRatesGraphWindow(const WindowDesc *desc, WindowNumber window_number) : BaseGraphWindow(desc, window_number, 2, 24, 200, false, STR_CURRCOMPACT) @@ -735,7 +743,7 @@ struct PaymentRatesGraphWindow : BaseGraphWindow { /* Set the properties of each widget */ for (uint i = 0; i != num_active; i++) { - Widget *wi = &this->widget[3 + i]; + Widget *wi = &this->widget[CPW_CARGO_FIRST + i]; wi->type = WWT_PANEL; wi->display_flags = RESIZE_NONE; wi->colour = COLOUR_ORANGE; @@ -746,7 +754,7 @@ struct PaymentRatesGraphWindow : BaseGraphWindow { wi->data = 0; wi->tooltips = STR_GRAPH_CARGO_PAYMENT_TOGGLE_CARGO; - if (!HasBit(_legend_excluded_cargo, i)) this->LowerWidget(i + 3); + if (!HasBit(_legend_excluded_cargo, i)) this->LowerWidget(i + CPW_CARGO_FIRST); } this->SetDirty(); @@ -778,12 +786,12 @@ struct PaymentRatesGraphWindow : BaseGraphWindow { /* Only draw labels for widgets that exist. If the widget doesn't * exist then the local company has used the climate cheat or * changed the NewGRF configuration with this window open. */ - if (i + 3 < this->widget_count) { + if (i + CPW_CARGO_FIRST < this->widget_count) { /* Since the buttons have no text, no images, * both the text and the coloured box have to be manually painted. * clk_dif will move one pixel down and one pixel to the right * when the button is clicked */ - byte clk_dif = this->IsWidgetLowered(i + 3) ? 1 : 0; + byte clk_dif = this->IsWidgetLowered(i + CPW_CARGO_FIRST) ? 1 : 0; GfxFillRect(x + clk_dif, y + clk_dif, x + 8 + clk_dif, y + 5 + clk_dif, 0); GfxFillRect(x + 1 + clk_dif, y + 1 + clk_dif, x + 7 + clk_dif, y + 4 + clk_dif, cs->legend_colour); @@ -809,21 +817,14 @@ struct PaymentRatesGraphWindow : BaseGraphWindow { virtual void OnClick(Point pt, int widget) { - if (widget >= 3) { - ToggleBit(_legend_excluded_cargo, widget - 3); + if (widget >= CPW_CARGO_FIRST) { + ToggleBit(_legend_excluded_cargo, widget - CPW_CARGO_FIRST); this->ToggleWidgetLoweredState(widget); this->SetDirty(); } } }; -/** Widget numbers of the cargo payment rates. */ -enum CargoPaymentRatesWidgets { - CPW_CLOSEBOX, - CPW_CAPTION, - CPW_BACKGROUND, -}; - static const Widget _cargo_payment_rates_widgets[] = { { WWT_CLOSEBOX, RESIZE_NONE, COLOUR_GREY, 0, 10, 0, 13, STR_BLACK_CROSS, STR_TOOLTIP_CLOSE_WINDOW}, { WWT_CAPTION, RESIZE_NONE, COLOUR_GREY, 11, 567, 0, 13, STR_GRAPH_CARGO_PAYMENT_RATES_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS}, |