|
Nokia N97 SDK Example Applications Guide |
#include <guiengineappview.h>
Inheritance diagram for CGuiEngineAppView:

Definition at line 43 of file guiengineappview.h.
Public Types |
|
| enum | TBrushShapeType { ECircle = 0, ERectangle } |
Public Member Functions |
|
| virtual | ~CGuiEngineAppView () |
| void | Clear () |
| void | SetBrushShapeType (TBrushShapeType aBrushShapeType) |
| TBrushShapeType | BrushShapeType () const |
| void | ExternalizeL (RWriteStream &aStream) const |
| void | InternalizeL (RReadStream &aStream) |
| void | Draw (const TRect &aRect) const |
| TKeyResponse | OfferKeyEventL (const TKeyEvent &aKeyEvent, TEventCode aType) |
| void | HandleResourceChange (TInt aType) |
Static Public Member Functions |
|
| static CGuiEngineAppView * | NewL (const TRect &aRect, CGuiEngineDocument *aDocument) |
| static CGuiEngineAppView * | NewLC (const TRect &aRect, CGuiEngineDocument *aDocument) |
Private Member Functions |
|
| CGuiEngineAppView (CGuiEngineDocument *aDocument) | |
| void | ConstructL (const TRect &aRect) |
Private Attributes |
|
| CGuiEngineDocument * | iDocument |
| TBrushShapeType | iBrushShapeType |
| TPoint | iPosition |
|
|
TBrushShapeType The shape type to be drawn
Definition at line 54 of file guiengineappview.h.
|
|
|
~CGuiEngineAppView. Virtual Destructor. Definition at line 95 of file guiengineappview.cpp. References iDocument. 00096 { 00097 iDocument = NULL; // Not the owner 00098 }
|
|
|
CGuiEngineAppView. C++ default constructor.
Definition at line 38 of file guiengineappview.cpp. Referenced by NewLC(). 00039 : iDocument(aDocument), iPosition ( 10, 10 ) 00040 { 00041 // No implementation required 00042 }
|
|
||||||||||||
|
NewL. Two-phased constructor. Create a CGuiEngineAppView object, which will draw itself to aRect
Definition at line 49 of file guiengineappview.cpp. References NewLC(). Referenced by CGuiEngineAppUi::ConstructL(). 00051 { 00052 CGuiEngineAppView* self = NewLC( aRect, aDocument ); 00053 CleanupStack::Pop( self ); 00054 return self; 00055 }
|
|
||||||||||||
|
NewLC Two-phased constructor. Create a CGuiEngineAppView object, which will draw itself to aRect
Definition at line 62 of file guiengineappview.cpp. References CGuiEngineAppView(). Referenced by NewL(). 00064 { 00065 CGuiEngineAppView* self = new ( ELeave ) CGuiEngineAppView( aDocument ); 00066 CleanupStack::PushL( self ); 00067 self->ConstructL( aRect ); 00068 return self; 00069 }
|
|
|
Clear Clear the view / model Definition at line 142 of file guiengineappview.cpp. References CShapeListManager::Clear(), iDocument, and CGuiEngineDocument::Model(). Referenced by CGuiEngineAppUi::HandleCommandL().
|
|
|
SetBrushShapeType Set the type of shape that will be added to the list
Definition at line 153 of file guiengineappview.cpp. References iBrushShapeType. Referenced by CGuiEngineAppUi::HandleCommandL(). 00154 { 00155 iBrushShapeType = aShapeType; 00156 }
|
|
|
BrushShapeType Get the type of shape that will be added to the list
Definition at line 163 of file guiengineappview.cpp. References iBrushShapeType. 00164 { 00165 return iBrushShapeType; 00166 }
|
|
|
ExternalizeL Save the view settings to a stream
Definition at line 173 of file guiengineappview.cpp. References iBrushShapeType. Referenced by CGuiEngineAppUi::StoreL(). 00174 { 00175 aStream.WriteInt8L( static_cast<TInt8>( iBrushShapeType ) ); 00176 }
|
|
|
InternalizeL Read the view settings from a stream
Definition at line 183 of file guiengineappview.cpp. References iBrushShapeType. Referenced by CGuiEngineAppUi::RestoreL(). 00184 { 00185 iBrushShapeType = static_cast<TBrushShapeType>( aStream.ReadInt8L() ); 00186 }
|
|
|
Draw Draw this to the screen.
Definition at line 105 of file guiengineappview.cpp. References NShapes::TShape::Draw(), CShapeListManager::GetNextShape(), iDocument, iPosition, and CGuiEngineDocument::Model(). 00106 { 00107 00108 CWindowGc& graphicsContext = SystemGc(); 00109 00110 // Clear the application view 00111 graphicsContext.Clear(); 00112 00113 // Gets the control's extent 00114 TRect rect( Rect() ); 00115 graphicsContext.DrawRect( rect ); 00116 00117 // Draw the 'cursor' crosshair, size 10 pixels by 10 pixels 00118 graphicsContext.SetPenSize( TSize( 1,1 ) ); 00119 00120 //graphicsContext.SetPenColor( RgbBlack ); 00121 graphicsContext.DrawLine ( TPoint( iPosition.iX - 10, iPosition.iY ), 00122 TPoint( iPosition.iX + 10, iPosition.iY ) ); 00123 00124 graphicsContext.DrawLine ( TPoint( iPosition.iX, iPosition.iY - 10 ), 00125 TPoint( iPosition.iX, iPosition.iY + 10 ) ); 00126 00127 00128 // Draw all the current shapes 00129 TShape* shape = iDocument->Model()->GetNextShape(); 00130 while ( shape ) 00131 { 00132 shape->Draw( graphicsContext ); 00133 shape = iDocument->Model()->GetNextShape(); 00134 } 00135 }
|
|
||||||||||||
|
OfferKeyEventL From CCoeControl, Handles key event.
Definition at line 195 of file guiengineappview.cpp. References CShapeListManager::AddShapeL(), iBrushShapeType, iDocument, iPosition, and CGuiEngineDocument::Model(). 00197 { 00198 if ( aType != EEventKey ) 00199 { 00200 return EKeyWasNotConsumed; 00201 } 00202 00203 // Move left 00204 if ( aKeyEvent.iScanCode == EStdKeyLeftArrow ) 00205 { 00206 if ( iPosition.iX > ( Rect().iTl.iX + 10 ) ) 00207 { 00208 --iPosition.iX; 00209 DrawNow(); 00210 } 00211 return EKeyWasConsumed; 00212 } 00213 00214 // Move right 00215 else if ( aKeyEvent.iScanCode == EStdKeyRightArrow ) 00216 { 00217 if ( iPosition.iX < ( Rect().iBr.iX - 10 ) ) 00218 { 00219 ++iPosition.iX; 00220 DrawNow(); 00221 } 00222 return EKeyWasConsumed; 00223 } 00224 00225 // Move up 00226 else if ( aKeyEvent.iScanCode == EStdKeyUpArrow ) 00227 { 00228 if (iPosition.iY > ( Rect().iTl.iY + 10 ) ) 00229 { 00230 --iPosition.iY; 00231 DrawNow(); 00232 } 00233 return EKeyWasConsumed; 00234 } 00235 00236 // Move down 00237 else if ( aKeyEvent.iScanCode == EStdKeyDownArrow ) 00238 { 00239 if ( iPosition.iY < ( Rect().iBr.iY - 10 ) ) 00240 { 00241 ++iPosition.iY; 00242 DrawNow(); 00243 } 00244 return EKeyWasConsumed; 00245 } 00246 00247 00248 // Place a shape 00249 else if ( aKeyEvent.iScanCode == EStdKeyDevice3 ) 00250 { 00251 00252 TShape* newShape = NULL; 00253 // Update the co-ordinates in the model to the position at which the 00254 // pointer event occurred. 00255 00256 switch ( iBrushShapeType ) 00257 { 00258 case ECircle: 00259 00260 newShape = new ( ELeave ) TCircle( iPosition, KBrushRadius ); 00261 00262 // Takes ownership 00263 iDocument->Model()->AddShapeL( newShape ); 00264 break; 00265 00266 case ERectangle: 00267 newShape = new ( ELeave ) TRectangle( iPosition, KBrushHeight, KBrushWidth ); 00268 00269 // Takes ownership 00270 iDocument->Model()->AddShapeL( newShape ); 00271 break; 00272 00273 default: 00274 User::Panic( KGuiEnginePanicName, EGuiEngineInvalidBrushType ); 00275 } 00276 00277 DrawNow(); 00278 return EKeyWasConsumed; 00279 } 00280 00281 return EKeyWasNotConsumed; 00282 }
|
|
|
HandleResourceChange From CCoeControl. Handles a change to the control's resources.
Definition at line 291 of file guiengineappview.cpp. 00292 { 00293 CCoeControl::HandleResourceChange( aType ); 00294 // ADDED FOR SCALABLE UI SUPPORT 00295 // ***************************** 00296 if ( aType==KEikDynamicLayoutVariantSwitch ) 00297 { 00298 TRect rect; 00299 AknLayoutUtils::LayoutMetricsRect(AknLayoutUtils::EMainPane, rect); 00300 SetRect(rect); 00301 } 00302 }
|
|
|
ConstructL. 2nd phase constructor.
Definition at line 76 of file guiengineappview.cpp. 00077 { 00078 // Create a window for this application view 00079 CreateWindowL(); 00080 00081 // Set the windows size 00082 SetRect( aRect ); 00083 00084 // Activate the window, which makes it ready to be drawn 00085 ActivateL(); 00086 00087 Window().SetPointerCursor( KBlackPointer ); 00088 }
|
|
|
iDocument, The current document Not owned by CGuiEngineAppView object. Definition at line 173 of file guiengineappview.h. Referenced by Clear(), Draw(), OfferKeyEventL(), and ~CGuiEngineAppView(). |
|
|
iBrushShapeType The type of shape currently selected for adding Definition at line 176 of file guiengineappview.h. Referenced by BrushShapeType(), ExternalizeL(), InternalizeL(), OfferKeyEventL(), and SetBrushShapeType(). |
|
|
iPosition The current 'cursor' position Definition at line 179 of file guiengineappview.h. Referenced by Draw(), and OfferKeyEventL(). |
|
© Nokia 2009 |