Layout.c File Reference

#include <X11/IntrinsicP.h>
#include <X11/StringDefs.h>
#include <X11/Xmu/Misc.h>
#include <X11/Xmu/Converters.h>
#include <X11/Xaw3d/LayoutP.h>
#include <ctype.h>
#include <stdio.h>

Include dependency graph for Layout.c:

Go to the source code of this file.

Defines

#define DBUG_ENTER(s)
#define DBUG_VOID_RETURN   return
#define DBUG_PRINT(f, s)
#define DBUG_RETURN(f, v)   return(v)
#define offset(field)   XtOffsetOf(LayoutRec, layout.field)
#define SuperClass   ((ConstraintWidgetClass)&constraintClassRec)
#define ForAllChildren(pw, childP)
#define CheckGlue(l, box, glue, n)
#define DoStretch(l, box, dir)   CheckGlue (l, box, box->params.stretch[dir], (double) box->natural[dir]);
#define DoShrink(l, box, dir)   CheckGlue (l, box, box->params.shrink[dir], (double) box->natural[dir])
#define GluePart(a, b, dist)

Functions

static void ClassInitialize ()
static void Initialize ()
static void Resize ()
static Boolean SetValues ()
static XtGeometryResult GeometryManager ()
static void ChangeManaged ()
static void InsertChild ()
static XtGeometryResult QueryGeometry ()
static void GetDesiredSize ()
static void LayoutLayout ()
static void LayoutGetNaturalSize ()
static void LayoutFreeLayout ()
void LayYYsetsource ()
void LayYYsetdest ()
int LayYYparse ()
static Boolean CvtStringToLayout (Display *dpy, XrmValue *args, Cardinal *num_args, XrmValue *from, XrmValue *to, XtPointer *converter_data)
static void DisposeLayout (XtAppContext app, XrmValue *to, XtPointer data, XrmValuePtr args, Cardinal *num_args)
static XtGeometryResult GeometryManager (Widget child, XtWidgetGeometry *request, XtWidgetGeometry *reply)
static void Initialize (Widget request, Widget new, ArgList args, Cardinal *num_args)
static void ChangeManaged (Widget gw)
static void GetDesiredSize (Widget child)
static void InsertChild (Widget child)
static void Resize (Widget gw)
static Boolean SetValues (Widget gold, Widget greq, Widget gnew, ArgList args, Cardinal *num_args)
static XtGeometryResult QueryGeometry (Widget gw, XtWidgetGeometry *request, XtWidgetGeometry *prefered_return)
static void PrintGlue (GlueRec g)
static void PrintDirection (LayoutDirection dir)
static void TabTo (int level)
static void PrintBox (BoxPtr box, int level)
static ExprPtr LookupVariable (BoxPtr child, XrmQuark quark)
static double Evaluate (LayoutWidget l, BoxPtr box, ExprPtr expr, double natural)
static void DisposeExpr (ExprPtr expr)
static void ComputeNaturalSizes (LayoutWidget l, BoxPtr box, LayoutDirection dir)
static Bool ComputeSizes (BoxPtr box)
static void SetSizes (BoxPtr box, Position x, Position y)
static void LayoutFreeLayout (BoxPtr box)
static void LayoutGetNaturalSize (LayoutWidget l, Dimension *widthp, Dimension *heightp)
static void LayoutLayout (LayoutWidget l, Bool attemptResize)

Variables

static XtResource resources []
LayoutClassRec layoutClassRec
WidgetClass layoutWidgetClass = (WidgetClass) &layoutClassRec


Define Documentation

#define CheckGlue ( l,
box,
glue,
n   ) 

Value:

{ \
    if (glue.expr) \
        glue.value = Evaluate (l, box, glue.expr, n); \
    if (glue.order == 0 && glue.value == 0) \
        glue.order = -1; \
    else if (glue.order == -1 && glue.value != 0) \
        glue.order = 0; \
}

Definition at line 634 of file Layout.c.

#define DBUG_ENTER ( s   ) 

Definition at line 63 of file Layout.c.

Referenced by ChangeManaged(), ComputeNaturalSizes(), LayoutGetNaturalSize(), LayoutLayout(), and LookupVariable().

#define DBUG_PRINT ( f,
s   ) 

Definition at line 65 of file Layout.c.

Referenced by ComputeNaturalSizes(), Evaluate(), and LookupVariable().

#define DBUG_RETURN ( f,
v   )     return(v)

Definition at line 66 of file Layout.c.

Referenced by LookupVariable().

#define DBUG_VOID_RETURN   return

Definition at line 64 of file Layout.c.

Referenced by ChangeManaged(), ComputeNaturalSizes(), LayoutGetNaturalSize(), and LayoutLayout().

#define DoShrink ( l,
box,
dir   )     CheckGlue (l, box, box->params.shrink[dir], (double) box->natural[dir])

Definition at line 646 of file Layout.c.

Referenced by ComputeNaturalSizes().

#define DoStretch ( l,
box,
dir   )     CheckGlue (l, box, box->params.stretch[dir], (double) box->natural[dir]);

Definition at line 643 of file Layout.c.

Referenced by ComputeNaturalSizes().

#define ForAllChildren ( pw,
childP   ) 

Value:

for ( (childP) = (pw)->composite.children ; \
        (childP) < (pw)->composite.children + (pw)->composite.num_children ; \
        (childP)++ ) if (!XtIsManaged(*childP)) ; else

Definition at line 190 of file Layout.c.

