Re: GtkTextView Questions -- please help! =]



Hi Raymond,

Thanks for replying. But I still have some issues, and I cant figure them out. I
was thinking if I showed you some code it would help:

1) As far as creating 2 textviews with the same hieght, I do this (but it ends
up with the first textview 1/3 the size of the second):

      table = gtk_table_new (1, 4, FALSE);
      gtk_container_add(GTK_CONTAINER(window), table);
     
      temp->display = gtk_text_view_new ();
     // gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(temp->display),  GTK_WRAP_CHAR);
      gtk_text_view_set_editable(GTK_TEXT_VIEW(temp->display), FALSE);
       
      
      temp->dispBuffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (temp->display));
   
      temp->input = gtk_text_view_new();
      gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(temp->input), GTK_WRAP_CHAR);
      temp->typeBuffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (temp->input));
      
      sw = gtk_scrolled_window_new (NULL, NULL);
      gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw),
GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
        
     

      gtk_paned_add1 (GTK_PANED (panel), sw);

      gtk_container_add (GTK_CONTAINER (sw), temp->display);   

     

      sw = gtk_scrolled_window_new (NULL, NULL);
      gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw),
GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);

         

      gtk_paned_add2 (GTK_PANED (panel), sw);

      gtk_container_add (GTK_CONTAINER (sw), temp->input);

      gtk_table_attach (GTK_TABLE (table),
                        panel,
                        /* X direction */       /* Y direction */
                        0, 1,                   0, 3,
                        GTK_EXPAND | GTK_FILL,  GTK_EXPAND | GTK_FILL,
                        0,                      0); 


so quick explaination of the code, I have a paned widget, I create 2 scrolled
windows with textviews in them. I create them the same way, and add the to the
panel, then I add the panel to the table. You would think that the  size of the
scrolled windows would be the same.

2) I actually figured out this problem by sending the textview widget to the
function where i enter text into it, and used the gtk_text_view_scroll_iter or
something like that.

3) If you look in the code above, you will see the line:

gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(temp->input), GTK_WRAP_CHAR)

i was hoping that this would set the scrolled window to wrap text, however, it
does not. In this textview, users will type in text, and then once they hit a
button, it will go to the other textview. Just like a instant message (this is
actually what it is). But for some reason it doesn't work, and as text is typed,
it never wraps. I was wondering if you had any suggestions. Thanks for your help!

Quoting Raymond Wan <rwan cs mu oz au>:

> 
> Hi,
> 
> On Mon, 3 Mar 2003, Arash Nikkar wrote:
> > 1)  I have created a window, with 2 textviews within it. Now I initialized
> > the textviews the same way, but the top one is about 1/3 of the window,
> > while the bottom is 2/3. I was wondering how i could set them to be the
> same
> > length.
> 
> 	This has to do with the container widget (hbox, vbox, table,
> whatever) you put them in and the options that you set.  You should take a
> look at the container docs or tutorial.
> 
> > 2) I have a scrolled window within both of the textviews, and i insert
> text
> > line by line. For some reason, the scrollbars don't scroll down as text is
> > inserted into the textviews. They have to be manually scrolled down. I was
> > wondering if there is some way to fix that.
> 
> 	The scrolled window has vertical adjustments associated with it.
> If you want it to follow the text, you might have to manually get the
> adjustments, change it accordingly, and go to it.  I'm not entirely sure
> as I tend to put all my text in a char buffer and then put the buffer at
> one time -- much faster.  Anyway, take a look at the documentation to
> scrolled windows and it should lead you to a GTKAdjustment data structure
> which you can read.
> 
> > 3) Is there anyway to set the attribute of a textview so that it will word
> > wrap text that IS TYPED into the textview. I know how to word wrap text
> that
> > you insert into a textview, but I cant figure out how to word wrap text
> that
> > a user enters into the textview.
> 
> 	...I don't know what you mean but manually, perhaps?  That is,
> when a user hits the "Enter" key, you add the \n character to the buffer.
> 
> Ray
> 
> 
> 
> 
> 
> 


-- 
Arash Nikkar
arash umail ucsb edu



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]