Beginning with the basics:
1. Download and install Tizen IDE from developer.tizen.org. (Available for Windows, Mac and Ubuntu). We need to set up Security Profile and install an emulator to start testing your program.
2. We would be using the blank project template for beginning.
Screen-shot:
We would directly move on to application development, going through the following basics may help in the application development process.
Referring to the Application Life cycle, all of the initialization should be done in HelloTizenApp::OnAppInitializing(AppRegistry& appRegistry)function, present in HelloTizen.cpp. We are just going to change this fucnction of ours.
Step 1: Initialize a Frame //This is already done for us by the Tizen IDE
HelloTizenFrame* pHelloTizenFrame = new HelloTizenFrame;
pHelloTizenFrame->Construct();
pHelloTizenFrame->SetName(L"HelloTizen");
AddFrame(*pHelloTizenFrame);
Step 2: Initialize a form
Tizen::Ui::Controls::Form *firstForm = new Tizen::Ui::Controls::Form();
firstForm->Construct(FORM_STYLE_NORMAL | FORM_STYLE_HEADER);
Step 3: Add form to the frame
Tizen::Ui::Controls::Frame * frame = Application::GetInstance()->GetAppFrame()->GetFrame();
result r = frame->AddControl(firstForm);
Step 4: Set current form of the frame to the one we just created
result r = frame->SetCurrentForm(firstForm);
/*result variable is just to check the error codes refer help*/
Step 5: Set the Text 'Hello Tizen'
Header *header = firstForm->GetHeader();
header->SetTitleText(L"Hello Tizen");
Step 6: Make the form visible
firstForm->Draw();
firstForm->Show();
And with all this small addition, we are up with a new application 'Hello Tizen'
Snapshot:
And this is how we see in our app in the emulator |
Complete code of HelloTizenApp::OnAppInitializing(AppRegistry& appRegistry):
bool
HelloTizenApp::OnAppInitializing(AppRegistry& appRegistry)
{
// TODO:
// Initialize App specific data.
// The App's permanent data and context can be obtained from the appRegistry.
//
// If this method is successful, return true; otherwise, return false.
// If this method returns false, the App will be terminated.
// Create a Frame
HelloTizenFrame* pHelloTizenFrame = new HelloTizenFrame;
pHelloTizenFrame->Construct();
pHelloTizenFrame->SetName(L"HelloTizen");
AddFrame(*pHelloTizenFrame);
//Initializing the form
Tizen::Ui::Controls::Form *firstForm = new Tizen::Ui::Controls::Form();
firstForm->Construct(FORM_STYLE_NORMAL | FORM_STYLE_HEADER);
//Add the form to Tizen::Ui::Controls::Frame instance
Tizen::Ui::Controls::Frame * frame = Application::GetInstance()->GetAppFrame()->GetFrame();
r = frame->AddControl(firstForm);
if ( r == E_SUCCESS ) //Error Checking
{
AppLog ("myFlag: Successfully added form to the frame");
}
else
{
AppLog("myFlag: Error Code is %s ", GetErrorMessage(r));
}
//THis form should be created as a default form
r = frame->SetCurrentForm(firstForm);
if ( r == E_SUCCESS )
{
AppLog ("myFlag: Successfully set current form");
}
else
{
AppLog("myFlag: Error Code is %s ", GetErrorMessage(r));
}
//Getting a Header
Header *header = firstForm->GetHeader();
header->SetTitleText(L"Hello Tizen");
//Showing the form
firstForm->Draw();
firstForm->Show();
//firstForm->Invalidate(true);
return true;
}
No comments:
Post a Comment