Referenced by ChangeManaged(), GetEventEntry(), GetMenuHeight(), GetMenuWidth(), Layout(), ManageAndUnmanageGrips(), Redisplay(), Resize(), and ResortChildren().

#define GluePart ( a,
b,
dist   ) 

Value:

((a) ? ((int) (((a) * (dist)) / (b) + \
                                        ((dist >= 0) ? 0.5 : -0.5))) : 0)

Definition at line 780 of file Layout.c.

Referenced by ComputeSizes().

#define offset ( field   )     XtOffsetOf(LayoutRec, layout.field)

Definition at line 75 of file Layout.c.

#define SuperClass   ((ConstraintWidgetClass)&constraintClassRec)

Definition at line 108 of file Layout.c.


Function Documentation

static void ChangeManaged ( Widget  gw  )  [static]

Definition at line 310 of file Layout.c.

References DBUG_ENTER, DBUG_VOID_RETURN, ForAllChildren, GetDesiredSize(), LayoutLayout(), TRUE, and w.

00312 {
00313     LayoutWidget        w = (LayoutWidget) gw;
00314     Widget              *children;
00315 
00316     DBUG_ENTER("changeManaged");
00317 
00318     ForAllChildren (w, children)
00319         GetDesiredSize (*children);
00320     LayoutLayout ((LayoutWidget) w, TRUE);
00321 #ifdef MOTIF
00322     _XmNavigChangeManaged ( gw );        
00323 #endif
00324     DBUG_VOID_RETURN;
00325 }

Here is the call graph for this function:

static void ChangeManaged (  )  [static]

static void ClassInitialize (  )  [static]

Definition at line 238 of file Layout.c.

References CvtStringToLayout(), DisposeLayout(), and XtRLayout.

00239 {
00240     XtSetTypeConverter ( XtRString, XtRLayout, CvtStringToLayout,
00241                     (XtConvertArgList)NULL, (Cardinal)0, XtCacheNone, 
00242                     DisposeLayout );
00243 }

Here is the call graph for this function:

static void ComputeNaturalSizes ( LayoutWidget  l,
BoxPtr  box,
LayoutDirection  dir 
) [static]

Definition at line 651 of file Layout.c.

References AddGlue, _Box::box, BoxBox, DBUG_ENTER, DBUG_PRINT, DBUG_VOID_RETURN, DoShrink, DoStretch, Evaluate(), _Box::glue, GlueBox, info, LayoutHorizontal, LayoutVertical, MinGlue, _Box::natural, _Box::nextSibling, _Glue::order, _Box::params, QuarkToWidget, _BoxParams::shrink, _BoxParams::stretch, SubInfo, _Box::type, _Box::u, _Glue::value, VariableBox, w, _Box::widget, WidgetBox, and ZeroGlue.

Referenced by LayoutGetNaturalSize().

00655 {
00656     BoxPtr      child;
00657     Widget      w;
00658     SubInfoPtr  info;
00659     int         minStretchOrder, minShrinkOrder;
00660     LayoutDirection thisDir;
00661 
00662     DBUG_ENTER("ComputeNaturalSizes");
00663     DBUG_PRINT("box->type=%d",box->type);
00664     switch (box->type) {
00665     case WidgetBox:
00666         w = box->u.widget.widget = QuarkToWidget (l, box->u.widget.quark);
00667         if (!w)
00668         {
00669             box->natural[LayoutHorizontal] = 0;
00670             box->natural[LayoutVertical] = 0;
00671         }
00672         else 
00673         {
00674             info = SubInfo (w);
00675             box->natural[LayoutHorizontal] = info->naturalSize[LayoutHorizontal];
00676             box->natural[LayoutVertical] = info->naturalSize[LayoutVertical];
00677         }
00678         DoStretch (l, box, dir);
00679         DoShrink (l, box, dir);
00680         DoStretch (l, box, !dir);
00681         DoShrink (l, box, !dir);
00682         break;
00683     case GlueBox:
00684         box->natural[dir] = Evaluate (l, box, box->u.glue.expr, 0.0);
00685         box->natural[!dir] = 0;
00686         DoStretch (l, box, dir);
00687         DoShrink (l, box, dir);
00688         break;
00689     case BoxBox:
00690         thisDir = box->u.box.dir;
00691         box->natural[0] = 0;
00692         box->natural[1] = 0;
00693         minStretchOrder = 100000;
00694         minShrinkOrder = 100000;
00695         ZeroGlue (box->params.shrink[thisDir]);
00696         ZeroGlue (box->params.stretch[thisDir]);
00697         box->params.shrink[!thisDir].order = 100000;
00698         box->params.stretch[!thisDir].order = 100000;
00699         for (child = box->u.box.firstChild; child; child = child->nextSibling) 
00700         {
00701             ComputeNaturalSizes (l, child, thisDir);
00702             /*
00703              * along box axis:
00704              *  normal size += child normal size
00705              *  shrink += child shrink
00706              *  stretch += child stretch
00707              */
00708             box->natural[thisDir] += child->natural[thisDir];
00709             AddGlue (box->params.shrink[thisDir],
00710                      box->params.shrink[thisDir],
00711                      child->params.shrink[thisDir]);
00712             AddGlue (box->params.stretch[thisDir],
00713                      box->params.stretch[thisDir],
00714                      child->params.stretch[thisDir]);
00715             /*
00716              * normal to box axis:
00717              *  normal size = maximum child normal size of minimum shrink order
00718              *  shrink = difference between normal size and minimum shrink
00719              *  stretch = minimum child stretch
00720              */
00721             if (box->natural[!thisDir] >= child->natural[!thisDir])
00722             {
00723                 if (child->params.stretch[!thisDir].order < minShrinkOrder)
00724                 {
00725                     box->natural[!thisDir] = child->natural[!thisDir];
00726                     minStretchOrder = child->params.stretch[!thisDir].order;
00727                     if (child->params.shrink[!thisDir].order < minShrinkOrder)
00728                         minShrinkOrder = child->params.shrink[!thisDir].order;
00729                 }
00730             }
00731             else
00732             {
00733                 if (child->params.shrink[!thisDir].order <= minStretchOrder)
00734                 {
00735                     box->natural[!thisDir] = child->natural[!thisDir];
00736                     minShrinkOrder = child->params.shrink[!thisDir].order;
00737                     if (child->params.stretch[!thisDir].order < minStretchOrder)
00738                         minStretchOrder = child->params.stretch[!thisDir].order;
00739                 }
00740             }
00741             MinGlue (box->params.stretch[!thisDir],
00742                      box->params.stretch[!thisDir],
00743                      child->params.stretch[!thisDir]);
00744             MinGlue (box->params.shrink[!thisDir],
00745                      box->params.shrink[!thisDir],
00746                      child->params.shrink[!thisDir]);
00747         }
00748         if (box->params.shrink[!thisDir].order <= 0)
00749         {
00750             int     minSize;
00751             int     largestMinSize;
00752             
00753             largestMinSize = 0;
00754             for (child = box->u.box.firstChild; child; child = child->nextSibling) 
00755             {
00756                 if (child->params.shrink[!thisDir].order <= 0)
00757                 {
00758                     minSize = child->natural[!thisDir] -
00759                               child->params.shrink[!thisDir].value;
00760                     if (minSize > largestMinSize)
00761                         largestMinSize = minSize;
00762                 }
00763             }
00764             box->params.shrink[!thisDir].value = box->natural[!thisDir] -
00765                                                  largestMinSize;
00766             if (box->params.shrink[!thisDir].value == 0)
00767                 box->params.shrink[!thisDir].order = -1;
00768             else
00769                 box->params.shrink[!thisDir].order = 0;
00770         }
00771         break;
00772     case VariableBox:
00773         break;
00774     }
00775     DBUG_VOID_RETURN;
00776 }

