您当前的位置:首页 > IT编程 > C++
| C语言 | Java | VB | VC | python | Android | TensorFlow | C++ | oracle | 学术与代码 | cnn卷积神经网络 | gnn | 图像修复 | Keras | 数据集 | Neo4j | 自然语言处理 | 深度学习 | 医学CAD | 医学影像 | 超参数 | pointnet | pytorch | 异常检测 | Transformers | 情感分类 | 知识图谱 |

自学教程:C++ text_width函数代码示例

51自学网 2021-06-03 08:47:13
  C++
这篇教程C++ text_width函数代码示例写得很实用,希望能帮到您。

本文整理汇总了C++中text_width函数的典型用法代码示例。如果您正苦于以下问题:C++ text_width函数的具体用法?C++ text_width怎么用?C++ text_width使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。

在下文中一共展示了text_width函数的28个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: render

    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);    }
开发者ID:Fru5trum,项目名称:acr,代码行数:35,


示例2: text_with_bar

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);}
开发者ID:dapus,项目名称:mmkeyosd,代码行数:29,


示例3: im_show

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]);}
开发者ID:lilydjwg,项目名称:fcitx-fbterm,代码行数:25,


示例4: render

  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;  }
开发者ID:bsegovia,项目名称:cube,代码行数:34,


示例5: read_text

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);  }
开发者ID:svn2github,项目名称:Brany_Skeldalu,代码行数:50,


示例6: text_with_text

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);}
开发者ID:dapus,项目名称:mmkeyosd,代码行数:15,


示例7: compute_spadcommand_extent

static voidcompute_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;}
开发者ID:billpage,项目名称:fricas,代码行数:31,


示例8: draw_lookup_table

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);	}}
开发者ID:L-ios,项目名称:ibus-fbterm,代码行数:31,


示例9: calculate_lookup_win

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;	}}
开发者ID:L-ios,项目名称:ibus-fbterm,代码行数:25,


示例10: endpastebutton_extent

static voidendpastebutton_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;}
开发者ID:billpage,项目名称:fricas,代码行数:27,


示例11: compute_pastebutton_extent

static voidcompute_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;}
开发者ID:billpage,项目名称:fricas,代码行数:25,


示例12: endbutton_extent

static voidendbutton_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;}
开发者ID:billpage,项目名称:fricas,代码行数:35,


示例13: compute_begin_items_extent

static voidcompute_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;}
开发者ID:billpage,项目名称:fricas,代码行数:33,


示例14: compute_box_extent

static voidcompute_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;}
开发者ID:billpage,项目名称:fricas,代码行数:28,


示例15: end_spadsrc_extent

static voidend_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;}
开发者ID:billpage,项目名称:fricas,代码行数:29,


示例16: strcpy

voidw_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;}
开发者ID:MaddTheSane,项目名称:alephone,代码行数:31,


示例17: draw_text_right

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;	}}
开发者ID:FpgaAtHome,项目名称:seti_fpga,代码行数:27,


示例18: Point

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));  }}
开发者ID:dalerank,项目名称:caesaria-game,代码行数:31,


示例19: tab

 //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;  }
开发者ID:snowr,项目名称:tesseract,代码行数:30,


示例20: render

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);}
开发者ID:mytchel,项目名称:nenu,代码行数:30,


示例21: calculate_status_win

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;	}}
开发者ID:L-ios,项目名称:ibus-fbterm,代码行数:25,


示例22: draw_item

	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);	}
开发者ID:logue,项目名称:alephone_jp,代码行数:27,


示例23: get_wide_spaced_center_offset

voidw_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
开发者ID:Aleph-One-Marathon,项目名称:alephone,代码行数:25,


示例24: text_width_list

static int text_width_list(void *ctx, word *text) {    int w = 0;    while (text) {	w += text_width(ctx, text);	text = text->next;    }    return w;}
开发者ID:mloar,项目名称:halibut,代码行数:8,


示例25: compute_table_extent

static voidcompute_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;}
开发者ID:billpage,项目名称:fricas,代码行数:58,


示例26: ui_draw_centerd_text

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));}
开发者ID:jjgod,项目名称:legend,代码行数:9,


示例27: text_width

//--------- 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);}
开发者ID:acknapp,项目名称:7kaa,代码行数:11,


示例28: text_width

//-------- 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 );}
开发者ID:mecirt,项目名称:7k2,代码行数:23,



注:本文中的text_width函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


C++ textattr函数代码示例
C++ text_to_cstring函数代码示例
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。