• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ drawtext函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: edit_draw

void edit_draw(EDIT *edit, int x, int y, int width, int height)
{
    if((width - 4 * SCALE - SCROLL_WIDTH) < 0) {
        return;
    }

    if(utox_window_baseline && y > utox_window_baseline - font_small_lineheight - 4 * SCALE) {
        y = utox_window_baseline - font_small_lineheight - 4 * SCALE;
    }

    edit->width = width -4 * SCALE - (edit->multiline ? SCROLL_WIDTH : 0);
    edit->height = height - 4 * SCALE;

    if(!edit->noborder) {
        framerect(x, y, x + width, y + height, (edit == active_edit) ? BLUE : (edit->mouseover ? C_GRAY2 : C_GRAY));
    }
    drawrect(x + 1, y + 1, x + width - 1, y + height - 1, WHITE);

    setfont(FONT_TEXT);
    setcolor(COLOR_TEXT);

    int yy = y;

    if(edit->multiline) {
        pushclip(x + 1, y + 1, width - 2, height - 2);

        SCROLLABLE *scroll = edit->scroll;
        scroll->content_height = text_height(width - 4 * SCALE - SCROLL_WIDTH, font_small_lineheight, edit->data, edit->length) + 4 * SCALE;
        scroll_draw(scroll, x, y, width, height);
        yy -= scroll_gety(scroll, height);
    }


    if(!edit->length && maybe_i18nal_string_is_valid(&edit->empty_str)) {
        STRING* empty_str_text = maybe_i18nal_string_get(&edit->empty_str);
        setcolor(C_GRAY2);
        drawtext(x + 2 * SCALE, yy + 2 * SCALE, empty_str_text->str, empty_str_text->length);
    }

    _Bool a = (edit == active_edit);
    drawtextmultiline(x + 2 * SCALE, x + width - 2 * SCALE - (edit->multiline ? SCROLL_WIDTH : 0), yy + 2 * SCALE, y, y + height, font_small_lineheight, edit->data, edit->length,
                      a ? edit_sel.start : STRING_IDX_MAX, a ? edit_sel.length : STRING_IDX_MAX, edit->multiline);

    if(edit->multiline) {
        popclip();
    }
}
开发者ID:Antonius-git,项目名称:uTox,代码行数:47,代码来源:edit.c


示例2: usb_dnld_hook

int usb_dnld_hook(){
  /* These are global buffers to the packet data, its length, and the
     block address that it runs to.  The stock firmware has a bug
     in that it assumes the packet size is always 2048 bytes.
  */
  static char *packet=(char*) 0x200199f0;//2.032
  static int *packetlen=(int*) 0x2001d20c;//2.032
  static int *blockadr=(int*) 0x2001d208;//2.032
  static char *dfu_state=(char*) 0x2001d405;//2.032
  static char **dfu_target_adr=(char**) 0x2000112c; //2.032
  
  //Don't know what these do.
  //char *thingy=(char*) 0x2001d276;
  char *thingy2=(char*) 0x2001d041;
  
  /* DFU transfers begin at block 2, and special commands hook block
     0.  We'll use block 1, because it handily fits in the gap without
     breaking backward compatibility with the older code.
   */
  if(*blockadr==1){
    switch(packet[0]){
    case TDFU_DMESG:
      //The DMESG buffer might move, so this command
      //sets the target address to the DMESG buffer.
      *dfu_target_adr=dmesg_start;
      break;
    case TDFU_PRINT: // 0x80, u8 x, u8 y, u8 str[].
      drawtext((wchar_t *) (packet+3),
	       packet[1],packet[2]);
      break;
    }
    
    thingy2[0]=0;
    thingy2[1]=0;
    thingy2[2]=0;
    thingy2[3]=3;
    *dfu_state=3;
    
    *blockadr=0;
    *packetlen=0;
    return 0;
  }else{
    /* For all other blocks, we default to the internal handler.
     */
    return usb_dnld_handle();
  }
}
开发者ID:hewittc,项目名称:md380tools,代码行数:47,代码来源:usb.c


示例3: dropdown_drawactive

void dropdown_drawactive(void)
{
    DROPDOWN *b = active;
    if(!b) {
        return;
    }

    int x = active_x, y = active_y, w = active_width, h = active_height;

    setfont(FONT_TEXT);
    setcolor(COLOR_TEXT);

    int i, sign = 1;

    // Increase width if needed, so that all menu items fit.
    for(i = 0; i != b->dropcount; i++) {
        STRING* e = b->ondisplay(i, b);
        int needed_w = textwidth(e->str, e->length) + 4 * SCALE;
        if(w < needed_w) {
            w = needed_w;
        }
    }

    if(y + h * b->dropcount > height) {
        y -= h * (b->dropcount - 1);
        sign = -1;
    }

    drawrect(x, y, x + w, y + h * b->dropcount, WHITE);
    framerect(x, y, x + w, y + h * b->dropcount, BLUE);

    if(sign == -1) {
        y += h * (b->dropcount - 1);
    }

    for(i = 0; i != b->dropcount; i++) {
        int j = index(b, i);
        STRING* e = b->ondisplay(j, b);
        if(j == b->over) {
            drawrectw(x + 1, y + 1, w - 2, h - 2, C_GRAY);
        }
        drawtext(x + 2 * SCALE, y + 2 * SCALE, e->str, e->length);

        y += sign * h;
    }
}
开发者ID:aviau,项目名称:uTox,代码行数:46,代码来源:dropdown.c


