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 38class ImageFilePanel; 39 40 41class BGImageMenuItem : public BMenuItem { 42public: 43 BGImageMenuItem(const char* label, int32 imageIndex, 44 BMessage* message, char shortcut = 0, 45 uint32 modifiers = 0); 46 47 int32 ImageIndex() { return fImageIndex; } 48 49private: 50 int32 fImageIndex; 51}; 52 53 54enum 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 66class FramePart : public BView { 67public: 68 FramePart(int32 part); 69 70 void Draw(BRect rect); 71 void SetDesktop(bool isDesktop); 72 73private: 74 void _SetSizeAndAlignment(); 75 76 int32 fFramePart; 77 bool fIsDesktop; 78}; 79 80 81class Preview : public BControl { 82public: 83 Preview(); 84 85 BPoint fPoint; 86 BRect fImageBounds; 87 88protected: 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 102class BackgroundsView : public BBox { 103public: 104 BackgroundsView(); 105 ~BackgroundsView(); 106 107 void AllAttached(); 108 void MessageReceived(BMessage* msg); 109 110 void RefsReceived(BMessage* msg); 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 120protected: 121 void _Save(); 122 void _NotifyServer(); 123 void _LoadSettings(); 124 void _LoadDesktopFolder(); 125 void _LoadDefaultFolder(); 126 void _LoadFolder(bool isDesktop); 127 void _LoadRecentFolder(BPath path); 128 void _UpdateWithCurrent(); 129 void _UpdatePreview(); 130 void _UpdateButtons(); 131 void _SetDesktop(bool isDesktop); 132 int32 _AddPath(BPath path); 133 134 static int32 _NotifyThread(void* data); 135 136 BGImageMenuItem* _FindImageItem(const int32 imageIndex); 137 138 bool _AddItem(BGImageMenuItem* item); 139 140 BackgroundImage::Mode _FindPlacementMode(); 141 142 BColorControl* fPicker; 143 BButton* fApply; 144 BButton* fRevert; 145 BCheckBox* fIconLabelOutline; 146 BMenu* fPlacementMenu; 147 BMenu* fImageMenu; 148 BMenu* fWorkspaceMenu; 149 BTextControl* fXPlacementText; 150 BTextControl* fYPlacementText; 151 Preview* fPreview; 152 BBox* fPreviewBox; 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 182