Changeset 77 in Sophya


Ignore:
Timestamp:
Feb 19, 1998, 6:05:29 PM (28 years ago)
Author:
ansari
Message:

PIConsole - Suite Reza 19/02/98

Location:
trunk/SophyaPI/PI
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/SophyaPI/PI/picons.cc

    r72 r77  
    33#include <string.h>
    44
     5#include "pisysdep.h"
     6#include PIMENU_H
    57#include "picons.h"
    68
     9
     10#define DEBUG_PICONS 1
     11
     12//  Le menu qui va servir a changer de fontes, couleurs, ...
     13// de bouton-3
     14static PIPUMenu* opmc=NULL;
     15static int nb_opmc = 0;
    716
    817/*  --------------------------------------------------------------------------------- */
     
    2534mCmdStr = new char[CmdStrLen+1];
    2635mCCP = mCLC = 0;
     36mDCOff = 0;
    2737AssocScrollBar(NULL);
    2838SetMsg(msg);
     
    3848ClrCmd();
    3949SelectFont();
     50SelFgBgCol();
    4051mCurL = mNL-mWSzL-1;
    4152mCurC = 0;
    4253
     54// Pour le menu des options : Fontes, couleur, ...
     55if (!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  }
     64nb_opmc++;
     65
    4366ActivateKeyboard();
     67ActivateButton(1); // Pour permettre la selection
     68ActivateButton(3); // Pour afficher le menu des options (Fontes/couleur)
    4469Manage();
    4570return;
     
    5479delete[] mStrBuf;
    5580delete[] mCmdStr;
     81nb_opmc--;
     82if (nb_opmc == 0) { delete opmc;  opmc=NULL; }
    5683}
    5784
     
    120147mFHaut = mWGrC->GetFontHeight(asc, desc);
    121148mFLarg = mWGrC->CalcStringWidth("A");
    122 mWSzL = YSize()/mFHaut;
    123 mWSzC = XSize()/mFLarg;
     149mWSzL = YSize()/mFHaut - 1;
     150mWSzC = XSize()/mFLarg - 1;
     151mOffL = 0;
     152if (mScb) {
     153  mScb->SetSize(WindNbLines());
     154  mScb->SetValue(NbLines()-WindNbLines()-1);
     155  }
    124156}
    125157
     
    185217void PIConsole::Resize()
    186218{
    187 mWSzL = YSize()/mFHaut;
    188 mWSzC = XSize()/mFLarg;
     219mWSzL = YSize()/mFHaut-1;
     220mWSzC = XSize()/mFLarg-1;
    189221if (mScb) {
    190222  mScb->SetMinMax(0, NbLines()-1);
     
    193225  }
    194226mOffL = 0;
     227if (mScb)  mScb->SetValue(NbLines()-WindNbLines()-1);
    195228}
    196229
     
    210243if (isprint(key))  c = key;
    211244
    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);
    214247if ( (kmod == PIKM_Alt) ) {
    215248  char buff[128];
     
    311344}
    312345
     346
     347/* --Methode-- */
     348void PIConsole::But1Press(int x, int y)
     349{
     350printf("PIConsole::But3Press(%d %d ) \n", x, y);
     351}
     352
     353/* --Methode-- */
     354void PIConsole::But3Press(int x, int y)
     355{
     356opmc->SetMsgParent((PIMsgHandler*)this);
     357opmc->Show(this, x, y);
     358}
     359
    313360/* --Methode-- */
    314361void PIConsole::CmdAddChar(int key)
     
    384431                      PI_ItalicFont, PI_RomanFont};
    385432PIColors fgc, bgc;
     433
     434g->SelForeground(mFgC);
     435g->SelBackground(mBgC);
    386436fgc =  g->GetForeground();
    387437bgc =  g->GetBackground();
     
    393443
    394444for(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;
    397447 for(j=0; j<mNC; j++) {
    398448   if (mAtt[mLPo[l]+j] != lva) {
     
    431481void PIConsole::ClrCmd()
    432482{
    433 mCCP = 0; mCLC = 0;
     483mCCP = 0; mCLC = 0; mDCOff = 0;
    434484mCmdStr[0] = '\0';
    435485
     
    453503  } 
    454504jj2 = mWSzC-j1;
    455 int koff = (mCCP >= jj2) ? mCCP-(jj2/2) : 0;
     505if (mDCOff>=mCCP) mDCOff = 0;
     506int koff = ((mCCP-mDCOff) >= jj2) ? mCCP-(jj2/2) : mDCOff;
     507mDCOff = koff;
    456508int kmx = mCLC-koff;
    457509j2 = j1+kmx;
     
    466518
    467519strg[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));
    469521mAtt[mLPo[mNL-1]+j1+mCCP-koff] = PIVA_Reverse;    // Pour le curseur
    470522DisplayLines(mWGrC, l1, l2);
     
    472524}
    473525
     526/* --Methode-- */
     527void PIConsole::SelFgBgCol(PIColors fc, PIColors bc)
     528{
     529mFgC = fc; mBgC = bc;
     530SetBackgroundColor(bc);
     531}
    474532
    475533/* --Methode-- */
     
    479537printf("PIConsole::Process() UserMsg()= %d ModMsg= %d \n", (int)UserMsg(msg),
    480538       (int)ModMsg(msg) );
    481 if ((ModMsg(msg) == PIMsg_DataChanged) && (UserMsg(msg) == msgScb) ) {
     539
     540if (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
     568else if ((ModMsg(msg) == PIMsg_DataChanged) && (UserMsg(msg) == msgScb) ) {
    482569  off = (int)data;
    483570  printf(" PIConsole::Process() From ScrollBar : Off=%d \n ", off);
     
    485572  Refresh();
    486573  }
    487 else ReSend(msg, sender, data);
     574// Sinon, on retranmet le message
     575else ReSend(msg, sender, data);
    488576}
    489577
  • trunk/SophyaPI/PI/picons.h

    r72 r77  
    3939  virtual void       Resize();
    4040  virtual void       Keyboard(int key, PIKeyModifier kmod);
     41  virtual void       But1Press(int x, int y);
     42  virtual void       But3Press(int x, int y);
    4143
    4244          void       DebugPrint(int cont=0);
     
    4951          void       ClrCmd();
    5052          void       CmdAddChar(int key);
     53          void       SelFgBgCol(PIColors fc=PI_Black, PIColors bc=PI_White);
    5154  virtual void       Process(PIMessage msg, PIMsgHandler* sender, void* data=NULL);
    5255
    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
    6672
    6773// S il y a un scroll-bar associe
Note: See TracChangeset for help on using the changeset viewer.