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/lib/cici/config.rb CHANGED
@@ -1,6 +1,5 @@
1
1
  # coding: utf-8
2
- module Cici
3
- Config = Object.new
2
+ class Cici
4
3
 
5
4
  ANSI_CHARSET = 0
6
5
  DEFAULT_CHARSET = 1
@@ -11,16 +10,7 @@ module Cici
11
10
  GB2312_CHARSET = 134
12
11
  CHINESEBIG5_CHARSET = 136
13
12
 
14
- KEYMAP = {'LEFT'=>37,'UP'=>38,'RIGHT'=>39,'DOWN'=>40,
15
- 'PAGE UP'=>33,'PAGE DOWN'=>34,'END'=>35,'HOME'=>36,
16
- '`'=>192,'-'=>189,'='=>187,'BACKSPACE'=>8,
17
- '['=>219,']'=>221,'\\'=>220,
18
- ';'=>186,'\''=>222,'ENTER'=>13,
19
- ','=>188,'.'=>190,'/'=>191,
20
- 'F1'=>112,'F2'=>113,'F3'=>114,'F4'=>115,'F5'=>116,'F6'=>117,'F7'=>118,'F8'=>119,'F9'=>120,'F10'=>121,
21
- 'PRINT SCREEN'=>44,'PAUSE'=>19,'INSERT'=>45,'DELETE'=>46
22
- }
23
-
13
+ Config = Object.new
24
14
  class << Config
25
15
  @@config = {
26
16
  :default_font => Font['宋体', 12, '', GB2312_CHARSET],
@@ -40,5 +30,10 @@ module Cici
40
30
  def [] k
41
31
  @@config[k]
42
32
  end
33
+
34
+ def []= k, v
35
+ @@config[k] = v
36
+ end
43
37
  end
38
+
44
39
  end
data/lib/cici/dlg.rb CHANGED
@@ -1,24 +1,24 @@
1
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)|
2
+ class Cici
3
+ def choose_file filter = nil
4
+ arg = "All (*.*)\0*.*\0"
5
+ if filter.is_a? Hash
6
+ arg = filter.map do |(k, v)|
8
7
  "#{k} (#{v})\0#{v}\0"
9
- end.join
10
- end
11
- Cici.choose_file "#{arg}\0"
8
+ end.join
12
9
  end
10
+ _choose_file "#{arg}\0"
11
+ end
13
12
 
14
- def save_file filter = nil
15
- arg = "All (*.*)\0*.*\0"
16
- if filter.is_a? Hash
17
- arg = filter.map do |(k, v)|
13
+ def save_file filter = nil
14
+ arg = "All (*.*)\0*.*\0"
15
+ if filter.is_a? Hash
16
+ arg = filter.map do |(k, v)|
18
17
  "#{k} (#{v})\0#{v}\0"
19
- end.join
20
- end
21
- Cici.save_file "#{arg}\0"
18
+ end.join
22
19
  end
20
+ _save_file "#{arg}\0"
23
21
  end
22
+
23
+ private :_choose_file, :_save_file
24
24
  end
data/lib/cici/element.rb CHANGED
@@ -1,8 +1,9 @@
1
1
  # Coding: utf-8
2
- module Cici
2
+ class Cici
3
3
  class ElementBase
4
4
  def parent= p
5
5
  @parent.children.delete self
6
+ # TODO deal with pool allocation issues
6
7
  self._parent = p
7
8
  @parent = p
8
9
  p.children << self
@@ -11,38 +12,3 @@ module Cici
11
12
  end
12
13
  end
13
14
 
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 CHANGED
@@ -1,23 +1,47 @@
1
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
2
+ class Cici
3
+
4
+ KEYMAP = {
5
+ 'LEFT'=>37,'UP'=>38,'RIGHT'=>39,'DOWN'=>40,
6
+
7
+ 'PAGE UP'=>33,'PAGE DOWN'=>34,'END'=>35,'HOME'=>36,
8
+ 'PAGEUP'=>33,'PAGEDOWN'=>34,'PGUP'=>33,'PGDN'=>34, # fuzzy alias
9
+
10
+ 'F1'=>112,'F2'=>113,'F3'=>114,'F4'=>115,'F5'=>116,'F6'=>117,'F7'=>118,'F8'=>119,'F9'=>120,'F10'=>121,
11
+
12
+ 'PRINT SCREEN'=>44,'PAUSE'=>19,'INSERT'=>45,'DELETE'=>46,
13
+ 'PRTSC'=>44,'PRINTSCR'=>44,'INS'=>45,'DEL'=>46, # fuzzy alias
14
+
15
+ '`'=>192,'-'=>189,'='=>187,'BACKSPACE'=>8,'BS'=>8,
16
+ '['=>219,']'=>221,'\\'=>220,
17
+ ';'=>186,'\''=>222,'ENTER'=>13,'RETURN'=>13,
18
+ ','=>188,'.'=>190,'/'=>191,
19
+
20
+ 'CAPS LOCK'=>20,'CAPSLOCK'=>20,'TAB'=>9,
21
+ 'WIN'=>91,'WINDOWS'=>91,'CONTEXTMENU'=>93,
22
+ }
23
+
24
+ def keymap char, *mods, &block
25
+ modnum = 0
26
+ mods.each do |mod|
27
+ modnum |= 1 if mod == :shift
28
+ modnum |= 2 if mod == :ctrl
29
+ modnum |= 4 if mod == :alt
30
+ end
31
+ charnum = nil
32
+ if char.is_a? Fixnum
33
+ charnum = char.to_i
34
+ else
35
+ charnum = KEYMAP[char]
36
+ charnum ||= char.upcase.ord
20
37
  end
