pcb 4.1.1
An interactive printed circuit board layout editor.

pcb-printf.h

Go to the documentation of this file.
00001 
00081 #ifndef PCB_PCB_PRINTF_H
00082 #define PCB_PCB_PRINTF_H
00083 
00084 enum e_allow {
00085   NO_PRINT = 0,         /* suffixes we can read but not print (i.e., "inch") */
00086   ALLOW_NM = 1,
00087   ALLOW_UM = 2,
00088   ALLOW_MM = 4,
00089   ALLOW_CM = 8,
00090   ALLOW_M  = 16,
00091   ALLOW_KM = 32,
00092 
00093   ALLOW_CMIL = 1024,
00094   ALLOW_DMIL = 2048,
00095   ALLOW_MIL  = 4096,
00096   ALLOW_IN   = 8192,
00097 
00098   ALLOW_METRIC   = ALLOW_NM | ALLOW_UM | ALLOW_MM |
00099                    ALLOW_CM | ALLOW_M  | ALLOW_KM,
00100   ALLOW_IMPERIAL = ALLOW_CMIL | ALLOW_DMIL | ALLOW_MIL | ALLOW_IN,
00101   /* This is all units allowed in parse_l.l */
00102 #if 0
00103   ALLOW_READABLE = ALLOW_NM | ALLOW_UM | ALLOW_MM |
00104                    ALLOW_M  | ALLOW_KM | ALLOW_CMIL |
00105                    ALLOW_MIL | ALLOW_IN,
00106 #else
00107   ALLOW_READABLE = ALLOW_MIL | ALLOW_MM,
00108 #endif
00109 
00110   ALLOW_ALL = ~ALLOW_DMIL
00111 };
00112 
00113 enum e_family { METRIC, IMPERIAL };
00114 enum e_suffix {
00115   NO_SUFFIX,                    
00116   SUFFIX,                       
00117   FILE_MODE_NO_SUFFIX,          
00118   FILE_MODE                     
00119 };
00120 
00121 struct unit {
00122   int index;                    
00123   const char *suffix;
00124   const char *in_suffix;        
00125   char printf_code;
00126   double scale_factor;
00127   enum e_family family;
00128   enum e_allow  allow;
00129   int default_prec;
00130   /* used for gui spinboxes */
00131   double step_tiny;
00132   double step_small;
00133   double step_medium;
00134   double step_large;
00135   double step_huge;
00136   /* aliases -- right now we only need 1 ("inch"->"in"), add as needed */
00137   const char *alias[1];
00138 };
00139 
00140 struct increments {
00141   const char *suffix;
00142   /* key g and <shift>g value  */
00143   Coord grid;
00144   Coord grid_min;
00145   Coord grid_max;
00146   /* key s and <shift>s value  */
00147   Coord size;
00148   Coord size_min;
00149   Coord size_max;
00150   /* key l and <shift>l value  */
00151   Coord line;
00152   Coord line_min;
00153   Coord line_max;
00154   /* key k and <shift>k value  */
00155   Coord clear;
00156   Coord clear_min;
00157   Coord clear_max;
00158 };
00159 
00160 void initialize_units();
00161 
00162 const Unit *get_unit_struct (const char *suffix);
00163 const Unit *get_unit_list (void);
00164 int get_n_units (void);
00165 double coord_to_unit (const Unit *, Coord);
00166 Coord  unit_to_coord (const Unit *, double);
00167 Increments *get_increments_struct (enum e_family family);
00168 void copy_nonzero_increments (Increments *dst, const Increments *src);
00169 enum e_allow set_allow_readable(enum e_allow new_mask);
00170 
00171 int pcb_fprintf(FILE *f, const char *fmt, ...);
00172 int pcb_snprintf(char *string, size_t size, const char *fmt, ...);
00173 int pcb_printf(const char *fmt, ...);
00174 char *pcb_g_strdup_printf(const char *fmt, ...);
00175 gchar *pcb_vprintf(const char *fmt, va_list args);
00176 
00177 #ifdef PCB_UNIT_TEST
00178 void pcb_printf_register_tests ();
00179 void pcb_printf_test_unit ();
00180 void pcb_printf_test_printf ();
00181 #endif
00182 
00183 #endif
00184