PCB-FPW developer documentation based on version: 0.0.11

Functions

preview.c File Reference

A footprint preview widget. More...

Go to the source code of this file.

Functions

static void preview_close_cb (GtkWidget *widget, GtkWidget *preview_window)
 Close the preview window (destroy the preview widget).
static gboolean preview_configure_event (GtkWidget *widget, GdkEventConfigure *event)
 Create a new backing pixmap of the appropriate size.
void preview_delete_event (GtkWidget *widget, GdkEvent *event)
 Delete the window.
int preview_set_fg_color (GdkGC *gc, const char *color_name)
 Set the foreground color of the Graphics Context.
int preview_set_fill_mode (GdkGC *gc, GdkFill fill_mode)
 Set the fill mode of the Graphics Context.
int preview_set_line_cap (GdkGC *gc, GdkCapStyle line_cap)
 Set the line capsulation of the Graphics Context.
int preview_set_line_style (GdkGC *gc, GdkLineStyle line_style)
 Set the line style of the Graphics Context.
int preview_set_line_width (GdkGC *gc, gint line_width)
 Set the line width of the Graphics Context.
int preview_use_gc (GdkDrawable *drawable, GdkGC *gc, const char *color_name, gint line_width, GdkCapStyle line_cap, GdkLineStyle line_style, GdkFill fill_mode)
 Use a Graphics Context when drawing entities.
static void preview_draw_arc (GtkWidget *widget, preview_arc arc)
 Draw an arc on the preview pixmap.
static void preview_draw_background (GtkWidget *widget, gdouble x, gdouble y)
 Draw a white background (rectangle) on the screen.
static void preview_draw_line (GtkWidget *widget, preview_line line)
 Draw a line on the preview pixmap.
static void preview_draw_pad (GtkWidget *widget)
 Draw a pad on the preview pixmap.
static void preview_draw_pin (GtkWidget *widget)
 Draw a pin on the preview pixmap.
static void preview_draw_polygon (GtkWidget *widget, preview_polygon polygon)
 Draw a pin on the preview pixmap.
static void preview_draw_rectangle (GtkWidget *widget, preview_rectangle rectangle)
 Draws a rectangle on the preview canvas.
static gboolean preview_expose_event (GtkWidget *widget, GdkEventExpose *event)
 Redraw the screen from the backing pixmap.
int preview_create_window (gchar *footprint_name, gint width, gint height)
 Create a preview window containing a pixmap with the footprint.

Detailed Description

A footprint preview widget.

Author:
Copyright (C) 2007, 2008, 2009, 2010 by Bert Timmerman <bert.timmerman@xs4all.nl>

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.

Definition in file preview.c.


Function Documentation

static void preview_close_cb ( GtkWidget *  widget,
GtkWidget *  preview_window 
) [static]

Close the preview window (destroy the preview widget).

Parameters:
widget : is the caller widget.
preview_window : is the widget to be closed.

Definition at line 37 of file preview.c.

Referenced by preview_create_window().

static gboolean preview_configure_event ( GtkWidget *  widget,
GdkEventConfigure *  event 
) [static]

Create a new backing pixmap of the appropriate size.

Returns:
TRUE when function is completed.
Parameters:
widget : is the (drawable) widget to contain the image.
event : is the configure event passed from the caller.

Definition at line 55 of file preview.c.

References pixmap.

Referenced by preview_create_window().

int preview_create_window ( gchar *  footprint_name,
gint  width,
gint  height 
)

Create a preview window containing a pixmap with the footprint.

The footprint_name variable is used in the dialog title.

Returns:
0 when successful.
Parameters:
footprint_name : is the footprint type.
width : is width of the pixmap.
height : is height of the pixmap.

Definition at line 681 of file preview.c.

References preview_close_cb(), preview_configure_event(), preview_delete_event(), and preview_expose_event().

Here is the call graph for this function:

void preview_delete_event ( GtkWidget *  widget,
GdkEvent *  event 
)

Delete the window.

Parameters:
widget : is the widget to be deleted.
event : is the delete event passed from the caller.

Definition at line 87 of file preview.c.

static void preview_draw_arc ( GtkWidget *  widget,
preview_arc  arc 
) [static]

Draw an arc on the preview pixmap.

Draws an arc or a filled 'pie slice'.
The arc is defined by the bounding rectangle of the entire ellipse, and the start and end angles of the part of the ellipse to be drawn.

Parameters:
widget : is the toplevel widget containing the drawable.
arc : is a preview arc.

Definition at line 444 of file preview.c.

References preview_arc::angle1, preview_arc::angle2, preview_arc::drawable, preview_arc::filled, preview_arc::gc, preview_arc::height, preview_arc::width, preview_arc::x, and preview_arc::y.

