summaryrefslogtreecommitdiff
path: root/src/news_gui.cpp
diff options
context:
space:
mode:
authoralberth <alberth@openttd.org>2009-08-14 21:33:30 +0000
committeralberth <alberth@openttd.org>2009-08-14 21:33:30 +0000
commit3d38744b9f1e82c6cfda8c013a6afa3a6de4a4a3 (patch)
tree2cc2c514c91dffd1907d958540eca0bc613666b9 /src/news_gui.cpp
parente6a1da11a377bdd28e530695ec0fb5e4957e1923 (diff)
downloadopenttd-3d38744b9f1e82c6cfda8c013a6afa3a6de4a4a3.tar.xz
(svn r17176) -Codechange: Move widget state updating out of OnPaint method of message options window.
Diffstat (limited to 'src/news_gui.cpp')
-rw-r--r--src/news_gui.cpp15
1 files changed, 11 insertions, 4 deletions
diff --git a/src/news_gui.cpp b/src/news_gui.cpp
index 68fbf730b..4c6d3c75a 100644
--- a/src/news_gui.cpp
+++ b/src/news_gui.cpp
@@ -955,6 +955,7 @@ struct MessageOptionsWindow : Window {
}
/* If all values are the same value, the ALL-button will take over this value */
this->state = all_val;
+ this->OnInvalidateData(0);
this->FindWindowPlacementAndResize(desc);
}
@@ -977,9 +978,6 @@ struct MessageOptionsWindow : Window {
virtual void OnPaint()
{
- if (_news_ticker_sound) this->LowerWidget(WIDGET_NEWSOPT_SOUNDTICKER);
-
- this->widget[WIDGET_NEWSOPT_DROP_SUMMARY].data = this->message_opt[this->state];
this->DrawWidgets();
/* Draw the string of each setting on each button. */
@@ -989,6 +987,14 @@ struct MessageOptionsWindow : Window {
}
}
+ virtual void OnInvalidateData(int data)
+ {
+ /* Update the dropdown value for 'set all categories'. */
+ this->widget[WIDGET_NEWSOPT_DROP_SUMMARY].data = this->message_opt[this->state];
+ /* Update widget to reflect the value of the #_news_ticker_sound variable. */
+ this->SetWidgetLoweredState(WIDGET_NEWSOPT_SOUNDTICKER, _news_ticker_sound);
+ }
+
virtual void OnClick(Point pt, int widget)
{
switch (widget) {
@@ -998,7 +1004,7 @@ struct MessageOptionsWindow : Window {
case WIDGET_NEWSOPT_SOUNDTICKER: // Change ticker sound on/off
_news_ticker_sound ^= 1;
- this->ToggleWidgetLoweredState(widget);
+ this->OnInvalidateData(0);
this->InvalidateWidget(widget);
break;
@@ -1025,6 +1031,7 @@ struct MessageOptionsWindow : Window {
this->SetMessageButtonStates(index, i);
_news_type_data[i].display = (NewsDisplay)index;
}
+ this->OnInvalidateData(0);
this->SetDirty();
}
};