コード例 #1
0
ファイル: class_star.cpp プロジェクト: AndreasAakesson/cpp
void star::operator ++() {
    draw();
}
コード例 #2
0
ファイル: CCNode.cpp プロジェクト: KoalaStudio/HelloWorld
void Node::draw()
{
    auto renderer = _director->getRenderer();
    draw(renderer, _modelViewTransform, true);
}
コード例 #3
0
//------------------------------------------------------------
void ofxPolyline::draw() {
    draw(0, size()-1);
}
コード例 #4
0
ファイル: SixFringeCapture.cpp プロジェクト: karpinsn/SLS
void SixFringeCapture::decode(void)
{
  OGLStatus::logOGLErrors("SixFringeCapture - decode()");
  draw();
}
コード例 #5
0
ファイル: move.c プロジェクト: theflash193/wolf3d
void	right(t_env *e)
{
	e->angle += M_PI / 18;
	draw(e);
}
コード例 #6
0
ファイル: glow_growbar.cpp プロジェクト: siamect/proview
void GrowBar::set_range(double min, double max)
{
  max_value = max;
  min_value = min;
  draw();
}
コード例 #7
0
	int charset::draw(char c, vector2d pos)
	{
		return draw(c, pos, 1.0f);
	}
コード例 #8
0
ファイル: cols.c プロジェクト: Earnestly/plan9
Window*
coladd(Column *c, Window *w, Window *clone, int y)
{
	Rectangle r, r1;
	Window *v;
	int i, t;

	v = nil;
	r = c->r;
	r.min.y = c->tag.r.max.y+Border;
	if(y<r.min.y && c->nw>0){	/* steal half of last window by default */
		v = c->w[c->nw-1];
		y = v->body.r.min.y+Dy(v->body.r)/2;
	}
	/* look for window we'll land on */
	for(i=0; i<c->nw; i++){
		v = c->w[i];
		if(y < v->r.max.y)
			break;
	}
	if(c->nw > 0){
		if(i < c->nw)
			i++;	/* new window will go after v */
		/*
		 * if v's too small, grow it first.
		 */
		if(!c->safe || v->body.maxlines<=3){
			colgrow(c, v, 1);
			y = v->body.r.min.y+Dy(v->body.r)/2;
		}
		r = v->r;
		if(i == c->nw)
			t = c->r.max.y;
		else
			t = c->w[i]->r.min.y-Border;
		r.max.y = t;
		draw(screen, r, textcols[BACK], nil, ZP);
		r1 = r;
		y = min(y, t-(v->tag.font->height+v->body.font->height+Border+1));
		r1.max.y = min(y, v->body.r.min.y+v->body.nlines*v->body.font->height);
		r1.min.y = winresize(v, r1, FALSE);
		r1.max.y = r1.min.y+Border;
		draw(screen, r1, display->black, nil, ZP);
		r.min.y = r1.max.y;
	}
	if(w == nil){
		w = emalloc(sizeof(Window));
		w->col = c;
		draw(screen, r, textcols[BACK], nil, ZP);
		wininit(w, clone, r);
	}else{
		w->col = c;
		winresize(w, r, FALSE);
	}
	w->tag.col = c;
	w->tag.row = c->row;
	w->body.col = c;
	w->body.row = c->row;
	c->w = realloc(c->w, (c->nw+1)*sizeof(Window*));
	memmove(c->w+i+1, c->w+i, (c->nw-i)*sizeof(Window*));
	c->nw++;
	c->w[i] = w;
	savemouse(w);
	/* near but not on the button */
	moveto(mousectl, addpt(w->tag.scrollr.max, Pt(3, 3)));
	barttext = &w->body;
	c->safe = TRUE;
	return w;
}
コード例 #9
0
ファイル: cols.c プロジェクト: Earnestly/plan9
void
coldragwin(Column *c, Window *w, int but)
{
	Rectangle r;
	int i, b;
	Point p, op;
	Window *v;
	Column *nc;

	clearmouse();
	setcursor(mousectl, &boxcursor);
	b = mouse->buttons;
	op = mouse->xy;
	while(mouse->buttons == b)
		readmouse(mousectl);
	setcursor(mousectl, nil);
	if(mouse->buttons){
		while(mouse->buttons)
			readmouse(mousectl);
		return;
	}

	for(i=0; i<c->nw; i++)
		if(c->w[i] == w)
			goto Found;
	error("can't find window");

  Found:
	p = mouse->xy;
	if(abs(p.x-op.x)<5 && abs(p.y-op.y)<5){
		colgrow(c, w, but);
		winmousebut(w);
		return;
	}
	/* is it a flick to the right? */
	if(abs(p.y-op.y)<10 && p.x>op.x+30 && rowwhichcol(c->row, p)==c)
		p.x = op.x+Dx(w->r);	/* yes: toss to next column */
	nc = rowwhichcol(c->row, p);
	if(nc!=nil && nc!=c){
		colclose(c, w, FALSE);
		coladd(nc, w, nil, p.y);
		winmousebut(w);
		return;
	}
	if(i==0 && c->nw==1)
		return;			/* can't do it */
	if((i>0 && p.y<c->w[i-1]->r.min.y) || (i<c->nw-1 && p.y>w->r.max.y)
	|| (i==0 && p.y>w->r.max.y)){
		/* shuffle */
		colclose(c, w, FALSE);
		coladd(c, w, nil, p.y);
		winmousebut(w);
		return;
	}
	if(i == 0)
		return;
	v = c->w[i-1];
	if(p.y < v->tag.all.max.y)
		p.y = v->tag.all.max.y;
	if(p.y > w->r.max.y-Dy(w->tag.all)-Border)
		p.y = w->r.max.y-Dy(w->tag.all)-Border;
	r = v->r;
	r.max.y = p.y;
	if(r.max.y > v->body.r.min.y){
		r.max.y -= (r.max.y-v->body.r.min.y)%v->body.font->height;
		if(v->body.r.min.y == v->body.r.max.y)
			r.max.y++;
	}
	if(!eqrect(v->r, r)){
		draw(screen, r, textcols[BACK], nil, ZP);
		winresize(v, r, c->safe);
	}
	r.min.y = v->r.max.y;
	r.max.y = r.min.y+Border;
	draw(screen, r, display->black, nil, ZP);
	r.min.y = r.max.y;
	if(i == c->nw-1)
		r.max.y = c->r.max.y;
	else
		r.max.y = c->w[i+1]->r.min.y-Border;
	if(!eqrect(w->r, r)){
		draw(screen, r, textcols[BACK], nil, ZP);
		winresize(w, r, c->safe);
	}
	c->safe = TRUE;
    	winmousebut(w);
}
コード例 #10
0
ファイル: camera.cpp プロジェクト: Jagholin/cgsee
void Camera::draw(
    Program * program
,   const glm::mat4 & transform)
{
    return draw(program);
}
コード例 #11
0
ファイル: cols.c プロジェクト: Earnestly/plan9
void
colgrow(Column *c, Window *w, int but)
{
	Rectangle r, cr;
	int i, j, k, l, y1, y2, *nl, *ny, tot, nnl, onl, dnl, h;
	Window *v;

	for(i=0; i<c->nw; i++)
		if(c->w[i] == w)
			goto Found;
	error("can't find window");

  Found:
	cr = c->r;
	if(but < 0){	/* make sure window fills its own space properly */
		r = w->r;
		if(i==c->nw-1 || c->safe==FALSE)
			r.max.y = cr.max.y;
		else
			r.max.y = c->w[i+1]->r.min.y;
		winresize(w, r, FALSE);
		return;
	}
	cr.min.y = c->w[0]->r.min.y;
	if(but == 3){	/* full size */
		if(i != 0){
			v = c->w[0];
			c->w[0] = w;
			c->w[i] = v;
		}
		draw(screen, cr, textcols[BACK], nil, ZP);
		winresize(w, cr, FALSE);
		for(i=1; i<c->nw; i++)
			c->w[i]->body.maxlines = 0;
		c->safe = FALSE;
		return;
	}
	/* store old #lines for each window */
	onl = w->body.maxlines;
	nl = emalloc(c->nw * sizeof(int));
	ny = emalloc(c->nw * sizeof(int));
	tot = 0;
	for(j=0; j<c->nw; j++){
		l = c->w[j]->body.maxlines;
		nl[j] = l;
		tot += l;
	}
	/* approximate new #lines for this window */
	if(but == 2){	/* as big as can be */
		memset(nl, 0, c->nw * sizeof(int));
		goto Pack;
	}
	nnl = min(onl + max(min(5, w->maxlines), onl/2), tot);
	if(nnl < w->maxlines)
		nnl = (w->maxlines+nnl)/2;
	if(nnl == 0)
		nnl = 2;
	dnl = nnl - onl;
	/* compute new #lines for each window */
	for(k=1; k<c->nw; k++){
		/* prune from later window */
		j = i+k;
		if(j<c->nw && nl[j]){
			l = min(dnl, max(1, nl[j]/2));
			nl[j] -= l;
			nl[i] += l;
			dnl -= l;
		}
		/* prune from earlier window */
		j = i-k;
		if(j>=0 && nl[j]){
			l = min(dnl, max(1, nl[j]/2));
			nl[j] -= l;
			nl[i] += l;
			dnl -= l;
		}
	}
    Pack:
	/* pack everyone above */
	y1 = cr.min.y;
	for(j=0; j<i; j++){
		v = c->w[j];
		r = v->r;
		r.min.y = y1;
		r.max.y = y1+Dy(v->tag.all);
		if(nl[j])
			r.max.y += 1 + nl[j]*v->body.font->height;
		if(!c->safe || !eqrect(v->r, r)){
			draw(screen, r, textcols[BACK], nil, ZP);
			winresize(v, r, c->safe);
		}
		r.min.y = v->r.max.y;
		r.max.y += Border;
		draw(screen, r, display->black, nil, ZP);
		y1 = r.max.y;
	}
	/* scan to see new size of everyone below */
	y2 = c->r.max.y;
	for(j=c->nw-1; j>i; j--){
		v = c->w[j];
		r = v->r;
		r.min.y = y2-Dy(v->tag.all);
		if(nl[j])
			r.min.y -= 1 + nl[j]*v->body.font->height;
		r.min.y -= Border;
		ny[j] = r.min.y;
		y2 = r.min.y;
	}
	/* compute new size of window */
	r = w->r;
	r.min.y = y1;
	r.max.y = r.min.y+Dy(w->tag.all);
	h = w->body.font->height;
	if(y2-r.max.y >= 1+h+Border){
		r.max.y += 1;
		r.max.y += h*((y2-r.max.y)/h);
	}
	/* draw window */
	if(!c->safe || !eqrect(w->r, r)){
		draw(screen, r, textcols[BACK], nil, ZP);
		winresize(w, r, c->safe);
	}
	if(i < c->nw-1){
		r.min.y = r.max.y;
		r.max.y += Border;
		draw(screen, r, display->black, nil, ZP);
		for(j=i+1; j<c->nw; j++)
			ny[j] -= (y2-r.max.y);
	}
	/* pack everyone below */
	y1 = r.max.y;
	for(j=i+1; j<c->nw; j++){
		v = c->w[j];
		r = v->r;
		r.min.y = y1;
		r.max.y = y1+Dy(v->tag.all);
		if(nl[j])
			r.max.y += 1 + nl[j]*v->body.font->height;
		if(!c->safe || !eqrect(v->r, r)){
			draw(screen, r, textcols[BACK], nil, ZP);
			winresize(v, r, c->safe);
		}
		if(j < c->nw-1){	/* no border on last window */
			r.min.y = v->r.max.y;
			r.max.y += Border;
			draw(screen, r, display->black, nil, ZP);
		}
		y1 = r.max.y;
	}
	r = w->r;
	r.min.y = y1;
	r.max.y = c->r.max.y;
	draw(screen, r, textcols[BACK], nil, ZP);
	free(nl);
	free(ny);
	c->safe = TRUE;
	winmousebut(w);
}
コード例 #12
0
static void
event_loop(Display *dpy, GLXWindow win)
{
   while (1) {
      while (XPending(dpy) > 0) {
         XEvent event;
         XNextEvent(dpy, &event);
         switch (event.type) {
	 case Expose:
            /* we'll redraw below */
	    break;
	 case ConfigureNotify:
	    reshape(event.xconfigure.width, event.xconfigure.height);
	    break;
         case KeyPress:
            {
               char buffer[10];
               int code;
               code = XLookupKeysym(&event.xkey, 0);
               if (code == XK_Left) {
                  view_roty += 5.0;
               }
               else if (code == XK_Right) {
                  view_roty -= 5.0;
               }
               else if (code == XK_Up) {
                  view_rotx += 5.0;
               }
               else if (code == XK_Down) {
                  view_rotx -= 5.0;
               }
               else {
                  XLookupString(&event.xkey, buffer, sizeof(buffer),
                                NULL, NULL);
                  if (buffer[0] == 27) {
                     /* escape */
                     return;
                  }
               }
            }
         }
      }

      /* next frame */
      angle += 2.0;

      draw();
      glXSwapBuffers(dpy, win);

      /* calc framerate */
      {
         static int t0 = -1;
         static int frames = 0;
         int t = current_time();

         if (t0 < 0)
            t0 = t;

         frames++;

         if (t - t0 >= 5.0) {
            GLfloat seconds = t - t0;
            GLfloat fps = frames / seconds;
            printf("%d frames in %3.1f seconds = %6.3f FPS\n", frames, seconds,
                   fps);
            fflush(stdout);
            t0 = t;
            frames = 0;
         }
      }
   }
}
コード例 #13
0
void GrowSlider::set_range( double min_val, double max_val)
{
  max_value = max_val;
  min_value = min_val;
  draw();
}
コード例 #14
0
/*
 * Drawing-related functions
 */
