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