Beispiel #1
0
ret_code printMenu(const MenuItem_t* items, int numItems)
{
#define MAX 50
	point center = getScreenCenter(); 
	int i, j, h, k=0;
	clrscr();
	show_bmp(LOGO_FILENAME);
	CHECK(NULL!=items);
	CHECK(numItems>0);
	for (i=0;i<numItems;i++) {
		if (!items->hidden) {
			k++;
		}
	}
	h = center.y - k + 2;
	for (i=0, j=0; i<numItems; i++) {
		char buf[MAX];
		if (!items->hidden) {
#ifdef WIN32
			_snprintf(buf,MAX,"%d> %s",i+1,items->name);
#else
			snprintf(buf,MAX,"%d> %s",j+1,items->name);
#endif
			WRITE_AT(buf,4,h+(j++)*2);
		}
		items++;
	}
	return SUCCESS;
}
Beispiel #2
0
closure* telaEscolhePeriodo(closure* cl)
{
	point top, bottom;
	int y,x;
	int clear_key_pressed = FALSE;
	date_t* begin =  NULL, *end = NULL;
	closure* next_cl = NULL;
	getScreenDims(&top, &bottom);	
	y=bottom.y/2-2;
	x=bottom.x/2-8;	
	while(!clear_key_pressed && NULL==next_cl) {
		clrscr ();	
		show_bmp(LOGO_FILENAME);
		WRITE_AT("Início: ddmmaaaa", x, y);		
		WRITE_AT("Fim:    ddmmaaaa", x, y+1);				
		begin = get_date(x+8,y,8,&top,&bottom,&clear_key_pressed);		
		if (NULL!=begin && !clear_key_pressed) {			
			end = get_date(x+8,y+1,8,&top,&bottom,&clear_key_pressed);		
		}
		if (!clear_key_pressed) {
			if (NULL==begin || NULL==end || !date_check2(begin,end)) {
				show_data_incorreta(&bottom);
			}  else if (NULL!=begin && NULL!=end) {
				next_cl = telaRelatorio(cl,date_makeCopy(begin),date_makeCopy(end));
			}
		}
		date_delete(begin);
		date_delete(end);
	}
	return next_cl? next_cl : popClosure(cl);
}
Beispiel #3
0
ret_code printMenu2(MenuItem_t* items, int numItems, bool multipage, bool lastpage, int page)
{
#define MAX 50
	point center = getScreenCenter(); 	
	int start, end, i, h, rowidx;
	clrscr();
	show_bmp(LOGO_FILENAME);
	CHECK(NULL!=items);
	CHECK(numItems>0);
	start = page * PAGE_ITEMS;
	if (multipage) {
		end = lastpage? numItems : (page+1)*PAGE_ITEMS;
	} else {
		end = numItems;
	}
	CHECK(end<=numItems);
	h = center.y - (end-start);
	items = items + start;
	for (rowidx=0, i=start; i<end+2; i++,rowidx++) {
		char buf[MAX];
		if (i==end) {
#ifdef WIN32
			_snprintf(buf,MAX,"#> %s","Tela Anterior");
#else
			snprintf(buf,MAX,"#> %s","Tela Anterior");
#endif
			WRITE_AT(buf,2,h+rowidx*2);
		
		} else if (multipage && !lastpage && i==(end+1)) {
#ifdef WIN32
			_snprintf(buf,MAX,"*> %s","Tela Seguinte");
#else
			snprintf(buf,MAX,"*> %s","Tela Seguinte");
#endif
			WRITE_AT(buf,2,h+rowidx*2);

		} else if (i<end) {
			items->key = KEY_1 + rowidx;
#ifdef WIN32
			_snprintf(buf,MAX,"%d> ",rowidx + 1);
#else
			snprintf(buf,MAX,"%d> ",rowidx + 1);
#endif		
			WRITE_AT(buf,2,h+rowidx*2);
			write_multiline(items->name,5,h+rowidx*2,2);

		} else {
			break;
		}
		items++;
	}
	return SUCCESS;
}
Beispiel #4
0
// *Date params will be deleted by this function
closure* telaRelatorio(closure* cl, char* beginDate, char* endDate)
{
	relatorio_t* relatorio;
	int isFinished = FALSE, refresh = TRUE; 
	char buf[MAXBUF];	
	const char* evId = (const char*)cl->param;
	point center = getScreenCenter(); 	
	memset (buf,'\0',sizeof(buf));
	snprintf(buf,MAXBUF,"Gerando relatório...");
	WRITE_AT(buf,center.x-10,center.y*2-1);
	CHECK(NULL!=evId);
	CHECK(SUCCESS==initAmbiente());
	CHECK(SUCCESS==get_relatorio(beginDate,endDate,evId,&relatorio));
	CHECK(NULL!=relatorio);	
	while (!isFinished) {
		char szKey;
		long lOSEvent = wait_event();
		if (refresh /*if there's no check it will keep rewriting constantly*/) {
			clrscr ();	
			show_bmp(LOGO_FILENAME);
			WRITE_AT_CENTERED("Relatorio",center.x,center.y-3);
			snprintf(buf,MAXBUF,"Inicio: %s\0",relatorio->begin_date);		
			WRITE_AT(buf,center.x-10,center.y);
			snprintf(buf,MAXBUF,"Fim:    %s\0",relatorio->end_date);		
			WRITE_AT(buf,center.x-10,center.y+1);
			snprintf(buf,MAXBUF,"Valor:  %s\0",valor_withCurrency(relatorio->value));
			WRITE_AT(buf,center.x-10,center.y+2);
			WRITE_AT("1> Imprimir",center.x-10,center.y+4);
			WRITE_AT("#> Tela Anterior",center.x-10,center.y+5);
			refresh = FALSE;
		} 
		if (lOSEvent & EVT_KBD) {
			if (read(g_conHandle, &szKey, 1) > 0) {
				szKey = convertKey (szKey);	
				if (KEY_HASH == szKey || KEY_BACK == szKey || KEY_ESC == szKey) {
					isFinished = TRUE;
				} else if (szKey == KEY_1) {
					char msg[MAX_BUFF_SIZE];
					if(relatorio_hasError(relatorio, msg, MAX_BUFF_SIZE)) {
						clrscr();
						write_multilineCentered(msg);
						SVC_WAIT(2000);
						refresh = TRUE;
					} else {
						CHECK(SUCCESS==print_relatorio(relatorio));
					}
				}
			}
		}
	}
	delete_relatorio(relatorio);
	return popClosure(cl);
}
Beispiel #5
0
int main(int argc, char * argv[]) {

    struct Surface * sur;
    sur = open_fb("/dev/fb0");

    if (!sur) {
        return 1;
    }

    show_bmp("background.bmp", sur);

    sur->destroy(sur);
    return 0;

}
Beispiel #6
0
ret_code loginScreenInit(int* cancel)
{
	ret_code ret = ERROR;
	point top, bottom;
	const char* err;	
	signed char login_buf[200];	
	char        pwd_buf[100];
    short       len;
    int         ret_val;
    memset (login_buf, '\0', sizeof (login_buf));
    memset (pwd_buf, '\0', sizeof (pwd_buf));
	getScreenDims(&top, &bottom);

	for (;SUCCESS!=ret;) {
		int ret_val, len, height = bottom.y/2, width = bottom.x/2;
		memset (login_buf, '\0', sizeof (login_buf));
		window(top.x,top.y,bottom.x,bottom.y);	
		clrscr ();	
		CHECK(SUCCESS==set_cursor(1));		
		show_bmp(LOGO_FILENAME);
		WRITE_AT("Operador:", 3, height-1);
		WRITE_AT("Senha:", 6, height);
		window (13, height-1, 29, height-1);		
		gotoxy (1, 1);
		ret_val = getkbd_entry (h_clock, "", (signed char *) login_buf, 0/*no timeout*/, NUMERIC,
                            (char *) szKeyMapVx680, sizeof (szKeyMapVx680), 10, 1);
		if (ret_val>0) {
			ret = op_checkId(login_buf,NULL,&err);
			if (SUCCESS!=ret) {
				CHECK(SUCCESS==set_cursor(0));		
				clrscr();				
				window(top.x,top.y,bottom.x,bottom.y);	
				WRITE_AT(err, bottom.x/2-strlen(err)/2, 5);
				SVC_WAIT(2000);
			} else {
				// Now get the pwd
				window (13, height, 29, height);		
				gotoxy(1, 1);
				ret_val = getkbd_entry (h_clock, "", (signed char *) pwd_buf, 0/*no timeout*/, NUMERIC,
                            (char *) szKeyMapVx680, sizeof (szKeyMapVx680), 10, 1);
				if (ret_val>0) {
					ret = op_checkId(login_buf,pwd_buf,&err);
					if (SUCCESS!=ret) {
						CHECK(SUCCESS==set_cursor(0));		
						clrscr();				
						window(top.x,top.y,bottom.x,bottom.y);	
						WRITE_AT(err, bottom.x/2-strlen(err)/2, 5);
						SVC_WAIT(2000);
					} 
				}
			}
		} else if(-3==ret_val) {
			/* go to prev screen when user presses ESC*/
			*cancel = 1;
			ret = SUCCESS;
		}
	}
	CHECK(SUCCESS==set_cursor(0));		
	window(top.x,top.y,bottom.x,bottom.y);	
	if (0==*cancel) {		
		memset (login_buf, '\0', sizeof (login_buf));
		sprintf (login_buf, "Bem-vindo %s", g_operador);
		SCREEN_WARNING(login_buf);
	}
	return ret;
}