src/window.h
branchgamebalance
changeset 9895 7bd07f43b0e3
parent 6505 abcb0580d976
child 9908 0fa543611bbe
equal deleted inserted replaced
9894:70d78ac95d6c 9895:7bd07f43b0e3
     9 #include "string.h"
     9 #include "string.h"
    10 #include "order.h"
    10 #include "order.h"
    11 #include "rail.h"
    11 #include "rail.h"
    12 #include "airport.h"
    12 #include "airport.h"
    13 
    13 
    14 typedef struct WindowEvent WindowEvent;
    14 struct WindowEvent;
    15 
    15 
    16 typedef void WindowProc(Window *w, WindowEvent *e);
    16 typedef void WindowProc(Window *w, WindowEvent *e);
    17 
    17 
    18 /* How the resize system works:
    18 /* How the resize system works:
    19     First, you need to add a WWT_RESIZEBOX to the widgets, and you need
    19     First, you need to add a WWT_RESIZEBOX to the widgets, and you need
    40     the default height/width of the window itself. You can change this
    40     the default height/width of the window itself. You can change this
    41     AFTER window-creation, with:
    41     AFTER window-creation, with:
    42      w->resize.width or w->resize.height.
    42      w->resize.width or w->resize.height.
    43    That was all.. good luck, and enjoy :) -- TrueLight */
    43    That was all.. good luck, and enjoy :) -- TrueLight */
    44 
    44 
    45 typedef enum ResizeFlags {
    45 enum ResizeFlag {
    46 	RESIZE_NONE   = 0,  ///< no resize required
    46 	RESIZE_NONE   = 0,  ///< no resize required
    47 
    47 
    48 	RESIZE_LEFT   = 1,  ///< left resize flag
    48 	RESIZE_LEFT   = 1,  ///< left resize flag
    49 	RESIZE_RIGHT  = 2,  ///< rigth resize flag
    49 	RESIZE_RIGHT  = 2,  ///< rigth resize flag
    50 	RESIZE_TOP    = 4,  ///< top resize flag
    50 	RESIZE_TOP    = 4,  ///< top resize flag
    62 	 * These states are used in exceptions. If nothing is specified, they will indicate
    62 	 * These states are used in exceptions. If nothing is specified, they will indicate
    63 	 * Enabled, visible or unclicked widgets*/
    63 	 * Enabled, visible or unclicked widgets*/
    64 	WIDG_DISABLED = 4,  ///< widget is greyed out, not available
    64 	WIDG_DISABLED = 4,  ///< widget is greyed out, not available
    65 	WIDG_HIDDEN   = 5,  ///< widget is made invisible
    65 	WIDG_HIDDEN   = 5,  ///< widget is made invisible
    66 	WIDG_LOWERED  = 6,  ///< widget is paint lowered, a pressed button in fact
    66 	WIDG_LOWERED  = 6,  ///< widget is paint lowered, a pressed button in fact
    67 } ResizeFlag;
    67 };
    68 
    68 
    69 enum {
    69 enum {
    70 	WIDGET_LIST_END = -1, ///< indicate the end of widgets' list for vararg functions
    70 	WIDGET_LIST_END = -1, ///< indicate the end of widgets' list for vararg functions
    71 };
    71 };
    72 
    72 
    73 typedef struct Widget {
    73 struct Widget {
    74 	byte type;                        ///< Widget type, see WindowWidgetTypes
    74 	byte type;                        ///< Widget type, see WindowWidgetTypes
    75 	byte display_flags;               ///< Resize direction, alignment, etc. during resizing, see ResizeFlags
    75 	byte display_flags;               ///< Resize direction, alignment, etc. during resizing, see ResizeFlags
    76 	byte color;                       ///< Widget colour, see docs/ottd-colourtext-palette.png
    76 	byte color;                       ///< Widget colour, see docs/ottd-colourtext-palette.png
    77 	int16 left, right, top, bottom;   ///< The position offsets inside the window
    77 	int16 left, right, top, bottom;   ///< The position offsets inside the window
    78 	uint16 data;                      ///< The String/Image or special code (list-matrixes) of a widget
    78 	uint16 data;                      ///< The String/Image or special code (list-matrixes) of a widget
    79 	StringID tooltips;                ///< Tooltips that are shown when rightclicking on a widget
    79 	StringID tooltips;                ///< Tooltips that are shown when rightclicking on a widget
    80 } Widget;
    80 };
    81 
    81 
    82 typedef enum FrameFlags {
    82 enum FrameFlags {
    83 	FR_NONE         = 0x00,
    83 	FR_NONE         = 0x00,
    84 	FR_TRANSPARENT  = 0x01,  ///< Makes the background transparent if set
    84 	FR_TRANSPARENT  = 0x01,  ///< Makes the background transparent if set
    85 	FR_BORDERONLY   = 0x10,  ///< Draw border only, no background
    85 	FR_BORDERONLY   = 0x10,  ///< Draw border only, no background
    86 	FR_LOWERED      = 0x20,  ///< If set the frame is lowered and the background color brighter (ie. buttons when pressed)
    86 	FR_LOWERED      = 0x20,  ///< If set the frame is lowered and the background color brighter (ie. buttons when pressed)
    87 	FR_DARKENED     = 0x40,  ///< If set the background is darker, allows for lowered frames with normal background color when used with FR_LOWERED (ie. dropdown boxes)
    87 	FR_DARKENED     = 0x40,  ///< If set the background is darker, allows for lowered frames with normal background color when used with FR_LOWERED (ie. dropdown boxes)
    88 } FrameFlags;
    88 };
    89 
    89 
    90 DECLARE_ENUM_AS_BIT_SET(FrameFlags);
    90 DECLARE_ENUM_AS_BIT_SET(FrameFlags);
    91 
    91 
    92 void DrawFrameRect(int left, int top, int right, int bottom, int color, FrameFlags flags);
    92 void DrawFrameRect(int left, int top, int right, int bottom, int color, FrameFlags flags);
    93 
    93 
   184 			int wheel;     ///< how much was 'wheel'd'
   184 			int wheel;     ///< how much was 'wheel'd'
   185 		} wheel;
   185 		} wheel;
   186 	} we;
   186 	} we;
   187 };
   187 };
   188 
   188 
   189 typedef struct WindowDesc {
   189 struct WindowDesc {
   190 	int16 left, top, width, height;
   190 	int16 left, top, width, height;
   191 	WindowClass cls;
   191 	WindowClass cls;
   192 	WindowClass parent_cls;
   192 	WindowClass parent_cls;
   193 	uint32 flags;
   193 	uint32 flags;
   194 	const Widget *widgets;
   194 	const Widget *widgets;
   195 	WindowProc *proc;
   195 	WindowProc *proc;
   196 } WindowDesc;
   196 };
   197 
   197 
   198 enum WindowDefaultFlag {
   198 enum WindowDefaultFlag {
   199 	WDF_STD_TOOLTIPS    =   1, ///< use standard routine when displaying tooltips
   199 	WDF_STD_TOOLTIPS    =   1, ///< use standard routine when displaying tooltips
   200 	WDF_DEF_WIDGET      =   2, ///< default widget control for some widgets in the on click event
   200 	WDF_DEF_WIDGET      =   2, ///< default widget control for some widgets in the on click event
   201 	WDF_STD_BTN         =   4, ///< default handling for close and drag widgets (widget no 0 and 1)
   201 	WDF_STD_BTN         =   4, ///< default handling for close and drag widgets (widget no 0 and 1)
   212 	WDP_CENTER    = -2, ///< Center the window (left/right or top/bottom)
   212 	WDP_CENTER    = -2, ///< Center the window (left/right or top/bottom)
   213 	WDP_ALIGN_TBR = -3, ///< Align the right side of the window with the right side of the main toolbar
   213 	WDP_ALIGN_TBR = -3, ///< Align the right side of the window with the right side of the main toolbar
   214 	WDP_ALIGN_TBL = -4, ///< Align the left side of the window with the left side of the main toolbar
   214 	WDP_ALIGN_TBL = -4, ///< Align the left side of the window with the left side of the main toolbar
   215 };
   215 };
   216 
   216 
   217 typedef struct Textbuf {
   217 struct Textbuf {
   218 	char *buf;                  ///< buffer in which text is saved
   218 	char *buf;                  ///< buffer in which text is saved
   219 	uint16 maxlength, maxwidth; ///< the maximum size of the buffer. Maxwidth specifies screensize in pixels, maxlength is in bytes
   219 	uint16 maxlength, maxwidth; ///< the maximum size of the buffer. Maxwidth specifies screensize in pixels, maxlength is in bytes
   220 	uint16 length, width;       ///< the current size of the string. Width specifies screensize in pixels, length is in bytes
   220 	uint16 length, width;       ///< the current size of the string. Width specifies screensize in pixels, length is in bytes
   221 	bool caret;                 ///< is the caret ("_") visible or not
   221 	bool caret;                 ///< is the caret ("_") visible or not
   222 	uint16 caretpos;            ///< the current position of the caret in the buffer, in bytes
   222 	uint16 caretpos;            ///< the current position of the caret in the buffer, in bytes
   223 	uint16 caretxoffs;          ///< the current position of the caret in pixels
   223 	uint16 caretxoffs;          ///< the current position of the caret in pixels
   224 } Textbuf;
   224 };
   225 
   225 
   226 #define WP(ptr,str) (*(str*)(ptr)->custom)
   226 #define WP(ptr,str) (*(str*)(ptr)->custom)
   227 /* You cannot 100% reliably calculate the biggest custom struct as
   227 /* You cannot 100% reliably calculate the biggest custom struct as
   228  * the number of pointers in it and alignment will have a huge impact.
   228  * the number of pointers in it and alignment will have a huge impact.
   229  * 96 is the largest window-size for 64-bit machines currently */
   229  * 96 is the largest window-size for 64-bit machines currently */
   230 #define WINDOW_CUSTOM_SIZE 96
   230 #define WINDOW_CUSTOM_SIZE 96
   231 
   231 
   232 typedef struct Scrollbar {
   232 struct Scrollbar {
   233 	uint16 count, cap, pos;
   233 	uint16 count, cap, pos;
   234 } Scrollbar;
   234 };
   235 
   235 
   236 typedef struct ResizeInfo {
   236 struct ResizeInfo {
   237 	uint width; ///< Minimum width and height
   237 	uint width; ///< Minimum width and height
   238 	uint height;
   238 	uint height;
   239 	uint step_width; ///< In how big steps the width and height go
   239 	uint step_width; ///< In how big steps the width and height go
   240 	uint step_height;
   240 	uint step_height;
   241 } ResizeInfo;
   241 };
   242 
   242 
   243 typedef struct WindowMessage {
   243 struct WindowMessage {
   244 		int msg;
   244 	int msg;
   245 		int wparam;
   245 	int wparam;
   246 		int lparam;
   246 	int lparam;
   247 } WindowMessage;
   247 };
   248 
   248 
   249 struct Window {
   249 struct Window {
   250 	uint16 flags4;
   250 	uint16 flags4;
   251 	WindowClass window_class;
   251 	WindowClass window_class;
   252 	WindowNumber window_number;
   252 	WindowNumber window_number;
   269 	WindowMessage message;
   269 	WindowMessage message;
   270 	Window *parent;
   270 	Window *parent;
   271 	byte custom[WINDOW_CUSTOM_SIZE];
   271 	byte custom[WINDOW_CUSTOM_SIZE];
   272 };
   272 };
   273 
   273 
   274 typedef struct querystr_d {
   274 struct querystr_d {
   275 	StringID caption;
   275 	StringID caption;
   276 	Textbuf text;
   276 	Textbuf text;
   277 	const char *orig;
   277 	const char *orig;
   278 	CharSetFilter afilter;
   278 	CharSetFilter afilter;
   279 	bool handled;
   279 	bool handled;
   280 } querystr_d;
   280 };
   281 assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(querystr_d));
   281 assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(querystr_d));
   282 
   282 
   283 typedef struct {
   283 struct menu_d {
   284 	byte item_count;      ///< follow_vehicle
   284 	byte item_count;      ///< follow_vehicle
   285 	byte sel_index;       ///< scrollpos_x
   285 	byte sel_index;       ///< scrollpos_x
   286 	byte main_button;     ///< scrollpos_y
   286 	byte main_button;     ///< scrollpos_y
   287 	byte action_id;
   287 	byte action_id;
   288 	StringID string_id;   ///< unk30
   288 	StringID string_id;   ///< unk30
   289 	uint16 checked_items; ///< unk32
   289 	uint16 checked_items; ///< unk32
   290 	byte disabled_items;
   290 	byte disabled_items;
   291 } menu_d;
   291 };
   292 assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(menu_d));
   292 assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(menu_d));
   293 
   293 
   294 typedef struct {
   294 struct def_d {
   295 	int16 data_1, data_2, data_3;
   295 	int16 data_1, data_2, data_3;
   296 	int16 data_4, data_5;
   296 	int16 data_4, data_5;
   297 	bool close;
   297 	bool close;
   298 	byte byte_1;
   298 	byte byte_1;
   299 } def_d;
   299 };
   300 assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(def_d));
   300 assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(def_d));
   301 
   301 
   302 typedef struct {
   302 struct void_d {
   303 	void *data;
   303 	void *data;
   304 } void_d;
   304 };
   305 assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(void_d));
   305 assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(void_d));
   306 
   306 
   307 typedef struct {
   307 struct tree_d {
   308 	uint16 base;
   308 	uint16 base;
   309 	uint16 count;
   309 	uint16 count;
   310 } tree_d;
   310 };
   311 assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(tree_d));
   311 assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(tree_d));
   312 
   312 
   313 typedef struct {
   313 struct tooltips_d {
   314 	StringID string_id;
   314 	StringID string_id;
   315 	byte paramcount;
   315 	byte paramcount;
   316 	uint32 params[5];
   316 	uint32 params[5];
   317 } tooltips_d;
   317 };
   318 assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(tooltips_d));
   318 assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(tooltips_d));
   319 
   319 
   320 typedef struct {
   320 struct buildvehicle_d {
   321 	byte vehicle_type;
   321 	byte vehicle_type;
   322 	union {
   322 	union {
   323 		RailTypeByte railtype;
   323 		RailTypeByte railtype;
   324 		AirportFTAClass::Flags flags;
   324 		AirportFTAClass::Flags flags;
   325 	} filter;
   325 	} filter;
   328 	byte sort_criteria;
   328 	byte sort_criteria;
   329 	bool regenerate_list;
   329 	bool regenerate_list;
   330 	EngineID sel_engine;
   330 	EngineID sel_engine;
   331 	EngineID rename_engine;
   331 	EngineID rename_engine;
   332 	EngineList eng_list;
   332 	EngineList eng_list;
   333 } buildvehicle_d;
   333 };
   334 assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(buildvehicle_d));
   334 assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(buildvehicle_d));
   335 
   335 
   336 typedef struct {
   336 struct replaceveh_d {
   337 	byte sel_index[2];
   337 	byte sel_index[2];
   338 	EngineID sel_engine[2];
   338 	EngineID sel_engine[2];
   339 	uint16 count[2];
   339 	uint16 count[2];
   340 	bool wagon_btnstate; ///< true means engine is selected
   340 	bool wagon_btnstate; ///< true means engine is selected
   341 	EngineList list[2];
   341 	EngineList list[2];
   342 	bool update_left;
   342 	bool update_left;
   343 	bool update_right;
   343 	bool update_right;
   344 	bool init_lists;
   344 	bool init_lists;
   345 } replaceveh_d;
   345 };
   346 assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(replaceveh_d));
   346 assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(replaceveh_d));
   347 
   347 
   348 typedef struct {
   348 struct depot_d {
   349 	VehicleID sel;
   349 	VehicleID sel;
   350 	byte type;
   350 	byte type;
   351 	bool generate_list;
   351 	bool generate_list;
   352 	uint16 engine_list_length;
   352 	uint16 engine_list_length;
   353 	uint16 wagon_list_length;
   353 	uint16 wagon_list_length;
   354 	uint16 engine_count;
   354 	uint16 engine_count;
   355 	uint16 wagon_count;
   355 	uint16 wagon_count;
   356 	Vehicle **vehicle_list;
   356 	Vehicle **vehicle_list;
   357 	Vehicle **wagon_list;
   357 	Vehicle **wagon_list;
   358 } depot_d;
   358 };
   359 assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(depot_d));
   359 assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(depot_d));
   360 
   360 
   361 typedef struct {
   361 struct order_d {
   362 	int sel;
   362 	int sel;
   363 } order_d;
   363 };
   364 assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(order_d));
   364 assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(order_d));
   365 
   365 
   366 typedef struct {
   366 struct traindetails_d {
   367 	byte tab;
   367 	byte tab;
   368 } traindetails_d;
   368 };
   369 assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(traindetails_d));
   369 assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(traindetails_d));
   370 
   370 
   371 typedef struct {
   371 struct smallmap_d {
   372 	int32 scroll_x;
   372 	int32 scroll_x;
   373 	int32 scroll_y;
   373 	int32 scroll_y;
   374 	int32 subscroll;
   374 	int32 subscroll;
   375 } smallmap_d;
   375 };
   376 assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(smallmap_d));
   376 assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(smallmap_d));
   377 
   377 
   378 typedef struct {
   378 struct facesel_d {
   379 	uint32 face;
   379 	uint32 face;
   380 	byte gender;
   380 	byte gender;
   381 } facesel_d;
   381 };
   382 assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(facesel_d));
   382 assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(facesel_d));
   383 
   383 
   384 typedef struct {
   384 struct refit_d {
   385 	int sel;
   385 	int sel;
   386 	struct RefitOption *cargo;
   386 	struct RefitOption *cargo;
   387 	struct RefitList *list;
   387 	struct RefitList *list;
   388 	uint length;
   388 	uint length;
   389 	VehicleOrderID order;
   389 	VehicleOrderID order;
   390 } refit_d;
   390 };
   391 assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(refit_d));
   391 assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(refit_d));
   392 
   392 
   393 typedef struct {
   393 struct vp_d {
   394 	VehicleID follow_vehicle;
   394 	VehicleID follow_vehicle;
   395 	int32 scrollpos_x;
   395 	int32 scrollpos_x;
   396 	int32 scrollpos_y;
   396 	int32 scrollpos_y;
   397 } vp_d;
   397 };
   398 assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(vp_d));
   398 assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(vp_d));
   399 
   399 
   400 /* vp2_d is the same as vp_d, except for the data_# values.. */
   400 /* vp2_d is the same as vp_d, except for the data_# values.. */
   401 typedef struct {
   401 struct vp2_d {
   402 	VehicleID follow_vehicle;
   402 	VehicleID follow_vehicle;
   403 	int32 scrollpos_x;
   403 	int32 scrollpos_x;
   404 	int32 scrollpos_y;
   404 	int32 scrollpos_y;
   405 	byte data_1;
   405 	byte data_1;
   406 	byte data_2;
   406 	byte data_2;
   407 	byte data_3;
   407 	byte data_3;
   408 } vp2_d;
   408 };
   409 assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(vp2_d));
   409 assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(vp2_d));
   410 
   410 
   411 typedef struct {
   411 struct news_d {
   412 	uint16 follow_vehicle;
   412 	uint16 follow_vehicle;
   413 	int32 scrollpos_x;
   413 	int32 scrollpos_x;
   414 	int32 scrollpos_y;
   414 	int32 scrollpos_y;
   415 	NewsItem *ni;
   415 	NewsItem *ni;
   416 } news_d;
   416 };
   417 assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(news_d));
   417 assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(news_d));
   418 
   418 
   419 typedef struct {
   419 struct highscore_d {
   420 	uint32 background_img;
   420 	uint32 background_img;
   421 	int8 rank;
   421 	int8 rank;
   422 } highscore_d;
   422 };
   423 assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(highscore_d));
   423 assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(highscore_d));
   424 
   424 
   425 typedef struct {
   425 struct scroller_d {
   426 	int height;
   426 	int height;
   427 	uint16 counter;
   427 	uint16 counter;
   428 } scroller_d;
   428 };
   429 assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(scroller_d));
   429 assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(scroller_d));
   430 
   430 
   431 typedef enum SortListFlags {
   431 enum SortListFlags {
   432 	VL_NONE    = 0x00,  ///< no sort
   432 	VL_NONE    = 0x00,  ///< no sort
   433 	VL_DESC    = 0x01,  ///< sort descending or ascending
   433 	VL_DESC    = 0x01,  ///< sort descending or ascending
   434 	VL_RESORT  = 0x02,  ///< instruct the code to resort the list in the next loop
   434 	VL_RESORT  = 0x02,  ///< instruct the code to resort the list in the next loop
   435 	VL_REBUILD = 0x04,  ///< create sort-listing to use for qsort and friends
   435 	VL_REBUILD = 0x04,  ///< create sort-listing to use for qsort and friends
   436 	VL_END     = 0x08
   436 	VL_END     = 0x08
   437 } SortListFlags;
   437 };
   438 
   438 
   439 DECLARE_ENUM_AS_BIT_SET(SortListFlags);
   439 DECLARE_ENUM_AS_BIT_SET(SortListFlags);
   440 
   440 
   441 typedef struct Listing {
   441 struct Listing {
   442 	bool order;    ///< Ascending/descending
   442 	bool order;    ///< Ascending/descending
   443 	byte criteria; ///< Sorting criteria
   443 	byte criteria; ///< Sorting criteria
   444 } Listing;
   444 };
   445 
   445 
   446 typedef struct list_d {
   446 struct list_d {
   447 	uint16 list_length;  ///< length of the list being sorted
   447 	uint16 list_length;  ///< length of the list being sorted
   448 	byte sort_type;      ///< what criteria to sort on
   448 	byte sort_type;      ///< what criteria to sort on
   449 	SortListFlags flags; ///< used to control sorting/resorting/etc.
   449 	SortListFlags flags; ///< used to control sorting/resorting/etc.
   450 	uint16 resort_timer; ///< resort list after a given amount of ticks if set
   450 	uint16 resort_timer; ///< resort list after a given amount of ticks if set
   451 } list_d;
   451 };
   452 assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(list_d));
   452 assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(list_d));
   453 
   453 
   454 typedef struct message_d {
   454 struct message_d {
   455 	int msg;
   455 	int msg;
   456 	int wparam;
   456 	int wparam;
   457 	int lparam;
   457 	int lparam;
   458 } message_d;
   458 };
   459 assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(message_d));
   459 assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(message_d));
   460 
   460 
   461 typedef struct dropdown_d {
   461 struct dropdown_d {
   462 	uint32 disabled_state;
   462 	uint32 disabled_state;
   463 	uint32 hidden_state;
   463 	uint32 hidden_state;
   464 	WindowClass parent_wnd_class;
   464 	WindowClass parent_wnd_class;
   465 	WindowNumber parent_wnd_num;
   465 	WindowNumber parent_wnd_num;
   466 	byte parent_button;
   466 	byte parent_button;
   467 	byte num_items;
   467 	byte num_items;
   468 	byte selected_index;
   468 	byte selected_index;
   469 	const StringID *items;
   469 	const StringID *items;
   470 	byte click_delay;
   470 	byte click_delay;
   471 	bool drag_mode;
   471 	bool drag_mode;
   472 } dropdown_d;
   472 };
   473 assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(dropdown_d));
   473 assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(dropdown_d));
   474 
   474 
   475 
   475 
   476 /****************** THESE ARE NOT WIDGET TYPES!!!!! *******************/
   476 /****************** THESE ARE NOT WIDGET TYPES!!!!! *******************/
   477 enum WindowWidgetBehaviours {
   477 enum WindowWidgetBehaviours {
   490 	WWT_IMGBTN_2,   ///< button with diff image when clicked
   490 	WWT_IMGBTN_2,   ///< button with diff image when clicked
   491 
   491 
   492 	WWT_TEXTBTN,    ///< button with text
   492 	WWT_TEXTBTN,    ///< button with text
   493 	WWT_TEXTBTN_2,  ///< button with diff text when clicked
   493 	WWT_TEXTBTN_2,  ///< button with diff text when clicked
   494 	WWT_LABEL,      ///< centered label
   494 	WWT_LABEL,      ///< centered label
       
   495 	WWT_TEXT,       ///< pure simple text
   495 	WWT_MATRIX,
   496 	WWT_MATRIX,
   496 	WWT_SCROLLBAR,
   497 	WWT_SCROLLBAR,
   497 	WWT_FRAME,      ///< frame
   498 	WWT_FRAME,      ///< frame
   498 	WWT_CAPTION,
   499 	WWT_CAPTION,
   499 
   500 
   531 	WF_SCROLL2           = 1 << 13,
   532 	WF_SCROLL2           = 1 << 13,
   532 };
   533 };
   533 
   534 
   534 /* window.cpp */
   535 /* window.cpp */
   535 void CallWindowEventNP(Window *w, int event);
   536 void CallWindowEventNP(Window *w, int event);
   536 void CallWindowTickEvent(void);
   537 void CallWindowTickEvent();
   537 void SetWindowDirty(const Window *w);
   538 void SetWindowDirty(const Window *w);
   538 void SendWindowMessage(WindowClass wnd_class, WindowNumber wnd_num, int msg, int wparam, int lparam);
   539 void SendWindowMessage(WindowClass wnd_class, WindowNumber wnd_num, int msg, int wparam, int lparam);
   539 void SendWindowMessageClass(WindowClass wnd_class, int msg, int wparam, int lparam);
   540 void SendWindowMessageClass(WindowClass wnd_class, int msg, int wparam, int lparam);
   540 
   541 
   541 Window *FindWindowById(WindowClass cls, WindowNumber number);
   542 Window *FindWindowById(WindowClass cls, WindowNumber number);
   707 {
   708 {
   708 	assert(widget_index < w->widget_count);
   709 	assert(widget_index < w->widget_count);
   709 	return HASBIT(w->widget[widget_index].display_flags, WIDG_LOWERED);
   710 	return HASBIT(w->widget[widget_index].display_flags, WIDG_LOWERED);
   710 }
   711 }
   711 
   712 
   712 void InitWindowSystem(void);
   713 void InitWindowSystem();
   713 void UnInitWindowSystem(void);
   714 void UnInitWindowSystem();
   714 void ResetWindowSystem(void);
   715 void ResetWindowSystem();
   715 int GetMenuItemIndex(const Window *w, int x, int y);
   716 int GetMenuItemIndex(const Window *w, int x, int y);
   716 void InputLoop(void);
   717 void InputLoop();
   717 void InvalidateWidget(const Window *w, byte widget_index);
   718 void InvalidateWidget(const Window *w, byte widget_index);
   718 void InvalidateThisWindowData(Window *w);
   719 void InvalidateThisWindowData(Window *w);
   719 void InvalidateWindowData(WindowClass cls, WindowNumber number);
   720 void InvalidateWindowData(WindowClass cls, WindowNumber number);
   720 void RaiseWindowButtons(Window *w);
   721 void RaiseWindowButtons(Window *w);
   721 void RelocateAllWindows(int neww, int newh);
   722 void RelocateAllWindows(int neww, int newh);
   736 void DrawWindowWidgets(const Window *w);
   737 void DrawWindowWidgets(const Window *w);
   737 void ShowDropDownMenu(Window *w, const StringID *strings, int selected, int button, uint32 disabled_mask, uint32 hidden_mask);
   738 void ShowDropDownMenu(Window *w, const StringID *strings, int selected, int button, uint32 disabled_mask, uint32 hidden_mask);
   738 
   739 
   739 void HandleButtonClick(Window *w, byte widget);
   740 void HandleButtonClick(Window *w, byte widget);
   740 
   741 
   741 Window *GetCallbackWnd(void);
   742 Window *GetCallbackWnd();
   742 void DeleteNonVitalWindows(void);
   743 void DeleteNonVitalWindows();
   743 void DeleteAllNonVitalWindows(void);
   744 void DeleteAllNonVitalWindows();
   744 void HideVitalWindows(void);
   745 void HideVitalWindows();
   745 void ShowVitalWindows(void);
   746 void ShowVitalWindows();
   746 Window **FindWindowZPosition(const Window *w);
   747 Window **FindWindowZPosition(const Window *w);
   747 
   748 
   748 /* window.cpp */
   749 /* window.cpp */
   749 extern Window *_z_windows[];
   750 extern Window *_z_windows[];
   750 extern Window **_last_z_window;
   751 extern Window **_last_z_window;