Пример #1
0
/* Kreslicí funkce spoleèná pro gtk_ev_draw() a gtk_ev_expose(), která kreslí
 * vnitøní okno widgetu */
static void gtk_ev_paint_ev_win(GtkEv *ev, GdkRectangle *area)
{
    GtkWidget *widget;
    gint width, x, y;
    const char *title = "Event Window";
    GdkFont *font;

    g_return_if_fail(ev);
    g_return_if_fail(area);

    widget = GTK_WIDGET(ev);
    font = gtk_style_get_font(widget->style);
    if(!GTK_WIDGET_DRAWABLE(ev))
        return;

    gdk_window_clear_area(ev->ev_win, area->x, area->y,
                          area->width, area->height);

    gdk_gc_set_clip_rectangle(widget->style->black_gc, area);

    width = gdk_string_width(font, title);

    x = (ev->ev_win_rect.width - width)/2;
    y = font->ascent + 2;

    gdk_draw_string(ev->ev_win, font, widget->style->black_gc, x, y, title);

    gdk_gc_set_clip_rectangle(widget->style->black_gc, NULL);
}
Пример #2
0
static void
gimv_zalbum_cell_size_request (GimvZList *list, gpointer cell, GtkRequisition *requisition)
{
   GimvZAlbum *album;
   gint text_height = 0;

   g_return_if_fail (list && requisition);

   album = GIMV_ZALBUM (list);

   switch (album->label_pos) {
   case GIMV_ZALBUM_CELL_LABEL_LEFT:
   case GIMV_ZALBUM_CELL_LABEL_RIGHT:
      text_height = 0;
      break;
   case GIMV_ZALBUM_CELL_LABEL_BOTTOM:
   case GIMV_ZALBUM_CELL_LABEL_TOP:
   default:
      text_height = LINE_HEIGHT (gtk_style_get_font (GTK_WIDGET (list)->style));
      break;
   }

   requisition->width
      = MAX (album->max_cell_width, album->max_pix_width)
      + 2 * CELL_PADDING;
   requisition->height
      = MAX (album->max_cell_height, album->max_pix_height)
      + 2 * CELL_PADDING + text_height;
}
Пример #3
0
/* Kreslicí funkce spoleèná pro gtk_ev_draw() a gtk_ev_expose(), která kreslí
 * hlavní okno widgetu */
static void gtk_ev_paint(GtkEv *ev, GdkRectangle *area)
{
    GtkWidget *widget;
    
    g_return_if_fail(ev);
    g_return_if_fail(area);

    widget = GTK_WIDGET(ev);

    if(!GTK_WIDGET_DRAWABLE(widget))
        return; /* Not visible and mapped */

    gdk_window_clear_area(widget->window, area->x, area->y, area->width,
                          area->height);
    gdk_gc_set_clip_rectangle(widget->style->black_gc, area);

    /* Èerný rámeèek kolem vnitøního okna */
    gdk_draw_rectangle(widget->window, widget->style->black_gc, FALSE,
                       ev->ev_win_rect.x-1, ev->ev_win_rect.y-1,
                       ev->ev_win_rect.width+2, ev->ev_win_rect.height+2);

    gdk_gc_set_clip_rectangle(widget->style->black_gc, NULL);

    /* Text (seznam zachycených událostí) */
    if(ev->list) {
        GdkRectangle intersect;

        if(gdk_rectangle_intersect(&ev->list_rect, area, &intersect)) {
            static const gint space = 2;
            gint line, step, first_baseline;
            GList *p;
	    GdkFont *font = gtk_style_get_font(widget->style);

            step = font->ascent + font->descent + space;
            first_baseline = ev->list_rect.y + font->ascent + space;
            line = 0;
            for(p = ev->list; p; p = g_list_next(p)) {
                gchar **pev = p->data;
                gint i;
                
                for(i = 0; pev[i]; i++) {
                    gtk_paint_string(widget->style, widget->window,
                                     widget->state, &intersect, widget,
                                     (char *) "ev", ev->list_rect.x,
                                     first_baseline + line*step, pev[i]);
                    line++;
                }
                
                if(first_baseline + line*step - 2*step >
                   intersect.y + intersect.height)
                    break;
            }
        }
    }

    /* Grafické zvýraznìní, kdy¾ má okno focus */
    if(GTK_WIDGET_HAS_FOCUS(widget))
        gtk_paint_focus(widget->style, widget->window, GTK_WIDGET_STATE(widget),
			area, widget, (char *) "ev", 0, 0, -1, -1);
}
Пример #4
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);
    }
}
Пример #5
0
/*
 *	Get log font
 */
