Changeset 75 in Sophya


Ignore:
Timestamp:
Feb 13, 1998, 5:17:14 PM (28 years ago)
Author:
ansari
Message:

Modifs interface copier/coller, et fonction PrefSize() ds PIApplication

Reza 13/02/98

Location:
trunk/SophyaPI/PI
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/SophyaPI/PI/piapplgen.h

    r18 r75  
    2727
    2828        virtual void              AppendMenu(PIPDMenu *pdm);
     29
     30        virtual int               PrefXSize() = 0;
     31        virtual int               PrefYSize() = 0;
     32
    2933protected:
    3034    PIContainer               *topcont;
  • trunk/SophyaPI/PI/piapplx.cc

    r60 r75  
    138138  }
    139139}
     140
     141
     142/* --Methode-- */
     143int PIApplicationX::PrefXSize()
     144{
     145  return(10);  // $CHECK$ A remplacer Reza 13/02/98
     146}
     147
     148/* --Methode-- */
     149int PIApplicationX::PrefYSize()
     150{
     151  return(18);  // $CHECK$ A remplacer Reza 13/02/98
     152}
     153
     154
  • trunk/SophyaPI/PI/piapplx.h

    r18 r75  
    2020  virtual void    SetBlocked();
    2121
     22  virtual int     PrefXSize();
     23  virtual int     PrefYSize();
     24
    2225  PIContainer*    MBCont() { return intcont; }
    2326protected:
  • trunk/SophyaPI/PI/piwdggen.h

    r63 r75  
    1717  PIBK_fixed = 1,
    1818  PIBK_elastic = 2
     19};
     20
     21enum PICopyPasteKind {    // Pour gerer les types d objets echange en copier/coller
     22  PICP_string = 1
    1923};
    2024
     
    6872
    6973//  Gestion de copier-coller
    70   virtual bool           ClaimSelection()=0;
    71   virtual void           LoseSelection()=0;
    72   virtual void           RequestSelection()=0;
    73   virtual void           CopyFromSelection(char *, int l)=0;
    74   virtual char*          SelectionString(int& len)=0;
     74  virtual bool           ClaimSelection(int typ=PICP_string)            = 0;
     75  virtual void           SelectionLost()                                = 0;
     76  virtual int            RequestSelection(int typ=PICP_string)          = 0;
     77  virtual void*          ProvideSelection(int& typ, int& len)           = 0;
     78  virtual void           PasteSelection(int& typ, void *, int l)        = 0;
    7579
    7680protected:
  • trunk/SophyaPI/PI/piwdgx.cc

    r63 r75  
    497497if (!curselwdg)  return(FALSE);
    498498int l;
    499 *value = curselwdg->SelectionString(l);
     499int styp = 1;
     500*value = curselwdg->ProvideSelection(styp, l);
    500501*len=l;
    501502*typ = XA_STRING;
     
    507508void forXt_LoseSelection(Widget w, Atom* sel)
    508509{
    509 if (curselwdg)  curselwdg->LoseSelection();
     510if (curselwdg)  curselwdg->SelectionLost();
    510511curselwdg = NULL;
    511512}
     
    524525printf("forXt_SelectionValue()/Debug: %lx %lx - %lx - %d \n", (unsigned long)w,
    525526       (unsigned long)usd, (unsigned long)value, (*len));
     527int styp = 1;
    526528if ( (value != NULL) && (*len > 0) )
    527   ((PIWdgX*)usd)->CopyFromSelection((char*)value, (*len)) ;
     529  ((PIWdgX*)usd)->PasteSelection(styp, (void*)value, (*len)) ;
    528530}
    529531
     
    532534// Gestion de Copier/Coller
    533535/* --Methode-- */
    534 bool PIWdgX::ClaimSelection()
     536bool PIWdgX::ClaimSelection(int typ)
     537// Pour prendre possession du buffer copier/coller
    535538{
    536539if (XtOwnSelection(XtWdg(), XA_PRIMARY, PIXGetLastEventTime(), forXt_ConvertSelection,
    537540                   forXt_LoseSelection, forXt_DoneSelection) ) {
    538   printf("PIWdgX::ClaimSelection() - OK  (Wdg= %lx)\n", (unsigned long)this);
     541  printf("PIWdgX::ClaimSelection(%d) - OK  (Wdg= %lx)\n", typ, (unsigned long)this);
    539542  curselwdg = this;
    540543  return (true);
     
    548551
    549552/* --Methode-- */
    550 void PIWdgX::LoseSelection()
    551 {
    552   printf("PIWdgX::LoseSelection()  Ne fait rien !(Wdg= %lx - %lx) \n",
     553void PIWdgX::SelectionLost()
     554// Appele quand le PIWdg perd la possession du buffer copier/coller
     555{
     556  printf("PIWdgX::SelectionLost()  Ne fait rien !(Wdg= %lx - %lx) \n",
    553557        (unsigned long)this, (unsigned long)curselwdg);
    554558  if (curselwdg == this)  curselwdg = NULL;
     
    556560
    557561/* --Methode-- */
    558 void PIWdgX::RequestSelection()
    559 {
    560 printf("PIWdgX::RequestSelection() (Wdg= %lx - %lx) \n",
     562int PIWdgX::RequestSelection(int typ)
     563{
     564// Pour demander le contenu du buffer de copier/coller
     565printf("PIWdgX::RequestSelection(%d) (Wdg= %lx - %lx) \n", typ, 
    561566        (unsigned long)this, (unsigned long)curselwdg);
    562567XtGetSelectionValue(XtWdg(), XA_PRIMARY, XA_STRING, forXt_SelectionValue,
    563568                    (XtPointer)this, PIXGetLastEventTime());
    564 }
    565 
    566 /* --Methode-- */
    567 void PIWdgX::CopyFromSelection(char * sv, int l)
    568 {
    569 char* buff = new char[l+2];
    570 strncpy(buff, sv, l);
    571 buff[l] = '\0';
    572 printf("PIWdgX::RequestSelection() L=%d [%s] \n", l, buff);
    573 delete buff;
    574 return;
    575 }
    576 
    577 /* --Methode-- */
    578 char* PIWdgX::SelectionString(int& len)
    579 {
    580 char *rs = new char[60];
    581 strcpy(rs, "Test-of-PIWdgX::SelectionString()");
     569return(1);
     570}
     571
     572
     573/* --Methode-- */
     574void* PIWdgX::ProvideSelection(int& typ, int& len)
     575// Le widget doit fournier une l zone memoire contenant la selection
     576// en un type donne
     577// Renvoie le pointeur de cette zone, sa taille et son typ
     578{
     579char *rs = new char[80];
     580sprintf(rs, "Test-of-PIWdgX::ProvideSelection(%d)", typ);
    582581len = strlen(rs);
    583582return(rs);
    584583}
     584
     585/* --Methode-- */
     586void PIWdgX::PasteSelection(int& typ, void *buff, int l)
     587{
     588// Methode appele apres que le widget ait fait RequestSelection
     589// Le typ de donnees fourni ainsi que les donnees et leur taille
     590// sont en argument
     591char* mbuff = new char[l+1];
     592strncpy(mbuff, (char *)buff, l);
     593mbuff[l] = '\0';
     594printf("PIWdgX::PasteSelection() L=%d [%s] \n", l, mbuff);
     595delete[] mbuff;
     596return;
     597}
  • trunk/SophyaPI/PI/piwdgx.h

    r63 r75  
    5656
    5757//  Gestion de copier-coller
    58   virtual bool           ClaimSelection();
    59   virtual void           LoseSelection();
    60   virtual void           RequestSelection();
    61   virtual void           CopyFromSelection(char *, int l);
    62   virtual char*          SelectionString(int& len);
     58  virtual bool           ClaimSelection(int typ=PICP_string);
     59  virtual void           SelectionLost();
     60  virtual int            RequestSelection(int typ=PICP_string);
     61  virtual void*          ProvideSelection(int& typ, int& len);
     62  virtual void           PasteSelection(int& typ, void *, int l);
    6363
    6464  inline SysDWdg XtWdg() const {return(sdw); };
Note: See TracChangeset for help on using the changeset viewer.