示例#1
0
GtkPlotCanvasChild*
gtk_plot_canvas_ellipse_new (GtkPlotLineStyle style,
                          gfloat width,
                          const GdkColor *fg,
                          const GdkColor *bg,
                          gboolean fill)
{
  GtkPlotCanvasEllipse *ellipse;
                                                                                
  ellipse = gtk_type_new (gtk_plot_canvas_ellipse_get_type ());
                                   
  ellipse->line.line_width = width;                                             
  if(fg) ellipse->line.color = *fg;
  if(bg) ellipse->bg = *bg;
  ellipse->filled = fill;
                                                                                
  return GTK_PLOT_CANVAS_CHILD (ellipse);
}
GtkPlotCanvasChild*
gtk_plot_canvas_rectangle_new (GtkPlotLineStyle style,
                          gfloat width,
                          const GdkColor *fg,
                          const GdkColor *bg,
			  GtkPlotBorderStyle border,
                          gboolean fill)
{
  GtkPlotCanvasRectangle *rectangle;
                                                                                
  rectangle = gtk_type_new (gtk_plot_canvas_rectangle_get_type ());
                                   
  rectangle->line.line_width = width;                                             
  if(fg) rectangle->line.color = *fg;
  if(bg) rectangle->bg = *bg;
  rectangle->border = border;
  rectangle->filled = fill;
                                                                                
  return GTK_PLOT_CANVAS_CHILD (rectangle);
}
static void
gtk_plot_canvas_text_init (GtkPlotCanvasText *text)
{
  GtkPlotText *text_attr;

  text_attr = &text->text;

  text_attr->angle = 0;
  gdk_color_black(gdk_colormap_get_system(), &text_attr->fg);
  gdk_color_white(gdk_colormap_get_system(), &text_attr->bg);
  text_attr->justification = GTK_JUSTIFY_LEFT;
  text_attr->transparent = TRUE;
  text_attr->border = 0;
  text_attr->border_width = 0;
  text_attr->shadow_width = 0;
                                                                                
  text_attr->text = NULL;

  GTK_PLOT_CANVAS_CHILD(text)->flags = GTK_PLOT_CANVAS_CAN_MOVE;
}
GtkPlotCanvasChild*
gtk_plot_canvas_text_new (const gchar *font, gint height, gint angle,
                          const GdkColor *fg, const GdkColor *bg,
                          gboolean transparent,
                          GtkJustification justification,
                          const gchar *real_text)
{
  GtkPlotCanvasText *text;
  GtkPlotText *text_attr;
                                                                                
  text = gtk_type_new (gtk_plot_canvas_text_get_type ());

  text_attr = &text->text;

  text_attr->angle = angle;
  text_attr->justification = justification;
  text_attr->transparent = transparent;
  text_attr->border = 0;
  text_attr->border_width = 0;
  text_attr->shadow_width = 0;
                                                                                
  if(!font) {
    text_attr->font = g_strdup(DEFAULT_FONT);
    text_attr->height = DEFAULT_FONT_HEIGHT;
  } else {
    text_attr->font = g_strdup(font);
    text_attr->height = height;
  }
                                                                                
  text_attr->text = NULL;
  if(text) text_attr->text = g_strdup(real_text);
                                                                                
  if(fg != NULL)
    text_attr->fg = *fg;
                                                                                
  if(bg != NULL)
    text_attr->bg = *bg;

  return GTK_PLOT_CANVAS_CHILD (text);
}