Here is the call graph for this function:

Here is the caller graph for this function:

static Bool ComputeSizes ( BoxPtr  box  )  [static]

Definition at line 784 of file Layout.c.

References _Box::box, BoxBox, dir, GluePart, i, _Box::natural, _Box::nextSibling, _Glue::order, _Box::params, _BoxParams::shrink, _Box::size, size, _BoxParams::stretch, _Box::type, _Box::u, value, _Glue::value, and VariableBox.

Referenced by LayoutLayout().

00786 {
00787     LayoutDirection dir;
00788     BoxPtr          child;
00789     GlueRec         stretch;
00790     GlueRec         shrink;
00791     GlueRec         totalGlue[2];
00792     double          remainingGlue;
00793     GluePtr         glue;
00794     int             size;
00795     int             totalSizes;
00796     int             totalChange[2];
00797     int             change;
00798     int             remainingChange;
00799     Bool            shrinking;
00800     Bool            happy;
00801     int             i;
00802     int             maxGlue;
00803 
00804     dir = box->u.box.dir;
00805     size = box->size[dir];
00806     
00807     stretch = box->params.stretch[dir];
00808     shrink = box->params.shrink[dir];
00809     
00810     /* pick the correct adjustment parameters based on the change direction */
00811 
00812     totalChange[0] = size - box->natural[dir];
00813 
00814     shrinking = totalChange[0] < 0;
00815     
00816     totalChange[1] = 0;
00817     totalGlue[1].order = 100000;
00818     totalGlue[1].value = 0;
00819     maxGlue = 1;
00820     if (shrinking) 
00821     {
00822         totalGlue[0] = shrink;
00823         /* for first-order infinites, shrink it to zero and then
00824          * shrink the zero-orders
00825          */
00826         if (shrink.order == 1) {
00827             totalSizes = 0;
00828             remainingGlue = 0;
00829             for (child = box->u.box.firstChild; 
00830                  child; 
00831                  child = child->nextSibling) 
00832             {
00833                 switch (child->params.shrink[dir].order) {
00834                 case 0:
00835                     remainingGlue += child->params.shrink[dir].value;
00836                     break;
00837                 case 1:
00838                     totalSizes += child->natural[dir];
00839                     break;
00840                 }
00841             }
00842             if (totalSizes < -totalChange[0])
00843             {
00844                 totalGlue[1] = shrink;
00845                 totalGlue[0].order = 0;
00846                 totalGlue[0].value = remainingGlue;
00847                 totalChange[1] = -totalSizes;
00848                 totalChange[0] = totalChange[0] - totalChange[1];
00849                 maxGlue = 2;
00850             }
00851         }
00852         if (totalGlue[0].order <= 0 && 
00853             totalChange[0] > totalGlue[0].value)
00854         {
00855             totalChange[0] = totalGlue[0].value;
00856         }
00857     }
00858     else
00859         totalGlue[0] = stretch;
00860 
00861     /* adjust each box */
00862     totalSizes = 0;
00863     remainingGlue = totalGlue[0].value + totalGlue[1].value;
00864     remainingChange = totalChange[0] + totalChange[1];
00865     happy = True;
00866     for (child = box->u.box.firstChild; child; child = child->nextSibling) 
00867     {
00868         /* never add glue or stretch to a VariableBox! */
00869         if (child->type == VariableBox) continue;
00870 
00871         if (shrinking)
00872             glue = &child->params.shrink[dir];
00873         else
00874             glue = &child->params.stretch[dir];
00875     
00876         child->size[dir] = child->natural[dir];
00877         for (i = 0; i < maxGlue; i++)
00878         {
00879             if (glue->order == totalGlue[i].order)
00880             {
00881                 remainingGlue -= glue->value;
00882                 if (remainingGlue <= 0)
00883                     change = remainingChange;
00884                 else
00885                     change = GluePart (glue->value, 
00886                                        totalGlue[i].value, 
00887                                        totalChange[i]);
00888                 child->size[dir] += change;
00889                 remainingChange -= change;
00890             }
00891         }
00892         child->size[!dir] = box->size[!dir];
00893         totalSizes += child->size[dir];
00894         if (child->type == BoxBox)
00895             if (!ComputeSizes (child))
00896                 happy = False;
00897     }
00898     return totalSizes == box->size[dir] && happy;
00899 }

