⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 main.c

📁 自主国产操作系统的一个应用程序框架.这是内部开发版本,让大家了解FutureAlpha的应用程序和WINDOWS程序的差别
💻 C
字号:
/*
	GUI应用端 of The FutureAlpha Operating System
	Sinomanic

*/

#include "gui\api4guic.h"



//对一个消息进行分流:找到对应的消息处理函数.
CALL_IN_C_FORM void response_msg_by_gui(msg_between_thread *what)
{
	char key;
	char *plocation;
	char str[64];
	

	int i;
	//the node for handler of message
	struct user_msg_handler *msg_list_node;
	
	//printf("\nFa Get a message.");
	//STEP,是通知型消息?
	if(what->msg_status &MSG_STATUS_NOTIFYING)
	{
		//是通知性的,但是,可能是一个地址调用
		if(what->msg_status &MSG_STATUS_IS_ADDRESS_CALL)
		{
			_asm_call_by_address(what->message_name   ,what);
		}
		
		//clear the msg
		what->msg_status	=(MSG_STATUS_IS_END_OF_OPERATION|MSG_STATUS_RECEIVER_REPS|MSG_STATUS_NOTIFYING);								//clear status.
		what->used			=FALSE;																					//clear the occupyied bit,so we can use this position 
	}
	//非通知型消息,那么别人在等待我们完成任务。
	else																			
	{
		//找到对应的处理函数。
		if(what->msg_status &MSG_STATUS_IS_ADDRESS_CALL)
		{
#if 0
			//step,Address calling: Translate FUNC ID to Func Address
			func_address=funcID_to_funcAdress[what->message_name ];
			if(func_address!=NULL)
			{
				//printf("\nFunc ID -> Func Address:%h ",func_address);				
				_asm_call_by_address(func_address ,what);
				
			}
#endif
		}

		
		what->msg_status	=(MSG_STATUS_IS_END_OF_OPERATION|MSG_STATUS_RECEIVER_REPS);	
	}	

}

