Changeset 30 in Sophya for trunk/SophyaPI/PI/pistdwdgx.cc


Ignore:
Timestamp:
Nov 1, 1996, 8:14:18 PM (29 years ago)
Author:
ansari
Message:

Nouveaux Objets : PIScrollBar et PIList
Nouvelles methodes PIColorMap::GetColor() Et PIWindow::AutoHideOnClose()
Reza 1 Nov 96

File:
1 edited

Legend:

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

    r23 r30  
    221221
    222222
     223/************* PICheckBoxX ************/
     224#include <Xm/ToggleB.h>
     225
     226// Fonction prive (CallBack)
     227static void toggb_action(Widget w, XtPointer *usd, XtPointer *calld);
     228
     229/* Nouvelle-Fonction */
     230void  toggb_action(Widget , XtPointer *usd, XtPointer *)
     231{
     232PICheckBoxX *picb;
     233picb = (PICheckBoxX *) usd ;
     234picb->Send(picb->Msg(), PIMsg_DataChanged, (void *)picb->GetState());
     235return;
     236}
     237
     238/* --Methode-- */
     239PICheckBoxX::PICheckBoxX(PIContainerGen *par, char *nom, PIMessage msg,
     240                         int sx, int sy, int px, int py)
     241: PICheckBoxGen(par, nom, msg, sx, sy, px, py)
     242{
     243CreateXtWdg(nom, xmToggleButtonWidgetClass, NULL, sx, sy, px, py);
     244XtAddCallback(XtWdg(), XmNvalueChangedCallback,
     245              toggb_action, (XtPointer)this);
     246Arg warg[2];
     247XtSetArg(warg[0],XmNhighlightThickness, 0);
     248XtSetValues(XtWdg(), warg, 1);
     249Manage();
     250}
     251
     252
     253/* --Methode-- */
     254PICheckBoxX::~PICheckBoxX()
     255{}
     256
     257
     258/* --Methode-- */
     259void PICheckBoxX::SetState(bool st)
     260{
     261Arg warg[2];
     262XtSetArg(warg[0],XmNset, st);
     263XtSetValues(XtWdg(), warg, 1);
     264return;
     265}
     266
     267/* --Methode-- */
     268bool PICheckBoxX::GetState()
     269{
     270int val;
     271Arg warg[2];
     272XtSetArg(warg[0], XmNset, &val);
     273XtGetValues(XtWdg(), warg, 1);
     274return ((bool)val);
     275}
     276
     277
    223278/************* PIScaleX ************/
    224279#include <Xm/Scale.h>
     
    241296/* --Methode-- */
    242297PIScaleX::PIScaleX(PIContainerGen *par, char *nom, PIMessage msg,
    243                    int min, int max, int sx, int sy, int px, int py)
    244 : PIScaleGen(par, nom, msg, min, max, sx, sy, px, py)
     298                   bool horiz, int sx, int sy, int px, int py)
     299: PIScaleGen(par, nom, msg, horiz, sx, sy, px, py)
    245300{
    246301int n=0;
     
    248303CreateXtWdg(nom, xmScaleWidgetClass, NULL, sx, sy, px, py);
    249304XtSetArg(warg[n], XmNshowValue, TRUE); n++;
    250 if (sx > sy)
     305if (horiz)
    251306  {
    252307  XtSetArg(warg[n], XmNorientation, XmHORIZONTAL); n++;
     
    263318
    264319XtSetValues(XtWdg(), warg, n);
    265 SetMinMax(min, max);
    266 SetValue(min);
     320SetMinMax(1, 10);
     321SetValue(1);
    267322XtAddCallback(XtWdg(), XmNvalueChangedCallback,
    268323              scale_action, (XtPointer)this);
     
    312367XtGetValues(this->sdw, warg, n);
    313368mVal = val;
    314 return(val);
     369return(mVal);
    315370}
    316371
     
    322377}
    323378
    324 /************* PICheckBoxX ************/
    325 #include <Xm/ToggleB.h>
     379
     380
     381/************* PIScrollBarX ************/
     382
     383#include <Xm/ScrollBar.h>
    326384
    327385// Fonction prive (CallBack)
    328 static void toggb_action(Widget w, XtPointer *usd, XtPointer *calld);
    329 
    330 /* Nouvelle-Fonction */
    331 void  toggb_action(Widget , XtPointer *usd, XtPointer *)
    332 {
    333 PICheckBoxX *picb;
    334 picb = (PICheckBoxX *) usd ;
    335 picb->Send(picb->Msg(), PIMsg_DataChanged, (void *)picb->GetState());
    336 return;
    337 }
    338 
    339 /* --Methode-- */
    340 PICheckBoxX::PICheckBoxX(PIContainerGen *par, char *nom, PIMessage msg,
    341                          int sx, int sy, int px, int py)
    342 : PICheckBoxGen(par, nom, msg, sx, sy, px, py)
    343 {
    344 CreateXtWdg(nom, xmToggleButtonWidgetClass, NULL, sx, sy, px, py);
    345 XtAddCallback(XtWdg(), XmNvalueChangedCallback,
    346               toggb_action, (XtPointer)this);
    347 Arg warg[2];
    348 XtSetArg(warg[0],XmNhighlightThickness, 0);
    349 XtSetValues(XtWdg(), warg, 1);
     386static void scrollbar_action(Widget w, XtPointer *usd,
     387                             XmScrollBarCallbackStruct *calld);
     388static void scrollbar_drag(Widget w, XtPointer *usd,
     389                           XmScrollBarCallbackStruct *calld);
     390
     391void  scrollbar_action(Widget, XtPointer *usd,
     392                       XmScrollBarCallbackStruct *calld)
     393{
     394PIScrollBar *pis;
     395
     396pis = (PIScrollBar *) usd ;
     397pis->CBSetVal(calld->value);
     398pis->Send(pis->Msg(), PIMsg_DataChanged, (void *)calld->value);
     399return;
     400}
     401
     402void  scrollbar_drag(Widget, XtPointer *usd,
     403                       XmScrollBarCallbackStruct *calld)
     404{
     405PIScrollBar *pis;
     406
     407pis = (PIScrollBar *) usd ;
     408pis->CBSetVal(calld->value);
     409pis->Send(pis->Msg(), PIMsg_Drag, (void *)calld->value);
     410return;
     411}
     412
     413/* --Methode-- */
     414PIScrollBarX::PIScrollBarX(PIContainerGen *par, char *nom, PIMessage msg,
     415                           bool vert, int sx, int sy, int px, int py)
     416: PIScrollBarGen(par, nom, msg, vert, sx, sy, px, py)
     417{
     418int n=0;
     419Arg warg[3];
     420
     421CreateXtWdg(nom, xmScrollBarWidgetClass, NULL, sx, sy, px, py);
     422if (vert)
     423  {
     424  XtSetArg(warg[n], XmNorientation, XmVERTICAL); n++;
     425  XtSetArg(warg[n], XmNprocessingDirection, XmMAX_ON_BOTTOM); n++;
     426  }
     427else
     428  {
     429  XtSetArg(warg[n], XmNorientation, XmHORIZONTAL); n++;
     430  XtSetArg(warg[n], XmNprocessingDirection, XmMAX_ON_RIGHT); n++;
     431  }
     432XtSetValues(XtWdg(), warg, n);
     433mAcD = false;
     434mVal = -1;
     435mMin = mMax = 0;
     436mSz = 0;
     437SetMinMax(0, 100);
     438SetSize(10);
     439SetValue(0);
     440XtAddCallback(XtWdg(), XmNvalueChangedCallback,
     441              scrollbar_action, (XtPointer)this);
    350442Manage();
    351443}
    352444
    353 
    354 /* --Methode-- */
    355 PICheckBoxX::~PICheckBoxX()
     445/* --Methode-- */
     446PIScrollBarX::~PIScrollBarX()
    356447{}
    357448
    358449
    359450/* --Methode-- */
    360 void PICheckBoxX::SetState(bool st)
    361 {
    362 Arg warg[2];
    363 XtSetArg(warg[0],XmNset, st);
    364 XtSetValues(XtWdg(), warg, 1);
    365 return;
    366 }
    367 
    368 /* --Methode-- */
    369 bool PICheckBoxX::GetState()
     451void PIScrollBarX::ActivateDrag(bool acd)
     452{
     453if (mAcD == acd)  return;
     454   
     455if (mAcD)
     456  XtRemoveCallback(XtWdg(), XmNdragCallback,
     457                   scrollbar_drag, (XtPointer)this);
     458else
     459  XtAddCallback(XtWdg(), XmNdragCallback,
     460                scrollbar_drag, (XtPointer)this);
     461mAcD = acd;
     462return;
     463}       
     464
     465/* --Methode-- */
     466void PIScrollBarX::SetMinMax(int min, int max)
     467{
     468if (min >= max)  max = min+100;
     469if (mVal < min)  mVal = min;
     470if (mVal > max)  mVal = max;
     471int n=0;
     472Arg warg[3];
     473XtSetArg(warg[n], XmNminimum, min); n++;
     474XtSetArg(warg[n], XmNmaximum, max); n++;
     475XtSetArg(warg[n], XmNvalue, mVal); n++;
     476XtSetValues(XtWdg(), warg, n);
     477mMin = min;   mMax = max;
     478return;
     479}
     480
     481
     482/* --Methode-- */
     483void PIScrollBarX::SetValue(int val)
     484{
     485int n=0;
     486if (val < mMin)  val = mMin;
     487if (val > mMax)  val = mMax;
     488Arg warg[2];
     489XtSetArg(warg[n], XmNvalue, val); n++;
     490XtSetValues(this->sdw, warg, n);
     491mVal = val;
     492return;
     493}
     494
     495/* --Methode-- */
     496int  PIScrollBarX::GetValue()
    370497{
    371498int val;
    372 Arg warg[2];
    373 XtSetArg(warg[0], XmNset, &val);
    374 XtGetValues(XtWdg(), warg, 1);
    375 return ((bool)val);
    376 }
     499int n=0;
     500Arg warg[2];
     501XtSetArg(warg[n], XmNvalue, &val); n++;
     502XtGetValues(this->sdw, warg, n);
     503mVal = val;
     504return(mVal);
     505}
     506
     507/* --Methode-- */
     508void PIScrollBarX::SetSize(int sz)
     509{
     510int n=0;
     511Arg warg[3];
     512int szl;
     513
     514szl = mMax-mMin;
     515if (sz > szl)  sz = szl;
     516szl /= 100;
     517if (szl < 1)  szl = 1;
     518if (sz < szl)  sz = szl;
     519szl = sz/10;
     520if (szl < 1)  szl = 1;
     521XtSetArg(warg[n], XmNsliderSize, sz); n++;
     522XtSetArg(warg[n], XmNpageIncrement, sz); n++;
     523XtSetArg(warg[n], XmNincrement, szl); n++;
     524XtSetValues(this->sdw, warg, n);
     525mSz = sz;
     526return;
     527}
     528
     529/* --Methode-- */
     530int  PIScrollBarX::GetSize()
     531{
     532int sz;
     533int n=0;
     534Arg warg[2];
     535XtSetArg(warg[n], XmNsliderSize, &sz); n++;
     536XtGetValues(this->sdw, warg, n);
     537mSz = sz;
     538return(mSz);
     539}
     540
     541
     542/* --Methode-- */
     543void  PIScrollBarX::CBSetVal(int val)
     544{
     545mVal = val;
     546return;
     547}
     548
Note: See TracChangeset for help on using the changeset viewer.