コード例 #1
0
void ttext_::set_cursor(const size_t offset, const bool select)
{
	if(select) {

		if(selection_start_ == offset) {
			selection_length_ = 0;
		} else {
			selection_length_ = - static_cast<int>(selection_start_ - offset);
		}

#ifdef __unix__
		// selecting copies on UNIX systems.
		copy_selection(true);
#endif
		update_canvas();
		set_dirty(true);

	} else {
		assert(offset <= text_.get_length());
		selection_start_ = offset;
		selection_length_ = 0;

		update_canvas();
		set_dirty(true);
	}
}
コード例 #2
0
ファイル: text_box.cpp プロジェクト: ArtBears/wesnoth
void ttext_box::update_offsets()
{
	assert(config());

	boost::intrusive_ptr<const ttext_box_definition::tresolution>
	conf = boost::dynamic_pointer_cast<const ttext_box_definition::tresolution>(
			config());

	assert(conf);

	text_height_ = font::get_max_height(conf->text_font_size);

	game_logic::map_formula_callable variables;
	variables.add("height", variant(get_height()));
	variables.add("width", variant(get_width()));
	variables.add("text_font_height", variant(text_height_));

	text_x_offset_ = conf->text_x_offset(variables);
	text_y_offset_ = conf->text_y_offset(variables);

	// Since this variable doesn't change set it here instead of in
	// update_canvas().
	for(auto & tmp : canvas())
	{
		tmp.set_variable("text_font_height", variant(text_height_));
	}

	// Force an update of the canvas since now text_font_height is known.
	update_canvas();
}
コード例 #3
0
int GraphicGUI::resize_event(int w, int h)
{
	int difference = h - get_h();
	int canvas_xdiff = get_w() - canvas->get_w();
	int canvas_ydiff = get_h() - canvas->get_h();
	
	canvas->reposition_window(canvas->get_x(),
		canvas->get_y(),
		w - canvas_xdiff,
		h - canvas_ydiff);
	freq_text->reposition_window(freq_text->get_x(),
		freq_text->get_y() + difference);
	value_text->reposition_window(value_text->get_x(),
		value_text->get_y() + difference);
	freq_title->reposition_window(freq_title->get_x(),
		freq_title->get_y() + difference);
	level_title->reposition_window(level_title->get_x(),
		level_title->get_y() + difference);
	size_title->reposition_window(size_title->get_x(),
		size_title->get_y() + difference);
	reset->reposition_window(reset->get_x(),
		reset->get_y() + difference);
	size->reposition_window(size->get_x(),
		size->get_y() + difference);

	draw_ticks();
	update_canvas();
	flash();

	plugin->w = w;
	plugin->h = h;
	plugin->send_configure_change();
	return 1;
}
コード例 #4
0
ファイル: text.cpp プロジェクト: shikadilord/wesnoth
void ttext_::set_selection(size_t start, int length)
{
	const size_t text_size = text_.get_length();

	if(start >= text_size) {
		start = text_size;
	}

	if(length == 0) {
		set_cursor(start, false);
		return;
	}

	// The text pos/size type differs in both signedness and size with the
	// selection length. Such is life.
	const int sel_start = std::min<size_t>(start, std::numeric_limits<int>::max());
	const int sel_max_length = std::min<size_t>(text_size - start, std::numeric_limits<int>::max());

	const bool backwards = length < 0;

	if(backwards && -length > sel_start) {
		length = -sel_start;
	} else if(!backwards && length > sel_max_length) {
		length = sel_max_length;
	}

	set_selection_start(start);
	set_selection_length(length);

	update_canvas();
}
コード例 #5
0
ファイル: parametric.C プロジェクト: knutj/cinelerra
void ParametricWindow::update_gui()
{
	for(int i = 0; i < BANDS; i++)
		bands[i]->update_gui();
	wetness->update(plugin->config.wetness);
	size->update(plugin->config.window_size);
	update_canvas();
}
コード例 #6
0
static int 
VGUI_sync(void) {
 //printf("VGUI_sync\n");
 if (vdevice.bgnmode == VLINE) {
  cairo_stroke (VGUI.cr);
 }
 if (VGUI.in_frontbuffer) update_canvas();
 return (1);
};
コード例 #7
0
ファイル: label.cpp プロジェクト: ArtBears/wesnoth
void tlabel::set_link_color(const std::string & color)
{
	if(color == link_color_) {
		return;
	}
	link_color_ = color;
	update_canvas();
	set_is_dirty(true);
}
コード例 #8
0
void GraphicGUI::create_objects()
{
	int margin = plugin->get_theme()->widget_border;
	int x = get_text_width(SMALLFONT, "-00") + LINE_W4 + margin;
	int y = margin;
	int freq_h = get_text_height(SMALLFONT) + LINE_W4;

	add_subwindow(canvas = new GraphicCanvas(plugin,
		this,
		x, 
		y, 
		get_w() - x - margin, 
		get_h() - 
//			BC_Pot::calculate_h() - 
			BC_TextBox::calculate_h(this, MEDIUMFONT, 1, 1) -
			margin * 3 - 
			y - 
			freq_h));
	y += canvas->get_h() + freq_h + margin;

	int x1 = x;
	int y1 = y;
	add_subwindow(freq_title = new BC_Title(x, y, "Frequency:"));
	x += freq_title->get_w() + margin;
	add_subwindow(freq_text = new FreqTextBox(plugin, this, x, y, 100));
	x += freq_text->get_w() + margin;

	add_subwindow(level_title = new BC_Title(x, y, "Level:"));
	x += level_title->get_w() + margin;
	add_subwindow(value_text = new ValueTextBox(plugin, this, x, y, 100));
	x += value_text->get_w() + margin;

	add_subwindow(reset = new GraphicReset(plugin, this, x, y));
	x += reset->get_w() + margin;
	

//	x = x1;
//	y += value_text->get_h() + margin;

	add_subwindow(size_title = new BC_Title(x, y, "Window size:"));
	x += size_title->get_w() + margin;
	add_subwindow(size = new GraphicSize(this, plugin, x, y));
	size->create_objects();
	size->update(plugin->config.window_size);
	x += size->get_w() + margin;

//	add_subwindow(title = new BC_Title(x, y, "Wetness:"));
//	x += title->get_w() + margin;
// 	add_subwindow(wetness = new GraphicWetness(this, plugin, 
// 		x, 
// 		y));

	draw_ticks();
	update_canvas();
	show_window();
}
コード例 #9
0
void styled_widget::set_text_alignment(const PangoAlignment text_alignment)
{
	if(text_alignment_ == text_alignment) {
		return;
	}

	text_alignment_ = text_alignment;
	update_canvas();
	set_is_dirty(true);
}
コード例 #10
0
void styled_widget::set_use_markup(bool use_markup)
{
	if(use_markup == use_markup_) {
		return;
	}

	use_markup_ = use_markup;
	update_canvas();
	set_is_dirty(true);
}
コード例 #11
0
ファイル: label.cpp プロジェクト: ArtBears/wesnoth
void tlabel::set_link_aware(bool link_aware)
{
	if(link_aware == link_aware_) {
		return;
	}

	link_aware_ = link_aware;
	update_canvas();
	set_is_dirty(true);
}
コード例 #12
0
ファイル: control.cpp プロジェクト: ArtBears/wesnoth
void tcontrol::set_text_alignment(const PangoAlignment text_alignment)
{
	if(text_alignment_ == text_alignment) {
		return;
	}

	text_alignment_ = text_alignment;
	update_canvas();
	set_is_dirty(true);
}
コード例 #13
0
ファイル: control.cpp プロジェクト: ArtBears/wesnoth
void tcontrol::set_use_markup(bool use_markup)
{
	if(use_markup == use_markup_) {
		return;
	}

	use_markup_ = use_markup;
	update_canvas();
	set_is_dirty(true);
}
コード例 #14
0
void styled_widget::set_label(const t_string& label)
{
	if(label == label_) {
		return;
	}

	label_ = label;
	set_layout_size(point());
	update_canvas();
	set_is_dirty(true);
}
コード例 #15
0
ファイル: control.cpp プロジェクト: ArtBears/wesnoth
void tcontrol::set_label(const t_string& label)
{
	if(label == label_) {
		return;
	}

	label_ = label;
	set_layout_size(tpoint(0, 0));
	update_canvas();
	set_is_dirty(true);
}
コード例 #16
0
ファイル: text.cpp プロジェクト: shikadilord/wesnoth
void ttext_::insert_char(const utf8::string& unicode)
{
	delete_selection();

	if(text_.insert_text(selection_start_, unicode)) {

		// Update status
		set_cursor(selection_start_ + 1, false);
		update_canvas();
		set_is_dirty(true);
	}
}
コード例 #17
0
void ttext_::set_value(const std::string& text)
{
	if(text != text_.text()) {
		text_.set_text(text, false);

		// default to put the cursor at the end of the buffer.
		selection_start_ = text_.get_length();
		selection_length_ = 0;
		update_canvas();
		set_dirty(true);
	}
}
コード例 #18
0
void ttext_::insert_char(const Uint16 unicode)
{
	delete_selection();

	if(text_.insert_unicode(selection_start_, unicode)) {

		// Update status
		set_cursor(selection_start_ + 1, false);
		update_canvas();
		set_dirty(true);
	}
}
コード例 #19
0
ファイル: text.cpp プロジェクト: blackberry/Wesnoth
void ttext_::paste_selection(const bool mouse)
{
	const std::string& text = copy_from_clipboard(mouse);
	if(text.empty()) {
		return;
	}

	delete_selection();

	selection_start_ += text_.insert_text(selection_start_, text);

	update_canvas();
	set_dirty();
}
コード例 #20
0
ファイル: panel.cpp プロジェクト: suxinde2009/Rose
void tpanel::set_hole_variable(int left, int right)
{
	if (left < 0 || right < 0) {
		return;
	}

	if (left != hole_left_ || right != hole_right_) {
		hole_left_ = left;
		hole_right_ = right;
		if (x_ >= 0) {
			update_canvas();
			set_dirty();
		}
	}
}
コード例 #21
0
void ttext_::paste_selection(const bool mouse)
{
	const std::string& text = copy_from_clipboard(mouse);
	if(text.empty()) {
		return;
	}

	delete_selection();

	selection_start_ += text_.insert_text(selection_start_, text);

	update_canvas();
	set_dirty(true);
	fire(event::NOTIFY_MODIFIED, *this, NULL);
}
コード例 #22
0
ファイル: barber.c プロジェクト: jvesely/helenos
static void frame_timer_callback(void *data)
{
	struct timeval prev;
	getuptime(&prev);
	
	frame++;
	if (frame >= FRAMES)
		frame = 0;
	
	update_canvas(frame_canvas, frames[frame]);
	
	struct timeval cur;
	getuptime(&cur);
	
	plan_frame_timer(tv_sub_diff(&cur, &prev));
}
コード例 #23
0
void CompressorWindow::create_objects()
{
	int x = 35, y = 10;
	int control_margin = 130;

	add_subwindow(canvas = new CompressorCanvas(plugin, 
		x, 
		y, 
		get_w() - x - control_margin - 10, 
		get_h() - y - 70));
	canvas->set_cursor(CROSS_CURSOR, 0, 0);
	x = get_w() - control_margin;
	add_subwindow(new BC_Title(x, y, _("Reaction secs:")));
	y += 20;
	add_subwindow(reaction = new CompressorReaction(plugin, x, y));
	y += 30;
	add_subwindow(new BC_Title(x, y, _("Decay secs:")));
	y += 20;
	add_subwindow(decay = new CompressorDecay(plugin, x, y));
	y += 30;
	add_subwindow(new BC_Title(x, y, _("Trigger Type:")));
	y += 20;
	add_subwindow(input = new CompressorInput(plugin, x, y));
	input->create_objects();
	y += 30;
	add_subwindow(new BC_Title(x, y, _("Trigger:")));
	y += 20;
	add_subwindow(trigger = new CompressorTrigger(plugin, x, y));
	if(plugin->config.input != CompressorConfig::TRIGGER) trigger->disable();
	y += 30;
	add_subwindow(smooth = new CompressorSmooth(plugin, x, y));
	y += 60;
	add_subwindow(clear = new CompressorClear(plugin, x, y));
	x = 10;
	y = get_h() - 40;
	add_subwindow(new BC_Title(x, y, _("Point:")));
	x += 50;
	add_subwindow(x_text = new CompressorX(plugin, x, y));
	x += 110;
	add_subwindow(new BC_Title(x, y, _("x")));
	x += 20;
	add_subwindow(y_text = new CompressorY(plugin, x, y));
	draw_scales();

	update_canvas();
	show_window();
}
コード例 #24
0
void ttext_::set_maximum_length(const size_t maximum_length)
{
	const bool need_update = text_.get_length() > maximum_length;

	text_.set_maximum_length(maximum_length);

	if(need_update) {
		if(selection_start_ > maximum_length) {
			selection_start_ = maximum_length;
			selection_length_ = 0;
		} else if(selection_start_ + selection_length_ > maximum_length) {
			selection_length_ = maximum_length - selection_start_;
		}
		update_canvas();
		set_dirty(true);
	}
}
コード例 #25
0
void tpassword_box::post_function() {
	// See above
	size_t selection_start = get_selection_start();
	size_t selection_length = get_selection_length();

	// Get the input back and make ttext_box forget it
	real_value_ = get_value();
	ttext_box::set_value(std::string(get_text_length(real_value_), '*'));

	// See above
	set_selection_start(selection_start);
	set_selection_length(selection_length);

	// Why do the selection functions not update
	// the canvas?
	update_canvas();
	set_dirty(true);
}
コード例 #26
0
void styled_widget::definition_load_configuration(const std::string& control_type)
{
	assert(!config());

	set_config(get_control(control_type, definition_));
	if(get_canvas().size() != config()->state.size())
	{
		// TODO: Some widgets (toggle panel, toggle button) have a variable canvas count which is determined by its definition.
		// I think we should remove the canvas_count from tcontrols constructor and always read it from the definition.
		DBG_GUI_L << "Corrected canvas count to " << config()->state.size() << std::endl;
		get_canvas() = std::vector<canvas>(config()->state.size());
	}
	for(size_t i = 0; i < get_canvas().size(); ++i) {
		get_canvas(i) = config()->state[i].canvas_;
	}

	update_canvas();
}
コード例 #27
0
ファイル: scrollbar.cpp プロジェクト: Coffee--/wesnoth-old
void tscrollbar_::set_item_position(const unsigned item_position)
{
	// Set the value always execute since we update a part of the state.
	item_position_ = item_position > item_count_ - visible_items_
			? item_count_ - visible_items_
			: item_position;

	item_position_ = (item_position_ + step_size_ - 1) / step_size_;

	if(all_items_visible()) {
		item_position_ = 0;
	}

	// Determine the pixel offset of the item position.
	positioner_offset_ = static_cast<unsigned>(item_position_ * pixels_per_step_);

	update_canvas();

	assert(item_position_ <= item_count_ - visible_items_);
}
コード例 #28
0
void styled_widget::place(const point& origin, const point& size)
{
	// resize canvasses
	for(auto & canvas : canvas_)
	{
		canvas.set_width(size.x);
		canvas.set_height(size.y);
	}

	// Note we assume that the best size has been queried but otherwise it
	// should return false.
	if(renderer_.is_truncated() && use_tooltip_on_label_overflow_
	   && tooltip_.empty()) {

		set_tooltip(label_);
	}

	// inherited
	widget::place(origin, size);

	// update the state of the canvas after the sizes have been set.
	update_canvas();
}
コード例 #29
0
ファイル: text_box.cpp プロジェクト: CliffsDover/wesnoth
void ttext_box::handle_mouse_selection(tpoint mouse, const bool start_selection)
{
	mouse.x -= get_x();
	mouse.y -= get_y();
	// FIXME we don't test for overflow in width
	if(mouse.x < static_cast<int>(text_x_offset_)
	   || mouse.y < static_cast<int>(text_y_offset_)
	   || mouse.y >= static_cast<int>(text_y_offset_ + text_height_)) {
		return;
	}

	int offset = get_column_line(tpoint(mouse.x - text_x_offset_, mouse.y - text_y_offset_)).x;

	if(offset < 0) {
		return;
	}


	set_cursor(offset, !start_selection);
	update_canvas();
	set_is_dirty(true);
	dragging_ |= start_selection;
}
コード例 #30
0
	void set_icon_name(const std::string& icon_name)
		{ icon_name_ = icon_name; update_canvas(); }