1 /* 2 Open Tracker License 3 4 Terms and Conditions 5 6 Copyright (c) 1991-2000, Be Incorporated. All rights reserved. 7 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: 14 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. 17 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. 24 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. 28 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. 32 All rights reserved. 33 */ 34 35 // Classes used for setting up and managing background images 36 // 37 38 #ifndef __BACKGROUND_IMAGE__ 39 #define __BACKGROUND_IMAGE__ 40 41 #include "String.h" 42 #include "ObjectList.h" 43 44 #include <GraphicsDefs.h> 45 #include <Node.h> 46 #include <Path.h> 47 48 49 class BView; 50 class BBitmap; 51 52 class BackgroundImage; 53 class Image; 54 class BackgroundsView; 55 56 extern const char *kBackgroundImageInfo; 57 extern const char *kBackgroundImageInfoOffset; 58 extern const char *kBackgroundImageInfoEraseText; 59 extern const char *kBackgroundImageInfoMode; 60 extern const char *kBackgroundImageInfoWorkspaces; 61 extern const char *kBackgroundImageInfoPath; 62 extern const char *kBackgroundImageInfoSet; 63 extern const char *kBackgroundImageInfoSetPeriod; 64 65 const uint32 kRestoreBackgroundImage = 'Tbgr'; 66 const uint32 kChangeBackgroundImage = 'Cbgr'; 67 68 class BackgroundImage { 69 // This class knows everything about which bitmap to use for a given 70 // view and how. 71 // Unlike other windows, the Desktop window can have different backgrounds 72 // for each workspace 73 public: 74 75 enum Mode { 76 kAtOffset, 77 kCentered, // only works on Desktop 78 kScaledToFit, // only works on Desktop 79 kTiled 80 }; 81 82 class BackgroundImageInfo { 83 // element of the per-workspace list 84 public: 85 BackgroundImageInfo(uint32 workspace, int32 imageIndex, Mode mode, 86 BPoint offset, bool eraseTextWidget, uint32 imageSet, 87 uint32 cacheMode); 88 ~BackgroundImageInfo(); 89 90 void LoadBitmap(); 91 void UnloadBitmap(uint32 globalCacheMode); 92 93 uint32 fWorkspace; 94 int32 fImageIndex; 95 Mode fMode; 96 BPoint fOffset; 97 bool fEraseTextWidgetBackground; 98 uint32 fImageSet; 99 uint32 fCacheMode; // image cache strategy (0 cache , 1 no cache) 100 }; 101 102 static BackgroundImage *GetBackgroundImage(const BNode *node, 103 bool isDesktop, BackgroundsView* view); 104 // create a BackgroundImage object by reading it from a node 105 106 virtual ~BackgroundImage(); 107 108 void Show(BView *view, int32 workspace); 109 // display the right background for a given workspace 110 void Remove(); 111 // remove the background from it's current view 112 113 void WorkspaceActivated(BView *view, int32 workspace, bool state); 114 // respond to a workspace change 115 void ScreenChanged(BRect rect, color_space space); 116 // respond to a screen size change 117 /*static BackgroundImage *Refresh(BackgroundImage *oldBackgroundImage, 118 const BNode *fromNode, bool desktop, BPoseView *poseView); 119 // respond to a background image setting change 120 void ChangeImageSet(BPoseView *poseView); 121 // change to the next imageSet if any, no refresh*/ 122 BackgroundImageInfo *ImageInfoForWorkspace(int32) const; 123 124 // return fIsDesktop 125 bool IsDesktop() { return fIsDesktop;} 126 127 status_t SetBackgroundImage(BNode *node); 128 129 void Show(BackgroundImageInfo *, BView *view); 130 131 uint32 GetShowingImageSet() { return fShowingImageSet; } 132 133 void Add(BackgroundImageInfo *); 134 void Remove(BackgroundImageInfo *); 135 void RemoveAll(); 136 137 private: 138 BackgroundImage(const BNode *node, bool isDesktop, BackgroundsView* view); 139 // no public constructor, GetBackgroundImage factory function is 140 // used instead 141 142 bool fIsDesktop; 143 BNode fDefinedByNode; 144 BView *fView; 145 BackgroundsView* fBackgroundsView; 146 BackgroundImageInfo *fShowingBitmap; 147 148 BObjectList<BackgroundImageInfo> fBitmapForWorkspaceList; 149 150 uint32 fImageSetPeriod; // period between imagesets, 0 if none 151 uint32 fShowingImageSet; // current imageset 152 uint32 fImageSetCount; // imageset count 153 uint32 fCacheMode;// image cache strategy (0 all, 1 none, 2 own strategy) 154 bool fRandomChange; // random or sequential change 155 }; 156 157 class Image { 158 // element for each image 159 public: 160 Image(BPath path); 161 ~Image(); 162 163 void UnloadBitmap(); 164 const char* GetName() {return name.String();} 165 BBitmap* GetBitmap(); 166 BPath GetPath() {return fPath;} 167 private: 168 BBitmap *fBitmap; 169 BPath fPath; 170 BString name; 171 }; 172 173 #endif 174