void GLViewImpl::setIMEKeyboardState(bool open)
{
    if (open)
    {
        if (!s_keypadWin)
        {
            auto frameSize = Director::getInstance()->getOpenGLView()->getFrameSize();
            auto app = Application::getInstance();

            s_keypadWin = elm_win_add(app->_win, "cocos2d-x textfield", ELM_WIN_BASIC);
            elm_win_autodel_set(s_keypadWin, EINA_TRUE);
            elm_win_conformant_set(s_keypadWin, EINA_TRUE);
            elm_win_alpha_set(s_keypadWin, EINA_TRUE);
            eext_object_event_callback_add(s_keypadWin, EEXT_CALLBACK_BACK, keyPadBackCallback, NULL);
            evas_object_show(s_keypadWin);

            int rots[2];
            rots[0] = (int)elm_win_rotation_get(app->_win);
            rots[1] = rots[0] + 180 % 360;
            elm_win_wm_rotation_available_rotations_set(s_keypadWin, rots, 2);

            auto rectangle = elm_bg_add(s_keypadWin);
            evas_object_resize(rectangle, frameSize.width, frameSize.height + 50);
            evas_object_color_set(rectangle, 0xff, 0xff, 0xff, 0);
            evas_object_move(rectangle, 0, -50);
            evas_object_show(rectangle);

            evas_object_repeat_events_set(rectangle, EINA_TRUE);
            evas_object_event_callback_add(rectangle, EVAS_CALLBACK_MOUSE_UP, blankAreaClickedCallback, NULL);
            evas_object_event_callback_add(rectangle, EVAS_CALLBACK_MULTI_UP, blankAreaClickedCallback, NULL);

            s_keypadEntry = elm_entry_add(rectangle);
            elm_entry_single_line_set(s_keypadEntry, EINA_TRUE);
            evas_object_resize(s_keypadEntry, frameSize.width, 50);
            evas_object_move(s_keypadEntry, 0, -50);
            elm_entry_input_panel_return_key_type_set(s_keypadEntry, ELM_INPUT_PANEL_RETURN_KEY_TYPE_DONE);
            elm_entry_prediction_allow_set(s_keypadEntry, EINA_FALSE);
            evas_object_event_callback_add(s_keypadEntry, EVAS_CALLBACK_KEY_UP, entryKeyCallback, NULL);
            evas_object_show(s_keypadEntry);

            elm_object_focus_set(s_keypadEntry, EINA_TRUE);
            evas_object_smart_callback_add(s_keypadEntry, "activated", entryActivatedCallback, NULL);
            elm_entry_input_panel_show(s_keypadEntry);

            s_imf = (Ecore_IMF_Context*)elm_entry_imf_context_get(s_keypadEntry);
            ecore_imf_context_event_callback_add(s_imf, ECORE_IMF_CALLBACK_COMMIT, imfEventCommitCallback, s_keypadEntry);
        }
    }
    else if (s_keypadWin)
    {
        closeKeypad();
    }
}
/* Create main window */
static Evas_Object *create_win(const char *name)
{
	Evas_Object *eo;
	int w, h;

	eo = elm_win_add(NULL, name, ELM_WIN_DIALOG_BASIC);
	if (eo) {
		elm_win_title_set(eo, name);
		elm_win_borderless_set(eo, EINA_TRUE);
		evas_object_smart_callback_add(eo, "delete,request", win_del, NULL);
		elm_win_alpha_set(eo, EINA_TRUE);
		ecore_x_window_size_get(ecore_x_window_root_first_get(), &w,
				&h);
		evas_object_resize(eo, w, h);
	}

	return eo;
}
Beispiel #3
0
EAPI int
elm_main(int argc, char **argv)
{
   Evas_Object *window;
   Evas_Object *layout;
   Evas_Object *edje;
   Evas_Object *grid;
   Evas_Object *list;
   char path[PATH_MAX];
   Eina_Bool quit_option = EINA_FALSE;
   int args;

   Ecore_Getopt_Value values[] = {
     ECORE_GETOPT_VALUE_BOOL(crazy_option),
     ECORE_GETOPT_VALUE_BOOL(quit_option),
     ECORE_GETOPT_VALUE_BOOL(quit_option),
     ECORE_GETOPT_VALUE_BOOL(quit_option),
     ECORE_GETOPT_VALUE_BOOL(quit_option),
     ECORE_GETOPT_VALUE_NONE
   };

   _log_domain = eina_log_domain_register("Excessive", NULL);
   if (_log_domain < 0)
     {
        EINA_LOG_CRIT("could not create log domain 'Excessive'.");
        return -1;
     }

   args = ecore_getopt_parse(&options, values, argc, argv);
   if (args < 0)
     {
        ERR("could not parse command line options.");
        return -1;
     }

   if (quit_option) return 0;

   excessive_browse_init();

   elm_policy_set(ELM_POLICY_QUIT, ELM_POLICY_QUIT_LAST_WINDOW_CLOSED);
   elm_theme_extension_add(NULL, PACKAGE_DATA_DIR "/themes/theme.edj");
   elm_theme_overlay_add(NULL, PACKAGE_DATA_DIR "/themes/theme.edj");
   elm_need_efreet();
   elm_need_ethumb();

   window = elm_win_add(NULL, PACKAGE_NAME, ELM_WIN_BASIC);
   if (!window)
     {
        ERR("could'nt create window.");
        return -1;
     }

   /* FIXME: later remember last size */
   elm_win_alpha_set(window, 1);
   evas_object_resize(window, 800, 600);
   elm_win_title_set(window, PACKAGE_STRING);
   elm_win_autodel_set(window, 1);

   layout = elm_layout_add(window);
   if (!layout)
     {
        ERR("couldn't create layout object.");
        return -1;
     }

   evas_object_size_hint_align_set(layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
   evas_object_size_hint_weight_set(layout, EVAS_HINT_FILL, EVAS_HINT_FILL);
   elm_win_resize_object_add(window, layout);

   if (!elm_layout_theme_set(layout, "layout", "application", "content"))
     {
        ERR("could not load style 'content' from theme");
        return -1;
     }

   evas_object_show(layout);
   evas_object_show(window);

   edje = elm_layout_edje_get(layout);
   grid = edje_object_part_external_object_get(edje, "grid");

   evas_object_data_set(grid, "excessive/layout", layout);
   evas_object_data_set(layout, "excessive/win", window);

   evas_object_size_hint_align_set(grid, EVAS_HINT_FILL, EVAS_HINT_FILL);
   evas_object_size_hint_weight_set(grid, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
   elm_gengrid_bounce_set(grid, EINA_FALSE, EINA_TRUE);
   elm_gengrid_align_set(grid, 0.5, 0.5);
   elm_gengrid_item_size_set(grid, 128, 128);

   excessive_browse_load(layout);

   list = edje_object_part_external_object_get(edje, "shortcut");

   excessive_shortcut_init(list, grid);

   if (argc < args + 1)
     {
       getcwd(path, PATH_MAX);

       excessive_browse_directory(grid, path);
     }
   else
     {
       excessive_browse_directory(grid, argv[args]);
     }

   elm_run();

   excessive_shortcut_shutdown();
   excessive_browse_shutdown();

   return 0;
}
void EditBoxImplTizen::openKeyboard()
{
    if (s_keypadWin)
    {
        return;
    }

    if (_delegate != NULL)
    {
        _delegate->editBoxEditingDidBegin(_editBox);
    }

#if CC_ENABLE_SCRIPT_BINDING
    EditBox* pEditBox = this->getEditBox();
    if (NULL != pEditBox && 0 != pEditBox->getScriptEditBoxHandler())
    {
        CommonScriptData data(pEditBox->getScriptEditBoxHandler(), "began",pEditBox);
        ScriptEvent event(cocos2d::kCommonEvent,(void*)&data);
        ScriptEngineManager::getInstance()->getScriptEngine()->sendEvent(&event);
    }
#endif

    Evas_Object* parent = Application::getInstance()->_win;
    GLView* glView = Director::getInstance()->getOpenGLView();
    Size frameSize = glView->getFrameSize();

    s_keypadWin = elm_win_add(parent, "cocos2d-x", ELM_WIN_BASIC);
    elm_win_autodel_set(s_keypadWin, EINA_TRUE);
    elm_win_conformant_set(s_keypadWin, EINA_TRUE);
    elm_win_alpha_set(s_keypadWin, EINA_TRUE);
    evas_object_show(s_keypadWin);
    eext_object_event_callback_add(s_keypadWin, EEXT_CALLBACK_BACK, entry_back_cb, this);
    int rots[2];
    rots[0] = (int)(elm_win_rotation_get(parent));
    rots[1] = rots[0] + 180 % 360;
    elm_win_wm_rotation_available_rotations_set(s_keypadWin, rots, 2);

    Evas_Object* bgFull = elm_bg_add(s_keypadWin);
    evas_object_color_set(bgFull, 0, 0, 0, 0xa0);
    evas_object_resize(bgFull, frameSize.width, frameSize.height);
    evas_object_show(bgFull);

    int height = frameSize.height / 10;
    Evas_Object* rectangle = elm_bg_add(bgFull);
    evas_object_resize(rectangle, frameSize.width, height);
    evas_object_move(rectangle, 0, height);
    evas_object_color_set(rectangle, 0xff, 0xff, 0xff, 0xff);
    evas_object_show(rectangle);

    Evas_Object* title = elm_entry_add(rectangle);
    evas_object_resize(title, frameSize.width, height);
    auto text = _placeHolder.c_str();
    auto richText = (char*)malloc(strlen(text) + 50);
    sprintf(richText,"<color=#ffffff>%s</>", text);
    elm_entry_entry_set(title, richText);
    elm_entry_editable_set(title, EINA_FALSE);
    //elm_entry_drag_disabled_set(title, EINA_TRUE);
    //elm_entry_drop_disabled_set(title, EINA_TRUE);
    evas_object_show(title);
    free(richText);

    Evas_Object* entry = elm_entry_add(bgFull);
    elm_object_focus_set(entry, EINA_TRUE);
    evas_object_resize(entry, frameSize.width, height);
    evas_object_move(entry, 0, height);
    elm_entry_single_line_set(entry, EINA_TRUE);
    elm_entry_line_wrap_set(entry, ELM_WRAP_MIXED);
    elm_entry_entry_set(entry, _text.c_str());
    evas_object_show(entry);
    elm_object_focus_set(entry, EINA_TRUE);
    eext_entry_selection_back_event_allow_set(entry, EINA_TRUE);
    Elm_Entry_Filter_Limit_Size limit_size = { 0, };
    limit_size.max_char_count = _maxLength;
    elm_entry_markup_filter_append(entry, elm_entry_filter_limit_size, &limit_size);
    elm_entry_input_panel_return_key_type_set(entry, ELM_INPUT_PANEL_RETURN_KEY_TYPE_DONE);
    elm_entry_prediction_allow_set(entry, EINA_FALSE);

    evas_object_smart_callback_add(entry, "activated", entry_activated_cb, this);

    switch(_editBoxInputFlag)
    {
    case EditBox::InputFlag::PASSWORD:
        elm_entry_password_set(entry, EINA_TRUE);
        elm_entry_input_panel_layout_set(entry, ELM_INPUT_PANEL_LAYOUT_EMAIL);
        break;
    case EditBox::InputFlag::SENSITIVE:
        elm_entry_input_hint_set(entry, ELM_INPUT_HINT_SENSITIVE_DATA);
        break;
    case EditBox::InputFlag::INITIAL_CAPS_WORD:
        elm_entry_autocapital_type_set(entry, ELM_AUTOCAPITAL_TYPE_WORD);
        break;
    case EditBox::InputFlag::INITIAL_CAPS_SENTENCE:
        elm_entry_autocapital_type_set(entry, ELM_AUTOCAPITAL_TYPE_SENTENCE);
        break;
    case EditBox::InputFlag::INITIAL_CAPS_ALL_CHARACTERS:
        elm_entry_autocapital_type_set(entry, ELM_AUTOCAPITAL_TYPE_ALLCHARACTER);
        break;
    }

    switch(_editBoxInputMode)
    {
    case EditBox::InputMode::ANY:
        break;
    case EditBox::InputMode::EMAIL_ADDRESS:
        elm_entry_input_panel_layout_set(entry, ELM_INPUT_PANEL_LAYOUT_EMAIL);
        break;
    case EditBox::InputMode::NUMERIC:
        elm_entry_input_panel_layout_set(entry, ELM_INPUT_PANEL_LAYOUT_NUMBER);
        break;
    case EditBox::InputMode::PHONE_NUMBER:
        elm_entry_input_panel_layout_set(entry, ELM_INPUT_PANEL_LAYOUT_PHONENUMBER);
        break;
    case EditBox::InputMode::URL:
        elm_entry_input_panel_layout_set(entry, ELM_INPUT_PANEL_LAYOUT_URL);
        break;
    case EditBox::InputMode::DECIMAL:
        elm_entry_input_panel_layout_set(entry, ELM_INPUT_PANEL_LAYOUT_HEX); //fixme?
        break;
    case EditBox::InputMode::SINGLE_LINE:
        break;
    }
}
Beispiel #5
0
void _show_highscores(void *data, Evas_Object *obj, void *event_info)
{
    highscores_window = elm_win_add(NULL, "Highscores", ELM_WIN_BASIC);
    elm_win_autodel_set(highscores_window, EINA_TRUE);
    elm_win_alpha_set(highscores_window, EINA_TRUE);
    elm_policy_set(ELM_POLICY_QUIT, ELM_POLICY_QUIT_LAST_WINDOW_CLOSED);
    
    highscores_layout = elm_layout_add(highscores_window);
    evas_object_size_hint_weight_set(highscores_layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
    elm_win_resize_object_add(highscores_window, highscores_layout);
	elm_layout_file_set(highscores_layout, HIGHSCORES_LAYOUT, "highscore_layout");
    
    /*highscores_toolbar = elm_toolbar_add(highscores_window);
	elm_toolbar_shrink_mode_set(highscores_toolbar, ELM_TOOLBAR_SHRINK_SCROLL);
    Elm_Object_Item *it = elm_toolbar_item_append(highscores_toolbar, NULL, "Classic - small grid", _show_hs, (int*)CLASSIC_GAME_SMALL_GRID);
    elm_toolbar_item_append(highscores_toolbar, NULL, "Classic - medium grid", _show_hs, (int*)CLASSIC_GAME_MEDIUM_GRID);
    elm_toolbar_item_append(highscores_toolbar, NULL, "Classic - big grid", _show_hs, (int*)CLASSIC_GAME_BIG_GRID);
    elm_toolbar_item_append(highscores_toolbar, NULL, "Arcade", _show_hs, (int*)ARCADE_GAME);
    elm_toolbar_select_mode_set(highscores_toolbar, ELM_OBJECT_SELECT_MODE_ALWAYS);*/
    Evas_Object *btn = elm_button_add(highscores_window);
    evas_object_size_hint_weight_set(btn, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
	evas_object_size_hint_align_set(btn, EVAS_HINT_FILL, EVAS_HINT_FILL);
	elm_object_text_set(btn, "Small");
	evas_object_smart_callback_add(btn, "clicked", _show_hs, (int*)CLASSIC_GAME_SMALL_GRID);
	elm_layout_table_pack(highscores_layout, "hs_toolbar", btn, 0, 0, 1, 1);
	evas_object_show(btn);

    btn = elm_button_add(highscores_window);
    evas_object_size_hint_weight_set(btn, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
	evas_object_size_hint_align_set(btn, EVAS_HINT_FILL, EVAS_HINT_FILL);
	elm_object_text_set(btn, "Normal");
	evas_object_smart_callback_add(btn, "clicked", _show_hs, (int*)CLASSIC_GAME_MEDIUM_GRID);
	elm_layout_table_pack(highscores_layout, "hs_toolbar", btn, 1, 0, 1, 1);
	evas_object_show(btn);

    btn = elm_button_add(highscores_window);
    evas_object_size_hint_weight_set(btn, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
	evas_object_size_hint_align_set(btn, EVAS_HINT_FILL, EVAS_HINT_FILL);
	elm_object_text_set(btn, "Big");
	evas_object_smart_callback_add(btn, "clicked", _show_hs, (int*)CLASSIC_GAME_BIG_GRID);
	elm_layout_table_pack(highscores_layout, "hs_toolbar", btn, 2, 0, 1, 1);
	evas_object_show(btn);

    btn = elm_button_add(highscores_window);
    evas_object_size_hint_weight_set(btn, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
	evas_object_size_hint_align_set(btn, EVAS_HINT_FILL, EVAS_HINT_FILL);
	elm_object_text_set(btn, "Arcade");
	evas_object_smart_callback_add(btn, "clicked", _show_hs, (int*)ARCADE_GAME);
	elm_layout_table_pack(highscores_layout, "hs_toolbar", btn, 3, 0, 1, 1);
	evas_object_show(btn);
    
    highscores_genlist = elm_genlist_add(highscores_window);
    elm_object_part_content_set(highscores_layout, "list", highscores_genlist);

	Evas_Object *reset_btn = elm_button_add(highscores_window);
	elm_object_text_set(reset_btn, "Reset highscores");
	elm_object_part_content_set(highscores_layout, "reset_button", reset_btn);
    evas_object_smart_callback_add(reset_btn, "clicked", _highscores_back_button_cb, NULL);
    
    evas_object_show(highscores_layout);
    evas_object_show(highscores_window);
    //elm_toolbar_item_selected_set(it, EINA_TRUE);
	ea_object_event_callback_add(highscores_window, EA_CALLBACK_BACK, _highscores_back_button_cb, NULL);
   
	//_show_hs((int*)CLASSIC_GAME_SMALL_GRID, highscores_toolbar, it);
	
}