diff options
author | alberth <alberth@openttd.org> | 2009-04-25 11:59:36 +0000 |
---|---|---|
committer | alberth <alberth@openttd.org> | 2009-04-25 11:59:36 +0000 |
commit | f4ea018f7f726bcfd2896285518f3ce59dd94b2b (patch) | |
tree | bf2fc3f56df96159fa3de2e09a1b3e42d4c36d4d /src/widget_type.h | |
parent | c6d5923d22852a3ceb2a4e07b9a375b658c8039c (diff) | |
download | openttd-f4ea018f7f726bcfd2896285518f3ce59dd94b2b.tar.xz |
(svn r16140) -Codechange: Call a function while contructing a widget tree.
Diffstat (limited to 'src/widget_type.h')
-rw-r--r-- | src/widget_type.h | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/widget_type.h b/src/widget_type.h index 87cf2c87d..39ed87c2b 100644 --- a/src/widget_type.h +++ b/src/widget_type.h @@ -112,6 +112,7 @@ enum WidgetType { WPT_PADDING, ///< Widget part for specifying a padding. WPT_PIPSPACE, ///< Widget part for specifying pre/inter/post space for containers. WPT_ENDCONTAINER, ///< Widget part to denote end of a container. + WPT_FUNCTION, ///< Widget part for calling a user function. /* Pushable window widget types. */ WWT_MASK = 0x7F, @@ -312,6 +313,9 @@ struct NWidgetPartPIP { uint8 pre, inter, post; ///< Amount of space before/between/after child widgets. }; +/** Pointer to function returning a nested widget. */ +typedef NWidgetBase *NWidgetFunctionType(); + /** Partial widget specification to allow NWidgets to be written nested. */ struct NWidgetPart { WidgetType type; ///< Type of the part. @see NWidgetPartType. @@ -323,6 +327,7 @@ struct NWidgetPart { NWidgetPartWidget widget; ///< Part with a start of a widget. NWidgetPartPaddings padding; ///< Part with paddings. NWidgetPartPIP pip; ///< Part with pre/inter/post spaces. + NWidgetFunctionType *func_ptr; ///< Part with a function call. } u; }; @@ -523,6 +528,16 @@ static inline NWidgetPart NWidget(WidgetType tp) return part; } +static inline NWidgetPart NWidgetFunction(NWidgetFunctionType *func_ptr) +{ + NWidgetPart part; + + part.type = WPT_FUNCTION; + part.u.func_ptr = func_ptr; + + return part; +} + NWidgetContainer *MakeNWidgets(const NWidgetPart *parts, int count); #endif /* WIDGET_TYPE_H */ |