Changeset 90 in Sophya for trunk/SophyaPI


Ignore:
Timestamp:
Mar 12, 1998, 8:06:58 PM (28 years ago)
Author:
ansari
Message:

1/ Adaptation pour modif Eric PIGraphicGen - PIGraphicWin
2/ Utilisation XtApp...() et determination de la taille preferee
des composantes graphiques Reza 12/03/98

Location:
trunk/SophyaPI/PI
Files:
12 edited

Legend:

Unmodified
Added
Removed
  • trunk/SophyaPI/PI/exclude

    r70 r90  
    44picontainermac.cc
    55pifilechomac.cc
     6pigraphmac.cc
    67pilistmac.cc
    78pimenubarmac.cc
  • trunk/SophyaPI/PI/piapplgen.cc

    r76 r90  
    5454#include "piapplgen.h"
    5555
     56// Variable qui contient le pointeur de l'application courante
     57// permet de recuperer la taille pref pour la fonction globale
     58static PIApplicationGen * curapp = NULL;
     59
    5660PIApplicationGen::PIApplicationGen()
    5761:topcont(NULL), menubar(NULL), mState(0)
    58 {}
     62{
     63curapp = this;   
     64}
    5965
    6066PIApplicationGen::~PIApplicationGen()
     
    8995}
    9096
     97
     98void     PIApplicationPrefCompSize(int& szx, int& szy)
     99{
     100szx = szy = 10;
     101if (curapp)  curapp->PrefCompSz(szx, szy);
     102return;
     103}
  • trunk/SophyaPI/PI/piapplgen.h

    r81 r90  
    3030        virtual void              AppendMenu(PIPDMenu *pdm);
    3131
    32         virtual int               PrefXSize() = 0;
    33         virtual int               PrefYSize() = 0;
     32        virtual void              PrefCompSz(int& szx, int& szy) = 0;
    3433
    3534        virtual void              RedirectOutStream(PIConsole* cons, unsigned char va= PIVA_Def)  = 0;
     
    4241};
    4342
     43//   Fonction globale pour recuperer la taille standard des composants (taille x,y)
     44void     PIApplicationPrefCompSize(int& szx, int& szy); 
     45
    4446#endif
  • trunk/SophyaPI/PI/piapplx.cc

    r85 r90  
    9494topwdg->SetSize(MBCont()->XSize(), MBCont()->YSize());
    9595
     96int szx, szy;
     97XtAppContext * appctx = PIXtAppCtx(szx, szy);
     98
    9699while (mStop)
    97100  {
    98   XtNextEvent(&evt);
     101  XtAppNextEvent(*appctx, &evt);
    99102  XtDispatchEvent(&evt);
    100103  }
     
    146149
    147150/* --Methode-- */
    148 int PIApplicationX::PrefXSize()
    149 {
    150   return(10);  // $CHECK$ A remplacer Reza 13/02/98
    151 }
    152 
    153 /* --Methode-- */
    154 int PIApplicationX::PrefYSize()
    155 {
    156   return(18);  // $CHECK$ A remplacer Reza 13/02/98
     151void PIApplicationX::PrefCompSz(int& szx, int& szy)
     152{
     153PIXtAppCtx(szx, szy);
     154return;
    157155}
    158156
     
    188186int p[2];
    189187pipe(p);
    190 // Redirection de stdout :
     188// Redirection de stdout (fid=1) : 
    191189close(1);
    192190dup(p[1]);
     
    195193setlinebuf(stdout);
    196194
    197 XtAddInput(p[0], (XtPointer) XtInputReadMask, redirectstream_callback, (XtPointer) streamno);
     195int szx, szy;
     196XtAppContext * appctx = PIXtAppCtx(szx, szy);
     197XtAppAddInput(*appctx, p[0], (XtPointer) XtInputReadMask, redirectstream_callback, (XtPointer) streamno);
    198198}
    199199
     
    208208int p[2];
    209209pipe(p);
    210 // Redirection de stderr :
     210// Redirection de stderr (fid=0) :
    211211close(2);
    212212dup(p[1]);
     
    215215setlinebuf(stderr);
    216216
    217 XtAddInput(p[0], (XtPointer) XtInputReadMask, redirectstream_callback, (XtPointer) (streamno+1));
    218 }
    219 
     217int szx, szy;
     218XtAppContext * appctx = PIXtAppCtx(szx, szy);
     219XtAppAddInput(*appctx, p[0], (XtPointer) XtInputReadMask, redirectstream_callback, (XtPointer) (streamno+1));
     220}
     221
  • trunk/SophyaPI/PI/piapplx.h

    r81 r90  
    1919  virtual void              SetBlocked();
    2020
    21   virtual int               PrefXSize();
    22   virtual int               PrefYSize();
     21  virtual void              PrefCompSz(int& szx, int& szy);
    2322
    2423  virtual void              RedirectOutStream(PIConsole* cons, unsigned char va= PIVA_Def);
  • trunk/SophyaPI/PI/pibwdggen.h

    r88 r90  
    9696
    9797protected:
    98   PIGraphic* mWGrC;  // PIGraphic (Contexte graphique) associe a la fenetre
     98  PIGraphicWin* mWGrC;  // PIGraphic (Contexte graphique) associe a la fenetre
    9999  bool mAdfg;
    100100  int mDrwId;
  • trunk/SophyaPI/PI/pibwdgx.cc

    r80 r90  
    4343
    4444Manage();
    45 mWGrC = new PIGraphic(this);   // PIGraphic (Contexte graphique) associe a la fenetre
     45mWGrC = new PIGraphicX(this);   // PIGraphic (Contexte graphique) associe a la fenetre
    4646}
    4747
  • trunk/SophyaPI/PI/pigraphx.h

    r71 r90  
    8686};
    8787
    88 typedef PIGraphicX PIGraphic;
     88typedef PIGraphicX PIGraphicWin;
    8989
    9090#endif
  • trunk/SophyaPI/PI/piperiodx.cc

    r18 r90  
    11#include "piperiodx.h"
     2#include "piwdgx.h"
    23
    34/* Nouvelle-Fonction */
     
    89pip = (PIPeriodX *)usd;
    910pip->DoPeriodic();
    10 id = XtAddTimeOut(pip->Interval()*1000, xttimer_action, pip);
     11int szx, szy;
     12XtAppContext * appctx = PIXtAppCtx(szx, szy);
     13id = XtAppAddTimeOut(*appctx, pip->Interval()*1000, xttimer_action, pip);
    1114pip->SetTimerId(id);
    1215return;
     
    3235if (dt > 0)  mDt = dt;
    3336
    34 mTId = XtAddTimeOut(mDt*1000, xttimer_action, this);
     37int szx,szy;
     38XtAppContext * appctx = PIXtAppCtx(szx, szy);
     39mTId = XtAppAddTimeOut(*appctx, mDt*1000, xttimer_action, this);
    3540mFgact = true;
    3641return;
  • trunk/SophyaPI/PI/piwdgx.cc

    r79 r90  
    1818// #define DEBUG_PIWdgX
    1919
     20// Quelques variables statiques globales, Connection Display, Top Widget Xt, AppContext Xt ...
     21// et leurs fonctions d'acces
    2022static SysDWdg  top = NULL;
    2123static Display * dpy = NULL;
    22 static char appname[64];
     24// static char appname[64];
    2325static char appclass[64];
     26static XtAppContext appctx;
     27static int appSzX = 10;
     28static int appSzY = 10;
     29static XFontStruct * stdfnt = NULL;
     30
     31/* Nouvelle-Fonction */
     32XtAppContext* PIXtAppCtx(int& szx, int& szy)
     33{
     34szx = appSzX;  szy = appSzY;
     35return(&appctx);
     36}
     37
    2438/* Nouvelle-Fonction */
    2539SysDWdg   PIXtTopWdg()
     
    458472
    459473
     474// Ressources X si non definis
     475static String fallback_res[22] = {
     476"PeidaInt*default*background:                 LightGrey" ,
     477"PeidaInt*background:                         LightGrey" ,
     478"PeidaInt*bottomShadowColor:                  Black" ,
     479"PeidaInt*default*bottomShadowColor:          Black" ,
     480"PeidaInt*Foreground:                         Black",
     481"PeidaInt*default*Foreground:                 Black",
     482"PeidaInt*topShadowColor:                     White",
     483"PeidaInt*default*topShadowColor:             White",
     484"PeidaInt*borderColor:                        Black",
     485"PeidaInt*XmLabel.borderWidth:                0",
     486"PeidaInt*XmScrollBar*background:             LightGrey",
     487"PeidaInt*XmDrawingArea*background:           Black",
     488"PeidaInt*XmPushButton*borderWidth:           0",
     489"PeidaInt*XmText*shadowThickness:             2",
     490"PeidaInt*XmText*highlightThickness:          0",
     491"PeidaInt*XmText*marginHeigt:                 0",
     492"PeidaInt*XmText*marginWidth:                 3",
     493// "PeidaInt*DefMenubar*XtNwidth:                250",
     494// "PeidaInt*DefMenubar*XtNheight:               30",
     495"PeidaInt*fontList:           -*-courier-bold-r-normal-*-12-*-*-*-*-*-ISO8859-1",
     496"PeidaInt*default*fontList:   -*-courier-bold-r-normal-*-12-*-*-*-*-*-ISO8859-1"
     497"PeidaInt*fontFamilyName:                     *-courier",   // Pas de blanc apres le nom de font
     498"PeidaInt*XmToggleButton*selectColor:         Red",
     499""
     500};
     501
    460502
    461503/* --Methode-- */
    462504int PIWdgX::InitXt(int narg, char *arg[])
    463505{
    464 if (top == NULL)   // Initialisation ... 
    465   {
    466   int n;
    467   char *pc = "PIWdgX";
    468   char **ppc;
    469   if (narg > 0)  { n = narg, ppc = arg; }
    470   else { ppc = &pc; n = 1; }
    471   strncpy(appname, ppc[0], 63); appname[63] = '\0';
    472   strncpy(appclass,"PeidaInt",63);  appclass[63] = '\0';     
    473   top = XtInitialize(appname, appclass, NULL, 0, &n, ppc);
    474   dpy = XtDisplay(top);
    475   }
     506if (top != NULL)  return(0);
     507// Initialisation ... 
     508int n;
     509char *pc = "PIWdgX";
     510char **ppc;
     511if (narg > 0)  { n = narg, ppc = arg; }
     512else { ppc = &pc; n = 1; }
     513//  strncpy(appname, ppc[0], 63); appname[63] = '\0';
     514strncpy(appclass,"PeidaInt",63);  appclass[63] = '\0';     
     515//  top = XtAppInitialize(&appctx, appclass, NULL, 0, &n, ppc);
     516top = XtVaAppInitialize(&appctx, appclass, NULL, 0, &n, ppc, fallback_res, NULL);
     517dpy = XtDisplay(top);
     518
     519// On va recuperer la fonte par defaut des composantes Motif
     520XtResource res[] = {
     521  { "fontList", "FontList", XtRString, sizeof(String),
     522    0, XtRString, "-*-courier-bold-*-*-*-*-*-*-*-*-*-*-*" }
     523};
     524
     525String fntname;
     526XtGetApplicationResources(top, &fntname, res, XtNumber(res), NULL, 0);
     527// scr = XDefaultScreen(dpy);
     528int count;
     529char **list;
     530char buff[256];
     531strcpy(buff, fntname);
     532list = XListFonts(dpy, buff, 15, &count);
     533XFreeFontNames(list);
     534if (count < 1)  strcpy(buff,"-*-*-*-*-*-*-*-*-*-*-*-*-*-*" );
     535stdfnt = XLoadQueryFont(dpy, buff);
     536
     537// On calcule la taille de la chaine CANCEL (6 caracteres)
     538char a[2];
     539XCharStruct  ovr;
     540int hd, fa, fd, len;  // direction, font-ascent, font-descent len("CANCEL")
     541XTextExtents(stdfnt, a, 0, &hd, &fa, &fd, &ovr);
     542len = XTextWidth(stdfnt, "CANCEL", 6);
     543appSzY = (float)(fa+fd)*1.4+10;  // pour les shadow
     544appSzX = (float)len*1.5;
     545// Taille multiple de 5 pixels
     546if ( (appSzX % 5) != 0 )   appSzX = 5*(appSzX/5 + 1);
     547if ( (appSzY % 5) != 0 )   appSzY = 5*(appSzY/5 + 1);
     548if(appSzY < 10) appSzY = 10;
     549if(appSzX < 30) appSzX = 30;
     550
     551// printf("PIWdgX::InitXt(Font=%s- %d %d , %d ) SzX,Y= %d %d \n", buff, fa,fd,len,appSzX, appSzY);
    476552return(0);
    477553}
     
    567643
    568644/* --Methode-- */
    569 int PIWdgX::RequestSelection(unsigned int typ)
     645unsigned int PIWdgX::RequestSelection(unsigned int typ)
    570646{
    571647// Pour demander le contenu du buffer de copier/coller
  • trunk/SophyaPI/PI/piwdgx.h

    r76 r90  
    5858  virtual bool           ClaimSelection(unsigned int typ=PICP_string);
    5959  virtual void           SelectionLost();
    60   virtual int            RequestSelection(unsigned int typ=PICP_string);
     60  virtual unsigned int   RequestSelection(unsigned int typ=PICP_string);
    6161  virtual void*          ProvideSelection(unsigned int& typ, unsigned int& len);
    6262  virtual void           SelectionTransferEnd();
     
    8181// Utile pour avoir acces au Display et Screen X ...
    8282SysDWdg   PIXtTopWdg();
     83XtAppContext* PIXtAppCtx(int& szx, int& szy);
    8384Display * PIXDisplay();
    8485#define  PIXScreen()  DefaultScreen(PIXDisplay())
  • trunk/SophyaPI/PI/piwindowx.cc

    r52 r90  
    7676                (XtCallbackProc)popdwn_cb, (XtPointer)this);
    7777
    78   if (!fgactl)
     78  if (fgactl == 0)
    7979    {
    8080    XtActionsRec desact = {"CloseWindow" ,CloseWindow};
    81     XtAddActions(&desact, 1);  fgactl = 1;
     81    int szx, szy;
     82    XtAppContext * appctx = PIXtAppCtx(szx, szy);
     83    XtAppAddActions(*appctx, &desact, 1);  fgactl = 1;
    8284    }
    8385
Note: See TracChangeset for help on using the changeset viewer.