My favorites | Sign in
Project Home Downloads Source
Checkout   Browse   Changes    
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
Image GetDriveImage(char drive_style);
Image GetFileIcon(const char *path, bool dir, bool force = false);

void DrawFileName(Draw& w, int x, int y, int wcx, int cy, const WString& mname, bool isdir, Font font,
Color ink, Color extink, const WString& desc = Null, Font descfont = Null,
bool justname = false, Color underline = Null);

Image NativePathIcon(const char *path, bool folder);
Image NativePathIcon(const char *path);

Image NativePathLargeIcon(const char *path, bool folder);
Image NativePathLargeIcon(const char *path);

class FileList : public ColumnList, private Display {
public:
virtual void LeftDown(Point p, dword);
virtual bool Key(dword key, int count);

virtual void Paint(Draw& w, const Rect& r, const Value& q,
Color ink, Color paper, dword style) const;
virtual Size GetStdSize(const Value& q) const;

public:
struct File {
bool isdir;
bool unixexe;
bool hidden;
Image icon;
String name;
Font font;
Color ink;
int64 length;
Time time;
Color extink;
String desc;
Font descfont;
Value data;
Color underline;

operator const String&() const { return name; }
};

class Order {
public:
virtual bool operator()(const File& a, const File& b) const = 0;
virtual ~Order() {}
};

private:
int iconwidth;
EditField edit;

bool renaming;
bool justname;
bool accelkey;

void UpdateSelect();
void Update();
bool FindChar(int from, int chr);
void KillEdit();

struct FileOrder;

protected:
enum {
TIMEID_STARTEDIT = ColumnList::TIMEID_COUNT,
TIMEID_COUNT
};

public:
Callback2<const String&, const String&> WhenRename;

void StartEdit();
void EndEdit();
bool IsEdit() const { return edit.IsVisible(); }
void OkEdit();

const File& Get(int i) const;
const File& operator[](int i) const { return Get(i); }
void Insert(int ii,
const String& name, const Image& icon = Null,
Font font = StdFont(), Color ink = SColorText(),
bool isdir = false, int64 length = 0, Time time = Null, Color extink = Null,
const String& desc = Null, Font descfont = Null, Value data = Null,
Color underline = Null, bool unixexe = false, bool hidden = false);
void Set(int ii,
const String& name, const Image& icon = Null,
Font font = StdFont(), Color ink = SColorText(),
bool isdir = false, int64 length = 0, Time time = Null, Color extink = Null,
const String& desc = Null, Font descfont = Null, Value data = Null,
Color underline = Null, bool unixexe = false, bool hidden = false);
void Set(int ii, const File& f);
void SetIcon(int ii, const Image& icon);
void Add(const String& name, const Image& icon = Null,
Font font = StdFont(), Color ink = SColorText(),
bool isdir = false, int64 length = 0, Time time = Null, Color extink = Null,
const String& desc = Null, Font descfont = Null, Value data = Null,
Color underline = Null, bool unixexe = false, bool hidden = false);
String GetCurrentName() const;

int Find(const char *name);
bool FindSetCursor(const char *name);

void Sort(const Order& order);

FileList& IconWidth(int w) { iconwidth = w; Refresh(); return *this; }
int GetIconWidth() const { return iconwidth; }
FileList& Renaming(bool b = true) { renaming = b; return *this; }
FileList& JustName(bool b = true) { justname = b; Refresh(); return *this; }
FileList& AccelKey(bool b = true) { accelkey = b; return *this; }

typedef FileList CLASSNAME;

FileList();
virtual ~FileList();
};

bool Load(FileList& list, const String& dir, const char *patterns, bool dirs = false,
Callback3<bool, const String&, Image&> WhenIcon = CNULL,
FileSystemInfo& filesystem = StdFileSystemInfo(), const String& search = String(),
bool hidden = true, bool hiddenfiles = true, bool lazyicons = false);
void SortByName(FileList& list);
void SortByExt(FileList& list);

class LazyFileIcons {
TimeCallback tm;
String dir;
FileList *list;
int pos;
bool quick;
int ptime;
int start;
Vector<int> ndx;
Callback3<bool, const String&, Image&> WhenIcon;

void Do();
void Restart(int delay) { tm.KillSet(delay, callback(this, &LazyFileIcons::Do)); }

public:
void ReOrder();
void Start(FileList& list_, const String& dir_, Callback3<bool, const String&, Image&> WhenIcon_);
};

String DirectoryUp(String& dir, bool basedir = false);