static void preview_draw_background ( GtkWidget *  widget,
gdouble  x,
gdouble  y 
) [static]

Draw a white background (rectangle) on the screen.

Parameters:
widget : is the toplevel widget containing the drawable.
x : is the X-coordinate of the left edge of the background.
y : is the Y-coordinate of the top edge of the background.

Definition at line 478 of file preview.c.

References pixmap.

static void preview_draw_line ( GtkWidget *  widget,
preview_line  line 
) [static]

Draw a line on the preview pixmap.

Draws a line, using the foreground color and other attributes of the GdkGC.

Parameters:
widget : is the toplevel widget containing the drawable.
line : is a preview line.

Definition at line 520 of file preview.c.

References preview_line::drawable, preview_line::gc, preview_line::x1, preview_line::x2, preview_line::y1, and preview_line::y2.

static void preview_draw_pad ( GtkWidget *  widget  )  [static]

Draw a pad on the preview pixmap.

Todo:
Add code here.

Parameters:
widget : is the toplevel widget containing the drawable.

Definition at line 549 of file preview.c.

static void preview_draw_pin ( GtkWidget *  widget  )  [static]

Draw a pin on the preview pixmap.

Todo:
Add code here.

Parameters:
widget : is the toplevel widget containing the drawable.

Definition at line 563 of file preview.c.

static void preview_draw_polygon ( GtkWidget *  widget,
preview_polygon  polygon 
) [static]

Draw a pin on the preview pixmap.

Parameters:
widget : is the toplevel widget containing the drawable.
polygon : is a preview polygon.

Definition at line 577 of file preview.c.

References preview_polygon::drawable, preview_polygon::filled, preview_polygon::gc, preview_polygon::npoints, and preview_polygon::points.

static void preview_draw_rectangle ( GtkWidget *  widget,
preview_rectangle  rectangle 
) [static]

Draws a rectangle on the preview canvas.

Draws a rectangular outline or filled rectangle, using the foreground color and other attributes of the GdkGC.
A rectangle drawn filled is 1 pixel smaller in both dimensions than a rectangle outlined.
Calling gdk_draw_rectangle (window, gc, TRUE, 0, 0, 20, 20) results in a filled rectangle 20 pixels wide and 20 pixels high.
Calling gdk_draw_rectangle (window, gc, FALSE, 0, 0, 20, 20) results in an outlined rectangle with corners at (0, 0), (0, 20), (20, 20), and (20, 0), which makes it 21 pixels wide and 21 pixels high.

Parameters:
widget : is the toplevel widget containing the drawable.
rectangle : is a preview rectangle.

Definition at line 615 of file preview.c.

References preview_rectangle::drawable, preview_rectangle::filled, preview_rectangle::gc, preview_rectangle::height, preview_rectangle::width, preview_rectangle::x, and preview_rectangle::y.

static gboolean preview_expose_event ( GtkWidget *  widget,
GdkEventExpose *  event 
) [static]

Redraw the screen from the backing pixmap.

Returns:
FALSE when function is completed.

Todo:
Add code here to draw footprints.

Parameters:
widget : is the toplevel widget containing the drawable.
event : is the event passed from the caller.

Definition at line 647 of file preview.c.

References pixmap.

Referenced by preview_create_window().

int preview_set_fg_color ( GdkGC *  gc,
const char *  color_name 
)

Set the foreground color of the Graphics Context.

Returns:
EXIT_SUCCESS when function is completed, EXIT_FAILURE when an eror occurred.
Parameters:
gc : is the Graphics Context.
color_name : is a NULL terminated color name.

Definition at line 106 of file preview.c.

int preview_set_fill_mode ( GdkGC *  gc,
GdkFill  fill_mode 
)

Set the fill mode of the Graphics Context.

Returns:
EXIT_SUCCESS when function is completed, EXIT_FAILURE when an eror occurred.
Parameters:
gc : is the Graphics Context.
fill_mode : determines how primitives are drawn.
Valid values are:

  • GDK_SOLID : draw with the foreground color.
  • GDK_TILED : draw with a tiled pixmap.
  • GDK_STIPPLED : draw using the stipple bitmap.
    Pixels corresponding to bits in the stipple bitmap that are set will be drawn in the foreground color;
    pixels corresponding to bits that are not set will be left untouched.
  • GDK_OPAQUE_STIPPLED : draw using the stipple bitmap.
    Pixels corresponding to bits in the stipple bitmap that are set will be drawn in the foreground color;
    pixels corresponding to bits that are not set will be drawn with the background color.

Definition at line 142 of file preview.c.

