The rounded corners look really dumb at this size.
[wxWidgets.git] / include / wx / volume.h
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 // Copyright: (c) 2002 George Policello
8 // Licence: wxWindows licence
9 /////////////////////////////////////////////////////////////////////////////
10
11 // ----------------------------------------------------------------------------
12 // wxFSVolume represents a volume/drive in a file system
13 // ----------------------------------------------------------------------------
14
15 #ifndef _WX_FSVOLUME_H_
16 #define _WX_FSVOLUME_H_
17
18 #include "wx/defs.h"
19
20 #if wxUSE_FSVOLUME
21
22 #include "wx/arrstr.h"
23
24 // the volume flags
25 enum wxFSVolumeFlags
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
52 class WXDLLIMPEXP_BASE wxFSVolumeBase
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()).
69 wxFSVolumeBase();
70 wxFSVolumeBase(const wxString& name);
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
93 // TODO: operatios (Mount(), Unmount(), Eject(), ...)?
94
95 protected:
96 // the internal volume name
97 wxString m_volName;
98
99 // the volume name as it is displayed to the user
100 wxString m_dispName;
101
102 // have we been initialized correctly?
103 bool m_isOk;
104 };
105
106 #if wxUSE_GUI
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
121 class WXDLLIMPEXP_CORE wxFSVolume : public wxFSVolumeBase
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)
133 wxIconArray m_icons;
134 };
135
136 #else // !wxUSE_GUI
137
138 // wxFSVolume is the same thing as wxFSVolume in wxBase
139 typedef wxFSVolumeBase wxFSVolume;
140
141 #endif // wxUSE_GUI/!wxUSE_GUI
142
143 #endif // wxUSE_FSVOLUME
144
145 #endif // _WX_FSVOLUME_H_