path text_box_rep::find_box_path (SI x, SI y, SI delta, bool force, bool& found) { (void) y; (void) force; found= true; STACK_NEW_ARRAY (xpos, SI, N(str)+1); if (is_nil (xk)) fn->get_xpositions (str, xpos); else { fn->get_xpositions (str, xpos, xk->padding); x += (xk->padding - xk->left); } int prev_i, prev_x=0, i=0; while (i<N(str)) { prev_i= i; if (str[i]=='<') while ((i<N(str)) && (str[i]!='>')) i++; i++; int m= (prev_x + xpos[i]) >> 1; if ((x<m) || ((x==m) && (delta<0))) { STACK_DELETE_ARRAY (xpos); return path (prev_i); } prev_x= xpos[i]; } STACK_DELETE_ARRAY (xpos); return path (i); }
selection text_box_rep::find_selection (path lbp, path rbp) { SI x1, y1, x2, y2; metric ex; fn->get_extents (str (0, lbp->item), ex); x1= ex->x2; fn->get_extents (str (0, rbp->item), ex); x2= ex->x2; if (!is_nil (xk) && N(str) != 0) { STACK_NEW_ARRAY (xpos, SI, N(str)+1); fn->get_xpositions (str, xpos, xk->padding); SI d= xk->padding - xk->left; x1= xpos[lbp->item] - d; x2= xpos[rbp->item] - d; if (lbp->item == 0) x1 += d; if (rbp->item == 0) x2 += d; if (lbp->item == N(str)) x1 += xk->right; if (rbp->item == N(str)) x2 += xk->right; STACK_DELETE_ARRAY (xpos); } fn->get_extents (str (lbp->item, rbp->item), ex); y1= ex->y1; y2= ex->y2; return selection (rectangle (x1, y1, x2, y2), find_tree_path (lbp), find_tree_path (rbp)); }
cursor text_box_rep::find_cursor (path bp) { metric ex; cursor cu (0, 0); int l= min (bp->item, N(str)); fn->get_extents (str (0, l), ex); cu->ox= ex->x2; if (!is_nil (xk) && N(str) != 0) { STACK_NEW_ARRAY (xpos, SI, N(str)+1); fn->get_xpositions (str, xpos, xk->padding); SI d= xk->padding - xk->left; cu->ox= xpos[l] - d; if (l == 0) cu->ox += d; if (l == N(str)) cu->ox += xk->right; STACK_DELETE_ARRAY (xpos); } if (l != 0) { int k= l; tm_char_backwards (str, k); fn->get_extents (str (k, l), ex); } cu->y1= min (ex->y1, 0); cu->y2= max (ex->y2, fn->yx); cu->slope= fn->get_right_slope (str); return cu; }
static int get_position (font fn, string s, SI x) { int prev_i, prev_x=0, i=0, n=N(s); STACK_NEW_ARRAY (xpos, SI, n+1); fn->get_xpositions (s, xpos); while (i<n) { prev_i= i; if (s[i]=='<') { while ((i<n) && (s[i]!='>')) i++; if (i<n) i++; } else i++; int m= (prev_x + xpos[i]) >> 1; if (x<m) { STACK_DELETE_ARRAY (xpos); return prev_i; } prev_x= xpos[i]; } STACK_DELETE_ARRAY (xpos); return i; }
void poor_stretched_font_rep::get_xpositions (string s, SI* xpos, SI xk) { base->get_xpositions (s, xpos, xk); }
void poor_stretched_font_rep::get_xpositions (string s, SI* xpos, bool lig) { base->get_xpositions (s, xpos, lig); }
void poor_distorted_font_rep::get_xpositions (string s, SI* xpos, SI xk) { base->get_xpositions (s, xpos, xk); }
void poor_bbb_font_rep::get_xpositions (string s, SI* xpos, SI xk) { base->get_xpositions (s, xpos, xk); adjust_xpositions (s, xpos); }