2005-07-24 14:12:37 +00:00
/* $Id$ */
2004-08-09 17:04:08 +00:00
# ifndef WINDOW_H
# define WINDOW_H
2006-08-19 09:31:22 +00:00
# include "string.h"
2004-08-09 17:04:08 +00:00
typedef union WindowEvent WindowEvent ;
typedef void WindowProc ( Window * w , WindowEvent * e ) ;
2005-01-03 19:45:18 +00:00
/* How the resize system works:
First , you need to add a WWT_RESIZEBOX to the widgets , and you need
to add the flag WDF_RESIZABLE to the window . Now the window is ready
to resize itself .
As you may have noticed , all widgets have a RESIZE_XXX in their line .
This lines controls how the widgets behave on resize . RESIZE_NONE means
it doesn ' t do anything . Any other option let ' s one of the borders
move with the changed width / height . So if a widget has
RESIZE_RIGHT , and the window is made 5 pixels wider by the user ,
the right of the window will also be made 5 pixels wider .
Now , what if you want to clamp a widget to the bottom ? Give it the flag
RESIZE_TB . This is RESIZE_TOP + RESIZE_BOTTOM . Now if the window gets
5 pixels bigger , both the top and bottom gets 5 bigger , so the whole
widgets moves downwards without resizing , and appears to be clamped
to the bottom . Nice aint it ?
You should know one more thing about this system . Most windows can ' t
handle an increase of 1 pixel . So there is a step function , which
let the windowsize only be changed by X pixels . You configure this
after making the window , like this :
w - > resize . step_height = 10 ;
Now the window will only change in height in steps of 10.
You can also give a minimum width and height . The default value is
the default height / width of the window itself . You can change this
AFTER window - creation , with :
w - > resize . width or w - > resize . height .
That was all . . good luck , and enjoy : ) - - TrueLight */
enum {
RESIZE_NONE = 0 ,
RESIZE_LEFT = 1 ,
RESIZE_RIGHT = 2 ,
RESIZE_TOP = 4 ,
RESIZE_BOTTOM = 8 ,
RESIZE_LR = RESIZE_LEFT | RESIZE_RIGHT ,
RESIZE_RB = RESIZE_RIGHT | RESIZE_BOTTOM ,
RESIZE_TB = RESIZE_TOP | RESIZE_BOTTOM ,
RESIZE_LRB = RESIZE_LEFT | RESIZE_RIGHT | RESIZE_BOTTOM ,
RESIZE_LRTB = RESIZE_LEFT | RESIZE_RIGHT | RESIZE_TOP | RESIZE_BOTTOM ,
RESIZE_RTB = RESIZE_RIGHT | RESIZE_TOP | RESIZE_BOTTOM ,
} ;
2004-08-09 17:04:08 +00:00
typedef struct Widget {
byte type ;
2005-01-03 19:45:18 +00:00
byte resize_flag ;
2004-08-09 17:04:08 +00:00
byte color ;
uint16 left , right , top , bottom ;
uint16 unkA ;
2005-11-13 21:16:34 +00:00
StringID tooltips ;
2004-08-09 17:04:08 +00:00
} Widget ;
2006-08-29 06:07:57 +00:00
typedef enum FrameFlags {
2005-06-15 17:27:14 +00:00
FR_TRANSPARENT = 0x01 , ///< Makes the background transparent if set
FR_BORDERONLY = 0x10 , ///< Draw border only, no background
FR_LOWERED = 0x20 , ///< If set the frame is lowered and the background color brighter (ie. buttons when pressed)
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)
2006-08-29 06:07:57 +00:00
} FrameFlags ;
void DrawFrameRect ( int left , int top , int right , int bottom , int color , FrameFlags flags ) ;
2005-06-15 17:27:14 +00:00
2005-04-05 21:03:30 +00:00
/* XXX - outside "byte event" so you can set event directly without going into
* the union elements at first . Because of this every first element of the union
* MUST BE ' byte event ' . Whoever did this must get shot ! Scheduled for immediate
* rewrite after 0.4 .0 */
2004-08-09 17:04:08 +00:00
union WindowEvent {
byte event ;
struct {
byte event ;
Point pt ;
int widget ;
} click ;
struct {
byte event ;
Point pt ;
2005-06-24 12:38:35 +00:00
TileIndex tile ;
TileIndex starttile ;
2004-08-09 17:04:08 +00:00
int userdata ;
} place ;
struct {
byte event ;
Point pt ;
int widget ;
} dragdrop ;
2005-01-03 19:45:18 +00:00
struct {
byte event ;
Point size ;
Point diff ;
} sizing ;
2004-08-09 17:04:08 +00:00
struct {
byte event ;
2005-02-06 18:30:45 +00:00
char * str ;
2004-08-09 17:04:08 +00:00
} edittext ;
struct {
byte event ;
Point pt ;
} popupmenu ;
struct {
byte event ;
int button ;
int index ;
} dropdown ;
2004-12-04 17:54:56 +00:00
struct {
byte event ;
Point pt ;
int widget ;
} mouseover ;
2004-08-09 17:04:08 +00:00
struct {
byte event ;
bool cont ; // continue the search? (default true)
byte ascii ; // 8-bit ASCII-value of the key
uint16 keycode ; // untranslated key (including shift-state)
} keypress ;
2005-04-05 21:03:30 +00:00
struct {
byte event ;
uint msg ; // message to be sent
uint wparam ; // additional message-specific information
uint lparam ; // additional message-specific information
} message ;
2006-08-21 14:34:59 +00:00
struct {
byte event ;
Point delta ; // delta position against position of last call
} scroll ;
2006-08-21 14:59:58 +00:00
struct {
byte event ;
int wheel ; // how much was 'wheel'd'
} wheel ;
2004-08-09 17:04:08 +00:00
} ;
enum WindowKeyCodes {
WKC_SHIFT = 0x8000 ,
WKC_CTRL = 0x4000 ,
WKC_ALT = 0x2000 ,
WKC_META = 0x1000 ,
2004-09-05 14:20:36 +00:00
2004-08-09 17:04:08 +00:00
// Special ones
2006-08-22 14:38:37 +00:00
WKC_NONE = 0 ,
WKC_ESC = 1 ,
WKC_BACKSPACE = 2 ,
WKC_INSERT = 3 ,
WKC_DELETE = 4 ,
2004-08-09 17:04:08 +00:00
2006-08-22 14:38:37 +00:00
WKC_PAGEUP = 5 ,
WKC_PAGEDOWN = 6 ,
WKC_END = 7 ,
WKC_HOME = 8 ,
2004-08-09 17:04:08 +00:00
// Arrow keys
2006-08-22 14:38:37 +00:00
WKC_LEFT = 9 ,
WKC_UP = 10 ,
WKC_RIGHT = 11 ,
WKC_DOWN = 12 ,
2004-08-09 17:04:08 +00:00
// Return & tab
2006-08-22 14:38:37 +00:00
WKC_RETURN = 13 ,
WKC_TAB = 14 ,
2004-09-05 14:20:36 +00:00
2004-08-09 17:04:08 +00:00
// Numerical keyboard
2006-08-22 14:38:37 +00:00
WKC_NUM_0 = 16 ,
WKC_NUM_1 = 17 ,
WKC_NUM_2 = 18 ,
WKC_NUM_3 = 19 ,
WKC_NUM_4 = 20 ,
WKC_NUM_5 = 21 ,
WKC_NUM_6 = 22 ,
WKC_NUM_7 = 23 ,
WKC_NUM_8 = 24 ,
WKC_NUM_9 = 25 ,
WKC_NUM_DIV = 26 ,
WKC_NUM_MUL = 27 ,
WKC_NUM_MINUS = 28 ,
WKC_NUM_PLUS = 29 ,
WKC_NUM_ENTER = 30 ,
2004-08-09 17:04:08 +00:00
WKC_NUM_DECIMAL = 31 ,
// Space
2006-08-22 14:38:37 +00:00
WKC_SPACE = 32 ,
2004-08-09 17:04:08 +00:00
// Function keys
2006-08-22 14:38:37 +00:00
WKC_F1 = 33 ,
WKC_F2 = 34 ,
WKC_F3 = 35 ,
WKC_F4 = 36 ,
WKC_F5 = 37 ,
WKC_F6 = 38 ,
WKC_F7 = 39 ,
WKC_F8 = 40 ,
WKC_F9 = 41 ,
WKC_F10 = 42 ,
WKC_F11 = 43 ,
WKC_F12 = 44 ,
2004-08-09 17:04:08 +00:00
2004-08-24 11:53:30 +00:00
// backquote is the key left of "1"
// we only store this key here, no matter what character is really mapped to it
// on a particular keyboard. (US keyboard: ` and ~ ; German keyboard: ^ and <20> )
2006-08-22 14:38:37 +00:00
WKC_BACKQUOTE = 45 ,
WKC_PAUSE = 46 ,
2004-09-05 14:20:36 +00:00
2004-08-09 17:04:08 +00:00
// 0-9 are mapped to 48-57
// A-Z are mapped to 65-90
// a-z are mapped to 97-122
} ;
typedef struct WindowDesc {
int16 left , top , width , height ;
2005-12-24 15:01:17 +00:00
WindowClass cls ;
WindowClass parent_cls ;
2004-08-09 17:04:08 +00:00
uint32 flags ;
const Widget * widgets ;
WindowProc * proc ;
} WindowDesc ;
enum {
2006-08-22 14:38:37 +00:00
WDF_STD_TOOLTIPS = 1 , /* use standard routine when displaying tooltips */
WDF_DEF_WIDGET = 2 , /* default widget control for some widgets in the on click event */
WDF_STD_BTN = 4 , /* default handling for close and drag widgets (widget no 0 and 1) */
2005-07-15 15:09:52 +00:00
2006-08-22 14:38:37 +00:00
WDF_UNCLICK_BUTTONS = 16 , /* Unclick buttons when the window event times out */
WDF_STICKY_BUTTON = 32 , /* Set window to sticky mode; they are not closed unless closed with 'X' (widget 2) */
WDF_RESIZABLE = 64 , /* A window can be resized */
2004-08-09 17:04:08 +00:00
} ;
/* can be used as x or y coordinates to cause a specific placement */
enum {
2006-08-22 14:38:37 +00:00
WDP_AUTO = - 1 ,
2004-08-09 17:04:08 +00:00
WDP_CENTER = - 2 ,
} ;
2005-02-21 18:59:54 +00:00
typedef struct Textbuf {
char * buf ; /* buffer in which text is saved */
uint16 maxlength , maxwidth ; /* the maximum size of the buffer. Maxwidth specifies screensize in pixels */
2006-04-06 19:11:41 +00:00
uint16 length , width ; /* the current size of the string. Width specifies screensize in pixels */
2005-02-21 18:59:54 +00:00
bool caret ; /* is the caret ("_") visible or not */
uint16 caretpos ; /* the current position of the caret in the buffer */
uint16 caretxoffs ; /* the current position of the caret in pixels */
} Textbuf ;
2004-08-09 17:04:08 +00:00
# define WP(ptr,str) (*(str*)(ptr)->custom)
2006-01-28 11:52:20 +00:00
/* You cannot 100% reliably calculate the biggest custom struct as
* the number of pointers in it and alignment will have a huge impact .
2006-08-19 09:31:22 +00:00
* 96 is the largest window - size for 64 - bit machines currently */
# define WINDOW_CUSTOM_SIZE 96
2004-08-09 17:04:08 +00:00
2005-11-04 14:01:44 +00:00
typedef struct Scrollbar {
2004-08-16 13:09:52 +00:00
uint16 count , cap , pos ;
2004-08-09 17:04:08 +00:00
} Scrollbar ;
2005-11-04 14:01:44 +00:00
typedef struct ResizeInfo {
2005-01-03 19:45:18 +00:00
uint width ; /* Minimum width and height */
uint height ;
uint step_width ; /* In how big steps the width and height go */
uint step_height ;
} ResizeInfo ;
2005-11-10 15:23:55 +00:00
typedef struct WindowMessage {
2005-04-05 21:03:30 +00:00
int msg ;
int wparam ;
int lparam ;
2005-11-10 15:23:55 +00:00
} WindowMessage ;
2005-04-05 21:03:30 +00:00
2004-08-09 17:04:08 +00:00
struct Window {
uint16 flags4 ;
WindowClass window_class ;
WindowNumber window_number ;
2005-01-03 19:45:18 +00:00
int left , top ;
int width , height ;
2004-08-09 17:04:08 +00:00
2005-01-02 17:23:04 +00:00
Scrollbar hscroll , vscroll , vscroll2 ;
2005-01-03 19:45:18 +00:00
ResizeInfo resize ;
2004-08-09 17:04:08 +00:00
byte caption_color ;
uint32 click_state , disabled_state , hidden_state ;
WindowProc * wndproc ;
ViewPort * viewport ;
2005-01-03 19:45:18 +00:00
const Widget * original_widget ;
2006-06-27 21:25:53 +00:00
Widget * widget ;
2004-08-09 17:04:08 +00:00
uint32 desc_flags ;
2005-11-10 15:23:55 +00:00
WindowMessage message ;
2004-09-05 14:20:36 +00:00
byte custom [ WINDOW_CUSTOM_SIZE ] ;
2004-08-09 17:04:08 +00:00
} ;
2006-08-19 09:31:22 +00:00
typedef struct querystr_d {
StringID caption ;
WindowClass wnd_class ;
WindowNumber wnd_num ;
Textbuf text ;
const char * orig ;
CharSetFilter afilter ;
} querystr_d ;
assert_compile ( WINDOW_CUSTOM_SIZE > = sizeof ( querystr_d ) ) ;
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
- New optional landscape generator (TerraGenesis Perlin)
- Load heightmaps (either BMP or PNG)
- Progress dialog while generating worlds (no longer a 'hanging' screen)
- New dialogs for NewGame, Create Scenario and Play Heightmap
- Easier to configure your landscape
- More things to configure (tree-placer, ..)
- Speedup of world generation
- New console command 'restart': restart the map EXACTLY as it was when you
first started it (needs a game made after or with this commit)
- New console command 'getseed': get the seed of your map and share it with
others (of course only works with generated maps)
- Many new, world generation related, things
- Many internal cleanups and rewrites
Many tnx to those people who helped making this:
Belugas, DaleStan, glx, KUDr, RichK67, Rubidium, and TrueLight (alfabetic)
Many tnx to those who helped testing:
Arnau, Bjarni, and tokai (alfabetic)
And to all other people who helped testing and sending comments / bugs
Stats: 673 lines changed, 3534 new lines, 79 new strings
2006-08-19 10:00:30 +00:00
typedef struct query_d {
StringID caption ;
StringID message ;
WindowClass wnd_class ;
WindowNumber wnd_num ;
void ( * ok_cancel_callback ) ( bool ok_clicked ) ;
bool calledback ;
} query_d ;
assert_compile ( WINDOW_CUSTOM_SIZE > = sizeof ( query_d ) ) ;
2004-08-09 17:04:08 +00:00
typedef struct {
2006-07-26 03:33:12 +00:00
byte item_count ; /* follow_vehicle */
byte sel_index ; /* scrollpos_x */
byte main_button ; /* scrollpos_y */
2004-08-09 17:04:08 +00:00
byte action_id ;
2006-07-26 03:33:12 +00:00
StringID string_id ; /* unk30 */
2004-08-09 17:04:08 +00:00
uint16 checked_items ; /* unk32 */
2005-07-28 08:49:29 +00:00
byte disabled_items ;
2004-08-09 17:04:08 +00:00
} menu_d ;
2005-01-14 00:14:13 +00:00
assert_compile ( WINDOW_CUSTOM_SIZE > = sizeof ( menu_d ) ) ;
2004-08-09 17:04:08 +00:00
typedef struct {
int16 data_1 , data_2 , data_3 ;
int16 data_4 , data_5 ;
2005-11-04 14:01:44 +00:00
bool close ;
2004-08-09 17:04:08 +00:00
byte byte_1 ;
} def_d ;
2005-01-14 00:14:13 +00:00
assert_compile ( WINDOW_CUSTOM_SIZE > = sizeof ( def_d ) ) ;
2004-08-09 17:04:08 +00:00
typedef struct {
void * data ;
} void_d ;
2005-01-14 00:14:13 +00:00
assert_compile ( WINDOW_CUSTOM_SIZE > = sizeof ( void_d ) ) ;
2004-08-09 17:04:08 +00:00
typedef struct {
2005-11-04 14:01:44 +00:00
uint16 base ;
uint16 count ;
2004-08-09 17:04:08 +00:00
} tree_d ;
2005-01-14 00:14:13 +00:00
assert_compile ( WINDOW_CUSTOM_SIZE > = sizeof ( tree_d ) ) ;
2004-08-09 17:04:08 +00:00
typedef struct {
StringID string_id ;
} tooltips_d ;
2005-01-14 00:14:13 +00:00
assert_compile ( WINDOW_CUSTOM_SIZE > = sizeof ( tooltips_d ) ) ;
2004-08-09 17:04:08 +00:00
typedef struct {
byte railtype ;
byte sel_index ;
2005-10-07 07:35:15 +00:00
EngineID sel_engine ;
EngineID rename_engine ;
2004-08-09 17:04:08 +00:00
} buildtrain_d ;
2005-01-14 00:14:13 +00:00
assert_compile ( WINDOW_CUSTOM_SIZE > = sizeof ( buildtrain_d ) ) ;
2004-08-09 17:04:08 +00:00
2005-01-02 17:23:04 +00:00
typedef struct {
byte vehicletype ;
byte sel_index [ 2 ] ;
2005-12-13 09:57:07 +00:00
EngineID sel_engine [ 2 ] ;
2005-01-02 17:23:04 +00:00
uint16 count [ 2 ] ;
2006-08-28 18:53:03 +00:00
bool wagon_btnstate ; // true means engine is selected
2005-01-02 17:23:04 +00:00
} replaceveh_d ;
2005-01-14 00:14:13 +00:00
assert_compile ( WINDOW_CUSTOM_SIZE > = sizeof ( replaceveh_d ) ) ;
2005-01-02 17:23:04 +00:00
2004-08-09 17:04:08 +00:00
typedef struct {
VehicleID sel ;
} traindepot_d ;
2005-01-14 00:14:13 +00:00
assert_compile ( WINDOW_CUSTOM_SIZE > = sizeof ( traindepot_d ) ) ;
2004-08-09 17:04:08 +00:00
typedef struct {
int sel ;
} order_d ;
2005-01-14 00:14:13 +00:00
assert_compile ( WINDOW_CUSTOM_SIZE > = sizeof ( order_d ) ) ;
2004-08-09 17:04:08 +00:00
typedef struct {
byte tab ;
} traindetails_d ;
2005-01-14 00:14:13 +00:00
assert_compile ( WINDOW_CUSTOM_SIZE > = sizeof ( traindetails_d ) ) ;
2004-08-09 17:04:08 +00:00
typedef struct {
2005-01-03 08:50:44 +00:00
int32 scroll_x ;
int32 scroll_y ;
int32 subscroll ;
2004-08-09 17:04:08 +00:00
} smallmap_d ;
2006-08-20 11:51:10 +00:00
assert_compile ( WINDOW_CUSTOM_SIZE > = sizeof ( smallmap_d ) ) ;
2004-08-09 17:04:08 +00:00
typedef struct {
uint32 face ;
byte gender ;
} facesel_d ;
2005-01-14 00:14:13 +00:00
assert_compile ( WINDOW_CUSTOM_SIZE > = sizeof ( facesel_d ) ) ;
2004-08-09 17:04:08 +00:00
typedef struct {
int sel ;
2006-03-26 22:23:32 +00:00
CargoID cargo ;
2004-08-09 17:04:08 +00:00
} refit_d ;
2005-01-14 00:14:13 +00:00
assert_compile ( WINDOW_CUSTOM_SIZE > = sizeof ( refit_d ) ) ;
2004-08-09 17:04:08 +00:00
typedef struct {
2005-07-17 20:14:58 +00:00
VehicleID follow_vehicle ;
2005-01-03 08:50:44 +00:00
int32 scrollpos_x ;
int32 scrollpos_y ;
2004-08-09 17:04:08 +00:00
} vp_d ;
2005-01-14 00:14:13 +00:00
assert_compile ( WINDOW_CUSTOM_SIZE > = sizeof ( vp_d ) + 3 * sizeof ( byte ) ) ; // + 3 * byte is a hack from Miham
// vp2_d is the same as vp_d, except for the data_# values..
typedef struct {
uint16 follow_vehicle ;
int32 scrollpos_x ;
int32 scrollpos_y ;
byte data_1 ;
byte data_2 ;
byte data_3 ;
} vp2_d ;
assert_compile ( WINDOW_CUSTOM_SIZE > = sizeof ( vp2_d ) ) ;
2004-08-09 17:04:08 +00:00
typedef struct {
uint16 follow_vehicle ;
2005-01-03 08:50:44 +00:00
int32 scrollpos_x ;
int32 scrollpos_y ;
2004-08-09 17:04:08 +00:00
NewsItem * ni ;
} news_d ;
2005-01-14 00:14:13 +00:00
assert_compile ( WINDOW_CUSTOM_SIZE > = sizeof ( news_d ) ) ;
2004-08-09 17:04:08 +00:00
2005-01-03 16:45:42 +00:00
typedef struct {
2005-01-13 16:28:47 +00:00
uint32 background_img ;
int8 rank ;
} highscore_d ;
2005-01-14 00:14:13 +00:00
assert_compile ( WINDOW_CUSTOM_SIZE > = sizeof ( highscore_d ) ) ;
2005-01-13 16:28:47 +00:00
typedef struct {
int height ;
uint16 counter ;
} scroller_d ;
2005-01-14 00:14:13 +00:00
assert_compile ( WINDOW_CUSTOM_SIZE > = sizeof ( scroller_d ) ) ;
2005-01-03 16:45:42 +00:00
2004-12-10 18:16:08 +00:00
typedef enum VehicleListFlags {
2006-01-26 17:10:11 +00:00
VL_DESC = 0x01 , // sort descending or ascending
VL_RESORT = 0x02 , // instruct the code to resort the list in the next loop
VL_REBUILD = 0x04 // create sort-listing to use for qsort and friends
2004-12-10 18:16:08 +00:00
} VehicleListFlags ;
typedef struct vehiclelist_d {
2006-08-14 20:25:29 +00:00
const Vehicle * * sort_list ;
2004-12-10 18:16:08 +00:00
uint16 list_length ;
byte sort_type ;
VehicleListFlags flags ;
uint16 resort_timer ;
} vehiclelist_d ;
2005-01-14 00:14:13 +00:00
assert_compile ( WINDOW_CUSTOM_SIZE > = sizeof ( vehiclelist_d ) ) ;
2004-12-10 18:16:08 +00:00
2006-01-26 17:10:11 +00:00
typedef struct list_d {
uint16 list_length ; // length of the list being sorted
byte sort_type ; // what criteria to sort on
VehicleListFlags flags ; // used to control sorting/resorting/etc.
uint16 resort_timer ; // resort list after a given amount of ticks if set
} list_d ;
assert_compile ( WINDOW_CUSTOM_SIZE > = sizeof ( list_d ) ) ;
2005-04-05 21:03:30 +00:00
typedef struct message_d {
int msg ;
int wparam ;
int lparam ;
} message_d ;
assert_compile ( WINDOW_CUSTOM_SIZE > = sizeof ( message_d ) ) ;
2005-11-14 08:42:45 +00:00
typedef struct dropdown_d {
2005-11-22 14:02:45 +00:00
uint32 disabled_state ;
uint32 hidden_state ;
2005-11-14 08:42:45 +00:00
WindowClass parent_wnd_class ;
WindowNumber parent_wnd_num ;
byte parent_button ;
byte num_items ;
byte selected_index ;
const StringID * items ;
byte click_delay ;
bool drag_mode ;
} dropdown_d ;
assert_compile ( WINDOW_CUSTOM_SIZE > = sizeof ( dropdown_d ) ) ;
2004-08-09 17:04:08 +00:00
enum WindowEvents {
2006-08-22 14:38:37 +00:00
WE_CLICK = 0 ,
WE_PAINT = 1 ,
WE_MOUSELOOP = 2 ,
WE_TICK = 3 ,
WE_4 = 4 ,
WE_TIMEOUT = 5 ,
WE_PLACE_OBJ = 6 ,
WE_ABORT_PLACE_OBJ = 7 ,
WE_DESTROY = 8 ,
WE_ON_EDIT_TEXT = 9 ,
WE_POPUPMENU_SELECT = 10 ,
WE_POPUPMENU_OVER = 11 ,
WE_DRAGDROP = 12 ,
WE_PLACE_DRAG = 13 ,
WE_PLACE_MOUSEUP = 14 ,
WE_PLACE_PRESIZE = 15 ,
WE_DROPDOWN_SELECT = 16 ,
WE_RCLICK = 17 ,
WE_KEYPRESS = 18 ,
WE_CREATE = 19 ,
WE_MOUSEOVER = 20 ,
2004-12-04 17:54:56 +00:00
WE_ON_EDIT_TEXT_CANCEL = 21 ,
2006-08-22 14:38:37 +00:00
WE_RESIZE = 22 ,
WE_MESSAGE = 23 ,
WE_SCROLL = 24 ,
WE_MOUSEWHEEL = 25 ,
2004-08-09 17:04:08 +00:00
} ;
/****************** THESE ARE NOT WIDGET TYPES!!!!! *******************/
enum WindowWidgetBehaviours {
2006-08-22 14:38:37 +00:00
WWB_PUSHBUTTON = 1 < < 5 ,
2004-08-09 17:04:08 +00:00
WWB_NODISBUTTON = 2 < < 5 ,
} ;
enum WindowWidgetTypes {
WWT_EMPTY = 0 ,
2004-09-05 14:20:36 +00:00
2006-08-22 14:38:37 +00:00
WWT_IMGBTN = 1 , /* button with image */
WWT_PANEL = WWT_IMGBTN ,
WWT_PANEL_2 = 2 , /* button with diff image when clicked */
2004-08-09 17:04:08 +00:00
2006-08-22 14:38:37 +00:00
WWT_TEXTBTN = 3 , /* button with text */
WWT_4 = 4 , /* button with diff text when clicked */
2006-08-22 15:23:25 +00:00
WWT_LABEL = 5 , /* centered label */
2006-08-22 14:38:37 +00:00
WWT_6 = 6 , /* combo box text area */
WWT_MATRIX = 7 ,
WWT_SCROLLBAR = 8 ,
WWT_FRAME = 9 , /* frame */
WWT_CAPTION = 10 ,
2004-09-05 14:20:36 +00:00
2004-08-09 17:04:08 +00:00
WWT_HSCROLLBAR = 11 ,
2006-08-22 14:38:37 +00:00
WWT_STICKYBOX = 12 ,
WWT_SCROLL2BAR = 13 , /* 2nd vertical scrollbar*/
WWT_RESIZEBOX = 14 ,
WWT_CLOSEBOX = 15 ,
WWT_LAST = 16 , /* Last Item. use WIDGETS_END to fill up padding!! */
2004-08-09 17:04:08 +00:00
2006-08-22 14:38:37 +00:00
WWT_MASK = 31 ,
2004-08-09 17:04:08 +00:00
2006-08-28 18:53:03 +00:00
WWT_PUSHTXTBTN = WWT_TEXTBTN | WWB_PUSHBUTTON ,
WWT_PUSHIMGBTN = WWT_IMGBTN | WWB_PUSHBUTTON ,
WWT_NODISTXTBTN = WWT_TEXTBTN | WWB_NODISBUTTON ,
2004-08-09 17:04:08 +00:00
} ;
2005-01-03 19:45:18 +00:00
# define WIDGETS_END WWT_LAST, RESIZE_NONE, 0, 0, 0, 0, 0, 0, STR_NULL
2004-09-07 21:48:09 +00:00
2004-08-09 17:04:08 +00:00
enum WindowFlags {
2006-08-22 14:38:37 +00:00
WF_TIMEOUT_SHL = 0 ,
WF_TIMEOUT_MASK = 7 ,
WF_DRAGGING = 1 < < 3 ,
WF_SCROLL_UP = 1 < < 4 ,
WF_SCROLL_DOWN = 1 < < 5 ,
WF_SCROLL_MIDDLE = 1 < < 6 ,
WF_HSCROLL = 1 < < 7 ,
WF_SIZING = 1 < < 8 ,
WF_STICKY = 1 < < 9 ,
2005-01-03 19:45:18 +00:00
2004-08-09 17:04:08 +00:00
WF_DISABLE_VP_SCROLL = 1 < < 10 ,
2006-08-22 14:38:37 +00:00
WF_WHITE_BORDER_ONE = 1 < < 11 ,
2004-08-09 17:04:08 +00:00
WF_WHITE_BORDER_MASK = 3 < < 11 ,
2006-08-22 14:38:37 +00:00
WF_SCROLL2 = 1 < < 13 ,
2004-08-09 17:04:08 +00:00
} ;
/* window.c */
void CallWindowEventNP ( Window * w , int event ) ;
2005-01-22 20:23:18 +00:00
void CallWindowTickEvent ( void ) ;
2006-07-26 03:33:12 +00:00
void SetWindowDirty ( const Window * w ) ;
2005-04-05 21:03:30 +00:00
void SendWindowMessage ( WindowClass wnd_class , WindowNumber wnd_num , uint msg , uint wparam , uint lparam ) ;
2004-08-09 17:04:08 +00:00
Window * FindWindowById ( WindowClass cls , WindowNumber number ) ;
void DeleteWindow ( Window * w ) ;
Window * BringWindowToFrontById ( WindowClass cls , WindowNumber number ) ;
Window * FindWindowFromPt ( int x , int y ) ;
2006-07-26 03:33:12 +00:00
bool IsWindowOfPrototype ( const Window * w , const Widget * widget ) ;
2005-01-03 19:45:18 +00:00
void AssignWidgetToWindow ( Window * w , const Widget * widget ) ;
2004-08-09 17:04:08 +00:00
Window * AllocateWindow (
int x ,
int y ,
int width ,
int height ,
2004-09-05 14:20:36 +00:00
WindowProc * proc ,
2004-08-09 17:04:08 +00:00
WindowClass cls ,
const Widget * widget ) ;
Window * AllocateWindowDesc ( const WindowDesc * desc ) ;
Window * AllocateWindowDescFront ( const WindowDesc * desc , int value ) ;
void DrawWindowViewport ( Window * w ) ;
2005-01-22 20:23:18 +00:00
void InitWindowSystem ( void ) ;
2005-03-09 19:48:20 +00:00
void UnInitWindowSystem ( void ) ;
void ResetWindowSystem ( void ) ;
2005-09-18 20:56:44 +00:00
int GetMenuItemIndex ( const Window * w , int x , int y ) ;
2005-03-26 04:16:39 +00:00
void InputLoop ( void ) ;
2005-01-22 20:23:18 +00:00
void UpdateWindows ( void ) ;
2006-07-26 03:33:12 +00:00
void InvalidateWidget ( const Window * w , byte widget_index ) ;
2004-08-09 17:04:08 +00:00
2005-07-24 15:56:31 +00:00
void GuiShowTooltips ( StringID string_id ) ;
2004-08-09 17:04:08 +00:00
void UnclickWindowButtons ( Window * w ) ;
void UnclickSomeWindowButtons ( Window * w , uint32 mask ) ;
void RelocateAllWindows ( int neww , int newh ) ;
2004-11-13 18:15:03 +00:00
int PositionMainToolbar ( Window * w ) ;
2004-08-09 17:04:08 +00:00
/* widget.c */
2005-09-18 20:56:44 +00:00
int GetWidgetFromPos ( const Window * w , int x , int y ) ;
void DrawWindowWidgets ( const Window * w ) ;
2005-09-23 07:44:03 +00:00
void ShowDropDownMenu ( Window * w , const StringID * strings , int selected , int button , uint32 disabled_mask , uint32 hidden_mask ) ;
2004-08-09 17:04:08 +00:00
void HandleButtonClick ( Window * w , byte widget ) ;
2005-01-22 20:23:18 +00:00
Window * GetCallbackWnd ( void ) ;
void DeleteNonVitalWindows ( void ) ;
2004-12-22 17:37:21 +00:00
void DeleteAllNonVitalWindows ( void ) ;
2005-01-11 00:54:06 +00:00
void HideVitalWindows ( void ) ;
void ShowVitalWindows ( void ) ;
2004-08-09 17:04:08 +00:00
/* window.c */
2004-12-15 23:33:04 +00:00
VARDEF Window _windows [ 25 ] ;
2004-08-09 17:04:08 +00:00
VARDEF Window * _last_window ;
VARDEF Point _cursorpos_drag_start ;
VARDEF bool _left_button_down ;
VARDEF bool _left_button_clicked ;
VARDEF bool _right_button_down ;
VARDEF bool _right_button_clicked ;
VARDEF int _alloc_wnd_parent_num ;
VARDEF int _scrollbar_start_pos ;
VARDEF int _scrollbar_size ;
VARDEF byte _scroller_click_timeout ;
VARDEF bool _scrolling_scrollbar ;
VARDEF bool _scrolling_viewport ;
VARDEF bool _popup_menu_active ;
VARDEF byte _special_mouse_mode ;
enum SpecialMouseMode {
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
} ;
void ScrollbarClickHandler ( Window * w , const Widget * wi , int x , int y ) ;
# endif /* WINDOW_H */