示例4: luatpt_drawtext

int luatpt_drawtext(lua_State* l)
{
    char *string;
	int textx, texty, textred, textgreen, textblue, textalpha;
	textx = luaL_optint(l, 1, 0);
	texty = luaL_optint(l, 2, 0);
	string = luaL_optstring(l, 3, "");
	textred = luaL_optint(l, 4, 255);
	textgreen = luaL_optint(l, 5, 255);
	textblue = luaL_optint(l, 6, 255);
	textalpha = luaL_optint(l, 7, 255);
	if(vid_buf!=NULL){
		drawtext(vid_buf, textx, texty, string, textred, textgreen, textblue, textalpha);
		return 0;	
	}
	return -1;
}
开发者ID:321boom,项目名称:The-Powder-Toy,代码行数:17,代码来源:luaconsole.c


示例5: draw_rr_pin

static void draw_rr_pin (int inode, enum color_types color) {

/* Draws an IPIN or OPIN rr_node.  Note that the pin can appear on more    *
 * than one side of a clb.  Also note that this routine can change the     *
 * current color to BLACK.                                                 */

 int ipin, i, j, iside, iclass, iblk;
 float xcen, ycen;
 char str[BUFSIZE];

 i = rr_node[inode].xlow;
 j = rr_node[inode].ylow;
 ipin = rr_node[inode].ptc_num;
 setcolor (color);

 if (clb[i][j].type == CLB) {
    iclass = clb_pin_class[ipin];

    for (iside=0;iside<=3;iside++) {
       if (pinloc[iside][ipin] == 1) {   /* Pin exists on this side. */
          get_rr_pin_draw_coords (inode, iside, &xcen, &ycen);
          fillrect (xcen-pin_size, ycen-pin_size, xcen+pin_size, ycen+pin_size);
          sprintf (str, "%d", ipin);
          setcolor (BLACK);
          drawtext (xcen, ycen, str, 2*pin_size);
          setcolor (color);
       }
    }
 }

 else {               /* IO pad. */
    iblk = clb[i][j].u.io_blocks[ipin];

    if (i == 0) 
       iside = RIGHT;
    else if (j == 0)
       iside = TOP;
    else if (i == nx+1)
       iside = LEFT;
    else
       iside = BOTTOM;

    get_rr_pin_draw_coords (inode, iside, &xcen, &ycen);
    fillrect (xcen-pin_size, ycen-pin_size, xcen+pin_size, ycen+pin_size);
 }
}
开发者ID:BackupTheBerlios,项目名称:pvpr,代码行数:46,代码来源:draw.c


示例6: sprintf

void Transmitter::renderLevels(int width, int height) {
    char val[50];
    const int LEVEL_CORNER_X = 10;
    const int LEVEL_CORNER_Y = 400;
    
    // Draw the numeric degree/sec values from the gyros
    sprintf(val, "Pitch Rate %4.1f", _lastRotationRate.x);
    drawtext(LEVEL_CORNER_X, LEVEL_CORNER_Y, 0.10, 0, 1.0, 1, val, 0, 1, 0);
    sprintf(val, "Yaw Rate   %4.1f", _lastRotationRate.y);
    drawtext(LEVEL_CORNER_X, LEVEL_CORNER_Y + 15, 0.10, 0, 1.0, 1, val, 0, 1, 0);
    sprintf(val, "Roll Rate  %4.1f", _lastRotationRate.z);
    drawtext(LEVEL_CORNER_X, LEVEL_CORNER_Y + 30, 0.10, 0, 1.0, 1, val, 0, 1, 0);
    sprintf(val, "Pitch      %4.3f", _estimatedRotation.x);
    drawtext(LEVEL_CORNER_X, LEVEL_CORNER_Y + 45, 0.10, 0, 1.0, 1, val, 0, 1, 0);
    sprintf(val, "Yaw        %4.3f", _estimatedRotation.y);
    drawtext(LEVEL_CORNER_X, LEVEL_CORNER_Y + 60, 0.10, 0, 1.0, 1, val, 0, 1, 0);
    sprintf(val, "Roll       %4.3f", _estimatedRotation.z);
    drawtext(LEVEL_CORNER_X, LEVEL_CORNER_Y + 75, 0.10, 0, 1.0, 1, val, 0, 1, 0);
    
    //  Draw the levels as horizontal lines
    const int LEVEL_CENTER = 150;
    const float ACCEL_VIEW_SCALING = 1.f;
    glLineWidth(2.0);
    glColor4f(1, 1, 1, 1);
    glBegin(GL_LINES);
    // Gyro rates
    glVertex2f(LEVEL_CORNER_X + LEVEL_CENTER, LEVEL_CORNER_Y - 3);
    glVertex2f(LEVEL_CORNER_X + LEVEL_CENTER + _lastRotationRate.x, LEVEL_CORNER_Y - 3);
    glVertex2f(LEVEL_CORNER_X + LEVEL_CENTER, LEVEL_CORNER_Y + 12);
    glVertex2f(LEVEL_CORNER_X + LEVEL_CENTER + _lastRotationRate.y, LEVEL_CORNER_Y + 12);
    glVertex2f(LEVEL_CORNER_X + LEVEL_CENTER, LEVEL_CORNER_Y + 27);
    glVertex2f(LEVEL_CORNER_X + LEVEL_CENTER + _lastRotationRate.z, LEVEL_CORNER_Y + 27);
    // Acceleration
    glVertex2f(LEVEL_CORNER_X + LEVEL_CENTER, LEVEL_CORNER_Y + 42);
    glVertex2f(LEVEL_CORNER_X + LEVEL_CENTER + (int)(_estimatedRotation.x * ACCEL_VIEW_SCALING),
               LEVEL_CORNER_Y + 42);
    glVertex2f(LEVEL_CORNER_X + LEVEL_CENTER, LEVEL_CORNER_Y + 57);
    glVertex2f(LEVEL_CORNER_X + LEVEL_CENTER + (int)(_estimatedRotation.y * ACCEL_VIEW_SCALING),
               LEVEL_CORNER_Y + 57);
    glVertex2f(LEVEL_CORNER_X + LEVEL_CENTER, LEVEL_CORNER_Y + 72);
    glVertex2f(LEVEL_CORNER_X + LEVEL_CENTER + (int)(_estimatedRotation.z * ACCEL_VIEW_SCALING),
               LEVEL_CORNER_Y + 72);
    
    glEnd();
    //  Draw green vertical centerline
    glColor4f(0, 1, 0, 0.5);
    glBegin(GL_LINES);
    glVertex2f(LEVEL_CORNER_X + LEVEL_CENTER, LEVEL_CORNER_Y - 6);
    glVertex2f(LEVEL_CORNER_X + LEVEL_CENTER, LEVEL_CORNER_Y + 30);
    glEnd();

    
}
开发者ID:Issacchaos,项目名称:hifi,代码行数:53,代码来源:Transmitter.cpp


