TextSink.c

Go to the documentation of this file.
00001 /* $XConsortium: TextSink.c,v 1.19 94/04/17 20:13:11 kaleb Exp $ */
00002 /*
00003 
00004 Copyright (c) 1989, 1994  X Consortium
00005 
00006 Permission is hereby granted, free of charge, to any person obtaining a copy
00007 of this software and associated documentation files (the "Software"), to deal
00008 in the Software without restriction, including without limitation the rights
00009 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
00010 copies of the Software, and to permit persons to whom the Software is
00011 furnished to do so, subject to the following conditions:
00012 
00013 The above copyright notice and this permission notice shall be included in
00014 all copies or substantial portions of the Software.
00015 
00016 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
00017 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
00018 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
00019 X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
00020 AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
00021 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
00022 
00023 Except as contained in this notice, the name of the X Consortium shall not be
00024 used in advertising or otherwise to promote the sale, use or other dealings
00025 in this Software without prior written authorization from the X Consortium.
00026 
00027 */
00028 
00029 /*
00030  * Author:  Chris Peterson, MIT X Consortium.
00031  *
00032  * Much code taken from X11R3 AsciiSink.
00033  */
00034 
00035 /*
00036  * TextSink.c - TextSink object. (For use with the text widget).
00037  *
00038  */
00039 
00040 #include <stdio.h>
00041 #include <ctype.h>
00042 #include <X11/IntrinsicP.h>
00043 #include <X11/StringDefs.h>
00044 #include <X11/Xaw3d/XawInit.h>
00045 #include <X11/Xaw3d/TextSinkP.h>
00046 #include <X11/Xaw3d/TextP.h>
00047 
00048 /****************************************************************
00049  *
00050  * Full class record constant
00051  *
00052  ****************************************************************/
00053 
00054 static void ClassPartInitialize(), Initialize(), Destroy();
00055 static Boolean SetValues();
00056 
00057 static int MaxHeight(), MaxLines();
00058 static void DisplayText(), InsertCursor(), ClearToBackground(), FindPosition();
00059 static void FindDistance(), Resolve(), SetTabs(), GetCursorBounds();
00060 
00061 #define offset(field) XtOffsetOf(TextSinkRec, text_sink.field)
00062 static XtResource resources[] = {
00063   {XtNforeground, XtCForeground, XtRPixel, sizeof (Pixel),
00064      offset(foreground), XtRString, XtDefaultForeground}, 
00065   {XtNbackground, XtCBackground, XtRPixel, sizeof (Pixel),
00066      offset(background), XtRString, XtDefaultBackground}, 
00067 };
00068 #undef offset
00069 
00070 #define SuperClass              (&objectClassRec)
00071 TextSinkClassRec textSinkClassRec = {
00072   {
00073 /* core_class fields */ 
00074     /* superclass               */      (WidgetClass) SuperClass,
00075     /* class_name               */      "TextSink",
00076     /* widget_size              */      sizeof(TextSinkRec),
00077     /* class_initialize         */      XawInitializeWidgetSet,
00078     /* class_part_initialize    */      ClassPartInitialize,
00079     /* class_inited             */      FALSE,
00080     /* initialize               */      Initialize,
00081     /* initialize_hook          */      NULL,
00082     /* obj1                     */      NULL,
00083     /* obj2                     */      NULL,
00084     /* obj3                     */      0,
00085     /* resources                */      resources,
00086     /* num_resources            */      XtNumber(resources),
00087     /* xrm_class                */      NULLQUARK,
00088     /* obj4                     */      FALSE,
00089     /* obj5                     */      FALSE,
00090     /* obj6                     */      FALSE,
00091     /* obj7                     */      FALSE,
00092     /* destroy                  */      Destroy,
00093     /* obj8                     */      NULL,
00094     /* obj9                     */      NULL,
00095     /* set_values               */      SetValues,
00096     /* set_values_hook          */      NULL,
00097     /* obj10                    */      NULL,
00098     /* get_values_hook          */      NULL,
00099     /* obj11                    */      NULL,
00100     /* version                  */      XtVersion,
00101     /* callback_private         */      NULL,
00102     /* obj12                    */      NULL,
00103     /* obj13                    */      NULL,
00104     /* obj14                    */      NULL,
00105     /* extension                */      NULL
00106   },
00107 /* textSink_class fields */
00108   {
00109     /* DisplayText              */      DisplayText,
00110     /* InsertCursor             */      InsertCursor,
00111     /* ClearToBackground        */      ClearToBackground,
00112     /* FindPosition             */      FindPosition,
00113     /* FindDistance             */      FindDistance,
00114     /* Resolve                  */      Resolve,
00115     /* MaxLines                 */      MaxLines,
00116     /* MaxHeight                */      MaxHeight,
00117     /* SetTabs                  */      SetTabs,
00118     /* GetCursorBounds          */      GetCursorBounds,
00119   }
00120 };
00121 
00122 WidgetClass textSinkObjectClass = (WidgetClass)&textSinkClassRec;
00123 
00124 static void
00125 ClassPartInitialize(wc)
00126 WidgetClass wc;
00127 {
00128   TextSinkObjectClass t_src, superC;
00129 
00130   t_src = (TextSinkObjectClass) wc;
00131   superC = (TextSinkObjectClass) t_src->object_class.superclass;
00132 
00133 /* 
00134  * We don't need to check for null super since we'll get to TextSink
00135  * eventually.
00136  */
00137 
00138     if (t_src->text_sink_class.DisplayText == XtInheritDisplayText) 
00139       t_src->text_sink_class.DisplayText = superC->text_sink_class.DisplayText;
00140 
00141     if (t_src->text_sink_class.InsertCursor == XtInheritInsertCursor) 
00142       t_src->text_sink_class.InsertCursor =
00143                                           superC->text_sink_class.InsertCursor;
00144 
00145     if (t_src->text_sink_class.ClearToBackground== XtInheritClearToBackground) 
00146       t_src->text_sink_class.ClearToBackground = 
00147                                      superC->text_sink_class.ClearToBackground;
00148 
00149     if (t_src->text_sink_class.FindPosition == XtInheritFindPosition) 
00150       t_src->text_sink_class.FindPosition = 
00151                                           superC->text_sink_class.FindPosition;
00152 
00153     if (t_src->text_sink_class.FindDistance == XtInheritFindDistance) 
00154       t_src->text_sink_class.FindDistance = 
00155                                          superC->text_sink_class.FindDistance;
00156 
00157     if (t_src->text_sink_class.Resolve == XtInheritResolve) 
00158       t_src->text_sink_class.Resolve = superC->text_sink_class.Resolve;
00159 
00160     if (t_src->text_sink_class.MaxLines == XtInheritMaxLines) 
00161       t_src->text_sink_class.MaxLines = superC->text_sink_class.MaxLines;
00162 
00163     if (t_src->text_sink_class.MaxHeight == XtInheritMaxHeight) 
00164       t_src->text_sink_class.MaxHeight = superC->text_sink_class.MaxHeight;
00165 
00166     if (t_src->text_sink_class.SetTabs == XtInheritSetTabs) 
00167       t_src->text_sink_class.SetTabs = superC->text_sink_class.SetTabs;
00168 
00169     if (t_src->text_sink_class.GetCursorBounds == XtInheritGetCursorBounds) 
00170       t_src->text_sink_class.GetCursorBounds = 
00171                                        superC->text_sink_class.GetCursorBounds;
00172 }
00173 
00174 /*      Function Name: Initialize
00175  *      Description: Initializes the TextSink Object.
00176  *      Arguments: request, new - the requested and new values for the object
00177  *                                instance.
00178  *      Returns: none.
00179  *
00180  */
00181 
00182 /* ARGSUSED */
00183 static void
00184 Initialize(request, new, args, num_args)
00185 Widget request, new;
00186 ArgList args;
00187 Cardinal *num_args;
00188 {
00189   TextSinkObject sink = (TextSinkObject) new;
00190 
00191   sink->text_sink.tab_count = 0; /* Initialize the tab stops. */
00192   sink->text_sink.tabs = NULL;
00193   sink->text_sink.char_tabs = NULL;
00194 }
00195 
00196 /*      Function Name: Destroy
00197  *      Description: This function cleans up when the object is 
00198  *                   destroyed.
00199  *      Arguments: w - the TextSink Object.
00200  *      Returns: none.
00201  */
00202 
00203 static void
00204 Destroy(w)
00205 Widget w;
00206 {
00207   TextSinkObject sink = (TextSinkObject) w;
00208 
00209   XtFree((char *) sink->text_sink.tabs);
00210   XtFree((char *) sink->text_sink.char_tabs);
00211 }
00212 
00213 /*      Function Name: SetValues
00214  *      Description: Sets the values for the TextSink
00215  *      Arguments: current - current state of the object.
00216  *                 request - what was requested.
00217  *                 new - what the object will become.
00218  *      Returns: True if redisplay is needed.
00219  */
00220 
00221 /* ARGSUSED */
00222 static Boolean
00223 SetValues(current, request, new, args, num_args)
00224 Widget current, request, new;
00225 ArgList args;
00226 Cardinal *num_args;
00227 {
00228   TextSinkObject w = (TextSinkObject) new;
00229   TextSinkObject old_w = (TextSinkObject) current;
00230 
00231   if (w->text_sink.foreground != old_w->text_sink.foreground)
00232      ((TextWidget)XtParent(new))->text.redisplay_needed = True;
00233 
00234   return FALSE;
00235 }
00236 
00237 /************************************************************
00238  *
00239  * Class specific methods.
00240  *
00241  ************************************************************/
00242 
00243 /*      Function Name: DisplayText
00244  *      Description: Stub function that in subclasses will display text. 
00245  *      Arguments: w - the TextSink Object.
00246  *                 x, y - location to start drawing text.
00247  *                 pos1, pos2 - location of starting and ending points
00248  *                              in the text buffer.
00249  *                 highlight - hightlight this text?
00250  *      Returns: none.
00251  *
00252  * This function doesn't actually display anything, it is only a place
00253  * holder.
00254  */
00255 
00256 /* ARGSUSED */
00257 static void
00258 DisplayText(w, x, y, pos1, pos2, highlight)
00259 Widget w;
00260 Position x, y;
00261 Boolean highlight;
00262 XawTextPosition pos1, pos2;
00263 {
00264   return;
00265 }
00266 
00267 /*      Function Name: InsertCursor
00268  *      Description: Places the InsertCursor.
00269  *      Arguments: w - the TextSink Object.
00270  *                 x, y - location for the cursor.
00271  *                 staye - whether to turn the cursor on, or off.
00272  *      Returns: none.
00273  *
00274  * This function doesn't actually display anything, it is only a place
00275  * holder.
00276  */
00277 
00278 /* ARGSUSED */
00279 static void
00280 InsertCursor(w, x, y, state)
00281 Widget w;
00282 Position x, y;
00283 XawTextInsertState state;
00284 {
00285   return;
00286 }
00287 
00288 /*      Function Name: ClearToBackground
00289  *      Description: Clears a region of the sink to the background color.
00290  *      Arguments: w - the TextSink Object.
00291  *                 x, y  - location of area to clear.
00292  *                 width, height - size of area to clear
00293  *      Returns: void.
00294  *
00295  */
00296 
00297 /* ARGSUSED */
00298 static void
00299 ClearToBackground (w, x, y, width, height)
00300 Widget w;
00301 Position x, y;
00302 Dimension width, height;
00303 {
00304 /* 
00305  * Don't clear in height or width are zero.
00306  * XClearArea() has special semantic for these values.
00307  */
00308 
00309     if ( (height == 0) || (width == 0) ) return;
00310     XClearArea(XtDisplayOfObject(w), XtWindowOfObject(w),
00311                x, y, width, height, False);
00312 }
00313 
00314 /*      Function Name: FindPosition
00315  *      Description: Finds a position in the text.
00316  *      Arguments: w - the TextSink Object.
00317  *                 fromPos - reference position.
00318  *                 fromX   - reference location.
00319  *                 width,  - width of section to paint text.
00320  *                 stopAtWordBreak - returned position is a word break?
00321  *                 resPos - Position to return.      *** RETURNED ***
00322  *                 resWidth - Width actually used.   *** RETURNED ***
00323  *                 resHeight - Height actually used. *** RETURNED ***
00324  *      Returns: none (see above).
00325  */
00326 
00327 /* ARGSUSED */
00328 static void
00329 FindPosition(w, fromPos, fromx, width, stopAtWordBreak, 
00330              resPos, resWidth, resHeight)
00331 Widget w;
00332 XawTextPosition fromPos; 
00333 int fromx, width;                       
00334 Boolean stopAtWordBreak;                
00335 XawTextPosition *resPos;        
00336 int *resWidth, *resHeight;              
00337 {
00338   *resPos = fromPos;
00339   *resHeight = *resWidth = 0;
00340 }
00341 
00342 /*      Function Name: FindDistance
00343  *      Description: Find the Pixel Distance between two text Positions.
00344  *      Arguments: w - the TextSink Object.
00345  *                 fromPos - starting Position.
00346  *                 fromX   - x location of starting Position.
00347  *                 toPos   - end Position.
00348  *                 resWidth - Distance between fromPos and toPos.
00349  *                 resPos   - Acutal toPos used.
00350  *                 resHeight - Height required by this text.
00351  *      Returns: none.
00352  */
00353 
00354 /* ARGSUSED */
00355 static void
00356 FindDistance (w, fromPos, fromx, toPos, resWidth, resPos, resHeight)
00357 Widget w;
00358 XawTextPosition fromPos;
00359 int fromx;
00360 XawTextPosition toPos;
00361 int *resWidth;
00362 XawTextPosition *resPos;
00363 int *resHeight;
00364 {
00365   *resWidth = *resHeight = 0;
00366   *resPos = fromPos;
00367 }
00368 
00369 /*      Function Name: Resolve
00370  *      Description: Resloves a location to a position.
00371  *      Arguments: w - the TextSink Object.
00372  *                 pos - a reference Position.
00373  *                 fromx - a reference Location.
00374  *                 width - width to move.
00375  *                 resPos - the resulting position.
00376  *      Returns: none
00377  */
00378 
00379 /* ARGSUSED */
00380 static void
00381 Resolve (w, pos, fromx, width, resPos)
00382 Widget w;
00383 XawTextPosition pos;
00384 int fromx, width;
00385 XawTextPosition *resPos;
00386 {
00387   *resPos = pos;
00388 }
00389 
00390 /*      Function Name: MaxLines
00391  *      Description: Finds the Maximum number of lines that will fit in
00392  *                   a given height.
00393  *      Arguments: w - the TextSink Object.
00394  *                 height - height to fit lines into.
00395  *      Returns: the number of lines that will fit.
00396  */
00397 
00398 /* ARGSUSED */
00399 static int
00400 MaxLines(w, height)
00401 Widget w;
00402 Dimension height;
00403 {
00404   /*
00405    * The fontset has gone down to descent Sink Widget, so
00406    * the functions such MaxLines, SetTabs... are bound to the descent.
00407    *
00408    * by Li Yuhong, Jan. 15, 1991
00409    */
00410   return 0;
00411 }
00412 
00413 /*      Function Name: MaxHeight
00414  *      Description: Finds the Minium height that will contain a given number 
00415  *                   lines.
00416  *      Arguments: w - the TextSink Object.
00417  *                 lines - the number of lines.
00418  *      Returns: the height.
00419  */
00420 
00421 /* ARGSUSED */
00422 static int
00423 MaxHeight(w, lines)
00424 Widget w;
00425 int lines;
00426 {
00427   return 0;
00428 }
00429 
00430 /*      Function Name: SetTabs
00431  *      Description: Sets the Tab stops.
00432  *      Arguments: w - the TextSink Object.
00433  *                 tab_count - the number of tabs in the list.
00434  *                 tabs - the text positions of the tabs.
00435  *      Returns: none
00436  */
00437 
00438 /*ARGSUSED*/
00439 static void
00440 SetTabs(w, tab_count, tabs)
00441 Widget w;
00442 int tab_count;
00443 short *tabs;
00444 {
00445   return;
00446 }
00447 
00448 /*      Function Name: GetCursorBounds
00449  *      Description: Finds the bounding box for the insert curor (caret).
00450  *      Arguments: w - the TextSinkObject.
00451  *                 rect - an X rectance containing the cursor bounds.
00452  *      Returns: none (fills in rect).
00453  */
00454 
00455 /* ARGSUSED */
00456 static void
00457 GetCursorBounds(w, rect)
00458 Widget w;
00459 XRectangle * rect;
00460 {
00461   rect->x = rect->y = rect->width = rect->height = 0;
00462 }
00463 /************************************************************
00464  *
00465  * Public Functions.
00466  *
00467  ************************************************************/
00468 
00469 
00470 /*      Function Name: XawTextSinkDisplayText
00471  *      Description: Stub function that in subclasses will display text. 
00472  *      Arguments: w - the TextSink Object.
00473  *                 x, y - location to start drawing text.
00474  *                 pos1, pos2 - location of starting and ending points
00475  *                              in the text buffer.
00476  *                 highlight - hightlight this text?
00477  *      Returns: none.
00478  *
00479  * This function doesn't actually display anything, it is only a place
00480  * holder.
00481  */
00482 
00483 /* ARGSUSED */
00484 void
00485 #if NeedFunctionPrototypes
00486 XawTextSinkDisplayText(Widget w,
00487 #if NeedWidePrototypes
00488                        /* Position */ int x, /* Position */ int y,
00489 #else
00490                        Position x, Position y,
00491 #endif
00492                        XawTextPosition pos1, XawTextPosition pos2,
00493 #if NeedWidePrototypes
00494                        /* Boolean */ int highlight)
00495 #else
00496                        Boolean highlight)
00497 #endif
00498 #else
00499 XawTextSinkDisplayText(w, x, y, pos1, pos2, highlight)
00500 Widget w;
00501 Position x, y;
00502 Boolean highlight;
00503 XawTextPosition pos1, pos2;
00504 #endif
00505 {
00506   TextSinkObjectClass class = (TextSinkObjectClass) w->core.widget_class;
00507 
00508   (*class->text_sink_class.DisplayText)(w, x, y, pos1, pos2, highlight);
00509 }
00510 
00511 /*      Function Name: XawTextSinkInsertCursor
00512  *      Description: Places the InsertCursor.
00513  *      Arguments: w - the TextSink Object.
00514  *                 x, y - location for the cursor.
00515  *                 staye - whether to turn the cursor on, or off.
00516  *      Returns: none.
00517  *
00518  * This function doesn't actually display anything, it is only a place
00519  * holder.
00520  */
00521 
00522 /* ARGSUSED */
00523 void
00524 #if NeedFunctionPrototypes
00525 XawTextSinkInsertCursor(Widget w,
00526 #if NeedWidePrototypes
00527                         int x, int y, int state)
00528 #else
00529                         Position x, Position y, XawTextInsertState state)
00530 #endif
00531 #else    
00532 XawTextSinkInsertCursor(w, x, y, state)
00533 Widget w;
00534 Position x, y;
00535 XawTextInsertState state;
00536 #endif
00537 {
00538   TextSinkObjectClass class = (TextSinkObjectClass) w->core.widget_class;
00539     
00540   (*class->text_sink_class.InsertCursor)(w, x, y, state);
00541 }
00542 
00543 
00544 /*      Function Name: XawTextSinkClearToBackground
00545  *      Description: Clears a region of the sink to the background color.
00546  *      Arguments: w - the TextSink Object.
00547  *                 x, y  - location of area to clear.
00548  *                 width, height - size of area to clear
00549  *      Returns: void.
00550  *
00551  * This function doesn't actually display anything, it is only a place
00552  * holder.
00553  */
00554 
00555 /* ARGSUSED */
00556 void
00557 #if NeedFunctionPrototypes
00558 XawTextSinkClearToBackground (Widget w,
00559 #if NeedWidePrototypes
00560                               int x, int y, int width, int height)
00561 #else
00562                               Position x, Position y, 
00563                               Dimension width, Dimension height)
00564 #endif
00565 #else
00566 XawTextSinkClearToBackground (w, x, y, width, height)
00567 Widget w;
00568 Position x, y;
00569 Dimension width, height;
00570 #endif
00571 {
00572   TextSinkObjectClass class = (TextSinkObjectClass) w->core.widget_class;
00573 
00574   (*class->text_sink_class.ClearToBackground)(w, x, y, width, height);
00575 }
00576 
00577 /*      Function Name: XawTextSinkFindPosition
00578  *      Description: Finds a position in the text.
00579  *      Arguments: w - the TextSink Object.
00580  *                 fromPos - reference position.
00581  *                 fromX   - reference location.
00582  *                 width,  - width of section to paint text.
00583  *                 stopAtWordBreak - returned position is a word break?
00584  *                 resPos - Position to return.      *** RETURNED ***
00585  *                 resWidth - Width actually used.   *** RETURNED ***
00586  *                 resHeight - Height actually used. *** RETURNED ***
00587  *      Returns: none (see above).
00588  */
00589 
00590 /* ARGSUSED */
00591 void
00592 #if NeedFunctionPrototypes
00593 XawTextSinkFindPosition(Widget w, XawTextPosition fromPos, int fromx,
00594                         int width,
00595 #if NeedWidePrototypes
00596                         /* Boolean */ int stopAtWordBreak,
00597 #else
00598                         Boolean stopAtWordBreak,
00599 #endif
00600                         XawTextPosition *resPos, int *resWidth, int *resHeight)
00601 #else
00602 XawTextSinkFindPosition(w, fromPos, fromx, width, stopAtWordBreak, 
00603                         resPos, resWidth, resHeight)
00604 Widget w;
00605 XawTextPosition fromPos; 
00606 int fromx, width;                       
00607 Boolean stopAtWordBreak;                
00608 XawTextPosition *resPos;        
00609 int *resWidth, *resHeight;
00610 #endif
00611 {
00612   TextSinkObjectClass class = (TextSinkObjectClass) w->core.widget_class;
00613 
00614   (*class->text_sink_class.FindPosition)(w, fromPos, fromx, width,
00615                                          stopAtWordBreak, 
00616                                          resPos, resWidth, resHeight);
00617 }
00618 
00619 /*      Function Name: XawTextSinkFindDistance
00620  *      Description: Find the Pixel Distance between two text Positions.
00621  *      Arguments: w - the TextSink Object.
00622  *                 fromPos - starting Position.
00623  *                 fromX   - x location of starting Position.
00624  *                 toPos   - end Position.
00625  *                 resWidth - Distance between fromPos and toPos.
00626  *                 resPos   - Acutal toPos used.
00627  *                 resHeight - Height required by this text.
00628  *      Returns: none.
00629  */
00630 
00631 /* ARGSUSED */
00632 void
00633 #if NeedFunctionPrototypes
00634 XawTextSinkFindDistance (Widget w, XawTextPosition fromPos, int fromx,
00635                          XawTextPosition toPos, int *resWidth, 
00636                          XawTextPosition *resPos, int *resHeight)
00637 #else
00638 XawTextSinkFindDistance (w, fromPos, fromx, toPos, resWidth, resPos, resHeight)
00639 Widget w;
00640 XawTextPosition fromPos, toPos, *resPos;
00641 int fromx, *resWidth, *resHeight;
00642 #endif
00643 {
00644   TextSinkObjectClass class = (TextSinkObjectClass) w->core.widget_class;
00645 
00646   (*class->text_sink_class.FindDistance)(w, fromPos, fromx, toPos,
00647                                          resWidth, resPos, resHeight);
00648 }
00649 
00650 /*      Function Name: XawTextSinkResolve
00651  *      Description: Resloves a location to a position.
00652  *      Arguments: w - the TextSink Object.
00653  *                 pos - a reference Position.
00654  *                 fromx - a reference Location.
00655  *                 width - width to move.
00656  *                 resPos - the resulting position.
00657  *      Returns: none
00658  */
00659 
00660 /* ARGSUSED */
00661 void
00662 #if NeedFunctionPrototypes
00663 XawTextSinkResolve(Widget w, XawTextPosition pos, int fromx, int width,
00664                    XawTextPosition *resPos)
00665 #else
00666 XawTextSinkResolve(w, pos, fromx, width, resPos)
00667 Widget w;
00668 XawTextPosition pos;
00669 int fromx, width;
00670 XawTextPosition *resPos;
00671 #endif
00672 {
00673   TextSinkObjectClass class = (TextSinkObjectClass) w->core.widget_class;
00674 
00675   (*class->text_sink_class.Resolve)(w, pos, fromx, width, resPos);
00676 }
00677 
00678 /*      Function Name: XawTextSinkMaxLines
00679  *      Description: Finds the Maximum number of lines that will fit in
00680  *                   a given height.
00681  *      Arguments: w - the TextSink Object.
00682  *                 height - height to fit lines into.
00683  *      Returns: the number of lines that will fit.
00684  */
00685 
00686 /* ARGSUSED */
00687 int
00688 #if NeedFunctionPrototypes
00689 XawTextSinkMaxLines(Widget w,
00690 #if NeedWidePrototypes
00691                     /* Dimension */ int height)
00692 #else
00693                     Dimension height)
00694 #endif
00695 #else
00696 XawTextSinkMaxLines(w, height)
00697 Widget w;
00698 Dimension height;
00699 #endif
00700 {
00701   TextSinkObjectClass class = (TextSinkObjectClass) w->core.widget_class;
00702 
00703   return((*class->text_sink_class.MaxLines)(w, height));
00704 }
00705 
00706 /*      Function Name: XawTextSinkMaxHeight
00707  *      Description: Finds the Minimum height that will contain a given number 
00708  *                   lines.
00709  *      Arguments: w - the TextSink Object.
00710  *                 lines - the number of lines.
00711  *      Returns: the height.
00712  */
00713 
00714 /* ARGSUSED */
00715 int
00716 #if NeedFunctionPrototypes
00717 XawTextSinkMaxHeight(Widget w, int lines)
00718 #else
00719 XawTextSinkMaxHeight(w, lines)
00720 Widget w;
00721 int lines;
00722 #endif
00723 {
00724   TextSinkObjectClass class = (TextSinkObjectClass) w->core.widget_class;
00725 
00726   return((*class->text_sink_class.MaxHeight)(w, lines));
00727 }
00728 
00729 /*      Function Name: XawTextSinkSetTabs
00730  *      Description: Sets the Tab stops.
00731  *      Arguments: w - the TextSink Object.
00732  *                 tab_count - the number of tabs in the list.
00733  *                 tabs - the text positions of the tabs.
00734  *      Returns: none
00735  */
00736 
00737 void
00738 #if NeedFunctionPrototypes
00739 XawTextSinkSetTabs(Widget w, int tab_count, int *tabs)
00740 #else
00741 XawTextSinkSetTabs(w, tab_count, tabs)
00742 Widget w;
00743 int tab_count, *tabs;
00744 #endif
00745 {
00746   if (tab_count > 0) {
00747     TextSinkObjectClass class = (TextSinkObjectClass) w->core.widget_class;
00748     short *char_tabs = (short*)XtMalloc( (unsigned)tab_count*sizeof(short) );
00749     short *tab;
00750     int i;
00751 
00752     for (i = tab_count, tab = char_tabs; i; i--) *tab++ = (short)*tabs++;
00753 
00754     (*class->text_sink_class.SetTabs)(w, tab_count, char_tabs);
00755     XtFree((char *)char_tabs);
00756   }
00757 }
00758                                                   
00759 /*      Function Name: XawTextSinkGetCursorBounds
00760  *      Description: Finds the bounding box for the insert curor (caret).
00761  *      Arguments: w - the TextSinkObject.
00762  *                 rect - an X rectance containing the cursor bounds.
00763  *      Returns: none (fills in rect).
00764  */
00765 
00766 /* ARGSUSED */
00767 void
00768 #if NeedFunctionPrototypes
00769 XawTextSinkGetCursorBounds(Widget w, XRectangle *rect)
00770 #else
00771 XawTextSinkGetCursorBounds(w, rect)
00772 Widget w;
00773 XRectangle * rect;
00774 #endif
00775 {
00776   TextSinkObjectClass class = (TextSinkObjectClass) w->core.widget_class;
00777 
00778   (*class->text_sink_class.GetCursorBounds)(w, rect);
00779 }

Generated on Sun Mar 4 15:03:55 2007 for Scilab [trunk] by  doxygen 1.5.1