示例#1
0
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);
}
示例#2
0
static void
gtk_switch_allocate_contents (GtkCssGadget        *gadget,
                              const GtkAllocation *allocation,
                              int                  baseline,
                              GtkAllocation       *out_clip,
                              gpointer             unused)
{
  GtkSwitch *self = GTK_SWITCH (gtk_css_gadget_get_owner (gadget));
  GtkSwitchPrivate *priv = self->priv;
  GtkAllocation slider_alloc;
  
  slider_alloc.x = allocation->x + round (priv->handle_pos * (allocation->width - allocation->width / 2));
  slider_alloc.y = allocation->y;
  slider_alloc.width = allocation->width / 2;
  slider_alloc.height = allocation->height;

  gtk_css_gadget_allocate (priv->slider_gadget,
                           &slider_alloc,
                           baseline,
                           out_clip);

  if (gtk_widget_get_realized (GTK_WIDGET (self)))
    {
      GtkAllocation border_allocation;
      gtk_css_gadget_get_border_allocation (gadget, &border_allocation, NULL);
      gdk_window_move_resize (priv->event_window,
                              border_allocation.x,
                              border_allocation.y,
                              border_allocation.width,
                              border_allocation.height);
    }
}
示例#3
0
static void
gtk_level_bar_allocate_trough_continuous (GtkLevelBar *self,
                                          const GtkAllocation *allocation,
                                          int baseline,
                                          GtkAllocation *out_clip)
{
  GtkAllocation block_area, clip;
  gdouble fill_percentage;
  gboolean inverted;

  inverted = gtk_level_bar_get_real_inverted (self);

  /* allocate the empty (unfilled) part */
  block_area = *allocation;
  gtk_css_gadget_allocate (self->priv->block_gadget[inverted ? 0 : 1],
                           &block_area,
                           baseline,
                           out_clip);

  /* now allocate the filled part */
  block_area = *allocation;
  fill_percentage = (self->priv->cur_value - self->priv->min_value) /
    (self->priv->max_value - self->priv->min_value);

  if (self->priv->orientation == GTK_ORIENTATION_HORIZONTAL)
    {
      block_area.width = (gint) floor (block_area.width * fill_percentage);

      if (inverted)
        block_area.x += allocation->width - block_area.width;
    }
  else
    {
      block_area.height = (gint) floor (block_area.height * fill_percentage);

      if (inverted)
        block_area.y += allocation->height - block_area.height;
    }

  gtk_css_gadget_allocate (self->priv->block_gadget[inverted ? 1 : 0],
                           &block_area,
                           baseline,
                           &clip);
  gdk_rectangle_intersect (out_clip, &clip, out_clip);
}
示例#4
0
static void
gtk_switch_size_allocate (GtkWidget     *widget,
                          GtkAllocation *allocation)
{
  GtkSwitchPrivate *priv = GTK_SWITCH (widget)->priv;
  GtkAllocation clip;

  gtk_widget_set_allocation (widget, allocation);
  gtk_css_gadget_allocate (priv->gadget,
                           allocation,
                           gtk_widget_get_allocated_baseline (widget),
                           &clip);

  gtk_widget_set_clip (widget, &clip);
}
示例#5
0
static void
gtk_level_bar_size_allocate (GtkWidget     *widget,
                             GtkAllocation *allocation)
{
  GtkAllocation clip;

  GTK_WIDGET_CLASS (gtk_level_bar_parent_class)->size_allocate (widget, allocation);

  gtk_css_gadget_allocate (GTK_LEVEL_BAR (widget)->priv->trough_gadget,
                           allocation,
                           gtk_widget_get_allocated_baseline (widget),
                           &clip);

  gtk_widget_set_clip (widget, &clip);
}
示例#6
0
static void
gtk_button_size_allocate (GtkWidget     *widget,
			  GtkAllocation *allocation)
{
  GtkButton *button = GTK_BUTTON (widget);
  GtkButtonPrivate *priv = button->priv;
  GtkAllocation clip;

  gtk_widget_set_allocation (widget, allocation);
  gtk_css_gadget_allocate (priv->gadget,
                           allocation,
                           gtk_widget_get_allocated_baseline (widget),
                           &clip);

  gtk_widget_set_clip (widget, &clip);
}
示例#7
0
static void
gtk_level_bar_allocate_trough_discrete (GtkLevelBar *self,
                                        const GtkAllocation *allocation,
                                        int baseline,
                                        GtkAllocation *out_clip)
{
  GtkAllocation block_area, clip;
  gint num_blocks, i;
  gint block_width, block_height;

  gtk_level_bar_get_min_block_size (self, &block_width, &block_height);
  num_blocks = gtk_level_bar_get_num_blocks (self);

  if (self->priv->orientation == GTK_ORIENTATION_HORIZONTAL)
    {
      block_width = MAX (block_width, (gint) floor (allocation->width / num_blocks));
      block_height = allocation->height;
    }
  else
    {
      block_width = allocation->width;
      block_height = MAX (block_height, (gint) floor (allocation->height / num_blocks));
    }

  block_area.x = allocation->x;
  block_area.y = allocation->y;
  block_area.width = block_width;
  block_area.height = block_height;

  for (i = 0; i < num_blocks; i++)
    {
      gtk_css_gadget_allocate (self->priv->block_gadget[i],
                               &block_area,
                               baseline,
                               &clip);
      gdk_rectangle_intersect (out_clip, &clip, out_clip);

      if (self->priv->orientation == GTK_ORIENTATION_HORIZONTAL)
        block_area.x += block_area.width;
      else
        block_area.y += block_area.height;
    }
}
示例#8
0
static void
swatch_size_allocate (GtkWidget     *widget,
                      GtkAllocation *allocation)
{
    GtkColorSwatch *swatch = GTK_COLOR_SWATCH (widget);
    GtkAllocation clip;

    gtk_widget_set_allocation (widget, allocation);

    if (gtk_widget_get_realized (widget))
        gdk_window_move_resize (swatch->priv->event_window,
                                allocation->x,
                                allocation->y,
                                allocation->width,
                                allocation->height);

    gtk_css_gadget_allocate (swatch->priv->gadget,
                             allocation,
                             gtk_widget_get_allocated_baseline (widget),
                             &clip);

    gtk_widget_set_clip (widget, &clip);
}