38
+ raise 'char not valid' unless charnum
39
+ register_key charnum, modnum, block
21
40
  end
41
+
42
+ def ctrl_key char, block
43
+ keymap char, :ctrl, &block
44
+ end
45
+
22
46
  end
23
47
 
data/lib/cici/list.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # Coding: utf-8
2
- module Cici
2
+ class Cici
3
3
  module ListBase
4
4
  def items= args
5
5
  args.each do |e|
@@ -21,15 +21,3 @@ module Cici
21
21
  end
22
22
  end
23
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
Binary file
Binary file
@@ -1,23 +1,6 @@
1
- module Cici
1
+ class Cici
2
2
  class Scintilla
3
3
 
4
- # set all font to f
5
- def font= f
6
- style_set_default_font f
7
- @font = f
8
- end
9
- attr_reader :font
10
-
11
- # ------------------------------------------------------------------------------
12
- # events
13
-
14
- # event binding example
15
- # @s.onchar = proc do |sci, lparam|
16
- # scn = Cici::Scintilla.scn lparam
17
- # puts scn.ch.chr 'utf-8'
18
- # end
19
- attr_accessor :onstyle
20
-
21
4
  # called when an indentation is needed
22
5
  # lineno: current line number
23
6
  def onindentneeded lineno
@@ -46,10 +29,3 @@ module Cici
46
29
  end # class Scintilla
47
30
  end
48
31
 
49
- module Cici
50
- module View
51
- def scintilla sz
52
- Scintilla.create nil, sz[0], sz[1]
53
- end
54
- end
55
- end
data/lib/cici/support.rb CHANGED
@@ -11,13 +11,6 @@ class String
11
11
  end
12
12
  end
13
13
 
14
- # TODO not used yet
15
- class Fixnum
16
- def percent
17
- @percent = true
18
- end
19
- end
20
-
21
14
  Size = Object.new
22
15
  def Size.[] x, y
23
16
  [x, y]
@@ -52,7 +45,7 @@ def Font.[] face, sz, style = '', charset = 0
52
45
  else
53
46
  @mem[[face, sz, style, charset]] =
54
47
  Cici::FontClass.create face.toString,
55
- sz, (style ? style.downcase : ''), charset
48
+ sz, (style ? style.downcase : ''), charset
56
49
  end
57
50
  end
58
51
 
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.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - luikore
@@ -32,7 +32,6 @@ files:
32
32
  - lib/cici/element.rb
33
33
  - lib/cici/keymap.rb
34
34
  - lib/cici/list.rb
35
- - lib/cici/menu.rb
36
35
  - lib/cici/mingw32
37
36
  - lib/cici/mingw32/ext.so
38
37
  - lib/cici/mswin32_90
@@ -41,8 +40,6 @@ files:
41
40
  - lib/cici/scintilla.rb
42
41
  - lib/cici/support.rb
43
42
  - lib/cici.rb
44
- - examples/button.rb
45
- - examples/calculator.rb
46
43
  - examples/cici.rb
47
44
  - examples/Collective Intelligence.png
48
45
  - examples/common_dialogs.rb
@@ -60,7 +57,6 @@ files:
60
57
  - examples/regexp_test.rb
61
58
  - examples/scintilla.rb
62
59
  - examples/style.rb
63
- - examples/tab.rb
64
60
  - examples/timer.rb
65
61
  has_rdoc: false
66
62
  homepage: http://wiki.github.com/luikore/cici
data/examples/button.rb DELETED
@@ -1,11 +0,0 @@
1
- require 'cici.rb'
2
- include Cici::View
3
-
4
- view [300, 80] do
5
- @cb = checkbox
6
- text 'checkbox'
7
-
8
- button 'see if checked' do
9
- alert "checked = #{@cb.checked ? 'true' : 'false'}"
10
- end
11
- end
@@ -1,43 +0,0 @@
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/tab.rb DELETED
@@ -1,21 +0,0 @@
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/lib/cici/menu.rb DELETED
@@ -1,41 +0,0 @@
1
- # Coding: utf-8
2
- module Cici
3
- # the menu part
4
- class Menu
5
- def build hash
6
- hash.each do |key, val| # key.toString called in C
7
- sz = self.size
8
- if val.is_a? Proc
9
- self.insert_item sz, key, val
10
- elsif val.is_a? Hash
11
- self.insert_menu sz, key, Menu.popup(@parent).build(val)
12
- elsif val.nil?
13
- self.insert_line sz
14
- else
15
- raise 'Menu item processor should be a proc or hash or nil(separate line)'
16
- end
17
- end
18
- return self
19
- end
20
- end
21
-
22
- class Canvas
23
- def menu hash
24
- Menu.sys(self).build(hash).draw
25
- end
26
- end
27
-
28
- class ElementBase
29
- def menu hash
30
- self.menu = Menu.popup(@parent).build hash
31
- end
32
- end
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