src/window_gui.h
branchNewGRF_ports
changeset 10184 fcf5fb2548eb
parent 6878 7d1ff2f621c7
child 10200 aba3af04cdbd
equal deleted inserted replaced
10179:eec5a7dcbf61 10184:fcf5fb2548eb
    71 
    71 
    72 enum {
    72 enum {
    73 	WIDGET_LIST_END = -1, ///< indicate the end of widgets' list for vararg functions
    73 	WIDGET_LIST_END = -1, ///< indicate the end of widgets' list for vararg functions
    74 };
    74 };
    75 
    75 
       
    76 /**
       
    77  * Window widget data structure
       
    78  */
    76 struct Widget {
    79 struct Widget {
    77 	byte type;                        ///< Widget type, see WindowWidgetTypes
    80 	byte type;                        ///< Widget type, see WindowWidgetTypes
    78 	byte display_flags;               ///< Resize direction, alignment, etc. during resizing, see ResizeFlags
    81 	byte display_flags;               ///< Resize direction, alignment, etc. during resizing, see ResizeFlags
    79 	byte color;                       ///< Widget colour, see docs/ottd-colourtext-palette.png
    82 	byte color;                       ///< Widget colour, see docs/ottd-colourtext-palette.png
    80 	int16 left, right, top, bottom;   ///< The position offsets inside the window
    83 	int16 left, right, top, bottom;   ///< The position offsets inside the window
    81 	uint16 data;                      ///< The String/Image or special code (list-matrixes) of a widget
    84 	uint16 data;                      ///< The String/Image or special code (list-matrixes) of a widget
    82 	StringID tooltips;                ///< Tooltips that are shown when rightclicking on a widget
    85 	StringID tooltips;                ///< Tooltips that are shown when rightclicking on a widget
    83 };
    86 };
    84 
    87 
       
    88 /**
       
    89  * Flags to describe the look of the frame
       
    90  */
    85 enum FrameFlags {
    91 enum FrameFlags {
    86 	FR_NONE         =  0,
    92 	FR_NONE         =  0,
    87 	FR_TRANSPARENT  =  1 << 0,  ///< Makes the background transparent if set
    93 	FR_TRANSPARENT  =  1 << 0,  ///< Makes the background transparent if set
    88 	FR_BORDERONLY   =  1 << 4,  ///< Draw border only, no background
    94 	FR_BORDERONLY   =  1 << 4,  ///< Draw border only, no background
    89 	FR_LOWERED      =  1 << 5,  ///< If set the frame is lowered and the background color brighter (ie. buttons when pressed)
    95 	FR_LOWERED      =  1 << 5,  ///< If set the frame is lowered and the background color brighter (ie. buttons when pressed)
    90 	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)
    96 	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)
    91 };
    97 };
    92 
    98 
    93 DECLARE_ENUM_AS_BIT_SET(FrameFlags);
    99 DECLARE_ENUM_AS_BIT_SET(FrameFlags);
    94 
   100 
       
   101 /* wiget.cpp */
    95 void DrawFrameRect(int left, int top, int right, int bottom, int color, FrameFlags flags);
   102 void DrawFrameRect(int left, int top, int right, int bottom, int color, FrameFlags flags);
    96 
   103 
       
   104 /**
       
   105  * Available window events
       
   106  */
    97 enum WindowEventCodes {
   107 enum WindowEventCodes {
    98 	WE_CREATE,
   108 	WE_CREATE,       ///< Initialize the Window
    99 	WE_DESTROY,
   109 	WE_DESTROY,      ///< Prepare for deletion of the window
   100 	WE_PAINT,
   110 	WE_PAINT,        ///< Repaint the window contents
   101 	WE_KEYPRESS,
   111 	WE_KEYPRESS,     ///< Key pressed
   102 	WE_CLICK,
   112 	WE_CLICK,        ///< Left mouse button click
   103 	WE_DOUBLE_CLICK,
   113 	WE_DOUBLE_CLICK, ///< Left mouse button double click
   104 	WE_RCLICK,
   114 	WE_RCLICK,       ///< Right mouse button click
   105 	WE_MOUSEOVER,
   115 	WE_MOUSEOVER,
   106 	WE_MOUSELOOP,
   116 	WE_MOUSELOOP,
   107 	WE_MOUSEWHEEL,
   117 	WE_MOUSEWHEEL,
   108 	WE_TICK,
   118 	WE_TICK,         ///< Regularly occurring event (about once every 20 seconds orso, 10 days) for slowly changing content (typically list sorting)
   109 	WE_4,
   119 	WE_4,            ///< Regularly occurring event for updating continuously changing window content (other than view ports), or timer expiring
   110 	WE_TIMEOUT,
   120 	WE_TIMEOUT,
   111 	WE_PLACE_OBJ,
   121 	WE_PLACE_OBJ,
   112 	WE_ABORT_PLACE_OBJ,
   122 	WE_ABORT_PLACE_OBJ,
   113 	WE_ON_EDIT_TEXT,
   123 	WE_ON_EDIT_TEXT,
   114 	WE_ON_EDIT_TEXT_CANCEL,
   124 	WE_ON_EDIT_TEXT_CANCEL,
   117 	WE_DRAGDROP,
   127 	WE_DRAGDROP,
   118 	WE_PLACE_DRAG,
   128 	WE_PLACE_DRAG,
   119 	WE_PLACE_MOUSEUP,
   129 	WE_PLACE_MOUSEUP,
   120 	WE_PLACE_PRESIZE,
   130 	WE_PLACE_PRESIZE,
   121 	WE_DROPDOWN_SELECT,
   131 	WE_DROPDOWN_SELECT,
   122 	WE_RESIZE,
   132 	WE_RESIZE,          ///< Request to resize the window, @see WindowEvent.we.resize
   123 	WE_MESSAGE,
   133 	WE_MESSAGE,         ///< Receipt of a message from another window. @see WindowEvent.we.message, SendWindowMessage(), SendWindowMessageClass()
   124 	WE_SCROLL,
   134 	WE_SCROLL,
   125 	WE_INVALIDATE_DATA,
   135 	WE_INVALIDATE_DATA, ///< Notification that data displayed by the window is obsolete
   126 	WE_CTRL_CHANGED,
   136 	WE_CTRL_CHANGED,    ///< CTRL key has changed state
   127 };
   137 };
   128 
   138 
       
   139 /**
       
   140  * Data structures for additional data associated with a window event
       
   141  * @see WindowEventCodes
       
   142  */
   129 struct WindowEvent {
   143 struct WindowEvent {
   130 	byte event;
   144 	byte event;
   131 	union {
   145 	union {
   132 		struct {
   146 		struct {
   133 			void *data;
   147 			void *data;
   198 			bool cont;     ///< continue the search? (default true)
   212 			bool cont;     ///< continue the search? (default true)
   199 		} ctrl;
   213 		} ctrl;
   200 	} we;
   214 	} we;
   201 };
   215 };
   202 
   216 
       
   217 /**
       
   218  * High level window description
       
   219  */
   203 struct WindowDesc {
   220 struct WindowDesc {
   204 	int16 left, top, minimum_width, minimum_height, default_width, default_height;
   221 	int16 left;             ///< Prefered x position of left edge of the window, @see WindowDefaultPosition()
   205 	WindowClass cls;
   222 	int16 top;              ///< Prefered y position of the top of the window, @see WindowDefaultPosition()
   206 	WindowClass parent_cls;
   223 	int16 minimum_width;    ///< Minimal width of the window
   207 	uint32 flags;
   224 	int16 minimum_height;   ///< Minimal height of the window
   208 	const Widget *widgets;
   225 	int16 default_width;    ///< Prefered initial width of the window
   209 	WindowProc *proc;
   226 	int16 default_height;   ///< Prefered initial height of the window
   210 };
   227 	WindowClass cls;        ///< Class of the window, @see WindowClass
   211 
   228 	WindowClass parent_cls; ///< Class of the parent window, @see WindowClass
       
   229 	uint32 flags;           ///< Flags, @see WindowDefaultFlags
       
   230 	const Widget *widgets;  ///< List of widgets with their position and size for the window
       
   231 	WindowProc *proc;       ///< Window event handler function for the window
       
   232 };
       
   233 
       
   234 /**
       
   235  * Window default widget/window handling flags
       
   236  */
   212 enum WindowDefaultFlag {
   237 enum WindowDefaultFlag {
   213 	WDF_STD_TOOLTIPS    =   1 << 0, ///< use standard routine when displaying tooltips
   238 	WDF_STD_TOOLTIPS    =   1 << 0, ///< use standard routine when displaying tooltips
   214 	WDF_DEF_WIDGET      =   1 << 1, ///< default widget control for some widgets in the on click event
   239 	WDF_DEF_WIDGET      =   1 << 1, ///< Default widget control for some widgets in the on click event, @see DispatchLeftClickEvent()
   215 	WDF_STD_BTN         =   1 << 2, ///< default handling for close and drag widgets (widget no 0 and 1)
   240 	WDF_STD_BTN         =   1 << 2, ///< Default handling for close and titlebar widgets (widget no 0 and 1)
   216 
   241 
   217 	WDF_UNCLICK_BUTTONS =   1 << 4, ///< Unclick buttons when the window event times out */
   242 	WDF_UNCLICK_BUTTONS =   1 << 4, ///< Unclick buttons when the window event times out
   218 	WDF_STICKY_BUTTON   =   1 << 5, ///< Set window to sticky mode; they are not closed unless closed with 'X' (widget 2)
   243 	WDF_STICKY_BUTTON   =   1 << 5, ///< Set window to sticky mode; they are not closed unless closed with 'X' (widget 2)
   219 	WDF_RESIZABLE       =   1 << 6, ///< A window can be resized
   244 	WDF_RESIZABLE       =   1 << 6, ///< Window can be resized
   220 	WDF_MODAL           =   1 << 7, ///< The window is a modal child of some other window, meaning the parent is 'inactive'
   245 	WDF_MODAL           =   1 << 7, ///< The window is a modal child of some other window, meaning the parent is 'inactive'
   221 };
   246 };
   222 
   247 
   223 /* can be used as x or y coordinates to cause a specific placement */
   248 /**
       
   249  * Special values for 'left' and 'top' to cause a specific placement
       
   250  */
   224 enum WindowDefaultPosition {
   251 enum WindowDefaultPosition {
   225 	WDP_AUTO      = -1, ///< Find a place automatically
   252 	WDP_AUTO      = -1, ///< Find a place automatically
   226 	WDP_CENTER    = -2, ///< Center the window (left/right or top/bottom)
   253 	WDP_CENTER    = -2, ///< Center the window (left/right or top/bottom)
   227 	WDP_ALIGN_TBR = -3, ///< Align the right side of the window with the right side of the main toolbar
   254 	WDP_ALIGN_TBR = -3, ///< Align the right side of the window with the right side of the main toolbar
   228 	WDP_ALIGN_TBL = -4, ///< Align the left side of the window with the left side of the main toolbar
   255 	WDP_ALIGN_TBL = -4, ///< Align the left side of the window with the left side of the main toolbar
   229 };
   256 };
   230 
   257 
   231 #define WP(ptr, str) (*(str*)(ptr)->custom)
   258 #define WP(ptr, str) (*(str*)(ptr)->custom)
   232 
   259 
       
   260 /**
       
   261  * Scrollbar data structure
       
   262  */
   233 struct Scrollbar {
   263 struct Scrollbar {
   234 	uint16 count, cap, pos;
   264 	uint16 count;  ///< Number of elements in the list
   235 };
   265 	uint16 cap;    ///< Number of visible elements of the scroll bar
   236 
   266 	uint16 pos;
       
   267 };
       
   268 
       
   269 /**
       
   270  * Data structure for resizing a window
       
   271  */
   237 struct ResizeInfo {
   272 struct ResizeInfo {
   238 	uint width; ///< Minimum width and height
   273 	uint width;       ///< Minimum allowed width of the window
   239 	uint height;
   274 	uint height;      ///< Minimum allowed height of the window
   240 	uint step_width; ///< In how big steps the width and height go
   275 	uint step_width;  ///< Step-size of width resize changes
   241 	uint step_height;
   276 	uint step_height; ///< Step-size of height resize changes
   242 };
   277 };
   243 
   278 
       
   279 /**
       
   280  * Message data structure for messages sent between winodows
       
   281  * @see SendWindowMessageW()
       
   282  */
   244 struct WindowMessage {
   283 struct WindowMessage {
   245 	int msg;
   284 	int msg;
   246 	int wparam;
   285 	int wparam;
   247 	int lparam;
   286 	int lparam;
   248 };
   287 };
   249 
   288 
       
   289 /**
       
   290  * Data structure for an opened window
       
   291  */
   250 struct Window {
   292 struct Window {
   251 	uint16 flags4;
   293 	uint16 flags4;              ///< Window flags, @see WindowFlags
   252 	WindowClass window_class;
   294 	WindowClass window_class;   ///< Window class
   253 	WindowNumber window_number;
   295 	WindowNumber window_number; ///< Window number within the window class
   254 
   296 
   255 	int left, top;
   297 	int left;   ///< x position of left edge of the window
   256 	int width, height;
   298 	int top;    ///< y position of top edge of the window
   257 
   299 	int width;  ///< width of the window (number of pixels to the right in x direction)
   258 	Scrollbar hscroll, vscroll, vscroll2;
   300 	int height; ///< Height of the window (number of pixels down in y direction)
   259 	ResizeInfo resize;
   301 
   260 
   302 	Scrollbar hscroll;  ///< Horizontal scroll bar
   261 	byte caption_color;
   303 	Scrollbar vscroll;  ///< First vertical scroll bar
   262 
   304 	Scrollbar vscroll2; ///< Second vertical scroll bar
   263 	WindowProc *wndproc;
   305 	ResizeInfo resize;  ///< Resize information
   264 	ViewPort *viewport;
   306 
   265 	const Widget *original_widget;
   307 	byte caption_color; ///< Background color of the window caption, contains PlayerID
   266 	Widget *widget;
   308 
   267 	uint widget_count;
   309 	WindowProc *wndproc;   ///< Event handler function for the window
   268 	uint32 desc_flags;
   310 	ViewPort *viewport;    ///< Pointer to viewport, if present (structure is part of derived class)
   269 
   311 	const Widget *original_widget; ///< Original widget layout, copied from WindowDesc
   270 	WindowMessage message;
   312 	Widget *widget;        ///< Widgets of the window
   271 	Window *parent;
   313 	uint widget_count;     ///< Number of widgets of the window
   272 	byte custom[WINDOW_CUSTOM_SIZE];
   314 	uint32 desc_flags;     ///< Window/widgets default flags setting, @see WindowDefaultFlag
       
   315 
       
   316 	WindowMessage message; ///< Buffer for storing received messages (for communication between different window events)
       
   317 	Window *parent;        ///< Parent window
       
   318 	byte custom[WINDOW_CUSTOM_SIZE]; ///< Additional data depending on window type
   273 
   319 
   274 	void HandleButtonClick(byte widget);
   320 	void HandleButtonClick(byte widget);
   275 
   321 
   276 	void SetWidgetDisabledState(byte widget_index, bool disab_stat);
   322 	void SetWidgetDisabledState(byte widget_index, bool disab_stat);
   277 	void DisableWidget(byte widget_index);
   323 	void DisableWidget(byte widget_index);
   329 	byte paramcount;
   375 	byte paramcount;
   330 	uint64 params[5];
   376 	uint64 params[5];
   331 };
   377 };
   332 assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(tooltips_d));
   378 assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(tooltips_d));
   333 
   379 
   334 struct replaceveh_d {
       
   335 	byte sel_index[2];
       
   336 	EngineID sel_engine[2];
       
   337 	uint16 count[2];
       
   338 	bool wagon_btnstate; ///< true means engine is selected
       
   339 	EngineList list[2];
       
   340 	bool update_left;
       
   341 	bool update_right;
       
   342 	bool init_lists;
       
   343 	GroupID sel_group;
       
   344 };
       
   345 assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(replaceveh_d));
       
   346 
       
   347 struct depot_d {
   380 struct depot_d {
   348 	VehicleID sel;
   381 	VehicleID sel;
   349 	VehicleType type;
   382 	VehicleType type;
   350 	bool generate_list;
   383 	bool generate_list;
   351 	uint16 engine_list_length;
   384 	uint16 engine_list_length;
   372 	int32 scroll_y;
   405 	int32 scroll_y;
   373 	int32 subscroll;
   406 	int32 subscroll;
   374 };
   407 };
   375 assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(smallmap_d));
   408 assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(smallmap_d));
   376 
   409 
   377 struct refit_d {
       
   378 	int sel;
       
   379 	struct RefitOption *cargo;
       
   380 	struct RefitList *list;
       
   381 	uint length;
       
   382 	VehicleOrderID order;
       
   383 };
       
   384 assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(refit_d));
       
   385 
       
   386 struct vp_d {
   410 struct vp_d {
   387 	VehicleID follow_vehicle;
   411 	VehicleID follow_vehicle;
   388 	int32 scrollpos_x;
   412 	int32 scrollpos_x;
   389 	int32 scrollpos_y;
   413 	int32 scrollpos_y;
   390 	int32 dest_scrollpos_x;
   414 	int32 dest_scrollpos_x;
   391 	int32 dest_scrollpos_y;
   415 	int32 dest_scrollpos_y;
   392 };
   416 };
   393 assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(vp_d));
   417 assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(vp_d));
   394 
   418 
   395 struct news_d {
       
   396 	uint16 follow_vehicle;
       
   397 	int32 scrollpos_x;
       
   398 	int32 scrollpos_y;
       
   399 	int32 dest_scrollpos_x;
       
   400 	int32 dest_scrollpos_y;
       
   401 	NewsItem *ni;
       
   402 };
       
   403 assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(news_d));
       
   404 
       
   405 struct highscore_d {
   419 struct highscore_d {
   406 	uint32 background_img;
   420 	uint32 background_img;
   407 	int8 rank;
   421 	int8 rank;
   408 };
   422 };
   409 assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(highscore_d));
   423 assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(highscore_d));
   451 	VehicleType vehicle_type;   // The vehicle type that is sorted
   465 	VehicleType vehicle_type;   // The vehicle type that is sorted
   452 	list_d l;                   // General list struct
   466 	list_d l;                   // General list struct
   453 };
   467 };
   454 assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(vehiclelist_d));
   468 assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(vehiclelist_d));
   455 
   469 
   456 struct grouplist_d {
       
   457 	const Group **sort_list;
       
   458 	list_d l;                   // General list struct
       
   459 };
       
   460 assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(grouplist_d));
       
   461 
       
   462 struct groupveh_d : vehiclelist_d {
       
   463 	GroupID group_sel;
       
   464 	VehicleID vehicle_sel;
       
   465 
       
   466 	grouplist_d gl;
       
   467 };
       
   468 assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(groupveh_d));
       
   469 
       
   470 /****************** THESE ARE NOT WIDGET TYPES!!!!! *******************/
   470 /****************** THESE ARE NOT WIDGET TYPES!!!!! *******************/
   471 enum WindowWidgetBehaviours {
   471 enum WindowWidgetBehaviours {
   472 	WWB_PUSHBUTTON  = 1 << 5,
   472 	WWB_PUSHBUTTON  = 1 << 5,
   473 
   473 
   474 	WWB_MASK        = 0xE0,
   474 	WWB_MASK        = 0xE0,
   475 };
   475 };
   476 
   476 
   477 
   477 
       
   478 /**
       
   479  * Window widget types
       
   480  */
   478 enum WindowWidgetTypes {
   481 enum WindowWidgetTypes {
   479 	WWT_EMPTY,
   482 	WWT_EMPTY,      ///< Empty widget, place holder to reserve space in widget array
   480 
   483 
   481 	WWT_PANEL,      ///< simple depressed panel
   484 	WWT_PANEL,      ///< Simple depressed panel
   482 	WWT_INSET,      ///< pressed (inset) panel, most commonly used as combo box _text_ area
   485 	WWT_INSET,      ///< Pressed (inset) panel, most commonly used as combo box _text_ area
   483 	WWT_IMGBTN,     ///< button with image
   486 	WWT_IMGBTN,     ///< Button with image
   484 	WWT_IMGBTN_2,   ///< button with diff image when clicked
   487 	WWT_IMGBTN_2,   ///< Button with diff image when clicked
   485 
   488 
   486 	WWT_TEXTBTN,    ///< button with text
   489 	WWT_TEXTBTN,    ///< Button with text
   487 	WWT_TEXTBTN_2,  ///< button with diff text when clicked
   490 	WWT_TEXTBTN_2,  ///< Button with diff text when clicked
   488 	WWT_LABEL,      ///< centered label
   491 	WWT_LABEL,      ///< Centered label
   489 	WWT_TEXT,       ///< pure simple text
   492 	WWT_TEXT,       ///< Pure simple text
   490 	WWT_MATRIX,
   493 	WWT_MATRIX,     ///< List of items underneath each other
   491 	WWT_SCROLLBAR,
   494 	WWT_SCROLLBAR,  ///< Vertical scrollbar
   492 	WWT_FRAME,      ///< frame
   495 	WWT_FRAME,      ///< Frame
   493 	WWT_CAPTION,
   496 	WWT_CAPTION,    ///< Window caption (window title between closebox and stickybox)
   494 
   497 
   495 	WWT_HSCROLLBAR,
   498 	WWT_HSCROLLBAR, ///< Horizontal scrollbar
   496 	WWT_STICKYBOX,
   499 	WWT_STICKYBOX,  ///< Sticky box (normally at top-right of a window)
   497 	WWT_SCROLL2BAR, ///< 2nd vertical scrollbar
   500 	WWT_SCROLL2BAR, ///< 2nd vertical scrollbar
   498 	WWT_RESIZEBOX,
   501 	WWT_RESIZEBOX,  ///< Resize box (normally at bottom-right of a window)
   499 	WWT_CLOSEBOX,
   502 	WWT_CLOSEBOX,   ///< Close box (at top-left of a window)
   500 	WWT_DROPDOWN,   ///< Raised drop down list (regular)
   503 	WWT_DROPDOWN,   ///< Raised drop down list (regular)
   501 	WWT_DROPDOWNIN, ///< Inset drop down list (used on game options only)
   504 	WWT_DROPDOWNIN, ///< Inset drop down list (used on game options only)
       
   505 	WWT_EDITBOX,    ///< a textbox for typing (don't forget to call ShowOnScreenKeyboard() when clicked)
   502 	WWT_LAST,       ///< Last Item. use WIDGETS_END to fill up padding!!
   506 	WWT_LAST,       ///< Last Item. use WIDGETS_END to fill up padding!!
   503 
   507 
   504 	WWT_MASK = 0x1F,
   508 	WWT_MASK = 0x1F,
   505 
   509 
   506 	WWT_PUSHBTN     = WWT_PANEL   | WWB_PUSHBUTTON,
   510 	WWT_PUSHBTN     = WWT_PANEL   | WWB_PUSHBUTTON,
   508 	WWT_PUSHIMGBTN  = WWT_IMGBTN  | WWB_PUSHBUTTON,
   512 	WWT_PUSHIMGBTN  = WWT_IMGBTN  | WWB_PUSHBUTTON,
   509 };
   513 };
   510 
   514 
   511 #define WIDGETS_END WWT_LAST,   RESIZE_NONE,     0,     0,     0,     0,     0, 0, STR_NULL
   515 #define WIDGETS_END WWT_LAST,   RESIZE_NONE,     0,     0,     0,     0,     0, 0, STR_NULL
   512 
   516 
       
   517 /**
       
   518  * Window flags
       
   519  */
   513 enum WindowFlags {
   520 enum WindowFlags {
   514 	WF_TIMEOUT_SHL       = 0,
   521 	WF_TIMEOUT_SHL       = 0,       ///< Window timeout counter shift
   515 	WF_TIMEOUT_MASK      = 7,
   522 	WF_TIMEOUT_MASK      = 7,       ///< Window timeout counter bit mask (3 bits), @see WF_TIMEOUT_SHL
   516 	WF_DRAGGING          = 1 <<  3,
   523 	WF_DRAGGING          = 1 <<  3, ///< Window is being dragged
   517 	WF_SCROLL_UP         = 1 <<  4,
   524 	WF_SCROLL_UP         = 1 <<  4, ///< Upper scroll button has been pressed, @see ScrollbarClickHandler()
   518 	WF_SCROLL_DOWN       = 1 <<  5,
   525 	WF_SCROLL_DOWN       = 1 <<  5, ///< Lower scroll button has been pressed, @see ScrollbarClickHandler()
   519 	WF_SCROLL_MIDDLE     = 1 <<  6,
   526 	WF_SCROLL_MIDDLE     = 1 <<  6, ///< Scrollbar scrolling, @see ScrollbarClickHandler()
   520 	WF_HSCROLL           = 1 <<  7,
   527 	WF_HSCROLL           = 1 <<  7,
   521 	WF_SIZING            = 1 <<  8,
   528 	WF_SIZING            = 1 <<  8,
   522 	WF_STICKY            = 1 <<  9,
   529 	WF_STICKY            = 1 <<  9, ///< Window is made sticky by user
   523 
   530 
   524 	WF_DISABLE_VP_SCROLL = 1 << 10,
   531 	WF_DISABLE_VP_SCROLL = 1 << 10, ///< Window does not do autoscroll, @see HandleAutoscroll()
   525 
   532 
   526 	WF_WHITE_BORDER_ONE  = 1 << 11,
   533 	WF_WHITE_BORDER_ONE  = 1 << 11,
   527 	WF_WHITE_BORDER_MASK = 1 << 12 | WF_WHITE_BORDER_ONE,
   534 	WF_WHITE_BORDER_MASK = 1 << 12 | WF_WHITE_BORDER_ONE,
   528 	WF_SCROLL2           = 1 << 13,
   535 	WF_SCROLL2           = 1 << 13,
   529 };
   536 };
   530 
   537 
   531 /* window.cpp */
   538 /* window.cpp */
   532 void CallWindowEventNP(Window *w, int event);
   539 void CallWindowEventNP(Window *w, int event);
   533 void CallWindowTickEvent();
   540 void CallWindowTickEvent();
   534 
   541 
   535 /**
       
   536  * Marks the window as dirty for repaint.
       
   537  *
       
   538  * @ingroup dirty
       
   539  */
       
   540 void SetWindowDirty(const Window *w);
   542 void SetWindowDirty(const Window *w);
   541 void SendWindowMessage(WindowClass wnd_class, WindowNumber wnd_num, int msg, int wparam, int lparam);
   543 void SendWindowMessage(WindowClass wnd_class, WindowNumber wnd_num, int msg, int wparam, int lparam);
   542 void SendWindowMessageClass(WindowClass wnd_class, int msg, int wparam, int lparam);
   544 void SendWindowMessageClass(WindowClass wnd_class, int msg, int wparam, int lparam);
   543 
   545 
   544 Window *FindWindowById(WindowClass cls, WindowNumber number);
   546 Window *FindWindowById(WindowClass cls, WindowNumber number);
   625 	WSM_PRESIZE  = 3,
   627 	WSM_PRESIZE  = 3,
   626 };
   628 };
   627 
   629 
   628 void ScrollbarClickHandler(Window *w, const Widget *wi, int x, int y);
   630 void ScrollbarClickHandler(Window *w, const Widget *wi, int x, int y);
   629 
   631 
   630 /** Evenly distribute some widgets when resizing horizontally (often a button row)
       
   631  *  The widgets are presumed to be in a line and numberef from left to right (without gaps)
       
   632  * @param w widow to modify
       
   633  * @param left The leftmost widget to resize
       
   634  * @param right The rightmost widget to resize. Since right side of it is used, remember to set it to RESIZE_RIGHT
       
   635  */
       
   636 void ResizeButtons(Window *w, byte left, byte right);
   632 void ResizeButtons(Window *w, byte left, byte right);
   637 
   633 
   638 /** Resize a widget an shuffle other widgets around to fit.
       
   639  */
       
   640 void ResizeWindowForWidget(Window *w, int widget, int delta_x, int delta_y);
   634 void ResizeWindowForWidget(Window *w, int widget, int delta_x, int delta_y);
   641 
   635 
   642 
   636 
   643 /**
   637 /**
   644  * Sets the enabled/disabled status of a widget.
   638  * Sets the enabled/disabled status of a widget.