Changeset 316 in Sophya
- Timestamp:
- Jun 15, 1999, 3:56:51 PM (26 years ago)
- Location:
- trunk/SophyaPI/PI
- Files:
-
- 14 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/SophyaPI/PI/pibwdgx.cc
r292 r316 149 149 printf("PIBaseWdgX::ActivateMove %d \n \n", bid); 150 150 #endif 151 unsigned long evtmask ;151 unsigned long evtmask = 0; 152 152 153 153 // bid == 0 -> PointerMove sans bouton -
trunk/SophyaPI/PI/picmapview.cc
r130 r316 117 117 sprintf(buff, "%.2f", vmax); 118 118 int fa, fd; 119 g->DrawString(4, g->GetFont Height(fa,fd)+4, buff);119 g->DrawString(4, g->GetFont().GetFontHeight(fa,fd)+4, buff); 120 120 } 121 121 -
trunk/SophyaPI/PI/pigraphgen.cc
r292 r316 24 24 // Links Voir aussi 25 25 // PIGrCoord 26 // PIFont 26 27 // PIColorMap 27 28 //-- … … 191 192 // void SelGOMode(PIGOMode mod=PI_GOCopy) 192 193 // Choix du mode de tracé graphique: "PI_GOCopy" ou "PI_GOXOR" ou "PI_GOInvert" 193 // void SelFont(PIFontSize sz=PI_NormalSizeFont, PIFontAtt att=PI_RomanFont)194 // Choix de la fonte pour le tracé de texte195 //| PI_SmallSizeFont , PI_NormalSizeFont , PI_BigSizeFont, PI_HugeSizeFont196 //| PI_RomanFont , PI_BoldFont , PI_ItalicFont197 // void SelFontSzPt(int npt=12, PIFontAtt att=PI_RomanFont)198 // Choix de la fonte avec spécification de taille en points (pixels sur l'écran)199 194 // void SelLine(PILineAtt att=PI_NormalLine) 200 195 // Choix du type de ligne pour le tracé des lignes et contours … … 208 203 //| PI_TriangleMarker , PI_FTriangleMarker , PI_StarMarker , PI_FStarMarker 209 204 // (Les "StarMaker" ne sont pas encore implémentés 11/98) 205 //-- 206 207 //++ 208 // Titre Changement de fontes 209 //-- 210 //++ 211 // void SelFont(PIFont & fnt) 212 // Choix de fonte courant. 213 // void SelFont(PIFontSize sz=PI_NormalSizeFont, PIFontAtt att=PI_RomanFont) 214 // Changement de taille et attribut de fonte 215 //| PI_SmallSizeFont , PI_NormalSizeFont , PI_BigSizeFont, PI_HugeSizeFont 216 //| PI_RomanFont , PI_BoldFont , PI_ItalicFont 217 // void SelFontSzPt(int npt=12, PIFontAtt att=PI_RomanFont) 218 // Choix de taille de fonte avec spécification de taille en points 219 // (pixels sur l'écran) 220 // 210 221 //-- 211 222 … … 241 252 // int GetMarkerSize() 242 253 // Renvoie la taille des signes (Marker) pour le marker courant 243 // int GetFontHeight(int& asc, int& desc) 254 // PIFont GetFont() 255 // Retourne une copie de l'objet "PIFont" courant. 256 // PIGrCoord GetFontHeight(PIGrCoord& asc, PIGrCoord& desc); 244 257 // Renvoie la hauteur des caractères, ainsi que la taille au dessus 245 258 // et en-dessous de la ligne de base ("asc , desc") pour la fonte courante 259 // dans le système de coordonnées courant (Fenêtre ou UC). 246 260 // PIGrCoord CalcStringWidth(char const* s) 247 261 // Renvoie la largeur occupé par un texte s'il était affiché dans le 248 262 // système de coordonnées courant (Fenêtre ou UC). 249 263 //-- 264 265 /* --Methode-- */ 266 PIGrCoord PIGraphicGen::GetFontHeight(PIGrCoord& asc, PIGrCoord& desc) 267 { 268 int t,a,d; 269 t = myFont.GetFontHeight(a, d); 270 asc = a; desc = d; 271 return(t); 272 } 273 274 /* --Methode-- */ 275 PIGrCoord PIGraphicGen::CalcStringWidth(char const* s) 276 { 277 return (myFont.GetStringWidth(s)); 278 } 250 279 251 280 //++ … … 267 296 sBCol = GetBackground(); 268 297 sGOm = GetGOMode(); 269 sFAtt = GetFontAtt(); 270 sFSize = GetFontSize(); 298 sFont = GetFont(); 271 299 sLAtt = GetLineAtt(); 272 300 sMrk = GetMarker(); … … 281 309 SelBackground(sBCol); 282 310 SelGOMode(sGOm); 283 SelFont SzPt(sFSize, sFAtt);311 SelFont(sFont); 284 312 SelLine(sLAtt); 285 313 SelMarker(sMrkSz, sMrk); -
trunk/SophyaPI/PI/pigraphgen.h
r292 r316 11 11 #include PIWDG_H 12 12 #include PICMAP_H 13 #include PIFONT_H 13 14 14 15 … … 22 23 PI_ColorAllBits0 = 16, PI_ColorAllBits1 = 17 }; 23 24 24 enum PIFontSize { PI_NotDefFontSize = -1,25 PI_SmallSizeFont = 1, PI_NormalSizeFont = 2,26 PI_BigSizeFont = 3, PI_HugeSizeFont = 4 };27 28 enum PIFontAtt { PI_NotDefFontAtt = -1,29 PI_RomanFont = 1, PI_BoldFont = 2, PI_ItalicFont = 4 };30 25 31 26 enum PILineAtt { PI_NotDefLineAtt = -1, … … 112 107 virtual void SelBackground(PIColorMap& cmap, int cid) = 0; 113 108 virtual void SelGOMode(PIGOMode mod=PI_GOCopy) = 0; 114 virtual void SelFont(PIFontSize sz=PI_NormalSizeFont,115 PIFontAtt att=PI_RomanFont) = 0;116 virtual void SelFontSzPt(int npt=12, PIFontAtt att=PI_RomanFont) = 0;117 109 virtual void SelLine(PILineAtt att=PI_NormalLine) = 0; 118 110 virtual void SelMarker(int msz=3, PIMarker mrk=PI_DotMarker) = 0; 111 // Modifications de fonte 112 virtual void SelFont(PIFont & fnt) = 0; 113 virtual void SelFont(PIFontSize sz=PI_NormalSizeFont, 114 PIFontAtt att=PI_RomanFont) = 0; 115 virtual void SelFontSzPt(int npt=12, PIFontAtt att=PI_RomanFont) = 0; 119 116 120 117 // Selection de zone de trace (clip) … … 126 123 virtual PIColors GetBackground() = 0; 127 124 virtual PIGOMode GetGOMode() = 0; 128 virtual PIFontAtt GetFontAtt() = 0;129 virtual int GetFontSize() = 0;130 125 virtual PILineAtt GetLineAtt() = 0; 131 126 virtual PIMarker GetMarker() = 0; 132 127 virtual int GetMarkerSize() = 0; 133 128 134 virtual int GetFontHeight(int& asc, int& desc) = 0; 135 virtual PIGrCoord CalcStringWidth(char const* s) = 0; 129 // Acces a la fonte et ses attributs 130 inline PIFont GetFont() { return (myFont) ; } 131 virtual PIGrCoord GetFontHeight(PIGrCoord& asc, PIGrCoord& desc); 132 virtual PIGrCoord CalcStringWidth(char const* s); 136 133 137 134 // Sauvegarde des attributs graphiques … … 144 141 PIScreenBuffer* myGrb; 145 142 143 PIFont myFont; 146 144 PIColors sFCol, sBCol; 147 145 PIGOMode sGOm; 148 PIFont Att sFAtt;146 PIFont sFont; 149 147 PILineAtt sLAtt; 150 148 int sFSize; … … 152 150 int sMrkSz; 153 151 }; 154 155 #endif156 152 157 153 typedef PIGraphicGen PIGraphic; … … 162 158 // PIGraphicPS 163 159 // PIGraphicUC 160 161 #endif // PIGRAPHGEN_H_SEEN -
trunk/SophyaPI/PI/pigraphps.cc
r204 r316 327 327 return; 328 328 } 329 /* --Methode-- */ 330 void PIGraphicPS::SelFont(PIFont & fnt) 331 { 332 // $CHECK$ - Reza 13/06/99 333 SelFontSzPt(fnt.GetFontSize(), fnt.GetFontAtt()); 334 } 329 335 330 336 /* --Methode-- */ 331 337 void PIGraphicPS::SelFontSzPt(int npt, PIFontAtt att) 332 338 { 339 // $CHECK$ - Reza 13/06/99 340 myFont.SetFontSzPt(npt); 341 myFont.SetFontAtt(att); 333 342 mFSize = npt; 334 343 mFAtt = att; … … 341 350 void PIGraphicPS::SelFont(PIFontSize sz, PIFontAtt att) 342 351 { 352 // $CHECK$ - Reza 13/06/99 343 353 int i; 344 354 switch (sz) { … … 356 366 break; 357 367 } 368 myFont.SetFontSz(sz); 369 myFont.SetFontAtt(att); 358 370 mFSize = fntsz[i]; 359 371 mFAtt = att; … … 413 425 } 414 426 415 /* --Methode-- */416 PIFontAtt PIGraphicPS::GetFontAtt()417 {418 return (mFAtt);419 }420 421 /* --Methode-- */422 int PIGraphicPS::GetFontSize()423 {424 return (mFSize);425 }426 427 427 428 /* --Methode-- */ … … 443 444 } 444 445 445 /* --Methode-- */446 /* --Methode-- 446 447 int PIGraphicPS::GetFontHeight(int& asc, int& desc) 447 448 { 448 /* $CHECK$ A refaire , voir Nicolas */ 449 $CHECK$ A refaire , voir Nicolas 449 450 asc = mFSize; desc = 0; 450 451 return(asc+desc); 451 } 452 453 454 /* --Methode-- */ 452 } 453 */ 454 455 456 /* --Methode-- 455 457 PIGrCoord PIGraphicPS::CalcStringWidth(char const* s) 456 458 { 457 return((double)(mFSize*strlen(s)*0.5)); /* facteur 0.5 ad'hoc $CHECK$ Voir Nicolas ! */ 458 } 459 return((double)(mFSize*strlen(s)*0.5)); 460 // facteur 0.5 ad hoc $CHECK$ Voir Nicolas 461 } 462 */ 463 459 464 460 465 /* --Methode-- */ … … 464 469 sFCol = mFCol; sBCol = mBCol; 465 470 sGOm = mGOm; 466 sF Att = mFAtt; sFSize = mFSize;471 sFont = myFont; 467 472 sMrk = mMrk; sMrkSz = mMrkSz; 468 473 return; … … 478 483 // else A faire Nicolas 479 484 SelGOMode(sGOm); 480 SelFont SzPt(sFSize, sFAtt);485 SelFont(sFont); 481 486 SelLine(sLAtt); 482 487 SelMarker(sMrkSz, sMrk); -
trunk/SophyaPI/PI/pigraphps.h
r204 r316 46 46 virtual void SelBackground(PIColorMap& cmap, int cid); 47 47 virtual void SelGOMode(PIGOMode mod=PI_GOCopy); 48 virtual void SelLine(PILineAtt att=PI_NormalLine); 49 virtual void SelMarker(int msz=3, PIMarker mrk=PI_DotMarker); 50 51 virtual void SelFont(PIFont & fnt); 48 52 virtual void SelFont(PIFontSize sz=PI_NormalSizeFont, 49 53 PIFontAtt att=PI_RomanFont); 50 54 virtual void SelFontSzPt(int npt=12, PIFontAtt att=PI_RomanFont); 51 virtual void SelLine(PILineAtt att=PI_NormalLine);52 virtual void SelMarker(int msz=3, PIMarker mrk=PI_DotMarker);53 55 54 56 // Selection de zone de trace (clip) … … 60 62 virtual PIColors GetBackground(); 61 63 virtual PIGOMode GetGOMode(); 62 virtual PIFontAtt GetFontAtt();63 virtual int GetFontSize();64 64 virtual PILineAtt GetLineAtt(); 65 65 virtual PIMarker GetMarker(); 66 66 virtual int GetMarkerSize(); 67 67 68 virtual int GetFontHeight(int& asc, int& desc);69 virtual PIGrCoord CalcStringWidth(char const* s);68 // virtual PIGrCoord GetFontHeight(PIGrCoord& asc, PIGrCoord& desc); 69 // virtual PIGrCoord CalcStringWidth(char const* s); 70 70 71 71 // Sauvegarde des attributs graphiques -
trunk/SophyaPI/PI/pigraphuc.cc
r204 r316 583 583 584 584 /* --Methode-- */ 585 void PIGraphicUC::SelFont(PIFont & fnt) 586 { 587 if (!mGrC) return; 588 mGrC->SelFont(fnt); 589 return; 590 } 591 592 /* --Methode-- */ 585 593 void PIGraphicUC::SelFont(PIFontSize sz, PIFontAtt att) 586 594 { … … 671 679 } 672 680 673 /* --Methode-- */674 PIFontAtt PIGraphicUC::GetFontAtt()675 {676 if (!mGrC) return(PI_NotDefFontAtt);677 return(mGrC->GetFontAtt());678 }679 680 /* --Methode-- */681 int PIGraphicUC::GetFontSize()682 {683 if (!mGrC) return(0);684 return(mGrC->GetFontSize());685 }686 681 687 682 /* --Methode-- */ … … 706 701 } 707 702 /* --Methode-- */ 708 PIGrCoord PIGraphicUC::GetFontHeight UC(PIGrCoord& asc, PIGrCoord& desc)703 PIGrCoord PIGraphicUC::GetFontHeight(PIGrCoord& asc, PIGrCoord& desc) 709 704 { 710 705 asc = desc = 0; … … 712 707 int h,a,d; 713 708 double fh, fa, fd, x; 714 h = m GrC->GetFontHeight(a, d) ;709 h = myFont.GetFontHeight(a, d) ; 715 710 DGrC2UC(0., h, x, fh); 716 711 DGrC2UC(0., a, x, fa); … … 720 715 } 721 716 722 /* --Methode-- */723 int PIGraphicUC::GetFontHeight(int& asc, int& desc)724 {725 asc = desc = 0;726 if (!mGrC) return(0);727 return( mGrC->GetFontHeight(asc, desc) );728 }729 717 730 718 /* --Methode-- */ … … 732 720 { 733 721 if (!mGrC) return(0.); 734 double dx = m GrC->CalcStringWidth(s);722 double dx = myFont.GetStringWidth(s); 735 723 double dxx, dxy; 736 724 DGrC2UC(dx, dx, dxx, dxy); -
trunk/SophyaPI/PI/pigraphuc.h
r204 r316 64 64 virtual void SelBackground(PIColorMap& cmap, int cid); 65 65 virtual void SelGOMode(PIGOMode mod=PI_GOCopy); 66 virtual void SelLine(PILineAtt att=PI_NormalLine); 67 virtual void SelMarker(int msz=3, PIMarker mrk=PI_DotMarker); 68 69 // Modification de fonte 70 virtual void SelFont(PIFont & fnt); 66 71 virtual void SelFont(PIFontSize sz=PI_NormalSizeFont, 67 72 PIFontAtt att=PI_RomanFont); 68 73 virtual void SelFontSzPt(int npt=12, PIFontAtt att=PI_RomanFont); 69 virtual void SelLine(PILineAtt att=PI_NormalLine);70 virtual void SelMarker(int msz=3, PIMarker mrk=PI_DotMarker);71 72 74 // Fonctions specifiques a PIGraphicUC : 73 75 virtual void SelFontSz(PIGrCoord sz, PIFontAtt att=PI_RomanFont); 74 76 virtual void SelMarkerSz(PIGrCoord msz, PIMarker mrk=PI_DotMarker); 75 virtual PIGrCoord GetFontHeightUC(PIGrCoord& asc, PIGrCoord& desc);76 77 77 78 // Selection de zone de trace (clip) … … 83 84 virtual PIColors GetBackground(); 84 85 virtual PIGOMode GetGOMode(); 85 virtual PIFontAtt GetFontAtt();86 virtual int GetFontSize();87 86 virtual PILineAtt GetLineAtt(); 88 87 virtual PIMarker GetMarker(); 89 88 virtual int GetMarkerSize(); 90 89 91 virtual int GetFontHeight(int& asc, int& desc);90 virtual PIGrCoord GetFontHeight(PIGrCoord& asc, PIGrCoord& desc); 92 91 virtual PIGrCoord CalcStringWidth(char const* s); 92 93 93 94 94 // Sauvegarde des attributs graphiques -
trunk/SophyaPI/PI/pigraphx.cc
r292 r316 12 12 13 13 /* Variables globales pour modifier les GC */ 14 #define NMAXFONTSZ 715 static XFontStruct * fntst[NMAXFONTSZ][3];16 static int fntsz[NMAXFONTSZ] = {8,10,12,14,18,24,36};17 static int SmallFontIndex = 1;18 static int NormalFontIndex = 3;19 static int BigFontIndex = 5;20 static int HugeFontIndex = 6;21 static PIFontAtt fntatt[3] = { PI_RomanFont, PI_BoldFont, PI_ItalicFont };22 14 #define NMAXCOL 18 23 15 static PIXColor colpix[NMAXCOL]; … … 74 66 SelBackground(PI_White); 75 67 mLAtt = PI_ThinLine; 68 XSetFont(mDisp, DefGC(), myFont.GetXFontId()); // Pour initialiser la fonte ds le GC 76 69 SelLine(); 77 mFAtt = PI_BoldFont; mFSize = 0;78 SelFont();79 70 SelMarker(1, PI_DotMarker); 80 71 mFCfMap = colpix[PI_Black]; mBCfMap = colpix[PI_White]; … … 430 421 431 422 /* --Methode-- */ 423 void PIGraphicX::SelFont(PIFont & fnt) 424 { 425 if (myFont == fnt) return; 426 myFont = fnt; 427 XSetFont(mDisp, DefGC(), myFont.GetXFontId()); 428 } 429 430 /* --Methode-- */ 431 void PIGraphicX::SelFont(PIFontSize sz, PIFontAtt att) 432 { 433 PIFont fnt(myFont.GetFontName()); 434 fnt.SetFontAtt(att); 435 fnt.SetFontSz(sz); 436 SelFont(fnt); 437 } 438 439 /* --Methode-- */ 432 440 void PIGraphicX::SelFontSzPt(int npt, PIFontAtt att) 433 441 { 434 int dsz,i,isel, j; 435 436 if ((npt == mFSize) && (att == mFAtt)) return; 437 isel = 0; 438 dsz = 9999; 439 for(i=0; i<NMAXFONTSZ; i++) 440 { 441 j = npt - fntsz[i]; if (j < 0) j = -j; 442 if (j < dsz) { isel = i; dsz = j; } 443 } 444 445 j = 0; 446 if (att & PI_RomanFont) j = 0; 447 if (att & PI_BoldFont) j = 1; 448 if (att & PI_ItalicFont) j = 2; 449 SelectFont(isel, j); 450 451 } 452 453 /* --Methode-- */ 454 void PIGraphicX::SelFont(PIFontSize sz, PIFontAtt att) 455 { 456 int i,j; 457 switch (sz) 458 { 459 case PI_SmallSizeFont: 460 i = SmallFontIndex; 461 break; 462 case PI_NormalSizeFont: 463 i = NormalFontIndex; 464 break; 465 case PI_BigSizeFont: 466 i = BigFontIndex; 467 break; 468 case PI_HugeSizeFont: 469 i = HugeFontIndex; 470 break; 471 default: 472 i = NormalFontIndex; 473 break; 474 } 475 476 j = 0; 477 if (att & PI_RomanFont) j = 0; 478 if (att & PI_BoldFont) j = 1; 479 if (att & PI_ItalicFont) j = 2; 480 481 SelectFont(i, j); 442 PIFont fnt(npt, myFont.GetFontName(), att); 443 SelFont(fnt); 482 444 } 483 445 … … 632 594 } 633 595 634 /* --Methode-- */635 int PIGraphicX::GetFontHeight(int& asc, int& desc)636 {637 char a[2];638 XCharStruct ovr;639 int hd, fa, fd;640 XTextExtents(mFSt, a, 0, &hd, &fa, &fd, &ovr);641 asc = fa; desc = fd;642 return(fa+fd);643 }644 645 /* --Methode-- */646 PIGrCoord PIGraphicX::CalcStringWidth(char const* s)647 {648 return(XTextWidth(mFSt, s, strlen(s)));649 }650 596 651 597 /* --Methode-- */ … … 655 601 sFCol = mFCol; sBCol = mBCol; 656 602 sGOm = mGOm; 657 sF Att = mFAtt; sFSize = mFSize;603 sFont = myFont; 658 604 sMrk = mMrk; sMrkSz = mMrkSz; 659 605 sFCfMap = mFCfMap; sBCfMap = mBCfMap; … … 669 615 else SelectBCol(sBCfMap); 670 616 SelGOMode(sGOm); 671 SelFont SzPt(sFSize, sFAtt);617 SelFont(sFont); 672 618 SelLine(sLAtt); 673 619 SelMarker(sMrkSz, sMrk); … … 684 630 685 631 686 static bool fggrcx = false ; 687 688 // Le bazar pour recuperer des resources de .Xdefault et autres 689 typedef struct 690 { 691 String fntFam; 692 } myAppData; 693 static myAppData apd; 694 695 static XtResource resources[] = { 696 { "fontFamilyName", "FontFamilyName", XtRString, sizeof(String), 697 /*XtOffset(apdp, fntFam)*/ 0, XtRString, "*-courier" } 698 }; 699 700 static char * fnbi_b[4] = { "medium-r-normal", "bold-r-normal", 701 "medium-o-normal", "medium-i-normal" }; 702 703 static XFontStruct * defnt = NULL; 704 static char * fnbi[3]; 632 static bool fggrcx = false ; // Flag init done 705 633 706 634 … … 708 636 void PIGraphicX::GlInit() 709 637 { 710 char buff[256];711 int i,j,count;712 char **list;713 714 638 if (fggrcx) return; 715 639 fggrcx = true; … … 723 647 scr = XDefaultScreen(mdsp); 724 648 725 XtGetApplicationResources(PIXtTopWdg(), &apd, resources,726 XtNumber(resources), NULL, 0);727 sprintf(buff,"-%s-*-*-*-*-*-*-*-*-*-*-*-*", apd.fntFam);728 list = XListFonts(mdsp, buff, 15, &count);729 XFreeFontNames(list);730 if (count < 5)731 {732 printf("PIGraphicX::Init %d fonts found for %s , switching to courier\n",733 count, apd.fntFam);734 apd.fntFam = "*-courier";735 }736 sprintf(buff,"-%s-%s-*-*-*-*-*-*-*-*-*", apd.fntFam, fnbi_b[0]);737 list = XListFonts(mdsp, buff, 10, &count);738 XFreeFontNames(list);739 if (count < 2) fnbi[0] = "*-*-*";740 else fnbi[0] = fnbi_b[0];741 sprintf(buff,"-%s-%s-*-*-*-*-*-*-*-*-*", apd.fntFam, fnbi_b[1]);742 list = XListFonts(mdsp, buff, 10, &count);743 XFreeFontNames(list);744 if (count < 2) fnbi[1] = "*-*-*";745 else fnbi[1] = fnbi_b[1];746 sprintf(buff,"-%s-%s-*-*-*-*-*-*-*-*-*", apd.fntFam, fnbi_b[2]);747 list = XListFonts(mdsp, buff, 10, &count);748 XFreeFontNames(list);749 fnbi[2] = fnbi_b[2];750 if (count < 2)751 {752 sprintf(buff,"-%s-%s-*-*-*-*-*-*-*-*-*", apd.fntFam, fnbi_b[3]);753 list = XListFonts(mdsp, buff, 10, &count);754 XFreeFontNames(list);755 fnbi[2] = fnbi_b[3];756 }757 if (count < 2) fnbi[2] = "*-*-*";758 759 sprintf(buff,"-*-fixed-*-*-*-*-14-*-*-*-*-*-*-*");760 list = XListFonts(mdsp, buff, 10, &count);761 XFreeFontNames(list);762 if (count < 1)763 {764 sprintf(buff,"fixed");765 list = XListFonts(mdsp, buff, 10, &count);766 XFreeFontNames(list);767 }768 if (count < 1)769 {770 strcpy(buff,"");771 list = XListFonts(mdsp, buff, 10, &count);772 XFreeFontNames(list);773 printf("PIGraphicX::Init/ Erreur, no font found ... \n");774 defnt = NULL;775 }776 else defnt = XLoadQueryFont(mdsp, buff);777 778 for (i=0; i<NMAXFONTSZ; i++)779 for (j=0; j<3; j++) fntst[i][j] = NULL;780 781 // Choix des trois tailles de fontes standard en fonction de782 // la taille de fonte par defaut des composantes standard783 int szx, szy, szf;784 PIXtAppCtx(szx, szy, szf);785 int kkk, kkj, kksel, kkdsz = 9999;786 kksel = NMAXFONTSZ/2;787 for(kkk=NMAXFONTSZ-1; kkk>=0; kkk--) {788 kkj = szf - fntsz[kkk]; if (kkj < 0) kkj = -kkj;789 if (kkj < kkdsz) { kksel = kkk; kkdsz = kkj; }790 }791 if (kksel == NMAXFONTSZ-1) kksel = NMAXFONTSZ-2;792 NormalFontIndex = kksel;793 SmallFontIndex = (kksel > 1) ? kksel-2 : 0 ;794 BigFontIndex = NMAXFONTSZ-2 ;795 if (BigFontIndex < NormalFontIndex) BigFontIndex = NormalFontIndex;796 HugeFontIndex = NMAXFONTSZ-1;797 798 //printf("PIGraphicX::Init()-DBG- FontIndex= %d %d %d (%d) \n",799 // SmallFontIndex, NormalFontIndex, BigFontIndex, szf);800 801 649 /* Les couleurs */ 802 650 cmap = XDefaultColormap (mdsp, scr); 803 651 804 for(i =0; i<NMAXCOL; i++) colpix[i] = XWhitePixel(mdsp, scr);652 for(int i=0; i<NMAXCOL; i++) colpix[i] = XWhitePixel(mdsp, scr); 805 653 colpix[PI_Black] = XBlackPixel(mdsp, scr); 806 654 colpix[PI_White] = XWhitePixel(mdsp, scr); … … 847 695 848 696 849 /* --Methode-- */ 850 void PIGraphicX::SelectFont(int isz, int jat) 851 { 852 853 if (!fntst[isz][jat]) // Il faut charger la fonte 854 { 855 char buff[256]; 856 int count,k; 857 Display * mdsp = PIXDisplay(); 858 char **list; 859 860 for (k=0; k<5; k++) // Recherche de la fonte pour tailles croissantes 861 { 862 sprintf(buff,"-%s-%s-*-%d-*-*-*-*-*-*-*", apd.fntFam, fnbi[jat], fntsz[isz]+k); 863 list = XListFonts(mdsp, buff, 10, &count); 864 XFreeFontNames(list); 865 if (count > 0) break; 866 } 867 if (count > 0) 868 fntst[isz][jat] = XLoadQueryFont(mdsp, buff); 869 else 870 { printf("PIGraphicX::SelectFont/ Pb font %s - Using default \n", buff); 871 fntst[isz][jat] = defnt; } 872 } 873 874 mFAtt = fntatt[jat]; 875 mFSize = fntsz[isz]; 876 mFSt = fntst[isz][jat]; 877 XSetFont(mDisp, DefGC(), fntst[isz][jat]->fid); 878 return; 879 } 880 881 697 698 -
trunk/SophyaPI/PI/pigraphx.h
r204 r316 47 47 virtual void SelBackground(PIColorMap& cmap, int cid); 48 48 virtual void SelGOMode(PIGOMode mod=PI_GOCopy); 49 virtual void SelLine(PILineAtt att=PI_NormalLine); 50 virtual void SelMarker(int msz=3, PIMarker mrk=PI_DotMarker); 51 52 // Modifications de fonte 53 virtual void SelFont(PIFont & fnt); 49 54 virtual void SelFont(PIFontSize sz=PI_NormalSizeFont, 50 55 PIFontAtt att=PI_RomanFont); 51 56 virtual void SelFontSzPt(int npt=12, PIFontAtt att=PI_RomanFont); 52 virtual void SelLine(PILineAtt att=PI_NormalLine);53 virtual void SelMarker(int msz=3, PIMarker mrk=PI_DotMarker);54 57 55 58 // Selection de zone de trace (clip) … … 66 69 virtual PIMarker GetMarker(); 67 70 virtual int GetMarkerSize(); 68 69 virtual int GetFontHeight(int& asc, int& desc);70 virtual PIGrCoord CalcStringWidth(char const* s);71 71 72 72 // Sauvegarde des attributs graphiques -
trunk/SophyaPI/PI/piimage.cc
r294 r316 673 673 void PIImage::Ptr2Move(int x, int y) 674 674 { 675 int xp, yp , tmp;675 int xp, yp; 676 676 if (img == NULL) return; 677 677 if (xmv0 < 0) return; … … 1102 1102 else { 1103 1103 int a,d,h; 1104 h = g->GetFont Height(a, d);1104 h = g->GetFont().GetFontHeight(a, d); 1105 1105 if (g->kind() != PI_PSFileGraphics ) PIPixmap::Draw(g, 0, YSize()-10-h, XSize(), h+10); 1106 1106 } -
trunk/SophyaPI/PI/piimgtools.cc
r292 r316 30 30 spy = bsy/4; 31 31 32 int wszx = 8*spx+3*bsx+2*bsy; 32 // int wszx = 8*spx+3*bsx+2*bsy; 33 int wszx = 8*spx+3.5*bsx; 33 34 int wszy = 9*spy+9*bsy; 34 35 SetSize(wszx, wszy); … … 46 47 cpy = spy*2; 47 48 cpx += spx+bsx; 48 mText[0] = new PIText(this, "MinVal", 1. 75*bsx, bsy, cpx, cpy);49 mText[0] = new PIText(this, "MinVal", 1.5*bsx, bsy, cpx, cpy); 49 50 mText[0]->SetText("1"); 50 51 cpy += spy+bsy; 51 mText[1] = new PIText(this, "MaxVal", 1. 75*bsx, bsy, cpx, cpy);52 mText[1] = new PIText(this, "MaxVal", 1.5*bsx, bsy, cpx, cpy); 52 53 mText[1]->SetText("32000"); 53 54 mText[0]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic); … … 58 59 mOlb[0]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic); 59 60 cpx += spx+bsx; 60 mOpt[0] = new PIOptMenu(this, "imglut-opt-1", 1. 75*bsx, bsy, cpx, cpy);61 mOpt[0] = new PIOptMenu(this, "imglut-opt-1", 1.5*bsx, bsy, cpx, cpy); 61 62 mOpt[0]->AppendItem("Linear", 1100); 62 63 mOpt[0]->AppendItem("Log.", 1101); … … 69 70 mOlb[1]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic); 70 71 cpx += spx+bsx; 71 mOpt[1] = new PIOptMenu(this, "imglut-opt-2", 1. 75*bsx, bsy, cpx, cpy);72 mOpt[1] = new PIOptMenu(this, "imglut-opt-2", 1.5*bsx, bsy, cpx, cpy); 72 73 mOpt[1]->AppendItem("+3 Sig", 1203); 73 74 mOpt[1]->AppendItem("+2 Sig", 1202); … … 81 82 82 83 cpy += 2*spy+bsy; 83 cpx = bsx/2;84 cpx = 3*spx; 84 85 mBut[0] = new PIButton(this, "Apply", 2500, bsx*1.75, bsy, cpx, cpy); 85 cpx += bsx* 2;86 cpx += bsx*1.75+2*spx; 86 87 mBut[1] = new PIButton(this, "Dismiss", 2600, bsx*1.75, bsy, cpx, cpy); 87 88 mBut[0]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic); … … 91 92 // printf("-DBG- PIImgTools() SzX,Y= %d %d , ButPos= %d %d (off=%d)\n", wszx, wszy, cpx, cpy, offy); 92 93 93 cpx = 4*spx+2.75*bsx; 94 // cpx = 4*spx+2.75*bsx; 95 cpx = wszx-bsx-3*spx; 94 96 cpy = 2*spy; 95 mSc[0] = new PIScale(this, "sc-offset-lut", 2700, kSDirDownUp, 1.25*bsy, 4.5*bsy, cpx, cpy);96 cpx += 1.50*bsy;97 mSc[1] = new PIScale(this, "sc-dyn-lut", 2800, kSDirDownUp, 1.25*bsy, 4.5*bsy, cpx, cpy);97 mSc[0] = new PIScale(this, "sc-offset-lut", 2700, kSDirDownUp, 0.5*bsx, 4.5*bsy, cpx, cpy); 98 cpx += 0.50*bsx+spx; 99 mSc[1] = new PIScale(this, "sc-dyn-lut", 2800, kSDirDownUp, 0.55*bsx, 4.5*bsy, cpx, cpy); 98 100 mSc[0]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic); 99 101 mSc[0]->SetMinMax(-50, 50); … … 104 106 105 107 // Option-Menu Couleur/Zoom 106 cpx = bsx/2;108 cpx = 3*spx; 107 109 cpy = offy; 108 110 mOptzc[0] = new PIOptMenu(this, "imglut-opt-3", bsx*1.75, bsy, cpx, cpy); … … 120 122 mOptzc[0]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic); 121 123 122 cpx += bsx* 2;124 cpx += bsx*1.75+2*spx; 123 125 mOptzc[1] = new PIOptMenu(this, "imglut-opt-4", bsx*1.75, bsy, cpx, cpy); 124 126 mOptzc[1]->AppendItem("Agr. x10", 110); … … 145 147 int pspy = spy; 146 148 147 cpx = 2* pspx;149 cpx = 2*spx; 148 150 cpy += pbsy+2*spy; 149 151 mButsz[0] = new PIButton(this, "1x1", 3201, pbsx, pbsy, cpx, cpy); … … 162 164 mButsz[4]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic); 163 165 164 cpx += pbsx+10*pspx; 166 //cpx += pbsx+10*pspx; 167 cpx = wszx-3.0*pbsx-2*spx-pspx; 165 168 mButoa[0] = new PIButton(this, "+Info", 5311, 1.5*pbsx, pbsy, cpx, cpy); 166 169 mButoa[0]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic); … … 170 173 171 174 172 cpx = 2* pspx;175 cpx = 2*spx; 173 176 cpy += pbsy+pspy; 174 177 mButcax[0] = new PIButton(this, "-X", 5201, pbsx, pbsy, cpx, cpy); … … 181 184 mButcax[2]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic); 182 185 183 cpx += 1.5*pbsx+pspx+10*pspx; 186 // cpx += 1.5*pbsx+pspx+10*pspx; 187 cpx = wszx-4.5*pbsx-2*spx-2*pspx; 184 188 mButoa[2] = new PIButton(this, "-All", 5300, 1.5*pbsx, pbsy, cpx, cpy); 185 189 mButoa[2]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic); -
trunk/SophyaPI/PI/pisysdep.h
r113 r316 15 15 16 16 #define PIAPP_H "piapplmac.h" 17 #define PIPERIODIC_H "piperiodmac.h" 17 18 18 #define PI BWDG_H "pibwdgmac.h"19 #define PIFONT_H "pifontmac.h" 19 20 #define PIGRAPHIC_H "pigraphmac.h" 20 21 21 #define PICMAPNTV_H "picmapmac.h" 22 22 #define PICMAP_H "picmap.h" 23 24 #define PIBWDG_H "pibwdgmac.h" 23 25 #define PIPIXMAP_H "pipixmapmac.h" 24 25 26 26 27 #else // XWindow … … 36 37 37 38 #define PIAPP_H "piapplx.h" 39 #define PIPERIODIC_H "piperiodx.h" 40 41 #define PIFONT_H "pifontx.h" 42 #define PIGRAPHIC_H "pigraphx.h" 43 #define PICMAPNTV_H "picmapx.h" 44 #define PICMAP_H "picmap.h" 38 45 39 46 #define PIBWDG_H "pibwdgx.h" 40 #define PIGRAPHIC_H "pigraphx.h"41 42 #define PICMAPNTV_H "picmapx.h"43 #define PICMAP_H "picmap.h"44 47 #define PIPIXMAP_H "pipixmapx.h" 45 46 #define PIPERIODIC_H "piperiodx.h"47 48 48 49 #endif -
trunk/SophyaPI/PI/piwdgx.cc
r292 r316 555 555 556 556 // Ressources X si non definis 557 static const String fallback_res[2 2] = {557 static const String fallback_res[24] = { 558 558 "PeidaInt*default*background: LightGrey" , 559 559 "PeidaInt*background: LightGrey" , … … 576 576 // "PeidaInt*DefMenubar*XtNheight: 30", 577 577 "PeidaInt*fontList: -*-courier-bold-r-normal-*-12-*-*-*-*-*-ISO8859-1", 578 "PeidaInt*default*fontList: -*-courier-bold-r-normal-*-12-*-*-*-*-*-ISO8859-1" 578 "PeidaInt*default*fontList: -*-courier-bold-r-normal-*-12-*-*-*-*-*-ISO8859-1", 579 579 "PeidaInt*fontFamilyName: *-courier", // Pas de blanc apres le nom de font 580 "PeidaInt*courierfontFamilyName: *-courier", // " " 581 "PeidaInt*symbolfontFamilyName: *-symbol", // " " 580 582 "PeidaInt*XmToggleButton*selectColor: Red", 581 "" 583 NULL 582 584 }; 583 585 … … 595 597 // strncpy(appname, ppc[0], 63); appname[63] = '\0'; 596 598 strncpy(appclass,"PeidaInt",63); appclass[63] = '\0'; 597 // top = XtAppInitialize(&appctx, appclass, NULL, 0, &n, ppc); 598 top = XtVaAppInitialize(&appctx, appclass, NULL, 0, &n, ppc, const_cast<String*>(fallback_res), NULL); 599 //----- XtAppInitialize obsolete (X11/R6 , remplace par XtOpenApplication - Reza 14/06/99 ----- 600 // top = XtAppInitialize(&appctx, appclass, NULL, 0, &n, ppc, 601 // const_cast<String*>(fallback_res), NULL, 0 ); 602 //BUG ? - DEL top = XtVaAppInitialize(&appctx, appclass, NULL, 0, &n, ppc, const_cast<String*>(fallback_res)); 603 top = XtOpenApplication(&appctx, appclass, NULL, 0, &n, ppc, const_cast<String*>(fallback_res), 604 applicationShellWidgetClass, NULL, 0); 599 605 if (top == NULL) { 600 606 fprintf(stderr, "PIWdgX::InitXt()/ Error XtVaAppInitialize() -> Exit \n"); … … 627 633 strcpy(buff, fntname); 628 634 list = XListFonts(dpy, buff, 15, &count); 629 XFreeFontNames(list); 630 if (count < 1) strcpy(buff,"-*-*-*-*-*-*-*-*-*-*-*-*-*-*" ); 635 if (count < 1) { 636 strcpy(buff,"-*-*-*-*-*-*-*-*-*-*-*-*-*-*" ); 637 XFreeFontNames(list); 638 list = XListFonts(dpy, buff, 15, &count); 639 } 631 640 stdfnt = XLoadQueryFont(dpy, buff); 632 641 char * myfntname = "???"; 642 // Recherche du champ taille en pixel de la fonte : apres le 7eme tiret 643 int mySzFont = 12; 644 if (count > 0) { 645 myfntname = list[0]; 646 int kt = 0; 647 int kdx = 0; 648 char * pcf = list[0]; 649 // printf("DBG-X1 : %s \n ", pcf); 650 while (kt < 7) { 651 if (pcf[kdx] == '-') kt++; 652 if (pcf[kdx] == '\0') break; 653 kdx++; 654 } 655 // printf("DBG-X2 : %s \n ", pcf+kdx); 656 int iii = 0; 657 while ( (pcf[kdx+iii] != '-') && (pcf[kdx+iii] != '\0') ) 658 { buff[iii] = pcf[kdx+iii]; iii++; } 659 buff[iii] = '\0'; 660 mySzFont = atoi(buff); 661 // printf("*DBG*X3* %s -> %d \n", buff, mySzFont); 662 } 633 663 // On calcule la taille de la chaine CANCEL (6 caracteres) 634 664 char a[2]; … … 637 667 XTextExtents(stdfnt, a, 0, &hd, &fa, &fd, &ovr); 638 668 len = XTextWidth(stdfnt, "CANCEL", 6); 639 appSzY = (float)(fa+fd)*1. 4+10; // pour les shadow669 appSzY = (float)(fa+fd)*1.5+8; // pour les shadow $CHECK$ - a ameliorer peut-etre 640 670 appSzX = (float)len*1.5; 641 appSzFont = fa+fd;642 // Taille multiple de 5pixels671 appSzFont = mySzFont ; 672 // Taille X multiple de 5 pixels, Y mult 2 pixels 643 673 if ( (appSzX % 5) != 0 ) appSzX = 5*(appSzX/5 + 1); 644 if ( (appSzY % 5) != 0 ) appSzY = 5*(appSzY/5+ 1);674 if ( (appSzY % 2) != 0 ) appSzY = 2*(appSzY/2 + 1); 645 675 if(appSzY < 10) appSzY = 10; 646 676 if(appSzX < 30) appSzX = 30; 647 677 648 // printf("PIWdgX::InitXt(Font=%s- %d %d , %d ) SzX,Y= %d %d \n", buff, fa,fd,len,appSzX, appSzY); 678 // printf("PIWdgX::InitXt(Font=%s- %d %d , %d ) SzX,Y= %d %d - FSz= %d \n", myfntname, fa,fd,len,appSzX, appSzY, appSzFont); 679 XFreeFontNames(list); 649 680 return(0); 650 681 }
Note:
See TracChangeset
for help on using the changeset viewer.