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

📄 aknexquerycontainer.cpp

📁 symbian中询问对话框生成的源代码 适合初学者使用。
💻 CPP
📖 第 1 页 / 共 5 页
字号:
    iDisplayDialog = EFalse;
    }


// ----------------------------------------------------------------------------
// CAknExQueryContainer::OfferKeyEventL()
// Handles the key events.
// ----------------------------------------------------------------------------
//
TKeyResponse CAknExQueryContainer::OfferKeyEventL(
    const TKeyEvent& aKeyEvent,
    TEventCode aType )
    {
    if ( aType != EEventKey )
        {
        return EKeyWasNotConsumed;
        }
    switch ( aKeyEvent.iCode )
        {
        case EKeySpace:
            if ( iDisplayDialog )
                {
                return EKeyWasNotConsumed;
                }
            iView->DisplayNextOutlineL();
            DrawNow();
            break;
        default:
            if ( !iDisplayDialog && iListBox )
                {
                return iListBox->OfferKeyEventL( aKeyEvent, aType );
                }
            else
                {
                return EKeyWasNotConsumed;
                }
        }
    return EKeyWasConsumed;
    }

// ----------------------------------------------------------------------------
// CAknExQueryContainer::SizeChanged()
// Called by framework when the view size is changed
// ----------------------------------------------------------------------------
//
void CAknExQueryContainer::SizeChanged()
    {
    if ( iLabel )
        {
        iLabel->SetExtent( AKNEXQUERY_LABEL_ORIGIN, Size() );
        iLabel->SetAlignment( EHCenterVCenter );
        }
    }

// ----------------------------------------------------------------------------
// CAknExQueryContainer::CountComponentControls() const
//  Returns number of component.
// ----------------------------------------------------------------------------
//
TInt CAknExQueryContainer::CountComponentControls() const
    {
    TInt count( KAknExQueryCountComponentControls );
    if ( iLabelResultMessage )
        {
        count++;
        }
    if ( iListBox )
        {
        count++;
        }
    return count;
    }

// ----------------------------------------------------------------------------
// CAknExQueryContainer::ComponentControl( TInt aIndex ) const
// Returns pointer to particular component.
// ----------------------------------------------------------------------------
//
CCoeControl* CAknExQueryContainer::ComponentControl( TInt aIndex ) const
    {
    switch ( aIndex )
        {
        case EAknExQueryComponentLabel:
            return iLabel;
        case EAknExQueryComponentLabel2:
            if ( iLabelResultMessage )
                {
                return iLabelResultMessage;
                }
            else
                {
                return iListBox;
                }
        case EAknExQueryComponentListBox:
            return iListBox;
        default:
            return NULL;
        }
    }

// ----------------------------------------------------------------------------
// CAknExQueryContainer::Draw( const TRect& aRect ) const
//
// ----------------------------------------------------------------------------
//
void CAknExQueryContainer::Draw( const TRect& aRect ) const
    {
    CWindowGc& gc = SystemGc();
    gc.SetPenStyle( CGraphicsContext::ENullPen );
    gc.SetBrushColor( KAknExQueryGray );
    gc.SetBrushStyle( CGraphicsContext::ESolidBrush );
    gc.DrawRect( aRect );
    }


// ----------------------------------------------------------------------------
// CAknExQueryContainer::ShowMultiLineNumberAndNumberLayoutL
// Display of MultiLineNumber Query
// ----------------------------------------------------------------------------
//
void CAknExQueryContainer::ShowMultiLineNumberAndNumberLayoutL()
    {
    iDisplayDialog = ETrue;
    SetTextToLabelL( R_AKNEXQUERY_OPERATE_MESSAGE );

    TInt topData( 0 );
    TInt bottomData( 0 );

    CAknMultiLineDataQueryDialog* dlg =
        CAknMultiLineDataQueryDialog::NewL( topData, bottomData );

    dlg->ExecuteLD( R_AKNEXQUERY_MULTI_LINE_NUMBER_AND_NUMBER_LAYOUT );

    iDisplayDialog = EFalse;
    }


// ----------------------------------------------------------------------------
// CAknExQueryContainer::DoRunDlgL
// Call CAknQueryDialog::RunDlgLD.
// ----------------------------------------------------------------------------
void CAknExQueryContainer::DoRunDlgL( TInt aResouceId )
    {
    CAknQueryDialog* dlg = CAknQueryDialog::NewL(
        CAknQueryDialog::ENoTone );
    dlg->ExecuteLD( aResouceId );
    }


