virtual void render(int x, int y, int w) { bool selection = isselection(); int tw = max(VIRTW/4, 16*text_width("w")); if(selection) renderbg(x+w-tw, y-FONTH/6, tw, NULL); draw_text(text, x, y); int cibl = (int)strlen(input.buf); // current input-buffer length int iboff = input.pos > 14 ? (input.pos < cibl ? input.pos - 14 : cibl - 14) : input.pos==-1 ? (cibl > 14 ? cibl - 14 : 0) : 0; // input-buffer offset string showinput; int sc = 14; while(iboff > 0) { copystring(showinput, input.buf + iboff - 1, sc + 2); if(text_width(showinput) > 15 * text_width("w")) break; iboff--; sc++; } while(iboff + sc < cibl) { copystring(showinput, input.buf + iboff, sc + 2); if(text_width(showinput) > 15 * text_width("w")) break; sc++; } copystring(showinput, input.buf + iboff, sc + 1); char *masked; if(hideinput) // "mask" user input with asterisks, use for menuitemtextinputs that take passwords // TODO: better masking code? { masked = newstring(showinput); for(unsigned int i = 0; i < strlen(masked); i++) { masked[i] = '*'; } } draw_text(hideinput ? masked : showinput, x+w-tw, y, 255, 255, 255, 255, selection ? (input.pos>=0 ? (input.pos > sc ? sc : input.pos) : cibl) : -1); }
void text_with_bar(struct config *c, char *in, int error) { int nww, twb; /* If there was an error, display it instead of drawing a bar */ if(error) { text_with_text(c, in, error); return; } /* Calculate window size */ twb = text_width(&fontbig, c->text); nww = MAX(ww, twb + 30); XRectangle r = { CENTER(nww, barw), (wh/2), barw, barh }; moveresizeclear(nww, wh); draw_text(&fontbig, &fgcol, c->text, CENTER(nww, text_width(&fontbig, c->text)), CENTER(wh/2, fontbig.h)+fontbig.h); XSetForeground(dpy, gc, fgcol.pixel); /* border */ XDrawRectangles(dpy, win, gc, &r, 1); /* and bar */ r.width = (float)atoi(in)/100.0*(float)barw; XFillRectangles(dpy, win, gc, &r, 1); }
static void im_show(unsigned winid) { int sizeup = text_width(textup); int sizedown = text_width(textdown); int width = (sizeup > sizedown ? sizeup : sizedown) * currentInfo.fontWidth + MARGIN * 2; int totalheight = 3 * (MARGIN * 2 + currentInfo.fontHeight); Rectangle rect; int x, y; x = cursor_x + currentInfo.fontWidth; y = cursor_y + currentInfo.fontHeight; if (y + totalheight > currentInfo.screenHeight) y = cursor_y - totalheight - currentInfo.fontHeight * 2; if (y < 0) y = 0; if (x + width > currentInfo.screenWidth) x = currentInfo.screenWidth - width; if (x < 0) x = 0; rect.x = x; rect.y = y; DRAW_NEXT_STRING(textup, 0, textup[0]); DRAW_NEXT_STRING(textdown, 1, textdown[0]); DRAW_NEXT_STRING(imname, 2, textup[0] || textdown[0]); }
bool render(void) { if(vmenu<0) { menustack.setsize(0); return false; } if(vmenu==1) refreshservers(); gmenu &m = menus[vmenu]; sprintf_sd(title)(vmenu>1 ? "[ %s menu ]" : "%s", m.name); int mdisp = m.items.length(); int w = 0; loopi(mdisp) { int x = text_width(m.items[i].text); if(x>w) w = x; } int tw = text_width(title); if(tw>w) w = tw; int step = FONTH/4*5; int h = (mdisp+2)*step; int y = (VIRTH-h)/2; int x = (VIRTW-w)/2; blendbox(x-FONTH/2*3, y-FONTH, x+w+FONTH/2*3, y+h+FONTH, true); draw_text(title, x, y,2); y += FONTH*2; if(vmenu) { int bh = y+m.menusel*step; blendbox(x-FONTH, bh-10, x+w+FONTH, bh+FONTH+10, false); } loopj(mdisp) { draw_text(m.items[j].text, x, y, 2); y += step; } return true; }
static void read_text(FILE *txt) { int i; int xs; char ss[2] =" "; char wsp = 1; buff_pos = 0; buff_end = 0; xs = 0; do { i = fgetc(txt); if (i == EOF) break; if (i<32) i = 32; if (i =='<') { if (read_tag(txt)) { xs = 0; wsp = 1; } continue; } if (i =='[') { if (skip_section(txt)) break; continue; } if (i == 32) { if (wsp) continue; buff_pos = buff_end; wsp = 1; } else wsp = 0; if (i =='&') i = fgetc(txt); if (winconv && i>137) i = xlat_table[i-138]; ss[0] = i; xs += text_width(ss); read_buff[buff_end++] = i; if (xs>total_width && !wsp) { save_buffer(); read_buff[buff_end] = 0; xs = text_width(read_buff); } } while (1); }
void text_with_text(struct config *c, char *in, int error) { int nww, tws, twb; /* Calculate window size */ tws = text_width(&fontsmall, in); twb = text_width(&fontbig, c->text); nww = MAX(ww, MAX(tws, twb) + 20); moveresizeclear(nww, wh); draw_text(&fontbig, &fgcol, c->text, CENTER(nww, text_width(&fontbig, c->text)), CENTER(wh/2, fontbig.h)+fontbig.h); draw_text(&fontsmall, error ? &errcol : &fgcol, in, CENTER(nww, text_width(&fontsmall, in)), (wh/2)+fontsmall.h); }
static void compute_spadcommand_extent(TextNode *node) { /* * From now on if there is an example which will take over a line, then * it will start and end with a newline */ /*int height;*/ int t_width; /*int store_x = text_x;*/ /*int store_y = text_y;*/ /*int lh = present_line_height;*/ in_fricas_command = 1; push_spad_group(); /* Check to see if we should space in front of myself */ if (gInLine && node->space) text_x += inter_word_space; t_width = text_width(node->next, Endspadcommand); if (gInLine && ((text_x + t_width) > right_margin)) { start_newline(present_line_height, node); text_x = indent; } node->x = text_x; node->y = text_y; spad_node = node; }
static void draw_lookup_table() { set_im_window(LookupTableWin, lookup_table_win); if (!lookup_table_win.w) return; draw_margin(lookup_table_win, COLOR_BG); unsigned i, x = lookup_table_win.x + MARGIN, y = lookup_table_win.y + MARGIN; for (i = 0; ; i++) { IBusText *text = ibus_lookup_table_get_candidate(lookup_table, i); if (!text) break; char buf[8]; snprintf(buf, sizeof(buf), "%d.", i + 1); draw_text(x, y, COLOR_FG, COLOR_BG, buf, strlen(buf)); x += FW(2); draw_text(x, y, i == lookup_table->cursor_pos ? COLOR_ACTIVE_CANDIDATE : COLOR_FG, COLOR_BG, text->text, strlen(text->text)); x += FW(text_width(text->text)); char space = ' '; draw_text(x, y, COLOR_FG, COLOR_BG, &space, 1); x += FW(1); } unsigned endx = lookup_table_win.x + lookup_table_win.w - MARGIN; if (x < endx) { Rectangle rect = { x, y, endx - x, FH(1) }; fill_rect(rect, COLOR_BG); } }
static void calculate_lookup_win() { if (!lookup_table) { lookup_table_win.w = 0; return; } unsigned i, w = 0; for (i = 0; ; i++) { IBusText *text = ibus_lookup_table_get_candidate(lookup_table, i); if (!text) break; w += text_width(text->text); } lookup_table_win.x = cursor_x; lookup_table_win.y = get_cursor_y() + WIN_INTERVAL + GAP; lookup_table_win.w = FW(w + 3 * lookup_table->page_size) + 2 * MARGIN; lookup_table_win.h = WIN_HEIGHT; if (lookup_table_win.x + lookup_table_win.w > SW) { if (lookup_table_win.w > SW) lookup_table_win.x = 0; else lookup_table_win.x = SW - lookup_table_win.w; } }
static void endpastebutton_extent(TextNode *node) { int temp; int height; int twidth; paste_node->width = twidth = text_width(paste_node->next, Endpastebutton); height = paste_node->y; temp = text_height(paste_node->next, Endpastebutton); paste_node->height = temp - paste_node->y + line_height; if (text_y > height) { paste_node->y = temp; paste_node->width = right_margin - indent; if (gInLine) { start_newline(present_line_height, node); text_x = indent; } } else { paste_node->width = twidth; paste_node->y = text_y + paste_node->height - line_height; } pop_group_stack(); paste_node = NULL; gInLine = 1; }
static void compute_pastebutton_extent(TextNode *node) { int twidth; push_active_group(); /* First see if we should leave a little space in front of myself * */ if (gInLine && node->space) text_x += inter_word_space; twidth = text_width(node->next, Endpastebutton); if (gInLine && node->space) text_x += inter_word_space; if (text_x + twidth > right_margin && gInLine) { start_newline(present_line_height, node); text_x = indent; } node->x = text_x; node->y = text_y; paste_node = node; return; }
static void endbutton_extent(TextNode *node) { int temp; int height; int twidth; int y; int maxx; maxx = max_x(link_node, Endbutton); link_node->width = twidth = text_width(link_node->next, Endbutton); height = link_node->y; temp = text_height(link_node->next, Endbutton); link_node->height = temp - link_node->y + line_height; if (gInLine) y = text_y; else y = text_y - past_line_height; if (y > height) { link_node->y = temp; /* height + link_node->height - * normal_text_height; */ link_node->width = maxx - indent; if (gInLine) { start_newline(present_line_height, node); text_x = indent; } } else { link_node->width = twidth; link_node->y = text_y + link_node->height - line_height; } pop_group_stack(); link_node = NULL; }
static void compute_begin_items_extent(TextNode * node) { int store_x, store_y, lh; /* * This routine pushes the current item_stack, and then tries to set the * item_indent, and the indent level. It checks for an optional argument * to begin{items} and if found uses its width. */ if (gInLine) { start_newline(present_line_height, node); } store_x = text_x, store_y = text_y, lh = present_line_height; text_x = indent; push_item_stack(); gInItem++; item_indent = indent; if (node->data.node != NULL) { /* we have a desc */ gInDesc = 1; compute_text_extent(node->data.node); gInDesc = 0; item_space = text_width(node->data.node, Enddescription); text_x = store_x; text_y = store_y; present_line_height = lh; indent = item_indent + item_space; } else indent = item_indent + 30; gInLine = 0; }
static void compute_box_extent(TextNode *node) { int t_width; /* * First thing we do is see if we need to skip some space in front of the * word */ if (gInLine && node->space) text_x += inter_word_space; /* Calculate the actual width of the box */ t_width = text_width(node->next, Endbox) + 2 * box_width; if (text_x + t_width > right_margin) { start_newline(present_line_height, node); text_x = indent; } node->x = text_x; text_x = text_x + box_width; node->y = text_y - 2; node->width = t_width; node->height = line_height - 2; gInLine = 1; }
static void end_spadsrc_extent(TextNode *node) { int temp; int height; int twidth; int maxx; int y = (gInLine) ? (text_y) : (text_y - past_line_height); maxx = max_x(spad_node, Endspadsrc); twidth = spad_node->width = text_width(spad_node->next, Endspadsrc); height = spad_node->y; temp = text_height(spad_node->next, Endspadsrc); spad_node->height = temp - height + line_height; if (y > height && gInLine) { spad_node->y = temp; spad_node->width = maxx - indent; start_newline(present_line_height, node); text_x = indent; } else { spad_node->width = twidth; spad_node->y = text_y - line_height + spad_node->height; } pop_group_stack(); in_fricas_command = 0; spad_node = NULL; }
void w_players_in_game2::click(int, int) { player_entry2 thePlayerEntry; // make up a name /* int theNameLength = (local_random() % MAXIMUM_PLAYER_NAME_LENGTH) + 1; for(int i = 0; i < theNameLength; i++) thePlayerEntry.player_name[i] = 'a' + (local_random() % ('z' - 'a')); thePlayerEntry.player_name[theNameLength] = '\0'; // strcpy(thePlayerEntry.player_name, "The Big Lebowski"); */ strcpy(thePlayerEntry.player_name, sTestingNames[local_random() % 8]); // Set the size of the text thePlayerEntry.name_width = text_width(thePlayerEntry.player_name, font, style); // Make up a team-color int theTeamColor = local_random() % 8; // Get the pixel-color for the player's team (for drawing the name) thePlayerEntry.name_pixel_color = get_dialog_player_color(theTeamColor); // Set up a player image for the player (funfun) thePlayerEntry.player_image = new PlayerImage; thePlayerEntry.player_image->setRandomFlatteringView(); thePlayerEntry.player_image->setTeamColor(theTeamColor); player_entries.push_back(thePlayerEntry); dirty = true; }
void draw_text_right( GLfloat* _pos, GLfloat char_height, GLfloat line_width, GLfloat line_spacing, const char* text ) { char *q, *p; char buf[4096]; GLfloat pos[3]; memcpy(pos,_pos,sizeof(pos)); float orig = pos[0]; strlcpy(buf, text, 4096); p=buf; float w; while (*p) { q = strchr(p, '\n'); if (q) *q = 0; w = text_width(p)/66.5f; pos[0] -= w; draw_text_start(pos, char_height, line_width); draw_text_line_aux(p); draw_text_end(); pos[1] -= line_spacing; pos[0]=orig; if (!q) break; p = q+1; } }
void RenderContext::draw_text(litehtml::uint_ptr hdc, const litehtml::tchar_t* text, litehtml::uint_ptr hFont, litehtml::web_color color, const litehtml::position& pos ) { CntxFont* fnt = (CntxFont*)hFont; int x = pos.left(); int y = pos.top();// - ext.descent; fnt->font.setColor(NColor(color.alpha,color.red,color.green,color.blue)); fnt->font.draw( _picture, text, Point(x,y), true, false); int tw = 0; if(fnt->underline || fnt->strikeout) { tw = text_width(text, hFont); } if(fnt->underline) { int h = fnt->font.getTextSize(text).height(); Decorator::drawLine( _picture, Point(x, y + h + 1),Point(x + tw,y + h + 1), NColor(color.alpha, color.red, color.green, color.blue)); } if(fnt->strikeout) { Size tex = fnt->font.getTextSize("x"); int ln_y = y - tex.height() / 2.0; Decorator::drawLine( _picture, Point(x, y + ln_y - 1),Point(x + tw, y + ln_y - 1), NColor(color.alpha, color.red, color.green, color.blue)); } }
//tab is always at top of page void tab(const char *name, int color) { if(curdepth != 0) return; if(color) tcolor = color; tpos++; if(!name) name = intstr(tpos); int w = max(text_width(name) - 2*INSERT, 0); if(layoutpass) { ty = max(ty, ysize); ysize = 0; } else { cury = -ysize; int h = FONTH-2*INSERT, x1 = curx + tx, x2 = x1 + w + ((skinx[3]-skinx[2]) + (skinx[5]-skinx[4]))*SKIN_SCALE, y1 = cury - ((skiny[6]-skiny[1])-(skiny[3]-skiny[2]))*SKIN_SCALE-h, y2 = cury; bool hit = tcurrent && windowhit==this && hitx>=x1 && hity>=y1 && hitx<x2 && hity<y2; if(hit && (!guiclicktab || mousebuttons&G3D_DOWN)) *tcurrent = tpos; //roll-over to switch tab drawskin(x1-skinx[visible()?2:6]*SKIN_SCALE, y1-skiny[1]*SKIN_SCALE, w, h, visible()?10:19, 9, gui2d ? 1 : 2, light, alpha); text_(name, x1 + (skinx[3]-skinx[2])*SKIN_SCALE - (w ? INSERT : INSERT/2), y1 + (skiny[2]-skiny[1])*SKIN_SCALE - INSERT, tcolor, visible()); } tx += w + ((skinx[5]-skinx[4]) + (skinx[3]-skinx[2]))*SKIN_SCALE; }
void render() { int cursor_pos; FcChar8 t; update_size(); XftDrawRect(draw, &bg, 0, 0, w, h); if (prompt[0]) draw_string(prompt, PADDING, PADDING + ascent); if (text_input) { draw_string(text, PADDING + prompt_width, PADDING + ascent); t = text[cursor]; text[cursor] = '\0'; cursor_pos = prompt_width + text_width(text); text[cursor] = t; draw_string("_", PADDING + 1 + cursor_pos, PADDING + ascent); } if (draw_options) render_options(PADDING + ((text_input || prompt[0]) ? ascent + descent : 0)); XCopyArea(display, buf, win, gc, 0, 0, w, h, 0, 0); }
static void calculate_status_win() { if (!property_list) { status_bar_win.w = 0; return; } unsigned i, w = 0; for (i = 0; ; i++) { IBusProperty *prop = ibus_prop_list_get(property_list, i); if (!prop) break; w += text_width(prop->label->text); } status_bar_win.x = cursor_x; status_bar_win.y = get_cursor_y() + 2 * WIN_INTERVAL + GAP; status_bar_win.w = FW(w + property_list->properties->len) + 2 * MARGIN; status_bar_win.h = WIN_HEIGHT; if (status_bar_win.x + status_bar_win.w > SW) { if (status_bar_win.w > SW) status_bar_win.x = 0; else status_bar_win.x = SW - status_bar_win.w; } }
void draw_item(vector<dir_entry>::const_iterator i, SDL_Surface *s, int16 x, int16 y, uint16 width, bool selected) const { y += font->get_ascent(); set_drawing_clip_rectangle(0, x, s->h, x + width); if(i->is_directory) { string theName = i->name + "/"; draw_text(s, theName.c_str (), x, y, selected ? get_theme_color (ITEM_WIDGET, ACTIVE_STATE) : get_theme_color (ITEM_WIDGET, DEFAULT_STATE), font, style, true); } else { char date[256]; tm *time_info = localtime(&i->date); if (time_info) { strftime(date, 256, "%x %R", time_info); int date_width = text_width(date, font, style); draw_text(s, date, x + width - date_width, y, selected ? get_theme_color(ITEM_WIDGET, ACTIVE_STATE) : get_theme_color(ITEM_WIDGET, DEFAULT_STATE), font, style); set_drawing_clip_rectangle(0, x, s->h, x + width - date_width - 4); } draw_text(s, FileSpecifier::HideExtension(i->name).c_str (), x, y, selected ? get_theme_color (ITEM_WIDGET, ACTIVE_STATE) : get_theme_color (ITEM_WIDGET, DEFAULT_STATE), font, style, true); } set_drawing_clip_rectangle(SHRT_MIN, SHRT_MIN, SHRT_MAX, SHRT_MAX); }
void w_players_in_game2::draw_carnage_totals(SDL_Surface* s) const { for(size_t i = 0; i < num_valid_net_rankings; i++) { int center_x; if(clump_players_by_team) center_x = get_wide_spaced_center_offset(rect.x, rect.w, i, num_valid_net_rankings); else center_x = get_close_spaced_center_offset(rect.x, rect.w, i, num_valid_net_rankings); // Draw carnage score for player/team (list -N for N suicides) int thePlayerCarnageScore = (selected_player == i) ? -net_rankings[i].kills : net_rankings[i].kills - net_rankings[i].deaths; if(thePlayerCarnageScore == 0) strncpy(temporary, "0", 256); else sprintf(temporary, "%+d", thePlayerCarnageScore); uint16 theBiggerFontStyle = 0; font_info* theBiggerFont = get_theme_font(LABEL_WIDGET, theBiggerFontStyle); int theStringCenter = center_x - (text_width(temporary, theBiggerFont, theBiggerFontStyle | styleShadow) / 2); draw_text(s, temporary, theStringCenter, rect.y + rect.h - 1, SDL_MapRGB(s->format, 0xff, 0xff, 0xff), theBiggerFont, theBiggerFontStyle | styleShadow); } // walk through rankings } // draw_carnage_totals
static int text_width_list(void *ctx, word *text) { int w = 0; while (text) { w += text_width(ctx, text); text = text->next; } return w; }
virtual void render(int x, int y, int w) { int tk = text_width(keyname ? keyname : " "); static color capturec(0.4f, 0, 0); if(isselection()) blendbox(x+w-tk-FONTH, y-FONTH/6, x+w+FONTH, y+FONTH+FONTH/6, false, -1, capture ? &capturec : NULL); draw_text(text, x, y); draw_text(keyname, x+w-tk, y); }
static void compute_table_extent(TextNode **node) { int num_cols, num_lines; int max_width = 0, node_width, col_width; int x, y, num_entries = 0,/* n=0, */ screen_width, table_top; TextNode *front = *node; TextNode *tn; gInTable = 1; front->x = text_x; front->y = text_y; for (tn = front->next; tn->type != Endtable; num_entries++, tn = tn->next) { /* Now we need to scan the table group by group */ node_width = text_width(tn->next, Endtableitem); if (node_width > max_width) max_width = node_width; /* Get to the beginning og the next group */ for (; tn->type != Endtableitem; tn = tn->next); } col_width = max_width + min_inter_column_space; screen_width = gWindow->width - right_margin_space - indent; num_cols = screen_width / col_width; if (num_cols == 0) num_cols = 1; num_lines = num_entries / num_cols; if (num_entries % num_cols != 0) ++num_lines; if (gInLine) { start_newline(present_line_height, *node); } table_top = text_y; num_cols = num_entries / num_lines; if (num_entries % num_lines != 0) ++num_cols; col_width = screen_width / num_cols; for (tn = front->next, x = 0; x < num_cols; x++) for (y = 0; y < num_lines && tn->type != Endtable; y++) { if (num_cols == 1 && y > 0) text_y += line_height; else text_y = table_top + y * line_height; text_x = indent + x * col_width; gInLine = 0; compute_text_extent(tn->next); for (; tn->type != Endtableitem; tn = tn->next); tn = tn->next; } front->height = num_lines * line_height; front->width = screen_width; text_x = indent; if (num_cols == 1) text_y += line_height; else text_y = table_top + front->height; *node = tn; gInLine = 0; }
virtual void render(int x, int y, int w) { mitem::render(x, y, w); if(image || altfont) { int xs = 0; if(image) { glBindTexture(GL_TEXTURE_2D, image->id); glDisable(GL_BLEND); glColor3f(1, 1, 1); xs = (FONTH*image->xs)/image->ys; glBegin(GL_TRIANGLE_STRIP); glTexCoord2f(0, 0); glVertex2f(x, y); glTexCoord2f(1, 0); glVertex2f(x+xs, y); glTexCoord2f(0, 1); glVertex2f(x, y+FONTH); glTexCoord2f(1, 1); glVertex2f(x+xs, y+FONTH); glEnd(); xtraverts += 4; glEnable(GL_BLEND); } draw_text(text, !image || *text == '\t' ? x : x+xs + FONTH/2, y); if(altfont && strchr(text, '\a')) { char *r = newstring(text), *re, *l = r; while((re = strchr(l, '\a')) && re[1]) { *re = '\0'; x += text_width(l); l = re + 2; pushfont(altfont->name); draw_textf("%c", x, y, re[1]); popfont(); } delete[] r; } if(image && isselection() && !hidebigmenuimages && image->ys > FONTH) { w += FONTH; int xs = (2 * VIRTW - w) / 5, ys = (xs * image->ys) / image->xs; x = (6 * VIRTW + w - 2 * xs) / 4; y = VIRTH - ys / 2; blendbox(x - FONTH, y - FONTH, x + xs + FONTH, y + ys + FONTH, false); glBindTexture(GL_TEXTURE_2D, image->id); // I just copy&pasted this... glDisable(GL_BLEND); glColor3f(1, 1, 1); glBegin(GL_TRIANGLE_STRIP); glTexCoord2f(0, 0); glVertex2f(x, y); glTexCoord2f(1, 0); glVertex2f(x+xs, y); glTexCoord2f(0, 1); glVertex2f(x, y+ys); glTexCoord2f(1, 1); glVertex2f(x+xs, y+ys); glEnd(); xtraverts += 4; glEnable(GL_BLEND); } } else mitemmanual::render(x, y, w); }
void ui_draw_centerd_text(const char *text, int y, unsigned int c) { int w, x; w = text_width(text); x = (screen->w - w) / 2; draw_text(screen, text, x, y, color_from_int(c)); }
//--------- Begin of function Font::center_put_to_buffer ---------// void Font::center_put_to_buffer(char* dest, int destPitch, int x1, int y1, int x2, int y2, char *desStr) { int tx = x1 + ((x2-x1) - text_width(desStr))/2; int ty = y1 + ((y2-y1) - font_height)/2; if( tx<0 ) tx=0; put_to_buffer( dest, destPitch, tx, ty, desStr); }
//-------- Begin of function Font::center_put --------// // // Display the textPtr on the center of the given area // // <int> x1,y1 = the coordination of the panel // <int> x2,y2 = // <char*> desStr = the spinner description // [char] clearBack = clear background with back_color or not // (default : 0) // [cap] set all letter to Cap letter (default : 0) // // Return : <int> lastX, the x coordination of the last pixel of last font // int Font::center_put(int x1, int y1, int x2, int y2, const char* desStr, char clearBack, int cap) { int tx = x1 + ((x2-x1+1) - text_width(desStr, -1, 0, cap))/2; int ty = y1 + ((y2-y1+1) - font_height)/2; if( tx<0 ) tx=0; return put( tx, ty, desStr, clearBack, x2, cap ); }