Главная » Просмотр файлов » Wiley.Developing.Software.for.Symbian.OS.2nd.Edition.Dec.2007

Wiley.Developing.Software.for.Symbian.OS.2nd.Edition.Dec.2007 (779887), страница 12

Файл №779887 Wiley.Developing.Software.for.Symbian.OS.2nd.Edition.Dec.2007 (Symbian Books) 12 страницаWiley.Developing.Software.for.Symbian.OS.2nd.Edition.Dec.2007 (779887) страница 122018-01-10СтудИзба
Просмтор этого файла доступен только зарегистрированным пользователям. Но у нас супер быстрая регистрация: достаточно только электронной почты!

Текст из файла (страница 12)

It contains the application classimplementation. These methods are called by the GUI framework when50SYMBIAN OS QUICK STARTstarting the application. It defines and returns the application’s UIDand creates and returns the application document object. Following isSimpleEx App.cpp:/*=================================================================File: simpleEx_app.cppThis file contains the application class for SimpleEx.==================================================================*/#include "SimpleEx.h"CApaDocument* CSimpleExApplication::CreateDocumentL(){return new(ELeave) CSimpleExDocument(*this);}TUid CSimpleExApplication::AppDllUid() const{return KUidSimpleExApp;}SimpleEx Doc.cppThis file is also common between S60 and UIQ.

The file contains the application document object. Although this example has no actual persistentdata, the example still overrides the CreateAppUiL() method of thedocument class since the framework calls this method to create and passa pointer to the application UI class. Following is SimpleEx Doc.cpp:#include "SimpleEx.h"CEikAppUi* CSimpleExDocument::CreateAppUiL(){return new (ELeave) CSimpleExAppUi;}SimpleEx UI.cppThis file contains the example application’s UI class. In the S60 example,this class contains the HandleCommandL() method where the mainaction of the application occurs. All user events (except alphanumeric keyboard input) come through the UI class method HandleCommandL().When the menu item ‘Start’ is selected, the GUI framework invokesthe HandleCommandL() method, passing it the command ESimpleExCommand (the command specified in the menu resource in the SimpleExresource file).

HandleCommandL() responds to this command by popping up an alert window with the message ‘Start Selected!’.I used the iEikonEnv->AlertWin() function for the pop-up sincethis is a core GUI method available to all platforms. This looks quitegood on UIQ, although fairly plain on the other platforms. In practice,you should follow the UI guidelines for the software platform you areusing, which are available for download from their developer websites.SIMPLE EXAMPLE APPLICATION51This may involve using platform-specific classes for controls or messagedisplays instead of core Uikon controls.As an example, in S60 you can use the S60-specific UI control classCAknInformationNote to pop up a message.

This would look betterfor the S60 UI than the generic Symbian OS application frameworkalternative.The UI class ConstructL() method creates the application view.ConstructL() is called by the framework after getting a pointer to theUI object from the document. You will see later how it is common forSymbian C++ objects to be constructed in two steps: instantiating theC++ class then invoking its ConstructL() method.Note further that, in the HandleCommandL() method, commandEAknSoftkeyExit handles the S60 Exit softkey that is put up at application start, as specified by the R AVKON SOFTKEYS OPTIONS EXIToption in the S60 resource file.

Following is SimpleEx UI.cpp filefor S60:/*=================================================================File: simpleEx_ui.cppThis file contains the application UI class for S60 SimpleEx.==================================================================*/#include "SimpleEx.h"void CSimpleExAppUi::ConstructL(){BaseConstructL(CAknEnableSkin);iAppView = CSimpleExAppView::NewL(ClientRect());}CSimpleExAppUi::~CSimpleExAppUi(){delete iAppView;}void CSimpleExAppUi::HandleCommandL(TInt aCommand){switch(aCommand){case EEikCmdExit:case EAknSoftkeyExit:Exit();break;case ESimpleExCommand:{_LIT(KMessage,"Start Selected!");iEikonEnv->AlertWin(KMessage);break;}}}The UIQ 3 version of SimpleEx appui.cpp is:/*=================================================================File: simpleEx_ui.cppThis file contains the application UI class for UIQ SimpleEx.52SYMBIAN OS QUICK START#include "SimpleEx.h"void CSimpleExAppUi::ConstructL(){BaseConstructL();iAppView = CSimpleExAppView::NewLC(*this);AddViewL(*iAppView);CleanupStack::Pop(iAppView);}In the UIQ version of the UI class, I implemented only one method:the secondary constructor, ConstructL().