示例7: drawsettings_content

/* Text content for settings page */
static void drawsettings_content(int UNUSED(x), int y, int UNUSED(w), int UNUSED(height))
{
    setcolor(C_TITLE);
    setfont(FONT_TEXT);
    drawstr(LIST_RIGHT + SCALE * 5, y + SCALE * 5, NAME);

    drawstr(LIST_RIGHT + SCALE * 5, y + SCALE * 29, STATUSMESSAGE);

    drawstr(LIST_RIGHT + SCALE * 5, y + SCALE * 123, AUDIOINPUTDEVICE);
    drawstr(LIST_RIGHT + SCALE * 190, y + SCALE * 123, AUDIOFILTERING);
    drawstr(LIST_RIGHT + SCALE * 5, y + SCALE * 147, AUDIOOUTPUTDEVICE);
    drawstr(LIST_RIGHT + SCALE * 5, y + SCALE * 171, VIDEOINPUTDEVICE);

    drawstr(LIST_RIGHT + SCALE * 5, y + SCALE * 206, DPI);
    drawstr(LIST_RIGHT + SCALE * 5, y + SCALE * 230, LANGUAGE);
    drawstr(LIST_RIGHT + SCALE * 5, y + SCALE * 254, NETWORK);

    drawstr(LIST_RIGHT + SCALE * 5, y + SCALE * 266, IPV6);
    drawstr(LIST_RIGHT + SCALE * 5 + 50 * SCALE, y + SCALE * 266, UDP);

    drawstr(LIST_RIGHT + SCALE * 5, y + SCALE * 278, PROXY);

    drawstr(LIST_RIGHT + SCALE * 5, y + SCALE * 310, LOGGING);

    drawtext(LIST_RIGHT + SCALE * 132, y + SCALE * 290, (uint8_t*)":", 1);

    setfont(FONT_SELF_NAME);

    drawstr(LIST_RIGHT + SCALE * 5, y + SCALE * 54, TOXID);

    drawstr(LIST_RIGHT + SCALE * 5, y + SCALE * 76, PREVIEW);

    drawstr(LIST_RIGHT + SCALE * 5, y + SCALE * 113, DEVICESELECTION);

    drawstr(LIST_RIGHT + SCALE * 5, y + SCALE * 195, OTHERSETTINGS);

    setfont(FONT_MISC);
    setcolor(C_RED);
    drawstr(LIST_RIGHT + SCALE * 5, y + SCALE * 302, WARNING);

    setcolor(C_TITLE);
    setfont(FONT_TEXT);
    drawstr(LIST_RIGHT + SCALE * 5, y + SCALE * 334, AUDIONOTIFICATIONS);
}
开发者ID:draziw-,项目名称:uTox,代码行数:45,代码来源:ui.c


示例8: drawmenu

