From 37afd58fdbc904f017770e401c51d7f4516b49a7 Mon Sep 17 00:00:00 2001
From: alberth <alberth@openttd.org>
Date: Sat, 2 May 2009 16:33:28 +0000
Subject: [PATCH] (svn r16201) -Codechange: Add NWidgetBase::SetPadding method.

---
 src/widget.cpp    | 11 ++---------
 src/widget_type.h | 15 +++++++++++++++
 2 files changed, 17 insertions(+), 9 deletions(-)

diff --git a/src/widget.cpp b/src/widget.cpp
index ab80118254..5701cf434b 100644
--- a/src/widget.cpp
+++ b/src/widget.cpp
@@ -1636,16 +1636,9 @@ static int MakeNWidget(const NWidgetPart *parts, int count, NWidgetBase **dest,
 				break;
 			}
 
-			case WPT_PADDING: {
-				NWidgetBase *nwb = *dest;
-				if (nwb != NULL) {
-					nwb->padding_top = parts->u.padding.top;
-					nwb->padding_right = parts->u.padding.right;
-					nwb->padding_bottom = parts->u.padding.bottom;
-					nwb->padding_left = parts->u.padding.left;
-				}
+			case WPT_PADDING:
+				if (*dest != NULL) (*dest)->SetPadding(parts->u.padding.top, parts->u.padding.right, parts->u.padding.bottom, parts->u.padding.left);
 				break;
-			}
 
 			case WPT_PIPSPACE: {
 				NWidgetPIPContainer *nwc = dynamic_cast<NWidgetPIPContainer *>(*dest);
diff --git a/src/widget_type.h b/src/widget_type.h
index 0128d510d1..1e4b657a1d 100644
--- a/src/widget_type.h
+++ b/src/widget_type.h
@@ -157,6 +157,21 @@ public:
 
 	virtual void StoreWidgets(Widget *widgets, int length, bool left_moving, bool top_moving, bool rtl) = 0;
 
+	/**
+	 * Set additional space (padding) around the widget.
+	 * @param top    Amount of additional space above the widget.
+	 * @param right  Amount of additional space right of the widget.
+	 * @param bottom Amount of additional space below the widget.
+	 * @param left   Amount of additional space left of the widget.
+	 */
+	inline void SetPadding(uint8 top, uint8 right, uint8 bottom, uint8 left)
+	{
+		this->padding_top = top;
+		this->padding_right = right;
+		this->padding_bottom = bottom;
+		this->padding_left = left;
+	};
+
 	WidgetType type;      ///< Type of the widget / nested widget.
 	uint min_x;           ///< Minimal horizontal size.
 	uint min_y;           ///< Minimal vertical size.