GdkFont *
GTK_get_log_font(void)
{
	GtkStyle *style;
//	if (GTK_OBJECT(v9t9_command_log)->flags & GTK_DESTROYED)
//		return 0L;//2.0
	if (!v9t9_command_log) return 0L;
	style = gtk_widget_get_style(v9t9_command_log);
	return gtk_style_get_font(style);
}
Пример #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);
    }
}
Пример #7
0
static void
gimv_zalbum_draw (GimvZAlbum *album, GimvZAlbumCell *cell,
                  GdkRectangle *cell_area,
                  GdkRectangle *area)
{
   GtkWidget *widget;
   gint text_area_height, v_text_area_height, xdest, ydest;
   gint xpad, ypad;
   gboolean center = TRUE;
   GdkRectangle widget_area, draw_area;

   g_return_if_fail (album && cell && cell_area);

   widget = GTK_WIDGET (album);

   if (!GTK_WIDGET_DRAWABLE (widget))
      return;

   widget_area.x = widget_area.y = 0;
   widget_area.width  = widget->allocation.width;
   widget_area.height = widget->allocation.height;
   if (!area) {
      draw_area = widget_area;
   } else {
      if (!gdk_rectangle_intersect (area, &widget_area, &draw_area))
         return;
   }

   gimv_zalbum_prepare_cell (album, cell, cell_area, &draw_area);

   switch (album->label_pos) {
   case GIMV_ZALBUM_CELL_LABEL_RIGHT:
   case GIMV_ZALBUM_CELL_LABEL_LEFT:
      text_area_height = cell_area->height;
      v_text_area_height = 0;
      break;
   case GIMV_ZALBUM_CELL_LABEL_BOTTOM:
   case GIMV_ZALBUM_CELL_LABEL_TOP:
   default:
      text_area_height = LINE_HEIGHT (gtk_style_get_font (GTK_WIDGET (album)->style));
      v_text_area_height = text_area_height;
      break;
   }

   if (cell->ipix) {
      GdkRectangle pixmap_area, intersect_area;
      gboolean need_draw;
      gint w, h;
      gint iwidth = 0, iheight = 0;

      gdk_window_get_size (cell->ipix, &iwidth, &iheight);

      w    = iwidth;
      h    = iheight;

      switch (album->label_pos) {
      case GIMV_ZALBUM_CELL_LABEL_RIGHT:
         xpad = 0;
         break;
      case GIMV_ZALBUM_CELL_LABEL_LEFT:
         /* not implemented yet */
         /* break; */
      case GIMV_ZALBUM_CELL_LABEL_BOTTOM:
      case GIMV_ZALBUM_CELL_LABEL_TOP:
      default:
         xpad = (cell_area->width  - w)  / 2;
         break;
      }
      ypad = (cell_area->height - v_text_area_height - h) / 2;

      if (xpad < 0) {
         w += xpad;
         xpad = 0;
      }

      if (ypad < 0) {
         h += ypad;
         ypad = 0;
      }

      pixmap_area.x = cell_area->x + xpad;
      pixmap_area.y = cell_area->y + ypad;
      pixmap_area.width  = iwidth;
      pixmap_area.height = iheight;

      need_draw = gdk_rectangle_intersect (&draw_area, &pixmap_area, &intersect_area);

      if (cell->ipix && need_draw) {
         draw_cell_pixmap (widget->window,
                           &intersect_area,
                           widget->style->fg_gc[GTK_STATE_NORMAL],
                           cell->ipix, cell->imask,
                           pixmap_area.x, pixmap_area.y,
                           iwidth, iheight);
      }
   }

   switch (album->label_pos) {
   case GIMV_ZALBUM_CELL_LABEL_RIGHT:
      xdest = cell_area->x + album->max_pix_width + LABEL_HPADDING;
      ydest = cell_area->y
         + gtk_style_get_font (GTK_WIDGET (album)->style)->ascent;
      center = FALSE;
      break;

   case GIMV_ZALBUM_CELL_LABEL_LEFT:
      /* not implemented yet */
      /* break; */

   case GIMV_ZALBUM_CELL_LABEL_TOP:
      /* not implemented yet */
      /* break; */

   case GIMV_ZALBUM_CELL_LABEL_BOTTOM:
   default:
      xdest = cell_area->x;
      ydest = (cell_area->y + cell_area->height - v_text_area_height)
         + gtk_style_get_font (GTK_WIDGET (album)->style)->ascent
         + LABEL_VPADDING;
      center = TRUE;
      break;
   }

   gimv_zalbum_draw_string (widget, cell, cell->name,
                            xdest, ydest,
                            cell_area->width, text_area_height,
                            center);

}
Пример #8
0
/**
 * TBD
 */
