Nokia N97 SDK
Example Applications Guide

COpenCHelloGlibEventExUi Class Reference

#include <openchelloglibeventexui.h>

Inheritance diagram for COpenCHelloGlibEventExUi:

List of all members.

Detailed Description

COpenCHelloGlibEventExUi application UI class. Interacts with the user through the UI and request message processing from the handler class

Definition at line 35 of file openchelloglibeventexui.h.


Public Member Functions

void  ConstructL ()
  COpenCHelloGlibEventExUi ()
virtual  ~COpenCHelloGlibEventExUi ()

Private Member Functions

void  HandleCommandL (TInt aCommand)
void  HandleStatusPaneSizeChange ()

Private Attributes

COpenCHelloGlibEventExView *  iAppView
GMainContext *  iMainContext
GSource *  iTimeoutSource
COpenCHelloGlibEventExHandler *  iGlibEventHandler


Constructor & Destructor Documentation

COpenCHelloGlibEventExUi::COpenCHelloGlibEventExUi (   ) 
 

COpenCHelloGlibEventExUi. C++ default constructor. This needs to be public due to the way the framework constructs the AppUi

Definition at line 128 of file openchelloglibeventexui.cpp.

00129     {
00130     // No implementation required
00131     }

COpenCHelloGlibEventExUi::~COpenCHelloGlibEventExUi (   )  [virtual]
 

~COpenCHelloGlibEventExUi. Virtual Destructor.

Definition at line 138 of file openchelloglibeventexui.cpp.

References iAppView, iGlibEventHandler, iMainContext, iTimeoutSource, and COpenCHelloGlibEventExHandler::Stop().

00139     {
00140     // Stop and delete the event handler active object
00141     // NOTE: This needs to be done for all event handlers created
00142     iGlibEventHandler->Stop();
00143     delete iGlibEventHandler;
00144    
00145         // unref the Timeout source
00146         g_source_unref(iTimeoutSource);
00147         
00148         // unref the GMainContext
00149         // NOTE: This is not required for the "default" context
00150     g_main_context_unref(iMainContext);
00151     
00152     if ( iAppView )
00153         {
00154         delete iAppView;
00155         iAppView = NULL;
00156         }
00157 
00158     }


Member Function Documentation

void COpenCHelloGlibEventExUi::ConstructL (   ) 
 

ConstructL. 2nd phase constructor.

Definition at line 65 of file openchelloglibeventexui.cpp.

References iAppView, iGlibEventHandler, iMainContext, iTimeoutSource, COpenCHelloGlibEventExHandler::NewL(), COpenCHelloGlibEventExView::NewL(), and COpenCHelloGlibEventExHandler::Start().

00066     {
00067     // Initialise app UI with standard value.
00068     BaseConstructL(CAknAppUi::EAknEnableSkin);
00069 
00070     // Create view object
00071     iAppView = COpenCHelloGlibEventExView::NewL( ClientRect() );
00072         
00073         // required for preventing Alloc Panics in Debug builds
00074         setenv("G_SLICE", "always-malloc", 1);
00075         
00076         // In the Glib event loop paradigm, events can come from any number of 
00077         // different types of sources.
00078         // To allow multiple independent sets of sources to be handled in different 
00079         // threads, each source is associated with a GMainContext. A GMainContext 
00080         // can only be running in a single thread.
00081         // In this example, we create a new GMainContext in which the timeout 
00082         // source will be added.
00083         // NOTE: This is NOT required if the event sources are to be added to the 
00084         // "default" context.
00085     iMainContext = g_main_context_new();
00086         
00087         // An event source is represented by the GSource structure, and new
00088         // source types are created by "deriving" from the GSource structure.
00089         // In this example, we create an instance of timeout source, 
00090         // with the timout value of 1000 milliseconds.
00091         // The newly created GSource is intially not attached to any GMainContext
00092         iTimeoutSource = g_timeout_source_new(1000);
00093         
00094         // Associate a callback function with the timeout source
00095         // The iAppView pointer is being passed to glib here, so that the 
00096         // callback function gets called with the iAppView pointer as the argument
00097         g_source_set_callback(iTimeoutSource, timeout_cb, iAppView, NULL);
00098         
00099         // add the timeout source to the GMainContext
00100         // NOTE: Pass NULL instead of iMainContext to attach the source to the 
00101         // "default" context
00102         g_source_attach(iTimeoutSource, iMainContext);
00103         
00104         // Create an instance of the event handler active object, for handling
00105         // event sources of the given GMainContext
00106         // The event handler active object adds itself to the current 
00107         // installed active scheduler (created by the Symbian UI framework)
00108         // NOTE 1: Create one instance of event handler each for each of the 
00109         // GMainContexts in the application.
00110         // NOTE 2: Pass NULL as the argument to create an event handler for the 
00111         // "default" context
00112         iGlibEventHandler = COpenCHelloGlibEventExHandler::NewL(iMainContext);
00113         
00114         // Start the event handler active object
00115         // NOTE: This needs to be done for all event handlers created
00116         // Once started, the event handler active object schedules itself based
00117         // on the Symbian RTimer service. It runs one non-blocking iteration
00118         // of the event loop for the given GMainContext, each time it gets
00119         // scheduled.
00120         iGlibEventHandler->Start();
00121     }

