📄 progbuildappui.cpp
字号:
// ProgBuildAppUI.cpp
//
// Copyright (c) 1999-2007 Symbian Software Ltd. All rights reserved.
//
// $Change: 937687 $
// SYSTEM HEADERS
#include <eikenv.h>
#include <uikon.hrh>
#include <eikfnlab.h>
#include <eiktbar.h>
#include <eikdialg.h>
#include <eikapp.h>
#include <eikmfne.h>
// PROJECT HEADERS
#include "ProgBuildAppUI.h"
#define EAppFileName 102
// ConstructL
// Initial object setup chores.
void CProgBuildAppUi::ConstructL()
{
BaseConstructL();
iAppView = new(ELeave) CProgBuildView(iCounter);
iAppView->ConstructL(ClientRect());
AddToStackL(iAppView); // app view should go onto control stack
}
CProgBuildAppUi::CProgBuildAppUi(RCountServ& aCounter) : iCounter(aCounter)
{
}
// ~CProgBuildAppUi
CProgBuildAppUi::~CProgBuildAppUi()
{
if (iAppView)
{
RemoveFromStack(iAppView);
delete iAppView;
}
}
// HandleCommandL: Handle command requests.
void CProgBuildAppUi::HandleCommandL(TInt aCommand)
{
switch (aCommand)
{
// misc commands
case EIncrease:
CmdIncrease();
break;
case EIncreaseBy:
CmdIncreaseBy();
break;
case EDecrease:
CmdDecrease();
break;
case EDecreaseBy:
CmdDecreaseBy();
break;
case EReset:
CmdReset();
break;
// file/app
case EEikCmdExit:
CmdExit();
break;
}
}
void CProgBuildAppUi::CmdIncrease()
{
iCounter.Increase();
iAppView->DrawNow();
}
void CProgBuildAppUi::CmdIncreaseBy()
{
TBool decrFlag = EFalse;
TInt numEditorValue = 0;
CEikDialog* dialog = new(ELeave) CCounterDialog(decrFlag, numEditorValue);
// Launch the dialog, puts increase value in model
if (dialog->ExecuteLD(R_COUNTER_INCR_DIALOG))
{
iCounter.IncreaseBy(numEditorValue);
// Redraw the application view with the new counter value
iAppView->DrawNow();
}
}
void CProgBuildAppUi::CmdDecrease()
{
iCounter.Decrease();
iAppView->DrawNow();
}
void CProgBuildAppUi::CmdDecreaseBy()
{
TBool decrFlag = ETrue;
TInt numEditorValue = 0;
CEikDialog* dialog = new(ELeave) CCounterDialog(decrFlag, numEditorValue);
// Launch the dialog
if (dialog->ExecuteLD(R_COUNTER_DECR_DIALOG))
{
iCounter.DecreaseBy(numEditorValue);
// Redraw the application view with the new counter value
iAppView->DrawNow();
}
}
void CProgBuildAppUi::CmdReset()
{
iCounter.Reset();
iAppView->DrawNow();
}
void CProgBuildAppUi::CmdExit()
{
TInt ret = iCounter.Stop();
if (ret == KErrNotSupported)
{
iEikonEnv->InfoMsg(R_FUNC_NOT_SUPPORTED);
}
// close the count server session
iCounter.Close();
Exit();
}
///////////////////////////////////////
// CCounterDialog classes
///////////////////////////////////////
CCounterDialog::CCounterDialog(TBool aDecrFlag, TInt& aNumEditorValue)
:iDecrFlag(aDecrFlag), iNumEditor(aNumEditorValue)
{
}
TBool CCounterDialog::OkToExitL(TInt /*aKeycode*/)
{
CEikNumberEditor* numEditor = (CEikNumberEditor*) Control(ECounterOperand);
iNumEditor = (numEditor->Number());
return ETrue;
}
void CCounterDialog::PreLayoutDynInitL()
{
// Initialise the number editor to 0
CEikNumberEditor* numEditor = (CEikNumberEditor*) Control(ECounterOperand);
numEditor->SetNumber(0);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -