代码之家  ›  专栏  ›  技术社区  ›  ptomato

GtkCheckButton或GtkRadioButton标签中的换行

  •  0
  • ptomato  · 技术社区  · 14 年前

    GtkCheckButton GtkRadioButton

    2 回复  |  直到 14 年前
        1
  •  2
  •   doublep    14 年前

    你可以访问button的子控件它是一个 GtkLabel wrap . 然而,由于在GTK+2.x中没有宽度布局协商的高度,您想要的可能很难/几乎不可能实现。请注意,如果需要,也可以替换按钮的子级。

        2
  •  0
  •   Aerthel    13 年前

    我也这样做了(使用GtkSharp)

    RadioButton rb;
    
    /* Initialize the radio button ... */
    
    //Set its wrap mode
    (rb.Child as Gtk.Label).Wrap = true;
    (rb.Child as Gtk.Label).LineWrap = true;
    (rb.Child as Gtk.Label).LineWrapMode = Pango.WrapMode.Word;
    
        3
  •  0
  •   ntd    5 年前

    如果我正确理解这个问题 GtkCheckButton

    /* gcc -o wrap wrap.c $(pkg-config --libs --cflags gtk+-3.0) */
    #include <gtk/gtk.h>
    
    static void
    on_activate(GtkApplication *app)
    {
        GtkWidget *button;
        GtkWidget *label;
        GtkWidget *window;
    
        button = gtk_check_button_new_with_label("Some really useful text goes here");
        label  = gtk_bin_get_child(GTK_BIN(button));
        gtk_label_set_line_wrap(GTK_LABEL(label), TRUE);
        gtk_label_set_max_width_chars(GTK_LABEL(label), 0);
    
        window = gtk_application_window_new(app);
        gtk_window_set_default_size(GTK_WINDOW(window), 600, 480);
        gtk_container_add(GTK_CONTAINER(window), button);
        gtk_widget_show_all(window);
    }
    
    int
    main(int argc, char **argv)
    {
        GtkApplication *app;
        int status;
    
        app = gtk_application_new("org.gnome.LabelWrapping", G_APPLICATION_FLAGS_NONE);
        g_signal_connect(app, "activate", G_CALLBACK(on_activate), NULL);
        status = g_application_run(G_APPLICATION(app), argc, argv);
        g_object_unref(app);
    
        return status;
    }
    
    推荐文章