Ejemplo n.º 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);
	}

}
Ejemplo n.º 3
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;
}
Ejemplo n.º 4
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);
}