From 3d38744b9f1e82c6cfda8c013a6afa3a6de4a4a3 Mon Sep 17 00:00:00 2001 From: alberth Date: Fri, 14 Aug 2009 21:33:30 +0000 Subject: (svn r17176) -Codechange: Move widget state updating out of OnPaint method of message options window. --- src/news_gui.cpp | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'src/news_gui.cpp') 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(); } }; -- cgit v1.2.3-70-g09d2