luikore-cici 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +10 -3
- data/examples/common_dialogs.rb +21 -20
- data/examples/destroy.rb +10 -11
- data/examples/flow.rb +9 -7
- data/examples/hello world.rb +8 -4
- data/examples/img.rb +9 -8
- data/examples/key.rb +7 -7
- data/examples/list.rb +15 -16
- data/examples/menu.rb +15 -10
- data/examples/position.rb +16 -13
- data/examples/regexp_test.rb +42 -46
- data/examples/scintilla.rb +4 -28
- data/examples/style.rb +24 -24
- data/examples/timer.rb +31 -28
- data/lib/cici.rb +33 -8
- data/lib/cici/canvas.rb +159 -191
- data/lib/cici/config.rb +7 -12
- data/lib/cici/dlg.rb +16 -16
- data/lib/cici/element.rb +2 -36
- data/lib/cici/keymap.rb +42 -18
- data/lib/cici/list.rb +1 -13
- data/lib/cici/mingw32/ext.so +0 -0
- data/lib/cici/mswin32_90/ext.so +0 -0
- data/lib/cici/scintilla.rb +1 -25
- data/lib/cici/support.rb +1 -8
- metadata +1 -5
- data/examples/button.rb +0 -11
- data/examples/calculator.rb +0 -43
- data/examples/tab.rb +0 -21
- data/lib/cici/menu.rb +0 -41
data/README.rdoc
CHANGED
@@ -6,6 +6,8 @@ No other prepared libraries needed, that is -- No Qt, Gtk, Mfc ...
|
|
6
6
|
|
7
7
|
Light and small with nice efficiency.
|
8
8
|
|
9
|
+
API still in change.
|
10
|
+
|
9
11
|
== install
|
10
12
|
|
11
13
|
Require ruby 1.9.1, either ruby-1.9.1-mswin32_90 or ruby-1.9.1-mingw32 is OK.
|
@@ -24,11 +26,16 @@ Currently the mingw32 version does not support images.
|
|
24
26
|
== example
|
25
27
|
|
26
28
|
require 'cici'
|
27
|
-
|
28
|
-
|
29
|
-
|
29
|
+
app = Cici.app 'hello world'
|
30
|
+
|
31
|
+
app.paint [100, 30] do |v|
|
32
|
+
v.button 'hello' do
|
33
|
+
app.alert 'world'
|
34
|
+
end
|
30
35
|
end
|
31
36
|
|
37
|
+
app.message_loop
|
38
|
+
|
32
39
|
Find more in examples folder.
|
33
40
|
|
34
41
|
== document
|
data/examples/common_dialogs.rb
CHANGED
@@ -1,23 +1,24 @@
|
|
1
1
|
require 'cici'
|
2
|
-
|
2
|
+
app = Cici.app 'common dialogs'
|
3
|
+
c = app.paint [200, 100]
|
3
4
|
|
4
|
-
|
5
|
-
|
6
|
-
|
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
|
5
|
+
c.button 'choose file' do
|
6
|
+
f = app.choose_file 'all'=>'*.*', 'ruby'=>'*.rb'
|
7
|
+
app.alert(f || 'nil')
|
23
8
|
end
|
9
|
+
c.button 'save file' do
|
10
|
+
f = app.save_file 'all'=>'*.*', 'ruby'=>'*.rb'
|
11
|
+
app.alert(f || 'nil')
|
12
|
+
end
|
13
|
+
c.br
|
14
|
+
c.button 'choose font' do
|
15
|
+
f = app.choose_font
|
16
|
+
app.alert(f || 'nil')
|
17
|
+
end
|
18
|
+
c.button 'choose color' do
|
19
|
+
co = app.choose_color
|
20
|
+
app.alert(co || 'nil')
|
21
|
+
end
|
22
|
+
c.br
|
23
|
+
app.message_loop
|
24
|
+
|
data/examples/destroy.rb
CHANGED
@@ -1,17 +1,16 @@
|
|
1
1
|
require 'cici.rb'
|
2
|
-
include Cici::View
|
3
2
|
|
4
|
-
|
5
|
-
@p = paint [40, 30] do |p|
|
6
|
-
p.bkcolor = RGB[100,100,100]
|
3
|
+
app = Cici.app 'click a button to destroy a child window'
|
7
4
|
|
8
|
-
|
9
|
-
end
|
10
|
-
end
|
5
|
+
v = app.paint [300, 300]
|
11
6
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
7
|
+
p = v.paint [40, 30]
|
8
|
+
p.bkcolor = RGB[100,100,100]
|
9
|
+
p.paint [10, 10]
|
10
|
+
|
11
|
+
@b = v.button 'destroy' do
|
12
|
+
p.destroy
|
13
|
+
@b.onclick = nil
|
16
14
|
end
|
17
15
|
|
16
|
+
app.message_loop
|
data/examples/flow.rb
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
require 'cici'
|
2
|
-
|
2
|
+
app = Cici.app 'flow layout'
|
3
3
|
|
4
|
-
|
4
|
+
app.paint [300, 200], Cici::FlowLayout do |v|
|
5
5
|
v.flow_width = 200
|
6
|
-
[80, 100, 80, 300].each do |i|
|
7
|
-
e = edit [i, 20]
|
6
|
+
[80, 50, 25, 100, 20, 20, 80, 30, 300].each do |i|
|
7
|
+
e = v.edit [i, 20]
|
8
8
|
e
|
9
9
|
end
|
10
10
|
|
@@ -13,11 +13,13 @@ view [300, 200], layout: :flow, title: 'flow layout' do |v|
|
|
13
13
|
if t.respond_to? :to_i
|
14
14
|
v.flow_width = t.to_i
|
15
15
|
else
|
16
|
-
alert 'flow width not valid'
|
16
|
+
app.alert 'flow width not valid'
|
17
17
|
end
|
18
18
|
end
|
19
|
-
button 'change flow width:', &@change_flow_width
|
20
|
-
@e = edit [80, 20]
|
19
|
+
v.button 'change flow width:', &@change_flow_width
|
20
|
+
@e = v.edit [80, 20]
|
21
21
|
@e.text = v.flow_width.toString
|
22
22
|
@e.onenter = @change_flow_width
|
23
23
|
end
|
24
|
+
|
25
|
+
app.message_loop
|
data/examples/hello world.rb
CHANGED
data/examples/img.rb
CHANGED
@@ -1,11 +1,12 @@
|
|
1
1
|
require 'cici.rb'
|
2
|
-
include Cici::View
|
3
2
|
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
3
|
+
app = Cici.app 'image'
|
4
|
+
box = app.paint [600, 400]
|
5
|
+
|
6
|
+
box.image 'collective intelligence.png'
|
7
|
+
@neko = box.image 'quantummi7.jpg', [50, 100]
|
8
|
+
box.br
|
9
|
+
box.button 'make full size of neko shojo' do
|
10
|
+
@neko.size = nil
|
11
11
|
end
|
12
|
+
app.message_loop
|
data/examples/key.rb
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
require 'cici'
|
2
|
-
|
2
|
+
app = Cici.app 'key'
|
3
|
+
c = app.paint [100, 100]
|
4
|
+
|
5
|
+
c.text 'press ctrl+A'
|
6
|
+
|
7
|
+
app.keymap('A', :ctrl) { app.alert 'hi' }
|
8
|
+
app.message_loop
|
3
9
|
|
4
|
-
view [100, 100] do
|
5
|
-
text 'press ctrl+A'
|
6
|
-
keymap 'A', :ctrl do
|
7
|
-
alert 'hi'
|
8
|
-
end
|
9
|
-
end
|
data/examples/list.rb
CHANGED
@@ -1,19 +1,18 @@
|
|
1
1
|
require 'cici'
|
2
|
-
|
2
|
+
app = Cici.app 'list demo'
|
3
|
+
v = app.paint [300, 300]
|
4
|
+
v.marginx = 5
|
5
|
+
v.br 10
|
3
6
|
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
+
v.text 'listbox:'
|
8
|
+
v.br
|
9
|
+
@l = v.listbox [200, 130]
|
10
|
+
@l.onchange = proc{ |l| @d.cur_select = l.cur_select }
|
11
|
+
@l.items = (1..9).map{ |e| "listbox item #{e}"}
|
12
|
+
v.br 10
|
7
13
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
br 10
|
14
|
-
|
15
|
-
text 'droplist:'
|
16
|
-
br
|
17
|
-
@d = droplist
|
18
|
-
@d.items = (1..9).map{ |e| "combobox item #{e}"}
|
19
|
-
end
|
14
|
+
v.text 'droplist:'
|
15
|
+
v.br
|
16
|
+
@d = v.droplist
|
17
|
+
@d.items = (1..9).map{ |e| "combobox item #{e}"}
|
18
|
+
app.message_loop
|
data/examples/menu.rb
CHANGED
@@ -1,17 +1,22 @@
|
|
1
1
|
require 'cici.rb'
|
2
|
-
include Cici::View
|
3
2
|
|
4
|
-
|
3
|
+
app = Cici.app 'menu'
|
4
|
+
@cost = proc{|money, this| app.alert "cost #{money}"}.curry
|
5
5
|
|
6
|
-
|
7
|
-
v.
|
8
|
-
'
|
9
|
-
|
10
|
-
'
|
11
|
-
|
6
|
+
app.paint [200, 100] do |v|
|
7
|
+
v.menubar {|m|
|
8
|
+
m.item '&bread', &@cost[0.2]
|
9
|
+
m.menu('soup') {|m|
|
10
|
+
m.item 'salty', &@cost[0.1]
|
11
|
+
m.line
|
12
|
+
m.item 'sw&eety', &@cost[0.1]
|
12
13
|
}
|
14
|
+
}
|
13
15
|
|
14
|
-
@t = text 'r-click to popup menu'
|
15
|
-
@t.
|
16
|
+
@t = v.text 'r-click to popup menu'
|
17
|
+
@t.popupmenu {|m|
|
18
|
+
m.item('exit'){ exit }
|
19
|
+
}
|
16
20
|
end
|
17
21
|
|
22
|
+
app.message_loop
|
data/examples/position.rb
CHANGED
@@ -1,15 +1,18 @@
|
|
1
|
-
require 'cici
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
end
|
9
|
-
br
|
10
|
-
button 'move(absolute position)' do |this|
|
11
|
-
this.absolute_pos = [320, 320]
|
12
|
-
puts this.absolute_pos
|
13
|
-
end
|
1
|
+
require 'cici'
|
2
|
+
app = Cici.app 'positioning'
|
3
|
+
c = app.paint [500, 500]
|
4
|
+
|
5
|
+
b = c.button 'move(relative to parent)' do |this|
|
6
|
+
this.pos = [nil, 80]
|
7
|
+
puts this.pos
|
14
8
|
end
|
15
9
|
|
10
|
+
c.br
|
11
|
+
|
12
|
+
c.button 'move(absolute position)' do |this|
|
13
|
+
this.absolute_pos = [320, 320]
|
14
|
+
puts this.absolute_pos
|
15
|
+
end
|
16
|
+
|
17
|
+
app.message_loop
|
18
|
+
|
data/examples/regexp_test.rb
CHANGED
@@ -1,9 +1,6 @@
|
|
1
1
|
require 'cici.rb'
|
2
|
-
include Cici::View
|
3
2
|
|
4
|
-
Cici::Config
|
5
|
-
:default_font => Font['Courier New', 12, '', 0],
|
6
|
-
}
|
3
|
+
Cici::Config[:default_font] = Font['Courier New', 12, '', 0]
|
7
4
|
|
8
5
|
@check_reg = proc do
|
9
6
|
begin
|
@@ -21,53 +18,52 @@ Cici::Config << {
|
|
21
18
|
end
|
22
19
|
end
|
23
20
|
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
21
|
+
app = Cici.app 'Regular Expression Test'
|
22
|
+
v = app.paint [890, 245]
|
23
|
+
v.bkcolor = RGB[0xaabbff]
|
24
|
+
v.marginx = 8
|
25
|
+
v.br 10
|
28
26
|
|
29
|
-
|
27
|
+
sz1 = [780, 20]
|
30
28
|
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
29
|
+
v.text 'regexp:/'
|
30
|
+
@reg = v.edit sz1
|
31
|
+
@reg.ontab = proc { @txt.focus; @check_reg[] }
|
32
|
+
v.text '/'
|
33
|
+
v.br
|
36
34
|
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
35
|
+
v.text 'string: '
|
36
|
+
@txt = v.edit sz1
|
37
|
+
@txt.ontab = proc { @reg.focus; @check_reg[] }
|
38
|
+
v.br
|
41
39
|
|
42
|
-
|
43
|
-
|
44
|
-
|
40
|
+
v.text 'result: '
|
41
|
+
@result = v.edit sz1
|
42
|
+
v.br 10
|
45
43
|
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
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
|
44
|
+
# match groups
|
45
|
+
gs = v.paint [780, 115]
|
46
|
+
@globals = (1..9).map do |i|
|
47
|
+
gs.text " $#{i}", Font['Monaco', 12]
|
48
|
+
e = gs.edit [210, 20]
|
49
|
+
gs.br if (i==3 or i==6)
|
50
|
+
e
|
51
|
+
end
|
70
52
|
|
71
|
-
|
53
|
+
# control buttons
|
54
|
+
gs = v.paint [60, 115]
|
55
|
+
sz = [60, 22]
|
56
|
+
gs.button('match', sz).onclick = @check_reg
|
57
|
+
gs.br 8
|
58
|
+
gs.button 'copy', sz do
|
59
|
+
@reg.copy
|
60
|
+
app.alert "\"#{@reg.text}\" copied."
|
72
61
|
end
|
62
|
+
gs.br 8
|
63
|
+
gs.button 'escape', sz do
|
64
|
+
@reg.text = Regexp.escape @reg.text
|
65
|
+
end
|
66
|
+
|
67
|
+
@reg.focus
|
68
|
+
app.message_loop
|
73
69
|
|
data/examples/scintilla.rb
CHANGED
@@ -1,29 +1,5 @@
|
|
1
|
-
# Coding: utf-8
|
2
1
|
require 'cici'
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
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
|
-
sci.set_styling endp - startp, 1
|
25
|
-
end
|
26
|
-
@s.oncharadded = proc do |sci, c|
|
27
|
-
puts c
|
28
|
-
end
|
29
|
-
end
|
2
|
+
app = Cici.app 'scintilla'
|
3
|
+
c = app.paint [600, 600], Cici::ZoomLayout
|
4
|
+
c.scintilla [500, 500]
|
5
|
+
app.message_loop
|
data/examples/style.rb
CHANGED
@@ -1,33 +1,33 @@
|
|
1
1
|
# coding: utf-8
|
2
2
|
require 'cici'
|
3
|
-
include Cici::View
|
4
3
|
|
5
|
-
|
6
|
-
|
7
|
-
|
4
|
+
app = Cici.app 'style demo'
|
5
|
+
v = app.paint [400, 400]
|
6
|
+
v.bkcolor = RGB[0xffff66]
|
7
|
+
v.marginx = 5
|
8
8
|
|
9
|
-
|
10
|
-
|
9
|
+
v.text 'Arial', Font['Arial', 22 ,'si']
|
10
|
+
v.br
|
11
11
|
|
12
|
-
|
13
|
-
|
14
|
-
|
12
|
+
@t1 = v.text 'Courier New', Font['Courier New', 18, 'u']
|
13
|
+
@t1.color = RGB[18, 128, 0]
|
14
|
+
v.br
|
15
15
|
|
16
|
-
|
17
|
-
|
16
|
+
v.text 'AvQest', Font['AvQest', 33]
|
17
|
+
v.br
|
18
18
|
|
19
|
-
|
20
|
-
|
21
|
-
|
19
|
+
@t2 = v.text '黑体', Font['黑体', 22 ,'b', Cici::GB2312_CHARSET]
|
20
|
+
@t2.color = RGB[0xff3300]
|
21
|
+
v.br
|
22
22
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
23
|
+
b = v.button '宋体'
|
24
|
+
b.font_size = 15
|
25
|
+
b.size = [80, 20]
|
26
|
+
v.br
|
27
27
|
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
28
|
+
c = v.paint [250, 80]
|
29
|
+
c.bkcolor = RGB[0x99ccff]
|
30
|
+
c.border_stroke = Stroke[RGB[0x00cc00], dot:2]
|
31
|
+
c.border_radius = 5
|
32
|
+
|
33
|
+
app.message_loop
|