Changeset 80 in Sophya


Ignore:
Timestamp:
Feb 24, 1998, 6:07:41 PM (28 years ago)
Author:
ansari
Message:

Fin (?) PIConsole , Methode PIBaseWdg::AssignKeyboard(),
PIMsg_ResizeRequest + divers modifs - Reza 24/02/98

Location:
trunk/SophyaPI/PI
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/SophyaPI/PI/pibwdggen.h

    r71 r80  
    5151  virtual PIColors   GetBackgroundColor()                                    = 0;
    5252  virtual PIPointer  GetPointerShape()                                       = 0;
     53  virtual void       AssignKeyboard()                                        = 0;
    5354
    5455//  Fonction qui doit etre appelee pour rafraichir la fenetre
  • trunk/SophyaPI/PI/pibwdgx.cc

    r71 r80  
    161161
    162162/* --Methode-- */
     163void PIBaseWdgX::AssignKeyboard()
     164{
     165XSetInputFocus(XtDisplay (XtWdg()), XtWindow(XtWdg()), RevertToParent, PIXGetLastEventTime());
     166}
     167
     168/* --Methode-- */
    163169PIColors   PIBaseWdgX::GetBackgroundColor()
    164170{
  • trunk/SophyaPI/PI/pibwdgx.h

    r71 r80  
    3232  virtual PIColors   GetBackgroundColor();
    3333  virtual PIPointer  GetPointerShape();
     34  virtual void       AssignKeyboard();
    3435
    3536//  Appel depuis le PIXtBaseWidget uniquement (ExposeEvt de Xt )
  • trunk/SophyaPI/PI/picons.cc

    r79 r80  
    2020
    2121static int CmdStrLen = 256;
     22static int PIVA_Select = 128;
    2223
    2324/* --Methode-- */
    2425PIConsole::PIConsole(PIContainer* par, char* nom, PIMessage msg,
    25                      int nl, int nc, int sx, int sy, int px, int py) :
     26                     int nl, int nc, int sx, int sy, int px, int py, bool scb) :
    2627PIBaseWdg(par, nom, sx, sy, px, py)
    2728{
     
    3536mCCP = mCLC = 0;
    3637mDCOff = 0;
    37 AssocScrollBar(NULL);
     38
    3839SetMsg(msg);
     40
    3941int i;
    4042for(i=0; i<mNL; i++) {
     
    5456mCPBuffer = NULL;
    5557mCPBufLen = 0;
    56 mCPbeginC =  mCPendC = 0;
    57 mCPbeginL = mCPendL = 0;
     58mCPbeginC =  mCPendC = -1;
     59mCPbeginL = mCPendL = -1;
    5860
    5961SetPrompt("Cmd> ");
     
    6365mCurL = mNL-mWSzL-1;
    6466mCurC = 0;
     67
     68// Pour ajouter un scroll-bar
     69AssocScrollBar(par, nom, scb, sx, sy, px, py);
    6570
    6671// Pour le menu des options : Fontes, couleur, ...
     
    7681nb_opmc++;
    7782
    78 ActivateKeyboard();
    79 // ActivateButton(1);   Pour permettre la selection
    80 ActivateButton(3); // Pour afficher le menu des options (Fontes/couleur)
     83ActivateKeyboard();  // Gestion de l'edition
     84ActivateButton(1);   //  Action selection / copier - coller
     85ActivateMove(1);     //      "    "     " 
     86ActivateButton(2);   //      "    "     " 
     87ActivateButton(3);   // Pour afficher le menu des options (Fontes/couleur)
    8188Manage();
    8289return;
     
    9198delete[] mStrBuf;
    9299delete[] mCmdStr;
     100if (mScb) delete mScb;
    93101nb_opmc--;
    94102if (nb_opmc == 0) { delete opmc;  opmc=NULL; }
     
    152160
    153161/* --Methode-- */
    154 void PIConsole::SelectFont(PIFontSize sz, bool autosz)
     162void PIConsole::SelectFont(PIFontSize sz)
    155163{
    156164int asc, desc;
     
    162170mWSzC = XSize()/mFLarg - 2;
    163171mOffL = 0;
    164 if (autosz) SetSize((mWSzC+2)*mFLarg, (mWSzL+1)*mFHaut);
    165172if (mScb) {
    166173  mScb->SetMinMax(0, NbLines()-1);
     
    170177}
    171178
     179/* --Methode-- */
     180void PIConsole::AutoSize()
     181{
     182int dsz[2];
     183dsz[0] = (mNC+2)*mFLarg - XSize();
     184dsz[1] = (mWSzL+1)*mFHaut - YSize();
     185Send(Msg(), PIMsg_ResizeRequest, dsz);
     186SetSize((mWSzC+2)*mFLarg, (mWSzL+1)*mFHaut);
     187}
     188
     189/* --Methode-- */
     190void PIConsole::PreferedSize(int& sx, int& sy)
     191{
     192sx = (mNC+2)*mFLarg;
     193sy = (mWSzL+1)*mFHaut;
     194return;
     195}
    172196
    173197/* --Methode-- */
     
    222246}
    223247
    224 /* --Methode-- */
    225 void PIConsole::AssocScrollBar(PIScrollBar* scb)
    226 {
    227 mScb = scb;
    228 if (mScb)  {
    229   msgScb = mScb->Msg();
    230   mScb->SetMsgParent(this);
    231   mScb->SetMinMax(0, NbLines()-1);
    232   mScb->SetSize(WindNbLines());
    233   mScb->SetValue(NbLines()-WindNbLines()-1);
    234   }
    235 else msgScb = 0;
    236 }
    237248
    238249/* --Methode-- */
     
    256267}
    257268
    258 static int lines = 0;
    259269
    260270/* --Methode-- */
    261271void PIConsole::Keyboard(int key, PIKeyModifier kmod)
    262272{
     273
     274if (kmod == PIKM_Alt) {
     275  if (key == 'O' || key == 'o') {   // Menu des options
     276    opmc->SetMsgParent((PIMsgHandler*)this);
     277    opmc->Show();
     278    return;
     279    }
     280  else if (key == 'A' || key == 'a') {  // Pour tout selectionner
     281    mCPbeginC = 0; mCPendC = XSize();
     282    mCPbeginL = 0;  mCPendL = YSize();
     283    SaveSelection();
     284    return;
     285    }
     286  }
    263287
    264288if (mNCmdL < 1)  return;
     
    283307else if (kmod == PIKM_Alt) {
    284308  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     }
    293309  }
    294310
     
    323339    case PIK_Up :
    324340    case PIK_Down :
    325       printf("Process()-Debug- CursorUp/Down(%d)  Index= %d %d  \n", key, mRindx, mRCindx);
     341//      printf("Process()-Debug- CursorUp/Down(%d)  Index= %d %d  \n", key, mRindx, mRCindx);
    326342      if (mNComm > 0) {
    327343        int nmxrec = (mNComm < NMxRecall) ? mNComm : NMxRecall;
     
    361377/*   Pour debugger le code - Reza 23/02/98
    362378#ifdef DEBUG_PICONS
     379static int lines = 0;
    363380if ( (kmod == PIKM_Alt) ) {
    364381  char buff[128];
     
    419436*/
    420437
    421 /* --Methode--
     438/* --Methode-- */
    422439void PIConsole::But1Press(int x, int y)
    423440{
    424 printf("PIConsole::But1Press(%d %d ) \n", x, y);
    425 } */
     441Send(Msg(), PIMsg_Active);
     442AssignKeyboard();
     443mWGrC->SelGOMode(PI_GOXOR);
     444mWGrC->SelForeground(mFgC);
     445mCPbeginC = x;  mCPbeginL = y;
     446mCPendC = mCPendL = -1;
     447}
     448
     449/* --Methode-- */
     450void PIConsole::Ptr1Move(int x, int y)
     451{
     452if (mCPendC >= 0) mWGrC->DrawBox(mCPbeginC, mCPbeginL, mCPendC-mCPbeginC, mCPendL-mCPbeginL);
     453mCPendC = x;  mCPendL = y;
     454mWGrC->DrawBox(mCPbeginC, mCPbeginL, mCPendC-mCPbeginC, mCPendL-mCPbeginL);
     455}
     456 
     457/* --Methode-- */
     458void PIConsole::But1Release(int x, int y)
     459{
     460if ( (mCPendC >= 0) && (mCPbeginC >= 0) ) {
     461  mWGrC->DrawBox(mCPbeginC, mCPbeginL, mCPendC-mCPbeginC, mCPendL-mCPbeginL);
     462  mCPendC = x;  mCPendL = y;
     463  }
     464else {
     465  mCPbeginC =  mCPendC = -1;
     466  mCPbeginL = mCPendL = -1;
     467  }
     468mWGrC->SelGOMode(PI_GOCopy);
     469mWGrC->SelForeground(mFgC);
     470SaveSelection();
     471}
     472
     473/* --Methode-- */
     474void PIConsole::But2Press(int x, int y)
     475{
     476RequestSelection();  // Pour recuperer la selection = coller (copier/coller)
     477}
    426478
    427479/* --Methode-- */
     
    446498{
    447499// printf("Debug PIConsole::SelectionLost() %lx (L=%d)\n",(long)mCPBuffer, mCPBufLen);
    448 if (mCPBuffer) delete[] mCPBuffer; 
     500if (!mCPBuffer) return;
     501delete[] mCPBuffer; 
    449502mCPBuffer = NULL;
    450503mCPBufLen = 0;
    451 mCPbeginC =  mCPendC = 0;
    452 mCPbeginL = mCPendL = 0;
     504mCPbeginC =  mCPendC = -1;
     505mCPbeginL = mCPendL = -1;
     506int i,j;
     507int l1,l2;
     508l1 = mNL+1; l2 = -1;
     509for(i=0; i<mNL; i++)   // On enleve le bit select a tous les caracteres
     510  for(j=0; j<mNC; j++)
     511    if ( mAtt[mLPo[i]+j] & PIVA_Select) {
     512      if (l1 > i)  l1 = i;
     513      if (l2 < i)  l2 = i;
     514      mAtt[mLPo[i]+j] &= ~PIVA_Select ;
     515    }
     516
     517if (IsVisible() && l2 > -1)  DisplayLines(mWGrC, l1, l2);
     518return;
    453519}
    454520
     
    464530{
    465531typ = 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");
    483532len = mCPBufLen;
    484533return(mCPBuffer);
    485534}
    486535
    487 /* --Methode-- */
    488 void PIConsole::CmdAddChar(int key)
    489 {
    490   int k, kmx;
    491   if ( (mCCP < CmdStrLen) && isprint(key) ) {   // Ajout de caracteres
    492     if (mCCP < mCLC)  { // Insertion au milieu de la chaine
    493       kmx = (mCLC < CmdStrLen) ? mCLC : CmdStrLen-1;
    494       //      printf(" ++DBG++ C=%d L=%d MX=%d KMX=%d\n", mCCP, mCLC, CmdStrLen,kmx);
    495       for(k=kmx; k>mCCP; k--) mCmdStr[k] = mCmdStr[k-1];   mCLC = kmx+1;     
    496     }
    497     mCmdStr[mCCP] = key;  mCCP++;
    498     if (mCCP > mCLC)  mCLC = mCCP;
    499     }
    500 }
     536/* ----------------------------------------------------------------------------- */
     537/*    ---------------------- Methodes protected -------------------------        */
     538/* ----------------------------------------------------------------------------- */
     539
    501540
    502541/* --Methode--
     
    519558*/
    520559
     560//  Gestion du scroll-bar
     561static int Scb_Width = 14;
     562
     563/* --Methode-- */
     564void PIConsole::AssocScrollBar(PIContainer* par, char* nom, bool scb, int sx, int sy, int px, int py)
     565{
     566if (!scb) {
     567  mScb = NULL;
     568  msgScb = 0;
     569  SetBinding(PIBK_fixed, PIBK_fixed, PIBK_fixed, PIBK_fixed);
     570  return;   
     571}
     572
     573sx -= Scb_Width;
     574SetSize(sx, sy);
     575SetBinding(PIBK_fixed, PIBK_fixed, PIBK_fixed, PIBK_fixed);
     576char name[128];
     577strcpy(name,"ScrollBar_");
     578strncat(name, nom, 127);
     579msgScb = Msg()+55;
     580mScb = new PIScrollBar (par, name, msgScb, true, Scb_Width, sy, px+sx, py);
     581mScb->SetBinding(PIBK_free, PIBK_fixed, PIBK_fixed, PIBK_fixed);
     582 
     583mScb->SetMsgParent(this);
     584mScb->SetMinMax(0, NbLines()-1);
     585mScb->SetSize(WindNbLines());
     586mScb->SetValue(NbLines()-WindNbLines()-1);
     587}
     588
    521589/* --Methode-- */
    522590void PIConsole::ScrollUp()
     
    558626                      PI_RomanFont, PI_RomanFont, PI_BoldFont,
    559627                      PI_ItalicFont, PI_RomanFont};
    560 PIColors fgc, bgc;
     628PIColors fgc, bgc, dbgc;
    561629
    562630g->SelForeground(mFgC);
    563631g->SelBackground(mBgC);
    564632fgc =  g->GetForeground();
    565 bgc =  g->GetBackground();
     633dbgc = bgc =  g->GetBackground();
    566634
    567635int dx = mFLarg;
     
    592660     lva = mAtt[mLPo[l]+j];
    593661     g->SelFont(mFTaille, vafat[lva]);
     662     if (lva & PIVA_Select) bgc = PI_Grey;
     663     else bgc = dbgc;
    594664     if (lva & PIVA_Reverse) {
    595665       g->SelForeground(bgc);
     
    612682
    613683g->SelForeground(fgc);
    614 g->SelBackground(bgc);
    615 return;
    616 }
    617 /* --Methode-- */
    618 void PIConsole::ClrCmd()
    619 {
    620 mCCP = 0; mCLC = 0; mDCOff = 0;
    621 mCmdStr[0] = '\0';
    622 
     684g->SelBackground(dbgc);
     685return;
     686}
    623687
    624688/* --Methode-- */
    625689void PIConsole::UpdCmdLine()
    626690{
    627   char strg[260]; //debug
     691//  char strg[260];  debug
    628692int l1,l2;
    629693l1 = l2 = mNL-1;
     
    637701  mText[mLPo[mNL-1]+j] = mPrompt[j];
    638702  mAtt[mLPo[mNL-1]+j] = PIVA_Ital;
    639   strg[j] = mPrompt[j]; 
     703//  strg[j] = mPrompt[j];    debug
    640704  } 
    641705jj2 = mWSzC-j1;
     
    650714  mText[mLPo[mNL-1]+j] = mCmdStr[k];
    651715  mAtt[mLPo[mNL-1]+j] = PIVA_Bold;
    652   strg[j] = mCmdStr[k];
     716//  strg[j] = mCmdStr[k];   debug
    653717  k++;
    654718  } 
    655719
    656 strg[j] = '\0';
     720// strg[j] = '\0';   Debug
    657721// printf("UpdCmdLine() %d %d - %s (%d) \n [%d %d %d] %d\n", koff,kmx,strg,j1+mCCP-koff, mWSzC, j1, jj2, mCCP-(jj2/2));
    658722mAtt[mLPo[mNL-1]+j1+mCCP-koff] = PIVA_Reverse;    // Pour le curseur
    659723DisplayLines(mWGrC, l1, l2);
    660 
    661 }
     724}
     725
     726/* --Methode-- */
     727void PIConsole::ClrCmd()
     728{
     729mCCP = 0; mCLC = 0; mDCOff = 0;
     730mCmdStr[0] = '\0';
     731
     732
     733/* --Methode-- */
     734void PIConsole::CmdAddChar(int key)
     735{
     736  int k, kmx;
     737  if ( (mCCP < CmdStrLen) && isprint(key) ) {   // Ajout de caracteres
     738    if (mCCP < mCLC)  { // Insertion au milieu de la chaine
     739      kmx = (mCLC < CmdStrLen) ? mCLC : CmdStrLen-1;
     740      //      printf(" ++DBG++ C=%d L=%d MX=%d KMX=%d\n", mCCP, mCLC, CmdStrLen,kmx);
     741      for(k=kmx; k>mCCP; k--) mCmdStr[k] = mCmdStr[k-1];   mCLC = kmx+1;     
     742    }
     743    mCmdStr[mCCP] = key;  mCCP++;
     744    if (mCCP > mCLC)  mCLC = mCCP;
     745    }
     746}
     747
    662748
    663749/* --Methode-- */
     
    666752mFgC = fc; mBgC = bc;
    667753SetBackgroundColor(bc);
     754}
     755
     756
     757/* --Methode-- */
     758void PIConsole::SaveSelection()
     759{
     760int i,j,k,l;
     761int l1, l2, nl, nc;
     762
     763if (mCPbeginC > mCPendC) { j = mCPbeginC; mCPbeginC = mCPendC ; mCPendC = j; }
     764if (mCPbeginL > mCPendL) { j = mCPbeginL; mCPbeginL = mCPendL ; mCPendL = j; }
     765
     766nc = (mCPendC-mCPbeginC)/mFLarg;
     767nl = (mCPendL-mCPbeginL)/mFHaut;
     768// printf("*DBG* NC=%d NL=%d \n",nc, nl);
     769l1 = mNL+1; l2 = -1;
     770
     771if (mCPBuffer) {
     772  delete[] mCPBuffer; 
     773  mCPBuffer = NULL;
     774  mCPBufLen = 0;
     775  for(i=0; i<mNL; i++)   // On enleve le bit select a tous les caracteres
     776    for(j=0; j<mNC; j++)
     777      if ( mAtt[mLPo[i]+j] & PIVA_Select) {
     778        if (l1 > i)  l1 = i;
     779        if (l2 < i)  l2 = i;
     780        mAtt[mLPo[i]+j] &= ~PIVA_Select ;
     781      }
     782  }
     783
     784// printf("**DBG** Save: C= %d %d  L = %d %d \n", mCPbeginC, mCPendC, mCPbeginL, mCPendL);
     785
     786if (!ClaimSelection()) {
     787  mCPbeginC = mCPendC = -1;
     788  mCPbeginL = mCPendL = -1;
     789  return;
     790  }
     791
     792
     793// On transforme la position sur la fenetre en position en caracteres ds les buffers
     794
     795mCPbeginC = mCPbeginC/mFLarg-1;
     796mCPendC = (int) ( (float)mCPendC/(float)mFLarg-0.8 );
     797mCPbeginL = (int) ( (float)mCPbeginL/(float)mFHaut-0.5 ) ;
     798mCPendL = (int) ( (float)mCPendL/(float)mFHaut-0.3 ) ;
     799// printf("..DBG.. C= %d %d  L = %d %d ", mCPbeginC, mCPendC, mCPbeginL, mCPendL);
     800j = mNL-mWSzL-mOffL;
     801mCPbeginL += j;  mCPendL += j;
     802// printf(" -> %d %d \n", mCPbeginL, mCPendL);
     803
     804if (mCPbeginC < 0) mCPbeginC = 0;
     805if (mCPendC > mNC) mCPendC = mNC;
     806if (mCPbeginL < 0) mCPbeginL = 0;
     807if (mCPendL > mNL) mCPendL = mNL;
     808
     809if ( (nc > 0) && (nl > 0) ) {
     810  l = (mCPendC-mCPbeginC+1) * (mCPendL-mCPbeginL);
     811  if (l < 0) l = 0;
     812  mCPBufLen = l;
     813  mCPBuffer = new char[l+1]; 
     814  k = 0; 
     815  for(j=mCPbeginL; j<mCPendL; j++) {
     816    for(i=mCPbeginC; i<mCPendC; i++)  {
     817      mAtt[mLPo[j]+i] |= PIVA_Select;
     818      mCPBuffer[k] = mText[mLPo[j]+i]; k++;
     819      }
     820    mCPBuffer[k] = '\n'; k++;
     821    }
     822  mCPBuffer[l] = '\0';
     823  if (l1 > mCPbeginL) l1 = mCPbeginL;
     824  if (l2 < (mCPendL-1))  l2 = mCPendL-1;
     825  }
     826else { 
     827  l = 0;   
     828  mCPbeginC =  mCPendC = mCPbeginL = mCPendL = -1;
     829  mCPBufLen = 0;
     830  mCPBuffer = new char[10]; 
     831  mCPBuffer[0] = mCPBuffer[1] = '\0';
     832  }
     833
     834//  printf("*DBG* Save_Display %d %d \n", l1, l2);
     835
     836if (l2 > -1) DisplayLines(mWGrC, l1, l2);
    668837}
    669838
     
    680849    case 3101 :
    681850      SelectFont(PI_SmallSizeFont);
     851      AutoSize();
    682852      break;
    683853    case 3102 :
    684854      SelectFont(PI_NormalSizeFont);
     855      AutoSize();
    685856      break;
    686857    case 3103 :
    687858      SelectFont(PI_BigSizeFont);
     859      AutoSize();
    688860      break;
    689861    case 3201 :
     
    713885}
    714886
    715 /*  --------------------------------------------------------------------------------- */
    716 /*  --------------   Classe PIScConsole : Console avec ScrollBar  ------------------- */
    717 /*  --------------------------------------------------------------------------------- */
    718 
    719 static int Scb_Width = 12;
    720 static int Scb_msg = 400;
    721 
    722 /* --Methode-- */
    723 PIScConsole::PIScConsole(PIContainer* par, char* nom, PIMessage msg,
    724                      int nl, int nc, int sx, int sy, int px, int py) :
    725 PIContainer(par, nom, sx, sy, px, py)
    726 {
    727 char name[80];
    728 strcpy(name,"TextArea_");
    729 strncat(name, nom, 70);
    730 mCons = new PIConsole(this, name, msg, nl, nc, sx-Scb_Width, sy, 0, 0);
    731 mCons->SetBinding(PIBK_fixed, PIBK_fixed, PIBK_fixed, PIBK_fixed);
    732 strcpy(name,"ScrollBar_");
    733 strncat(name, nom, 70);
    734 mScb = new PIScrollBar (this, name, Scb_msg, true, Scb_Width, sy, sx-Scb_Width, 0);
    735 mScb->SetBinding(PIBK_free, PIBK_fixed, PIBK_fixed, PIBK_fixed);
    736 mCons->AssocScrollBar(mScb);
    737 Show();
    738 }
    739 
    740 /* --Methode-- */
    741 PIScConsole::~PIScConsole()
    742 {
    743 delete mCons;
    744 delete mScb;
    745 }
    746 
  • trunk/SophyaPI/PI/picons.h

    r79 r80  
    1717class PIConsole : public PIBaseWdg {
    1818public:
    19                      PIConsole(PIContainer* par, char* nom, PIMessage msg,
    20                                int nl, int nc, int sx=300, int sy=200, int px=0, int py=0);
     19                     PIConsole(PIContainer* par, char* nom, PIMessage msg, int nl, int nc,
     20                               int sx=300, int sy=200, int px=0, int py=0, bool scb=true);
    2121                     ~PIConsole();
    2222
     23// Interface d utilisation :
    2324          void       AddChar(char c, unsigned char va= PIVA_Def, bool ref=true);
    2425          void       AddStr(char* strg, unsigned char va= PIVA_Def, bool ref=true);
    2526
    26           void       SelectFont(PIFontSize sz=PI_NormalSizeFont, bool autosz=true);
     27          void       SelectFont(PIFontSize sz=PI_NormalSizeFont);
     28          void       AutoSize();
     29          void       PreferedSize(int& sx, int& sy);
    2730          void       AcceptCmd(bool acc=true, int nrecmx=20);
    2831          void       SetPrompt(char* prompt);
    2932
    3033  inline  int        WindNbLines() { return mWSzL; }
    31   inline  int        NbLines() { return mNL; }
    32 
    33           void       SetDispOffset(int ldeb=-1);
    34           void       AssocScrollBar(PIScrollBar* scb);
    35          
     34  inline  int        NbLines() { return mNL; }         
    3635  inline  string     GetCmdString() { mCmdStr[mCLC] = '\0'; return((string)mCmdStr); }
    3736
     37// Gestion des evenements input/draw
    3838  virtual void       Draw(PIGraphicGen* g);
    3939  virtual void       Resize();
    4040  virtual void       Keyboard(int key, PIKeyModifier kmod);
     41  virtual void       But1Press(int x, int y);
     42  virtual void       Ptr1Move(int x, int y);
     43  virtual void       But1Release(int x, int y);
     44  virtual void       But2Press(int x, int y);
    4145  virtual void       But3Press(int x, int y);
    4246
     47// Gestion de copier/coller
    4348  virtual void       PasteSelection(unsigned int typ, void *pdata, unsigned int l);
    4449  virtual void*      ProvideSelection(unsigned int& typ, unsigned int& len);
     
    4752
    4853protected:
     54          void       AssocScrollBar(PIContainer* par, char* nom, bool scb, int sx, int sy, int px, int py);
    4955          void       ScrollUp();
     56          void       SetDispOffset(int ldeb=-1);
    5057          void       ClearLine(int l);
    5158          void       DisplayLines(PIGraphicGen* g, int l1, int l2);
     
    5461          void       CmdAddChar(int key);
    5562          void       SelFgBgCol(PIColors fc=PI_Black, PIColors bc=PI_White);
     63          void       SaveSelection();  // Pour copier la selection dans un buffer
     64
    5665  virtual void       Process(PIMessage msg, PIMsgHandler* sender, void* data=NULL);
     66
    5767
    5868  int mNL, mNC;         // Nb de lignes, colonnes total de la console
     
    90100
    91101
    92 class PIScConsole : public PIContainer {
    93 public :
    94                      PIScConsole(PIContainer* par, char* nom, PIMessage msg,
    95                                int nl, int nc, int sx=300, int sy=200, int px=0, int py=0);
    96                      ~PIScConsole();
    97 
    98   inline  void       AddChar(char c, unsigned char va= PIVA_Def, bool ref=true)
    99                              { mCons->AddChar(c, va, ref); }
    100   inline  void       AddStr(char* strg, unsigned char va= PIVA_Def, bool ref=true)
    101                              { mCons->AddStr(strg, va, ref); }
    102 
    103   inline  void       SelectFont(PIFontSize sz=PI_NormalSizeFont)
    104                              { mCons->SelectFont(sz); }
    105 
    106   inline  void       AcceptCmd(bool acc=true)
    107                              { mCons->AcceptCmd(acc); }
    108   inline  void       SetPrompt(char* prompt)
    109                              { mCons->SetPrompt(prompt); }
    110   inline  string     GetCmdString() { return(mCons->GetCmdString()); }
    111 
    112   inline  void       Refresh() { mCons->Refresh(); }
    113 
    114   PIConsole* mCons;
    115 
    116 protected:
    117   PIScrollBar* mScb;
    118 };
    119 
    120102#endif
  • trunk/SophyaPI/PI/pimenux.cc

    r60 r80  
    360360evt.window = XtWindow(PIXtTopWdg());
    361361evt.root = DefaultRootWindow(evt.display);
    362 evt.serial = 8866559909;
     362evt.serial = PIXGetLastEventSerial();
     363evt.time = PIXGetLastEventTime();
    363364evt.send_event = False;
    364365evt.same_screen = XQueryPointer(evt.display, evt.window, &(evt.root),
     
    399400evt.x = px;
    400401evt.y = py;
    401 evt.serial = 8866559909;
     402evt.serial = PIXGetLastEventSerial();
     403evt.time = PIXGetLastEventTime();
    402404evt.send_event = False;
    403405evt.same_screen = True;
  • trunk/SophyaPI/PI/pimsghandler.h

    r52 r80  
     1#ifndef PIMSGHANDLER_H_SEEN
     2#define PIMSGHANDLER_H_SEEN
     3
    14/* Classe de gestion de messages */
    25
    36#include <stdlib.h>
    4 
    5 #ifndef PIMSGHANDLER_H_SEEN
    6 #define PIMSGHANDLER_H_SEEN
    77
    88enum {
     
    1212        PIMsg_Close         = 2,
    1313        PIMsg_Resize        = 3,
     14        PIMsg_ResizeRequest = 4,
    1415
    1516        PIMsg_Click         = 21,
  • trunk/SophyaPI/PI/piwindowgen.cc

    r76 r80  
    9090/*  avec un message ActiveWdg de la part de la fenetre              */
    9191{
    92 
    93 if ((msg == BuildMsg(Msg(), PIMsg_Close)) && (sender == this) && mAHC)
     92if (ModMsg(msg) == PIMsg_ResizeRequest) {
     93  // On change la taille de la fenetre - data est un pointeur sur entier
     94  // data[0] represente l'increment (positif ou negatif) en X, data[1] en Y
     95  int* nsz = (int*) data;
     96  SetSize(XSize()+nsz[0], YSize()+nsz[1]);
     97  return;
     98  }
     99else if ((msg == BuildMsg(Msg(), PIMsg_Close)) && (sender == this) && mAHC)
    94100  Hide();   // Action par defaut en cas de MsgClose.
    95 
    96 if (ModMsg(msg) == PIMsg_Active)
     101else if (ModMsg(msg) == PIMsg_Active)
    97102  Send(Msg(),PIMsg_Active);
    98103
Note: See TracChangeset for help on using the changeset viewer.