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

📄 uiprgmgr_new.c

📁 嵌入工linux开发的源码
💻 C
📖 第 1 页 / 共 2 页
字号:
/**************************************************************
        INCLUDE FILES
**************************************************************/
#include <pr2k.h>

#include <sys/syscall.h>
#include <tool/cofflib.h>
#include <kernel/thread.h>
#include <kernel/linklist.h>

#include <uiwnd.h>
#include <uimessage.h>
#include <uirecycle.h>
#include <uiStringRC.h>
#include <uiInfo_box.h>
#include <uiListbox.h>
#include <uiBitmap.h>
#include <uiScroll.h>
#include <uibutton.h>
#include <uiviewport.h>
#include <uiIcon_img.h>
#include <uiprg_mgr.h>
#include <filesys.h>
//#include <FatSys.h>
#include <uikey_hdr.h>

#ifdef __WIN32__
	#include <Machine\Init_Hw.h>
	#include <direct.h>
#else
	#include "pendrv.h"
	#include <dconfig.h>
	#include <machine/arti.mip/basic.h>
#endif

/**************************************************************
        MACRO DEFINE
**************************************************************/

#ifdef _DEBUG
//#define _DEBUG_PM_
#endif

#define PM_HAVE_DIRECTORY
/*
#ifdef CHIPMOS
#define PM_DIRECTORY_NUMBER	    4 
#else
*/
#define PM_DIRECTORY_NUMBER	    6
//#endif

//#define PM_DIRECTORY_NUMBER	8         // by zhang xue ping
#define PM_WISEVALE_STYLE

// PM state mode for WiseVale
#ifdef PM_WISEVALE_STYLE
	#ifndef __WIN32__
//	#include "../../driver/pen/include/wisevale/Pendrv2.h"
	extern unsigned char LCD_Adjusted;
	#else
	#define PEN_READY	1
	unsigned char LCD_Adjusted = PEN_READY;
	#endif

	#define PM_PAGE_FOCUS	0
	#define PM_ICON_FOCUS	1
	#define PM_APP_FOCUS	2
#endif

extern int gLanguage;
//macro of icon
//#define PM_ICON_START_X		1
//#define PM_ICON_START_Y		6
#define PM_ICON_START_X		15
#define PM_ICON_START_Y		0

#define PM_ICON_START_X4	2
#define PM_ICON_START_Y4	8


#define PM_ICON_RANGE_WIDTH		(PM_ICON_WIDTH+24)
//#define PM_ICON_RANGE_WIDTH		(PM_ICON_WIDTH+24+12)       // by zhangxp  2003/07/08
//#define PM_ICON_RANGE_HEIGHT	(PM_ICON_HEIGHT+15)
#define PM_ICON_RANGE_HEIGHT	(PM_ICON_HEIGHT+12)   // by zhang xue ping

#define PM_ICON_DISPLAY_X		12
#define PM_ICON_DISPLAY_Y		1

//#define PM_ICON_INTERVAL_X		0
//#define PM_ICON_INTERVAL_Y		8
#define PM_ICON_INTERVAL_X		20
#define PM_ICON_INTERVAL_Y		8


//special macro for sub window's icon
//#define PM_ICON_START_X_SUB		2
//#define PM_ICON_INTERVAL_X_SUB	5
#define PM_ICON_START_X_SUB		    15               // by zhang xue ping
#define PM_ICON_INTERVAL_X_SUB	    20


/**************************************************************
        GLOBAL VARIABLE
**************************************************************/

extern struct thread * CurrentThread ;// record current thread
extern PF_VOID gaKeyHandler[];

typedef struct tagLaunchableApp
{
	TPM_APP *pApp;
	HNDL hBitmap;
}TLaunchableApp;

static struct tagPU_CommonObj
{

	HNDL hMainWnd; 							// Prg.Mgr main window
	HNDL hSubWnd;  							// Prg.Mgr sub window
	HNDL hVport;							// container
	struct dLinkList tLaunchableAppList;	//usable app in current page;
	struct dLinkList * pAppList;			//all usable app;
	TPM_APP * CurrentApp; 					// 指到current application之data structure的指标;
	int ExtAppAdded;						//indicate if screen should be repainted;
} *UIP = NULL ;

/**************************************************************
	FUNCTION DECLARATION
**************************************************************/

void guiRestoreCustomAreaCallback(void);
DLL_EXP(void) guiRestoreKeyCallback(void);

extern void restore_PIM_Data_To_RamDisk( void );

static int PrgmngUI_Init(void);

STATUS InitLaunchableAppList(int iClassID);
void exeWIN_APP_EXIT(void);

