📄 mopoidappui.cpp
字号:
/*
* ============================================================================
* Name : CMopoidAppUi from MopoidAppUi.cpp
* Part of : Mopoid
* Created : 16.01.2004 by Andreas Jakl / Mopius - http://www.mopius.com/
* Description:
* Declares UI class for application.
* Version : 1.02
* Copyright:
* 'Mopoid' 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.
*
* 'Mopoid' 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 'Mopoid'; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* ============================================================================
*/
#include <e32std.h>
#include "Mopoid.hrh"
#include "Mopoidappui.h"
#include "Mopoidview.h"
#include "MopoidGameengine.h"
CMopoidAppUi::CMopoidAppUi()
{}
// -----------------------------------------------------------------------
// Method managed by IDE to construct views
// Please do not edit this routine as its
// contents are regenerated upon new view creation.
// -----------------------------------------------------------------------
void CMopoidAppUi::InitViewsL()
{
iMopoidView = CMopoidView::NewL();
AddViewL( iMopoidView );
}
// -----------------------------------------------------------------------
// Constructs AppUI Object
// -----------------------------------------------------------------------
void CMopoidAppUi::ConstructL()
{
BaseConstructL();
InitViewsL();
#ifdef WITH_TAB_GROUP
// -----------------------------------------------------------------------
// Show tabs for main views from resources
// -----------------------------------------------------------------------
CEikStatusPane* sp = StatusPane();
iNaviPane = (CAknNavigationControlContainer *)sp->ControlL(TUid::Uid(EEikStatusPaneUidNavi));
sp->SetDimmed(ETrue);
// -------------------------------------------------------------------------------
// Tabgroup has been read from resource and it was 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();
}
if (iTabGroup)
{
ActivateLocalViewL(TUid::Uid(iTabGroup->ActiveTabId()));
}
#else
// -----------------------------------------------------------------------
// Set default view
// -----------------------------------------------------------------------
SetDefaultViewL(*iMopoidView);
#endif
}
// -----------------------------------------------------------------------
// Cleanup of AppUI object
// -----------------------------------------------------------------------
CMopoidAppUi::~CMopoidAppUi()
{
#ifdef WITH_TAB_GROUP
delete iDecoratedTabGroup;
#endif
}
#ifdef WITH_TAB_GROUP
// -----------------------------------------------------------------------
// Key Event Handler - Primarily to automate navigation through tab groups
// -----------------------------------------------------------------------
TKeyResponse CMopoidAppUi::HandleKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aType)
{
if (aType == EEventKey)
{
if (iTabGroup == NULL)
{
return EKeyWasNotConsumed;
}
}
TInt active = iTabGroup->ActiveTabIndex();
TInt count = iTabGroup->TabCount();
switch (aKeyEvent.iCode)
{
case EKeyLeftArrow:
if (active > 0)
{
// -----------------------------------------------------------------------
// Change to usual layout
// -----------------------------------------------------------------------
TRect cr = ClientRect();
if (cr.iTl.iY == Kqpn_height_status_pane_idle)
{
StatusPane()->SwitchLayoutL(R_AVKON_STATUS_PANE_LAYOUT_USUAL);
}
active--;
iTabGroup->SetActiveTabByIndex(active);
ActivateLocalViewL(TUid::Uid(iTabGroup->TabIdFromIndex(active)));
return EKeyWasConsumed;
}
break;
case EKeyRightArrow:
if((active + 1) < count)
{
TRect cr = ClientRect();
if (cr.iTl.iY == Kqpn_height_status_pane_idle)
{
StatusPane()->SwitchLayoutL(R_AVKON_STATUS_PANE_LAYOUT_USUAL);
}
active++;
iTabGroup->SetActiveTabByIndex(active);
ActivateLocalViewL(TUid::Uid(iTabGroup->TabIdFromIndex(active)));
return EKeyWasConsumed;
}
break;
default:
break;
}
return EKeyWasNotConsumed;
}
#endif
// -----------------------------------------------------------------------
// Default handler of Command Events
// -----------------------------------------------------------------------
void CMopoidAppUi::HandleCommandL(TInt aCommand)
{
if (DispatchAppUICommandEvents(aCommand))
return;
switch (aCommand) {
case EEikCmdExit:
case EAknSoftkeyExit:
Exit();
break;
default:
break;
}
}
// -----------------------------------------------------------------------
// Here we dispatch to Command Event Handlers
//
// NOTE: This routine is managed by the C++Builder IDE - DO NOT MODIFY
// -----------------------------------------------------------------------
bool CMopoidAppUi::DispatchAppUICommandEvents(TInt aCommand)
{
switch ( aCommand )
{
default:
return false;
}
return true;
}
void CMopoidAppUi::OniMenuItemAboutAppUICommand( TInt aCommand )
{
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -