Re: How to add `underline' to a gtk label widget?
- From: Jeans <jeans ace ulyssis org>
- To: learfox furry ao net
- Cc: GTK Application Development List <gtk-app-devel-list gnome org>
- Subject: Re: How to add `underline' to a gtk label widget?
- Date: Thu, 12 Oct 2000 12:27:47 +0200 (CEST)
How do I make (part or the entire) text underlined in a gtk label
widget?
GtkWidget* widget = gtk_label_new("Text");
gtk_label_set_pattern(GTK_LABEL(widget), "_ ");
or you can use this function:
(hack it a little bit and replace PGString by char*)
// Create label with underscore at '&' positions
GtkWidget*
PGMakeLabelWithUnderscore(PGString* label, GtkJustification jtype) {
BOOL isUnder = FALSE;
int len = label->getLength();
char *text = new char[len+1];
char *underscores = new char[len+1];
char *labeltext = label->getValue();
int ps = 0, pt = 0;
while (ps < len) {
char ch = labeltext[ps];
if (ch == 0) break;
if (ch == '&') {
isUnder = TRUE;
} else {
if (isUnder) {
underscores[pt] = '_';
isUnder = FALSE;
} else {
underscores[pt] = ' ';
}
text[pt] = ch;
pt++;
}
ps++;
}
text[pt] = underscores[pt] = 0;
GtkWidget* widget = gtk_label_new(text);
gtk_label_set_pattern(GTK_LABEL(widget), underscores);
gtk_label_set_justify(GTK_LABEL(widget), jtype);
delete text;
delete underscores;
return widget;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]