Changeset 77 in Sophya
- Timestamp:
- Feb 19, 1998, 6:05:29 PM (28 years ago)
- Location:
- trunk/SophyaPI/PI
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/SophyaPI/PI/picons.cc
r72 r77 3 3 #include <string.h> 4 4 5 #include "pisysdep.h" 6 #include PIMENU_H 5 7 #include "picons.h" 6 8 9 10 #define DEBUG_PICONS 1 11 12 // Le menu qui va servir a changer de fontes, couleurs, ... 13 // de bouton-3 14 static PIPUMenu* opmc=NULL; 15 static int nb_opmc = 0; 7 16 8 17 /* --------------------------------------------------------------------------------- */ … … 25 34 mCmdStr = new char[CmdStrLen+1]; 26 35 mCCP = mCLC = 0; 36 mDCOff = 0; 27 37 AssocScrollBar(NULL); 28 38 SetMsg(msg); … … 38 48 ClrCmd(); 39 49 SelectFont(); 50 SelFgBgCol(); 40 51 mCurL = mNL-mWSzL-1; 41 52 mCurC = 0; 42 53 54 // Pour le menu des options : Fontes, couleur, ... 55 if (!opmc) { 56 opmc = new PIPUMenu((PIMsgHandler *)this, "OptCons"); 57 opmc->AppendItem("SmallFont", 3101); 58 opmc->AppendItem("NormalFont", 3102); 59 opmc->AppendItem("LargeFont", 3103); 60 opmc->AppendItem("White-Black", 3201); 61 opmc->AppendItem("Black-White", 3202); 62 opmc->AppendItem("Black-Yellow", 3203); 63 } 64 nb_opmc++; 65 43 66 ActivateKeyboard(); 67 ActivateButton(1); // Pour permettre la selection 68 ActivateButton(3); // Pour afficher le menu des options (Fontes/couleur) 44 69 Manage(); 45 70 return; … … 54 79 delete[] mStrBuf; 55 80 delete[] mCmdStr; 81 nb_opmc--; 82 if (nb_opmc == 0) { delete opmc; opmc=NULL; } 56 83 } 57 84 … … 120 147 mFHaut = mWGrC->GetFontHeight(asc, desc); 121 148 mFLarg = mWGrC->CalcStringWidth("A"); 122 mWSzL = YSize()/mFHaut; 123 mWSzC = XSize()/mFLarg; 149 mWSzL = YSize()/mFHaut - 1; 150 mWSzC = XSize()/mFLarg - 1; 151 mOffL = 0; 152 if (mScb) { 153 mScb->SetSize(WindNbLines()); 154 mScb->SetValue(NbLines()-WindNbLines()-1); 155 } 124 156 } 125 157 … … 185 217 void PIConsole::Resize() 186 218 { 187 mWSzL = YSize()/mFHaut ;188 mWSzC = XSize()/mFLarg ;219 mWSzL = YSize()/mFHaut-1; 220 mWSzC = XSize()/mFLarg-1; 189 221 if (mScb) { 190 222 mScb->SetMinMax(0, NbLines()-1); … … 193 225 } 194 226 mOffL = 0; 227 if (mScb) mScb->SetValue(NbLines()-WindNbLines()-1); 195 228 } 196 229 … … 210 243 if (isprint(key)) c = key; 211 244 212 printf("PIConsole::Keyboard: Key= %d (%c) Mod= %d NCmdL=%d (%d,%d)\n",213 key, c, (int)kmod, mNCmdL, mCCP, mCLC);245 //printf("PIConsole::Keyboard: Key= %d (%c) Mod= %d NCmdL=%d (%d,%d)\n", 246 // key, c, (int)kmod, mNCmdL, mCCP, mCLC); 214 247 if ( (kmod == PIKM_Alt) ) { 215 248 char buff[128]; … … 311 344 } 312 345 346 347 /* --Methode-- */ 348 void PIConsole::But1Press(int x, int y) 349 { 350 printf("PIConsole::But3Press(%d %d ) \n", x, y); 351 } 352 353 /* --Methode-- */ 354 void PIConsole::But3Press(int x, int y) 355 { 356 opmc->SetMsgParent((PIMsgHandler*)this); 357 opmc->Show(this, x, y); 358 } 359 313 360 /* --Methode-- */ 314 361 void PIConsole::CmdAddChar(int key) … … 384 431 PI_ItalicFont, PI_RomanFont}; 385 432 PIColors fgc, bgc; 433 434 g->SelForeground(mFgC); 435 g->SelBackground(mBgC); 386 436 fgc = g->GetForeground(); 387 437 bgc = g->GetBackground(); … … 393 443 394 444 for(l=l1; l<=l2; l++) { 395 y = (l-l0 )*mFHaut;396 k = 0; x = 0 ;445 y = (l-l0+0.5)*mFHaut; 446 k = 0; x = 0.5*mFLarg; 397 447 for(j=0; j<mNC; j++) { 398 448 if (mAtt[mLPo[l]+j] != lva) { … … 431 481 void PIConsole::ClrCmd() 432 482 { 433 mCCP = 0; mCLC = 0; 483 mCCP = 0; mCLC = 0; mDCOff = 0; 434 484 mCmdStr[0] = '\0'; 435 485 } … … 453 503 } 454 504 jj2 = mWSzC-j1; 455 int koff = (mCCP >= jj2) ? mCCP-(jj2/2) : 0; 505 if (mDCOff>=mCCP) mDCOff = 0; 506 int koff = ((mCCP-mDCOff) >= jj2) ? mCCP-(jj2/2) : mDCOff; 507 mDCOff = koff; 456 508 int kmx = mCLC-koff; 457 509 j2 = j1+kmx; … … 466 518 467 519 strg[j] = '\0'; 468 printf("UpdCmdLine() %d %d - %s (%d) \n [%d %d %d] %d\n", koff,kmx,strg,j1+mCCP-koff, mWSzC, j1, jj2, mCCP-(jj2/2));520 // printf("UpdCmdLine() %d %d - %s (%d) \n [%d %d %d] %d\n", koff,kmx,strg,j1+mCCP-koff, mWSzC, j1, jj2, mCCP-(jj2/2)); 469 521 mAtt[mLPo[mNL-1]+j1+mCCP-koff] = PIVA_Reverse; // Pour le curseur 470 522 DisplayLines(mWGrC, l1, l2); … … 472 524 } 473 525 526 /* --Methode-- */ 527 void PIConsole::SelFgBgCol(PIColors fc, PIColors bc) 528 { 529 mFgC = fc; mBgC = bc; 530 SetBackgroundColor(bc); 531 } 474 532 475 533 /* --Methode-- */ … … 479 537 printf("PIConsole::Process() UserMsg()= %d ModMsg= %d \n", (int)UserMsg(msg), 480 538 (int)ModMsg(msg) ); 481 if ((ModMsg(msg) == PIMsg_DataChanged) && (UserMsg(msg) == msgScb) ) { 539 540 if (sender == opmc) { // Menu des options 541 bool fgr = true; 542 switch (UserMsg(msg)) { 543 case 3101 : 544 SelectFont(PI_SmallSizeFont); 545 break; 546 case 3102 : 547 SelectFont(PI_NormalSizeFont); 548 break; 549 case 3103 : 550 SelectFont(PI_BigSizeFont); 551 break; 552 case 3201 : 553 SelFgBgCol(PI_Black, PI_White); 554 break; 555 case 3202 : 556 SelFgBgCol(PI_White, PI_Black); 557 break; 558 case 3203 : 559 SelFgBgCol(PI_Yellow, PI_Black); 560 break; 561 default : 562 fgr = false; 563 break; 564 } 565 if (fgr) Refresh(); 566 } 567 // Le traitement du scroll-bar 568 else if ((ModMsg(msg) == PIMsg_DataChanged) && (UserMsg(msg) == msgScb) ) { 482 569 off = (int)data; 483 570 printf(" PIConsole::Process() From ScrollBar : Off=%d \n ", off); … … 485 572 Refresh(); 486 573 } 487 else ReSend(msg, sender, data); 574 // Sinon, on retranmet le message 575 else ReSend(msg, sender, data); 488 576 } 489 577 -
trunk/SophyaPI/PI/picons.h
r72 r77 39 39 virtual void Resize(); 40 40 virtual void Keyboard(int key, PIKeyModifier kmod); 41 virtual void But1Press(int x, int y); 42 virtual void But3Press(int x, int y); 41 43 42 44 void DebugPrint(int cont=0); … … 49 51 void ClrCmd(); 50 52 void CmdAddChar(int key); 53 void SelFgBgCol(PIColors fc=PI_Black, PIColors bc=PI_White); 51 54 virtual void Process(PIMessage msg, PIMsgHandler* sender, void* data=NULL); 52 55 53 int mNL, mNC; 54 int mCurL, mCurC; 55 int mWSzL, mWSzC, mOffL; 56 int mNCmdL; 57 char* mText; 58 unsigned char* mAtt; 59 int* mLPo; 60 char* mStrBuf; 61 int mFHaut, mFLarg; 62 PIFontSize mFTaille; 63 char mPrompt[32]; 64 char* mCmdStr; 65 int mCCP, mCLC; 56 int mNL, mNC; // Nb de lignes, colonnes total de la console 57 int mCurL, mCurC; // Numero de ligne, colonne courante 58 int mWSzL, mWSzC; // Taille de fenetre en lignes, colonnes 59 int mOffL; // Offset d affichage (lignes) 60 int mNCmdL, mLCOff; // Nb de lignes reserve a l entree des commandes 61 int mDCOff; // Offset (en caractere) pour l affichage de la ligne de commande 62 char* mText; // Contenu de la console 63 unsigned char* mAtt; // Attributs du contenu (bold, ...) 64 int* mLPo; // Adresse des lignes ds les tableaux mText, mAtt 65 char* mStrBuf; // Buffer 66 int mFHaut, mFLarg; // Hauteur, Largeur des caracteres 67 PIFontSize mFTaille; // Taille des caracteres 68 PIColors mFgC, mBgC; // Couleur Avant - arriere plan 69 char mPrompt[32]; // Le prompt 70 char* mCmdStr; // La commande 71 int mCCP, mCLC; // Position du curseur, longeur de la commande 66 72 67 73 // S il y a un scroll-bar associe
Note:
See TracChangeset
for help on using the changeset viewer.