Form Manager will be detailed in two posts :)
We've seen a lot of bada concepts, bada environment, bada tools, bada docs and we've seen a first bada app.
Now, let's see how to switch forms in bada...
What are Forms?
The Form provides the top level container with an indicator bar, soft key, and title bar. It is attached to a Frame. The Frame provides the main window for an application. There can be only 1 frame, however we can have a lot of forms in bada.
As your applications become more complex, it won't be enough to have one form only.
Let's start creating a new Form Manager Sample Code...
As we know, we must create a bada Form Based Project




And after these steps, we'll see our project in workspace.

If you ckeck the code into the header (FormMain.h) you'll see the declaration of the form's class.
class FormMain :
public Osp::Ui::Controls::Form,
public Osp::Ui::IActionEventListener
{
Every Form are derived from Osp::Ui::Controls::Form.
The Form is created in FormMain.cpp, on Initialize() function.
bool
FormMain::Initialize()
{
// Construct an XML form
Construct(L"IDF_FORMMAIN");
return true;
}
Note that the construct parameter refers to Form name, that could be updated in Form properties, as shown below.
Once you have your form’s class ready, you will need to show it somehow to the user. For such purposes we have to go to the application's class. The FormMain.cpp, in this example, is not the main class of the project so it must be explicity initialized. When we create a bada project, the class that has the exact name of the project is the main class of the project (application class). In this example, FormManagerSample is the application class.
In FormManagerSample.cpp, you can find a callback function which is called on application’s start: OnAppInitializing()
bool
FormManagerSample::OnAppInitializing(AppRegistry& appRegistry)
{
// TODO:
// Initialize UI resources and application
// specific data.
// The application'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 application
// will be terminated.
// Uncomment the following statement to listen to
//the screen on/off events.
//PowerManager::SetScreenEventListener(*this);
// Create a form
FormMain *pFormMain = new FormMain();
pFormMain->Initialize();
// Add the form to the frame
Frame *pFrame = GetAppFrame()->GetFrame();
pFrame->AddControl(*pFormMain);
// Set the current form
pFrame->SetCurrentForm(*pFormMain);
// Draw and Show the form
pFormMain->Draw();
pFormMain->Show();
return true;
}
And... if you need a lot of Forms (screens)?
Bada suggests FormMgr (code is available in SDK_FOLDER\workspace\UiControls\src\FormMgr.cpp). You can just add UiControls project to your workspace by accessing "bada SDK Samples" view (as shown here).
What is FormMgr?
Another Form in the application responsible for Forms management. The FormMgr just change screens in bada. FormMgr don't present labels, images, etc...
Let's better understand FormMgr in next post!
Thanks for your visit! :)
Next post: Form Manager - how to switch forms in bada apps (part 2)
Feel free to ask/suggest/comment.
Twitter: @oliveiraeduardo
Nenhum comentário:
Postar um comentário