TextSink.c revision 749
159N/ACopyright (c) 1989, 1994 X Consortium 159N/APermission is hereby granted, free of charge, to any person obtaining a copy 159N/Aof this software and associated documentation files (the "Software"), to deal 919N/Ain the Software without restriction, including without limitation the rights 919N/Ato use, copy, modify, merge, publish, distribute, sublicense, and/or sell 919N/Acopies of the Software, and to permit persons to whom the Software is 919N/Afurnished to do so, subject to the following conditions: 919N/AThe above copyright notice and this permission notice shall be included in 919N/Aall copies or substantial portions of the Software. 919N/ATHE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 919N/AIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 919N/AFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 919N/AX CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN 919N/AAN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 919N/ACONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 919N/AExcept as contained in this notice, the name of the X Consortium shall not be 919N/Aused in advertising or otherwise to promote the sale, use or other dealings 159N/Ain this Software without prior written authorization from the X Consortium. 159N/A * Author: Chris Peterson, MIT X Consortium. 1351N/A * Much code taken from X11R3 AsciiSink. 159N/A/**************************************************************** 999N/A * Full class record constant 999N/A ****************************************************************/ 1196N/A /* class_name */ "TextSink",
/* class_inited */ FALSE,
/* initialize_hook */ NULL,
/* set_values_hook */ NULL,
/* get_values_hook */ NULL,
/* callback_private */ NULL,
/* textSink_class fields */ * We don't need to check for null super since we'll get to TextSink /* Function Name: Initialize * Description: Initializes the TextSink Object. * Arguments: request, new - the requested and new values for the object /* Function Name: Destroy * Description: This function cleans up when the object is * Arguments: w - the TextSink Object. /* Function Name: SetValues * Description: Sets the values for the TextSink * Arguments: current - current state of the object. * request - what was requested. * new - what the object will become. * Returns: True if redisplay is needed. /************************************************************ * Class specific methods. ************************************************************/ /* Function Name: DisplayText * Description: Stub function that in subclasses will display text. * Arguments: w - the TextSink Object. * x, y - location to start drawing text. * pos1, pos2 - location of starting and ending points * highlight - hightlight this text? * This function doesn't actually display anything, it is only a place /* Function Name: InsertCursor * Description: Places the InsertCursor. * Arguments: w - the TextSink Object. * x, y - location for the cursor. * staye - whether to turn the cursor on, or off. * This function doesn't actually display anything, it is only a place /* Function Name: ClearToBackground * Description: Clears a region of the sink to the background color. * Arguments: w - the TextSink Object. * x, y - location of area to clear. * width, height - size of area to clear * Don't clear in height or width are zero. * XClearArea() has special semantic for these values. /* Function Name: FindPosition * Description: Finds a position in the text. * Arguments: w - the TextSink Object. * fromPos - reference position. * fromX - reference location. * width, - width of section to paint text. * stopAtWordBreak - returned position is a word break? * resPos - Position to return. *** RETURNED *** * resWidth - Width actually used. *** RETURNED *** * resHeight - Height actually used. *** RETURNED *** * Returns: none (see above). /* Function Name: FindDistance * Description: Find the Pixel Distance between two text Positions. * Arguments: w - the TextSink Object. * fromPos - starting Position. * fromX - x location of starting Position. * resWidth - Distance between fromPos and toPos. * resPos - Acutal toPos used. * resHeight - Height required by this text. /* Function Name: Resolve * Description: Resloves a location to a position. * Arguments: w - the TextSink Object. * pos - a reference Position. * fromx - a reference Location. * resPos - the resulting position. /* Function Name: MaxLines * Description: Finds the Maximum number of lines that will fit in * Arguments: w - the TextSink Object. * height - height to fit lines into. * Returns: the number of lines that will fit. * The fontset has gone down to descent Sink Widget, so * the functions such MaxLines, SetTabs... are bound to the descent. * by Li Yuhong, Jan. 15, 1991 /* Function Name: MaxHeight * Description: Finds the Minium height that will contain a given number * Arguments: w - the TextSink Object. * lines - the number of lines. /* Function Name: SetTabs * Description: Sets the Tab stops. * Arguments: w - the TextSink Object. * tab_count - the number of tabs in the list. * tabs - the text positions of the tabs. /* Function Name: GetCursorBounds * Description: Finds the bounding box for the insert curor (caret). * Arguments: w - the TextSinkObject. * rect - an X rectance containing the cursor bounds. * Returns: none (fills in rect). /************************************************************ ************************************************************/ /* Function Name: XawTextSinkDisplayText * Description: Stub function that in subclasses will display text. * Arguments: w - the TextSink Object. * x, y - location to start drawing text. * pos1, pos2 - location of starting and ending points * highlight - hightlight this text? * This function doesn't actually display anything, it is only a place /* Position */ int x,
/* Position */ int y,
/* Function Name: XawTextSinkInsertCursor * Description: Places the InsertCursor. * Arguments: w - the TextSink Object. * x, y - location for the cursor. * staye - whether to turn the cursor on, or off. * This function doesn't actually display anything, it is only a place /* Function Name: XawTextSinkClearToBackground * Description: Clears a region of the sink to the background color. * Arguments: w - the TextSink Object. * x, y - location of area to clear. * width, height - size of area to clear * This function doesn't actually display anything, it is only a place /* Function Name: XawTextSinkFindPosition * Description: Finds a position in the text. * Arguments: w - the TextSink Object. * fromPos - reference position. * fromX - reference location. * width, - width of section to paint text. * stopAtWordBreak - returned position is a word break? * resPos - Position to return. *** RETURNED *** * resWidth - Width actually used. *** RETURNED *** * resHeight - Height actually used. *** RETURNED *** * Returns: none (see above). /* Function Name: XawTextSinkFindDistance * Description: Find the Pixel Distance between two text Positions. * Arguments: w - the TextSink Object. * fromPos - starting Position. * fromX - x location of starting Position. * resWidth - Distance between fromPos and toPos. * resPos - Acutal toPos used. * resHeight - Height required by this text. /* Function Name: XawTextSinkResolve * Description: Resloves a location to a position. * Arguments: w - the TextSink Object. * pos - a reference Position. * fromx - a reference Location. * resPos - the resulting position. /* Function Name: XawTextSinkMaxLines * Description: Finds the Maximum number of lines that will fit in * Arguments: w - the TextSink Object. * height - height to fit lines into. * Returns: the number of lines that will fit. /* Dimension */ unsigned int height)
/* Function Name: XawTextSinkMaxHeight * Description: Finds the Minimum height that will contain a given number * Arguments: w - the TextSink Object. * lines - the number of lines. /* Function Name: XawTextSinkSetTabs * Description: Sets the Tab stops. * Arguments: w - the TextSink Object. * tab_count - the number of tabs in the list. * tabs - the text positions of the tabs. /* Function Name: XawTextSinkGetCursorBounds * Description: Finds the bounding box for the insert curor (caret). * Arguments: w - the TextSinkObject. * rect - an X rectance containing the cursor bounds. * Returns: none (fills in rect).