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

📄 bencoolensettingsview.cpp

📁 Symbian截图软件ScreenShot*水印版*的源码,2nd和3rd的也在这个包中
💻 CPP
字号:
/*
 * BencoolenSettingsView.cpp
 *
 * Copyright 2005 - 2007, Antony Pranata
 * http://www.antonypranata.com
 *
 * Project: Screenshot for Symbian OS.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License along
 * with this program; if not, write to the Free Software Foundation, Inc.,
 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 */

// INCLUDE FILES
#include <avkon.hrh>
#include <avkon.rsg>
#include <akntitle.h>
#include <aknviewappui.h>
#include <screenshot.rsg>

#include "Bencoolen.hrh"
#include "BencoolenSettingsView.h"
#include "BencoolenAppUi.h"
#include "BencoolenSettingsListBox.h"


// MEMBER FUNCTIONS

// --------------------------------------------------------------------------
// Two-phase contructor.
// --------------------------------------------------------------------------
CBencoolenSettingsView* CBencoolenSettingsView::NewL(
        CScreenShotData* aScreenShotData)
    {
    CBencoolenSettingsView* self = new (ELeave) CBencoolenSettingsView(
        aScreenShotData);
    CleanupStack::PushL(self);
    self->ConstructL();
    CleanupStack::Pop(); // self;
    return self;
    }

// --------------------------------------------------------------------------
// Destructor.
// --------------------------------------------------------------------------
CBencoolenSettingsView::~CBencoolenSettingsView()
    {
    if (iListBox)
        {
        AppUi()->RemoveFromStack(iListBox);
        delete iListBox;
        }
    }

// --------------------------------------------------------------------------
// Returns the identifier of this view.
// --------------------------------------------------------------------------
TUid CBencoolenSettingsView::Id() const
    {
    return TUid::Uid(EBencoolenSettingsViewId);
    }
    
// --------------------------------------------------------------------------
// Handles commands in this view.
// Basically we only need to handle Change menu. If the user selects Change
// menu, we send OK key event to the list box.
// Otherwise, we just pass the command to AppUi().
// --------------------------------------------------------------------------
void CBencoolenSettingsView::HandleCommandL(TInt aCommand)
    {
    switch (aCommand)
        {
        case EAknSoftkeyBack:
            {
            AppUi()->ActivateLocalViewL(TUid::Uid(EBencoolenAppViewId));
            break;
            }

        case EBencoolenCmdChange:
            {
            // Simulates Scroll key.
            TKeyEvent keyEvent = { 63557, EStdKeyDevice3, EModifierAutorepeatable, 0 }; 
            iListBox->OfferKeyEventL(keyEvent, EEventKeyDown);
            break;
            }

        default:
            AppUi()->HandleCommandL(aCommand);
            break;
        }
    }

#if (__S60__ >= 203)

// --------------------------------------------------------------------------
// Called when screen size/resolution is changed. We need to re-adjust
// the size/layout of list box.
// --------------------------------------------------------------------------
void CBencoolenSettingsView::HandleResourceChange(TInt aType)
    {
    if (iListBox)
        {
        iListBox->HandleResourceChange(aType);
        }
    }
    
#endif

// --------------------------------------------------------------------------
// C++ default constructor can NOT contain any code, that might leave.
// --------------------------------------------------------------------------
CBencoolenSettingsView::CBencoolenSettingsView(CScreenShotData* aScreenShotData)
:iScreenShotData(aScreenShotData)
    {
    }

// --------------------------------------------------------------------------
// Second phase constructor.
// --------------------------------------------------------------------------
void CBencoolenSettingsView::ConstructL()
    {
    BaseConstructL(R_BENCOOLEN_SETTINGSVIEW);
    }

// --------------------------------------------------------------------------
// Creates list box control.
// --------------------------------------------------------------------------
void CBencoolenSettingsView::CreateListBoxL(TInt aResourceId)
    {
    iListBox = new (ELeave) CBencoolenSettingsListBox();
    iListBox->SetData(iScreenShotData);
    iListBox->SetMopParent(this);
    iListBox->ConstructFromResourceL(aResourceId);

    AppUi()->AddToStackL(*this, iListBox);
    iListBox->MakeVisible(ETrue);
    iListBox->SetRect(ClientRect());
    iListBox->ActivateL();
    iListBox->DrawNow();
    }

// --------------------------------------------------------------------------
// Creates container class object.
// --------------------------------------------------------------------------
void CBencoolenSettingsView::DoActivateL( const TVwsViewId& /*aPrevViewId*/,
                                         TUid /*aCustomMessageId*/,
                                         const TDesC8& /*aCustomMessage*/ )
    {
    CreateListBoxL(R_BENCOOLEN_SETTINGS_ITEM);
    }

// --------------------------------------------------------------------------
// Deletes container class object.
// --------------------------------------------------------------------------
void CBencoolenSettingsView::DoDeactivate()
    {    
    if (iListBox)
        {
        iListBox->UpdateData();
        AppUi()->RemoveFromStack(iListBox);
        delete iListBox;
        iListBox = NULL;
        }

    // Sets the capture key
    static_cast<CBencoolenAppUi*> (AppUi())->SetCaptureKey();
    }
    
// End of File

⌨️ 快捷键说明

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