(svn r17176) -Codechange: Move widget state updating out of OnPaint method of message options window.

This commit is contained in:
alberth 2009-08-14 21:33:30 +00:00
parent e6a1da11a3
commit 3d38744b9f

View File

@ -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();
}
};