From 8bfbfd0031bd155440432759cd6b2af0df1bccbd Mon Sep 17 00:00:00 2001 From: rubidium Date: Wed, 19 Dec 2007 19:44:29 +0000 Subject: (svn r11667) -Codechange: split window.h into a header that defines some 'global' window related types, on that defined 'global' window functions and one that defines functions and types only used by *_gui.cpps. --- src/aircraft_gui.cpp | 1 - src/airport_gui.cpp | 1 - src/autoreplace_gui.cpp | 1 - src/bridge_gui.cpp | 1 - src/build_vehicle_gui.cpp | 1 - src/console.cpp | 1 - src/console.h | 2 + src/dock_gui.cpp | 1 - src/economy.cpp | 1 - src/engine_gui.cpp | 1 - src/genworld_gui.cpp | 1 - src/graph_gui.cpp | 1 - src/group_cmd.cpp | 1 - src/group_gui.cpp | 1 - src/gui.h | 2 +- src/industry_gui.cpp | 1 - src/intro_gui.cpp | 1 - src/main_gui.cpp | 1 - src/misc_cmd.cpp | 1 - src/misc_gui.cpp | 1 - src/music_gui.cpp | 2 +- src/network/network_client.cpp | 1 - src/network/network_gui.cpp | 1 - src/newgrf_gui.cpp | 1 - src/news.h | 2 + src/news_gui.cpp | 1 - src/openttd.cpp | 2 +- src/openttd.h | 87 ----- src/order_gui.cpp | 1 - src/player_gui.cpp | 1 - src/players.cpp | 2 +- src/rail_cmd.cpp | 2 +- src/rail_gui.cpp | 1 - src/road_cmd.cpp | 2 +- src/road_gui.cpp | 1 - src/roadveh_gui.cpp | 1 - src/settings.cpp | 1 - src/settings_gui.cpp | 1 - src/signs_gui.cpp | 1 - src/smallmap_gui.cpp | 1 - src/sound.cpp | 2 +- src/station.cpp | 1 - src/station_cmd.cpp | 2 +- src/station_gui.cpp | 1 - src/subsidy_gui.cpp | 2 +- src/terraform_gui.cpp | 1 - src/timetable_gui.cpp | 1 - src/town_gui.cpp | 1 - src/train_gui.cpp | 1 - src/transparency_gui.cpp | 1 - src/unix.cpp | 2 +- src/vehicle.h | 1 + src/vehicle_gui.cpp | 1 - src/vehicle_gui.h | 2 +- src/video/dedicated_v.cpp | 1 - src/video/null_v.cpp | 1 - src/video/sdl_v.cpp | 2 - src/video/win32_v.cpp | 2 - src/viewport.cpp | 1 - src/viewport.h | 1 + src/widget.cpp | 2 +- src/win32.cpp | 1 - src/window.cpp | 2 +- src/window.h | 830 ----------------------------------------- src/window_func.h | 40 ++ src/window_gui.h | 830 +++++++++++++++++++++++++++++++++++++++++ src/window_type.h | 98 +++++ 67 files changed, 987 insertions(+), 977 deletions(-) delete mode 100644 src/window.h create mode 100644 src/window_func.h create mode 100644 src/window_gui.h create mode 100644 src/window_type.h (limited to 'src') diff --git a/src/aircraft_gui.cpp b/src/aircraft_gui.cpp index dbc6ee251..750db29ee 100644 --- a/src/aircraft_gui.cpp +++ b/src/aircraft_gui.cpp @@ -11,7 +11,6 @@ #include "table/strings.h" #include "strings.h" #include "map.h" -#include "window.h" #include "gui.h" #include "vehicle.h" #include "gfx.h" diff --git a/src/airport_gui.cpp b/src/airport_gui.cpp index ef456e144..f70ee4582 100644 --- a/src/airport_gui.cpp +++ b/src/airport_gui.cpp @@ -8,7 +8,6 @@ #include "table/strings.h" #include "functions.h" #include "map.h" -#include "window.h" #include "gui.h" #include "viewport.h" #include "gfx.h" diff --git a/src/autoreplace_gui.cpp b/src/autoreplace_gui.cpp index a91c0f431..9d4acfeaa 100644 --- a/src/autoreplace_gui.cpp +++ b/src/autoreplace_gui.cpp @@ -9,7 +9,6 @@ #include "table/sprites.h" #include "table/strings.h" #include "strings.h" -#include "window.h" #include "gui.h" #include "command.h" #include "variables.h" diff --git a/src/bridge_gui.cpp b/src/bridge_gui.cpp index 85757bdf7..e1f4036c2 100644 --- a/src/bridge_gui.cpp +++ b/src/bridge_gui.cpp @@ -8,7 +8,6 @@ #include "strings.h" #include "functions.h" #include "map.h" -#include "window.h" #include "gui.h" #include "viewport.h" #include "gfx.h" diff --git a/src/build_vehicle_gui.cpp b/src/build_vehicle_gui.cpp index 81c6652d4..b6e546877 100644 --- a/src/build_vehicle_gui.cpp +++ b/src/build_vehicle_gui.cpp @@ -12,7 +12,6 @@ #include "functions.h" #include "table/sprites.h" #include "table/strings.h" -#include "window.h" #include "gui.h" #include "vehicle.h" #include "articulated_vehicles.h" diff --git a/src/console.cpp b/src/console.cpp index 78f6f1143..fca19fbc5 100644 --- a/src/console.cpp +++ b/src/console.cpp @@ -6,7 +6,6 @@ #include "openttd.h" #include "table/strings.h" #include "functions.h" -#include "window.h" #include "gui.h" #include "gfx.h" #include "player.h" diff --git a/src/console.h b/src/console.h index 3a58716f0..4030c3851 100644 --- a/src/console.h +++ b/src/console.h @@ -5,6 +5,8 @@ #ifndef CONSOLE_H #define CONSOLE_H +#include "window_type.h" + /* maximum length of a typed in command */ #define ICON_CMDLN_SIZE 255 /* maximum length of a totally expanded command */ diff --git a/src/dock_gui.cpp b/src/dock_gui.cpp index 781b16a5f..8aa11a551 100644 --- a/src/dock_gui.cpp +++ b/src/dock_gui.cpp @@ -8,7 +8,6 @@ #include "table/strings.h" #include "functions.h" #include "map.h" -#include "window.h" #include "station.h" #include "gui.h" #include "viewport.h" diff --git a/src/economy.cpp b/src/economy.cpp index 5b4f108c5..eae326ddb 100644 --- a/src/economy.cpp +++ b/src/economy.cpp @@ -15,7 +15,6 @@ #include "player.h" #include "station.h" #include "vehicle.h" -#include "window.h" #include "gfx.h" #include "command.h" #include "saveload.h" diff --git a/src/engine_gui.cpp b/src/engine_gui.cpp index 380b25997..288fc54e0 100644 --- a/src/engine_gui.cpp +++ b/src/engine_gui.cpp @@ -8,7 +8,6 @@ #include "strings.h" #include "table/sprites.h" #include "functions.h" -#include "window.h" #include "gui.h" #include "viewport.h" #include "gfx.h" diff --git a/src/genworld_gui.cpp b/src/genworld_gui.cpp index 82f263705..3380e0373 100644 --- a/src/genworld_gui.cpp +++ b/src/genworld_gui.cpp @@ -8,7 +8,6 @@ #include "functions.h" #include "table/strings.h" #include "table/sprites.h" -#include "window.h" #include "gui.h" #include "gfx.h" #include "strings.h" diff --git a/src/graph_gui.cpp b/src/graph_gui.cpp index ddabf882d..1f9d0e8fe 100644 --- a/src/graph_gui.cpp +++ b/src/graph_gui.cpp @@ -8,7 +8,6 @@ #include "strings.h" #include "table/sprites.h" #include "functions.h" -#include "window.h" #include "gui.h" #include "gfx.h" #include "player.h" diff --git a/src/group_cmd.cpp b/src/group_cmd.cpp index bb31c9d37..f0e4de372 100644 --- a/src/group_cmd.cpp +++ b/src/group_cmd.cpp @@ -16,7 +16,6 @@ #include "train.h" #include "aircraft.h" #include "string.h" -#include "window.h" #include "vehicle_gui.h" #include "strings.h" #include "misc/autoptr.hpp" diff --git a/src/group_gui.cpp b/src/group_gui.cpp index ce4742a92..a665b99d8 100644 --- a/src/group_gui.cpp +++ b/src/group_gui.cpp @@ -7,7 +7,6 @@ #include "functions.h" #include "table/strings.h" #include "table/sprites.h" -#include "window.h" #include "gui.h" #include "gfx.h" #include "vehicle.h" diff --git a/src/gui.h b/src/gui.h index 4b189804b..8e6531931 100644 --- a/src/gui.h +++ b/src/gui.h @@ -6,7 +6,7 @@ #define GUI_H #include "station.h" -#include "window.h" +#include "window_gui.h" #include "string.h" /* main_gui.cpp */ diff --git a/src/industry_gui.cpp b/src/industry_gui.cpp index 1154b0a1d..727a52f5c 100644 --- a/src/industry_gui.cpp +++ b/src/industry_gui.cpp @@ -11,7 +11,6 @@ #include "table/sprites.h" #include "map.h" #include "gui.h" -#include "window.h" #include "gfx.h" #include "command.h" #include "viewport.h" diff --git a/src/intro_gui.cpp b/src/intro_gui.cpp index 488ac2892..802783fd2 100644 --- a/src/intro_gui.cpp +++ b/src/intro_gui.cpp @@ -8,7 +8,6 @@ #include "strings.h" #include "table/sprites.h" #include "functions.h" -#include "window.h" #include "gui.h" #include "gfx.h" #include "player.h" diff --git a/src/main_gui.cpp b/src/main_gui.cpp index 100d0f455..5e0f61998 100644 --- a/src/main_gui.cpp +++ b/src/main_gui.cpp @@ -14,7 +14,6 @@ #include "table/strings.h" #include "map.h" #include "tile.h" -#include "window.h" #include "gui.h" #include "viewport.h" #include "gfx.h" diff --git a/src/misc_cmd.cpp b/src/misc_cmd.cpp index cd42c5907..74fb31302 100644 --- a/src/misc_cmd.cpp +++ b/src/misc_cmd.cpp @@ -10,7 +10,6 @@ #include "command.h" #include "player.h" #include "gfx.h" -#include "window.h" #include "gui.h" #include "economy.h" #include "network/network.h" diff --git a/src/misc_gui.cpp b/src/misc_gui.cpp index da0fbb762..812f7e1ac 100644 --- a/src/misc_gui.cpp +++ b/src/misc_gui.cpp @@ -17,7 +17,6 @@ #include "strings.h" #include "table/tree_land.h" #include "map.h" -#include "window.h" #include "gui.h" #include "viewport.h" #include "gfx.h" diff --git a/src/music_gui.cpp b/src/music_gui.cpp index d97048610..0b383d5e6 100644 --- a/src/music_gui.cpp +++ b/src/music_gui.cpp @@ -9,13 +9,13 @@ #include "strings.h" #include "functions.h" #include "fileio.h" -#include "window.h" #include "gfx.h" #include "sound.h" #include "macros.h" #include "variables.h" #include "music.h" #include "music/music_driver.hpp" +#include "window_gui.h" static byte _music_wnd_cursong; static bool _song_is_active; diff --git a/src/network/network_client.cpp b/src/network/network_client.cpp index 7c27e0b46..fcc2824e9 100644 --- a/src/network/network_client.cpp +++ b/src/network/network_client.cpp @@ -17,7 +17,6 @@ #include "network_gui.h" #include "../saveload.h" #include "../command.h" -#include "../window.h" #include "../console.h" #include "../variables.h" #include "../ai/ai.h" diff --git a/src/network/network_gui.cpp b/src/network/network_gui.cpp index 876f74df0..70372d8bc 100644 --- a/src/network/network_gui.cpp +++ b/src/network/network_gui.cpp @@ -16,7 +16,6 @@ #include "network_client.h" #include "network_gui.h" #include "network_gamelist.h" -#include "../window.h" #include "../gui.h" #include "../gfx.h" #include "../command.h" diff --git a/src/newgrf_gui.cpp b/src/newgrf_gui.cpp index fbd4934a7..710d9e5ac 100644 --- a/src/newgrf_gui.cpp +++ b/src/newgrf_gui.cpp @@ -8,7 +8,6 @@ #include "variables.h" #include "gfx.h" #include "gui.h" -#include "window.h" #include "table/strings.h" #include "table/sprites.h" #include "newgrf.h" diff --git a/src/news.h b/src/news.h index 436f2e40f..1330f9aa1 100644 --- a/src/news.h +++ b/src/news.h @@ -5,6 +5,8 @@ #ifndef NEWS_H #define NEWS_H +#include "window_type.h" + struct NewsItem { StringID string_id; ///< Message text (sometimes also used for storing other info) uint16 duration; ///< Remaining time for showing this news message diff --git a/src/news_gui.cpp b/src/news_gui.cpp index 859786c12..28d34238f 100644 --- a/src/news_gui.cpp +++ b/src/news_gui.cpp @@ -7,7 +7,6 @@ #include "strings.h" #include "table/sprites.h" #include "table/strings.h" -#include "window.h" #include "gui.h" #include "viewport.h" #include "gfx.h" diff --git a/src/openttd.cpp b/src/openttd.cpp index af80a9dd1..2f5250999 100644 --- a/src/openttd.cpp +++ b/src/openttd.cpp @@ -31,7 +31,7 @@ #include "tunnel_map.h" #include "vehicle.h" #include "viewport.h" -#include "window.h" +#include "window_gui.h" #include "player.h" #include "command.h" #include "town.h" diff --git a/src/openttd.h b/src/openttd.h index 6ca6fc8a7..ec68bf914 100644 --- a/src/openttd.h +++ b/src/openttd.h @@ -32,7 +32,6 @@ struct Pair { struct Vehicle; struct Depot; struct Waypoint; -struct Window; struct Station; struct ViewPort; struct Town; @@ -80,7 +79,6 @@ assert_compile(sizeof(DestinationID) == sizeof(DepotID)); assert_compile(sizeof(DestinationID) == sizeof(WaypointID)); assert_compile(sizeof(DestinationID) == sizeof(StationID)); -typedef int32 WindowNumber; enum { INVALID_YEAR = -1, @@ -500,91 +498,6 @@ struct TileTypeProcs { }; -enum WindowClass { - WC_NONE, - WC_MAIN_WINDOW = WC_NONE, - WC_MAIN_TOOLBAR, - WC_STATUS_BAR, - WC_BUILD_TOOLBAR, - WC_NEWS_WINDOW, - WC_TOWN_DIRECTORY, - WC_STATION_LIST, - WC_TOWN_VIEW, - WC_SMALLMAP, - WC_TRAINS_LIST, - WC_ROADVEH_LIST, - WC_SHIPS_LIST, - WC_AIRCRAFT_LIST, - WC_VEHICLE_VIEW, - WC_VEHICLE_DETAILS, - WC_VEHICLE_REFIT, - WC_VEHICLE_ORDERS, - WC_STATION_VIEW, - WC_VEHICLE_DEPOT, - WC_BUILD_VEHICLE, - WC_BUILD_BRIDGE, - WC_ERRMSG, - WC_BUILD_STATION, - WC_BUS_STATION, - WC_TRUCK_STATION, - WC_BUILD_DEPOT, - WC_COMPANY, - WC_FINANCES, - WC_PLAYER_COLOR, - WC_QUERY_STRING, - WC_SAVELOAD, - WC_SELECT_GAME, - WC_TOOLBAR_MENU, - WC_INCOME_GRAPH, - WC_OPERATING_PROFIT, - WC_TOOLTIPS, - WC_INDUSTRY_VIEW, - WC_PLAYER_FACE, - WC_LAND_INFO, - WC_TOWN_AUTHORITY, - WC_SUBSIDIES_LIST, - WC_GRAPH_LEGEND, - WC_DELIVERED_CARGO, - WC_PERFORMANCE_HISTORY, - WC_COMPANY_VALUE, - WC_COMPANY_LEAGUE, - WC_BUY_COMPANY, - WC_PAYMENT_RATES, - WC_ENGINE_PREVIEW, - WC_MUSIC_WINDOW, - WC_MUSIC_TRACK_SELECTION, - WC_SCEN_LAND_GEN, - WC_SCEN_TOWN_GEN, - WC_SCEN_INDUSTRY, - WC_SCEN_BUILD_ROAD, - WC_BUILD_TREES, - WC_SEND_NETWORK_MSG, - WC_DROPDOWN_MENU, - WC_BUILD_INDUSTRY, - WC_GAME_OPTIONS, - WC_NETWORK_WINDOW, - WC_INDUSTRY_DIRECTORY, - WC_MESSAGE_HISTORY, - WC_CHEATS, - WC_PERFORMANCE_DETAIL, - WC_CONSOLE, - WC_EXTRA_VIEW_PORT, - WC_CLIENT_LIST, - WC_NETWORK_STATUS_WINDOW, - WC_CUSTOM_CURRENCY, - WC_REPLACE_VEHICLE, - WC_HIGHSCORE, - WC_ENDSCREEN, - WC_SIGN_LIST, - WC_GENERATE_LANDSCAPE, - WC_GENERATE_PROGRESS_WINDOW, - WC_CONFIRM_POPUP_QUERY, - WC_TRANSPARENCY_TOOLBAR, - WC_VEHICLE_TIMETABLE, - WC_BUILD_SIGNAL, - WC_COMPANY_PASSWORD_WINDOW, -}; - enum ExpensesType { EXPENSES_CONSTRUCTION = 0, diff --git a/src/order_gui.cpp b/src/order_gui.cpp index 105ee842d..80438ef7d 100644 --- a/src/order_gui.cpp +++ b/src/order_gui.cpp @@ -12,7 +12,6 @@ #include "functions.h" #include "map.h" #include "tile.h" -#include "window.h" #include "gui.h" #include "gfx.h" #include "vehicle.h" diff --git a/src/player_gui.cpp b/src/player_gui.cpp index d296ed6d8..bec52e1a0 100644 --- a/src/player_gui.cpp +++ b/src/player_gui.cpp @@ -8,7 +8,6 @@ #include "table/strings.h" #include "strings.h" #include "functions.h" -#include "window.h" #include "gui.h" #include "viewport.h" #include "gfx.h" diff --git a/src/players.cpp b/src/players.cpp index 7f9b5ff7f..9f6ce32fd 100644 --- a/src/players.cpp +++ b/src/players.cpp @@ -25,10 +25,10 @@ #include "engine.h" #include "ai/ai.h" #include "date.h" -#include "window.h" #include "player_face.h" #include "group.h" #include "settings.h" +#include "window_func.h" /** * Sets the local player and updates the patch settings that are set on a diff --git a/src/rail_cmd.cpp b/src/rail_cmd.cpp index 15146f5e5..bca945341 100644 --- a/src/rail_cmd.cpp +++ b/src/rail_cmd.cpp @@ -29,7 +29,6 @@ #include "sprite.h" #include "depot.h" #include "waypoint.h" -#include "window.h" #include "rail.h" #include "railtypes.h" // include table for railtypes #include "newgrf.h" @@ -43,6 +42,7 @@ #include "transparency.h" #include "water.h" #include "tunnelbridge_map.h" +#include "window_func.h" const byte _track_sloped_sprites[14] = { diff --git a/src/rail_gui.cpp b/src/rail_gui.cpp index 2b48d7a23..3dde487de 100644 --- a/src/rail_gui.cpp +++ b/src/rail_gui.cpp @@ -12,7 +12,6 @@ #include "date.h" #include "map.h" #include "tile.h" -#include "window.h" #include "gui.h" #include "viewport.h" #include "gfx.h" diff --git a/src/road_cmd.cpp b/src/road_cmd.cpp index 26b016e7d..e1c362a04 100644 --- a/src/road_cmd.cpp +++ b/src/road_cmd.cpp @@ -15,7 +15,6 @@ #include "table/strings.h" #include "strings.h" #include "functions.h" -#include "window.h" #include "map.h" #include "landscape.h" #include "tile.h" @@ -36,6 +35,7 @@ #include "autoslope.h" #include "transparency.h" #include "tunnelbridge_map.h" +#include "window_func.h" #define M(x) (1 << (x)) diff --git a/src/road_gui.cpp b/src/road_gui.cpp index c6eeedf57..1204bf314 100644 --- a/src/road_gui.cpp +++ b/src/road_gui.cpp @@ -10,7 +10,6 @@ #include "functions.h" #include "map.h" #include "tile.h" -#include "window.h" #include "gui.h" #include "viewport.h" #include "gfx.h" diff --git a/src/roadveh_gui.cpp b/src/roadveh_gui.cpp index 97aa325af..86ca4e142 100644 --- a/src/roadveh_gui.cpp +++ b/src/roadveh_gui.cpp @@ -9,7 +9,6 @@ #include "roadveh.h" #include "table/sprites.h" #include "table/strings.h" -#include "window.h" #include "gui.h" #include "strings.h" #include "vehicle.h" diff --git a/src/settings.cpp b/src/settings.cpp index 6e94cebea..98be97da0 100644 --- a/src/settings.cpp +++ b/src/settings.cpp @@ -1085,7 +1085,6 @@ static void ini_save_setting_list(IniFile *ini, const char *grpname, char **list #include "table/strings.h" /* Begin - Callback Functions for the various settings */ -#include "window.h" #include "gui.h" #include "town.h" #include "gfx.h" diff --git a/src/settings_gui.cpp b/src/settings_gui.cpp index f584e8541..14f82c59d 100644 --- a/src/settings_gui.cpp +++ b/src/settings_gui.cpp @@ -10,7 +10,6 @@ #include "strings.h" // XXX GetCurrentCurrencyRate() #include "table/sprites.h" #include "table/strings.h" -#include "window.h" #include "gui.h" #include "gfx.h" #include "command.h" diff --git a/src/signs_gui.cpp b/src/signs_gui.cpp index 0397ce49f..d8d9a12ae 100644 --- a/src/signs_gui.cpp +++ b/src/signs_gui.cpp @@ -7,7 +7,6 @@ #include "table/strings.h" #include "table/sprites.h" #include "functions.h" -#include "window.h" #include "gui.h" #include "gfx.h" #include "player.h" diff --git a/src/smallmap_gui.cpp b/src/smallmap_gui.cpp index 2208128b7..3b6d46972 100644 --- a/src/smallmap_gui.cpp +++ b/src/smallmap_gui.cpp @@ -19,7 +19,6 @@ #include "gui.h" #include "tree_map.h" #include "tunnel_map.h" -#include "window.h" #include "gfx.h" #include "viewport.h" #include "player.h" diff --git a/src/sound.cpp b/src/sound.cpp index 312484c42..0e8acfc3c 100644 --- a/src/sound.cpp +++ b/src/sound.cpp @@ -10,12 +10,12 @@ #include "mixer.h" #include "sound.h" #include "vehicle.h" -#include "window.h" #include "viewport.h" #include "fileio.h" #include "newgrf_sound.h" #include "helpers.hpp" #include "fios.h" +#include "window_gui.h" static uint _file_count; static FileEntry *_files; diff --git a/src/station.cpp b/src/station.cpp index 2f69b1bac..326521d8e 100644 --- a/src/station.cpp +++ b/src/station.cpp @@ -14,7 +14,6 @@ #include "tile.h" #include "station.h" #include "gfx.h" -#include "window.h" #include "viewport.h" #include "command.h" #include "town.h" diff --git a/src/station_cmd.cpp b/src/station_cmd.cpp index 38a1af494..3b64116fe 100644 --- a/src/station_cmd.cpp +++ b/src/station_cmd.cpp @@ -4,6 +4,7 @@ #include "stdafx.h" #include "openttd.h" +#include "string.h" #include "aircraft.h" #include "bridge_map.h" #include "cmd_helper.h" @@ -17,7 +18,6 @@ #include "tile.h" #include "station.h" #include "gfx.h" -#include "window.h" #include "viewport.h" #include "command.h" #include "town.h" diff --git a/src/station_gui.cpp b/src/station_gui.cpp index 9cc342830..36c9948d7 100644 --- a/src/station_gui.cpp +++ b/src/station_gui.cpp @@ -8,7 +8,6 @@ #include "functions.h" #include "strings.h" #include "table/strings.h" -#include "window.h" #include "gui.h" #include "station.h" #include "gfx.h" diff --git a/src/subsidy_gui.cpp b/src/subsidy_gui.cpp index 0379ab29b..91cfceb81 100644 --- a/src/subsidy_gui.cpp +++ b/src/subsidy_gui.cpp @@ -7,7 +7,6 @@ #include "table/strings.h" #include "strings.h" #include "functions.h" -#include "window.h" #include "station.h" #include "industry.h" #include "town.h" @@ -17,6 +16,7 @@ #include "variables.h" #include "date.h" #include "cargotype.h" +#include "window_gui.h" static void HandleSubsidyClick(int y) { diff --git a/src/terraform_gui.cpp b/src/terraform_gui.cpp index 115eb5de5..42f289e28 100644 --- a/src/terraform_gui.cpp +++ b/src/terraform_gui.cpp @@ -11,7 +11,6 @@ #include "functions.h" #include "player.h" #include "tile.h" -#include "window.h" #include "gui.h" #include "viewport.h" #include "gfx.h" diff --git a/src/timetable_gui.cpp b/src/timetable_gui.cpp index 4a3f91927..d18e88194 100644 --- a/src/timetable_gui.cpp +++ b/src/timetable_gui.cpp @@ -13,7 +13,6 @@ #include "engine.h" #include "gui.h" #include "string.h" -#include "window.h" #include "vehicle.h" #include "cargotype.h" #include "depot.h" diff --git a/src/town_gui.cpp b/src/town_gui.cpp index ebfd06278..cdf6da858 100644 --- a/src/town_gui.cpp +++ b/src/town_gui.cpp @@ -10,7 +10,6 @@ #include "table/sprites.h" #include "table/strings.h" #include "town.h" -#include "window.h" #include "gfx.h" #include "viewport.h" #include "gui.h" diff --git a/src/train_gui.cpp b/src/train_gui.cpp index 419e6bb26..7692b1e24 100644 --- a/src/train_gui.cpp +++ b/src/train_gui.cpp @@ -9,7 +9,6 @@ #include "table/sprites.h" #include "table/strings.h" #include "strings.h" -#include "window.h" #include "gui.h" #include "vehicle.h" #include "viewport.h" diff --git a/src/transparency_gui.cpp b/src/transparency_gui.cpp index 1dd64a32e..5b0fe21b1 100644 --- a/src/transparency_gui.cpp +++ b/src/transparency_gui.cpp @@ -5,7 +5,6 @@ #include "table/sprites.h" #include "table/strings.h" #include "functions.h" -#include "window.h" #include "gui.h" #include "viewport.h" #include "gfx.h" diff --git a/src/unix.cpp b/src/unix.cpp index 0dc98d63c..521f51368 100644 --- a/src/unix.cpp +++ b/src/unix.cpp @@ -5,10 +5,10 @@ #include "stdafx.h" #include "openttd.h" #include "functions.h" -#include "window.h" #include "string.h" #include "table/strings.h" #include "variables.h" +#include "gui.h" #include #include diff --git a/src/vehicle.h b/src/vehicle.h index 0bc0fb0d9..48c507f15 100644 --- a/src/vehicle.h +++ b/src/vehicle.h @@ -10,6 +10,7 @@ #include "track_type.h" #include "rail_type.h" #include "road_type.h" +#include "window_type.h" #include "cargopacket.h" #include "texteff.hpp" diff --git a/src/vehicle_gui.cpp b/src/vehicle_gui.cpp index 2aa2f193e..629827d98 100644 --- a/src/vehicle_gui.cpp +++ b/src/vehicle_gui.cpp @@ -12,7 +12,6 @@ #include "table/sprites.h" #include "table/strings.h" #include "vehicle.h" -#include "window.h" #include "engine.h" #include "gui.h" #include "command.h" diff --git a/src/vehicle_gui.h b/src/vehicle_gui.h index b9cfba174..fe9235c04 100644 --- a/src/vehicle_gui.h +++ b/src/vehicle_gui.h @@ -5,7 +5,7 @@ #ifndef VEHICLE_GUI_H #define VEHICLE_GUI_H -#include "window.h" +#include "window_gui.h" #include "vehicle.h" void DrawVehicleProfitButton(const Vehicle *v, int x, int y); diff --git a/src/video/dedicated_v.cpp b/src/video/dedicated_v.cpp index 0d4afae5f..f2d2aecab 100644 --- a/src/video/dedicated_v.cpp +++ b/src/video/dedicated_v.cpp @@ -9,7 +9,6 @@ #include "../functions.h" #include "../gfx.h" #include "../network/network.h" -#include "../window.h" #include "../console.h" #include "../variables.h" #include "../genworld.h" diff --git a/src/video/null_v.cpp b/src/video/null_v.cpp index 81eed708c..2250cbaf0 100644 --- a/src/video/null_v.cpp +++ b/src/video/null_v.cpp @@ -4,7 +4,6 @@ #include "../openttd.h" #include "../gfx.h" #include "../variables.h" -#include "../window.h" #include "../debug.h" #include "../blitter/factory.hpp" #include "null_v.h" diff --git a/src/video/sdl_v.cpp b/src/video/sdl_v.cpp index c0cd58ef6..e1130c3ae 100644 --- a/src/video/sdl_v.cpp +++ b/src/video/sdl_v.cpp @@ -10,8 +10,6 @@ #include "../gfx.h" #include "../macros.h" #include "../sdl.h" -#include "../window.h" -#include "../network/network.h" #include "../variables.h" #include "../blitter/factory.hpp" #include "sdl_v.h" diff --git a/src/video/win32_v.cpp b/src/video/win32_v.cpp index b742bbfd3..0b8305a0d 100644 --- a/src/video/win32_v.cpp +++ b/src/video/win32_v.cpp @@ -5,10 +5,8 @@ #include "../functions.h" #include "../gfx.h" #include "../macros.h" -#include "../network/network.h" #include "../variables.h" #include "../win32.h" -#include "../window.h" #include "../blitter/factory.hpp" #include "win32_v.h" #include diff --git a/src/viewport.cpp b/src/viewport.cpp index aac54aeb3..1021a6cd9 100644 --- a/src/viewport.cpp +++ b/src/viewport.cpp @@ -14,7 +14,6 @@ #include "landscape.h" #include "map.h" #include "viewport.h" -#include "window.h" #include "vehicle.h" #include "station.h" #include "gfx.h" diff --git a/src/viewport.h b/src/viewport.h index b1bba7d4d..9cff8861d 100644 --- a/src/viewport.h +++ b/src/viewport.h @@ -6,6 +6,7 @@ #define VIEWPORT_H #include "zoom.hpp" +#include "window_type.h" struct ViewPort { int left,top; // screen coordinates for the viewport diff --git a/src/widget.cpp b/src/widget.cpp index 59ab2433b..a1a62d127 100644 --- a/src/widget.cpp +++ b/src/widget.cpp @@ -8,9 +8,9 @@ #include "player.h" #include "table/sprites.h" #include "table/strings.h" -#include "window.h" #include "gfx.h" #include "viewport.h" +#include "window_gui.h" static Point HandleScrollbarHittest(const Scrollbar *sb, int top, int bottom) { diff --git a/src/win32.cpp b/src/win32.cpp index b1e143d4f..98452773a 100644 --- a/src/win32.cpp +++ b/src/win32.cpp @@ -11,7 +11,6 @@ #include "saveload.h" #include "string.h" #include "gfx.h" -#include "window.h" #include "fileio.h" #include #include diff --git a/src/window.cpp b/src/window.cpp index f5b9ac041..5f05dfe89 100644 --- a/src/window.cpp +++ b/src/window.cpp @@ -9,7 +9,6 @@ #include "functions.h" #include "map.h" #include "player.h" -#include "window.h" #include "gfx.h" #include "viewport.h" #include "console.h" @@ -18,6 +17,7 @@ #include "genworld.h" #include "helpers.hpp" #include "blitter/factory.hpp" +#include "window_gui.h" /* delta between mouse cursor and upper left corner of dragged window */ static Point _drag_delta; diff --git a/src/window.h b/src/window.h deleted file mode 100644 index 403b2268e..000000000 --- a/src/window.h +++ /dev/null @@ -1,830 +0,0 @@ -/* $Id$ */ - -/** @file window.h regroups declarations for all windowing system, as well as a few helper functions */ - -#ifndef WINDOW_H -#define WINDOW_H - -#include "macros.h" -#include "string.h" -#include "order.h" -#include "rail_type.h" -#include "road_type.h" -#include "airport.h" -#include "vehicle.h" -#include "viewport.h" - -/** - * The maximum number of windows that can be opened. - */ -static const int MAX_NUMBER_OF_WINDOWS = 25; - -struct WindowEvent; - -typedef void WindowProc(Window *w, WindowEvent *e); - -/* How the resize system works: - First, you need to add a WWT_RESIZEBOX to the widgets, and you need - to add the flag WDF_RESIZABLE to the window. Now the window is ready - to resize itself. - As you may have noticed, all widgets have a RESIZE_XXX in their line. - This lines controls how the widgets behave on resize. RESIZE_NONE means - it doesn't do anything. Any other option let's one of the borders - move with the changed width/height. So if a widget has - RESIZE_RIGHT, and the window is made 5 pixels wider by the user, - the right of the window will also be made 5 pixels wider. - Now, what if you want to clamp a widget to the bottom? Give it the flag - RESIZE_TB. This is RESIZE_TOP + RESIZE_BOTTOM. Now if the window gets - 5 pixels bigger, both the top and bottom gets 5 bigger, so the whole - widgets moves downwards without resizing, and appears to be clamped - to the bottom. Nice aint it? - You should know one more thing about this system. Most windows can't - handle an increase of 1 pixel. So there is a step function, which - let the windowsize only be changed by X pixels. You configure this - after making the window, like this: - w->resize.step_height = 10; - Now the window will only change in height in steps of 10. - You can also give a minimum width and height. The default value is - the default height/width of the window itself. You can change this - AFTER window-creation, with: - w->resize.width or w->resize.height. - That was all.. good luck, and enjoy :) -- TrueLight */ - -enum ResizeFlag { - RESIZE_NONE = 0, ///< no resize required - - RESIZE_LEFT = 1, ///< left resize flag - RESIZE_RIGHT = 2, ///< rigth resize flag - RESIZE_TOP = 4, ///< top resize flag - RESIZE_BOTTOM = 8, ///< bottom resize flag - - RESIZE_LR = RESIZE_LEFT | RESIZE_RIGHT, ///< combination of left and right resize flags - RESIZE_RB = RESIZE_RIGHT | RESIZE_BOTTOM, ///< combination of right and bottom resize flags - RESIZE_TB = RESIZE_TOP | RESIZE_BOTTOM, ///< combination of top and bottom resize flags - RESIZE_LRB = RESIZE_LEFT | RESIZE_RIGHT | RESIZE_BOTTOM, ///< combination of left, right and bottom resize flags - RESIZE_LRTB = RESIZE_LEFT | RESIZE_RIGHT | RESIZE_TOP | RESIZE_BOTTOM, ///< combination of all resize flags - RESIZE_RTB = RESIZE_RIGHT | RESIZE_TOP | RESIZE_BOTTOM, ///< combination of right, top and bottom resize flag - - /* The following flags are used by the system to specify what is disabled, hidden, or clicked - * They are used in the same place as the above RESIZE_x flags, Widget visual_flags. - * These states are used in exceptions. If nothing is specified, they will indicate - * Enabled, visible or unclicked widgets*/ - WIDG_DISABLED = 4, ///< widget is greyed out, not available - WIDG_HIDDEN = 5, ///< widget is made invisible - WIDG_LOWERED = 6, ///< widget is paint lowered, a pressed button in fact -}; - -enum { - WIDGET_LIST_END = -1, ///< indicate the end of widgets' list for vararg functions -}; - -struct Widget { - byte type; ///< Widget type, see WindowWidgetTypes - byte display_flags; ///< Resize direction, alignment, etc. during resizing, see ResizeFlags - byte color; ///< Widget colour, see docs/ottd-colourtext-palette.png - int16 left, right, top, bottom; ///< The position offsets inside the window - uint16 data; ///< The String/Image or special code (list-matrixes) of a widget - StringID tooltips; ///< Tooltips that are shown when rightclicking on a widget -}; - -enum FrameFlags { - FR_NONE = 0, - FR_TRANSPARENT = 1 << 0, ///< Makes the background transparent if set - FR_BORDERONLY = 1 << 4, ///< Draw border only, no background - FR_LOWERED = 1 << 5, ///< If set the frame is lowered and the background color brighter (ie. buttons when pressed) - FR_DARKENED = 1 << 6, ///< If set the background is darker, allows for lowered frames with normal background color when used with FR_LOWERED (ie. dropdown boxes) -}; - -DECLARE_ENUM_AS_BIT_SET(FrameFlags); - -void DrawFrameRect(int left, int top, int right, int bottom, int color, FrameFlags flags); - -enum WindowEventCodes { - WE_CREATE, - WE_DESTROY, - WE_PAINT, - WE_KEYPRESS, - WE_CLICK, - WE_DOUBLE_CLICK, - WE_RCLICK, - WE_MOUSEOVER, - WE_MOUSELOOP, - WE_MOUSEWHEEL, - WE_TICK, - WE_4, - WE_TIMEOUT, - WE_PLACE_OBJ, - WE_ABORT_PLACE_OBJ, - WE_ON_EDIT_TEXT, - WE_ON_EDIT_TEXT_CANCEL, - WE_POPUPMENU_SELECT, - WE_POPUPMENU_OVER, - WE_DRAGDROP, - WE_PLACE_DRAG, - WE_PLACE_MOUSEUP, - WE_PLACE_PRESIZE, - WE_DROPDOWN_SELECT, - WE_RESIZE, - WE_MESSAGE, - WE_SCROLL, - WE_INVALIDATE_DATA, -}; - -struct WindowEvent { - byte event; - union { - struct { - void *data; - } create; - - struct { - Point pt; - int widget; - } click; - - struct { - Point pt; - TileIndex tile; - TileIndex starttile; - ViewportPlaceMethod select_method; - byte select_proc; - } place; - - struct { - Point pt; - int widget; - } dragdrop; - - struct { - Point size; - Point diff; - } sizing; - - struct { - char *str; - } edittext; - - struct { - Point pt; - } popupmenu; - - struct { - int button; - int index; - } dropdown; - - struct { - Point pt; - int widget; - } mouseover; - - struct { - bool cont; ///< continue the search? (default true) - uint16 key; ///< 16-bit Unicode value of the key - uint16 keycode; ///< untranslated key (including shift-state) - } keypress; - - struct { - int msg; ///< message to be sent - int wparam; ///< additional message-specific information - int lparam; ///< additional message-specific information - } message; - - struct { - Point delta; ///< delta position against position of last call - } scroll; - - struct { - int wheel; ///< how much was 'wheel'd' - } wheel; - } we; -}; - -struct WindowDesc { - int16 left, top, minimum_width, minimum_height, default_width, default_height; - WindowClass cls; - WindowClass parent_cls; - uint32 flags; - const Widget *widgets; - WindowProc *proc; -}; - -enum WindowDefaultFlag { - WDF_STD_TOOLTIPS = 1 << 0, ///< use standard routine when displaying tooltips - WDF_DEF_WIDGET = 1 << 1, ///< default widget control for some widgets in the on click event - WDF_STD_BTN = 1 << 2, ///< default handling for close and drag widgets (widget no 0 and 1) - - WDF_UNCLICK_BUTTONS = 1 << 4, ///< Unclick buttons when the window event times out */ - WDF_STICKY_BUTTON = 1 << 5, ///< Set window to sticky mode; they are not closed unless closed with 'X' (widget 2) - WDF_RESIZABLE = 1 << 6, ///< A window can be resized - WDF_MODAL = 1 << 7, ///< The window is a modal child of some other window, meaning the parent is 'inactive' -}; - -/* can be used as x or y coordinates to cause a specific placement */ -enum WindowDefaultPosition { - WDP_AUTO = -1, ///< Find a place automatically - WDP_CENTER = -2, ///< Center the window (left/right or top/bottom) - WDP_ALIGN_TBR = -3, ///< Align the right side of the window with the right side of the main toolbar - WDP_ALIGN_TBL = -4, ///< Align the left side of the window with the left side of the main toolbar -}; - -struct Textbuf { - char *buf; ///< buffer in which text is saved - uint16 maxlength, maxwidth; ///< the maximum size of the buffer. Maxwidth specifies screensize in pixels, maxlength is in bytes - uint16 length, width; ///< the current size of the string. Width specifies screensize in pixels, length is in bytes - bool caret; ///< is the caret ("_") visible or not - uint16 caretpos; ///< the current position of the caret in the buffer, in bytes - uint16 caretxoffs; ///< the current position of the caret in pixels -}; - -#define WP(ptr, str) (*(str*)(ptr)->custom) -/* You cannot 100% reliably calculate the biggest custom struct as - * the number of pointers in it and alignment will have a huge impact. - * 96 is the largest window-size for 64-bit machines currently */ -#define WINDOW_CUSTOM_SIZE 96 - -struct Scrollbar { - uint16 count, cap, pos; -}; - -struct ResizeInfo { - uint width; ///< Minimum width and height - uint height; - uint step_width; ///< In how big steps the width and height go - uint step_height; -}; - -struct WindowMessage { - int msg; - int wparam; - int lparam; -}; - -struct Window { - uint16 flags4; - WindowClass window_class; - WindowNumber window_number; - - int left, top; - int width, height; - - Scrollbar hscroll, vscroll, vscroll2; - ResizeInfo resize; - - byte caption_color; - - WindowProc *wndproc; - ViewPort *viewport; - const Widget *original_widget; - Widget *widget; - uint widget_count; - uint32 desc_flags; - - WindowMessage message; - Window *parent; - byte custom[WINDOW_CUSTOM_SIZE]; - - void HandleButtonClick(byte widget); - - void SetWidgetDisabledState(byte widget_index, bool disab_stat); - void DisableWidget(byte widget_index); - void EnableWidget(byte widget_index); - bool IsWidgetDisabled(byte widget_index) const; - void SetWidgetHiddenState(byte widget_index, bool hidden_stat); - void HideWidget(byte widget_index); - void ShowWidget(byte widget_index); - bool IsWidgetHidden(byte widget_index) const; - void SetWidgetLoweredState(byte widget_index, bool lowered_stat); - void ToggleWidgetLoweredState(byte widget_index); - void LowerWidget(byte widget_index); - void RaiseWidget(byte widget_index); - bool IsWidgetLowered(byte widget_index) const; - - void RaiseButtons(); - void CDECL SetWidgetsDisabledState(bool disab_stat, int widgets, ...); - void CDECL SetWidgetsHiddenState(bool hidden_stat, int widgets, ...); - void CDECL SetWidgetsLoweredState(bool lowered_stat, int widgets, ...); - void InvalidateWidget(byte widget_index) const; -}; - -struct querystr_d { - StringID caption; - Textbuf text; - const char *orig; - CharSetFilter afilter; - bool handled; -}; -assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(querystr_d)); - -struct chatquerystr_d : public querystr_d { - int dest; -}; -assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(chatquerystr_d)); - -struct menu_d { - byte item_count; ///< follow_vehicle - byte sel_index; ///< scrollpos_x - byte main_button; ///< scrollpos_y - byte action_id; - StringID string_id; ///< unk30 - uint16 checked_items; ///< unk32 - byte disabled_items; -}; -assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(menu_d)); - -struct def_d { - int16 data_1, data_2, data_3; - int16 data_4, data_5; - bool close; - byte byte_1; -}; -assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(def_d)); - -struct void_d { - void *data; -}; -assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(void_d)); - -struct tree_d { - uint16 base; - uint16 count; -}; -assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(tree_d)); - -struct tooltips_d { - StringID string_id; - byte paramcount; - uint64 params[5]; -}; -assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(tooltips_d)); - -struct buildvehicle_d { - VehicleType vehicle_type; - union { - RailTypeByte railtype; - AirportFTAClass::Flags flags; - RoadTypes roadtypes; - } filter; - byte sel_index; ///< deprecated value, used for 'unified' ship and road - bool descending_sort_order; - byte sort_criteria; - bool regenerate_list; - EngineID sel_engine; - EngineID rename_engine; - EngineList eng_list; -}; -assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(buildvehicle_d)); - -struct replaceveh_d { - byte sel_index[2]; - EngineID sel_engine[2]; - uint16 count[2]; - bool wagon_btnstate; ///< true means engine is selected - EngineList list[2]; - bool update_left; - bool update_right; - bool init_lists; - GroupID sel_group; -}; -assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(replaceveh_d)); - -struct depot_d { - VehicleID sel; - VehicleType type; - bool generate_list; - uint16 engine_list_length; - uint16 wagon_list_length; - uint16 engine_count; - uint16 wagon_count; - Vehicle **vehicle_list; - Vehicle **wagon_list; -}; -assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(depot_d)); - -struct order_d { - int sel; -}; -assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(order_d)); - -struct vehicledetails_d { - byte tab; -}; -assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(vehicledetails_d)); - -struct smallmap_d { - int32 scroll_x; - int32 scroll_y; - int32 subscroll; -}; -assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(smallmap_d)); - -/* player face selection window */ -struct facesel_d { - PlayerFace face; // player face bits - bool advanced; // advance player face selection window -}; -assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(facesel_d)); - -struct refit_d { - int sel; - struct RefitOption *cargo; - struct RefitList *list; - uint length; - VehicleOrderID order; -}; -assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(refit_d)); - -struct vp_d { - VehicleID follow_vehicle; - int32 scrollpos_x; - int32 scrollpos_y; - int32 dest_scrollpos_x; - int32 dest_scrollpos_y; -}; -assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(vp_d)); - -struct news_d { - uint16 follow_vehicle; - int32 scrollpos_x; - int32 scrollpos_y; - int32 dest_scrollpos_x; - int32 dest_scrollpos_y; - NewsItem *ni; -}; -assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(news_d)); - -struct highscore_d { - uint32 background_img; - int8 rank; -}; -assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(highscore_d)); - -struct scroller_d { - int height; - uint16 counter; -}; -assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(scroller_d)); - -enum SortListFlags { - VL_NONE = 0, ///< no sort - VL_DESC = 1 << 0, ///< sort descending or ascending - VL_RESORT = 1 << 1, ///< instruct the code to resort the list in the next loop - VL_REBUILD = 1 << 2, ///< create sort-listing to use for qsort and friends - VL_END = 1 << 3, -}; - -DECLARE_ENUM_AS_BIT_SET(SortListFlags); - -struct Listing { - bool order; ///< Ascending/descending - byte criteria; ///< Sorting criteria -}; - -struct list_d { - uint16 list_length; ///< length of the list being sorted - byte sort_type; ///< what criteria to sort on - SortListFlags flags; ///< used to control sorting/resorting/etc. - uint16 resort_timer; ///< resort list after a given amount of ticks if set -}; -assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(list_d)); - -struct message_d { - int msg; - int wparam; - int lparam; -}; -assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(message_d)); - -struct dropdown_d { - uint32 disabled_state; - uint32 hidden_state; - WindowClass parent_wnd_class; - WindowNumber parent_wnd_num; - byte parent_button; - byte num_items; - byte selected_index; - const StringID *items; - byte click_delay; - bool drag_mode; -}; -assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(dropdown_d)); - -struct vehiclelist_d { - const Vehicle** sort_list; // List of vehicles (sorted) - Listing *_sorting; // pointer to the appropiate subcategory of _sorting - uint16 length_of_sort_list; // Keeps track of how many vehicle pointers sort list got space for - VehicleType vehicle_type; // The vehicle type that is sorted - list_d l; // General list struct -}; -assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(vehiclelist_d)); - -struct grouplist_d { - const Group **sort_list; - list_d l; // General list struct -}; -assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(grouplist_d)); - -struct groupveh_d : vehiclelist_d { - GroupID group_sel; - VehicleID vehicle_sel; - - grouplist_d gl; -}; -assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(groupveh_d)); - -/****************** THESE ARE NOT WIDGET TYPES!!!!! *******************/ -enum WindowWidgetBehaviours { - WWB_PUSHBUTTON = 1 << 5, - - WWB_MASK = 0xE0, -}; - - -enum WindowWidgetTypes { - WWT_EMPTY, - - WWT_PANEL, ///< simple depressed panel - WWT_INSET, ///< pressed (inset) panel, most commonly used as combo box _text_ area - WWT_IMGBTN, ///< button with image - WWT_IMGBTN_2, ///< button with diff image when clicked - - WWT_TEXTBTN, ///< button with text - WWT_TEXTBTN_2, ///< button with diff text when clicked - WWT_LABEL, ///< centered label - WWT_TEXT, ///< pure simple text - WWT_MATRIX, - WWT_SCROLLBAR, - WWT_FRAME, ///< frame - WWT_CAPTION, - - WWT_HSCROLLBAR, - WWT_STICKYBOX, - WWT_SCROLL2BAR, ///< 2nd vertical scrollbar - WWT_RESIZEBOX, - WWT_CLOSEBOX, - WWT_LAST, ///< Last Item. use WIDGETS_END to fill up padding!! - - WWT_MASK = 0x1F, - - WWT_PUSHBTN = WWT_PANEL | WWB_PUSHBUTTON, - WWT_PUSHTXTBTN = WWT_TEXTBTN | WWB_PUSHBUTTON, - WWT_PUSHIMGBTN = WWT_IMGBTN | WWB_PUSHBUTTON, -}; - -#define WIDGETS_END WWT_LAST, RESIZE_NONE, 0, 0, 0, 0, 0, 0, STR_NULL - -enum WindowFlags { - WF_TIMEOUT_SHL = 0, - WF_TIMEOUT_MASK = 7, - WF_DRAGGING = 1 << 3, - WF_SCROLL_UP = 1 << 4, - WF_SCROLL_DOWN = 1 << 5, - WF_SCROLL_MIDDLE = 1 << 6, - WF_HSCROLL = 1 << 7, - WF_SIZING = 1 << 8, - WF_STICKY = 1 << 9, - - WF_DISABLE_VP_SCROLL = 1 << 10, - - WF_WHITE_BORDER_ONE = 1 << 11, - WF_WHITE_BORDER_MASK = 1 << 12 | WF_WHITE_BORDER_ONE, - WF_SCROLL2 = 1 << 13, -}; - -/* window.cpp */ -void CallWindowEventNP(Window *w, int event); -void CallWindowTickEvent(); - -/** - * Marks the window as dirty for repaint. - * - * @ingroup dirty - */ -void SetWindowDirty(const Window *w); -void SendWindowMessage(WindowClass wnd_class, WindowNumber wnd_num, int msg, int wparam, int lparam); -void SendWindowMessageClass(WindowClass wnd_class, int msg, int wparam, int lparam); - -Window *FindWindowById(WindowClass cls, WindowNumber number); -void DeleteWindow(Window *w); -void DeletePlayerWindows(PlayerID pi); -void ChangeWindowOwner(PlayerID old_player, PlayerID new_player); -Window *BringWindowToFrontById(WindowClass cls, WindowNumber number); -Window *FindWindowFromPt(int x, int y); - -bool IsWindowOfPrototype(const Window *w, const Widget *widget); -void AssignWidgetToWindow(Window *w, const Widget *widget); -Window *AllocateWindow( - int x, - int y, - int width, - int height, - WindowProc *proc, - WindowClass cls, - const Widget *widget, - void *data = NULL); - -Window *AllocateWindowDesc(const WindowDesc *desc, void *data = NULL); -Window *AllocateWindowDescFront(const WindowDesc *desc, int window_number, void *data = NULL); - -void DrawWindowViewport(const Window *w); -void ResizeWindow(Window *w, int x, int y); - -void InitWindowSystem(); -void UnInitWindowSystem(); -void ResetWindowSystem(); -int GetMenuItemIndex(const Window *w, int x, int y); -void InputLoop(); -void InvalidateThisWindowData(Window *w); -void InvalidateWindowData(WindowClass cls, WindowNumber number); -void RelocateAllWindows(int neww, int newh); -int PositionMainToolbar(Window *w); - -/* misc_gui.cpp */ -void GuiShowTooltipsWithArgs(StringID str, uint paramcount, const uint64 params[]); -static inline void GuiShowTooltips(StringID str) -{ - GuiShowTooltipsWithArgs(str, 0, NULL); -} - -/* widget.cpp */ -int GetWidgetFromPos(const Window *w, int x, int y); -void DrawWindowWidgets(const Window *w); -void ShowDropDownMenu(Window *w, const StringID *strings, int selected, int button, uint32 disabled_mask, uint32 hidden_mask); - - -Window *GetCallbackWnd(); -void DeleteNonVitalWindows(); -void DeleteAllNonVitalWindows(); -void HideVitalWindows(); -void ShowVitalWindows(); -Window **FindWindowZPosition(const Window *w); - -/* window.cpp */ -extern Window *_z_windows[]; -extern Window **_last_z_window; -#define FOR_ALL_WINDOWS(wz) for (wz = _z_windows; wz != _last_z_window; wz++) - -VARDEF Point _cursorpos_drag_start; - -VARDEF int _scrollbar_start_pos; -VARDEF int _scrollbar_size; -VARDEF byte _scroller_click_timeout; - -VARDEF bool _scrolling_scrollbar; -VARDEF bool _scrolling_viewport; -VARDEF bool _popup_menu_active; - -VARDEF byte _special_mouse_mode; -enum SpecialMouseMode { - WSM_NONE = 0, - WSM_DRAGDROP = 1, - WSM_SIZING = 2, - WSM_PRESIZE = 3, -}; - -void ScrollbarClickHandler(Window *w, const Widget *wi, int x, int y); - -/** Evenly distribute some widgets when resizing horizontally (often a button row) - * The widgets are presumed to be in a line and numberef from left to right (without gaps) - * @param w widow to modify - * @param left The leftmost widget to resize - * @param right The rightmost widget to resize. Since right side of it is used, remember to set it to RESIZE_RIGHT - */ -void ResizeButtons(Window *w, byte left, byte right); - - -/** - * Sets the enabled/disabled status of a widget. - * By default, widgets are enabled. - * On certain conditions, they have to be disabled. - * @param widget_index : index of this widget in the window - * @param disab_stat : status to use ie: disabled = true, enabled = false - */ -inline void Window::SetWidgetDisabledState(byte widget_index, bool disab_stat) -{ - assert(widget_index < this->widget_count); - SB(this->widget[widget_index].display_flags, WIDG_DISABLED, 1, !!disab_stat); -} - -/** - * Sets a widget to disabled. - * @param widget_index : index of this widget in the window - */ -inline void Window::DisableWidget(byte widget_index) -{ - SetWidgetDisabledState(widget_index, true); -} - -/** - * Sets a widget to Enabled. - * @param widget_index : index of this widget in the window - */ -inline void Window::EnableWidget(byte widget_index) -{ - SetWidgetDisabledState(widget_index, false); -} - -/** - * Gets the enabled/disabled status of a widget. - * @param widget_index : index of this widget in the window - * @return status of the widget ie: disabled = true, enabled = false - */ -inline bool Window::IsWidgetDisabled(byte widget_index) const -{ - assert(widget_index < this->widget_count); - return HasBit(this->widget[widget_index].display_flags, WIDG_DISABLED); -} - -/** - * Sets the hidden/shown status of a widget. - * By default, widgets are visible. - * On certain conditions, they have to be hidden. - * @param widget_index index of this widget in the window - * @param hidden_stat status to use ie. hidden = true, visible = false - */ -inline void Window::SetWidgetHiddenState(byte widget_index, bool hidden_stat) -{ - assert(widget_index < this->widget_count); - SB(this->widget[widget_index].display_flags, WIDG_HIDDEN, 1, !!hidden_stat); -} - -/** - * Sets a widget hidden. - * @param widget_index : index of this widget in the window - */ -inline void Window::HideWidget(byte widget_index) -{ - SetWidgetHiddenState(widget_index, true); -} - -/** - * Sets a widget visible. - * @param widget_index : index of this widget in the window - */ -inline void Window::ShowWidget(byte widget_index) -{ - SetWidgetHiddenState(widget_index, false); -} - -/** - * Gets the visibility of a widget. - * @param widget_index : index of this widget in the window - * @return status of the widget ie: hidden = true, visible = false - */ -inline bool Window::IsWidgetHidden(byte widget_index) const -{ - assert(widget_index < this->widget_count); - return HasBit(this->widget[widget_index].display_flags, WIDG_HIDDEN); -} - -/** - * Sets the lowered/raised status of a widget. - * @param widget_index : index of this widget in the window - * @param lowered_stat : status to use ie: lowered = true, raised = false - */ -inline void Window::SetWidgetLoweredState(byte widget_index, bool lowered_stat) -{ - assert(widget_index < this->widget_count); - SB(this->widget[widget_index].display_flags, WIDG_LOWERED, 1, !!lowered_stat); -} - -/** - * Invert the lowered/raised status of a widget. - * @param widget_index : index of this widget in the window - */ -inline void Window::ToggleWidgetLoweredState(byte widget_index) -{ - assert(widget_index < this->widget_count); - ToggleBit(this->widget[widget_index].display_flags, WIDG_LOWERED); -} - -/** - * Marks a widget as lowered. - * @param widget_index : index of this widget in the window - */ -inline void Window::LowerWidget(byte widget_index) -{ - SetWidgetLoweredState(widget_index, true); -} - -/** - * Marks a widget as raised. - * @param widget_index : index of this widget in the window - */ -inline void Window::RaiseWidget(byte widget_index) -{ - SetWidgetLoweredState(widget_index, false); -} - -/** - * Gets the lowered state of a widget. - * @param widget_index : index of this widget in the window - * @return status of the widget ie: lowered = true, raised= false - */ -inline bool Window::IsWidgetLowered(byte widget_index) const -{ - assert(widget_index < this->widget_count); - return HasBit(this->widget[widget_index].display_flags, WIDG_LOWERED); -} - -#endif /* WINDOW_H */ diff --git a/src/window_func.h b/src/window_func.h new file mode 100644 index 000000000..8f3e5ff1d --- /dev/null +++ b/src/window_func.h @@ -0,0 +1,40 @@ +/* $Id$ */ + +/** @file window.h Window functions not directly related to making/drawing windows. */ + +#ifndef WINDOW_FUNC_H +#define WINDOW_FUNC_H + +#include "window_type.h" + +/** + * Marks the window as dirty for repaint. + * + * @ingroup dirty + */ +void SetWindowDirty(const Window *w); +void SendWindowMessage(WindowClass wnd_class, WindowNumber wnd_num, int msg, int wparam, int lparam); +void SendWindowMessageClass(WindowClass wnd_class, int msg, int wparam, int lparam); + +Window *FindWindowById(WindowClass cls, WindowNumber number); +void DeleteWindow(Window *w); +void DeletePlayerWindows(PlayerID pi); +void ChangeWindowOwner(PlayerID old_player, PlayerID new_player); + +void ResizeWindow(Window *w, int x, int y); + +void InitWindowSystem(); +void UnInitWindowSystem(); +void ResetWindowSystem(); +void InputLoop(); +void InvalidateThisWindowData(Window *w); +void InvalidateWindowData(WindowClass cls, WindowNumber number); +void RelocateAllWindows(int neww, int newh); + +void DeleteNonVitalWindows(); +void DeleteAllNonVitalWindows(); +void HideVitalWindows(); +void ShowVitalWindows(); +Window **FindWindowZPosition(const Window *w); + +#endif /* WINDOW_FUNC_H */ diff --git a/src/window_gui.h b/src/window_gui.h new file mode 100644 index 000000000..b4f87661c --- /dev/null +++ b/src/window_gui.h @@ -0,0 +1,830 @@ +/* $Id$ */ + +/** @file window_gui.h Functions, definitions and such used only by the GUI. */ + +#ifndef WINDOW_GUI_H +#define WINDOW_GUI_H + +#include "macros.h" +#include "string.h" +#include "order.h" +#include "rail_type.h" +#include "road_type.h" +#include "airport.h" +#include "vehicle.h" +#include "viewport.h" + +/** + * The maximum number of windows that can be opened. + */ +static const int MAX_NUMBER_OF_WINDOWS = 25; + +struct WindowEvent; + +typedef void WindowProc(Window *w, WindowEvent *e); + +/* How the resize system works: + First, you need to add a WWT_RESIZEBOX to the widgets, and you need + to add the flag WDF_RESIZABLE to the window. Now the window is ready + to resize itself. + As you may have noticed, all widgets have a RESIZE_XXX in their line. + This lines controls how the widgets behave on resize. RESIZE_NONE means + it doesn't do anything. Any other option let's one of the borders + move with the changed width/height. So if a widget has + RESIZE_RIGHT, and the window is made 5 pixels wider by the user, + the right of the window will also be made 5 pixels wider. + Now, what if you want to clamp a widget to the bottom? Give it the flag + RESIZE_TB. This is RESIZE_TOP + RESIZE_BOTTOM. Now if the window gets + 5 pixels bigger, both the top and bottom gets 5 bigger, so the whole + widgets moves downwards without resizing, and appears to be clamped + to the bottom. Nice aint it? + You should know one more thing about this system. Most windows can't + handle an increase of 1 pixel. So there is a step function, which + let the windowsize only be changed by X pixels. You configure this + after making the window, like this: + w->resize.step_height = 10; + Now the window will only change in height in steps of 10. + You can also give a minimum width and height. The default value is + the default height/width of the window itself. You can change this + AFTER window-creation, with: + w->resize.width or w->resize.height. + That was all.. good luck, and enjoy :) -- TrueLight */ + +enum ResizeFlag { + RESIZE_NONE = 0, ///< no resize required + + RESIZE_LEFT = 1, ///< left resize flag + RESIZE_RIGHT = 2, ///< rigth resize flag + RESIZE_TOP = 4, ///< top resize flag + RESIZE_BOTTOM = 8, ///< bottom resize flag + + RESIZE_LR = RESIZE_LEFT | RESIZE_RIGHT, ///< combination of left and right resize flags + RESIZE_RB = RESIZE_RIGHT | RESIZE_BOTTOM, ///< combination of right and bottom resize flags + RESIZE_TB = RESIZE_TOP | RESIZE_BOTTOM, ///< combination of top and bottom resize flags + RESIZE_LRB = RESIZE_LEFT | RESIZE_RIGHT | RESIZE_BOTTOM, ///< combination of left, right and bottom resize flags + RESIZE_LRTB = RESIZE_LEFT | RESIZE_RIGHT | RESIZE_TOP | RESIZE_BOTTOM, ///< combination of all resize flags + RESIZE_RTB = RESIZE_RIGHT | RESIZE_TOP | RESIZE_BOTTOM, ///< combination of right, top and bottom resize flag + + /* The following flags are used by the system to specify what is disabled, hidden, or clicked + * They are used in the same place as the above RESIZE_x flags, Widget visual_flags. + * These states are used in exceptions. If nothing is specified, they will indicate + * Enabled, visible or unclicked widgets*/ + WIDG_DISABLED = 4, ///< widget is greyed out, not available + WIDG_HIDDEN = 5, ///< widget is made invisible + WIDG_LOWERED = 6, ///< widget is paint lowered, a pressed button in fact +}; + +enum { + WIDGET_LIST_END = -1, ///< indicate the end of widgets' list for vararg functions +}; + +struct Widget { + byte type; ///< Widget type, see WindowWidgetTypes + byte display_flags; ///< Resize direction, alignment, etc. during resizing, see ResizeFlags + byte color; ///< Widget colour, see docs/ottd-colourtext-palette.png + int16 left, right, top, bottom; ///< The position offsets inside the window + uint16 data; ///< The String/Image or special code (list-matrixes) of a widget + StringID tooltips; ///< Tooltips that are shown when rightclicking on a widget +}; + +enum FrameFlags { + FR_NONE = 0, + FR_TRANSPARENT = 1 << 0, ///< Makes the background transparent if set + FR_BORDERONLY = 1 << 4, ///< Draw border only, no background + FR_LOWERED = 1 << 5, ///< If set the frame is lowered and the background color brighter (ie. buttons when pressed) + FR_DARKENED = 1 << 6, ///< If set the background is darker, allows for lowered frames with normal background color when used with FR_LOWERED (ie. dropdown boxes) +}; + +DECLARE_ENUM_AS_BIT_SET(FrameFlags); + +void DrawFrameRect(int left, int top, int right, int bottom, int color, FrameFlags flags); + +enum WindowEventCodes { + WE_CREATE, + WE_DESTROY, + WE_PAINT, + WE_KEYPRESS, + WE_CLICK, + WE_DOUBLE_CLICK, + WE_RCLICK, + WE_MOUSEOVER, + WE_MOUSELOOP, + WE_MOUSEWHEEL, + WE_TICK, + WE_4, + WE_TIMEOUT, + WE_PLACE_OBJ, + WE_ABORT_PLACE_OBJ, + WE_ON_EDIT_TEXT, + WE_ON_EDIT_TEXT_CANCEL, + WE_POPUPMENU_SELECT, + WE_POPUPMENU_OVER, + WE_DRAGDROP, + WE_PLACE_DRAG, + WE_PLACE_MOUSEUP, + WE_PLACE_PRESIZE, + WE_DROPDOWN_SELECT, + WE_RESIZE, + WE_MESSAGE, + WE_SCROLL, + WE_INVALIDATE_DATA, +}; + +struct WindowEvent { + byte event; + union { + struct { + void *data; + } create; + + struct { + Point pt; + int widget; + } click; + + struct { + Point pt; + TileIndex tile; + TileIndex starttile; + ViewportPlaceMethod select_method; + byte select_proc; + } place; + + struct { + Point pt; + int widget; + } dragdrop; + + struct { + Point size; + Point diff; + } sizing; + + struct { + char *str; + } edittext; + + struct { + Point pt; + } popupmenu; + + struct { + int button; + int index; + } dropdown; + + struct { + Point pt; + int widget; + } mouseover; + + struct { + bool cont; ///< continue the search? (default true) + uint16 key; ///< 16-bit Unicode value of the key + uint16 keycode; ///< untranslated key (including shift-state) + } keypress; + + struct { + int msg; ///< message to be sent + int wparam; ///< additional message-specific information + int lparam; ///< additional message-specific information + } message; + + struct { + Point delta; ///< delta position against position of last call + } scroll; + + struct { + int wheel; ///< how much was 'wheel'd' + } wheel; + } we; +}; + +struct WindowDesc { + int16 left, top, minimum_width, minimum_height, default_width, default_height; + WindowClass cls; + WindowClass parent_cls; + uint32 flags; + const Widget *widgets; + WindowProc *proc; +}; + +enum WindowDefaultFlag { + WDF_STD_TOOLTIPS = 1 << 0, ///< use standard routine when displaying tooltips + WDF_DEF_WIDGET = 1 << 1, ///< default widget control for some widgets in the on click event + WDF_STD_BTN = 1 << 2, ///< default handling for close and drag widgets (widget no 0 and 1) + + WDF_UNCLICK_BUTTONS = 1 << 4, ///< Unclick buttons when the window event times out */ + WDF_STICKY_BUTTON = 1 << 5, ///< Set window to sticky mode; they are not closed unless closed with 'X' (widget 2) + WDF_RESIZABLE = 1 << 6, ///< A window can be resized + WDF_MODAL = 1 << 7, ///< The window is a modal child of some other window, meaning the parent is 'inactive' +}; + +/* can be used as x or y coordinates to cause a specific placement */ +enum WindowDefaultPosition { + WDP_AUTO = -1, ///< Find a place automatically + WDP_CENTER = -2, ///< Center the window (left/right or top/bottom) + WDP_ALIGN_TBR = -3, ///< Align the right side of the window with the right side of the main toolbar + WDP_ALIGN_TBL = -4, ///< Align the left side of the window with the left side of the main toolbar +}; + +struct Textbuf { + char *buf; ///< buffer in which text is saved + uint16 maxlength, maxwidth; ///< the maximum size of the buffer. Maxwidth specifies screensize in pixels, maxlength is in bytes + uint16 length, width; ///< the current size of the string. Width specifies screensize in pixels, length is in bytes + bool caret; ///< is the caret ("_") visible or not + uint16 caretpos; ///< the current position of the caret in the buffer, in bytes + uint16 caretxoffs; ///< the current position of the caret in pixels +}; + +#define WP(ptr, str) (*(str*)(ptr)->custom) +/* You cannot 100% reliably calculate the biggest custom struct as + * the number of pointers in it and alignment will have a huge impact. + * 96 is the largest window-size for 64-bit machines currently */ +#define WINDOW_CUSTOM_SIZE 96 + +struct Scrollbar { + uint16 count, cap, pos; +}; + +struct ResizeInfo { + uint width; ///< Minimum width and height + uint height; + uint step_width; ///< In how big steps the width and height go + uint step_height; +}; + +struct WindowMessage { + int msg; + int wparam; + int lparam; +}; + +struct Window { + uint16 flags4; + WindowClass window_class; + WindowNumber window_number; + + int left, top; + int width, height; + + Scrollbar hscroll, vscroll, vscroll2; + ResizeInfo resize; + + byte caption_color; + + WindowProc *wndproc; + ViewPort *viewport; + const Widget *original_widget; + Widget *widget; + uint widget_count; + uint32 desc_flags; + + WindowMessage message; + Window *parent; + byte custom[WINDOW_CUSTOM_SIZE]; + + void HandleButtonClick(byte widget); + + void SetWidgetDisabledState(byte widget_index, bool disab_stat); + void DisableWidget(byte widget_index); + void EnableWidget(byte widget_index); + bool IsWidgetDisabled(byte widget_index) const; + void SetWidgetHiddenState(byte widget_index, bool hidden_stat); + void HideWidget(byte widget_index); + void ShowWidget(byte widget_index); + bool IsWidgetHidden(byte widget_index) const; + void SetWidgetLoweredState(byte widget_index, bool lowered_stat); + void ToggleWidgetLoweredState(byte widget_index); + void LowerWidget(byte widget_index); + void RaiseWidget(byte widget_index); + bool IsWidgetLowered(byte widget_index) const; + + void RaiseButtons(); + void CDECL SetWidgetsDisabledState(bool disab_stat, int widgets, ...); + void CDECL SetWidgetsHiddenState(bool hidden_stat, int widgets, ...); + void CDECL SetWidgetsLoweredState(bool lowered_stat, int widgets, ...); + void InvalidateWidget(byte widget_index) const; +}; + +struct querystr_d { + StringID caption; + Textbuf text; + const char *orig; + CharSetFilter afilter; + bool handled; +}; +assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(querystr_d)); + +struct chatquerystr_d : public querystr_d { + int dest; +}; +assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(chatquerystr_d)); + +struct menu_d { + byte item_count; ///< follow_vehicle + byte sel_index; ///< scrollpos_x + byte main_button; ///< scrollpos_y + byte action_id; + StringID string_id; ///< unk30 + uint16 checked_items; ///< unk32 + byte disabled_items; +}; +assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(menu_d)); + +struct def_d { + int16 data_1, data_2, data_3; + int16 data_4, data_5; + bool close; + byte byte_1; +}; +assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(def_d)); + +struct void_d { + void *data; +}; +assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(void_d)); + +struct tree_d { + uint16 base; + uint16 count; +}; +assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(tree_d)); + +struct tooltips_d { + StringID string_id; + byte paramcount; + uint64 params[5]; +}; +assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(tooltips_d)); + +struct buildvehicle_d { + VehicleType vehicle_type; + union { + RailTypeByte railtype; + AirportFTAClass::Flags flags; + RoadTypes roadtypes; + } filter; + byte sel_index; ///< deprecated value, used for 'unified' ship and road + bool descending_sort_order; + byte sort_criteria; + bool regenerate_list; + EngineID sel_engine; + EngineID rename_engine; + EngineList eng_list; +}; +assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(buildvehicle_d)); + +struct replaceveh_d { + byte sel_index[2]; + EngineID sel_engine[2]; + uint16 count[2]; + bool wagon_btnstate; ///< true means engine is selected + EngineList list[2]; + bool update_left; + bool update_right; + bool init_lists; + GroupID sel_group; +}; +assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(replaceveh_d)); + +struct depot_d { + VehicleID sel; + VehicleType type; + bool generate_list; + uint16 engine_list_length; + uint16 wagon_list_length; + uint16 engine_count; + uint16 wagon_count; + Vehicle **vehicle_list; + Vehicle **wagon_list; +}; +assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(depot_d)); + +struct order_d { + int sel; +}; +assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(order_d)); + +struct vehicledetails_d { + byte tab; +}; +assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(vehicledetails_d)); + +struct smallmap_d { + int32 scroll_x; + int32 scroll_y; + int32 subscroll; +}; +assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(smallmap_d)); + +/* player face selection window */ +struct facesel_d { + PlayerFace face; // player face bits + bool advanced; // advance player face selection window +}; +assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(facesel_d)); + +struct refit_d { + int sel; + struct RefitOption *cargo; + struct RefitList *list; + uint length; + VehicleOrderID order; +}; +assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(refit_d)); + +struct vp_d { + VehicleID follow_vehicle; + int32 scrollpos_x; + int32 scrollpos_y; + int32 dest_scrollpos_x; + int32 dest_scrollpos_y; +}; +assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(vp_d)); + +struct news_d { + uint16 follow_vehicle; + int32 scrollpos_x; + int32 scrollpos_y; + int32 dest_scrollpos_x; + int32 dest_scrollpos_y; + NewsItem *ni; +}; +assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(news_d)); + +struct highscore_d { + uint32 background_img; + int8 rank; +}; +assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(highscore_d)); + +struct scroller_d { + int height; + uint16 counter; +}; +assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(scroller_d)); + +enum SortListFlags { + VL_NONE = 0, ///< no sort + VL_DESC = 1 << 0, ///< sort descending or ascending + VL_RESORT = 1 << 1, ///< instruct the code to resort the list in the next loop + VL_REBUILD = 1 << 2, ///< create sort-listing to use for qsort and friends + VL_END = 1 << 3, +}; + +DECLARE_ENUM_AS_BIT_SET(SortListFlags); + +struct Listing { + bool order; ///< Ascending/descending + byte criteria; ///< Sorting criteria +}; + +struct list_d { + uint16 list_length; ///< length of the list being sorted + byte sort_type; ///< what criteria to sort on + SortListFlags flags; ///< used to control sorting/resorting/etc. + uint16 resort_timer; ///< resort list after a given amount of ticks if set +}; +assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(list_d)); + +struct message_d { + int msg; + int wparam; + int lparam; +}; +assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(message_d)); + +struct dropdown_d { + uint32 disabled_state; + uint32 hidden_state; + WindowClass parent_wnd_class; + WindowNumber parent_wnd_num; + byte parent_button; + byte num_items; + byte selected_index; + const StringID *items; + byte click_delay; + bool drag_mode; +}; +assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(dropdown_d)); + +struct vehiclelist_d { + const Vehicle** sort_list; // List of vehicles (sorted) + Listing *_sorting; // pointer to the appropiate subcategory of _sorting + uint16 length_of_sort_list; // Keeps track of how many vehicle pointers sort list got space for + VehicleType vehicle_type; // The vehicle type that is sorted + list_d l; // General list struct +}; +assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(vehiclelist_d)); + +struct grouplist_d { + const Group **sort_list; + list_d l; // General list struct +}; +assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(grouplist_d)); + +struct groupveh_d : vehiclelist_d { + GroupID group_sel; + VehicleID vehicle_sel; + + grouplist_d gl; +}; +assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(groupveh_d)); + +/****************** THESE ARE NOT WIDGET TYPES!!!!! *******************/ +enum WindowWidgetBehaviours { + WWB_PUSHBUTTON = 1 << 5, + + WWB_MASK = 0xE0, +}; + + +enum WindowWidgetTypes { + WWT_EMPTY, + + WWT_PANEL, ///< simple depressed panel + WWT_INSET, ///< pressed (inset) panel, most commonly used as combo box _text_ area + WWT_IMGBTN, ///< button with image + WWT_IMGBTN_2, ///< button with diff image when clicked + + WWT_TEXTBTN, ///< button with text + WWT_TEXTBTN_2, ///< button with diff text when clicked + WWT_LABEL, ///< centered label + WWT_TEXT, ///< pure simple text + WWT_MATRIX, + WWT_SCROLLBAR, + WWT_FRAME, ///< frame + WWT_CAPTION, + + WWT_HSCROLLBAR, + WWT_STICKYBOX, + WWT_SCROLL2BAR, ///< 2nd vertical scrollbar + WWT_RESIZEBOX, + WWT_CLOSEBOX, + WWT_LAST, ///< Last Item. use WIDGETS_END to fill up padding!! + + WWT_MASK = 0x1F, + + WWT_PUSHBTN = WWT_PANEL | WWB_PUSHBUTTON, + WWT_PUSHTXTBTN = WWT_TEXTBTN | WWB_PUSHBUTTON, + WWT_PUSHIMGBTN = WWT_IMGBTN | WWB_PUSHBUTTON, +}; + +#define WIDGETS_END WWT_LAST, RESIZE_NONE, 0, 0, 0, 0, 0, 0, STR_NULL + +enum WindowFlags { + WF_TIMEOUT_SHL = 0, + WF_TIMEOUT_MASK = 7, + WF_DRAGGING = 1 << 3, + WF_SCROLL_UP = 1 << 4, + WF_SCROLL_DOWN = 1 << 5, + WF_SCROLL_MIDDLE = 1 << 6, + WF_HSCROLL = 1 << 7, + WF_SIZING = 1 << 8, + WF_STICKY = 1 << 9, + + WF_DISABLE_VP_SCROLL = 1 << 10, + + WF_WHITE_BORDER_ONE = 1 << 11, + WF_WHITE_BORDER_MASK = 1 << 12 | WF_WHITE_BORDER_ONE, + WF_SCROLL2 = 1 << 13, +}; + +/* window.cpp */ +void CallWindowEventNP(Window *w, int event); +void CallWindowTickEvent(); + +/** + * Marks the window as dirty for repaint. + * + * @ingroup dirty + */ +void SetWindowDirty(const Window *w); +void SendWindowMessage(WindowClass wnd_class, WindowNumber wnd_num, int msg, int wparam, int lparam); +void SendWindowMessageClass(WindowClass wnd_class, int msg, int wparam, int lparam); + +Window *FindWindowById(WindowClass cls, WindowNumber number); +void DeleteWindow(Window *w); +void DeletePlayerWindows(PlayerID pi); +void ChangeWindowOwner(PlayerID old_player, PlayerID new_player); +Window *BringWindowToFrontById(WindowClass cls, WindowNumber number); +Window *FindWindowFromPt(int x, int y); + +bool IsWindowOfPrototype(const Window *w, const Widget *widget); +void AssignWidgetToWindow(Window *w, const Widget *widget); +Window *AllocateWindow( + int x, + int y, + int width, + int height, + WindowProc *proc, + WindowClass cls, + const Widget *widget, + void *data = NULL); + +Window *AllocateWindowDesc(const WindowDesc *desc, void *data = NULL); +Window *AllocateWindowDescFront(const WindowDesc *desc, int window_number, void *data = NULL); + +void DrawWindowViewport(const Window *w); +void ResizeWindow(Window *w, int x, int y); + +void InitWindowSystem(); +void UnInitWindowSystem(); +void ResetWindowSystem(); +int GetMenuItemIndex(const Window *w, int x, int y); +void InputLoop(); +void InvalidateThisWindowData(Window *w); +void InvalidateWindowData(WindowClass cls, WindowNumber number); +void RelocateAllWindows(int neww, int newh); +int PositionMainToolbar(Window *w); + +/* misc_gui.cpp */ +void GuiShowTooltipsWithArgs(StringID str, uint paramcount, const uint64 params[]); +static inline void GuiShowTooltips(StringID str) +{ + GuiShowTooltipsWithArgs(str, 0, NULL); +} + +/* widget.cpp */ +int GetWidgetFromPos(const Window *w, int x, int y); +void DrawWindowWidgets(const Window *w); +void ShowDropDownMenu(Window *w, const StringID *strings, int selected, int button, uint32 disabled_mask, uint32 hidden_mask); + + +Window *GetCallbackWnd(); +void DeleteNonVitalWindows(); +void DeleteAllNonVitalWindows(); +void HideVitalWindows(); +void ShowVitalWindows(); +Window **FindWindowZPosition(const Window *w); + +/* window.cpp */ +extern Window *_z_windows[]; +extern Window **_last_z_window; +#define FOR_ALL_WINDOWS(wz) for (wz = _z_windows; wz != _last_z_window; wz++) + +VARDEF Point _cursorpos_drag_start; + +VARDEF int _scrollbar_start_pos; +VARDEF int _scrollbar_size; +VARDEF byte _scroller_click_timeout; + +VARDEF bool _scrolling_scrollbar; +VARDEF bool _scrolling_viewport; +VARDEF bool _popup_menu_active; + +VARDEF byte _special_mouse_mode; +enum SpecialMouseMode { + WSM_NONE = 0, + WSM_DRAGDROP = 1, + WSM_SIZING = 2, + WSM_PRESIZE = 3, +}; + +void ScrollbarClickHandler(Window *w, const Widget *wi, int x, int y); + +/** Evenly distribute some widgets when resizing horizontally (often a button row) + * The widgets are presumed to be in a line and numberef from left to right (without gaps) + * @param w widow to modify + * @param left The leftmost widget to resize + * @param right The rightmost widget to resize. Since right side of it is used, remember to set it to RESIZE_RIGHT + */ +void ResizeButtons(Window *w, byte left, byte right); + + +/** + * Sets the enabled/disabled status of a widget. + * By default, widgets are enabled. + * On certain conditions, they have to be disabled. + * @param widget_index : index of this widget in the window + * @param disab_stat : status to use ie: disabled = true, enabled = false + */ +inline void Window::SetWidgetDisabledState(byte widget_index, bool disab_stat) +{ + assert(widget_index < this->widget_count); + SB(this->widget[widget_index].display_flags, WIDG_DISABLED, 1, !!disab_stat); +} + +/** + * Sets a widget to disabled. + * @param widget_index : index of this widget in the window + */ +inline void Window::DisableWidget(byte widget_index) +{ + SetWidgetDisabledState(widget_index, true); +} + +/** + * Sets a widget to Enabled. + * @param widget_index : index of this widget in the window + */ +inline void Window::EnableWidget(byte widget_index) +{ + SetWidgetDisabledState(widget_index, false); +} + +/** + * Gets the enabled/disabled status of a widget. + * @param widget_index : index of this widget in the window + * @return status of the widget ie: disabled = true, enabled = false + */ +inline bool Window::IsWidgetDisabled(byte widget_index) const +{ + assert(widget_index < this->widget_count); + return HasBit(this->widget[widget_index].display_flags, WIDG_DISABLED); +} + +/** + * Sets the hidden/shown status of a widget. + * By default, widgets are visible. + * On certain conditions, they have to be hidden. + * @param widget_index index of this widget in the window + * @param hidden_stat status to use ie. hidden = true, visible = false + */ +inline void Window::SetWidgetHiddenState(byte widget_index, bool hidden_stat) +{ + assert(widget_index < this->widget_count); + SB(this->widget[widget_index].display_flags, WIDG_HIDDEN, 1, !!hidden_stat); +} + +/** + * Sets a widget hidden. + * @param widget_index : index of this widget in the window + */ +inline void Window::HideWidget(byte widget_index) +{ + SetWidgetHiddenState(widget_index, true); +} + +/** + * Sets a widget visible. + * @param widget_index : index of this widget in the window + */ +inline void Window::ShowWidget(byte widget_index) +{ + SetWidgetHiddenState(widget_index, false); +} + +/** + * Gets the visibility of a widget. + * @param widget_index : index of this widget in the window + * @return status of the widget ie: hidden = true, visible = false + */ +inline bool Window::IsWidgetHidden(byte widget_index) const +{ + assert(widget_index < this->widget_count); + return HasBit(this->widget[widget_index].display_flags, WIDG_HIDDEN); +} + +/** + * Sets the lowered/raised status of a widget. + * @param widget_index : index of this widget in the window + * @param lowered_stat : status to use ie: lowered = true, raised = false + */ +inline void Window::SetWidgetLoweredState(byte widget_index, bool lowered_stat) +{ + assert(widget_index < this->widget_count); + SB(this->widget[widget_index].display_flags, WIDG_LOWERED, 1, !!lowered_stat); +} + +/** + * Invert the lowered/raised status of a widget. + * @param widget_index : index of this widget in the window + */ +inline void Window::ToggleWidgetLoweredState(byte widget_index) +{ + assert(widget_index < this->widget_count); + ToggleBit(this->widget[widget_index].display_flags, WIDG_LOWERED); +} + +/** + * Marks a widget as lowered. + * @param widget_index : index of this widget in the window + */ +inline void Window::LowerWidget(byte widget_index) +{ + SetWidgetLoweredState(widget_index, true); +} + +/** + * Marks a widget as raised. + * @param widget_index : index of this widget in the window + */ +inline void Window::RaiseWidget(byte widget_index) +{ + SetWidgetLoweredState(widget_index, false); +} + +/** + * Gets the lowered state of a widget. + * @param widget_index : index of this widget in the window + * @return status of the widget ie: lowered = true, raised= false + */ +inline bool Window::IsWidgetLowered(byte widget_index) const +{ + assert(widget_index < this->widget_count); + return HasBit(this->widget[widget_index].display_flags, WIDG_LOWERED); +} + +#endif /* WINDOW_GUI_H */ diff --git a/src/window_type.h b/src/window_type.h new file mode 100644 index 000000000..bc8ee42b7 --- /dev/null +++ b/src/window_type.h @@ -0,0 +1,98 @@ +/* $Id$ */ + +/** @file window_type.h Types related to windows */ + +#ifndef WINDOW_TYPE_H +#define WINDOW_TYPE_H + +#include "core/enum_type.hpp" + +enum WindowClass { + WC_NONE, + WC_MAIN_WINDOW = WC_NONE, + WC_MAIN_TOOLBAR, + WC_STATUS_BAR, + WC_BUILD_TOOLBAR, + WC_NEWS_WINDOW, + WC_TOWN_DIRECTORY, + WC_STATION_LIST, + WC_TOWN_VIEW, + WC_SMALLMAP, + WC_TRAINS_LIST, + WC_ROADVEH_LIST, + WC_SHIPS_LIST, + WC_AIRCRAFT_LIST, + WC_VEHICLE_VIEW, + WC_VEHICLE_DETAILS, + WC_VEHICLE_REFIT, + WC_VEHICLE_ORDERS, + WC_STATION_VIEW, + WC_VEHICLE_DEPOT, + WC_BUILD_VEHICLE, + WC_BUILD_BRIDGE, + WC_ERRMSG, + WC_BUILD_STATION, + WC_BUS_STATION, + WC_TRUCK_STATION, + WC_BUILD_DEPOT, + WC_COMPANY, + WC_FINANCES, + WC_PLAYER_COLOR, + WC_QUERY_STRING, + WC_SAVELOAD, + WC_SELECT_GAME, + WC_TOOLBAR_MENU, + WC_INCOME_GRAPH, + WC_OPERATING_PROFIT, + WC_TOOLTIPS, + WC_INDUSTRY_VIEW, + WC_PLAYER_FACE, + WC_LAND_INFO, + WC_TOWN_AUTHORITY, + WC_SUBSIDIES_LIST, + WC_GRAPH_LEGEND, + WC_DELIVERED_CARGO, + WC_PERFORMANCE_HISTORY, + WC_COMPANY_VALUE, + WC_COMPANY_LEAGUE, + WC_BUY_COMPANY, + WC_PAYMENT_RATES, + WC_ENGINE_PREVIEW, + WC_MUSIC_WINDOW, + WC_MUSIC_TRACK_SELECTION, + WC_SCEN_LAND_GEN, + WC_SCEN_TOWN_GEN, + WC_SCEN_INDUSTRY, + WC_SCEN_BUILD_ROAD, + WC_BUILD_TREES, + WC_SEND_NETWORK_MSG, + WC_DROPDOWN_MENU, + WC_BUILD_INDUSTRY, + WC_GAME_OPTIONS, + WC_NETWORK_WINDOW, + WC_INDUSTRY_DIRECTORY, + WC_MESSAGE_HISTORY, + WC_CHEATS, + WC_PERFORMANCE_DETAIL, + WC_CONSOLE, + WC_EXTRA_VIEW_PORT, + WC_CLIENT_LIST, + WC_NETWORK_STATUS_WINDOW, + WC_CUSTOM_CURRENCY, + WC_REPLACE_VEHICLE, + WC_HIGHSCORE, + WC_ENDSCREEN, + WC_SIGN_LIST, + WC_GENERATE_LANDSCAPE, + WC_GENERATE_PROGRESS_WINDOW, + WC_CONFIRM_POPUP_QUERY, + WC_TRANSPARENCY_TOOLBAR, + WC_VEHICLE_TIMETABLE, + WC_BUILD_SIGNAL, + WC_COMPANY_PASSWORD_WINDOW, +}; + +struct Window; +typedef int32 WindowNumber; + +#endif /* WINDOW_TYPE_H */ -- cgit v1.2.3-54-g00ecf