|
|
|||
A UIQ application's view occupies the application space, which is most of the screen area.
It contains controls which the user can interact with. It is owned and constructed by the application UI class.
The view also handles pointer events and user commands. It is also possible to pass on the commands that are not applicable to the App UI.
To create a minimal view class:
Derive a view class from CQikViewBase or CQikMultiPageViewBase depending on the type of view.
If the view has several pages it should inherit from CQikMultiPageViewBase and if it is just a single page it should inherit from CQikViewBase.
Implement a second phase constructor.
The constructor should call CQikViewBase::BaseConstructL() for initialization.
Overload CQikViewBase::ViewId().
This is then called by the framework and returns the ID of the view.
The following code fragment shows a minimal view-class definition.
class CExampleView : public CQikViewBase
{
private:
void ConstructL();
protected:
TVwsViewId ViewId()const;
void ViewContructL();
};
The following code fragment shows the minimal implementation of NewLC() in the class. Note that the function leaves the class on the cleanup stack.
CExampleView* CExampleView::NewLC(CQikAppUi& aAppUi, const TVwsViewId aParentViewId, CExampleModel& aModel)
{
CExampleView* self = new(ELeave) CExampleView(aAppUi, aParentViewId, aModel);
CleanupStack::PushL(self);
self->ConstructL();
return self;
}
The following code fragment shows the minimal implementation of first-phase constructor.
CExampleView::CExampleView(CQikAppUi& aAppUi, const TVwsViewId aParentViewId, CExampleModel& aModel)
: CQikViewBase(aAppUi, aParentViewId), iExampleModel(aModel), iCmdManager(CQikCommandManager::Static())
{
}
The following code fragment shows the minimal implementation of second-phase constructor. This is a standard pattern for a view control.
void CExampleAppView::ConstructL(const TRect& aRect)
{
CQikViewBase::BaseConstructL();
}
The following code fragment shows the implementation of ViewId() function.
void CExampleAppView::ViewId()const
{
return TVwsViewId(KUidExampleApp, KUidExampleAppView);
}
The following code fragment shows a minimal implementation of ViewConstructL() function.
It reads a resource struct from the resource file and constructs the view.
void CExampleAppView::ViewConstructL()
{
ViewConstructFromResourceL(R_EXAMPLEAPP_LISTVIEW_UI_CONFIGURATIONS);
}