示例#1
0
文件: buttons.c 项目: Vladimir84/rcc
static void draw_picture(control obj, rect r)
{
	image   img;
	bitmap	store = NULL;
	rgb     old = currentcolour();

	img = obj->img;
	if (has_transparent_pixels(img)) {
		store = newbitmap(r.width, r.height, 0);
		drawto(store);
		setcolour(getbackground(obj));
		fillrect(r);
	}

	if (img) {
		/* Draw the button image. */
		if (ischecked(obj))
			drawdarker(img, r, getrect(img));
		else if (isenabled(obj))
			drawimage(img, r, getrect(img));
		else
			drawimage(img, r, getrect(img)); /* never grey */
	}

	if (store != NULL) {
		drawto(obj);
		copyrect(store, pt(0,0), getrect(store));
		del(store);
	}

	setcolour(old);
}
示例#2
0
文件: buttons.c 项目: Vladimir84/rcc
static void draw_image_button(button obj, rect r)
{
	image   img;
	bitmap	store = NULL;
	rect    ir;
	rgb     up, down;
	rgb     old = currentcolour();

	img = obj->img;
	if (has_transparent_pixels(img)) {
		store = newbitmap(r.width, r.height, 0);
		drawto(store);
		setcolour(getbackground(obj));
		fillrect(r);
	}

	if (img) {
		ir = insetr(r,2);
		if (ishighlighted(obj)) /* button is pressed */
			ir.x += 1, ir.y += 1;

		/* Draw the button image. */
		if (ischecked(obj))
			drawdarker(img, ir, getrect(img));
		else if (isenabled(obj))
			drawimage(img, ir, getrect(img));
		else
			drawgreyscale(img, ir, getrect(img));

		if (ishighlighted(obj)) { /* fill the gap */
			ir.x -= 1, ir.y -= 1;
			setcolour(getbackground(obj));
			drawline(topleft(ir),topright(ir));
			drawline(topleft(ir),bottomleft(ir));
		}
	}

	/* Draw button border. */
	setcolour(getforeground(obj));
	setlinewidth(1);
	drawrect(r);

	/* Draw button shadow. */
	up = White, down = Grey;
	if (ishighlighted(obj))
		up = Grey, down = LightGrey;
	draw_shadow(insetr(r,1), up, down, 1);

	if (store != NULL) {
		drawto(obj);
		copyrect(store, pt(0,0), getrect(store));
		del(store);
	}

	setcolour(old);
}
示例#3
0
文件: main.c 项目: siebenmann/sam
int
getr(Rectangle *rp)
{
	Point p;
	Rectangle r;

	*rp = getrect(3, &mouse);
	if(rp->max.x && rp->max.x-rp->min.x<=5 && rp->max.y-rp->min.y<=5){
		p = rp->min;
		r = cmd.l[cmd.front].entire;
		*rp = screen.r;
		if(cmd.nwin==1){
			if (p.y <= r.min.y)
				rp->max.y = r.min.y;
			else if (p.y >= r.max.y)
				rp->min.y = r.max.y;
			if (p.x <= r.min.x)
				rp->max.x = r.min.x;
			else if (p.x >= r.max.x)
				rp->min.x = r.max.x;
		}
	}
	return rectclip(rp, screen.r) &&
	   rp->max.x-rp->min.x>100 && rp->max.y-rp->min.y>40;
}
示例#4
0
void Projectile::midstep(Gamestate *state, double frametime)
{
    if (isrectangular())
    {
        if (state->currentmap->collides(getrect(), std::atan2(vspeed, hspeed)))
        {
            oncollision(state);
        }
        for (auto p : state->playerlist)
        {
            // DEBUGTOOL: Replace this check with checking whether p is on enemy team
            if (p != owner)
            {
                Character *c = state->get<Player>(p)->getcharacter(state);
                if (c != 0)
                {
                    if (collides(state, state->get<Player>(p)->character, std::atan2(vspeed, hspeed)))
                    {
                        oncollision(state, c);
                    }
                }
            }
        }
    }
}
示例#5
0
void copytoclipboard(drawing sb)
{
    HBITMAP hbmpOldDest, hbmpNew;
    HDC     hdcSrc, hdcDest;
    rect r;

    r = getrect(sb);
    hdcSrc =  get_context((object)sb);
    hdcDest = CreateCompatibleDC(hdcSrc);

    hbmpNew = CreateCompatibleBitmap(hdcSrc, r.width, r.height);
    hbmpOldDest = SelectObject(hdcDest, hbmpNew);
    BitBlt(hdcDest, 0, 0, r.width, r.height, hdcSrc, 0, 0, SRCCOPY);
    SelectObject(hdcDest, hbmpOldDest);
    DeleteDC(hdcDest);

    if (!OpenClipboard(NULL) || !EmptyClipboard()) {
	R_ShowMessage(G_("Unable to open the clipboard"));
	DeleteObject(hbmpNew);
	return;
    }
    SetClipboardData(CF_BITMAP, hbmpNew);
    CloseClipboard();
    return;
}
示例#6
0
文件: rv2.c 项目: NREL/Radiance
void
getframe(				/* get a new frame */
	char  *s
)
{
	if (getrect(s, &pframe) < 0)
		return;
	pdepth = 0;
}
示例#7
0
文件: buttons.c 项目: Vladimir84/rcc
static void checkbox_mousemove(control c, int buttons, point xy)
{
	if (!isarmed(c))
		return;
	if (buttons && ptinr(xy,getrect(c)))
		highlight(c);
	else
		unhighlight(c);
}
示例#8
0
文件: buttons.c 项目: Vladimir84/rcc
static void button_mouseup(control c, int buttons, point xy)
{
	if (!isarmed(c))
		return;
	disarm(c);
	unhighlight(c);
	if (ptinr(xy, getrect(c)))
		activatecontrol(c);
}
示例#9
0
文件: buttons.c 项目: Vladimir84/rcc
static void radio_mouseup(control c, int buttons, point xy)
{
	if (! isarmed(c))
		return;
	disarm(c);
	unhighlight(c);
	if (! ptinr(xy, getrect(c)))
		return;
	radio_hit(c);
}
示例#10
0
static void cleanmasks(fz_node *node)
{
    fz_node *prev;
    fz_node *current;
    fz_node *shape;
    fz_node *color;
    fz_rect bbox;

    for (current = node->first; current; current = current->next)
        cleanmasks(current);

    prev = nil;
    for (current = node->first; current; current = current->next)
    {
retry:
        if (!current)
            break;

        if (fz_ismasknode(current))
        {
            shape = current->first;
            color = shape->next;

            if (color == nil)
            {
                fz_removenode(current);
                prev = nil;
                current = node->first;
                goto retry;
            }

            if (fz_ispathnode(shape))
            {
                if (getrect((fz_pathnode*)shape, &bbox))
                {
                    if (fitsinside(color, bbox))
                    {
                        fz_removenode(current);
                        if (prev)
                            fz_insertnodeafter(prev, color);
                        else
                            fz_insertnodefirst(node, color);
                        /* cf. http://bugs.ghostscript.com/show_bug.cgi?id=690679 */
                        current->first->next = nil;
                        fz_dropnode(current);
                        current = color;
                        goto retry;
                    }
                }
            }
        }

        prev = current;
    }
}
示例#11
0
文件: rv2.c 项目: NREL/Radiance
void
getrepaint(				/* get area and repaint */
	char  *s
)
{
	RECT  box;

	if (getrect(s, &box) < 0)
		return;
	paintrect(&ptrunk, &box);
}
示例#12
0
文件: win.c 项目: grobe0ba/plan9front
Win *
newwinsel(int t, Mousectl *mc, File *f)
{
	Rectangle u;

	u = getrect(3, mc);
	if(Dx(u) < MINSIZ || Dy(u) < MINSIZ)
		return nil;
	rectclip(&u, screen->r);
	return newwin(t, u, f);
}
示例#13
0
文件: buttons.c 项目: Vladimir84/rcc
static void checkbox_mouseup(control c, int buttons, point xy)
{
	if (! isenabled(c))
		return;
	disarm(c);
	unhighlight(c);
	if (! ptinr(xy, getrect(c)))
		return;
	if (ischecked(c))
		uncheck(c);
	else
		check(c);
	activatecontrol(c);
}
示例#14
0
文件: win.c 项目: grobe0ba/plan9front
void
winresize(Win *w, Mousectl *mc)
{
	Rectangle r;
	
	if(w == nil)
		return;
	r = getrect(3, mc);
	if(Dx(r) < MINSIZ || Dy(r) < MINSIZ)
		return;
	rectclip(&r, screen->r);
	freeimage(w->im);
	w->entire = r;
	w->inner = insetrect(r, BORDSIZ);
	w->im = allocwindow(scr, r, Refbackup, 0);
	draw(w->im, w->inner, w->tab->cols[BACK], nil, ZP);
	setfocus(w);
	w->tab->draw(w);
}
示例#15
0
void applyGUI(Gui newGUI)
{
    rect r = getrect(RConsole);
    ConsoleData p = (ConsoleData) getdata(RConsole);
    int havenewfont = 0;
    struct structGUI curGUI;

    getActive(&curGUI);

    if(!has_changed(&curGUI, newGUI)) return;

    if(newGUI->MDI != curGUI.MDI || newGUI->toolbar != curGUI.toolbar ||
       newGUI->statusbar != curGUI.statusbar)
	askok(G_("The overall console properties cannot be changed\non a running console.\n\nSave the preferences and restart Rgui to apply them.\n"));

    if(strcmp(newGUI->language, curGUI.language)) {
	char *buf = malloc(50);
	askok(G_("The language for menus cannot be changed on a\n running console.\n\nSave the preferences and restart Rgui to apply to menus.\n"));
	snprintf(buf, 50, "LANGUAGE=%s", newGUI->language);
	putenv(buf);
    }


/*  Set a new font? */
    if(strcmp(newGUI->font, curGUI.font) ||
       newGUI->pointsize != curGUI.pointsize ||
       strcmp(newGUI->style, curGUI.style))
    {
	char msg[LF_FACESIZE + 128];
	int sty = Plain;

	if(newGUI->tt_font) strcpy(fontname, "TT "); else strcpy(fontname, "");
	strcat(fontname,  newGUI->font);
	if (!strcmp(newGUI->style, "bold")) sty = Bold;
	if (!strcmp(newGUI->style, "italic")) sty = Italic;
	pointsize = newGUI->pointsize;
	fontsty = sty;

	/* Don't delete font: open pagers may be using it */
	if (strcmp(fontname, "FixedFont"))
	    consolefn = gnewfont(NULL, fontname, fontsty, pointsize, 0.0, 1);
	else consolefn = FixedFont;
	if (!consolefn) {
	    snprintf(msg, LF_FACESIZE + 128,
		     G_("Font %s-%d-%d  not found.\nUsing system fixed font"),
		     fontname, fontsty | FixedWidth, pointsize);
	    R_ShowMessage(msg);
	    consolefn = FixedFont;
	}
	/* if (!ghasfixedwidth(consolefn)) {
	   sprintf(msg,
	   G_("Font %s-%d-%d has variable width.\nUsing system fixed font"),
	   fontname, fontsty, pointsize);
	   R_ShowMessage(msg);
	   consolefn = FixedFont;
	   } */
	p->f = consolefn;
	FH = fontheight(p->f);
	FW = fontwidth(p->f);
	havenewfont = 1;
    }

/* resize console, possibly with new font */
    if (consoler != newGUI->crows || consolec != newGUI->ccols || havenewfont) {
	char buf[20];
	consoler = newGUI->crows;
	consolec = newGUI->ccols;
	r.width = (consolec + 1) * FW;
	r.height = (consoler + 1) * FH;
	resize(RConsole, r);
	snprintf(buf, 20, "%d", ROWS); settext(f_crows, buf);
	snprintf(buf, 20, "%d", COLS); settext(f_ccols, buf);
    }
    if (p->lbuf->dim != newGUI->cbb || p->lbuf->ms != newGUI->cbl)
	xbufgrow(p->lbuf, newGUI->cbb, newGUI->cbl);

/* Set colours and redraw */
    for (int i=0; i<numGuiColors; i++)
    	p->guiColors[i] = guiColors[i] = newGUI->guiColors[i];
    drawconsole(RConsole, r);
    if(haveusedapager &&
       (newGUI->prows != curGUI.prows || newGUI->pcols != curGUI.pcols))
	askok(G_("Changes in pager size will not apply to any open pagers"));
    pagerrow = newGUI->prows;
    pagercol = newGUI->pcols;

    if(newGUI->pagerMultiple != pagerMultiple) {
	if(!haveusedapager ||
	   askokcancel(G_("Do not change pager type if any pager is open\nProceed?"))
	   == YES)
	    pagerMultiple = newGUI->pagerMultiple;
	if(pagerMultiple) {
	    check(rb_mwin); uncheck(rb_swin);
	} else {check(rb_swin); uncheck(rb_mwin);}
    }

    setWidthOnResize = newGUI->setWidthOnResize;
    consolebuffered = newGUI->buffered;

    Rwin_graphicsx = newGUI->grx;
    Rwin_graphicsy = newGUI->gry;
    
    p->cursor_blink = newGUI->cursor_blink;
}
示例#16
0
MCRectangle MCPlayer::getactiverect(void)
{
	return MCU_reduce_rect(getrect(), getflag(F_SHOW_BORDER) ? borderwidth : 0);
}