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

📄 application.c

📁 microwindows上的修改的GUI
💻 C
字号:
/*
 *  Application layer
 *
 *
 *  COPYRIGHT (c) 2001 - 2010.
 *  emTech System Corporation.
 *
 *  The license and distribution terms for this file may be
 *  found in found in the file LICENSE.
 */

/*	Huangf emcore@263.net
 */
 
#include "emGUI.h"

#include <stdlib.h>
#include <string.h>

static Chain_Control _ApplicationList;

void AppInitialization()
{
	_Chain_Initialize_empty(
		&_ApplicationList
	);
}

Application *FirstApplication()
{
	Application *first;
	/*  ApplicationEnter(); */
	if (_Chain_Is_empty(&_ApplicationList)){
		/*  ApplicationLeave(); */
		return NULL;
	}

	first = (Application *)_ApplicationList.first;

	/*  ApplicationLeave(); */
	return first;
}

Application *CreateApplication(
	void		*appMain,
	void	 	*appProc,
	unsigned32	*phCount
)
{
	unsigned long 	msgQ = 0;		
	Application 	*app = 0;	
	unsigned long 	task = 0;	

	if (appMain == NULL || appProc == NULL || phCount == NULL){
		return NULL;
	}
	
	app = (struct Application *)malloc(sizeof(Application));
	if (app == NULL){
		return NULL;
	}
	memset(app, 0, sizeof(*app));
	
	app->phCount		= phCount;
	app->appProc		= appProc;
	_Chain_Initialize_empty(
		&app->WinList
	);
		
	msgQ = CreateMsgQ();
	if (msgQ == 0){
		goto failed;
	}

	app->msgQ 			= msgQ;					

	task = CreateAppTask(
		app, 
		appMain
	);

	if (task == 0){
		goto failed;
	}
		
	/*  ApplicationEnter(); */
	_Chain_Prepend_unprotected(
		&_ApplicationList,
		&app->node
	);
	/*  ApplicationLeave(); */
	
	PostAppMessage(
		app,
		APPCREATE,
		0,
		0
	);
	
	return app;
	
failed:
	if (task){
		SysDeleteTask(task);
	}
	if (app){
		free(app);
	}
	if (msgQ){
		SysDeleteMsgQ(msgQ);
	}
	return 	NULL;
}

void DestroyApplication(
	Application *app
)
{
	/*  ApplicationEnter(); */
	_Chain_Extract_unprotected(
		&app->node
	);
	/*  ApplicationLeave(); */

/*  task is deleted automatically, 
 *  we only delete messageQ for current application 
 */

	/*  destroy message */
	SysDeleteMsgQ(app->msgQ);
}

boolean SwitchApplication(
	Application *newapp
)
{
	/*  ApplicationEnter(); */		

	if (_Chain_Is_empty(&_ApplicationList)){
		/*  ApplicationLeave(); */
		return FALSE;
	}
	
	if ((Application *)_ApplicationList.first == newapp){
		/*  ApplicationLeave(); */
		return TRUE;
	}
	
	_Chain_Extract_unprotected(
		&newapp->node
	);

	_Chain_Prepend_unprotected(
		&_ApplicationList,
		&newapp->node
	);

	/*  ApplicationLeave(); */
	return TRUE;
}

⌨️ 快捷键说明

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