class FileSel : public WithFileSelectorLayout<TopWindow> {
public:
virtual bool Key(dword key, int count);

private:
SizeGrip sizegrip;

Button dirup, mkdir, plus, minus, toggle;

protected:
Vector<String> mask;
Vector<String> path;
Vector<String> lru;
int lastsby;
FileSystemInfo *filesystem;

String olddir;
String basedir;
String activetype;
String defext;
String preselect;
Vector<String> fn;

#ifdef PLATFORM_WIN32
Array<NetNode> netstack;
Array<NetNode> netnode;
#endif

DisplayCtrl preview_display;
Ctrl *preview;
FileList list;
ArrayCtrl places;
LazyFileIcons lazyicons;

enum {
OPEN, SAVEAS, SELECTDIR
};

int mode;
bool asking;
bool multi;
bool rdonly;
bool bidname;
bool appmodal;

void LoadNet();
void SelectNet();
bool PatternMatch(const char *fn);
bool OpenItem();
void OpenItem2() { OpenItem(); }
void Open();
void DirUp();
void MkDir();
void Plus();
void Minus();
void Toggle();
void PlusMinus(const char *title, bool sel);
void Update();
void FileUpdate();
void Rename(const String& on, const String& nn);
void Choice();
void SearchLoad();
void Load();
String FilePath(const String& fn);
void SetDir(const String& dir);
String GetDir();
void AddName(Vector<String>& fn, String& o);
void Finish();
bool Execute(int mode);
bool IsMulti() { return multi && mode == OPEN; }
void SyncSplitter();
void InitSplitter();
String GetMask();
void GoToPlace();
void AddPlaceRaw(const String& path, const Image& m, const String& name, const char* group = NULL, int row = -1);
void AddSystemPlaces(int row = -1);

using WithFileSelectorLayout<TopWindow>::Title;

typedef FileSel CLASSNAME;
public:

Callback3<bool, const String&, Image&> WhenIcon;

void Serialize(Stream& s);

bool ExecuteOpen(const char *title = NULL);
bool ExecuteSaveAs(const char *title = NULL);

bool ExecuteSelectDir(const char *title = NULL);

String Get() const { return GetFile(0); }
void Set(const String& s);
void Set(const Vector<String>& s) { fn <<= s; bidname = true; }

operator String() const { return Get(); }
void operator=(const String& s) { Set(s); }

String operator~() const { return Get(); }
void operator<<=(const String& s) { Set(s); }

int GetCount() const { return fn.GetCount(); }
String GetFile(int i) const;
String operator[](int i) const { return GetFile(i); }
void ClearFiles() { fn.Clear(); }

bool GetReadOnly() const { return readonly; }
String GetActiveDir() const { return dir.GetData(); }
int GetActiveType() const { return type.GetIndex(); }

void Filesystem(FileSystemInfo& fsys) { filesystem = &fsys;}
FileSystemInfo& GetFilesystem() const { return *filesystem; }

FileSel& Type(const char *name, const char *ext);
FileSel& Types(const char *d);
FileSel& AllFilesType();
FileSel& ClearTypes();
FileSel& ActiveDir(const String& d) { dir <<= d; return *this; }
FileSel& ActiveType(int i);
FileSel& PreSelect(const String& path);
FileSel& DefaultExt(const char *ext) { defext = ext; return *this; }
FileSel& Multi(bool b = true) { multi = b; return *this; }
FileSel& ReadOnlyOption(bool b = true) { rdonly = b; return *this; }
FileSel& MkDirOption(bool b = true) { mkdir.Show(b); return *this; }
FileSel& NoMkDirOption() { return MkDirOption(false); }
FileSel& BaseDir(const char *dir) { basedir = dir; return *this; }
FileSel& Asking(bool b = true) { asking = b; return *this; }
FileSel& NoAsking() { return Asking(false); }
FileSel& EditFileName(bool b) { file.SetEditable(b); return *this; }
FileSel& NoEditFileName() { return EditFileName(false); }
FileSel& AppModal(bool b = true) { appmodal = b; return *this; }
FileSel& NoAppModal() { return AppModal(false); }
FileSel& Preview(Ctrl& ctrl);
FileSel& Preview(const Display& d);
FileSel& ClearPlaces();
FileSel& AddPlace(const String& path, const Image& m, const String& name, const char* group = NULL, int row = -1);
FileSel& AddPlace(const String& path, const String& name, const char* group = NULL, int row = -1);
FileSel& AddPlace(const String& path, const char* group = NULL, int row = -1);
FileSel& AddPlaceSeparator();
FileSel& AddStandardPlaces();

FileSel();
virtual ~FileSel();
};

String SelectFileOpen(const char *types);
String SelectFileSaveAs(const char *types);
String SelectDirectory();
String SelectLoadFile(const char *types);
bool SelectSaveFile(const char *types, const String& data);

struct SelectFileIn : FileIn {
SelectFileIn(const char *types);
};

struct SelectFileOut : FileOut {
SelectFileOut(const char *types);
};

Change log

r4326 by unodgs on Dec 18, 2011   Diff
CtrlLib: Added refreshing system places in
file selector each time the dialog is
opened
Go to: 
Project members, sign in to write a code review

Older revisions

r3943 by cxl on Oct 2, 2011   Diff
ide: Ide now highlights errorenous
files and packages (rm #54)
r2915 by cxl on Dec 19, 2010   Diff
.CtrlLib: Tuning FileSel icons
r2890 by cxl on Dec 5, 2010   Diff
CtrlLib:FileSel icons optimizations...
All revisions of this file

File info

Size: 10270 bytes, 303 lines

File properties

svn:eol-style
native
Powered by Google Project Hosting