diff --git a/dlangui-msvc.sln b/dlangui-msvc.sln index 1df50262..17ff89ca 100644 --- a/dlangui-msvc.sln +++ b/dlangui-msvc.sln @@ -35,6 +35,11 @@ Project("{002A2DE9-8BB6-484D-9802-7E4AD4084715}") = "dlangide", "..\dlangide\dla {52A2ABB9-2CF7-4D5F-AE8C-75B21F8585A5} = {52A2ABB9-2CF7-4D5F-AE8C-75B21F8585A5} EndProjectSection EndProject +Project("{002A2DE9-8BB6-484D-9802-7E4AD4084715}") = "spreadsheet", "examples\spreadsheet\spreadsheet-msvc.visualdproj", "{533AF38D-98E7-446F-9689-805BDFF3CE84}" + ProjectSection(ProjectDependencies) = postProject + {52A2ABB9-2CF7-4D5F-AE8C-75B21F8585A5} = {52A2ABB9-2CF7-4D5F-AE8C-75B21F8585A5} + EndProjectSection +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Win32 = Debug|Win32 @@ -97,6 +102,13 @@ Global {DA4E9F22-21EB-4A71-AF1F-3B5BC370CBA0}.Release|Win32.ActiveCfg = Release|Win32 {DA4E9F22-21EB-4A71-AF1F-3B5BC370CBA0}.Release|Win32.Build.0 = Release|Win32 {DA4E9F22-21EB-4A71-AF1F-3B5BC370CBA0}.Release|x64.ActiveCfg = Release|Win32 + {533AF38D-98E7-446F-9689-805BDFF3CE84}.Debug|Win32.ActiveCfg = Debug|Win32 + {533AF38D-98E7-446F-9689-805BDFF3CE84}.Debug|Win32.Build.0 = Debug|Win32 + {533AF38D-98E7-446F-9689-805BDFF3CE84}.Debug|x64.ActiveCfg = Debug|x64 + {533AF38D-98E7-446F-9689-805BDFF3CE84}.Debug|x64.Build.0 = Debug|x64 + {533AF38D-98E7-446F-9689-805BDFF3CE84}.Release|Win32.ActiveCfg = Release|Win32 + {533AF38D-98E7-446F-9689-805BDFF3CE84}.Release|Win32.Build.0 = Release|Win32 + {533AF38D-98E7-446F-9689-805BDFF3CE84}.Release|x64.ActiveCfg = Release|Win32 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/dub.json b/dub.json index 6088ef30..c32e31b8 100644 --- a/dub.json +++ b/dub.json @@ -34,7 +34,8 @@ "./examples/example1/", "./examples/dmledit/", "./examples/d3d/", - "./examples/tetris/" + "./examples/tetris/", + "./examples/spreadsheet/" ], "configurations": [ diff --git a/examples/spreadsheet/dub.json b/examples/spreadsheet/dub.json new file mode 100644 index 00000000..e2064dd0 --- /dev/null +++ b/examples/spreadsheet/dub.json @@ -0,0 +1,25 @@ +{ + "name": "spreadsheet", + "description": "dlangui library example DML Editor", + "homepage": "https://github.com/buggins/dlangui", + "license": "Boost", + "authors": ["Vadim Lopatin"], + + "stringImportPaths": ["views", "views/res", "views/res/i18n", "views/res/mdpi"], + + "targetPath": "bin", + "targetName": "spreadsheet", + "targetType": "executable", + + "sourceFiles-windows": ["$PACKAGE_DIR/src/win_app.def"], + + "versions": ["EmbedStandardResources"], + + "dependencies": { + "dlangui": {"path": "../../"} + }, + + "subConfigurations": { + "dlangui": "minimal" + } +} diff --git a/examples/spreadsheet/spreadsheet-msvc.visualdproj b/examples/spreadsheet/spreadsheet-msvc.visualdproj new file mode 100644 index 00000000..f8d2ae1d --- /dev/null +++ b/examples/spreadsheet/spreadsheet-msvc.visualdproj @@ -0,0 +1,416 @@ + + {533AF38D-98E7-446F-9689-805BDFF3CE84} + + 0 + 0 + 0 + 2 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 3 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 2.043 + 0 + 0 + 0 + 0 + 0 + $(CC) -c + 1 + $(DMDInstallDir)windows\bin\dmd.exe + $(SolutionDir)/src $(SolutionDir)/3rdparty $(SolutionDir)/deps/DerelictGL3/source $(SolutionDir)/deps/DerelictUtil/source $(SolutionDir)/deps/DerelictFT/source $(SolutionDir)/deps/DerelictSDL2/source $(SolutionDir)/deps/de_image/source/interfaces $(SolutionDir)/deps/de_image/source/png $(SolutionDir)/deps/dlib + views views/res views/res/i18n views/res/mdpi views/res/hdpi + $(ConfigurationName) + $(OutDir) + + + 0 + + + + + 0 + + + 1 + $(IntDir)\$(TargetName).json + 0 + + 0 + Unicode EmbedStandardResources + 0 + 0 + 0 + + + + 0 + + 1 + $(VisualDInstallDir)cv2pdb\cv2pdb.exe + 0 + 0 + 0 + + + + ole32.lib kernel32.lib user32.lib comctl32.lib comdlg32.lib + + + + $(OutDir)\$(ProjectName).exe + 1 + 2 + 0 + + + + *.obj;*.cmd;*.build;*.json;*.dep + + + 0 + 0 + 0 + 2 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 1 + 1 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 2.043 + 0 + 0 + 0 + 0 + 0 + $(CC) -c + 1 + $(DMDInstallDir)windows\bin\dmd.exe + $(SolutionDir)/src $(SolutionDir)/3rdparty $(SolutionDir)/deps/DerelictGL3/source $(SolutionDir)/deps/DerelictUtil/source $(SolutionDir)/deps/DerelictFT/source $(SolutionDir)/deps/DerelictSDL2/source $(SolutionDir)/deps/de_image/source/interfaces $(SolutionDir)/deps/de_image/source/png $(SolutionDir)/deps/dlib + views views/res views/res/i18n views/res/mdpi views/res/hdpi + $(ConfigurationName) + $(OutDir) + + + 0 + + + + + 0 + + + 1 + $(IntDir)\$(TargetName).json + 0 + + 0 + Unicode EmbedStandardResources + 0 + 0 + 0 + + + + 0 + + 0 + $(VisualDInstallDir)cv2pdb\cv2pdb.exe + 0 + 0 + 0 + + + + ole32.lib kernel32.lib user32.lib comctl32.lib comdlg32.lib + + + + $(OutDir)\$(ProjectName).exe + 1 + 1 + 0 + + + + *.obj;*.cmd;*.build;*.json;*.dep + + + 0 + 0 + 0 + 2 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 3 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 2.043 + 0 + 0 + 0 + 0 + 0 + $(CC) -c + 1 + $(DMDInstallDir)windows\bin\dmd.exe + $(SolutionDir)/src $(SolutionDir)/3rdparty $(SolutionDir)/deps/DerelictGL3/source $(SolutionDir)/deps/DerelictUtil/source $(SolutionDir)/deps/DerelictFT/source $(SolutionDir)/deps/DerelictSDL2/source $(SolutionDir)/deps/de_image/source/interfaces $(SolutionDir)/deps/de_image/source/png $(SolutionDir)/deps/dlib + views views/res views/res/i18n views/res/mdpi views/res/hdpi + $(ConfigurationName) + $(OutDir) + + + 0 + + + + + 0 + + + 1 + $(IntDir)\$(TargetName).json + 0 + + 0 + Unicode EmbedStandardResources + 0 + 0 + 0 + + + + 0 + + 1 + $(VisualDInstallDir)cv2pdb\cv2pdb.exe + 0 + 0 + 0 + + + + ole32.lib kernel32.lib user32.lib comctl32.lib comdlg32.lib + + + + $(OutDir)\$(ProjectName).exe + 1 + 2 + 0 + + + + *.obj;*.cmd;*.build;*.json;*.dep + + + 0 + 0 + 0 + 2 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 1 + 0 + 1 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 1 + 1 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 2.043 + 0 + 0 + 0 + 0 + 0 + $(CC) -c + 1 + $(DMDInstallDir)windows\bin\dmd.exe + $(SolutionDir)/src $(SolutionDir)/3rdparty $(SolutionDir)/deps/DerelictGL3/source $(SolutionDir)/deps/DerelictUtil/source $(SolutionDir)/deps/DerelictFT/source $(SolutionDir)/deps/DerelictSDL2/source $(SolutionDir)/deps/de_image/source/interfaces $(SolutionDir)/deps/de_image/source/png $(SolutionDir)/deps/dlib + views views/res views/res/i18n views/res/mdpi views/res/hdpi + $(ConfigurationName) + $(OutDir) + + + 0 + + + + + 0 + + + 1 + $(IntDir)\$(TargetName).json + 0 + + 0 + Unicode EmbedStandardResources + 0 + 0 + 0 + + + + 0 + + 0 + $(VisualDInstallDir)cv2pdb\cv2pdb.exe + 0 + 0 + 0 + + + + ole32.lib kernel32.lib user32.lib comctl32.lib comdlg32.lib + + + + $(OutDir)\$(ProjectName).exe + 1 + 1 + 0 + + + + *.obj;*.cmd;*.build;*.json;*.dep + + + + + + + diff --git a/examples/spreadsheet/src/spreadsheet.d b/examples/spreadsheet/src/spreadsheet.d new file mode 100644 index 00000000..46159324 --- /dev/null +++ b/examples/spreadsheet/src/spreadsheet.d @@ -0,0 +1,372 @@ +module spreadsheet; + +import dlangui; +import dlangui.dialogs.filedlg; +import dlangui.dialogs.dialog; +import dlangui.dml.dmlhighlight; +import std.array : replaceFirst; + +mixin APP_ENTRY_POINT; + +// action codes +enum IDEActions : int { + //ProjectOpen = 1010000, + FileNew = 1010000, + FileOpen, + FileSave, + FileSaveAs, + FileSaveAll, + FileClose, + FileExit, + EditPreferences, + DebugStart, + HelpAbout, +} + +// actions +const Action ACTION_FILE_NEW = new Action(IDEActions.FileNew, "MENU_FILE_NEW"c, "document-new", KeyCode.KEY_N, KeyFlag.Control); +const Action ACTION_FILE_SAVE = (new Action(IDEActions.FileSave, "MENU_FILE_SAVE"c, "document-save", KeyCode.KEY_S, KeyFlag.Control)).disableByDefault(); +const Action ACTION_FILE_SAVE_AS = (new Action(IDEActions.FileSaveAs, "MENU_FILE_SAVE_AS"c)).disableByDefault(); +const Action ACTION_FILE_OPEN = new Action(IDEActions.FileOpen, "MENU_FILE_OPEN"c, "document-open", KeyCode.KEY_O, KeyFlag.Control); +const Action ACTION_FILE_EXIT = new Action(IDEActions.FileExit, "MENU_FILE_EXIT"c, "document-close"c, KeyCode.KEY_X, KeyFlag.Alt); +const Action ACTION_EDIT_COPY = (new Action(EditorActions.Copy, "MENU_EDIT_COPY"c, "edit-copy"c, KeyCode.KEY_C, KeyFlag.Control)).addAccelerator(KeyCode.INS, KeyFlag.Control).disableByDefault(); +const Action ACTION_EDIT_PASTE = (new Action(EditorActions.Paste, "MENU_EDIT_PASTE"c, "edit-paste"c, KeyCode.KEY_V, KeyFlag.Control)).addAccelerator(KeyCode.INS, KeyFlag.Shift).disableByDefault(); +const Action ACTION_EDIT_CUT = (new Action(EditorActions.Cut, "MENU_EDIT_CUT"c, "edit-cut"c, KeyCode.KEY_X, KeyFlag.Control)).addAccelerator(KeyCode.DEL, KeyFlag.Shift).disableByDefault(); +const Action ACTION_EDIT_UNDO = (new Action(EditorActions.Undo, "MENU_EDIT_UNDO"c, "edit-undo"c, KeyCode.KEY_Z, KeyFlag.Control)).disableByDefault(); +const Action ACTION_EDIT_REDO = (new Action(EditorActions.Redo, "MENU_EDIT_REDO"c, "edit-redo"c, KeyCode.KEY_Y, KeyFlag.Control)).addAccelerator(KeyCode.KEY_Z, KeyFlag.Control|KeyFlag.Shift).disableByDefault(); +const Action ACTION_EDIT_INDENT = (new Action(EditorActions.Indent, "MENU_EDIT_INDENT"c, "edit-indent"c, KeyCode.TAB, 0)).addAccelerator(KeyCode.KEY_BRACKETCLOSE, KeyFlag.Control).disableByDefault(); +const Action ACTION_EDIT_UNINDENT = (new Action(EditorActions.Unindent, "MENU_EDIT_UNINDENT"c, "edit-unindent", KeyCode.TAB, KeyFlag.Shift)).addAccelerator(KeyCode.KEY_BRACKETOPEN, KeyFlag.Control).disableByDefault(); +const Action ACTION_EDIT_TOGGLE_LINE_COMMENT = (new Action(EditorActions.ToggleLineComment, "MENU_EDIT_TOGGLE_LINE_COMMENT"c, null, KeyCode.KEY_DIVIDE, KeyFlag.Control)).disableByDefault(); +const Action ACTION_EDIT_TOGGLE_BLOCK_COMMENT = (new Action(EditorActions.ToggleBlockComment, "MENU_EDIT_TOGGLE_BLOCK_COMMENT"c, null, KeyCode.KEY_DIVIDE, KeyFlag.Control|KeyFlag.Shift)).disableByDefault(); +const Action ACTION_EDIT_PREFERENCES = (new Action(IDEActions.EditPreferences, "MENU_EDIT_PREFERENCES"c, null)).disableByDefault(); +const Action ACTION_DEBUG_START = new Action(IDEActions.DebugStart, "MENU_DEBUG_UPDATE_PREVIEW"c, "debug-run"c, KeyCode.F5, 0); +const Action ACTION_HELP_ABOUT = new Action(IDEActions.HelpAbout, "MENU_HELP_ABOUT"c); + +/// DIDE source file editor +class DMLSourceEdit : SourceEdit { + this(string ID) { + super(ID); + MenuItem editPopupItem = new MenuItem(null); + editPopupItem.add(ACTION_EDIT_COPY, ACTION_EDIT_PASTE, ACTION_EDIT_CUT, ACTION_EDIT_UNDO, ACTION_EDIT_REDO, ACTION_EDIT_INDENT, ACTION_EDIT_UNINDENT, ACTION_EDIT_TOGGLE_LINE_COMMENT, ACTION_DEBUG_START); + popupMenu = editPopupItem; + content.syntaxSupport = new DMLSyntaxSupport(""); + setTokenHightlightColor(TokenCategory.Comment, 0x008000); // green + setTokenHightlightColor(TokenCategory.Keyword, 0x0000FF); // blue + setTokenHightlightColor(TokenCategory.String, 0xa31515); // brown + setTokenHightlightColor(TokenCategory.Integer, 0xa315C0); // + setTokenHightlightColor(TokenCategory.Float, 0xa315C0); // + setTokenHightlightColor(TokenCategory.Error, 0xFF0000); // red + setTokenHightlightColor(TokenCategory.Op, 0x503000); + setTokenHightlightColor(TokenCategory.Identifier_Class, 0x000080); // blue + + } + this() { + this("DMLEDIT"); + } +} + +immutable dstring SAMPLE_SOURCE_CODE = +q{VerticalLayout { + id: vlayout + margins: Rect { left: 5; right: 3; top: 2; bottom: 4 } + padding: Rect { 5, 4, 3, 2 } // same as Rect { left: 5; top: 4; right: 3; bottom: 2 } + TextWidget { + /* this widget can be accessed via id myLabel1 + e.g. w.childById!TextWidget("myLabel1") + */ + id: myLabel1 + text: "Some text"; padding: 5 + enabled: false + } + TextWidget { + id: myLabel2 + text: "More text"; margins: 5 + enabled: true + } + CheckBox{ id: cb1; text: "Some checkbox" } + HorizontalLayout { + RadioButton { id: rb1; text: "Radio Button 1" } + RadioButton { id: rb1; text: "Radio Button 2" } + } +} +}; + + +class EditFrame : AppFrame { + + MenuItem mainMenuItems; + + override protected void init() { + _appName = "DMLEdit"; + super.init(); + updatePreview(); + } + + /// create main menu + override protected MainMenu createMainMenu() { + mainMenuItems = new MenuItem(); + MenuItem fileItem = new MenuItem(new Action(1, "MENU_FILE")); + fileItem.add(ACTION_FILE_NEW, ACTION_FILE_OPEN, + ACTION_FILE_EXIT); + mainMenuItems.add(fileItem); + MenuItem editItem = new MenuItem(new Action(2, "MENU_EDIT")); + editItem.add(ACTION_EDIT_COPY, ACTION_EDIT_PASTE, + ACTION_EDIT_CUT, ACTION_EDIT_UNDO, ACTION_EDIT_REDO, + ACTION_EDIT_INDENT, ACTION_EDIT_UNINDENT, ACTION_EDIT_TOGGLE_LINE_COMMENT, ACTION_EDIT_TOGGLE_BLOCK_COMMENT, ACTION_DEBUG_START); + + editItem.add(ACTION_EDIT_PREFERENCES); + mainMenuItems.add(editItem); + MainMenu mainMenu = new MainMenu(mainMenuItems); + return mainMenu; + } + + + /// create app toolbars + override protected ToolBarHost createToolbars() { + ToolBarHost res = new ToolBarHost(); + ToolBar tb; + tb = res.getOrAddToolbar("Standard"); + tb.addButtons(ACTION_FILE_NEW, ACTION_FILE_OPEN, ACTION_FILE_SAVE, ACTION_SEPARATOR, ACTION_DEBUG_START); + + tb = res.getOrAddToolbar("Edit"); + tb.addButtons(ACTION_EDIT_COPY, ACTION_EDIT_PASTE, ACTION_EDIT_CUT, ACTION_SEPARATOR, + ACTION_EDIT_UNDO, ACTION_EDIT_REDO, ACTION_EDIT_INDENT, ACTION_EDIT_UNINDENT); + return res; + } + + string _filename; + void openSourceFile(string filename) { + import std.file; + // TODO + if (exists(filename)) { + _filename = filename; + window.windowCaption = toUTF32(filename); + _editor.load(filename); + updatePreview(); + } + } + + void saveSourceFile(string filename) { + if (filename.length == 0) + filename = _filename; + import std.file; + _filename = filename; + window.windowCaption = toUTF32(filename); + _editor.save(filename); + } + + bool onCanClose() { + // todo + return true; + } + + FileDialog createFileDialog(UIString caption, bool fileMustExist = true) { + uint flags = DialogFlag.Modal | DialogFlag.Resizable; + if (fileMustExist) + flags |= FileDialogFlag.FileMustExist; + FileDialog dlg = new FileDialog(caption, window, null, flags); + dlg.filetypeIcons[".d"] = "text-dml"; + return dlg; + } + + void saveAs() { + } + + /// override to handle specific actions + override bool handleAction(const Action a) { + if (a) { + switch (a.id) { + case IDEActions.FileExit: + if (onCanClose()) + window.close(); + return true; + case IDEActions.HelpAbout: + window.showMessageBox(UIString("About DlangUI ML Editor"d), + UIString("DLangIDE\n(C) Vadim Lopatin, 2015\nhttp://github.com/buggins/dlangui\nSimple editor for DML code"d)); + return true; + case IDEActions.FileNew: + UIString caption; + caption = "Create new DML file"d; + FileDialog dlg = createFileDialog(caption, false); + dlg.addFilter(FileFilterEntry(UIString("DML files"d), "*.dml")); + dlg.addFilter(FileFilterEntry(UIString("All files"d), "*.*")); + dlg.onDialogResult = delegate(Dialog dlg, const Action result) { + if (result.id == ACTION_OPEN.id) { + string filename = result.stringParam; + _editor.text=""d; + saveSourceFile(filename); + } + }; + dlg.show(); + return true; + case IDEActions.FileSave: + if (_filename.length) { + saveSourceFile(_filename); + return true; + } + UIString caption; + caption = "Save DML File as"d; + FileDialog dlg = createFileDialog(caption, false); + dlg.addFilter(FileFilterEntry(UIString("DML files"d), "*.dml")); + dlg.addFilter(FileFilterEntry(UIString("All files"d), "*.*")); + dlg.onDialogResult = delegate(Dialog dlg, const Action result) { + if (result.id == ACTION_OPEN.id) { + string filename = result.stringParam; + saveSourceFile(filename); + } + }; + dlg.show(); + return true; + case IDEActions.FileOpen: + UIString caption; + caption = "Open DML File"d; + FileDialog dlg = createFileDialog(caption); + dlg.addFilter(FileFilterEntry(UIString("DML files"d), "*.dml")); + dlg.addFilter(FileFilterEntry(UIString("All files"d), "*.*")); + dlg.onDialogResult = delegate(Dialog dlg, const Action result) { + if (result.id == ACTION_OPEN.id) { + string filename = result.stringParam; + openSourceFile(filename); + } + }; + dlg.show(); + return true; + case IDEActions.DebugStart: + updatePreview(); + return true; + case IDEActions.EditPreferences: + //showPreferences(); + return true; + default: + return super.handleAction(a); + } + } + return false; + } + + /// override to handle specific actions state (e.g. change enabled state for supported actions) + override bool handleActionStateRequest(const Action a) { + switch (a.id) { + case IDEActions.HelpAbout: + case IDEActions.FileNew: + case IDEActions.FileSave: + case IDEActions.FileOpen: + case IDEActions.DebugStart: + case IDEActions.EditPreferences: + a.state = ACTION_STATE_ENABLED; + return true; + default: + return super.handleActionStateRequest(a); + } + } + + void updatePreview() { + dstring dsource = _editor.text; + string source = toUTF8(dsource); + try { + Widget w = parseML(source); + if (statusLine) + statusLine.setStatusText("No errors"d); + if (_fillHorizontal) + w.layoutWidth = FILL_PARENT; + if (_fillVertical) + w.layoutHeight = FILL_PARENT; + if (_highlightBackground) + w.backgroundColor = 0xC0C0C0C0; + _preview.contentWidget = w; + } catch (ParserException e) { + if (statusLine) + statusLine.setStatusText(toUTF32("ERROR: " ~ e.msg)); + _editor.setCaretPos(e.line, e.pos); + string msg = "\n" ~ e.msg ~ "\n"; + msg = replaceFirst(msg, " near `", "\nnear `"); + TextWidget w = new MultilineTextWidget(null, toUTF32(msg)); + w.padding = 10; + w.margins = 10; + w.maxLines = 10; + w.backgroundColor = 0xC0FF8080; + _preview.contentWidget = w; + } + } + + protected bool _fillHorizontal; + protected bool _fillVertical; + protected bool _highlightBackground; + protected DMLSourceEdit _editor; + protected ScrollWidget _preview; + /// create app body widget + override protected Widget createBody() { + VerticalLayout bodyWidget = new VerticalLayout(); + bodyWidget.layoutWidth = FILL_PARENT; + bodyWidget.layoutHeight = FILL_PARENT; + HorizontalLayout hlayout = new HorizontalLayout(); + hlayout.layoutWidth = FILL_PARENT; + hlayout.layoutHeight = FILL_PARENT; + _editor = new DMLSourceEdit(); + hlayout.addChild(_editor); + _editor.text = SAMPLE_SOURCE_CODE; + VerticalLayout previewLayout = new VerticalLayout(); + previewLayout.layoutWidth = makePercentSize(50); + previewLayout.layoutHeight = FILL_PARENT; + auto previewControls = new HorizontalLayout(); + auto cbFillHorizontal = new CheckBox(null, "Fill Horizontal"d); + auto cbFillVertical = new CheckBox(null, "Fill Vertical"d); + auto cbHighlightBackground = new CheckBox(null, "Background"d); + cbFillHorizontal.onCheckChangeListener = delegate(Widget source, bool checked) { + _fillHorizontal = checked; + updatePreview(); + return true; + }; + cbFillVertical.onCheckChangeListener = delegate(Widget source, bool checked) { + _fillVertical = checked; + updatePreview(); + return true; + }; + cbHighlightBackground.onCheckChangeListener = delegate(Widget source, bool checked) { + _highlightBackground = checked; + updatePreview(); + return true; + }; + previewControls.addChild(cbFillHorizontal); + previewControls.addChild(cbFillVertical); + previewControls.addChild(cbHighlightBackground); + + _preview = new ScrollWidget(); + _preview.layoutWidth = FILL_PARENT; + _preview.layoutHeight = FILL_PARENT; + _preview.backgroundImageId = "tx_fabric.tiled"; + previewLayout.addChild(previewControls); + previewLayout.addChild(_preview); + hlayout.addChild(previewLayout); + bodyWidget.addChild(hlayout); + return bodyWidget; + } + +} + +/// entry point for dlangui based application +extern (C) int UIAppMain(string[] args) { + + // embed non-standard resources listed in views/resources.list into executable + embeddedResourceList.addResources(embedResourcesFromList!("resources.list")()); + + /// set font gamma (1.0 is neutral, < 1.0 makes glyphs lighter, >1.0 makes glyphs bolder) + FontManager.fontGamma = 0.8; + FontManager.hintingMode = HintingMode.Normal; + + // create window + Window window = Platform.instance.createWindow("DlangUI ML editor"d, null, WindowFlag.Resizable, 700, 470); + + // create some widget to show in window + window.windowIcon = drawableCache.getImage("dlangui-logo1"); + + + // create some widget to show in window + window.mainWidget = new EditFrame(); + + // show window + window.show(); + + // run message loop + return Platform.instance.enterMessageLoop(); +} diff --git a/examples/spreadsheet/src/win_app.def b/examples/spreadsheet/src/win_app.def new file mode 100644 index 00000000..40b796c7 --- /dev/null +++ b/examples/spreadsheet/src/win_app.def @@ -0,0 +1,2 @@ +EXETYPE NT +SUBSYSTEM WINDOWS diff --git a/examples/spreadsheet/views/res/hdpi/document-close.png b/examples/spreadsheet/views/res/hdpi/document-close.png new file mode 100644 index 00000000..0bcfe981 Binary files /dev/null and b/examples/spreadsheet/views/res/hdpi/document-close.png differ diff --git a/examples/spreadsheet/views/res/hdpi/document-open-recent.png b/examples/spreadsheet/views/res/hdpi/document-open-recent.png new file mode 100644 index 00000000..6a10e6ef Binary files /dev/null and b/examples/spreadsheet/views/res/hdpi/document-open-recent.png differ diff --git a/examples/spreadsheet/views/res/hdpi/document-open.png b/examples/spreadsheet/views/res/hdpi/document-open.png new file mode 100644 index 00000000..8ba54411 Binary files /dev/null and b/examples/spreadsheet/views/res/hdpi/document-open.png differ diff --git a/examples/spreadsheet/views/res/hdpi/document-save-as.png b/examples/spreadsheet/views/res/hdpi/document-save-as.png new file mode 100644 index 00000000..9695a564 Binary files /dev/null and b/examples/spreadsheet/views/res/hdpi/document-save-as.png differ diff --git a/examples/spreadsheet/views/res/hdpi/document-save.png b/examples/spreadsheet/views/res/hdpi/document-save.png new file mode 100644 index 00000000..7fa489c0 Binary files /dev/null and b/examples/spreadsheet/views/res/hdpi/document-save.png differ diff --git a/examples/spreadsheet/views/res/hdpi/edit-clear.png b/examples/spreadsheet/views/res/hdpi/edit-clear.png new file mode 100644 index 00000000..631ed445 Binary files /dev/null and b/examples/spreadsheet/views/res/hdpi/edit-clear.png differ diff --git a/examples/spreadsheet/views/res/hdpi/edit-copy.png b/examples/spreadsheet/views/res/hdpi/edit-copy.png new file mode 100644 index 00000000..477e83a6 Binary files /dev/null and b/examples/spreadsheet/views/res/hdpi/edit-copy.png differ diff --git a/examples/spreadsheet/views/res/hdpi/edit-cut.png b/examples/spreadsheet/views/res/hdpi/edit-cut.png new file mode 100644 index 00000000..07323280 Binary files /dev/null and b/examples/spreadsheet/views/res/hdpi/edit-cut.png differ diff --git a/examples/spreadsheet/views/res/hdpi/edit-delete.png b/examples/spreadsheet/views/res/hdpi/edit-delete.png new file mode 100644 index 00000000..cc6d2af8 Binary files /dev/null and b/examples/spreadsheet/views/res/hdpi/edit-delete.png differ diff --git a/examples/spreadsheet/views/res/hdpi/edit-paste.png b/examples/spreadsheet/views/res/hdpi/edit-paste.png new file mode 100644 index 00000000..6788b022 Binary files /dev/null and b/examples/spreadsheet/views/res/hdpi/edit-paste.png differ diff --git a/examples/spreadsheet/views/res/hdpi/edit-redo.png b/examples/spreadsheet/views/res/hdpi/edit-redo.png new file mode 100644 index 00000000..d759f136 Binary files /dev/null and b/examples/spreadsheet/views/res/hdpi/edit-redo.png differ diff --git a/examples/spreadsheet/views/res/hdpi/edit-undo.png b/examples/spreadsheet/views/res/hdpi/edit-undo.png new file mode 100644 index 00000000..c893a1a6 Binary files /dev/null and b/examples/spreadsheet/views/res/hdpi/edit-undo.png differ diff --git a/examples/spreadsheet/views/res/i18n/en.ini b/examples/spreadsheet/views/res/i18n/en.ini new file mode 100644 index 00000000..576671ef --- /dev/null +++ b/examples/spreadsheet/views/res/i18n/en.ini @@ -0,0 +1,40 @@ +EXIT=Exit +MENU_FILE=&File +MENU_FILE_NEW=&New +MENU_FILE_OPEN=&Open +MENU_FILE_OPEN_RECENT=Open recent +MENU_FILE_SAVE=&Save +MENU_FILE_EXIT=E&xit +MENU_EDIT=&Edit +MENU_EDIT_COPY=&Copy +MENU_EDIT_PASTE=&Paste +MENU_EDIT_CUT=Cu&t +MENU_EDIT_UNDO=&Undo +MENU_EDIT_REDO=&Redo +MENU_EDIT_INDENT=Indent block +MENU_EDIT_UNINDENT=Unindent block +MENU_EDIT_TOGGLE_LINE_COMMENT=Toggle line comment +MENU_EDIT_TOGGLE_BLOCK_COMMENT=Toggle block comment +MENU_EDIT_PREFERENCES=&Preferences +MENU_VIEW=&View +MENU_VIEW_LANGUAGE=Interface &Language +MENU_VIEW_LANGUAGE_EN=English +MENU_VIEW_LANGUAGE_RU=Русский +MENU_VIEW_THEME=&Theme +MENU_VIEW_THEME_DEFAULT=Default +MENU_VIEW_THEME_DARK=Dark +MENU_VIEW_THEME_CUSTOM1=Custom 1 +MENU_WINDOW=&Window +MENU_WINDOW_PREFERENCES=&Preferences +MENU_HELP=&Help +MENU_HELP_VIEW_HELP=&View help +MENU_HELP_ABOUT=&About +MENU_DEBUG_UPDATE_PREVIEW=Update Preview + +TAB_LONG_LIST=Long list +TAB_BUTTONS=Buttons +TAB_ANIMATION=Animation +TAB_TABLE_LAYOUT=Table layout +TAB_EDITORS=Editors +TAB_CANVAS=Canvas + diff --git a/examples/spreadsheet/views/res/i18n/ru.ini b/examples/spreadsheet/views/res/i18n/ru.ini new file mode 100644 index 00000000..ab52d3d0 --- /dev/null +++ b/examples/spreadsheet/views/res/i18n/ru.ini @@ -0,0 +1,34 @@ +EXIT=Выход +MENU_FILE=&Файл +MENU_FILE_OPEN=&Открыть +MENU_FILE_OPEN_RECENT=Открыть из последних +MENU_FILE_SAVE=&Сохранить +MENU_FILE_EXIT=Вы&ход +MENU_EDIT=&Правка +MENU_EDIT_COPY=&Копировать +MENU_EDIT_PASTE=&Вставить +MENU_EDIT_CUT=Вырезать +MENU_EDIT_UNDO=&Отмена +MENU_EDIT_REDO=&Повторить +MENU_EDIT_PREFERENCES=&Настройки +MENU_VIEW=&Вид +MENU_VIEW_LANGUAGE=&Язык интерфейса +MENU_VIEW_LANGUAGE_EN=English +MENU_VIEW_LANGUAGE_RU=Русский +MENU_VIEW_THEME=&Тема +MENU_VIEW_THEME_DEFAULT=Стандартная +MENU_VIEW_THEME_DARK=Тёмная +MENU_VIEW_THEME_CUSTOM1=Пример 1 +MENU_WINDOW=&Окно +MENU_WINDOW_PREFERENCES=&Настройки +MENU_HELP=&Справка +MENU_HELP_VIEW_HELP=&Просмотр справки +MENU_HELP_ABOUT=&О программе + +TAB_LONG_LIST=Длинный список +TAB_BUTTONS=Кнопки +TAB_ANIMATION=Анимация +TAB_TABLE_LAYOUT=Табличный layout +TAB_EDITORS=Редакторы + + diff --git a/examples/spreadsheet/views/res/mdpi/cr3_logo.png b/examples/spreadsheet/views/res/mdpi/cr3_logo.png new file mode 100644 index 00000000..6e0d94ea Binary files /dev/null and b/examples/spreadsheet/views/res/mdpi/cr3_logo.png differ diff --git a/examples/spreadsheet/views/res/mdpi/debug-run.png b/examples/spreadsheet/views/res/mdpi/debug-run.png new file mode 100644 index 00000000..eee3e905 Binary files /dev/null and b/examples/spreadsheet/views/res/mdpi/debug-run.png differ diff --git a/examples/spreadsheet/views/res/mdpi/document-close.png b/examples/spreadsheet/views/res/mdpi/document-close.png new file mode 100644 index 00000000..411031eb Binary files /dev/null and b/examples/spreadsheet/views/res/mdpi/document-close.png differ diff --git a/examples/spreadsheet/views/res/mdpi/document-new.png b/examples/spreadsheet/views/res/mdpi/document-new.png new file mode 100644 index 00000000..a956a809 Binary files /dev/null and b/examples/spreadsheet/views/res/mdpi/document-new.png differ diff --git a/examples/spreadsheet/views/res/mdpi/document-open-recent.png b/examples/spreadsheet/views/res/mdpi/document-open-recent.png new file mode 100644 index 00000000..15847ce4 Binary files /dev/null and b/examples/spreadsheet/views/res/mdpi/document-open-recent.png differ diff --git a/examples/spreadsheet/views/res/mdpi/document-open.png b/examples/spreadsheet/views/res/mdpi/document-open.png new file mode 100644 index 00000000..17076a31 Binary files /dev/null and b/examples/spreadsheet/views/res/mdpi/document-open.png differ diff --git a/examples/spreadsheet/views/res/mdpi/document-properties.png b/examples/spreadsheet/views/res/mdpi/document-properties.png new file mode 100644 index 00000000..12c6b448 Binary files /dev/null and b/examples/spreadsheet/views/res/mdpi/document-properties.png differ diff --git a/examples/spreadsheet/views/res/mdpi/document-save-as.png b/examples/spreadsheet/views/res/mdpi/document-save-as.png new file mode 100644 index 00000000..41c52aaa Binary files /dev/null and b/examples/spreadsheet/views/res/mdpi/document-save-as.png differ diff --git a/examples/spreadsheet/views/res/mdpi/document-save.png b/examples/spreadsheet/views/res/mdpi/document-save.png new file mode 100644 index 00000000..3f7fd63c Binary files /dev/null and b/examples/spreadsheet/views/res/mdpi/document-save.png differ diff --git a/examples/spreadsheet/views/res/mdpi/edit-copy.png b/examples/spreadsheet/views/res/mdpi/edit-copy.png new file mode 100644 index 00000000..54eaf777 Binary files /dev/null and b/examples/spreadsheet/views/res/mdpi/edit-copy.png differ diff --git a/examples/spreadsheet/views/res/mdpi/edit-cut.png b/examples/spreadsheet/views/res/mdpi/edit-cut.png new file mode 100644 index 00000000..f4a55e3d Binary files /dev/null and b/examples/spreadsheet/views/res/mdpi/edit-cut.png differ diff --git a/examples/spreadsheet/views/res/mdpi/edit-indent.png b/examples/spreadsheet/views/res/mdpi/edit-indent.png new file mode 100644 index 00000000..ffd0730d Binary files /dev/null and b/examples/spreadsheet/views/res/mdpi/edit-indent.png differ diff --git a/examples/spreadsheet/views/res/mdpi/edit-paste.png b/examples/spreadsheet/views/res/mdpi/edit-paste.png new file mode 100644 index 00000000..3f71b1c7 Binary files /dev/null and b/examples/spreadsheet/views/res/mdpi/edit-paste.png differ diff --git a/examples/spreadsheet/views/res/mdpi/edit-redo.png b/examples/spreadsheet/views/res/mdpi/edit-redo.png new file mode 100644 index 00000000..c03bba0c Binary files /dev/null and b/examples/spreadsheet/views/res/mdpi/edit-redo.png differ diff --git a/examples/spreadsheet/views/res/mdpi/edit-undo.png b/examples/spreadsheet/views/res/mdpi/edit-undo.png new file mode 100644 index 00000000..f1239421 Binary files /dev/null and b/examples/spreadsheet/views/res/mdpi/edit-undo.png differ diff --git a/examples/spreadsheet/views/res/mdpi/edit-unindent.png b/examples/spreadsheet/views/res/mdpi/edit-unindent.png new file mode 100644 index 00000000..1e6f2cdb Binary files /dev/null and b/examples/spreadsheet/views/res/mdpi/edit-unindent.png differ diff --git a/examples/spreadsheet/views/res/mdpi/text-dml.png b/examples/spreadsheet/views/res/mdpi/text-dml.png new file mode 100644 index 00000000..7a97a453 Binary files /dev/null and b/examples/spreadsheet/views/res/mdpi/text-dml.png differ diff --git a/examples/spreadsheet/views/res/mdpi/tx_fabric.jpg b/examples/spreadsheet/views/res/mdpi/tx_fabric.jpg new file mode 100644 index 00000000..6c33894a Binary files /dev/null and b/examples/spreadsheet/views/res/mdpi/tx_fabric.jpg differ diff --git a/examples/spreadsheet/views/resources.list b/examples/spreadsheet/views/resources.list new file mode 100644 index 00000000..d8a1b540 --- /dev/null +++ b/examples/spreadsheet/views/resources.list @@ -0,0 +1,20 @@ +res/i18n/en.ini +res/i18n/ru.ini +res/mdpi/cr3_logo.png +res/mdpi/debug-run.png +res/mdpi/document-close.png +res/mdpi/document-new.png +res/mdpi/document-open-recent.png +res/mdpi/document-open.png +res/mdpi/document-properties.png +res/mdpi/document-save-as.png +res/mdpi/document-save.png +res/mdpi/edit-copy.png +res/mdpi/edit-cut.png +res/mdpi/edit-indent.png +res/mdpi/edit-paste.png +res/mdpi/edit-redo.png +res/mdpi/edit-undo.png +res/mdpi/edit-unindent.png +res/mdpi/text-dml.png +res/mdpi/tx_fabric.jpg