1/*
2Open Tracker License
3
4Terms and Conditions
5
6Copyright (c) 1991-2000, Be Incorporated. All rights reserved.
7
8Permission is hereby granted, free of charge, to any person obtaining a copy of
9this software and associated documentation files (the "Software"), to deal in
10the Software without restriction, including without limitation the rights to
11use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
12of the Software, and to permit persons to whom the Software is furnished to do
13so, subject to the following conditions:
14
15The above copyright notice and this permission notice applies to all licensees
16and shall be included in all copies or substantial portions of the Software.
17
18THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF TITLE, MERCHANTABILITY,
20FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
21BE INCORPORATED BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
22AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF, OR IN CONNECTION
23WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24
25Except as contained in this notice, the name of Be Incorporated shall not be
26used in advertising or otherwise to promote the sale, use or other dealings in
27this Software without prior written authorization from Be Incorporated.
28
29Tracker(TM), Be(R), BeOS(R), and BeIA(TM) are trademarks or registered trademarks
30of Be Incorporated in the United States and other countries. Other brand product
31names are registered trademarks or trademarks of their respective holders.
32All rights reserved.
33*/
34
35//  Classes used for setting up and managing background images
36
37
38#ifndef _BACKGROUND_IMAGE_H
39#define _BACKGROUND_IMAGE_H
40
41
42#include <ObjectList.h>
43#include <String.h>
44
45
46class BNode;
47class BView;
48class BBitmap;
49
50namespace BPrivate {
51
52class BackgroundImage;
53class BPoseView;
54
55extern const char* kBackgroundImageInfo;
56extern const char* kBackgroundImageInfoOffset;
57extern const char* kBackgroundImageInfoTextOutline;
58extern const char* kBackgroundImageInfoMode;
59extern const char* kBackgroundImageInfoWorkspaces;
60extern const char* kBackgroundImageInfoPath;
61
62const uint32 kRestoreBackgroundImage = 'Tbgr';
63
64class BackgroundImage {
65	// This class knows everything about which bitmap to use for a given
66	// view and how.
67	// Unlike other windows, the Desktop window can have different backgrounds
68	// for each workspace
69public:
70
71	enum Mode {
72		kAtOffset,
73		kCentered,			// only works on Desktop
74		kScaledToFit,		// only works on Desktop
75		kTiled
76	};
77
78	class BackgroundImageInfo {
79		// element of the per-workspace list
80	public:
81		BackgroundImageInfo(uint32 workspace, BBitmap* bitmap, Mode mode,
82			BPoint offset, bool textWidgetOutline);
83		~BackgroundImageInfo();
84
85		uint32 fWorkspace;
86		BBitmap* fBitmap;
87		Mode fMode;
88		BPoint fOffset;
89		bool fTextWidgetOutline;
90	};
91
92	static BackgroundImage* GetBackgroundImage(const BNode* node,
93		bool isDesktop);
94		// create a BackgroundImage object by reading it from a node
95	virtual ~BackgroundImage();
96
97	void Show(BView* view, int32 workspace);
98		// display the right background for a given workspace
99	void Remove();
100		// remove the background from it's current view
101
102	void WorkspaceActivated(BView* view, int32 workspace, bool state);
103		// respond to a workspace change
104	void ScreenChanged(BRect rect, color_space space);
105		// respond to a screen size change
106	static BackgroundImage* Refresh(BackgroundImage* oldBackgroundImage,
107		const BNode* fromNode, bool desktop, BPoseView* poseView);
108		// respond to a background image setting change
109
110private:
111	BackgroundImageInfo* ImageInfoForWorkspace(int32) const;
112	void Show(BackgroundImageInfo*, BView* view);
113
114	BackgroundImage(const BNode*, bool);
115		// no public constructor, GetBackgroundImage factory function is
116		// used instead
117
118	void Add(BackgroundImageInfo*);
119
120	float BRectRatio(BRect rect);
121	float BRectHorizontalOverlap(BRect hostRect, BRect resizedRect);
122	float BRectVerticalOverlap(BRect hostRect, BRect resizedRect);
123
124	bool fIsDesktop;
125	BNode fDefinedByNode;
126	BView* fView;
127	BackgroundImageInfo* fShowingBitmap;
128
129	BObjectList<BackgroundImageInfo> fBitmapForWorkspaceList;
130};
131
132} // namespace BPrivate
133
134using namespace BPrivate;
135
136
137#endif	// _BACKGROUND_IMAGE_H
138