?? alarmorganiserdefaultcontainer.cpp
字號:
/**
*
* @brief Definition of CAlarmOrganiserDefaultContainer
*
* Copyright (c) EMCC Software Ltd 2003
* @version 1.0
*/
// INCLUDES
// Class include
#include "AlarmOrganiserDefaultContainer.h"
// System includes
#include <AlarmOrganiser.rsg> // R_EMPTY_LIST_TEXT
#include <aknlists.h> // CAknSingleNumberStyleListBox
#include <AknQueryDialog.h> // CAknQueryDialog
// User Includes
#include "AlarmOrganiserDefaultEngine.h" // CAlarmOrganiserDefaultEngine
// = ================ MEMBER FUNCTIONS ====================== =
/**
* Symbian OS 2 phase constructor.
* Constructs the CAlarmOrganiserDefaultContainer using the NewLC method, popping
* the constructed object from the CleanupStack before returning it.
*
* @param aRect The rectangle for this window
* @return The newly constructed CAlarmOrganiserDefaultContainer
*/
CAlarmOrganiserDefaultContainer* CAlarmOrganiserDefaultContainer::NewL(const TRect& aRect)
{
CAlarmOrganiserDefaultContainer* self = CAlarmOrganiserDefaultContainer::NewLC(aRect);
CleanupStack::Pop(self);
return self;
}
/**
* Symbian OS 2 phase constructor.
* Constructs the CAlarmOrganiserDefaultContainer using the constructor and ConstructL
* method, leaving the constructed object on the CleanupStack before returning it.
*
* @param aRect The rectangle for this window
* @return The newly constructed CAlarmOrganiserDefaultContainer
*/
CAlarmOrganiserDefaultContainer* CAlarmOrganiserDefaultContainer::NewLC(const TRect& aRect)
{
CAlarmOrganiserDefaultContainer* self = new (ELeave) CAlarmOrganiserDefaultContainer;
CleanupStack::PushL(self);
self->ConstructL(aRect);
return self;
}
/**
* Symbian OS 2nd phase constructor. Creates a Window for the controls, creates the listbox
* and then creates the AlarmOrganiser engine
* @param aRect The rectangle for this window
*/
void CAlarmOrganiserDefaultContainer::ConstructL(const TRect& aRect)
{
CreateWindowL();
// Create the List Box
iListBox = new (ELeave) CAknSingleNumberStyleListBox();
iListBox->ConstructL(this, EAknListBoxSelectionList);
iListBox->SetContainerWindowL(*this);
iListBox->CreateScrollBarFrameL(ETrue);
iListBox->ScrollBarFrame()->SetScrollBarVisibilityL(CEikScrollBarFrame::EOff, CEikScrollBarFrame::EAuto);
iListBox->SetRect(Rect());
iListBox->SetListBoxObserver(this);
// Show the empty list box text rather than the default "no data"
HBufC* emptyListText = iEikonEnv->AllocReadResourceLC(R_EMPTY_LIST_TEXT);
iListBox->View()->SetListEmptyTextL(*emptyListText);
CleanupStack::PopAndDestroy (emptyListText);
SetRect(aRect);
ActivateL();
// Create the alarm engine
iEngine = CAlarmOrganiserDefaultEngine::NewL(*this);
}
/**
*
* Called by framework when the view size is changed.
* Resizes the iListBox accordingly.
*
*/
void CAlarmOrganiserDefaultContainer::SizeChanged()
{
if (iListBox)
{
iListBox->SetRect(Rect());
}
}
/**
* Called by the framework in compound controls
* @return The number of controls in this CAlarmOrganiserDefaultContainer
*/
TInt CAlarmOrganiserDefaultContainer::CountComponentControls() const
{
return 1;
}
/**
* Called by the framework in compound controls
* @param The index of the control to return
* @return The control for aIndex
*/
CCoeControl* CAlarmOrganiserDefaultContainer::ComponentControl(TInt aIndex) const
{
switch (aIndex)
{
case 0:
return iListBox;
default:
return NULL;
}
}
/**
* Destructor.
*/
CAlarmOrganiserDefaultContainer::~CAlarmOrganiserDefaultContainer()
{
delete iEngine;
delete iListBox;
}
/**
* Called by the framework to draw this control. Clears the area in
* aRect.
* @param aRect in which to draw
*/
void CAlarmOrganiserDefaultContainer::Draw(const TRect& aRect) const
{
CWindowGc& gc = SystemGc();
gc.Clear(aRect);
}
/**
* Inherited from MAgnProgressCallBack.
* This function is called at intervals while an activity on an
* Agenda model (in this case OpenL()) is in progress. If the
* activity completes quickly this function may not be called at all.
* @param aPercentageCompleted what percentage of the process has been completed
*/
void CAlarmOrganiserDefaultContainer::Progress(TInt /*aPercentageCompleted*/)
{
}
/**
* Inherited from MAgnProgressCallBack.
* Called when the activity has completed.
* @param aError any error which has occurred.
*/
void CAlarmOrganiserDefaultContainer::Completed(TInt /*aError*/)
{
}
/**
* Inherited from MAlarmOrganiserEngineMixin. Called back
* when the engine has been initialised.
* @param aError any error which has occurred.
*/
void CAlarmOrganiserDefaultContainer::EngineCallBack(TInt aError)
{
if (aError == KErrNone)
{
SetListBoxArray();
}
}
/**
* Called by the framework whenever a key event occurs.
* Passes the key event to the listbox if it is not null, otherwise returns
* EKeyWasNotConsumed
* @param aKeyEvent the Key event which occured, e.g. select key pressed
* @param aType the type of Key event which occurred, e.g. key up, key down
* @return TKeyResponse EKeyWasNotConsumed if the key was not processed, EKeyWasConsumed if it was
*/
TKeyResponse CAlarmOrganiserDefaultContainer::OfferKeyEventL(const TKeyEvent& aKeyEvent, TEventCode aType)
{
TChar charCode(aKeyEvent.iCode);
switch (charCode)
{
// Switches tab
case EKeyLeftArrow: // Left key.
case EKeyRightArrow: // Right Key.
break;
default:
{
if (iListBox)
{
return iListBox->OfferKeyEventL(aKeyEvent, aType);
}
}
}
return EKeyWasNotConsumed;
}
/**
* Handles listbox event. Calls remove alarm
* @param aListBox Pointer to ListBox object is not used.
* @param aEventType Type of listbox event.
*/
void CAlarmOrganiserDefaultContainer::HandleListBoxEventL(CEikListBox* /*aListBox*/, TListBoxEvent aListBoxEvent)
{
// if the Select Key has been pressed
if ((aListBoxEvent == MEikListBoxObserver::EEventEnterKeyPressed) ||
(aListBoxEvent == MEikListBoxObserver::EEventItemClicked))
{
RemoveAlarmL();
}
}
/**
* This functions sets the data displayed in the list box
* to the array created by CAlarmOrganiserDefaultEngine
*/
void CAlarmOrganiserDefaultContainer::SetListBoxArray()
{
CTextListBoxModel* model = iListBox->Model();
// Set the model data
model->SetItemTextArray(iEngine->ListBoxArray());
model->SetOwnershipType(ELbmDoesNotOwnItemArray);
iListBox->Reset();
DrawNow();
}
/**
* Displays a dialog asking whether to remove the currently selected
* alarm. Calls the CAlarmOrganiserEngineBase::RemoveAlarmL() if the
* alarm is to be removed
*/
void CAlarmOrganiserDefaultContainer::RemoveAlarmL()
{
TInt alarm = iListBox->CurrentItemIndex();
if (alarm < 0)
{
return; // Invalid alarm.
}
HBufC* text = CEikonEnv::Static()->AllocReadResourceLC(R_REMOVE_ALARM_TEXT);
CAknQueryDialog* dlg = new (ELeave) CAknQueryDialog(*text);
if (dlg->ExecuteLD(R_ALARMORGANISER_CONFIRMATION_QUERY))
{
iEngine->RemoveAlarmL(alarm);
}
CleanupStack::PopAndDestroy(text);
}
/**
* returns if the list box is empty or not
* @return ETrue if the listbox is empty
*/
TBool CAlarmOrganiserDefaultContainer::ListBoxEmpty()
{
return (iListBox->Model()->NumberOfItems() == 0);
}
// End of File
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -