Changeset 1847 in Sophya


Ignore:
Timestamp:
Jan 6, 2002, 6:58:59 PM (24 years ago)
Author:
ansari
Message:

Extension programme de test de DrawString pour test positionnement chaine - Reza 6/1/2002

File:
1 edited

Legend:

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

    r1846 r1847  
    3838  PIFontAtt mFAtt,mSFAtt;
    3939  PIFontSize mFSize, mSFSize;
     40  PIFontName mFName, mSFName;
    4041  int mSL[10], mSH[10];
     42};
     43
     44
     45// ---- Declaration de la classe StringDrawWdg --------
     46class StringPosDrawWdg : public StringDrawWdg
     47{
     48public:
     49// Les methodes ...
     50
     51                  StringPosDrawWdg(PIContainerGen *par, char *nom,
     52                         int sx=10, int sy=10, int px=0, int py=0);
     53  virtual         ~StringPosDrawWdg();
     54
     55// Traitement des evenements   
     56//  virtual void   Resize();
     57  virtual void   Draw(PIGraphic* g, int x0, int y0, int dx, int dy);
     58
     59protected:
    4160};
    4261
     
    5675  mSFAtt = PI_NotDefFontAtt;
    5776  mSFSize = PI_NotDefFontSize;
     77  mSFName = mFName = PI_CourierFont;
    5878  for(int k=0; k<10; k++)
    5979    mSL[k] = mSH[k] = 0;
     
    173193void StringDrawWdg::Keyboard(int key, PIKeyModifier kmod)
    174194{
     195PIFontName fn[4] = { PI_CourierFont, PI_HelveticaFont,
     196                     PI_TimesFont, PI_SymbolFont};
    175197
    176198bool fgref = true;
     
    188210   mFAtt = PI_BoldItalicFont;
    189211   break;
     212 case 'C':
     213   mFName = PI_CourierFont;
     214   break;
     215 case 'H':
     216   mFName = PI_HelveticaFont;
     217   break;
     218 case 'T':
     219   mFName = PI_TimesFont;
     220   break;
     221 case 'S':
     222   mFName = PI_SymbolFont;
     223   break;
    190224 case '1':
    191225   mFSize = PI_TinySizeFont;
     
    215249{
    216250  Send(Msg(), PIMsg_Active);
     251}
     252
     253/* ........................................................... */
     254/*     Classe StringPosDrawWdg (Implementation des methodes)             */
     255/* ........................................................... */
     256
     257/* --Methode-- */
     258StringPosDrawWdg::StringPosDrawWdg(PIContainerGen *par, char *nom,
     259                       int sx, int sy, int px, int py)
     260: StringDrawWdg(par, nom, sx, sy, px, py)
     261
     262{
     263}
     264
     265/* --Methode-- */
     266StringPosDrawWdg::~StringPosDrawWdg()
     267{
     268}
     269 
     270
     271/* --Methode-- */
     272void StringPosDrawWdg::Draw(PIGraphicGen* g, int /*x0*/, int /*y0*/, int /*dx*/, int /*dy*/)
     273{
     274PIFontAtt att[4] = { PI_RomanFont, PI_BoldFont, PI_ItalicFont, PI_BoldItalicFont};
     275PIFontSize fsz[5] = { PI_TinySizeFont, PI_SmallSizeFont, PI_NormalSizeFont,
     276                      PI_BigSizeFont, PI_HugeSizeFont };
     277PIFontName fn[4] = { PI_CourierFont, PI_HelveticaFont,
     278                     PI_TimesFont, PI_SymbolFont};
     279char * fnstr[4] = { "Courier-Font", "Helvetica-Font",
     280                     "Times-Font", "Symbol-Font"};
     281char * attstr[4] = { "RomanFont" , "BoldFont", "ItalicFont", "BoldItalicFont"};
     282char * fszstr[5] = { "TinySizeFont", "SmallSizeFont", "NormalSizeFont",
     283                      "BigSizeFont", "HugeSizeFont" };
     284
     285if (g->kind() != PI_PSFileGraphics ) EraseWindow();
     286
     287
     288int ia=0, js=0;
     289int k;
     290for(k=0; k<4; k++)
     291  if (att[k] == mFAtt)  {ia = k; break; }
     292for(k=0; k<5; k++)
     293  if (fsz[k] == mFSize)  {js = k; break; }
     294
     295if ((mFSize != mSFSize) || (mFAtt != mSFAtt))
     296  for(k=0; k<10; k++)
     297    mSL[k] = mSH[k] = 0;
     298PIFont f(14, PI_DefaultFont, mFAtt);
     299g->SelFont(f);
     300g->SelForeground(PI_Black);
     301g->SelLine(PI_ThinLine);
     302
     303g->DrawString(20,24,"StringPosDraw");
     304g->DrawString(XSize()/3,24,attstr[ia]);
     305g->DrawString(2*XSize()/3,24,fszstr[js]);
     306
     307int fh,fa,fd;
     308fh = f.GetFontHeight(fa, fd);
     309cout << " FontSize= " << f.GetFontSize() << " FontHeight= " << fh << endl;
     310
     311
     312
     313int xpos, ypos;
     314char * s1;
     315
     316// --------------- Vertical Top -----------------
     317
     318xpos = 30;  ypos = 75;
     319s1 = "V_Top-H_Left";
     320g->SelForeground(PI_Red);
     321g->DrawLine(xpos-50, ypos, xpos+50, ypos);
     322g->DrawLine(xpos, ypos-10, xpos, ypos+10);
     323g->SelForeground(PI_Black);
     324g->DrawString(xpos, ypos, s1, PI_HorizontalLeft|PI_VerticalTop);
     325
     326xpos = 250;  ypos = 75;
     327s1 = "V_Top-H_Center";
     328g->SelForeground(PI_Red);
     329g->DrawLine(xpos-50, ypos, xpos+50, ypos);
     330g->DrawLine(xpos, ypos-10, xpos, ypos+10);
     331g->SelForeground(PI_Black);
     332g->DrawString(xpos, ypos, s1, PI_HorizontalCenter|PI_VerticalTop);
     333
     334xpos = 470;  ypos = 75;
     335s1 = "V_Top-H_Center";
     336g->SelForeground(PI_Red);
     337g->DrawLine(xpos-50, ypos, xpos+50, ypos);
     338g->DrawLine(xpos, ypos-10, xpos, ypos+10);
     339g->SelForeground(PI_Black);
     340g->DrawString(xpos, ypos, s1, PI_HorizontalRight|PI_VerticalTop);
     341
     342// --------------- Vertical Center -----------------
     343xpos = 30;  ypos = 150;
     344s1 = "V_Center-H_Left";
     345g->SelForeground(PI_Red);
     346g->DrawLine(xpos-50, ypos, xpos+50, ypos);
     347g->DrawLine(xpos, ypos-10, xpos, ypos+10);
     348g->SelForeground(PI_Black);
     349g->DrawString(xpos, ypos, s1, PI_HorizontalLeft|PI_VerticalCenter);
     350
     351xpos = 250;  ypos = 150;
     352s1 = "V_Center-H_Center";
     353g->SelForeground(PI_Red);
     354g->DrawLine(xpos-50, ypos, xpos+50, ypos);
     355g->DrawLine(xpos, ypos-10, xpos, ypos+10);
     356g->SelForeground(PI_Black);
     357g->DrawString(xpos, ypos, s1, PI_HorizontalCenter|PI_VerticalCenter);
     358
     359xpos = 470;  ypos = 150;
     360s1 = "V_Center-H_Right";
     361g->SelForeground(PI_Red);
     362g->DrawLine(xpos-50, ypos, xpos+50, ypos);
     363g->DrawLine(xpos, ypos-10, xpos, ypos+10);
     364g->SelForeground(PI_Black);
     365g->DrawString(xpos, ypos, s1, PI_HorizontalRight|PI_VerticalCenter);
     366 
     367// --------------- Vertical Bottom -----------------
     368xpos = 30;  ypos = 250;
     369s1 = "V_Bottom-H_Left";
     370g->SelForeground(PI_Red);
     371g->DrawLine(xpos-50, ypos, xpos+50, ypos);
     372g->DrawLine(xpos, ypos-10, xpos, ypos+10);
     373g->SelForeground(PI_Black);
     374g->DrawString(xpos, ypos, s1, PI_HorizontalLeft|PI_VerticalBottom);
     375
     376xpos = 250;  ypos = 250;
     377s1 = "V_Bottom-H_Center";
     378g->SelForeground(PI_Red);
     379g->DrawLine(xpos-50, ypos, xpos+50, ypos);
     380g->DrawLine(xpos, ypos-10, xpos, ypos+10);
     381g->SelForeground(PI_Black);
     382g->DrawString(xpos, ypos, s1, PI_HorizontalCenter|PI_VerticalBottom);
     383
     384xpos = 470;  ypos = 250;
     385s1 = "V_Bottom-H_Center";
     386g->SelForeground(PI_Red);
     387g->DrawLine(xpos-50, ypos, xpos+50, ypos);
     388g->DrawLine(xpos, ypos-10, xpos, ypos+10);
     389g->SelForeground(PI_Black);
     390g->DrawString(xpos, ypos, s1, PI_HorizontalRight|PI_VerticalBottom);
     391 
     392return;
    217393}
    218394
     
    245421m[0] = new PIMenu(Menubar(),"Actions");
    246422m[0]->AppendItem("StringDrawWdg", 10101);
     423m[0]->AppendItem("StringPosDrawWdg", 10102);
    247424m[0]->AppendItem("->eps", 10111);
    248425m[0]->AppendItem("->ps", 10112);
     
    258435txt->SetTextEditable(false);
    259436txt->SetText("");
    260 txt->SetText("StringDrawWdg/Keyboard: \n r,b,i,I (Roman,bold,italic,bolditalic) \n Size 1,2,3,4,5");
     437txt->SetText("StringDrawWdg/Keyboard: \n r,b,i,I (Roman,bold,italic,bolditalic) \n Size 1,2,3,4,5\n C,H,T,S (Courier,Helvetica,Times,Symbol)");
    261438
    262439mcurwin = NULL;
     
    304481      PIWindow* wp = new PIWindow(this, strg, PIWK_normal,  400, 400, 150, 150);
    305482      wp->SetAutoDelChilds(true);
    306       StringDrawWdg* exb  = new StringDrawWdg(wp, "bwdg", 400, 400, 0, 0);
     483      StringDrawWdg* exb  = new StringDrawWdg(wp, "sdrawwdg", 400, 400, 0, 0);
     484      exb->SetBinding(PIBK_fixed,PIBK_elastic,PIBK_elastic,PIBK_elastic);
     485      wp->SetUserData(exb);
     486      wp->Show();
     487      }
     488    break;
     489
     490    case 10102: // Creation d'un StringPosDrawWdg
     491      {
     492      nbwin++;
     493      sprintf(strg, "Creation StringPosDrawWdg   \n Fenetre No %d ", nbwin);
     494      sprintf(strg,"StringPosDrawWdg - %d", nbwin);
     495      PIWindow* wp = new PIWindow(this, strg, PIWK_normal,  500, 300, 150, 150);
     496      wp->SetAutoDelChilds(true);
     497      StringPosDrawWdg* exb  = new StringPosDrawWdg(wp, "sposdrawwdg", 500, 300, 0, 0);
    307498      exb->SetBinding(PIBK_fixed,PIBK_elastic,PIBK_elastic,PIBK_elastic);
    308499      wp->SetUserData(exb);
Note: See TracChangeset for help on using the changeset viewer.