src/window.h
author KUDr
Sat, 21 Apr 2007 08:23:57 +0000
branchcpp_gui
changeset 6308 646711c5feaa
parent 6307 f40e88cff863
permissions -rw-r--r--
(svn r9708) [cpp_gui] -Sync with trunk (r9633:9707)
2186
461a2aff3486 (svn r2701) Insert Id tags into all source files
tron
parents: 2159
diff changeset
     1
/* $Id$ */
461a2aff3486 (svn r2701) Insert Id tags into all source files
tron
parents: 2159
diff changeset
     2
6268
4b5241e5dd10 (svn r8938) [cpp_gui] -Sync with trunk (r8772..r8900)
bjarni
parents: 6267
diff changeset
     3
/** @file window.h regroups declarations for all windowing system, as well as a few helper functions */
4b5241e5dd10 (svn r8938) [cpp_gui] -Sync with trunk (r8772..r8900)
bjarni
parents: 6267
diff changeset
     4
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
     5
#ifndef WINDOW_H
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
     6
#define WINDOW_H
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
     7
6264
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents: 6263
diff changeset
     8
#include "widget/widget.h"
6297
4bf29d14edba (svn r9096) [cpp_gui] -Codechange: CompositeWidget now uses std::vector for child widgets instead of std::map
KUDr
parents: 6293
diff changeset
     9
#include <map>
4299
b86602eaaff1 (svn r5944) -Merge TGP (r5578, r5579, r5724, r5726): -Feature: filter for textboxes to only
truelight
parents: 4266
diff changeset
    10
6264
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents: 6263
diff changeset
    11
struct WindowEvent;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    12
6258
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents: 6256
diff changeset
    13
typedef void WindowProc(BaseWindow *w, WindowEvent *e);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    14
867
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 859
diff changeset
    15
/* How the resize system works:
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 859
diff changeset
    16
    First, you need to add a WWT_RESIZEBOX to the widgets, and you need
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 859
diff changeset
    17
     to add the flag WDF_RESIZABLE to the window. Now the window is ready
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 859
diff changeset
    18
     to resize itself.
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 859
diff changeset
    19
    As you may have noticed, all widgets have a RESIZE_XXX in their line.
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 859
diff changeset
    20
     This lines controls how the widgets behave on resize. RESIZE_NONE means
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 859
diff changeset
    21
     it doesn't do anything. Any other option let's one of the borders
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 859
diff changeset
    22
     move with the changed width/height. So if a widget has
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 859
diff changeset
    23
     RESIZE_RIGHT, and the window is made 5 pixels wider by the user,
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 859
diff changeset
    24
     the right of the window will also be made 5 pixels wider.
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 859
diff changeset
    25
    Now, what if you want to clamp a widget to the bottom? Give it the flag
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 859
diff changeset
    26
     RESIZE_TB. This is RESIZE_TOP + RESIZE_BOTTOM. Now if the window gets
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 859
diff changeset
    27
     5 pixels bigger, both the top and bottom gets 5 bigger, so the whole
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 859
diff changeset
    28
     widgets moves downwards without resizing, and appears to be clamped
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 859
diff changeset
    29
     to the bottom. Nice aint it?
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 859
diff changeset
    30
   You should know one more thing about this system. Most windows can't
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 859
diff changeset
    31
    handle an increase of 1 pixel. So there is a step function, which
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 859
diff changeset
    32
    let the windowsize only be changed by X pixels. You configure this
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 859
diff changeset
    33
    after making the window, like this:
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 859
diff changeset
    34
      w->resize.step_height = 10;
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 859
diff changeset
    35
    Now the window will only change in height in steps of 10.
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 859
diff changeset
    36
   You can also give a minimum width and height. The default value is
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 859
diff changeset
    37
    the default height/width of the window itself. You can change this
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 859
diff changeset
    38
    AFTER window-creation, with:
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 859
diff changeset
    39
     w->resize.width or w->resize.height.
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 859
diff changeset
    40
   That was all.. good luck, and enjoy :) -- TrueLight */
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 859
diff changeset
    41
6258
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents: 6256
diff changeset
    42
enum ResizeFlag {
6285
187e3ef04cc9 (svn r9004) [cpp_gui] -Sync with trunk (r8900..r9003)
KUDr
parents: 6284
diff changeset
    43
	RESIZE_NONE   = 0,  ///< no resize required
867
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 859
diff changeset
    44
6285
187e3ef04cc9 (svn r9004) [cpp_gui] -Sync with trunk (r8900..r9003)
KUDr
parents: 6284
diff changeset
    45
	RESIZE_LEFT   = 1,  ///< left resize flag
187e3ef04cc9 (svn r9004) [cpp_gui] -Sync with trunk (r8900..r9003)
KUDr
parents: 6284
diff changeset
    46
	RESIZE_RIGHT  = 2,  ///< rigth resize flag
187e3ef04cc9 (svn r9004) [cpp_gui] -Sync with trunk (r8900..r9003)
KUDr
parents: 6284
diff changeset
    47
	RESIZE_TOP    = 4,  ///< top resize flag
187e3ef04cc9 (svn r9004) [cpp_gui] -Sync with trunk (r8900..r9003)
KUDr
parents: 6284
diff changeset
    48
	RESIZE_BOTTOM = 8,  ///< bottom resize flag
867
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 859
diff changeset
    49
6285
187e3ef04cc9 (svn r9004) [cpp_gui] -Sync with trunk (r8900..r9003)
KUDr
parents: 6284
diff changeset
    50
	RESIZE_LR     = RESIZE_LEFT  | RESIZE_RIGHT,   ///<  combination of left and right resize flags
187e3ef04cc9 (svn r9004) [cpp_gui] -Sync with trunk (r8900..r9003)
KUDr
parents: 6284
diff changeset
    51
	RESIZE_RB     = RESIZE_RIGHT | RESIZE_BOTTOM,  ///<  combination of right and bottom resize flags
187e3ef04cc9 (svn r9004) [cpp_gui] -Sync with trunk (r8900..r9003)
KUDr
parents: 6284
diff changeset
    52
	RESIZE_TB     = RESIZE_TOP   | RESIZE_BOTTOM,  ///<  combination of top and bottom resize flags
187e3ef04cc9 (svn r9004) [cpp_gui] -Sync with trunk (r8900..r9003)
KUDr
parents: 6284
diff changeset
    53
	RESIZE_LRB    = RESIZE_LEFT  | RESIZE_RIGHT  | RESIZE_BOTTOM, ///< combination of left, right and bottom resize flags
187e3ef04cc9 (svn r9004) [cpp_gui] -Sync with trunk (r8900..r9003)
KUDr
parents: 6284
diff changeset
    54
	RESIZE_LRTB   = RESIZE_LEFT  | RESIZE_RIGHT  | RESIZE_TOP | RESIZE_BOTTOM,  ///<  combination of all resize flags
187e3ef04cc9 (svn r9004) [cpp_gui] -Sync with trunk (r8900..r9003)
KUDr
parents: 6284
diff changeset
    55
	RESIZE_RTB    = RESIZE_RIGHT | RESIZE_TOP    | RESIZE_BOTTOM, ///<  combination of right, top and bottom resize flag
4749
9490e643f23f (svn r6661) Feature: Windows are not restricted to 32 widget items anymore.
belugas
parents: 4739
diff changeset
    56
9490e643f23f (svn r6661) Feature: Windows are not restricted to 32 widget items anymore.
belugas
parents: 4739
diff changeset
    57
	/* The following flags are used by the system to specify what is disabled, hidden, or clicked
9490e643f23f (svn r6661) Feature: Windows are not restricted to 32 widget items anymore.
belugas
parents: 4739
diff changeset
    58
	 * They are used in the same place as the above RESIZE_x flags, Widget visual_flags.
9490e643f23f (svn r6661) Feature: Windows are not restricted to 32 widget items anymore.
belugas
parents: 4739
diff changeset
    59
	 * These states are used in exceptions. If nothing is specified, they will indicate
9490e643f23f (svn r6661) Feature: Windows are not restricted to 32 widget items anymore.
belugas
parents: 4739
diff changeset
    60
	 * Enabled, visible or unclicked widgets*/
6268
4b5241e5dd10 (svn r8938) [cpp_gui] -Sync with trunk (r8772..r8900)
bjarni
parents: 6267
diff changeset
    61
	WIDG_DISABLED = 4,  ///< widget is greyed out, not available
4b5241e5dd10 (svn r8938) [cpp_gui] -Sync with trunk (r8772..r8900)
bjarni
parents: 6267
diff changeset
    62
	WIDG_HIDDEN   = 5,  ///< widget is made invisible
4b5241e5dd10 (svn r8938) [cpp_gui] -Sync with trunk (r8772..r8900)
bjarni
parents: 6267
diff changeset
    63
	WIDG_LOWERED  = 6,  ///< widget is paint lowered, a pressed button in fact
6258
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents: 6256
diff changeset
    64
};
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents: 6256
diff changeset
    65
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents: 6256
diff changeset
    66
DECLARE_ENUM_AS_BIT_SET(ResizeFlag);
867
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 859
diff changeset
    67
6242
17609af8a1d1 (svn r8704) [cpp_gui] -Codechange: flash_timeout and autorepeat_timeout extracted from Window::flags4
KUDr
parents: 6241
diff changeset
    68
enum WindowFlags {
17609af8a1d1 (svn r8704) [cpp_gui] -Codechange: flash_timeout and autorepeat_timeout extracted from Window::flags4
KUDr
parents: 6241
diff changeset
    69
	//WF_TIMEOUT_SHL       = 0,
17609af8a1d1 (svn r8704) [cpp_gui] -Codechange: flash_timeout and autorepeat_timeout extracted from Window::flags4
KUDr
parents: 6241
diff changeset
    70
	//WF_TIMEOUT_MASK      = 7,
17609af8a1d1 (svn r8704) [cpp_gui] -Codechange: flash_timeout and autorepeat_timeout extracted from Window::flags4
KUDr
parents: 6241
diff changeset
    71
	WF_DRAGGING          = 1 <<  3,
17609af8a1d1 (svn r8704) [cpp_gui] -Codechange: flash_timeout and autorepeat_timeout extracted from Window::flags4
KUDr
parents: 6241
diff changeset
    72
	WF_SCROLL_UP         = 1 <<  4,
17609af8a1d1 (svn r8704) [cpp_gui] -Codechange: flash_timeout and autorepeat_timeout extracted from Window::flags4
KUDr
parents: 6241
diff changeset
    73
	WF_SCROLL_DOWN       = 1 <<  5,
17609af8a1d1 (svn r8704) [cpp_gui] -Codechange: flash_timeout and autorepeat_timeout extracted from Window::flags4
KUDr
parents: 6241
diff changeset
    74
	WF_SCROLL_MIDDLE     = 1 <<  6,
17609af8a1d1 (svn r8704) [cpp_gui] -Codechange: flash_timeout and autorepeat_timeout extracted from Window::flags4
KUDr
parents: 6241
diff changeset
    75
	WF_HSCROLL           = 1 <<  7,
17609af8a1d1 (svn r8704) [cpp_gui] -Codechange: flash_timeout and autorepeat_timeout extracted from Window::flags4
KUDr
parents: 6241
diff changeset
    76
	WF_SIZING            = 1 <<  8,
17609af8a1d1 (svn r8704) [cpp_gui] -Codechange: flash_timeout and autorepeat_timeout extracted from Window::flags4
KUDr
parents: 6241
diff changeset
    77
	WF_STICKY            = 1 <<  9,
17609af8a1d1 (svn r8704) [cpp_gui] -Codechange: flash_timeout and autorepeat_timeout extracted from Window::flags4
KUDr
parents: 6241
diff changeset
    78
17609af8a1d1 (svn r8704) [cpp_gui] -Codechange: flash_timeout and autorepeat_timeout extracted from Window::flags4
KUDr
parents: 6241
diff changeset
    79
	WF_DISABLE_VP_SCROLL = 1 << 10,
17609af8a1d1 (svn r8704) [cpp_gui] -Codechange: flash_timeout and autorepeat_timeout extracted from Window::flags4
KUDr
parents: 6241
diff changeset
    80
17609af8a1d1 (svn r8704) [cpp_gui] -Codechange: flash_timeout and autorepeat_timeout extracted from Window::flags4
KUDr
parents: 6241
diff changeset
    81
	//WF_WHITE_BORDER_ONE  = 1 << 11,
17609af8a1d1 (svn r8704) [cpp_gui] -Codechange: flash_timeout and autorepeat_timeout extracted from Window::flags4
KUDr
parents: 6241
diff changeset
    82
	//WF_WHITE_BORDER_MASK = 1 << 12 | WF_WHITE_BORDER_ONE,
17609af8a1d1 (svn r8704) [cpp_gui] -Codechange: flash_timeout and autorepeat_timeout extracted from Window::flags4
KUDr
parents: 6241
diff changeset
    83
	WF_SCROLL2           = 1 << 13,
17609af8a1d1 (svn r8704) [cpp_gui] -Codechange: flash_timeout and autorepeat_timeout extracted from Window::flags4
KUDr
parents: 6241
diff changeset
    84
};
17609af8a1d1 (svn r8704) [cpp_gui] -Codechange: flash_timeout and autorepeat_timeout extracted from Window::flags4
KUDr
parents: 6241
diff changeset
    85
17609af8a1d1 (svn r8704) [cpp_gui] -Codechange: flash_timeout and autorepeat_timeout extracted from Window::flags4
KUDr
parents: 6241
diff changeset
    86
DECLARE_ENUM_AS_BIT_SET(WindowFlags);
17609af8a1d1 (svn r8704) [cpp_gui] -Codechange: flash_timeout and autorepeat_timeout extracted from Window::flags4
KUDr
parents: 6241
diff changeset
    87
4755
4a3564952554 (svn r6669) -Add: vararg functions to set hidden/disabled/lowered state of multiple widgets in one call
glx
parents: 4749
diff changeset
    88
/* used to indicate the end of widgets' list for vararg functions */
4a3564952554 (svn r6669) -Add: vararg functions to set hidden/disabled/lowered state of multiple widgets in one call
glx
parents: 4749
diff changeset
    89
enum {
6285
187e3ef04cc9 (svn r9004) [cpp_gui] -Sync with trunk (r8900..r9003)
KUDr
parents: 6284
diff changeset
    90
	WIDGET_LIST_END = -1, ///< indicate the end of widgets' list for vararg functions
4755
4a3564952554 (svn r6669) -Add: vararg functions to set hidden/disabled/lowered state of multiple widgets in one call
glx
parents: 4749
diff changeset
    91
};
4a3564952554 (svn r6669) -Add: vararg functions to set hidden/disabled/lowered state of multiple widgets in one call
glx
parents: 4749
diff changeset
    92
6258
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents: 6256
diff changeset
    93
/****************** THESE ARE NOT WIDGET TYPES!!!!! *******************/
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents: 6256
diff changeset
    94
enum WindowWidgetBehaviours {
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents: 6256
diff changeset
    95
	WWB_PUSHBUTTON  = 1 << 5,
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents: 6256
diff changeset
    96
	WWB_MASK        = 0xE0,
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents: 6256
diff changeset
    97
};
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents: 6256
diff changeset
    98
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents: 6256
diff changeset
    99
enum WindowWidgetTypes {
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents: 6256
diff changeset
   100
	WWT_EMPTY,
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents: 6256
diff changeset
   101
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents: 6256
diff changeset
   102
	WWT_PANEL,      /* simple depressed panel */
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents: 6256
diff changeset
   103
	WWT_INSET,      /* pressed (inset) panel, most commonly used as combo box _text_ area */
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents: 6256
diff changeset
   104
	WWT_IMGBTN,     /* button with image */
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents: 6256
diff changeset
   105
	WWT_IMGBTN_2,   /* button with diff image when clicked */
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents: 6256
diff changeset
   106
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents: 6256
diff changeset
   107
	WWT_TEXTBTN,    /* button with text */
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents: 6256
diff changeset
   108
	WWT_TEXTBTN_2,  /* button with diff text when clicked */
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents: 6256
diff changeset
   109
	WWT_LABEL,      /* centered label */
6298
c30fe89622df (svn r9119) [cpp_gui] -Sync with trunk (r9003:9100)
bjarni
parents: 6297
diff changeset
   110
	WWT_TEXT,       /* pure simple text */
6258
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents: 6256
diff changeset
   111
	WWT_MATRIX,
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents: 6256
diff changeset
   112
	WWT_SCROLLBAR,
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents: 6256
diff changeset
   113
	WWT_FRAME,      /* frame */
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents: 6256
diff changeset
   114
	WWT_CAPTION,
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents: 6256
diff changeset
   115
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents: 6256
diff changeset
   116
	WWT_HSCROLLBAR,
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents: 6256
diff changeset
   117
	WWT_STICKYBOX,
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents: 6256
diff changeset
   118
	WWT_SCROLL2BAR, /* 2nd vertical scrollbar*/
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents: 6256
diff changeset
   119
	WWT_RESIZEBOX,
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents: 6256
diff changeset
   120
	WWT_CLOSEBOX,
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents: 6256
diff changeset
   121
	WWT_LAST,       /* Last Item. use WIDGETS_END to fill up padding!! */
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents: 6256
diff changeset
   122
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents: 6256
diff changeset
   123
	WWT_MASK = 0x1F,
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents: 6256
diff changeset
   124
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents: 6256
diff changeset
   125
	WWT_PUSHBTN     = WWT_PANEL   | WWB_PUSHBUTTON,
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents: 6256
diff changeset
   126
	WWT_PUSHTXTBTN  = WWT_TEXTBTN | WWB_PUSHBUTTON,
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents: 6256
diff changeset
   127
	WWT_PUSHIMGBTN  = WWT_IMGBTN  | WWB_PUSHBUTTON,
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents: 6256
diff changeset
   128
};
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents: 6256
diff changeset
   129
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents: 6256
diff changeset
   130
#define WIDGETS_END WWT_LAST,   RESIZE_NONE,     0,     0,     0,     0,     0, 0, STR_NULL
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents: 6256
diff changeset
   131
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents: 6256
diff changeset
   132
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents: 6256
diff changeset
   133
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents: 6256
diff changeset
   134
4437
d06bb548e48d (svn r6209) Move DrawFrameRect() out of gfx.[ch], because it uses data (_color_list) which the renderer shouldn't have know about
tron
parents: 4434
diff changeset
   135
void DrawFrameRect(int left, int top, int right, int bottom, int color, FrameFlags flags);
1938
21bd6ef5f85e (svn r2444) - CodeChange: Add an enum for demagicifying the values of the 'flags' parameter of DrawFrameRect(). (_Abraxa_)
hackykid
parents: 1648
diff changeset
   136
4634
897461a3e9ca (svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents: 4547
diff changeset
   137
enum WindowEventCodes {
5664
dbbf4f842a00 (svn r7616) -Cleanup:
Darkvater
parents: 5268
diff changeset
   138
	WE_CREATE,
dbbf4f842a00 (svn r7616) -Cleanup:
Darkvater
parents: 5268
diff changeset
   139
	WE_DESTROY,
dbbf4f842a00 (svn r7616) -Cleanup:
Darkvater
parents: 5268
diff changeset
   140
	WE_PAINT,
dbbf4f842a00 (svn r7616) -Cleanup:
Darkvater
parents: 5268
diff changeset
   141
	WE_KEYPRESS,
dbbf4f842a00 (svn r7616) -Cleanup:
Darkvater
parents: 5268
diff changeset
   142
	WE_CLICK,
dbbf4f842a00 (svn r7616) -Cleanup:
Darkvater
parents: 5268
diff changeset
   143
	WE_RCLICK,
dbbf4f842a00 (svn r7616) -Cleanup:
Darkvater
parents: 5268
diff changeset
   144
	WE_MOUSEOVER,
dbbf4f842a00 (svn r7616) -Cleanup:
Darkvater
parents: 5268
diff changeset
   145
	WE_MOUSELOOP,
dbbf4f842a00 (svn r7616) -Cleanup:
Darkvater
parents: 5268
diff changeset
   146
	WE_MOUSEWHEEL,
dbbf4f842a00 (svn r7616) -Cleanup:
Darkvater
parents: 5268
diff changeset
   147
	WE_TICK,
dbbf4f842a00 (svn r7616) -Cleanup:
Darkvater
parents: 5268
diff changeset
   148
	WE_4,
dbbf4f842a00 (svn r7616) -Cleanup:
Darkvater
parents: 5268
diff changeset
   149
	WE_TIMEOUT,
dbbf4f842a00 (svn r7616) -Cleanup:
Darkvater
parents: 5268
diff changeset
   150
	WE_PLACE_OBJ,
dbbf4f842a00 (svn r7616) -Cleanup:
Darkvater
parents: 5268
diff changeset
   151
	WE_ABORT_PLACE_OBJ,
dbbf4f842a00 (svn r7616) -Cleanup:
Darkvater
parents: 5268
diff changeset
   152
	WE_ON_EDIT_TEXT,
dbbf4f842a00 (svn r7616) -Cleanup:
Darkvater
parents: 5268
diff changeset
   153
	WE_ON_EDIT_TEXT_CANCEL,
dbbf4f842a00 (svn r7616) -Cleanup:
Darkvater
parents: 5268
diff changeset
   154
	WE_POPUPMENU_SELECT,
dbbf4f842a00 (svn r7616) -Cleanup:
Darkvater
parents: 5268
diff changeset
   155
	WE_POPUPMENU_OVER,
dbbf4f842a00 (svn r7616) -Cleanup:
Darkvater
parents: 5268
diff changeset
   156
	WE_DRAGDROP,
dbbf4f842a00 (svn r7616) -Cleanup:
Darkvater
parents: 5268
diff changeset
   157
	WE_PLACE_DRAG,
dbbf4f842a00 (svn r7616) -Cleanup:
Darkvater
parents: 5268
diff changeset
   158
	WE_PLACE_MOUSEUP,
dbbf4f842a00 (svn r7616) -Cleanup:
Darkvater
parents: 5268
diff changeset
   159
	WE_PLACE_PRESIZE,
dbbf4f842a00 (svn r7616) -Cleanup:
Darkvater
parents: 5268
diff changeset
   160
	WE_DROPDOWN_SELECT,
dbbf4f842a00 (svn r7616) -Cleanup:
Darkvater
parents: 5268
diff changeset
   161
	WE_RESIZE,
dbbf4f842a00 (svn r7616) -Cleanup:
Darkvater
parents: 5268
diff changeset
   162
	WE_MESSAGE,
dbbf4f842a00 (svn r7616) -Cleanup:
Darkvater
parents: 5268
diff changeset
   163
	WE_SCROLL,
dbbf4f842a00 (svn r7616) -Cleanup:
Darkvater
parents: 5268
diff changeset
   164
	WE_INVALIDATE_DATA,
4634
897461a3e9ca (svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents: 4547
diff changeset
   165
};
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   166
4634
897461a3e9ca (svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents: 4547
diff changeset
   167
struct WindowEvent {
897461a3e9ca (svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents: 4547
diff changeset
   168
	byte event;
897461a3e9ca (svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents: 4547
diff changeset
   169
	union {
897461a3e9ca (svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents: 4547
diff changeset
   170
		struct{
6259
0f36789984b1 (svn r8803) [cpp_gui] -Codechange: point structures (Point, Point16) made compatible
KUDr
parents: 6258
diff changeset
   171
			PointRaw pt;
4634
897461a3e9ca (svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents: 4547
diff changeset
   172
			int widget;
897461a3e9ca (svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents: 4547
diff changeset
   173
		} click;
543
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 424
diff changeset
   174
4634
897461a3e9ca (svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents: 4547
diff changeset
   175
		struct {
6259
0f36789984b1 (svn r8803) [cpp_gui] -Codechange: point structures (Point, Point16) made compatible
KUDr
parents: 6258
diff changeset
   176
			PointRaw pt;
4634
897461a3e9ca (svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents: 4547
diff changeset
   177
			TileIndex tile;
897461a3e9ca (svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents: 4547
diff changeset
   178
			TileIndex starttile;
897461a3e9ca (svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents: 4547
diff changeset
   179
			int userdata;
897461a3e9ca (svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents: 4547
diff changeset
   180
		} place;
1648
747061dca705 (svn r2152) - Fix: Chatbar in MP games is now on-top of the news window.
darkvater
parents: 1570
diff changeset
   181
4634
897461a3e9ca (svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents: 4547
diff changeset
   182
		struct {
6259
0f36789984b1 (svn r8803) [cpp_gui] -Codechange: point structures (Point, Point16) made compatible
KUDr
parents: 6258
diff changeset
   183
			PointRaw pt;
4634
897461a3e9ca (svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents: 4547
diff changeset
   184
			int widget;
897461a3e9ca (svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents: 4547
diff changeset
   185
		} dragdrop;
4335
18bc63352a17 (svn r6036) -Codechange: do not handle SCROLL in a central function, but let windows handle them theirself. Added WE_SCROLL for this.
truelight
parents: 4318
diff changeset
   186
4634
897461a3e9ca (svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents: 4547
diff changeset
   187
		struct {
6259
0f36789984b1 (svn r8803) [cpp_gui] -Codechange: point structures (Point, Point16) made compatible
KUDr
parents: 6258
diff changeset
   188
			PointRaw size;
0f36789984b1 (svn r8803) [cpp_gui] -Codechange: point structures (Point, Point16) made compatible
KUDr
parents: 6258
diff changeset
   189
			PointRaw diff;
4634
897461a3e9ca (svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents: 4547
diff changeset
   190
		} sizing;
4337
f77887bd2634 (svn r6038) -Codechange: move mousewheel code to event WE_MOUSEWHEEL instead of a general function that handles that
truelight
parents: 4335
diff changeset
   191
4634
897461a3e9ca (svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents: 4547
diff changeset
   192
		struct {
897461a3e9ca (svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents: 4547
diff changeset
   193
			char *str;
897461a3e9ca (svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents: 4547
diff changeset
   194
		} edittext;
897461a3e9ca (svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents: 4547
diff changeset
   195
897461a3e9ca (svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents: 4547
diff changeset
   196
		struct {
6259
0f36789984b1 (svn r8803) [cpp_gui] -Codechange: point structures (Point, Point16) made compatible
KUDr
parents: 6258
diff changeset
   197
			PointRaw pt;
4634
897461a3e9ca (svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents: 4547
diff changeset
   198
		} popupmenu;
897461a3e9ca (svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents: 4547
diff changeset
   199
897461a3e9ca (svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents: 4547
diff changeset
   200
		struct {
897461a3e9ca (svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents: 4547
diff changeset
   201
			int button;
897461a3e9ca (svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents: 4547
diff changeset
   202
			int index;
897461a3e9ca (svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents: 4547
diff changeset
   203
		} dropdown;
897461a3e9ca (svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents: 4547
diff changeset
   204
897461a3e9ca (svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents: 4547
diff changeset
   205
		struct {
6259
0f36789984b1 (svn r8803) [cpp_gui] -Codechange: point structures (Point, Point16) made compatible
KUDr
parents: 6258
diff changeset
   206
			PointRaw pt;
4634
897461a3e9ca (svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents: 4547
diff changeset
   207
			int widget;
897461a3e9ca (svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents: 4547
diff changeset
   208
		} mouseover;
897461a3e9ca (svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents: 4547
diff changeset
   209
897461a3e9ca (svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents: 4547
diff changeset
   210
		struct {
6268
4b5241e5dd10 (svn r8938) [cpp_gui] -Sync with trunk (r8772..r8900)
bjarni
parents: 6267
diff changeset
   211
			bool cont;      ///< continue the search? (default true)
4b5241e5dd10 (svn r8938) [cpp_gui] -Sync with trunk (r8772..r8900)
bjarni
parents: 6267
diff changeset
   212
			uint16 key;     ///< 16-bit Unicode value of the key
4b5241e5dd10 (svn r8938) [cpp_gui] -Sync with trunk (r8772..r8900)
bjarni
parents: 6267
diff changeset
   213
			uint16 keycode; ///< untranslated key (including shift-state)
4634
897461a3e9ca (svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents: 4547
diff changeset
   214
		} keypress;
897461a3e9ca (svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents: 4547
diff changeset
   215
897461a3e9ca (svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents: 4547
diff changeset
   216
		struct {
6268
4b5241e5dd10 (svn r8938) [cpp_gui] -Sync with trunk (r8772..r8900)
bjarni
parents: 6267
diff changeset
   217
			int msg;      ///< message to be sent
4b5241e5dd10 (svn r8938) [cpp_gui] -Sync with trunk (r8772..r8900)
bjarni
parents: 6267
diff changeset
   218
			int wparam;   ///< additional message-specific information
4b5241e5dd10 (svn r8938) [cpp_gui] -Sync with trunk (r8772..r8900)
bjarni
parents: 6267
diff changeset
   219
			int lparam;   ///< additional message-specific information
4634
897461a3e9ca (svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents: 4547
diff changeset
   220
		} message;
897461a3e9ca (svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents: 4547
diff changeset
   221
897461a3e9ca (svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents: 4547
diff changeset
   222
		struct {
6268
4b5241e5dd10 (svn r8938) [cpp_gui] -Sync with trunk (r8772..r8900)
bjarni
parents: 6267
diff changeset
   223
			PointRaw delta;   ///< delta position against position of last call
4634
897461a3e9ca (svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents: 4547
diff changeset
   224
		} scroll;
897461a3e9ca (svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents: 4547
diff changeset
   225
897461a3e9ca (svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents: 4547
diff changeset
   226
		struct {
6268
4b5241e5dd10 (svn r8938) [cpp_gui] -Sync with trunk (r8772..r8900)
bjarni
parents: 6267
diff changeset
   227
			int wheel;     ///< how much was 'wheel'd'
4634
897461a3e9ca (svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents: 4547
diff changeset
   228
		} wheel;
897461a3e9ca (svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents: 4547
diff changeset
   229
	} we;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   230
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   231
6258
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents: 6256
diff changeset
   232
struct OldWidget;
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents: 6256
diff changeset
   233
6298
c30fe89622df (svn r9119) [cpp_gui] -Sync with trunk (r9003:9100)
bjarni
parents: 6297
diff changeset
   234
struct WindowDesc {
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   235
	int16 left, top, width, height;
2788
db2896482939 (svn r3336) byte -> WindowClass, uint16 -> WindowNumber
tron
parents: 2757
diff changeset
   236
	WindowClass cls;
db2896482939 (svn r3336) byte -> WindowClass, uint16 -> WindowNumber
tron
parents: 2757
diff changeset
   237
	WindowClass parent_cls;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   238
	uint32 flags;
6258
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents: 6256
diff changeset
   239
	const OldWidget *widgets;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   240
	WindowProc *proc;
6298
c30fe89622df (svn r9119) [cpp_gui] -Sync with trunk (r9003:9100)
bjarni
parents: 6297
diff changeset
   241
};
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   242
5664
dbbf4f842a00 (svn r7616) -Cleanup:
Darkvater
parents: 5268
diff changeset
   243
enum WindowDefaultFlag {
6268
4b5241e5dd10 (svn r8938) [cpp_gui] -Sync with trunk (r8772..r8900)
bjarni
parents: 6267
diff changeset
   244
	WDF_STD_TOOLTIPS    =   1, ///< use standard routine when displaying tooltips
4b5241e5dd10 (svn r8938) [cpp_gui] -Sync with trunk (r8772..r8900)
bjarni
parents: 6267
diff changeset
   245
	WDF_DEF_WIDGET      =   2, ///< default widget control for some widgets in the on click event
4b5241e5dd10 (svn r8938) [cpp_gui] -Sync with trunk (r8772..r8900)
bjarni
parents: 6267
diff changeset
   246
	WDF_STD_BTN         =   4, ///< default handling for close and drag widgets (widget no 0 and 1)
2064
c889fcc76398 (svn r2573) Codechange: Removed WDF_RESTORE_DPARAM, it's not needed with the new string system.
ludde
parents: 2021
diff changeset
   247
6268
4b5241e5dd10 (svn r8938) [cpp_gui] -Sync with trunk (r8772..r8900)
bjarni
parents: 6267
diff changeset
   248
	WDF_UNCLICK_BUTTONS =  16, ///< Unclick buttons when the window event times out */
4b5241e5dd10 (svn r8938) [cpp_gui] -Sync with trunk (r8772..r8900)
bjarni
parents: 6267
diff changeset
   249
	WDF_STICKY_BUTTON   =  32, ///< Set window to sticky mode; they are not closed unless closed with 'X' (widget 2)
4b5241e5dd10 (svn r8938) [cpp_gui] -Sync with trunk (r8772..r8900)
bjarni
parents: 6267
diff changeset
   250
	WDF_RESIZABLE       =  64, ///< A window can be resized
4b5241e5dd10 (svn r8938) [cpp_gui] -Sync with trunk (r8772..r8900)
bjarni
parents: 6267
diff changeset
   251
	WDF_MODAL           = 128, ///< The window is a modal child of some other window, meaning the parent is 'inactive'
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   252
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   253
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   254
/* can be used as x or y coordinates to cause a specific placement */
5664
dbbf4f842a00 (svn r7616) -Cleanup:
Darkvater
parents: 5268
diff changeset
   255
enum WindowDefaultPosition {
5072
df5bde83a4bc (svn r7130) -Codechange: Handle the positioning of windows through the desc->left/top settings with
Darkvater
parents: 5071
diff changeset
   256
	WDP_AUTO      = -1, ///< Find a place automatically
df5bde83a4bc (svn r7130) -Codechange: Handle the positioning of windows through the desc->left/top settings with
Darkvater
parents: 5071
diff changeset
   257
	WDP_CENTER    = -2, ///< Center the window (left/right or top/bottom)
df5bde83a4bc (svn r7130) -Codechange: Handle the positioning of windows through the desc->left/top settings with
Darkvater
parents: 5071
diff changeset
   258
	WDP_ALIGN_TBR = -3, ///< Align the right side of the window with the right side of the main toolbar
df5bde83a4bc (svn r7130) -Codechange: Handle the positioning of windows through the desc->left/top settings with
Darkvater
parents: 5071
diff changeset
   259
	WDP_ALIGN_TBL = -4, ///< Align the left side of the window with the left side of the main toolbar
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   260
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   261
6298
c30fe89622df (svn r9119) [cpp_gui] -Sync with trunk (r9003:9100)
bjarni
parents: 6297
diff changeset
   262
struct Textbuf {
6268
4b5241e5dd10 (svn r8938) [cpp_gui] -Sync with trunk (r8772..r8900)
bjarni
parents: 6267
diff changeset
   263
	char *buf;                  ///< buffer in which text is saved
4b5241e5dd10 (svn r8938) [cpp_gui] -Sync with trunk (r8772..r8900)
bjarni
parents: 6267
diff changeset
   264
	uint16 maxlength, maxwidth; ///< the maximum size of the buffer. Maxwidth specifies screensize in pixels, maxlength is in bytes
4b5241e5dd10 (svn r8938) [cpp_gui] -Sync with trunk (r8772..r8900)
bjarni
parents: 6267
diff changeset
   265
	uint16 length, width;       ///< the current size of the string. Width specifies screensize in pixels, length is in bytes
4b5241e5dd10 (svn r8938) [cpp_gui] -Sync with trunk (r8772..r8900)
bjarni
parents: 6267
diff changeset
   266
	bool caret;                 ///< is the caret ("_") visible or not
4b5241e5dd10 (svn r8938) [cpp_gui] -Sync with trunk (r8772..r8900)
bjarni
parents: 6267
diff changeset
   267
	uint16 caretpos;            ///< the current position of the caret in the buffer, in bytes
4b5241e5dd10 (svn r8938) [cpp_gui] -Sync with trunk (r8772..r8900)
bjarni
parents: 6267
diff changeset
   268
	uint16 caretxoffs;          ///< the current position of the caret in pixels
6298
c30fe89622df (svn r9119) [cpp_gui] -Sync with trunk (r9003:9100)
bjarni
parents: 6297
diff changeset
   269
};
1390
53a5713cf3f9 (svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents: 1386
diff changeset
   270
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   271
#define WP(ptr,str) (*(str*)(ptr)->custom)
2906
18fa7bda750f (svn r3461) - Fix: Increase window-size as for 64-bit machines it wasn't enough
Darkvater
parents: 2888
diff changeset
   272
/* You cannot 100% reliably calculate the biggest custom struct as
18fa7bda750f (svn r3461) - Fix: Increase window-size as for 64-bit machines it wasn't enough
Darkvater
parents: 2888
diff changeset
   273
 * the number of pointers in it and alignment will have a huge impact.
4299
b86602eaaff1 (svn r5944) -Merge TGP (r5578, r5579, r5724, r5726): -Feature: filter for textboxes to only
truelight
parents: 4266
diff changeset
   274
 * 96 is the largest window-size for 64-bit machines currently */
b86602eaaff1 (svn r5944) -Merge TGP (r5578, r5579, r5724, r5726): -Feature: filter for textboxes to only
truelight
parents: 4266
diff changeset
   275
#define WINDOW_CUSTOM_SIZE 96
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   276
6298
c30fe89622df (svn r9119) [cpp_gui] -Sync with trunk (r9003:9100)
bjarni
parents: 6297
diff changeset
   277
struct Scrollbar {
62
2bdd81b8adcc (svn r63) Fix: [ 1009385 ] Too many save games prevented loading
dominik
parents: 0
diff changeset
   278
	uint16 count, cap, pos;
6298
c30fe89622df (svn r9119) [cpp_gui] -Sync with trunk (r9003:9100)
bjarni
parents: 6297
diff changeset
   279
};
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   280
6298
c30fe89622df (svn r9119) [cpp_gui] -Sync with trunk (r9003:9100)
bjarni
parents: 6297
diff changeset
   281
struct ResizeInfo {
6268
4b5241e5dd10 (svn r8938) [cpp_gui] -Sync with trunk (r8772..r8900)
bjarni
parents: 6267
diff changeset
   282
	uint width; ///< Minimum width and height
867
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 859
diff changeset
   283
	uint height;
6268
4b5241e5dd10 (svn r8938) [cpp_gui] -Sync with trunk (r8772..r8900)
bjarni
parents: 6267
diff changeset
   284
	uint step_width; ///< In how big steps the width and height go
867
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 859
diff changeset
   285
	uint step_height;
6298
c30fe89622df (svn r9119) [cpp_gui] -Sync with trunk (r9003:9100)
bjarni
parents: 6297
diff changeset
   286
};
867
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 859
diff changeset
   287
6298
c30fe89622df (svn r9119) [cpp_gui] -Sync with trunk (r9003:9100)
bjarni
parents: 6297
diff changeset
   288
struct WindowMessage {
c30fe89622df (svn r9119) [cpp_gui] -Sync with trunk (r9003:9100)
bjarni
parents: 6297
diff changeset
   289
	int msg;
c30fe89622df (svn r9119) [cpp_gui] -Sync with trunk (r9003:9100)
bjarni
parents: 6297
diff changeset
   290
	int wparam;
c30fe89622df (svn r9119) [cpp_gui] -Sync with trunk (r9003:9100)
bjarni
parents: 6297
diff changeset
   291
	int lparam;
c30fe89622df (svn r9119) [cpp_gui] -Sync with trunk (r9003:9100)
bjarni
parents: 6297
diff changeset
   292
};
1648
747061dca705 (svn r2152) - Fix: Chatbar in MP games is now on-top of the news window.
darkvater
parents: 1570
diff changeset
   293
6258
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents: 6256
diff changeset
   294
struct OldWidget {
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents: 6256
diff changeset
   295
	WindowWidgetTypes type;           ///< OldWidget type, see @WindowWidgetTypes
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents: 6256
diff changeset
   296
	byte m_display_flags;             ///< Resize direction, alignment, etc. during resizing, see @ResizeFlags
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents: 6256
diff changeset
   297
	byte color;                       ///< OldWidget colour, see docs/ottd-colourtext-palette.png
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents: 6256
diff changeset
   298
	int16 left, right, top, bottom;   ///< The position offsets inside the window
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents: 6256
diff changeset
   299
	uint16 data;                      ///< The String/Image or special code (list-matrixes) of a widget
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents: 6256
diff changeset
   300
	StringID tooltips;                ///< Tooltips that are shown when rightclicking on a widget
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents: 6256
diff changeset
   301
};
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents: 6256
diff changeset
   302
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents: 6256
diff changeset
   303
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents: 6256
diff changeset
   304
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents: 6256
diff changeset
   305
struct BaseWindow;
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents: 6256
diff changeset
   306
typedef CCountedPtr<BaseWindow> WindowPtr;
6235
5077e6ed3788 (svn r8683) [cpp_gui] -Codechange: first steps towards OO GUI (together with Bjarni) without changes in the logic
KUDr
parents: 6224
diff changeset
   307
5077e6ed3788 (svn r8683) [cpp_gui] -Codechange: first steps towards OO GUI (together with Bjarni) without changes in the logic
KUDr
parents: 6224
diff changeset
   308
struct WindowList {
5077e6ed3788 (svn r8683) [cpp_gui] -Codechange: first steps towards OO GUI (together with Bjarni) without changes in the logic
KUDr
parents: 6224
diff changeset
   309
	struct Item {
5077e6ed3788 (svn r8683) [cpp_gui] -Codechange: first steps towards OO GUI (together with Bjarni) without changes in the logic
KUDr
parents: 6224
diff changeset
   310
		WindowPtr w;
6258
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents: 6256
diff changeset
   311
		Item(BaseWindow *v = NULL) : w(v) {}
6235
5077e6ed3788 (svn r8683) [cpp_gui] -Codechange: first steps towards OO GUI (together with Bjarni) without changes in the logic
KUDr
parents: 6224
diff changeset
   312
		Item(const Item &src) : w(src.w) {}
5077e6ed3788 (svn r8683) [cpp_gui] -Codechange: first steps towards OO GUI (together with Bjarni) without changes in the logic
KUDr
parents: 6224
diff changeset
   313
		~Item()
5077e6ed3788 (svn r8683) [cpp_gui] -Codechange: first steps towards OO GUI (together with Bjarni) without changes in the logic
KUDr
parents: 6224
diff changeset
   314
		{}
5077e6ed3788 (svn r8683) [cpp_gui] -Codechange: first steps towards OO GUI (together with Bjarni) without changes in the logic
KUDr
parents: 6224
diff changeset
   315
	};
5077e6ed3788 (svn r8683) [cpp_gui] -Codechange: first steps towards OO GUI (together with Bjarni) without changes in the logic
KUDr
parents: 6224
diff changeset
   316
	typedef std::list<Item> List;
5077e6ed3788 (svn r8683) [cpp_gui] -Codechange: first steps towards OO GUI (together with Bjarni) without changes in the logic
KUDr
parents: 6224
diff changeset
   317
	typedef List::iterator Iterator;
5077e6ed3788 (svn r8683) [cpp_gui] -Codechange: first steps towards OO GUI (together with Bjarni) without changes in the logic
KUDr
parents: 6224
diff changeset
   318
	typedef List::reverse_iterator ReverseIterator;
5077e6ed3788 (svn r8683) [cpp_gui] -Codechange: first steps towards OO GUI (together with Bjarni) without changes in the logic
KUDr
parents: 6224
diff changeset
   319
5077e6ed3788 (svn r8683) [cpp_gui] -Codechange: first steps towards OO GUI (together with Bjarni) without changes in the logic
KUDr
parents: 6224
diff changeset
   320
	List m_list;
5077e6ed3788 (svn r8683) [cpp_gui] -Codechange: first steps towards OO GUI (together with Bjarni) without changes in the logic
KUDr
parents: 6224
diff changeset
   321
6258
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents: 6256
diff changeset
   322
	void Add(BaseWindow *w);
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents: 6256
diff changeset
   323
	void Remove(BaseWindow *w);
6264
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents: 6263
diff changeset
   324
	void CloseAll();
6258
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents: 6256
diff changeset
   325
	Iterator Find(BaseWindow *w);
6235
5077e6ed3788 (svn r8683) [cpp_gui] -Codechange: first steps towards OO GUI (together with Bjarni) without changes in the logic
KUDr
parents: 6224
diff changeset
   326
	Iterator FindFirstVitalWindow();
5077e6ed3788 (svn r8683) [cpp_gui] -Codechange: first steps towards OO GUI (together with Bjarni) without changes in the logic
KUDr
parents: 6224
diff changeset
   327
	Iterator FindByClass(WindowClass cls);
5077e6ed3788 (svn r8683) [cpp_gui] -Codechange: first steps towards OO GUI (together with Bjarni) without changes in the logic
KUDr
parents: 6224
diff changeset
   328
	Iterator FindById(WindowClass cls, WindowNumber num);
6258
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents: 6256
diff changeset
   329
	Iterator FindFromPt(int x, int y);
6235
5077e6ed3788 (svn r8683) [cpp_gui] -Codechange: first steps towards OO GUI (together with Bjarni) without changes in the logic
KUDr
parents: 6224
diff changeset
   330
6236
ec056d324811 (svn r8693) [cpp_gui] -Fix: g++ compilation errors 'non-local function A uses local type B' (template arguments must have external linkage while local type has no linkage)
KUDr
parents: 6235
diff changeset
   331
	Iterator EnumT(bool (*enum_proc)(Iterator))
6235
5077e6ed3788 (svn r8683) [cpp_gui] -Codechange: first steps towards OO GUI (together with Bjarni) without changes in the logic
KUDr
parents: 6224
diff changeset
   332
	{
5077e6ed3788 (svn r8683) [cpp_gui] -Codechange: first steps towards OO GUI (together with Bjarni) without changes in the logic
KUDr
parents: 6224
diff changeset
   333
		for (Iterator it = m_list.begin(); it != m_list.end(); ++it) {
6236
ec056d324811 (svn r8693) [cpp_gui] -Fix: g++ compilation errors 'non-local function A uses local type B' (template arguments must have external linkage while local type has no linkage)
KUDr
parents: 6235
diff changeset
   334
			if (enum_proc(it)) return it;
6235
5077e6ed3788 (svn r8683) [cpp_gui] -Codechange: first steps towards OO GUI (together with Bjarni) without changes in the logic
KUDr
parents: 6224
diff changeset
   335
		}
5077e6ed3788 (svn r8683) [cpp_gui] -Codechange: first steps towards OO GUI (together with Bjarni) without changes in the logic
KUDr
parents: 6224
diff changeset
   336
		return m_list.end();
5077e6ed3788 (svn r8683) [cpp_gui] -Codechange: first steps towards OO GUI (together with Bjarni) without changes in the logic
KUDr
parents: 6224
diff changeset
   337
	}
5077e6ed3788 (svn r8683) [cpp_gui] -Codechange: first steps towards OO GUI (together with Bjarni) without changes in the logic
KUDr
parents: 6224
diff changeset
   338
6236
ec056d324811 (svn r8693) [cpp_gui] -Fix: g++ compilation errors 'non-local function A uses local type B' (template arguments must have external linkage while local type has no linkage)
KUDr
parents: 6235
diff changeset
   339
	template <class Tmatch_1> Iterator EnumT(bool (*enum_proc)(Iterator, Tmatch_1), Tmatch_1 match)
ec056d324811 (svn r8693) [cpp_gui] -Fix: g++ compilation errors 'non-local function A uses local type B' (template arguments must have external linkage while local type has no linkage)
KUDr
parents: 6235
diff changeset
   340
	{
ec056d324811 (svn r8693) [cpp_gui] -Fix: g++ compilation errors 'non-local function A uses local type B' (template arguments must have external linkage while local type has no linkage)
KUDr
parents: 6235
diff changeset
   341
		for (Iterator it = m_list.begin(); it != m_list.end(); ++it) {
ec056d324811 (svn r8693) [cpp_gui] -Fix: g++ compilation errors 'non-local function A uses local type B' (template arguments must have external linkage while local type has no linkage)
KUDr
parents: 6235
diff changeset
   342
			if (enum_proc(it, match)) return it;
ec056d324811 (svn r8693) [cpp_gui] -Fix: g++ compilation errors 'non-local function A uses local type B' (template arguments must have external linkage while local type has no linkage)
KUDr
parents: 6235
diff changeset
   343
		}
ec056d324811 (svn r8693) [cpp_gui] -Fix: g++ compilation errors 'non-local function A uses local type B' (template arguments must have external linkage while local type has no linkage)
KUDr
parents: 6235
diff changeset
   344
		return m_list.end();
ec056d324811 (svn r8693) [cpp_gui] -Fix: g++ compilation errors 'non-local function A uses local type B' (template arguments must have external linkage while local type has no linkage)
KUDr
parents: 6235
diff changeset
   345
	}
ec056d324811 (svn r8693) [cpp_gui] -Fix: g++ compilation errors 'non-local function A uses local type B' (template arguments must have external linkage while local type has no linkage)
KUDr
parents: 6235
diff changeset
   346
ec056d324811 (svn r8693) [cpp_gui] -Fix: g++ compilation errors 'non-local function A uses local type B' (template arguments must have external linkage while local type has no linkage)
KUDr
parents: 6235
diff changeset
   347
	template <class Tmatch_1, class Tmatch_2> Iterator EnumT(bool (*enum_proc)(Iterator, Tmatch_1, Tmatch_2), Tmatch_1 match_1, Tmatch_2 match_2)
ec056d324811 (svn r8693) [cpp_gui] -Fix: g++ compilation errors 'non-local function A uses local type B' (template arguments must have external linkage while local type has no linkage)
KUDr
parents: 6235
diff changeset
   348
	{
ec056d324811 (svn r8693) [cpp_gui] -Fix: g++ compilation errors 'non-local function A uses local type B' (template arguments must have external linkage while local type has no linkage)
KUDr
parents: 6235
diff changeset
   349
		for (Iterator it = m_list.begin(); it != m_list.end(); ++it) {
ec056d324811 (svn r8693) [cpp_gui] -Fix: g++ compilation errors 'non-local function A uses local type B' (template arguments must have external linkage while local type has no linkage)
KUDr
parents: 6235
diff changeset
   350
			if (enum_proc(it, match_1, match_2)) return it;
ec056d324811 (svn r8693) [cpp_gui] -Fix: g++ compilation errors 'non-local function A uses local type B' (template arguments must have external linkage while local type has no linkage)
KUDr
parents: 6235
diff changeset
   351
		}
ec056d324811 (svn r8693) [cpp_gui] -Fix: g++ compilation errors 'non-local function A uses local type B' (template arguments must have external linkage while local type has no linkage)
KUDr
parents: 6235
diff changeset
   352
		return m_list.end();
ec056d324811 (svn r8693) [cpp_gui] -Fix: g++ compilation errors 'non-local function A uses local type B' (template arguments must have external linkage while local type has no linkage)
KUDr
parents: 6235
diff changeset
   353
	}
ec056d324811 (svn r8693) [cpp_gui] -Fix: g++ compilation errors 'non-local function A uses local type B' (template arguments must have external linkage while local type has no linkage)
KUDr
parents: 6235
diff changeset
   354
ec056d324811 (svn r8693) [cpp_gui] -Fix: g++ compilation errors 'non-local function A uses local type B' (template arguments must have external linkage while local type has no linkage)
KUDr
parents: 6235
diff changeset
   355
	Iterator ReverseEnumT(bool (*enum_proc)(Iterator))
6235
5077e6ed3788 (svn r8683) [cpp_gui] -Codechange: first steps towards OO GUI (together with Bjarni) without changes in the logic
KUDr
parents: 6224
diff changeset
   356
	{
5077e6ed3788 (svn r8683) [cpp_gui] -Codechange: first steps towards OO GUI (together with Bjarni) without changes in the logic
KUDr
parents: 6224
diff changeset
   357
		for (Iterator it = m_list.end(); it != m_list.begin(); ) {
5077e6ed3788 (svn r8683) [cpp_gui] -Codechange: first steps towards OO GUI (together with Bjarni) without changes in the logic
KUDr
parents: 6224
diff changeset
   358
			--it;
6236
ec056d324811 (svn r8693) [cpp_gui] -Fix: g++ compilation errors 'non-local function A uses local type B' (template arguments must have external linkage while local type has no linkage)
KUDr
parents: 6235
diff changeset
   359
			if (enum_proc(it)) return it;
ec056d324811 (svn r8693) [cpp_gui] -Fix: g++ compilation errors 'non-local function A uses local type B' (template arguments must have external linkage while local type has no linkage)
KUDr
parents: 6235
diff changeset
   360
		}
ec056d324811 (svn r8693) [cpp_gui] -Fix: g++ compilation errors 'non-local function A uses local type B' (template arguments must have external linkage while local type has no linkage)
KUDr
parents: 6235
diff changeset
   361
		return m_list.end();
ec056d324811 (svn r8693) [cpp_gui] -Fix: g++ compilation errors 'non-local function A uses local type B' (template arguments must have external linkage while local type has no linkage)
KUDr
parents: 6235
diff changeset
   362
	}
ec056d324811 (svn r8693) [cpp_gui] -Fix: g++ compilation errors 'non-local function A uses local type B' (template arguments must have external linkage while local type has no linkage)
KUDr
parents: 6235
diff changeset
   363
ec056d324811 (svn r8693) [cpp_gui] -Fix: g++ compilation errors 'non-local function A uses local type B' (template arguments must have external linkage while local type has no linkage)
KUDr
parents: 6235
diff changeset
   364
	template <class Tmatch_1> Iterator ReverseEnumT(bool (*enum_proc)(Iterator, Tmatch_1), Tmatch_1 match)
ec056d324811 (svn r8693) [cpp_gui] -Fix: g++ compilation errors 'non-local function A uses local type B' (template arguments must have external linkage while local type has no linkage)
KUDr
parents: 6235
diff changeset
   365
	{
ec056d324811 (svn r8693) [cpp_gui] -Fix: g++ compilation errors 'non-local function A uses local type B' (template arguments must have external linkage while local type has no linkage)
KUDr
parents: 6235
diff changeset
   366
		for (Iterator it = m_list.end(); it != m_list.begin(); ) {
ec056d324811 (svn r8693) [cpp_gui] -Fix: g++ compilation errors 'non-local function A uses local type B' (template arguments must have external linkage while local type has no linkage)
KUDr
parents: 6235
diff changeset
   367
			--it;
ec056d324811 (svn r8693) [cpp_gui] -Fix: g++ compilation errors 'non-local function A uses local type B' (template arguments must have external linkage while local type has no linkage)
KUDr
parents: 6235
diff changeset
   368
			if (enum_proc(it, match)) return it;
6235
5077e6ed3788 (svn r8683) [cpp_gui] -Codechange: first steps towards OO GUI (together with Bjarni) without changes in the logic
KUDr
parents: 6224
diff changeset
   369
		}
5077e6ed3788 (svn r8683) [cpp_gui] -Codechange: first steps towards OO GUI (together with Bjarni) without changes in the logic
KUDr
parents: 6224
diff changeset
   370
		return m_list.end();
5077e6ed3788 (svn r8683) [cpp_gui] -Codechange: first steps towards OO GUI (together with Bjarni) without changes in the logic
KUDr
parents: 6224
diff changeset
   371
	}
6258
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents: 6256
diff changeset
   372
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents: 6256
diff changeset
   373
	template <class Tmatch_1, class Tmatch_2> Iterator ReverseEnumT(bool (*enum_proc)(Iterator, Tmatch_1, Tmatch_2), Tmatch_1 match_1, Tmatch_2 match_2)
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents: 6256
diff changeset
   374
	{
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents: 6256
diff changeset
   375
		for (Iterator it = m_list.end(); it != m_list.begin(); ) {
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents: 6256
diff changeset
   376
			--it;
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents: 6256
diff changeset
   377
			if (enum_proc(it, match_1, match_2)) return it;
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents: 6256
diff changeset
   378
		}
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents: 6256
diff changeset
   379
		return m_list.end();
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents: 6256
diff changeset
   380
	}
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents: 6256
diff changeset
   381
6235
5077e6ed3788 (svn r8683) [cpp_gui] -Codechange: first steps towards OO GUI (together with Bjarni) without changes in the logic
KUDr
parents: 6224
diff changeset
   382
};
5077e6ed3788 (svn r8683) [cpp_gui] -Codechange: first steps towards OO GUI (together with Bjarni) without changes in the logic
KUDr
parents: 6224
diff changeset
   383
6301
e0251f797d59 (svn r9484) [cpp_gui] -Add: Auto layout/resize ability of widgets.
KUDr
parents: 6298
diff changeset
   384
struct BaseWindow : public gui::Panel {
6245
6fa82c6ee8ca (svn r8711) [cpp_gui] -Codechange: even more funktion->method conversions
bjarni
parents: 6244
diff changeset
   385
public:
6301
e0251f797d59 (svn r9484) [cpp_gui] -Add: Auto layout/resize ability of widgets.
KUDr
parents: 6298
diff changeset
   386
	typedef gui::Panel super;
6263
19dab6a68886 (svn r8913) [cpp_gui] -Codechange: use BaseWindow accessors instead of accessing window size/position directly
KUDr
parents: 6261
diff changeset
   387
6235
5077e6ed3788 (svn r8683) [cpp_gui] -Codechange: first steps towards OO GUI (together with Bjarni) without changes in the logic
KUDr
parents: 6224
diff changeset
   388
	static WindowList s_list;
5077e6ed3788 (svn r8683) [cpp_gui] -Codechange: first steps towards OO GUI (together with Bjarni) without changes in the logic
KUDr
parents: 6224
diff changeset
   389
6261
5fd6b1cfa424 (svn r8815) [cpp_gui] -Codechange: Added ZeroInitBegin and ZeroInitEnd helper structures
KUDr
parents: 6260
diff changeset
   390
	ZeroInitBegin m_zero_init_area; ///< following members get cleared by constructor
5fd6b1cfa424 (svn r8815) [cpp_gui] -Codechange: Added ZeroInitBegin and ZeroInitEnd helper structures
KUDr
parents: 6260
diff changeset
   391
6242
17609af8a1d1 (svn r8704) [cpp_gui] -Codechange: flash_timeout and autorepeat_timeout extracted from Window::flags4
KUDr
parents: 6241
diff changeset
   392
	WindowFlags flags4;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   393
	WindowClass window_class;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   394
	WindowNumber window_number;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   395
6263
19dab6a68886 (svn r8913) [cpp_gui] -Codechange: use BaseWindow accessors instead of accessing window size/position directly
KUDr
parents: 6261
diff changeset
   396
protected:
6283
7072ee68c676 (svn r8997) [cpp_gui] -Codechange: common window features are now controlled by FeatureFlags enum.
KUDr
parents: 6279
diff changeset
   397
	Point16    m_wnd_pos;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   398
6263
19dab6a68886 (svn r8913) [cpp_gui] -Codechange: use BaseWindow accessors instead of accessing window size/position directly
KUDr
parents: 6261
diff changeset
   399
public:
6283
7072ee68c676 (svn r8997) [cpp_gui] -Codechange: common window features are now controlled by FeatureFlags enum.
KUDr
parents: 6279
diff changeset
   400
	StringID   m_caption_text;
7072ee68c676 (svn r8997) [cpp_gui] -Codechange: common window features are now controlled by FeatureFlags enum.
KUDr
parents: 6279
diff changeset
   401
842
ebfd36603ab9 (svn r1323) Adding autoreplace feature
bjarni
parents: 826
diff changeset
   402
	Scrollbar hscroll, vscroll, vscroll2;
867
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 859
diff changeset
   403
	ResizeInfo resize;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   404
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   405
	byte caption_color;
6242
17609af8a1d1 (svn r8704) [cpp_gui] -Codechange: flash_timeout and autorepeat_timeout extracted from Window::flags4
KUDr
parents: 6241
diff changeset
   406
	byte autorepeat_timeout; ///< timer for scroll (spin) click autorepeat
17609af8a1d1 (svn r8704) [cpp_gui] -Codechange: flash_timeout and autorepeat_timeout extracted from Window::flags4
KUDr
parents: 6241
diff changeset
   407
	byte flash_timeout;      ///< timer for flashing white border
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   408
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   409
	WindowProc *wndproc;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   410
	ViewPort *viewport;
6258
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents: 6256
diff changeset
   411
	const OldWidget *original_widget;
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents: 6256
diff changeset
   412
	OldWidget *widget;
5232
0ba6acdc527f (svn r7352) -Codechange: add widget_count parameter to the window.
rubidium
parents: 5199
diff changeset
   413
	uint widget_count;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   414
	uint32 desc_flags;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   415
2622
1219c6a5bef3 (svn r3162) -Fix: renamed 'Message' to 'WindowMessage', a struct named 'Message' already
truelight
parents: 2596
diff changeset
   416
	WindowMessage message;
6258
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents: 6256
diff changeset
   417
	BaseWindow *parent;
158
b1a821f84250 (svn r159) -Fix: w->custom[] was too small for 64bit pointers
truelight
parents: 129
diff changeset
   418
	byte custom[WINDOW_CUSTOM_SIZE];
6235
5077e6ed3788 (svn r8683) [cpp_gui] -Codechange: first steps towards OO GUI (together with Bjarni) without changes in the logic
KUDr
parents: 6224
diff changeset
   419
6261
5fd6b1cfa424 (svn r8815) [cpp_gui] -Codechange: Added ZeroInitBegin and ZeroInitEnd helper structures
KUDr
parents: 6260
diff changeset
   420
	ZeroInitEnd m_zero_init_end; ///< end of zero initialization area
5fd6b1cfa424 (svn r8815) [cpp_gui] -Codechange: Added ZeroInitBegin and ZeroInitEnd helper structures
KUDr
parents: 6260
diff changeset
   421
6264
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents: 6263
diff changeset
   422
protected:
6283
7072ee68c676 (svn r8997) [cpp_gui] -Codechange: common window features are now controlled by FeatureFlags enum.
KUDr
parents: 6279
diff changeset
   423
	BaseWindow(WindowClass cls, StringID caption_text = 0, byte color = COLOUR_GREY, gui::FeatureFlags feature_flags = gui::FF_NONE)
6301
e0251f797d59 (svn r9484) [cpp_gui] -Add: Auto layout/resize ability of widgets.
KUDr
parents: 6298
diff changeset
   424
		: super(NULL, feature_flags, 0, color)
6284
45d0233e7d79 (svn r8998) [cpp_gui] -Fix(r8997): some obscure g++ warnings about base/member initialization order (glx)
KUDr
parents: 6283
diff changeset
   425
		, m_zero_init_area(m_zero_init_end)
6264
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents: 6263
diff changeset
   426
		, window_class(cls)
6283
7072ee68c676 (svn r8997) [cpp_gui] -Codechange: common window features are now controlled by FeatureFlags enum.
KUDr
parents: 6279
diff changeset
   427
		, m_caption_text(caption_text)
6264
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents: 6263
diff changeset
   428
	{}
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents: 6263
diff changeset
   429
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents: 6263
diff changeset
   430
public:
6261
5fd6b1cfa424 (svn r8815) [cpp_gui] -Codechange: Added ZeroInitBegin and ZeroInitEnd helper structures
KUDr
parents: 6260
diff changeset
   431
	BaseWindow(const WindowDesc *desc, WindowNumber num = 0)
5fd6b1cfa424 (svn r8815) [cpp_gui] -Codechange: Added ZeroInitBegin and ZeroInitEnd helper structures
KUDr
parents: 6260
diff changeset
   432
		: m_zero_init_area(m_zero_init_end)
5fd6b1cfa424 (svn r8815) [cpp_gui] -Codechange: Added ZeroInitBegin and ZeroInitEnd helper structures
KUDr
parents: 6260
diff changeset
   433
	{
5fd6b1cfa424 (svn r8815) [cpp_gui] -Codechange: Added ZeroInitBegin and ZeroInitEnd helper structures
KUDr
parents: 6260
diff changeset
   434
		Create(desc, num);
5fd6b1cfa424 (svn r8815) [cpp_gui] -Codechange: Added ZeroInitBegin and ZeroInitEnd helper structures
KUDr
parents: 6260
diff changeset
   435
	}
5fd6b1cfa424 (svn r8815) [cpp_gui] -Codechange: Added ZeroInitBegin and ZeroInitEnd helper structures
KUDr
parents: 6260
diff changeset
   436
6263
19dab6a68886 (svn r8913) [cpp_gui] -Codechange: use BaseWindow accessors instead of accessing window size/position directly
KUDr
parents: 6261
diff changeset
   437
	int16 Left() const;
19dab6a68886 (svn r8913) [cpp_gui] -Codechange: use BaseWindow accessors instead of accessing window size/position directly
KUDr
parents: 6261
diff changeset
   438
	int16 Top() const;
19dab6a68886 (svn r8913) [cpp_gui] -Codechange: use BaseWindow accessors instead of accessing window size/position directly
KUDr
parents: 6261
diff changeset
   439
	int16 Right() const;
19dab6a68886 (svn r8913) [cpp_gui] -Codechange: use BaseWindow accessors instead of accessing window size/position directly
KUDr
parents: 6261
diff changeset
   440
	int16 Bottom() const;
19dab6a68886 (svn r8913) [cpp_gui] -Codechange: use BaseWindow accessors instead of accessing window size/position directly
KUDr
parents: 6261
diff changeset
   441
	const Point16& TopLeft() const;
19dab6a68886 (svn r8913) [cpp_gui] -Codechange: use BaseWindow accessors instead of accessing window size/position directly
KUDr
parents: 6261
diff changeset
   442
	Point16 BottomRight() const;
19dab6a68886 (svn r8913) [cpp_gui] -Codechange: use BaseWindow accessors instead of accessing window size/position directly
KUDr
parents: 6261
diff changeset
   443
	Rect16 GetRect() const;
19dab6a68886 (svn r8913) [cpp_gui] -Codechange: use BaseWindow accessors instead of accessing window size/position directly
KUDr
parents: 6261
diff changeset
   444
19dab6a68886 (svn r8913) [cpp_gui] -Codechange: use BaseWindow accessors instead of accessing window size/position directly
KUDr
parents: 6261
diff changeset
   445
	void SetLeft(int16 val);
19dab6a68886 (svn r8913) [cpp_gui] -Codechange: use BaseWindow accessors instead of accessing window size/position directly
KUDr
parents: 6261
diff changeset
   446
	void SetTop(int16 val);
19dab6a68886 (svn r8913) [cpp_gui] -Codechange: use BaseWindow accessors instead of accessing window size/position directly
KUDr
parents: 6261
diff changeset
   447
	void SetRight(int16 val);
19dab6a68886 (svn r8913) [cpp_gui] -Codechange: use BaseWindow accessors instead of accessing window size/position directly
KUDr
parents: 6261
diff changeset
   448
	void SetBottom(int16 val);
19dab6a68886 (svn r8913) [cpp_gui] -Codechange: use BaseWindow accessors instead of accessing window size/position directly
KUDr
parents: 6261
diff changeset
   449
	void SetTopLeft(const Point16 &pt);
19dab6a68886 (svn r8913) [cpp_gui] -Codechange: use BaseWindow accessors instead of accessing window size/position directly
KUDr
parents: 6261
diff changeset
   450
	void SetBottomRight(const Point16 &pt);
19dab6a68886 (svn r8913) [cpp_gui] -Codechange: use BaseWindow accessors instead of accessing window size/position directly
KUDr
parents: 6261
diff changeset
   451
	void SetSize(const Point16 &pt);
19dab6a68886 (svn r8913) [cpp_gui] -Codechange: use BaseWindow accessors instead of accessing window size/position directly
KUDr
parents: 6261
diff changeset
   452
	void SetRect(const Rect16 &rect);
19dab6a68886 (svn r8913) [cpp_gui] -Codechange: use BaseWindow accessors instead of accessing window size/position directly
KUDr
parents: 6261
diff changeset
   453
6264
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents: 6263
diff changeset
   454
	virtual bool Create(WindowNumber num);
6258
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents: 6256
diff changeset
   455
	virtual bool Create(const WindowDesc *desc, WindowNumber num = 0);
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents: 6256
diff changeset
   456
6283
7072ee68c676 (svn r8997) [cpp_gui] -Codechange: common window features are now controlled by FeatureFlags enum.
KUDr
parents: 6279
diff changeset
   457
	/*virtual*/ void CreateNcWidgets();
6279
c75b2c7222ff (svn r8991) [cpp_gui] -Codechange: composite widgets (incl. windows) now must implement CreateWidgets() method which is called from the default OnCreate() implementation
KUDr
parents: 6268
diff changeset
   458
	/*virtual*/ void CreateWidgets(); ///< @TODO remove it when old gui infrastructure will no longer be used
c75b2c7222ff (svn r8991) [cpp_gui] -Codechange: composite widgets (incl. windows) now must implement CreateWidgets() method which is called from the default OnCreate() implementation
KUDr
parents: 6268
diff changeset
   459
6301
e0251f797d59 (svn r9484) [cpp_gui] -Add: Auto layout/resize ability of widgets.
KUDr
parents: 6298
diff changeset
   460
	/*virtual*/ void OnCreate(gui::EvtCreate &ev);
6293
59b7305f9a8b (svn r9087) [cpp_gui] -Codechange: Window is now clipping its widgets in OnPaint()
KUDr
parents: 6285
diff changeset
   461
	/*virtual*/ void OnPaint(gui::EvtPaint &ev);
6301
e0251f797d59 (svn r9484) [cpp_gui] -Add: Auto layout/resize ability of widgets.
KUDr
parents: 6298
diff changeset
   462
	/*virtual*/ void OnResize(gui::EvtResize &ev);
6293
59b7305f9a8b (svn r9087) [cpp_gui] -Codechange: Window is now clipping its widgets in OnPaint()
KUDr
parents: 6285
diff changeset
   463
59b7305f9a8b (svn r9087) [cpp_gui] -Codechange: Window is now clipping its widgets in OnPaint()
KUDr
parents: 6285
diff changeset
   464
6258
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents: 6256
diff changeset
   465
	static BaseWindow* Allocate(int x, int y, int width, int height, WindowProc *proc, WindowClass cls, const OldWidget *widget);
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents: 6256
diff changeset
   466
	static BaseWindow* Allocate(const WindowDesc *desc, int window_number = 0);
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents: 6256
diff changeset
   467
	static BaseWindow* AllocateFront(const WindowDesc *desc, int window_number = 0);
6235
5077e6ed3788 (svn r8683) [cpp_gui] -Codechange: first steps towards OO GUI (together with Bjarni) without changes in the logic
KUDr
parents: 6224
diff changeset
   468
6264
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents: 6263
diff changeset
   469
	/*virtual*/ BaseWindow* GetWindow();
6258
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents: 6256
diff changeset
   470
	BaseWindow* FindChild() const;
6235
5077e6ed3788 (svn r8683) [cpp_gui] -Codechange: first steps towards OO GUI (together with Bjarni) without changes in the logic
KUDr
parents: 6224
diff changeset
   471
	void SetDirty() const;
5077e6ed3788 (svn r8683) [cpp_gui] -Codechange: first steps towards OO GUI (together with Bjarni) without changes in the logic
KUDr
parents: 6224
diff changeset
   472
	void CDECL SetWidgetsDisabledState(bool disab_stat, int widgets, ...);
5077e6ed3788 (svn r8683) [cpp_gui] -Codechange: first steps towards OO GUI (together with Bjarni) without changes in the logic
KUDr
parents: 6224
diff changeset
   473
	void CDECL SetWidgetsHiddenState(bool hidden_stat, int widgets, ...);
5077e6ed3788 (svn r8683) [cpp_gui] -Codechange: first steps towards OO GUI (together with Bjarni) without changes in the logic
KUDr
parents: 6224
diff changeset
   474
	void CDECL SetWidgetsLoweredState(bool lowered_stat, int widgets, ...);
5077e6ed3788 (svn r8683) [cpp_gui] -Codechange: first steps towards OO GUI (together with Bjarni) without changes in the logic
KUDr
parents: 6224
diff changeset
   475
	void RaiseButtons();
5077e6ed3788 (svn r8683) [cpp_gui] -Codechange: first steps towards OO GUI (together with Bjarni) without changes in the logic
KUDr
parents: 6224
diff changeset
   476
	void HandleButtonClick(byte widget);
5077e6ed3788 (svn r8683) [cpp_gui] -Codechange: first steps towards OO GUI (together with Bjarni) without changes in the logic
KUDr
parents: 6224
diff changeset
   477
	void BringToFront();
6258
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents: 6256
diff changeset
   478
	static BaseWindow* BringToFrontById(WindowClass cls, WindowNumber number);
6235
5077e6ed3788 (svn r8683) [cpp_gui] -Codechange: first steps towards OO GUI (together with Bjarni) without changes in the logic
KUDr
parents: 6224
diff changeset
   479
	void StartDrag();
5077e6ed3788 (svn r8683) [cpp_gui] -Codechange: first steps towards OO GUI (together with Bjarni) without changes in the logic
KUDr
parents: 6224
diff changeset
   480
	bool ContinueDrag();
5077e6ed3788 (svn r8683) [cpp_gui] -Codechange: first steps towards OO GUI (together with Bjarni) without changes in the logic
KUDr
parents: 6224
diff changeset
   481
	void StartSizing();
5077e6ed3788 (svn r8683) [cpp_gui] -Codechange: first steps towards OO GUI (together with Bjarni) without changes in the logic
KUDr
parents: 6224
diff changeset
   482
	bool ContinueSizing();
5077e6ed3788 (svn r8683) [cpp_gui] -Codechange: first steps towards OO GUI (together with Bjarni) without changes in the logic
KUDr
parents: 6224
diff changeset
   483
	static bool HandleWindowDragging(void);
6243
8f231ee779cb (svn r8706) [cpp_gui] -Codechange: few more functions turned into Window methods
KUDr
parents: 6242
diff changeset
   484
	void DispatchLeftClickEvent(int x, int y);
8f231ee779cb (svn r8706) [cpp_gui] -Codechange: few more functions turned into Window methods
KUDr
parents: 6242
diff changeset
   485
	void DispatchRightClickEvent(int x, int y);
8f231ee779cb (svn r8706) [cpp_gui] -Codechange: few more functions turned into Window methods
KUDr
parents: 6242
diff changeset
   486
	void DispatchMouseWheelEvent(int widget, int wheel);
6235
5077e6ed3788 (svn r8683) [cpp_gui] -Codechange: first steps towards OO GUI (together with Bjarni) without changes in the logic
KUDr
parents: 6224
diff changeset
   487
5077e6ed3788 (svn r8683) [cpp_gui] -Codechange: first steps towards OO GUI (together with Bjarni) without changes in the logic
KUDr
parents: 6224
diff changeset
   488
	/*virtual*/ void FinalRelease();
5077e6ed3788 (svn r8683) [cpp_gui] -Codechange: first steps towards OO GUI (together with Bjarni) without changes in the logic
KUDr
parents: 6224
diff changeset
   489
	virtual void Close();
5077e6ed3788 (svn r8683) [cpp_gui] -Codechange: first steps towards OO GUI (together with Bjarni) without changes in the logic
KUDr
parents: 6224
diff changeset
   490
	virtual bool IsVital();
5077e6ed3788 (svn r8683) [cpp_gui] -Codechange: first steps towards OO GUI (together with Bjarni) without changes in the logic
KUDr
parents: 6224
diff changeset
   491
6258
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents: 6256
diff changeset
   492
	static BaseWindow* Get(WindowList::Iterator it);
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents: 6256
diff changeset
   493
	static BaseWindow* FindFromPt(int x, int y);
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents: 6256
diff changeset
   494
	static BaseWindow* FindById(WindowClass cls, WindowNumber num);
6235
5077e6ed3788 (svn r8683) [cpp_gui] -Codechange: first steps towards OO GUI (together with Bjarni) without changes in the logic
KUDr
parents: 6224
diff changeset
   495
	static void SetDirtyById(WindowClass cls, WindowNumber num);
5077e6ed3788 (svn r8683) [cpp_gui] -Codechange: first steps towards OO GUI (together with Bjarni) without changes in the logic
KUDr
parents: 6224
diff changeset
   496
6258
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents: 6256
diff changeset
   497
	bool IsOfPrototype(const OldWidget *widgets) const;
6238
1ff56ccccbb5 (svn r8696) [cpp_gui] -Codechange: changed GetMenuItemIndex() and ResizeWindow() into Window methods
bjarni
parents: 6237
diff changeset
   498
	int GetMenuItemIndex(int x, int y) const;
6240
8d4ea2d6befc (svn r8699) [cpp_gui] -Cleanup: removed the word Window from some Window method names as just being Winddow methods indicates that it's working on a window
bjarni
parents: 6239
diff changeset
   499
	void Resize(int x, int y);
6238
1ff56ccccbb5 (svn r8696) [cpp_gui] -Codechange: changed GetMenuItemIndex() and ResizeWindow() into Window methods
bjarni
parents: 6237
diff changeset
   500
6245
6fa82c6ee8ca (svn r8711) [cpp_gui] -Codechange: even more funktion->method conversions
bjarni
parents: 6244
diff changeset
   501
	void CallEventNP(int event);
6fa82c6ee8ca (svn r8711) [cpp_gui] -Codechange: even more funktion->method conversions
bjarni
parents: 6244
diff changeset
   502
6264
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents: 6263
diff changeset
   503
	void OldWndProc(WindowEvent *e);
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents: 6263
diff changeset
   504
	static void DefaultWndProc(BaseWindow *w, WindowEvent *e);
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents: 6263
diff changeset
   505
6258
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents: 6256
diff changeset
   506
	void AssignWidget(const OldWidget *widget);
6237
bce32e54c993 (svn r8695) [cpp_gui] -Codechange: changed AssignWidgetToWindow() and InvalidateWidget() into Window methods
bjarni
parents: 6236
diff changeset
   507
6244
4b42fb40e6d2 (svn r8710) [cpp_gui] -Codechange: yet another two functions are turned into Window methods
bjarni
parents: 6243
diff changeset
   508
	void InvalidateData();
6237
bce32e54c993 (svn r8695) [cpp_gui] -Codechange: changed AssignWidgetToWindow() and InvalidateWidget() into Window methods
bjarni
parents: 6236
diff changeset
   509
	void InvalidateWidget(byte widget_index) const;
bce32e54c993 (svn r8695) [cpp_gui] -Codechange: changed AssignWidgetToWindow() and InvalidateWidget() into Window methods
bjarni
parents: 6236
diff changeset
   510
6249
abafebc2fbce (svn r8717) [cpp_gui] -Codechange: changed the functions about closing all windows into methods
bjarni
parents: 6248
diff changeset
   511
	static void DeleteNonVitalWindows(void);
abafebc2fbce (svn r8717) [cpp_gui] -Codechange: changed the functions about closing all windows into methods
bjarni
parents: 6248
diff changeset
   512
	static void DeleteAllNonVitalWindows(void);
abafebc2fbce (svn r8717) [cpp_gui] -Codechange: changed the functions about closing all windows into methods
bjarni
parents: 6248
diff changeset
   513
	static void ShowVitalWindows(void);
abafebc2fbce (svn r8717) [cpp_gui] -Codechange: changed the functions about closing all windows into methods
bjarni
parents: 6248
diff changeset
   514
	static void HideVitalWindows(void);
abafebc2fbce (svn r8717) [cpp_gui] -Codechange: changed the functions about closing all windows into methods
bjarni
parents: 6248
diff changeset
   515
6244
4b42fb40e6d2 (svn r8710) [cpp_gui] -Codechange: yet another two functions are turned into Window methods
bjarni
parents: 6243
diff changeset
   516
	/* viewport.cpp */
4b42fb40e6d2 (svn r8710) [cpp_gui] -Codechange: yet another two functions are turned into Window methods
bjarni
parents: 6243
diff changeset
   517
	void DrawViewport() const;
4b42fb40e6d2 (svn r8710) [cpp_gui] -Codechange: yet another two functions are turned into Window methods
bjarni
parents: 6243
diff changeset
   518
6241
6a7a41b0cd32 (svn r8702) [cpp_gui] -Codechange: changed the 3 window functions in widget.cpp into Window methods
bjarni
parents: 6240
diff changeset
   519
	/* widget.cpp */
6a7a41b0cd32 (svn r8702) [cpp_gui] -Codechange: changed the 3 window functions in widget.cpp into Window methods
bjarni
parents: 6240
diff changeset
   520
	int GetWidgetFromPos(int x, int y) const;
6a7a41b0cd32 (svn r8702) [cpp_gui] -Codechange: changed the 3 window functions in widget.cpp into Window methods
bjarni
parents: 6240
diff changeset
   521
	void DrawWidgets() const;
6a7a41b0cd32 (svn r8702) [cpp_gui] -Codechange: changed the 3 window functions in widget.cpp into Window methods
bjarni
parents: 6240
diff changeset
   522
	void ShowDropDownMenu(const StringID *strings, int selected, int button, uint32 disabled_mask, uint32 hidden_mask);
6245
6fa82c6ee8ca (svn r8711) [cpp_gui] -Codechange: even more funktion->method conversions
bjarni
parents: 6244
diff changeset
   523
	void ResizeButtons(byte left, byte right);
6fa82c6ee8ca (svn r8711) [cpp_gui] -Codechange: even more funktion->method conversions
bjarni
parents: 6244
diff changeset
   524
6fa82c6ee8ca (svn r8711) [cpp_gui] -Codechange: even more funktion->method conversions
bjarni
parents: 6244
diff changeset
   525
private:
6258
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents: 6256
diff changeset
   526
	void ScrollbarClickHandler(const OldWidget *wi, int x, int y);
6245
6fa82c6ee8ca (svn r8711) [cpp_gui] -Codechange: even more funktion->method conversions
bjarni
parents: 6244
diff changeset
   527
public:
6241
6a7a41b0cd32 (svn r8702) [cpp_gui] -Codechange: changed the 3 window functions in widget.cpp into Window methods
bjarni
parents: 6240
diff changeset
   528
6248
24583caadfee (svn r8716) [cpp_gui] -Codechange: IsWindowWidgetDisabled() turned into Window method
KUDr
parents: 6247
diff changeset
   529
	/*inline*/ void SetWidgetDisabledState(byte widget_index, bool disab_stat);
24583caadfee (svn r8716) [cpp_gui] -Codechange: IsWindowWidgetDisabled() turned into Window method
KUDr
parents: 6247
diff changeset
   530
	/*inline*/ void DisableWidget(byte widget_index);
24583caadfee (svn r8716) [cpp_gui] -Codechange: IsWindowWidgetDisabled() turned into Window method
KUDr
parents: 6247
diff changeset
   531
	/*inline*/ void EnableWidget(byte widget_index);
24583caadfee (svn r8716) [cpp_gui] -Codechange: IsWindowWidgetDisabled() turned into Window method
KUDr
parents: 6247
diff changeset
   532
	/*inline*/ bool IsWidgetDisabled(byte widget_index) const;
6251
cd413fa2e252 (svn r8720) [cpp_gui] -Codechange: SetWindowWidgetLoweredState(), ToggleWidgetLoweredState(), LowerWindowWidget(), RaiseWindowWidget() and IsWindowWidgetLowered() turned into Window methods
KUDr
parents: 6250
diff changeset
   533
6250
5135b200b376 (svn r8718) [cpp_gui] -Codechange: SetWindowWidgetHiddenState(), HideWindowWidget(), ShowWindowWidget() and IsWindowWidgetHidden() turned into Window methods
KUDr
parents: 6249
diff changeset
   534
	/*inline*/ void SetWidgetHiddenState(byte widget_index, bool hidden_stat);
5135b200b376 (svn r8718) [cpp_gui] -Codechange: SetWindowWidgetHiddenState(), HideWindowWidget(), ShowWindowWidget() and IsWindowWidgetHidden() turned into Window methods
KUDr
parents: 6249
diff changeset
   535
	/*inline*/ void HideWidget(byte widget_index);
5135b200b376 (svn r8718) [cpp_gui] -Codechange: SetWindowWidgetHiddenState(), HideWindowWidget(), ShowWindowWidget() and IsWindowWidgetHidden() turned into Window methods
KUDr
parents: 6249
diff changeset
   536
	/*inline*/ void ShowWidget(byte widget_index);
5135b200b376 (svn r8718) [cpp_gui] -Codechange: SetWindowWidgetHiddenState(), HideWindowWidget(), ShowWindowWidget() and IsWindowWidgetHidden() turned into Window methods
KUDr
parents: 6249
diff changeset
   537
	/*inline*/ bool IsWidgetHidden(byte widget_index) const;
6246
2a4c2c4d66f0 (svn r8713) [cpp_gui] -Codechange: SetWindowWidgetDisabledState turned into Window method
KUDr
parents: 6245
diff changeset
   538
6251
cd413fa2e252 (svn r8720) [cpp_gui] -Codechange: SetWindowWidgetLoweredState(), ToggleWidgetLoweredState(), LowerWindowWidget(), RaiseWindowWidget() and IsWindowWidgetLowered() turned into Window methods
KUDr
parents: 6250
diff changeset
   539
	/*inline*/ void SetWidgetLoweredState(byte widget_index, bool lowered_stat);
cd413fa2e252 (svn r8720) [cpp_gui] -Codechange: SetWindowWidgetLoweredState(), ToggleWidgetLoweredState(), LowerWindowWidget(), RaiseWindowWidget() and IsWindowWidgetLowered() turned into Window methods
KUDr
parents: 6250
diff changeset
   540
	/*inline*/ void ToggleWidgetLoweredState(byte widget_index);
cd413fa2e252 (svn r8720) [cpp_gui] -Codechange: SetWindowWidgetLoweredState(), ToggleWidgetLoweredState(), LowerWindowWidget(), RaiseWindowWidget() and IsWindowWidgetLowered() turned into Window methods
KUDr
parents: 6250
diff changeset
   541
	/*inline*/ void LowerWidget(byte widget_index);
cd413fa2e252 (svn r8720) [cpp_gui] -Codechange: SetWindowWidgetLoweredState(), ToggleWidgetLoweredState(), LowerWindowWidget(), RaiseWindowWidget() and IsWindowWidgetLowered() turned into Window methods
KUDr
parents: 6250
diff changeset
   542
	/*inline*/ void RaiseWidget(byte widget_index);
cd413fa2e252 (svn r8720) [cpp_gui] -Codechange: SetWindowWidgetLoweredState(), ToggleWidgetLoweredState(), LowerWindowWidget(), RaiseWindowWidget() and IsWindowWidgetLowered() turned into Window methods
KUDr
parents: 6250
diff changeset
   543
	/*inline*/ bool IsWidgetLowered(byte widget_index) const;
cd413fa2e252 (svn r8720) [cpp_gui] -Codechange: SetWindowWidgetLoweredState(), ToggleWidgetLoweredState(), LowerWindowWidget(), RaiseWindowWidget() and IsWindowWidgetLowered() turned into Window methods
KUDr
parents: 6250
diff changeset
   544
6235
5077e6ed3788 (svn r8683) [cpp_gui] -Codechange: first steps towards OO GUI (together with Bjarni) without changes in the logic
KUDr
parents: 6224
diff changeset
   545
	//int32 AddRef()
5077e6ed3788 (svn r8683) [cpp_gui] -Codechange: first steps towards OO GUI (together with Bjarni) without changes in the logic
KUDr
parents: 6224
diff changeset
   546
	//{
5077e6ed3788 (svn r8683) [cpp_gui] -Codechange: first steps towards OO GUI (together with Bjarni) without changes in the logic
KUDr
parents: 6224
diff changeset
   547
	//	const char *name = NULL;
5077e6ed3788 (svn r8683) [cpp_gui] -Codechange: first steps towards OO GUI (together with Bjarni) without changes in the logic
KUDr
parents: 6224
diff changeset
   548
	//	switch (window_class)
5077e6ed3788 (svn r8683) [cpp_gui] -Codechange: first steps towards OO GUI (together with Bjarni) without changes in the logic
KUDr
parents: 6224
diff changeset
   549
	//	{
5077e6ed3788 (svn r8683) [cpp_gui] -Codechange: first steps towards OO GUI (together with Bjarni) without changes in the logic
KUDr
parents: 6224
diff changeset
   550
	//		case WC_MAIN_WINDOW:      name = "mw"; break;
5077e6ed3788 (svn r8683) [cpp_gui] -Codechange: first steps towards OO GUI (together with Bjarni) without changes in the logic
KUDr
parents: 6224
diff changeset
   551
	//		case WC_SELECT_GAME:      name = "sg"; break;
5077e6ed3788 (svn r8683) [cpp_gui] -Codechange: first steps towards OO GUI (together with Bjarni) without changes in the logic
KUDr
parents: 6224
diff changeset
   552
	//		case WC_INDUSTRY_VIEW:    name = "iw"; break;
5077e6ed3788 (svn r8683) [cpp_gui] -Codechange: first steps towards OO GUI (together with Bjarni) without changes in the logic
KUDr
parents: 6224
diff changeset
   553
	//		default: break;
5077e6ed3788 (svn r8683) [cpp_gui] -Codechange: first steps towards OO GUI (together with Bjarni) without changes in the logic
KUDr
parents: 6224
diff changeset
   554
	//	}
5077e6ed3788 (svn r8683) [cpp_gui] -Codechange: first steps towards OO GUI (together with Bjarni) without changes in the logic
KUDr
parents: 6224
diff changeset
   555
	//	if (name != NULL) printf("%s+\n", name);
6256
220cd0db67a4 (svn r8774) [cpp_gui] -Codechange: CountedObject renamed to SimpleCountedObject and moved to countedptr.hpp and countedobj.cpp
KUDr
parents: 6254
diff changeset
   556
	//	return SimpleCountedObject::AddRef();
6235
5077e6ed3788 (svn r8683) [cpp_gui] -Codechange: first steps towards OO GUI (together with Bjarni) without changes in the logic
KUDr
parents: 6224
diff changeset
   557
	//}
5077e6ed3788 (svn r8683) [cpp_gui] -Codechange: first steps towards OO GUI (together with Bjarni) without changes in the logic
KUDr
parents: 6224
diff changeset
   558
5077e6ed3788 (svn r8683) [cpp_gui] -Codechange: first steps towards OO GUI (together with Bjarni) without changes in the logic
KUDr
parents: 6224
diff changeset
   559
	//int32 Release()
5077e6ed3788 (svn r8683) [cpp_gui] -Codechange: first steps towards OO GUI (together with Bjarni) without changes in the logic
KUDr
parents: 6224
diff changeset
   560
	//{
5077e6ed3788 (svn r8683) [cpp_gui] -Codechange: first steps towards OO GUI (together with Bjarni) without changes in the logic
KUDr
parents: 6224
diff changeset
   561
	//	const char *name = NULL;
5077e6ed3788 (svn r8683) [cpp_gui] -Codechange: first steps towards OO GUI (together with Bjarni) without changes in the logic
KUDr
parents: 6224
diff changeset
   562
	//	switch (window_class)
5077e6ed3788 (svn r8683) [cpp_gui] -Codechange: first steps towards OO GUI (together with Bjarni) without changes in the logic
KUDr
parents: 6224
diff changeset
   563
	//	{
5077e6ed3788 (svn r8683) [cpp_gui] -Codechange: first steps towards OO GUI (together with Bjarni) without changes in the logic
KUDr
parents: 6224
diff changeset
   564
	//		case WC_MAIN_WINDOW:      name = "mw"; break;
5077e6ed3788 (svn r8683) [cpp_gui] -Codechange: first steps towards OO GUI (together with Bjarni) without changes in the logic
KUDr
parents: 6224
diff changeset
   565
	//		case WC_SELECT_GAME:      name = "sg"; break;
5077e6ed3788 (svn r8683) [cpp_gui] -Codechange: first steps towards OO GUI (together with Bjarni) without changes in the logic
KUDr
parents: 6224
diff changeset
   566
	//		case WC_INDUSTRY_VIEW:    name = "iw"; break;
5077e6ed3788 (svn r8683) [cpp_gui] -Codechange: first steps towards OO GUI (together with Bjarni) without changes in the logic
KUDr
parents: 6224
diff changeset
   567
	//		default: break;
5077e6ed3788 (svn r8683) [cpp_gui] -Codechange: first steps towards OO GUI (together with Bjarni) without changes in the logic
KUDr
parents: 6224
diff changeset
   568
	//	}
5077e6ed3788 (svn r8683) [cpp_gui] -Codechange: first steps towards OO GUI (together with Bjarni) without changes in the logic
KUDr
parents: 6224
diff changeset
   569
	//	if (name != NULL) printf("%s-\n", name);
6256
220cd0db67a4 (svn r8774) [cpp_gui] -Codechange: CountedObject renamed to SimpleCountedObject and moved to countedptr.hpp and countedobj.cpp
KUDr
parents: 6254
diff changeset
   570
	//	return SimpleCountedObject::Release();
6235
5077e6ed3788 (svn r8683) [cpp_gui] -Codechange: first steps towards OO GUI (together with Bjarni) without changes in the logic
KUDr
parents: 6224
diff changeset
   571
	//}
5077e6ed3788 (svn r8683) [cpp_gui] -Codechange: first steps towards OO GUI (together with Bjarni) without changes in the logic
KUDr
parents: 6224
diff changeset
   572
5077e6ed3788 (svn r8683) [cpp_gui] -Codechange: first steps towards OO GUI (together with Bjarni) without changes in the logic
KUDr
parents: 6224
diff changeset
   573
	template <class Tmatch> struct EnumMatch {
5077e6ed3788 (svn r8683) [cpp_gui] -Codechange: first steps towards OO GUI (together with Bjarni) without changes in the logic
KUDr
parents: 6224
diff changeset
   574
		Tmatch &m_match;
5077e6ed3788 (svn r8683) [cpp_gui] -Codechange: first steps towards OO GUI (together with Bjarni) without changes in the logic
KUDr
parents: 6224
diff changeset
   575
		EnumMatch(Tmatch &m)
5077e6ed3788 (svn r8683) [cpp_gui] -Codechange: first steps towards OO GUI (together with Bjarni) without changes in the logic
KUDr
parents: 6224
diff changeset
   576
			: m_match(m)
5077e6ed3788 (svn r8683) [cpp_gui] -Codechange: first steps towards OO GUI (together with Bjarni) without changes in the logic
KUDr
parents: 6224
diff changeset
   577
		{}
5077e6ed3788 (svn r8683) [cpp_gui] -Codechange: first steps towards OO GUI (together with Bjarni) without changes in the logic
KUDr
parents: 6224
diff changeset
   578
		bool EnumProc(WindowList::Iterator it)
5077e6ed3788 (svn r8683) [cpp_gui] -Codechange: first steps towards OO GUI (together with Bjarni) without changes in the logic
KUDr
parents: 6224
diff changeset
   579
		{
5077e6ed3788 (svn r8683) [cpp_gui] -Codechange: first steps towards OO GUI (together with Bjarni) without changes in the logic
KUDr
parents: 6224
diff changeset
   580
			return m_match->EnumProc((*it).w);
5077e6ed3788 (svn r8683) [cpp_gui] -Codechange: first steps towards OO GUI (together with Bjarni) without changes in the logic
KUDr
parents: 6224
diff changeset
   581
		}
5077e6ed3788 (svn r8683) [cpp_gui] -Codechange: first steps towards OO GUI (together with Bjarni) without changes in the logic
KUDr
parents: 6224
diff changeset
   582
	};
5077e6ed3788 (svn r8683) [cpp_gui] -Codechange: first steps towards OO GUI (together with Bjarni) without changes in the logic
KUDr
parents: 6224
diff changeset
   583
6258
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents: 6256
diff changeset
   584
	//template <class Tmatch> BaseWindow* EnumT(Tmatch m)
6236
ec056d324811 (svn r8693) [cpp_gui] -Fix: g++ compilation errors 'non-local function A uses local type B' (template arguments must have external linkage while local type has no linkage)
KUDr
parents: 6235
diff changeset
   585
	//{
6258
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents: 6256
diff changeset
   586
	//	WindowList::Iterator it = BaseWindow::s_list.EnumT(EnumMatch<Tmatch>(m));
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents: 6256
diff changeset
   587
	//	return (it == BaseWindow::s_list.m_list.end()) ? NULL : (*it).w;
6236
ec056d324811 (svn r8693) [cpp_gui] -Fix: g++ compilation errors 'non-local function A uses local type B' (template arguments must have external linkage while local type has no linkage)
KUDr
parents: 6235
diff changeset
   588
	//}
6235
5077e6ed3788 (svn r8683) [cpp_gui] -Codechange: first steps towards OO GUI (together with Bjarni) without changes in the logic
KUDr
parents: 6224
diff changeset
   589
6258
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents: 6256
diff changeset
   590
	//template <class Tmatch> BaseWindow* ReverseEnumT(Tmatch m)
6236
ec056d324811 (svn r8693) [cpp_gui] -Fix: g++ compilation errors 'non-local function A uses local type B' (template arguments must have external linkage while local type has no linkage)
KUDr
parents: 6235
diff changeset
   591
	//{
6258
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents: 6256
diff changeset
   592
	//	WindowList::Iterator it = BaseWindow::s_list.ReverseEnumT(EnumMatch<Tmatch>(m));
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents: 6256
diff changeset
   593
	//	return (it == BaseWindow::s_list.m_list.end()) ? NULL : (*it).w;
6236
ec056d324811 (svn r8693) [cpp_gui] -Fix: g++ compilation errors 'non-local function A uses local type B' (template arguments must have external linkage while local type has no linkage)
KUDr
parents: 6235
diff changeset
   594
	//}
6235
5077e6ed3788 (svn r8683) [cpp_gui] -Codechange: first steps towards OO GUI (together with Bjarni) without changes in the logic
KUDr
parents: 6224
diff changeset
   595
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   596
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   597
6235
5077e6ed3788 (svn r8683) [cpp_gui] -Codechange: first steps towards OO GUI (together with Bjarni) without changes in the logic
KUDr
parents: 6224
diff changeset
   598
5077e6ed3788 (svn r8683) [cpp_gui] -Codechange: first steps towards OO GUI (together with Bjarni) without changes in the logic
KUDr
parents: 6224
diff changeset
   599
5077e6ed3788 (svn r8683) [cpp_gui] -Codechange: first steps towards OO GUI (together with Bjarni) without changes in the logic
KUDr
parents: 6224
diff changeset
   600
#define FOR_ALL_WINDOWS(wz) \
6258
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents: 6256
diff changeset
   601
	for (WindowList::Iterator it = BaseWindow::s_list.m_list.begin(); it != BaseWindow::s_list.m_list.end() && (wz = (*it).w) != NULL; it++)
6235
5077e6ed3788 (svn r8683) [cpp_gui] -Codechange: first steps towards OO GUI (together with Bjarni) without changes in the logic
KUDr
parents: 6224
diff changeset
   602
5077e6ed3788 (svn r8683) [cpp_gui] -Codechange: first steps towards OO GUI (together with Bjarni) without changes in the logic
KUDr
parents: 6224
diff changeset
   603
#define REVERSED_FOR_ALL_WINDOWS(wz) \
6258
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents: 6256
diff changeset
   604
	for (WindowList::ReverseIterator it = BaseWindow::s_list.m_list.rbegin(); it != BaseWindow::s_list.m_list.rend() && (wz = (*it).w) != NULL; it++)
6235
5077e6ed3788 (svn r8683) [cpp_gui] -Codechange: first steps towards OO GUI (together with Bjarni) without changes in the logic
KUDr
parents: 6224
diff changeset
   605
5077e6ed3788 (svn r8683) [cpp_gui] -Codechange: first steps towards OO GUI (together with Bjarni) without changes in the logic
KUDr
parents: 6224
diff changeset
   606
6298
c30fe89622df (svn r9119) [cpp_gui] -Sync with trunk (r9003:9100)
bjarni
parents: 6297
diff changeset
   607
struct querystr_d {
4299
b86602eaaff1 (svn r5944) -Merge TGP (r5578, r5579, r5724, r5726): -Feature: filter for textboxes to only
truelight
parents: 4266
diff changeset
   608
	StringID caption;
b86602eaaff1 (svn r5944) -Merge TGP (r5578, r5579, r5724, r5726): -Feature: filter for textboxes to only
truelight
parents: 4266
diff changeset
   609
	Textbuf text;
b86602eaaff1 (svn r5944) -Merge TGP (r5578, r5579, r5724, r5726): -Feature: filter for textboxes to only
truelight
parents: 4266
diff changeset
   610
	const char *orig;
b86602eaaff1 (svn r5944) -Merge TGP (r5578, r5579, r5724, r5726): -Feature: filter for textboxes to only
truelight
parents: 4266
diff changeset
   611
	CharSetFilter afilter;
5682
eeddbbacd4ac (svn r7637) -Codechange: Change ShowQueryString to use a window pointer as a parent. If the
Darkvater
parents: 5669
diff changeset
   612
	bool handled;
6298
c30fe89622df (svn r9119) [cpp_gui] -Sync with trunk (r9003:9100)
bjarni
parents: 6297
diff changeset
   613
};
4299
b86602eaaff1 (svn r5944) -Merge TGP (r5578, r5579, r5724, r5726): -Feature: filter for textboxes to only
truelight
parents: 4266
diff changeset
   614
assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(querystr_d));
b86602eaaff1 (svn r5944) -Merge TGP (r5578, r5579, r5724, r5726): -Feature: filter for textboxes to only
truelight
parents: 4266
diff changeset
   615
6298
c30fe89622df (svn r9119) [cpp_gui] -Sync with trunk (r9003:9100)
bjarni
parents: 6297
diff changeset
   616
struct menu_d {
6268
4b5241e5dd10 (svn r8938) [cpp_gui] -Sync with trunk (r8772..r8900)
bjarni
parents: 6267
diff changeset
   617
	byte item_count;      ///< follow_vehicle
4b5241e5dd10 (svn r8938) [cpp_gui] -Sync with trunk (r8772..r8900)
bjarni
parents: 6267
diff changeset
   618
	byte sel_index;       ///< scrollpos_x
4b5241e5dd10 (svn r8938) [cpp_gui] -Sync with trunk (r8772..r8900)
bjarni
parents: 6267
diff changeset
   619
	byte main_button;     ///< scrollpos_y
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   620
	byte action_id;
6268
4b5241e5dd10 (svn r8938) [cpp_gui] -Sync with trunk (r8772..r8900)
bjarni
parents: 6267
diff changeset
   621
	StringID string_id;   ///< unk30
4b5241e5dd10 (svn r8938) [cpp_gui] -Sync with trunk (r8772..r8900)
bjarni
parents: 6267
diff changeset
   622
	uint16 checked_items; ///< unk32
2216
51a715447fc4 (svn r2734) -Feature: The Main Toolbar Dropdown Menu can now display disabled items
celestar
parents: 2187
diff changeset
   623
	byte disabled_items;
6298
c30fe89622df (svn r9119) [cpp_gui] -Sync with trunk (r9003:9100)
bjarni
parents: 6297
diff changeset
   624
};
1004
edbdc62fbf24 (svn r1503) Added feature:
miham
parents: 998
diff changeset
   625
assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(menu_d));
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   626
6298
c30fe89622df (svn r9119) [cpp_gui] -Sync with trunk (r9003:9100)
bjarni
parents: 6297
diff changeset
   627
struct def_d {
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   628
	int16 data_1, data_2, data_3;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   629
	int16 data_4, data_5;
2596
d228e8ce6fcf (svn r3133) - static, const
tron
parents: 2549
diff changeset
   630
	bool close;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   631
	byte byte_1;
6298
c30fe89622df (svn r9119) [cpp_gui] -Sync with trunk (r9003:9100)
bjarni
parents: 6297
diff changeset
   632
};
1004
edbdc62fbf24 (svn r1503) Added feature:
miham
parents: 998
diff changeset
   633
assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(def_d));
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   634
6298
c30fe89622df (svn r9119) [cpp_gui] -Sync with trunk (r9003:9100)
bjarni
parents: 6297
diff changeset
   635
struct void_d {
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   636
	void *data;
6298
c30fe89622df (svn r9119) [cpp_gui] -Sync with trunk (r9003:9100)
bjarni
parents: 6297
diff changeset
   637
};
1004
edbdc62fbf24 (svn r1503) Added feature:
miham
parents: 998
diff changeset
   638
assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(void_d));
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   639
6298
c30fe89622df (svn r9119) [cpp_gui] -Sync with trunk (r9003:9100)
bjarni
parents: 6297
diff changeset
   640
struct tree_d {
2596
d228e8ce6fcf (svn r3133) - static, const
tron
parents: 2549
diff changeset
   641
	uint16 base;
d228e8ce6fcf (svn r3133) - static, const
tron
parents: 2549
diff changeset
   642
	uint16 count;
6298
c30fe89622df (svn r9119) [cpp_gui] -Sync with trunk (r9003:9100)
bjarni
parents: 6297
diff changeset
   643
};
1004
edbdc62fbf24 (svn r1503) Added feature:
miham
parents: 998
diff changeset
   644
assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(tree_d));
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   645
6298
c30fe89622df (svn r9119) [cpp_gui] -Sync with trunk (r9003:9100)
bjarni
parents: 6297
diff changeset
   646
struct tooltips_d {
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   647
	StringID string_id;
4834
ddcf440d0ffd (svn r6758) -Feature: Add a measurement tool that will show dimensions and height
Darkvater
parents: 4800
diff changeset
   648
	byte paramcount;
ddcf440d0ffd (svn r6758) -Feature: Add a measurement tool that will show dimensions and height
Darkvater
parents: 4800
diff changeset
   649
	uint32 params[5];
6298
c30fe89622df (svn r9119) [cpp_gui] -Sync with trunk (r9003:9100)
bjarni
parents: 6297
diff changeset
   650
};
1004
edbdc62fbf24 (svn r1503) Added feature:
miham
parents: 998
diff changeset
   651
assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(tooltips_d));
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   652
6298
c30fe89622df (svn r9119) [cpp_gui] -Sync with trunk (r9003:9100)
bjarni
parents: 6297
diff changeset
   653
struct buildvehicle_d {
4800
009e3c6cea8a (svn r6722) -Codechange: [aircraft build window] moved aircraft build window to a file of it's own
bjarni
parents: 4790
diff changeset
   654
	byte vehicle_type;
5187
d1f4e447a7eb (svn r7299) -CodeChange: Train and Aircraft Build window GUI code simplified a bit:
KUDr
parents: 5124
diff changeset
   655
	union {
5838
9c3129cb019b (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents: 5726
diff changeset
   656
		RailTypeByte railtype;
6254
abc6ad7c035c (svn r8769) [cpp_gui] -Sync with trunk (r8730..r8768)
KUDr
parents: 6251
diff changeset
   657
		AirportFTAClass::Flags flags;
5187
d1f4e447a7eb (svn r7299) -CodeChange: Train and Aircraft Build window GUI code simplified a bit:
KUDr
parents: 5124
diff changeset
   658
	} filter;
6268
4b5241e5dd10 (svn r8938) [cpp_gui] -Sync with trunk (r8772..r8900)
bjarni
parents: 6267
diff changeset
   659
	byte sel_index;  ///< deprecated value, used for 'unified' ship and road
5187
d1f4e447a7eb (svn r7299) -CodeChange: Train and Aircraft Build window GUI code simplified a bit:
KUDr
parents: 5124
diff changeset
   660
	bool descending_sort_order;
4770
987ef30e5b45 (svn r6684) -Feature: [train build window] added sorting options for the engines
bjarni
parents: 4766
diff changeset
   661
	byte sort_criteria;
6032
cc75c53d40e9 (svn r8333) -Codechange: when invalidating a build window list, set a flag instead of rebuilding the list and then rebuild it the next time it's redrawn
bjarni
parents: 5838
diff changeset
   662
	bool regenerate_list;
2498
befad2fe53d2 (svn r3024) -Codechange: Another batch of replacements of int/uint/int16/byte/-1 with proper types and constants
tron
parents: 2448
diff changeset
   663
	EngineID sel_engine;
befad2fe53d2 (svn r3024) -Codechange: Another batch of replacements of int/uint/int16/byte/-1 with proper types and constants
tron
parents: 2448
diff changeset
   664
	EngineID rename_engine;
5187
d1f4e447a7eb (svn r7299) -CodeChange: Train and Aircraft Build window GUI code simplified a bit:
KUDr
parents: 5124
diff changeset
   665
	EngineList eng_list;
6298
c30fe89622df (svn r9119) [cpp_gui] -Sync with trunk (r9003:9100)
bjarni
parents: 6297
diff changeset
   666
};
4790
04df6a3f9b31 (svn r6712) -Code cleanup: renamed buildtrain_d to buildvehicle_d as it's used for all vehicle types
bjarni
parents: 4786
diff changeset
   667
assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(buildvehicle_d));
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   668
6298
c30fe89622df (svn r9119) [cpp_gui] -Sync with trunk (r9003:9100)
bjarni
parents: 6297
diff changeset
   669
struct replaceveh_d {
842
ebfd36603ab9 (svn r1323) Adding autoreplace feature
bjarni
parents: 826
diff changeset
   670
	byte sel_index[2];
2746
d96ce2fdc3e4 (svn r3291) - Codechange, Autoreplace: Replace int with EngineID and -1 with INVALID_ENGINE, as appropriate.
peter1138
parents: 2683
diff changeset
   671
	EngineID sel_engine[2];
842
ebfd36603ab9 (svn r1323) Adding autoreplace feature
bjarni
parents: 826
diff changeset
   672
	uint16 count[2];
6268
4b5241e5dd10 (svn r8938) [cpp_gui] -Sync with trunk (r8772..r8900)
bjarni
parents: 6267
diff changeset
   673
	bool wagon_btnstate; ///< true means engine is selected
6195
b90cf92697b9 (svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni
parents: 6075
diff changeset
   674
	EngineList list[2];
b90cf92697b9 (svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni
parents: 6075
diff changeset
   675
	bool update_left;
b90cf92697b9 (svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni
parents: 6075
diff changeset
   676
	bool update_right;
b90cf92697b9 (svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni
parents: 6075
diff changeset
   677
	bool init_lists;
6298
c30fe89622df (svn r9119) [cpp_gui] -Sync with trunk (r9003:9100)
bjarni
parents: 6297
diff changeset
   678
};
1004
edbdc62fbf24 (svn r1503) Added feature:
miham
parents: 998
diff changeset
   679
assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(replaceveh_d));
842
ebfd36603ab9 (svn r1323) Adding autoreplace feature
bjarni
parents: 826
diff changeset
   680
6298
c30fe89622df (svn r9119) [cpp_gui] -Sync with trunk (r9003:9100)
bjarni
parents: 6297
diff changeset
   681
struct depot_d {
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   682
	VehicleID sel;
4638
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents: 4635
diff changeset
   683
	byte type;
4739
bd535b408617 (svn r6651) -Coding feature: added the windowevent WE_INVALIDATE_DATA
bjarni
parents: 4730
diff changeset
   684
	bool generate_list;
4635
b9fb2f19eb64 (svn r6503) -Codechange: added a function to tell what vehicles a depot contains
bjarni
parents: 4634
diff changeset
   685
	uint16 engine_list_length;
b9fb2f19eb64 (svn r6503) -Codechange: added a function to tell what vehicles a depot contains
bjarni
parents: 4634
diff changeset
   686
	uint16 wagon_list_length;
b9fb2f19eb64 (svn r6503) -Codechange: added a function to tell what vehicles a depot contains
bjarni
parents: 4634
diff changeset
   687
	uint16 engine_count;
b9fb2f19eb64 (svn r6503) -Codechange: added a function to tell what vehicles a depot contains
bjarni
parents: 4634
diff changeset
   688
	uint16 wagon_count;
b9fb2f19eb64 (svn r6503) -Codechange: added a function to tell what vehicles a depot contains
bjarni
parents: 4634
diff changeset
   689
	Vehicle **vehicle_list;
b9fb2f19eb64 (svn r6503) -Codechange: added a function to tell what vehicles a depot contains
bjarni
parents: 4634
diff changeset
   690
	Vehicle **wagon_list;
6298
c30fe89622df (svn r9119) [cpp_gui] -Sync with trunk (r9003:9100)
bjarni
parents: 6297
diff changeset
   691
};
4638
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents: 4635
diff changeset
   692
assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(depot_d));
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   693
6298
c30fe89622df (svn r9119) [cpp_gui] -Sync with trunk (r9003:9100)
bjarni
parents: 6297
diff changeset
   694
struct order_d {
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   695
	int sel;
6298
c30fe89622df (svn r9119) [cpp_gui] -Sync with trunk (r9003:9100)
bjarni
parents: 6297
diff changeset
   696
};
1004
edbdc62fbf24 (svn r1503) Added feature:
miham
parents: 998
diff changeset
   697
assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(order_d));
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   698
6298
c30fe89622df (svn r9119) [cpp_gui] -Sync with trunk (r9003:9100)
bjarni
parents: 6297
diff changeset
   699
struct traindetails_d {
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   700
	byte tab;
6298
c30fe89622df (svn r9119) [cpp_gui] -Sync with trunk (r9003:9100)
bjarni
parents: 6297
diff changeset
   701
};
1004
edbdc62fbf24 (svn r1503) Added feature:
miham
parents: 998
diff changeset
   702
assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(traindetails_d));
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   703
6298
c30fe89622df (svn r9119) [cpp_gui] -Sync with trunk (r9003:9100)
bjarni
parents: 6297
diff changeset
   704
struct smallmap_d {
849
c6223dbdb202 (svn r1330) Increase size of some vars from int16 to int32 to guard against future overflows
tron
parents: 842
diff changeset
   705
	int32 scroll_x;
c6223dbdb202 (svn r1330) Increase size of some vars from int16 to int32 to guard against future overflows
tron
parents: 842
diff changeset
   706
	int32 scroll_y;
c6223dbdb202 (svn r1330) Increase size of some vars from int16 to int32 to guard against future overflows
tron
parents: 842
diff changeset
   707
	int32 subscroll;
6298
c30fe89622df (svn r9119) [cpp_gui] -Sync with trunk (r9003:9100)
bjarni
parents: 6297
diff changeset
   708
};
4318
fe085a1dd0ad (svn r5971) -Fix: wrong struct in assert_compile (thomasdev)
truelight
parents: 4300
diff changeset
   709
assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(smallmap_d));
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   710
6298
c30fe89622df (svn r9119) [cpp_gui] -Sync with trunk (r9003:9100)
bjarni
parents: 6297
diff changeset
   711
struct facesel_d {
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   712
	uint32 face;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   713
	byte gender;
6298
c30fe89622df (svn r9119) [cpp_gui] -Sync with trunk (r9003:9100)
bjarni
parents: 6297
diff changeset
   714
};
1004
edbdc62fbf24 (svn r1503) Added feature:
miham
parents: 998
diff changeset
   715
assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(facesel_d));
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   716
6298
c30fe89622df (svn r9119) [cpp_gui] -Sync with trunk (r9003:9100)
bjarni
parents: 6297
diff changeset
   717
struct refit_d {
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   718
	int sel;
4695
52419a88345d (svn r6602) - Feature: we now support NewGRF livery refits, as used by DBsetXL, amongst others. This requires a savegame bump to save the cargo subtype.
peter1138
parents: 4694
diff changeset
   719
	struct RefitOption *cargo;
4694
a4d2a3abe75c (svn r6601) - Codechange: Support cargo subtypes in the refit window. The refit window has been altered to support resizing and scrolling. Note that the cargo subtype isn't yet passed for actual refitting yet. (Based on mart3p's patch)
peter1138
parents: 4692
diff changeset
   720
	struct RefitList *list;
a4d2a3abe75c (svn r6601) - Codechange: Support cargo subtypes in the refit window. The refit window has been altered to support resizing and scrolling. Note that the cargo subtype isn't yet passed for actual refitting yet. (Based on mart3p's patch)
peter1138
parents: 4692
diff changeset
   721
	uint length;
4712
273ec3b182bf (svn r6624) -Feature: added ability to add refit commands to vehicle orders (can only be done in goto depot orders)
bjarni
parents: 4695
diff changeset
   722
	VehicleOrderID order;
6298
c30fe89622df (svn r9119) [cpp_gui] -Sync with trunk (r9003:9100)
bjarni
parents: 6297
diff changeset
   723
};
1004
edbdc62fbf24 (svn r1503) Added feature:
miham
parents: 998
diff changeset
   724
assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(refit_d));
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   725
6298
c30fe89622df (svn r9119) [cpp_gui] -Sync with trunk (r9003:9100)
bjarni
parents: 6297
diff changeset
   726
struct vp_d {
2116
cdfc27b696b7 (svn r2626) static, const, misc.
tron
parents: 2064
diff changeset
   727
	VehicleID follow_vehicle;
849
c6223dbdb202 (svn r1330) Increase size of some vars from int16 to int32 to guard against future overflows
tron
parents: 842
diff changeset
   728
	int32 scrollpos_x;
c6223dbdb202 (svn r1330) Increase size of some vars from int16 to int32 to guard against future overflows
tron
parents: 842
diff changeset
   729
	int32 scrollpos_y;
6298
c30fe89622df (svn r9119) [cpp_gui] -Sync with trunk (r9003:9100)
bjarni
parents: 6297
diff changeset
   730
};
5123
9eb435a37492 (svn r7203) -Cleanup: Donnu what Miham was smoking there, but removed it (assert_compile + 3)
Darkvater
parents: 5120
diff changeset
   731
assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(vp_d));
1004
edbdc62fbf24 (svn r1503) Added feature:
miham
parents: 998
diff changeset
   732
6268
4b5241e5dd10 (svn r8938) [cpp_gui] -Sync with trunk (r8772..r8900)
bjarni
parents: 6267
diff changeset
   733
/* vp2_d is the same as vp_d, except for the data_# values.. */
6298
c30fe89622df (svn r9119) [cpp_gui] -Sync with trunk (r9003:9100)
bjarni
parents: 6297
diff changeset
   734
struct vp2_d {
5123
9eb435a37492 (svn r7203) -Cleanup: Donnu what Miham was smoking there, but removed it (assert_compile + 3)
Darkvater
parents: 5120
diff changeset
   735
	VehicleID follow_vehicle;
1004
edbdc62fbf24 (svn r1503) Added feature:
miham
parents: 998
diff changeset
   736
	int32 scrollpos_x;
edbdc62fbf24 (svn r1503) Added feature:
miham
parents: 998
diff changeset
   737
	int32 scrollpos_y;
edbdc62fbf24 (svn r1503) Added feature:
miham
parents: 998
diff changeset
   738
	byte data_1;
edbdc62fbf24 (svn r1503) Added feature:
miham
parents: 998
diff changeset
   739
	byte data_2;
edbdc62fbf24 (svn r1503) Added feature:
miham
parents: 998
diff changeset
   740
	byte data_3;
6298
c30fe89622df (svn r9119) [cpp_gui] -Sync with trunk (r9003:9100)
bjarni
parents: 6297
diff changeset
   741
};
1004
edbdc62fbf24 (svn r1503) Added feature:
miham
parents: 998
diff changeset
   742
assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(vp2_d));
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   743
6298
c30fe89622df (svn r9119) [cpp_gui] -Sync with trunk (r9003:9100)
bjarni
parents: 6297
diff changeset
   744
struct news_d {
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   745
	uint16 follow_vehicle;
849
c6223dbdb202 (svn r1330) Increase size of some vars from int16 to int32 to guard against future overflows
tron
parents: 842
diff changeset
   746
	int32 scrollpos_x;
c6223dbdb202 (svn r1330) Increase size of some vars from int16 to int32 to guard against future overflows
tron
parents: 842
diff changeset
   747
	int32 scrollpos_y;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   748
	NewsItem *ni;
6298
c30fe89622df (svn r9119) [cpp_gui] -Sync with trunk (r9003:9100)
bjarni
parents: 6297
diff changeset
   749
};
1004
edbdc62fbf24 (svn r1503) Added feature:
miham
parents: 998
diff changeset
   750
assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(news_d));
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   751
6298
c30fe89622df (svn r9119) [cpp_gui] -Sync with trunk (r9003:9100)
bjarni
parents: 6297
diff changeset
   752
struct highscore_d {
998
d9dc257b8949 (svn r1496) -Fix: highscore no longer crashes in network games with a dedicated server. At the end of the game (can only be set by the server) the highscore is shown for the top5 companies of that game
darkvater
parents: 983
diff changeset
   753
	uint32 background_img;
d9dc257b8949 (svn r1496) -Fix: highscore no longer crashes in network games with a dedicated server. At the end of the game (can only be set by the server) the highscore is shown for the top5 companies of that game
darkvater
parents: 983
diff changeset
   754
	int8 rank;
6298
c30fe89622df (svn r9119) [cpp_gui] -Sync with trunk (r9003:9100)
bjarni
parents: 6297
diff changeset
   755
};
1004
edbdc62fbf24 (svn r1503) Added feature:
miham
parents: 998
diff changeset
   756
assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(highscore_d));
998
d9dc257b8949 (svn r1496) -Fix: highscore no longer crashes in network games with a dedicated server. At the end of the game (can only be set by the server) the highscore is shown for the top5 companies of that game
darkvater
parents: 983
diff changeset
   757
6298
c30fe89622df (svn r9119) [cpp_gui] -Sync with trunk (r9003:9100)
bjarni
parents: 6297
diff changeset
   758
struct scroller_d {
998
d9dc257b8949 (svn r1496) -Fix: highscore no longer crashes in network games with a dedicated server. At the end of the game (can only be set by the server) the highscore is shown for the top5 companies of that game
darkvater
parents: 983
diff changeset
   759
	int height;
d9dc257b8949 (svn r1496) -Fix: highscore no longer crashes in network games with a dedicated server. At the end of the game (can only be set by the server) the highscore is shown for the top5 companies of that game
darkvater
parents: 983
diff changeset
   760
	uint16 counter;
6298
c30fe89622df (svn r9119) [cpp_gui] -Sync with trunk (r9003:9100)
bjarni
parents: 6297
diff changeset
   761
};
1004
edbdc62fbf24 (svn r1503) Added feature:
miham
parents: 998
diff changeset
   762
assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(scroller_d));
859
46839573bed8 (svn r1340) -Feature: scrolling credits list...finally! Hope nobody gets offended if I forgot them.
darkvater
parents: 849
diff changeset
   763
6298
c30fe89622df (svn r9119) [cpp_gui] -Sync with trunk (r9003:9100)
bjarni
parents: 6297
diff changeset
   764
enum SortListFlags {
6285
187e3ef04cc9 (svn r9004) [cpp_gui] -Sync with trunk (r8900..r9003)
KUDr
parents: 6284
diff changeset
   765
	VL_NONE    = 0x00,  ///< no sort
6268
4b5241e5dd10 (svn r8938) [cpp_gui] -Sync with trunk (r8772..r8900)
bjarni
parents: 6267
diff changeset
   766
	VL_DESC    = 0x01,  ///< sort descending or ascending
4b5241e5dd10 (svn r8938) [cpp_gui] -Sync with trunk (r8772..r8900)
bjarni
parents: 6267
diff changeset
   767
	VL_RESORT  = 0x02,  ///< instruct the code to resort the list in the next loop
4b5241e5dd10 (svn r8938) [cpp_gui] -Sync with trunk (r8772..r8900)
bjarni
parents: 6267
diff changeset
   768
	VL_REBUILD = 0x04,  ///< create sort-listing to use for qsort and friends
5838
9c3129cb019b (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents: 5726
diff changeset
   769
	VL_END     = 0x08
6298
c30fe89622df (svn r9119) [cpp_gui] -Sync with trunk (r9003:9100)
bjarni
parents: 6297
diff changeset
   770
};
588
1b60458bdc29 (svn r1009) -Feature: per-station vehicle lists
tron
parents: 543
diff changeset
   771
5838
9c3129cb019b (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents: 5726
diff changeset
   772
DECLARE_ENUM_AS_BIT_SET(SortListFlags);
9c3129cb019b (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents: 5726
diff changeset
   773
6298
c30fe89622df (svn r9119) [cpp_gui] -Sync with trunk (r9003:9100)
bjarni
parents: 6297
diff changeset
   774
struct Listing {
6268
4b5241e5dd10 (svn r8938) [cpp_gui] -Sync with trunk (r8772..r8900)
bjarni
parents: 6267
diff changeset
   775
	bool order;    ///< Ascending/descending
4b5241e5dd10 (svn r8938) [cpp_gui] -Sync with trunk (r8772..r8900)
bjarni
parents: 6267
diff changeset
   776
	byte criteria; ///< Sorting criteria
6298
c30fe89622df (svn r9119) [cpp_gui] -Sync with trunk (r9003:9100)
bjarni
parents: 6297
diff changeset
   777
};
588
1b60458bdc29 (svn r1009) -Feature: per-station vehicle lists
tron
parents: 543
diff changeset
   778
6298
c30fe89622df (svn r9119) [cpp_gui] -Sync with trunk (r9003:9100)
bjarni
parents: 6297
diff changeset
   779
struct list_d {
6268
4b5241e5dd10 (svn r8938) [cpp_gui] -Sync with trunk (r8772..r8900)
bjarni
parents: 6267
diff changeset
   780
	uint16 list_length;  ///< length of the list being sorted
4b5241e5dd10 (svn r8938) [cpp_gui] -Sync with trunk (r8772..r8900)
bjarni
parents: 6267
diff changeset
   781
	byte sort_type;      ///< what criteria to sort on
4b5241e5dd10 (svn r8938) [cpp_gui] -Sync with trunk (r8772..r8900)
bjarni
parents: 6267
diff changeset
   782
	SortListFlags flags; ///< used to control sorting/resorting/etc.
4b5241e5dd10 (svn r8938) [cpp_gui] -Sync with trunk (r8772..r8900)
bjarni
parents: 6267
diff changeset
   783
	uint16 resort_timer; ///< resort list after a given amount of ticks if set
6298
c30fe89622df (svn r9119) [cpp_gui] -Sync with trunk (r9003:9100)
bjarni
parents: 6297
diff changeset
   784
};
2888
0972346d11a8 (svn r3441) - Feature: Allow the network game list to be sorted (by name/clients/compatibility ascending/descending)
Darkvater
parents: 2887
diff changeset
   785
assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(list_d));
0972346d11a8 (svn r3441) - Feature: Allow the network game list to be sorted (by name/clients/compatibility ascending/descending)
Darkvater
parents: 2887
diff changeset
   786
6298
c30fe89622df (svn r9119) [cpp_gui] -Sync with trunk (r9003:9100)
bjarni
parents: 6297
diff changeset
   787
struct message_d {
1648
747061dca705 (svn r2152) - Fix: Chatbar in MP games is now on-top of the news window.
darkvater
parents: 1570
diff changeset
   788
	int msg;
747061dca705 (svn r2152) - Fix: Chatbar in MP games is now on-top of the news window.
darkvater
parents: 1570
diff changeset
   789
	int wparam;
747061dca705 (svn r2152) - Fix: Chatbar in MP games is now on-top of the news window.
darkvater
parents: 1570
diff changeset
   790
	int lparam;
6298
c30fe89622df (svn r9119) [cpp_gui] -Sync with trunk (r9003:9100)
bjarni
parents: 6297
diff changeset
   791
};
1648
747061dca705 (svn r2152) - Fix: Chatbar in MP games is now on-top of the news window.
darkvater
parents: 1570
diff changeset
   792
assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(message_d));
747061dca705 (svn r2152) - Fix: Chatbar in MP games is now on-top of the news window.
darkvater
parents: 1570
diff changeset
   793
6298
c30fe89622df (svn r9119) [cpp_gui] -Sync with trunk (r9003:9100)
bjarni
parents: 6297
diff changeset
   794
struct dropdown_d {
2683
6f67fcf73873 (svn r3225) - Fix for "[ 1359165 ] Autoreplace problem with r3171 and later" -- Move the disabled/hidden bits to custom data in window struct.
peter1138
parents: 2636
diff changeset
   795
	uint32 disabled_state;
6f67fcf73873 (svn r3225) - Fix for "[ 1359165 ] Autoreplace problem with r3171 and later" -- Move the disabled/hidden bits to custom data in window struct.
peter1138
parents: 2636
diff changeset
   796
	uint32 hidden_state;
2636
e2bfdc3e82b6 (svn r3178) - Codechange: move static _dropdown_* vars into the window custom data, giving var1 and var2 more meaningful names.
peter1138
parents: 2634
diff changeset
   797
	WindowClass parent_wnd_class;
e2bfdc3e82b6 (svn r3178) - Codechange: move static _dropdown_* vars into the window custom data, giving var1 and var2 more meaningful names.
peter1138
parents: 2634
diff changeset
   798
	WindowNumber parent_wnd_num;
e2bfdc3e82b6 (svn r3178) - Codechange: move static _dropdown_* vars into the window custom data, giving var1 and var2 more meaningful names.
peter1138
parents: 2634
diff changeset
   799
	byte parent_button;
e2bfdc3e82b6 (svn r3178) - Codechange: move static _dropdown_* vars into the window custom data, giving var1 and var2 more meaningful names.
peter1138
parents: 2634
diff changeset
   800
	byte num_items;
e2bfdc3e82b6 (svn r3178) - Codechange: move static _dropdown_* vars into the window custom data, giving var1 and var2 more meaningful names.
peter1138
parents: 2634
diff changeset
   801
	byte selected_index;
e2bfdc3e82b6 (svn r3178) - Codechange: move static _dropdown_* vars into the window custom data, giving var1 and var2 more meaningful names.
peter1138
parents: 2634
diff changeset
   802
	const StringID *items;
e2bfdc3e82b6 (svn r3178) - Codechange: move static _dropdown_* vars into the window custom data, giving var1 and var2 more meaningful names.
peter1138
parents: 2634
diff changeset
   803
	byte click_delay;
e2bfdc3e82b6 (svn r3178) - Codechange: move static _dropdown_* vars into the window custom data, giving var1 and var2 more meaningful names.
peter1138
parents: 2634
diff changeset
   804
	bool drag_mode;
6298
c30fe89622df (svn r9119) [cpp_gui] -Sync with trunk (r9003:9100)
bjarni
parents: 6297
diff changeset
   805
};
2636
e2bfdc3e82b6 (svn r3178) - Codechange: move static _dropdown_* vars into the window custom data, giving var1 and var2 more meaningful names.
peter1138
parents: 2634
diff changeset
   806
assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(dropdown_d));
e2bfdc3e82b6 (svn r3178) - Codechange: move static _dropdown_* vars into the window custom data, giving var1 and var2 more meaningful names.
peter1138
parents: 2634
diff changeset
   807
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   808
6268
4b5241e5dd10 (svn r8938) [cpp_gui] -Sync with trunk (r8772..r8900)
bjarni
parents: 6267
diff changeset
   809
/* window.cpp */
6258
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents: 6256
diff changeset
   810
//void CallWindowEventNP(BaseWindow *w, int event);
6298
c30fe89622df (svn r9119) [cpp_gui] -Sync with trunk (r9003:9100)
bjarni
parents: 6297
diff changeset
   811
void CallWindowTickEvent();
6258
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents: 6256
diff changeset
   812
//void SetWindowDirty(const BaseWindow *w);
5838
9c3129cb019b (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents: 5726
diff changeset
   813
void SendWindowMessage(WindowClass wnd_class, WindowNumber wnd_num, int msg, int wparam, int lparam);
9c3129cb019b (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents: 5726
diff changeset
   814
void SendWindowMessageClass(WindowClass wnd_class, int msg, int wparam, int lparam);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   815
6258
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents: 6256
diff changeset
   816
//BaseWindow *FindWindowById(WindowClass cls, WindowNumber number);
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents: 6256
diff changeset
   817
//void DeleteWindow(BaseWindow *w);
5077
587701a06b6a (svn r7138) -Fix: [vehicle list windows] fixed a rare crash where having some (not all) vehicle list windows open for a player, that goes bankrupt would crash the game
bjarni
parents: 5072
diff changeset
   818
void DeletePlayerWindows(PlayerID pi);
587701a06b6a (svn r7138) -Fix: [vehicle list windows] fixed a rare crash where having some (not all) vehicle list windows open for a player, that goes bankrupt would crash the game
bjarni
parents: 5072
diff changeset
   819
void ChangeWindowOwner(PlayerID old_player, PlayerID new_player);
6258
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents: 6256
diff changeset
   820
//BaseWindow *BringWindowToFrontById(WindowClass cls, WindowNumber number);
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents: 6256
diff changeset
   821
//BaseWindow *FindWindowFromPt(int x, int y);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   822
6258
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents: 6256
diff changeset
   823
//BaseWindow *AllocateWindow(
6235
5077e6ed3788 (svn r8683) [cpp_gui] -Codechange: first steps towards OO GUI (together with Bjarni) without changes in the logic
KUDr
parents: 6224
diff changeset
   824
//							int x,
5077e6ed3788 (svn r8683) [cpp_gui] -Codechange: first steps towards OO GUI (together with Bjarni) without changes in the logic
KUDr
parents: 6224
diff changeset
   825
//							int y,
5077e6ed3788 (svn r8683) [cpp_gui] -Codechange: first steps towards OO GUI (together with Bjarni) without changes in the logic
KUDr
parents: 6224
diff changeset
   826
//							int width,
5077e6ed3788 (svn r8683) [cpp_gui] -Codechange: first steps towards OO GUI (together with Bjarni) without changes in the logic
KUDr
parents: 6224
diff changeset
   827
//							int height,
5077e6ed3788 (svn r8683) [cpp_gui] -Codechange: first steps towards OO GUI (together with Bjarni) without changes in the logic
KUDr
parents: 6224
diff changeset
   828
//							WindowProc *proc,
5077e6ed3788 (svn r8683) [cpp_gui] -Codechange: first steps towards OO GUI (together with Bjarni) without changes in the logic
KUDr
parents: 6224
diff changeset
   829
//							WindowClass cls,
5077e6ed3788 (svn r8683) [cpp_gui] -Codechange: first steps towards OO GUI (together with Bjarni) without changes in the logic
KUDr
parents: 6224
diff changeset
   830
//							const Widget *widget);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   831
6258
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents: 6256
diff changeset
   832
//BaseWindow *AllocateWindowDesc(const WindowDesc *desc);
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents: 6256
diff changeset
   833
//BaseWindow *AllocateWindowDescFront(const WindowDesc *desc, int window_number);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   834
6258
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents: 6256
diff changeset
   835
//void DrawWindowViewport(const BaseWindow *w);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   836
4692
fdccb9b2dbcd (svn r6599) -Codechange: Add accessors around the members click/disabled/hidden_state of Window
belugas
parents: 4638
diff changeset
   837
/**
fdccb9b2dbcd (svn r6599) -Codechange: Add accessors around the members click/disabled/hidden_state of Window
belugas
parents: 4638
diff changeset
   838
 * Sets the enabled/disabled status of a widget.
fdccb9b2dbcd (svn r6599) -Codechange: Add accessors around the members click/disabled/hidden_state of Window
belugas
parents: 4638
diff changeset
   839
 * By default, widgets are enabled.
fdccb9b2dbcd (svn r6599) -Codechange: Add accessors around the members click/disabled/hidden_state of Window
belugas
parents: 4638
diff changeset
   840
 * On certain conditions, they have to be disabled.
6258
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents: 6256
diff changeset
   841
 * @param w : BaseWindow on which the widget is located
4692
fdccb9b2dbcd (svn r6599) -Codechange: Add accessors around the members click/disabled/hidden_state of Window
belugas
parents: 4638
diff changeset
   842
 * @param widget_index : index of this widget in the window
fdccb9b2dbcd (svn r6599) -Codechange: Add accessors around the members click/disabled/hidden_state of Window
belugas
parents: 4638
diff changeset
   843
 * @param disab_stat : status to use ie: disabled = true, enabled = false
fdccb9b2dbcd (svn r6599) -Codechange: Add accessors around the members click/disabled/hidden_state of Window
belugas
parents: 4638
diff changeset
   844
 */
6258
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents: 6256
diff changeset
   845
inline void BaseWindow::SetWidgetDisabledState(byte widget_index, bool disab_stat)
4692
fdccb9b2dbcd (svn r6599) -Codechange: Add accessors around the members click/disabled/hidden_state of Window
belugas
parents: 4638
diff changeset
   846
{
6246
2a4c2c4d66f0 (svn r8713) [cpp_gui] -Codechange: SetWindowWidgetDisabledState turned into Window method
KUDr
parents: 6245
diff changeset
   847
	assert(widget_index < widget_count);
6258
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents: 6256
diff changeset
   848
	SB(widget[widget_index].m_display_flags, WIDG_DISABLED, 1, !!disab_stat);
4692
fdccb9b2dbcd (svn r6599) -Codechange: Add accessors around the members click/disabled/hidden_state of Window
belugas
parents: 4638
diff changeset
   849
}
fdccb9b2dbcd (svn r6599) -Codechange: Add accessors around the members click/disabled/hidden_state of Window
belugas
parents: 4638
diff changeset
   850
fdccb9b2dbcd (svn r6599) -Codechange: Add accessors around the members click/disabled/hidden_state of Window
belugas
parents: 4638
diff changeset
   851
/**
fdccb9b2dbcd (svn r6599) -Codechange: Add accessors around the members click/disabled/hidden_state of Window
belugas
parents: 4638
diff changeset
   852
 * Sets a widget to disabled.
6258
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents: 6256
diff changeset
   853
 * @param w : BaseWindow on which the widget is located
4692
fdccb9b2dbcd (svn r6599) -Codechange: Add accessors around the members click/disabled/hidden_state of Window
belugas
parents: 4638
diff changeset
   854
 * @param widget_index : index of this widget in the window
fdccb9b2dbcd (svn r6599) -Codechange: Add accessors around the members click/disabled/hidden_state of Window
belugas
parents: 4638
diff changeset
   855
 */
6258
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents: 6256
diff changeset
   856
inline void BaseWindow::DisableWidget(byte widget_index)
4692
fdccb9b2dbcd (svn r6599) -Codechange: Add accessors around the members click/disabled/hidden_state of Window
belugas
parents: 4638
diff changeset
   857
{
6247
67e881450cf3 (svn r8714) [cpp_gui] -Codechange: DisableWindowWidget() and EnableWindowWidget() turned into Window methods
KUDr
parents: 6246
diff changeset
   858
	SetWidgetDisabledState(widget_index, true);
4692
fdccb9b2dbcd (svn r6599) -Codechange: Add accessors around the members click/disabled/hidden_state of Window
belugas
parents: 4638
diff changeset
   859
}
fdccb9b2dbcd (svn r6599) -Codechange: Add accessors around the members click/disabled/hidden_state of Window
belugas
parents: 4638
diff changeset
   860
fdccb9b2dbcd (svn r6599) -Codechange: Add accessors around the members click/disabled/hidden_state of Window
belugas
parents: 4638
diff changeset
   861
/**
fdccb9b2dbcd (svn r6599) -Codechange: Add accessors around the members click/disabled/hidden_state of Window
belugas
parents: 4638
diff changeset
   862
 * Sets a widget to Enabled.
6258
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents: 6256
diff changeset
   863
 * @param w : BaseWindow on which the widget is located
4692
fdccb9b2dbcd (svn r6599) -Codechange: Add accessors around the members click/disabled/hidden_state of Window
belugas
parents: 4638
diff changeset
   864
 * @param widget_index : index of this widget in the window
fdccb9b2dbcd (svn r6599) -Codechange: Add accessors around the members click/disabled/hidden_state of Window
belugas
parents: 4638
diff changeset
   865
 */
6258
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents: 6256
diff changeset
   866
inline void BaseWindow::EnableWidget(byte widget_index)
4692
fdccb9b2dbcd (svn r6599) -Codechange: Add accessors around the members click/disabled/hidden_state of Window
belugas
parents: 4638
diff changeset
   867
{
6247
67e881450cf3 (svn r8714) [cpp_gui] -Codechange: DisableWindowWidget() and EnableWindowWidget() turned into Window methods
KUDr
parents: 6246
diff changeset
   868
	SetWidgetDisabledState(widget_index, false);
4692
fdccb9b2dbcd (svn r6599) -Codechange: Add accessors around the members click/disabled/hidden_state of Window
belugas
parents: 4638
diff changeset
   869
}
fdccb9b2dbcd (svn r6599) -Codechange: Add accessors around the members click/disabled/hidden_state of Window
belugas
parents: 4638
diff changeset
   870
fdccb9b2dbcd (svn r6599) -Codechange: Add accessors around the members click/disabled/hidden_state of Window
belugas
parents: 4638
diff changeset
   871
/**
fdccb9b2dbcd (svn r6599) -Codechange: Add accessors around the members click/disabled/hidden_state of Window
belugas
parents: 4638
diff changeset
   872
 * Gets the enabled/disabled status of a widget.
6258
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents: 6256
diff changeset
   873
 * @param w : BaseWindow on which the widget is located
4692
fdccb9b2dbcd (svn r6599) -Codechange: Add accessors around the members click/disabled/hidden_state of Window
belugas
parents: 4638
diff changeset
   874
 * @param widget_index : index of this widget in the window
fdccb9b2dbcd (svn r6599) -Codechange: Add accessors around the members click/disabled/hidden_state of Window
belugas
parents: 4638
diff changeset
   875
 * @return status of the widget ie: disabled = true, enabled = false
fdccb9b2dbcd (svn r6599) -Codechange: Add accessors around the members click/disabled/hidden_state of Window
belugas
parents: 4638
diff changeset
   876
 */
6258
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents: 6256
diff changeset
   877
inline bool BaseWindow::IsWidgetDisabled(byte widget_index) const
4692
fdccb9b2dbcd (svn r6599) -Codechange: Add accessors around the members click/disabled/hidden_state of Window
belugas
parents: 4638
diff changeset
   878
{
6248
24583caadfee (svn r8716) [cpp_gui] -Codechange: IsWindowWidgetDisabled() turned into Window method
KUDr
parents: 6247
diff changeset
   879
	assert(widget_index < widget_count);
6258
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents: 6256
diff changeset
   880
	return HASBIT(widget[widget_index].m_display_flags, WIDG_DISABLED);
4692
fdccb9b2dbcd (svn r6599) -Codechange: Add accessors around the members click/disabled/hidden_state of Window
belugas
parents: 4638
diff changeset
   881
}
fdccb9b2dbcd (svn r6599) -Codechange: Add accessors around the members click/disabled/hidden_state of Window
belugas
parents: 4638
diff changeset
   882
fdccb9b2dbcd (svn r6599) -Codechange: Add accessors around the members click/disabled/hidden_state of Window
belugas
parents: 4638
diff changeset
   883
/**
fdccb9b2dbcd (svn r6599) -Codechange: Add accessors around the members click/disabled/hidden_state of Window
belugas
parents: 4638
diff changeset
   884
 * Sets the hidden/shown status of a widget.
fdccb9b2dbcd (svn r6599) -Codechange: Add accessors around the members click/disabled/hidden_state of Window
belugas
parents: 4638
diff changeset
   885
 * By default, widgets are visible.
fdccb9b2dbcd (svn r6599) -Codechange: Add accessors around the members click/disabled/hidden_state of Window
belugas
parents: 4638
diff changeset
   886
 * On certain conditions, they have to be hidden.
6258
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents: 6256
diff changeset
   887
 * @param w BaseWindow on which the widget is located
4692
fdccb9b2dbcd (svn r6599) -Codechange: Add accessors around the members click/disabled/hidden_state of Window
belugas
parents: 4638
diff changeset
   888
 * @param widget_index index of this widget in the window
fdccb9b2dbcd (svn r6599) -Codechange: Add accessors around the members click/disabled/hidden_state of Window
belugas
parents: 4638
diff changeset
   889
 * @param hidden_stat status to use ie. hidden = true, visible = false
fdccb9b2dbcd (svn r6599) -Codechange: Add accessors around the members click/disabled/hidden_state of Window
belugas
parents: 4638
diff changeset
   890
 */
6258
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents: 6256
diff changeset
   891
inline void BaseWindow::SetWidgetHiddenState(byte widget_index, bool hidden_stat)
4692
fdccb9b2dbcd (svn r6599) -Codechange: Add accessors around the members click/disabled/hidden_state of Window
belugas
parents: 4638
diff changeset
   892
{
6250
5135b200b376 (svn r8718) [cpp_gui] -Codechange: SetWindowWidgetHiddenState(), HideWindowWidget(), ShowWindowWidget() and IsWindowWidgetHidden() turned into Window methods
KUDr
parents: 6249
diff changeset
   893
	assert(widget_index < widget_count);
6258
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents: 6256
diff changeset
   894
	SB(widget[widget_index].m_display_flags, WIDG_HIDDEN, 1, !!hidden_stat);
4692
fdccb9b2dbcd (svn r6599) -Codechange: Add accessors around the members click/disabled/hidden_state of Window
belugas
parents: 4638
diff changeset
   895
}
fdccb9b2dbcd (svn r6599) -Codechange: Add accessors around the members click/disabled/hidden_state of Window
belugas
parents: 4638
diff changeset
   896
fdccb9b2dbcd (svn r6599) -Codechange: Add accessors around the members click/disabled/hidden_state of Window
belugas
parents: 4638
diff changeset
   897
/**
fdccb9b2dbcd (svn r6599) -Codechange: Add accessors around the members click/disabled/hidden_state of Window
belugas
parents: 4638
diff changeset
   898
 * Sets a widget hidden.
6258
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents: 6256
diff changeset
   899
 * @param w : BaseWindow on which the widget is located
4692
fdccb9b2dbcd (svn r6599) -Codechange: Add accessors around the members click/disabled/hidden_state of Window
belugas
parents: 4638
diff changeset
   900
 * @param widget_index : index of this widget in the window
fdccb9b2dbcd (svn r6599) -Codechange: Add accessors around the members click/disabled/hidden_state of Window
belugas
parents: 4638
diff changeset
   901
 */
6258
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents: 6256
diff changeset
   902
inline void BaseWindow::HideWidget(byte widget_index)
4692
fdccb9b2dbcd (svn r6599) -Codechange: Add accessors around the members click/disabled/hidden_state of Window
belugas
parents: 4638
diff changeset
   903
{
6250
5135b200b376 (svn r8718) [cpp_gui] -Codechange: SetWindowWidgetHiddenState(), HideWindowWidget(), ShowWindowWidget() and IsWindowWidgetHidden() turned into Window methods
KUDr
parents: 6249
diff changeset
   904
	SetWidgetHiddenState(widget_index, true);
4692
fdccb9b2dbcd (svn r6599) -Codechange: Add accessors around the members click/disabled/hidden_state of Window
belugas
parents: 4638
diff changeset
   905
}
fdccb9b2dbcd (svn r6599) -Codechange: Add accessors around the members click/disabled/hidden_state of Window
belugas
parents: 4638
diff changeset
   906
fdccb9b2dbcd (svn r6599) -Codechange: Add accessors around the members click/disabled/hidden_state of Window
belugas
parents: 4638
diff changeset
   907
/**
fdccb9b2dbcd (svn r6599) -Codechange: Add accessors around the members click/disabled/hidden_state of Window
belugas
parents: 4638
diff changeset
   908
 * Sets a widget visible.
6258
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents: 6256
diff changeset
   909
 * @param w : BaseWindow on which the widget is located
4692
fdccb9b2dbcd (svn r6599) -Codechange: Add accessors around the members click/disabled/hidden_state of Window
belugas
parents: 4638
diff changeset
   910
 * @param widget_index : index of this widget in the window
fdccb9b2dbcd (svn r6599) -Codechange: Add accessors around the members click/disabled/hidden_state of Window
belugas
parents: 4638
diff changeset
   911
 */
6258
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents: 6256
diff changeset
   912
inline void BaseWindow::ShowWidget(byte widget_index)
4692
fdccb9b2dbcd (svn r6599) -Codechange: Add accessors around the members click/disabled/hidden_state of Window
belugas
parents: 4638
diff changeset
   913
{
6250
5135b200b376 (svn r8718) [cpp_gui] -Codechange: SetWindowWidgetHiddenState(), HideWindowWidget(), ShowWindowWidget() and IsWindowWidgetHidden() turned into Window methods
KUDr
parents: 6249
diff changeset
   914
	SetWidgetHiddenState(widget_index, false);
4692
fdccb9b2dbcd (svn r6599) -Codechange: Add accessors around the members click/disabled/hidden_state of Window
belugas
parents: 4638
diff changeset
   915
}
fdccb9b2dbcd (svn r6599) -Codechange: Add accessors around the members click/disabled/hidden_state of Window
belugas
parents: 4638
diff changeset
   916
fdccb9b2dbcd (svn r6599) -Codechange: Add accessors around the members click/disabled/hidden_state of Window
belugas
parents: 4638
diff changeset
   917
/**
fdccb9b2dbcd (svn r6599) -Codechange: Add accessors around the members click/disabled/hidden_state of Window
belugas
parents: 4638
diff changeset
   918
 * Gets the visibility of a widget.
6258
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents: 6256
diff changeset
   919
 * @param w : BaseWindow on which the widget is located
4692
fdccb9b2dbcd (svn r6599) -Codechange: Add accessors around the members click/disabled/hidden_state of Window
belugas
parents: 4638
diff changeset
   920
 * @param widget_index : index of this widget in the window
fdccb9b2dbcd (svn r6599) -Codechange: Add accessors around the members click/disabled/hidden_state of Window
belugas
parents: 4638
diff changeset
   921
 * @return status of the widget ie: hidden = true, visible = false
fdccb9b2dbcd (svn r6599) -Codechange: Add accessors around the members click/disabled/hidden_state of Window
belugas
parents: 4638
diff changeset
   922
 */
6258
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents: 6256
diff changeset
   923
inline bool BaseWindow::IsWidgetHidden(byte widget_index) const
4692
fdccb9b2dbcd (svn r6599) -Codechange: Add accessors around the members click/disabled/hidden_state of Window
belugas
parents: 4638
diff changeset
   924
{
6250
5135b200b376 (svn r8718) [cpp_gui] -Codechange: SetWindowWidgetHiddenState(), HideWindowWidget(), ShowWindowWidget() and IsWindowWidgetHidden() turned into Window methods
KUDr
parents: 6249
diff changeset
   925
	assert(widget_index < widget_count);
6258
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents: 6256
diff changeset
   926
	return HASBIT(widget[widget_index].m_display_flags, WIDG_HIDDEN);
4692
fdccb9b2dbcd (svn r6599) -Codechange: Add accessors around the members click/disabled/hidden_state of Window
belugas
parents: 4638
diff changeset
   927
}
fdccb9b2dbcd (svn r6599) -Codechange: Add accessors around the members click/disabled/hidden_state of Window
belugas
parents: 4638
diff changeset
   928
fdccb9b2dbcd (svn r6599) -Codechange: Add accessors around the members click/disabled/hidden_state of Window
belugas
parents: 4638
diff changeset
   929
/**
fdccb9b2dbcd (svn r6599) -Codechange: Add accessors around the members click/disabled/hidden_state of Window
belugas
parents: 4638
diff changeset
   930
 * Sets the lowered/raised status of a widget.
6258
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents: 6256
diff changeset
   931
 * @param w : BaseWindow on which the widget is located
4692
fdccb9b2dbcd (svn r6599) -Codechange: Add accessors around the members click/disabled/hidden_state of Window
belugas
parents: 4638
diff changeset
   932
 * @param widget_index : index of this widget in the window
6307
f40e88cff863 (svn r9639) [cpp_gui] -Sync with trunk (r9476:9633)
KUDr
parents: 6301
diff changeset
   933
 * @param lowered_stat : status to use ie: lowered = true, raised = false
4692
fdccb9b2dbcd (svn r6599) -Codechange: Add accessors around the members click/disabled/hidden_state of Window
belugas
parents: 4638
diff changeset
   934
 */
6258
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents: 6256
diff changeset
   935
inline void BaseWindow::SetWidgetLoweredState(byte widget_index, bool lowered_stat)
4692
fdccb9b2dbcd (svn r6599) -Codechange: Add accessors around the members click/disabled/hidden_state of Window
belugas
parents: 4638
diff changeset
   936
{
6251
cd413fa2e252 (svn r8720) [cpp_gui] -Codechange: SetWindowWidgetLoweredState(), ToggleWidgetLoweredState(), LowerWindowWidget(), RaiseWindowWidget() and IsWindowWidgetLowered() turned into Window methods
KUDr
parents: 6250
diff changeset
   937
	assert(widget_index < widget_count);
6258
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents: 6256
diff changeset
   938
	SB(widget[widget_index].m_display_flags, WIDG_LOWERED, 1, !!lowered_stat);
4692
fdccb9b2dbcd (svn r6599) -Codechange: Add accessors around the members click/disabled/hidden_state of Window
belugas
parents: 4638
diff changeset
   939
}
fdccb9b2dbcd (svn r6599) -Codechange: Add accessors around the members click/disabled/hidden_state of Window
belugas
parents: 4638
diff changeset
   940
fdccb9b2dbcd (svn r6599) -Codechange: Add accessors around the members click/disabled/hidden_state of Window
belugas
parents: 4638
diff changeset
   941
/**
fdccb9b2dbcd (svn r6599) -Codechange: Add accessors around the members click/disabled/hidden_state of Window
belugas
parents: 4638
diff changeset
   942
 * Invert the lowered/raised  status of a widget.
6258
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents: 6256
diff changeset
   943
 * @param w : BaseWindow on which the widget is located
4692
fdccb9b2dbcd (svn r6599) -Codechange: Add accessors around the members click/disabled/hidden_state of Window
belugas
parents: 4638
diff changeset
   944
 * @param widget_index : index of this widget in the window
fdccb9b2dbcd (svn r6599) -Codechange: Add accessors around the members click/disabled/hidden_state of Window
belugas
parents: 4638
diff changeset
   945
 */
6258
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents: 6256
diff changeset
   946
inline void BaseWindow::ToggleWidgetLoweredState(byte widget_index)
4692
fdccb9b2dbcd (svn r6599) -Codechange: Add accessors around the members click/disabled/hidden_state of Window
belugas
parents: 4638
diff changeset
   947
{
6251
cd413fa2e252 (svn r8720) [cpp_gui] -Codechange: SetWindowWidgetLoweredState(), ToggleWidgetLoweredState(), LowerWindowWidget(), RaiseWindowWidget() and IsWindowWidgetLowered() turned into Window methods
KUDr
parents: 6250
diff changeset
   948
	assert(widget_index < widget_count);
6258
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents: 6256
diff changeset
   949
	TOGGLEBIT(widget[widget_index].m_display_flags, WIDG_LOWERED);
4692
fdccb9b2dbcd (svn r6599) -Codechange: Add accessors around the members click/disabled/hidden_state of Window
belugas
parents: 4638
diff changeset
   950
}
fdccb9b2dbcd (svn r6599) -Codechange: Add accessors around the members click/disabled/hidden_state of Window
belugas
parents: 4638
diff changeset
   951
fdccb9b2dbcd (svn r6599) -Codechange: Add accessors around the members click/disabled/hidden_state of Window
belugas
parents: 4638
diff changeset
   952
/**
fdccb9b2dbcd (svn r6599) -Codechange: Add accessors around the members click/disabled/hidden_state of Window
belugas
parents: 4638
diff changeset
   953
 * Marks a widget as lowered.
6258
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents: 6256
diff changeset
   954
 * @param w : BaseWindow on which the widget is located
4692
fdccb9b2dbcd (svn r6599) -Codechange: Add accessors around the members click/disabled/hidden_state of Window
belugas
parents: 4638
diff changeset
   955
 * @param widget_index : index of this widget in the window
fdccb9b2dbcd (svn r6599) -Codechange: Add accessors around the members click/disabled/hidden_state of Window
belugas
parents: 4638
diff changeset
   956
 */
6258
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents: 6256
diff changeset
   957
inline void BaseWindow::LowerWidget(byte widget_index)
4692
fdccb9b2dbcd (svn r6599) -Codechange: Add accessors around the members click/disabled/hidden_state of Window
belugas
parents: 4638
diff changeset
   958
{
6251
cd413fa2e252 (svn r8720) [cpp_gui] -Codechange: SetWindowWidgetLoweredState(), ToggleWidgetLoweredState(), LowerWindowWidget(), RaiseWindowWidget() and IsWindowWidgetLowered() turned into Window methods
KUDr
parents: 6250
diff changeset
   959
	SetWidgetLoweredState(widget_index, true);
4692
fdccb9b2dbcd (svn r6599) -Codechange: Add accessors around the members click/disabled/hidden_state of Window
belugas
parents: 4638
diff changeset
   960
}
fdccb9b2dbcd (svn r6599) -Codechange: Add accessors around the members click/disabled/hidden_state of Window
belugas
parents: 4638
diff changeset
   961
fdccb9b2dbcd (svn r6599) -Codechange: Add accessors around the members click/disabled/hidden_state of Window
belugas
parents: 4638
diff changeset
   962
/**
fdccb9b2dbcd (svn r6599) -Codechange: Add accessors around the members click/disabled/hidden_state of Window
belugas
parents: 4638
diff changeset
   963
 * Marks a widget as raised.
6258
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents: 6256
diff changeset
   964
 * @param w : BaseWindow on which the widget is located
4692
fdccb9b2dbcd (svn r6599) -Codechange: Add accessors around the members click/disabled/hidden_state of Window
belugas
parents: 4638
diff changeset
   965
 * @param widget_index : index of this widget in the window
fdccb9b2dbcd (svn r6599) -Codechange: Add accessors around the members click/disabled/hidden_state of Window
belugas
parents: 4638
diff changeset
   966
 */
6258
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents: 6256
diff changeset
   967
inline void BaseWindow::RaiseWidget(byte widget_index)
4692
fdccb9b2dbcd (svn r6599) -Codechange: Add accessors around the members click/disabled/hidden_state of Window
belugas
parents: 4638
diff changeset
   968
{
6251
cd413fa2e252 (svn r8720) [cpp_gui] -Codechange: SetWindowWidgetLoweredState(), ToggleWidgetLoweredState(), LowerWindowWidget(), RaiseWindowWidget() and IsWindowWidgetLowered() turned into Window methods
KUDr
parents: 6250
diff changeset
   969
	SetWidgetLoweredState(widget_index, false);
4692
fdccb9b2dbcd (svn r6599) -Codechange: Add accessors around the members click/disabled/hidden_state of Window
belugas
parents: 4638
diff changeset
   970
}
fdccb9b2dbcd (svn r6599) -Codechange: Add accessors around the members click/disabled/hidden_state of Window
belugas
parents: 4638
diff changeset
   971
fdccb9b2dbcd (svn r6599) -Codechange: Add accessors around the members click/disabled/hidden_state of Window
belugas
parents: 4638
diff changeset
   972
/**
fdccb9b2dbcd (svn r6599) -Codechange: Add accessors around the members click/disabled/hidden_state of Window
belugas
parents: 4638
diff changeset
   973
 * Gets the lowered state of a widget.
6258
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents: 6256
diff changeset
   974
 * @param w : BaseWindow on which the widget is located
4692
fdccb9b2dbcd (svn r6599) -Codechange: Add accessors around the members click/disabled/hidden_state of Window
belugas
parents: 4638
diff changeset
   975
 * @param widget_index : index of this widget in the window
fdccb9b2dbcd (svn r6599) -Codechange: Add accessors around the members click/disabled/hidden_state of Window
belugas
parents: 4638
diff changeset
   976
 * @return status of the widget ie: lowered = true, raised= false
fdccb9b2dbcd (svn r6599) -Codechange: Add accessors around the members click/disabled/hidden_state of Window
belugas
parents: 4638
diff changeset
   977
 */
6258
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents: 6256
diff changeset
   978
inline bool BaseWindow::IsWidgetLowered(byte widget_index) const
4692
fdccb9b2dbcd (svn r6599) -Codechange: Add accessors around the members click/disabled/hidden_state of Window
belugas
parents: 4638
diff changeset
   979
{
6251
cd413fa2e252 (svn r8720) [cpp_gui] -Codechange: SetWindowWidgetLoweredState(), ToggleWidgetLoweredState(), LowerWindowWidget(), RaiseWindowWidget() and IsWindowWidgetLowered() turned into Window methods
KUDr
parents: 6250
diff changeset
   980
	assert(widget_index < widget_count);
6258
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents: 6256
diff changeset
   981
	return HASBIT(widget[widget_index].m_display_flags, WIDG_LOWERED);
4692
fdccb9b2dbcd (svn r6599) -Codechange: Add accessors around the members click/disabled/hidden_state of Window
belugas
parents: 4638
diff changeset
   982
}
fdccb9b2dbcd (svn r6599) -Codechange: Add accessors around the members click/disabled/hidden_state of Window
belugas
parents: 4638
diff changeset
   983
6298
c30fe89622df (svn r9119) [cpp_gui] -Sync with trunk (r9003:9100)
bjarni
parents: 6297
diff changeset
   984
void InitWindowSystem();
c30fe89622df (svn r9119) [cpp_gui] -Sync with trunk (r9003:9100)
bjarni
parents: 6297
diff changeset
   985
void UnInitWindowSystem();
c30fe89622df (svn r9119) [cpp_gui] -Sync with trunk (r9003:9100)
bjarni
parents: 6297
diff changeset
   986
void ResetWindowSystem();
c30fe89622df (svn r9119) [cpp_gui] -Sync with trunk (r9003:9100)
bjarni
parents: 6297
diff changeset
   987
void InputLoop();
6258
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents: 6256
diff changeset
   988
//void InvalidateThisWindowData(BaseWindow *w);
4739
bd535b408617 (svn r6651) -Coding feature: added the windowevent WE_INVALIDATE_DATA
bjarni
parents: 4730
diff changeset
   989
void InvalidateWindowData(WindowClass cls, WindowNumber number);
6258
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents: 6256
diff changeset
   990
//void RaiseWindowButtons(BaseWindow *w);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   991
void RelocateAllWindows(int neww, int newh);
6258
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents: 6256
diff changeset
   992
int PositionMainToolbar(BaseWindow *w);
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents: 6256
diff changeset
   993
//void CDECL SetWindowWidgetsDisabledState(BaseWindow *w, bool disab_stat, int widgets, ...);
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents: 6256
diff changeset
   994
//void CDECL SetWindowWidgetsHiddenState(BaseWindow *w, bool hidden_stat, int widgets, ...);
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents: 6256
diff changeset
   995
//void CDECL SetWindowWidgetsLoweredState(BaseWindow *w, bool lowered_stat, int widgets, ...);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   996
6268
4b5241e5dd10 (svn r8938) [cpp_gui] -Sync with trunk (r8772..r8900)
bjarni
parents: 6267
diff changeset
   997
/* misc_gui.cpp */
4884
895f06b87934 (svn r6821) -Codechange: For the measurement tool do not show the tooltip when the selection
Darkvater
parents: 4834
diff changeset
   998
void GuiShowTooltipsWithArgs(StringID str, uint paramcount, const uint params[]);
4834
ddcf440d0ffd (svn r6758) -Feature: Add a measurement tool that will show dimensions and height
Darkvater
parents: 4800
diff changeset
   999
static inline void GuiShowTooltips(StringID str)
ddcf440d0ffd (svn r6758) -Feature: Add a measurement tool that will show dimensions and height
Darkvater
parents: 4800
diff changeset
  1000
{
ddcf440d0ffd (svn r6758) -Feature: Add a measurement tool that will show dimensions and height
Darkvater
parents: 4800
diff changeset
  1001
	GuiShowTooltipsWithArgs(str, 0, NULL);
ddcf440d0ffd (svn r6758) -Feature: Add a measurement tool that will show dimensions and height
Darkvater
parents: 4800
diff changeset
  1002
}
4719
413b21513ef7 (svn r6631) -Codechange: Use accessors for click_state.
belugas
parents: 4712
diff changeset
  1003
6258
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents: 6256
diff changeset
  1004
//void HandleButtonClick(BaseWindow *w, byte widget);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1005
6258
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents: 6256
diff changeset
  1006
BaseWindow *GetCallbackWnd(void);
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents: 6256
diff changeset
  1007
//WindowList::Iterator FindWindowZPosition(const BaseWindow *w);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1008
6268
4b5241e5dd10 (svn r8938) [cpp_gui] -Sync with trunk (r8772..r8900)
bjarni
parents: 6267
diff changeset
  1009
/* window.cpp */
6258
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents: 6256
diff changeset
  1010
//extern BaseWindow *_z_windows[];
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents: 6256
diff changeset
  1011
//extern BaseWindow **_last_z_window;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1012
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1013
VARDEF Point _cursorpos_drag_start;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1014
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1015
VARDEF int _scrollbar_start_pos;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1016
VARDEF int _scrollbar_size;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1017
VARDEF byte _scroller_click_timeout;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1018
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1019
VARDEF bool _scrolling_scrollbar;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1020
VARDEF bool _scrolling_viewport;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1021
VARDEF bool _popup_menu_active;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1022
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1023
VARDEF byte _special_mouse_mode;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1024
enum SpecialMouseMode {
4344
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4337
diff changeset
  1025
	WSM_NONE     = 0,
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1026
	WSM_DRAGDROP = 1,
4344
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4337
diff changeset
  1027
	WSM_SIZING   = 2,
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4337
diff changeset
  1028
	WSM_PRESIZE  = 3,
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1029
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1030
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1031
6073
d8dae377c879 (svn r8384) -Codechange: [GUI] instead of writing a resize button function for each window, a global ResizeButtons() is added
bjarni
parents: 6032
diff changeset
  1032
/** Evenly distribute some widgets when resizing horizontally (often a button row)
6075
33cdb35f9af5 (svn r8390) -Codechange (r8384): Rewrote ResizeButtons()
bjarni
parents: 6073
diff changeset
  1033
 *  The widgets are presumed to be in a line and numberef from left to right (without gaps)
6073
d8dae377c879 (svn r8384) -Codechange: [GUI] instead of writing a resize button function for each window, a global ResizeButtons() is added
bjarni
parents: 6032
diff changeset
  1034
 * @param w widow to modify
d8dae377c879 (svn r8384) -Codechange: [GUI] instead of writing a resize button function for each window, a global ResizeButtons() is added
bjarni
parents: 6032
diff changeset
  1035
 * @param left The leftmost widget to resize
6075
33cdb35f9af5 (svn r8390) -Codechange (r8384): Rewrote ResizeButtons()
bjarni
parents: 6073
diff changeset
  1036
 * @param right The rightmost widget to resize. Since right side of it is used, remember to set it to RESIZE_RIGHT
6073
d8dae377c879 (svn r8384) -Codechange: [GUI] instead of writing a resize button function for each window, a global ResizeButtons() is added
bjarni
parents: 6032
diff changeset
  1037
 */
6258
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents: 6256
diff changeset
  1038
//void ResizeButtons(BaseWindow *w, byte left, byte right);
6073
d8dae377c879 (svn r8384) -Codechange: [GUI] instead of writing a resize button function for each window, a global ResizeButtons() is added
bjarni
parents: 6032
diff changeset
  1039
6264
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents: 6263
diff changeset
  1040
template <WindowClass Tcls> struct WindowT;
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents: 6263
diff changeset
  1041
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents: 6263
diff changeset
  1042
struct WindowFactory
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents: 6263
diff changeset
  1043
{
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents: 6263
diff changeset
  1044
	typedef BaseWindow* (*CreateFn)(WindowNumber);
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents: 6263
diff changeset
  1045
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents: 6263
diff changeset
  1046
	typedef std::map<WindowClass, WindowFactory*> Factories;
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents: 6263
diff changeset
  1047
6267
7c8ec33959b1 (svn r8937) [cpp_gui] -Fix(r8931): the global map of Window Factories needs to be constructed on the fly. Otherwise it is not sure that it will be constructed before first WindowFactory. (Bjarni)
KUDr
parents: 6264
diff changeset
  1048
	static Factories& GetFactories()
7c8ec33959b1 (svn r8937) [cpp_gui] -Fix(r8931): the global map of Window Factories needs to be constructed on the fly. Otherwise it is not sure that it will be constructed before first WindowFactory. (Bjarni)
KUDr
parents: 6264
diff changeset
  1049
	{
7c8ec33959b1 (svn r8937) [cpp_gui] -Fix(r8931): the global map of Window Factories needs to be constructed on the fly. Otherwise it is not sure that it will be constructed before first WindowFactory. (Bjarni)
KUDr
parents: 6264
diff changeset
  1050
		static Factories s_factories;
7c8ec33959b1 (svn r8937) [cpp_gui] -Fix(r8931): the global map of Window Factories needs to be constructed on the fly. Otherwise it is not sure that it will be constructed before first WindowFactory. (Bjarni)
KUDr
parents: 6264
diff changeset
  1051
		return s_factories;
7c8ec33959b1 (svn r8937) [cpp_gui] -Fix(r8931): the global map of Window Factories needs to be constructed on the fly. Otherwise it is not sure that it will be constructed before first WindowFactory. (Bjarni)
KUDr
parents: 6264
diff changeset
  1052
	}
6264
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents: 6263
diff changeset
  1053
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents: 6263
diff changeset
  1054
	WindowClass m_cls;
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents: 6263
diff changeset
  1055
	CreateFn    m_creator;
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents: 6263
diff changeset
  1056
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents: 6263
diff changeset
  1057
	WindowFactory(WindowClass cls, CreateFn creator)
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents: 6263
diff changeset
  1058
		: m_cls(cls)
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents: 6263
diff changeset
  1059
		, m_creator(creator)
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents: 6263
diff changeset
  1060
	{
6267
7c8ec33959b1 (svn r8937) [cpp_gui] -Fix(r8931): the global map of Window Factories needs to be constructed on the fly. Otherwise it is not sure that it will be constructed before first WindowFactory. (Bjarni)
KUDr
parents: 6264
diff changeset
  1061
		std::pair<Factories::iterator, bool> P = GetFactories().insert(Factories::value_type(m_cls, this));
6264
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents: 6263
diff changeset
  1062
		assert(P.second);
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents: 6263
diff changeset
  1063
	}
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents: 6263
diff changeset
  1064
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents: 6263
diff changeset
  1065
	~WindowFactory()
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents: 6263
diff changeset
  1066
	{
6267
7c8ec33959b1 (svn r8937) [cpp_gui] -Fix(r8931): the global map of Window Factories needs to be constructed on the fly. Otherwise it is not sure that it will be constructed before first WindowFactory. (Bjarni)
KUDr
parents: 6264
diff changeset
  1067
		GetFactories().erase(m_cls);
6264
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents: 6263
diff changeset
  1068
	}
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents: 6263
diff changeset
  1069
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents: 6263
diff changeset
  1070
	static BaseWindow* NewWindow(WindowClass cls, WindowNumber num)
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents: 6263
diff changeset
  1071
	{
6267
7c8ec33959b1 (svn r8937) [cpp_gui] -Fix(r8931): the global map of Window Factories needs to be constructed on the fly. Otherwise it is not sure that it will be constructed before first WindowFactory. (Bjarni)
KUDr
parents: 6264
diff changeset
  1072
		Factories::iterator it = GetFactories().find(cls);
7c8ec33959b1 (svn r8937) [cpp_gui] -Fix(r8931): the global map of Window Factories needs to be constructed on the fly. Otherwise it is not sure that it will be constructed before first WindowFactory. (Bjarni)
KUDr
parents: 6264
diff changeset
  1073
		if (it == GetFactories().end()) return NULL;
6264
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents: 6263
diff changeset
  1074
		WindowFactory *f = (*it).second;
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents: 6263
diff changeset
  1075
		BaseWindow *w = f->m_creator(num);
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents: 6263
diff changeset
  1076
		return w;
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents: 6263
diff changeset
  1077
	}
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents: 6263
diff changeset
  1078
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents: 6263
diff changeset
  1079
};
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents: 6263
diff changeset
  1080
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents: 6263
diff changeset
  1081
template <WindowClass Tcls> struct WindowFactoryT : public WindowFactory
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents: 6263
diff changeset
  1082
{
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents: 6263
diff changeset
  1083
	WindowFactoryT()
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents: 6263
diff changeset
  1084
		: WindowFactory(Tcls, &NewWindow)
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents: 6263
diff changeset
  1085
	{}
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents: 6263
diff changeset
  1086
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents: 6263
diff changeset
  1087
	static BaseWindow* NewWindow(WindowNumber num)
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents: 6263
diff changeset
  1088
	{
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents: 6263
diff changeset
  1089
		WindowT<Tcls> *w = new WindowT<Tcls>();
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents: 6263
diff changeset
  1090
		w->Create(num);
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents: 6263
diff changeset
  1091
		return w;
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents: 6263
diff changeset
  1092
	}
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents: 6263
diff changeset
  1093
};
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents: 6263
diff changeset
  1094
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents: 6263
diff changeset
  1095
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1096
#endif /* WINDOW_H */