Beispiel #1
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
}
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);
	}

}
Beispiel #3
0
void GUIWindowManagerProvider_System::create_window(
    GUITopLevelWindow *handle,
    GUITopLevelWindow *owner,
    GUIComponent *component,
    GUITopLevelDescription description)
{
    description.set_update_supported(true);

    GUITopLevelWindowSystem *owner_window = 0;
    if (owner)
    {
        owner_window = window_map[owner];
        description.set_owner_window(owner_window->window);
    }

    GUITopLevelWindowSystem *top_level_window;

#ifdef WIN32	// Cached windows do not work on Linux
    if (description.get_using_gui_window_cache())
    {
        used_cached_windows++;

        if (used_cached_windows <= cached_windows.size())
        {
            top_level_window = cached_windows[used_cached_windows-1];
            top_level_window->slots = SlotContainer();
            cache_window_handles[handle] = top_level_window->window.get_hwnd();
        }
        else
        {
            top_level_window = new GUITopLevelWindowSystem;
            top_level_window->window = DisplayWindow(description);
            top_level_window->canvas = Canvas(top_level_window->window);
            cached_windows.push_back(top_level_window);
            cache_window_handles[handle] = top_level_window->window.get_hwnd();
        }
    }
    else
#endif
    {
        top_level_window = new GUITopLevelWindowSystem;
        top_level_window->window = DisplayWindow(description);
        top_level_window->canvas = Canvas(top_level_window->window);
    }

    top_level_window->canvas.set_map_mode(map_2d_upper_left);

    top_level_window->slots.connect(top_level_window->window.sig_lost_focus(), this, &GUIWindowManagerProvider_System::on_displaywindow_lost_focus, handle);
    top_level_window->slots.connect(top_level_window->window.sig_got_focus(), this, &GUIWindowManagerProvider_System::on_displaywindow_got_focus, handle);
    top_level_window->slots.connect(top_level_window->window.sig_resize(), this, &GUIWindowManagerProvider_System::on_displaywindow_resize, handle);
    top_level_window->slots.connect(top_level_window->window.sig_paint(), this, &GUIWindowManagerProvider_System::on_displaywindow_paint, handle);
    top_level_window->slots.connect(top_level_window->window.sig_window_close(), this, &GUIWindowManagerProvider_System::on_displaywindow_window_close, handle);
    top_level_window->slots.connect(top_level_window->window.sig_window_destroy(), this, &GUIWindowManagerProvider_System::on_displaywindow_window_destroy, handle);

    InputContext ic = top_level_window->window.get_ic();
    top_level_window->slots.connect(ic.get_mouse().sig_key_up(), this, &GUIWindowManagerProvider_System::on_input, handle);
    top_level_window->slots.connect(ic.get_mouse().sig_key_down(), this, &GUIWindowManagerProvider_System::on_input, handle);
    top_level_window->slots.connect(ic.get_mouse().sig_key_dblclk(), this, &GUIWindowManagerProvider_System::on_input, handle);
    top_level_window->slots.connect(ic.get_mouse().sig_pointer_move(), this, &GUIWindowManagerProvider_System::on_input, handle);
    top_level_window->slots.connect(ic.get_keyboard().sig_key_up(), this, &GUIWindowManagerProvider_System::on_input, handle);
    top_level_window->slots.connect(ic.get_keyboard().sig_key_down(), this, &GUIWindowManagerProvider_System::on_input, handle);

    for (int i = 0; i < ic.get_tablet_count(); ++i)
    {
        top_level_window->slots.connect(ic.get_tablet(i).sig_axis_move(), this, &GUIWindowManagerProvider_System::on_input, handle);
        top_level_window->slots.connect(ic.get_tablet(i).sig_key_down(), this, &GUIWindowManagerProvider_System::on_input, handle);
        top_level_window->slots.connect(ic.get_tablet(i).sig_key_dblclk(), this, &GUIWindowManagerProvider_System::on_input, handle);
        top_level_window->slots.connect(ic.get_tablet(i).sig_key_up(), this, &GUIWindowManagerProvider_System::on_input, handle);
        top_level_window->slots.connect(ic.get_tablet(i).sig_proximity_change(), this, &GUIWindowManagerProvider_System::on_input, handle);
    }

    window_map[handle] = top_level_window;

    sig_toplevel_window_created.invoke(top_level_window->window);
}