/* $XConsortium: TextSink.c,v 1.19 94/04/17 20:13:11 kaleb Exp $ */
/*
Copyright (c) 1989, 1994 X Consortium
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Except as contained in this notice, the name of the X Consortium shall not be
used in advertising or otherwise to promote the sale, use or other dealings
in this Software without prior written authorization from the X Consortium.
*/
/*
* Author: Chris Peterson, MIT X Consortium.
*
* Much code taken from X11R3 AsciiSink.
*/
/*
* TextSink.c - TextSink object. (For use with the text widget).
*
*/
#include <stdio.h>
#include <ctype.h>
#include <X11/IntrinsicP.h>
#include <X11/StringDefs.h>
/****************************************************************
*
* Full class record constant
*
****************************************************************/
};
{
/* core_class fields */
/* class_name */ "TextSink",
/* widget_size */ sizeof(TextSinkRec),
/* class_initialize */ XawInitializeWidgetSet,
/* class_part_initialize */ ClassPartInitialize,
/* class_inited */ FALSE,
/* initialize */ Initialize,
/* initialize_hook */ NULL,
/* obj1 */ NULL,
/* obj2 */ NULL,
/* obj3 */ 0,
/* resources */ resources,
/* xrm_class */ NULLQUARK,
/* obj4 */ FALSE,
/* obj5 */ FALSE,
/* obj6 */ FALSE,
/* obj7 */ FALSE,
/* destroy */ Destroy,
/* obj8 */ NULL,
/* obj9 */ NULL,
/* set_values */ SetValues,
/* set_values_hook */ NULL,
/* obj10 */ NULL,
/* get_values_hook */ NULL,
/* obj11 */ NULL,
/* version */ XtVersion,
/* callback_private */ NULL,
/* obj12 */ NULL,
/* obj13 */ NULL,
/* obj14 */ NULL,
/* extension */ NULL
},
/* textSink_class fields */
{
/* DisplayText */ DisplayText,
/* InsertCursor */ InsertCursor,
/* ClearToBackground */ ClearToBackground,
/* FindPosition */ FindPosition,
/* FindDistance */ FindDistance,
/* Resolve */ Resolve,
/* MaxLines */ MaxLines,
/* MaxHeight */ MaxHeight,
/* SetTabs */ SetTabs,
/* GetCursorBounds */ GetCursorBounds,
}
};
static void
{
/*
* We don't need to check for null super since we'll get to TextSink
* eventually.
*/
}
/* Function Name: Initialize
* Description: Initializes the TextSink Object.
* Arguments: request, new - the requested and new values for the object
* instance.
* Returns: none.
*
*/
/* ARGSUSED */
static void
{
}
/* Function Name: Destroy
* Description: This function cleans up when the object is
* destroyed.
* Arguments: w - the TextSink Object.
* Returns: none.
*/
static void
Destroy(w)
Widget w;
{
}
/* 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.
*/
/* ARGSUSED */
static Boolean
{
return FALSE;
}
/************************************************************
*
* 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
* in the text buffer.
* highlight - hightlight this text?
* Returns: none.
*
* This function doesn't actually display anything, it is only a place
* holder.
*/
/* ARGSUSED */
static void
Widget w;
Position x, y;
{
return;
}
/* 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.
* Returns: none.
*
* This function doesn't actually display anything, it is only a place
* holder.
*/
/* ARGSUSED */
static void
Widget w;
Position x, y;
{
return;
}
/* 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
* Returns: void.
*
*/
/* ARGSUSED */
static void
Widget w;
Position x, y;
{
/*
* 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).
*/
/* ARGSUSED */
static void
Widget w;
{
}
/* 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.
* toPos - end Position.
* resWidth - Distance between fromPos and toPos.
* resPos - Acutal toPos used.
* resHeight - Height required by this text.
* Returns: none.
*/
/* ARGSUSED */
static void
Widget w;
int fromx;
int *resWidth;
int *resHeight;
{
}
/* Function Name: Resolve
* Description: Resloves a location to a position.
* Arguments: w - the TextSink Object.
* pos - a reference Position.
* fromx - a reference Location.
* width - width to move.
* resPos - the resulting position.
* Returns: none
*/
/* ARGSUSED */
static void
Widget w;
{
}
/* Function Name: MaxLines
* Description: Finds the Maximum number of lines that will fit in
* a given height.
* Arguments: w - the TextSink Object.
* height - height to fit lines into.
* Returns: the number of lines that will fit.
*/
/* ARGSUSED */
static int
Widget w;
{
/*
* 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
*/
return 0;
}
/* Function Name: MaxHeight
* Description: Finds the Minium height that will contain a given number
* lines.
* Arguments: w - the TextSink Object.
* lines - the number of lines.
* Returns: the height.
*/
/* ARGSUSED */
static int
Widget w;
int lines;
{
return 0;
}
/* 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.
* Returns: none
*/
/*ARGSUSED*/
static void
Widget w;
int tab_count;
short *tabs;
{
return;
}
/* 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).
*/
/* ARGSUSED */
static void
Widget w;
XRectangle * rect;
{
}
/************************************************************
*
* Public Functions.
*
************************************************************/
/* 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
* in the text buffer.
* highlight - hightlight this text?
* Returns: none.
*
* This function doesn't actually display anything, it is only a place
* holder.
*/
/* ARGSUSED */
void
/* Position */ int x, /* Position */ int y,
#else
#endif
/* Boolean */ int highlight)
#else
#endif
#else
Widget w;
Position x, y;
#endif
{
}
/* 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.
* Returns: none.
*
* This function doesn't actually display anything, it is only a place
* holder.
*/
/* ARGSUSED */
void
int x, int y, int state)
#else
#endif
#else
XawTextSinkInsertCursor(w, x, y, state)
Widget w;
Position x, y;
#endif
{
}
/* 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
* Returns: void.
*
* This function doesn't actually display anything, it is only a place
* holder.
*/
/* ARGSUSED */
void
#else
#endif
#else
Widget w;
Position x, y;
#endif
{
}
/* 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).
*/
/* ARGSUSED */
void
int width,
/* Boolean */ int stopAtWordBreak,
#else
#endif
#else
Widget w;
#endif
{
}
/* 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.
* toPos - end Position.
* resWidth - Distance between fromPos and toPos.
* resPos - Acutal toPos used.
* resHeight - Height required by this text.
* Returns: none.
*/
/* ARGSUSED */
void
#else
Widget w;
#endif
{
}
/* Function Name: XawTextSinkResolve
* Description: Resloves a location to a position.
* Arguments: w - the TextSink Object.
* pos - a reference Position.
* fromx - a reference Location.
* width - width to move.
* resPos - the resulting position.
* Returns: none
*/
/* ARGSUSED */
void
#else
Widget w;
#endif
{
}
/* Function Name: XawTextSinkMaxLines
* Description: Finds the Maximum number of lines that will fit in
* a given height.
* Arguments: w - the TextSink Object.
* height - height to fit lines into.
* Returns: the number of lines that will fit.
*/
/* ARGSUSED */
int
/* Dimension */ unsigned int height)
#else
#endif
#else
Widget w;
#endif
{
}
/* Function Name: XawTextSinkMaxHeight
* Description: Finds the Minimum height that will contain a given number
* lines.
* Arguments: w - the TextSink Object.
* lines - the number of lines.
* Returns: the height.
*/
/* ARGSUSED */
int
#else
Widget w;
int lines;
#endif
{
}
/* 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.
* Returns: none
*/
void
#else
Widget w;
#endif
{
if (tab_count > 0) {
short *tab;
int i;
}
}
/* 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).
*/
/* ARGSUSED */
void
#else
Widget w;
XRectangle * rect;
#endif
{
}