mirror of https://github.com/buggins/dlangui.git
fix broken 64bit build
This commit is contained in:
parent
5e30aee4fc
commit
47c56cf718
|
@ -21,19 +21,19 @@ Copyright: Vadim Lopatin, 2014
|
|||
License: Boost License 1.0
|
||||
Authors: Vadim Lopatin, coolreader.org@gmail.com
|
||||
*/
|
||||
module dlangui.dialogs.filedlg;
|
||||
|
||||
import dlangui.core.events;
|
||||
import dlangui.core.i18n;
|
||||
module dlangui.dialogs.filedlg;
|
||||
|
||||
import dlangui.core.events;
|
||||
import dlangui.core.i18n;
|
||||
import dlangui.core.stdaction;
|
||||
import dlangui.core.files;
|
||||
import dlangui.widgets.controls;
|
||||
import dlangui.widgets.lists;
|
||||
import dlangui.widgets.popup;
|
||||
import dlangui.core.files;
|
||||
import dlangui.widgets.controls;
|
||||
import dlangui.widgets.lists;
|
||||
import dlangui.widgets.popup;
|
||||
import dlangui.widgets.layouts;
|
||||
import dlangui.widgets.grid;
|
||||
import dlangui.widgets.editors;
|
||||
import dlangui.platforms.common.platform;
|
||||
import dlangui.platforms.common.platform;
|
||||
import dlangui.dialogs.dialog;
|
||||
|
||||
private import std.file;
|
||||
|
@ -41,69 +41,69 @@ private import std.path;
|
|||
private import std.utf;
|
||||
private import std.conv : to;
|
||||
|
||||
|
||||
/// flags for file dialog options
|
||||
enum FileDialogFlag : uint {
|
||||
/// file must exist (use this for open dialog)
|
||||
FileMustExist = 0x100,
|
||||
/// ask before saving to existing
|
||||
ConfirmOverwrite = 0x200,
|
||||
/// flags for Open dialog
|
||||
Open = FileMustExist,
|
||||
/// flags for Save dialog
|
||||
Save = ConfirmOverwrite,
|
||||
}
|
||||
|
||||
/// File open / save dialog
|
||||
|
||||
/// flags for file dialog options
|
||||
enum FileDialogFlag : uint {
|
||||
/// file must exist (use this for open dialog)
|
||||
FileMustExist = 0x100,
|
||||
/// ask before saving to existing
|
||||
ConfirmOverwrite = 0x200,
|
||||
/// flags for Open dialog
|
||||
Open = FileMustExist,
|
||||
/// flags for Save dialog
|
||||
Save = ConfirmOverwrite,
|
||||
}
|
||||
|
||||
/// File open / save dialog
|
||||
class FileDialog : Dialog, CustomGridCellAdapter {
|
||||
protected EditLine path;
|
||||
protected EditLine filename;
|
||||
protected StringGridWidget list;
|
||||
//protected StringGridWidget places;
|
||||
protected VerticalLayout leftPanel;
|
||||
protected VerticalLayout leftPanel;
|
||||
protected VerticalLayout rightPanel;
|
||||
|
||||
protected RootEntry[] _roots;
|
||||
protected string _path;
|
||||
protected string _filename;
|
||||
protected DirEntry[] _entries;
|
||||
protected bool _isRoot;
|
||||
protected DirEntry[] _entries;
|
||||
protected bool _isRoot;
|
||||
|
||||
this(UIString caption, Window parent, uint fileDialogFlags = DialogFlag.Modal | DialogFlag.Resizable | FileDialogFlag.FileMustExist) {
|
||||
super(caption, parent, fileDialogFlags);
|
||||
}
|
||||
|
||||
protected bool openDirectory(string dir) {
|
||||
dir = buildNormalizedPath(dir);
|
||||
Log.d("FileDialog.openDirectory(", dir, ")");
|
||||
list.rows = 0;
|
||||
string[] filters;
|
||||
if (!listDirectory(dir, true, true, filters, _entries))
|
||||
return false;
|
||||
_path = dir;
|
||||
_isRoot = isRoot(dir);
|
||||
path.text = toUTF32(_path);
|
||||
list.rows = cast(int)_entries.length;
|
||||
for (int i = 0; i < _entries.length; i++) {
|
||||
string fname = baseName(_entries[i].name);
|
||||
string sz;
|
||||
string date;
|
||||
bool d = _entries[i].isDir;
|
||||
list.setCellText(1, i, toUTF32(fname));
|
||||
if (d) {
|
||||
list.setCellText(0, i, "folder");
|
||||
} else {
|
||||
list.setCellText(0, i, "text-plain"d);
|
||||
sz = to!string(_entries[i].size);
|
||||
date = "2014-01-01 00:00:00";
|
||||
}
|
||||
list.setCellText(2, i, toUTF32(sz));
|
||||
list.setCellText(3, i, toUTF32(date));
|
||||
}
|
||||
list.autoFitColumnWidths();
|
||||
return true;
|
||||
}
|
||||
|
||||
this(UIString caption, Window parent, uint fileDialogFlags = DialogFlag.Modal | DialogFlag.Resizable | FileDialogFlag.FileMustExist) {
|
||||
super(caption, parent, fileDialogFlags);
|
||||
}
|
||||
|
||||
protected bool openDirectory(string dir) {
|
||||
dir = buildNormalizedPath(dir);
|
||||
Log.d("FileDialog.openDirectory(", dir, ")");
|
||||
list.rows = 0;
|
||||
string[] filters;
|
||||
if (!listDirectory(dir, true, true, filters, _entries))
|
||||
return false;
|
||||
_path = dir;
|
||||
_isRoot = isRoot(dir);
|
||||
path.text = toUTF32(_path);
|
||||
list.rows = _entries.length;
|
||||
for (int i = 0; i < _entries.length; i++) {
|
||||
string fname = baseName(_entries[i].name);
|
||||
string sz;
|
||||
string date;
|
||||
bool d = _entries[i].isDir;
|
||||
list.setCellText(1, i, toUTF32(fname));
|
||||
if (d) {
|
||||
list.setCellText(0, i, "folder");
|
||||
} else {
|
||||
list.setCellText(0, i, "text-plain"d);
|
||||
sz = to!string(_entries[i].size);
|
||||
date = "2014-01-01 00:00:00";
|
||||
}
|
||||
list.setCellText(2, i, toUTF32(sz));
|
||||
list.setCellText(3, i, toUTF32(date));
|
||||
}
|
||||
list.autoFitColumnWidths();
|
||||
return true;
|
||||
}
|
||||
|
||||
/// return true for custom drawn cell
|
||||
override bool isCustomCell(int col, int row) {
|
||||
if (col == 0 && row >= 0)
|
||||
|
@ -139,39 +139,39 @@ class FileDialog : Dialog, CustomGridCellAdapter {
|
|||
img.drawTo(buf, rc, st);
|
||||
}
|
||||
}
|
||||
|
||||
protected Widget createRootsList() {
|
||||
ListWidget list = new ListWidget("ROOTS_LIST");
|
||||
WidgetListAdapter adapter = new WidgetListAdapter();
|
||||
foreach(ref RootEntry root; _roots) {
|
||||
ImageTextButton btn = new ImageTextButton(null, root.icon, root.label);
|
||||
btn.orientation = Orientation.Vertical;
|
||||
btn.styleId = "TRANSPARENT_BUTTON_BACKGROUND";
|
||||
btn.focusable = false;
|
||||
adapter.widgets.add(btn);
|
||||
}
|
||||
list.ownAdapter = adapter;
|
||||
list.layoutWidth = WRAP_CONTENT;
|
||||
list.layoutHeight = FILL_PARENT;
|
||||
list.onItemClickListener = delegate(Widget source, int itemIndex) {
|
||||
openDirectory(_roots[itemIndex].path);
|
||||
return true;
|
||||
};
|
||||
return list;
|
||||
}
|
||||
|
||||
protected void onItemActivated(int index) {
|
||||
DirEntry e = _entries[index];
|
||||
if (e.isDir) {
|
||||
openDirectory(e.name);
|
||||
} else if (e.isFile) {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
protected Widget createRootsList() {
|
||||
ListWidget list = new ListWidget("ROOTS_LIST");
|
||||
WidgetListAdapter adapter = new WidgetListAdapter();
|
||||
foreach(ref RootEntry root; _roots) {
|
||||
ImageTextButton btn = new ImageTextButton(null, root.icon, root.label);
|
||||
btn.orientation = Orientation.Vertical;
|
||||
btn.styleId = "TRANSPARENT_BUTTON_BACKGROUND";
|
||||
btn.focusable = false;
|
||||
adapter.widgets.add(btn);
|
||||
}
|
||||
list.ownAdapter = adapter;
|
||||
list.layoutWidth = WRAP_CONTENT;
|
||||
list.layoutHeight = FILL_PARENT;
|
||||
list.onItemClickListener = delegate(Widget source, int itemIndex) {
|
||||
openDirectory(_roots[itemIndex].path);
|
||||
return true;
|
||||
};
|
||||
return list;
|
||||
}
|
||||
|
||||
protected void onItemActivated(int index) {
|
||||
DirEntry e = _entries[index];
|
||||
if (e.isDir) {
|
||||
openDirectory(e.name);
|
||||
} else if (e.isFile) {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// override to implement creation of dialog controls
|
||||
override void init() {
|
||||
_roots = getRootPaths;
|
||||
_roots = getRootPaths;
|
||||
layoutWidth(FILL_PARENT);
|
||||
layoutWidth(FILL_PARENT);
|
||||
LinearLayout content = new HorizontalLayout("dlgcontent");
|
||||
|
@ -226,4 +226,4 @@ class FileDialog : Dialog, CustomGridCellAdapter {
|
|||
list.layoutHeight = FILL_PARENT;
|
||||
layoutHeight = FILL_PARENT;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -102,7 +102,7 @@ class StringListAdapter : ListAdapter {
|
|||
|
||||
protected void updateStatesLength() {
|
||||
if (_states.length < _items.length) {
|
||||
int oldlen = _states.length;
|
||||
int oldlen = cast(int)_states.length;
|
||||
_states.length = _items.length;
|
||||
for (int i = oldlen; i < _items.length; i++)
|
||||
_states[i] = State.Enabled;
|
||||
|
|
Loading…
Reference in New Issue