1 /* 2 * Copyright 2002-2009 Haiku, Inc. All rights reserved. 3 * Distributed under the terms of the MIT License. 4 * 5 * Authors: 6 * Jerome Duval, jerome.duval@free.fr 7 */ 8 #ifndef BACKGROUNDS_VIEW_H 9 #define BACKGROUNDS_VIEW_H 10 11 12 #include <Box.h> 13 #include <Button.h> 14 #include <CheckBox.h> 15 #include <ColorControl.h> 16 #include <Control.h> 17 #include <Cursor.h> 18 #include <Entry.h> 19 #include <FilePanel.h> 20 #include <Menu.h> 21 #include <MenuItem.h> 22 #include <Message.h> 23 #include <Picture.h> 24 #include <Screen.h> 25 #include <ScrollView.h> 26 #include <ScrollBar.h> 27 #include <String.h> 28 #include <StringView.h> 29 #include <TextControl.h> 30 #include <View.h> 31 32 #include "BackgroundImage.h" 33 34 35 #define SETTINGS_FILE "Backgrounds_settings" 36 37 38 class ImageFilePanel; 39 40 41 class BGImageMenuItem : public BMenuItem { 42 public: 43 BGImageMenuItem(const char* label, int32 imageIndex, 44 BMessage* message, char shortcut = 0, 45 uint32 modifiers = 0); 46 47 int32 ImageIndex() { return fImageIndex; } 48 49 private: 50 int32 fImageIndex; 51 }; 52 53 54 enum frame_parts { 55 FRAME_TOP_LEFT = 0, 56 FRAME_TOP, 57 FRAME_TOP_RIGHT, 58 FRAME_LEFT_SIDE, 59 FRAME_RIGHT_SIDE, 60 FRAME_BOTTOM_LEFT, 61 FRAME_BOTTOM, 62 FRAME_BOTTOM_RIGHT, 63 }; 64 65 66 class FramePart : public BView { 67 public: 68 FramePart(int32 part); 69 70 void Draw(BRect rect); 71 void SetDesktop(bool isDesktop); 72 73 private: 74 void _SetSizeAndAlignment(); 75 76 int32 fFramePart; 77 bool fIsDesktop; 78 }; 79 80 81 class Preview : public BControl { 82 public: 83 Preview(); 84 85 BPoint fPoint; 86 BRect fImageBounds; 87 88 protected: 89 void MouseDown(BPoint point); 90 void MouseUp(BPoint point); 91 void MouseMoved(BPoint point, uint32 transit, 92 const BMessage* message); 93 void AttachedToWindow(); 94 95 BPoint fOldPoint; 96 float fXRatio; 97 float fYRatio; 98 display_mode fMode; 99 }; 100 101 102 class BackgroundsView : public BBox { 103 public: 104 BackgroundsView(); 105 ~BackgroundsView(); 106 107 void AllAttached(); 108 void MessageReceived(BMessage* message); 109 110 void RefsReceived(BMessage* message); 111 112 void SaveSettings(); 113 void WorkspaceActivated(uint32 oldWorkspaces, 114 bool active); 115 int32 AddImage(BPath path); 116 Image* GetImage(int32 imageIndex); 117 118 bool FoundPositionSetting(); 119 120 protected: 121 void _Save(); 122 void _NotifyServer(); 123 void _NotifyScreenPreflet(); 124 void _LoadSettings(); 125 void _LoadDesktopFolder(); 126 void _LoadDefaultFolder(); 127 void _LoadFolder(bool isDesktop); 128 void _LoadRecentFolder(BPath path); 129 void _UpdateWithCurrent(); 130 void _UpdatePreview(); 131 void _UpdateButtons(); 132 void _SetDesktop(bool isDesktop); 133 int32 _AddPath(BPath path); 134 135 static int32 _NotifyThread(void* data); 136 137 BGImageMenuItem* _FindImageItem(const int32 imageIndex); 138 139 bool _AddItem(BGImageMenuItem* item); 140 141 BackgroundImage::Mode _FindPlacementMode(); 142 143 BColorControl* fPicker; 144 BButton* fApply; 145 BButton* fRevert; 146 BCheckBox* fIconLabelOutline; 147 BMenu* fPlacementMenu; 148 BMenu* fImageMenu; 149 BMenu* fWorkspaceMenu; 150 BTextControl* fXPlacementText; 151 BTextControl* fYPlacementText; 152 Preview* fPreview; 153 BFilePanel* fFolderPanel; 154 ImageFilePanel* fPanel; 155 156 BackgroundImage* fCurrent; 157 158 BackgroundImage::BackgroundImageInfo* fCurrentInfo; 159 160 entry_ref fCurrentRef; 161 int32 fLastImageIndex; 162 int32 fLastWorkspaceIndex; 163 BMessage fSettings; 164 165 BObjectList<BPath> fPathList; 166 BObjectList<Image> fImageList; 167 168 FramePart* fTopLeft; 169 FramePart* fTop; 170 FramePart* fTopRight; 171 FramePart* fLeft; 172 FramePart* fRight; 173 FramePart* fBottomLeft; 174 FramePart* fBottom; 175 FramePart* fBottomRight; 176 177 bool fFoundPositionSetting; 178 }; 179 180 #endif // BACKGROUNDS_VIEW_H 181