Changing Font Information in TextBuffers



Title: Nachricht
Hi all,
I got 2 Problems and i hope you can fix them:
 
1)          gtk_text_view_set_cursor_visible (GTK_TEXT_VIEW (textfeld), FALSE);
        in the tutorial on www.gtk.org is written that this will make the mouse cursor disapear but the cursor is still here.
        I want to have no coursor because my window is so wide and there should only be text in it and the coursor is
        not needed and so the coursor only blockates the text written on my side
        hope someone can tell me what is wrong on this commands or tell me how to make the coursor disapear
 
2)           tag = gtk_text_buffer_create_tag (text, "blue_foreground","foreground", "blue", NULL);  
             gtk_text_buffer_get_iter_at_offset (text, &start, 7);
             gtk_text_buffer_get_iter_at_offset (text, &end, 12);
             gtk_text_buffer_apply_tag (text, tag, &start, &end);
        with this it is possible to change the colour of the text but my question is:
        is it possible also to change textstyle and texthigh (but not for the whole window only for example
        to make a headline or in the text to make comments in smaller textsize and another style) like the
        commands above?
 
The whole sorce of my little program (only testing program because i started learning GTK a few days ago) is:
 
    GtkWidget *window;
    GtkWidget *textfeld;
    GtkTextBuffer *text;
    GdkColor color;
    PangoFontDescription *font_desc;
    GtkTextTag *tag;
    GtkTextIter start, end;
 
    gtk_init (&argc, &argv);
 
    window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
 
    gtk_window_set_title (GTK_WINDOW (window), " need HELP !!! ");
    gtk_widget_set_uposition (window, 0, 0);
    gtk_widget_set_usize(window, 1016, 741);

    textfeld = gtk_text_view_new ();
    text = gtk_text_view_get_buffer (GTK_TEXT_VIEW (textfeld));
 
    gtk_container_add(GTK_CONTAINER (window), textfeld);
 
/* Change default font throughout the widget */
         font_desc = pango_font_description_from_string ("courier 15");
         gtk_widget_modify_font (textfeld, font_desc);
         pango_font_description_free (font_desc);
 
/* Change default color throughout the widget */
         gdk_color_parse ("black", &color);
         gtk_widget_modify_text (textfeld, GTK_STATE_NORMAL, &color);
 
         gtk_text_buffer_set_text (text, "Hello, this is some text", -1);
 

/* Change left margin throughout the widget (in Pixel) */
         gtk_text_view_set_left_margin (GTK_TEXT_VIEW (textfeld), 10);
 
/* No edit */
         gtk_text_view_set_editable (GTK_TEXT_VIEW (textfeld), FALSE);
 
/* No mousecursor */
         gtk_text_view_set_cursor_visible (GTK_TEXT_VIEW (textfeld), FALSE);
 
/* Use a tag to change the color for just one part of the widget */
         tag = gtk_text_buffer_create_tag (text, "blue_foreground","foreground", "blue", NULL);  
         gtk_text_buffer_get_iter_at_offset (text, &start, 7);
         gtk_text_buffer_get_iter_at_offset (text, &end, 12);
         gtk_text_buffer_apply_tag (text, tag, &start, &end);
 
 
    gtk_widget_show (window);
    gtk_widget_show (textfeld); 
 
    gtk_main ();
 
THX
Benedikt Schäfer


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