Added wsf_html documentation in the doc/workbook.
Also improved the structure of `wsf_html` library. Added a few widgets.
This commit is contained in:
224
library/server/wsf_html/widget/table/wsf_widget_agent_table.e
Normal file
224
library/server/wsf_html/widget/table/wsf_widget_agent_table.e
Normal file
@@ -0,0 +1,224 @@
|
||||
note
|
||||
description: "Summary description for {WSF_WIDGET_AGENT_TABLE}."
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
class
|
||||
WSF_WIDGET_AGENT_TABLE [G -> detachable ANY]
|
||||
|
||||
inherit
|
||||
WSF_WIDGET
|
||||
|
||||
WSF_WITH_CSS_ID
|
||||
|
||||
WSF_WITH_CSS_CLASS
|
||||
|
||||
WSF_WITH_CSS_STYLE
|
||||
|
||||
create
|
||||
make
|
||||
|
||||
convert
|
||||
to_computed_table: {WSF_WIDGET_TABLE}
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
make
|
||||
do
|
||||
create columns.make_empty
|
||||
end
|
||||
|
||||
feature -- Access
|
||||
|
||||
column_count: INTEGER
|
||||
do
|
||||
Result := columns.count
|
||||
end
|
||||
|
||||
columns: ARRAY [WSF_WIDGET_TABLE_COLUMN]
|
||||
|
||||
column (c: INTEGER): WSF_WIDGET_TABLE_COLUMN
|
||||
do
|
||||
if c > column_count then
|
||||
set_column_count (c)
|
||||
end
|
||||
Result := columns[c]
|
||||
end
|
||||
|
||||
has_title: BOOLEAN
|
||||
do
|
||||
Result := across columns as c some c.item.title /= Void end
|
||||
end
|
||||
|
||||
head_data: detachable ITERABLE [G]
|
||||
-- thead
|
||||
|
||||
foot_data: detachable ITERABLE [G]
|
||||
-- tfoot
|
||||
|
||||
data: detachable ITERABLE [G]
|
||||
-- tbody
|
||||
|
||||
compute_item_function: detachable FUNCTION [G, WSF_WIDGET_TABLE_ROW]
|
||||
|
||||
feature -- Change
|
||||
|
||||
set_head_data (d: like head_data)
|
||||
do
|
||||
head_data := d
|
||||
end
|
||||
|
||||
set_foot_data (d: like foot_data)
|
||||
do
|
||||
foot_data := d
|
||||
end
|
||||
|
||||
set_data (d: like data)
|
||||
do
|
||||
data := d
|
||||
end
|
||||
|
||||
set_compute_item_function (fct: like compute_item_function)
|
||||
do
|
||||
compute_item_function := fct
|
||||
end
|
||||
|
||||
set_column_count (nb: INTEGER)
|
||||
do
|
||||
if nb > columns.count then
|
||||
-- columns.conservative_resize_with_default (create {WSF_WIDGET_TABLE_COLUMN}, 1, nb)
|
||||
from
|
||||
until
|
||||
columns.count = nb
|
||||
loop
|
||||
columns.force (create {WSF_WIDGET_TABLE_COLUMN}.make (columns.upper + 1), columns.upper + 1)
|
||||
end
|
||||
else
|
||||
columns.remove_tail (columns.count - nb)
|
||||
end
|
||||
end
|
||||
|
||||
set_column_title (c: INTEGER; t: READABLE_STRING_32)
|
||||
do
|
||||
if c > column_count then
|
||||
set_column_count (c)
|
||||
end
|
||||
if attached column (c) as col then
|
||||
col.set_title (t)
|
||||
end
|
||||
end
|
||||
|
||||
feature -- Conversion
|
||||
|
||||
to_computed_table: WSF_WIDGET_TABLE
|
||||
local
|
||||
col: WSF_WIDGET_TABLE_COLUMN
|
||||
do
|
||||
create Result.make
|
||||
Result.set_column_count (column_count)
|
||||
-- css classes
|
||||
Result.add_css_classes (css_classes)
|
||||
-- css id
|
||||
Result.set_css_id (css_id)
|
||||
-- css style
|
||||
Result.add_css_style (css_style)
|
||||
|
||||
-- columns
|
||||
across
|
||||
columns as c
|
||||
loop
|
||||
col := Result.column (c.item.index)
|
||||
col.set_title (c.item.title)
|
||||
col.add_css_style (c.item.css_style)
|
||||
col.add_css_classes (c.item.css_classes)
|
||||
end
|
||||
|
||||
-- rows
|
||||
if attached compute_item_function as fct then
|
||||
if attached head_data as lst then
|
||||
across lst as d loop
|
||||
Result.add_head_row (fct.item ([d.item]))
|
||||
end
|
||||
end
|
||||
if attached data as lst then
|
||||
across lst as d loop
|
||||
Result.add_row (fct.item ([d.item]))
|
||||
end
|
||||
end
|
||||
if attached foot_data as lst then
|
||||
across lst as d loop
|
||||
Result.add_foot_row (fct.item ([d.item]))
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
feature -- Conversion: HTML
|
||||
|
||||
append_to_html (a_theme: WSF_THEME; a_html: STRING_8)
|
||||
local
|
||||
l_use_tbody: BOOLEAN
|
||||
do
|
||||
a_html.append ("<table")
|
||||
append_css_id_to (a_html)
|
||||
append_css_class_to (a_html, Void)
|
||||
append_css_style_to (a_html)
|
||||
a_html.append (">")
|
||||
|
||||
if has_title then
|
||||
a_html.append ("<tr>")
|
||||
across
|
||||
columns as c
|
||||
loop
|
||||
c.item.append_table_header_to_html (a_theme, a_html)
|
||||
end
|
||||
a_html.append ("</tr>")
|
||||
end
|
||||
if attached head_data as l_head_data then
|
||||
l_use_tbody := True
|
||||
a_html.append ("<thead>")
|
||||
append_data_to_html (l_head_data, a_theme, a_html)
|
||||
a_html.append ("</thead>")
|
||||
end
|
||||
if attached foot_data as l_foot_data then
|
||||
l_use_tbody := True
|
||||
a_html.append ("<tfoot>")
|
||||
append_data_to_html (l_foot_data, a_theme, a_html)
|
||||
a_html.append ("</tfoot>")
|
||||
end
|
||||
|
||||
if attached data as l_data then
|
||||
if l_use_tbody then
|
||||
a_html.append ("<tbody>")
|
||||
end
|
||||
append_data_to_html (l_data, a_theme, a_html)
|
||||
if l_use_tbody then
|
||||
a_html.append ("</tbody>")
|
||||
end
|
||||
end
|
||||
a_html.append ("</table>")
|
||||
end
|
||||
|
||||
append_data_to_html (lst: ITERABLE [G]; a_theme: WSF_THEME; a_html: STRING_8)
|
||||
local
|
||||
fct: like compute_item_function
|
||||
do
|
||||
fct := compute_item_function
|
||||
across
|
||||
lst as d
|
||||
loop
|
||||
if fct /= Void and then attached fct.item ([d.item]) as r then
|
||||
r.append_to_html (a_theme, a_html)
|
||||
else
|
||||
a_html.append ("<tr>")
|
||||
a_html.append ("<td>")
|
||||
if attached d.item as g then
|
||||
a_html.append (g.out)
|
||||
end
|
||||
a_html.append ("</td>")
|
||||
a_html.append ("</tr>")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
281
library/server/wsf_html/widget/table/wsf_widget_table.e
Normal file
281
library/server/wsf_html/widget/table/wsf_widget_table.e
Normal file
@@ -0,0 +1,281 @@
|
||||
note
|
||||
description: "Summary description for {WSF_WIDGET_FILLED_TABLE}."
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
class
|
||||
WSF_WIDGET_TABLE
|
||||
|
||||
inherit
|
||||
WSF_WIDGET
|
||||
|
||||
WSF_WITH_CSS_ID
|
||||
|
||||
WSF_WITH_CSS_CLASS
|
||||
|
||||
WSF_WITH_CSS_STYLE
|
||||
|
||||
WSF_WITH_HTML_ATTRIBUTE
|
||||
|
||||
ITERABLE [WSF_WIDGET_TABLE_ITEM]
|
||||
|
||||
create
|
||||
make
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
make
|
||||
do
|
||||
create columns.make_empty
|
||||
end
|
||||
|
||||
make_from_table (tb: WSF_WIDGET_AGENT_TABLE [detachable ANY])
|
||||
do
|
||||
make
|
||||
set_column_count (tb.column_count)
|
||||
-- css classes
|
||||
if attached tb.css_classes as lst then
|
||||
across lst as c loop
|
||||
add_css_class (c.item)
|
||||
end
|
||||
end
|
||||
-- css id
|
||||
set_css_id (tb.css_id)
|
||||
|
||||
-- css style
|
||||
add_css_style (tb.css_style)
|
||||
|
||||
-- columns
|
||||
across
|
||||
tb.columns as c
|
||||
loop
|
||||
columns [c.item.index] := c.item.twin
|
||||
end
|
||||
|
||||
-- rows
|
||||
if attached tb.compute_item_function as fct then
|
||||
if attached tb.head_data as lst then
|
||||
across lst as d loop
|
||||
add_head_row (fct.item ([d.item]))
|
||||
end
|
||||
end
|
||||
if attached tb.data as lst then
|
||||
across lst as d loop
|
||||
add_row (fct.item ([d.item]))
|
||||
end
|
||||
end
|
||||
if attached tb.foot_data as lst then
|
||||
across lst as d loop
|
||||
add_foot_row (fct.item ([d.item]))
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
feature -- Access
|
||||
|
||||
new_cursor: WSF_WIDGET_TABLE_ITERATION_CURSOR
|
||||
-- Fresh cursor associated with current structure
|
||||
do
|
||||
create Result.make (Current)
|
||||
end
|
||||
|
||||
column_count: INTEGER
|
||||
do
|
||||
Result := columns.count
|
||||
end
|
||||
|
||||
head_row_count: INTEGER
|
||||
do
|
||||
if attached head_rows as lst then
|
||||
Result := lst.count
|
||||
end
|
||||
end
|
||||
|
||||
body_row_count: INTEGER
|
||||
do
|
||||
if attached rows as lst then
|
||||
Result := lst.count
|
||||
end
|
||||
end
|
||||
|
||||
foot_row_count: INTEGER
|
||||
do
|
||||
if attached foot_rows as lst then
|
||||
Result := lst.count
|
||||
end
|
||||
end
|
||||
|
||||
row_count: INTEGER
|
||||
do
|
||||
Result := head_row_count + body_row_count + foot_row_count
|
||||
end
|
||||
|
||||
columns: ARRAY [WSF_WIDGET_TABLE_COLUMN]
|
||||
|
||||
|
||||
column (c: INTEGER): WSF_WIDGET_TABLE_COLUMN
|
||||
do
|
||||
if c > column_count then
|
||||
set_column_count (c)
|
||||
end
|
||||
Result := columns[c]
|
||||
end
|
||||
|
||||
row (r: INTEGER): detachable WSF_WIDGET_TABLE_ROW
|
||||
do
|
||||
if r <= head_row_count then
|
||||
if attached head_rows as lst then
|
||||
Result := lst [r]
|
||||
end
|
||||
elseif r <= head_row_count + body_row_count then
|
||||
if attached rows as lst then
|
||||
Result := lst [r - head_row_count]
|
||||
end
|
||||
elseif r <= row_count then
|
||||
if attached foot_rows as lst then
|
||||
Result := lst [r - head_row_count - body_row_count]
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
has_title: BOOLEAN
|
||||
do
|
||||
Result := across columns as c some c.item.title /= Void end
|
||||
end
|
||||
|
||||
head_rows: detachable ARRAYED_LIST [WSF_WIDGET_TABLE_ROW]
|
||||
-- thead
|
||||
|
||||
foot_rows: detachable ARRAYED_LIST [WSF_WIDGET_TABLE_ROW]
|
||||
-- tfoot
|
||||
|
||||
rows: detachable ARRAYED_LIST [WSF_WIDGET_TABLE_ROW]
|
||||
-- tbody
|
||||
|
||||
feature -- Change
|
||||
|
||||
clear_rows
|
||||
do
|
||||
head_rows := Void
|
||||
foot_rows := Void
|
||||
rows := Void
|
||||
end
|
||||
|
||||
add_head_row (r: WSF_WIDGET_TABLE_ROW)
|
||||
local
|
||||
lst: like head_rows
|
||||
do
|
||||
lst := head_rows
|
||||
if lst = Void then
|
||||
create {ARRAYED_LIST [WSF_WIDGET_TABLE_ROW]} lst.make (1)
|
||||
head_rows := lst
|
||||
end
|
||||
lst.force (r)
|
||||
end
|
||||
|
||||
add_foot_row (r: WSF_WIDGET_TABLE_ROW)
|
||||
local
|
||||
lst: like foot_rows
|
||||
do
|
||||
lst := foot_rows
|
||||
if lst = Void then
|
||||
create {ARRAYED_LIST [WSF_WIDGET_TABLE_ROW]} lst.make (1)
|
||||
foot_rows := lst
|
||||
end
|
||||
lst.force (r)
|
||||
end
|
||||
|
||||
add_row (r: WSF_WIDGET_TABLE_ROW)
|
||||
local
|
||||
lst: like rows
|
||||
do
|
||||
lst := rows
|
||||
if lst = Void then
|
||||
create {ARRAYED_LIST [WSF_WIDGET_TABLE_ROW]} lst.make (1)
|
||||
rows := lst
|
||||
end
|
||||
lst.force (r)
|
||||
end
|
||||
|
||||
set_column_count (nb: INTEGER)
|
||||
do
|
||||
if nb > columns.count then
|
||||
from
|
||||
until
|
||||
columns.count = nb
|
||||
loop
|
||||
columns.force (create {WSF_WIDGET_TABLE_COLUMN}.make (columns.upper + 1), columns.upper + 1)
|
||||
end
|
||||
else
|
||||
columns.remove_tail (columns.count - nb)
|
||||
end
|
||||
end
|
||||
|
||||
set_column_title (c: INTEGER; t: READABLE_STRING_32)
|
||||
do
|
||||
if c > column_count then
|
||||
set_column_count (c)
|
||||
end
|
||||
if attached column (c) as col then
|
||||
col.set_title (t)
|
||||
end
|
||||
end
|
||||
|
||||
feature -- Conversion
|
||||
|
||||
append_to_html (a_theme: WSF_THEME; a_html: STRING_8)
|
||||
local
|
||||
l_use_tbody: BOOLEAN
|
||||
do
|
||||
a_html.append ("<table")
|
||||
append_css_id_to (a_html)
|
||||
append_css_class_to (a_html, Void)
|
||||
append_css_style_to (a_html)
|
||||
append_html_attributes_to (a_html)
|
||||
a_html.append (">")
|
||||
|
||||
if has_title then
|
||||
a_html.append ("<tr>")
|
||||
across
|
||||
columns as c
|
||||
loop
|
||||
c.item.append_table_header_to_html (a_theme, a_html)
|
||||
end
|
||||
a_html.append ("</tr>")
|
||||
end
|
||||
if attached head_rows as l_head_rows then
|
||||
l_use_tbody := True
|
||||
a_html.append ("<thead>")
|
||||
append_rows_to_html (l_head_rows, a_theme, a_html)
|
||||
a_html.append ("</thead>")
|
||||
end
|
||||
if attached foot_rows as l_foot_rows then
|
||||
l_use_tbody := True
|
||||
a_html.append ("<tfoot>")
|
||||
append_rows_to_html (l_foot_rows, a_theme, a_html)
|
||||
a_html.append ("</tfoot>")
|
||||
end
|
||||
|
||||
if attached rows as l_rows then
|
||||
if l_use_tbody then
|
||||
a_html.append ("<tbody>")
|
||||
end
|
||||
append_rows_to_html (l_rows, a_theme, a_html)
|
||||
if l_use_tbody then
|
||||
a_html.append ("</tbody>")
|
||||
end
|
||||
end
|
||||
a_html.append ("</table>")
|
||||
end
|
||||
|
||||
append_rows_to_html (lst: ITERABLE [WSF_WIDGET_TABLE_ROW]; a_theme: WSF_THEME; a_html: STRING_8)
|
||||
do
|
||||
across
|
||||
lst as r
|
||||
loop
|
||||
r.item.append_to_html (a_theme, a_html)
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
@@ -0,0 +1,52 @@
|
||||
note
|
||||
description: "Summary description for {WSF_WIDGET_COLUMN}."
|
||||
author: ""
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
class
|
||||
WSF_WIDGET_TABLE_COLUMN
|
||||
|
||||
inherit
|
||||
WSF_WITH_CSS_CLASS
|
||||
|
||||
WSF_WITH_CSS_STYLE
|
||||
|
||||
create
|
||||
make
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
make (i: like index)
|
||||
do
|
||||
index := i
|
||||
end
|
||||
|
||||
feature -- Access
|
||||
|
||||
index: INTEGER
|
||||
|
||||
title: detachable READABLE_STRING_32
|
||||
|
||||
feature -- Change
|
||||
|
||||
set_title (t: like title)
|
||||
do
|
||||
title := t
|
||||
end
|
||||
|
||||
feature -- Conversion
|
||||
|
||||
append_table_header_to_html (a_theme: WSF_THEME; a_html: STRING_8)
|
||||
do
|
||||
a_html.append ("<th")
|
||||
append_css_class_to (a_html, Void)
|
||||
append_css_style_to (a_html)
|
||||
a_html.append_character ('>')
|
||||
if attached title as l_title then
|
||||
a_html.append (a_theme.html_encoded (l_title))
|
||||
end
|
||||
a_html.append ("</th>")
|
||||
end
|
||||
|
||||
end
|
||||
79
library/server/wsf_html/widget/table/wsf_widget_table_item.e
Normal file
79
library/server/wsf_html/widget/table/wsf_widget_table_item.e
Normal file
@@ -0,0 +1,79 @@
|
||||
note
|
||||
description: "Summary description for {WSF_WIDGET_TABLE_ITEM}."
|
||||
author: ""
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
class
|
||||
WSF_WIDGET_TABLE_ITEM
|
||||
|
||||
inherit
|
||||
WSF_WIDGET
|
||||
|
||||
WSF_WITH_HTML_ATTRIBUTE
|
||||
|
||||
WSF_WITH_CSS_CLASS
|
||||
|
||||
WSF_WITH_CSS_STYLE
|
||||
|
||||
ITERABLE [WSF_WIDGET]
|
||||
|
||||
create
|
||||
make_with_text,
|
||||
make_with_text_and_css,
|
||||
make_with_content
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
make_with_text (a_text: READABLE_STRING_8)
|
||||
do
|
||||
make_with_content (create {WSF_WIDGET_TEXT}.make_with_text (a_text))
|
||||
end
|
||||
|
||||
make_with_text_and_css (a_text: READABLE_STRING_8; a_css_classes: detachable ITERABLE [READABLE_STRING_8])
|
||||
do
|
||||
make_with_text (a_text)
|
||||
if a_css_classes /= Void then
|
||||
across
|
||||
a_css_classes as c
|
||||
loop
|
||||
add_css_class (c.item)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
make_with_content (a_widget: WSF_WIDGET)
|
||||
do
|
||||
content := a_widget
|
||||
end
|
||||
|
||||
feature -- Access
|
||||
|
||||
content: WSF_WIDGET
|
||||
|
||||
feature -- Access
|
||||
|
||||
new_cursor: ITERATION_CURSOR [WSF_WIDGET]
|
||||
-- Fresh cursor associated with current structure
|
||||
local
|
||||
lst: ARRAYED_LIST [WSF_WIDGET]
|
||||
do
|
||||
create lst.make (1)
|
||||
lst.extend (content)
|
||||
Result := lst.new_cursor
|
||||
end
|
||||
|
||||
feature -- Conversion
|
||||
|
||||
append_to_html (a_theme: WSF_THEME; a_html: STRING_8)
|
||||
do
|
||||
a_html.append ("<td")
|
||||
append_css_class_to (a_html, Void)
|
||||
append_css_style_to (a_html)
|
||||
append_html_attributes_to (a_html)
|
||||
a_html.append_character ('>')
|
||||
content.append_to_html (a_theme, a_html)
|
||||
a_html.append ("</td>")
|
||||
end
|
||||
|
||||
end
|
||||
@@ -0,0 +1,96 @@
|
||||
note
|
||||
description: "Summary description for {WSF_WIDGET_TABLE_ITERATION_CURSOR}."
|
||||
author: ""
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
class
|
||||
WSF_WIDGET_TABLE_ITERATION_CURSOR
|
||||
|
||||
inherit
|
||||
ITERATION_CURSOR [WSF_WIDGET_TABLE_ITEM]
|
||||
|
||||
create
|
||||
make
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
make (a_table: WSF_WIDGET_TABLE)
|
||||
do
|
||||
table := a_table
|
||||
start
|
||||
end
|
||||
|
||||
table: WSF_WIDGET_TABLE
|
||||
|
||||
row_index: INTEGER
|
||||
column_index: INTEGER
|
||||
|
||||
feature -- Access
|
||||
|
||||
start
|
||||
do
|
||||
row_index := 1
|
||||
column_index := 0
|
||||
forth
|
||||
end
|
||||
|
||||
item: WSF_WIDGET_TABLE_ITEM
|
||||
-- Item at current cursor position.
|
||||
do
|
||||
if attached table.row (row_index) as r then
|
||||
if attached r.item (column_index) as w then
|
||||
Result := w
|
||||
else
|
||||
create Result.make_with_text ("")
|
||||
end
|
||||
else
|
||||
create Result.make_with_text ("")
|
||||
end
|
||||
end
|
||||
|
||||
feature -- Status report
|
||||
|
||||
after: BOOLEAN
|
||||
-- Are there no more items to iterate over?
|
||||
do
|
||||
if row_index > table.row_count then
|
||||
Result := True
|
||||
elseif row_index = table.row_count then
|
||||
if attached table.row (row_index) as l_row then
|
||||
if column_index > l_row.count then
|
||||
Result := True
|
||||
else
|
||||
Result := False
|
||||
end
|
||||
else
|
||||
Result := True
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
feature -- Cursor movement
|
||||
|
||||
forth
|
||||
-- Move to next position.
|
||||
do
|
||||
if row_index <= table.row_count then
|
||||
if attached table.row (row_index) as l_row then
|
||||
if column_index < l_row.count then
|
||||
column_index := column_index + 1
|
||||
else
|
||||
from
|
||||
row_index := row_index + 1
|
||||
column_index := 1
|
||||
until
|
||||
row_index > table.row_count or
|
||||
attached table.row (row_index) as r and then r.count > 0
|
||||
loop
|
||||
row_index := row_index + 1
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
106
library/server/wsf_html/widget/table/wsf_widget_table_row.e
Normal file
106
library/server/wsf_html/widget/table/wsf_widget_table_row.e
Normal file
@@ -0,0 +1,106 @@
|
||||
note
|
||||
description: "Summary description for {WSF_WIDGET_TABLE_ROW}."
|
||||
author: ""
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
class
|
||||
WSF_WIDGET_TABLE_ROW
|
||||
|
||||
inherit
|
||||
WSF_WITH_CSS_CLASS
|
||||
|
||||
WSF_WITH_CSS_STYLE
|
||||
|
||||
ITERABLE [WSF_WIDGET_TABLE_ITEM]
|
||||
|
||||
create
|
||||
make,
|
||||
make_with_items
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
make (n: INTEGER)
|
||||
do
|
||||
create items.make (n)
|
||||
end
|
||||
|
||||
make_with_items (lst: ITERABLE [WSF_WIDGET_TABLE_ITEM])
|
||||
local
|
||||
n: INTEGER
|
||||
do
|
||||
across lst as c loop
|
||||
n := n + 1
|
||||
end
|
||||
make (n)
|
||||
across
|
||||
lst as c
|
||||
loop
|
||||
add_item (c.item)
|
||||
end
|
||||
end
|
||||
|
||||
items: ARRAYED_LIST [WSF_WIDGET_TABLE_ITEM]
|
||||
|
||||
feature -- Access
|
||||
|
||||
new_cursor: ITERATION_CURSOR [WSF_WIDGET_TABLE_ITEM]
|
||||
do
|
||||
Result := items.new_cursor
|
||||
end
|
||||
|
||||
count: INTEGER
|
||||
do
|
||||
Result := items.count
|
||||
end
|
||||
|
||||
item (c: INTEGER): WSF_WIDGET_TABLE_ITEM
|
||||
do
|
||||
Result := items [c]
|
||||
end
|
||||
|
||||
feature -- Change
|
||||
|
||||
set_item (w: WSF_WIDGET_TABLE_ITEM; col: INTEGER)
|
||||
do
|
||||
if col > items.count then
|
||||
items.grow (col)
|
||||
from
|
||||
until
|
||||
items.count >= col - 1
|
||||
loop
|
||||
items.force (create {WSF_WIDGET_TABLE_ITEM}.make_with_text (""))
|
||||
end
|
||||
items.force (w)
|
||||
else
|
||||
items.put_i_th (w, col)
|
||||
end
|
||||
end
|
||||
|
||||
add_widget (w: WSF_WIDGET)
|
||||
do
|
||||
add_item (create {WSF_WIDGET_TABLE_ITEM}.make_with_content (w))
|
||||
end
|
||||
|
||||
force, add_item (w: WSF_WIDGET_TABLE_ITEM)
|
||||
do
|
||||
items.force (w)
|
||||
end
|
||||
|
||||
feature -- Conversion
|
||||
|
||||
append_to_html (a_theme: WSF_THEME; a_html: STRING_8)
|
||||
do
|
||||
a_html.append ("<tr")
|
||||
append_css_class_to (a_html, Void)
|
||||
append_css_style_to (a_html)
|
||||
a_html.append_character ('>')
|
||||
across
|
||||
items as c
|
||||
loop
|
||||
c.item.append_to_html (a_theme, a_html)
|
||||
end
|
||||
a_html.append ("</tr>")
|
||||
end
|
||||
|
||||
end
|
||||
Reference in New Issue
Block a user