Changeset 1896 in Sophya
- Timestamp:
- Feb 7, 2002, 7:22:56 PM (24 years ago)
- Location:
- trunk/SophyaPI/PI
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/SophyaPI/PI/Tests/pist.cc
r1854 r1896 48 48 int sx=10, int sy=10, int px=0, int py=0); 49 49 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 55 protected: 56 }; 57 58 // ---- Declaration de la classe CompStringDrawWdg -------- 59 class CompStringDrawWdg : public StringDrawWdg 60 { 61 public: 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(); 50 67 51 68 // Traitement des evenements … … 419 436 420 437 /* ........................................................... */ 438 /* Classe CompStringDrawWdg (Implementation des methodes) */ 439 /* ........................................................... */ 440 441 /* --Methode-- */ 442 CompStringDrawWdg::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-- */ 450 CompStringDrawWdg::~CompStringDrawWdg() 451 { 452 } 453 454 455 /* --Methode-- */ 456 void CompStringDrawWdg::Draw(PIGraphicGen* g, int /*x0*/, int /*y0*/, int /*dx*/, int /*dy*/) 457 { 458 PIFontAtt att[4] = { PI_RomanFont, PI_BoldFont, PI_ItalicFont, PI_BoldItalicFont}; 459 PIFontSize fsz[5] = { PI_TinySizeFont, PI_SmallSizeFont, PI_NormalSizeFont, 460 PI_BigSizeFont, PI_HugeSizeFont }; 461 PIFontName fn[4] = { PI_CourierFont, PI_HelveticaFont, 462 PI_TimesFont, PI_SymbolFont}; 463 char * fnstr[4] = { "Courier-Font", "Helvetica-Font", 464 "Times-Font", "Symbol-Font"}; 465 char * attstr[4] = { "RomanFont" , "BoldFont", "ItalicFont", "BoldItalicFont"}; 466 char * fszstr[5] = { "TinySizeFont", "SmallSizeFont", "NormalSizeFont", 467 "BigSizeFont", "HugeSizeFont" }; 468 469 if (g->kind() != PI_PSFileGraphics ) EraseWindow(); 470 471 472 int ia=0, js=0; 473 int k; 474 for(k=0; k<4; k++) 475 if (att[k] == mFAtt) {ia = k; break; } 476 for(k=0; k<5; k++) 477 if (fsz[k] == mFSize) {js = k; break; } 478 479 if ((mFSize != mSFSize) || (mFAtt != mSFAtt)) 480 for(k=0; k<10; k++) 481 mSL[k] = mSH[k] = 0; 482 PIFont f(14, PI_DefaultFont, mFAtt); 483 g->SelFont(f); 484 g->SelForeground(PI_Black); 485 g->SelLine(PI_ThinLine); 486 487 g->DrawString(20,24,"StringDraw"); 488 g->DrawString(XSize()/5,24,attstr[ia]); 489 g->DrawString(XSize()/3,24,fszstr[js]); 490 491 492 PIFont fx(14,fn[2]); 493 fx.SetFontSz(mFSize); 494 fx.SetFontAtt(mFAtt); 495 g->SelFont(fx); 496 int fh,fa,fd; 497 fh = fx.GetFontHeight(fa, fd); 498 cout << " FontSize= " << f.GetFontSize() << " FontHeight= " << fh << endl; 499 500 g->DrawCompString(XSize()/2,40,"10","-34",NULL); 501 g->DrawCompString(XSize()/2+60,40,"10","+78",NULL); 502 g->DrawCompString(XSize()/2+120,40, "10", NULL, "a"); 503 504 int xpos, ypos; 505 char *s, *su, *sd; 506 507 // --------------- Vertical Top ----------------- 508 509 xpos = 30; ypos = 75; 510 s = "HLeftVTop"; 511 su = "824"; 512 sd = "ij"; 513 g->SelForeground(PI_Red); 514 g->DrawLine(xpos-50, ypos, xpos+50, ypos); 515 g->DrawLine(xpos, ypos-10, xpos, ypos+10); 516 g->SelForeground(PI_Black); 517 g->DrawCompString(xpos, ypos, s, su, sd, PI_HorizontalLeft|PI_VerticalTop); 518 519 xpos = XSize()/2; ypos = 75; 520 s = "HCenVTop"; 521 su = "76843"; 522 sd = "abc"; 523 g->SelForeground(PI_Red); 524 g->DrawLine(xpos-50, ypos, xpos+50, ypos); 525 g->DrawLine(xpos, ypos-10, xpos, ypos+10); 526 g->SelForeground(PI_Black); 527 g->DrawCompString(xpos, ypos, s, su, sd, PI_HorizontalCenter|PI_VerticalTop); 528 529 xpos = XSize()-30; ypos = 75; 530 s = "HRigVTop"; 531 su = "76843"; 532 sd = "abc"; 533 g->SelForeground(PI_Red); 534 g->DrawLine(xpos-50, ypos, xpos+50, ypos); 535 g->DrawLine(xpos, ypos-10, xpos, ypos+10); 536 g->SelForeground(PI_Black); 537 g->DrawCompString(xpos, ypos, s, su, sd, PI_HorizontalRight|PI_VerticalTop); 538 539 // --------------- Vertical Center ----------------- 540 xpos = 30; ypos = 150; 541 s = "HLeftVCen"; 542 su = "32987"; 543 sd = NULL; 544 g->SelForeground(PI_Red); 545 g->DrawLine(xpos-50, ypos, xpos+50, ypos); 546 g->DrawLine(xpos, ypos-10, xpos, ypos+10); 547 g->SelForeground(PI_Black); 548 g->DrawCompString(xpos, ypos, s, su, sd, PI_HorizontalLeft|PI_VerticalCenter); 549 550 xpos = XSize()/2; ypos = 150; 551 s = "HCenVCen"; 552 su = "32987"; 553 sd = "klm"; 554 g->SelForeground(PI_Red); 555 g->DrawLine(xpos-50, ypos, xpos+50, ypos); 556 g->DrawLine(xpos, ypos-10, xpos, ypos+10); 557 g->SelForeground(PI_Black); 558 g->DrawCompString(xpos, ypos, s, su, sd, PI_HorizontalCenter|PI_VerticalCenter); 559 560 xpos = XSize()-30; ypos = 150; 561 s = "HRigVCen"; 562 su = "2"; 563 sd = "alpha"; 564 g->SelForeground(PI_Red); 565 g->DrawLine(xpos-50, ypos, xpos+50, ypos); 566 g->DrawLine(xpos, ypos-10, xpos, ypos+10); 567 g->SelForeground(PI_Black); 568 g->DrawCompString(xpos, ypos, s, su, sd, PI_HorizontalRight|PI_VerticalCenter); 569 570 // --------------- Vertical BaseLine ----------------- 571 xpos = 30; ypos = 250; 572 s = "HLeftVBas"; 573 su = "3"; 574 sd = "beta"; 575 g->SelForeground(PI_Red); 576 g->DrawLine(xpos-50, ypos, xpos+50, ypos); 577 g->DrawLine(xpos, ypos-10, xpos, ypos+10); 578 g->SelForeground(PI_Black); 579 g->DrawCompString(xpos, ypos, s, su, sd, PI_HorizontalLeft|PI_VerticalBaseLine); 580 581 xpos = XSize()/2; ypos = 250; 582 s = "HCenVBas"; 583 su = "gamma"; 584 sd = "44"; 585 g->SelForeground(PI_Red); 586 g->DrawLine(xpos-50, ypos, xpos+50, ypos); 587 g->DrawLine(xpos, ypos-10, xpos, ypos+10); 588 g->SelForeground(PI_Black); 589 g->DrawCompString(xpos, ypos, s, su, sd, PI_HorizontalCenter|PI_VerticalBaseLine); 590 591 xpos = XSize()-30; ypos = 250; 592 s = "HRigVBas"; 593 su = "55"; 594 sd = "alpha"; 595 g->SelForeground(PI_Red); 596 g->DrawLine(xpos-50, ypos, xpos+50, ypos); 597 g->DrawLine(xpos, ypos-10, xpos, ypos+10); 598 g->SelForeground(PI_Black); 599 g->DrawCompString(xpos, ypos, s, su, sd, PI_HorizontalRight|PI_VerticalBaseLine); 600 601 // --------------- Vertical Bottom ----------------- 602 xpos = 30; ypos = 325; 603 s = "HLeftVBot"; 604 su = "abc"; 605 sd = "6"; 606 g->SelForeground(PI_Red); 607 g->DrawLine(xpos-50, ypos, xpos+50, ypos); 608 g->DrawLine(xpos, ypos-10, xpos, ypos+10); 609 g->SelForeground(PI_Black); 610 g->DrawCompString(xpos, ypos, s, su, sd, PI_HorizontalLeft|PI_VerticalBottom); 611 612 xpos = XSize()/2; ypos = 325; 613 s = "HCentVBot"; 614 su = NULL; 615 sd = "lm"; 616 g->SelForeground(PI_Red); 617 g->DrawLine(xpos-50, ypos, xpos+50, ypos); 618 g->DrawLine(xpos, ypos-10, xpos, ypos+10); 619 g->SelForeground(PI_Black); 620 g->DrawCompString(xpos, ypos, s, su, sd, PI_HorizontalCenter|PI_VerticalBottom); 621 622 xpos = XSize()-30; ypos = 325; 623 s = "HLeftVBot"; 624 su = NULL; 625 sd = NULL; 626 g->SelForeground(PI_Red); 627 g->DrawLine(xpos-50, ypos, xpos+50, ypos); 628 g->DrawLine(xpos, ypos-10, xpos, ypos+10); 629 g->SelForeground(PI_Black); 630 g->DrawCompString(xpos, ypos, s, su, sd, PI_HorizontalRight|PI_VerticalBottom); 631 632 return; 633 } 634 635 /* ........................................................... */ 421 636 /* Classe PITApp */ 422 637 /* ........................................................... */ … … 447 662 m[0]->AppendItem("StringDrawWdg", 10101); 448 663 m[0]->AppendItem("StringPosDrawWdg", 10102); 664 m[0]->AppendItem("CompStringDrawWdg", 10103); 449 665 m[0]->AppendItem("->eps", 10111); 450 666 m[0]->AppendItem("->ps", 10112); … … 521 737 wp->SetAutoDelChilds(true); 522 738 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); 523 753 exb->SetBinding(PIBK_fixed,PIBK_elastic,PIBK_elastic,PIBK_elastic); 524 754 wp->SetUserData(exb); -
trunk/SophyaPI/PI/pigraphgen.cc
r1893 r1896 196 196 const char* s_up, const char* s_dn, int pos) 197 197 { 198 // AFAIREREZA012002 198 if ((s_up == NULL) && (s_dn == NULL)) { 199 if (s != NULL) DrawString(x,y,s,pos); 200 return; 201 } 202 203 int fh,fas,fds; 204 fh = myFont.GetFontHeight(fas, fds); 205 int sw_s = 0; 206 if (s != NULL) sw_s = myFont.GetStringWidth(s); 207 208 PIFont fnt_save(myFont); 209 PIFont fnt_ss(myFont); 210 fnt_ss.SetFontSzPt(2*myFont.GetFontSize()/3); 211 212 int sw_sup = 0; 213 if (s_up != NULL) sw_sup = fnt_ss.GetStringWidth(s_up); 214 int sw_sdn = 0; 215 if (s_dn != NULL) sw_sdn = fnt_ss.GetStringWidth(s_dn); 216 217 PIGrCoord xs,ys; 218 int posh = pos & PI_HorizontalPosition; 219 int posv = pos & PI_VerticalPosition; 220 221 int dyu, dyd; 222 dyu = -fh/2; dyd = fh/2-fh/5; 223 if (posv == PI_VerticalBaseLine) { 224 dyu = -fh/2; dyd = fh/2-fh/5; 225 } 226 else if (posv == PI_VerticalBottom) { 227 dyu = -fh/2-fds; dyd = fh/2-fh/5-fds; 228 } 229 else if (posv == PI_VerticalCenter) { 230 dyu = -fds; dyd = fh-fh/5-fds; 231 } 232 else if (posv == PI_VerticalTop) { 233 dyu = fh/2-fds; dyd = 3*fh/2-fh/5-fds; 234 } 235 236 int deltaposx = ((fh/8) > 0) ? fh/8 : 1; 237 238 239 if ((pos == 0) || ((posh == PI_HorizontalLeft) && (posv == PI_VerticalBaseLine))) { 240 if (s != NULL) DrawString(x, y, s, 0); 241 xs = (int)x+sw_s+deltaposx; 242 ys = (int)y+dyu; 243 SelFont(fnt_ss); 244 if (s_up != NULL) DrawString(xs, ys, s_up, 0); 245 ys = (int)y+dyd; 246 if (s_dn != NULL) DrawString(xs, ys, s_dn, 0); 247 } 248 else { 249 if (posh == PI_HorizontalRight) { 250 int sw_ss_max = ( sw_sup > sw_sdn ) ? sw_sup : sw_sdn; 251 xs = (int)x-sw_ss_max-deltaposx; 252 if (s != NULL) DrawString(xs, y, s, PI_HorizontalRight | posv); 253 SelFont(fnt_ss); 254 xs = (int)xs+deltaposx; 255 ys = (int)y+dyu; 256 if (s_up != NULL) DrawString(xs, ys, s_up, 0); 257 ys = (int)y+dyd; 258 if (s_dn != NULL) DrawString(xs, ys, s_dn, 0); 259 } 260 else if (posh == PI_HorizontalCenter) { 261 int sw_tot = sw_sup+sw_sdn+sw_s+deltaposx; 262 xs = (int)x-sw_tot/2+sw_s; 263 if (s != NULL) DrawString(xs, y, s, PI_HorizontalRight | posv); 264 SelFont(fnt_ss); 265 xs = (int)xs+deltaposx; 266 ys = (int)y+dyu; 267 if (s_up != NULL) DrawString(xs, ys, s_up, 0); 268 ys = (int)y+dyd; 269 if (s_dn != NULL) DrawString(xs, ys, s_dn, 0); 270 } 271 else { 272 if (s != NULL) DrawString(x, y, s, posv); 273 SelFont(fnt_ss); 274 xs = (int)x+sw_s+deltaposx; 275 ys = (int)y+dyu; 276 if (s_up != NULL) DrawString(xs, ys, s_up, 0); 277 ys = (int)y+dyd; 278 if (s_dn != NULL) DrawString(xs, ys, s_dn, 0); 279 } 280 } 281 SelFont(fnt_save); 282 return; 199 283 } 200 284 … … 564 648 // Des constructeurs et des méthodes de conversion à partir 565 649 // et vers des "int", "float" et "double" sont définis. 566 // L'objet conserve le type effectif de l'argument lors de la 567 // création ou de la dernière affectation. 650 // La valeur entiere d'un objet PIGrCoord construite à partir 651 // d'une valeur flottante (ou suite à une affectation) correpond 652 // à l'entier le plus proche. 568 653 // 569 //| PIGrCoord gco; 570 //| gco = 3.141596 ; 654 //| PIGrCoord gco = 3.14; 571 655 //| int ic = gco; // ic -> 3 572 //| float fc = gco; // fc -> 3.141596 656 //| float fc = gco; // fc -> 3.14 657 //| gco = 1.1; // (int)gco -> 1 658 //| gco = 1.6; // (int)gco -> 2 659 //| gco = -0.4; // (int)gco -> 0 660 //| gco = -0.7; // (int)gco -> -1 573 661 //-- 574 662 //++
Note:
See TracChangeset
for help on using the changeset viewer.