Beruflich Dokumente
Kultur Dokumente
When considering forms, the important members of the DIALOG structure are:
* flags, which specifies the whole form style. The flag parameters are defin
ed in the eikon.hrh file.
* pages, which is a reference to an ARRAY of PAGE. Used only in multi-page f
orms (see Multi-page form). For single-page forms, this should not be specified.
* buttons, which specifies softkeys.
* form, which is a reference to the FORM structure described later. Used in
single-page forms. For multi-page forms, this should not be specified.
See document S60 3.1 Dialogs API Specification for more information on other DIA
LOG structure members.
STRUCT FORM
{
WORD flags = 0;
STRUCT items[];
}
The FORM structure member flags can be used to specify the style of the form. Th
e default setting is single-line display, and the predefined values are as follo
ws:
Flag Description
EEikFormUseDoubleSpacedFormat Double-line display.
EEikFormHideEmptyFields Makes empty data fields invisible.
EEikFormShowBitmaps Displays a bitmap on a label.
EEikFormEditModeOnly Displays the form in edit mode only.
EEikFormShowEmptyFields Displays single-line display (default).
Form fields are described with the structure DLG_LINE in the member items of the
FORM structure.
STRUCT DLG_LINE
{
WORD type;
LTEXT prompt;
WORD id = 0;
LONG itemflags = 0;
STRUCT control;
LTEXT trailer = "";
LTEXT bmpfile = "";
WORD bmpid = 0xffff;
WORD bmpmask;
LTEXT tooltip = "";
}
Multi-page form
Multi-page forms also use the DIALOG resource structure, but DIALOG structure me
mber pages are needed as a reference to an ARRAY of PAGE. The PAGE structure is
as follows:
STRUCT PAGE
{
WORD id = 0;
LTEXT text;
LTEXT bmpfile = "";
WORD bmpid = 0xffff;
WORD bmpmask;
LLINK lines = 0;
LLINK form = 0;
WORD flags = 0;
}
The following members are concerned with forms in the PAGE structure:
* id, which specifies the page ID of an application.
* text, which specifies the title string of tabs.
* form, which is a reference to the FORM structure.
The following resource defines a form for viewing and editing TMyStruct data in
a multi-page dialog. The DLG_LINE structures are identical to the single-page ex
ample (except that the first page is decorated with icons).
RESOURCE DIALOG r_my_multipage_dialog
{
flags = EEikDialogFlagNoBorder | EEikDialogFlagNoDrag |
EEikDialogFlagNoTitleBar | EEikDialogFlagFillAppClientRect |
EEikDialogFlagCbaButtons | EEikDialogFlagWait;
buttons = R_AVKON_SOFTKEYS_OPTIONS_BACK ;
pages = r_my_pages;
}
RESOURCE ARRAY r_my_pages
{
items =
{
PAGE { text = "text"; id = EMyAppPage1 ; form = r_my_form_1 ; },
PAGE { text = "number"; id = EMyAppPage2 ; form = r_my_form_2 ; },
PAGE { text = "misc"; id = EMyAppPage3 ; form = r_my_form_3 ; }
};
}
CleanupStack::PopAndDestroy( queryVal );
CleanupStack::PopAndDestroy( textArray );
CleanupStack::PopAndDestroy( array );
void CMyForm::LoadFormDataL()
{
CEikEdwin* textEd =
(CEikEdwin*)Control( EMyAppControlIdTextEd );
textEd->SetTextL( &iData.iText );
CEikGlobalTextEditor* globalTextEd =
(CEikGlobalTextEditor*)Control( EMyAppControlIdGlobalTextEd );
globalTextEd->SetTextL( &iData.iGlobalText );
CEikRichTextEditor* richTextEd =
(CEikRichTextEditor*)Control( EMyAppControlIdRichTextEd );
richTextEd->SetTextL( &iData.iRichText );
CEikNumberEditor* numberEd =
(CEikNumberEditor*)Control( EMyAppControlIdNumberEd );
numberEd->SetNumber( iData.iNumber );
CAknIntegerEdwin* integerEd =
(CAknIntegerEdwin*)Control( EMyAppControlIdIntegerEd );
integerEd->SetValueL( iData.iInteger );
CEikFloatingPointEditor* floatEd =
(CEikFloatingPointEditor*)Control( EMyAppControlIdFloatEd );
floatEd->SetValueL( &iData.iFloat );
CEikFixedPointEditor* fixEd =
(CEikFixedPointEditor*)Control( EMyAppControlIdFixEd );
fixEd->SetValueL( &iData.iFix );
CEikDateEditor* dateEd =
(CEikDateEditor*)Control( EMyAppControlIdDateEd );
dateEd->SetDate( iData.iDate );
CEikTimeEditor* timeEd =
(CEikTimeEditor*)Control( EMyAppControlIdTimeEd );
timeEd->SetTime( iData.iTime );
CEikDurationEditor* durationEd =
(CEikDurationEditor*)Control( EMyAppControlIdDurationEd );
durationEd->SetDuration( iData.iDuration );
CAknNumericSecretEditor* numPwdEd =
(CAknNumericSecretEditor*)Control( EMyAppControlIdNumPwdEd );
numPwdEd->SetText( iData.iNumPwd );
CEikSecretEditor* alphaPwdEd =
(CEikSecretEditor*)Control( EMyAppControlIdAlphaPwdEd );
alphaPwdEd->SetText( iData.iAlphaPwd );
CAknIpFieldEditor* ipAddrEd =
(CAknIpFieldEditor*)Control( EMyAppControlIdIpAddrEd );
ipAddrEd->SetAddress( iData.iIpAddr );
iData.iPopupVal->SetCurrentValueIndex( 0 );
CAknPopupField* popupField =
(CAknPopupField*)Control( EMyAppControlIdPopupField );
popupField->SetQueryValueL( iData.iPopupVal );
CAknPopupFieldText* popupFieldText =
(CAknPopupFieldText*)Control( EMyAppControlIdPopupFieldText );
popupFieldText->SetCurrentValueIndex( iData.iPopupTextIndex );
CAknSlider* slider =
(CAknSlider*)Control( EMyAppControlIdSlider );
slider->SetValueL( iData.iSliderVal );
}
Forms can validate the entered data. SaveFormDataL() should return EFalse if val
idation failed, this indicates that the data has not been saved. In this case, t
he form remains in edit state.
Reverting changes
DoNotSaveFormDataL() is called if the user responds No in QuerySaveChangesL(). T
he form should restore the original data.
void CMyForm::DoNotSaveFormDataL()
{
LoadFormDataL();
}
The same effect can achieved by passing the ID of a MENU_BAR resource to CAknFor
m::ConstructL(). Menu items from R_MY_MENUBAR will be appended to R_AVKON_FORM_M
ENUPANE:
RESOURCE MENU_BAR r_my_menubar
{
titles=
{
MENU_TITLE { menu_pane = r_my_extra_menu; txt=""; }
};
}
Processing commands
ProcessCommandL() can be overridden to handle custom commands. Built-in form com
mands are handled by CAknForm.
void CMyForm::ProcessCommandL( TInt aCommandId )
{
// Form default commands.
CAknForm::ProcessCommandL( aCommandId );
// Custom commands.
switch ( aCommandId )
{
case EMyCommand:
User::InfoPrint( _L("my command") );
break;
default:
break;
}
}
Managing fields
In edit mode, fields can be added or deleted dynamically. CAknForm::AddItemL() a
nd CAknForm::DeleteCurrentItemL() provide default implementation for handling th
e commands EAknFormCmdAdd and EAknFormCmdDelete, respectively.
The following sample adds an editor control.
void CMyForm::AddItemL()
{
_LIT( caption, "Added text" );
TInt pageId = ActivePageId();
TInt id = iAddedItemId++; // All controls must have unique id.
TInt type = EEikCtEdwin;
TAny* unused=0;
CEikEdwin* edwin = (CEikEdwin*)CreateLineByTypeL
( caption, pageId, id, type, unused );
edwin->ConstructL
( EEikEdwinNoHorizScrolling | EEikEdwinResizable, 10, 100, 1 );
Line( id )->ActivateL();
SetChangesPending( ETrue );
UpdatePageL( ETrue );
}
Note that all controls in the dialog must have a unique ID. The sample code uses
its iAddedItemId member to ensure that IDs are unique, but does not store the I
Ds of the dynamically created controls. Real-life implementations need the IDs t
o access field data later.
enum TMyControlIds
{
EMyAppControlIdTextEd = 100,
EMyAppControlIdGlobalTextEd,
EMyAppControlIdRichTextEd,
EMyAppControlIdNumberEd,
EMyAppControlIdIntegerEd,
EMyAppControlIdFloatEd,
EMyAppControlIdFixEd,
EMyAppControlIdDateEd,
EMyAppControlIdTimeEd,
EMyAppControlIdDurationEd,
EMyAppControlIdNumPwdEd,
EMyAppControlIdAlphaPwdEd,
EMyAppControlIdIpAddrEd,
EMyAppControlIdPopupField,
EMyAppControlIdPopupFieldText,
EMyAppControlIdSlider,
EMyAppControlIdFirstAdded // Dynamically added items
};
Error handling
Form API uses standard Symbian OS error reporting mechanism and standard error c
odes.
Memory overhead
Memory consumption of dialogs depends on the contained controls.
Limitations of the API
None.
Copyright © Nokia Corporation 2001-2008
Back to top