?? heatmeter2appui.cpp
字號:
/*
* ============================================================================
* Name : CHeatMeter2AppUi from HeatMeter2AppUi.cpp
* Part of : HeatMeter2
* Created : 2004.03.27. by
* Implementation notes:
* Initial content was generated by Series 60 AppWizard.
* Version :
* Copyright:
* ============================================================================
*/
// INCLUDE FILES
#include "HeatMeter2AppUi.h"
#include "HeatMeter2View.h"
#include <HeatMeter2.rsg>
#include "heatmeter2.hrh"
#include "SettingListBox.h"
#include "HeatMeter2Container.h"
#include "DataBase.h"
#include <avkon.hrh>
// ================= MEMBER FUNCTIONS =======================
//
// ----------------------------------------------------------
// CHeatMeter2AppUi::ConstructL()
//
// ----------------------------------------------------------
//
void CHeatMeter2AppUi::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 resource and it were 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();
}
view1 = new (ELeave) CHeatMeter2View;
CleanupStack::PushL( view1 );
view1->ConstructL();
AddViewL( view1 ); // transfer ownership to CAknViewAppUi
CleanupStack::Pop(); // view1
SetDefaultViewL(*view1);
}
// ----------------------------------------------------
// CHeatMeter2AppUi::~CHeatMeter2AppUi()
// Destructor
// Frees reserved resources
// ----------------------------------------------------
//
CHeatMeter2AppUi::~CHeatMeter2AppUi()
{
if (iListBox)
{
RemoveFromStack(iListBox);
delete iListBox;
iListBox = NULL;
}
delete iDecoratedTabGroup;
}
// ------------------------------------------------------------------------------
// CHeatMeter2AppUi::DynInitMenuPaneL(TInt aResourceId,CEikMenuPane* aMenuPane)
// This function is called by the EIKON framework just before it displays
// a menu pane. Its default implementation is empty, and by overriding it,
// the application can set the state of menu items dynamically according
// to the state of application data.
// ------------------------------------------------------------------------------
//
void CHeatMeter2AppUi::DynInitMenuPaneL(
TInt /*aResourceId*/,CEikMenuPane* /*aMenuPane*/)
{
}
// ----------------------------------------------------
// CHeatMeter2AppUi::HandleKeyEventL(
// const TKeyEvent& aKeyEvent,TEventCode /*aType*/)
// takes care of key event handling
// ----------------------------------------------------
//
TKeyResponse CHeatMeter2AppUi::HandleKeyEventL(
const TKeyEvent& aKeyEvent,TEventCode /*aType*/)
{
if ( iTabGroup == NULL )
{
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;
}
// ----------------------------------------------------
// CHeatMeter2AppUi::HandleCommandL(TInt aCommand)
// takes care of command handling
// ----------------------------------------------------
//
void CHeatMeter2AppUi::HandleCommandL(TInt aCommand)
{
switch ( aCommand )
{
case EEikCmdExit:
case EAknSoftkeyExit:
{
Exit();
break;
}
case EHeatMeter2CmdAppTest:
{
iEikonEnv->InfoMsg(_L("test"));
break;
}
case EHeatMeter2CmdSettings:
{
//show the settings dialog
DoSettings();
break;
}
// TODO: Add Your command handling code here
case EAknSoftkeyBack:
if (iListBox)
{
SettingsDone();
} break;
default:
break;
}
}
//show the settings dialog
void CHeatMeter2AppUi::DoSettings()
{
if (iListBox)
{
RemoveFromStack(iListBox);
delete iListBox;
iListBox = NULL;
}
iListBox = new (ELeave) CSettingListbox;
iListBox->SetData(&(view1->iContainer->iHeatMeterDatabase->iClientID), &(view1->iContainer->iServerAddr));
iListBox->SetMopParent(this);
iListBox->ConstructFromResourceL(R_HEATMETER_SETTING_ITEM_LIST);
AddToStackL(iListBox);
iListBox->MakeVisible(ETrue);
iListBox->SetRect(ClientRect());
iListBox->ActivateL();
CEikButtonGroupContainer *c=Cba();
c->SetCommandSetL(R_AVKON_SOFTKEYS_OK_EMPTY);
c->DrawNow();
// view1->DoSettings();
iListBox->DrawNow();
}
void CHeatMeter2AppUi::SettingsDone()
{
TInt iOldClientId=view1->iContainer->iHeatMeterDatabase->iClientID;
Cba()->SetCommandSetL(R_AVKON_SOFTKEYS_OPTIONS_EXIT);
Cba()->DrawNow();
//iListBox->StoreSettingsL();
RemoveFromStack(iListBox);
iListBox->StoreSettingsL();
delete iListBox;
iListBox = NULL;
if (iOldClientId!=view1->iContainer->iHeatMeterDatabase->iClientID)
{
view1->iContainer->iHeatMeterDatabase->ResetDataBase();
view1->iContainer->FillListBox();
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -