Changeset 170 in Sophya


Ignore:
Timestamp:
Dec 21, 1998, 9:47:37 AM (27 years ago)
Author:
ercodmgr
Message:

Ajout classe PIEventHandler et PIDrawer3D::ZMin/Max() - Reza 21/12/98

Location:
trunk/SophyaPI/PI
Files:
12 edited

Legend:

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

    r163 r170  
    2626  lCO = 10.;  dlCO = 3.; 
    2727  v3D_obs = false;
     28  xMin = yMin = zMin = -1.; 
     29  xMax = yMax = zMax = 1.;
    2830}
    2931
     
    8587
    8688// ......................................................................
    87 // ........................  Classe PIDrawer3D ..........................
     89// .......................  Classe PIDraw3DWdg ..........................
    8890// ......................................................................
    8991
  • trunk/SophyaPI/PI/pi3ddrw.h

    r163 r170  
    3131  virtual PIGraphicUC*  SetDrwWdg(PIBaseWdgGen* drw, int x0, int y0, int dx, int dy, PIGraphicGen* g);
    3232
     33  float ZMin() const {return zMin;}
     34  float ZMax() const {return zMax;}
     35
    3336protected :
    3437  float xO, yO, zO;  // Position observateur = camera
     
    3841  float lCO, dlCO;   // Distance Camera-Centre du champ et profondeur de champ
    3942  bool v3D_obs;      // Si defini par Set3DView_Obs
     43  float zMin, zMax;  // Pour delimiter le cube 3D (avec x/yMin-Max)
    4044};
    4145
  • trunk/SophyaPI/PI/pibwdggen.h

    r163 r170  
     1// This may look like C code, but it is really -*- C++ -*-
     2// Module PI : Peida Interactive      PIBaseWdgGen
     3// Classe de base pour la creation de nouvelles composantes
     4// graphiques interactives       
     5//                        R.Ansari -  E.Aubourg 96
     6// LAL (Orsay) / IN2P3-CNRS  DAPNIA/SPP (Saclay) / CEA
     7
    18#ifndef PIBWDGGEN_H_SEEN
    29#define PIBWDGGEN_H_SEEN
     
    815#include PIGRAPHIC_H
    916#include "pigraphuc.h"
     17#include "pievthandler.h"
    1018#include "psfile.h"
    1119
     
    1523#include <vector.h>
    1624#endif
    17 
    18 enum PIKeyModifier { PIKM_Blank = 0, PIKM_Shift = 1, PIKM_Alt = 2, PIKM_Cntl = 4 } ;
    19 
    20 enum PIKeyValues { PIK_Return = 0xFF0D, PIK_Enter = 0xFF8D ,
    21                    PIK_BackSpace = 0xFF08, PIK_Delete = 0xFFFF,
    22                    PIK_Tab = 0xFF09, PIK_Escape = 0xFF1B,
    23                    PIK_Up = 0xFF52, PIK_Down = 0xFF54,
    24                    PIK_Right = 0xFF53, PIK_Left = 0xFF51,
    25                    PIK_Previous = 0xFF55, PIK_Next = 0xFF56  } ;
    2625
    2726
  • trunk/SophyaPI/PI/picmapx.cc

    r163 r170  
    6161static int NTotAllocCol = 0;
    6262
     63static int nerrallocol = 0;
     64
    6365/* --Methode-- */
    6466bool PIColorMapX::AllocColor(PIColor const& col, int index)
     
    106108  }
    107109else {
    108   printf("PIColorMapX::AllocColor() Error: Pb Allocation RGB= %d %d %d \n",
     110  nerrallocol++;
     111  if (nerrallocol < 21) printf("PIColorMapX::AllocColor() Error: Pb Allocation RGB= %d %d %d \n",
    109112         (int) col.red, (int) col.blue, (int) col.green);
     113  if (nerrallocol == 20) printf("No more  PIColorMapX::AllocColor() Errors will be reported \n");
    110114  return(false);
    111115  }
  • trunk/SophyaPI/PI/pievthandler.cc

    r167 r170  
    11// Module PI : Peida Interactive      PIEventHandler
    22// Classe Gestionnaire d'evenements (Ecran/Clavier/Souris)
    3 //                                    Reza 11/98
     3//                                    R.Ansari  12/98
     4// LAL (Orsay) / IN2P3-CNRS  DAPNIA/SPP (Saclay) / CEA
    45
     6#include "pievthandler.h"
     7
     8
     9/* --Methode-- */
     10PIEventHandler::PIEventHandler(PIMsgHandler* par, PIMessage msg)
     11        : PIMsgHandler(par)
     12{
     13SetMsg(msg);
     14curwdg = NULL;
     15event = PIEvent_None;
     16posx = posy = 0;
     17key = 0;
     18keymod = PIKM_Blank;
     19evttime = 0;
     20}
     21
     22/* --Methode-- */
     23PIEventHandler::~PIEventHandler()
     24{
     25}
     26
     27/* --Methode-- */
     28void PIEventHandler::Draw(PIGraphic*, int, int, int, int)
     29{
     30return;
     31}
     32
     33/* --Methode-- */
     34void PIEventHandler::ProcessEvent()
     35{
     36return;
     37}
     38
     39/* --Methode-- */
     40void PIEventHandler::SetCurrentWdg(PIWdg* wdg)
     41{
     42curwdg = wdg;
     43}
     44
     45
     46/* --Methode-- */
     47void PIEventHandler::SetEventInfo(PIEventMask evt, int px, int py,
     48                                  int k, PIKeyModifier km, unsigned long tm)
     49{
     50event = evt;
     51posx = px; posy = py;
     52key = k;
     53keymod = km;
     54evttime = tm;
     55}
     56
  • trunk/SophyaPI/PI/pievthandler.h

    r167 r170  
    22// Module PI : Peida Interactive      PIEventHandler
    33// Classe Gestionnaire d'evenements (Ecran/Clavier/Souris)
    4 //                                    Reza 11/98
     4//                                    R.Ansari  12/98
     5// LAL (Orsay) / IN2P3-CNRS  DAPNIA/SPP (Saclay) / CEA
    56
    67#ifndef PIEVTHANDLER_H_SEEN
    78#define PIEVTHANDLER_H_SEEN
    89
     10#include "pisysdep.h"
    911#include "pimsghandler.h"
     12#include PIWDG_H
     13#include PIGRAPHIC_H
    1014
     15
     16// ....  KeyModifier (<Shift>, <Control> , <Alt>) and special key values ....
     17enum PIKeyModifier { PIKM_Blank = 0, PIKM_Shift = 1, PIKM_Alt = 2, PIKM_Cntl = 4 } ;
     18
     19enum PIKeyValues { PIK_Return = 0xFF0D, PIK_Enter = 0xFF8D ,
     20                   PIK_BackSpace = 0xFF08, PIK_Delete = 0xFFFF,
     21                   PIK_Tab = 0xFF09, PIK_Escape = 0xFF1B,
     22                   PIK_Up = 0xFF52, PIK_Down = 0xFF54,
     23                   PIK_Right = 0xFF53, PIK_Left = 0xFF51,
     24                   PIK_Previous = 0xFF55, PIK_Next = 0xFF56  } ;
     25
     26// .......... Event Mask values ..........
     27enum PIEventMask {
     28     PIEvent_None         =  0,                  //
     29     PIEvent_Draw         =  1 << 0,             // ReDraw window
     30     PIEvent_Resize       =  1 << 1,             // window resized
     31     PIEvent_Enter        =  1 << 2,             // Pointer entered window
     32     PIEvent_Leave        =  1 << 3,             // Pointer leaved window
     33     PIEvent_But1Press    =  1 << 4,             // Button-1 Press
     34     PIEvent_But1Release  =  1 << 5,             // Button-1 Release
     35     PIEvent_But2Press    =  1 << 6,             // Button-2 Press
     36     PIEvent_But2Release  =  1 << 7,             // Button-2 Release
     37     PIEvent_But3Press    =  1 << 8,             // Button-3 Press
     38     PIEvent_But3Release  =  1 << 9,             // Button-3 Release
     39     PIEvent_PtrMove      =  1 << 14,            // Pointer moved
     40     PIEvent_Ptr1Move     =  1 << 15,            // Pointer moved with button-1
     41     PIEvent_Ptr2Move     =  1 << 16,            // Pointer moved with button-2
     42     PIEvent_Ptr3Move     =  1 << 17,            // Pointer moved with button-3
     43     PIEvent_Keyboard     =  1 << 20             // key-pressed Keyboard
     44} ;
     45
     46
     47// -----------------  Class PIEventHandler  -----------------------
    1148class PIEventHandler : public PIMsgHandler
    1249{
    1350public:
     51                        PIEventHandler(PIMsgHandler* par=NULL, PIMessage msg = 0);
     52                        ~PIEventHandler();
     53
     54  inline  void          SetMsg(PIMessage msg = 0) { myMsg=msg; }
     55  inline  PIMessage     Msg() { return (myMsg); }
     56
     57  virtual void          Draw(PIGraphic* g, int x0, int y0, int dx, int dy);
     58  virtual void          ProcessEvent();
     59
     60  virtual  void         SetCurrentWdg(PIWdg* wdg);
     61  inline  PIWdg*        CurrentWdg() { return(curwdg); }
     62
     63  virtual void          SetEventInfo(PIEventMask evt, int px, int py,
     64                                     int k, PIKeyModifier km, unsigned long tm);
     65  inline  PIEventMask   EventType() { return(event); }
     66  inline  int           GetPosX() { return(posx); } 
     67  inline  int           GetPosY() { return(posy); } 
     68  inline  int           GetKey() { return(key); }
     69  inline  PIKeyModifier GetKeyMod() { return(keymod); }
     70  inline  unsigned long GetEventTime() { return(evttime); }
     71
     72protected:
     73  PIMessage     myMsg;         // associated user message
     74
     75  PIWdg*        curwdg;        // Current PIWdg, where event originated
     76  PIEventMask   event;         // event type
     77  int           posx, posy;    // Pointer Position 
     78  int           key;           // Pressed key-code
     79  PIKeyModifier keymod;        // Pressed key-modifier (shift, Cntl, ...)
     80  unsigned long evttime;       // Event-time in ms 
    1481};
    1582
  • trunk/SophyaPI/PI/piperiodx.cc

    r114 r170  
    1111int szx, szy, szf;
    1212XtAppContext * appctx = PIXtAppCtx(szx, szy, szf);
    13 id = XtAppAddTimeOut(*appctx, pip->Interval()*1000, xttimer_action, pip);
     13id = XtAppAddTimeOut(*appctx, pip->Intervalms(), xttimer_action, pip);
    1414pip->SetTimerId(id);
    1515return;
     
    3333{
    3434if (mFgact) return;
    35 if (dt > 0)  mDt = dt;
     35if (dt > 0)  { mDt = dt;  mDtms = dt*1000; }
    3636
    3737int szx,szy,szf;
  • trunk/SophyaPI/PI/pisurfdr.cc

    r163 r170  
    5656  Set3DView((xmin+xmax)/2., (ymin+ymax)/2, zmin+(zmax-zmin)*0.40,
    5757            (xmin+xmax)/2.+D , (ymin+ymax)/2.+2*D , zmin+(zmax-zmin)*0.60, 0.25, 0.25); 
     58 
     59  xMin = xmin - 0.05*(xmax-xmin);
     60  xMax = xmax + 0.05*(xmax-xmin);
     61  yMin = ymin - 0.05*(ymax-ymin);
     62  yMax = ymax + 0.05*(ymax-ymin);
     63  zMin = zmin - 0.05*(zmax-zmin);
     64  zMax = zmax + 0.05*(zmax-zmin);
     65
    5866//  printf("PISurfaceDrawer::UpdateLimits() : %g-%g  %g-%g  %g-%g (%g) \n", xmin,xmax,ymin,ymax,zmin,zmax,D);
    5967//  printf("PISurfaceDrawer::UpdateLimits() :  %g %g %g <<- %g %g %g \n",
  • trunk/SophyaPI/PI/piwdggen.cc

    r138 r170  
    1010#include "piwdggen.h"
    1111#include "picontainergen.h"
    12 
     12#include "pievthandler.h"
    1313#include "psfile.h"
    1414
     
    181181//  ChildDel() doit etre appele par la classe qui implemente le widget
    182182// if (parent)  parent->ChildDel(this);   //  On previent le container parent
     183list<EvHand>::iterator it;
     184for(it= mDHlist.begin(); it != mDHlist.end(); it++)
     185  if ((*it).ad) delete (*it).evh;
     186for(it= mEHlist.begin(); it != mEHlist.end(); it++)
     187  if ((*it).ad) delete (*it).evh;
    183188}
    184189
     
    220225}
    221226
     227//++
     228// Titre        Gestion des Draw/Event Handler
     229//      Des Draw ou des Event Handler peuvent etre ajoute a un Widget
     230//--
     231
     232//++
     233// void AddDrawHandler(PIEventHandler* drwh, bool ad=false)
     234//      Ajout de
     235// void RemoveDrawHandler(PIEventHandler* drwh)
     236//      Suppression de
     237// void AddEventHandler(PIEventHandler* evh, unsigned long evtmask, bool ad=false)
     238//      Ajout de
     239// void RemoveEventHandler(PIEventHandler* evh)
     240//      Suppression de
     241//--
     242
     243/* --Methode-- */
     244void PIWdgGen::AddDrawHandler(PIEventHandler* drwh, bool ad)
     245{
     246EvHand eh;
     247eh.evh = drwh; eh.mask = PIEvent_Draw;  eh.ad = ad;
     248mDHlist.push_back(eh);
     249}
     250
     251/* --Methode-- */
     252void PIWdgGen::RemoveDrawHandler(PIEventHandler* drwh)
     253{
     254list<EvHand>::iterator it;
     255for(it= mDHlist.begin(); it != mDHlist.end(); it++)
     256  if ((*it).evh == drwh) { mDHlist.erase(it); break; }
     257}
     258
     259/* --Methode-- */
     260void PIWdgGen::AddEventHandler(PIEventHandler* evh, unsigned long evtmask, bool ad)
     261{
     262EvHand eh;
     263eh.evh = evh; eh.mask = evtmask;  eh.ad = ad;
     264mEHlist.push_back(eh);
     265}
     266
     267/* --Methode-- */
     268void PIWdgGen::RemoveEventHandler(PIEventHandler* evh)
     269{
     270list<EvHand>::iterator it;
     271for(it= mEHlist.begin(); it != mEHlist.end(); it++)
     272  if ((*it).evh == evh) { mEHlist.erase(it); break; }
     273}
     274
     275
    222276/* --Methode--
    223277string PIWdgGen::kindstr()
  • trunk/SophyaPI/PI/piwdggen.h

    r163 r170  
    77#define PIWDG_H_SEEN
    88
     9#include "pimsghandler.h"
     10
    911#include <string>
     12#include <list>
    1013#if defined(__KCC__)
    1114using std::string ;
     15#include <list.h>
    1216#endif
    1317
    14 #include "pimsghandler.h"
    1518
    1619void PIBeep();
     
    3033class PSFile;
    3134class PIContainerGen;
     35class PIEventHandler;
     36
    3237class PIWdgGen : public PIMsgHandler
    3338{
     
    9196  virtual void           PasteSelection(unsigned int typ, void *pdata, unsigned int l)    = 0;
    9297
     98//  Gestion des EventHandler
     99  virtual void           AddDrawHandler(PIEventHandler* drwh, bool ad=false);
     100  virtual void           RemoveDrawHandler(PIEventHandler* drwh);
     101  virtual void           AddEventHandler(PIEventHandler* evh, unsigned long evtmask, bool ad=false);
     102  virtual void           RemoveEventHandler(PIEventHandler* evh);
     103
     104// !! Devrait etre protected - mis ici a cause de cxx  Reza 12/98
     105  struct EvHand { PIEventHandler* evh; unsigned long mask;  bool ad; };
    93106protected:
    94   PIContainerGen        *parent;
     107  PIContainerGen*        parent;
    95108  PIMessage              myMsg;
    96 
     109  list<EvHand>           mDHlist;
     110  list<EvHand>           mEHlist;
    97111private:
    98112  int flag;
  • trunk/SophyaPI/PI/piwdgx.cc

    r164 r170  
    99#include <X11/CoreP.h>
    1010
     11#include <X11/keysym.h>
     12
    1113#include <Xm/Xm.h>       // A cause des container XmForm
    1214#include <Xm/Form.h>     // Idem
     
    1416#include "piwdgx.h"
    1517#include "picontainerx.h"
     18#include "pievthandler.h"
    1619
    1720
     
    734737return;
    735738}
     739
     740
     741// Declaration de l' EventHandler Xt
     742static void evthandler_piwdgx (Widget wdgp, XtPointer, XEvent* evt, Boolean* cont);
     743
     744
     745/* --Methode-- */
     746void PIWdgX::AddDrawHandler(PIEventHandler* drwh, bool ad)
     747{
     748PIWdgGen::AddDrawHandler(drwh, ad);
     749XtAddEventHandler( XtWdg(), ExposureMask, FALSE, evthandler_piwdgx, this);
     750}
     751
     752/* --Methode-- */
     753void PIWdgX::RemoveDrawHandler(PIEventHandler* drwh)
     754{
     755PIWdgGen::RemoveDrawHandler(drwh);
     756if (mEHlist.size() <= 0) XtRemoveEventHandler( XtWdg(), ExposureMask, FALSE, evthandler_piwdgx, this);
     757}
     758
     759/* --Methode-- */
     760void PIWdgX::AddEventHandler(PIEventHandler* evh, unsigned long evtmask, bool ad)
     761{
     762PIWdgGen::AddEventHandler(evh, evtmask, ad);
     763EventMask mask = 0;
     764// if (evtmask & PIEvent_Resize)  pas traite pour le moment
     765if (evtmask & PIEvent_Enter)  mask |= EnterNotify;
     766if (evtmask & PIEvent_Leave)  mask |= LeaveNotify;
     767if (evtmask & PIEvent_But1Press)  mask |= ButtonPressMask;
     768if (evtmask & PIEvent_But1Release)  mask |= ButtonRelease;
     769if (evtmask & PIEvent_But2Press)  mask |= ButtonPressMask;
     770if (evtmask & PIEvent_But2Release)  mask |= ButtonRelease;
     771if (evtmask & PIEvent_But3Press)  mask |= ButtonPressMask;
     772if (evtmask & PIEvent_But3Release)  mask |= ButtonRelease;
     773if (evtmask & PIEvent_PtrMove)  mask |= PointerMotionHintMask;
     774if (evtmask & PIEvent_Ptr1Move)  mask |= (PointerMotionHintMask | Button1MotionMask);
     775if (evtmask & PIEvent_Ptr2Move)  mask |= (PointerMotionHintMask | Button2MotionMask);
     776if (evtmask & PIEvent_Ptr3Move)  mask |= (PointerMotionHintMask | Button3MotionMask);
     777if (evtmask & PIEvent_Keyboard)  mask |= KeyPressMask;
     778XtAddEventHandler( XtWdg(), mask, FALSE, evthandler_piwdgx, this);
     779}
     780
     781/* --Methode-- */
     782void PIWdgX::RemoveEventHandler(PIEventHandler* evh)
     783{
     784PIWdgGen::RemoveEventHandler(evh);
     785if (mEHlist.size() > 0) return;
     786unsigned mask = EnterNotify;
     787mask |= LeaveNotify;
     788mask |= ButtonPressMask;
     789mask |= ButtonRelease;
     790mask |= ButtonPressMask;
     791mask |= ButtonRelease;
     792mask |= ButtonPressMask;
     793mask |= ButtonRelease;
     794mask |= PointerMotionHintMask;
     795mask |= (PointerMotionHintMask | Button1MotionMask);
     796mask |= (PointerMotionHintMask | Button2MotionMask);
     797mask |= (PointerMotionHintMask | Button3MotionMask);
     798mask |= KeyPressMask;
     799XtRemoveEventHandler( XtWdg(), mask, FALSE, evthandler_piwdgx, this);
     800}
     801
     802/* --Methode-- */
     803void PIWdgX::CallDrawHandlers(int x0, int y0, int dx, int dy)
     804{
     805PIGraphicWin* g = new PIGraphicWin(this);
     806PIEventHandler* eh;
     807list<EvHand>::iterator it;
     808for(it= mDHlist.begin(); it != mDHlist.end(); it++) {
     809  eh = (*it).evh;
     810  eh->SetCurrentWdg(this);
     811  eh->SetEventInfo(PIEvent_Draw, x0, y0, 0, PIKM_Blank, 0);
     812  g->SaveGraphicAtt();
     813  eh->Draw(g, x0, y0, dx, dy);
     814  g->RestoreGraphicAtt();
     815  }
     816delete g;
     817}
     818
     819/* --Methode-- */
     820void PIWdgX::CallEventHandlers(unsigned long evt, int px, int py,
     821                               int k, int km, unsigned long tm)
     822{
     823PIEventHandler* eh;
     824list<EvHand>::iterator it;
     825for(it= mEHlist.begin(); it != mEHlist.end(); it++) {
     826  if (!((*it).mask & evt))  continue;
     827  eh = (*it).evh;
     828  eh->SetCurrentWdg(this);
     829  eh->SetEventInfo((PIEventMask)evt, px, py, k, (PIKeyModifier)km, tm);
     830  eh->ProcessEvent();
     831  }
     832}
     833
     834
     835// -------   Event Handler Xt ----------
     836/* Nouvelle-Fonction */
     837void evthandler_piwdgx (Widget wdgp, XtPointer usd,
     838                             XEvent* evt, Boolean* cont)
     839{
     840
     841*cont = FALSE ;
     842PIWdgX* wx = (PIWdgX*)usd;
     843PIEventMask evm = PIEvent_None;
     844PIKeyModifier kmod = PIKM_Blank;
     845
     846switch (evt->type) {
     847  case Expose :
     848    wx->CallDrawHandlers(evt->xexpose.x , evt->xexpose.y , evt->xexpose.width , evt->xexpose.height);
     849    break;
     850  case EnterNotify :
     851    wx->CallEventHandlers(PIEvent_Enter, evt->xcrossing.x, evt->xcrossing.y, 0,
     852                          PIKM_Blank, evt->xcrossing.time);
     853    PIXSetLastEventTimeSerial(evt->xcrossing.time, evt->xcrossing.serial);
     854    break;
     855
     856  case LeaveNotify :
     857    wx->CallEventHandlers(PIEvent_Leave, evt->xcrossing.x, evt->xcrossing.y, 0,
     858                          PIKM_Blank, evt->xcrossing.time);
     859    PIXSetLastEventTimeSerial(evt->xcrossing.time, evt->xcrossing.serial);
     860  break;
     861
     862  case ButtonPress :
     863    if  (evt->xbutton.state & ShiftMask)   
     864      kmod = (PIKeyModifier) (kmod | PIKM_Shift);
     865    if  (evt->xbutton.state & ControlMask)
     866      kmod = (PIKeyModifier) (kmod | PIKM_Cntl);
     867    if  (evt->xbutton.state & Mod1Mask)   
     868      kmod = (PIKeyModifier) (kmod | PIKM_Alt);
     869    if (evt->xbutton.button == 1) evm = PIEvent_But1Press;
     870    else if (evt->xbutton.button == 2) evm = PIEvent_But2Press;
     871    else if (evt->xbutton.button == 3) evm = PIEvent_But3Press;
     872    wx->CallEventHandlers(evm, evt->xbutton.x, evt->xbutton.y, 0,
     873                          kmod, evt->xbutton.time);
     874    PIXSetLastEventTimeSerial(evt->xbutton.time, evt->xbutton.serial);
     875  break;
     876
     877  case ButtonRelease :
     878    if  (evt->xbutton.state & ShiftMask)   
     879      kmod = (PIKeyModifier) (kmod | PIKM_Shift);
     880    if  (evt->xbutton.state & ControlMask)
     881      kmod = (PIKeyModifier) (kmod | PIKM_Cntl);
     882    if  (evt->xbutton.state & Mod1Mask)   
     883      kmod = (PIKeyModifier) (kmod | PIKM_Alt);
     884    if (evt->xbutton.button == 1) evm = PIEvent_But1Release;
     885    else if (evt->xbutton.button == 2) evm = PIEvent_But2Release;
     886    else if (evt->xbutton.button == 3) evm = PIEvent_But3Release;
     887
     888    wx->CallEventHandlers(evm, evt->xbutton.x, evt->xbutton.y, 0,
     889                          kmod, evt->xbutton.time);
     890    PIXSetLastEventTimeSerial(evt->xbutton.time, evt->xbutton.serial);
     891  break;
     892
     893  case MotionNotify :
     894    {
     895    int xw, yw, xr, yr;
     896    unsigned int key_but;
     897    Window rw, cw;
     898    if ( evt->xmotion.is_hint == NotifyHint ) {
     899      if (!XQueryPointer( XtDisplay(wdgp), evt->xmotion.window, &rw, &cw,
     900                  &xr, &yr, &xw, &yw, &key_but) ) break ;
     901      }
     902    else { key_but =  evt->xmotion.state ; xw = evt->xmotion.x;  yw = evt->xmotion.y; }
     903    if  (key_but & Button1Mask ) evm = PIEvent_Ptr1Move;
     904    else  if (key_but & Button2Mask ) evm = PIEvent_Ptr2Move;
     905    else  if (key_but & Button3Mask ) evm = PIEvent_Ptr3Move;
     906    else if ( !(key_but & (Button4Mask|Button5Mask)) )  evm = PIEvent_PtrMove;
     907
     908    if  (key_but & ShiftMask)   kmod = (PIKeyModifier) (kmod | PIKM_Shift);
     909    if  (key_but & ControlMask) kmod = (PIKeyModifier) (kmod | PIKM_Cntl);
     910    if  (key_but & Mod1Mask)    kmod = (PIKeyModifier) (kmod | PIKM_Alt);
     911
     912    wx->CallEventHandlers(evm, xw, yw, 0, kmod, evt->xbutton.time);
     913    PIXSetLastEventTimeSerial(evt->xmotion.time, evt->xmotion.serial);   
     914    }
     915  break;
     916
     917  case KeyPress :
     918    {
     919    XComposeStatus cs;
     920    KeySym key;
     921    char buf[10];
     922    int i,nc,rkey;
     923
     924 
     925    kmod = PIKM_Blank;
     926    nc = XLookupString(&(evt->xkey), buf, 10, &key, &cs);
     927
     928    if  (evt->xkey.state & ShiftMask)   
     929      kmod = (PIKeyModifier) (kmod | PIKM_Shift);
     930    if  (evt->xkey.state & ControlMask)
     931      kmod = (PIKeyModifier) (kmod | PIKM_Cntl);
     932    if  (evt->xkey.state & Mod1Mask)   
     933      kmod = (PIKeyModifier) (kmod | PIKM_Alt);
     934    switch (key) {
     935      case XK_Return :
     936        rkey = PIK_Return;
     937      break;
     938      case XK_KP_Enter :
     939        rkey = PIK_Enter;
     940      break;
     941      case XK_Up :
     942        rkey = PIK_Up;
     943      break;
     944      case XK_Down :
     945        rkey = PIK_Down;
     946      break;
     947      case XK_Left :
     948        rkey = PIK_Left;
     949      break;
     950      case XK_Right :
     951        rkey = PIK_Right;
     952      break;
     953      case XK_Prior :
     954        rkey = PIK_Previous;
     955      break;
     956      case XK_Next :
     957        rkey = PIK_Next;
     958      break;
     959      default :
     960        rkey = 0;
     961      break;
     962    }
     963    if (rkey > 0)  wx->CallEventHandlers(PIEvent_Keyboard, evt->xkey.y, evt->xkey.x,
     964                                         rkey, kmod, evt->xkey.time);
     965    else for(i=0; i<nc; i++) 
     966            wx->CallEventHandlers(PIEvent_Keyboard, evt->xkey.y, evt->xkey.x,
     967                                 (int)(buf[i]), kmod, evt->xkey.time);
     968    PIXSetLastEventTimeSerial(evt->xkey.time, evt->xkey.serial);   
     969
     970  }
     971  break;
     972}
     973
     974return;
     975}
  • trunk/SophyaPI/PI/piwdgx.h

    r158 r170  
    1 /* Classe pour enrobage generique des widgets Xt, Mac, etc  */
    2 /*                                    Reza 10/95            */
     1// This may look like C code, but it is really -*- C++ -*-
     2// Module PI : Peida Interactive      PIWdgX
     3//                                    Reza 10/95           
     4// LAL (Orsay) / IN2P3-CNRS  DAPNIA/SPP (Saclay) / CEA
    35
    46#ifndef PIWDG_X_SEEN
     
    6264  virtual void           PasteSelection(unsigned int typ, void *, unsigned int l);
    6365
     66//  Gestion des EventHandler
     67  virtual void           AddDrawHandler(PIEventHandler* drwh, bool ad=false);
     68  virtual void           RemoveDrawHandler(PIEventHandler* drwh);
     69  virtual void           AddEventHandler(PIEventHandler* evh, unsigned long evtmask, bool ad=false);
     70  virtual void           RemoveEventHandler(PIEventHandler* evh);
     71
     72// En public, pour permettre l'acces depuis call-back Xt
     73  virtual void           CallDrawHandlers(int x0, int y0, int dx, int dy);
     74  virtual void           CallEventHandlers(unsigned long evt, int px, int py,
     75                                           int k, int km, unsigned long tm);
     76
    6477//  Usage limite a a la version X11
    6578  inline SysDWdg XtWdg() const {return(sdw); };
Note: See TracChangeset for help on using the changeset viewer.