2005-07-24 14:12:37 +00:00
/* $Id$ */
2009-08-21 20:21:05 +00:00
/*
* This file is part of OpenTTD .
* OpenTTD is free software ; you can redistribute it and / or modify it under the terms of the GNU General Public License as published by the Free Software Foundation , version 2.
* OpenTTD is distributed in the hope that it will be useful , but WITHOUT ANY WARRANTY ; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE .
* See the GNU General Public License for more details . You should have received a copy of the GNU General Public License along with OpenTTD . If not , see < http : //www.gnu.org/licenses/>.
*/
2007-12-19 19:44:29 +00:00
/** @file window_gui.h Functions, definitions and such used only by the GUI. */
2007-02-23 01:48:53 +00:00
2007-12-19 19:44:29 +00:00
# ifndef WINDOW_GUI_H
# define WINDOW_GUI_H
2004-08-09 17:04:08 +00:00
2009-06-28 15:16:57 +00:00
# include "core/geometry_func.hpp"
2009-09-02 06:34:40 +00:00
# include "core/math_func.hpp"
2007-12-26 11:45:43 +00:00
# include "vehicle_type.h"
2008-01-09 09:45:45 +00:00
# include "viewport_type.h"
2008-09-30 20:51:04 +00:00
# include "company_type.h"
2008-04-13 19:25:14 +00:00
# include "core/alloc_type.hpp"
2008-05-07 13:10:15 +00:00
# include "window_type.h"
# include "tile_type.h"
2009-02-09 01:06:23 +00:00
# include "widget_type.h"
2004-08-09 17:04:08 +00:00
2008-04-07 20:28:58 +00:00
/**
* Flags to describe the look of the frame
*/
2007-03-07 12:11:48 +00:00
enum FrameFlags {
2007-12-04 17:51:50 +00:00
FR_NONE = 0 ,
FR_TRANSPARENT = 1 < < 0 , ///< Makes the background transparent if set
FR_BORDERONLY = 1 < < 4 , ///< Draw border only, no background
2009-02-09 02:57:15 +00:00
FR_LOWERED = 1 < < 5 , ///< If set the frame is lowered and the background colour brighter (ie. buttons when pressed)
FR_DARKENED = 1 < < 6 , ///< If set the background is darker, allows for lowered frames with normal background colour when used with FR_LOWERED (ie. dropdown boxes)
2007-03-07 12:11:48 +00:00
} ;
2006-08-29 06:07:57 +00:00
2007-01-10 18:56:51 +00:00
DECLARE_ENUM_AS_BIT_SET ( FrameFlags ) ;
2009-06-28 22:23:26 +00:00
/** Distances used in drawing widgets. */
enum WidgetDrawDistances {
2009-07-12 12:19:41 +00:00
/* WWT_IMGBTN */
WD_IMGBTN_LEFT = 1 , ///< Left offset of the image in the button.
WD_IMGBTN_RIGHT = 2 , ///< Right offset of the image in the button.
WD_IMGBTN_TOP = 1 , ///< Top offset of image in the button.
WD_IMGBTN_BOTTOM = 2 , ///< Bottom offset of image in the button.
/* WWT_IMGBTN_2 */
WD_IMGBTN2_LEFT = 1 , ///< Left offset of the images in the button.
WD_IMGBTN2_RIGHT = 3 , ///< Right offset of the images in the button.
WD_IMGBTN2_TOP = 1 , ///< Top offset of images in the button.
WD_IMGBTN2_BOTTOM = 3 , ///< Bottom offset of images in the button.
2009-06-28 22:23:26 +00:00
/* WWT_INSET */
WD_INSET_LEFT = 2 , ///< Left offset of string.
WD_INSET_RIGHT = 2 , ///< Right offset of string.
WD_INSET_TOP = 1 , ///< Top offset of string.
2009-07-12 12:19:41 +00:00
WD_VSCROLLBAR_WIDTH = 12 , ///< Width of a vertical scrollbar.
2009-06-28 22:23:26 +00:00
WD_HSCROLLBAR_HEIGHT = 12 , ///< Height of a horizontal scrollbar.
/* FrameRect widgets, all text buttons, panel, editbox */
2009-07-12 12:19:41 +00:00
WD_FRAMERECT_LEFT = 2 , ///< Offset at left to draw the frame rectangular area
WD_FRAMERECT_RIGHT = 2 , ///< Offset at right to draw the frame rectangular area
WD_FRAMERECT_TOP = 1 , ///< Offset at top to draw the frame rectangular area
2009-06-28 22:23:26 +00:00
WD_FRAMERECT_BOTTOM = 1 , ///< Offset at bottom to draw the frame rectangular area
2009-08-30 17:07:53 +00:00
/* Extra space at top/bottom of text panels */
WD_TEXTPANEL_TOP = 6 , ///< Offset at top to draw above the text
WD_TEXTPANEL_BOTTOM = 6 , ///< Offset at bottom to draw below the text
2009-06-28 22:23:26 +00:00
/* WWT_FRAME */
2009-07-12 12:19:41 +00:00
WD_FRAMETEXT_LEFT = 6 , ///< Left offset of the text of the frame.
2009-06-28 22:23:26 +00:00
WD_FRAMETEXT_RIGHT = 6 , ///< Right offset of the text of the frame.
2009-07-31 22:08:19 +00:00
/* WWT_MATRIX */
WD_MATRIX_LEFT = 2 , ///< Offset at left of a matrix cell.
WD_MATRIX_RIGHT = 2 , ///< Offset at right of a matrix cell.
WD_MATRIX_TOP = 3 , ///< Offset at top of a matrix cell.
WD_MATRIX_BOTTOM = 1 , ///< Offset at bottom of a matrix cell.
2009-06-28 22:23:26 +00:00
/* WWT_STICKYBOX */
2009-07-12 12:19:41 +00:00
WD_STICKYBOX_WIDTH = 12 , ///< Width of a standard sticky box widget.
WD_STICKYBOX_LEFT = 2 , ///< Left offset of sticky sprite.
WD_STICKYBOX_RIGHT = 2 , ///< Right offset of sticky sprite.
WD_STICKYBOX_TOP = 3 , ///< Top offset of sticky sprite.
2009-07-14 21:25:32 +00:00
WD_STICKYBOX_BOTTOM = 3 , ///< Bottom offset of sticky sprite.
2009-06-28 22:23:26 +00:00
/* WWT_RESIZEBOX */
2009-07-12 12:19:41 +00:00
WD_RESIZEBOX_WIDTH = 12 , ///< Width of a resize box widget.
WD_RESIZEBOX_LEFT = 3 , ///< Left offset of resize sprite.
WD_RESIZEBOX_RIGHT = 2 , ///< Right offset of resize sprite.
WD_RESIZEBOX_TOP = 3 , ///< Top offset of resize sprite.
2009-07-14 21:25:32 +00:00
WD_RESIZEBOX_BOTTOM = 2 , ///< Bottom offset of resize sprite.
2009-06-28 22:23:26 +00:00
/* WWT_CLOSEBOX */
2009-07-12 12:19:41 +00:00
WD_CLOSEBOX_WIDTH = 11 , ///< Width of a close box widget.
WD_CLOSEBOX_LEFT = 2 , ///< Left offset of closebox string.
WD_CLOSEBOX_RIGHT = 1 , ///< Right offset of closebox string.
WD_CLOSEBOX_TOP = 2 , ///< Top offset of closebox string.
WD_CLOSEBOX_BOTTOM = 2 , ///< Bottom offset of closebox string.
2009-06-28 22:23:26 +00:00
/* WWT_CAPTION */
2009-07-12 12:19:41 +00:00
WD_CAPTION_HEIGHT = 14 , ///< Height of a title bar.
WD_CAPTIONTEXT_LEFT = 2 , ///< Offset of the caption text at the left.
WD_CAPTIONTEXT_RIGHT = 2 , ///< Offset of the caption text at the right.
WD_CAPTIONTEXT_TOP = 2 , ///< Offset of the caption text at the top.
WD_CAPTIONTEXT_BOTTOM = 2 , ///< Offset of the caption text at the bottom.
2009-06-28 22:23:26 +00:00
/* Dropdown widget. */
2009-07-12 12:19:41 +00:00
WD_DROPDOWN_HEIGHT = 12 , ///< Height of a drop down widget.
WD_DROPDOWNTEXT_LEFT = 2 , ///< Left offset of the dropdown widget string.
WD_DROPDOWNTEXT_RIGHT = 14 , ///< Right offset of the dropdown widget string.
WD_DROPDOWNTEXT_TOP = 1 , ///< Top offset of the dropdown widget string.
WD_DROPDOWNTEXT_BOTTOM = 1 , ///< Bottom offset of the dropdown widget string.
2009-07-02 21:18:22 +00:00
WD_SORTBUTTON_ARROW_WIDTH = 11 , ///< Width of up/down arrow of sort button state.
2009-07-10 20:48:08 +00:00
2009-07-12 12:19:41 +00:00
WD_PAR_VSEP_NORMAL = 2 , ///< Amount of vertical space between two paragraphs of text.
2009-06-28 22:23:26 +00:00
} ;
2008-04-07 20:28:58 +00:00
/* wiget.cpp */
2009-02-09 02:57:15 +00:00
void DrawFrameRect ( int left , int top , int right , int bottom , Colours colour , FrameFlags flags ) ;
2005-06-15 17:27:14 +00:00
2009-02-17 12:41:29 +00:00
/* window.cpp */
extern Window * _z_front_window ;
extern Window * _z_back_window ;
extern Window * _focused_window ;
2008-04-07 20:28:58 +00:00
/**
* High level window description
*/
2009-03-15 15:12:06 +00:00
struct WindowDesc : ZeroedMemoryAllocator {
WindowDesc ( int16 left , int16 top , int16 min_width , int16 min_height , int16 def_width , int16 def_height ,
2009-03-22 21:15:45 +00:00
WindowClass window_class , WindowClass parent_class , uint32 flags , const Widget * widgets ,
const NWidgetPart * nwid_parts = NULL , int16 nwid_length = 0 ) ;
2009-03-15 15:12:06 +00:00
2009-03-22 21:15:45 +00:00
~ WindowDesc ( ) ;
int16 left ; ///< Prefered x position of left edge of the window. @see WindowDefaultPosition()
int16 top ; ///< Prefered y position of the top of the window. @see WindowDefaultPosition()
int16 minimum_width ; ///< Minimal width of the window.
int16 minimum_height ; ///< Minimal height of the window.
int16 default_width ; ///< Prefered initial width of the window.
int16 default_height ; ///< Prefered initial height of the window.
WindowClass cls ; ///< Class of the window, @see WindowClass.
WindowClass parent_cls ; ///< Class of the parent window. @see WindowClass
uint32 flags ; ///< Flags. @see WindowDefaultFlags
const Widget * widgets ; ///< List of widgets with their position and size for the window.
const NWidgetPart * nwid_parts ; ///< Nested widget parts describing the window.
int16 nwid_length ; ///< Length of the #nwid_parts array.
mutable Widget * new_widgets ; ///< Widgets generated from #nwid_parts.
const Widget * GetWidgets ( ) const ;
2007-03-07 12:11:48 +00:00
} ;
2004-08-09 17:04:08 +00:00
2008-04-07 20:28:58 +00:00
/**
* Window default widget / window handling flags
*/
2006-12-29 13:59:48 +00:00
enum WindowDefaultFlag {
2007-12-04 17:51:50 +00:00
WDF_STD_TOOLTIPS = 1 < < 0 , ///< use standard routine when displaying tooltips
2008-04-07 20:28:58 +00:00
WDF_DEF_WIDGET = 1 < < 1 , ///< Default widget control for some widgets in the on click event, @see DispatchLeftClickEvent()
2009-03-28 02:46:10 +00:00
WDF_STD_BTN = 1 < < 2 , ///< Default handling for close and titlebar widgets (the widgets with type WWT_CLOSEBOX and WWT_CAPTION).
2009-02-04 16:59:41 +00:00
WDF_CONSTRUCTION = 1 < < 3 , ///< This window is used for construction; close it whenever changing company.
2007-12-06 15:58:39 +00:00
2008-04-07 20:28:58 +00:00
WDF_UNCLICK_BUTTONS = 1 < < 4 , ///< Unclick buttons when the window event times out
2009-03-28 02:46:10 +00:00
WDF_STICKY_BUTTON = 1 < < 5 , ///< Set window to sticky mode; they are not closed unless closed with 'X' (widget with type WWT_STICKYBOX).
2008-04-07 20:28:58 +00:00
WDF_RESIZABLE = 1 < < 6 , ///< Window can be resized
2007-12-04 17:51:50 +00:00
WDF_MODAL = 1 < < 7 , ///< The window is a modal child of some other window, meaning the parent is 'inactive'
2009-02-09 01:22:29 +00:00
WDF_NO_FOCUS = 1 < < 8 , ///< This window won't get focus/make any other window lose focus when click
2004-08-09 17:04:08 +00:00
} ;
2008-04-07 20:28:58 +00:00
/**
* Special values for ' left ' and ' top ' to cause a specific placement
*/
2006-12-29 13:59:48 +00:00
enum WindowDefaultPosition {
2006-11-11 10:12:00 +00:00
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
2004-08-09 17:04:08 +00:00
} ;
2008-04-07 20:28:58 +00:00
/**
* Scrollbar data structure
*/
2009-09-02 06:34:40 +00:00
class Scrollbar {
2009-09-02 08:58:20 +00:00
private :
2008-04-07 20:28:58 +00:00
uint16 count ; ///< Number of elements in the list
uint16 cap ; ///< Number of visible elements of the scroll bar
2008-08-01 09:34:34 +00:00
uint16 pos ; ///< Index of first visible item of the list
2009-09-02 06:34:40 +00:00
public :
/**
* Gets the number of elements in the list
* @ return the number of elements
*/
FORCEINLINE uint16 GetCount ( ) const
{
return this - > count ;
}
/**
* Gets the number of visible elements of the scrollbar
* @ return the number of visible elements
*/
FORCEINLINE uint16 GetCapacity ( ) const
{
return this - > cap ;
}
/**
* Gets the position of the first visible element in the list
* @ return the position of the element
*/
FORCEINLINE uint16 GetPosition ( ) const
{
return this - > pos ;
}
2009-09-02 07:01:25 +00:00
/**
* Checks whether given current item is visible in the list
* @ param item to check
* @ return true iff the item is visible
*/
FORCEINLINE bool IsVisible ( uint16 item ) const
{
return IsInsideBS ( item , this - > GetPosition ( ) , this - > GetCapacity ( ) ) ;
}
2009-09-02 06:34:40 +00:00
/**
* Sets the number of elements in the list
* @ param num the number of elements in the list
* @ note updates the position if needed
*/
void SetCount ( int num )
{
assert ( num > = 0 ) ;
assert ( num < = MAX_UVALUE ( uint16 ) ) ;
this - > count = num ;
num - = this - > cap ;
if ( num < 0 ) num = 0 ;
if ( num < this - > pos ) this - > pos = num ;
}
/**
* Set the capacity of visible elements .
* @ param capacity the new capacity
* @ note updates the position if needed
*/
void SetCapacity ( int capacity )
{
assert ( capacity > 0 ) ;
assert ( capacity < = MAX_UVALUE ( uint16 ) ) ;
this - > cap = capacity ;
if ( this - > cap + this - > pos > this - > count ) this - > pos = max ( 0 , this - > count - this - > cap ) ;
}
/**
* Updates the capacity by adding / removing a number of ( visible ) elements .
* @ param difference the difference in capacity
* @ note updates the position if needed
*/
void UpdateCapacity ( int difference )
{
2009-09-02 07:17:15 +00:00
if ( difference = = 0 ) return ;
2009-09-02 06:34:40 +00:00
this - > SetCapacity ( this - > cap + difference ) ;
}
/**
* Sets the position of the first visible element
* @ param position the position of the element
*/
void SetPosition ( int position )
{
assert ( position > = 0 ) ;
2009-09-02 07:01:25 +00:00
assert ( this - > count < = this - > cap ? ( position = = 0 ) : ( position + this - > cap < = this - > count ) ) ;
2009-09-02 06:34:40 +00:00
this - > pos = position ;
}
/**
* Updates the position of the first visible element by the given amount .
* If the position would be too low or high it will be clamped appropriately
* @ param difference the amount of change requested
*/
void UpdatePosition ( int difference )
{
2009-09-02 07:17:15 +00:00
if ( difference = = 0 ) return ;
2009-09-03 09:07:14 +00:00
this - > SetPosition ( Clamp ( this - > pos + difference , 0 , max ( this - > count - this - > cap , 0 ) ) ) ;
2009-09-02 06:34:40 +00:00
}
2009-09-02 08:08:30 +00:00
/**
* Scroll towards the given position ; if the item is visible nothing
* happens , otherwise it will be shown either at the bottom or top of
* the window depending on where in the list it was .
* @ param position the position to scroll towards .
*/
void ScrollTowards ( int position )
{
if ( position < this - > GetPosition ( ) ) {
/* scroll up to the item */
this - > SetPosition ( position ) ;
} else if ( position > = this - > GetPosition ( ) + this - > GetCapacity ( ) ) {
/* scroll down so that the item is at the bottom */
this - > SetPosition ( position - this - > GetCapacity ( ) + 1 ) ;
}
}
2007-03-07 12:11:48 +00:00
} ;
2004-08-09 17:04:08 +00:00
2008-04-07 20:28:58 +00:00
/**
* Data structure for resizing a window
*/
2007-03-07 12:11:48 +00:00
struct ResizeInfo {
2008-04-07 20:28:58 +00:00
uint width ; ///< Minimum allowed width of the window
uint height ; ///< Minimum allowed height of the window
uint step_width ; ///< Step-size of width resize changes
uint step_height ; ///< Step-size of height resize changes
2007-03-07 12:11:48 +00:00
} ;
2005-01-03 19:45:18 +00:00
2009-08-14 18:41:03 +00:00
/** State of a sort direction button. */
2008-05-17 12:48:06 +00:00
enum SortButtonState {
2009-08-14 18:41:03 +00:00
SBS_OFF , ///< Do not sort (with this button).
SBS_DOWN , ///< Sort ascending.
SBS_UP , ///< Sort descending.
2008-05-17 12:48:06 +00:00
} ;
2008-04-07 20:28:58 +00:00
/**
2009-07-26 12:49:26 +00:00
* Data structure for a window viewport .
* A viewport is either following a vehicle ( its id in then in # follow_vehicle ) , or it aims to display a specific
* location # dest_scrollpos_x , # dest_scrollpos_y ( # follow_vehicle is then # INVALID_VEHICLE ) .
* The actual location being shown is # scrollpos_x , # scrollpos_y .
2009-07-26 17:29:01 +00:00
* @ see InitializeViewport ( ) , UpdateViewportPosition ( ) , UpdateViewportCoordinates ( ) .
2008-05-11 15:08:44 +00:00
*/
struct ViewportData : ViewPort {
2009-07-26 12:49:26 +00:00
VehicleID follow_vehicle ; ///< VehicleID to follow if following a vehicle, #INVALID_VEHICLE otherwise.
int32 scrollpos_x ; ///< Currently shown x coordinate (virtual screen coordinate of topleft corner of the viewport).
int32 scrollpos_y ; ///< Currently shown y coordinate (virtual screen coordinate of topleft corner of the viewport).
int32 dest_scrollpos_x ; ///< Current destination x coordinate to display (virtual screen coordinate of topleft corner of the viewport).
int32 dest_scrollpos_y ; ///< Current destination y coordinate to display (virtual screen coordinate of topleft corner of the viewport).
2008-05-11 15:08:44 +00:00
} ;
2008-05-17 03:29:16 +00:00
/**
2008-04-07 20:28:58 +00:00
* Data structure for an opened window
*/
2008-04-13 19:25:14 +00:00
struct Window : ZeroedMemoryAllocator {
2008-10-14 19:27:08 +00:00
/** State whether an event is handled or not */
2008-05-17 23:11:06 +00:00
enum EventState {
2008-10-14 19:27:08 +00:00
ES_HANDLED , ///< The passed event is handled
ES_NOT_HANDLED , ///< The passed event is not handled
2008-05-17 23:11:06 +00:00
} ;
2008-05-08 11:31:41 +00:00
protected :
2009-08-01 15:49:18 +00:00
void InitializeData ( WindowClass cls , const Widget * widget , int window_number ) ;
2009-07-09 19:52:47 +00:00
void InitializePositionSize ( int x , int y , int min_width , int min_height ) ;
2008-05-11 11:41:18 +00:00
void FindWindowPlacementAndResize ( int def_width , int def_height ) ;
void FindWindowPlacementAndResize ( const WindowDesc * desc ) ;
2008-05-08 11:31:41 +00:00
2008-05-04 10:05:50 +00:00
public :
2008-05-18 20:40:30 +00:00
Window ( int x , int y , int width , int height , WindowClass cls , const Widget * widget ) ;
2008-05-13 14:43:33 +00:00
Window ( const WindowDesc * desc , WindowNumber number = 0 ) ;
2009-06-04 14:34:38 +00:00
Window ( ) ;
2008-05-08 11:31:41 +00:00
2008-05-06 21:28:30 +00:00
virtual ~ Window ( ) ;
2009-01-07 18:59:46 +00:00
/* Don't allow arrays; arrays of Windows are pointless as you need
* to destruct them all at the same time too , which is kinda hard . */
FORCEINLINE void * operator new [ ] ( size_t size ) { NOT_REACHED ( ) ; }
/* Don't free the window directly; it corrupts the linked list when iterating */
FORCEINLINE void operator delete ( void * ptr , size_t size ) { }
2008-05-04 10:05:50 +00:00
2008-04-07 20:28:58 +00:00
uint16 flags4 ; ///< Window flags, @see WindowFlags
WindowClass window_class ; ///< Window class
WindowNumber window_number ; ///< Window number within the window class
2004-08-09 17:04:08 +00:00
2008-04-07 20:28:58 +00:00
int left ; ///< x position of left edge of the window
int top ; ///< y position of top edge of the window
int width ; ///< width of the window (number of pixels to the right in x direction)
int height ; ///< Height of the window (number of pixels down in y direction)
2004-08-09 17:04:08 +00:00
2008-04-07 20:28:58 +00:00
Scrollbar hscroll ; ///< Horizontal scroll bar
Scrollbar vscroll ; ///< First vertical scroll bar
Scrollbar vscroll2 ; ///< Second vertical scroll bar
ResizeInfo resize ; ///< Resize information
2004-08-09 17:04:08 +00:00
2009-02-09 02:33:10 +00:00
Owner owner ; ///< The owner of the content shown in this window. Company colour is acquired from this variable.
2004-08-09 17:04:08 +00:00
2009-06-04 14:07:05 +00:00
ViewportData * viewport ; ///< Pointer to viewport data, if present.
Widget * widget ; ///< Widgets of the window.
uint widget_count ; ///< Number of widgets of the window.
uint32 desc_flags ; ///< Window/widgets default flags setting. @see WindowDefaultFlag
const Widget * focused_widget ; ///< Currently focused widget, or \c NULL if no widget has focus.
const NWidgetCore * nested_focus ; ///< Currently focused nested widget, or \c NULL if no nested widget has focus.
NWidgetBase * nested_root ; ///< Root of the nested tree.
2009-09-19 11:31:12 +00:00
NWidgetBase * * nested_array ; ///< Array of pointers into the tree. Do not access directly, use #Window::GetWidget() instead.
2009-06-04 14:07:05 +00:00
uint nested_array_size ; ///< Size of the nested array.
2004-08-09 17:04:08 +00:00
2009-06-04 14:07:05 +00:00
Window * parent ; ///< Parent window.
Window * z_front ; ///< The window in front of us in z-order.
Window * z_back ; ///< The window behind us in z-order.
2007-12-02 00:59:48 +00:00
2009-09-19 14:41:43 +00:00
template < class NWID >
2009-09-19 11:31:12 +00:00
inline NWID * GetWidget ( uint widnum ) const ;
2009-06-04 14:34:38 +00:00
void InitNested ( const WindowDesc * desc , WindowNumber number = 0 ) ;
2009-08-01 15:49:18 +00:00
void CreateNestedTree ( const WindowDesc * desc , bool fill_nested = true ) ;
void FinishInitNested ( const WindowDesc * desc , WindowNumber window_number ) ;
2009-06-04 14:34:38 +00:00
2009-02-17 12:41:29 +00:00
/**
* 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 SetWidgetDisabledState ( byte widget_index , bool disab_stat )
{
2009-06-03 21:13:13 +00:00
if ( this - > widget ! = NULL ) {
assert ( widget_index < this - > widget_count ) ;
SB ( this - > widget [ widget_index ] . display_flags , WIDG_DISABLED , 1 , ! ! disab_stat ) ;
}
if ( this - > nested_array ! = NULL ) {
assert ( widget_index < this - > nested_array_size ) ;
2009-09-19 11:31:12 +00:00
if ( this - > nested_array [ widget_index ] ! = NULL ) this - > GetWidget < NWidgetCore > ( widget_index ) - > SetDisabled ( disab_stat ) ;
2009-06-03 21:13:13 +00:00
}
2009-02-17 12:41:29 +00:00
}
/**
* Sets a widget to disabled .
* @ param widget_index index of this widget in the window
*/
inline void 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 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 IsWidgetDisabled ( byte widget_index ) const
{
2009-06-03 21:13:13 +00:00
if ( this - > nested_array ! = NULL ) {
assert ( widget_index < this - > nested_array_size ) ;
2009-09-19 11:31:12 +00:00
return this - > GetWidget < NWidgetCore > ( widget_index ) - > IsDisabled ( ) ;
2009-06-03 21:13:13 +00:00
}
2009-02-17 12:41:29 +00:00
assert ( widget_index < this - > widget_count ) ;
return HasBit ( this - > widget [ widget_index ] . display_flags , WIDG_DISABLED ) ;
}
2007-12-08 02:55:47 +00:00
2009-02-17 12:41:29 +00:00
/**
* 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 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 HideWidget ( byte widget_index )
{
SetWidgetHiddenState ( widget_index , true ) ;
}
/**
* Sets a widget visible .
* @ param widget_index index of this widget in the window
*/
inline void 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 IsWidgetHidden ( byte widget_index ) const
{
assert ( widget_index < this - > widget_count ) ;
return HasBit ( this - > widget [ widget_index ] . display_flags , WIDG_HIDDEN ) ;
}
/**
* Check if given widget is focused within this window
* @ param widget_index : index of the widget in the window to check
* @ return true if given widget is the focused window in this window
*/
inline bool IsWidgetFocused ( byte widget_index ) const
{
2009-06-04 14:07:05 +00:00
return ( this - > widget ! = NULL & & this - > focused_widget = = & this - > widget [ widget_index ] ) | |
( this - > nested_focus ! = NULL & & this - > nested_focus - > index = = widget_index ) ;
2009-02-17 12:41:29 +00:00
}
/**
* Check if given widget has user input focus . This means that both the window
* has focus and that the given widget has focus within the window .
* @ param widget_index : index of the widget in the window to check
* @ return true if given widget is the focused window in this window and this window has focus
*/
inline bool IsWidgetGloballyFocused ( byte widget_index ) const
{
return _focused_window = = this & & IsWidgetFocused ( widget_index ) ;
}
/**
* 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 SetWidgetLoweredState ( byte widget_index , bool lowered_stat )
{
2009-06-03 21:13:13 +00:00
if ( this - > widget ! = NULL ) {
assert ( widget_index < this - > widget_count ) ;
SB ( this - > widget [ widget_index ] . display_flags , WIDG_LOWERED , 1 , ! ! lowered_stat ) ;
}
if ( this - > nested_array ! = NULL ) {
assert ( widget_index < this - > nested_array_size ) ;
2009-09-19 11:31:12 +00:00
this - > GetWidget < NWidgetCore > ( widget_index ) - > SetLowered ( lowered_stat ) ;
2009-06-03 21:13:13 +00:00
}
2009-02-17 12:41:29 +00:00
}
/**
* Invert the lowered / raised status of a widget .
* @ param widget_index index of this widget in the window
*/
inline void ToggleWidgetLoweredState ( byte widget_index )
{
2009-06-03 21:13:13 +00:00
if ( this - > widget ! = NULL ) {
assert ( widget_index < this - > widget_count ) ;
ToggleBit ( this - > widget [ widget_index ] . display_flags , WIDG_LOWERED ) ;
}
if ( this - > nested_array ! = NULL ) {
assert ( widget_index < this - > nested_array_size ) ;
2009-09-19 11:31:12 +00:00
bool lowered_state = this - > GetWidget < NWidgetCore > ( widget_index ) - > IsLowered ( ) ;
this - > GetWidget < NWidgetCore > ( widget_index ) - > SetLowered ( ! lowered_state ) ;
2009-06-03 21:13:13 +00:00
}
2009-02-17 12:41:29 +00:00
}
/**
* Marks a widget as lowered .
* @ param widget_index index of this widget in the window
*/
inline void 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 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 IsWidgetLowered ( byte widget_index ) const
{
2009-06-03 21:13:13 +00:00
if ( this - > nested_array ! = NULL ) {
assert ( widget_index < this - > nested_array_size ) ;
2009-09-19 11:31:12 +00:00
return this - > GetWidget < NWidgetCore > ( widget_index ) - > IsLowered ( ) ;
2009-06-03 21:13:13 +00:00
}
2009-02-17 12:41:29 +00:00
assert ( widget_index < this - > widget_count ) ;
return HasBit ( this - > widget [ widget_index ] . display_flags , WIDG_LOWERED ) ;
}
/**
* Align widgets a and b next to each other .
* @ param widget_index_a the left widget
* @ param widget_index_b the right widget ( fixed )
*/
inline void AlignWidgetRight ( byte widget_index_a , byte widget_index_b )
{
assert ( widget_index_a < this - > widget_count ) ;
assert ( widget_index_b < this - > widget_count ) ;
int w = this - > widget [ widget_index_a ] . right - this - > widget [ widget_index_a ] . left ;
this - > widget [ widget_index_a ] . right = this - > widget [ widget_index_b ] . left - 1 ;
this - > widget [ widget_index_a ] . left = this - > widget [ widget_index_a ] . right - w ;
}
/**
* Get the width of a widget .
* @ param widget_index the widget
* @ return width of the widget
*/
inline int GetWidgetWidth ( byte widget_index ) const
{
assert ( widget_index < this - > widget_count ) ;
return this - > widget [ widget_index ] . right - this - > widget [ widget_index ] . left + 1 ;
}
2009-09-11 19:12:05 +00:00
bool SetFocusedWidget ( byte widget_index ) ;
2009-02-17 12:41:29 +00:00
void HandleButtonClick ( byte widget ) ;
2009-05-16 11:25:19 +00:00
const Widget * GetWidgetOfType ( WidgetType widget_type ) const ;
2007-12-02 00:59:48 +00:00
2009-08-14 21:27:08 +00:00
void RaiseButtons ( bool autoraise = false ) ;
2007-12-02 00:59:48 +00:00
void CDECL SetWidgetsDisabledState ( bool disab_stat , int widgets , . . . ) ;
void CDECL SetWidgetsHiddenState ( bool hidden_stat , int widgets , . . . ) ;
void CDECL SetWidgetsLoweredState ( bool lowered_stat , int widgets , . . . ) ;
2009-09-13 19:15:59 +00:00
void SetWidgetDirty ( byte widget_index ) const ;
2008-05-04 10:05:50 +00:00
2008-05-17 12:48:06 +00:00
void DrawWidgets ( ) const ;
void DrawViewport ( ) const ;
void DrawSortButtonState ( int widget , SortButtonState state ) const ;
2008-09-24 16:40:06 +00:00
void DeleteChildWindows ( ) const ;
2008-05-06 21:28:30 +00:00
void SetDirty ( ) const ;
2009-06-28 20:09:40 +00:00
void ReInit ( ) ;
2008-05-06 21:28:30 +00:00
2009-09-30 21:00:35 +00:00
/**
* Mark this window ' s data as invalid ( in need of re - computing )
* @ param data The data to invalidate with
*/
void InvalidateData ( int data = 0 )
{
this - > SetDirty ( ) ;
this - > OnInvalidateData ( data ) ;
}
2008-05-10 13:46:36 +00:00
/*** Event handling ***/
/**
2009-06-28 22:23:26 +00:00
* The window must be repainted .
* @ note This method should not change any state , it should only use drawing functions .
2008-05-10 13:46:36 +00:00
*/
2008-05-19 09:48:47 +00:00
virtual void OnPaint ( ) { }
2008-05-10 13:46:36 +00:00
2009-06-28 22:23:26 +00:00
/**
* Draw the contents of a nested widget .
* @ param r Rectangle occupied by the widget .
* @ param widget Number of the widget to draw .
* @ note This method may not change any state , it may only use drawing functions .
*/
virtual void DrawWidget ( const Rect & r , int widget ) const { }
2009-07-04 15:35:36 +00:00
/**
2009-07-18 10:46:55 +00:00
* Update size and resize step of a widget in the window .
* After retrieval of the minimal size and the resize - steps of a widget , this function is called to allow further refinement ,
* typically by computing the real maximal size of the content . Afterwards , \ a size is taken to be the minimal size of the widget
* and \ a resize is taken to contain the resize steps . For the convenience of the callee , \ a padding contains the amount of
* padding between the content and the edge of the widget . This should be added to the returned size .
* @ param widget Widget number .
* @ param size Size of the widget .
* @ param padding Recommended amount of space between the widget content and the widget edge .
* @ param resize Resize step of the widget .
2009-07-04 15:35:36 +00:00
*/
2009-07-18 10:46:55 +00:00
virtual void UpdateWidgetSize ( int widget , Dimension * size , const Dimension & padding , Dimension * resize ) { }
2009-07-04 15:35:36 +00:00
2009-07-25 11:54:53 +00:00
/**
* Initialize string parameters for a widget .
* Calls to this function are made during initialization to measure the size ( that is as part of # InitNested ( ) ) , during drawing ,
* and while re - initializing the window . Only for widgets that render text initializing is requested .
* @ param widget Widget number .
*/
virtual void SetStringParameters ( int widget ) const { }
2009-02-09 01:22:29 +00:00
/**
* Called when window gains focus
*/
virtual void OnFocus ( ) { }
/**
* Called when window looses focus
*/
virtual void OnFocusLost ( ) { }
2008-05-10 13:46:36 +00:00
/**
* A key has been pressed .
* @ param key the Unicode value of the key .
* @ param keycode the untranslated key code including shift state .
2008-05-17 23:11:06 +00:00
* @ return ES_HANDLED if the key press has been handled and no other
2008-05-10 13:46:36 +00:00
* window should receive the event .
*/
2008-05-19 09:48:47 +00:00
virtual EventState OnKeyPress ( uint16 key , uint16 keycode ) { return ES_NOT_HANDLED ; }
2008-05-10 13:46:36 +00:00
/**
* The state of the control key has changed
2008-05-17 23:11:06 +00:00
* @ return ES_HANDLED if the change has been handled and no other
2008-05-10 13:46:36 +00:00
* window should receive the event .
*/
2008-05-19 09:48:47 +00:00
virtual EventState OnCTRLStateChange ( ) { return ES_NOT_HANDLED ; }
2008-05-10 13:46:36 +00:00
/**
* A click with the left mouse button has been made on the window .
* @ param pt the point inside the window that has been clicked .
* @ param widget the clicked widget .
*/
2008-05-19 09:48:47 +00:00
virtual void OnClick ( Point pt , int widget ) { }
2008-05-10 13:46:36 +00:00
/**
* A double click with the left mouse button has been made on the window .
* @ param pt the point inside the window that has been clicked .
* @ param widget the clicked widget .
*/
2008-05-16 23:30:10 +00:00
virtual void OnDoubleClick ( Point pt , int widget ) { }
2008-05-10 13:46:36 +00:00
/**
* A click with the right mouse button has been made on the window .
* @ param pt the point inside the window that has been clicked .
* @ param widget the clicked widget .
*/
2008-05-16 23:30:10 +00:00
virtual void OnRightClick ( Point pt , int widget ) { }
2008-05-10 13:46:36 +00:00
/**
* A dragged ' object ' has been released .
* @ param pt the point inside the window where the release took place .
* @ param widget the widget where the release took place .
*/
2008-05-16 23:30:10 +00:00
virtual void OnDragDrop ( Point pt , int widget ) { }
2008-05-10 13:46:36 +00:00
/**
* Handle the request for ( viewport ) scrolling .
* @ param delta the amount the viewport must be scrolled .
*/
2008-05-16 23:30:10 +00:00
virtual void OnScroll ( Point delta ) { }
2008-05-10 13:46:36 +00:00
/**
* The mouse is currently moving over the window or has just moved outside
* of the window . In the latter case pt is ( - 1 , - 1 ) .
* @ param pt the point inside the window that the mouse hovers over .
* @ param widget the widget the mouse hovers over .
*/
2008-05-16 23:30:10 +00:00
virtual void OnMouseOver ( Point pt , int widget ) { }
2008-05-10 13:46:36 +00:00
/**
* The mouse wheel has been turned .
* @ param wheel the amount of movement of the mouse wheel .
*/
2008-05-16 23:30:10 +00:00
virtual void OnMouseWheel ( int wheel ) { }
2008-05-10 13:46:36 +00:00
/**
* Called for every mouse loop run , which is at least once per ( game ) tick .
*/
2008-05-19 09:48:47 +00:00
virtual void OnMouseLoop ( ) { }
2008-05-10 13:46:36 +00:00
/**
* Called once per ( game ) tick .
*/
2008-05-19 09:48:47 +00:00
virtual void OnTick ( ) { }
2008-05-10 13:46:36 +00:00
/**
* Called once every 100 ( game ) ticks .
*/
2008-05-19 09:48:47 +00:00
virtual void OnHundredthTick ( ) { }
2008-05-10 13:46:36 +00:00
/**
* Called when this window ' s timeout has been reached .
*/
2008-05-19 09:48:47 +00:00
virtual void OnTimeout ( ) { }
2008-05-10 13:46:36 +00:00
/**
2009-03-29 09:49:11 +00:00
* Called after the window got resized .
2009-07-26 17:29:01 +00:00
* For nested windows with a viewport , call NWidgetViewport : : UpdateViewportCoordinates .
2009-03-29 09:49:11 +00:00
* @ param delta The amount of which the window size changed .
2008-05-10 13:46:36 +00:00
*/
2009-03-29 09:49:11 +00:00
virtual void OnResize ( Point delta ) { }
2008-05-10 13:46:36 +00:00
/**
* A dropdown option associated to this window has been selected .
* @ param widget the widget ( button ) that the dropdown is associated with .
* @ param index the element in the dropdown that is selected .
*/
2008-05-19 09:48:47 +00:00
virtual void OnDropdownSelect ( int widget , int index ) { }
2008-05-10 13:46:36 +00:00
/**
* The query window opened from this window has closed .
* @ param str the new value of the string or NULL if the window
* was cancelled .
*/
2008-05-19 09:48:47 +00:00
virtual void OnQueryTextFinished ( char * str ) { }
2008-05-10 13:46:36 +00:00
/**
* Some data on this window has become invalid .
* @ param data information about the changed data .
*/
2008-05-19 09:48:47 +00:00
virtual void OnInvalidateData ( int data = 0 ) { }
2008-05-10 13:46:36 +00:00
/**
* The user clicked some place on the map when a tile highlight mode
* has been set .
* @ param pt the exact point on the map that has been clicked .
* @ param tile the tile on the map that has been clicked .
*/
2008-05-19 09:48:47 +00:00
virtual void OnPlaceObject ( Point pt , TileIndex tile ) { }
2008-05-10 13:46:36 +00:00
/**
* The user cancelled a tile highlight mode that has been set .
*/
2008-05-19 09:48:47 +00:00
virtual void OnPlaceObjectAbort ( ) { }
2008-05-10 13:46:36 +00:00
/**
* The user is dragging over the map when the tile highlight mode
* has been set .
* @ param select_method the method of selection ( allowed directions )
* @ param select_proc what will be created when the drag is over .
* @ param pt the exact point on the map where the mouse is .
*/
2008-05-19 09:48:47 +00:00
virtual void OnPlaceDrag ( ViewportPlaceMethod select_method , ViewportDragDropSelectionProcess select_proc , Point pt ) { }
2008-05-10 13:46:36 +00:00
/**
* The user has dragged over the map when the tile highlight mode
* has been set .
* @ param select_method the method of selection ( allowed directions )
* @ param select_proc what should be created .
* @ param pt the exact point on the map where the mouse was released .
* @ param start_tile the begin tile of the drag .
* @ param end_tile the end tile of the drag .
*/
2008-05-19 09:48:47 +00:00
virtual void OnPlaceMouseUp ( ViewportPlaceMethod select_method , ViewportDragDropSelectionProcess select_proc , Point pt , TileIndex start_tile , TileIndex end_tile ) { }
2008-05-10 13:46:36 +00:00
/**
* The user moves over the map when a tile highlight mode has been set
* when the special mouse mode has been set to ' PRESIZE ' mode . An
* example of this is the tile highlight for dock building .
* @ param pt the exact point on the map where the mouse is .
* @ param tile the tile on the map where the mouse is .
*/
2008-05-19 09:48:47 +00:00
virtual void OnPlacePresize ( Point pt , TileIndex tile ) { }
2008-05-10 13:46:36 +00:00
/*** End of the event handling ***/
2004-08-09 17:04:08 +00:00
} ;
2009-09-19 11:31:12 +00:00
/** Get the nested widget with number \a widnum from the nested widget tree.
* @ tparam NWID Type of the nested widget .
* @ param widnum Widget number of the widget to retrieve .
* @ return The requested widget if it is instantiated , \ c NULL otherwise .
*/
template < class NWID >
inline NWID * Window : : GetWidget ( uint widnum ) const
{
if ( widnum > = this - > nested_array_size | | this - > nested_array [ widnum ] = = NULL ) return NULL ;
NWID * nwid = dynamic_cast < NWID * > ( this - > nested_array [ widnum ] ) ;
assert ( nwid ! = NULL ) ;
return nwid ;
}
/** Specialized case of #Window::GetWidget for the nested widget base class. */
template < >
inline NWidgetBase * Window : : GetWidget < NWidgetBase > ( uint widnum ) const
{
if ( widnum > = this - > nested_array_size ) return NULL ;
return this - > nested_array [ widnum ] ;
}
2008-05-17 03:29:16 +00:00
/**
2009-07-20 19:44:28 +00:00
* Base class for windows opened from a toolbar .
2008-05-17 03:29:16 +00:00
*/
class PickerWindowBase : public Window {
public :
2009-07-21 22:25:21 +00:00
PickerWindowBase ( const WindowDesc * desc , Window * parent , WindowNumber number = 0 ) : Window ( desc , number )
2008-05-24 11:19:30 +00:00
{
this - > parent = parent ;
} ;
2008-05-17 03:29:16 +00:00
2009-07-20 19:44:28 +00:00
PickerWindowBase ( Window * parent ) : Window ( )
{
this - > parent = parent ;
} ;
2008-05-17 03:29:16 +00:00
virtual ~ PickerWindowBase ( ) ;
} ;
2008-04-07 20:28:58 +00:00
/**
* Window flags
*/
2004-08-09 17:04:08 +00:00
enum WindowFlags {
2008-09-23 19:25:00 +00:00
WF_TIMEOUT_TRIGGER = 1 , ///< When the timeout should start triggering
WF_TIMEOUT_BEGIN = 7 , ///< The initial value for the timeout
2008-09-23 15:24:15 +00:00
WF_TIMEOUT_MASK = 7 , ///< Window timeout counter bit mask (3 bits)
2008-04-07 20:28:58 +00:00
WF_DRAGGING = 1 < < 3 , ///< Window is being dragged
WF_SCROLL_UP = 1 < < 4 , ///< Upper scroll button has been pressed, @see ScrollbarClickHandler()
WF_SCROLL_DOWN = 1 < < 5 , ///< Lower scroll button has been pressed, @see ScrollbarClickHandler()
WF_SCROLL_MIDDLE = 1 < < 6 , ///< Scrollbar scrolling, @see ScrollbarClickHandler()
2009-03-18 01:06:48 +00:00
WF_SCROLL2 = 1 < < 7 ,
WF_HSCROLL = 1 < < 8 ,
WF_SIZING_RIGHT = 1 < < 9 , ///< Window is being resized towards the right.
WF_SIZING_LEFT = 1 < < 10 , ///< Window is being resized towards the left.
WF_SIZING = WF_SIZING_RIGHT | WF_SIZING_LEFT , ///< Window is being resized.
WF_STICKY = 1 < < 11 , ///< Window is made sticky by user
2005-01-03 19:45:18 +00:00
2009-03-18 01:06:48 +00:00
WF_DISABLE_VP_SCROLL = 1 < < 12 , ///< Window does not do autoscroll, @see HandleAutoscroll()
2004-08-09 17:04:08 +00:00
2009-03-18 01:06:48 +00:00
WF_WHITE_BORDER_ONE = 1 < < 13 ,
WF_WHITE_BORDER_MASK = 1 < < 14 | WF_WHITE_BORDER_ONE ,
2004-08-09 17:04:08 +00:00
} ;
Window * BringWindowToFrontById ( WindowClass cls , WindowNumber number ) ;
Window * FindWindowFromPt ( int x , int y ) ;
2008-05-08 11:50:34 +00:00
/**
* Open a new window .
2008-10-14 19:27:08 +00:00
* @ param desc The pointer to the WindowDesc to be created
2008-05-08 11:50:34 +00:00
* @ param window_number the window number of the new window
* @ return see Window pointer of the newly created window
*/
template < typename Wcls >
2008-05-13 14:43:33 +00:00
Wcls * AllocateWindowDescFront ( const WindowDesc * desc , int window_number )
2008-05-08 11:50:34 +00:00
{
if ( BringWindowToFrontById ( desc - > cls , window_number ) ) return NULL ;
2008-05-13 14:43:33 +00:00
return new Wcls ( desc , window_number ) ;
2008-05-08 11:50:34 +00:00
}
2004-08-09 17:04:08 +00:00
void RelocateAllWindows ( int neww , int newh ) ;
2007-02-23 01:48:53 +00:00
/* misc_gui.cpp */
2008-08-02 11:26:25 +00:00
void GuiShowTooltips ( StringID str , uint paramcount = 0 , const uint64 params [ ] = NULL , bool use_left_mouse_button = false ) ;
2006-10-03 20:16:20 +00:00
2007-02-23 01:48:53 +00:00
/* widget.cpp */
2005-09-18 20:56:44 +00:00
int GetWidgetFromPos ( const Window * w , int x , int y ) ;
2004-08-09 17:04:08 +00:00
2008-10-14 19:27:08 +00:00
/** Iterate over all windows */
2009-01-07 18:59:46 +00:00
# define FOR_ALL_WINDOWS_FROM_BACK_FROM(w, start) for (w = start; w != NULL; w = w->z_front) if (w->window_class != WC_INVALID)
# define FOR_ALL_WINDOWS_FROM_FRONT_FROM(w, start) for (w = start; w != NULL; w = w->z_back) if (w->window_class != WC_INVALID)
# define FOR_ALL_WINDOWS_FROM_BACK(w) FOR_ALL_WINDOWS_FROM_BACK_FROM(w, _z_back_window)
# define FOR_ALL_WINDOWS_FROM_FRONT(w) FOR_ALL_WINDOWS_FROM_FRONT_FROM(w, _z_front_window)
2004-08-09 17:04:08 +00:00
2008-01-13 13:36:01 +00:00
extern Point _cursorpos_drag_start ;
2004-08-09 17:04:08 +00:00
2008-01-13 13:36:01 +00:00
extern int _scrollbar_start_pos ;
extern int _scrollbar_size ;
extern byte _scroller_click_timeout ;
2004-08-09 17:04:08 +00:00
2008-01-13 13:36:01 +00:00
extern bool _scrolling_scrollbar ;
extern bool _scrolling_viewport ;
2004-08-09 17:04:08 +00:00
2008-01-13 13:36:01 +00:00
extern byte _special_mouse_mode ;
2004-08-09 17:04:08 +00:00
enum SpecialMouseMode {
2006-08-22 14:38:37 +00:00
WSM_NONE = 0 ,
2004-08-09 17:04:08 +00:00
WSM_DRAGDROP = 1 ,
2006-08-22 14:38:37 +00:00
WSM_SIZING = 2 ,
WSM_PRESIZE = 3 ,
2004-08-09 17:04:08 +00:00
} ;
2008-04-19 13:28:48 +00:00
Window * GetCallbackWnd ( ) ;
2009-02-09 01:22:29 +00:00
void SetFocusedWindow ( Window * w ) ;
bool EditBoxInGlobalFocus ( ) ;
2004-08-09 17:04:08 +00:00
void ScrollbarClickHandler ( Window * w , const Widget * wi , int x , int y ) ;
2009-06-04 14:07:05 +00:00
void ScrollbarClickHandler ( Window * w , const NWidgetCore * nw , int x , int y ) ;
2004-08-09 17:04:08 +00:00
2007-01-24 02:36:55 +00:00
void ResizeButtons ( Window * w , byte left , byte right ) ;
2008-08-03 17:35:08 +00:00
void ResizeWindowForWidget ( Window * w , uint widget , int delta_x , int delta_y ) ;
2008-01-26 20:55:04 +00:00
2007-12-19 19:44:29 +00:00
# endif /* WINDOW_GUI_H */