📄 mousedialog.c
字号:
/*===========================================================================
FILE: mousedialog.c
===========================================================================*/
#include "AEEModGen.h" // Module interface definitions
#include "AEEAppGen.h" // Applet interface definitions
#include "AEEShell.h" // Shell interface definitions
#include "AEEStdLib.h"
#include "aeemenu.h"
#include "AEEText.h"
#include "mousedialog.bid"
#include "mousedialog.brh"
#define kColorClearGray 0xC0C0C000
#define kColorClearLightYellow 0xC0FFFF00
#define kColorClearBlack 0x00000000
#define kColorClearDialogBox kColorClearBlack
#define kColorClearDialogBackground kColorClearLightYellow
/*-------------------------------------------------------------------
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 _mousedialog {
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
int m_nScrWidth;
int m_nScrHight;
int m_nLineHight;
int m_nLargeLineHight;
AEERect m_nCIntAreaRect;
IDialog* m_pDialog;
} mousedialog;
/*-------------------------------------------------------------------
Function Prototypes
-------------------------------------------------------------------*/
static boolean mousedialog_HandleEvent(mousedialog* pMe, AEEEvent eCode,
uint16 wParam, uint32 dwParam);
boolean mousedialog_InitAppData(mousedialog* pMe);
void mousedialog_FreeAppData(mousedialog* pMe);
static void dialog_ReleaseObj(void** ppObj);
static boolean dlg_HandleEvent(mousedialog* pMe, AEEEvent eCode,
uint16 wParam, uint32 dwParam);
int AEEClsCreateInstance(AEECLSID ClsId, IShell *pIShell, IModule *po, void **ppObj)
{
*ppObj = NULL;
if( ClsId == AEECLSID_MOUSEDIALOG )
{ //用户定义应用事件处理过程
if( AEEApplet_New(sizeof(mousedialog),
ClsId,
pIShell,
po,
(IApplet**)ppObj,
(AEEHANDLER)mousedialog_HandleEvent,
(PFNFREEAPPDATA)mousedialog_FreeAppData) )
{
if(mousedialog_InitAppData((mousedialog*)*ppObj))
{
return(AEE_SUCCESS);
}
else
{
IAPPLET_Release((IApplet*)*ppObj);
return EFAILED;
}
}
}
return(EFAILED);
}
static boolean mousedialog_HandleEvent(mousedialog* pMe, AEEEvent eCode, uint16 wParam, uint32 dwParam)
{
int nRet;
switch (eCode)
{
case EVT_APP_START:
if (SUCCESS==(nRet=ISHELL_CreateDialog(pMe->a.m_pIShell,MOUSEDIALOG_RES_FILE,
IDD_DEMODLG,NULL)))
{
return TRUE;
}
else
return FALSE;
case EVT_APP_STOP:
return(TRUE);
case EVT_APP_SUSPEND:
return(TRUE);
case EVT_APP_RESUME:
return(TRUE);
case EVT_APP_MESSAGE:
return(TRUE);
case EVT_KEY:
switch(wParam)
{
case AVK_SOFT1:
ISHELL_EndDialog(pMe->a.m_pIShell);
return TRUE;
}
return FALSE;
case EVT_DIALOG_INIT:
pMe->m_pDialog =(IDialog*)dwParam;
//此函数可为对话框设置或重置事件处理程序, 还可以为对话框
//发送给应用程序的应用程序事件或对话框未处理的事件选择备选事件回调。
IDIALOG_SetEventHandler(pMe->m_pDialog,(PFNAEEEVENT)dlg_HandleEvent,pMe);
return TRUE;
case EVT_DIALOG_START:
case EVT_DIALOG_END:
return TRUE;
case EVT_COMMAND:
return TRUE;
default:
break;
}
return FALSE;
}
boolean mousedialog_InitAppData(mousedialog* pMe)
{
pMe->DeviceInfo.wStructSize = sizeof(pMe->DeviceInfo);
ISHELL_GetDeviceInfo(pMe->a.m_pIShell,&pMe->DeviceInfo);
pMe->pIDisplay = pMe->a.m_pIDisplay;
pMe->pIShell = pMe->a.m_pIShell;
pMe->m_nLineHight=IDISPLAY_GetFontMetrics(pMe->a.m_pIDisplay,
AEE_FONT_NORMAL,
NULL,
NULL);
pMe->m_nLargeLineHight=IDISPLAY_GetFontMetrics(pMe->a.m_pIDisplay,
AEE_FONT_LARGE,
NULL,
NULL);
pMe->m_nScrHight=pMe->DeviceInfo.cyScreen;
pMe->m_nScrWidth=pMe->DeviceInfo.cxScreen;
SETAEERECT(&pMe->m_nCIntAreaRect,
0,
0,
pMe->DeviceInfo.cxScreen,
pMe->DeviceInfo.cyScreen-pMe->m_nLargeLineHight);
return TRUE;
}
void mousedialog_FreeAppData(mousedialog* pMe)
{
// insert your code here for freeing any resources you have allocated...
// example to use for releasing each interface:
// if ( pMe->pIMenuCtl != NULL ) // check for NULL first
// {
// IMENUCTL_Release(pMe->pIMenuCtl) // release the interface
// pMe->pIMenuCtl = NULL; // set to NULL so no problems trying to free later
// }
//
}
static void dialog_ReleaseObj(void** ppObj)
{
if (ppObj&&*ppObj)
{
(void)IBASE_Release(((IBase*)*ppObj));
*ppObj=NULL;
}
}
static boolean dlg_HandleEvent(mousedialog* pMe, AEEEvent eCode,
uint16 wParam, uint32 dwParam)
{
ITextCtl *pITextCtl,*pIStatic;
AEERect rc;
AECHAR pBuf[60];
AECHAR *p;
int nFits=0;
int width =0;
int height = 0;
#define EDIT_HEIGHT 20
switch(eCode)
{
case EVT_DIALOG_START:
/*添加静态文本*/
pIStatic=(ITextCtl*)IDIALOG_GetControl(pMe->m_pDialog,IDC_STATIC);
SETAEERECT(&rc,0,pMe->m_nScrHight - EDIT_HEIGHT,pMe->m_nScrWidth,pMe->m_nLineHight);
ITEXTCTL_SetRect(pIStatic,&rc);
ITEXTCTL_Redraw(pIStatic);
/*添加编辑框*/
//用于获取与指定标识符关联的控件的 IControl 指针。
pITextCtl=(ITextCtl*)IDIALOG_GetControl(pMe->m_pDialog,IDC_DLGTEXT);
SETAEERECT(&rc,0,0,pMe->m_nScrWidth,pMe->m_nScrHight - EDIT_HEIGHT);
// SETAEERECT(&rc,(pMe->m_nScrWidth-EDIT_WIDTH)/4,
// (pMe->m_nScrHight-EDIT_HEIGHT)/4,EDIT_WIDTH,EDIT_HEIGHT);
ITEXTCTL_SetRect(pITextCtl,&rc);
ITEXTCTL_SetMaxSize(pITextCtl,60);
ITEXTCTL_SetProperties(pITextCtl,TP_FRAME|TP_MULTILINE);
rc.x-=2;rc.dx+=4;rc.y-=2;rc.dy+=6;
IDISPLAY_DrawRect(pMe->a.m_pIDisplay,&rc,kColorClearDialogBox,
kColorClearDialogBackground,
IDF_RECT_FRAME|IDF_RECT_FILL);
ITEXTCTL_Redraw(pITextCtl);
return TRUE;
case EVT_DIALOG_END:
pITextCtl=(ITextCtl*)IDIALOG_GetControl(pMe->m_pDialog,IDC_DLGTEXT);
ITEXTCTL_GetText(pITextCtl,pBuf,sizeof(pBuf));
p=pBuf;
IDISPLAY_ClearScreen(pMe->a.m_pIDisplay);
while(*p)
{
IDISPLAY_MeasureTextEx(pMe->a.m_pIDisplay,
AEE_FONT_NORMAL,
p,
-1,
pMe->m_nScrWidth,
&nFits);
IDISPLAY_DrawText(pMe->a.m_pIDisplay,
AEE_FONT_NORMAL,
p,
nFits,
0,
height,
NULL,
IDF_TEXT_TRANSPARENT);
p+=nFits;
height+=pMe->m_nLineHight;
}
IDISPLAY_Update(pMe->a.m_pIDisplay);
return TRUE;
case EVT_KEY:
return FALSE;
case EVT_COMMAND:
return FALSE;
default:
return FALSE;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -