📄 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 + -