summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorglx <glx@openttd.org>2006-10-06 21:10:14 +0000
committerglx <glx@openttd.org>2006-10-06 21:10:14 +0000
commit30e0a8e9522a3ea43fa501cd387ccf8cf962461b (patch)
tree94b2f19d11771e2c48d38b3bfaed3bc9b878b1e2
parent592ed98a196841d51ce864e6b585bbb73572f689 (diff)
downloadopenttd-30e0a8e9522a3ea43fa501cd387ccf8cf962461b.tar.xz
(svn r6669) -Add: vararg functions to set hidden/disabled/lowered state of multiple widgets in one call
-rw-r--r--window.c43
-rw-r--r--window.h8
2 files changed, 51 insertions, 0 deletions
diff --git a/window.c b/window.c
index ce80facb0..1d3bfefdb 100644
--- a/window.c
+++ b/window.c
@@ -1,6 +1,7 @@
/* $Id$ */
#include "stdafx.h"
+#include <stdarg.h>
#include "openttd.h"
#include "debug.h"
#include "functions.h"
@@ -17,6 +18,48 @@
// delta between mouse cursor and upper left corner of dragged window
static Point _drag_delta;
+void CDECL SetWindowWidgetsDisabledState(Window *w, bool disab_stat, int widgets, ...)
+{
+ va_list wdg_list;
+
+ va_start(wdg_list, widgets);
+
+ while (widgets != WIDGET_LIST_END) {
+ SetWindowWidgetHiddenState(w, widgets, disab_stat);
+ widgets = va_arg(wdg_list, int);
+ }
+
+ va_end(wdg_list);
+}
+
+void CDECL SetWindowWidgetsHiddenState(Window *w, bool hidden_stat, int widgets, ...)
+{
+ va_list wdg_list;
+
+ va_start(wdg_list, widgets);
+
+ while (widgets != WIDGET_LIST_END) {
+ SetWindowWidgetHiddenState(w, widgets, hidden_stat);
+ widgets = va_arg(wdg_list, int);
+ }
+
+ va_end(wdg_list);
+}
+
+void CDECL SetWindowWidgetsLoweredState(Window *w, bool lowered_stat, int widgets, ...)
+{
+ va_list wdg_list;
+
+ va_start(wdg_list, widgets);
+
+ while (widgets != WIDGET_LIST_END) {
+ SetWindowWidgetLoweredState(w, widgets, lowered_stat);
+ widgets = va_arg(wdg_list, int);
+ }
+
+ va_end(wdg_list);
+}
+
void RaiseWindowButtons(Window *w)
{
const Widget *wi = w->widget;
diff --git a/window.h b/window.h
index 09a5044e5..47faf3b66 100644
--- a/window.h
+++ b/window.h
@@ -62,6 +62,11 @@ enum ResizeFlags {
WIDG_LOWERED = 6, // widget is paint lowered, a pressed button in fact
} ResizeFlag;
+/* used to indicate the end of widgets' list for vararg functions */
+enum {
+ WIDGET_LIST_END = -1,
+};
+
typedef struct Widget {
byte type; ///< Widget type, see @WindowWidgetTypes
byte display_flags; ///< Resize direction, alignment, etc. during resizing, see @ResizeFlags
@@ -783,6 +788,9 @@ void InvalidateWindowData(WindowClass cls, WindowNumber number);
void RaiseWindowButtons(Window *w);
void RelocateAllWindows(int neww, int newh);
int PositionMainToolbar(Window *w);
+void CDECL SetWindowWidgetsDisabledState(Window *w, bool disab_stat, int widgets, ...);
+void CDECL SetWindowWidgetsHiddenState(Window *w, bool hidden_stat, int widgets, ...);
+void CDECL SetWindowWidgetsLoweredState(Window *w, bool lowered_stat, int widgets, ...);
/* misc_gui.c*/
void GuiShowTooltips(StringID string_id);