?? vencurschedule.c
字號:
/*===========================================================================
FILE: VenCurSchedule.c
===========================================================================*/
/* 本程序為一個小的課程表設計,能夠實現課程表瀏覽,課程表設計等簡單的功能。有關數據以
文件的形式進行存儲,由于每次對文件的操作都必須對整個文件進行檢索,大大延長了操作的時間,
這是這個程序最大的缺陷,此程序有待進一步優化。這也是我在編寫程序之前沒有仔細的考慮數據的
存儲方式造成的·!以后應該多加注意!
/*===============================================================================
INCLUDES AND VARIABLE DEFINITIONS
=============================================================================== */
#include "AEEModGen.h" // Module interface definitions
#include "AEEAppGen.h" // Applet interface definitions
#include "AEEShell.h" // Shell interface definitions
#include "AEEMenu.h" // Menu interface definitions
#include "AEEText.h"
#include "AEEFile.h"
#include "AEEHtmlViewer.h"
#include "AEEStdLib.h"
#include "VenCurSchedule.bid"
#include "VenCurSchedule_res.h"
/*-------------------------------------------------------------------
Applet structure. All variables in here are reference via "pMe->"
-------------------------------------------------------------------*/
// create an applet structure that's passed around. All variables in
// here will be able to be referenced as static.
typedef struct _Detail
{
AECHAR Course[8];
AECHAR Class[8];
AECHAR Teacher[8];
AECHAR Remind[8];
AECHAR Memo[8];
}DetailFile;
typedef struct _File
{
DetailFile DetailFileArry[8];
AECHAR Course[8];
AECHAR Class[8];
AECHAR Teacher[8];
AECHAR Remind[8];
AECHAR Memo[8];
}ScheduleFile;
typedef struct _VenCurSchedule {
AEEApplet a ; // First element of this structure must be AEEApplet
AEEDeviceInfo DeviceInfo; // always have access to the hardware device information
IDisplay *pIDisplay; // give a standard way to access the Display interface
IShell *pIShell; // give a standard way to access the Shell interface
IMenuCtl *pIMenuCtl; // give a standard way to access the MenuCtl interface
IMenuCtl *v_pIMenuCtl;
IMenuCtl *m_pSoftMenu; // Softkey Menu
IMenuCtl *helpSoftMenu;
ITextCtl *pITextCtl;
ITextCtl *CpITextCtl;
ITextCtl *TpITextCtl;
ITextCtl *RpITextCtl;
ITextCtl *MpITextCtl;
ITextCtl *Text[5];
ITextCtl *pDTextCourse;
ITextCtl *pDTextClass;
AEERect m_rScreenRect; // Screen Rect
AEERect m_nClntAreaRect; //Message Rect
AEERect rect;
AEERect m_sRect;
IStatic *m_pIStatic; // Static Control
IStatic *m_phIStatic; // Static congtrol about Help Info;
IBitmap *pScreen;
IBitmap *pBitmap;
IBitmap *pImage;
CtlAddItem addSoftMenu;
IImage *m_pTitleBarImg; // Pointer to the titlebar bitmap image
AEEBitmapInfo pIBitmapInfo;
NativeColor nativecolor;
IDialog *pIDiag;
IHtmlViewer *pIHtml;
JulianType dwWeekDay;
IFileMgr *pIFileMgr;
IFileMgr *pScheduleFileMgr;
IFile *pScheduleFile;
IFile *pIFile;
FileInfo ScheduleFileInfo;
FileInfo m_nFileInfo;
// ScheduleFile pScheduleFileData;
ScheduleFile FileArry[7];
int m_nScrWidth;
int m_nScrHeight;
int m_nLineHeight;
int m_nLargeLineHeight;
int fontHeight;
int fitNumber;
int y;
int point;
int period;
int Eday; //每一天
uint16 day;
uint8 m_nState;
uint32 ScheduleTotleSize;
} VenCurSchedule;
/************************************************************************/
/* */
/************************************************************************/
#define SPLASH_DISPLAY_TIMER 750
#define FINISH_DISPLAY_TIMER 750
#define ABOUT_DISPLAY_TIMER 2000
#define MAXCHAR 2000
#define DIALOG_BORDER_WIDTH 1
#define MAX_RES_STRING_BUF_SIZE 256
#define APP_STATE_MAINMENU 1
#define APP_STATE_SPLASH 2
#define APP_STATE_ABOUT 3
#define APP_STATE_HELP 4
#define APP_STATE_QUIT 5
#define APP_STATE_VMAINMENU 6
#define APP_STATE_DESIGN 7
#define APP_STATE_SYSTEM 8
#define APP_STATE_EVERYDESIGN 9
#define kColorClearGray 0xC0C0C000
#define kColorClearLightYellow 0xC0FFFF00
#define kColorClearBlack 0x00000000
#define kColorClearDialogBox kColorClearBlack
#define kColorClearDialogBackground kColorClearLightYellow
/*-------------------------------------------------------------------
Function Prototypes
-------------------------------------------------------------------*/
static boolean VenCurSchedule_HandleEvent(VenCurSchedule* pMe, AEEEvent eCode,
uint16 wParam, uint32 dwParam);
static boolean VenCurSchedule_InitAppData(VenCurSchedule* pMe); //初始函數
static void VenCurSchedule_FreeAppData(VenCurSchedule* pMe); //釋放函數
static boolean VenCurSchedule_MenuStart(VenCurSchedule* pMe); //主菜單
static void VenCurSchedule_ImageTitle(VenCurSchedule* pMe,uint16 wReslID,int x,int y); //添加標題圖片
static void VenCurSchedule_DevDrawDialog(VenCurSchedule* pMe,const AECHAR *szText); //彈出對話框函數
static void VenCurSchedule_DisplaySplashScreen(VenCurSchedule* pMe); //設置閃屏
static void VenCurSchedule_DisplayAboutScreen(VenCurSchedule* pMe); //關于版本信息
static boolean VenCurSchedule_DisplayHelpScreen(VenCurSchedule* pMe); //幫助
static void VenCurSchedule_DisplayQuitScreen(VenCurSchedule* pMe); //退出系統命令
static void VenCurSchedule_DisplayViewScreen(VenCurSchedule* pMe,uint16 Wday); //瀏覽課程表函數
static void VenCurSchedule_DisplayDesignScreen(VenCurSchedule* pMe,uint16 Wday,int Nodal); //課程設計函數
static void VenCurSchedule_DisplayFontScreen(VenCurSchedule* pMe, uint16 wReslID,int x,int y);//在規定的位置顯示相應的字體
static void VenCurSchedule_ReadScheduleFile(VenCurSchedule* pMe); //讀文件
static void VenCurSchedule_WriteScheduleFile(VenCurSchedule* pMe); //寫文件
static void VenCurSchedule_EveryCourseDesignScreen(VenCurSchedule* pMe); // 對每一節課的設置
static void VenCurSchedule_SystemDesignSCreen(VenCurSchedule* pMe); //系統設置函數
static void VenCurSchedule_FinishSplashScreen(VenCurSchedule* pMe); //對文件進行操作后提示的完成函數
/*===============================================================================
=============================================================================== */
/*===========================================================================
===========================================================================*/
int AEEClsCreateInstance(AEECLSID ClsId, IShell *pIShell, IModule *po, void **ppObj)
{
*ppObj = NULL;
if( ClsId == AEECLSID_VENCURSCHEDULE )
{
// Create the applet and make room for the applet structure
if( AEEApplet_New(sizeof(VenCurSchedule),
ClsId,
pIShell,
po,
(IApplet**)ppObj,
(AEEHANDLER)VenCurSchedule_HandleEvent,
(PFNFREEAPPDATA)VenCurSchedule_FreeAppData) ) // the FreeAppData function is called after sending EVT_APP_STOP to the HandleEvent function
{
//Initialize applet data, this is called before sending EVT_APP_START
// to the HandleEvent function
if(VenCurSchedule_InitAppData((VenCurSchedule*)*ppObj))
{
//Data initialized successfully
return(AEE_SUCCESS);
}
else
{
//Release the applet. This will free the memory allocated for the applet when
// AEEApplet_New was called.
IAPPLET_Release((IApplet*)*ppObj);
return EFAILED;
}
} // end AEEApplet_New
}
return(EFAILED);
}
/*===========================================================================
FUNCTION SampleAppWizard_HandleEvent
DESCRIPTION
This is the EventHandler for this app. All events to this app are handled in this
function. All APPs must supply an Event Handler.
PROTOTYPE:
boolean SampleAppWizard_HandleEvent(IApplet * pi, AEEEvent eCode, uint16 wParam, uint32 dwParam)
PARAMETERS:
pi: Pointer to the AEEApplet structure. This structure contains information specific
to this applet. It was initialized during the AEEClsCreateInstance() function.
ecode: Specifies the Event sent to this applet
wParam, dwParam: Event specific data.
DEPENDENCIES
none
RETURN VALUE
TRUE: If the app has processed the event
FALSE: If the app did not process the event
SIDE EFFECTS
none
===========================================================================*/
static boolean VenCurSchedule_HandleEvent(VenCurSchedule* pMe, AEEEvent eCode, uint16 wParam, uint32 dwParam)
{
switch (eCode)
{
case EVT_DIALOG_INIT:
return (TRUE);
case EVT_DIALOG_START:
return (TRUE);
case EVT_DIALOG_END:
ISHELL_EndDialog(pMe->pIShell);
return (TRUE);
// App is told it is starting up
case EVT_APP_START:
// Add your code here...
VenCurSchedule_DisplaySplashScreen(pMe);
return(TRUE);
// App is told it is exiting
case EVT_APP_STOP:
return TRUE;
case EVT_APP_SUSPEND: //應用程序的掛起事件
if(pMe->pIMenuCtl)IMENUCTL_SetActive(pMe->pIMenuCtl,FALSE);
if(pMe->v_pIMenuCtl)IMENUCTL_SetActive(pMe->v_pIMenuCtl,FALSE);
if(pMe->helpSoftMenu)IMENUCTL_SetActive(pMe->helpSoftMenu,FALSE);
if(pMe->m_pSoftMenu)IMENUCTL_SetActive(pMe->m_pSoftMenu,FALSE);
if(pMe->TpITextCtl)ITEXTCTL_SetActive(pMe->TpITextCtl,FALSE);
if(pMe->RpITextCtl)ITEXTCTL_SetActive(pMe->RpITextCtl,FALSE);
if(pMe->pDTextCourse)ITEXTCTL_SetActive(pMe->pDTextCourse,FALSE);
if(pMe->pDTextClass)ITEXTCTL_SetActive(pMe->pDTextClass,FALSE);
if(pMe->CpITextCtl)ITEXTCTL_SetActive(pMe->CpITextCtl,FALSE);
if(pMe->MpITextCtl)ITEXTCTL_SetActive(pMe->MpITextCtl,FALSE);
if(pMe->pITextCtl)ITEXTCTL_SetActive(pMe->pITextCtl,FALSE);
if(pMe->m_pIStatic) ISTATIC_SetActive(pMe->m_pIStatic,FALSE);
if(pMe->m_phIStatic) ISTATIC_SetActive(pMe->m_phIStatic,FALSE);
return(TRUE);
case EVT_APP_RESUME: //應用程序的掛起恢復事件
if(pMe->pIMenuCtl)IMENUCTL_SetActive(pMe->pIMenuCtl,TRUE);
if(pMe->v_pIMenuCtl)IMENUCTL_SetActive(pMe->v_pIMenuCtl,TRUE);
if(pMe->helpSoftMenu)IMENUCTL_SetActive(pMe->helpSoftMenu,TRUE);
if(pMe->m_pSoftMenu)IMENUCTL_SetActive(pMe->m_pSoftMenu,TRUE);
if(pMe->TpITextCtl)ITEXTCTL_SetActive(pMe->TpITextCtl,TRUE);
if(pMe->RpITextCtl)ITEXTCTL_SetActive(pMe->RpITextCtl,TRUE);
if(pMe->pDTextCourse)ITEXTCTL_SetActive(pMe->pDTextCourse,TRUE);
if(pMe->pDTextClass)ITEXTCTL_SetActive(pMe->pDTextClass,TRUE);
if(pMe->CpITextCtl)ITEXTCTL_SetActive(pMe->CpITextCtl,TRUE);
if(pMe->MpITextCtl)ITEXTCTL_SetActive(pMe->MpITextCtl,TRUE);
if(pMe->pITextCtl)ITEXTCTL_SetActive(pMe->pITextCtl,TRUE);
if(pMe->m_pIStatic)ISTATIC_SetActive(pMe->m_pIStatic,TRUE);
if(pMe->m_phIStatic)ISTATIC_SetActive(pMe->m_phIStatic,TRUE);
return(TRUE);
case EVT_APP_MESSAGE:
case EVT_KEY:
switch(pMe->m_nState)
{
case APP_STATE_HELP:
if (IHTMLVIEWER_HandleEvent(pMe->pIHtml,eCode,wParam,dwParam))
return TRUE;
switch(wParam)
{
case AVK_CLR:
return VenCurSchedule_MenuStart(pMe);
case AVK_SELECT:
return VenCurSchedule_MenuStart(pMe);
default:
break;
}
case APP_STATE_SYSTEM:
switch(wParam)
{
case AVK_CLR:
ISHELL_EndDialog(pMe->pIShell); //關閉對話框
return VenCurSchedule_MenuStart(pMe);
case AVK_SELECT:
return VenCurSchedule_MenuStart(pMe);
default:
break;
}
case APP_STATE_DESIGN:
if(wParam==AVK_DOWN)
{
int i=0;
i=pMe->point;
if (i==5) {
ITEXTCTL_SetActive(pMe->Text[4],FALSE);
IMENUCTL_SetActive(pMe->m_pSoftMenu,TRUE);
}
else if (i==6) {
IMENUCTL_SetActive(pMe->m_pSoftMenu,FALSE);
ITEXTCTL_SetActive(pMe->Text[0],TRUE);
}
else{
ITEXTCTL_SetActive(pMe->Text[i-1],FALSE);
ITEXTCTL_SetActive(pMe->Text[i],TRUE);
}
pMe->point=(++pMe->point)%6;
if (pMe->point==0) {
pMe->point=6;
}
return TRUE;
}
if(wParam == AVK_UP)
{
int i=0;
i=pMe->point;
if (i==5) {
ITEXTCTL_SetActive(pMe->Text[4],TRUE);
IMENUCTL_SetActive(pMe->m_pSoftMenu,FALSE);
}
else if (i==6) {
IMENUCTL_SetActive(pMe->m_pSoftMenu,TRUE);
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -