hid/gtk: Clean up ghid_pan_fixup ()
[geda-pcb/pcjc2.git] / src / misc.h
blob792646024a042429cc6f75ef8b0a2aea25dd018f
1 /*
2 * COPYRIGHT
4 * PCB, interactive printed circuit board design
5 * Copyright (C) 1994,1995,1996,2006 Thomas Nau
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 * Contact addresses for paper mail and Email:
22 * Thomas Nau, Schlehenweg 15, 88471 Baustetten, Germany
23 * Thomas.Nau@rz.uni-ulm.de
25 * RCS: $Id$
28 /* prototypes for misc routines
31 #ifndef __MISC_INCLUDED__
32 #define __MISC_INCLUDED__
34 #include <stdlib.h>
35 #include "global.h"
36 #include "mymem.h"
38 enum unitflags { UNIT_PERCENT = 1 };
40 typedef struct {
41 const char *suffix;
42 double scale;
43 enum unitflags flags;
44 } UnitList[];
46 double Distance (double x1, double y1, double x2, double y2);
48 void r_delete_element (DataTypePtr, ElementTypePtr);
49 void SetLineBoundingBox (LineTypePtr);
50 void SetArcBoundingBox (ArcTypePtr);
51 void SetPointBoundingBox (PointTypePtr);
52 void SetPinBoundingBox (PinTypePtr);
53 void SetPadBoundingBox (PadTypePtr);
54 void SetPolygonBoundingBox (PolygonTypePtr);
55 void SetElementBoundingBox (DataTypePtr, ElementTypePtr, FontTypePtr);
56 bool IsDataEmpty (DataTypePtr);
57 bool IsLayerEmpty (LayerTypePtr);
58 bool IsLayerNumEmpty (int);
59 bool IsLayerGroupEmpty (int);
60 bool IsPasteEmpty (int);
61 BoxTypePtr GetDataBoundingBox (DataTypePtr);
62 void CenterDisplay (LocationType, LocationType);
63 void SetFontInfo (FontTypePtr);
64 int ParseGroupString (char *, LayerGroupTypePtr, int /* LayerN */);
65 int ParseRouteString (char *, RouteStyleTypePtr, const char *);
66 void QuitApplication (void);
67 char *EvaluateFilename (char *, char *, char *, char *);
68 char *ExpandFilename (char *, char *);
69 void SetTextBoundingBox (FontTypePtr, TextTypePtr);
71 void SaveOutputWindow (void);
72 int GetLayerNumber (DataTypePtr, LayerTypePtr);
73 int GetLayerGroupNumberByPointer (LayerTypePtr);
74 int GetLayerGroupNumberByNumber (Cardinal);
75 int GetGroupOfLayer (int);
76 int ChangeGroupVisibility (int, bool, bool);
77 void LayerStringToLayerStack (char *);
80 BoxTypePtr GetObjectBoundingBox (int, void *, void *, void *);
81 void ResetStackAndVisibility (void);
82 void SaveStackAndVisibility (void);
83 void RestoreStackAndVisibility (void);
84 char *GetWorkingDirectory (char *);
85 void CreateQuotedString (DynamicStringTypePtr, char *);
86 int GetGridFactor (void);
87 BoxTypePtr GetArcEnds (ArcTypePtr);
88 void ChangeArcAngles (LayerTypePtr, ArcTypePtr, long int, long int);
89 char *UniqueElementName (DataTypePtr, char *);
90 void AttachForCopy (LocationType, LocationType);
91 double GetValue (const char *, const char *, bool *);
92 double GetValueEx (const char *, const char *, bool *, UnitList, const char *);
93 int FileExists (const char *);
94 char *Concat (const char *, ...); /* end with NULL */
96 char *pcb_author ();
98 /* Returns NULL if the name isn't found, else the value for that named
99 attribute. */
100 char *AttributeGetFromList (AttributeListType *list, char *name);
101 /* Adds an attribute to the list. If the attribute already exists,
102 whether it's replaced or a second copy added depends on
103 REPLACE. Returns non-zero if an existing attribute was replaced. */
104 int AttributePutToList (AttributeListType *list, const char *name, const char *value, int replace);
105 /* Simplistic version: Takes a pointer to an object, looks up attributes in it. */
106 #define AttributeGet(OBJ,name) AttributeGetFromList (&(OBJ->Attributes), name)
107 /* Simplistic version: Takes a pointer to an object, sets attributes in it. */
108 #define AttributePut(OBJ,name,value) AttributePutToList (&(OBJ->Attributes), name, value, 1)
109 /* Remove an attribute by name. */
110 void AttributeRemoveFromList(AttributeListType *list, char *name);
111 /* Simplistic version of Remove. */
112 #define AttributeRemove(OBJ, name) AttributeRemoveFromList (&(OBJ->Attributes), name)
114 /* For passing modified flags to other functions. */
115 FlagType MakeFlags (unsigned int);
116 FlagType OldFlags (unsigned int);
117 FlagType AddFlags (FlagType, unsigned int);
118 FlagType MaskFlags (FlagType, unsigned int);
119 #define NoFlags() MakeFlags(0)
121 /* Layer Group Functions */
123 /* Returns group actually moved to (i.e. either group or previous) */
124 int MoveLayerToGroup (int layer, int group);
125 /* returns pointer to private buffer */
126 char *LayerGroupsToString (LayerGroupTypePtr);
127 /* Make the current layer groups the default. */
128 void MakeLayerGroupsDefault ();
130 /* These act like you'd expect, except always in the C locale. */
131 extern double c_strtod(const char *s);
132 extern const char *c_dtostr(double d);
134 /* Returns a string with info about this copy of pcb. */
135 char * GetInfoString (void);
137 /* Return a relative rotation for an element, useful only for
138 comparing two similar footprints. */
139 int ElementOrientation (ElementType *e);
141 /* These are in netlist.c */
143 void NetlistChanged (int force_unfreeze);
146 * Check whether mkdir() is mkdir or _mkdir, and whether it takes one
147 * or two arguments. WIN32 mkdir takes one argument and POSIX takes
148 * two.
150 #if HAVE_MKDIR
151 #if MKDIR_TAKES_ONE_ARG
152 /* MinGW32 */
153 #include <io.h> /* mkdir under MinGW only takes one argument */
154 #define MKDIR(a, b) mkdir(a)
155 #else
156 #define MKDIR(a, b) mkdir(a, b)
157 #endif
158 #else
159 #if HAVE__MKDIR
160 /* plain Windows 32 */
161 #define MKDIR(a, b) _mkdir(a)
162 #else
163 #define MKDIR(a, b) pcb_mkdir(a, b)
164 #define MKDIR_IS_PCBMKDIR 1
165 int pcb_mkdir (const char *path, int mode);
166 #endif
167 #endif
170 #endif /* __MISC_INCLUDED__ */