JNIEXPORT void JNICALL
Java_gnu_java_awt_peer_gtk_GdkGraphics_setClipRectangle
  (JNIEnv *env, jobject obj, jint x, jint y, jint width, jint height)
{
  struct graphics *g;
  GdkRectangle rectangle;

  g = (struct graphics *) NSA_GET_PTR (env, obj);

  rectangle.x = x + g->x_offset;
  rectangle.y = y + g->y_offset;
  rectangle.width = width;
  rectangle.height = height;

  gdk_threads_enter ();
  gdk_gc_set_clip_rectangle (g->gc, &rectangle);
  gdk_threads_leave ();
}
/* Draw the exon view */
static void drawExonView(GtkWidget *exonView, GdkDrawable *drawable)
{
  DEBUG_ENTER("drawExonView");
  
  ExonViewProperties *properties = exonViewGetProperties(exonView);
  DotterContext *dc = properties->dc;

  GdkGC *gc = gdk_gc_new(drawable);

  /* Set a clip rectangle for drawing the exons and introns (because they are drawn "over the
   * edges" to make sure intron lines have the correct slope etc.) */
  gdk_gc_set_clip_origin(gc, 0, 0);
  gdk_gc_set_clip_rectangle(gc, &properties->exonViewRect);
  
  /* Draw the exons and introns. Since we could have a lot of them in the loop, extract all the
   * info we need now and pass it around so we don't have to look for this stuff each time. */
  
  DrawData drawData = {
    properties->parent,
    drawable,
    gc,
    properties->dc,
    properties->dwc,
    
    &properties->exonViewRect,
    properties->qRange,
    
    properties->yPad,
    properties->horizontal ? properties->exonViewRect.y : properties->exonViewRect.x,
    properties->exonHeight,

    properties->strand,
    properties->horizontal,
    properties->bumped,
    FALSE
  };
  
  /* Loop through all sequences, drawing all msps that are exons/introns */
  GList *seqList = dc->seqList;
  g_list_foreach(seqList, drawExonIntronItem, &drawData);

  g_object_unref(gc);
  DEBUG_EXIT("drawExonView returning ");
}
Esempio n. 3
0
static void
draw_string (GtkStyle     *style,
             GdkWindow    *window,
             GtkStateType  state,
             GdkRectangle *area,
             GtkWidget    *widget,
             const gchar  *detail,
             gint          x,
             gint          y,
             const gchar  *string)
{
  g_return_if_fail (style != NULL);
  g_return_if_fail (window != NULL);

  /* FIXME: memory leak */
  LOG ("widget=%s, primitive=string, state=%s, detail='%s', name='%s'",
        G_OBJECT_TYPE_NAME (widget),
        enum_value_to_string (gtk_state_type_get_type (), state),
        detail,
        gtk_widget_get_name (widget));

  if (state == GTK_STATE_INSENSITIVE)
    {
      if (area)
	{
	  gdk_gc_set_clip_rectangle (style->white_gc, area);
	  gdk_gc_set_clip_rectangle (style->fg_gc[state], area);
	}

      gdk_draw_string (window, gtk_style_get_font (style),
                       style->fg_gc[state], x, y, string);

      if (area)
	{
	  gdk_gc_set_clip_rectangle (style->white_gc, NULL);
	  gdk_gc_set_clip_rectangle (style->fg_gc[state], NULL);
	}
    }
  else
    {
      gdk_gc_set_clip_rectangle (style->fg_gc[state], area);
      gdk_draw_string (window, gtk_style_get_font (style),
                       style->fg_gc[state], x, y, string);
      gdk_gc_set_clip_rectangle (style->fg_gc[state], NULL);
    }
}
Esempio n. 4
0
/* This function is based on a portion of EnGradient's draw_box */
void
draw_default_triangle(GtkStyle * style,
	              GdkWindow * window,
	              GtkStateType state_type,
	              GtkShadowType shadow_type,
	              GdkRectangle * area,
	              GtkWidget * widget,
	              const gchar * detail,
		      gint x,
		      gint y,
		      gint width,
		      gint height)
{
  GdkPoint points1[3]; /* dark */
  GdkPoint points2[3]; /* light */
  
  points1[0].x = x+2;  points1[0].y = y+2;
  points1[1].x = x+10; points1[1].y = y+2;
  points1[2].x = x+2;  points1[2].y = y+10;
  points2[0].x = x+3;  points2[0].y = y+3;
  points2[1].x = x+10; points2[1].y = y+3;
  points2[2].x = x+3;  points2[2].y = y+10;

   if (area) {
     gdk_gc_set_clip_rectangle(style->bg_gc[state_type], area);
     gdk_gc_set_clip_rectangle(style->light_gc[state_type], area);
     gdk_gc_set_clip_rectangle(style->dark_gc[state_type], area);
   } 
	
   /* Paint a triangle here instead of in "buttondefault"
      which is drawn _behind_ the current button */
   if (GTK_WIDGET_HAS_DEFAULT (widget)) {
     gdk_draw_polygon(window, style->dark_gc[state_type], FALSE, points1, 3);
     gdk_draw_polygon(window, style->light_gc[state_type], FALSE, points2, 3);
     gdk_draw_polygon(window, style->bg_gc[GTK_STATE_SELECTED], TRUE, points2, 3);
   }

   if (area) {
     gdk_gc_set_clip_rectangle(style->bg_gc[state_type], NULL);
     gdk_gc_set_clip_rectangle(style->light_gc[state_type], NULL);
     gdk_gc_set_clip_rectangle(style->dark_gc[state_type], NULL);
   } 
}
Esempio n. 5
0
static void
draw_string (GtkStyle * style,
	     GdkWindow * window,
	     GtkStateType state,
	     GdkRectangle * area,
	     GtkWidget * widget,
	     const gchar *detail,
	     gint x,
	     gint y,
	     const gchar * string)
{
  PangoLayout *layout = NULL;

  g_return_if_fail(style != NULL);
  g_return_if_fail(window != NULL);

  layout = gtk_widget_create_pango_layout (widget, string);

  if (state == GTK_STATE_INSENSITIVE)
    {
      if (area)
	{
	  gdk_gc_set_clip_rectangle(style->white_gc, area);
	  gdk_gc_set_clip_rectangle(style->fg_gc[state], area);
	}

      gdk_draw_layout(GDK_DRAWABLE (window), style->fg_gc[state], x, y, layout);
      
      if (area)
	{
	  gdk_gc_set_clip_rectangle(style->white_gc, NULL);
	  gdk_gc_set_clip_rectangle(style->fg_gc[state], NULL);
	}
    }
  else
    {
      gdk_gc_set_clip_rectangle(style->fg_gc[state], area);
      gdk_draw_layout(GDK_DRAWABLE (window), style->fg_gc[state], x, y, layout);
      gdk_gc_set_clip_rectangle(style->fg_gc[state], NULL);
    }
}
Esempio n. 6
0
static void
draw_string (GtkStyle * style,
	     GdkWindow * window,
	     GtkStateType state,
	     GdkRectangle * area,
	     GtkWidget * widget,
	     const gchar *detail,
	     gint x,
	     gint y,
	     const gchar * string)
{
  g_return_if_fail(style != NULL);
  g_return_if_fail(window != NULL);

  if (state == GTK_STATE_INSENSITIVE)
    {
      if (area)
	{
	  gdk_gc_set_clip_rectangle(style->white_gc, area);
	  gdk_gc_set_clip_rectangle(style->fg_gc[state], area);
	}

      gdk_draw_string(window, gtk_style_get_font (style), style->fg_gc[state], x, y, string);
      
      if (area)
	{
	  gdk_gc_set_clip_rectangle(style->white_gc, NULL);
	  gdk_gc_set_clip_rectangle(style->fg_gc[state], NULL);
	}
    }
  else
    {
      gdk_gc_set_clip_rectangle(style->fg_gc[state], area);
      gdk_draw_string(window, gtk_style_get_font (style), style->fg_gc[state], x, y, string);
      gdk_gc_set_clip_rectangle(style->fg_gc[state], NULL);
    }
}
Esempio n. 7
0
void iupdrvDrawText(IdrawCanvas* dc, const char* text, int len, int x, int y, int w, int h, long color, const char* font, int flags, double text_orientation)
{
  PangoLayout* fontlayout = (PangoLayout*)iupgtkGetPangoLayout(font);
  PangoAlignment alignment = PANGO_ALIGN_LEFT;
  GdkColor c;
  PangoContext* fontcontext = NULL;
  int layout_w = w, layout_h = h;
  int layout_center = flags & IUP_DRAW_LAYOUTCENTER;

  if (text_orientation && layout_center)
    iupDrawGetTextInnerBounds(w, h, text_orientation, &layout_w, &layout_h);

  iupgdkColorSet(&c, color);
  gdk_gc_set_rgb_fg_color(dc->pixmap_gc, &c);

  text = iupgtkStrConvertToSystemLen(text, &len);
  pango_layout_set_text(fontlayout, text, len);

  if (flags & IUP_DRAW_RIGHT)
    alignment = PANGO_ALIGN_RIGHT;
  else if (flags & IUP_DRAW_CENTER)
    alignment = PANGO_ALIGN_CENTER;

  if (flags & IUP_DRAW_WRAP)
  {
    pango_layout_set_width(fontlayout, iupGTK_PIXELS2PANGOUNITS(layout_w));
#ifdef PANGO_VERSION_CHECK
#if PANGO_VERSION_CHECK(1,2,0)  
    pango_layout_set_height(fontlayout, iupGTK_PIXELS2PANGOUNITS(layout_h));
#endif
#endif
  }
  else if (flags & IUP_DRAW_ELLIPSIS)
  {
    pango_layout_set_width(fontlayout, iupGTK_PIXELS2PANGOUNITS(layout_w));
#ifdef PANGO_VERSION_CHECK
#if PANGO_VERSION_CHECK(1,2,0)  
    pango_layout_set_height(fontlayout, iupGTK_PIXELS2PANGOUNITS(layout_h));
#endif
#endif
    pango_layout_set_ellipsize(fontlayout, PANGO_ELLIPSIZE_END);
  }

  pango_layout_set_alignment(fontlayout, alignment);

  if (flags & IUP_DRAW_CLIP)
  {
    GdkRectangle rect;
    rect.x = x;
    rect.y = y;
    rect.width = w;
    rect.height = h;
    gdk_gc_set_clip_rectangle(dc->pixmap_gc, &rect);
  }

  if (text_orientation)
  {
    PangoRectangle rect;
    PangoMatrix fontmatrix = PANGO_MATRIX_INIT;
    fontcontext = pango_layout_get_context(fontlayout);

    pango_matrix_rotate(&fontmatrix, text_orientation);

    pango_context_set_matrix(fontcontext, &fontmatrix);
    pango_layout_context_changed(fontlayout);

    pango_layout_get_pixel_extents(fontlayout, NULL, &rect);
#ifdef PANGO_VERSION_CHECK
#if PANGO_VERSION_CHECK(1,16,0)
    pango_matrix_transform_pixel_rectangle(&fontmatrix, &rect);
#endif
#endif

    /* Adjust the position considering the Pango rectangle transformed */
    if (layout_center)
    {
      x += (w - rect.width) / 2;
      y += (h - rect.height) / 2;
    }
    else
    {
      x += (int)rect.x;
      y += (int)rect.y;
    }
  }

  gdk_draw_layout(dc->pixmap, dc->pixmap_gc, x, y, fontlayout);

  /* restore settings */
  if ((flags & IUP_DRAW_WRAP) || (flags & IUP_DRAW_ELLIPSIS))
  {
    pango_layout_set_width(fontlayout, -1);
#ifdef PANGO_VERSION_CHECK
#if PANGO_VERSION_CHECK(1,2,0)  
    pango_layout_set_height(fontlayout, -1);
#endif
#endif
  }
  if (flags & IUP_DRAW_ELLIPSIS)
    pango_layout_set_ellipsize(fontlayout, PANGO_ELLIPSIZE_NONE);
  if (flags & IUP_DRAW_CLIP)
    gdk_gc_set_clip_region(dc->pixmap_gc, NULL);
  if (text_orientation)
    pango_context_set_matrix(fontcontext, NULL);
}
Esempio n. 8
0
static void _unset_clipping(MT_GC *gc)
{
   MT_GTK_GC *mtgc = (MT_GTK_GC *)gc;

   gdk_gc_set_clip_rectangle(mtgc->gc, NULL);
}
Esempio n. 9
0
  /* Do the Pango text rendering.  If called when pixmap is bg_text_layer,
  |  it is a background draw.  But if called from push_decal_pixmaps() it is
  |  considered a push operation because it is being done whenever any panel
  |  decals or krells are modified.  In this case, Pango does the pixel pushing
  |  instead of gkrellm as was done in pre 2.2.0.
  */
