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

📄 ccreatenewform.cpp

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

CCreateNewForm::CCreateNewForm(AEEApplet* p, CRootForm* pr):CForm(p)
{
	this->prootForm = pr;
	IImage * pImage;
	int		 result = SUCCESS;

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

CCreateNewForm::~CCreateNewForm()
{
	RELEASEIF(pITo);
	RELEASEIF(pISub);
	RELEASEIF(pIAccessory);
	RELEASEIF(pIText);
}

void CCreateNewForm::setCreateNewForm(AEEApplet* p,CRootForm* pr)
{
	IConstraintContainer	*pIConstraintContainer;
	IImage * pImage;
	WExtent					extent;
	AEERect					rc;
	IWidget					*pIWidget = NULL, *pIConstraintContainerWidget = NULL;
	WidgetConstraint		widgetContraint ;
	WExtent					size ;
	int						result = SUCCESS;

	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);
	IFORM_SetWidget(this->pIForm, WID_FORM, pIConstraintContainerWidget);
	HANDLERDESC_Init( &handleNewMailForm, handleEvent, this, NULL );
	setHandler( this, &handleNewMailForm );

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

	result = ISHELL_CreateInstance( p->m_pIShell, AEECLSID_STATICWIDGET, (void**)&pIWidget );
	if ( result != SUCCESS ) goto error;
	
	IWIDGET_SetExtent( pIWidget, &size ); 
	IWIDGET_SetText( pIWidget, L"To", FALSE );
	result = ICONSTRAINTCONTAINER_Insert( pIConstraintContainer, pIWidget, WIDGET_ZNORMAL, &widgetContraint ); 
	RELEASEIF( pIWidget );


    
	widgetContraint.constraint.top.offset = 0;
	widgetContraint.constraint.top.type = CONSTRAINT_PREV_TOP;
	widgetContraint.constraint.left.type = CONSTRAINT_PREV_RIGHT;
	widgetContraint.constraint.right.type = CONSTRAINT_PARENT_RIGHT;
	widgetContraint.constraint.bottom.type = WIDGET_SIZE_TO_FIT;

	result = ISHELL_CreateInstance( p->m_pIShell, AEECLSID_TEXTWIDGET, (void**)&pIWidget );
	if ( result != SUCCESS ) goto error;
	IWIDGET_SetExtent( pIWidget, &size ); 
	result = ICONSTRAINTCONTAINER_Insert( pIConstraintContainer, pIWidget, WIDGET_ZNORMAL, &widgetContraint ); 

	IWIDGET_MoveFocus( pIConstraintContainerWidget, pIWidget );

	IWIDGET_GetModel( pIWidget, AEEIID_TEXTMODEL, (IModel **)&pITo );
	RELEASEIF( pIWidget );

    

	widgetContraint.constraint.top.type = CONSTRAINT_PREV_BOTTOM;
	widgetContraint.constraint.top.offset = 0;
	widgetContraint.constraint.left.type = CONSTRAINT_PREV_LEFT;
	widgetContraint.constraint.left.offset = -10;
	widgetContraint.constraint.right.type = WIDGET_SIZE_TO_FIT;

	result = ISHELL_CreateInstance(p->m_pIShell, AEECLSID_STATICWIDGET, (void**)&pIWidget );
	if ( result != SUCCESS ) goto error;
	IWIDGET_SetExtent( pIWidget, &size ); 
	IWIDGET_SetText( pIWidget, L"Sub", FALSE );
	result = ICONSTRAINTCONTAINER_Insert( pIConstraintContainer, pIWidget, WIDGET_ZNORMAL, &widgetContraint ); 
	RELEASEIF( pIWidget );

	

	widgetContraint.constraint.top.offset = 0;
	widgetContraint.constraint.top.type = CONSTRAINT_PREV_TOP;
	widgetContraint.constraint.left.type = CONSTRAINT_PREV_RIGHT;
	widgetContraint.constraint.left.offset = 0;
	widgetContraint.constraint.right.type = CONSTRAINT_PARENT_RIGHT;

	result = ISHELL_CreateInstance( p->m_pIShell, AEECLSID_TEXTWIDGET, (void**)&pIWidget );
	if ( result != SUCCESS ) goto error;
	IWIDGET_SetExtent( pIWidget, &size ); 
	IWIDGET_SetText( pIWidget, L"0.00", FALSE );
	result = ICONSTRAINTCONTAINER_Insert( pIConstraintContainer, pIWidget, WIDGET_ZNORMAL, &widgetContraint ); 
	IWIDGET_GetModel( pIWidget, AEEIID_TEXTMODEL, (IModel **)&pISub );
	RELEASEIF( pIWidget );

    

	widgetContraint.constraint.top.type = CONSTRAINT_PREV_BOTTOM;
	widgetContraint.constraint.top.offset = 0;
	widgetContraint.constraint.left.type = CONSTRAINT_PREV_LEFT;
	widgetContraint.constraint.left.offset = -20;
	widgetContraint.constraint.right.type = WIDGET_SIZE_TO_FIT;

	result = ISHELL_CreateInstance(p->m_pIShell, AEECLSID_IMAGEWIDGET, (void**)&pIWidget );
	pImage = ISHELL_LoadImage(p->m_pIShell, "accessory.bmp"); 
	if (pImage) 
	{ 
		IWIDGET_SetImage(pIWidget, pImage);
		IIMAGE_Release(pImage);
	} 
	if ( result != SUCCESS ) goto error;
	result = ICONSTRAINTCONTAINER_Insert( pIConstraintContainer, pIWidget, WIDGET_ZNORMAL, &widgetContraint ); 
	RELEASEIF( pIWidget );

	

	widgetContraint.constraint.top.offset = 0;
	widgetContraint.constraint.top.type = CONSTRAINT_PREV_TOP;
	widgetContraint.constraint.left.type = CONSTRAINT_PREV_RIGHT;
	widgetContraint.constraint.left.offset = 0;
	widgetContraint.constraint.right.type = CONSTRAINT_PARENT_RIGHT;

	result = ISHELL_CreateInstance( p->m_pIShell, AEECLSID_TEXTWIDGET, (void**)&pIWidget );
	if ( result != SUCCESS ) goto error;
	IWIDGET_SetExtent( pIWidget, &size ); 
	IWIDGET_SetText( pIWidget, L"0.00", FALSE );
	result = ICONSTRAINTCONTAINER_Insert( pIConstraintContainer, pIWidget, WIDGET_ZNORMAL, &widgetContraint ); 
	IWIDGET_GetModel( pIWidget, AEEIID_TEXTMODEL, (IModel **)&pIAccessory );
	RELEASEIF( pIWidget );

    

	widgetContraint.constraint.top.type = CONSTRAINT_PREV_BOTTOM;
	widgetContraint.constraint.top.offset = 0;
	widgetContraint.constraint.left.type = CONSTRAINT_PREV_LEFT;
	widgetContraint.constraint.left.offset = -20;
	widgetContraint.constraint.right.type = WIDGET_SIZE_TO_FIT;

	result = ISHELL_CreateInstance(p->m_pIShell, AEECLSID_IMAGEWIDGET, (void**)&pIWidget );
	pImage = ISHELL_LoadImage(p->m_pIShell, "text.bmp"); 
	if (pImage) 
	{ 
		IWIDGET_SetImage(pIWidget, pImage);
		IIMAGE_Release(pImage);
	} 
	if ( result != SUCCESS ) goto error;
	result = ICONSTRAINTCONTAINER_Insert( pIConstraintContainer, pIWidget, WIDGET_ZNORMAL, &widgetContraint ); 
	RELEASEIF( pIWidget );

    

	widgetContraint.constraint.top.offset = 0;
	widgetContraint.constraint.top.type = CONSTRAINT_PREV_TOP;
	widgetContraint.constraint.left.type = CONSTRAINT_PREV_RIGHT;
	widgetContraint.constraint.left.offset = 0;
	widgetContraint.constraint.right.type = CONSTRAINT_PARENT_RIGHT;

	result = ISHELL_CreateInstance( p->m_pIShell, AEECLSID_TEXTWIDGET, (void**)&pIWidget );
	if ( result != SUCCESS ) goto error;
	IWIDGET_SetExtent( pIWidget, &size ); 
	IWIDGET_SetText( pIWidget, L"0.00", FALSE );
	result = ICONSTRAINTCONTAINER_Insert( pIConstraintContainer, pIWidget, WIDGET_ZNORMAL, &widgetContraint ); 
	IWIDGET_GetModel( pIWidget, AEEIID_TEXTMODEL, (IModel **)&pIText );
	RELEASEIF( pIWidget );

error:
	RELEASEIF( pIConstraintContainer );
	RELEASEIF( pIConstraintContainerWidget );
	RELEASEIF( pIWidget );
}

boolean  CCreateNewForm::handleEvent(CCreateNewForm *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:
				IWIDGET_MoveFocus( pIContainerWidget, (IWidget *)(wParam == AVK_UP ? WIDGET_FOCUS_FIRST : WIDGET_FOCUS_NEXT ));
				break;
			case AVK_SOFT1:
				po->prootForm->popForm(po->prootForm);
				break;
			case AVK_SOFT2:
				break;
		}
		RELEASEIF( pIContainerWidget );
	}
	return HANDLERDESC_Call( &po->handleNewMailForm, eCode, wParam, dwParam );
}

⌨️ 快捷键说明

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