Each WebView must be attached to a GFWindow native window. For more Information about GfWindow see GfWindow.h.
Each GfWindow contains a set of callback methods. These methods allow the developer to gather information and display this to the user. You must implement a GfCallbacks class in order to implement this functionality:
// create a callbacks class MyCallbacks *callbacks = new MyCallbacks(); // set the callbacks class on the window window->setCallbacks(callbacks);
To set the native window and the size:
webView->setViewWindow(window); webView->initWithFrame(rect, NULL, NULL);
The following code snippet implements the GFCallbacks class in the sample application.
class MyCallbacks : public GfCallbacks { public: void updateScreen(gf_surface_t surf, int x, int y, int x2, int y2, int dstX, int dstY) { if (first_update == 0) { first_update = perf_snapshot_time(); } gf_draw_begin(layer_context); gf_draw_blit2(layer_context, surf, layer_surface, x, y, x2, y2, dstX, dstY); gf_draw_finish(layer_context); gf_draw_end(layer_context); } void newWindow() { } };
The GfWindow.h header file contains the GFCallbacks class. The implemented methods of GFCallbacks are described below (listed alphabetically):
createWindow()
getInstancePtr()
restoreViewState()
runJavaScriptAlert()
runJavaScriptConfirm()
runJavaScriptPrompt()
saveViewState()
setInputMethodState()
setInstancePtr()
textFieldBegin()
textFieldEnd()
updateScreen()