void SMV::buttonClicked(Widget* button) { mEditBox->hideKeyboard(); MAUtil::String str; str = mEditBox->getText(); strcpy(engine->url_path, str.c_str()); int str_c = strlen(engine->url_path); if(engine->url_path[str_c-1] != '/') { engine->url_path[str_c++] = '/'; engine->url_path[str_c] = '\0'; //mEditBox->setText(engine->url_path); } MAHandle directory = maFileOpen(engine->url_path, MA_ACCESS_READ); if (directory < 0) maMessageBox("Uwaga!", "Blad FileOpen!"); else { if (!maFileExists(directory)) maMessageBox("Uwaga!", "Katalog nie istnieje!"); else { maWidgetScreenShow(0); int res = maLocationStart(); if(res<0) maPanic(1, "No GPS available"); engine->read_conf_file(); engine->env_init(); engine->draw(); } } }
void SMV::listViewItemClicked(ListView* listView, int index) { maWidgetScreenShow(0); int res = maLocationStart(); if(res<0) maPanic(1, "No GPS available"); engine->selected_dir = index; engine->read_conf_file(); engine->env_init(); engine->draw(); }
void createUI() { // Create screen that holds the WebView. mScreen = maWidgetCreate("Screen"); // Create the WebView. mWebView = createWebView(); // Compose objects. maWidgetAddChild(mScreen, mWebView); // Show the screen. maWidgetScreenShow(mScreen); }
void MoSync_InitFullscreenGL() { int openglScreen = createOpenGLScreen(sOpenglView); maWidgetScreenShow(openglScreen); maWidgetSetProperty(sOpenglView, "bind", ""); }
/** * Show a screen. Only one screen at a time is visible. * The previous screen will be hidden when showing a screen. * Note: This method is only applicable to screens. */ void Screen::show() { maWidgetScreenShow(getWidgetHandle()); }
/** * Show the screen with the game user interface. * NOTE: If we had more screens, it could have been necessary * to do some UI initialization here, before the screen is displayed. */ void NativeScreen::showScreen() { maWidgetScreenShow(mScreen); }
//Now a method for showing the screen. void show() { //Show screen using the IOCTL function maWidgetShowScreen. maWidgetScreenShow(mScreen); }
/** * Implementation of standard API exposed to JavaScript * This function is used to detect different messages from JavaScript * and call the respective function in MoSync. * * @return true if stream was handled, false if not. */ bool NativeUIMessageHandler::handleMessage(Wormhole::MessageStream& stream) { char buffer[1024]; printf("Getting the next action \n"); char * action = (char*)stream.getNext(); printf("action: %s\n", action); // Widget Handling Calls if(0 == strcmp("maWidgetCreate", action)) { char* widgetType = (char*)stream.getNext(); char* widgetID = (char*)stream.getNext(); char* callbackID = (char*)stream.getNext(); printf("maWidgetCreate: %s, %s, %s\n", widgetType, widgetID, callbackID); int numParams = stringToInteger(stream.getNext()); MAWidgetHandle widget = maWidgetCreate(widgetType); if(widget <= 0) { sprintf(buffer,"'%s', %d", callbackID, widget); sendNativeUIError(buffer); } else { if(numParams > 0) { for(int i = 0; i < numParams/2; i++) { char* property = (char*)stream.getNext(); char* value = (char*)stream.getNext(); printf("maWidgetSetProperty %s, %s\n", property, value); int res = maWidgetSetProperty(widget, property, value); if(res < 0) { printf("could not set property\n"); } else { printf("set property done\n"); } } } //We use a special callback for widget creation printf("calling CallBack \n"); sprintf( buffer, "mosync.nativeui.createCallback('%s', '%s', %d)", callbackID, widgetID, widget); printf("Done creatign the script %s\n", buffer); mWebView->callJS(buffer); printf("done Calling Callback"); } } else if(0 == strcmp("maWidgetDestroy", action)) { MAWidgetHandle widget = stringToInteger(stream.getNext()); char* callbackID = (char*)stream.getNext(); int res = maWidgetDestroy(widget); if(res < 0) { sprintf(buffer,"'%s', %d", callbackID, res); sendNativeUIError(buffer); } else { sprintf(buffer,"'%s', %d", callbackID, res); sendNativeUISuccess(buffer); } } else if(0 == strcmp("maWidgetAddChild", action) ) { MAWidgetHandle parent = stringToInteger(stream.getNext()); MAWidgetHandle child = stringToInteger(stream.getNext()); char* callbackID = (char*)stream.getNext(); int res = maWidgetAddChild(parent, child); if(res < 0) { sprintf(buffer,"'%s', %d", callbackID, res); sendNativeUIError(buffer); } else { sprintf(buffer,"'%s', %d", callbackID, res); sendNativeUISuccess(buffer); } } else if(0 == strcmp("maWidgetInsertChild", action)) { MAWidgetHandle parent = stringToInteger((char*)stream.getNext()); MAWidgetHandle child = stringToInteger((char*)stream.getNext()); int index = stringToInteger((char*)stream.getNext()); char* callbackID = (char*)stream.getNext(); int res = maWidgetInsertChild(parent, child, index); if(res < 0) { sprintf(buffer,"'%s', %d", callbackID, res); sendNativeUIError(buffer); } else { sprintf(buffer,"'%s', %d", callbackID, res); sendNativeUISuccess(buffer); } } else if(0 == strcmp("maWidgetRemoveChild", action)) { MAWidgetHandle child = stringToInteger(stream.getNext()); char* callbackID = (char*)stream.getNext(); int res = maWidgetRemoveChild(child); if(res < 0) { sprintf(buffer,"'%s', %d", callbackID, res); sendNativeUIError(buffer); } else { sprintf(buffer,"'%s', %d", callbackID, res); sendNativeUISuccess(buffer); } } else if(0 == strcmp("maWidgetModalDialogShow", action)) { MAWidgetHandle dialogHandle = stringToInteger(stream.getNext()); char* callbackID = (char*)stream.getNext(); int res = maWidgetModalDialogShow(dialogHandle); if(res < 0) { sprintf(buffer,"'%s', %d", callbackID, res); sendNativeUIError(buffer); } else { sprintf(buffer,"'%s', %d", callbackID, res); sendNativeUISuccess(buffer); } } else if(0 == strcmp("maWidgetModalDialogHide", action)) { MAWidgetHandle dialogHandle = stringToInteger(stream.getNext()); char* callbackID = (char*)stream.getNext(); int res = maWidgetModalDialogHide(dialogHandle); if(res < 0) { sprintf(buffer,"'%s', %d", callbackID, res); sendNativeUIError(buffer); } else { sprintf(buffer,"'%s', %d", callbackID, res); sendNativeUISuccess(buffer); } } else if(0 == strcmp("maWidgetScreenShow", action)) { MAWidgetHandle screenHandle = stringToInteger(stream.getNext()); char* callbackID = (char*)stream.getNext(); int res = maWidgetScreenShow(screenHandle); if(res < 0) { sprintf(buffer,"'%s', %d", callbackID, res); sendNativeUIError(buffer); } else { sprintf(buffer,"'%s', %d", callbackID, res); sendNativeUISuccess(buffer); } } else if(0 == strcmp("maWidgetStackScreenPush", action)) { MAWidgetHandle stackScreen = stringToInteger(stream.getNext()); MAWidgetHandle newScreen = stringToInteger(stream.getNext()); char* callbackID = (char*)stream.getNext(); int res = maWidgetStackScreenPush(stackScreen, newScreen); if(res < 0) { sprintf(buffer,"'%s', %d", callbackID, res); sendNativeUIError(buffer); } else { sprintf(buffer,"'%s', %d", callbackID, res); sendNativeUISuccess(buffer); } } else if(0 == strcmp("maWidgetStackScreenPop", action)) { MAWidgetHandle stackScreen = stringToInteger(stream.getNext()); char* callbackID = (char*)stream.getNext(); int res = maWidgetStackScreenPop(stackScreen); if(res < 0) { sprintf(buffer,"'%s', %d", callbackID, res); sendNativeUIError(buffer); } else { sprintf(buffer,"'%s', %d", callbackID, res); sendNativeUISuccess(buffer); } } else if(0 == strcmp("maWidgetSetProperty", action)) { MAWidgetHandle widget = stringToInteger(stream.getNext()); char *property = (char*)stream.getNext(); char *value = (char*)stream.getNext(); char* callbackID = (char*)stream.getNext(); int res = maWidgetSetProperty(widget, property, value); if(res < 0) { sprintf(buffer,"'%s', %d", callbackID, res); sendNativeUIError(buffer); } else { sprintf(buffer,"'%s', %d", callbackID, res); sendNativeUISuccess(buffer); } } else if(0 == strcmp("maWidgetGetProperty", action)) { char value[1024]; MAWidgetHandle widget = stringToInteger(stream.getNext()); char* property = (char*)stream.getNext(); char* callbackID = (char*)stream.getNext(); int res = maWidgetGetProperty(widget, property, value, 1024); if(res < 0) { sprintf(buffer,"'%s', %d", callbackID, res); sendNativeUIError(buffer); } else { sprintf(buffer,"'%s', '%s', '%s'", callbackID, property, value); sendNativeUISuccess(buffer); } } // Tell the WebView that we have processed the stream, so that // it can send the next one. char replyScript[1024]; char * mosyncCallBackId = (char*)stream.getNext(); if(mosyncCallBackId != NULL) { sprintf( replyScript, "mosync.bridge.reply(%s)", mosyncCallBackId); printf("calling general callback %s\n", replyScript); mWebView->callJS(replyScript); } return true; }
/** * In the constructor we create the user interface. */ SineRunnerMoblet() : mGLViewInitialized(false) { // Create a screen widget that will hold the OpenGL view. int screen = maWidgetCreate(MAW_SCREEN); MAExtent screenSize = maGetScrSize(); mXRes = EXTENT_X(screenSize); mYRes = EXTENT_Y(screenSize); mTime = 0; mX = mY = 0.0; mCPosStart = -100.0; mCPos = mCPosStart; //behind the front of the curve mCYPos = 0.0; mMaxPoint = 0.0; mHit = false; mHitTimes = 0; mScreenIsPressed = false; mNumTicks = 0; inAir = false; mDead = false; mFinished = false; // Check if NativeUI is supported by the runtime platform. // For example, MoRE does not support NativeUI at the time // of writing this program. if (IOCTL_UNAVAILABLE == screen) { maPanic(0, "NativeUI is not available."); } // Create a GL_VIEW widget and add it to the screen. // widgetSetPropertyInt is a helper function defined // in WidgetUtil.cpp. mGLView = maWidgetCreate(MAW_GL_VIEW); if (MAW_RES_INVALID_TYPE_NAME == mGLView) { maPanic(1, "OpenGL|ES unavailable. OpenGL|ES is only available on Android and iOS. Also, please check that the device is able to run the version of OpenGL|ES you requested."); } widgetSetPropertyInt( mGLView, MAW_WIDGET_WIDTH, MAW_CONSTANT_FILL_AVAILABLE_SPACE); widgetSetPropertyInt( mGLView, MAW_WIDGET_HEIGHT, MAW_CONSTANT_FILL_AVAILABLE_SPACE); maWidgetAddChild(screen, mGLView); // Show the screen. maWidgetScreenShow(screen); // Make the Moblet listen to custom events, so that we // know when the GLView widget is ready to be drawn. MAUtil::Environment::getEnvironment().addCustomEventListener(this); }