Exemplo n.º 1
0
int main(void)
{	
	entry* entries = main_create_entries();
	list* menu = create_list(0,24,25,entries,MAINMENU_SIZE);
	nio_scrbuf_init();
	do
	{
		int selection = update_list(menu);
		if(selection != -1)
		{
			wait_no_key_pressed();
			switch(selection)
			{
				case 0:
					display_tasks_screen();
					break;
				case 1:
					display_pools_screen();
					break;
				case 2:
					display_events_screen();
					break;
				case 3:
					display_queues_screen();
					break;
				case 4:
					display_semaphores_screen();
					break;
				case 5:
					display_mailboxes_screen();
					break;
				default:
					display_settings_screen();
					break;
			}
		}
		
		nio_scrbuf_clear();
		
		nio_grid_printf(0,0,0,0,NIO_COLOR_WHITE,NIO_COLOR_BLACK,"TI-Nspire Task Manager (built %s %s)",__DATE__,__TIME__);
		int i;
		for(i = 0; i < 53; i++)
		{
			nio_grid_putc(0,0,i,2,'-',NIO_COLOR_WHITE,NIO_COLOR_BLACK);
			nio_grid_putc(0,0,i,28,'-',NIO_COLOR_WHITE,NIO_COLOR_BLACK);
		}
		draw_list(menu);
		nio_grid_puts(0,0,0,29,"Use UP/DOWN keys to navigate, ENTER to select",NIO_COLOR_WHITE,NIO_COLOR_BLACK);
		
		nio_scrbuf_flip();
		wait_key_pressed();
	} while(!isKeyPressed(KEY_NSPIRE_ESC));
	
	nio_scrbuf_free();
	free(entries);
	free(menu);
	return 0;
}
Exemplo n.º 2
0
int get_string (int x,int y,char * s,int width,int max,BOOL only_num,int clf,int clb)
{
	unsigned	ch;
	BOOL		refresh = TRUE;
	int			len = strlen(s);

	while(1)
	{
		if (refresh)
		{
			int i;
			
			for(i=0;i<width;++i)
				dg_put_str(x+i*CHAR_WIDTH,y," ",clf,clb);
			
			dg_put_str(x,y,(len>width-1?(s+len-width+1):s),clf,clb);
			
			dg_put_str(len>width-1?x+(width-1)*CHAR_WIDTH:x+len*CHAR_WIDTH,y,'|',clf,clb);
			
			refresh = FALSE;
		}
		
		wait_key_pressed();
		ch = nio__getch();
		
		if ((ch>='a' && ch<='z' && !only_num)
			|| (ch>='0' && ch<='9')
			|| (ch==' ')
			&& len<max) // get char
		{
			s[len++]	= ch;
			s[len]		= '\0';
			refresh		= TRUE;
		}
		else if (ch==8 && len>0)
		{
			s[--len]	= '\0';
			refresh		= TRUE;
		}
		else if (ch=='\n')
		{
			return 1;
		}
		else if (ch==0)
		{
			return 0;
		}
	}
	return 0;
}
Exemplo n.º 3
0
// Activation
int  ActivateList(Widget *w)
{
	SDL_Surface *scr = w->construct->scr;
	wTHEME *t = w->construct->theme;
	ListArgs *args = w->args;
	args->isActive = 1;
	wMENU *m = args->menu;
	int ok = ACTION_CONTINUE;
	int db = w->displayBounds;
	
	
	do {
		DrawList(w);
		SDL_Flip(scr);
		wait_key_pressed();
		
		if (K_CLICK() && args->menu->nItems) {
			int ws = nSDL_GetStringWidth(t->font, m->title);
			int xw = (w->bounds.w*3)/5;
			if (!m->title)
				xw = w->bounds.w - 6;
			else if (xw + ws + 9 > w->bounds.w)
				xw = w->bounds.w - ws - 9;
			int x = w->bounds.x + w->bounds.w - xw - 3;
			w->displayBounds = -1;
			
			ok=OpenMenu(w, m, x+1, 0, xw, w->bounds.y+4);
			w->displayBounds = db;
			wDrawBounds(w);
			if (ok == MENU_QUIT) ok = ACTION_CONTINUE;
			if (ok != ACTION_CONTINUE) break;
			
			while (K_ESC() || K_LEFT() || K_ENTER());
		}
		
		else if (K_UP() || K_DOWN() || K_LEFT() || K_RIGHT() || K_MENU() || K_TAB() ||
			 K_SCRATCHPAD() || K_ENTER()) break;
		
		else if (any_key_pressed()) {
			if ((ok=wExecCallback(w, SIGNAL_KEY)) != ACTION_CONTINUE)
				break;
			SDL_Flip(scr);
		}
		
	} while (!K_ESC());
	
	args->isActive = 0;
	return ok;
}
Exemplo n.º 4
0
int Read()
{
	VRAM   = init_VRAM();			AllClr_VRAM( VRAM   );
	char * VRAM_A = init_VRAM();	AllClr_VRAM( VRAM_A );
	char * VRAM_B = init_VRAM();	AllClr_VRAM( VRAM_B );
	int total_page , page = 0 , i ,last_key_pressed=0;
	char buff[1000] , statue_bar[100];
	int auto_down = 0 , _auto = 0 , mark = 1 ;
	int user_contrast = *p_contrast;
	long auto_time = 0 ;
	int msg_utf8 = 0;
	auto_down = _auto = 0 ;
	strcpy( txtname , fname );
	TXT = fopen( txtname , "rb" ) ;
	fseek(TXT , 0 , SEEK_END);
	filesize = ftell( TXT );
	
	total_page = divid();
	
	memset( buff , 0x0 , 1000 );
	
	load_mark( &page , total_page , 1 );

	fseek( TXT , pagepos[page] , SEEK_SET );
	fread( buff , pagepos[ page+1 ] - pagepos[ page ] , 1 , TXT );
	AllFill_VRAM(VRAM_A,cl_bg);
	PrintChStr( VRAM_A , 0 , 0 , buff , cl_fg , cl_bg );

	PutDisp_DDVRAM( VRAM_A );
	auto_down = 0 ;
	while( 1 )
	{
		if(isKeyPressed(KEY_NSPIRE_SCRATCHPAD))
		{
			wait_no_key_pressed();
			if(msg_utf8==0)
				i = show_msgbox_3b( "提示" , "调用API必须保证文本为UTF-8编码,也就是此时用nNovel无法正常阅读,要继续吗?" , "确定" , "取消" ,"确定且不再提示" );
			else
				i = 1;
			if( i == 3 )
			{
				i = 1;
				msg_utf8 = 1;
			}
			if( i == 1 )
			{
				wait_no_key_pressed();
				show_msgbox( "本页内容:" , buff );
			}
		}
		if(isKeyPressed(KEY_NSPIRE_MULTIPLY))
		{
			if( is_cx && (*p_contrast)< 225)
				(*p_contrast)++;
			else if( (!is_cx) && (*p_contrast) < 0xc0 )
				(*p_contrast)++;
		}
		else if(isKeyPressed(KEY_NSPIRE_DIVIDE))
		{
			if( is_cx && (*p_contrast)> 1 )
				(*p_contrast)--;
			else if( (!is_cx) && (*p_contrast) >50 )
				(*p_contrast)--;
		}
		else if(isKeyPressed(KEY_NSPIRE_TAB))
		{
			i = num_input(VRAM , 30 , 30 , "  ����ҳ��" );
			if( i == -1) continue;
			else if( i == 0 ){ page = 0;}
			else if( i > total_page){ page = total_page;}
			else page = i - 1;
			memset( buff , 0x0 , 1000 );
			fseek( TXT , pagepos[page] , SEEK_SET );
			fread( buff , pagepos[ page +1 ] - pagepos[ page ] , 1 , TXT );
			AllFill_VRAM(VRAM_A,cl_bg);
			PrintChStr( VRAM_A , 0 , 0 , buff , cl_fg , cl_bg );
			PutDisp_DDVRAM( VRAM_A );
			wait_no_key_pressed();
		}
		else if(isKeyPressed(KEY_NSPIRE_DOC))
		{
			save_mark( page , total_page , 0 );
			wait_no_key_pressed();
		}
		else if(isKeyPressed(KEY_NSPIRE_MENU))
		{
			load_mark( &page , total_page , 0 );
			memset( buff , 0x0 , 1000 );
			fseek( TXT , pagepos[page] , SEEK_SET );
			fread( buff , pagepos[ page +1 ] - pagepos[ page ] , 1 , TXT );
			AllFill_VRAM(VRAM_B,cl_bg);
			PrintChStr( VRAM_A , 0 , 0 , buff , cl_fg , cl_bg );
			PutDisp_DDVRAM( VRAM_A );
			wait_no_key_pressed();
		}
		else if(isKeyPressed(KEY_NSPIRE_SHIFT))
		{
			if(cl_bg == 15)
			{
				cl_fg = 15;
				cl_bg = 0;
			}
			else
			{
				cl_fg = 0;
				cl_bg = 15;
			}
			memset( buff , 0x0 , 1000 );
			fseek( TXT , pagepos[page] , SEEK_SET );
			fread( buff , pagepos[ page +1 ] - pagepos[ page ] , 1 , TXT );
			AllFill_VRAM(VRAM_A,cl_bg);
			PrintChStr( VRAM_A , 0 , 0 , buff , cl_fg , cl_bg );
			PutDisp_DDVRAM( VRAM_A );
			wait_no_key_pressed();
		}
		
		if((*p_RTC - auto_time)%(_auto) != 0)
			mark = 0;
		if( ( isKeyPressed(KEY_NSPIRE_DOWN ) || isKeyPressed(KEY_NSPIRE_MINUS )|| auto_down == 1 )&& page < total_page )
		{
			auto_down = 0;
			page++;
			memset( buff , 0x0 , 1000 );
			fseek( TXT , pagepos[page] , SEEK_SET );
			fread( buff , pagepos[ page +1 ] - pagepos[ page ] , 1 , TXT );
			if( cl_bg != 15 )
				AllFill_VRAM(VRAM_B,cl_bg);
			else
				AllClr_VRAM(VRAM_B);
			PrintChStr( VRAM_B , 0 , 0 , buff , cl_fg , cl_bg );
			if( config.show_page_slide == 1 )
				slide_down(statue_bar , VRAM_A , VRAM_B , 1 );
			else
			{
				Fill_Rect_VRAM( VRAM_B , 0 , 224 , 320 , 240 , 0 );
				PrintChStr( VRAM_B , 0 , 224 , statue_bar , 15 , 0 );
				PutDisp_DDVRAM(VRAM_B);
				for( i=0 ; i<=FIRST_KEY_WAIT ; i++ )
				{
					if((!isKeyPressed(KEY_NSPIRE_DOWN )|| isKeyPressed(KEY_NSPIRE_MINUS )))
						break;
					if(last_key_pressed)
						break;
					sleep(1);
					if( i == FIRST_KEY_WAIT )
						last_key_pressed = 1;
				}
			}
			memcpy(VRAM_A,VRAM_B,SCREEN_BYTES_SIZE);
		}
		else if( isKeyPressed(KEY_NSPIRE_UP )|| isKeyPressed(KEY_NSPIRE_PLUS ) )
		{
			if( page == 0 )
				continue;
			page --;
			memset( buff , 0x0 , 1000 );
			fseek( TXT , pagepos[page] , SEEK_SET );
			fread( buff , pagepos[ page +1 ] - pagepos[ page ], 1 , TXT );
			AllFill_VRAM(VRAM_B,cl_bg);
			PrintChStr( VRAM_B , 0 , 0 , buff , cl_fg , cl_bg );
			if( config.show_page_slide == 1 )
				slide_up( statue_bar , VRAM_B , VRAM_A , 1 );
			else
			{
				Fill_Rect_VRAM( VRAM_B , 0 , 224 , 320 , 240 , 0 );
				PrintChStr( VRAM_B , 0 , 224 , statue_bar , 15 , 0 );
				PutDisp_DDVRAM(VRAM_B);
				for( i=0 ; i<=FIRST_KEY_WAIT ; i++ )
				{
					if((!isKeyPressed(KEY_NSPIRE_UP )|| isKeyPressed(KEY_NSPIRE_PLUS )))
						break;
					if(last_key_pressed)
						break;
					sleep(1);
					if( i == FIRST_KEY_WAIT )
						last_key_pressed = 1;
				}
			}
			memcpy(VRAM_A,VRAM_B,SCREEN_BYTES_SIZE);
		}
		else
			last_key_pressed = 0;
		memcpy(VRAM,VRAM_A,SCREEN_BYTES_SIZE);
		Fill_Rect_VRAM( VRAM , 0 , 224 , 320 , 240 , 0 );
		if( config.show_time )
		{
			update_time();
			if( config.show_second )
				sprintf(statue_bar , " %d%d:%d%d:%d%d     %5d/%5d   %4s", time.hour/10 , time.hour%10 , time.minute/10, time.minute%10 , time.second/10 , time.second%10 , page +1 , total_page +1 , _auto == 0?"":"Auto");
			else
				sprintf(statue_bar , " %d%d:%d%d        %5d/%5d   %4s", time.hour/10 , time.hour%10 , time.minute/10, time.minute%10 , page +1 , total_page +1 ,_auto == 0?"":"Auto");
		}
		else 
		{
			sprintf(statue_bar , "              %5d/%5d", page +1 , total_page +1 );
		}
		PrintChStr( VRAM , 0 , 224 , statue_bar , 15 , 0 );
//		DrawMiniString_VRAM(VRAM , 0 , 228 , statue_bar , 15 , 0 );
		PutDisp_DDVRAM(VRAM);
			
		if( ! config.show_time )
		{
			if( !(isKeyPressed(KEY_NSPIRE_UP)||isKeyPressed(KEY_NSPIRE_DOWN)) )
				wait_key_pressed();
		}
		
		if( isKeyPressed(KEY_NSPIRE_ESC))
		{
			if(isKeyPressed(KEY_NSPIRE_CTRL))
				goto exit;
			switch(menu(VRAM,10,10,"    �˵�\nҳ����ת(Tab)\n�Զ���ҳ\n��ȡ��ǩ(menu)\n������ǩ(doc)\n����\nҹ��ģʽ(shift)\n�����ǩ��ҳ���˳�\n����API�鿴��ҳ(��ǩ��)\n�˳�(ctrl+esc)\n","\n������λ����ת������λ��\n����/�ر��Զ���ҳ\n����ǩ�ļ��ж�ȡ����\n����ǩ�ļ���д�����\n�鿴���޸�����\n����ҹ��ģʽ(��ɫ)\n��������ɵ�������ǩ�ͷ�ҳ�Ľ���ļ�\n����MsgBox����ʾ��ҳ����\n�˳�����\n") )
			{
				case 1://ҳ����ת
				{
					i = num_input(SCREEN_BASE_ADDRESS , 30 , 30 , "  ����ҳ��" );
					if( i == -1) break;
					else if( i == 0 ){ page = 0;}
					else if( i > total_page){ page = total_page;}
					else page = i - 1;
					memset( buff , 0x0 , 1000 );
					fseek( TXT , pagepos[page] , SEEK_SET );
					fread( buff , pagepos[ page +1 ] - pagepos[ page ] , 1 , TXT );
					AllFill_VRAM(VRAM_A,cl_bg);
					PrintChStr( VRAM_A , 0 , 0 , buff , cl_fg , cl_bg );
					PutDisp_DDVRAM( VRAM_A );
					break;
				}
				case 2://�Զ���ҳ
				{
					if( _auto != 0 )
					{
						_auto = 0 ;
						mark = 1;
						break;
					}
					_auto = num_input( SCREEN_BASE_ADDRESS , 30 , 30 , "��������" );
					if(_auto == -1)
						_auto = 0;
					auto_time = *p_RTC;
					
					break;
				}
				case 3: //��ȡ��ǩ
				{
					load_mark( &page , total_page , 0 );
					memset( buff , 0x0 , 1000 );
					fseek( TXT , pagepos[page] , SEEK_SET );
					fread( buff , pagepos[ page +1 ] - pagepos[ page ] , 1 , TXT );
					AllFill_VRAM(VRAM_B,cl_bg);
					PrintChStr( VRAM_A , 0 , 0 , buff , cl_fg , cl_bg );
					PutDisp_DDVRAM( VRAM_A );
					break;
				}
				case 4: save_mark( page , total_page , 0 );break;//������ǩ
				case 5:	//����
				{
					setup_config();
					memset( buff , 0x0 , 1000 );
					fseek( TXT , pagepos[page] , SEEK_SET );
					fread( buff , pagepos[ page +1 ] - pagepos[ page ] , 1 , TXT );
					AllFill_VRAM(VRAM_A,cl_bg);
					PrintChStr( VRAM_A , 0 , 0 , buff , cl_fg , cl_bg );
					PutDisp_DDVRAM( VRAM_A );
					break;
				}
				case 6: //��ɫ
				{
					if(cl_bg == 15)
					{
						cl_fg = 15;
						cl_bg = 0;
					}
					else
					{
						cl_fg = 0;
						cl_bg = 15;
					}
					memset( buff , 0x0 , 1000 );
					fseek( TXT , pagepos[page] , SEEK_SET );
					fread( buff , pagepos[ page +1 ] - pagepos[ page ] , 1 , TXT );
					AllFill_VRAM(VRAM_A,cl_bg);
					PrintChStr( VRAM_A , 0 , 0 , buff , cl_fg , cl_bg );
					PutDisp_DDVRAM( VRAM_A );
					break;
				}
				case 7: //�����ǩ
				{
					char path[ 50 ];
					for( i = 0 ; i < strlen(txtname) - 8 ; i ++ )
						path[i] = txtname[i] ;
					path[ i ] = 0;
					strcat( path , ".div" );
					remove(path);
					for( i = 0 ; i < strlen(txtname) - 8 ; i ++ )
						path[i] = txtname[i] ;
					path[ i ] = 0;
					strcat( path , ".sav" );
					remove(path);
					goto exit2;
				}
				case 8://API
				{
					wait_no_key_pressed();
					if(msg_utf8==0)
						i = show_msgbox_3b( "提示" , "调用API必须保证文本为UTF-8编码,也就是此时用nNovel无法正常阅读,要继续吗?" , "确定" , "取消" ,"确定且不再提示" );
					else
						i = 1;
					if( i == 3 )
					{
						i = 1;
						msg_utf8 = 1;
					}
					if( i == 1 )
					{
						wait_no_key_pressed();
						show_msgbox( "本页内容:" , buff );
						break;
					}
					else
						break;
				}
				case 9: goto exit;//�˳�
				default :wait_no_key_pressed();break;
			}
			wait_no_key_pressed();
		}
		if( config.auto_save )
			if( page%config.auto_save_time==0 )
				save_mark( page , total_page , 1 );
		if( (*p_RTC - auto_time)%(_auto) == 0 && mark == 0)
		{
			mark = 1 ;
			auto_down = 1 ;
			auto_time = *p_RTC;
		}
	}
	exit:
	save_mark( page , total_page , 1 );
	exit2:
	* p_contrast = user_contrast;
	fclose( TXT );
	close_VRAM( VRAM_A );close_VRAM( VRAM_B );
	close_VRAM( VRAM );
	return 0;
}
Exemplo n.º 5
0
int divid()
{
	char divpath[50];
	int x = 0 , y = 0 , page = 1 , pos = 0 , i ;
	pagepos[0] = 0 ;
	char c;
	
	for( i = 0 ; i < strlen(txtname) - 8 ; i ++ )
		divpath[i] = txtname[i] ;
	divpath[ i ] = 0;
	strcat( divpath , ".div" );

	
	FILE *DIV = fopen( divpath , "rb" );
	if( filesize > MAXNOTDIV )
	{
		if( DIV == NULL )
			DIV = fopen( divpath , "wb+" );
		else
		{
			fread( pagepos , sizeof(int) , PAGEMAX , DIV );
			page = pagepos[ 0 ];
			pagepos[ 0 ] = 0;
			fclose( DIV );
			return page -1 ;
		}
		clrscr();
		AllFill_VRAM(VRAM,cl_bg);
		PrintChStr(VRAM,0,0,"�״δ��ı��ļ�����з�ҳ�����ļ��ϴ������Ҫ�ϳ�ʱ�䡣��ҳ��ɺ�����һ�������صķ�ҳ���������������������ɾ������Ҳ�������Ķ�ʱʹ�ò˵��еĹ�����ɾ������",cl_fg , cl_bg);
		PutDisp_DDVRAM( VRAM );
	}
	else
	{
		clrscr();
		AllFill_VRAM(VRAM,cl_bg);
		PrintChStr(VRAM,0,0,"���Ե�......",cl_fg , cl_bg);
		PutDisp_DDVRAM( VRAM );
	}
/*	while( ( !feof( TXT ) ) || page >= PAGEMAX -1 )
	{
		if( x > 39 )
		{
			x = 0 ; y ++ ;
		}
		if( y > 13 )
		{
			x = y = 0 ;
			pagepos[ page ++ ] = pos;
		}
		fread(&c , 1 , 1 , TXT );pos++;
		if( c == '\r' )
		{	y ++ ; x = 0 ; fread(&c , 1 , 1 , TXT );pos++; continue; }
		if( !( c&0x80 ) )
		{
			if(x>19)
			{	x = 0 ; y ++ ;}
			x ++ ;
			continue;
		}
		fread(&c , 1 , 1 , TXT );pos++;
		x+=2;
	}*/
	fseek( TXT , 0 , SEEK_SET );
	while( ( !feof( TXT ) ) || page >= PAGEMAX -1 )
	{
		if(x>40)
		{
			x = 0 ; y++ ;
		}
		if( y > 13 )
		{
			x = y = 0 ;
			pagepos[ page ++ ] = pos;
			continue;
		}
		fread(&c , 1 , 1 , TXT );pos++;
		if( !(c&0x80) )
		{
			if( c == '\r' || c == '\n'  )
			{
				y ++ ; x = 0 ; fread(&c , 1 , 1 , TXT );pos++;
				continue;
			}
			if(x > 40)
			{
				y ++ ; x = 0 ;
			}
			x++;
			continue;
		}
		if(x + 1 >= 40)
		{
			if( y == 13 )
			{
				fseek(TXT , -1 , SEEK_CUR);
				pos--;
				y ++;
				continue;
			}
			x = 0 ;
			y ++;
		}
		fread(&c , 1 , 1 , TXT );pos++;
		x+=2;
	}
	
	
	pagepos[ page ] = pos ;
	pagepos[ 0 ] = page;
	if(filesize > MAXNOTDIV)
	{
		fwrite( pagepos , sizeof(int) , PAGEMAX , DIV );
		fclose( DIV );
		PrintChStr(VRAM,0,6*16 , "��ҳ˳����ɣ�������Լ���" ,cl_fg , cl_bg);
		PutDisp_DDVRAM( VRAM );
		wait_key_pressed();
	}

	pagepos[ 0 ] = 0;
	return page -1;
}
Exemplo n.º 6
0
// Activation
int ActivateScrolledLayout(Widget *w)
{
	SDL_Surface *scr = w->construct->scr;
	ScrolledLayoutArgs *args = w->args;
	if (!args->nWidgets || !args->widgets) return 0;
	int ok = 3;
	int nWidget = args->cWidget;
	int n = 0;
	BOOL dynamic = 0;
	
	
	if (K_DOWN() || K_TAB())	nWidget = wFindNextWidget(args->widgets, args->nWidgets, ARROW_BOT, w->construct->previousWidgetBounds);
	else if (K_UP())		nWidget = wFindNextWidget(args->widgets, args->nWidgets, ARROW_TOP, w->construct->previousWidgetBounds);
	else if (K_RIGHT())	nWidget = wFindNextWidget(args->widgets, args->nWidgets, ARROW_RIGHT, w->construct->previousWidgetBounds);
	else if (K_LEFT())	nWidget = wFindNextWidget(args->widgets, args->nWidgets, ARROW_LEFT, w->construct->previousWidgetBounds);
	
	if ((nWidget == -1 || nWidget == args->cWidget) && args->cWidget >= 0 && !args->widgets[args->cWidget]->isDynamic) {
		args->cWidget =- 1, nWidget = -1;
		while (!isFullyDrawn(args->widgets[n])) n++;
		while (isFullyDrawn(args->widgets[n])) {
			if (args->widgets[n]->isDynamic) {
				nWidget = n;
				break;
			}
			n++;
			if (n == args->nWidgets) break;
		}
	}
	// w->construct->previousWidgetBounds.y += args->y;
	
	

	if (nWidget > -1 && nWidget < args->nWidgets) args->cWidget = nWidget;
	if (args->cWidget == -1) SDL_Flip(scr);
	
	
	// Début de la boucle
	while (ok == 3) {
		dynamic = 0;
		if (args->cWidget >= 0) {
			ok = wActivateWidget(args->widgets[args->cWidget]);
			if (ok < 2) return ok;
		}
		else {
			ok = 2;
			wait_key_pressed();
			if (K_ENTER()) return 1;
			else if (K_ESC()) return 0;
			dynamic = 1;
		}
		
		
		if (K_UP()) {		// on regarde qui est le prochain widget
			
			// S'il n'y a aucun widget actif visible
			if (args->cWidget == -1) {
			  UP:
				n=0;
				while (!isFullyDrawn(args->widgets[n])) n++;
				if (!n) continue;
				
				int y = args->widgets[n-1]->bounds.y + args->y - w->bounds.y - 3;
				ok = 3;
				
				w->construct->previousWidgetBounds.y -= y - args->y;
				SetY(w, y);
				wDrawWidget(w);
				
				if (args->widgets[n-1]->isDynamic) args->cWidget = n-1;
				else {
					if (args->cWidget >= 0) {
						if(!isFullyDrawn(args->widgets[args->cWidget])) {
							args->cWidget = -1;
							SDL_Flip(scr);
						}
					}
					else
						SDL_Flip(scr);
				}
			}
			
			else {
				if (!args->cWidget) continue;
				
				// s'il y a un widget dynamique au dessus pleinement visible on le sélectionne
				n = args->cWidget-1;
				while (isFullyDrawn(args->widgets[n])) {
					if (args->widgets[n]->isDynamic) {
						args->cWidget = n;
						ok = 3;
						break;
					}
					if (!n--) break;
				}
				
				// sinon on affiche le prochain
				if (args->cWidget != n) {
					if (n == -1) continue;
					goto UP;
				}
			}
		}
		
		else if (K_DOWN() || K_TAB()) {
			Widget *wx;
			
			// S'il n'y a aucun widget actif visible
			if (args->cWidget == -1) {
			  DOWN:
				n = args->nWidgets-1;
				while (!isFullyDrawn(args->widgets[n])) n--;
				
				if (n == args->nWidgets-1) continue;
				wx = args->widgets[n+1];
				int y = wx->bounds.y + wx->bounds.h + args->y - w->bounds.y - w->bounds.h + 3;
				ok = 3;
				
				w->construct->previousWidgetBounds.y -= y - args->y;
				SetY(w, y);
				wDrawWidget(w);
				
				if (wx->isDynamic) args->cWidget = n+1;
				else {
					if (args->cWidget >= 0) {
						if(!isFullyDrawn(args->widgets[args->cWidget])) {
							args->cWidget = -1;
							SDL_Flip(scr);
						}
					}
					else
						SDL_Flip(scr);
				}
			}
			
			else {
				if (args->cWidget == args->nWidgets-1) continue;
				
				// s'il y a un widget dynamique au dessous pleinement visible on le sélectionne
				n = args->cWidget+1;
				
				while (isFullyDrawn(args->widgets[n])) {
					if (args->widgets[n]->isDynamic) {
						args->cWidget = n;
						ok = 3;
						break;
					}
					if ((++n) == args->nWidgets) break;
				}
				
				// sinon on affiche le prochain
				if (args->cWidget != n) {
					if (n == args->nWidgets) continue;
					goto DOWN;
				}
			}
		}
	}
	
	if (dynamic) w->construct->previousWidgetBounds = w->bounds;
	
	return 2;
}
Exemplo n.º 7
0
int main(void)
{
	SDL_Surface *scr = wInitSDL();
	DrawFillRect(scr, NULL, SDL_MapRGB(scr->format, 0, 0, 0));
	wInitTheme(NULL);
	
	
	nSDL_Font *font = nSDL_LoadFont(NSDL_FONT_VGA, 255, 255, 255);
	nSDL_DrawStringCF(scr, font, 5, 5, "Couco\45 u !");
	SDL_Flip(scr);
	wait_key_pressed();
	
	nSDL_FreeFont(font);
	
	
	/*
	// Déclaration des widgets
	Widget *mainWidget = wWindow("Aide");
	Widget *tabs = wTab();
	
	// 1er onglet
	Widget *body1 = wBasicLayout(0);
	Widget *subody1 = wHorizontalLayout(0);
	Widget *im_tbtton = wPixmapNTI(image_buttonScratchpad);
	Widget *navigation = wText("Use the T-Button to navigate between tabs.\n\nIf you maintain this button while using RIGHT or LEFT buttons, you will be able to select your tab.\n\nMaintaining the T-Button plus pushing DEL will delete the selected tab from your work space.\n\nTo navigate faster in your texts, use CTRL+Directional Arrow.", 15);
	
	//2e onglet
	Widget *keys = wText("DOC - Quicksave the current file\nSHIFT + DOC - Quickave all files\n\nSHIFT + Directional Arrow - Select text\nCTRL + VAR - Copy selection\nVAR - Paste selection\n\nUse CTRL + (Character Button) or SHIFT + (Character Button) to get another character.\n\nHere are some useful examples :\nCTRL + ' , '  -->   ;\nCTRL + ' 0 '  -->   :\nCTRL + '.'  -->   !\nCTRL + '(-)'  -->   ?\nqu'est-ce qui bug au fond ??? Est-ce quand j'ai un wText avec progressbar mais non éditable ???\nCTRL+'2' = '\"'\nCTRL+'/' '\%'\nCTRL+'(' = '['\nSHIFT+'(' = '{'\nSHIFT+1 = '<'\nSHIT+'2' = '_'\nSHIFT+'3' = '>'\netc...\n\nUse CTRL+'?!>' to get some special characters.	", 17);
// 
	// 3e onglet
	Widget *body3 = wGridLayout(1, 3,0);
	Widget *text1 = wText("Rename a file with '.py' or '.py.tns' extension to get Python's syntax highlights.", 3);
	Widget *text2 = wText("You can then click ENTER at any time to execute and test your program.", 3);
	Widget *text3 = wText("If you placed the Micropython executable into a specific location, indicate his path via the 'Options' dialog box.", 3);
	
	
	wText_SetUnEditable(navigation);
	wText_SetUnEditable(keys);
	wText_SetUnEditable(text1);
	wText_SetUnEditable(text2);
	wText_SetUnEditable(text3);
	wTab_AddTab(tabs, "Navigation", body1);
	wTab_AddTab(tabs, "Keys", keys);
	wTab_AddTab(tabs, "Python", body3);
	
	wAddWidget(mainWidget, tabs);
	
	wAddWidget(body1, subody1);
	wAddWidget(subody1, im_tbtton);
	wAddWidget(subody1, wExLabel("<--- This is the awesome T-BUTTON.", ALIGN_LEFT, nSDL_LoadFont(NSDL_FONT_VGA, 204,15,225)));
	wAddWidget(body1, navigation);
	
	wAddWidget(body3, text1);
	wAddWidget(body3, text2);
	wAddWidget(body3, text3);
	
	wSetHeight(subody1, 24);
	wSetWidth(mainWidget, 300);
	wSetHeight(mainWidget, 220);
		
	wExecConstruct(mainWidget);//*/

	wCloseTheme();
	SDL_Quit();
	return 1;
}