CALL_IN_C_FORM done_user_main(int argc, char **argv)
{

	int i;


	msg_between_thread *r,*retry,*next_msg;

	struct cwindow *board1, *board2;
	//struct range *screen_space;
    struct cbutton *button;
    struct cscrollbar *bar;
	
    uint app_handle;
	//cdc test
    struct range rect;
	//绘制变量

    



    struct ImageList* imglist;
    struct Bitmap bmp;

    int ret ;

	uint phy,log;
    struct DC           client_dc;
	struct ctoolbox		*toolbox;
	struct cmenubar		*menubar;
	struct cmenu		*menu;
	struct cmenu		*sub_menu;
	struct Pen			pen;
	struct point_position point;
    struct clabel       *label;
    struct ctimer       *timer;
	file				*pfile;
	int					number = 0;

	//
	struct clistbox  *plistbox;
	struct cbutton	 *pbutton;



    msg_between_thread paint_msg;
    msg_between_thread *msg_search_head;
	uint row;
    int p;

    struct data_buf *dbuf;
    byte   buf[1024*2];
	int		time;


    //get the default msg list, this two line is the para of the old main para
    msg_search_head = get_frame_work_default_msg_list();

	//STEP,注册本客户端
	printf("\nFutureAlpha GUI应用端...");
	
	app_handle = register_fgui_app_client("开发时的测试");

	printf("\nGUI 客户端地址:%h",app_handle);
	if(app_handle == 0)
	{
		//??????????返回值如果为0,说明注册一个应用程序没有成功,应该调用kill这个线程
		//??????????释放他所站用的资源
		//add code here
        goto msg_loop;
	}


	board1 = (struct cwindow*) wnd_CreateWnd(NULL,300,100,500,700,"开发时的测试");
    if(board1 == 0)goto msg_loop;


	plistbox = listbox_CreatListBox(board1, 0, 0, 300);

	listbox_InsertListboxItem(plistbox, "dfsdfs", 0);
	listbox_InsertListboxItem(plistbox, "dfsdfs", 0);
	listbox_InsertListboxItem(plistbox, "dfsdfs", 0);
	listbox_InsertListboxItem(plistbox, "dfsdfs", 0);


	pbutton = button_CreateButton(board1, 100, 400, 100, 100, "郁闷");

	ShowWindow(board1, 0);


#if 0
	menubar = menubar_CreateMenuBar((struct CBoard*)board1, 0, 0);
	menubar_InsertMenuBarItem(menubar, NULL, "文件");
	menubar_InsertMenuBarItem(menubar, NULL, "编辑");
	menubar_InsertMenuBarItem(menubar, NULL, "查看");
	menubar_InsertMenuBarItem(menubar, NULL, "收藏");
	menubar_InsertMenuBarItem(menubar, NULL, "工具");
	menubar_InsertMenuBarItem(menubar, NULL, "帮助");

	//insert a new menu
	menu = menu_CreateMenu((struct CBoard*)board1,0,100);//////////////
	menu_InsertMenuItem(menu, NULL, " 111",0,0);


	menu_InsertMenuItem(menu, NULL, " 222",0,0);
	menu_InsertMenuItem(menu, NULL, " 333",0,0);
	menu_InsertMenuItem(menu, NULL, " 444",0,0);
	menu_InsertMenuItem(menu, NULL, " 555",0,0);
	menu_InsertMenuItem(menu, NULL, NULL,FGUIC_MENU_ITEM_SEPARATOR,0);
	menu_InsertMenuItem(menu, NULL, " 666",0,0);
	menubar_AppendPopupmenu(menubar,menu,1);


	sub_menu = menu_CreateMenu((struct CBoard*)board1,0,100);
	menu_InsertMenuItem(sub_menu, NULL, " 111",0,0);
	menu_InsertMenuItem(sub_menu, NULL, " &&&",0,0);
	menu_InsertMenuItem(sub_menu, NULL, " ***",0,0);

	menu_AppendSubMenu(menu, sub_menu, 1);

	sub_menu = menu_CreateMenu((struct CBoard*)board1,0,100);
	menu_InsertMenuItem(sub_menu, NULL, " 222",0,0);
	menu_InsertMenuItem(sub_menu, NULL, " &&&",0,0);
	menu_InsertMenuItem(sub_menu, NULL, " ***",0,0);

	//menu_AppendSubMenu(menu, sub_menu, 2);

	sub_menu = menu_CreateMenu((struct CBoard*)board1,0,100);
	menu_InsertMenuItem(sub_menu, NULL, " 333",0,0);
	menu_InsertMenuItem(sub_menu, NULL, " &&&",0,0);
	menu_InsertMenuItem(sub_menu, NULL, " ***",0,0);

	//menu_AppendSubMenu(menu, sub_menu, 3);
	//insert a new menu

	menu = menu_CreateMenu((struct CBoard*)parent,50,100);
	menu_InsertMenuItem(menu, NULL, " aaa",0,0);
	menu_InsertMenuItem(menu, NULL, " bbb",0,0);
	menu_InsertMenuItem(menu, NULL, " ccc",0,0);
	menu_InsertMenuItem(menu, NULL, " ddd",0,0);
	menu_InsertMenuItem(menu, NULL, NULL,FGUIC_MENU_ITEM_SEPARATOR,0);
	menu_InsertMenuItem(menu, NULL, " abcd",0,0);*/

	//无心,test scroll bar

	//无心,test scroll bar end here

	//test toolbox
	//toolbox = toolbox_CreateToolBox(board1,20,20,0);

	ShowWindow(board1,0);

	//test screen copy
	rect.iX1 =-40;rect.iY1 =-40;
	rect.iX2 =160;rect.iY2 =160;

	bitmap_CreateBitmap(&bmp,40,40,1,32,0);

	CopyScreenToBuffer(&rect,&bmp);

	point.x=30;
	point.y=30;
	dc_CommitUserBitmap(board1,&bmp,&point);

#endif

	
////////////////////////////////////
msg_loop:
	//字定义算法。
	r=msg_search_head;
	while(1)
	{
		
		while(r->msg_status&MSG_STATUS_SENDER_REPS)		//get a usebale msg
		{
			
			
			response_msg_by_gui(r);
			//sprintf(str,"\n 1m:%h ",r);write_debug_info(str,RGB(0,255,255));
			//get next
			if(r->end_of_msg_list)
				r=msg_search_head;
			else
				r++;//not end mask,add a structure to get the next

		}

		//check posible sleep:check cycle,and sleep.
		//check the whole cycle.
		retry=r;
		do
		{
			if(r->msg_status&MSG_STATUS_SENDER_REPS)
			{
				response_msg_by_gui(r);
				//sprintf(str,"\n 2m:%h ",retry);write_debug_info(str,RGB(0,255,255));

			}
			//get next
			if(r->end_of_msg_list)
				r=msg_search_head;
			else
				r++;//not end mask,add a structure to get the next


		}while(retry!=r);

		//no message
		//sleep
		user_thread_want_to_sleep(0);
		
	}
}




⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -