本文整理匯總了C++中GTK_COLOR_SWATCH函數的典型用法代碼示例。如果您正苦於以下問題:C++ GTK_COLOR_SWATCH函數的具體用法?C++ GTK_COLOR_SWATCH怎麽用?C++ GTK_COLOR_SWATCH使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了GTK_COLOR_SWATCH函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C++代碼示例。
示例1: gtk_color_swatch_measure
static void
gtk_color_swatch_measure (GtkCssGadget *gadget,
GtkOrientation orientation,
int for_size,
int *minimum,
int *natural,
int *minimum_baseline,
int *natural_baseline,
gpointer unused)
{
GtkWidget *widget;
GtkColorSwatch *swatch;
gint w, h, min;
widget = gtk_css_gadget_get_owner (gadget);
swatch = GTK_COLOR_SWATCH (widget);
gtk_css_gadget_get_preferred_size (swatch->priv->overlay_gadget,
orientation,
-1,
minimum, natural,
NULL, NULL);
gtk_widget_get_size_request (widget, &w, &h);
if (orientation == GTK_ORIENTATION_HORIZONTAL)
min = w < 0 ? 48 : w;
else
min = h < 0 ? 32 : h;
*minimum = MAX (*minimum, min);
*natural = MAX (*natural, min);
}
示例2: swatch_button_press
static gboolean
swatch_button_press (GtkWidget *widget,
GdkEventButton *event)
{
GtkColorSwatch *swatch = GTK_COLOR_SWATCH (widget);
gtk_widget_grab_focus (widget);
if (gdk_event_triggers_context_menu ((GdkEvent *) event) &&
swatch->priv->has_color)
{
do_popup (widget, event);
return TRUE;
}
else if (event->type == GDK_2BUTTON_PRESS &&
event->button == GDK_BUTTON_PRIMARY)
{
g_signal_emit (swatch, signals[ACTIVATE], 0);
return TRUE;
}
else if (event->button == GDK_BUTTON_PRIMARY)
{
return TRUE;
}
return FALSE;
}
示例3: swatch_realize
static void
swatch_realize (GtkWidget *widget)
{
GtkColorSwatch *swatch = GTK_COLOR_SWATCH (widget);
GtkAllocation allocation;
GdkWindow *window;
GdkWindowAttr attributes;
gint attributes_mask;
gtk_widget_get_allocation (widget, &allocation);
gtk_widget_set_realized (widget, TRUE);
attributes.window_type = GDK_WINDOW_CHILD;
attributes.x = allocation.x;
attributes.y = allocation.y;
attributes.width = allocation.width;
attributes.height = allocation.height;
attributes.wclass = GDK_INPUT_ONLY;
attributes.event_mask = gtk_widget_get_events (widget);
attributes.event_mask |= GDK_BUTTON_PRESS_MASK
| GDK_BUTTON_RELEASE_MASK
| GDK_ENTER_NOTIFY_MASK
| GDK_LEAVE_NOTIFY_MASK
| GDK_TOUCH_MASK;
attributes_mask = GDK_WA_X | GDK_WA_Y;
window = gtk_widget_get_parent_window (widget);
gtk_widget_set_window (widget, window);
g_object_ref (window);
swatch->priv->event_window = gdk_window_new (window, &attributes, attributes_mask);
gtk_widget_register_window (widget, swatch->priv->event_window);
}
示例4: swatch_key_press
static gboolean
swatch_key_press (GtkWidget *widget,
GdkEventKey *event)
{
GtkColorSwatch *swatch = GTK_COLOR_SWATCH (widget);
if (event->keyval == GDK_KEY_space ||
event->keyval == GDK_KEY_Return ||
event->keyval == GDK_KEY_ISO_Enter||
event->keyval == GDK_KEY_KP_Enter ||
event->keyval == GDK_KEY_KP_Space)
{
if (swatch->priv->has_color &&
swatch->priv->selectable &&
(gtk_widget_get_state_flags (widget) & GTK_STATE_FLAG_SELECTED) == 0)
gtk_widget_set_state_flags (widget, GTK_STATE_FLAG_SELECTED, FALSE);
else
g_signal_emit (swatch, signals[ACTIVATE], 0);
return TRUE;
}
if (GTK_WIDGET_CLASS (gtk_color_swatch_parent_class)->key_press_event (widget, event))
return TRUE;
return FALSE;
}
示例5: gtk_color_swatch_allocate
static void
gtk_color_swatch_allocate (GtkCssGadget *gadget,
const GtkAllocation *allocation,
int baseline,
GtkAllocation *out_clip,
gpointer unused)
{
GtkColorSwatch *swatch;
GtkAllocation overlay_alloc;
gint overlay_width, overlay_height;
swatch = GTK_COLOR_SWATCH (gtk_css_gadget_get_owner (gadget));
gtk_css_gadget_get_preferred_size (swatch->priv->overlay_gadget,
GTK_ORIENTATION_HORIZONTAL,
-1,
&overlay_width, NULL,
NULL, NULL);
gtk_css_gadget_get_preferred_size (swatch->priv->overlay_gadget,
GTK_ORIENTATION_VERTICAL,
-1,
&overlay_height, NULL,
NULL, NULL);
overlay_alloc.x = allocation->x + (allocation->width - overlay_width) / 2;
overlay_alloc.y = allocation->y + (allocation->height - overlay_height) / 2;
overlay_alloc.width = overlay_width;
overlay_alloc.height = overlay_height;
gtk_css_gadget_allocate (swatch->priv->overlay_gadget, &overlay_alloc, baseline, out_clip);
}
示例6: swatch_touch
static gboolean
swatch_touch (GtkWidget *widget,
GdkEventTouch *event)
{
GtkColorSwatch *swatch = GTK_COLOR_SWATCH (widget);
if (!swatch->priv->press_and_hold)
{
gint drag_threshold;
g_object_get (gtk_widget_get_settings (widget),
"gtk-dnd-drag-threshold", &drag_threshold,
NULL);
swatch->priv->press_and_hold = gtk_press_and_hold_new ();
g_object_set (swatch->priv->press_and_hold,
"drag-threshold", drag_threshold,
"hold-time", 1000,
NULL);
g_signal_connect (swatch->priv->press_and_hold, "hold",
G_CALLBACK (hold_action), swatch);
g_signal_connect (swatch->priv->press_and_hold, "tap",
G_CALLBACK (tap_action), swatch);
}
gtk_press_and_hold_process_event (swatch->priv->press_and_hold, (GdkEvent *)event);
return TRUE;
}
示例7: swatch_get_property
static void
swatch_get_property (GObject *object,
guint prop_id,
GValue *value,
GParamSpec *pspec)
{
GtkColorSwatch *swatch = GTK_COLOR_SWATCH (object);
GdkRGBA color;
switch (prop_id)
{
case PROP_RGBA:
gtk_color_swatch_get_rgba (swatch, &color);
g_value_set_boxed (value, &color);
break;
case PROP_SELECTABLE:
g_value_set_boolean (value, gtk_color_swatch_get_selectable (swatch));
break;
case PROP_HAS_MENU:
g_value_set_boolean (value, swatch->priv->has_menu);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
示例8: swatch_state_flags_changed
static void
swatch_state_flags_changed (GtkWidget *widget,
GtkStateFlags previous_state)
{
GtkColorSwatch *swatch = GTK_COLOR_SWATCH (widget);
gtk_css_node_set_state (swatch->priv->overlay_node, gtk_widget_get_state_flags (widget));
}
示例9: swatch_draw
static gboolean
swatch_draw (GtkWidget *widget,
cairo_t *cr)
{
gtk_css_gadget_draw (GTK_COLOR_SWATCH (widget)->priv->gadget, cr);
return FALSE;
}
示例10: swatch_finalize
static void
swatch_finalize (GObject *object)
{
GtkColorSwatch *swatch = GTK_COLOR_SWATCH (object);
g_free (swatch->priv->icon);
G_OBJECT_CLASS (gtk_color_swatch_parent_class)->finalize (object);
}
示例11: swatch_drag_begin
static void
swatch_drag_begin (GtkWidget *widget,
GdkDragContext *context)
{
GtkColorSwatch *swatch = GTK_COLOR_SWATCH (widget);
GdkRGBA color;
gtk_color_swatch_get_rgba (swatch, &color);
drag_set_color_icon (context, &color);
}
示例12: swatch_unmap
static void
swatch_unmap (GtkWidget *widget)
{
GtkColorSwatch *swatch = GTK_COLOR_SWATCH (widget);
if (swatch->priv->event_window)
gdk_window_hide (swatch->priv->event_window);
GTK_WIDGET_CLASS (gtk_color_swatch_parent_class)->unmap (widget);
}
示例13: swatch_leave_notify
static gboolean
swatch_leave_notify (GtkWidget *widget,
GdkEventCrossing *event)
{
GtkColorSwatch *swatch = GTK_COLOR_SWATCH (widget);
swatch->priv->contains_pointer = FALSE;
gtk_widget_unset_state_flags (widget, GTK_STATE_FLAG_PRELIGHT);
return FALSE;
}
示例14: swatch_get_preferred_height
static void
swatch_get_preferred_height (GtkWidget *widget,
gint *minimum,
gint *natural)
{
gtk_css_gadget_get_preferred_size (GTK_COLOR_SWATCH (widget)->priv->gadget,
GTK_ORIENTATION_VERTICAL,
-1,
minimum, natural,
NULL, NULL);
}
示例15: gtk_color_editor_set_use_alpha
static void
gtk_color_editor_set_use_alpha (GtkColorEditor *editor,
gboolean use_alpha)
{
if (editor->priv->use_alpha != use_alpha)
{
editor->priv->use_alpha = use_alpha;
gtk_widget_set_visible (editor->priv->a_slider, use_alpha);
gtk_color_swatch_set_use_alpha (GTK_COLOR_SWATCH (editor->priv->swatch), use_alpha);
}
}