Here is the caller graph for this function:

static Boolean CvtStringToLayout ( Display *  dpy,
XrmValue *  args,
Cardinal *  num_args,
XrmValue *  from,
XrmValue *  to,
XtPointer *  converter_data 
) [static]

Definition at line 209 of file Layout.c.

References FALSE, LayYYparse(), LayYYsetdest(), LayYYsetsource(), and TRUE.

Referenced by ClassInitialize().

00215 {
00216     static BoxPtr tmp;
00217     
00218     LayYYsetsource ((char *) from->addr);
00219     if (!to->addr) to->addr = (XtPointer)&tmp;
00220     LayYYsetdest ((BoxPtr *) to->addr);
00221     to->size = sizeof (BoxPtr *);
00222     return  LayYYparse() ? FALSE : TRUE;
00223 }

Here is the call graph for this function:

Here is the caller graph for this function:

static void DisposeExpr ( ExprPtr  expr  )  [static]

Definition at line 611 of file Layout.c.

References Binary, Dispose, Height, Unary, Variable, and Width.

Referenced by LayoutFreeLayout().

00613 {
00614     if (!expr)
00615         return;
00616     switch (expr->type) {
00617     case Constant:
00618         break;
00619     case Binary:
00620         DisposeExpr (expr->u.binary.left);
00621         DisposeExpr (expr->u.binary.right);
00622         break;
00623     case Unary:
00624         DisposeExpr (expr->u.unary.down);
00625         break;
00626     case Width:
00627     case Height:
00628     case Variable:
00629         break;
00630     }
00631     Dispose (expr);
00632 }

Here is the caller graph for this function:

static void DisposeLayout ( XtAppContext  app,
XrmValue *  to,
XtPointer  data,
XrmValuePtr  args,
Cardinal *  num_args 
) [static]

Definition at line 227 of file Layout.c.

References LayoutFreeLayout().

Referenced by ClassInitialize().

00233 {
00234     LayoutFreeLayout (* (LayoutPtr *) to->addr);
00235 }

Here is the call graph for this function:

Here is the caller graph for this function:

static double Evaluate ( LayoutWidget  l,
BoxPtr  box,
ExprPtr  expr,
double  natural 
) [static]

Definition at line 534 of file Layout.c.

References Binary, buf, DBUG_PRINT, Divide, expr(), Height, info, LayoutHorizontal, LayoutVertical, left, LookupVariable(), Minus, Percent, Plus, QuarkToWidget, right, SubInfo, Times, Unary, Variable, void(), and Width.

Referenced by ComputeNaturalSizes().

00539 {
00540     double      left, right, down;
00541     Widget      widget;
00542     SubInfoPtr  info;
00543 
00544     DBUG_PRINT("Evaluate %d", expr->type);
00545     switch (expr->type) {
00546     case Constant:
00547         return expr->u.constant;
00548     case Binary:
00549         left = Evaluate (l, box, expr->u.binary.left, natural);
00550         right = Evaluate (l, box, expr->u.binary.right, natural);
00551         switch (expr->u.binary.op) {
00552         case Plus:
00553             return left + right;
00554         case Minus:
00555             return left - right;
00556         case Times:
00557             return left * right;
00558         case Divide:
00559             return left / right;
00560         case Percent:
00561             return right * left / 100.0;
00562         }
00563     case Unary:
00564         down = Evaluate (l, box, expr->u.unary.down, natural);
00565         switch (expr->u.unary.op) {
00566         case Percent:
00567             return natural * down / 100.0;
00568         case Minus:
00569             return -down;
00570         case Plus:
00571         case Times:
00572         case Divide:
00573             break;
00574         }
00575     case Width:
00576         widget = QuarkToWidget (l, expr->u.width);
00577         if (!widget)
00578             return 0;
00579         info = SubInfo (widget);
00580         return info->naturalSize[LayoutHorizontal];
00581     case Height:
00582         widget = QuarkToWidget (l, expr->u.height);
00583         if (!widget)
00584             return 0;
00585         info = SubInfo (widget);
00586         return info->naturalSize[LayoutVertical];
00587     case Variable: 
00588         {
00589         /* in the original code there was no nexpr, 
00590            expr was overwritten by LookupVariable and 
00591            the expression "expr->u.variable" to obtain the
00592            variable name for the errormessage cause a segmentation
00593            violation */
00594         ExprPtr    nexpr;
00595         nexpr = LookupVariable (box, expr->u.variable);
00596         if (!nexpr)
00597             {
00598             char    buf[256];
00599             (void) sprintf (buf, "Layout: undefined variable %s\n",
00600                             XrmQuarkToString (expr->u.variable));
00601             XtError (buf);
00602             return 0.0;
00603             }
00604         return Evaluate (l, box, nexpr, natural);
00605         }
00606     }
00607     return 0.0;
00608 }

Here is the call graph for this function:

Here is the caller graph for this function:

static XtGeometryResult GeometryManager ( Widget  child,
XtWidgetGeometry *  request,
XtWidgetGeometry *  reply 
) [static]

Definition at line 264 of file Layout.c.

References FALSE, LayoutHorizontal, LayoutLayout(), LayoutVertical, p, SubInfo, TRUE, and w.

00267 {
00268     LayoutWidget    w = (LayoutWidget) XtParent(child);
00269     SubInfoPtr      p = SubInfo(child);
00270     int             bw;
00271     Bool            changed, bwChanged;
00272 
00273     bw = p->naturalBw;
00274     changed = FALSE;
00275     bwChanged = FALSE;
00276     if (request->request_mode & CWBorderWidth &&
00277         request->border_width != child->core.border_width) 
00278     {
00279         p->naturalBw = bw;
00280         bw = request->border_width;
00281         changed = TRUE;
00282         bwChanged = TRUE;
00283     }
00284     if (bwChanged || ((request->request_mode & CWWidth) &&
00285         request->width != child->core.width))
00286     {
00287         p->naturalSize[LayoutHorizontal] = request->width + bw * 2;
00288         changed = TRUE;
00289     }
00290     if (bwChanged || ((request->request_mode & CWHeight) &&
00291         request->height != child->core.height))
00292     {
00293         p->naturalSize[LayoutVertical] = request->height + bw * 2;
00294         changed = TRUE;
00295     }
00296     if (changed)
00297         LayoutLayout (w, TRUE);
00298     return XtGeometryDone;
00299 }

Here is the call graph for this function:

static XtGeometryResult GeometryManager (  )  [static]

static void GetDesiredSize ( Widget  child  )  [static]

Definition at line 328 of file Layout.c.

References LayoutHorizontal, LayoutVertical, p, and SubInfo.

00330 {
00331     XtWidgetGeometry    desired;
00332     SubInfoPtr          p;
00333     
00334     XtQueryGeometry (child, (XtWidgetGeometry *) NULL, &desired);
00335     p = SubInfo (child);
00336     p->naturalBw = desired.border_width;
00337     p->naturalSize[LayoutHorizontal] = desired.width + desired.border_width * 2;
00338     p->naturalSize[LayoutVertical] = desired.height + desired.border_width * 2;
00339 }

static void GetDesiredSize (  )  [static]

Referenced by ChangeManaged(), and InsertChild().

Here is the caller graph for this function:

static void Initialize ( Widget  request,
Widget  new,
ArgList  args,
Cardinal *  num_args 
) [static]

Definition at line 302 of file Layout.c.

00306 {
00307 /*    LayoutWidget w = (LayoutWidget)new; */
00308 }

static void Initialize (  ) 

Definition at line 26 of file javasci_globals.c.

00027 {
00028   static char env[1024];
00029   static char initstr[]="exec(\"SCI/etc/scilab.start\",-1);quit;";
00030   static int iflag=-1, stacksize = 1000000, ierr=0;
00031 
00032   #ifdef _MSC_VER
00033     static char JavaSciInterf[]="javasci";
00034     static char nw[]="-nw";
00035     static char nb[]="-nb";
00036   #endif
00037 
00038   
00039   char *p1 = (char*)getenv ("SCI");
00040   
00041   
00042   #ifdef _MSC_VER
00043   /* Supprime le mode windows et la baniere */
00044     add_sci_argv(JavaSciInterf);
00045     add_sci_argv(nb);
00046   #endif
00047   
00048   #ifdef _MSC_VER 
00049     if ( p1== NULL )
00050     {
00051                 /* Detection Scilab path */
00052                 char modname[MAX_PATH+1];
00053                 if (!GetModuleFileName (GetModuleHandle("javasci.dll"), modname, MAX_PATH))
00054                 {
00055                         MessageBox(NULL,"javasci.dll not found","Warning",MB_ICONWARNING);
00056                 }
00057                 else
00058                 {
00059                         char *p;
00060                         if ((p = strrchr (modname, '\\')) == NULL) exit(1); /* remove \javasci.dll from modname */
00061                         else
00062                         {
00063                                 *p='\0';
00064                                 if ((p = strrchr (modname, '\\')) == NULL) exit(1); /* remove \bin from modname */
00065                                 else
00066                                 {
00067                                         *p='\0';
00068                                         set_sci_env(modname);
00069                                 }
00070                         }
00071                 }
00072     }
00073     else 
00074         {
00075                 char *pathSCI=(char*)MALLOC((strlen(p1)+1)*sizeof(char));
00076                 sprintf(pathSCI,"%s",p1);
00077                 set_sci_env(pathSCI);
00078                 if (pathSCI) {FREE(pathSCI);pathSCI=NULL;}
00079         }
00080   #else
00081    if (p1==NULL)
00082    {
00083         fprintf(stderr,"Please define SCI environment variable\n");
00084         sprintf (env, "%s=%s", "SCI",SCI);
00085         setSCIpath(SCI);
00086         putenv (env);
00087    }
00088   #endif
00089   /* set TMPDIR */
00090   C2F(settmpdir)();
00091   /* Scilab Initialization */
00092   C2F(inisci)(&iflag,&stacksize,&ierr);
00093   if ( ierr > 0 ) 
00094     {
00095       fprintf(stderr,"Scilab initialization failed !\n");
00096       exit(1);
00097     }
00098 
00099 
00100   /* Initialisation fenetre graphique */
00101   #ifdef _MSC_VER
00102     InitWindowGraphDll();
00103   #endif
00104 
00105   /* pour initialisation de la primitive scilab : fromjava() */
00106   SetFromJavaToON();
00107 
00108   /* Chargement de Scilab.start */
00109   C2F(scirun)(initstr,(int)strlen(initstr));
00110  
00111 }

static void InsertChild ( Widget  child  )  [static]

Definition at line 341 of file Layout.c.

References GetDesiredSize(), and SuperClass.

00343 {
00344     (*SuperClass->composite_class.insert_child) (child);
00345     GetDesiredSize (child);
00346 }

Here is the call graph for this function:

static void InsertChild (  )  [static]

static void LayoutFreeLayout ( BoxPtr  box  )  [static]

Definition at line 955 of file Layout.c.

References _Box::box, BoxBox, Dispose, DisposeExpr(), GlueBox, LayoutFreeLayout(), LayoutHorizontal, LayoutVertical, _Box::nextSibling, _Box::u, VariableBox, and WidgetBox.

00957 {
00958     BoxPtr  child, next;
00959     
00960     switch (box->type) {
00961     case BoxBox:
00962         for (child = box->u.box.firstChild; child; child = next)
00963         {
00964             next = child->nextSibling;
00965             LayoutFreeLayout (child);
00966         }
00967         break;
00968     case GlueBox:
00969         DisposeExpr (box->u.glue.expr);
00970         break;
00971     case WidgetBox:
00972     case VariableBox:
00973     default: 
00974         break;
00975     }
00976     DisposeExpr (box->params.stretch[LayoutHorizontal].expr);
00977     DisposeExpr (box->params.shrink[LayoutHorizontal].expr);
00978     DisposeExpr (box->params.stretch[LayoutVertical].expr);
00979     DisposeExpr (box->params.shrink[LayoutVertical].expr);
00980     Dispose (box);
00981 }

Here is the call graph for this function:

static void LayoutFreeLayout (  )  [static]

Referenced by DisposeLayout(), and LayoutFreeLayout().

Here is the caller graph for this function:

static void LayoutGetNaturalSize ( LayoutWidget  l,
Dimension *  widthp,
Dimension *  heightp 
) [static]

Definition at line 985 of file Layout.c.

References ComputeNaturalSizes(), DBUG_ENTER, DBUG_VOID_RETURN, LayoutHorizontal, LayoutVertical, and _Box::natural.

00988 {
00989     BoxPtr              box;
00990 
00991     DBUG_ENTER("LayoutGetNaturalSize");
00992     box = l->layout.layout;
00993     if (box) 
00994     {
00995         ComputeNaturalSizes (l, box, LayoutHorizontal);
00996         *widthp = box->natural[LayoutHorizontal];
00997         *heightp = box->natural[LayoutVertical];
00998     }
00999     else
01000     {
01001         *widthp = 0;
01002         *heightp = 0;
01003     }
01004     DBUG_VOID_RETURN;
01005 }

Here is the call graph for this function:

static void LayoutGetNaturalSize (  )  [static]

Referenced by LayoutLayout(), and QueryGeometry().

Here is the caller graph for this function:

static void LayoutLayout ( LayoutWidget  l,
Bool  attemptResize 
) [static]

Definition at line 1008 of file Layout.c.

References ComputeSizes(), DBUG_ENTER, DBUG_VOID_RETURN, height, LayoutGetNaturalSize(), LayoutHorizontal, LayoutVertical, PrintBox(), SetSizes(), _Box::size, and width.

01011 {
01012     BoxPtr              box;
01013     Dimension           width, height;
01014     Dimension           prefered_width, prefered_height;
01015 
01016     DBUG_ENTER("LayoutLayout");
01017     box = l->layout.layout;
01018     if (!box)
01019         return;
01020     LayoutGetNaturalSize (l, &prefered_width, &prefered_height);
01021     if (l->core.width == 0 || l->core.height == 0)
01022     {
01023         l->core.width = prefered_width;
01024         l->core.height = prefered_height;
01025     }
01026     box->size[LayoutHorizontal] = l->core.width;
01027     box->size[LayoutVertical] = l->core.height;
01028     if (!ComputeSizes (box) && attemptResize)
01029     {
01030         XtMakeResizeRequest ((Widget) l,
01031                             prefered_width, prefered_height,
01032                             &width, &height);
01033         if (width != box->size[LayoutHorizontal] ||
01034             height != box->size[LayoutVertical])
01035         {
01036             box->size[LayoutHorizontal] = width;
01037             box->size[LayoutVertical] = height;
01038             ComputeSizes (box);
01039         }
01040     }
01041     if (l->layout.debug)
01042     {
01043         PrintBox (box, 0);
01044         fflush (stdout);
01045     }
01046     SetSizes (box, 0, 0);
01047     DBUG_VOID_RETURN;
01048 }

