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

📄 querylistdialog.cpp

📁 《基于Symbian OS的手机开发与应用实践》这本书的配套源码。
💻 CPP
字号:
/*
* ============================================================================
*  Name     : CQueryListDialog from SimpleDlgDialog.h
*  Part of  : QueryListDialog
*  Created  : 12.04.2005 by ToBeReplacedByAuthor
*  Implementation notes:
*     Initial content was generated by Series 60 Application Wizard.
*  Version  :
*  Copyright: ToBeReplacedByCopyright
* ============================================================================
*/

// INCLUDE FILES
#include    "QueryListDialog.h"

#include <eiklabel.h>  // for example label control
#include <avkon.hrh>
#include <aknappui.h>
#include <guictrls.rsg>
#include "guictrls.hrh"
#include <akntitle.h> // for title pane
#include <eikspane.h>
#include <aknlists.h> 
#include <AknQueryDialog.h> // for query control

// ================= MEMBER FUNCTIONS =======================


// Destructor
CQueryListDialog::~CQueryListDialog()
    {
    }

TInt CQueryListDialog::RunLD()
    {
    CQueryListDialog* dialog = new(ELeave) CQueryListDialog();
    CleanupStack::PushL(dialog);
    dialog->ConstructL(0);
    CleanupStack::Pop();
    return dialog->ExecuteLD(R_QUERYLIST_DIALOG);
    }
    
TBool CQueryListDialog::OkToExitL(TInt aButtonId)
    {
    if (aButtonId == EEikBidSelect|| aButtonId == EEikBidOk)
        {
        ShowQueryL();    
        return EFalse;
        }
    TBool ret = CAknDialog::OkToExitL(aButtonId);
    if (ret)
        {
        CEikStatusPane* sp = iEikonEnv->AppUiFactory()->StatusPane();
        CAknTitlePane* title = (CAknTitlePane*)sp->ControlL( TUid::Uid( EEikStatusPaneUidTitle ) );
        title->SetTextToDefaultL();
        }
    return ret;
    }

void CQueryListDialog::ShowQueryL()
    {
    CAknSingleStyleListBox*    listbox = static_cast<CAknSingleStyleListBox*> (Control(EDialogLine1));
    TInt index = listbox->CurrentItemIndex();
    switch (index)
        {
    case 0: // Confirmation Query
        {
        CAknQueryDialog* dlg = CAknQueryDialog::NewL();
        if(dlg->ExecuteLD(R_GUICTRLS_CONFIRMATION_QUERY))
            {
            iEikonEnv->InfoMsg(_L("Yes selected"));
            }
        else
            {
            iEikonEnv->InfoMsg(_L("Canceled"));
            }
        
        break;
        }
    case 1: // Data - Text
        {
        TBuf<20> buf;
        CAknTextQueryDialog* dlg =     CAknTextQueryDialog::NewL(buf);
        if (dlg->ExecuteLD(R_GUICTRLS_DATA_QUERY_TEXT))
            {
            // ok pressed
            }
        iEikonEnv->InfoMsg(buf);
        break;
        }
    case 2: //Data - Number
        {
        TInt value(0);
        CAknNumberQueryDialog* dlg = CAknNumberQueryDialog::NewL(value);
        if (dlg->ExecuteLD(R_GUICTRLS_DATA_QUERY_NUMBER))
            {
            // ok pressed
            }
        break;
        }
    case 3: // Data - Time
        {
        TTime value;
        CAknTimeQueryDialog* dlg = CAknTimeQueryDialog::NewL(value);
        if (dlg->ExecuteLD(R_GUICTRLS_DATA_QUERY_TIME))
            {
            // ok pressed
            }
        break;
        }
    case 4: // Data - Duration
        {
        TTimeIntervalSeconds duration;
        CAknDurationQueryDialog* dlg = CAknDurationQueryDialog::NewL(duration);
        if (dlg->ExecuteLD( R_GUICTRLS_DATA_QUERY_DURATION ))
            {
            // ok pressed
            }
        break;
        }
    case 5: // Data - Floating Point
        {
        TReal value;
        CAknFloatingPointQueryDialog* dlg = CAknFloatingPointQueryDialog::NewL(value);
        if (dlg->ExecuteLD( R_GUICTRLS_DATA_QUERY_FLOATINGPOINT ))
            {
            // ok pressed
            }
        break;
        }
    case 6: // Data - Multiline
        {
        TInt topData( 0 );
        TInt bottomData( 0 );
        CAknMultiLineDataQueryDialog* dlg = 
            CAknMultiLineDataQueryDialog::NewL( topData, bottomData );
        if (dlg->ExecuteLD( R_GUICTRLS_DATA_QUERY_MULTILINE ))
            {
            // ok pressed
            }
        break;
        }
    case 7: // List - SingleSelect
        {
        TInt index( 0 );
        CAknListQueryDialog* dlg = new ( ELeave ) CAknListQueryDialog( &index );
        if (dlg->ExecuteLD( R_GUICTRLS_LIST_QUERY_SINGLE ))
            {
            // ok pressed
            }
        break;
        }
    case 8: // List - MultiSelect
        {
        CArrayFixFlat<TInt>* array = new ( ELeave ) CArrayFixFlat<TInt>( 6 );
        CleanupStack::PushL( array );
        CAknListQueryDialog* dlg = new ( ELeave ) CAknListQueryDialog( array );
        if (dlg->ExecuteLD( R_GUICTRLS_LIST_QUERY_MULTI ))
            {
            // ok pressed
            }
        CleanupStack::PopAndDestroy();
        break;
        }
    case 9: // Data - Secret
        {
        TBuf<8> buf;
        CAknTextQueryDialog* dlg = CAknTextQueryDialog::NewL(buf);
        if (dlg->ExecuteLD(R_GUICTRLS_DATA_QUERY_SECRET))
            {
            // ok pressed
            }
        iEikonEnv->InfoMsg(buf);
        break;
        }
    case 10: // Data - Date
        {
        TTime value;
        value.HomeTime();
        CAknTimeQueryDialog* dlg = CAknTimeQueryDialog::NewL(value);
        if (dlg->ExecuteLD(R_GUICTRLS_DATA_QUERY_DATE))
            {
            // ok pressed
            }
        break;
        }
    default:
        break;
        }
    }

void CQueryListDialog::PreLayoutDynInitL()
    {
    CAknSingleStyleListBox*    listbox = static_cast<CAknSingleStyleListBox*> (Control(EDialogLine1));
    listbox->ActivateL();
    listbox->CreateScrollBarFrameL(ETrue);
    listbox->ScrollBarFrame()->SetScrollBarVisibilityL(CEikScrollBarFrame::EOn, CEikScrollBarFrame::EOn);
    }

// End of File

⌨️ 快捷键说明

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