📄 guictrlscontainer.cpp
字号:
/*
* ============================================================================
* Name : CGuiCtrlsContainer from GuiCtrlsContainer.h
* Part of : GuiCtrls
* Created : 15.04.2005 by ToBeReplacedByAuthor
* Implementation notes:
* Initial content was generated by Series 60 Application Wizard.
* Version :
* Copyright: ToBeReplacedByCopyright
* ============================================================================
*/
// INCLUDE FILES
#include "GuiCtrlsContainer.h"
#include "GuiCtrlsView.h"
#include <barsread.h> // BAFL, for resource reader
#include <aknlists.h> // for Listbox
#include <guictrls.rsg>
#include <akntitle.h> // for title pane
#include <eikspane.h>
#include "NoteListDialog.h"
#include "QueryListDialog.h"
#include "DemoForm.h"
#include "EditorForm.h"
// ================= MEMBER FUNCTIONS =======================
// ---------------------------------------------------------
// CGuiCtrlsContainer::ConstructL(const TRect& aRect)
// EPOC two phased constructor
// ---------------------------------------------------------
//
void CGuiCtrlsContainer::ConstructL(const TRect& aRect, CGuiCtrlsView* aView)
{
CreateWindowL();
iView = aView;
iListBox = new(ELeave)CAknSingleStyleListBox();
iListBox->SetContainerWindowL(*this);
TResourceReader reader;
CEikonEnv::Static()->CreateResourceReaderLC(reader, R_GUICTRLS_LISTBOX_MAIN);
iListBox->ConstructFromResourceL( reader );
CleanupStack::PopAndDestroy(); // resource stuffs.
iListBox->SetListBoxObserver(this);
iListBox->CreateScrollBarFrameL(ETrue);
iListBox->ScrollBarFrame()->SetScrollBarVisibilityL(CEikScrollBarFrame::EOn, CEikScrollBarFrame::EOn);
SetRect(aRect);
ActivateL();
}
// Destructor
CGuiCtrlsContainer::~CGuiCtrlsContainer()
{
delete iListBox;
}
// ---------------------------------------------------------
// CGuiCtrlsContainer::SizeChanged()
// Called by framework when the view size is changed
// ---------------------------------------------------------
//
void CGuiCtrlsContainer::SizeChanged()
{
iListBox->SetExtent( TPoint(0,0), iListBox->MinimumSize() );
}
// ---------------------------------------------------------
// CGuiCtrlsContainer::CountComponentControls() const
// ---------------------------------------------------------
//
TInt CGuiCtrlsContainer::CountComponentControls() const
{
return 1; // return nbr of controls inside this container
}
// ---------------------------------------------------------
// CGuiCtrlsContainer::ComponentControl(TInt aIndex) const
// ---------------------------------------------------------
//
CCoeControl* CGuiCtrlsContainer::ComponentControl(TInt aIndex) const
{
switch ( aIndex )
{
case 0:
return iListBox;
default:
return NULL;
}
}
// ---------------------------------------------------------
// CGuiCtrlsContainer::Draw(const TRect& aRect) const
// ---------------------------------------------------------
//
void CGuiCtrlsContainer::Draw(const TRect& aRect) const
{
CWindowGc& gc = SystemGc();
gc.Clear();
}
void CGuiCtrlsContainer::HandleListBoxEventL(
CEikListBox* /*aListBox*/,
TListBoxEvent aEventType )
{
if ( aEventType == MEikListBoxObserver::EEventEnterKeyPressed ||
aEventType == MEikListBoxObserver::EEventItemClicked )
{
SwitchScreenL();
}
}
void CGuiCtrlsContainer::SwitchScreenL()
{
TInt index = iListBox->CurrentItemIndex();
CEikStatusPane* sp = iEikonEnv->AppUiFactory()->StatusPane();
CAknTitlePane* title = (CAknTitlePane*)sp->ControlL( TUid::Uid( EEikStatusPaneUidTitle ) );
switch (index)
{
case 0: // demo Form
title->SetTextL(_L("Form Demo"));
CDemoForm::RunLD();
break;
case 1: // Editor Form
title->SetTextL(_L("Editors Demo"));
CEditorForm::RunLD();
break;
case 2: // Notes Demo Dialog
title->SetTextL(_L("Notes Demo"));
CNoteListDialog::RunLD();
break;
case 3: // Query Demo Dialog
title->SetTextL(_L("Query Demo"));
CQueryListDialog::RunLD();
break;
case 4: // Menu Demo View
iView->ActivateAnotherViewL();
break;
default:
break;
}
}
// ---------------------------------------------------------
// CGuiCtrlsContainer::OfferKeyEventL(...)
// Notify key events to editors.
// ---------------------------------------------------------
//
TKeyResponse CGuiCtrlsContainer::OfferKeyEventL(
const TKeyEvent& aKeyEvent, TEventCode aType)
{
if ( aType != EEventKey ) // Is not key event?
{
return EKeyWasNotConsumed;
}
if (iListBox)
{
return iListBox->OfferKeyEventL(aKeyEvent, aType);
}
return EKeyWasNotConsumed;
}
// End of File
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -