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

Last change on this file since 4764 was 4764, checked in by Jean-Yves Lamoureux, 9 years ago
  • Fixed indentation (nia nia nia)
File size: 1.5 KB
Line 
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 */
12#include "renderer.h"
13
14void gaycko_render(gWindow *window) {
15        window->dom->root->properties->width = window->width;
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);
21}
22
23
24void gaycko_print_dom(gWindow *window) {
25        gaycko_print_node(window->dom->root, window);
26}
27
28void gaycko_print_node(gNode *node, gWindow *window) {
29        unsigned int c = 0;
30
31        switch(node->type) {
32                case ELEM_TEXT:
33                        caca_set_color_argb(window->cv, 0, 0xFFFF);
34                        caca_put_str(window->cv, node->properties->x, node->properties->y, node->text);
35                        break;
36                case ELEM_HR:
37                        caca_draw_line(window->cv,
38                                        node->properties->x, node->properties->y,
39                                        node->properties->x+node->parent->properties->width, node->properties->y,
40                                        '-');
41                        printf("Line parent is '%s', width %d\n", node->parent->name, node->parent->properties->width);
42                        break;
43                default:
44
45                        break;
46        }
47
48        for(c = 0; c < node->children_count; c++) {
49                gaycko_print_node(node->children[c], window);
50        }
51}
Note: See TracBrowser for help on using the repository browser.