static void
panel_draw_decal_text_list(GdkPixmap *pixmap, GkrellmDecal *d)
	{
	PangoLayout			*layout;
	GdkRectangle		rect;
	GList				*list;
	GkrellmText			*tx;
	GkrellmTextstyle	*ts;
	gchar				*s;
	gint				x, y;

	layout = gtk_widget_create_pango_layout(gkrellm_get_top_window(), NULL);
	rect.x = d->x;
	rect.y = d->y;
	rect.width = d->w;
	rect.height = d->h;
	gdk_gc_set_clip_rectangle(_GK.text_GC, &rect);
	for (list = d->text_list; list; list = list->next)
		{
		tx = (GkrellmText *) list->data;
		if (!*tx->text)
			continue;
		ts = &tx->text_style;

		pango_layout_set_font_description(layout, ts->font);
		x = tx->x_off;
		y = tx->y_off;
		if (d->flags & DF_SCROLL_TEXT_DIVERTED)
			{
			if (d->flags & DF_SCROLL_TEXT_CENTER)
				pango_layout_set_alignment(layout, PANGO_ALIGN_CENTER);
			if (d->flags & DF_SCROLL_TEXT_H_LOOP)
				{
				x %= d->scroll_width;
				if (x > 0)
					x -= d->scroll_width;
				s = g_strconcat(tx->text, tx->text, NULL);
				if (d->flags & DF_TEXT_USE_MARKUP)
					pango_layout_set_markup(layout, s, strlen(s));
				else
					pango_layout_set_text(layout, s, strlen(s));
				g_free(s);
				}
			else if (d->flags & DF_SCROLL_TEXT_V_LOOP)
				{
				y %= d->scroll_height + d->y_ink;
				if (y > 0)
					y -= d->scroll_height + d->y_ink;
				s = g_strconcat(tx->text, "\n", tx->text, NULL);
				if (d->flags & DF_TEXT_USE_MARKUP)
					pango_layout_set_markup(layout, s, strlen(s));
				else
					pango_layout_set_text(layout, s, strlen(s));
				g_free(s);
				}
			else
				{
				if (d->flags & DF_TEXT_USE_MARKUP)
					pango_layout_set_markup(layout, tx->text,strlen(tx->text));
				else
					pango_layout_set_text(layout, tx->text, strlen(tx->text));
				}
			}
		else
			{
			if (d->flags & DF_TEXT_USE_MARKUP)
				pango_layout_set_markup(layout, tx->text, strlen(tx->text));
			else
				pango_layout_set_text(layout, tx->text, strlen(tx->text));
			}
		x += d->x;
		y += d->y;

		if (ts->effect)
			{
			gdk_gc_set_foreground(_GK.text_GC, &ts->shadow_color);
			gdk_draw_layout_with_colors(pixmap, _GK.text_GC,
						x + 1, y + 1, layout,
						&ts->shadow_color, NULL);
			}
		gdk_gc_set_foreground(_GK.text_GC, &ts->color);
		gdk_draw_layout(pixmap, _GK.text_GC, x, y, layout);
		}
	gdk_gc_set_clip_rectangle(_GK.text_GC, NULL);
	g_object_unref(layout);
	}
Esempio n. 10
0
void cl_draw_combobox_button (GtkStyle *style, GdkWindow *window,
                    GtkStateType state_type, GtkShadowType shadow_type,
                    GdkRectangle *area,
                    GtkWidget *widget, const gchar *detail,
                    gint x, gint y, gint width, gint height)
{
	ClearlooksStyle *clearlooks_style = CLEARLOOKS_STYLE(style);
	gboolean is_active  = FALSE;
	gboolean draw_inset = FALSE;
	CLRectangle r;

	cl_rectangle_set_button (&r, style, state_type,
	                         GTK_WIDGET_HAS_DEFAULT  (widget),
	                         GTK_WIDGET_HAS_FOCUS (widget),
	                         CL_CORNER_NONE, CL_CORNER_ROUND,
	                         CL_CORNER_NONE, CL_CORNER_ROUND);
	
	if (state_type == GTK_STATE_ACTIVE)
		is_active = TRUE;
	else
		r.fillgc = NULL;
	
	/* Seriously, why can't non-gtk-apps at least try to be decent citizens?
	   Take this fscking OpenOffice.org 1.9 for example. The morons responsible
	   for this utter piece of crap give the clip size wrong values! :'(  */
	
	if (area)
	{
		area->x = x;
		area->y = y;
		area->width = width;
		area->height = height;
	}

	x--;
	width++;
	
	/* Draw "sunken" look when border thickness is more than 2 pixels. */
	if (GTK_IS_COMBO(widget->parent))
		draw_inset = (widget->parent->style->xthickness > 2 &&
	                  widget->parent->style->ythickness > 2);
	else
		draw_inset = (style->xthickness > 2 && style->ythickness > 2);
		
	if (draw_inset)
	{
		cl_draw_inset (style, window, widget, area, x, y, width, height,
		               CL_CORNER_NONE, CL_CORNER_ROUND,
		               CL_CORNER_NONE, CL_CORNER_ROUND);
	
		x++;
		y++;
		height-=2;
		width-=2;
	}
	else
	{
		x++;
		width--;
	}
	
	if (area)
		cl_rectangle_set_clip_rectangle (&r, area);

	cl_draw_rectangle (window, widget, style, x, y, width, height, &r);
	
	if (!is_active)
	{
		int tmp_height = (float)height*0.25;
	
		gdk_gc_set_clip_rectangle (style->bg_gc[state_type], area);
		
		draw_hgradient (window, style->bg_gc[state_type], style,
		                x+2,y+2,width-4,tmp_height,
		                &clearlooks_style->button_g1[state_type],
			            &clearlooks_style->button_g2[state_type]);
		
		draw_hgradient (window, style->bg_gc[state_type], style,
		                x+2, y+2+tmp_height, width-4, height-3-tmp_height*2,
		                &clearlooks_style->button_g2[state_type],
			            &clearlooks_style->button_g3[state_type]);
		
		draw_hgradient (window, style->bg_gc[state_type], style,
		                x+2,y+height-tmp_height-1,width-4,tmp_height,
		                &clearlooks_style->button_g3[state_type],
			            &clearlooks_style->button_g4[state_type]);

		gdk_gc_set_clip_rectangle (style->bg_gc[state_type], NULL);
	}					
	
	cl_draw_shadow    (window, widget, style, x, y, width, height, &r);

	if (area)
		cl_rectangle_reset_clip_rectangle (&r);
}
Esempio n. 11
0
/* Draw a normal (toggle)button. Not spinbuttons.*/ 
void cl_draw_button(GtkStyle *style, GdkWindow *window,
                    GtkStateType state_type, GtkShadowType shadow_type,
                    GdkRectangle *area,
                    GtkWidget *widget, const gchar *detail,
                    gint x, gint y, gint width, gint height)
{
	ClearlooksStyle *clearlooks_style = CLEARLOOKS_STYLE(style);
	int my_state_type = (state_type == GTK_STATE_ACTIVE) ? 2 : 0;
	GdkGC *bg_gc = NULL;
	gboolean is_active = FALSE;
	CLRectangle r;
	
	/* Get the background color of the window we're on */
	bg_gc = cl_get_window_bg_gc(widget);
	
	cl_rectangle_set_button (&r, style, state_type,
	                         GTK_WIDGET_HAS_DEFAULT (widget),
	                         GTK_WIDGET_HAS_FOCUS (widget),
	                         CL_CORNER_ROUND, CL_CORNER_ROUND,
	                         CL_CORNER_ROUND, CL_CORNER_ROUND);
		
	if (state_type == GTK_STATE_ACTIVE)
		is_active = TRUE;

	if (GTK_IS_TOGGLE_BUTTON(widget) &&
	    gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON(widget)) &&
	    state_type == GTK_STATE_PRELIGHT)
	{
		cl_rectangle_set_gradient (&r.fill_gradient, &clearlooks_style->shade[1], &clearlooks_style->shade[1]);
		r.topleft     = clearlooks_style->shade_gc[3];
		r.bottomright = clearlooks_style->shade_gc[1];
		
		is_active = TRUE;
	}	

	if (!is_active)
		r.fillgc = NULL;
		
	if (!GTK_IS_NOTEBOOK (widget->parent))
	{
		gdk_draw_rectangle (window, bg_gc, FALSE, x, y, width-1, height-1);
	
		/* Draw "sunken" look when border thickness is more than 2 pixels. */
		if (style->xthickness > 2 && style->ythickness > 2)
		cl_draw_inset (style, window, widget, area, x, y, width, height,
		               CL_CORNER_ROUND, CL_CORNER_ROUND,
		               CL_CORNER_ROUND, CL_CORNER_ROUND);
	}
	
	/* Draw "sunken" look when border thickness is more than 2 pixels.*/
	if (style->xthickness > 2 && style->ythickness > 2)
	{
		x++;
		y++;
		height-=2;
		width-=2;
	}
	
	/* Don't draw the normal gradient for normal buttons. */

	cl_rectangle_set_clip_rectangle (&r, area);
	cl_draw_rectangle (window, widget, style, x, y, width, height, &r);
	
	
	if (!is_active) 
	{
		int tmp_height = (float)height*0.25;
	
		gdk_gc_set_clip_rectangle (style->bg_gc[state_type], area);
		
		draw_hgradient (window, style->bg_gc[state_type], style,
		                x+2,y+2,width-4,tmp_height,
		                &clearlooks_style->button_g1[state_type],
			            &clearlooks_style->button_g2[state_type]);
		
		draw_hgradient (window, style->bg_gc[state_type], style,
		                x+2, y+2+tmp_height, width-4, height-3-tmp_height*2,
		                &clearlooks_style->button_g2[state_type],
			            &clearlooks_style->button_g3[state_type]);
		
		draw_hgradient (window, style->bg_gc[state_type], style,
		                x+2,y+height-tmp_height-1,width-4,tmp_height,
		                &clearlooks_style->button_g3[state_type],
			            &clearlooks_style->button_g4[state_type]);

		gdk_gc_set_clip_rectangle (style->bg_gc[state_type], NULL);
	}				
	
	cl_draw_shadow    (window, widget, style, x, y, width, height, &r);
	cl_rectangle_reset_clip_rectangle (&r);
}
Esempio n. 12
0
void
gtk_text_layout_draw (GtkTextLayout *layout,
                      GtkWidget *widget,
                      GdkDrawable *drawable,
		      GdkGC       *cursor_gc,
                      /* Location of the drawable
                         in layout coordinates */
                      gint x_offset,
                      gint y_offset,
                      /* Region of the layout to
                         render */
                      gint x,
                      gint y,
                      gint width,
                      gint height,
                      /* widgets to expose */
                      GList **widgets)
{
  GdkRectangle clip;
  gint current_y;
  GSList *cursor_list;
  GtkTextRenderState *render_state;
  GtkTextIter selection_start, selection_end;
  gboolean have_selection = FALSE;
  GSList *line_list;
  GSList *tmp_list;
  
  g_return_if_fail (GTK_IS_TEXT_LAYOUT (layout));
  g_return_if_fail (layout->default_style != NULL);
  g_return_if_fail (layout->buffer != NULL);
  g_return_if_fail (drawable != NULL);
  g_return_if_fail (width >= 0);
  g_return_if_fail (height >= 0);

  if (width == 0 || height == 0)
    return;

  line_list =  gtk_text_layout_get_lines (layout, y + y_offset, y + y_offset + height, &current_y);
  current_y -= y_offset;

  if (line_list == NULL)
    return; /* nothing on the screen */

  clip.x = x;
  clip.y = y;
  clip.width = width;
  clip.height = height;

  render_state = gtk_text_render_state_new (widget, drawable, &clip);

  gdk_gc_set_clip_rectangle (render_state->fg_gc, &clip);
  gdk_gc_set_clip_rectangle (render_state->bg_gc, &clip);

  gtk_text_layout_wrap_loop_start (layout);

  if (gtk_text_buffer_get_selection_bounds (layout->buffer,
                                            &selection_start,
                                            &selection_end))
    have_selection = TRUE;

  tmp_list = line_list;
  while (tmp_list != NULL)
    {
      GtkTextLineDisplay *line_display;
      gint selection_start_index = -1;
      gint selection_end_index = -1;
      gboolean have_strong;
      gboolean have_weak;

      GtkTextLine *line = tmp_list->data;

      line_display = gtk_text_layout_get_line_display (layout, line, FALSE);

      if (line_display->height > 0)
        {
          g_assert (line_display->layout != NULL);
          
          if (have_selection)
            {
              GtkTextIter line_start, line_end;
              gint byte_count;
              
              gtk_text_layout_get_iter_at_line (layout,
                                                &line_start,
                                                line, 0);
              line_end = line_start;
	      if (!gtk_text_iter_ends_line (&line_end))
		gtk_text_iter_forward_to_line_end (&line_end);
              byte_count = gtk_text_iter_get_line_index (&line_end);     

              if (gtk_text_iter_compare (&selection_start, &line_end) <= 0 &&
                  gtk_text_iter_compare (&selection_end, &line_start) >= 0)
                {
                  if (gtk_text_iter_compare (&selection_start, &line_start) >= 0)
                    selection_start_index = gtk_text_iter_get_line_index (&selection_start);
                  else
                    selection_start_index = -1;

                  if (gtk_text_iter_compare (&selection_end, &line_end) <= 0)
                    selection_end_index = gtk_text_iter_get_line_index (&selection_end);
                  else
                    selection_end_index = MAX(byte_count, 1);
                }
            }

          render_para (drawable, render_state, line_display,
                       - x_offset,
                       current_y,
                       selection_start_index, selection_end_index,
                       widgets);

          /* We paint the cursors last, because they overlap another chunk
         and need to appear on top. */

 	  have_strong = FALSE;
 	  have_weak = FALSE;
	  
	  cursor_list = line_display->cursors;
	  while (cursor_list)
	    {
	      GtkTextCursorDisplay *cursor = cursor_list->data;
 	      if (cursor->is_strong)
 		have_strong = TRUE;
 	      else
 		have_weak = TRUE;
	      
	      cursor_list = cursor_list->next;
 	    }
	  
          cursor_list = line_display->cursors;
          while (cursor_list)
            {
              GtkTextCursorDisplay *cursor = cursor_list->data;
	      GtkTextDirection dir;
 	      GdkRectangle cursor_location;
              GdkGC *gc;

              dir = line_display->direction;
 	      if (have_strong && have_weak)
 		{
 		  if (!cursor->is_strong)
 		    dir = (dir == GTK_TEXT_DIR_RTL) ? GTK_TEXT_DIR_LTR : GTK_TEXT_DIR_RTL;
 		}
 
 	      cursor_location.x = line_display->x_offset + cursor->x - x_offset;
 	      cursor_location.y = current_y + line_display->top_margin + cursor->y;
 	      cursor_location.width = 0;
 	      cursor_location.height = cursor->height;
 
	      gc = _gtk_get_insertion_cursor_gc (widget, cursor->is_strong);
	      gdk_gc_set_clip_rectangle(gc, &clip);
 	      _gtk_draw_insertion_cursor (widget, drawable, gc, &cursor_location,
                                          dir, have_strong && have_weak);
              gdk_gc_set_clip_rectangle (gc, NULL);

	      g_object_unref (gc);

              cursor_list = cursor_list->next;
            }
        } /* line_display->height > 0 */
          
      current_y += line_display->height;
      gtk_text_layout_free_line_display (layout, line_display);
      render_state->last_appearance = NULL;
      render_state->last_bg_appearance = NULL;
      
      tmp_list = g_slist_next (tmp_list);
    }

  gtk_text_layout_wrap_loop_end (layout);
  gtk_text_render_state_destroy (render_state);

  g_slist_free (line_list);
}
Esempio n. 13
0
//__________________________________________________________________
void        _HYButtonBar::_DisplayToolTip      (void)
{
    // TBI

    int h = _FindClickedButton (saveMousePosV,saveMousePosH);

    if ( h>=0 && h<toolTips.lLength) {
        _String* toolTip = (_String*)toolTips(h);
        if (toolTip->sLength) {
            GdkColor      toolTipColor = HYColorToGDKColor((_HYColor) {
                0xFF,0xCC,0x66
            });

            int        bL,
                       bT;

            GetButtonLoc (h,bL,bT,false);

            PangoLayout          * ttText = pango_layout_new (screenPContext);
            PangoFontDescription * ttFont = pango_font_description_new();
            HYFont2PangoFontDesc(_hyttDisplayFont,ttFont);

            pango_layout_set_font_description (ttText, ttFont);
            pango_layout_set_width(ttText, -1);
            pango_layout_set_text (ttText, toolTip->sData, toolTip->sLength);

            PangoRectangle extents;
            pango_layout_get_pixel_extents (ttText,&extents,nil);

            toolTipBounds.y      = bT - 16;
            toolTipBounds.height = 16;

            if (toolTipBounds.y<0) {
                toolTipBounds.y = bT+buttonDim+1;
            }

            h = extents.width + 4;

            toolTipBounds.x = bL+(buttonDim-h-1)/2;

            if (toolTipBounds.x<=0) {
                toolTipBounds.x = 1;
            }

            toolTipBounds.width = h+2;

            h = toolTipBounds.x+toolTipBounds.width-parentWindow->allocation.width;

            if (h>0) {
                if (h>=toolTipBounds.x) {
                    h = toolTipBounds.x-1;
                }
                toolTipBounds.x -= h;
            }

            toolTipBounds.x += parentWindow->allocation.x;
            toolTipBounds.y += parentWindow->allocation.y;

            gdk_gc_set_foreground(bbGC,&toolTipColor);
            gdk_draw_rectangle(parentWindow->window,bbGC,true,toolTipBounds.x, toolTipBounds.y, toolTipBounds.width, toolTipBounds.height);

            toolTipColor = HYColorToGDKColor((_HYColor) {
                0,0,0
            });
            gdk_gc_set_foreground(bbGC,&toolTipColor);
            gdk_draw_rectangle(parentWindow->window,bbGC,false,toolTipBounds.x, toolTipBounds.y, toolTipBounds.width, toolTipBounds.height);

            gdk_gc_set_clip_rectangle  (bbGC, &toolTipBounds);
            gdk_draw_layout (parentWindow->window, bbGC, toolTipBounds.x+3, toolTipBounds.y+3, ttText);
            gdk_gc_set_clip_rectangle  (bbGC, nil);

            pango_font_description_free (ttFont);
            g_object_unref (ttText);

        }
    }
}
Esempio n. 14
0
//__________________________________________________________________
void        _HYPlatformButtonBar::_Paint (Ptr p)
{
    _HYButtonBar * theParent = (_HYButtonBar*)this;

    if (theParent->parentWindow->window) {
        GdkRectangle    cRect    = HYRect2GDKRect(*(_HYRect*)p),
                        iRect;

        if (!bbGC) {
            bbGC                 = gdk_gc_new (theParent->parentWindow->window);
            gdk_gc_set_line_attributes (bbGC, 1, GDK_LINE_SOLID, GDK_CAP_NOT_LAST, GDK_JOIN_MITER);
        }

        cRect.x += theParent->parentWindow->allocation.x;
        cRect.y += theParent->parentWindow->allocation.y;

        if (!(theParent->settings.width&HY_COMPONENT_TRANSP_BG)) {
            gdk_gc_set_foreground(bbGC,&backFill);
            gdk_draw_rectangle(theParent->parentWindow->window,bbGC,true,cRect.x, cRect.y, cRect.width, cRect.height);
        }


        gdk_gc_set_clip_rectangle(bbGC,&cRect);

        cRect.x  = buttonRect.x;
        cRect.y  = buttonRect.y;

        int   step   = theParent->GetButtonDim()+2*HY_BUTTONBAR_BORDER;

        cRect.width  = cRect.height = step;

        gdk_gc_set_foreground(bbGC,&buttonBorder1);
        for (long i=0; i<theParent->ButtonCount(); i++) {
            if (i&& i%theParent->BarWidth()==0) {
                cRect.x  =  buttonRect.x;
                cRect.y  += step;
            }

            iRect    = cRect;
            iRect.x += theParent->parentWindow->allocation.x + HY_BUTTONBAR_BORDER;
            iRect.y += theParent->parentWindow->allocation.y + HY_BUTTONBAR_BORDER;

            iRect.width  -= 2*HY_BUTTONBAR_BORDER;
            iRect.height -= 2*HY_BUTTONBAR_BORDER;

            GdkPixbuf * buttonToPlot = nil;

            if (theParent->activationFlag) {
                if (i==pushed) {
                    buttonToPlot = gdk_pixbuf_composite_color_simple ((GdkPixbuf*)theParent->buttons.lData[i], iRect.width, iRect.height,GDK_INTERP_BILINEAR,128,1024,0x00000000,0x00000000);
                } else {
                    if (theParent->enabledButtons.Find(i)>=0) {
                        buttonToPlot = gdk_pixbuf_composite_color_simple ((GdkPixbuf*)theParent->buttons.lData[i], iRect.width, iRect.height,GDK_INTERP_BILINEAR,255,1024,0,0);
                    } else {
                        buttonToPlot = gdk_pixbuf_composite_color_simple ((GdkPixbuf*)theParent->buttons.lData[i], iRect.width, iRect.height,GDK_INTERP_BILINEAR,128,1,0x00ffffff,0x00888888);
                    }
                }
            } else {
                buttonToPlot = gdk_pixbuf_composite_color_simple ((GdkPixbuf*)theParent->buttons.lData[i], iRect.width, iRect.height,GDK_INTERP_BILINEAR,128,1,0x00ffffff,0x00888888);
            }
            gdk_draw_pixbuf (theParent->parentWindow->window,bbGC, buttonToPlot, 0,0, iRect.x, iRect.y, iRect.width, iRect.height, GDK_RGB_DITHER_NORMAL, 0, 0);
            g_object_unref (buttonToPlot);
            iRect.x --;
            iRect.y --;
            iRect.width += 2;
            iRect.height += 2;

            gdk_draw_rectangle(theParent->parentWindow->window,bbGC,false,iRect.x, iRect.y, iRect.width, iRect.height);
            cRect.x +=step;
        }
        gdk_gc_set_clip_rectangle(bbGC,nil);

    }

    (*theParent)._HYPlatformComponent::_Paint(p);
}
Esempio n. 15
0
void cl_draw_treeview_header (GtkStyle *style, GdkWindow *window,
                              GtkStateType state_type, GtkShadowType shadow_type,
                              GdkRectangle *area,
                              GtkWidget *widget, const gchar *detail,
                              gint x, gint y, gint width, gint height)
{
	ClearlooksStyle *clearlooks_style = CLEARLOOKS_STYLE (style);
	gint columns = 0, column_index = -1, fill_width = width;
	gboolean is_etree = strcmp("ETree", G_OBJECT_TYPE_NAME(widget->parent)) == 0;
	gboolean resizable = TRUE;
	
	GdkGC *bottom = clearlooks_style->shade_gc[5];
		
	if ( width < 2 || height < 2 )
		return;
	
	if (GTK_IS_TREE_VIEW (widget->parent))
	{
		gtk_treeview_get_header_index (GTK_TREE_VIEW(widget->parent),
	                                   widget, &column_index, &columns,
	                                   &resizable);
	}
	else if (GTK_IS_CLIST (widget->parent))
	{
		gtk_clist_get_header_index (GTK_CLIST(widget->parent),
		                            widget, &column_index, &columns);
	}
	
	if (area)
	{
		gdk_gc_set_clip_rectangle (clearlooks_style->shade_gc[0], area);
		gdk_gc_set_clip_rectangle (clearlooks_style->shade_gc[4], area);
		gdk_gc_set_clip_rectangle (style->bg_gc[state_type], area);			
		gdk_gc_set_clip_rectangle (clearlooks_style->shade_gc[5], area);
	}
	
	if (state_type != GTK_STATE_NORMAL)
		fill_width-=2;
	
	gdk_draw_rectangle (window, style->bg_gc[state_type], TRUE, x, y, fill_width, height-(height/3)+1);
	
	draw_hgradient (window, style->bg_gc[state_type], style,
	                x, 1+y+height-(height/3), fill_width, height/3,
	                &style->bg[state_type], &clearlooks_style->inset_dark[state_type]);

	if (resizable || (column_index != columns-1))
	{
		gdk_draw_line (window, clearlooks_style->shade_gc[4], x+width-2, y+4, x+width-2, y+height-5); 
		gdk_draw_line (window, clearlooks_style->shade_gc[0], x+width-1, y+4, x+width-1, y+height-5); 
	}
	
	/* left light line */
	if (column_index == 0)
		gdk_draw_line (window, clearlooks_style->shade_gc[0], x, y+1, x, y+height-2);
		
	/* top light line */
	gdk_draw_line (window, clearlooks_style->shade_gc[0], x, y, x+width-1, y);
	
	/* bottom dark line */
	if (state_type == GTK_STATE_INSENSITIVE)
		bottom = clearlooks_style->shade_gc[3];
	
	
	gdk_draw_line (window, bottom, x, y+height-1, x+width-1, y+height-1);
	
	if (area)
	{
		gdk_gc_set_clip_rectangle (clearlooks_style->shade_gc[0], NULL);
		gdk_gc_set_clip_rectangle (clearlooks_style->shade_gc[4], NULL);
		gdk_gc_set_clip_rectangle (style->bg_gc[state_type], NULL);
		gdk_gc_set_clip_rectangle (clearlooks_style->shade_gc[5], NULL);
	}		
}
Esempio n. 16
0
/* could be improved, I think. */
void cl_progressbar_fill (GdkDrawable *drawable, GtkWidget *widget,
                          GtkStyle *style, GdkGC *gc,
                          gint x, gint y,
                          gint width, gint height,
                          guint8 offset, GdkRectangle *area)
{
	GtkProgressBarOrientation orientation = gtk_progress_bar_get_orientation (GTK_PROGRESS_BAR (widget));
	gint size = (orientation == GTK_PROGRESS_LEFT_TO_RIGHT || orientation == GTK_PROGRESS_RIGHT_TO_LEFT) ? height : width;
	GdkPixmap *tile = cl_progressbar_tile_new (widget->window, widget, style, size, offset);

	gint nx = x,
	     ny = y,
	     nwidth = height,
	     nheight = width;
	
	gdk_gc_set_clip_rectangle (gc, area);
	
	switch (orientation)
	{
		case GTK_PROGRESS_LEFT_TO_RIGHT:
		{
			while (nx <= x + width )
			{
				if (nx + nwidth > x+width ) nwidth = (x+width) - nx;
				gdk_draw_drawable (drawable, gc, tile, 0, 0, nx, y, nwidth, height);
                                if (height <= 1)
                                    nx += 1;
                                else
				    nx += (height-1 + !(height % 2));
			}
			break;
		}
		case GTK_PROGRESS_RIGHT_TO_LEFT:
		{
			gint src_x = 0, dst_x;
			nx += width;
			while (nx >= x )
			{
				dst_x = nx - height;
				if (dst_x < x )
				{
					src_x = x - dst_x;
					dst_x = x;
				}
				gdk_draw_drawable (drawable, gc, tile, src_x, 0, dst_x, y, nwidth, height);
                                if (height <= 1)
                                    nx -= 1;
                                else
				    nx -= (height-1 + !(height % 2));
			}
			break;
		}
		case GTK_PROGRESS_TOP_TO_BOTTOM:
		{
			while (ny <= y + height )
			{
				if (ny + nheight > y+height ) nheight = (y+height) - ny;
				gdk_draw_drawable (drawable, gc, tile, 0, 0, x, ny, width, nheight);
                                if (width <= 1)
                                    ny += 1;
                                else
				    ny += (width-1 + !(width % 2));
			}
			break;
		}
		case GTK_PROGRESS_BOTTOM_TO_TOP:
		{
			gint src_y = 0, dst_y;
			ny += height;
			while (ny >= y )
			{
				dst_y = ny - width;
				if (dst_y < y )
				{
					src_y = y - dst_y;
					dst_y = y;
				}
				gdk_draw_drawable (drawable, gc, tile, 0, src_y, x, dst_y, width, width);
                                if (width <= 1)
                                    ny -= 1;
                                else
				    ny -= (width-1 + !(width % 2));
			}
			break;
		}
	}
	
	gdk_gc_set_clip_rectangle (gc, NULL);
	
	g_object_unref (tile);
}
Esempio n. 17
0
/* This function is a homegrown function based upon the draw_shadow 
 * & draw_shadow_gap routines of XFCE, lighthouseblue, EnGradient, 
 * & Xenophilia.
 */
void
do_draw_shadow_with_gap(GdkWindow * window,
	       GdkRectangle * area,
               GdkGC * tl_gc,
               GdkGC * br_gc,
	       gint x,
	       gint y,
	       gint width,
	       gint height,
	       GtkPositionType gap_side, 
	       gint gap_pos,
	       gint gap_size,
	       gboolean topleft_overlap)
{
  if (area)
    {
      gdk_gc_set_clip_rectangle(tl_gc, area);
      gdk_gc_set_clip_rectangle(br_gc, area);
    }

  switch (gap_side) {
    case GTK_POS_TOP:
      if (topleft_overlap) {
        gdk_draw_line(window, br_gc, x, y + height-1, x + width-1, y + height-1);
        gdk_draw_line(window, br_gc, x + width-1, y, x + width-1, y + height-1);
      } 

      gdk_draw_line(window, tl_gc, x, y, x, y + height-1);
    
      if (gap_size <= 0)
        gdk_draw_line(window, tl_gc, x, y, x + width-1, y);
      else {
        if (gap_pos > 0)
          gdk_draw_line(window, tl_gc, x, y, x + gap_pos, y);
        if ((width - (gap_pos + gap_size)) > 0)
	  gdk_draw_line (window, tl_gc,  x + gap_pos + gap_size - 1, y, x + width - 1, y);
      }

      if (!topleft_overlap) {
        gdk_draw_line(window, br_gc, x, y + height-1, x + width-1, y + height-1);
        gdk_draw_line(window, br_gc, x + width-1, y, x + width-1, y + height-1);
      } 
      break;
    case GTK_POS_BOTTOM:
      if (!topleft_overlap) {
        gdk_draw_line(window, tl_gc, x, y, x, y + height-1);
        gdk_draw_line(window, tl_gc, x, y, x + width-1, y);
      } 

      if (gap_size <= 0)
        gdk_draw_line(window, br_gc, x, y + height-1, x + width-1, y + height-1);
      else {
        if (gap_pos > 0)
          gdk_draw_line(window, br_gc, x, y + height-1, x + gap_pos, y + height-1);
        if ((width - (gap_pos + gap_size)) > 0)
          gdk_draw_line(window, br_gc, x + gap_pos + gap_size - 1, y + height-1, x + width - 1, y + height-1);
      }
      gdk_draw_line(window, br_gc, x + width-1, y, x + width-1, y + height-1);

      if (topleft_overlap) {
        gdk_draw_line(window, tl_gc, x, y, x, y + height-1);
        gdk_draw_line(window, tl_gc, x, y, x + width-1, y);
      } 
      break;
    case GTK_POS_LEFT:
      if (topleft_overlap) {
        gdk_draw_line(window, br_gc, x, y + height-1, x + width-1, y + height-1);
        gdk_draw_line(window, br_gc, x + width-1, y, x + width-1, y + height-1);
      } 

       gdk_draw_line(window, tl_gc, x, y, x + width -1, y);
    
      if (gap_size <= 0)
        gdk_draw_line(window, tl_gc, x, y, x, y + height-1);
      else {
        if (gap_pos > 0)
          gdk_draw_line(window, tl_gc, x, y, x, y + gap_pos);
          
        if ((height - (gap_pos + gap_size)) > 0)
	  gdk_draw_line (window, tl_gc,  x, y + gap_pos + gap_size - 1, x, y + height - 1);
      }

      if (!topleft_overlap) {
        gdk_draw_line(window, br_gc, x, y + height-1, x + width-1, y + height-1);
        gdk_draw_line(window, br_gc, x + width-1, y, x + width-1, y + height-1);
      } 
      break;
    case GTK_POS_RIGHT:
      if (!topleft_overlap) {
        gdk_draw_line(window, tl_gc, x, y, x, y + height-1);
        gdk_draw_line(window, tl_gc, x, y, x + width-1, y);
      } 

      gdk_draw_line(window, br_gc, x, y + height-1, x + width-1, y + height-1);
      if (gap_size <= 0)
        gdk_draw_line(window, br_gc, x + width-1, y, x + width-1, y + height-1);
      else {
        if (gap_pos > 0)
          gdk_draw_line(window, br_gc, x + width-1, y, x + width-1, y + gap_pos);
          
       if ((height - (gap_pos + gap_size)) > 0)
          gdk_draw_line(window, br_gc, x + width-1, y + gap_pos + gap_size -1, x + width-1, y + height-1);
      }

      if (topleft_overlap) {
        gdk_draw_line(window, tl_gc, x, y, x, y + height-1);
        gdk_draw_line(window, tl_gc, x, y, x + width-1, y);
      } 
      break;
    default :
      break;
  }
  if (area)
    {
      gdk_gc_set_clip_rectangle(tl_gc, NULL);
      gdk_gc_set_clip_rectangle(br_gc, NULL);
    }
}
Esempio n. 18
0
/* Draw spinbuttons. */
void cl_draw_spinbutton(GtkStyle *style, GdkWindow *window,
                        GtkStateType state_type, GtkShadowType shadow_type,
                        GdkRectangle *area,
                        GtkWidget *widget, const gchar *detail,
                        gint x, gint y, gint width, gint height)
{
	CLRectangle r;
	GdkRectangle new_area;

	int tl = CL_CORNER_NONE, tr = CL_CORNER_NONE,
	    bl = CL_CORNER_NONE, br = CL_CORNER_NONE;	
	
	if (area == NULL)
	{
		new_area.x = x;
		new_area.y = y;
		new_area.width = width;
		new_area.height = height;
		area = &new_area;		
	}

	if (!strcmp (detail, "spinbutton")) /* draws the 'back' of the spinbutton */
	{
		GdkGC *bg_gc = cl_get_window_bg_gc(widget);
		
		gdk_gc_set_clip_rectangle (bg_gc, area);
		gdk_draw_rectangle (window, bg_gc, FALSE, x, y, width-1, height-1);
		gdk_gc_set_clip_rectangle (bg_gc, NULL);

		if (style->xthickness > 2 && style->ythickness > 2)
			cl_draw_inset (style, window, widget, area, x, y, width, height,
			               CL_CORNER_NONE, CL_CORNER_ROUND,
			               CL_CORNER_NONE, CL_CORNER_ROUND);
		
		return;
	}

	if (!strcmp (detail, "spinbutton_up"))
	{
		tr = CL_CORNER_ROUND;
		
		(style->xthickness > 2 && style->ythickness > 2) ? y++ : height++;
	}
	
	if (!strcmp (detail, "spinbutton_down"))
	{
		br = CL_CORNER_ROUND;
		
		if (style->xthickness > 2 && style->ythickness > 2)
			height--;
	}
	
	cl_rectangle_set_button (&r, style, state_type,
	                         GTK_WIDGET_HAS_DEFAULT  (widget),
	                         GTK_WIDGET_HAS_FOCUS (widget),
	                         tl, tr,
	                         bl, br);
	width--;
	
	cl_rectangle_set_clip_rectangle (&r, area);
	cl_draw_rectangle (window, widget, style, x, y, width, height, &r);
	cl_draw_shadow    (window, widget, style, x, y, width, height, &r);
	cl_rectangle_reset_clip_rectangle (&r);
}
Esempio n. 19
0
/* Draw the exon view */
static void drawExonView(GtkWidget *exonView, GdkDrawable *drawable)
{
    GtkWidget *blxWindow = exonViewGetBlxWindow(exonView);
    BlxViewContext *bc = blxWindowGetContext(blxWindow);

    ExonViewProperties *properties = exonViewGetProperties(exonView);
    const IntRange* const displayRange = bigPictureGetDisplayRange(properties->bigPicture);

    /* First, highlight any assembly gaps */
    /* Get the display range in dna coords */
    IntRange bpRange;
    convertDisplayRangeToDnaRange(displayRange, bc->seqType, bc->numFrames, bc->displayRev, &bc->refSeqRange, &bpRange);

    GdkColor *gapColor = getGdkColor(BLXCOLOR_ASSEMBLY_GAP, bc->defaultColors, FALSE, bc->usePrintColors);
    drawAssemblyGaps(exonView, drawable, gapColor, bc->displayRev, &properties->exonViewRect, &bpRange, bc->featureLists[BLXMSP_GAP]);

    /* Set a clip rectangle for drawing the exons and introns (because they are drawn "over the
     * edges" to make sure intron lines have the correct slope etc.) */
    GdkGC *gc = gdk_gc_new(drawable);

    gdk_gc_set_clip_origin(gc, 0, 0);
    gdk_gc_set_clip_rectangle(gc, &properties->exonViewRect);

    /* Draw the exons and introns. Since we could have a lot of them in the loop, extract all the
     * info we need now and pass it around so we don't have to look for this stuff each time. */

    DrawData drawData = {
        drawable,
        gc,
        &properties->exonViewRect,
        blxWindow,
        bc,
        properties->currentStrand,
        displayRange,
        &bc->refSeqRange,
        bc->displayRev,
        bc->numFrames,
        bc->seqType,
        properties->expanded,
        FALSE,
        properties->yPad,
        properties->exonViewRect.y,
        properties->exonHeight
    };

    /* If the view is compressed (i.e. exons will overlap each other), then
     * only draw "normal" MSPs the first time round, and draw grouped/selected
     * MSPs afterwards, so that they appear on top. If the view is expanded,
     * we can draw them all in a single loop, because they will not overlap. */
    drawData.normalOnly = !properties->expanded;

    /* Loop through all sequences, drawing all msps that are exons/introns */
    GList *seqList = blxWindowGetAllMatchSeqs(blxWindow);
    g_list_foreach(seqList, drawExonIntronItem, &drawData);

    if (!properties->expanded)
    {
        drawData.normalOnly = FALSE;

        /* Draw all selected msps */
        g_list_foreach(bc->selectedSeqs, drawExonIntronItem, &drawData);

        /* Increment the y value when finished, because we calculate the view height based on this */
        drawData.y += drawData.height + drawData.yPad;
    }

    /* Set the height based on the height of the exons that were actually drawn */
    const int newHeight = drawData.y - properties->exonViewRect.y + drawData.yPad;
    gtk_layout_set_size(GTK_LAYOUT(exonView), exonView->allocation.width, newHeight);

    g_object_unref(gc);
}
Esempio n. 20
0
static void
gnc_header_draw (GnomeCanvasItem *item, GdkDrawable *drawable,
                 int x, int y, int width, int height)
{
    GncHeader *header = GNC_HEADER(item);
    SheetBlockStyle *style = header->style;
    Table *table = header->sheet->table;
    VirtualLocation virt_loc;
    VirtualCell *vcell;
    CellDimensions *cd;
    GdkColor *bg_color;
    int xpaint, ypaint;
    const char *text;
    CellBlock *cb;
    guint32 argb, color_type;
    int i, j;
    int w, h;
    PangoLayout *layout;

    virt_loc.vcell_loc.virt_row = 0;
    virt_loc.vcell_loc.virt_col = 0;
    virt_loc.phys_row_offset = 0;
    virt_loc.phys_col_offset = 0;

    if (header->sheet->use_theme_colors)
    {
        color_type = gnc_table_get_gtkrc_bg_color (table, virt_loc,
                     NULL);
        bg_color = get_gtkrc_color(header->sheet, color_type);
    }
    else
    {
        argb = gnc_table_get_bg_color (table, virt_loc, NULL);
        bg_color = gnucash_color_argb_to_gdk (argb);
    }

    h = style->dimensions->height;
    h *= header->num_phys_rows;
    h /= header->style->nrows;

    gdk_gc_set_foreground (header->gc, bg_color);

    gdk_draw_rectangle (drawable, header->gc, TRUE, 0, 0,
                        style->dimensions->width, h);

    gdk_gc_set_line_attributes (header->gc, 1, GDK_LINE_SOLID, GDK_CAP_NOT_LAST, GDK_JOIN_MITER);
    gdk_gc_set_foreground (header->gc, &gn_black);

    gdk_draw_rectangle (drawable, header->gc, FALSE, -x, -y,
                        style->dimensions->width, h);

    gdk_draw_line (drawable, header->gc, 0, h + 1,
                   style->dimensions->width, h + 1);

    gdk_gc_set_line_attributes (header->gc, 1, GDK_LINE_SOLID, GDK_CAP_NOT_LAST, GDK_JOIN_MITER);
    gdk_gc_set_background (header->gc, &gn_white);
    gdk_gc_set_foreground (header->gc, &gn_black);
    /*font = gnucash_register_font;*/

    vcell = gnc_table_get_virtual_cell
            (table, table->current_cursor_loc.vcell_loc);
    cb = vcell ? vcell->cellblock : NULL;

    ypaint = -y;
    h = 0;

    for (i = 0; i < style->nrows; i++)
    {
        xpaint = -x;
        virt_loc.phys_row_offset = i;

        /* TODO: This routine is duplicated in several places.
           Can we abstract at least the cell drawing routine?
           That way we'll be sure everything is drawn
           consistently, and cut down on maintenance issues. */

        for (j = 0; j < style->ncols; j++)
        {
            /*                        gint x_offset, y_offset;*/
            GdkRectangle rect;
            BasicCell *cell;

            virt_loc.phys_col_offset = j;

            cd = gnucash_style_get_cell_dimensions (style, i, j);

            if (header->in_resize && (j == header->resize_col))
                w = header->resize_col_width;
            else
                w = cd->pixel_width;

            cell = gnc_cellblock_get_cell (cb, i, j);
            if (!cell || !cell->cell_name)
            {
                xpaint += w;
                continue;
            }

            h = cd->pixel_height;

            gdk_draw_rectangle (drawable, header->gc, FALSE,
                                xpaint, ypaint, w, h);

            virt_loc.vcell_loc =
                table->current_cursor_loc.vcell_loc;
            text = gnc_table_get_label (table, virt_loc);
            if (!text)
                text = "";

            layout = gtk_widget_create_pango_layout (GTK_WIDGET (header->sheet), text);

            /*y_offset = ((h / 2) +
                                    (((font->ascent + font->descent) / 2) -
                                     font->descent));
                        y_offset++;*/

            switch (gnc_table_get_align (table, virt_loc))
            {
            default:
            case CELL_ALIGN_LEFT:
                pango_layout_set_alignment (layout, PANGO_ALIGN_LEFT);
                break;

            case CELL_ALIGN_RIGHT:
                pango_layout_set_alignment (layout, PANGO_ALIGN_RIGHT);
                break;

            case CELL_ALIGN_CENTER:
                pango_layout_set_alignment (layout, PANGO_ALIGN_CENTER);
                break;
            }

            rect.x = xpaint + CELL_HPADDING;
            rect.y = ypaint + 1;
            rect.width = MAX (0, w - (2 * CELL_HPADDING));
            rect.height = h - 2;

            gdk_gc_set_clip_rectangle (header->gc, &rect);

            gdk_draw_layout (drawable,
                             header->gc,
                             xpaint + CELL_HPADDING,
                             ypaint + 1,
                             layout);

            g_object_unref (layout);

            gdk_gc_set_clip_rectangle (header->gc, NULL);

            xpaint += w;
        }

        ypaint += h;
    }
}
Esempio n. 21
0
static gboolean ddb_equalizer_real_expose_event (GtkWidget* base, GdkEventExpose* event) {
	DdbEqualizer * self;
	gboolean result = FALSE;
	GdkColor _tmp0_ = {0};
	GdkColor fore_bright_color;
	GdkColor c1;
	GdkColor _tmp1_ = {0};
	GdkColor c2;
	GdkColor fore_dark_color;
	gint width;
	gint height;
	GdkDrawable* d;
	GdkGCValues _tmp2_ = {0};
	GdkGCValues _tmp3_;
	GdkGC* gc;
	double step;
	gint i = 0;
	double vstep;
	PangoLayout* l;
	PangoContext* ctx;
	PangoFontDescription* fd;
	gint fontsize;
	gboolean _tmp7_ = FALSE;
	char* tmp;
	double val;
	const char* _tmp9_;
	char* _tmp10_;
	const char* _tmp11_;
	char* _tmp12_;
	GdkRectangle _tmp13_ = {0};
	GdkRectangle _tmp14_;
	gint count;
	GdkRectangle _tmp16_ = {0};
	GdkRectangle _tmp17_;
	gint bar_w;
	GdkRectangle _tmp22_ = {0};
	GdkRectangle _tmp23_;
	self = (DdbEqualizer*) base;
	fore_bright_color = (gtkui_get_bar_foreground_color (&_tmp0_), _tmp0_);
	c1 = fore_bright_color;
	c2 = (gtkui_get_bar_background_color (&_tmp1_), _tmp1_);
	fore_dark_color = c2;
	fore_dark_color.red = fore_dark_color.red + ((guint16) ((gint16) ((c1.red - c2.red) * 0.5)));
	fore_dark_color.green = fore_dark_color.green + ((guint16) ((gint16) ((c1.green - c2.green) * 0.5)));
	fore_dark_color.blue = fore_dark_color.blue + ((guint16) ((gint16) ((c1.blue - c2.blue) * 0.5)));
	width = ((GtkWidget*) self)->allocation.width;
	height = ((GtkWidget*) self)->allocation.height;
	d = _g_object_ref0 ((GdkDrawable*) gtk_widget_get_window ((GtkWidget*) self));
	gc = _g_object_ref0 (GDK_DRAWABLE_GET_CLASS (d)->create_gc (d, (_tmp3_ = (memset (&_tmp2_, 0, sizeof (GdkGCValues)), _tmp2_), &_tmp3_), 0));
	gdk_gc_set_rgb_fg_color (gc, &c2);
	gdk_draw_rectangle (d, gc, TRUE, 0, 0, width, height);
	gdk_gc_set_rgb_fg_color (gc, &fore_dark_color);
	step = ((double) (width - self->priv->margin_left)) / ((double) (DDB_EQUALIZER_bands + 1));
	{
		gboolean _tmp4_;
		i = 0;
		_tmp4_ = TRUE;
		while (TRUE) {
			if (!_tmp4_) {
				i++;
			}
			_tmp4_ = FALSE;
			if (!(i < DDB_EQUALIZER_bands)) {
				break;
			}
			gdk_draw_line (d, gc, ((gint) ((i + 1) * step)) + self->priv->margin_left, 0, ((gint) ((i + 1) * step)) + self->priv->margin_left, height - self->priv->margin_bottom);
		}
	}
	vstep = (double) (height - self->priv->margin_bottom);
	{
		double di;
		di = (double) 0;
		{
			gboolean _tmp5_;
			_tmp5_ = TRUE;
			while (TRUE) {
				if (!_tmp5_) {
					di = di + 0.25;
				}
				_tmp5_ = FALSE;
				if (!(di < 2)) {
					break;
				}
				gdk_draw_line (d, gc, self->priv->margin_left, (gint) ((di - self->priv->preamp) * vstep), width, (gint) ((di - self->priv->preamp) * vstep));
			}
		}
	}
	gdk_gc_set_rgb_fg_color (gc, &fore_bright_color);
	l = gtk_widget_create_pango_layout ((GtkWidget*) self, NULL);
	ctx = _g_object_ref0 (pango_layout_get_context (l));
	fd = pango_font_description_copy (gtk_widget_get_style ((GtkWidget*) self)->font_desc);
	pango_font_description_set_size (fd, (gint) (pango_font_description_get_size (gtk_widget_get_style ((GtkWidget*) self)->font_desc) * 0.7));
	pango_context_set_font_description (ctx, fd);
	{
		gboolean _tmp6_;
		i = 0;
		_tmp6_ = TRUE;
		while (TRUE) {
			PangoRectangle ink = {0};
			PangoRectangle log = {0};
			gint offs;
			if (!_tmp6_) {
				i++;
			}
			_tmp6_ = FALSE;
			if (!(i < DDB_EQUALIZER_bands)) {
				break;
			}
			pango_layout_set_text (l, freqs[i], (gint) g_utf8_strlen (freqs[i], -1));
			pango_layout_get_pixel_extents (l, &ink, &log);
			offs = 2;
			if ((i % 2) != 0) {
				offs = offs + 2;
			}
			gdk_draw_layout (d, gc, (((gint) ((i + 1) * step)) + self->priv->margin_left) - (ink.width / 2), (height - self->priv->margin_bottom) + offs, l);
		}
	}
	pango_font_description_set_size (fd, (gint) pango_font_description_get_size (gtk_widget_get_style ((GtkWidget*) self)->font_desc));
	pango_context_set_font_description (ctx, fd);
	pango_layout_set_width (l, self->priv->margin_left - 1);
	pango_layout_set_alignment (l, PANGO_ALIGN_RIGHT);
	fontsize = (gint) ((pango_units_to_double (pango_font_description_get_size (fd)) * gdk_screen_get_resolution (gdk_screen_get_default ())) / 72);
	if (self->priv->mouse_y >= 0) {
		_tmp7_ = self->priv->mouse_y < (height - self->priv->margin_bottom);
	} else {
		_tmp7_ = FALSE;
	}
	if (_tmp7_) {
		double db;
		const char* _tmp8_;
		char* tmp;
		db = ddb_equalizer_scale (self, ((double) (self->priv->mouse_y - 1)) / ((double) ((height - self->priv->margin_bottom) - 2)));
		_tmp8_ = NULL;
		if (db > 0) {
			_tmp8_ = "+";
		} else {
			_tmp8_ = "";
		}
		tmp = g_strdup_printf ("%s%.1fdB", _tmp8_, db);
		pango_layout_set_text (l, tmp, (gint) g_utf8_strlen (tmp, -1));
		gdk_draw_layout (d, gc, self->priv->margin_left - 1, self->priv->mouse_y - 3, l);
		_g_free0 (tmp);
	}
	tmp = NULL;
	val = ddb_equalizer_scale (self, (double) 1);
	_tmp9_ = NULL;
	if (val > 0) {
		_tmp9_ = "+";
	} else {
		_tmp9_ = "";
	}
	tmp = (_tmp10_ = g_strdup_printf ("%s%.1fdB", _tmp9_, val), _g_free0 (tmp), _tmp10_);
	pango_layout_set_text (l, tmp, (gint) g_utf8_strlen (tmp, -1));
	gdk_draw_layout (d, gc, self->priv->margin_left - 1, (height - self->priv->margin_bottom) - fontsize, l);
	val = ddb_equalizer_scale (self, (double) 0);
	_tmp11_ = NULL;
	if (val > 0) {
		_tmp11_ = "+";
	} else {
		_tmp11_ = "";
	}
	tmp = (_tmp12_ = g_strdup_printf ("%s%.1fdB", _tmp11_, val), _g_free0 (tmp), _tmp12_);
	pango_layout_set_text (l, tmp, (gint) g_utf8_strlen (tmp, -1));
	gdk_draw_layout (d, gc, self->priv->margin_left - 1, 1, l);
	pango_layout_set_text (l, "+0dB", 4);
	gdk_draw_layout (d, gc, self->priv->margin_left - 1, ((gint) ((1 - self->priv->preamp) * (height - self->priv->margin_bottom))) - (fontsize / 2), l);
	pango_layout_set_text (l, "preamp", 6);
	pango_layout_set_alignment (l, PANGO_ALIGN_LEFT);
	gdk_draw_layout (d, gc, 1, (height - self->priv->margin_bottom) + 2, l);
	gdk_draw_rectangle (d, gc, FALSE, self->priv->margin_left, 0, (width - self->priv->margin_left) - 1, (height - self->priv->margin_bottom) - 1);
	gdk_gc_set_line_attributes (gc, 2, GDK_LINE_SOLID, GDK_CAP_NOT_LAST, GDK_JOIN_MITER);
	gdk_gc_set_clip_rectangle (gc, (_tmp14_ = (_tmp13_.x = 0, _tmp13_.y = (gint) (self->priv->preamp * (height - self->priv->margin_bottom)), _tmp13_.width = 11, _tmp13_.height = height, _tmp13_), &_tmp14_));
	gdk_gc_set_rgb_fg_color (gc, &fore_bright_color);
	count = ((gint) ((height - self->priv->margin_bottom) / 6)) + 1;
	{
		gint j;
		j = 0;
		{
			gboolean _tmp15_;
			_tmp15_ = TRUE;
			while (TRUE) {
				if (!_tmp15_) {
					j++;
				}
				_tmp15_ = FALSE;
				if (!(j < count)) {
					break;
				}
				gdk_draw_rectangle (d, gc, TRUE, 1, ((height - self->priv->margin_bottom) - (j * 6)) - 6, 11, 4);
			}
		}
	}
	gdk_gc_set_clip_rectangle (gc, (_tmp17_ = (_tmp16_.x = self->priv->margin_left + 1, _tmp16_.y = 1, _tmp16_.width = (width - self->priv->margin_left) - 2, _tmp16_.height = (height - self->priv->margin_bottom) - 2, _tmp16_), &_tmp17_));
	gdk_gc_set_rgb_fg_color (gc, &fore_bright_color);
	bar_w = 11;
	if (step < bar_w) {
		bar_w = ((gint) step) - 1;
	}
	{
		gboolean _tmp18_;
		i = 0;
		_tmp18_ = TRUE;
		while (TRUE) {
			GdkRectangle _tmp19_ = {0};
			GdkRectangle _tmp20_;
			if (!_tmp18_) {
				i++;
			}
			_tmp18_ = FALSE;
			if (!(i < DDB_EQUALIZER_bands)) {
				break;
			}
			gdk_gc_set_clip_rectangle (gc, (_tmp20_ = (_tmp19_.x = (((gint) ((i + 1) * step)) + self->priv->margin_left) - (bar_w / 2), _tmp19_.y = (gint) (self->priv->values[i] * (height - self->priv->margin_bottom)), _tmp19_.width = 11, _tmp19_.height = height, _tmp19_), &_tmp20_));
			count = ((gint) (((height - self->priv->margin_bottom) * (1 - self->priv->values[i])) / 6)) + 1;
			{
				gint j;
				j = 0;
				{
					gboolean _tmp21_;
					_tmp21_ = TRUE;
					while (TRUE) {
						if (!_tmp21_) {
							j++;
						}
						_tmp21_ = FALSE;
						if (!(j < count)) {
							break;
						}
						gdk_draw_rectangle (d, gc, TRUE, (((gint) ((i + 1) * step)) + self->priv->margin_left) - (bar_w / 2), ((height - self->priv->margin_bottom) - (j * 6)) - 6, bar_w, 4);
					}
				}
			}
		}
	}
	gdk_gc_set_clip_rectangle (gc, (_tmp23_ = (_tmp22_.x = 0, _tmp22_.y = 0, _tmp22_.width = width, _tmp22_.height = height, _tmp22_), &_tmp23_));
	gdk_gc_set_line_attributes (gc, 1, GDK_LINE_ON_OFF_DASH, GDK_CAP_NOT_LAST, GDK_JOIN_MITER);
	gdk_draw_line (d, gc, self->priv->margin_left + 1, self->priv->mouse_y, width, self->priv->mouse_y);
	result = FALSE;
	_g_free0 (tmp);
	_pango_font_description_free0 (fd);
	_g_object_unref0 (ctx);
	_g_object_unref0 (l);
	_g_object_unref0 (gc);
	_g_object_unref0 (d);
	return result;
}