Here is the call graph for this function:

static void LayoutLayout (  )  [static]

Referenced by ChangeManaged(), GeometryManager(), Resize(), and SetValues().

Here is the caller graph for this function:

int LayYYparse (  ) 

Referenced by CvtStringToLayout().

Here is the caller graph for this function:

void LayYYsetdest (  ) 

Referenced by CvtStringToLayout().

Here is the caller graph for this function:

void LayYYsetsource (  ) 

Referenced by CvtStringToLayout().

Here is the caller graph for this function:

static ExprPtr LookupVariable ( BoxPtr  child,
XrmQuark  quark 
) [static]

Definition at line 510 of file Layout.c.

References _Box::box, DBUG_ENTER, DBUG_PRINT, DBUG_RETURN, _Box::nextSibling, _Box::parent, _Box::type, _Box::u, _Box::variable, and VariableBox.

Referenced by Evaluate().

00513 {
00514     BoxPtr      parent, box;
00515 
00516     DBUG_ENTER("LookupVariable");
00517     DBUG_PRINT("name = <%s>",XrmQuarkToString(quark));
00518     DBUG_PRINT("child = %p",child);
00519     while ((parent = child->parent))
00520     {
00521         for (box = parent->u.box.firstChild; 
00522              box != child; 
00523              box = box->nextSibling)
00524         {
00525             if (box->type == VariableBox && box->u.variable.quark == quark)
00526                 DBUG_RETURN("%p", box->u.variable.expr);
00527         }
00528         child = parent;
00529     }
00530     DBUG_RETURN("failure -> %d",0);
00531 }

Here is the caller graph for this function:

static void PrintBox ( BoxPtr  box,
int  level 
) [static]

Definition at line 470 of file Layout.c.

References _Box::box, BoxBox, GlueBox, LayoutHorizontal, LayoutVertical, _Box::nextSibling, PrintDirection(), PrintGlue(), TabTo(), _Box::u, VariableBox, void(), and WidgetBox.

Referenced by LayoutLayout().

00473 {
00474     BoxPtr      child;
00475     
00476     TabTo (level);
00477     (void) printf ("%s", "< ");
00478     (void) printf ("%s", " + "); 
00479     PrintGlue (box->params.stretch[LayoutHorizontal]);
00480     (void) printf ("%s", " - "); 
00481     PrintGlue (box->params.shrink[LayoutHorizontal]);
00482     (void) printf ("%s", " * ");
00483     (void) printf ("%s", " + "); 
00484     PrintGlue (box->params.stretch[LayoutVertical]);
00485     (void) printf ("%s", " - "); 
00486     PrintGlue (box->params.shrink[LayoutVertical]);
00487     (void) printf ("%s", " >");
00488     (void) printf (" size: %d x %d", box->size[0], box->size[1]);
00489     (void) printf (" natural: %d x %d ", box->natural[0], box->natural[1]);
00490     switch (box->type) {
00491     case BoxBox:
00492         PrintDirection (box->u.box.dir);
00493         (void) printf ("%s\n", "");
00494         for (child = box->u.box.firstChild; child; child = child->nextSibling)
00495             PrintBox (child, level+1);
00496         break;
00497     case WidgetBox:
00498         (void) printf (" %s\n", XrmQuarkToString (box->u.widget.quark));
00499         break;
00500     case GlueBox:
00501         (void) printf ("%s\n", " glue");
00502         break;
00503     case VariableBox:
00504         (void) printf (" variable %s\n", XrmQuarkToString (box->u.variable.quark));
00505         break;
00506     }
00507 }

Here is the call graph for this function:

Here is the caller graph for this function:

static void PrintDirection ( LayoutDirection  dir  )  [static]

Definition at line 444 of file Layout.c.

References LayoutHorizontal, LayoutVertical, and void().

Referenced by PrintBox().

00446 {
00447     switch (dir) {
00448     case LayoutHorizontal:
00449         (void) printf ("%s", "horizontal");
00450         break;
00451     case LayoutVertical:
00452         (void) printf ("%s", "vertical");
00453         break;
00454     default:
00455         (void) printf ("Unknown layout direction %d\n", dir);
00456         break;
00457   
00458     }
00459 }

Here is the call graph for this function:

Here is the caller graph for this function:

static void PrintGlue ( GlueRec  g  )  [static]

Definition at line 430 of file Layout.c.

References void().

Referenced by PrintBox().

00432 {
00433     if (g.order == 0 || g.value != 1.0)
00434         (void) printf ("%g", g.value);
00435     if (g.order > 0)
00436     {
00437         (void) printf ("%s", " inf");
00438         if (g.order > 1)
00439             (void) printf (" %d", g.order);
00440     }
00441 }

Here is the call graph for this function:

Here is the caller graph for this function:

static XtGeometryResult QueryGeometry ( Widget  gw,
XtWidgetGeometry *  request,
XtWidgetGeometry *  prefered_return 
) [static]

Definition at line 371 of file Layout.c.

References LayoutGetNaturalSize(), result, and w.

