/*
* ============================================================================
* Name : tactileexampleappview.cpp
* Part of : Tactile Example
* Interface : N/A
* Description : Implementation of view class
* Version :
*
* Copyright (c) 2008 Nokia Corporation.
* This material, including documentation and any related
* computer programs, is protected by copyright controlled by
* Nokia Corporation.
* ============================================================================
*/
// INCLUDE FILES
#include <aknbutton.h>
#include <stringloader.h>
#include <touchfeedback.h>
#include <tactileexample.rsg>
#include "tactileexampleappview.h"
#include "tactileexamplesquare.h"
#include "tactileexamplecircle.h"
//ENUMERATION
enum TPointerToComponentView
{
ESquare = 0,
ECircle,
EButton
};
//CONSTANTS
const TInt KNumberOfComponents = 3;
const TInt KMovementGrid = 10; // in pixels
const TInt KButtonHeight = 4; // divisions of screen height
const TInt KObjSize = 4; // divisions of screen height or width
// ============================ MEMBER FUNCTIONS =============================
// ---------------------------------------------------------------------------
// Two-phased constructor.
// ---------------------------------------------------------------------------
//
CTactileExampleAppView* CTactileExampleAppView::NewL( const TRect& aRect )
{
CTactileExampleAppView* self = CTactileExampleAppView::NewLC( aRect );
CleanupStack::Pop( self );
return self;
}
// ---------------------------------------------------------------------------
// Two-phased constructor.
// ---------------------------------------------------------------------------
//
CTactileExampleAppView* CTactileExampleAppView::NewLC( const TRect& aRect )
{
CTactileExampleAppView* self = new ( ELeave ) CTactileExampleAppView;
CleanupStack::PushL( self );
self->ConstructL( aRect );
return self;
}
// ---------------------------------------------------------------------------
// Frees reserved resources
// ---------------------------------------------------------------------------
//
CTactileExampleAppView::~CTactileExampleAppView()
{
delete iButton;
delete iSquare;
delete iCircle;
}
// ---------------------------------------------------------------------------
// From class CCoeControl.
// return nbr of controls inside this container.
// ---------------------------------------------------------------------------
//
TInt CTactileExampleAppView::CountComponentControls() const
{
return KNumberOfComponents;
}
// ---------------------------------------------------------------------------
// From class CCoeControl.
// return pointer of controls inside this container
// ---------------------------------------------------------------------------
//
CCoeControl* CTactileExampleAppView::ComponentControl(TInt aIndex) const
{
switch( aIndex )
{
case EButton:
return iButton;
case ESquare:
return iSquare;
case ECircle:
return iCircle;
default:
return NULL;
}
}
// ---------------------------------------------------------------------------
// From class CCoeControl.
// Draw this CTactileExampleAppView to the screen.
// ---------------------------------------------------------------------------
//
void CTactileExampleAppView::Draw( const TRect& aRect ) const
{
// Get the standard graphics context
CWindowGc& gc = SystemGc();
gc.SetPenStyle( CGraphicsContext::ENullPen );
gc.SetBrushColor( KRgbWhite );
gc.SetBrushStyle( CGraphicsContext::ESolidBrush );
// Clears the area
gc.Clear( aRect );
}
// ---------------------------------------------------------------------------
// From class CCoeControl.
// Called by framework when the view size is changed.
// Set objects to default positions
// ---------------------------------------------------------------------------
//
void CTactileExampleAppView::SizeChanged()
{
// Gets the control's extent
TRect rect( Rect() );
// Set button's extent
TRect buttonRect = TRect( rect.iTl.iX,
rect.iBr.iY - rect.Height() / KButtonHeight,
rect.iBr.iX, rect.iBr.iY );
iButton->SetRect( buttonRect );
// Set area where dragging is possible
iDragArea.SetRect( rect.iTl.iX, rect.iTl.iY, rect.iBr.iX, buttonRect.iTl.iY );
// Update object dimension
ObjectDimension();
}
// ---------------------------------------------------------------------------
// From class CCoeControl.
// Moves objects and plays feedback during dragging
// ---------------------------------------------------------------------------
//
void CTactileExampleAppView::HandlePointerEventL( const TPointerEvent& aPointerEvent )
{
TPoint point = aPointerEvent.iPosition;
if ( iDragArea.Contains( point ))
{
if ( aPointerEvent.iType == TPointerEvent::EButton1Down &&
iSquare->Rect().Center() != iCircle->Rect().Center() )
{
if ( iCircle->HitRegionContains( point, *iCircle ))
{
// dragging of circle started
iDragCircle = ETrue;
iDraggingOffset = iCircle->Position() - point;
}
else if ( iSquare->HitRegionContains( point, *iSquare ))
{
// dragging of square started
iDragSquare = ETrue;
iDraggingOffset = iSquare->Position() - point;
}
else
{
// Cancel dragging just in case
iDragCircle = EFalse;
iDragSquare = EFalse;
}
}
if ( aPointerEvent.iType == TPointerEvent::EDrag )
{
if( iDragCircle )
{
Move( iCircle, point + iDraggingOffset );
}
else if( iDragSquare )
{
Move( iSquare, point + iDraggingOffset );
}
if( iSquare->Rect().Center() == iCircle->Rect().Center() )
{
// Objects are in end positions -> cancel dragging
iDragCircle = EFalse;
iDragSquare = EFalse;
// and disable all feedbacks
iSquare->EnableFeedback( EFalse );
iCircle->EnableFeedback( EFalse );
}
}
}
if ( aPointerEvent.iType == TPointerEvent::EButton1Up )
{
// possible dragging is cancelled if button is released
iDragCircle = EFalse;
iDragSquare = EFalse;
}
CCoeControl::HandlePointerEventL( aPointerEvent );
}
// ---------------------------------------------------------------------------
// From class CCoeControl.
// Enables feedback when layout is changed
// ---------------------------------------------------------------------------
//
void CTactileExampleAppView::HandleResourceChange( TInt aType )
{
CCoeControl::HandleResourceChange( aType );
if ( aType == KEikDynamicLayoutVariantSwitch )
{
// Set circle and square to default positions
SetObjects();
// enable feedback again since it might have been disabled
// if square & circle are in end positions
iCircle->EnableFeedback( ETrue );
iSquare->EnableFeedback( ETrue );
// ohjects are made visible/hidden depending
// is touch supported for new layout
iSquare->MakeVisible( AknLayoutUtils::PenEnabled() );
iCircle->MakeVisible( AknLay
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
TactileExample.rar (82个子文件)
TactileExample
.project 526B
group
ABLD.BAT 372B
bld.inf 611B
tactileexample.mmp 2KB
Icons_scalable_dc.mk 1KB
sis
tactileexample_armv5.pkg 1KB
tactileexample_gcce.pkg 1KB
backup_registration.xml 234B
.cproject 14KB
inc
tactileexampleappview.h 5KB
tactileexampleapplication.h 2KB
tactileexamplesquare.h 3KB
tactileexampledocument.h 2KB
tactileexampleappui.h 2KB
TactileExampleForm.hrh 391B
TactileExampleFormView.h 3KB
tactileexamplecircle.h 2KB
TactileExampleForm.h 2KB
src
tactileexampleapplication.cpp 2KB
tactileexample.cpp 1KB
tactileexampleappui.cpp 3KB
TactileExampleFormView.cpp 6KB
tactileexamplesquare.cpp 5KB
TactileExampleForm.cpp 7KB
tactileexampleappview.cpp 13KB
tactileexamplecircle.cpp 5KB
tactileexampledocument.cpp 2KB
gfx
qgn_menu_tactileexample.svg 4KB
doc
tabs.css 2KB
tactileexamplesquare_8cpp-source.html 16KB
class_c_tactile_example_square.html 25KB
tab_r.gif 3KB
class_c_tactile_example_circle.png 704B
class_c_tactile_example_app_view-members.html 9KB
class_c_tactile_example_square.png 725B
class_c_tactile_example_application.html 8KB
tactileexampleappview_8cpp-source.html 42KB
class_c_tactile_example_circle-members.html 5KB
tact.jpg 11KB
tactileexampleappview_8h-source.html 21KB
tactileexample_8cpp-source.html 5KB
class_c_tactile_example_app_ui-members.html 4KB
class_c_tactile_example_application-members.html 3KB
tactileexamplecircle_8cpp-source.html 15KB
files.html 4KB
class_c_tactile_example_document.png 509B
class_c_tactile_example_app_ui.png 470B
class_c_tactile_example_app_view.html 73KB
tab_b.gif 35B
doxygen.png 1KB
tactileexampleapplication_8cpp-source.html 7KB
tactileexampleapplication_8h-source.html 7KB
functions_func.html 9KB
tactileexamplecircle_8h-source.html 10KB
tactileexamplesquare_8h-source.html 12KB
annotated.html 3KB
class_c_tactile_example_application.png 517B
tactileexampleappui_8h-source.html 9KB
functions.html 11KB
tab_l.gif 706B
tactileexampleappui_8cpp-source.html 12KB
Mainpage.dox 5KB
class_c_tactile_example_app_view.png 740B
functions_vars.html 4KB
class_c_tactile_example_square-members.html 5KB
class_c_tactile_example_app_ui.html 17KB
index.html 7KB
tactileexampledocument_8h-source.html 7KB
class_c_tactile_example_document-members.html 3KB
top.gif 898B
tactileexample_8mmp-source.html 6KB
style.css 7KB
tactileexampledocument_8cpp-source.html 7KB
class_c_tactile_example_circle.html 21KB
class_c_tactile_example_document.html 9KB
hierarchy.html 3KB
data
TactileExampleForm.l01 376B
TactileExampleForm.rssi 2KB
TactileExample_reg.rss 937B
TactileExampleForm.loc 330B
tactileexample.rls 839B
tactileexample.rss 2KB
共 82 条
- 1
资源评论
newtonbacan
- 粉丝: 1
- 资源: 6
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功