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

📄 cindexmenuform.cpp

📁 brew email program ,comfortable for the basic studier
💻 CPP
字号:
#include "CIndexMenuForm.h"

CIndexMenuForm::CIndexMenuForm(AEEApplet* p,CRootForm* pr):CForm(p)
{
	prootForm = pr;
	IImage * pImage;
	int		 result = SUCCESS;

	if ( !pIMenuModel )
	{
		result = ISHELL_CreateInstance(p->m_pIShell, AEECLSID_MENUMODEL, (void **)&pIMenuModel);
		if ( result == SUCCESS ) 
		{
			IMENUMODEL_SetPfnFree(pIMenuModel, listItemFree);
		}
	}

	pImage = ISHELL_LoadImage(p->m_pIShell, "title.bmp"); 
	if (pImage) 
	{ 
		IFORM_SetTitleImage(this->pIForm, pImage); 
		IIMAGE_Release(pImage);
	} 
	setText(this, FID_TITLE, L"Bmail");
	setText(this, FID_SOFTKEY1, L"Back");
	setText(this, FID_SOFTKEY2, L"OK");

	nCmdId=1;

	pCCreateNewForm = new CCreateNewForm(p,pr);
}

CIndexMenuForm::~CIndexMenuForm()
{
	RELEASEIF( this->pIMenuModel);
}