// ----------------------------------------------------------------------------
// CAknExQueryContainer::ShowMultiLineTextAndTextLayoutL()
// Display of MultiLineText Query.
// ----------------------------------------------------------------------------
//
void CAknExQueryContainer::ShowMultiLineTextAndTextLayoutL(
    const TInt  aResouceId,
    const TInt  aTopResourceId,
    const TInt  aBottomResourceId,
    const TBool aSetPromptFlag,
    const TInt  aLengthOfFirstEditor,
    const TInt  aLengthOfSecondEditor )
    {
    iDisplayDialog = ETrue;
    SetTextToLabelL( R_AKNEXQUERY_OPERATE_MESSAGE );

    TBuf<KAknExQueryTextBufLength> topData;
    TBuf<KAknExQueryTextBufLength> bottomData;

    if ( aResouceId == R_AKNEXQUERY_MULTI_LINE_DATA_AND_DATA_LAYOUT )
        {
        if ( aTopResourceId != KAknExQueryInitialId )
            {
            iCoeEnv->ReadResource( topData, aTopResourceId );
            }
        if ( aBottomResourceId != KAknExQueryInitialId )
            {
            iCoeEnv->ReadResource( bottomData, aBottomResourceId );
            }
        }

    CAknMultiLineDataQueryDialog* dlg =
            CAknMultiLineDataQueryDialog::NewL( topData, bottomData );

    if ( aSetPromptFlag )
        {
        dlg->SetPromptL( topData, bottomData );
        }

    if ( aLengthOfFirstEditor || aLengthOfSecondEditor )
        {
        dlg->PrepareLC( aResouceId );

        if ( aLengthOfFirstEditor )
            {
            dlg->SetMaxLengthOfFirstEditor( aLengthOfFirstEditor );
            }
        if ( aLengthOfSecondEditor )
            {
            dlg->SetMaxLengthOfSecondEditor( aLengthOfSecondEditor );
            }

        dlg->RunLD();
        }
    else
        {
        dlg->ExecuteLD( aResouceId );
        }

    iDisplayDialog = EFalse;
    }


// ----------------------------------------------------------------------------
// CAknExQueryContainer::ShowMultiLineTextAndNumberLayoutL()
// Display of MultiLine Text with number Query
// ----------------------------------------------------------------------------
void CAknExQueryContainer::ShowMultiLineTextAndNumberLayoutL(
    const TInt aResourceId )
    {
    iDisplayDialog = ETrue;
    SetTextToLabelL( R_AKNEXQUERY_OPERATE_MESSAGE );

    TBuf<KAknExQueryTextBufLength> topData;
    TInt bottomData( 0 );

    CAknMultiLineDataQueryDialog* dlg =
        CAknMultiLineDataQueryDialog::NewL( topData, bottomData );

    dlg->ExecuteLD( aResourceId );

    iDisplayDialog = EFalse;
    }

// ----------------------------------------------------------------------------
// CAknExQueryContainer::ShowMultiLineTextAndLDurationLayoutL()
// Display of MultiLine Text with Duration Query
// ----------------------------------------------------------------------------
void CAknExQueryContainer::ShowMultiLineTextAndLDurationLayoutL(
    const TInt aResourceId )
    {
    iDisplayDialog = ETrue;
    SetTextToLabelL( R_AKNEXQUERY_OPERATE_MESSAGE );

    TBuf<KAknExQueryTextBufLength> topData;
    TTimeIntervalSeconds bottomData( 0 );

    CAknMultiLineDataQueryDialog* dlg =
        CAknMultiLineDataQueryDialog::NewL( topData, bottomData );
    dlg->ExecuteLD( aResourceId );

    iDisplayDialog = EFalse;
    }

