|
Nokia N97 SDK Example Applications Guide |
Inheritance diagram for CSensorExampleAppView:

Definition at line 27 of file sensorexampleappview.h.
Public Member Functions |
|
| virtual | ~CSensorExampleAppView () |
| void | Draw (const TRect &aRect) const |
| virtual void | SizeChanged () |
| void | TappingEvent (TInt aDirection) |
| void | AccelerometerData (TInt aX, TInt aY) |
| void | OrientationEvent (TSensrvOrientationData::TSensrvDeviceOrientation aDeviceOrientation) |
| TInt | ShowQueryDialogL (RSensrvChannelInfoList &aChannelList) |
| TInt | ShowQueryDialogL (RSensrvPropertyList &aChannelPropertyList) |
| void | GetPropertyStringL (TSensrvPropertyId aPropertyId, TInt aItemIndex, TDes &aPropertyBuf) |
Static Public Member Functions |
|
| static CSensorExampleAppView * | NewL (const TRect &aRect) |
| static CSensorExampleAppView * | NewLC (const TRect &aRect) |
Private Member Functions |
|
| void | ConstructL (const TRect &aRect) |
| CSensorExampleAppView () | |
Private Attributes |
|
| const CFont * | iFont |
| TSensrvOrientationData::TSensrvDeviceOrientation | iDeviceOrientation |
| TInt | iX |
| TInt | iY |
| TRgb | iFaceColor |
|
|
~CSensorExampleAppView Virtual Destructor. Definition at line 103 of file sensorexampleappview.cpp.
|
|
|
CSensorExampleAppView. C++ default constructor. Definition at line 89 of file sensorexampleappview.cpp. 00090 : iDeviceOrientation( iDeviceOrientation = TSensrvOrientationData::EOrientationDisplayUp ), 00091 iX( 0 ), 00092 iY( 0 ), 00093 iFaceColor( KRgbRed ) 00094 { 00095 // No implementation required 00096 }
|
|
|
NewL. Two-phased constructor. Create a CSensorExampleAppView object, which will draw itself to aRect.
Definition at line 44 of file sensorexampleappview.cpp. References NewLC(). Referenced by CSensorExampleAppUi::ConstructL(). 00045 { 00046 CSensorExampleAppView* self = CSensorExampleAppView::NewLC( aRect ); 00047 CleanupStack::Pop( self ); 00048 return self; 00049 }
|
|
|
NewLC. Two-phased constructor. Create a CSensorExampleAppView object, which will draw itself to aRect.
Definition at line 56 of file sensorexampleappview.cpp. References ConstructL(). Referenced by NewL(). 00057 { 00058 CSensorExampleAppView* self = new ( ELeave ) CSensorExampleAppView; 00059 CleanupStack::PushL( self ); 00060 self->ConstructL( aRect ); 00061 return self; 00062 }
|
|
|
From CCoeControl, Draw Draw this CSensorExampleAppView to the screen. If the user has given a text, it is also printed to the center of the screen.
Definition at line 114 of file sensorexampleappview.cpp. References iDeviceOrientation, iFaceColor, iX, and iY. 00115 { 00116 // note that the whole screen is drawn everytime, so aRect-parameter is ignored 00117 00118 CWindowGc& gc = SystemGc();// Get the standard graphics context 00119 TRect rect( Rect());// Gets the control's extent 00120 TSize screenSize( rect.Size()); 00121 TPoint middlePoint( screenSize.iWidth / 2, screenSize.iHeight / 2); 00122 TPoint ballTopLeftCorner( ( ( middlePoint.iX + iX ) - ( KBallSize.iWidth / 2 ) ), 00123 ( ( middlePoint.iY + iY )- ( KBallSize.iHeight / 2 ) ) ); 00124 TRect ballRect( ballTopLeftCorner, KBallSize ); 00125 00126 gc.SetPenStyle( CGraphicsContext::ENullPen ); 00127 gc.SetBrushColor( KRgbWhite ); 00128 gc.SetBrushStyle( CGraphicsContext::ESolidBrush ); 00129 gc.Clear( rect );//Clear screen 00130 gc.SetBrushColor( iFaceColor ); 00131 gc.DrawEllipse( ballRect );//Draw circle for smiley 00132 gc.SetBrushColor( KRgbWhite ); 00133 00134 //Draw rest of smiley i.e. eyes, nose and mouth 00135 TSize mouthSize; 00136 TRect smileyRect; 00137 TPoint eye1; 00138 TPoint eye2; 00139 TPoint nose; 00140 TPoint mouth; 00141 TPoint eyeTopLeftCorner; 00142 TPoint eyeTopRightCorner; 00143 TPoint eyeBottomLeftCorner; 00144 TPoint eyeBottomRightCorner; 00145 TPoint mouthTop; 00146 TPoint mouthBottom; 00147 TPoint mouthLeft; 00148 TPoint mouthRight; 00149 00150 eyeTopLeftCorner.iX = ( ballTopLeftCorner.iX + KBallSize.iWidth / 3 ) - ( KEyeDiameter / 2 ); 00151 eyeTopLeftCorner.iY = ( ballTopLeftCorner.iY + KBallSize.iHeight / 3 ) - ( KEyeDiameter / 2 ); 00152 eyeTopRightCorner.iX = ( ballTopLeftCorner.iX + KBallSize.iWidth / 3 * 2 ) - ( KEyeDiameter / 2 ); 00153 eyeTopRightCorner.iY = ( ballTopLeftCorner.iY + KBallSize.iHeight / 3 ) - ( KEyeDiameter / 2 ); 00154 eyeBottomLeftCorner.iX = ( ballTopLeftCorner.iX + KBallSize.iWidth / 3 ) - ( KEyeDiameter / 2 ); 00155 eyeBottomLeftCorner.iY = ( ballTopLeftCorner.iY + KBallSize.iHeight / 3 * 2 ) - ( KEyeDiameter / 2 ); 00156 eyeBottomRightCorner.iX = ( ballTopLeftCorner.iX + KBallSize.iWidth / 3 * 2 ) - ( KEyeDiameter / 2 ); 00157 eyeBottomRightCorner.iY = ( ballTopLeftCorner.iY + KBallSize.iHeight / 3 * 2 ) - ( KEyeDiameter / 2 ); 00158 00159 mouthTop.iX = ( ballTopLeftCorner.iX + KBallSize.iWidth / 2 ) - ( KMouthWidth / 2 ); 00160 mouthTop.iY = ( ballTopLeftCorner.iY + KMouthWidth / 2 ); 00161 mouthBottom.iX = ( ballTopLeftCorner.iX + KBallSize.iWidth / 2 ) - ( KMouthWidth / 2 ); 00162 mouthBottom.iY = ( ballTopLeftCorner.iY + KBallSize.iHeight / 2 ) + ( KMouthWidth / 2 ); 00163 mouthLeft.iX = ( ballTopLeftCorner.iX + KBallSize.iWidth / 2 ) + ( KMouthWidth / 2 ); 00164 mouthLeft.iY = ( ballTopLeftCorner.iY + KBallSize.iHeight / 2 ) - ( KMouthWidth / 2 ); 00165 mouthRight.iX = ( ballTopLeftCorner.iX + KMouthWidth / 2 ); 00166 mouthRight.iY = ( ballTopLeftCorner.iY + KBallSize.iHeight / 2 ) - ( KMouthWidth / 2 ); 00167 00168 nose.iX = ( ballTopLeftCorner.iX + KBallSize.iWidth / 2 ) - ( KMouthWidth / 2 ); 00169 nose.iY = ( ballTopLeftCorner.iY + KBallSize.iHeight / 2 ) - ( KMouthWidth / 2 ); 00170 00171 switch( iDeviceOrientation ) 00172 { 00173 case TSensrvOrientationData::EOrientationDisplayDown: 00174 { 00175 eye1 = eyeBottomLeftCorner; 00176 eye2 = eyeBottomRightCorner; 00177 mouth = mouthTop; 00178 mouthSize = KMouthSizeVertical; 00179 } 00180 break; 00181 00182 case TSensrvOrientationData::EOrientationDisplayLeftUp: 00183 { 00184 eye1 = eyeBottomLeftCorner; 00185 eye2 = eyeTopLeftCorner; 00186 mouth = mouthLeft; 00187 mouthSize = KMouthSizeHorizontal; 00188 } 00189 break; 00190 00191 case TSensrvOrientationData::EOrientationDisplayRightUp: 00192 { 00193 eye1 = eyeTopRightCorner; 00194 eye2 = eyeBottomRightCorner; 00195 mouth = mouthRight; 00196 mouthSize = KMouthSizeHorizontal; 00197 } 00198 break; 00199 00200 default: 00201 { 00202 eye1 = eyeTopLeftCorner; 00203 eye2 = eyeTopRightCorner; 00204 mouth = mouthBottom; 00205 mouthSize = KMouthSizeVertical; 00206 } 00207 break; 00208 } 00209 00210 smileyRect.SetRect( eye1, KEyeSize ); 00211 gc.DrawEllipse( smileyRect ); 00212 smileyRect.SetRect( eye2, KEyeSize ); 00213 gc.DrawEllipse( smileyRect ); 00214 smileyRect.SetRect( nose, KEyeSize ); 00215 gc.DrawEllipse( smileyRect ); 00216 smileyRect.SetRect( mouth, mouthSize ); 00217 gc.DrawEllipse( smileyRect ); 00218 }
|
|
|
From CoeControl, SizeChanged. Called by framework when the view size is changed. Definition at line 538 of file sensorexampleappview.cpp.
|
|
|
Called by CSensorExampleDataListener when channel data is received. Definition at line 225 of file sensorexampleappview.cpp. References iFaceColor. Referenced by CSensorExampleDataListener::DataReceived(). 00226 { 00227 //Alter drawing color for smiley 00228 if( KRgbRed == iFaceColor ) 00229 { 00230 iFaceColor = KRgbBlue; 00231 } 00232 else 00233 { 00234 iFaceColor = KRgbRed; 00235 } 00236 00237 DrawNow(); 00238 }
|
|
|
Show channel query dialog.
Definition at line 271 of file sensorexampleappview.cpp. Referenced by CSensorExampleAppUi::HandleQueryL(). 00272 { 00273 TInt selectedIndex( 0 ); 00274 CAknListQueryDialog* dialog = new (ELeave) CAknListQueryDialog ( &selectedIndex ); 00275 dialog->PrepareLC( R_SENSOREXAMPLE_DIALOG_CHANNELTYPEID_QUERY ); 00276 CDesCArrayFlat* itemList = new ( ELeave ) CDesCArrayFlat( aChannelList.Count() ); 00277 CleanupStack::PushL( itemList ); 00278 00279 for( TInt i=0; i<aChannelList.Count(); i++ ) 00280 { 00281 switch( aChannelList[i].iChannelType ) 00282 { 00283 case KSensrvChannelTypeIdAccelerometerDoubleTappingData: 00284 { 00285 itemList->AppendL( iCoeEnv->AllocReadResourceLC( R_SE_DOUBLETAPCHANNEL )->Des() ); 00286 CleanupStack::PopAndDestroy();//R_SE_DOUBLETAPCHANNEL 00287 } 00288 break; 00289 00290 case KSensrvChannelTypeIdAccelerometerXYZAxisData: 00291 { 00292 itemList->AppendL( iCoeEnv->AllocReadResourceLC( R_SE_ACCELEROMETERCHANNEL )->Des() ); 00293 CleanupStack::PopAndDestroy();//R_SE_ACCELEROMETERCHANNEL 00294 } 00295 break; 00296 00297 case KSensrvChannelTypeIdOrientationData: 00298 { 00299 itemList->AppendL( iCoeEnv->AllocReadResourceLC( R_SE_ORIENTATIONCHANNEL )->Des() ); 00300 CleanupStack::PopAndDestroy();//R_SE_ORIENTATIONCHANNEL 00301 } 00302 break; 00303 00304 case KSensrvChannelTypeIdRotationData: 00305 { 00306 itemList->AppendL( iCoeEnv->AllocReadResourceLC( R_SE_ROTATIONCHANNEL )->Des() ); 00307 CleanupStack::PopAndDestroy();//R_SE_ROTATIONCHANNEL 00308 } 00309 break; 00310 00311 default: 00312 { 00313 //Only number is printed for the rest of the channels. 00314 TBuf<KItemBufferSize> item; 00315 item.Append( KHexPrefix ); 00316 item.AppendNum( aChannelList[i].iChannelType, EHex ); 00317 itemList->AppendL( item ); 00318 } 00319 break; 00320 } 00321 } 00322 00323 dialog->SetOwnershipType( ELbmOwnsItemArray ); 00324 dialog->SetItemTextArray( itemList ); 00325 00326 CleanupStack::Pop( itemList ); 00327 00328 TInt result = dialog->RunLD(); 00329 00330 if( result == -2 ) 00331 { 00332 // Ok was pressed 00333 } 00334 else 00335 { 00336 // Cancel was pressed 00337 selectedIndex = KErrCancel; 00338 } 00339 00340 return selectedIndex; 00341 }
|
|
|
Show property query dialog
Definition at line 347 of file sensorexampleappview.cpp. 00348 { 00349 TInt selectedIndex( 0 ); 00350 CAknListQueryDialog* dialog = new (ELeave) CAknListQueryDialog ( &selectedIndex ); 00351 dialog->PrepareLC( R_SENSOREXAMPLE_DIALOG_CHANNELPROPERTY_QUERY ); 00352 CDesCArrayFlat* itemList = new ( ELeave ) CDesCArrayFlat( aChannelPropertyList.Count() ); 00353 CleanupStack::PushL( itemList ); 00354 00355 for( TInt i=0; i<aChannelPropertyList.Count(); i++ ) 00356 { 00357 TBuf<KItemBufferSize> property; 00358 00359 GetPropertyStringL( aChannelPropertyList[i].GetPropertyId(), 00360 aChannelPropertyList[i].PropertyItemIndex(), 00361 property ); 00362 00363 if( ESensrvArrayPropertyInfo == aChannelPropertyList[i].GetArrayIndex() ) 00364 { 00365 //Append suffix for array properties 00366 property.Append( iCoeEnv->AllocReadResourceLC( R_SE_ARRAYSUFFIX )->Des() ); 00367 CleanupStack::PopAndDestroy();//R_SE_ARRAYSUFFIX 00368 } 00369 else if( aChannelPropertyList[i].GetArrayIndex() >= 0 ) 00370 { 00371 //Append array index 00372 TBuf<KItemBufferSize> buff; 00373 _LIT( KArrayIndex, " (%d)"); 00374 buff.Format( KArrayIndex, aChannelPropertyList[i].GetArrayIndex() ); 00375 property.Append( buff ); 00376 } 00377 00378 itemList->AppendL( property ); 00379 } 00380 00381 dialog->SetOwnershipType( ELbmOwnsItemArray ); 00382 dialog->SetItemTextArray( itemList ); 00383 00384 CleanupStack::Pop( itemList ); 00385 00386 TInt result = dialog->RunLD(); 00387 00388 if( result == -2 ) 00389 { 00390 // Ok was pressed 00391 } 00392 else 00393 { 00394 // Cancel was pressed 00395 selectedIndex = KErrCancel; 00396 } 00397 00398 return selectedIndex; 00399 }
|
|
||||||||||||||||
|
Return name of a property
Definition at line 405 of file sensorexampleappview.cpp. 00408 { 00409 switch( aPropertyId ) 00410 { 00411 case KSensrvPropIdDataRate://0x00000002 00412 { 00413 aPropertyBuf.Append( iCoeEnv->AllocReadResourceLC( R_SE_DATARATE )->Des() ); 00414 CleanupStack::PopAndDestroy();//R_SE_DATARATE 00415 } 00416 break; 00417 00418 case KSensrvPropIdAvailability://0x00000004 00419 { 00420 aPropertyBuf.Append( iCoeEnv->AllocReadResourceLC( R_SE_AVAILABILITY )->Des() ); 00421 CleanupStack::PopAndDestroy();//R_SE_AVAILABILITY 00422 } 00423 break; 00424 00425 case KSensrvPropIdMeasureRange:// 0x00000005 00426 { 00427 aPropertyBuf.Append( iCoeEnv->AllocReadResourceLC( R_SE_MEASURERANGE )->Des() ); 00428 CleanupStack::PopAndDestroy();//R_SE_MEASURERANGE 00429 } 00430 break; 00431 00432 case KSensrvPropIdChannelDataFormat://0x000000006 00433 { 00434 aPropertyBuf.Append( iCoeEnv->AllocReadResourceLC( R_SE_DATAFORMAT )->Des() ); 00435 CleanupStack::PopAndDestroy();//R_SE_DATAFORMAT 00436 } 00437 break; 00438 00439 case KSensrvPropIdScaledRange://0x000000007 00440 { 00441 aPropertyBuf.Append( iCoeEnv->AllocReadResourceLC( R_SE_SCALEDRANGE )->Des() ); 00442 CleanupStack::PopAndDestroy();//R_SE_SCALEDRANGE 00443 } 00444 break; 00445 00446 case KSensrvPropIdChannelAccuracy://0x000000008 00447 { 00448 aPropertyBuf.Append( iCoeEnv->AllocReadResourceLC( R_SE_ACCURACY )->Des() ); 00449 CleanupStack::PopAndDestroy();//R_SE_ACCURACY 00450 } 00451 break; 00452 00453 case KSensrvPropIdChannelScale://0x000000009; 00454 { 00455 aPropertyBuf.Append( iCoeEnv->AllocReadResourceLC( R_SE_SCALE )->Des() ); 00456 CleanupStack::PopAndDestroy();//R_SE_SCALE 00457 } 00458 break; 00459 00460 case KSensrvPropIdChannelUnit://0x0000000010 00461 { 00462 aPropertyBuf.Append( iCoeEnv->AllocReadResourceLC( R_SE_UNIT )->Des() ); 00463 CleanupStack::PopAndDestroy();//R_SE_UNIT 00464 } 00465 break; 00466 00467 case KSensrvSensorModel://0x0000000011 00468 { 00469 aPropertyBuf.Append( iCoeEnv->AllocReadResourceLC( R_SE_MODEL )->Des() ); 00470 CleanupStack::PopAndDestroy();//R_SE_MODEL 00471 } 00472 break; 00473 00474 case KSensrvSensorConnectionType://0x0000000012 00475 { 00476 aPropertyBuf.Append( iCoeEnv->AllocReadResourceLC( R_SE_CONNECTIONTYPE )->Des() ); 00477 CleanupStack::PopAndDestroy();//R_SE_CONNECTIONTYPE 00478 } 00479 break; 00480 00481 case KSensrvSensorDescription://0x0000000013 00482 { 00483 aPropertyBuf.Append( iCoeEnv->AllocReadResourceLC( R_SE_DESCRIPTION )->Des() ); 00484 CleanupStack::PopAndDestroy();//R_SE_DESCRIPTION 00485 } 00486 break; 00487 00488 case KSensrvPropIdAxisActive://0x00010001 00489 { 00490 if( TSensrvAccelerometerAxisData::EAxisX == aItemIndex ) 00491 { 00492 aPropertyBuf.Append( iCoeEnv->AllocReadResourceLC( R_SE_XAXISACTIVE )->Des() ); 00493 CleanupStack::PopAndDestroy();//R_SE_XAXISACTIVE 00494 } 00495 else if( TSensrvAccelerometerAxisData::EAxisY == aItemIndex ) 00496 { 00497 aPropertyBuf.Append( iCoeEnv->AllocReadResourceLC( R_SE_YAXISACTIVE )->Des() ); 00498 CleanupStack::PopAndDestroy();//R_SE_YAXISACTIVE 00499 } 00500 else if( TSensrvAccelerometerAxisData::EAxisZ == aItemIndex ) 00501 { 00502 aPropertyBuf.Append( iCoeEnv->AllocReadResourceLC( R_SE_ZAXISACTIVE )->Des() ); 00503 CleanupStack::PopAndDestroy();//R_SE_ZAXISACTIVE 00504 } 00505 } 00506 break; 00507 00508 case KSensrvPropIdDblTapLatency://0x00010004 00509 { 00510 aPropertyBuf.Append( iCoeEnv->AllocReadResourceLC( R_SE_DOUBLETAPLATENCY )->Des() ); 00511 CleanupStack::PopAndDestroy();//R_SE_DOUBLETAPLATENCY 00512 } 00513 break; 00514 00515 case KSensrvPropIdDblTapInterval://0x00010005 00516 { 00517 aPropertyBuf.Append( iCoeEnv->AllocReadResourceLC( R_SE_DOUBLETAPINTERVAL )->Des() ); 00518 CleanupStack::PopAndDestroy();//R_SE_DOUBLETAPINTERVAL 00519 } 00520 break; 00521 00522 default: 00523 { 00524 //Only number is printed for the rest of the properties. 00525 aPropertyBuf.Append( KHexPrefix ); 00526 aPropertyBuf.AppendNumUC( aPropertyId, EHex ); 00527 } 00528 break; 00529 } 00530 00531 }
|
|
|
ConstructL 2nd phase constructor. Perform the second phase construction of a CSensorExampleAppView object.
Definition at line 69 of file sensorexampleappview.cpp. References iFont. Referenced by NewLC(). 00070 { 00071 // Create a window for this application view 00072 CreateWindowL(); 00073 00074 // set the font 00075 iFont = AknLayoutUtils::FontFromId(EAknLogicalFontPrimaryFont); 00076 00077 // Set the windows size 00078 SetRect( aRect ); 00079 00080 // Activate the window, which makes it ready to be drawn 00081 ActivateL(); 00082 }
|
|
|
font used, when printing user-given text to the screen Definition at line 132 of file sensorexampleappview.h. Referenced by ConstructL(). |
|
|
Latest sensor data Definition at line 137 of file sensorexampleappview.h. Referenced by Draw(), and OrientationEvent(). |
|
© Nokia 2009 |