This function simply createsthe application view and registers it via AddViewL(). As we will seeshortly, in UIQ the HandleCommandL() function is handled in the viewclass instead of the UI class like in the S60 version. The view mechanismshows its full benefits when using multiple views, but we use it here onlyfor a single view.SimpleEx View.cppThis file contains the application view class. The ConstructL() methodof the view class is called by the UI framework after the view class isinstantiated, and it’s this method that creates the main application windowand activates it for display.Draw() is a method called by the framework for every control inorder to draw it to the screen. The application view is a control, and,for this example, I implement the Draw() function to output the text‘Simple Example’ in the center of the window.

The drawing is performedby opening a graphics context (GC), getting a font, and calling thecontext’s DrawText() function. Cleanup is performed on the font uponcompletion.Following is the view class for S60:/*=================================================================File: simpleEx_view.cppThis file contains the application view class for SimpleEx.==================================================================*/#include "eikenv.h"#include <coemain.h>#include "SimpleEx.h"CSimpleExAppView* CSimpleExAppView::NewL(const TRect& aRect){CSimpleExAppView* self = CSimpleExAppView::NewLC(aRect);CleanupStack::Pop(self);return self;}CSimpleExAppView* CSimpleExAppView::NewLC(const TRect& aRect){CSimpleExAppView* self = new (ELeave) CSimpleExAppView;CleanupStack::PushL(self);self->ConstructL(aRect);return self;SIMPLE EXAMPLE APPLICATION53}void CSimpleExAppView::ConstructL(const TRect& aRect){CreateWindowL();SetRect(aRect);ActivateL();}void CSimpleExAppView::Draw(const TRect& ) const{CWindowGc& gc = SystemGc();TRect drawRect = Rect();gc.Clear();const CFont* font = iEikonEnv->TitleFont();gc.UseFont(font);TInt baselineOffset=(drawRect.Height() - font->HeightInPixels())/2;gc.DrawText(_L("Simple Example"),drawRect,baselineOffset,CGraphicsContext::ECenter, 0);gc.DiscardFont();}The following shows the view class for UIQ:/*=================================================================File: simpleEx_view.cppThis file contains the application view class for UIQ SimpleEx.==================================================================*/#include "eikenv.h"#include <coemain.h>#include "SimpleEx.h"#include "SimpleEx.rsg"#include <QikCommand.h>CSimpleExAppView* CSimpleExAppView::NewL(CQikAppUi& aAppUi){CSimpleExAppView* self = CSimpleExAppView::NewLC(aAppUi);CleanupStack::Pop(self);return self;}CSimpleExAppView* CSimpleExAppView::NewLC(CQikAppUi& aAppUi){CSimpleExAppView* self = new (ELeave) CSimpleExAppView(aAppUi);CleanupStack::PushL(self);self->ConstructL();return self;}CSimpleExAppView::CSimpleExAppView(CQikAppUi& aAppUi): CQikViewBase(aAppUi, KNullViewId){}void CSimpleExAppView::ConstructL(){BaseConstructL();}void CSimpleExAppView::ViewConstructL(){// Loads information about the UI configurations this view supports54SYMBIAN OS QUICK START// together with definition of each view.ViewConstructFromResourceL(R_SIMPLEEX_CONFIGURATIONS);}TVwsViewId CSimpleExAppView::ViewId()const{return TVwsViewId(KUidSimpleExApp, KUidSimpleExView);}void CSimpleExAppView::Draw(const TRect& ) const{CWindowGc& gc = SystemGc();TRect drawRect = Rect();gc.Clear();const CFont* font = iEikonEnv->TitleFont();gc.UseFont(font);TInt baselineOffset=(drawRect.Height() - font->HeightInPixels())/2;gc.DrawText(_L("Simple Example"),drawRect,baselineOffset,CGraphicsContext::ECenter, 0);gc.DiscardFont();}void CSimpleExAppView::HandleCommandL(CQikCommand& aCommand){switch(aCommand.Id()){case ESimpleExCommand:{_LIT(KMessage,"Start Selected!");iEikonEnv->AlertWin(KMessage);break;}default:CQikViewBase::HandleCommandL(aCommand);}}As you can see, the UIQ view class is more complex than the S60 one.The UIQ version of the view class has the method ViewConstructL(),which in turns calls the function ViewConstructFromResourceL(RSIMPLEEX CONFIGURATIONS).

