WxAndroid/WXCalls

From WxWiki
Jump to: navigation, search

General

WXCalls is class containing static methods that JNI wrapeprs located in "wx/android/private/wrappers.h" use. It is used for communication from CPP to Java. It contains methods that rely on data from wxWidgets to update Views, Windows and Activities.
This class helps keeping everything in synchronization and validates existence of parents.

addView

static void addView(int id, int parentId, int width, int height, int x, int y, String classStr, long ptr)

Adds and shows view(wxControl) with wxWindowID id. View is added to WXApp.m_viewList.

  • parentId - id of parent wxWindow(wxFrame,wxPanel)
  • width, height - wxSize of view.
  • x, y - wxPoint, coordinates of control.
  • classStr - string identifier for corresponding java class e.g. Button -> "android.widget.Button"
  • ptr - pointer to class in wxWidgets.

registerWindow

static void registerWindow(final int id)

Registers that new wxTLW is being constructed and therefore allows adding of wxControls to it for future use.

  • id - id of new wxTLW.

showWindow

 static void showWindow(final int id, final String title)

Puts wxTLW with given id in front of screen, and showing all visible children on screen.

  • id - id of wxTLW.
  • title - String showed at top of activity, represents frame title.

invokeViewMethod

static void invokeViewMethod(final String methodStr, final int parentId, final int id, final long params, final Object... args))

Invokes method of view with given id, it can be any method in any superclass or view's class it self.
Example of view is android.View.Button, has superclass method "setText" that can still be accessed with this method.
This method takes advantage of Java's reflection to find proper class and method. Maximum amount of arguments is 15.

  • methodStr - Name of method, such as "setText", "setMaxHeight" ...
  • parentId - Id of View's parent window, all wxControl objects store this in m_parentId member.
  • id - Id of View that should execute method, id coorespond's to control's Id.
  • params - Check out MethodParams C++ class.
  • args - values of method arguments.

notify

static void notify(int duration, String text)

Used by wxNotifyMessage, creates and shows toast with given text.

  • duartion - Android's Toast supports only 2 durations, short one with value of 0 and long one with value of 1.
  • text - Main text that will be displayed.