int preview_set_line_cap ( GdkGC *  gc,
GdkCapStyle  line_cap 
)

Set the line capsulation of the Graphics Context.

Returns:
EXIT_SUCCESS when function is completed, EXIT_FAILURE when an eror occurs.
Parameters:
gc : is the Graphics Context.
line_cap : determines how the end of lines are drawn.
Valid values are:

  • GDK_CAP_NOT_LAST : the same as GDK_CAP_BUTT for lines of non-zero width.
    for zero width lines, the final point on the line will not be drawn.
  • GDK_CAP_BUTT : the ends of the lines are drawn squared off and extending to the coordinates of the end point.
  • GDK_CAP_ROUND : the ends of the lines are drawn as semicircles with the diameter equal to the line width and centered at the end point.
  • GDK_CAP_PROJECTING : the ends of the lines are drawn squared off and extending half the width of the line beyond the end point.

Definition at line 192 of file preview.c.

int preview_set_line_style ( GdkGC *  gc,
GdkLineStyle  line_style 
)

Set the line style of the Graphics Context.

Returns:
EXIT_SUCCESS when function is completed, EXIT_FAILURE when an eror occurs.
Parameters:
gc : is the Graphics Context.
line_style : determines how lines are drawn.
Valid values are:

  • GDK_LINE_SOLID : lines are drawn solid.
  • GDK_LINE_ON_OFF_DASH : even segments are drawn;
    odd segments are not drawn.
  • GDK_LINE_DOUBLE_DASH : even segments are normally.
    Odd segments are drawn in the background color if the fill style is GDK_SOLID, or in the background color masked by the stipple if the fill style is GDK_STIPPLED.

Definition at line 247 of file preview.c.

int preview_set_line_width ( GdkGC *  gc,
gint  line_width 
)

Set the line width of the Graphics Context.

Returns:
EXIT_SUCCESS when function is completed, EXIT_FAILURE when an eror occurs.
Parameters:
gc : is the Graphics Context.
line_width : is the line width in pixels [px].

Definition at line 299 of file preview.c.

int preview_use_gc ( GdkDrawable *  drawable,
GdkGC *  gc,
const char *  color_name,
gint  line_width,
GdkCapStyle  line_cap,
GdkLineStyle  line_style,
GdkFill  fill_mode 
)

Use a Graphics Context when drawing entities.

If the passed Graphics Context is NULL , create a Graphics Context.

Returns:
EXIT_SUCCESS when function is completed, EXIT_FAILURE when an eror occurs.
Parameters:
drawable : is an opaque structure representing an object that can be drawn onto.
This can be a GdkPixmap, a GdkBitmap, or a GdkWindow.
gc : is the Graphics Context.
color_name : is a NULL terminated color name.
line_width : is the line width in pixels [px].
line_cap : determines how the end of lines are drawn.
Valid values are:

  • GDK_CAP_NOT_LAST : the same as GDK_CAP_BUTT for lines of non-zero width.
    for zero width lines, the final point on the line will not be drawn.
  • GDK_CAP_BUTT : the ends of the lines are drawn squared off and extending to the coordinates of the end point.
  • GDK_CAP_ROUND : the ends of the lines are drawn as semicircles with the diameter equal to the line width and centered at the end point.
  • GDK_CAP_PROJECTING : the ends of the lines are drawn squared off and extending half the width of the line beyond the end point.
line_style : determines how lines are drawn.
Valid values are:

  • GDK_LINE_SOLID : lines are drawn solid.
  • GDK_LINE_ON_OFF_DASH : even segments are drawn;
    odd segments are not drawn.
  • GDK_LINE_DOUBLE_DASH : even segments are normally.
    Odd segments are drawn in the background color if the fill style is GDK_SOLID, or in the background color masked by the stipple if the fill style is GDK_STIPPLED.
fill_mode : determines how primitives are drawn.
Valid values are:

  • GDK_SOLID : draw with the foreground color.
  • GDK_TILED : draw with a tiled pixmap.
  • GDK_STIPPLED : draw using the stipple bitmap.
    Pixels corresponding to bits in the stipple bitmap that are set will be drawn in the foreground color;
    pixels corresponding to bits that are not set will be left untouched.
  • GDK_OPAQUE_STIPPLED : draw using the stipple bitmap.
    Pixels corresponding to bits in the stipple bitmap that are set will be drawn in the foreground color;
    pixels corresponding to bits that are not set will be drawn with the background color.

Definition at line 348 of file preview.c.

References preview_set_fg_color(), preview_set_fill_mode(), preview_set_line_cap(), preview_set_line_style(), and preview_set_line_width().

Here is the call graph for this function: