📄 aknexquerycontainer.cpp
字号:
/* Copyright (c) 2004, Nokia. All rights reserved */
// INCLUDE FILES
#include <eikenv.h>
#include <eiklabel.h> // For label control
#include <eikclb.h> // For listbox
#include <eiktxlbm.h> // For listbox model
#include <eikclbd.h> // For listbox data
#include <aknlists.h> // For list pane
#include <aknpopup.h>
#include <aknpopupheadingpane.h>
#include <akniconarray.h>
#include <AknMessageQueryDialog.h> // for global message query
#include <aknglobalconfirmationquery.h> // for global message query
#include <StringLoader.h>
#include <avkon.hrh>
#include <avkon.rsg>
#include <AVKON.mbg>
#include <AKNEXQUERY.mbg>
#include <AknListQueryDialog.h>
#include <AknExQuery.rsg>
#include "AknExQuery.hrh"
#include "AknExQueryView.h"
#include "AknExQueryContainer.h"
#include "AknExQueryEditorListEventHandler.h"
#include "AknExQueryRollerListEventHandler.h"
#include "AknExQueryTextAndTextListEventHandler.h"
#include "AknExQueryTextAndTimeListEventHandler.h"
#include "AknExQueryTimeAndTimeListEventHandler.h"
#include "AknExQueryTextAndNumberListEventHandler.h"
#include "AknExQueryTextAndDurationListEventHandler.h"
#include "AknExQueryTimeAndDurationListEventHandler.h"
#include "AknExQueryKeyListEventHandler.h"
#include "AknExQueryIconListEventHandler.h"
// ================= MEMBER FUNCTIONS =========================================
// ----------------------------------------------------------------------------
// CAknExQueryContainer::CAknExQueryContainer()
// Overload constructor.
//-----------------------------------------------------------------------------
//
CAknExQueryContainer::CAknExQueryContainer( CAknExQueryView* aView )
: iView( aView )
{
}
// ----------------------------------------------------------------------------
// CAknExQueryContainer::ConstructL()
// two phased constructor
//-----------------------------------------------------------------------------
//
void CAknExQueryContainer::ConstructL( const TRect& aRect )
{
// Creates window.
CreateWindowL();
// Creates label object.
if ( !iLabel )
{
iLabel = new ( ELeave ) CEikLabel;
iLabel->SetContainerWindowL( *this );
if (AknLayoutUtils::Variant() == EApacVariant)
{
iLabel->SetFont( ApacPlain16() );
}
else
{
iLabel->SetFont( LatinBold19() );
}
SetTextToLabelL( R_AKNEXQUERY_TITLE_MESSAGE );
}
SetRect( aRect ); // Sets rectangle of frame.
ActivateL(); // Activates the window. ( Ready to draw )
}
// ----------------------------------------------------------------------------
// CAknExQueryContainer::~CAknExQueryContainer()
// Destructor.
// ----------------------------------------------------------------------------
//
CAknExQueryContainer::~CAknExQueryContainer()
{
delete iLabel;
delete iLabelResultMessage;
delete iListBox;
delete iHandler;
delete iGlobalListQuery;
delete iGlobalListObserver;
delete iGlobalMsgQuery;
}
// ----------------------------------------------------------------------------
// CAknExQueryContainer::ShowConfirmationQueryL()
// Display of Confirmation Query.
// ----------------------------------------------------------------------------
//
void CAknExQueryContainer::ShowConfirmationQueryL(
const TInt aResourceId,
const TInt aTextResourceId,
const TBool aPromptFlag,
const TBool aToneFlag,
const TBool aHeaderTextAndImageFlag,
const CAknQueryDialog::TTone aTone
)
{
iDisplayDialog = ETrue;
SetTextToLabelL( R_AKNEXQUERY_OPERATE_MESSAGE );
CAknQueryDialog* dlg;
if ( aHeaderTextAndImageFlag )
{
dlg = CAknQueryDialog::NewL( aTone );
dlg->PrepareLC( aResourceId );
TBuf<KAknExQueryTextBufLength> prompt;
iCoeEnv->ReadResource( prompt, R_AKNEXQUERY_NUMQUERY_WITHHEAD_HEAD );
dlg->QueryHeading()->SetTextL( prompt );
SetIconL( dlg, EMbmAknexqueryAnchor_id, EMbmAknexqueryAnchor_id_mask );
dlg->RunLD();
}
else
{
if ( !aTextResourceId )
{
dlg = CAknQueryDialog::NewL( aTone );
}
else
{
TBuf<KAknExQueryTextBufLength> prompt;
iCoeEnv->ReadResource( prompt, aTextResourceId );
if ( aPromptFlag )
{
dlg = CAknQueryDialog::NewL( aTone );
CleanupStack::PushL( dlg );
dlg->SetPromptL( prompt );
CleanupStack::Pop();
}
else if ( aToneFlag )
{
dlg = new ( ELeave ) CAknQueryDialog( prompt, aTone );
}
else
{
dlg = new ( ELeave ) CAknQueryDialog( prompt );
}
}
ShowResultMessageL( dlg->ExecuteLD( aResourceId ) );
}
iDisplayDialog = EFalse;
}
// ----------------------------------------------------------------------------
// CAknExQueryContainer::ShowResultMessageL()
// Display return value of dialog.
// ----------------------------------------------------------------------------
//
void CAknExQueryContainer::ShowResultMessageL( TBool aResult )
{
TInt res( R_AKNEXQUERY_NO_OR_CANCEL_MESSAGE );
if ( aResult )
{
res = R_AKNEXQUERY_YES_OR_OK_MESSAGE;
}
TBuf<KAknExQueryTextBufLength> messageConfirmationQuery;
iCoeEnv->ReadResource( messageConfirmationQuery, res );
ShowMessageL( messageConfirmationQuery );
}
// ----------------------------------------------------------------------------
// CAknExQueryContainer::ShowDataQueryL()
// Display of Data Query.
// ----------------------------------------------------------------------------
//
void CAknExQueryContainer::ShowDataQueryL(
const TInt aQueryResourceId,
const TInt aTextResourceId,
const TInt aPromptResoureId,
const TInt aMaxLength,
const TBool aDisplayFlag )
{
iDisplayDialog = ETrue;
SetTextToLabelL( R_AKNEXQUERY_OPERATE_MESSAGE );
TBuf<KAknExQueryTextBufLength> textData;
if ( aTextResourceId )
{
iCoeEnv->ReadResource( textData, aTextResourceId );
}
CAknTextQueryDialog* dlg;
if ( !aPromptResoureId )
{
dlg = new ( ELeave )CAknTextQueryDialog(
textData, CAknQueryDialog::ENoTone );
}
else
{
TBuf<KAknExQueryTextBufLength> prompt;
iCoeEnv->ReadResource( prompt, aTextResourceId );
dlg = CAknTextQueryDialog::NewL(
textData, CAknQueryDialog::ENoTone );
CleanupStack::PushL( dlg );
dlg->SetPromptL( prompt );
CleanupStack::Pop(); // dlg
}
if ( aMaxLength )
{
dlg->SetMaxLength( aMaxLength );
}
TBool answer( dlg->ExecuteLD( aQueryResourceId ) );
if ( aDisplayFlag && answer )
{
iLabelResultMessage->SetTextL( textData );
}
iDisplayDialog = EFalse;
DrawNow();
}
// ----------------------------------------------------------------------------
// CAknExQueryContainer::ShowTimeQueryL()
// Display of Time Query.
// ----------------------------------------------------------------------------
//
void CAknExQueryContainer::ShowTimeQueryL(
TInt aResourceQueryId,
TInt aResourceValueId,
TInt aResourcePromptId )
{
iDisplayDialog = ETrue;
SetTextToLabelL( R_AKNEXQUERY_OPERATE_MESSAGE );
TBuf<KAknExQueryTextBufLength> textData;
TTime value;
iCoeEnv->ReadResource( textData, aResourceValueId );
value.Set( textData );
CAknTimeQueryDialog* dlg;
if ( !aResourcePromptId )
{
dlg = CAknTimeQueryDialog::NewL( value, CAknQueryDialog::ENoTone );
}
else
{
TBuf<KAknExQueryTextBufLength> prompt;
iCoeEnv->ReadResource( prompt, aResourceValueId );
dlg = CAknTimeQueryDialog::NewL( value, CAknQueryDialog::ENoTone );
CleanupStack::PushL( dlg );
dlg->SetPromptL( prompt );
CleanupStack::Pop(); //dlg
}
dlg->ExecuteLD( aResourceQueryId );
iDisplayDialog = EFalse;
}
// ----------------------------------------------------------------------------
// CAknExQueryContainer::ShowDurationLayoutL()
// Display of Duration Query.
// ----------------------------------------------------------------------------
//
void CAknExQueryContainer::ShowDurationLayoutL()
{
iDisplayDialog = ETrue;
SetTextToLabelL( R_AKNEXQUERY_OPERATE_MESSAGE );
TTimeIntervalSeconds duration;
CAknDurationQueryDialog* dlg = CAknDurationQueryDialog::NewL(
duration, CAknQueryDialog::ENoTone );
dlg->ExecuteLD( R_AKNEXQUERY_DURATION_LAYOUT );
iDisplayDialog = EFalse;
}
// ----------------------------------------------------------------------------
// CAknExQueryContainer::ShowNumberLayoutL()
// Display of Number Query.
// ----------------------------------------------------------------------------
//
void CAknExQueryContainer::ShowNumberLayoutL(
const TInt aResourceId,
const TInt /* aTextResourceId */,
const TInt aQueryValue,
TInt aMinimumValue,
TInt aMaximumValue )
{
iDisplayDialog = ETrue;
SetTextToLabelL( R_AKNEXQUERY_OPERATE_MESSAGE );
TInt number( aQueryValue );
CAknNumberQueryDialog* dlg;
if ( aMinimumValue || aMaximumValue )
{
dlg = new ( ELeave ) CAknNumberQueryDialog ( number );
dlg->PrepareLC( aResourceId );
dlg->SetEmergencyCallSupport( EFalse );
dlg->SetMinimumAndMaximum( aMinimumValue, aMaximumValue );
dlg->RunLD();
}
else
{
dlg = CAknNumberQueryDialog::NewL(
number, CAknQueryDialog::ENoTone );
dlg->ExecuteLD( aResourceId );
}
iDisplayDialog = EFalse;
}
// ----------------------------------------------------------------------------
// CAknExQueryContainer::ShowPopupSubMenuLayoutL()
// Display sub popmenu
// ----------------------------------------------------------------------------
//
void CAknExQueryContainer::ShowPopupSubMenuLayoutL( TBool aTitle )
{
iDisplayDialog = ETrue;
SetTextToLabelL( R_AKNEXQUERY_OPERATE_MESSAGE );
CEikTextListBox* listPane = new ( ELeave ) CAknSinglePopupMenuStyleListBox;
CleanupStack::PushL( listPane );
CAknPopupList* popupList = CAknPopupList::NewL(
listPane,
R_AVKON_SOFTKEYS_SELECT_CANCEL,
AknPopupLayouts::EMenuWindow );
CleanupStack::PushL( popupList );
listPane->ConstructL( popupList, CEikListBox::ELeftDownInViewRect );
listPane->CreateScrollBarFrameL( ETrue );
listPane->ScrollBarFrame()->SetScrollBarVisibilityL(
CEikScrollBarFrame::EOff, CEikScrollBarFrame::EAuto );
listPane->SetSize( AKNEXQUERY_POPUP_MENU_SIZE );
if ( aTitle )
{
TBuf<KAknExQueryTextBufLength> titleData;
iCoeEnv->ReadResource( titleData, R_AKNEXQUERY_SUB_POPUP_TITLE );
popupList->SetTitleL( titleData );
}
CEikImage* image = new ( ELeave ) CEikImage();
CleanupStack::PushL( image );
CFbsBitmap* bitmap = iEikonEnv->CreateBitmapL(
KAknExQueryMbmFilePath, EMbmAknexqueryAnchor_id );
CleanupStack::PushL( bitmap );
CFbsBitmap* mask = iEikonEnv->CreateBitmapL(
KAknExQueryMbmFilePath, EMbmAknexqueryAnchor_id_mask );
CleanupStack::PushL( mask );
image->SetBitmap( bitmap );
image->SetMask( mask );
popupList->Heading()->SetHeaderImageL( image );
CleanupStack::Pop( 2 ); // mask and bitmap
CleanupStack::PopAndDestroy(); // image...mask and bitmap are also deleted
// when image is deleted.
CDesCArray* array = NULL;
array = iCoeEnv->ReadDesCArrayResourceL( R_AKNEXQUERY_SUB_POPUP_DATA );
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -