Index: /trunk/SophyaPI/PI/picons.cc
===================================================================
--- /trunk/SophyaPI/PI/picons.cc	(revision 76)
+++ /trunk/SophyaPI/PI/picons.cc	(revision 77)
@@ -3,6 +3,15 @@
 #include <string.h>
 
+#include "pisysdep.h"
+#include PIMENU_H
 #include "picons.h"
 
+
+#define DEBUG_PICONS 1
+
+//  Le menu qui va servir a changer de fontes, couleurs, ...
+// de bouton-3
+static PIPUMenu* opmc=NULL;
+static int nb_opmc = 0;
 
 /*  --------------------------------------------------------------------------------- */
@@ -25,4 +34,5 @@
 mCmdStr = new char[CmdStrLen+1];
 mCCP = mCLC = 0;
+mDCOff = 0;
 AssocScrollBar(NULL);
 SetMsg(msg);
@@ -38,8 +48,23 @@
 ClrCmd();
 SelectFont();
+SelFgBgCol();
 mCurL = mNL-mWSzL-1; 
 mCurC = 0;
 
+// Pour le menu des options : Fontes, couleur, ...
+if (!opmc) {
+  opmc = new PIPUMenu((PIMsgHandler *)this, "OptCons");
+  opmc->AppendItem("SmallFont", 3101);
+  opmc->AppendItem("NormalFont", 3102);
+  opmc->AppendItem("LargeFont", 3103);
+  opmc->AppendItem("White-Black", 3201);
+  opmc->AppendItem("Black-White", 3202);
+  opmc->AppendItem("Black-Yellow", 3203);
+  }
+nb_opmc++;
+
 ActivateKeyboard();
+ActivateButton(1); // Pour permettre la selection 
+ActivateButton(3); // Pour afficher le menu des options (Fontes/couleur)
 Manage();
 return;
@@ -54,4 +79,6 @@
 delete[] mStrBuf;
 delete[] mCmdStr;
+nb_opmc--;
+if (nb_opmc == 0) { delete opmc;  opmc=NULL; }
 }
 
@@ -120,6 +147,11 @@
 mFHaut = mWGrC->GetFontHeight(asc, desc);
 mFLarg = mWGrC->CalcStringWidth("A");
-mWSzL = YSize()/mFHaut;
-mWSzC = XSize()/mFLarg;
+mWSzL = YSize()/mFHaut - 1;
+mWSzC = XSize()/mFLarg - 1;
+mOffL = 0;
+if (mScb) {
+  mScb->SetSize(WindNbLines());
+  mScb->SetValue(NbLines()-WindNbLines()-1);
+  }
 }
 
@@ -185,6 +217,6 @@
 void PIConsole::Resize()
 {
-mWSzL = YSize()/mFHaut;
-mWSzC = XSize()/mFLarg;
+mWSzL = YSize()/mFHaut-1;
+mWSzC = XSize()/mFLarg-1;
 if (mScb) {
   mScb->SetMinMax(0, NbLines()-1);
@@ -193,4 +225,5 @@
   }
 mOffL = 0;
+if (mScb)  mScb->SetValue(NbLines()-WindNbLines()-1);
 }
 
@@ -210,6 +243,6 @@
 if (isprint(key))  c = key;
 
-printf("PIConsole::Keyboard: Key= %d (%c) Mod= %d  NCmdL=%d (%d,%d)\n", 
-       key, c, (int)kmod, mNCmdL, mCCP, mCLC);
+//printf("PIConsole::Keyboard: Key= %d (%c) Mod= %d  NCmdL=%d (%d,%d)\n", 
+//       key, c, (int)kmod, mNCmdL, mCCP, mCLC);
 if ( (kmod == PIKM_Alt) ) {
   char buff[128];
@@ -311,4 +344,18 @@
 }
 
+
+/* --Methode-- */
+void PIConsole::But1Press(int x, int y)
+{
+printf("PIConsole::But3Press(%d %d ) \n", x, y);
+}
+
+/* --Methode-- */
+void PIConsole::But3Press(int x, int y)
+{
+opmc->SetMsgParent((PIMsgHandler*)this);
+opmc->Show(this, x, y);
+}
+
 /* --Methode-- */
 void PIConsole::CmdAddChar(int key)
@@ -384,4 +431,7 @@
                       PI_ItalicFont, PI_RomanFont};
 PIColors fgc, bgc;
+
+g->SelForeground(mFgC);
+g->SelBackground(mBgC);
 fgc =  g->GetForeground();
 bgc =  g->GetBackground();