void CIndexMenuForm::setIndexMenuForm(AEEApplet* p,CRootForm* pr)
{
	//ImageStaticInfo         imageInfo;
	//IImage *                pImage;

	char * a = "Create new";
	char * b = "Inbox";
	char * c = "Outbox";
	char * d = "Check new mail";
	char * e = "Settings";
    AECHAR * temp =( AECHAR*)MALLOC(32*(sizeof(AECHAR)));

	IConstraintContainer	*pIConstraintContainer = NULL;
	WExtent					extent;
	AEERect					rc;
	IValueModel				*pIValueModel = NULL;
	IWidget					*pIMenu = NULL, *pIWidget = NULL, *pIConstraintContainerWidget = NULL;
	IDecorator				*pIMenuAsDecorator = NULL;
	WidgetConstraint		widgetContraint ;
	WExtent					size;
	int						result = ENOMEMORY;

	result = ISHELL_CreateInstance( p->m_pIShell, AEECLSID_CONSTRAINTCONTAINER, (void**)&pIConstraintContainer );
	if ( result != SUCCESS ) goto error;
	result = ICONSTRAINTCONTAINER_QueryInterface( pIConstraintContainer, AEEIID_WIDGET, (void**)&pIConstraintContainerWidget );
	if ( result != SUCCESS ) goto error;

	IROOTFORM_GetClientRect(pr->pIRootForm, NULL, &rc);
	SETWEXTENT(&extent, rc.dx, rc.dy);
	IWIDGET_SetExtent(pIConstraintContainerWidget, &extent);
	setWidget(this, WID_FORM, pIConstraintContainerWidget);

	result = ISHELL_CreateInstance( p->m_pIShell, AEECLSID_LISTWIDGET, (void **)&pIMenu );
	if ( result != SUCCESS ) goto error;
	result = ISHELL_CreateInstance( p->m_pIShell, AEECLSID_STATICWIDGET, (void **)&pIWidget );
	if ( result != SUCCESS ) goto error;
	
	IWIDGET_SetModel( pIMenu, IMENUMODEL_TO_IMODEL( this->pIMenuModel ) );

	IWIDGET_SetBorderWidth( pIMenu , 0 );
	IWIDGET_SetSelectedFGColor( pIWidget, MAKE_RGB(255, 255, 255) );
	IWIDGET_SetSelectedBGColor( pIWidget, RGB_BLACK );

	if(IWIDGET_QueryInterface(pIMenu, AEEIID_DECORATOR, (void**)&pIMenuAsDecorator) == SUCCESS)
	{
		IWIDGET_GetPreferredExtent( pIWidget, &size );
		IWIDGET_SetItemHeight( pIMenu, size.height+40 );
		IDECORATOR_SetWidget( pIMenuAsDecorator, pIWidget );
		IDECORATOR_Release( pIMenuAsDecorator );
	}

	widgetContraint.constraint.top.type = CONSTRAINT_PARENT_TOP;
	widgetContraint.constraint.top.offset = 0;
	widgetContraint.constraint.left.type = CONSTRAINT_PARENT_LEFT;
	widgetContraint.constraint.left.offset = 50;
	widgetContraint.constraint.right.type = CONSTRAINT_PARENT_RIGHT;
	widgetContraint.constraint.right.offset = 0;
	widgetContraint.constraint.bottom.type = WIDGET_SIZE_TO_FIT;
	widgetContraint.constraint.bottom.offset = 0;
	widgetContraint.bVisible = TRUE;

    
	/*
	IWIDGET_GetModel( pIWidget, AEEIID_VALUEMODEL, (IModel **)&pIValueModel );
	IVALUEMODEL_AdaptGet(pIValueModel, (PFNADAPTGET)PickAdapter, 0);

	pImage = ISHELL_LoadImage(p->m_pIShell, "title.bmp");
	STRTOWSTR(a,temp,32);
	imageInfo.pwText = temp;
	imageInfo.piImage = pImage;
	IMENUMODEL_Add( pIMenuModel, &imageInfo, nCmdId++, MMF_ENABLED );
	*/

	
	STRTOWSTR(a,temp,32);
	IMENUMODEL_Add( pIMenuModel, WSTRDUP(temp), nCmdId++, MMF_ENABLED );
	STRTOWSTR(b,temp,32);
	IMENUMODEL_Add( pIMenuModel, WSTRDUP(temp), nCmdId++, MMF_ENABLED );
	STRTOWSTR(c,temp,32);
	IMENUMODEL_Add( pIMenuModel, WSTRDUP(temp), nCmdId++, MMF_ENABLED );
	STRTOWSTR(d,temp,32);
	IMENUMODEL_Add( pIMenuModel, WSTRDUP(temp), nCmdId++, MMF_ENABLED );
	STRTOWSTR(e,temp,32);
	IMENUMODEL_Add( pIMenuModel, WSTRDUP(temp), nCmdId++, MMF_ENABLED );
	

	result = ICONSTRAINTCONTAINER_Insert( pIConstraintContainer, pIMenu, WIDGET_ZNORMAL, &widgetContraint );
	IWIDGET_MoveFocus( pIConstraintContainerWidget, pIMenu );
	HANDLERDESC_Init( &handleIndexMenuForm, handleEvent, this, NULL );
	setHandler( this, &handleIndexMenuForm);
	IWIDGET_SetFocusListener(pIMenu, &listenerMenu, (PFNLISTENER)listenerFocus, this);
	
	
error:
	RELEASEIF( pIValueModel );	
	RELEASEIF( pIWidget );
	RELEASEIF( pIMenu );
	RELEASEIF( pIConstraintContainerWidget );	
	RELEASEIF( pIConstraintContainer );	
	FREE(temp);
	//RELEASEIF( pImage );	
}

boolean  CIndexMenuForm::handleEvent(CIndexMenuForm *po, AEEEvent eCode, uint16 wParam, uint32 dwParam)
{ 
	IWidget	*pIContainerWidget = NULL;

	

	if ( eCode == EVT_KEY )
	{
		IFORM_GetWidget( po->pIForm, WID_FORM, &pIContainerWidget );
		if ( pIContainerWidget ) 
			switch ( wParam )
		{
			case AVK_UP: 
			case AVK_DOWN:
				break;
			case AVK_SOFT1:
				return TRUE;
				break;
			case AVK_SOFT2:
				IROOTFORM_PushForm(po->prootForm->pIRootForm, po->pCCreateNewForm->pIForm);
				break;
		}
		RELEASEIF( pIContainerWidget );
	}
	return HANDLERDESC_Call( &po->handleIndexMenuForm, eCode, wParam, dwParam );
}

void CIndexMenuForm::listItemFree(void* pvItem)
{
	AECHAR* pItem = (AECHAR*) pvItem;
	if (!pItem) return;

	FREE(pItem);
	return;
}

void CIndexMenuForm::listenerFocus( void *p, ModelEvent *pEvent )
{
}

⌨️ 快捷键说明

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