6 Copyright (c) 1991-2000, Be Incorporated. All rights reserved.
8 Permission is hereby granted, free of charge, to any person obtaining a copy of
9 this software and associated documentation files (the "Software"), to deal in
10 the Software without restriction, including without limitation the rights to
11 use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
12 of the Software, and to permit persons to whom the Software is furnished to do
13 so, subject to the following conditions:
15 The above copyright notice and this permission notice applies to all licensees
16 and shall be included in all copies or substantial portions of the Software.
18 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF TITLE, MERCHANTABILITY,
20 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
21 BE INCORPORATED BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
22 AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF, OR IN CONNECTION
23 WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25 Except as contained in this notice, the name of Be Incorporated shall not be
26 used in advertising or otherwise to promote the sale, use or other dealings in
27 this Software without prior written authorization from Be Incorporated.
29 Tracker(TM), Be(R), BeOS(R), and BeIA(TM) are trademarks or registered trademarks
30 of Be Incorporated in the United States and other countries. Other brand product
31 names are registered trademarks or trademarks of their respective holders.
35 // Classes used for setting up and managing background images
38 #ifndef __BACKGROUND_IMAGE__
39 #define __BACKGROUND_IMAGE__
42 #include <GraphicsDefs.h>
46 #include "ObjectList.h"
53 class BackgroundImage
;
55 class BackgroundsView
;
57 extern const char* kBackgroundImageInfo
;
58 extern const char* kBackgroundImageInfoOffset
;
59 extern const char* kBackgroundImageInfoEraseText
;
60 extern const char* kBackgroundImageInfoMode
;
61 extern const char* kBackgroundImageInfoWorkspaces
;
62 extern const char* kBackgroundImageInfoPath
;
63 extern const char* kBackgroundImageInfoSet
;
64 extern const char* kBackgroundImageInfoSetPeriod
;
66 const uint32 kRestoreBackgroundImage
= 'Tbgr';
67 const uint32 kChangeBackgroundImage
= 'Cbgr';
69 class BackgroundImage
{
70 // This class knows everything about which bitmap to use for a given
72 // Unlike other windows, the Desktop window can have different backgrounds
78 kCentered
, // only works on Desktop
79 kScaledToFit
, // only works on Desktop
83 class BackgroundImageInfo
{
84 // element of the per-workspace list
86 BackgroundImageInfo(uint32 workspace
, int32 imageIndex
, Mode mode
,
87 BPoint offset
, bool textWidgetLabelOutline
, uint32 imageSet
,
89 ~BackgroundImageInfo();
92 void UnloadBitmap(uint32 globalCacheMode
);
98 bool fTextWidgetLabelOutline
;
100 uint32 fCacheMode
; // image cache strategy (0 cache , 1 no cache)
103 static BackgroundImage
* GetBackgroundImage(const BNode
* node
,
104 bool isDesktop
, BackgroundsView
* view
);
105 // create a BackgroundImage object by reading it from a node
107 virtual ~BackgroundImage();
109 void Show(BView
* view
, int32 workspace
);
110 // display the right background for a given workspace
112 // remove the background from it's current view
114 void WorkspaceActivated(BView
* view
, int32 workspace
, bool state
);
115 // respond to a workspace change
116 void ScreenChanged(BRect rect
, color_space space
);
117 // respond to a screen size change
118 /*static BackgroundImage* Refresh(BackgroundImage* oldBackgroundImage,
119 const BNode* fromNode, bool desktop, BPoseView* poseView);
120 // respond to a background image setting change
121 void ChangeImageSet(BPoseView* poseView);
122 // change to the next imageSet if any, no refresh*/
123 BackgroundImageInfo
* ImageInfoForWorkspace(int32
) const;
125 bool IsDesktop() { return fIsDesktop
;}
127 status_t
SetBackgroundImage(BNode
* node
);
129 void Show(BackgroundImageInfo
*, BView
* view
);
131 uint32
GetShowingImageSet() { return fShowingImageSet
; }
133 void Add(BackgroundImageInfo
*);
134 void Remove(BackgroundImageInfo
*);
138 BackgroundImage(const BNode
* node
, bool isDesktop
, BackgroundsView
* view
);
139 // no public constructor, GetBackgroundImage factory function is
142 float BRectRatio(BRect rect
);
143 float BRectHorizontalOverlap(BRect hostRect
, BRect resizedRect
);
144 float BRectVerticalOverlap(BRect hostRect
, BRect resizedRect
);
147 BNode fDefinedByNode
;
149 BackgroundsView
* fBackgroundsView
;
150 BackgroundImageInfo
* fShowingBitmap
;
152 BObjectList
<BackgroundImageInfo
> fBitmapForWorkspaceList
;
154 uint32 fImageSetPeriod
; // period between imagesets, 0 if none
155 uint32 fShowingImageSet
; // current imageset
156 uint32 fImageSetCount
; // imageset count
157 uint32 fCacheMode
;// image cache strategy (0 all, 1 none, 2 own strategy)
158 bool fRandomChange
; // random or sequential change
162 // element for each image
168 const char* GetName() { return fName
.String(); }
169 BBitmap
* GetBitmap();
170 BPath
GetPath() { return fPath
; }