Changeset 2426 in Sophya
- Timestamp:
- Sep 5, 2003, 5:32:47 PM (22 years ago)
- Location:
- trunk/SophyaPI/PI
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/SophyaPI/PI/pigraphgen.cc
r2394 r2426 163 163 //-- 164 164 165 inline void compstring_swapcoord( unsigned long txtdir, PIGrCoord& x, PIGrCoord& y) 166 { 167 if (txtdir != PI_TextDirectionHorizontal) { 168 PIGrCoord tmp = x; 169 x = y; y = tmp; 170 } 171 return; 172 } 173 174 inline void compstring_chksgn_dyud( unsigned long txtdir, int & dyu, int & dyd) 175 { 176 if (txtdir == PI_TextDirectionVerticalDown) { 177 dyu = -dyu; 178 dyd = -dyd; 179 } 180 } 181 inline void compstring_chksgn_dx( unsigned long txtdir, int & dx) 182 { 183 if (txtdir == PI_TextDirectionVerticalUp) dx = -dx; 184 } 185 165 186 /* --Methode-- */ 166 187 void … … 188 209 if (s_dn != NULL) sw_sdn = fnt_ss.GetStringWidth(s_dn); 189 210 190 PIGrCoord xs,ys ;211 PIGrCoord xs,ys,xss,yss; 191 212 int posh = pos & PI_HorizontalPosition; 192 213 int posv = pos & PI_VerticalPosition; 214 unsigned long txtdir = pos&PI_TextDirection; 193 215 194 216 int dyu, dyd; … … 209 231 int deltaposx = ((fh/8) > 0) ? fh/8 : 1; 210 232 233 // Pour gerer les traces de texte verticaux 234 compstring_swapcoord(txtdir, x, y); 235 compstring_chksgn_dyud( txtdir, dyu, dyd); 236 compstring_chksgn_dx( txtdir, deltaposx); 237 compstring_chksgn_dx( txtdir, sw_s); 238 compstring_chksgn_dx( txtdir, sw_sup); 239 compstring_chksgn_dx( txtdir, sw_sdn); 211 240 212 241 if ((pos == 0) || ((posh == PI_HorizontalLeft) && (posv == PI_VerticalBaseLine))) { 213 242 xs = (int)x+sw_s; 214 if (s != NULL) DrawString(xs, y, s, PI_HorizontalRight); 243 ys = y; 244 compstring_swapcoord(txtdir, xs, ys); 245 if (s != NULL) DrawString(xs, ys, s, txtdir | PI_HorizontalRight); 215 246 xs = (int)x+sw_s+deltaposx; 216 247 ys = (int)y+dyu; 217 248 SelFont(fnt_ss); 218 if (s_up != NULL) DrawString(xs, ys, s_up, PI_HorizontalLeft); 249 compstring_swapcoord(txtdir, xs, ys); 250 if (s_up != NULL) DrawString(xs, ys, s_up, txtdir | PI_HorizontalLeft); 251 xs = (int)x+sw_s+deltaposx; 219 252 ys = (int)y+dyd; 220 if (s_dn != NULL) DrawString(xs, ys, s_dn, PI_HorizontalLeft); 253 compstring_swapcoord(txtdir, xs, ys); 254 if (s_dn != NULL) DrawString(xs, ys, s_dn, txtdir | PI_HorizontalLeft); 221 255 } 222 256 else { 223 257 if (posh == PI_HorizontalRight) { 224 258 int sw_ss_max = ( sw_sup > sw_sdn ) ? sw_sup : sw_sdn; 225 xs = (int)x-sw_ss_max-deltaposx; 226 if (s != NULL) DrawString(xs, y, s, PI_HorizontalRight | posv); 259 xss = xs = (int)x-sw_ss_max-deltaposx; 260 ys = y; 261 compstring_swapcoord(txtdir, xs, ys); 262 if (s != NULL) DrawString(xs, ys, s, txtdir | PI_HorizontalRight | posv); 227 263 SelFont(fnt_ss); 228 xs = (int)xs +deltaposx;264 xs = (int)xss+deltaposx; 229 265 ys = (int)y+dyu; 230 if (s_up != NULL) DrawString(xs, ys, s_up, PI_HorizontalLeft); 266 compstring_swapcoord(txtdir, xs, ys); 267 if (s_up != NULL) DrawString(xs, ys, s_up, txtdir | PI_HorizontalLeft); 268 xs = (int)xss+deltaposx; 231 269 ys = (int)y+dyd; 232 if (s_dn != NULL) DrawString(xs, ys, s_dn, PI_HorizontalLeft); 270 compstring_swapcoord(txtdir, xs, ys); 271 if (s_dn != NULL) DrawString(xs, ys, s_dn, txtdir | PI_HorizontalLeft); 233 272 } 234 273 else if (posh == PI_HorizontalCenter) { 235 274 int sw_tot = sw_sup+sw_sdn+sw_s+deltaposx; 236 xs = (int)x-sw_tot/2+sw_s; 237 if (s != NULL) DrawString(xs, y, s, PI_HorizontalRight | posv); 275 xss = xs = (int)x-sw_tot/2+sw_s; 276 ys = y; 277 compstring_swapcoord(txtdir, xs, ys); 278 if (s != NULL) DrawString(xs, ys, s, txtdir | PI_HorizontalRight | posv); 238 279 SelFont(fnt_ss); 239 xs = (int)xs +deltaposx;280 xs = (int)xss+deltaposx; 240 281 ys = (int)y+dyu; 241 if (s_up != NULL) DrawString(xs, ys, s_up, PI_HorizontalLeft); 282 compstring_swapcoord(txtdir, xs, ys); 283 if (s_up != NULL) DrawString(xs, ys, s_up, txtdir | PI_HorizontalLeft); 284 xs = (int)xss+deltaposx; 242 285 ys = (int)y+dyd; 243 if (s_dn != NULL) DrawString(xs, ys, s_dn, PI_HorizontalLeft); 286 compstring_swapcoord(txtdir, xs, ys); 287 if (s_dn != NULL) DrawString(xs, ys, s_dn, txtdir | PI_HorizontalLeft); 244 288 } 245 289 else { 246 290 xs = (int)x+sw_s; 247 if (s != NULL) DrawString(xs, y, s, PI_HorizontalRight | posv); 291 ys = y; 292 compstring_swapcoord(txtdir, xs, ys); 293 if (s != NULL) DrawString(xs, ys, s, txtdir | PI_HorizontalRight | posv); 248 294 SelFont(fnt_ss); 249 295 xs = (int)x+sw_s+deltaposx; 250 296 ys = (int)y+dyu; 251 if (s_up != NULL) DrawString(xs, ys, s_up, PI_HorizontalLeft); 297 compstring_swapcoord(txtdir, xs, ys); 298 if (s_up != NULL) DrawString(xs, ys, s_up, txtdir | PI_HorizontalLeft); 299 xs = (int)x+sw_s+deltaposx; 252 300 ys = (int)y+dyd; 253 if (s_dn != NULL) DrawString(xs, ys, s_dn, PI_HorizontalLeft); 301 compstring_swapcoord(txtdir, xs, ys); 302 if (s_dn != NULL) DrawString(xs, ys, s_dn, txtdir | PI_HorizontalLeft); 254 303 } 255 304 } -
trunk/SophyaPI/PI/piversion.h
r2374 r2426 2 2 #define PIVERSION_H_SEEN 3 3 4 #define PI_VERSIONNUMBER 3.9 54 #define PI_VERSIONNUMBER 3.96 5 5 6 6 #endif -
trunk/SophyaPI/PI/pixtbase.cc
r2410 r2426 1 #include "machdefs.h" 2 #include <stdlib.h> 1 3 #include <stdio.h> 2 4 … … 110 112 { st = last_state_xevt; t = last_time_xevt; } 111 113 114 /* Gestion de variable d'environnement pour choix Mod1Mask ou Mod2Mask */ 115 static bool fgenv_kb_modmasks = false; 116 static int sel_kb_modmasks = 1; 117 112 118 /* Nouvelle-Fonction */ 113 119 static void init_class_pixtbase() 114 120 { 121 // Pour le choix Mod1Mask OU Mod2mask OU ( Mod1Mask | Mod2mask ) 122 // Il faut en particulier Mod2Mask sur serveur X11/MacOSX (touche pomme) 123 // Reza / Septembre 2003 124 // Var. Env PIXKBMODMASK =2 -> Mod2Mask 125 // =3 -> Mod1Mask | Mod2Mask 126 // =0 -> Pas de ModMask 127 // =autre -> Mod1Mask (defaut) 128 if ( !fgenv_kb_modmasks ) { 129 char *envmodmask = getenv("PIXKBMODMASK"); 130 if (envmodmask) { 131 if (envmodmask[0] == '0') sel_kb_modmasks = 0; 132 else if (envmodmask[0] == '2') sel_kb_modmasks = 2; 133 else if (envmodmask[0] == '3') sel_kb_modmasks = 3; 134 else sel_kb_modmasks = 1; 135 } 136 } 115 137 #ifdef DEBUG_PIXTB 116 138 puts("Debug_init_class_pixtbase() "); … … 288 310 if (evt->xkey.state & ControlMask) 289 311 kmod = (PIKeyModifier) (kmod | PIKM_Cntl); 290 // sur MacOSX, la touche Alt correspond a la touche pomme 291 // et la masque associe est Mod2Mask - Reza 02/2002 292 // Pour eviter les problemes, on va confondre Mod1Mask et Mod2mask 293 // Reza / Juillet 2003 294 if ((evt->xkey.state & Mod1Mask) || (evt->xkey.state & Mod2Mask)) 312 // Choix Mod1Mask Et/Ou Mod2Mask par variable sel_kb_modmasks 313 // Reza / Septembre 2003 314 if ((sel_kb_modmasks == 1) && (evt->xkey.state & Mod1Mask) ) 295 315 kmod = (PIKeyModifier) (kmod | PIKM_Alt); 316 if ((sel_kb_modmasks == 2) && (evt->xkey.state & Mod2Mask) ) 317 kmod = (PIKeyModifier) (kmod | PIKM_Alt); 318 if ((sel_kb_modmasks == 3) && 319 ((evt->xkey.state & Mod1Mask) || (evt->xkey.state & Mod2Mask)) ) 320 kmod = (PIKeyModifier) (kmod | PIKM_Alt); 321 296 322 switch (key) { 297 323 case XK_Return : -
trunk/SophyaPI/PI/psfile.cc
r2394 r2426 893 893 894 894 895 /* fonction pour rajouter \ devant ( ) et \ pour string postscript */ 896 static char * EscapePSString(const char *s) 897 { 898 int nce = 0; 899 int ls = strlen(s); 900 int i,j,k; 901 for(int k=0; k<ls; k++) 902 if ( (s[k] == '(') || (s[k] == ')') || (s[k] == '\\') ) nce++; 903 if (nce == 0) return NULL; 904 char * es = new char[ls+nce+1]; 905 j = 0; 906 for(int k=0; k<ls; k++) { 907 if ( (s[k] == '(') || (s[k] == ')') || (s[k] == '\\') ) { 908 es[j] = '\\'; j++; 909 } 910 es[j] = s[k]; j++; 911 } 912 es[j] = '\0'; 913 return es; 914 } 915 895 916 void PSFile::DrawString (double x, double y, const char *s, 896 917 PIColors DrawColor, … … 964 985 setFontDone = true ; // $CHECK$ - doit etre fait uniquement a ce moment 965 986 } 987 /* Les () et \ doivent avoir le caractere escape \ dans les chaines postscript */ 988 char * es = EscapePSString(s); 989 const char * epss = s; 990 if (es != NULL) epss = es; 966 991 if (pos == 0) 967 fprintf(mPSFile, "gs %.2f Ux %.2f Uy m (%s) S gr\n", x, y, s) ;992 fprintf(mPSFile, "gs %.2f Ux %.2f Uy m (%s) S gr\n", x, y, epss) ; 968 993 else { 969 994 unsigned long txtdir = pos & PI_TextDirection; … … 978 1003 if (angle == 0) 979 1004 fprintf(mPSFile, "gs %.2f Ux %.2f Uy m (%s) hlshstr gr\n", 980 x, y, s) ;1005 x, y, epss) ; 981 1006 else 982 1007 fprintf(mPSFile, "gs %.2f Ux %.2f Uy m %d rotate (%s) hlshstr gr\n", 983 x, y, angle, s) ;1008 x, y, angle, epss) ; 984 1009 } 985 1010 else { … … 994 1019 if (angle == 0) 995 1020 fprintf(mPSFile, "gs %.2f Ux %.2f Uy m (%s) h%cshstr gr\n", 996 x, y, s, sshp) ;1021 x, y, epss, sshp) ; 997 1022 else fprintf(mPSFile, "gs %.2f Ux %.2f Uy m %d rotate (%s) h%cshstr gr\n", 998 x, y, angle, s, sshp) ;1023 x, y, angle, epss, sshp) ; 999 1024 } 1000 1025 else { … … 1005 1030 if (angle == 0) 1006 1031 fprintf(mPSFile, "gs %.2f Ux %.2f Uy m (%s) h%cv%cshstr gr\n", 1007 x, y, s, sshp, ssvp) ;1032 x, y, epss, sshp, ssvp) ; 1008 1033 else 1009 1034 fprintf(mPSFile, "gs %.2f Ux %.2f Uy m %d rotate (%s) h%cv%cshstr gr\n", 1010 x, y, angle, s, sshp, ssvp) ;1035 x, y, angle, epss, sshp, ssvp) ; 1011 1036 } 1012 1037 } 1013 1038 1039 if (es) delete[] es; /* chaine modifiee avec des \( \) ou \\ */ 1040 return; 1014 1041 } 1015 1042
Note:
See TracChangeset
for help on using the changeset viewer.