userThread guiProgramManager(void)
{
#ifdef _DEBUG_PM_
	int remain;
#endif
	//Main window;
	HNDL hMainWnd;
	HNDL a_hBitmap[PM_DIRECTORY_NUMBER];
	HNDL a_hInfobox_Main[3];
	HNDL hBitmap_Line_Main;

	//Sub window;
	HNDL hSubWnd;
	HNDL hMainVport, hVport;
	HNDL a_hInfobox_Sub[3];
	HNDL hBitmap_Line_Sub;

	HNDL hCurWnd, hTopWnd;
/*
#ifdef CHIPMOS
	HNDL hChipmosBitmap;
#endif
*/

//	char iconName[LANGUAGE_NUM][];

	int i;
	TPM_APP *pHitApp;
	TGuiMessage message,tempMessage;
	TWindow	* pWnd;
	TLaunchableApp *pLaunchable;
	struct dLinkList *pLinkList;

	TBitmapCaption bitmapCaption;

	//initialize
	guiInitPrgMgr();
	PrgmngUI_Init();

	// 安装 ExternalApp
	if(guiCreateExternalApps()==0)//success
		UIP->ExtAppAdded = 0 ;
  
/*
	guiRegistergaKeyAppID(1, VCARD_APPID); 

	guiRegistergaKeyAppID(6, MEMO_APPID); 
	guiRegistergaKeyAppID(7, CALC_APPID); 

	registerAppShortcut(1, VCARD_APPID);
	registerAppShortcut(6, MEMO_APPID); 
	registerAppShortcut(7, CALC_APPID);
*/
	guiRegistergaKeyAppID(0, PLAYER_APPID); 

	//guiRegistergaKeyAppID(1, RECORDER_APPID); 
	guiRegistergaKeyAppID(1, MEREADER_APPID);    // by zhangxp 2003/05/15
	guiRegistergaKeyAppID(2, SCHE_APPID); 
	//guiRegistergaKeyAppID(3, EBOOK1_APPID); 
	guiRegistergaKeyAppID(3, VCARD_APPID);

	registerAppShortcut(0, PLAYER_APPID);
	registerAppShortcut(1, MEREADER_APPID); 
	registerAppShortcut(2, SCHE_APPID);
	//registerAppShortcut(3, EBOOK1_APPID);
	registerAppShortcut(3, VCARD_APPID);


    hMainWnd=guiWindow_Create(NULL,"",NULL,NULL,GUIWIN_TITLE_NONE|GUIWIN_CLOSE_NONE);
    guiSetPrgMgrWinHandle(hMainWnd);
    UIP->hMainWnd=hMainWnd;
	//hMainVport=guiViewport_Create(0,0,GUI_SCREEN_WIDTH-1,GUI_SCREEN_HEIGHT-18, VPORT_V_SCROLLBAR|VPORT_NONE_BORDER);
	hMainVport=guiViewport_Create(0,0,GUI_SCREEN_WIDTH-1,GUI_SCREEN_HEIGHT-18, VPORT_NONE_BORDER);
#if (PM_DIRECTORY_NUMBER > 6)
	guiViewport_ModiScroll(hMainVport,3,PM_ICON_RANGE_HEIGHT+PM_ICON_INTERVAL_Y,VPORT_V_SCROLLBAR);
#else
	guiViewport_ModiScroll(hMainVport,3,PM_ICON_RANGE_HEIGHT+PM_ICON_INTERVAL_Y-1,VPORT_V_SCROLLBAR);
#endif
	guiControl_Add(hMainWnd,hMainVport);

	hSubWnd=guiWindow_Create(hMainWnd,"",NULL,NULL,GUIWIN_TITLE_NONE|GUIWIN_CLOSE_NONE);
	UIP->hSubWnd=hSubWnd;

	//hVport=guiViewport_Create(0,0,GUI_SCREEN_WIDTH-1,GUI_SCREEN_HEIGHT-17, VPORT_V_SCROLLBAR|VPORT_NONE_BORDER);
	hVport=guiViewport_Create(0,0,GUI_SCREEN_WIDTH-1,GUI_SCREEN_HEIGHT-18, VPORT_V_SCROLLBAR|VPORT_NONE_BORDER);
#if (PM_DIRECTORY_NUMBER > 6)
	guiViewport_ModiScroll(hVport,3,PM_ICON_RANGE_HEIGHT+PM_ICON_INTERVAL_Y,VPORT_V_SCROLLBAR);
#else
	guiViewport_ModiScroll(hVport,3,PM_ICON_RANGE_HEIGHT+PM_ICON_INTERVAL_Y-1,VPORT_V_SCROLLBAR);
#endif
	UIP->hVport=hVport;

	//a_hInfobox_Main[0]=guiInfoBox_Create(0,146,31,158,GUI_RUNTIME_NON_CLOCK|GUI_RUNTIME_NON_SOLAR_DAY|GUI_RUNTIME_NON_LUNAR_DAY|GUI_RUNTIME_NON_WEEK);
	//a_hInfobox_Main[1]=guiInfoBox_Create(32,146,101,158,GUI_RUNTIME_NON_CLOCK|GUI_RUNTIME_NON_BATTERY_REMAIN/*|GUI_RUNTIME_INVERT*/);
	//a_hInfobox_Main[2]=guiInfoBox_Create(102,146,158,158,GUI_RUNTIME_NON_SOLAR_DAY|GUI_RUNTIME_NON_LUNAR_DAY|GUI_RUNTIME_NON_WEEK|GUI_RUNTIME_NON_BATTERY_REMAIN);

	//a_hInfobox_Sub[0]=guiInfoBox_Create(0,146,31,158,GUI_RUNTIME_NON_CLOCK|GUI_RUNTIME_NON_SOLAR_DAY|GUI_RUNTIME_NON_LUNAR_DAY|GUI_RUNTIME_NON_WEEK);
	//a_hInfobox_Sub[1]=guiInfoBox_Create(32,146,101,158,GUI_RUNTIME_NON_CLOCK|GUI_RUNTIME_NON_BATTERY_REMAIN/*|GUI_RUNTIME_INVERT*/);
	//a_hInfobox_Sub[2]=guiInfoBox_Create(102,146,158,158,GUI_RUNTIME_NON_SOLAR_DAY|GUI_RUNTIME_NON_LUNAR_DAY|GUI_RUNTIME_NON_WEEK|GUI_RUNTIME_NON_BATTERY_REMAIN);

	a_hInfobox_Main[0]=guiInfoBox_Create(0, GUI_SCREEN_HEIGHT-14, 31, GUI_SCREEN_HEIGHT-2,GUI_RUNTIME_NON_CLOCK|GUI_RUNTIME_NON_SOLAR_DAY|GUI_RUNTIME_NON_LUNAR_DAY|GUI_RUNTIME_NON_WEEK);
	a_hInfobox_Main[1]=guiInfoBox_Create(32, GUI_SCREEN_HEIGHT-14, 101, GUI_SCREEN_HEIGHT-2, GUI_RUNTIME_NON_CLOCK|GUI_RUNTIME_NON_BATTERY_REMAIN/*|GUI_RUNTIME_INVERT*/);
	a_hInfobox_Main[2]=guiInfoBox_Create(102, GUI_SCREEN_HEIGHT-14, 158, GUI_SCREEN_HEIGHT-2, GUI_RUNTIME_NON_SOLAR_DAY|GUI_RUNTIME_NON_LUNAR_DAY|GUI_RUNTIME_NON_WEEK|GUI_RUNTIME_NON_BATTERY_REMAIN);

	a_hInfobox_Sub[0]=guiInfoBox_Create(0, GUI_SCREEN_HEIGHT-14,31,GUI_SCREEN_HEIGHT-2,GUI_RUNTIME_NON_CLOCK|GUI_RUNTIME_NON_SOLAR_DAY|GUI_RUNTIME_NON_LUNAR_DAY|GUI_RUNTIME_NON_WEEK);
	a_hInfobox_Sub[1]=guiInfoBox_Create(32, GUI_SCREEN_HEIGHT-14, 101,GUI_SCREEN_HEIGHT-2,GUI_RUNTIME_NON_CLOCK|GUI_RUNTIME_NON_BATTERY_REMAIN/*|GUI_RUNTIME_INVERT*/);
	a_hInfobox_Sub[2]=guiInfoBox_Create(102, GUI_SCREEN_HEIGHT-14, 158, GUI_SCREEN_HEIGHT-2, GUI_RUNTIME_NON_SOLAR_DAY|GUI_RUNTIME_NON_LUNAR_DAY|GUI_RUNTIME_NON_WEEK|GUI_RUNTIME_NON_BATTERY_REMAIN);

	hBitmap_Line_Main = guiBitmap_Create(1, GUI_SCREEN_HEIGHT-17, GUI_SCREEN_WIDTH-2, GUI_SCREEN_HEIGHT-16, icon_Gui_Line, BMP_BITMAP);
	hBitmap_Line_Sub  = guiBitmap_Create(1, GUI_SCREEN_HEIGHT-17, GUI_SCREEN_WIDTH-2, GUI_SCREEN_HEIGHT-16, icon_Gui_Line, BMP_BITMAP);

	for(i=0;i<3;i++)
	{
		guiControl_Add(hMainWnd,a_hInfobox_Main[i]);
		guiControl_Add(hSubWnd,a_hInfobox_Sub[i]);
	}

	//Add control into main window;
	for(i=0;i<PM_DIRECTORY_NUMBER;i++)
	{
		int x1, y1, x2, y2;
		/*
		x1 = PM_ICON_START_X+(i%4)*(PM_ICON_RANGE_WIDTH+PM_ICON_INTERVAL_X);
		y1 = PM_ICON_START_Y+(i/4)*(PM_ICON_RANGE_HEIGHT+PM_ICON_INTERVAL_Y);
		x2 = PM_ICON_START_X+(i%4)*(PM_ICON_RANGE_WIDTH+PM_ICON_INTERVAL_X)+PM_ICON_RANGE_WIDTH;
		y2 = PM_ICON_START_Y+(i/4)*(PM_ICON_RANGE_HEIGHT+PM_ICON_INTERVAL_Y)+PM_ICON_RANGE_HEIGHT;
		*/
		x1 = PM_ICON_START_X+(i%2)*(PM_ICON_RANGE_WIDTH+PM_ICON_INTERVAL_X);
		x2 = PM_ICON_START_X+(i%2)*(PM_ICON_RANGE_WIDTH+PM_ICON_INTERVAL_X)+PM_ICON_RANGE_WIDTH;
		/* Kevin , 2003/5/28 */
/*
#ifdef CHIPMOS
		x1 = PM_ICON_START_X4+(i%2)*(PM_ICON_RANGE_WIDTH+PM_ICON_INTERVAL_X+18);
		x2 = PM_ICON_START_X4+(i%2)*(PM_ICON_RANGE_WIDTH+PM_ICON_INTERVAL_X+18)+PM_ICON_RANGE_WIDTH+12;
		y1 = PM_ICON_START_Y4+(i/2)*(PM_ICON_RANGE_HEIGHT+PM_ICON_INTERVAL_Y+40);
		y2 = PM_ICON_START_Y4+(i/2)*(PM_ICON_RANGE_HEIGHT+PM_ICON_INTERVAL_Y+40)+PM_ICON_RANGE_HEIGHT;		

#else
*/
#if (PM_DIRECTORY_NUMBER > 6)
		y1 = PM_ICON_START_Y+(i/2)*(PM_ICON_RANGE_HEIGHT+PM_ICON_INTERVAL_Y);
		y2 = PM_ICON_START_Y+(i/2)*(PM_ICON_RANGE_HEIGHT+PM_ICON_INTERVAL_Y)+PM_ICON_RANGE_HEIGHT;

#else
		y1 = PM_ICON_START_Y+(i/2)*(PM_ICON_RANGE_HEIGHT+PM_ICON_INTERVAL_Y-1);
		y2 = PM_ICON_START_Y+(i/2)*(PM_ICON_RANGE_HEIGHT+PM_ICON_INTERVAL_Y-1)+PM_ICON_RANGE_HEIGHT;		
#endif
	
//#endif
		a_hBitmap[i]=guiBitmap_Create(x1, y1, x2, y2, a_icon_PM_Directory[i],0);

		//guiBitmap_SetString(a_hBitmap[i], RES_STR_PRGMGR_DIR[gLanguage][i]);
		strcpy(bitmapCaption.szCaption_ENG, RES_STR_PRGMGR_DIR[i][0]);
		strcpy(bitmapCaption.szCaption_CHT, RES_STR_PRGMGR_DIR[i][1]);
		strcpy(bitmapCaption.szCaption_CHS, RES_STR_PRGMGR_DIR[i][2]);
		guiBitmap_SetString(a_hBitmap[i], &bitmapCaption);
		
/*		
#ifdef CHIPMOS
		guiBitmap_SetPicLocation(a_hBitmap[i],PM_ICON_DISPLAY_X+7,PM_ICON_DISPLAY_Y);
#else
*/
		guiBitmap_SetPicLocation(a_hBitmap[i],PM_ICON_DISPLAY_X,PM_ICON_DISPLAY_Y);
//#endif
	
		//guiControl_Add(hMainWnd,a_hBitmap[i]);
		guiViewport_AddControl(hMainVport, a_hBitmap[i]);
		//guiControl_Enable(pLaunchable->hBitmap);


	}
	guiControl_Add(hMainWnd,hBitmap_Line_Main);

	//Add control into sub window;
	guiControl_Add(hSubWnd,hVport);
	guiControl_Add(hSubWnd,hBitmap_Line_Sub);

/*
#ifdef CHIPMOS
	hChipmosBitmap = guiBitmap_Create(50, 40,  43+60, 32+60, icon_Gui_Chipmos,0);
	guiViewport_AddControl(hMainVport, hChipmosBitmap);
	guiControl_Disable(hChipmosBitmap);
#endif
*/
#ifdef PM_HAVE_DIRECTORY
//	guiFillRect (0, 0, 143, 159, 159, GUI_LIGHTGRAY, REPLACE_STYLE);

	guiWindow_Show(hMainWnd);
	hCurWnd = hMainWnd;


#else
	InitLaunchableAppList(0);
	guiWindow_Show(hSubWnd);
	hCurWnd = hSubWnd;
#endif


//	pcelp_proc();

	pWnd=(TWindow *)hMainWnd;
#if defined(AR2001)&&(AR2001==2)
	while(1)
		ShellEntry();
#endif
	while(1)
	{
		if(guiDequeue(pWnd->messageQueue,&message)==-1)
		{
			continue;
		}
		switch(message.messageType)
		{
		case KEYPAD_CLICK:
			guiArrowKeyCallBack(message.x);

		case BITMAP_CLICK:
			//directory
			if(hMainWnd==(HNDL)gpTopWindow)
			{
				for(i=0;i<PM_DIRECTORY_NUMBER;i++)
				{
					if(message.handle==a_hBitmap[i])
					{
						break;
					}
				}
				if(i>=PM_DIRECTORY_NUMBER)
				{
					break;
				}
				InitLaunchableAppList(i);
				guiWindow_Show(hSubWnd);
				hCurWnd = hSubWnd;
				guiControl_Show(hVport);
				//guiDrawLine(0,0,144,159,144,GUI_BLACK,GUI_HATCH);
				//guiDrawLine(0,0, GUI_SCREEN_HEIGHT-16,159, GUI_SCREEN_HEIGHT-16,GUI_BLACK,GUI_HATCH);

				break;
			}

			//start run ap;
			if(hSubWnd==(HNDL)gpTopWindow)
			{
				pLinkList=UIP->tLaunchableAppList.back;
				while(pLinkList)
				{
					pLaunchable=(TLaunchableApp *)pLinkList->elementPointer;
					if(message.handle==pLaunchable->hBitmap)
					{
						if (pLaunchable->pApp)
						{
							tempMessage.messageType=PRG_MGR_SWITCH_APP;
							tempMessage.handle=(HNDL)pLaunchable->pApp;
							_guiEnqueue(((TWindow *)(UIP->hMainWnd))->messageQueue,&tempMessage);
						}

						break;
					}
					pLinkList=pLinkList->back;
				}
			}
			break;
		case PRG_MGR_SWITCH_APP:
#ifndef __WIN32__
			{
				int Device_Status;
				getDeviceStatus(POWER_SAVING,&Device_Status);
				if(Device_Status==0)
					setDeviceStatus(POWER_SAVING,(void *)60);
			}
#endif

			//目前有 Current AP ( 不管执行了没 )
			if (UIP->CurrentApp!=NULL)
			{
				//同一个AP,离开
				if (message.handle == UIP->CurrentApp->handle)
				{
					break;
				}
				//不同的AP,砍
				else
				{
					/*
					if(((DWORD)gpTopWindow) != UIP->hMainWnd&&((DWORD)gpTopWindow) != UIP->hSubWnd)
					{
						//UIP->CurrentApp->currentWinHandle = (DWORD)gpTopWindow ;
						break;
					}*/
#ifdef _DEBUG_PM_
					 remain=_debugDisplayMemInfo("before exit ap");
#endif
					exeWIN_APP_EXIT();
#ifdef _DEBUG_PM_
					remain=_debugDisplayMemInfo("after exit ap");
#endif

				}

			}

			//此时没有Current AP, 开始launch new AP
			// restore keypad callback
			guiRestoreKeyCallback();        // by zhangxp  2003/06/28
			guiRestoreCustomAreaCallback();

#ifndef __WIN32__
			LcdOn();//Kevin
#endif

			// empty message in system message queue
			_guiEmptyQueue(SysMsgQueue) ;

			// empty message in PM message queue
			_guiEmptyQueue(pWnd->messageQueue) ;

#ifdef _DEBUG_PM_
			remain=_debugDisplayMemInfo("before launch ap");
#endif

			if (guiLaunchApp(message.handle))
			{

				UIP->CurrentApp = (TPM_APP *)(message.handle);
			}

#ifdef _DEBUG_PM_
			 remain=_debugDisplayMemInfo("after launch ap");
#endif
			break;

⌨️ 快捷键说明

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