void COpenCHelloGlibEventExUi::HandleCommandL (  TInt  aCommand  )  [private]
 

From CEikAppUi, HandleCommandL. Takes care of command handling.

Parameters:
aCommand  Command to be handled.

Definition at line 165 of file openchelloglibeventexui.cpp.

00166     {
00167     switch( aCommand )
00168         {
00169         case EEikCmdExit:
00170         case EAknSoftkeyExit:
00171             Exit();
00172             break;
00173 
00174         case EOpenCHelloGlibEventExCommand1:
00175             {
00176             
00177             // Load a string from the resource file and display it
00178             HBufC* textResource = StringLoader::LoadLC( R_OCHG_COMMAND1_TEXT );
00179             CAknInformationNote* informationNote;
00180 
00181             informationNote = new ( ELeave ) CAknInformationNote;
00182 
00183             // Show the information Note with
00184             // textResource loaded with StringLoader.
00185             informationNote->ExecuteLD( *textResource);
00186 
00187             // Pop HBuf from CleanUpStack and Destroy it.
00188             CleanupStack::PopAndDestroy( textResource );
00189             }
00190             break;
00191         default:
00192             break;
00193         }
00194     }

void COpenCHelloGlibEventExUi::HandleStatusPaneSizeChange (   )  [private]
 

HandleStatusPaneSizeChange. Called by the framework when the application status pane size is changed.

Definition at line 202 of file openchelloglibeventexui.cpp.

References iAppView.

00203         {
00204         iAppView->SetRect( ClientRect() );
00205         
00206         } 


Member Data Documentation

COpenCHelloGlibEventExView* COpenCHelloGlibEventExUi::iAppView [private]
 

The application view Owned by CHelloWorldBasicAppUi

Definition at line 81 of file openchelloglibeventexui.h.

Referenced by ConstructL(), HandleStatusPaneSizeChange(), and ~COpenCHelloGlibEventExUi().

GMainContext* COpenCHelloGlibEventExUi::iMainContext [private]
 

GMainContext to add the Timeout Source

Definition at line 86 of file openchelloglibeventexui.h.

Referenced by ConstructL(), and ~COpenCHelloGlibEventExUi().

GSource* COpenCHelloGlibEventExUi::iTimeoutSource [private]
 

Glib Timeout Source

Definition at line 91 of file openchelloglibeventexui.h.

Referenced by ConstructL(), and ~COpenCHelloGlibEventExUi().

COpenCHelloGlibEventExHandler* COpenCHelloGlibEventExUi::iGlibEventHandler [private]
 

Event Handler Active Object

Definition at line 96 of file openchelloglibeventexui.h.

Referenced by ConstructL(), and ~COpenCHelloGlibEventExUi().


The documentation for this class was generated from the following files:

© Nokia 2009

Back to top