src/widget/widget_composite.cpp
author KUDr
Sat, 03 Mar 2007 20:25:37 +0000
branchcpp_gui
changeset 6283 7072ee68c676
parent 6282 c5b92f2d924f
child 6295 a88d8c2cff6e
permissions -rw-r--r--
(svn r8997) [cpp_gui] -Codechange: common window features are now controlled by FeatureFlags enum.
-Caption bar, close box and resize box are created automatically depending on features specified in window ctor.
6258
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
     1
/* $Id$ */
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
     2
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
     3
#include "../stdafx.h"
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
     4
#include <stdarg.h>
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
     5
#include "../openttd.h"
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
     6
#include "../debug.h"
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
     7
#include "../functions.h"
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
     8
#include "../map.h"
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
     9
#include "../player.h"
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
    10
#include "../window.h"
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
    11
#include "../gfx.h"
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
    12
#include "../viewport.h"
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
    13
#include "../console.h"
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
    14
#include "../variables.h"
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
    15
#include "../table/sprites.h"
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
    16
#include "../genworld.h"
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
    17
#include "../helpers.hpp"
6264
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents: 6260
diff changeset
    18
#include "window_events.hpp"
6258
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
    19
6264
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents: 6260
diff changeset
    20
namespace gui {
6258
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
    21
6278
c09f5e53af9b (svn r8986) [cpp_gui] -Add: resizing window by dragging ResizeBox
KUDr
parents: 6264
diff changeset
    22
6258
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
    23
void CompositeWidget::AddWidget(Widget *wd)
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
    24
{
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
    25
	WidgetId id = wd->GetId();
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
    26
	std::pair<WidgetIterator, bool> pib = m_widgets.insert(Widgets::value_type(id, wd));
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
    27
	assert(pib.second);
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
    28
}
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
    29
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
    30
Widget* CompositeWidget::GetWidget(WidgetId id)
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
    31
{
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
    32
	WidgetIterator it = m_widgets.find(id);
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
    33
	return (it != m_widgets.end()) ? (*it).second : NULL;
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
    34
}
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
    35
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
    36
Widget* CompositeWidget::RemoveWidget(WidgetId id)
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
    37
{
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
    38
	WidgetIterator it = m_widgets.find(id);
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
    39
	if (it == m_widgets.end()) return NULL;
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
    40
	Widget *wd = (*it).second;
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
    41
	assert(wd->m_container == this);
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
    42
	wd->m_container = NULL;
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
    43
	m_widgets.erase(it);
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
    44
	return wd;
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
    45
}
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
    46
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
    47
/*virtual*/ Widget* CompositeWidget::WidgetFromPt(const Point16 &pt_parent)
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
    48
{
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
    49
	Point16 pt_local = pt_parent - TopLeft();
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
    50
	bool inside_me = m_rect.PtInRect(pt_parent);
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
    51
	for (WidgetReverseIterator rit = m_widgets.rbegin(); rit != m_widgets.rend(); ++rit) {
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
    52
		/* get next child */
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
    53
		Widget *wd_child = (*rit).second;
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
    54
		/* ask the child recursively */
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
    55
		Widget *wd = wd_child->WidgetFromPt(pt_local);
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
    56
		if (wd != NULL) {
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
    57
			/* if the widget we found is inside me it is what we are searching for */
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
    58
			if (inside_me) return wd;
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
    59
			/* the point is outside me. The widget is clipped unless it is on-top widget */
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
    60
			if (wd->m_dont_clip) return wd;
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
    61
			/* try next child */
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
    62
		}
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
    63
	}
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
    64
	return inside_me ? this : NULL;
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
    65
}
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
    66
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
    67
/*virtual*/ void CompositeWidget::Close()
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
    68
{
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
    69
	/* mark all children as closed in safe way */
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
    70
	for (WidgetReverseIterator rit_next = m_widgets.rbegin(); rit_next != m_widgets.rend(); ) {
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
    71
		/* save the iterator (it can be invalidated) and move forward */
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
    72
		WidgetReverseIterator rit = rit_next++;
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
    73
		/* get child */
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
    74
		Widget *wd_child = (*rit).second;
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
    75
		/* tell him we are closing */
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
    76
		wd_child->Close();
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
    77
	}
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
    78
	/* remove children */
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
    79
	m_widgets.clear();
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
    80
	/* mark self as closed */
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
    81
	super::Close();
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
    82
}
6260
740c702f6871 (svn r8804) [cpp_gui] -Codechange: BaseWindow now inherits from CompositeWidget (with no benefits yet)
KUDr
parents: 6258
diff changeset
    83
6278
c09f5e53af9b (svn r8986) [cpp_gui] -Add: resizing window by dragging ResizeBox
KUDr
parents: 6264
diff changeset
    84
/*virtual*/ void CompositeWidget::OnCreate(EvtCreate &ev)
c09f5e53af9b (svn r8986) [cpp_gui] -Add: resizing window by dragging ResizeBox
KUDr
parents: 6264
diff changeset
    85
{
6283
7072ee68c676 (svn r8997) [cpp_gui] -Codechange: common window features are now controlled by FeatureFlags enum.
KUDr
parents: 6282
diff changeset
    86
	/* create standard children */
6279
c75b2c7222ff (svn r8991) [cpp_gui] -Codechange: composite widgets (incl. windows) now must implement CreateWidgets() method which is called from the default OnCreate() implementation
KUDr
parents: 6278
diff changeset
    87
	CreateWidgets();
6283
7072ee68c676 (svn r8997) [cpp_gui] -Codechange: common window features are now controlled by FeatureFlags enum.
KUDr
parents: 6282
diff changeset
    88
	/* if there are any non-client widgets, create them */
7072ee68c676 (svn r8997) [cpp_gui] -Codechange: common window features are now controlled by FeatureFlags enum.
KUDr
parents: 6282
diff changeset
    89
	CreateNcWidgets();
6279
c75b2c7222ff (svn r8991) [cpp_gui] -Codechange: composite widgets (incl. windows) now must implement CreateWidgets() method which is called from the default OnCreate() implementation
KUDr
parents: 6278
diff changeset
    90
c75b2c7222ff (svn r8991) [cpp_gui] -Codechange: composite widgets (incl. windows) now must implement CreateWidgets() method which is called from the default OnCreate() implementation
KUDr
parents: 6278
diff changeset
    91
	/* notify all children that we are creating */
6278
c09f5e53af9b (svn r8986) [cpp_gui] -Add: resizing window by dragging ResizeBox
KUDr
parents: 6264
diff changeset
    92
	for (WidgetIterator it_next = m_widgets.begin(); it_next != m_widgets.end(); ) {
c09f5e53af9b (svn r8986) [cpp_gui] -Add: resizing window by dragging ResizeBox
KUDr
parents: 6264
diff changeset
    93
		/* save the iterator (it can be invalidated) and move forward */
c09f5e53af9b (svn r8986) [cpp_gui] -Add: resizing window by dragging ResizeBox
KUDr
parents: 6264
diff changeset
    94
		WidgetIterator it = it_next++;
c09f5e53af9b (svn r8986) [cpp_gui] -Add: resizing window by dragging ResizeBox
KUDr
parents: 6264
diff changeset
    95
		/* get child */
c09f5e53af9b (svn r8986) [cpp_gui] -Add: resizing window by dragging ResizeBox
KUDr
parents: 6264
diff changeset
    96
		Widget *wd_child = (*it).second;
c09f5e53af9b (svn r8986) [cpp_gui] -Add: resizing window by dragging ResizeBox
KUDr
parents: 6264
diff changeset
    97
		/* tell him we are creating window */
c09f5e53af9b (svn r8986) [cpp_gui] -Add: resizing window by dragging ResizeBox
KUDr
parents: 6264
diff changeset
    98
		wd_child->OnCreate(ev);
c09f5e53af9b (svn r8986) [cpp_gui] -Add: resizing window by dragging ResizeBox
KUDr
parents: 6264
diff changeset
    99
	}
6279
c75b2c7222ff (svn r8991) [cpp_gui] -Codechange: composite widgets (incl. windows) now must implement CreateWidgets() method which is called from the default OnCreate() implementation
KUDr
parents: 6278
diff changeset
   100
6278
c09f5e53af9b (svn r8986) [cpp_gui] -Add: resizing window by dragging ResizeBox
KUDr
parents: 6264
diff changeset
   101
	super::OnCreate(ev);
c09f5e53af9b (svn r8986) [cpp_gui] -Add: resizing window by dragging ResizeBox
KUDr
parents: 6264
diff changeset
   102
}
c09f5e53af9b (svn r8986) [cpp_gui] -Add: resizing window by dragging ResizeBox
KUDr
parents: 6264
diff changeset
   103
6264
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents: 6260
diff changeset
   104
/*virtual*/ void CompositeWidget::OnPaint(EvtPaint &ev)
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents: 6260
diff changeset
   105
{
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents: 6260
diff changeset
   106
	/* paint background */
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents: 6260
diff changeset
   107
	DrawBackground(ev);
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents: 6260
diff changeset
   108
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents: 6260
diff changeset
   109
	/* paint all children */
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents: 6260
diff changeset
   110
	for (WidgetIterator it_next = m_widgets.begin(); it_next != m_widgets.end(); ) {
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents: 6260
diff changeset
   111
		/* save the iterator (it can be invalidated) and move forward */
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents: 6260
diff changeset
   112
		WidgetIterator it = it_next++;
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents: 6260
diff changeset
   113
		/* get child */
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents: 6260
diff changeset
   114
		Widget *wd_child = (*it).second;
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents: 6260
diff changeset
   115
		/* tell him we are closing */
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents: 6260
diff changeset
   116
		wd_child->OnPaint(ev);
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents: 6260
diff changeset
   117
	}
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents: 6260
diff changeset
   118
}
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents: 6260
diff changeset
   119
6282
c5b92f2d924f (svn r8996) [cpp_gui] -Add: CloseBox added into CaptionBar
KUDr
parents: 6279
diff changeset
   120
/*virtual*/ void CompositeWidget::OnLeftButtonDown(EvtLeftButtonDown &ev)
6260
740c702f6871 (svn r8804) [cpp_gui] -Codechange: BaseWindow now inherits from CompositeWidget (with no benefits yet)
KUDr
parents: 6258
diff changeset
   121
{
740c702f6871 (svn r8804) [cpp_gui] -Codechange: BaseWindow now inherits from CompositeWidget (with no benefits yet)
KUDr
parents: 6258
diff changeset
   122
	//Point16 pt(ev->we.click.pt.x, ev->we.click.pt.y);
6264
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents: 6260
diff changeset
   123
	Widget *wd_child = WidgetFromPt(ev.m_pt);
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents: 6260
diff changeset
   124
	if (wd_child != NULL && wd_child != this) {
6282
c5b92f2d924f (svn r8996) [cpp_gui] -Add: CloseBox added into CaptionBar
KUDr
parents: 6279
diff changeset
   125
		wd_child->OnLeftButtonDown(ev);
6264
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents: 6260
diff changeset
   126
		return;
6260
740c702f6871 (svn r8804) [cpp_gui] -Codechange: BaseWindow now inherits from CompositeWidget (with no benefits yet)
KUDr
parents: 6258
diff changeset
   127
	}
6282
c5b92f2d924f (svn r8996) [cpp_gui] -Add: CloseBox added into CaptionBar
KUDr
parents: 6279
diff changeset
   128
	super::OnLeftButtonDown(ev);
6260
740c702f6871 (svn r8804) [cpp_gui] -Codechange: BaseWindow now inherits from CompositeWidget (with no benefits yet)
KUDr
parents: 6258
diff changeset
   129
}
6264
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents: 6260
diff changeset
   130
6282
c5b92f2d924f (svn r8996) [cpp_gui] -Add: CloseBox added into CaptionBar
KUDr
parents: 6279
diff changeset
   131
/*virtual*/ void CompositeWidget::OnRightButtonDown(EvtRightButtonDown &ev)
6264
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents: 6260
diff changeset
   132
{
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents: 6260
diff changeset
   133
	//Point16 pt(ev->we.click.pt.x, ev->we.click.pt.y);
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents: 6260
diff changeset
   134
	Widget *wd_child = WidgetFromPt(ev.m_pt);
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents: 6260
diff changeset
   135
	if (wd_child != NULL && wd_child != this) {
6282
c5b92f2d924f (svn r8996) [cpp_gui] -Add: CloseBox added into CaptionBar
KUDr
parents: 6279
diff changeset
   136
		wd_child->OnRightButtonDown(ev);
6264
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents: 6260
diff changeset
   137
		return;
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents: 6260
diff changeset
   138
	}
6282
c5b92f2d924f (svn r8996) [cpp_gui] -Add: CloseBox added into CaptionBar
KUDr
parents: 6279
diff changeset
   139
	super::OnRightButtonDown(ev);
6264
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents: 6260
diff changeset
   140
}
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents: 6260
diff changeset
   141
6278
c09f5e53af9b (svn r8986) [cpp_gui] -Add: resizing window by dragging ResizeBox
KUDr
parents: 6264
diff changeset
   142
/*virtual*/ void CompositeWidget::OnResize(EvtResize &ev)
c09f5e53af9b (svn r8986) [cpp_gui] -Add: resizing window by dragging ResizeBox
KUDr
parents: 6264
diff changeset
   143
{
c09f5e53af9b (svn r8986) [cpp_gui] -Add: resizing window by dragging ResizeBox
KUDr
parents: 6264
diff changeset
   144
	if (ev.m_change == Point16(0, 0)) return;
c09f5e53af9b (svn r8986) [cpp_gui] -Add: resizing window by dragging ResizeBox
KUDr
parents: 6264
diff changeset
   145
c09f5e53af9b (svn r8986) [cpp_gui] -Add: resizing window by dragging ResizeBox
KUDr
parents: 6264
diff changeset
   146
	EvtResizeParent evp(ev);
c09f5e53af9b (svn r8986) [cpp_gui] -Add: resizing window by dragging ResizeBox
KUDr
parents: 6264
diff changeset
   147
	/* notify all children */
c09f5e53af9b (svn r8986) [cpp_gui] -Add: resizing window by dragging ResizeBox
KUDr
parents: 6264
diff changeset
   148
	for (WidgetIterator it_next = m_widgets.begin(); it_next != m_widgets.end(); ) {
c09f5e53af9b (svn r8986) [cpp_gui] -Add: resizing window by dragging ResizeBox
KUDr
parents: 6264
diff changeset
   149
		/* save the iterator (it can be invalidated) and move forward */
c09f5e53af9b (svn r8986) [cpp_gui] -Add: resizing window by dragging ResizeBox
KUDr
parents: 6264
diff changeset
   150
		WidgetIterator it = it_next++;
c09f5e53af9b (svn r8986) [cpp_gui] -Add: resizing window by dragging ResizeBox
KUDr
parents: 6264
diff changeset
   151
		/* get child */
c09f5e53af9b (svn r8986) [cpp_gui] -Add: resizing window by dragging ResizeBox
KUDr
parents: 6264
diff changeset
   152
		Widget *wd_child = (*it).second;
c09f5e53af9b (svn r8986) [cpp_gui] -Add: resizing window by dragging ResizeBox
KUDr
parents: 6264
diff changeset
   153
		/* tell him we are resizing */
c09f5e53af9b (svn r8986) [cpp_gui] -Add: resizing window by dragging ResizeBox
KUDr
parents: 6264
diff changeset
   154
		wd_child->OnResizeParent(evp);
c09f5e53af9b (svn r8986) [cpp_gui] -Add: resizing window by dragging ResizeBox
KUDr
parents: 6264
diff changeset
   155
	}
c09f5e53af9b (svn r8986) [cpp_gui] -Add: resizing window by dragging ResizeBox
KUDr
parents: 6264
diff changeset
   156
	super::OnResize(ev);
c09f5e53af9b (svn r8986) [cpp_gui] -Add: resizing window by dragging ResizeBox
KUDr
parents: 6264
diff changeset
   157
}
c09f5e53af9b (svn r8986) [cpp_gui] -Add: resizing window by dragging ResizeBox
KUDr
parents: 6264
diff changeset
   158
6264
9fc3b5467396 (svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents: 6260
diff changeset
   159
}; // namespace gui