[...]
> It's similar as in the following example (where render_table_header_on =~ draw_line_on):
>
> def draw_line_on(canvas, x, y, w, h)
> ...
> end
>
> def draw_box_on(canvas, x, y, w, h)
> ...
> end
>
> def draw_on(canvas)
> draw_line_on(canvas, ....)
> draw_box_on(canvas, ...)
> endWho does all of this drawing? It looks like some unknown power is doing
(and knowing) way too much.
The component! For example the button component has to draw itself onto
the screen, for which it needs a canvas.
Well, my example above was not good choosen. Better would have been:
class Button < Component
# this one is called from 'outside'
def draw_on(canvas)
draw_frame(canvas)
draw_inner(canvas)
end
private
# helper method
def draw_frame(canvas)
if @pressed
canvas.color = :lightgray
canvas.line(x, y, x+w, y)
canvas.line(x+w, y, x+w, y+h)
...
else
...
end
end
# helper method
def draw_inner(canvas)
canvas.text(@caption)
end
end
Of course the canvas implements the drawing primitives.
Now think the same for the Web and Html generation.
> Of course I'd removed the "_on" in the GUI case.
> The actual "drawing" is done this way (inside render_xxxx_on):
>
> renderer.table {
> renderer.row {
> ...If I were the renderer, I'd have a headache from all the knowledge that
you must have stuffed into my poor brainThere must be a better way
to do this.
Hm, but somewhere you have to implement how the component looks like, no?
The above is equivalent to:
cgi.table {
cgi.tr {
cgi.td { ... } +
cgi.td { ... }
}
}
But in a more imperatively fashion, similar as for drawing a GUI on the
canvas, where you don't do this ('+'):
canvas.box(...) {
canvas.line(1, 1, 10, 10) +
canvas.line(...) +
...
}
Regards,
Michael
···
On Fri, Oct 22, 2004 at 04:49:18PM +0900, Stefan Schmiedl wrote:
On Fri, 22 Oct 2004 07:36:12 +0900, > Michael Neumann <mneumann@ntecs.de> wrote: