Table Color & label justification



        Hi,
        I'm doing some sort of exam which is implemented
        from a series of label & radio buttons inside a
        vbox and this goes inside a table cell.  The cell
        then is within a Scrolled Window & finally the
        Scrolled Window goes inside a Dialog Window.

        But I have 2 problems:
        1.- I want to change the color of the "exam" (table
            contents, i.e. labels, radio buttons).  I've
            tried some of the answers in the list but
            with no success =-(   IDK if I'm doing it
            on the wrong widget...
        2.- Adjusting the labels (inside the table) does
            nothing.  The labels are always centered & I
            want'em to be left aligned.

        Here is my code (some parts snipped, but I hope what
        it's shown here may help):

~~~~~~~~~~~~~~~~~~~~~~~< code >~~~~~~~~~~~~~~~~~~~~~~~~~
struct ChoicesWidgets {
        GtkWidget ** radiobtns, /* Radio Buttons array */
                   * box;       /* Box where the choices are stored in */
        GSList     * gp;        /* Group they belog to... */
};

struct ChoicesWidgets choices_widgets[N_QUESTIONS];

/*
 * Fcn maketest.
 * Creates the table with the questions & posible answers (choices,
 * GtkRadioButtons).
 */
GtkWidget *
maketest( void )
{
        GtkWidget        * table,
                         * label;
        int                i,
                           pos;

        table = gtk_table_new( N_QUESTIONS*2 + 1, 1, FALSE );

        label = gtk_label_new( "Evaluación" );
        gtk_table_attach( GTK_TABLE(table), label, 0, 1, 0, 1,
                          GTK_FILL | GTK_EXPAND,
                          GTK_FILL | GTK_EXPAND,
                          0, 50 );
        gtk_widget_show( label );

        makechoices( choices_widgets, N_QUESTIONS );

        /*
         * Preguntas & Opciones de respuestas
         */
        for( i = 0, pos = 1; i < N_QUESTIONS; i++, pos += 2 ) {
                label = gtk_label_new( questions[i] );
                gtk_table_attach_defaults( GTK_TABLE(table), label,
                                           0,1,
                                           pos, pos+1 );
                /*
                 * FIX ME!
                 * I can't set the justification here... why? =-(
                 */
                gtk_label_set_justify( GTK_LABEL(label), GTK_JUSTIFY_LEFT );
                gtk_widget_show( label );
                gtk_table_set_row_spacing( GTK_TABLE(table), pos, 10 );

                gtk_table_attach_defaults( GTK_TABLE(table),
                                           choices_widgets[i].box,
                                           0,1,
                                           pos+1, pos+2 );
                gtk_widget_show_all( choices_widgets[i].box );
                if ( i != N_QUESTIONS-1 )
                        gtk_table_set_row_spacing( GTK_TABLE(table), pos+1, 30 );
        }

        return table;
}

/*
 * Callback seteval
 * Creates the "exam"
 */
void
seteval( void )
{
[...]
        evalwin = gtk_dialog_new();
[...]

        /*
         * All inside Scrolled-Window
         */
        sw = gtk_scrolled_window_new( NULL, NULL );
        gtk_scrolled_window_set_policy( GTK_SCROLLED_WINDOW(sw),
                        GTK_POLICY_AUTOMATIC,
                        GTK_POLICY_AUTOMATIC );
        gtk_box_pack_start( GTK_BOX(GTK_DIALOG(evalwin)->vbox), sw,
                        TRUE, TRUE, 0 );

[...]
        test = maketest();
        gtk_container_set_border_width( GTK_CONTAINER(test), 20 );
        gtk_scrolled_window_add_with_viewport( GTK_SCROLLED_WINDOW(sw), test );
[...]
}
~~~~~~~~~~~~~~~~~~~~~~~< /code >~~~~~~~~~~~~~~~~~~~~~~~~~

        What would be the chosen widget for the color change?
        (the table, the Dialog Win, each one of the label &
        radio buttons, etc.)?
        Why does the justification has no effect on the labels?

        Any corrections, suggestions are welcome.

        Thanks a lot in advance.
        Regards,

                                              Eduardo.





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