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

📄 calculator.c

📁 Form/widget演示程序
💻 C
字号:
/*===========================================================================

FILE: Calculator.c
===========================================================================*/


/*===============================================================================
INCLUDES AND VARIABLE DEFINITIONS
=============================================================================== */
#include "AEEModGen.h"          // Module interface definitions
#include "AEEAppGen.h"          // Applet interface definitions
#include "AEEShell.h"           // Shell interface definitions
#include "AEEForm.h"
#include "AEERootForm.h"

#include "AppForm.h"

//define applet structure
typedef struct _CalcApp {
   AEEApplet a; 
   IRootForm* rootForm;
   IForm* mainForm;
   IDisplay* piDisplay;
} CalcApp;

/*-------------------------------------------------------------------
Function Prototypes
-------------------------------------------------------------------*/
static boolean Calculator_HandleEvent(IApplet * pi, AEEEvent eCode, 
                                      uint16 wParam, uint32 dwParam);
static int Calculator_InitAppData(CalcApp* pMe);
static void Calculator_FreeAppData(CalcApp* pMe);


/*===============================================================================
FUNCTION DEFINITIONS
=============================================================================== */


int AEEClsCreateInstance(AEECLSID ClsId,IShell * pIShell,IModule * po,void ** ppObj)
{
   CalcApp* pMe=NULL;
   *ppObj = NULL;

   if(!AEEApplet_New(sizeof(CalcApp), ClsId, pIShell,po,(IApplet**)ppObj,
                     (AEEHANDLER)Calculator_HandleEvent, (PFNFREEAPPDATA) Calculator_FreeAppData))
      return ENOMEMORY;

   pMe = (CalcApp*) *ppObj;

   if(Calculator_InitAppData(pMe) != 0)
      return EFAILED;

   return AEE_SUCCESS;
}


/* Initialize applet data*/
int Calculator_InitAppData(CalcApp* pMe) {
   int result = 0;

   pMe->mainForm = NULL;

   //create rootForm
   result = ISHELL_CreateInstance(pMe->a.m_pIShell, AEECLSID_ROOTFORM, (void**) &pMe->rootForm);

   //set the theme
   if(result == 0)
	   result = IROOTFORM_SetThemeFileName(pMe->rootForm, "theme.bar");

   if(result==0)
      ISHELL_CreateInstance(pMe->a.m_pIShell, AEECLSID_DISPLAY, (void**) &pMe->piDisplay);

   return result;
}


// Free app data
static void Calculator_FreeAppData(CalcApp* pMe) {
   if(pMe->rootForm) {
      IROOTFORM_Release(pMe->rootForm);
      pMe->rootForm = NULL;
   }

   if(pMe->mainForm) {
      IFORM_Release(pMe->mainForm);
      pMe->mainForm = NULL;
   }

   if(pMe->piDisplay) {
      IDISPLAY_Release(pMe->piDisplay);
      pMe->piDisplay = NULL;
   }
}



// App handle event
static boolean Calculator_HandleEvent(IApplet * pi, AEEEvent eCode, uint16 wParam, uint32 dwParam)
{  
   int result=0;
   CalcApp* pMe = (CalcApp*) pi;

   // Allow rootform to handle event first
   if(IROOTFORM_HandleEvent(pMe->rootForm, eCode, wParam, dwParam)) {
      return TRUE;
   }

   switch(eCode) {
   case EVT_APP_START: 
      // create main app form and push it onto the stack
      if(AppForm_New(&pMe->mainForm, pMe->a.m_pIShell, pMe->rootForm, pMe->piDisplay) == 0) {
         IROOTFORM_PushForm(pMe->rootForm, pMe->mainForm);
         return TRUE;
      }
      break;

   case EVT_APP_STOP:
      return TRUE;

   default:
      break;
   }
   return FALSE;
}


⌨️ 快捷键说明

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