home *** CD-ROM | disk | FTP | other *** search
/ BCI NET 2 / BCI NET 2.iso / archives / programming / source / term43-source.lha / Extras / Source / term-Source.lha / termBoxes.c < prev    next >
Encoding:
C/C++ Source or Header  |  1995-02-07  |  12.9 KB  |  754 lines

  1. /*
  2. **    termBoxes.c
  3. **
  4. **    Text box management support routines
  5. **
  6. **    Copyright © 1990-1995 by Olaf `Olsen' Barthel
  7. **        All Rights Reserved
  8. */
  9.  
  10. #include "termGlobal.h"
  11.  
  12.     /* Sizing data. */
  13.  
  14. STATIC struct RastPort    *SZ_RPort;
  15. STATIC struct TextFont    *SZ_TextFont;
  16. STATIC struct Screen    *SZ_Screen;
  17.  
  18. STATIC LONG         SZ_Left,
  19.              SZ_Top,
  20.              SZ_CurrentLeft,
  21.              SZ_CurrentTop,
  22.              SZ_CurrentWidth,
  23.              SZ_MaxWidth,
  24.              SZ_TextPen,
  25.              SZ_BackPen,
  26.              SZ_LastLeft,
  27.              SZ_LastTop,
  28.              SZ_LastWidth,
  29.              SZ_LastHeight,
  30.              SZ_AverageGlyphWidth;
  31.  
  32.     /* SZ_GetLeftEdge():
  33.      *
  34.      *    Get the current object left edge.
  35.      */
  36.  
  37. LONG
  38. SZ_GetLeftEdge()
  39. {
  40.     return(SZ_CurrentLeft);
  41. }
  42.  
  43.     /* SZ_SetTopEdge(LONG Top):
  44.      *
  45.      *    Set the current object top edge.
  46.      */
  47.  
  48. VOID __regargs
  49. SZ_SetTopEdge(LONG Top)
  50. {
  51.     SZ_CurrentTop = Top;
  52. }
  53.  
  54.     /* SZ_SetLeftEdge(LONG Left):
  55.      *
  56.      *    Set the current object left edge.
  57.      */
  58.  
  59. VOID __regargs
  60. SZ_SetLeftEdge(LONG Left)
  61. {
  62.     SZ_CurrentLeft = Left;
  63. }
  64.  
  65.     /* SZ_SetAbsoluteTop(LONG Top):
  66.      *
  67.      *    Set new inner window top edge.
  68.      */
  69.  
  70. VOID __regargs
  71. SZ_SetAbsoluteTop(LONG Top)
  72. {
  73.     SZ_Top = Top;
  74. }
  75.  
  76.     /* SZ_SetAbsoluteLeft(LONG Left):
  77.      *
  78.      *    Set new inner window left edge.
  79.      */
  80.  
  81. VOID __regargs
  82. SZ_SetAbsoluteLeft(LONG Left)
  83. {
  84.     SZ_Left = Left;
  85. }
  86.  
  87.     /* SZ_SetWidth(LONG Width):
  88.      *
  89.      *    Set current object width.
  90.      */
  91.  
  92. VOID __regargs
  93. SZ_SetWidth(LONG Width)
  94. {
  95.     SZ_CurrentWidth = Width;
  96. }
  97.  
  98.     /* SZ_AddLeftOffset(LONG Offset):
  99.      *
  100.      *    Update current object left offset.
  101.      */
  102.  
  103. VOID __regargs
  104. SZ_AddLeftOffset(LONG Offset)
  105. {
  106.     SZ_CurrentLeft += Offset;
  107. }
  108.  
  109.     /* SZ_LeftOffsetN(LONG DataArray,...):
  110.      *
  111.      *    Determine the maximum length of a number of
  112.      *    gadget labels (first, second, third item, -1 terminates
  113.      *    the array).
  114.      */
  115.  
  116. LONG __stdargs
  117. SZ_LeftOffsetN(LONG DataArray,...)
  118. {
  119.     LONG    *Data = &DataArray,
  120.          Len,
  121.          Max = 0;
  122.     STRPTR     String;
  123.  
  124.     while(*Data != -1)
  125.     {
  126.         String = LocaleString(*Data++);
  127.  
  128.         if((Len = TextLength(SZ_RPort,String,strlen(String))) > Max)
  129.             Max = Len;
  130.     }
  131.  
  132.     return(Max + INTERWIDTH);
  133. }
  134.  
  135.     /* SZ_SizeCleanup():
  136.      *
  137.      *    Free data allocated by SZ_SizeSetup().
  138.      */
  139.  
  140. VOID
  141. SZ_SizeCleanup()
  142. {
  143.     if(SZ_TextFont)
  144.     {
  145.         CloseFont(SZ_TextFont);
  146.  
  147.         SZ_TextFont = NULL;
  148.     }
  149.  
  150.     if(SZ_RPort)
  151.     {
  152.         FreeVecPooled(SZ_RPort);
  153.  
  154.         SZ_RPort = NULL;
  155.     }
  156. }
  157.  
  158.     /* SZ_SizeSetup(struct Screen *Screen,struct TextAttr *TextAttr):
  159.      *
  160.      *    Perform setups for gadget creation.
  161.      */
  162.  
  163. BYTE __regargs
  164. SZ_SizeSetup(struct Screen *Screen,struct TextAttr *TextAttr)
  165. {
  166.     struct DrawInfo *DrawInfo;
  167.  
  168.     SZ_SizeCleanup();
  169.  
  170.     if(DrawInfo = GetScreenDrawInfo(Screen))
  171.     {
  172.         SZ_TextPen = DrawInfo -> dri_Pens[TEXTPEN];
  173.         SZ_BackPen = DrawInfo -> dri_Pens[BACKGROUNDPEN];
  174.  
  175.         FreeScreenDrawInfo(Screen,DrawInfo);
  176.     }
  177.  
  178.     SZ_Screen = Screen;
  179.  
  180.     if(SZ_RPort = (struct RastPort *)AllocVecPooled(sizeof(struct RastPort),MEMF_ANY | MEMF_CLEAR))
  181.     {
  182.         InitRastPort(SZ_RPort);
  183.  
  184.         if(!TextAttr)
  185.             TextAttr = Screen -> Font;
  186.  
  187.         if(SZ_TextFont = (struct TextFont *)OpenDiskFont(TextAttr))
  188.         {
  189.             UWORD    i,Width;
  190.             UBYTE    Char;
  191.  
  192.             InterWidth = INTERWIDTH;
  193.  
  194.             if(SZ_TextFont -> tf_YSize <= 8)
  195.                 InterHeight = 1;
  196.             else
  197.                 InterHeight = SZ_TextFont -> tf_YSize / 4;
  198.  
  199.             SetFont(SZ_RPort,SZ_TextFont);
  200.  
  201.             SZ_AverageGlyphWidth = 0;
  202.  
  203.             for(i = 0 ; i < 256 ; i++)
  204.             {
  205.                 Char = i;
  206.  
  207.                 Width = TextLength(SZ_RPort,&Char,1);
  208.  
  209.                 SZ_AverageGlyphWidth += Width;
  210.             }
  211.  
  212.             SZ_AverageGlyphWidth /= 256;
  213.  
  214.             SZ_Top        = Screen -> WBorTop + Screen -> Font -> ta_YSize + 1 + InterHeight;
  215.             SZ_Left        = InterWidth;
  216.  
  217.             SZ_CurrentLeft    = InterWidth;
  218.             SZ_CurrentTop    = SZ_Top;
  219.  
  220.             SZ_CurrentWidth    = 0;
  221.             SZ_MaxWidth    = 0;
  222.  
  223.             return(TRUE);
  224.         }
  225.     }
  226.  
  227.     SZ_SizeCleanup();
  228.  
  229.     return(FALSE);
  230. }
  231.  
  232.     /* SZ_GetLen(STRPTR String):
  233.      *
  234.      *    Get the string pixel width, measured using the average
  235.      *    glyph width.
  236.      */
  237.  
  238. ULONG __regargs
  239. SZ_GetLen(STRPTR String)
  240. {
  241.     return(strlen(String) * SZ_AverageGlyphWidth);
  242. }
  243.  
  244.     /* SZ_FreeBox(struct TextBox *Box):
  245.      *
  246.      *    Free a text box.
  247.      */
  248.  
  249. STATIC VOID __regargs
  250. SZ_FreeBox(struct TextBox *Box)
  251. {
  252.     if(Box)
  253.     {
  254.         if(Box -> Text)
  255.         {
  256.             LONG i;
  257.  
  258.             for(i = 0 ; i < Box -> NumLines ; i++)
  259.             {
  260.                 if(Box -> Text[i])
  261.                     FreeVecPooled(Box -> Text[i]);
  262.             }
  263.  
  264.             FreeVecPooled(Box -> Text);
  265.         }
  266.  
  267.         if(Box -> Title)
  268.             FreeVecPooled(Box -> Title);
  269.  
  270.         FreeVecPooled(Box);
  271.     }
  272. }
  273.  
  274.     /* SZ_FreeBoxes(struct TextBox *FirstBox):
  275.      *
  276.      *    Free a number of text boxes.
  277.      */
  278.  
  279. VOID __regargs
  280. SZ_FreeBoxes(struct TextBox *FirstBox)
  281. {
  282.     if(FirstBox)
  283.     {
  284.         struct TextBox *NextBox;
  285.  
  286.         do
  287.         {
  288.             NextBox = FirstBox -> NextBox;
  289.  
  290.             SZ_FreeBox(FirstBox);
  291.  
  292.             FirstBox = NextBox;
  293.         }
  294.         while(FirstBox);
  295.     }
  296. }
  297.  
  298.     /* SZ_BoxWidth(LONG Chars):
  299.      *
  300.      *    Determine the width of a text box.
  301.      */
  302.  
  303. LONG __regargs
  304. SZ_BoxWidth(LONG Chars)
  305. {
  306.     return((LONG)(4 + SZ_AverageGlyphWidth * Chars + 4));
  307. }
  308.  
  309.     /* SZ_BoxHeight(LONG Lines):
  310.      *
  311.      *    Determine the height of a text box.
  312.      */
  313.  
  314. LONG __regargs
  315. SZ_BoxHeight(LONG Lines)
  316. {
  317.     return(2 + SZ_TextFont -> tf_YSize * Lines + 2);
  318. }
  319.  
  320.     /* SZ_SetTitlePen(struct TextBox *Box,LONG FgPen,LONG BgPen):
  321.      *
  322.      *    Set the text box list title text rendering pens.
  323.      */
  324.  
  325. VOID __regargs
  326. SZ_SetTitlePen(struct TextBox *Box,LONG FgPen,LONG BgPen)
  327. {
  328.     while(Box)
  329.     {
  330.         Box -> TitleFgPen = FgPen;
  331.         Box -> TitleBgPen = BgPen;
  332.  
  333.         Box = Box -> NextBox;
  334.     }
  335. }
  336.  
  337.     /* SZ_CreateTextBox(struct TextBox **FirstBox,...):
  338.      *
  339.      *    Create a text box, this routine works similar
  340.      *    to the CreateGadget() frontend.
  341.      */
  342.  
  343. struct TextBox * __stdargs
  344. SZ_CreateTextBox(struct TextBox **FirstBox,...)
  345. {
  346.     va_list                 VarArgs;
  347.     struct TagItem            *TagList,
  348.                     *ThisTag;
  349.     LONG                 Chars,Lines,
  350.                      Width,
  351.                      Height,
  352.                      Left = SZ_CurrentLeft;
  353.     BYTE                 AutoWidth    = FALSE,
  354.                      MoveDown    = TRUE,
  355.                      SetLeft    = FALSE,
  356.                      SetBelow    = FALSE;
  357.  
  358.     struct TextBox            *Box;
  359.     LONG                 i;
  360.  
  361.     va_start(VarArgs,FirstBox);
  362.  
  363.     TagList = (struct TagItem *)VarArgs;
  364.  
  365.     if(ThisTag = FindTagItem(SZ_Lines,TagList))
  366.         Lines = (LONG)ThisTag -> ti_Data;
  367.     else
  368.         return(NULL);
  369.  
  370.     Height = 2 + SZ_TextFont -> tf_YSize * Lines + 2;
  371.  
  372.     if(ThisTag = FindTagItem(SZ_AutoWidth,TagList))
  373.         AutoWidth = ThisTag -> ti_Data;
  374.  
  375.     if(!AutoWidth)
  376.         return(NULL);
  377.     else
  378.         Chars = (SZ_CurrentWidth - 8) / SZ_AverageGlyphWidth;
  379.  
  380.     if(!(Box = (struct TextBox *)AllocVecPooled(sizeof(struct TextBox),MEMF_ANY | MEMF_CLEAR)))
  381.         return(NULL);
  382.  
  383.     if(ThisTag = FindTagItem(SZ_NewColumn,TagList))
  384.     {
  385.         if(ThisTag -> ti_Data)
  386.         {
  387.             SZ_CurrentTop    = SZ_Top;
  388.             Left        = Left + SZ_MaxWidth + InterWidth;
  389.  
  390.             SZ_MaxWidth    = 0;
  391.         }
  392.     }
  393.  
  394.     if(ThisTag = FindTagItem(SZ_AutoWidth,TagList))
  395.         AutoWidth = ThisTag -> ti_Data;
  396.  
  397.     if(!AutoWidth)
  398.         Width = SZ_BoxWidth(Chars);
  399.     else
  400.         Width = SZ_CurrentWidth;
  401.  
  402.     Box -> Left        = Left;
  403.     Box -> Top        = SZ_CurrentTop;
  404.     Box -> Width        = Width;
  405.     Box -> Height        = Height;
  406.  
  407.     Box -> LineWidth    = Chars * SZ_AverageGlyphWidth;
  408.     Box -> LineHeight    = SZ_TextFont -> tf_YSize;
  409.  
  410.     Box -> NumChars        = Chars;
  411.     Box -> NumLines        = Lines;
  412.  
  413.     Box -> TitleFgPen    = SZ_TextPen;
  414.     Box -> TitleBgPen    = SZ_BackPen;
  415.     Box -> TextPen        = SZ_TextPen;
  416.  
  417.     if(!(Box -> Title = (STRPTR *)AllocVecPooled(sizeof(STRPTR) * Lines,MEMF_ANY | MEMF_CLEAR)))
  418.     {
  419.         SZ_FreeBox(Box);
  420.  
  421.         return(NULL);
  422.     }
  423.  
  424.     if(!(Box -> Text = (STRPTR *)AllocVecPooled(sizeof(STRPTR) * Lines,MEMF_ANY | MEMF_CLEAR)))
  425.     {
  426.         SZ_FreeBox(Box);
  427.  
  428.         return(NULL);
  429.     }
  430.  
  431.     for(i = 0 ; i < Lines ; i++)
  432.     {
  433.         if(!(Box -> Text[i] = (STRPTR)AllocVecPooled(Chars + 1,MEMF_ANY | MEMF_CLEAR)))
  434.         {
  435.             SZ_FreeBox(Box);
  436.  
  437.             return(NULL);
  438.         }
  439.     }
  440.  
  441.     if(SetBelow)
  442.         MoveDown = FALSE;
  443.  
  444.     if(MoveDown)
  445.         SZ_CurrentTop = SZ_CurrentTop + Height + InterHeight;
  446.     else
  447.         SZ_MaxWidth = 0;
  448.  
  449.     if(Width > SZ_MaxWidth)
  450.         SZ_MaxWidth = Width;
  451.  
  452.     if(!SetLeft)
  453.         SZ_CurrentLeft = Left;
  454.  
  455.     if(!(*FirstBox))
  456.         *FirstBox = Box;
  457.     else
  458.     {
  459.         struct TextBox *CurrentBox = *FirstBox;
  460.  
  461.         while(CurrentBox -> NextBox)
  462.             CurrentBox = CurrentBox -> NextBox;
  463.  
  464.         CurrentBox -> NextBox = Box;
  465.     }
  466.  
  467.     return(Box);
  468. }
  469.  
  470.     /* SZ_SetBoxTitles(struct TextBox *Box,STRPTR Array,...):
  471.      *
  472.      *    Set the titles displayed in a text box.
  473.      */
  474.  
  475. VOID __stdargs
  476. SZ_SetBoxTitles(struct TextBox *Box,STRPTR Array,...)
  477. {
  478.     if(Box)
  479.     {
  480.         STRPTR    *Data = &Array;
  481.         LONG     i = 0;
  482.  
  483.         while(*Data != NULL)
  484.         {
  485.             if(i < Box -> NumLines)
  486.                 Box -> Title[i++] = *Data;
  487.  
  488.             Data++;
  489.         }
  490.     }
  491. }
  492.  
  493.     /* SZ_SetLine():
  494.      *
  495.      *    Print a string into a text box, plain version.
  496.      */
  497.  
  498. VOID __regargs
  499. SZ_SetLine(struct RastPort *RPort,struct TextBox *Box,LONG Line,STRPTR String)
  500. {
  501.     BYTE         FgPen    = ReadAPen(RPort),
  502.              BgPen    = ReadBPen(RPort),
  503.              DrMd    = ReadDrMd(RPort);
  504.     struct TextFont    *Font    = RPort -> Font;
  505.  
  506.     LONG         Width,Len,
  507.              Left    = Box -> Left + 4,
  508.              Top    = Box -> Top + 2 + Line * Box -> LineHeight;
  509.  
  510.     if(DrMd != JAM2)
  511.         SetDrMd(RPort,JAM2);
  512.  
  513.     if(FgPen != Box -> TextPen)
  514.         SetAPen(RPort,Box -> TextPen);
  515.  
  516.     if(BgPen != SZ_BackPen)
  517.         SetBPen(RPort,SZ_BackPen);
  518.  
  519.     if(Font != UserTextFont)
  520.         SetFont(RPort,UserTextFont);
  521.  
  522.     if(Len = strlen(String))
  523.     {
  524.         if(Len > Box -> NumChars)
  525.             Len = Box -> NumChars;
  526.  
  527.         while(Len > 0 && TextLength(RPort,String,Len) > Box -> LineWidth)
  528.             Len--;
  529.  
  530.         if(Len)
  531.         {
  532.             Width = TextLength(RPort,String,Len);
  533.  
  534.             Move(RPort,Left,Top + RPort -> Font -> tf_Baseline);
  535.             Text(RPort,String,Len);
  536.         }
  537.         else
  538.             Width = 0;
  539.     }
  540.     else
  541.         Width = 0;
  542.  
  543.     if(Width != Box -> LineWidth)
  544.     {
  545.         if(FgPen != SZ_BackPen)
  546.         {
  547.             SetAPen(RPort,SZ_BackPen);
  548.  
  549.             RectFill(RPort,Left + Width,Top,Left + Box -> LineWidth - 1,Top + Box -> LineHeight - 1);
  550.  
  551.             SetAPen(RPort,FgPen);
  552.         }
  553.         else
  554.             RectFill(RPort,Left + Width,Top,Left + Box -> LineWidth - 1,Top + Box -> LineHeight - 1);
  555.     }
  556.  
  557.     if(DrMd != JAM2)
  558.         SetDrMd(RPort,DrMd);
  559.  
  560.     if(String != Box -> Text[Line])
  561.     {
  562.         if(Len > 0)
  563.             CopyMem(String,Box -> Text[Line],Len);
  564.  
  565.         Box -> Text[Line][Len] = 0;
  566.     }
  567.  
  568.     if(Font != UserTextFont)
  569.         SetFont(RPort,Font);
  570.  
  571.     if(BgPen != SZ_BackPen)
  572.         SetBPen(RPort,BgPen);
  573.  
  574.     SetAPen(RPort,FgPen);
  575. }
  576.  
  577.     /* SZ_PrintLine():
  578.      *
  579.      *    Print a string into a text box, varargs version.
  580.      */
  581.  
  582. VOID __stdargs
  583. SZ_PrintLine(struct RastPort *RPort,struct TextBox *Box,LONG Line,STRPTR String,...)
  584. {
  585.     va_list    VarArgs;
  586.     UBYTE    Buffer[256];
  587.  
  588.     va_start(VarArgs,String);
  589.     VSPrintf(Buffer,String,VarArgs);
  590.     va_end(VarArgs);
  591.  
  592.     SZ_SetLine(RPort,Box,Line,Buffer);
  593. }
  594.  
  595.     /* SZ_DrawBox(struct RastPort *RPort,struct TextBox *Box):
  596.      *
  597.      *    (Re-)Draw a text box.
  598.      */
  599.  
  600. STATIC VOID __regargs
  601. SZ_DrawBox(struct RastPort *RPort,struct TextBox *Box)
  602. {
  603.     if(Box)
  604.     {
  605.         LONG         LineY,i,Len,FgPen = ReadAPen(RPort),BgPen = ReadBPen(RPort),DrMd = ReadDrMd(RPort);
  606.         struct TextFont    *Font = RPort -> Font;
  607.  
  608.         if(Font != UserTextFont)
  609.             SetFont(RPort,UserTextFont);
  610.  
  611.         if(FgPen != SZ_BackPen)
  612.         {
  613.             SetAPen(RPort,SZ_BackPen);
  614.  
  615.             RectFill(RPort,Box -> Left,Box -> Top,Box -> Left + Box -> Width - 1,Box -> Top + Box -> Height - 1);
  616.  
  617.             SetAPen(RPort,FgPen);
  618.         }
  619.         else
  620.             RectFill(RPort,Box -> Left,Box -> Top,Box -> Left + Box -> Width - 1,Box -> Top + Box -> Height - 1);
  621.  
  622.         DrawBevelBox(RPort,Box -> Left,Box -> Top,Box -> Width,Box -> Height,
  623.             GT_VisualInfo,    VisualInfo,
  624.             GTBB_Recessed,    TRUE,
  625.         TAG_DONE);
  626.  
  627.         LineY = Box -> Top + 2 + RPort -> Font -> tf_Baseline;
  628.  
  629.         SetAPen(RPort,Box -> TitleFgPen);
  630.         SetBPen(RPort,Box -> TitleBgPen);
  631.         SetDrMd(RPort,JAM2);
  632.  
  633.         for(i = 0 ; i < Box -> NumLines ; i++)
  634.         {
  635.             if(Len = strlen(Box -> Title[i]))
  636.             {
  637.                 Move(RPort,Box -> Left - INTERWIDTH - TextLength(RPort,Box -> Title[i],Len),LineY);
  638.                 Text(RPort,Box -> Title[i],Len);
  639.             }
  640.  
  641.             LineY += Box -> LineHeight;
  642.         }
  643.  
  644.         for(i = 0 ; i < Box -> NumLines ; i++)
  645.             SZ_PrintLine(RPort,Box,i,Box -> Text[i]);
  646.  
  647.         SetAPen(RPort,FgPen);
  648.         SetBPen(RPort,BgPen);
  649.  
  650.         SetDrMd(RPort,DrMd);
  651.  
  652.         if(Font != UserTextFont)
  653.             SetFont(RPort,Font);
  654.     }
  655. }
  656.  
  657.     /* SZ_DrawBoxes(struct RastPort *RPort,struct TextBox *FirstBox):
  658.      *
  659.      *    (Re-)Draw a number of text boxes.
  660.      */
  661.  
  662. VOID __regargs
  663. SZ_DrawBoxes(struct RastPort *RPort,struct TextBox *FirstBox)
  664. {
  665.     do
  666.         SZ_DrawBox(RPort,FirstBox);
  667.     while(FirstBox = FirstBox -> NextBox);
  668. }
  669.  
  670.     /* SZ_MoveBox(struct TextBox *Box,LONG Left,LONG Top):
  671.      *
  672.      *    Change the location of a text box.
  673.      */
  674.  
  675. STATIC VOID __regargs
  676. SZ_MoveBox(struct TextBox *Box,LONG Left,LONG Top)
  677. {
  678.     Box -> Left    += Left;
  679.     Box -> Top    += Top;
  680. }
  681.  
  682.     /* SZ_MoveBoxes(struct TextBox *FirstBox,LONG Left,LONG Top):
  683.      *
  684.      *    Change the locations of a number of text boxes.
  685.      */
  686.  
  687. VOID __regargs
  688. SZ_MoveBoxes(struct TextBox *FirstBox,LONG Left,LONG Top)
  689. {
  690.     do
  691.         SZ_MoveBox(FirstBox,Left,Top);
  692.     while(FirstBox = FirstBox -> NextBox);
  693. }
  694.  
  695.     /* SZ_SetBox(struct TextBox *Box,LONG Left,LONG Top):
  696.      *
  697.      *    Set the location of a text box.
  698.      */
  699.  
  700. STATIC VOID __regargs
  701. SZ_SetBox(struct TextBox *Box,LONG Left,LONG Top)
  702. {
  703.     if(Left >= 0)
  704.         Box -> Left = Left;
  705.  
  706.     if(Top >= 0)
  707.         Box -> Top = Top;
  708. }
  709.  
  710.     /* SZ_SetBoxes(struct TextBox *FirstBox,LONG Left,LONG Top):
  711.      *
  712.      *    Set the locations of a number of text boxes.
  713.      */
  714.  
  715. VOID __regargs
  716. SZ_SetBoxes(struct TextBox *FirstBox,LONG Left,LONG Top)
  717. {
  718.     do
  719.         SZ_SetBox(FirstBox,Left,Top);
  720.     while(FirstBox = FirstBox -> NextBox);
  721. }
  722.  
  723.     /* SZ_GetBoxInfo(struct TextBox *Box,LONG Type):
  724.      *
  725.      *    Query information on a certain text box.
  726.      */
  727.  
  728. LONG __regargs
  729. SZ_GetBoxInfo(struct TextBox *Box,LONG Type)
  730. {
  731.     switch(Type)
  732.     {
  733.         case BOX_LEFT:
  734.  
  735.             return(Box -> Left);
  736.  
  737.         case BOX_TOP:
  738.  
  739.             return(Box -> Top);
  740.  
  741.         case BOX_WIDTH:
  742.  
  743.             return(Box -> Width);
  744.  
  745.         case BOX_HEIGHT:
  746.  
  747.             return(Box -> Height);
  748.  
  749.         default:
  750.  
  751.             return(0);
  752.     }
  753. }
  754.