......
vbox = gtk_vbox_new(FALSE,0);
vbox1 = gtk_vbox_new(FALSE,0);
vbox2 = gtk_vbox_new(FALSE,0);
gtk_box_pack_start(GTK_BOX(vbox),vbox1,FALSE,FALSE,5);
gtk_box_pack_start(GTK_BOX(vbox),vbox2,FALSE,FALSE,5);
//分割板
vpaned = gtk_vpaned_new();
gtk_paned_set_position(GTK_PANED(vpaned),300);//分割位置
gtk_container_add(GTK_CONTAINER(window), vpaned);
//分割上部分
//滑动窗口
scwin1 = gtk_scrolled_window_new(NULL,NULL);
gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scwin1),GTK_POLICY_AUTOMATIC,GTK_POLICY_AUTOMATIC); //第二第三个参数分别代表水平垂直自动
//上边添加滑动窗口
gtk_paned_add1(GTK_PANED(vpaned),scwin1);
gtk_widget_show(scwin1);
//view1
view1 = gtk_text_view_new();
gtk_text_view_set_border_window_size(GTK_TEXT_VIEW(view1),GTK_TEXT_WINDOW_BOTTOM ,30);
gtk_container_add(GTK_CONTAINER(scwin1), view1);//添加到滑动窗口
//第下部分
gtk_paned_add2(GTK_PANED(vpaned),vbox);
//view2
//view2 = gtk_text_view_new_with_buffer(buffer);
view2 = gtk_text_view_new();
gtk_text_view_set_border_window_size(GTK_TEXT_VIEW(view2),GTK_TEXT_WINDOW_BOTTOM ,30);
//gtk_container_add(GTK_CONTAINER(scwin2), view2);//添加到滑动窗口
//创建下边的scolledwindow
scwin2 = gtk_scrolled_window_new(NULL,NULL);
gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scwin2),GTK_POLICY_AUTOMATIC,GTK_POLICY_AUTOMATIC); //第二第三个参数分别代表水平垂直自动
//上边view添加滑动窗口
gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(scwin2),view2);//
//gtk_box_pack_start(GTK_BOX(vbox1),scwin2,TRUE,TRUE,5);
gtk_box_pack_end(GTK_BOX(vbox1),scwin2,TRUE,TRUE,5);//将scolledwindow放到vbox里
gtk_widget_show(scwin2);
//gtk_container_add(GTK_CONTAINER(vbox1), view2);//直接就可以
//下边确定按钮
button = gtk_button_new_with_label("发送");
gtk_box_pack_end(GTK_BOX(vbox2),button,FALSE,FALSE,5);
/*------------------------------------------------缓冲区-------------------------------*/
buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(view2));
//方法1
gtk_text_buffer_create_tag(buffer, "blue_foreground", "foreground", "blue",NULL);
gtk_text_buffer_create_tag(buffer, "yellow_background", "foreground", "yellow",NULL);
gtk_text_buffer_get_end_iter(buffer,&end);
gtk_text_buffer_insert(buffer, &end, "hello world!\n",-1);
//方法2
gtk_text_buffer_get_end_iter(buffer,&iter);
gtk_text_buffer_insert_with_tags_by_name(buffer, &iter, "你好!\n", -1, "blue_foreground", NULL);
gtk_text_buffer_insert_with_tags_by_name(buffer, &iter, "你好吗!\n", -1, "yellow_background", NULL);
转载于:https://my.oschina.net/u/658004/blog/206421