Changeset 1847 in Sophya
- Timestamp:
- Jan 6, 2002, 6:58:59 PM (24 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/SophyaPI/PI/Tests/pist.cc
r1846 r1847 38 38 PIFontAtt mFAtt,mSFAtt; 39 39 PIFontSize mFSize, mSFSize; 40 PIFontName mFName, mSFName; 40 41 int mSL[10], mSH[10]; 42 }; 43 44 45 // ---- Declaration de la classe StringDrawWdg -------- 46 class StringPosDrawWdg : public StringDrawWdg 47 { 48 public: 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 59 protected: 41 60 }; 42 61 … … 56 75 mSFAtt = PI_NotDefFontAtt; 57 76 mSFSize = PI_NotDefFontSize; 77 mSFName = mFName = PI_CourierFont; 58 78 for(int k=0; k<10; k++) 59 79 mSL[k] = mSH[k] = 0; … … 173 193 void StringDrawWdg::Keyboard(int key, PIKeyModifier kmod) 174 194 { 195 PIFontName fn[4] = { PI_CourierFont, PI_HelveticaFont, 196 PI_TimesFont, PI_SymbolFont}; 175 197 176 198 bool fgref = true; … … 188 210 mFAtt = PI_BoldItalicFont; 189 211 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; 190 224 case '1': 191 225 mFSize = PI_TinySizeFont; … … 215 249 { 216 250 Send(Msg(), PIMsg_Active); 251 } 252 253 /* ........................................................... */ 254 /* Classe StringPosDrawWdg (Implementation des methodes) */ 255 /* ........................................................... */ 256 257 /* --Methode-- */ 258 StringPosDrawWdg::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-- */ 266 StringPosDrawWdg::~StringPosDrawWdg() 267 { 268 } 269 270 271 /* --Methode-- */ 272 void StringPosDrawWdg::Draw(PIGraphicGen* g, int /*x0*/, int /*y0*/, int /*dx*/, int /*dy*/) 273 { 274 PIFontAtt att[4] = { PI_RomanFont, PI_BoldFont, PI_ItalicFont, PI_BoldItalicFont}; 275 PIFontSize fsz[5] = { PI_TinySizeFont, PI_SmallSizeFont, PI_NormalSizeFont, 276 PI_BigSizeFont, PI_HugeSizeFont }; 277 PIFontName fn[4] = { PI_CourierFont, PI_HelveticaFont, 278 PI_TimesFont, PI_SymbolFont}; 279 char * fnstr[4] = { "Courier-Font", "Helvetica-Font", 280 "Times-Font", "Symbol-Font"}; 281 char * attstr[4] = { "RomanFont" , "BoldFont", "ItalicFont", "BoldItalicFont"}; 282 char * fszstr[5] = { "TinySizeFont", "SmallSizeFont", "NormalSizeFont", 283 "BigSizeFont", "HugeSizeFont" }; 284 285 if (g->kind() != PI_PSFileGraphics ) EraseWindow(); 286 287 288 int ia=0, js=0; 289 int k; 290 for(k=0; k<4; k++) 291 if (att[k] == mFAtt) {ia = k; break; } 292 for(k=0; k<5; k++) 293 if (fsz[k] == mFSize) {js = k; break; } 294 295 if ((mFSize != mSFSize) || (mFAtt != mSFAtt)) 296 for(k=0; k<10; k++) 297 mSL[k] = mSH[k] = 0; 298 PIFont f(14, PI_DefaultFont, mFAtt); 299 g->SelFont(f); 300 g->SelForeground(PI_Black); 301 g->SelLine(PI_ThinLine); 302 303 g->DrawString(20,24,"StringPosDraw"); 304 g->DrawString(XSize()/3,24,attstr[ia]); 305 g->DrawString(2*XSize()/3,24,fszstr[js]); 306 307 int fh,fa,fd; 308 fh = f.GetFontHeight(fa, fd); 309 cout << " FontSize= " << f.GetFontSize() << " FontHeight= " << fh << endl; 310 311 312 313 int xpos, ypos; 314 char * s1; 315 316 // --------------- Vertical Top ----------------- 317 318 xpos = 30; ypos = 75; 319 s1 = "V_Top-H_Left"; 320 g->SelForeground(PI_Red); 321 g->DrawLine(xpos-50, ypos, xpos+50, ypos); 322 g->DrawLine(xpos, ypos-10, xpos, ypos+10); 323 g->SelForeground(PI_Black); 324 g->DrawString(xpos, ypos, s1, PI_HorizontalLeft|PI_VerticalTop); 325 326 xpos = 250; ypos = 75; 327 s1 = "V_Top-H_Center"; 328 g->SelForeground(PI_Red); 329 g->DrawLine(xpos-50, ypos, xpos+50, ypos); 330 g->DrawLine(xpos, ypos-10, xpos, ypos+10); 331 g->SelForeground(PI_Black); 332 g->DrawString(xpos, ypos, s1, PI_HorizontalCenter|PI_VerticalTop); 333 334 xpos = 470; ypos = 75; 335 s1 = "V_Top-H_Center"; 336 g->SelForeground(PI_Red); 337 g->DrawLine(xpos-50, ypos, xpos+50, ypos); 338 g->DrawLine(xpos, ypos-10, xpos, ypos+10); 339 g->SelForeground(PI_Black); 340 g->DrawString(xpos, ypos, s1, PI_HorizontalRight|PI_VerticalTop); 341 342 // --------------- Vertical Center ----------------- 343 xpos = 30; ypos = 150; 344 s1 = "V_Center-H_Left"; 345 g->SelForeground(PI_Red); 346 g->DrawLine(xpos-50, ypos, xpos+50, ypos); 347 g->DrawLine(xpos, ypos-10, xpos, ypos+10); 348 g->SelForeground(PI_Black); 349 g->DrawString(xpos, ypos, s1, PI_HorizontalLeft|PI_VerticalCenter); 350 351 xpos = 250; ypos = 150; 352 s1 = "V_Center-H_Center"; 353 g->SelForeground(PI_Red); 354 g->DrawLine(xpos-50, ypos, xpos+50, ypos); 355 g->DrawLine(xpos, ypos-10, xpos, ypos+10); 356 g->SelForeground(PI_Black); 357 g->DrawString(xpos, ypos, s1, PI_HorizontalCenter|PI_VerticalCenter); 358 359 xpos = 470; ypos = 150; 360 s1 = "V_Center-H_Right"; 361 g->SelForeground(PI_Red); 362 g->DrawLine(xpos-50, ypos, xpos+50, ypos); 363 g->DrawLine(xpos, ypos-10, xpos, ypos+10); 364 g->SelForeground(PI_Black); 365 g->DrawString(xpos, ypos, s1, PI_HorizontalRight|PI_VerticalCenter); 366 367 // --------------- Vertical Bottom ----------------- 368 xpos = 30; ypos = 250; 369 s1 = "V_Bottom-H_Left"; 370 g->SelForeground(PI_Red); 371 g->DrawLine(xpos-50, ypos, xpos+50, ypos); 372 g->DrawLine(xpos, ypos-10, xpos, ypos+10); 373 g->SelForeground(PI_Black); 374 g->DrawString(xpos, ypos, s1, PI_HorizontalLeft|PI_VerticalBottom); 375 376 xpos = 250; ypos = 250; 377 s1 = "V_Bottom-H_Center"; 378 g->SelForeground(PI_Red); 379 g->DrawLine(xpos-50, ypos, xpos+50, ypos); 380 g->DrawLine(xpos, ypos-10, xpos, ypos+10); 381 g->SelForeground(PI_Black); 382 g->DrawString(xpos, ypos, s1, PI_HorizontalCenter|PI_VerticalBottom); 383 384 xpos = 470; ypos = 250; 385 s1 = "V_Bottom-H_Center"; 386 g->SelForeground(PI_Red); 387 g->DrawLine(xpos-50, ypos, xpos+50, ypos); 388 g->DrawLine(xpos, ypos-10, xpos, ypos+10); 389 g->SelForeground(PI_Black); 390 g->DrawString(xpos, ypos, s1, PI_HorizontalRight|PI_VerticalBottom); 391 392 return; 217 393 } 218 394 … … 245 421 m[0] = new PIMenu(Menubar(),"Actions"); 246 422 m[0]->AppendItem("StringDrawWdg", 10101); 423 m[0]->AppendItem("StringPosDrawWdg", 10102); 247 424 m[0]->AppendItem("->eps", 10111); 248 425 m[0]->AppendItem("->ps", 10112); … … 258 435 txt->SetTextEditable(false); 259 436 txt->SetText(""); 260 txt->SetText("StringDrawWdg/Keyboard: \n r,b,i,I (Roman,bold,italic,bolditalic) \n Size 1,2,3,4,5 ");437 txt->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)"); 261 438 262 439 mcurwin = NULL; … … 304 481 PIWindow* wp = new PIWindow(this, strg, PIWK_normal, 400, 400, 150, 150); 305 482 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); 307 498 exb->SetBinding(PIBK_fixed,PIBK_elastic,PIBK_elastic,PIBK_elastic); 308 499 wp->SetUserData(exb);
Note:
See TracChangeset
for help on using the changeset viewer.