fontsandtextappui.cpp
来自「最新官方例子,图形,描述副,基本控件,通讯协议,等等,」· C++ 代码 · 共 143 行
CPP
143 行
/**
*
* @brief Definition of CFontsAndTextAppUi
*
* Copyright (c) EMCC Software Ltd 2003
* @version 1.0
*/
// INCLUDE FILES
// Class includes
#include "FontsAndTextAppUi.h"
// System includes
#include <akntabgrp.h> // CAknTabGroup
#include <aknnavi.h> // CAknNavigationControlContainer
#include <aknnavide.h> // CAknNavigationDecorator
// User includes
#include "FontsAndTextBasicView.h" // CFontsAndTextBasicView
#include "FontsAndTextMetricsView.h" // CFontsAndTextMetricsView
#include "FontsAndTextDeviceFontsView.h" // CFontsAndTextDeviceFontsView
#include "FontsAndTextEffectsView.h" // CFontsAndTextEffectsView
// ================= MEMBER FUNCTIONS =======================
/**
* Symbian OS 2nd phase constructor. Constructs the application's views,
* transferring ownership of them to the superclass.
* Also sets up the navi pane to allow for 'tabbed' appearance of views
*/
void CFontsAndTextAppUi::ConstructL()
{
BaseConstructL();
// Show tabs for main views from resources
CEikStatusPane* sp = StatusPane();
// Fetch pointer to the default navi pane control
iNaviPane = (CAknNavigationControlContainer*)sp->ControlL(TUid::Uid(EEikStatusPaneUidNavi));
// Tabgroup has been read from the resource file and pushed to the navi pane.
// Get pointer to the navigation decorator with the ResourceDecorator() function.
// Application owns the decorator and it has responsibility to delete the object.
iDecoratedTabGroup = iNaviPane->ResourceDecorator();
if (iDecoratedTabGroup)
{
iTabGroup = (CAknTabGroup*)iDecoratedTabGroup->DecoratedControl();
}
CFontsAndTextBasicView* basicView = CFontsAndTextBasicView::NewLC();
AddViewL(basicView); // transfer ownership to CAknViewAppUi
CleanupStack::Pop(basicView);
CFontsAndTextMetricsView* metricsView = CFontsAndTextMetricsView::NewLC();
AddViewL(metricsView); // transfer ownership to CAknViewAppUi
CleanupStack::Pop(metricsView);
CFontsAndTextDeviceFontsView* deviceFontsView = CFontsAndTextDeviceFontsView::NewLC();
AddViewL(deviceFontsView); // transfer ownership to CAknViewAppUi
CleanupStack::Pop(deviceFontsView);
CFontsAndTextEffectsView* effectsView = CFontsAndTextEffectsView::NewLC();
AddViewL(effectsView); // transfer ownership to CAknViewAppUi
CleanupStack::Pop(effectsView);
SetDefaultViewL(*basicView);
}
/**
* Destructor. Cleans up resources held on the heap
*/
CFontsAndTextAppUi::~CFontsAndTextAppUi()
{
delete iDecoratedTabGroup;
}
/**
* Manages key input events of moving the directional pad left or right will cause the previous
* or next view to be displayed
*
* @param aKeyEvent the key event
* @param aType not used
*
*/
TKeyResponse CFontsAndTextAppUi::HandleKeyEventL(const TKeyEvent& aKeyEvent, TEventCode /*aType*/)
{
if (!iTabGroup)
{
return EKeyWasNotConsumed;
}
TInt active = iTabGroup->ActiveTabIndex();
TInt count = iTabGroup->TabCount();
switch (aKeyEvent.iCode)
{
case EKeyLeftArrow:
if (active > 0)
{
active--;
iTabGroup->SetActiveTabByIndex(active);
ActivateLocalViewL(TUid::Uid(iTabGroup->TabIdFromIndex(active)));
}
break;
case EKeyRightArrow:
if ((active + 1) < count)
{
active++;
iTabGroup->SetActiveTabByIndex(active);
ActivateLocalViewL(TUid::Uid(iTabGroup->TabIdFromIndex(active)));
}
break;
default:
return EKeyWasNotConsumed;
break;
}
return EKeyWasConsumed;
}
/**
* From CEikAppUi, takes care of command handling for both views.
*
* @param aCommand command to be handled
*/
void CFontsAndTextAppUi::HandleCommandL(TInt aCommand)
{
switch (aCommand)
{
case EEikCmdExit:
{
Exit();
break;
}
default:
break;
}
}
// End of File
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?