1 /* 2 * Copyright 2002-2007, 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 "BackgroundImage.h" 13 14 #include <View.h> 15 #include <ColorControl.h> 16 #include <Message.h> 17 #include <Button.h> 18 #include <ScrollView.h> 19 #include <ScrollBar.h> 20 #include <String.h> 21 #include <Box.h> 22 #include <CheckBox.h> 23 #include <TextControl.h> 24 #include <Menu.h> 25 #include <MenuItem.h> 26 #include <Entry.h> 27 #include <Screen.h> 28 #include <Control.h> 29 #include <Picture.h> 30 #include <FilePanel.h> 31 #include <StringView.h> 32 #include <Cursor.h> 33 34 #define SETTINGS_FILE "Backgrounds_settings" 35 36 class ImageFilePanel; 37 38 class BGImageMenuItem : public BMenuItem { 39 public: 40 BGImageMenuItem(const char *label, int32 imageIndex, BMessage *message, 41 char shortcut = 0, uint32 modifiers = 0); 42 43 int32 ImageIndex() { return fImageIndex; } 44 45 private: 46 int32 fImageIndex; 47 }; 48 49 50 class PreviewBox : public BBox { 51 public: 52 PreviewBox(BRect frame, const char *name); 53 54 void Draw(BRect rect); 55 void SetDesktop(bool isDesktop); 56 57 protected: 58 bool fIsDesktop; 59 }; 60 61 62 class PreView : public BControl { 63 public: 64 PreView(BRect frame, const char *name, int32 resize, int32 flags); 65 66 BPoint fPoint; 67 BRect fImageBounds; 68 69 protected: 70 void MouseDown(BPoint point); 71 void MouseUp(BPoint point); 72 void MouseMoved(BPoint point, uint32 transit, const BMessage *message); 73 void AttachedToWindow(); 74 75 BPoint fOldPoint; 76 float x_ratio, y_ratio; 77 display_mode mode; 78 79 BCursor fMoveHandCursor; 80 }; 81 82 83 class BackgroundsView : public BBox { 84 public: 85 BackgroundsView(BRect frame, const char *name, int32 resize, int32 flags); 86 ~BackgroundsView(void); 87 88 void SaveSettings(); 89 void WorkspaceActivated(uint32 oldWorkspaces, bool active); 90 int32 AddImage(BPath path); 91 Image* GetImage(int32 imageIndex); 92 void ProcessRefs(entry_ref dir_ref, BMessage* msg); 93 94 void GetPreferredSize(float* _width, float* _height); 95 96 protected: 97 void Save(); 98 void NotifyServer(); 99 void LoadSettings(); 100 void AllAttached(); 101 void MessageReceived(BMessage *msg); 102 void LoadDesktopFolder(); 103 void LoadDefaultFolder(); 104 void LoadFolder(bool isDesktop); 105 void LoadRecentFolder(BPath path); 106 void UpdateWithCurrent(); 107 void UpdatePreview(); 108 void UpdateButtons(); 109 void RefsReceived(BMessage *msg); 110 int32 AddPath(BPath path); 111 112 static int32 NotifyThread(void *data); 113 114 BGImageMenuItem *FindImageItem(const int32 imageIndex); 115 bool AddItem(BGImageMenuItem *item); 116 117 BackgroundImage::Mode FindPlacementMode(); 118 119 BColorControl *fPicker; // color picker 120 BButton *fApply, *fRevert; // apply and revert buttons 121 BCheckBox *fIconLabelOutline; // label ckeckbox 122 BMenu* fPlacementMenu, *fImageMenu, *fWorkspaceMenu; // the three comboboxes 123 BTextControl *fXPlacementText, *fYPlacementText; // x and y textboxes 124 PreView *fPreView; // the view for previewing the result 125 PreviewBox *fPreview; // the box which draws a computer/folder 126 BFilePanel *fFolderPanel; // the file panels for folders 127 ImageFilePanel *fPanel; // the file panels for images 128 129 BackgroundImage *fCurrent; // the current BackgroundImage object 130 BackgroundImage::BackgroundImageInfo *fCurrentInfo;//the current BackgroundImageInfo object 131 entry_ref fCurrentRef; // the entry for the node which holds current 132 int32 fLastImageIndex, fLastWorkspaceIndex; // last indexes for cancel 133 BMessage fSettings; // settings loaded from settings directory 134 135 BObjectList<BPath> fPathList; 136 BObjectList<Image> fImageList; 137 }; 138 139 #endif // BACKGROUNDS_VIEW_H 140