source: gaycko/trunk/src/render/renderer.c @ 4768

Last change on this file since 4768 was 4768, checked in by Jean-Yves Lamoureux, 10 years ago
  • Reworked table handling
File size: 1.4 KB
RevLine 
[4748]1/*
2 *  Gaycko        Text mode web browser
3 *  Copyright (c) 2011 Jean-Yves Lamoureux <jylam@lnxscene.org>
4 *                All Rights Reserved
5 *
6 *  This library is free software. It comes without any warranty, to
7 *  the extent permitted by applicable law. You can redistribute it
8 *  and/or modify it under the terms of the Do What The Fuck You Want
9 *  To Public License, Version 2, as published by Sam Hocevar. See
10 *  http://sam.zoy.org/wtfpl/COPYING for more details.
11 */
[4746]12#include "renderer.h"
13
[4753]14void gaycko_render(gWindow *window) {
15        window->dom->root->properties->width = window->width;
[4764]16        gaycko_get_position(window->dom->root, NULL);
17        caca_set_canvas_size(window->cv,
18                        window->dom->root->properties->width,
19                        window->dom->root->properties->height);
20        gaycko_print_dom(window);
[4750]21}
[4746]22
[4750]23
[4753]24void gaycko_print_dom(gWindow *window) {
25        gaycko_print_node(window->dom->root, window);
[4750]26}
27
[4752]28void gaycko_print_node(gNode *node, gWindow *window) {
[4760]29        unsigned int c = 0;
[4764]30
31        switch(node->type) {
[4758]32                case ELEM_TEXT:
[4768]33            if(!strcmp(node->text, " ")) break;
[4764]34                        caca_put_str(window->cv, node->properties->x, node->properties->y, node->text);
35                        break;
36                case ELEM_HR:
[4758]37                        caca_draw_line(window->cv,
[4764]38                                        node->properties->x, node->properties->y,
39                                        node->properties->x+node->parent->properties->width, node->properties->y,
40                                        '-');
41                        break;
42                default:
43
44                        break;
[4758]45        }
[4764]46
47        for(c = 0; c < node->children_count; c++) {
48                gaycko_print_node(node->children[c], window);
49        }
50}
Note: See TracBrowser for help on using the repository browser.