src/widget/window_event_base.h
author KUDr
Sat, 21 Apr 2007 08:23:57 +0000
branchcpp_gui
changeset 6308 646711c5feaa
parent 6282 c5b92f2d924f
permissions -rw-r--r--
(svn r9708) [cpp_gui] -Sync with trunk (r9633:9707)
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 WINDOW_EVENT_BASE_H
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
     4
#define WINDOW_EVENT_BASE_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
struct BaseWindow;
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
     7
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
     8
namespace gui {
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
     9
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
    10
enum EventCode {
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
    11
	EVT_CREATE,
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
    12
	EVT_DESTROY,
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
    13
	EVT_PAINT,
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
    14
	EVT_KEYPRESS,
6282
c5b92f2d924f (svn r8996) [cpp_gui] -Add: CloseBox added into CaptionBar
KUDr
parents: 6280
diff changeset
    15
	EVT_LBUTTON_DOWN,
c5b92f2d924f (svn r8996) [cpp_gui] -Add: CloseBox added into CaptionBar
KUDr
parents: 6280
diff changeset
    16
	EVT_LEFT_CLICK,
c5b92f2d924f (svn r8996) [cpp_gui] -Add: CloseBox added into CaptionBar
KUDr
parents: 6280
diff changeset
    17
	EVT_RBUTTON_DOWN,
6264
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
    18
	EVT_MOUSEOVER,
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
    19
	EVT_MOUSELOOP,
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
    20
	EVT_MOUSEWHEEL,
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
    21
	EVT_TICK,
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
    22
	EVT_4,
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
    23
	EVT_TIMEOUT,
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
    24
	EVT_PLACE_OBJ,
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
    25
	EVT_ABORT_PLACE_OBJ,
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
    26
	EVT_ON_EDIT_TEXT,
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
    27
	EVT_ON_EDIT_TEXT_CANCEL,
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
    28
	EVT_POPUPMENU_SELECT,
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
    29
	EVT_POPUPMENU_OVER,
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
    30
	EVT_DRAGDROP,
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
    31
	EVT_PLACE_DRAG,
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
    32
	EVT_PLACE_MOUSEUP,
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
    33
	EVT_PLACE_PRESIZE,
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
    34
	EVT_DROPDOWN_SELECT,
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
    35
	EVT_RESIZE,
6278
c09f5e53af9b (svn r8986) [cpp_gui] -Add: resizing window by dragging ResizeBox
KUDr
parents: 6271
diff changeset
    36
	EVT_RESIZE_PARENT,
6264
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
    37
	EVT_MESSAGE,
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
    38
	EVT_SCROLL,
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
    39
	EVT_INVALIDATE_DATA,
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
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
    42
template <EventCode Tcode> struct EventT;
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
typedef EventT<EVT_CREATE             > EvtCreate;
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
    45
typedef EventT<EVT_DESTROY            > EvtDestroy;
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
    46
typedef EventT<EVT_PAINT              > EvtPaint;
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
    47
typedef EventT<EVT_KEYPRESS           > EvtKeyPress;
6282
c5b92f2d924f (svn r8996) [cpp_gui] -Add: CloseBox added into CaptionBar
KUDr
parents: 6280
diff changeset
    48
typedef EventT<EVT_LBUTTON_DOWN       > EvtLeftButtonDown;
c5b92f2d924f (svn r8996) [cpp_gui] -Add: CloseBox added into CaptionBar
KUDr
parents: 6280
diff changeset
    49
typedef EventT<EVT_LEFT_CLICK         > EvtLeftClick;
c5b92f2d924f (svn r8996) [cpp_gui] -Add: CloseBox added into CaptionBar
KUDr
parents: 6280
diff changeset
    50
typedef EventT<EVT_RBUTTON_DOWN       > EvtRightButtonDown;
6264
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
    51
typedef EventT<EVT_MOUSEOVER          > EvtMouseOver;
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
    52
typedef EventT<EVT_MOUSELOOP          > EvtMouseLoop;
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
    53
typedef EventT<EVT_MOUSEWHEEL         > EvtMouseWheel;
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
    54
typedef EventT<EVT_TICK               > EvtTick;
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
    55
typedef EventT<EVT_4                  > Evt4;
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
    56
typedef EventT<EVT_TIMEOUT            > EvtTimeout;
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
    57
typedef EventT<EVT_PLACE_OBJ          > EvtPlaceObj;
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
    58
typedef EventT<EVT_ABORT_PLACE_OBJ    > EvtAbortPlaceObj;
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
    59
typedef EventT<EVT_ON_EDIT_TEXT       > EvtOnEditText;
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
    60
typedef EventT<EVT_ON_EDIT_TEXT_CANCEL> EvtOnEditTextCancel;
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
    61
typedef EventT<EVT_POPUPMENU_SELECT   > EvtPopupMenuSelect;
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
    62
typedef EventT<EVT_POPUPMENU_OVER     > EvtPopupMenuOver;
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
    63
typedef EventT<EVT_DRAGDROP           > EvtDragDrop;
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
    64
typedef EventT<EVT_PLACE_DRAG         > EvtPlaceDrag;
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
    65
typedef EventT<EVT_PLACE_MOUSEUP      > EvtPlaceMouseUp;
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
    66
typedef EventT<EVT_PLACE_PRESIZE      > EvtPlacePresize;
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
    67
typedef EventT<EVT_DROPDOWN_SELECT    > EvtDropdownSelect;
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
    68
typedef EventT<EVT_RESIZE             > EvtResize;
6278
c09f5e53af9b (svn r8986) [cpp_gui] -Add: resizing window by dragging ResizeBox
KUDr
parents: 6271
diff changeset
    69
typedef EventT<EVT_RESIZE_PARENT      > EvtResizeParent;
6264
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
    70
typedef EventT<EVT_MESSAGE            > EvtMessage;
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
    71
typedef EventT<EVT_SCROLL             > EvtScroll;
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
    72
typedef EventT<EVT_INVALIDATE_DATA    > EvtInvalidateData;
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
    73
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
    74
struct Widget;
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
    75
typedef CCountedPtr<Widget> WidgetPtr;
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
    76
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
    77
/** Base of all gui events. Never constructed directly. Used as base class
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
    78
 *  of event types */
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
    79
struct EventBase {
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
    80
protected:
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
    81
	EventCode m_code;
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
    82
	bool      m_handled;
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
    83
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
    84
public:
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
    85
	WidgetPtr m_widget;
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
    86
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
    87
protected:
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
    88
	/** protected constructor (called from subclasses only) */
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
    89
	EventBase(EventCode code)
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
    90
		: m_code(code)
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
    91
		, m_handled(false)
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
    92
	{}
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
    93
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
    94
public:
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
    95
	virtual ~EventBase() {}
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
    96
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
    97
	/** @return event code */
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
    98
	EventCode GetCode() const
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
    99
	{
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
   100
		return m_code;
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
   101
	}
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
   102
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
   103
	/** @return true if event was already handled */
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
   104
	bool IsHandled() const
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
   105
	{
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
   106
		return m_handled;
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
   107
	}
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
   108
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
   109
	void SetHandled(bool handled = true)
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
   110
	{
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
   111
		m_handled = handled;
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
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
   114
	/** type-safe conversion operator */
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
   115
	//template <EventCode Tcode> operator EventT<Tcode>& ()
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
   116
	//{
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
   117
	//	assert(m_code == Tcode);
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
   118
	//	return *(EventT<Tcode>*)this;
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
   119
	//}
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 Dispatch() = 0;
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
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
   124
/** Intermediate event base that calls EventBase constructor with the proper event type as parameter.
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
   125
 *  Used only by event subclasses */
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
   126
template <EventCode Tcode, void (Widget::*Tevt_method)(EventT<Tcode> &)> struct EventBaseT : public EventBase {
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
   127
	static const EventCode ID = Tcode; ///< allow access to event codes by class name (i.e. EvtCreate::ID)
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
   128
protected:
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
   129
	EventBaseT()
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
   130
		: EventBase(Tcode)
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
   131
	{}
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
   132
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
   133
	/*virtual*/ void Dispatch()
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
   134
	{
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
   135
		assert(!m_widget.IsNull());
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
   136
		assert(m_code == Tcode);
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
   137
		(m_widget->*Tevt_method)(*(EventT<Tcode>*)this);
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
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
 * Base of all Event Handler Delegates - class that represents Event Handler object/method
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
   143
 * pair that can be called by widget when particular event is handled by a widget. Object
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
   144
 * of any type can register itself and its method as gui event callback handler by adding
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
   145
 * the appropriate delegate object into widget handler list.
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
   146
 */
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
   147
struct EventHandlerDelegate : public SimpleCountedObject {
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
   148
	EventCode m_code;     ///< event code this handler is registered for
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
   149
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
   150
	EventHandlerDelegate(EventCode code)
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
   151
		: m_code(code)
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
	/**
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
   155
	 * The only method that delegate must provide. Called by widget if the appropriate event
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
   156
	 * is reflected.
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
   157
	 */
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
   158
	virtual void HandleEvent(BaseWindow *w, EventBase &e) = 0;
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
   159
};
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
/** Reference counting pointer to the event handler delegate. */
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
   162
typedef CCountedPtr<EventHandlerDelegate> EventHandlerDelegatePtr;
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
   163
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
   164
/**
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
   165
 * Delegate for handlers of events reflected back from widget to window.
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
   166
 */
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
   167
template <class Twnd_cls, EventCode Tevt_code> struct ReflectHandlerDelegateT : public EventHandlerDelegate {
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
   168
	void (Twnd_cls::*m_handler)(EventT<Tevt_code>&);
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
   169
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
   170
	ReflectHandlerDelegateT(void (Twnd_cls::*handler)(EventT<Tevt_code>&))
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
   171
		: EventHandlerDelegate(Tevt_code)
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
   172
		, m_handler(handler)
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
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
   175
	virtual void HandleEvent(BaseWindow *w, EventBase &e)
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
   176
	{
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
   177
		assert(e.GetCode() == Tevt_code);
6271
0ad100a98853 (svn r8958) [cpp_gui] -Add: Widget can now capture specified gui events
KUDr
parents: 6264
diff changeset
   178
		assert(w != NULL);
6264
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
   179
		Twnd_cls &wnd = *(Twnd_cls*)w;
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
   180
		EventT<Tevt_code> &ev = *(EventT<Tevt_code>*)&e;
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
   181
		(wnd.*m_handler)(ev);
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
};
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
   184
6271
0ad100a98853 (svn r8958) [cpp_gui] -Add: Widget can now capture specified gui events
KUDr
parents: 6264
diff changeset
   185
/**
0ad100a98853 (svn r8958) [cpp_gui] -Add: Widget can now capture specified gui events
KUDr
parents: 6264
diff changeset
   186
 * Delegate for capture handlers (inside widget)
0ad100a98853 (svn r8958) [cpp_gui] -Add: Widget can now capture specified gui events
KUDr
parents: 6264
diff changeset
   187
 */
0ad100a98853 (svn r8958) [cpp_gui] -Add: Widget can now capture specified gui events
KUDr
parents: 6264
diff changeset
   188
template <class Twd_cls, EventCode Tevt_code> struct CaptureHandlerDelegateT : public EventHandlerDelegate {
0ad100a98853 (svn r8958) [cpp_gui] -Add: Widget can now capture specified gui events
KUDr
parents: 6264
diff changeset
   189
	Twd_cls *m_widget;
0ad100a98853 (svn r8958) [cpp_gui] -Add: Widget can now capture specified gui events
KUDr
parents: 6264
diff changeset
   190
	void (Twd_cls::*m_handler)(EventT<Tevt_code>&);
0ad100a98853 (svn r8958) [cpp_gui] -Add: Widget can now capture specified gui events
KUDr
parents: 6264
diff changeset
   191
0ad100a98853 (svn r8958) [cpp_gui] -Add: Widget can now capture specified gui events
KUDr
parents: 6264
diff changeset
   192
	CaptureHandlerDelegateT(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: 6264
diff changeset
   193
		: EventHandlerDelegate(Tevt_code)
0ad100a98853 (svn r8958) [cpp_gui] -Add: Widget can now capture specified gui events
KUDr
parents: 6264
diff changeset
   194
		, m_widget(wd)
0ad100a98853 (svn r8958) [cpp_gui] -Add: Widget can now capture specified gui events
KUDr
parents: 6264
diff changeset
   195
		, m_handler(handler)
0ad100a98853 (svn r8958) [cpp_gui] -Add: Widget can now capture specified gui events
KUDr
parents: 6264
diff changeset
   196
	{
0ad100a98853 (svn r8958) [cpp_gui] -Add: Widget can now capture specified gui events
KUDr
parents: 6264
diff changeset
   197
		assert(wd != NULL);
0ad100a98853 (svn r8958) [cpp_gui] -Add: Widget can now capture specified gui events
KUDr
parents: 6264
diff changeset
   198
	}
0ad100a98853 (svn r8958) [cpp_gui] -Add: Widget can now capture specified gui events
KUDr
parents: 6264
diff changeset
   199
0ad100a98853 (svn r8958) [cpp_gui] -Add: Widget can now capture specified gui events
KUDr
parents: 6264
diff changeset
   200
	virtual void HandleEvent(BaseWindow *w, EventBase &e)
0ad100a98853 (svn r8958) [cpp_gui] -Add: Widget can now capture specified gui events
KUDr
parents: 6264
diff changeset
   201
	{
0ad100a98853 (svn r8958) [cpp_gui] -Add: Widget can now capture specified gui events
KUDr
parents: 6264
diff changeset
   202
		assert(e.GetCode() == Tevt_code);
0ad100a98853 (svn r8958) [cpp_gui] -Add: Widget can now capture specified gui events
KUDr
parents: 6264
diff changeset
   203
		EventT<Tevt_code> &ev = *(EventT<Tevt_code>*)&e;
0ad100a98853 (svn r8958) [cpp_gui] -Add: Widget can now capture specified gui events
KUDr
parents: 6264
diff changeset
   204
		(m_widget->*m_handler)(ev);
0ad100a98853 (svn r8958) [cpp_gui] -Add: Widget can now capture specified gui events
KUDr
parents: 6264
diff changeset
   205
	}
0ad100a98853 (svn r8958) [cpp_gui] -Add: Widget can now capture specified gui events
KUDr
parents: 6264
diff changeset
   206
};
0ad100a98853 (svn r8958) [cpp_gui] -Add: Widget can now capture specified gui events
KUDr
parents: 6264
diff changeset
   207
0ad100a98853 (svn r8958) [cpp_gui] -Add: Widget can now capture specified gui events
KUDr
parents: 6264
diff changeset
   208
0ad100a98853 (svn r8958) [cpp_gui] -Add: Widget can now capture specified gui events
KUDr
parents: 6264
diff changeset
   209
/**
0ad100a98853 (svn r8958) [cpp_gui] -Add: Widget can now capture specified gui events
KUDr
parents: 6264
diff changeset
   210
 * Event Capture Stack - widgets can register their Event Handler Delegates here
0ad100a98853 (svn r8958) [cpp_gui] -Add: Widget can now capture specified gui events
KUDr
parents: 6264
diff changeset
   211
 * to override default event processing dynamically. For example when moving window
0ad100a98853 (svn r8958) [cpp_gui] -Add: Widget can now capture specified gui events
KUDr
parents: 6264
diff changeset
   212
 * by dragging its caption bar, CaptionBar widget can capture mouse move events and
0ad100a98853 (svn r8958) [cpp_gui] -Add: Widget can now capture specified gui events
KUDr
parents: 6264
diff changeset
   213
 * process them until the mouse button is released.
0ad100a98853 (svn r8958) [cpp_gui] -Add: Widget can now capture specified gui events
KUDr
parents: 6264
diff changeset
   214
 * When gui event occurs, the stack is searched from front (last added delegate) to
0ad100a98853 (svn r8958) [cpp_gui] -Add: Widget can now capture specified gui events
KUDr
parents: 6264
diff changeset
   215
 * back and if the appropriate handler delegate (same event code) is found, it is
0ad100a98853 (svn r8958) [cpp_gui] -Add: Widget can now capture specified gui events
KUDr
parents: 6264
diff changeset
   216
 * called (given the event object). If this handler wants to prevent further event
0ad100a98853 (svn r8958) [cpp_gui] -Add: Widget can now capture specified gui events
KUDr
parents: 6264
diff changeset
   217
 * processing (by other handlers) it must set EventBase::m_handled to true by calling
0ad100a98853 (svn r8958) [cpp_gui] -Add: Widget can now capture specified gui events
KUDr
parents: 6264
diff changeset
   218
 * e->SetHandled();. Otherwise the next handler is taken from the stack or the event
0ad100a98853 (svn r8958) [cpp_gui] -Add: Widget can now capture specified gui events
KUDr
parents: 6264
diff changeset
   219
 * is processed by standard way.
0ad100a98853 (svn r8958) [cpp_gui] -Add: Widget can now capture specified gui events
KUDr
parents: 6264
diff changeset
   220
 */
0ad100a98853 (svn r8958) [cpp_gui] -Add: Widget can now capture specified gui events
KUDr
parents: 6264
diff changeset
   221
struct EventCaptureStack {
0ad100a98853 (svn r8958) [cpp_gui] -Add: Widget can now capture specified gui events
KUDr
parents: 6264
diff changeset
   222
	/** delegates are stored as a list of smart pointers to delegates */
0ad100a98853 (svn r8958) [cpp_gui] -Add: Widget can now capture specified gui events
KUDr
parents: 6264
diff changeset
   223
	typedef std::list<AdaptT<EventHandlerDelegatePtr> > Handlers;
0ad100a98853 (svn r8958) [cpp_gui] -Add: Widget can now capture specified gui events
KUDr
parents: 6264
diff changeset
   224
0ad100a98853 (svn r8958) [cpp_gui] -Add: Widget can now capture specified gui events
KUDr
parents: 6264
diff changeset
   225
	/**
0ad100a98853 (svn r8958) [cpp_gui] -Add: Widget can now capture specified gui events
KUDr
parents: 6264
diff changeset
   226
	 * Capture Ticket - issued by EventCaptureStack when new handler registers itself
0ad100a98853 (svn r8958) [cpp_gui] -Add: Widget can now capture specified gui events
KUDr
parents: 6264
diff changeset
   227
	 * in order to capture input events. Widget must save it in the safe place to keep
0ad100a98853 (svn r8958) [cpp_gui] -Add: Widget can now capture specified gui events
KUDr
parents: 6264
diff changeset
   228
	 * the input capture. When ticket gets destroyed, handler is automatically removed
0ad100a98853 (svn r8958) [cpp_gui] -Add: Widget can now capture specified gui events
KUDr
parents: 6264
diff changeset
   229
	 * from the capture stack.
0ad100a98853 (svn r8958) [cpp_gui] -Add: Widget can now capture specified gui events
KUDr
parents: 6264
diff changeset
   230
	 */
0ad100a98853 (svn r8958) [cpp_gui] -Add: Widget can now capture specified gui events
KUDr
parents: 6264
diff changeset
   231
	struct CaptureTicket {
0ad100a98853 (svn r8958) [cpp_gui] -Add: Widget can now capture specified gui events
KUDr
parents: 6264
diff changeset
   232
	protected:
0ad100a98853 (svn r8958) [cpp_gui] -Add: Widget can now capture specified gui events
KUDr
parents: 6264
diff changeset
   233
		mutable Handlers::iterator m_it;          ///< iterator to that stack (to know which handler it belongs to)
0ad100a98853 (svn r8958) [cpp_gui] -Add: Widget can now capture specified gui events
KUDr
parents: 6264
diff changeset
   234
	public:
0ad100a98853 (svn r8958) [cpp_gui] -Add: Widget can now capture specified gui events
KUDr
parents: 6264
diff changeset
   235
		CaptureTicket();                          ///< constructs clean ticket
0ad100a98853 (svn r8958) [cpp_gui] -Add: Widget can now capture specified gui events
KUDr
parents: 6264
diff changeset
   236
		CaptureTicket(Handlers::iterator it);     ///< constructs ticket from iterator
0ad100a98853 (svn r8958) [cpp_gui] -Add: Widget can now capture specified gui events
KUDr
parents: 6264
diff changeset
   237
		CaptureTicket(const CaptureTicket &src);  ///< takeover iterator (detach from src, attach to this)
0ad100a98853 (svn r8958) [cpp_gui] -Add: Widget can now capture specified gui events
KUDr
parents: 6264
diff changeset
   238
		~CaptureTicket();                         ///< call Release() and destroy ticket
6280
57f6156a327d (svn r8992) [cpp_gui] -Add: CaptureTicket::IsActive() to determine if the ticket is in use
KUDr
parents: 6278
diff changeset
   239
		bool IsActive() const;                    ///< determines whether the CaptureTicket is in use
6271
0ad100a98853 (svn r8958) [cpp_gui] -Add: Widget can now capture specified gui events
KUDr
parents: 6264
diff changeset
   240
		void Attach(Handlers::iterator it);       ///< Attach iterator to the ticket
0ad100a98853 (svn r8958) [cpp_gui] -Add: Widget can now capture specified gui events
KUDr
parents: 6264
diff changeset
   241
		Handlers::iterator Detach() const;        ///< Detach iterator from ticket (give up ownership)
0ad100a98853 (svn r8958) [cpp_gui] -Add: Widget can now capture specified gui events
KUDr
parents: 6264
diff changeset
   242
		void Release();                           ///< remove Event Capture Delegate from the Stack
0ad100a98853 (svn r8958) [cpp_gui] -Add: Widget can now capture specified gui events
KUDr
parents: 6264
diff changeset
   243
		CaptureTicket& operator = (const CaptureTicket &src);
0ad100a98853 (svn r8958) [cpp_gui] -Add: Widget can now capture specified gui events
KUDr
parents: 6264
diff changeset
   244
	};
0ad100a98853 (svn r8958) [cpp_gui] -Add: Widget can now capture specified gui events
KUDr
parents: 6264
diff changeset
   245
0ad100a98853 (svn r8958) [cpp_gui] -Add: Widget can now capture specified gui events
KUDr
parents: 6264
diff changeset
   246
protected:
0ad100a98853 (svn r8958) [cpp_gui] -Add: Widget can now capture specified gui events
KUDr
parents: 6264
diff changeset
   247
0ad100a98853 (svn r8958) [cpp_gui] -Add: Widget can now capture specified gui events
KUDr
parents: 6264
diff changeset
   248
	Handlers m_handlers;   ///< handler delegates are stored here
0ad100a98853 (svn r8958) [cpp_gui] -Add: Widget can now capture specified gui events
KUDr
parents: 6264
diff changeset
   249
0ad100a98853 (svn r8958) [cpp_gui] -Add: Widget can now capture specified gui events
KUDr
parents: 6264
diff changeset
   250
	/** add new delegate into list and return its iterator - called from Add() */
0ad100a98853 (svn r8958) [cpp_gui] -Add: Widget can now capture specified gui events
KUDr
parents: 6264
diff changeset
   251
	Handlers::iterator InternalAdd(EventHandlerDelegate *delegate);
0ad100a98853 (svn r8958) [cpp_gui] -Add: Widget can now capture specified gui events
KUDr
parents: 6264
diff changeset
   252
	/** remove handler referenced by the given iterator - called from CaptureTicket::Release() */
0ad100a98853 (svn r8958) [cpp_gui] -Add: Widget can now capture specified gui events
KUDr
parents: 6264
diff changeset
   253
	void InternalRemove(Handlers::iterator it);
0ad100a98853 (svn r8958) [cpp_gui] -Add: Widget can now capture specified gui events
KUDr
parents: 6264
diff changeset
   254
	/** handle event and return true if event was captured */
0ad100a98853 (svn r8958) [cpp_gui] -Add: Widget can now capture specified gui events
KUDr
parents: 6264
diff changeset
   255
	bool InternalHandleEvent(EventBase &e);
0ad100a98853 (svn r8958) [cpp_gui] -Add: Widget can now capture specified gui events
KUDr
parents: 6264
diff changeset
   256
	/** return the instance of EventCaptureStack - assuming there is only one global instance */
0ad100a98853 (svn r8958) [cpp_gui] -Add: Widget can now capture specified gui events
KUDr
parents: 6264
diff changeset
   257
	static EventCaptureStack& GetInstance();
0ad100a98853 (svn r8958) [cpp_gui] -Add: Widget can now capture specified gui events
KUDr
parents: 6264
diff changeset
   258
0ad100a98853 (svn r8958) [cpp_gui] -Add: Widget can now capture specified gui events
KUDr
parents: 6264
diff changeset
   259
public:
0ad100a98853 (svn r8958) [cpp_gui] -Add: Widget can now capture specified gui events
KUDr
parents: 6264
diff changeset
   260
	/**
0ad100a98853 (svn r8958) [cpp_gui] -Add: Widget can now capture specified gui events
KUDr
parents: 6264
diff changeset
   261
	 * iterate through capture handler list and try to handle event
0ad100a98853 (svn r8958) [cpp_gui] -Add: Widget can now capture specified gui events
KUDr
parents: 6264
diff changeset
   262
	 * @return true if event was handled (no default processing is necessary)
0ad100a98853 (svn r8958) [cpp_gui] -Add: Widget can now capture specified gui events
KUDr
parents: 6264
diff changeset
   263
	 */
0ad100a98853 (svn r8958) [cpp_gui] -Add: Widget can now capture specified gui events
KUDr
parents: 6264
diff changeset
   264
	static bool HandleEvent(EventBase &e);
0ad100a98853 (svn r8958) [cpp_gui] -Add: Widget can now capture specified gui events
KUDr
parents: 6264
diff changeset
   265
0ad100a98853 (svn r8958) [cpp_gui] -Add: Widget can now capture specified gui events
KUDr
parents: 6264
diff changeset
   266
	/** use it to add your own capture handler */
0ad100a98853 (svn r8958) [cpp_gui] -Add: Widget can now capture specified gui events
KUDr
parents: 6264
diff changeset
   267
	static CaptureTicket AddHandler(EventHandlerDelegate *delegate);
0ad100a98853 (svn r8958) [cpp_gui] -Add: Widget can now capture specified gui events
KUDr
parents: 6264
diff changeset
   268
};
0ad100a98853 (svn r8958) [cpp_gui] -Add: Widget can now capture specified gui events
KUDr
parents: 6264
diff changeset
   269
0ad100a98853 (svn r8958) [cpp_gui] -Add: Widget can now capture specified gui events
KUDr
parents: 6264
diff changeset
   270
typedef EventCaptureStack::CaptureTicket CaptureTicket;
0ad100a98853 (svn r8958) [cpp_gui] -Add: Widget can now capture specified gui events
KUDr
parents: 6264
diff changeset
   271
6264
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
   272
}; // namespace gui
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
   273
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff changeset
   274
#endif /* WINDOW_EVENT_BASE_H */