void
drawmenu(void) {
	int curpos;
	Item *item;

	dc->x = 0;
	dc->y = 0;
	dc->h = bh;
	drawrect(dc, 0, 0, mw, mh, True, normcol->BG);

	if(prompt && *prompt) {
		dc->w = promptw;
		drawtext(dc, prompt, selcol);
		dc->x = dc->w;
	}
	/* draw input field */
	dc->w = (lines > 0 || !matches) ? mw - dc->x : inputw;
	drawtext(dc, text, normcol);
	if((curpos = textnw(dc, text, cursor) + dc->font.height/2) < dc->w)
		drawrect(dc, curpos, (dc->h - dc->font.height)/2 + 1, 1, dc->font.height -1, True, normcol->FG);

    if(!quiet || strlen(text) > 0) {    
        if(lines > 0) {
            /* draw vertical list */
            dc->w = mw - dc->x;
            for(item = curr; item != next; item = item->right) {
                dc->y += dc->h;
                drawtext(dc, item->text, (item == sel) ? selcol : normcol);
            }
        }
        else if(matches) {
            /* draw horizontal list */
            dc->x += inputw;
            dc->w = textw(dc, "<");
            if(curr->left)
                drawtext(dc, "<", normcol);
            for(item = curr; item != next; item = item->right) {
                dc->x += dc->w;
                dc->w = MIN(textw(dc, item->text), mw - dc->x - textw(dc, ">"));
                drawtext(dc, item->text, (item == sel) ? selcol : normcol);
            }
            dc->w = textw(dc, ">");
            dc->x = mw - dc->w;
            if(next)
                drawtext(dc, ">", normcol);
        }
    }
	mapdc(dc, win, mw, mh);
}
开发者ID:OliverUv,项目名称:dmenu-q-xywh-xft,代码行数:49,代码来源:dmenu.c


示例9: handleevents

ULONG handleevents(struct Window *win, struct Screen *screen, WORD x, WORD y)
{
    struct IntuiMessage *imsg;
    WORD y1;
    struct MsgPort *port = win->UserPort;
    BOOL terminated = FALSE;
    ULONG retidcmp = 0;
	
    while (!terminated)
    {
	if ((imsg = (struct IntuiMessage *)GetMsg(port)) != NULL)
	{
	    
	    switch (imsg->Class)
	    {
	    case IDCMP_CLOSEWINDOW:
	    	terminated = TRUE;
	    	break;

	    case IDCMP_INTUITICKS:
	        y1 = drawtext(win, x, y, "Screen position: (%d, %d)               ", screen->LeftEdge, screen->TopEdge);
		y1 = drawtext(win, x, y1, "Mouse position: (%d, %d)               ", screen->MouseX, screen->MouseY);
		y1 = drawtext(win, x, y1, "ViewPort size: %dx%d               ", screen->ViewPort.DWidth, screen->ViewPort.DHeight);
		y1 = drawtext(win, x, y1, "ViewPort position: (%d, %d)               ", screen->ViewPort.DxOffset, screen->ViewPort.DyOffset);
		y1 = drawtext(win, x, y1, "RasInfo position: (%d, %d)               ", screen->ViewPort.RasInfo->RxOffset, screen->ViewPort.RasInfo->RyOffset);
		y1 = drawtext(win, x, y1, "Window position: (%d, %d)               ", win->LeftEdge, win->TopEdge);
		drawtext(win, x, y1, "Window mouse position: (%d, %d)       ",
                    win->MouseX, win->MouseY);
		break;

	    } /* switch (imsg->Class) */
	    ReplyMsg((struct Message *)imsg);
	    
	    			
	} /* if ((imsg = GetMsg(port)) != NULL) */
	else
	{
	    Wait(1L << port->mp_SigBit);
	}
    } /* while (!terminated) */
    
    return retidcmp;
	
} /* HandleEvents() */
开发者ID:michalsc,项目名称:AROS,代码行数:44,代码来源:screentest.c


示例10: drawInit

static void drawInit( int sizex, int sizey, char* seqName, char* filename, float score) {

 int i,k=0;
 int x,y;
 char* c;
 c =(char*)malloc(sizeof(char)*1000);
 


/* initialize display */
 init_graphics("RNA");


/* still picture drawing allows user to zoom, etc. */
 init_world (0.,0.,CELLSIZE*sizex,CELLSIZE*sizey);
 //event_loop(button_press, drawscreen);   

/* animation section */
 clearscreen();
 init_postscript(filename);
 clearscreen();
 
 sprintf(c, "%s%s%s%d%s%f%s", "RNA: ", seqName, ", length = ", sizex, ", energy = ",-score/1000.0, " kal/mol");
 //printf(" output string is %s\n",c);
 update_message("RNA secondary structure");
 flushinput();
 
 drawtext (sizex*CELLSIZE/2,sizey*CELLSIZE/10,c,1.0e6);
 flushinput();
 setcolor (BLACK);
 setlinewidth(1);
 setlinestyle (SOLID);
 for (i=0;i<=sizex;i++) {
    drawline (i*CELLSIZE,(sizey/2-1)*CELLSIZE,i*CELLSIZE,CELLSIZE*sizey/2);
    flushinput();
 }
 drawline(0,(sizey/2-1)*CELLSIZE, sizex*CELLSIZE, CELLSIZE*(sizey/2-1));
 drawline(0,sizey*CELLSIZE/2, sizex*CELLSIZE, CELLSIZE*sizey/2);
 flushinput();
 free(c);
}
开发者ID:mayc2,项目名称:PseudoKnot_research,代码行数:41,代码来源:PlotRna.c


