void DisplayMessageQueue_X11::process_message()
	{
		std::shared_ptr<ThreadData> data = get_thread_data();
		::Display *display = get_display();
		XEvent event;
		while (XPending(display) > 0)
		{
			XNextEvent(display, &event);

			for (auto & elem : data->windows)
			{
				X11Window *window = elem;
				if (window->get_window() == event.xany.window)
				{
					X11Window *mouse_capture_window = current_mouse_capture_window;
					if (mouse_capture_window == nullptr)
						mouse_capture_window = window;

					window->process_message(event, mouse_capture_window);
				}
			}
		}

		for (auto & elem : data->windows)
		{
			elem->process_message_complete();
		}

		// Process all input context messages (done seperately, because of the mouse_capture hack)
		for (auto & elem : data->windows)
		{
			InputContext context = elem->get_ic();
			context.process_messages();
		}
	}
Esempio n. 2
0
void gun::HighScoreEntryScreen::HandleInput(const InputContext& input_context)
{
	std::string string = name_text_.string();
	sf::Uint32 unicode = input_context.GetTextEnteredUnicode();

	if (unicode >= 0)
	{
		if(unicode == '\b' && string.length() > 0)
		{
			string.erase(string.length() - 1, 1);
		}
		else if(unicode < 128 && string.length() < 10)
		{
			sf::String ch(unicode);
			char ansi_ch = ch.toAnsiString()[0];

			if(ch.getSize() > 0 && isalnum(ansi_ch))
			{
				string += ch;
			}
		}
	}

	boost::to_upper(string);
	name_text_.set_string(string);
	
	if (input_context.IsKeyReleased(sf::Keyboard::Return))
	{
		EnterHighScores();
	}
}
void DisplayMessageQueue_X11::process_message()
{
	 std::shared_ptr<ThreadData> data = get_thread_data();

	XEvent event;
	while(XPending(display) > 0)
	{
		XNextEvent(display, &event);

		for (std::vector<X11Window *>::size_type i = 0; i < data->windows.size(); i++)
		{
			X11Window *window = data->windows[i];
			if (window->get_window() == event.xany.window)
			{
				X11Window *mouse_capture_window = current_mouse_capture_window;
				if (mouse_capture_window == NULL)
					mouse_capture_window = window;

				window->process_message(event, mouse_capture_window);
			}
		}
	}

	for (std::vector<X11Window *>::size_type i = 0; i < data->windows.size(); i++)
	{
		data->windows[i]->process_message_complete();
	}

	// Process all input context messages (done seperately, because of the mouse_capture hack)
	for (std::vector<X11Window *>::size_type i = 0; i < data->windows.size(); i++)
	{
		InputContext context = data->windows[i]->get_ic();
		context.process_messages();
	}
}
Esempio n. 4
0
void CompWnd_Paint(HWND hCompWnd) {
  FOOTMARK();

  PAINTSTRUCT ps;
  HDC hDC = ::BeginPaint(hCompWnd, &ps);

  HFONT hOldFont = NULL;
  HFONT hFont = (HFONT)::GetWindowLongPtr(hCompWnd, FIGWLP_FONT);
  if (hFont) hOldFont = (HFONT)::SelectObject(hDC, hFont);

  HWND hSvrWnd = (HWND)::GetWindowLongPtr(hCompWnd, FIGWLP_SERVERWND);

  HIMC hIMC = (HIMC)::GetWindowLongPtr(hSvrWnd, IMMGWLP_IMC);
  if (hIMC) {
    InputContext *lpIMC = TheIME.LockIMC(hIMC);
    if (lpIMC) {
      CompStr *lpCompStr = lpIMC->LockCompStr();
      if (lpCompStr) {
        if (lpCompStr->dwCompStrLen > 0) {
          CompWnd_Draw(hCompWnd, hDC, lpIMC, lpCompStr);
        }
        lpIMC->UnlockCompStr();
      }
      TheIME.UnlockIMC(hIMC);
    }
  }
  if (hFont && hOldFont) ::SelectObject(hDC, hOldFont);
  ::EndPaint(hCompWnd, &ps);
} // CompWnd_Paint
Esempio n. 5
0
void InputContext::update_prop_label_cb(void *ptr, const char *str)
{
    InputContext *ic = (InputContext *)ptr;
    InputContext *focusedContext = InputContext::focusedContext();
    if (ic == focusedContext)
      ic->update_prop_label(str);
}
Esempio n. 6
0
void DynamicEditor::render()
{
    if (instanceTab->getTabCount() != 0)
    {
        InputContext* context = getActiveEditor();
        context->render(); //FIXME put this back in
    }
}
Esempio n. 7
0
InputContext * InputContextStack::popInputContext() {
    InputContext * res = m_stack.back();

    //reset states of all input listeners
    res->resetListeners(); 
    m_stack.pop_back();

    return res;
}
	void DisplayMessageQueue_Win32::process_input_contexts()
	{
		std::shared_ptr<ThreadData> data = get_thread_data();
		for (std::vector<Win32Window *>::size_type i = 0; i < data->windows.size(); i++)
		{
			InputContext context = data->windows[i]->get_ic();
			context.process_messages();
		}
	}
Esempio n. 9
0
void
InputContext::commit_cb(void *ptr, const char *str)
{
    InputContext *ic = (InputContext *)ptr;
    XimIC *xic = ic->get_ic();

    ic->clear_pe_stat();
    ic->update_preedit();
    xic->commit_string(str);
}
Esempio n. 10
0
void XimServer::changeContext(const char *engine) {
    set_im(engine);
    std::list<InputContext *>::iterator it;
    for (it = ic_list.begin(); it != ic_list.end(); ++it) {
	(*it)->changeContext(engine);
    }
    // make sure to use appropriate locale for the focused context
    InputContext *focusedContext = InputContext::focusedContext();
    if (focusedContext)
	focusedContext->focusIn();
}
Esempio n. 11
0
File: main.cpp Progetto: dai-vdr/uim
void
reload_uim(int reload_libuim)
{
    if (reload_libuim) {
	fprintf(stderr, "\nReloading uim...\n\n");

	terminate_canddisp_connection();
	helper_disconnect_cb();
	terminate_x_connection();

	std::map<Window, XimServer *>::iterator it;
	std::list<InputContext *>::iterator it_c;

	for (it = XimServer::gServerMap.begin(); it != XimServer::gServerMap.end(); ++it) {
	    XimServer *xs = it->second;
	    for (it_c = xs->ic_list.begin(); it_c != xs->ic_list.end(); ++it_c)
		(*it_c)->clear();
	}
	uim_quit();
    }

    clear_uim_info();
    get_uim_info();
    //print_uim_info();

    if (reload_libuim) {
	std::map<Window, XimServer *>::iterator it;
	std::list<InputContext *>::iterator it_c;

	for (it = XimServer::gServerMap.begin(); it != XimServer::gServerMap.end(); ++it) {
	    XimServer *xs = it->second;
	    for (it_c = xs->ic_list.begin(); it_c != xs->ic_list.end(); ++it_c) {
		const char *engine = (*it_c)->get_engine_name();
		(*it_c)->createUimContext(engine);
	    }
	}

	// make sure to use appropriate locale for the focused context
	InputContext *focusedContext = InputContext::focusedContext();
	if (focusedContext)
	    focusedContext->focusIn();

	pretrans_setup();
    }
}
void InputConfigFile::process(InputContext &input)
{
	//ファイル一行目のバージョン文字列を取得
	std::string version = input.nextToken();
	input.skipReturn();

	//バージョン文字列に応じたInputProcedureを実行する
	if(version == InputConfigFileEV3Linetracer_1_0::VERSION_STRING)
	{
		InputConfigFileEV3Linetracer_1_0 body(ev3LineTracer);
		body.process(input);
	}
	else
	{
		//バージョンが一致しなかったら例外を投げる
		throw  std::ios::failure("バージョンが不正です");
	}
}
Esempio n. 13
0
static void candwin_read_cb(int fd, int /* ev */)
{
    char buf[1024];
    int n;

    n = static_cast<int>(read(fd, buf, 1024 - 1));
    if (n == 0) {
	terminate_canddisp_connection();
	return;
    }
    if (n == -1)
	return;
    buf[n] = '\0';

    if (!strcmp(buf, "err")) {
	terminate_canddisp_connection();
	return;
    }

    InputContext *focusedContext = InputContext::focusedContext();
    if (focusedContext) {
	char *line = buf;
	char *eol = strchr(line, '\n');
	if (eol != NULL)
	    *eol = '\0';

	if (strcmp("index", line) == 0) {
	    line = eol + 1;
	    eol = strchr(line, '\n');
	    if (eol != NULL)
		*eol = '\0';

	    int index;
	    sscanf(line, "%d", &index);
	    focusedContext->candidate_select(index);
	    uim_set_candidate_index(focusedContext->getUC(), index);
	    // send packet queue for drawing on-the-spot preedit strings
	    focusedContext->get_ic()->force_send_packet();
	}
    }
    return;
}
/*
 <SingleState>::=
 <StateIndex><tab>;StateIndex
 <RefMax><tab>;RefMax
 <ControlCount>;ControlCount
 */
void ReadSingleState::process(InputContext &input)
{
	idx stateindex;
	real refmax;
	idx controlcount;

	//State[stateIndex]を読み取りev3LineTracerに設定する
	stateindex = StringToData::parseTo<idx>(input.nextToken());
	//読み取ったstateindexとstateIndexが異なっていれば例外発生
	if(stateindex != stateIndex)
	{
		std::string msg("invalid stateIndex");
		throw std::ios_base::failure(msg);
	}
	refmax = StringToData::parseTo<real>(input.nextToken());
	controlcount = StringToData::parseTo<idx>(input.nextToken());
	input.skipReturn();

	ev3LineTracer.setState(stateindex,refmax,controlcount);

}
Esempio n. 15
0
int HSV::start(const std::vector<std::string> &args)
{
	DisplayWindow window("ClanLib HSV Example", 1024, 768);
	Slot slot = window.sig_window_close().connect(this, &HSV::on_close);
	Slot slot_input_up = (window.get_ic().get_keyboard()).sig_key_up().connect(this, &HSV::on_input_up);

	Canvas canvas(window);
	InputContext ic = window.get_ic();
	ProgramObject program = create_shader_program(canvas);
	Texture texture = create_texture(canvas);

	clan::Font font(canvas, "tahoma", 24);

	ubyte64 last_time = System::get_time();

	float hue_offset = 0.0;
	while (!quit)
	{
		ubyte64 current_time = System::get_time();
		float time_delta_ms = static_cast<float> (current_time - last_time);
		last_time = current_time;

		if (ic.get_keyboard().get_keycode(keycode_left))
			hue_offset += 0.0005f * time_delta_ms;
		else if (ic.get_keyboard().get_keycode(keycode_right))
			hue_offset -= 0.0005f * time_delta_ms;
		if (hue_offset < -1.0f)
			hue_offset += 1.0f;
		if (hue_offset > 1.0f)
			hue_offset -= 1.0f;

		render_texture(canvas, program, texture, hue_offset);

		font.draw_text(canvas, 32, 700, "Use cursor keys left and right");
		window.flip();
		KeepAlive::process(10);
	}

	return 0;
}
Esempio n. 16
0
void InputContext::update_cb(void *ptr)
{
    InputContext *ic = (InputContext *)ptr;
    ic->update_preedit();
}
Esempio n. 17
0
void InputContext::pushback_cb(void *ptr, int attr, const char *str)
{
    InputContext *ic = (InputContext *)ptr;
    ic->pushback_preedit_string(attr, str);
}
Esempio n. 18
0
int HSV::start(const std::vector<std::string> &args)
{
    clan::SlotContainer cc;
	DisplayWindow window("ClanLib HSV Sprite", 1024, 768);
	cc.connect(window.sig_window_close(), clan::bind_member(this, &HSV::on_close));
	cc.connect(window.get_ic().get_keyboard().sig_key_up(), clan::bind_member(this, &HSV::on_input_up));
	Canvas canvas(window);
	InputContext ic = window.get_ic();

	clan::Font font(canvas, "Tahoma", -11);

	HSVSpriteBatch sprite_batcher(canvas);
	HSVSprite car1(canvas, &sprite_batcher, "../../Game/SpritesRTS/Gfx/spaceshoot_body_moving1.png");
	HSVSprite car2(canvas, &sprite_batcher, "Resources/ferrari_maranello.png");
	HSVSprite *cars[] = { &car1, &car2 };

	ubyte64 last_fps_update = System::get_time();
	ubyte64 last_time = last_fps_update;

	int fps = 0;
	std::string fps_text;

	float hue_offset = 0.0;
	while (!quit)
	{
		ubyte64 current_time = System::get_time();
		float time_delta_ms = static_cast<float> (current_time - last_time);
		last_time = current_time;

		if (ic.get_keyboard().get_keycode(keycode_left))
			hue_offset += 0.0005f * time_delta_ms;
		else if (ic.get_keyboard().get_keycode(keycode_right))
			hue_offset -= 0.0005f * time_delta_ms;
		if (hue_offset < -1.0f)
			hue_offset += 1.0f;
		if (hue_offset > 1.0f)
			hue_offset -= 1.0f;

		canvas.clear(Colorf::darkslategrey);
		float car_hue = hue_offset;
		for (int y = 0; y < 10; y++)
		{
			for (int x = 0; x < 7; x++)
			{
				cars[(x+y)%2]->draw(canvas, 60+x*128, 60+y*64, car_hue);

				car_hue += 0.02f;
				if (car_hue < -1.0f)
					car_hue += 1.0f;
				if (car_hue > 1.0f)
					car_hue -= 1.0f;
			}
		}

		fps++;
		if (System::get_time() - last_fps_update > 2000)
		{
			fps_text = string_format("%1 fps", fps/2.0f);
			last_fps_update = System::get_time();
			fps = 0;
		}

		Size fps_size = font.get_text_size(canvas, fps_text);
		font.draw_text(canvas, canvas.get_width()-10-fps_size.width, 16, fps_text);
		font.draw_text(canvas, 32, 730, "Use cursor keys left and right");

		window.flip(0);
		KeepAlive::process();
	}

	return 0;
}
Esempio n. 19
0
void InputContext::configuration_changed_cb(void *ptr)
{
    InputContext *ic = (InputContext *)ptr;

    ic->configuration_changed();
}
Esempio n. 20
0
void InputContext::switch_system_global_im_cb(void *ptr, const char *name)
{
    InputContext *ic = (InputContext *)ptr;

    ic->switch_system_global_im(name);
}
GUIWindowManagerProvider_Direct::GUIWindowManagerProvider_Direct(DisplayWindow &display_window, Canvas &canvas)
: site(0), activated_window(0), capture_mouse_window(NULL), display_window(display_window), window_canvas(canvas)
{
	slots.connect(display_window.sig_window_close(), this, &GUIWindowManagerProvider_Direct::on_displaywindow_window_close);

	InputContext ic = display_window.get_ic();
	slots.connect(ic.get_mouse().sig_key_up(), this, &GUIWindowManagerProvider_Direct::on_input_mouse_up);
	slots.connect(ic.get_mouse().sig_key_down(), this, &GUIWindowManagerProvider_Direct::on_input_mouse_down);
	slots.connect(ic.get_mouse().sig_key_dblclk(), this, &GUIWindowManagerProvider_Direct::on_input_mouse_down);
	slots.connect(ic.get_mouse().sig_pointer_move(), this, &GUIWindowManagerProvider_Direct::on_input_mouse_move);

	slots.connect(ic.get_keyboard().sig_key_up(), this, &GUIWindowManagerProvider_Direct::on_input);
	slots.connect(ic.get_keyboard().sig_key_down(), this, &GUIWindowManagerProvider_Direct::on_input);

	for (int tc = 0; tc < ic.get_tablet_count(); ++tc)
	{
		slots.connect(ic.get_tablet(tc).sig_axis_move(), this, &GUIWindowManagerProvider_Direct::on_input_mouse_move);
		slots.connect(ic.get_tablet(tc).sig_key_dblclk(), this, &GUIWindowManagerProvider_Direct::on_input_mouse_down);
		slots.connect(ic.get_tablet(tc).sig_key_down(), this, &GUIWindowManagerProvider_Direct::on_input_mouse_down);
		slots.connect(ic.get_tablet(tc).sig_key_up(), this, &GUIWindowManagerProvider_Direct::on_input);
	}

}
Esempio n. 22
0
void InputContext::candidate_shift_page_cb(void *ptr, int direction)
{
    InputContext *ic = (InputContext *)ptr;
    ic->candidate_shift_page(direction);
}
Esempio n. 23
0
WindowManagerProvider::WindowManagerProvider(DisplayWindow window)
: window(window), canvas(window.get_gc()), site(0), focus(0), mouse_capture(0), scale(1.0f), mouse_enabled(true), enabled(false)
{
	slots.connect(window.sig_resize(), this, &WindowManagerProvider::on_displaywindow_resize);

	InputContext ic = window.get_ic();
	slots.connect(ic.get_mouse().sig_key_up(), this, &WindowManagerProvider::on_mouse_input_received);
	slots.connect(ic.get_mouse().sig_key_down(), this, &WindowManagerProvider::on_mouse_input_received);
	slots.connect(ic.get_mouse().sig_key_dblclk(), this, &WindowManagerProvider::on_mouse_input_received);
	slots.connect(ic.get_mouse().sig_pointer_move(), this, &WindowManagerProvider::on_mouse_input_received);
	slots.connect(ic.get_keyboard().sig_key_up(), this, &WindowManagerProvider::on_input_received);
	slots.connect(ic.get_keyboard().sig_key_down(), this, &WindowManagerProvider::on_input_received);

	for (int i = 0; i < ic.get_tablet_count(); ++i)
	{
		slots.connect(ic.get_tablet(i).sig_axis_move(), this, &WindowManagerProvider::on_mouse_input_received);
		slots.connect(ic.get_tablet(i).sig_key_down(), this, &WindowManagerProvider::on_mouse_input_received);
		slots.connect(ic.get_tablet(i).sig_key_dblclk(), this, &WindowManagerProvider::on_mouse_input_received);
		slots.connect(ic.get_tablet(i).sig_key_up(), this, &WindowManagerProvider::on_mouse_input_received);
		slots.connect(ic.get_tablet(i).sig_proximity_change(), this, &WindowManagerProvider::on_mouse_input_received);
	}

#ifdef WIN32
	DataBuffer ani_file = File::read_bytes("Resources/Engine/Cursors/NormalSelect.ani");
	int desired_width = 32;
	int desired_height = 32;
	cursor = (HCURSOR)CreateIconFromResourceEx((PBYTE) ani_file.get_data(), ani_file.get_size(), FALSE, 0x00030000, desired_width, desired_height, LR_DEFAULTCOLOR);
	if (cursor == 0)
		throw Exception("CreateIconFromResourceEx failed!");
#endif
}
Esempio n. 24
0
void InputContext::clear_cb(void *ptr)
{
    InputContext *ic = (InputContext *)ptr;
    ic->clear_pe_stat();
}
Esempio n. 25
0
void InputContext::candidate_activate_cb(void *ptr, int nr, int display_limit)
{
    InputContext *ic = (InputContext *)ptr;
    ic->candidate_activate(nr, display_limit);
}
Esempio n. 26
0
void InputContext::candidate_select_cb(void *ptr, int index)
{
    InputContext *ic = (InputContext *)ptr;
    ic->set_need_hilite_selected_cand(true);
    ic->candidate_select(index);
}
Esempio n. 27
0
void InputContext::candidate_activate_with_delay_cb(void *ptr, int delay)
{
    InputContext *ic = (InputContext *)ptr;
    ic->candidate_activate_with_delay(delay);
}
Esempio n. 28
0
void InputContext::candidate_activate_timeout_cb(void *ptr)
{
    InputContext *ic = (InputContext *)ptr;
    ic->candidate_activate_timeout();
}
Esempio n. 29
0
int Editor::main(const std::vector<std::string> &args)
{
	
	std::string theme;
	if (clan::FileHelp::file_exists("Resources/GUIThemeAero/theme.css"))
		theme = "Resources/GUIThemeAero";
	else if (clan::FileHelp::file_exists("Resources/GUIThemeBasic/theme.css"))
		theme = "Resources/GUIThemeBasic";
	else
		throw clan::Exception("Not themes found");


	GUIManager gui(theme);
	clan::DisplayWindowDescription win_desc;
	win_desc.set_allow_resize(false);
	win_desc.set_title("Editor");
	win_desc.set_position(clan::Rect(100, 100, Size(SCREEN_WIDTH,SCREEN_HEIGHT)), false);

	window= new clan::GUIComponent (&gui, win_desc, "Window");
	window->func_close().set(this, &Editor::on_window_close, window);
	window->func_render().set(this, &Editor::on_window_draw);

	window->set_constant_repaint(true);

	InputContext ic = window->get_ic();
	device = ic.get_mouse();
	Slot slot = device.sig_key_up().connect(this, &Editor::on_right_mouse_click);


	GUIManager gui2(theme);
	clan::DisplayWindowDescription popup_desc;
	popup_desc.set_allow_resize(false);
	popup_desc.set_title("Properties");
	popup_desc.set_position(clan::Rect(100, 100, Size(300,100)), false);

	popupwindow = new clan::GUIComponent (&gui2, popup_desc, "Window");
	popupwindow->set_visible(false);

	clan::Label* label = new clan::Label(popupwindow);
	label->set_geometry(clan::Rect(0,0,clan::Size(40,20)));
	label->set_text("Nome");

	lineedit = new clan::LineEdit(popupwindow);
	lineedit->set_geometry(clan::Rect(40, 0, clan::Size(100, 30)));
	lineedit->set_text("LineEdit");

	clan::PushButton* OKButton = new clan::PushButton(popupwindow);
	OKButton->set_geometry(clan::Rect(10,40,clan::Size(70,30)));
	OKButton->set_text("OK");
	OKButton->func_clicked().set(this, &Editor::on_button_ok_clicked, OKButton);

	clan::PushButton* DeleteButton = new clan::PushButton(popupwindow);
	DeleteButton->set_geometry(clan::Rect(200,40,clan::Size(70,30)));
	DeleteButton->set_text("Delete");
	DeleteButton->func_clicked().set(this, &Editor::on_button_delete_clicked, DeleteButton);


	toMod = new Label(window);

	spin = new clan::Spin(popupwindow);
	spin->set_geometry(clan::Rect(100,40,Size(80,20)));



	clan::MenuBar mb(window);
	mb.set_geometry(clan::Rect(0, 0, Size(SCREEN_WIDTH,30)));
	clan::PopupMenu ppMenu;
	ppMenu.insert_item("New");
	ppMenu.insert_item("Open");
	ppMenu.insert_item("Close");
	ppMenu.set_minimum_width(100);
	mb.add_menu("File",ppMenu);


	clan::Image actor(window->get_canvas(), "Resources/actor.png");

	clan::ImageView actorCreator(window);
	actorCreator.set_image(actor);
	actorCreator.set_geometry(clan::Rect(0,SCREEN_HEIGHT-actor.get_height(),Size(actor.get_width()*0.75,actor.get_height()*0.75)));
	actorCreator.func_input_pressed().set(this,&Editor::actor_create);

	clan::Label newLabel(&actorCreator);
	newLabel.set_geometry(clan::Rect(actor.get_width()*0.25,actor.get_height()*0.25,Size(100,20)));//0.25 -> circa metà dell'immagine ridimensionata
	newLabel.set_text("New Actor");



	font = new clan::Font(window->get_canvas(),"tahoma",FONT_SIZE);




	gui.exec();

	return 0;
}
Esempio n. 30
0
void InputContext::candidate_deactivate_cb(void *ptr)
{
    InputContext *ic = (InputContext *)ptr;
    ic->candidate_deactivate();
}