WxAndroid/docs
About
wxWidgets for Android implementation requires use of JNI calls and specific Java classes that ease communication between two languages. Illustrated bellow is currently used design.
Here it can be seen that java components will use static methods of WXNative when ever needed to update wxWidgets's components, while wxWidgets uses WXCalls to update Java components. Files wrappers.h
and native.h
located in private directory of include/wx/android
contain macros and definitions of functions that are used to communicate with Android.
Further reading:
Here is brief example of two objects communicating:
wxButton * btn = new wxButton(frame, wxID_ANY);
Here, new object wxButton
is being constructed with wxFrame
instance as his parent. This is all done in traditional wxWidgets way, with all regular constructors and base class initialization. However, once wxWidgets is ready it needs to show new button on screen. To do that object Android's Button object needs to be created and passed to Activity that represents frame.
This is done through WXCall, by wxButton instance executing following code:
CALL_STATIC_VOID("addView", "(IIIIIILjava/lang/String;)V",
id, parent->GetId(), size.GetWidth(), size.GetHeight(), pos.x, pos.y, wxAndroid::Env->NewStringUTF(WXBUTTON_C));
WXCalls must ensure that button with given parameters is shown on screen.
CALL_STATIC_VOID
is one of many wrappers that are supposed to ease use of WXCalls methods, and is part of "wx/android/private/wrappers.h"
Frames/Windows and application life cycle
To understand how wxWidgets behaves on Android, general knowledge of Android's app life cycle is required.
From Android's documentation:
"An activity is a single, focused thing that the user can do. Almost all activities interact with the user, so the Activity class takes care of creating a window for you in which you can place your UI with setContentView(View)."
As such activity in this implementation is used as Window,
TO-DO: EVENTS <source>
Not yet finished:
wxWidgets code is compiled into .so library that must be loaded into java project. Full C++ implementation was/is possible but would require implementing each control and app life cycle on our own.