示例11: drawnode

uint
drawnode(Tnode *t, Image *m, Image *clipr, Point o)
{
    int i;
    char *fs, *s;
    uint dy;
    Point oo;

    if(t == nil)
        return 0;

    t->offset = o;

    oo = Pt(o.x+Nubwidth+2, o.y);
//	if(t->draw)
//		dy = (*t->draw)(t, m, clipr, oo);
//	else{
    fs = nil;
    if(t->str)
        s = t->str;
    //	else if(t->strfn)
    //		fs = s = (*t->strfn)(t);
    else
        s = "???";
    dy = drawtext(s, m, clipr, oo);
    free(fs);
//	}

    if(t->expanded) {
        if(t->nkid == -1 && t->expand)
            (*t->expand)(t);
        oo = Pt(o.x+Nubwidth+(Linewidth-Nubwidth)/2, o.y+dy);
        for(i=0; i<t->nkid; i++)
            oo.y += drawnode(t->kid[i], m, clipr, oo);
        dy = oo.y - o.y;
    }
    drawnub(m, clipr, o, t);
    return dy;
}
开发者ID:brandondyck,项目名称:plan9port,代码行数:39,代码来源:view.c


示例12: draw_button

static void draw_button(control c, rect r)
{
	rect textrect;
	rgb up, down;
	font f;
	rgb old = currentcolour();

	clear(c);

	/* Draw the button name. */
	if (isenabled(c))
		setcolour(getforeground(c));
	else
		setcolour(Grey);
	f = gettextfont(c);
	setfont(f);
	textrect = r;
	if (ishighlighted(c))
		textrect.x += 1, textrect.y += 1;
	drawtext(textrect, Center|VCenter, getname(c));

	/* Draw button border. */
	setlinewidth(1);
	drawrect(r);
	r = insetr(r,1);

	/* Draw button shadow. */
	up = White, down = Grey;
	if (ishighlighted(c))
		up = Grey, down = LightGrey;
	else if (hasfocus(c)) {
		setcolour(Black);
		drawrect(r);
		r = insetr(r,1);
	}
	draw_shadow(r, up, down, SHADOW_WIDTH);

	setcolour(old);
}
开发者ID:Vladimir84,项目名称:rcc,代码行数:39,代码来源:buttons.c


示例13: renderhold

int renderhold(int h) {
  int i, j, x, y;
  const int shape_sz = 18;
  const int const_h = shape_sz * SHAPE_MAX_H + 6;
  if (g_state != GAME_STARTED) return h;
  drawtext(panel, X_MARGIN, h, "\nHolding:", 0xff, 0xff, 0xff, 0xff);
  h += FONT_H*2 + 3;
  drawrect(panel, X_MARGIN, h, shape_sz * SHAPE_MAX_W + 6,
           shape_sz * SHAPE_MAX_H + 6, 0xff, 0xff, 0xff, 0x7f);
  h += 3;
  if (g_hold == -1) return h+const_h;
  for (i = 0; i != g_shape[g_hold].w; ++i) {
    for (j = 0; j != g_shape[g_hold].h; ++j) {
      if (g_shape[g_hold].pixels[j][i]) {
        x = (i + g_shape[g_hold].off_x) * 18; y = j * 18;
        x += X_MARGIN + 3; y += h;
        fillrect(panel, x, y, 18, 18,
                 UNPIXRGB(g_shape[g_hold].color), 0xff);
      }
    }
  }
  return h+const_h;
}
开发者ID:shouya,项目名称:blockgame,代码行数:23,代码来源:extpanel.c


示例14: renderqueue

int renderqueue(int h) {
  int i, j, x, y, q = 0;
  const int nxt_sz = 15;
  const int oth_sz = 4;
  if (g_state != GAME_STARTED) return h;

  drawtext(panel, X_MARGIN, h, "\nNext:", 0xff, 0xff, 0xff, 0xff);
  h += FONT_H*2 + 3;

  for (i = 0; i != g_shape[g_queue[q]].w; ++i) {
    for (j = 0; j != g_shape[g_queue[q]].h; ++j) {
      if (g_shape[g_queue[q]].pixels[j][i]) {
        x = (i /*+ g_shape[g_queue[q]].off_x*/) * nxt_sz; y = j * nxt_sz;
        x += X_MARGIN; y += h;
        fillrect(panel, x, y, nxt_sz, nxt_sz,
                 UNPIXRGB(g_shape[g_queue[q]].color), 0xff);
      }
    }
  }

  for (q = 1; q != QUEUE_SIZE; ++q) {
    for (i = 0; i != g_shape[g_queue[q]].w; ++i) {
      for (j = 0; j != g_shape[g_queue[q]].h; ++j) {
        if (g_shape[g_queue[q]].pixels[j][i]) {
          x = (i /*+ g_shape[g_queue[q]].off_x*/) * oth_sz; y = j * oth_sz;
          x += X_MARGIN+nxt_sz*SHAPE_MAX_W+10; y += h;
          fillrect(panel, x, y, oth_sz, oth_sz,
                   UNPIXRGB(g_shape[g_queue[q]].color),
                   0xff-0xf0*q/QUEUE_SIZE);
        }
      }
    }
    h += SHAPE_MAX_H * oth_sz + 3;
  }

  return h; /* 6*4 + 6 */
}
开发者ID:shouya,项目名称:blockgame,代码行数:37,代码来源:extpanel.c


