S60 Notepad Library API Specification: Using Notepad Library API

Handling templates

FetchTemplateL static function from Notepad Library API can be used for fetching the templates. See usage example of the FetchTemplateL function below.

//Returns NULL if the popup list is cancelled or there is no template. aTitle is Optional parameter for title.

HBufC* buf = CNotepadApi::FetchTemplateL( aTitle );

The ExecTemplatesL static function from Notepad Library API can be used for executing the Templates. See usage example of the ExecTemplatesL function below.

//Returns exit status.

CNotepadApi::ExecTemplatesL();

Handling memos

The FetchMemoL static function from Notepad Library API can be used for fetching the memos. See usage example of the FetchMemoL function below.

//Returns NULL if the popup list is cancelled or there is no memo. aTitle is Optional parameter for title.

HBufC* desc = CNotepadApi::FetchMemoL( aTitle );

Viewing files

The ExecFileViewerL static function from Notepad Library API can be used for showing the contents of text file. See usage example of the ExecFileViewerL function using the file handle below.

//Creates non-wait/waiting CNotepadViewerDialog. 
//Following snippet of code Creates waiting dialog with given file name.
//file is a handle of opened aFileName file. aTitle TitlePane string, if it is NULL then Title will be FileName.
//aDoWait is used for non-wait/waiting dialog.
// aGuessEncoding guess encoding if ETrue, it ignores charconvCharsetID. charconvCharsetID encoding of the File, default is ISO-8859-1 and returns Dialog's exit status.

RFs fileSession;
RFile file;
User::LeaveIfError(fileSession.Connect());
CleanupClosePushL(fileSession);
User::LeaveIfError(file.Open(fileSession, aFileName, EFileRead));
CleanupClosePushL(file);

CNotepadApi::ExecFileViewerL( file, 
NULL, ETrue, EFalse, charconvCharsetID );

Another overloaded ExecFileViewerL static function from Notepad Library API can also be used for showing the contents of text file. In the previous code snippet the file handle is used as a parameter. In the following usage example of the ExecFileViewerL function the file name is used as a parameter.

// filename is the name of the file to open by Notepad Library API.
CNotepadApi::ExecFileViewerL( fileName );

Opening Editor

The ExecTextEditorL static function from Notepad Library API can be used for opening the editor. See usage example of the ExecTextEditorL function below.

//aReturnStatus is the return status, returns KErrGeneral (-1) if document was deleted and KErrNone in other case. aDescription parameter tells about the initial text. If null, editor starts empty. title is the title of the editor dialog. delConf Confirmation text is shown if user chooses to delete the document. This function returns pointer to the modified text.

HBufC* desc = CNotepadApi::ExecTextEditorL(aStatus, aDescription, *title, *delConf);

Error handling

Normal Symbian error handling practises should be used, including e.g. using cleanup stack and trap harness. Leaves and system wide error codes as function return values are used if the error is recoverable. A client application can handle these errors similarly as a normal Symbian platform application.


Copyright © Nokia Corporation 2001-2008
Back to top