Changeset 4764 for gaycko/trunk/src/render/position.c
 Timestamp:
 Feb 6, 2011, 8:22:33 PM (9 years ago)
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

gaycko/trunk/src/render/position.c
r4763 r4764 15 15 void gaycko_get_position(gNode *node, gNode *parent) { 16 16 unsigned int c = 0; 17 unsigned int w = 0; 18 unsigned int h = 0; 19 unsigned int x = node>properties>x; 20 unsigned int y = node>properties>y; 21 22 for(c = 0; c < node>children_count; c++) { 23 node>children[c]>properties>x = x; 24 node>children[c]>properties>y = y; 25 switch(node>children[c]>type) { 26 case ELEM_TABLE: 27 gaycko_get_position(node>children[c], parent); 28 x+=node>children[c]>properties>width; 29 30 gaycko_fix_table(node>children[c]); 31 if(node>children[c]>properties>width>w) { 32 w = (node>children[c]>properties>width); 33 } 34 break; 35 36 case ELEM_TR: 37 gaycko_get_position(node>children[c], parent); 38 node>children[c]>properties>height+=1; 39 x = 0; 40 w+=node>children[c]>properties>width+1; 41 break; 42 43 case ELEM_TD: 44 gaycko_get_position(node>children[c], parent); 45 x+=node>children[c]>properties>width; 46 if(node>children[c]>properties>width>w) { 47 w = (node>children[c]>properties>width); 48 } 49 break; 50 51 case ELEM_BR: 52 node>children[c]>properties>height+=1; 53 x = 0; 54 w+=node>children[c]>properties>width+1; 55 break; 56 57 case ELEM_HR: 58 node>children[c]>properties>height+=1; 59 x = 0; 60 w+=node>children[c]>properties>width+1; 61 break; 62 63 case ELEM_H1: 64 case ELEM_H2: 65 case ELEM_H3: 66 node>children[c]>properties>height+=1; 67 x = 0; 68 w+=node>children[c]>properties>width+1; 69 break; 70 71 72 case ELEM_TEXT: 73 if(parent && 74 (parent>type!=ELEM_TR && parent>type!=ELEM_TABLE)) { 75 if(node>children[c]>text) { 76 node>children[c]>properties>width = strlen(node>children[c]>text); 77 } else { 78 node>children[c]>properties>width = 0; 79 } 80 } else { 81 node>children[c]>properties>width = 0; 82 node>children[c]>properties>height = 0; 83 } 84 x+=node>children[c]>properties>width; 85 if(node>children[c]>properties>width>w) { 86 w = (node>children[c]>properties>width); 87 } 88 break; 89 90 91 default: 92 gaycko_get_position(node>children[c], node); 93 x+=node>children[c]>properties>width; 94 if(node>children[c]>properties>width>w) { 95 w = (node>children[c]>properties>width); 96 } 97 98 break; 99 } 17 unsigned int w = 0; 18 unsigned int h = 0; 19 unsigned int x = node>properties>x; 20 unsigned int y = node>properties>y; 100 21 101 y+=node>children[c]>properties>height; 102 h+=node>children[c]>properties>height; 103 } 104 105 node>properties>width = w; 106 node>properties>height = h; 22 for(c = 0; c < node>children_count; c++) { 23 node>children[c]>properties>x = x; 24 node>children[c]>properties>y = y; 25 switch(node>children[c]>type) { 26 case ELEM_TABLE: 27 gaycko_get_position(node>children[c], parent); 28 x+=node>children[c]>properties>width; 29 30 gaycko_fix_table(node>children[c]); 31 if(node>children[c]>properties>width>w) { 32 w = (node>children[c]>properties>width); 33 } 34 break; 35 36 case ELEM_TR: 37 gaycko_get_position(node>children[c], parent); 38 node>children[c]>properties>height+=1; 39 x = 0; 40 w+=node>children[c]>properties>width+1; 41 break; 42 43 case ELEM_TD: 44 gaycko_get_position(node>children[c], parent); 45 x+=node>children[c]>properties>width; 46 if(node>children[c]>properties>width>w) { 47 w = (node>children[c]>properties>width); 48 } 49 break; 50 51 case ELEM_BR: 52 node>children[c]>properties>height+=1; 53 x = 0; 54 w+=node>children[c]>properties>width+1; 55 break; 56 57 case ELEM_HR: 58 node>children[c]>properties>height+=1; 59 x = 0; 60 w+=node>children[c]>properties>width+1; 61 break; 62 63 case ELEM_H1: 64 case ELEM_H2: 65 case ELEM_H3: 66 node>children[c]>properties>height+=1; 67 x = 0; 68 w+=node>children[c]>properties>width+1; 69 break; 70 71 72 case ELEM_TEXT: 73 if(parent && 74 (parent>type!=ELEM_TR && parent>type!=ELEM_TABLE)) { 75 if(node>children[c]>text) { 76 node>children[c]>properties>width = strlen(node>children[c]>text); 77 } else { 78 node>children[c]>properties>width = 0; 79 } 80 } else { 81 node>children[c]>properties>width = 0; 82 node>children[c]>properties>height = 0; 83 } 84 x+=node>children[c]>properties>width; 85 if(node>children[c]>properties>width>w) { 86 w = (node>children[c]>properties>width); 87 } 88 break; 89 90 91 default: 92 gaycko_get_position(node>children[c], node); 93 x+=node>children[c]>properties>width; 94 if(node>children[c]>properties>width>w) { 95 w = (node>children[c]>properties>width); 96 } 97 98 break; 99 } 100 101 y+=node>children[c]>properties>height; 102 h+=node>children[c]>properties>height; 103 } 104 105 node>properties>width = w; 106 node>properties>height = h; 107 107 } 108 108 … … 110 110 void gaycko_add_node_x(gNode *node, unsigned int add) { 111 111 112 113 114 115 116 117 112 unsigned int e = 0; 113 for(e = 0 ; e < node>children_count; e++) { 114 gaycko_add_node_x(node>children[e], add); 115 } 116 node>properties>x += add; 117 118 118 } 119 119
Note: See TracChangeset
for help on using the changeset viewer.