|
S60 3rd Edition SDK for Symbian OS Example Applications Guide |
00001 /* 00002 * ============================================================================== 00003 * Name : SIPExDoc.cpp 00004 * Part of : SIPEx 00005 * Interface : 00006 * Description : 00007 * Version : 00008 * 00009 * Copyright (c) 2004-2006 Nokia Corporation. 00010 * This material, including documentation and any related 00011 * computer programs, is protected by copyright controlled by 00012 * Nokia Corporation. 00013 * ============================================================================== 00014 */ 00015 00016 // INCLUDE FILES 00017 00018 #include "SIPExDoc.h" 00019 #include "SIPExAppUi.h" 00020 #include "SIPExGameEngine.h" 00021 00022 // CONSTANTS 00023 const TInt KMaxInfoLength = 1024; 00024 00025 // ============================ MEMBER FUNCTIONS =============================== 00026 00027 // ----------------------------------------------------------------------------- 00028 // CSIPExDoc::CSIPSettinsgDoc 00029 // C++ default constructor can NOT contain any code, that 00030 // might leave. 00031 // ----------------------------------------------------------------------------- 00032 // 00033 CSIPExDoc::CSIPExDoc( CEikApplication& aApp ) 00034 : CEikDocument( aApp ) 00035 { 00036 } 00037 00038 // ----------------------------------------------------------------------------- 00039 // CSIPExDoc::ConstructL 00040 // Symbian 2nd phase constructor can leave. 00041 // ----------------------------------------------------------------------------- 00042 // 00043 void CSIPExDoc::ConstructL() 00044 { 00045 iInfoText = HBufC::NewL( KMaxInfoLength ); 00046 } 00047 00048 // ----------------------------------------------------------------------------- 00049 // CSIPExDoc::NewL 00050 // Two-phased constructor. 00051 // ----------------------------------------------------------------------------- 00052 // 00053 CSIPExDoc* CSIPExDoc::NewL( CEikApplication& aApp ) 00054 { 00055 CSIPExDoc* self = new( ELeave ) CSIPExDoc( aApp ); 00056 00057 CleanupStack::PushL( self ); 00058 self->ConstructL(); 00059 CleanupStack::Pop(); 00060 00061 return self; 00062 } 00063 00064 // Destructor 00065 CSIPExDoc::~CSIPExDoc() 00066 { 00067 delete iEngine; 00068 delete iInfoText; 00069 } 00070 00071 // ----------------------------------------------------------------------------- 00072 // CSIPExDoc::CreateAppUiL 00073 // Creates the application user interface and return a pointer to it 00074 // ----------------------------------------------------------------------------- 00075 // 00076 CEikAppUi* CSIPExDoc::CreateAppUiL() 00077 { 00078 CSIPExAppUi* appUi = new ( ELeave ) CSIPExAppUi; 00079 return appUi; 00080 } 00081 00082 // ----------------------------------------------------------------------------- 00083 // CSIPExDoc::CreateEngineL 00084 // Creates the application engine 00085 // ----------------------------------------------------------------------------- 00086 // 00087 CSIPExEngine* CSIPExDoc::CreateEngineL( MSIPExGameObserver& aObserver ) 00088 { 00089 iEngine = CSIPExEngine::NewL( aObserver ); 00090 return iEngine; 00091 } 00092 00093 // ----------------------------------------------------------------------------- 00094 // CSIPExDoc::StoreInfoTextL 00095 // ----------------------------------------------------------------------------- 00096 // 00097 void CSIPExDoc::StoreInfoTextL( const TDesC& aText ) 00098 { 00099 __ASSERT_ALWAYS( 00100 ( aText.Length() + 1 ) < KMaxInfoLength, User::Leave( KErrArgument ) ); 00101 00102 TPtr ptext( iInfoText->Des() ); 00103 00104 TInt appendLen = aText.Length() + 1; // plus one is for line break 00105 00106 if ( ( appendLen + iInfoText->Length() ) > KMaxInfoLength ) 00107 { 00108 ptext.Delete( 0, appendLen ); 00109 } 00110 00111 ptext.Append( aText ); 00112 ptext.Append( CEditableText::ELineBreak ); 00113 } 00114 00115 // ----------------------------------------------------------------------------- 00116 // CSIPExDoc::InfoText 00117 // ----------------------------------------------------------------------------- 00118 // 00119 const TDesC& CSIPExDoc::InfoText() 00120 { 00121 return *iInfoText; 00122 } 00123 00124 // End of File
|
© Nokia 2006 |