Changeset 79 in Sophya
- Timestamp:
- Feb 23, 1998, 7:32:03 PM (28 years ago)
- Location:
- trunk/SophyaPI/PI
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/SophyaPI/PI/picons.cc
r78 r79 45 45 mOffL = 0; 46 46 mNCmdL = 0; 47 48 // Pile de rappel des commandes 49 mRStr = NULL; 50 mNComm = NMxRecall = 0; 51 mRCindx = mRindx = 0; 52 53 // Copier/coller 54 mCPBuffer = NULL; 55 mCPBufLen = 0; 56 mCPbeginC = mCPendC = 0; 57 mCPbeginL = mCPendL = 0; 58 47 59 SetPrompt("Cmd> "); 48 60 ClrCmd(); … … 140 152 141 153 /* --Methode-- */ 142 void PIConsole::SelectFont(PIFontSize sz )154 void PIConsole::SelectFont(PIFontSize sz, bool autosz) 143 155 { 144 156 int asc, desc; … … 146 158 mFTaille = sz; 147 159 mFHaut = mWGrC->GetFontHeight(asc, desc); 148 mFLarg = mWGrC->CalcStringWidth("A");160 mFLarg = (int)mWGrC->CalcStringWidth("ABCDEFGHIJ")/10; 149 161 mWSzL = YSize()/mFHaut - 1; 150 mWSzC = XSize()/mFLarg - 1;162 mWSzC = XSize()/mFLarg - 2; 151 163 mOffL = 0; 164 if (autosz) SetSize((mWSzC+2)*mFLarg, (mWSzL+1)*mFHaut); 152 165 if (mScb) { 153 166 mScb->SetMinMax(0, NbLines()-1); … … 157 170 } 158 171 159 /* --Methode-- */ 160 void PIConsole::AcceptCmd(bool acc) 172 173 /* --Methode-- */ 174 void PIConsole::AcceptCmd(bool acc, int nmxrec) 161 175 { 162 176 int l1, l2; … … 169 183 UpdCmdLine(); 170 184 l2 = mNL-1; 185 if (nmxrec > 0) { 186 NMxRecall = (nmxrec > 5) ? nmxrec : 5; 187 mRStr = new string[NMxRecall]; 188 mNComm = mRCindx = mRindx = 0; 189 } 171 190 } 172 191 else { … … 176 195 ClrCmd(); 177 196 l1 = l2 = mNL-1; 197 delete[] mRStr; 198 mRCindx = mRindx = 0; 178 199 } 179 200 DisplayLines(mWGrC, l1, l2); … … 218 239 void PIConsole::Resize() 219 240 { 220 mWSzL = YSize()/mFHaut -1;221 mWSzC = XSize()/mFLarg -1;241 mWSzL = YSize()/mFHaut - 1; 242 mWSzC = XSize()/mFLarg - 2; 222 243 if (mScb) { 223 244 mScb->SetMinMax(0, NbLines()-1); … … 241 262 { 242 263 243 264 if (mNCmdL < 1) return; 265 266 int k; 267 bool fgfk = false; 268 269 if (kmod == PIKM_Cntl) { 270 switch (key) { 271 case 1 : // <Cntl> A 272 mCCP = 0; 273 break; 274 case 5 : // <Cntl> E 275 mCCP = mCLC; 276 break; 277 case 11 : // <Cntl> K 278 mCLC = mCCP; 279 break; 280 } 281 } 282 283 else if (kmod == PIKM_Alt) { 284 if (key == 'V' || key == 'v') RequestSelection(); // Pour coller (copier/coller) 285 else if (key == 'A' || key == 'a') { // Pour tout selectionner 286 if (ClaimSelection()) { // Definition de la zone de copie 287 SelectionLost(); 288 mCPbeginC = 0; mCPendC = mNC; 289 mCPbeginL = mNL-mWSzL-mOffL; mCPendL = mNL-mOffL; 290 } 291 else mCPbeginC = mCPendC = mCPbeginL = mCPendL = 0; 292 } 293 } 294 295 else if (kmod == PIKM_Blank) { 296 switch (key) { 297 case PIK_Return : 298 case PIK_Enter : 299 mCmdStr[mCLC] = '\0'; 300 // printf("Process()-Debug- <CR/Enter> CmdStr= %s (L=%d)\n", mCmdStr, strlen(mCmdStr) ); 301 302 // Gestion de rappel des commandes 303 mRStr[mRCindx] = mCmdStr; 304 mRCindx++; mNComm++; 305 if (mRCindx >= NMxRecall) mRCindx = 0; 306 mRindx = mRCindx; 307 308 Send( Msg(), PIMsg_OK, mCmdStr); 309 ClrCmd(); 310 break; 311 312 case PIK_BackSpace : 313 case 127 : // Touche del 314 case 8 : // Touche backspace 315 if (mCCP > 0) { 316 for(k=mCCP-1; k<mCLC-1; k++) mCmdStr[k] = mCmdStr[k+1]; 317 mCmdStr[mCLC-1] = ' '; mCCP--; mCLC--; 318 } 319 // printf("Process()-Debug- Backspace CCP,CLC= %d %d CmdStr= %s (L=%d) \n", mCCP, mCLC, 320 // mCmdStr, strlen(mCmdStr)); 321 break; 322 323 case PIK_Up : 324 case PIK_Down : 325 printf("Process()-Debug- CursorUp/Down(%d) Index= %d %d \n", key, mRindx, mRCindx); 326 if (mNComm > 0) { 327 int nmxrec = (mNComm < NMxRecall) ? mNComm : NMxRecall; 328 if (key == PIK_Up) { 329 mRindx--; 330 if (mRindx < 0) mRindx = 0; 331 } 332 else { 333 mRindx++; 334 if (mRindx >= nmxrec) mRindx= nmxrec-1; 335 } 336 mCLC = mCCP = mRStr[mRindx].length(); 337 for(k=0; k< mCLC; k++) mCmdStr[k] = mRStr[mRindx][k]; 338 mCmdStr[mCLC] = '\0'; 339 } 340 break; 341 342 case PIK_Left : 343 if (mCCP > 0) mCCP--; 344 // printf("Process()-Debug- Left CCP,CLC= %d %d \n", mCCP, mCLC); 345 break; 346 case PIK_Right : 347 if (mCCP < mCLC) mCCP++; 348 // printf("Process()-Debug- Right CCP,CLC= %d %d \n", mCCP, mCLC); 349 break; 350 default : 351 fgfk = true; 352 break; 353 } 354 } 355 if ( ( fgfk && (kmod == PIKM_Blank) ) || (kmod == PIKM_Shift) ) CmdAddChar(key); 356 UpdCmdLine(); 357 // DisplayLines(mNL-1, mNL-1); 358 return; 359 } 360 361 /* Pour debugger le code - Reza 23/02/98 244 362 #ifdef DEBUG_PICONS 245 363 if ( (kmod == PIKM_Alt) ) { … … 299 417 } 300 418 #endif 301 302 if (mNCmdL < 1) return; 303 304 int k; 305 bool fgfk = false; 306 307 if (kmod == PIKM_Cntl) { 308 switch (key) { 309 case 'A' : 310 case 'a' : 311 mCCP = 0; 312 break; 313 case 'E' : 314 case 'e' : 315 mCCP = mCLC; 316 break; 317 case 'K' : 318 case 'k' : 319 mCLC = mCCP; 320 break; 321 } 322 } 323 324 else if (kmod == PIKM_Alt) { 325 if (key == 'V' || key == 'v') RequestSelection(); // Pour coller (copier/coller) 326 } 327 328 else if (kmod == PIKM_Blank) { 329 switch (key) { 330 case PIK_Return : 331 case PIK_Enter : 332 mCmdStr[mCLC] = '\0'; 333 // printf("Process()-Debug- <CR/Enter> CmdStr= %s (L=%d)\n", mCmdStr, strlen(mCmdStr) ); 334 Send( Msg(), PIMsg_OK, mCmdStr); 335 ClrCmd(); 336 break; 337 338 case PIK_BackSpace : 339 case 127 : // Touche del 340 case 8 : // Touche backspace 341 if (mCCP > 0) { 342 for(k=mCCP-1; k<mCLC-1; k++) mCmdStr[k] = mCmdStr[k+1]; 343 mCmdStr[mCLC-1] = ' '; mCCP--; mCLC--; 344 } 345 // printf("Process()-Debug- Backspace CCP,CLC= %d %d CmdStr= %s (L=%d) \n", mCCP, mCLC, 346 // mCmdStr, strlen(mCmdStr)); 347 break; 348 case PIK_Left : 349 if (mCCP > 0) mCCP--; 350 // printf("Process()-Debug- Left CCP,CLC= %d %d \n", mCCP, mCLC); 351 break; 352 case PIK_Right : 353 if (mCCP < mCLC) mCCP++; 354 // printf("Process()-Debug- Right CCP,CLC= %d %d \n", mCCP, mCLC); 355 break; 356 default : 357 fgfk = true; 358 break; 359 } 360 } 361 if ( ( fgfk && (kmod == PIKM_Blank) ) || (kmod == PIKM_Shift) ) CmdAddChar(key); 362 UpdCmdLine(); 363 // DisplayLines(mNL-1, mNL-1); 364 return; 365 } 366 419 */ 367 420 368 421 /* --Methode-- … … 387 440 for(i=0; i<l; i++) CmdAddChar(pc[i]); 388 441 UpdCmdLine(); 442 } 443 444 /* --Methode-- */ 445 void PIConsole::SelectionLost() 446 { 447 // printf("Debug PIConsole::SelectionLost() %lx (L=%d)\n",(long)mCPBuffer, mCPBufLen); 448 if (mCPBuffer) delete[] mCPBuffer; 449 mCPBuffer = NULL; 450 mCPBufLen = 0; 451 mCPbeginC = mCPendC = 0; 452 mCPbeginL = mCPendL = 0; 453 } 454 455 /* --Methode-- */ 456 void PIConsole::SelectionTransferEnd() 457 { 458 // printf("Debug PIConsole::SelectionTransferEnd() -Rien- %lx (L=%d)\n",(long)mCPBuffer, mCPBufLen); 459 } 460 461 462 /* --Methode-- */ 463 void * PIConsole::ProvideSelection(unsigned int& typ, unsigned int& len) 464 { 465 typ = PICP_string; 466 if (!mCPBuffer) { // Il faut effectuer la copie 467 int l = (mCPendC-mCPbeginC+1) * (mCPendL-mCPbeginL); 468 if (l < 1) l = 1; 469 mCPBufLen = l; 470 mCPBuffer = new char[l+1]; 471 int i,j,k; 472 k = 0; 473 for(j=mCPbeginL; j<mCPendL; j++) { 474 for(i=mCPbeginC; i<mCPendC; i++) 475 { mCPBuffer[k] = mText[mLPo[j]+i]; k++; } 476 mCPBuffer[k] = '\n'; k++; 477 } 478 mCPBuffer[l] = '\0'; 479 } 480 // printf("PIConsole::ProvideSelection() %d-%d %d-%d -> %d (%lx)\n", mCPbeginL, mCPendL, mCPbeginC, mCPendC, 481 // mCPBufLen,(long) mCPBuffer); 482 int i; for(i=0; i<40; i++) putchar(mCPBuffer[i]); printf("\n"); 483 len = mCPBufLen; 484 return(mCPBuffer); 389 485 } 390 486 … … 404 500 } 405 501 406 /* --Methode-- */502 /* --Methode-- 407 503 void PIConsole::DebugPrint(int lp) 408 504 { … … 421 517 return; 422 518 } 519 */ 423 520 424 521 /* --Methode-- */ … … 468 565 bgc = g->GetBackground(); 469 566 470 l0 = mNL-mWSzL-1-mOffL; 567 int dx = mFLarg; 568 int dy = mFHaut/2; 569 int dxo2 = dx/2; 570 if (dxo2 > 3) dxo2 = 3; 571 int dyo2 = dy/2; 572 if (dyo2 > 3) dyo2 = 3; 573 574 g->DrawBox(dxo2, dyo2, (mNC+2)*mFLarg-2*dxo2, (mWSzL+1)*mFHaut-dyo2); 575 576 l0 = mNL-mWSzL-mOffL; 471 577 if (l0 < 0) l0 = 0; 472 578 if (l1 < l0) l1 = l0; 473 if ( l2 > mNL-mOffL-1) l2 = mNL-mOffL-1;474 475 for(l=l1; l< =l2; l++) {476 y = (l-l0+ 0.5)*mFHaut;477 k = 0; x = 0.5*mFLarg;579 if (++l2 > mNL-mOffL) l2 = mNL-mOffL; 580 581 for(l=l1; l<l2; l++) { 582 y = (l-l0+1)*mFHaut+dy; 583 k = 0; x = dx; 478 584 for(j=0; j<mNC; j++) { 479 585 if (mAtt[mLPo[l]+j] != lva) { … … 530 636 for(j=0; j<j1; j++) { 531 637 mText[mLPo[mNL-1]+j] = mPrompt[j]; 532 mAtt[mLPo[mNL-1]+j] = PIVA_ Bold;638 mAtt[mLPo[mNL-1]+j] = PIVA_Ital; 533 639 strg[j] = mPrompt[j]; 534 640 } … … 543 649 for(j=j1; j<j2; j++) { 544 650 mText[mLPo[mNL-1]+j] = mCmdStr[k]; 545 mAtt[mLPo[mNL-1]+j] = PIVA_ Def;651 mAtt[mLPo[mNL-1]+j] = PIVA_Bold; 546 652 strg[j] = mCmdStr[k]; 547 653 k++; … … 566 672 { 567 673 int off; 568 printf("PIConsole::Process() UserMsg()= %d ModMsg= %d \n", (int)UserMsg(msg),569 (int)ModMsg(msg) );674 // printf("PIConsole::Process() UserMsg()= %d ModMsg= %d \n", (int)UserMsg(msg), 675 // (int)ModMsg(msg) ); 570 676 571 677 if (sender == opmc) { // Menu des options … … 599 705 else if ((ModMsg(msg) == PIMsg_DataChanged) && (UserMsg(msg) == msgScb) ) { 600 706 off = (int)data; 601 printf(" PIConsole::Process() From ScrollBar : Off=%d \n ", off);707 // printf(" PIConsole::Process() From ScrollBar : Off=%d \n ", off); 602 708 SetDispOffset(off); 603 709 Refresh(); -
trunk/SophyaPI/PI/picons.h
r78 r79 23 23 void AddChar(char c, unsigned char va= PIVA_Def, bool ref=true); 24 24 void AddStr(char* strg, unsigned char va= PIVA_Def, bool ref=true); 25 // void MoveCursor(int il, int jc);26 // void DelChar(int il, int jc);27 25 28 void SelectFont(PIFontSize sz=PI_NormalSizeFont );29 void AcceptCmd(bool acc=true );26 void SelectFont(PIFontSize sz=PI_NormalSizeFont, bool autosz=true); 27 void AcceptCmd(bool acc=true, int nrecmx=20); 30 28 void SetPrompt(char* prompt); 29 31 30 inline int WindNbLines() { return mWSzL; } 32 31 inline int NbLines() { return mNL; } 32 33 33 void SetDispOffset(int ldeb=-1); 34 34 void AssocScrollBar(PIScrollBar* scb); … … 39 39 virtual void Resize(); 40 40 virtual void Keyboard(int key, PIKeyModifier kmod); 41 // virtual void But1Press(int x, int y);42 41 virtual void But3Press(int x, int y); 42 43 43 virtual void PasteSelection(unsigned int typ, void *pdata, unsigned int l); 44 45 void DebugPrint(int cont=0); 44 virtual void* ProvideSelection(unsigned int& typ, unsigned int& len); 45 virtual void SelectionLost(); 46 virtual void SelectionTransferEnd(); 46 47 47 48 protected: … … 72 73 int mCCP, mCLC; // Position du curseur, longeur de la commande 73 74 75 // Pour le rappel des commandes 76 int NMxRecall, mNComm; // Profondeur de la pile de rappels, nb de commandes 77 string * mRStr; // Stockage des chaines 78 int mRCindx, mRindx; // Index pour le rappel 79 80 // Gestion du buffer de copie 81 char* mCPBuffer; 82 unsigned int mCPBufLen; 83 int mCPbeginC, mCPbeginL; 84 int mCPendC, mCPendL; 85 74 86 // S il y a un scroll-bar associe 75 87 PIScrollBar* mScb; … … 96 108 inline void SetPrompt(char* prompt) 97 109 { mCons->SetPrompt(prompt); } 110 inline string GetCmdString() { return(mCons->GetCmdString()); } 98 111 99 112 inline void Refresh() { mCons->Refresh(); } -
trunk/SophyaPI/PI/pigraphx.cc
r72 r79 8 8 9 9 /* Variables globales pour modifier les GC */ 10 #define NMAXFONTSZ 510 #define NMAXFONTSZ 7 11 11 static XFontStruct * fntst[NMAXFONTSZ][3]; 12 static int fntsz[NMAXFONTSZ] = {8,10,12,14,16 };12 static int fntsz[NMAXFONTSZ] = {8,10,12,14,16,20,24}; 13 13 static PIFontAtt fntatt[3] = { PI_RomanFont, PI_BoldFont, PI_ItalicFont }; 14 14 #define NMAXCOL 10 … … 358 358 { 359 359 case PI_SmallSizeFont: 360 i = 0;360 i = 1; 361 361 break; 362 362 case PI_NormalSizeFont: 363 i = 2;363 i = 3; 364 364 break; 365 365 case PI_BigSizeFont: 366 i = 4;366 i = 5; 367 367 break; 368 368 default: … … 550 550 static XtResource resources[] = { 551 551 { "fontFamilyName", "FontFamilyName", XtRString, sizeof(String), 552 /*XtOffset(apdp, fntFam)*/ 0, XtRString, "*- helvetica" }552 /*XtOffset(apdp, fntFam)*/ 0, XtRString, "*-courier" } 553 553 }; 554 554 … … 585 585 if (count < 5) 586 586 { 587 printf("PIGraphicX::Init %d fonts found for %s , switching to helvetica\n",587 printf("PIGraphicX::Init %d fonts found for %s , switching to courier\n", 588 588 count, apd.fntFam); 589 apd.fntFam = "*- helvetica";589 apd.fntFam = "*-courier"; 590 590 } 591 591 sprintf(buff,"-%s-%s-*-*-*-*-*-*-*-*-*", apd.fntFam, fnbi_b[0]); -
trunk/SophyaPI/PI/pihisto2d.cc
r76 r79 28 28 if (!mDrawer) return; 29 29 if (mDrawer->LimitsFixed()) return; 30 if (!mHisto) return; 30 31 // Commencer par trouver nos limites 31 32 … … 48 49 PIHisto2D::Draw(PIGraphicUC* g, float /*xmin*/, float /*ymin*/, float /*xmax*/, float /*ymax*/) 49 50 { 51 if (!mHisto) return; 50 52 float hmin = mHisto->VMin(); 51 53 float hmax = mHisto->VMax(); … … 155 157 { 156 158 int i,j; 159 char str[128]; 160 161 if ((!mPih) || (!mPih->Histogram())) { 162 sprintf(str,"X=%g Y=%g ???",x,y); 163 return((string)str); 164 } 165 157 166 Histo2D* h = mPih->Histogram(); 158 char str[128]; 167 159 168 160 169 h->FindBin(x,y,i,j); … … 169 178 { 170 179 //printf("PIH2DWdg::Process(%d-%d , %lx ...) \n", UserMsg(msg), ModMsg(msg), (long)sender); 171 180 if (!mPih) return; 172 181 if (sender == optmenh2d) { // On n'attend de message que de la part du menu 173 182 int opt=6101; -
trunk/SophyaPI/PI/pistdwdgx.cc
r78 r79 485 485 int n=0; 486 486 if (val < mMin) val = mMin; 487 if (val > mMax ) val = mMax;487 if (val > mMax-mSz) val = mMax-mSz; 488 488 Arg warg[2]; 489 489 XtSetArg(warg[n], XmNvalue, val); n++; … … 509 509 { 510 510 int n=0; 511 Arg warg[ 3];511 Arg warg[4]; 512 512 int szl; 513 513 … … 522 522 XtSetArg(warg[n], XmNpageIncrement, sz); n++; 523 523 XtSetArg(warg[n], XmNincrement, szl); n++; 524 if (mVal > mMax-sz) { 525 mVal = mMax-sz; 526 XtSetArg(warg[n], XmNvalue, mVal); n++; 527 } 524 528 XtSetValues(this->sdw, warg, n); 525 529 mSz = sz; -
trunk/SophyaPI/PI/piwdgx.cc
r76 r79 502 502 if (*targ != XA_STRING) return(FALSE); 503 503 if (!curselwdg) return(FALSE); 504 intl = 0;505 int styp = reqseltype;506 *value = curselwdg->ProvideSelection(styp, l );507 *len=l ;504 unsigned int ll = 0; 505 unsigned int styp = reqseltype; 506 *value = curselwdg->ProvideSelection(styp, ll); 507 *len=ll; 508 508 *typ = XA_STRING; 509 509 *format = 8; … … 529 529 XtPointer value, unsigned long* len, int* format ) 530 530 { 531 printf("forXt_SelectionValue()/Debug: %lx %lx - %lx - %d (%d %d %d)\n", (unsigned long)w,532 (unsigned long)usd, (unsigned long)value, (*len), curseltype, reqseltype, provseltype);533 531 if ( (value != NULL) && (*len > 0) ) 534 532 ((PIWdgX*)usd)->PasteSelection(provseltype, (void*)value, (*len)) ; … … 544 542 if (XtOwnSelection(XtWdg(), XA_PRIMARY, PIXGetLastEventTime(), forXt_ConvertSelection, 545 543 forXt_LoseSelection, forXt_DoneSelection) ) { 544 #ifdef DEBUG_PIWdgX 546 545 printf("PIWdgX::ClaimSelection(%d) - OK (Wdg= %lx)\n", typ, (unsigned long)this); 546 #endif 547 547 curselwdg = this; 548 548 curseltype = (typ != 0) ? typ : PICP_string; … … 550 550 } 551 551 else { 552 #ifdef DEBUG_PIWdgX 552 553 printf("PIWdgX::ClaimSelection() - Probleme (Wdg= %lx)\n", (unsigned long)this); 554 #endif 553 555 curselwdg = NULL; 554 556 curseltype = PICP_string; … … 561 563 // Appele quand le PIWdg perd la possession du buffer copier/coller 562 564 { 563 printf("PIWdgX::SelectionLost() Ne fait rien !(Wdg= %lx - %lx) \n", 564 (unsigned long)this, (unsigned long)curselwdg); 565 return; 565 566 } 566 567 … … 569 570 { 570 571 // Pour demander le contenu du buffer de copier/coller 572 #ifdef DEBUG_PIWdgX 571 573 printf("PIWdgX::RequestSelection(%d) (Wdg= %lx - %lx) \n", typ, 572 574 (unsigned long)this, (unsigned long)curselwdg); 575 #endif 573 576 reqseltype = (typ != 0) ? typ : PICP_string; 574 577 XtGetSelectionValue(XtWdg(), XA_PRIMARY, XA_STRING, forXt_SelectionValue, … … 585 588 // Renvoie le pointeur de cette zone, sa taille et son typ 586 589 { 587 rs = new char[ 80];590 rs = new char[128]; 588 591 sprintf(rs, "Test-of-PIWdgX::ProvideSelection(%d)- %lx", typ,(long)rs); 589 592 len = strlen(rs); … … 594 597 void PIWdgX::SelectionTransferEnd() 595 598 { 596 printf("PIWdgX::SelectionTransferEnd() %lx \n", (long)rs);597 599 delete[] rs; 598 600 } … … 605 607 // Le typ de donnees fourni ainsi que les donnees et leur taille 606 608 // sont en argument 609 #ifdef DEBUG_PIWdgX 607 610 char* mbuff = new char[l+1]; 608 611 strncpy(mbuff, (char *)buff, l); … … 610 613 printf("PIWdgX::PasteSelection(%d, %lx, %d) [%s] \n", typ, (long)buff, l, mbuff); 611 614 delete[] mbuff; 612 return; 613 } 615 #endif 616 return; 617 }
Note:
See TracChangeset
for help on using the changeset viewer.