Gtkmm 4.18, gtk :: columnview Header, manipulieren Sie Header, Text nicht fett, bis sich das CSS -Styling anders verhältCSS

CSS verstehen
Anonymous
 Gtkmm 4.18, gtk :: columnview Header, manipulieren Sie Header, Text nicht fett, bis sich das CSS -Styling anders verhält

Post by Anonymous »

Um die Header in einem GTK :: Columnview zu stylen, habe ich CSS verwendet, um die Header zu einer Schriftart mit fester Breite zu machen, damit ich sie grob zentrieren konnte. Ich hatte auch den Schriftartenstil mutig eingestellt. Ich habe kürzlich den folgenden C ++ - Code geschrieben, um das zugrunde liegende GTK :: Box und das GTK :: Label zu manipulieren, um den Text über Markup zu fett zu machen und das GTK :: -Feld zu zentrieren. Da die GTK :: Box das GTK :: Etikett enthält, zentriert es das Etikett. Das Problem, auf das ich begegnet bin, ist, dass der Text in den Headern bei der Verwendung der C ++-Methode darin besteht, dass sie, bis ich über die Überschriften schwebe, nicht fett und scheinbar nicht ausgewählt zu sein schien oder so. Ich habe mit GTK Inspector herumgespielt und konnte keine offensichtliche Einstellung finden, die ich in meinem Code verpasst hatte. Der Code, den ich geschrieben habe, lautet wie folgt: < /p>
//
//Now we must fetch the first child of the matrix which is the headers
//so that we can then fetch the box and then the underlying label that
//contains the actual header.
//
auto matrix_header = matrix->get_first_child();
assert(matrix_header);

//
//As the matrix header can be viewed as a vector of widgets, we now need
//to fetch the children of the above.
//
auto matrix_header_widgets = matrix_header->get_children();
assert(matrix_header_widgets.size() > 0);

//
//Now that we have the vector of widgets that forms the header line we
//can now loop and process each widget.
//
for (Gtk::Widget * widget : matrix_header_widgets)
{
//
//As the widget will be a column view row we must fetch the first
//child of this, which will be a Gtk::Box, and cast it so that we
//can then work with it.
//
auto box = dynamic_cast(
widget->get_first_child()
);

assert(box);

//
//Now for each widget we must fetch the underlying label (which should
//be the first widget of the above Gtk::Box so that we can then make
//the text stored there bold.
//
auto label = dynamic_cast
(
box->get_first_child()
);

assert(label);

//
//Now that we have the underlying label, we now must fetch the text
//that is stored in the label, remove leading and trailing spaces and
//then make it bold.
//
Label_Set_Markup_Bold(
label,
String::Trim(
Label_Get_Text(label)
)
);

//
//Now that we have set the label to bold, we now must align the label
//so that the heading is to be centred. As the label is contained
//within a Gtk::Box, it is the box that we must centre as this box
//is contained within a row view title.
//
Widget_Set_Alignment(
box,
Widget_Alignment_Centre
);
}
< /code>
Beachten Sie, dass eine 'Matrix' meine benutzerdefinierte Klasse ist, die aus einer GTK :: ColumnView abgeleitet ist. Als ich CSS als Styling -Mechanismus verwendet hatte>

Quick Reply

Change Text Case: 
   
  • Similar Topics
    Replies
    Views
    Last post