Changeset 90 in Sophya for trunk/SophyaPI
- Timestamp:
- Mar 12, 1998, 8:06:58 PM (28 years ago)
- Location:
- trunk/SophyaPI/PI
- Files:
-
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/SophyaPI/PI/exclude
r70 r90 4 4 picontainermac.cc 5 5 pifilechomac.cc 6 pigraphmac.cc 6 7 pilistmac.cc 7 8 pimenubarmac.cc -
trunk/SophyaPI/PI/piapplgen.cc
r76 r90 54 54 #include "piapplgen.h" 55 55 56 // Variable qui contient le pointeur de l'application courante 57 // permet de recuperer la taille pref pour la fonction globale 58 static PIApplicationGen * curapp = NULL; 59 56 60 PIApplicationGen::PIApplicationGen() 57 61 :topcont(NULL), menubar(NULL), mState(0) 58 {} 62 { 63 curapp = this; 64 } 59 65 60 66 PIApplicationGen::~PIApplicationGen() … … 89 95 } 90 96 97 98 void PIApplicationPrefCompSize(int& szx, int& szy) 99 { 100 szx = szy = 10; 101 if (curapp) curapp->PrefCompSz(szx, szy); 102 return; 103 } -
trunk/SophyaPI/PI/piapplgen.h
r81 r90 30 30 virtual void AppendMenu(PIPDMenu *pdm); 31 31 32 virtual int PrefXSize() = 0; 33 virtual int PrefYSize() = 0; 32 virtual void PrefCompSz(int& szx, int& szy) = 0; 34 33 35 34 virtual void RedirectOutStream(PIConsole* cons, unsigned char va= PIVA_Def) = 0; … … 42 41 }; 43 42 43 // Fonction globale pour recuperer la taille standard des composants (taille x,y) 44 void PIApplicationPrefCompSize(int& szx, int& szy); 45 44 46 #endif -
trunk/SophyaPI/PI/piapplx.cc
r85 r90 94 94 topwdg->SetSize(MBCont()->XSize(), MBCont()->YSize()); 95 95 96 int szx, szy; 97 XtAppContext * appctx = PIXtAppCtx(szx, szy); 98 96 99 while (mStop) 97 100 { 98 Xt NextEvent(&evt);101 XtAppNextEvent(*appctx, &evt); 99 102 XtDispatchEvent(&evt); 100 103 } … … 146 149 147 150 /* --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 151 void PIApplicationX::PrefCompSz(int& szx, int& szy) 152 { 153 PIXtAppCtx(szx, szy); 154 return; 157 155 } 158 156 … … 188 186 int p[2]; 189 187 pipe(p); 190 // Redirection de stdout :188 // Redirection de stdout (fid=1) : 191 189 close(1); 192 190 dup(p[1]); … … 195 193 setlinebuf(stdout); 196 194 197 XtAddInput(p[0], (XtPointer) XtInputReadMask, redirectstream_callback, (XtPointer) streamno); 195 int szx, szy; 196 XtAppContext * appctx = PIXtAppCtx(szx, szy); 197 XtAppAddInput(*appctx, p[0], (XtPointer) XtInputReadMask, redirectstream_callback, (XtPointer) streamno); 198 198 } 199 199 … … 208 208 int p[2]; 209 209 pipe(p); 210 // Redirection de stderr :210 // Redirection de stderr (fid=0) : 211 211 close(2); 212 212 dup(p[1]); … … 215 215 setlinebuf(stderr); 216 216 217 XtAddInput(p[0], (XtPointer) XtInputReadMask, redirectstream_callback, (XtPointer) (streamno+1)); 218 } 219 217 int szx, szy; 218 XtAppContext * appctx = PIXtAppCtx(szx, szy); 219 XtAppAddInput(*appctx, p[0], (XtPointer) XtInputReadMask, redirectstream_callback, (XtPointer) (streamno+1)); 220 } 221 -
trunk/SophyaPI/PI/piapplx.h
r81 r90 19 19 virtual void SetBlocked(); 20 20 21 virtual int PrefXSize(); 22 virtual int PrefYSize(); 21 virtual void PrefCompSz(int& szx, int& szy); 23 22 24 23 virtual void RedirectOutStream(PIConsole* cons, unsigned char va= PIVA_Def); -
trunk/SophyaPI/PI/pibwdggen.h
r88 r90 96 96 97 97 protected: 98 PIGraphic * mWGrC; // PIGraphic (Contexte graphique) associe a la fenetre98 PIGraphicWin* mWGrC; // PIGraphic (Contexte graphique) associe a la fenetre 99 99 bool mAdfg; 100 100 int mDrwId; -
trunk/SophyaPI/PI/pibwdgx.cc
r80 r90 43 43 44 44 Manage(); 45 mWGrC = new PIGraphic (this); // PIGraphic (Contexte graphique) associe a la fenetre45 mWGrC = new PIGraphicX(this); // PIGraphic (Contexte graphique) associe a la fenetre 46 46 } 47 47 -
trunk/SophyaPI/PI/pigraphx.h
r71 r90 86 86 }; 87 87 88 typedef PIGraphicX PIGraphic ;88 typedef PIGraphicX PIGraphicWin; 89 89 90 90 #endif -
trunk/SophyaPI/PI/piperiodx.cc
r18 r90 1 1 #include "piperiodx.h" 2 #include "piwdgx.h" 2 3 3 4 /* Nouvelle-Fonction */ … … 8 9 pip = (PIPeriodX *)usd; 9 10 pip->DoPeriodic(); 10 id = XtAddTimeOut(pip->Interval()*1000, xttimer_action, pip); 11 int szx, szy; 12 XtAppContext * appctx = PIXtAppCtx(szx, szy); 13 id = XtAppAddTimeOut(*appctx, pip->Interval()*1000, xttimer_action, pip); 11 14 pip->SetTimerId(id); 12 15 return; … … 32 35 if (dt > 0) mDt = dt; 33 36 34 mTId = XtAddTimeOut(mDt*1000, xttimer_action, this); 37 int szx,szy; 38 XtAppContext * appctx = PIXtAppCtx(szx, szy); 39 mTId = XtAppAddTimeOut(*appctx, mDt*1000, xttimer_action, this); 35 40 mFgact = true; 36 41 return; -
trunk/SophyaPI/PI/piwdgx.cc
r79 r90 18 18 // #define DEBUG_PIWdgX 19 19 20 // Quelques variables statiques globales, Connection Display, Top Widget Xt, AppContext Xt ... 21 // et leurs fonctions d'acces 20 22 static SysDWdg top = NULL; 21 23 static Display * dpy = NULL; 22 static char appname[64];24 // static char appname[64]; 23 25 static char appclass[64]; 26 static XtAppContext appctx; 27 static int appSzX = 10; 28 static int appSzY = 10; 29 static XFontStruct * stdfnt = NULL; 30 31 /* Nouvelle-Fonction */ 32 XtAppContext* PIXtAppCtx(int& szx, int& szy) 33 { 34 szx = appSzX; szy = appSzY; 35 return(&appctx); 36 } 37 24 38 /* Nouvelle-Fonction */ 25 39 SysDWdg PIXtTopWdg() … … 458 472 459 473 474 // Ressources X si non definis 475 static 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 460 502 461 503 /* --Methode-- */ 462 504 int PIWdgX::InitXt(int narg, char *arg[]) 463 505 { 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 } 506 if (top != NULL) return(0); 507 // Initialisation ... 508 int n; 509 char *pc = "PIWdgX"; 510 char **ppc; 511 if (narg > 0) { n = narg, ppc = arg; } 512 else { ppc = &pc; n = 1; } 513 // strncpy(appname, ppc[0], 63); appname[63] = '\0'; 514 strncpy(appclass,"PeidaInt",63); appclass[63] = '\0'; 515 // top = XtAppInitialize(&appctx, appclass, NULL, 0, &n, ppc); 516 top = XtVaAppInitialize(&appctx, appclass, NULL, 0, &n, ppc, fallback_res, NULL); 517 dpy = XtDisplay(top); 518 519 // On va recuperer la fonte par defaut des composantes Motif 520 XtResource res[] = { 521 { "fontList", "FontList", XtRString, sizeof(String), 522 0, XtRString, "-*-courier-bold-*-*-*-*-*-*-*-*-*-*-*" } 523 }; 524 525 String fntname; 526 XtGetApplicationResources(top, &fntname, res, XtNumber(res), NULL, 0); 527 // scr = XDefaultScreen(dpy); 528 int count; 529 char **list; 530 char buff[256]; 531 strcpy(buff, fntname); 532 list = XListFonts(dpy, buff, 15, &count); 533 XFreeFontNames(list); 534 if (count < 1) strcpy(buff,"-*-*-*-*-*-*-*-*-*-*-*-*-*-*" ); 535 stdfnt = XLoadQueryFont(dpy, buff); 536 537 // On calcule la taille de la chaine CANCEL (6 caracteres) 538 char a[2]; 539 XCharStruct ovr; 540 int hd, fa, fd, len; // direction, font-ascent, font-descent len("CANCEL") 541 XTextExtents(stdfnt, a, 0, &hd, &fa, &fd, &ovr); 542 len = XTextWidth(stdfnt, "CANCEL", 6); 543 appSzY = (float)(fa+fd)*1.4+10; // pour les shadow 544 appSzX = (float)len*1.5; 545 // Taille multiple de 5 pixels 546 if ( (appSzX % 5) != 0 ) appSzX = 5*(appSzX/5 + 1); 547 if ( (appSzY % 5) != 0 ) appSzY = 5*(appSzY/5 + 1); 548 if(appSzY < 10) appSzY = 10; 549 if(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); 476 552 return(0); 477 553 } … … 567 643 568 644 /* --Methode-- */ 569 int PIWdgX::RequestSelection(unsigned int typ)645 unsigned int PIWdgX::RequestSelection(unsigned int typ) 570 646 { 571 647 // Pour demander le contenu du buffer de copier/coller -
trunk/SophyaPI/PI/piwdgx.h
r76 r90 58 58 virtual bool ClaimSelection(unsigned int typ=PICP_string); 59 59 virtual void SelectionLost(); 60 virtual intRequestSelection(unsigned int typ=PICP_string);60 virtual unsigned int RequestSelection(unsigned int typ=PICP_string); 61 61 virtual void* ProvideSelection(unsigned int& typ, unsigned int& len); 62 62 virtual void SelectionTransferEnd(); … … 81 81 // Utile pour avoir acces au Display et Screen X ... 82 82 SysDWdg PIXtTopWdg(); 83 XtAppContext* PIXtAppCtx(int& szx, int& szy); 83 84 Display * PIXDisplay(); 84 85 #define PIXScreen() DefaultScreen(PIXDisplay()) -
trunk/SophyaPI/PI/piwindowx.cc
r52 r90 76 76 (XtCallbackProc)popdwn_cb, (XtPointer)this); 77 77 78 if ( !fgactl)78 if (fgactl == 0) 79 79 { 80 80 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; 82 84 } 83 85
Note:
See TracChangeset
for help on using the changeset viewer.