示例15: draw_timeline

void 
draw_timeline(BWAnal *aa) {
   double off0= (aa->c.off) / aa->rate;
   double off1= (aa->c.off + aa->c.sx * aa->c.tbase) / aa->rate;
   double step= (off1 - off0)/5;
   int log10= (int)floor(log(step) / M_LN10);
   double step10= exp(M_LN10 * log10);
   double off;
   
   if (step >= step10 * 5) step= step10*5;
   else if (step >= step10 * 2) step= step10*2;
   else step= step10;

   modf((off0 + step * 0.999) / step, &off);
   off *= step;

   clear_rect(d_tim_xx, d_tim_yy, d_tim_sx, d_tim_sy, colour[0]);

   while (off < off1) {
      int xx= d_tim_xx + (int)((off-off0) / (off1-off0) * d_tim_sx);
      char buf[32];
      
      vline(xx, d_tim_yy + d_tim_sy/2, d_tim_sy/2, colour[9]);

      if (log10 < 0)
	 sprintf(buf, "\x8E%.*f", -log10, off);
      else 
	 sprintf(buf, "\x8E%g", off);

      drawtext(disp_font, xx + 3, d_tim_yy, buf);
      off += step;
   }

   // Update
   update(d_tim_xx, d_tim_yy, d_tim_sx, d_tim_sy);
}
开发者ID:BesnikMulici,项目名称:INF-PRO-FHL,代码行数:36,代码来源:display.c


示例16: drawmenu

static void
drawmenu(void) {
	Item *item;
	int rw;

	/* use default colors */
	fprintf(stderr, "\033[0m");

	/* place cursor in first column, clear it */
	fprintf(stderr, "\033[0G");
	fprintf(stderr, "\033[K");

	if (prompt)
		drawtext(prompt, promptw, C_Reverse);

	drawtext(text, (lines==0 && matches) ? inputw : mw-promptw, C_Normal);

	if (lines > 0) {
		if (barpos != 0) resetline();
		for (rw = 0, item = curr; item != next; rw++, item = item->right) {
			fprintf(stderr, "\n");
			drawtext(item->text, mw, (item == sel) ? C_Reverse : C_Normal);
		}
		for (; rw < lines; rw++)
			fprintf(stderr, "\n\033[K");
		resetline();
	} else if (matches) {
		rw = mw-(4+promptw+inputw);
		if (curr->left)
			drawtext("<", 5 /*textw("<")*/, C_Normal);
		for (item = curr; item != next; item = item->right) {
			drawtext(item->text, MIN(textw(item->text), rw), (item == sel) ? C_Reverse : C_Normal);
			if ((rw -= textw(item->text)) <= 0) break;
		}
		if (next) {
			fprintf(stderr, "\033[%iG", mw-5);
			drawtext(">", 5 /*textw(">")*/, C_Normal);
		}

	}
	fprintf(stderr, "\033[%iG", (int)(promptw+textwn(text, cursor)-1));
}
开发者ID:larryhynes,项目名称:vis,代码行数:42,代码来源:vis-menu.c


示例17: x_unhilight_line

static void
x_unhilight_line(int line) {
	drawtext(dzen.slave_win.tbuf[line + dzen.slave_win.first_line_vis], 0, line, dzen.slave_win.alignment);
	XCopyArea(dzen.dpy, dzen.slave_win.drawable[line], dzen.slave_win.line[line], dzen.rgc,
			0, 0, dzen.slave_win.width, dzen.line_height, 0, 0);
}
开发者ID:SparklePigBang,项目名称:dzen,代码行数:6,代码来源:main.c


示例18: dropdown_drawactive

// Draw background rectangles for a dropdown
void dropdown_drawactive(void) {
    DROPDOWN *b = active;
    if(!b) {
        return;
    }

    // load colors for this style
    uint32_t color_bg,
             color_border,
             color_aoptbg,
             color_aopttext,
             color_text;

    switch(b->style) {
        case AUXILIARY_STYLE:
            color_bg = COLOR_BACKGROUND_AUX;
            color_border = COLOR_AUX_EDGE_ACTIVE;
            color_aoptbg = COLOR_AUX_ACTIVEOPTION_BACKGROUND;
            color_aopttext = COLOR_AUX_ACTIVEOPTION_TEXT;
            color_text = COLOR_AUX_TEXT;
            break;
        default:
            color_bg = COLOR_BACKGROUND_MAIN;
            color_border = COLOR_EDGE_ACTIVE;
            color_aoptbg = COLOR_ACTIVEOPTION_BACKGROUND;
            color_aopttext = COLOR_ACTIVEOPTION_TEXT;
            color_text = COLOR_MAIN_TEXT;
            break;
    }

    int x = active_x, y = active_y, w = active_width, h = active_height;

    int i, sign = 1;

    // Increase width if needed, so that all menu items fit.
    for(i = 0; i != b->dropcount; i++) {
        STRING* e = b->ondisplay(i, b);
        int needed_w = textwidth(e->str, e->length) + 4 * SCALE;
        if(w < needed_w) {
            w = needed_w;
        }
    }

    if(y + h * b->dropcount > utox_window_height) {
        y -= h * (b->dropcount - 1);
        sign = -1;
    }

    draw_rect_fill (x, y, w, h * b->dropcount, color_bg);
    draw_rect_frame(x, y, w, h * b->dropcount, color_border);

    if(sign == -1) {
        y += h * (b->dropcount - 1);
    }

    for(i = 0; i != b->dropcount; i++) {
        int j = index(b, i);
        STRING* e = b->ondisplay(j, b);
        if(j == b->over) {
            draw_rect_fill(x + 1, y + 1, w - 2, h - 2, color_aoptbg);
            setcolor(color_aopttext);
        } else {
            setcolor(color_text);
        }
        setfont(FONT_TEXT);
        drawtext(x + 2 * SCALE, y + 2 * SCALE, e->str, e->length);

        y += sign * h;
    }
}
开发者ID:Doom032,项目名称:uTox,代码行数:71,代码来源:dropdown.c


