コード例 #1
0
ファイル: g_action.c プロジェクト: SayCV/geda-gaf
/*! \brief Get the action position.
 * \par Function Description
 * Retrieves the current action position and stores it in \a x and \a
 * y, optionally snapping it to the grid if \a snap is true.  This
 * should be interpreted as the position that the user was pointing
 * with the mouse pointer when the current action was invoked.  If
 * there is no valid world position for the current action, returns
 * FALSE without modifying the output variables.
 *
 * This should be used by actions implemented in C to figure out where
 * on the schematic the user wants them to apply the action.
 *
 * See also the (gschem action) Scheme module.
 *
 * \param w_current    Current gschem toplevel structure.
 * \param x            Location to store x coordinate.
 * \param y            Location to store y coordinate.
 *
 * \return TRUE if current action position is set, FALSE otherwise.
 */
gboolean
g_action_get_position (gboolean snap, int *x, int *y)
{
  SCM s_action_position_proc;
  SCM s_point;
  GschemToplevel *w_current = g_current_window ();

  g_assert (w_current);

  /* Get the action-position procedure */
  s_action_position_proc =
    scm_variable_ref (scm_c_module_lookup (scm_c_resolve_module ("gschem action"),
                                           "action-position"));

  /* Retrieve the action position */
  s_point = scm_call_0 (s_action_position_proc);

  if (scm_is_false (s_point)) return FALSE;

  if (x) {
    *x = scm_to_int (scm_car (s_point));
    if (snap) {
      *x = snap_grid (w_current, *x);
    }
  }
  if (y) {
    *y = scm_to_int (scm_cdr (s_point));
    if (snap) {
      *y = snap_grid (w_current, *y);
    }
  }

  return TRUE;
}
コード例 #2
0
ファイル: g_funcs.c プロジェクト: jaredcasper/geda-gaf
/*! \todo Finish function documentation!!!
 *  \brief
 *  \par Function Description
 *
 */
SCM g_funcs_image(SCM scm_filename)
{
  char *filename;

  SCM_ASSERT (scm_is_string (scm_filename), scm_filename,
              SCM_ARG1, "gschem-image");

  GSCHEM_TOPLEVEL *w_current = g_current_window ();

  if (output_filename) {
    x_image_lowlevel (w_current, output_filename,
                      w_current->image_width,
                      w_current->image_height,
		      g_strdup("png"));
  } else  {
    filename = scm_to_utf8_string (scm_filename);
    x_image_lowlevel (w_current, filename,
                      w_current->image_width,
                      w_current->image_height,
		      g_strdup("png"));
    free(filename);
  }
  
  return SCM_BOOL_T;
}
コード例 #3
0
ファイル: g_funcs.c プロジェクト: jaredcasper/geda-gaf
/*! \todo Finish function documentation!!!
 *  \brief
 *  \par Function Description
 *
 */
SCM g_funcs_use_rc_values(void)
{
  i_vars_set(g_current_window ());
  return SCM_BOOL_T;
}
コード例 #4
0
ファイル: g_attrib.c プロジェクト: blueantst/geda-gaf
 *
 * \return the newly created text object.
 */
SCM_DEFINE (add_attrib_x, "%add-attrib!", 5, 0, 0,
            (SCM target_s, SCM name_s, SCM value_s, SCM visible_s, SCM show_s),
            "Add an attribute to an object, or floating")
{
  SCM_ASSERT ((edascm_is_page (target_s) ||
               edascm_is_object (target_s) ||
               scm_is_false (target_s)),
              target_s, SCM_ARG1, s_add_attrib_x);
  SCM_ASSERT (scm_is_string (name_s), name_s, SCM_ARG2, s_add_attrib_x);
  SCM_ASSERT (scm_is_string (value_s), value_s, SCM_ARG3, s_add_attrib_x);
  SCM_ASSERT (scm_is_symbol (show_s), show_s, SCM_ARG5, s_add_attrib_x);

  GschemToplevel *w_current = g_current_window ();
  TOPLEVEL *toplevel = gschem_toplevel_get_toplevel (w_current);

  /* Check target object, if present */
  OBJECT *obj = NULL;
  if (edascm_is_object (target_s)) {
    obj = edascm_to_object (target_s);
    if (o_get_page (toplevel, obj) != toplevel->page_current) {
      scm_error (object_state_sym,
                 s_add_attrib_x,
                 _("Object ~A is not included in the current gschem page."),
                 scm_list_1 (target_s), SCM_EOL);
    }
  }

  /* Visibility */