… | |
… | |
1049 | xy_to_index (CFPlus::Layout self, int x, int y) |
1049 | xy_to_index (CFPlus::Layout self, int x, int y) |
1050 | CODE: |
1050 | CODE: |
1051 | { |
1051 | { |
1052 | int index, trailing; |
1052 | int index, trailing; |
1053 | pango_layout_xy_to_index (self->pl, x * PANGO_SCALE, y * PANGO_SCALE, &index, &trailing); |
1053 | pango_layout_xy_to_index (self->pl, x * PANGO_SCALE, y * PANGO_SCALE, &index, &trailing); |
1054 | RETVAL = index; |
1054 | RETVAL = index + trailing; |
1055 | } |
1055 | } |
1056 | OUTPUT: |
1056 | OUTPUT: |
1057 | RETVAL |
1057 | RETVAL |
1058 | |
1058 | |
1059 | void |
1059 | void |
… | |
… | |
1065 | |
1065 | |
1066 | EXTEND (SP, 3); |
1066 | EXTEND (SP, 3); |
1067 | PUSHs (sv_2mortal (newSViv (strong_pos.x / PANGO_SCALE))); |
1067 | PUSHs (sv_2mortal (newSViv (strong_pos.x / PANGO_SCALE))); |
1068 | PUSHs (sv_2mortal (newSViv (strong_pos.y / PANGO_SCALE))); |
1068 | PUSHs (sv_2mortal (newSViv (strong_pos.y / PANGO_SCALE))); |
1069 | PUSHs (sv_2mortal (newSViv (strong_pos.height / PANGO_SCALE))); |
1069 | PUSHs (sv_2mortal (newSViv (strong_pos.height / PANGO_SCALE))); |
|
|
1070 | } |
|
|
1071 | |
|
|
1072 | void |
|
|
1073 | index_to_line_x (CFPlus::Layout self, int index, int trailing = 0) |
|
|
1074 | PPCODE: |
|
|
1075 | { |
|
|
1076 | int line, x; |
|
|
1077 | |
|
|
1078 | pango_layout_index_to_line_x (self->pl, index, trailing, &line, &x); |
|
|
1079 | /* pango bug: line is between 1..numlines, not 0..numlines-1 */ |
|
|
1080 | |
|
|
1081 | EXTEND (SP, 2); |
|
|
1082 | PUSHs (sv_2mortal (newSViv (line - 1))); |
|
|
1083 | PUSHs (sv_2mortal (newSViv (x / PANGO_SCALE))); |
|
|
1084 | } |
|
|
1085 | |
|
|
1086 | void |
|
|
1087 | line_x_to_index (CFPlus::Layout self, int line, int x) |
|
|
1088 | PPCODE: |
|
|
1089 | { |
|
|
1090 | PangoLayoutLine *lp; |
|
|
1091 | int index, trailing; |
|
|
1092 | |
|
|
1093 | if (line < 0) |
|
|
1094 | XSRETURN_EMPTY; |
|
|
1095 | |
|
|
1096 | if (!(lp = pango_layout_get_line (self->pl, line))) |
|
|
1097 | XSRETURN_EMPTY; /* do better */ |
|
|
1098 | |
|
|
1099 | pango_layout_line_x_to_index (lp, x * PANGO_SCALE, &index, &trailing); |
|
|
1100 | |
|
|
1101 | EXTEND (SP, 2); |
|
|
1102 | if (GIMME_V == G_SCALAR) |
|
|
1103 | PUSHs (sv_2mortal (newSViv (index + trailing))); |
|
|
1104 | else |
|
|
1105 | { |
|
|
1106 | PUSHs (sv_2mortal (newSViv (index))); |
|
|
1107 | PUSHs (sv_2mortal (newSViv (trailing))); |
|
|
1108 | } |
1070 | } |
1109 | } |
1071 | |
1110 | |
1072 | void |
1111 | void |
1073 | render (CFPlus::Layout self, float x, float y, int flags = 0) |
1112 | render (CFPlus::Layout self, float x, float y, int flags = 0) |
1074 | PPCODE: |
1113 | PPCODE: |