fat: Greatly simplify and clean up dosfs_get_file_map().
[haiku.git] / src / preferences / backgrounds / BackgroundsView.h
blobeece562986fc3f53f93e07a82f8c6f824be1076d
1 /*
2 * Copyright 2002-2009 Haiku, Inc. All rights reserved.
3 * Distributed under the terms of the MIT License.
5 * Authors:
6 * Jerome Duval, jerome.duval@free.fr
7 */
8 #ifndef BACKGROUNDS_VIEW_H
9 #define BACKGROUNDS_VIEW_H
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>
32 #include "BackgroundImage.h"
35 #define SETTINGS_FILE "Backgrounds_settings"
38 class ImageFilePanel;
41 class BGImageMenuItem : public BMenuItem {
42 public:
43 BGImageMenuItem(const char* label, int32 imageIndex,
44 BMessage* message, char shortcut = 0,
45 uint32 modifiers = 0);
47 int32 ImageIndex() { return fImageIndex; }
49 private:
50 int32 fImageIndex;
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,
66 class FramePart : public BView {
67 public:
68 FramePart(int32 part);
70 void Draw(BRect rect);
71 void SetDesktop(bool isDesktop);
73 private:
74 void _SetSizeAndAlignment();
76 int32 fFramePart;
77 bool fIsDesktop;
81 class Preview : public BControl {
82 public:
83 Preview();
85 BPoint fPoint;
86 BRect fImageBounds;
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();
95 BPoint fOldPoint;
96 float fXRatio;
97 float fYRatio;
98 display_mode fMode;
102 class BackgroundsView : public BBox {
103 public:
104 BackgroundsView();
105 ~BackgroundsView();
107 void AllAttached();
108 void MessageReceived(BMessage* message);
110 void RefsReceived(BMessage* message);
112 void SaveSettings();
113 void WorkspaceActivated(uint32 oldWorkspaces,
114 bool active);
115 int32 AddImage(BPath path);
116 Image* GetImage(int32 imageIndex);
118 bool FoundPositionSetting();
120 protected:
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);
134 static int32 _NotifyThread(void* data);
136 BGImageMenuItem* _FindImageItem(const int32 imageIndex);
138 bool _AddItem(BGImageMenuItem* item);
140 BackgroundImage::Mode _FindPlacementMode();
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 BFilePanel* fFolderPanel;
153 ImageFilePanel* fPanel;
155 BackgroundImage* fCurrent;
157 BackgroundImage::BackgroundImageInfo* fCurrentInfo;
159 entry_ref fCurrentRef;
160 int32 fLastImageIndex;
161 int32 fLastWorkspaceIndex;
162 BMessage fSettings;
164 BObjectList<BPath> fPathList;
165 BObjectList<Image> fImageList;
167 FramePart* fTopLeft;
168 FramePart* fTop;
169 FramePart* fTopRight;
170 FramePart* fLeft;
171 FramePart* fRight;
172 FramePart* fBottomLeft;
173 FramePart* fBottom;
174 FramePart* fBottomRight;
176 bool fFoundPositionSetting;
179 #endif // BACKGROUNDS_VIEW_H