@@ -393,6 +443,6 @@
 
 for(l=l1; l<=l2; l++) {
- y = (l-l0)*mFHaut;
- k = 0;   x = 0;
+ y = (l-l0+0.5)*mFHaut;
+ k = 0;   x = 0.5*mFLarg;
  for(j=0; j<mNC; j++) {
    if (mAtt[mLPo[l]+j] != lva) {
@@ -431,5 +481,5 @@
 void PIConsole::ClrCmd() 
 { 
-mCCP = 0; mCLC = 0; 
+mCCP = 0; mCLC = 0; mDCOff = 0;
 mCmdStr[0] = '\0'; 
 }  
@@ -453,5 +503,7 @@
   }  
 jj2 = mWSzC-j1;
-int koff = (mCCP >= jj2) ? mCCP-(jj2/2) : 0;
+if (mDCOff>=mCCP) mDCOff = 0;
+int koff = ((mCCP-mDCOff) >= jj2) ? mCCP-(jj2/2) : mDCOff;
+mDCOff = koff;
 int kmx = mCLC-koff;
 j2 = j1+kmx;
@@ -466,5 +518,5 @@
 
 strg[j] = '\0';
-printf("UpdCmdLine() %d %d - %s (%d) \n [%d %d %d] %d\n", koff,kmx,strg,j1+mCCP-koff, mWSzC, j1, jj2, mCCP-(jj2/2));
+// printf("UpdCmdLine() %d %d - %s (%d) \n [%d %d %d] %d\n", koff,kmx,strg,j1+mCCP-koff, mWSzC, j1, jj2, mCCP-(jj2/2));
 mAtt[mLPo[mNL-1]+j1+mCCP-koff] = PIVA_Reverse;    // Pour le curseur
 DisplayLines(mWGrC, l1, l2);
@@ -472,4 +524,10 @@
 }
 
+/* --Methode-- */
+void PIConsole::SelFgBgCol(PIColors fc, PIColors bc)
+{
+mFgC = fc; mBgC = bc;
+SetBackgroundColor(bc);
+}
 
 /* --Methode-- */
@@ -479,5 +537,34 @@
 printf("PIConsole::Process() UserMsg()= %d ModMsg= %d \n", (int)UserMsg(msg), 
        (int)ModMsg(msg) );
-if ((ModMsg(msg) == PIMsg_DataChanged) && (UserMsg(msg) == msgScb) ) {
+
+if (sender == opmc) { // Menu des options 
+  bool fgr = true;
+  switch (UserMsg(msg)) {
+    case 3101 :
+      SelectFont(PI_SmallSizeFont);
+      break;
+    case 3102 :
+      SelectFont(PI_NormalSizeFont);
+      break;
+    case 3103 :
+      SelectFont(PI_BigSizeFont);
+      break;
+    case 3201 :
+      SelFgBgCol(PI_Black, PI_White);
+      break;
+    case 3202 :
+      SelFgBgCol(PI_White, PI_Black);
+      break;
+    case 3203 :
+      SelFgBgCol(PI_Yellow, PI_Black);
+      break;
+    default :
+      fgr = false;
+      break;
+    }
+  if (fgr) Refresh();
+  }
+// Le traitement du scroll-bar
+else if ((ModMsg(msg) == PIMsg_DataChanged) && (UserMsg(msg) == msgScb) ) {
   off = (int)data;
   printf(" PIConsole::Process() From ScrollBar : Off=%d \n ", off);
@@ -485,5 +572,6 @@
   Refresh();
   }
-else ReSend(msg, sender, data);
+// Sinon, on retranmet le message
+else ReSend(msg, sender, data); 
 }
 
Index: /trunk/SophyaPI/PI/picons.h
===================================================================
--- /trunk/SophyaPI/PI/picons.h	(revision 76)
+++ /trunk/SophyaPI/PI/picons.h	(revision 77)
@@ -39,4 +39,6 @@
   virtual void       Resize();
   virtual void       Keyboard(int key, PIKeyModifier kmod);
+  virtual void       But1Press(int x, int y);
+  virtual void       But3Press(int x, int y);
 
           void       DebugPrint(int cont=0);
@@ -49,19 +51,23 @@
           void       ClrCmd();
           void       CmdAddChar(int key);
+          void       SelFgBgCol(PIColors fc=PI_Black, PIColors bc=PI_White);
   virtual void       Process(PIMessage msg, PIMsgHandler* sender, void* data=NULL);
 
-  int mNL, mNC;
-  int mCurL, mCurC; 
-  int mWSzL, mWSzC, mOffL;
-  int mNCmdL;
-  char* mText;
-  unsigned char* mAtt;
-  int* mLPo;
-  char* mStrBuf;
-  int mFHaut, mFLarg;
-  PIFontSize mFTaille;
-  char  mPrompt[32];
-  char* mCmdStr;
-  int mCCP, mCLC;
+  int mNL, mNC;         // Nb de lignes, colonnes total de la console
+  int mCurL, mCurC;     // Numero de ligne, colonne courante
+  int mWSzL, mWSzC;     // Taille de fenetre en lignes, colonnes
+  int mOffL;            // Offset d affichage (lignes) 
+  int mNCmdL, mLCOff;   // Nb de lignes reserve a l entree des commandes
+  int mDCOff;           // Offset (en caractere) pour l affichage de la ligne de commande
+  char* mText;          // Contenu de la console
+  unsigned char* mAtt;  // Attributs du contenu (bold, ...)
+  int* mLPo;            // Adresse des lignes ds les tableaux mText, mAtt
+  char* mStrBuf;        // Buffer 
+  int mFHaut, mFLarg;   // Hauteur, Largeur des caracteres 
+  PIFontSize mFTaille;  // Taille des caracteres 
+  PIColors mFgC, mBgC;  // Couleur Avant - arriere plan
+  char  mPrompt[32];    // Le prompt
+  char* mCmdStr;        // La commande 
+  int mCCP, mCLC;       // Position du curseur, longeur de la commande
 
 // S il y a un scroll-bar associe
