| 1 |
yuya |
1.1 |
#! /usr/bin/ruby -Ks |
| 2 |
|
|
|
| 3 |
yuya |
1.4 |
# $Id: exerb-studio.rb,v 1.3 2003/06/12 04:04:00 yuya Exp $ |
| 4 |
yuya |
1.2 |
|
| 5 |
yuya |
1.3 |
require 'uconv' |
| 6 |
|
|
require 'rexml/document' |
| 7 |
yuya |
1.1 |
require 'vr/vruby' |
| 8 |
|
|
require 'vr/vrcontrol' |
| 9 |
|
|
require 'vr/vrcomctl' |
| 10 |
|
|
require 'vr/vrdialog' |
| 11 |
yuya |
1.3 |
require 'vrext/vrext' |
| 12 |
|
|
|
| 13 |
yuya |
1.1 |
require 'form/form' |
| 14 |
|
|
require 'model/model' |
| 15 |
yuya |
1.3 |
#require 'node/node' |
| 16 |
yuya |
1.4 |
require 'config' |
| 17 |
yuya |
1.1 |
|
| 18 |
|
|
class MainForm < VRForm |
| 19 |
|
|
|
| 20 |
|
|
include VRMenuUseable |
| 21 |
|
|
include VRStatusbarDockable |
| 22 |
|
|
|
| 23 |
|
|
def construct |
| 24 |
|
|
self.caption = 'Exerb Studio' |
| 25 |
|
|
self.move(50, 50, 300, 450) |
| 26 |
|
|
self.create_menu |
| 27 |
|
|
self.create_controls |
| 28 |
|
|
end |
| 29 |
|
|
|
| 30 |
|
|
def create_menu |
| 31 |
|
|
menu = newMenu.set( |
| 32 |
|
|
[ |
| 33 |
|
|
[ |
| 34 |
|
|
"&File", |
| 35 |
|
|
[ |
| 36 |
|
|
["Open Project...", "menu_file_open"], |
| 37 |
|
|
["E&xit", "menu_file_exit"], |
| 38 |
|
|
] |
| 39 |
|
|
], |
| 40 |
|
|
[ |
| 41 |
|
|
"&Build", |
| 42 |
|
|
[ |
| 43 |
|
|
["&Build", "menu_build_build"], |
| 44 |
|
|
] |
| 45 |
|
|
], |
| 46 |
|
|
[ |
| 47 |
|
|
"&Help", |
| 48 |
|
|
[ |
| 49 |
|
|
["&About", "menu_help_about"], |
| 50 |
|
|
] |
| 51 |
|
|
], |
| 52 |
|
|
] |
| 53 |
|
|
) |
| 54 |
|
|
self.setMenu(menu) |
| 55 |
|
|
end |
| 56 |
|
|
protected :create_menu |
| 57 |
|
|
|
| 58 |
|
|
def create_controls |
| 59 |
|
|
@imglist = VRLocalScreen.factory.newimagelist(16, 16) |
| 60 |
yuya |
1.3 |
@imglist.addicon('res/folder_close.ico') |
| 61 |
|
|
@imglist.addicon('res/folder_open.ico') |
| 62 |
|
|
@imglist.addicon('mail.ico') |
| 63 |
yuya |
1.1 |
|
| 64 |
|
|
self.addStatusbar("status bar") |
| 65 |
|
|
|
| 66 |
|
|
cx, cy, cw, ch = self.clientrect |
| 67 |
|
|
self.addControl(VRStatic, 'line1', '', cx, cy, cw, 0, WStyle::SS_ETCHEDHORZ) |
| 68 |
|
|
@lab1 = self.addControl(VRStatic, 'lab1', '', cx + 5, cy + 5, cw, 16) |
| 69 |
|
|
@lab2 = self.addControl(VRStatic, 'lab2', '', cx + 5, cy + 21, cw, 16) |
| 70 |
|
|
@tree = self.addControl(VRTreeview, 'tree', '', cx, cy + 38, cw, ch - 38 - 20, WStyle::WS_BORDER) |
| 71 |
|
|
@tree.setImagelist(@imglist) |
| 72 |
|
|
|
| 73 |
|
|
font = @screen.factory.newfont("Terminal", 14) |
| 74 |
|
|
[@lab1, @lab2, @tree].each { |ctrl| ctrl.setFont(font) } |
| 75 |
|
|
|
| 76 |
yuya |
1.3 |
project = Model::Project.loadxml('sample.xml') |
| 77 |
|
|
project.create_node(@tree, WConst::TVI_ROOT) |
| 78 |
yuya |
1.1 |
end |
| 79 |
|
|
protected :create_controls |
| 80 |
|
|
|
| 81 |
|
|
def menu_file_exit_clicked |
| 82 |
|
|
self.close |
| 83 |
|
|
end |
| 84 |
|
|
|
| 85 |
|
|
def menu_help_about_clicked |
| 86 |
|
|
VRLocalScreen.openModalDialog(self, nil, Form::About) |
| 87 |
|
|
end |
| 88 |
|
|
|
| 89 |
|
|
def tree_selchanged(hitem, lparam) |
| 90 |
yuya |
1.3 |
@tree_selected_item = Model::Store.get(@tree.getItemLParamOf(hitem)) |
| 91 |
yuya |
1.1 |
if @tree_selected_item |
| 92 |
|
|
@lab1.caption = @tree_selected_item.name |
| 93 |
yuya |
1.3 |
@lab2.caption = (@tree_selected_item.kind_of?(Model::File) ? @tree_selected_item.filepath : '') |
| 94 |
yuya |
1.1 |
end |
| 95 |
|
|
end |
| 96 |
|
|
|
| 97 |
|
|
def tree_clicked |
| 98 |
|
|
end |
| 99 |
|
|
|
| 100 |
|
|
def tree_dblclicked |
| 101 |
yuya |
1.3 |
if @tree_selected_item && @tree_selected_item.kind_of?(Model::File) |
| 102 |
yuya |
1.1 |
editor(@tree_selected_item.filepath) |
| 103 |
|
|
end |
| 104 |
|
|
end |
| 105 |
|
|
|
| 106 |
|
|
def editor(filepath) |
| 107 |
|
|
system(EDITOR + ' "' + filepath + '" &') |
| 108 |
|
|
end |
| 109 |
|
|
|
| 110 |
|
|
end |
| 111 |
|
|
|
| 112 |
|
|
VRLocalScreen.showForm(MainForm) |
| 113 |
|
|
VRLocalScreen.messageloop |