[gtkada] Changing the color of a GtkLabel

Karl Ran karlran at hotmail.com
Sun Feb 16 15:24:27 CET 2003


Hi,
I'd like to change the text color of a 'GtkLabel' at run-time.

I've found this C-example, but don't realy know how to
translate it to Ada:


http://www106.pair.com/rhp/gtk-colors.html :
--------------------------------------------------------

  GtkRcStyle *rc_style;
  GdkColor color;

  /* There are two good ways to fill in a color */

  /* 1) Initialize r/g/b components, they are 16-bit values */
  color.red = 65535;
  color.green = 0;
  color.blue = 0;

  /* 2) Parse a color string; an HTML color spec such as "#FF0000"
   * is allowed here too
   */
  gdk_color_parse ("red", &color);


  /* After filling in your GdkColor, create a GtkRcStyle */

  rc_style = gtk_rc_style_new ();

  /* Set foreground (fg) color in normal state to red */
  rc_style->fg[GTK_STATE_NORMAL] = color;

  /* Indicate which colors the GtkRcStyle will affect;
   * unflagged colors will follow the theme
   */
  rc_style->color_flags[GTK_STATE_NORMAL] |= GTK_RC_FG;

  gtk_widget_modify_style (widget, rc_style);

  gtk_rc_style_unref (rc_style);
--------------------------------------------------------

Anyone done this before?


Thanks,
Karl


_________________________________________________________________
The new MSN 8: smart spam protection and 2 months FREE*  
http://join.msn.com/?page=features/junkmail




More information about the gtkada mailing list