void Creature::draw(WINDOW *w, int player_x, int player_y, bool inverted) const
{
    draw( w, tripoint( player_x, player_y, posz() ), inverted );
}
コード例 #15
0
ファイル: BitmapImageCairo.cpp プロジェクト: jiezh/h5vcc
void BitmapImage::draw(GraphicsContext* context, const FloatRect& dst, const FloatRect& src, ColorSpace styleColorSpace, CompositeOperator op, BlendMode blendMode)
{
    draw(context, dst, src, styleColorSpace, op, blendMode, DoNotRespectImageOrientation);
}
コード例 #16
0
ファイル: MenuManager.cpp プロジェクト: 50Wliu/sourcemod
IMenuPanel *MenuManager::RenderMenu(int client, menu_states_t &md, ItemOrder order)
{
	IBaseMenu *menu = md.menu;

	if (!menu)
	{
		return NULL;
	}

	struct
	{
		unsigned int position;
		ItemDrawInfo draw;
	} drawItems[10];

	/* Figure out how many items to draw */
	IMenuStyle *style = menu->GetDrawStyle();
	unsigned int pgn = menu->GetPagination();
	unsigned int maxItems = style->GetMaxPageItems();
	bool exitButton = (menu->GetMenuOptionFlags() & MENUFLAG_BUTTON_EXIT) == MENUFLAG_BUTTON_EXIT;
	bool novoteButton = (menu->GetMenuOptionFlags() & MENUFLAG_BUTTON_NOVOTE) == MENUFLAG_BUTTON_NOVOTE;

	if (pgn != MENU_NO_PAGINATION)
	{
		maxItems = pgn;
	}
	else if (exitButton)
	{
		maxItems--;
	}

	if (novoteButton)
	{
		maxItems--;
	}

	/* This is very not allowed! */
	if (maxItems < 2)
	{
		return NULL;
	}

	unsigned int totalItems = menu->GetItemCount();
	unsigned int startItem = 0;

	/* For pagination, find the starting point. */
	if (pgn != MENU_NO_PAGINATION)
	{
		if (order == ItemOrder_Ascending)
		{
			startItem = md.lastItem;
			/* This shouldn't happen with well-coded menus.
			 * If the item is out of bounds, switch the order to
			 * Items_Descending and make us start from the top.
			 */
			if (startItem >= totalItems)
			{
				startItem = totalItems - 1;
				order = ItemOrder_Descending;
			}
		}
		else if (order == ItemOrder_Descending)
		{
			startItem = md.firstItem;
			/* This shouldn't happen with well-coded menus.
			 * If searching backwards doesn't give us enough room,
			 * start from the beginning and change to ascending.
			 */
			if (startItem <= maxItems)
			{
				startItem = 0;
				order = ItemOrder_Ascending;
			}
		}
	}

	/* Get our Display pointer and initialize some crap */
	IMenuPanel *panel = menu->CreatePanel();
	IMenuHandler *mh = md.mh;
	bool foundExtra = false;
	unsigned int extraItem = 0;

	if (panel == NULL)
	{
		return NULL;
	}

	/**
	 * We keep searching until:
	 * 1) There are no more items
	 * 2) We reach one OVER the maximum number of slot items
	 * 3) We have reached maxItems and pagination is MENU_NO_PAGINATION
	 */
	unsigned int i = startItem;
	unsigned int foundItems = 0;
	while (totalItems)
	{
		ItemDrawInfo &dr = drawItems[foundItems].draw;
		/* Is the item valid? */
		if (menu->GetItemInfo(i, &dr) != NULL)
		{
			/* Ask the user to change the style, if necessary */
			mh->OnMenuDrawItem(menu, client, i, dr.style);
			/* Check if it's renderable */
			if (IsSlotItem(panel, dr.style))
			{
				/* If we've already found the max number of items,
				 * This means we should just cancel out and log our
				 * "last item."
				 */
				if (foundItems >= maxItems)
				{
					foundExtra = true;
					extraItem = i;
					break;
				}
				drawItems[foundItems++].position = i;
			}
		}
		/* If there's no pagination, stop once the menu is full. */
		if (pgn == MENU_NO_PAGINATION)
		{
			/* If we've filled up, then stop */
			if (foundItems >= maxItems)
			{
				break;
			}
		}
		/* If we're descending and this is the first item, stop */
		if (order == ItemOrder_Descending)
		{
			if (i == 0)
			{
				break;
			}
			i--;
		} 
		/* If we're ascending and this is the last item, stop */
		else if (order == ItemOrder_Ascending)
		{
			if (i >= totalItems - 1)
			{
				break;
			}
			i++;
		}
	}

	/* There were no items to draw! */
	if (!foundItems)
	{
		panel->DeleteThis();
		return NULL;
	}

	bool displayPrev = false;
	bool displayNext = false;

	/* This is an annoying process.
	 * Skip it for non-paginated menus, which get special treatment.
	 */
	if (pgn != MENU_NO_PAGINATION)
	{
		if (foundExtra)
		{
			if (order == ItemOrder_Descending)
			{
				displayPrev = true;
				md.firstItem = extraItem;
			}
			else if (order == ItemOrder_Ascending)
			{
				displayNext = true;
				md.lastItem = extraItem;
			}
		}

		unsigned int lastItem = 0;
		ItemDrawInfo dr;
		/* Find the last feasible item to search from. */
		if (order == ItemOrder_Descending)
		{
			lastItem = drawItems[0].position;
			if (lastItem >= totalItems - 1)
			{
				goto skip_search;
			}
			while (++lastItem < totalItems)
			{
				if (menu->GetItemInfo(lastItem, &dr) != NULL)
				{
					mh->OnMenuDrawItem(menu, client, lastItem, dr.style);
					if (IsSlotItem(panel, dr.style))
					{
						displayNext = true;
						md.lastItem = lastItem;
						break;
					}
				}
			}
		}
		else if (order == ItemOrder_Ascending)
		{
			lastItem = drawItems[0].position;
			if (lastItem == 0)
			{
				goto skip_search;
			}
			lastItem--;
			while (lastItem != 0)
			{
				if (menu->GetItemInfo(lastItem, &dr) != NULL)
				{
					mh->OnMenuDrawItem(menu, client, lastItem, dr.style);
					if (IsSlotItem(panel, dr.style))
					{
						displayPrev = true;
						md.firstItem = lastItem;
						break;
					}
				}
				lastItem--;
			}
		}
	}

skip_search:

	/* Draw the item according to the order */
	menu_slots_t *slots = md.slots;
	unsigned int position = 0;			/* Keep track of the last position */

	if (novoteButton)
	{
		char text[50];
		if (!logicore.CoreTranslate(text, sizeof(text), "%T", 2, NULL, "No Vote", &client))
		{
			UTIL_Format(text, sizeof(text), "No Vote");
		}
		ItemDrawInfo dr(text, 0);
		position = panel->DrawItem(dr);
		slots[position].type = ItemSel_Exit;
		position++;
	}

	if (order == ItemOrder_Ascending)
	{
		md.item_on_page = drawItems[0].position;
		for (unsigned int i = 0; i < foundItems; i++)
		{
			ItemDrawInfo &dr = drawItems[i].draw;
			if ((position = mh->OnMenuDisplayItem(menu, client, panel, drawItems[i].position, dr)) == 0)
			{
				position = panel->DrawItem(dr);
			}
			if (position != 0)
			{
				slots[position].item = drawItems[i].position;
				if ((dr.style & ITEMDRAW_DISABLED) == ITEMDRAW_DISABLED)
				{
					slots[position].type = ItemSel_None;
				}
				else
				{
					slots[position].type = ItemSel_Item;
				}
			}
		}
	}
	else if (order == ItemOrder_Descending)
	{
		unsigned int i = foundItems;
		/* NOTE: There will always be at least one item because
		 * of the check earlier.
		 */
		md.item_on_page = drawItems[foundItems - 1].position;
		while (i--)
		{
			ItemDrawInfo &dr = drawItems[i].draw;
			if ((position = mh->OnMenuDisplayItem(menu, client, panel, drawItems[i].position, dr)) == 0)
			{
				position = panel->DrawItem(dr);
			}
			if (position != 0)
			{
				slots[position].item = drawItems[i].position;
				if ((dr.style & ITEMDRAW_DISABLED) == ITEMDRAW_DISABLED)
				{
					slots[position].type = ItemSel_None;
				}
				else
				{
					slots[position].type = ItemSel_Item;
				}
			}
		}
	}

	/* Now, we need to check if we need to add anything extra */
	if (pgn != MENU_NO_PAGINATION || exitButton)
	{
		bool canDrawDisabled = panel->CanDrawItem(ITEMDRAW_DISABLED|ITEMDRAW_CONTROL);
		bool exitBackButton = false;
		char text[50];

		if (pgn != MENU_NO_PAGINATION
			&& (menu->GetMenuOptionFlags() & MENUFLAG_BUTTON_EXITBACK) == MENUFLAG_BUTTON_EXITBACK)
		{
			exitBackButton = true;
		}

		/* Calculate how many items we are allowed for control stuff */
		unsigned int padding = style->GetMaxPageItems() - maxItems;
		
		/* Add the number of available slots */
		padding += (maxItems - foundItems);

		/* Someday, if we are able to re-enable this, we will be very lucky men. */
#if 0
		if (!style->FeatureExists(MenuStyleFeature_ImplicitExit))
		{
#endif
		/* Even if we don't draw an exit button, we invalidate the slot. */
		padding--;
#if 0
		} else {
			/* Otherwise, we don't draw anything and leave the slot available */
			exitButton = false;
		}
#endif

		if (pgn != MENU_NO_PAGINATION)
		{
			/* Subtract two slots for the displayNext/displayPrev padding */
			padding -= 2;
		}

		/* If we have an "Exit Back" button and the space to draw it, do so. */
		if (exitBackButton)
		{
			if (!displayPrev)
			{
				displayPrev = true;
			}
			else
			{
				exitBackButton = false;
			}
		}

		/**
		 * We allow next/prev to be undrawn if neither exists.
		 * Thus, we only need padding if one of them will be drawn,
		 * or the exit button will be drawn.
		 */
		ItemDrawInfo padItem(NULL, ITEMDRAW_SPACER);
		if (exitButton || (displayNext || displayPrev))
		{
			/* If there are no control options,
			 * Instead just pad with invisible slots.
			 */
			if (!displayPrev && !displayPrev)
			{
				padItem.style = ITEMDRAW_NOTEXT;
			}
			/* Add spacers so we can pad to the end */
			for (unsigned int i=0; i<padding; i++)
			{
				position = panel->DrawItem(padItem);
				slots[position].type = ItemSel_None;
			}
		}

		/* Put a fake spacer before control stuff, if possible */
		if ((displayPrev || displayNext) || exitButton)
		{
			ItemDrawInfo draw("", ITEMDRAW_RAWLINE|ITEMDRAW_SPACER);
			panel->DrawItem(draw);
		}

		ItemDrawInfo dr(text, 0);

		/**
		 * If we have one or the other, we need to have spacers for both.
		 */
		if (pgn != MENU_NO_PAGINATION)
		{
			if (displayPrev || displayNext)
			{
				/* PREVIOUS */
				ItemDrawInfo padCtrlItem(NULL, ITEMDRAW_SPACER|ITEMDRAW_CONTROL);
				if (displayPrev || canDrawDisabled)
				{
					if (exitBackButton)
					{
						if (!logicore.CoreTranslate(text, sizeof(text), "%T", 2, NULL, "Back", &client))
						{
							UTIL_Format(text, sizeof(text), "Back");
						}
						dr.style = ITEMDRAW_CONTROL;
						position = panel->DrawItem(dr);
						slots[position].type = ItemSel_ExitBack;
					}
					else
					{
						if (!logicore.CoreTranslate(text, sizeof(text), "%T", 2, NULL, "Previous", &client))
						{
							UTIL_Format(text, sizeof(text), "Previous");
						}
						dr.style = (displayPrev ? 0 : ITEMDRAW_DISABLED)|ITEMDRAW_CONTROL;
						position = panel->DrawItem(dr);
						slots[position].type = ItemSel_Back;
					}
				}
				else if (displayNext || exitButton)
				{
					/* If we can't display this, and there is an exit button,
					 * we need to pad!
					 */
					position = panel->DrawItem(padCtrlItem);
					slots[position].type = ItemSel_None;
				}

				/* NEXT */
				if (displayNext || canDrawDisabled)
				{
					if (!logicore.CoreTranslate(text, sizeof(text), "%T", 2, NULL, "Next", &client))
					{
						UTIL_Format(text, sizeof(text), "Next");
					}
					dr.style = (displayNext ? 0 : ITEMDRAW_DISABLED)|ITEMDRAW_CONTROL;
					position = panel->DrawItem(dr);
					slots[position].type = ItemSel_Next;
				}
				else if (exitButton)
				{
					/* If we can't display this,
					 * but there is an "exit" button, we need to pad!
					 */
					position = panel->DrawItem(padCtrlItem);
					slots[position].type = ItemSel_None;
				}
			}
			else
			{
				/* Otherwise, bump to two slots! */
				ItemDrawInfo numBump(NULL, ITEMDRAW_NOTEXT);
				position = panel->DrawItem(numBump);
				slots[position].type = ItemSel_None;
				position = panel->DrawItem(numBump);
				slots[position].type = ItemSel_None;
			}
		}

		/* EXIT */
		if (exitButton)
		{
			if (!logicore.CoreTranslate(text, sizeof(text), "%T", 2, NULL, "Exit", &client))
			{
				UTIL_Format(text, sizeof(text), "Exit");
			}
			dr.style = ITEMDRAW_CONTROL;
			position = panel->DrawItem(dr);
			slots[position].type = ItemSel_Exit;
		}
	}

	/* Lastly, fill in any slots we could have missed */
	for (unsigned int i = position + 1; i < 10; i++)
	{
		slots[i].type = ItemSel_None;
	}

	/* Do title stuff */
	mh->OnMenuDisplay(menu, client, panel);
	panel->DrawTitle(menu->GetDefaultTitle(), true);

	return panel;
}
コード例 #17
0
ファイル: glow_growbar.cpp プロジェクト: siamect/proview
void GrowBar::set_highlight(int on)
{
  highlight = on;
  draw();
}
コード例 #18
0
void GUIDisplayVisitor::visit(Component* component)
{
    vector<int> layerCounter;
    int y = 0;
    draw(component, 0, y);
}
コード例 #19
0
ファイル: main.cpp プロジェクト: ArthurAlensky/Tank
void myDisplay()
{
	RegenerateShadowMap();

		glMatrixMode(GL_PROJECTION);
		glLoadIdentity();
		gluPerspective(45.0, (double)gWinWidth/(double)gWinHeight, 0.1, 1000.0);
		glMatrixMode(GL_MODELVIEW);
		glLoadIdentity();
		caculateCameraView(gViewMode);
		camera.view();
		glViewport(0, 0, gWinWidth, gWinHeight);
	glPushMatrix();
		glTranslatef(lightPosition[0], lightPosition[1], lightPosition[2]);
		glColor3ub(255, 255, 40);
		gluSphere(gluNewQuadric(), 1.0, 60, 60);
	glPopMatrix();

	//------------------------------------------------------------------

	// Track light position
	glLightfv(GL_LIGHT0, GL_POSITION, lightPosition);
			glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
	// Because there is no support for an "ambient"
	// shadow compare fail value, we'll have to
	// draw an ambient pass first...
	glLightfv(GL_LIGHT0, GL_AMBIENT, lowAmbient);
	glLightfv(GL_LIGHT0, GL_DIFFUSE, lowDiffuse);

	// Draw objects in the scene
	draw();

	glLightfv(GL_LIGHT0, GL_AMBIENT, ambientLight);
	glLightfv(GL_LIGHT0, GL_DIFFUSE, diffuseLight);

	// Set up shadow comparison
	glEnable(GL_TEXTURE_2D);
	glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_MODE, GL_COMPARE_R_TO_TEXTURE);

	// Enable alpha test so that shadowed fragments are discarded
	glAlphaFunc(GL_GREATER, 0.9f);
	glEnable(GL_ALPHA_TEST);	

	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
	//glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
	//glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);

	// Set up the eye plane for projecting the shadow map on the scene
	glEnable(GL_TEXTURE_GEN_S);
	glEnable(GL_TEXTURE_GEN_T);
	glEnable(GL_TEXTURE_GEN_R);
	glEnable(GL_TEXTURE_GEN_Q);
	glTexGenfv(GL_S, GL_EYE_PLANE, sPlane);
	glTexGenfv(GL_T, GL_EYE_PLANE, tPlane);
	glTexGenfv(GL_R, GL_EYE_PLANE, rPlane);
	glTexGenfv(GL_Q, GL_EYE_PLANE, qPlane);

	// Draw objects in the scene
	draw();

	glDisable(GL_ALPHA_TEST);
	glDisable(GL_TEXTURE_2D);
	glDisable(GL_TEXTURE_GEN_S);
	glDisable(GL_TEXTURE_GEN_T);
	glDisable(GL_TEXTURE_GEN_R);
	glDisable(GL_TEXTURE_GEN_Q);
	// Flush drawing commands

	glutSwapBuffers();
}
コード例 #20
0
ファイル: ScreenStats.cpp プロジェクト: ReeceGrim/Marlin
	void ScreenStats::init(uint16_t index)
	{
		lcd_disable_button();
		draw();
		lcd_enable_button();
	}
