summaryrefslogtreecommitdiff
path: root/src/news_gui.cpp
diff options
context:
space:
mode:
authoralberth <alberth@openttd.org>2009-09-02 20:39:40 +0000
committeralberth <alberth@openttd.org>2009-09-02 20:39:40 +0000
commit33756275526f812e381d491318c2f0140ce569ca (patch)
tree819289636cad93c1b1c2e4c180bab097542c98df /src/news_gui.cpp
parent0847b338c691a825ba05d506a08089c3b9cebe9f (diff)
downloadopenttd-33756275526f812e381d491318c2f0140ce569ca.tar.xz
(svn r17390) -Codechange: Switch news item windows to nested widgets.
Diffstat (limited to 'src/news_gui.cpp')
-rw-r--r--src/news_gui.cpp36
1 files changed, 9 insertions, 27 deletions
diff --git a/src/news_gui.cpp b/src/news_gui.cpp
index 9acf3a81d..41870a82f 100644
--- a/src/news_gui.cpp
+++ b/src/news_gui.cpp
@@ -124,12 +124,7 @@ enum NewsTypeWidgets {
NTW_VIEWPORT, ///< Viewport in window. Only used in type0-news.
};
-static const Widget _normal_news_widgets[] = {
-{ WWT_PANEL, RESIZE_NONE, COLOUR_WHITE, 0, 429, 0, 169, 0x0, STR_NULL},
-{ WWT_PANEL, RESIZE_NONE, COLOUR_WHITE, 0, 10, 0, 11, 0x0, STR_NULL},
-{ WIDGETS_END},
-};
-
+/* Normal news items. */
static const NWidgetPart _nested_normal_news_widgets[] = {
NWidget(WWT_PANEL, COLOUR_WHITE, NTW_HEADLINE),
NWidget(NWID_HORIZONTAL),
@@ -144,15 +139,10 @@ static WindowDesc _normal_news_desc(
WDP_CENTER, 476, 430, 170, 430, 170,
WC_NEWS_WINDOW, WC_NONE,
WDF_DEF_WIDGET,
- _normal_news_widgets, _nested_normal_news_widgets, lengthof(_nested_normal_news_widgets)
+ NULL, _nested_normal_news_widgets, lengthof(_nested_normal_news_widgets)
);
-static const Widget _thin_news_widgets[] = {
-{ WWT_PANEL, RESIZE_NONE, COLOUR_WHITE, 0, 429, 0, 129, 0x0, STR_NULL},
-{ WWT_PANEL, RESIZE_NONE, COLOUR_WHITE, 0, 10, 0, 11, 0x0, STR_NULL},
-{ WIDGETS_END},
-};
-
+/* Thin news items. */
static const NWidgetPart _nested_thin_news_widgets[] = {
NWidget(WWT_PANEL, COLOUR_WHITE, NTW_HEADLINE),
NWidget(NWID_HORIZONTAL),
@@ -167,17 +157,10 @@ static WindowDesc _thin_news_desc(
WDP_CENTER, 476, 430, 130, 430, 130,
WC_NEWS_WINDOW, WC_NONE,
WDF_DEF_WIDGET,
- _thin_news_widgets, _nested_thin_news_widgets, lengthof(_nested_thin_news_widgets)
+ NULL, _nested_thin_news_widgets, lengthof(_nested_thin_news_widgets)
);
-static const Widget _small_news_widgets[] = {
-{ WWT_PANEL, RESIZE_NONE, COLOUR_LIGHT_BLUE, 0, 279, 14, 86, 0x0, STR_NULL},
-{ WWT_CLOSEBOX, RESIZE_NONE, COLOUR_LIGHT_BLUE, 0, 10, 0, 13, STR_BLACK_CROSS, STR_TOOLTIP_CLOSE_WINDOW},
-{ WWT_CAPTION, RESIZE_NONE, COLOUR_LIGHT_BLUE, 11, 279, 0, 13, STR_NEWS_MESSAGE_CAPTION, STR_NULL},
-{ WWT_INSET, RESIZE_NONE, COLOUR_LIGHT_BLUE, 2, 277, 16, 64, 0x0, STR_NULL},
-{ WIDGETS_END},
-};
-
+/* Small news items. */
static NWidgetPart _nested_small_news_widgets[] = {
/* Caption + close box */
NWidget(NWID_HORIZONTAL),
@@ -204,8 +187,7 @@ static WindowDesc _small_news_desc(
WDP_CENTER, 476, 280, 87, 280, 87,
WC_NEWS_WINDOW, WC_NONE,
WDF_DEF_WIDGET,
- _small_news_widgets,
- _nested_small_news_widgets, lengthof(_nested_small_news_widgets)
+ NULL, _nested_small_news_widgets, lengthof(_nested_small_news_widgets)
);
/**
@@ -276,7 +258,7 @@ struct NewsWindow : Window {
NewsItem *ni; ///< News item to display.
static uint duration; ///< Remaining time for showing current news message (may only be accessed while a news item is displayed).
- NewsWindow(const WindowDesc *desc, NewsItem *ni) : Window(desc), ni(ni)
+ NewsWindow(const WindowDesc *desc, NewsItem *ni) : Window(), ni(ni)
{
NewsWindow::duration = 555;
const Window *w = FindWindowById(WC_SEND_NETWORK_MSG, 0);
@@ -284,7 +266,7 @@ struct NewsWindow : Window {
this->flags4 |= WF_DISABLE_VP_SCROLL;
- this->FindWindowPlacementAndResize(desc);
+ this->InitNested(desc);
const NewsMode display_mode = _news_subtype_data[this->ni->subtype].display_mode;
switch (display_mode) {
@@ -305,7 +287,7 @@ struct NewsWindow : Window {
}
}
- void DrawNewsBorder()
+ void DrawNewsBorder() const
{
int left = 0;
int right = this->width - 1;