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