S60 5th Edition SDK
Example Applications Guide

CHelloWorldBasicAppUi Class Reference

#include <helloworldbasicappui.h>

Inheritance diagram for CHelloWorldBasicAppUi:

List of all members.

Detailed Description

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

Definition at line 32 of file helloworldbasicappui.h.

Public Member Functions

void ConstructL ()
 CHelloWorldBasicAppUi ()
virtual ~CHelloWorldBasicAppUi ()

Private Member Functions

void HandleCommandL (TInt aCommand)
void HandleResourceChangeL (TInt aType)

Private Attributes

CHelloWorldBasicAppViewiAppView


Constructor & Destructor Documentation

CHelloWorldBasicAppUi::CHelloWorldBasicAppUi  ) 
 

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

Definition at line 100 of file helloworldbasicappui.cpp.

00101     {
00102     // No implementation required
00103     }

CHelloWorldBasicAppUi::~CHelloWorldBasicAppUi  )  [virtual]
 

~CHelloWorldBasicAppUi. Virtual Destructor.

Definition at line 110 of file helloworldbasicappui.cpp.

References iAppView.

00111     {
00112     if ( iAppView )
00113         {
00114         delete iAppView;
00115         iAppView = NULL;
00116         }
00117     }


Member Function Documentation

void CHelloWorldBasicAppUi::ConstructL  ) 
 

ConstructL. 2nd phase constructor.

Definition at line 40 of file helloworldbasicappui.cpp.

References iAppView, and CHelloWorldBasicAppView::NewL().

00041     {
00042     // Initialise app UI with standard value.
00043     BaseConstructL(CAknAppUi::EAknEnableSkin);
00044 
00045     // Here the Hello.txt file is created. Because HelloWorld application is
00046     // localized to various languages, the Hello.txt-file is created every time
00047     // with current localization language
00048     //
00049     RFs fsSession;
00050     User::LeaveIfError(fsSession.Connect());
00051     CleanupClosePushL( fsSession );
00052     TInt objectsInStack = 1;
00053 
00054     #if defined(__WINS__) || defined(__WINSCW__)
00055     // create private folder, when testing in emulator.
00056     // ignore the return value; if this fails, then file.Replace() will fail
00057     // and a warning note will be printed.
00058     //
00059     fsSession.CreatePrivatePath(EDriveC);
00060     #endif
00061 
00062     RFile file;
00063 
00064     // Create a file to write the text to
00065     TInt err = file.Replace(fsSession, KHelloFileName, EFileWrite );
00066     if (KErrNone == err)
00067         {
00068         CleanupClosePushL( file );
00069 
00070         RFileWriteStream outputFileStream( file );
00071         CleanupClosePushL( outputFileStream );
00072 
00073         // Load a string from the resource file and stream it to file
00074         HBufC* textResource = StringLoader::LoadLC( R_HEWB_FILE_TEXT );
00075         objectsInStack += 3; // file, outputFileStream, testResource
00076 
00077         outputFileStream << *textResource;
00078         }
00079     else
00080         {
00081         _LIT(KFileWriteFailed,"Writing file %S failed: error %d");
00082         CAknWarningNote* note = new ( ELeave ) CAknWarningNote(ETrue);
00083 
00084         TBuf<64> text;
00085         text.Format(KFileWriteFailed, &KHelloFileName, err);
00086         note->ExecuteLD( text );
00087         }
00088 
00089     CleanupStack::PopAndDestroy(objectsInStack, &fsSession);
00090 
00091     // Create view object
00092     iAppView = CHelloWorldBasicAppView::NewL( ClientRect() );
00093 
00094     }

void CHelloWorldBasicAppUi::HandleCommandL TInt  aCommand  )  [private]
 

From CEikAppUi, HandleCommandL. Takes care of command handling.

Parameters:
aCommand Command to be handled.

Definition at line 124 of file helloworldbasicappui.cpp.

References CHelloWorldBasicAppView::GetText(), and iAppView.

