Changeset 4762


Ignore:
Timestamp:
02/06/11 19:19:06 (2 years ago)
Author:
jylam
Message:
  • Almost correct td width handling
Location:
gaycko/trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • gaycko/trunk/src/render/position.c

    r4761 r4762  
    2727                gaycko_get_position(node->children[c], parent); 
    2828                x+=node->children[c]->properties->width; 
     29                 
     30                 
     31                gaycko_fix_table(node->children[c]); 
    2932                if(node->children[c]->properties->width>w) { 
    3033                    w = (node->children[c]->properties->width); 
    3134                } 
    32                 gaycko_fix_table(node->children[c]); 
    3335                break; 
    3436                 
     
    100102        y+=node->children[c]->properties->height; 
    101103        h+=node->children[c]->properties->height; 
    102         
    103104    } 
    104105     
     
    108109 
    109110 
    110  
    111111void gaycko_add_node_x(gNode *node, unsigned int add) { 
    112112 
    113113    unsigned int e = 0; 
    114114    for(e = 0 ; e < node->children_count; e++) { 
    115                 node->children[e]->properties->x +=add; 
     115                //gaycko_add_node_x(node->children[e], add); 
     116        //gaycko_add_node_x(node->children[e], add); 
     117        node->children[e]->properties->width += add; 
     118        node->children[e]->properties->x += add;         
    116119    } 
     120    node->properties->x += add; 
     121     
    117122} 
    118123 
  • gaycko/trunk/src/render/renderer.h

    r4760 r4762  
    2828void gaycko_fix_table(gNode *table); 
    2929void gaycko_fix_tr(gNode *tr); 
    30 unsigned int gaycko_get_td_width(gNode *tr, unsigned int td_index); 
    31 void gaycko_set_td_width(gNode *tr, unsigned td_index, unsigned int width); 
     30unsigned int gaycko_get_trtd_width(gNode *tr, unsigned int td_index); 
     31unsigned int gaycko_get_node_width(gNode *td); 
     32void gaycko_set_trtd_width(gNode *tr, unsigned td_index, unsigned int width); 
     33unsigned int gaycko_get_tr_width(gNode *tr); 
    3234void gaycko_add_node_x(gNode *node, unsigned int add); 
    3335 
  • gaycko/trunk/src/render/table.c

    r4761 r4762  
    2929    /* Scan TD's and set each correspondants to the max width */ 
    3030    unsigned int td = 0; 
     31     
    3132    for(td = 0; td < last_tr->specific.tr->td_count; td++) { 
    3233        unsigned int biggest_td = 0; 
    3334         
     35        /* Find widest at a given X offset */ 
    3436        for(e = 0 ; e < table->children_count; e++) { 
    3537            if(table->children[e]->type == ELEM_TR) { 
    36                 unsigned int td_width = gaycko_get_td_width(table->children[e], td); 
     38                unsigned int td_width = gaycko_get_trtd_width(table->children[e], td); 
    3739                if(biggest_td < td_width) { 
    3840                    biggest_td = td_width; 
     
    4042            } 
    4143        } 
     44        /* Set the others's width to the widest one */ 
    4245        for(e = 0 ; e < table->children_count; e++) { 
    4346            if(table->children[e]->type == ELEM_TR) { 
    44                 gaycko_set_td_width(table->children[e], td, biggest_td); 
     47                gaycko_set_trtd_width(table->children[e], td, biggest_td); 
    4548            } 
    4649        } 
    4750    } 
     51     
     52    table->properties->width = gaycko_get_tr_width(last_tr); 
     53    printf("Table %d wide\n", table->properties->width); 
     54     
    4855} 
     56 
     57 
     58 
     59unsigned int gaycko_get_tr_width(gNode *tr) { 
     60        unsigned int w = 0, td = 0; 
     61     
     62    for(td = 0 ; td < tr->children_count; td++) { 
     63        if(tr->children[td]->type == ELEM_TD) { 
     64            unsigned int tw = gaycko_get_node_width(tr->children[td]); 
     65            w +=  tw; 
     66            printf("TD width %d\n", tw); 
     67        } 
     68    } 
     69    printf("So TR width %d\n", w); 
     70    return w; 
     71} 
     72 
     73unsigned int gaycko_get_node_width(gNode *td) { 
     74    unsigned int e = 0; 
     75        unsigned int w = 0; 
     76    for(e = 0 ; e < td->children_count; e++) { 
     77        w+=td->properties->width; 
     78    } 
     79    return w; 
     80} 
     81 
    4982 
    5083void gaycko_fix_tr(gNode *tr) { 
     
    5992}     
    6093 
    61 unsigned int gaycko_get_td_width(gNode *tr, unsigned int td_index) { 
     94unsigned int gaycko_get_trtd_width(gNode *tr, unsigned int td_index) { 
    6295    unsigned int e = 0; 
    6396    unsigned int td = 0; 
     
    71104} 
    72105 
    73 void gaycko_set_td_width(gNode *tr, unsigned td_index, unsigned int width) { 
     106void gaycko_set_trtd_width(gNode *tr, unsigned td_index, unsigned int width) { 
    74107    unsigned int e = 0; 
    75108    unsigned int td = 0; 
     
    80113            if(td == td_index) { 
    81114                add_width = width - tr->children[e]->properties->width; 
    82             } else { 
     115            }  
     116            td++; 
     117        } 
     118    } 
     119        td = 0; 
     120    for(e = 0 ; e < tr->children_count; e++) { 
     121        if(tr->children[e]->type == ELEM_TD) { 
     122            if(td == td_index) { 
     123                 
     124            } else if(td > td_index){ 
     125                tr->children[e]->properties->width = width; 
    83126                gaycko_add_node_x(tr->children[e], add_width); 
    84127            } 
     
    86129        } 
    87130    } 
     131     
     132     
    88133} 
     134 
  • gaycko/trunk/tests/table.html

    r4759 r4762  
    44Du texte<br/> 
    55<table width=50%> 
    6 <tr><td> Cell1 </td><td> Cell2</td></tr> 
    7 <tr><td> Cell3 plus grande</td><td> Cell4</td></tr> 
     6<tr><td> Cell1 </td><td> Cell2</td><td>Cell3 large</td></tr> 
     7<tr><td> Cell4 wide too</td><td> Cell5</td><td>Cell6</td></tr> 
    88</table> 
    99</body> 
Note: See TracChangeset for help on using the changeset viewer.