00374 {
00375     LayoutWidget        w = (LayoutWidget) gw;
00376     XtGeometryResult    result;
00377     XtWidgetGeometry    prefered_size;
00378 
00379     if (request && !(request->request_mode & (CWWidth|CWHeight)))
00380         return XtGeometryYes;
00381     LayoutGetNaturalSize (w, &prefered_size.width, &prefered_size.height);
00382     prefered_return->request_mode = 0;
00383     result = XtGeometryYes;
00384     if (!request) {
00385         prefered_return->width = prefered_size.width;
00386         prefered_return->height= prefered_size.height;
00387         if (prefered_size.width != w->core.width) {
00388             prefered_return->request_mode |= CWWidth;
00389             result = XtGeometryAlmost;
00390         }
00391         if (prefered_size.height != w->core.height) {
00392             prefered_return->request_mode |= CWHeight;
00393             result = XtGeometryAlmost;
00394         }
00395     } else {
00396         if (request->request_mode & CWWidth) {
00397             if (prefered_size.width > request->width)
00398             {
00399                 if (prefered_size.width == w->core.width)
00400                     result = XtGeometryNo;
00401                 else if (result != XtGeometryNo) {
00402                     result = XtGeometryAlmost;
00403                     prefered_return->request_mode |= CWWidth;
00404                     prefered_return->width = prefered_size.width;
00405                 }
00406             }
00407         }
00408         if (request->request_mode & CWHeight) {
00409             if (prefered_size.height > request->height)
00410             {
00411                 if (prefered_size.height == w->core.height)
00412                     result = XtGeometryNo;
00413                 else if (result != XtGeometryNo) {
00414                     result = XtGeometryAlmost;
00415                     prefered_return->request_mode |= CWHeight;
00416                     prefered_return->height = prefered_size.height;
00417                 }
00418             }
00419         }
00420     }
00421     return result;
00422 }

Here is the call graph for this function:

static XtGeometryResult QueryGeometry (  )  [static]

static void Resize ( Widget  gw  )  [static]

Definition at line 349 of file Layout.c.

References FALSE, and LayoutLayout().

00351 {
00352     LayoutLayout ((LayoutWidget) gw, FALSE);
00353 }

Here is the call graph for this function:

static void Resize (  )  [static]

static void SetSizes ( BoxPtr  box,
Position  x,
Position  y 
) [static]

Definition at line 902 of file Layout.c.

References _Box::box, BoxBox, GlueBox, height, info, LayoutHorizontal, LayoutVertical, _Box::nextSibling, _Box::size, SubInfo, _Box::u, VariableBox, w, WidgetBox, and width.

Referenced by LayoutLayout().

00905 {
00906     BoxPtr      child;
00907     int         width, height;
00908     int         bw;
00909     Widget      w;
00910     SubInfoPtr  info;
00911     
00912     switch (box->type) {
00913     case WidgetBox:
00914         w = box->u.widget.widget;
00915         if (w)
00916         {
00917             info = SubInfo(w);
00918             /* info = (SubInfoPtr) w->core.constraints; */
00919             width = box->size[LayoutHorizontal];
00920             height = box->size[LayoutVertical];
00921             bw = info->naturalBw;
00922             width -= bw * 2;
00923             height -= bw * 2;
00924             /* Widgets which grow too small are placed off screen */
00925             if (width <= 0 || height <= 0) 
00926             {
00927                 width = 1;
00928                 height = 1;
00929                 bw = 0;
00930                 x = -1;
00931                 y = -1;
00932             }
00933             XtConfigureWidget (w, x, y, 
00934                               (Dimension)width, (Dimension)height, 
00935                               (Dimension)bw);
00936         }
00937         break;
00938     case BoxBox:
00939         for (child = box->u.box.firstChild; child; child = child->nextSibling) 
00940         {
00941             SetSizes (child, x, y);
00942             if (box->u.box.dir == LayoutHorizontal)
00943                 x += child->size[LayoutHorizontal];
00944             else
00945                 y += child->size[LayoutVertical];
00946         }
00947         break;
00948     case GlueBox:
00949     case VariableBox:
00950         break;
00951     }
00952 }

Here is the caller graph for this function:

static Boolean SetValues ( Widget  gold,
Widget  greq,
Widget  gnew,
ArgList  args,
Cardinal *  num_args 
) [static]

Definition at line 357 of file Layout.c.

References FALSE, LayoutPart::layout, _LayoutRec::layout, LayoutLayout(), and TRUE.

00361 {
00362     LayoutWidget    old = (LayoutWidget) gold,
00363                     new = (LayoutWidget) gnew;
00364 
00365     if (old->layout.layout != new->layout.layout)
00366         LayoutLayout (new, TRUE);
00367     return FALSE;
00368 } /* SetValues */

Here is the call graph for this function:

static Boolean SetValues (  )  [static]

static void TabTo ( int  level  )  [static]

Definition at line 462 of file Layout.c.

References void().

Referenced by PrintBox().

00464 {
00465     while (level--)
00466         (void) printf ("%s", "  ");
00467 }

Here is the call graph for this function:

Here is the caller graph for this function:


Variable Documentation

LayoutClassRec layoutClassRec

Definition at line 111 of file Layout.c.

WidgetClass layoutWidgetClass = (WidgetClass) &layoutClassRec

Definition at line 188 of file Layout.c.

XtResource resources[] [static]

Initial value:

 {
    {XtNlayout, XtCLayout, XtRLayout, sizeof (BoxPtr),
        offset(layout), XtRLayout, NULL },
    {XtNdebug, XtCBoolean, XtRBoolean, sizeof(Boolean),
         offset(debug), XtRImmediate, (XtPointer) FALSE},
}

Definition at line 77 of file Layout.c.


Generated on Sun Mar 4 16:01:16 2007 for Scilab [trunk] by  doxygen 1.5.1