htmlgrid 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (83) hide show
  1. data/History.txt +6 -0
  2. data/LICENCE.txt +515 -0
  3. data/Manifest.txt +82 -0
  4. data/README.txt +30 -0
  5. data/Rakefile +28 -0
  6. data/ext/htmlgrid/MANIFEST +3 -0
  7. data/ext/htmlgrid/Makefile +150 -0
  8. data/ext/htmlgrid/extconf.rb +33 -0
  9. data/ext/htmlgrid/grid.c +881 -0
  10. data/ext/htmlgrid/grid.o +0 -0
  11. data/ext/htmlgrid/htmlgrid.c +30 -0
  12. data/ext/htmlgrid/htmlgrid.o +0 -0
  13. data/ext/htmlgrid/htmlgrid.so +0 -0
  14. data/ext/htmlgrid/include/grid.h +79 -0
  15. data/ext/htmlgrid/include/htmlgrid.h +33 -0
  16. data/install.rb +1098 -0
  17. data/lib/htmlgrid/booleanvalue.rb +41 -0
  18. data/lib/htmlgrid/button.rb +36 -0
  19. data/lib/htmlgrid/centeredcomposite.rb +47 -0
  20. data/lib/htmlgrid/component.rb +232 -0
  21. data/lib/htmlgrid/composite.rb +350 -0
  22. data/lib/htmlgrid/datevalue.rb +39 -0
  23. data/lib/htmlgrid/div.rb +37 -0
  24. data/lib/htmlgrid/divcomposite.rb +52 -0
  25. data/lib/htmlgrid/divform.rb +35 -0
  26. data/lib/htmlgrid/divlist.rb +26 -0
  27. data/lib/htmlgrid/divtemplate.rb +12 -0
  28. data/lib/htmlgrid/dojotoolkit.rb +173 -0
  29. data/lib/htmlgrid/errormessage.rb +70 -0
  30. data/lib/htmlgrid/form.rb +93 -0
  31. data/lib/htmlgrid/formlist.rb +42 -0
  32. data/lib/htmlgrid/grid.rb +286 -0
  33. data/lib/htmlgrid/image.rb +43 -0
  34. data/lib/htmlgrid/infomessage.rb +41 -0
  35. data/lib/htmlgrid/input.rb +59 -0
  36. data/lib/htmlgrid/inputcheckbox.rb +41 -0
  37. data/lib/htmlgrid/inputcurrency.rb +36 -0
  38. data/lib/htmlgrid/inputdate.rb +38 -0
  39. data/lib/htmlgrid/inputfile.rb +40 -0
  40. data/lib/htmlgrid/inputradio.rb +37 -0
  41. data/lib/htmlgrid/inputtext.rb +37 -0
  42. data/lib/htmlgrid/javascript.rb +22 -0
  43. data/lib/htmlgrid/label.rb +90 -0
  44. data/lib/htmlgrid/labeltext.rb +35 -0
  45. data/lib/htmlgrid/link.rb +54 -0
  46. data/lib/htmlgrid/list.rb +170 -0
  47. data/lib/htmlgrid/namedcomponent.rb +52 -0
  48. data/lib/htmlgrid/pass.rb +38 -0
  49. data/lib/htmlgrid/passthru.rb +44 -0
  50. data/lib/htmlgrid/popuplink.rb +66 -0
  51. data/lib/htmlgrid/reset.rb +36 -0
  52. data/lib/htmlgrid/richtext.rb +26 -0
  53. data/lib/htmlgrid/select.rb +53 -0
  54. data/lib/htmlgrid/span.rb +37 -0
  55. data/lib/htmlgrid/spancomposite.rb +45 -0
  56. data/lib/htmlgrid/spanlist.rb +15 -0
  57. data/lib/htmlgrid/staticinput.rb +40 -0
  58. data/lib/htmlgrid/submit.rb +36 -0
  59. data/lib/htmlgrid/template.rb +130 -0
  60. data/lib/htmlgrid/text.rb +36 -0
  61. data/lib/htmlgrid/textarea.rb +49 -0
  62. data/lib/htmlgrid/ulcomposite.rb +49 -0
  63. data/lib/htmlgrid/ullist.rb +15 -0
  64. data/lib/htmlgrid/urllink.rb +65 -0
  65. data/lib/htmlgrid/value.rb +36 -0
  66. data/test/rebuild.rb +39 -0
  67. data/test/stub/cgi.rb +44 -0
  68. data/test/suite.rb +32 -0
  69. data/test/test_component.rb +138 -0
  70. data/test/test_composite.rb +201 -0
  71. data/test/test_datevalue.rb +60 -0
  72. data/test/test_form.rb +123 -0
  73. data/test/test_formlist.rb +111 -0
  74. data/test/test_grid.rb +395 -0
  75. data/test/test_input.rb +70 -0
  76. data/test/test_label.rb +116 -0
  77. data/test/test_list.rb +146 -0
  78. data/test/test_select.rb +78 -0
  79. data/test/test_template.rb +97 -0
  80. data/test/test_text.rb +63 -0
  81. data/usage-en.txt +112 -0
  82. data/widget/Tooltip.js +85 -0
  83. metadata +180 -0
