Example #1
0
void Tooltip_Dtor(Tooltip *me)
{
    FREEIF(me->pStringData);
    RELEASEIF(me->piDisplay);
    RELEASEIF(me->piShell);
    CALLBACK_Cancel(&me->cb);
    ZEROAT(me);
}
int CSettings_New(IForm** ppo, IShell *piShell,IRootForm *pRootForm) 
{
	int result=0;
	IImage* m_pIImage;
	//allocate space for the form
	CSettings *pMe = MALLOCREC(CSettings);
	if(!pMe)
		return ENOMEMORY;

	pMe->pIShell = piShell;
	pMe->rootForm = pRootForm;

	if(ISHELL_CreateInstance(pMe->pIShell, AEECLSID_FORM, (void**) &pMe->csettings) == 0)
	
	{
		result =  ISHELL_CreateInstance(pMe->pIShell, AEECLSID_PROPCONTAINER, (void**) &pMe->mainContainer);
		*ppo = pMe->csettings;
		m_pIImage = ISHELL_LoadResImage(piShell,RIPPLEVAULT_RES_FILE,IDI_TITLE);
		IFORM_SetTitleImage((IForm*)pMe->csettings,m_pIImage);
		result += IFORM_SetResText((IForm*)pMe->csettings, FID_TITLE, RIPPLEVAULT_RES_FILE, IDS_CONTACTSETTINGS);
		result +=  IFORM_SetSoftkeys((IForm*)pMe->csettings, RIPPLEVAULT_RES_FILE, MAINSK1, PHOTOSK2);
		result += CSettings_PopulateMainContainer(pMe);	//add items to the form
	
	RELEASEIF(m_pIImage);
	}
	return result;
}
Example #3
0
void StatusBox_Dtor(StatusBox *me)
{
   FREEIF(me->pStringData);
   CALLBACK_Cancel(&me->cb);
   RELEASEIF(me->piImage);
   ZEROAT(me);
}
Example #4
0
uint32 CEventDispatcher_Release(IEventDispatcher* po)
{
    DECLARE_ME(CEventDispatcher);

    if (1 == CBase_Refs(po))
    {
        RELEASEIF(pMe->m_pListeners);
    }

    return CBase_Release((IBase*)po);
}
Example #5
0
static IWidget* MemChecker_CreateButton(MemChecker* pMe, const char* pszName, int x, int y, int dx, int dy, const AECHAR* pszText)
{
    IWidget *piwStatic = NULL;
    IWidget *piButton = NULL;
    IImage *piImage = NULL;
    IBitmap *piMaskBitmap = NULL;
    NativeColor ncTrans;

    IClassFactory_CreateInstance(pMe->m_pIClassFactory, XCLSID_Button, (void**)&piButton);
    IWidget_SetName(piButton, pszName);
    IWidget_SetPosition(piButton, x, y);
    IWidget_SetSize(piButton, dx, dy);
    IWidget_SetBorderWidth(piButton, 0);
    IWidget_SetBGColor(piButton, RGB_NONE);
    piImage = ISHELL_LoadResImage(pMe->a.m_pIShell, MEMCHECKER_RES_FILE, IDI_BUTTON_BG);
    IWidget_SetBGImage(piButton, piImage);
    RELEASEIF(piImage);
    piImage = ISHELL_LoadResImage(pMe->a.m_pIShell, MEMCHECKER_RES_FILE, IDI_BUTTON_BG_A);
    IWidget_SetProperty(piButton, PROP_ACTIVE_BGIMAGE, piImage);
    RELEASEIF(piImage);
    piImage = ISHELL_LoadResImage(pMe->a.m_pIShell, MEMCHECKER_RES_FILE, IDI_BUTTON_BG_S);
    IWidget_SetProperty(piButton, PROP_SELECTED_ACTIVE_BGIMAGE, piImage);
    RELEASEIF(piImage);
    piMaskBitmap = ISHELL_LoadResBitmap(pMe->a.m_pIShell, MEMCHECKER_RES_FILE, IDI_BUTTON_MASK);
    ncTrans = IBitmap_RGBToNative(piMaskBitmap, RGB_BLACK);
    IBitmap_SetTransparencyColor(piMaskBitmap, ncTrans);
    IWidget_SetMaskBitmap(piButton, piMaskBitmap);
    RELEASEIF(piMaskBitmap);
    {
        IClassFactory_CreateInstance(pMe->m_pIClassFactory, XCLSID_StaticCtl, (void **)&piwStatic);
        IWidget_SetSize(piwStatic, dx, dy);
        IWidget_SetBorderWidth(piwStatic, 0);
        IWidget_SetBGColor(piwStatic, RGB_NONE);
        IWidget_SetFGColor(piwStatic, RGB_WHITE);
        IWidget_SetText(piwStatic, pszText, TRUE);
        IContainer_Insert((IContainer*)piButton, piwStatic, -1, NULL);
        RELEASEIF(piwStatic);
    }

    return piButton;
}
Example #6
0
static int MemChecker_CreateMainMenu(MemChecker* pMe)
{
    IWindow *piWindow = NULL;
    IWidget *piWidget = NULL;
    AECHAR *pszText = NULL;

    IClassFactory_CreateInstance(pMe->m_pIClassFactory, XCLSID_Window, (void **)&piWindow);
    IWidget_SetName((IWidget*)piWindow, "Window1");
    IWindow_SetSize(piWindow, 240, 320);
    IDesktopWindow_AddWindow(pMe->m_pIDesktopWindow, piWindow);
    IWidget_Release((IWidget*)piWindow);

    ISHELL_LoadResStringEx(pMe->a.m_pIShell, MEMCHECKER_RES_FILE, IDS_BEGIN_WATCH, &pszText);
    piWidget = MemChecker_CreateButton(pMe, "Button1", 0, 0, 96, 84, pszText);
    if (NULL != piWidget)
    {
        Listener* pListener = MALLOCREC(Listener);
        Listener_Init(pListener, MemChecker_Button_Listener, pMe);
        IWidget_AddListener(piWidget, pListener);

        IWidget_SetID(piWidget, IDS_BEGIN_WATCH);
        IWindow_Insert(piWindow, piWidget, -1, NULL);
        RELEASEIF(piWidget);
    }

    ISHELL_LoadResStringEx(pMe->a.m_pIShell, MEMCHECKER_RES_FILE, IDS_RUN_AND_WATCH, &pszText);
    piWidget = MemChecker_CreateButton(pMe, "Button2", 72, 42, 96, 84, pszText);
    if (NULL != piWidget)
    {
        Listener* pListener = MALLOCREC(Listener);
        Listener_Init(pListener, MemChecker_Button_Listener, pMe);
        IWidget_AddListener(piWidget, pListener);

        IWidget_SetID(piWidget, IDS_RUN_AND_WATCH);
        IWindow_Insert(piWindow, piWidget, -1, NULL);
        RELEASEIF(piWidget);
    }

    ISHELL_LoadResStringEx(pMe->a.m_pIShell, MEMCHECKER_RES_FILE, IDS_ABOUT, &pszText);
    piWidget = MemChecker_CreateButton(pMe, "Button3", 144, 0, 96, 84, pszText);
    if (NULL != piWidget)
    {
        Listener* pListener = MALLOCREC(Listener);
        Listener_Init(pListener, MemChecker_Button_Listener, pMe);
        IWidget_AddListener(piWidget, pListener);

        IWidget_SetID(piWidget, IDS_ABOUT);
        IWindow_Insert(piWindow, piWidget, -1, NULL);
        RELEASEIF(piWidget);
    }

    piWidget = MemChecker_CreateButton(pMe, NULL, 0, 84, 96, 84, WSTRDUP(L"Unimplemented"));
    if (NULL != piWidget)
    {
        IWindow_Insert(piWindow, piWidget, -1, NULL);
        RELEASEIF(piWidget);
    }
    piWidget = MemChecker_CreateButton(pMe, NULL, 72, 126, 96, 84, WSTRDUP(L"Unimplemented"));
    if (NULL != piWidget)
    {
        IWindow_Insert(piWindow, piWidget, -1, NULL);
        RELEASEIF(piWidget);
    }
    piWidget = MemChecker_CreateButton(pMe, NULL, 144, 84, 96, 84, WSTRDUP(L"Unimplemented"));
    if (NULL != piWidget)
    {
        IWindow_Insert(piWindow, piWidget, -1, NULL);
        RELEASEIF(piWidget);
    }
    piWidget = MemChecker_CreateButton(pMe, NULL, 0, 168, 96, 84, WSTRDUP(L"Unimplemented"));
    if (NULL != piWidget)
    {
        IWindow_Insert(piWindow, piWidget, -1, NULL);
        RELEASEIF(piWidget);
    }
    piWidget = MemChecker_CreateButton(pMe, NULL, 72, 210, 96, 84, WSTRDUP(L"Unimplemented"));
    if (NULL != piWidget)
    {
        IWindow_Insert(piWindow, piWidget, -1, NULL);
        RELEASEIF(piWidget);
    }
    piWidget = MemChecker_CreateButton(pMe, NULL, 144, 168, 96, 84, WSTRDUP(L"Unimplemented"));
    if (NULL != piWidget)
    {
        IWindow_Insert(piWindow, piWidget, -1, NULL);
        RELEASEIF(piWidget);
    }

    IContainer_Invalidate((IContainer *)pMe->m_pIDesktopWindow, NULL, NULL);

    return SUCCESS;
}
Example #7
0
/*===========================================================================
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 MemChecker_HandleEvent(MemChecker* pMe, AEEEvent eCode, uint16 wParam, uint32 dwParam)
{
#if 1
    // for debugging
    if (EVT_POINTER_DOWN == eCode)
    {
        AEERect rc;
        int x, y;
        AEE_POINTER_GET_XY((char *)dwParam, &x, &y);
        SETAEERECT(&rc, x, y, 2, 2);
        IDisplay_FillRect(pMe->a.m_pIDisplay, &rc, RGB_BLACK);
        IDisplay_Update(pMe->a.m_pIDisplay);
    }
#endif

    if (pMe->m_pIDesktopWindow 
        && IDesktopWindow_HandleEvent(pMe->m_pIDesktopWindow, eCode, wParam, dwParam))
    {
        return TRUE;
    }

    switch (eCode) 
    {
        // App is told it is starting up
    case EVT_APP_START:
        DBGPRINTF("##MemChecker_HandleEvent: EVT_APP_START ##############");

        if (pMe->m_bBackground)
        {
            pMe->m_bBackground = FALSE;
            IContainer_Invalidate((IContainer *)pMe->m_pIDesktopWindow, NULL, NULL);
            return TRUE;
        }

        ISHELL_CreateInstance(pMe->a.m_pIShell, AEECLSID_APPLETCTL, (void **)&pMe->m_pIAppletCtl);
        IniFileParser_LoadFile(pMe->a.m_pIShell, MemChecker_ParseLineCB, pMe);

        // ClassFactory & DestopWindow
        pMe->m_pIClassFactory = XClassFactory_New();
        IClassFactory_CreateInstance(pMe->m_pIClassFactory, XCLSID_DesktopWindow, (void **)&pMe->m_pIDesktopWindow);
        IWidget_SetName((IWidget*)pMe->m_pIDesktopWindow, "DesktopWindow");
        IDesktopWindow_SetDisplay(pMe->m_pIDesktopWindow, pMe->a.m_pIDisplay);
        IWidget_SetRectEx((IWidget*)pMe->m_pIDesktopWindow, 0, 0, pMe->DeviceInfo.cxScreen, pMe->DeviceInfo.cyScreen);

        MemChecker_CreateMainMenu(pMe);

        return(TRUE);


    // App is told it is exiting
    case EVT_APP_STOP:
        DBGPRINTF("##MemChecker_HandleEvent: EVT_APP_STOP ###################");

        if (pMe->m_bBackground)
        {
            *(boolean *)dwParam = FALSE;
            return TRUE;
        }

        CALLBACK_Cancel(&pMe->m_cbModUnload);
        CALLBACK_Cancel(&pMe->m_cbWaitForAppStartup);

        MemHook_Uninstall();

        RELEASEIF(pMe->m_pIClassFactory);
        RELEASEIF(pMe->m_pIDesktopWindow);

        RELEASEIF(pMe->m_pIAppletCtl);

        return(TRUE);


        // App is being suspended 
    case EVT_APP_SUSPEND:
        DBGPRINTF("##MemChecker_HandleEvent: EVT_APP_SUSPEND ################");

        return(TRUE);


        // App is being resumed
    case EVT_APP_RESUME:
        DBGPRINTF("##MemChecker_HandleEvent: EVT_APP_RESUME #################");
        IContainer_Invalidate((IContainer *)pMe->m_pIDesktopWindow, NULL, NULL);

        return(TRUE);


        // An SMS message has arrived for this app. Message is in the dwParam above as (char *)
        // sender simply uses this format "//BREW:ClassId:Message", example //BREW:0x00000001:Hello World
    case EVT_APP_MESSAGE:
        // Add your code here...

        return(TRUE);


        // If nothing fits up to this point then we'll just break out
    default:
        break;
    }

    return FALSE;
}
int CSettings_PopulateMainContainer(CSettings* pMe) 
{
	int result = 0;
	ImageStaticWidget* imageWidget = NULL;
	IMenuModel * iMenuModal = NULL;
	IWidget* wItemList;
	IWidget* containerWidget = NULL;
	IWidget* pScrollBar = NULL;
	WExtent we;
	WidgetProp wp;
	IFont *piFont = 0;
	
	result = ISHELL_CreateInstance(pMe->pIShell, AEECLSID_IMAGESTATICWIDGET, (void**)&imageWidget);
	result += ISHELL_CreateInstance(pMe->pIShell, AEECLSID_MENUMODEL, (void**)&iMenuModal);
  	result += ISHELL_CreateInstance(pMe->pIShell, AEECLSID_LISTWIDGET, (void**)&wItemList);
	result += ISHELL_CreateInstance(pMe->pIShell, AEECLSID_SCROLLBARWIDGET, (void**)&pScrollBar);
	result += ISHELL_CreateInstance(pMe->pIShell, AEECLSID_FONTSYSBOLD, (void**)&piFont);
	ISHELL_GetDeviceInfo(pMe->pIShell, &pMe->DeviceInfo);
	
	//load the strings
	pMe->str1 = (AECHAR*) MALLOC(20);
	pMe->str2 = (AECHAR*) MALLOC(20);

	result += ISHELL_LoadResString(pMe->pIShell, RIPPLEVAULT_RES_FILE, IDS_RANGE, pMe->str1, 20);
	result += ISHELL_LoadResString(pMe->pIShell, RIPPLEVAULT_RES_FILE, IDS_SHEDULER, pMe->str2, 20);
	
	//load the images
	pMe->imageInfo1.pwText = (AECHAR*)pMe->str1;
	pMe->imageInfo2.pwText = (AECHAR*)pMe->str2;

	IMENUMODEL_Add(iMenuModal,&pMe->imageInfo1,1,MMF_ENABLED);
	IMENUMODEL_Add(iMenuModal,&pMe->imageInfo2,2,MMF_ENABLED);

	//set the vidget to act as a menu modal vidget
	IWIDGET_SetModel(wItemList, IMENUMODEL_TO_IMODEL(iMenuModal));

	//set the picklist widget properties
	IWIDGET_SetBorderWidth(wItemList, 0);
	IWIDGET_SetItemHeight(wItemList, 30);
	IWIDGET_SetItemWidth(wItemList, pMe->DeviceInfo.cxScreen);
	IWIDGET_SetHintCols(wItemList, 5);
	IWIDGET_GetPreferredExtent(wItemList, &we);
	IWIDGET_SetExtent(wItemList, &we);

	IWIDGET_SetFont((IWidget *)imageWidget, piFont);
	IWIDGET_SetSelectedShadowOffset((IWidget *)imageWidget,2);
	IWIDGET_SetShadowColor((IWidget *)imageWidget,MAKE_RGB(122,122,122));
	IWIDGET_SetSelectedActiveBGColor((IWidget*)imageWidget, MAKE_RGB(128,128,255));
	IWIDGET_SetProperty(pScrollBar, PROP_ACTIVE_SCROLLCOLOR, MAKE_RGB(128,128,255));
	IDECORATOR_SetWidget((IDecorator*)pScrollBar, (IWidget *)wItemList);
	IDECORATOR_SetWidget((IDecorator*)wItemList, (IWidget *)imageWidget);

	// get the view model of the wItemList and register a listener 
	// in order to to pick up operator selection
	{
		IModel* pickListViewModel = NULL;
		IWIDGET_GetViewModel(wItemList, &pickListViewModel);
		IMODEL_AddListenerEx(pickListViewModel, &pMe->menuListener, (PFNLISTENER)MenuModal_EventHandler, pMe);
		IMODEL_Release(pickListViewModel);
	}
	wp.bVisible = TRUE;
	wp.prop = 1;
	IPROPCONTAINER_Insert(pMe->mainContainer, pScrollBar, WIDGET_ZNORMAL, &wp);

	//set WID_FORM to the container
	result = IPROPCONTAINER_QueryInterface(pMe->mainContainer, AEEIID_WIDGET, (void**)&pMe->containerWidget);
	
	HANDLERDESC_Init(&pMe->settingsMenuHandler, CSettings_HandleEvent, pMe, CSettings_Delete);
	IFORM_SetHandler((IForm*)pMe->csettings, &pMe->settingsMenuHandler);	
	if(result ==0) 
	{
		IFORM_SetWidget((IForm*)pMe->csettings, WID_FORM, pMe->containerWidget);
		IWIDGET_MoveFocus(pMe->containerWidget, wItemList);
	}

	IWIDGET_Release((IWidget*)imageWidget);
	IMENUMODEL_Release(iMenuModal);
	IWIDGET_Release(wItemList);
	IWIDGET_Release(pScrollBar);
	if (pMe->containerWidget)
		IWIDGET_Release(pMe->containerWidget);
	
	RELEASEIF(piFont);
		
	if(result != 0)
		return EFAILED;
	
	return result;
}
Example #9
0
PicBrowser::~PicBrowser()  
{
	FREEIF(m_pwszTitle); //释放资源
	RELEASEIF(m_pImage);
}
Example #10
0
/**
  || Function
  || --------
  || static void StatusBox_Init(StatusBox *me)
  ||
  || Description
  || -----------
  || load the IImage, calculate rectangles
  ||
  || Parameters
  || ----------
  || StatusBox *me: the status box
  ||
  || Returns
  || -------
  || nothing
  ||
  || Remarks
  || -------
  ||
  */
