src/widget/widget.h
author KUDr
Sat, 03 Mar 2007 02:47:45 +0000
branchcpp_gui
changeset 6278 c09f5e53af9b
parent 6277 732cf765e2d7
child 6279 c75b2c7222ff
permissions -rw-r--r--
(svn r8986) [cpp_gui] -Add: resizing window by dragging ResizeBox
-Fix: Moving top-left corner of widget now moves is instead of resizing
-Add: Resizing widget/window now generates OnResize() event
-Add: Resizing container now generates OnResizeParent() for all children
-Add: Widget anchors (widgets now resize/move when container widget resizes)
6264
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
     1
/* $Id$ */
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
     2
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
     3
#ifndef WIDGET_H
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
     4
#define WIDGET_H
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
     5
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
     6
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
     7
#include <list>
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
     8
#include <map>
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
     9
#include "../macros.h"
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
    10
#include "../string.h"
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
    11
#include "../order.h"
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
    12
#include "../rail.h"
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
    13
#include "../airport.h"
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
    14
#include "../misc/rect.hpp"
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
    15
#include "../misc/countedptr.hpp"
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
    16
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
    17
#include "window_event_base.h"
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
    18
6265
7054c910251d (svn r8932) [cpp_gui] -Fix(r8931): forward enum declaration doesn't work for g++
KUDr
parents: 6264
diff changeset
    19
enum FrameFlags {
7054c910251d (svn r8932) [cpp_gui] -Fix(r8931): forward enum declaration doesn't work for g++
KUDr
parents: 6264
diff changeset
    20
	FR_NONE         = 0x00,
7054c910251d (svn r8932) [cpp_gui] -Fix(r8931): forward enum declaration doesn't work for g++
KUDr
parents: 6264
diff changeset
    21
	FR_TRANSPARENT  = 0x01,  ///< Makes the background transparent if set
7054c910251d (svn r8932) [cpp_gui] -Fix(r8931): forward enum declaration doesn't work for g++
KUDr
parents: 6264
diff changeset
    22
	FR_BORDERONLY   = 0x10,  ///< Draw border only, no background
7054c910251d (svn r8932) [cpp_gui] -Fix(r8931): forward enum declaration doesn't work for g++
KUDr
parents: 6264
diff changeset
    23
	FR_LOWERED      = 0x20,  ///< If set the frame is lowered and the background color brighter (ie. buttons when pressed)
7054c910251d (svn r8932) [cpp_gui] -Fix(r8931): forward enum declaration doesn't work for g++
KUDr
parents: 6264
diff changeset
    24
	FR_DARKENED     = 0x40,  ///< If set the background is darker, allows for lowered frames with normal background color when used with FR_LOWERED (ie. dropdown boxes)
7054c910251d (svn r8932) [cpp_gui] -Fix(r8931): forward enum declaration doesn't work for g++
KUDr
parents: 6264
diff changeset
    25
};
7054c910251d (svn r8932) [cpp_gui] -Fix(r8931): forward enum declaration doesn't work for g++
KUDr
parents: 6264
diff changeset
    26
7054c910251d (svn r8932) [cpp_gui] -Fix(r8931): forward enum declaration doesn't work for g++
KUDr
parents: 6264
diff changeset
    27
DECLARE_ENUM_AS_BIT_SET(FrameFlags);
7054c910251d (svn r8932) [cpp_gui] -Fix(r8931): forward enum declaration doesn't work for g++
KUDr
parents: 6264
diff changeset
    28
6278
c09f5e53af9b (svn r8986) [cpp_gui] -Add: resizing window by dragging ResizeBox
KUDr
parents: 6277
diff changeset
    29
