RE: TextView and ScrolledWindow not behaving properly
- From: "Jeremy Wise" <jwise springthrough com>
- To: "'Morten Brix Pedersen'" <morten wtf dk>, <gtk-app-devel-list gnome org>
- Subject: RE: TextView and ScrolledWindow not behaving properly
- Date: Tue, 16 Jul 2002 08:14:52 -0400
I've noticed exactly the same behavior in GnomeICU when I add a message
to the text box. For some reason, it's expanding the size of the entire
window instead of wrapping the word to the next line. This gives a
pretty bad appearance... I don't know if it's a bug in the TextView or a
bug in the scrolled window.. also, a TreeView in a scrolled window can't
be shrunk below the width required for the longest string in the view.
Later,
Jeremy Wise
GnomeICU Team
-----Original Message-----
From: gtk-app-devel-list-admin gnome org [mailto:gtk-app-devel-list-
admin gnome org] On Behalf Of Morten Brix Pedersen
Sent: Monday, July 15, 2002 9:30 PM
To: gtk-app-devel-list gnome org
Subject: TextView and ScrolledWindow not behaving properly
Hi,
I have a TextView in a ScrolledWindow, but it's not behaving like it
should:
* It should be possible to shrink the window to a size less than the
text width (my example can show why this isn't always true)
* The TextWidget should not expand the window while you type or
insert
text into it. E.g. a 50x50 window should stay 50x50 nomatter the
text
inserted. The user should still be able to resize it as he wishes.
* The text should wrap.
* There should be no horizontal scrollbar.
The below example illustrates my problem, I have set wrap_mode to
GTK_WRAP_CHAR, but the text doesn't wrap when the window is shrinked.
If you uncomment the gtk_widget_set_size_request(), the text does
wrap,
but when shrinking the window, the window can't get any smaller than
the
length of the text. E.g. if I type and the window gets enlarged to
100x100 pixels, it can't be shrinked down.
Enough mumbling:
#include <gtk/gtk.h>
int main(int argc, char *argv[])
{
GtkWidget *window;
GtkWidget *scrolled_window;
GtkWidget *view;
GtkTextBuffer *buffer;
gtk_init (&argc, &argv);
scrolled_window = gtk_scrolled_window_new (NULL, NULL);
gtk_container_set_border_width (GTK_CONTAINER (scrolled_window),
10);
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_window_set_default_size(GTK_WINDOW (window), 600, 500);
gtk_window_set_resizable (GTK_WINDOW (window), TRUE);
view = gtk_text_view_new ();
buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view));
gtk_text_buffer_set_text (buffer, "Hello, this is some text", -1);
gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW
(scrolled_window),
GTK_POLICY_NEVER, GTK_POLICY_ALWAYS);
/* when this line is enabled, the window can be shrinked but the
text
* doesn't wrap */
gtk_widget_set_size_request (scrolled_window, 0, -1);
gtk_scrolled_window_add_with_viewport (
GTK_SCROLLED_WINDOW (scrolled_window), view);
gtk_container_add (GTK_CONTAINER (window), scrolled_window);
gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(view), GTK_WRAP_CHAR);
gtk_widget_show (window);
gtk_widget_show (view);
gtk_widget_show (scrolled_window);
gtk_main ();
return 0;
}
_______________________________________________
gtk-app-devel-list mailing list
gtk-app-devel-list gnome org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]