luikore-cici 0.0.9 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +17 -8
- data/examples/Collective Intelligence.png +0 -0
- data/examples/button.rb +11 -0
- data/examples/calculator.rb +43 -0
- data/examples/cici.rb +1 -0
- data/examples/common_dialogs.rb +23 -0
- data/examples/destroy.rb +17 -0
- data/examples/flow.rb +23 -0
- data/examples/hello world.rb +7 -0
- data/examples/img.rb +11 -0
- data/examples/key.rb +9 -0
- data/examples/list.rb +19 -0
- data/examples/menu.rb +17 -0
- data/examples/mk +2 -0
- data/examples/mk.bat +2 -0
- data/examples/position.rb +15 -0
- data/examples/quantummi7.jpg +0 -0
- data/examples/regexp_test.rb +73 -0
- data/examples/scintilla.rb +27 -0
- data/examples/style.rb +33 -0
- data/examples/tab.rb +21 -0
- data/examples/timer.rb +64 -0
- data/lib/cici/Scintilla.dll +0 -0
- data/lib/cici/canvas.rb +64 -6
- data/lib/cici/countlines.rb +2 -4
- data/lib/cici/dlg.rb +24 -0
- data/lib/cici/element.rb +48 -0
- data/lib/cici/keymap.rb +23 -0
- data/lib/cici/list.rb +13 -0
- data/lib/cici/{misc.rb → menu.rb} +9 -1
- data/lib/cici/mingw32/ext.so +0 -0
- data/lib/cici/mswin32_90/ext.so +0 -0
- data/lib/cici/scintilla.rb +20 -9
- data/lib/cici.rb +9 -2
- metadata +31 -8
- data/lib/cici/SciLexer.dll +0 -0
- data/lib/cici/element_base.rb +0 -12
- data/lib/cici/ext.so +0 -0
- data/lib/cici/lexers/ruby +0 -64
- data/lib/cici/view.rb +0 -130
data/README.rdoc
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
=
|
1
|
+
= cici
|
2
2
|
|
3
3
|
Mini Ruby text-based traditional GUI lib for Windows. (project just started)
|
4
4
|
|
@@ -6,13 +6,22 @@ No other prepared libraries needed, that is -- No Qt, Gtk, Mfc ...
|
|
6
6
|
|
7
7
|
Light and small with nice efficiency.
|
8
8
|
|
9
|
-
==
|
9
|
+
== download
|
10
10
|
|
11
|
-
|
11
|
+
require:
|
12
|
+
Ruby-1.9.1-mswin32-90 || Ruby-1.9.1-mingw32
|
12
13
|
|
14
|
+
Either can be obtained at:
|
13
15
|
http://github.com/LuiKore/Cici/downloads
|
14
16
|
|
15
|
-
|
17
|
+
then: (mswin32-90 binary)
|
18
|
+
gem install luikore-cici
|
19
|
+
|
20
|
+
or build from source ~ ~
|
21
|
+
|
22
|
+
Currently the mingw32 version does not support images.
|
23
|
+
|
24
|
+
== example
|
16
25
|
|
17
26
|
require 'cici'
|
18
27
|
include Cici::View
|
@@ -22,13 +31,13 @@ http://github.com/LuiKore/Cici/downloads
|
|
22
31
|
|
23
32
|
Find more in examples folder.
|
24
33
|
|
25
|
-
==
|
34
|
+
== document
|
26
35
|
|
27
36
|
http://wiki.github.com/LuiKore/Cici
|
28
37
|
|
29
|
-
==
|
38
|
+
== license (MIT)
|
30
39
|
|
31
|
-
Copyright (c) 2009
|
40
|
+
Copyright (c) 2009 luikore
|
32
41
|
|
33
42
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
34
43
|
of this software and associated documentation files (the "Software"), to
|
@@ -47,7 +56,7 @@ THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
|
47
56
|
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
48
57
|
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
49
58
|
|
50
|
-
==
|
59
|
+
== my blog (中文)
|
51
60
|
|
52
61
|
http://night-stalker.javaeye.com
|
53
62
|
|
Binary file
|
data/examples/button.rb
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
require 'cici.rb'
|
2
|
+
include Cici::View
|
3
|
+
|
4
|
+
def calculate txt
|
5
|
+
(eval txt).to_s
|
6
|
+
rescue Exception => ex
|
7
|
+
ex.message
|
8
|
+
end
|
9
|
+
|
10
|
+
def calc_button x
|
11
|
+
b = button x
|
12
|
+
b.onclick = proc do |this|
|
13
|
+
@edt.text = @edt.text + x
|
14
|
+
@edt.focus
|
15
|
+
end
|
16
|
+
b
|
17
|
+
end
|
18
|
+
|
19
|
+
view [200, 200] do
|
20
|
+
paint [200, 90] do
|
21
|
+
(0..9).each do |i|
|
22
|
+
br if (i == 4 or i == 8)
|
23
|
+
num = i.to_s
|
24
|
+
calc_button num
|
25
|
+
end
|
26
|
+
button 'C' do
|
27
|
+
@edt.text = ''
|
28
|
+
end
|
29
|
+
end
|
30
|
+
br
|
31
|
+
paint [200, 30] do
|
32
|
+
%w[+ - * /].each do |op|
|
33
|
+
calc_button op
|
34
|
+
end
|
35
|
+
button('=').onclick = proc do |this|
|
36
|
+
@edt.text = calculate @edt.text
|
37
|
+
@edt.focus
|
38
|
+
end
|
39
|
+
end
|
40
|
+
br
|
41
|
+
@edt = edit [180, 20]
|
42
|
+
end
|
43
|
+
|
data/examples/cici.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require File.dirname(__FILE__) + "/../lib/cici.rb"
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'cici'
|
2
|
+
include Cici::View
|
3
|
+
|
4
|
+
view [200, 100] do
|
5
|
+
button 'choose file' do
|
6
|
+
f = choose_file 'all'=>'*.*', 'ruby'=>'*.rb'
|
7
|
+
alert(f || 'nil')
|
8
|
+
end
|
9
|
+
button 'save file' do
|
10
|
+
f = save_file 'all'=>'*.*', 'ruby'=>'*.rb'
|
11
|
+
alert(f || 'nil')
|
12
|
+
end
|
13
|
+
br
|
14
|
+
button 'choose font' do
|
15
|
+
f = choose_font
|
16
|
+
alert(f || 'nil')
|
17
|
+
end
|
18
|
+
button 'choose color' do
|
19
|
+
c = choose_color
|
20
|
+
alert(c || 'nil')
|
21
|
+
end
|
22
|
+
br
|
23
|
+
end
|
data/examples/destroy.rb
ADDED
data/examples/flow.rb
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'cici'
|
2
|
+
include Cici::View
|
3
|
+
|
4
|
+
view [300, 200], layout: :flow, title: 'flow layout' do |v|
|
5
|
+
v.flow_width = 200
|
6
|
+
[80, 100, 80, 300].each do |i|
|
7
|
+
e = edit [i, 20]
|
8
|
+
e
|
9
|
+
end
|
10
|
+
|
11
|
+
@change_flow_width = proc do
|
12
|
+
t = @e.text
|
13
|
+
if t.respond_to? :to_i
|
14
|
+
v.flow_width = t.to_i
|
15
|
+
else
|
16
|
+
alert 'flow width not valid'
|
17
|
+
end
|
18
|
+
end
|
19
|
+
button 'change flow width:', &@change_flow_width
|
20
|
+
@e = edit [80, 20]
|
21
|
+
@e.text = v.flow_width.toString
|
22
|
+
@e.onenter = @change_flow_width
|
23
|
+
end
|
data/examples/img.rb
ADDED
data/examples/key.rb
ADDED
data/examples/list.rb
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'cici'
|
2
|
+
include Cici::View
|
3
|
+
|
4
|
+
view [300,300] do |v|
|
5
|
+
v.marginx = 5
|
6
|
+
br 10
|
7
|
+
|
8
|
+
text 'listbox:'
|
9
|
+
br
|
10
|
+
@l = listbox [200, 130]
|
11
|
+
@l.onchange = proc{ |l| @d.cur_select = l.cur_select }
|
12
|
+
@l.items = (1..9).map{ |e| "listbox item #{e}"}
|
13
|
+
br 10
|
14
|
+
|
15
|
+
text 'droplist:'
|
16
|
+
br
|
17
|
+
@d = droplist
|
18
|
+
@d.items = (1..9).map{ |e| "combobox item #{e}"}
|
19
|
+
end
|
data/examples/menu.rb
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'cici.rb'
|
2
|
+
include Cici::View
|
3
|
+
|
4
|
+
@cost = proc{|money, this| alert "cost #{money}"}.curry
|
5
|
+
|
6
|
+
view [200, 100] do |v|
|
7
|
+
v.menu '&bread' => @cost[0.2],
|
8
|
+
'soup' => {
|
9
|
+
'salty' => @cost[0.1],
|
10
|
+
'line' => nil,
|
11
|
+
'sw&eety' => @cost[0.1]
|
12
|
+
}
|
13
|
+
|
14
|
+
@t = text 'r-click to popup menu'
|
15
|
+
@t.menu 'exit' => proc{ exit }
|
16
|
+
end
|
17
|
+
|
data/examples/mk
ADDED
data/examples/mk.bat
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'cici.rb'
|
2
|
+
include Cici::View
|
3
|
+
|
4
|
+
view [500,500] do |v|
|
5
|
+
b = button 'move(relative to parent)' do |this|
|
6
|
+
this.pos = [nil, 80]
|
7
|
+
puts this.pos
|
8
|
+
end
|
9
|
+
br
|
10
|
+
button 'move(absolute position)' do |this|
|
11
|
+
this.absolute_pos = [320, 320]
|
12
|
+
puts this.absolute_pos
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
Binary file
|
@@ -0,0 +1,73 @@
|
|
1
|
+
require 'cici.rb'
|
2
|
+
include Cici::View
|
3
|
+
|
4
|
+
Cici::Config << {
|
5
|
+
:default_font => Font['Courier New', 12, '', 0],
|
6
|
+
}
|
7
|
+
|
8
|
+
@check_reg = proc do
|
9
|
+
begin
|
10
|
+
re = Regexp.new @reg.text
|
11
|
+
match = (re =~ @txt.text)
|
12
|
+
@result.text = (match ? match.to_s : 'nil')
|
13
|
+
@globals.each_with_index do |g, i|
|
14
|
+
g.text = (eval "$#{i+1}") || 'nil'
|
15
|
+
end
|
16
|
+
rescue Exception => ex
|
17
|
+
@result.text = ex.message
|
18
|
+
@globals.each do |g|
|
19
|
+
g.text = 'nil'
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
view [890, 245], :title => 'Regular Expression Test' do |v|
|
25
|
+
v.bkcolor = RGB[0xaabbff]
|
26
|
+
v.marginx = 8
|
27
|
+
br 10
|
28
|
+
|
29
|
+
sz1 = [780, 20]
|
30
|
+
|
31
|
+
text 'regexp:/'
|
32
|
+
@reg = edit sz1
|
33
|
+
@reg.ontab = proc { @txt.focus; @check_reg[] }
|
34
|
+
text '/'
|
35
|
+
br
|
36
|
+
|
37
|
+
text 'string: '
|
38
|
+
@txt = edit sz1
|
39
|
+
@txt.ontab = proc { @reg.focus; @check_reg[] }
|
40
|
+
br
|
41
|
+
|
42
|
+
text 'result: '
|
43
|
+
@result = edit sz1
|
44
|
+
br 10
|
45
|
+
|
46
|
+
paint [780, 115] do
|
47
|
+
@globals = (1..9).map do |i|
|
48
|
+
text " $#{i}", Font['Monaco', 12]
|
49
|
+
e = edit [210, 20]
|
50
|
+
br if (i==3 or i==6)
|
51
|
+
e
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
paint [60, 115] do
|
56
|
+
sz = [60, 22]
|
57
|
+
button('match', sz).onclick = @check_reg
|
58
|
+
br 8
|
59
|
+
|
60
|
+
button('copy', sz).onclick = proc do
|
61
|
+
@reg.copy
|
62
|
+
alert "\"#{@reg.text}\" copied."
|
63
|
+
end
|
64
|
+
br 8
|
65
|
+
|
66
|
+
button('escape', sz).onclick = proc do
|
67
|
+
@reg.text = Regexp.escape @reg.text
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
@reg.focus
|
72
|
+
end
|
73
|
+
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# Coding: utf-8
|
2
|
+
require 'cici'
|
3
|
+
include Cici::View
|
4
|
+
|
5
|
+
SysMenu = {
|
6
|
+
'&File' => {
|
7
|
+
'&Open' => proc{ (fn = choose_file 'ruby file'=>'*.rb', 'all'=>'*.*') and (@s.text = File.read(fn).encode 'utf-8') },
|
8
|
+
'&Save' => proc{ puts 'ss'; (fn = save_file) and File.open(fn,'w'){ |f| f << @s.text } },
|
9
|
+
'E&xit' => proc{ exit },
|
10
|
+
}
|
11
|
+
}
|
12
|
+
|
13
|
+
cx = 800
|
14
|
+
cy = 600
|
15
|
+
view [cx, cy], title: 'Scintilla', layout: :zoom do |v|
|
16
|
+
v.menu SysMenu
|
17
|
+
@s = scintilla [cx - 8, cy - 46]
|
18
|
+
@s.style_set_default_font Font['Monaco',9]
|
19
|
+
@s.line_margin = 1 # show line number
|
20
|
+
@s.fold_margin = 2
|
21
|
+
@s.text = File.read(__FILE__).encode 'utf-8' # read in self
|
22
|
+
@s.indent = 2 # auto indent 2 chars when needed
|
23
|
+
@s.onstyle = proc do |sci, startp, endp|
|
24
|
+
puts startp, endp
|
25
|
+
sci.set_styling endp - startp, 1
|
26
|
+
end
|
27
|
+
end
|
data/examples/style.rb
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
require 'cici'
|
3
|
+
include Cici::View
|
4
|
+
|
5
|
+
view [400, 400] do |v|
|
6
|
+
v.bkcolor = RGB[0xffff66]
|
7
|
+
v.marginx = 5
|
8
|
+
|
9
|
+
text 'Arial', Font['Arial', 22 ,'si']
|
10
|
+
br
|
11
|
+
|
12
|
+
@t1 = text 'Courier New', Font['Courier New', 18, 'u']
|
13
|
+
@t1.color = RGB[18, 128, 0]
|
14
|
+
br
|
15
|
+
|
16
|
+
text 'AvQest', Font['AvQest', 33]
|
17
|
+
br
|
18
|
+
|
19
|
+
@t2 = text '黑体', Font['黑体', 22 ,'b', Cici::GB2312_CHARSET]
|
20
|
+
@t2.color = RGB[0xff3300]
|
21
|
+
br
|
22
|
+
|
23
|
+
b = button '宋体'
|
24
|
+
b.font_size = 15
|
25
|
+
b.size = [80, 20]
|
26
|
+
br
|
27
|
+
|
28
|
+
paint [250, 80] do |c|
|
29
|
+
c.bkcolor = RGB[0x99ccff]
|
30
|
+
c.border_stroke = Stroke[RGB[0x00cc00], dot:2]
|
31
|
+
c.border_radius = 5
|
32
|
+
end
|
33
|
+
end
|
data/examples/tab.rb
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'cici'
|
2
|
+
include Cici::View
|
3
|
+
|
4
|
+
view [200, 250] do
|
5
|
+
@t = paint [170, 170], :layout => :tab do
|
6
|
+
end
|
7
|
+
|
8
|
+
@t['one'] = paint [170, 170] do
|
9
|
+
button 'one inside'
|
10
|
+
end
|
11
|
+
|
12
|
+
@t['two'] = paint [170, 170] do
|
13
|
+
button 'two inside'
|
14
|
+
end
|
15
|
+
|
16
|
+
@t['three'] = paint [170, 170] do
|
17
|
+
button 'three inside'
|
18
|
+
end
|
19
|
+
|
20
|
+
@t.tab_index = 0
|
21
|
+
end
|
data/examples/timer.rb
ADDED
@@ -0,0 +1,64 @@
|
|
1
|
+
require 'cici.rb'
|
2
|
+
include Cici::View
|
3
|
+
|
4
|
+
module Second
|
5
|
+
attr_writer :carry_target
|
6
|
+
|
7
|
+
def incr
|
8
|
+
txt = self.text.succ
|
9
|
+
if txt == '60.0'
|
10
|
+
self.text = '0.0'
|
11
|
+
@carry_target.text = @carry_target.text.succ
|
12
|
+
else
|
13
|
+
self.text = txt
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
def stop
|
18
|
+
(self.kill_timer @tid) if @tid
|
19
|
+
end
|
20
|
+
|
21
|
+
def start
|
22
|
+
@tid = self.set_timer 95 do |ds|
|
23
|
+
ds.incr
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
# time text
|
29
|
+
def ttext txt
|
30
|
+
text txt, Font['Arial', 14]
|
31
|
+
end
|
32
|
+
|
33
|
+
view [230, 63], :title => 'Timer' do |box|
|
34
|
+
br
|
35
|
+
box.bkcolor = 0x88ffff
|
36
|
+
|
37
|
+
@min = ttext '0'
|
38
|
+
ttext 'min'
|
39
|
+
|
40
|
+
@sec = ttext '0.0'
|
41
|
+
@sec.__send__ :extend, Second
|
42
|
+
@sec.carry_target = @min
|
43
|
+
ttext 'sec'
|
44
|
+
|
45
|
+
@start = ->this {
|
46
|
+
@sec.start
|
47
|
+
this.text = 'pause'
|
48
|
+
this.onclick = @pause
|
49
|
+
}
|
50
|
+
|
51
|
+
@pause = ->this {
|
52
|
+
@sec.stop
|
53
|
+
this.text = 'start'
|
54
|
+
this.onclick = @start
|
55
|
+
}
|
56
|
+
|
57
|
+
@spbutton = button 'start', &@start # start button
|
58
|
+
|
59
|
+
button 'reset' do
|
60
|
+
@pause[@spbutton]
|
61
|
+
@sec.text = '0.0'
|
62
|
+
@min.text = '0'
|
63
|
+
end
|
64
|
+
end
|
Binary file
|
data/lib/cici/canvas.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
# Coding: utf-8
|
2
2
|
module Cici
|
3
3
|
class Canvas
|
4
|
+
|
4
5
|
# downing: the biggest bottom position of current elements
|
5
6
|
# padding: space between horizontal elements
|
6
7
|
attr_reader :padding, :downing, :turtlex, :turtley, :children
|
@@ -17,10 +18,19 @@ module Cici
|
|
17
18
|
end.join ','
|
18
19
|
end
|
19
20
|
|
21
|
+
def destroy
|
22
|
+
@children.each{ |c| c.destroy }
|
23
|
+
@children = nil
|
24
|
+
_destroy # call build in delete
|
25
|
+
end
|
26
|
+
|
27
|
+
|
20
28
|
# ----------------------------------------------------------------
|
21
29
|
# fixed layout
|
22
30
|
module Fixed
|
31
|
+
|
23
32
|
private
|
33
|
+
|
24
34
|
def onresize
|
25
35
|
end
|
26
36
|
|
@@ -37,17 +47,21 @@ module Cici
|
|
37
47
|
end
|
38
48
|
|
39
49
|
public
|
50
|
+
|
40
51
|
def br space = 5
|
41
52
|
@turtlex = @marginx
|
42
53
|
@turtley += (@downing + space)
|
43
54
|
@downing = 0
|
44
55
|
end
|
56
|
+
|
45
57
|
end
|
46
58
|
|
47
59
|
# ----------------------------------------------------------------
|
48
60
|
# flow layout
|
49
61
|
module Flow
|
62
|
+
|
50
63
|
private
|
64
|
+
|
51
65
|
def onresize
|
52
66
|
end
|
53
67
|
|
@@ -61,7 +75,7 @@ module Cici
|
|
61
75
|
to_append = @children.dup
|
62
76
|
@children = []
|
63
77
|
to_append.each do |c|
|
64
|
-
|
78
|
+
onappend c, *c.size
|
65
79
|
end
|
66
80
|
# self.invalidate_rect # FIXME doesn't work...
|
67
81
|
end
|
@@ -89,20 +103,23 @@ module Cici
|
|
89
103
|
end
|
90
104
|
|
91
105
|
public
|
106
|
+
|
92
107
|
def flow_width= fw
|
93
108
|
@flow_width = fw.to_i
|
94
|
-
|
109
|
+
onchildresize nil
|
95
110
|
fw
|
96
111
|
end
|
97
112
|
|
98
113
|
attr_reader :flow_width
|
114
|
+
|
99
115
|
end # module Flow
|
100
116
|
|
101
117
|
# ----------------------------------------------------------------
|
102
|
-
# zoom layout
|
118
|
+
# zoom layout FIXME when removing child ?
|
103
119
|
module Zoom
|
104
|
-
|
120
|
+
|
105
121
|
private
|
122
|
+
|
106
123
|
def onresize
|
107
124
|
if @percents
|
108
125
|
@turtlex = @marginx
|
@@ -114,7 +131,7 @@ module Cici
|
|
114
131
|
szx, szy = self.size
|
115
132
|
to_append.each_with_index do |c, i|
|
116
133
|
px, py = stored_percents[i]
|
117
|
-
|
134
|
+
onappend c, px*szx, py*szy
|
118
135
|
end
|
119
136
|
else
|
120
137
|
@percents = []
|
@@ -137,17 +154,21 @@ module Cici
|
|
137
154
|
end
|
138
155
|
|
139
156
|
public
|
157
|
+
|
140
158
|
def br space = 5
|
141
159
|
@turtlex = @marginx
|
142
160
|
@turtley += (@downing + space)
|
143
161
|
@downing = 0
|
144
|
-
end
|
162
|
+
end
|
163
|
+
|
145
164
|
end
|
146
165
|
|
147
166
|
# ----------------------------------------------------------------
|
148
167
|
# tab layout (or say, navigate / tabbook layout)
|
149
168
|
module Tab
|
169
|
+
|
150
170
|
private
|
171
|
+
|
151
172
|
def check_index idx
|
152
173
|
raise "index #{idx} out of range" if @pages.empty? or (not ((0...(@pages.size)).include? idx))
|
153
174
|
end
|
@@ -180,7 +201,9 @@ module Cici
|
|
180
201
|
end
|
181
202
|
|
182
203
|
public
|
204
|
+
|
183
205
|
attr_reader :tab_index, :pages, :labels
|
206
|
+
|
184
207
|
def tab_index= idx
|
185
208
|
check_index idx
|
186
209
|
if idx != @tab_index
|
@@ -201,7 +224,42 @@ module Cici
|
|
201
224
|
page.pos = [0, 22]
|
202
225
|
@tab_index = @pages.size - 1
|
203
226
|
end
|
227
|
+
|
204
228
|
end
|
205
229
|
|
206
230
|
end # class Canvas
|
207
231
|
end
|
232
|
+
|
233
|
+
module Cici
|
234
|
+
module View
|
235
|
+
|
236
|
+
# new canvas
|
237
|
+
def paint sz, opts = {}, &block
|
238
|
+
mod = {
|
239
|
+
flow: Canvas::Flow,
|
240
|
+
zoom: Canvas::Zoom,
|
241
|
+
tab: Canvas::Tab
|
242
|
+
}[opts[:layout]]
|
243
|
+
mod ||= Canvas::Fixed # default
|
244
|
+
Canvas.paint nil, sz[0], sz[1], mod, &block
|
245
|
+
end
|
246
|
+
|
247
|
+
# main
|
248
|
+
def view sz = nil, opts = {}, &block
|
249
|
+
Config[:external_font_paths].each do |p|
|
250
|
+
Cici.load_external_font p
|
251
|
+
end
|
252
|
+
raise 'Config[:default_font] should be a Font' unless Config[:default_font].is_a? Cici::FontClass
|
253
|
+
Cici.set_default_font Config[:default_font]
|
254
|
+
|
255
|
+
Cici.app (opts[:title] || 'Cici') do
|
256
|
+
paint sz, opts, &block
|
257
|
+
end
|
258
|
+
end
|
259
|
+
|
260
|
+
def br space = 5
|
261
|
+
Canvas.current.br space
|
262
|
+
end
|
263
|
+
|
264
|
+
end
|
265
|
+
end
|
data/lib/cici/countlines.rb
CHANGED
data/lib/cici/dlg.rb
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
module Cici
|
3
|
+
module View
|
4
|
+
def choose_file filter = nil
|
5
|
+
arg = "All (*.*)\0*.*\0"
|
6
|
+
if filter.is_a? Hash
|
7
|
+
arg = filter.map do |(k, v)|
|
8
|
+
"#{k} (#{v})\0#{v}\0"
|
9
|
+
end.join
|
10
|
+
end
|
11
|
+
Cici.choose_file "#{arg}\0"
|
12
|
+
end
|
13
|
+
|
14
|
+
def save_file filter = nil
|
15
|
+
arg = "All (*.*)\0*.*\0"
|
16
|
+
if filter.is_a? Hash
|
17
|
+
arg = filter.map do |(k, v)|
|
18
|
+
"#{k} (#{v})\0#{v}\0"
|
19
|
+
end.join
|
20
|
+
end
|
21
|
+
Cici.save_file "#{arg}\0"
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
data/lib/cici/element.rb
ADDED
@@ -0,0 +1,48 @@
|
|
1
|
+
# Coding: utf-8
|
2
|
+
module Cici
|
3
|
+
class ElementBase
|
4
|
+
def parent= p
|
5
|
+
@parent.children.delete self
|
6
|
+
self._parent = p
|
7
|
+
@parent = p
|
8
|
+
p.children << self
|
9
|
+
end
|
10
|
+
attr_reader :parent
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
module Cici
|
15
|
+
module View
|
16
|
+
def button txt, sz=nil, &block
|
17
|
+
b = Button.create nil, txt.toString, 0
|
18
|
+
b.onclick = block if block
|
19
|
+
b.size = sz if sz.is_a? Array
|
20
|
+
b
|
21
|
+
end
|
22
|
+
|
23
|
+
# BS_AUTOCHECKBOX
|
24
|
+
def checkbox &block
|
25
|
+
b = Button.create nil, '', 3
|
26
|
+
b.onclick = block if block
|
27
|
+
b
|
28
|
+
end
|
29
|
+
|
30
|
+
def text txt, font = nil
|
31
|
+
font = nil unless font.is_a? FontClass
|
32
|
+
Text.create nil, txt.toString, font
|
33
|
+
end
|
34
|
+
|
35
|
+
def image path, sz = nil
|
36
|
+
x, y = nil, nil
|
37
|
+
if sz.is_a? Array
|
38
|
+
x, y = *sz
|
39
|
+
end
|
40
|
+
Image.create nil, path, x, y
|
41
|
+
end
|
42
|
+
|
43
|
+
def edit sz = nil
|
44
|
+
sz = [200, 28] unless (sz.is_a? Array)
|
45
|
+
Edit.create nil, sz[0], sz[1], nil
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
data/lib/cici/keymap.rb
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
module Cici
|
3
|
+
module View
|
4
|
+
def keymap char, *mods, &block
|
5
|
+
modnum = 0
|
6
|
+
mods.each do |mod|
|
7
|
+
modnum |= 1 if mod == :shift
|
8
|
+
modnum |= 2 if mod == :ctrl
|
9
|
+
modnum |= 4 if mod == :alt
|
10
|
+
end
|
11
|
+
charnum = nil
|
12
|
+
if char.is_a? Fixnum
|
13
|
+
charnum = char.to_i
|
14
|
+
else
|
15
|
+
charnum = Cici::KEYMAP[char]
|
16
|
+
charnum ||= char.upcase.ord
|
17
|
+
end
|
18
|
+
raise 'char not valid' unless charnum
|
19
|
+
Cici.register_key charnum, modnum, block
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
data/lib/cici/list.rb
CHANGED
@@ -20,3 +20,16 @@ module Cici
|
|
20
20
|
include ListBase
|
21
21
|
end
|
22
22
|
end
|
23
|
+
|
24
|
+
module Cici
|
25
|
+
module View
|
26
|
+
def listbox sz
|
27
|
+
ListBox.create(nil, sz[0].to_i, sz[1].to_i)
|
28
|
+
end
|
29
|
+
|
30
|
+
def droplist sz = nil
|
31
|
+
sz = [200, 28] unless (sz.is_a? Array)
|
32
|
+
DropList.create(nil, sz[0].to_i, sz[1].to_i)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -6,7 +6,7 @@ module Cici
|
|
6
6
|
hash.each do |key, val| # key.toString called in C
|
7
7
|
sz = self.size
|
8
8
|
if val.is_a? Proc
|
9
|
-
self.
|
9
|
+
self.insert_item sz, key, val
|
10
10
|
elsif val.is_a? Hash
|
11
11
|
self.insert_menu sz, key, Menu.popup(@parent).build(val)
|
12
12
|
elsif val.nil?
|
@@ -31,3 +31,11 @@ module Cici
|
|
31
31
|
end
|
32
32
|
end
|
33
33
|
end
|
34
|
+
|
35
|
+
module Cici
|
36
|
+
module View
|
37
|
+
def popup_menu hash
|
38
|
+
Menu.popup(Canvas.current).build hash
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
Binary file
|
Binary file
|
data/lib/cici/scintilla.rb
CHANGED
@@ -1,21 +1,23 @@
|
|
1
1
|
module Cici
|
2
2
|
class Scintilla
|
3
|
-
def lexer= l
|
4
|
-
l.downcase!
|
5
|
-
self._lexer = l
|
6
|
-
eval File.read(File.dirname(__FILE__) + '\\lexers\\' + l)
|
7
|
-
l
|
8
|
-
end
|
9
|
-
alias lexer _lexer
|
10
3
|
|
11
4
|
# set all font to f
|
12
5
|
def font= f
|
13
|
-
|
6
|
+
style_set_default_font f
|
14
7
|
@font = f
|
15
8
|
end
|
9
|
+
|
16
10
|
attr_reader :font
|
17
11
|
|
18
|
-
|
12
|
+
# ------------------------------------------------------------------------------
|
13
|
+
# events
|
14
|
+
|
15
|
+
# event binding example
|
16
|
+
# @s.onchar = proc do |sci, lparam|
|
17
|
+
# scn = Cici::Scintilla.scn lparam
|
18
|
+
# puts scn.ch.chr 'utf-8'
|
19
|
+
# end
|
20
|
+
attr_accessor :onchar, :onstyle
|
19
21
|
|
20
22
|
# called when an indentation is needed
|
21
23
|
# lineno: current line number
|
@@ -41,5 +43,14 @@ module Cici
|
|
41
43
|
end
|
42
44
|
self.set_line_indent lineno, i
|
43
45
|
end
|
46
|
+
|
44
47
|
end # class Scintilla
|
45
48
|
end
|
49
|
+
|
50
|
+
module Cici
|
51
|
+
module View
|
52
|
+
def scintilla sz
|
53
|
+
Scintilla.create nil, sz[0], sz[1]
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
data/lib/cici.rb
CHANGED
@@ -1,7 +1,14 @@
|
|
1
1
|
libdir = File.dirname(__FILE__) + '/cici/'
|
2
|
-
|
2
|
+
|
3
|
+
if RUBY_PLATFORM =~ /mswin32_90/
|
4
|
+
require "#{libdir}mswin32_90/ext.so"
|
5
|
+
elsif RUBY_PLATFORM =~ /mingw32/
|
6
|
+
require "#{libdir}mingw32/ext.so"
|
7
|
+
end
|
8
|
+
|
9
|
+
%w[support.rb keymap.rb canvas.rb config.rb element.rb list.rb dlg.rb menu.rb].each do |e|
|
3
10
|
require "#{libdir}#{e}"
|
4
11
|
end
|
5
12
|
|
6
|
-
Cici.scintilla_init(libdir + '
|
13
|
+
Cici.scintilla_init(libdir + 'Scintilla.dll')
|
7
14
|
require "#{libdir}scintilla.rb"
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: luikore-cici
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- luikore
|
@@ -28,17 +28,40 @@ files:
|
|
28
28
|
- lib/cici/canvas.rb
|
29
29
|
- lib/cici/config.rb
|
30
30
|
- lib/cici/countlines.rb
|
31
|
-
- lib/cici/
|
32
|
-
- lib/cici/
|
33
|
-
- lib/cici/
|
34
|
-
- lib/cici/lexers/ruby
|
31
|
+
- lib/cici/dlg.rb
|
32
|
+
- lib/cici/element.rb
|
33
|
+
- lib/cici/keymap.rb
|
35
34
|
- lib/cici/list.rb
|
36
|
-
- lib/cici/
|
37
|
-
- lib/cici/
|
35
|
+
- lib/cici/menu.rb
|
36
|
+
- lib/cici/mingw32
|
37
|
+
- lib/cici/mingw32/ext.so
|
38
|
+
- lib/cici/mswin32_90
|
39
|
+
- lib/cici/mswin32_90/ext.so
|
40
|
+
- lib/cici/Scintilla.dll
|
38
41
|
- lib/cici/scintilla.rb
|
39
42
|
- lib/cici/support.rb
|
40
|
-
- lib/cici/view.rb
|
41
43
|
- lib/cici.rb
|
44
|
+
- examples/button.rb
|
45
|
+
- examples/calculator.rb
|
46
|
+
- examples/cici.rb
|
47
|
+
- examples/Collective Intelligence.png
|
48
|
+
- examples/common_dialogs.rb
|
49
|
+
- examples/destroy.rb
|
50
|
+
- examples/flow.rb
|
51
|
+
- examples/hello world.rb
|
52
|
+
- examples/img.rb
|
53
|
+
- examples/key.rb
|
54
|
+
- examples/list.rb
|
55
|
+
- examples/menu.rb
|
56
|
+
- examples/mk
|
57
|
+
- examples/mk.bat
|
58
|
+
- examples/position.rb
|
59
|
+
- examples/quantummi7.jpg
|
60
|
+
- examples/regexp_test.rb
|
61
|
+
- examples/scintilla.rb
|
62
|
+
- examples/style.rb
|
63
|
+
- examples/tab.rb
|
64
|
+
- examples/timer.rb
|
42
65
|
has_rdoc: false
|
43
66
|
homepage: http://wiki.github.com/luikore/cici
|
44
67
|
licenses:
|
data/lib/cici/SciLexer.dll
DELETED
Binary file
|
data/lib/cici/element_base.rb
DELETED
data/lib/cici/ext.so
DELETED
Binary file
|
data/lib/cici/lexers/ruby
DELETED
@@ -1,64 +0,0 @@
|
|
1
|
-
# normal keywords
|
2
|
-
set_keywords 0, "DATA __END__ __FILE__ __LINE__ alias and begin break case class def defined? do else elsif end ensure false for if in module next nil not or raise redo rescue retry return self super then true undef unless until when while yield"
|
3
|
-
|
4
|
-
# indent keywords
|
5
|
-
set_keywords 1, "def class module if unless begin do elsif else case while for when"
|
6
|
-
|
7
|
-
# unindent keywords
|
8
|
-
set_keywords 2, "end rescue ensure when"
|
9
|
-
|
10
|
-
# line number
|
11
|
-
style_set_color 33, nil, 0XC0C0C0
|
12
|
-
|
13
|
-
#brace highlight
|
14
|
-
style_set_color 34, 0X00009F, 0XFFFF80
|
15
|
-
|
16
|
-
#brace incomplete highlight
|
17
|
-
style_set_color 35, 0XFF0000, 0X000000
|
18
|
-
|
19
|
-
#control chars
|
20
|
-
style_set_color 36, 0X000000, nil
|
21
|
-
|
22
|
-
#indent guides
|
23
|
-
style_set_color 37, 0XC0C0C0, 0XFFFFFF
|
24
|
-
|
25
|
-
# from scite
|
26
|
-
{
|
27
|
-
0=>0X808080,
|
28
|
-
2=>0X007f00,
|
29
|
-
3=>0X004000,
|
30
|
-
4=>0X7f7f00,
|
31
|
-
5=>0X7f0000,
|
32
|
-
6=>0X7f007f,
|
33
|
-
7=>0X7f007f,
|
34
|
-
8=>0Xff0000,
|
35
|
-
9=>0X7f7f00,
|
36
|
-
12=>0X000000,
|
37
|
-
13=>0X800080,
|
38
|
-
14=>0X30a0c0,
|
39
|
-
15=>0Xa000a0,
|
40
|
-
16=>0X8000b0,
|
41
|
-
17=>0Xb00080,
|
42
|
-
18=>0X00ffff,
|
43
|
-
19=>0X000060,
|
44
|
-
20=>0X000000,
|
45
|
-
21=>0X7f007f,
|
46
|
-
22=>0X7f007f,
|
47
|
-
23=>0X7f007f,
|
48
|
-
24=>0X7f007f,
|
49
|
-
26=>0X00ffff,
|
50
|
-
27=>0X000000,
|
51
|
-
28=>0X000000,
|
52
|
-
34=>0Xff0000,
|
53
|
-
35=>0X0000ff
|
54
|
-
}.each do |n, c|
|
55
|
-
style_set_color n, c, nil
|
56
|
-
end
|
57
|
-
|
58
|
-
@indent_pattern = /^\s*
|
59
|
-
(?:def|class|if|elsif|else|case|while|for)\b.*
|
60
|
-
|
|
61
|
-
.*(?:\bdo|\{)(?:\s*\|[^\|]*?\|)?
|
62
|
-
\s*$/x
|
63
|
-
|
64
|
-
@unindent_pattern = %r"^\s*(?:end|\})\s*$"
|
data/lib/cici/view.rb
DELETED
@@ -1,130 +0,0 @@
|
|
1
|
-
# coding: utf-8
|
2
|
-
module Cici
|
3
|
-
module View
|
4
|
-
def choose_file filter = nil
|
5
|
-
arg = "All (*.*)\0*.*\0"
|
6
|
-
if filter.is_a? Hash
|
7
|
-
arg = filter.map do |(k, v)|
|
8
|
-
"#{k} (#{v})\0#{v}\0"
|
9
|
-
end.join
|
10
|
-
end
|
11
|
-
Cici.choose_file "#{arg}\0"
|
12
|
-
end
|
13
|
-
|
14
|
-
def save_file filter = nil
|
15
|
-
arg = "All (*.*)\0*.*\0"
|
16
|
-
if filter.is_a? Hash
|
17
|
-
arg = filter.map do |(k, v)|
|
18
|
-
"#{k} (#{v})\0#{v}\0"
|
19
|
-
end.join
|
20
|
-
end
|
21
|
-
Cici.save_file "#{arg}\0"
|
22
|
-
end
|
23
|
-
|
24
|
-
def popup_menu hash
|
25
|
-
Menu.popup(Canvas.current).build hash
|
26
|
-
end
|
27
|
-
|
28
|
-
def button txt, sz=nil, &block
|
29
|
-
b = Button.create nil, txt.toString, 0
|
30
|
-
b.onclick = block if block
|
31
|
-
b.size = sz if sz.is_a? Array
|
32
|
-
b
|
33
|
-
end
|
34
|
-
|
35
|
-
# BS_AUTOCHECKBOX
|
36
|
-
def checkbox &block
|
37
|
-
b = Button.create nil, '', 3
|
38
|
-
b.onclick = block if block
|
39
|
-
b
|
40
|
-
end
|
41
|
-
|
42
|
-
# BS_AUTORADIOBUTTON
|
43
|
-
=begin
|
44
|
-
def radio txt, sz=nil, &block
|
45
|
-
b = Button.create nil, txt.toString, 9
|
46
|
-
b.onclick = block if block
|
47
|
-
b.size = sz if sz.is_a? Array
|
48
|
-
b
|
49
|
-
end
|
50
|
-
=end
|
51
|
-
|
52
|
-
def text txt, font = nil
|
53
|
-
font = nil unless font.is_a? FontClass
|
54
|
-
Text.create nil, txt.toString, font
|
55
|
-
end
|
56
|
-
|
57
|
-
def image path, sz = nil
|
58
|
-
x, y = nil, nil
|
59
|
-
if sz.is_a? Array
|
60
|
-
x, y = *sz
|
61
|
-
end
|
62
|
-
Image.create nil, path, x, y
|
63
|
-
end
|
64
|
-
|
65
|
-
def edit sz = nil
|
66
|
-
sz = [200, 28] unless (sz.is_a? Array)
|
67
|
-
Edit.create nil, sz[0], sz[1], nil
|
68
|
-
end
|
69
|
-
|
70
|
-
def listbox sz
|
71
|
-
ListBox.create(nil, sz[0].to_i, sz[1].to_i)
|
72
|
-
end
|
73
|
-
|
74
|
-
def droplist sz = nil
|
75
|
-
sz = [200, 28] unless (sz.is_a? Array)
|
76
|
-
DropList.create(nil, sz[0].to_i, sz[1].to_i)
|
77
|
-
end
|
78
|
-
|
79
|
-
# new canvas
|
80
|
-
def paint sz, opts = {}, &block
|
81
|
-
mod = {
|
82
|
-
flow: Canvas::Flow,
|
83
|
-
zoom: Canvas::Zoom,
|
84
|
-
tab: Canvas::Tab
|
85
|
-
}[opts[:layout]]
|
86
|
-
mod ||= Canvas::Fixed # default
|
87
|
-
Canvas.paint nil, sz[0], sz[1], mod, &block
|
88
|
-
end
|
89
|
-
|
90
|
-
def scintilla sz
|
91
|
-
Scintilla.create nil, sz[0], sz[1]
|
92
|
-
end
|
93
|
-
|
94
|
-
# main
|
95
|
-
def view sz = nil, opts = {}, &block
|
96
|
-
Config[:external_font_paths].each do |p|
|
97
|
-
Cici.load_external_font p
|
98
|
-
end
|
99
|
-
raise 'Config[:default_font] should be a Font' unless Config[:default_font].is_a? Cici::FontClass
|
100
|
-
Cici.set_default_font Config[:default_font]
|
101
|
-
|
102
|
-
Cici.app (opts[:title] || 'Cici') do
|
103
|
-
paint sz, opts, &block
|
104
|
-
end
|
105
|
-
end
|
106
|
-
|
107
|
-
def br space = 5
|
108
|
-
Canvas.current.br space
|
109
|
-
end
|
110
|
-
|
111
|
-
def keymap char, *mods, &block
|
112
|
-
modnum = 0
|
113
|
-
mods.each do |mod|
|
114
|
-
modnum |= 1 if mod == :shift
|
115
|
-
modnum |= 2 if mod == :ctrl
|
116
|
-
modnum |= 4 if mod == :alt
|
117
|
-
end
|
118
|
-
charnum = nil
|
119
|
-
if char.is_a? Fixnum
|
120
|
-
charnum = char.to_i
|
121
|
-
else
|
122
|
-
charnum = Cici::KEYMAP[char]
|
123
|
-
charnum ||= char.upcase.ord
|
124
|
-
end
|
125
|
-
raise 'char not valid' unless charnum
|
126
|
-
Cici.register_key charnum, modnum, block
|
127
|
-
end
|
128
|
-
|
129
|
-
end
|
130
|
-
end
|