enum Anchors {
c09f5e53af9b (svn r8986) [cpp_gui] -Add: resizing window by dragging ResizeBox
KUDr
parents: 6277
diff changeset
    30
	PIN_NONE     = 0x00,
c09f5e53af9b (svn r8986) [cpp_gui] -Add: resizing window by dragging ResizeBox
KUDr
parents: 6277
diff changeset
    31
	PIN_LEFT     = 0x01,
c09f5e53af9b (svn r8986) [cpp_gui] -Add: resizing window by dragging ResizeBox
KUDr
parents: 6277
diff changeset
    32
	PIN_TOP      = 0x02,
c09f5e53af9b (svn r8986) [cpp_gui] -Add: resizing window by dragging ResizeBox
KUDr
parents: 6277
diff changeset
    33
	PIN_RIGHT    = 0x04,
c09f5e53af9b (svn r8986) [cpp_gui] -Add: resizing window by dragging ResizeBox
KUDr
parents: 6277
diff changeset
    34
	PIN_BOTTOM   = 0x08,
c09f5e53af9b (svn r8986) [cpp_gui] -Add: resizing window by dragging ResizeBox
KUDr
parents: 6277
diff changeset
    35
};
c09f5e53af9b (svn r8986) [cpp_gui] -Add: resizing window by dragging ResizeBox
KUDr
parents: 6277
diff changeset
    36
c09f5e53af9b (svn r8986) [cpp_gui] -Add: resizing window by dragging ResizeBox
KUDr
parents: 6277
diff changeset
    37
DECLARE_ENUM_AS_BIT_SET(Anchors);
6264
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
    38
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
    39