示例19: glLineWidth

void Audio::render(int screenWidth, int screenHeight) {
    if (_stream) {
        glLineWidth(2.0);
        glBegin(GL_LINES);
        glColor3f(1,1,1);
        
        int startX = 20.0;
        int currentX = startX;
        int topY = screenHeight - 40;
        int bottomY = screenHeight - 20;
        float frameWidth = 20.0;
        float halfY = topY + ((bottomY - topY) / 2.0);
        
        // draw the lines for the base of the ring buffer
        
        glVertex2f(currentX, topY);
        glVertex2f(currentX, bottomY);
        
        for (int i = 0; i < RING_BUFFER_LENGTH_FRAMES / 2; i++) {
            glVertex2f(currentX, halfY);
            glVertex2f(currentX + frameWidth, halfY);
            currentX += frameWidth;
            
            glVertex2f(currentX, topY);
            glVertex2f(currentX, bottomY);
        }
        glEnd();
        
        //  Show a bar with the amount of audio remaining in ring buffer beyond current playback
        float remainingBuffer = 0;
        timeval currentTime;
        gettimeofday(&currentTime, NULL);
        float timeLeftInCurrentBuffer = 0;
        if (_lastCallbackTime.tv_usec > 0) {
            timeLeftInCurrentBuffer = AUDIO_CALLBACK_MSECS - diffclock(&_lastCallbackTime, &currentTime);
        }
        
        if (_ringBuffer.getEndOfLastWrite() != NULL)
            remainingBuffer = _ringBuffer.diffLastWriteNextOutput() / PACKET_LENGTH_SAMPLES * AUDIO_CALLBACK_MSECS;
        
        if (_wasStarved == 0) {
            glColor3f(0, 1, 0);
        } else {
            glColor3f(0.5 + (_wasStarved / 20.0f), 0, 0);
            _wasStarved--;
        }
        
        glBegin(GL_QUADS);
        glVertex2f(startX, topY + 2);
        glVertex2f(startX + (remainingBuffer + timeLeftInCurrentBuffer)/AUDIO_CALLBACK_MSECS*frameWidth, topY + 2);
        glVertex2f(startX + (remainingBuffer + timeLeftInCurrentBuffer)/AUDIO_CALLBACK_MSECS*frameWidth, bottomY - 2);
        glVertex2f(startX, bottomY - 2);
        glEnd();
        
        if (_averagedLatency == 0.0) {
            _averagedLatency = remainingBuffer + timeLeftInCurrentBuffer;
        } else {
            _averagedLatency = 0.99f * _averagedLatency + 0.01f * (remainingBuffer + timeLeftInCurrentBuffer);
        }
        
        //  Show a yellow bar with the averaged msecs latency you are hearing (from time of packet receipt)
        glColor3f(1,1,0);
        glBegin(GL_QUADS);
        glVertex2f(startX + _averagedLatency / AUDIO_CALLBACK_MSECS * frameWidth - 2, topY - 2);
        glVertex2f(startX + _averagedLatency / AUDIO_CALLBACK_MSECS * frameWidth + 2, topY - 2);
        glVertex2f(startX + _averagedLatency / AUDIO_CALLBACK_MSECS * frameWidth + 2, bottomY + 2);
        glVertex2f(startX + _averagedLatency / AUDIO_CALLBACK_MSECS * frameWidth - 2, bottomY + 2);
        glEnd();
        
        char out[40];
        sprintf(out, "%3.0f\n", _averagedLatency);
        drawtext(startX + _averagedLatency / AUDIO_CALLBACK_MSECS * frameWidth - 10, topY - 9, 0.10, 0, 1, 0, out, 1,1,0);
        
        //  Show a red bar with the 'start' point of one frame plus the jitter buffer
        
        glColor3f(1, 0, 0);
        int jitterBufferPels = (1.f + (float)getJitterBufferSamples() / (float)PACKET_LENGTH_SAMPLES_PER_CHANNEL) * frameWidth;
        sprintf(out, "%.0f\n", getJitterBufferSamples() / SAMPLE_RATE * 1000.f);
        drawtext(startX + jitterBufferPels - 5, topY - 9, 0.10, 0, 1, 0, out, 1, 0, 0);
        sprintf(out, "j %.1f\n", _measuredJitter);
        if (Menu::getInstance()->getAudioJitterBufferSamples() == 0) {
            drawtext(startX + jitterBufferPels - 5, bottomY + 12, 0.10, 0, 1, 0, out, 1, 0, 0);
        } else {
            drawtext(startX, bottomY + 12, 0.10, 0, 1, 0, out, 1, 0, 0);
        }
    
        glBegin(GL_QUADS);
        glVertex2f(startX + jitterBufferPels - 2, topY - 2);
        glVertex2f(startX + jitterBufferPels + 2, topY - 2);
        glVertex2f(startX + jitterBufferPels + 2, bottomY + 2);
        glVertex2f(startX + jitterBufferPels - 2, bottomY + 2);
        glEnd();

    }
}
开发者ID:heracek,项目名称:hifi,代码行数:95,代码来源:Audio.cpp


