From 0e42a7bac73bb55f8a740ccc1aef388677ad28e8 Mon Sep 17 00:00:00 2001 From: Yexo Date: Thu, 29 Jan 2009 02:42:36 +0000 Subject: [PATCH] (svn r15291) -Cleanup: Move the station list widgets to their class from station_gui.h -Fix: comment for ReallocT was wrong, the memory is not zeroed. --- src/core/alloc_func.hpp | 2 +- src/station_gui.cpp | 36 ++++++++++++++++++++++++++++++++---- src/station_gui.h | 25 ------------------------- 3 files changed, 33 insertions(+), 30 deletions(-) diff --git a/src/core/alloc_func.hpp b/src/core/alloc_func.hpp index f1e0f7ba8b..a5a730771c 100644 --- a/src/core/alloc_func.hpp +++ b/src/core/alloc_func.hpp @@ -69,7 +69,7 @@ static FORCEINLINE T *CallocT(size_t num_elements) * elements of the given type. It also explicitly casts it to the requested * type. It extends/shrinks the memory allocation given in t_ptr. * @note throws an error when there is no memory anymore. - * @note the memory contains all zero values. + * @note the pointer to the data may change, but the data will remain valid. * @param T the type of the variable(s) to allocation. * @param t_ptr the previous allocation to extend/shrink. * @param num_elements the number of elements to allocate of the given type. diff --git a/src/station_gui.cpp b/src/station_gui.cpp index f0bfae69dd..4cfdb6b901 100644 --- a/src/station_gui.cpp +++ b/src/station_gui.cpp @@ -93,6 +93,34 @@ typedef GUIList GUIStationList; */ class CompanyStationsWindow : public Window { + /** Enum for CompanyStations, referring to _company_stations_widgets */ + enum StationListWidgets { + SLW_CLOSEBOX = 0, ///< Close window button + SLW_CAPTION, ///< Window caption + SLW_STICKY, ///< Sticky button + SLW_LIST, ///< The main panel, list of stations + SLW_SCROLLBAR, ///< Scrollbar next to the main panel + SLW_RESIZE, ///< Resize button + + SLW_TRAIN, ///< 'TRAIN' button - list only facilities where is a railroad station + SLW_TRUCK, ///< 'TRUCK' button - list only facilities where is a truck stop + SLW_BUS, ///< 'BUS' button - list only facilities where is a bus stop + SLW_AIRPLANE, ///< 'AIRPLANE' button - list only facilities where is an airport + SLW_SHIP, ///< 'SHIP' button - list only facilities where is a dock + SLW_FACILALL, ///< 'ALL' button - list all facilities + + SLW_PAN_BETWEEN, ///< Small panel between list of types of ficilities and list of cargo types + SLW_NOCARGOWAITING, ///< 'NO' button - list stations where no cargo is waiting + SLW_CARGOALL, ///< 'ALL' button - list all stations + SLW_PAN_RIGHT, ///< Panel right of list of cargo types + + SLW_SORTBY, ///< 'Sort by' button - reverse sort direction + SLW_SORTDROPBTN, ///< Dropdown button + SLW_PAN_SORT_RIGHT, ///< Panel right of sorting options + + SLW_CARGOSTART, ///< Widget numbers used for list of cargo types (not present in _company_stations_widgets) + }; + protected: /* Runtime saved values */ static Listing last_sorting; @@ -570,11 +598,11 @@ const StringID CompanyStationsWindow::sorter_names[] = { static const Widget _company_stations_widgets[] = { { WWT_CLOSEBOX, RESIZE_NONE, COLOUR_GREY, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, // SLW_CLOSEBOX -{ WWT_CAPTION, RESIZE_RIGHT, COLOUR_GREY, 11, 345, 0, 13, STR_3048_STATIONS, STR_018C_WINDOW_TITLE_DRAG_THIS}, -{ WWT_STICKYBOX, RESIZE_LR, COLOUR_GREY, 346, 357, 0, 13, 0x0, STR_STICKY_BUTTON}, +{ WWT_CAPTION, RESIZE_RIGHT, COLOUR_GREY, 11, 345, 0, 13, STR_3048_STATIONS, STR_018C_WINDOW_TITLE_DRAG_THIS}, // SLW_CAPTION +{ WWT_STICKYBOX, RESIZE_LR, COLOUR_GREY, 346, 357, 0, 13, 0x0, STR_STICKY_BUTTON}, // SLW_STICKY { WWT_PANEL, RESIZE_RB, COLOUR_GREY, 0, 345, 37, 161, 0x0, STR_3057_STATION_NAMES_CLICK_ON}, // SLW_LIST -{ WWT_SCROLLBAR, RESIZE_LRB, COLOUR_GREY, 346, 357, 37, 149, 0x0, STR_0190_SCROLL_BAR_SCROLLS_LIST}, -{ WWT_RESIZEBOX, RESIZE_LRTB, COLOUR_GREY, 346, 357, 150, 161, 0x0, STR_RESIZE_BUTTON}, +{ WWT_SCROLLBAR, RESIZE_LRB, COLOUR_GREY, 346, 357, 37, 149, 0x0, STR_0190_SCROLL_BAR_SCROLLS_LIST}, // SLW_SCROLLBAR +{ WWT_RESIZEBOX, RESIZE_LRTB, COLOUR_GREY, 346, 357, 150, 161, 0x0, STR_RESIZE_BUTTON}, // SLW_RESIZE { WWT_TEXTBTN, RESIZE_NONE, COLOUR_GREY, 0, 13, 14, 24, STR_TRAIN, STR_USE_CTRL_TO_SELECT_MORE}, // SLW_TRAIN { WWT_TEXTBTN, RESIZE_NONE, COLOUR_GREY, 14, 27, 14, 24, STR_LORRY, STR_USE_CTRL_TO_SELECT_MORE}, // SLW_TRUCK diff --git a/src/station_gui.h b/src/station_gui.h index 1addc6ab9d..8efe3aae23 100644 --- a/src/station_gui.h +++ b/src/station_gui.h @@ -7,31 +7,6 @@ #include "command_type.h" -/** Enum for CompanyStations, referring to _company_stations_widgets */ -enum StationListWidgets { - SLW_CLOSEBOX = 0, ///< Close 'X' button - - SLW_LIST = 3, ///< The main panel, list of stations - - SLW_TRAIN = 6, ///< 'TRAIN' button - list only facilities where is a railroad station - SLW_TRUCK, - SLW_BUS, - SLW_AIRPLANE, - SLW_SHIP, - SLW_FACILALL, ///< 'ALL' button - list all facilities - - SLW_PAN_BETWEEN = 12, ///< Small panel between list of types of ficilities and list of cargo types - SLW_NOCARGOWAITING = 13, ///< 'NO' button - list stations where no cargo is waiting - SLW_CARGOALL = 14, ///< 'ALL' button - list all stations - SLW_PAN_RIGHT = 15, ///< Panel right of list of cargo types - - SLW_SORTBY = 16, ///< 'Sort by' button - reverse sort direction - SLW_SORTDROPBTN = 17, ///< Dropdown button - SLW_PAN_SORT_RIGHT = 18, ///< Panel right of sorting options - - SLW_CARGOSTART = 19, ///< Widget numbers used for list of cargo types (not present in _company_stations_widgets) -}; - /** Enum for StationView, referring to _station_view_widgets and _station_view_expanded_widgets */ enum StationViewWidgets { SVW_CLOSEBOX = 0, ///< Close 'X' button