// ----------------------------------------------------------------------------
// CAknExQueryContainer::ShowMultiLineTimeAndDurationLayoutL
// Display of MultiLine Time with Duration Query
// ----------------------------------------------------------------------------
void CAknExQueryContainer::ShowMultiLineTimeAndDurationLayoutL(
     const TInt aResourceId,
    const TInt aTopResourceId)
    {
    iDisplayDialog = ETrue;
    SetTextToLabelL( R_AKNEXQUERY_OPERATE_MESSAGE );

    TBuf<KAknExQueryTextBufLength> bufferRes;

    iCoeEnv -> ReadResource(bufferRes, aTopResourceId);

    TTime topDateTime;
    topDateTime.Set(bufferRes);
	topDateTime.HomeTime();

    TTimeIntervalSeconds bottomDuration = 300;	// set timer field to 5 minutes

    CAknMultiLineDataQueryDialog* dlg =
        CAknMultiLineDataQueryDialog::NewL( topDateTime, bottomDuration );

    dlg->ExecuteLD( aResourceId );

    iDisplayDialog = EFalse;
    }


// ----------------------------------------------------------------------------
// CAknExQueryContainer::DoSetItemTextArrayL()
// Set item dynamically
// ----------------------------------------------------------------------------
void CAknExQueryContainer::DoSetItemTextArrayL()
    {
    iDisplayDialog = ETrue;
    SetTextToLabelL( R_AKNEXQUERY_OPERATE_MESSAGE );

    CDesCArrayFlat* items =
        new ( ELeave ) CDesCArrayFlat( KAknExQueryArrayFlatResourceId );
    CleanupStack::PushL( items );


    CDesCArray *array = NULL;
    array = iCoeEnv->ReadDesCArrayResourceL( R_AKNEXQUERY_SUB_POPUP_DATA );
    CleanupStack::PushL( array );

    for ( TInt i( 0 ) ; i < 5 ; i += 1 )
        {
        items->AppendL( ( *array )[i] );
        }

    TInt index( 0 );
    CAknListQueryDialog* dlg = new ( ELeave ) CAknListQueryDialog( &index );
    dlg->PrepareLC( R_AKNEXQUERY_LIST_QUERY );
    dlg->SetItemTextArray( items );

    dlg->SetOwnershipType( ELbmDoesNotOwnItemArray );
    dlg->RunLD();
    CleanupStack::PopAndDestroy(); // items with array
    CleanupStack::PopAndDestroy(); // items with array
    iDisplayDialog = EFalse;
    }


// ----------------------------------------------------------------------------
// CAknExQueryContainer::ShowMultiLineTimeAndTimeLayoutL()
// Display of MultiLine Time with Time Query
// ----------------------------------------------------------------------------
void CAknExQueryContainer::ShowMultiLineTimeAndTimeLayoutL(
        const TInt aResourceId,
        const TInt aTopResourceId,
        const TInt aBottomResourceId )
    {
    iDisplayDialog = ETrue;
    SetTextToLabelL( R_AKNEXQUERY_OPERATE_MESSAGE );

    TBuf<KAknExQueryTextBufLength> topData;
    TBuf<KAknExQueryTextBufLength> bottomData;
    TTime topTime;
    TTime bottomTime;
    iCoeEnv->ReadResource( topData, aTopResourceId );
    topTime.Set( topData );
    iCoeEnv->ReadResource( bottomData, aBottomResourceId );
    bottomTime.Set( bottomData );

    CAknMultiLineDataQueryDialog* dlg =
        CAknMultiLineDataQueryDialog::NewL( topTime, bottomTime );
    dlg->ExecuteLD( aResourceId );

    iDisplayDialog = EFalse;
    }

// ----------------------------------------------------------------------------
// CAknExQueryContainer::ShowMultiLineTextAndTimeLayoutL()
// Display of MultiLine Text with Time Query
// ----------------------------------------------------------------------------
void CAknExQueryContainer::ShowMultiLineTextAndTimeLayoutL(
    const TInt aResourceId,
    const TInt aBottomResourceId )
    {
    iDisplayDialog = ETrue;
    SetTextToLabelL( R_AKNEXQUERY_OPERATE_MESSAGE );

    TBuf<KAknExQueryCodeBufLength> topData;
    TBuf<KAknExQueryTextBufLength> bottomData;
    TTime bottomDate;
    iCoeEnv->ReadResource( bottomData, aBottomResourceId );
    bottomDate.Set( bottomData );


    CAknMultiLineDataQueryDialog* dlg =
        CAknMultiLineDataQueryDialog::NewL( topData, bottomDate );
    dlg->ExecuteLD( aResourceId );

    iDisplayDialog = EFalse;
    }

// ----------------------------------------------------------------------------
// CAknExQueryContainer::ShowGlobalMessageQueryL()
// Show Global Message Query
// ----------------------------------------------------------------------------
//

⌨️ 快捷键说明

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