Exemple #1
0
/*
 * Render the whole screen by querying the model.
 */
static void
screen_render(Screen *s)
{
	/* determine the visible set of rows using key */
	RowIterator iter = RowMapLowerBound(rowmap(s), key(s));
	RowIterator end = RowMapEnd(rowmap(s));

	/* reposition the cursor to the origin */
	int i = 0;
	int ctr = 0;
	move(ctr, 0);

	/* display the header row in reverse video at the top of screen */
	attron(A_REVERSE);
	render_row(s, &s->model->header, '|');
	attroff(A_REVERSE);
	ctr++;

	/* render visible set */
	for (; iter != end && ctr < lines(s); iter++, ++ctr)
	{
		render_row(s, iter, ' ');
	}

	/* blank out any remaining rows below the last row */
	for (i = ctr; i < lines(s); ++i) {
		printw("\n");
		clrtoeol();
	}
}
Exemple #2
0
static int cursor_down(OptionsPanel* prPanel) {
    CursorPos* prCursor = NULL;
    int y = 0;
    int oldy = 0;
    if (prPanel == NULL) {
        return OPTIONSPANEL_NULLPTR;
    }
    prCursor = get_cursorpos(prPanel);
    y = prCursor->y + 1;
    if (y > 5) {
        y = 0;
    }
    if (y != prCursor->y) {
        prCursor->x = 0;
    }
    oldy = prCursor->y;
    prCursor->y = y;
    if (oldy != y) {
        if (render_row(prPanel, oldy) < 0) {
            return OPTIONSPANEL_FAILURE;
        }
        if (render_row(prPanel, prCursor->y) < 0) {
            return OPTIONSPANEL_FAILURE;
        }
    }
    return OPTIONSPANEL_SUCCESS;
}
Exemple #3
0
int optionspanel_redraw(OptionsPanel* prPanel) {
    HexPad* prPad = NULL;
    ColorConfig* prColor = NULL;
    CursorPos* prPos = NULL;
    Dimension* prSize = NULL;
    char sFmt[10];
    int i = 0;

    if (prPanel == NULL) {
        return OPTIONSPANEL_NULLPTR;
    }
    
    if (prPanel->editing == 1) {
        prPad = get_hexpad(prPanel);
        if (prPad->visible == 1) {
            if (hexpad_redraw(prPad) < 0) {
                return OPTIONSPANEL_FAILURE;
            }
            return OPTIONSPANEL_SUCCESS;
        }
        if (commit_edit(prPanel) < 1) {
            return OPTIONSPANEL_FAILURE;
        }
    }
    
    if (prPanel->dirty == 0) {
        return OPTIONSPANEL_SUCCESS;
    }
    prColor = get_panelcolor(prPanel);
    prPos = get_position(prPanel);
    prSize = get_size(prPanel);
    
    pspDebugScreenSetXY(prPos->x, prPos->y + 1);
    pspDebugScreenSetBackColor(prColor->background);
    pspDebugScreenSetTextColor(prColor->text);
    sprintf(sFmt, "%%-%ds", prSize->width);
    pspDebugScreenKprintf(sFmt, "Options");

    for (i = 0; i < prSize->height - 2; i++) {
        if (render_row(prPanel, i) < 0) {
            return OPTIONSPANEL_FAILURE;
        }
    }
    prPanel->dirty = 0;
    return OPTIONSPANEL_SUCCESS;
}
Exemple #4
0
static int cursor_right(OptionsPanel* prPanel) {
    CursorPos* prCursor = NULL;
    int x = 0;
    if (prPanel == NULL) {
        return OPTIONSPANEL_NULLPTR;
    }
    prCursor = get_cursorpos(prPanel);
    if (prCursor->y > 0) {
        x = prCursor->x + 1;
        if (x > 1) {
            x = 0;
        }
        if (x != prCursor->x) {
            prCursor->x = x;
            if (render_row(prPanel, prCursor->y) < 0) {
                return OPTIONSPANEL_FAILURE;
            }
        }
    }
    return OPTIONSPANEL_SUCCESS;
}
Exemple #5
0
/*
** Triangles passed to this function have already been clipped by
** the clip box.
*/
static void render_triangle_1(WILLUSBITMAP *bmap,TRIANGLE2D *srctri,
                              RENDER_COLOR *rcolor,
                              RENDER_COLOR *bgcolor,int render_type)

    {
    TRIANGLE2D *tri,_tri;
    int     row,bottom_row,top_row;

/*
{
int i;
printf("@render_triangle_1\n");
for (i=0;i<4;i++)
printf("%6.4f %6.4f\n",srctri->p[i%3].x*bmap->width,srctri->p[i%3].y*bmap->height);
printf("//nc\n");
}
*/
    if (render_type==RENDER_TYPE_SET)
        {
        render_triangle_2(bmap,srctri,rcolor);
        return;
        }
    tri=&_tri;
    if (tri2d_zero_area(srctri))
        return;
    (*tri)=(*srctri);
    tri2d_sort_ypoints(tri);
    bottom_row = render_row(bmap,tri->p[0].y);
    top_row = render_row(bmap,tri->p[2].y);
    for (row=bottom_row;row<=top_row;row++)
        {
        int     nx,i,j,k,col,left_col,right_col;
        double  y0,y1;
        static double x[9];

// printf("row=%d\n",row);
        y0 = (double)row/bmap->height;
        y1 = (double)(row+1)/bmap->height;
        i=0;
        /* Create array of possible extreme x-coords */
        /* Triangle vertices */
        for (j=0;j<3;j++)
            if (y0<=tri->p[j].y && y1>=tri->p[j].y)
                x[i++] = tri->p[j].x;
        /* Segments intercepting y0 */
        for (j=0;j<2;j++)
            for (k=j+1;k<3;k++)
                if (tri->p[j].y < y0 && tri->p[k].y > y0)
                    x[i++] = p2d_x_intercept(y0,tri->p[j],tri->p[k]);
        /* Segments intercepting y1 */
        for (j=0;j<2;j++)
            for (k=j+1;k<3;k++)
                if (tri->p[j].y < y1 && tri->p[k].y > y1)
                    x[i++] = p2d_x_intercept(y1,tri->p[j],tri->p[k]);
        nx=i;
        left_col  = render_col(bmap,array_min(x,nx));
        right_col = render_col(bmap,array_max(x,nx));
// printf("    %d to %d\n",left_col,right_col);
        for (col=left_col;col<=right_col;col++)
            {
            if (render_type==RENDER_TYPE_ANTIALIASED)
                render_pixelset(bmap,col,row,rcolor,
                       render_type,bgcolor,
                       tri2d_intersection_area(bmap,tri,row,col));
            else
                if (render_pixel_contained(bmap,tri,row,col))
                    render_pixelset(bmap,col,row,rcolor,
                                      render_type,bgcolor,1.);
            }
        }
    }