Changeset 369 in Sophya


Ignore:
Timestamp:
Aug 9, 1999, 2:31:39 PM (26 years ago)
Author:
ercodmgr
Message:

pour le mac

Location:
trunk/SophyaPI/PI
Files:
4 added
2 deleted
27 edited

Legend:

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

    r204 r369  
    145145double minhis, maxhis, binwidth;
    146146int under,over,tothis;
    147 int *phis;
    148 int *q;
     147int_4 *phis;
     148int_4 *q;
    149149
    150150double MINDYNAMIC = 1.e-8;          /* Gamme dynamique minimale (MaxAff-MinAff)*/
  • trunk/SophyaPI/PI/piapplmac.cc

    r88 r369  
    2323
    2424PIInit piInit;
     25
     26static PIApplication* cur_piapp = NULL;
     27PIApplication* PIApplicationGetApp() { return cur_piapp; }
     28
    2529
    2630class PISIOUXAttachment : public LAttachment {
     
    7478    menubar = new PIMenubar(this, "DefMenubar");
    7579    topcont = new PIWindowMac(this, "TopLevel", PIWK_floating, sx, sy, 10, 45);
     80
     81  cur_piapp = this;
    7682}
    7783
     
    96102
    97103/* --Methode-- */
    98 int PIApplicationMac::PrefXSize()
     104void PIApplicationMac::PrefCompSz(int& szx, int& szy)
    99105{
    100   return(10);  // $CHECK$ A remplacer Reza 13/02/98
     106  szx = 10;
     107  szy = 10;
    101108}
    102109
    103110/* --Methode-- */
    104 int PIApplicationMac::PrefYSize()
     111void PIApplicationMac::ScreenSz(int& szx, int& szy)
    105112{
    106   return(18);  // $CHECK$ A remplacer Reza 13/02/98
     113  szx = 800;
     114  szy = 600;
    107115}
    108116
  • trunk/SophyaPI/PI/piapplmac.h

    r88 r369  
    1313        virtual void    Stop();
    1414       
    15   virtual int     PrefXSize();
    16   virtual int     PrefYSize();
     15        virtual void              PrefCompSz(int& szx, int& szy);
     16        virtual void              ScreenSz(int& szx, int& szy);
    1717
    1818        virtual void              RedirectOutStream(PIConsole* cons, unsigned char va= PIVA_Def);
     
    2424typedef PIApplicationMac PIApplication;
    2525
     26//  Pour recuperer un objet PIApplication
     27PIApplication* PIApplicationGetApp();
    2628#endif
  • trunk/SophyaPI/PI/pibwdgmac.h

    r88 r369  
    2424  virtual void       ActivateKeyboard();
    2525
     26//  Divers : couleur de fond, Effacement fenetre,  forme de la souris
     27  virtual void       SetBackgroundColor(PIColors col=PI_White);
    2628  virtual void       EraseWindow(int x0=0, int y0=0, int dx=0, int dy=0);
    2729  virtual void       SelPointerShape(PIPointer ptr=PI_ArrowPointer);
    28   virtual void       SetBackgroundColor(PIColors col=PI_White);
    2930  virtual PIColors   GetBackgroundColor();
    3031  virtual PIPointer  GetPointerShape();
    3132  virtual void       AssignKeyboard() {}
     33
     34// Acces aux caracteristiques du dernier evenement
     35  virtual void       GetLastEventInfo(PIKeyModifier& kmod, unsigned long& tm);
    3236
    3337protected:
  • trunk/SophyaPI/PI/pigraph3d.cc

    r204 r369  
    66#include <math.h>
    77#include "pigraph3d.h"
     8
     9#ifndef M_PI_2
     10#define M_PI_2 (M_PI/2)
     11#endif
    812
    913//++
  • trunk/SophyaPI/PI/pigraphmac.cc

    r89 r369  
    22
    33#include "pigraphmac.h"
     4#include "UDrawingState.h"
    45
    56
     
    2930
    3031/* --Methode-- */
    31 void PIGraphicMac::DrawString(PIGrCoord x, PIGrCoord y, char* s, int /*pos*/)
     32void PIGraphicMac::DrawString(PIGrCoord x, PIGrCoord y, char const* s, int /*pos*/)
    3233{
    3334  if (!mPane->FocusDraw()) {
    3435    ::MoveTo(x, y);
    3536    LStr255 ps = s;
    36     ::TextFont(applFont);
     37    StTextState saver;
     38    myFont.Apply();
    3739    ::DrawString(ps);
    3840  }
     
    4042
    4143/* --Methode-- */
    42 void PIGraphicMac::DrawOpaqueString(PIGrCoord x, PIGrCoord y, char* s, int /*pos*/)
     44void PIGraphicMac::DrawOpaqueString(PIGrCoord x, PIGrCoord y, char const* s, int /*pos*/)
    4345{
    4446  if (mPane->FocusDraw()) {
    4547    ::MoveTo(x, y);
    4648    LStr255 ps = s;
    47     ::TextFont(applFont);
     49    StTextState saver;
     50    myFont.Apply();
    4851        Rect box;
    4952        box.left = x;
     
    5255        box.right = box.left + iWidth;
    5356        int z;
    54         box.top = box.bottom + GetFontHeight(z,z);
     57        box.top = box.bottom + myFont.GetFontHeight(z,z);
    5558    ::TETextBox(s,strlen(s),&box,teForceLeft);
    5659  }
     
    114117}
    115118
    116 
    117 /* --Methode-- */
    118 void PIGraphicMac::DrawPolygon(PIGrCoord *x, PIGrCoord *y, int n)
     119/* --Methode-- */
     120void PIGraphicMac::DrawOval(PIGrCoord x0, PIGrCoord y0, PIGrCoord dx, PIGrCoord dy)
     121{
     122  if (mPane->FocusDraw()) {
     123    Rect rr = {(int)y0-(int)dy, (int)x0-(int)dx, (int)y0+(int)dy, (int)x0+(int)dx};
     124    if (rr.top  > rr.bottom) swap(rr.top,  rr.bottom);
     125    if (rr.left > rr.right)  swap(rr.left, rr.right);
     126    ::FrameOval(&rr);
     127  }
     128}
     129
     130/* --Methode-- */
     131void PIGraphicMac::DrawFOval(PIGrCoord x0, PIGrCoord y0, PIGrCoord dx, PIGrCoord dy)
     132{
     133  if (mPane->FocusDraw()) {
     134    Rect rr = {(int)y0-(int)dy, (int)x0-(int)dx, (int)y0+(int)dy, (int)x0+(int)dx};
     135    if (rr.top  > rr.bottom) swap(rr.top,  rr.bottom);
     136    if (rr.left > rr.right)  swap(rr.left, rr.right);
     137    ::PaintOval(&rr);
     138  }
     139}
     140
     141
     142/* --Methode-- */
     143void PIGraphicMac::DrawPolygon(PIGrCoord *x, PIGrCoord *y, int n, bool cinc)
    119144{
    120145  PolyHandle h = MakePoly(x,y,n);
     
    127152
    128153/* --Methode-- */
    129 void PIGraphicMac::DrawFPolygon(PIGrCoord *x, PIGrCoord *y, int n)
     154void PIGraphicMac::DrawFPolygon(PIGrCoord *x, PIGrCoord *y, int n, bool cinc)
    130155{
    131156  PolyHandle h = MakePoly(x,y,n);
     
    135160  }
    136161}
     162
     163
     164/* --Methode-- */
     165void PIGraphicMac::DrawArc(PIGrCoord x0, PIGrCoord y0, PIGrCoord dx, PIGrCoord dy,
     166                         double degdeb, double degfin)
     167{
     168  if (mPane->FocusDraw()) {
     169    Rect rr = {(int)y0-(int)dy, (int)x0-(int)dx, (int)y0+(int)dy, (int)x0+(int)dx};
     170    if (rr.top  > rr.bottom) swap(rr.top,  rr.bottom);
     171    if (rr.left > rr.right)  swap(rr.left, rr.right);
     172    ::FrameArc(&rr, degdeb, degfin-degdeb);
     173  }
     174}
     175
     176/* --Methode-- */
     177void PIGraphicMac::DrawFArc(PIGrCoord x0, PIGrCoord y0, PIGrCoord dx, PIGrCoord dy,
     178                         double degdeb, double degfin)
     179{
     180  if (mPane->FocusDraw()) {
     181    Rect rr = {(int)y0-(int)dy, (int)x0-(int)dx, (int)y0+(int)dy, (int)x0+(int)dx};
     182    if (rr.top  > rr.bottom) swap(rr.top,  rr.bottom);
     183    if (rr.left > rr.right)  swap(rr.left, rr.right);
     184    ::PaintArc(&rr, degdeb, degfin-degdeb);
     185  }
     186}
     187
    137188
    138189/* --Methode-- */
     
    364415void PIGraphicMac::SelFontSzPt(int npt, PIFontAtt att)
    365416{
    366   if (mPane->FocusDraw()) {
    367     ::TextFont(applFont);
    368     ::TextSize(npt);
    369     switch(att) {
    370       case PI_RomanFont:
    371         ::TextFace(0);
    372         break;
    373       case PI_BoldFont:
    374         ::TextFace(bold);
    375         break;
    376       case PI_ItalicFont:
    377         ::TextFace(italic);
    378         break;
    379     }
    380   }
    381   mFSize = npt;
    382   mFAtt  = att;
     417  myFont.SetFontSzPt(npt);
     418  myFont.SetFontAtt(att);
    383419}
    384420
     
    386422void PIGraphicMac::SelFont(PIFontSize sz, PIFontAtt att)
    387423{
    388   switch(sz) {
    389       case PI_SmallSizeFont:
    390         SelFontSzPt(9, att);
    391         break;
    392       case PI_NormalSizeFont:
    393         SelFontSzPt(12, att);
    394         break;
    395       case PI_BigSizeFont:
    396         SelFontSzPt(14, att);
    397         break;
    398   }
    399 }
    400 
     424  myFont.SetFontSz(sz);
     425  myFont.SetFontAtt(att);
     426}
     427
     428/* --Methode-- */
     429void PIGraphicMac::SelFont(PIFont & fnt)
     430{
     431  myFont = fnt;
     432}
    401433
    402434
     
    464496PIFontAtt  PIGraphicMac::GetFontAtt()
    465497{
    466 return (mFAtt);
     498return (myFont.GetFontAtt());
    467499}
    468500
     
    470502int        PIGraphicMac::GetFontSize()
    471503{
    472 return (mFSize);
     504return (myFont.GetFontSize());
    473505}
    474506
     
    491523}
    492524
    493 /* --Methode-- */
    494 int        PIGraphicMac::GetFontHeight(int& asc, int& desc)   
    495 {
    496   if (mPane->FocusDraw()) {
    497     FontInfo info;
    498     GetFontInfo(&info);
    499     asc = info.ascent;
    500     desc = info.descent;
    501     return (asc + desc);
    502   } else {
    503     return 0;
    504   }
    505 }
    506 
    507 /* --Methode-- */
    508 PIGrCoord PIGraphicMac::CalcStringWidth(char const* s)
    509 {
    510 //  if (mPane->FocusDraw())
    511 //    ::TextFont(applFont);
    512   return ::TextWidth(s,0,strlen(s));
    513 }
    514 
    515 /* --Methode-- */
    516 void PIGraphicMac::SaveGraphicAtt()
    517 
    518 // Pour optimier l'implementation de PIBaseWdgGen
    519 
    520 // $CHECK$ faut faire quoi en plus de Gen ?
    521 PIGraphicGen::SaveGraphicAtt();
    522 return;
    523 }
    524 
    525 /* --Methode-- */
    526 void PIGraphicMac::RestoreGraphicAtt()
    527 {
    528 PIGraphicGen::RestoreGraphicAtt();
    529 }
    530 
    531 
    532 
    533 
    534 
    535 
     525
  • trunk/SophyaPI/PI/pigraphmac.h

    r89 r369  
     1// This may look like C code, but it is really -*- C++ -*-
     2// Module PI : Peida Interactive     PIGraphicMac
     3// Trace graphiques- Implementation Mac  E. Aubourg 99
     4// LAL (Orsay) / IN2P3-CNRS  DAPNIA/SPP (Saclay) / CEA
     5
    16#ifndef PIGRAPHICMAC_H_SEEN
    27#define PIGRAPHICMAC_H_SEEN
     
    1318//  Trace graphiques
    1419  virtual void       Erase(PIGrCoord x0, PIGrCoord y0, PIGrCoord dx, PIGrCoord dy);
    15   virtual void       DrawString(PIGrCoord x, PIGrCoord y, char* s, int pos = 0);
    16   virtual void       DrawOpaqueString(PIGrCoord x, PIGrCoord y, char* s, int pos = 0);
     20  virtual void       DrawString(PIGrCoord x, PIGrCoord y, const char* s, int pos = 0);
     21  virtual void       DrawOpaqueString(PIGrCoord x, PIGrCoord y, const char* s, int pos = 0);
    1722  virtual void       DrawLine(PIGrCoord x1, PIGrCoord y1, PIGrCoord x2, PIGrCoord y2);
    1823  virtual void       DrawBox(PIGrCoord x0, PIGrCoord y0, PIGrCoord dx, PIGrCoord dy);
     
    2025  virtual void       DrawCircle(PIGrCoord x0, PIGrCoord y0, PIGrCoord r);
    2126  virtual void       DrawFCircle(PIGrCoord x0, PIGrCoord y0, PIGrCoord r);
    22   virtual void       DrawPolygon(PIGrCoord *x, PIGrCoord *y, int n); 
    23   virtual void       DrawFPolygon(PIGrCoord *x, PIGrCoord *y, int n); 
     27  virtual void       DrawOval(PIGrCoord x0, PIGrCoord y0, PIGrCoord dx, PIGrCoord dy);
     28  virtual void       DrawFOval(PIGrCoord x0, PIGrCoord y0, PIGrCoord dx, PIGrCoord dy);
     29  virtual void       DrawPolygon(PIGrCoord *x, PIGrCoord *y, int n, bool cinc=true); 
     30  virtual void       DrawFPolygon(PIGrCoord *x, PIGrCoord *y, int n, bool cinc=true); 
     31  virtual void       DrawArc(PIGrCoord x0, PIGrCoord y0, PIGrCoord dx, PIGrCoord dy,
     32                             double degdeb, double degfin);
     33  virtual void       DrawFArc(PIGrCoord x0, PIGrCoord y0, PIGrCoord dx, PIGrCoord dy,
     34                              double degdeb, double degfin);
    2435  virtual void       DrawMarker(PIGrCoord x0, PIGrCoord y0);
    2536  virtual void       DrawMarkers(PIGrCoord *x, PIGrCoord *y, int n);
     
    3344  virtual void       SelBackground(PIColorMap& cmap, int cid);
    3445  virtual void       SelGOMode(PIGOMode mod=PI_GOCopy);
     46  virtual void       SelFont(PIFont & fnt);
    3547  virtual void       SelFont(PIFontSize sz=PI_NormalSizeFont,
    3648                             PIFontAtt att=PI_RomanFont);
     
    5365  virtual int        GetMarkerSize();
    5466
    55   virtual int        GetFontHeight(int& asc, int& desc);
    56   virtual PIGrCoord  CalcStringWidth(char const* s);
     67  //virtual int        GetFontHeight(int& asc, int& desc);
     68  //virtual PIGrCoord  CalcStringWidth(char const* s);
    5769
    5870// Sauvegarde des attributs graphiques
    59   virtual void       SaveGraphicAtt();
    60   virtual void       RestoreGraphicAtt();
     71 // virtual void       SaveGraphicAtt();
     72 // virtual void       RestoreGraphicAtt();
    6173
    6274protected:
     
    6779  PIColors  mFCol, mBCol;
    6880  PIGOMode  mGOm;
    69   PIFontAtt mFAtt;
    7081  PILineAtt mLAtt;
    71   int       mFSize;
    7282  PIMarker  mMrk;
    7383  int       mMrkSz;
  • trunk/SophyaPI/PI/pilistmac.cc

    r64 r369  
    3535
    3636/* --Methode-- */
    37 void PIListMac::DeleteItem(PIMessage msg)
     37void PIListMac::DeleteItemMsg(PIMessage msg)
    3838{
    3939  mPIPPList->DeleteItem(msg);
     
    7272
    7373/* --Methode-- */
    74 void PIListMac::SelectItem(PIMessage msg)
     74void PIListMac::SelectItemMsg(PIMessage msg)
    7575{
    7676  mPIPPList->SelectItem(msg);
     
    8585
    8686/* --Methode-- */
    87 void PIListMac::ClearSelItem(PIMessage msg)
     87void PIListMac::ClearSelItemMsg(PIMessage msg)
    8888{
    8989  mPIPPList->ClearSelItem(msg);
  • trunk/SophyaPI/PI/pilistmac.h

    r64 r369  
    1313  virtual void       AppendItem(const char * item, PIMessage msg);
    1414  virtual void       DeleteItem(const char *item);
    15   virtual void       DeleteItem(PIMessage msg);
     15  virtual void       DeleteItemMsg(PIMessage msg);
     16  virtual void       DeleteAllItems();
     17
     18  virtual int          GetNbItems();
     19  virtual PIMessage  GetItemMsg(int n);
     20  virtual string     GetItem(int n);
    1621
    1722  virtual void       SetMultipleSelect(bool ms=false);
     
    2227
    2328  virtual void       SelectItem(const char * item);
    24   virtual void       SelectItem(PIMessage msg);
     29  virtual void       SelectItemMsg(PIMessage msg);
    2530  virtual void       ClearSelItem(const char * item);
    26   virtual void       ClearSelItem(PIMessage msg);
     31  virtual void       ClearSelItemMsg(PIMessage msg);
    2732
    2833
  • trunk/SophyaPI/PI/pimenubarmac.cc

    r69 r369  
    1313
    1414void
    15 PIMenubarMac::AppendMenu(PIPDMenu *pdm)
     15PIMenubarMac::AppendMenu(PIMenu *pdm)
    1616{
    1717  LMenuBar::GetCurrentMenuBar()->InstallMenu(pdm->macMenu, InstallMenu_AtEnd);
    1818}
     19
     20void
     21PIMenubarMac::RemoveMenu(PIMenu *pdm)
     22{
     23  LMenuBar::GetCurrentMenuBar()->RemoveMenu(pdm->macMenu);
     24}
     25
     26void
     27PIMenubarMac::SetSensitivity(PIMenu *pdm, bool sens)
     28{
     29
     30}
     31
     32bool
     33PIMenubarMac::IsSensitive(PIMenu *pdm)
     34{
     35  return true;
     36}
  • trunk/SophyaPI/PI/pimenubarmac.h

    r2 r369  
    88                    PIMenubarMac(PIApplicationGen* par, char* nom);
    99                   ~PIMenubarMac();
    10  virtual void   AppendMenu(PIPDMenu *pdm);
     10                   
     11  virtual void      AppendMenu(PIMenu *pdm);
     12  virtual void      RemoveMenu(PIMenu *pdm);
     13  virtual void      SetSensitivity(PIMenu *pdm, bool sens=true);
     14  virtual bool      IsSensitive(PIMenu *pdm);
    1115
    1216};
  • trunk/SophyaPI/PI/pimenumac.cc

    r88 r369  
    22#include "pimenumac.h"
    33#include <algorithm>
     4#include <iostream>
    45
    56int PIMenuMac::lastId = 1024;
    6 list<PIMenuMac*> PIMenuMac::sMenus;
    7 
    8 PIMenuMac::PIMenuMac(PIMsgHandler *par, char *nom, PIMenuType pdpu)
     7vector<PIMenuMac::menuInfo> mMenuInfos;
     8
     9/* --Methode-- */
     10PIMenuMac::PIMenuMac(PIWdg* par, const char *nom, PIMenuType pdpu)
    911: PIMenuGen(par, nom, pdpu)
    1012{
    1113   macMenu = new LMenu(lastId, LStr255(nom));
    12    mMenuId = lastId;
    13    sMenus.push_back(this);
     14   menuInfo info;
     15   info.mId = lastId;
     16   info.pimenu = this;
     17   mMenuInfos.push_back(info);
    1418   lastId++;
    1519}
    1620
    1721
     22/* --Methode-- */
    1823PIMenuMac::~PIMenuMac()
    1924{
    2025  LMenuBar::GetCurrentMenuBar()->RemoveMenu(macMenu);
    21   sMenus.remove(this);
     26  mMenuInfos.erase(mMenuInfos.begin() + GetMenuNum());
    2227  delete macMenu;
    2328}
    2429
    25 int
    26 PIMenuMac::FindItemByMsg(PIMessage msg)
    27 {
    28   if (mMsgs.size() == 0) return -1;
    29   int i = find(mMsgs.begin(), mMsgs.end(), msg) - mMsgs.begin();
    30   return (i>=mMsgs.size()) ? -1 : i;
    31 }
    32 
    33 int
    34 PIMenuMac::FindItemByName(string const& s)
    35 {
    36   int n = ::CountMItems(GetMacMenuHandle());
    37   for (int i=0; i<n; i++)
    38     if (GetMenuItemText(i) == s)
    39       return i;
    40   return -1;
    41 }
    42 
    43 
    44 void
    45 PIMenuMac::AppendItem(char* nom, PIMessage msg, char* sc)  // sc = short-cut , raccourci clavier
    46 {
     30/* --Methode-- */
     31void PIMenuMac::AppendItem(const char* nom, PIMessage msg, char* sc)
     32{
     33  AddItem(nom, msg, 0, sc, NULL);
     34}
     35
     36/* --Methode-- */
     37void PIMenuMac::AppendCheckItem(const char* nom, PIMessage msg, char* sc)
     38{
     39  AddItem(nom, msg, 1, sc, NULL);
     40}
     41
     42/* --Methode-- */
     43void PIMenuMac::AppendPDMenu(PIMenuGen *pdm, char* sc)
     44{
     45  if (pdm->MType() !=  k_PulldownMenu) {
     46    cerr << "PIMenuX::AppendPDMenu()/Erreur: PullDownMenu seulement ... " << endl;
     47    return;
     48  }
     49  AddItem(NULL, pdm->Msg(), 2, sc, (PIMenuMac*)pdm);
     50}
     51
     52/* --Methode-- */
     53void PIMenuMac::AddItem(const char* nom, PIMessage msg, int tog, char* sc, PIMenuMac *pdm)
     54{
     55  macMenu->InsertCommand("\ptemp", -2000, 1000);
     56  MenuHandle mh = GetMacMenuHandle();
     57  short i = ::CountMenuItems(mh);
    4758  LStr255 titre(nom);
    48   if (titre.BeginsWith("-",1))
    49     titre.Insert(" ", 1, 0);
    50   if (sc) {
    51     titre.Append('/');
    52     titre.Append(*sc);
     59  ::SetMenuItemText(mh, i, titre);
     60
     61  // Gestion menus hiérarchiques
     62  if (tog == 2 && pdm != NULL) {
     63    ::SetItemCmd(mh, i, hMenuCmd);
     64    ::SetItemMark(mh, i, pdm->GetMacMenuID());
    5365  }
    54   macMenu->InsertCommand(titre, -2000, 1000); // ou cmd_UseMenuItem ???
    55   mMsgs.push_back(msg);
    56 }
    57 
    58 void
    59 PIMenuMac::CheckItemNum(int n, bool st)
    60 {
    61   if (n<0 || n >= mMsgs.size()) return; // $CHECK$ exception ?
     66  // Le menu hierarchique sera "insere" au moment de l'insertion dans la
     67  // menubar...
     68 
     69  itemInfo info;
     70  info.pimsg  = msg;
     71  info.name   = nom;
     72  mItemInfos.push_back(info);
     73}
     74
     75/* --Methode-- */
     76int PIMenuMac::GetItemNum(const char *nom)
     77{
     78  int j=0;
     79  for (vector<itemInfo>::iterator i = mItemInfos.begin(); i != mItemInfos.end(); i++,j++)
     80    if ((*i).name == nom) return j;
     81  return(-1);
     82}
     83
     84/* --Methode-- */
     85int PIMenuMac::GetItemNumMsg(PIMessage msg)
     86{
     87  int j=0;
     88  for (vector<itemInfo>::iterator i = mItemInfos.begin(); i != mItemInfos.end(); i++,j++)
     89    if ((*i).pimsg == msg) return j;
     90  return(-1);
     91}
     92
     93/* --Methode-- */
     94int PIMenuMac::GetMenuNum()
     95{
     96  int j=0;
     97  for (vector<menuInfo>::iterator i = mMenuInfos.begin(); i != mMenuInfos.end(); i++,j++)
     98    if ((*i).pimenu == this) return j;
     99  return(-1);
     100}
     101
     102/* --Methode-- */
     103int PIMenuMac::GetMenuNum(short menuId)
     104{
     105  int j=0;
     106  for (vector<menuInfo>::iterator i = mMenuInfos.begin(); i != mMenuInfos.end(); i++,j++)
     107    if ((*i).mId == menuId) return j;
     108  return(-1);
     109}
     110
     111/* --Methode-- */
     112PIMenu* PIMenuMac::GetMenu(short menuId)
     113{
     114  int j=0;
     115  for (vector<menuInfo>::iterator i = mMenuInfos.begin(); i != mMenuInfos.end(); i++,j++)
     116    if ((*i).mId == menuId) return (*i).pimenu;
     117  return(NULL);
     118}
     119
     120
     121/* --Methode-- */
     122void
     123PIMenuMac::SetStateNum(int n, bool st)
     124{
     125  if (n<0 || n >= mItemInfos.size()) return; // $CHECK$ exception ?
    62126  ::CheckItem(macMenu->GetMacMenuH(), n, st);
    63127}
    64128
    65 void
    66 PIMenuMac::CheckItemMsg(PIMessage msg, bool st)
    67 {
    68   int i = FindItemByMsg(msg);
    69   if (i>=0)
    70     CheckItemNum(i, st);
    71 }
    72 
    73 void
    74 PIMenuMac::CheckItem(char* nom, bool st)
    75 {
    76   int i = FindItemByName(nom);
    77   if (i>=0)
    78     CheckItemNum(i, st);
     129/* --Methode-- */
     130void
     131PIMenuMac::SetStateMsg(PIMessage msg, bool st)
     132{
     133  int i = GetItemNumMsg(msg);
     134  if (i>=0)
     135    SetStateNum(i, st);
     136}
     137
     138/* --Methode-- */
     139void
     140PIMenuMac::SetState(const char* nom, bool st)
     141{
     142  int i = GetItemNum(nom);
     143  if (i>=0)
     144    SetStateNum(i, st);
    79145}
    80146
     
    82148PIMenuMac::DeleteItemNum(int n)
    83149{
    84   if (n<0 || n >= mMsgs.size()) return; // $CHECK$ exception ?
     150  if (n<0 || n >= mItemInfos.size()) return; // $CHECK$ exception ?
    85151  macMenu->RemoveItem(n+1);
    86   mMsgs.erase(mMsgs.begin()+n);
     152  mItemInfos.erase(mItemInfos.begin()+n);
    87153}
    88154
     
    90156PIMenuMac::DeleteItemMsg(PIMessage msg)
    91157{
    92   int i = FindItemByMsg(msg);
     158  int i = GetItemNumMsg(msg);
    93159  if (i>=0)
    94160    DeleteItemNum(i);
     
    96162
    97163void
    98 PIMenuMac::DeleteItem(char* nom)
    99 {
    100   int i = FindItemByName(nom);
     164PIMenuMac::DeleteItem(const char* nom)
     165{
     166  int i = GetItemNum(nom);
    101167  if (i>=0)
    102168    DeleteItemNum(i);
    103169}
    104170
    105 
    106 
    107171void
    108172PIMenuMac::ItemSelected(int item)
    109173{
    110   if (item<0 || item >= mMsgs.size()) return; // $CHECK$ exception ?
    111   Send(mMsgs[item], PIMsg_Click, (void*) GetMenuItemText(item).c_str());
    112 }
     174  if (item<0 || item >= mItemInfos.size()) return; // $CHECK$ exception ?
     175  Send(mItemInfos[item].pimsg, PIMsg_Click, (void*) mItemInfos[item].name.c_str());
     176}
     177
     178string
     179PIMenuMac::GetMenuItemText(int item)
     180{
     181  if (item<0 || item >= mItemInfos.size()) return ""; // $CHECK$ exception ?
     182  return mItemInfos[item].name;
     183}
     184
     185PIMessage
     186PIMenuMac::GetMenuItemMsg(int item)
     187{
     188  if (item<0 || item >= mItemInfos.size()) return -1; // $CHECK$ exception ?
     189  return mItemInfos[item].pimsg;
     190}
     191
    113192
    114193
     
    121200{}
    122201
    123 void
    124 PIMenuMac::Hide()
    125 {}
    126 
    127 PIMenuMac*
    128 PIMenuMac::findMenu(int id)
    129 {
    130   list<PIMenuMac*>::iterator i = sMenus.begin();
    131  
    132   while (i != sMenus.end()) {
    133     if ((*i)->MenuId()==id) return *i;
    134     i++;
    135   }
    136  
    137   return NULL;
    138 }
    139202
    140203MenuHandle
     
    151214
    152215
    153 string
    154 PIMenuMac::GetMenuItemText(int item)
    155 {
    156   if (item<0 || item >= mMsgs.size()) return ""; // $CHECK$ exception ?
    157   MenuHandle h = GetMacMenuHandle();
    158   Str255 txt;
    159   ::GetMenuItemText(h, item+1, txt);
    160   p2cstr(txt);
    161   return (char*) txt;
    162 }
    163 
    164 PIMenuMac::GetMenuItemMsg(int item)
    165 {
    166   if (item<0 || item >= mMsgs.size()) return -1; // $CHECK$ exception ?
    167   return mMsgs[item];
    168 }
    169 
    170 
    171 
    172 /* --Methode-- */
    173 PIPUMenuMac::PIPUMenuMac(PIMsgHandler* par, char* nom)
    174 : PIMenuMac(par, nom, k_PopupMenu)
    175 {
    176 }
    177 
    178 /* --Methode-- */
    179 PIPUMenuMac::~PIPUMenuMac()
    180 {
    181 }
    182 
    183 void
    184 PIPUMenuMac::Show()
    185 {
    186   Point pt;
    187   ::GetMouse(&pt);
    188   ::LocalToGlobal(&pt);
    189   int item = ::PopUpMenuSelect(macMenu->GetMacMenuH(),pt.v,pt.h,1);
    190   ItemSelected(item);
    191 }
    192 
    193 void
    194 PIPUMenuMac::Show(PIWdg *w, int px, int py)
    195 {
    196   int item = ::PopUpMenuSelect(macMenu->GetMacMenuH(),py,px,1);
    197   ItemSelected(item);
    198 }
    199 
    200 /* --Methode-- */
    201 PIPDMenuMac::PIPDMenuMac(PIMsgHandler* par, char* nom)
    202 : PIMenuMac(par, nom, k_PulldownMenu)
    203 {
    204 }
    205 
    206 /* --Methode-- */
    207 PIPDMenuMac::~PIPDMenuMac()
    208 {
    209 }
    210 
  • trunk/SophyaPI/PI/pimenumac.h

    r88 r369  
    1010class PIMenuMac : public PIMenuGen {
    1111public:
    12                                         PIMenuMac(PIMsgHandler* par, char* nom, PIMenuType pdpu);
     12                                        PIMenuMac(PIWdg* par, const char* nom, PIMenuType pdpu=k_UTMenu);
    1313                                   ~PIMenuMac();
    1414                                   
    15     virtual void    AppendItem(char* nom, PIMessage msg, char* sc=NULL);
     15  virtual void    AppendItem(const char* nom, PIMessage msg, char* sc=NULL);
     16  virtual void    AppendCheckItem(const char* nom, PIMessage msg, char* sc=NULL);
     17  virtual void    AppendPDMenu(PIMenuGen *pdm, char* sc=NULL);
    1618
    17     virtual void    DeleteItem(char *nom);
    18     virtual void    DeleteItemMsg(PIMessage msg);
    19     virtual void    DeleteItemNum(int n);
     19  virtual void    DeleteItem(const char *nom);
     20  virtual void    DeleteItemMsg(PIMessage msg);
     21  virtual void    DeleteItemNum(int n);
    2022
    21     virtual void    CheckItem(char *nom, bool st=false);
    22     virtual void    CheckItemMsg(PIMessage msg, bool st=false);
    23     virtual void    CheckItemNum(int n, bool st=false);
    24        
    25     virtual void    Show();
    26     virtual void    Show(PIWdg *w, int px, int py);
     23  virtual void    SetSensitivity(const char *nom, bool sens=true);
     24  virtual void    SetSensitivityMsg(PIMessage msg, bool sens=true);
     25  virtual void    SetSensitivityNum(int n, bool sens=true);
    2726
    28     virtual void    Hide();
    29    
    30     int             MenuId() {return mMenuId;}
    31     void            ItemSelected(int item);
    32    
    33         string          GetMenuItemText(int item);
    34         int             GetMenuItemMsg(int item);
    35         int             FindItemByMsg(PIMessage msg);
    36         int             FindItemByName(string const& nom);
    37        
     27  virtual bool    IsSensitive(const char *nom);
     28  virtual bool    IsSensitiveMsg(PIMessage msg);
     29  virtual bool    IsSensitiveNum(int n);
     30
     31  virtual void    SetState(const char *nom, bool st=false);
     32  virtual void    SetStateMsg(PIMessage msg, bool st=false);
     33  virtual void    SetStateNum(int n, bool st=false);
     34 
     35  virtual bool    GetState(const char *nom);
     36  virtual bool    GetStateMsg(PIMessage msg);
     37  virtual bool    GetStateNum(int n);
     38
     39  virtual void    Show();
     40  virtual void    Show(PIWdg *w, int px, int py);
     41
     42  LMenu*          GetPPMenu() {return macMenu;}
     43  void            ItemSelected(int item);
     44  string          GetMenuItemText(int item);
     45  PIMessage       GetMenuItemMsg(int item);     
    3846protected:
    39         static PIMenuMac* findMenu(int id);
    4047        LMenu*          macMenu;
    41         int             mMenuId;
    42         vector<PIMessage>    mMsgs;
     48        struct menuInfo {
     49          short      mId;
     50          PIMenuMac* pimenu;
     51        };
     52        struct itemInfo {
     53          PIMessage  pimsg;
     54          string     name;
     55        };
     56        static vector<menuInfo> mMenuInfos;
     57        vector<itemInfo> mItemInfos;
    4358        static int      lastId;
    44         static list<PIMenuMac*> sMenus;
    4559       
    4660        friend class    PIMenubarMac;
     
    5165        ResIDT          GetMacMenuID();
    5266       
    53    
    54 };
    55 
    56 // Menu popup
    57 class PIPUMenuMac : public PIMenuMac
    58 {
    59 public:
    60                PIPUMenuMac(PIMsgHandler* par, char* nom);
    61                ~PIPUMenuMac();
    62 virtual void   Show();
    63 virtual void   Show(PIWdg *w, int px, int py);
    64 };
    65 
    66 // Menu pull-down
    67 class PIPDMenuMac : public PIMenuMac
    68 {
    69 public:
    70                PIPDMenuMac(PIMsgHandler* par, char* nom);
    71                ~PIPDMenuMac();
     67    int             GetItemNum(const char* nom);
     68        int             GetItemNumMsg(PIMessage msg);
     69        int             GetMenuNum();
     70        static int      GetMenuNum(short menuId);
     71        static PIMenuMac*  GetMenu(short menuId);
     72    void            AddItem(const char* nom, PIMessage msg, int tog, char* sc, PIMenuMac *pdm);
    7273};
    7374
    7475
    7576typedef PIMenuMac      PIMenu;
    76 typedef PIPUMenuMac    PIPUMenu;
    77 typedef PIPDMenuMac    PIPDMenu;
    7877
    7978#endif
  • trunk/SophyaPI/PI/pioptmenumac.cc

    r69 r369  
    33
    44/* --Methode-- */
    5 PIOptMenuMac::PIOptMenuMac(PIContainerGen* par, PIPUMenu *pdm,
     5PIOptMenuMac::PIOptMenuMac(PIContainerGen* par, char const* nom,
    66                     int sx, int sy, int px, int py)
    7 : PIOptMenuGen(par, pdm, sx, sy, px, py), mPUMenu(pdm)
     7: PIOptMenuGen(par, nom, sx, sy, px, py)
    88{
    99  delete mPane;
    10   //LStr255 titre(Nom().c_str());
     10 
     11  char buff[128];
     12  strncpy(buff, nom, 64);
     13  strcat(buff,"_Menu");
     14  mMen = new PIMenu((PIWdg*)par, buff, k_PopupMenu);
     15  mMen->SetMsgParent(this);
    1116  LStr255 titre("");
    1217 
     
    1722  int titleWidth = ::StringWidth(titre);
    1823 
    19   //mPane = new LStdPopupMenu(mPaneInfo, msg_Click, 0, 200, titleWidth+5, popupMenuProc/*+popupVariableWidth*/, 130, titre, 0, 1);
    2024  mPane = new PIPPOptMenu(mPaneInfo, msg_Click, 0, 200, titleWidth+5, popupMenuProc/*+popupVariableWidth*/, 130, titre, 0, 1);
    21   //macMenu = ((LStdPopupMenu*)mPane)->GetMacMenuH();
    2225 
    23   // On va changer la resource de menu au passage...
    24 //  InsertMenu(pdm->GetMacMenuHandle(), hierMenu);
    25 //  PopupPrivateDataHandle      dataH =
    26 ////            (PopupPrivateDataHandle) (**((LStdPopupMenu*)mPane)->GetMacControl()).contrlData;
    27 //  (**dataH).mHandle = pdm->GetMacMenuHandle();
    28 //  (**dataH).mID = pdm->GetMacMenuID();
    29  
    30   ((PIPPOptMenu*)mPane)->SetMenu(pdm);
     26  ((PIPPOptMenu*)mPane)->SetMenu(mMen);
    3127  ((LStdPopupMenu*)mPane)->AddListener(this);
    3228 
     
    3733PIOptMenuMac::~PIOptMenuMac()
    3834{
     35  delete mMen;
    3936}
    4037
     
    4239void PIOptMenuMac::Process(PIMessage msg, PIMsgHandler* sender, void* data)
    4340{
    44 Select((char *)data, UserMsg(msg));  //  Reza 17/10/96 $CHECK$ ???
    45 ReSend(msg, sender, data);
     41if (sender == mMen)   {
     42  SetValue(UserMsg(msg));
     43  ReSend(msg, this, NULL);
     44}
     45return;
    4646}
    4747
     
    5050{
    5151//  if (inMessage == msg_Click)
    52     mPUMenu->ItemSelected(((LStdPopupMenu*)mPane)->GetValue()-1);
    53 }
    54 
    55 void
    56 PIOptMenuMac::Select(char *txt, PIMessage msg)
    57 { // Ca doit faire quoi ????
    58 mStext = txt;  mSmsg = msg;
     52  int n = ((LStdPopupMenu*)mPane)->GetValue()-1;
     53  mMen->ItemSelected(n);
     54  mStext = mMen->GetMenuItemText(n);
     55  mSmsg  = mMen->GetMenuItemMsg(n);
    5956}
    6057
     
    6259void PIOptMenuMac::SetValueStr(string & s)
    6360{
    64 int n;
    65 n=mPUMenu->FindItemByName((char *)s.c_str());
    66 if (n < 0)  return; 
     61  int n;
     62  n=mMen->GetItemNum((char *)s.c_str());
     63  if (n < 0)  return; 
    6764
    68 ((LStdPopupMenu*)mPane)->SetValue(n+1);
    69 mStext = s;
    70 mSmsg  = mPUMenu->GetMenuItemMsg(n);
    71 
    72 return;
     65  StopListening();
     66  ((LStdPopupMenu*)mPane)->SetValue(n+1);
     67  StartListening();
     68  mStext = s;
     69  mSmsg  = mMen->GetMenuItemMsg(n);
    7370}
    7471
     
    7673void PIOptMenuMac::SetValue(PIMessage msg)
    7774{
    78 int n;
    79 n=mPUMenu->FindItemByMsg(msg);
    80 if (n < 0)  return;
     75  int n;
     76  n=mMen->GetItemNumMsg(msg);
     77  if (n < 0)  return;
    8178 
    82 StopListening();
    83 ((LStdPopupMenu*)mPane)->SetValue(n+1);
    84 StartListening();
    85 mStext = mPUMenu->GetMenuItemText(n);
    86 mSmsg  = msg;
    87 
    88 return;
     79  StopListening();
     80  ((LStdPopupMenu*)mPane)->SetValue(n+1);
     81  StartListening();
     82  mStext = mMen->GetMenuItemText(n);
     83  mSmsg  = msg;
    8984}
    9085
  • trunk/SophyaPI/PI/pioptmenumac.h

    r23 r369  
    66class PIOptMenuMac : public PIOptMenuGen {
    77public:
    8                         PIOptMenuMac(PIContainerGen* par, PIPUMenu *pdm, 
     8                        PIOptMenuMac(PIContainerGen* par, const char* nom, 
    99                               int sx=10, int sy=10, int px=0, int py=0);
    1010                       ~PIOptMenuMac();
     
    1818  virtual void      SetValue(PIMessage msg);
    1919 
    20   inline void       Select(char *txt, PIMessage msg); // public ou protege ???
    21 
    2220
    2321protected:
    2422  string    mStext;
    2523  PIMessage mSmsg;
    26   //MenuHandle macMenu;
    27   PIPUMenu* mPUMenu;
    2824};
    2925
  • trunk/SophyaPI/PI/pipixmapmac.cc

    r88 r369  
    1212
    1313/* --Methode-- */
    14 void PIPixmapMac::SetPixmap(unsigned char *pix, int sx, int sy, bool refr)
     14void PIPixmapMac::SetPixmap(unsigned char *pix, int sx, int sy, bool refr, int ox, int oy)
    1515{
    1616  if (nx != sx || ny != sy)
  • trunk/SophyaPI/PI/pipixmapmac.h

    r88 r369  
    1111  virtual      ~PIPixmapMac();
    1212
    13   virtual void  SetPixmap(unsigned char *pix, int sx, int sy, bool refr=true);
     13  virtual void  SetPixmap(unsigned char *pix, int sx, int sy, bool refr=true, int ox=0, int oy=0);
    1414  virtual void  Draw(PIGraphic* g);
    1515  virtual void  Draw(PIGraphic* g, int x0, int y0, int dx, int dy);
  • trunk/SophyaPI/PI/pippmenubar.cc

    r69 r369  
    2020        int menuItem = LoWord(outMenuChoice)-1; // Dans PI les menu items commencent a 0
    2121       
    22         PIMenuMac* menu = PIMenuMac::findMenu(menuId);
     22        PIMenuMac* menu = PIMenuMac::GetMenu(menuId);
    2323        if (menu)
    2424          menu->ItemSelected(menuItem);
     
    3737        int menuItem = LoWord(outMenuChoice)-1; // Dans PI les menu items commencent a 0
    3838       
    39         PIMenuMac* menu = PIMenuMac::findMenu(menuId);
     39        PIMenuMac* menu = PIMenuMac::GetMenu(menuId);
    4040        if (menu)
    4141          menu->ItemSelected(menuItem);
  • trunk/SophyaPI/PI/pippoptmenu.cc

    r69 r369  
    4747
    4848void
    49 PIPPOptMenu::SetMenu(PIPUMenu* pdm)
     49PIPPOptMenu::SetMenu(PIMenu* pdm)
    5050{
    5151  // On va changer la resource de menu au passage...
  • trunk/SophyaPI/PI/pippoptmenu.h

    r69 r369  
    2929                                                        LStream                         *inStream);
    3030                                                       
    31                                         void SetMenu(PIPUMenu* pdm);
     31                                        void SetMenu(PIMenu* pdm);
    3232protected:
    3333        virtual void            HotSpotResult(
  • trunk/SophyaPI/PI/pippviewadapter.cc

    r66 r369  
    2626                                  PIBindingKind right, PIBindingKind bottom)
    2727{
    28   piBindings.left = left;
    29   piBindings.right = right;
    30   piBindings.top = top;
     28  piBindings.left   = left;
     29  piBindings.right  = right;
     30  piBindings.top    = top;
    3131  piBindings.bottom = bottom;
    3232}
     33
     34bool PIPPViewAdapter::GetBinding(PIBindingKind& left, PIBindingKind& top,
     35                                  PIBindingKind& right, PIBindingKind& bottom)
     36{
     37  left   = (PIBindingKind)piBindings.left;
     38  right  = (PIBindingKind)piBindings.right;
     39  top    = (PIBindingKind)piBindings.top;
     40  bottom = (PIBindingKind)piBindings.bottom;
     41 
     42  return false;
     43}
     44
    3345
    3446void PIPPViewAdapter::AdaptToSuperFrameSize(
  • trunk/SophyaPI/PI/pippviewadapter.h

    r66 r369  
    1515        virtual void        SetBinding(PIBindingKind left, PIBindingKind top,
    1616                                   PIBindingKind right, PIBindingKind bottom);
     17        bool                GetBinding(PIBindingKind& left, PIBindingKind& top,
     18                                   PIBindingKind& right, PIBindingKind& bottom);
    1719        virtual void            AdaptToSuperFrameSize(
    1820                                                                Int32                           inSurrWidthDelta,
  • trunk/SophyaPI/PI/pistdwdgmac.cc

    r88 r369  
    2323
    2424PIButtonMac::PIButtonMac(PIContainerGen *par, char *nom, PIMessage msg,
    25                          int sx, int sy, int px, int py, PIBtnSign bsgn)
    26 : PIButtonGen(par, nom, msg, sx, sy, px, py, bsgn)
     25                         int sx, int sy, int px, int py)
     26: PIButtonGen(par, nom, msg, sx, sy, px, py)
    2727{
    2828  delete mPane;
     
    3636
    3737void
     38PIButtonMac::SetLabel(string const& str)
     39{
     40  LStr255 sstr(str.c_str());
     41  ((LStdButton*)mPane)->SetDescriptor(sstr);
     42}
     43
     44
     45void
    3846PIButtonMac::ListenToMessage(MessageT inMessage, void *)
    3947{
     
    4654#include <LEditField.h>
    4755
    48 PITextMac::PITextMac(PIContainerGen *par, char *nom,
     56PITextMac::PITextMac(PIContainerGen *par, const char *nom,
    4957                         int sx, int sy, int px, int py)
    5058: PITextGen(par, nom, sx, sy, px, py)
     
    5462  mPane = new LEditField(mPaneInfo, titre, 130, 255, true, true, NULL, LCommander::GetTopCommander());
    5563}
     64
     65PITextMac::PITextMac(PIContainerGen *par, const char *nom,
     66                     bool vsb, bool hsb,
     67                     int sx, int sy, int px, int py)
     68: PITextGen(par, nom, vsb, hsb, sx, sy, px, py)
     69{
     70  delete mPane;
     71  LStr255 titre(nom);
     72  mPane = new LEditField(mPaneInfo, titre, 130, 255, true, true, NULL, LCommander::GetTopCommander());
     73}
     74
    5675
    5776PITextMac::~PITextMac()
     
    127146
    128147void
     148PIScaleMac::GetMinMax(int &min, int &max)
     149{
     150  min = ((LStdControl*)mPane)->GetMinValue();
     151  max = ((LStdControl*)mPane)->GetMaxValue();
     152}
     153
     154void
    129155PIScaleMac::SetValue(int val)
    130156{
     
    219245
    220246void
     247PIScrollBarMac::GetMinMax(int &min, int &max)
     248{
     249  min = ((LStdControl*)mPane)->GetMinValue();
     250  max = ((LStdControl*)mPane)->GetMaxValue();
     251}
     252
     253
     254void
    221255PIScrollBarMac::SetValue(int val)
    222256{
  • trunk/SophyaPI/PI/pistdwdgmac.h

    r98 r369  
    1111                                 int sx=10, int sy=10, int px=0, int py=0);
    1212  virtual           ~PILabelMac();
     13  virtual void       SetLabel(string const&);
    1314};
    1415
     
    1718public:
    1819                     PIButtonMac(PIContainerGen *par, char *nom, PIMessage msg = PIMsg_Click,
    19                                  int sx=10, int sy=10, int px=0, int py=0,
    20                                  PIBtnSign bsgn = PIBtn_Label);
     20                                 int sx=10, int sy=10, int px=0, int py=0);
    2121  virtual           ~PIButtonMac();
     22  virtual void       SetLabel(string const&);
    2223  virtual void       ListenToMessage(MessageT inMessage, void *ioParam);
    2324  virtual void       ActivatePress(bool=false) {}
     
    2728{
    2829public:
    29                      PITextMac(PIContainerGen *par, char *nom,
     30                     PITextMac(PIContainerGen *par, const char *nom,
     31                               int sx=10, int sy=10, int px=0, int py=0);
     32                     PITextMac(PIContainerGen *par, const char *nom,
     33                               bool vsb, bool hsb,
    3034                               int sx=10, int sy=10, int px=0, int py=0);
    3135  virtual           ~PITextMac();
     
    4751
    4852  virtual void       SetMinMax(int min, int max);
     53  virtual void       GetMinMax(int& min, int& max);
    4954  virtual void       SetValue(int val);
    5055  virtual int        GetValue();
     
    6772  virtual void       ActivateDrag(bool /*acd*/=false) {};
    6873  virtual void       SetMinMax(int min, int max);
     74  virtual void       GetMinMax(int& min, int& max);
    6975  virtual void       SetValue(int val);
    7076  virtual int        GetValue();
  • trunk/SophyaPI/PI/piupdattachment.cc

    r88 r369  
    2323    switch(msg) {
    2424      case msg_DrawOrPrint:
    25         myWdg->Draw(myGraphic);
     25        myWdg->Draw(myGraphic,0,0,999999,999999);
    2626                break;
    2727      case msg_Resize:
  • trunk/SophyaPI/PI/piwdgmac.cc

    r88 r369  
    122122}
    123123
     124bool
     125PIWdgMac::GetBinding(PIBindingKind& left, PIBindingKind& top,
     126                     PIBindingKind& right, PIBindingKind& bottom)
     127{
     128  if (mAdapter) 
     129    mAdapter->GetBinding(left, top, right, bottom);
     130  //else
     131  //  mPane->SetBinding(left, top, right, bottom);
     132  return false;
     133}
     134
     135void PIWdgMac::Refresh()
     136{
     137  if (mPane) mPane->Refresh();
     138  if (mAdapter) mAdapter->Refresh();
     139}
     140
     141
    124142int
    125143PIWdgMac::XSize()
     
    169187bool PIWdgMac::ClaimSelection(unsigned int)
    170188{
    171   int l;
     189  unsigned int l;
    172190  char* txt = SelectionString(l);
    173191  LClipboard::GetClipboard()->SetData('TEXT',txt,l,true);
     
    211229
    212230/* --Methode-- */
    213 char* PIWdgMac::SelectionString(int& len)
     231char* PIWdgMac::SelectionString(unsigned int& len)
    214232{
    215233char *rs = new char[60];
     
    250268  return(mPane->IsVisible());
    251269}
     270
     271
     272// -------- La classe PIScreenBuffer ----------
     273/* --Methode-- */
     274PIScreenBuffer::PIScreenBuffer(int sx, int sy)
     275{
     276  if (sx < 1) sx = 1;
     277  if (sy < 1) sy = 1;
     278  Rect bounds = {0,0,sy,sx};
     279  mGWorld = new LGWorld(bounds);
     280}
     281/* --Methode-- */
     282PIScreenBuffer::~PIScreenBuffer()
     283{
     284  delete mGWorld;
     285}
     286
     287/* --Methode-- */
     288int PIScreenBuffer::XSize()
     289{
     290  Rect bounds;
     291  mGWorld->GetBounds(bounds);
     292  return bounds.right - bounds.left;
     293}
     294
     295/* --Methode-- */
     296int PIScreenBuffer::YSize()
     297{
     298  Rect bounds;
     299  mGWorld->GetBounds(bounds);
     300  return bounds.bottom - bounds.top;
     301}
     302
     303/* --Methode-- */
     304void PIScreenBuffer::CopyFromWdg(PIWdg* wdg, int ox, int oy, int dx, int dy, int x, int y)
     305{
     306  mGWorld->BeginDrawing();
     307  LPane* pane = wdg->GetPane();
     308  Rect srcRect = {oy, ox, oy+dy, ox+dx};
     309  Rect destRect = {y, x, y+dy, x+dx};
     310  CopyBits(&pane->GetMacPort()->portBits,&GrafPtr(mGWorld->GetMacGWorld())->portBits,&srcRect,&destRect,srcCopy,NULL);
     311  mGWorld->EndDrawing();
     312}
     313
     314/* --Methode-- */
     315void PIScreenBuffer::CopyToWdg(PIWdg* wdg, int ox, int oy, int dx, int dy, int x, int y)
     316{
     317  LPane* pane = wdg->GetPane();
     318  Rect srcRect = {oy, ox, oy+dy, ox+dx};
     319  Rect destRect = {y, x, y+dy, x+dx};
     320  CopyBits(&GrafPtr(mGWorld->GetMacGWorld())->portBits,&pane->GetMacPort()->portBits,&srcRect,&destRect,srcCopy,NULL);
     321}
     322
     323/* --Methode-- */
     324void PIScreenBuffer::CopyFrom(PIScreenBuffer* grb, int ox, int oy, int dx, int dy, int x, int y)
     325{
     326
     327  mGWorld->BeginDrawing();
     328  Rect srcRect = {oy, ox, oy+dy, ox+dx};
     329  Rect destRect = {y, x, y+dy, x+dx};
     330  CopyBits(&GrafPtr(grb->mGWorld->GetMacGWorld())->portBits,&GrafPtr(mGWorld->GetMacGWorld())->portBits,&srcRect,&destRect,srcCopy,NULL);
     331  mGWorld->EndDrawing();
     332}
  • trunk/SophyaPI/PI/piwdgmac.h

    r88 r369  
    2121  virtual void           SetPos(int px, int py);
    2222  virtual void           SetBorderWidth(int /*bw*/) {}
     23 
    2324  virtual void           SetBinding(PIBindingKind left, PIBindingKind top,
    2425                                    PIBindingKind right, PIBindingKind bottom);
     26  virtual bool           GetBinding(PIBindingKind& left, PIBindingKind& top,
     27                                    PIBindingKind& right, PIBindingKind& bottom);
    2528  virtual int            XSize();
    2629  virtual int            YSize();
     
    2932  virtual string         Nom()  { return mNom; }
    3033
     34// Pour activer, desactiver un composant graphique (PIWdg)
    3135  virtual void           Manage();
    3236  virtual void           UnManage();
     
    3438  virtual bool           IsVisible();
    3539 
     40//  Fonction qui doit etre appelee pour rafraichir la fenetre
     41  virtual void           Refresh();
     42 
     43//  Pour rendre un composant graphique (PIWdg) sensible/insensible
     44//  aux actions utilisateur (souris, clavier, ...)
     45  virtual void           SetSensitive();
     46  virtual void           SetUnSensitive();
     47  virtual bool           IfSensitive();
     48
    3649//  Gestion de copier-coller
    37 // $$CHECK$$ Pourquoi les noms ont-ils change ???
    38 // En plus, pour des trucs tout aussi obscurs...
    39 // Et c'est quoi, typ, qui en plus n'est pas utilise sous X ???
    4050  virtual bool           ClaimSelection(unsigned int typ=PICP_string);
    4151  virtual void           SelectionLost();
     
    4454  virtual void           PasteSelection(unsigned int typ, void *, unsigned int l);
    4555  virtual void           CopyFromSelection(char *, int l);
    46   virtual char*          SelectionString(int& len);
     56  virtual char*          SelectionString(unsigned int& len);
    4757  virtual void           SelectionTransferEnd();
    4858
     59//  Copie depuis un PIWdgGen
     60  virtual void           CopyFrom(PIWdgGen* wdg, int ox, int oy, int dx, int dy, int x, int y);
     61
     62//  Gestion des EventHandler
     63  virtual void           AddDrawHandler(PIEventHandler* drwh, bool ad=false);
     64  virtual void           RemoveDrawHandler(PIEventHandler* drwh);
     65  virtual void           AddEventHandler(PIEventHandler* evh, unsigned long evtmask, bool ad=false);
     66  virtual void           RemoveEventHandler(PIEventHandler* evh);
     67
     68
     69  LPane*                 GetPane() {return mPane;}
     70 
    4971protected:
    5072  LPane*                                 mPane;
     
    6183typedef PIWdgMac PIWdg;
    6284
     85// -------- La classe PIScreenBuffer ----------
     86
     87#include <UGWorld.h>
     88
     89class PIScreenBuffer {
     90public :
     91                 PIScreenBuffer(int sx, int sy);
     92  virtual       ~PIScreenBuffer();
     93
     94  virtual int       XSize();
     95  virtual int       YSize();
     96  virtual void      CopyFromWdg(PIWdg* wdg, int ox, int oy, int dx, int dy, int x, int y);
     97  virtual void      CopyToWdg(PIWdg* wdg, int ox, int oy, int dx, int dy, int x, int y);
     98  virtual void      CopyFrom(PIScreenBuffer* grb, int ox, int oy, int dx, int dy, int x, int y);
     99
     100protected :
     101  LGWorld* mGWorld;
     102};
     103
     104
    63105
    64106#endif
Note: See TracChangeset for help on using the changeset viewer.