States are as follows:
enum GtkStateType
Code: Select all
typedef enum
{
GTK_STATE_NORMAL,
GTK_STATE_ACTIVE,
GTK_STATE_PRELIGHT,
GTK_STATE_SELECTED,
GTK_STATE_INSENSITIVE
} GtkStateType;
This type indicates the current state of a widget; the state determines how the widget is drawn. The GtkStateType enumeration is also used to identify different colors in a GtkStyle for drawing, so states can be used for subparts of a widget as well as entire widgets.
GTK_STATE_NORMAL
State during normal operation.
GTK_STATE_ACTIVE
State of a currently active widget, such as a depressed button.
GTK_STATE_PRELIGHT
State indicating that the mouse pointer is over the widget and the widget will respond to mouse clicks.
GTK_STATE_SELECTED
State of a selected item, such the selected row in a list.
GTK_STATE_INSENSITIVE
State indicating that the widget is unresponsive to user actions.
And the color changing methods are:
Code: Select all
gtk_widget_modify_fg ()
void gtk_widget_modify_fg (GtkWidget *widget,
GtkStateType state,
const GdkColor *color);
Sets the foreground color for a widget in a particular state. All other style values are left untouched. See also gtk_widget_modify_style().
widget :
a GtkWidget
state :
the state for which to set the foreground color
color :
the color to assign (does not need to be allocated), or NULL to undo the effect of previous calls to of gtk_widget_modify_fg().
Code: Select all
gtk_widget_modify_bg ()
void gtk_widget_modify_bg (GtkWidget *widget,
GtkStateType state,
const GdkColor *color);
Sets the background color for a widget in a particular state. All other style values are left untouched. See also gtk_widget_modify_style().
Note that "no window" widgets (which have the GTK_NO_WINDOW flag set) draw on their parent container's window and thus may not draw any background themselves. This is the case for e.g. GtkLabel. To modify the background of such widgets, you have to set the background color on their parent; if you want to set the background of a rectangular area around a label, try placing the label in a GtkEventBox widget and setting the background color on that.
widget :
a GtkWidget
state :
the state for which to set the background color
color :
the color to assign (does not need to be allocated), or NULL to undo the effect of previous calls to of gtk_widget_modify_bg().
Code: Select all
gtk_widget_modify_text ()
void gtk_widget_modify_text (GtkWidget *widget,
GtkStateType state,
const GdkColor *color);
Sets the text color for a widget in a particular state. All other style values are left untouched. The text color is the foreground color used along with the base color (see gtk_widget_modify_base()) for widgets such as GtkEntry and GtkTextView. See also gtk_widget_modify_style().
widget :
a GtkWidget
state :
the state for which to set the text color
color :
the color to assign (does not need to be allocated), or NULL to undo the effect of previous calls to of gtk_widget_modify_text().
Code: Select all
gtk_widget_modify_base ()
void gtk_widget_modify_base (GtkWidget *widget,
GtkStateType state,
const GdkColor *color);
Sets the base color for a widget in a particular state. All other style values are left untouched. The base color is the background color used along with the text color (see gtk_widget_modify_text()) for widgets such as GtkEntry and GtkTextView. See also gtk_widget_modify_style().
Note that "no window" widgets (which have the GTK_NO_WINDOW flag set) draw on their parent container's window and thus may not draw any background themselves. This is the case for e.g. GtkLabel. To modify the background of such widgets, you have to set the base color on their parent; if you want to set the background of a rectangular area around a label, try placing the label in a GtkEventBox widget and setting the base color on that.
widget :
a GtkWidget
state :
the state for which to set the base color
color :
the color to assign (does not need to be allocated), or NULL to undo the effect of previous calls to of gtk_widget_modify_base().
However I tried modify_text for my button and it didn't work. I tried setting background colors for different states and got that working fine with this code:
Code: Select all
METHOD SetColor( cColor ) INLINE MsgInfo( "red"), GtkSetColor( ::hWnd, cColor )
#pragma BEGINDUMP
#include <hbapi.h>
#include <gtk/gtk.h>
HB_FUNC( GTKSETCOLOR )
{
GdkColor color;
GdkColor acolor;
gdk_color_parse( "red", &color );
gdk_color_parse( "yellow", &acolor );
gtk_widget_modify_bg( ( GtkWidget * ) hb_parnl( 1 ), GTK_STATE_NORMAL, &color );
gtk_widget_modify_bg( ( GtkWidget * ) hb_parnl( 1 ), GTK_STATE_PRELIGHT, &acolor );
}
#pragma ENDDUMP
So a generic SetColor might take color names for the various states.
Could you tell me the best way to debug why I don't seem to be getting the string valuse passed in to the C code.
Thanks
Doug