summaryrefslogtreecommitdiff
path: root/src/station_gui.cpp
diff options
context:
space:
mode:
authortruebrain <truebrain@openttd.org>2011-12-16 18:33:02 +0000
committertruebrain <truebrain@openttd.org>2011-12-16 18:33:02 +0000
commitbcf00dbb8fbaf4c263034499633fa0c9e473f5db (patch)
treeb4763b370fc61974b02ab86ceaf792ccb7adcfa1 /src/station_gui.cpp
parent6d0673f0c1e4e2170ae86b196620acad60170a15 (diff)
downloadopenttd-bcf00dbb8fbaf4c263034499633fa0c9e473f5db.tar.xz
(svn r23553) -Fix: avoid naming conflict in widget enums
Diffstat (limited to 'src/station_gui.cpp')
-rw-r--r--src/station_gui.cpp152
1 files changed, 76 insertions, 76 deletions
diff --git a/src/station_gui.cpp b/src/station_gui.cpp
index 76df154e1..44945158f 100644
--- a/src/station_gui.cpp
+++ b/src/station_gui.cpp
@@ -314,7 +314,7 @@ protected:
this->last_station = NULL;
/* Set the modified widget dirty */
- this->SetWidgetDirty(WID_SL_LIST);
+ this->SetWidgetDirty(WID_STL_LIST);
}
public:
@@ -327,23 +327,23 @@ public:
this->SortStationsList();
this->CreateNestedTree(desc);
- this->vscroll = this->GetScrollbar(WID_SL_SCROLLBAR);
+ this->vscroll = this->GetScrollbar(WID_STL_SCROLLBAR);
this->FinishInitNested(desc, window_number);
this->owner = (Owner)this->window_number;
CargoID cid;
FOR_EACH_SET_CARGO_ID(cid, this->cargo_filter) {
- if (CargoSpec::Get(cid)->IsValid()) this->LowerWidget(WID_SL_CARGOSTART + cid);
+ if (CargoSpec::Get(cid)->IsValid()) this->LowerWidget(WID_STL_CARGOSTART + cid);
}
if (this->cargo_filter == this->cargo_filter_max) this->cargo_filter = _cargo_mask;
for (uint i = 0; i < 5; i++) {
- if (HasBit(this->facilities, i)) this->LowerWidget(i + WID_SL_TRAIN);
+ if (HasBit(this->facilities, i)) this->LowerWidget(i + WID_STL_TRAIN);
}
- this->SetWidgetLoweredState(WID_SL_NOCARGOWAITING, this->include_empty);
+ this->SetWidgetLoweredState(WID_STL_NOCARGOWAITING, this->include_empty);
- this->GetWidget<NWidgetCore>(WID_SL_SORTDROPBTN)->widget_data = this->sorter_names[this->stations.SortType()];
+ this->GetWidget<NWidgetCore>(WID_STL_SORTDROPBTN)->widget_data = this->sorter_names[this->stations.SortType()];
}
~CompanyStationsWindow()
@@ -354,7 +354,7 @@ public:
virtual void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize)
{
switch (widget) {
- case WID_SL_SORTBY: {
+ case WID_STL_SORTBY: {
Dimension d = GetStringBoundingBox(this->GetWidget<NWidgetCore>(widget)->widget_data);
d.width += padding.width + WD_SORTBUTTON_ARROW_WIDTH * 2; // Doubled since the string is centred and it also looks better.
d.height += padding.height;
@@ -362,7 +362,7 @@ public:
break;
}
- case WID_SL_SORTDROPBTN: {
+ case WID_STL_SORTDROPBTN: {
Dimension d = {0, 0};
for (int i = 0; this->sorter_names[i] != INVALID_STRING_ID; i++) {
d = maxdim(d, GetStringBoundingBox(this->sorter_names[i]));
@@ -373,23 +373,23 @@ public:
break;
}
- case WID_SL_LIST:
+ case WID_STL_LIST:
resize->height = FONT_HEIGHT_NORMAL;
size->height = WD_FRAMERECT_TOP + 5 * resize->height + WD_FRAMERECT_BOTTOM;
break;
- case WID_SL_TRAIN:
- case WID_SL_TRUCK:
- case WID_SL_BUS:
- case WID_SL_AIRPLANE:
- case WID_SL_SHIP:
+ case WID_STL_TRAIN:
+ case WID_STL_TRUCK:
+ case WID_STL_BUS:
+ case WID_STL_AIRPLANE:
+ case WID_STL_SHIP:
size->height = max<uint>(FONT_HEIGHT_SMALL, 10) + padding.height;
break;
- case WID_SL_CARGOALL:
- case WID_SL_FACILALL:
- case WID_SL_NOCARGOWAITING: {
- Dimension d = GetStringBoundingBox(widget == WID_SL_NOCARGOWAITING ? STR_ABBREV_NONE : STR_ABBREV_ALL);
+ case WID_STL_CARGOALL:
+ case WID_STL_FACILALL:
+ case WID_STL_NOCARGOWAITING: {
+ Dimension d = GetStringBoundingBox(widget == WID_STL_NOCARGOWAITING ? STR_ABBREV_NONE : STR_ABBREV_ALL);
d.width += padding.width + 2;
d.height += padding.height;
*size = maxdim(*size, d);
@@ -397,8 +397,8 @@ public:
}
default:
- if (widget >= WID_SL_CARGOSTART) {
- const CargoSpec *cs = CargoSpec::Get(widget - WID_SL_CARGOSTART);
+ if (widget >= WID_STL_CARGOSTART) {
+ const CargoSpec *cs = CargoSpec::Get(widget - WID_STL_CARGOSTART);
if (cs->IsValid()) {
Dimension d = GetStringBoundingBox(cs->abbrev);
d.width += padding.width + 2;
@@ -421,12 +421,12 @@ public:
virtual void DrawWidget(const Rect &r, int widget) const
{
switch (widget) {
- case WID_SL_SORTBY:
+ case WID_STL_SORTBY:
/* draw arrow pointing up/down for ascending/descending sorting */
- this->DrawSortButtonState(WID_SL_SORTBY, this->stations.IsDescSortOrder() ? SBS_DOWN : SBS_UP);
+ this->DrawSortButtonState(WID_STL_SORTBY, this->stations.IsDescSortOrder() ? SBS_DOWN : SBS_UP);
break;
- case WID_SL_LIST: {
+ case WID_STL_LIST: {
bool rtl = _current_text_dir == TD_RTL;
int max = min(this->vscroll->GetPosition() + this->vscroll->GetCapacity(), this->stations.Length());
int y = r.top + WD_FRAMERECT_TOP;
@@ -471,27 +471,27 @@ public:
break;
}
- case WID_SL_NOCARGOWAITING: {
+ case WID_STL_NOCARGOWAITING: {
int cg_ofst = this->IsWidgetLowered(widget) ? 2 : 1;
DrawString(r.left + cg_ofst, r.right + cg_ofst, r.top + cg_ofst, STR_ABBREV_NONE, TC_BLACK, SA_HOR_CENTER);
break;
}
- case WID_SL_CARGOALL: {
+ case WID_STL_CARGOALL: {
int cg_ofst = this->IsWidgetLowered(widget) ? 2 : 1;
DrawString(r.left + cg_ofst, r.right + cg_ofst, r.top + cg_ofst, STR_ABBREV_ALL, TC_BLACK, SA_HOR_CENTER);
break;
}
- case WID_SL_FACILALL: {
+ case WID_STL_FACILALL: {
int cg_ofst = this->IsWidgetLowered(widget) ? 2 : 1;
DrawString(r.left + cg_ofst, r.right + cg_ofst, r.top + cg_ofst, STR_ABBREV_ALL, TC_BLACK);
break;
}
default:
- if (widget >= WID_SL_CARGOSTART) {
- const CargoSpec *cs = CargoSpec::Get(widget - WID_SL_CARGOSTART);
+ if (widget >= WID_STL_CARGOSTART) {
+ const CargoSpec *cs = CargoSpec::Get(widget - WID_STL_CARGOSTART);
if (cs->IsValid()) {
int cg_ofst = HasBit(this->cargo_filter, cs->Index()) ? 2 : 1;
GfxFillRect(r.left + cg_ofst, r.top + cg_ofst, r.right - 2 + cg_ofst, r.bottom - 2 + cg_ofst, cs->rating_colour);
@@ -504,7 +504,7 @@ public:
virtual void SetStringParameters(int widget) const
{
- if (widget == WID_SL_CAPTION) {
+ if (widget == WID_STL_CAPTION) {
SetDParam(0, this->window_number);
SetDParam(1, this->vscroll->GetCount());
}
@@ -513,8 +513,8 @@ public:
virtual void OnClick(Point pt, int widget, int click_count)
{
switch (widget) {
- case WID_SL_LIST: {
- uint id_v = this->vscroll->GetScrolledRowFromWidget(pt.y, this, WID_SL_LIST, 0, FONT_HEIGHT_NORMAL);
+ case WID_STL_LIST: {
+ uint id_v = this->vscroll->GetScrolledRowFromWidget(pt.y, this, WID_STL_LIST, 0, FONT_HEIGHT_NORMAL);
if (id_v >= this->stations.Length()) return; // click out of list bound
const Station *st = this->stations[id_v];
@@ -529,28 +529,28 @@ public:
break;
}
- case WID_SL_TRAIN:
- case WID_SL_TRUCK:
- case WID_SL_BUS:
- case WID_SL_AIRPLANE:
- case WID_SL_SHIP:
+ case WID_STL_TRAIN:
+ case WID_STL_TRUCK:
+ case WID_STL_BUS:
+ case WID_STL_AIRPLANE:
+ case WID_STL_SHIP:
if (_ctrl_pressed) {
- ToggleBit(this->facilities, widget - WID_SL_TRAIN);
+ ToggleBit(this->facilities, widget - WID_STL_TRAIN);
this->ToggleWidgetLoweredState(widget);
} else {
uint i;
FOR_EACH_SET_BIT(i, this->facilities) {
- this->RaiseWidget(i + WID_SL_TRAIN);
+ this->RaiseWidget(i + WID_STL_TRAIN);
}
- this->facilities = 1 << (widget - WID_SL_TRAIN);
+ this->facilities = 1 << (widget - WID_STL_TRAIN);
this->LowerWidget(widget);
}
this->stations.ForceRebuild();
this->SetDirty();
break;
- case WID_SL_FACILALL:
- for (uint i = WID_SL_TRAIN; i <= WID_SL_SHIP; i++) {
+ case WID_STL_FACILALL:
+ for (uint i = WID_STL_TRAIN; i <= WID_STL_SHIP; i++) {
this->LowerWidget(i);
}
@@ -559,12 +559,12 @@ public:
this->SetDirty();
break;
- case WID_SL_CARGOALL: {
+ case WID_STL_CARGOALL: {
for (uint i = 0; i < NUM_CARGO; i++) {
const CargoSpec *cs = CargoSpec::Get(i);
- if (cs->IsValid()) this->LowerWidget(WID_SL_CARGOSTART + i);
+ if (cs->IsValid()) this->LowerWidget(WID_STL_CARGOSTART + i);
}
- this->LowerWidget(WID_SL_NOCARGOWAITING);
+ this->LowerWidget(WID_STL_NOCARGOWAITING);
this->cargo_filter = _cargo_mask;
this->include_empty = true;
@@ -573,40 +573,40 @@ public:
break;
}
- case WID_SL_SORTBY: // flip sorting method asc/desc
+ case WID_STL_SORTBY: // flip sorting method asc/desc
this->stations.ToggleSortOrder();
this->SetTimeout();
- this->LowerWidget(WID_SL_SORTBY);
+ this->LowerWidget(WID_STL_SORTBY);
this->SetDirty();
break;
- case WID_SL_SORTDROPBTN: // select sorting criteria dropdown menu
- ShowDropDownMenu(this, this->sorter_names, this->stations.SortType(), WID_SL_SORTDROPBTN, 0, 0);
+ case WID_STL_SORTDROPBTN: // select sorting criteria dropdown menu
+ ShowDropDownMenu(this, this->sorter_names, this->stations.SortType(), WID_STL_SORTDROPBTN, 0, 0);
break;
- case WID_SL_NOCARGOWAITING:
+ case WID_STL_NOCARGOWAITING:
if (_ctrl_pressed) {
this->include_empty = !this->include_empty;
- this->ToggleWidgetLoweredState(WID_SL_NOCARGOWAITING);
+ this->ToggleWidgetLoweredState(WID_STL_NOCARGOWAITING);
} else {
for (uint i = 0; i < NUM_CARGO; i++) {
const CargoSpec *cs = CargoSpec::Get(i);
- if (cs->IsValid()) this->RaiseWidget(WID_SL_CARGOSTART + i);
+ if (cs->IsValid()) this->RaiseWidget(WID_STL_CARGOSTART + i);
}
this->cargo_filter = 0;
this->include_empty = true;
- this->LowerWidget(WID_SL_NOCARGOWAITING);
+ this->LowerWidget(WID_STL_NOCARGOWAITING);
}
this->stations.ForceRebuild();
this->SetDirty();
break;
default:
- if (widget >= WID_SL_CARGOSTART) { // change cargo_filter
+ if (widget >= WID_STL_CARGOSTART) { // change cargo_filter
/* Determine the selected cargo type */
- const CargoSpec *cs = CargoSpec::Get(widget - WID_SL_CARGOSTART);
+ const CargoSpec *cs = CargoSpec::Get(widget - WID_STL_CARGOSTART);
if (!cs->IsValid()) break;
if (_ctrl_pressed) {
@@ -615,9 +615,9 @@ public:
} else {
for (uint i = 0; i < NUM_CARGO; i++) {
const CargoSpec *cs = CargoSpec::Get(i);
- if (cs->IsValid()) this->RaiseWidget(WID_SL_CARGOSTART + i);
+ if (cs->IsValid()) this->RaiseWidget(WID_STL_CARGOSTART + i);
}
- this->RaiseWidget(WID_SL_NOCARGOWAITING);
+ this->RaiseWidget(WID_STL_NOCARGOWAITING);
this->cargo_filter = 0;
this->include_empty = false;
@@ -638,7 +638,7 @@ public:
this->stations.SetSortType(index);
/* Display the current sort variant */
- this->GetWidget<NWidgetCore>(WID_SL_SORTDROPBTN)->widget_data = this->sorter_names[this->stations.SortType()];
+ this->GetWidget<NWidgetCore>(WID_STL_SORTDROPBTN)->widget_data = this->sorter_names[this->stations.SortType()];
this->SetDirty();
}
@@ -655,13 +655,13 @@ public:
virtual void OnTimeout()
{
- this->RaiseWidget(WID_SL_SORTBY);
+ this->RaiseWidget(WID_STL_SORTBY);
this->SetDirty();
}
virtual void OnResize()
{
- this->vscroll->SetCapacityFromWidget(this, WID_SL_LIST, WD_FRAMERECT_TOP + WD_FRAMERECT_BOTTOM);
+ this->vscroll->SetCapacityFromWidget(this, WID_STL_LIST, WD_FRAMERECT_TOP + WD_FRAMERECT_BOTTOM);
}
/**
@@ -707,7 +707,7 @@ const StringID CompanyStationsWindow::sorter_names[] = {
};
/**
- * Make a horizontal row of cargo buttons, starting at widget #WID_SL_CARGOSTART.
+ * Make a horizontal row of cargo buttons, starting at widget #WID_STL_CARGOSTART.
* @param biggest_index Pointer to store biggest used widget number of the buttons.
* @return Horizontal row.
*/
@@ -718,53 +718,53 @@ static NWidgetBase *CargoWidgets(int *biggest_index)
for (uint i = 0; i < NUM_CARGO; i++) {
const CargoSpec *cs = CargoSpec::Get(i);
if (cs->IsValid()) {
- NWidgetBackground *panel = new NWidgetBackground(WWT_PANEL, COLOUR_GREY, WID_SL_CARGOSTART + i);
+ NWidgetBackground *panel = new NWidgetBackground(WWT_PANEL, COLOUR_GREY, WID_STL_CARGOSTART + i);
panel->SetMinimalSize(14, 11);
panel->SetResize(0, 0);
panel->SetFill(0, 1);
panel->SetDataTip(0, STR_STATION_LIST_USE_CTRL_TO_SELECT_MORE);
container->Add(panel);
} else {
- NWidgetLeaf *nwi = new NWidgetLeaf(WWT_EMPTY, COLOUR_GREY, WID_SL_CARGOSTART + i, 0x0, STR_NULL);
+ NWidgetLeaf *nwi = new NWidgetLeaf(WWT_EMPTY, COLOUR_GREY, WID_STL_CARGOSTART + i, 0x0, STR_NULL);
nwi->SetMinimalSize(0, 11);
nwi->SetResize(0, 0);
nwi->SetFill(0, 1);
container->Add(nwi);
}
}
- *biggest_index = WID_SL_CARGOSTART + NUM_CARGO;
+ *biggest_index = WID_STL_CARGOSTART + NUM_CARGO;
return container;
}
static const NWidgetPart _nested_company_stations_widgets[] = {
NWidget(NWID_HORIZONTAL),
NWidget(WWT_CLOSEBOX, COLOUR_GREY),
- NWidget(WWT_CAPTION, COLOUR_GREY, WID_SL_CAPTION), SetDataTip(STR_STATION_LIST_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
+ NWidget(WWT_CAPTION, COLOUR_GREY, WID_STL_CAPTION), SetDataTip(STR_STATION_LIST_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
NWidget(WWT_SHADEBOX, COLOUR_GREY),
NWidget(WWT_STICKYBOX, COLOUR_GREY),
EndContainer(),
NWidget(NWID_HORIZONTAL),
- NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_SL_TRAIN), SetMinimalSize(14, 11), SetDataTip(STR_TRAIN, STR_STATION_LIST_USE_CTRL_TO_SELECT_MORE), SetFill(0, 1),
- NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_SL_TRUCK), SetMinimalSize(14, 11), SetDataTip(STR_LORRY, STR_STATION_LIST_USE_CTRL_TO_SELECT_MORE), SetFill(0, 1),
- NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_SL_BUS), SetMinimalSize(14, 11), SetDataTip(STR_BUS, STR_STATION_LIST_USE_CTRL_TO_SELECT_MORE), SetFill(0, 1),
- NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_SL_SHIP), SetMinimalSize(14, 11), SetDataTip(STR_SHIP, STR_STATION_LIST_USE_CTRL_TO_SELECT_MORE), SetFill(0, 1),
- NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_SL_AIRPLANE), SetMinimalSize(14, 11), SetDataTip(STR_PLANE, STR_STATION_LIST_USE_CTRL_TO_SELECT_MORE), SetFill(0, 1),
- NWidget(WWT_PUSHBTN, COLOUR_GREY, WID_SL_FACILALL), SetMinimalSize(14, 11), SetDataTip(0x0, STR_STATION_LIST_SELECT_ALL_FACILITIES), SetFill(0, 1),
+ NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_STL_TRAIN), SetMinimalSize(14, 11), SetDataTip(STR_TRAIN, STR_STATION_LIST_USE_CTRL_TO_SELECT_MORE), SetFill(0, 1),
+ NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_STL_TRUCK), SetMinimalSize(14, 11), SetDataTip(STR_LORRY, STR_STATION_LIST_USE_CTRL_TO_SELECT_MORE), SetFill(0, 1),
+ NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_STL_BUS), SetMinimalSize(14, 11), SetDataTip(STR_BUS, STR_STATION_LIST_USE_CTRL_TO_SELECT_MORE), SetFill(0, 1),
+ NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_STL_SHIP), SetMinimalSize(14, 11), SetDataTip(STR_SHIP, STR_STATION_LIST_USE_CTRL_TO_SELECT_MORE), SetFill(0, 1),
+ NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_STL_AIRPLANE), SetMinimalSize(14, 11), SetDataTip(STR_PLANE, STR_STATION_LIST_USE_CTRL_TO_SELECT_MORE), SetFill(0, 1),
+ NWidget(WWT_PUSHBTN, COLOUR_GREY, WID_STL_FACILALL), SetMinimalSize(14, 11), SetDataTip(0x0, STR_STATION_LIST_SELECT_ALL_FACILITIES), SetFill(0, 1),
NWidget(WWT_PANEL, COLOUR_GREY), SetMinimalSize(5, 11), SetFill(0, 1), EndContainer(),
NWidgetFunction(CargoWidgets),
- NWidget(WWT_PANEL, COLOUR_GREY, WID_SL_NOCARGOWAITING), SetMinimalSize(14, 11), SetDataTip(0x0, STR_STATION_LIST_NO_WAITING_CARGO), SetFill(0, 1), EndContainer(),
- NWidget(WWT_PUSHBTN, COLOUR_GREY, WID_SL_CARGOALL), SetMinimalSize(14, 11), SetDataTip(0x0, STR_STATION_LIST_SELECT_ALL_TYPES), SetFill(0, 1),
+ NWidget(WWT_PANEL, COLOUR_GREY, WID_STL_NOCARGOWAITING), SetMinimalSize(14, 11), SetDataTip(0x0, STR_STATION_LIST_NO_WAITING_CARGO), SetFill(0, 1), EndContainer(),
+ NWidget(WWT_PUSHBTN, COLOUR_GREY, WID_STL_CARGOALL), SetMinimalSize(14, 11), SetDataTip(0x0, STR_STATION_LIST_SELECT_ALL_TYPES), SetFill(0, 1),
NWidget(WWT_PANEL, COLOUR_GREY), SetDataTip(0x0, STR_NULL), SetResize(1, 0), SetFill(1, 1), EndContainer(),
EndContainer(),
NWidget(NWID_HORIZONTAL),
- NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_SL_SORTBY), SetMinimalSize(81, 12), SetDataTip(STR_BUTTON_SORT_BY, STR_TOOLTIP_SORT_ORDER),
- NWidget(WWT_DROPDOWN, COLOUR_GREY, WID_SL_SORTDROPBTN), SetMinimalSize(163, 12), SetDataTip(STR_SORT_BY_NAME, STR_TOOLTIP_SORT_CRITERIA), // widget_data gets overwritten.
+ NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_STL_SORTBY), SetMinimalSize(81, 12), SetDataTip(STR_BUTTON_SORT_BY, STR_TOOLTIP_SORT_ORDER),
+ NWidget(WWT_DROPDOWN, COLOUR_GREY, WID_STL_SORTDROPBTN), SetMinimalSize(163, 12), SetDataTip(STR_SORT_BY_NAME, STR_TOOLTIP_SORT_CRITERIA), // widget_data gets overwritten.
NWidget(WWT_PANEL, COLOUR_GREY), SetDataTip(0x0, STR_NULL), SetResize(1, 0), SetFill(1, 1), EndContainer(),
EndContainer(),
NWidget(NWID_HORIZONTAL),
- NWidget(WWT_PANEL, COLOUR_GREY, WID_SL_LIST), SetMinimalSize(346, 125), SetResize(1, 10), SetDataTip(0x0, STR_STATION_LIST_TOOLTIP), SetScrollbar(WID_SL_SCROLLBAR), EndContainer(),
+ NWidget(WWT_PANEL, COLOUR_GREY, WID_STL_LIST), SetMinimalSize(346, 125), SetResize(1, 10), SetDataTip(0x0, STR_STATION_LIST_TOOLTIP), SetScrollbar(WID_STL_SCROLLBAR), EndContainer(),
NWidget(NWID_VERTICAL),
- NWidget(NWID_VSCROLLBAR, COLOUR_GREY, WID_SL_SCROLLBAR),
+ NWidget(NWID_VSCROLLBAR, COLOUR_GREY, WID_STL_SCROLLBAR),
NWidget(WWT_RESIZEBOX, COLOUR_GREY),
EndContainer(),
EndContainer(),