The document discusses native application development for BlackBerry 10 using C/C++. It covers the Native SDK and Cascades SDK. The Native SDK provides access to platform services and uses C/C++. The Cascades SDK is a C++ framework that uses Qt and allows building UIs in C++ or QML. It provides controls, animations, data binding and navigation between pages. The document demonstrates core concepts like events, touch handling, and custom components.
4. Native SDK
Hello World
#include <stdio.h>
#include <stdlib.h>
int
main(intargc, char **argv)
{
fprintf(stdout, “Hello World!n”);
return EXIT_SUCCESS;
}
5. Native SDK
BlackBerry Platform Services
the BlackBerry Platform Services (BPS) library provides an
application with a single consistent interface to a number
of different services during the execution of the application.
•
•
•
•
•
universal event management
user interaction/navigator
input/output (sensors, audio, LED, screen, multimedia)
device information, locale and payment services
network status and geo-location
6. Native SDK
BlackBerry Platform Services
bps_event_t *event_bps;
event_bps = NULL;
bps_get_event(&event_bps, timeout); // -1, forever
if (event_bps != NULL)
{
event_domain = bps_event_get_domain(event_bps);
if (event_domain == xxx)
{
// request event information within the domain
}
}
7. Native SDK
BlackBerry Platform Services
handling {service} events
{service}_request_events({param}); // request events
then capture the appropriate {service} events
event_domain = bps_event_get_domain(event_bps);
if (event_domain == {service}_get_domain())
{
// handle the {service} event
13. Mature C++ application framework
Good APIs
Signals and Slots
Many help classes
QML
QtGui Cascades
14. Qt
• Cross-platform application framework
• Design GUI, Command line, Daemon Applications
• More than a software development kit
• Extends C++ (Meta Object Compiler)
Cascades
• Replacement for Qt UI Creation Kit (Qt
Quick)
• Libraries to access device hardware
• Provides development tools (Cascades Builder)
15. Powerful toolkit with many components
• QtNetwork Module
• QtMedia Module
• QtCore
• C++ Extensions
QtQuick
• QtModeling Language (QML)
• JavaScript based declarative language
• Used in design of User Interface Applications
Qt Creator
• Aids in QML development
16. Replacement for QtQuick
• Cascades UI rendering is NOT on the main thread!
Features
• Provides BlackBerry Look and Feel
• Provides advanced placement management of
components
• Supports multiple resolutions
• Supports orientation changes (Landscape vs
Portrait)
Uses QML
• Replaces Qt Creator
• QNX Momentics IDE Plugin – Cascades Builder
22. Scene Graph
Designing UI with QML
• QML User Interfaces built on Object-Tree Model
• Need a root node
Typical root nodes
• Anything that subclasses AbstractPane
• Page – individual screen within an application
• NavigationPane
• TabbedPane
Container – contains multiple UI objects
• Used for custom components
27. Handling Touch Events in C++
QObject::connect(bubble,SIGNAL
(touch(bb::cascades::TouchEvent*))
this,SLOT
(touched(bb::cascades::TouchEvent*))
);
touched(bb::cascades::TouchEvent *t)
{
if (t->isDown()) {
bubble->setScale(2f);
bubble->setRotation(45.0f);
}
else if (t->isUp()) {
bubble->setScale(1f);
bubble->setRotation(0.0f);
}
}
}
28. C++
QML
You can choose!
No difference between UI created in QML or C++
They can be combined
Typically, UI in QML and business logic in C++
QML supports JavaScript for signal handling
29. Animations
Any Cascades UI element can be animated
Animations are “running” on the engine thread
Remember the client server setup?
Explicit&Implicit animations:
translation, rotation, scale, opacity, …