RE: How to modify textview default vertical scrollbar position
- From: "Josepo Urrutia" <find_all hotmail com>
- To: masegurita gmail com, gtkmm-list gnome org
- Cc:
- Subject: RE: How to modify textview default vertical scrollbar position
- Date: Thu, 04 May 2006 07:20:16 +0000
To do what you say I use the following code.
/* *******************************
textbuffer_puerto_changed
**************************** */
// Funcion q salta cada vez q se modifica el textbuffer_puerto
void window_principal::textbuffer_puerto_changed()
{
// Utilizamos esta funcion para poder mover el scroll sobre el textview
// y no perder el texto cuando hay muchas lineas
bool scroll = false;
if (scroll_window.get_vadjustment()->get_value() >=
(this->scroll_window.get_vadjustment()->get_upper() -
this->scroll_window.get_vadjustment()->get_page_size() - 1e-12))
scroll = true;
if (scroll)
{
Glib::RefPtr<Gtk::TextBuffer> buffer = textview_puerto.get_buffer();
Glib::RefPtr<Gtk::TextBuffer::Mark> pos;
pos = buffer->create_mark(buffer->end());
buffer->move_mark(pos, buffer->end());
textview_puerto.scroll_to_mark(pos, 0.0);
}
} // Fin de textbuffer_puerto_changed
This function must be connected to the changed signal of the textbuffer :
with gtkmm 2.2
textbuffer_puerto->signal_changed().connect(SigC::slot(*this,&window_principal::textbuffer_puerto_changed));
with gtkmm2.4 or higher
textbuffer_puerto->signal_changed().connect(sigc::mem_fun(*this,&window_principal::textbuffer_puerto_changed));
From: "Mario Segura" <masegurita gmail com>
To: gtkmm-list <gtkmm-list gnome org>
Subject: How to modify textview default vertical scrollbar position
Date: Sat, 29 Apr 2006 19:01:32 -0400
Hi,
I use a textview widget and I insert text using its buffer. The method I
use
is "insert_at_cursor".
I will like to modify the position of the vertical scrollbar, because if i
write several lines (more than the ones the window can display) the
vertical
scrollbar appear but is fixed in the upper position while the text is
inserted at the button of the buffer, so it isn't displayed.
The contengency solution I did was to set the value of the vertical
scrollbar (to the bottom) everytime i write a new line, but i think isn't
the right way to do it.
Any idea how to fix the vertical scrollbar in the bottom instead of the top
position?
Thanks,
---Code
string line = "ANYTHING \n";
consolabuffer->insert_at_cursor(line);
//Vertical scrollbar adjustment. Contengency solution ***********
Gtk::Adjustment *ajustev;
ajustev = consolaventana.get_vadjustment();
ajustev->set_value(ajustev->get_upper());
---End
--Variables
Gtk::TextView consolaview;
Glib::RefPtr<Gtk::TextBuffer> consolabuffer;
--End of variables
--
Mario Segura S.
_______________________________________________
gtkmm-list mailing list
gtkmm-list gnome org
http://mail.gnome.org/mailman/listinfo/gtkmm-list
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]