Marc Santhoff napisaƂ(a):
Hi,
from studying the patch and searching for information on setting color
on gtk i wonder if setting the flags on the corresponding GtkStyle is
the missing part. Maybe this is done in initializations somewhere I
didn't look at.

I found the following piece of documentation (without knowing where it's
coming from, there is only a mail address in a document titled "GTK
colors mini-FAQ"):
Thx, its helpful, I forget about styleunref,

But in LCL is more problem
1. Many components has more than one widgets (for example tButton has two) and I don;t want to create new style for everyone 2. Set color must be invoked in proper way, during initialization (this is done, i think) and runtime


Can You sent me example program to test colors

Darek


<snip>
Short answer: how to set the color of a widget
In GTK+ 1.2:
  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);

</snip>

Immediately before the call to "gtk_widget_modify_style" the flags for
colors to use is set.

A working snippet from my own code looks like this:

<snip>
st:     pGtkRcStyle;
cola:   TGdkColor;
...
gdk_color_parse(SPEED_COLOR_ACTIVE, @cola);     
st := gtk_rc_style_new ();
st^.bg[GTK_STATE_ACTIVE] := cola;
st^.color_flags[GTK_STATE_ACTIVE] := st^.color_flags[GTK_STATE_ACTIVE] OR GTK_RC_BG;
gtk_widget_modify_style(GTK_WIDGET(TState(_me).scales[0]), st);
</snip>

HTH,
Marc


_________________________________________________________________
     To unsubscribe: mail [EMAIL PROTECTED] with
                "unsubscribe" as the Subject
   archives at http://www.lazarus.freepascal.org/mailarchives



_________________________________________________________________
    To unsubscribe: mail [EMAIL PROTECTED] with
               "unsubscribe" as the Subject
  archives at http://www.lazarus.freepascal.org/mailarchives

Reply via email to