This commit is contained in:
Vadim Lopatin 2015-01-16 13:59:20 +03:00
parent fcdcf2a1fb
commit f8b20e7b99
5 changed files with 60 additions and 18 deletions

View File

@ -1,26 +1,26 @@
EXIT=Exit
MENU_FILE=&File
MENU_FILE=&FILE
MENU_FILE_OPEN=&Open
MENU_FILE_OPEN_RECENT=Open recent
MENU_FILE_SAVE=&Save
MENU_FILE_EXIT=E&xit
MENU_EDIT=&Edit
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_PREFERENCES=&Preferences
MENU_VIEW=&View
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_CUSTOM1=&Custom 1
MENU_WINDOW=&Window
MENU_WINDOW=&WINDOW
MENU_WINDOW_PREFERENCES=&Preferences
MENU_HELP=&Help
MENU_HELP=&HELP
MENU_HELP_VIEW_HELP=&View help
MENU_HELP_ABOUT=&About

View File

@ -261,6 +261,28 @@
layoutHeight="FILL_PARENT"
padding="1,1,1,1"
/>
<style id="TOOLBAR_HOST"
backgroundColor="#d6dbe9"
layoutWidth="FILL_PARENT"
layoutHeight="WRAP_CONTENT"
padding="1,1,1,1"
/>
<style id="TOOLBAR"
backgroundImageId="toolbar_background"
layoutWidth="WRAP_CONTENT"
layoutHeight="WRAP_CONTENT"
margins="2,2,2,2"
/>
<style id="TOOLBAR_BUTTON"
backgroundImageId="btn_background_transparent"
align="Center"
margins="2,2,2,2"
/>
<style id="TOOLBAR_SEPARATOR"
align="Center"
/>
<style id="TREE_ITEM"
padding="2,2,2,2"
margins="0,0,0,0"

View File

@ -39,10 +39,12 @@ extern (C) int UIAppMain(string[] args) {
Window window = Platform.instance.createWindow("Dlang IDE", null);
IDEFrame frame = new IDEFrame(window);
frame.loadWorkspace(appendPath(exePath, "../workspaces/sample1/sample1.dlangidews"));
// create some widget to show in window
window.mainWidget = frame;
window.windowIcon = drawableCache.getImage("dlangui-logo1");
frame.loadWorkspace(appendPath(exePath, "../workspaces/sample1/sample1.dlangidews"));
// show window
window.show();

View File

@ -2,10 +2,16 @@ module dlangide.ui.commands;
import dlangui.core.events;
enum : int {
ACTION_HELP_ABOUT = 5500,
}
enum IDEActions : int {
None = 0,
ProjectOpen = 1010000,
FileNew,
FileOpen,
FileSave,
FileClose,
FileExit,
EditCopy = 1011000,
@ -15,3 +21,11 @@ enum IDEActions : int {
EditRedo,
}
__gshared Action ACTION_FILE_OPEN;
__gshared Action ACTION_FILE_SAVE;
__gshared Action ACTION_FILE_EXIT;
__gshared static this() {
ACTION_FILE_OPEN = new Action(IDEActions.FileOpen, "MENU_FILE_OPEN"c, "document-open", KeyCode.KEY_O, KeyFlag.Control);
ACTION_FILE_SAVE = new Action(IDEActions.FileSave, "MENU_FILE_SAVE"c, "document-save", KeyCode.KEY_S, KeyFlag.Control);
ACTION_FILE_EXIT = new Action(IDEActions.FileExit, "MENU_FILE_EXIT"c, "document-close"c, KeyCode.KEY_X, KeyFlag.Alt);
}

View File

@ -7,6 +7,7 @@ import dlangui.widgets.editors;
import dlangui.widgets.controls;
import dlangui.widgets.appframe;
import dlangui.widgets.docks;
import dlangui.widgets.toolbars;
import dlangui.dialogs.dialog;
import dlangui.dialogs.filedlg;
@ -16,13 +17,6 @@ import dlangide.workspace.workspace;
import std.conv;
enum : int {
ACTION_FILE_OPEN = 5500,
ACTION_FILE_SAVE,
ACTION_FILE_CLOSE,
ACTION_FILE_EXIT,
ACTION_HELP_ABOUT,
}
class IDEFrame : AppFrame {
@ -79,9 +73,9 @@ class IDEFrame : AppFrame {
mainMenuItems = new MenuItem();
MenuItem fileItem = new MenuItem(new Action(1, "MENU_FILE"));
fileItem.add(new Action(ACTION_FILE_OPEN, "MENU_FILE_OPEN"c, "document-open", KeyCode.KEY_O, KeyFlag.Control));
fileItem.add(new Action(ACTION_FILE_SAVE, "MENU_FILE_SAVE"c, "document-save", KeyCode.KEY_S, KeyFlag.Control));
fileItem.add(new Action(ACTION_FILE_EXIT, "MENU_FILE_EXIT"c, "document-close"c, KeyCode.KEY_X, KeyFlag.Alt));
fileItem.add(ACTION_FILE_OPEN);
fileItem.add(ACTION_FILE_SAVE);
fileItem.add(ACTION_FILE_EXIT);
MenuItem editItem = new MenuItem(new Action(2, "MENU_EDIT"));
editItem.add(new Action(EditorActions.Copy, "MENU_EDIT_COPY"c, "edit-copy", KeyCode.KEY_C, KeyFlag.Control));
editItem.add(new Action(EditorActions.Paste, "MENU_EDIT_PASTE"c, "edit-paste", KeyCode.KEY_V, KeyFlag.Control));
@ -108,22 +102,32 @@ class IDEFrame : AppFrame {
mainMenuItems.add(helpItem);
MainMenu mainMenu = new MainMenu(mainMenuItems);
mainMenu.backgroundColor = 0xd6dbe9;
return mainMenu;
}
/// create app toolbars
override protected ToolBarHost createToolbars() {
ToolBarHost res = new ToolBarHost();
ToolBar tb;
tb = res.getOrAddToolbar("Standard");
tb.addButtons(ACTION_FILE_OPEN, ACTION_FILE_SAVE, ACTION_SEPARATOR, ACTION_FILE_EXIT);
return res;
}
override bool onMenuItemClick(MenuItem item) {
Log.d("mainMenu.onMenuItemListener", item.label);
const Action a = item.action;
if (a) {
switch (a.id) {
case ACTION_FILE_EXIT:
case IDEActions.FileExit:
return true;
case ACTION_HELP_ABOUT:
Window wnd = Platform.instance.createWindow("About...", window, WindowFlag.Modal);
wnd.mainWidget = createAboutWidget();
wnd.show();
return true;
case ACTION_FILE_OPEN:
case IDEActions.FileOpen:
UIString caption;
caption = "Open Text File"d;
FileDialog dlg = new FileDialog(caption, window, null);