Changeset 316 in Sophya for trunk/SophyaPI


Ignore:
Timestamp:
Jun 15, 1999, 3:56:51 PM (26 years ago)
Author:
ercodmgr
Message:

Introduction PIFont - Reza 15/06/99

Location:
trunk/SophyaPI/PI
Files:
14 edited

Legend:

Unmodified
Added
Removed
  • trunk/SophyaPI/PI/pibwdgx.cc

    r292 r316  
    149149printf("PIBaseWdgX::ActivateMove %d \n \n", bid);
    150150#endif
    151 unsigned long evtmask ;
     151unsigned long evtmask = 0;
    152152
    153153// bid == 0  -> PointerMove sans bouton
  • trunk/SophyaPI/PI/picmapview.cc

    r130 r316  
    117117    sprintf(buff, "%.2f", vmax);
    118118    int fa, fd;
    119     g->DrawString(4, g->GetFontHeight(fa,fd)+4, buff);
     119    g->DrawString(4, g->GetFont().GetFontHeight(fa,fd)+4, buff);
    120120    }
    121121   
  • trunk/SophyaPI/PI/pigraphgen.cc

    r292 r316  
    2424// Links        Voir aussi
    2525// PIGrCoord
     26// PIFont
    2627// PIColorMap
    2728//--
     
    191192// void  SelGOMode(PIGOMode mod=PI_GOCopy)
    192193//      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 texte
    195 //|     PI_SmallSizeFont , PI_NormalSizeFont , PI_BigSizeFont, PI_HugeSizeFont
    196 //|     PI_RomanFont , PI_BoldFont , PI_ItalicFont
    197 // 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)
    199194// void  SelLine(PILineAtt att=PI_NormalLine)
    200195//      Choix du type de ligne pour le tracé des lignes et contours
     
    208203//|     PI_TriangleMarker , PI_FTriangleMarker , PI_StarMarker , PI_FStarMarker
    209204//      (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//
    210221//--
    211222
     
    241252// int GetMarkerSize()
    242253//      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);
    244257//      Renvoie la hauteur des caractères, ainsi que la taille au dessus
    245258//      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).
    246260// PIGrCoord CalcStringWidth(char const* s)
    247261//      Renvoie la largeur occupé par un texte s'il était affiché dans le
    248262//      système de coordonnées courant (Fenêtre ou UC).
    249263//--
     264
     265/* --Methode-- */
     266PIGrCoord PIGraphicGen::GetFontHeight(PIGrCoord& asc, PIGrCoord& desc)
     267{
     268int t,a,d;
     269t = myFont.GetFontHeight(a, d);
     270asc = a;   desc = d;
     271return(t);
     272}
     273
     274/* --Methode-- */
     275PIGrCoord PIGraphicGen::CalcStringWidth(char const* s)
     276{
     277return (myFont.GetStringWidth(s));
     278}
    250279
    251280//++
     
    267296  sBCol = GetBackground();
    268297  sGOm = GetGOMode();
    269   sFAtt = GetFontAtt();   
    270   sFSize = GetFontSize();
     298  sFont = GetFont();   
    271299  sLAtt = GetLineAtt();
    272300  sMrk = GetMarker();   
     
    281309  SelBackground(sBCol);
    282310  SelGOMode(sGOm);
    283   SelFontSzPt(sFSize, sFAtt);
     311  SelFont(sFont);
    284312  SelLine(sLAtt);
    285313  SelMarker(sMrkSz, sMrk);
  • trunk/SophyaPI/PI/pigraphgen.h

    r292 r316  
    1111#include PIWDG_H
    1212#include PICMAP_H
     13#include PIFONT_H
    1314
    1415
     
    2223                 PI_ColorAllBits0 = 16, PI_ColorAllBits1 = 17 };
    2324
    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 };
    3025
    3126enum PILineAtt { PI_NotDefLineAtt = -1,
     
    112107  virtual void       SelBackground(PIColorMap& cmap, int cid)                  = 0;
    113108  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;
    117109  virtual void       SelLine(PILineAtt att=PI_NormalLine)                      = 0;
    118110  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;
    119116
    120117// Selection de zone de trace (clip)
     
    126123  virtual PIColors   GetBackground()    = 0;
    127124  virtual PIGOMode   GetGOMode()        = 0;
    128   virtual PIFontAtt  GetFontAtt()       = 0;
    129   virtual int        GetFontSize()      = 0;
    130125  virtual PILineAtt  GetLineAtt()       = 0;
    131126  virtual PIMarker   GetMarker()        = 0;
    132127  virtual int        GetMarkerSize()    = 0;
    133128
    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);
    136133
    137134// Sauvegarde des attributs graphiques
     
    144141  PIScreenBuffer* myGrb;
    145142
     143  PIFont myFont;
    146144  PIColors  sFCol, sBCol;
    147145  PIGOMode sGOm;
    148   PIFontAtt sFAtt;
     146  PIFont sFont;
    149147  PILineAtt sLAtt;
    150148  int sFSize;
     
    152150  int sMrkSz;
    153151};
    154 
    155 #endif
    156152
    157153typedef PIGraphicGen PIGraphic;
     
    162158//     PIGraphicPS
    163159//     PIGraphicUC
     160
     161#endif      // PIGRAPHGEN_H_SEEN
  • trunk/SophyaPI/PI/pigraphps.cc

    r204 r316  
    327327return;
    328328}
     329/* --Methode-- */
     330void PIGraphicPS::SelFont(PIFont & fnt)
     331{
     332//  $CHECK$   -  Reza 13/06/99
     333SelFontSzPt(fnt.GetFontSize(), fnt.GetFontAtt());
     334}
    329335
    330336/* --Methode-- */
    331337void PIGraphicPS::SelFontSzPt(int npt, PIFontAtt att)
    332338{
     339//  $CHECK$   -  Reza 13/06/99
     340myFont.SetFontSzPt(npt);
     341myFont.SetFontAtt(att);
    333342mFSize = npt;
    334343mFAtt = att;
     
    341350void PIGraphicPS::SelFont(PIFontSize sz, PIFontAtt att)
    342351{
     352//  $CHECK$   -  Reza 13/06/99
    343353int i;
    344354switch (sz) {
     
    356366    break;
    357367  }
     368myFont.SetFontSz(sz);
     369myFont.SetFontAtt(att);
    358370mFSize = fntsz[i];
    359371mFAtt = att;
     
    413425}
    414426
    415 /* --Methode-- */
    416 PIFontAtt  PIGraphicPS::GetFontAtt()
    417 {
    418 return (mFAtt);
    419 }
    420 
    421 /* --Methode-- */
    422 int        PIGraphicPS::GetFontSize()
    423 {
    424 return (mFSize);
    425 }
    426427
    427428/* --Methode-- */
     
    443444}
    444445
    445 /* --Methode-- */
     446/* --Methode--
    446447int        PIGraphicPS::GetFontHeight(int& asc, int& desc)   
    447448{
    448 /*  $CHECK$  A refaire , voir Nicolas  */
     449  $CHECK$  A refaire , voir Nicolas 
    449450asc = mFSize; desc = 0;
    450451return(asc+desc);
    451 }
    452 
    453 
    454 /* --Methode-- */
     452}
     453*/
     454
     455
     456/* --Methode--
    455457PIGrCoord PIGraphicPS::CalcStringWidth(char const* s)
    456458{
    457 return((double)(mFSize*strlen(s)*0.5));   /*  facteur 0.5 ad'hoc $CHECK$  Voir Nicolas ! */
    458 }
     459return((double)(mFSize*strlen(s)*0.5));   
     460//  facteur 0.5 ad hoc $CHECK$  Voir Nicolas
     461}
     462*/
     463 
    459464
    460465/* --Methode-- */
     
    464469sFCol = mFCol;    sBCol = mBCol;
    465470sGOm = mGOm;
    466 sFAtt = mFAtt;   sFSize = mFSize;
     471sFont = myFont;
    467472sMrk = mMrk;   sMrkSz = mMrkSz;
    468473return;
     
    478483// else    A faire Nicolas 
    479484  SelGOMode(sGOm);
    480   SelFontSzPt(sFSize, sFAtt);
     485  SelFont(sFont);
    481486  SelLine(sLAtt);
    482487  SelMarker(sMrkSz, sMrk);
  • trunk/SophyaPI/PI/pigraphps.h

    r204 r316  
    4646  virtual void       SelBackground(PIColorMap& cmap, int cid);
    4747  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);
    4852  virtual void       SelFont(PIFontSize sz=PI_NormalSizeFont,
    4953                             PIFontAtt att=PI_RomanFont);
    5054  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);
    5355
    5456// Selection de zone de trace (clip)
     
    6062  virtual PIColors   GetBackground();
    6163  virtual PIGOMode   GetGOMode();
    62   virtual PIFontAtt  GetFontAtt();
    63   virtual int        GetFontSize();
    6464  virtual PILineAtt  GetLineAtt();
    6565  virtual PIMarker   GetMarker();
    6666  virtual int        GetMarkerSize();
    6767
    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);
    7070
    7171// Sauvegarde des attributs graphiques
  • trunk/SophyaPI/PI/pigraphuc.cc

    r204 r316  
    583583
    584584/* --Methode-- */
     585void PIGraphicUC::SelFont(PIFont & fnt)
     586{
     587  if (!mGrC) return;
     588  mGrC->SelFont(fnt);
     589  return; 
     590}
     591
     592/* --Methode-- */
    585593void PIGraphicUC::SelFont(PIFontSize sz, PIFontAtt att)
    586594{
     
    671679}
    672680
    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 }
    686681
    687682/* --Methode-- */
     
    706701}
    707702/* --Methode-- */
    708 PIGrCoord PIGraphicUC::GetFontHeightUC(PIGrCoord& asc, PIGrCoord& desc)
     703PIGrCoord PIGraphicUC::GetFontHeight(PIGrCoord& asc, PIGrCoord& desc)
    709704{
    710705  asc = desc = 0;
     
    712707  int h,a,d;
    713708  double fh, fa, fd, x;
    714   h = mGrC->GetFontHeight(a, d) ;
     709  h = myFont.GetFontHeight(a, d) ;
    715710  DGrC2UC(0., h, x, fh);
    716711  DGrC2UC(0., a, x, fa);
     
    720715}
    721716
    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 }
    729717
    730718/* --Methode-- */
     
    732720{
    733721  if (!mGrC) return(0.);
    734   double dx = mGrC->CalcStringWidth(s);
     722  double dx = myFont.GetStringWidth(s);
    735723  double dxx, dxy;
    736724  DGrC2UC(dx, dx, dxx, dxy);
  • trunk/SophyaPI/PI/pigraphuc.h

    r204 r316  
    6464  virtual void       SelBackground(PIColorMap& cmap, int cid);
    6565  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);
    6671  virtual void       SelFont(PIFontSize sz=PI_NormalSizeFont,
    6772                             PIFontAtt att=PI_RomanFont);
    6873  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 
    7274//  Fonctions specifiques a PIGraphicUC :
    7375  virtual void       SelFontSz(PIGrCoord sz, PIFontAtt att=PI_RomanFont);
    7476  virtual void       SelMarkerSz(PIGrCoord msz, PIMarker mrk=PI_DotMarker);
    75   virtual PIGrCoord  GetFontHeightUC(PIGrCoord& asc, PIGrCoord& desc);
    7677
    7778// Selection de zone de trace (clip)
     
    8384  virtual PIColors   GetBackground();
    8485  virtual PIGOMode   GetGOMode();
    85   virtual PIFontAtt  GetFontAtt();
    86   virtual int        GetFontSize();
    8786  virtual PILineAtt  GetLineAtt();
    8887  virtual PIMarker   GetMarker();
    8988  virtual int        GetMarkerSize();
    9089
    91   virtual int        GetFontHeight(int& asc, int& desc);
     90  virtual PIGrCoord  GetFontHeight(PIGrCoord& asc, PIGrCoord& desc);
    9291  virtual PIGrCoord  CalcStringWidth(char const* s);
     92
    9393
    9494// Sauvegarde des attributs graphiques
  • trunk/SophyaPI/PI/pigraphx.cc

    r292 r316  
    1212
    1313/*  Variables globales pour modifier les GC  */
    14 #define NMAXFONTSZ  7
    15 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 };
    2214#define NMAXCOL  18
    2315static  PIXColor colpix[NMAXCOL];
     
    7466SelBackground(PI_White);
    7567mLAtt = PI_ThinLine;
     68 XSetFont(mDisp, DefGC(), myFont.GetXFontId());  // Pour initialiser la fonte ds le GC
    7669SelLine();
    77 mFAtt = PI_BoldFont;  mFSize = 0;
    78 SelFont();
    7970SelMarker(1, PI_DotMarker); 
    8071mFCfMap = colpix[PI_Black];  mBCfMap = colpix[PI_White];
     
    430421
    431422/* --Methode-- */
     423void PIGraphicX::SelFont(PIFont & fnt)
     424{
     425if (myFont == fnt)  return;
     426myFont = fnt;
     427XSetFont(mDisp, DefGC(), myFont.GetXFontId());
     428}
     429
     430/* --Methode-- */
     431void PIGraphicX::SelFont(PIFontSize sz, PIFontAtt att)
     432{
     433PIFont fnt(myFont.GetFontName());
     434fnt.SetFontAtt(att);
     435fnt.SetFontSz(sz);
     436SelFont(fnt);
     437}
     438
     439/* --Methode-- */
    432440void PIGraphicX::SelFontSzPt(int npt, PIFontAtt att)
    433441{
    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);
     442PIFont fnt(npt, myFont.GetFontName(), att);
     443SelFont(fnt);
    482444}
    483445
     
    632594}
    633595
    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 }
    650596
    651597/* --Methode-- */
     
    655601sFCol = mFCol;    sBCol = mBCol;
    656602sGOm = mGOm;
    657 sFAtt = mFAtt;   sFSize = mFSize;
     603sFont = myFont;   
    658604sMrk = mMrk;   sMrkSz = mMrkSz;
    659605sFCfMap = mFCfMap; sBCfMap = mBCfMap;
     
    669615  else SelectBCol(sBCfMap);
    670616  SelGOMode(sGOm);
    671   SelFontSzPt(sFSize, sFAtt);
     617  SelFont(sFont);
    672618  SelLine(sLAtt);
    673619  SelMarker(sMrkSz, sMrk);
     
    684630
    685631
    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];
     632static bool fggrcx = false ;  // Flag init done
    705633
    706634
     
    708636void PIGraphicX::GlInit()
    709637{
    710 char buff[256];
    711 int i,j,count;
    712 char **list;
    713 
    714638if (fggrcx)  return;
    715639fggrcx = true;
     
    723647scr = XDefaultScreen(mdsp);
    724648
    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 de
    782 // la taille de fonte par defaut des composantes standard
    783 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 
    801649/*  Les couleurs  */
    802650cmap = XDefaultColormap (mdsp, scr);
    803651
    804 for(i=0; i<NMAXCOL; i++)  colpix[i] = XWhitePixel(mdsp, scr);
     652for(int i=0; i<NMAXCOL; i++)  colpix[i] = XWhitePixel(mdsp, scr);
    805653colpix[PI_Black] = XBlackPixel(mdsp, scr);
    806654colpix[PI_White] = XWhitePixel(mdsp, scr);
     
    847695
    848696
    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  
    4747  virtual void       SelBackground(PIColorMap& cmap, int cid);
    4848  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);
    4954  virtual void       SelFont(PIFontSize sz=PI_NormalSizeFont,
    5055                             PIFontAtt att=PI_RomanFont);
    5156  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);
    5457
    5558// Selection de zone de trace (clip)
     
    6669  virtual PIMarker   GetMarker();
    6770  virtual int        GetMarkerSize();
    68 
    69   virtual int        GetFontHeight(int& asc, int& desc);
    70   virtual PIGrCoord  CalcStringWidth(char const* s);
    7171
    7272// Sauvegarde des attributs graphiques
  • trunk/SophyaPI/PI/piimage.cc

    r294 r316  
    673673void PIImage::Ptr2Move(int x, int y)
    674674{
    675 int xp, yp, tmp;
     675int xp, yp;
    676676if (img == NULL)  return;
    677677if (xmv0 < 0)  return;
     
    11021102else {
    11031103  int a,d,h;
    1104   h = g->GetFontHeight(a, d);
     1104  h = g->GetFont().GetFontHeight(a, d);
    11051105  if (g->kind() != PI_PSFileGraphics )   PIPixmap::Draw(g, 0, YSize()-10-h, XSize(), h+10);
    11061106  }
  • trunk/SophyaPI/PI/piimgtools.cc

    r292 r316  
    3030spy = bsy/4;
    3131
    32 int wszx = 8*spx+3*bsx+2*bsy;
     32// int wszx = 8*spx+3*bsx+2*bsy;
     33int wszx = 8*spx+3.5*bsx;
    3334int wszy = 9*spy+9*bsy;
    3435SetSize(wszx, wszy);
     
    4647cpy = spy*2;
    4748cpx += spx+bsx;
    48 mText[0] = new PIText(this, "MinVal", 1.75*bsx, bsy, cpx, cpy);
     49mText[0] = new PIText(this, "MinVal", 1.5*bsx, bsy, cpx, cpy);
    4950mText[0]->SetText("1");
    5051cpy += spy+bsy;
    51 mText[1] = new PIText(this, "MaxVal", 1.75*bsx, bsy, cpx, cpy);
     52mText[1] = new PIText(this, "MaxVal", 1.5*bsx, bsy, cpx, cpy);
    5253mText[1]->SetText("32000");
    5354mText[0]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic);
     
    5859mOlb[0]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic);
    5960cpx += spx+bsx;
    60 mOpt[0] = new PIOptMenu(this, "imglut-opt-1", 1.75*bsx, bsy, cpx, cpy);
     61mOpt[0] = new PIOptMenu(this, "imglut-opt-1", 1.5*bsx, bsy, cpx, cpy);
    6162mOpt[0]->AppendItem("Linear", 1100);
    6263mOpt[0]->AppendItem("Log.", 1101);
     
    6970mOlb[1]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic);
    7071cpx += spx+bsx;
    71 mOpt[1] = new PIOptMenu(this, "imglut-opt-2", 1.75*bsx, bsy, cpx, cpy);
     72mOpt[1] = new PIOptMenu(this, "imglut-opt-2", 1.5*bsx, bsy, cpx, cpy);
    7273mOpt[1]->AppendItem("+3 Sig", 1203);
    7374mOpt[1]->AppendItem("+2 Sig", 1202);
     
    8182
    8283cpy += 2*spy+bsy;
    83 cpx = bsx/2;
     84cpx = 3*spx;
    8485mBut[0] = new PIButton(this, "Apply", 2500, bsx*1.75, bsy, cpx, cpy);
    85 cpx += bsx*2;
     86cpx += bsx*1.75+2*spx;
    8687mBut[1] = new PIButton(this, "Dismiss", 2600,  bsx*1.75, bsy, cpx, cpy);
    8788mBut[0]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic);
     
    9192// printf("-DBG- PIImgTools()  SzX,Y= %d %d , ButPos= %d %d (off=%d)\n", wszx, wszy, cpx, cpy, offy);
    9293
    93 cpx = 4*spx+2.75*bsx;
     94// cpx = 4*spx+2.75*bsx;
     95cpx = wszx-bsx-3*spx;
    9496cpy = 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);
     97mSc[0] = new PIScale(this, "sc-offset-lut", 2700, kSDirDownUp, 0.5*bsx, 4.5*bsy, cpx, cpy);
     98cpx += 0.50*bsx+spx;
     99mSc[1] = new PIScale(this, "sc-dyn-lut", 2800, kSDirDownUp, 0.55*bsx, 4.5*bsy, cpx, cpy);
    98100mSc[0]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic);
    99101mSc[0]->SetMinMax(-50, 50);
     
    104106
    105107//  Option-Menu  Couleur/Zoom
    106 cpx = bsx/2;
     108cpx = 3*spx;
    107109cpy = offy;
    108110mOptzc[0] = new PIOptMenu(this, "imglut-opt-3", bsx*1.75, bsy, cpx, cpy);
     
    120122mOptzc[0]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic);
    121123
    122 cpx += bsx*2;
     124cpx += bsx*1.75+2*spx;
    123125mOptzc[1] = new PIOptMenu(this, "imglut-opt-4", bsx*1.75, bsy, cpx, cpy);
    124126mOptzc[1]->AppendItem("Agr. x10", 110);
     
    145147int pspy = spy;
    146148
    147 cpx = 2*pspx;
     149cpx = 2*spx;
    148150cpy += pbsy+2*spy;
    149151mButsz[0] = new PIButton(this, "1x1", 3201,  pbsx, pbsy, cpx, cpy);
     
    162164mButsz[4]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic);
    163165
    164 cpx += pbsx+10*pspx;
     166//cpx += pbsx+10*pspx;
     167cpx = wszx-3.0*pbsx-2*spx-pspx;
    165168mButoa[0] = new PIButton(this, "+Info", 5311,  1.5*pbsx, pbsy, cpx, cpy);
    166169mButoa[0]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic);
     
    170173
    171174
    172 cpx = 2*pspx;
     175cpx = 2*spx;
    173176cpy += pbsy+pspy;
    174177mButcax[0] = new PIButton(this, "-X", 5201,  pbsx, pbsy, cpx, cpy);
     
    181184mButcax[2]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic);
    182185
    183 cpx += 1.5*pbsx+pspx+10*pspx;
     186// cpx += 1.5*pbsx+pspx+10*pspx;
     187cpx = wszx-4.5*pbsx-2*spx-2*pspx;
    184188mButoa[2] = new PIButton(this, "-All", 5300,  1.5*pbsx, pbsy, cpx, cpy);
    185189mButoa[2]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic);
  • trunk/SophyaPI/PI/pisysdep.h

    r113 r316  
    1515
    1616  #define PIAPP_H "piapplmac.h"
     17  #define PIPERIODIC_H "piperiodmac.h"
    1718 
    18   #define PIBWDG_H "pibwdgmac.h"
     19  #define PIFONT_H "pifontmac.h"
    1920  #define PIGRAPHIC_H "pigraphmac.h"
    20 
    2121  #define PICMAPNTV_H "picmapmac.h"
    2222  #define PICMAP_H "picmap.h"
     23
     24  #define PIBWDG_H "pibwdgmac.h"
    2325  #define PIPIXMAP_H "pipixmapmac.h"
    24 
    2526
    2627#else                  // XWindow
     
    3637
    3738  #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"
    3845
    3946  #define PIBWDG_H "pibwdgx.h"
    40   #define PIGRAPHIC_H "pigraphx.h"
    41 
    42   #define PICMAPNTV_H "picmapx.h"
    43   #define PICMAP_H "picmap.h"
    4447  #define PIPIXMAP_H "pipixmapx.h"
    45 
    46   #define PIPERIODIC_H "piperiodx.h"
    4748
    4849#endif
  • trunk/SophyaPI/PI/piwdgx.cc

    r292 r316  
    555555
    556556// Ressources X si non definis
    557 static const String fallback_res[22] = {
     557static const String fallback_res[24] = {
    558558"PeidaInt*default*background:                 LightGrey" ,
    559559"PeidaInt*background:                         LightGrey" ,
     
    576576// "PeidaInt*DefMenubar*XtNheight:               30",
    577577"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",
    579579"PeidaInt*fontFamilyName:                     *-courier",   // Pas de blanc apres le nom de font
     580"PeidaInt*courierfontFamilyName:              *-courier",   //           "        "
     581"PeidaInt*symbolfontFamilyName:               *-symbol",    //           "        "
    580582"PeidaInt*XmToggleButton*selectColor:         Red",
    581 ""
     583NULL
    582584};
    583585
     
    595597//  strncpy(appname, ppc[0], 63); appname[63] = '\0';
    596598strncpy(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));
     603top = XtOpenApplication(&appctx, appclass, NULL, 0, &n, ppc, const_cast<String*>(fallback_res),
     604                          applicationShellWidgetClass, NULL, 0);
    599605if (top == NULL) {
    600606  fprintf(stderr, "PIWdgX::InitXt()/ Error XtVaAppInitialize() -> Exit \n");
     
    627633strcpy(buff, fntname);
    628634list = XListFonts(dpy, buff, 15, &count);
    629 XFreeFontNames(list);
    630 if (count < 1)  strcpy(buff,"-*-*-*-*-*-*-*-*-*-*-*-*-*-*" );
     635if (count < 1)  {
     636  strcpy(buff,"-*-*-*-*-*-*-*-*-*-*-*-*-*-*" );
     637  XFreeFontNames(list);
     638  list = XListFonts(dpy, buff, 15, &count);
     639  }
    631640stdfnt = XLoadQueryFont(dpy, buff);
    632 
     641char * myfntname = "???";
     642// Recherche du champ taille en pixel de la fonte : apres le 7eme tiret
     643int mySzFont = 12;
     644if (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}
    633663// On calcule la taille de la chaine CANCEL (6 caracteres)
    634664char a[2];
     
    637667XTextExtents(stdfnt, a, 0, &hd, &fa, &fd, &ovr);
    638668len = XTextWidth(stdfnt, "CANCEL", 6);
    639 appSzY = (float)(fa+fd)*1.4+10;  // pour les shadow
     669appSzY = (float)(fa+fd)*1.5+8;  // pour les shadow  $CHECK$ - a ameliorer peut-etre
    640670appSzX = (float)len*1.5;
    641 appSzFont = fa+fd;
    642 // Taille multiple de 5 pixels
     671appSzFont =  mySzFont ;
     672// Taille X multiple de 5 pixels, Y mult 2 pixels
    643673if ( (appSzX % 5) != 0 )   appSzX = 5*(appSzX/5 + 1);
    644 if ( (appSzY % 5) != 0 )   appSzY = 5*(appSzY/5 + 1);
     674if ( (appSzY % 2) != 0 )   appSzY = 2*(appSzY/2 + 1);
    645675if(appSzY < 10) appSzY = 10;
    646676if(appSzX < 30) appSzX = 30;
    647677
    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);
     679XFreeFontNames(list);
    649680return(0);
    650681}
Note: See TracChangeset for help on using the changeset viewer.