namespace gui {
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
    40
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
    41
struct Widget;
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
    42
typedef CCountedPtr<Widget> WidgetPtr;
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
    43
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
    44
struct CompositeWidget;
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
    45
typedef CCountedPtr<CompositeWidget> CompositeWidgetPtr;
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
    46
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
    47
typedef int32 WidgetId;
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
    48
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
    49
struct Widget : public SimpleCountedObject {
6269
3b3bd4fe0736 (svn r8947) [cpp_gui] -Codechange: proprietary smart pointer adapter replaced by generic one
KUDr
parents: 6265
diff changeset
    50
	typedef AdaptT<EventHandlerDelegatePtr> Handler;
6264
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
    51
	typedef std::list<Handler> Handlers;
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
    52
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
    53
	CompositeWidget *m_container;       ///< widget container (can be any panel or window)
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
    54
	WidgetId        m_id;               ///< Widget id in its container
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
    55
	Rect16          m_rect;             ///< The position offsets relative to the container
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
    56
	uint16          m_data;             ///< The String/Image or special code (list-matrices) of a widget
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
    57
	byte            m_display_flags;    ///< Resize direction, alignment, etc. during resizing, see @ResizeFlags
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
    58
	byte            m_color;            ///< Widget color, see docs/ottd-colourtext-palette.png
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
    59
	bool            m_is_closing : 1;   ///< Widget was logically destroyed
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
    60
	bool            m_dont_clip : 1;    ///< should not be clipped by parent (container)
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
    61
	StringID        m_tooltips;         ///< Tooltips that are shown when right clicking on a widget
6278
c09f5e53af9b (svn r8986) [cpp_gui] -Add: resizing window by dragging ResizeBox
KUDr
parents: 6277
diff changeset
    62
	Anchors         m_anchors;          ///< Resize/move when container resizes?
6264
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
    63
	Handlers        m_handlers;         ///< dynamically registered event handlers
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
    64
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
    65
	Widget()
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
    66
		: m_container(NULL), m_id(0), m_rect(), m_data(0), m_display_flags(0), m_color(0)
6278
c09f5e53af9b (svn r8986) [cpp_gui] -Add: resizing window by dragging ResizeBox
KUDr
parents: 6277
diff changeset
    67
		, m_is_closing(false), m_tooltips(0), m_anchors(PIN_NONE)
6264
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
    68
	{}
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
    69
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
    70
	Widget(CompositeWidget *container, WidgetId id, byte display_flags, byte color, const Rect16 &rect, StringID tooltips)
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
    71
		: m_container(container)
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
    72
		, m_id(id)
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
    73
		, m_rect(rect)
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
    74
		, m_data(0)
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
    75
		, m_display_flags(display_flags)
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
    76
		, m_color(color)
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
    77
		, m_is_closing(false)
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
    78
		, m_dont_clip(false)
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
    79
		, m_tooltips(tooltips)
6278
c09f5e53af9b (svn r8986) [cpp_gui] -Add: resizing window by dragging ResizeBox
KUDr
parents: 6277
diff changeset
    80
		, m_anchors(PIN_NONE)
6264
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
    81
	{}
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
    82
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
    83
	int16 Left() const;
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
    84
	int16 Top() const;
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
    85
	int16 Right() const;
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
    86
	int16 Bottom() const;
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
    87
	int16 Width() const;
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
    88
	int16 Height() const;
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
    89
	const Point16& TopLeft() const;
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
    90
	const Point16& BottomRight() const;
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
    91
	Point16 Size() const;
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
    92
	Point16 CenterPt() const;
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
    93
	const Rect16& GetRect() const;
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
    94
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
    95
	void SetLeft(int16 val);
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
    96
	void SetTop(int16 val);
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
    97
	void SetRight(int16 val);
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
    98
	void SetBottom(int16 val);
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
    99
	void SetWidth(int16 val);
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
   100
	void SetHeight(int16 val);
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
   101
	void SetTopLeft(const Point16 &pt);
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
   102
	void SetBottomRight(const Point16 &pt);
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
   103
	void SetSize(const Point16 &pt);
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
   104
	void SetRect(const Rect16 &rect);
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
   105
6278
c09f5e53af9b (svn r8986) [cpp_gui] -Add: resizing window by dragging ResizeBox
KUDr
parents: 6277
diff changeset
   106
	void SetAnchors(Anchors a);
c09f5e53af9b (svn r8986) [cpp_gui] -Add: resizing window by dragging ResizeBox
KUDr
parents: 6277
diff changeset
   107
6264
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
   108
	WidgetId GetId() const;
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
   109
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
   110
	void AddHandler(EventHandlerDelegate *d);
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
   111
	void CallHandlers(EventBase &e);
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
   112
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
   113
	void Invalidate() {}; ///< now we redraw gui all the time, so no processing is needed here
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
   114
	static /*static*/ void FillRect(const Rect16 &rc, int color);
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
   115
	static void DrawFrameRect(int left, int top, int right, int bottom, int ctab, FrameFlags flags);
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
   116
	void DrawFrameRect(int ctab, FrameFlags flags);
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
   117
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
   118
	virtual BaseWindow* GetWindow();
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
   119
	virtual Widget* WidgetFromPt(const Point16 &pt);
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
   120
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
   121
	virtual void Close();
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
   122
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
   123
	virtual void DrawBackground(EvtPaint &ev);
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
   124
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
   125
	/**
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
   126
	 * OnCreate() handler called when window gets created. Override this method in your
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
   127
	 * Window subclass and place widgets into your window from there.
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
   128
	 */
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
   129
	virtual void OnCreate(EvtCreate &ev) {};
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
   130
	virtual void OnDestroy(EvtDestroy &ev) {};
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
   131
	virtual void OnPaint(EvtPaint &ev) = 0;
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
   132
	virtual void OnKeyPress(EvtKeyPress &ev) {};
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
   133
	virtual void OnLeftClick(EvtClick &ev);
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
   134
	virtual void OnRightClick(EvtRightClick &ev);
6271
0ad100a98853 (svn r8958) [cpp_gui] -Add: Widget can now capture specified gui events
KUDr
parents: 6269
diff changeset
   135
	virtual void OnMouseOver(EvtMouseOver &ev) {};
6278
c09f5e53af9b (svn r8986) [cpp_gui] -Add: resizing window by dragging ResizeBox
KUDr
parents: 6277
diff changeset
   136
	virtual void OnResize(EvtResize &ev) {};
c09f5e53af9b (svn r8986) [cpp_gui] -Add: resizing window by dragging ResizeBox
KUDr
parents: 6277
diff changeset
   137
	virtual void OnResizeParent(EvtResizeParent &ev);
6264
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
   138
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
   139
	/**
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
   140
	 * Dispatch event by its type calling appropriate OnCreate(), OnDestroy(), etc.
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
   141
	 */
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
   142
	virtual void DispatchEvent(EventBase &ev);
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
   143
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
   144
	/**
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
   145
	 * @function AddReflectHandlerT Registers reflected event handler. Use it from
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
   146
	 * BaseWindow subclasses (Window implementations) to register custom event handler.
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
   147
	 * For example if you are implementing 'MyWindow' class and want to handle OnLeftClick()
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
   148
	 * event for your button 'MyButton', define your handler method inside 'MyWindow' class
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
   149
	 * like:
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
   150
	 *       void MyWindow::MyButtonClickHandler(gui::EvtClick &e)
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
   151
	 *       {
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
   152
	 *          ...
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
   153
	 *       }
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
   154
	 * then from inside OnCreate() handler, create your button 'my_button' and
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
   155
	 * call:
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
   156
	 *       my_button->AddReflectHandlerT(&MyWindow::MyButtonClickHandler);
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
   157
	 * and your MyButtonClickHandler will be called on every click on my_button.
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
   158
	 */
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
   159
	template <class Twnd_cls, EventCode Tevt_code> void AddReflectHandlerT(void (Twnd_cls::*handler)(gui::EventT<Tevt_code>&))
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
   160
	{
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
   161
		typedef ReflectHandlerDelegateT<Twnd_cls, Tevt_code> Delegate;
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
   162
		AddHandler(new Delegate(handler));
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
   163
	}
6271
0ad100a98853 (svn r8958) [cpp_gui] -Add: Widget can now capture specified gui events
KUDr
parents: 6269
diff changeset
   164
0ad100a98853 (svn r8958) [cpp_gui] -Add: Widget can now capture specified gui events
KUDr
parents: 6269
diff changeset
   165
	/** add capture handler using default delegate type (CaptureHandlerDelegateT<>) */
0ad100a98853 (svn r8958) [cpp_gui] -Add: Widget can now capture specified gui events
KUDr
parents: 6269
diff changeset
   166
	template <class Twd_cls, EventCode Tevt_code> CaptureTicket CaptureEventsT(Twd_cls *wd, void (Twd_cls::*handler)(EventT<Tevt_code>&))
0ad100a98853 (svn r8958) [cpp_gui] -Add: Widget can now capture specified gui events
KUDr
parents: 6269
diff changeset
   167
	{
0ad100a98853 (svn r8958) [cpp_gui] -Add: Widget can now capture specified gui events
KUDr
parents: 6269
diff changeset
   168
		CaptureTicket ticket = EventCaptureStack::AddHandler(new CaptureHandlerDelegateT<Twd_cls, Tevt_code>(wd, handler));
0ad100a98853 (svn r8958) [cpp_gui] -Add: Widget can now capture specified gui events
KUDr
parents: 6269
diff changeset
   169
		return ticket;
0ad100a98853 (svn r8958) [cpp_gui] -Add: Widget can now capture specified gui events
KUDr
parents: 6269
diff changeset
   170
	}
0ad100a98853 (svn r8958) [cpp_gui] -Add: Widget can now capture specified gui events
KUDr
parents: 6269
diff changeset
   171
6264
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
   172
};
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
   173
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
   174
struct CompositeWidget : public Widget {
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
   175
	typedef Widget super;
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
   176
	typedef std::map<WidgetId, WidgetPtr> Widgets;
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
   177
	typedef Widgets::iterator WidgetIterator;
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
   178
	typedef Widgets::reverse_iterator WidgetReverseIterator;
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
   179
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
   180
protected:
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
   181
	Widgets m_widgets;
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
   182
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
   183
public:
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
   184
	CompositeWidget()
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
   185
		: Widget()
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
   186
	{}
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
   187
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
   188
	CompositeWidget(CompositeWidget *container, WidgetId id, byte display_flags, byte color, const Rect16 &rect, StringID tooltips)
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
   189
		: Widget(container, id, display_flags, color, rect, tooltips)
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
   190
	{}
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
   191
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
   192
	void AddWidget(Widget *wd);
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
   193
	Widget* GetWidget(WidgetId id);
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
   194
	Widget* RemoveWidget(WidgetId id);
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
   195
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
   196
	/*virtual*/ Widget* WidgetFromPt(const Point16 &pt);
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
   197
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
   198
	virtual void Close();
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
   199
6278
c09f5e53af9b (svn r8986) [cpp_gui] -Add: resizing window by dragging ResizeBox
KUDr
parents: 6277
diff changeset
   200
	/*virtual*/ void OnCreate(EvtCreate &ev);
6264
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
   201
	/*virtual*/ void OnPaint(EvtPaint &ev);
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
   202
	/*virtual*/ void OnLeftClick(EvtClick &ev);
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
   203
	/*virtual*/ void OnRightClick(EvtRightClick &ev);
6278
c09f5e53af9b (svn r8986) [cpp_gui] -Add: resizing window by dragging ResizeBox
KUDr
parents: 6277
diff changeset
   204
	/*virtual*/ void OnResize(EvtResize &ev);
6264
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
   205
};
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
   206
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
   207
struct Button : public Widget {
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
   208
	typedef Widget super;
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
   209
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
   210
protected:
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
   211
	bool m_pushed;
6271
0ad100a98853 (svn r8958) [cpp_gui] -Add: Widget can now capture specified gui events
KUDr
parents: 6269
diff changeset
   212
	CaptureTicket m_ticket_pressed;
6264
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
   213
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
   214
public:
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
   215
	Button()
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
   216
		: Widget()
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
   217
		, m_pushed(false)
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
   218
	{}
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
   219
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
   220
	Button(CompositeWidget *container, WidgetId id, byte display_flags, byte color, const Rect16 &rect, StringID tooltips)
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
   221
		: Widget(container, id, display_flags, color, rect, tooltips)
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
   222
		, m_pushed(false)
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
   223
	{}
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
   224
6271
0ad100a98853 (svn r8958) [cpp_gui] -Add: Widget can now capture specified gui events
KUDr
parents: 6269
diff changeset
   225
	void OnCapturePressed(EvtMouseOver &e);
0ad100a98853 (svn r8958) [cpp_gui] -Add: Widget can now capture specified gui events
KUDr
parents: 6269
diff changeset
   226
6264
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
   227
	/*virtual*/ void DrawBackground(EvtPaint &ev);
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
   228
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
   229
	/*virtual*/ void OnLeftClick(EvtClick &ev);
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
   230
};
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
   231
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
   232
struct TextButton : public Button {
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
   233
	typedef Button super;
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
   234
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
   235
protected:
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
   236
	StringID m_text;
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
   237
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
   238
public:
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
   239
	TextButton()
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
   240
		: Button()
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
   241
	{}
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
   242
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
   243
	TextButton(CompositeWidget *container, WidgetId id, byte display_flags, byte color, const Rect16 &rect, StringID tooltips, StringID text)
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
   244
		: Button(container, id, display_flags, color, rect, tooltips)
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
   245
		, m_text(text)
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
   246
	{}
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
   247
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
   248
	/*virtual*/ void OnPaint(EvtPaint &ev);
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
   249
};
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
   250
6278
c09f5e53af9b (svn r8986) [cpp_gui] -Add: resizing window by dragging ResizeBox
KUDr
parents: 6277
diff changeset
   251
struct ResizeBox : public Widget {
c09f5e53af9b (svn r8986) [cpp_gui] -Add: resizing window by dragging ResizeBox
KUDr
parents: 6277
diff changeset
   252
	typedef Widget super;
c09f5e53af9b (svn r8986) [cpp_gui] -Add: resizing window by dragging ResizeBox
KUDr
parents: 6277
diff changeset
   253
c09f5e53af9b (svn r8986) [cpp_gui] -Add: resizing window by dragging ResizeBox
KUDr
parents: 6277
diff changeset
   254
	static const int16 DEFAULT_WIDTH  = 11;
c09f5e53af9b (svn r8986) [cpp_gui] -Add: resizing window by dragging ResizeBox
KUDr
parents: 6277
diff changeset
   255
	static const int16 DEFAULT_HEIGHT = 11;
c09f5e53af9b (svn r8986) [cpp_gui] -Add: resizing window by dragging ResizeBox
KUDr
parents: 6277
diff changeset
   256
c09f5e53af9b (svn r8986) [cpp_gui] -Add: resizing window by dragging ResizeBox
KUDr
parents: 6277
diff changeset
   257
protected:
c09f5e53af9b (svn r8986) [cpp_gui] -Add: resizing window by dragging ResizeBox
KUDr
parents: 6277
diff changeset
   258
	Point16       m_sizing_offset;
c09f5e53af9b (svn r8986) [cpp_gui] -Add: resizing window by dragging ResizeBox
KUDr
parents: 6277
diff changeset
   259
	CaptureTicket m_ticket_sizing;
c09f5e53af9b (svn r8986) [cpp_gui] -Add: resizing window by dragging ResizeBox
KUDr
parents: 6277
diff changeset
   260
c09f5e53af9b (svn r8986) [cpp_gui] -Add: resizing window by dragging ResizeBox
KUDr
parents: 6277
diff changeset
   261
public:
c09f5e53af9b (svn r8986) [cpp_gui] -Add: resizing window by dragging ResizeBox
KUDr
parents: 6277
diff changeset
   262
	ResizeBox()
c09f5e53af9b (svn r8986) [cpp_gui] -Add: resizing window by dragging ResizeBox
KUDr
parents: 6277
diff changeset
   263
		: Widget()
c09f5e53af9b (svn r8986) [cpp_gui] -Add: resizing window by dragging ResizeBox
KUDr
parents: 6277
diff changeset
   264
	{}
c09f5e53af9b (svn r8986) [cpp_gui] -Add: resizing window by dragging ResizeBox
KUDr
parents: 6277
diff changeset
   265
c09f5e53af9b (svn r8986) [cpp_gui] -Add: resizing window by dragging ResizeBox
KUDr
parents: 6277
diff changeset
   266
	ResizeBox(CompositeWidget *container)
c09f5e53af9b (svn r8986) [cpp_gui] -Add: resizing window by dragging ResizeBox
KUDr
parents: 6277
diff changeset
   267
		: Widget(container, -101, 0, container->m_color, Rect16(), 0)
c09f5e53af9b (svn r8986) [cpp_gui] -Add: resizing window by dragging ResizeBox
KUDr
parents: 6277
diff changeset
   268
	{}
c09f5e53af9b (svn r8986) [cpp_gui] -Add: resizing window by dragging ResizeBox
KUDr
parents: 6277
diff changeset
   269
c09f5e53af9b (svn r8986) [cpp_gui] -Add: resizing window by dragging ResizeBox
KUDr
parents: 6277
diff changeset
   270
	/*virtual*/ void DrawBackground(EvtPaint &ev);
c09f5e53af9b (svn r8986) [cpp_gui] -Add: resizing window by dragging ResizeBox
KUDr
parents: 6277
diff changeset
   271
	void OnCaptureSizing(EvtMouseOver &e);
c09f5e53af9b (svn r8986) [cpp_gui] -Add: resizing window by dragging ResizeBox
KUDr
parents: 6277
diff changeset
   272
c09f5e53af9b (svn r8986) [cpp_gui] -Add: resizing window by dragging ResizeBox
KUDr
parents: 6277
diff changeset
   273
	/*virtual*/ void OnCreate(EvtCreate &ev);
c09f5e53af9b (svn r8986) [cpp_gui] -Add: resizing window by dragging ResizeBox
KUDr
parents: 6277
diff changeset
   274
	/*virtual*/ void OnPaint(EvtPaint &ev);
c09f5e53af9b (svn r8986) [cpp_gui] -Add: resizing window by dragging ResizeBox
KUDr
parents: 6277
diff changeset
   275
	/*virtual*/ void OnLeftClick(EvtClick &ev);
c09f5e53af9b (svn r8986) [cpp_gui] -Add: resizing window by dragging ResizeBox
KUDr
parents: 6277
diff changeset
   276
	/*virtual*/ void OnResizeParent(EvtResizeParent &ev);
c09f5e53af9b (svn r8986) [cpp_gui] -Add: resizing window by dragging ResizeBox
KUDr
parents: 6277
diff changeset
   277
c09f5e53af9b (svn r8986) [cpp_gui] -Add: resizing window by dragging ResizeBox
KUDr
parents: 6277
diff changeset
   278
};
c09f5e53af9b (svn r8986) [cpp_gui] -Add: resizing window by dragging ResizeBox
KUDr
parents: 6277
diff changeset
   279
6273
d8a2c6844650 (svn r8981) [cpp_gui] -Add: simple CaptionBar Widget
KUDr
parents: 6271
diff changeset
   280
struct CaptionBar : public CompositeWidget {
d8a2c6844650 (svn r8981) [cpp_gui] -Add: simple CaptionBar Widget
KUDr
parents: 6271
diff changeset
   281
	typedef CompositeWidget super;
d8a2c6844650 (svn r8981) [cpp_gui] -Add: simple CaptionBar Widget
KUDr
parents: 6271
diff changeset
   282
d8a2c6844650 (svn r8981) [cpp_gui] -Add: simple CaptionBar Widget
KUDr
parents: 6271
diff changeset
   283
	static const int16 DEFAULT_HEIGHT = 14;
d8a2c6844650 (svn r8981) [cpp_gui] -Add: simple CaptionBar Widget
KUDr
parents: 6271
diff changeset
   284
d8a2c6844650 (svn r8981) [cpp_gui] -Add: simple CaptionBar Widget
KUDr
parents: 6271
diff changeset
   285
protected:
6275
bd57b30a8b81 (svn r8983) [cpp_gui] -Add: moving window by dragging CaptionBar
KUDr
parents: 6273
diff changeset
   286
	StringID      m_text;
bd57b30a8b81 (svn r8983) [cpp_gui] -Add: moving window by dragging CaptionBar
KUDr
parents: 6273
diff changeset
   287
	byte          m_text_color;
bd57b30a8b81 (svn r8983) [cpp_gui] -Add: moving window by dragging CaptionBar
KUDr
parents: 6273
diff changeset
   288
	Point16       m_moving_offset;
bd57b30a8b81 (svn r8983) [cpp_gui] -Add: moving window by dragging CaptionBar
KUDr
parents: 6273
diff changeset
   289
	CaptureTicket m_ticket_moving;
6273
d8a2c6844650 (svn r8981) [cpp_gui] -Add: simple CaptionBar Widget
KUDr
parents: 6271
diff changeset
   290
d8a2c6844650 (svn r8981) [cpp_gui] -Add: simple CaptionBar Widget
KUDr
parents: 6271
diff changeset
   291
public:
d8a2c6844650 (svn r8981) [cpp_gui] -Add: simple CaptionBar Widget
KUDr
parents: 6271
diff changeset
   292
	CaptionBar()
d8a2c6844650 (svn r8981) [cpp_gui] -Add: simple CaptionBar Widget
KUDr
parents: 6271
diff changeset
   293
		: CompositeWidget()
d8a2c6844650 (svn r8981) [cpp_gui] -Add: simple CaptionBar Widget
KUDr
parents: 6271
diff changeset
   294
		, m_text(0)
d8a2c6844650 (svn r8981) [cpp_gui] -Add: simple CaptionBar Widget
KUDr
parents: 6271
diff changeset
   295
		, m_text_color(0xFF)
d8a2c6844650 (svn r8981) [cpp_gui] -Add: simple CaptionBar Widget
KUDr
parents: 6271
diff changeset
   296
	{}
d8a2c6844650 (svn r8981) [cpp_gui] -Add: simple CaptionBar Widget
KUDr
parents: 6271
diff changeset
   297
d8a2c6844650 (svn r8981) [cpp_gui] -Add: simple CaptionBar Widget
KUDr
parents: 6271
diff changeset
   298
	CaptionBar(CompositeWidget *container, WidgetId id, byte display_flags, byte color, byte text_color, StringID tooltips, StringID text)
d8a2c6844650 (svn r8981) [cpp_gui] -Add: simple CaptionBar Widget
KUDr
parents: 6271
diff changeset
   299
		: CompositeWidget(container, id, display_flags, color, Rect16(0, 0, container->Width() - 1, DEFAULT_HEIGHT - 1), tooltips)
d8a2c6844650 (svn r8981) [cpp_gui] -Add: simple CaptionBar Widget
KUDr
parents: 6271
diff changeset
   300
		, m_text(text)
d8a2c6844650 (svn r8981) [cpp_gui] -Add: simple CaptionBar Widget
KUDr
parents: 6271
diff changeset
   301
		, m_text_color(text_color)
d8a2c6844650 (svn r8981) [cpp_gui] -Add: simple CaptionBar Widget
KUDr
parents: 6271
diff changeset
   302
	{}
d8a2c6844650 (svn r8981) [cpp_gui] -Add: simple CaptionBar Widget
KUDr
parents: 6271
diff changeset
   303
d8a2c6844650 (svn r8981) [cpp_gui] -Add: simple CaptionBar Widget
KUDr
parents: 6271
diff changeset
   304
	/*virtual*/ void DrawBackground(EvtPaint &ev);
d8a2c6844650 (svn r8981) [cpp_gui] -Add: simple CaptionBar Widget
KUDr
parents: 6271
diff changeset
   305
6278
c09f5e53af9b (svn r8986) [cpp_gui] -Add: resizing window by dragging ResizeBox
KUDr
parents: 6277
diff changeset
   306
	/*virtual*/ void OnCreate(EvtCreate &ev);
6273
d8a2c6844650 (svn r8981) [cpp_gui] -Add: simple CaptionBar Widget
KUDr
parents: 6271
diff changeset
   307
	/*virtual*/ void OnPaint(EvtPaint &ev);
6275
bd57b30a8b81 (svn r8983) [cpp_gui] -Add: moving window by dragging CaptionBar
KUDr
parents: 6273
diff changeset
   308
	/*virtual*/ void OnLeftClick(EvtClick &ev);
6277
732cf765e2d7 (svn r8985) [cpp_gui] -Cleanup: copy/paste error (CaptionBar::OnCaptureMoving method name)
KUDr
parents: 6275
diff changeset
   309
	void OnCaptureMoving(EvtMouseOver &e);
6273
d8a2c6844650 (svn r8981) [cpp_gui] -Add: simple CaptionBar Widget
KUDr
parents: 6271
diff changeset
   310
};
d8a2c6844650 (svn r8981) [cpp_gui] -Add: simple CaptionBar Widget
KUDr
parents: 6271
diff changeset
   311
6264
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
   312
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
   313
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
   314
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
   315
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
   316
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
   317
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
   318
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
   319
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
   320
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
   321
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
   322
}; // namespace gui
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
   323
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
   324
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
   325
#endif /* WIDGET_H */