1/*
2 * Copyright 2010, Haiku.
3 * Distributed under the terms of the MIT License.
4 *
5 * Authors:
6 *		Clemens Zeidler <haiku@clemens-zeidler.de>
7 */
8#ifndef SAT_WINDOW_H
9#define SAT_WINDOW_H
10
11
12#include <Region.h>
13
14#include "SATDecorator.h"
15#include "SATGroup.h"
16#include "Stacking.h"
17#include "Tiling.h"
18
19
20class Desktop;
21class SATGroup;
22class StackAndTile;
23class Window;
24
25
26class SATWindow {
27public:
28								SATWindow(StackAndTile* sat, Window* window);
29								~SATWindow();
30
31			Window*				GetWindow() { return fWindow; }
32			SATDecorator*		GetDecorator() const;
33			StackAndTile*		GetStackAndTile() { return fStackAndTile; }
34			Desktop*			GetDesktop() { return fDesktop; }
35			//! Can be NULL if memory allocation failed!
36			SATGroup*			GetGroup();
37			WindowArea*			GetWindowArea() { return fWindowArea; }
38
39			bool				HandleMessage(SATWindow* sender,
40									BPrivate::LinkReceiver& link,
41									BPrivate::LinkSender& reply);
42
43			bool				PropagateToGroup(SATGroup* group);
44
45			// hook function called from SATGroup
46			bool				AddedToGroup(SATGroup* group, WindowArea* area);
47			bool				RemovedFromGroup(SATGroup* group,
48									bool stayBelowMouse);
49			void				RemovedFromArea(WindowArea* area);
50			void				WindowLookChanged(window_look look);
51
52			bool				StackWindow(SATWindow* child);
53
54			void				FindSnappingCandidates();
55			bool				JoinCandidates();
56			void				DoGroupLayout();
57
58			void				AdjustSizeLimits(BRect targetFrame);
59			void				SetOriginalSizeLimits(int32 minWidth,
60									int32 maxWidth, int32 minHeight,
61									int32 maxHeight);
62			void				GetSizeLimits(int32* minWidth, int32* maxWidth,
63									int32* minHeight, int32* maxHeight) const;
64			void				AddDecorator(int32* minWidth, int32* maxWidth,
65									int32* minHeight, int32* maxHeight);
66			void				AddDecorator(BRect& frame);
67
68			// hook called when window has been resized form the outside
69			void				Resized();
70			bool				IsHResizeable() const;
71			bool				IsVResizeable() const;
72
73			//! \return the complete window frame including the Decorator
74			BRect				CompleteWindowFrame();
75
76			//! \return true if window is in a group with a least another window
77			bool				PositionManagedBySAT();
78
79			bool				HighlightTab(bool active);
80			bool				HighlightBorders(Decorator::Region region,
81									bool active);
82			bool				IsTabHighlighted();
83			bool				IsBordersHighlighted();
84
85			uint64				Id();
86
87			bool				SetSettings(const BMessage& message);
88			void				GetSettings(BMessage& message);
89private:
90			uint64				_GenerateId();
91
92			void				_UpdateSizeLimits();
93			void				_RestoreOriginalSize(
94									bool stayBelowMouse = true);
95
96			Window*				fWindow;
97			StackAndTile*		fStackAndTile;
98			Desktop*			fDesktop;
99
100			//! Current group.
101			WindowArea*			fWindowArea;
102
103			SATSnappingBehaviour*	fOngoingSnapping;
104			SATStacking			fSATStacking;
105			SATTiling			fSATTiling;
106
107			SATSnappingBehaviourList	fSATSnappingBehaviourList;
108
109			int32				fOriginalMinWidth;
110			int32				fOriginalMaxWidth;
111			int32				fOriginalMinHeight;
112			int32				fOriginalMaxHeight;
113
114			float				fOriginalWidth;
115			float				fOriginalHeight;
116
117			uint64				fId;
118
119			float				fOldTabLocatiom;
120};
121
122
123#endif
124