|
S60 3rd Edition SDK for Symbian OS Example Applications Guide |
#include <Bitmapinst.h>
Public Member Functions | |
| ~CBitmapInst () | |
| NPError | PluginNew (NPMIMEType aPluginType, NPP aInstance, uint16 aMode, CDesC16Array *aArgn, CDesC16Array *aArgv, NPSavedData *aSaved) |
| NPError | PluginDestroy (NPSavedData **aSave) |
| NPError | PluginSetWindowL (NPWindow *aWindow) |
| NPError | PluginSetValue (NPNVariable aVariable, void *aValue) |
| NPError | PluginNewStream (NPMIMEType aType, NPStream *aStream, NPBool aSeekable, uint16 *aStype) |
| NPError | PluginDestroyStream (NPStream *aStream, NPReason aReason) |
| void | PluginStreamAsFile (NPStream *aStream, const TDesC16 &aFileName) |
| int32 | PluginWrite (NPStream *aStream, int32 aOffset, int32 aLength, void *aBuffer) |
| int32 | PluginWriteReady (NPStream *aStream) |
| void | PluginURLNotify (const TDesC16 &aUrl, NPReason aReason, void *aNotifyData) |
| TInt | NotifyL (TNotificationType aCallType, TAny *aParam) |
| TCoeInputCapabilities | InputCapabilities (void) const |
| TKeyResponse | OfferKeyEventL (const TKeyEvent &aKeyEvent, TEventCode aType) |
| void | HandleControlEventL (CCoeControl *aControl, TCoeEvent aEventType) |
| void | HandlePointerEventL (const TPointerEvent &aPointerEvent) |
| void | FocusChanged (TDrawNow aDrawNow) |
| void | SizeChanged (void) |
Static Public Member Functions | |
| static CBitmapInst * | NewL (NPP aNpp) |
Private Member Functions | |
| CBitmapInst (NPP aNpp) | |
| void | Construct () |
| void | Draw (const TRect &aRect) const |
| NPError | HandleGet (void) |
Private Attributes | |
| NPStream * | iStream |
| TInt | iWriteReady |
| TUint16 * | iSourceUrl |
| NPP | iNpp |
| TBool | iFirstTime |
| TBool | iFlipBitmap |
| HBufC * | iFileName |
| TInt | iNumDownload |
Definition at line 34 of file Bitmapinst.h.
|
|
Destructor Definition at line 75 of file Bitmapecominst.cpp. References iFileName, and iSourceUrl. 00076 { 00077 if ( iFileName ) 00078 { 00079 delete iFileName; 00080 iFileName = NULL; 00081 } 00082 CBitmapEcomMain* npm = ( CBitmapEcomMain* ) Dll :: Tls(); 00083 delete iSourceUrl; 00084 }
|
|
|
Constructor Definition at line 53 of file Bitmapecominst.cpp. References iFirstTime, iFlipBitmap, iNumDownload, iSourceUrl, and iWriteReady. 00053 : CCoeControl(), iNpp( aNpp ) 00054 { 00055 iWriteReady = 100; 00056 iSourceUrl = NULL; 00057 iFirstTime = ETrue; 00058 iFlipBitmap = EFalse; 00059 iNumDownload = 0; 00060 }
|
|
|
Two phase construction.
Definition at line 40 of file Bitmapecominst.cpp. References CBitmapInst(). 00041 { 00042 CBitmapInst* self = new ( ELeave ) CBitmapInst( aNpp ); 00043 CleanupStack :: PushL( self ); 00044 self->Construct(); 00045 CleanupStack :: Pop(); 00046 return self; 00047 }
|
|
||||||||||||||||||||||||||||
|
This function creates a new instance of the plug-in.
Definition at line 98 of file Bitmapecominst.cpp. References HandleGet(), and iSourceUrl. 00105 { 00106 if ( aInstance->pdata != this ) 00107 { 00108 return NPERR_INVALID_INSTANCE_ERROR; 00109 } 00110 00111 // Traverse the attribute list to find the Url from which to retrieve data 00112 for ( TInt i = 0; i < aArgn->Count(); i++ ) 00113 { 00114 TPtrC16 namePtr( (*aArgn)[i] ); 00115 TPtrC16 valPtr( (*aArgv)[i] ); 00116 00117 if ( ( KSourceUrl().FindF( namePtr ) == 0 ) ) 00118 { 00119 iSourceUrl = new TUint16[valPtr.Length() + 1]; 00120 if ( iSourceUrl == NULL ) 00121 { 00122 return NPERR_OUT_OF_MEMORY_ERROR; 00123 } 00124 TPtr16 ptr( iSourceUrl, 0, valPtr.Length() + 1 ); 00125 ptr.Copy( valPtr ); 00126 ptr.ZeroTerminate(); 00127 break; 00128 } 00129 } 00130 return HandleGet(); 00131 }
|
|
|
This function deletes a plug-in instance.
Definition at line 140 of file Bitmapecominst.cpp.
|
|
|
This function sets the parent and the coordinates for the plug-in. It makes a call to the ExtractParentControlAndApiL API to extract the platform dependent window.The first time PluginSetWindowL() is called, it is important to construct the corresponding plug-in control. The other times this call is made, it is expected that the function simply updates the bounds of the control.
Definition at line 158 of file Bitmapecominst.cpp. References iFirstTime. 00159 { 00160 MPluginAdapterPTR pPluginAdapter( NULL ); 00161 pPluginAdapter = static_cast<MPluginAdapter*>( aWindow->window ); 00162 CCoeControl* pParentControl = pPluginAdapter->GetParentControl(); 00163 00164 if ( !pParentControl ) 00165 return NPERR_NO_ERROR; 00166 00167 if ( iFirstTime ) 00168 { 00169 CreateWindowL( pParentControl ); 00170 pPluginAdapter->SetPluginNotifier( this ); 00171 pPluginAdapter->PluginConstructedL( this ); 00172 } 00173 00174 TPoint point( aWindow->x, aWindow->y ); 00175 TSize size( aWindow->width, aWindow->height ); 00176 SetExtent( point, size ); 00177 00178 if ( iFirstTime ) 00179 { 00180 ActivateL(); 00181 iFirstTime = EFalse; 00182 } 00183 00184 return NPERR_NO_ERROR; 00185 }
|
|
||||||||||||
|
This function has an empty implementation here, but the actual purpose of the function is to set values for the plugin variables.
Definition at line 196 of file Bitmapecominst.cpp.
|
|
||||||||||||||||||||
|
This function notifies a plug-in instance of a new data stream.
Definition at line 217 of file Bitmapecominst.cpp. References iStream. 00222 { 00223 *aStype = NP_ASFILE; 00224 iStream = aStream; 00225 iStream->pdata = this; 00226 return NPERR_NO_ERROR; 00227 }
|
|
||||||||||||
|
This function destroys the stream that was previously created to stream data to the plug-in.
Definition at line 244 of file Bitmapecominst.cpp.
|
|
||||||||||||
|
This function passes a file name to the plug-in in which the stream data is stored.
Definition at line 259 of file Bitmapecominst.cpp. References iFileName, iNumDownload, and iStream. 00262 { 00263 if ( ( aStream->pdata != this ) || ( aStream != iStream ) 00264 || ( iNumDownload > 0 ) ) 00265 { 00266 return; 00267 } 00268 iFileName = aFileName.Alloc(); 00269 iNumDownload ++; 00270 }
|
|
||||||||||||||||||||
|
This function writes a chunk of data to the plug-in.
Definition at line 282 of file Bitmapecominst.cpp. References iStream. 00287 { 00288 if ( aStream->pdata != this || aStream != iStream ) 00289 { 00290 return 0; 00291 } 00292 00293 return aLength; 00294 }
|
|
|
The browser calls the NPP_Write function with the amount of data returned from the NPP_WriteReady function.
Definition at line 304 of file Bitmapecominst.cpp. References iWriteReady. 00305 { 00306 return iWriteReady; 00307 }
|
|
||||||||||||||||
|
The browser calls the NPP_URLNotify function to notify the plug-in of the completion of a URL request made by the NPN_GetURLNotify function or the NPN_PostURLNotify function.
Definition at line 321 of file Bitmapecominst.cpp.
|
|
||||||||||||
|
This function implements the NotifyL() function of the MPluginNotifier interface. It notifies the plug-in of an event.
Definition at line 386 of file Bitmapecominst.cpp. References iFlipBitmap. 00387 { 00388 switch ( aCallType ) 00389 { 00390 case EApplicationFocusChanged: 00391 { 00392 if ( iFlipBitmap ) 00393 { 00394 iFlipBitmap = EFalse; 00395 } 00396 else 00397 { 00398 iFlipBitmap = ETrue; 00399 } 00400 DrawNow(); 00401 break; 00402 } 00403 default: 00404 break; 00405 } 00406 return 0; 00407 }
|
|
|
Returns the supported input capabilities which correspond to the behaviour of the OfferKeyEventL() function of the control;
Definition at line 417 of file Bitmapecominst.cpp.
|
|
||||||||||||
|
This function handles key events. when 'Enter' key or 'OK' key is pressed, the bitmap rendered is flipped from redflower to blueflower and viceversa.
Definition at line 433 of file Bitmapecominst.cpp. References iFlipBitmap. 00436 { 00437 if ( aType == EEventKeyUp ) 00438 { 00439 switch ( aKeyEvent.iScanCode ) 00440 { 00441 case EStdKeyEnter: 00442 case EStdKeyDevice3: 00443 { 00444 if ( iFlipBitmap ) 00445 { 00446 iFlipBitmap = EFalse; 00447 } 00448 else 00449 { 00450 iFlipBitmap = ETrue; 00451 } 00452 DrawNow(); 00453 return EKeyWasConsumed; 00454 } 00455 default: 00456 return EKeyWasNotConsumed; 00457 } 00458 } 00459 return EKeyWasNotConsumed; 00460 }
|
|
||||||||||||
|
This function inherited from MCoeControlObserver handles an event from an observed control.
Definition at line 470 of file Bitmapecominst.cpp. References iNpp. 00473 { 00474 if ( aControl != (( MPluginAdapter* ) ( iNpp->ndata ))->GetParentControl() ) 00475 { 00476 return; 00477 } 00478 00479 switch ( aEventType ) 00480 { 00481 case EEventRequestFocus: 00482 default: 00483 break; 00484 } 00485 }
|
|
|
This function handles pointer events. On clicking the left mouse button, the bitmap rendered is flipped from redflower to blueflower and viceversa.
Definition at line 494 of file Bitmapecominst.cpp. References iFlipBitmap. 00495 { 00496 switch ( aPointerEvent.iType ) 00497 { 00498 case TPointerEvent::EButton1Down: 00499 { 00500 if ( iFlipBitmap ) 00501 { 00502 iFlipBitmap = EFalse; 00503 } 00504 else 00505 { 00506 iFlipBitmap = ETrue; 00507 } 00508 DrawNow(); 00509 break; 00510 } 00511 default: 00512 break; 00513 } 00514 }
|
|
|
This function is called whenever a control gains or loses focus - as a result of a call to SetFocus().
Definition at line 523 of file Bitmapecominst.cpp.
|
|
|
This function which responds to size changes to set the size and position of the contents of the control does nothing and has an empty implementation.
Definition at line 533 of file Bitmapecominst.cpp.
|
|
|
second phase constructor Definition at line 66 of file Bitmapecominst.cpp.
|
|
|
This function draws the control. When iFlipBitmap is true it renders one bitmap, and when iFlipBitmap is false it renders another one.
Definition at line 337 of file Bitmapecominst.cpp. References iFileName, and iFlipBitmap. 00338 { 00339 TInt ret( KErrNone ); 00340 CFbsBitmap* bitmap = NULL; 00341 00342 bitmap = new CFbsBitmap(); 00343 if ( !bitmap ) 00344 { 00345 return; 00346 } 00347 00348 if ( iFileName ) 00349 { 00350 if( iFlipBitmap ) 00351 { 00352 ret = bitmap->Load( iFileName->Des(), EMbmAllbitmapsRedflower, ETrue ); 00353 } 00354 else 00355 { 00356 ret = bitmap->Load( iFileName->Des(), EMbmAllbitmapsBlueflower, ETrue ); 00357 } 00358 } 00359 if ( ret != KErrNone ) 00360 { 00361 delete ( bitmap ); 00362 bitmap = NULL; 00363 return; 00364 } 00365 00366 SystemGc().Clear(); 00367 SystemGc().DrawBitmap( aRect, bitmap ); 00368 delete ( bitmap ); 00369 bitmap = NULL; 00370 }
|
|
|
This function calls the NPN_GetURL function to ask the browser to deliver the data to the plug-in instance in a new stream.
Definition at line 546 of file Bitmapecominst.cpp. References CBitmapEcomMain::Funcs(), iNpp, and iSourceUrl. 00547 { 00548 CBitmapEcomMain* npm = ( CBitmapEcomMain* ) Dll :: Tls(); 00549 TPtrC url; 00550 00551 if ( iSourceUrl ) // iSourceUrl is non-null 00552 { 00553 url.Set( iSourceUrl ); 00554 return ( npm->Funcs()->geturl( iNpp, url, NULL ) ); 00555 } 00556 else 00557 { 00558 return NPERR_GENERIC_ERROR; 00559 } 00560 }
|
|
© Nokia 2006 |