示例20: usb_dnld_hook


//.........这里部分代码省略.........
        md380_spiflash_enable();
        md380_spi_sendrecv(0xd8);
        md380_spi_sendrecv((adr>> 16) & 0xff);
        md380_spi_sendrecv((adr>>  8) & 0xff);
        md380_spi_sendrecv(adr & 0xff);
        md380_spiflash_disable();
      }  
//      md380_spiflash_wait();   // this is the problem :( 
                           // must be polled via dfu commenad?
      break;
    case TDFU_SPIFLASHWRITE_NEW: // not working, this is not the problem
      //Re-uses the dmesg transmit buffer.
      *dfu_target_adr=dmesg_tx_buf;
      adr = *((uint32_t*)(packet+1));
      size = *((uint32_t*)(packet+5));
      memset(dmesg_tx_buf,0,DMESG_SIZE);
      if (check_spi_flash_type()) {
        printf ("DFU_SPIFLASHWRITE_new %x %d %x\n", adr, size, packet+9);
        // enable write

        for (int i=0;i<size;i=i+256) {
          int page_adr;
          page_adr=adr+i;
          printf("%d %x\n",i,page_adr);
          md380_spiflash_wait();

          md380_spiflash_enable();
          md380_spi_sendrecv(0x6);
          md380_spiflash_disable();

          md380_spiflash_enable();
          md380_spi_sendrecv(0x2);
          printf("%x ", ((page_adr>> 16) & 0xff));
          md380_spi_sendrecv((page_adr>> 16) & 0xff);
          printf("%x ", ((page_adr>>  8) & 0xff));
          md380_spi_sendrecv((page_adr>>  8) & 0xff);
          printf("%x ", (page_adr & 0xff));
          md380_spi_sendrecv(page_adr & 0xff);
          for (int ii=0; ii < 256; ii++) {
            md380_spi_sendrecv(packet[9+ii+i]);
          }
          md380_spiflash_disable();
          md380_spiflash_wait();
          printf("\n");
        }
      }
      break;
    case TDFU_SPIFLASHSECURITYREGREAD:
      //Re-uses the dmesg transmit buffer.
      *dfu_target_adr=dmesg_tx_buf;
      printf("Dumping %d bytes from adr 0 SPI Flash security_registers\n",
	     DMESG_SIZE);
      md380_spiflash_security_registers_read(dmesg_tx_buf,
                                      0,
                                      3*256);
      break;

      
//Radio Commands
    case TDFU_C5000_READREG:
      //Re-uses the dmesg transmit buffer.
      *dfu_target_adr=dmesg_tx_buf;
      memset(dmesg_tx_buf,0,DMESG_SIZE);
      state=OS_ENTER_CRITICAL();
      c5000_spi0_readreg(packet[1],dmesg_tx_buf);
      OS_EXIT_CRITICAL(state);
      break;
    case TDFU_C5000_WRITEREG:
      //Re-uses the dmesg transmit buffer.
      *dfu_target_adr=dmesg_tx_buf;
      memset(dmesg_tx_buf,0,DMESG_SIZE);
      state=OS_ENTER_CRITICAL();
      c5000_spi0_writereg(packet[1],packet[2]);
      OS_EXIT_CRITICAL(state);
      break;

//Graphics commands.
    case TDFU_PRINT: // 0x80, u8 x, u8 y, u8 str[].
      drawtext((wchar_t *) (packet+3),
	       packet[1],packet[2]);
      break;
      
    case TDFU_BOX:
    default:
      printf("Unhandled DFU packet type 0x%02x.\n",packet[0]);
    }
    
    thingy2[0]=0;
    thingy2[1]=0;
    thingy2[2]=0;
    thingy2[3]=3;
    *dfu_state=3;
    
    *blockadr=0;
    *packetlen=0;
    return 0;
  }else{
    /* For all other blocks, we default to the internal handler.
     */
    return usb_dnld_handle();
开发者ID:ThorstenHi,项目名称:md380tools,代码行数:101,代码来源:usb.c



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ dri2_egl_display函数代码示例发布时间:2022-05-30
下一篇:
C++ drawstr函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap