]>
Commit | Line | Data |
---|---|---|
7183fd72 VZ |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: wx/volume.h | |
3 | // Purpose: wxFSVolume - encapsulates system volume information | |
4 | // Author: George Policello | |
5 | // Modified by: | |
6 | // Created: 28 Jan 02 | |
7183fd72 | 7 | // Copyright: (c) 2002 George Policello |
65571936 | 8 | // Licence: wxWindows licence |
7183fd72 VZ |
9 | ///////////////////////////////////////////////////////////////////////////// |
10 | ||
11 | // ---------------------------------------------------------------------------- | |
34db8177 | 12 | // wxFSVolume represents a volume/drive in a file system |
7183fd72 VZ |
13 | // ---------------------------------------------------------------------------- |
14 | ||
15 | #ifndef _WX_FSVOLUME_H_ | |
16 | #define _WX_FSVOLUME_H_ | |
17 | ||
05815ab3 VZ |
18 | #include "wx/defs.h" |
19 | ||
20 | #if wxUSE_FSVOLUME | |
21 | ||
34deaa93 WS |
22 | #include "wx/arrstr.h" |
23 | ||
7183fd72 | 24 | // the volume flags |
34db8177 | 25 | enum wxFSVolumeFlags |
7183fd72 VZ |
26 | { |
27 | // is the volume mounted? | |
28 | wxFS_VOL_MOUNTED = 0x0001, | |
29 | ||
30 | // is the volume removable (floppy, CD, ...)? | |
31 | wxFS_VOL_REMOVABLE = 0x0002, | |
32 | ||
33 | // read only? (otherwise read write) | |
34 | wxFS_VOL_READONLY = 0x0004, | |
35 | ||
36 | // network resources | |
37 | wxFS_VOL_REMOTE = 0x0008 | |
38 | }; | |
39 | ||
40 | // the volume types | |
41 | enum wxFSVolumeKind | |
42 | { | |
43 | wxFS_VOL_FLOPPY, | |
44 | wxFS_VOL_DISK, | |
45 | wxFS_VOL_CDROM, | |
46 | wxFS_VOL_DVDROM, | |
47 | wxFS_VOL_NETWORK, | |
48 | wxFS_VOL_OTHER, | |
49 | wxFS_VOL_MAX | |
50 | }; | |
51 | ||
bddd7a8d | 52 | class WXDLLIMPEXP_BASE wxFSVolumeBase |
7183fd72 VZ |
53 | { |
54 | public: | |
55 | // return the array containing the names of the volumes | |
56 | // | |
57 | // only the volumes with the flags such that | |
58 | // (flags & flagsSet) == flagsSet && !(flags & flagsUnset) | |
59 | // are returned (by default, all mounted ones) | |
60 | static wxArrayString GetVolumes(int flagsSet = wxFS_VOL_MOUNTED, | |
61 | int flagsUnset = 0); | |
62 | ||
63 | // stop execution of GetVolumes() called previously (should be called from | |
64 | // another thread, of course) | |
65 | static void CancelSearch(); | |
66 | ||
67 | // create the volume object with this name (should be one of those returned | |
68 | // by GetVolumes()). | |
e2478fde VZ |
69 | wxFSVolumeBase(); |
70 | wxFSVolumeBase(const wxString& name); | |
7183fd72 VZ |
71 | bool Create(const wxString& name); |
72 | ||
73 | // accessors | |
74 | // --------- | |
75 | ||
76 | // is this a valid volume? | |
77 | bool IsOk() const; | |
78 | ||
79 | // kind of this volume? | |
80 | wxFSVolumeKind GetKind() const; | |
81 | ||
82 | // flags of this volume? | |
83 | int GetFlags() const; | |
84 | ||
85 | // can we write to this volume? | |
86 | bool IsWritable() const { return !(GetFlags() & wxFS_VOL_READONLY); } | |
87 | ||
88 | // get the name of the volume and the name which should be displayed to the | |
89 | // user | |
90 | wxString GetName() const { return m_volName; } | |
91 | wxString GetDisplayName() const { return m_dispName; } | |
92 | ||
7183fd72 VZ |
93 | // TODO: operatios (Mount(), Unmount(), Eject(), ...)? |
94 | ||
e2478fde VZ |
95 | protected: |
96 | // the internal volume name | |
7183fd72 | 97 | wxString m_volName; |
e2478fde VZ |
98 | |
99 | // the volume name as it is displayed to the user | |
7183fd72 | 100 | wxString m_dispName; |
e2478fde VZ |
101 | |
102 | // have we been initialized correctly? | |
103 | bool m_isOk; | |
104 | }; | |
105 | ||
7183fd72 | 106 | #if wxUSE_GUI |
e2478fde VZ |
107 | |
108 | #include "wx/icon.h" | |
109 | #include "wx/iconbndl.h" // only for wxIconArray | |
110 | ||
111 | enum wxFSIconType | |
112 | { | |
113 | wxFS_VOL_ICO_SMALL = 0, | |
114 | wxFS_VOL_ICO_LARGE, | |
115 | wxFS_VOL_ICO_SEL_SMALL, | |
116 | wxFS_VOL_ICO_SEL_LARGE, | |
117 | wxFS_VOL_ICO_MAX | |
118 | }; | |
119 | ||
120 | // wxFSVolume adds GetIcon() to wxFSVolumeBase | |
d241d258 | 121 | class WXDLLIMPEXP_CORE wxFSVolume : public wxFSVolumeBase |
e2478fde VZ |
122 | { |
123 | public: | |
124 | wxFSVolume() : wxFSVolumeBase() { InitIcons(); } | |
125 | wxFSVolume(const wxString& name) : wxFSVolumeBase(name) { InitIcons(); } | |
126 | ||
127 | wxIcon GetIcon(wxFSIconType type) const; | |
128 | ||
129 | private: | |
130 | void InitIcons(); | |
131 | ||
132 | // the different icons for this volume (created on demand) | |
7183fd72 | 133 | wxIconArray m_icons; |
e2478fde VZ |
134 | }; |
135 | ||
136 | #else // !wxUSE_GUI | |
7183fd72 | 137 | |
e2478fde | 138 | // wxFSVolume is the same thing as wxFSVolume in wxBase |
8d65a2e1 | 139 | typedef wxFSVolumeBase wxFSVolume; |
7183fd72 | 140 | |
e2478fde VZ |
141 | #endif // wxUSE_GUI/!wxUSE_GUI |
142 | ||
05815ab3 VZ |
143 | #endif // wxUSE_FSVOLUME |
144 | ||
7183fd72 | 145 | #endif // _WX_FSVOLUME_H_ |