Changeset 1896 in Sophya for trunk/SophyaPI/PI/Tests/pist.cc


Ignore:
Timestamp:
Feb 7, 2002, 7:22:56 PM (24 years ago)
Author:
ansari
Message:

Implementation de DrawCompString() et test ds pist.cc - Reza 07/02/2002

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/SophyaPI/PI/Tests/pist.cc

    r1854 r1896  
    4848                         int sx=10, int sy=10, int px=0, int py=0);
    4949  virtual         ~StringPosDrawWdg();
     50
     51// Traitement des evenements   
     52//  virtual void   Resize();
     53  virtual void   Draw(PIGraphic* g, int x0, int y0, int dx, int dy);
     54
     55protected:
     56};
     57
     58// ---- Declaration de la classe CompStringDrawWdg --------
     59class CompStringDrawWdg : public StringDrawWdg
     60{
     61public:
     62// Les methodes ...
     63
     64                  CompStringDrawWdg(PIContainerGen *par, char *nom,
     65                                    int sx=10, int sy=10, int px=0, int py=0);
     66  virtual         ~CompStringDrawWdg();
    5067
    5168// Traitement des evenements   
     
    419436
    420437/* ........................................................... */
     438/*     Classe CompStringDrawWdg (Implementation des methodes)             */
     439/* ........................................................... */
     440
     441/* --Methode-- */
     442CompStringDrawWdg::CompStringDrawWdg(PIContainerGen *par, char *nom,
     443                       int sx, int sy, int px, int py)
     444: StringDrawWdg(par, nom, sx, sy, px, py)
     445
     446{
     447}
     448
     449/* --Methode-- */
     450CompStringDrawWdg::~CompStringDrawWdg()
     451{
     452}
     453 
     454
     455/* --Methode-- */
     456void CompStringDrawWdg::Draw(PIGraphicGen* g, int /*x0*/, int /*y0*/, int /*dx*/, int /*dy*/)
     457{
     458PIFontAtt att[4] = { PI_RomanFont, PI_BoldFont, PI_ItalicFont, PI_BoldItalicFont};
     459PIFontSize fsz[5] = { PI_TinySizeFont, PI_SmallSizeFont, PI_NormalSizeFont,
     460                      PI_BigSizeFont, PI_HugeSizeFont };
     461PIFontName fn[4] = { PI_CourierFont, PI_HelveticaFont,
     462                     PI_TimesFont, PI_SymbolFont};
     463char * fnstr[4] = { "Courier-Font", "Helvetica-Font",
     464                     "Times-Font", "Symbol-Font"};
     465char * attstr[4] = { "RomanFont" , "BoldFont", "ItalicFont", "BoldItalicFont"};
     466char * fszstr[5] = { "TinySizeFont", "SmallSizeFont", "NormalSizeFont",
     467                      "BigSizeFont", "HugeSizeFont" };
     468
     469if (g->kind() != PI_PSFileGraphics ) EraseWindow();
     470
     471
     472int ia=0, js=0;
     473int k;
     474for(k=0; k<4; k++)
     475  if (att[k] == mFAtt)  {ia = k; break; }
     476for(k=0; k<5; k++)
     477  if (fsz[k] == mFSize)  {js = k; break; }
     478
     479if ((mFSize != mSFSize) || (mFAtt != mSFAtt))
     480  for(k=0; k<10; k++)
     481    mSL[k] = mSH[k] = 0;
     482PIFont f(14, PI_DefaultFont, mFAtt);
     483g->SelFont(f);
     484g->SelForeground(PI_Black);
     485g->SelLine(PI_ThinLine);
     486
     487g->DrawString(20,24,"StringDraw");
     488g->DrawString(XSize()/5,24,attstr[ia]);
     489g->DrawString(XSize()/3,24,fszstr[js]);
     490
     491
     492PIFont fx(14,fn[2]);
     493fx.SetFontSz(mFSize);
     494fx.SetFontAtt(mFAtt);
     495g->SelFont(fx);
     496int fh,fa,fd;
     497fh = fx.GetFontHeight(fa, fd);
     498cout << " FontSize= " << f.GetFontSize() << " FontHeight= " << fh << endl;
     499
     500g->DrawCompString(XSize()/2,40,"10","-34",NULL);
     501g->DrawCompString(XSize()/2+60,40,"10","+78",NULL);
     502g->DrawCompString(XSize()/2+120,40, "10", NULL, "a");
     503
     504int xpos, ypos;
     505char *s, *su, *sd;
     506
     507// --------------- Vertical Top -----------------
     508
     509xpos = 30;  ypos = 75;
     510s = "HLeftVTop";
     511su = "824";
     512sd = "ij";
     513g->SelForeground(PI_Red);
     514g->DrawLine(xpos-50, ypos, xpos+50, ypos);
     515g->DrawLine(xpos, ypos-10, xpos, ypos+10);
     516g->SelForeground(PI_Black);
     517g->DrawCompString(xpos, ypos, s, su, sd, PI_HorizontalLeft|PI_VerticalTop);
     518
     519xpos = XSize()/2;  ypos = 75;
     520s = "HCenVTop";
     521su = "76843";
     522sd = "abc";
     523g->SelForeground(PI_Red);
     524g->DrawLine(xpos-50, ypos, xpos+50, ypos);
     525g->DrawLine(xpos, ypos-10, xpos, ypos+10);
     526g->SelForeground(PI_Black);
     527g->DrawCompString(xpos, ypos, s, su, sd, PI_HorizontalCenter|PI_VerticalTop);
     528
     529xpos = XSize()-30;  ypos = 75;
     530s = "HRigVTop";
     531su = "76843";
     532sd = "abc";
     533g->SelForeground(PI_Red);
     534g->DrawLine(xpos-50, ypos, xpos+50, ypos);
     535g->DrawLine(xpos, ypos-10, xpos, ypos+10);
     536g->SelForeground(PI_Black);
     537g->DrawCompString(xpos, ypos, s, su, sd, PI_HorizontalRight|PI_VerticalTop);
     538
     539// --------------- Vertical Center -----------------
     540xpos = 30;  ypos = 150;
     541s = "HLeftVCen";
     542su = "32987";
     543sd = NULL;
     544g->SelForeground(PI_Red);
     545g->DrawLine(xpos-50, ypos, xpos+50, ypos);
     546g->DrawLine(xpos, ypos-10, xpos, ypos+10);
     547g->SelForeground(PI_Black);
     548g->DrawCompString(xpos, ypos, s, su, sd, PI_HorizontalLeft|PI_VerticalCenter);
     549
     550xpos = XSize()/2;  ypos = 150;
     551s = "HCenVCen";
     552su = "32987";
     553sd = "klm";
     554g->SelForeground(PI_Red);
     555g->DrawLine(xpos-50, ypos, xpos+50, ypos);
     556g->DrawLine(xpos, ypos-10, xpos, ypos+10);
     557g->SelForeground(PI_Black);
     558g->DrawCompString(xpos, ypos, s, su, sd, PI_HorizontalCenter|PI_VerticalCenter);
     559
     560xpos = XSize()-30;  ypos = 150;
     561s = "HRigVCen";
     562su = "2";
     563sd = "alpha";
     564g->SelForeground(PI_Red);
     565g->DrawLine(xpos-50, ypos, xpos+50, ypos);
     566g->DrawLine(xpos, ypos-10, xpos, ypos+10);
     567g->SelForeground(PI_Black);
     568g->DrawCompString(xpos, ypos, s, su, sd, PI_HorizontalRight|PI_VerticalCenter);
     569
     570// --------------- Vertical BaseLine -----------------
     571xpos = 30;  ypos = 250;
     572s = "HLeftVBas";
     573su = "3";
     574sd = "beta";
     575g->SelForeground(PI_Red);
     576g->DrawLine(xpos-50, ypos, xpos+50, ypos);
     577g->DrawLine(xpos, ypos-10, xpos, ypos+10);
     578g->SelForeground(PI_Black);
     579g->DrawCompString(xpos, ypos, s, su, sd, PI_HorizontalLeft|PI_VerticalBaseLine);
     580
     581xpos = XSize()/2;  ypos = 250;
     582s = "HCenVBas";
     583su = "gamma";
     584sd = "44";
     585g->SelForeground(PI_Red);
     586g->DrawLine(xpos-50, ypos, xpos+50, ypos);
     587g->DrawLine(xpos, ypos-10, xpos, ypos+10);
     588g->SelForeground(PI_Black);
     589g->DrawCompString(xpos, ypos, s, su, sd, PI_HorizontalCenter|PI_VerticalBaseLine);
     590
     591xpos = XSize()-30;  ypos = 250;
     592s = "HRigVBas";
     593su = "55";
     594sd = "alpha";
     595g->SelForeground(PI_Red);
     596g->DrawLine(xpos-50, ypos, xpos+50, ypos);
     597g->DrawLine(xpos, ypos-10, xpos, ypos+10);
     598g->SelForeground(PI_Black);
     599g->DrawCompString(xpos, ypos, s, su, sd, PI_HorizontalRight|PI_VerticalBaseLine);
     600
     601// --------------- Vertical Bottom -----------------
     602xpos = 30;  ypos = 325;
     603s = "HLeftVBot";
     604su = "abc";
     605sd = "6";
     606g->SelForeground(PI_Red);
     607g->DrawLine(xpos-50, ypos, xpos+50, ypos);
     608g->DrawLine(xpos, ypos-10, xpos, ypos+10);
     609g->SelForeground(PI_Black);
     610g->DrawCompString(xpos, ypos, s, su, sd, PI_HorizontalLeft|PI_VerticalBottom);
     611
     612xpos = XSize()/2;  ypos = 325;
     613s = "HCentVBot";
     614su = NULL;
     615sd = "lm";
     616g->SelForeground(PI_Red);
     617g->DrawLine(xpos-50, ypos, xpos+50, ypos);
     618g->DrawLine(xpos, ypos-10, xpos, ypos+10);
     619g->SelForeground(PI_Black);
     620g->DrawCompString(xpos, ypos, s, su, sd, PI_HorizontalCenter|PI_VerticalBottom);
     621
     622xpos = XSize()-30;  ypos = 325;
     623s = "HLeftVBot";
     624su = NULL;
     625sd = NULL;
     626g->SelForeground(PI_Red);
     627g->DrawLine(xpos-50, ypos, xpos+50, ypos);
     628g->DrawLine(xpos, ypos-10, xpos, ypos+10);
     629g->SelForeground(PI_Black);
     630g->DrawCompString(xpos, ypos, s, su, sd, PI_HorizontalRight|PI_VerticalBottom);
     631 
     632return;
     633}
     634
     635/* ........................................................... */
    421636/*                       Classe PITApp                         */
    422637/* ........................................................... */
     
    447662m[0]->AppendItem("StringDrawWdg", 10101);
    448663m[0]->AppendItem("StringPosDrawWdg", 10102);
     664m[0]->AppendItem("CompStringDrawWdg", 10103);
    449665m[0]->AppendItem("->eps", 10111);
    450666m[0]->AppendItem("->ps", 10112);
     
    521737      wp->SetAutoDelChilds(true);
    522738      StringPosDrawWdg* exb  = new StringPosDrawWdg(wp, "sposdrawwdg", 600, 400, 0, 0);
     739      exb->SetBinding(PIBK_fixed,PIBK_elastic,PIBK_elastic,PIBK_elastic);
     740      wp->SetUserData(exb);
     741      wp->Show();
     742      }
     743    break;
     744
     745    case 10103: // Creation d'un StringPosDrawWdg
     746      {
     747      nbwin++;
     748      sprintf(strg, "Creation CompStringDrawWdg   \n Fenetre No %d ", nbwin);
     749      sprintf(strg,"CompStringDrawWdg - %d", nbwin);
     750      PIWindow* wp = new PIWindow(this, strg, PIWK_normal,  600, 400, 150, 150);
     751      wp->SetAutoDelChilds(true);
     752      CompStringDrawWdg* exb  = new CompStringDrawWdg(wp, "compposdrawwdg", 600, 400, 0, 0);
    523753      exb->SetBinding(PIBK_fixed,PIBK_elastic,PIBK_elastic,PIBK_elastic);
    524754      wp->SetUserData(exb);
Note: See TracChangeset for help on using the changeset viewer.