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