@@ -0,0 +1,90 @@
1
+ #!/usr/bin/env ruby
2
+ # encoding: utf-8
3
+ #
4
+ # HtmlGrid -- HyperTextMarkupLanguage Framework
5
+ # Copyright (C) 2003 ywesee - intellectual capital connected
6
+ # Andreas Schrafl, Benjamin Fay, Hannes Wyss, Markus Huggler
7
+ #
8
+ # This library is free software; you can redistribute it and/or
9
+ # modify it under the terms of the GNU Lesser General Public
10
+ # License as published by the Free Software Foundation; either
11
+ # version 2.1 of the License, or (at your option) any later version.
12
+ #
13
+ # This library is distributed in the hope that it will be useful,
14
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16
+ # Lesser General Public License for more details.
17
+ #
18
+ # You should have received a copy of the GNU Lesser General Public
19
+ # License along with this library; if not, write to the Free Software
20
+ # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21
+ #
22
+ # ywesee - intellectual capital connected, Winterthurerstrasse 52, CH-8006 Zuerich, Switzerland
23
+ # htmlgrid@ywesee.com, www.ywesee.com/htmlgrid
24
+ #
25
+ # Label -- htmlgrid -- 26.11.2002 -- hwyss@ywesee.com
26
+
27
+ require 'delegate'
28
+ require 'htmlgrid/namedcomponent'
29
+
30
+ module HtmlGrid
31
+ class SimpleLabel < NamedComponent
32
+ def init
33
+ super
34
+ @value = @lookandfeel.lookup(@name)
35
+ state = @session.state
36
+ if(state.respond_to?(:mandatory?) && state.mandatory?(@name))
37
+ @value += "*"
38
+ end
39
+ end
40
+ def to_html(context)
41
+ context.label(@attributes) { @value }
42
+ end
43
+ end
44
+ class Label < SimpleDelegator
45
+ include Enumerable
46
+ def initialize(component, session, label_key=nil)
47
+ @component = component
48
+ @attributes = {}
49
+ @session = session
50
+ @lookandfeel = session.lookandfeel
51
+ @label_key = label_key
52
+ if(@component.respond_to? :name)
53
+ @attributes['for'] = @component.name.to_s
54
+ @label_key ||= @component.name
55
+ end
56
+ if(@component.respond_to?(:data_origin) \
57
+ && (origin = @component.data_origin))
58
+ @attributes.store('title', origin.to_s)
59
+ end
60
+ if(@session.error(@label_key) \
61
+ || (@component.respond_to?(:name) && @session.error(@component.name)))
62
+ @attributes["class"] = "error"
63
+ end
64
+ if(@component.respond_to?(:attributes) \
65
+ && (id = @component.attributes['id']))
66
+ @attributes.store('id', "label_#{id}")
67
+ end
68
+ super(component)
69
+ end
70
+ def each
71
+ yield self if(@component.respond_to?(:label?) && @component.label?)
72
+ yield @component
73
+ end
74
+ def to_html(context)
75
+ key = @label_key
76
+ label = @lookandfeel.lookup(key)
77
+ if(!label && @component.respond_to?(:name))
78
+ key = @component.name
79
+ label = @lookandfeel.lookup(key)
80
+ end
81
+ state = @session.state
82
+ if(label && state.respond_to?(:mandatory?) && state.mandatory?(key))
83
+ label += "*"
84
+ end
85
+ if(label)
86
+ context.label(@attributes) { label }
87
+ end
88
+ end
89
+ end
90
+ end
@@ -0,0 +1,35 @@
1
+ #!/usr/bin/env ruby
2
+ # encoding: utf-8
3
+ #
4
+ # HtmlGrid -- HyperTextMarkupLanguage Framework
5
+ # Copyright (C) 2003 ywesee - intellectual capital connected
6
+ # Andreas Schrafl, Benjamin Fay, Hannes Wyss, Markus Huggler
7
+ #
8
+ # This library is free software; you can redistribute it and/or
9
+ # modify it under the terms of the GNU Lesser General Public
10
+ # License as published by the Free Software Foundation; either
11
+ # version 2.1 of the License, or (at your option) any later version.
12
+ #
13
+ # This library is distributed in the hope that it will be useful,
14
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16
+ # Lesser General Public License for more details.
17
+ #
18
+ # You should have received a copy of the GNU Lesser General Public
19
+ # License along with this library; if not, write to the Free Software
20
+ # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21
+ #
22
+ # ywesee - intellectual capital connected, Winterthurerstrasse 52, CH-8006 Zuerich, Switzerland
23
+ # htmlgrid@ywesee.com, www.ywesee.com
24
+ #
25
+ # LabelText -- oddb -- 22.07.2003 -- hwyss@ywesee.com
26
+
27
+ require 'htmlgrid/text'
28
+
29
+ module HtmlGrid
30
+ class LabelText < Text
31
+ def to_html(context)
32
+ context.label { super }
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,54 @@
1
+ #!/usr/bin/env ruby
2
+ # encoding: utf-8
3
+ #
4
+ # HtmlGrid -- HyperTextMarkupLanguage Framework
5
+ # Copyright (C) 2003 ywesee - intellectual capital connected
6
+ # Andreas Schrafl, Benjamin Fay, Hannes Wyss, Markus Huggler
7
+ #
8
+ # This library is free software; you can redistribute it and/or
9
+ # modify it under the terms of the GNU Lesser General Public
10
+ # License as published by the Free Software Foundation; either
11
+ # version 2.1 of the License, or (at your option) any later version.
12
+ #
13
+ # This library is distributed in the hope that it will be useful,
14
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16
+ # Lesser General Public License for more details.
17
+ #
18
+ # You should have received a copy of the GNU Lesser General Public
19
+ # License along with this library; if not, write to the Free Software
20
+ # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21
+ #
22
+ # ywesee - intellectual capital connected, Winterthurerstrasse 52, CH-8006 Zuerich, Switzerland
23
+ # htmlgrid@ywesee.com, www.ywesee.com/htmlgrid
24
+ #
25
+ # Link -- htmlgrid -- 19.11.2002 -- hwyss@ywesee.com
26
+
27
+ require 'htmlgrid/namedcomponent'
28
+
29
+ module HtmlGrid
30
+ class Link < NamedComponent
31
+ def init
32
+ super
33
+ @value = @lookandfeel.lookup(@name)
34
+ end
35
+ def href
36
+ @attributes['href']
37
+ end
38
+ def href=(url)
39
+ @attributes['href'] = url
40
+ end
41
+ def target=(trg)
42
+ @attributes['target'] = trg
43
+ end
44
+ def to_html(context)
45
+ context.a(@attributes) {
46
+ if(@value.respond_to?(:to_html))
47
+ @value.to_html(context)
48
+ else
49
+ super
50
+ end
51
+ } << dynamic_html(context)
52
+ end
53
+ end
54
+ end
@@ -0,0 +1,170 @@
1
+ #!/usr/bin/env ruby
2
+ # encoding: utf-8
3
+ #
4
+ # HtmlGrid -- HyperTextMarkupLanguage Framework
5
+ # Copyright (C) 2003 ywesee - intellectual capital connected
6
+ # Andreas Schrafl, Benjamin Fay, Hannes Wyss, Markus Huggler
7
+ #
8
+ # This library is free software; you can redistribute it and/or
9
+ # modify it under the terms of the GNU Lesser General Public
10
+ # License as published by the Free Software Foundation; either
11
+ # version 2.1 of the License, or (at your option) any later version.
12
+ #
13
+ # This library is distributed in the hope that it will be useful,
14
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16
+ # Lesser General Public License for more details.
17
+ #
18
+ # You should have received a copy of the GNU Lesser General Public
19
+ # License along with this library; if not, write to the Free Software
20
+ # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21
+ #
22
+ # ywesee - intellectual capital connected, Winterthurerstrasse 52, CH-8006 Zuerich, Switzerland
23
+ # htmlgrid@ywesee.com, www.ywesee.com/htmlgrid
24
+ #
25
+ # List -- htmlgrid -- 03.03.2003 -- hwyss@ywesee.com
26
+
27
+ require 'htmlgrid/composite'
28
+ require 'htmlgrid/link'
29
+ require 'htmlgrid/value'
30
+
31
+ module HtmlGrid
32
+ class List < Composite
33
+ BACKGROUND_ROW = nil
34
+ BACKGROUND_SUFFIX = '-bg'
35
+ CSS_HEAD_MAP = {}
36
+ DEFAULT_CLASS = Value
37
+ DEFAULT_HEAD_CLASS = nil
38
+ EMPTY_LIST = false
39
+ EMPTY_LIST_KEY = :empty_list
40
+ OFFSET_STEP = [0,1]
41
+ OMIT_HEADER = false
42
+ OMIT_HEAD_TAG = false
43
+ SORT_DEFAULT = :to_s
44
+ SORT_HEADER = true
45
+ SORT_REVERSE = false
46
+ STRIPED_BG = true
47
+ def compose(model=@model, offset=[0,0])
48
+ unless (self::class::OMIT_HEADER)
49
+ offset = compose_header(offset)
50
+ end
51
+ if(model.empty?)
52
+ offset = compose_empty_list(offset) unless (self::class::EMPTY_LIST)
53
+ else
54
+ offset = compose_list(model, offset)
55
+ end
56
+ compose_footer(offset)
57
+ end
58
+ def compose_footer(offset=[0,0])
59
+ end
60
+ def compose_empty_list(offset, klass='list')
61
+ fill_row(offset, self::class::EMPTY_LIST_KEY, klass)
62
+ end
63
+ def compose_list(model=@model, offset=[0,0])
64
+ bg_flag = false
65
+ model.each_with_index { |mdl, idx|
66
+ @list_index = idx
67
+ _compose(mdl, offset, bg_flag)
68
+ #compose_components(mdl, offset)
69
+ #compose_css(offset, resolve_suffix(mdl, bg_flag))
70
+ #compose_colspan(offset)
71
+ if(rcss = row_css(mdl, bg_flag))
72
+ @grid.set_row_attributes({'class' => rcss}, offset.at(1),
73
+ self::class::OFFSET_STEP.at(1))
74
+ end
75
+ offset = resolve_offset(offset, self::class::OFFSET_STEP)
76
+ bg_flag = !bg_flag if self::class::STRIPED_BG
77
+ }
78
+ offset
79
+ end
80
+ def compose_header(offset=[0,0])
81
+ step = if(defined?(self::class::HEAD_OFFSET_STEP))
82
+ self::class::HEAD_OFFSET_STEP
83
+ else
84
+ self::class::OFFSET_STEP
85
+ end
86
+ ystep = step.at(1)
87
+ components.each { |matrix, component|
88
+ key = lookandfeel_key(component)
89
+ header_key = 'th_' << key.to_s
90
+ if(txt = @lookandfeel.lookup(header_key))
91
+ if(self::class::SORT_HEADER)
92
+ @grid.add(sort_link(header_key, matrix, component), *matrix)
93
+ else
94
+ @grid.add(txt, *matrix)
95
+ end
96
+ end
97
+ if((cls = css_head_map[matrix]) \
98
+ || (cls = self::class::DEFAULT_HEAD_CLASS))
99
+ @grid.add_attribute('class', cls, *matrix)
100
+ #link.attributes['class'] = cls
101
+ end
102
+ unless(self::class::OMIT_HEAD_TAG || matrix.at(1) >= ystep)
103
+ @grid.add_tag('TH', *matrix)
104
+ end
105
+ if(title = @lookandfeel.lookup(header_key + '_title'))
106
+ @grid.add_attribute('title', title, *matrix)
107
+ end
108
+ }
109
+ #span = full_colspan || 1
110
+ resolve_offset(offset, step)
111
+ end
112
+ def css_head_map
113
+ @css_head_map ||= self::class::CSS_HEAD_MAP.dup
114
+ end
115
+ def fill_row(offset, key, klass)
116
+ @grid.add(@lookandfeel.lookup(key), *offset)
117
+ @grid.add_attribute('class', klass, *offset)
118
+ @grid.set_colspan(*offset)
119
+ resolve_offset(offset, self::class::OFFSET_STEP)
120
+ end
121
+ private
122
+ def init
123
+ @model ||= []
124
+ @index = 0
125
+ sort_model()
126
+ if(self::class::SORT_REVERSE && (@session.event != :sort))
127
+ @model = @model.reverse
128
+ end
129
+ super
130
+ end
131
+ def row_css(model, bg_flag)
132
+ self::class::BACKGROUND_ROW if(bg_flag)
133
+ end
134
+ def sort_link(header_key, matrix, component)
135
+ link = Link.new(header_key, @model, @session, self)
136
+ args = {
137
+ 'sortvalue' => component.to_s,
138
+ }
139
+ link.attributes['href'] = @lookandfeel.event_url(:sort, args)
140
+ if((cls = css_head_map[matrix]) \
141
+ || (cls = self::class::DEFAULT_HEAD_CLASS))
142
+ link.attributes['class'] = cls
143
+ end
144
+ link
145
+ end
146
+ def sort_model
147
+ block = self::class::SORT_DEFAULT
148
+ if(block && (@session.event != :sort))
149
+ begin
150
+ if(block == :self)
151
+ @model = @model.sort
152
+ else
153
+ unless(block.is_a?(Proc))
154
+ block = Proc.new { |item|
155
+ begin
156
+ item.send(self::class::SORT_DEFAULT)
157
+ rescue RuntimeError => e
158
+ item.to_s
159
+ end
160
+ }
161
+ end
162
+ @model = @model.sort_by(&block)
163
+ end
164
+ rescue StandardError => e
165
+ puts "could not sort: #{e.message}"
166
+ end
167
+ end
168
+ end
169
+ end
170
+ end
@@ -0,0 +1,52 @@
1
+ #!/usr/bin/env ruby
2
+ # encoding: utf-8
3
+ #
4
+ # HtmlGrid -- HyperTextMarkupLanguage Framework
5
+ # Copyright (C) 2003 ywesee - intellectual capital connected
6
+ # Andreas Schrafl, Benjamin Fay, Hannes Wyss, Markus Huggler
7
+ #
8
+ # This library is free software; you can redistribute it and/or
9
+ # modify it under the terms of the GNU Lesser General Public
10
+ # License as published by the Free Software Foundation; either
11
+ # version 2.1 of the License, or (at your option) any later version.
12
+ #
13
+ # This library is distributed in the hope that it will be useful,
14
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16
+ # Lesser General Public License for more details.
17
+ #
18
+ # You should have received a copy of the GNU Lesser General Public
19
+ # License along with this library; if not, write to the Free Software
20
+ # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21
+ #
22
+ # ywesee - intellectual capital connected, Winterthurerstrasse 52, CH-8006 Zuerich, Switzerland
23
+ # htmlgrid@ywesee.com, www.ywesee.com/htmlgrid
24
+ #
25
+ # NamedComponent -- htmlgrid -- 19.11.2002 -- hwyss@ywesee.com
26
+
27
+ require 'htmlgrid/component'
28
+
29
+ module HtmlGrid
30
+ class NamedComponent < Component
31
+ attr_reader :name
32
+ def initialize(name, model, session, container=nil)
33
+ @name = name
34
+ super(model, session, container)
35
+ @attributes['name'] = @name.to_s
36
+ end
37
+ def init
38
+ super
39
+ @attributes.update(@lookandfeel.attributes(@name)) if @lookandfeel
40
+ end
41
+ def data_origin
42
+ if(@model.respond_to?(:data_origin))
43
+ @model.data_origin(@name)
44
+ end
45
+ end
46
+ def error?
47
+ if(@model.respond_to?(:error?))
48
+ @model.error?(@name)
49
+ end
50
+ end
51
+ end
52
+ end
@@ -0,0 +1,38 @@
1
+ #!/usr/bin/env ruby
2
+ # encoding: utf-8
3
+ #
4
+ # HtmlGrid -- HyperTextMarkupLanguage Framework
5
+ # Copyright (C) 2003 ywesee - intellectual capital connected
6
+ # Andreas Schrafl, Benjamin Fay, Hannes Wyss, Markus Huggler
7
+ #
8
+ # This library is free software; you can redistribute it and/or
9
+ # modify it under the terms of the GNU Lesser General Public
10
+ # License as published by the Free Software Foundation; either
11
+ # version 2.1 of the License, or (at your option) any later version.
12
+ #
13
+ # This library is distributed in the hope that it will be useful,
14
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16
+ # Lesser General Public License for more details.
17
+ #
18
+ # You should have received a copy of the GNU Lesser General Public
19
+ # License along with this library; if not, write to the Free Software
20
+ # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21
+ #
22
+ # ywesee - intellectual capital connected, Winterthurerstrasse 52, CH-8006 Zuerich, Switzerland
23
+ # htmlgrid@ywesee.com, www.ywesee.com/htmlgrid
24
+ #
25
+ # Pass -- htmlgrid -- 03.03.2003 -- hwyss@ywesee.com
26
+
27
+ require 'htmlgrid/input'
28
+
29
+ module HtmlGrid
30
+ class Pass < Input
31
+ LABEL = true
32
+ def init
33
+ super
34
+ @attributes['type'] = 'password'
35
+ @attributes.delete('value')
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,44 @@
1
+ #!/usr/bin/env ruby
2
+ # encoding: utf-8
3
+ #
4
+ # HtmlGrid -- HyperTextMarkupLanguage Framework
5
+ # Copyright (C) 2003 ywesee - intellectual capital connected
6
+ # Andreas Schrafl, Benjamin Fay, Hannes Wyss, Markus Huggler
7
+ #
8
+ # This library is free software; you can redistribute it and/or
9
+ # modify it under the terms of the GNU Lesser General Public
10
+ # License as published by the Free Software Foundation; either
11
+ # version 2.1 of the License, or (at your option) any later version.
12
+ #
13
+ # This library is distributed in the hope that it will be useful,
14
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16
+ # Lesser General Public License for more details.
17
+ #
18
+ # You should have received a copy of the GNU Lesser General Public
19
+ # License along with this library; if not, write to the Free Software
20
+ # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21
+ #
22
+ # ywesee - intellectual capital connected, Winterthurerstrasse 52, CH-8006 Zuerich, Switzerland
23
+ # htmlgrid@ywesee.com, www.ywesee.com/htmlgrid
24
+ #
25
+ # PassThru -- HtmlGrid -- 29.10.2003 -- hwyss@ywesee.com
26
+
27
+ module HtmlGrid
28
+ class PassThru
29
+ def initialize(model, session, container=nil)
30
+ @model = model
31
+ @session = session
32
+ @lookandfeel = @session.lookandfeel
33
+ init()
34
+ end
35
+ def init
36
+ end
37
+ def http_headers
38
+ {}
39
+ end
40
+ def to_html(context)
41
+ ''
42
+ end
43
+ end
44
+ end
@@ -0,0 +1,66 @@
1
+ #!/usr/bin/env ruby
2
+ # encoding: utf-8
3
+ #
4
+ # HtmlGrid -- HyperTextMarkupLanguage Framework
5
+ # Copyright (C) 2003 ywesee - intellectual capital connected
6
+ # Andreas Schrafl, Benjamin Fay, Hannes Wyss, Markus Huggler
7
+ #
8
+ # This library is free software; you can redistribute it and/or
9
+ # modify it under the terms of the GNU Lesser General Public
10
+ # License as published by the Free Software Foundation; either
11
+ # version 2.1 of the License, or (at your option) any later version.
12
+ #
13
+ # This library is distributed in the hope that it will be useful,
14
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16
+ # Lesser General Public License for more details.
17
+ #
18
+ # You should have received a copy of the GNU Lesser General Public
19
+ # License along with this library; if not, write to the Free Software
20
+ # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21
+ #
22
+ # ywesee - intellectual capital connected, Winterthurerstrasse 52, CH-8006 Zuerich, Switzerland
23
+ # htmlgrid@ywesee.com, www.ywesee.com/htmlgrid
24
+ #
25
+ # PopupLink -- htmlgrid -- 20.03.2003 -- hwyss@ywesee.com
26
+
27
+ require 'htmlgrid/link'
28
+
29
+ module HtmlGrid
30
+ class PopupLink < Link
31
+ attr_writer :width, :height
32
+ attr_writer :locationbar, :scrollbars, :resizable, :toolbar, :menubar
33
+ def init
34
+ super
35
+ @scrollbars = true
36
+ @resizable = true
37
+ @toolbar = true
38
+ @menubar = false
39
+ @locationbar = false
40
+ @width = 750
41
+ @height = 460
42
+ end
43
+ @@name_ptrn = /[^a-z]+/i
44
+ def to_html(context)
45
+ props = {
46
+ 'scrollbars' => yesorno(@scrollbars),
47
+ 'resizable' => yesorno(@resizable),
48
+ 'toolbar' => yesorno(@toolbar),
49
+ 'menubar' => yesorno(@menubar),
50
+ 'locationbar' => yesorno(@locationbar),
51
+ 'width' => @width,
52
+ 'height' => @height,
53
+ }.collect { |key, val|
54
+ [key,val].join('=')
55
+ }.join(',')
56
+ name = @lookandfeel.lookup(@name).to_s.gsub(@@name_ptrn, '')
57
+ script = "window.open('#{href}', '#{name}', '#{props}').focus(); return false"
58
+ @attributes.store('onClick', script)
59
+ super
60
+ end
61
+ private
62
+ def yesorno(value)
63
+ value ? 'yes' : 'no'
64
+ end
65
+ end
66
+ end
@@ -0,0 +1,36 @@
1
+ #!/usr/bin/env ruby
2
+ # encoding: utf-8
3
+ #
4
+ # HtmlGrid -- HyperTextMarkupLanguage Framework
5
+ # Copyright (C) 2003 ywesee - intellectual capital connected
6
+ # Andreas Schrafl, Benjamin Fay, Hannes Wyss, Markus Huggler
7
+ #
8
+ # This library is free software; you can redistribute it and/or
9
+ # modify it under the terms of the GNU Lesser General Public
10
+ # License as published by the Free Software Foundation; either
11
+ # version 2.1 of the License, or (at your option) any later version.
12
+ #
13
+ # This library is distributed in the hope that it will be useful,
14
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16
+ # Lesser General Public License for more details.
17
+ #
18
+ # You should have received a copy of the GNU Lesser General Public
19
+ # License along with this library; if not, write to the Free Software
20
+ # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21
+ #
22
+ # ywesee - intellectual capital connected, Winterthurerstrasse 52, CH-8006 Zuerich, Switzerland
23
+ # htmlgrid@ywesee.com, www.ywesee.com/htmlgrid
24
+ #
25
+ # Reset -- htmlgrid -- 14.01.2003 -- benfay@ywesee.com
26
+
27
+ require 'htmlgrid/staticinput'
28
+
29
+ module HtmlGrid
30
+ class Reset < StaticInput
31
+ def init
32
+ super
33
+ @attributes['type'] = 'reset'
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,26 @@
1
+ #!/usr/bin/env ruby
2
+ # encoding: utf-8
3
+ # Richtext -- htmlgrid -- 29.06.2004 -- mhuggler@ywesee.com
4
+
5
+ require 'htmlgrid/component'
6
+
7
+ module HtmlGrid
8
+ class RichText < Component
9
+ def init
10
+ super
11
+ @elements = []
12
+ end
13
+ def <<(element)
14
+ @elements.push(element)
15
+ end
16
+ def to_html(context)
17
+ @elements.collect { |element|
18
+ if(element.respond_to?(:to_html))
19
+ element.to_html(context)
20
+ else
21
+ element.to_s
22
+ end
23
+ }.join(' ')
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,53 @@
1
+ #!/usr/bin/env ruby
2
+ # encoding: utf-8
3
+ #
4
+ # HtmlGrid -- HyperTextMarkupLanguage Framework
5
+ # Copyright (C) 2003 ywesee - intellectual capital connected
6
+ # Andreas Schrafl, Benjamin Fay, Hannes Wyss, Markus Huggler
7
+ #
8
+ # This library is free software; you can redistribute it and/or
9
+ # modify it under the terms of the GNU Lesser General Public
10
+ # License as published by the Free Software Foundation; either
11
+ # version 2.1 of the License, or (at your option) any later version.
12
+ #
13
+ # This library is distributed in the hope that it will be useful,
14
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16
+ # Lesser General Public License for more details.
17
+ #
18
+ # You should have received a copy of the GNU Lesser General Public
19
+ # License along with this library; if not, write to the Free Software
20
+ # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21
+ #
22
+ # ywesee - intellectual capital connected, Winterthurerstrasse 52, CH-8006 Zuerich, Switzerland
23
+ # htmlgrid@ywesee.com, www.ywesee.com/htmlgrid
24
+ #
25
+ # Select -- htmlgrid -- 10.03.2003 -- hwyss@ywesee.com
26
+
27
+ require 'htmlgrid/namedcomponent'
28
+
29
+ module HtmlGrid
30
+ class AbstractSelect < NamedComponent
31
+ LABEL = true
32
+ attr_accessor :selected, :valid_values
33
+ def to_html(context)
34
+ context.select(@attributes) {
35
+ sel = selection(context)
36
+ sel.is_a?(Array) ? sel.join : sel.to_s
37
+ }
38
+ end
39
+ end
40
+ class Select < AbstractSelect
41
+ private
42
+ def selection(context)
43
+ @selected ||= (@model.send(@name).to_s if(@model.respond_to?(@name)))
44
+ @valid_values ||= @session.valid_values(@name)
45
+ @valid_values.collect { |value|
46
+ val = value.to_s
47
+ attributes = { "value" => val }
48
+ attributes.store("selected", true) if(val == selected)
49
+ context.option(attributes) { @lookandfeel.lookup(value) { val } }
50
+ }
51
+ end
52
+ end
53
+ end