=== modified file 'src/widget.cpp' --- src/widget.cpp 2008-07-15 12:55:36 +0000 +++ src/widget.cpp 2008-07-15 13:27:58 +0000 @@ -603,3 +603,17 @@ int offset = this->IsWidgetLowered(widget) ? 1 : 0; DoDrawString(state == SBS_DOWN ? DOWNARROW : UPARROW, this->widget[widget].right - 11 + offset, this->widget[widget].top + 1 + offset, TC_BLACK); } + + +/** Mark widget as dirty (in need of repaint) + * @param w Window that the widget belongs to + */ +void Widget::SetDirty(const Window *w) const +{ + /* Don't redraw if the widget is invisible or of no-type */ + if (type == WWT_EMPTY || IsHidden()) return; + + /* Mark area covered by the widget dirty */ + SetDirtyBlocks(w->left + left, w->top + top, w->left + right + 1, w->top + bottom + 1); +} + === modified file 'src/window.cpp' --- src/window.cpp 2008-07-15 12:55:36 +0000 +++ src/window.cpp 2008-07-15 13:27:58 +0000 @@ -102,14 +102,15 @@ } } +/** + * Mark widget of a window as invalid. Specified widget is marked as dirty to + * have it repainted by the video system. + * @param widget_index Number of the widget to invalidate + */ void Window::InvalidateWidget(byte widget_index) const { const Widget *wi = &this->widget[widget_index]; - - /* Don't redraw the window if the widget is invisible or of no-type */ - if (wi->type == WWT_EMPTY || wi->IsHidden()) return; - - SetDirtyBlocks(this->left + wi->left, this->top + wi->top, this->left + wi->right + 1, this->top + wi->bottom + 1); + wi->SetDirty(this); } void Window::HandleButtonClick(byte widget) === modified file 'src/window_gui.h' --- src/window_gui.h 2008-07-15 12:55:36 +0000 +++ src/window_gui.h 2008-07-15 13:27:58 +0000 @@ -86,6 +86,8 @@ uint16 data; ///< The String/Image or special code (list-matrixes) of a widget StringID tooltips; ///< Tooltips that are shown when rightclicking on a widget + void SetDirty(const Window *w) const; + void SetDisabledState(bool disab_stat); void Disable(); void Enable();