00125     {
00126     // clear possible old user-given text
00127     if (iAppView->GetText().Size() > 0)
00128         {
00129         iAppView->GetText().Zero();
00130         iAppView->DrawNow();
00131         }
00132 
00133     switch( aCommand )
00134         {
00135         case EEikCmdExit:
00136         case EAknSoftkeyExit:
00137             Exit();
00138             break;
00139 
00140         case EHelloWorldBasicCommand1:
00141             {
00142             // Load a string from the resource file and display it
00143             HBufC* textResource = StringLoader::LoadLC( R_HEWB_COMMAND1_TEXT );
00144             CAknInformationNote* note = new ( ELeave ) CAknInformationNote;
00145 
00146             // Show the information Note with
00147             // textResource loaded with StringLoader.
00148             note->ExecuteLD( *textResource );
00149 
00150             // Pop HBuf from CleanUpStack and Destroy it.
00151             CleanupStack::PopAndDestroy( textResource );
00152             }
00153             break;
00154 
00155         case EHelloWorldBasicCommand2:
00156             {
00157             RFs fsSession;
00158             RFile rFile;
00159 
00160             // Connects a client process to the fileserver
00161             User::LeaveIfError(fsSession.Connect());
00162             CleanupClosePushL(fsSession);
00163 
00164             //Open file where the stream text is
00165             User::LeaveIfError(rFile.Open(fsSession,KHelloFileName, EFileStreamText));
00166             CleanupClosePushL(rFile);
00167 
00168             // copy stream from file to RFileStream object
00169             RFileReadStream inputFileStream(rFile);
00170             CleanupClosePushL(inputFileStream);
00171 
00172             // HBufC descriptor is created from the RFileStream object.
00173             HBufC* fileData = HBufC::NewLC(inputFileStream, 32);
00174 
00175             CAknInformationNote* note = new ( ELeave ) CAknInformationNote;
00176 
00177             // Show the information Note
00178             note->ExecuteLD( *fileData );
00179 
00180             // Pop loaded resources from the cleanup stack:
00181             // filedata, inputFileStream, rFile, fsSession
00182             CleanupStack::PopAndDestroy(4, &fsSession);
00183             }
00184             break;
00185 
00186         case EHelloWorldBasicCommand3:
00187             {
00188             // Load a string from the resources and use it as a default value
00189             HBufC* defaultText = StringLoader::LoadLC( R_HEWB_FILE_TEXT );
00190 
00191             CHelloWorldQueryDialog *dlg = new (ELeave)
00192                 CHelloWorldQueryDialog( iAppView->GetText(), defaultText );
00193 
00194             dlg->ExecuteLD( R_DIALOG_TEXT_EDIT_QUERY );
00195             iAppView->DrawNow();
00196 
00197             // Pop HBuf from CleanUpStack and Destroy it.
00198             CleanupStack::PopAndDestroy( defaultText );
00199             }
00200             break;
00201 
00202         default:
00203             break;
00204         }
00205     }

void CHelloWorldBasicAppUi::HandleResourceChangeL TInt  aType  )  [private]
 

HandleResourceChangeL() Called by framework when layout is changed.

Parameters:
aType the type of resources that have changed

Definition at line 211 of file helloworldbasicappui.cpp.

References iAppView.

00212 {
00213     // base-class call also
00214     CAknAppUi::HandleResourceChangeL(aType);
00215     if (aType == KEikDynamicLayoutVariantSwitch)
00216         {
00217         if (iAppView)
00218             iAppView->SetRect( ClientRect() );
00219         }
00220 }


Member Data Documentation

CHelloWorldBasicAppView* CHelloWorldBasicAppUi::iAppView [private]
 

The application view Owned by CHelloWorldBasicAppUi

Definition at line 77 of file helloworldbasicappui.h.

Referenced by ConstructL(), HandleCommandL(), HandleResourceChangeL(), and ~CHelloWorldBasicAppUi().


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

© Nokia 2009

Back to top