aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/src/others/irrlicht-1.8.1/tools/GUIEditor/CGUIPanel.h
blob: cb6f79a5f8900a42e69c71bf812aeaa8d641142a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
// Copyright 2006-2012 Asger Feldthaus
// This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in irrlicht.h

#ifndef _C_GUI_PANEL_H_
#define _C_GUI_PANEL_H_

#include "IGUIElement.h"
#include "EGUIEditTypes.h"

namespace irr
{
namespace gui
{

class IGUIScrollBar;
class IGUITab;

enum E_SCROLL_BAR_MODE
{
	//! The scrollbar will only show up when needed.
	ESBM_AUTOMATIC = 0,

	//! The scrollbar will never be visible.
	ESBM_ALWAYS_INVISIBLE,

	//! The scrollbar will always the visible.
	ESBM_ALWAYS_VISIBLE,

	//! just a count of how many are in this enum
	ESBM_COUNT
};

const c8* const GUIScrollBarModeNames[] =
{
	"automatic",
	"alwaysInvisible",
	"alwaysVisible",
	0
};

class CGUIPanel : public IGUIElement
{
public:
	CGUIPanel( IGUIEnvironment* environment, IGUIElement* parent, s32 id=-1,
			const core::rect<s32>& rectangle = core::rect<s32>(0,0,100,100),
			bool border=false,
			E_SCROLL_BAR_MODE vMode=ESBM_AUTOMATIC,
			E_SCROLL_BAR_MODE hMode=ESBM_ALWAYS_INVISIBLE );

	virtual ~CGUIPanel();

	//! draws the panel and its children
	virtual void draw();

	//! returns true if it has a border, false if not
	bool hasBorder() const;

	//! sets whether the element draws a border
	void setBorder(bool enabled);

	//! returns a pointer to the vertical scrollbar
	IGUIScrollBar* getVScrollBar() const;

	//! returns a pointer to the horizontal scrollbar
	IGUIScrollBar* getHScrollBar() const;

	//! returns the vertical scrollbar visibility rule
	E_SCROLL_BAR_MODE getVScrollBarMode() const;

	//! sets the vertical scrollbar visibility rule
	void setVScrollBarMode(E_SCROLL_BAR_MODE mode);

	//! returns the horizontal scrollbar visibility rule
	E_SCROLL_BAR_MODE getHScrollBarMode() const;

	//! sets the horizontal scrollbar visibility rule
	void setHScrollBarMode(E_SCROLL_BAR_MODE mode);

	//! returns the visible area inside the panel, excluding scrollbar and border
	core::rect<s32> getClientArea() const;

	virtual bool OnEvent(const SEvent &event);

	//! adds a child to the panel
	virtual void addChild(IGUIElement* child);

	//! removes a child from the panel
	virtual void removeChild(IGUIElement* child);

	//! updates the absolute position
	virtual void updateAbsolutePosition();

	//! returns children of the inner pane
	virtual const core::list<IGUIElement*>& getChildren();

	//! Returns the type name of the gui element.
	virtual const c8* getTypeName() const
	{
		return GUIEditElementTypeNames[EGUIEDIT_GUIPANEL];
	}

	virtual void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options=0);
	virtual void deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options=0);

protected:
	void moveInnerPane();
	void resizeInnerPane();
	void calculateClientArea();

private:

	IGUIScrollBar*	VScrollBar;
	IGUIScrollBar*	HScrollBar;
	IGUITab*	ClipPane;
	IGUITab*	InnerPane;

	E_SCROLL_BAR_MODE VScrollBarMode;
	E_SCROLL_BAR_MODE HScrollBarMode;

	bool NeedsUpdate;
	bool Border;
};

} // namespace gui
} // namespace irr

#endif