Remember that R SIMPLEEXCONFIGURATIONS is the name of the QIK VIEW CONFIGURATIONSresource defined in the UIQ resource file, which points to the commandsassociated with the different display modes of the phone (in our case,the same command set). The UIQ view class has the HandleCommandL() function in it that handles these commands. ViewId() returnsthe UID of the application along with a view ID that uniquely identifiesthis view (via the line: TVwsViewId(KUidSimpleExApp, KUidSimpleExView)). In SimpleEx.h, this unique view ID (as specified inKUidSimpleExView) is 1.At this point you should have all the source files in the src directory.2.3.6Project Build FilesNow, let’s create the project build files: SimpleEx.mmp and bld.inf.SIMPLE EXAMPLE APPLICATION55Creating the SimpleEx.mmp project definition fileThis section shows the project definition files for the example for S60 andUIQ (they are very similar except for the platform-specific library shownin bold in the listings).

Use the file corresponding to your platform. Namethe file SimpleEx.mmp and place it in the group directory.The S60 project file is as follows:TARGETSimpleEx.exeTARGETTYPEexeUID0x100039CE 0xE000027FSOURCEPATH..\srcSOURCESimpleEx.cppSOURCESimpleEx_app.cppSOURCESimpleEx_view.cppSOURCESimpleEx_ui.cppSOURCESimpleEx_doc.cppSOURCEPATH..\groupSTART RESOURCESimpleEx_reg.rssTARGETPATH\private\10003a3f\appsENDSTART RESOURCESimpleEx.rssHEADERTARGETPATH resource/appsENDSYSTEMINCLUDE\epoc32\includeUSERINCLUDE..\includeLIBRARYeuser.lib apparc.lib cone.lib eikcore.libLIBRARYavkon.lib gdi.libThe UIQ project file is as follows:TARGETSimpleEx.exeTARGETTYPEexeUID0x100039CE 0xE000027FSOURCEPATH..\srcSOURCESimpleEx.cppSOURCESimpleEx_app.cppSOURCESimpleEx_view.cppSOURCESimpleEx_ui.cppSOURCESimpleEx_doc.cppSOURCEPATH..\groupSTART RESOURCESimpleEx_reg.rssTARGETPATH\private\10003a3f\appsENDSTART RESOURCESimpleEx.rssHEADERTARGETPATH resource/appsENDSYSTEMINCLUDE\epoc32\includeUSERINCLUDE..\includeLIBRARYeuser.lib apparc.lib cone.lib eikcore.libLIBRARYqikcore.lib gdi.lib56SYMBIAN OS QUICK STARTThe project definition file is a Symbian OS-specific text file that endsin .mmp and defines how to build the application.

Характеристики

Тип файла
PDF-файл
Размер
3,36 Mb
Материал
Тип материала
Высшее учебное заведение

Список файлов книги

