![]() |
![]() |
![]() |
Mx Toolkit Reference Manual | ![]() |
---|---|---|---|---|
Top | Description |
enum MxStyleChangedFlags; MxStylableIface; void mx_stylable_iface_install_property (MxStylableIface *iface
,GType owner_type
,GParamSpec *pspec
); void mx_stylable_freeze_notify (MxStylable *stylable
); void mx_stylable_notify (MxStylable *stylable
,const gchar *property_name
); void mx_stylable_thaw_notify (MxStylable *stylable
); GParamSpec ** mx_stylable_list_properties (MxStylable *stylable
,guint *n_props
); GParamSpec * mx_stylable_find_property (MxStylable *stylable
,const gchar *property_name
); void mx_stylable_set_style (MxStylable *stylable
,MxStyle *style
); MxStyle * mx_stylable_get_style (MxStylable *stylable
); void mx_stylable_get (MxStylable *stylable
,const gchar *first_property_name
,...
); void mx_stylable_get_property (MxStylable *stylable
,const gchar *property_name
,GValue *value
); gboolean mx_stylable_get_default_value (MxStylable *stylable
,const gchar *property_name
,GValue *value_out
); const gchar * mx_stylable_get_style_class (MxStylable *stylable
); void mx_stylable_set_style_class (MxStylable *stylable
,const gchar *style_class
); const gchar * mx_stylable_get_style_pseudo_class (MxStylable *stylable
); void mx_stylable_set_style_pseudo_class (MxStylable *stylable
,const gchar *pseudo_class
); void mx_stylable_style_changed (MxStylable *stylable
,MxStyleChangedFlags flags
); void mx_stylable_connect_change_notifiers (MxStylable *stylable
); void mx_stylable_apply_clutter_text_attributes (MxStylable *stylable
,ClutterText *text
);
Stylable objects are classes that can have "style properties", that is properties that can be changed by attaching a MxStyle to them.
typedef enum { MX_STYLE_CHANGED_NONE = 0, MX_STYLE_CHANGED_FORCE = 1 << 0, MX_STYLE_CHANGED_INVALIDATE_CACHE = 1 << 1 } MxStyleChangedFlags;
typedef struct { GTypeInterface g_iface; /* virtual functions */ MxStyle * (* get_style) (MxStylable *stylable); void (* set_style) (MxStylable *stylable, MxStyle *style); G_CONST_RETURN gchar* (* get_style_class) (MxStylable *stylable); void (* set_style_class) (MxStylable *stylable, const gchar *style_class); G_CONST_RETURN gchar* (* get_style_pseudo_class) (MxStylable *stylable); void (* set_style_pseudo_class) (MxStylable *stylable, const gchar *style_class); /* context virtual functions */ /* signals, not vfuncs */ #if 0 void (* style_notify) (MxStylable *stylable, GParamSpec *pspec); #endif void (* style_changed) (MxStylable *stylable, MxStyleChangedFlags flags); } MxStylableIface;
void mx_stylable_iface_install_property (MxStylableIface *iface
,GType owner_type
,GParamSpec *pspec
);
Installs a property for owner_type
using pspec
as the property
description.
This function should be used inside the MxStylableIface initialization function of a class, for instance:
G_DEFINE_TYPE_WITH_CODE (FooActor, foo_actor, CLUTTER_TYPE_ACTOR, G_IMPLEMENT_INTERFACE (MX_TYPE_STYLABLE, mx_stylable_init)); ... static void mx_stylable_init (MxStylableIface *iface) { static gboolean is_initialized = FALSE; if (!is_initialized) { ... mx_stylable_iface_install_property (stylable, FOO_TYPE_ACTOR, g_param_spec_int ("x-spacing", "X Spacing", "Horizontal spacing", -1, G_MAXINT, 2, G_PARAM_READWRITE)); ... } }
|
a MxStylableIface |
|
GType of the style property owner |
|
a GParamSpec |
GParamSpec ** mx_stylable_list_properties (MxStylable *stylable
,guint *n_props
);
Retrieves all the GParamSpecs installed by stylable
.
|
a MxStylable |
|
return location for the number of properties, or NULL . [out]
|
Returns : |
an array
of GParamSpecs. Free it with g_free() when done. [transfer container][array length=n_props]
|
GParamSpec * mx_stylable_find_property (MxStylable *stylable
,const gchar *property_name
);
Finds the GParamSpec installed by stylable
for the property
with property_name
.
|
a MxStylable |
|
the name of the property to find |
Returns : |
a GParamSpec for the given property,
or NULL if no property with that name was found. [transfer none]
|
void mx_stylable_set_style (MxStylable *stylable
,MxStyle *style
);
Sets style
as the new MxStyle to be used by stylable
.
The MxStylable will take ownership of the passed MxStyle.
After the MxStyle has been set, the MxStylable::style-set signal will be emitted.
|
a MxStylable |
|
a MxStyle |
MxStyle * mx_stylable_get_style (MxStylable *stylable
);
Retrieves the MxStyle used by stylable
. This function does not
alter the reference count of the returned object.
|
a MxStylable |
Returns : |
a MxStyle. [transfer none] |
void mx_stylable_get (MxStylable *stylable
,const gchar *first_property_name
,...
);
Gets the style properties for stylable
.
In general, a copy is made of the property contents and the called is responsible for freeing the memory in the appropriate manner for the property type.
Example 1. Using mx_stylable_get()
An example of using mx_stylable_get()
to get the contents of
two style properties - one of type G_TYPE_INT and one of type
CLUTTER_TYPE_COLOR:
gint x_spacing; ClutterColor *bg_color; mx_stylable_get (stylable, "x-spacing", &x_spacing, "bg-color", &bg_color, NULL); /* do something with x_spacing and bg_color */ clutter_color_free (bg_color);
|
a MxStylable |
|
name of the first property to get |
|
return location for the first property, followed optionally
by more name/return location pairs, followed by NULL
|
void mx_stylable_get_property (MxStylable *stylable
,const gchar *property_name
,GValue *value
);
Retrieves the value of property_name
for stylable
, and puts it
into value
.
|
a MxStylable |
|
the name of the property |
|
return location for an empty GValue. [out] |
gboolean mx_stylable_get_default_value (MxStylable *stylable
,const gchar *property_name
,GValue *value_out
);
Query stylable
for the default value of property property_name
and
fill value_out
with the result.
|
a MxStylable |
|
name of the property to query |
|
return location for the default value. [out] |
Returns : |
TRUE if property property_name exists and the default value has
been returned. |
const gchar * mx_stylable_get_style_class (MxStylable *stylable
);
Get the current style class name
|
a MxStylable |
Returns : |
the class name string. The string is owned by the MxWidget and should not be modified or freed. |
void mx_stylable_set_style_class (MxStylable *stylable
,const gchar *style_class
);
Set the style class name
|
a MxStylable |
|
a new style class string |
const gchar * mx_stylable_get_style_pseudo_class (MxStylable *stylable
);
Get the current style pseudo class
|
a MxStylable |
Returns : |
the pseudo class string. The string is owned by the MxWidget and should not be modified or freed. |
void mx_stylable_set_style_pseudo_class (MxStylable *stylable
,const gchar *pseudo_class
);
Set the style pseudo class
|
a MxStylable |
|
a new pseudo class string |
void mx_stylable_style_changed (MxStylable *stylable
,MxStyleChangedFlags flags
);
Emit the "style-changed" signal on stylable
to notify it that one or more
of the style properties has changed.
If stylable
is a ClutterContainer then the "style-changed" notification is
propagated to it's children, since their style may depend on one or more
properties of the parent.
|
an MxStylable |
|
flags that control the style changing |
void mx_stylable_connect_change_notifiers
(MxStylable *stylable
);
void mx_stylable_apply_clutter_text_attributes (MxStylable *stylable
,ClutterText *text
);