void create_hist_list( void ) {
    static char *title[1] = { "History" };
    GtkStyle *style, *new_style;
    gint sz, max_sz;
    int n;
    char tmp[80];
    GtkWidget *scrolled_win;
    GdkFont *private_font;

    hist_list = gtk_clist_new_with_titles( 1, title );

    /*
     * When a selection is made, we want to know about it. The callback *
     * used is selection_made, and its code can be found further down 
     */
    select_hist_handler_id =
       gtk_signal_connect( GTK_OBJECT( hist_list ), "select_row", GTK_SIGNAL_FUNC( hist_list_selected ), NULL );

    /*
     * It isn't necessary to shadow the border, but it looks nice :) 
     */
    gtk_clist_set_shadow_type( GTK_CLIST( hist_list ), GTK_SHADOW_OUT );

    /*
     * Make sure titles are being shown
     */
    gtk_clist_column_titles_show( GTK_CLIST( hist_list ) );

    /*
     * What however is important, is that we set the column widths as * they
     * will never be right otherwise. Note that the columns are * numbered
     * from 0 and up. 
     */
    style = gtk_widget_get_style( hist_list );
    new_style = gtk_style_copy( style );
    if ( ( private_font = gdk_font_load( "*courier-*-r*140*" ) ) == NULL )
        if ( ( private_font = gdk_font_load( "*courier-*-r*120*" ) ) == NULL )
            private_font = gtk_style_get_font( style );
    gtk_style_set_font( style, private_font );
    gtk_widget_set_style( hist_list, new_style );
    for ( max_sz = 0, n = 0; n < 10; n++ ) {
        sprintf( tmp, "%d: %s: %c%d",
           RANDOM( 1, 60 ), ( rand(  ) % 2 ) ? "Black" : "White", RANDOM( 0, 7 ) + 'A', RANDOM( 1, 8 ) );
        sz = gdk_string_width( private_font, tmp );
        if ( sz > max_sz )
            max_sz = sz;
    }
    gtk_clist_set_column_width( GTK_CLIST( hist_list ), 0, max_sz );

    /*
     * --- Set the column justifications --- 
     */
    gtk_clist_set_column_justification( GTK_CLIST( hist_list ), 0, GTK_JUSTIFY_LEFT );
    gtk_clist_column_titles_passive( GTK_CLIST( hist_list ) );

    /*
     * --- Selection mode --- 
     */
    gtk_clist_set_selection_mode( GTK_CLIST( hist_list ), GTK_SELECTION_BROWSE );

    /*
     * Add the GtkCList widget to the vertical box and show it. 
     */
    gtk_widget_show( hist_list );
    scrolled_win = gtk_scrolled_window_new( NULL, NULL );
    gtk_container_add( GTK_CONTAINER( scrolled_win ), hist_list );
    gtk_scrolled_window_set_policy( GTK_SCROLLED_WINDOW( scrolled_win ), GTK_POLICY_NEVER, GTK_POLICY_ALWAYS );
    gtk_box_pack_start( GTK_BOX( main_hbox ), scrolled_win, FALSE, FALSE, 0 );
    gtk_widget_show( scrolled_win );

}                               // create_hist_list