Свежие статьи
Популярно сейчас
Почему делать на заказ в разы дороже, чем купить готовую учебную работу на СтудИзбе? Наши учебные работы продаются каждый год, тогда как большинство заказов выполняются с нуля. Найдите подходящий учебный материал на СтудИзбе!
Ответы на популярные вопросы
Да! Наши авторы собирают и выкладывают те работы, которые сдаются в Вашем учебном заведении ежегодно и уже проверены преподавателями.
Да! У нас любой человек может выложить любую учебную работу и зарабатывать на её продажах! Но каждый учебный материал публикуется только после тщательной проверки администрацией.
Вернём деньги! А если быть более точными, то автору даётся немного времени на исправление, а если не исправит или выйдет время, то вернём деньги в полном объёме!
Да! На равне с готовыми студенческими работами у нас продаются услуги. Цены на услуги видны сразу, то есть Вам нужно только указать параметры и сразу можно оплачивать.
Отзывы студентов
Ставлю 10/10
Все нравится, очень удобный сайт, помогает в учебе. Кроме этого, можно заработать самому, выставляя готовые учебные материалы на продажу здесь. Рейтинги и отзывы на преподавателей очень помогают сориентироваться в начале нового семестра. Спасибо за такую функцию. Ставлю максимальную оценку.
Лучшая платформа для успешной сдачи сессии
Познакомился со СтудИзбой благодаря своему другу, очень нравится интерфейс, количество доступных файлов, цена, в общем, все прекрасно. Даже сам продаю какие-то свои работы.
Студизба ван лав ❤
Очень офигенный сайт для студентов. Много полезных учебных материалов. Пользуюсь студизбой с октября 2021 года. Серьёзных нареканий нет. Хотелось бы, что бы ввели подписочную модель и сделали материалы дешевле 300 рублей в рамках подписки бесплатными.
Отличный сайт
Лично меня всё устраивает - и покупка, и продажа; и цены, и возможность предпросмотра куска файла, и обилие бесплатных файлов (в подборках по авторам, читай, ВУЗам и факультетам). Есть определённые баги, но всё решаемо, да и администраторы реагируют в течение суток.
Маленький отзыв о большом помощнике!
Студизба спасает в те моменты, когда сроки горят, а работ накопилось достаточно. Довольно удобный сайт с простой навигацией и огромным количеством материалов.
Студ. Изба как крупнейший сборник работ для студентов
Тут дофига бывает всего полезного. Печально, что бывают предметы по которым даже одного бесплатного решения нет, но это скорее вопрос к студентам. В остальном всё здорово.
Спасательный островок
Если уже не успеваешь разобраться или застрял на каком-то задание поможет тебе быстро и недорого решить твою проблему.
Всё и так отлично
Всё очень удобно. Особенно круто, что есть система бонусов и можно выводить остатки денег. Очень много качественных бесплатных файлов.
Отзыв о системе "Студизба"
Отличная платформа для распространения работ, востребованных студентами. Хорошо налаженная и качественная работа сайта, огромная база заданий и аудитория.
Отличный помощник
Отличный сайт с кучей полезных файлов, позволяющий найти много методичек / учебников / отзывов о вузах и преподователях.
Отлично помогает студентам в любой момент для решения трудных и незамедлительных задач
Хотелось бы больше конкретной информации о преподавателях. А так в принципе хороший сайт, всегда им пользуюсь и ни разу не было желания прекратить. Хороший сайт для помощи студентам, удобный и приятный интерфейс. Из недостатков можно выделить только отсутствия небольшого количества файлов.
Спасибо за шикарный сайт
Великолепный сайт на котором студент за не большие деньги может найти помощь с дз, проектами курсовыми, лабораторными, а также узнать отзывы на преподавателей и бесплатно скачать пособия.
Популярные преподаватели
Добавляйте материалы
и зарабатывайте!
Продажи идут автоматически
6552
Авторов
на СтудИзбе
299
Средний доход
с одного платного файла
Обучение Подробнее