static void StatusBox_Init(StatusBox *me)
{
   AEEImageInfo ii;
   
   ZEROAT(&ii);

   /* re-init this stuff every time */
   if ((IImage *)0 != me->piImage) {
      
      IIMAGE_GetInfo(me->piImage, &ii);
      
      if ((ii.cx == 0) || (ii.cy == 0)) {
         /* IIMAGE barfed */
         RELEASEIF(me->piImage);
         ZEROAT(&ii);
      } else if (ii.bAnimated) {
         me->bSelfAnimated = TRUE;
         me->nFrame = -1;
         IIMAGE_SetParm(me->piImage, IPARM_REDRAW, 
                        (int)me->pfnInvalidate, (int)me->pInvalidateData);
      } else {

         uint16 uFrameWidth;

         if (me->uFrameWidth != 0) {
            uFrameWidth = me->uFrameWidth;
         } else { /* use the height, for square frames */
            uFrameWidth = ii.cy;
         }

         me->nFrames = MAX(1,ii.cx/uFrameWidth);
         
         if ((me->nFrames * uFrameWidth) != ii.cx) { 
            /* not exact frames, don't animate */
            me->nFrames = 1;
         } else {
            ii.cx = uFrameWidth; /* fake out rect calc stuff below */
         }

         if (0 == me->uFrameDuration) {
            me->uFrameDuration = 150;
         }
         
         IIMAGE_SetFrameCount(me->piImage, me->nFrames);
         me->nFrame = 0;
         /* 
            Don't do this, run animation myself for invalidation code to work

            animate over 1 second...
            IIMAGE_SetAnimationRate(me->piImage, 1000/nFrames); 
         */
      }
   }

   /* initialize status rectangles */
   
   /* if we found the image above and it's non-empty...*/
   if (0 != ii.cy) {
      me->rcImage.y = me->rcCenter.y + ((me->rcCenter.dy - ii.cy) / 2) - 1;
      me->rcImage.x = me->rcCenter.x + ((me->rcCenter.dx - ii.cx) / 2) - 1;
      /* insist on square */
      me->rcImage.dy = ii.cy + 2;
      me->rcImage.dx = ii.cx + 2;

      /* image too big for screen, fuggedaboudit */
      if ((me->rcImage.dy > me->rcCenter.dy) ||
          (me->rcImage.dx > me->rcCenter.dx)) {
         RELEASEIF(me->piImage);
         ZEROAT(&me->rcImage);
      }
   } else {/* no image, just text box... */
      ZEROAT(&me->rcImage);
   }

   {
      int nAscent;
      int nDescent;
   
      IDISPLAY_GetFontMetrics(me->piDisplay,AEE_FONT_NORMAL,
                              &nAscent,&nDescent);

      me->rcText.dy = nAscent + nDescent + 4;
      
   }

   if ((0 == me->rcImage.dy) || 
       (me->rcImage.dy + me->rcText.dy - 1 > me->rcCenter.dy)) {
      me->rcText.y = 
         me->rcCenter.y + ((me->rcCenter.dy - me->rcText.dy) / 2);
   } else {
      me->rcImage.y -= me->rcText.dy/2;
      me->rcText.y = me->rcImage.y + me->rcImage.dy - 1;      
   }

}