|
Nokia N97 SDK Example Applications Guide |
1. About this Example
2. User Interface
3. Design and implementation
A query dialog is only displayed within an application, while a global list query is displayed on top even when another application moves to the foreground.
The query example application demonstrates the following functions:
Query dialog:
Global list query:
The following are examples of how queries are used:
When the dialog closes, press the right soft key (Next) to open the next dialog in the example application. To close this dialog, press the Ok or Cancel key. When the user presses the Ok key, user input data is displayed.
When the dialog closes, press the right soft key (Next) to open the next dialog. To close this dialog, press the Ok or Cancel key. When the user presses the Ok key, user input data is displayed.
This dialog shows Time and Duration input.
To open the next dialog, press the right soft key (Next). This dialog demonstrates another type of list item selection. To close this dialog, press the Ok or Cancel key.
Yes/No selection dialog
RESOURCE DIALOG r_aknexquery_confirmation_query
{
flags = EGeneralQueryFlags;
buttons = R_AVKON_SOFTKEYS_YES_NO;
items =
{
DLG_LINE
{
type = EAknCtQuery;
id = EGeneralQuery;
control = AVKON_CONFIRMATION_QUERY
{
layout = EConfirmationQueryLayout;
label = STRING_r_aknexquery_con_label_text;
bmpfile = AKNEXQUERY_BMPFILE_NAME;
bmpid = AKNEXQUERY_BITMAP_MASK_FLAG;
};
}
};
}
Single data input
RESOURCE DIALOG r_aknexquery_data_query
{
flags = EGeneralQueryFlags;
buttons = R_AVKON_SOFTKEYS_OK_CANCEL;
items =
{
DLG_LINE
{
type = EAknCtQuery;
id = EGeneralQuery;
control = AVKON_DATA_QUERY
{
layout = EDataLayout;
label = STRING_r_aknexquery_data_label_text;
control = EDWIN
{
flags = EEikEdwinNoHorizScrolling | EEikEdwinResizable;
width = AKNTAQUERY_EDWIN_WIDTH;
maxlength = AKNTAQUERY_EDWIN_MAXLENGTH;
// added to limit expanding in forms.
// If you want full screen use 6 here
max_view_height_in_lines = AKNEXQUERY_EDWIN_LINES;
// if you have the line above, you must have this.
// It's calculable from LAF
base_line_delta = 21;
};
};
}
};
}
Multiple data input
RESOURCE DIALOG r_aknexquery_multi_line_date_and_duration_layout
{
flags = EGeneralQueryFlags;
buttons = R_AVKON_SOFTKEYS_OK_CANCEL;
items =
{
DLG_LINE
{
type = EAknCtMultilineQuery;
id = EMultilineFirstLine;
control = AVKON_DATA_QUERY
{
layout = EMultiDataFirstEdwin;
label = STRING_r_aknexquery_date_label_text;
control = DATE_EDITOR
{
minDate = DATE
{
year = AKNEXQUERY_DATE_EDITOR_MIN_DATE;
};
maxDate = DATE
{
year = AKNEXQUERY_DATE_EDITOR_MAX_DATE;
};
flags = AKNEXQUERY_DATE_EDITOR_FLAGS;
};
};
},
DLG_LINE
{
type = EAknCtMultilineQuery;
id = EMultilineSecondLine;
control = AVKON_DATA_QUERY
{
layout = EMultiDataSecondEdwin;
label = STRING_r_aknexquery_dura_label_text;
control = DURATION_EDITOR
{
minDuration = DURATION
{
};
maxDuration = DURATION
{
seconds = AKNEXQUERY_DURATION_EDITOR_MAX_SECOND;
};
flags = AKNEXQUERY_DURATION_EDITOR_FLAGS;
};
};
}
};
}
For the multiple line query, it is necessary to define two DLG_LINE structures. The first line for the multiple line query is identified by EMultilineFirstLine in "id". The second line is identified by EMultilineSecondLine in "id".
Select list item dialog
RESOURCE DIALOG r_aknexquery_list_single_pane
{
flags = EGeneralQueryFlags;
buttons = R_AVKON_SOFTKEYS_OK_CANCEL;
items =
{
DLG_LINE
{
type = EAknCtListQueryControl;
id = EListQueryControl;
control = AVKON_LIST_QUERY_CONTROL
{
listtype = EAknCtSinglePopupMenuListBox;
listbox = LISTBOX
{
flags = EAknListBoxMenuList;
height = AKNEXQUERY_LISTBOX_HEIGHT;
width = AKNEXQUERY_LISTBOX_WIDTH;
array_id = r_aknexquery_list_single_pane_item;
};
heading = STRING_r_aknexquery_list_title;
};
}
};
}
Global list query
RESOURCE ARRAY r_aknexquery_sub_popup_data
{
items =
{
LBUF
{
txt = STRING_r_aknexquery_sub_popup_data1;
},
LBUF
{
txt = STRING_r_aknexquery_sub_popup_data2;
},
LBUF
{
txt = STRING_r_aknexquery_sub_popup_data3;
},
LBUF
{
txt = STRING_r_aknexquery_sub_popup_data4;
},
LBUF
{
txt = STRING_r_aknexquery_sub_popup_data5;
}
};
}
When the user responds to this dialog, the query dialog sets the value of the soft key event of OK or Cancel (or Yes or No) into the reference that is passed at the construction phase. Then the query dialog closes itself and deletes the query dialog object by itself. The program returns to the application from the dialog after the dialog is deleted. In this example application, input text data is shown in the application view.
TBuf<KAknExQueryTextBufLength> textData; CAknTextQueryDialog* dlg; dlg = new ( ELeave )CAknTextQueryDialog( textData, CAknQueryDialog::ENoTone ); TBool answer( dlg->ExecuteLD( aQueryResourceId ) ); if ( aDisplayFlag && answer ) { iLabelResultMessage->SetTextL( textData ); }
The following sequence diagram shows the life of a query dialog from the time it is instantiated until it is deleted.
At first, the active object (CAknExQueryGlobalListObserver class) is instantiated, (see (a)), then CAknExQueryGlobalListObserver::Start() is called. Next, the global list query (CAknGlobalListQuery class) is instantiated, (see (c)), then the iStatus variable of the active object is set into CAknGlobalListQuery::ShowListQueryL() as a parameter and then this function is called. Now the global list query is shown. When the user selects a list item and presses the OK or Cancel soft key, a soft key event occurs and the global list query is closed and the CAknExQueryGlobalListObserver::RunL() function is called by the active object framework. Then an index number (-1 is set when Cancel is selected) of the list that is selected in the global list query is set to iStatus of the active object by the notify framework.
iDisplayDialog = ETrue; SetTextToLabelL( R_AKNEXQUERY_OPERATE_MESSAGE ); CDesCArray* textArray = iCoeEnv->ReadDesCArrayResourceL(R_AKNEXQUERY_SUB_POPUP_DATA); CleanupStack::PushL(textArray); iGlobalListObserver = CAknTaQueryGlobalListObserver::NewL( this ); // (a) iGlobalListObserver->Start(); // <-- (b) iGlobalListQuery = CAknGlobalListQuery::NewL(); // <-- (c) iGlobalListObserver->SetSelectItemFlag(); iGlobalListQuery->ShowListQueryL(textArray, iGlobalListObserver->iStatus, 0); // (d) CleanupStack::PopAndDestroy(); // textArray iDisplayDialog = EFalse;
The following sequence diagram shows the life of the active object and global list query:
|
© Nokia 2009 |