コード例 #21
0
	int charset::draw(string numstr, char space, alignment align, vector2d pos)
	{
		return draw(numstr, space, align, pos, 1.0f);
	}
コード例 #22
0
void phdGenerator::draw(phdGenParams * _params) {
	draw( 0.0, 0.0, getWidth(), getHeight(), _params);
}
コード例 #23
0
ファイル: move.c プロジェクト: theflash193/wolf3d
void	left(t_env *e)
{
	e->angle -= M_PI / 18;
	draw(e);
}
コード例 #24
0
ファイル: drawer.c プロジェクト: LeFranck/T1_remake
void view(Layout* layout, int refreshInterval)
{
    the_layout = layout;

    /* Se cierra el canal para errores para que GTK no moleste */
    fclose(stderr);

    /* Inicialmente no se ha dibujado ninguna vez */
    draw_count = 0;

    /* Inicializar GTK */
    gtk_init(0, NULL);

    /* Inicializar ventana */
    GtkWidget* window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
    g_signal_connect(window, "destroy", G_CALLBACK(gtk_main_quit), NULL);

    /* Inicializar canvas */
    GtkWidget* drawingArea = gtk_drawing_area_new();
    /* Dimensiones del canvas */
    size_t width = CELL_SIZE * the_layout -> width;
    size_t height = CELL_SIZE * the_layout -> height;
    gtk_widget_set_size_request(drawingArea, width, height);
    /* Ligar eventos */
    g_signal_connect(drawingArea, "draw", G_CALLBACK(draw), NULL);

    /* Meter canvas a la ventana */
    gtk_container_add(GTK_CONTAINER(window), drawingArea);

    /* Mostrar todo */
    gtk_widget_show(drawingArea);
    gtk_widget_show(window);

    /* Cuantas decisiones debemos tomar */
    decision_count = 0;
    for(int i = 0; i < the_layout -> zone_count; i++)
    {
        decision_count += the_layout -> zones[i] -> building_count / 2;
    }
    /* El stack de decisiones del actualizador*/
    decisions = malloc(sizeof(struct choice) * decision_count);
    decision_count = 0;

    /* Registramos la funcion actualizadora */
    gdk_threads_add_timeout(refreshInterval, update, drawingArea);

    /* Comenzamos la ejecucion de GTK */
    gtk_main();

    if(pdf)
    {
        cairo_surface_t* surface;
        cairo_t *cr;

        surface = cairo_pdf_surface_create ("watcher.pdf",width, height);
        cr = cairo_create(surface);

        /* Dibuja el estado actual */
        draw(NULL, cr, NULL);

        cairo_surface_destroy(surface);
        cairo_destroy(cr);
    }
}
コード例 #25
0
ファイル: fifteen.c プロジェクト: dylanoldfield/CS50
int main(int argc, string argv[])
{
    // ensure proper usage
    if (argc != 2)
    {
        printf("Usage: fifteen d\n");
        return 1;
    }

    // ensure valid dimensions
    d = atoi(argv[1]);
    if (d < DIM_MIN || d > DIM_MAX)
    {
        printf("Board must be between %i x %i and %i x %i, inclusive.\n",
            DIM_MIN, DIM_MIN, DIM_MAX, DIM_MAX);
        return 2;
    }

    // open log
    FILE* file = fopen("log.txt", "w");
    if (file == NULL)
    {
        return 3;
    }

    // greet user with instructions
    greet();

    // initialize the board
    init();

    // accept moves until game is won
    while (true)
    {
        // clear the screen
        clear();

        // draw the current state of the board
        draw();

        // log the current state of the board (for testing)
        for (int i = 0; i < d; i++)
        {
            for (int j = 0; j < d; j++)
            {
                fprintf(file, "%i", board[i][j]);
                if (j < d - 1)
                {
                    fprintf(file, "|");
                }
            }
            fprintf(file, "\n");
        }
        fflush(file);

        // check for win
        if (won())
        {
            printf("ftw!\n");
            break;
        }

        // prompt for move
        printf("Tile to move: ");
        int tile = GetInt();
        
        // quit if user inputs 0 (for testing)
        if (tile == 0)
        {
            break;
        }

        // log move (for testing)
        fprintf(file, "%i\n", tile);
        fflush(file);

        // move if possible, else report illegality
        if (!move(tile))
        {
            printf("\nIllegal move.\n");
            usleep(500000);
        }

        // sleep thread for animation's sake
        usleep(500000);
    }
    
    // close log
    fclose(file);

    // success
    return 0;
}
コード例 #26
0
ファイル: emptywaveformwidget.cpp プロジェクト: Alppasa/mixxx
void EmptyWaveformWidget::paintEvent(QPaintEvent* event) {
    // Only render if Qt thinks it is required
    QPainter painter(this);
    draw(&painter,event);
}
コード例 #27
0
ファイル: ofFbo.cpp プロジェクト: pampam/openFrameworks
void ofFbo::draw(float x, float y) {
    draw(x, y, settings.width, settings.height);
}
コード例 #28
0
const std::string &string_input_popup::query_string( const bool loop, const bool draw_only )
{
    if( !w ) {
        create_window();
    }
    if( !ctxt ) {
        create_context();
    }
    utf8_wrapper ret( _text );
    utf8_wrapper edit( ctxt->get_edittext() );
    if( _position == -1 ) {
        _position = ret.length();
    }
    const int scrmax = _endx - _startx;
    // in output (console) cells, not characters of the string!
    int shift = 0;
    bool redraw = true;

    int ch = 0;

    do {

        if( _position < 0 ) {
            _position = 0;
        }

        const size_t left_shift = ret.substr( 0, _position ).display_width();
        if( ( int )left_shift < shift ) {
            shift = 0;
        } else if( _position < ( int )ret.length() && ( int )left_shift + 1 >= shift + scrmax ) {
            // if the cursor is inside the input string, keep one cell right of
            // the cursor visible, because the cursor might be on a multi-cell
            // character.
            shift = left_shift - scrmax + 2;
        } else if( _position == ( int )ret.length() && ( int )left_shift >= shift + scrmax ) {
            // cursor is behind the end of the input string, keep the
            // trailing '_' visible (always a single cell character)
            shift = left_shift - scrmax + 1;
        } else if( shift < 0 ) {
            shift = 0;
        }
        const size_t xleft_shift = ret.substr_display( 0, shift ).display_width();
        if( ( int )xleft_shift != shift ) {
            // This prevents a multi-cell character from been split, which is not possible
            // instead scroll a cell further to make that character disappear completely
            shift++;
        }

        if( redraw ) {
            redraw = false;
            draw( ret, edit, shift );
            wrefresh( w );
        }

        wrefresh( w );

        if( draw_only ) {
            return _text;
        }

        const std::string action = ctxt->handle_input();
        const input_event ev = ctxt->get_raw_input();
        ch = ev.type == CATA_INPUT_KEYBOARD ? ev.get_first_input() : 0;

        if( callbacks[ch] ) {
            callbacks[ch]();
        }

        // This class only registers the ANY_INPUT action by default. If the
        // client provides their own input_context with registered actions
        // besides ANY_INPUT, ignore those so that the client may handle them.
        if( action != "ANY_INPUT" ) {
            continue;
        }

        if( ch == KEY_ESCAPE ) {
            _text = std::string();
            _canceled = true;
            return _text;
        } else if( ch == '\n' ) {
            add_to_history( ret.str() );
            _text = ret.str();
            return _text;
        } else if( ch == KEY_UP ) {
            show_history( ret );
            redraw = true;
        } else if( ch == KEY_DOWN || ch == KEY_NPAGE || ch == KEY_PPAGE || ch == KEY_BTAB || ch == 9 ) {
            /* absolutely nothing */
        } else if( ch == KEY_RIGHT ) {
            if( _position + 1 <= ( int )ret.size() ) {
                _position++;
            }
            redraw = true;
        } else if( ch == KEY_LEFT ) {
            if( _position > 0 ) {
                _position--;
            }
            redraw = true;
        } else if( ch == 0x15 ) {                      // ctrl-u: delete all the things
            _position = 0;
            ret.erase( 0 );
            redraw = true;
            // Move the cursor back and re-draw it
        } else if( ch == KEY_BACKSPACE ) {
            // but silently drop input if we're at 0, instead of adding '^'
            if( _position > 0 && _position <= ( int )ret.size() ) {
                //TODO: it is safe now since you only input ascii chars
                _position--;
                ret.erase( _position, 1 );
                redraw = true;
            }
        } else if( ch == KEY_HOME ) {
            _position = 0;
            redraw = true;
        } else if( ch == KEY_END ) {
            _position = ret.size();
            redraw = true;
        } else if( ch == KEY_DC ) {
            if( _position < ( int )ret.size() ) {
                ret.erase( _position, 1 );
                redraw = true;
            }
        } else if( ch == KEY_F( 2 ) ) {
            std::string tmp = get_input_string_from_file();
            int tmplen = utf8_width( tmp );
            if( tmplen > 0 && ( tmplen + utf8_width( ret.c_str() ) <= _max_length || _max_length == 0 ) ) {
                ret.append( tmp );
            }
        } else if( ch == ERR ) {
            // Ignore the error
        } else if( !ev.text.empty() && _only_digits && !( isdigit( ev.text[0] ) || ev.text[0] == '-' ) ) {
            // ignore non-digit (and '-' is a digit as well)
        } else if( _max_length > 0 && ( int )ret.length() >= _max_length ) {
            // no further input possible, ignore key
        } else if( !ev.text.empty() ) {
            const utf8_wrapper t( ev.text );
            ret.insert( _position, t );
            _position += t.length();
            edit.erase( 0 );
            ctxt->set_edittext( edit.c_str() );
            redraw = true;
        } else if( ev.edit_refresh ) {
            const utf8_wrapper t( ev.edit );
            edit.erase( 0 );
            edit.insert( 0, t );
            ctxt->set_edittext( edit.c_str() );
            redraw = true;
        } else if( ev.edit.empty() ) {
            edit.erase( 0 );
            ctxt->set_edittext( edit.c_str() );
            redraw = true;
        }
    } while( loop == true );
    _text = ret.str();
    return _text;
}
コード例 #29
0
ファイル: chart.cpp プロジェクト: ongbe/xchart
 void Chart::draw(GraphLib::GraphRenderer *renderer)
 {
     draw(renderer, enclosingBox());
 }
コード例 #30
0
ファイル: L3Geom.cpp プロジェクト: Sotrelius/trunk
void Gl1_L6Geom::go(const shared_ptr<IGeom>& ig, const shared_ptr<Interaction>&, const shared_ptr<Body>&, const shared_ptr<Body>&, bool){ draw(ig,true,phiScale); }