コード例 #1
0
void MainWindow::on_resized()
{
	CL_Rect client_area = get_client_area();

	menubar->set_geometry(CL_Rect(client_area.left, client_area.top, client_area.right, client_area.top + 22));
	workspace->set_geometry(CL_Rect(client_area.left, client_area.top + 22, client_area.right, client_area.bottom));
}
コード例 #2
0
ファイル: theme.cpp プロジェクト: wbyang1985/ClanLib
Theme::Theme(clan::GUIManager &manager, gui_theme default_theme) : current_theme(default_theme),
	clan::Window(&manager, clan::GUITopLevelDescription("Window Theme", clan::Rect(256*3 + 32, 256 + 180 + 24, clan::Size(256, 180)), false))
{

	func_close() = bind_member(this, &Theme::on_close);

	clan::Rect client_area = get_client_area();

	groupbox = new clan::GroupBox(this);
	groupbox->set_geometry(clan::Rect(client_area.left + 5, client_area.top + 5, client_area.right - 5, client_area.bottom - 5));

	int xoffset = client_area.left + 100;
	int yoffset = client_area.top + 4;
	int ygap = 20;

	radiobutton_aero = new clan::RadioButton(this);
	radiobutton_aero->set_geometry(clan::Rect(xoffset, yoffset , clan::Size(96, 24)));
	radiobutton_aero->set_text("Aero");
	radiobutton_aero->set_selected(default_theme == theme_aero);
	radiobutton_aero->set_group_name("Theme");
	radiobutton_aero->func_selected() = [=](){on_theme_selected(radiobutton_aero);};
	yoffset += ygap;

	radiobutton_aero_packed = new clan::RadioButton(this);
	radiobutton_aero_packed->set_geometry(clan::Rect(xoffset, yoffset , clan::Size(96, 24)));
	radiobutton_aero_packed->set_text("Aero Packed");
	radiobutton_aero_packed->set_selected(default_theme == theme_aero_packed);
	radiobutton_aero_packed->set_group_name("Theme");
	radiobutton_aero_packed->func_selected() = [=](){on_theme_selected(radiobutton_aero_packed); };
	yoffset += ygap;

	radiobutton_basic = new clan::RadioButton(this);
	radiobutton_basic->set_geometry(clan::Rect(xoffset, yoffset , clan::Size(96, 24)));
	radiobutton_basic->set_text("Basic");
	radiobutton_basic->set_selected(default_theme == theme_basic);
	radiobutton_basic->set_group_name("Theme");
	radiobutton_basic->func_selected() = [=](){on_theme_selected(radiobutton_basic); };
	yoffset += ygap;

	radiobutton_basic_packed = new clan::RadioButton(this);
	radiobutton_basic_packed->set_geometry(clan::Rect(xoffset, yoffset , clan::Size(96, 24)));
	radiobutton_basic_packed->set_text("Basic Packed");
	radiobutton_basic_packed->set_selected(default_theme == theme_basic_packed);
	radiobutton_basic_packed->set_group_name("Theme");
	radiobutton_basic_packed->func_selected() = [=](){on_theme_selected(radiobutton_basic_packed); };
	yoffset += ygap;

	if (!clan::FileHelp::file_exists("../../../Resources/GUIThemeAero/theme.css"))
	{
		radiobutton_aero->set_enabled(false);
		radiobutton_aero_packed->set_enabled(false);
		radiobutton_basic->set_selected(true);

	}


}
コード例 #3
0
PushButton::PushButton(GUI *gui) : 
	CL_Window(&gui->get_gui_manager(), CL_GUITopLevelDescription("PushButton", CL_Rect(256 + 16, 256 + 16, CL_Size(256, 180)), false)),
	gui(gui)
{
	CL_GraphicContext gc = gui->get_window()->get_gc();
	test_image = CL_Image(gc, "tux", &gui->get_resources_internal());

	set_draggable(true);

	CL_Rect client_area = get_client_area();

	pushbutton1 = new CL_PushButton(this);
	pushbutton1->set_geometry(CL_Rect(client_area.left + 11, client_area.top + 10, CL_Size(128, 40)));
	pushbutton1->set_text("Push Button");
	pushbutton1->set_flat(false);
	pushbutton1->func_clicked().set(this, &PushButton::on_clicked, pushbutton1);

	int label_xpos = client_area.left + 31;
	int yoffset = client_area.top + 80;
	CL_Size label_size(50, 15);
	const int gap = 16;

	checkbox_flat = new CL_CheckBox(this);
	checkbox_flat->set_geometry(CL_Rect(client_area.left + 11, yoffset, CL_Size(100, 15)));
	checkbox_flat->func_checked().set(this, &PushButton::on_checked_flat, checkbox_flat);
	checkbox_flat->func_unchecked().set(this, &PushButton::on_unchecked_flat, checkbox_flat);
	checkbox_flat->set_text("Flat");

	yoffset+=gap;
	checkbox_icon = new CL_CheckBox(this);
	checkbox_icon->set_geometry(CL_Rect(client_area.left + 11, yoffset, CL_Size(100, 15)));
	checkbox_icon->func_checked().set(this, &PushButton::on_checked_icon, checkbox_icon);
	checkbox_icon->func_unchecked().set(this, &PushButton::on_unchecked_icon, checkbox_icon);
	checkbox_icon->set_text("Icon");

	yoffset+=gap;
	checkbox_toggle = new CL_CheckBox(this);
	checkbox_toggle->set_geometry(CL_Rect(client_area.left + 11, yoffset, CL_Size(100, 15)));
	checkbox_toggle->func_checked().set(this, &PushButton::on_checked_toggle, checkbox_toggle);
	checkbox_toggle->func_unchecked().set(this, &PushButton::on_unchecked_toggle, checkbox_toggle);
	checkbox_toggle->set_text("Enable Toggle");

	yoffset+=gap;
	checkbox_disable = new CL_CheckBox(this);
	checkbox_disable->set_geometry(CL_Rect(client_area.left + 11, yoffset, CL_Size(100, 15)));
	checkbox_disable->func_checked().set(this, &PushButton::on_checked_disable, checkbox_disable);
	checkbox_disable->func_unchecked().set(this, &PushButton::on_unchecked_disable, checkbox_disable);
	checkbox_disable->set_text("Disable");

	int xoffset = client_area.left + 36;
	yoffset = client_area.top + 60;

	info_clicked = new Info(gui, this);
	info_clicked->set(xoffset, yoffset, "Clicked");
}
コード例 #4
0
void CSSBrowser::on_resized()
{
	CL_Rect client_box = get_client_area();
	int height = 38;
	CL_Rect toolbar_box(client_box.left, client_box.top, client_box.right, client_box.top + height);
	toolbar_box.shrink(11,11,11,5);
	CL_Rect label_box(toolbar_box.left, toolbar_box.top, toolbar_box.left+50, toolbar_box.bottom);
	CL_Rect edit_box(label_box.right, label_box.top, toolbar_box.right, label_box.bottom);
	CL_Rect view_box(client_box.left, client_box.top + height, client_box.right, client_box.bottom);
	label->set_geometry(label_box);
	edit->set_geometry(edit_box);
	view->set_geometry(view_box);
}
コード例 #5
0
ファイル: spin.cpp プロジェクト: wbyang1985/ClanLib
Spin::Spin(clan::GUIManager &manager) :
	clan::Window(&manager, clan::GUITopLevelDescription("Spin", clan::Rect(256*3 + 32, 256 + 16, clan::Size(256, 180)), false))
{

	func_close() = bind_member(this, &Spin::on_close);

	clan::Rect client_area = get_client_area();

	spin1 = new clan::Spin(this);
	spin1->set_geometry(clan::Rect(client_area.left + 11, client_area.top + 10, clan::Size(128, 21)));
	spin1->set_number_of_decimal_places(2);
	spin1->set_value(500);
	spin1->set_step_size(50);
	spin1->set_ranges(200, 2000);
	spin1->set_floating_point_mode(false);
	spin1->func_value_changed() = bind_member(this, &Spin::on_value_changed);

	int xoffset = client_area.left + 16;
	int yoffset = client_area.top + 40;
	const int gap = 16;
	clan::Size label_size(50, 15);

	info_value_changed = new Info(this);
	info_value_changed->set(xoffset, yoffset, "Value Changed");
	yoffset += gap;

	clan::Size lineedit_size(48, 20);
	int lineedit_xpos = client_area.left + 6;
	int label_xpos = client_area.left + 56;
	int lineedit_ypos = client_area.top + 60;
	const int lineedit_gap = 25;

	lineedit_value = new clan::LineEdit(this);
	lineedit_value->set_geometry(clan::Rect(lineedit_xpos, lineedit_ypos, lineedit_size));
	lineedit_value->set_text("500");
	lineedit_value->set_numeric_mode(true);
	lineedit_value->func_enter_pressed() = bind_member(this, &Spin::on_value_enter_pressed);

	lineedit_label_value = new clan::Label(this);
	lineedit_label_value->set_geometry(clan::Rect(label_xpos, lineedit_ypos, label_size));
	lineedit_label_value->set_text("Value");
	lineedit_ypos += lineedit_gap;

	lineedit_decimal_places = new clan::LineEdit(this);
	lineedit_decimal_places->set_geometry(clan::Rect(lineedit_xpos, lineedit_ypos, lineedit_size));
	lineedit_decimal_places->set_text("2");
	lineedit_decimal_places->set_numeric_mode(true, true);
	lineedit_decimal_places->func_enter_pressed() = bind_member(this, &Spin::on_decimal_places_enter_pressed);

	lineedit_label_decimal_places = new clan::Label(this);
	lineedit_label_decimal_places->set_geometry(clan::Rect(label_xpos, lineedit_ypos, label_size));
	lineedit_label_decimal_places->set_text("Decimal Places");
	lineedit_ypos += lineedit_gap;
	lineedit_decimal_places->set_enabled(false);

	lineedit_xpos = client_area.left + 146;
	label_xpos = client_area.left + 196;
	lineedit_ypos = client_area.top + 10;

	lineedit_min = new clan::LineEdit(this);
	lineedit_min->set_geometry(clan::Rect(lineedit_xpos, lineedit_ypos, lineedit_size));
	lineedit_min->set_text("200");
	lineedit_min->set_numeric_mode(true, true);
	lineedit_min->func_enter_pressed() = bind_member(this, &Spin::on_min_enter_pressed);

	lineedit_label_min = new clan::Label(this);
	lineedit_label_min->set_geometry(clan::Rect(label_xpos, lineedit_ypos, label_size));
	lineedit_label_min->set_text("Min");
	lineedit_ypos += lineedit_gap;

	lineedit_max = new clan::LineEdit(this);
	lineedit_max->set_geometry(clan::Rect(lineedit_xpos, lineedit_ypos, lineedit_size));
	lineedit_max->set_text("2000");
	lineedit_max->set_numeric_mode(true, true);
	lineedit_max->func_enter_pressed() = bind_member(this, &Spin::on_max_enter_pressed);

	lineedit_label_max = new clan::Label(this);
	lineedit_label_max->set_geometry(clan::Rect(label_xpos, lineedit_ypos, label_size));
	lineedit_label_max->set_text("Max");
	lineedit_ypos += lineedit_gap;

	lineedit_step = new clan::LineEdit(this);
	lineedit_step->set_geometry(clan::Rect(lineedit_xpos, lineedit_ypos, lineedit_size));
	lineedit_step->set_text("50");
	lineedit_step->set_numeric_mode(true, true);
	lineedit_step->func_enter_pressed() = bind_member(this, &Spin::on_step_enter_pressed);

	lineedit_label_step = new clan::Label(this);
	lineedit_label_step->set_geometry(clan::Rect(label_xpos, lineedit_ypos, label_size));
	lineedit_label_step->set_text("Step");
	lineedit_ypos += lineedit_gap;

	pushbutton_apply = new clan::PushButton(this);
	pushbutton_apply->set_geometry(clan::Rect(lineedit_xpos, lineedit_ypos, clan::Size(48, 20)));
	pushbutton_apply->set_text("Apply");
	pushbutton_apply->func_clicked() = bind_member(this, &Spin::on_apply_clicked);

	xoffset = client_area.left + 1;
	yoffset = client_area.top + 126 - gap;

	checkbox_fp_mode = new clan::CheckBox(this);
	checkbox_fp_mode->set_geometry(clan::Rect(xoffset, yoffset, clan::Size(100, 15)));
	checkbox_fp_mode->func_checked() = bind_member(this, &Spin::on_checked_fp_mode);
	checkbox_fp_mode->func_unchecked() = bind_member(this, &Spin::on_unchecked_fp_mode);
	checkbox_fp_mode->set_text("Floating Point Mode");

	yoffset += gap;

	checkbox_disable = new clan::CheckBox(this);
	checkbox_disable->set_geometry(clan::Rect(xoffset, yoffset, clan::Size(100, 15)));
	checkbox_disable->func_checked() = bind_member(this, &Spin::on_checked_disable);
	checkbox_disable->func_unchecked() = bind_member(this, &Spin::on_unchecked_disable);
	checkbox_disable->set_text("Disable");
}
コード例 #6
0
ファイル: slider.cpp プロジェクト: Cassie90/ClanLib
Slider::Slider(clan::GUIManager &manager) : 
	clan::Window(&manager, clan::GUITopLevelDescription("Slider", clan::Rect(256 + 16, 8, clan::Size(256, 256)), false))
{

	func_close().set(this, &Slider::on_close);

	clan::Rect client_area = get_client_area();

	slider_vertical = new clan::Slider(this);
	slider_vertical->set_geometry(clan::Rect(client_area.left + 1, client_area.top + 10, clan::Size(17, 200)));
	slider_vertical->set_vertical(true);
	slider_vertical->set_horizontal(false);
	slider_vertical->set_min(0);
	slider_vertical->set_max(100);
	slider_vertical->set_tick_count(10);
	slider_vertical->set_page_step(40);
	slider_vertical->set_position(50);
	slider_vertical->set_lock_to_ticks(false);
	slider_vertical->func_value_changed().set(this, &Slider::on_value_changed, slider_vertical);
	slider_vertical->func_value_decremented().set(this, &Slider::on_value_decremented, slider_vertical);
	slider_vertical->func_value_incremented().set(this, &Slider::on_value_incremented, slider_vertical);
	slider_vertical->func_slider_moved().set(this, &Slider::on_slider_moved, slider_vertical);

	slider_horizontal = new clan::Slider(this);
	slider_horizontal->set_geometry(clan::Rect(client_area.left + 36, client_area.top + 10, clan::Size(200, 17)));
	slider_horizontal->set_vertical(false);
	slider_horizontal->set_horizontal(true);
	slider_horizontal->set_min(0);
	slider_horizontal->set_max(100);
	slider_horizontal->set_tick_count(10);
	slider_horizontal->set_page_step(40);
	slider_horizontal->set_position(50);
	slider_horizontal->set_lock_to_ticks(false);
	slider_horizontal->func_value_changed().set(this, &Slider::on_value_changed, slider_horizontal);
	slider_horizontal->func_value_decremented().set(this, &Slider::on_value_decremented, slider_horizontal);
	slider_horizontal->func_value_incremented().set(this, &Slider::on_value_incremented, slider_horizontal);
	slider_horizontal->func_slider_moved().set(this, &Slider::on_slider_moved, slider_horizontal);

	clan::Size lineedit_size(42, 20);
	clan::Size label_size(50, 15);
	int lineedit_xpos = client_area.left + 146;
	int label_xpos = client_area.left + 190;

	int lineedit_ypos = client_area.top + 40;
	const int lineedit_gap = 25;

	lineedit_min = new clan::LineEdit(this);
	lineedit_min->set_geometry(clan::Rect(lineedit_xpos, lineedit_ypos, lineedit_size));
	lineedit_min->set_text("0");
	lineedit_min->set_numeric_mode(true);
	lineedit_min->func_enter_pressed().set(this, &Slider::on_min_enter_pressed, lineedit_min);

	lineedit_label_min = new clan::Label(this);
	lineedit_label_min->set_geometry(clan::Rect(label_xpos, lineedit_ypos, label_size));
	lineedit_label_min->set_text("Min");
	lineedit_ypos += lineedit_gap;

	lineedit_max = new clan::LineEdit(this);
	lineedit_max->set_geometry(clan::Rect(lineedit_xpos, lineedit_ypos, lineedit_size));
	lineedit_max->set_text("100");
	lineedit_max->set_numeric_mode(true);
	lineedit_max->func_enter_pressed().set(this, &Slider::on_max_enter_pressed, lineedit_max);

	lineedit_label_max = new clan::Label(this);
	lineedit_label_max->set_geometry(clan::Rect(label_xpos, lineedit_ypos, label_size));
	lineedit_label_max->set_text("Max");
	lineedit_ypos += lineedit_gap;

	lineedit_tick_count = new clan::LineEdit(this);
	lineedit_tick_count->set_geometry(clan::Rect(lineedit_xpos, lineedit_ypos, lineedit_size));
	lineedit_tick_count->set_text("10");
	lineedit_tick_count->func_enter_pressed().set(this, &Slider::on_tick_count_enter_pressed, lineedit_tick_count);

	lineedit_label_tick_count = new clan::Label(this);
	lineedit_label_tick_count->set_geometry(clan::Rect(label_xpos, lineedit_ypos, label_size));
	lineedit_label_tick_count->set_text("Tick Count");
	lineedit_ypos += lineedit_gap;

	lineedit_page_step = new clan::LineEdit(this);
	lineedit_page_step->set_geometry(clan::Rect(lineedit_xpos, lineedit_ypos, lineedit_size));
	lineedit_page_step->set_text("40");
	lineedit_page_step->func_enter_pressed().set(this, &Slider::on_page_step_enter_pressed, lineedit_page_step);

	lineedit_label_page_step = new clan::Label(this);
	lineedit_label_page_step->set_geometry(clan::Rect(label_xpos, lineedit_ypos, label_size));
	lineedit_label_page_step->set_text("Page Step");
	lineedit_ypos += lineedit_gap;

	lineedit_position_vert = new clan::LineEdit(this);
	lineedit_position_vert->set_geometry(clan::Rect(lineedit_xpos, lineedit_ypos, lineedit_size));
	lineedit_position_vert->set_text("50");
	lineedit_position_vert->func_enter_pressed().set(this, &Slider::on_position_enter_pressed_vert, lineedit_position_vert);

	lineedit_label_position_vert = new clan::Label(this);
	lineedit_label_position_vert->set_geometry(clan::Rect(label_xpos, lineedit_ypos, label_size));
	lineedit_label_position_vert->set_text("Vertical");
	lineedit_ypos += lineedit_gap;

	lineedit_position_horiz = new clan::LineEdit(this);
	lineedit_position_horiz->set_geometry(clan::Rect(lineedit_xpos, lineedit_ypos, lineedit_size));
	lineedit_position_horiz->set_text("50");
	lineedit_position_horiz->func_enter_pressed().set(this, &Slider::on_position_enter_pressed_horiz, lineedit_position_horiz);

	lineedit_label_position_horiz = new clan::Label(this);
	lineedit_label_position_horiz->set_geometry(clan::Rect(label_xpos, lineedit_ypos, label_size));
	lineedit_label_position_horiz->set_text("Horizonal");
	lineedit_ypos += lineedit_gap;

	pushbutton_apply = new clan::PushButton(this);
	pushbutton_apply->set_geometry(clan::Rect(lineedit_xpos, lineedit_ypos, clan::Size(48, 20)));
	pushbutton_apply->set_text("Apply");
	pushbutton_apply->func_clicked().set(this, &Slider::on_apply_clicked, pushbutton_apply);

	int xoffset = client_area.left + 21;
	int yoffset = client_area.top + 35;
	const int gap = 16;

	info_value_changed = new Info(this);
	info_value_changed->set(xoffset, yoffset, "Value Changed");
	yoffset += gap;

	info_value_decremented = new Info(this);
	info_value_decremented->set(xoffset, yoffset, "Value Decr.");
	yoffset += gap;

	info_value_incremented = new Info(this);
	info_value_incremented->set(xoffset, yoffset, "Value Incr.");
	yoffset += gap;

	info_slider_moved = new Info(this);
	info_slider_moved->set(xoffset, yoffset, "Slider Moved");
	yoffset += gap;

	xoffset = client_area.left + 36;
	yoffset = client_area.top + 195 - gap;

	checkbox_lock_to_ticks = new clan::CheckBox(this);
	checkbox_lock_to_ticks->set_geometry(clan::Rect(xoffset, yoffset, clan::Size(100, 15)));
	checkbox_lock_to_ticks->func_checked().set(this, &Slider::on_checked_lock_to_ticks, checkbox_lock_to_ticks);
	checkbox_lock_to_ticks->func_unchecked().set(this, &Slider::on_unchecked_lock_to_ticks, checkbox_lock_to_ticks);
	checkbox_lock_to_ticks->set_text("Lock to Ticks");

	yoffset += gap;

	checkbox_disable = new clan::CheckBox(this);
	checkbox_disable->set_geometry(clan::Rect(xoffset, yoffset, clan::Size(100, 15)));
	checkbox_disable->func_checked().set(this, &Slider::on_checked_disable, checkbox_disable);
	checkbox_disable->func_unchecked().set(this, &Slider::on_unchecked_disable, checkbox_disable);
	checkbox_disable->set_text("Disable");
}
コード例 #7
0
ファイル: lineedit.cpp プロジェクト: Cassie90/ClanLib
LineEdit::LineEdit(clan::GUIManager &manager) :
	clan::Window(&manager, clan::GUITopLevelDescription("Line Edit", clan::Rect(512 + 24, 8, clan::Size(256, 256)), false))
{
	func_close().set(this, &LineEdit::on_close);


	clan::Rect client_area = get_client_area();

	lineedit1 = new clan::LineEdit(this);
	lineedit1->set_geometry(clan::Rect(client_area.left + 11, client_area.top + 10, clan::Size(128, 21)));
	lineedit1->set_text("Line Edit");

	lineedit1->func_before_edit_changed().set(this, &LineEdit::on_before_edit_changed, lineedit1);
	lineedit1->func_after_edit_changed().set(this, &LineEdit::on_after_edit_changed, lineedit1);
	lineedit1->func_selection_changed().set(this, &LineEdit::on_selection_changed, lineedit1);
	lineedit1->func_focus_gained().set(this, &LineEdit::on_focus_gained, lineedit1);
	lineedit1->func_focus_lost().set(this, &LineEdit::on_focus_lost, lineedit1);
	lineedit1->func_enter_pressed().set(this, &LineEdit::on_enter_pressed, lineedit1);

	int xoffset = client_area.left + 96;
	int yoffset = client_area.top + 40;
	const int gap = 16;

	info_before_edit_changed = new Info(this);
	info_before_edit_changed->set(xoffset, yoffset, "Before Edit Changed");
	yoffset += gap;
	info_after_edit_changed = new Info(this);
	info_after_edit_changed->set(xoffset, yoffset, "After Edit Changed");
	yoffset += gap;
	info_selection_changed = new Info(this);
	info_selection_changed->set(xoffset, yoffset, "Selection Changed");
	yoffset += gap;
	info_focus_gained = new Info(this);
	info_focus_gained->set(xoffset, yoffset, "Focus Gained");
	yoffset += gap;
	info_focus_lost = new Info(this);
	info_focus_lost->set(xoffset, yoffset, "Focus Lost");
	yoffset += gap;
	info_enter_pressed = new Info(this);
	info_enter_pressed->set(xoffset, yoffset, "Enter Pressed");
	yoffset += gap;

	xoffset = client_area.left + 1;
	yoffset = client_area.top + 195 - gap*8;
	clan::Size label_size(50, 15);

	checkbox_mask_hex = new clan::CheckBox(this);
	checkbox_mask_hex->set_geometry(clan::Rect(xoffset, yoffset, clan::Size(100, 15)));
	checkbox_mask_hex->func_checked().set(this, &LineEdit::on_checked_mask_hex, checkbox_mask_hex);
	checkbox_mask_hex->func_unchecked().set(this, &LineEdit::on_unchecked_mask_hex, checkbox_mask_hex);
	checkbox_mask_hex->set_text("Hex Mask");

	yoffset+=gap;
	checkbox_read_only = new clan::CheckBox(this);
	checkbox_read_only->set_geometry(clan::Rect(xoffset, yoffset, clan::Size(100, 15)));
	checkbox_read_only->func_checked().set(this, &LineEdit::on_checked_read_only, checkbox_read_only);
	checkbox_read_only->func_unchecked().set(this, &LineEdit::on_unchecked_read_only, checkbox_read_only);
	checkbox_read_only->set_text("Read Only");

	yoffset+=gap;
	checkbox_lowercase = new clan::CheckBox(this);
	checkbox_lowercase->set_geometry(clan::Rect(xoffset, yoffset, clan::Size(100, 15)));
	checkbox_lowercase->func_checked().set(this, &LineEdit::on_checked_lowercase, checkbox_lowercase);
	checkbox_lowercase->func_unchecked().set(this, &LineEdit::on_unchecked_lowercase, checkbox_lowercase);
	checkbox_lowercase->set_text("Lowercase");

	yoffset+=gap;
	checkbox_uppercase = new clan::CheckBox(this);
	checkbox_uppercase->set_geometry(clan::Rect(xoffset, yoffset, clan::Size(100, 15)));
	checkbox_uppercase->func_checked().set(this, &LineEdit::on_checked_uppercase, checkbox_uppercase);
	checkbox_uppercase->func_unchecked().set(this, &LineEdit::on_unchecked_uppercase, checkbox_uppercase);
	checkbox_uppercase->set_text("Uppercase");

	yoffset+=gap;
	checkbox_password_mode = new clan::CheckBox(this);
	checkbox_password_mode->set_geometry(clan::Rect(xoffset, yoffset, clan::Size(100, 15)));
	checkbox_password_mode->func_checked().set(this, &LineEdit::on_checked_password_mode, checkbox_password_mode);
	checkbox_password_mode->func_unchecked().set(this, &LineEdit::on_unchecked_password_mode, checkbox_password_mode);
	checkbox_password_mode->set_text("Password Mode");

	yoffset+=gap;
	checkbox_numeric_mode = new clan::CheckBox(this);
	checkbox_numeric_mode->set_geometry(clan::Rect(xoffset, yoffset, clan::Size(100, 15)));
	checkbox_numeric_mode->func_checked().set(this, &LineEdit::on_checked_numeric_mode, checkbox_numeric_mode);
	checkbox_numeric_mode->func_unchecked().set(this, &LineEdit::on_unchecked_numeric_mode, checkbox_numeric_mode);
	checkbox_numeric_mode->set_text("Numeric Mode");

	yoffset+=gap;
	checkbox_numeric_mode_decimals = new clan::CheckBox(this);
	checkbox_numeric_mode_decimals->set_geometry(clan::Rect(xoffset, yoffset, clan::Size(100, 15)));
	checkbox_numeric_mode_decimals->func_checked().set(this, &LineEdit::on_checked_numeric_mode_decimals, checkbox_numeric_mode_decimals);
	checkbox_numeric_mode_decimals->func_unchecked().set(this, &LineEdit::on_unchecked_numeric_mode_decimals, checkbox_numeric_mode_decimals);
	checkbox_numeric_mode_decimals->set_text("Numeric Mode Decimals");
	checkbox_numeric_mode_decimals->set_enabled(false);

	yoffset+=gap;
	pushbutton_resize = new clan::PushButton(this);
	pushbutton_resize->set_geometry(clan::Rect(xoffset, yoffset, clan::Size(64, 20)));
	pushbutton_resize->set_text("Resize");
	pushbutton_resize->func_clicked().set(this, &LineEdit::on_resize_clicked, pushbutton_resize);

	yoffset+=gap+4;
	checkbox_disable = new clan::CheckBox(this);
	checkbox_disable->set_geometry(clan::Rect(xoffset, yoffset, clan::Size(100, 15)));
	checkbox_disable->func_checked().set(this, &LineEdit::on_checked_disable, checkbox_disable);
	checkbox_disable->func_unchecked().set(this, &LineEdit::on_unchecked_disable, checkbox_disable);
	checkbox_disable->set_text("Disable");

	xoffset = client_area.left + 101;
	yoffset = client_area.top + 190;
	menu_settext.insert_item("(Settings)");
	menu_settext.insert_item("Set Align: Left");
	menu_settext.insert_item("Set Align: Centre");
	menu_settext.insert_item("Set Align: Right");
	menu_settext.insert_item("Set Text: Hello World");
	menu_settext.insert_item("Set Integer: 1234");
	menu_settext.insert_item("Set Float: 123.456");
	menu_settext.insert_item("Select: All");
	menu_settext.insert_item("Select: 2nd to 5th char");
	menu_settext.insert_item("Select: None");

	combo_settext = new clan::ComboBox(this);
	combo_settext->set_geometry(clan::Rect(xoffset, yoffset, clan::Size(130, 20)));
	combo_settext->set_editable(false);
	combo_settext->set_dropdown_height(128);
	combo_settext->set_dropdown_minimum_width(64);
	combo_settext->set_popup_menu(menu_settext);
	combo_settext->set_selected_item(0);
	combo_settext->func_item_selected().set(this, &LineEdit::on_settext_selected, combo_settext);
}
コード例 #8
0
ファイル: filterbar.cpp プロジェクト: kjradv/Isotoxin
/*virtual*/ bool gui_filterbar_c::sq_evt(system_query_e qp, RID rid, evt_data_s &data)
{
    switch(qp)
    {
    case SQ_RECT_CHANGED:
        {
            ts::irect cla = get_client_area();
            fake_margin.x = 5;
            fake_margin.y = 0;
            if (prf().get_options().is(UIOPT_TAGFILETR_BAR))
            {
                if (!textrect.get_text().is_empty())
                {
                    ts::ivec2 sz = textrect.calc_text_size(cla.width() - 10, custom_tag_parser_delegate());
                    sz.y += 3;
                    textrect.set_size(sz);
                }
            }
            if (edit)
            {
                MODIFY(*edit).pos(cla.lt).size(cla.width(), filtereditheight);
                fake_margin.y += filtereditheight;

            }
            if (option1)
            {
                int omy = option1->get_min_size().y;
                MODIFY( *option1 ).pos( cla.lt + ts::ivec2(0,filtereditheight) ).size( cla.width(), omy );
                fake_margin.y += omy;
            }
        }
        return true;
    case SQ_MOUSE_LUP:
        if (overlink == clicklink && clicklink >= 0)
            do_tag_click(clicklink);
        clicklink = -1;
        break;
    case SQ_MOUSE_LDOWN:
        if (overlink >= 0)
            clicklink = overlink;
        break;
    case SQ_MOUSE_RUP:
        if (overlink == rclicklink && rclicklink >= 0)
            do_tag_rclick(rclicklink);
        rclicklink = -1;
        break;
    case SQ_MOUSE_RDOWN:
        if (overlink >= 0)
            rclicklink = overlink;
        break;
    case SQ_DRAW:
        if (rid == getrid())
        {
            if (prf().get_options().is(UIOPT_TAGFILETR_BAR))
            {
                ts::irect ca = get_client_area();
                draw_data_s &dd = getengine().begin_draw();

                dd.offset += ca.lt; dd.offset.x += 5;
                dd.size = ca.size();
                dd.size.x -= 10;

                if (edit)
                    dd.offset.y += edit->getprops().size().y;
                if (option1)
                    dd.offset.y += option1->get_min_size().y;

                text_draw_params_s tdp;
                tdp.rectupdate = updaterect;
                draw(dd, tdp);
                getengine().end_draw();

            }

            return gui_control_c::sq_evt(qp,rid,data);

        }
        break;
    }

    return __super::sq_evt(qp,rid,data);
}
コード例 #9
0
ファイル: listview.cpp プロジェクト: wbyang1985/ClanLib
ListView::ListView(clan::GUIManager &manager) :
	clan::Window(&manager, clan::GUITopLevelDescription("List View & Toolbar", clan::Rect(8, 256*1 + 180*1 + 24, clan::Size(256*2, 180*2)), false))
{

	func_close() = bind_member(this, &ListView::on_close);

	clan::Rect client_area = get_client_area();

	clan::Canvas canvas = get_canvas();
	if (clan::FileHelp::file_exists("../../../Resources/GUIThemeLuna/Images/icon_mycomputer.png"))
	{
		sprite_mycomputer = clan::Sprite(canvas, "../../../Resources/GUIThemeLuna/Images/icon_mycomputer.png");
		sprite_folder = clan::Sprite(canvas, "../../../Resources/GUIThemeLuna/Images/icon_folder_32x32.png");
		sprite_overlay = clan::Sprite(canvas, "../../../Resources/GUIThemeLuna/Images/overlay_96x96.png");
	}
	else
	{
		sprite_mycomputer = clan::Sprite(canvas, "../CommonCode/Resources/tux.png");
		sprite_folder = clan::Sprite(canvas, "../CommonCode/Resources/tux.png");
		sprite_overlay = clan::Sprite(canvas, "../CommonCode/Resources/tux.png");
	}

	toolbar = new clan::ToolBar(this);
	toolbar->set_geometry(clan::Rect(client_area.left, client_area.top, clan::Size(32, 180)));
	toolbar->add_item(clan::Sprite(canvas, "../CommonCode/Resources/tux.png"), 0, "Tux1", 0);
	toolbar->add_item(clan::Sprite(canvas, "../CommonCode/Resources/tux.png"), 0, "Tux2", 0);

	listview1 = new clan::ListView(this);
	listview1->set_geometry(clan::Rect(client_area.left + 100, client_area.top + 10, clan::Size(360, 180)));
	listview1->set_display_mode(clan::listview_mode_details);

	listview1->func_selection_changed() = bind_member(this, &ListView::on_selection_changed);
	listview1->func_item_edited() = bind_member(this, &ListView::on_item_edited);
	listview1->func_key_pressed() = bind_member(this, &ListView::on_key_pressed);
	listview1->func_key_released() = bind_member(this, &ListView::on_key_released);
	listview1->func_mouse_right_up() = bind_member(this, &ListView::on_mouse_right_up);
	clan::ListViewItem doc_item = listview1->get_document_item(); 

	clan::ListViewHeader *lv_header = listview1->get_header();  
	lv_header->append(lv_header->create_column("col1_id", "col1")).set_width(130);
	lv_header->append(lv_header->create_column("col2_id", "col2")).set_width(80);
	lv_header->append(lv_header->create_column("col3_id", "col3")).set_width(80);

	clan::ListViewIcon icon;
	icon.set_sprite(sprite_mycomputer, clan::listview_mode_details);
	icon.set_sprite(sprite_folder, clan::listview_mode_icons);
	icon.set_sprite(sprite_folder, clan::listview_mode_thumbnails);

	clan::ListViewIcon olay;
	olay.set_sprite(sprite_overlay, clan::listview_mode_thumbnails);
	olay.set_offset(clan::Point(0, 96-sprite_overlay.get_height()), clan::listview_mode_thumbnails);
	olay.set_scalable(false);

	clan::ListViewIconList ico_list = listview1->get_icon_list();
	ico_list.set_icon(1, icon);
	ico_list.set_icon(1001, olay);

	clan::ListViewItem i1 = listview1->create_item();
	{
		i1.set_column_text("col1_id", "i1");
		i1.set_column_text("col2_id", "col2 text!");
		i1.set_editable(true);
		i1.set_icon(1);
		i1.add_overlay_icon(1001);
		i1.set_open(false);
		doc_item.append_child(i1);

		clan::ListViewItem i1c1 = listview1->create_item();  
		{ 
			i1c1.set_column_text("col1_id", "i1c1");
			i1c1.set_column_text("col2_id", "BOOYAA!");
			i1c1.set_icon(1);
			i1.append_child(i1c1);
		}
	}

	clan::ListViewItem i2 = listview1->create_item();
	{
		i2.set_column_text("col1_id", "i2");
		i2.set_column_text("col2_id", "bar2");
		i2.set_column_text("col3_id", "foobar!");
		i2.set_icon(1);
		i2.set_open(true);

		clan::ListViewItem i2c1 = listview1->create_item();  
		{
			i2c1.set_column_text("col1_id", "i2c1"); 
			i2c1.set_column_text("col2_id", "BOOYAA!");
			i2c1.set_icon(1);
		}
		i2.append_child(i2c1); 

		clan::ListViewItem i2c2 = listview1->create_item();
		{
			i2c2.set_column_text("col1_id", "i2c2");
			i2c2.set_column_text("col2_id", "BOOYAA!");
			i2c2.set_icon(1);
			i2c2.set_open(true); 

			clan::ListViewItem i2c2c1 = listview1->create_item();
			{
				i2c2c1.set_column_text("col1_id", "i2c2c1"); 
				i2c2c1.set_column_text("col2_id", "BOOYAA!");
				i2c2c1.set_icon(1);
			}
			i2c2.append_child(i2c2c1); 
		}
		i2.append_child(i2c2);
	}
	doc_item.append_child(i2);


	for (int j = 0;j < 15; j++)
	{  
		clan::ListViewItem i = listview1->create_item();
		i.set_editable(true);
		i.set_column_text("col1_id", clan::string_format("item %1", j)); 
		i.set_icon(1);       
		if ((j%4) == 0)
		{ 
			i.set_column_text("col3_id", clan::string_format("item %1, col3", j));
		}
		if (( j%2)==0)
		{
			i.set_column_text("col2_id", clan::string_format("item %1, col2", j));
		} 
		doc_item.append_child(i);
	}

	int xoffset = client_area.left + 100;
	int yoffset = client_area.top + 200;
	const int gap = 16;

	info_selection_changed = new Info(this);
	info_selection_changed->set(xoffset, yoffset, "Selection Changed");
	yoffset += gap;

	info_item_edited = new Info(this);
	info_item_edited->set(xoffset, yoffset, "Item Edited");
	yoffset += gap;

	info_key_pressed = new Info(this);
	info_key_pressed->set(xoffset, yoffset, "Key Pressed");
	yoffset += gap;

	info_key_released = new Info(this);
	info_key_released->set(xoffset, yoffset, "Key Released");
	yoffset += gap;

	info_mouse_right_up = new Info(this);
	info_mouse_right_up->set(xoffset, yoffset, "Mouse Right Up");
}
コード例 #10
0
ファイル: menubar.cpp プロジェクト: animehunter/clanlib-2.3
MenuBar::MenuBar(CL_GUIManager &manager, CL_ResourceManager &application_resources) :
	CL_Window(&manager, CL_GUITopLevelDescription("Menu Bar & Status Bar", CL_Rect(512 + 24, 256 + 16, CL_Size(256, 180)), false))
{
	tux_image = CL_ImageProviderFactory::load("../CommonCode/Resources/tux.png");

	CL_GraphicContext gc = get_gc();
	tux_head = CL_Image(gc, "tux_head", &application_resources);

	set_draggable(true);

	CL_Rect client_area = get_client_area();

	menubar1 = new CL_MenuBar(this);
	menubar1->set_geometry(CL_Rect(client_area.left, client_area.top, client_area.right, client_area.top + 25));

	menu_file.insert_item("New").func_clicked().set(this, &MenuBar::on_item_selected);
	menu_file.insert_item("Open").func_clicked().set(this, &MenuBar::on_item_selected);
	menu_file.insert_item("Save").func_clicked().set(this, &MenuBar::on_item_selected);
	CL_PopupMenuItem tux_item = menu_file.insert_item("Tux");
	tux_item.func_clicked().set(this, &MenuBar::on_item_selected);
	tux_item.set_icon(tux_image);

	menu_file.insert_item("Exit").func_clicked().set(this, &MenuBar::on_item_selected);
	menubar1->add_menu("File", menu_file);

	menu_edit.insert_item("Undo").func_clicked().set(this, &MenuBar::on_item_selected);
	CL_PopupMenuItem redo_item = menu_edit.insert_item("Redo");
	redo_item.func_clicked().set(this, &MenuBar::on_item_selected);
	redo_item.set_enabled(false);
	menu_edit.insert_separator();
	menu_edit.insert_item("Cut").func_clicked().set(this, &MenuBar::on_item_selected);
	menu_edit.insert_item("Copy").func_clicked().set(this, &MenuBar::on_item_selected);
	menu_edit.insert_separator();
	item_submenu = menu_edit.insert_item("Submenu");
	item_submenu.func_clicked().set(this, &MenuBar::on_item_selected);
	menu_edit.insert_separator();
	menu_edit.insert_item("Paste").func_clicked().set(this, &MenuBar::on_item_selected);
	menu_edit.insert_item("Delete").func_clicked().set(this, &MenuBar::on_item_selected);
	menu_edit.insert_separator();
	menu_edit.insert_item("Select All").func_clicked().set(this, &MenuBar::on_item_selected);

	menu_submenu.insert_item("foo").func_clicked().set(this, &MenuBar::on_item_selected);
	menu_submenu.insert_item("bar").func_clicked().set(this, &MenuBar::on_item_selected);
	menu_submenu.insert_item("foobar").func_clicked().set(this, &MenuBar::on_item_selected);
	CL_PopupMenuItem check_item1 = menu_submenu.insert_item("Checkable 1");
	check_item1.func_clicked().set(this, &MenuBar::on_item_selected);
	check_item1.set_checkable(true);
	check_item1.set_checked(true);
	CL_PopupMenuItem check_item2 = menu_submenu.insert_item("Checkable 2");
	check_item2.func_clicked().set(this, &MenuBar::on_item_selected);
	check_item2.set_checkable(true);
	check_item2.set_checked(false);
	CL_PopupMenuItem check_item3 = menu_submenu.insert_item("Disabled Checkable 1");
	check_item3.func_clicked().set(this, &MenuBar::on_item_selected);
	check_item3.set_checkable(true);
	check_item3.set_checked(true);
	check_item3.set_enabled(false);
	CL_PopupMenuItem check_item4 = menu_submenu.insert_item("Disabled Checkable 2");
	check_item4.func_clicked().set(this, &MenuBar::on_item_selected);
	check_item4.set_checkable(true);
	check_item4.set_checked(false);
	check_item4.set_enabled(false);
	item_submenu.set_submenu(menu_submenu);

	menubar1->add_menu("Edit", menu_edit);

	int xoffset = client_area.left + 80;
	int yoffset = client_area.top + 30;
	const int gap = 16;
	CL_Size label_size(50, 15);

	info_item_selected = new Info(this);
	info_item_selected->set(xoffset, yoffset, "Item Selected");
	yoffset += gap;

	statusbar1 = new CL_StatusBar(this);
	int statusbar_height = statusbar1->get_preferred_height();
	CL_Rect statusbar_rect(0, client_area.get_height() - statusbar_height, CL_Size(client_area.get_width(), statusbar_height));
	statusbar_rect.translate(client_area.left, client_area.top);
	statusbar1->set_geometry(statusbar_rect);
	statusbar1->set_status_text("Status bar");
	statusbar1->show_size_grip(true);

	pushbutton1 = new CL_PushButton(statusbar1);
	pushbutton1->set_icon(tux_head);
	pushbutton1->func_clicked().set(this, &MenuBar::on_clicked, pushbutton1);
	statusbar1->add_part(0, 48, pushbutton1);
	statusbar1->func_part_double_clicked(0).set(this, &MenuBar::on_part_double_clicked_0, statusbar1);

	component1 = new CL_GUIComponent(statusbar1);
	statusbar1->add_part(1, 48, component1);
	statusbar1->set_part_text(1, "ClanTest");
	statusbar1->func_part_double_clicked(1).set(this, &MenuBar::on_part_double_clicked_1, statusbar1);

	CL_GUIComponent *component2 = (new CL_GUIComponent(statusbar1));
	statusbar1->add_part(2, 48, component2);
	statusbar1->set_part_text(2, tux_head, "");
	statusbar1->func_part_double_clicked(2).set(this, &MenuBar::on_part_double_clicked_2, statusbar1);

	xoffset = client_area.left + 5;
	yoffset = client_area.top + 40;

	label_status = new CL_Label(this);
	label_status->set_geometry(CL_Rect(xoffset, yoffset, label_size));
	label_status->set_text("Status Bar:");
	yoffset += gap;

	checkbox_status_size_grip = new CL_CheckBox(this);
	checkbox_status_size_grip->set_geometry(CL_Rect(xoffset, yoffset, CL_Size(150, 15)));
	checkbox_status_size_grip->func_checked().set(this, &MenuBar::on_checked_status_size_grip, checkbox_status_size_grip);
	checkbox_status_size_grip->func_unchecked().set(this, &MenuBar::on_unchecked_status_size_grip, checkbox_status_size_grip);
	checkbox_status_size_grip->set_text("Show Size Grip");
	checkbox_status_size_grip->set_checked(true);
	yoffset += gap;

	checkbox_status_text = new CL_CheckBox(this);
	checkbox_status_text->set_geometry(CL_Rect(xoffset, yoffset, CL_Size(150, 15)));
	checkbox_status_text->func_checked().set(this, &MenuBar::on_checked_status_text, checkbox_status_text);
	checkbox_status_text->func_unchecked().set(this, &MenuBar::on_unchecked_status_text, checkbox_status_text);
	checkbox_status_text->set_text("Change Status Text");
	checkbox_status_text->set_checked(true);
	yoffset += gap;

	checkbox_status_show_clantest = new CL_CheckBox(this);
	checkbox_status_show_clantest->set_geometry(CL_Rect(xoffset, yoffset, CL_Size(150, 15)));
	checkbox_status_show_clantest->func_checked().set(this, &MenuBar::on_checked_show_clantest, checkbox_status_show_clantest);
	checkbox_status_show_clantest->func_unchecked().set(this, &MenuBar::on_unchecked_show_clantest, checkbox_status_show_clantest);
	checkbox_status_show_clantest->set_text("Show ClanTest");
	checkbox_status_show_clantest->set_checked(true);
	yoffset += gap;

	checkbox_status_remove_clantest = new CL_CheckBox(this);
	checkbox_status_remove_clantest->set_geometry(CL_Rect(xoffset, yoffset, CL_Size(150, 15)));
	checkbox_status_remove_clantest->func_checked().set(this, &MenuBar::on_checked_remove_clantest, checkbox_status_remove_clantest);
	checkbox_status_remove_clantest->func_unchecked().set(this, &MenuBar::on_unchecked_remove_clantest, checkbox_status_remove_clantest);
	checkbox_status_remove_clantest->set_text("Remove ClanTest");
	checkbox_status_remove_clantest->set_checked(false);
	yoffset += gap;

	xoffset = client_area.left + 110;
	yoffset -= (gap*2);

	info_clicked = new Info(this);
	info_clicked->set(xoffset, yoffset, "Push Button Clicked");

	yoffset += gap;

	info_part_clicked = new Info(this);
	info_part_clicked->set(xoffset, yoffset, "Part Dbl Clicked");

}