summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKaleb Keithley <kaleb@freedesktop.org>2003-11-14 15:54:38 +0000
committerKaleb Keithley <kaleb@freedesktop.org>2003-11-14 15:54:38 +0000
commitb6e0280a57c4dfa572770241a42fe6a476109516 (patch)
tree13fdc17fc7a24447270fff008af4774c9cdd42b2
downloadxorg-lib-libXaw-b6e0280a57c4dfa572770241a42fe6a476109516.tar.gz
R6.6 is the Xorg base-lineXORG-MAIN
-rw-r--r--include/X11/Xaw/AllWidgets.h38
-rw-r--r--include/X11/Xaw/AsciiSink.h90
-rw-r--r--include/X11/Xaw/AsciiSinkP.h117
-rw-r--r--include/X11/Xaw/AsciiSrc.h161
-rw-r--r--include/X11/Xaw/AsciiSrcP.h166
-rw-r--r--include/X11/Xaw/AsciiText.h147
-rw-r--r--include/X11/Xaw/AsciiTextP.h162
-rw-r--r--include/X11/Xaw/Box.h97
-rw-r--r--include/X11/Xaw/BoxP.h107
-rw-r--r--include/X11/Xaw/Cardinals.h43
-rw-r--r--include/X11/Xaw/Command.h117
-rw-r--r--include/X11/Xaw/CommandP.h139
-rw-r--r--include/X11/Xaw/Dialog.h108
-rw-r--r--include/X11/Xaw/DialogP.h97
-rw-r--r--include/X11/Xaw/Form.h167
-rw-r--r--include/X11/Xaw/FormP.h142
-rw-r--r--include/X11/Xaw/Grip.h104
-rw-r--r--include/X11/Xaw/GripP.h102
-rw-r--r--include/X11/Xaw/Label.h128
-rw-r--r--include/X11/Xaw/LabelP.h128
-rw-r--r--include/X11/Xaw/List.h236
-rw-r--r--include/X11/Xaw/ListP.h115
-rw-r--r--include/X11/Xaw/MenuButtoP.h99
-rw-r--r--include/X11/Xaw/MenuButton.h89
-rw-r--r--include/X11/Xaw/MultiSink.h117
-rw-r--r--include/X11/Xaw/MultiSinkP.h156
-rw-r--r--include/X11/Xaw/MultiSrc.h150
-rw-r--r--include/X11/Xaw/MultiSrcP.h197
-rw-r--r--include/X11/Xaw/Paned.h255
-rw-r--r--include/X11/Xaw/PanedP.h192
-rw-r--r--include/X11/Xaw/Panner.h108
-rw-r--r--include/X11/Xaw/PannerP.h103
-rw-r--r--include/X11/Xaw/Porthole.h64
-rw-r--r--include/X11/Xaw/PortholeP.h64
-rw-r--r--include/X11/Xaw/Repeater.h76
-rw-r--r--include/X11/Xaw/RepeaterP.h79
-rw-r--r--include/X11/Xaw/Reports.h56
-rw-r--r--include/X11/Xaw/Scrollbar.h143
-rw-r--r--include/X11/Xaw/ScrollbarP.h104
-rw-r--r--include/X11/Xaw/Simple.h102
-rw-r--r--include/X11/Xaw/SimpleMenP.h98
-rw-r--r--include/X11/Xaw/SimpleMenu.h151
-rw-r--r--include/X11/Xaw/SimpleP.h85
-rw-r--r--include/X11/Xaw/Sme.h80
-rw-r--r--include/X11/Xaw/SmeBSB.h100
-rw-r--r--include/X11/Xaw/SmeBSBP.h112
-rw-r--r--include/X11/Xaw/SmeLine.h78
-rw-r--r--include/X11/Xaw/SmeLineP.h96
-rw-r--r--include/X11/Xaw/SmeP.h104
-rw-r--r--include/X11/Xaw/StripCharP.h106
-rw-r--r--include/X11/Xaw/StripChart.h119
-rw-r--r--include/X11/Xaw/Template.c93
-rw-r--r--include/X11/Xaw/Template.h72
-rw-r--r--include/X11/Xaw/TemplateP.h67
-rw-r--r--include/X11/Xaw/Text.h309
-rw-r--r--include/X11/Xaw/TextP.h288
-rw-r--r--include/X11/Xaw/TextSink.h317
-rw-r--r--include/X11/Xaw/TextSinkP.h142
-rw-r--r--include/X11/Xaw/TextSrc.h236
-rw-r--r--include/X11/Xaw/TextSrcP.h163
-rw-r--r--include/X11/Xaw/Toggle.h176
-rw-r--r--include/X11/Xaw/ToggleP.h110
-rw-r--r--include/X11/Xaw/Tree.h124
-rw-r--r--include/X11/Xaw/TreeP.h131
-rw-r--r--include/X11/Xaw/VendorEP.h80
-rw-r--r--include/X11/Xaw/Viewport.h123
-rw-r--r--include/X11/Xaw/ViewportP.h105
-rw-r--r--include/X11/Xaw/XawImP.h223
-rw-r--r--include/X11/Xaw/XawInit.h32
-rw-r--r--old-doc/CHANGES153
-rw-r--r--src/AllWidgets.c121
-rw-r--r--src/AsciiSink.c692
-rw-r--r--src/AsciiSrc.c1408
-rw-r--r--src/AsciiText.c335
-rw-r--r--src/Box.c616
-rw-r--r--src/Command.c590
-rw-r--r--src/Dialog.c447
-rw-r--r--src/Form.c847
-rw-r--r--src/Grip.c145
-rw-r--r--src/Label.c772
-rw-r--r--src/List.c1203
-rw-r--r--src/MenuButton.c229
-rw-r--r--src/MultiSink.c772
-rw-r--r--src/MultiSrc.c1458
-rw-r--r--src/Paned.c1944
-rw-r--r--src/Panner.c956
-rw-r--r--src/Porthole.c365
-rw-r--r--src/Repeater.c274
-rw-r--r--src/Scrollbar.c776
-rw-r--r--src/Simple.c302
-rw-r--r--src/SimpleMenu.c1288
-rw-r--r--src/Sme.c243
-rw-r--r--src/SmeBSB.c750
-rw-r--r--src/SmeLine.c288
-rw-r--r--src/StripChart.c514
-rw-r--r--src/Text.c3518
-rw-r--r--src/TextAction.c2259
-rw-r--r--src/TextPop.c1455
-rw-r--r--src/TextSink.c778
-rw-r--r--src/TextSrc.c678
-rw-r--r--src/TextTr.c129
-rw-r--r--src/Toggle.c615
-rw-r--r--src/Tree.c1007
-rw-r--r--src/Vendor.c460
-rw-r--r--src/Viewport.c1083
-rw-r--r--src/XawI18n.c87
-rw-r--r--src/XawI18n.h77
-rw-r--r--src/XawIm.c1693
-rw-r--r--src/XawInit.c48
-rw-r--r--src/sharedlib.c171
110 files changed, 40331 insertions, 0 deletions
diff --git a/include/X11/Xaw/AllWidgets.h b/include/X11/Xaw/AllWidgets.h
new file mode 100644
index 0000000..0200ac4
--- /dev/null
+++ b/include/X11/Xaw/AllWidgets.h
@@ -0,0 +1,38 @@
+/*
+ * $Xorg: AllWidgets.h,v 1.5 2001/02/09 02:03:42 xorgcvs Exp $
+ *
+Copyright 1990, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+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
+OPEN GROUP 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 Open Group 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 Open Group.
+ */
+
+#ifndef _XawAllWidgets_h
+#define _XawAllWidgets_h
+
+#include <X11/Xmu/WidgetNode.h>
+
+/*
+ * This file matches the generated AllWidgets.c
+ */
+extern XmuWidgetNode XawWidgetArray[];
+extern int XawWidgetCount;
+
+#endif /* _XawAllWidgets_h */
diff --git a/include/X11/Xaw/AsciiSink.h b/include/X11/Xaw/AsciiSink.h
new file mode 100644
index 0000000..d88288f
--- /dev/null
+++ b/include/X11/Xaw/AsciiSink.h
@@ -0,0 +1,90 @@
+/*
+ * $Xorg: AsciiSink.h,v 1.4 2001/02/09 02:03:42 xorgcvs Exp $
+ */
+
+/***********************************************************
+
+Copyright 1987, 1988, 1994, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+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
+OPEN GROUP 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 Open Group 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 Open Group.
+
+
+Copyright 1987, 1988 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+******************************************************************/
+
+#ifndef _XawAsciiSink_h
+#define _XawAsciiSink_h
+
+/***********************************************************************
+ *
+ * AsciiSink Object
+ *
+ ***********************************************************************/
+
+#include <X11/Xaw/TextSink.h>
+
+/* Resources:
+
+ Name Class RepType Default Value
+ ---- ----- ------- -------------
+ echo Output Boolean True
+ displayNonprinting Output Boolean True
+
+*/
+
+#define XtCOutput "Output"
+
+#define XtNdisplayNonprinting "displayNonprinting"
+#define XtNecho "echo"
+
+/* Class record constants */
+
+extern WidgetClass asciiSinkObjectClass;
+
+typedef struct _AsciiSinkClassRec *AsciiSinkObjectClass;
+typedef struct _AsciiSinkRec *AsciiSinkObject;
+
+/************************************************************
+ *
+ * Public Functions.
+ *
+ ************************************************************/
+
+#endif /* _XawAsciiSrc_h */
diff --git a/include/X11/Xaw/AsciiSinkP.h b/include/X11/Xaw/AsciiSinkP.h
new file mode 100644
index 0000000..02b9d39
--- /dev/null
+++ b/include/X11/Xaw/AsciiSinkP.h
@@ -0,0 +1,117 @@
+/*
+* $Xorg: AsciiSinkP.h,v 1.4 2001/02/09 02:03:42 xorgcvs Exp $
+*/
+
+
+/***********************************************************
+
+Copyright 1987, 1988, 1994, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+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
+OPEN GROUP 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 Open Group 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 Open Group.
+
+
+Copyright 1987, 1988 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+******************************************************************/
+
+/*
+ * asciiSinkP.h - Private definitions for asciiSink object
+ *
+ */
+
+#ifndef _XawAsciiSinkP_h
+#define _XawAsciiSinkP_h
+
+/***********************************************************************
+ *
+ * AsciiSink Object Private Data
+ *
+ ***********************************************************************/
+
+#include <X11/Xaw/TextSinkP.h>
+#include <X11/Xaw/AsciiSink.h>
+
+/************************************************************
+ *
+ * New fields for the AsciiSink object class record.
+ *
+ ************************************************************/
+
+typedef struct _AsciiSinkClassPart {
+ int foo;
+} AsciiSinkClassPart;
+
+/* Full class record declaration */
+
+typedef struct _AsciiSinkClassRec {
+ ObjectClassPart object_class;
+ TextSinkClassPart text_sink_class;
+ AsciiSinkClassPart ascii_sink_class;
+} AsciiSinkClassRec;
+
+extern AsciiSinkClassRec asciiSinkClassRec;
+
+/* New fields for the AsciiSink object record */
+typedef struct {
+ /* public resources */
+ XFontStruct *font; /* Font to draw in. */
+ Boolean echo;
+ Boolean display_nonprinting;
+
+ /* private state */
+ GC normgc, invgc, xorgc;
+ Pixmap insertCursorOn;
+ XawTextInsertState laststate;
+ short cursor_x, cursor_y; /* Cursor Location. */
+} AsciiSinkPart;
+
+/****************************************************************
+ *
+ * Full instance record declaration
+ *
+ ****************************************************************/
+
+typedef struct _AsciiSinkRec {
+ ObjectPart object;
+ TextSinkPart text_sink;
+ AsciiSinkPart ascii_sink;
+} AsciiSinkRec;
+
+#endif /* _XawAsciiSinkP_h */
+
diff --git a/include/X11/Xaw/AsciiSrc.h b/include/X11/Xaw/AsciiSrc.h
new file mode 100644
index 0000000..c174b01
--- /dev/null
+++ b/include/X11/Xaw/AsciiSrc.h
@@ -0,0 +1,161 @@
+/* $Xorg: AsciiSrc.h,v 1.4 2001/02/09 02:03:42 xorgcvs Exp $ */
+
+/*
+
+Copyright 1989, 1994, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+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
+OPEN GROUP 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 Open Group 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 Open Group.
+
+*/
+
+
+/*
+ * AsciiSrc.h - Public Header file for Ascii Text Source.
+ *
+ * This is the public header file for the Ascii Text Source.
+ * It is intended to be used with the Text widget, the simplest way to use
+ * this text source is to use the AsciiText Object.
+ *
+ * Date: June 29, 1989
+ *
+ * By: Chris D. Peterson
+ * MIT X Consortium
+ * kit@expo.lcs.mit.edu
+ */
+
+
+#ifndef _XawAsciiSrc_h
+#define _XawAsciiSrc_h
+
+#include <X11/Xaw/TextSrc.h>
+
+/* Resources:
+
+ Name Class RepType Default Value
+ ---- ----- ------- -------------
+ callback Callback Callback (none)
+ dataCompression DataCompression Boolean True
+ length Length int (internal)
+ pieceSize PieceSize int BUFSIZ
+ string String String NULL
+ type Type XawAsciiType XawAsciiString
+ useStringInPlace UseStringInPlace Boolean False
+
+*/
+
+/* Class record constants */
+
+extern WidgetClass asciiSrcObjectClass;
+
+typedef struct _AsciiSrcClassRec *AsciiSrcObjectClass;
+typedef struct _AsciiSrcRec *AsciiSrcObject;
+
+/*
+ * Just to make people's lives a bit easier.
+ */
+
+#define AsciiSourceObjectClass AsciiSrcObjectClass
+#define AsciiSourceObject AsciiSrcObject
+
+/*
+ * Resource Definitions.
+ */
+
+#define XtCDataCompression "DataCompression"
+#define XtCPieceSize "PieceSize"
+#define XtCType "Type"
+#define XtCUseStringInPlace "UseStringInPlace"
+
+#define XtNdataCompression "dataCompression"
+#define XtNpieceSize "pieceSize"
+#define XtNtype "type"
+#define XtNuseStringInPlace "useStringInPlace"
+
+#define XtRAsciiType "AsciiType"
+
+#define XtEstring "string"
+#define XtEfile "file"
+
+typedef enum {XawAsciiFile, XawAsciiString} XawAsciiType;
+
+/************************************************************
+ *
+ * Public routines
+ *
+ ************************************************************/
+
+_XFUNCPROTOBEGIN
+
+/* Function Name: XawAsciiSourceFreeString
+ * Description: Frees the string returned by a get values call
+ * on the string when the source is of type string.
+ * Arguments: w - the AsciiSrc object.
+ * Returns: none.
+ */
+
+extern void XawAsciiSourceFreeString(
+#if NeedFunctionPrototypes
+ Widget /* w */
+#endif
+);
+
+/* Function Name: XawAsciiSave
+ * Description: Saves all the pieces into a file or string as required.
+ * Arguments: w - the asciiSrc Object.
+ * Returns: TRUE if the save was successful.
+ */
+
+extern Boolean XawAsciiSave(
+#if NeedFunctionPrototypes
+ Widget /* w */
+#endif
+);
+
+/* Function Name: XawAsciiSaveAsFile
+ * Description: Save the current buffer as a file.
+ * Arguments: w - the asciiSrc object.
+ * name - name of the file to save this file into.
+ * Returns: True if the save was successful.
+ */
+
+extern Boolean XawAsciiSaveAsFile(
+#if NeedFunctionPrototypes
+ Widget /* w */,
+ _Xconst char* /* name */
+#endif
+);
+
+/* Function Name: XawAsciiSourceChanged
+ * Description: Returns true if the source has changed since last saved.
+ * Arguments: w - the asciiSource object.
+ * Returns: a Boolean (see description).
+ */
+
+extern Boolean XawAsciiSourceChanged(
+#if NeedFunctionPrototypes
+ Widget /* w */
+#endif
+);
+
+_XFUNCPROTOEND
+
+#endif /* _XawAsciiSrc_h */
+
diff --git a/include/X11/Xaw/AsciiSrcP.h b/include/X11/Xaw/AsciiSrcP.h
new file mode 100644
index 0000000..de69cf1
--- /dev/null
+++ b/include/X11/Xaw/AsciiSrcP.h
@@ -0,0 +1,166 @@
+/*
+* $Xorg: AsciiSrcP.h,v 1.4 2001/02/09 02:03:42 xorgcvs Exp $
+*/
+
+
+/***********************************************************
+
+Copyright 1987, 1988, 1994, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+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
+OPEN GROUP 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 Open Group 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 Open Group.
+
+
+Copyright 1987, 1988 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+******************************************************************/
+
+/*
+ * AsciiSrcP.h - Private Header for Ascii Text Source.
+ *
+ * This is the private header file for the Ascii Text Source.
+ * It is intended to be used with the Text widget, the simplest way to use
+ * this text source is to use the AsciiText Object.
+ *
+ * Date: June 29, 1989
+ *
+ * By: Chris D. Peterson
+ * MIT X Consortium
+ * kit@expo.lcs.mit.edu
+ */
+
+/*
+ * TextSrcP.h - Private definitions for AsciiSrc object
+ *
+ */
+
+#ifndef _XawAsciiSrcP_h
+#define _XawAsciiSrcP_h
+
+#include <X11/Xaw/TextSrcP.h>
+#include <X11/Xaw/AsciiSrc.h>
+
+/************************************************************
+ *
+ * Private declarations.
+ *
+ ************************************************************/
+
+#ifdef L_tmpnam
+#define TMPSIZ L_tmpnam
+#else
+#ifdef PATH_MAX
+#define TMPSIZ PATH_MAX
+#else
+#define TMPSIZ 1024 /* bytes to allocate for tmpnam */
+#endif
+#endif
+
+#define MAGIC_VALUE ((XawTextPosition) -1) /* Magic value. */
+
+#define streq(a, b) ( strcmp((a), (b)) == 0 )
+
+typedef struct _Piece { /* Piece of the text file of BUFSIZ allocated
+ characters. */
+ char * text; /* The text in this buffer. */
+ XawTextPosition used; /* The number of characters of this buffer
+ that have been used. */
+ struct _Piece *prev, *next; /* linked list pointers. */
+} Piece;
+
+/************************************************************
+ *
+ * New fields for the AsciiSrc object class record.
+ *
+ ************************************************************/
+
+typedef struct _AsciiSrcClassPart { char foo; } AsciiSrcClassPart;
+
+/* Full class record declaration */
+typedef struct _AsciiSrcClassRec {
+ ObjectClassPart object_class;
+ TextSrcClassPart text_src_class;
+ AsciiSrcClassPart ascii_src_class;
+} AsciiSrcClassRec;
+
+extern AsciiSrcClassRec asciiSrcClassRec;
+
+/* New fields for the AsciiSrc object record */
+
+typedef struct _AsciiSrcPart {
+
+ /* Resources. */
+
+ char *string; /* either the string, or the
+ file name, depending upon the type. */
+ XawAsciiType type; /* either string or disk. */
+ XawTextPosition piece_size; /* Size of text buffer for each piece. */
+ Boolean data_compression; /* compress to minimum memory automatically
+ on save? */
+ XtCallbackList callback; /* A callback list to call when the source is
+ changed. */
+ Boolean use_string_in_place; /* Use the string passed in place. */
+ int ascii_length; /* length field for ascii string emulation. */
+
+#ifdef ASCII_DISK
+ String filename; /* name of file for Compatability. */
+#endif /* ASCII_DISK */
+
+/* Private data. */
+
+ Boolean is_tempfile; /* Is this a temporary file? */
+ Boolean changes; /* Has this file been edited? */
+ Boolean allocated_string; /* Have I allocated the
+ string in ascii_src->string? */
+ XawTextPosition length; /* length of file */
+ Piece * first_piece; /* first piece of the text. */
+} AsciiSrcPart;
+
+/****************************************************************
+ *
+ * Full instance record declaration
+ *
+ ****************************************************************/
+
+typedef struct _AsciiSrcRec {
+ ObjectPart object;
+ TextSrcPart text_src;
+ AsciiSrcPart ascii_src;
+} AsciiSrcRec;
+
+#endif /* _XawAsciiSrcP_h */
diff --git a/include/X11/Xaw/AsciiText.h b/include/X11/Xaw/AsciiText.h
new file mode 100644
index 0000000..6f60c27
--- /dev/null
+++ b/include/X11/Xaw/AsciiText.h
@@ -0,0 +1,147 @@
+/*
+ * $Xorg: AsciiText.h,v 1.4 2001/02/09 02:03:42 xorgcvs Exp $
+ */
+
+/***********************************************************
+
+Copyright 1987, 1988, 1994, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+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
+OPEN GROUP 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 Open Group 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 Open Group.
+
+
+Copyright 1987, 1988 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+******************************************************************/
+
+/***********************************************************************
+ *
+ * AsciiText Widget
+ *
+ ***********************************************************************/
+
+/*
+ * AsciiText.c - Public header file for AsciiText Widget.
+ *
+ * This Widget is intended to be used as a simple front end to the
+ * text widget with an ascii source and ascii sink attached to it.
+ *
+ * Date: June 29, 1989
+ *
+ * By: Chris D. Peterson
+ * MIT X Consortium
+ * kit@expo.lcs.mit.edu
+ */
+
+#ifndef _AsciiText_h
+#define _AsciiText_h
+
+/****************************************************************
+ *
+ * AsciiText widgets
+ *
+ ****************************************************************/
+
+#include <X11/Xaw/Text.h> /* AsciiText is a subclass of Text */
+#include <X11/Xaw/AsciiSrc.h>
+#include <X11/Xaw/MultiSrc.h>
+
+/* Resources:
+
+ Name Class RepType Default Value
+ ---- ----- ------- -------------
+ autoFill AutoFill Boolean False
+ background Background Pixel XtDefaultBackground
+ border BorderColor Pixel XtDefaultForeground
+ borderWidth BorderWidth Dimension 1
+ bottomMargin Margin Position 2
+ cursor Cursor Cursor xterm
+ destroyCallback Callback Pointer NULL
+ displayCaret Output Boolean True
+ displayPosition TextPosition int 0
+ editType EditType XawTextEditType XawtextRead
+ font Font XFontStruct* Fixed
+ foreground Foreground Pixel Black
+ height Height Dimension font height
+ insertPosition TextPosition int 0
+ international International Boolean false
+ leftMargin Margin Position 2
+ mappedWhenManaged MappedWhenManaged Boolean True
+ resize Resize XawTextResizeMode XawtextResizeNever
+ rightMargin Margin Position 4
+ scrollHorizontal Scroll XawTextScrollMode XawtextScrollNever
+ scrollVertical Scroll XawTextScrollMode XawtextScrollNever
+ selectTypes SelectTypes Pointer pos/word/line/par/all
+ selection Selection Pointer (empty selection)
+ sensitive Sensitive Boolean True
+ sink TextSink Widget (none)
+ source TextSource Widget (none)
+ string String String NULL
+ topMargin Margin Position 2
+ width Width Dimension 100
+ wrap Wrap XawTextWrapMode XawtextWrapNever
+ x Position Position 0
+ y Position Position 0
+
+ (see also *Src.h and *Sink.h)
+*/
+
+/*
+ * Everything else we need is in StringDefs.h or Text.h
+ */
+
+typedef struct _AsciiTextClassRec *AsciiTextWidgetClass;
+typedef struct _AsciiRec *AsciiWidget;
+
+extern WidgetClass asciiTextWidgetClass;
+
+/************************************************************
+ *
+ * Disk and String Emulation Info.
+ *
+ ************************************************************/
+
+#ifdef ASCII_STRING
+extern WidgetClass asciiStringWidgetClass;
+#endif
+
+#ifdef ASCII_DISK
+extern WidgetClass asciiDiskWidgetClass;
+#endif
+
+#endif /* _AsciiText_h */
diff --git a/include/X11/Xaw/AsciiTextP.h b/include/X11/Xaw/AsciiTextP.h
new file mode 100644
index 0000000..a525d67
--- /dev/null
+++ b/include/X11/Xaw/AsciiTextP.h
@@ -0,0 +1,162 @@
+/*
+ * $Xorg: AsciiTextP.h,v 1.4 2001/02/09 02:03:42 xorgcvs Exp $
+ */
+
+/***********************************************************
+
+Copyright 1987, 1988, 1994, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+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
+OPEN GROUP 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 Open Group 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 Open Group.
+
+
+Copyright 1987, 1988 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+******************************************************************/
+
+/***********************************************************************
+ *
+ * AsciiText Widget
+ *
+ ***********************************************************************/
+
+/*
+ * AsciiText.c - Private header file for AsciiText Widget.
+ *
+ * This Widget is intended to be used as a simple front end to the
+ * text widget with an ascii source and ascii sink attached to it.
+ *
+ * Date: June 29, 1989
+ *
+ * By: Chris D. Peterson
+ * MIT X Consortium
+ * kit@expo.lcs.mit.edu
+ */
+
+#ifndef _AsciiTextP_h
+#define _AsciiTextP_h
+
+#include <X11/Xaw/TextP.h>
+#include <X11/Xaw/AsciiText.h>
+#include <X11/Xaw/AsciiSrc.h>
+#include <X11/Xaw/MultiSrc.h>
+
+typedef struct {int empty;} AsciiClassPart;
+
+typedef struct _AsciiTextClassRec {
+ CoreClassPart core_class;
+ SimpleClassPart simple_class;
+ TextClassPart text_class;
+ AsciiClassPart ascii_class;
+} AsciiTextClassRec;
+
+extern AsciiTextClassRec asciiTextClassRec;
+
+typedef struct { char foo; /* keep compiler happy. */ } AsciiPart;
+
+typedef struct _AsciiRec {
+ CorePart core;
+ SimplePart simple;
+ TextPart text;
+ AsciiPart ascii;
+} AsciiRec;
+
+/************************************************************
+ *
+ * Ascii String Emulation widget.
+ *
+ ************************************************************/
+
+#ifdef ASCII_STRING
+
+typedef struct {int empty;} AsciiStringClassPart;
+
+typedef struct _AsciiStringClassRec {
+ CoreClassPart core_class;
+ SimpleClassPart simple_class;
+ TextClassPart text_class;
+ AsciiClassPart ascii_class;
+ AsciiStringClassPart string_class;
+} AsciiStringClassRec;
+
+extern AsciiStringClassRec asciiStringClassRec;
+
+typedef struct { char foo; /* keep compiler happy. */ } AsciiStringPart;
+
+typedef struct _AsciiStringRec {
+ CorePart core;
+ SimplePart simple;
+ TextPart text;
+ AsciiPart ascii;
+ AsciiStringPart ascii_str;
+} AsciiStringRec;
+
+#endif /* ASCII_STRING */
+
+#ifdef ASCII_DISK
+
+/************************************************************
+ *
+ * Ascii Disk Emulation widget.
+ *
+ ************************************************************/
+
+typedef struct {int empty;} AsciiDiskClassPart;
+
+typedef struct _AsciiDiskClassRec {
+ CoreClassPart core_class;
+ SimpleClassPart simple_class;
+ TextClassPart text_class;
+ AsciiClassPart ascii_class;
+ AsciiDiskClassPart disk_class;
+} AsciiDiskClassRec;
+
+extern AsciiDiskClassRec asciiDiskClassRec;
+
+typedef struct { char foo; /* keep compiler happy. */ } AsciiDiskPart;
+
+typedef struct _AsciiDiskRec {
+ CorePart core;
+ SimplePart simple;
+ TextPart text;
+ AsciiPart ascii;
+ AsciiDiskPart ascii_disk;
+} AsciiDiskRec;
+#endif /* ASCII_DISK */
+
+#endif /* _AsciiTextP_h */
diff --git a/include/X11/Xaw/Box.h b/include/X11/Xaw/Box.h
new file mode 100644
index 0000000..d265feb
--- /dev/null
+++ b/include/X11/Xaw/Box.h
@@ -0,0 +1,97 @@
+/*
+* $Xorg: Box.h,v 1.4 2001/02/09 02:03:43 xorgcvs Exp $
+*/
+
+
+/***********************************************************
+
+Copyright 1987, 1988, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+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
+OPEN GROUP 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 Open Group 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 Open Group.
+
+
+Copyright 1987, 1988 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+******************************************************************/
+
+#ifndef _XawBox_h
+#define _XawBox_h
+
+#include <X11/Xmu/Converters.h>
+
+/***********************************************************************
+ *
+ * Box Widget (subclass of CompositeClass)
+ *
+ ***********************************************************************/
+
+/* Parameters:
+
+ Name Class RepType Default Value
+ ---- ----- ------- -------------
+ background Background Pixel XtDefaultBackground
+ border BorderColor Pixel XtDefaultForeground
+ borderWidth BorderWidth Dimension 1
+ destroyCallback Callback Pointer NULL
+ hSpace HSpace Dimension 4
+ height Height Dimension 0
+ mappedWhenManaged MappedWhenManaged Boolean True
+ orientation Orientation XtOrientation vertical
+ vSpace VSpace Dimension 4
+ width Width Dimension 0
+ x Position Position 0
+ y Position Position 0
+
+*/
+
+
+/* New fields */
+#ifndef _XtStringDefs_h_
+#define XtNhSpace "hSpace"
+#define XtNvSpace "vSpace"
+#endif
+
+/* Class record constants */
+
+extern WidgetClass boxWidgetClass;
+
+typedef struct _BoxClassRec *BoxWidgetClass;
+typedef struct _BoxRec *BoxWidget;
+
+#endif /* _XawBox_h */
diff --git a/include/X11/Xaw/BoxP.h b/include/X11/Xaw/BoxP.h
new file mode 100644
index 0000000..ecd7b35
--- /dev/null
+++ b/include/X11/Xaw/BoxP.h
@@ -0,0 +1,107 @@
+/*
+* $Xorg: BoxP.h,v 1.4 2001/02/09 02:03:43 xorgcvs Exp $
+*/
+
+
+/***********************************************************
+
+Copyright 1987, 1988, 1994, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+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
+OPEN GROUP 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 Open Group 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 Open Group.
+
+
+Copyright 1987, 1988 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+******************************************************************/
+
+/*
+ * BoxP.h - Private definitions for Box widget
+ *
+ */
+
+#ifndef _XawBoxP_h
+#define _XawBoxP_h
+
+/***********************************************************************
+ *
+ * Box Widget Private Data
+ *
+ ***********************************************************************/
+
+#include <X11/Xaw/Box.h>
+#include <X11/Xmu/Converters.h>
+
+/* New fields for the Box widget class record */
+typedef struct {int empty;} BoxClassPart;
+
+/* Full class record declaration */
+typedef struct _BoxClassRec {
+ CoreClassPart core_class;
+ CompositeClassPart composite_class;
+ BoxClassPart box_class;
+} BoxClassRec;
+
+extern BoxClassRec boxClassRec;
+
+/* New fields for the Box widget record */
+typedef struct {
+ /* resources */
+ Dimension h_space, v_space;
+ XtOrientation orientation;
+
+ /* private state */
+ Dimension preferred_width, preferred_height;
+ Dimension last_query_width, last_query_height;
+ XtGeometryMask last_query_mode;
+} BoxPart;
+
+
+/****************************************************************
+ *
+ * Full instance record declaration
+ *
+ ****************************************************************/
+
+typedef struct _BoxRec {
+ CorePart core;
+ CompositePart composite;
+ BoxPart box;
+} BoxRec;
+
+#endif /* _XawBoxP_h */
diff --git a/include/X11/Xaw/Cardinals.h b/include/X11/Xaw/Cardinals.h
new file mode 100644
index 0000000..a8b3dfc
--- /dev/null
+++ b/include/X11/Xaw/Cardinals.h
@@ -0,0 +1,43 @@
+/* $Xorg: Cardinals.h,v 1.4 2001/02/09 02:03:43 xorgcvs Exp $ */
+/*
+
+Copyright 1985, 1986, 1987, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+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
+OPEN GROUP 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 Open Group 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 Open Group.
+
+*/
+
+#ifndef _Cardinals_h
+#define _Cardinals_h
+
+#define ZERO ((Cardinal)0)
+#define ONE ((Cardinal)1)
+#define TWO ((Cardinal)2)
+#define THREE ((Cardinal)3)
+#define FOUR ((Cardinal)4)
+#define FIVE ((Cardinal)5)
+#define SIX ((Cardinal)6)
+#define SEVEN ((Cardinal)7)
+#define EIGHT ((Cardinal)8)
+#define NINE ((Cardinal)9)
+#define TEN ((Cardinal)10)
+
+#endif /* _Cardinals_h */
diff --git a/include/X11/Xaw/Command.h b/include/X11/Xaw/Command.h
new file mode 100644
index 0000000..a9738d2
--- /dev/null
+++ b/include/X11/Xaw/Command.h
@@ -0,0 +1,117 @@
+/* $Xorg: Command.h,v 1.4 2001/02/09 02:03:43 xorgcvs Exp $ */
+
+/***********************************************************
+
+Copyright 1987, 1988, 1994, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+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
+OPEN GROUP 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 Open Group 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 Open Group.
+
+
+Copyright 1987, 1988 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+******************************************************************/
+
+#ifndef _XawCommand_h
+#define _XawCommand_h
+
+#include <X11/Xaw/Label.h>
+
+/* Command widget resources:
+
+ Name Class RepType Default Value
+ ---- ----- ------- -------------
+ accelerators Accelerators AcceleratorTable NULL
+ ancestorSensitive AncestorSensitive Boolean True
+ background Background Pixel XtDefaultBackground
+ backgroundPixmap Pixmap Pixmap XtUnspecifiedPixmap
+ bitmap Pixmap Pixmap None
+ borderColor BorderColor Pixel XtDefaultForeground
+ borderPixmap Pixmap Pixmap XtUnspecifiedPixmap
+ borderWidth BorderWidth Dimension 1
+ callback Callback XtCallbackList NULL
+ colormap Colormap Colormap parent's colormap
+ cornerRoundPercent CornerRoundPercent Dimension 25
+ cursor Cursor Cursor None
+ cursorName Cursor String NULL
+ depth Depth int parent's depth
+ destroyCallback Callback XtCallbackList NULL
+ encoding Encoding UnsignedChar XawTextEncoding8bit
+ font Font XFontStruct* XtDefaultFont
+ foreground Foreground Pixel XtDefaultForeground
+ height Height Dimension text height
+ highlightThickness Thickness Dimension 0 if shaped, else 2
+ insensitiveBorder Insensitive Pixmap Gray
+ internalHeight Height Dimension 2
+ internalWidth Width Dimension 4
+ justify Justify XtJustify XtJustifyCenter
+ label Label String NULL
+ leftBitmap LeftBitmap Pixmap None
+ mappedWhenManaged MappedWhenManaged Boolean True
+ pointerColor Foreground Pixel XtDefaultForeground
+ pointerColorBackground Background Pixel XtDefaultBackground
+ resize Resize Boolean True
+ screen Screen Screen parent's Screen
+ sensitive Sensitive Boolean True
+ shapeStyle ShapeStyle ShapeStyle Rectangle
+ translations Translations TranslationTable see doc or source
+ width Width Dimension text width
+ x Position Position 0
+ y Position Position 0
+
+*/
+
+#define XtNhighlightThickness "highlightThickness"
+
+#define XtNshapeStyle "shapeStyle"
+#define XtCShapeStyle "ShapeStyle"
+#define XtRShapeStyle "ShapeStyle"
+#define XtNcornerRoundPercent "cornerRoundPercent"
+#define XtCCornerRoundPercent "CornerRoundPercent"
+
+#define XawShapeRectangle XmuShapeRectangle
+#define XawShapeOval XmuShapeOval
+#define XawShapeEllipse XmuShapeEllipse
+#define XawShapeRoundedRectangle XmuShapeRoundedRectangle
+
+extern WidgetClass commandWidgetClass;
+
+typedef struct _CommandClassRec *CommandWidgetClass;
+typedef struct _CommandRec *CommandWidget;
+
+#endif /* _XawCommand_h */
diff --git a/include/X11/Xaw/CommandP.h b/include/X11/Xaw/CommandP.h
new file mode 100644
index 0000000..4c4db90
--- /dev/null
+++ b/include/X11/Xaw/CommandP.h
@@ -0,0 +1,139 @@
+/*
+* $Xorg: CommandP.h,v 1.4 2001/02/09 02:03:43 xorgcvs Exp $
+*/
+
+
+/***********************************************************
+
+Copyright 1987, 1988, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+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
+OPEN GROUP 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 Open Group 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 Open Group.
+
+
+Copyright 1987, 1988 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+******************************************************************/
+
+/*
+ * CommandP.h - Private definitions for Command widget
+ *
+ */
+
+#ifndef _XawCommandP_h
+#define _XawCommandP_h
+
+#include <X11/Xaw/Command.h>
+#include <X11/Xaw/LabelP.h>
+
+/***********************************************************************
+ *
+ * Command Widget Private Data
+ *
+ ***********************************************************************/
+
+typedef enum {
+ HighlightNone, /* Do not highlight. */
+ HighlightWhenUnset, /* Highlight only when unset, this is
+ to preserve current command widget
+ functionality. */
+ HighlightAlways /* Always highlight, lets the toggle widget
+ and other subclasses do the right thing. */
+} XtCommandHighlight;
+
+/************************************
+ *
+ * Class structure
+ *
+ ***********************************/
+
+
+ /* New fields for the Command widget class record */
+typedef struct _CommandClass
+ {
+ int makes_compiler_happy; /* not used */
+ } CommandClassPart;
+
+ /* Full class record declaration */
+typedef struct _CommandClassRec {
+ CoreClassPart core_class;
+ SimpleClassPart simple_class;
+ LabelClassPart label_class;
+ CommandClassPart command_class;
+} CommandClassRec;
+
+extern CommandClassRec commandClassRec;
+
+/***************************************
+ *
+ * Instance (widget) structure
+ *
+ **************************************/
+
+ /* New fields for the Command widget record */
+typedef struct {
+ /* resources */
+ Dimension highlight_thickness;
+ XtCallbackList callbacks;
+
+ /* private state */
+ Pixmap gray_pixmap;
+ GC normal_GC;
+ GC inverse_GC;
+ Boolean set;
+ XtCommandHighlight highlighted;
+ /* more resources */
+ int shape_style;
+ Dimension corner_round;
+} CommandPart;
+
+
+/* XtEventsPtr eventTable;*/
+
+
+ /* Full widget declaration */
+typedef struct _CommandRec {
+ CorePart core;
+ SimplePart simple;
+ LabelPart label;
+ CommandPart command;
+} CommandRec;
+
+#endif /* _XawCommandP_h */
+
+
diff --git a/include/X11/Xaw/Dialog.h b/include/X11/Xaw/Dialog.h
new file mode 100644
index 0000000..2000702
--- /dev/null
+++ b/include/X11/Xaw/Dialog.h
@@ -0,0 +1,108 @@
+/* $Xorg: Dialog.h,v 1.4 2001/02/09 02:03:43 xorgcvs Exp $ */
+
+/***********************************************************
+
+Copyright 1987, 1988, 1994, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+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
+OPEN GROUP 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 Open Group 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 Open Group.
+
+
+Copyright 1987, 1988 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+******************************************************************/
+
+#ifndef _XawDialog_h
+#define _XawDialog_h
+
+#include <X11/Xaw/Form.h>
+
+/***********************************************************************
+ *
+ * Dialog Widget
+ *
+ ***********************************************************************/
+
+/* Parameters:
+
+ Name Class RepType Default Value
+ ---- ----- ------- -------------
+ background Background Pixel XtDefaultBackground
+ border BorderColor Pixel XtDefaultForeground
+ borderWidth BorderWidth Dimension 1
+ destroyCallback Callback Pointer NULL
+ height Height Dimension computed at create
+ icon Icon Pixmap 0
+ label Label String NULL
+ mappedWhenManaged MappedWhenManaged Boolean True
+ sensitive Sensitive Boolean True
+ value Value String NULL
+ width Width Dimension computed at create
+ x Position Position 0
+ y Position Position 0
+
+*/
+
+#define XtCIcon "Icon"
+#define XtNicon "icon"
+
+typedef struct _DialogClassRec *DialogWidgetClass;
+typedef struct _DialogRec *DialogWidget;
+
+extern WidgetClass dialogWidgetClass;
+
+_XFUNCPROTOBEGIN
+
+extern void XawDialogAddButton(
+#if NeedFunctionPrototypes
+ Widget /* dialog */,
+ _Xconst char* /* name */,
+ XtCallbackProc /* function */,
+ XtPointer /* client_data */
+#endif
+);
+
+extern char *XawDialogGetValueString(
+#if NeedFunctionPrototypes
+ Widget /* w */
+#endif
+);
+
+_XFUNCPROTOEND
+
+#endif /* _XawDialog_h */
diff --git a/include/X11/Xaw/DialogP.h b/include/X11/Xaw/DialogP.h
new file mode 100644
index 0000000..e230f90
--- /dev/null
+++ b/include/X11/Xaw/DialogP.h
@@ -0,0 +1,97 @@
+/* $Xorg: DialogP.h,v 1.4 2001/02/09 02:03:43 xorgcvs Exp $ */
+
+
+/***********************************************************
+
+Copyright 1987, 1988, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+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
+OPEN GROUP 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 Open Group 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 Open Group.
+
+
+Copyright 1987, 1988 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+******************************************************************/
+
+/* Private definitions for Dialog widget */
+
+#ifndef _DialogP_h
+#define _DialogP_h
+
+#include <X11/Xaw/Dialog.h>
+#include <X11/Xaw/FormP.h>
+
+typedef struct {int empty;} DialogClassPart;
+
+typedef struct _DialogClassRec {
+ CoreClassPart core_class;
+ CompositeClassPart composite_class;
+ ConstraintClassPart constraint_class;
+ FormClassPart form_class;
+ DialogClassPart dialog_class;
+} DialogClassRec;
+
+extern DialogClassRec dialogClassRec;
+
+typedef struct _DialogPart {
+ /* resources */
+ String label; /* description of the dialog */
+ String value; /* for the user response */
+ Pixmap icon; /* icon bitmap */
+ /* private data */
+ Widget iconW; /* widget to display the icon */
+ Widget labelW; /* widget to display description*/
+ Widget valueW; /* user response TextWidget */
+} DialogPart;
+
+typedef struct _DialogRec {
+ CorePart core;
+ CompositePart composite;
+ ConstraintPart constraint;
+ FormPart form;
+ DialogPart dialog;
+} DialogRec;
+
+typedef struct {int empty;} DialogConstraintsPart;
+
+typedef struct _DialogConstraintsRec {
+ FormConstraintsPart form;
+ DialogConstraintsPart dialog;
+} DialogConstraintsRec, *DialogConstraints;
+
+#endif /* _DialogP_h */
diff --git a/include/X11/Xaw/Form.h b/include/X11/Xaw/Form.h
new file mode 100644
index 0000000..d12ed0b
--- /dev/null
+++ b/include/X11/Xaw/Form.h
@@ -0,0 +1,167 @@
+/* $Xorg: Form.h,v 1.5 2001/02/09 02:03:43 xorgcvs Exp $ */
+
+
+/***********************************************************
+
+Copyright 1987, 1988, 1994, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+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
+OPEN GROUP 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 Open Group 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 Open Group.
+
+
+Copyright 1987, 1988 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+******************************************************************/
+
+#ifndef _XawForm_h
+#define _XawForm_h
+
+#include <X11/Intrinsic.h>
+
+/***********************************************************************
+ *
+ * Form Widget
+ *
+ ***********************************************************************/
+
+/* Parameters:
+
+ Name Class RepType Default Value
+ ---- ----- ------- -------------
+ background Background Pixel XtDefaultBackground
+ border BorderColor Pixel XtDefaultForeground
+ borderWidth BorderWidth Dimension 1
+ defaultDistance Thickness int 4
+ destroyCallback Callback Pointer NULL
+ height Height Dimension computed at realize
+ mappedWhenManaged MappedWhenManaged Boolean True
+ sensitive Sensitive Boolean True
+ width Width Dimension computed at realize
+ x Position Position 0
+ y Position Position 0
+
+*/
+
+/* Constraint parameters:
+
+ Name Class RepType Default Value
+ ---- ----- ------- -------------
+ bottom Edge XtEdgeType XtRubber
+ fromHoriz Widget Widget (left edge of form)
+ fromVert Widget Widget (top of form)
+ horizDistance Thickness int defaultDistance
+ left Edge XtEdgeType XtRubber
+ resizable Boolean Boolean False
+ right Edge XtEdgeType XtRubber
+ top Edge XtEdgeType XtRubber
+ vertDistance Thickness int defaultDistance
+
+*/
+
+
+#ifndef _XtStringDefs_h_
+#define XtNtop "top"
+#define XtRWidget "Widget"
+#endif
+
+#define XtNdefaultDistance "defaultDistance"
+#define XtNbottom "bottom"
+#define XtNleft "left"
+#define XtNright "right"
+#define XtNfromHoriz "fromHoriz"
+#define XtNfromVert "fromVert"
+#define XtNhorizDistance "horizDistance"
+#define XtNvertDistance "vertDistance"
+#define XtNresizable "resizable"
+
+#define XtCEdge "Edge"
+#define XtCWidget "Widget"
+
+#ifndef _XawEdgeType_e
+#define _XawEdgeType_e
+typedef enum {
+ XawChainTop, /* Keep this edge a constant distance from
+ the top of the form */
+ XawChainBottom, /* Keep this edge a constant distance from
+ the bottom of the form */
+ XawChainLeft, /* Keep this edge a constant distance from
+ the left of the form */
+ XawChainRight, /* Keep this edge a constant distance from
+ the right of the form */
+ XawRubber /* Keep this edge a proportional distance
+ from the edges of the form*/
+} XawEdgeType;
+#endif /* _XawEdgeType_e */
+
+/*
+ * Unfortunatly I missed this definition for R4, so I cannot
+ * protect it with XAW_BC, it looks like this particular problem is
+ * one that we will have to live with for a while.
+ *
+ * Chris D. Peterson - 3/23/90.
+ */
+
+#define XtEdgeType XawEdgeType
+
+#define XtChainTop XawChainTop
+#define XtChainBottom XawChainBottom
+#define XtChainLeft XawChainLeft
+#define XtChainRight XawChainRight
+#define XtRubber XawRubber
+
+typedef struct _FormClassRec *FormWidgetClass;
+typedef struct _FormRec *FormWidget;
+
+extern WidgetClass formWidgetClass;
+
+_XFUNCPROTOBEGIN
+
+extern void XawFormDoLayout(
+#if NeedFunctionPrototypes
+ Widget /* w */,
+#if NeedWidePrototypes
+ /* Boolean */ int /* do_layout */
+#else
+ Boolean /* do_layout */
+#endif
+#endif
+);
+
+_XFUNCPROTOEND
+
+#endif /* _XawForm_h */
diff --git a/include/X11/Xaw/FormP.h b/include/X11/Xaw/FormP.h
new file mode 100644
index 0000000..b2456c0
--- /dev/null
+++ b/include/X11/Xaw/FormP.h
@@ -0,0 +1,142 @@
+/* $Xorg: FormP.h,v 1.4 2001/02/09 02:03:43 xorgcvs Exp $ */
+
+/***********************************************************
+
+Copyright 1987, 1988, 1994, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+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
+OPEN GROUP 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 Open Group 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 Open Group.
+
+
+Copyright 1987, 1988 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+******************************************************************/
+
+/* Form widget private definitions */
+
+#ifndef _XawFormP_h
+#define _XawFormP_h
+
+#include <X11/Xaw/Form.h>
+
+#define XtREdgeType "EdgeType"
+
+typedef enum {LayoutPending, LayoutInProgress, LayoutDone} LayoutState;
+#define XtInheritLayout ((Boolean (*)())_XtInherit)
+
+typedef struct {
+ Boolean (*layout)(/* FormWidget, Dimension, Dimension */);
+} FormClassPart;
+
+/*
+ * Layout(
+ * FormWidget w - the widget whose children are to be configured
+ * Dimension w, h - bounding box of layout to be calculated
+ *
+ * Stores preferred geometry in w->form.preferred_{width,height}.
+ * If w->form.resize_in_layout is True, then a geometry request
+ * may be made for the preferred bounding box if necessary.
+ *
+ * Returns True if a geometry request was granted, False otherwise.
+ */
+
+typedef struct _FormClassRec {
+ CoreClassPart core_class;
+ CompositeClassPart composite_class;
+ ConstraintClassPart constraint_class;
+ FormClassPart form_class;
+} FormClassRec;
+
+extern FormClassRec formClassRec;
+
+typedef struct _FormPart {
+ /* resources */
+ int default_spacing; /* default distance between children */
+ /* private state */
+ Dimension old_width, old_height; /* last known dimensions */
+ int no_refigure; /* no re-layout while > 0 */
+ Boolean needs_relayout; /* next time no_refigure == 0 */
+ Boolean resize_in_layout; /* should layout() do geom request? */
+ Dimension preferred_width, preferred_height; /* cached from layout */
+ Boolean resize_is_no_op; /* Causes resize to take not action. */
+} FormPart;
+
+typedef struct _FormRec {
+ CorePart core;
+ CompositePart composite;
+ ConstraintPart constraint;
+ FormPart form;
+} FormRec;
+
+typedef struct _FormConstraintsPart {
+/*
+ * Constraint Resources.
+ */
+ XtEdgeType top, bottom, /* where to drag edge on resize */
+ left, right;
+ int dx; /* desired horiz offset */
+ int dy; /* desired vertical offset */
+ Widget horiz_base; /* measure dx from here if non-null */
+ Widget vert_base; /* measure dy from here if non-null */
+ Boolean allow_resize; /* TRUE if child may request resize */
+
+/*
+ * Private contstraint resources.
+ */
+
+/*
+ * What the size of this child would be if we did not impose the
+ * constraint the width and height must be greater than zero (0).
+ */
+ short virtual_width, virtual_height;
+
+/*
+ * Temporary Storage for children's new possible possition.
+ */
+
+ Position new_x, new_y;
+
+ LayoutState layout_state; /* temporary layout state */
+ Boolean deferred_resize; /* was resized while no_refigure is set */
+} FormConstraintsPart;
+
+typedef struct _FormConstraintsRec {
+ FormConstraintsPart form;
+} FormConstraintsRec, *FormConstraints;
+
+#endif /* _XawFormP_h */
diff --git a/include/X11/Xaw/Grip.h b/include/X11/Xaw/Grip.h
new file mode 100644
index 0000000..fdf751f
--- /dev/null
+++ b/include/X11/Xaw/Grip.h
@@ -0,0 +1,104 @@
+/* $Xorg: Grip.h,v 1.4 2001/02/09 02:03:43 xorgcvs Exp $ */
+
+/***********************************************************
+
+Copyright 1987, 1988, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+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
+OPEN GROUP 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 Open Group 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 Open Group.
+
+
+Copyright 1987, 1988 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+******************************************************************/
+
+/*
+ * Grip.h - Public Definitions for Grip widget (used by VPane Widget)
+ *
+ */
+
+#ifndef _XawGrip_h
+#define _XawGrip_h
+
+#include <X11/Xaw/Simple.h>
+
+/***************************************************************************
+ *
+ * Grip Widget
+ *
+ **************************************************************************/
+
+/* Parameters:
+
+ Name Class RepType Default Value
+ ---- ----- ------- -------------
+ foreground Foreground Pixel XtDefaultForeground
+ border BorderColor Pixel XtDefaultForeground
+ borderWidth BorderWidth Dimension 0
+ callback Callback Pointer GripAction
+ cursor Cursor Cursor None
+ cursorName Cursor String NULL
+ destroyCallback Callback Pointer NULL
+ height Height Dimension 8
+ mappedWhenManaged MappedWhenManaged Boolean True
+ pointerColor Foreground Pixel XtDefaultForeground
+ pointerColorBackground Background Pixel XtDefaultBackground
+ sensitive Sensitive Boolean True
+ width Width Dimension 8
+ x Position Position 0
+ y Position Position 0
+
+*/
+
+#define XtNgripTranslations "gripTranslations"
+
+typedef struct _XawGripCallData {
+ XEvent *event; /* the event causing the GripAction */
+ String *params; /* the TranslationTable params */
+ Cardinal num_params; /* count of params */
+} XawGripCallDataRec, *XawGripCallData,
+ GripCallDataRec, *GripCallData; /* supported for R4 compatibility */
+
+/* Class Record Constant */
+
+extern WidgetClass gripWidgetClass;
+
+typedef struct _GripClassRec *GripWidgetClass;
+typedef struct _GripRec *GripWidget;
+
+#endif /* _XawGrip_h */
diff --git a/include/X11/Xaw/GripP.h b/include/X11/Xaw/GripP.h
new file mode 100644
index 0000000..4e89917
--- /dev/null
+++ b/include/X11/Xaw/GripP.h
@@ -0,0 +1,102 @@
+/*
+* $Xorg: GripP.h,v 1.4 2001/02/09 02:03:43 xorgcvs Exp $
+*/
+
+
+/***********************************************************
+
+Copyright 1987, 1988, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+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
+OPEN GROUP 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 Open Group 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 Open Group.
+
+
+Copyright 1987, 1988 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+******************************************************************/
+
+/*
+ * GripP.h - Private definitions for Grip widget (Used by VPane Widget)
+ *
+ */
+
+#ifndef _XawGripP_h
+#define _XawGripP_h
+
+#include <X11/Xaw/Grip.h>
+#include <X11/Xaw/SimpleP.h>
+
+/*****************************************************************************
+ *
+ * Grip Widget Private Data
+ *
+ *****************************************************************************/
+
+#define DEFAULT_GRIP_SIZE 8
+
+/* New fields for the Grip widget class record */
+typedef struct {int empty;} GripClassPart;
+
+/* Full Class record declaration */
+typedef struct _GripClassRec {
+ CoreClassPart core_class;
+ SimpleClassPart simple_class;
+ GripClassPart grip_class;
+} GripClassRec;
+
+extern GripClassRec gripClassRec;
+
+/* New fields for the Grip widget record */
+typedef struct {
+ XtCallbackList grip_action;
+} GripPart;
+
+/*****************************************************************************
+ *
+ * Full instance record declaration
+ *
+ ****************************************************************************/
+
+typedef struct _GripRec {
+ CorePart core;
+ SimplePart simple;
+ GripPart grip;
+} GripRec;
+
+#endif /* _XawGripP_h */
+
diff --git a/include/X11/Xaw/Label.h b/include/X11/Xaw/Label.h
new file mode 100644
index 0000000..03696ae
--- /dev/null
+++ b/include/X11/Xaw/Label.h
@@ -0,0 +1,128 @@
+/* $Xorg: Label.h,v 1.4 2001/02/09 02:03:44 xorgcvs Exp $ */
+
+/***********************************************************
+
+Copyright 1987, 1988, 1994, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+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
+OPEN GROUP 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 Open Group 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 Open Group.
+
+
+Copyright 1987, 1988 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+******************************************************************/
+
+#ifndef _XawLabel_h
+#define _XawLabel_h
+
+/***********************************************************************
+ *
+ * Label Widget
+ *
+ ***********************************************************************/
+
+#include <X11/Xaw/Simple.h>
+
+/* Resources:
+
+ Name Class RepType Default Value
+ ---- ----- ------- -------------
+ background Background Pixel XtDefaultBackground
+ bitmap Pixmap Pixmap None
+ border BorderColor Pixel XtDefaultForeground
+ borderWidth BorderWidth Dimension 1
+ cursor Cursor Cursor None
+ cursorName Cursor String NULL
+ destroyCallback Callback XtCallbackList NULL
+ encoding Encoding unsigned char XawTextEncoding8bit
+ font Font XFontStruct* XtDefaultFont
+ foreground Foreground Pixel XtDefaultForeground
+ height Height Dimension text height
+ insensitiveBorder Insensitive Pixmap Gray
+ internalHeight Height Dimension 2
+ internalWidth Width Dimension 4
+ justify Justify XtJustify XtJustifyCenter
+ label Label String NULL
+ leftBitmap LeftBitmap Pixmap None
+ mappedWhenManaged MappedWhenManaged Boolean True
+ pointerColor Foreground Pixel XtDefaultForeground
+ pointerColorBackground Background Pixel XtDefaultBackground
+ resize Resize Boolean True
+ sensitive Sensitive Boolean True
+ width Width Dimension text width
+ x Position Position 0
+ y Position Position 0
+
+*/
+
+#define XawTextEncoding8bit 0
+#define XawTextEncodingChar2b 1
+
+#define XtNleftBitmap "leftBitmap"
+#define XtCLeftBitmap "LeftBitmap"
+#define XtNencoding "encoding"
+#define XtCEncoding "Encoding"
+
+#ifndef XtNfontSet
+#define XtNfontSet "fontSet"
+#endif
+
+#ifndef XtCFontSet
+#define XtCFontSet "FontSet"
+#endif
+
+#ifndef _XtStringDefs_h_
+#define XtNbitmap "bitmap"
+#define XtNforeground "foreground"
+#define XtNlabel "label"
+#define XtNfont "font"
+#define XtNinternalWidth "internalWidth"
+#define XtNinternalHeight "internalHeight"
+#define XtNresize "resize"
+#define XtCResize "Resize"
+#define XtCBitmap "Bitmap"
+#endif
+
+/* Class record constants */
+
+extern WidgetClass labelWidgetClass;
+
+typedef struct _LabelClassRec *LabelWidgetClass;
+typedef struct _LabelRec *LabelWidget;
+
+#endif /* _XawLabel_h */
diff --git a/include/X11/Xaw/LabelP.h b/include/X11/Xaw/LabelP.h
new file mode 100644
index 0000000..384c55e
--- /dev/null
+++ b/include/X11/Xaw/LabelP.h
@@ -0,0 +1,128 @@
+/*
+* $Xorg: LabelP.h,v 1.4 2001/02/09 02:03:44 xorgcvs Exp $
+*/
+
+
+/***********************************************************
+
+Copyright 1987, 1988, 1994, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+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
+OPEN GROUP 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 Open Group 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 Open Group.
+
+
+Copyright 1987, 1988 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+******************************************************************/
+
+/*
+ * LabelP.h - Private definitions for Label widget
+ *
+ */
+
+#ifndef _XawLabelP_h
+#define _XawLabelP_h
+
+/***********************************************************************
+ *
+ * Label Widget Private Data
+ *
+ ***********************************************************************/
+
+#include <X11/Xaw/Label.h>
+#include <X11/Xaw/SimpleP.h>
+
+/* New fields for the Label widget class record */
+
+typedef struct {int foo;} LabelClassPart;
+
+/* Full class record declaration */
+typedef struct _LabelClassRec {
+ CoreClassPart core_class;
+ SimpleClassPart simple_class;
+ LabelClassPart label_class;
+} LabelClassRec;
+
+extern LabelClassRec labelClassRec;
+
+/* New fields for the Label widget record */
+typedef struct {
+ /* resources */
+ Pixel foreground;
+ XFontStruct *font;
+ XFontSet fontset;
+ char *label;
+ XtJustify justify;
+ Dimension internal_width;
+ Dimension internal_height;
+ Pixmap pixmap;
+ Boolean resize;
+ unsigned char encoding;
+ Pixmap left_bitmap;
+
+ /* private state */
+ GC normal_GC;
+ GC gray_GC;
+ Pixmap stipple;
+ Position label_x;
+ Position label_y;
+ Dimension label_width;
+ Dimension label_height;
+ Dimension label_len;
+ int lbm_y; /* where in label */
+ unsigned int lbm_width, lbm_height; /* size of pixmap */
+} LabelPart;
+
+
+/****************************************************************
+ *
+ * Full instance record declaration
+ *
+ ****************************************************************/
+
+typedef struct _LabelRec {
+ CorePart core;
+ SimplePart simple;
+ LabelPart label;
+} LabelRec;
+
+#define LEFT_OFFSET(lw) ((lw)->label.left_bitmap \
+ ? (lw)->label.lbm_width + (lw)->label.internal_width \
+ : 0)
+
+#endif /* _XawLabelP_h */
diff --git a/include/X11/Xaw/List.h b/include/X11/Xaw/List.h
new file mode 100644
index 0000000..e40e1a5
--- /dev/null
+++ b/include/X11/Xaw/List.h
@@ -0,0 +1,236 @@
+/* $Xorg: List.h,v 1.4 2001/02/09 02:03:44 xorgcvs Exp $ */
+
+/*
+Copyright 1989, 1994, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+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
+OPEN GROUP 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 Open Group 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 Open Group.
+*/
+
+/* This is the List widget, it is useful to display a list, without the
+ * overhead of having a widget for each item in the list. It allows
+ * the user to select an item in a list and notifies the application through
+ * a callback function.
+ *
+ * Created: 8/13/88
+ * By: Chris D. Peterson
+ * MIT X Consortium
+ */
+
+#ifndef _XawList_h
+#define _XawList_h
+
+/***********************************************************************
+ *
+ * List Widget
+ *
+ ***********************************************************************/
+
+#include <X11/Xaw/Simple.h>
+
+/* Resources:
+
+ Name Class RepType Default Value
+ ---- ----- ------- -------------
+ background Background Pixel XtDefaultBackground
+ border BorderColor Pixel XtDefaultForeground
+ borderWidth BorderWidth Dimension 1
+ callback Callback XtCallbackList NULL **6
+ columnSpacing Spacing Dimension 6
+ cursor Cursor Cursor left_ptr
+ cursorName Cursor String NULL
+ defaultColumns Columns int 2 **5
+ destroyCallback Callback Pointer NULL
+ font Font XFontStruct* XtDefaultFont
+ forceColumns Columns Boolean False **5
+ foreground Foreground Pixel XtDefaultForeground
+ height Height Dimension 0 **1
+ insensitiveBorder Insensitive Pixmap Gray
+ internalHeight Height Dimension 2
+ internalWidth Width Dimension 4
+ list List String * NULL **2
+ longest Longest int 0 **3 **4
+ mappedWhenManaged MappedWhenManaged Boolean True
+ numberStrings NumberStrings int 0 **4
+ pasteBuffer Boolean Boolean False
+ pointerColor Foreground Pixel XtDefaultForeground
+ pointerColorBackground Background Pixel XtDefaultBackground
+ rowSpacing Spacing Dimension 4
+ sensitive Sensitive Boolean True
+ verticalList Boolean Boolean False
+ width Width Dimension 0 **1
+ x Position Position 0
+ y Position Position 0
+
+ **1 - If the Width or Height of the list widget is zero (0) then the value
+ is set to the minimum size necessay to fit the entire list.
+
+ If both Width and Height are zero then they are adjusted to fit the
+ entire list that is created width the number of default columns
+ specified in the defaultColumns resource.
+
+ **2 - This is an array of strings the specify elements of the list.
+ This resource must be specified.
+ (What good is a list widget without a list?? :-)
+
+ **3 - Longest is the length of the widest string in pixels.
+
+ **4 - If either of these values are zero (0) then the list widget calculates
+ the correct value.
+
+ (This allows you to make startup faster if you already have
+ this information calculated)
+
+ NOTE: If the numberStrings value is zero the list must
+ be NULL terminated.
+
+ **5 - By setting the List.Columns resource you can force the application to
+ have a given number of columns.
+
+ **6 - This returns the name and index of the item selected in an
+ XawListReturnStruct that is pointed to by the client_data
+ in the CallbackProc.
+
+*/
+
+
+/*
+ * Value returned when there are no highlighted objects.
+ */
+
+#define XAW_LIST_NONE -1
+
+#define XtCList "List"
+#define XtCSpacing "Spacing"
+#define XtCColumns "Columns"
+#define XtCLongest "Longest"
+#define XtCNumberStrings "NumberStrings"
+
+#define XtNcursor "cursor"
+#define XtNcolumnSpacing "columnSpacing"
+#define XtNdefaultColumns "defaultColumns"
+#define XtNforceColumns "forceColumns"
+#define XtNlist "list"
+#define XtNlongest "longest"
+#define XtNnumberStrings "numberStrings"
+#define XtNpasteBuffer "pasteBuffer"
+#define XtNrowSpacing "rowSpacing"
+#define XtNverticalList "verticalList"
+
+#ifndef XtNfontSet
+#define XtNfontSet "fontSet"
+#endif
+
+#ifndef XtCFontSet
+#define XtCFontSet "FontSet"
+#endif
+
+/* Class record constants */
+
+extern WidgetClass listWidgetClass;
+
+typedef struct _ListClassRec *ListWidgetClass;
+typedef struct _ListRec *ListWidget;
+
+/* The list return structure. */
+
+typedef struct _XawListReturnStruct {
+ String string;
+ int list_index;
+} XawListReturnStruct;
+
+/******************************************************************
+ *
+ * Exported Functions
+ *
+ *****************************************************************/
+
+_XFUNCPROTOBEGIN
+
+/* Function Name: XawListChange.
+ * Description: Changes the list being used and shown.
+ * Arguments: w - the list widget.
+ * list - the new list.
+ * nitems - the number of items in the list.
+ * longest - the length (in Pixels) of the longest element
+ * in the list.
+ * resize - if TRUE the the list widget will
+ * try to resize itself.
+ * Returns: none.
+ * NOTE: If nitems of longest are <= 0 then they will be caluculated.
+ * If nitems is <= 0 then the list needs to be NULL terminated.
+ */
+
+extern void XawListChange(
+#if NeedFunctionPrototypes
+ Widget /* w */,
+ String* /* list */,
+ int /* nitems */,
+ int /* longest */,
+#if NeedWidePrototypes
+ /* Boolean */ int /* resize */
+#else
+ Boolean /* resize */
+#endif
+#endif
+);
+
+/* Function Name: XawListUnhighlight
+ * Description: unlights the current highlighted element.
+ * Arguments: w - the widget.
+ * Returns: none.
+ */
+
+extern void XawListUnhighlight(
+#if NeedFunctionPrototypes
+ Widget /* w */
+#endif
+);
+
+/* Function Name: XawListHighlight
+ * Description: Highlights the given item.
+ * Arguments: w - the list widget.
+ * item - the item to highlight.
+ * Returns: none.
+ */
+
+extern void XawListHighlight(
+#if NeedFunctionPrototypes
+ Widget /* w */,
+ int /* item */
+#endif
+);
+
+
+/* Function Name: XawListShowCurrent
+ * Description: returns the currently highlighted object.
+ * Arguments: w - the list widget.
+ * Returns: the info about the currently highlighted object.
+ */
+
+extern XawListReturnStruct * XawListShowCurrent(
+#if NeedFunctionPrototypes
+ Widget /* w */
+#endif
+);
+
+_XFUNCPROTOEND
+
+#endif /* _XawList_h */
diff --git a/include/X11/Xaw/ListP.h b/include/X11/Xaw/ListP.h
new file mode 100644
index 0000000..f492559
--- /dev/null
+++ b/include/X11/Xaw/ListP.h
@@ -0,0 +1,115 @@
+/* $Xorg: ListP.h,v 1.4 2001/02/09 02:03:44 xorgcvs Exp $ */
+
+/*
+Copyright 1989, 1994, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+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
+OPEN GROUP 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 Open Group 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 Open Group.
+*/
+
+
+/*
+ * ListP.h - Private definitions for List widget
+ *
+ * This is a List widget. It allows the user to select an item in a list and
+ * notifies the application through a callback function.
+ *
+ * Created: 8/13/88
+ * By: Chris D. Peterson
+ * MIT - Project Athena
+ */
+
+#ifndef _XawListP_h
+#define _XawListP_h
+
+/***********************************************************************
+ *
+ * List Widget Private Data
+ *
+ ***********************************************************************/
+
+#include <X11/Xaw/SimpleP.h>
+#include <X11/Xaw/List.h>
+
+#define NO_HIGHLIGHT XAW_LIST_NONE
+#define OUT_OF_RANGE -1
+#define OKAY 0
+
+/* New fields for the List widget class record */
+
+typedef struct {int foo;} ListClassPart;
+
+/* Full class record declaration */
+typedef struct _ListClassRec {
+ CoreClassPart core_class;
+ SimpleClassPart simple_class;
+ ListClassPart list_class;
+} ListClassRec;
+
+extern ListClassRec listClassRec;
+
+/* New fields for the List widget record */
+typedef struct {
+ /* resources */
+ Pixel foreground;
+ Dimension internal_width, /* if not 3d, user sets directly. */
+ internal_height,
+ column_space, /* half of *_space is add on top/bot/left of*/
+ row_space; /* each item's text bounding box. half added to longest for right */
+ int default_cols;
+ Boolean force_cols,
+ paste,
+ vertical_cols;
+ int longest; /* in pixels */
+ int nitems; /* number of items in the list. */
+ XFontStruct *font;
+ XFontSet fontset; /* Sheeran, Omron KK, 93/03/05 */
+ String * list; /* for i18n, always in multibyte format */
+ XtCallbackList callback;
+
+ /* private state */
+ int is_highlighted, /* set to the item currently highlighted. */
+ highlight, /* set to the item that should be highlighted.*/
+ col_width, /* width of each column. */
+ row_height, /* height of each row. */
+ nrows, /* number of rows in the list. */
+ ncols; /* number of columns in the list. */
+ GC normgc, /* a couple of GC's. */
+ revgc,
+ graygc; /* used when inactive. */
+
+ int freedoms; /* flags for resizing height and width */
+
+} ListPart;
+
+
+/****************************************************************
+ *
+ * Full instance record declaration
+ *
+ ****************************************************************/
+
+typedef struct _ListRec {
+ CorePart core;
+ SimplePart simple;
+ ListPart list;
+} ListRec;
+
+#endif /* _XawListP_h */
diff --git a/include/X11/Xaw/MenuButtoP.h b/include/X11/Xaw/MenuButtoP.h
new file mode 100644
index 0000000..47f415f
--- /dev/null
+++ b/include/X11/Xaw/MenuButtoP.h
@@ -0,0 +1,99 @@
+/* $Xorg: MenuButtoP.h,v 1.4 2001/02/09 02:03:44 xorgcvs Exp $
+ *
+Copyright 1989,1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+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
+OPEN GROUP 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 Open Group 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 Open Group.
+ */
+
+/***********************************************************************
+ *
+ * MenuButton Widget
+ *
+ ***********************************************************************/
+
+/*
+ * MenuButtonP.h - Private Header file for MenuButton widget.
+ *
+ * This is the private header file for the Athena MenuButton widget.
+ * It is intended to provide an easy method of activating pulldown menus.
+ *
+ * Date: May 2, 1989
+ *
+ * By: Chris D. Peterson
+ * MIT X Consortium
+ * kit@expo.lcs.mit.edu
+ */
+
+#ifndef _XawMenuButtonP_h
+#define _XawMenuButtonP_h
+
+#include <X11/Xaw/MenuButton.h>
+#include <X11/Xaw/CommandP.h>
+
+/************************************
+ *
+ * Class structure
+ *
+ ***********************************/
+
+
+ /* New fields for the MenuButton widget class record */
+typedef struct _MenuButtonClass
+{
+ int makes_compiler_happy; /* not used */
+} MenuButtonClassPart;
+
+ /* Full class record declaration */
+typedef struct _MenuButtonClassRec {
+ CoreClassPart core_class;
+ SimpleClassPart simple_class;
+ LabelClassPart label_class;
+ CommandClassPart command_class;
+ MenuButtonClassPart menuButton_class;
+} MenuButtonClassRec;
+
+extern MenuButtonClassRec menuButtonClassRec;
+
+/***************************************
+ *
+ * Instance (widget) structure
+ *
+ **************************************/
+
+ /* New fields for the MenuButton widget record */
+typedef struct {
+ /* resources */
+ String menu_name;
+
+} MenuButtonPart;
+
+ /* Full widget declaration */
+typedef struct _MenuButtonRec {
+ CorePart core;
+ SimplePart simple;
+ LabelPart label;
+ CommandPart command;
+ MenuButtonPart menu_button;
+} MenuButtonRec;
+
+#endif /* _XawMenuButtonP_h */
+
+
diff --git a/include/X11/Xaw/MenuButton.h b/include/X11/Xaw/MenuButton.h
new file mode 100644
index 0000000..ebab47a
--- /dev/null
+++ b/include/X11/Xaw/MenuButton.h
@@ -0,0 +1,89 @@
+/*
+ * $Xorg: MenuButton.h,v 1.4 2001/02/09 02:03:44 xorgcvs Exp $
+ *
+Copyright 1989, 1994, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+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
+OPEN GROUP 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 Open Group 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 Open Group.
+ */
+
+/***********************************************************************
+ *
+ * MenuButton Widget
+ *
+ ***********************************************************************/
+
+/*
+ * MenuButton.h - Public Header file for MenuButton widget.
+ *
+ * This is the public header file for the Athena MenuButton widget.
+ * It is intended to provide an easy method of activating pulldown menus.
+ *
+ * Date: May 2, 1989
+ *
+ * By: Chris D. Peterson
+ * MIT X Consortium
+ * kit@expo.lcs.mit.edu
+ */
+
+#ifndef _XawMenuButton_h
+#define _XawMenuButton_h
+
+#include <X11/Xaw/Command.h>
+
+/* Resources:
+
+ Name Class RepType Default Value
+ ---- ----- ------- -------------
+ background Background Pixel XtDefaultBackground
+ bitmap Pixmap Pixmap None
+ border BorderColor Pixel XtDefaultForeground
+ borderWidth BorderWidth Dimension 1
+ callback Callback Pointer NULL
+ cursor Cursor Cursor None
+ destroyCallback Callback Pointer NULL
+ font Font XFontStruct* XtDefaultFont
+ foreground Foreground Pixel XtDefaultForeground
+ height Height Dimension text height
+ highlightThickness Thickness Dimension 2
+ insensitiveBorder Insensitive Pixmap Gray
+ internalHeight Height Dimension 2
+ internalWidth Width Dimension 4
+ justify Justify XtJustify XtJustifyCenter
+ label Label String NULL
+ mappedWhenManaged MappedWhenManaged Boolean True
+ menuName MenuName String "menu"
+ resize Resize Boolean True
+ sensitive Sensitive Boolean True
+ width Width Dimension text width
+ x Position Position 0
+ y Position Position 0
+
+*/
+
+#define XtNmenuName "menuName"
+#define XtCMenuName "MenuName"
+
+extern WidgetClass menuButtonWidgetClass;
+
+typedef struct _MenuButtonClassRec *MenuButtonWidgetClass;
+typedef struct _MenuButtonRec *MenuButtonWidget;
+
+#endif /* _XawMenuButton_h */
diff --git a/include/X11/Xaw/MultiSink.h b/include/X11/Xaw/MultiSink.h
new file mode 100644
index 0000000..d010c31
--- /dev/null
+++ b/include/X11/Xaw/MultiSink.h
@@ -0,0 +1,117 @@
+/* $Xorg: MultiSink.h,v 1.4 2001/02/09 02:03:44 xorgcvs Exp $ */
+
+/*
+ * Copyright 1991 by OMRON Corporation
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name OMRON is not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. OMRON makes no representations
+ * about the suitability of this software for any purpose. It is provided
+ * "as is" without express or implied warranty.
+ *
+ * OMRON DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL OMRON BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTUOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ *
+ * Author: Li Yuhong OMRON Corporation
+ */
+
+/***********************************************************
+
+Copyright 1987, 1988, 1994, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+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
+OPEN GROUP 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 Open Group 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 Open Group.
+
+
+Copyright 1987, 1988 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+******************************************************************/
+
+#ifndef _XawMultiSink_h
+#define _XawMultiSink_h
+
+/***********************************************************************
+ *
+ * MultiSink Object
+ *
+ ***********************************************************************/
+
+#include <X11/Xaw/TextSink.h>
+
+/* Resources:
+
+ Name Class RepType Default Value
+ ---- ----- ------- -------------
+ echo Output Boolean True
+ displayNonprinting Output Boolean True
+ fontSet FontSet XFontSet XtDefaultFontSet
+
+*/
+
+#define XtCOutput "Output"
+
+#define XtNdisplayNonprinting "displayNonprinting"
+#define XtNecho "echo"
+
+#ifndef XtNfontSet /*Sheeran, Omron KK, 93/03/04*/
+#define XtNfontSet "fontSet"
+#endif
+
+#ifndef XtCFontSet /*Sheeran, Omron KK, 93/03/04*/
+#define XtCFontSet "FontSet"
+#endif
+
+/* Class record constants */
+
+extern WidgetClass multiSinkObjectClass;
+
+typedef struct _MultiSinkClassRec *MultiSinkObjectClass;
+typedef struct _MultiSinkRec *MultiSinkObject;
+
+
+#endif /* _XawMultiSrc_h */
+/* DON'T ADD STUFF AFTER THIS #endif */
diff --git a/include/X11/Xaw/MultiSinkP.h b/include/X11/Xaw/MultiSinkP.h
new file mode 100644
index 0000000..3a4b38d
--- /dev/null
+++ b/include/X11/Xaw/MultiSinkP.h
@@ -0,0 +1,156 @@
+/* $Xorg: MultiSinkP.h,v 1.4 2001/02/09 02:03:44 xorgcvs Exp $ */
+
+/*
+ * Copyright 1991 by OMRON Corporation
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name OMRON not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. OMRON make no representations
+ * about the suitability of this software for any purpose. It is provided
+ * "as is" without express or implied warranty.
+ *
+ * OMRON DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL OMRON BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTUOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ *
+ * Author: Li Yuhong OMRON Corporation
+ */
+
+
+/***********************************************************
+
+Copyright 1987, 1988, 1994, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+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
+OPEN GROUP 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 Open Group 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 Open Group.
+
+
+Copyright 1987, 1988 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+******************************************************************/
+
+/*
+ * multiSinkP.h - Private definitions for multiSink object
+ *
+ */
+
+#ifndef _XawMultiSinkP_h
+#define _XawMultiSinkP_h
+
+/***********************************************************************
+ *
+ * MultiSink Object Private Data
+ *
+ ***********************************************************************/
+
+#include <X11/Xaw/TextSinkP.h>
+#include <X11/Xaw/MultiSink.h>
+
+/************************************************************
+ *
+ * New fields for the MultiSink object class record.
+ *
+ ************************************************************/
+
+typedef struct _MultiSinkClassPart {
+ int foo;
+} MultiSinkClassPart;
+
+/* Full class record declaration */
+
+typedef struct _MultiSinkClassRec {
+ ObjectClassPart object_class;
+ TextSinkClassPart text_sink_class;
+ MultiSinkClassPart multi_sink_class;
+} MultiSinkClassRec;
+
+extern MultiSinkClassRec multiSinkClassRec;
+
+/* New fields for the MultiSink object record */
+typedef struct {
+ /* public resources */
+ Boolean echo;
+ Boolean display_nonprinting;
+
+ /* private state */
+ GC normgc, invgc, xorgc;
+ Pixmap insertCursorOn;
+ XawTextInsertState laststate;
+ short cursor_x, cursor_y; /* Cursor Location. */
+ XFontSet fontset; /* font set to draw */
+} MultiSinkPart;
+
+/****************************************************************
+ *
+ * Full instance record declaration
+ *
+ ****************************************************************/
+
+typedef struct _MultiSinkRec {
+ ObjectPart object;
+ TextSinkPart text_sink;
+ MultiSinkPart multi_sink;
+} MultiSinkRec;
+
+
+/********************************************
+ *
+ * Semi-private functions
+ * for use by other Xaw modules only
+ *
+ *******************************************/
+
+extern void _XawMultiSinkPosToXY(
+#if NeedFunctionPrototypes
+ Widget /* w */,
+ XawTextPosition /* pos */,
+ Position * /* x */,
+ Position * /*y */
+#endif
+);
+
+#endif /* _XawMultiSinkP_h */
+
diff --git a/include/X11/Xaw/MultiSrc.h b/include/X11/Xaw/MultiSrc.h
new file mode 100644
index 0000000..9ac060d
--- /dev/null
+++ b/include/X11/Xaw/MultiSrc.h
@@ -0,0 +1,150 @@
+/* $Xorg: MultiSrc.h,v 1.4 2001/02/09 02:03:44 xorgcvs Exp $ */
+
+/*
+ * Copyright 1991 by OMRON Corporation
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name OMRON not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. OMRON makes no representations
+ * about the suitability of this software for any purpose. It is provided
+ * "as is" without express or implied warranty.
+ *
+ * OMRON DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL OMRON BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTUOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ *
+ * Author: Li Yuhong OMRON Corporation
+ */
+
+/*
+
+Copyright 1989, 1991, 1994, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+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
+OPEN GROUP 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 Open Group 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 Open Group.
+
+*/
+
+/*
+ * This file was modified from AsciiSrc.h.
+ *
+ * By Li Yuhong, Sept. 18, 1990
+ */
+
+#ifndef _XawMultiSrc_h
+#define _XawMultiSrc_h
+
+#include <X11/Xaw/TextSrc.h>
+/*Xfuncproto.h included by Intrinsic.h*/
+
+/* Resources:
+
+ Name Class RepType Default Value
+ ---- ----- ------- -------------
+ callback Callback Callback (none)
+ dataCompression DataCompression Boolean True
+ length Length int (internal)
+ pieceSize PieceSize int BUFSIZ
+ string String String NULL
+ type Type XawAsciiType XawAsciiString
+ useStringInPlace UseStringInPlace Boolean False
+
+*/
+
+/* Class record constants */
+
+extern WidgetClass multiSrcObjectClass;
+
+typedef struct _MultiSrcClassRec *MultiSrcObjectClass;
+typedef struct _MultiSrcRec *MultiSrcObject;
+
+/*
+ * Just to make people's lives a bit easier.
+ */
+
+#define MultiSourceObjectClass MultiSrcObjectClass
+#define MultiSourceObject MultiSrcObject
+
+/*
+ * Resource Definitions.
+ */
+
+#define XtCDataCompression "DataCompression"
+#define XtCPieceSize "PieceSize"
+#define XtCType "Type"
+#define XtCUseStringInPlace "UseStringInPlace"
+
+#define XtNdataCompression "dataCompression"
+#define XtNpieceSize "pieceSize"
+#define XtNtype "type"
+#define XtNuseStringInPlace "useStringInPlace"
+
+#define XtRMultiType "MultiType"
+
+#define XtEstring "string"
+#define XtEfile "file"
+
+/************************************************************
+ *
+ * THESE ROUTINES ARE NOT PUBLIC: Source should call
+ *
+ * the AsciiSrc API which currently forwards requests here.
+ *
+ * future versions (like theres going to be an R7 Xaw!) may
+ *
+ * eliminate this file or at least these functions entirely.
+ *
+ ************************************************************/
+
+_XFUNCPROTOBEGIN
+
+
+extern void XawMultiSourceFreeString(
+#if NeedFunctionPrototypes
+ Widget /* w */
+#endif
+);
+
+extern Boolean _XawMultiSave(
+#if NeedFunctionPrototypes
+ Widget /* w */
+#endif
+);
+
+extern Boolean _XawMultiSaveAsFile(
+#if NeedFunctionPrototypes
+ Widget /* w */,
+ _Xconst char* /* name */
+#endif
+);
+
+
+_XFUNCPROTOEND
+
+#endif /* _XawMultiSrc_h - Don't add anything after this line. */
+
diff --git a/include/X11/Xaw/MultiSrcP.h b/include/X11/Xaw/MultiSrcP.h
new file mode 100644
index 0000000..00426db
--- /dev/null
+++ b/include/X11/Xaw/MultiSrcP.h
@@ -0,0 +1,197 @@
+/* $Xorg: MultiSrcP.h,v 1.4 2001/02/09 02:03:45 xorgcvs Exp $ */
+
+/*
+ * Copyright 1991 by OMRON Corporation
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name OMRON not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. OMRON make no representations
+ * about the suitability of this software for any purpose. It is provided
+ * "as is" without express or implied warranty.
+ *
+ * OMRON DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL OMRON BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTUOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ *
+ * Author: Li Yuhong OMRON Corporation
+ */
+
+
+/***********************************************************
+
+Copyright 1987, 1988, 1991, 1994, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+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
+OPEN GROUP 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 Open Group 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 Open Group.
+
+
+Copyright 1987, 1988 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+******************************************************************/
+
+/*
+ * MultiSrcP.h - Private Header for Multi Text Source.
+ *
+ * This is the private header file for the Multi Text Source.
+ * It is intended to be used with the Text widget, the simplest way to use
+ * this text source is to use the MultiText Object.
+ *
+ * Date: June 29, 1989
+ *
+ * By: Chris D. Peterson
+ * MIT X Consortium
+ * kit@expo.lcs.mit.edu
+ */
+
+/*
+ * TextSrcP.h - Private definitions for MultiSrc object
+ *
+ */
+
+/*
+ * This file was changed from AsciiSrcP.h.
+ *
+ * By Li Yuhong, Sept. 18, 1990
+ */
+
+#ifndef _XawMultiSrcP_h
+#define _XawMultiSrcP_h
+
+#include <X11/Xaw/TextSrcP.h>
+#include <X11/Xaw/MultiSrc.h>
+
+/************************************************************
+ *
+ * Private declarations.
+ *
+ ************************************************************/
+
+#ifdef L_tmpnam
+#define TMPSIZ L_tmpnam
+#else
+#ifdef PATH_MAX
+#define TMPSIZ PATH_MAX
+#else
+#define TMPSIZ 1024 /* bytes to allocate for tmpnam */
+#endif
+#endif
+
+#define MAGIC_VALUE ((XawTextPosition) -1) /* Magic value. */
+
+#define streq(a, b) ( strcmp((a), (b)) == 0 )
+
+typedef struct _MultiPiece { /* Piece of the text file of BUFSIZ allocated
+ characters. */
+ wchar_t* text; /* The text in this buffer. */
+ XawTextPosition used; /* The number of characters of this buffer
+ that have been used. */
+ struct _MultiPiece *prev, *next; /* linked list pointers. */
+} MultiPiece;
+
+/************************************************************
+ *
+ * New fields for the MultiSrc object class record.
+ *
+ ************************************************************/
+
+typedef struct _MultiSrcClassPart { char foo; } MultiSrcClassPart;
+
+/* Full class record declaration */
+typedef struct _MultiSrcClassRec {
+ ObjectClassPart object_class;
+ TextSrcClassPart text_src_class;
+ MultiSrcClassPart multi_src_class;
+} MultiSrcClassRec;
+
+extern MultiSrcClassRec multiSrcClassRec;
+
+/* New fields for the MultiSrc object record */
+
+typedef struct _MultiSrcPart {
+
+ /* Resources. */
+
+ XIC ic; /* for X Input Method. */
+ XtPointer string; /* either the string, or the file name, depend-
+ ing upon the `type'. ALWAYS IN MB FORMAT. */
+ XawAsciiType type; /* either string or disk. */
+ XawTextPosition piece_size; /* Size of text buffer for each piece. */
+ Boolean data_compression; /* compress to minimum memory automatically
+ on save? */
+ XtCallbackList callback; /* A callback list to call when the source is
+ changed. */
+ Boolean use_string_in_place; /* Use the string passed in place. */
+ int multi_length; /* length field for multi string emulation. */
+
+/* Private data. */
+
+ Boolean is_tempfile; /* Is this a temporary file? */
+ Boolean changes; /* Has this file been edited? */
+ Boolean allocated_string; /* Have I allocated the
+ string in multi_src->string? */
+ XawTextPosition length; /* length of file - IN CHARACTERS, NOT BYTES. */
+ MultiPiece * first_piece; /* first piece of the text. */
+} MultiSrcPart;
+
+/****************************************************************
+ *
+ * Full instance record declaration
+ *
+ ****************************************************************/
+
+typedef struct _MultiSrcRec {
+ ObjectPart object;
+ TextSrcPart text_src;
+ MultiSrcPart multi_src;
+} MultiSrcRec;
+
+#if NeedFunctionPrototypes
+extern void _XawMultiSourceFreeString( Widget );
+#else
+extern void _XawMultiSourceFreeString();
+#endif
+
+#endif /* _XawMultiSrcP_h --- Don't add anything after this line. */
diff --git a/include/X11/Xaw/Paned.h b/include/X11/Xaw/Paned.h
new file mode 100644
index 0000000..1f6c29e
--- /dev/null
+++ b/include/X11/Xaw/Paned.h
@@ -0,0 +1,255 @@
+/*
+* $Xorg: Paned.h,v 1.5 2001/02/09 02:03:45 xorgcvs Exp $
+*/
+
+
+/***********************************************************
+
+Copyright 1987, 1988, 1994, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+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
+OPEN GROUP 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 Open Group 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 Open Group.
+
+
+Copyright 1987, 1988 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+******************************************************************/
+
+/*
+ * Paned.h - Paned Composite Widget's public header file.
+ *
+ * Updated and significantly modifided from the Athena VPaned Widget.
+ *
+ * Date: March 1, 1989
+ *
+ * By: Chris D. Peterson
+ * MIT X Consortium
+ * kit@expo.lcs.mit.edu
+ */
+
+#ifndef _XawPaned_h
+#define _XawPaned_h
+
+#include <X11/Intrinsic.h>
+#include <X11/Xmu/Converters.h>
+
+/****************************************************************
+ *
+ * Vertical Paned Widget (SubClass of CompositeClass)
+ *
+ ****************************************************************/
+
+/* RESOURCES:
+
+ Name Class RepType Default Value
+ ---- ----- ------- -------------
+ background Background Pixel XtDefaultBackground
+ betweenCursor Cursor Cursor **
+ border BorderColor Pixel XtDefaultForeground
+ borderWidth BorderWidth Dimension 1
+ cursor Cursor Cursor None
+ destroyCallback Callback Pointer NULL
+ height Height Dimension 0
+ gripIndent GripIndent Position 16
+ gripCursor Cursor Cursor **
+ horizontalGripCursol Cursor Cursor sb_h_double_arrow
+ horizontalBetweencursor Cursor Cursor sb_up_arrow
+ internalBorderColor BorderColor Pixel XtDefaultForeground
+ internalBorderWidth BorderWidth Position 1
+ leftCursor Cursor Cursor sb_left_arrow
+ lowerCursor Cursor Cursor sb_down_arrow
+ mappedWhenManaged MappedWhenManaged Boolean True
+ orientation Orientation XtOrientation XtorientVertical
+ refigureMode Boolean Boolean On
+ rightCursor Cursor Cursor sb_right_arrow
+ sensitive Sensitive Boolean True
+ upperCursor Cursor Cursor sb_up_arrow
+ verticalBetweenCursor Cursor Cursor sb_left_arrow
+ verticalGripCursor Cursor Cursor sb_v_double_arrow
+ width Width Dimension 0
+ x Position Position 0
+ y Position Position 0
+
+** These resources now are set to the vertical or horizontal cursor
+ depending upon orientation, by default. If a value is specified here
+ then that cursor will be used reguardless of orientation.
+
+
+CONSTRAINT RESOURCES:
+
+ Name Class RepType Default Value
+ ---- ----- ------- -------------
+ allowResize Boolean Boolean False
+ max Max Dimension unlimited
+ min Min Dimension Grip Size
+ preferredPaneSize PerferredPaneSize Dimension PANED_ASK_CHILD
+ resizeToPreferred Boolean Boolean False
+ showGrip ShowGrip Boolean True
+ skipAdjust Boolean Boolean False
+
+*/
+
+#define PANED_ASK_CHILD 0
+#define PANED_GRIP_SIZE 0
+
+/* New Fields */
+#define XtNallowResize "allowResize"
+#define XtNbetweenCursor "betweenCursor"
+#define XtNverticalBetweenCursor "verticalBetweenCursor"
+#define XtNhorizontalBetweenCursor "horizontalBetweenCursor"
+#define XtNgripCursor "gripCursor"
+#define XtNgripIndent "gripIndent"
+#define XtNhorizontalGripCursor "horizontalGripCursor"
+#define XtNinternalBorderColor "internalBorderColor"
+#define XtNinternalBorderWidth "internalBorderWidth"
+#define XtNleftCursor "leftCursor"
+#define XtNlowerCursor "lowerCursor"
+#define XtNrefigureMode "refigureMode"
+#define XtNposition "position"
+#define XtNmin "min"
+#define XtNmax "max"
+#define XtNpreferredPaneSize "preferredPaneSize"
+#define XtNresizeToPreferred "resizeToPreferred"
+#define XtNrightCursor "rightCursor"
+#define XtNshowGrip "showGrip"
+#define XtNskipAdjust "skipAdjust"
+#define XtNupperCursor "upperCursor"
+#define XtNverticalGripCursor "verticalGripCursor"
+
+#define XtCGripIndent "GripIndent"
+#define XtCMin "Min"
+#define XtCMax "Max"
+#define XtCPreferredPaneSize "PreferredPaneSize"
+#define XtCShowGrip "ShowGrip"
+
+/* Class record constant */
+extern WidgetClass panedWidgetClass;
+
+typedef struct _PanedClassRec *PanedWidgetClass;
+typedef struct _PanedRec *PanedWidget;
+
+/************************************************************
+ *
+ * Public Procedures
+ *
+ ************************************************************/
+
+_XFUNCPROTOBEGIN
+
+/* Function Name: XawPanedSetMinMax
+ * Description: Sets the min and max size for a pane.
+ * Arguments: widget - the widget that is a child of the Paned widget.
+ * min, max - the new min and max size for the pane.
+ * Returns: none.
+ */
+
+extern void XawPanedSetMinMax(
+#if NeedFunctionPrototypes
+ Widget /* w */,
+ int /* min */,
+ int /* max */
+#endif
+);
+
+/* Function Name: XawPanedGetMinMax
+ * Description: Gets the min and max size for a pane.
+ * Arguments: widget - the widget that is a child of the Paned widget.
+ ** RETURNED ** min, max - the current min and max size for the pane.
+ * Returns: none.
+ */
+
+extern void XawPanedGetMinMax(
+#if NeedFunctionPrototypes
+ Widget /* w */,
+ int * /* min_return */,
+ int * /* max_return */
+#endif
+);
+
+/* Function Name: XawPanedSetRefigureMode
+ * Description: Allows a flag to be set the will inhibit
+ * the paned widgets relayout routine.
+ * Arguments: w - the paned widget.
+ * mode - if FALSE then inhibit refigure.
+ * Returns: none.
+ */
+
+extern void XawPanedSetRefigureMode(
+#if NeedFunctionPrototypes
+ Widget /* w */,
+#if NeedWidePrototypes
+ /* Boolean */ int /* mode */
+#else
+ Boolean /* mode */
+#endif
+#endif
+);
+
+/* Function Name: XawPanedGetNumSub
+ * Description: Returns the number of panes in the paned widget.
+ * Arguments: w - the paned widget.
+ * Returns: the number of panes in the paned widget.
+ */
+
+extern int XawPanedGetNumSub(
+#if NeedFunctionPrototypes
+ Widget /* w */
+#endif
+);
+
+/* Function Name: XawPanedAllowResize
+ * Description: Allows a flag to be set that determines if the paned
+ * widget will allow geometry requests from this child
+ * Arguments: widget - a child of the paned widget.
+ * Returns: none.
+ */
+
+extern void XawPanedAllowResize(
+#if NeedFunctionPrototypes
+ Widget /* w */,
+#if NeedWidePrototypes
+ /* Boolean */ int /* allow_resize */
+#else
+ Boolean /* allow_resize */
+#endif
+#endif
+);
+
+_XFUNCPROTOEND
+
+#endif /* _XawPaned_h */
diff --git a/include/X11/Xaw/PanedP.h b/include/X11/Xaw/PanedP.h
new file mode 100644
index 0000000..32b909f
--- /dev/null
+++ b/include/X11/Xaw/PanedP.h
@@ -0,0 +1,192 @@
+/***********************************************************
+
+ $Xorg: PanedP.h,v 1.4 2001/02/09 02:03:45 xorgcvs Exp $
+
+
+Copyright 1987, 1988, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+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
+OPEN GROUP 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 Open Group 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 Open Group.
+
+
+Copyright 1987, 1988 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+******************************************************************/
+
+/*
+ * PanedP.h - Paned Composite Widget's private header file.
+ *
+ * Updated and significantly modified from the Athena VPaned Widget.
+ *
+ * Date: March 1, 1989
+ *
+ * By: Chris D. Peterson
+ * MIT X Consortium
+ * kit@expo.lcs.mit.edu
+ */
+
+#ifndef _XawPanedP_h
+#define _XawPanedP_h
+
+#include <X11/Xaw/Paned.h>
+
+/*********************************************************************
+ *
+ * Paned Widget Private Data
+ *
+ *********************************************************************/
+
+/* New fields for the Paned widget class record */
+
+typedef struct _PanedClassPart {
+ int foo; /* keep compiler happy. */
+} PanedClassPart;
+
+/* Full Class record declaration */
+typedef struct _PanedClassRec {
+ CoreClassPart core_class;
+ CompositeClassPart composite_class;
+ ConstraintClassPart constraint_class;
+ PanedClassPart paned_class;
+} PanedClassRec;
+
+extern PanedClassRec panedClassRec;
+
+/* Paned constraint record */
+typedef struct _PanedConstraintsPart {
+ /* Resources. */
+ Dimension min; /* Minimum height */
+ Dimension max; /* Maximum height */
+ Boolean allow_resize; /* TRUE iff child resize requests are ok */
+ Boolean show_grip; /* TRUE iff child will have grip below it,
+ when it is not the bottom pane. */
+ Boolean skip_adjust; /* TRUE iff child's height should not be */
+ /* changed without explicit user action. */
+ int position; /* position location in Paned (relative to
+ other children) ** NIY ** */
+ Dimension preferred_size; /* The Preferred size of the pane.
+ Iff this is zero then ask child for size.*/
+ Boolean resize_to_pref; /* resize this pane to its preferred size
+ on a resize or change managed after
+ realize. */
+
+ /* Private state. */
+ Position delta; /* Desired Location */
+ Position olddelta; /* The last value of dy. */
+ Boolean paned_adjusted_me; /* Has the vpaned adjusted this widget w/o
+ user interaction to make things fit? */
+ Dimension wp_size; /* widget's preferred size */
+ int size; /* the size the widget will actually get. */
+ Widget grip; /* The grip for this child */
+
+} PanedConstraintsPart, *Pane;
+
+typedef struct _PanedConstraintsRec {
+ PanedConstraintsPart paned;
+} PanedConstraintsRec, *PanedConstraints;
+
+/*
+ * The Pane Stack Structure.
+ */
+
+typedef struct _PaneStack {
+ struct _PaneStack * next; /* The next element on the stack. */
+ Pane pane; /* The pane in this element on the stack. */
+ int start_size; /* The size of this element when it was pushed
+ onto the stack. */
+} PaneStack;
+
+/* New Fields for the Paned widget record */
+typedef struct {
+ /* resources */
+ Position grip_indent; /* Location of grips (offset
+ from right margin) */
+ Boolean refiguremode; /* Whether to refigure changes
+ right now */
+ XtTranslations grip_translations; /* grip translation table */
+ Pixel internal_bp; /* color of internal borders. */
+ Dimension internal_bw; /* internal border width. */
+ XtOrientation orientation; /* Orientation of paned widget. */
+
+ Cursor cursor; /* Cursor for paned window */
+ Cursor grip_cursor; /* inactive grip cursor */
+ Cursor v_grip_cursor; /* inactive vert grip cursor */
+ Cursor h_grip_cursor; /* inactive horiz grip cursor */
+ Cursor adjust_this_cursor; /* active grip cursor: T */
+ Cursor v_adjust_this_cursor; /* active vert grip cursor: T */
+ Cursor h_adjust_this_cursor; /* active horiz grip cursor: T */
+
+ /* vertical. */
+ Cursor adjust_upper_cursor; /* active grip cursor: U */
+ Cursor adjust_lower_cursor; /* active grip cursor: D */
+
+ /* horizontal. */
+ Cursor adjust_left_cursor; /* active grip cursor: U */
+ Cursor adjust_right_cursor; /* active grip cursor: D */
+
+ /* private */
+ Boolean recursively_called; /* for ChangeManaged */
+ Boolean resize_children_to_pref; /* override constrain resources
+ and resize all children to
+ preferred size. */
+ int start_loc; /* mouse origin when adjusting */
+ Widget whichadd; /* Which pane to add changes to */
+ Widget whichsub; /* Which pane to sub changes from */
+ GC normgc; /* GC to use when drawing borders */
+ GC invgc; /* GC to use when erasing borders */
+ GC flipgc; /* GC to use when animating
+ borders */
+ int num_panes; /* count of managed panes */
+ PaneStack * stack; /* The pane stack for this widget.*/
+} PanedPart;
+
+/**************************************************************************
+ *
+ * Full instance record declaration
+ *
+ **************************************************************************/
+
+typedef struct _PanedRec {
+ CorePart core;
+ CompositePart composite;
+ ConstraintPart constraint;
+ PanedPart paned;
+} PanedRec;
+
+#endif /* _XawPanedP_h */
+/* DON'T ADD STUFF AFTER THIS #endif */
diff --git a/include/X11/Xaw/Panner.h b/include/X11/Xaw/Panner.h
new file mode 100644
index 0000000..037b257
--- /dev/null
+++ b/include/X11/Xaw/Panner.h
@@ -0,0 +1,108 @@
+/*
+ * $Xorg: Panner.h,v 1.5 2001/02/09 02:03:45 xorgcvs Exp $
+ *
+Copyright 1989, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+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
+OPEN GROUP 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 Open Group 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 Open Group.
+ *
+ * Author: Jim Fulton, MIT X Consortium
+ */
+
+#ifndef _XawPanner_h
+#define _XawPanner_h
+
+#include <X11/Intrinsic.h>
+#include <X11/Xaw/Reports.h>
+
+/*****************************************************************************
+ *
+ * Panner Widget (subclass of Simple)
+ *
+ * This widget is used to represent navigation in a 2d coordinate system.
+ *
+ * Parameters:
+ *
+ * Name Class Type Default
+ * ---- ----- ---- -------
+ *
+ * allowOff AllowOff Boolean FALSE
+ * background Background Pixel XtDefaultBackground
+ * backgroundStipple BackgroundStipple String NULL
+ * canvasWidth CanvasWidth Dimension 0
+ * canvasHeight CanvasHeight Dimension 0
+ * defaultScale DefaultScale Dimension 8 percent
+ * foreground Foreground Pixel XtDefaultBackground
+ * internalSpace InternalSpace Dimension 4
+ * lineWidth LineWidth Dimension 0
+ * reportCallback ReportCallback XtCallbackList NULL
+ * resize Resize Boolean TRUE
+ * rubberBand RubberBand Boolean FALSE
+ * shadowColor ShadowColor Pixel XtDefaultForeground
+ * shadowThickness ShadowThickness Dimension 2
+ * sliderX SliderX Position 0
+ * sliderY SliderY Position 0
+ * sliderWidth SliderWidth Dimension 0
+ * sliderHeight SliderHeight Dimension 0
+ *
+ *****************************************************************************/
+
+ /* new instance and class names */
+#ifndef _XtStringDefs_h_
+#define XtNresize "resize"
+#define XtCResize "Resize"
+#endif
+
+#define XtNallowOff "allowOff"
+#define XtCAllowOff "AllowOff"
+#define XtNbackgroundStipple "backgroundStipple"
+#define XtCBackgroundStipple "BackgroundStipple"
+#define XtNdefaultScale "defaultScale"
+#define XtCDefaultScale "DefaultScale"
+#define XtNcanvasWidth "canvasWidth"
+#define XtCCanvasWidth "CanvasWidth"
+#define XtNcanvasHeight "canvasHeight"
+#define XtCCanvasHeight "CanvasHeight"
+#define XtNinternalSpace "internalSpace"
+#define XtCInternalSpace "InternalSpace"
+#define XtNlineWidth "lineWidth"
+#define XtCLineWidth "LineWidth"
+#define XtNrubberBand "rubberBand"
+#define XtCRubberBand "RubberBand"
+#define XtNshadowThickness "shadowThickness"
+#define XtCShadowThickness "ShadowThickness"
+#define XtNshadowColor "shadowColor"
+#define XtCShadowColor "ShadowColor"
+#define XtNsliderX "sliderX"
+#define XtCSliderX "SliderX"
+#define XtNsliderY "sliderY"
+#define XtCSliderY "SliderY"
+#define XtNsliderWidth "sliderWidth"
+#define XtCSliderWidth "SliderWidth"
+#define XtNsliderHeight "sliderHeight"
+#define XtCSliderHeight "SliderHeight"
+
+ /* external declarations */
+extern WidgetClass pannerWidgetClass;
+
+typedef struct _PannerClassRec *PannerWidgetClass;
+typedef struct _PannerRec *PannerWidget;
+
+#endif /* _XawPanner_h */
diff --git a/include/X11/Xaw/PannerP.h b/include/X11/Xaw/PannerP.h
new file mode 100644
index 0000000..a952b02
--- /dev/null
+++ b/include/X11/Xaw/PannerP.h
@@ -0,0 +1,103 @@
+/*
+ * $Xorg: PannerP.h,v 1.4 2001/02/09 02:03:45 xorgcvs Exp $
+ *
+Copyright 1989, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+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
+OPEN GROUP 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 Open Group 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 Open Group.
+ *
+ * Author: Jim Fulton, MIT X Consortium
+ */
+
+#ifndef _XawPannerP_h
+#define _XawPannerP_h
+
+#include <X11/Xaw/Panner.h>
+#include <X11/Xaw/SimpleP.h> /* parent */
+
+typedef struct { /* new fields in widget class */
+ int dummy;
+} PannerClassPart;
+
+typedef struct _PannerClassRec { /* Panner widget class */
+ CoreClassPart core_class;
+ SimpleClassPart simple_class;
+ PannerClassPart panner_class;
+} PannerClassRec;
+
+typedef struct { /* new fields in widget */
+ /* resources... */
+ XtCallbackList report_callbacks; /* callback/Callback */
+ Boolean allow_off; /* allowOff/AllowOff */
+ Boolean resize_to_pref; /* resizeToPreferred/Boolean */
+ Pixel foreground; /* foreground/Foreground */
+ Pixel shadow_color; /* shadowColor/ShadowColor */
+ Dimension shadow_thickness; /* shadowThickness/ShadowThickness */
+ Dimension default_scale; /* defaultScale/DefaultScale */
+ Dimension line_width; /* lineWidth/LineWidth */
+ Dimension canvas_width; /* canvasWidth/CanvasWidth */
+ Dimension canvas_height; /* canvasHeight/CanvasHeight */
+ Position slider_x; /* sliderX/SliderX */
+ Position slider_y; /* sliderY/SliderY */
+ Dimension slider_width; /* sliderWidth/SliderWidth */
+ Dimension slider_height; /* sliderHeight/SliderHeight */
+ Dimension internal_border; /* internalBorderWidth/BorderWidth */
+ String stipple_name; /* backgroundStipple/BackgroundStipple */
+ /* private data... */
+ GC slider_gc; /* background of slider */
+ GC shadow_gc; /* edge of slider and shadow */
+ GC xor_gc; /* for doing XOR tmp graphics */
+ double haspect, vaspect; /* aspect ratio of core to canvas */
+ Boolean rubber_band; /* true = rubber band, false = move */
+ struct {
+ Boolean doing; /* tmp graphics in progress */
+ Boolean showing; /* true if tmp graphics displayed */
+ Position startx, starty; /* initial position of slider */
+ Position dx, dy; /* offset loc for tmp graphics */
+ Position x, y; /* location for tmp graphics */
+ } tmp;
+ Position knob_x, knob_y; /* real upper left of knob in canvas */
+ Dimension knob_width, knob_height; /* real size of knob in canvas */
+ Boolean shadow_valid; /* true if rects are valid */
+ XRectangle shadow_rects[2]; /* location of shadows */
+ Position last_x, last_y; /* previous location of knob */
+} PannerPart;
+
+typedef struct _PannerRec {
+ CorePart core;
+ SimplePart simple;
+ PannerPart panner;
+} PannerRec;
+
+#define PANNER_HSCALE(pw,val) ((pw)->panner.haspect * ((double) (val)))
+#define PANNER_VSCALE(pw,val) ((pw)->panner.vaspect * ((double) (val)))
+
+#define PANNER_DSCALE(pw,val) (Dimension) \
+ ((((unsigned long) (val)) * (unsigned long) pw->panner.default_scale) / 100L)
+#define PANNER_DEFAULT_SCALE 8 /* percent */
+
+#define PANNER_OUTOFRANGE -30000
+
+/*
+ * external declarations
+ */
+extern PannerClassRec pannerClassRec;
+
+#endif /* _XawPannerP_h */
diff --git a/include/X11/Xaw/Porthole.h b/include/X11/Xaw/Porthole.h
new file mode 100644
index 0000000..0eb3419
--- /dev/null
+++ b/include/X11/Xaw/Porthole.h
@@ -0,0 +1,64 @@
+/*
+ * $Xorg: Porthole.h,v 1.5 2001/02/09 02:03:45 xorgcvs Exp $
+ *
+Copyright 1990, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+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
+OPEN GROUP 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 Open Group 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 Open Group.
+ *
+ * Author: Jim Fulton, MIT X Consortium
+ */
+
+#ifndef _XawPorthole_h
+#define _XawPorthole_h
+
+#include <X11/Intrinsic.h>
+#include <X11/Xaw/Reports.h>
+
+/*****************************************************************************
+ *
+ * Porthole Widget (subclass of Composite)
+ *
+ * This widget is similar to a viewport without scrollbars. Child movement
+ * is done by external panners or scrollbars.
+ *
+ * Parameters:
+ *
+ * Name Class Type Default
+ * ---- ----- ---- -------
+ *
+ * background Background Pixel XtDefaultBackground
+ * border BorderColor Pixel XtDefaultForeground
+ * borderWidth BorderWidth Dimension 1
+ * height Height Dimension 0
+ * reportCallback ReportCallback Pointer NULL
+ * width Width Dimension 0
+ * x Position Position 0
+ * y Position Position 0
+ *
+ *****************************************************************************/
+
+ /* external declarations */
+
+extern WidgetClass portholeWidgetClass;
+typedef struct _PortholeClassRec *PortholeWidgetClass;
+typedef struct _PortholeRec *PortholeWidget;
+
+#endif /* _XawPorthole_h */
diff --git a/include/X11/Xaw/PortholeP.h b/include/X11/Xaw/PortholeP.h
new file mode 100644
index 0000000..e5d6ba6
--- /dev/null
+++ b/include/X11/Xaw/PortholeP.h
@@ -0,0 +1,64 @@
+/*
+ * $Xorg: PortholeP.h,v 1.4 2001/02/09 02:03:45 xorgcvs Exp $
+ *
+Copyright 1990, 1994, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+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
+OPEN GROUP 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 Open Group 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 Open Group.
+ *
+ * Author: Jim Fulton, MIT X Consortium
+ */
+
+#ifndef _XawPortholeP_h
+#define _XawPortholeP_h
+
+#include <X11/Xaw/Porthole.h>
+
+typedef struct { /* new fields in widget class */
+ int dummy;
+} PortholeClassPart;
+
+typedef struct _PortholeClassRec { /* Porthole widget class */
+ CoreClassPart core_class;
+ CompositeClassPart composite_class;
+ PortholeClassPart porthole_class;
+} PortholeClassRec;
+
+
+typedef struct { /* new fields in widget */
+ /* resources... */
+ XtCallbackList report_callbacks; /* callback/Callback */
+ /* private data... */
+} PortholePart;
+
+typedef struct _PortholeRec {
+ CorePart core;
+ CompositePart composite;
+ PortholePart porthole;
+} PortholeRec;
+
+
+/*
+ * external declarations
+ */
+extern PortholeClassRec portholeClassRec;
+
+
+#endif /* _XawPortholeP_h */
diff --git a/include/X11/Xaw/Repeater.h b/include/X11/Xaw/Repeater.h
new file mode 100644
index 0000000..49232cd
--- /dev/null
+++ b/include/X11/Xaw/Repeater.h
@@ -0,0 +1,76 @@
+/*
+ * $Xorg: Repeater.h,v 1.4 2001/02/09 02:03:45 xorgcvs Exp $
+ *
+Copyright 1989, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+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
+OPEN GROUP 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 Open Group 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 Open Group.
+ *
+ * Author: Jim Fulton, MIT X Consortium
+ */
+
+#ifndef _XawRepeater_h
+#define _XawRepeater_h
+
+#include <X11/Xaw/Command.h>
+
+/*****************************************************************************
+ *
+ * Repeater Widget (subclass of Command)
+ *
+ * This widget is a push button that repeatedly fires when held down.
+ *
+ * Parameters:
+ *
+ * Name Class Type Default
+ * ---- ----- ---- -------
+ *
+ * decay Decay int 5 milliseconds
+ * flash Boolean Boolean FALSE
+ * initialDelay Delay int 200 milliseconds
+ * minimumDelay MinimumDelay int 10 milliseconds
+ * repeatDelay Delay int 50 milliseconds
+ * startCallback StartCallback XtCallbackList NULL
+ * stopCallback StopCallback XtCallbackList NULL
+ *
+ *****************************************************************************/
+
+ /* new instance and class names */
+#define XtNdecay "decay"
+#define XtCDecay "Decay"
+#define XtNinitialDelay "initialDelay"
+#define XtCDelay "Delay"
+#define XtNminimumDelay "minimumDelay"
+#define XtCMinimumDelay "MinimumDelay"
+#define XtNrepeatDelay "repeatDelay"
+#define XtNflash "flash"
+#define XtNstartCallback "startCallback"
+#define XtCStartCallback "StartCallback"
+#define XtNstopCallback "stopCallback"
+#define XtCStopCallback "StopCallback"
+
+
+ /* external declarations */
+extern WidgetClass repeaterWidgetClass;
+
+typedef struct _RepeaterClassRec *RepeaterWidgetClass;
+typedef struct _RepeaterRec *RepeaterWidget;
+
+#endif /* _XawRepeater_h */
diff --git a/include/X11/Xaw/RepeaterP.h b/include/X11/Xaw/RepeaterP.h
new file mode 100644
index 0000000..0c82c4c
--- /dev/null
+++ b/include/X11/Xaw/RepeaterP.h
@@ -0,0 +1,79 @@
+/*
+ * $Xorg: RepeaterP.h,v 1.4 2001/02/09 02:03:45 xorgcvs Exp $
+ *
+Copyright 1989, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+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
+OPEN GROUP 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 Open Group 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 Open Group.
+ *
+ * Author: Jim Fulton, MIT X Consortium
+ */
+
+#ifndef _XawRepeaterP_h
+#define _XawRepeaterP_h
+
+#include <X11/Xaw/CommandP.h>
+#include <X11/Xaw/Repeater.h>
+
+typedef struct { /* new fields in widget class */
+ int dummy;
+} RepeaterClassPart;
+
+typedef struct _RepeaterClassRec { /* Repeater widget class */
+ CoreClassPart core_class;
+ SimpleClassPart simple_class;
+ LabelClassPart label_class;
+ CommandClassPart command_class;
+ RepeaterClassPart repeater_class;
+} RepeaterClassRec;
+
+typedef struct { /* new fields in widget */
+ /* resources... */
+ int initial_delay; /* initialDelay/Delay */
+ int repeat_delay; /* repeatDelay/Delay */
+ int minimum_delay; /* minimumDelay/MinimumDelay */
+ int decay; /* decay to minimum delay */
+ Boolean flash; /* flash/Boolean */
+ XtCallbackList start_callbacks; /* startCallback/StartCallback */
+ XtCallbackList stop_callbacks; /* stopCallback/StopCallback */
+ /* private data... */
+ int next_delay; /* next amount for timer */
+ XtIntervalId timer; /* timer that will fire */
+} RepeaterPart;
+
+typedef struct _RepeaterRec {
+ CorePart core;
+ SimplePart simple;
+ LabelPart label;
+ CommandPart command;
+ RepeaterPart repeater;
+} RepeaterRec;
+
+#define REP_DEF_DECAY 5 /* milliseconds */
+#define REP_DEF_INITIAL_DELAY 200 /* milliseconds */
+#define REP_DEF_MINIMUM_DELAY 10 /* milliseconds */
+#define REP_DEF_REPEAT_DELAY 50 /* milliseconds */
+
+/*
+ * external declarations
+ */
+extern RepeaterClassRec repeaterClassRec;
+
+#endif /* _XawRepeaterP_h */
diff --git a/include/X11/Xaw/Reports.h b/include/X11/Xaw/Reports.h
new file mode 100644
index 0000000..33f18d1
--- /dev/null
+++ b/include/X11/Xaw/Reports.h
@@ -0,0 +1,56 @@
+/*
+ * $Xorg: Reports.h,v 1.5 2001/02/09 02:03:45 xorgcvs Exp $
+ *
+Copyright 1990, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+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
+OPEN GROUP 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 Open Group 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 Open Group.
+ */
+
+#ifndef _Xaw_Reports_h
+#define _Xaw_Reports_h
+
+#include <X11/Intrinsic.h>
+
+/*
+ * XawPannerReport - this structure is used by the reportCallback of the
+ * Panner, Porthole, Viewport, and Scrollbar widgets to report its position.
+ * All fields must be filled in, although the changed field may be used as
+ * a hint as to which fields have been altered since the last report.
+ */
+typedef struct {
+ unsigned int changed; /* mask, see below */
+ Position slider_x, slider_y; /* location of slider within outer */
+ Dimension slider_width, slider_height; /* size of slider */
+ Dimension canvas_width, canvas_height; /* size of canvas */
+} XawPannerReport;
+
+#define XawPRSliderX (1 << 0)
+#define XawPRSliderY (1 << 1)
+#define XawPRSliderWidth (1 << 2)
+#define XawPRSliderHeight (1 << 3)
+#define XawPRCanvasWidth (1 << 4)
+#define XawPRCanvasHeight (1 << 5)
+#define XawPRAll (63) /* union of above */
+
+#define XtNreportCallback "reportCallback"
+#define XtCReportCallback "reportCallback"
+
+#endif /* _Xaw_Reports_h */
diff --git a/include/X11/Xaw/Scrollbar.h b/include/X11/Xaw/Scrollbar.h
new file mode 100644
index 0000000..877f81f
--- /dev/null
+++ b/include/X11/Xaw/Scrollbar.h
@@ -0,0 +1,143 @@
+/* $Xorg: Scrollbar.h,v 1.4 2001/02/09 02:03:45 xorgcvs Exp $ */
+
+
+/***********************************************************
+
+Copyright 1987, 1988, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+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
+OPEN GROUP 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 Open Group 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 Open Group.
+
+
+Copyright 1987, 1988 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+******************************************************************/
+
+#ifndef _Scrollbar_h
+#define _Scrollbar_h
+
+/****************************************************************
+ *
+ * Scrollbar Widget
+ *
+ ****************************************************************/
+
+#include <X11/Xmu/Converters.h>
+#include <X11/Xfuncproto.h>
+
+/* Scrollbar resources:
+
+ Name Class RepType Default Value
+ ---- ----- ------- -------------
+ accelerators Accelerators AcceleratorTable NULL
+ ancestorSensitive AncestorSensitive Boolean True
+ background Background Pixel XtDefaultBackground
+ backgroundPixmap Pixmap Pixmap XtUnspecifiedPixmap
+ borderColor BorderColor Pixel XtDefaultForeground
+ borderPixmap Pixmap Pixmap XtUnspecifiedPixmap
+ borderWidth BorderWidth Dimension 1
+ colormap Colormap Colormap parent's colormap
+ cursor Cursor Cursor None
+ cursorName Cursor String NULL
+ depth Depth int parent's depth
+ destroyCallback Callback XtCallbackList NULL
+ foreground Foreground Pixel XtDefaultForeground
+ height Height Dimension length or thickness
+ insensitiveBorder Insensitive Pixmap GreyPixmap
+ jumpProc Callback XtCallbackList NULL
+ length Length Dimension 1
+ mappedWhenManaged MappedWhenManaged Boolean True
+ minimumThumb MinimumThumb Dimension 7
+ orientation Orientation XtOrientation XtorientVertical
+ pointerColor Foreground Pixel XtDefaultForeground
+ pointerColorBackground Background Pixel XtDefaultBackground
+ screen Screen Screen parent's screen
+ scrollDCursor Cursor Cursor XC_sb_down_arrow
+ scrollHCursor Cursor Cursor XC_sb_h_double_arrow
+ scrollLCursor Cursor Cursor XC_sb_left_arrow
+ scrollProc Callback XtCallbackList NULL
+ scrollRCursor Cursor Cursor XC_sb_right_arrow
+ scrollUCursor Cursor Cursor XC_sb_up_arrow
+ scrollVCursor Cursor Cursor XC_sb_v_double_arrow
+ sensitive Sensitive Boolean True
+ shown Shown Float 0.0
+ thickness Thickness Dimension 14
+ thumb Thumb Bitmap GreyPixmap
+ thumbProc Callback XtCallbackList NULL
+ topOfThumb TopOfThumb Float 0.0
+ translations Translations TranslationTable see source or doc
+ width Width Dimension thickness or length
+ x Position Position 0
+ y Position Position 0
+
+*/
+
+/*
+ * Most things we need are in StringDefs.h
+ */
+
+#define XtCMinimumThumb "MinimumThumb"
+#define XtCShown "Shown"
+#define XtCTopOfThumb "TopOfThumb"
+
+#define XtNminimumThumb "minimumThumb"
+#define XtNtopOfThumb "topOfThumb"
+
+typedef struct _ScrollbarRec *ScrollbarWidget;
+typedef struct _ScrollbarClassRec *ScrollbarWidgetClass;
+
+extern WidgetClass scrollbarWidgetClass;
+
+_XFUNCPROTOBEGIN
+
+extern void XawScrollbarSetThumb(
+#if NeedFunctionPrototypes
+ Widget /* scrollbar */,
+#if NeedWidePrototypes
+ /* float */ double /* top */,
+ /* float */ double /* shown */
+#else
+ float /* top */,
+ float /* shown */
+#endif
+#endif
+);
+
+_XFUNCPROTOEND
+
+#endif /* _Scrollbar_h */
diff --git a/include/X11/Xaw/ScrollbarP.h b/include/X11/Xaw/ScrollbarP.h
new file mode 100644
index 0000000..250afbb
--- /dev/null
+++ b/include/X11/Xaw/ScrollbarP.h
@@ -0,0 +1,104 @@
+/*
+ * $Xorg: ScrollbarP.h,v 1.4 2001/02/09 02:03:45 xorgcvs Exp $
+ */
+
+
+/***********************************************************
+
+Copyright 1987, 1988, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+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
+OPEN GROUP 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 Open Group 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 Open Group.
+
+
+Copyright 1987, 1988 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+******************************************************************/
+
+#ifndef _ScrollbarP_h
+#define _ScrollbarP_h
+
+#include <X11/Xaw/Scrollbar.h>
+#include <X11/Xaw/SimpleP.h>
+
+typedef struct {
+ /* public */
+ Pixel foreground; /* thumb foreground color */
+ XtOrientation orientation; /* horizontal or vertical */
+ XtCallbackList scrollProc; /* proportional scroll */
+ XtCallbackList thumbProc; /* jump (to position) scroll */
+ XtCallbackList jumpProc; /* same as thumbProc but pass data by ref */
+ Pixmap thumb; /* thumb color */
+ Cursor upCursor; /* scroll up cursor */
+ Cursor downCursor; /* scroll down cursor */
+ Cursor leftCursor; /* scroll left cursor */
+ Cursor rightCursor; /* scroll right cursor */
+ Cursor verCursor; /* scroll vertical cursor */
+ Cursor horCursor; /* scroll horizontal cursor */
+ float top; /* What percent is above the win's top */
+ float shown; /* What percent is shown in the win */
+ Dimension length; /* either height or width */
+ Dimension thickness; /* either width or height */
+ Dimension min_thumb; /* minium size for the thumb. */
+
+ /* private */
+ Cursor inactiveCursor; /* The normal cursor for scrollbar */
+ char direction; /* a scroll has started; which direction */
+ GC gc; /* a (shared) gc */
+ Position topLoc; /* Pixel that corresponds to top */
+ Dimension shownLength; /* Num pixels corresponding to shown */
+
+} ScrollbarPart;
+
+typedef struct _ScrollbarRec {
+ CorePart core;
+ SimplePart simple;
+ ScrollbarPart scrollbar;
+} ScrollbarRec;
+
+typedef struct {int empty;} ScrollbarClassPart;
+
+typedef struct _ScrollbarClassRec {
+ CoreClassPart core_class;
+ SimpleClassPart simple_class;
+ ScrollbarClassPart scrollbar_class;
+} ScrollbarClassRec;
+
+extern ScrollbarClassRec scrollbarClassRec;
+
+#endif /* _ScrollbarP_h */
diff --git a/include/X11/Xaw/Simple.h b/include/X11/Xaw/Simple.h
new file mode 100644
index 0000000..e50cccf
--- /dev/null
+++ b/include/X11/Xaw/Simple.h
@@ -0,0 +1,102 @@
+/* $Xorg: Simple.h,v 1.4 2001/02/09 02:03:45 xorgcvs Exp $ */
+
+/***********************************************************
+
+Copyright 1987, 1988, 1994, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+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
+OPEN GROUP 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 Open Group 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 Open Group.
+
+
+Copyright 1987, 1988 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+******************************************************************/
+
+#ifndef _Simple_h
+#define _Simple_h
+
+#include <X11/Xmu/Converters.h>
+
+/****************************************************************
+ *
+ * Simple widgets
+ *
+ ****************************************************************/
+
+/* Resources:
+
+ Name Class RepType Default Value
+ ---- ----- ------- -------------
+ background Background Pixel XtDefaultBackground
+ border BorderColor Pixel XtDefaultForeground
+ borderWidth BorderWidth Dimension 1
+ cursor Cursor Cursor None
+ cursorName Cursor String NULL
+ destroyCallback Callback Pointer NULL
+ height Height Dimension 0
+ insensitiveBorder Insensitive Pixmap Gray
+ mappedWhenManaged MappedWhenManaged Boolean True
+ pointerColor Foreground Pixel XtDefaultForeground
+ pointerColorBackground Background Pixel XtDefaultBackground
+ sensitive Sensitive Boolean True
+ width Width Dimension 0
+ x Position Position 0
+ y Position Position 0
+
+*/
+
+#define XtNcursor "cursor"
+#define XtNcursorName "cursorName"
+#define XtNinsensitiveBorder "insensitiveBorder"
+
+#define XtCInsensitive "Insensitive"
+
+#ifndef XtCInternational
+#define XtCInternational "International"
+#endif
+
+#ifndef XtNinternational
+#define XtNinternational "international"
+#endif
+
+typedef struct _SimpleClassRec *SimpleWidgetClass;
+typedef struct _SimpleRec *SimpleWidget;
+
+extern WidgetClass simpleWidgetClass;
+
+#endif /* _Simple_h */
diff --git a/include/X11/Xaw/SimpleMenP.h b/include/X11/Xaw/SimpleMenP.h
new file mode 100644
index 0000000..6e6dc7d
--- /dev/null
+++ b/include/X11/Xaw/SimpleMenP.h
@@ -0,0 +1,98 @@
+/*
+ * $Xorg: SimpleMenP.h,v 1.4 2001/02/09 02:03:45 xorgcvs Exp $
+ *
+Copyright 1989, 1994, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+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
+OPEN GROUP 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 Open Group 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 Open Group.
+ *
+ */
+
+/*
+ * SimpleMenuP.h - Private Header file for SimpleMenu widget.
+ *
+ * Date: April 3, 1989
+ *
+ * By: Chris D. Peterson
+ * MIT X Consortium
+ * kit@expo.lcs.mit.edu
+ */
+
+#ifndef _SimpleMenuP_h
+#define _SimpleMenuP_h
+
+#include <X11/Xaw/SimpleMenu.h>
+#include <X11/Xaw/SmeP.h>
+#include <X11/ShellP.h>
+
+typedef struct {
+ XtPointer extension; /* For future needs. */
+} SimpleMenuClassPart;
+
+typedef struct _SimpleMenuClassRec {
+ CoreClassPart core_class;
+ CompositeClassPart composite_class;
+ ShellClassPart shell_class;
+ OverrideShellClassPart override_shell_class;
+ SimpleMenuClassPart simpleMenu_class;
+} SimpleMenuClassRec;
+
+extern SimpleMenuClassRec simpleMenuClassRec;
+
+typedef struct _SimpleMenuPart {
+
+ /* resources */
+
+ String label_string; /* The string for the label or NULL. */
+ SmeObject label; /* If label_string is non-NULL then this is
+ the label widget. */
+ WidgetClass label_class; /* Widget Class of the menu label object. */
+
+ Dimension top_margin; /* Top and bottom margins. */
+ Dimension bottom_margin;
+ Dimension row_height; /* height of each row (menu entry) */
+
+ Cursor cursor; /* The menu's cursor. */
+ SmeObject popup_entry; /* The entry to position the cursor on for
+ when using XawPositionSimpleMenu. */
+ Boolean menu_on_screen; /* Force the menus to be fully on the screen.*/
+ int backing_store; /* What type of backing store to use. */
+
+ /* private state */
+
+ Boolean recursive_set_values; /* contain a possible infinite loop. */
+
+ Boolean menu_width; /* If true then force width to remain
+ core.width */
+ Boolean menu_height; /* Just like menu_width, but for height. */
+
+ SmeObject entry_set; /* The entry that is currently set or
+ highlighted. */
+} SimpleMenuPart;
+
+typedef struct _SimpleMenuRec {
+ CorePart core;
+ CompositePart composite;
+ ShellPart shell;
+ OverrideShellPart override;
+ SimpleMenuPart simple_menu;
+} SimpleMenuRec;
+
+#endif /* _SimpleMenuP_h */
diff --git a/include/X11/Xaw/SimpleMenu.h b/include/X11/Xaw/SimpleMenu.h
new file mode 100644
index 0000000..3a59fc1
--- /dev/null
+++ b/include/X11/Xaw/SimpleMenu.h
@@ -0,0 +1,151 @@
+/*
+ * $Xorg: SimpleMenu.h,v 1.4 2001/02/09 02:03:45 xorgcvs Exp $
+ *
+Copyright 1989, 1994, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+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
+OPEN GROUP 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 Open Group 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 Open Group.
+ *
+ * Author: Chris D. Peterson, MIT X Consortium
+ */
+
+/*
+ * SimpleMenu.h - Public Header file for SimpleMenu widget.
+ *
+ * This is the public header file for the Athena SimpleMenu widget.
+ * It is intended to provide one pane pulldown and popup menus within
+ * the framework of the X Toolkit. As the name implies it is a first and
+ * by no means complete implementation of menu code. It does not attempt to
+ * fill the needs of all applications, but does allow a resource oriented
+ * interface to menus.
+ *
+ * Date: April 3, 1989
+ *
+ * By: Chris D. Peterson
+ * MIT X Consortium
+ * kit@expo.lcs.mit.edu
+ */
+
+#ifndef _SimpleMenu_h
+#define _SimpleMenu_h
+
+#include <X11/Shell.h>
+#include <X11/Xmu/Converters.h>
+
+/****************************************************************
+ *
+ * SimpleMenu widget
+ *
+ ****************************************************************/
+
+/* SimpleMenu Resources:
+
+ Name Class RepType Default Value
+ ---- ----- ------- -------------
+ background Background Pixel XtDefaultBackground
+ backgroundPixmap BackgroundPixmap Pixmap None
+ borderColor BorderColor Pixel XtDefaultForeground
+ borderPixmap BorderPixmap Pixmap None
+ borderWidth BorderWidth Dimension 1
+ bottomMargin VerticalMargins Dimension VerticalSpace
+ columnWidth ColumnWidth Dimension Width of widest text
+ cursor Cursor Cursor None
+ destroyCallback Callback Pointer NULL
+ height Height Dimension 0
+ label Label String NULL (No label)
+ labelClass LabelClass Pointer smeBSBObjectClass
+ mappedWhenManaged MappedWhenManaged Boolean True
+ rowHeight RowHeight Dimension Height of Font
+ sensitive Sensitive Boolean True
+ topMargin VerticalMargins Dimension VerticalSpace
+ width Width Dimension 0
+ x Position Position 0n
+ y Position Position 0
+
+*/
+
+typedef struct _SimpleMenuClassRec* SimpleMenuWidgetClass;
+typedef struct _SimpleMenuRec* SimpleMenuWidget;
+
+extern WidgetClass simpleMenuWidgetClass;
+
+#define XtNcursor "cursor"
+#define XtNbottomMargin "bottomMargin"
+#define XtNcolumnWidth "columnWidth"
+#define XtNlabelClass "labelClass"
+#define XtNmenuOnScreen "menuOnScreen"
+#define XtNpopupOnEntry "popupOnEntry"
+#define XtNrowHeight "rowHeight"
+#define XtNtopMargin "topMargin"
+
+#define XtCColumnWidth "ColumnWidth"
+#define XtCLabelClass "LabelClass"
+#define XtCMenuOnScreen "MenuOnScreen"
+#define XtCPopupOnEntry "PopupOnEntry"
+#define XtCRowHeight "RowHeight"
+#define XtCVerticalMargins "VerticalMargins"
+
+/************************************************************
+ *
+ * Public Functions.
+ *
+ ************************************************************/
+
+_XFUNCPROTOBEGIN
+
+/* Function Name: XawSimpleMenuAddGlobalActions
+ * Description: adds the global actions to the simple menu widget.
+ * Arguments: app_con - the appcontext.
+ * Returns: none.
+ */
+
+extern void XawSimpleMenuAddGlobalActions(
+#if NeedFunctionPrototypes
+ XtAppContext /* app_con */
+#endif
+);
+
+/* Function Name: XawSimpleMenuGetActiveEntry
+ * Description: Gets the currently active (set) entry.
+ * Arguments: w - the smw widget.
+ * Returns: the currently set entry or NULL if none is set.
+ */
+
+extern Widget XawSimpleMenuGetActiveEntry(
+#if NeedFunctionPrototypes
+ Widget /* w */
+#endif
+);
+
+/* Function Name: XawSimpleMenuClearActiveEntry
+ * Description: Unsets the currently active (set) entry.
+ * Arguments: w - the smw widget.
+ * Returns: none.
+ */
+
+extern void XawSimpleMenuClearActiveEntry(
+#if NeedFunctionPrototypes
+ Widget /* w */
+#endif
+);
+
+_XFUNCPROTOEND
+
+#endif /* _SimpleMenu_h */
diff --git a/include/X11/Xaw/SimpleP.h b/include/X11/Xaw/SimpleP.h
new file mode 100644
index 0000000..d052629
--- /dev/null
+++ b/include/X11/Xaw/SimpleP.h
@@ -0,0 +1,85 @@
+/***********************************************************
+
+ $Xorg: SimpleP.h,v 1.4 2001/02/09 02:03:45 xorgcvs Exp $
+
+
+Copyright 1987, 1988, 1994, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+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
+OPEN GROUP 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 Open Group 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 Open Group.
+
+
+Copyright 1987, 1988 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+******************************************************************/
+
+#ifndef _SimpleP_h
+#define _SimpleP_h
+
+#include <X11/Xaw/Simple.h>
+
+typedef struct {
+ Boolean (*change_sensitive)(/* widget */);
+} SimpleClassPart;
+
+#define XtInheritChangeSensitive ((Boolean (*)())_XtInherit)
+
+typedef struct _SimpleClassRec {
+ CoreClassPart core_class;
+ SimpleClassPart simple_class;
+} SimpleClassRec;
+
+extern SimpleClassRec simpleClassRec;
+
+typedef struct {
+ /* resources */
+ Cursor cursor;
+ Pixmap insensitive_border;
+ String cursor_name; /* cursor specified by name. */
+
+ Pixel pointer_fg, pointer_bg; /* Pointer colors. */
+ Boolean international;
+ /* private state */
+} SimplePart;
+
+typedef struct _SimpleRec {
+ CorePart core;
+ SimplePart simple;
+} SimpleRec;
+
+#endif /* _SimpleP_h */
diff --git a/include/X11/Xaw/Sme.h b/include/X11/Xaw/Sme.h
new file mode 100644
index 0000000..8315aa1
--- /dev/null
+++ b/include/X11/Xaw/Sme.h
@@ -0,0 +1,80 @@
+/*
+ * $Xorg: Sme.h,v 1.5 2001/02/09 02:03:45 xorgcvs Exp $
+ *
+Copyright 1989, 1994, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+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
+OPEN GROUP 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 Open Group 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 Open Group.
+ */
+
+/*
+ * Sme.h - Public Header file for Sme object.
+ *
+ * This is the public header file for the Athena Sme object.
+ * It is intended to be used with the simple menu widget.
+ *
+ * Date: April 3, 1989
+ *
+ * By: Chris D. Peterson
+ * MIT X Consortium
+ * kit@expo.lcs.mit.edu
+ */
+
+#ifndef _Sme_h
+#define _Sme_h
+
+#include <X11/Intrinsic.h>
+#include <X11/RectObj.h>
+
+/****************************************************************
+ *
+ * Sme Object
+ *
+ ****************************************************************/
+
+/* Simple Menu Entry Resources:
+
+ Name Class RepType Default Value
+ ---- ----- ------- -------------
+ callback Callback Pointer NULL
+ destroyCallback Callback Pointer NULL
+ height Height Dimension 0
+ sensitive Sensitive Boolean True
+ width Width Dimension 0
+ x Position Position 0n
+ y Position Position 0
+
+*/
+
+#ifndef XtCInternational
+#define XtCInternational "International"
+#endif
+
+#ifndef XtNinternational
+#define XtNinternational "international"
+#endif
+
+
+typedef struct _SmeClassRec* SmeObjectClass;
+typedef struct _SmeRec* SmeObject;
+
+extern WidgetClass smeObjectClass;
+
+#endif /* _Sme_h */
diff --git a/include/X11/Xaw/SmeBSB.h b/include/X11/Xaw/SmeBSB.h
new file mode 100644
index 0000000..0a7bc40
--- /dev/null
+++ b/include/X11/Xaw/SmeBSB.h
@@ -0,0 +1,100 @@
+/*
+ * $Xorg: SmeBSB.h,v 1.4 2001/02/09 02:03:45 xorgcvs Exp $
+ *
+Copyright 1989, 1994, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+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
+OPEN GROUP 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 Open Group 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 Open Group.
+ */
+
+/*
+ * SmeBSB.h - Public Header file for SmeBSB object.
+ *
+ * This is the public header file for the Athena BSB Sme object.
+ * It is intended to be used with the simple menu widget. This object
+ * provides bitmap - string - bitmap style entries.
+ *
+ * Date: April 3, 1989
+ *
+ * By: Chris D. Peterson
+ * MIT X Consortium
+ * kit@expo.lcs.mit.edu
+ */
+
+#ifndef _SmeBSB_h
+#define _SmeBSB_h
+
+#include <X11/Xmu/Converters.h>
+
+#include <X11/Xaw/Sme.h>
+
+/****************************************************************
+ *
+ * SmeBSB object
+ *
+ ****************************************************************/
+
+/* BSB Menu Entry Resources:
+
+ Name Class RepType Default Value
+ ---- ----- ------- -------------
+ callback Callback Callback NULL
+ destroyCallback Callback Pointer NULL
+ font Font XFontStruct * XtDefaultFont
+ foreground Foreground Pixel XtDefaultForeground
+ height Height Dimension 0
+ label Label String Name of entry
+ leftBitmap LeftBitmap Pixmap None
+ leftMargin HorizontalMargins Dimension 4
+ rightBitmap RightBitmap Pixmap None
+ rightMargin HorizontalMargins Dimension 4
+ sensitive Sensitive Boolean True
+ vertSpace VertSpace int 25
+ width Width Dimension 0
+ x Position Position 0n
+ y Position Position 0
+
+*/
+
+typedef struct _SmeBSBClassRec *SmeBSBObjectClass;
+typedef struct _SmeBSBRec *SmeBSBObject;
+
+extern WidgetClass smeBSBObjectClass;
+
+#define XtNleftBitmap "leftBitmap"
+#define XtNleftMargin "leftMargin"
+#define XtNrightBitmap "rightBitmap"
+#define XtNrightMargin "rightMargin"
+#define XtNvertSpace "vertSpace"
+
+#ifndef XtNfontSet
+#define XtNfontSet "fontSet"
+#endif
+
+#ifndef XtCFontSet
+#define XtCFontSet "FontSet"
+#endif
+
+#define XtCLeftBitmap "LeftBitmap"
+#define XtCHorizontalMargins "HorizontalMargins"
+#define XtCRightBitmap "RightBitmap"
+#define XtCVertSpace "VertSpace"
+
+#endif /* _SmeBSB_h */
diff --git a/include/X11/Xaw/SmeBSBP.h b/include/X11/Xaw/SmeBSBP.h
new file mode 100644
index 0000000..c3521eb
--- /dev/null
+++ b/include/X11/Xaw/SmeBSBP.h
@@ -0,0 +1,112 @@
+/*
+ * $Xorg: SmeBSBP.h,v 1.4 2001/02/09 02:03:45 xorgcvs Exp $
+ *
+Copyright 1989, 1994, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+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
+OPEN GROUP 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 Open Group 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 Open Group.
+ *
+ * Author: Chris D. Peterson, MIT X Consortium
+ */
+
+/*
+ * SmeP.h - Private definitions for Sme object
+ *
+ */
+
+#ifndef _XawSmeBSBP_h
+#define _XawSmeBSBP_h
+
+/***********************************************************************
+ *
+ * Sme Object Private Data
+ *
+ ***********************************************************************/
+
+#include <X11/Xaw/SmeP.h>
+#include <X11/Xaw/SmeBSB.h>
+
+/************************************************************
+ *
+ * New fields for the Sme Object class record.
+ *
+ ************************************************************/
+
+typedef struct _SmeBSBClassPart {
+ XtPointer extension;
+} SmeBSBClassPart;
+
+/* Full class record declaration */
+typedef struct _SmeBSBClassRec {
+ RectObjClassPart rect_class;
+ SmeClassPart sme_class;
+ SmeBSBClassPart sme_bsb_class;
+} SmeBSBClassRec;
+
+extern SmeBSBClassRec smeBSBClassRec;
+
+/* New fields for the Sme Object record */
+typedef struct {
+ /* resources */
+ String label; /* The entry label. */
+ int vert_space; /* extra vert space to leave, as a percentage
+ of the font height of the label. */
+ Pixmap left_bitmap, right_bitmap; /* bitmaps to show. */
+ Dimension left_margin, right_margin; /* left and right margins. */
+ Pixel foreground; /* foreground color. */
+ XFontStruct * font; /* The font to show label in. */
+ XFontSet fontset; /* or fontset*/
+ XtJustify justify; /* Justification for the label. */
+
+/* private resources. */
+
+ Boolean set_values_area_cleared; /* Remember if we need to unhighlight. */
+ GC norm_gc; /* noral color gc. */
+ GC rev_gc; /* reverse color gc. */
+ GC norm_gray_gc; /* Normal color (grayed out) gc. */
+ GC invert_gc; /* gc for flipping colors. */
+
+ Dimension left_bitmap_width; /* size of each bitmap. */
+ Dimension left_bitmap_height;
+ Dimension right_bitmap_width;
+ Dimension right_bitmap_height;
+
+} SmeBSBPart;
+
+/****************************************************************
+ *
+ * Full instance record declaration
+ *
+ ****************************************************************/
+
+typedef struct _SmeBSBRec {
+ ObjectPart object;
+ RectObjPart rectangle;
+ SmePart sme;
+ SmeBSBPart sme_bsb;
+} SmeBSBRec;
+
+/************************************************************
+ *
+ * Private declarations.
+ *
+ ************************************************************/
+
+#endif /* _XawSmeBSBP_h */
diff --git a/include/X11/Xaw/SmeLine.h b/include/X11/Xaw/SmeLine.h
new file mode 100644
index 0000000..bd529f3
--- /dev/null
+++ b/include/X11/Xaw/SmeLine.h
@@ -0,0 +1,78 @@
+/*
+ * $Xorg: SmeLine.h,v 1.4 2001/02/09 02:03:45 xorgcvs Exp $
+ *
+Copyright 1989, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+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
+OPEN GROUP 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 Open Group 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 Open Group.
+ *
+ */
+
+/*
+ * SmeLine.h - Public Header file for SmeLine object.
+ *
+ * This is the public header file for the Athena SmeLine object.
+ * It is intended to be used with the simple menu widget.
+ *
+ * Date: April 3, 1989
+ *
+ * By: Chris D. Peterson
+ * MIT X Consortium
+ * kit@expo.lcs.mit.edu
+ */
+
+#ifndef _SmeLine_h
+#define _SmeLine_h
+
+#include <X11/Xaw/Sme.h>
+#include <X11/Xmu/Converters.h>
+
+/****************************************************************
+ *
+ * SmeLine Object
+ *
+ ****************************************************************/
+
+/* Menu Entry Resources:
+
+ Name Class RepType Default Value
+ ---- ----- ------- -------------
+ callback Callback Pointer NULL
+ destroyCallback Callback Pointer NULL
+ height Height Dimension 0
+ sensitive Sensitive Boolean True
+ width Width Dimension 0
+ x Position Position 0n
+ y Position Position 0
+
+*/
+
+#define XtCLineWidth "LineWidth"
+#define XtCStipple "Stipple"
+
+#define XtNlineWidth "lineWidth"
+#define XtNstipple "stipple"
+
+typedef struct _SmeLineClassRec* SmeLineObjectClass;
+typedef struct _SmeLineRec* SmeLineObject;
+
+extern WidgetClass smeLineObjectClass;
+
+#endif /* _SmeLine_h */
diff --git a/include/X11/Xaw/SmeLineP.h b/include/X11/Xaw/SmeLineP.h
new file mode 100644
index 0000000..32831f7
--- /dev/null
+++ b/include/X11/Xaw/SmeLineP.h
@@ -0,0 +1,96 @@
+/*
+ * $Xorg: SmeLineP.h,v 1.4 2001/02/09 02:03:46 xorgcvs Exp $
+ *
+Copyright 1989, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+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
+OPEN GROUP 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 Open Group 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 Open Group.
+ *
+ * Author: Chris D. Peterson, MIT X Consortium
+ */
+
+/*
+ * SmeLineP.h - Private definitions for SmeLine widget
+ *
+ */
+
+#ifndef _XawSmeLineP_h
+#define _XawSmeLineP_h
+
+/***********************************************************************
+ *
+ * SmeLine Widget Private Data
+ *
+ ***********************************************************************/
+
+#include <X11/Xaw/SmeP.h>
+#include <X11/Xaw/SmeLine.h>
+
+/************************************************************
+ *
+ * New fields for the SmeLine widget class record.
+ *
+ ************************************************************/
+
+typedef struct _SmeLineClassPart {
+ XtPointer extension;
+} SmeLineClassPart;
+
+/* Full class record declaration */
+typedef struct _SmeLineClassRec {
+ RectObjClassPart rect_class;
+ SmeClassPart sme_class;
+ SmeLineClassPart sme_line_class;
+} SmeLineClassRec;
+
+extern SmeLineClassRec smeLineClassRec;
+
+/* New fields for the SmeLine widget record */
+typedef struct {
+ /* resources */
+ Pixel foreground; /* Foreground color. */
+ Pixmap stipple; /* Line Stipple. */
+ Dimension line_width; /* Width of the line. */
+
+ /* private data. */
+
+ GC gc; /* Graphics context for drawing line. */
+} SmeLinePart;
+
+/****************************************************************
+ *
+ * Full instance record declaration
+ *
+ ****************************************************************/
+
+typedef struct _SmeLineRec {
+ ObjectPart object;
+ RectObjPart rectangle;
+ SmePart sme;
+ SmeLinePart sme_line;
+} SmeLineRec;
+
+/************************************************************
+ *
+ * Private declarations.
+ *
+ ************************************************************/
+
+#endif /* _XawSmeLineP_h */
diff --git a/include/X11/Xaw/SmeP.h b/include/X11/Xaw/SmeP.h
new file mode 100644
index 0000000..9a5d9fd
--- /dev/null
+++ b/include/X11/Xaw/SmeP.h
@@ -0,0 +1,104 @@
+/*
+ * $Xorg: SmeP.h,v 1.4 2001/02/09 02:03:46 xorgcvs Exp $
+ *
+Copyright 1989, 1994, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+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
+OPEN GROUP 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 Open Group 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 Open Group.
+ */
+
+/*
+ * SmeP.h - Private Header file for Sme object.
+ *
+ * This is the private header file for the Athena Sme object.
+ * This object is intended to be used with the simple menu widget.
+ *
+ * Date: April 3, 1989
+ *
+ * By: Chris D. Peterson
+ * MIT X Consortium
+ * kit@expo.lcs.mit.edu
+ */
+
+#ifndef _XawSmeP_h
+#define _XawSmeP_h
+
+/***********************************************************************
+ *
+ * Sme Widget Private Data
+ *
+ ***********************************************************************/
+
+#include <X11/Xaw/Sme.h>
+
+/************************************************************
+ *
+ * New fields for the Sme widget class record.
+ *
+ ************************************************************/
+
+typedef struct _SmeClassPart {
+ void (*highlight)();
+ void (*unhighlight)();
+ void (*notify)();
+ XtPointer extension;
+} SmeClassPart;
+
+/* Full class record declaration */
+typedef struct _SmeClassRec {
+ RectObjClassPart rect_class;
+ SmeClassPart sme_class;
+} SmeClassRec;
+
+extern SmeClassRec smeClassRec;
+
+/* New fields for the Sme widget record */
+typedef struct {
+ /* resources */
+ XtCallbackList callbacks; /* The callback list */
+ Boolean international;
+
+} SmePart;
+
+/****************************************************************
+ *
+ * Full instance record declaration
+ *
+ ****************************************************************/
+
+typedef struct _SmeRec {
+ ObjectPart object;
+ RectObjPart rectangle;
+ SmePart sme;
+} SmeRec;
+
+/************************************************************
+ *
+ * Private declarations.
+ *
+ ************************************************************/
+
+typedef void (*_XawEntryVoidFunc)();
+
+#define XtInheritHighlight ((_XawEntryVoidFunc) _XtInherit)
+#define XtInheritUnhighlight XtInheritHighlight
+#define XtInheritNotify XtInheritHighlight
+
+#endif /* _XawSmeP_h */
diff --git a/include/X11/Xaw/StripCharP.h b/include/X11/Xaw/StripCharP.h
new file mode 100644
index 0000000..19584cf
--- /dev/null
+++ b/include/X11/Xaw/StripCharP.h
@@ -0,0 +1,106 @@
+/*
+* $Xorg: StripCharP.h,v 1.4 2001/02/09 02:03:46 xorgcvs Exp $
+*/
+
+
+/***********************************************************
+
+Copyright 1987, 1988, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+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
+OPEN GROUP 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 Open Group 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 Open Group.
+
+
+Copyright 1987, 1988 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+******************************************************************/
+
+#ifndef _XawStripChartP_h
+#define _XawStripChartP_h
+
+#include <X11/Xaw/StripChart.h>
+#include <X11/Xaw/SimpleP.h>
+
+#define NO_GCS 0
+#define FOREGROUND 1 << 0
+#define HIGHLIGHT 1 << 1
+#define ALL_GCS (FOREGROUND | HIGHLIGHT)
+
+/* New fields for the stripChart widget instance record */
+
+typedef struct {
+ Pixel fgpixel; /* color index for graph */
+ Pixel hipixel; /* color index for lines */
+ GC fgGC; /* graphics context for fgpixel */
+ GC hiGC; /* graphics context for hipixel */
+
+ /* start of graph stuff */
+
+ int update; /* update frequence */
+ int scale; /* scale factor */
+ int min_scale; /* smallest scale factor */
+ int interval; /* data point interval */
+ XPoint * points ; /* Poly point for repairing graph lines. */
+ double max_value; /* Max Value in window */
+ double valuedata[2048];/* record of data points */
+ XtIntervalId interval_id;
+ XtCallbackList get_value; /* proc to call to fetch load pt */
+ int jump_val; /* Amount to jump on each scroll. */
+} StripChartPart;
+
+/* Full instance record declaration */
+typedef struct _StripChartRec {
+ CorePart core;
+ SimplePart simple;
+ StripChartPart strip_chart;
+} StripChartRec;
+
+/* New fields for the StripChart widget class record */
+typedef struct {int dummy;} StripChartClassPart;
+
+/* Full class record declaration. */
+typedef struct _StripChartClassRec {
+ CoreClassPart core_class;
+ SimpleClassPart simple_class;
+ StripChartClassPart strip_chart_class;
+} StripChartClassRec;
+
+/* Class pointer. */
+extern StripChartClassRec stripChartClassRec;
+
+#endif /* _XawStripChartP_h */
diff --git a/include/X11/Xaw/StripChart.h b/include/X11/Xaw/StripChart.h
new file mode 100644
index 0000000..325a6db
--- /dev/null
+++ b/include/X11/Xaw/StripChart.h
@@ -0,0 +1,119 @@
+/* $Xorg: StripChart.h,v 1.5 2001/02/09 02:03:46 xorgcvs Exp $ */
+
+/***********************************************************
+
+Copyright 1987, 1988, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+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
+OPEN GROUP 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 Open Group 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 Open Group.
+
+
+Copyright 1987, 1988 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+******************************************************************/
+
+#ifndef _XawStripChart_h
+#define _XawStripChart_h
+
+#include <X11/Intrinsic.h>
+
+/***********************************************************************
+ *
+ * StripChart Widget
+ *
+ ***********************************************************************/
+
+/* StripChart resources:
+
+ Name Class RepType Default Value
+ ---- ----- ------- -------------
+ accelerators Accelerators AcceleratorTable NULL
+ ancestorSensitive AncestorSensitive Boolean True
+ background Background Pixel XtDefaultBackground
+ backgroundPixmap Pixmap Pixmap XtUnspecifiedPixmap
+ borderColor BorderColor Pixel XtDefaultForeground
+ borderPixmap Pixmap Pixmap XtUnspecifiedPixmap
+ borderWidth BorderWidth Dimension 1
+ colormap Colormap Colormap parent's colormap
+ cursor Cursor Cursor None
+ cursorName Cursor String NULL
+ depth Depth int parent's depth
+ destroyCallback Callback XtCallbackList NULL
+ foreground Foreground Pixel XtDefaultForeground
+ getValue Callback XtCallbackList NULL
+ height Height Dimension 120
+ highlight Foreground Pixel XtDefaultForeground
+ insensitiveBorder Insensitive Pixmap GreyPixmap
+ jumpScroll JumpScroll int 1/2 width
+ mappedWhenManaged MappedWhenManaged Boolean True
+ minScale Scale int 1
+ pointerColor Foreground Pixel XtDefaultForeground
+ pointerColorBackground Background Pixel XtDefaultBackground
+ screen Screen Screen parent's screen
+ sensitive Sensitive Boolean True
+ translations Translations TranslationTable NULL
+ update Interval int 10 (seconds)
+ width Width Dimension 120
+ x Position Position 0
+ y Position Position 0
+
+*/
+
+#define DEFAULT_JUMP -1
+
+#ifndef _XtStringDefs_h_
+#define XtNhighlight "highlight"
+#define XtNupdate "update"
+#endif
+
+#define XtCJumpScroll "JumpScroll"
+#define XtCScale "Scale"
+
+#define XtNgetValue "getValue"
+#define XtNjumpScroll "jumpScroll"
+#define XtNminScale "minScale"
+#define XtNscale "scale"
+#define XtNvmunix "vmunix"
+
+typedef struct _StripChartRec *StripChartWidget;
+typedef struct _StripChartClassRec *StripChartWidgetClass;
+
+extern WidgetClass stripChartWidgetClass;
+
+#endif /* _XawStripChart_h */
+/* DON'T ADD STUFF AFTER THIS #endif */
diff --git a/include/X11/Xaw/Template.c b/include/X11/Xaw/Template.c
new file mode 100644
index 0000000..8f9ba8b
--- /dev/null
+++ b/include/X11/Xaw/Template.c
@@ -0,0 +1,93 @@
+/* $Xorg: Template.c,v 1.4 2001/02/09 02:03:46 xorgcvs Exp $ */
+
+/*
+
+Copyright 1987, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+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
+OPEN GROUP 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 Open Group 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 Open Group.
+
+*/
+
+#include <X11/IntrinsicP.h>
+#include <X11/StringDefs.h>
+#include "TemplateP.h"
+
+static XtResource resources[] = {
+#define offset(field) XtOffsetOf(TemplateRec, template.field)
+ /* {name, class, type, size, offset, default_type, default_addr}, */
+ { XtNtemplateResource, XtCTemplateResource, XtRTemplateResource,
+ sizeof(char*), offset(resource), XtRString, (XtPointer) "default" },
+#undef offset
+};
+
+static void TemplateAction(/* Widget, XEvent*, String*, Cardinal* */);
+
+static XtActionsRec actions[] =
+{
+ /* {name, procedure}, */
+ {"template", TemplateAction},
+};
+
+static char translations[] =
+"<Key>: template() \n\
+";
+
+TemplateClassRec templateClassRec = {
+ { /* core fields */
+ /* superclass */ (WidgetClass) &widgetClassRec,
+ /* class_name */ "Template",
+ /* widget_size */ sizeof(TemplateRec),
+ /* class_initialize */ NULL,
+ /* class_part_initialize */ NULL,
+ /* class_inited */ FALSE,
+ /* initialize */ NULL,
+ /* initialize_hook */ NULL,
+ /* realize */ XtInheritRealize,
+ /* actions */ actions,
+ /* num_actions */ XtNumber(actions),
+ /* resources */ resources,
+ /* num_resources */ XtNumber(resources),
+ /* xrm_class */ NULLQUARK,
+ /* compress_motion */ TRUE,
+ /* compress_exposure */ TRUE,
+ /* compress_enterleave */ TRUE,
+ /* visible_interest */ FALSE,
+ /* destroy */ NULL,
+ /* resize */ NULL,
+ /* expose */ NULL,
+ /* set_values */ NULL,
+ /* set_values_hook */ NULL,
+ /* set_values_almost */ XtInheritSetValuesAlmost,
+ /* get_values_hook */ NULL,
+ /* accept_focus */ NULL,
+ /* version */ XtVersion,
+ /* callback_private */ NULL,
+ /* tm_table */ translations,
+ /* query_geometry */ XtInheritQueryGeometry,
+ /* display_accelerator */ XtInheritDisplayAccelerator,
+ /* extension */ NULL
+ },
+ { /* template fields */
+ /* empty */ 0
+ }
+};
+
+WidgetClass templateWidgetClass = (WidgetClass)&templateClassRec;
diff --git a/include/X11/Xaw/Template.h b/include/X11/Xaw/Template.h
new file mode 100644
index 0000000..d51e228
--- /dev/null
+++ b/include/X11/Xaw/Template.h
@@ -0,0 +1,72 @@
+/* $Xorg: Template.h,v 1.5 2001/02/09 02:03:46 xorgcvs Exp $ */
+
+/*
+
+Copyright 1987, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+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
+OPEN GROUP 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 Open Group 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 Open Group.
+
+*/
+
+#ifndef _Template_h
+#define _Template_h
+
+#include <X11/Intrinsic.h>
+
+/****************************************************************
+ *
+ * Template widget
+ *
+ ****************************************************************/
+
+/* Resources:
+
+ Name Class RepType Default Value
+ ---- ----- ------- -------------
+ background Background Pixel XtDefaultBackground
+ border BorderColor Pixel XtDefaultForeground
+ borderWidth BorderWidth Dimension 1
+ destroyCallback Callback Pointer NULL
+ height Height Dimension 0
+ mappedWhenManaged MappedWhenManaged Boolean True
+ sensitive Sensitive Boolean True
+ width Width Dimension 0
+ x Position Position 0
+ y Position Position 0
+
+*/
+
+/* define any special resource names here that are not in <X11/StringDefs.h> */
+
+#define XtNtemplateResource "templateResource"
+
+#define XtCTemplateResource "TemplateResource"
+
+/* declare specific TemplateWidget class and instance datatypes */
+
+typedef struct _TemplateClassRec* TemplateWidgetClass;
+typedef struct _TemplateRec* TemplateWidget;
+
+/* declare the class constant */
+
+extern WidgetClass templateWidgetClass;
+
+#endif /* _Template_h */
diff --git a/include/X11/Xaw/TemplateP.h b/include/X11/Xaw/TemplateP.h
new file mode 100644
index 0000000..08488ed
--- /dev/null
+++ b/include/X11/Xaw/TemplateP.h
@@ -0,0 +1,67 @@
+/* $Xorg: TemplateP.h,v 1.5 2001/02/09 02:03:46 xorgcvs Exp $ */
+
+/*
+
+Copyright 1987, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+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
+OPEN GROUP 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 Open Group 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 Open Group.
+
+*/
+
+
+#ifndef _TemplateP_h
+#define _TemplateP_h
+
+#include <X11/Xaw/Template.h>
+/* include superclass private header file */
+#include <X11/CoreP.h>
+
+/* define unique representation types not found in <X11/StringDefs.h> */
+
+#define XtRTemplateResource "TemplateResource"
+
+typedef struct {
+ int empty;
+} TemplateClassPart;
+
+typedef struct _TemplateClassRec {
+ CoreClassPart core_class;
+ TemplateClassPart template_class;
+} TemplateClassRec;
+
+extern TemplateClassRec templateClassRec;
+
+typedef struct {
+ /* resources */
+ char* resource;
+ /* private state */
+} TemplatePart;
+
+typedef struct _TemplateRec {
+ CorePart core;
+#if defined(__cplusplus) || defined(c_plusplus)
+ TemplatePart c_template;
+#else
+ TemplatePart template;
+#endif
+} TemplateRec;
+
+#endif /* _TemplateP_h */
diff --git a/include/X11/Xaw/Text.h b/include/X11/Xaw/Text.h
new file mode 100644
index 0000000..84f2a3f
--- /dev/null
+++ b/include/X11/Xaw/Text.h
@@ -0,0 +1,309 @@
+/* $Xorg: Text.h,v 1.4 2001/02/09 02:03:46 xorgcvs Exp $ */
+
+/***********************************************************
+
+Copyright 1987, 1988, 1994, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+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
+OPEN GROUP 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 Open Group 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 Open Group.
+
+
+Copyright 1987, 1988 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+******************************************************************/
+
+#ifndef _XawText_h
+#define _XawText_h
+
+#include <X11/Xaw/Simple.h>
+
+/*
+ Text widget
+
+ Class: textWidgetClass
+ Class Name: Text
+ Superclass: Simple
+
+ Resources added by the Text widget:
+
+ Name Class RepType Default Value
+ ---- ----- ------- -------------
+ autoFill AutoFill Boolean False
+ bottomMargin Margin Position 2
+ displayPosition TextPosition XawTextPosition 0
+ insertPosition TextPosition XawTextPosition 0
+ leftMargin Margin Position 2
+ resize Resize XawTextResizeMode XawTextResizeNever
+ rightMargin Margin Position 4
+ scrollHorizontal Scroll XawTextScrollMode XawtextScrollNever
+ scrollVertical Scroll XawTextScrollMode XawtextScrollNever
+ selectTypes SelectTypes Pointer see documentation
+ textSink TextSink Widget NULL
+ textSource TextSource Widget NULL
+ topMargin Margin Position 2
+ unrealizeCallback Callback Callback NULL
+ wrap Wrap XawTextWrapMode XawTextWrapNever
+
+*/
+
+typedef long XawTextPosition;
+
+typedef enum { XawtextScrollNever,
+ XawtextScrollWhenNeeded, XawtextScrollAlways} XawTextScrollMode;
+
+typedef enum { XawtextWrapNever,
+ XawtextWrapLine, XawtextWrapWord} XawTextWrapMode;
+
+typedef enum { XawtextResizeNever, XawtextResizeWidth,
+ XawtextResizeHeight, XawtextResizeBoth} XawTextResizeMode;
+
+typedef enum {XawsdLeft, XawsdRight} XawTextScanDirection;
+typedef enum {XawtextRead, XawtextAppend, XawtextEdit} XawTextEditType;
+typedef enum {XawselectNull, XawselectPosition, XawselectChar, XawselectWord,
+ XawselectLine, XawselectParagraph, XawselectAll} XawTextSelectType;
+
+typedef struct {
+ int firstPos;
+ int length;
+ char *ptr;
+ unsigned long format;
+ } XawTextBlock, *XawTextBlockPtr;
+
+#include <X11/Xaw/TextSink.h>
+#include <X11/Xaw/TextSrc.h>
+
+#define XtEtextScrollNever "never"
+#define XtEtextScrollWhenNeeded "whenneeded"
+#define XtEtextScrollAlways "always"
+
+#define XtEtextWrapNever "never"
+#define XtEtextWrapLine "line"
+#define XtEtextWrapWord "word"
+
+#define XtEtextResizeNever "never"
+#define XtEtextResizeWidth "width"
+#define XtEtextResizeHeight "height"
+#define XtEtextResizeBoth "both"
+
+#define XtNautoFill "autoFill"
+#define XtNbottomMargin "bottomMargin"
+#define XtNdialogHOffset "dialogHOffset"
+#define XtNdialogVOffset "dialogVOffset"
+#define XtNdisplayCaret "displayCaret"
+#define XtNdisplayPosition "displayPosition"
+#define XtNleftMargin "leftMargin"
+#define XtNrightMargin "rightMargin"
+#define XtNscrollVertical "scrollVertical"
+#define XtNscrollHorizontal "scrollHorizontal"
+#define XtNselectTypes "selectTypes"
+#define XtNtopMargin "topMargin"
+#define XtNwrap "wrap"
+
+#define XtCAutoFill "AutoFill"
+#define XtCScroll "Scroll"
+#define XtCSelectTypes "SelectTypes"
+#define XtCWrap "Wrap"
+
+#ifndef _XtStringDefs_h_
+#define XtNinsertPosition "insertPosition"
+#define XtNresize "resize"
+#define XtNselection "selection"
+#define XtCResize "Resize"
+#endif
+
+/* Return Error code for XawTextSearch */
+
+#define XawTextSearchError (-12345L)
+
+/* Return codes from XawTextReplace */
+
+#define XawReplaceError -1
+#define XawEditDone 0
+#define XawEditError 1
+#define XawPositionError 2
+
+extern unsigned long FMT8BIT;
+extern unsigned long XawFmt8Bit;
+extern unsigned long XawFmtWide;
+
+/* Class record constants */
+
+extern WidgetClass textWidgetClass;
+
+typedef struct _TextClassRec *TextWidgetClass;
+typedef struct _TextRec *TextWidget;
+
+_XFUNCPROTOBEGIN
+
+extern XrmQuark _XawTextFormat(
+#if NeedFunctionPrototypes
+ TextWidget /* tw */
+#endif
+);
+
+extern void XawTextDisplay(
+#if NeedFunctionPrototypes
+ Widget /* w */
+#endif
+);
+
+extern void XawTextEnableRedisplay(
+#if NeedFunctionPrototypes
+ Widget /* w */
+#endif
+);
+
+extern void XawTextDisableRedisplay(
+#if NeedFunctionPrototypes
+ Widget /* w */
+#endif
+);
+
+extern void XawTextSetSelectionArray(
+#if NeedFunctionPrototypes
+ Widget /* w */,
+ XawTextSelectType* /* sarray */
+#endif
+);
+
+extern void XawTextGetSelectionPos(
+#if NeedFunctionPrototypes
+ Widget /* w */,
+ XawTextPosition* /* begin_return */,
+ XawTextPosition* /* end_return */
+#endif
+);
+
+extern void XawTextSetSource(
+#if NeedFunctionPrototypes
+ Widget /* w */,
+ Widget /* source */,
+ XawTextPosition /* position */
+#endif
+);
+
+extern int XawTextReplace(
+#if NeedFunctionPrototypes
+ Widget /* w */,
+ XawTextPosition /* start */,
+ XawTextPosition /* end */,
+ XawTextBlock* /* text */
+#endif
+);
+
+extern XawTextPosition XawTextTopPosition(
+#if NeedFunctionPrototypes
+ Widget /* w */
+#endif
+);
+
+extern void XawTextSetInsertionPoint(
+#if NeedFunctionPrototypes
+ Widget /* w */,
+ XawTextPosition /* position */
+#endif
+);
+
+extern XawTextPosition XawTextGetInsertionPoint(
+#if NeedFunctionPrototypes
+ Widget /* w */
+#endif
+);
+
+extern void XawTextUnsetSelection(
+#if NeedFunctionPrototypes
+ Widget /* w */
+#endif
+);
+
+extern void XawTextSetSelection(
+#if NeedFunctionPrototypes
+ Widget /* w */,
+ XawTextPosition /* left */,
+ XawTextPosition /* right */
+#endif
+);
+
+extern void XawTextInvalidate(
+#if NeedFunctionPrototypes
+ Widget /* w */,
+ XawTextPosition /* from */,
+ XawTextPosition /* to */
+#endif
+);
+
+extern Widget XawTextGetSource(
+#if NeedFunctionPrototypes
+ Widget /* w */
+#endif
+);
+
+extern XawTextPosition XawTextSearch(
+#if NeedFunctionPrototypes
+ Widget /* w */,
+#if NeedWidePrototypes
+ /* XawTextScanDirection */ int /* dir */,
+#else
+ XawTextScanDirection /* dir */,
+#endif
+ XawTextBlock* /* text */
+#endif
+);
+
+extern void XawTextDisplayCaret(
+#if NeedFunctionPrototypes
+ Widget /* w */,
+#if NeedWidePrototypes
+ /* Boolean */ int /* visible */
+#else
+ Boolean /* visible */
+#endif
+#endif
+);
+
+_XFUNCPROTOEND
+
+/*
+ * For R3 compatability only.
+ */
+
+#include <X11/Xaw/AsciiSrc.h>
+#include <X11/Xaw/AsciiSink.h>
+
+#endif /* _XawText_h */
+/* DON'T ADD STUFF AFTER THIS #endif */
diff --git a/include/X11/Xaw/TextP.h b/include/X11/Xaw/TextP.h
new file mode 100644
index 0000000..f679db1
--- /dev/null
+++ b/include/X11/Xaw/TextP.h
@@ -0,0 +1,288 @@
+/*
+* $Xorg: TextP.h,v 1.4 2001/02/09 02:03:46 xorgcvs Exp $
+*/
+
+
+/***********************************************************
+
+Copyright 1987, 1988, 1994, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+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
+OPEN GROUP 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 Open Group 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 Open Group.
+
+
+Copyright 1987, 1988 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+******************************************************************/
+
+#ifndef _XawTextP_h
+#define _XawTextP_h
+
+#include <X11/Xaw/Text.h>
+#include <X11/Xaw/SimpleP.h>
+
+/****************************************************************
+ *
+ * Text widget private
+ *
+ ****************************************************************/
+#define MAXCUT 30000 /* Maximum number of characters that can be cut. */
+
+#define GETLASTPOS XawTextSourceScan(ctx->text.source, 0, \
+ XawstAll, XawsdRight, 1, TRUE)
+
+#define zeroPosition ((XawTextPosition) 0)
+
+extern XtActionsRec _XawTextActionsTable[];
+extern Cardinal _XawTextActionsTableCount;
+
+#define XawLF 0x0a
+#define XawCR 0x0d
+#define XawTAB 0x09
+#define XawBS 0x08
+#define XawSP 0x20
+#define XawDEL 0x7f
+#define XawESC 0x1b
+#define XawBSLASH '\\'
+
+/* constants that subclasses may want to know */
+#define DEFAULT_TEXT_HEIGHT ((Dimension)~0)
+
+/* displayable text management data structures */
+
+typedef struct {
+ XawTextPosition position;
+ Position y;
+ Dimension textWidth;
+} XawTextLineTableEntry, *XawTextLineTableEntryPtr;
+
+typedef struct {
+ XawTextPosition left, right;
+ XawTextSelectType type;
+ Atom* selections;
+ int atom_count;
+ int array_size;
+} XawTextSelection;
+
+typedef struct _XawTextSelectionSalt {
+ struct _XawTextSelectionSalt *next;
+ XawTextSelection s;
+ /*
+ * The element "contents" stores the CT string which is gotten in the
+ * function _XawTextSaltAwaySelection().
+ */
+ char *contents;
+ int length;
+} XawTextSelectionSalt;
+
+/* Line Tables are n+1 long - last position displayed is in last lt entry */
+typedef struct {
+ XawTextPosition top; /* Top of the displayed text. */
+ int lines; /* How many lines in this table. */
+ XawTextLineTableEntry *info; /* A dynamic array, one entry per line */
+} XawTextLineTable, *XawTextLineTablePtr;
+
+
+typedef struct _XawTextMargin {
+ Position left, right, top, bottom;
+} XawTextMargin;
+
+#define VMargins(ctx) ( (ctx)->text.margin.top + (ctx)->text.margin.bottom )
+#define HMargins(ctx) ( (ctx)->text.margin.left + (ctx)->text.margin.right )
+
+#define IsPositionVisible(ctx, pos) \
+ (pos >= ctx->text.lt.info[0].position && \
+ pos < ctx->text.lt.info[ctx->text.lt.lines].position)
+
+/*
+ * Search & Replace data structure.
+ */
+
+struct SearchAndReplace {
+ Boolean selection_changed; /* flag so that the selection cannot be
+ changed out from underneath query-replace.*/
+ Widget search_popup; /* The poppup widget that allows searches.*/
+ Widget label1; /* The label widgets for the search window. */
+ Widget label2;
+ Widget left_toggle; /* The left search toggle radioGroup. */
+ Widget right_toggle; /* The right search toggle radioGroup. */
+ Widget rep_label; /* The Replace label string. */
+ Widget rep_text; /* The Replace text field. */
+ Widget search_text; /* The Search text field. */
+ Widget rep_one; /* The Replace one button. */
+ Widget rep_all; /* The Replace all button. */
+};
+
+/* Private Text Definitions */
+
+typedef int (*ActionProc)();
+
+/* New fields for the Text widget class record */
+
+typedef struct {int empty;} TextClassPart;
+
+struct text_move {
+ int h, v;
+ struct text_move * next;
+};
+
+/* Full class record declaration */
+typedef struct _TextClassRec {
+ CoreClassPart core_class;
+ SimpleClassPart simple_class;
+ TextClassPart text_class;
+} TextClassRec;
+
+extern TextClassRec textClassRec;
+
+/* New fields for the Text widget record */
+typedef struct _TextPart {
+ /* resources */
+
+ Widget source, sink;
+ XawTextPosition insertPos;
+ XawTextSelection s;
+ XawTextSelectType *sarray; /* Array to cycle for selections. */
+ XawTextSelectionSalt *salt; /* salted away selections */
+ int options; /* wordbreak, scroll, etc. */
+ int dialog_horiz_offset; /* position for popup dialog */
+ int dialog_vert_offset; /* position for popup dialog */
+ Boolean display_caret; /* insertion pt visible iff T */
+ Boolean auto_fill; /* Auto fill mode? */
+ XawTextScrollMode scroll_vert, scroll_horiz; /*what type of scrollbars.*/
+ XawTextWrapMode wrap; /* The type of wrapping. */
+ XawTextResizeMode resize; /* what to resize */
+ XawTextMargin r_margin; /* The real margins. */
+ XtCallbackList unrealize_callbacks; /* used for scrollbars */
+
+ /* private state */
+
+ XawTextMargin margin; /* The current margins. */
+ XawTextLineTable lt;
+ XawTextScanDirection extendDir;
+ XawTextSelection origSel; /* the selection being modified */
+ Time lasttime; /* timestamp of last processed action */
+ Time time; /* time of last key or button action */
+ Position ev_x, ev_y; /* x, y coords for key or button action */
+ Widget vbar, hbar; /* The scroll bars (none = NULL). */
+ struct SearchAndReplace * search;/* Search and replace structure. */
+ Widget file_insert; /* The file insert popup widget. */
+ XawTextPosition *updateFrom; /* Array of start positions for update. */
+ XawTextPosition *updateTo; /* Array of end positions for update. */
+ int numranges; /* How many update ranges there are. */
+ int maxranges; /* How many ranges we have space for */
+ XawTextPosition lastPos; /* Last position of source. */
+ GC gc;
+ Boolean showposition; /* True if we need to show the position. */
+ Boolean hasfocus; /* TRUE if we currently have input focus.*/
+ Boolean update_disabled; /* TRUE if display updating turned off */
+ Boolean single_char; /* Single character replaced. */
+ XawTextPosition old_insert; /* Last insertPos for batched updates */
+ short mult; /* Multiplier. */
+ struct text_move * copy_area_offsets; /* Text offset area (linked list) */
+
+ /* private state, shared w/Source and Sink */
+ Boolean redisplay_needed; /* in SetValues */
+ XawTextSelectionSalt *salt2; /* salted away selections */
+} TextPart;
+
+/*************************************************************
+ *
+ * Resource types private to Text widget.
+ *
+ *************************************************************/
+
+#define XtRScrollMode "ScrollMode"
+#define XtRWrapMode "WrapMode"
+#define XtRResizeMode "ResizeMode"
+
+/****************************************************************
+ *
+ * Full instance record declaration
+ *
+ ****************************************************************/
+
+typedef struct _TextRec {
+ CorePart core;
+ SimplePart simple;
+ TextPart text;
+} TextRec;
+
+/********************************************
+ *
+ * Semi-private functions
+ * for use by other Xaw modules only
+ *
+ *******************************************/
+
+extern void _XawTextBuildLineTable (
+#if NeedFunctionPrototypes
+ TextWidget /*ctx*/,
+ XawTextPosition /*top pos*/,
+ _XtBoolean /* force_rebuild */
+#endif
+);
+
+extern char* _XawTextGetSTRING(
+#if NeedFunctionPrototypes
+ TextWidget /*ctx*/,
+ XawTextPosition /*left*/,
+ XawTextPosition /*right*/
+#endif
+);
+
+extern void _XawTextSaltAwaySelection(
+#if NeedFunctionPrototypes
+ TextWidget /*ctx*/,
+ Atom* /*selections*/,
+ int /*num_atoms*/
+#endif
+);
+
+extern void _XawTextPosToXY(
+#if NeedFunctionPrototypes
+ Widget /* w */,
+ XawTextPosition /* pos */,
+ Position * /* x */,
+ Position * /*y */
+#endif
+);
+
+#endif /* _XawTextP_h */
+
+
diff --git a/include/X11/Xaw/TextSink.h b/include/X11/Xaw/TextSink.h
new file mode 100644
index 0000000..f5ce84b
--- /dev/null
+++ b/include/X11/Xaw/TextSink.h
@@ -0,0 +1,317 @@
+/*
+ * $Xorg: TextSink.h,v 1.4 2001/02/09 02:03:46 xorgcvs Exp $
+ */
+
+/***********************************************************
+
+Copyright 1987, 1988, 1994, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+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
+OPEN GROUP 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 Open Group 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 Open Group.
+
+
+Copyright 1987, 1988 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+******************************************************************/
+
+#ifndef _XawTextSink_h
+#define _XawTextSink_h
+
+#include <X11/Xaw/Text.h>
+
+/***********************************************************************
+ *
+ * TextSink Object
+ *
+ ***********************************************************************/
+
+/* Resources:
+
+ Name Class RepType Default Value
+ ---- ----- ------- -------------
+ font Font XFontStruct * XtDefaultFont
+ foreground Foreground Pixel XtDefaultForeground
+ background Background Pixel XtDefaultBackground
+
+*/
+
+/* Class record constants */
+
+extern WidgetClass textSinkObjectClass;
+
+typedef struct _TextSinkClassRec *TextSinkObjectClass;
+typedef struct _TextSinkRec *TextSinkObject;
+
+typedef enum {XawisOn, XawisOff} XawTextInsertState;
+
+/************************************************************
+ *
+ * Public Functions.
+ *
+ ************************************************************/
+
+_XFUNCPROTOBEGIN
+
+/* 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.
+ */
+
+extern void XawTextSinkDisplayText(
+#if NeedFunctionPrototypes
+ Widget /* w */,
+#if NeedWidePrototypes
+ /* Position */ int /* x */,
+ /* Position */ int /* y */,
+#else
+ Position /* x */,
+ Position /* y */,
+#endif
+ XawTextPosition /* pos1 */,
+ XawTextPosition /* pos2 */,
+#if NeedWidePrototypes
+ /* Boolean */ int /* highlight */
+#else
+ Boolean /* highlight */
+#endif
+#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.
+ */
+
+extern void XawTextSinkInsertCursor(
+#if NeedFunctionPrototypes
+ Widget /* w */,
+#if NeedWidePrototypes
+ /* Position */ int /* x */,
+ /* Position */ int /* y */,
+ /* XawTextInsertState */ int /* state */
+#else
+ Position /* x */,
+ Position /* y */,
+ XawTextInsertState /* state */
+#endif
+#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.
+ */
+
+extern void XawTextSinkClearToBackground(
+#if NeedFunctionPrototypes
+ Widget /* w */,
+#if NeedWidePrototypes
+ /* Position */ int /* x */,
+ /* Position */ int /* y */,
+ /* Dimension */ int /* width */,
+ /* Dimension */ int /* height */
+#else
+ Position /* x */,
+ Position /* y */,
+ Dimension /* width */,
+ Dimension /* height */
+#endif
+#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).
+ */
+
+extern void XawTextSinkFindPosition(
+#if NeedFunctionPrototypes
+ Widget /* w */,
+ XawTextPosition /* fromPos */,
+ int /* fromX */,
+ int /* width */,
+#if NeedWidePrototypes
+ /* Boolean */ int /* stopAtWordBreak */,
+#else
+ Boolean /* stopAtWordBreak */,
+#endif
+ XawTextPosition* /* pos_return */,
+ int* /* width_return */,
+ int* /* height_return */
+#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.
+ */
+
+extern void XawTextSinkFindDistance (
+#if NeedFunctionPrototypes
+ Widget /* w */,
+ XawTextPosition /* fromPos */,
+ int /* fromX */,
+ XawTextPosition /* toPos */,
+ int* /* width_return */,
+ XawTextPosition* /* pos_return */,
+ int* /* height_return */
+#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
+ */
+
+extern void XawTextSinkResolve(
+#if NeedFunctionPrototypes
+ Widget /* w */,
+ XawTextPosition /* fromPos */,
+ int /* fromX */,
+ int /* width */,
+ XawTextPosition* /* pos_return */
+#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.
+ */
+
+extern int XawTextSinkMaxLines(
+#if NeedFunctionPrototypes
+ Widget /* w */,
+#if NeedWidePrototypes
+ /* Dimension */ int /* height */
+#else
+ Dimension /* height */
+#endif
+#endif
+);
+
+/* Function Name: XawTextSinkMaxHeight
+ * 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.
+ */
+
+extern int XawTextSinkMaxHeight(
+#if NeedFunctionPrototypes
+ 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
+ */
+
+extern void XawTextSinkSetTabs(
+#if NeedFunctionPrototypes
+ Widget /* w */,
+ int /* tab_count */,
+ int* /* tabs */
+#endif
+);
+
+/* 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).
+ */
+
+extern void XawTextSinkGetCursorBounds(
+#if NeedFunctionPrototypes
+ Widget /* w */,
+ XRectangle* /* rect_return */
+#endif
+);
+
+_XFUNCPROTOEND
+
+#endif /* _XawTextSrc_h */
diff --git a/include/X11/Xaw/TextSinkP.h b/include/X11/Xaw/TextSinkP.h
new file mode 100644
index 0000000..9645145
--- /dev/null
+++ b/include/X11/Xaw/TextSinkP.h
@@ -0,0 +1,142 @@
+/*
+* $Xorg: TextSinkP.h,v 1.4 2001/02/09 02:03:46 xorgcvs Exp $
+*/
+
+
+/***********************************************************
+
+Copyright 1987, 1988, 1994, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+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
+OPEN GROUP 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 Open Group 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 Open Group.
+
+
+Copyright 1987, 1988 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+******************************************************************/
+
+/*
+ * TextSinkP.h - Private definitions for TextSink object
+ *
+ */
+
+#ifndef _XawTextSinkP_h
+#define _XawTextSinkP_h
+
+/***********************************************************************
+ *
+ * TextSink Object Private Data
+ *
+ ***********************************************************************/
+
+#include <X11/Xaw/TextSink.h>
+#include <X11/Xaw/TextP.h> /* This source works with the Text widget. */
+#include <X11/Xaw/TextSrcP.h> /* This source works with the Text Source. */
+
+/************************************************************
+ *
+ * New fields for the TextSink object class record.
+ *
+ ************************************************************/
+
+typedef struct _TextSinkClassPart {
+ void (*DisplayText)();
+ void (*InsertCursor)();
+ void (*ClearToBackground)();
+ void (*FindPosition)();
+ void (*FindDistance)();
+ void (*Resolve)();
+ int (*MaxLines)();
+ int (*MaxHeight)();
+ void (*SetTabs)();
+ void (*GetCursorBounds)();
+} TextSinkClassPart;
+
+/* Full class record declaration */
+typedef struct _TextSinkClassRec {
+ ObjectClassPart object_class;
+ TextSinkClassPart text_sink_class;
+} TextSinkClassRec;
+
+extern TextSinkClassRec textSinkClassRec;
+
+/* New fields for the TextSink object record */
+typedef struct {
+ /* resources */
+ Pixel foreground; /* Foreground color. */
+ Pixel background; /* Background color. */
+
+ /* private state. */
+ Position *tabs; /* The tab stops as pixel values. */
+ short *char_tabs; /* The tabs stops as character values. */
+ int tab_count; /* number of items in tabs */
+
+} TextSinkPart;
+
+/****************************************************************
+ *
+ * Full instance record declaration
+ *
+ ****************************************************************/
+
+typedef struct _TextSinkRec {
+ ObjectPart object;
+ TextSinkPart text_sink;
+} TextSinkRec;
+
+/************************************************************
+ *
+ * Private declarations.
+ *
+ ************************************************************/
+
+typedef int (*_XawSinkIntFunc)();
+typedef void (*_XawSinkVoidFunc)();
+
+#define XtInheritDisplayText ((_XawSinkVoidFunc) _XtInherit)
+#define XtInheritInsertCursor ((_XawSinkVoidFunc) _XtInherit)
+#define XtInheritClearToBackground ((_XawSinkVoidFunc) _XtInherit)
+#define XtInheritFindPosition ((_XawSinkVoidFunc) _XtInherit)
+#define XtInheritFindDistance ((_XawSinkVoidFunc) _XtInherit)
+#define XtInheritResolve ((_XawSinkVoidFunc) _XtInherit)
+#define XtInheritMaxLines ((_XawSinkIntFunc) _XtInherit)
+#define XtInheritMaxHeight ((_XawSinkIntFunc) _XtInherit)
+#define XtInheritSetTabs ((_XawSinkVoidFunc) _XtInherit)
+#define XtInheritGetCursorBounds ((_XawSinkVoidFunc) _XtInherit)
+
+#endif /* _XawTextSinkP_h */
diff --git a/include/X11/Xaw/TextSrc.h b/include/X11/Xaw/TextSrc.h
new file mode 100644
index 0000000..b976174
--- /dev/null
+++ b/include/X11/Xaw/TextSrc.h
@@ -0,0 +1,236 @@
+/*
+ * $Xorg: TextSrc.h,v 1.4 2001/02/09 02:03:47 xorgcvs Exp $
+ */
+
+/***********************************************************
+
+Copyright 1987, 1988, 1994, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+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
+OPEN GROUP 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 Open Group 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 Open Group.
+
+
+Copyright 1987, 1988 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+******************************************************************/
+
+#ifndef _XawTextSrc_h
+#define _XawTextSrc_h
+
+/***********************************************************************
+ *
+ * TextSrc Object
+ *
+ ***********************************************************************/
+
+#include <X11/Xaw/Text.h>
+
+/* Resources:
+
+ Name Class RepType Default Value
+ ---- ----- ------- -------------
+ editType EditType XawTextEditType XawtextRead
+
+*/
+
+/* Class record constants */
+
+extern WidgetClass textSrcObjectClass;
+
+typedef struct _TextSrcClassRec *TextSrcObjectClass;
+typedef struct _TextSrcRec *TextSrcObject;
+
+typedef enum {XawstPositions, XawstWhiteSpace, XawstEOL, XawstParagraph,
+ XawstAll} XawTextScanType;
+typedef enum {Normal, Selected }highlightType;
+typedef enum {XawsmTextSelect, XawsmTextExtend} XawTextSelectionMode;
+typedef enum {XawactionStart, XawactionAdjust, XawactionEnd}
+ XawTextSelectionAction;
+
+/*
+ * Error Conditions:
+ */
+
+#define XawTextReadError -1
+#define XawTextScanError -1
+
+/************************************************************
+ *
+ * Public Functions.
+ *
+ ************************************************************/
+
+_XFUNCPROTOBEGIN
+
+/* Function Name: XawTextSourceRead
+ * Description: This function reads the source.
+ * Arguments: w - the TextSrc Object.
+ * pos - position of the text to retreive.
+ * RETURNED text - text block that will contain returned text.
+ * length - maximum number of characters to read.
+ * Returns: The number of characters read into the buffer.
+ */
+
+extern XawTextPosition XawTextSourceRead(
+#if NeedFunctionPrototypes
+ Widget /* w */,
+ XawTextPosition /* pos */,
+ XawTextBlock* /* text_return */,
+ int /* length */
+#endif
+);
+
+/* Function Name: XawTextSourceReplace.
+ * Description: Replaces a block of text with new text.
+ * Arguments: src - the Text Source Object.
+ * startPos, endPos - ends of text that will be removed.
+ * text - new text to be inserted into buffer at startPos.
+ * Returns: XawEditError or XawEditDone.
+ */
+
+extern int XawTextSourceReplace (
+#if NeedFunctionPrototypes
+ Widget /* w */,
+ XawTextPosition /* start */,
+ XawTextPosition /* end */,
+ XawTextBlock* /* text */
+#endif
+);
+
+/* Function Name: XawTextSourceScan
+ * Description: Scans the text source for the number and type
+ * of item specified.
+ * Arguments: w - the TextSrc Object.
+ * position - the position to start scanning.
+ * type - type of thing to scan for.
+ * dir - direction to scan.
+ * count - which occurance if this thing to search for.
+ * include - whether or not to include the character found in
+ * the position that is returned.
+ * Returns: The position of the text.
+ *
+ */
+
+extern XawTextPosition XawTextSourceScan(
+#if NeedFunctionPrototypes
+ Widget /* w */,
+ XawTextPosition /* position */,
+#if NeedWidePrototypes
+ /* XawTextScanType */ int /* type */,
+ /* XawTextScanDirection */ int /* dir */,
+#else
+ XawTextScanType /* type */,
+ XawTextScanDirection /* dir */,
+#endif
+ int /* count */,
+#if NeedWidePrototypes
+ /* Boolean */ int /* include */
+#else
+ Boolean /* include */
+#endif
+#endif
+);
+
+/* Function Name: XawTextSourceSearch
+ * Description: Searchs the text source for the text block passed
+ * Arguments: w - the TextSource Object.
+ * position - the position to start scanning.
+ * dir - direction to scan.
+ * text - the text block to search for.
+ * Returns: The position of the text we are searching for or
+ * XawTextSearchError.
+ */
+
+extern XawTextPosition XawTextSourceSearch(
+#if NeedFunctionPrototypes
+ Widget /* w */,
+ XawTextPosition /* position */,
+#if NeedWidePrototypes
+ /* XawTextScanDirection */ int /* dir */,
+#else
+ XawTextScanDirection /* dir */,
+#endif
+ XawTextBlock* /* text */
+#endif
+);
+
+/* Function Name: XawTextSourceConvertSelection
+ * Description: Dummy selection converter.
+ * Arguments: w - the TextSrc object.
+ * selection - the current selection atom.
+ * target - the current target atom.
+ * type - the type to conver the selection to.
+ * RETURNED value, length - the return value that has been converted.
+ * RETURNED format - the format of the returned value.
+ * Returns: TRUE if the selection has been converted.
+ *
+ */
+
+extern Boolean XawTextSourceConvertSelection(
+#if NeedFunctionPrototypes
+ Widget /* w */,
+ Atom* /* selection */,
+ Atom* /* target */,
+ Atom* /* type */,
+ XtPointer* /* value_return */,
+ unsigned long* /* length_return */,
+ int* /* format_return */
+#endif
+);
+
+/* Function Name: XawTextSourceSetSelection
+ * Description: allows special setting of the selection.
+ * Arguments: w - the TextSrc object.
+ * left, right - bounds of the selection.
+ * selection - the selection atom.
+ * Returns: none
+ */
+
+extern void XawTextSourceSetSelection(
+#if NeedFunctionPrototypes
+ Widget /* w */,
+ XawTextPosition /* start */,
+ XawTextPosition /* end */,
+ Atom /* selection */
+#endif
+);
+
+_XFUNCPROTOEND
+
+#endif /* _XawTextSrc_h */
+/* DON'T ADD STUFF AFTER THIS #endif */
diff --git a/include/X11/Xaw/TextSrcP.h b/include/X11/Xaw/TextSrcP.h
new file mode 100644
index 0000000..c85f404
--- /dev/null
+++ b/include/X11/Xaw/TextSrcP.h
@@ -0,0 +1,163 @@
+/*
+* $Xorg: TextSrcP.h,v 1.4 2001/02/09 02:03:47 xorgcvs Exp $
+*/
+
+
+/***********************************************************
+
+Copyright 1987, 1988, 1994, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+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
+OPEN GROUP 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 Open Group 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 Open Group.
+
+
+Copyright 1987, 1988 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+******************************************************************/
+
+/*
+ * TextSrcP.h - Private definitions for TextSrc object
+ *
+ */
+
+#ifndef _XawTextSrcP_h
+#define _XawTextSrcP_h
+
+/***********************************************************************
+ *
+ * TextSrc Object Private Data
+ *
+ ***********************************************************************/
+
+#include <X11/Xaw/TextSrc.h>
+#include <X11/Xaw/TextP.h> /* This source works with the Text widget. */
+
+/************************************************************
+ *
+ * New fields for the TextSrc object class record.
+ *
+ ************************************************************/
+
+typedef struct {
+ XtPointer next_extension;
+ XrmQuark record_type;
+ long version;
+ Cardinal record_size;
+ int (*Input)();
+} TextSrcExtRec, *TextSrcExt;
+
+typedef struct _TextSrcClassPart {
+ XawTextPosition (*Read)();
+ int (*Replace)();
+ XawTextPosition (*Scan)();
+ XawTextPosition (*Search)();
+ void (*SetSelection)();
+ Boolean (*ConvertSelection)();
+} TextSrcClassPart;
+
+/* Full class record declaration */
+typedef struct _TextSrcClassRec {
+ ObjectClassPart object_class;
+ TextSrcClassPart textSrc_class;
+} TextSrcClassRec;
+
+extern TextSrcClassRec textSrcClassRec;
+
+/* New fields for the TextSrc object record */
+typedef struct {
+ /* resources */
+ XawTextEditType edit_mode;
+ XrmQuark text_format; /* 2 formats: FMT8BIT for Ascii */
+ /* FMTWIDE for ISO 10646 */
+} TextSrcPart;
+
+/****************************************************************
+ *
+ * Full instance record declaration
+ *
+ ****************************************************************/
+
+typedef struct _TextSrcRec {
+ ObjectPart object;
+ TextSrcPart textSrc;
+} TextSrcRec;
+
+/******************************************************************
+ *
+ * Semiprivate declarations of functions used in other modules
+ *
+ ******************************************************************/
+
+char* _XawTextWCToMB(
+#if NeedFunctionPrototypes
+ Display* /* d */,
+ wchar_t* /* wstr */,
+ int* /* len_in_out */
+#endif
+);
+
+wchar_t* _XawTextMBToWC(
+#if NeedFunctionPrototypes
+ Display* /* d */,
+ char* /* str */,
+ int* /* len_in_out */
+#endif
+);
+
+/************************************************************
+ *
+ * Private declarations.
+ *
+ ************************************************************/
+
+typedef Boolean (*_XawBooleanFunc)();
+typedef int (*_XawIntFunc)();
+typedef XawTextPosition (*_XawTextPositionFunc)();
+typedef void (*_XawTextVoidFunc)();
+
+#define XtInheritInput ((_XawTextPositionFunc) _XtInherit)
+#define XtInheritRead ((_XawTextPositionFunc) _XtInherit)
+#define XtInheritReplace ((_XawIntFunc) _XtInherit)
+#define XtInheritScan ((_XawTextPositionFunc) _XtInherit)
+#define XtInheritSearch ((_XawTextPositionFunc) _XtInherit)
+#define XtInheritSetSelection ((_XawTextVoidFunc) _XtInherit)
+#define XtInheritConvertSelection ((_XawBooleanFunc) _XtInherit)
+#define XtTextSrcExtVersion 1
+#define XtTextSrcExtTypeString "XT_TEXTSRC_EXT"
+
+#endif /* _XawTextSrcP_h */
diff --git a/include/X11/Xaw/Toggle.h b/include/X11/Xaw/Toggle.h
new file mode 100644
index 0000000..a433bd0
--- /dev/null
+++ b/include/X11/Xaw/Toggle.h
@@ -0,0 +1,176 @@
+/*
+ * $Xorg: Toggle.h,v 1.4 2001/02/09 02:03:47 xorgcvs Exp $
+ *
+Copyright 1989, 1994, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+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
+OPEN GROUP 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 Open Group 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 Open Group.
+ */
+
+/*
+ * ToggleP.h - Private definitions for Toggle widget
+ *
+ * Author: Chris D. Peterson
+ * MIT X Consortium
+ * kit@expo.lcs.mit.edu
+ *
+ * Date: January 12, 1989
+ */
+
+#ifndef _XawToggle_h
+#define _XawToggle_h
+
+/***********************************************************************
+ *
+ * Toggle Widget
+ *
+ ***********************************************************************/
+
+#include <X11/Xaw/Command.h>
+
+/* Resources:
+
+ Name Class RepType Default Value
+ ---- ----- ------- -------------
+ radioGroup RadioGroup Widget NULL +
+ radioData RadioData Pointer (XPointer) Widget ++
+ state State Boolean Off
+
+ background Background Pixel XtDefaultBackground
+ bitmap Pixmap Pixmap None
+ border BorderColor Pixel XtDefaultForeground
+ borderWidth BorderWidth Dimension 1
+ callback Callback Pointer NULL
+ cursor Cursor Cursor None
+ destroyCallback Callback Pointer NULL
+ font Font XFontStructx* XtDefaultFont
+ foreground Foreground Pixel XtDefaultForeground
+ height Height Dimension text height
+ highlightThickness Thickness Dimension 2
+ insensitiveBorder Insensitive Pixmap Gray
+ internalHeight Height Dimension 2
+ internalWidth Width Dimension 4
+ justify Justify XtJustify XtJustifyCenter
+ label Label String NULL
+ mappedWhenManaged MappedWhenManaged Boolean True
+ resize Resize Boolean True
+ sensitive Sensitive Boolean True
+ width Width Dimension text width
+ x Position Position 0
+ y Position Position 0
+
++ To use the toggle as a radio toggle button, set this resource to point to
+ any other widget in the radio group.
+
+++ This is the data returned from a call to XtToggleGetCurrent, by default
+ this is set to the name of toggle widget.
+
+*/
+
+/*
+ * These should be in StringDefs.h but aren't so we will define
+ * them here if they are needed.
+ */
+
+
+#define XtCWidget "Widget"
+#define XtCState "State"
+#define XtCRadioGroup "RadioGroup"
+#define XtCRadioData "RadioData"
+
+#ifndef _XtStringDefs_h_
+#define XtRWidget "Widget"
+#endif
+
+#define XtNstate "state"
+#define XtNradioGroup "radioGroup"
+#define XtNradioData "radioData"
+
+extern WidgetClass toggleWidgetClass;
+
+typedef struct _ToggleClassRec *ToggleWidgetClass;
+typedef struct _ToggleRec *ToggleWidget;
+
+
+/************************************************************
+ *
+ * Public Functions
+ *
+ ************************************************************/
+
+_XFUNCPROTOBEGIN
+
+/* Function Name: XawToggleChangeRadioGroup
+ * Description: Allows a toggle widget to change radio lists.
+ * Arguments: w - The toggle widget to change lists.
+ * radio_group - any widget in the new list.
+ * Returns: none.
+ */
+
+extern void XawToggleChangeRadioGroup(
+#if NeedFunctionPrototypes
+ Widget /* w */,
+ Widget /* radio_group */
+#endif
+);
+
+/* Function Name: XawToggleGetCurrent
+ * Description: Returns the RadioData associated with the toggle
+ * widget that is currently active in a toggle list.
+ * Arguments: radio_group - any toggle widget in the toggle list.
+ * Returns: The XtNradioData associated with the toggle widget.
+ */
+
+extern XtPointer XawToggleGetCurrent(
+#if NeedFunctionPrototypes
+ Widget /* radio_group */
+#endif
+);
+
+/* Function Name: XawToggleSetCurrent
+ * Description: Sets the Toggle widget associated with the
+ * radio_data specified.
+ * Arguments: radio_group - any toggle widget in the toggle list.
+ * radio_data - radio data of the toggle widget to set.
+ * Returns: none.
+ */
+
+extern void XawToggleSetCurrent(
+#if NeedFunctionPrototypes
+ Widget /* radio_group */,
+ XtPointer /* radio_data */
+#endif
+);
+
+/* Function Name: XawToggleUnsetCurrent
+ * Description: Unsets all Toggles in the radio_group specified.
+ * Arguments: radio_group - any toggle widget in the toggle list.
+ * Returns: none.
+ */
+
+extern void XawToggleUnsetCurrent(
+#if NeedFunctionPrototypes
+ Widget /* radio_group */
+#endif
+);
+
+_XFUNCPROTOEND
+
+#endif /* _XawToggle_h */
diff --git a/include/X11/Xaw/ToggleP.h b/include/X11/Xaw/ToggleP.h
new file mode 100644
index 0000000..bacee25
--- /dev/null
+++ b/include/X11/Xaw/ToggleP.h
@@ -0,0 +1,110 @@
+/* $Xorg: ToggleP.h,v 1.4 2001/02/09 02:03:47 xorgcvs Exp $ */
+
+/*
+
+Copyright 1989, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+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
+OPEN GROUP 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 Open Group 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 Open Group.
+
+*/
+
+/*
+ * ToggleP.h - Private definitions for Toggle widget
+ *
+ * Author: Chris D. Peterson
+ * MIT X Consortium
+ * kit@expo.lcs.mit.edu
+ *
+ * Date: January 12, 1989
+ *
+ */
+
+#ifndef _XawToggleP_h
+#define _XawToggleP_h
+
+#include <X11/Xaw/Toggle.h>
+#include <X11/Xaw/CommandP.h>
+
+/***********************************************************************
+ *
+ * Toggle Widget Private Data
+ *
+ ***********************************************************************/
+
+#define streq(a, b) ( strcmp((a), (b)) == 0 )
+
+typedef struct _RadioGroup {
+ struct _RadioGroup *prev, *next; /* Pointers to other elements in group. */
+ Widget widget; /* Widget corrosponding to this element. */
+} RadioGroup;
+
+/************************************
+ *
+ * Class structure
+ *
+ ***********************************/
+
+ /* New fields for the Toggle widget class record */
+typedef struct _ToggleClass {
+ XtActionProc Set;
+ XtActionProc Unset;
+ XtPointer extension;
+} ToggleClassPart;
+
+ /* Full class record declaration */
+typedef struct _ToggleClassRec {
+ CoreClassPart core_class;
+ SimpleClassPart simple_class;
+ LabelClassPart label_class;
+ CommandClassPart command_class;
+ ToggleClassPart toggle_class;
+} ToggleClassRec;
+
+extern ToggleClassRec toggleClassRec;
+
+/***************************************
+ *
+ * Instance (widget) structure
+ *
+ **************************************/
+
+ /* New fields for the Toggle widget record */
+typedef struct {
+ /* resources */
+ Widget widget;
+ XtPointer radio_data;
+
+ /* private data */
+ RadioGroup * radio_group;
+} TogglePart;
+
+ /* Full widget declaration */
+typedef struct _ToggleRec {
+ CorePart core;
+ SimplePart simple;
+ LabelPart label;
+ CommandPart command;
+ TogglePart toggle;
+} ToggleRec;
+
+#endif /* _XawToggleP_h */
+
+
diff --git a/include/X11/Xaw/Tree.h b/include/X11/Xaw/Tree.h
new file mode 100644
index 0000000..9e45d47
--- /dev/null
+++ b/include/X11/Xaw/Tree.h
@@ -0,0 +1,124 @@
+/*
+ * $Xorg: Tree.h,v 1.4 2001/02/09 02:03:47 xorgcvs Exp $
+ *
+
+Copyright 1990, 1994, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+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
+OPEN GROUP 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 Open Group 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 Open Group.
+
+ * Copyright 1989 Prentice Hall
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose and without fee is hereby granted, provided that the above
+ * copyright notice appear in all copies and that both the copyright notice
+ * and this permission notice appear in supporting documentation.
+ *
+ * Prentice Hall and the authors disclaim all warranties with regard
+ * to this software, including all implied warranties of merchantability and
+ * fitness. In no event shall Prentice Hall or the authors be liable
+ * for any special, indirect or cosequential damages or any damages whatsoever
+ * resulting from loss of use, data or profits, whether in an action of
+ * contract, negligence or other tortious action, arising out of or in
+ * connection with the use or performance of this software.
+ *
+ * Authors: Jim Fulton, MIT X Consortium,
+ * based on a version by Douglas Young, Prentice Hall
+ *
+ * This widget is based on the Tree widget described on pages 397-419 of
+ * Douglas Young's book "The X Window System, Programming and Applications
+ * with Xt OSF/Motif Edition." The layout code has been rewritten to use
+ * additional blank space to make the structure of the graph easier to see
+ * as well as to support vertical trees.
+ */
+
+
+#ifndef _XawTree_h
+#define _XawTree_h
+
+#include <X11/Xmu/Converters.h>
+
+/******************************************************************************
+ *
+ * Tree Widget (subclass of ConstraintClass)
+ *
+ ******************************************************************************
+ *
+ * Parameters:
+ *
+ * Name Class Type Default
+ * ---- ----- ---- -------
+ *
+ * autoReconfigure AutoReconfigure Boolean FALSE
+ * background Background Pixel XtDefaultBackground
+ * foreground Foreground Pixel XtDefaultForeground
+ * gravity Gravity XtGravity West
+ * hSpace HSpace Dimension 20
+ * lineWidth LineWidth Dimension 0
+ * vSpace VSpace Dimension 6
+ *
+ *
+ * Constraint Resources attached to children:
+ *
+ * treeGC TreeGC GC NULL
+ * treeParent TreeParent Widget NULL
+ *
+ *
+ *****************************************************************************/
+
+ /* new instance field names */
+#ifndef _XtStringDefs_h_
+#define XtNhSpace "hSpace"
+#define XtNvSpace "vSpace"
+#define XtCHSpace "HSpace"
+#define XtCVSpace "VSpace"
+#endif
+
+#define XtNautoReconfigure "autoReconfigure"
+#define XtNlineWidth "lineWidth"
+#define XtNtreeGC "treeGC"
+#define XtNtreeParent "treeParent"
+#define XtNgravity "gravity"
+
+ /* new class field names */
+#define XtCAutoReconfigure "AutoReconfigure"
+#define XtCLineWidth "LineWidth"
+#define XtCTreeGC "TreeGC"
+#define XtCTreeParent "TreeParent"
+#define XtCGravity "Gravity"
+
+#define XtRGC "GC"
+ /* external declarations */
+extern WidgetClass treeWidgetClass;
+
+typedef struct _TreeClassRec *TreeWidgetClass;
+typedef struct _TreeRec *TreeWidget;
+
+_XFUNCPROTOBEGIN
+
+extern void XawTreeForceLayout (
+#if NeedFunctionPrototypes
+ Widget /* tree */
+#endif
+);
+
+_XFUNCPROTOEND
+
+#endif /* _XawTree_h */
diff --git a/include/X11/Xaw/TreeP.h b/include/X11/Xaw/TreeP.h
new file mode 100644
index 0000000..3b4e0ff
--- /dev/null
+++ b/include/X11/Xaw/TreeP.h
@@ -0,0 +1,131 @@
+/*
+ * $Xorg: TreeP.h,v 1.4 2001/02/09 02:03:47 xorgcvs Exp $
+ *
+
+Copyright 1990, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+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
+OPEN GROUP 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 Open Group 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 Open Group.
+
+ * Copyright 1989 Prentice Hall
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose and without fee is hereby granted, provided that the above
+ * copyright notice appear in all copies and that both the copyright notice
+ * and this permission notice appear in supporting documentation.
+ *
+ * Prentice Hall and the authors disclaim all warranties with regard
+ * to this software, including all implied warranties of merchantability and
+ * fitness. In no event shall Prentice Hall or the authors be liable
+ * for any special, indirect or cosequential damages or any damages whatsoever
+ * resulting from loss of use, data or profits, whether in an action of
+ * contract, negligence or other tortious action, arising out of or in
+ * connection with the use or performance of this software.
+ *
+ * Authors: Jim Fulton, MIT X Consortium,
+ * based on a version by Douglas Young, Prentice Hall
+ *
+ * This widget is based on the Tree widget described on pages 397-419 of
+ * Douglas Young's book "The X Window System, Programming and Applications
+ * with Xt OSF/Motif Edition." The layout code has been rewritten to use
+ * additional blank space to make the structure of the graph easier to see
+ * as well as to support vertical trees.
+ */
+
+
+#ifndef _XawTreeP_h
+#define _XawTreeP_h
+
+#include <X11/Xaw/Tree.h>
+
+typedef struct _TreeClassPart {
+ int ignore;
+} TreeClassPart;
+
+typedef struct _TreeClassRec {
+ CoreClassPart core_class;
+ CompositeClassPart composite_class;
+ ConstraintClassPart constraint_class;
+ TreeClassPart tree_class;
+} TreeClassRec;
+
+extern TreeClassRec treeClassRec;
+
+typedef struct {
+ /* fields available through resources */
+ Dimension hpad; /* hSpace/HSpace */
+ Dimension vpad; /* vSpace/VSpace */
+ Dimension line_width; /* lineWidth/LineWidth */
+ Pixel foreground; /* foreground/Foreground */
+ XtGravity gravity; /* gravity/Gravity */
+ Boolean auto_reconfigure; /* autoReconfigure/AutoReconfigure */
+ /* private fields */
+ GC gc; /* used to draw lines */
+ Widget tree_root; /* hidden root off all children */
+ Dimension *largest; /* list of largest per depth */
+ int n_largest; /* number of elements in largest */
+ Dimension maxwidth, maxheight; /* for shrink wrapping */
+} TreePart;
+
+
+typedef struct _TreeRec {
+ CorePart core;
+ CompositePart composite;
+ ConstraintPart constraint;
+ TreePart tree;
+} TreeRec;
+
+
+/*
+ * structure attached to all children
+ */
+typedef struct _TreeConstraintsPart {
+ /* resources */
+ Widget parent; /* treeParent/TreeParent */
+ GC gc; /* treeGC/TreeGC */
+ /* private data */
+ Widget *children;
+ int n_children;
+ int max_children;
+ Dimension bbsubwidth, bbsubheight; /* bounding box of sub tree */
+ Dimension bbwidth, bbheight; /* bounding box including node */
+ Position x, y;
+} TreeConstraintsPart;
+
+typedef struct _TreeConstraintsRec {
+ TreeConstraintsPart tree;
+} TreeConstraintsRec, *TreeConstraints;
+
+
+/*
+ * useful macros
+ */
+
+#define TREE_CONSTRAINT(w) \
+ ((TreeConstraints)((w)->core.constraints))
+
+#define TREE_INITIAL_DEPTH 10 /* for allocating largest array */
+#define TREE_HORIZONTAL_DEFAULT_SPACING 20
+#define TREE_VERTICAL_DEFAULT_SPACING 6
+
+#endif /* _XawTreeP_h */
+
+
+
diff --git a/include/X11/Xaw/VendorEP.h b/include/X11/Xaw/VendorEP.h
new file mode 100644
index 0000000..37d65ef
--- /dev/null
+++ b/include/X11/Xaw/VendorEP.h
@@ -0,0 +1,80 @@
+/* $Xorg: VendorEP.h,v 1.4 2001/02/09 02:03:47 xorgcvs Exp $ */
+
+/*
+ * Copyright 1991 by OMRON Corporation
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of OMRON not be used in advertising or
+ * publicity pertaining to distribution of the software without specific,
+ * written prior permission. OMRON makes no representations about the
+ * suitability of this software for any purpose. It is provided "as is"
+ * without express or implied warranty.
+ *
+ * OMRON DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+ * OMRON BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ * ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+ * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTUOUS ACTION,
+ * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+ * SOFTWARE.
+ *
+ * Author: Seiji Kuwari OMRON Corporation
+ * kuwa@omron.co.jp
+ * kuwa%omron.co.jp@uunet.uu.net
+ */
+
+/*
+
+Copyright 1994, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+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
+OPEN GROUP 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 Open Group 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 Open Group.
+
+*/
+
+#ifndef _VendorEP_h
+#define _VendorEP_h
+
+#include <X11/Xaw/XawImP.h>
+
+typedef struct {
+ XtPointer extension;
+} XawVendorShellExtClassPart;
+
+typedef struct _VendorShellExtClassRec {
+ ObjectClassPart object_class;
+ XawVendorShellExtClassPart vendor_shell_ext_class;
+} XawVendorShellExtClassRec;
+
+typedef struct {
+ Widget parent;
+ XawImPart im;
+ XawIcPart ic;
+} XawVendorShellExtPart;
+
+typedef struct XawVendorShellExtRec {
+ ObjectPart object;
+ XawVendorShellExtPart vendor_ext;
+} XawVendorShellExtRec, *XawVendorShellExtWidget;
+
+#endif /* _VendorEP_h */
diff --git a/include/X11/Xaw/Viewport.h b/include/X11/Xaw/Viewport.h
new file mode 100644
index 0000000..6f09420
--- /dev/null
+++ b/include/X11/Xaw/Viewport.h
@@ -0,0 +1,123 @@
+/* $Xorg: Viewport.h,v 1.4 2001/02/09 02:03:47 xorgcvs Exp $ */
+
+/************************************************************
+
+Copyright 1987, 1994, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+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
+OPEN GROUP 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 Open Group 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 Open Group.
+
+
+Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+********************************************************/
+
+#ifndef _XawViewport_h
+#define _XawViewport_h
+
+#include <X11/Xaw/Form.h>
+#include <X11/Xaw/Reports.h>
+
+/* Resources:
+
+ Name Class RepType Default Value
+ ---- ----- ------- -------------
+ allowHoriz Boolean Boolean False
+ allowVert Boolean Boolean False
+ background Background Pixel XtDefaultBackground
+ border BorderColor Pixel XtDefaultForeground
+ borderWidth BorderWidth Dimension 1
+ destroyCallback Callback Pointer NULL
+ foreceBars Boolean Boolean False
+ height Height Dimension 0
+ mappedWhenManaged MappedWhenManaged Boolean True
+ reportCallback ReportCallback Pointer NULL
+ sensitive Sensitive Boolean True
+ useBottom Boolean Boolean False
+ useRight Boolean Boolean False
+ width Width Dimension 0
+ x Position Position 0
+ y Position Position 0
+
+*/
+
+/* fields added to Form */
+#ifndef _XtStringDefs_h_
+#define XtNforceBars "forceBars"
+#define XtNallowHoriz "allowHoriz"
+#define XtNallowVert "allowVert"
+#define XtNuseBottom "useBottom"
+#define XtNuseRight "useRight"
+#endif
+
+extern WidgetClass viewportWidgetClass;
+
+typedef struct _ViewportClassRec *ViewportWidgetClass;
+typedef struct _ViewportRec *ViewportWidget;
+
+_XFUNCPROTOBEGIN
+
+extern void XawViewportSetLocation (
+#if NeedFunctionPrototypes
+ Widget /* gw */,
+#if NeedWidePrototypes
+ /* float */ double /* xoff */,
+ /* float */ double /* yoff */
+#else
+ float /* xoff */,
+ float /* yoff */
+#endif
+#endif
+);
+
+extern void XawViewportSetCoordinates (
+#if NeedFunctionPrototypes
+ Widget /* gw */,
+#if NeedWidePrototypes
+ /* Position */ int /* x */,
+ /* Position */ int /* y */
+#else
+ Position /* x */,
+ Position /* y */
+#endif
+#endif
+);
+
+_XFUNCPROTOEND
+
+#endif /* _XawViewport_h */
diff --git a/include/X11/Xaw/ViewportP.h b/include/X11/Xaw/ViewportP.h
new file mode 100644
index 0000000..6792426
--- /dev/null
+++ b/include/X11/Xaw/ViewportP.h
@@ -0,0 +1,105 @@
+/*
+ * $Xorg: ViewportP.h,v 1.4 2001/02/09 02:03:47 xorgcvs Exp $
+ * Private declarations for ViewportWidgetClass
+ */
+
+/************************************************************
+
+Copyright 1987, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+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
+OPEN GROUP 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 Open Group 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 Open Group.
+
+
+Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+********************************************************/
+
+#ifndef _ViewportP_h
+#define _ViewportP_h
+
+#include <X11/Xaw/Viewport.h>
+#include <X11/Xaw/FormP.h>
+
+typedef struct {int empty;} ViewportClassPart;
+
+typedef struct _ViewportClassRec {
+ CoreClassPart core_class;
+ CompositeClassPart composite_class;
+ ConstraintClassPart constraint_class;
+ FormClassPart form_class;
+ ViewportClassPart viewport_class;
+} ViewportClassRec;
+
+extern ViewportClassRec viewportClassRec;
+
+typedef struct _ViewportPart {
+ /* resources */
+ Boolean forcebars; /* Whether we should always display */
+ /* the selected scrollbars. */
+ Boolean allowhoriz; /* Whether we allow horizontal scrollbars. */
+ Boolean allowvert; /* Whether we allow vertical scrollbars. */
+ Boolean usebottom; /* True iff horiz bars appear at bottom. */
+ Boolean useright; /* True iff vert bars appear at right. */
+ XtCallbackList report_callbacks; /* when size/position changes */
+ /* private state */
+ Widget clip, child; /* The clipping and (scrolled) child widgets */
+ Widget horiz_bar, vert_bar;/* What scrollbars we currently have. */
+} ViewportPart;
+
+typedef struct _ViewportRec {
+ CorePart core;
+ CompositePart composite;
+ ConstraintPart constraint;
+ FormPart form;
+ ViewportPart viewport;
+} ViewportRec;
+
+typedef struct {
+ /* resources */
+
+ /* private state */
+ Boolean reparented; /* True if child has been re-parented */
+} ViewportConstraintsPart;
+
+typedef struct _ViewportConstraintsRec {
+ FormConstraintsPart form;
+ ViewportConstraintsPart viewport;
+} ViewportConstraintsRec, *ViewportConstraints;
+
+#endif /* _ViewportP_h */
diff --git a/include/X11/Xaw/XawImP.h b/include/X11/Xaw/XawImP.h
new file mode 100644
index 0000000..1974a19
--- /dev/null
+++ b/include/X11/Xaw/XawImP.h
@@ -0,0 +1,223 @@
+/* $Xorg: XawImP.h,v 1.4 2001/02/09 02:03:47 xorgcvs Exp $ */
+
+/*
+ * Copyright 1991 by OMRON Corporation
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of OMRON not be used in advertising or
+ * publicity pertaining to distribution of the software without specific,
+ * written prior permission. OMRON makes no representations about the
+ * suitability of this software for any purpose. It is provided "as is"
+ * without express or implied warranty.
+ *
+ * OMRON DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+ * OMRON BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ * ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+ * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTUOUS ACTION,
+ * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+ * SOFTWARE.
+ *
+ * Author: Seiji Kuwari OMRON Corporation
+ * kuwa@omron.co.jp
+ * kuwa%omron.co.jp@uunet.uu.net
+ */
+
+/*
+
+Copyright 1994, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+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
+OPEN GROUP 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 Open Group 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 Open Group.
+
+*/
+
+#ifndef _XawImP_h
+#define _XawImP_h
+
+#define XtNinputMethod "inputMethod"
+#define XtCInputMethod "InputMethod"
+#define XtNpreeditType "preeditType"
+#define XtCPreeditType "PreeditType"
+#define XtNopenIm "openIm"
+#define XtCOpenIm "OpenIm"
+#define XtNsharedIc "sharedIc"
+#define XtCSharedIc "SharedIc"
+
+#include <X11/Xaw/Text.h>
+
+#define CIICFocus (1 << 0)
+#define CIFontSet (1 << 1)
+#define CIFg (1 << 2)
+#define CIBg (1 << 3)
+#define CIBgPixmap (1 << 4)
+#define CICursorP (1 << 5)
+#define CILineS (1 << 6)
+
+typedef struct _XawImPart
+{
+ XIM xim;
+ XrmResourceList resources;
+ Cardinal num_resources;
+ Boolean open_im;
+ Boolean initialized;
+ Dimension area_height;
+ String input_method;
+ String preedit_type;
+} XawImPart;
+
+typedef struct _XawIcTablePart
+{
+ Widget widget;
+ XIC xic;
+ XIMStyle input_style;
+ unsigned long flg;
+ unsigned long prev_flg;
+ Boolean ic_focused;
+ XFontSet font_set;
+ Pixel foreground;
+ Pixel background;
+ Pixmap bg_pixmap;
+ XawTextPosition cursor_position;
+ unsigned long line_spacing;
+ Boolean openic_error;
+ struct _XawIcTablePart *next;
+} XawIcTablePart, *XawIcTableList;
+
+typedef struct _XawIcPart
+{
+ XIMStyle input_style;
+ Boolean shared_ic;
+ XawIcTableList shared_ic_table;
+ XawIcTableList current_ic_table;
+ XawIcTableList ic_table;
+} XawIcPart;
+
+typedef struct _contextDataRec
+{
+ Widget parent;
+ Widget ve;
+} contextDataRec;
+
+typedef struct _contextErrDataRec
+{
+ Widget widget;
+ XIM xim;
+} contextErrDataRec;
+
+void _XawImResizeVendorShell(
+#if NeedFunctionPrototypes
+ Widget /* w */
+#endif
+);
+
+Dimension _XawImGetShellHeight(
+#if NeedFunctionPrototypes
+ Widget /* w */
+#endif
+);
+
+void _XawImRealize(
+#if NeedFunctionPrototypes
+ Widget /* w */
+#endif
+);
+
+void _XawImInitialize(
+#if NeedFunctionPrototypes
+ Widget, /* w */
+ Widget /* ext */
+#endif
+);
+
+void _XawImReconnect(
+#if NeedFunctionPrototypes
+ Widget /* w */
+#endif
+);
+
+void _XawImRegister(
+#if NeedFunctionPrototypes
+ Widget /* w */
+#endif
+);
+
+void _XawImUnregister(
+#if NeedFunctionPrototypes
+ Widget /* w */
+#endif
+);
+
+void _XawImSetValues(
+#if NeedFunctionPrototypes
+ Widget, /* w */
+ ArgList, /* args */
+ Cardinal /* num_args */
+#endif
+);
+
+void _XawImSetFocusValues(
+#if NeedFunctionPrototypes
+ Widget, /* w */
+ ArgList, /* args */
+ Cardinal /* num_args */
+#endif
+);
+
+void _XawImUnsetFocus(
+#if NeedFunctionPrototypes
+ Widget /* w */
+#endif
+);
+
+int _XawImWcLookupString(
+#if NeedFunctionPrototypes
+ Widget, /* w */
+ XKeyPressedEvent*, /* event */
+ wchar_t*, /* buffer_return */
+ int, /* bytes_buffer */
+ KeySym*, /* keysym_return */
+ Status* /* status return */
+#endif
+);
+
+int _XawImGetImAreaHeight(
+#if NeedFunctionPrototypes
+ Widget /* w */
+#endif
+);
+
+void _XawImCallVendorShellExtResize(
+#if NeedFunctionPrototypes
+ Widget /* w */
+#endif
+);
+
+void _XawImDestroy(
+#if NeedFunctionPrototypes
+ Widget, /* w */
+ Widget /* ext */
+#endif
+);
+
+#endif /* _XawImP_h */
diff --git a/include/X11/Xaw/XawInit.h b/include/X11/Xaw/XawInit.h
new file mode 100644
index 0000000..53de0ef
--- /dev/null
+++ b/include/X11/Xaw/XawInit.h
@@ -0,0 +1,32 @@
+/* $Xorg: XawInit.h,v 1.5 2001/02/09 02:03:47 xorgcvs Exp $
+ *
+Copyright 1989, 1994, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+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
+OPEN GROUP 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 Open Group 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 Open Group.
+ */
+
+#include <X11/Xfuncproto.h>
+
+_XFUNCPROTOBEGIN
+
+extern void XawInitializeWidgetSet(); /* called from ClassInit procs */
+
+_XFUNCPROTOEND
diff --git a/old-doc/CHANGES b/old-doc/CHANGES
new file mode 100644
index 0000000..2eb316a
--- /dev/null
+++ b/old-doc/CHANGES
@@ -0,0 +1,153 @@
+
+ These changes have been made to Xaw since X11R4.
+
+
+
+Documentation:
+ Fixed definition of XtAppInitialize().
+
+ Changed all references to XawOrient* and XtOrient* to Xtorient*.
+
+ Many other corrections and clarifications.
+
+Everywhere:
+ Function prototypes for public interfaces.
+
+ Many bugs not mentioned here have been fixed.
+
+AllWidgets:
+ Add WidgetNode table for use with listres and viewres.
+
+AsciiSrc (Text):
+ No warning message is printed when the file can not be
+ written to, the return value should be enough info.
+
+ GetValues on the string resource was failing when
+ "useStringInPlace" was set to true.
+
+ Memory leak when freeing pieces in a source of type "ascii String"
+ has been plugged.
+
+ Buffer is now updated whenever the "string" resource is set using
+ XtSetValues(). If type is file then the file is read in again.
+
+Box:
+ The public header file now includes Xmu/Converters.h for the
+ orientation resources.
+
+Clock:
+ Made subclass of simple instead of Core
+
+Command:
+ Fixed bug in changing shape style to Rectangular.
+
+Dialog:
+ Resource Type of Icon changed from Pixmap -> Bitmap.
+
+Form:
+ The geometry handler now will now disallow geometry management
+ reqests that will force the child outside the Form's window.
+
+ Fixed missing parens typo in PreferredGeometry.
+
+ Fixed EdgeTypes to be Xaw* instead of Xt*, but left the
+ old definitions around with #define so that code will still work.
+
+ StringToWidget converter no longer caches resources.
+
+Logo:
+ Made subclass of simple instead of Core.
+ Fixed reverse video.
+
+Mailbox:
+ Made subclass of simple instead of Core.
+ Fixed reverse video and many other bugs.
+
+MenuButton:
+* The MenuButton widget no longer places a server grab on itself.
+ Instead, PopupMenu is registered as a grab action. As a result
+ of this, clients which popped up menus without using XtMenuPopup
+ or MenuPopup or PopupMenu in the menu button translations will
+ fail to have a grab active. They should make a call to
+ XtRegisterGrabAction on the appropriate action in the application
+ initialization routine, or use a different translation.
+
+Paned:
+ The public header file now includes Xmu/Converters.h for the
+ orientation resources.
+
+Panner: This widget is new in R5.
+
+Porthole:
+ New for R5.
+
+Scrollbar:
+ Fixed bug that could call XtReleaseGC() with garbage
+ Made subclass of simple instead of Core
+
+ Type of thumb resource is XtRBitmap; it used to be XtRPixmap.
+ However, if applications provide the resource conversion, the
+ Scrollbar's SetValues can still handle pixmaps of correct depth.
+
+Simple:
+ Added a color cursor converter. and the new resource types:
+ XtNpointerColor
+ XtNpointerColorBackground
+ XtNcursorName
+
+SmeBSB:
+ Right bitmaps are now painted in the correct location.
+
+ Right and Left Bitmaps can be specified in resource files, and
+ at startup time.
+
+Text:
+ If there is no current selection the the selection extends
+ from the insert point, rather than some random location.
+
+ Forward (Backward) Paragraph works at the paragraph boundaries now.
+
+ Selecting a word now transitions correctly at BOTH end points.
+
+ Infinite loop when using fill paragraph in a read only text widget
+ has been found and fixed.
+
+ When the "resize" resource is set the text will start up with
+ exactly enough space to contain the text in the widget.
+
+ Fixed a bug that could cause an infinite loop when Meta-Q was used
+ to invoke the form-paragraph function on a read-only text widget.
+
+ Exposures fixed.
+
+TextP.h:
+ Symbolic constants private to the Text widget should not conflict
+ with operating system headers files. The names of these symbolic
+ constants have each had the prefix Xaw added to them:
+ #define XawLF 0x0a
+ #define XawCR 0x0d
+ #define XawTAB 0x09
+ #define XawBS 0x08
+ #define XawSP 0x20
+ #define XawDEL 0x7f
+ #define XawBSLASH '\\'
+
+
+Toggle:
+* Toggle widget state is preserved across changes in sensitivity.
+
+ A string to widget converter is regisetered for radio groups.
+
+Tree:
+ New for R5.
+
+Paned:
+ Fixed bug that caused XtGeometryYes returns to have bogus values,
+ causes panes to get random sizes.
+
+Vendor:
+ Added support for the Resource Editor.
+ Fixed bug causing Shell to ignore all but first child.
+
+Viewport:
+ Added XawPannerReport support.
diff --git a/src/AllWidgets.c b/src/AllWidgets.c
new file mode 100644
index 0000000..5a0ad0b
--- /dev/null
+++ b/src/AllWidgets.c
@@ -0,0 +1,121 @@
+/* $Xorg: AllWidgets.c,v 1.4 2001/02/09 02:03:42 xorgcvs Exp $ */
+
+/*
+
+Copyright (c) 1991, 1994, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+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
+OPEN GROUP 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 Open Group 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 Open Group.
+
+*/
+
+#include <X11/IntrinsicP.h>
+#include <X11/Xmu/WidgetNode.h>
+
+extern WidgetClass applicationShellWidgetClass;
+extern WidgetClass asciiSinkObjectClass;
+extern WidgetClass asciiSrcObjectClass;
+extern WidgetClass asciiTextWidgetClass;
+extern WidgetClass boxWidgetClass;
+extern WidgetClass commandWidgetClass;
+extern WidgetClass compositeWidgetClass;
+extern WidgetClass constraintWidgetClass;
+extern WidgetClass coreWidgetClass;
+extern WidgetClass dialogWidgetClass;
+extern WidgetClass formWidgetClass;
+extern WidgetClass gripWidgetClass;
+extern WidgetClass labelWidgetClass;
+extern WidgetClass listWidgetClass;
+extern WidgetClass menuButtonWidgetClass;
+extern WidgetClass multiSinkObjectClass;
+extern WidgetClass multiSrcObjectClass;
+extern WidgetClass objectClass;
+extern WidgetClass overrideShellWidgetClass;
+extern WidgetClass panedWidgetClass;
+extern WidgetClass pannerWidgetClass;
+extern WidgetClass portholeWidgetClass;
+extern WidgetClass rectObjClass;
+extern WidgetClass repeaterWidgetClass;
+extern WidgetClass scrollbarWidgetClass;
+extern WidgetClass shellWidgetClass;
+extern WidgetClass simpleMenuWidgetClass;
+extern WidgetClass simpleWidgetClass;
+extern WidgetClass smeBSBObjectClass;
+extern WidgetClass smeLineObjectClass;
+extern WidgetClass smeObjectClass;
+extern WidgetClass stripChartWidgetClass;
+extern WidgetClass textSinkObjectClass;
+extern WidgetClass textSrcObjectClass;
+extern WidgetClass textWidgetClass;
+extern WidgetClass toggleWidgetClass;
+extern WidgetClass topLevelShellWidgetClass;
+extern WidgetClass transientShellWidgetClass;
+extern WidgetClass treeWidgetClass;
+extern WidgetClass vendorShellWidgetClass;
+extern WidgetClass viewportWidgetClass;
+extern WidgetClass wmShellWidgetClass;
+
+XmuWidgetNode XawWidgetArray[] = {
+{ "applicationShell", &applicationShellWidgetClass },
+{ "asciiSink", &asciiSinkObjectClass },
+{ "asciiSrc", &asciiSrcObjectClass },
+{ "asciiText", &asciiTextWidgetClass },
+{ "box", &boxWidgetClass },
+{ "command", &commandWidgetClass },
+{ "composite", &compositeWidgetClass },
+{ "constraint", &constraintWidgetClass },
+{ "core", &coreWidgetClass },
+{ "dialog", &dialogWidgetClass },
+{ "form", &formWidgetClass },
+{ "grip", &gripWidgetClass },
+{ "label", &labelWidgetClass },
+{ "list", &listWidgetClass },
+{ "menuButton", &menuButtonWidgetClass },
+{ "multiSink", &multiSinkObjectClass },
+{ "multiSrc", &multiSrcObjectClass },
+{ "object", &objectClass },
+{ "overrideShell", &overrideShellWidgetClass },
+{ "paned", &panedWidgetClass },
+{ "panner", &pannerWidgetClass },
+{ "porthole", &portholeWidgetClass },
+{ "rect", &rectObjClass },
+{ "repeater", &repeaterWidgetClass },
+{ "scrollbar", &scrollbarWidgetClass },
+{ "shell", &shellWidgetClass },
+{ "simpleMenu", &simpleMenuWidgetClass },
+{ "simple", &simpleWidgetClass },
+{ "smeBSB", &smeBSBObjectClass },
+{ "smeLine", &smeLineObjectClass },
+{ "sme", &smeObjectClass },
+{ "stripChart", &stripChartWidgetClass },
+{ "textSink", &textSinkObjectClass },
+{ "textSrc", &textSrcObjectClass },
+{ "text", &textWidgetClass },
+{ "toggle", &toggleWidgetClass },
+{ "topLevelShell", &topLevelShellWidgetClass },
+{ "transientShell", &transientShellWidgetClass },
+{ "tree", &treeWidgetClass },
+{ "vendorShell", &vendorShellWidgetClass },
+{ "viewport", &viewportWidgetClass },
+{ "wmShell", &wmShellWidgetClass },
+};
+
+int XawWidgetCount = XtNumber(XawWidgetArray);
+
diff --git a/src/AsciiSink.c b/src/AsciiSink.c
new file mode 100644
index 0000000..ddf6115
--- /dev/null
+++ b/src/AsciiSink.c
@@ -0,0 +1,692 @@
+/* $Xorg: AsciiSink.c,v 1.4 2001/02/09 02:03:42 xorgcvs Exp $ */
+
+/***********************************************************
+
+Copyright 1987, 1988, 1994, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+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
+OPEN GROUP 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 Open Group 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 Open Group.
+
+
+Copyright 1987, 1988 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+******************************************************************/
+
+#include <stdio.h>
+
+#include <X11/Xatom.h>
+#include <X11/IntrinsicP.h>
+#include <X11/StringDefs.h>
+#include <X11/Xaw/XawInit.h>
+#include <X11/Xaw/AsciiSinkP.h>
+#include <X11/Xaw/AsciiSrcP.h> /* For source function defs. */
+#include <X11/Xaw/TextP.h> /* I also reach into the text widget. */
+
+#ifdef GETLASTPOS
+#undef GETLASTPOS /* We will use our own GETLASTPOS. */
+#endif
+
+#define GETLASTPOS XawTextSourceScan(source, (XawTextPosition) 0, XawstAll, XawsdRight, 1, TRUE)
+
+static void Initialize(), Destroy();
+static Boolean SetValues();
+static int MaxLines(), MaxHeight();
+static void SetTabs();
+
+static void DisplayText(), InsertCursor(), FindPosition();
+static void FindDistance(), Resolve(), GetCursorBounds();
+
+#define offset(field) XtOffsetOf(AsciiSinkRec, ascii_sink.field)
+
+static XtResource resources[] = {
+ {XtNfont, XtCFont, XtRFontStruct, sizeof (XFontStruct *),
+ offset(font), XtRString, XtDefaultFont},
+ {XtNecho, XtCOutput, XtRBoolean, sizeof(Boolean),
+ offset(echo), XtRImmediate, (XtPointer) True},
+ {XtNdisplayNonprinting, XtCOutput, XtRBoolean, sizeof(Boolean),
+ offset(display_nonprinting), XtRImmediate, (XtPointer) True},
+};
+#undef offset
+
+#define SuperClass (&textSinkClassRec)
+AsciiSinkClassRec asciiSinkClassRec = {
+ {
+/* core_class fields */
+ /* superclass */ (WidgetClass) SuperClass,
+ /* class_name */ "AsciiSink",
+ /* widget_size */ sizeof(AsciiSinkRec),
+ /* class_initialize */ XawInitializeWidgetSet,
+ /* class_part_initialize */ NULL,
+ /* class_inited */ FALSE,
+ /* initialize */ Initialize,
+ /* initialize_hook */ NULL,
+ /* obj1 */ NULL,
+ /* obj2 */ NULL,
+ /* obj3 */ 0,
+ /* resources */ resources,
+ /* num_resources */ XtNumber(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
+ },
+/* text_sink_class fields */
+ {
+ /* DisplayText */ DisplayText,
+ /* InsertCursor */ InsertCursor,
+ /* ClearToBackground */ XtInheritClearToBackground,
+ /* FindPosition */ FindPosition,
+ /* FindDistance */ FindDistance,
+ /* Resolve */ Resolve,
+ /* MaxLines */ MaxLines,
+ /* MaxHeight */ MaxHeight,
+ /* SetTabs */ SetTabs,
+ /* GetCursorBounds */ GetCursorBounds
+ },
+/* ascii_sink_class fields */
+ {
+ /* unused */ 0
+ }
+};
+
+WidgetClass asciiSinkObjectClass = (WidgetClass)&asciiSinkClassRec;
+
+/* Utilities */
+
+static int
+CharWidth (w, x, c)
+Widget w;
+int x;
+unsigned char c;
+{
+ int i, width, nonPrinting;
+ AsciiSinkObject sink = (AsciiSinkObject) w;
+ XFontStruct *font = sink->ascii_sink.font;
+ Position *tab;
+
+ if ( c == XawLF ) return(0);
+
+ if (c == XawTAB) {
+ /* Adjust for Left Margin. */
+ x -= ((TextWidget) XtParent(w))->text.margin.left;
+
+ if (x >= (int)XtParent(w)->core.width) return 0;
+ for (i = 0, tab = sink->text_sink.tabs ;
+ i < sink->text_sink.tab_count ; i++, tab++) {
+ if (x < *tab) {
+ if (*tab < (int)XtParent(w)->core.width)
+ return *tab - x;
+ else
+ return 0;
+ }
+ }
+ return 0;
+ }
+
+ if ( (nonPrinting = (c < (unsigned char) XawSP)) )
+ if (sink->ascii_sink.display_nonprinting)
+ c += '@';
+ else {
+ c = XawSP;
+ nonPrinting = False;
+ }
+
+ if (font->per_char &&
+ (c >= font->min_char_or_byte2 && c <= font->max_char_or_byte2))
+ width = font->per_char[c - font->min_char_or_byte2].width;
+ else
+ width = font->min_bounds.width;
+
+ if (nonPrinting)
+ width += CharWidth(w, x, (unsigned char) '^');
+
+ return width;
+}
+
+/* Function Name: PaintText
+ * Description: Actually paints the text into the windoe.
+ * Arguments: w - the text widget.
+ * gc - gc to paint text with.
+ * x, y - location to paint the text.
+ * buf, len - buffer and length of text to paint.
+ * Returns: the width of the text painted, or 0.
+ *
+ * NOTE: If this string attempts to paint past the end of the window
+ * then this function will return zero.
+ */
+
+static Dimension
+PaintText(w, gc, x, y, buf, len)
+Widget w;
+GC gc;
+Position x, y;
+unsigned char * buf;
+int len;
+{
+ AsciiSinkObject sink = (AsciiSinkObject) w;
+ TextWidget ctx = (TextWidget) XtParent(w);
+
+ Position max_x;
+ Dimension width = XTextWidth(sink->ascii_sink.font, (char *) buf, len);
+ max_x = (Position) ctx->core.width;
+
+ if ( ((int) width) <= -x) /* Don't draw if we can't see it. */
+ return(width);
+
+ XDrawImageString(XtDisplay(ctx), XtWindow(ctx), gc,
+ (int) x, (int) y, (char *) buf, len);
+ if ( (((Position) width + x) > max_x) && (ctx->text.margin.right != 0) ) {
+ x = ctx->core.width - ctx->text.margin.right;
+ width = ctx->text.margin.right;
+ XFillRectangle(XtDisplay((Widget) ctx), XtWindow( (Widget) ctx),
+ sink->ascii_sink.normgc, (int) x,
+ (int) y - sink->ascii_sink.font->ascent,
+ (unsigned int) width,
+ (unsigned int) (sink->ascii_sink.font->ascent +
+ sink->ascii_sink.font->descent));
+ return(0);
+ }
+ return(width);
+}
+
+/* Sink Object Functions */
+
+/*
+ * This function does not know about drawing more than one line of text.
+ */
+
+static void
+DisplayText(w, x, y, pos1, pos2, highlight)
+Widget w;
+Position x, y;
+Boolean highlight;
+XawTextPosition pos1, pos2;
+{
+ AsciiSinkObject sink = (AsciiSinkObject) w;
+ Widget source = XawTextGetSource(XtParent(w));
+ unsigned char buf[BUFSIZ];
+
+ int j, k;
+ XawTextBlock blk;
+ GC gc = highlight ? sink->ascii_sink.invgc : sink->ascii_sink.normgc;
+ GC invgc = highlight ? sink->ascii_sink.normgc : sink->ascii_sink.invgc;
+
+ if (!sink->ascii_sink.echo) return;
+
+ y += sink->ascii_sink.font->ascent;
+ for ( j = 0 ; pos1 < pos2 ; ) {
+ pos1 = XawTextSourceRead(source, pos1, &blk, (int) pos2 - pos1);
+ for (k = 0; k < blk.length; k++) {
+ if (j >= BUFSIZ) { /* buffer full, dump the text. */
+ x += PaintText(w, gc, x, y, buf, j);
+ j = 0;
+ }
+ buf[j] = blk.ptr[k];
+ if (buf[j] == XawLF) /* line feeds ('\n') are not printed. */
+ continue;
+
+ else if (buf[j] == '\t') {
+ Position temp = 0;
+ Dimension width;
+
+ if ((j != 0) && ((temp = PaintText(w, gc, x, y, buf, j)) == 0))
+ return;
+
+ x += temp;
+ width = CharWidth(w, x, (unsigned char) '\t');
+ XFillRectangle(XtDisplayOfObject(w), XtWindowOfObject(w),
+ invgc, (int) x,
+ (int) y - sink->ascii_sink.font->ascent,
+ (unsigned int) width,
+ (unsigned int) (sink->ascii_sink.font->ascent +
+ sink->ascii_sink.font->descent));
+ x += width;
+ j = -1;
+ }
+ else if ( buf[j] < (unsigned char) ' ' ) {
+ if (sink->ascii_sink.display_nonprinting) {
+ buf[j + 1] = buf[j] + '@';
+ buf[j] = '^';
+ j++;
+ }
+ else
+ buf[j] = ' ';
+ }
+ j++;
+ }
+ }
+ if (j > 0)
+ (void) PaintText(w, gc, x, y, buf, j);
+}
+
+#define insertCursor_width 6
+#define insertCursor_height 3
+static char insertCursor_bits[] = {0x0c, 0x1e, 0x33};
+
+static Pixmap
+CreateInsertCursor(s)
+Screen *s;
+{
+ return (XCreateBitmapFromData (DisplayOfScreen(s), RootWindowOfScreen(s),
+ insertCursor_bits, insertCursor_width, insertCursor_height));
+}
+
+/* Function Name: GetCursorBounds
+ * Description: Returns the size and location of the cursor.
+ * Arguments: w - the text object.
+ * RETURNED rect - an X rectangle to return the cursor bounds in.
+ * Returns: none.
+ */
+
+static void
+GetCursorBounds(w, rect)
+Widget w;
+XRectangle * rect;
+{
+ AsciiSinkObject sink = (AsciiSinkObject) w;
+
+ rect->width = (unsigned short) insertCursor_width;
+ rect->height = (unsigned short) insertCursor_height;
+ rect->x = sink->ascii_sink.cursor_x - (short) (rect->width / 2);
+ rect->y = sink->ascii_sink.cursor_y - (short) rect->height;
+}
+
+/*
+ * The following procedure manages the "insert" cursor.
+ */
+
+static void
+InsertCursor (w, x, y, state)
+Widget w;
+Position x, y;
+XawTextInsertState state;
+{
+ AsciiSinkObject sink = (AsciiSinkObject) w;
+ Widget text_widget = XtParent(w);
+ XRectangle rect;
+
+ sink->ascii_sink.cursor_x = x;
+ sink->ascii_sink.cursor_y = y;
+
+ GetCursorBounds(w, &rect);
+ if (state != sink->ascii_sink.laststate && XtIsRealized(text_widget))
+ XCopyPlane(XtDisplay(text_widget),
+ sink->ascii_sink.insertCursorOn,
+ XtWindow(text_widget), sink->ascii_sink.xorgc,
+ 0, 0, (unsigned int) rect.width, (unsigned int) rect.height,
+ (int) rect.x, (int) rect.y, 1);
+ sink->ascii_sink.laststate = state;
+}
+
+/*
+ * Given two positions, find the distance between them.
+ */
+
+static void
+FindDistance (w, fromPos, fromx, toPos, resWidth, resPos, resHeight)
+Widget w;
+XawTextPosition fromPos; /* First position. */
+int fromx; /* Horizontal location of first position. */
+XawTextPosition toPos; /* Second position. */
+int *resWidth; /* Distance between fromPos and resPos. */
+XawTextPosition *resPos; /* Actual second position used. */
+int *resHeight; /* Height required. */
+{
+ AsciiSinkObject sink = (AsciiSinkObject) w;
+ Widget source = XawTextGetSource(XtParent(w));
+
+ XawTextPosition index, lastPos;
+ unsigned char c;
+ XawTextBlock blk;
+
+ /* we may not need this */
+ lastPos = GETLASTPOS;
+ XawTextSourceRead(source, fromPos, &blk, (int) toPos - fromPos);
+ *resWidth = 0;
+ for (index = fromPos; index != toPos && index < lastPos; index++) {
+ if (index - blk.firstPos >= blk.length)
+ XawTextSourceRead(source, index, &blk, (int) toPos - fromPos);
+ c = blk.ptr[index - blk.firstPos];
+ *resWidth += CharWidth(w, fromx + *resWidth, c);
+ if (c == XawLF) {
+ index++;
+ break;
+ }
+ }
+ *resPos = index;
+ *resHeight = sink->ascii_sink.font->ascent +sink->ascii_sink.font->descent;
+}
+
+
+static void
+FindPosition(w, fromPos, fromx, width, stopAtWordBreak,
+ resPos, resWidth, resHeight)
+Widget w;
+XawTextPosition fromPos; /* Starting position. */
+int fromx; /* Horizontal location of starting position.*/
+int width; /* Desired width. */
+int stopAtWordBreak; /* Whether the resulting position should be at
+ a word break. */
+XawTextPosition *resPos; /* Resulting position. */
+int *resWidth; /* Actual width used. */
+int *resHeight; /* Height required. */
+{
+ AsciiSinkObject sink = (AsciiSinkObject) w;
+ Widget source = XawTextGetSource(XtParent(w));
+
+ XawTextPosition lastPos, index, whiteSpacePosition;
+ int lastWidth, whiteSpaceWidth;
+ Boolean whiteSpaceSeen;
+ unsigned char c;
+ XawTextBlock blk;
+
+ lastPos = GETLASTPOS;
+
+ XawTextSourceRead(source, fromPos, &blk, BUFSIZ);
+ *resWidth = 0;
+ whiteSpaceSeen = FALSE;
+ c = 0;
+ for (index = fromPos; *resWidth <= width && index < lastPos; index++) {
+ lastWidth = *resWidth;
+ if (index - blk.firstPos >= blk.length)
+ XawTextSourceRead(source, index, &blk, BUFSIZ);
+ c = blk.ptr[index - blk.firstPos];
+ *resWidth += CharWidth(w, fromx + *resWidth, c);
+
+ if ((c == XawSP || c == XawTAB) && *resWidth <= width) {
+ whiteSpaceSeen = TRUE;
+ whiteSpacePosition = index;
+ whiteSpaceWidth = *resWidth;
+ }
+ if (c == XawLF) {
+ index++;
+ break;
+ }
+ }
+ if (*resWidth > width && index > fromPos) {
+ *resWidth = lastWidth;
+ index--;
+ if (stopAtWordBreak && whiteSpaceSeen) {
+ index = whiteSpacePosition + 1;
+ *resWidth = whiteSpaceWidth;
+ }
+ }
+ if (index == lastPos && c != XawLF) index = lastPos + 1;
+ *resPos = index;
+ *resHeight = sink->ascii_sink.font->ascent +sink->ascii_sink.font->descent;
+}
+
+static void
+Resolve (w, pos, fromx, width, leftPos, rightPos)
+Widget w;
+XawTextPosition pos;
+int fromx, width;
+XawTextPosition *leftPos, *rightPos;
+{
+ int resWidth, resHeight;
+ Widget source = XawTextGetSource(XtParent(w));
+
+ FindPosition(w, pos, fromx, width, FALSE, leftPos, &resWidth, &resHeight);
+ if (*leftPos > GETLASTPOS)
+ *leftPos = GETLASTPOS;
+ *rightPos = *leftPos;
+}
+
+static void
+GetGC(sink)
+AsciiSinkObject sink;
+{
+ XtGCMask valuemask = (GCFont |
+ GCGraphicsExposures | GCForeground | GCBackground );
+ XGCValues values;
+
+ values.font = sink->ascii_sink.font->fid;
+ values.graphics_exposures = (Bool) FALSE;
+
+ values.foreground = sink->text_sink.foreground;
+ values.background = sink->text_sink.background;
+ sink->ascii_sink.normgc = XtGetGC((Widget)sink, valuemask, &values);
+
+ values.foreground = sink->text_sink.background;
+ values.background = sink->text_sink.foreground;
+ sink->ascii_sink.invgc = XtGetGC((Widget)sink, valuemask, &values);
+
+ values.function = GXxor;
+ values.background = (unsigned long) 0L; /* (pix ^ 0) = pix */
+ values.foreground = (sink->text_sink.background ^
+ sink->text_sink.foreground);
+ valuemask = GCGraphicsExposures | GCFunction | GCForeground | GCBackground;
+
+ sink->ascii_sink.xorgc = XtGetGC((Widget)sink, valuemask, &values);
+}
+
+
+/***** Public routines *****/
+
+/* 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
+Initialize(request, new, args, num_args)
+Widget request, new;
+ArgList args;
+Cardinal *num_args;
+{
+ AsciiSinkObject sink = (AsciiSinkObject) new;
+
+ GetGC(sink);
+
+ sink->ascii_sink.insertCursorOn= CreateInsertCursor(XtScreenOfObject(new));
+ sink->ascii_sink.laststate = XawisOff;
+ sink->ascii_sink.cursor_x = sink->ascii_sink.cursor_y = 0;
+}
+
+/* Function Name: Destroy
+ * Description: This function cleans up when the object is
+ * destroyed.
+ * Arguments: w - the AsciiSink Object.
+ * Returns: none.
+ */
+
+static void
+Destroy(w)
+Widget w;
+{
+ AsciiSinkObject sink = (AsciiSinkObject) w;
+
+ XtReleaseGC(w, sink->ascii_sink.normgc);
+ XtReleaseGC(w, sink->ascii_sink.invgc);
+ XtReleaseGC(w, sink->ascii_sink.xorgc);
+ XFreePixmap(XtDisplayOfObject(w), sink->ascii_sink.insertCursorOn);
+}
+
+/* Function Name: SetValues
+ * Description: Sets the values for the AsciiSink
+ * 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
+SetValues(current, request, new, args, num_args)
+Widget current, request, new;
+ArgList args;
+Cardinal *num_args;
+{
+ AsciiSinkObject w = (AsciiSinkObject) new;
+ AsciiSinkObject old_w = (AsciiSinkObject) current;
+
+ if (w->ascii_sink.font != old_w->ascii_sink.font
+ || w->text_sink.background != old_w->text_sink.background
+ || w->text_sink.foreground != old_w->text_sink.foreground) {
+ XtReleaseGC((Widget)w, w->ascii_sink.normgc);
+ XtReleaseGC((Widget)w, w->ascii_sink.invgc);
+ XtReleaseGC((Widget)w, w->ascii_sink.xorgc);
+ GetGC(w);
+ ((TextWidget)XtParent(new))->text.redisplay_needed = True;
+ } else {
+ if ( (w->ascii_sink.echo != old_w->ascii_sink.echo) ||
+ (w->ascii_sink.display_nonprinting !=
+ old_w->ascii_sink.display_nonprinting) )
+ ((TextWidget)XtParent(new))->text.redisplay_needed = True;
+ }
+
+ return False;
+}
+
+/* Function Name: MaxLines
+ * Description: Finds the Maximum number of lines that will fit in
+ * a given height.
+ * Arguments: w - the AsciiSink Object.
+ * height - height to fit lines into.
+ * Returns: the number of lines that will fit.
+ */
+
+/* ARGSUSED */
+static int
+MaxLines(w, height)
+Widget w;
+Dimension height;
+{
+ AsciiSinkObject sink = (AsciiSinkObject) w;
+ int font_height;
+
+ font_height = sink->ascii_sink.font->ascent + sink->ascii_sink.font->descent;
+ return( ((int) height) / font_height );
+}
+
+/* Function Name: MaxHeight
+ * Description: Finds the Minium height that will contain a given number
+ * lines.
+ * Arguments: w - the AsciiSink Object.
+ * lines - the number of lines.
+ * Returns: the height.
+ */
+
+/* ARGSUSED */
+static int
+MaxHeight(w, lines)
+Widget w;
+int lines;
+{
+ AsciiSinkObject sink = (AsciiSinkObject) w;
+
+ return(lines * (sink->ascii_sink.font->ascent +
+ sink->ascii_sink.font->descent));
+}
+
+/* Function Name: SetTabs
+ * Description: Sets the Tab stops.
+ * Arguments: w - the AsciiSink Object.
+ * tab_count - the number of tabs in the list.
+ * tabs - the text positions of the tabs.
+ * Returns: none
+ */
+
+static void
+SetTabs(w, tab_count, tabs)
+Widget w;
+int tab_count;
+short *tabs;
+{
+ AsciiSinkObject sink = (AsciiSinkObject) w;
+ int i;
+ Atom XA_FIGURE_WIDTH;
+ unsigned long figure_width = 0;
+ XFontStruct *font = sink->ascii_sink.font;
+
+/*
+ * Find the figure width of the current font.
+ */
+
+ XA_FIGURE_WIDTH = XInternAtom(XtDisplayOfObject(w), "FIGURE_WIDTH", FALSE);
+ if ( (XA_FIGURE_WIDTH != None) &&
+ ( (!XGetFontProperty(font, XA_FIGURE_WIDTH, &figure_width)) ||
+ (figure_width == 0)) )
+ if (font->per_char && font->min_char_or_byte2 <= '$' &&
+ font->max_char_or_byte2 >= '$')
+ figure_width = font->per_char['$' - font->min_char_or_byte2].width;
+ else
+ figure_width = font->max_bounds.width;
+
+ if (tab_count > sink->text_sink.tab_count) {
+ sink->text_sink.tabs = (Position *)
+ XtRealloc((char *) sink->text_sink.tabs,
+ (Cardinal) (tab_count * sizeof(Position)));
+ sink->text_sink.char_tabs = (short *)
+ XtRealloc((char *) sink->text_sink.char_tabs,
+ (Cardinal) (tab_count * sizeof(short)));
+ }
+
+ for ( i = 0 ; i < tab_count ; i++ ) {
+ sink->text_sink.tabs[i] = tabs[i] * figure_width;
+ sink->text_sink.char_tabs[i] = tabs[i];
+ }
+
+ sink->text_sink.tab_count = tab_count;
+
+#ifndef NO_TAB_FIX
+ { TextWidget ctx = (TextWidget)XtParent(w);
+ ctx->text.redisplay_needed = True;
+ _XawTextBuildLineTable(ctx, ctx->text.lt.top, TRUE);
+ }
+#endif
+}
diff --git a/src/AsciiSrc.c b/src/AsciiSrc.c
new file mode 100644
index 0000000..f377640
--- /dev/null
+++ b/src/AsciiSrc.c
@@ -0,0 +1,1408 @@
+/* $Xorg: AsciiSrc.c,v 1.4 2001/02/09 02:03:42 xorgcvs Exp $ */
+
+/*
+
+Copyright 1989, 1994, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+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
+OPEN GROUP 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 Open Group 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 Open Group.
+
+*/
+
+/*
+ * AsciiSrc.c - AsciiSrc object. (For use with the text widget).
+ *
+ */
+
+#include <X11/IntrinsicP.h>
+#include <stdio.h>
+#include <ctype.h>
+#include <errno.h>
+#include <X11/StringDefs.h>
+#include <X11/Xos.h>
+#ifndef X_NOT_STDC_ENV
+#include <stdlib.h>
+#endif
+#include <X11/Xfuncs.h>
+#include <X11/Xaw/XawInit.h>
+#include <X11/Xaw/AsciiSrcP.h>
+#include <X11/Xmu/Misc.h>
+#include <X11/Xmu/CharSet.h>
+#include <X11/Xaw/MultiSrcP.h>
+
+
+#if (defined(ASCII_STRING) || defined(ASCII_DISK))
+# include <X11/Xaw/AsciiText.h> /* for Widget Classes. */
+#endif
+
+
+/****************************************************************
+ *
+ * Full class record constant
+ *
+ ****************************************************************/
+
+/* Private Data */
+
+static int magic_value = MAGIC_VALUE;
+
+#define offset(field) XtOffsetOf(AsciiSrcRec, ascii_src.field)
+
+static XtResource resources[] = {
+ {XtNstring, XtCString, XtRString, sizeof (char *),
+ offset(string), XtRString, NULL},
+ {XtNtype, XtCType, XtRAsciiType, sizeof (XawAsciiType),
+ offset(type), XtRImmediate, (XtPointer)XawAsciiString},
+ {XtNdataCompression, XtCDataCompression, XtRBoolean, sizeof (Boolean),
+ offset(data_compression), XtRImmediate, (XtPointer) TRUE},
+ {XtNpieceSize, XtCPieceSize, XtRInt, sizeof (XawTextPosition),
+ offset(piece_size), XtRImmediate, (XtPointer) BUFSIZ},
+ {XtNcallback, XtCCallback, XtRCallback, sizeof(XtPointer),
+ offset(callback), XtRCallback, (XtPointer)NULL},
+ {XtNuseStringInPlace, XtCUseStringInPlace, XtRBoolean, sizeof (Boolean),
+ offset(use_string_in_place), XtRImmediate, (XtPointer) FALSE},
+ {XtNlength, XtCLength, XtRInt, sizeof (int),
+ offset(ascii_length), XtRInt, (XtPointer) &magic_value},
+
+#ifdef ASCII_DISK
+ {XtNfile, XtCFile, XtRString, sizeof (String),
+ offset(filename), XtRString, NULL},
+#endif /* ASCII_DISK */
+};
+#undef offset
+
+static XawTextPosition Scan(), Search(), ReadText();
+static int ReplaceText();
+static Piece * FindPiece(), * AllocNewPiece();
+static FILE * InitStringOrFile();
+static void FreeAllPieces(), RemovePiece(), BreakPiece(), LoadPieces();
+static void RemoveOldStringOrFile(), CvtStringToAsciiType();
+static void ClassInitialize(), Initialize(), Destroy(), GetValuesHook();
+static String MyStrncpy(), StorePiecesInString();
+static Boolean SetValues(), WriteToFile();
+#ifdef X_NOT_STDC_ENV
+extern int errno;
+#endif
+
+#ifdef X_NOT_POSIX
+#define Off_t long
+#define Size_t unsigned int
+#else
+#define Off_t off_t
+#define Size_t size_t
+#endif
+
+#define superclass (&textSrcClassRec)
+AsciiSrcClassRec asciiSrcClassRec = {
+ {
+/* core_class fields */
+ /* superclass */ (WidgetClass) superclass,
+ /* class_name */ "AsciiSrc",
+ /* widget_size */ sizeof(AsciiSrcRec),
+ /* class_initialize */ ClassInitialize,
+ /* class_part_initialize */ NULL,
+ /* class_inited */ FALSE,
+ /* initialize */ Initialize,
+ /* initialize_hook */ NULL,
+ /* realize */ NULL,
+ /* actions */ NULL,
+ /* num_actions */ 0,
+ /* resources */ resources,
+ /* num_resources */ XtNumber(resources),
+ /* xrm_class */ NULLQUARK,
+ /* compress_motion */ FALSE,
+ /* compress_exposure */ FALSE,
+ /* compress_enterleave */ FALSE,
+ /* visible_interest */ FALSE,
+ /* destroy */ Destroy,
+ /* resize */ NULL,
+ /* expose */ NULL,
+ /* set_values */ SetValues,
+ /* set_values_hook */ NULL,
+ /* set_values_almost */ NULL,
+ /* get_values_hook */ GetValuesHook,
+ /* accept_focus */ NULL,
+ /* version */ XtVersion,
+ /* callback_private */ NULL,
+ /* tm_table */ NULL,
+ /* query_geometry */ NULL,
+ /* display_accelerator */ NULL,
+ /* extension */ NULL
+ },
+/* textSrc_class fields */
+ {
+ /* Read */ ReadText,
+ /* Replace */ ReplaceText,
+ /* Scan */ Scan,
+ /* Search */ Search,
+ /* SetSelection */ XtInheritSetSelection,
+ /* ConvertSelection */ XtInheritConvertSelection
+ },
+/* asciiSrc_class fields */
+ {
+ /* Keep the compiler happy */ '\0'
+ }
+};
+
+WidgetClass asciiSrcObjectClass = (WidgetClass)&asciiSrcClassRec;
+
+/************************************************************
+ *
+ * Semi-Public Interfaces.
+ *
+ ************************************************************/
+
+/* Function Name: ClassInitialize
+ * Description: Class Initialize routine, called only once.
+ * Arguments: none.
+ * Returns: none.
+ */
+
+static void
+ClassInitialize()
+{
+ XawInitializeWidgetSet();
+ XtAddConverter( XtRString, XtRAsciiType, CvtStringToAsciiType,
+ NULL, (Cardinal) 0);
+}
+
+/* Function Name: Initialize
+ * Description: Initializes the simple menu widget
+ * Arguments: request - the widget requested by the argument list.
+ * new - the new widget with both resource and non
+ * resource values.
+ * Returns: none.
+ */
+
+/* ARGSUSED */
+static void
+Initialize(request, new, args, num_args)
+Widget request, new;
+ArgList args;
+Cardinal *num_args;
+{
+ AsciiSrcObject src = (AsciiSrcObject) new;
+ FILE * file;
+
+/*
+ * Set correct flags (override resources) depending upon widget class.
+ */
+
+ src->text_src.text_format = XawFmt8Bit; /* data format. */
+
+#ifdef ASCII_DISK
+ if (XtIsSubclass(XtParent(new), asciiDiskWidgetClass)) {
+ src->ascii_src.type = XawAsciiFile;
+ src->ascii_src.string = src->ascii_src.filename;
+ }
+#endif
+
+#ifdef ASCII_STRING
+ if (XtIsSubclass(XtParent(new), asciiStringWidgetClass)) {
+ src->ascii_src.use_string_in_place = TRUE;
+ src->ascii_src.type = XawAsciiString;
+ }
+#endif
+
+ src->ascii_src.changes = FALSE;
+ src->ascii_src.allocated_string = FALSE;
+
+ file = InitStringOrFile(src, src->ascii_src.type == XawAsciiFile);
+ LoadPieces(src, file, NULL);
+
+ if (file != NULL) fclose(file);
+}
+
+/* Function Name: ReadText
+ * Description: This function reads the source.
+ * Arguments: w - the AsciiSource widget.
+ * pos - position of the text to retreive.
+ * RETURNED text - text block that will contain returned text.
+ * length - maximum number of characters to read.
+ * Returns: The number of characters read into the buffer.
+ */
+
+static XawTextPosition
+ReadText(w, pos, text, length)
+Widget w;
+XawTextPosition pos;
+XawTextBlock *text;
+int length;
+{
+ AsciiSrcObject src = (AsciiSrcObject) w;
+ XawTextPosition count, start;
+ Piece * piece = FindPiece(src, pos, &start);
+
+ text->firstPos = pos;
+ text->ptr = piece->text + (pos - start);
+ count = piece->used - (pos - start);
+ text->length = (length > count) ? count : length;
+ return(pos + text->length);
+}
+
+/* Function Name: ReplaceText.
+ * Description: Replaces a block of text with new text.
+ * Arguments: w - the AsciiSource widget.
+ * startPos, endPos - ends of text that will be removed.
+ * text - new text to be inserted into buffer at startPos.
+ * Returns: XawEditError or XawEditDone.
+ */
+
+/*ARGSUSED*/
+static int
+ReplaceText (w, startPos, endPos, text)
+Widget w;
+XawTextPosition startPos, endPos;
+XawTextBlock *text;
+{
+ AsciiSrcObject src = (AsciiSrcObject) w;
+ Piece *start_piece, *end_piece, *temp_piece;
+ XawTextPosition start_first, end_first;
+ int length, firstPos;
+
+/*
+ * Editing a read only source is not allowed.
+ */
+
+ if (src->text_src.edit_mode == XawtextRead)
+ return(XawEditError);
+
+ start_piece = FindPiece(src, startPos, &start_first);
+ end_piece = FindPiece(src, endPos, &end_first);
+
+ src->ascii_src.changes = TRUE; /* We have changed the buffer. */
+
+/*
+ * Remove Old Stuff.
+ */
+
+ if (start_piece != end_piece) {
+ temp_piece = start_piece->next;
+
+/*
+ * If empty and not the only piece then remove it.
+ */
+
+ if ( ((start_piece->used = startPos - start_first) == 0) &&
+ !((start_piece->next == NULL) && (start_piece->prev == NULL)) )
+ RemovePiece(src, start_piece);
+
+ while (temp_piece != end_piece) {
+ temp_piece = temp_piece->next;
+ RemovePiece(src, temp_piece->prev);
+ }
+ end_piece->used -= endPos - end_first;
+ if (end_piece->used != 0)
+ MyStrncpy(end_piece->text, (end_piece->text + endPos - end_first),
+ (int) end_piece->used);
+ }
+ else { /* We are fully in one piece. */
+ if ( (start_piece->used -= endPos - startPos) == 0) {
+ if ( !((start_piece->next == NULL) && (start_piece->prev == NULL)) )
+ RemovePiece(src, start_piece);
+ }
+ else {
+ MyStrncpy(start_piece->text + (startPos - start_first),
+ start_piece->text + (endPos - start_first),
+ (int) (start_piece->used - (startPos - start_first)) );
+ if ( src->ascii_src.use_string_in_place &&
+ ((src->ascii_src.length - (endPos - startPos)) <
+ (src->ascii_src.piece_size - 1)) )
+ start_piece->text[src->ascii_src.length - (endPos - startPos)] = '\0';
+ }
+ }
+
+ src->ascii_src.length += -(endPos - startPos) + text->length;
+
+ if ( text->length != 0) {
+
+ /*
+ * Put in the New Stuff.
+ */
+
+ start_piece = FindPiece(src, startPos, &start_first);
+
+ length = text->length;
+ firstPos = text->firstPos;
+
+ while (length > 0) {
+ char * ptr;
+ int fill;
+
+ if (src->ascii_src.use_string_in_place) {
+ if (start_piece->used == (src->ascii_src.piece_size - 1)) {
+ /*
+ * If we are in ascii string emulation mode. Then the
+ * string is not allowed to grow.
+ */
+ start_piece->used = src->ascii_src.length =
+ src->ascii_src.piece_size - 1;
+ start_piece->text[src->ascii_src.length] = '\0';
+ return(XawEditError);
+ }
+ }
+
+
+ if (start_piece->used == src->ascii_src.piece_size) {
+ BreakPiece(src, start_piece);
+ start_piece = FindPiece(src, startPos, &start_first);
+ }
+
+ fill = Min((int)(src->ascii_src.piece_size - start_piece->used), length);
+
+ ptr = start_piece->text + (startPos - start_first);
+ MyStrncpy(ptr + fill, ptr,
+ (int) start_piece->used - (startPos - start_first));
+ strncpy(ptr, text->ptr + firstPos, fill);
+
+ startPos += fill;
+ firstPos += fill;
+ start_piece->used += fill;
+ length -= fill;
+ }
+ }
+
+ if (src->ascii_src.use_string_in_place)
+ start_piece->text[start_piece->used] = '\0';
+
+ XtCallCallbacks(w, XtNcallback, NULL); /* Call callbacks, we have changed
+ the buffer. */
+
+ return(XawEditDone);
+}
+
+/* Function Name: Scan
+ * Description: Scans the text source for the number and type
+ * of item specified.
+ * Arguments: w - the AsciiSource widget.
+ * position - the position to start scanning.
+ * type - type of thing to scan for.
+ * dir - direction to scan.
+ * count - which occurance if this thing to search for.
+ * include - whether or not to include the character found in
+ * the position that is returned.
+ * Returns: the position of the item found.
+ *
+ * Note: While there are only 'n' characters in the file there are n+1
+ * possible cursor positions (one before the first character and
+ * one after the last character.
+ */
+
+static
+XawTextPosition
+Scan (w, position, type, dir, count, include)
+Widget w;
+XawTextPosition position;
+XawTextScanType type;
+XawTextScanDirection dir;
+int count;
+Boolean include;
+{
+ AsciiSrcObject src = (AsciiSrcObject) w;
+ int inc;
+ Piece* piece;
+ XawTextPosition first, first_eol_position;
+ char* ptr;
+
+ if (type == XawstAll) { /* Optomize this common case. */
+ if (dir == XawsdRight)
+ return(src->ascii_src.length);
+ return(0); /* else. */
+ }
+
+ if (position > src->ascii_src.length)
+ position = src->ascii_src.length;
+
+ if ( dir == XawsdRight ) {
+ if (position == src->ascii_src.length)
+/*
+ * Scanning right from src->ascii_src.length???
+ */
+ return(src->ascii_src.length);
+ inc = 1;
+ }
+ else {
+ if (position == 0)
+ return(0); /* Scanning left from 0??? */
+ inc = -1;
+ position--;
+ }
+
+ piece = FindPiece(src, position, &first);
+
+/*
+ * If the buffer is empty then return 0.
+ */
+
+ if ( piece->used == 0 ) return(0);
+
+ ptr = (position - first) + piece->text;
+
+ switch (type) {
+ case XawstEOL:
+ case XawstParagraph:
+ case XawstWhiteSpace:
+ for ( ; count > 0 ; count-- ) {
+ Boolean non_space = FALSE, first_eol = TRUE;
+ /* CONSTCOND */
+ while (TRUE) {
+ unsigned char c = *ptr;
+
+ ptr += inc;
+ position += inc;
+
+ if (type == XawstWhiteSpace) {
+ if (isspace(c)) {
+ if (non_space)
+ break;
+ }
+ else
+ non_space = TRUE;
+ }
+ else if (type == XawstEOL) {
+ if (c == '\n') break;
+ }
+ else { /* XawstParagraph */
+ if (first_eol) {
+ if (c == '\n') {
+ first_eol_position = position;
+ first_eol = FALSE;
+ }
+ }
+ else
+ if ( c == '\n')
+ break;
+ else if ( !isspace(c) )
+ first_eol = TRUE;
+ }
+
+
+ if ( ptr < piece->text ) {
+ piece = piece->prev;
+ if (piece == NULL) /* Begining of text. */
+ return(0);
+ ptr = piece->text + piece->used - 1;
+ }
+ else if ( ptr >= (piece->text + piece->used) ) {
+ piece = piece->next;
+ if (piece == NULL) /* End of text. */
+ return(src->ascii_src.length);
+ ptr = piece->text;
+ }
+ }
+ }
+ if (!include) {
+ if ( type == XawstParagraph)
+ position = first_eol_position;
+ position -= inc;
+ }
+ break;
+ case XawstPositions:
+ position += count * inc;
+ break;
+/* case XawstAll: ---- handled in special code above */
+ }
+
+ if ( dir == XawsdLeft )
+ position++;
+
+ if (position >= src->ascii_src.length)
+ return(src->ascii_src.length);
+ if (position < 0)
+ return(0);
+
+ return(position);
+}
+
+/* Function Name: Search
+ * Description: Searchs the text source for the text block passed
+ * Arguments: w - the AsciiSource Widget.
+ * position - the position to start scanning.
+ * dir - direction to scan.
+ * text - the text block to search for.
+ * Returns: the position of the item found.
+ */
+
+static XawTextPosition
+Search(w, position, dir, text)
+Widget w;
+XawTextPosition position;
+XawTextScanDirection dir;
+XawTextBlock * text;
+{
+ AsciiSrcObject src = (AsciiSrcObject) w;
+ int inc, count = 0;
+ char * ptr;
+ Piece * piece;
+ char * buf;
+ XawTextPosition first;
+
+ if ( dir == XawsdRight )
+ inc = 1;
+ else {
+ inc = -1;
+ if (position == 0)
+ return(XawTextSearchError); /* scanning left from 0??? */
+ position--;
+ }
+
+ buf = XtMalloc((unsigned)sizeof(unsigned char) * text->length);
+ strncpy(buf, (text->ptr + text->firstPos), text->length);
+ piece = FindPiece(src, position, &first);
+ ptr = (position - first) + piece->text;
+
+ /* CONSTCOND */
+ while (TRUE) {
+ if (*ptr == ((dir == XawsdRight) ? *(buf + count)
+ : *(buf + text->length - count - 1)) ) {
+ if (count == (text->length - 1))
+ break;
+ else
+ count++;
+ }
+ else {
+ if (count != 0) {
+ position -=inc * count;
+ ptr -= inc * count;
+ }
+ count = 0;
+ }
+
+ ptr += inc;
+ position += inc;
+
+ while ( ptr < piece->text ) {
+ piece = piece->prev;
+ if (piece == NULL) { /* Begining of text. */
+ XtFree(buf);
+ return(XawTextSearchError);
+ }
+ ptr = piece->text + piece->used - 1;
+ }
+
+ while ( ptr >= (piece->text + piece->used) ) {
+ piece = piece->next;
+ if (piece == NULL) { /* End of text. */
+ XtFree(buf);
+ return(XawTextSearchError);
+ }
+ ptr = piece->text;
+ }
+ }
+
+ XtFree(buf);
+ if (dir == XawsdLeft)
+ return(position);
+ return(position - (text->length - 1));
+}
+
+/* Function Name: SetValues
+ * Description: Sets the values for the AsciiSource.
+ * Arguments: current - current state of the widget.
+ * request - what was requested.
+ * new - what the widget will become.
+ * Returns: True if redisplay is needed.
+ */
+
+/* ARGSUSED */
+static Boolean
+SetValues(current, request, new, args, num_args)
+Widget current, request, new;
+ArgList args;
+Cardinal * num_args;
+{
+ AsciiSrcObject src = (AsciiSrcObject) new;
+ AsciiSrcObject old_src = (AsciiSrcObject) current;
+ Boolean total_reset = FALSE, string_set = FALSE;
+ FILE * file;
+ int i;
+
+ if ( old_src->ascii_src.use_string_in_place !=
+ src->ascii_src.use_string_in_place ) {
+ XtAppWarning( XtWidgetToApplicationContext(new),
+ "AsciiSrc: The XtNuseStringInPlace resource may not be changed.");
+ src->ascii_src.use_string_in_place =
+ old_src->ascii_src.use_string_in_place;
+ }
+
+ for (i = 0; i < *num_args ; i++ )
+ if (streq(args[i].name, XtNstring)) {
+ string_set = TRUE;
+ break;
+ }
+
+ if ( string_set || (old_src->ascii_src.type != src->ascii_src.type) ) {
+ RemoveOldStringOrFile(old_src, string_set); /* remove old info. */
+ file = InitStringOrFile(src, string_set); /* Init new info. */
+ LoadPieces(src, file, NULL); /* load new info into internal buffers. */
+ if (file != NULL) fclose(file);
+ XawTextSetSource( XtParent(new), new, 0); /* Tell text widget
+ what happened. */
+ total_reset = TRUE;
+ }
+
+ if ( old_src->ascii_src.ascii_length != src->ascii_src.ascii_length )
+ src->ascii_src.piece_size = src->ascii_src.ascii_length;
+
+ if ( !total_reset &&
+ (old_src->ascii_src.piece_size != src->ascii_src.piece_size) ) {
+ String string = StorePiecesInString(old_src);
+ FreeAllPieces(old_src);
+ LoadPieces(src, NULL, string);
+ XtFree(string);
+ }
+
+ return(FALSE);
+}
+
+/* Function Name: GetValuesHook
+ * Description: This is a get values hook routine that sets the
+ * values specific to the ascii source.
+ * Arguments: w - the AsciiSource Widget.
+ * args - the argument list.
+ * num_args - the number of args.
+ * Returns: none.
+ */
+
+static void
+GetValuesHook(w, args, num_args)
+Widget w;
+ArgList args;
+Cardinal * num_args;
+{
+ AsciiSrcObject src = (AsciiSrcObject) w;
+ int i;
+
+ if (src->ascii_src.type == XawAsciiString) {
+ for (i = 0; i < *num_args ; i++ )
+ if (streq(args[i].name, XtNstring)) {
+ if (src->ascii_src.use_string_in_place) {
+ *((char **) args[i].value) = src->ascii_src.first_piece->text;
+ }
+ else {
+ if (XawAsciiSave(w)) /* If save sucessful. */
+ *((char **) args[i].value) = src->ascii_src.string;
+ }
+ break;
+ }
+ }
+}
+
+/* Function Name: Destroy
+ * Description: Destroys an ascii source (frees all data)
+ * Arguments: src - the Ascii source Widget to free.
+ * Returns: none.
+ */
+
+static void
+Destroy (w)
+Widget w;
+{
+ RemoveOldStringOrFile((AsciiSrcObject) w, True);
+}
+
+/************************************************************
+ *
+ * Public routines
+ *
+ ************************************************************/
+
+/* Function Name: XawAsciiSourceFreeString
+ * Description: Frees the string returned by a get values call
+ * on the string when the source is of type string.
+ * Arguments: w - the AsciiSrc widget.
+ * Returns: none.
+ */
+
+void
+#if NeedFunctionPrototypes
+XawAsciiSourceFreeString(Widget w)
+#else
+XawAsciiSourceFreeString(w)
+Widget w;
+#endif
+{
+ AsciiSrcObject src = (AsciiSrcObject) w;
+
+ /* If the src is really a multi, call the multi routine.*/
+
+ if ( XtIsSubclass( w, multiSrcObjectClass ) ) {
+ _XawMultiSourceFreeString( w );
+ return;
+ }
+
+ else if ( !XtIsSubclass( w, asciiSrcObjectClass ) ) {
+ XtErrorMsg("bad argument", "asciiSource", "XawError",
+ "XawAsciiSourceFreeString's parameter must be an asciiSrc or multiSrc.",
+ NULL, NULL);
+ }
+
+ if (src->ascii_src.allocated_string && src->ascii_src.type != XawAsciiFile) {
+ src->ascii_src.allocated_string = FALSE;
+ XtFree(src->ascii_src.string);
+ src->ascii_src.string = NULL;
+ }
+}
+
+/* Function Name: XawAsciiSave
+ * Description: Saves all the pieces into a file or string as required.
+ * Arguments: w - the asciiSrc Widget.
+ * Returns: TRUE if the save was successful.
+ */
+
+Boolean
+#if NeedFunctionPrototypes
+XawAsciiSave(Widget w)
+#else
+XawAsciiSave(w)
+Widget w;
+#endif
+{
+ AsciiSrcObject src = (AsciiSrcObject) w;
+
+ /* If the src is really a multi, call the multi save. */
+
+ if ( XtIsSubclass( w, multiSrcObjectClass ) )
+ return( _XawMultiSave( w ) );
+
+ else if ( !XtIsSubclass( w, asciiSrcObjectClass ) ) {
+ XtErrorMsg("bad argument", "asciiSource", "XawError",
+ "XawAsciiSave's parameter must be an asciiSrc or multiSrc.",
+ NULL, NULL);
+ }
+
+/*
+ * If using the string in place then there is no need to play games
+ * to get the internal info into a readable string.
+ */
+
+ if (src->ascii_src.use_string_in_place)
+ return(TRUE);
+
+ if (src->ascii_src.type == XawAsciiFile) {
+ char * string;
+
+ if (!src->ascii_src.changes) /* No changes to save. */
+ return(TRUE);
+
+ string = StorePiecesInString(src);
+
+ if (WriteToFile(string, src->ascii_src.string) == FALSE) {
+ XtFree(string);
+ return(FALSE);
+ }
+ XtFree(string);
+ }
+ else {
+ if (src->ascii_src.allocated_string == TRUE)
+ XtFree(src->ascii_src.string);
+ else
+ src->ascii_src.allocated_string = TRUE;
+
+ src->ascii_src.string = StorePiecesInString(src);
+ }
+ src->ascii_src.changes = FALSE;
+ return(TRUE);
+}
+
+/* Function Name: XawAsciiSaveAsFile
+ * Description: Save the current buffer as a file.
+ * Arguments: w - the AsciiSrc widget.
+ * name - name of the file to save this file into.
+ * Returns: True if the save was sucessful.
+ */
+
+Boolean
+#if NeedFunctionPrototypes
+XawAsciiSaveAsFile(Widget w, _Xconst char* name)
+#else
+XawAsciiSaveAsFile(w, name)
+Widget w;
+String name;
+#endif
+{
+ AsciiSrcObject src = (AsciiSrcObject) w;
+ String string;
+ Boolean ret;
+
+ /* If the src is really a multi, call the multi save. - */
+
+ if ( XtIsSubclass( w, multiSrcObjectClass ) )
+ return( _XawMultiSaveAsFile( w, name ) );
+
+ else if ( !XtIsSubclass( w, asciiSrcObjectClass ) ) {
+ XtErrorMsg("bad argument", "asciiSource", "XawError",
+ "XawAsciiSaveAsFile's 1st parameter must be an asciiSrc or multiSrc.",
+ NULL, NULL);
+ }
+
+ string = StorePiecesInString(src);
+
+ ret = WriteToFile(string, name);
+ XtFree(string);
+ return(ret);
+}
+
+/* Function Name: XawAsciiSourceChanged
+ * Description: Returns true if the source has changed since last saved.
+ * Arguments: w - the ascii source widget.
+ * Returns: a Boolean (see description).
+ */
+
+Boolean
+#if NeedFunctionPrototypes
+XawAsciiSourceChanged(Widget w)
+#else
+XawAsciiSourceChanged(w)
+Widget w;
+#endif
+{
+ if ( XtIsSubclass( w, multiSrcObjectClass ) )
+ return( ( (MultiSrcObject) w )->multi_src.changes );
+
+ if ( XtIsSubclass( w, asciiSrcObjectClass ) )
+ return( ( (AsciiSrcObject) w)->ascii_src.changes );
+
+ XtErrorMsg("bad argument", "asciiSource", "XawError",
+ "XawAsciiSourceChanged parameter must be an asciiSrc or multiSrc.",
+ NULL, NULL);
+
+ return( True ); /* for gcc -Wall */
+}
+
+/************************************************************
+ *
+ * Private Functions.
+ *
+ ************************************************************/
+
+static void
+RemoveOldStringOrFile(src, checkString)
+AsciiSrcObject src;
+Boolean checkString;
+{
+ FreeAllPieces(src);
+
+ if (checkString && src->ascii_src.allocated_string) {
+ XtFree(src->ascii_src.string);
+ src->ascii_src.allocated_string = False;
+ src->ascii_src.string = NULL;
+ }
+}
+
+/* Function Name: WriteToFile
+ * Description: Write the string specified to the begining of the file
+ * specified.
+ * Arguments: string - string to write.
+ * name - the name of the file
+ * Returns: returns TRUE if sucessful, FALSE otherwise.
+ */
+
+static Boolean
+WriteToFile(string, name)
+String string, name;
+{
+ int fd;
+
+ if ( ((fd = creat(name, 0666)) == -1 ) ||
+ (write(fd, string, sizeof(unsigned char) * strlen(string)) == -1) )
+ return(FALSE);
+
+ if ( close(fd) == -1 )
+ return(FALSE);
+
+ return(TRUE);
+}
+
+/* Function Name: StorePiecesInString
+ * Description: store the pieces in memory into a standard ascii string.
+ * Arguments: data - the ascii pointer data.
+ * Returns: none.
+ */
+
+static String
+StorePiecesInString(src)
+AsciiSrcObject src;
+{
+ String string;
+ XawTextPosition first;
+ Piece * piece;
+
+ string = XtMalloc((unsigned) sizeof(unsigned char) *
+ src->ascii_src.length + 1);
+
+ for (first = 0, piece = src->ascii_src.first_piece ; piece != NULL;
+ first += piece->used, piece = piece->next)
+ strncpy(string + first, piece->text, piece->used);
+
+ string[src->ascii_src.length] = '\0'; /* NULL terminate this sucker. */
+
+/*
+ * This will refill all pieces to capacity.
+ */
+
+ if (src->ascii_src.data_compression) {
+ FreeAllPieces(src);
+ LoadPieces(src, NULL, string);
+ }
+
+ return(string);
+}
+
+/* Function Name: InitStringOrFile.
+ * Description: Initializes the string or file.
+ * Arguments: src - the AsciiSource.
+ * Returns: none - May exit though.
+ */
+
+static FILE *
+InitStringOrFile(src, newString)
+AsciiSrcObject src;
+Boolean newString;
+{
+ char * open_mode;
+ FILE * file;
+ char fileName[TMPSIZ];
+
+ if (src->ascii_src.type == XawAsciiString) {
+
+ if (src->ascii_src.string == NULL)
+ src->ascii_src.length = 0;
+
+ else if (! src->ascii_src.use_string_in_place) {
+ src->ascii_src.string = XtNewString(src->ascii_src.string);
+ src->ascii_src.allocated_string = True;
+ src->ascii_src.length = strlen(src->ascii_src.string);
+ }
+
+ if (src->ascii_src.use_string_in_place) {
+ src->ascii_src.length = strlen(src->ascii_src.string);
+ /* In case the length resource is incorrectly set */
+ if (src->ascii_src.length > src->ascii_src.ascii_length)
+ src->ascii_src.ascii_length = src->ascii_src.length;
+
+ if (src->ascii_src.ascii_length == MAGIC_VALUE)
+ src->ascii_src.piece_size = src->ascii_src.length;
+ else
+ src->ascii_src.piece_size = src->ascii_src.ascii_length + 1;
+ }
+
+ return(NULL);
+ }
+
+/*
+ * type is XawAsciiFile.
+ */
+
+ src->ascii_src.is_tempfile = FALSE;
+
+ switch (src->text_src.edit_mode) {
+ case XawtextRead:
+ if (src->ascii_src.string == NULL)
+ XtErrorMsg("NoFile", "asciiSourceCreate", "XawError",
+ "Creating a read only disk widget and no file specified.",
+ NULL, 0);
+ open_mode = "r";
+ break;
+ case XawtextAppend:
+ case XawtextEdit:
+ if (src->ascii_src.string == NULL) {
+ src->ascii_src.string = fileName;
+ (void) tmpnam(src->ascii_src.string);
+ src->ascii_src.is_tempfile = TRUE;
+ open_mode = "w";
+ } else
+ open_mode = "r+";
+ break;
+ default:
+ XtErrorMsg("badMode", "asciiSourceCreate", "XawError",
+ "Bad editMode for ascii source; must be Read, Append or Edit.",
+ NULL, NULL);
+ }
+
+ /* Allocate new memory for the temp filename, because it is held in
+ * a stack variable, not static memory. This widget does not need
+ * to keep the private state field is_tempfile -- it is only accessed
+ * in this routine, and its former setting is unused.
+ */
+ if (newString || src->ascii_src.is_tempfile) {
+ src->ascii_src.string = XtNewString(src->ascii_src.string);
+ src->ascii_src.allocated_string = TRUE;
+ }
+
+ if (!src->ascii_src.is_tempfile) {
+ if ((file = fopen(src->ascii_src.string, open_mode)) != 0) {
+ (void) fseek(file, (Off_t)0, 2);
+ src->ascii_src.length = (XawTextPosition) ftell(file);
+ return file;
+ } else {
+ String params[2];
+ Cardinal num_params = 2;
+
+ params[0] = src->ascii_src.string;
+ params[1] = strerror(errno);
+ XtAppWarningMsg(XtWidgetToApplicationContext((Widget)src),
+ "openError", "asciiSourceCreate", "XawWarning",
+ "Cannot open file %s; %s", params, &num_params);
+ }
+ }
+ src->ascii_src.length = 0;
+ return((FILE *)NULL);
+}
+
+static void
+LoadPieces(src, file, string)
+AsciiSrcObject src;
+FILE * file;
+char * string;
+{
+ char *local_str, *ptr;
+ Piece * piece = NULL;
+ XawTextPosition left;
+
+ if (string == NULL) {
+ if (src->ascii_src.type == XawAsciiFile) {
+ local_str = XtMalloc((unsigned) (src->ascii_src.length + 1)
+ * sizeof(unsigned char));
+ if (src->ascii_src.length != 0) {
+ fseek(file, (Off_t)0, 0);
+ src->ascii_src.length = fread(local_str, (Size_t)sizeof(unsigned char),
+ (Size_t)src->ascii_src.length, file);
+ if (src->ascii_src.length <= 0)
+ XtErrorMsg("readError", "asciiSourceCreate", "XawError",
+ "fread returned error.", NULL, NULL);
+ }
+ local_str[src->ascii_src.length] = '\0';
+ }
+ else
+ local_str = src->ascii_src.string;
+ }
+ else
+ local_str = string;
+
+ if (src->ascii_src.use_string_in_place) {
+ piece = AllocNewPiece(src, piece);
+ piece->used = Min(src->ascii_src.length, src->ascii_src.piece_size);
+ piece->text = src->ascii_src.string;
+ return;
+ }
+
+ ptr = local_str;
+ left = src->ascii_src.length;
+
+ do {
+ piece = AllocNewPiece(src, piece);
+
+ piece->text = XtMalloc((unsigned)src->ascii_src.piece_size
+ * sizeof(unsigned char));
+ piece->used = Min(left, src->ascii_src.piece_size);
+ if (piece->used != 0)
+ strncpy(piece->text, ptr, piece->used);
+
+ left -= piece->used;
+ ptr += piece->used;
+ } while (left > 0);
+
+ if ( (src->ascii_src.type == XawAsciiFile) && (string == NULL) )
+ XtFree(local_str);
+}
+
+/* Function Name: AllocNewPiece
+ * Description: Allocates a new piece of memory.
+ * Arguments: src - The AsciiSrc Widget.
+ * prev - the piece just before this one, or NULL.
+ * Returns: the allocated piece.
+ */
+
+static Piece *
+AllocNewPiece(src, prev)
+AsciiSrcObject src;
+Piece * prev;
+{
+ Piece * piece = XtNew(Piece);
+
+ if (prev == NULL) {
+ src->ascii_src.first_piece = piece;
+ piece->next = NULL;
+ }
+ else {
+ if (prev->next != NULL)
+ (prev->next)->prev = piece;
+ piece->next = prev->next;
+ prev->next = piece;
+ }
+
+ piece->prev = prev;
+
+ return(piece);
+}
+
+/* Function Name: FreeAllPieces
+ * Description: Frees all the pieces
+ * Arguments: src - The AsciiSrc Widget.
+ * Returns: none.
+ */
+
+static void
+FreeAllPieces(src)
+AsciiSrcObject src;
+{
+ Piece * next, * first = src->ascii_src.first_piece;
+
+ if (first->prev != NULL)
+ (void) printf("Xaw AsciiSrc Object: possible memory leak in FreeAllPieces().\n");
+
+ for ( ; first != NULL ; first = next ) {
+ next = first->next;
+ RemovePiece(src, first);
+ }
+}
+
+/* Function Name: RemovePiece
+ * Description: Removes a piece from the list.
+ * Arguments:
+ * piece - the piece to remove.
+ * Returns: none.
+ */
+
+static void
+RemovePiece(src, piece)
+AsciiSrcObject src;
+Piece * piece;
+{
+ if (piece->prev == NULL)
+ src->ascii_src.first_piece = piece->next;
+ else
+ (piece->prev)->next = piece->next;
+
+ if (piece->next != NULL)
+ (piece->next)->prev = piece->prev;
+
+ if (!src->ascii_src.use_string_in_place)
+ XtFree(piece->text);
+
+ XtFree((char *)piece);
+}
+
+/* Function Name: FindPiece
+ * Description: Finds the piece containing the position indicated.
+ * Arguments: src - The AsciiSrc Widget.
+ * position - the position that we are searching for.
+ * RETURNED first - the position of the first character in this piece.
+ * Returns: piece - the piece that contains this position.
+ */
+
+static Piece *
+FindPiece(src, position, first)
+AsciiSrcObject src;
+XawTextPosition position, *first;
+{
+ Piece * old_piece, * piece = src->ascii_src.first_piece;
+ XawTextPosition temp;
+
+ for ( temp = 0 ; piece != NULL ; temp += piece->used, piece = piece->next ) {
+ *first = temp;
+ old_piece = piece;
+
+ if ((temp + piece->used) > position)
+ return(piece);
+ }
+ return(old_piece); /* if we run off the end the return the last piece */
+}
+
+/* Function Name: MyStrncpy
+ * Description: Just like string copy, but slower and will always
+ * work on overlapping strings.
+ * Arguments: (same as strncpy) - s1, s2 - strings to copy (2->1).
+ * n - the number of chars to copy.
+ * Returns: s1.
+ */
+
+static String
+MyStrncpy(s1, s2, n)
+char * s1, * s2;
+int n;
+{
+ char buf[256];
+ char* temp;
+
+ if (n == 0) return s1;
+
+ if (n < sizeof buf) temp = buf;
+ else temp = XtMalloc((unsigned)sizeof(unsigned char) * n);
+
+ strncpy(temp, s2, n); /* Saber has a bug that causes it to generate*/
+ strncpy(s1, temp, n); /* a bogus warning message here (CDP 6/32/89)*/
+
+ if (temp != buf) XtFree(temp);
+ return s1;
+}
+
+/* Function Name: BreakPiece
+ * Description: Breaks a full piece into two new pieces.
+ * Arguments: src - The AsciiSrc Widget.
+ * piece - the piece to break.
+ * Returns: none.
+ */
+
+#define HALF_PIECE (src->ascii_src.piece_size/2)
+
+static void
+BreakPiece(src, piece)
+AsciiSrcObject src;
+Piece * piece;
+{
+ Piece * new = AllocNewPiece(src, piece);
+
+ new->text = XtMalloc(src->ascii_src.piece_size * sizeof(unsigned char));
+ strncpy(new->text, piece->text + HALF_PIECE,
+ src->ascii_src.piece_size - HALF_PIECE);
+ piece->used = HALF_PIECE;
+ new->used = src->ascii_src.piece_size - HALF_PIECE;
+}
+
+/* ARGSUSED */
+static void
+CvtStringToAsciiType(args, num_args, fromVal, toVal)
+XrmValuePtr args; /* unused */
+Cardinal *num_args; /* unused */
+XrmValuePtr fromVal;
+XrmValuePtr toVal;
+{
+ static XawAsciiType type;
+ static XrmQuark XtQEstring = NULLQUARK;
+ static XrmQuark XtQEfile;
+ XrmQuark q;
+ char lowerName[40];
+
+ if (XtQEstring == NULLQUARK) {
+ XtQEstring = XrmPermStringToQuark(XtEstring);
+ XtQEfile = XrmPermStringToQuark(XtEfile);
+ }
+
+ if (strlen ((char*)fromVal->addr) < sizeof lowerName) {
+ XmuCopyISOLatin1Lowered(lowerName, (char *) fromVal->addr);
+ q = XrmStringToQuark(lowerName);
+
+ if (q == XtQEstring) type = XawAsciiString;
+ else if (q == XtQEfile) type = XawAsciiFile;
+ else {
+ toVal->size = 0;
+ toVal->addr = NULL;
+ return;
+ }
+ toVal->size = sizeof type;
+ toVal->addr = (XPointer) &type;
+ return;
+ }
+ toVal->size = 0;
+ toVal->addr = NULL;
+}
+
+#if (defined(ASCII_STRING) || defined(ASCII_DISK))
+# include <X11/Xaw/Cardinals.h>
+#endif
+
+#ifdef ASCII_STRING
+/************************************************************
+ *
+ * Compatability functions.
+ *
+ ************************************************************/
+
+/* Function Name: AsciiStringSourceCreate
+ * Description: Creates a string source.
+ * Arguments: parent - the widget that will own this source.
+ * args, num_args - the argument list.
+ * Returns: a pointer to the new text source.
+ */
+
+Widget
+XawStringSourceCreate(parent, args, num_args)
+Widget parent;
+ArgList args;
+Cardinal num_args;
+{
+ XawTextSource src;
+ ArgList ascii_args;
+ Arg temp[2];
+
+ XtSetArg(temp[0], XtNtype, XawAsciiString);
+ XtSetArg(temp[1], XtNuseStringInPlace, TRUE);
+ ascii_args = XtMergeArgLists(temp, TWO, args, num_args);
+
+ src = XtCreateWidget("genericAsciiString", asciiSrcObjectClass, parent,
+ ascii_args, num_args + TWO);
+ XtFree((char *)ascii_args);
+ return(src);
+}
+
+/*
+ * This is hacked up to try to emulate old functionality, it
+ * may not work, as I have not old code to test it on.
+ *
+ * Chris D. Peterson 8/31/89.
+ */
+
+void
+XawTextSetLastPos (w, lastPos)
+Widget w;
+XawTextPosition lastPos;
+{
+ AsciiSrcObject src = (AsciiSrcObject) XawTextGetSource(w);
+
+ src->ascii_src.piece_size = lastPos;
+}
+#endif /* ASCII_STRING */
+
+#ifdef ASCII_DISK
+/* Function Name: AsciiDiskSourceCreate
+ * Description: Creates a disk source.
+ * Arguments: parent - the widget that will own this source.
+ * args, num_args - the argument list.
+ * Returns: a pointer to the new text source.
+ */
+
+Widget
+XawDiskSourceCreate(parent, args, num_args)
+Widget parent;
+ArgList args;
+Cardinal num_args;
+{
+ XawTextSource src;
+ ArgList ascii_args;
+ Arg temp[1];
+ int i;
+
+ XtSetArg(temp[0], XtNtype, XawAsciiFile);
+ ascii_args = XtMergeArgLists(temp, ONE, args, num_args);
+ num_args++;
+
+ for (i = 0; i < num_args; i++)
+ if (streq(ascii_args[i].name, XtNfile) ||
+ streq(ascii_args[i].name, XtCFile))
+ ascii_args[i].name = XtNstring;
+
+ src = XtCreateWidget("genericAsciiDisk", asciiSrcObjectClass, parent,
+ ascii_args, num_args);
+ XtFree((char *)ascii_args);
+ return(src);
+}
+#endif /* ASCII_DISK */
diff --git a/src/AsciiText.c b/src/AsciiText.c
new file mode 100644
index 0000000..3a6427f
--- /dev/null
+++ b/src/AsciiText.c
@@ -0,0 +1,335 @@
+/* $Xorg: AsciiText.c,v 1.4 2001/02/09 02:03:42 xorgcvs Exp $ */
+
+/*
+
+Copyright 1987, 1988, 1994, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+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
+OPEN GROUP 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 Open Group 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 Open Group.
+
+
+Copyright 1987, 1988 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+*/
+
+/***********************************************************************
+ *
+ * AsciiText Widget
+ *
+ ***********************************************************************/
+
+/*
+ * AsciiText.c - Source code for AsciiText Widget.
+ *
+ * This Widget is intended to be used as a simple front end to the
+ * text widget with an ascii source and ascii sink attached to it.
+ *
+ * Date: June 29, 1989
+ *
+ * By: Chris D. Peterson
+ * MIT X Consortium
+ * kit@expo.lcs.mit.edu
+ */
+
+#include <stdio.h>
+#include <X11/IntrinsicP.h>
+#include <X11/StringDefs.h>
+
+#include <X11/Xaw/XawInit.h>
+#include <X11/Xaw/Cardinals.h>
+#include <X11/Xaw/AsciiTextP.h>
+#include <X11/Xaw/AsciiSrc.h>
+#include <X11/Xaw/AsciiSink.h>
+#include <X11/Xaw/MultiSrc.h>
+#include <X11/Xaw/MultiSinkP.h>
+#include <X11/Xaw/XawImP.h>
+
+#define TAB_COUNT 32
+
+static void Initialize(), Destroy();
+
+AsciiTextClassRec asciiTextClassRec = {
+ { /* core fields */
+ /* superclass */ (WidgetClass) &textClassRec,
+ /* class_name */ "Text",
+ /* widget_size */ sizeof(AsciiRec),
+ /* class_initialize */ XawInitializeWidgetSet,
+ /* class_part_init */ NULL,
+ /* class_inited */ FALSE,
+ /* initialize */ Initialize,
+ /* initialize_hook */ NULL,
+ /* realize */ XtInheritRealize,
+ /* actions */ NULL,
+ /* num_actions */ 0,
+ /* resources */ NULL,
+ /* num_resource */ 0,
+ /* xrm_class */ NULLQUARK,
+ /* compress_motion */ TRUE,
+ /* compress_exposure*/ XtExposeGraphicsExpose | XtExposeNoExpose,
+ /* compress_enterleave*/ TRUE,
+ /* visible_interest */ FALSE,
+ /* destroy */ Destroy,
+ /* resize */ XtInheritResize,
+ /* expose */ XtInheritExpose,
+ /* set_values */ NULL,
+ /* set_values_hook */ NULL,
+ /* set_values_almost*/ XtInheritSetValuesAlmost,
+ /* get_values_hook */ NULL,
+ /* accept_focus */ XtInheritAcceptFocus,
+ /* version */ XtVersion,
+ /* callback_private */ NULL,
+ /* tm_table */ XtInheritTranslations,
+ /* query_geometry */ XtInheritQueryGeometry
+ },
+ { /* Simple fields */
+ /* change_sensitive */ XtInheritChangeSensitive
+ },
+ { /* text fields */
+ /* empty */ 0
+ },
+ { /* ascii fields */
+ /* empty */ 0
+ }
+};
+
+WidgetClass asciiTextWidgetClass = (WidgetClass)&asciiTextClassRec;
+
+
+static void
+Initialize(request, new, args, num_args)
+Widget request, new;
+ArgList args;
+Cardinal *num_args;
+{
+ AsciiWidget w = (AsciiWidget) new;
+ int i;
+ int tabs[TAB_COUNT], tab;
+
+ MultiSinkObject sink;
+
+ /* superclass Initialize can't set the following,
+ * as it didn't know the source or sink when it was called */
+
+ if (request->core.height == DEFAULT_TEXT_HEIGHT)
+ new->core.height = DEFAULT_TEXT_HEIGHT;
+
+
+ /* This is the main change for internationalization. */
+
+ if ( w->simple.international == True ) { /* The multi* are international. */
+
+ w->text.source = XtCreateWidget( "textSource", multiSrcObjectClass,
+ new, args, *num_args );
+ w->text.sink = XtCreateWidget( "textSink", multiSinkObjectClass,
+ new, args, *num_args );
+ }
+ else {
+
+ w->text.source = XtCreateWidget( "textSource", asciiSrcObjectClass,
+ new, args, *num_args );
+ w->text.sink = XtCreateWidget( "textSink", asciiSinkObjectClass,
+ new, args, *num_args );
+ }
+
+ if (w->core.height == DEFAULT_TEXT_HEIGHT)
+ w->core.height = VMargins(w) + XawTextSinkMaxHeight(w->text.sink, 1);
+
+ for (i=0, tab=0 ; i < TAB_COUNT ; i++)
+ tabs[i] = (tab += 8);
+
+ XawTextSinkSetTabs(w->text.sink, TAB_COUNT, tabs);
+
+ XawTextDisableRedisplay(new);
+ XawTextEnableRedisplay(new);
+
+
+ /* If we are using a MultiSink we need to tell the input method stuff. */
+
+ if ( w->simple.international == True ) {
+ Arg list[4];
+ Cardinal ac = 0;
+
+ sink = (MultiSinkObject)w->text.sink;
+ _XawImRegister( new );
+ XtSetArg (list[ac], XtNfontSet, sink->multi_sink.fontset); ac++;
+ XtSetArg (list[ac], XtNinsertPosition, w->text.insertPos); ac++;
+ XtSetArg (list[ac], XtNforeground, sink->text_sink.foreground); ac++;
+ XtSetArg (list[ac], XtNbackground, sink->text_sink.background); ac++;
+ _XawImSetValues(new, list, ac);
+ }
+}
+
+static void
+Destroy(w)
+Widget w;
+{
+ /* Disconnect input method */
+
+ if ( ((AsciiWidget)w)->simple.international == True )
+ _XawImUnregister( w );
+
+ if (w == XtParent(((AsciiWidget)w)->text.source))
+ XtDestroyWidget( ((AsciiWidget)w)->text.source );
+
+ if (w == XtParent(((AsciiWidget)w)->text.sink))
+ XtDestroyWidget( ((AsciiWidget)w)->text.sink );
+}
+
+#ifdef ASCII_STRING
+
+/************************************************************
+ *
+ * Ascii String Compatibility Code.
+ *
+ ************************************************************/
+
+AsciiStringClassRec asciiStringClassRec = {
+ { /* core fields */
+ /* superclass */ (WidgetClass) &asciiTextClassRec,
+ /* class_name */ "Text",
+ /* widget_size */ sizeof(AsciiStringRec),
+ /* class_initialize */ NULL,
+ /* class_part_init */ NULL,
+ /* class_inited */ FALSE,
+ /* initialize */ NULL,
+ /* initialize_hook */ NULL,
+ /* realize */ XtInheritRealize,
+ /* actions */ NULL,
+ /* num_actions */ 0,
+ /* resources */ NULL,
+ /* num_ resource */ 0,
+ /* xrm_class */ NULLQUARK,
+ /* compress_motion */ TRUE,
+ /* compress_exposure*/ XtExposeGraphicsExpose,
+ /* compress_enterleave*/ TRUE,
+ /* visible_interest */ FALSE,
+ /* destroy */ NULL,
+ /* resize */ XtInheritResize,
+ /* expose */ XtInheritExpose,
+ /* set_values */ NULL,
+ /* set_values_hook */ NULL,
+ /* set_values_almost*/ XtInheritSetValuesAlmost,
+ /* get_values_hook */ NULL,
+ /* accept_focus */ XtInheritAcceptFocus,
+ /* version */ XtVersion,
+ /* callback_private */ NULL,
+ /* tm_table */ XtInheritTranslations,
+ /* query_geometry */ XtInheritQueryGeometry
+ },
+ { /* Simple fields */
+ /* change_sensitive */ XtInheritChangeSensitive
+ },
+ { /* text fields */
+ /* empty */ 0
+ },
+ { /* ascii fields */
+ /* empty */ 0
+ }
+};
+
+WidgetClass asciiStringWidgetClass = (WidgetClass)&asciiStringClassRec;
+
+#endif /* ASCII_STRING */
+
+#ifdef ASCII_DISK
+
+/************************************************************
+ *
+ * Ascii Disk Compatibility Code.
+ *
+ ************************************************************/
+
+AsciiDiskClassRec asciiDiskClassRec = {
+ { /* core fields */
+ /* superclass */ (WidgetClass) &asciiTextClassRec,
+ /* class_name */ "Text",
+ /* widget_size */ sizeof(AsciiDiskRec),
+ /* class_initialize */ NULL,
+ /* class_part_init */ NULL,
+ /* class_inited */ FALSE,
+ /* initialize */ NULL,
+ /* initialize_hook */ NULL,
+ /* realize */ XtInheritRealize,
+ /* actions */ NULL,
+ /* num_actions */ 0,
+ /* resources */ NULL,
+ /* num_ resource */ 0,
+ /* xrm_class */ NULLQUARK,
+ /* compress_motion */ TRUE,
+ /* compress_exposure*/ XtExposeGraphicsExpose,
+ /* compress_enterleave*/ TRUE,
+ /* visible_interest */ FALSE,
+ /* destroy */ NULL,
+ /* resize */ XtInheritResize,
+ /* expose */ XtInheritExpose,
+ /* set_values */ NULL,
+ /* set_values_hook */ NULL,
+ /* set_values_almost*/ XtInheritSetValuesAlmost,
+ /* get_values_hook */ NULL,
+ /* accept_focus */ XtInheritAcceptFocus,
+ /* version */ XtVersion,
+ /* callback_private */ NULL,
+ /* tm_table */ XtInheritTranslations,
+ /* query_geometry */ XtInheritQueryGeometry
+ },
+ { /* Simple fields */
+ /* change_sensitive */ XtInheritChangeSensitive
+ },
+ { /* text fields */
+ /* empty */ 0
+ },
+ { /* ascii fields */
+ /* empty */ 0
+ }
+};
+
+WidgetClass asciiDiskWidgetClass = (WidgetClass)&asciiDiskClassRec;
+
+#endif /* ASCII_DISK */
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/Box.c b/src/Box.c
new file mode 100644
index 0000000..8e40b89
--- /dev/null
+++ b/src/Box.c
@@ -0,0 +1,616 @@
+/* $Xorg: Box.c,v 1.4 2001/02/09 02:03:43 xorgcvs Exp $ */
+
+/***********************************************************
+
+Copyright 1987, 1988, 1994, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+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
+OPEN GROUP 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 Open Group 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 Open Group.
+
+
+Copyright 1987, 1988 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+******************************************************************/
+
+
+/*
+ * Box.c - Box composite widget
+ *
+ */
+
+#include <X11/IntrinsicP.h>
+#include <X11/StringDefs.h>
+#include <X11/Xmu/Misc.h>
+#include <X11/Xaw/XawInit.h>
+#include <X11/Xaw/BoxP.h>
+
+/****************************************************************
+ *
+ * Box Resources
+ *
+ ****************************************************************/
+
+static XtResource resources[] = {
+ { XtNhSpace, XtCHSpace, XtRDimension, sizeof(Dimension),
+ XtOffsetOf(BoxRec, box.h_space),
+ XtRImmediate, (XtPointer)4 },
+ { XtNvSpace, XtCVSpace, XtRDimension, sizeof(Dimension),
+ XtOffsetOf(BoxRec, box.v_space),
+ XtRImmediate, (XtPointer)4 },
+ { XtNorientation, XtCOrientation, XtROrientation, sizeof(XtOrientation),
+ XtOffsetOf(BoxRec, box.orientation),
+ XtRImmediate, (XtPointer)XtorientVertical },
+};
+
+/****************************************************************
+ *
+ * Full class record constant
+ *
+ ****************************************************************/
+
+static void ClassInitialize();
+static void Initialize();
+static void Realize();
+static void Resize();
+static Boolean SetValues();
+static XtGeometryResult GeometryManager();
+static void ChangeManaged();
+static XtGeometryResult PreferredSize();
+
+BoxClassRec boxClassRec = {
+ {
+/* core_class fields */
+ /* superclass */ (WidgetClass) &compositeClassRec,
+ /* class_name */ "Box",
+ /* widget_size */ sizeof(BoxRec),
+ /* class_initialize */ ClassInitialize,
+ /* class_part_init */ NULL,
+ /* class_inited */ FALSE,
+ /* initialize */ Initialize,
+ /* initialize_hook */ NULL,
+ /* realize */ Realize,
+ /* actions */ NULL,
+ /* num_actions */ 0,
+ /* resources */ resources,
+ /* num_resources */ XtNumber(resources),
+ /* xrm_class */ NULLQUARK,
+ /* compress_motion */ TRUE,
+ /* compress_exposure */ TRUE,
+ /* compress_enterleave*/ TRUE,
+ /* visible_interest */ FALSE,
+ /* destroy */ NULL,
+ /* resize */ Resize,
+ /* expose */ NULL,
+ /* set_values */ SetValues,
+ /* set_values_hook */ NULL,
+ /* set_values_almost */ XtInheritSetValuesAlmost,
+ /* get_values_hook */ NULL,
+ /* accept_focus */ NULL,
+ /* version */ XtVersion,
+ /* callback_private */ NULL,
+ /* tm_table */ NULL,
+ /* query_geometry */ PreferredSize,
+ /* display_accelerator*/ XtInheritDisplayAccelerator,
+ /* extension */ NULL
+ },{
+/* composite_class fields */
+ /* geometry_manager */ GeometryManager,
+ /* change_managed */ ChangeManaged,
+ /* insert_child */ XtInheritInsertChild,
+ /* delete_child */ XtInheritDeleteChild,
+ /* extension */ NULL
+ },{
+/* Box class fields */
+ /* empty */ 0,
+ }
+};
+
+WidgetClass boxWidgetClass = (WidgetClass)&boxClassRec;
+
+
+/****************************************************************
+ *
+ * Private Routines
+ *
+ ****************************************************************/
+
+/*
+ *
+ * Do a layout, either actually assigning positions, or just calculating size.
+ * Returns minimum width and height that will preserve the same layout.
+ *
+ */
+
+static void DoLayout(bbw, width, height, reply_width, reply_height, position)
+ BoxWidget bbw;
+ Dimension width, height;
+ Dimension *reply_width, *reply_height; /* bounding box */
+ Boolean position; /* actually reposition the windows? */
+{
+ Boolean vbox = (bbw->box.orientation == XtorientVertical);
+ Cardinal i;
+ Dimension w, h; /* Width and height needed for box */
+ Dimension lw, lh; /* Width and height needed for current line */
+ Dimension bw, bh; /* Width and height needed for current widget */
+ Dimension h_space; /* Local copy of bbw->box.h_space */
+ Widget widget; /* Current widget */
+ int num_mapped_children = 0;
+
+ /* Box width and height */
+ h_space = bbw->box.h_space;
+
+ w = 0;
+ for (i = 0; i < bbw->composite.num_children; i++) {
+ if ( bbw->composite.children[i]->core.width > w )
+ w = bbw->composite.children[i]->core.width;
+ }
+ w += h_space;
+ if ( w > width ) width = w;
+ h = bbw->box.v_space;
+
+ /* Line width and height */
+ lh = 0;
+ lw = h_space;
+
+ for (i = 0; i < bbw->composite.num_children; i++) {
+ widget = bbw->composite.children[i];
+ if (widget->core.managed) {
+ if (widget->core.mapped_when_managed) num_mapped_children++;
+ /* Compute widget width */
+ bw = widget->core.width + 2*widget->core.border_width + h_space;
+ if ((Dimension)(lw + bw) > width) {
+ if (lw > h_space) {
+ /* At least one widget on this line, and
+ * can't fit any more. Start new line if vbox.
+ */
+ AssignMax(w, lw);
+ if (vbox) {
+ h += lh + bbw->box.v_space;
+ lh = 0;
+ lw = h_space;
+ }
+ }
+ else if (!position) {
+ /* too narrow for this widget; we'll assume we can grow */
+ DoLayout(bbw, lw + bw, height, reply_width,
+ reply_height, position);
+ return;
+ }
+ }
+ if (position && (lw != widget->core.x || h != widget->core.y)) {
+ /* It would be nice to use window gravity, but there isn't
+ * sufficient fine-grain control to nicely handle all
+ * situations (e.g. when only the height changes --
+ * a common case). Explicit unmapping is a cheap hack
+ * to speed things up & avoid the visual jitter as
+ * things slide around.
+ *
+ * %%% perhaps there should be a client resource to
+ * control this. If so, we'll have to optimize to
+ * perform the moves from the correct end so we don't
+ * force extra exposures as children occlude each other.
+ */
+ if (XtIsRealized(widget) && widget->core.mapped_when_managed)
+ XUnmapWindow( XtDisplay(widget), XtWindow(widget) );
+ XtMoveWidget(widget, (int)lw, (int)h);
+ }
+ lw += bw;
+ bh = widget->core.height + 2*widget->core.border_width;
+ AssignMax(lh, bh);
+ } /* if managed */
+ } /* for */
+
+ if (!vbox && width && lw > width && lh < height) {
+ /* reduce width if too wide and height not filled */
+ Dimension sw = lw, sh = lh;
+ Dimension width_needed;
+ XtOrientation orientation = bbw->box.orientation;
+ bbw->box.orientation = XtorientVertical;
+ while (sh < height && sw > width) {
+ width_needed = sw;
+ DoLayout(bbw, sw-1, height, &sw, &sh, False);
+ }
+ if (sh < height) width_needed = sw;
+ if (width_needed != lw) {
+ DoLayout(bbw,width_needed,height,reply_width,reply_height,position);
+ bbw->box.orientation = orientation;
+ return;
+ }
+ bbw->box.orientation = orientation;
+ }
+ if ( vbox && ( ( width < w ) || ( width < lw ) ) ) {
+ AssignMax(w, lw);
+ DoLayout( bbw, w, height, reply_width, reply_height, position );
+ return;
+ }
+ if (position && XtIsRealized((Widget)bbw)) {
+ if (bbw->composite.num_children == num_mapped_children)
+ XMapSubwindows( XtDisplay((Widget)bbw), XtWindow((Widget)bbw) );
+ else {
+ int i = bbw->composite.num_children;
+ Widget *childP = bbw->composite.children;
+ for (; i > 0; childP++, i--)
+ if (XtIsRealized(*childP) && XtIsManaged(*childP) &&
+ (*childP)->core.mapped_when_managed)
+ XtMapWidget(*childP);
+ }
+ }
+
+ /* Finish off last line */
+ if (lw > h_space) {
+ AssignMax(w, lw);
+ h += lh + bbw->box.v_space;
+ }
+
+ *reply_width = Max(w, 1);
+ *reply_height = Max(h, 1);
+}
+
+/*
+ *
+ * Calculate preferred size, given constraining box, caching it in the widget.
+ *
+ */
+
+static XtGeometryResult PreferredSize(widget, constraint, preferred)
+ Widget widget;
+ XtWidgetGeometry *constraint, *preferred;
+{
+ BoxWidget w = (BoxWidget)widget;
+ Dimension width /*, height */;
+ Dimension preferred_width = w->box.preferred_width;
+ Dimension preferred_height = w->box.preferred_height;
+
+ constraint->request_mode &= CWWidth | CWHeight;
+
+ if (constraint->request_mode == 0)
+ /* parent isn't going to change w or h, so nothing to re-compute */
+ return XtGeometryYes;
+
+ if (constraint->request_mode == w->box.last_query_mode &&
+ (!(constraint->request_mode & CWWidth) ||
+ constraint->width == w->box.last_query_width) &&
+ (!(constraint->request_mode & CWHeight) ||
+ constraint->height == w->box.last_query_height)) {
+ /* same query; current preferences are still valid */
+ preferred->request_mode = CWWidth | CWHeight;
+ preferred->width = preferred_width;
+ preferred->height = preferred_height;
+ if (constraint->request_mode == (CWWidth | CWHeight) &&
+ constraint->width == preferred_width &&
+ constraint->height == preferred_height)
+ return XtGeometryYes;
+ else
+ return XtGeometryAlmost;
+ }
+
+ /* else gotta do it the long way...
+ I have a preference for tall and narrow, so if my width is
+ constrained, I'll accept it; otherwise, I'll compute the minimum
+ width that will fit me within the height constraint */
+
+ w->box.last_query_mode = constraint->request_mode;
+ w->box.last_query_width = constraint->width;
+ w->box.last_query_height= constraint->height;
+
+ if (constraint->request_mode & CWWidth)
+ width = constraint->width;
+ else /* if (constraint->request_mode & CWHeight) */ {
+ /* let's see if I can become any narrower */
+ width = 0;
+ constraint->width = 65535;
+ }
+
+ /* height is currently ignored by DoLayout.
+ height = (constraint->request_mode & CWHeight) ? constraint->height
+ : *preferred_height;
+ */
+ DoLayout(w, width, (Dimension)0,
+ &preferred_width, &preferred_height, FALSE);
+
+ if (constraint->request_mode & CWHeight &&
+ preferred_height > constraint->height) {
+ /* find minimum width for this height */
+ if (preferred_width > constraint->width) {
+ /* punt; over-constrained */
+ }
+ else {
+ width = preferred_width;
+ do { /* find some width big enough to stay within this height */
+ width *= 2;
+ if (width > constraint->width) width = constraint->width;
+ DoLayout(w, width, 0, &preferred_width, &preferred_height, FALSE);
+ } while (preferred_height > constraint->height &&
+ width < constraint->width);
+ if (width != constraint->width) {
+ do { /* find minimum width */
+ width = preferred_width;
+ DoLayout(w, preferred_width-1, 0,
+ &preferred_width, &preferred_height, FALSE);
+ } while (preferred_height < constraint->height);
+ /* one last time */
+ DoLayout(w, width, 0, &preferred_width, &preferred_height, FALSE);
+ }
+ }
+ }
+
+ preferred->request_mode = CWWidth | CWHeight;
+ preferred->width = w->box.preferred_width = preferred_width;
+ preferred->height = w->box.preferred_height = preferred_height;
+
+ if (constraint->request_mode == (CWWidth|CWHeight)
+ && constraint->width == preferred_width
+ && constraint->height == preferred_height)
+ return XtGeometryYes;
+ else
+ return XtGeometryAlmost;
+
+}
+
+/*
+ *
+ * Actually layout the box
+ *
+ */
+
+static void Resize(w)
+ Widget w;
+{
+ Dimension junk;
+
+ DoLayout((BoxWidget)w, w->core.width, w->core.height, &junk, &junk, TRUE);
+
+} /* Resize */
+
+/*
+ *
+ * Try to do a new layout within the current width and height;
+ * if that fails try to resize and do it within the box returne
+ * by PreferredSize.
+ *
+ * TryNewLayout just says if it's possible, and doesn't actually move the kids
+ */
+
+static Boolean TryNewLayout(bbw)
+ BoxWidget bbw;
+{
+ Dimension preferred_width, preferred_height;
+ Dimension proposed_width, proposed_height;
+ int iterations;
+
+ DoLayout( bbw, bbw->core.width, bbw->core.height,
+ &preferred_width, &preferred_height, FALSE );
+
+ /* at this point, preferred_width is guaranteed to not be greater
+ than bbw->core.width unless some child is larger, so there's no
+ point in re-computing another layout */
+
+ if ((bbw->core.width == preferred_width) &&
+ (bbw->core.height == preferred_height)) {
+ /* Same size */
+ return (TRUE);
+ }
+
+ /* let's see if our parent will go for a new size. */
+ iterations = 0;
+ proposed_width = preferred_width;
+ proposed_height = preferred_height;
+ do {
+ switch (XtMakeResizeRequest((Widget)bbw,proposed_width,proposed_height,
+ &proposed_width, &proposed_height))
+ {
+ case XtGeometryYes:
+ return (TRUE);
+
+ case XtGeometryNo:
+ if (iterations > 0)
+ /* protect from malicious parents who change their minds */
+ DoLayout( bbw, bbw->core.width, bbw->core.height,
+ &preferred_width, &preferred_height, FALSE );
+ if ((preferred_width <= bbw->core.width) &&
+ (preferred_height <= bbw->core.height))
+ return (TRUE);
+ else
+ return (FALSE);
+
+ case XtGeometryAlmost:
+ if (proposed_height >= preferred_height &&
+ proposed_width >= preferred_width) {
+
+ /*
+ * Take it, and assume the parent knows what it is doing.
+ *
+ * The parent must accept this since it was returned in
+ * almost.
+ *
+ */
+ (void) XtMakeResizeRequest( (Widget)bbw,
+ proposed_width, proposed_height,
+ &proposed_width, &proposed_height);
+ return(TRUE);
+ }
+ else if (proposed_width != preferred_width) {
+ /* recalc bounding box; height might change */
+ DoLayout(bbw, proposed_width, 0,
+ &preferred_width, &preferred_height, FALSE);
+ proposed_height = preferred_height;
+ }
+ else { /* proposed_height != preferred_height */
+ XtWidgetGeometry constraints, reply;
+ constraints.request_mode = CWHeight;
+ constraints.height = proposed_height;
+ (void)PreferredSize((Widget)bbw, &constraints, &reply);
+ proposed_width = preferred_width;
+ }
+ }
+ iterations++;
+ } while (iterations < 10);
+ return (FALSE);
+}
+
+/*
+ *
+ * Geometry Manager
+ *
+ * 'reply' is unused; we say only yeay or nay, never almost.
+ *
+ */
+
+/*ARGSUSED*/
+static XtGeometryResult GeometryManager(w, request, reply)
+ Widget w;
+ XtWidgetGeometry *request;
+ XtWidgetGeometry *reply; /* RETURN */
+
+{
+ Dimension width, height, borderWidth;
+ BoxWidget bbw;
+
+ /* Position request always denied */
+ if ((request->request_mode & CWX && request->x != w->core.x) ||
+ (request->request_mode & CWY && request->y != w->core.y))
+ return (XtGeometryNo);
+
+ /* Size changes must see if the new size can be accomodated */
+ if (request->request_mode & (CWWidth | CWHeight | CWBorderWidth)) {
+
+ /* Make all three fields in the request valid */
+ if ((request->request_mode & CWWidth) == 0)
+ request->width = w->core.width;
+ if ((request->request_mode & CWHeight) == 0)
+ request->height = w->core.height;
+ if ((request->request_mode & CWBorderWidth) == 0)
+ request->border_width = w->core.border_width;
+
+ /* Save current size and set to new size */
+ width = w->core.width;
+ height = w->core.height;
+ borderWidth = w->core.border_width;
+ w->core.width = request->width;
+ w->core.height = request->height;
+ w->core.border_width = request->border_width;
+
+ /* Decide if new layout works: (1) new widget is smaller,
+ (2) new widget fits in existing Box, (3) Box can be
+ expanded to allow new widget to fit */
+
+ bbw = (BoxWidget) w->core.parent;
+
+/* whenever a child changes his geometry, we attempt to
+ * change ours to be the minimum enclosing size...
+ if (((request->width + request->border_width <= width + borderWidth) &&
+ (request->height + request->border_width <= height + borderWidth))
+ || bbw->box.preferred_width < bbw->core.width
+ || bbw->box.preferred_height < bbw->core.height
+ || TryNewLayout(bbw)) {
+ */
+ if (TryNewLayout(bbw)) {
+ /* Fits in existing or new space, relayout */
+ (*XtClass((Widget)bbw)->core_class.resize)((Widget)bbw);
+ return (XtGeometryYes);
+ } else {
+ /* Cannot satisfy request, change back to original geometry */
+ w->core.width = width;
+ w->core.height = height;
+ w->core.border_width = borderWidth;
+ return (XtGeometryNo);
+ }
+ }; /* if any size changes requested */
+
+ /* Any stacking changes don't make a difference, so allow if that's all */
+ return (XtGeometryYes);
+}
+
+static void ChangeManaged(w)
+ Widget w;
+{
+ /* Reconfigure the box */
+ (void) TryNewLayout((BoxWidget)w);
+ Resize(w);
+}
+
+static void ClassInitialize()
+{
+ XawInitializeWidgetSet();
+ XtAddConverter( XtRString, XtROrientation, XmuCvtStringToOrientation,
+ (XtConvertArgList)NULL, (Cardinal)0 );
+}
+
+/* ARGSUSED */
+static void Initialize(request, new, args, num_args)
+ Widget request, new;
+ ArgList args;
+ Cardinal *num_args;
+{
+ BoxWidget newbbw = (BoxWidget)new;
+
+ newbbw->box.last_query_mode = CWWidth | CWHeight;
+ newbbw->box.last_query_width = newbbw->box.last_query_height = 0;
+ newbbw->box.preferred_width = Max(newbbw->box.h_space, 1);
+ newbbw->box.preferred_height = Max(newbbw->box.v_space, 1);
+
+ if (newbbw->core.width == 0)
+ newbbw->core.width = newbbw->box.preferred_width;
+
+ if (newbbw->core.height == 0)
+ newbbw->core.height = newbbw->box.preferred_height;
+
+} /* Initialize */
+
+static void Realize(w, valueMask, attributes)
+ Widget w;
+ Mask *valueMask;
+ XSetWindowAttributes *attributes;
+{
+ attributes->bit_gravity = NorthWestGravity;
+ *valueMask |= CWBitGravity;
+
+ XtCreateWindow( w, (unsigned)InputOutput, (Visual *)CopyFromParent,
+ *valueMask, attributes);
+} /* Realize */
+
+/* ARGSUSED */
+static Boolean SetValues(current, request, new, args, num_args)
+ Widget current, request, new;
+ ArgList args;
+ Cardinal *num_args;
+{
+ /* need to relayout if h_space or v_space change */
+
+ return False;
+}
diff --git a/src/Command.c b/src/Command.c
new file mode 100644
index 0000000..8e20493
--- /dev/null
+++ b/src/Command.c
@@ -0,0 +1,590 @@
+/* $Xorg: Command.c,v 1.5 2001/02/09 02:03:43 xorgcvs Exp $ */
+
+/***********************************************************
+
+Copyright 1987, 1988, 1994, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+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
+OPEN GROUP 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 Open Group 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 Open Group.
+
+
+Copyright 1987, 1988 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+******************************************************************/
+
+/*
+ * Command.c - Command button widget
+ */
+
+#include <stdio.h>
+#include <X11/IntrinsicP.h>
+#include <X11/StringDefs.h>
+#include <X11/Xmu/Misc.h>
+#include <X11/Xaw/XawInit.h>
+#include <X11/Xaw/CommandP.h>
+#include <X11/Xmu/Converters.h>
+#include <X11/extensions/shape.h>
+
+#define DEFAULT_HIGHLIGHT_THICKNESS 2
+#define DEFAULT_SHAPE_HIGHLIGHT 32767
+
+/****************************************************************
+ *
+ * Full class record constant
+ *
+ ****************************************************************/
+
+/* Private Data */
+
+static char defaultTranslations[] =
+ "<EnterWindow>: highlight() \n\
+ <LeaveWindow>: reset() \n\
+ <Btn1Down>: set() \n\
+ <Btn1Up>: notify() unset() ";
+
+#define offset(field) XtOffsetOf(CommandRec, field)
+static XtResource resources[] = {
+ {XtNcallback, XtCCallback, XtRCallback, sizeof(XtPointer),
+ offset(command.callbacks), XtRCallback, (XtPointer)NULL},
+ {XtNhighlightThickness, XtCThickness, XtRDimension, sizeof(Dimension),
+ offset(command.highlight_thickness), XtRImmediate,
+ (XtPointer) DEFAULT_SHAPE_HIGHLIGHT},
+ {XtNshapeStyle, XtCShapeStyle, XtRShapeStyle, sizeof(int),
+ offset(command.shape_style), XtRImmediate, (XtPointer)XawShapeRectangle},
+ {XtNcornerRoundPercent, XtCCornerRoundPercent,
+ XtRDimension, sizeof(Dimension),
+ offset(command.corner_round), XtRImmediate, (XtPointer) 25}
+};
+#undef offset
+
+static Boolean SetValues();
+static void Initialize(), Redisplay(), Set(), Reset(), Notify(), Unset();
+static void Highlight(), Unhighlight(), Destroy(), PaintCommandWidget();
+static void ClassInitialize();
+static Boolean ShapeButton();
+static void Realize(), Resize();
+
+static XtActionsRec actionsList[] = {
+ {"set", Set},
+ {"notify", Notify},
+ {"highlight", Highlight},
+ {"reset", Reset},
+ {"unset", Unset},
+ {"unhighlight", Unhighlight}
+};
+
+#define SuperClass ((LabelWidgetClass)&labelClassRec)
+
+CommandClassRec commandClassRec = {
+ {
+ (WidgetClass) SuperClass, /* superclass */
+ "Command", /* class_name */
+ sizeof(CommandRec), /* size */
+ ClassInitialize, /* class_initialize */
+ NULL, /* class_part_initialize */
+ FALSE, /* class_inited */
+ Initialize, /* initialize */
+ NULL, /* initialize_hook */
+ Realize, /* realize */
+ actionsList, /* actions */
+ XtNumber(actionsList), /* num_actions */
+ resources, /* resources */
+ XtNumber(resources), /* resource_count */
+ NULLQUARK, /* xrm_class */
+ FALSE, /* compress_motion */
+ TRUE, /* compress_exposure */
+ TRUE, /* compress_enterleave */
+ FALSE, /* visible_interest */
+ Destroy, /* destroy */
+ Resize, /* resize */
+ Redisplay, /* expose */
+ SetValues, /* set_values */
+ NULL, /* set_values_hook */
+ XtInheritSetValuesAlmost, /* set_values_almost */
+ NULL, /* get_values_hook */
+ NULL, /* accept_focus */
+ XtVersion, /* version */
+ NULL, /* callback_private */
+ defaultTranslations, /* tm_table */
+ XtInheritQueryGeometry, /* query_geometry */
+ XtInheritDisplayAccelerator, /* display_accelerator */
+ NULL /* extension */
+ }, /* CoreClass fields initialization */
+ {
+ XtInheritChangeSensitive /* change_sensitive */
+ }, /* SimpleClass fields initialization */
+ {
+ 0, /* field not used */
+ }, /* LabelClass fields initialization */
+ {
+ 0, /* field not used */
+ }, /* CommandClass fields initialization */
+};
+
+ /* for public consumption */
+WidgetClass commandWidgetClass = (WidgetClass) &commandClassRec;
+
+/****************************************************************
+ *
+ * Private Procedures
+ *
+ ****************************************************************/
+
+static GC
+Get_GC(cbw, fg, bg)
+CommandWidget cbw;
+Pixel fg, bg;
+{
+ XGCValues values;
+
+ values.foreground = fg;
+ values.background = bg;
+ values.font = cbw->label.font->fid;
+ values.cap_style = CapProjecting;
+
+ if (cbw->command.highlight_thickness > 1 )
+ values.line_width = cbw->command.highlight_thickness;
+ else
+ values.line_width = 0;
+
+ if ( cbw->simple.international == True )
+ return XtAllocateGC((Widget)cbw, 0,
+ (GCForeground|GCBackground|GCLineWidth|GCCapStyle),
+ &values, GCFont, 0 );
+ else
+ return XtGetGC((Widget)cbw,
+ (GCForeground|GCBackground|GCFont|GCLineWidth|GCCapStyle),
+ &values);
+}
+
+
+/* ARGSUSED */
+static void
+Initialize(request, new, args, num_args)
+Widget request, new;
+ArgList args; /* unused */
+Cardinal *num_args; /* unused */
+{
+ CommandWidget cbw = (CommandWidget) new;
+ int shape_event_base, shape_error_base;
+
+ if (cbw->command.shape_style != XawShapeRectangle
+ && !XShapeQueryExtension(XtDisplay(new), &shape_event_base,
+ &shape_error_base))
+ cbw->command.shape_style = XawShapeRectangle;
+ if (cbw->command.highlight_thickness == DEFAULT_SHAPE_HIGHLIGHT) {
+ if (cbw->command.shape_style != XawShapeRectangle)
+ cbw->command.highlight_thickness = 0;
+ else
+ cbw->command.highlight_thickness = DEFAULT_HIGHLIGHT_THICKNESS;
+ }
+
+ cbw->command.normal_GC = Get_GC(cbw, cbw->label.foreground,
+ cbw->core.background_pixel);
+ cbw->command.inverse_GC = Get_GC(cbw, cbw->core.background_pixel,
+ cbw->label.foreground);
+ XtReleaseGC(new, cbw->label.normal_GC);
+ cbw->label.normal_GC = cbw->command.normal_GC;
+
+ cbw->command.set = FALSE;
+ cbw->command.highlighted = HighlightNone;
+}
+
+static Region
+HighlightRegion(cbw)
+CommandWidget cbw;
+{
+ static Region outerRegion = NULL, innerRegion, emptyRegion;
+ XRectangle rect;
+
+ if (cbw->command.highlight_thickness == 0 ||
+ cbw->command.highlight_thickness >
+ (Dimension) ((Dimension) Min(cbw->core.width, cbw->core.height)/2))
+ return(NULL);
+
+ if (outerRegion == NULL) {
+ /* save time by allocating scratch regions only once. */
+ outerRegion = XCreateRegion();
+ innerRegion = XCreateRegion();
+ emptyRegion = XCreateRegion();
+ }
+
+ rect.x = rect.y = 0;
+ rect.width = cbw->core.width;
+ rect.height = cbw->core.height;
+ XUnionRectWithRegion( &rect, emptyRegion, outerRegion );
+ rect.x = rect.y = cbw->command.highlight_thickness;
+ rect.width -= cbw->command.highlight_thickness * 2;
+ rect.height -= cbw->command.highlight_thickness * 2;
+ XUnionRectWithRegion( &rect, emptyRegion, innerRegion );
+ XSubtractRegion( outerRegion, innerRegion, outerRegion );
+ return outerRegion;
+}
+
+/***************************
+*
+* Action Procedures
+*
+***************************/
+
+/* ARGSUSED */
+static void
+Set(w,event,params,num_params)
+Widget w;
+XEvent *event;
+String *params; /* unused */
+Cardinal *num_params; /* unused */
+{
+ CommandWidget cbw = (CommandWidget)w;
+
+ if (cbw->command.set)
+ return;
+
+ cbw->command.set= TRUE;
+ if (XtIsRealized(w))
+ PaintCommandWidget(w, event, (Region) NULL, TRUE);
+}
+
+/* ARGSUSED */
+static void
+Unset(w,event,params,num_params)
+Widget w;
+XEvent *event;
+String *params; /* unused */
+Cardinal *num_params;
+{
+ CommandWidget cbw = (CommandWidget)w;
+
+ if (!cbw->command.set)
+ return;
+
+ cbw->command.set = FALSE;
+ if (XtIsRealized(w)) {
+ XClearWindow(XtDisplay(w), XtWindow(w));
+ PaintCommandWidget(w, event, (Region) NULL, TRUE);
+ }
+}
+
+/* ARGSUSED */
+static void
+Reset(w,event,params,num_params)
+Widget w;
+XEvent *event;
+String *params; /* unused */
+Cardinal *num_params; /* unused */
+{
+ CommandWidget cbw = (CommandWidget)w;
+
+ if (cbw->command.set) {
+ cbw->command.highlighted = HighlightNone;
+ Unset(w, event, params, num_params);
+ } else
+ Unhighlight(w, event, params, num_params);
+}
+
+/* ARGSUSED */
+static void
+Highlight(w,event,params,num_params)
+Widget w;
+XEvent *event;
+String *params;
+Cardinal *num_params;
+{
+ CommandWidget cbw = (CommandWidget)w;
+
+ if ( *num_params == (Cardinal) 0)
+ cbw->command.highlighted = HighlightWhenUnset;
+ else {
+ if ( *num_params != (Cardinal) 1)
+ XtWarning("Too many parameters passed to highlight action table.");
+ switch (params[0][0]) {
+ case 'A':
+ case 'a':
+ cbw->command.highlighted = HighlightAlways;
+ break;
+ default:
+ cbw->command.highlighted = HighlightWhenUnset;
+ break;
+ }
+ }
+
+ if (XtIsRealized(w))
+ PaintCommandWidget(w, event, HighlightRegion(cbw), TRUE);
+}
+
+/* ARGSUSED */
+static void
+Unhighlight(w,event,params,num_params)
+Widget w;
+XEvent *event;
+String *params; /* unused */
+Cardinal *num_params; /* unused */
+{
+ CommandWidget cbw = (CommandWidget)w;
+
+ cbw->command.highlighted = HighlightNone;
+ if (XtIsRealized(w))
+ PaintCommandWidget(w, event, HighlightRegion(cbw), TRUE);
+}
+
+/* ARGSUSED */
+static void
+Notify(w,event,params,num_params)
+Widget w;
+XEvent *event;
+String *params; /* unused */
+Cardinal *num_params; /* unused */
+{
+ CommandWidget cbw = (CommandWidget)w;
+
+ /* check to be sure state is still Set so that user can cancel
+ the action (e.g. by moving outside the window, in the default
+ bindings.
+ */
+ if (cbw->command.set)
+ XtCallCallbackList(w, cbw->command.callbacks, (XtPointer) NULL);
+}
+
+/*
+ * Repaint the widget window
+ */
+
+/************************
+*
+* REDISPLAY (DRAW)
+*
+************************/
+
+/* ARGSUSED */
+static void
+Redisplay(w, event, region)
+Widget w;
+XEvent *event;
+Region region;
+{
+ PaintCommandWidget(w, event, region, FALSE);
+}
+
+/* Function Name: PaintCommandWidget
+ * Description: Paints the command widget.
+ * Arguments: w - the command widget.
+ * region - region to paint (passed to the superclass).
+ * change - did it change either set or highlight state?
+ * Returns: none
+ */
+
+static void
+PaintCommandWidget(w, event, region, change)
+Widget w;
+XEvent *event;
+Region region;
+Boolean change;
+{
+ CommandWidget cbw = (CommandWidget) w;
+ Boolean very_thick;
+ GC norm_gc, rev_gc;
+
+ very_thick = cbw->command.highlight_thickness >
+ (Dimension)((Dimension) Min(cbw->core.width, cbw->core.height)/2);
+
+ if (cbw->command.set) {
+ cbw->label.normal_GC = cbw->command.inverse_GC;
+ XFillRectangle(XtDisplay(w), XtWindow(w), cbw->command.normal_GC,
+ 0, 0, cbw->core.width, cbw->core.height);
+ region = NULL; /* Force label to repaint text. */
+ }
+ else
+ cbw->label.normal_GC = cbw->command.normal_GC;
+
+ if (cbw->command.highlight_thickness <= 0)
+ {
+ (*SuperClass->core_class.expose) (w, event, region);
+ return;
+ }
+
+/*
+ * If we are set then use the same colors as if we are not highlighted.
+ */
+
+ if (cbw->command.set == (cbw->command.highlighted == HighlightNone)) {
+ norm_gc = cbw->command.inverse_GC;
+ rev_gc = cbw->command.normal_GC;
+ }
+ else {
+ norm_gc = cbw->command.normal_GC;
+ rev_gc = cbw->command.inverse_GC;
+ }
+
+ if ( !( (!change && (cbw->command.highlighted == HighlightNone)) ||
+ ((cbw->command.highlighted == HighlightWhenUnset) &&
+ (cbw->command.set))) ) {
+ if (very_thick) {
+ cbw->label.normal_GC = norm_gc; /* Give the label the right GC. */
+ XFillRectangle(XtDisplay(w),XtWindow(w), rev_gc,
+ 0, 0, cbw->core.width, cbw->core.height);
+ }
+ else {
+ /* wide lines are centered on the path, so indent it */
+ int offset = cbw->command.highlight_thickness/2;
+ XDrawRectangle(XtDisplay(w),XtWindow(w), rev_gc, offset, offset,
+ cbw->core.width - cbw->command.highlight_thickness,
+ cbw->core.height - cbw->command.highlight_thickness);
+ }
+ }
+ (*SuperClass->core_class.expose) (w, event, region);
+}
+
+static void
+Destroy(w)
+Widget w;
+{
+ CommandWidget cbw = (CommandWidget) w;
+
+ /* so Label can release it */
+ if (cbw->label.normal_GC == cbw->command.normal_GC)
+ XtReleaseGC( w, cbw->command.inverse_GC );
+ else
+ XtReleaseGC( w, cbw->command.normal_GC );
+}
+
+/*
+ * Set specified arguments into widget
+ */
+
+/* ARGSUSED */
+static Boolean
+SetValues (current, request, new, args, num_args)
+Widget current, request, new;
+ArgList args;
+Cardinal *num_args;
+{
+ CommandWidget oldcbw = (CommandWidget) current;
+ CommandWidget cbw = (CommandWidget) new;
+ Boolean redisplay = False;
+
+ if ( oldcbw->core.sensitive != cbw->core.sensitive && !cbw->core.sensitive) {
+ /* about to become insensitive */
+ cbw->command.set = FALSE;
+ cbw->command.highlighted = HighlightNone;
+ redisplay = TRUE;
+ }
+
+ if ( (oldcbw->label.foreground != cbw->label.foreground) ||
+ (oldcbw->core.background_pixel != cbw->core.background_pixel) ||
+ (oldcbw->command.highlight_thickness !=
+ cbw->command.highlight_thickness) ||
+ (oldcbw->label.font != cbw->label.font) )
+ {
+ if (oldcbw->label.normal_GC == oldcbw->command.normal_GC)
+ /* Label has release one of these */
+ XtReleaseGC(new, cbw->command.inverse_GC);
+ else
+ XtReleaseGC(new, cbw->command.normal_GC);
+
+ cbw->command.normal_GC = Get_GC(cbw, cbw->label.foreground,
+ cbw->core.background_pixel);
+ cbw->command.inverse_GC = Get_GC(cbw, cbw->core.background_pixel,
+ cbw->label.foreground);
+ XtReleaseGC(new, cbw->label.normal_GC);
+ cbw->label.normal_GC = (cbw->command.set
+ ? cbw->command.inverse_GC
+ : cbw->command.normal_GC);
+
+ redisplay = True;
+ }
+
+ if ( XtIsRealized(new)
+ && oldcbw->command.shape_style != cbw->command.shape_style
+ && !ShapeButton(cbw, TRUE))
+ {
+ cbw->command.shape_style = oldcbw->command.shape_style;
+ }
+
+ return (redisplay);
+}
+
+static void ClassInitialize()
+{
+ XawInitializeWidgetSet();
+ XtSetTypeConverter( XtRString, XtRShapeStyle, XmuCvtStringToShapeStyle,
+ (XtConvertArgList)NULL, 0, XtCacheNone, (XtDestructor)NULL );
+}
+
+
+static Boolean
+ShapeButton(cbw, checkRectangular)
+CommandWidget cbw;
+Boolean checkRectangular;
+{
+ Dimension corner_size;
+
+ if ( (cbw->command.shape_style == XawShapeRoundedRectangle) ) {
+ corner_size = (cbw->core.width < cbw->core.height) ? cbw->core.width
+ : cbw->core.height;
+ corner_size = (int) (corner_size * cbw->command.corner_round) / 100;
+ }
+
+ if (checkRectangular || cbw->command.shape_style != XawShapeRectangle) {
+ if (!XmuReshapeWidget((Widget) cbw, cbw->command.shape_style,
+ corner_size, corner_size)) {
+ cbw->command.shape_style = XawShapeRectangle;
+ return(False);
+ }
+ }
+ return(TRUE);
+}
+
+static void Realize(w, valueMask, attributes)
+ Widget w;
+ Mask *valueMask;
+ XSetWindowAttributes *attributes;
+{
+ (*commandWidgetClass->core_class.superclass->core_class.realize)
+ (w, valueMask, attributes);
+
+ ShapeButton( (CommandWidget) w, FALSE);
+}
+
+static void Resize(w)
+ Widget w;
+{
+ if (XtIsRealized(w))
+ ShapeButton( (CommandWidget) w, FALSE);
+
+ (*commandWidgetClass->core_class.superclass->core_class.resize)(w);
+}
diff --git a/src/Dialog.c b/src/Dialog.c
new file mode 100644
index 0000000..fe77938
--- /dev/null
+++ b/src/Dialog.c
@@ -0,0 +1,447 @@
+/* $Xorg: Dialog.c,v 1.4 2001/02/09 02:03:43 xorgcvs Exp $ */
+
+/***********************************************************
+
+Copyright 1987, 1988, 1994, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+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
+OPEN GROUP 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 Open Group 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 Open Group.
+
+
+Copyright 1987, 1988 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+******************************************************************/
+
+/* NOTE: THIS IS NOT A WIDGET! Rather, this is an interface to a widget.
+ It implements policy, and gives a (hopefully) easier-to-use interface
+ than just directly making your own form. */
+
+
+#include <X11/IntrinsicP.h>
+#include <X11/Xos.h>
+#include <X11/StringDefs.h>
+#include <X11/Xmu/Misc.h>
+
+#include <X11/Xaw/XawInit.h>
+#include <X11/Xaw/AsciiText.h>
+#include <X11/Xaw/Command.h>
+#include <X11/Xaw/Label.h>
+#include <X11/Xaw/DialogP.h>
+#include <X11/Xaw/Cardinals.h>
+
+/*
+ * After we have set the string in the value widget we set the
+ * string to a magic value. So that when a SetValues request is made
+ * on the dialog value we will notice it, and reset the string.
+ */
+
+#define MAGIC_VALUE ((char *) 3)
+
+#define streq(a,b) (strcmp( (a), (b) ) == 0)
+
+static XtResource resources[] = {
+ {XtNlabel, XtCLabel, XtRString, sizeof(String),
+ XtOffsetOf(DialogRec, dialog.label), XtRString, NULL},
+ {XtNvalue, XtCValue, XtRString, sizeof(String),
+ XtOffsetOf(DialogRec, dialog.value), XtRString, NULL},
+ {XtNicon, XtCIcon, XtRBitmap, sizeof(Pixmap),
+ XtOffsetOf(DialogRec, dialog.icon), XtRImmediate, 0},
+};
+
+static void Initialize(), ConstraintInitialize(), CreateDialogValueWidget(),
+ GetValuesHook();
+
+static Boolean SetValues();
+
+DialogClassRec dialogClassRec = {
+ { /* core_class fields */
+ /* superclass */ (WidgetClass) &formClassRec,
+ /* class_name */ "Dialog",
+ /* widget_size */ sizeof(DialogRec),
+ /* class_initialize */ XawInitializeWidgetSet,
+ /* class_part init */ NULL,
+ /* class_inited */ FALSE,
+ /* initialize */ Initialize,
+ /* initialize_hook */ NULL,
+ /* realize */ XtInheritRealize,
+ /* actions */ NULL,
+ /* num_actions */ 0,
+ /* resources */ resources,
+ /* num_resources */ XtNumber(resources),
+ /* xrm_class */ NULLQUARK,
+ /* compress_motion */ TRUE,
+ /* compress_exposure */ TRUE,
+ /* compress_enterleave*/ TRUE,
+ /* visible_interest */ FALSE,
+ /* destroy */ NULL,
+ /* resize */ XtInheritResize,
+ /* expose */ XtInheritExpose,
+ /* set_values */ SetValues,
+ /* set_values_hook */ NULL,
+ /* set_values_almost */ XtInheritSetValuesAlmost,
+ /* get_values_hook */ GetValuesHook,
+ /* accept_focus */ NULL,
+ /* version */ XtVersion,
+ /* callback_private */ NULL,
+ /* tm_table */ NULL,
+ /* query_geometry */ XtInheritQueryGeometry,
+ /* display_accelerator*/ XtInheritDisplayAccelerator,
+ /* extension */ NULL
+ },
+ { /* composite_class fields */
+ /* geometry_manager */ XtInheritGeometryManager,
+ /* change_managed */ XtInheritChangeManaged,
+ /* insert_child */ XtInheritInsertChild,
+ /* delete_child */ XtInheritDeleteChild,
+ /* extension */ NULL
+ },
+ { /* constraint_class fields */
+ /* subresourses */ NULL,
+ /* subresource_count */ 0,
+ /* constraint_size */ sizeof(DialogConstraintsRec),
+ /* initialize */ ConstraintInitialize,
+ /* destroy */ NULL,
+ /* set_values */ NULL,
+ /* extension */ NULL
+ },
+ { /* form_class fields */
+ /* layout */ XtInheritLayout
+ },
+ { /* dialog_class fields */
+ /* empty */ 0
+ }
+};
+
+WidgetClass dialogWidgetClass = (WidgetClass)&dialogClassRec;
+
+/* ARGSUSED */
+static void Initialize(request, new, args, num_args)
+Widget request, new;
+ArgList args;
+Cardinal *num_args;
+{
+ DialogWidget dw = (DialogWidget)new;
+ Arg arglist[9];
+ Cardinal arg_cnt = 0;
+
+ XtSetArg(arglist[arg_cnt], XtNborderWidth, 0); arg_cnt++;
+ XtSetArg(arglist[arg_cnt], XtNleft, XtChainLeft); arg_cnt++;
+
+ if (dw->dialog.icon != (Pixmap)0) {
+ XtSetArg(arglist[arg_cnt], XtNbitmap, dw->dialog.icon); arg_cnt++;
+ XtSetArg(arglist[arg_cnt], XtNright, XtChainLeft); arg_cnt++;
+ dw->dialog.iconW =
+ XtCreateManagedWidget( "icon", labelWidgetClass,
+ new, arglist, arg_cnt );
+ arg_cnt = 2;
+ XtSetArg(arglist[arg_cnt], XtNfromHoriz, dw->dialog.iconW);arg_cnt++;
+ } else dw->dialog.iconW = (Widget)NULL;
+
+ XtSetArg(arglist[arg_cnt], XtNlabel, dw->dialog.label); arg_cnt++;
+ XtSetArg(arglist[arg_cnt], XtNright, XtChainRight); arg_cnt++;
+
+ dw->dialog.labelW = XtCreateManagedWidget( "label", labelWidgetClass,
+ new, arglist, arg_cnt);
+
+ if (dw->dialog.iconW != (Widget)NULL &&
+ (dw->dialog.labelW->core.height < dw->dialog.iconW->core.height)) {
+ XtSetArg( arglist[0], XtNheight, dw->dialog.iconW->core.height );
+ XtSetValues( dw->dialog.labelW, arglist, ONE );
+ }
+ if (dw->dialog.value != NULL)
+ CreateDialogValueWidget( (Widget) dw);
+ else
+ dw->dialog.valueW = NULL;
+}
+
+/* ARGSUSED */
+static void ConstraintInitialize(request, new, args, num_args)
+Widget request, new;
+ArgList args;
+Cardinal *num_args;
+{
+ DialogWidget dw = (DialogWidget)new->core.parent;
+ DialogConstraints constraint = (DialogConstraints)new->core.constraints;
+
+ if (!XtIsSubclass(new, commandWidgetClass)) /* if not a button */
+ return; /* then just use defaults */
+
+ constraint->form.left = constraint->form.right = XtChainLeft;
+ if (dw->dialog.valueW == NULL)
+ constraint->form.vert_base = dw->dialog.labelW;
+ else
+ constraint->form.vert_base = dw->dialog.valueW;
+
+ if (dw->composite.num_children > 1) {
+ WidgetList children = dw->composite.children;
+ Widget *childP;
+ for (childP = children + dw->composite.num_children - 1;
+ childP >= children; childP-- ) {
+ if (*childP == dw->dialog.labelW || *childP == dw->dialog.valueW)
+ break;
+ if (XtIsManaged(*childP) &&
+ XtIsSubclass(*childP, commandWidgetClass)) {
+ constraint->form.horiz_base = *childP;
+ break;
+ }
+ }
+ }
+}
+
+#define ICON 0
+#define LABEL 1
+#define NUM_CHECKS 2
+
+/* ARGSUSED */
+static Boolean SetValues(current, request, new, in_args, in_num_args)
+Widget current, request, new;
+ArgList in_args;
+Cardinal *in_num_args;
+{
+ DialogWidget w = (DialogWidget)new;
+ DialogWidget old = (DialogWidget)current;
+ Arg args[5];
+ Cardinal num_args;
+ int i;
+ Boolean checks[NUM_CHECKS];
+
+ for (i = 0; i < NUM_CHECKS; i++)
+ checks[i] = FALSE;
+
+ for (i = 0; i < *in_num_args; i++) {
+ if (streq(XtNicon, in_args[i].name))
+ checks[ICON] = TRUE;
+ if (streq(XtNlabel, in_args[i].name))
+ checks[LABEL] = TRUE;
+ }
+
+ if (checks[ICON]) {
+ if (w->dialog.icon != (Pixmap)0) {
+ XtSetArg( args[0], XtNbitmap, w->dialog.icon );
+ if (old->dialog.iconW != (Widget)NULL) {
+ XtSetValues( old->dialog.iconW, args, ONE );
+ } else {
+ XtSetArg( args[1], XtNborderWidth, 0);
+ XtSetArg( args[2], XtNleft, XtChainLeft);
+ XtSetArg( args[3], XtNright, XtChainLeft);
+ w->dialog.iconW =
+ XtCreateWidget( "icon", labelWidgetClass,
+ new, args, FOUR );
+ ((DialogConstraints)w->dialog.labelW->core.constraints)->
+ form.horiz_base = w->dialog.iconW;
+ XtManageChild(w->dialog.iconW);
+ }
+ } else if (old->dialog.icon != (Pixmap)0) {
+ ((DialogConstraints)w->dialog.labelW->core.constraints)->
+ form.horiz_base = (Widget)NULL;
+ XtDestroyWidget(old->dialog.iconW);
+ w->dialog.iconW = (Widget)NULL;
+ }
+ }
+
+ if ( checks[LABEL] ) {
+ num_args = 0;
+ XtSetArg( args[num_args], XtNlabel, w->dialog.label ); num_args++;
+ if (w->dialog.iconW != (Widget)NULL &&
+ (w->dialog.labelW->core.height <= w->dialog.iconW->core.height)) {
+ XtSetArg(args[num_args], XtNheight, w->dialog.iconW->core.height);
+ num_args++;
+ }
+ XtSetValues( w->dialog.labelW, args, num_args );
+ }
+
+ if ( w->dialog.value != old->dialog.value ) {
+ if (w->dialog.value == NULL) /* only get here if it
+ wasn't NULL before. */
+ XtDestroyWidget(old->dialog.valueW);
+ else if (old->dialog.value == NULL) { /* create a new value widget. */
+ w->core.width = old->core.width;
+ w->core.height = old->core.height;
+#ifdef notdef
+/* this would be correct if Form had the same semantics on Resize
+ * as on MakeGeometryRequest. Unfortunately, Form botched it, so
+ * any subclasses will currently have to deal with the fact that
+ * we're about to change our real size.
+ */
+ w->form.resize_in_layout = False;
+ CreateDialogValueWidget( (Widget) w);
+ w->core.width = w->form.preferred_width;
+ w->core.height = w->form.preferred_height;
+ w->form.resize_in_layout = True;
+#else /*notdef*/
+ CreateDialogValueWidget( (Widget) w);
+#endif /*notdef*/
+ }
+ else { /* Widget ok, just change string. */
+ Arg args[1];
+ XtSetArg(args[0], XtNstring, w->dialog.value);
+ XtSetValues(w->dialog.valueW, args, ONE);
+ w->dialog.value = MAGIC_VALUE;
+ }
+ }
+ return False;
+}
+
+/* Function Name: GetValuesHook
+ * Description: This is a get values hook routine that gets the
+ * values in the dialog.
+ * Arguments: w - the Text Widget.
+ * args - the argument list.
+ * num_args - the number of args.
+ * Returns: none.
+ */
+
+static void
+GetValuesHook(w, args, num_args)
+Widget w;
+ArgList args;
+Cardinal * num_args;
+{
+ Arg a[1];
+ String s;
+ DialogWidget src = (DialogWidget) w;
+ int i;
+
+ for (i=0; i < *num_args; i++)
+ if (streq(args[i].name, XtNvalue)) {
+ XtSetArg(a[0], XtNstring, &s);
+ XtGetValues(src->dialog.valueW, a, 1);
+ *((char **) args[i].value) = s;
+ }
+}
+
+
+/* Function Name: CreateDialogValueWidget
+ * Description: Creates the dialog widgets value widget.
+ * Arguments: w - the dialog widget.
+ * Returns: none.
+ *
+ * must be called only when w->dialog.value is non-nil.
+ */
+
+static void
+CreateDialogValueWidget(w)
+Widget w;
+{
+ DialogWidget dw = (DialogWidget) w;
+ Arg arglist[10];
+ Cardinal num_args = 0;
+
+#ifdef notdef
+ XtSetArg(arglist[num_args], XtNwidth,
+ dw->dialog.labelW->core.width); num_args++; /* ||| hack */
+#endif /*notdef*/
+ XtSetArg(arglist[num_args], XtNstring, dw->dialog.value); num_args++;
+ XtSetArg(arglist[num_args], XtNresizable, True); num_args++;
+ XtSetArg(arglist[num_args], XtNresize, XawtextResizeBoth); num_args++;
+ XtSetArg(arglist[num_args], XtNeditType, XawtextEdit); num_args++;
+ XtSetArg(arglist[num_args], XtNfromVert, dw->dialog.labelW); num_args++;
+ XtSetArg(arglist[num_args], XtNleft, XtChainLeft); num_args++;
+ XtSetArg(arglist[num_args], XtNright, XtChainRight); num_args++;
+
+ dw->dialog.valueW = XtCreateWidget("value", asciiTextWidgetClass,
+ w, arglist, num_args);
+
+ /* if the value widget is being added after buttons,
+ * then the buttons need new layout constraints.
+ */
+ if (dw->composite.num_children > 1) {
+ WidgetList children = dw->composite.children;
+ Widget *childP;
+ for (childP = children + dw->composite.num_children - 1;
+ childP >= children; childP-- ) {
+ if (*childP == dw->dialog.labelW || *childP == dw->dialog.valueW)
+ continue;
+ if (XtIsManaged(*childP) &&
+ XtIsSubclass(*childP, commandWidgetClass)) {
+ ((DialogConstraints)(*childP)->core.constraints)->
+ form.vert_base = dw->dialog.valueW;
+ }
+ }
+ }
+ XtManageChild(dw->dialog.valueW);
+
+/*
+ * Value widget gets the keyboard focus.
+ */
+
+ XtSetKeyboardFocus(w, dw->dialog.valueW);
+ dw->dialog.value = MAGIC_VALUE;
+}
+
+
+void
+#if NeedFunctionPrototypes
+XawDialogAddButton(Widget dialog, _Xconst char* name, XtCallbackProc function,
+ XtPointer param)
+#else
+XawDialogAddButton(dialog, name, function, param)
+Widget dialog;
+String name;
+XtCallbackProc function;
+XtPointer param;
+#endif
+{
+/*
+ * Correct Constraints are all set in ConstraintInitialize().
+ */
+ Widget button;
+
+ button = XtCreateManagedWidget( name, commandWidgetClass, dialog,
+ (ArgList)NULL, (Cardinal)0 );
+
+ if (function != NULL) /* don't add NULL callback func. */
+ XtAddCallback(button, XtNcallback, function, param);
+}
+
+
+char *
+#if NeedFunctionPrototypes
+XawDialogGetValueString(Widget w)
+#else
+XawDialogGetValueString(w)
+Widget w;
+#endif
+{
+ Arg args[1];
+ char * value;
+
+ XtSetArg(args[0], XtNstring, &value);
+ XtGetValues( ((DialogWidget)w)->dialog.valueW, args, ONE);
+ return(value);
+}
diff --git a/src/Form.c b/src/Form.c
new file mode 100644
index 0000000..96b0ad6
--- /dev/null
+++ b/src/Form.c
@@ -0,0 +1,847 @@
+/* $Xorg: Form.c,v 1.4 2001/02/09 02:03:43 xorgcvs Exp $ */
+
+/***********************************************************
+
+Copyright 1987, 1988, 1994, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+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
+OPEN GROUP 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 Open Group 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 Open Group.
+
+
+Copyright 1987, 1988 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+******************************************************************/
+
+#include <X11/IntrinsicP.h>
+#include <X11/StringDefs.h>
+#include <X11/Xmu/Converters.h>
+#include <X11/Xmu/CharSet.h>
+#include <X11/Xaw/XawInit.h>
+#include <X11/Xaw/FormP.h>
+
+/* Private Definitions */
+
+static int default_value = -99999;
+
+#define Offset(field) XtOffsetOf(FormRec, form.field)
+static XtResource resources[] = {
+ {XtNdefaultDistance, XtCThickness, XtRInt, sizeof(int),
+ Offset(default_spacing), XtRImmediate, (XtPointer)4}
+};
+#undef Offset
+
+static XtEdgeType defEdge = XtRubber;
+
+#define Offset(field) XtOffsetOf(FormConstraintsRec, form.field)
+static XtResource formConstraintResources[] = {
+ {XtNtop, XtCEdge, XtREdgeType, sizeof(XtEdgeType),
+ Offset(top), XtREdgeType, (XtPointer)&defEdge},
+ {XtNbottom, XtCEdge, XtREdgeType, sizeof(XtEdgeType),
+ Offset(bottom), XtREdgeType, (XtPointer)&defEdge},
+ {XtNleft, XtCEdge, XtREdgeType, sizeof(XtEdgeType),
+ Offset(left), XtREdgeType, (XtPointer)&defEdge},
+ {XtNright, XtCEdge, XtREdgeType, sizeof(XtEdgeType),
+ Offset(right), XtREdgeType, (XtPointer)&defEdge},
+ {XtNhorizDistance, XtCThickness, XtRInt, sizeof(int),
+ Offset(dx), XtRInt, (XtPointer) &default_value},
+ {XtNfromHoriz, XtCWidget, XtRWidget, sizeof(Widget),
+ Offset(horiz_base), XtRWidget, (XtPointer)NULL},
+ {XtNvertDistance, XtCThickness, XtRInt, sizeof(int),
+ Offset(dy), XtRInt, (XtPointer) &default_value},
+ {XtNfromVert, XtCWidget, XtRWidget, sizeof(Widget),
+ Offset(vert_base), XtRWidget, (XtPointer)NULL},
+ {XtNresizable, XtCBoolean, XtRBoolean, sizeof(Boolean),
+ Offset(allow_resize), XtRImmediate, (XtPointer) FALSE},
+};
+#undef Offset
+
+static void ClassInitialize(), ClassPartInitialize(), Initialize(), Resize();
+static void ConstraintInitialize();
+static Boolean SetValues(), ConstraintSetValues();
+static XtGeometryResult GeometryManager(), PreferredGeometry();
+static void ChangeManaged();
+static Boolean Layout();
+
+static void LayoutChild(), ResizeChildren();
+
+FormClassRec formClassRec = {
+ { /* core_class fields */
+ /* superclass */ (WidgetClass) &constraintClassRec,
+ /* class_name */ "Form",
+ /* widget_size */ sizeof(FormRec),
+ /* class_initialize */ ClassInitialize,
+ /* class_part_init */ ClassPartInitialize,
+ /* class_inited */ FALSE,
+ /* initialize */ Initialize,
+ /* initialize_hook */ NULL,
+ /* realize */ XtInheritRealize,
+ /* actions */ NULL,
+ /* num_actions */ 0,
+ /* resources */ resources,
+ /* num_resources */ XtNumber(resources),
+ /* xrm_class */ NULLQUARK,
+ /* compress_motion */ TRUE,
+ /* compress_exposure */ TRUE,
+ /* compress_enterleave*/ TRUE,
+ /* visible_interest */ FALSE,
+ /* destroy */ NULL,
+ /* resize */ Resize,
+ /* expose */ XtInheritExpose,
+ /* set_values */ SetValues,
+ /* set_values_hook */ NULL,
+ /* set_values_almost */ XtInheritSetValuesAlmost,
+ /* get_values_hook */ NULL,
+ /* accept_focus */ NULL,
+ /* version */ XtVersion,
+ /* callback_private */ NULL,
+ /* tm_table */ NULL,
+ /* query_geometry */ PreferredGeometry,
+ /* display_accelerator*/ XtInheritDisplayAccelerator,
+ /* extension */ NULL
+ },
+ { /* composite_class fields */
+ /* geometry_manager */ GeometryManager,
+ /* change_managed */ ChangeManaged,
+ /* insert_child */ XtInheritInsertChild,
+ /* delete_child */ XtInheritDeleteChild,
+ /* extension */ NULL
+ },
+ { /* constraint_class fields */
+ /* subresourses */ formConstraintResources,
+ /* subresource_count */ XtNumber(formConstraintResources),
+ /* constraint_size */ sizeof(FormConstraintsRec),
+ /* initialize */ ConstraintInitialize,
+ /* destroy */ NULL,
+ /* set_values */ ConstraintSetValues,
+ /* extension */ NULL
+ },
+ { /* form_class fields */
+ /* layout */ Layout
+ }
+};
+
+WidgetClass formWidgetClass = (WidgetClass)&formClassRec;
+
+/****************************************************************
+ *
+ * Private Procedures
+ *
+ ****************************************************************/
+
+
+static XrmQuark XtQChainLeft, XtQChainRight, XtQChainTop,
+ XtQChainBottom, XtQRubber;
+
+/* ARGSUSED */
+static void _CvtStringToEdgeType(args, num_args, fromVal, toVal)
+ XrmValuePtr args; /* unused */
+ Cardinal *num_args; /* unused */
+ XrmValuePtr fromVal;
+ XrmValuePtr toVal;
+{
+ static XtEdgeType edgeType;
+ XrmQuark q;
+ char lowerName[40];
+
+ if (strlen ((char*) fromVal->addr) < sizeof lowerName) {
+ XmuCopyISOLatin1Lowered (lowerName, (char*)fromVal->addr);
+ q = XrmStringToQuark(lowerName);
+ if (q == XtQChainLeft) edgeType = XtChainLeft;
+ else if (q == XtQChainRight) edgeType = XtChainRight;
+ else if (q == XtQChainTop) edgeType = XtChainTop;
+ else if (q == XtQChainBottom) edgeType = XtChainBottom;
+ else if (q == XtQRubber) edgeType = XtRubber;
+ else {
+ toVal->size = 0;
+ toVal->addr = NULL;
+ return;
+ }
+ toVal->size = sizeof edgeType;
+ toVal->addr = (XPointer) &edgeType;
+ return;
+ }
+ toVal->addr = NULL;
+ toVal->size = 0;
+}
+
+static void ClassInitialize()
+{
+ static XtConvertArgRec parentCvtArgs[] = {
+ {XtBaseOffset, (XtPointer)XtOffsetOf(WidgetRec, core.parent),
+ sizeof(Widget)}
+ };
+ XawInitializeWidgetSet();
+ XtQChainLeft = XrmPermStringToQuark("chainleft");
+ XtQChainRight = XrmPermStringToQuark("chainright");
+ XtQChainTop = XrmPermStringToQuark("chaintop");
+ XtQChainBottom = XrmPermStringToQuark("chainbottom");
+ XtQRubber = XrmPermStringToQuark("rubber");
+
+ XtAddConverter( XtRString, XtREdgeType, _CvtStringToEdgeType,
+ (XtConvertArgList)NULL, 0 );
+ XtSetTypeConverter (XtRString, XtRWidget, XmuNewCvtStringToWidget,
+ parentCvtArgs, XtNumber(parentCvtArgs), XtCacheNone,
+ (XtDestructor)NULL);
+}
+
+static void ClassPartInitialize(class)
+ WidgetClass class;
+{
+ FormWidgetClass c = (FormWidgetClass)class;
+ FormWidgetClass super = (FormWidgetClass)
+ c->core_class.superclass;
+
+ if (c->form_class.layout == XtInheritLayout)
+ c->form_class.layout = super->form_class.layout;
+}
+
+/* ARGSUSED */
+static void Initialize(request, new, args, num_args)
+ Widget request, new;
+ ArgList args;
+ Cardinal *num_args;
+{
+ FormWidget fw = (FormWidget)new;
+
+ fw->form.old_width = fw->core.width;
+ fw->form.old_height = fw->core.height;
+ fw->form.no_refigure = False;
+ fw->form.needs_relayout = False;
+ fw->form.resize_in_layout = True;
+ fw->form.resize_is_no_op = False;
+}
+
+/* Function Name: ChangeFormGeometry
+ * Description: Ask the parent to change the form widget's geometry.
+ * Arguments: w - the Form widget.
+ * query_only - TRUE if this is only a query.
+ * width, height - the new width and height.
+ * ret_width, ret_height - the actual size the form is allowed
+ * to resize to.
+ * Returns: TRUE of children may always be resized.
+ */
+
+static Boolean
+ChangeFormGeometry(w, query_only, width, height, ret_width, ret_height)
+Widget w;
+Boolean query_only;
+Dimension width, height;
+Dimension *ret_width, *ret_height;
+{
+ FormWidget fw = (FormWidget) w;
+ Boolean always_resize_children;
+ XtGeometryResult result;
+ XtWidgetGeometry request, return_request;
+
+ /*
+ * If we are already at the desired size then there is no need
+ * to ask our parent of we can change size.
+ */
+
+ if ( (width == fw->core.width) && (height == fw->core.height) )
+ return(TRUE);
+
+ request.width = width;
+ request.height = height;
+ request.request_mode = CWWidth | CWHeight;
+ if (query_only)
+ request.request_mode |= XtCWQueryOnly;
+
+ /*
+ * Do no invoke the resize rules if our size changes here.
+ */
+
+ fw->form.resize_is_no_op = TRUE;
+
+ result = XtMakeGeometryRequest(w, &request, &return_request);
+ if (result == XtGeometryAlmost) {
+ request = return_request;
+ (void) XtMakeGeometryRequest(w, &request, &return_request);
+ always_resize_children = FALSE;
+ }
+ else
+ always_resize_children = (result == XtGeometryYes);
+
+ fw->form.resize_is_no_op = FALSE;
+
+ if (ret_width != NULL)
+ *ret_width = request.width;
+ if (ret_height != NULL)
+ *ret_height = request.height;
+
+ return(always_resize_children);
+}
+
+/* Function Name: Layout
+ * Description: Moves all the children around.
+ * Arguments: fw - the Form widget.
+ * width, height - ** UNUSED **.
+ * force_relayout - will force the children to be
+ * moved, even if some go past the edge
+ * of the form.
+ * Returns: True if the children are allowed to move from their
+ * current locations to the new ones.
+ */
+
+/* ARGSUSED */
+static Boolean Layout(fw, width, height, force_relayout)
+ FormWidget fw;
+ Dimension width, height;
+ Boolean force_relayout;
+{
+ int num_children = fw->composite.num_children;
+ WidgetList children = fw->composite.children;
+ Widget *childP;
+ Dimension maxx, maxy;
+ Boolean ret_val;
+
+ for (childP = children; childP - children < num_children; childP++) {
+ FormConstraints form = (FormConstraints)(*childP)->core.constraints;
+ form->form.layout_state = LayoutPending;
+ }
+
+ maxx = maxy = 1;
+ for (childP = children; childP - children < num_children; childP++) {
+ if (XtIsManaged(*childP)) {
+ FormConstraints form;
+ Position x, y;
+
+ form = (FormConstraints)(*childP)->core.constraints;
+
+ LayoutChild(*childP);
+
+ x = form->form.new_x + (*childP)->core.width +
+ ((*childP)->core.border_width << 1);
+ if (x > (int)maxx)
+ maxx = x;
+
+ y = form->form.new_y + (*childP)->core.height +
+ ((*childP)->core.border_width << 1);
+ if (y > (int)maxy)
+ maxy = y;
+ }
+ }
+
+ fw->form.preferred_width = (maxx += fw->form.default_spacing);
+ fw->form.preferred_height = (maxy += fw->form.default_spacing);
+
+ if (fw->form.resize_in_layout) {
+ Boolean always_resize_children;
+
+ always_resize_children =
+ ChangeFormGeometry( (Widget) fw, FALSE, maxx, maxy,
+ (Dimension *)NULL, (Dimension *)NULL);
+
+ fw->form.old_width = fw->core.width;
+ fw->form.old_height = fw->core.height;
+
+ ret_val = (always_resize_children || ( (fw->core.width >= maxx) &&
+ (fw->core.height >= maxy)));
+
+ if (force_relayout)
+ ret_val = TRUE;
+
+ if (ret_val)
+ ResizeChildren((Widget) fw);
+ }
+ else
+ ret_val = False;
+
+ fw->form.needs_relayout = False;
+ return ret_val;
+}
+
+/* Function Name: ResizeChildren
+ * Description: Resizes all children to new_x and new_y.
+ * Arguments: w - the form widget.
+ * Returns: none.
+ */
+
+static void ResizeChildren(w)
+Widget w;
+{
+ FormWidget fw = (FormWidget) w;
+ int num_children = fw->composite.num_children;
+ WidgetList children = fw->composite.children;
+ Widget *childP;
+
+ for (childP = children; childP - children < num_children; childP++) {
+ FormConstraints form;
+
+ if (!XtIsManaged(*childP))
+ continue;
+
+ form = (FormConstraints)(*childP)->core.constraints;
+ if (fw->form.no_refigure) {
+/*
+ * I am changing the widget wrapper w/o modifing the window. This is
+ * risky, but I can get away with it since I am the parent of this
+ * widget, and he must ask me for any geometry changes.
+ *
+ * The window will be updated when no_refigure is set back to False.
+ */
+ (*childP)->core.x = form->form.new_x;
+ (*childP)->core.y = form->form.new_y;
+ }
+ else
+ XtMoveWidget(*childP, form->form.new_x, form->form.new_y);
+ }
+}
+
+
+static void LayoutChild(w)
+ Widget w;
+{
+ FormConstraints form = (FormConstraints)w->core.constraints;
+ Widget ref;
+
+ switch (form->form.layout_state) {
+
+ case LayoutPending:
+ form->form.layout_state = LayoutInProgress;
+ break;
+
+ case LayoutDone:
+ return;
+
+ case LayoutInProgress:
+ {
+ String subs[2];
+ Cardinal num_subs = 2;
+ subs[0] = w->core.name;
+ subs[1] = w->core.parent->core.name;
+ XtAppWarningMsg(XtWidgetToApplicationContext(w),
+ "constraintLoop","xawFormLayout","XawToolkitError",
+ "constraint loop detected while laying out child '%s' in FormWidget '%s'",
+ subs, &num_subs);
+ return;
+ }
+ }
+
+ form->form.new_x = form->form.dx;
+ form->form.new_y = form->form.dy;
+ if ((ref = form->form.horiz_base) != (Widget)NULL) {
+ FormConstraints ref_form = (FormConstraints) ref->core.constraints;
+
+ LayoutChild(ref);
+ form->form.new_x += (ref_form->form.new_x +
+ ref->core.width + (ref->core.border_width << 1));
+ }
+ if ((ref = form->form.vert_base) != (Widget)NULL) {
+ FormConstraints ref_form = (FormConstraints) ref->core.constraints;
+
+ LayoutChild(ref);
+ form->form.new_y += (ref_form->form.new_y +
+ ref->core.height + (ref->core.border_width << 1));
+ }
+
+ form->form.layout_state = LayoutDone;
+}
+
+
+static Position TransformCoord(loc, old, new, type)
+ Position loc;
+ Dimension old, new;
+ XtEdgeType type;
+{
+ if (type == XtRubber) {
+ if ( ((int) old) > 0)
+ loc = (int)(loc * new) / (int)old;
+ }
+ else if (type == XtChainBottom || type == XtChainRight)
+ loc += (Position)new - (Position)old;
+
+ /* I don't see any problem with returning values less than zero. */
+
+ return (loc);
+}
+
+static void Resize(w)
+ Widget w;
+{
+ FormWidget fw = (FormWidget)w;
+ WidgetList children = fw->composite.children;
+ int num_children = fw->composite.num_children;
+ Widget *childP;
+ Position x, y;
+ Dimension width, height;
+
+ if (!fw->form.resize_is_no_op)
+ for (childP = children; childP - children < num_children; childP++) {
+ FormConstraints form= (FormConstraints)(*childP)->core.constraints;
+ if (!XtIsManaged(*childP)) continue;
+ x = TransformCoord( (*childP)->core.x, fw->form.old_width,
+ fw->core.width, form->form.left );
+ y = TransformCoord( (*childP)->core.y, fw->form.old_height,
+ fw->core.height, form->form.top );
+
+ form->form.virtual_width =
+ TransformCoord((Position)((*childP)->core.x
+ + form->form.virtual_width
+ + 2 * (*childP)->core.border_width),
+ fw->form.old_width, fw->core.width,
+ form->form.right )
+ - (x + 2 * (*childP)->core.border_width);
+
+ form->form.virtual_height =
+ TransformCoord((Position)((*childP)->core.y
+ + form->form.virtual_height
+ + 2 * (*childP)->core.border_width),
+ fw->form.old_height, fw->core.height,
+ form->form.bottom )
+ - ( y + 2 * (*childP)->core.border_width);
+
+ width = (Dimension)
+ (form->form.virtual_width < 1) ? 1 : form->form.virtual_width;
+ height = (Dimension)
+ (form->form.virtual_height < 1) ? 1 : form->form.virtual_height;
+
+ XtConfigureWidget(*childP,x,y, (Dimension)width, (Dimension)height,
+ (*childP)->core.border_width );
+ }
+
+ fw->form.old_width = fw->core.width;
+ fw->form.old_height = fw->core.height;
+}
+
+/*
+ * I don't want to even think about what ``Almost'' would mean - Chris.
+ */
+
+/* ARGSUSED */
+static XtGeometryResult GeometryManager(w, request, reply)
+ Widget w;
+ XtWidgetGeometry *request;
+ XtWidgetGeometry *reply; /* RETURN */
+{
+ Dimension old_width, old_height;
+ FormWidget fw = (FormWidget) XtParent(w);
+ FormConstraints form = (FormConstraints) w->core.constraints;
+ XtWidgetGeometry allowed;
+ XtGeometryResult ret_val;
+
+ if ((request->request_mode & ~(XtCWQueryOnly | CWWidth | CWHeight)) ||
+ !form->form.allow_resize) {
+
+ /* If GeometryManager is invoked during a SetValues call on a child
+ * then it is necessary to compute a new layout if ConstraintSetValues
+ * allowed any constraint changes. */
+
+ if (fw->form.needs_relayout)
+ (*((FormWidgetClass)fw->core.widget_class)->form_class.layout)
+ (fw, 0, 0, True);
+ return(XtGeometryNo);
+ }
+
+ if (request->request_mode & CWWidth)
+ allowed.width = request->width;
+ else
+ allowed.width = w->core.width;
+
+ if (request->request_mode & CWHeight)
+ allowed.height = request->height;
+ else
+ allowed.height = w->core.height;
+
+ if (allowed.width == w->core.width && allowed.height == w->core.height) {
+
+ /* If GeometryManager is invoked during a SetValues call on a child
+ * then it is necessary to compute a new layout if ConstraintSetValues
+ * allowed any constraint changes. */
+
+ if (fw->form.needs_relayout)
+ (*((FormWidgetClass)fw->core.widget_class)->form_class.layout)
+ (fw, 0, 0, True);
+ return(XtGeometryNo);
+ }
+
+ /*
+ * Remember the old size, and then set the size to the requested size.
+ */
+
+ old_width = w->core.width;
+ old_height = w->core.height;
+ w->core.width = allowed.width;
+ w->core.height = allowed.height;
+
+ if (request->request_mode & XtCWQueryOnly) {
+ Boolean always_resize_children;
+ Dimension ret_width, ret_height;
+
+ fw->form.resize_in_layout = FALSE;
+
+ (*((FormWidgetClass)fw->core.widget_class)->form_class.layout)
+ ( fw, w->core.width, w->core.height,
+ FALSE );
+
+ /*
+ * Reset the size of this child back to what it used to be.
+ */
+
+ w->core.width = old_width;
+ w->core.height = old_height;
+
+ fw->form.resize_in_layout = TRUE;
+
+ always_resize_children = ChangeFormGeometry(w, TRUE,
+ fw->form.preferred_width,
+ fw->form.preferred_height,
+ &ret_width, &ret_height);
+
+ if (always_resize_children ||
+ ((ret_width >= fw->form.preferred_width) &&
+ (ret_height >= fw->form.preferred_height)))
+ {
+ ret_val = XtGeometryYes;
+ }
+ else
+ ret_val = XtGeometryNo;
+ }
+ else {
+ if ((*((FormWidgetClass)fw->core.widget_class)->form_class.layout)
+ ( fw, w->core.width, w->core.height,
+ FALSE))
+ {
+ form->form.virtual_width = w->core.width; /* reset virtual */
+ form->form.virtual_height = w->core.height; /* width and height. */
+ if (fw->form.no_refigure) {
+/*
+ * I am changing the widget wrapper w/o modifing the window. This is
+ * risky, but I can get away with it since I am the parent of this
+ * widget, and he must ask me for any geometry changes.
+ *
+ * The window will be updated when no_refigure is set back to False.
+ */
+ form->form.deferred_resize = True;
+ ret_val = XtGeometryDone;
+ }
+ else
+ ret_val = XtGeometryYes;
+ }
+ else {
+ w->core.width = old_width;
+ w->core.height = old_height;
+ ret_val = XtGeometryNo;
+ }
+ }
+
+ return(ret_val);
+}
+
+
+/* ARGSUSED */
+static Boolean SetValues(current, request, new, args, num_args)
+ Widget current, request, new;
+ ArgList args;
+ Cardinal *num_args;
+{
+ return( FALSE );
+}
+
+
+/* ARGSUSED */
+static void ConstraintInitialize(request, new, args, num_args)
+ Widget request, new;
+ ArgList args;
+ Cardinal *num_args;
+{
+ FormConstraints form = (FormConstraints)new->core.constraints;
+ FormWidget fw = (FormWidget)new->core.parent;
+
+ form->form.virtual_width = (int) new->core.width;
+ form->form.virtual_height = (int) new->core.height;
+
+ if (form->form.dx == default_value)
+ form->form.dx = fw->form.default_spacing;
+
+ if (form->form.dy == default_value)
+ form->form.dy = fw->form.default_spacing;
+
+ form->form.deferred_resize = False;
+}
+
+/*ARGSUSED*/
+static Boolean ConstraintSetValues(current, request, new, args, num_args)
+ Widget current, request, new;
+ ArgList args;
+ Cardinal *num_args;
+{
+ FormConstraints cfc = (FormConstraints) current->core.constraints;
+ FormConstraints nfc = (FormConstraints) new->core.constraints;
+
+ if (cfc->form.top != nfc->form.top ||
+ cfc->form.bottom != nfc->form.bottom ||
+ cfc->form.left != nfc->form.left ||
+ cfc->form.right != nfc->form.right ||
+ cfc->form.dx != nfc->form.dx ||
+ cfc->form.dy != nfc->form.dy ||
+ cfc->form.horiz_base != nfc->form.horiz_base ||
+ cfc->form.vert_base != nfc->form.vert_base) {
+
+ FormWidget fp = (FormWidget) XtParent(new);
+
+ /* If there are no subclass ConstraintSetValues procedures remaining
+ * to be invoked, and if there is no geometry request about to be
+ * made, then invoke the new layout now; else defer it. */
+
+ if (XtClass(XtParent(new)) == formWidgetClass &&
+ current->core.x == new->core.x &&
+ current->core.y == new->core.y &&
+ current->core.width == new->core.width &&
+ current->core.height == new->core.height &&
+ current->core.border_width == new->core.border_width)
+ Layout(fp, 0, 0, True);
+ else fp->form.needs_relayout = True;
+ }
+ return( FALSE );
+}
+
+static void ChangeManaged(w)
+ Widget w;
+{
+ FormWidget fw = (FormWidget)w;
+ FormConstraints form;
+ WidgetList children, childP;
+ int num_children = fw->composite.num_children;
+ Widget child;
+
+ /*
+ * Reset virtual width and height for all children.
+ */
+
+ for (children = childP = fw->composite.children ;
+ childP - children < num_children; childP++) {
+ child = *childP;
+ if (XtIsManaged(child)) {
+ form = (FormConstraints)child->core.constraints;
+
+/*
+ * If the size is one (1) then we must not change the virtual sizes, as
+ * they contain useful information. If someone actually wants a widget of
+ * width or height one (1) in a form widget he will lose, can't win them all.
+ *
+ * Chris D. Peterson 2/9/89.
+ */
+
+ if ( child->core.width != 1)
+ form->form.virtual_width = (int) child->core.width;
+ if ( child->core.height != 1)
+ form->form.virtual_height = (int) child->core.height;
+ }
+ }
+ (*((FormWidgetClass)w->core.widget_class)->form_class.layout)
+ ((FormWidget) w, w->core.width,
+ w->core.height, TRUE);
+}
+
+
+static XtGeometryResult PreferredGeometry( widget, request, reply )
+ Widget widget;
+ XtWidgetGeometry *request, *reply;
+{
+ FormWidget w = (FormWidget)widget;
+
+ reply->width = w->form.preferred_width;
+ reply->height = w->form.preferred_height;
+ reply->request_mode = CWWidth | CWHeight;
+ if ( request->request_mode & (CWWidth | CWHeight) ==
+ (CWWidth | CWHeight)
+ && request->width == reply->width
+ && request->height == reply->height)
+ return XtGeometryYes;
+ else if (reply->width == w->core.width && reply->height == w->core.height)
+ return XtGeometryNo;
+ else
+ return XtGeometryAlmost;
+}
+
+
+/**********************************************************************
+ *
+ * Public routines
+ *
+ **********************************************************************/
+
+/*
+ * Set or reset figuring (ignored if not realized)
+ */
+
+void
+#if NeedFunctionPrototypes
+XawFormDoLayout(Widget w,
+#if NeedWidePrototypes
+ int doit)
+#else
+ Boolean doit)
+#endif
+#else
+XawFormDoLayout(w, doit)
+Widget w;
+Boolean doit;
+#endif
+{
+ Widget *childP;
+ FormWidget fw = (FormWidget)w;
+ int num_children = fw->composite.num_children;
+ WidgetList children = fw->composite.children;
+
+ if ( ((fw->form.no_refigure = !doit) == TRUE) || !XtIsRealized(w) )
+ return;
+
+ for (childP = children; childP - children < num_children; childP++) {
+ Widget w = *childP;
+ if (XtIsManaged(w)) {
+ FormConstraints form = (FormConstraints)w->core.constraints;
+
+ /*
+ * Xt Configure widget is too smart, and optimizes out
+ * my changes.
+ */
+
+ XMoveResizeWindow(XtDisplay(w), XtWindow(w),
+ w->core.x, w->core.y,
+ w->core.width, w->core.height);
+
+ if (form->form.deferred_resize &&
+ XtClass(w)->core_class.resize != (XtWidgetProc) NULL) {
+ (*(XtClass(w)->core_class.resize))(w);
+ form->form.deferred_resize = False;
+ }
+ }
+ }
+}
diff --git a/src/Grip.c b/src/Grip.c
new file mode 100644
index 0000000..4939d83
--- /dev/null
+++ b/src/Grip.c
@@ -0,0 +1,145 @@
+/* $Xorg: Grip.c,v 1.4 2001/02/09 02:03:43 xorgcvs Exp $ */
+
+/***********************************************************
+
+Copyright 1987, 1988, 1994, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+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
+OPEN GROUP 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 Open Group 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 Open Group.
+
+
+Copyright 1987, 1988 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+******************************************************************/
+
+/*
+ * Grip.c - Grip Widget (Used by Paned Widget)
+ *
+ */
+#include <X11/IntrinsicP.h>
+#include <X11/StringDefs.h>
+#include <X11/Xaw/XawInit.h>
+#include <X11/Xaw/GripP.h>
+
+static XtResource resources[] = {
+ {XtNwidth, XtCWidth, XtRDimension, sizeof(Dimension),
+ XtOffsetOf(GripRec, core.width), XtRImmediate,
+ (XtPointer) DEFAULT_GRIP_SIZE},
+ {XtNheight, XtCHeight, XtRDimension, sizeof(Dimension),
+ XtOffsetOf(GripRec, core.height), XtRImmediate,
+ (XtPointer) DEFAULT_GRIP_SIZE},
+ {XtNforeground, XtCForeground, XtRPixel, sizeof(Pixel),
+ XtOffsetOf(GripRec, core.background_pixel), XtRString,
+ XtDefaultForeground},
+ {XtNborderWidth, XtCBorderWidth, XtRDimension, sizeof(Dimension),
+ XtOffsetOf(GripRec, core.border_width), XtRImmediate, (XtPointer)0},
+ {XtNcallback, XtCCallback, XtRCallback, sizeof(XtPointer),
+ XtOffsetOf(GripRec, grip.grip_action), XtRCallback, NULL},
+};
+
+static void GripAction( /* Widget, XEvent*, String*, Cardinal */ );
+
+static XtActionsRec actionsList[] =
+{
+ {"GripAction", GripAction},
+};
+
+#define SuperClass (&simpleClassRec)
+
+GripClassRec gripClassRec = {
+ {
+/* core class fields */
+ /* superclass */ (WidgetClass) SuperClass,
+ /* class name */ "Grip",
+ /* size */ sizeof(GripRec),
+ /* class initialize */ XawInitializeWidgetSet,
+ /* class_part_init */ NULL,
+ /* class_inited */ FALSE,
+ /* initialize */ NULL,
+ /* initialize_hook */ NULL,
+ /* realize */ XtInheritRealize,
+ /* actions */ actionsList,
+ /* num_actions */ XtNumber(actionsList),
+ /* resources */ resources,
+ /* resource_count */ XtNumber(resources),
+ /* xrm_class */ NULLQUARK,
+ /* compress_motion */ TRUE,
+ /* compress_exposure */ TRUE,
+ /* compress_enterleave*/ TRUE,
+ /* visible_interest */ FALSE,
+ /* destroy */ NULL,
+ /* resize */ NULL,
+ /* expose */ NULL,
+ /* set_values */ NULL,
+ /* set_values_hook */ NULL,
+ /* set_values_almost */ XtInheritSetValuesAlmost,
+ /* get_values_hook */ NULL,
+ /* accept_focus */ NULL,
+ /* version */ XtVersion,
+ /* callback_private */ NULL,
+ /* tm_table */ NULL,
+ /* query_geometry */ XtInheritQueryGeometry,
+ /* display_accelerator*/ XtInheritDisplayAccelerator,
+ /* extension */ NULL
+ },
+/* Simple class fields initialization */
+ {
+ /* change_sensitive */ XtInheritChangeSensitive
+ },
+/* Grip class fields initialization */
+ {
+ /* not used */ 0
+ }
+};
+
+WidgetClass gripWidgetClass = (WidgetClass) &gripClassRec;
+
+static void GripAction( widget, event, params, num_params )
+ Widget widget;
+ XEvent *event;
+ String *params;
+ Cardinal *num_params;
+{
+ XawGripCallDataRec call_data;
+
+ call_data.event = event;
+ call_data.params = params;
+ call_data.num_params = *num_params;
+
+ XtCallCallbacks( widget, XtNcallback, (XtPointer)&call_data );
+}
diff --git a/src/Label.c b/src/Label.c
new file mode 100644
index 0000000..c43391b
--- /dev/null
+++ b/src/Label.c
@@ -0,0 +1,772 @@
+/* $Xorg: Label.c,v 1.5 2001/02/09 02:03:43 xorgcvs Exp $ */
+
+/***********************************************************
+
+Copyright 1987, 1988, 1994, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+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
+OPEN GROUP 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 Open Group 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 Open Group.
+
+
+Copyright 1987, 1988 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+******************************************************************/
+
+/*
+ * Label.c - Label widget
+ *
+ */
+
+#include <X11/IntrinsicP.h>
+#include <X11/StringDefs.h>
+#include <X11/Xos.h>
+#include <X11/Xaw/XawInit.h>
+#include <X11/Xaw/LabelP.h>
+#include <X11/Xmu/Converters.h>
+#include <X11/Xmu/Drawing.h>
+#include <stdio.h>
+#include <ctype.h>
+
+/* needed for abs() */
+#ifndef X_NOT_STDC_ENV
+#include <stdlib.h>
+#else
+int abs();
+#endif
+
+#define streq(a,b) (strcmp( (a), (b) ) == 0)
+
+#define MULTI_LINE_LABEL 32767
+
+#ifdef CRAY
+#define WORD64
+#endif
+
+/****************************************************************
+ *
+ * Full class record constant
+ *
+ ****************************************************************/
+
+/* Private Data */
+
+#define offset(field) XtOffsetOf(LabelRec, field)
+static XtResource resources[] = {
+ {XtNforeground, XtCForeground, XtRPixel, sizeof(Pixel),
+ offset(label.foreground), XtRString, XtDefaultForeground},
+ {XtNfont, XtCFont, XtRFontStruct, sizeof(XFontStruct *),
+ offset(label.font),XtRString, XtDefaultFont},
+ {XtNfontSet, XtCFontSet, XtRFontSet, sizeof(XFontSet ),
+ offset(label.fontset),XtRString, XtDefaultFontSet},
+ {XtNlabel, XtCLabel, XtRString, sizeof(String),
+ offset(label.label), XtRString, NULL},
+ {XtNencoding, XtCEncoding, XtRUnsignedChar, sizeof(unsigned char),
+ offset(label.encoding), XtRImmediate, (XtPointer)XawTextEncoding8bit},
+ {XtNjustify, XtCJustify, XtRJustify, sizeof(XtJustify),
+ offset(label.justify), XtRImmediate, (XtPointer)XtJustifyCenter},
+ {XtNinternalWidth, XtCWidth, XtRDimension, sizeof(Dimension),
+ offset(label.internal_width), XtRImmediate, (XtPointer)4},
+ {XtNinternalHeight, XtCHeight, XtRDimension, sizeof(Dimension),
+ offset(label.internal_height), XtRImmediate, (XtPointer)2},
+ {XtNleftBitmap, XtCLeftBitmap, XtRBitmap, sizeof(Pixmap),
+ offset(label.left_bitmap), XtRImmediate, (XtPointer) None},
+ {XtNbitmap, XtCPixmap, XtRBitmap, sizeof(Pixmap),
+ offset(label.pixmap), XtRImmediate, (XtPointer)None},
+ {XtNresize, XtCResize, XtRBoolean, sizeof(Boolean),
+ offset(label.resize), XtRImmediate, (XtPointer)True},
+};
+#undef offset
+
+static void Initialize();
+static void Resize();
+static void Redisplay();
+static Boolean SetValues();
+static void ClassInitialize();
+static void Destroy();
+static XtGeometryResult QueryGeometry();
+
+LabelClassRec labelClassRec = {
+ {
+/* core_class fields */
+ /* superclass */ (WidgetClass) &simpleClassRec,
+ /* class_name */ "Label",
+ /* widget_size */ sizeof(LabelRec),
+ /* class_initialize */ ClassInitialize,
+ /* class_part_initialize */ NULL,
+ /* class_inited */ FALSE,
+ /* initialize */ Initialize,
+ /* initialize_hook */ NULL,
+ /* realize */ XtInheritRealize,
+ /* actions */ NULL,
+ /* num_actions */ 0,
+ /* resources */ resources,
+ /* num_resources */ XtNumber(resources),
+ /* xrm_class */ NULLQUARK,
+ /* compress_motion */ TRUE,
+ /* compress_exposure */ TRUE,
+ /* compress_enterleave */ TRUE,
+ /* visible_interest */ FALSE,
+ /* destroy */ Destroy,
+ /* resize */ Resize,
+ /* expose */ Redisplay,
+ /* set_values */ SetValues,
+ /* set_values_hook */ NULL,
+ /* set_values_almost */ XtInheritSetValuesAlmost,
+ /* get_values_hook */ NULL,
+ /* accept_focus */ NULL,
+ /* version */ XtVersion,
+ /* callback_private */ NULL,
+ /* tm_table */ NULL,
+ /* query_geometry */ QueryGeometry,
+ /* display_accelerator */ XtInheritDisplayAccelerator,
+ /* extension */ NULL
+ },
+/* Simple class fields initialization */
+ {
+ /* change_sensitive */ XtInheritChangeSensitive
+ },
+/* Label class fields initialization */
+ {
+ /* ignore */ 0
+ }
+};
+WidgetClass labelWidgetClass = (WidgetClass)&labelClassRec;
+/****************************************************************
+ *
+ * Private Procedures
+ *
+ ****************************************************************/
+
+static void ClassInitialize()
+{
+ XawInitializeWidgetSet();
+ XtAddConverter( XtRString, XtRJustify, XmuCvtStringToJustify,
+ (XtConvertArgList)NULL, 0 );
+}
+
+#ifndef WORD64
+
+#define TXT16 XChar2b
+
+#else
+
+#define TXT16 char
+
+static XChar2b *buf2b;
+static int buf2blen = 0;
+
+_XawLabelWidth16(fs, str, n)
+ XFontStruct *fs;
+ char *str;
+ int n;
+{
+ int i;
+ XChar2b *ptr;
+
+ if (n > buf2blen) {
+ buf2b = (XChar2b *)XtRealloc((char *)buf2b, n * sizeof(XChar2b));
+ buf2blen = n;
+ }
+ for (ptr = buf2b, i = n; --i >= 0; ptr++) {
+ ptr->byte1 = *str++;
+ ptr->byte2 = *str++;
+ }
+ return XTextWidth16(fs, buf2b, n);
+}
+
+_XawLabelDraw16(dpy, d, gc, x, y, str, n)
+ Display *dpy;
+ Drawable d;
+ GC gc;
+ int x, y;
+ char *str;
+ int n;
+{
+ int i;
+ XChar2b *ptr;
+
+ if (n > buf2blen) {
+ buf2b = (XChar2b *)XtRealloc((char *)buf2b, n * sizeof(XChar2b));
+ buf2blen = n;
+ }
+ for (ptr = buf2b, i = n; --i >= 0; ptr++) {
+ ptr->byte1 = *str++;
+ ptr->byte2 = *str++;
+ }
+ XDrawString16(dpy, d, gc, x, y, buf2b, n);
+}
+
+#define XTextWidth16 _XawLabelWidth16
+#define XDrawString16 _XawLabelDraw16
+
+#endif /* WORD64 */
+
+/*
+ * Calculate width and height of displayed text in pixels
+ */
+
+static void SetTextWidthAndHeight(lw)
+ LabelWidget lw;
+{
+ XFontStruct *fs = lw->label.font;
+
+ char *nl;
+
+ if (lw->label.pixmap != None) {
+ Window root;
+ int x, y;
+ unsigned int width, height, bw, depth;
+ if (XGetGeometry(XtDisplay(lw), lw->label.pixmap, &root, &x, &y,
+ &width, &height, &bw, &depth)) {
+ lw->label.label_height = height;
+ lw->label.label_width = width;
+ lw->label.label_len = depth;
+ return;
+ }
+ }
+ if ( lw->simple.international == True ) {
+
+ XFontSet fset = lw->label.fontset;
+ XFontSetExtents *ext = XExtentsOfFontSet(fset);
+
+ lw->label.label_height = ext->max_ink_extent.height;
+ if (lw->label.label == NULL) {
+ lw->label.label_len = 0;
+ lw->label.label_width = 0;
+ }
+ else if ((nl = index(lw->label.label, '\n')) != NULL) {
+ char *label;
+ lw->label.label_len = MULTI_LINE_LABEL;
+ lw->label.label_width = 0;
+ for (label = lw->label.label; nl != NULL; nl = index(label, '\n')) {
+ int width = XmbTextEscapement(fset, label, (int)(nl - label));
+
+ if (width > (int)lw->label.label_width)
+ lw->label.label_width = width;
+ label = nl + 1;
+ if (*label)
+ lw->label.label_height +=
+ ext->max_ink_extent.height;
+ }
+ if (*label) {
+ int width = XmbTextEscapement(fset, label, strlen(label));
+
+ if (width > (int) lw->label.label_width)
+ lw->label.label_width = width;
+ }
+ } else {
+ lw->label.label_len = strlen(lw->label.label);
+ lw->label.label_width =
+ XmbTextEscapement(fset, lw->label.label, (int) lw->label.label_len);
+ }
+
+ } else {
+
+ lw->label.label_height = fs->max_bounds.ascent + fs->max_bounds.descent;
+ if (lw->label.label == NULL) {
+ lw->label.label_len = 0;
+ lw->label.label_width = 0;
+ }
+ else if ((nl = index(lw->label.label, '\n')) != NULL) {
+ char *label;
+ lw->label.label_len = MULTI_LINE_LABEL;
+ lw->label.label_width = 0;
+ for (label = lw->label.label; nl != NULL; nl = index(label, '\n')) {
+ int width;
+
+ if (lw->label.encoding)
+ width = XTextWidth16(fs, (TXT16*)label, (int)(nl - label)/2);
+ else
+ width = XTextWidth(fs, label, (int)(nl - label));
+ if (width > (int)lw->label.label_width)
+ lw->label.label_width = width;
+ label = nl + 1;
+ if (*label)
+ lw->label.label_height +=
+ fs->max_bounds.ascent + fs->max_bounds.descent;
+ }
+ if (*label) {
+ int width = XTextWidth(fs, label, strlen(label));
+
+ if (lw->label.encoding)
+ width = XTextWidth16(fs, (TXT16*)label, (int)strlen(label)/2);
+ else
+ width = XTextWidth(fs, label, strlen(label));
+ if (width > (int) lw->label.label_width)
+ lw->label.label_width = width;
+ }
+ } else {
+ lw->label.label_len = strlen(lw->label.label);
+ if (lw->label.encoding)
+ lw->label.label_width =
+ XTextWidth16(fs, (TXT16*)lw->label.label,
+ (int) lw->label.label_len/2);
+ else
+ lw->label.label_width =
+ XTextWidth(fs, lw->label.label, (int) lw->label.label_len);
+ }
+
+ }
+}
+
+static void GetnormalGC(lw)
+ LabelWidget lw;
+{
+ XGCValues values;
+
+ values.foreground = lw->label.foreground;
+ values.background = lw->core.background_pixel;
+ values.font = lw->label.font->fid;
+ values.graphics_exposures = False;
+
+ if ( lw->simple.international == True )
+ /* Since Xmb/wcDrawString eats the font, I must use XtAllocateGC. */
+ lw->label.normal_GC = XtAllocateGC(
+ (Widget)lw, 0,
+ (unsigned) GCForeground | GCBackground | GCGraphicsExposures,
+ &values, GCFont, 0 );
+ else
+ lw->label.normal_GC = XtGetGC(
+ (Widget)lw,
+ (unsigned) GCForeground | GCBackground | GCFont | GCGraphicsExposures,
+ &values);
+}
+
+static void GetgrayGC(lw)
+ LabelWidget lw;
+{
+ XGCValues values;
+
+ values.foreground = lw->label.foreground;
+ values.background = lw->core.background_pixel;
+ values.font = lw->label.font->fid;
+ values.fill_style = FillTiled;
+ values.tile = XmuCreateStippledPixmap(XtScreen((Widget)lw),
+ lw->label.foreground,
+ lw->core.background_pixel,
+ lw->core.depth);
+ values.graphics_exposures = False;
+
+ lw->label.stipple = values.tile;
+ if ( lw->simple.international == True )
+ /* Since Xmb/wcDrawString eats the font, I must use XtAllocateGC. */
+ lw->label.gray_GC = XtAllocateGC((Widget)lw, 0,
+ (unsigned) GCForeground | GCBackground |
+ GCTile | GCFillStyle |
+ GCGraphicsExposures,
+ &values, GCFont, 0);
+ else
+ lw->label.gray_GC = XtGetGC((Widget)lw,
+ (unsigned) GCForeground | GCBackground |
+ GCFont | GCTile | GCFillStyle |
+ GCGraphicsExposures,
+ &values);
+}
+
+static void compute_bitmap_offsets (lw)
+ LabelWidget lw;
+{
+ /*
+ * bitmap will be eventually be displayed at
+ * (internal_width, internal_height + lbm_y)
+ */
+ if (lw->label.lbm_height != 0) {
+ lw->label.lbm_y = (lw->core.height -
+ (lw->label.internal_height * 2 +
+ lw->label.lbm_height)) / 2;
+ } else {
+ lw->label.lbm_y = 0;
+ }
+}
+
+
+static void set_bitmap_info (lw)
+ LabelWidget lw;
+{
+ Window root;
+ int x, y;
+ unsigned int bw, depth;
+
+ if (!(lw->label.left_bitmap &&
+ XGetGeometry (XtDisplay(lw), lw->label.left_bitmap, &root, &x, &y,
+ &lw->label.lbm_width, &lw->label.lbm_height,
+ &bw, &depth))) {
+ lw->label.lbm_width = lw->label.lbm_height = 0;
+ }
+ compute_bitmap_offsets (lw);
+}
+
+
+
+/* ARGSUSED */
+static void Initialize(request, new, args, num_args)
+ Widget request, new;
+ ArgList args;
+ Cardinal *num_args;
+{
+ LabelWidget lw = (LabelWidget) new;
+
+ if (lw->label.label == NULL)
+ lw->label.label = XtNewString(lw->core.name);
+ else {
+ lw->label.label = XtNewString(lw->label.label);
+ }
+
+ GetnormalGC(lw);
+ GetgrayGC(lw);
+
+ SetTextWidthAndHeight(lw);
+
+ if (lw->core.height == 0)
+ lw->core.height = lw->label.label_height +
+ 2 * lw->label.internal_height;
+
+ set_bitmap_info (lw); /* need core.height */
+
+ if (lw->core.width == 0) /* need label.lbm_width */
+ lw->core.width = (lw->label.label_width +
+ 2 * lw->label.internal_width +
+ LEFT_OFFSET(lw));
+
+ lw->label.label_x = lw->label.label_y = 0;
+ (*XtClass(new)->core_class.resize) ((Widget)lw);
+
+} /* Initialize */
+
+/*
+ * Repaint the widget window
+ */
+
+/* ARGSUSED */
+static void Redisplay(gw, event, region)
+ Widget gw;
+ XEvent *event;
+ Region region;
+{
+ LabelWidget w = (LabelWidget) gw;
+ GC gc;
+
+ /*
+ * now we'll see if we need to draw the rest of the label
+ */
+ if (region != NULL) {
+ int x = w->label.label_x;
+ unsigned int width = w->label.label_width;
+ if (w->label.lbm_width) {
+ if (w->label.label_x > (x = w->label.internal_width))
+ width += w->label.label_x - x;
+ }
+ if (XRectInRegion(region, x, w->label.label_y,
+ width, w->label.label_height) == RectangleOut){
+ return;
+ }
+ }
+
+ gc = XtIsSensitive(gw) ? w->label.normal_GC : w->label.gray_GC;
+#ifdef notdef
+ if (region != NULL)
+ XSetRegion(XtDisplay(gw), gc, region);
+#endif /*notdef*/
+
+ if (w->label.pixmap == None) {
+ int len = w->label.label_len;
+ char *label = w->label.label;
+ Position y = w->label.label_y + w->label.font->max_bounds.ascent;
+ Position ksy = w->label.label_y;
+
+ /* display left bitmap */
+ if (w->label.left_bitmap && w->label.lbm_width != 0) {
+ XCopyPlane (XtDisplay(gw), w->label.left_bitmap, XtWindow(gw), gc,
+ 0, 0, w->label.lbm_width, w->label.lbm_height,
+ (int) w->label.internal_width,
+ (int) w->label.internal_height + w->label.lbm_y,
+ (unsigned long) 1L);
+ }
+
+ if ( w->simple.international == True ) {
+
+ XFontSetExtents *ext = XExtentsOfFontSet(w->label.fontset);
+
+ ksy += abs(ext->max_ink_extent.y);
+
+ if (len == MULTI_LINE_LABEL) {
+ char *nl;
+ while ((nl = index(label, '\n')) != NULL) {
+ XmbDrawString(XtDisplay(w), XtWindow(w), w->label.fontset, gc,
+ w->label.label_x, ksy, label, (int)(nl - label));
+ ksy += ext->max_ink_extent.height;
+ label = nl + 1;
+ }
+ len = strlen(label);
+ }
+ if (len)
+ XmbDrawString(XtDisplay(w), XtWindow(w), w->label.fontset, gc,
+ w->label.label_x, ksy, label, len);
+
+ } else { /*international false, so use R5 routine */
+
+ if (len == MULTI_LINE_LABEL) {
+ char *nl;
+ while ((nl = index(label, '\n')) != NULL) {
+ if (w->label.encoding)
+ XDrawString16(XtDisplay(gw), XtWindow(gw), gc,
+ w->label.label_x, y,
+ (TXT16*)label, (int)(nl - label)/2);
+ else
+ XDrawString(XtDisplay(gw), XtWindow(gw), gc,
+ w->label.label_x, y, label, (int)(nl - label));
+ y += w->label.font->max_bounds.ascent +
+ w->label.font->max_bounds.descent;
+ label = nl + 1;
+ }
+ len = strlen(label);
+ }
+ if (len) {
+ if (w->label.encoding)
+ XDrawString16(XtDisplay(gw), XtWindow(gw), gc,
+ w->label.label_x, y, (TXT16*)label, len/2);
+ else
+ XDrawString(XtDisplay(gw), XtWindow(gw), gc,
+ w->label.label_x, y, label, len);
+ }
+
+ } /*endif international*/
+
+ } else if (w->label.label_len == 1) { /* depth */
+ XCopyPlane(XtDisplay(gw), w->label.pixmap, XtWindow(gw), gc,
+ 0, 0, w->label.label_width, w->label.label_height,
+ w->label.label_x, w->label.label_y, 1L);
+ } else {
+ XCopyArea(XtDisplay(gw), w->label.pixmap, XtWindow(gw), gc,
+ 0, 0, w->label.label_width, w->label.label_height,
+ w->label.label_x, w->label.label_y);
+ }
+
+#ifdef notdef
+ if (region != NULL)
+ XSetClipMask(XtDisplay(gw), gc, (Pixmap)None);
+#endif /* notdef */
+}
+
+static void _Reposition(lw, width, height, dx, dy)
+ LabelWidget lw;
+ Dimension width, height;
+ Position *dx, *dy;
+{
+ Position newPos;
+ Position leftedge = lw->label.internal_width + LEFT_OFFSET(lw);
+
+ switch (lw->label.justify) {
+
+ case XtJustifyLeft :
+ newPos = leftedge;
+ break;
+
+ case XtJustifyRight :
+ newPos = width -
+ (lw->label.label_width + lw->label.internal_width);
+ break;
+
+ case XtJustifyCenter :
+ default:
+ newPos = (int)(width - lw->label.label_width) / 2;
+ break;
+ }
+ if (newPos < (Position)leftedge)
+ newPos = leftedge;
+ *dx = newPos - lw->label.label_x;
+ lw->label.label_x = newPos;
+ *dy = (newPos = (int)(height - lw->label.label_height) / 2)
+ - lw->label.label_y;
+ lw->label.label_y = newPos;
+ return;
+}
+
+static void Resize(w)
+ Widget w;
+{
+ LabelWidget lw = (LabelWidget)w;
+ Position dx, dy;
+
+ _Reposition(lw, w->core.width, w->core.height, &dx, &dy);
+ compute_bitmap_offsets (lw);
+}
+
+/*
+ * Set specified arguments into widget
+ */
+
+#define PIXMAP 0
+#define WIDTH 1
+#define HEIGHT 2
+#define NUM_CHECKS 3
+
+static Boolean SetValues(current, request, new, args, num_args)
+ Widget current, request, new;
+ ArgList args;
+ Cardinal *num_args;
+{
+ LabelWidget curlw = (LabelWidget) current;
+ LabelWidget reqlw = (LabelWidget) request;
+ LabelWidget newlw = (LabelWidget) new;
+ int i;
+ Boolean was_resized = False, redisplay = False, checks[NUM_CHECKS];
+
+ for (i = 0; i < NUM_CHECKS; i++)
+ checks[i] = FALSE;
+
+ for (i = 0; i < *num_args; i++) {
+ if (streq(XtNbitmap, args[i].name))
+ checks[PIXMAP] = TRUE;
+ if (streq(XtNwidth, args[i].name))
+ checks[WIDTH] = TRUE;
+ if (streq(XtNheight, args[i].name))
+ checks[HEIGHT] = TRUE;
+ }
+
+ if (newlw->label.label == NULL) {
+ newlw->label.label = newlw->core.name;
+ }
+
+ /*
+ * resize on bitmap change
+ */
+ if (curlw->label.left_bitmap != newlw->label.left_bitmap) {
+ was_resized = True;
+ }
+
+ if (curlw->label.encoding != newlw->label.encoding)
+ was_resized = True;
+
+ if ( (curlw->label.fontset != newlw->label.fontset) &&
+ curlw->simple.international ){
+ was_resized = True;
+ }
+ if (curlw->label.label != newlw->label.label) {
+ if (curlw->label.label != curlw->core.name)
+ XtFree( (char *)curlw->label.label );
+
+ if (newlw->label.label != newlw->core.name) {
+ newlw->label.label = XtNewString( newlw->label.label );
+ }
+ was_resized = True;
+ }
+
+ if (was_resized || (curlw->label.font != newlw->label.font) ||
+ (curlw->label.justify != newlw->label.justify) || checks[PIXMAP]) {
+
+ SetTextWidthAndHeight(newlw);
+ was_resized = True;
+ }
+
+ /* recalculate the window size if something has changed. */
+ if (newlw->label.resize && was_resized) {
+ if ((curlw->core.height == reqlw->core.height) && !checks[HEIGHT])
+ newlw->core.height = (newlw->label.label_height +
+ 2 * newlw->label.internal_height);
+
+ set_bitmap_info (newlw);
+
+ if ((curlw->core.width == reqlw->core.width) && !checks[WIDTH])
+ newlw->core.width = (newlw->label.label_width +
+ LEFT_OFFSET(newlw) +
+ 2 * newlw->label.internal_width);
+ }
+
+ if (curlw->label.foreground != newlw->label.foreground
+ || curlw->core.background_pixel != newlw->core.background_pixel
+ || curlw->label.font->fid != newlw->label.font->fid ) {
+
+ /* The Fontset is not in the GC - don't make a new GC if FS changes! */
+
+ XtReleaseGC(new, curlw->label.normal_GC);
+ XtReleaseGC(new, curlw->label.gray_GC);
+ XmuReleaseStippledPixmap( XtScreen(current), curlw->label.stipple );
+ GetnormalGC(newlw);
+ GetgrayGC(newlw);
+ redisplay = True;
+ }
+
+ if ((curlw->label.internal_width != newlw->label.internal_width)
+ || (curlw->label.internal_height != newlw->label.internal_height)
+ || was_resized) {
+ /* Resize() will be called if geometry changes succeed */
+ Position dx, dy;
+ _Reposition(newlw, curlw->core.width, curlw->core.height, &dx, &dy);
+ }
+
+ return was_resized || redisplay ||
+ XtIsSensitive(current) != XtIsSensitive(new);
+}
+
+static void Destroy(w)
+ Widget w;
+{
+ LabelWidget lw = (LabelWidget)w;
+
+ if ( lw->label.label != lw->core.name )
+ XtFree( lw->label.label );
+ XtReleaseGC( w, lw->label.normal_GC );
+ XtReleaseGC( w, lw->label.gray_GC);
+ XmuReleaseStippledPixmap( XtScreen(w), lw->label.stipple );
+}
+
+
+static XtGeometryResult QueryGeometry(w, intended, preferred)
+ Widget w;
+ XtWidgetGeometry *intended, *preferred;
+{
+ LabelWidget lw = (LabelWidget)w;
+
+ preferred->request_mode = CWWidth | CWHeight;
+ preferred->width = (lw->label.label_width +
+ 2 * lw->label.internal_width +
+ LEFT_OFFSET(lw));
+ preferred->height = lw->label.label_height +
+ 2 * lw->label.internal_height;
+ if ( ((intended->request_mode & (CWWidth | CWHeight))
+ == (CWWidth | CWHeight)) &&
+ intended->width == preferred->width &&
+ intended->height == preferred->height)
+ return XtGeometryYes;
+ else if (preferred->width == w->core.width &&
+ preferred->height == w->core.height)
+ return XtGeometryNo;
+ else
+ return XtGeometryAlmost;
+}
diff --git a/src/List.c b/src/List.c
new file mode 100644
index 0000000..9bcb44c
--- /dev/null
+++ b/src/List.c
@@ -0,0 +1,1203 @@
+/* $Xorg: List.c,v 1.4 2001/02/09 02:03:44 xorgcvs Exp $ */
+
+/*
+Copyright 1989, 1994, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+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
+OPEN GROUP 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 Open Group 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 Open Group.
+*/
+
+/*
+ * List.c - List widget
+ *
+ * This is a List widget. It allows the user to select an item in a list and
+ * notifies the application through a callback function.
+ *
+ * Created: 8/13/88
+ * By: Chris D. Peterson
+ * MIT X Consortium
+ */
+
+#include <stdio.h>
+#include <ctype.h>
+
+#include <X11/IntrinsicP.h>
+#include <X11/StringDefs.h>
+
+#include <X11/Xmu/Drawing.h>
+
+#include <X11/Xaw/XawInit.h>
+#include <X11/Xaw/ListP.h>
+
+/* These added so widget knows whether its height, width are user selected.
+I also added the freedoms member of the list widget part. */
+
+#define HeightLock 1
+#define WidthLock 2
+#define LongestLock 4
+
+#define HeightFree( w ) !(((ListWidget)(w))->list.freedoms & HeightLock )
+#define WidthFree( w ) !(((ListWidget)(w))->list.freedoms & WidthLock )
+#define LongestFree( w ) !(((ListWidget)(w))->list.freedoms & LongestLock )
+
+/*
+ * Default Translation table.
+ */
+
+static char defaultTranslations[] =
+ "<Btn1Down>: Set()\n\
+ <Btn1Up>: Notify()";
+
+/****************************************************************
+ *
+ * Full class record constant
+ *
+ ****************************************************************/
+
+/* Private Data */
+
+#define offset(field) XtOffset(ListWidget, field)
+
+static XtResource resources[] = {
+ {XtNforeground, XtCForeground, XtRPixel, sizeof(Pixel),
+ offset(list.foreground), XtRString, XtDefaultForeground},
+ {XtNcursor, XtCCursor, XtRCursor, sizeof(Cursor),
+ offset(simple.cursor), XtRString, "left_ptr"},
+ {XtNfont, XtCFont, XtRFontStruct, sizeof(XFontStruct *),
+ offset(list.font),XtRString, XtDefaultFont},
+ {XtNfontSet, XtCFontSet, XtRFontSet, sizeof(XFontSet ),
+ offset(list.fontset),XtRString, XtDefaultFontSet},
+ {XtNlist, XtCList, XtRPointer, sizeof(char **),
+ offset(list.list), XtRString, NULL},
+ {XtNdefaultColumns, XtCColumns, XtRInt, sizeof(int),
+ offset(list.default_cols), XtRImmediate, (XtPointer)2},
+ {XtNlongest, XtCLongest, XtRInt, sizeof(int),
+ offset(list.longest), XtRImmediate, (XtPointer)0},
+ {XtNnumberStrings, XtCNumberStrings, XtRInt, sizeof(int),
+ offset(list.nitems), XtRImmediate, (XtPointer)0},
+ {XtNpasteBuffer, XtCBoolean, XtRBoolean, sizeof(Boolean),
+ offset(list.paste), XtRImmediate, (XtPointer) False},
+ {XtNforceColumns, XtCColumns, XtRBoolean, sizeof(Boolean),
+ offset(list.force_cols), XtRImmediate, (XtPointer) False},
+ {XtNverticalList, XtCBoolean, XtRBoolean, sizeof(Boolean),
+ offset(list.vertical_cols), XtRImmediate, (XtPointer) False},
+ {XtNinternalWidth, XtCWidth, XtRDimension, sizeof(Dimension),
+ offset(list.internal_width), XtRImmediate, (XtPointer)2},
+ {XtNinternalHeight, XtCHeight, XtRDimension, sizeof(Dimension),
+ offset(list.internal_height), XtRImmediate, (XtPointer)2},
+ {XtNcolumnSpacing, XtCSpacing, XtRDimension, sizeof(Dimension),
+ offset(list.column_space), XtRImmediate, (XtPointer)6},
+ {XtNrowSpacing, XtCSpacing, XtRDimension, sizeof(Dimension),
+ offset(list.row_space), XtRImmediate, (XtPointer)2},
+ {XtNcallback, XtCCallback, XtRCallback, sizeof(XtPointer),
+ offset(list.callback), XtRCallback, NULL},
+};
+
+static void Initialize();
+static void ChangeSize();
+static void Resize();
+static void Redisplay();
+static void Destroy();
+static Boolean Layout();
+static XtGeometryResult PreferredGeom();
+static Boolean SetValues();
+static void Notify(), Set(), Unset();
+
+static XtActionsRec actions[] = {
+ {"Notify", Notify},
+ {"Set", Set},
+ {"Unset", Unset},
+};
+
+ListClassRec listClassRec = {
+ {
+/* core_class fields */
+ /* superclass */ (WidgetClass) &simpleClassRec,
+ /* class_name */ "List",
+ /* widget_size */ sizeof(ListRec),
+ /* class_initialize */ XawInitializeWidgetSet,
+ /* class_part_initialize */ NULL,
+ /* class_inited */ FALSE,
+ /* initialize */ Initialize,
+ /* initialize_hook */ NULL,
+ /* realize */ XtInheritRealize,
+ /* actions */ actions,
+ /* num_actions */ XtNumber(actions),
+ /* resources */ resources,
+ /* num_resources */ XtNumber(resources),
+ /* xrm_class */ NULLQUARK,
+ /* compress_motion */ TRUE,
+ /* compress_exposure */ FALSE,
+ /* compress_enterleave */ TRUE,
+ /* visible_interest */ FALSE,
+ /* destroy */ Destroy,
+ /* resize */ Resize,
+ /* expose */ Redisplay,
+ /* set_values */ SetValues,
+ /* set_values_hook */ NULL,
+ /* set_values_almost */ XtInheritSetValuesAlmost,
+ /* get_values_hook */ NULL,
+ /* accept_focus */ NULL,
+ /* version */ XtVersion,
+ /* callback_private */ NULL,
+ /* tm_table */ defaultTranslations,
+ /* query_geometry */ PreferredGeom,
+ },
+/* Simple class fields initialization */
+ {
+ /* change_sensitive */ XtInheritChangeSensitive
+ },
+/* List class fields initialization */
+ {
+ /* not used */ 0
+ },
+};
+
+WidgetClass listWidgetClass = (WidgetClass)&listClassRec;
+
+/****************************************************************
+ *
+ * Private Procedures
+ *
+ ****************************************************************/
+
+static void GetGCs(w)
+Widget w;
+{
+ XGCValues values;
+ ListWidget lw = (ListWidget) w;
+
+ values.foreground = lw->list.foreground;
+ values.font = lw->list.font->fid;
+
+ if ( lw->simple.international == True )
+ lw->list.normgc = XtAllocateGC( w, 0, (unsigned) GCForeground,
+ &values, GCFont, 0 );
+ else
+ lw->list.normgc = XtGetGC( w, (unsigned) GCForeground | GCFont,
+ &values);
+
+ values.foreground = lw->core.background_pixel;
+
+ if ( lw->simple.international == True )
+ lw->list.revgc = XtAllocateGC( w, 0, (unsigned) GCForeground,
+ &values, GCFont, 0 );
+ else
+ lw->list.revgc = XtGetGC( w, (unsigned) GCForeground | GCFont,
+ &values);
+
+ values.tile = XmuCreateStippledPixmap(XtScreen(w),
+ lw->list.foreground,
+ lw->core.background_pixel,
+ lw->core.depth);
+ values.fill_style = FillTiled;
+
+ if ( lw->simple.international == True )
+ lw->list.graygc = XtAllocateGC( w, 0, (unsigned) GCTile | GCFillStyle,
+ &values, GCFont, 0 );
+ else
+ lw->list.graygc = XtGetGC( w, (unsigned) GCFont | GCTile | GCFillStyle,
+ &values);
+}
+
+
+/* CalculatedValues()
+ *
+ * does routine checks/computations that must be done after data changes
+ * but won't hurt if accidently called
+ *
+ * These calculations were needed in SetValues. They were in ResetList.
+ * ResetList called ChangeSize, which made an XtGeometryRequest. You
+ * MAY NOT change your geometry from within a SetValues. (Xt man,
+ * sect. 9.7.2) So, I factored these changes out. */
+
+static void CalculatedValues( w )
+Widget w;
+{
+ int i, len;
+
+ ListWidget lw = (ListWidget) w;
+
+ /* If list is NULL then the list will just be the name of the widget. */
+
+ if (lw->list.list == NULL) {
+ lw->list.list = &(lw->core.name);
+ lw->list.nitems = 1;
+ }
+
+ /* Get number of items. */
+
+ if (lw->list.nitems == 0)
+ for ( ; lw->list.list[lw->list.nitems] != NULL ; lw->list.nitems++);
+
+ /* Get column width. */
+
+ if ( LongestFree( lw ) ) {
+
+ lw->list.longest = 0; /* so it will accumulate real longest below */
+
+ for ( i = 0 ; i < lw->list.nitems; i++) {
+ if ( lw->simple.international == True )
+ len = XmbTextEscapement(lw->list.fontset, lw->list.list[i],
+ strlen(lw->list.list[i]));
+ else
+ len = XTextWidth(lw->list.font, lw->list.list[i],
+ strlen(lw->list.list[i]));
+ if (len > lw->list.longest)
+ lw->list.longest = len;
+ }
+ }
+
+ lw->list.col_width = lw->list.longest + lw->list.column_space;
+}
+
+/* Function Name: ResetList
+ * Description: Resets the new list when important things change.
+ * Arguments: w - the widget.
+ * changex, changey - allow the height or width to change?
+ *
+ * Returns: TRUE if width or height have been changed
+ */
+
+static void
+ResetList( w, changex, changey )
+Widget w;
+Boolean changex, changey;
+{
+ Dimension width = w->core.width;
+ Dimension height = w->core.height;
+
+ CalculatedValues( w );
+
+ if( Layout( w, changex, changey, &width, &height ) )
+ ChangeSize( w, width, height );
+}
+
+/* Function Name: ChangeSize.
+ * Description: Laysout the widget.
+ * Arguments: w - the widget to try change the size of.
+ * Returns: none.
+ */
+
+static void
+ChangeSize(w, width, height)
+Widget w;
+Dimension width, height;
+{
+ XtWidgetGeometry request, reply;
+
+ request.request_mode = CWWidth | CWHeight;
+ request.width = width;
+ request.height = height;
+
+ switch ( XtMakeGeometryRequest(w, &request, &reply) ) {
+ case XtGeometryYes:
+ break;
+ case XtGeometryNo:
+ break;
+ case XtGeometryAlmost:
+ Layout(w, (request.height != reply.height),
+ (request.width != reply.width),
+ &(reply.width), &(reply.height));
+ request = reply;
+ switch (XtMakeGeometryRequest(w, &request, &reply) ) {
+ case XtGeometryYes:
+ case XtGeometryNo:
+ break;
+ case XtGeometryAlmost:
+ request = reply;
+ Layout(w, FALSE, FALSE, &(request.width), &(request.height));
+ request.request_mode = CWWidth | CWHeight;
+ XtMakeGeometryRequest(w, &request, &reply);
+ break;
+ default:
+ XtAppWarning(XtWidgetToApplicationContext(w),
+ "List Widget: Unknown geometry return.");
+ break;
+ }
+ break;
+ default:
+ XtAppWarning(XtWidgetToApplicationContext(w),
+ "List Widget: Unknown geometry return.");
+ break;
+ }
+}
+
+/* Function Name: Initialize
+ * Description: Function that initilizes the widget instance.
+ * Arguments: junk - NOT USED.
+ * new - the new widget.
+ * Returns: none
+ */
+
+/* ARGSUSED */
+static void
+Initialize(junk, new, args, num_args)
+Widget junk, new;
+ArgList args;
+Cardinal *num_args;
+{
+ ListWidget lw = (ListWidget) new;
+
+/*
+ * Initialize all private resources.
+ */
+
+ /* record for posterity if we are free */
+ lw->list.freedoms = (lw->core.width != 0) * WidthLock +
+ (lw->core.height != 0) * HeightLock +
+ (lw->list.longest != 0) * LongestLock;
+
+ GetGCs(new);
+
+ /* Set row height. based on font or fontset */
+
+ if (lw->simple.international == True )
+ lw->list.row_height =
+ XExtentsOfFontSet(lw->list.fontset)->max_ink_extent.height
+ + lw->list.row_space;
+ else
+ lw->list.row_height = lw->list.font->max_bounds.ascent
+ + lw->list.font->max_bounds.descent
+ + lw->list.row_space;
+
+ ResetList( new, WidthFree( lw ), HeightFree( lw ) );
+
+ lw->list.highlight = lw->list.is_highlighted = NO_HIGHLIGHT;
+
+} /* Initialize */
+
+/* Function Name: CvtToItem
+ * Description: Converts Xcoord to item number of item containing that
+ * point.
+ * Arguments: w - the list widget.
+ * xloc, yloc - x location, and y location.
+ * Returns: the item number.
+ */
+
+static int
+CvtToItem(w, xloc, yloc, item)
+Widget w;
+int xloc, yloc;
+int *item;
+{
+ int one, another;
+ ListWidget lw = (ListWidget) w;
+ int ret_val = OKAY;
+
+ if (lw->list.vertical_cols) {
+ one = lw->list.nrows * ((xloc - (int) lw->list.internal_width)
+ / lw->list.col_width);
+ another = (yloc - (int) lw->list.internal_height)
+ / lw->list.row_height;
+ /* If out of range, return minimum possible value. */
+ if (another >= lw->list.nrows) {
+ another = lw->list.nrows - 1;
+ ret_val = OUT_OF_RANGE;
+ }
+ }
+ else {
+ one = (lw->list.ncols * ((yloc - (int) lw->list.internal_height)
+ / lw->list.row_height)) ;
+ /* If in right margin handle things right. */
+ another = (xloc - (int) lw->list.internal_width) / lw->list.col_width;
+ if (another >= lw->list.ncols) {
+ another = lw->list.ncols - 1;
+ ret_val = OUT_OF_RANGE;
+ }
+ }
+ if ((xloc < 0) || (yloc < 0))
+ ret_val = OUT_OF_RANGE;
+ if (one < 0) one = 0;
+ if (another < 0) another = 0;
+ *item = one + another;
+ if (*item >= lw->list.nitems) return(OUT_OF_RANGE);
+ return(ret_val);
+}
+
+/* Function Name: FindCornerItems.
+ * Description: Find the corners of the rectangle in item space.
+ * Arguments: w - the list widget.
+ * event - the event structure that has the rectangle it it.
+ * ul_ret, lr_ret - the corners ** RETURNED **.
+ * Returns: none.
+ */
+
+static void
+FindCornerItems(w, event, ul_ret, lr_ret)
+Widget w;
+XEvent * event;
+int *ul_ret, *lr_ret;
+{
+ int xloc, yloc;
+
+ xloc = event->xexpose.x;
+ yloc = event->xexpose.y;
+ CvtToItem(w, xloc, yloc, ul_ret);
+ xloc += event->xexpose.width;
+ yloc += event->xexpose.height;
+ CvtToItem(w, xloc, yloc, lr_ret);
+}
+
+/* Function Name: ItemInRectangle
+ * Description: returns TRUE if the item passed is in the given rectangle.
+ * Arguments: w - the list widget.
+ * ul, lr - corners of the rectangle in item space.
+ * item - item to check.
+ * Returns: TRUE if the item passed is in the given rectangle.
+ */
+
+static Boolean
+ItemInRectangle(w, ul, lr, item)
+Widget w;
+int ul, lr, item;
+{
+ ListWidget lw = (ListWidget) w;
+ int mod_item;
+ int things;
+
+ if (item < ul || item > lr)
+ return(FALSE);
+ if (lw->list.vertical_cols)
+ things = lw->list.nrows;
+ else
+ things = lw->list.ncols;
+
+ mod_item = item % things;
+ if ( (mod_item >= ul % things) && (mod_item <= lr % things ) )
+ return(TRUE);
+ return(FALSE);
+}
+
+
+/* HighlightBackground()
+ *
+ * Paints the color of the background for the given item. It performs
+ * clipping to the interior of internal_width/height by hand, as its a
+ * simple calculation and probably much faster than using Xlib and a clip mask.
+ *
+ * x, y - ul corner of the area item occupies.
+ * gc - the gc to use to paint this rectangle */
+
+static void
+HighlightBackground( w, x, y, gc )
+Widget w;
+int x, y;
+GC gc;
+{
+ ListWidget lw = (ListWidget) w;
+
+ /* easy to clip the rectangle by hand and probably alot faster than Xlib */
+
+ Dimension width = lw->list.col_width;
+ Dimension height = lw->list.row_height;
+ Dimension frame_limited_width = w->core.width - lw->list.internal_width - x;
+ Dimension frame_limited_height= w->core.height- lw->list.internal_height- y;
+
+ /* Clip the rectangle width and height to the edge of the drawable area */
+
+ if ( width > frame_limited_width )
+ width = frame_limited_width;
+ if ( height> frame_limited_height)
+ height = frame_limited_height;
+
+ /* Clip the rectangle x and y to the edge of the drawable area */
+
+ if ( x < lw->list.internal_width ) {
+ width = width - ( lw->list.internal_width - x );
+ x = lw->list.internal_width;
+ }
+ if ( y < lw->list.internal_height) {
+ height = height - ( lw->list.internal_height - x );
+ y = lw->list.internal_height;
+ }
+ XFillRectangle( XtDisplay( w ), XtWindow( w ), gc, x, y,
+ width, height );
+}
+
+
+/* ClipToShadowInteriorAndLongest()
+ *
+ * Converts the passed gc so that any drawing done with that GC will not
+ * write in the empty margin (specified by internal_width/height) (which also
+ * prevents erasing the shadow. It also clips against the value longest.
+ * If the user doesn't set longest, this has no effect (as longest is the
+ * maximum of all item lengths). If the user does specify, say, 80 pixel
+ * columns, though, this prevents items from overwriting other items. */
+
+static void ClipToShadowInteriorAndLongest(lw, gc_p, x)
+ ListWidget lw;
+ GC* gc_p;
+ Dimension x;
+{
+ XRectangle rect;
+
+ rect.x = x;
+ rect.y = lw->list.internal_height;
+ rect.height = lw->core.height - lw->list.internal_height * 2;
+ rect.width = lw->core.width - lw->list.internal_width - x;
+ if ( rect.width > lw->list.longest )
+ rect.width = lw->list.longest;
+
+ XSetClipRectangles( XtDisplay((Widget)lw),*gc_p,0,0,&rect,1,YXBanded );
+}
+
+
+/* PaintItemName()
+ *
+ * paints the name of the item in the appropriate location.
+ * w - the list widget.
+ * item - the item to draw.
+ *
+ * NOTE: no action taken on an unrealized widget. */
+
+static void
+PaintItemName(w, item)
+Widget w;
+int item;
+{
+ char * str;
+ GC gc;
+ int x, y, str_y;
+ ListWidget lw = (ListWidget) w;
+ XFontSetExtents *ext = XExtentsOfFontSet(lw->list.fontset);
+
+ if (!XtIsRealized(w)) return; /* Just in case... */
+
+ if (lw->list.vertical_cols) {
+ x = lw->list.col_width * (item / lw->list.nrows)
+ + lw->list.internal_width;
+ y = lw->list.row_height * (item % lw->list.nrows)
+ + lw->list.internal_height;
+ }
+ else {
+ x = lw->list.col_width * (item % lw->list.ncols)
+ + lw->list.internal_width;
+ y = lw->list.row_height * (item / lw->list.ncols)
+ + lw->list.internal_height;
+ }
+
+ if ( lw->simple.international == True )
+ str_y = y + abs(ext->max_ink_extent.y);
+ else
+ str_y = y + lw->list.font->max_bounds.ascent;
+
+ if (item == lw->list.is_highlighted) {
+ if (item == lw->list.highlight) {
+ gc = lw->list.revgc;
+ HighlightBackground(w, x, y, lw->list.normgc);
+ }
+ else {
+ if (XtIsSensitive(w))
+ gc = lw->list.normgc;
+ else
+ gc = lw->list.graygc;
+ HighlightBackground(w, x, y, lw->list.revgc);
+ lw->list.is_highlighted = NO_HIGHLIGHT;
+ }
+ }
+ else {
+ if (item == lw->list.highlight) {
+ gc = lw->list.revgc;
+ HighlightBackground(w, x, y, lw->list.normgc);
+ lw->list.is_highlighted = item;
+ }
+ else {
+ if (XtIsSensitive(w))
+ gc = lw->list.normgc;
+ else
+ gc = lw->list.graygc;
+ }
+ }
+
+ /* List's overall width contains the same number of inter-column
+ column_space's as columns. There should thus be a half
+ column_width margin on each side of each column.
+ The row case is symmetric. */
+
+ x += lw->list.column_space / 2;
+ str_y += lw->list.row_space / 2;
+
+ str = lw->list.list[item]; /* draw it */
+
+ ClipToShadowInteriorAndLongest( lw, &gc, x );
+
+ if ( lw->simple.international == True )
+ XmbDrawString( XtDisplay( w ), XtWindow( w ), lw->list.fontset,
+ gc, x, str_y, str, strlen( str ) );
+ else
+ XDrawString( XtDisplay( w ), XtWindow( w ),
+ gc, x, str_y, str, strlen( str ) );
+
+ XSetClipMask( XtDisplay( w ), gc, None );
+}
+
+
+/* Redisplay()
+ *
+ * Repaints the widget window on expose events.
+ * w - the list widget.
+ * event - the expose event for this repaint.
+ * junk - not used, unless three-d patch enabled. */
+
+/* ARGSUSED */
+static void
+Redisplay(w, event, junk)
+Widget w;
+XEvent *event;
+Region junk;
+{
+ int item; /* an item to work with. */
+ int ul_item, lr_item; /* corners of items we need to paint. */
+ ListWidget lw = (ListWidget) w;
+
+ if (event == NULL) { /* repaint all. */
+ ul_item = 0;
+ lr_item = lw->list.nrows * lw->list.ncols - 1;
+ XClearWindow(XtDisplay(w), XtWindow(w));
+ }
+ else
+ FindCornerItems(w, event, &ul_item, &lr_item);
+
+ for (item = ul_item; (item <= lr_item && item < lw->list.nitems) ; item++)
+ if (ItemInRectangle(w, ul_item, lr_item, item))
+ PaintItemName(w, item);
+}
+
+
+/* PreferredGeom()
+ *
+ * This tells the parent what size we would like to be
+ * given certain constraints.
+ * w - the widget.
+ * intended - what the parent intends to do with us.
+ * requested - what we want to happen. */
+
+static XtGeometryResult
+PreferredGeom(w, intended, requested)
+Widget w;
+XtWidgetGeometry *intended, *requested;
+{
+ Dimension new_width, new_height;
+ Boolean change, width_req, height_req;
+
+ width_req = intended->request_mode & CWWidth;
+ height_req = intended->request_mode & CWHeight;
+
+ if (width_req)
+ new_width = intended->width;
+ else
+ new_width = w->core.width;
+
+ if (height_req)
+ new_height = intended->height;
+ else
+ new_height = w->core.height;
+
+ requested->request_mode = 0;
+
+/*
+ * We only care about our height and width.
+ */
+
+ if ( !width_req && !height_req)
+ return(XtGeometryYes);
+
+ change = Layout(w, !width_req, !height_req, &new_width, &new_height);
+
+ requested->request_mode |= CWWidth;
+ requested->width = new_width;
+ requested->request_mode |= CWHeight;
+ requested->height = new_height;
+
+ if (change)
+ return(XtGeometryAlmost);
+ return(XtGeometryYes);
+}
+
+
+/* Resize()
+ *
+ * resizes the widget, by changing the number of rows and columns. */
+
+static void
+Resize(w)
+ Widget w;
+{
+ Dimension width, height;
+
+ width = w->core.width;
+ height = w->core.height;
+
+ if (Layout(w, FALSE, FALSE, &width, &height))
+ XtAppWarning(XtWidgetToApplicationContext(w),
+ "List Widget: Size changed when it shouldn't have when resising.");
+}
+
+
+/* Layout()
+ *
+ * lays out the item in the list.
+ * w - the widget.
+ * xfree, yfree - TRUE if we are free to resize the widget in
+ * this direction.
+ * width, height- the is the current width and height that we are going
+ * we are going to layout the list widget to,
+ * depending on xfree and yfree of course.
+ *
+ * RETURNS: TRUE if width or height have been changed. */
+
+static Boolean
+Layout(w, xfree, yfree, width, height)
+Widget w;
+Boolean xfree, yfree;
+Dimension *width, *height;
+{
+ ListWidget lw = (ListWidget) w;
+ Boolean change = FALSE;
+
+/*
+ * If force columns is set then always use number of columns specified
+ * by default_cols.
+ */
+
+ if (lw->list.force_cols) {
+ lw->list.ncols = lw->list.default_cols;
+ if (lw->list.ncols <= 0) lw->list.ncols = 1;
+ /* 12/3 = 4 and 10/3 = 4, but 9/3 = 3 */
+ lw->list.nrows = ( ( lw->list.nitems - 1) / lw->list.ncols) + 1 ;
+ if (xfree) { /* If allowed resize width. */
+
+ /* this counts the same number
+ of inter-column column_space 's as columns. There should thus be a
+ half column_space margin on each side of each column...*/
+
+ *width = lw->list.ncols * lw->list.col_width
+ + 2 * lw->list.internal_width;
+ change = TRUE;
+ }
+ if (yfree) { /* If allowed resize height. */
+ *height = (lw->list.nrows * lw->list.row_height)
+ + 2 * lw->list.internal_height;
+ change = TRUE;
+ }
+ return(change);
+ }
+
+/*
+ * If both width and height are free to change the use default_cols
+ * to determine the number columns and set new width and height to
+ * just fit the window.
+ */
+
+ if (xfree && yfree) {
+ lw->list.ncols = lw->list.default_cols;
+ if (lw->list.ncols <= 0) lw->list.ncols = 1;
+ lw->list.nrows = ( ( lw->list.nitems - 1) / lw->list.ncols) + 1 ;
+ *width = lw->list.ncols * lw->list.col_width
+ + 2 * lw->list.internal_width;
+ *height = (lw->list.nrows * lw->list.row_height)
+ + 2 * lw->list.internal_height;
+ change = TRUE;
+ }
+/*
+ * If the width is fixed then use it to determine the number of columns.
+ * If the height is free to move (width still fixed) then resize the height
+ * of the widget to fit the current list exactly.
+ */
+ else if (!xfree) {
+ lw->list.ncols = ( (int)(*width - 2 * lw->list.internal_width)
+ / (int)lw->list.col_width);
+ if (lw->list.ncols <= 0) lw->list.ncols = 1;
+ lw->list.nrows = ( ( lw->list.nitems - 1) / lw->list.ncols) + 1 ;
+ if ( yfree ) {
+ *height = (lw->list.nrows * lw->list.row_height)
+ + 2 * lw->list.internal_height;
+ change = TRUE;
+ }
+ }
+/*
+ * The last case is xfree and !yfree we use the height to determine
+ * the number of rows and then set the width to just fit the resulting
+ * number of columns.
+ */
+ else if (!yfree) { /* xfree must be TRUE. */
+ lw->list.nrows = (int)(*height - 2 * lw->list.internal_height)
+ / (int)lw->list.row_height;
+ if (lw->list.nrows <= 0) lw->list.nrows = 1;
+ lw->list.ncols = (( lw->list.nitems - 1 ) / lw->list.nrows) + 1;
+ *width = lw->list.ncols * lw->list.col_width
+ + 2 * lw->list.internal_width;
+ change = TRUE;
+ }
+ return(change);
+}
+
+
+/* Notify() - ACTION
+ *
+ * Notifies the user that a button has been pressed, and
+ * calls the callback; if the XtNpasteBuffer resource is true
+ * then the name of the item is also put in CUT_BUFFER0. */
+
+/* ARGSUSED */
+static void
+Notify(w, event, params, num_params)
+Widget w;
+XEvent * event;
+String * params;
+Cardinal *num_params;
+{
+ ListWidget lw = ( ListWidget ) w;
+ int item, item_len;
+ XawListReturnStruct ret_value;
+
+/*
+ * Find item and if out of range then unhighlight and return.
+ *
+ * If the current item is unhighlighted then the user has aborted the
+ * notify, so unhighlight and return.
+ */
+
+ if ( ((CvtToItem(w, event->xbutton.x, event->xbutton.y, &item))
+ == OUT_OF_RANGE) || (lw->list.highlight != item) ) {
+ XawListUnhighlight(w);
+ return;
+ }
+
+ item_len = strlen(lw->list.list[item]);
+
+ if ( lw->list.paste ) /* if XtNpasteBuffer set then paste it. */
+ XStoreBytes(XtDisplay(w), lw->list.list[item], item_len);
+
+/*
+ * Call Callback function.
+ */
+
+ ret_value.string = lw->list.list[item];
+ ret_value.list_index = item;
+
+ XtCallCallbacks( w, XtNcallback, (XtPointer) &ret_value);
+}
+
+
+/* Unset() - ACTION
+ *
+ * unhighlights the current element. */
+
+/* ARGSUSED */
+static void
+Unset(w, event, params, num_params)
+Widget w;
+XEvent * event;
+String * params;
+Cardinal *num_params;
+{
+ XawListUnhighlight(w);
+}
+
+
+/* Set() - ACTION
+ *
+ * Highlights the current element. */
+
+/* ARGSUSED */
+static void
+Set(w, event, params, num_params)
+Widget w;
+XEvent * event;
+String * params;
+Cardinal *num_params;
+{
+ int item;
+ ListWidget lw = (ListWidget) w;
+
+ if ( (CvtToItem(w, event->xbutton.x, event->xbutton.y, &item))
+ == OUT_OF_RANGE)
+ XawListUnhighlight(w); /* Unhighlight current item. */
+ else if ( lw->list.is_highlighted != item ) /* If this item is not */
+ XawListHighlight(w, item); /* highlighted then do it. */
+}
+
+/*
+ * Set specified arguments into widget
+ */
+
+static Boolean
+SetValues(current, request, new, args, num_args)
+Widget current, request, new;
+ArgList args;
+Cardinal *num_args;
+{
+ ListWidget cl = (ListWidget) current;
+ ListWidget rl = (ListWidget) request;
+ ListWidget nl = (ListWidget) new;
+ Boolean redraw = FALSE;
+ XFontSetExtents *ext = XExtentsOfFontSet(nl->list.fontset);
+
+ /* If the request height/width is different, lock it. Unless its 0. If */
+ /* neither new nor 0, leave it as it was. Not in R5. */
+ if ( nl->core.width != cl->core.width )
+ nl->list.freedoms |= WidthLock;
+ if ( nl->core.width == 0 )
+ nl->list.freedoms &= ~WidthLock;
+
+ if ( nl->core.height != cl->core.height )
+ nl->list.freedoms |= HeightLock;
+ if ( nl->core.height == 0 )
+ nl->list.freedoms &= ~HeightLock;
+
+ if ( nl->list.longest != cl->list.longest )
+ nl->list.freedoms |= LongestLock;
+ if ( nl->list.longest == 0 )
+ nl->list.freedoms &= ~LongestLock;
+
+ /* _DONT_ check for fontset here - it's not in GC.*/
+
+ if ( (cl->list.foreground != nl->list.foreground) ||
+ (cl->core.background_pixel != nl->core.background_pixel) ||
+ (cl->list.font != nl->list.font) ) {
+ XGCValues values;
+ XGetGCValues(XtDisplay(current), cl->list.graygc, GCTile, &values);
+ XmuReleaseStippledPixmap(XtScreen(current), values.tile);
+ XtReleaseGC(current, cl->list.graygc);
+ XtReleaseGC(current, cl->list.revgc);
+ XtReleaseGC(current, cl->list.normgc);
+ GetGCs(new);
+ redraw = TRUE;
+ }
+
+ if ( ( cl->list.font != nl->list.font ) &&
+ ( cl->simple.international == False ) )
+ nl->list.row_height = nl->list.font->max_bounds.ascent
+ + nl->list.font->max_bounds.descent
+ + nl->list.row_space;
+
+ else if ( ( cl->list.fontset != nl->list.fontset ) &&
+ ( cl->simple.international == True ) )
+ nl->list.row_height = ext->max_ink_extent.height + nl->list.row_space;
+
+ /* ...If the above two font(set) change checkers above both failed, check
+ if row_space was altered. If one of the above passed, row_height will
+ already have been re-calculated. */
+
+ else if ( cl->list.row_space != nl->list.row_space ) {
+
+ if (cl->simple.international == True )
+ nl->list.row_height = ext->max_ink_extent.height + nl->list.row_space;
+ else
+ nl->list.row_height = nl->list.font->max_bounds.ascent
+ + nl->list.font->max_bounds.descent
+ + nl->list.row_space;
+ }
+
+ if ((cl->core.width != nl->core.width) ||
+ (cl->core.height != nl->core.height) ||
+ (cl->list.internal_width != nl->list.internal_width) ||
+ (cl->list.internal_height != nl->list.internal_height) ||
+ (cl->list.column_space != nl->list.column_space) ||
+ (cl->list.row_space != nl->list.row_space) ||
+ (cl->list.default_cols != nl->list.default_cols) ||
+ ( (cl->list.force_cols != nl->list.force_cols) &&
+ (rl->list.force_cols != nl->list.ncols) ) ||
+ (cl->list.vertical_cols != nl->list.vertical_cols) ||
+ (cl->list.longest != nl->list.longest) ||
+ (cl->list.nitems != nl->list.nitems) ||
+ (cl->list.font != nl->list.font) ||
+ /* Equiv. fontsets might have different values, but the same fonts, so the
+ next comparison is sloppy but not dangerous. */
+ (cl->list.fontset != nl->list.fontset) ||
+ (cl->list.list != nl->list.list) ) {
+
+ CalculatedValues( new );
+ Layout( new, WidthFree( nl ), HeightFree( nl ),
+ &nl->core.width, &nl->core.height );
+ redraw = TRUE;
+ }
+
+ if (cl->list.list != nl->list.list)
+ nl->list.is_highlighted = nl->list.highlight = NO_HIGHLIGHT;
+
+ if ((cl->core.sensitive != nl->core.sensitive) ||
+ (cl->core.ancestor_sensitive != nl->core.ancestor_sensitive)) {
+ nl->list.highlight = NO_HIGHLIGHT;
+ redraw = TRUE;
+ }
+
+ if (!XtIsRealized(current))
+ return(FALSE);
+
+ return(redraw);
+}
+
+static void Destroy(w)
+ Widget w;
+{
+ ListWidget lw = (ListWidget) w;
+ XGCValues values;
+
+ XGetGCValues(XtDisplay(w), lw->list.graygc, GCTile, &values);
+ XmuReleaseStippledPixmap(XtScreen(w), values.tile);
+ XtReleaseGC(w, lw->list.graygc);
+ XtReleaseGC(w, lw->list.revgc);
+ XtReleaseGC(w, lw->list.normgc);
+}
+
+/* Exported Functions */
+
+/* Function Name: XawListChange.
+ * Description: Changes the list being used and shown.
+ * Arguments: w - the list widget.
+ * list - the new list.
+ * nitems - the number of items in the list.
+ * longest - the length (in Pixels) of the longest element
+ * in the list.
+ * resize - if TRUE the the list widget will
+ * try to resize itself.
+ * Returns: none.
+ * NOTE: If nitems of longest are <= 0 then they will be calculated.
+ * If nitems is <= 0 then the list needs to be NULL terminated.
+ */
+
+void
+#if NeedFunctionPrototypes
+XawListChange(Widget w, char ** list, int nitems, int longest,
+#if NeedWidePrototypes
+ int resize_it)
+#else
+ Boolean resize_it)
+#endif
+#else
+XawListChange(w, list, nitems, longest, resize_it)
+Widget w;
+char ** list;
+int nitems, longest;
+Boolean resize_it;
+#endif
+{
+ ListWidget lw = (ListWidget) w;
+ Dimension new_width = w->core.width;
+ Dimension new_height = w->core.height;
+
+ lw->list.list = list;
+
+ if ( nitems <= 0 ) nitems = 0;
+ lw->list.nitems = nitems;
+ if ( longest <= 0 ) longest = 0;
+
+ /* If the user passes 0 meaning "calculate it", it must be free */
+ if ( longest != 0 )
+ lw->list.freedoms |= LongestLock;
+ else /* the user's word is god. */
+ lw->list.freedoms &= ~LongestLock;
+
+ if ( resize_it )
+ lw->list.freedoms &= ~WidthLock & ~HeightLock;
+ /* else - still resize if its not locked */
+
+ lw->list.longest = longest;
+
+ CalculatedValues( w );
+
+ if( Layout( w, WidthFree( w ), HeightFree( w ),
+ &new_width, &new_height ) )
+ ChangeSize( w, new_width, new_height );
+
+ lw->list.is_highlighted = lw->list.highlight = NO_HIGHLIGHT;
+ if ( XtIsRealized( w ) )
+ Redisplay( w, (XEvent *)NULL, (Region)NULL );
+}
+
+/* Function Name: XawListUnhighlight
+ * Description: unlights the current highlighted element.
+ * Arguments: w - the widget.
+ * Returns: none.
+ */
+
+void
+#if NeedFunctionPrototypes
+XawListUnhighlight(Widget w)
+#else
+XawListUnhighlight(w)
+Widget w;
+#endif
+{
+ ListWidget lw = ( ListWidget ) w;
+
+ lw->list.highlight = NO_HIGHLIGHT;
+ if (lw->list.is_highlighted != NO_HIGHLIGHT)
+ PaintItemName(w, lw->list.is_highlighted); /* unhighlight this one. */
+}
+
+/* Function Name: XawListHighlight
+ * Description: Highlights the given item.
+ * Arguments: w - the list widget.
+ * item - the item to hightlight.
+ * Returns: none.
+ */
+
+void
+#if NeedFunctionPrototypes
+XawListHighlight(Widget w, int item)
+#else
+XawListHighlight(w, item)
+Widget w;
+int item;
+#endif
+{
+ ListWidget lw = ( ListWidget ) w;
+
+ if (XtIsSensitive(w)) {
+ lw->list.highlight = item;
+ if (lw->list.is_highlighted != NO_HIGHLIGHT)
+ PaintItemName(w, lw->list.is_highlighted); /* Unhighlight. */
+ PaintItemName(w, item); /* HIGHLIGHT this one. */
+ }
+}
+
+/* Function Name: XawListShowCurrent
+ * Description: returns the currently highlighted object.
+ * Arguments: w - the list widget.
+ * Returns: the info about the currently highlighted object.
+ */
+
+XawListReturnStruct *
+#if NeedFunctionPrototypes
+XawListShowCurrent(Widget w)
+#else
+XawListShowCurrent(w)
+Widget w;
+#endif
+{
+ ListWidget lw = ( ListWidget ) w;
+ XawListReturnStruct * ret_val;
+
+ ret_val = (XawListReturnStruct *)
+ XtMalloc (sizeof (XawListReturnStruct));/* SPARE MALLOC OK */
+
+ ret_val->list_index = lw->list.highlight;
+ if (ret_val->list_index == XAW_LIST_NONE)
+ ret_val->string = "";
+ else
+ ret_val->string = lw->list.list[ ret_val->list_index ];
+
+ return(ret_val);
+}
+
diff --git a/src/MenuButton.c b/src/MenuButton.c
new file mode 100644
index 0000000..4483009
--- /dev/null
+++ b/src/MenuButton.c
@@ -0,0 +1,229 @@
+/* $Xorg: MenuButton.c,v 1.4 2001/02/09 02:03:44 xorgcvs Exp $ */
+
+/*
+Copyright 1989, 1994, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+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
+OPEN GROUP 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 Open Group 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 Open Group.
+ *
+ */
+
+
+/***********************************************************************
+ *
+ * MenuButton Widget
+ *
+ ***********************************************************************/
+
+/*
+ * MenuButton.c - Source code for MenuButton widget.
+ *
+ * This is the source code for the Athena MenuButton widget.
+ * It is intended to provide an easy method of activating pulldown menus.
+ *
+ * Date: May 2, 1989
+ *
+ * By: Chris D. Peterson
+ * MIT X Consortium
+ * kit@expo.lcs.mit.edu
+ */
+
+#include <stdio.h>
+#include <X11/IntrinsicP.h>
+#include <X11/StringDefs.h>
+
+#include <X11/Xaw/XawInit.h>
+#include <X11/Xaw/MenuButtoP.h>
+
+static void ClassInitialize();
+static void PopupMenu();
+
+#define superclass ((CommandWidgetClass)&commandClassRec)
+
+static char defaultTranslations[] =
+"<EnterWindow>: highlight()\n\
+ <LeaveWindow>: reset()\n\
+ Any<BtnDown>: reset() PopupMenu()";
+
+/****************************************************************
+ *
+ * Full class record constant
+ *
+ ****************************************************************/
+
+/* Private Data */
+
+#define offset(field) XtOffsetOf(MenuButtonRec, field)
+static XtResource resources[] = {
+ {
+ XtNmenuName, XtCMenuName, XtRString, sizeof(String),
+ offset(menu_button.menu_name), XtRString, (XtPointer)"menu"},
+};
+#undef offset
+
+static XtActionsRec actionsList[] =
+{
+ {"PopupMenu", PopupMenu}
+};
+
+MenuButtonClassRec menuButtonClassRec = {
+ {
+ (WidgetClass) superclass, /* superclass */
+ "MenuButton", /* class_name */
+ sizeof(MenuButtonRec), /* size */
+ ClassInitialize, /* class_initialize */
+ NULL, /* class_part_initialize */
+ FALSE, /* class_inited */
+ NULL, /* initialize */
+ NULL, /* initialize_hook */
+ XtInheritRealize, /* realize */
+ actionsList, /* actions */
+ XtNumber(actionsList), /* num_actions */
+ resources, /* resources */
+ XtNumber(resources), /* resource_count */
+ NULLQUARK, /* xrm_class */
+ FALSE, /* compress_motion */
+ TRUE, /* compress_exposure */
+ TRUE, /* compress_enterleave */
+ FALSE, /* visible_interest */
+ NULL, /* destroy */
+ XtInheritResize, /* resize */
+ XtInheritExpose, /* expose */
+ NULL, /* set_values */
+ NULL, /* set_values_hook */
+ XtInheritSetValuesAlmost, /* set_values_almost */
+ NULL, /* get_values_hook */
+ NULL, /* accept_focus */
+ XtVersion, /* version */
+ NULL, /* callback_private */
+ defaultTranslations, /* tm_table */
+ XtInheritQueryGeometry, /* query_geometry */
+ XtInheritDisplayAccelerator, /* display_accelerator */
+ NULL /* extension */
+ }, /* CoreClass fields initialization */
+ {
+ XtInheritChangeSensitive /* change_sensitive */
+ }, /* SimpleClass fields initialization */
+ {
+ 0, /* field not used */
+ }, /* LabelClass fields initialization */
+ {
+ 0, /* field not used */
+ }, /* CommandClass fields initialization */
+ {
+ 0, /* field not used */
+ } /* MenuButtonClass fields initialization */
+};
+
+ /* for public consumption */
+WidgetClass menuButtonWidgetClass = (WidgetClass) &menuButtonClassRec;
+
+/****************************************************************
+ *
+ * Private Procedures
+ *
+ ****************************************************************/
+
+static void ClassInitialize()
+{
+ XawInitializeWidgetSet();
+ XtRegisterGrabAction(PopupMenu, True,
+ (unsigned int)(ButtonPressMask | ButtonReleaseMask),
+ GrabModeAsync, GrabModeAsync);
+}
+
+/* ARGSUSED */
+static void
+PopupMenu(w, event, params, num_params)
+Widget w;
+XEvent * event;
+String * params;
+Cardinal * num_params;
+{
+ MenuButtonWidget mbw = (MenuButtonWidget) w;
+ Widget menu, temp;
+ Arg arglist[2];
+ Cardinal num_args;
+ int menu_x, menu_y, menu_width, menu_height, button_height;
+ Position button_x, button_y;
+
+ temp = w;
+ while(temp != NULL) {
+ menu = XtNameToWidget(temp, mbw->menu_button.menu_name);
+ if (menu == NULL)
+ temp = XtParent(temp);
+ else
+ break;
+ }
+
+ if (menu == NULL) {
+ char error_buf[BUFSIZ];
+ char* errorp;
+ int len;
+ char* fmt = "MenuButton: Could not find menu widget named %s.";
+
+ if ((len = strlen (fmt) + strlen (mbw->menu_button.menu_name)) < sizeof error_buf)
+ errorp = error_buf;
+ else
+ errorp = XtMalloc (len + 1);
+ if (errorp == NULL) {
+ errorp = error_buf;
+ strcpy (errorp, "MenuButton: Could not find menu widget.");
+ } else
+ (void) sprintf(errorp, fmt, mbw->menu_button.menu_name);
+ XtAppWarning (XtWidgetToApplicationContext (w), errorp);
+ if (errorp != error_buf) XtFree (errorp);
+ return;
+ }
+ if (!XtIsRealized(menu))
+ XtRealizeWidget(menu);
+
+ menu_width = menu->core.width + 2 * menu->core.border_width;
+ button_height = w->core.height + 2 * w->core.border_width;
+ menu_height = menu->core.height + 2 * menu->core.border_width;
+
+ XtTranslateCoords(w, 0, 0, &button_x, &button_y);
+ menu_x = button_x;
+ menu_y = button_y + button_height;
+
+ if (menu_x >= 0) {
+ int scr_width = WidthOfScreen(XtScreen(menu));
+ if (menu_x + menu_width > scr_width)
+ menu_x = scr_width - menu_width;
+ }
+ if (menu_x < 0)
+ menu_x = 0;
+
+ if (menu_y >= 0) {
+ int scr_height = HeightOfScreen(XtScreen(menu));
+ if (menu_y + menu_height > scr_height)
+ menu_y = scr_height - menu_height;
+ }
+ if (menu_y < 0)
+ menu_y = 0;
+
+ num_args = 0;
+ XtSetArg(arglist[num_args], XtNx, menu_x); num_args++;
+ XtSetArg(arglist[num_args], XtNy, menu_y); num_args++;
+ XtSetValues(menu, arglist, num_args);
+
+ XtPopupSpringLoaded(menu);
+}
+
diff --git a/src/MultiSink.c b/src/MultiSink.c
new file mode 100644
index 0000000..3f4b017
--- /dev/null
+++ b/src/MultiSink.c
@@ -0,0 +1,772 @@
+/* $Xorg: MultiSink.c,v 1.4 2001/02/09 02:03:44 xorgcvs Exp $ */
+
+/*
+ * Copyright 1991 by OMRON Corporation
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of OMRON not be used in advertising
+ * or publicity pertaining to distribution of the software without specific,
+ * written prior permission. OMRON makes no representations about the
+ * suitability of this software for any purpose. It is provided "as is"
+ * without express or implied warranty.
+ *
+ * OMRON DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL OMRON BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTUOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ *
+ * Author: Li Yuhong OMRON Corporation
+ */
+
+/***********************************************************
+
+Copyright 1987, 1988, 1994, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+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
+OPEN GROUP 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 Open Group 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 Open Group.
+
+
+Copyright 1987, 1988 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+******************************************************************/
+
+#include <X11/IntrinsicP.h>
+#include <X11/StringDefs.h>
+#include <X11/Xatom.h>
+#include <X11/Xaw/XawInit.h>
+#include <X11/Xaw/MultiSinkP.h>
+#include <X11/Xaw/MultiSrcP.h>
+#include <X11/Xaw/TextP.h>
+#include "XawI18n.h"
+#include <stdio.h>
+#include <ctype.h>
+
+#ifdef GETLASTPOS
+#undef GETLASTPOS /* We will use our own GETLASTPOS. */
+#endif
+
+#define GETLASTPOS XawTextSourceScan(source, (XawTextPosition) 0, XawstAll, XawsdRight, 1, TRUE)
+
+static void Initialize(), Destroy();
+static Boolean SetValues();
+static int MaxLines(), MaxHeight();
+static void SetTabs();
+
+static void DisplayText(), InsertCursor(), FindPosition();
+static void FindDistance(), Resolve(), GetCursorBounds();
+
+#define offset(field) XtOffsetOf(MultiSinkRec, multi_sink.field)
+
+static XtResource resources[] = {
+ {XtNfontSet, XtCFontSet, XtRFontSet, sizeof (XFontSet),
+ offset(fontset), XtRString, XtDefaultFontSet},
+ {XtNecho, XtCOutput, XtRBoolean, sizeof(Boolean),
+ offset(echo), XtRImmediate, (XtPointer) True},
+ {XtNdisplayNonprinting, XtCOutput, XtRBoolean, sizeof(Boolean),
+ offset(display_nonprinting), XtRImmediate, (XtPointer) True},
+};
+#undef offset
+
+#define SuperClass (&textSinkClassRec)
+MultiSinkClassRec multiSinkClassRec = {
+ { /* core_class fields */
+ /* superclass */ (WidgetClass) SuperClass,
+ /* class_name */ "MultiSink",
+ /* widget_size */ sizeof(MultiSinkRec),
+ /* class_initialize */ XawInitializeWidgetSet,
+ /* class_part_initialize */ NULL,
+ /* class_inited */ FALSE,
+ /* initialize */ Initialize,
+ /* initialize_hook */ NULL,
+ /* obj1 */ NULL,
+ /* obj2 */ NULL,
+ /* obj3 */ 0,
+ /* resources */ resources,
+ /* num_resources */ XtNumber(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
+ },
+ { /* text_sink_class fields */
+ /* DisplayText */ DisplayText,
+ /* InsertCursor */ InsertCursor,
+ /* ClearToBackground */ XtInheritClearToBackground,
+ /* FindPosition */ FindPosition,
+ /* FindDistance */ FindDistance,
+ /* Resolve */ Resolve,
+ /* MaxLines */ MaxLines,
+ /* MaxHeight */ MaxHeight,
+ /* SetTabs */ SetTabs,
+ /* GetCursorBounds */ GetCursorBounds
+ },
+ { /* multi_sink_class fields */
+ /* unused */ 0
+ }
+};
+
+WidgetClass multiSinkObjectClass = (WidgetClass)&multiSinkClassRec;
+
+/* Utilities */
+
+static int
+CharWidth (w, x, c)
+ Widget w;
+ int x;
+ wchar_t c;
+{
+ int i, width;
+ MultiSinkObject sink = (MultiSinkObject) w;
+ XFontSet fontset = sink->multi_sink.fontset;
+ Position *tab;
+
+ if ( c == _Xaw_atowc(XawLF) ) return(0);
+
+ if (c == _Xaw_atowc(XawTAB)) {
+ /* Adjust for Left Margin. */
+ x -= ((TextWidget) XtParent(w))->text.margin.left;
+
+ if (x >= (int)XtParent(w)->core.width) return 0;
+ for (i = 0, tab = sink->text_sink.tabs ;
+ i < sink->text_sink.tab_count ; i++, tab++) {
+ if (x < *tab) {
+ if (*tab < (int)XtParent(w)->core.width)
+ return *tab - x;
+ else
+ return 0;
+ }
+ }
+ return 0;
+ }
+
+ if (XwcTextEscapement (fontset, &c, 1) == 0)
+ if (sink->multi_sink.display_nonprinting)
+ c = _Xaw_atowc('@');
+ else {
+ c = _Xaw_atowc(XawSP);
+ }
+
+ /*
+ * if more efficiency(suppose one column is one ASCII char)
+
+ width = XwcGetColumn(fontset->font_charset, fontset->num_of_fonts, c) *
+ fontset->font_struct_list[0]->min_bounds.width;
+ *
+ * WARNING: Very Slower!!!
+ *
+ * Li Yuhong.
+ */
+
+ width = XwcTextEscapement(fontset, &c, 1);
+
+ return width;
+}
+
+/* Function Name: PaintText
+ * Description: Actually paints the text into the windoe.
+ * Arguments: w - the text widget.
+ * gc - gc to paint text with.
+ * x, y - location to paint the text.
+ * buf, len - buffer and length of text to paint.
+ * Returns: the width of the text painted, or 0.
+ *
+ * NOTE: If this string attempts to paint past the end of the window
+ * then this function will return zero.
+ */
+
+static Dimension
+PaintText(w, gc, x, y, buf, len)
+ Widget w;
+ GC gc;
+ Position x, y;
+ wchar_t* buf;
+ int len;
+{
+ MultiSinkObject sink = (MultiSinkObject) w;
+ TextWidget ctx = (TextWidget) XtParent(w);
+
+ XFontSet fontset = sink->multi_sink.fontset;
+ Position max_x;
+ Dimension width = XwcTextEscapement(fontset, buf, len);
+ XFontSetExtents *ext = XExtentsOfFontSet(fontset);
+ max_x = (Position) ctx->core.width;
+
+ if ( ((int) width) <= -x) /* Don't draw if we can't see it. */
+ return(width);
+
+ XwcDrawImageString(XtDisplay(ctx), XtWindow(ctx), fontset, gc,
+ (int) x, (int) y, buf, len);
+ if ( (((Position) width + x) > max_x) && (ctx->text.margin.right != 0) ) {
+ x = ctx->core.width - ctx->text.margin.right;
+ width = ctx->text.margin.right;
+ XFillRectangle(XtDisplay((Widget) ctx), XtWindow( (Widget) ctx),
+ sink->multi_sink.normgc, (int) x,
+ (int) y - abs(ext->max_logical_extent.y),
+ (unsigned int) width,
+ (unsigned int) ext->max_logical_extent.height);
+ return(0);
+ }
+ return(width);
+}
+
+/* Sink Object Functions */
+
+/*
+ * This function does not know about drawing more than one line of text.
+ */
+
+static void
+DisplayText(w, x, y, pos1, pos2, highlight)
+ Widget w;
+ Position x, y;
+ Boolean highlight;
+ XawTextPosition pos1, pos2;
+{
+ MultiSinkObject sink = (MultiSinkObject) w;
+ Widget source = XawTextGetSource(XtParent(w));
+ wchar_t buf[BUFSIZ];
+ XFontSetExtents *ext = XExtentsOfFontSet(sink->multi_sink.fontset);
+
+ int j, k;
+ XawTextBlock blk;
+ GC gc = highlight ? sink->multi_sink.invgc : sink->multi_sink.normgc;
+ GC invgc = highlight ? sink->multi_sink.normgc : sink->multi_sink.invgc;
+
+ if (!sink->multi_sink.echo) return;
+
+ y += abs(ext->max_logical_extent.y);
+ for ( j = 0 ; pos1 < pos2 ; ) {
+ pos1 = XawTextSourceRead(source, pos1, &blk, (int) pos2 - pos1);
+ for (k = 0; k < blk.length; k++) {
+ if (j >= BUFSIZ) { /* buffer full, dump the text. */
+ x += PaintText(w, gc, x, y, buf, j);
+ j = 0;
+ }
+ buf[j] = ((wchar_t *)blk.ptr)[k];
+ if (buf[j] == _Xaw_atowc(XawLF))
+ continue;
+
+ else if (buf[j] == _Xaw_atowc(XawTAB)) {
+ Position temp = 0;
+ Dimension width;
+
+ if ((j != 0) && ((temp = PaintText(w, gc, x, y, buf, j)) == 0))
+ return;
+
+ x += temp;
+ width = CharWidth(w, x, _Xaw_atowc(XawTAB));
+ XFillRectangle(XtDisplayOfObject(w), XtWindowOfObject(w),
+ invgc, (int) x,
+ (int) y - abs(ext->max_logical_extent.y),
+ (unsigned int)width,
+ (unsigned int)ext->max_logical_extent.height);
+ x += width;
+ j = -1;
+ }
+ else if (XwcTextEscapement (sink->multi_sink.fontset, &buf[j], 1) == 0) {
+ if (sink->multi_sink.display_nonprinting)
+ buf[j] = _Xaw_atowc('@');
+ else
+ buf[j] = _Xaw_atowc(' ');
+ }
+ j++;
+ }
+ }
+ if (j > 0)
+ (void) PaintText(w, gc, x, y, buf, j);
+}
+
+#define insertCursor_width 6
+#define insertCursor_height 3
+static char insertCursor_bits[] = {0x0c, 0x1e, 0x33};
+
+static Pixmap
+CreateInsertCursor(s)
+ Screen *s;
+{
+ return (XCreateBitmapFromData (DisplayOfScreen(s), RootWindowOfScreen(s),
+ insertCursor_bits, insertCursor_width, insertCursor_height));
+}
+
+/* Function Name: GetCursorBounds
+ * Description: Returns the size and location of the cursor.
+ * Arguments: w - the text object.
+ * RETURNED rect - an X rectangle to return the cursor bounds in.
+ * Returns: none.
+ */
+
+static void
+GetCursorBounds(w, rect)
+ Widget w;
+ XRectangle * rect;
+{
+ MultiSinkObject sink = (MultiSinkObject) w;
+
+ rect->width = (unsigned short) insertCursor_width;
+ rect->height = (unsigned short) insertCursor_height;
+ rect->x = sink->multi_sink.cursor_x - (short) (rect->width / 2);
+ rect->y = sink->multi_sink.cursor_y - (short) rect->height;
+}
+
+/*
+ * The following procedure manages the "insert" cursor.
+ */
+
+static void
+InsertCursor (w, x, y, state)
+ Widget w;
+ Position x, y;
+ XawTextInsertState state;
+{
+ MultiSinkObject sink = (MultiSinkObject) w;
+ Widget text_widget = XtParent(w);
+ XRectangle rect;
+
+ sink->multi_sink.cursor_x = x;
+ sink->multi_sink.cursor_y = y;
+
+ GetCursorBounds(w, &rect);
+ if (state != sink->multi_sink.laststate && XtIsRealized(text_widget))
+ XCopyPlane(XtDisplay(text_widget),
+ sink->multi_sink.insertCursorOn,
+ XtWindow(text_widget), sink->multi_sink.xorgc,
+ 0, 0, (unsigned int) rect.width, (unsigned int) rect.height,
+ (int) rect.x, (int) rect.y, 1);
+ sink->multi_sink.laststate = state;
+}
+
+/*
+ * Given two positions, find the distance between them.
+ */
+
+static void
+FindDistance (w, fromPos, fromx, toPos, resWidth, resPos, resHeight)
+ Widget w;
+ XawTextPosition fromPos; /* First position. */
+ int fromx; /* Horizontal location of first position. */
+ XawTextPosition toPos; /* Second position. */
+ int* resWidth; /* Distance between fromPos and resPos. */
+ XawTextPosition* resPos; /* Actual second position used. */
+ int* resHeight; /* Height required. */
+{
+ MultiSinkObject sink = (MultiSinkObject) w;
+ Widget source = XawTextGetSource(XtParent(w));
+
+ XawTextPosition index, lastPos;
+ wchar_t c;
+ XFontSetExtents *ext = XExtentsOfFontSet(sink->multi_sink.fontset);
+ XawTextBlock blk;
+
+ /* we may not need this */
+ lastPos = GETLASTPOS;
+ XawTextSourceRead(source, fromPos, &blk, (int) toPos - fromPos);
+ *resWidth = 0;
+ for (index = fromPos; index != toPos && index < lastPos; index++) {
+ if (index - blk.firstPos >= blk.length)
+ XawTextSourceRead(source, index, &blk, (int) toPos - fromPos);
+ c = ((wchar_t *)blk.ptr)[index - blk.firstPos];
+ *resWidth += CharWidth(w, fromx + *resWidth, c);
+ if (c == _Xaw_atowc(XawLF)) {
+ index++;
+ break;
+ }
+ }
+ *resPos = index;
+ *resHeight = ext->max_logical_extent.height;
+}
+
+
+static void
+FindPosition(w, fromPos, fromx, width, stopAtWordBreak, resPos, resWidth, resHeight)
+ Widget w;
+ XawTextPosition fromPos; /* Starting position. */
+ int fromx; /* Horizontal location of starting position.*/
+ int width; /* Desired width. */
+ int stopAtWordBreak; /* Whether the resulting position should be at
+ a word break. */
+ XawTextPosition *resPos; /* Resulting position. */
+ int* resWidth; /* Actual width used. */
+ int* resHeight; /* Height required. */
+{
+ MultiSinkObject sink = (MultiSinkObject) w;
+ Widget source = XawTextGetSource(XtParent(w));
+
+ XawTextPosition lastPos, index, whiteSpacePosition;
+ int lastWidth, whiteSpaceWidth;
+ Boolean whiteSpaceSeen;
+ wchar_t c;
+ XFontSetExtents *ext = XExtentsOfFontSet(sink->multi_sink.fontset);
+ XawTextBlock blk;
+
+ lastPos = GETLASTPOS;
+
+ XawTextSourceRead(source, fromPos, &blk, BUFSIZ);
+ *resWidth = 0;
+ whiteSpaceSeen = FALSE;
+ c = 0;
+ for (index = fromPos; *resWidth <= width && index < lastPos; index++) {
+ lastWidth = *resWidth;
+ if (index - blk.firstPos >= blk.length)
+ XawTextSourceRead(source, index, &blk, BUFSIZ);
+ c = ((wchar_t *)blk.ptr)[index - blk.firstPos];
+ *resWidth += CharWidth(w, fromx + *resWidth, c);
+
+ if ((c == _Xaw_atowc(XawSP) || c == _Xaw_atowc(XawTAB)) &&
+ *resWidth <= width) {
+ whiteSpaceSeen = TRUE;
+ whiteSpacePosition = index;
+ whiteSpaceWidth = *resWidth;
+ }
+ if (c == _Xaw_atowc(XawLF)) {
+ index++;
+ break;
+ }
+ }
+ if (*resWidth > width && index > fromPos) {
+ *resWidth = lastWidth;
+ index--;
+ if (stopAtWordBreak && whiteSpaceSeen) {
+ index = whiteSpacePosition + 1;
+ *resWidth = whiteSpaceWidth;
+ }
+ }
+ if (index == lastPos && c != _Xaw_atowc(XawLF)) index = lastPos + 1;
+ *resPos = index;
+ *resHeight = ext->max_logical_extent.height;
+}
+
+static void
+Resolve (w, pos, fromx, width, leftPos, rightPos)
+ Widget w;
+ XawTextPosition pos;
+ int fromx, width;
+ XawTextPosition *leftPos, *rightPos;
+{
+ int resWidth, resHeight;
+ Widget source = XawTextGetSource(XtParent(w));
+
+ FindPosition(w, pos, fromx, width, FALSE, leftPos, &resWidth, &resHeight);
+ if (*leftPos > GETLASTPOS)
+ *leftPos = GETLASTPOS;
+ *rightPos = *leftPos;
+}
+
+static void
+GetGC(sink)
+ MultiSinkObject sink;
+{
+ XtGCMask valuemask = (GCGraphicsExposures | GCForeground | GCBackground );
+ XGCValues values;
+
+ values.graphics_exposures = (Bool) FALSE;
+
+ values.foreground = sink->text_sink.foreground;
+ values.background = sink->text_sink.background;
+
+ sink->multi_sink.normgc = XtAllocateGC( (Widget)sink, 0, valuemask, &values, GCFont, 0 );
+
+ values.foreground = sink->text_sink.background;
+ values.background = sink->text_sink.foreground;
+ sink->multi_sink.invgc = XtAllocateGC( (Widget)sink, 0, valuemask, &values, GCFont, 0 );
+
+ values.function = GXxor;
+ values.background = (unsigned long) 0L; /* (pix ^ 0) = pix */
+ values.foreground = (sink->text_sink.background ^
+ sink->text_sink.foreground);
+ valuemask = GCGraphicsExposures | GCFunction | GCForeground | GCBackground;
+
+ /* if this GC is not used for fontset rendering then AllocateGC aint needed. Dont hurt tho.*/
+ sink->multi_sink.xorgc = XtAllocateGC( (Widget)sink, 0, valuemask, &values, GCFont, 0 );
+}
+
+
+/***** Public routines *****/
+
+/* 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
+Initialize(request, new, args, num_args)
+ Widget request, new;
+ ArgList args;
+ Cardinal* num_args;
+{
+ MultiSinkObject sink = (MultiSinkObject) new;
+
+ GetGC(sink);
+
+ sink->multi_sink.insertCursorOn= CreateInsertCursor(XtScreenOfObject(new));
+ sink->multi_sink.laststate = XawisOff;
+ sink->multi_sink.cursor_x = sink->multi_sink.cursor_y = 0;
+}
+
+/* Function Name: Destroy
+ * Description: This function cleans up when the object is
+ * destroyed.
+ * Arguments: w - the MultiSink Object.
+ * Returns: none.
+ */
+
+static void
+Destroy(w)
+ Widget w;
+{
+ MultiSinkObject sink = (MultiSinkObject) w;
+
+ XtReleaseGC(w, sink->multi_sink.normgc);
+ XtReleaseGC(w, sink->multi_sink.invgc);
+ XtReleaseGC(w, sink->multi_sink.xorgc);
+
+ XFreePixmap(XtDisplayOfObject(w), sink->multi_sink.insertCursorOn);
+}
+
+/* Function Name: SetValues
+ * Description: Sets the values for the MultiSink
+ * 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
+SetValues(current, request, new, args, num_args)
+ Widget current, request, new;
+ ArgList args;
+ Cardinal* num_args;
+{
+ MultiSinkObject w = (MultiSinkObject) new;
+ MultiSinkObject old_w = (MultiSinkObject) current;
+
+ /* Font set is not in the GC! Do not make a new GC when font set changes! */
+
+ if ( w->multi_sink.fontset != old_w->multi_sink.fontset ) {
+ ((TextWidget)XtParent(new))->text.redisplay_needed = True;
+#ifndef NO_TAB_FIX
+ SetTabs( w, w->text_sink.tab_count, w->text_sink.char_tabs );
+#endif
+ }
+
+ if ( w->text_sink.background != old_w->text_sink.background ||
+ w->text_sink.foreground != old_w->text_sink.foreground ) {
+
+ XtReleaseGC((Widget)w, w->multi_sink.normgc);
+ XtReleaseGC((Widget)w, w->multi_sink.invgc);
+ XtReleaseGC((Widget)w, w->multi_sink.xorgc);
+ GetGC(w);
+ ((TextWidget)XtParent(new))->text.redisplay_needed = True;
+ } else {
+ if ( (w->multi_sink.echo != old_w->multi_sink.echo) ||
+ (w->multi_sink.display_nonprinting !=
+ old_w->multi_sink.display_nonprinting) )
+ ((TextWidget)XtParent(new))->text.redisplay_needed = True;
+ }
+
+ return False;
+}
+
+/* Function Name: MaxLines
+ * Description: Finds the Maximum number of lines that will fit in
+ * a given height.
+ * Arguments: w - the MultiSink Object.
+ * height - height to fit lines into.
+ * Returns: the number of lines that will fit.
+ */
+
+/* ARGSUSED */
+static int
+MaxLines(w, height)
+ Widget w;
+ Dimension height;
+{
+ MultiSinkObject sink = (MultiSinkObject) w;
+ int font_height;
+ XFontSetExtents *ext = XExtentsOfFontSet(sink->multi_sink.fontset);
+
+ font_height = ext->max_logical_extent.height;
+ return( ((int) height) / font_height );
+}
+
+/* Function Name: MaxHeight
+ * Description: Finds the Minium height that will contain a given number
+ * lines.
+ * Arguments: w - the MultiSink Object.
+ * lines - the number of lines.
+ * Returns: the height.
+ */
+
+/* ARGSUSED */
+static int
+#if NeedFunctionPrototypes
+MaxHeight(
+ Widget w,
+ int lines )
+#else
+MaxHeight( w, lines )
+ Widget w;
+ int lines;
+#endif
+{
+ MultiSinkObject sink = (MultiSinkObject) w;
+ XFontSetExtents *ext = XExtentsOfFontSet(sink->multi_sink.fontset);
+
+ return(lines * ext->max_logical_extent.height);
+}
+
+/* Function Name: SetTabs
+ * Description: Sets the Tab stops.
+ * Arguments: w - the MultiSink Object.
+ * tab_count - the number of tabs in the list.
+ * tabs - the text positions of the tabs.
+ * Returns: none
+ */
+
+static void
+#if NeedFunctionPrototypes
+SetTabs(
+ Widget w,
+ int tab_count,
+ short* tabs )
+#else
+SetTabs( w, tab_count, tabs )
+ Widget w;
+ int tab_count;
+ short* tabs;
+#endif
+{
+ MultiSinkObject sink = (MultiSinkObject) w;
+ int i;
+ Atom XA_FIGURE_WIDTH;
+ unsigned long figure_width = 0;
+ XFontStruct *font;
+
+ /*
+ * Bug:
+ * Suppose the first font of fontset stores the unit of column.
+ *
+ * By Li Yuhong, Mar. 14, 1991
+ */
+ { XFontStruct **f_list;
+ char **f_name;
+
+ (void) XFontsOfFontSet(sink->multi_sink.fontset, &f_list, &f_name);
+ font = f_list[0];
+ }
+
+/*
+ * Find the figure width of the current font.
+ */
+
+ XA_FIGURE_WIDTH = XInternAtom(XtDisplayOfObject(w), "FIGURE_WIDTH", FALSE);
+ if ( (XA_FIGURE_WIDTH != None) &&
+ ( (!XGetFontProperty(font, XA_FIGURE_WIDTH, &figure_width)) ||
+ (figure_width == 0)) )
+ if (font->per_char && font->min_char_or_byte2 <= '$' &&
+ font->max_char_or_byte2 >= '$')
+ figure_width = font->per_char['$' - font->min_char_or_byte2].width;
+ else
+ figure_width = font->max_bounds.width;
+
+ if (tab_count > sink->text_sink.tab_count) {
+ sink->text_sink.tabs = (Position *)
+ XtRealloc((char *) sink->text_sink.tabs,
+ (Cardinal) (tab_count * sizeof(Position)));
+ sink->text_sink.char_tabs = (short *)
+ XtRealloc((char *) sink->text_sink.char_tabs,
+ (Cardinal) (tab_count * sizeof(short)));
+ }
+
+ for ( i = 0 ; i < tab_count ; i++ ) {
+ sink->text_sink.tabs[i] = tabs[i] * figure_width;
+ sink->text_sink.char_tabs[i] = tabs[i];
+ }
+
+ sink->text_sink.tab_count = tab_count;
+
+#ifndef NO_TAB_FIX
+ ((TextWidget)XtParent(w))->text.redisplay_needed = True;
+#endif
+}
+
+void
+#if NeedFunctionPrototypes
+_XawMultiSinkPosToXY(
+ Widget w,
+ XawTextPosition pos,
+ Position *x,
+ Position *y )
+#else
+_XawMultiSinkPosToXY( w, pos, x, y )
+ Widget w;
+ XawTextPosition pos;
+ Position *x, *y;
+#endif
+{
+ MultiSinkObject sink = (MultiSinkObject) ((TextWidget)w)->text.sink;
+ XFontSetExtents *ext = XExtentsOfFontSet( sink->multi_sink.fontset );
+
+ _XawTextPosToXY( w, pos, x, y );
+ *y += abs( ext->max_logical_extent.y );
+}
diff --git a/src/MultiSrc.c b/src/MultiSrc.c
new file mode 100644
index 0000000..671e6b5
--- /dev/null
+++ b/src/MultiSrc.c
@@ -0,0 +1,1458 @@
+/* $Xorg: MultiSrc.c,v 1.4 2001/02/09 02:03:44 xorgcvs Exp $ */
+
+/*
+ * Copyright 1991 by OMRON Corporation
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name OMRON not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. OMRON makes no representations
+ * about the suitability of this software for any purpose. It is provided
+ * "as is" without express or implied warranty.
+ *
+ * OMRON DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL OMRON BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTUOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ *
+ * Authors: Chris Peterson MIT X Consortium
+ * Li Yuhong OMRON Corporation
+ * Frank Sheeran OMRON Corporation
+ *
+ * Much code taken from X11R3 String and Disk Sources.
+ */
+
+/*
+
+Copyright 1991, 1994, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+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
+OPEN GROUP 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 Open Group 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 Open Group.
+
+*/
+
+/*
+ * MultiSrc.c - MultiSrc object. (For use with the text widget).
+ *
+ */
+
+#include <X11/IntrinsicP.h>
+#include <X11/StringDefs.h>
+#include <X11/Xfuncs.h>
+#include <X11/Xaw/XawInit.h>
+#include <X11/Xaw/MultiSrcP.h>
+#include <X11/Xaw/XawImP.h>
+#include <X11/Xmu/Misc.h>
+#include <X11/Xmu/CharSet.h>
+#include "XawI18n.h"
+#include <X11/Xos.h>
+#include <stdio.h>
+#include <ctype.h>
+#include <errno.h>
+
+/****************************************************************
+ *
+ * Full class record constant
+ *
+ ****************************************************************/
+
+/* Private Data */
+
+static int magic_value = MAGIC_VALUE;
+
+#define offset(field) XtOffsetOf(MultiSrcRec, multi_src.field)
+
+static XtResource resources[] = {
+ {XtNstring, XtCString, XtRString, sizeof (XtPointer),
+ offset(string), XtRPointer, NULL},
+ {XtNtype, XtCType, XtRMultiType, sizeof (XawAsciiType),
+ offset(type), XtRImmediate, (XtPointer)XawAsciiString},
+ /* not used. */
+ {XtNdataCompression, XtCDataCompression, XtRBoolean, sizeof (Boolean),
+ offset(data_compression), XtRImmediate, (XtPointer) FALSE},
+ {XtNpieceSize, XtCPieceSize, XtRInt, sizeof (XawTextPosition),
+ offset(piece_size), XtRImmediate, (XtPointer) BUFSIZ},
+ {XtNcallback, XtCCallback, XtRCallback, sizeof(XtPointer),
+ offset(callback), XtRCallback, (XtPointer)NULL},
+ {XtNuseStringInPlace, XtCUseStringInPlace, XtRBoolean, sizeof (Boolean),
+ offset(use_string_in_place), XtRImmediate, (XtPointer) FALSE},
+ {XtNlength, XtCLength, XtRInt, sizeof (int),
+ offset(multi_length), XtRInt, (XtPointer) &magic_value},
+
+};
+#undef offset
+
+static XawTextPosition Scan(), Search(), ReadText();
+static int ReplaceText();
+static MultiPiece * FindPiece(), * AllocNewPiece();
+static FILE * InitStringOrFile();
+static void FreeAllPieces(), RemovePiece(), BreakPiece(), LoadPieces();
+static void RemoveOldStringOrFile(), CvtStringToMultiType();
+static void ClassInitialize(), Initialize(), Destroy(), GetValuesHook();
+static String StorePiecesInString();
+static Boolean SetValues(), WriteToFile();
+
+#define MyWStrncpy( t,s,wcnt ) (void) memmove( (t), (s), (wcnt)*sizeof(wchar_t))
+
+#ifndef MyWStrncpy
+static void (MyWStrncpy)();
+#endif
+
+extern char *tmpnam();
+#ifdef X_NOT_STDC_ENV
+extern int errno;
+#endif
+
+#ifdef X_NOT_POSIX
+#define Off_t long
+#define Size_t unsigned int
+#else
+#define Off_t off_t
+#define Size_t size_t
+#endif
+
+extern wchar_t* _XawTextMBToWC();
+extern char *_XawTextWCToMB();
+
+#define superclass (&textSrcClassRec)
+MultiSrcClassRec multiSrcClassRec = {
+ { /* object_class fields */
+ /* superclass */ (WidgetClass) superclass,
+ /* class_name */ "MultiSrc",
+ /* widget_size */ sizeof(MultiSrcRec),
+ /* class_initialize */ ClassInitialize,
+ /* class_part_initialize */ NULL,
+ /* class_inited */ FALSE,
+ /* initialize */ Initialize,
+ /* initialize_hook */ NULL,
+ /* pad */ NULL,
+ /* pad */ NULL,
+ /* pad */ 0,
+ /* resources */ resources,
+ /* num_resources */ XtNumber(resources),
+ /* xrm_class */ NULLQUARK,
+ /* pad */ FALSE,
+ /* pad */ FALSE,
+ /* pad */ FALSE,
+ /* pad */ FALSE,
+ /* destroy */ Destroy,
+ /* pad */ NULL,
+ /* pad */ NULL,
+ /* set_values */ SetValues,
+ /* set_values_hook */ NULL,
+ /* pad */ NULL,
+ /* get_values_hook */ GetValuesHook,
+ /* pad */ NULL,
+ /* version */ XtVersion,
+ /* callback_private */ NULL,
+ /* pad */ NULL,
+ /* pad */ NULL,
+ /* pad */ NULL,
+ /* extension */ NULL
+ },
+ { /* textSrc_class fields */
+ /* Read */ ReadText,
+ /* Replace */ ReplaceText,
+ /* Scan */ Scan,
+ /* Search */ Search,
+ /* SetSelection */ XtInheritSetSelection,
+ /* ConvertSelection */ XtInheritConvertSelection
+ },
+ { /* multiSrc_class fields */
+ /* Keep the compiler happy */ '\0'
+ }
+};
+
+WidgetClass multiSrcObjectClass = (WidgetClass)&multiSrcClassRec;
+
+/************************************************************
+ *
+ * Semi-Public Interfaces.
+ *
+ ************************************************************/
+
+/* Function Name: ClassInitialize
+ * Description: Class Initialize routine, called only once.
+ * Arguments: none.
+ * Returns: none.
+ */
+
+static void
+ClassInitialize()
+{
+ XawInitializeWidgetSet();
+ XtAddConverter( XtRString, XtRMultiType, CvtStringToMultiType,
+ NULL, (Cardinal) 0);
+}
+
+/* Function Name: Initialize
+ * Description: Initializes the simple menu widget
+ * Arguments: request - the widget requested by the argument list.
+ * new - the new widget with both resource and non
+ * resource values.
+ * Returns: none.
+ */
+
+/* ARGSUSED */
+static void
+Initialize(request, new, args, num_args)
+ Widget request, new;
+ ArgList args;
+ Cardinal* num_args;
+{
+ MultiSrcObject src = (MultiSrcObject) new;
+ FILE * file;
+
+/*
+ * Set correct flags (override resources) depending upon widget class.
+ */
+
+ src->multi_src.changes = FALSE;
+ src->multi_src.allocated_string = FALSE;
+
+ file = InitStringOrFile(src, src->multi_src.type == XawAsciiFile);
+ LoadPieces(src, file, NULL);
+
+ if (file != NULL) fclose(file);
+ src->text_src.text_format = XawFmtWide;
+
+}
+
+/* Function Name: ReadText
+ * Description: This function reads the source.
+ * Arguments: w - the MultiSource widget.
+ * pos - position of the text to retreive.
+ * RETURNED text - text block that will contain returned text.
+ * length - maximum number of characters to read.
+ * Returns: The number of characters read into the buffer.
+ */
+
+static XawTextPosition
+ReadText(w, pos, text, length)
+ Widget w;
+ XawTextPosition pos;
+ XawTextBlock* text;
+ int length;
+{
+ MultiSrcObject src = (MultiSrcObject) w;
+ XawTextPosition count, start;
+ MultiPiece * piece = FindPiece(src, pos, &start);
+
+ text->format = XawFmtWide;
+ text->firstPos = pos;
+ text->ptr = (char *)(piece->text + (pos - start));
+ count = piece->used - (pos - start);
+ text->length = (length > count) ? count : length;
+ return(pos + text->length);
+}
+
+/* Function Name: ReplaceText.
+ * Description: Replaces a block of text with new text.
+ * Arguments: w - the MultiSource widget.
+ * startPos, endPos - ends of text that will be removed.
+ * text - new text to be inserted into buffer at startPos.
+ * Returns: XawEditError or XawEditDone.
+ */
+
+/*ARGSUSED*/
+static int
+ReplaceText( w, startPos, endPos, u_text_p)
+ Widget w;
+ XawTextPosition startPos, endPos;
+ XawTextBlock* u_text_p;
+{
+ MultiSrcObject src = (MultiSrcObject) w;
+ MultiPiece *start_piece, *end_piece, *temp_piece;
+ XawTextPosition start_first, end_first;
+ int length, firstPos;
+ wchar_t *wptr;
+ Boolean local_artificial_block = False;
+ XawTextBlock text;
+
+ /* STEP 1: The user handed me a text block called `u_text' that may be
+ * in either FMTWIDE or FMT8BIT (ie MB.) Later code needs the block
+ * `text' to hold FMTWIDE. So, this copies `u_text' to `text', and if
+ * `u_text' was MB, I knock it up to WIDE. */
+
+ if ( u_text_p->length == 0 ) /* if so, the block contents never ref'd. */
+ text.length = 0;
+
+ else if ( u_text_p->format == XawFmtWide) {
+ local_artificial_block = False; /* ie, don't have to free it ourselves*/
+ text.firstPos = u_text_p->firstPos;
+ text.length = u_text_p->length;
+ text.ptr = u_text_p->ptr;
+ /* text.format is unneeded */
+
+ } else {
+ /* WARNING! u_text->firstPos and length are in units of CHAR, not CHARACTERS! */
+
+ local_artificial_block = True; /* ie, have to free it ourselves */
+ text.firstPos = 0;
+ text.length = u_text_p->length; /* _XawTextMBToWC converts this to wchar len. */
+
+ text.ptr = (char*)_XawTextMBToWC( XtDisplay(XtParent(w)),
+ &(u_text_p->ptr[u_text_p->firstPos]), &(text.length) );
+
+ /* I assert the following assignment is not needed - since Step 4
+ depends on length, it has no need of a terminating NULL. I think
+ the ASCII-version has the same needless NULL. */
+ /*((wchar_t*)text.ptr)[ text.length ] = NULL;*/
+ }
+
+
+ /* STEP 2: some initialization... */
+
+ if (src->text_src.edit_mode == XawtextRead)
+ return(XawEditError);
+
+ start_piece = FindPiece(src, startPos, &start_first);
+ end_piece = FindPiece(src, endPos, &end_first);
+
+
+ /* STEP 3: remove the empty pieces... */
+
+ if (start_piece != end_piece) {
+ temp_piece = start_piece->next;
+
+ /* If empty and not the only piece then remove it. */
+
+ if ( ((start_piece->used = startPos - start_first) == 0) &&
+ !((start_piece->next == NULL) && (start_piece->prev == NULL)) )
+ RemovePiece(src, start_piece);
+
+ while (temp_piece != end_piece) {
+ temp_piece = temp_piece->next;
+ RemovePiece(src, temp_piece->prev);
+ }
+ end_piece->used -= endPos - end_first;
+ if (end_piece->used != 0)
+ MyWStrncpy(end_piece->text, (end_piece->text + endPos - end_first),
+ (int) end_piece->used);
+ }
+ else { /* We are fully in one piece. */
+ if ( (start_piece->used -= endPos - startPos) == 0) {
+ if ( !((start_piece->next == NULL) && (start_piece->prev == NULL)) )
+ RemovePiece(src, start_piece);
+ }
+ else {
+ MyWStrncpy(start_piece->text + (startPos - start_first),
+ start_piece->text + (endPos - start_first),
+ (int) (start_piece->used - (startPos - start_first)) );
+ if ( src->multi_src.use_string_in_place &&
+ ((src->multi_src.length - (endPos - startPos)) <
+ (src->multi_src.piece_size - 1)) )
+ start_piece->text[src->multi_src.length - (endPos - startPos)] = (wchar_t)0;
+ }
+ }
+
+ src->multi_src.length += text.length -(endPos - startPos);
+ /*((TextWidget)src->object.parent)->text.lastPos = src->multi_src.length;*/
+
+
+
+ /* STEP 4: insert the new stuff */
+
+ if ( text.length != 0) {
+
+ start_piece = FindPiece(src, startPos, &start_first);
+
+ length = text.length;
+ firstPos = text.firstPos;
+
+ while (length > 0) {
+ wchar_t* ptr;
+ int fill;
+
+ if (src->multi_src.use_string_in_place) {
+ if (start_piece->used == (src->multi_src.piece_size - 1)) {
+ /*
+ * The string is used in place, then the string
+ * is not allowed to grow.
+ */
+ start_piece->used = src->multi_src.length =
+ src->multi_src.piece_size - 1;
+ /*((TextWidget)src->object.parent)->text.lastPos = src->multi_src.length;*/
+
+
+ start_piece->text[src->multi_src.length] = (wchar_t)0;
+ return(XawEditError);
+ }
+ }
+
+
+ if (start_piece->used == src->multi_src.piece_size) {
+ BreakPiece(src, start_piece);
+ start_piece = FindPiece(src, startPos, &start_first);
+ }
+
+ fill = Min((int)(src->multi_src.piece_size - start_piece->used), length);
+
+ ptr = start_piece->text + (startPos - start_first);
+ MyWStrncpy(ptr + fill, ptr,
+ (int) start_piece->used - (startPos - start_first));
+ wptr =(wchar_t *)text.ptr;
+ (void)wcsncpy(ptr, wptr + firstPos, fill);
+
+ startPos += fill;
+ firstPos += fill;
+ start_piece->used += fill;
+ length -= fill;
+ }
+ }
+
+ if ( local_artificial_block == True )
+
+ /* In other words, text is not the u_text that the user handed me but
+ one I made myself. I only care, because I need to free the string. */
+
+ XFree( text.ptr );
+
+ if (src->multi_src.use_string_in_place)
+ start_piece->text[start_piece->used] = (wchar_t)0;
+
+ src->multi_src.changes = TRUE;
+
+ XtCallCallbacks(w, XtNcallback, NULL);
+
+ return(XawEditDone);
+}
+
+/* Function Name: Scan
+ * Description: Scans the text source for the number and type
+ * of item specified.
+ * Arguments: w - the MultiSource widget.
+ * position - the position to start scanning.
+ * type - type of thing to scan for.
+ * dir - direction to scan.
+ * count - which occurance if this thing to search for.
+ * include - whether or not to include the character found in
+ * the position that is returned.
+ * Returns: the position of the item found.
+ *
+ * Note: While there are only 'n' characters in the file there are n+1
+ * possible cursor positions (one before the first character and
+ * one after the last character.
+ */
+
+static
+XawTextPosition
+Scan( w, position, type, dir, count, include )
+ Widget w;
+ XawTextPosition position;
+ XawTextScanType type;
+ XawTextScanDirection dir;
+ int count;
+ Boolean include;
+{
+ MultiSrcObject src = (MultiSrcObject) w;
+ int inc;
+ MultiPiece * piece;
+ XawTextPosition first, first_eol_position;
+ wchar_t * ptr;
+
+ if (type == XawstAll) { /* Optimize this common case. */
+ if (dir == XawsdRight)
+ return(src->multi_src.length);
+ return(0); /* else. */
+ }
+
+
+ /* STEP 1: basic sanity checks */
+
+ if (position > src->multi_src.length)
+ position = src->multi_src.length;
+
+
+ if ( dir == XawsdRight ) {
+ if (position == src->multi_src.length)
+ return(src->multi_src.length);
+ inc = 1;
+ }
+ else {
+ if (position == 0)
+ return(0);
+ inc = -1;
+ position--;
+ }
+
+ piece = FindPiece(src, position, &first);
+
+ if ( piece->used == 0 ) return(0); /* i.e., buffer is empty. */
+
+ ptr = (position - first) + piece->text;
+
+ switch (type) {
+ case XawstEOL:
+ case XawstParagraph:
+ case XawstWhiteSpace:
+ for ( ; count > 0 ; count-- ) {
+ Boolean non_space = FALSE, first_eol = TRUE;
+ /* CONSTCOND */
+ while (TRUE) {
+ wchar_t c = *ptr;
+
+ ptr += inc;
+ position += inc;
+
+ if (type == XawstWhiteSpace) {
+ if (iswspace(c)) {
+ if (non_space)
+ break;
+ }
+ else
+ non_space = TRUE;
+ }
+ else if (type == XawstEOL) {
+ if (c == _Xaw_atowc(XawLF)) break;
+ }
+ else { /* XawstParagraph */
+ if (first_eol) {
+ if (c == _Xaw_atowc(XawLF)) {
+ first_eol_position = position;
+ first_eol = FALSE;
+ }
+ }
+ else
+ if ( c == _Xaw_atowc(XawLF))
+ break;
+ else if ( !iswspace(c) )
+ first_eol = TRUE;
+ }
+
+
+ if ( ptr < piece->text ) {
+ piece = piece->prev;
+ if (piece == NULL) /* Begining of text. */
+ return(0);
+ ptr = piece->text + piece->used - 1;
+ }
+ else if ( ptr >= (piece->text + piece->used) ) {
+ piece = piece->next;
+ if (piece == NULL) /* End of text. */
+ return(src->multi_src.length);
+ ptr = piece->text;
+ }
+ }
+ }
+ if (!include) {
+ if ( type == XawstParagraph)
+ position = first_eol_position;
+ position -= inc;
+ }
+ break;
+ case XawstPositions:
+ position += count * inc;
+ break;
+/* case XawstAll: ---- handled in special code above */
+ }
+
+ if ( dir == XawsdLeft )
+ position++;
+
+ if (position >= src->multi_src.length)
+ return(src->multi_src.length);
+ if (position < 0)
+ return(0);
+
+ return(position);
+}
+
+/* Function Name: Search
+ * Description: Searchs the text source for the text block passed
+ * Arguments: w - the MultiSource Widget.
+ * position - the position to start scanning.
+ * dir - direction to scan.
+ * text - the text block to search for.
+ * Returns: the position of the item found.
+ */
+
+static XawTextPosition
+Search(w, position, dir, text )
+ Widget w;
+ XawTextPosition position;
+ XawTextScanDirection dir;
+ XawTextBlock* text;
+{
+ MultiSrcObject src = (MultiSrcObject) w;
+ int inc, count = 0;
+ wchar_t * ptr;
+ wchar_t* wtarget;
+ int wtarget_len;
+ Display * d = XtDisplay(XtParent(w));
+ MultiPiece * piece;
+ wchar_t* buf;
+ XawTextPosition first;
+
+
+ /* STEP 1: First, a brief sanity check. */
+
+ if ( dir == XawsdRight )
+ inc = 1;
+ else {
+ inc = -1;
+ if (position == 0)
+ return(XawTextSearchError); /* scanning left from 0??? */
+ position--;
+ }
+
+
+ /* STEP 2: Ensure I have a local wide string.. */
+
+ /* Since this widget stores 32bit chars, I check here to see if
+ I'm being passed a string claiming to be 8bit chars (ie, MB text.)
+ If that is the case, naturally I convert to 32bit format. */
+
+ /*if the block was FMT8BIT, length will convert to REAL wchar count below */
+ wtarget_len = text->length;
+
+ if ( text->format == XawFmtWide )
+ wtarget = &( ((wchar_t*)text->ptr) [text->firstPos] );
+ else
+ {
+ /* The following converts wtarget_len from byte len to wchar count */
+ wtarget = _XawTextMBToWC( d, &text->ptr[ text->firstPos ], &wtarget_len );
+ }
+
+ /* OK, I can now assert that wtarget holds wide characters, wtarget_len
+ holds an accurate count of those characters, and that firstPos has been
+ effectively factored out of the following computations. */
+
+
+ /* STEP 3: SEARCH! */
+
+ buf = (wchar_t *)XtMalloc((unsigned)sizeof(wchar_t) * wtarget_len );
+ (void)wcsncpy(buf, wtarget, wtarget_len );
+ piece = FindPiece(src, position, &first);
+ ptr = (position - first) + piece->text;
+
+ /* CONSTCOND */
+ while (TRUE) {
+ if (*ptr == ((dir == XawsdRight) ? *(buf + count)
+ : *(buf + wtarget_len - count - 1)) ) {
+ if (count == (text->length - 1))
+ break;
+ else
+ count++;
+ }
+ else {
+ if (count != 0) {
+ position -=inc * count;
+ ptr -= inc * count;
+ }
+ count = 0;
+ }
+
+ ptr += inc;
+ position += inc;
+
+ while ( ptr < piece->text ) {
+ piece = piece->prev;
+ if (piece == NULL) { /* Begining of text. */
+ XtFree((char *)buf);
+ return(XawTextSearchError);
+ }
+ ptr = piece->text + piece->used - 1;
+ }
+
+ while ( ptr >= (piece->text + piece->used) ) {
+ piece = piece->next;
+ if (piece == NULL) { /* End of text. */
+ XtFree((char *)buf);
+ return(XawTextSearchError);
+ }
+ ptr = piece->text;
+ }
+ }
+
+ XtFree( (char *) buf );
+ if (dir == XawsdLeft)
+ return( position );
+ return( position - ( wtarget_len - 1 ) );
+}
+
+/* Function Name: SetValues
+ * Description: Sets the values for the MultiSource.
+ * Arguments: current - current state of the widget.
+ * request - what was requested.
+ * new - what the widget will become.
+ * Returns: True if redisplay is needed.
+ */
+
+/* ARGSUSED */
+static Boolean
+SetValues(current, request, new, args, num_args)
+ Widget current, request, new;
+ ArgList args;
+ Cardinal* num_args;
+{
+ MultiSrcObject src = (MultiSrcObject) new;
+ MultiSrcObject old_src = (MultiSrcObject) current;
+ XtAppContext app_con = XtWidgetToApplicationContext(new);
+ Boolean total_reset = FALSE, string_set = FALSE;
+ FILE * file;
+ int i;
+
+ if ( old_src->multi_src.use_string_in_place !=
+ src->multi_src.use_string_in_place ) {
+ XtAppWarning( app_con,
+ "MultiSrc: The XtNuseStringInPlace resources may not be changed.");
+ src->multi_src.use_string_in_place =
+ old_src->multi_src.use_string_in_place;
+ }
+
+ for (i = 0; i < *num_args ; i++ )
+ if (streq(args[i].name, XtNstring)) {
+ string_set = TRUE;
+ break;
+ }
+
+ if ( string_set || (old_src->multi_src.type != src->multi_src.type) ) {
+ RemoveOldStringOrFile(old_src, string_set);
+ file = InitStringOrFile(src, string_set);
+
+ /* Load pieces does this logic for us, but it shouldn't. Its messy.*/
+ /*if (old_src->multi_src.type == XawAsciiString)
+ LoadPieces(src, NULL, src->multi_src.string);
+ else*/
+ LoadPieces(src, file, NULL);
+ if (file != NULL) fclose(file);
+ XawTextSetSource( XtParent(new), new, 0); /* Tell text widget
+ what happened. */
+ total_reset = TRUE;
+ }
+
+ if ( old_src->multi_src.multi_length != src->multi_src.multi_length )
+ src->multi_src.piece_size = src->multi_src.multi_length;
+
+ if ( !total_reset && (old_src->multi_src.piece_size
+ != src->multi_src.piece_size) ) {
+ String mb_string = StorePiecesInString( old_src );
+
+ if ( mb_string != 0 ) {
+ FreeAllPieces( old_src );
+ LoadPieces( src, NULL, mb_string );
+ XtFree( mb_string );
+ } else {
+ /* If the buffer holds bad chars, don't touch it... */
+ XtAppWarningMsg( app_con,
+ "convertError", "multiSource", "XawError",
+ XtName( XtParent( (Widget) old_src ) ), NULL, NULL );
+ XtAppWarningMsg( app_con,
+ "convertError", "multiSource", "XawError",
+ "Non-character code(s) in buffer.", NULL, NULL );
+ }
+ }
+
+ return(FALSE);
+}
+
+/* Function Name: GetValuesHook
+ * Description: This is a get values hook routine that sets the
+ * values specific to the multi source.
+ * Arguments: w - the MultiSource Widget.
+ * args - the argument list.
+ * num_args - the number of args.
+ * Returns: none.
+ */
+
+static void
+GetValuesHook(w, args, num_args)
+ Widget w;
+ ArgList args;
+ Cardinal* num_args;
+{
+ MultiSrcObject src = (MultiSrcObject) w;
+ int i;
+
+ if (src->multi_src.type == XawAsciiString) {
+ for (i = 0; i < *num_args ; i++ )
+ if (streq(args[i].name, XtNstring)) {
+ if (src->multi_src.use_string_in_place) {
+ *((char **) args[i].value) = (char *)
+ src->multi_src.first_piece->text;
+ }
+ else {
+ if (_XawMultiSave(w)) /* If save sucessful. */
+ *((char **) args[i].value) = src->multi_src.string;
+ }
+ break;
+ }
+ }
+}
+
+/* Function Name: Destroy
+ * Description: Destroys an multi source (frees all data)
+ * Arguments: src - the Multi source Widget to free.
+ * Returns: none.
+ */
+
+static void
+Destroy (w)
+ Widget w;
+{
+ RemoveOldStringOrFile((MultiSrcObject) w, True);
+}
+
+/************************************************************
+ *
+ * Public routines
+ *
+ ************************************************************/
+
+/* Function Name: XawMultiSourceFreeString
+ * Description: Frees the string returned by a get values call
+ * on the string when the source is of type string.
+ * Arguments: w - the MultiSrc widget.
+ * Returns: none.
+ *
+ * The public interface is XawAsciiSourceFreeString!
+ */
+
+void
+#if NeedFunctionPrototypes
+_XawMultiSourceFreeString(
+ Widget w)
+#else
+_XawMultiSourceFreeString(w)
+ Widget w;
+#endif
+{
+ MultiSrcObject src = (MultiSrcObject) w;
+
+/*if (src->multi_src.allocated_string&& src->multi_src.type != XawAsciiFile) {*/
+ /* ASSERT: src->multi_src.allocated_string -> we MUST free .string! */
+ if ( src->multi_src.allocated_string ) {
+ XtFree(src->multi_src.string);
+ src->multi_src.allocated_string = FALSE;
+ src->multi_src.string = NULL;
+ }
+}
+
+/* Function Name: _XawMultiSave
+ * Description: Saves all the pieces into a file or string as required.
+ * Arguments: w - the multiSrc Widget.
+ * Returns: TRUE if the save was successful.
+ *
+ * The public interface is XawAsciiSave(w)!
+ */
+
+Boolean
+#if NeedFunctionPrototypes
+_XawMultiSave(
+ Widget w)
+#else
+_XawMultiSave(w)
+ Widget w;
+#endif
+{
+ MultiSrcObject src = (MultiSrcObject) w;
+ XtAppContext app_con = XtWidgetToApplicationContext(w);
+ char * mb_string;
+
+/*
+ * If using the string in place then there is no need to play games
+ * to get the internal info into a readable string.
+ */
+
+ if (src->multi_src.use_string_in_place)
+ return(TRUE);
+
+ if (src->multi_src.type == XawAsciiFile) {
+
+ if (!src->multi_src.changes) /* No changes to save. */
+ return(TRUE);
+
+ mb_string = StorePiecesInString( src );
+
+ if ( mb_string != 0 ) {
+ if ( WriteToFile( mb_string, src->multi_src.string ) == FALSE ) {
+ XtFree( mb_string );
+ return( FALSE );
+ }
+ XtFree( mb_string );
+ src->multi_src.changes = FALSE;
+ return( TRUE );
+ } else {
+ /* If the buffer holds bad chars, don't touch it... */
+ XtAppWarningMsg( app_con,
+ "convertError", "multiSource", "XawError",
+ "Due to illegal characters, file not saved.", NULL, NULL);
+ return( FALSE );
+ }
+ }
+ else {
+
+ /* THIS FUNCTIONALITY IS UNDOCUMENTED, probably UNNEEDED? The manual
+ says this routine's only function is to save files to disk. -Sheeran */
+
+ mb_string = StorePiecesInString( src );
+
+ if ( mb_string == 0 ) {
+ /* If the buffer holds bad chars, don't touch it... */
+ XtAppWarningMsg( app_con,
+ "convertError", "multiSource", "XawError",
+ XtName( XtParent( (Widget) src ) ), NULL, NULL);
+ return( FALSE );
+ }
+
+ /* assert: mb_string holds good characters so the buffer is fine */
+ if (src->multi_src.allocated_string == TRUE)
+ XtFree(src->multi_src.string);
+ else
+ src->multi_src.allocated_string = TRUE;
+
+ src->multi_src.string = mb_string;
+ }
+ src->multi_src.changes = FALSE;
+ return(TRUE);
+}
+
+/* Function Name: XawMultiSaveAsFile
+ * Description: Save the current buffer as a file.
+ * Arguments: w - the MultiSrc widget.
+ * name - name of the file to save this file into.
+ * Returns: True if the save was sucessful.
+ *
+ * The public interface is XawAsciiSaveAsFile!
+ */
+
+Boolean
+#if NeedFunctionPrototypes
+_XawMultiSaveAsFile(
+ Widget w,
+ _Xconst char* name)
+#else
+_XawMultiSaveAsFile(w, name)
+ Widget w;
+ String name;
+#endif
+{
+ MultiSrcObject src = (MultiSrcObject) w;
+ String mb_string;
+ Boolean ret;
+
+ mb_string = StorePiecesInString( src );
+
+ if ( mb_string != 0 ) {
+ ret = WriteToFile( mb_string, name );
+ XtFree( mb_string );
+ return( ret );
+ }
+
+ /* otherwise there was a conversion error. So print widget name too. */
+ XtAppWarningMsg( XtWidgetToApplicationContext(w),
+ "convertError", "multiSource", "XawError",
+ XtName( XtParent( (Widget) src ) ), NULL, NULL);
+ return( False );
+}
+
+/************************************************************
+ *
+ * Private Functions.
+ *
+ ************************************************************/
+
+static void
+RemoveOldStringOrFile(src, checkString)
+ MultiSrcObject src;
+ Boolean checkString;
+{
+ FreeAllPieces(src);
+
+ if (checkString && src->multi_src.allocated_string) {
+ XtFree(src->multi_src.string);
+ src->multi_src.allocated_string = False;
+ src->multi_src.string = NULL;
+ }
+}
+
+/* Function Name: WriteToFile
+ * Description: Write the string specified to the begining of the file
+ * specified.
+ * Arguments: string - string to write.
+ * name - the name of the file
+ * Returns: returns TRUE if sucessful, FALSE otherwise.
+ */
+
+static Boolean
+WriteToFile(string, name)
+ String string, name;
+{
+ int fd;
+
+ if ( ((fd = creat(name, 0666)) == -1 ) ||
+ (write(fd, string, sizeof(unsigned char) * strlen(string)) == -1) )
+ return(FALSE);
+
+ if ( close(fd) == -1 )
+ return(FALSE);
+
+ return(TRUE);
+}
+
+
+/* Function Name: StorePiecesInString
+ * Description: store the pieces in memory into a char string.
+ * Arguments: src - the multiSrc to gather data from
+ * Returns: char *mb_string. Caller must free.
+ * or 0: conversion error. Caller must panic!
+ */
+
+static String
+StorePiecesInString(src)
+ MultiSrcObject src;
+{
+ wchar_t* wc_string;
+ char *mb_string;
+ int char_count = src->multi_src.length;
+ XawTextPosition first;
+ MultiPiece * piece;
+
+ /* I believe the char_count + 1 and the NULL termination are unneeded! FS*/
+
+ wc_string = (wchar_t*) XtMalloc((unsigned)(char_count + 1) * sizeof(wchar_t));
+
+ for (first = 0, piece = src->multi_src.first_piece ; piece != NULL;
+ first += piece->used, piece = piece->next)
+ (void) wcsncpy( wc_string + first, piece->text, piece->used );
+
+ wc_string[ char_count ] = (wchar_t)0; /* NULL terminate this sucker. */
+
+
+ /* This will refill all pieces to capacity. */
+
+ if ( src->multi_src.data_compression ) {
+ FreeAllPieces( src );
+ LoadPieces( src, NULL, (char *)wc_string );
+ }
+
+ /* Lastly, convert it to a MB format and send it back. */
+
+ mb_string = _XawTextWCToMB( XtDisplayOfObject( (Widget)src ),
+ wc_string, &char_count );
+
+ /* NOTE THAT mb_string MAY BE ZERO IF THE CONVERSION FAILED. */
+ XtFree( (char*) wc_string );
+ return( mb_string );
+}
+
+
+/* Function Name: InitStringOrFile.
+ * Description: Initializes the string or file.
+ * Arguments: src - the MultiSource.
+ * Returns: none - May exit though.
+ */
+
+static FILE *
+InitStringOrFile(src, newString)
+ MultiSrcObject src;
+ Boolean newString;
+{
+ char * open_mode;
+ FILE * file;
+ char fileName[TMPSIZ];
+ Display *d = XtDisplayOfObject((Widget)src);
+
+ if (src->multi_src.type == XawAsciiString) {
+
+ if (src->multi_src.string == NULL)
+ src->multi_src.length = 0;
+
+ else if (! src->multi_src.use_string_in_place) {
+ int length;
+ String temp = XtNewString(src->multi_src.string);
+ if ( src->multi_src.allocated_string )
+ XtFree( src->multi_src.string );
+ src->multi_src.allocated_string = True;
+ src->multi_src.string = temp;
+
+ length = strlen(src->multi_src.string);
+
+ /* Wasteful, throwing away the WC string, but need side effect! */
+ (void) _XawTextMBToWC(d, src->multi_src.string, &length);
+ src->multi_src.length = (XawTextPosition) length;
+ } else {
+ src->multi_src.length = strlen(src->multi_src.string);
+ /* In case the length resource is incorrectly set */
+ if (src->multi_src.length > src->multi_src.multi_length)
+ src->multi_src.multi_length = src->multi_src.length;
+
+ if (src->multi_src.multi_length == MAGIC_VALUE)
+ src->multi_src.piece_size = src->multi_src.length;
+ else
+ src->multi_src.piece_size = src->multi_src.multi_length + 1;
+ }
+
+ /*((TextWidget)src->object.parent)->text.lastPos = src->multi_src.length;*/
+ return(NULL);
+ }
+
+/*
+ * type is XawAsciiFile.
+ */
+
+ src->multi_src.is_tempfile = FALSE;
+
+ switch (src->text_src.edit_mode) {
+ case XawtextRead:
+ if (src->multi_src.string == NULL)
+ XtErrorMsg("NoFile", "multiSourceCreate", "XawError",
+ "Creating a read only disk widget and no file specified.",
+ NULL, 0);
+ open_mode = "r";
+ break;
+ case XawtextAppend:
+ case XawtextEdit:
+ if (src->multi_src.string == NULL) {
+
+ if ( src->multi_src.allocated_string )
+ XtFree( src->multi_src.string );
+ src->multi_src.allocated_string = False;
+ src->multi_src.string = fileName;
+
+ (void) tmpnam(src->multi_src.string);
+ src->multi_src.is_tempfile = TRUE;
+ open_mode = "w";
+ } else
+ open_mode = "r+";
+ break;
+ default:
+ XtErrorMsg("badMode", "multiSourceCreate", "XawError",
+ "Bad editMode for multi source; must be Read, Append or Edit.",
+ NULL, NULL);
+ }
+
+ /* Allocate new memory for the temp filename, because it is held in
+ * a stack memory buffer. We must verify that all routines that set
+ * .string first check .allocated_string and free it - plumbing Sheeran.
+ */
+ if (newString || src->multi_src.is_tempfile) {
+ if ( src->multi_src.allocated_string )
+ XtFree( src->multi_src.string );
+ src->multi_src.string = XtNewString(src->multi_src.string);
+ src->multi_src.allocated_string = TRUE;
+ }
+
+ if (!src->multi_src.is_tempfile) {
+ if ((file = fopen(src->multi_src.string, open_mode)) != 0) {
+ (void) fseek(file, (Off_t)0, 2);
+ src->multi_src.length = ftell (file);
+ return file;
+ } else {
+ String params[2];
+ Cardinal num_params = 2;
+
+ params[0] = src->multi_src.string;
+ params[1] = strerror(errno);
+ XtAppWarningMsg(XtWidgetToApplicationContext((Widget)src),
+ "openError", "multiSourceCreate", "XawWarning",
+ "Cannot open file %s; %s", params, &num_params);
+ }
+ }
+ src->multi_src.length = 0;
+ return((FILE *)NULL);
+#undef StrLen
+}
+
+/* LoadPieces: This routine takes either the MB contents of open file `file' or the
+MB contents of string or the MB contents of src->multi_src.string and places
+them in Pieces in WC format.
+
+CAUTION: You must have src->multi_src.length set to file length bytes
+when src->multi_src.type == XawAsciiFile. src->multi_src.length must be
+the length of the parameter string if string is non-NULL. */
+
+static void
+LoadPieces(src, file, string)
+ MultiSrcObject src;
+ FILE* file;
+ char* string;
+{
+ Display *d = XtDisplayOfObject((Widget)src);
+ wchar_t* local_str, *ptr;
+ MultiPiece* piece = NULL;
+ XawTextPosition left;
+ int bytes = sizeof(wchar_t);
+ char* temp_mb_holder = NULL;
+
+ /*
+ * This is tricky - the _XawTextMBtoWC converter uses its 3rd arg
+ * in as MB length, out as WC length. We want local_length to be
+ * WC count.
+ */
+ int local_length = src->multi_src.length;
+
+ if (string != NULL) {
+ /*
+ * ASSERT: IF our caller passed a non-null string, THEN
+ * src->multi_src.length is currently string's * byte count,
+ * AND string is in a MB format.
+ */
+ local_str = _XawTextMBToWC(d, (char *)string, &local_length);
+ src->multi_src.length = (XawTextPosition) local_length;
+ } else if (src->multi_src.type != XawAsciiFile) {
+ /*
+ * here, we are not changing the contents, just reloading,
+ * so don't change len...
+ */
+ local_length = src->multi_src.string ?
+ strlen( src->multi_src.string ) : 0;
+ local_str = _XawTextMBToWC( d, (char*)src->multi_src.string, &local_length );
+ } else {
+ if (src->multi_src.length != 0) {
+ temp_mb_holder =
+ XtMalloc((unsigned)(src->multi_src.length + 1) * sizeof(unsigned char));
+ fseek(file, (Off_t)0, 0);
+ src->multi_src.length = fread (temp_mb_holder,
+ (Size_t)sizeof(unsigned char),
+ (Size_t)src->multi_src.length, file);
+ if (src->multi_src.length <= 0)
+ XtAppErrorMsg( XtWidgetToApplicationContext ((Widget) src),
+ "readError", "multiSource", "XawError",
+ "fread returned error.", NULL, NULL);
+ local_length = src->multi_src.length;
+ local_str = _XawTextMBToWC(d, temp_mb_holder, &local_length);
+ src->multi_src.length = local_length;
+
+ if ( local_str == 0 ) {
+ String params[2];
+ Cardinal num_params;
+ static char err_text[] =
+ "<<< FILE CONTENTS NOT REPRESENTABLE IN THIS LOCALE >>>";
+
+ params[0] = XtName(XtParent((Widget)src));
+ params[1] = src->multi_src.string;
+ num_params = 2;
+
+ XtAppWarningMsg( XtWidgetToApplicationContext((Widget)src),
+ "readLocaleError", "multiSource", "XawError",
+ "%s: The file `%s' contains characters not representable in this locale.",
+ params, &num_params);
+ src->multi_src.length = sizeof err_text;
+ local_length = src->multi_src.length;
+ local_str = _XawTextMBToWC(d, err_text, &local_length);
+ src->multi_src.length = local_length;
+ }
+ } else { /*ASSERT that since following while loop looks at local_length
+ this isn't needed. Sheeran, Omron KK, 1993/07/15
+ temp_mb_holder[src->multi_src.length] = '\0';*/
+ local_str = (wchar_t*)temp_mb_holder;
+ }
+ }
+
+ if (src->multi_src.use_string_in_place) {
+ piece = AllocNewPiece(src, piece);
+ piece->used = Min(src->multi_src.length, src->multi_src.piece_size);
+ piece->text = (wchar_t*)src->multi_src.string;
+ return;
+ }
+
+ ptr = local_str;
+ left = local_length;
+
+ do {
+ piece = AllocNewPiece(src, piece);
+
+ piece->text = (wchar_t*)XtMalloc(src->multi_src.piece_size * bytes);
+ piece->used = Min(left, src->multi_src.piece_size);
+ if (piece->used != 0)
+ (void) wcsncpy(piece->text, ptr, piece->used);
+
+ left -= piece->used;
+ ptr += piece->used;
+ } while (left > 0);
+
+ if ( temp_mb_holder )
+ XtFree( (char*) temp_mb_holder );
+}
+
+
+/* Function Name: AllocNewPiece
+ * Description: Allocates a new piece of memory.
+ * Arguments: src - The MultiSrc Widget.
+ * prev - the piece just before this one, or NULL.
+ * Returns: the allocated piece.
+ */
+
+static MultiPiece *
+AllocNewPiece(src, prev)
+ MultiSrcObject src;
+ MultiPiece * prev;
+{
+ MultiPiece * piece = XtNew(MultiPiece);
+
+ if (prev == NULL) {
+ src->multi_src.first_piece = piece;
+ piece->next = NULL;
+ }
+ else {
+ if (prev->next != NULL)
+ (prev->next)->prev = piece;
+ piece->next = prev->next;
+ prev->next = piece;
+ }
+
+ piece->prev = prev;
+
+ return(piece);
+}
+
+/* Function Name: FreeAllPieces
+ * Description: Frees all the pieces
+ * Arguments: src - The MultiSrc Widget.
+ * Returns: none.
+ */
+
+static void
+FreeAllPieces(src)
+ MultiSrcObject src;
+{
+ MultiPiece * next, * first = src->multi_src.first_piece;
+
+ if (first->prev != NULL)
+ printf("Xaw MultiSrc Object: possible memory leak in FreeAllPieces().\n");
+
+ for ( ; first != NULL ; first = next ) {
+ next = first->next;
+ RemovePiece(src, first);
+ }
+}
+
+/* Function Name: RemovePiece
+ * Description: Removes a piece from the list.
+ * Arguments:
+ * piece - the piece to remove.
+ * Returns: none.
+ */
+
+static void
+RemovePiece(src, piece)
+ MultiSrcObject src;
+ MultiPiece* piece;
+{
+ if (piece->prev == NULL)
+ src->multi_src.first_piece = piece->next;
+ else
+ (piece->prev)->next = piece->next;
+
+ if (piece->next != NULL)
+ (piece->next)->prev = piece->prev;
+
+ if (!src->multi_src.use_string_in_place)
+ XtFree((char *)piece->text);
+
+ XtFree((char *)piece);
+}
+
+/* Function Name: FindPiece
+ * Description: Finds the piece containing the position indicated.
+ * Arguments: src - The MultiSrc Widget.
+ * position - the position that we are searching for.
+ * RETURNED first - the position of the first character in this piece.
+ * Returns: piece - the piece that contains this position.
+ */
+
+static MultiPiece *
+FindPiece(src, position, first)
+ MultiSrcObject src;
+ XawTextPosition position, *first;
+{
+ MultiPiece * old_piece, * piece = src->multi_src.first_piece;
+ XawTextPosition temp;
+
+ for ( temp = 0 ; piece != NULL ; temp += piece->used, piece = piece->next ) {
+ *first = temp;
+ old_piece = piece;
+
+ if ((temp + piece->used) > position)
+ return(piece);
+ }
+ return(old_piece); /* if we run off the end the return the last piece */
+}
+
+/* Function Name: BreakPiece
+ * Description: Breaks a full piece into two new pieces.
+ * Arguments: src - The MultiSrc Widget.
+ * piece - the piece to break.
+ * Returns: none.
+ */
+
+#define HALF_PIECE (src->multi_src.piece_size/2)
+
+static void
+BreakPiece(src, piece)
+ MultiSrcObject src;
+ MultiPiece* piece;
+{
+ MultiPiece * new = AllocNewPiece(src, piece);
+
+ new->text = (wchar_t*)XtMalloc(src->multi_src.piece_size * sizeof(wchar_t));
+ (void) wcsncpy(new->text, piece->text + HALF_PIECE,
+ src->multi_src.piece_size - HALF_PIECE);
+ piece->used = HALF_PIECE;
+ new->used = src->multi_src.piece_size - HALF_PIECE;
+}
+
+/* Convert string "XawAsciiString" and "XawAsciiFile" to quarks. */
+
+/* ARGSUSED */
+static void
+CvtStringToMultiType(args, num_args, fromVal, toVal)
+ XrmValuePtr args; /* unused */
+ Cardinal* num_args; /* unused */
+ XrmValuePtr fromVal;
+ XrmValuePtr toVal;
+{
+ static XawAsciiType type;
+ static XrmQuark XtQEstring = NULLQUARK;
+ static XrmQuark XtQEfile;
+ XrmQuark q;
+ char lowerName[40];
+
+ if (XtQEstring == NULLQUARK) {
+ XtQEstring = XrmPermStringToQuark(XtEstring);
+ XtQEfile = XrmPermStringToQuark(XtEfile);
+ }
+
+ if (strlen ((char*) fromVal->addr) < sizeof lowerName) {
+ XmuCopyISOLatin1Lowered(lowerName, (char *) fromVal->addr);
+ q = XrmStringToQuark(lowerName);
+
+ if (q == XtQEstring) type = XawAsciiString;
+ else if (q == XtQEfile) type = XawAsciiFile;
+ else {
+ toVal->size = 0;
+ toVal->addr = NULL;
+ return;
+ }
+ toVal->size = sizeof type;
+ toVal->addr = (XPointer) &type;
+ return;
+ }
+ toVal->size = 0;
+ toVal->addr = NULL;
+}
diff --git a/src/Paned.c b/src/Paned.c
new file mode 100644
index 0000000..2c88c37
--- /dev/null
+++ b/src/Paned.c
@@ -0,0 +1,1944 @@
+/* $Xorg: Paned.c,v 1.4 2001/02/09 02:03:45 xorgcvs Exp $ */
+
+/***********************************************************
+
+Copyright 1987, 1988, 1994, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+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
+OPEN GROUP 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 Open Group 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 Open Group.
+
+
+Copyright 1987, 1988 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+******************************************************************/
+
+/*
+ * Paned.c - Paned Composite Widget.
+ *
+ * Updated and significantly modified from the Athena VPaned Widget.
+ *
+ * Date: March 1, 1989
+ *
+ * By: Chris D. Peterson
+ * MIT X Consortium
+ * kit@expo.lcs.mit.edu
+ */
+
+#include <X11/IntrinsicP.h>
+#include <X11/cursorfont.h>
+#include <X11/StringDefs.h>
+
+#include <X11/Xmu/Misc.h>
+#include <X11/Xmu/Converters.h>
+
+#include <X11/Xaw/XawInit.h>
+#include <X11/Xaw/Grip.h>
+#include <X11/Xaw/PanedP.h>
+
+/* I don't know why Paned.c calls _XawImCallVendorShellExtResize, but... */
+#include <X11/Xaw/XawImP.h>
+
+#include <ctype.h>
+
+typedef enum {UpLeftPane = 'U', LowRightPane = 'L',
+ ThisBorderOnly = 'T', AnyPane = 'A' } Direction;
+
+#define NO_INDEX -100
+#define IS_GRIP NULL
+
+#define PaneInfo(w) ((Pane)(w)->core.constraints)
+#define HasGrip(w) (PaneInfo(w)->grip != NULL)
+#define IsPane(w) ((w)->core.widget_class != gripWidgetClass)
+#define PaneIndex(w) (PaneInfo(w)->position)
+#define IsVert(w) ( (w)->paned.orientation == XtorientVertical )
+
+#define ForAllPanes(pw, childP) \
+ for ( (childP) = (pw)->composite.children ; \
+ (childP) < (pw)->composite.children + (pw)->paned.num_panes ; \
+ (childP)++ )
+
+#define ForAllChildren(pw, childP) \
+ for ( (childP) = (pw)->composite.children ; \
+ (childP) < (pw)->composite.children + (pw)->composite.num_children ; \
+ (childP)++ )
+
+/*****************************************************************************
+ *
+ * Full instance record declaration
+ *
+ ****************************************************************************/
+
+static char defGripTranslations[] =
+ "<Btn1Down>: GripAction(Start, UpLeftPane) \n\
+ <Btn2Down>: GripAction(Start, ThisBorderOnly) \n\
+ <Btn3Down>: GripAction(Start, LowRightPane) \n\
+ <Btn1Motion>: GripAction(Move, UpLeft) \n\
+ <Btn2Motion>: GripAction(Move, ThisBorder) \n\
+ <Btn3Motion>: GripAction(Move, LowRight) \n\
+ Any<BtnUp>: GripAction(Commit)";
+
+#define offset(field) XtOffsetOf(PanedRec, paned.field)
+
+static XtResource resources[] = {
+ {XtNinternalBorderColor, XtCBorderColor, XtRPixel, sizeof(Pixel),
+ offset(internal_bp), XtRString,
+ (XtPointer) XtDefaultForeground},
+ {XtNinternalBorderWidth, XtCBorderWidth, XtRDimension, sizeof(Dimension),
+ offset(internal_bw), XtRImmediate, (XtPointer) 1},
+ {XtNgripIndent, XtCGripIndent, XtRPosition, sizeof(Position),
+ offset(grip_indent), XtRImmediate, (XtPointer) 10},
+ {XtNrefigureMode, XtCBoolean, XtRBoolean, sizeof(Boolean),
+ offset(refiguremode), XtRImmediate, (XtPointer) TRUE},
+ {XtNgripTranslations, XtCTranslations, XtRTranslationTable,
+ sizeof(XtTranslations),
+ offset(grip_translations), XtRString, (XtPointer)defGripTranslations},
+ {XtNorientation, XtCOrientation, XtROrientation, sizeof(XtOrientation),
+ offset(orientation), XtRImmediate, (XtPointer) XtorientVertical},
+
+ /* Cursors - both horiz and vertical have to work. */
+
+ {XtNcursor, XtCCursor, XtRCursor, sizeof(Cursor),
+ offset(cursor), XtRImmediate, None},
+ {XtNgripCursor, XtCCursor, XtRCursor, sizeof(Cursor),
+ offset(grip_cursor), XtRImmediate, None},
+ {XtNverticalGripCursor, XtCCursor, XtRCursor, sizeof(Cursor),
+ offset(v_grip_cursor), XtRString, "sb_v_double_arrow"},
+ {XtNhorizontalGripCursor, XtCCursor, XtRCursor, sizeof(Cursor),
+ offset(h_grip_cursor), XtRString, "sb_h_double_arrow"},
+
+ {XtNbetweenCursor, XtCCursor, XtRCursor, sizeof(Cursor),
+ offset(adjust_this_cursor), XtRString, None},
+ {XtNverticalBetweenCursor, XtCCursor, XtRCursor, sizeof(Cursor),
+ offset(v_adjust_this_cursor), XtRString, "sb_left_arrow"},
+ {XtNhorizontalBetweenCursor, XtCCursor, XtRCursor, sizeof(Cursor),
+ offset(h_adjust_this_cursor), XtRString, "sb_up_arrow"},
+
+ {XtNupperCursor, XtCCursor, XtRCursor, sizeof(Cursor),
+ offset(adjust_upper_cursor), XtRString, "sb_up_arrow"},
+ {XtNlowerCursor, XtCCursor, XtRCursor, sizeof(Cursor),
+ offset(adjust_lower_cursor), XtRString, "sb_down_arrow"},
+ {XtNleftCursor, XtCCursor, XtRCursor, sizeof(Cursor),
+ offset(adjust_left_cursor), XtRString, "sb_left_arrow"},
+ {XtNrightCursor, XtCCursor, XtRCursor, sizeof(Cursor),
+ offset(adjust_right_cursor), XtRString, "sb_right_arrow"},
+};
+
+#undef offset
+
+#define offset(field) XtOffsetOf(PanedConstraintsRec, paned.field)
+
+static XtResource subresources[] = {
+ {XtNallowResize, XtCBoolean, XtRBoolean, sizeof(Boolean),
+ offset(allow_resize), XtRImmediate, (XtPointer) FALSE},
+ {XtNposition, XtCPosition, XtRInt, sizeof(int),
+ offset(position), XtRImmediate, (XtPointer) 0},
+ {XtNmin, XtCMin, XtRDimension, sizeof(Dimension),
+ offset(min), XtRImmediate, (XtPointer) PANED_GRIP_SIZE},
+ {XtNmax, XtCMax, XtRDimension, sizeof(Dimension),
+ offset(max), XtRImmediate, (XtPointer) ~0},
+ {XtNpreferredPaneSize, XtCPreferredPaneSize, XtRDimension,
+ sizeof(Dimension), offset(preferred_size),
+ XtRImmediate, (XtPointer) PANED_ASK_CHILD},
+ {XtNresizeToPreferred, XtCBoolean, XtRBoolean, sizeof(Boolean),
+ offset(resize_to_pref), XtRImmediate, (XtPointer) FALSE},
+ {XtNskipAdjust, XtCBoolean, XtRBoolean, sizeof(Boolean),
+ offset(skip_adjust), XtRImmediate, (XtPointer) FALSE},
+ {XtNshowGrip, XtCShowGrip, XtRBoolean, sizeof(Boolean),
+ offset(show_grip), XtRImmediate, (XtPointer) TRUE},
+};
+
+#undef offset
+
+static void ClassInitialize(), Initialize();
+static void Realize(), Resize();
+static void Redisplay();
+static void GetGCs(), ReleaseGCs();
+static void RefigureLocationsAndCommit();
+static Boolean SetValues();
+static XtGeometryResult GeometryManager();
+static void ChangeManaged();
+static void InsertChild();
+static void DeleteChild();
+static Boolean PaneSetValues();
+static Dimension PaneSize(), GetRequestInfo();
+static Boolean SatisfiesRule1(), SatisfiesRule2(), SatisfiesRule3();
+
+static void PushPaneStack();
+static void GetPaneStack();
+static Boolean PopPaneStack();
+static void ClearPaneStack();
+
+#define SuperClass ((ConstraintWidgetClass)&constraintClassRec)
+
+PanedClassRec panedClassRec = {
+ {
+/* core class fields */
+ /* superclass */ (WidgetClass) SuperClass,
+ /* class name */ "Paned",
+ /* size */ sizeof(PanedRec),
+ /* class_initialize */ ClassInitialize,
+ /* class_part init */ NULL,
+ /* class_inited */ FALSE,
+ /* initialize */ Initialize,
+ /* initialize_hook */ NULL,
+ /* realize */ Realize,
+ /* actions */ NULL,
+ /* num_actions */ 0,
+ /* resources */ resources,
+ /* resource_count */ XtNumber(resources),
+ /* xrm_class */ NULLQUARK,
+ /* compress_motion */ TRUE,
+ /* compress_exposure */ TRUE,
+ /* compress_enterleave*/ TRUE,
+ /* visible_interest */ FALSE,
+ /* destroy */ ReleaseGCs,
+ /* resize */ Resize,
+ /* expose */ Redisplay,
+ /* set_values */ SetValues,
+ /* set_values_hook */ NULL,
+ /* set_values_almost */ XtInheritSetValuesAlmost,
+ /* get_values_hook */ NULL,
+ /* accept_focus */ NULL,
+ /* version */ XtVersion,
+ /* callback_private */ NULL,
+ /* tm_table */ NULL,
+ /* query_geometry */ XtInheritQueryGeometry,
+ /* display_accelerator*/ XtInheritDisplayAccelerator,
+ /* extension */ NULL
+ }, {
+/* composite class fields */
+ /* geometry_manager */ GeometryManager,
+ /* change_managed */ ChangeManaged,
+ /* insert_child */ InsertChild,
+ /* delete_child */ DeleteChild,
+ /* extension */ NULL
+ }, {
+/* constraint class fields */
+ /* subresources */ subresources,
+ /* subresource_count */ XtNumber(subresources),
+ /* constraint_size */ sizeof(PanedConstraintsRec),
+ /* initialize */ NULL,
+ /* destroy */ NULL,
+ /* set_values */ PaneSetValues,
+ /* extension */ NULL
+ }
+};
+
+WidgetClass panedWidgetClass = (WidgetClass) &panedClassRec;
+
+/* For compatibility. */
+WidgetClass vPanedWidgetClass = (WidgetClass) &panedClassRec;
+
+/***********************************************************
+ *
+ * Private Functions.
+ *
+ ************************************************************/
+
+/* Function Name: AdjustPanedSize
+ * Description: Adjusts the size of the pane.
+ * Arguments: pw - the paned widget to adjust.
+ * off_size - the new off_size to use.
+ * result_ret - result of query ** RETURNED **
+ * on_size_ret - the new on_size ** RETURNED **
+ * off_size_ret - the new off_size ** RETURNED **
+ * Returns: the amount of change in size.
+ */
+
+static void
+AdjustPanedSize(pw, off_size, result_ret, on_size_ret, off_size_ret)
+PanedWidget pw;
+Dimension off_size;
+XtGeometryResult * result_ret;
+Dimension * on_size_ret, * off_size_ret;
+{
+ Dimension old_size = PaneSize( (Widget) pw, IsVert(pw));
+ Dimension newsize = 0;
+ Widget * childP;
+ XtWidgetGeometry request, reply;
+ request.request_mode = CWWidth | CWHeight;
+
+ ForAllPanes(pw, childP) {
+ int size = Max(PaneInfo(*childP)->size, (int)PaneInfo(*childP)->min);
+ AssignMin(size, (int) PaneInfo(*childP)->max);
+ newsize += size + pw->paned.internal_bw;
+ }
+ newsize -= pw->paned.internal_bw;
+
+ if (newsize < 1) newsize = 1;
+
+ if ( IsVert(pw) ) {
+ request.width = off_size;
+ request.height = newsize;
+ }
+ else {
+ request.width = newsize;
+ request.height = off_size;
+ }
+
+ if (result_ret != NULL) {
+ request.request_mode |= XtCWQueryOnly;
+
+ *result_ret = XtMakeGeometryRequest( (Widget) pw, &request, &reply );
+ _XawImCallVendorShellExtResize( (Widget) pw );
+
+ if ( (newsize == old_size) || (*result_ret == XtGeometryNo) ) {
+ *on_size_ret = old_size;
+ *off_size_ret = off_size;
+ return;
+ }
+ if (*result_ret != XtGeometryAlmost) {
+ *on_size_ret = GetRequestInfo( &request, IsVert(pw) );
+ *off_size_ret = GetRequestInfo( &request, !IsVert(pw) );
+ return;
+ }
+ *on_size_ret = GetRequestInfo( &reply, IsVert(pw) );
+ *off_size_ret = GetRequestInfo( &reply, !IsVert(pw) );
+ return;
+ }
+
+ if (newsize == old_size) return;
+
+ if (XtMakeGeometryRequest( (Widget) pw,
+ &request, &reply) == XtGeometryAlmost)
+ XtMakeGeometryRequest( (Widget) pw, &reply, &request);
+}
+
+/* Function Name: PaneSize
+ * Description: returns the width or height of the pane depending
+ * upon the orientation we are using.
+ * Arguments: w - and widget.
+ * vertical - TRUE if this is vertically oriented pane.
+ * Returns: the size requested
+ *
+ * vertical - return height
+ * !vertical - return width
+ */
+
+static Dimension
+PaneSize(w, vertical)
+Widget w;
+Boolean vertical;
+{
+ if (vertical) return (w->core.height);
+ return (w->core.width);
+}
+
+/* Function Name: GetRequestInfo
+ * Description: returns request information.
+ * Arguments: geo_struct - a geometry struct to get information out of.
+ * vert - TRUE if this is a vertical paned widget.
+ * Returns: the request information.
+ */
+
+static Dimension
+GetRequestInfo(geo_struct, vert)
+XtWidgetGeometry * geo_struct;
+Boolean vert;
+{
+ if ( vert ) return ( (Dimension) geo_struct->height);
+ return ( (Dimension) geo_struct->width);
+}
+
+/* Function Name: ChoosePaneToResize.
+ * Description: This function chooses a pane to resize.
+ * They are chosen using the following rules:
+ *
+ * 1) size < max && size > min
+ * 2) skip adjust == FALSE
+ * 3) widget not its prefered height &&
+ * this change will bring it closer &&
+ * The user has not resized this pane.
+ *
+ * If no widgets are found that fits all the rules then
+ * rule #3 is broken.
+ * If there are still no widgets found than
+ * rule #2 is broken.
+ * Rule #1 is never broken.
+ * If no widgets are found then NULL is returned.
+ *
+ * Arguments: pw - the paned widget.
+ * paneindex - the index of the current pane.
+ * dir - direction to search first.
+ * shrink - TRUE if we need to shrink a pane, FALSE otherwise.
+ * Returns: pane to resize or NULL.
+ */
+
+static Pane
+ChoosePaneToResize(pw, paneindex, dir, shrink)
+PanedWidget pw;
+int paneindex;
+Direction dir;
+Boolean shrink;
+{
+ Widget *childP;
+ int rules = 3;
+ Direction _dir = dir;
+ int _index = paneindex;
+
+ if ( (paneindex == NO_INDEX) || (dir == AnyPane) ) { /* Use defaults. */
+ _dir = LowRightPane; /* Go up. - really. */
+ _index = pw->paned.num_panes - 1; /* Start the last pane, and work
+ backwards. */
+ }
+ childP = pw->composite.children + _index;
+
+ /* CONSTCOND */
+ while(TRUE) {
+ Pane pane = PaneInfo(*childP);
+
+ if ( (rules < 3 || SatisfiesRule3(pane, shrink)) &&
+ (rules < 2 || SatisfiesRule2(pane)) &&
+ (SatisfiesRule1(pane, shrink)) &&
+ ((paneindex != PaneIndex(*childP)) || (dir == AnyPane)) )
+ return(pane);
+
+/*
+ * This is counter-intuitive, but if we are resizing the pane
+ * above the grip we want to choose a pane below the grip to lose,
+ * and visa-versa.
+ */
+
+ if (_dir == LowRightPane) --childP; else ++childP;
+
+/*
+ * If we have come to and edge then reduce the rule set, and try again.
+ * If we are reduced the rules to none, then return NULL.
+ */
+
+ if ( (childP - pw->composite.children < 0) ||
+ (childP - pw->composite.children >= pw->paned.num_panes) ) {
+ if (--rules < 1) /* less strict rules. */
+ return(NULL);
+ childP = pw->composite.children + _index;
+ }
+ }
+}
+
+/* Function Name: StatisfiesRule1
+ * Description: check for to see if this pane satisfies rule 1.
+ * Arguments: pane - the pane to check.
+ * shrink -TRUE if we want to shrink this pane, FALSE otherwise
+ * Returns: TRUE if the rule is satisfied.
+ */
+
+static Boolean
+SatisfiesRule1(pane, shrink)
+Pane pane;
+Boolean shrink;
+{
+ return( (shrink && (pane->size != pane->min)) ||
+ (!shrink && (pane->size != pane->max)) );
+}
+
+/* Function Name: StatisfiesRule2
+ * Description: check for to see if this pane satisfies rule 2.
+ * Arguments: pane - the pane to check.
+ * Returns: TRUE if the rule is satisfied.
+ */
+
+static Boolean
+SatisfiesRule2(pane)
+Pane pane;
+{
+ return(!pane->skip_adjust || pane->paned_adjusted_me);
+}
+
+/* Function Name: StatisfiesRule3
+ * Description: check for to see if this pane satisfies rule 3.
+ * Arguments: pane - the pane to check.
+ * shrink -TRUE if we want to shrink this pane, FALSE otherwise
+ * Returns: TRUE if the rule is satisfied.
+ */
+
+static Boolean
+SatisfiesRule3(pane, shrink)
+Pane pane;
+Boolean shrink;
+{
+ return ( pane->paned_adjusted_me &&
+ ( (shrink && ((int)pane->wp_size <= pane->size)) ||
+ (!shrink && ((int)pane->wp_size >= pane->size))) );
+}
+
+/* Function Name: LoopAndRefigureChildren.
+ * Description: if we are resizing either the UpleftPane or LowRight Pane
+ * loop through all the children to see if any will allow us
+ * to resize them.
+ * Arguments: pw - the paned widget.
+ * paneindex - the number of the pane border we are moving.
+ * dir - the pane to move (either UpLeftPane or LowRightPane).
+ * sizeused - current amount of space used.
+ * THIS VALUE IS USED AND RETURNED.
+ * Returns: none.
+ */
+
+static void
+LoopAndRefigureChildren(pw, paneindex, dir, sizeused)
+PanedWidget pw;
+int paneindex, *sizeused;
+Direction dir;
+{
+ int pane_size = (int) PaneSize( (Widget) pw, IsVert(pw));
+ Boolean shrink = (*sizeused > pane_size);
+
+ if (dir == LowRightPane) paneindex++;
+
+ while (*sizeused != pane_size) { /* While all panes do not fit properly. */
+/*
+ * Choose a pane to resize.
+ * First look on the Pane Stack, and then go hunting for another one.
+ * If we fail to find a pane to resize then give up.
+ */
+ Pane pane;
+ int start_size;
+ Dimension old;
+ Boolean rule3_ok = FALSE, from_stack = TRUE;
+
+ GetPaneStack(pw, shrink, &pane, &start_size);
+ if (pane == NULL) {
+ pane = ChoosePaneToResize(pw, paneindex, dir, shrink);
+ if (pane == NULL)
+ return; /* no one to resize, give up. */
+
+ rule3_ok = SatisfiesRule3(pane, shrink);
+ from_stack = FALSE;
+ PushPaneStack(pw, pane);
+ }
+
+
+/*
+ * Try to resize this pane so that all panes will fit, take min and max
+ * into account.
+ */
+ old = pane->size;
+ pane->size += pane_size - *sizeused;
+
+ if (from_stack) {
+ if (shrink) {
+ AssignMax(pane->size, start_size);
+ } /* don't remove these braces. */
+ else
+ AssignMin(pane->size, start_size);
+
+ if (pane->size == start_size) (void) PopPaneStack(pw);
+ }
+ else if (rule3_ok) {
+ if (shrink) {
+ AssignMax(pane->size, (int) pane->wp_size);
+ } /* don't remove these braces. */
+ else
+ AssignMin(pane->size, (int) pane->wp_size);
+ }
+
+ pane->paned_adjusted_me = (pane->size != pane->wp_size);
+ AssignMax(pane->size, (int) pane->min);
+ AssignMin(pane->size, (int) pane->max);
+ *sizeused += (pane->size - old);
+ }
+}
+
+/* Function Name: RefigureLocations
+ * Description: refigures all locations of children.
+ * Arguments: pw - the paned widget.
+ * paneindex - child to start refiguring at.
+ * dir - direction to move from child.
+ * Returns: none.
+ *
+ * There are special arguments to paneindex and dir, they are:
+ * paneindex - NO_INDEX.
+ * dir - AnyPane.
+ *
+ * If either of these is true then all panes may be resized and
+ * the choosing of panes procedes in reverse order starting with the
+ * last child.
+ */
+
+static void
+RefigureLocations(pw, paneindex, dir)
+PanedWidget pw;
+int paneindex;
+Direction dir;
+{
+ Widget *childP;
+ int pane_size = (int) PaneSize( (Widget) pw, IsVert(pw) );
+ int sizeused = 0;
+ Position loc = 0;
+
+ if (pw->paned.num_panes == 0 || !pw->paned.refiguremode) return;
+
+/*
+ * Get an initial estimate of the size we will use.
+ */
+
+ ForAllPanes(pw, childP) {
+ Pane pane = PaneInfo(*childP);
+ AssignMax(pane->size, (int) pane->min);
+ AssignMin(pane->size, (int) pane->max);
+ sizeused += (int) pane->size + (int) pw->paned.internal_bw;
+ }
+ sizeused -= (int) pw->paned.internal_bw;
+
+ if ( (dir != ThisBorderOnly) && (sizeused != pane_size) )
+ LoopAndRefigureChildren(pw, paneindex, dir, &sizeused);
+
+/*
+ * If we still are not the right size, then tell the pane that
+ * wanted to resize that it can't.
+ */
+
+
+ if ( (paneindex != NO_INDEX) && (dir != AnyPane) ) {
+ Pane pane = PaneInfo(*(pw->composite.children + paneindex));
+ Dimension old = pane->size;
+
+ pane->size += pane_size - sizeused;
+ AssignMax(pane->size, (int) pane->min);
+ AssignMin(pane->size, (int) pane->max);
+ sizeused += pane->size - old;
+ }
+
+/*
+ * It is possible that the panes will not fit inside the vpaned widget, but
+ * we have tried out best.
+ *
+ * Assign each pane a location.
+ */
+
+ ForAllPanes(pw, childP) {
+ PaneInfo(*childP)->delta = loc;
+ loc += PaneInfo(*childP)->size + pw->paned.internal_bw;
+ }
+}
+
+/* Function Name: CommitNewLocations
+ * Description: Commits all of the previously figured locations.
+ * Arguments: pw - the paned widget.
+ * Returns: none.
+ */
+
+static void
+CommitNewLocations(pw)
+PanedWidget pw;
+{
+ Widget *childP;
+ XWindowChanges changes;
+
+ changes.stack_mode = Above;
+
+ ForAllPanes(pw, childP) {
+ Pane pane = PaneInfo(*childP);
+ Widget grip = pane->grip; /* may be NULL. */
+
+ if (IsVert(pw)) {
+ XtMoveWidget(*childP, (Position) 0, pane->delta);
+ XtResizeWidget(*childP, pw->core.width, (Dimension) pane->size,
+ (Dimension) 0);
+
+ if (HasGrip(*childP)) { /* Move and Display the Grip */
+ changes.x = pw->core.width - pw->paned.grip_indent -
+ grip->core.width - grip->core.border_width*2;
+ changes.y = (*childP)->core.y + (*childP)->core.height -
+ grip->core.height/2 - grip->core.border_width +
+ pw->paned.internal_bw/2;
+ }
+ }
+ else {
+ XtMoveWidget(*childP, pane->delta, (Position) 0);
+ XtResizeWidget(*childP, (Dimension) pane->size, pw->core.height,
+ (Dimension) 0);
+
+
+ if (HasGrip(*childP)) { /* Move and Display the Grip */
+ changes.x = (*childP)->core.x + (*childP)->core.width -
+ grip->core.width/2 - grip->core.border_width +
+ pw->paned.internal_bw/2;
+ changes.y = pw->core.height - pw->paned.grip_indent -
+ grip->core.height - grip->core.border_width*2;
+ }
+ }
+
+/*
+ * This should match XtMoveWidget, except that we're also insuring the
+ * grip is Raised in the same request.
+ */
+
+ if (HasGrip(*childP)) {
+ grip->core.x = changes.x;
+ grip->core.y = changes.y;
+
+ if (XtIsRealized(pane->grip))
+ XConfigureWindow( XtDisplay(pane->grip), XtWindow(pane->grip),
+ CWX | CWY | CWStackMode, &changes );
+ }
+ }
+ ClearPaneStack(pw);
+}
+
+/* Function Name: RefigureLocationsAndCommit
+ * Description: Refigures all locations in a paned widget and
+ * commits them immediately.
+ * Arguments: pw - the paned widget.
+ * Returns: none
+ *
+ * This function does nothing if any of the following are true.
+ * o refiguremode is false.
+ * o The widget is unrealized.
+ * o There are no panes is the paned widget.
+ *
+ * NOTE: This is the resize Procedure for the Paned widget.
+ */
+
+static void
+RefigureLocationsAndCommit(w)
+Widget w;
+{
+ PanedWidget pw = (PanedWidget) w;
+ if (pw->paned.refiguremode && XtIsRealized( (Widget) pw) &&
+ pw->paned.num_panes > 0 ) {
+ RefigureLocations(pw, NO_INDEX, AnyPane);
+ CommitNewLocations(pw);
+ }
+}
+
+/* Function Name: _DrawRect
+ * Description: Draws a rectangle in the proper orientation.
+ * Arguments: pw - the paned widget.
+ * gc - gc to used for the draw.
+ * on_olc, off_loc - location of upper left corner of rect.
+ * on_size, off_size - size of rectangle.
+ * Returns: none
+ */
+
+static void
+_DrawRect(pw, gc, on_loc, off_loc, on_size, off_size)
+PanedWidget pw;
+GC gc;
+int on_loc, off_loc;
+unsigned int on_size, off_size;
+{
+ if (IsVert(pw))
+ XFillRectangle(XtDisplay(pw), XtWindow(pw), gc,
+ off_loc, on_loc, off_size, on_size);
+ else
+ XFillRectangle(XtDisplay(pw), XtWindow(pw), gc,
+ on_loc, off_loc, on_size, off_size);
+}
+
+/* Function Name: _DrawInternalBorders
+ * Description: Draws the internal borders into the paned widget.
+ * Arguments: pw - the paned widget.
+ * gc - the GC to use to draw the borders.
+ * Returns: none.
+ */
+
+static void
+_DrawInternalBorders(pw, gc)
+PanedWidget pw;
+GC gc;
+{
+ Widget *childP;
+ int on_loc, off_loc;
+ unsigned int on_size, off_size;
+
+/*
+ * This is an optimization. Do not paint the internal borders if
+ * they are the same color as the background.
+ */
+
+ if (pw->core.background_pixel == pw->paned.internal_bp)
+ return;
+
+ off_loc = 0;
+ off_size = (unsigned int) PaneSize( (Widget) pw, !IsVert(pw) );
+ on_size = (unsigned int) pw->paned.internal_bw;
+
+ ForAllPanes(pw, childP) {
+ on_loc = IsVert(pw) ? (*childP)->core.y : (*childP)->core.x;
+ on_loc -= (int) on_size;
+
+ _DrawRect( pw, gc, on_loc, off_loc, on_size, off_size);
+ }
+}
+
+/*
+ * This allows good reuse of code, as well as descriptive function names.
+ */
+
+#define DrawInternalBorders(pw) _DrawInternalBorders((pw), (pw)->paned.normgc);
+#define EraseInternalBorders(pw) _DrawInternalBorders((pw), (pw)->paned.invgc);
+
+/* Function Name: _DrawTrackLines
+ * Description: Draws the lines that animate the pane borders when the
+ * grips are moved.
+ * Arguments: pw - the Paned widget.
+ * erase - if True then just erase track lines, else
+ * draw them in.
+ * Returns: none.
+ */
+
+static void
+_DrawTrackLines(pw, erase)
+PanedWidget pw;
+Boolean erase;
+{
+ Widget *childP;
+ Pane pane;
+ int on_loc, off_loc;
+ unsigned int on_size, off_size;
+
+ off_loc = 0;
+ off_size = PaneSize( (Widget) pw, !IsVert(pw));
+
+ ForAllPanes(pw, childP) {
+ pane = PaneInfo(*childP);
+ if ( erase || (pane->olddelta != pane->delta) ) {
+ on_size = pw->paned.internal_bw;
+ if (!erase) {
+ on_loc = PaneInfo(*childP)->olddelta - (int) on_size;
+
+ _DrawRect( pw, pw->paned.flipgc,
+ on_loc, off_loc, on_size, off_size);
+ }
+
+ on_loc = PaneInfo(*childP)->delta - (int) on_size;
+
+ _DrawRect(pw, pw->paned.flipgc,
+ on_loc, off_loc, on_size, off_size);
+
+ pane->olddelta = pane->delta;
+ }
+ }
+}
+
+/*
+ * This allows good reuse of code, as well as descriptive function names.
+ */
+
+#define DrawTrackLines(pw) _DrawTrackLines((pw), FALSE);
+#define EraseTrackLines(pw) _DrawTrackLines((pw), TRUE);
+
+/* Function Name: GetEventLocation
+ * Description: Converts and event to an x and y location.
+ * Arguments: pw - the paned widget.
+ * event - a pointer to an event.
+ * Returns: if this is a vertical pane then (y) else (x).
+ */
+
+static int
+GetEventLocation(pw, event)
+PanedWidget pw;
+XEvent *event;
+{
+ int x, y;
+
+ switch (event->xany.type) {
+ case ButtonPress:
+ case ButtonRelease:
+ x = event->xbutton.x_root;
+ y = event->xbutton.y_root;
+ break;
+ case KeyPress:
+ case KeyRelease:
+ x = event->xkey.x_root;
+ y = event->xkey.y_root;
+ break;
+ case MotionNotify:
+ x = event->xmotion.x_root;
+ y = event->xmotion.y_root;
+ break;
+ default:
+ x = pw->paned.start_loc;
+ y = pw->paned.start_loc;
+ }
+ if (IsVert(pw))
+ return(y);
+ return(x);
+}
+
+/* Function Name: StartGripAdjustment
+ * Description: Starts the grip adjustment procedure.
+ * Arguments: pw - the paned widget.
+ * grip - the grip widget selected.
+ * dir - the direction that we are to be moving.
+ * Returns: none.
+ */
+
+static void
+StartGripAdjustment(pw, grip, dir)
+PanedWidget pw;
+Widget grip;
+Direction dir;
+{
+ Widget *childP;
+ Cursor cursor;
+
+ pw->paned.whichadd = pw->paned.whichsub = (Widget) NULL;
+
+ if (dir == ThisBorderOnly || dir == UpLeftPane)
+ pw->paned.whichadd = pw->composite.children[PaneIndex(grip)];
+ if (dir == ThisBorderOnly || dir == LowRightPane)
+ pw->paned.whichsub = pw->composite.children[PaneIndex(grip) + 1];
+
+/*
+ * Change the cursor.
+ */
+
+ if (XtIsRealized(grip)) {
+ if ( IsVert(pw) ) {
+ if (dir == UpLeftPane)
+ cursor = pw->paned.adjust_upper_cursor;
+ else if (dir == LowRightPane)
+ cursor = pw->paned.adjust_lower_cursor;
+ else {
+ if ( pw->paned.adjust_this_cursor == None)
+ cursor = pw->paned.v_adjust_this_cursor;
+ else
+ cursor = pw->paned.adjust_this_cursor;
+ }
+ }
+ else {
+ if (dir == UpLeftPane)
+ cursor = pw->paned.adjust_left_cursor;
+ else if (dir == LowRightPane)
+ cursor = pw->paned.adjust_right_cursor;
+ else {
+ if (pw->paned.adjust_this_cursor == None)
+ cursor = pw->paned.h_adjust_this_cursor;
+ else
+ cursor = pw->paned.adjust_this_cursor;
+ }
+ }
+
+ XDefineCursor(XtDisplay(grip), XtWindow(grip), cursor);
+ }
+
+ EraseInternalBorders(pw);
+ ForAllPanes(pw, childP)
+ PaneInfo(*childP)->olddelta = -99;
+}
+
+/* Function Name: MoveGripAdjustment
+ * Description: This routine moves all panes around when a grip is moved.
+ * Arguments: pw - the paned widget.
+ * grip - the grip that we are moving.
+ * dir - the direction the pane we are interested is w.r.t the
+ * grip.
+ * loc - location of pointer in proper direction.
+ * Returns: none.
+ */
+
+static void
+MoveGripAdjustment(pw, grip, dir, loc)
+PanedWidget pw;
+Widget grip;
+Direction dir;
+int loc;
+{
+ int diff, add_size = 0, sub_size = 0;
+
+ diff = loc - pw->paned.start_loc;
+
+ if (pw->paned.whichadd)
+ add_size = PaneSize(pw->paned.whichadd, IsVert(pw) ) + diff;
+
+ if (pw->paned.whichsub)
+ sub_size = PaneSize(pw->paned.whichsub, IsVert(pw) ) - diff;
+
+/*
+ * If moving this border only then do not allow either of the borders
+ * to go beyond the min or max size allowed.
+ */
+
+ if ( (dir == ThisBorderOnly) ) {
+ int old_add_size = add_size, old_sub_size;
+
+ AssignMax(add_size, (int) PaneInfo(pw->paned.whichadd)->min);
+ AssignMin(add_size, (int) PaneInfo(pw->paned.whichadd)->max);
+ if (add_size != old_add_size)
+ sub_size += old_add_size - add_size;
+
+ old_sub_size = sub_size;
+ AssignMax(sub_size, (int) PaneInfo(pw->paned.whichsub)->min);
+ AssignMin(sub_size, (int) PaneInfo(pw->paned.whichsub)->max);
+ if (sub_size != old_sub_size) return; /* Abort to current sizes. */
+ }
+
+ if (add_size != 0)
+ PaneInfo(pw->paned.whichadd)->size = add_size;
+ if (sub_size != 0)
+ PaneInfo(pw->paned.whichsub)->size = sub_size;
+ RefigureLocations(pw, PaneIndex(grip), dir);
+ DrawTrackLines(pw);
+}
+
+/* Function Name: CommitGripAdjustment
+ * Description: Commits the grip adjustment.
+ * Arguments: pw - the paned widget.
+ * Returns: none
+ */
+
+static void
+CommitGripAdjustment(pw)
+PanedWidget pw;
+{
+ EraseTrackLines(pw);
+ CommitNewLocations(pw);
+ DrawInternalBorders(pw);
+
+/*
+ * Since the user selected this size then use it as the preferred size.
+ */
+
+ if (pw->paned.whichadd) {
+ Pane pane = PaneInfo(pw->paned.whichadd);
+ pane->wp_size = pane->size;
+ }
+ if (pw->paned.whichsub) {
+ Pane pane = PaneInfo(pw->paned.whichsub);
+ pane->wp_size = pane->size;
+ }
+}
+
+/* Function Name: HandleGrip
+ * Description: Handles the grip manipulations.
+ * Arguments: grip - the grip widget that has been moved.
+ * junk - ** NOT USED **
+ * call_data - data passed to us from the grip widget.
+ * Returns: none.
+ */
+
+/* ARGSUSED */
+static void
+HandleGrip(grip, junk, callData)
+Widget grip;
+XtPointer junk, callData;
+{
+ XawGripCallData call_data = (XawGripCallData)callData;
+ PanedWidget pw = (PanedWidget) XtParent(grip);
+ int loc;
+ char action_type;
+ Cursor cursor;
+ Direction direction;
+ Arg arglist[1];
+
+ action_type = *call_data->params[0];
+
+ if (call_data->num_params == 0 ||
+ (action_type == 'C' && call_data->num_params != 1) ||
+ (action_type != 'C' && call_data->num_params != 2))
+ XtError( "Paned GripAction has been passed incorrect parameters." );
+
+ if (islower(action_type)) action_type = toupper(action_type);
+
+ loc = GetEventLocation(pw, (XEvent *) (call_data->event));
+
+ if (action_type != 'C') {
+ if ( isupper(*call_data->params[1]) )
+ direction = (Direction) *call_data->params[1];
+ else
+ direction = (Direction) toupper(*call_data->params[1]);
+ }
+
+ switch (action_type) {
+ case 'S': /* Start adjustment */
+ pw->paned.resize_children_to_pref = FALSE;
+ StartGripAdjustment(pw, grip, direction);
+ pw->paned.start_loc = loc;
+ break;
+
+ case 'M':
+ MoveGripAdjustment(pw, grip, direction, loc);
+ break;
+
+ case 'C':
+ XtSetArg(arglist[0], XtNcursor, &cursor);
+ XtGetValues(grip, arglist, (Cardinal) 1);
+ XDefineCursor(XtDisplay(grip), XtWindow(grip), cursor);
+ CommitGripAdjustment(pw);
+ break;
+
+ default:
+ XtError( "Paned GripAction(); 1st parameter invalid" );
+ }
+}
+
+/* Function Name: ResortChildren
+ * Description: Resorts the children so that all managed children
+ * are first.
+ * Arguments: pw - the paned widget.
+ * Returns: none.
+ */
+
+static void
+ResortChildren(pw)
+PanedWidget pw;
+{
+ Widget * unmanagedP, * childP;
+
+ unmanagedP = NULL;
+ ForAllChildren(pw, childP) {
+ if (!IsPane(*childP) || !XtIsManaged(*childP)) {
+ /*
+ * We only keep track of the first unmanaged pane.
+ */
+ if (unmanagedP == NULL)
+ unmanagedP = childP;
+ }
+ else { /* must be a managed pane */
+ /*
+ * If an earlier widget was not a managed pane, then swap
+ */
+ if (unmanagedP != NULL) {
+ Widget child = *unmanagedP;
+ *unmanagedP = *childP;
+ *childP = child;
+ childP = unmanagedP; /* easiest to just back-track */
+ unmanagedP = NULL; /* in case there is another managed */
+ }
+ }
+ }
+}
+
+/* Function Name: ManageAndUnmanageGrips
+ * Description: This function manages and unmanages the grips so that
+ * the managed state of each grip matches that of its pane.
+ * Arguments: pw - the paned widget.
+ * Returns: none.
+ */
+
+static void
+ManageAndUnmanageGrips(pw)
+PanedWidget pw;
+{
+ WidgetList managed_grips, unmanaged_grips;
+ Widget *managedP, *unmanagedP, *childP;
+ Cardinal alloc_size;
+
+ alloc_size = (Cardinal) sizeof(Widget) * pw->composite.num_children / 2;
+ managedP = managed_grips = (WidgetList) XtMalloc(alloc_size);
+ unmanagedP = unmanaged_grips = (WidgetList) XtMalloc(alloc_size);
+
+ ForAllChildren(pw, childP)
+ if (IsPane(*childP) && HasGrip(*childP))
+ if ( XtIsManaged(*childP) )
+ *managedP++ = PaneInfo(*childP)->grip;
+ else
+ *unmanagedP++ = PaneInfo(*childP)->grip;
+
+ if (managedP != managed_grips) {
+ *unmanagedP++ = *--managedP; /* Last grip is never managed */
+ XtManageChildren( managed_grips, (Cardinal)(managedP - managed_grips) );
+ }
+
+ if (unmanagedP != unmanaged_grips)
+ XtUnmanageChildren( unmanaged_grips,
+ (Cardinal)(unmanagedP - unmanaged_grips) );
+
+ XtFree((char *)managed_grips);
+ XtFree((char *)unmanaged_grips);
+}
+
+/* Function Name: CreateGrip
+ * Description: Creates a grip widget.
+ * Arguments: child - the child that wants a grip to be created for it.
+ * Returns: none.
+ */
+
+static void
+CreateGrip(child)
+Widget child;
+{
+ PanedWidget pw = (PanedWidget) XtParent(child);
+ Arg arglist[2];
+ Cardinal num_args = 0;
+ Cursor cursor;
+
+ XtSetArg(arglist[num_args], XtNtranslations, pw->paned.grip_translations);
+ num_args++;
+ if ( (cursor = pw->paned.grip_cursor) == None )
+ if (IsVert(pw))
+ cursor = pw->paned.v_grip_cursor;
+ else
+ cursor = pw->paned.h_grip_cursor;
+
+ XtSetArg(arglist[num_args], XtNcursor, cursor);
+ num_args++;
+ PaneInfo(child)->grip = XtCreateWidget("grip", gripWidgetClass, (Widget)pw,
+ arglist, num_args);
+
+ XtAddCallback(PaneInfo(child)->grip, XtNcallback,
+ HandleGrip, (XtPointer) child);
+}
+
+/* Function Name: GetGCs
+ * Description: Gets new GC's.
+ * Arguments: w - the paned widget.
+ * Returns: none.
+ */
+
+static void
+GetGCs(w)
+Widget w;
+{
+ PanedWidget pw = (PanedWidget) w;
+ XtGCMask valuemask;
+ XGCValues values;
+
+/*
+ * Draw pane borders in internal border color.
+ */
+
+ values.foreground = pw->paned.internal_bp;
+ valuemask = GCForeground;
+ pw->paned.normgc = XtGetGC(w, valuemask, &values);
+
+/*
+ * Erase pane borders with background color.
+ */
+
+ values.foreground = pw->core.background_pixel;
+ valuemask = GCForeground;
+ pw->paned.invgc = XtGetGC(w, valuemask, &values);
+
+/*
+ * Draw Track lines (animate pane borders) in internal border color ^ bg color.
+ */
+
+ values.function = GXinvert;
+ values.plane_mask = pw->paned.internal_bp ^ pw->core.background_pixel;
+ values.subwindow_mode = IncludeInferiors;
+ valuemask = GCPlaneMask | GCFunction | GCSubwindowMode;
+ pw->paned.flipgc = XtGetGC(w, valuemask, &values);
+}
+
+/* Function Name: SetChildrenPrefSizes.
+ * Description: Sets the preferred sizes of the children.
+ * Arguments: pw - the paned widget.
+ * Returns: none.
+ */
+
+static void
+SetChildrenPrefSizes(pw, off_size)
+PanedWidget pw;
+Dimension off_size;
+{
+ Widget * childP;
+ Boolean vert = IsVert(pw);
+ XtWidgetGeometry request, reply;
+
+ ForAllPanes(pw, childP)
+ if ( pw->paned.resize_children_to_pref ||
+ (PaneInfo(*childP)->size == 0) ||
+ (PaneInfo(*childP)->resize_to_pref) ) {
+
+ if (PaneInfo(*childP)->preferred_size != PANED_ASK_CHILD)
+ PaneInfo(*childP)->wp_size=PaneInfo(*childP)->preferred_size;
+ else {
+ if( vert ) {
+ request.request_mode = CWWidth;
+ request.width = off_size;
+ }
+ else {
+ request.request_mode = CWHeight;
+ request.height = off_size;
+ }
+
+ if ((XtQueryGeometry( *childP, &request, &reply )
+ == XtGeometryAlmost) &&
+ (reply.request_mode = (vert ? CWHeight : CWWidth)))
+ PaneInfo(*childP)->wp_size = GetRequestInfo(&reply, vert);
+ else
+ PaneInfo(*childP)->wp_size = PaneSize(*childP, vert);
+ }
+
+ PaneInfo(*childP)->size = PaneInfo(*childP)->wp_size;
+ }
+}
+
+/* Function Name: ChangeAllGripCursors
+ * Description: Changes all the grip cursors.
+ * Arguments: pw - the paned widget.
+ * Returns: none
+ */
+
+static void
+ChangeAllGripCursors(pw)
+PanedWidget pw;
+{
+ Widget * childP;
+
+ ForAllPanes(pw, childP) {
+ Arg arglist[1];
+ Cursor cursor;
+
+ if ( (cursor = pw->paned.grip_cursor) == None )
+ if ( IsVert(pw) )
+ cursor = pw->paned.v_grip_cursor;
+ else
+ cursor = pw->paned.h_grip_cursor;
+
+ if (HasGrip (*childP)) {
+ XtSetArg(arglist[0], XtNcursor, cursor);
+ XtSetValues(PaneInfo(*childP)->grip, arglist, (Cardinal) 1);
+ }
+ }
+}
+
+/************************************************************
+ *
+ * Stack Manipulation routines (Private).
+ *
+ ************************************************************/
+
+/* Function Name: PushPaneStack
+ * Description: Pushes a value onto the pane stack.
+ * Arguments: pw - the paned widget.
+ * pane - the pane that we are pushing.
+ * Returns: none.
+ */
+
+static void
+PushPaneStack(pw, pane)
+PanedWidget pw;
+Pane pane;
+{
+ PaneStack * stack = (PaneStack *) XtMalloc(sizeof(PaneStack));
+
+ stack->next = pw->paned.stack;
+ stack->pane = pane;
+ stack->start_size = pane->size;
+
+ pw->paned.stack = stack;
+}
+
+/* Function Name: GetPaneStack
+ * Description: Gets the top value from the pane stack.
+ * Arguments: pw - the paned widget.
+ * shrink - TRUE if we want to shrink this pane,
+ * FALSE otherwise.
+ * ** RETURNED ** pane - the pane that we are popping.
+ * ** RETURNED ** start_size - the size that this pane started at.
+ * Returns: none.
+ */
+
+static void
+GetPaneStack(pw, shrink, pane, start_size)
+PanedWidget pw;
+Boolean shrink;
+Pane * pane;
+int * start_size;
+{
+ if (pw->paned.stack == NULL) {
+ *pane = NULL;
+ return;
+ }
+
+ *pane = pw->paned.stack->pane;
+ *start_size = pw->paned.stack->start_size;
+
+ if (shrink != ((*pane)->size > *start_size)) *pane = NULL;
+}
+
+/* Function Name: PopPaneStack
+ * Description: Pops the top item off the pane stack.
+ * Arguments: pw - the paned widget.
+ * Returns: TRUE if this is not the last element on the stack.
+ */
+
+static Boolean
+PopPaneStack(pw)
+PanedWidget pw;
+{
+ PaneStack * stack = pw->paned.stack;
+
+ if (stack == NULL) return(FALSE);
+
+ pw->paned.stack = stack->next;
+ XtFree((char*)stack);
+
+ if (pw->paned.stack == NULL) return(FALSE);
+ return(TRUE);
+}
+
+/* Function Name: ClearPaneStack
+ * Description: removes all entries from the pane stack.
+ * Arguments: pw - the paned widget.
+ * Returns: none
+ */
+
+static void
+ClearPaneStack(pw)
+PanedWidget pw;
+{
+ while(PopPaneStack(pw));
+}
+
+/************************************************************
+ *
+ * Semi-public routines.
+ *
+ ************************************************************/
+
+/* Function Name: ClassInitialize
+ * Description: The Paned widgets class initialization proc.
+ * Arguments: none.
+ * Returns: none.
+ */
+
+static void
+ClassInitialize()
+{
+ XawInitializeWidgetSet();
+ XtAddConverter( XtRString, XtROrientation, XmuCvtStringToOrientation,
+ (XtConvertArgList)NULL, (Cardinal)0 );
+}
+
+/* The Geometry Manager only allows changes after Realize if
+ * allow_resize is True in the constraints record.
+ *
+ * For vertically paned widgets:
+ *
+ * It only allows height changes, but offers the requested height
+ * as a compromise if both width and height changes were requested.
+ *
+ * For horizontal widgets the converse is true.
+ * As all good Geometry Managers should, we will return No if the
+ * request will have no effect; i.e. when the requestor is already
+ * of the desired geometry.
+ */
+
+static XtGeometryResult GeometryManager(w, request, reply)
+Widget w;
+XtWidgetGeometry *request, *reply;
+{
+ PanedWidget pw = (PanedWidget) XtParent(w);
+ XtGeometryMask mask = request->request_mode;
+ Dimension old_size, old_wpsize, old_paned_size;
+ Pane pane = PaneInfo(w);
+ Boolean vert = IsVert(pw);
+ Dimension on_size, off_size;
+ XtGeometryResult result;
+ Boolean almost = FALSE;
+
+/*
+ * If any of the following is true, disallow the geometry change.
+ *
+ * o The paned widget is realized and allow_resize is false for the pane.
+ * o The child did not ask to change the on_size.
+ * o The request is not a width or height request.
+ * o The requested size is the same as the current size.
+ */
+
+ if ( (XtIsRealized((Widget)pw) && !pane->allow_resize) ||
+ !(mask & ((vert) ? CWHeight : CWWidth)) ||
+ (mask & ~(CWWidth | CWHeight)) ||
+ (GetRequestInfo(request, vert) == PaneSize(w, vert)) ) {
+ return XtGeometryNo;
+ }
+
+ old_paned_size = PaneSize( (Widget) pw, vert);
+ old_wpsize = pane->wp_size;
+ old_size = pane->size;
+
+ pane->wp_size = pane->size = GetRequestInfo(request, vert);
+
+ AdjustPanedSize(pw, PaneSize((Widget) pw, !vert), &result, &on_size,
+ &off_size);
+
+/*
+ * Fool the Refigure Locations proc to thinking that we are
+ * a different on_size;
+ */
+
+ if (result != XtGeometryNo)
+ if (vert)
+ pw->core.height = on_size;
+ else
+ pw->core.width = on_size;
+
+ RefigureLocations(pw, PaneIndex(w), AnyPane);
+
+/*
+ * Set up reply struct and reset core on_size.
+ */
+
+ if (vert) {
+ pw->core.height = old_paned_size;
+ reply->height = pane->size;
+ reply->width = off_size;
+ }
+ else {
+ pw->core.width = old_paned_size;
+ reply->height = off_size;
+ reply->width = pane->size;
+ }
+
+/*
+ * IF either of the following is true.
+ *
+ * o There was a "off_size" request and the new "off_size" is different
+ * from that requested.
+ * o There was no "off_size" request and the new "off_size" is different
+ *
+ * o The "on_size" we will allow is different from that requested.
+ *
+ * THEN: set almost
+ */
+
+ if ( !((vert ? CWWidth : CWHeight) & mask))
+ if (vert)
+ request->width = w->core.width;
+ else
+ request->height = w->core.height;
+
+ almost = GetRequestInfo(request, !vert) != GetRequestInfo(reply, !vert);
+ almost |= (GetRequestInfo(request, vert) != GetRequestInfo(reply, vert));
+
+ if ( (mask & XtCWQueryOnly) || almost ) {
+ pane->wp_size = old_wpsize;
+ pane->size = old_size;
+ RefigureLocations(pw, PaneIndex(w), AnyPane);
+ reply->request_mode = CWWidth | CWHeight;
+ if (almost) return XtGeometryAlmost;
+ }
+ else {
+ AdjustPanedSize(pw, PaneSize((Widget) pw, !vert),
+ (XtGeometryResult *)NULL,
+ (Dimension *)NULL, (Dimension *)NULL);
+ CommitNewLocations( pw ); /* layout already refigured. */
+ }
+ return XtGeometryDone;
+}
+
+/* ARGSUSED */
+static void Initialize(request, new, args, num_args)
+Widget request, new;
+ArgList args;
+Cardinal *num_args;
+{
+ PanedWidget pw = (PanedWidget)new;
+
+ GetGCs( (Widget) pw);
+
+ pw->paned.recursively_called = False;
+ pw->paned.stack = NULL;
+ pw->paned.resize_children_to_pref = TRUE;
+ pw->paned.num_panes = 0;
+}
+
+static void
+Realize(w, valueMask, attributes)
+Widget w;
+Mask *valueMask;
+XSetWindowAttributes *attributes;
+{
+ PanedWidget pw = (PanedWidget) w;
+ Widget * childP;
+
+ if ((attributes->cursor = (pw)->paned.cursor) != None)
+ *valueMask |= CWCursor;
+
+ (*SuperClass->core_class.realize) (w, valueMask, attributes);
+
+/*
+ * Before we commit the new locations we need to realize all the panes and
+ * their grips.
+ */
+
+ ForAllPanes(pw, childP) {
+ XtRealizeWidget( *childP );
+ if (HasGrip (*childP))
+ XtRealizeWidget( PaneInfo(*childP)->grip );
+ }
+
+ RefigureLocationsAndCommit(w);
+ pw->paned.resize_children_to_pref = FALSE;
+} /* Realize */
+
+static void
+ReleaseGCs(w)
+Widget w;
+{
+ PanedWidget pw = (PanedWidget)w;
+
+ XtReleaseGC( w, pw->paned.normgc );
+ XtReleaseGC( w, pw->paned.invgc );
+ XtReleaseGC( w, pw->paned.flipgc );
+}
+
+static void InsertChild(w)
+Widget w;
+{
+ Pane pane = PaneInfo(w);
+
+ /* insert the child widget in the composite children list with the */
+ /* superclass insert_child routine. */
+ (*SuperClass->composite_class.insert_child)(w);
+
+ if (!IsPane(w)) return;
+
+ /* ||| Panes will be added in the order they are created, temporarily */
+
+ if ( pane->show_grip == TRUE ) {
+ CreateGrip(w);
+ if (pane->min == PANED_GRIP_SIZE)
+ pane->min = PaneSize(pane->grip, IsVert((PanedWidget) XtParent(w)));
+ }
+ else {
+ if (pane->min == PANED_GRIP_SIZE)
+ pane->min = 1;
+ pane->grip = NULL;
+ }
+
+ pane->size = 0;
+ pane->paned_adjusted_me = FALSE;
+
+} /* InsertChild */
+
+static void DeleteChild(w)
+Widget w;
+{
+ /* remove the subwidget info and destroy the grip */
+
+ if ( IsPane(w) && HasGrip(w) ) XtDestroyWidget(PaneInfo(w)->grip);
+
+ /* delete the child widget in the composite children list with the */
+ /* superclass delete_child routine. */
+ (*SuperClass->composite_class.delete_child) (w);
+
+} /* DeleteChild */
+
+static void ChangeManaged(w)
+ Widget w;
+{
+ PanedWidget pw = (PanedWidget)w;
+ Boolean vert = IsVert(pw);
+ Dimension size;
+ Widget *childP;
+
+ if (pw->paned.recursively_called++) return;
+
+/*
+ * If the size is zero then set it to the size of the widest or tallest pane.
+ */
+
+ if ( (size = PaneSize( (Widget) pw, !vert )) == 0) {
+ size = 1;
+ ForAllChildren(pw, childP)
+ if ( XtIsManaged(*childP) && (PaneSize( *childP, !vert ) > size) )
+ size = PaneSize( *childP, !vert );
+ }
+
+ ManageAndUnmanageGrips(pw);
+ pw->paned.recursively_called = False;
+ ResortChildren(pw);
+
+ pw->paned.num_panes = 0;
+ ForAllChildren(pw, childP)
+ if ( IsPane(*childP) )
+ if ( XtIsManaged(*childP) ) {
+ Pane pane = PaneInfo(*childP);
+ if (HasGrip(*childP))
+ PaneInfo(pane->grip)->position = pw->paned.num_panes;
+ pane->position = pw->paned.num_panes; /*TEMPORY -CDP 3/89 */
+ pw->paned.num_panes++;
+ }
+ else
+ break; /* This list is already sorted. */
+
+ SetChildrenPrefSizes( (PanedWidget) w, size);
+
+/*
+ * ForAllPanes can now be used.
+ */
+
+ if ( PaneSize((Widget) pw, vert) == 0 )
+ AdjustPanedSize(pw, size, (XtGeometryResult *)NULL,
+ (Dimension *)NULL, (Dimension *)NULL);
+
+ if (XtIsRealized( (Widget) pw))
+ RefigureLocationsAndCommit( (Widget) pw);
+
+} /* ChangeManaged */
+
+/* Function Name: Resize
+ * Description: The paned widget's resize proc.
+ * Arguments: w - the paned widget.
+ * Returns: none.
+ */
+
+static void
+Resize(w)
+Widget w;
+{
+ SetChildrenPrefSizes( (PanedWidget) w,
+ PaneSize(w, !IsVert((PanedWidget) w)) );
+ RefigureLocationsAndCommit(w);
+}
+
+/* ARGSUSED */
+static void
+Redisplay(w, event, region)
+Widget w;
+XEvent * event; /* unused. */
+Region region; /* unused. */
+{
+ DrawInternalBorders( (PanedWidget) w);
+}
+
+/* ARGSUSED */
+static Boolean
+SetValues(old, request, new, args, num_args)
+Widget old, request, new;
+ArgList args;
+Cardinal *num_args;
+{
+ PanedWidget old_pw = (PanedWidget) old;
+ PanedWidget new_pw = (PanedWidget) new;
+ Boolean redisplay = FALSE;
+
+ if ( (old_pw->paned.cursor != new_pw->paned.cursor) && XtIsRealized(new))
+ XDefineCursor(XtDisplay(new), XtWindow(new), new_pw->paned.cursor);
+
+ if ( (old_pw->paned.internal_bp != new_pw->paned.internal_bp) ||
+ (old_pw->core.background_pixel != new_pw->core.background_pixel) ) {
+ ReleaseGCs(old);
+ GetGCs(new);
+ redisplay = TRUE;
+ }
+
+ if ( (old_pw->paned.grip_cursor != new_pw->paned.grip_cursor) ||
+ (old_pw->paned.v_grip_cursor != new_pw->paned.v_grip_cursor) ||
+ (old_pw->paned.h_grip_cursor != new_pw->paned.h_grip_cursor) ) {
+ ChangeAllGripCursors(new_pw);
+ }
+
+ if ( IsVert(old_pw) != IsVert(new_pw)) {
+/*
+ * We are fooling the paned widget into thinking that is needs to
+ * fully refigure everything, which is what we want.
+ */
+ if (IsVert(new_pw))
+ new_pw->core.width = 0;
+ else
+ new_pw->core.height = 0;
+
+ new_pw->paned.resize_children_to_pref = TRUE;
+ ChangeManaged(new); /* Seems weird, but does the right thing. */
+ new_pw->paned.resize_children_to_pref = FALSE;
+ if (new_pw->paned.grip_cursor == None)
+ ChangeAllGripCursors(new_pw);
+ return(TRUE);
+ }
+
+ if (old_pw->paned.internal_bw != new_pw->paned.internal_bw) {
+ AdjustPanedSize( new_pw, PaneSize(new, !IsVert(old_pw)),
+ (XtGeometryResult *)NULL,
+ (Dimension *)NULL, (Dimension *)NULL);
+ RefigureLocationsAndCommit(new);
+ return(TRUE); /* We have done a full configuration, return.*/
+ }
+
+ if ( (old_pw->paned.grip_indent != new_pw->paned.grip_indent) &&
+ (XtIsRealized(new)) ) {
+ CommitNewLocations(new_pw);
+ redisplay = TRUE;
+ }
+
+ return (redisplay);
+} /* SetValues */
+
+
+/* ARGSUSED */
+static Boolean
+PaneSetValues(old, request, new, args, num_args)
+Widget old, request, new;
+ArgList args;
+Cardinal *num_args;
+{
+ Pane old_pane = PaneInfo(old);
+ Pane new_pane = PaneInfo(new);
+ Boolean redisplay = FALSE;
+
+ /* Check for new min and max. */
+
+ if (old_pane->min != new_pane->min || old_pane->max != new_pane->max)
+ XawPanedSetMinMax(new, (int)new_pane->min, (int)new_pane->max);
+
+ /* Check for change in XtNshowGrip. */
+
+ if (old_pane->show_grip != new_pane->show_grip)
+ if (new_pane->show_grip == TRUE) {
+ CreateGrip(new);
+ if (XtIsRealized(XtParent(new))) {
+ if (XtIsManaged(new)) /* if paned is unrealized this will
+ happen automatically at realize time.*/
+ XtManageChild(PaneInfo(new)->grip); /* manage the grip. */
+ XtRealizeWidget(PaneInfo(new)->grip); /* realize the grip. */
+ CommitNewLocations( (PanedWidget) XtParent(new) );
+ }
+ }
+ else if ( HasGrip(old) ) {
+ XtDestroyWidget( old_pane->grip );
+ new_pane->grip = NULL;
+ redisplay = TRUE;
+ }
+
+ /* ||| need to look at position changes */
+
+ return(redisplay);
+}
+
+/************************************************************
+ *
+ * Public routines.
+ *
+ ************************************************************/
+
+/* Function Name: XawPanedSetMinMax
+ * Description: Sets the min and max size for a pane.
+ * Arguments: widget - the widget that is a child of the Paned widget.
+ * min, max - the new min and max size for the pane.
+ * Returns: none.
+ */
+
+void
+#if NeedFunctionPrototypes
+XawPanedSetMinMax(Widget widget, int min, int max)
+#else
+XawPanedSetMinMax(widget, min, max)
+Widget widget;
+int min, max;
+#endif
+{
+ Pane pane = PaneInfo(widget);
+
+ pane->min = min;
+ pane->max = max;
+ RefigureLocationsAndCommit( widget->core.parent );
+}
+
+/* Function Name: XawPanedGetMinMax
+ * Description: Gets the min and max size for a pane.
+ * Arguments: widget - the widget that is a child of the Paned widget.
+ ** RETURNED ** min, max - the current min and max size for the pane.
+ * Returns: none.
+ */
+
+void
+#if NeedFunctionPrototypes
+XawPanedGetMinMax(Widget widget, int *min, int *max)
+#else
+XawPanedGetMinMax(widget, min, max)
+Widget widget;
+int *min, *max;
+#endif
+{
+ Pane pane = PaneInfo(widget);
+
+ *min = pane->min;
+ *max = pane->max;
+}
+
+/* Function Name: XawPanedSetRefigureMode
+ * Description: Allows a flag to be set the will inhibit
+ * the paned widgets relayout routine.
+ * Arguments: w - the paned widget.
+ * mode - if FALSE then inhibit refigure.
+ * Returns: none.
+ */
+
+void
+#if NeedFunctionPrototypes
+XawPanedSetRefigureMode(Widget w,
+#if NeedWidePrototypes
+ int mode)
+#else
+ Boolean mode)
+#endif
+#else
+XawPanedSetRefigureMode(w, mode)
+Widget w;
+Boolean mode;
+#endif
+{
+ ((PanedWidget) w)->paned.refiguremode = mode;
+ RefigureLocationsAndCommit( w );
+}
+
+/* Function Name: XawPanedGetNumSub
+ * Description: Returns the number of panes in the paned widget.
+ * Arguments: w - the paned widget.
+ * Returns: the number of panes in the paned widget.
+ */
+
+int
+#if NeedFunctionPrototypes
+XawPanedGetNumSub(Widget w)
+#else
+XawPanedGetNumSub(w)
+Widget w;
+#endif
+{
+ return ((PanedWidget)w)->paned.num_panes;
+}
+
+/* Function Name: XawPanedAllowResize
+ * Description: Allows a flag to be set that determines if the paned
+ * widget will allow geometry requests from this child
+ * Arguments: widget - a child of the paned widget.
+ * Returns: none.
+ */
+
+void
+#if NeedFunctionPrototypes
+XawPanedAllowResize(Widget widget,
+#if NeedWidePrototypes
+ int allow_resize)
+#else
+ Boolean allow_resize)
+#endif
+#else
+XawPanedAllowResize(widget, allow_resize)
+Widget widget;
+Boolean allow_resize;
+#endif
+{
+ PaneInfo(widget)->allow_resize = allow_resize;
+}
diff --git a/src/Panner.c b/src/Panner.c
new file mode 100644
index 0000000..47f1886
--- /dev/null
+++ b/src/Panner.c
@@ -0,0 +1,956 @@
+/*
+ * $Xorg: Panner.c,v 1.4 2001/02/09 02:03:45 xorgcvs Exp $
+ *
+Copyright 1989, 1994, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+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
+OPEN GROUP 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 Open Group 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 Open Group.
+ *
+ * Author: Jim Fulton, MIT X Consortium
+ */
+
+#include <X11/IntrinsicP.h>
+#include <X11/StringDefs.h> /* for XtN and XtC defines */
+#include <X11/Xmu/CharSet.h> /* for XmuCompareISOLatin1() */
+#include <X11/Xaw/XawInit.h> /* for XawInitializeWidgetSet */
+#include <X11/Xaw/PannerP.h> /* us */
+#include <X11/Xos.h>
+#include <X11/Xmu/Misc.h> /* for Min */
+#include <X11/Xmu/Drawing.h>
+#include <ctype.h> /* for isascii() etc. */
+#include <math.h> /* for atof() */
+
+extern Bool XmuDistinguishablePixels(); /* not defined in any Xmu headers */
+
+#if defined(ISC) && __STDC__ && !defined(ISC30)
+extern double atof(char *);
+#endif
+
+static char defaultTranslations[] =
+ "<Btn1Down>: start() \n\
+ <Btn1Motion>: move() \n\
+ <Btn1Up>: notify() stop() \n\
+ <Btn2Down>: abort() \n\
+ :<Key>KP_Enter: set(rubberband,toggle) \n\
+ <Key>space: page(+1p,+1p) \n\
+ <Key>Delete: page(-1p,-1p) \n\
+ :<Key>KP_Delete: page(-1p,-1p) \n\
+ <Key>BackSpace: page(-1p,-1p) \n\
+ <Key>Left: page(-.5p,+0) \n\
+ :<Key>KP_Left: page(-.5p,+0) \n\
+ <Key>Right: page(+.5p,+0) \n\
+ :<Key>KP_Right: page(+.5p,+0) \n\
+ <Key>Up: page(+0,-.5p) \n\
+ :<Key>KP_Up: page(+0,-.5p) \n\
+ <Key>Down: page(+0,+.5p) \n\
+ :<Key>KP_Down: page(+0,+.5p) \n\
+ <Key>Home: page(0,0) \n\
+ :<Key>KP_Home: page(0,0)";
+
+
+static void ActionStart(), ActionStop(), ActionAbort(), ActionMove();
+static void ActionPage(), ActionNotify(), ActionSet();
+
+static XtActionsRec actions[] = {
+ { "start", ActionStart }, /* start tmp graphics */
+ { "stop", ActionStop }, /* stop tmp graphics */
+ { "abort", ActionAbort }, /* punt */
+ { "move", ActionMove }, /* move tmp graphics on Motion event */
+ { "page", ActionPage }, /* page around usually from keyboard */
+ { "notify", ActionNotify }, /* callback new position */
+ { "set", ActionSet }, /* set various parameters */
+};
+
+
+/*
+ * resources for the panner
+ */
+static XtResource resources[] = {
+#define poff(field) XtOffsetOf(PannerRec, panner.field)
+ { XtNallowOff, XtCAllowOff, XtRBoolean, sizeof(Boolean),
+ poff(allow_off), XtRImmediate, (XtPointer) FALSE },
+ { XtNresize, XtCResize, XtRBoolean, sizeof(Boolean),
+ poff(resize_to_pref), XtRImmediate, (XtPointer) TRUE },
+ { XtNreportCallback, XtCReportCallback, XtRCallback, sizeof(XtPointer),
+ poff(report_callbacks), XtRCallback, (XtPointer) NULL },
+ { XtNdefaultScale, XtCDefaultScale, XtRDimension, sizeof(Dimension),
+ poff(default_scale), XtRImmediate, (XtPointer) PANNER_DEFAULT_SCALE },
+ { XtNrubberBand, XtCRubberBand, XtRBoolean, sizeof(Boolean),
+ poff(rubber_band), XtRImmediate, (XtPointer) FALSE },
+ { XtNforeground, XtCForeground, XtRPixel, sizeof(Pixel),
+ poff(foreground), XtRString, (XtPointer) XtDefaultBackground },
+ { XtNinternalSpace, XtCInternalSpace, XtRDimension, sizeof(Dimension),
+ poff(internal_border), XtRImmediate, (XtPointer) 4 },
+ { XtNlineWidth, XtCLineWidth, XtRDimension, sizeof(Dimension),
+ poff(line_width), XtRImmediate, (XtPointer) 0 },
+ { XtNcanvasWidth, XtCCanvasWidth, XtRDimension, sizeof(Dimension),
+ poff(canvas_width), XtRImmediate, (XtPointer) 0 },
+ { XtNcanvasHeight, XtCCanvasHeight, XtRDimension, sizeof(Dimension),
+ poff(canvas_height), XtRImmediate, (XtPointer) 0 },
+ { XtNsliderX, XtCSliderX, XtRPosition, sizeof(Position),
+ poff(slider_x), XtRImmediate, (XtPointer) 0 },
+ { XtNsliderY, XtCSliderY, XtRPosition, sizeof(Position),
+ poff(slider_y), XtRImmediate, (XtPointer) 0 },
+ { XtNsliderWidth, XtCSliderWidth, XtRDimension, sizeof(Dimension),
+ poff(slider_width), XtRImmediate, (XtPointer) 0 },
+ { XtNsliderHeight, XtCSliderHeight, XtRDimension, sizeof(Dimension),
+ poff(slider_height), XtRImmediate, (XtPointer) 0 },
+ { XtNshadowColor, XtCShadowColor, XtRPixel, sizeof(Pixel),
+ poff(shadow_color), XtRString, (XtPointer) XtDefaultForeground },
+ { XtNshadowThickness, XtCShadowThickness, XtRDimension, sizeof(Dimension),
+ poff(shadow_thickness), XtRImmediate, (XtPointer) 2 },
+ { XtNbackgroundStipple, XtCBackgroundStipple, XtRString, sizeof(String),
+ poff(stipple_name), XtRImmediate, (XtPointer) NULL },
+#undef poff
+};
+
+
+/*
+ * widget class methods used below
+ */
+static void Initialize(); /* create gc's */
+static void Realize(); /* create window */
+static void Destroy(); /* clean up widget */
+static void Resize(); /* need to rescale ourselves */
+static void Redisplay(); /* draw ourselves */
+static Boolean SetValues(); /* set all of the resources */
+static void SetValuesAlmost(); /* deal with failed setval geom req */
+static XtGeometryResult QueryGeometry(); /* say how big we would like to be */
+
+PannerClassRec pannerClassRec = {
+ { /* core fields */
+ /* superclass */ (WidgetClass) &simpleClassRec,
+ /* class_name */ "Panner",
+ /* widget_size */ sizeof(PannerRec),
+ /* class_initialize */ XawInitializeWidgetSet,
+ /* class_part_initialize */ NULL,
+ /* class_inited */ FALSE,
+ /* initialize */ Initialize,
+ /* initialize_hook */ NULL,
+ /* realize */ Realize,
+ /* actions */ actions,
+ /* num_actions */ XtNumber(actions),
+ /* resources */ resources,
+ /* num_resources */ XtNumber(resources),
+ /* xrm_class */ NULLQUARK,
+ /* compress_motion */ TRUE,
+ /* compress_exposure */ TRUE,
+ /* compress_enterleave */ TRUE,
+ /* visible_interest */ FALSE,
+ /* destroy */ Destroy,
+ /* resize */ Resize,
+ /* expose */ Redisplay,
+ /* set_values */ SetValues,
+ /* set_values_hook */ NULL,
+ /* set_values_almost */ SetValuesAlmost,
+ /* get_values_hook */ NULL,
+ /* accept_focus */ NULL,
+ /* version */ XtVersion,
+ /* callback_private */ NULL,
+ /* tm_table */ defaultTranslations,
+ /* query_geometry */ QueryGeometry,
+ /* display_accelerator */ XtInheritDisplayAccelerator,
+ /* extension */ NULL
+ },
+ { /* simple fields */
+ /* change_sensitive */ XtInheritChangeSensitive
+ },
+ { /* panner fields */
+ /* ignore */ 0
+ }
+};
+
+WidgetClass pannerWidgetClass = (WidgetClass) &pannerClassRec;
+
+
+/*****************************************************************************
+ * *
+ * panner utility routines *
+ * *
+ *****************************************************************************/
+
+static void reset_shadow_gc (pw) /* used when resources change */
+ PannerWidget pw;
+{
+ XtGCMask valuemask = GCForeground;
+ XGCValues values;
+ unsigned long pixels[3];
+
+ if (pw->panner.shadow_gc) XtReleaseGC ((Widget) pw, pw->panner.shadow_gc);
+
+ pixels[0] = pw->panner.foreground;
+ pixels[1] = pw->core.background_pixel;
+ pixels[2] = pw->panner.shadow_color;
+ if (!pw->panner.stipple_name &&
+ !XmuDistinguishablePixels (XtDisplay (pw), pw->core.colormap,
+ pixels, 3) &&
+ XmuDistinguishablePixels (XtDisplay (pw), pw->core.colormap,
+ pixels, 2))
+ {
+ valuemask = GCTile | GCFillStyle;
+ values.fill_style = FillTiled;
+ values.tile = XmuCreateStippledPixmap(XtScreen((Widget)pw),
+ pw->panner.foreground,
+ pw->core.background_pixel,
+ pw->core.depth);
+ }
+ else
+ {
+ if (!pw->panner.line_width &&
+ !XmuDistinguishablePixels (XtDisplay (pw), pw->core.colormap,
+ pixels, 2))
+ pw->panner.line_width = 1;
+ valuemask = GCForeground;
+ values.foreground = pw->panner.shadow_color;
+ }
+ if (pw->panner.line_width > 0) {
+ values.line_width = pw->panner.line_width;
+ valuemask |= GCLineWidth;
+ }
+
+ pw->panner.shadow_gc = XtGetGC ((Widget) pw, valuemask, &values);
+}
+
+static void reset_slider_gc (pw) /* used when resources change */
+ PannerWidget pw;
+{
+ XtGCMask valuemask = GCForeground;
+ XGCValues values;
+
+ if (pw->panner.slider_gc) XtReleaseGC ((Widget) pw, pw->panner.slider_gc);
+
+ values.foreground = pw->panner.foreground;
+
+ pw->panner.slider_gc = XtGetGC ((Widget) pw, valuemask, &values);
+}
+
+static void reset_xor_gc (pw) /* used when resources change */
+ PannerWidget pw;
+{
+ if (pw->panner.xor_gc) XtReleaseGC ((Widget) pw, pw->panner.xor_gc);
+
+ if (pw->panner.rubber_band) {
+ XtGCMask valuemask = (GCForeground | GCFunction);
+ XGCValues values;
+ Pixel tmp;
+
+ tmp = ((pw->panner.foreground == pw->core.background_pixel) ?
+ pw->panner.shadow_color : pw->panner.foreground);
+ values.foreground = tmp ^ pw->core.background_pixel;
+ values.function = GXxor;
+ if (pw->panner.line_width > 0) {
+ valuemask |= GCLineWidth;
+ values.line_width = pw->panner.line_width;
+ }
+ pw->panner.xor_gc = XtGetGC ((Widget) pw, valuemask, &values);
+ } else {
+ pw->panner.xor_gc = NULL;
+ }
+}
+
+
+static void check_knob (pw, knob)
+ PannerWidget pw;
+ Boolean knob;
+{
+ Position pad = pw->panner.internal_border * 2;
+ Position maxx = (((Position) pw->core.width) - pad -
+ ((Position) pw->panner.knob_width));
+ Position maxy = (((Position) pw->core.height) - pad -
+ ((Position) pw->panner.knob_height));
+ Position *x = (knob ? &pw->panner.knob_x : &pw->panner.tmp.x);
+ Position *y = (knob ? &pw->panner.knob_y : &pw->panner.tmp.y);
+
+ /*
+ * note that positions are already normalized (i.e. internal_border
+ * has been subtracted out)
+ */
+ if (*x < 0) *x = 0;
+ if (*x > maxx) *x = maxx;
+
+ if (*y < 0) *y = 0;
+ if (*y > maxy) *y = maxy;
+
+ if (knob) {
+ pw->panner.slider_x = (Position) (((double) pw->panner.knob_x) /
+ pw->panner.haspect + 0.5);
+ pw->panner.slider_y = (Position) (((double) pw->panner.knob_y) /
+ pw->panner.vaspect + 0.5);
+ pw->panner.last_x = pw->panner.last_y = PANNER_OUTOFRANGE;
+ }
+}
+
+
+static void move_shadow (pw)
+ PannerWidget pw;
+{
+ if (pw->panner.shadow_thickness > 0) {
+ int lw = pw->panner.shadow_thickness + pw->panner.line_width * 2;
+ int pad = pw->panner.internal_border;
+
+ if ((int)pw->panner.knob_height > lw && (int)pw->panner.knob_width > lw) {
+ XRectangle *r = pw->panner.shadow_rects;
+ r->x = (short) (pw->panner.knob_x + pad + pw->panner.knob_width);
+ r->y = (short) (pw->panner.knob_y + pad + lw);
+ r->width = pw->panner.shadow_thickness;
+ r->height = (unsigned short) (pw->panner.knob_height - lw);
+ r++;
+ r->x = (short) (pw->panner.knob_x + pad + lw);
+ r->y = (short) (pw->panner.knob_y + pad + pw->panner.knob_height);
+ r->width = (unsigned short) (pw->panner.knob_width - lw +
+ pw->panner.shadow_thickness);
+ r->height = pw->panner.shadow_thickness;
+ pw->panner.shadow_valid = TRUE;
+ return;
+ }
+ }
+ pw->panner.shadow_valid = FALSE;
+}
+
+static void scale_knob (pw, location, size) /* set knob size and/or loc */
+ PannerWidget pw;
+ Boolean location, size;
+{
+ if (location) {
+ pw->panner.knob_x = (Position) PANNER_HSCALE (pw, pw->panner.slider_x);
+ pw->panner.knob_y = (Position) PANNER_VSCALE (pw, pw->panner.slider_y);
+ }
+ if (size) {
+ Dimension width, height;
+
+ if (pw->panner.slider_width < 1) {
+ pw->panner.slider_width = pw->panner.canvas_width;
+ }
+ if (pw->panner.slider_height < 1) {
+ pw->panner.slider_height = pw->panner.canvas_height;
+ }
+ width = Min (pw->panner.slider_width, pw->panner.canvas_width);
+ height = Min (pw->panner.slider_height, pw->panner.canvas_height);
+
+ pw->panner.knob_width = (Dimension) PANNER_HSCALE (pw, width);
+ pw->panner.knob_height = (Dimension) PANNER_VSCALE (pw, height);
+ }
+ if (!pw->panner.allow_off) check_knob (pw, TRUE);
+ move_shadow (pw);
+}
+
+static void rescale (pw)
+ PannerWidget pw;
+{
+ int hpad = pw->panner.internal_border * 2;
+ int vpad = hpad;
+
+ if (pw->panner.canvas_width < 1)
+ pw->panner.canvas_width = pw->core.width;
+ if (pw->panner.canvas_height < 1)
+ pw->panner.canvas_height = pw->core.height;
+
+ if ((int)pw->core.width <= hpad) hpad = 0;
+ if ((int)pw->core.height <= vpad) vpad = 0;
+
+ pw->panner.haspect = ((double) pw->core.width - hpad) /
+ (double) pw->panner.canvas_width;
+ pw->panner.vaspect = ((double) pw->core.height - vpad) /
+ (double) pw->panner.canvas_height;
+ scale_knob (pw, TRUE, TRUE);
+}
+
+
+static void get_default_size (pw, wp, hp)
+ PannerWidget pw;
+ Dimension *wp, *hp;
+{
+ Dimension pad = pw->panner.internal_border * 2;
+ *wp = PANNER_DSCALE (pw, pw->panner.canvas_width) + pad;
+ *hp = PANNER_DSCALE (pw, pw->panner.canvas_height) + pad;
+}
+
+static Boolean get_event_xy (pw, event, x, y)
+ PannerWidget pw;
+ XEvent *event;
+ int *x, *y;
+{
+ int pad = pw->panner.internal_border;
+
+ switch (event->type) {
+ case ButtonPress:
+ case ButtonRelease:
+ *x = event->xbutton.x - pad;
+ *y = event->xbutton.y - pad;
+ return TRUE;
+
+ case KeyPress:
+ case KeyRelease:
+ *x = event->xkey.x - pad;
+ *y = event->xkey.y - pad;
+ return TRUE;
+
+ case EnterNotify:
+ case LeaveNotify:
+ *x = event->xcrossing.x - pad;
+ *y = event->xcrossing.y - pad;
+ return TRUE;
+
+ case MotionNotify:
+ *x = event->xmotion.x - pad;
+ *y = event->xmotion.y - pad;
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+static int parse_page_string (s, pagesize, canvassize, relative)
+ char *s;
+ int pagesize, canvassize;
+ Boolean *relative;
+{
+ char *cp;
+ double val = 1.0;
+ Boolean rel = FALSE;
+
+ /*
+ * syntax: spaces [+-] number spaces [pc\0] spaces
+ */
+
+ for (; isascii(*s) && isspace(*s); s++) ; /* skip white space */
+
+ if (*s == '+' || *s == '-') { /* deal with signs */
+ rel = TRUE;
+ if (*s == '-') val = -1.0;
+ s++;
+ }
+ if (!*s) { /* if null then return nothing */
+ *relative = TRUE;
+ return 0;
+ }
+
+ /* skip over numbers */
+ for (cp = s; isascii(*s) && (isdigit(*s) || *s == '.'); s++) ;
+ val *= atof (cp);
+
+ /* skip blanks */
+ for (; isascii(*s) && isspace(*s); s++) ;
+
+ if (*s) { /* if units */
+ switch (s[0]) {
+ case 'p': case 'P':
+ val *= (double) pagesize;
+ break;
+
+ case 'c': case 'C':
+ val *= (double) canvassize;
+ break;
+ }
+ }
+ *relative = rel;
+ return ((int) val);
+}
+
+
+#define DRAW_TMP(pw) \
+{ \
+ XDrawRectangle (XtDisplay(pw), XtWindow(pw), \
+ pw->panner.xor_gc, \
+ (int) (pw->panner.tmp.x + pw->panner.internal_border), \
+ (int) (pw->panner.tmp.y + pw->panner.internal_border), \
+ (unsigned int) (pw->panner.knob_width - 1), \
+ (unsigned int) (pw->panner.knob_height - 1)); \
+ pw->panner.tmp.showing = !pw->panner.tmp.showing; \
+}
+
+#define UNDRAW_TMP(pw) \
+{ \
+ if (pw->panner.tmp.showing) DRAW_TMP(pw); \
+}
+
+#define BACKGROUND_STIPPLE(pw) \
+ XmuLocatePixmapFile (pw->core.screen, pw->panner.stipple_name, \
+ pw->panner.shadow_color, pw->core.background_pixel, \
+ pw->core.depth, NULL, 0, NULL, NULL, NULL, NULL)
+
+#define PIXMAP_OKAY(pm) ((pm) != None && (pm) != XtUnspecifiedPixmap)
+
+
+/*****************************************************************************
+ * *
+ * panner class methods *
+ * *
+ *****************************************************************************/
+
+
+/*ARGSUSED*/
+static void Initialize (greq, gnew, args, num_args)
+ Widget greq, gnew;
+ ArgList args;
+ Cardinal *num_args;
+{
+ PannerWidget req = (PannerWidget) greq, new = (PannerWidget) gnew;
+ Dimension defwidth, defheight;
+
+ if (req->panner.canvas_width < 1) new->panner.canvas_width = 1;
+ if (req->panner.canvas_height < 1) new->panner.canvas_height = 1;
+ if (req->panner.default_scale < 1)
+ new->panner.default_scale = PANNER_DEFAULT_SCALE;
+
+ get_default_size (req, &defwidth, &defheight);
+ if (req->core.width < 1) new->core.width = defwidth;
+ if (req->core.height < 1) new->core.height = defheight;
+
+ new->panner.shadow_gc = NULL;
+ reset_shadow_gc (new); /* shadowColor */
+ new->panner.slider_gc = NULL;
+ reset_slider_gc (new); /* foreground */
+ new->panner.xor_gc = NULL;
+ reset_xor_gc (new); /* foreground ^ background */
+
+ rescale (new); /* does a position check */
+ new->panner.shadow_valid = FALSE;
+ new->panner.tmp.doing = FALSE;
+ new->panner.tmp.showing = FALSE;
+}
+
+
+static void Realize (gw, valuemaskp, attr)
+ Widget gw;
+ XtValueMask *valuemaskp;
+ XSetWindowAttributes *attr;
+{
+ PannerWidget pw = (PannerWidget) gw;
+ Pixmap pm = XtUnspecifiedPixmap;
+ Boolean gotpm = FALSE;
+
+ if (pw->core.background_pixmap == XtUnspecifiedPixmap) {
+ if (pw->panner.stipple_name) pm = BACKGROUND_STIPPLE (pw);
+
+ if (PIXMAP_OKAY(pm)) {
+ attr->background_pixmap = pm;
+ *valuemaskp |= CWBackPixmap;
+ *valuemaskp &= ~CWBackPixel;
+ gotpm = TRUE;
+ }
+ }
+ (*pannerWidgetClass->core_class.superclass->core_class.realize)
+ (gw, valuemaskp, attr);
+
+ if (gotpm) XFreePixmap (XtDisplay(gw), pm);
+}
+
+
+static void Destroy (gw)
+ Widget gw;
+{
+ PannerWidget pw = (PannerWidget) gw;
+
+ XtReleaseGC (gw, pw->panner.shadow_gc);
+ XtReleaseGC (gw, pw->panner.slider_gc);
+ XtReleaseGC (gw, pw->panner.xor_gc);
+}
+
+
+static void Resize (gw)
+ Widget gw;
+{
+ rescale ((PannerWidget) gw);
+}
+
+
+/* ARGSUSED */
+static void Redisplay (gw, event, region)
+ Widget gw;
+ XEvent *event;
+ Region region;
+{
+ PannerWidget pw = (PannerWidget) gw;
+ Display *dpy = XtDisplay(gw);
+ Window w = XtWindow(gw);
+ int pad = pw->panner.internal_border;
+ Dimension lw = pw->panner.line_width;
+ Dimension extra = pw->panner.shadow_thickness + lw * 2;
+ int kx = pw->panner.knob_x + pad, ky = pw->panner.knob_y + pad;
+
+ pw->panner.tmp.showing = FALSE;
+ XClearArea (XtDisplay(pw), XtWindow(pw),
+ (int) pw->panner.last_x - ((int) lw) + pad,
+ (int) pw->panner.last_y - ((int) lw) + pad,
+ (unsigned int) (pw->panner.knob_width + extra),
+ (unsigned int) (pw->panner.knob_height + extra),
+ False);
+ pw->panner.last_x = pw->panner.knob_x;
+ pw->panner.last_y = pw->panner.knob_y;
+
+ XFillRectangle (dpy, w, pw->panner.slider_gc, kx, ky,
+ pw->panner.knob_width - 1, pw->panner.knob_height - 1);
+
+ if (lw)
+ {
+ XDrawRectangle (dpy, w, pw->panner.shadow_gc, kx, ky,
+ (unsigned int) (pw->panner.knob_width - 1),
+ (unsigned int) (pw->panner.knob_height - 1));
+ }
+
+ if (pw->panner.shadow_valid) {
+ XFillRectangles (dpy, w, pw->panner.shadow_gc,
+ pw->panner.shadow_rects, 2);
+ }
+ if (pw->panner.tmp.doing && pw->panner.rubber_band) DRAW_TMP (pw);
+}
+
+
+/* ARGSUSED */
+static Boolean SetValues (gcur, greq, gnew, args, num_args)
+ Widget gcur, greq, gnew;
+ ArgList args;
+ Cardinal *num_args;
+{
+ PannerWidget cur = (PannerWidget) gcur;
+ PannerWidget new = (PannerWidget) gnew;
+ Boolean redisplay = FALSE;
+
+ if (cur->panner.foreground != new->panner.foreground) {
+ reset_slider_gc (new);
+ if (cur->panner.foreground != cur->core.background_pixel)
+ reset_xor_gc (new);
+ redisplay = TRUE;
+ } else if (cur->panner.line_width != new->panner.line_width ||
+ cur->core.background_pixel != new->core.background_pixel) {
+ reset_xor_gc (new);
+ redisplay = TRUE;
+ }
+ if (cur->panner.shadow_color != new->panner.shadow_color) {
+ reset_shadow_gc (new);
+ if (cur->panner.foreground == cur->core.background_pixel)
+ reset_xor_gc (new);
+ redisplay = TRUE;
+ }
+ if (cur->panner.shadow_thickness != new->panner.shadow_thickness) {
+ move_shadow (new);
+ redisplay = TRUE;
+ }
+ if (cur->panner.rubber_band != new->panner.rubber_band) {
+ reset_xor_gc (new);
+ if (new->panner.tmp.doing) redisplay = TRUE;
+ }
+
+ if ((cur->panner.stipple_name != new->panner.stipple_name ||
+ cur->panner.shadow_color != new->panner.shadow_color ||
+ cur->core.background_pixel != new->core.background_pixel) &&
+ XtIsRealized(gnew)) {
+ Pixmap pm = (new->panner.stipple_name ? BACKGROUND_STIPPLE (new)
+ : XtUnspecifiedPixmap);
+
+ if (PIXMAP_OKAY(pm)) {
+ XSetWindowBackgroundPixmap (XtDisplay (new), XtWindow(new), pm);
+ XFreePixmap (XtDisplay (new), pm);
+ } else {
+ XSetWindowBackground (XtDisplay (new), XtWindow(new),
+ new->core.background_pixel);
+ }
+ redisplay = TRUE;
+ }
+
+ if (new->panner.resize_to_pref &&
+ (cur->panner.canvas_width != new->panner.canvas_width ||
+ cur->panner.canvas_height != new->panner.canvas_height ||
+ cur->panner.resize_to_pref != new->panner.resize_to_pref)) {
+ get_default_size (new, &new->core.width, &new->core.height);
+ redisplay = TRUE;
+ } else if (cur->panner.canvas_width != new->panner.canvas_width ||
+ cur->panner.canvas_height != new->panner.canvas_height ||
+ cur->panner.internal_border != new->panner.internal_border) {
+ rescale (new); /* does a scale_knob as well */
+ redisplay = TRUE;
+ } else {
+ Boolean loc = (cur->panner.slider_x != new->panner.slider_x ||
+ cur->panner.slider_y != new->panner.slider_y);
+ Boolean siz = (cur->panner.slider_width != new->panner.slider_width ||
+ cur->panner.slider_height != new->panner.slider_height);
+ if (loc || siz ||
+ (cur->panner.allow_off != new->panner.allow_off &&
+ new->panner.allow_off)) {
+ scale_knob (new, loc, siz);
+ redisplay = TRUE;
+ }
+ }
+
+ return redisplay;
+}
+
+static void SetValuesAlmost (gold, gnew, req, reply)
+ Widget gold, gnew;
+ XtWidgetGeometry *req, *reply;
+{
+ if (reply->request_mode == 0) { /* got turned down, so cope */
+ Resize (gnew);
+ }
+ (*pannerWidgetClass->core_class.superclass->core_class.set_values_almost)
+ (gold, gnew, req, reply);
+}
+
+static XtGeometryResult QueryGeometry (gw, intended, pref)
+ Widget gw;
+ XtWidgetGeometry *intended, *pref;
+{
+ PannerWidget pw = (PannerWidget) gw;
+
+ pref->request_mode = (CWWidth | CWHeight);
+ get_default_size (pw, &pref->width, &pref->height);
+
+ if (((intended->request_mode & (CWWidth | CWHeight)) ==
+ (CWWidth | CWHeight)) &&
+ intended->width == pref->width &&
+ intended->height == pref->height)
+ return XtGeometryYes;
+ else if (pref->width == pw->core.width && pref->height == pw->core.height)
+ return XtGeometryNo;
+ else
+ return XtGeometryAlmost;
+}
+
+
+/*****************************************************************************
+ * *
+ * panner action procs *
+ * *
+ *****************************************************************************/
+
+/* ARGSUSED */
+static void ActionStart (gw, event, params, num_params)
+ Widget gw;
+ XEvent *event;
+ String *params; /* unused */
+ Cardinal *num_params; /* unused */
+{
+ PannerWidget pw = (PannerWidget) gw;
+ int x, y;
+
+ if (!get_event_xy (pw, event, &x, &y)) {
+ XBell (XtDisplay(gw), 0); /* should do error message */
+ return;
+ }
+
+ pw->panner.tmp.doing = TRUE;
+ pw->panner.tmp.startx = pw->panner.knob_x;
+ pw->panner.tmp.starty = pw->panner.knob_y;
+ pw->panner.tmp.dx = (((Position) x) - pw->panner.knob_x);
+ pw->panner.tmp.dy = (((Position) y) - pw->panner.knob_y);
+ pw->panner.tmp.x = pw->panner.knob_x;
+ pw->panner.tmp.y = pw->panner.knob_y;
+ if (pw->panner.rubber_band) DRAW_TMP (pw);
+}
+
+/* ARGSUSED */
+static void ActionStop (gw, event, params, num_params)
+ Widget gw;
+ XEvent *event;
+ String *params; /* unused */
+ Cardinal *num_params; /* unused */
+{
+ PannerWidget pw = (PannerWidget) gw;
+ int x, y;
+
+ if (get_event_xy (pw, event, &x, &y)) {
+ pw->panner.tmp.x = ((Position) x) - pw->panner.tmp.dx;
+ pw->panner.tmp.y = ((Position) y) - pw->panner.tmp.dy;
+ if (!pw->panner.allow_off) check_knob (pw, FALSE);
+ }
+ if (pw->panner.rubber_band) UNDRAW_TMP (pw);
+ pw->panner.tmp.doing = FALSE;
+}
+
+/* ARGSUSED */
+static void ActionAbort (gw, event, params, num_params)
+ Widget gw;
+ XEvent *event;
+ String *params; /* unused */
+ Cardinal *num_params; /* unused */
+{
+ PannerWidget pw = (PannerWidget) gw;
+
+ if (!pw->panner.tmp.doing) return;
+
+ if (pw->panner.rubber_band) UNDRAW_TMP (pw);
+
+ if (!pw->panner.rubber_band) { /* restore old position */
+ pw->panner.tmp.x = pw->panner.tmp.startx;
+ pw->panner.tmp.y = pw->panner.tmp.starty;
+ ActionNotify (gw, event, params, num_params);
+ }
+ pw->panner.tmp.doing = FALSE;
+}
+
+
+/* ARGSUSED */
+static void ActionMove (gw, event, params, num_params)
+ Widget gw;
+ XEvent *event; /* must be a motion event */
+ String *params; /* unused */
+ Cardinal *num_params; /* unused */
+{
+ PannerWidget pw = (PannerWidget) gw;
+ int x, y;
+
+ if (!pw->panner.tmp.doing) return;
+
+ if (!get_event_xy (pw, event, &x, &y)) {
+ XBell (XtDisplay(gw), 0); /* should do error message */
+ return;
+ }
+
+ if (pw->panner.rubber_band) UNDRAW_TMP (pw);
+ pw->panner.tmp.x = ((Position) x) - pw->panner.tmp.dx;
+ pw->panner.tmp.y = ((Position) y) - pw->panner.tmp.dy;
+
+ if (!pw->panner.rubber_band) {
+ ActionNotify (gw, event, params, num_params); /* does a check */
+ } else {
+ if (!pw->panner.allow_off) check_knob (pw, FALSE);
+ DRAW_TMP (pw);
+ }
+}
+
+
+/* ARGSUSED */
+static void ActionPage (gw, event, params, num_params)
+ Widget gw;
+ XEvent *event; /* unused */
+ String *params;
+ Cardinal *num_params; /* unused */
+{
+ PannerWidget pw = (PannerWidget) gw;
+ Cardinal zero = 0;
+ Boolean isin = pw->panner.tmp.doing;
+ int x, y;
+ Boolean relx, rely;
+ int pad = pw->panner.internal_border * 2;
+
+ if (*num_params != 2) {
+ XBell (XtDisplay(gw), 0);
+ return;
+ }
+
+ x = parse_page_string (params[0], (int) pw->panner.knob_width,
+ ((int) pw->core.width) - pad, &relx);
+ y = parse_page_string (params[1], (int) pw->panner.knob_height,
+ ((int) pw->core.height) - pad, &rely);
+
+ if (relx) x += pw->panner.knob_x;
+ if (rely) y += pw->panner.knob_y;
+
+ if (isin) { /* if in, then use move */
+ XEvent ev;
+ ev.xbutton.type = ButtonPress;
+ ev.xbutton.x = x;
+ ev.xbutton.y = y;
+ ActionMove (gw, &ev, (String *) NULL, &zero);
+ } else { /* else just do it */
+ pw->panner.tmp.doing = TRUE;
+ pw->panner.tmp.x = x;
+ pw->panner.tmp.y = y;
+ ActionNotify (gw, event, (String *) NULL, &zero);
+ pw->panner.tmp.doing = FALSE;
+ }
+}
+
+
+/* ARGSUSED */
+static void ActionNotify (gw, event, params, num_params)
+ Widget gw;
+ XEvent *event; /* unused */
+ String *params; /* unused */
+ Cardinal *num_params; /* unused */
+{
+ PannerWidget pw = (PannerWidget) gw;
+
+ if (!pw->panner.tmp.doing) return;
+
+ if (!pw->panner.allow_off) check_knob (pw, FALSE);
+ pw->panner.knob_x = pw->panner.tmp.x;
+ pw->panner.knob_y = pw->panner.tmp.y;
+ move_shadow (pw);
+
+ pw->panner.slider_x = (Position) (((double) pw->panner.knob_x) /
+ pw->panner.haspect + 0.5);
+ pw->panner.slider_y = (Position) (((double) pw->panner.knob_y) /
+ pw->panner.vaspect + 0.5);
+ if (!pw->panner.allow_off) {
+ Position tmp;
+
+ if (pw->panner.slider_x >
+ (tmp = (((Position) pw->panner.canvas_width) -
+ ((Position) pw->panner.slider_width))))
+ pw->panner.slider_x = tmp;
+ if (pw->panner.slider_x < 0) pw->panner.slider_x = 0;
+ if (pw->panner.slider_y >
+ (tmp = (((Position) pw->panner.canvas_height) -
+ ((Position) pw->panner.slider_height))))
+ pw->panner.slider_y = tmp;
+ if (pw->panner.slider_y < 0) pw->panner.slider_y = 0;
+ }
+
+ if (pw->panner.last_x != pw->panner.knob_x ||
+ pw->panner.last_y != pw->panner.knob_y) {
+ XawPannerReport rep;
+
+ Redisplay (gw, (XEvent*) NULL, (Region) NULL);
+ rep.changed = (XawPRSliderX | XawPRSliderY);
+ rep.slider_x = pw->panner.slider_x;
+ rep.slider_y = pw->panner.slider_y;
+ rep.slider_width = pw->panner.slider_width;
+ rep.slider_height = pw->panner.slider_height;
+ rep.canvas_width = pw->panner.canvas_width;
+ rep.canvas_height = pw->panner.canvas_height;
+ XtCallCallbackList (gw, pw->panner.report_callbacks, (XtPointer) &rep);
+ }
+}
+
+/* ARGSUSED */
+static void ActionSet (gw, event, params, num_params)
+ Widget gw;
+ XEvent *event; /* unused */
+ String *params;
+ Cardinal *num_params;
+{
+ PannerWidget pw = (PannerWidget) gw;
+ Boolean rb;
+
+ if (*num_params < 2 ||
+ XmuCompareISOLatin1 (params[0], "rubberband") != 0) {
+ XBell (XtDisplay(gw), 0);
+ return;
+ }
+
+ if (XmuCompareISOLatin1 (params[1], "on") == 0) {
+ rb = TRUE;
+ } else if (XmuCompareISOLatin1 (params[1], "off") == 0) {
+ rb = FALSE;
+ } else if (XmuCompareISOLatin1 (params[1], "toggle") == 0) {
+ rb = !pw->panner.rubber_band;
+ } else {
+ XBell (XtDisplay(gw), 0);
+ return;
+ }
+
+ if (rb != pw->panner.rubber_band) {
+ Arg args[1];
+ XtSetArg (args[0], XtNrubberBand, rb);
+ XtSetValues (gw, args, (Cardinal) 1);
+ }
+}
diff --git a/src/Porthole.c b/src/Porthole.c
new file mode 100644
index 0000000..bab271c
--- /dev/null
+++ b/src/Porthole.c
@@ -0,0 +1,365 @@
+/*
+ * $Xorg: Porthole.c,v 1.4 2001/02/09 02:03:45 xorgcvs Exp $
+ *
+Copyright 1990, 1994, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+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
+OPEN GROUP 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 Open Group 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 Open Group.
+ *
+ * Author: Jim Fulton, MIT X Consortium
+ *
+ * This widget is a trivial clipping widget. It is typically used with a
+ * panner or scrollbar to navigate.
+ */
+
+#include <X11/IntrinsicP.h>
+#include <X11/StringDefs.h> /* get XtN and XtC defines */
+#include <X11/Xaw/XawInit.h> /* get Xaw initialize stuff */
+#include <X11/Xaw/PortholeP.h> /* get porthole structs */
+#include <X11/Xmu/Misc.h> /* for MAX */
+
+
+/*
+ * resources for the porthole
+ */
+static XtResource resources[] = {
+#define poff(field) XtOffsetOf(PortholeRec, porthole.field)
+ { XtNreportCallback, XtCReportCallback, XtRCallback, sizeof(XtPointer),
+ poff(report_callbacks), XtRCallback, (XtPointer) NULL },
+#undef poff
+};
+
+
+/*
+ * widget class methods used below
+ */
+static void Realize(); /* set gravity and upcall */
+static void Resize(); /* report new size */
+static XtGeometryResult GeometryManager(); /* deal with child requests */
+static void ChangeManaged(); /* somebody added a new widget */
+static XtGeometryResult QueryGeometry(); /* say how big would like to be */
+
+PortholeClassRec portholeClassRec = {
+ { /* core fields */
+ /* superclass */ (WidgetClass) &compositeClassRec,
+ /* class_name */ "Porthole",
+ /* widget_size */ sizeof(PortholeRec),
+ /* class_initialize */ XawInitializeWidgetSet,
+ /* class_part_initialize */ NULL,
+ /* class_inited */ FALSE,
+ /* initialize */ NULL,
+ /* initialize_hook */ NULL,
+ /* realize */ Realize,
+ /* actions */ NULL,
+ /* num_actions */ 0,
+ /* resources */ resources,
+ /* num_resources */ XtNumber(resources),
+ /* xrm_class */ NULLQUARK,
+ /* compress_motion */ TRUE,
+ /* compress_exposure */ TRUE,
+ /* compress_enterleave */ TRUE,
+ /* visible_interest */ FALSE,
+ /* destroy */ NULL,
+ /* resize */ Resize,
+ /* expose */ NULL,
+ /* set_values */ NULL,
+ /* set_values_hook */ NULL,
+ /* set_values_almost */ XtInheritSetValuesAlmost,
+ /* get_values_hook */ NULL,
+ /* accept_focus */ NULL,
+ /* version */ XtVersion,
+ /* callback_private */ NULL,
+ /* tm_table */ NULL,
+ /* query_geometry */ QueryGeometry,
+ /* display_accelerator */ XtInheritDisplayAccelerator,
+ /* extension */ NULL
+ },
+ { /* composite fields */
+ /* geometry_manager */ GeometryManager,
+ /* change_managed */ ChangeManaged,
+ /* insert_child */ XtInheritInsertChild,
+ /* delete_child */ XtInheritDeleteChild,
+ /* extension */ NULL
+ },
+ { /* porthole fields */
+ /* ignore */ 0
+ }
+};
+
+WidgetClass portholeWidgetClass = (WidgetClass) &portholeClassRec;
+
+
+/*****************************************************************************
+ * *
+ * utility routines *
+ * *
+ *****************************************************************************/
+
+static Widget find_child (pw)
+ PortholeWidget pw;
+{
+ Widget *children;
+ int i;
+
+ /*
+ * Find the managed child on which we should operate. Ignore multiple
+ * managed children.
+ */
+ for (i = 0, children = pw->composite.children;
+ i < pw->composite.num_children; i++, children++) {
+ if (XtIsManaged(*children)) return *children;
+ }
+
+ return (Widget) NULL;
+}
+
+static void SendReport (pw, changed)
+ PortholeWidget pw;
+ unsigned int changed;
+{
+ Widget child = find_child (pw);
+
+ if (pw->porthole.report_callbacks && child) {
+ XawPannerReport prep;
+
+ prep.changed = changed;
+ prep.slider_x = -child->core.x; /* porthole is "inner" */
+ prep.slider_y = -child->core.y; /* child is outer since it is larger */
+ prep.slider_width = pw->core.width;
+ prep.slider_height = pw->core.height;
+ prep.canvas_width = child->core.width;
+ prep.canvas_height = child->core.height;
+ XtCallCallbackList ((Widget)pw, pw->porthole.report_callbacks,
+ (XtPointer) &prep);
+ }
+}
+
+
+static void layout_child (pw, child, geomp, xp, yp, widthp, heightp)
+ PortholeWidget pw;
+ Widget child;
+ XtWidgetGeometry *geomp;
+ Position *xp, *yp;
+ Dimension *widthp, *heightp;
+{
+ Position minx, miny;
+
+ *xp = child->core.x; /* default to current values */
+ *yp = child->core.y;
+ *widthp = child->core.width;
+ *heightp = child->core.height;
+ if (geomp) { /* mix in any requested changes */
+ if (geomp->request_mode & CWX) *xp = geomp->x;
+ if (geomp->request_mode & CWY) *yp = geomp->y;
+ if (geomp->request_mode & CWWidth) *widthp = geomp->width;
+ if (geomp->request_mode & CWHeight) *heightp = geomp->height;
+ }
+
+ /*
+ * Make sure that the child is at least as large as the porthole; there
+ * is no maximum size.
+ */
+ if (*widthp < pw->core.width) *widthp = pw->core.width;
+ if (*heightp < pw->core.height) *heightp = pw->core.height;
+
+ /*
+ * Make sure that the child is still on the screen. Note that this must
+ * be done *after* the size computation so that we know where to put it.
+ */
+ minx = ((Position) pw->core.width) - ((Position) *widthp);
+ miny = ((Position) pw->core.height) - ((Position) *heightp);
+
+ if (*xp < minx) *xp = minx; /* keep at lower right corner */
+ if (*yp < miny) *yp = miny;
+
+ if (*xp > 0) *xp = 0; /* keep at upper left corner */
+ if (*yp > 0) *yp = 0;
+}
+
+
+
+/*****************************************************************************
+ * *
+ * Porthole Widget Class Methods *
+ * *
+ *****************************************************************************/
+
+
+static void Realize (gw, valueMask, attributes)
+ Widget gw;
+ Mask *valueMask;
+ XSetWindowAttributes *attributes;
+{
+ attributes->bit_gravity = NorthWestGravity;
+ *valueMask |= CWBitGravity;
+
+ if (gw->core.width < 1) gw->core.width = 1;
+ if (gw->core.height < 1) gw->core.height = 1;
+ (*portholeWidgetClass->core_class.superclass->core_class.realize)
+ (gw, valueMask, attributes);
+}
+
+
+static void Resize (gw)
+ Widget gw;
+{
+ PortholeWidget pw = (PortholeWidget) gw;
+ Widget child = find_child (pw);
+
+ /*
+ * If we have a child, we need to make sure that it is at least as big
+ * as we are and in the right place.
+ */
+ if (child) {
+ Position x, y;
+ Dimension width, height;
+
+ layout_child (pw, child, (XtWidgetGeometry *)NULL,
+ &x, &y, &width, &height);
+ XtConfigureWidget (child, x, y, width, height, (Dimension) 0);
+ }
+
+ SendReport (pw, (unsigned int) (XawPRCanvasWidth | XawPRCanvasHeight));
+}
+
+
+static XtGeometryResult QueryGeometry (gw, intended, preferred)
+ Widget gw;
+ XtWidgetGeometry *intended, *preferred;
+{
+ PortholeWidget pw = (PortholeWidget) gw;
+ Widget child = find_child (pw);
+
+ if (child) {
+#define SIZEONLY (CWWidth | CWHeight)
+ preferred->request_mode = SIZEONLY;
+ preferred->width = child->core.width;
+ preferred->height = child->core.height;
+
+ if (((intended->request_mode & SIZEONLY) == SIZEONLY) &&
+ intended->width == preferred->width &&
+ intended->height == preferred->height)
+ return XtGeometryYes;
+ else if (preferred->width == pw->core.width &&
+ preferred->height == pw->core.height)
+ return XtGeometryNo;
+ else
+ return XtGeometryAlmost;
+#undef SIZEONLY
+ }
+ return XtGeometryNo;
+}
+
+
+static XtGeometryResult GeometryManager (w, req, reply)
+ Widget w;
+ XtWidgetGeometry *req, *reply;
+{
+ PortholeWidget pw = (PortholeWidget) w->core.parent;
+ Widget child = find_child (pw);
+ Boolean okay = TRUE;
+
+ if (child != w) return XtGeometryNo; /* unknown child */
+
+ *reply = *req; /* assume we'll grant everything */
+
+ if ((req->request_mode & CWBorderWidth) && req->border_width != 0) {
+ reply->border_width = 0; /* require border width of 0 */
+ okay = FALSE;
+ }
+
+ layout_child (pw, child, req, &reply->x, &reply->y,
+ &reply->width, &reply->height);
+
+ if ((req->request_mode & CWX) && req->x != reply->x) okay = FALSE;
+ if ((req->request_mode & CWY) && req->x != reply->x) okay = FALSE;
+ if ((req->request_mode & CWWidth) && req->width != reply->width)
+ okay = FALSE;
+ if ((req->request_mode & CWHeight) && req->height != reply->height)
+ okay = FALSE;
+
+
+ /*
+ * If we failed on anything, simply return without touching widget
+ */
+ if (!okay) return XtGeometryAlmost;
+
+ /*
+ * If not just doing a query, update widget and send report. Note that
+ * we will often set fields that weren't requested because we want to keep
+ * the child visible.
+ */
+ if (!(req->request_mode & XtCWQueryOnly)) {
+ unsigned int changed = 0;
+
+ if (child->core.x != reply->x) {
+ changed |= XawPRSliderX;
+ child->core.x = reply->x;
+ }
+ if (child->core.y != reply->y) {
+ changed |= XawPRSliderY;
+ child->core.y = reply->y;
+ }
+ if (child->core.width != reply->width) {
+ changed |= XawPRSliderWidth;
+ child->core.width = reply->width;
+ }
+ if (child->core.height != reply->height) {
+ changed |= XawPRSliderHeight;
+ child->core.height = reply->height;
+ }
+ if (changed) SendReport (pw, changed);
+ }
+
+ return XtGeometryYes; /* success! */
+}
+
+
+static void ChangeManaged (gw)
+ Widget gw;
+{
+ PortholeWidget pw = (PortholeWidget) gw;
+ Widget child = find_child (pw); /* ignore extra children */
+
+ if (child) {
+ if (!XtIsRealized (gw)) {
+ XtWidgetGeometry geom, retgeom;
+
+ geom.request_mode = 0;
+ if (pw->core.width == 0) {
+ geom.width = child->core.width;
+ geom.request_mode |= CWWidth;
+ }
+ if (pw->core.height == 0) {
+ geom.height = child->core.height;
+ geom.request_mode |= CWHeight;
+ }
+ if (geom.request_mode &&
+ XtMakeGeometryRequest (gw, &geom, &retgeom) == XtGeometryAlmost) {
+ (void) XtMakeGeometryRequest (gw, &retgeom, (XtWidgetGeometry *)NULL);
+ }
+ }
+
+ XtResizeWidget (child, Max (child->core.width, pw->core.width),
+ Max (child->core.height, pw->core.height), 0);
+
+ SendReport (pw, (unsigned int) XawPRAll);
+ }
+}
diff --git a/src/Repeater.c b/src/Repeater.c
new file mode 100644
index 0000000..a530615
--- /dev/null
+++ b/src/Repeater.c
@@ -0,0 +1,274 @@
+/*
+ * $Xorg: Repeater.c,v 1.4 2001/02/09 02:03:45 xorgcvs Exp $
+ *
+Copyright 1990, 1994, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+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
+OPEN GROUP 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 Open Group 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 Open Group.
+ *
+ * Author: Jim Fulton, MIT X Consortium
+ *
+ * This widget is used for press-and-hold style buttons.
+ */
+
+#include <X11/IntrinsicP.h>
+#include <X11/StringDefs.h> /* for XtN and XtC defines */
+#include <X11/Xaw/XawInit.h> /* for XawInitializeWidgetSet() */
+#include <X11/Xaw/RepeaterP.h> /* us */
+
+static void tic(); /* clock timeout */
+
+#define DO_CALLBACK(rw) \
+ XtCallCallbackList ((Widget) rw, rw->command.callbacks, (XtPointer)NULL)
+
+
+#define ADD_TIMEOUT(rw,delay) \
+ XtAppAddTimeOut (XtWidgetToApplicationContext ((Widget) rw), \
+ (unsigned long) delay, tic, (XtPointer) rw)
+
+#define CLEAR_TIMEOUT(rw) \
+ if ((rw)->repeater.timer) { \
+ XtRemoveTimeOut ((rw)->repeater.timer); \
+ (rw)->repeater.timer = 0; \
+ }
+
+
+/*
+ * Translations to give user interface of press-notify...-release_or_leave
+ */
+static char defaultTranslations[] =
+ "<EnterWindow>: highlight() \n\
+ <LeaveWindow>: unhighlight() \n\
+ <Btn1Down>: set() start() \n\
+ <Btn1Up>: stop() unset() ";
+
+
+/*
+ * Actions added by this widget
+ */
+static void ActionStart(), ActionStop();
+
+static XtActionsRec actions[] = {
+ { "start", ActionStart }, /* trigger timers */
+ { "stop", ActionStop }, /* clear timers */
+};
+
+
+/*
+ * New resources added by this widget
+ */
+static XtResource resources[] = {
+#define off(field) XtOffsetOf(RepeaterRec, repeater.field)
+ { XtNdecay, XtCDecay, XtRInt, sizeof (int),
+ off(decay), XtRImmediate, (XtPointer) REP_DEF_DECAY },
+ { XtNinitialDelay, XtCDelay, XtRInt, sizeof (int),
+ off(initial_delay), XtRImmediate, (XtPointer) REP_DEF_INITIAL_DELAY },
+ { XtNminimumDelay, XtCMinimumDelay, XtRInt, sizeof (int),
+ off(minimum_delay), XtRImmediate, (XtPointer) REP_DEF_MINIMUM_DELAY },
+ { XtNrepeatDelay, XtCDelay, XtRInt, sizeof (int),
+ off(repeat_delay), XtRImmediate, (XtPointer) REP_DEF_REPEAT_DELAY },
+ { XtNflash, XtCBoolean, XtRBoolean, sizeof (Boolean),
+ off(flash), XtRImmediate, (XtPointer) FALSE },
+ { XtNstartCallback, XtCStartCallback, XtRCallback, sizeof (XtPointer),
+ off(start_callbacks), XtRImmediate, (XtPointer) NULL },
+ { XtNstopCallback, XtCStopCallback, XtRCallback, sizeof (XtPointer),
+ off(stop_callbacks), XtRImmediate, (XtPointer) NULL },
+#undef off
+};
+
+
+/*
+ * Class Methods
+ */
+
+static void Initialize(); /* setup private data */
+static void Destroy(); /* clear timers */
+static Boolean SetValues(); /* set resources */
+
+RepeaterClassRec repeaterClassRec = {
+ { /* core fields */
+ /* superclass */ (WidgetClass) &commandClassRec,
+ /* class_name */ "Repeater",
+ /* widget_size */ sizeof(RepeaterRec),
+ /* class_initialize */ XawInitializeWidgetSet,
+ /* class_part_initialize */ NULL,
+ /* class_inited */ FALSE,
+ /* initialize */ Initialize,
+ /* initialize_hook */ NULL,
+ /* realize */ XtInheritRealize,
+ /* actions */ actions,
+ /* num_actions */ XtNumber(actions),
+ /* resources */ resources,
+ /* num_resources */ XtNumber(resources),
+ /* xrm_class */ NULLQUARK,
+ /* compress_motion */ TRUE,
+ /* compress_exposure */ TRUE,
+ /* compress_enterleave */ TRUE,
+ /* visible_interest */ FALSE,
+ /* destroy */ Destroy,
+ /* resize */ XtInheritResize,
+ /* expose */ XtInheritExpose,
+ /* set_values */ SetValues,
+ /* set_values_hook */ NULL,
+ /* set_values_almost */ XtInheritSetValuesAlmost,
+ /* get_values_hook */ NULL,
+ /* accept_focus */ NULL,
+ /* version */ XtVersion,
+ /* callback_private */ NULL,
+ /* tm_table */ defaultTranslations,
+ /* query_geometry */ XtInheritQueryGeometry,
+ /* display_accelerator */ XtInheritDisplayAccelerator,
+ /* extension */ NULL
+ },
+ { /* simple fields */
+ /* change_sensitive */ XtInheritChangeSensitive
+ },
+ { /* label fields */
+ /* ignore */ 0
+ },
+ { /* command fields */
+ /* ignore */ 0
+ },
+ { /* repeater fields */
+ /* ignore */ 0
+ }
+};
+
+WidgetClass repeaterWidgetClass = (WidgetClass) &repeaterClassRec;
+
+
+/*****************************************************************************
+ * *
+ * repeater utility routines *
+ * *
+ *****************************************************************************/
+
+/* ARGSUSED */
+static void tic (client_data, id)
+ XtPointer client_data;
+ XtIntervalId *id;
+{
+ RepeaterWidget rw = (RepeaterWidget) client_data;
+
+ rw->repeater.timer = 0; /* timer is removed */
+ if (rw->repeater.flash) {
+ XtExposeProc expose;
+ expose = repeaterWidgetClass->core_class.superclass->core_class.expose;
+ XClearWindow (XtDisplay((Widget) rw), XtWindow((Widget) rw));
+ rw->command.set = FALSE;
+ (*expose) ((Widget) rw, (XEvent *) NULL, (Region) NULL);
+ XClearWindow (XtDisplay((Widget) rw), XtWindow((Widget) rw));
+ rw->command.set = TRUE;
+ (*expose) ((Widget) rw, (XEvent *) NULL, (Region) NULL);
+ }
+ DO_CALLBACK (rw);
+
+ rw->repeater.timer = ADD_TIMEOUT (rw, rw->repeater.next_delay);
+
+ /* decrement delay time, but clamp */
+ if (rw->repeater.decay) {
+ rw->repeater.next_delay -= rw->repeater.decay;
+ if (rw->repeater.next_delay < rw->repeater.minimum_delay)
+ rw->repeater.next_delay = rw->repeater.minimum_delay;
+ }
+}
+
+
+/*****************************************************************************
+ * *
+ * repeater class methods *
+ * *
+ *****************************************************************************/
+
+/* ARGSUSED */
+static void Initialize (greq, gnew, args, num_args)
+ Widget greq, gnew;
+ ArgList args;
+ Cardinal *num_args;
+{
+ RepeaterWidget new = (RepeaterWidget) gnew;
+
+ if (new->repeater.minimum_delay < 0) new->repeater.minimum_delay = 0;
+ new->repeater.timer = (XtIntervalId) 0;
+}
+
+static void Destroy (gw)
+ Widget gw;
+{
+ CLEAR_TIMEOUT ((RepeaterWidget) gw);
+}
+
+/* ARGSUSED */
+static Boolean SetValues (gcur, greq, gnew, args, num_args)
+ Widget gcur, greq, gnew;
+ ArgList args;
+ Cardinal *num_args;
+{
+ RepeaterWidget cur = (RepeaterWidget) gcur;
+ RepeaterWidget new = (RepeaterWidget) gnew;
+ Boolean redisplay = FALSE;
+
+ if (cur->repeater.minimum_delay != new->repeater.minimum_delay) {
+ if (new->repeater.next_delay < new->repeater.minimum_delay)
+ new->repeater.next_delay = new->repeater.minimum_delay;
+ }
+
+ return redisplay;
+}
+
+/*****************************************************************************
+ * *
+ * repeater action procs *
+ * *
+ *****************************************************************************/
+
+/* ARGSUSED */
+static void ActionStart (gw, event, params, num_params)
+ Widget gw;
+ XEvent *event;
+ String *params; /* unused */
+ Cardinal *num_params; /* unused */
+{
+ RepeaterWidget rw = (RepeaterWidget) gw;
+
+ CLEAR_TIMEOUT (rw);
+ if (rw->repeater.start_callbacks)
+ XtCallCallbackList (gw, rw->repeater.start_callbacks, (XtPointer)NULL);
+
+ DO_CALLBACK (rw);
+ rw->repeater.timer = ADD_TIMEOUT (rw, rw->repeater.initial_delay);
+ rw->repeater.next_delay = rw->repeater.repeat_delay;
+}
+
+
+/* ARGSUSED */
+static void ActionStop (gw, event, params, num_params)
+ Widget gw;
+ XEvent *event;
+ String *params; /* unused */
+ Cardinal *num_params; /* unused */
+{
+ RepeaterWidget rw = (RepeaterWidget) gw;
+
+ CLEAR_TIMEOUT ((RepeaterWidget) gw);
+ if (rw->repeater.stop_callbacks)
+ XtCallCallbackList (gw, rw->repeater.stop_callbacks, (XtPointer)NULL);
+}
+
diff --git a/src/Scrollbar.c b/src/Scrollbar.c
new file mode 100644
index 0000000..0493211
--- /dev/null
+++ b/src/Scrollbar.c
@@ -0,0 +1,776 @@
+/* $Xorg: Scrollbar.c,v 1.4 2001/02/09 02:03:45 xorgcvs Exp $ */
+
+/***********************************************************
+
+Copyright 1987, 1988, 1994, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+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
+OPEN GROUP 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 Open Group 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 Open Group.
+
+
+Copyright 1987, 1988 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+******************************************************************/
+
+/* ScrollBar.c */
+/* created by weissman, Mon Jul 7 13:20:03 1986 */
+/* converted by swick, Thu Aug 27 1987 */
+
+#include <X11/IntrinsicP.h>
+#include <X11/StringDefs.h>
+
+#include <X11/Xaw/XawInit.h>
+#include <X11/Xaw/ScrollbarP.h>
+#include <X11/Xmu/Drawing.h>
+
+/* Private definitions. */
+
+static char defaultTranslations[] =
+ "<Btn1Down>: StartScroll(Forward) \n\
+ <Btn2Down>: StartScroll(Continuous) MoveThumb() NotifyThumb() \n\
+ <Btn3Down>: StartScroll(Backward) \n\
+ <Btn2Motion>: MoveThumb() NotifyThumb() \n\
+ <BtnUp>: NotifyScroll(Proportional) EndScroll()";
+
+#ifdef bogusScrollKeys
+ /* examples */
+ "<KeyPress>f: StartScroll(Forward) NotifyScroll(FullLength) EndScroll()"
+ "<KeyPress>b: StartScroll(Backward) NotifyScroll(FullLength) EndScroll()"
+#endif
+
+static float floatZero = 0.0;
+
+#define Offset(field) XtOffsetOf(ScrollbarRec, field)
+
+static XtResource resources[] = {
+ {XtNlength, XtCLength, XtRDimension, sizeof(Dimension),
+ Offset(scrollbar.length), XtRImmediate, (XtPointer) 1},
+ {XtNthickness, XtCThickness, XtRDimension, sizeof(Dimension),
+ Offset(scrollbar.thickness), XtRImmediate, (XtPointer) 14},
+ {XtNorientation, XtCOrientation, XtROrientation, sizeof(XtOrientation),
+ Offset(scrollbar.orientation), XtRImmediate, (XtPointer) XtorientVertical},
+ {XtNscrollProc, XtCCallback, XtRCallback, sizeof(XtPointer),
+ Offset(scrollbar.scrollProc), XtRCallback, NULL},
+ {XtNthumbProc, XtCCallback, XtRCallback, sizeof(XtPointer),
+ Offset(scrollbar.thumbProc), XtRCallback, NULL},
+ {XtNjumpProc, XtCCallback, XtRCallback, sizeof(XtPointer),
+ Offset(scrollbar.jumpProc), XtRCallback, NULL},
+ {XtNthumb, XtCThumb, XtRBitmap, sizeof(Pixmap),
+ Offset(scrollbar.thumb), XtRImmediate, (XtPointer) XtUnspecifiedPixmap},
+ {XtNforeground, XtCForeground, XtRPixel, sizeof(Pixel),
+ Offset(scrollbar.foreground), XtRString, XtDefaultForeground},
+ {XtNshown, XtCShown, XtRFloat, sizeof(float),
+ Offset(scrollbar.shown), XtRFloat, (XtPointer)&floatZero},
+ {XtNtopOfThumb, XtCTopOfThumb, XtRFloat, sizeof(float),
+ Offset(scrollbar.top), XtRFloat, (XtPointer)&floatZero},
+ {XtNscrollVCursor, XtCCursor, XtRCursor, sizeof(Cursor),
+ Offset(scrollbar.verCursor), XtRString, "sb_v_double_arrow"},
+ {XtNscrollHCursor, XtCCursor, XtRCursor, sizeof(Cursor),
+ Offset(scrollbar.horCursor), XtRString, "sb_h_double_arrow"},
+ {XtNscrollUCursor, XtCCursor, XtRCursor, sizeof(Cursor),
+ Offset(scrollbar.upCursor), XtRString, "sb_up_arrow"},
+ {XtNscrollDCursor, XtCCursor, XtRCursor, sizeof(Cursor),
+ Offset(scrollbar.downCursor), XtRString, "sb_down_arrow"},
+ {XtNscrollLCursor, XtCCursor, XtRCursor, sizeof(Cursor),
+ Offset(scrollbar.leftCursor), XtRString, "sb_left_arrow"},
+ {XtNscrollRCursor, XtCCursor, XtRCursor, sizeof(Cursor),
+ Offset(scrollbar.rightCursor), XtRString, "sb_right_arrow"},
+ {XtNminimumThumb, XtCMinimumThumb, XtRDimension, sizeof(Dimension),
+ Offset(scrollbar.min_thumb), XtRImmediate, (XtPointer) 7},
+};
+#undef Offset
+
+static void ClassInitialize();
+static void Initialize();
+static void Destroy();
+static void Realize();
+static void Resize();
+static void Redisplay();
+static Boolean SetValues();
+
+static void StartScroll();
+static void MoveThumb();
+static void NotifyThumb();
+static void NotifyScroll();
+static void EndScroll();
+
+static XtActionsRec actions[] = {
+ {"StartScroll", StartScroll},
+ {"MoveThumb", MoveThumb},
+ {"NotifyThumb", NotifyThumb},
+ {"NotifyScroll", NotifyScroll},
+ {"EndScroll", EndScroll},
+};
+
+
+ScrollbarClassRec scrollbarClassRec = {
+ { /* core fields */
+ /* superclass */ (WidgetClass) &simpleClassRec,
+ /* class_name */ "Scrollbar",
+ /* size */ sizeof(ScrollbarRec),
+ /* class_initialize */ ClassInitialize,
+ /* class_part_init */ NULL,
+ /* class_inited */ FALSE,
+ /* initialize */ Initialize,
+ /* initialize_hook */ NULL,
+ /* realize */ Realize,
+ /* actions */ actions,
+ /* num_actions */ XtNumber(actions),
+ /* resources */ resources,
+ /* num_resources */ XtNumber(resources),
+ /* xrm_class */ NULLQUARK,
+ /* compress_motion */ TRUE,
+ /* compress_exposure*/ TRUE,
+ /* compress_enterleave*/ TRUE,
+ /* visible_interest */ FALSE,
+ /* destroy */ Destroy,
+ /* resize */ Resize,
+ /* expose */ Redisplay,
+ /* set_values */ SetValues,
+ /* set_values_hook */ NULL,
+ /* set_values_almost */ XtInheritSetValuesAlmost,
+ /* get_values_hook */ NULL,
+ /* accept_focus */ NULL,
+ /* version */ XtVersion,
+ /* callback_private */ NULL,
+ /* tm_table */ defaultTranslations,
+ /* query_geometry */ XtInheritQueryGeometry,
+ /* display_accelerator*/ XtInheritDisplayAccelerator,
+ /* extension */ NULL
+ },
+ { /* simple fields */
+ /* change_sensitive */ XtInheritChangeSensitive
+ },
+ { /* scrollbar fields */
+ /* ignore */ 0
+ }
+
+};
+
+WidgetClass scrollbarWidgetClass = (WidgetClass)&scrollbarClassRec;
+
+#define NoButton -1
+#define PICKLENGTH(widget, x, y) \
+ ((widget->scrollbar.orientation == XtorientHorizontal) ? x : y)
+#define MIN(x,y) ((x) < (y) ? (x) : (y))
+#define MAX(x,y) ((x) > (y) ? (x) : (y))
+
+static void ClassInitialize()
+{
+ XawInitializeWidgetSet();
+ XtAddConverter( XtRString, XtROrientation, XmuCvtStringToOrientation,
+ NULL, (Cardinal)0 );
+}
+
+/*
+ * Make sure the first number is within the range specified by the other
+ * two numbers.
+ */
+
+static int InRange(num, small, big)
+int num, small, big;
+{
+ return (num < small) ? small : ((num > big) ? big : num);
+}
+
+/*
+ * Same as above, but for floating numbers.
+ */
+
+static float FloatInRange(num, small, big)
+float num, small, big;
+{
+ return (num < small) ? small : ((num > big) ? big : num);
+}
+
+
+/* Fill the area specified by top and bottom with the given pattern. */
+static float FractionLoc(w, x, y)
+ ScrollbarWidget w;
+ int x, y;
+{
+ float result;
+
+ result = PICKLENGTH(w, x / (float)w->core.width,
+ y / (float)w->core.height);
+ return FloatInRange(result, 0.0, 1.0);
+}
+
+
+static void FillArea(w, top, bottom, thumb)
+ ScrollbarWidget w;
+ Position top, bottom;
+ int thumb;
+{
+ Dimension length = bottom-top;
+
+ if (bottom < 0) return;
+
+ switch(thumb) {
+ /* Fill the new Thumb location */
+ case 1:
+ if (w->scrollbar.orientation == XtorientHorizontal)
+ XFillRectangle(XtDisplay(w), XtWindow(w),
+ w->scrollbar.gc, top, 1, length,
+ w->core.height-2);
+
+ else XFillRectangle(XtDisplay(w), XtWindow(w), w->scrollbar.gc,
+ 1, top, w->core.width-2, length);
+
+ break;
+ /* Clear the old Thumb location */
+ case 0:
+ if (w->scrollbar.orientation == XtorientHorizontal)
+ XClearArea(XtDisplay(w), XtWindow(w), top, 1,
+ length, w->core.height-2, FALSE);
+
+ else XClearArea(XtDisplay(w), XtWindow(w), 1,
+ top, w->core.width-2, length, FALSE);
+
+ }
+}
+
+
+/* Paint the thumb in the area specified by w->top and
+ w->shown. The old area is erased. The painting and
+ erasing is done cleverly so that no flickering will occur. */
+
+static void PaintThumb( w )
+ ScrollbarWidget w;
+{
+ Position oldtop, oldbot, newtop, newbot;
+
+ oldtop = w->scrollbar.topLoc;
+ oldbot = oldtop + w->scrollbar.shownLength;
+ newtop = w->scrollbar.length * w->scrollbar.top;
+ newbot = newtop + (int)(w->scrollbar.length * w->scrollbar.shown);
+ if (newbot < newtop + (int)w->scrollbar.min_thumb)
+ newbot = newtop + w->scrollbar.min_thumb;
+ w->scrollbar.topLoc = newtop;
+ w->scrollbar.shownLength = newbot - newtop;
+
+ if (XtIsRealized((Widget)w)) {
+ if (newtop < oldtop) FillArea(w, newtop, MIN(newbot, oldtop), 1);
+ if (newtop > oldtop) FillArea(w, oldtop, MIN(newtop, oldbot), 0);
+ if (newbot < oldbot) FillArea(w, MAX(newbot, oldtop), oldbot, 0);
+ if (newbot > oldbot) FillArea(w, MAX(newtop, oldbot), newbot, 1);
+ }
+}
+
+
+static void SetDimensions(w)
+ ScrollbarWidget w;
+{
+ if (w->scrollbar.orientation == XtorientVertical) {
+ w->scrollbar.length = w->core.height;
+ w->scrollbar.thickness = w->core.width;
+ }
+ else {
+ w->scrollbar.length = w->core.width;
+ w->scrollbar.thickness = w->core.height;
+ }
+}
+
+/* Function Name: Destroy
+ * Description: Called as the scrollbar is going away...
+ * Arguments: w - the scrollbar.
+ * Returns: nonw
+ */
+
+static void
+Destroy(w)
+Widget w;
+{
+ ScrollbarWidget sbw = (ScrollbarWidget) w;
+
+ XtReleaseGC(w, sbw->scrollbar.gc);
+}
+
+/* Function Name: CreateGC
+ * Description: Creates the GC.
+ * Arguments: w - the scrollbar widget.
+ * Returns: none.
+ */
+
+static void
+CreateGC(w)
+Widget w;
+{
+ ScrollbarWidget sbw = (ScrollbarWidget) w;
+ XGCValues gcValues;
+ XtGCMask mask;
+ unsigned int depth = 1;
+
+ if (sbw->scrollbar.thumb == XtUnspecifiedPixmap) {
+ sbw->scrollbar.thumb = XmuCreateStippledPixmap (XtScreen(w),
+ (Pixel) 1, (Pixel) 0,
+ depth);
+ }
+ else if (sbw->scrollbar.thumb != None) {
+ Window root;
+ int x, y;
+ unsigned int width, height, bw;
+ if (XGetGeometry(XtDisplay(w), sbw->scrollbar.thumb, &root, &x, &y,
+ &width, &height, &bw, &depth) == 0) {
+ XtAppError(XtWidgetToApplicationContext(w),
+ "Scrollbar Widget: Could not get geometry of thumb pixmap.");
+ }
+ }
+
+ gcValues.foreground = sbw->scrollbar.foreground;
+ gcValues.background = sbw->core.background_pixel;
+ mask = GCForeground | GCBackground;
+
+ if (sbw->scrollbar.thumb != None) {
+ if (depth == 1) {
+ gcValues.fill_style = FillOpaqueStippled;
+ gcValues.stipple = sbw->scrollbar.thumb;
+ mask |= GCFillStyle | GCStipple;
+ }
+ else {
+ gcValues.fill_style = FillTiled;
+ gcValues.tile = sbw->scrollbar.thumb;
+ mask |= GCFillStyle | GCTile;
+ }
+ }
+ sbw->scrollbar.gc = XtGetGC( w, mask, &gcValues);
+}
+
+/* ARGSUSED */
+static void Initialize( request, new, args, num_args )
+ Widget request; /* what the client asked for */
+ Widget new; /* what we're going to give him */
+ ArgList args;
+ Cardinal *num_args;
+{
+ ScrollbarWidget w = (ScrollbarWidget) new;
+
+ CreateGC(new);
+
+ if (w->core.width == 0)
+ w->core.width = (w->scrollbar.orientation == XtorientVertical)
+ ? w->scrollbar.thickness : w->scrollbar.length;
+
+ if (w->core.height == 0)
+ w->core.height = (w->scrollbar.orientation == XtorientHorizontal)
+ ? w->scrollbar.thickness : w->scrollbar.length;
+
+ SetDimensions( w );
+ w->scrollbar.direction = 0;
+ w->scrollbar.topLoc = 0;
+ w->scrollbar.shownLength = w->scrollbar.min_thumb;
+}
+
+static void Realize( gw, valueMask, attributes )
+ Widget gw;
+ Mask *valueMask;
+ XSetWindowAttributes *attributes;
+{
+ ScrollbarWidget w = (ScrollbarWidget) gw;
+
+ w->scrollbar.inactiveCursor =
+ (w->scrollbar.orientation == XtorientVertical)
+ ? w->scrollbar.verCursor
+ : w->scrollbar.horCursor;
+
+ XtVaSetValues(gw, XtNcursor, w->scrollbar.inactiveCursor, NULL);
+
+ /*
+ * The Simple widget actually stuffs the value in the valuemask.
+ */
+
+ (*scrollbarWidgetClass->core_class.superclass->core_class.realize)
+ (gw, valueMask, attributes);
+}
+
+/* ARGSUSED */
+static Boolean
+SetValues( current, request, desired, args, num_args )
+Widget current, /* what I am */
+ request, /* what he wants me to be */
+ desired; /* what I will become */
+ArgList args;
+Cardinal *num_args;
+{
+ ScrollbarWidget w = (ScrollbarWidget) current;
+ ScrollbarWidget dw = (ScrollbarWidget) desired;
+ Boolean redraw = FALSE;
+
+/*
+ * If these values are outside the acceptable range ignore them...
+ */
+
+ if (dw->scrollbar.top < 0.0 || dw->scrollbar.top > 1.0)
+ dw->scrollbar.top = w->scrollbar.top;
+
+ if (dw->scrollbar.shown < 0.0 || dw->scrollbar.shown > 1.0)
+ dw->scrollbar.shown = w->scrollbar.shown;
+
+/*
+ * Change colors and stuff...
+ */
+
+ if ( XtIsRealized (desired) ) {
+ if ( (w->scrollbar.foreground != dw->scrollbar.foreground) ||
+ (w->core.background_pixel != dw->core.background_pixel) ||
+ (w->scrollbar.thumb != dw->scrollbar.thumb) )
+ {
+ XtReleaseGC((Widget)dw, w->scrollbar.gc);
+ CreateGC( (Widget) dw);
+ redraw = TRUE;
+ }
+ if (w->scrollbar.top != dw->scrollbar.top ||
+ w->scrollbar.shown != dw->scrollbar.shown)
+ redraw = TRUE;
+ }
+
+ return( redraw );
+}
+
+static void Resize( gw )
+ Widget gw;
+{
+ /* ForgetGravity has taken care of background, but thumb may
+ * have to move as a result of the new size. */
+ SetDimensions( (ScrollbarWidget)gw );
+ Redisplay( gw, (XEvent*)NULL, (Region)NULL );
+}
+
+
+/* ARGSUSED */
+static void Redisplay( gw, event, region )
+ Widget gw;
+ XEvent *event;
+ Region region;
+{
+ ScrollbarWidget w = (ScrollbarWidget) gw;
+ int x, y;
+ unsigned int width, height;
+
+ if (w->scrollbar.orientation == XtorientHorizontal) {
+ x = w->scrollbar.topLoc;
+ y = 1;
+ width = w->scrollbar.shownLength;
+ height = w->core.height - 2;
+ } else {
+ x = 1;
+ y = w->scrollbar.topLoc;
+ width = w->core.width - 2;
+ height = w->scrollbar.shownLength;
+ }
+
+ if ( (region == NULL) ||
+ (XRectInRegion(region, x, y, width, height) != RectangleOut) ) {
+ /* Forces entire thumb to be painted. */
+ w->scrollbar.topLoc = -(w->scrollbar.length + 1);
+ PaintThumb( w );
+ }
+}
+
+
+/* ARGSUSED */
+static void StartScroll( gw, event, params, num_params )
+ Widget gw;
+ XEvent *event;
+ String *params; /* direction: Back|Forward|Smooth */
+ Cardinal *num_params; /* we only support 1 */
+{
+ ScrollbarWidget w = (ScrollbarWidget) gw;
+ Cursor cursor;
+ char direction;
+
+ if (w->scrollbar.direction != 0) return; /* if we're already scrolling */
+ if (*num_params > 0) direction = *params[0];
+ else direction = 'C';
+
+ w->scrollbar.direction = direction;
+
+ switch( direction ) {
+ case 'B':
+ case 'b': cursor = (w->scrollbar.orientation == XtorientVertical)
+ ? w->scrollbar.downCursor
+ : w->scrollbar.rightCursor; break;
+
+ case 'F':
+ case 'f': cursor = (w->scrollbar.orientation == XtorientVertical)
+ ? w->scrollbar.upCursor
+ : w->scrollbar.leftCursor; break;
+
+ case 'C':
+ case 'c': cursor = (w->scrollbar.orientation == XtorientVertical)
+ ? w->scrollbar.rightCursor
+ : w->scrollbar.upCursor; break;
+
+ default: return; /* invalid invocation */
+ }
+
+ XtVaSetValues(gw, XtNcursor, cursor, NULL);
+
+ XFlush(XtDisplay(w));
+}
+
+
+static Boolean CompareEvents( oldEvent, newEvent )
+ XEvent *oldEvent, *newEvent;
+{
+#define Check(field) if (newEvent->field != oldEvent->field) return False;
+
+ Check(xany.display);
+ Check(xany.type);
+ Check(xany.window);
+
+ switch( newEvent->type ) {
+ case MotionNotify:
+ Check(xmotion.state); break;
+ case ButtonPress:
+ case ButtonRelease:
+ Check(xbutton.state);
+ Check(xbutton.button); break;
+ case KeyPress:
+ case KeyRelease:
+ Check(xkey.state);
+ Check(xkey.keycode); break;
+ case EnterNotify:
+ case LeaveNotify:
+ Check(xcrossing.mode);
+ Check(xcrossing.detail);
+ Check(xcrossing.state); break;
+ }
+#undef Check
+
+ return True;
+}
+
+struct EventData {
+ XEvent *oldEvent;
+ int count;
+};
+
+static Bool PeekNotifyEvent( dpy, event, args )
+ Display *dpy;
+ XEvent *event;
+ char *args;
+{
+ struct EventData *eventData = (struct EventData*)args;
+
+ return ((++eventData->count == QLength(dpy)) /* since PeekIf blocks */
+ || CompareEvents(event, eventData->oldEvent));
+}
+
+
+static Boolean LookAhead( w, event )
+ Widget w;
+ XEvent *event;
+{
+ XEvent newEvent;
+ struct EventData eventData;
+
+ if (QLength(XtDisplay(w)) == 0) return False;
+
+ eventData.count = 0;
+ eventData.oldEvent = event;
+
+ XPeekIfEvent(XtDisplay(w), &newEvent, PeekNotifyEvent, (char*)&eventData);
+
+ if (CompareEvents(event, &newEvent))
+ return True;
+ else
+ return False;
+}
+
+
+static void ExtractPosition( event, x, y )
+ XEvent *event;
+ Position *x, *y; /* RETURN */
+{
+ switch( event->type ) {
+ case MotionNotify:
+ *x = event->xmotion.x; *y = event->xmotion.y; break;
+ case ButtonPress:
+ case ButtonRelease:
+ *x = event->xbutton.x; *y = event->xbutton.y; break;
+ case KeyPress:
+ case KeyRelease:
+ *x = event->xkey.x; *y = event->xkey.y; break;
+ case EnterNotify:
+ case LeaveNotify:
+ *x = event->xcrossing.x; *y = event->xcrossing.y; break;
+ default:
+ *x = 0; *y = 0;
+ }
+}
+
+static void NotifyScroll( gw, event, params, num_params )
+ Widget gw;
+ XEvent *event;
+ String *params; /* style: Proportional|FullLength */
+ Cardinal *num_params; /* we only support 1 */
+{
+ ScrollbarWidget w = (ScrollbarWidget) gw;
+ int call_data;
+ char style;
+ Position x, y;
+
+ if (w->scrollbar.direction == 0) return; /* if no StartScroll */
+
+ if (LookAhead(gw, event)) return;
+
+ if (*num_params > 0) style = *params[0];
+ else style = 'P';
+
+ switch( style ) {
+ case 'P': /* Proportional */
+ case 'p': ExtractPosition( event, &x, &y );
+ call_data = InRange( PICKLENGTH( w, x, y ),
+ 0,
+ (int) w->scrollbar.length); break;
+
+ case 'F': /* FullLength */
+ case 'f': call_data = w->scrollbar.length; break;
+ }
+
+ switch( w->scrollbar.direction ) {
+ case 'B':
+ case 'b': call_data = -call_data;
+ /* fall through */
+ case 'F':
+ case 'f': XtCallCallbacks( gw, XtNscrollProc, (XtPointer)call_data);
+ break;
+
+ case 'C':
+ case 'c': /* NotifyThumb has already called the thumbProc(s) */
+ break;
+ }
+}
+
+/* ARGSUSED */
+static void EndScroll(gw, event, params, num_params )
+ Widget gw;
+ XEvent *event; /* unused */
+ String *params; /* unused */
+ Cardinal *num_params; /* unused */
+{
+ ScrollbarWidget w = (ScrollbarWidget) gw;
+
+ XtVaSetValues(gw, XtNcursor, w->scrollbar.inactiveCursor, NULL);
+ XFlush(XtDisplay(w)); /* make sure it get propogated. */
+
+ w->scrollbar.direction = 0;
+}
+
+
+/* ARGSUSED */
+static void MoveThumb( gw, event, params, num_params )
+ Widget gw;
+ XEvent *event;
+ String *params; /* unused */
+ Cardinal *num_params; /* unused */
+{
+ ScrollbarWidget w = (ScrollbarWidget) gw;
+ Position x, y;
+
+ if (w->scrollbar.direction == 0) return; /* if no StartScroll */
+
+ if (LookAhead(gw, event)) return;
+
+ if (!event->xmotion.same_screen) return;
+
+ ExtractPosition( event, &x, &y );
+ w->scrollbar.top = FractionLoc(w, x, y);
+ PaintThumb(w);
+ XFlush(XtDisplay(w)); /* re-draw it before Notifying */
+}
+
+
+/* ARGSUSED */
+static void NotifyThumb( gw, event, params, num_params )
+ Widget gw;
+ XEvent *event;
+ String *params; /* unused */
+ Cardinal *num_params; /* unused */
+{
+ ScrollbarWidget w = (ScrollbarWidget) gw;
+
+ if (w->scrollbar.direction == 0) return; /* if no StartScroll */
+
+ if (LookAhead(gw, event)) return;
+
+ /* thumbProc is not pretty, but is necessary for backwards
+ compatibility on those architectures for which it work{s,ed};
+ the intent is to pass a (truncated) float by value. */
+ XtCallCallbacks( gw, XtNthumbProc, *(XtPointer*)&w->scrollbar.top);
+ XtCallCallbacks( gw, XtNjumpProc, (XtPointer)&w->scrollbar.top);
+}
+
+
+
+/************************************************************
+ *
+ * Public routines.
+ *
+ ************************************************************/
+
+/* Set the scroll bar to the given location. */
+
+#if NeedFunctionPrototypes
+void XawScrollbarSetThumb(Widget gw,
+#if NeedWidePrototypes
+ double top, double shown)
+#else
+ float top, float shown)
+#endif
+#else
+void XawScrollbarSetThumb( gw, top, shown )
+Widget gw;
+float top, shown;
+#endif
+{
+ ScrollbarWidget w = (ScrollbarWidget)gw;
+
+ if (w->scrollbar.direction == 'c') return; /* if still thumbing */
+
+ w->scrollbar.top = (top > 1.0) ? 1.0 :
+ (top >= 0.0) ? top :
+ w->scrollbar.top;
+
+ w->scrollbar.shown = (shown > 1.0) ? 1.0 :
+ (shown >= 0.0) ? shown :
+ w->scrollbar.shown;
+
+ PaintThumb( w );
+}
diff --git a/src/Simple.c b/src/Simple.c
new file mode 100644
index 0000000..32e6980
--- /dev/null
+++ b/src/Simple.c
@@ -0,0 +1,302 @@
+/* $Xorg: Simple.c,v 1.4 2001/02/09 02:03:45 xorgcvs Exp $ */
+
+/***********************************************************
+
+Copyright 1987, 1988, 1994, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+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
+OPEN GROUP 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 Open Group 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 Open Group.
+
+
+Copyright 1987, 1988 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+******************************************************************/
+
+#include <stdio.h>
+#include <X11/IntrinsicP.h>
+#include <X11/StringDefs.h>
+#include <X11/Xaw/XawInit.h>
+#include <X11/Xaw/SimpleP.h>
+#include <X11/Xmu/Drawing.h>
+
+#define offset(field) XtOffsetOf(SimpleRec, simple.field)
+
+static XtResource resources[] = {
+ {XtNcursor, XtCCursor, XtRCursor, sizeof(Cursor),
+ offset(cursor), XtRImmediate, (XtPointer) None},
+ {XtNinsensitiveBorder, XtCInsensitive, XtRPixmap, sizeof(Pixmap),
+ offset(insensitive_border), XtRImmediate, (XtPointer) NULL},
+ {XtNpointerColor, XtCForeground, XtRPixel, sizeof(Pixel),
+ offset(pointer_fg), XtRString, XtDefaultForeground},
+ {XtNpointerColorBackground, XtCBackground, XtRPixel, sizeof(Pixel),
+ offset(pointer_bg), XtRString, XtDefaultBackground},
+ {XtNcursorName, XtCCursor, XtRString, sizeof(String),
+ offset(cursor_name), XtRString, NULL},
+ {XtNinternational, XtCInternational, XtRBoolean, sizeof(Boolean),
+ offset(international), XtRImmediate, (XtPointer) FALSE},
+#undef offset
+};
+
+static void ClassPartInitialize(), ClassInitialize(),Realize(),ConvertCursor();
+static Boolean SetValues(), ChangeSensitive();
+
+SimpleClassRec simpleClassRec = {
+ { /* core fields */
+ /* superclass */ (WidgetClass) &widgetClassRec,
+ /* class_name */ "Simple",
+ /* widget_size */ sizeof(SimpleRec),
+ /* class_initialize */ ClassInitialize,
+ /* class_part_initialize */ ClassPartInitialize,
+ /* class_inited */ FALSE,
+ /* initialize */ NULL,
+ /* initialize_hook */ NULL,
+ /* realize */ Realize,
+ /* actions */ NULL,
+ /* num_actions */ 0,
+ /* resources */ resources,
+ /* num_resources */ XtNumber(resources),
+ /* xrm_class */ NULLQUARK,
+ /* compress_motion */ TRUE,
+ /* compress_exposure */ TRUE,
+ /* compress_enterleave */ TRUE,
+ /* visible_interest */ FALSE,
+ /* destroy */ NULL,
+ /* resize */ NULL,
+ /* expose */ NULL,
+ /* set_values */ SetValues,
+ /* set_values_hook */ NULL,
+ /* set_values_almost */ XtInheritSetValuesAlmost,
+ /* get_values_hook */ NULL,
+ /* accept_focus */ NULL,
+ /* version */ XtVersion,
+ /* callback_private */ NULL,
+ /* tm_table */ NULL,
+ /* query_geometry */ XtInheritQueryGeometry,
+ /* display_accelerator */ XtInheritDisplayAccelerator,
+ /* extension */ NULL
+ },
+ { /* simple fields */
+ /* change_sensitive */ ChangeSensitive
+ }
+};
+
+WidgetClass simpleWidgetClass = (WidgetClass)&simpleClassRec;
+
+static void ClassInitialize()
+{
+ static XtConvertArgRec convertArg[] = {
+ {XtWidgetBaseOffset, (XtPointer) XtOffsetOf(WidgetRec, core.screen),
+ sizeof(Screen *)},
+ {XtResourceString, (XtPointer) XtNpointerColor, sizeof(Pixel)},
+ {XtResourceString, (XtPointer) XtNpointerColorBackground,
+ sizeof(Pixel)},
+ {XtWidgetBaseOffset, (XtPointer) XtOffsetOf(WidgetRec, core.colormap),
+ sizeof(Colormap)}
+ };
+
+ XawInitializeWidgetSet();
+ XtSetTypeConverter( XtRString, XtRColorCursor, XmuCvtStringToColorCursor,
+ convertArg, XtNumber(convertArg),
+ XtCacheByDisplay, (XtDestructor)NULL);
+}
+
+static void ClassPartInitialize(class)
+ WidgetClass class;
+{
+ SimpleWidgetClass c = (SimpleWidgetClass) class;
+ SimpleWidgetClass super = (SimpleWidgetClass) c->core_class.superclass;
+
+ if (c->simple_class.change_sensitive == NULL) {
+ char buf[BUFSIZ];
+ char* bufp;
+ int len;
+ char* fmt = "%s Widget: The Simple Widget class method 'change_sensitive' is undefined.\nA function must be defined or inherited.";
+
+ if ((len = strlen (fmt) + strlen (c->core_class.class_name)) < sizeof buf)
+ bufp = buf;
+ else
+ bufp = XtMalloc (len + 1);
+ if (bufp == NULL) {
+ bufp = buf;
+ strcpy (bufp, "The Simple Widget class method 'change_sensitive' is undefined.\nA function must be defined or inherited.");
+ } else
+ (void) sprintf(bufp, fmt, c->core_class.class_name);
+ XtWarning(buf);
+ if (bufp != buf) XtFree (bufp);
+ c->simple_class.change_sensitive = ChangeSensitive;
+ }
+
+ if (c->simple_class.change_sensitive == XtInheritChangeSensitive)
+ c->simple_class.change_sensitive = super->simple_class.change_sensitive;
+}
+
+static void Realize(w, valueMask, attributes)
+ Widget w;
+ Mask *valueMask;
+ XSetWindowAttributes *attributes;
+{
+ Pixmap border_pixmap;
+ if (!XtIsSensitive(w)) {
+ /* change border to gray; have to remember the old one,
+ * so XtDestroyWidget deletes the proper one */
+ if (((SimpleWidget)w)->simple.insensitive_border == None)
+ ((SimpleWidget)w)->simple.insensitive_border =
+ XmuCreateStippledPixmap(XtScreen(w),
+ w->core.border_pixel,
+ w->core.background_pixel,
+ w->core.depth);
+ border_pixmap = w->core.border_pixmap;
+ attributes->border_pixmap =
+ w->core.border_pixmap = ((SimpleWidget)w)->simple.insensitive_border;
+
+ *valueMask |= CWBorderPixmap;
+ *valueMask &= ~CWBorderPixel;
+ }
+
+ ConvertCursor(w);
+
+ if ((attributes->cursor = ((SimpleWidget)w)->simple.cursor) != None)
+ *valueMask |= CWCursor;
+
+ XtCreateWindow( w, (unsigned int)InputOutput, (Visual *)CopyFromParent,
+ *valueMask, attributes );
+
+ if (!XtIsSensitive(w))
+ w->core.border_pixmap = border_pixmap;
+}
+
+/* Function Name: ConvertCursor
+ * Description: Converts a name to a new cursor.
+ * Arguments: w - the simple widget.
+ * Returns: none.
+ */
+
+static void
+ConvertCursor(w)
+Widget w;
+{
+ SimpleWidget simple = (SimpleWidget) w;
+ XrmValue from, to;
+ Cursor cursor;
+
+ if (simple->simple.cursor_name == NULL)
+ return;
+
+ from.addr = (XPointer) simple->simple.cursor_name;
+ from.size = strlen((char *) from.addr) + 1;
+
+ to.size = sizeof(Cursor);
+ to.addr = (XPointer) &cursor;
+
+ if (XtConvertAndStore(w, XtRString, &from, XtRColorCursor, &to)) {
+ if ( cursor != None)
+ simple->simple.cursor = cursor;
+ }
+ else {
+ XtAppErrorMsg(XtWidgetToApplicationContext(w),
+ "convertFailed","ConvertCursor","XawError",
+ "Simple: ConvertCursor failed.",
+ (String *)NULL, (Cardinal *)NULL);
+ }
+}
+
+
+/* ARGSUSED */
+static Boolean SetValues(current, request, new, args, num_args)
+ Widget current, request, new;
+ ArgList args;
+ Cardinal *num_args;
+{
+ SimpleWidget s_old = (SimpleWidget) current;
+ SimpleWidget s_new = (SimpleWidget) new;
+ Boolean new_cursor = FALSE;
+
+ /* this disables user changes after creation*/
+ s_new->simple.international = s_old->simple.international;
+
+ if ( XtIsSensitive(current) != XtIsSensitive(new) )
+ (*((SimpleWidgetClass)XtClass(new))->
+ simple_class.change_sensitive) ( new );
+
+ if (s_old->simple.cursor != s_new->simple.cursor) {
+ new_cursor = TRUE;
+ }
+
+/*
+ * We are not handling the string cursor_name correctly here.
+ */
+
+ if ( (s_old->simple.pointer_fg != s_new->simple.pointer_fg) ||
+ (s_old->simple.pointer_bg != s_new->simple.pointer_bg) ||
+ (s_old->simple.cursor_name != s_new->simple.cursor_name) ) {
+ ConvertCursor(new);
+ new_cursor = TRUE;
+ }
+
+ if (new_cursor && XtIsRealized(new))
+ XDefineCursor(XtDisplay(new), XtWindow(new), s_new->simple.cursor);
+
+ return False;
+}
+
+
+static Boolean ChangeSensitive(w)
+ Widget w;
+{
+ if (XtIsRealized(w)) {
+ if (XtIsSensitive(w))
+ if (w->core.border_pixmap != XtUnspecifiedPixmap)
+ XSetWindowBorderPixmap( XtDisplay(w), XtWindow(w),
+ w->core.border_pixmap );
+ else
+ XSetWindowBorder( XtDisplay(w), XtWindow(w),
+ w->core.border_pixel );
+ else {
+ if (((SimpleWidget)w)->simple.insensitive_border == None)
+ ((SimpleWidget)w)->simple.insensitive_border =
+ XmuCreateStippledPixmap(XtScreen(w),
+ w->core.border_pixel,
+ w->core.background_pixel,
+ w->core.depth);
+ XSetWindowBorderPixmap( XtDisplay(w), XtWindow(w),
+ ((SimpleWidget)w)->
+ simple.insensitive_border );
+ }
+ }
+ return False;
+}
diff --git a/src/SimpleMenu.c b/src/SimpleMenu.c
new file mode 100644
index 0000000..516e23f
--- /dev/null
+++ b/src/SimpleMenu.c
@@ -0,0 +1,1288 @@
+/* $Xorg: SimpleMenu.c,v 1.4 2001/02/09 02:03:45 xorgcvs Exp $ */
+
+/*
+Copyright 1989, 1994, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+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
+OPEN GROUP 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 Open Group 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 Open Group.
+ */
+
+/*
+ * SimpleMenu.c - Source code file for SimpleMenu widget.
+ *
+ * Date: April 3, 1989
+ *
+ * By: Chris D. Peterson
+ * MIT X Consortium
+ * kit@expo.lcs.mit.edu
+ */
+
+#include <stdio.h>
+#include <X11/IntrinsicP.h>
+#include <X11/StringDefs.h>
+
+#include <X11/Xaw/XawInit.h>
+#include <X11/Xaw/SimpleMenP.h>
+#include <X11/Xaw/SmeBSB.h>
+#include <X11/Xaw/Cardinals.h>
+
+#include <X11/Xmu/Initer.h>
+#include <X11/Xmu/CharSet.h>
+
+#define streq(a, b) ( strcmp((a), (b)) == 0 )
+
+#define offset(field) XtOffsetOf(SimpleMenuRec, simple_menu.field)
+
+static XtResource resources[] = {
+
+/*
+ * Label Resources.
+ */
+
+ {XtNlabel, XtCLabel, XtRString, sizeof(String),
+ offset(label_string), XtRString, NULL},
+ {XtNlabelClass, XtCLabelClass, XtRPointer, sizeof(WidgetClass),
+ offset(label_class), XtRImmediate, (XtPointer) NULL},
+
+/*
+ * Layout Resources.
+ */
+
+ {XtNrowHeight, XtCRowHeight, XtRDimension, sizeof(Dimension),
+ offset(row_height), XtRImmediate, (XtPointer) 0},
+ {XtNtopMargin, XtCVerticalMargins, XtRDimension, sizeof(Dimension),
+ offset(top_margin), XtRImmediate, (XtPointer) 0},
+ {XtNbottomMargin, XtCVerticalMargins, XtRDimension, sizeof(Dimension),
+ offset(bottom_margin), XtRImmediate, (XtPointer) 0},
+
+/*
+ * Misc. Resources
+ */
+
+ { XtNallowShellResize, XtCAllowShellResize, XtRBoolean, sizeof(Boolean),
+ XtOffsetOf(SimpleMenuRec, shell.allow_shell_resize),
+ XtRImmediate, (XtPointer) TRUE },
+ {XtNcursor, XtCCursor, XtRCursor, sizeof(Cursor),
+ offset(cursor), XtRImmediate, (XtPointer) None},
+ {XtNmenuOnScreen, XtCMenuOnScreen, XtRBoolean, sizeof(Boolean),
+ offset(menu_on_screen), XtRImmediate, (XtPointer) TRUE},
+ {XtNpopupOnEntry, XtCPopupOnEntry, XtRWidget, sizeof(Widget),
+ offset(popup_entry), XtRWidget, NULL},
+ {XtNbackingStore, XtCBackingStore, XtRBackingStore, sizeof (int),
+ offset(backing_store),
+ XtRImmediate, (XtPointer) (Always + WhenMapped + NotUseful)},
+};
+#undef offset
+
+static char defaultTranslations[] =
+ "<EnterWindow>: highlight() \n\
+ <LeaveWindow>: unhighlight() \n\
+ <BtnMotion>: highlight() \n\
+ <BtnUp>: MenuPopdown() notify() unhighlight()";
+
+/*
+ * Semi Public function definitions.
+ */
+
+static void Redisplay(), Realize(), Resize(), ChangeManaged();
+static void Initialize(), ClassInitialize(), ClassPartInitialize();
+static Boolean SetValues(), SetValuesHook();
+static XtGeometryResult GeometryManager();
+
+/*
+ * Action Routine Definitions
+ */
+
+static void Highlight(), Unhighlight(), Notify(), PositionMenuAction();
+
+/*
+ * Private Function Definitions.
+ */
+
+static void MakeSetValuesRequest(), CreateLabel(), Layout();
+static void AddPositionAction(), PositionMenu(), ChangeCursorOnGrab();
+static Dimension GetMenuWidth(), GetMenuHeight();
+static Widget FindMenu();
+static SmeObject GetEventEntry();
+static void MoveMenu();
+
+static XtActionsRec actionsList[] =
+{
+ {"notify", Notify},
+ {"highlight", Highlight},
+ {"unhighlight", Unhighlight},
+};
+
+static CompositeClassExtensionRec extension_rec = {
+ /* next_extension */ NULL,
+ /* record_type */ NULLQUARK,
+ /* version */ XtCompositeExtensionVersion,
+ /* record_size */ sizeof(CompositeClassExtensionRec),
+ /* accepts_objects */ TRUE,
+};
+
+#define superclass (&overrideShellClassRec)
+
+SimpleMenuClassRec simpleMenuClassRec = {
+ {
+ /* superclass */ (WidgetClass) superclass,
+ /* class_name */ "SimpleMenu",
+ /* size */ sizeof(SimpleMenuRec),
+ /* class_initialize */ ClassInitialize,
+ /* class_part_initialize*/ ClassPartInitialize,
+ /* Class init'ed */ FALSE,
+ /* initialize */ Initialize,
+ /* initialize_hook */ NULL,
+ /* realize */ Realize,
+ /* actions */ actionsList,
+ /* num_actions */ XtNumber(actionsList),
+ /* resources */ resources,
+ /* resource_count */ XtNumber(resources),
+ /* xrm_class */ NULLQUARK,
+ /* compress_motion */ TRUE,
+ /* compress_exposure */ TRUE,
+ /* compress_enterleave*/ TRUE,
+ /* visible_interest */ FALSE,
+ /* destroy */ NULL,
+ /* resize */ Resize,
+ /* expose */ Redisplay,
+ /* set_values */ SetValues,
+ /* set_values_hook */ SetValuesHook,
+ /* set_values_almost */ XtInheritSetValuesAlmost,
+ /* get_values_hook */ NULL,
+ /* accept_focus */ NULL,
+ /* intrinsics version */ XtVersion,
+ /* callback offsets */ NULL,
+ /* tm_table */ defaultTranslations,
+ /* query_geometry */ NULL,
+ /* display_accelerator*/ NULL,
+ /* extension */ NULL
+ },{
+ /* geometry_manager */ GeometryManager,
+ /* change_managed */ ChangeManaged,
+ /* insert_child */ XtInheritInsertChild,
+ /* delete_child */ XtInheritDeleteChild,
+ /* extension */ NULL
+ },{
+ /* Shell extension */ NULL
+ },{
+ /* Override extension */ NULL
+ },{
+ /* Simple Menu extension*/ NULL
+ }
+};
+
+WidgetClass simpleMenuWidgetClass = (WidgetClass)&simpleMenuClassRec;
+
+#define ForAllChildren(smw, childP) \
+ for ( (childP) = (SmeObject *) (smw)->composite.children ; \
+ (childP) < (SmeObject *) ( (smw)->composite.children + \
+ (smw)->composite.num_children ) ; \
+ (childP)++ )
+
+/************************************************************
+ *
+ * Semi-Public Functions.
+ *
+ ************************************************************/
+
+/* Function Name: ClassInitialize
+ * Description: Class Initialize routine, called only once.
+ * Arguments: none.
+ * Returns: none.
+ */
+
+static void
+ClassInitialize()
+{
+ XawInitializeWidgetSet();
+ XtAddConverter( XtRString, XtRBackingStore, XmuCvtStringToBackingStore,
+ (XtConvertArgList)NULL, (Cardinal)0 );
+ XmuAddInitializer( AddPositionAction, NULL);
+}
+
+/* Function Name: ClassInitialize
+ * Description: Class Part Initialize routine, called for every
+ * subclass. Makes sure that the subclasses pick up
+ * the extension record.
+ * Arguments: wc - the widget class of the subclass.
+ * Returns: none.
+ */
+
+static void
+ClassPartInitialize(wc)
+WidgetClass wc;
+{
+ SimpleMenuWidgetClass smwc = (SimpleMenuWidgetClass) wc;
+
+/*
+ * Make sure that our subclass gets the extension rec too.
+ */
+
+ extension_rec.next_extension = smwc->composite_class.extension;
+ smwc->composite_class.extension = (XtPointer) &extension_rec;
+}
+
+/* Function Name: Initialize
+ * Description: Initializes the simple menu widget
+ * Arguments: request - the widget requested by the argument list.
+ * new - the new widget with both resource and non
+ * resource values.
+ * Returns: none.
+ */
+
+/* ARGSUSED */
+static void
+Initialize(request, new, args, num_args)
+Widget request, new;
+ArgList args;
+Cardinal *num_args;
+{
+ SimpleMenuWidget smw = (SimpleMenuWidget) new;
+
+ XmuCallInitializers(XtWidgetToApplicationContext(new));
+
+ if (smw->simple_menu.label_class == NULL)
+ smw->simple_menu.label_class = smeBSBObjectClass;
+
+ smw->simple_menu.label = NULL;
+ smw->simple_menu.entry_set = NULL;
+ smw->simple_menu.recursive_set_values = FALSE;
+
+ if (smw->simple_menu.label_string != NULL)
+ CreateLabel(new);
+
+ smw->simple_menu.menu_width = TRUE;
+
+ if (smw->core.width == 0) {
+ smw->simple_menu.menu_width = FALSE;
+ smw->core.width = GetMenuWidth(new, (Widget)NULL);
+ }
+
+ smw->simple_menu.menu_height = TRUE;
+
+ if (smw->core.height == 0) {
+ smw->simple_menu.menu_height = FALSE;
+ smw->core.height = GetMenuHeight(new);
+ }
+
+/*
+ * Add a popup_callback routine for changing the cursor.
+ */
+
+ XtAddCallback(new, XtNpopupCallback, ChangeCursorOnGrab, (XtPointer)NULL);
+}
+
+/* Function Name: Redisplay
+ * Description: Redisplays the contents of the widget.
+ * Arguments: w - the simple menu widget.
+ * event - the X event that caused this redisplay.
+ * region - the region the needs to be repainted.
+ * Returns: none.
+ */
+
+/* ARGSUSED */
+static void
+Redisplay(w, event, region)
+Widget w;
+XEvent * event;
+Region region;
+{
+ SimpleMenuWidget smw = (SimpleMenuWidget) w;
+ SmeObject * entry;
+ SmeObjectClass class;
+
+ if (region == NULL)
+ XClearWindow(XtDisplay(w), XtWindow(w));
+
+ /*
+ * Check and Paint each of the entries - including the label.
+ */
+
+ ForAllChildren(smw, entry) {
+ if (!XtIsManaged ( (Widget) *entry)) continue;
+
+ if (region != NULL)
+ switch(XRectInRegion(region, (int) (*entry)->rectangle.x,
+ (int) (*entry)->rectangle.y,
+ (unsigned int) (*entry)->rectangle.width,
+ (unsigned int) (*entry)->rectangle.height)) {
+ case RectangleIn:
+ case RectanglePart:
+ break;
+ default:
+ continue;
+ }
+ class = (SmeObjectClass) (*entry)->object.widget_class;
+
+ if (class->rect_class.expose != NULL)
+ (class->rect_class.expose)( (Widget) *entry, NULL, NULL);
+ }
+}
+
+/* Function Name: Realize
+ * Description: Realizes the widget.
+ * Arguments: w - the simple menu widget.
+ * mask - value mask for the window to create.
+ * attrs - attributes for the window to create.
+ * Returns: none
+ */
+
+static void
+Realize(w, mask, attrs)
+Widget w;
+XtValueMask * mask;
+XSetWindowAttributes * attrs;
+{
+ SimpleMenuWidget smw = (SimpleMenuWidget) w;
+
+ attrs->cursor = smw->simple_menu.cursor;
+ *mask |= CWCursor;
+ if ((smw->simple_menu.backing_store == Always) ||
+ (smw->simple_menu.backing_store == NotUseful) ||
+ (smw->simple_menu.backing_store == WhenMapped) ) {
+ *mask |= CWBackingStore;
+ attrs->backing_store = smw->simple_menu.backing_store;
+ }
+ else
+ *mask &= ~CWBackingStore;
+
+ (*superclass->core_class.realize) (w, mask, attrs);
+}
+
+/* Function Name: Resize
+ * Description: Handle the menu being resized bigger.
+ * Arguments: w - the simple menu widget.
+ * Returns: none.
+ */
+
+static void
+Resize(w)
+Widget w;
+{
+ SimpleMenuWidget smw = (SimpleMenuWidget) w;
+ SmeObject * entry;
+
+ if ( !XtIsRealized(w) ) return;
+
+ ForAllChildren(smw, entry) /* reset width of all entries. */
+ if (XtIsManaged( (Widget) *entry))
+ (*entry)->rectangle.width = smw->core.width;
+
+ Redisplay(w, (XEvent *) NULL, (Region) NULL);
+}
+
+/* Function Name: SetValues
+ * Description: Relayout the menu when one of the resources is changed.
+ * Arguments: current - current state of the widget.
+ * request - what was requested.
+ * new - what the widget will become.
+ * Returns: none
+ */
+
+/* ARGSUSED */
+static Boolean
+SetValues(current, request, new, args, num_args)
+Widget current, request, new;
+ArgList args;
+Cardinal *num_args;
+{
+ SimpleMenuWidget smw_old = (SimpleMenuWidget) current;
+ SimpleMenuWidget smw_new = (SimpleMenuWidget) new;
+ Boolean ret_val = FALSE, layout = FALSE;
+
+ if (!XtIsRealized(current)) return(FALSE);
+
+ if (!smw_new->simple_menu.recursive_set_values) {
+ if (smw_new->core.width != smw_old->core.width) {
+ smw_new->simple_menu.menu_width = (smw_new->core.width != 0);
+ layout = TRUE;
+ }
+ if (smw_new->core.height != smw_old->core.height) {
+ smw_new->simple_menu.menu_height = (smw_new->core.height != 0);
+ layout = TRUE;
+ }
+ }
+
+ if (smw_old->simple_menu.cursor != smw_new->simple_menu.cursor)
+ XDefineCursor(XtDisplay(new),
+ XtWindow(new), smw_new->simple_menu.cursor);
+
+ if (smw_old->simple_menu.label_string !=smw_new->simple_menu.label_string)
+ if (smw_new->simple_menu.label_string == NULL) /* Destroy. */
+ XtDestroyWidget((Widget) smw_old->simple_menu.label);
+ else if (smw_old->simple_menu.label_string == NULL) /* Create. */
+ CreateLabel(new);
+ else { /* Change. */
+ Arg arglist[1];
+
+ XtSetArg(arglist[0], XtNlabel, smw_new->simple_menu.label_string);
+ XtSetValues((Widget) smw_new->simple_menu.label, arglist, ONE);
+ }
+
+ if (smw_old->simple_menu.label_class != smw_new->simple_menu.label_class)
+ XtAppWarning(XtWidgetToApplicationContext(new),
+ "No Dynamic class change of the SimpleMenu Label.");
+
+ if ((smw_old->simple_menu.top_margin != smw_new->simple_menu.top_margin) ||
+ (smw_old->simple_menu.bottom_margin !=
+ smw_new->simple_menu.bottom_margin) /* filler................. */ ) {
+ layout = TRUE;
+ ret_val = TRUE;
+ }
+
+ if (layout)
+ Layout(new, (Dimension *)NULL, (Dimension *)NULL);
+
+ return(ret_val);
+}
+
+/* Function Name: SetValuesHook
+ * Description: To handle a special case, this is passed the
+ * actual arguments.
+ * Arguments: w - the menu widget.
+ * arglist - the argument list passed to XtSetValues.
+ * num_args - the number of args.
+ * Returns: none
+ */
+
+/*
+ * If the user actually passed a width and height to the widget
+ * then this MUST be used, rather than our newly calculated width and
+ * height.
+ */
+
+static Boolean
+SetValuesHook(w, arglist, num_args)
+Widget w;
+ArgList arglist;
+Cardinal *num_args;
+{
+ Cardinal i;
+ Dimension width, height;
+
+ width = w->core.width;
+ height = w->core.height;
+
+ for ( i = 0 ; i < *num_args ; i++) {
+ if ( streq(arglist[i].name, XtNwidth) )
+ width = (Dimension) arglist[i].value;
+ if ( streq(arglist[i].name, XtNheight) )
+ height = (Dimension) arglist[i].value;
+ }
+
+ if ((width != w->core.width) || (height != w->core.height))
+ MakeSetValuesRequest(w, width, height);
+ return(FALSE);
+}
+
+/************************************************************
+ *
+ * Geometry Management routines.
+ *
+ ************************************************************/
+
+/* Function Name: GeometryManager
+ * Description: This is the SimpleMenu Widget's Geometry Manager.
+ * Arguments: w - the Menu Entry making the request.
+ * request - requested new geometry.
+ * reply - the allowed geometry.
+ * Returns: XtGeometry{Yes, No, Almost}.
+ */
+
+static XtGeometryResult
+GeometryManager(w, request, reply)
+Widget w;
+XtWidgetGeometry * request, * reply;
+{
+ SimpleMenuWidget smw = (SimpleMenuWidget) XtParent(w);
+ SmeObject entry = (SmeObject) w;
+ XtGeometryMask mode = request->request_mode;
+ XtGeometryResult answer;
+ Dimension old_height, old_width;
+
+ if ( !(mode & CWWidth) && !(mode & CWHeight) )
+ return(XtGeometryNo);
+
+ reply->width = request->width;
+ reply->height = request->height;
+
+ old_width = entry->rectangle.width;
+ old_height = entry->rectangle.height;
+
+ Layout(w, &(reply->width), &(reply->height) );
+
+/*
+ * Since we are an override shell and have no parent there is no one to
+ * ask to see if this geom change is okay, so I am just going to assume
+ * we can do whatever we want. If you subclass be very careful with this
+ * assumption, it could bite you.
+ *
+ * Chris D. Peterson - Sept. 1989.
+ */
+
+ if ( (reply->width == request->width) &&
+ (reply->height == request->height) ) {
+
+ if ( mode & XtCWQueryOnly ) { /* Actually perform the layout. */
+ entry->rectangle.width = old_width;
+ entry->rectangle.height = old_height;
+ }
+ else {
+ Layout(( Widget) smw, (Dimension *)NULL, (Dimension *)NULL);
+ }
+ answer = XtGeometryDone;
+ }
+ else {
+ entry->rectangle.width = old_width;
+ entry->rectangle.height = old_height;
+
+ if ( ((reply->width == request->width) && !(mode & CWHeight)) ||
+ ((reply->height == request->height) && !(mode & CWWidth)) ||
+ ((reply->width == request->width) &&
+ (reply->height == request->height)) )
+ answer = XtGeometryNo;
+ else {
+ answer = XtGeometryAlmost;
+ reply->request_mode = 0;
+ if (reply->width != request->width)
+ reply->request_mode |= CWWidth;
+ if (reply->height != request->height)
+ reply->request_mode |= CWHeight;
+ }
+ }
+ return(answer);
+}
+
+/* Function Name: ChangeManaged
+ * Description: called whenever a new child is managed.
+ * Arguments: w - the simple menu widget.
+ * Returns: none.
+ */
+
+static void
+ChangeManaged(w)
+Widget w;
+{
+ Layout(w, (Dimension *)NULL, (Dimension *)NULL);
+}
+
+/************************************************************
+ *
+ * Global Action Routines.
+ *
+ * These actions routines will be added to the application's
+ * global action list.
+ *
+ ************************************************************/
+
+/* Function Name: PositionMenuAction
+ * Description: Positions the simple menu widget.
+ * Arguments: w - a widget (no the simple menu widget.)
+ * event - the event that caused this action.
+ * params, num_params - parameters passed to the routine.
+ * we expect the name of the menu here.
+ * Returns: none
+ */
+
+/* ARGSUSED */
+static void
+PositionMenuAction(w, event, params, num_params)
+Widget w;
+XEvent * event;
+String * params;
+Cardinal * num_params;
+{
+ Widget menu;
+ XPoint loc;
+ char error_buf[BUFSIZ];
+ char* ebp;
+ int len;
+ char* fmt = "Xaw SimpleMenuWidget: could not find menu named: \"%s\"";
+
+ if (*num_params != 1) {
+ char error_buf[BUFSIZ];
+ (void) sprintf(error_buf, "%s %s",
+ "Xaw - SimpleMenuWidget: position menu action expects only one",
+ "parameter which is the name of the menu.");
+ XtAppWarning(XtWidgetToApplicationContext(w),
+ "Xaw - SimpleMenuWidget: position menu action expects only one parameter which is the name of the menu.");
+ return;
+ }
+
+ if ( (menu = FindMenu(w, params[0])) == NULL) {
+ if ((len = strlen (fmt) + strlen (params[0])) < sizeof error_buf)
+ ebp = error_buf;
+ else
+ ebp = XtMalloc (len + 1);
+ if (ebp == NULL) {
+ ebp = error_buf;
+ strcpy (ebp, "Xaw - SimpleMenuWidget: could not find menu");
+ } else
+ (void) sprintf(ebp, fmt, params[0]);
+ XtAppWarning(XtWidgetToApplicationContext(w), ebp);
+ if (ebp != error_buf) XtFree (ebp);
+ return;
+ }
+
+ switch (event->type) {
+ case ButtonPress:
+ case ButtonRelease:
+ loc.x = event->xbutton.x_root;
+ loc.y = event->xbutton.y_root;
+ PositionMenu(menu, &loc);
+ break;
+ case EnterNotify:
+ case LeaveNotify:
+ loc.x = event->xcrossing.x_root;
+ loc.y = event->xcrossing.y_root;
+ PositionMenu(menu, &loc);
+ break;
+ case MotionNotify:
+ loc.x = event->xmotion.x_root;
+ loc.y = event->xmotion.y_root;
+ PositionMenu(menu, &loc);
+ break;
+ default:
+ PositionMenu(menu, (XPoint *)NULL);
+ break;
+ }
+}
+
+/************************************************************
+ *
+ * Widget Action Routines.
+ *
+ ************************************************************/
+
+/* Function Name: Unhighlight
+ * Description: Unhighlights current entry.
+ * Arguments: w - the simple menu widget.
+ * event - the event that caused this action.
+ * params, num_params - ** NOT USED **
+ * Returns: none
+ */
+
+/* ARGSUSED */
+static void
+Unhighlight(w, event, params, num_params)
+Widget w;
+XEvent * event;
+String * params;
+Cardinal * num_params;
+{
+ SimpleMenuWidget smw = (SimpleMenuWidget) w;
+ SmeObject entry = smw->simple_menu.entry_set;
+ SmeObjectClass class;
+
+ if ( entry == NULL) return;
+
+ smw->simple_menu.entry_set = NULL;
+ class = (SmeObjectClass) entry->object.widget_class;
+ (class->sme_class.unhighlight) ( (Widget) entry);
+}
+
+/* Function Name: Highlight
+ * Description: Highlights current entry.
+ * Arguments: w - the simple menu widget.
+ * event - the event that caused this action.
+ * params, num_params - ** NOT USED **
+ * Returns: none
+ */
+
+/* ARGSUSED */
+static void
+Highlight(w, event, params, num_params)
+Widget w;
+XEvent * event;
+String * params;
+Cardinal * num_params;
+{
+ SimpleMenuWidget smw = (SimpleMenuWidget) w;
+ SmeObject entry;
+ SmeObjectClass class;
+
+ if ( !XtIsSensitive(w) ) return;
+
+ entry = GetEventEntry(w, event);
+
+ if (entry == smw->simple_menu.entry_set) return;
+
+ Unhighlight(w, event, params, num_params);
+
+ if (entry == NULL) return;
+
+ if ( !XtIsSensitive( (Widget) entry)) {
+ smw->simple_menu.entry_set = NULL;
+ return;
+ }
+
+ smw->simple_menu.entry_set = entry;
+ class = (SmeObjectClass) entry->object.widget_class;
+
+ (class->sme_class.highlight) ( (Widget) entry);
+}
+
+/* Function Name: Notify
+ * Description: Notify user of current entry.
+ * Arguments: w - the simple menu widget.
+ * event - the event that caused this action.
+ * params, num_params - ** NOT USED **
+ * Returns: none
+ */
+
+/* ARGSUSED */
+static void
+Notify(w, event, params, num_params)
+Widget w;
+XEvent * event;
+String * params;
+Cardinal * num_params;
+{
+ SimpleMenuWidget smw = (SimpleMenuWidget) w;
+ SmeObject entry = smw->simple_menu.entry_set;
+ SmeObjectClass class;
+
+ if ( (entry == NULL) || !XtIsSensitive((Widget) entry ) ) return;
+
+ class = (SmeObjectClass) entry->object.widget_class;
+ (class->sme_class.notify)( (Widget) entry );
+}
+
+/************************************************************
+ *
+ * Public Functions.
+ *
+ ************************************************************/
+
+/* Function Name: XawSimpleMenuAddGlobalActions
+ * Description: adds the global actions to the simple menu widget.
+ * Arguments: app_con - the appcontext.
+ * Returns: none.
+ */
+
+void
+#if NeedFunctionPrototypes
+XawSimpleMenuAddGlobalActions(XtAppContext app_con)
+#else
+XawSimpleMenuAddGlobalActions(app_con)
+XtAppContext app_con;
+#endif
+{
+ XtInitializeWidgetClass(simpleMenuWidgetClass);
+ XmuCallInitializers( app_con );
+}
+
+
+/* Function Name: XawSimpleMenuGetActiveEntry
+ * Description: Gets the currently active (set) entry.
+ * Arguments: w - the smw widget.
+ * Returns: the currently set entry or NULL if none is set.
+ */
+
+Widget
+#if NeedFunctionPrototypes
+XawSimpleMenuGetActiveEntry(Widget w)
+#else
+XawSimpleMenuGetActiveEntry(w)
+Widget w;
+#endif
+{
+ SimpleMenuWidget smw = (SimpleMenuWidget) w;
+
+ return( (Widget) smw->simple_menu.entry_set);
+}
+
+/* Function Name: XawSimpleMenuClearActiveEntry
+ * Description: Unsets the currently active (set) entry.
+ * Arguments: w - the smw widget.
+ * Returns: none.
+ */
+
+void
+#if NeedFunctionPrototypes
+XawSimpleMenuClearActiveEntry(Widget w)
+#else
+XawSimpleMenuClearActiveEntry(w)
+Widget w;
+#endif
+{
+ SimpleMenuWidget smw = (SimpleMenuWidget) w;
+
+ smw->simple_menu.entry_set = NULL;
+}
+
+/************************************************************
+ *
+ * Private Functions.
+ *
+ ************************************************************/
+
+/* Function Name: CreateLabel
+ * Description: Creates a the menu label.
+ * Arguments: w - the smw widget.
+ * Returns: none.
+ *
+ * Creates the label object and makes sure it is the first child in
+ * in the list.
+ */
+
+static void
+CreateLabel(w)
+Widget w;
+{
+ SimpleMenuWidget smw = (SimpleMenuWidget) w;
+ Widget * child, * next_child;
+ int i;
+ Arg args[2];
+
+ if ( (smw->simple_menu.label_string == NULL) ||
+ (smw->simple_menu.label != NULL) ) {
+ char error_buf[BUFSIZ];
+
+ (void) sprintf(error_buf, "Xaw Simple Menu Widget: %s or %s, %s",
+ "label string is NULL", "label already exists",
+ "no label is being created.");
+ XtAppWarning(XtWidgetToApplicationContext(w), error_buf);
+ return;
+ }
+
+ XtSetArg(args[0], XtNlabel, smw->simple_menu.label_string);
+ XtSetArg(args[1], XtNjustify, XtJustifyCenter);
+ smw->simple_menu.label = (SmeObject)
+ XtCreateManagedWidget("menuLabel",
+ smw->simple_menu.label_class, w,
+ args, TWO);
+
+ next_child = NULL;
+ for (child = smw->composite.children + smw->composite.num_children,
+ i = smw->composite.num_children ; i > 0 ; i--, child--) {
+ if (next_child != NULL)
+ *next_child = *child;
+ next_child = child;
+ }
+ *child = (Widget) smw->simple_menu.label;
+}
+
+/* Function Name: Layout
+ * Description: lays the menu entries out all nice and neat.
+ * Arguments: w - See below (+++)
+ * width_ret, height_ret - The returned width and
+ * height values.
+ * Returns: none.
+ *
+ * if width == NULL || height == NULL then it assumes the you do not care
+ * about the return values, and just want a relayout.
+ *
+ * if this is not the case then it will set width_ret and height_ret
+ * to be width and height that the child would get if it were layed out
+ * at this time.
+ *
+ * +++ "w" can be the simple menu widget or any of its object children.
+ */
+
+static void
+Layout(w, width_ret, height_ret)
+Widget w;
+Dimension *width_ret, *height_ret;
+{
+ SmeObject current_entry, *entry;
+ SimpleMenuWidget smw;
+ Dimension width, height;
+ Boolean do_layout = ((height_ret == NULL) || (width_ret == NULL));
+ Boolean allow_change_size;
+ height = 0;
+
+ if ( XtIsSubclass(w, simpleMenuWidgetClass) ) {
+ smw = (SimpleMenuWidget) w;
+ current_entry = NULL;
+ }
+ else {
+ smw = (SimpleMenuWidget) XtParent(w);
+ current_entry = (SmeObject) w;
+ }
+
+ allow_change_size = (!XtIsRealized((Widget)smw) ||
+ (smw->shell.allow_shell_resize));
+
+ if ( smw->simple_menu.menu_height )
+ height = smw->core.height;
+ else
+ if (do_layout) {
+ height = smw->simple_menu.top_margin;
+ ForAllChildren(smw, entry) {
+ if (!XtIsManaged( (Widget) *entry)) continue;
+
+ if ( (smw->simple_menu.row_height != 0) &&
+ (*entry != smw->simple_menu.label) )
+ (*entry)->rectangle.height = smw->simple_menu.row_height;
+
+ (*entry)->rectangle.y = height;
+ (*entry)->rectangle.x = 0;
+ height += (*entry)->rectangle.height;
+ }
+ height += smw->simple_menu.bottom_margin;
+ }
+ else {
+ if ((smw->simple_menu.row_height != 0) &&
+ (current_entry != smw->simple_menu.label) )
+ height = smw->simple_menu.row_height;
+ }
+
+ if (smw->simple_menu.menu_width)
+ width = smw->core.width;
+ else if ( allow_change_size )
+ width = GetMenuWidth((Widget) smw, (Widget) current_entry);
+ else
+ width = smw->core.width;
+
+ if (do_layout) {
+ ForAllChildren(smw, entry)
+ if (XtIsManaged( (Widget) *entry))
+ (*entry)->rectangle.width = width;
+
+ if (allow_change_size)
+ MakeSetValuesRequest((Widget) smw, width, height);
+ }
+ else {
+ *width_ret = width;
+ if (height != 0)
+ *height_ret = height;
+ }
+}
+
+/* Function Name: AddPositionAction
+ * Description: Adds the XawPositionSimpleMenu action to the global
+ * action list for this appcon.
+ * Arguments: app_con - the application context for this app.
+ * data - NOT USED.
+ * Returns: none.
+ */
+
+/* ARGSUSED */
+static void
+AddPositionAction(app_con, data)
+XtAppContext app_con;
+XPointer data;
+{
+ static XtActionsRec pos_action[] = {
+ { "XawPositionSimpleMenu", PositionMenuAction },
+ };
+
+ XtAppAddActions(app_con, pos_action, XtNumber(pos_action));
+}
+
+/* Function Name: FindMenu
+ * Description: Find the menu give a name and reference widget.
+ * Arguments: widget - reference widget.
+ * name - the menu widget's name.
+ * Returns: the menu widget or NULL.
+ */
+
+static Widget
+FindMenu(widget, name)
+Widget widget;
+String name;
+{
+ Widget w, menu;
+
+ for ( w = widget ; w != NULL ; w = XtParent(w) )
+ if ( (menu = XtNameToWidget(w, name)) != NULL )
+ return(menu);
+ return(NULL);
+}
+
+/* Function Name: PositionMenu
+ * Description: Places the menu
+ * Arguments: w - the simple menu widget.
+ * location - a pointer the the position or NULL.
+ * Returns: none.
+ */
+
+static void
+PositionMenu(w, location)
+Widget w;
+XPoint * location;
+{
+ SimpleMenuWidget smw = (SimpleMenuWidget) w;
+ SmeObject entry;
+ XPoint t_point;
+
+ if (location == NULL) {
+ Window junk1, junk2;
+ int root_x, root_y, junkX, junkY;
+ unsigned int junkM;
+
+ location = &t_point;
+ if (XQueryPointer(XtDisplay(w), XtWindow(w), &junk1, &junk2,
+ &root_x, &root_y, &junkX, &junkY, &junkM) == FALSE) {
+ char error_buf[BUFSIZ];
+ (void) sprintf(error_buf, "%s %s", "Xaw Simple Menu Widget:",
+ "Could not find location of mouse pointer");
+ XtAppWarning(XtWidgetToApplicationContext(w), error_buf);
+ return;
+ }
+ location->x = (short) root_x;
+ location->y = (short) root_y;
+ }
+
+ /*
+ * The width will not be correct unless it is realized.
+ */
+
+ XtRealizeWidget(w);
+
+ location->x -= (Position) w->core.width/2;
+
+ if (smw->simple_menu.popup_entry == NULL)
+ entry = smw->simple_menu.label;
+ else
+ entry = smw->simple_menu.popup_entry;
+
+ if (entry != NULL)
+ location->y -= entry->rectangle.y + entry->rectangle.height/2;
+
+ MoveMenu(w, (Position) location->x, (Position) location->y);
+}
+
+/* Function Name: MoveMenu
+ * Description: Actually moves the menu, may force it to
+ * to be fully visable if menu_on_screen is TRUE.
+ * Arguments: w - the simple menu widget.
+ * x, y - the current location of the widget.
+ * Returns: none
+ */
+
+static void
+MoveMenu(w, x, y)
+Widget w;
+Position x, y;
+{
+ Arg arglist[2];
+ Cardinal num_args = 0;
+ SimpleMenuWidget smw = (SimpleMenuWidget) w;
+
+ if (smw->simple_menu.menu_on_screen) {
+ int width = w->core.width + 2 * w->core.border_width;
+ int height = w->core.height + 2 * w->core.border_width;
+
+ if (x >= 0) {
+ int scr_width = WidthOfScreen(XtScreen(w));
+ if (x + width > scr_width)
+ x = scr_width - width;
+ }
+ if (x < 0)
+ x = 0;
+
+ if (y >= 0) {
+ int scr_height = HeightOfScreen(XtScreen(w));
+ if (y + height > scr_height)
+ y = scr_height - height;
+ }
+ if (y < 0)
+ y = 0;
+ }
+
+ XtSetArg(arglist[num_args], XtNx, x); num_args++;
+ XtSetArg(arglist[num_args], XtNy, y); num_args++;
+ XtSetValues(w, arglist, num_args);
+}
+
+/* Function Name: ChangeCursorOnGrab
+ * Description: Changes the cursor on the active grab to the one
+ * specified in out resource list.
+ * Arguments: w - the widget.
+ * junk, garbage - ** NOT USED **.
+ * Returns: None.
+ */
+
+/* ARGSUSED */
+static void
+ChangeCursorOnGrab(w, junk, garbage)
+Widget w;
+XtPointer junk, garbage;
+{
+ SimpleMenuWidget smw = (SimpleMenuWidget) w;
+
+ /*
+ * The event mask here is what is currently in the MIT implementation.
+ * There really needs to be a way to get the value of the mask out
+ * of the toolkit (CDP 5/26/89).
+ */
+
+ XChangeActivePointerGrab(XtDisplay(w), ButtonPressMask|ButtonReleaseMask,
+ smw->simple_menu.cursor,
+ XtLastTimestampProcessed(XtDisplay(w)));
+}
+
+/* Function Name: MakeSetValuesRequest
+ * Description: Makes a (possibly recursive) call to SetValues,
+ * I take great pains to not go into an infinite loop.
+ * Arguments: w - the simple menu widget.
+ * width, height - the size of the ask for.
+ * Returns: none
+ */
+
+static void
+MakeSetValuesRequest(w, width, height)
+Widget w;
+Dimension width, height;
+{
+ SimpleMenuWidget smw = (SimpleMenuWidget) w;
+ Arg arglist[2];
+ Cardinal num_args = (Cardinal) 0;
+
+ if ( !smw->simple_menu.recursive_set_values ) {
+ if ( (smw->core.width != width) || (smw->core.height != height) ) {
+ smw->simple_menu.recursive_set_values = TRUE;
+ XtSetArg(arglist[num_args], XtNwidth, width); num_args++;
+ XtSetArg(arglist[num_args], XtNheight, height); num_args++;
+ XtSetValues(w, arglist, num_args);
+ }
+ else if (XtIsRealized( (Widget) smw))
+ Redisplay((Widget) smw, (XEvent *) NULL, (Region) NULL);
+ }
+ smw->simple_menu.recursive_set_values = FALSE;
+}
+
+/* Function Name: GetMenuWidth
+ * Description: Sets the length of the widest entry in pixels.
+ * Arguments: w - the simple menu widget.
+ * Returns: width of menu.
+ */
+
+static Dimension
+GetMenuWidth(w, w_ent)
+Widget w, w_ent;
+{
+ SmeObject cur_entry = (SmeObject) w_ent;
+ SimpleMenuWidget smw = (SimpleMenuWidget) w;
+ Dimension width, widest = (Dimension) 0;
+ SmeObject * entry;
+
+ if ( smw->simple_menu.menu_width )
+ return(smw->core.width);
+
+ ForAllChildren(smw, entry) {
+ XtWidgetGeometry preferred;
+
+ if (!XtIsManaged( (Widget) *entry)) continue;
+
+ if (*entry != cur_entry) {
+ XtQueryGeometry((Widget) *entry, (XtWidgetGeometry *)NULL, &preferred);
+
+ if (preferred.request_mode & CWWidth)
+ width = preferred.width;
+ else
+ width = (*entry)->rectangle.width;
+ }
+ else
+ width = (*entry)->rectangle.width;
+
+ if ( width > widest )
+ widest = width;
+ }
+
+ return(widest);
+}
+
+/* Function Name: GetMenuHeight
+ * Description: Sets the length of the widest entry in pixels.
+ * Arguments: w - the simple menu widget.
+ * Returns: width of menu.
+ */
+
+static Dimension
+GetMenuHeight(w)
+Widget w;
+{
+ SimpleMenuWidget smw = (SimpleMenuWidget) w;
+ SmeObject * entry;
+ Dimension height;
+
+ if (smw->simple_menu.menu_height)
+ return(smw->core.height);
+
+ height = smw->simple_menu.top_margin + smw->simple_menu.bottom_margin;
+
+ if (smw->simple_menu.row_height == 0) {
+ ForAllChildren(smw, entry)
+ if (XtIsManaged ((Widget) *entry))
+ height += (*entry)->rectangle.height;
+ } else
+ height += smw->simple_menu.row_height * smw->composite.num_children;
+
+ return(height);
+}
+
+/* Function Name: GetEventEntry
+ * Description: Gets an entry given an event that has X and Y coords.
+ * Arguments: w - the simple menu widget.
+ * event - the event.
+ * Returns: the entry that this point is in.
+ */
+
+static SmeObject
+GetEventEntry(w, event)
+Widget w;
+XEvent * event;
+{
+ Position x_loc, y_loc;
+ SimpleMenuWidget smw = (SimpleMenuWidget) w;
+ SmeObject * entry;
+
+ switch (event->type) {
+ case MotionNotify:
+ x_loc = event->xmotion.x;
+ y_loc = event->xmotion.y;
+ break;
+ case EnterNotify:
+ case LeaveNotify:
+ x_loc = event->xcrossing.x;
+ y_loc = event->xcrossing.y;
+ break;
+ case ButtonPress:
+ case ButtonRelease:
+ x_loc = event->xbutton.x;
+ y_loc = event->xbutton.y;
+ break;
+ default:
+ XtAppError(XtWidgetToApplicationContext(w),
+ "Unknown event type in GetEventEntry().");
+ break;
+ }
+
+ if ( (x_loc < 0) || (x_loc >= (int)smw->core.width) || (y_loc < 0) ||
+ (y_loc >= (int)smw->core.height) )
+ return(NULL);
+
+ ForAllChildren(smw, entry) {
+ if (!XtIsManaged ((Widget) *entry)) continue;
+
+ if ( ((*entry)->rectangle.y < y_loc) &&
+ ((*entry)->rectangle.y + (int) (*entry)->rectangle.height > y_loc) )
+ if ( *entry == smw->simple_menu.label )
+ return(NULL); /* cannot select the label. */
+ else
+ return(*entry);
+ }
+
+ return(NULL);
+}
diff --git a/src/Sme.c b/src/Sme.c
new file mode 100644
index 0000000..2d681a4
--- /dev/null
+++ b/src/Sme.c
@@ -0,0 +1,243 @@
+/* $Xorg: Sme.c,v 1.4 2001/02/09 02:03:45 xorgcvs Exp $ */
+
+/*
+Copyright 1989, 1994, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+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
+OPEN GROUP 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 Open Group 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 Open Group.
+ */
+
+/*
+ * Sme.c - Source code for the generic menu entry
+ *
+ * Date: September 26, 1989
+ *
+ * By: Chris D. Peterson
+ * MIT X Consortium
+ * kit@expo.lcs.mit.edu
+ */
+
+#include <stdio.h>
+#include <X11/IntrinsicP.h>
+#include <X11/StringDefs.h>
+
+#include <X11/Xaw/XawInit.h>
+#include <X11/Xaw/SmeP.h>
+#include <X11/Xaw/Cardinals.h>
+
+#define offset(field) XtOffsetOf(SmeRec, sme.field)
+static XtResource resources[] = {
+ {XtNcallback, XtCCallback, XtRCallback, sizeof(XtPointer),
+ offset(callbacks), XtRCallback, (XtPointer)NULL},
+ {XtNinternational, XtCInternational, XtRBoolean, sizeof(Boolean),
+ offset(international), XtRImmediate, (XtPointer) FALSE},
+};
+#undef offset
+
+/*
+ * Semi Public function definitions.
+ */
+
+static void Unhighlight(), Highlight(), Notify(), ClassPartInitialize();
+static void Initialize();
+static XtGeometryResult QueryGeometry();
+
+#define SUPERCLASS (&rectObjClassRec)
+
+SmeClassRec smeClassRec = {
+ {
+ /* superclass */ (WidgetClass) SUPERCLASS,
+ /* class_name */ "Sme",
+ /* size */ sizeof(SmeRec),
+ /* class_initialize */ XawInitializeWidgetSet,
+ /* class_part_initialize*/ ClassPartInitialize,
+ /* Class init'ed */ FALSE,
+ /* initialize */ Initialize,
+ /* initialize_hook */ NULL,
+ /* realize */ NULL,
+ /* actions */ NULL,
+ /* num_actions */ ZERO,
+ /* resources */ resources,
+ /* resource_count */ XtNumber(resources),
+ /* xrm_class */ NULLQUARK,
+ /* compress_motion */ FALSE,
+ /* compress_exposure */ FALSE,
+ /* compress_enterleave*/ FALSE,
+ /* visible_interest */ FALSE,
+ /* destroy */ NULL,
+ /* resize */ NULL,
+ /* expose */ NULL,
+ /* set_values */ NULL,
+ /* set_values_hook */ NULL,
+ /* set_values_almost */ XtInheritSetValuesAlmost,
+ /* get_values_hook */ NULL,
+ /* accept_focus */ NULL,
+ /* intrinsics version */ XtVersion,
+ /* callback offsets */ NULL,
+ /* tm_table */ NULL,
+ /* query_geometry */ QueryGeometry,
+ /* display_accelerator*/ NULL,
+ /* extension */ NULL
+ },{
+ /* Simple Menu Entry Fields */
+
+ /* highlight */ Highlight,
+ /* unhighlight */ Unhighlight,
+ /* notify */ Notify,
+ /* extension */ NULL
+ }
+};
+
+WidgetClass smeObjectClass = (WidgetClass) &smeClassRec;
+
+/************************************************************
+ *
+ * Semi-Public Functions.
+ *
+ ************************************************************/
+
+/* Function Name: ClassPartInitialize
+ * Description: handles inheritance of class functions.
+ * Arguments: class - the widget classs of this widget.
+ * Returns: none.
+ */
+
+static void
+ClassPartInitialize(class)
+WidgetClass class;
+{
+ SmeObjectClass m_ent, superC;
+
+ m_ent = (SmeObjectClass) class;
+ superC = (SmeObjectClass) m_ent->rect_class.superclass;
+
+/*
+ * We don't need to check for null super since we'll get to TextSink
+ * eventually.
+ */
+
+ if (m_ent->sme_class.highlight == XtInheritHighlight)
+ m_ent->sme_class.highlight = superC->sme_class.highlight;
+
+ if (m_ent->sme_class.unhighlight == XtInheritUnhighlight)
+ m_ent->sme_class.unhighlight = superC->sme_class.unhighlight;
+
+ if (m_ent->sme_class.notify == XtInheritNotify)
+ m_ent->sme_class.notify = superC->sme_class.notify;
+}
+
+/* Function Name: Initialize
+ * Description: Initializes the simple menu widget
+ * Arguments: request - the widget requested by the argument list.
+ * new - the new widget with both resource and non
+ * resource values.
+ * Returns: none.
+ *
+ * MENU ENTRIES CANNOT HAVE BORDERS.
+ */
+
+/* ARGSUSED */
+static void
+Initialize(request, new, args, num_args)
+Widget request, new;
+ArgList args;
+Cardinal *num_args;
+{
+ SmeObject entry = (SmeObject) new;
+
+ entry->rectangle.border_width = 0;
+}
+
+/* Function Name: Highlight
+ * Description: The default highlight proceedure for menu entries.
+ * Arguments: w - the menu entry.
+ * Returns: none.
+ */
+
+/* ARGSUSED */
+static void
+Highlight(w)
+Widget w;
+{
+/* This space intentionally left blank. */
+}
+
+/* Function Name: Unhighlight
+ * Description: The default unhighlight proceedure for menu entries.
+ * Arguments: w - the menu entry.
+ * Returns: none.
+ */
+
+/* ARGSUSED */
+static void
+Unhighlight(w)
+Widget w;
+{
+/* This space intentionally left blank. */
+}
+
+/* Function Name: Notify
+ * Description: calls the callback proceedures for this entry.
+ * Arguments: w - the menu entry.
+ * Returns: none.
+ */
+
+static void
+Notify(w)
+Widget w;
+{
+ XtCallCallbacks(w, XtNcallback, (XtPointer)NULL);
+}
+
+/* Function Name: QueryGeometry.
+ * Description: Returns the preferred geometry for this widget.
+ * Arguments: w - the menu entry object.
+ * itended, return - the intended and return geometry info.
+ * Returns: A Geometry Result.
+ *
+ * See the Intrinsics manual for details on what this function is for.
+ *
+ * I just return the height and a width of 1.
+ */
+
+static XtGeometryResult
+QueryGeometry(w, intended, return_val)
+Widget w;
+XtWidgetGeometry *intended, *return_val;
+{
+ SmeObject entry = (SmeObject) w;
+ Dimension width;
+ XtGeometryResult ret_val = XtGeometryYes;
+ XtGeometryMask mode = intended->request_mode;
+
+ width = 1; /* we can be really small. */
+
+ if ( ((mode & CWWidth) && (intended->width != width)) ||
+ !(mode & CWWidth) ) {
+ return_val->request_mode |= CWWidth;
+ return_val->width = width;
+ mode = return_val->request_mode;
+
+ if ( (mode & CWWidth) && (width == entry->rectangle.width) )
+ return(XtGeometryNo);
+ return(XtGeometryAlmost);
+ }
+ return(ret_val);
+}
diff --git a/src/SmeBSB.c b/src/SmeBSB.c
new file mode 100644
index 0000000..92fb0a6
--- /dev/null
+++ b/src/SmeBSB.c
@@ -0,0 +1,750 @@
+/* $Xorg: SmeBSB.c,v 1.5 2001/02/09 02:03:45 xorgcvs Exp $ */
+
+/*
+Copyright 1989, 1994, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+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
+OPEN GROUP 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 Open Group 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 Open Group.
+ */
+
+/*
+ * SmeBSB.c - Source code file for BSB Menu Entry object.
+ *
+ * Date: September 26, 1989
+ *
+ * By: Chris D. Peterson
+ * MIT X Consortium
+ * kit@expo.lcs.mit.edu
+ */
+
+#include <X11/IntrinsicP.h>
+#include <X11/StringDefs.h>
+#include <X11/Xos.h>
+
+/* needed for abs() */
+#ifdef X_NOT_STDC_ENV
+extern int abs();
+#else
+#include <stdlib.h>
+#endif
+
+#include <X11/Xmu/Drawing.h>
+
+#include <X11/Xaw/XawInit.h>
+#include <X11/Xaw/SimpleMenu.h>
+#include <X11/Xaw/SmeBSBP.h>
+#include <X11/Xaw/Cardinals.h>
+
+#include <stdio.h>
+
+#define ONE_HUNDRED 100
+
+#define offset(field) XtOffsetOf(SmeBSBRec, sme_bsb.field)
+
+static XtResource resources[] = {
+ {XtNlabel, XtCLabel, XtRString, sizeof(String),
+ offset(label), XtRString, NULL},
+ {XtNvertSpace, XtCVertSpace, XtRInt, sizeof(int),
+ offset(vert_space), XtRImmediate, (XtPointer) 25},
+ {XtNleftBitmap, XtCLeftBitmap, XtRBitmap, sizeof(Pixmap),
+ offset(left_bitmap), XtRImmediate, (XtPointer)None},
+ {XtNjustify, XtCJustify, XtRJustify, sizeof(XtJustify),
+ offset(justify), XtRImmediate, (XtPointer) XtJustifyLeft},
+ {XtNrightBitmap, XtCRightBitmap, XtRBitmap, sizeof(Pixmap),
+ offset(right_bitmap), XtRImmediate, (XtPointer)None},
+ {XtNleftMargin, XtCHorizontalMargins, XtRDimension, sizeof(Dimension),
+ offset(left_margin), XtRImmediate, (XtPointer) 4},
+ {XtNrightMargin, XtCHorizontalMargins, XtRDimension, sizeof(Dimension),
+ offset(right_margin), XtRImmediate, (XtPointer) 4},
+ {XtNforeground, XtCForeground, XtRPixel, sizeof(Pixel),
+ offset(foreground), XtRString, XtDefaultForeground},
+ {XtNfont, XtCFont, XtRFontStruct, sizeof(XFontStruct *),
+ offset(font), XtRString, XtDefaultFont},
+ {XtNfontSet, XtCFontSet, XtRFontSet, sizeof(XFontSet ),
+ offset(fontset),XtRString, XtDefaultFontSet},
+};
+#undef offset
+
+/*
+ * Semi Public function definitions.
+ */
+
+static void Redisplay(), Destroy(), Initialize(), FlipColors();
+static void ClassInitialize();
+static Boolean SetValues();
+static XtGeometryResult QueryGeometry();
+
+/*
+ * Private Function Definitions.
+ */
+
+static void GetDefaultSize(), DrawBitmaps(), GetBitmapInfo();
+static void CreateGCs(), DestroyGCs();
+
+#define superclass (&smeClassRec)
+SmeBSBClassRec smeBSBClassRec = {
+ {
+ /* superclass */ (WidgetClass) superclass,
+ /* class_name */ "SmeBSB",
+ /* size */ sizeof(SmeBSBRec),
+ /* class_initializer */ ClassInitialize,
+ /* class_part_initialize*/ NULL,
+ /* Class init'ed */ FALSE,
+ /* initialize */ Initialize,
+ /* initialize_hook */ NULL,
+ /* realize */ NULL,
+ /* actions */ NULL,
+ /* num_actions */ ZERO,
+ /* resources */ resources,
+ /* resource_count */ XtNumber(resources),
+ /* xrm_class */ NULLQUARK,
+ /* compress_motion */ FALSE,
+ /* compress_exposure */ FALSE,
+ /* compress_enterleave*/ FALSE,
+ /* visible_interest */ FALSE,
+ /* destroy */ Destroy,
+ /* resize */ NULL,
+ /* expose */ Redisplay,
+ /* set_values */ SetValues,
+ /* set_values_hook */ NULL,
+ /* set_values_almost */ XtInheritSetValuesAlmost,
+ /* get_values_hook */ NULL,
+ /* accept_focus */ NULL,
+ /* intrinsics version */ XtVersion,
+ /* callback offsets */ NULL,
+ /* tm_table */ NULL,
+ /* query_geometry */ QueryGeometry,
+ /* display_accelerator*/ NULL,
+ /* extension */ NULL
+ },{
+ /* SimpleMenuClass Fields */
+ /* highlight */ FlipColors,
+ /* unhighlight */ FlipColors,
+ /* notify */ XtInheritNotify,
+ /* extension */ NULL
+ }, {
+ /* BSBClass Fields */
+ /* extension */ NULL
+ }
+};
+
+WidgetClass smeBSBObjectClass = (WidgetClass) &smeBSBClassRec;
+
+/************************************************************
+ *
+ * Semi-Public Functions.
+ *
+ ************************************************************/
+
+/* Function Name: ClassInitialize
+ * Description: Initializes the SmeBSBObject.
+ * Arguments: none.
+ * Returns: none.
+ */
+
+static void
+ClassInitialize()
+{
+ XawInitializeWidgetSet();
+ XtAddConverter( XtRString, XtRJustify, XmuCvtStringToJustify,
+ (XtConvertArgList)NULL, (Cardinal)0 );
+}
+
+/* Function Name: Initialize
+ * Description: Initializes the simple menu widget
+ * Arguments: request - the widget requested by the argument list.
+ * new - the new widget with both resource and non
+ * resource values.
+ * Returns: none.
+ */
+
+/* ARGSUSED */
+static void
+Initialize(request, new, args, num_args)
+Widget request, new;
+ArgList args;
+Cardinal *num_args;
+{
+ SmeBSBObject entry = (SmeBSBObject) new;
+
+ if (entry->sme_bsb.label == NULL)
+ entry->sme_bsb.label = XtName(new);
+ else
+ entry->sme_bsb.label = XtNewString( entry->sme_bsb.label );
+
+ GetDefaultSize(new, &(entry->rectangle.width), &(entry->rectangle.height));
+ CreateGCs(new);
+
+ entry->sme_bsb.left_bitmap_width = entry->sme_bsb.left_bitmap_height = 0;
+ entry->sme_bsb.right_bitmap_width = entry->sme_bsb.right_bitmap_height = 0;
+
+ GetBitmapInfo(new, TRUE); /* Left Bitmap Info */
+ GetBitmapInfo(new, FALSE); /* Right Bitmap Info */
+}
+
+/* Function Name: Destroy
+ * Description: Called at destroy time, cleans up.
+ * Arguments: w - the simple menu widget.
+ * Returns: none.
+ */
+
+static void
+Destroy(w)
+Widget w;
+{
+ SmeBSBObject entry = (SmeBSBObject) w;
+
+ DestroyGCs(w);
+ if (entry->sme_bsb.label != XtName(w))
+ XtFree(entry->sme_bsb.label);
+}
+
+/* Function Name: Redisplay
+ * Description: Redisplays the contents of the widget.
+ * Arguments: w - the simple menu widget.
+ * event - the X event that caused this redisplay.
+ * region - the region the needs to be repainted.
+ * Returns: none.
+ */
+
+/* ARGSUSED */
+static void
+Redisplay(w, event, region)
+Widget w;
+XEvent * event;
+Region region;
+{
+ GC gc;
+ SmeBSBObject entry = (SmeBSBObject) w;
+ int font_ascent, font_descent, y_loc;
+
+ int fontset_ascent, fontset_descent;
+ XFontSetExtents *ext = XExtentsOfFontSet(entry->sme_bsb.fontset);
+
+ entry->sme_bsb.set_values_area_cleared = FALSE;
+ if ( entry->sme.international == True ) {
+ fontset_ascent = abs(ext->max_ink_extent.y);
+ fontset_descent = ext->max_ink_extent.height - fontset_ascent;
+ }
+ else { /*else, compute size from font like R5*/
+ font_ascent = entry->sme_bsb.font->max_bounds.ascent;
+ font_descent = entry->sme_bsb.font->max_bounds.descent;
+ }
+ y_loc = entry->rectangle.y;
+
+
+ if (XtIsSensitive(w) && XtIsSensitive( XtParent(w) ) ) {
+ if ( w == XawSimpleMenuGetActiveEntry(XtParent(w)) ) {
+ XFillRectangle(XtDisplayOfObject(w), XtWindowOfObject(w),
+ entry->sme_bsb.norm_gc, 0, y_loc,
+ (unsigned int) entry->rectangle.width,
+ (unsigned int) entry->rectangle.height);
+ gc = entry->sme_bsb.rev_gc;
+ }
+ else
+ gc = entry->sme_bsb.norm_gc;
+ }
+ else
+ gc = entry->sme_bsb.norm_gray_gc;
+
+ if (entry->sme_bsb.label != NULL) {
+ int x_loc = entry->sme_bsb.left_margin;
+ int len = strlen(entry->sme_bsb.label);
+ char * label = entry->sme_bsb.label;
+
+ switch(entry->sme_bsb.justify) {
+ int width, t_width;
+
+ case XtJustifyCenter:
+ if ( entry->sme.international == True ) {
+ t_width = XmbTextEscapement(entry->sme_bsb.fontset,label,len);
+ width = entry->rectangle.width - (entry->sme_bsb.left_margin +
+ entry->sme_bsb.right_margin);
+ }
+ else {
+ t_width = XTextWidth(entry->sme_bsb.font, label, len);
+ width = entry->rectangle.width - (entry->sme_bsb.left_margin +
+ entry->sme_bsb.right_margin);
+ }
+ x_loc += (width - t_width)/2;
+ break;
+ case XtJustifyRight:
+ if ( entry->sme.international == True ) {
+ t_width = XmbTextEscapement(entry->sme_bsb.fontset,label,len);
+ x_loc = entry->rectangle.width - ( entry->sme_bsb.right_margin
+ + t_width );
+ }
+ else {
+ t_width = XTextWidth(entry->sme_bsb.font, label, len);
+ x_loc = entry->rectangle.width - ( entry->sme_bsb.right_margin
+ + t_width );
+ }
+ break;
+ case XtJustifyLeft:
+ default:
+ break;
+ }
+
+
+ /* this will center the text in the gadget top-to-bottom */
+
+ if ( entry->sme.international==True ) {
+ y_loc += ((int)entry->rectangle.height -
+ (fontset_ascent + fontset_descent)) / 2 + fontset_ascent;
+
+ XmbDrawString(XtDisplayOfObject(w), XtWindowOfObject(w),
+ entry->sme_bsb.fontset, gc, x_loc, y_loc, label, len);
+ }
+ else {
+ y_loc += ((int)entry->rectangle.height -
+ (font_ascent + font_descent)) / 2 + font_ascent;
+
+ XDrawString(XtDisplayOfObject(w), XtWindowOfObject(w), gc,
+ x_loc, y_loc, label, len);
+ }
+ }
+
+ DrawBitmaps(w, gc);
+}
+
+
+/* Function Name: SetValues
+ * Description: Relayout the menu when one of the resources is changed.
+ * Arguments: current - current state of the widget.
+ * request - what was requested.
+ * new - what the widget will become.
+ * Returns: none
+ */
+
+/* ARGSUSED */
+static Boolean
+SetValues(current, request, new, args, num_args)
+Widget current, request, new;
+ArgList args;
+Cardinal *num_args;
+{
+ SmeBSBObject entry = (SmeBSBObject) new;
+ SmeBSBObject old_entry = (SmeBSBObject) current;
+ Boolean ret_val = FALSE;
+
+ if (old_entry->sme_bsb.label != entry->sme_bsb.label) {
+ if (old_entry->sme_bsb.label != XtName( new ) )
+ XtFree( (char *) old_entry->sme_bsb.label );
+
+ if (entry->sme_bsb.label != XtName(new) )
+ entry->sme_bsb.label = XtNewString( entry->sme_bsb.label );
+
+ ret_val = True;
+ }
+
+ if (entry->rectangle.sensitive != old_entry->rectangle.sensitive )
+ ret_val = TRUE;
+
+ if (entry->sme_bsb.left_bitmap != old_entry->sme_bsb.left_bitmap) {
+ GetBitmapInfo(new, TRUE);
+ ret_val = TRUE;
+ }
+
+ if (entry->sme_bsb.right_bitmap != old_entry->sme_bsb.right_bitmap) {
+ GetBitmapInfo(new, FALSE);
+ ret_val = TRUE;
+ }
+
+ if ( ( (old_entry->sme_bsb.font != entry->sme_bsb.font) &&
+ (old_entry->sme.international == False ) ) ||
+ (old_entry->sme_bsb.foreground != entry->sme_bsb.foreground) ) {
+ DestroyGCs(current);
+ CreateGCs(new);
+ ret_val = TRUE;
+ }
+
+ if ( ( old_entry->sme_bsb.fontset != entry->sme_bsb.fontset) &&
+ (old_entry->sme.international == True ) )
+ /* DONT changes the GCs, because the fontset is not in them. */
+ ret_val = TRUE;
+
+ if (ret_val) {
+ GetDefaultSize(new,
+ &(entry->rectangle.width), &(entry->rectangle.height));
+ entry->sme_bsb.set_values_area_cleared = TRUE;
+ }
+ return(ret_val);
+}
+
+/* Function Name: QueryGeometry.
+ * Description: Returns the preferred geometry for this widget.
+ * Arguments: w - the menu entry object.
+ * itended, return_val - the intended and return geometry info.
+ * Returns: A Geometry Result.
+ *
+ * See the Intrinsics manual for details on what this function is for.
+ *
+ * I just return the height and width of the label plus the margins.
+ */
+
+static XtGeometryResult
+QueryGeometry(w, intended, return_val)
+Widget w;
+XtWidgetGeometry *intended, *return_val;
+{
+ SmeBSBObject entry = (SmeBSBObject) w;
+ Dimension width, height;
+ XtGeometryResult ret_val = XtGeometryYes;
+ XtGeometryMask mode = intended->request_mode;
+
+ GetDefaultSize(w, &width, &height );
+
+ if ( ((mode & CWWidth) && (intended->width != width)) ||
+ !(mode & CWWidth) ) {
+ return_val->request_mode |= CWWidth;
+ return_val->width = width;
+ ret_val = XtGeometryAlmost;
+ }
+
+ if ( ((mode & CWHeight) && (intended->height != height)) ||
+ !(mode & CWHeight) ) {
+ return_val->request_mode |= CWHeight;
+ return_val->height = height;
+ ret_val = XtGeometryAlmost;
+ }
+
+ if (ret_val == XtGeometryAlmost) {
+ mode = return_val->request_mode;
+
+ if ( ((mode & CWWidth) && (width == entry->rectangle.width)) &&
+ ((mode & CWHeight) && (height == entry->rectangle.height)) )
+ return(XtGeometryNo);
+ }
+
+ return(ret_val);
+}
+
+/* Function Name: FlipColors
+ * Description: Invert the colors of the current entry.
+ * Arguments: w - the bsb menu entry widget.
+ * Returns: none.
+ */
+
+static void
+FlipColors(w)
+Widget w;
+{
+ SmeBSBObject entry = (SmeBSBObject) w;
+
+ if (entry->sme_bsb.set_values_area_cleared) {
+ return;
+ }
+
+ XFillRectangle(XtDisplayOfObject(w), XtWindowOfObject(w),
+ entry->sme_bsb.invert_gc,
+ 0, (int) entry->rectangle.y,
+ (unsigned int) entry->rectangle.width,
+ (unsigned int) entry->rectangle.height);
+}
+
+/************************************************************
+ *
+ * Private Functions.
+ *
+ ************************************************************/
+
+/* Function Name: GetDefaultSize
+ * Description: Calculates the Default (preferred) size of
+ * this menu entry.
+ * Arguments: w - the menu entry widget.
+ * width, height - default sizes (RETURNED).
+ * Returns: none.
+ */
+
+static void
+GetDefaultSize(w, width, height)
+Widget w;
+Dimension * width, * height;
+{
+ SmeBSBObject entry = (SmeBSBObject) w;
+
+ if ( entry->sme.international == True ) {
+ XFontSetExtents *ext = XExtentsOfFontSet(entry->sme_bsb.fontset);
+ if (entry->sme_bsb.label == NULL)
+ *width = 0;
+ else
+ *width = XmbTextEscapement(entry->sme_bsb.fontset, entry->sme_bsb.label,
+ strlen(entry->sme_bsb.label));
+ *width += entry->sme_bsb.left_margin + entry->sme_bsb.right_margin;
+ *height = ext->max_ink_extent.height;
+ *height = ((int)*height * ( ONE_HUNDRED +
+ entry->sme_bsb.vert_space )) / ONE_HUNDRED;
+ }
+ else {
+ if (entry->sme_bsb.label == NULL)
+ *width = 0;
+ else
+ *width = XTextWidth(entry->sme_bsb.font, entry->sme_bsb.label,
+ strlen(entry->sme_bsb.label));
+
+ *width += entry->sme_bsb.left_margin + entry->sme_bsb.right_margin;
+
+ *height = (entry->sme_bsb.font->max_bounds.ascent +
+ entry->sme_bsb.font->max_bounds.descent);
+
+ *height = ((int)*height * ( ONE_HUNDRED +
+ entry->sme_bsb.vert_space )) / ONE_HUNDRED;
+ }
+}
+
+/* Function Name: DrawBitmaps
+ * Description: Draws left and right bitmaps.
+ * Arguments: w - the simple menu widget.
+ * gc - graphics context to use for drawing.
+ * Returns: none
+ */
+
+static void
+DrawBitmaps(w, gc)
+Widget w;
+GC gc;
+{
+ int x_loc, y_loc;
+ SmeBSBObject entry = (SmeBSBObject) w;
+
+ if ( (entry->sme_bsb.left_bitmap == None) &&
+ (entry->sme_bsb.right_bitmap == None) ) return;
+
+/*
+ * Draw Left Bitmap.
+ */
+
+ if (entry->sme_bsb.left_bitmap != None) {
+ x_loc = (int)(entry->sme_bsb.left_margin -
+ entry->sme_bsb.left_bitmap_width) / 2;
+
+ y_loc = entry->rectangle.y +
+ (int)(entry->rectangle.height -
+ entry->sme_bsb.left_bitmap_height) / 2;
+
+ XCopyPlane(XtDisplayOfObject(w), entry->sme_bsb.left_bitmap,
+ XtWindowOfObject(w), gc, 0, 0,
+ entry->sme_bsb.left_bitmap_width,
+ entry->sme_bsb.left_bitmap_height, x_loc, y_loc, 1);
+ }
+
+/*
+ * Draw Right Bitmap.
+ */
+
+
+ if (entry->sme_bsb.right_bitmap != None) {
+ x_loc = entry->rectangle.width -
+ (int)(entry->sme_bsb.right_margin +
+ entry->sme_bsb.right_bitmap_width) / 2;
+
+ y_loc = entry->rectangle.y +
+ (int)(entry->rectangle.height -
+ entry->sme_bsb.right_bitmap_height) / 2;
+
+ XCopyPlane(XtDisplayOfObject(w), entry->sme_bsb.right_bitmap,
+ XtWindowOfObject(w), gc, 0, 0,
+ entry->sme_bsb.right_bitmap_width,
+ entry->sme_bsb.right_bitmap_height, x_loc, y_loc, 1);
+ }
+}
+
+/* Function Name: GetBitmapInfo
+ * Description: Gets the bitmap information from either of the bitmaps.
+ * Arguments: w - the bsb menu entry widget.
+ * is_left - TRUE if we are testing left bitmap,
+ * FALSE if we are testing the right bitmap.
+ * Returns: none
+ */
+
+static void
+GetBitmapInfo(w, is_left)
+Widget w;
+Boolean is_left;
+{
+ SmeBSBObject entry = (SmeBSBObject) w;
+ unsigned int depth, bw;
+ Window root;
+ int x, y;
+ unsigned int width, height;
+ char buf[BUFSIZ];
+ char* bufp;
+ int len;
+ char* fmt1 = "%s Could not get %s Bitmap geometry information for menu entry \"%s\"";
+ char* def1 = "%s Could not get Bitmap geometry information for menu entry";
+ char* fmt2 = "%s %s Bitmap of entry \"%s\" is not one bit deep";
+ char* def2 = "%s Bitmap of entry is not one bit deep";
+ char* Left = "Left";
+ char* Right = "Right";
+ char* smeobj = "Xaw SmeBSB Object:";
+
+ if (is_left) {
+ if (entry->sme_bsb.left_bitmap != None) {
+ if (!XGetGeometry(XtDisplayOfObject(w),
+ entry->sme_bsb.left_bitmap, &root,
+ &x, &y, &width, &height, &bw, &depth)) {
+ if ((len = strlen (fmt1) + strlen (smeobj) + strlen (Left) + strlen (XtName (w))) < sizeof buf)
+ bufp = buf;
+ else
+ bufp = XtMalloc (len + 1);
+ if (bufp == NULL) {
+ bufp = buf;
+ (void) sprintf (bufp, def1, smeobj);
+ } else
+ (void) sprintf(bufp, fmt1, smeobj, Left, XtName(w));
+ XtAppError(XtWidgetToApplicationContext(w), bufp);
+ if (bufp != buf) XtFree (bufp);
+ }
+ if (depth != 1) {
+ if ((len = strlen (fmt2) + strlen (smeobj) + strlen (Left) + strlen (XtName (w))) < sizeof buf)
+ bufp = buf;
+ else
+ bufp = XtMalloc (len + 1);
+ if (bufp == NULL) {
+ bufp = buf;
+ (void) sprintf (bufp, def2, smeobj);
+ } else
+ (void) sprintf(buf, fmt2, smeobj, Left, XtName(w));
+ XtAppError(XtWidgetToApplicationContext(w), buf);
+ if (bufp != buf) XtFree (bufp);
+ }
+ entry->sme_bsb.left_bitmap_width = (Dimension) width;
+ entry->sme_bsb.left_bitmap_height = (Dimension) height;
+ }
+ }
+ else if (entry->sme_bsb.right_bitmap != None) {
+ if (!XGetGeometry(XtDisplayOfObject(w),
+ entry->sme_bsb.right_bitmap, &root,
+ &x, &y, &width, &height, &bw, &depth)) {
+ if ((len = strlen (fmt1) + strlen (smeobj) + strlen (Right) + strlen (XtName (w))) < sizeof buf)
+ bufp = buf;
+ else
+ bufp = XtMalloc (len + 1);
+ if (bufp == NULL) {
+ bufp = buf;
+ (void) sprintf (bufp, def1, smeobj);
+ } else
+ (void) sprintf(bufp, fmt1, smeobj, Right, XtName(w));
+ XtAppError(XtWidgetToApplicationContext(w), bufp);
+ if (bufp != buf) XtFree (bufp);
+ }
+ if (depth != 1) {
+ if ((len = strlen (fmt2) + strlen (smeobj) + strlen (Right) + strlen (XtName (w))) < sizeof buf)
+ bufp = buf;
+ else
+ bufp = XtMalloc (len + 1);
+ if (bufp == NULL) {
+ bufp = buf;
+ (void) sprintf (bufp, def2, smeobj);
+ } else
+ (void) sprintf(buf, fmt2, smeobj, Right, XtName(w));
+ XtAppError(XtWidgetToApplicationContext(w), buf);
+ if (bufp != buf) XtFree (bufp);
+ }
+ entry->sme_bsb.right_bitmap_width = (Dimension) width;
+ entry->sme_bsb.right_bitmap_height = (Dimension) height;
+ }
+}
+
+/* Function Name: CreateGCs
+ * Description: Creates all gcs for the simple menu widget.
+ * Arguments: w - the simple menu widget.
+ * Returns: none.
+ */
+
+static void
+CreateGCs(w)
+Widget w;
+{
+ SmeBSBObject entry = (SmeBSBObject) w;
+ XGCValues values;
+ XtGCMask mask, mask_i18n;
+
+ values.foreground = XtParent(w)->core.background_pixel;
+ values.background = entry->sme_bsb.foreground;
+ values.font = entry->sme_bsb.font->fid;
+ values.graphics_exposures = FALSE;
+ mask = GCForeground | GCBackground | GCGraphicsExposures | GCFont;
+ mask_i18n = GCForeground | GCBackground | GCGraphicsExposures;
+ if ( entry->sme.international == True )
+ entry->sme_bsb.rev_gc = XtAllocateGC(w, 0, mask_i18n, &values, GCFont, 0 );
+ else
+ entry->sme_bsb.rev_gc = XtGetGC(w, mask, &values);
+
+ values.foreground = entry->sme_bsb.foreground;
+ values.background = XtParent(w)->core.background_pixel;
+ if ( entry->sme.international == True )
+ entry->sme_bsb.norm_gc = XtAllocateGC(w, 0, mask_i18n, &values, GCFont, 0 );
+ else
+ entry->sme_bsb.norm_gc = XtGetGC(w, mask, &values);
+
+ values.fill_style = FillTiled;
+ values.tile = XmuCreateStippledPixmap(XtScreenOfObject(w),
+ entry->sme_bsb.foreground,
+ XtParent(w)->core.background_pixel,
+ XtParent(w)->core.depth);
+ values.graphics_exposures = FALSE;
+ mask |= GCTile | GCFillStyle;
+ mask_i18n |= GCTile | GCFillStyle;
+ if ( entry->sme.international == True )
+ entry->sme_bsb.norm_gray_gc = XtAllocateGC(w, 0, mask_i18n, &values, GCFont, 0 );
+ else
+ entry->sme_bsb.norm_gray_gc = XtGetGC(w, mask, &values);
+
+ values.foreground ^= values.background;
+ values.background = 0;
+ values.function = GXxor;
+ mask = GCForeground | GCBackground | GCGraphicsExposures | GCFunction;
+ entry->sme_bsb.invert_gc = XtGetGC(w, mask, &values);
+}
+
+/* Function Name: DestroyGCs
+ * Description: Removes all gcs for the simple menu widget.
+ * Arguments: w - the simple menu widget.
+ * Returns: none.
+ */
+
+static void
+DestroyGCs(w)
+Widget w;
+{
+ SmeBSBObject entry = (SmeBSBObject) w;
+
+ XtReleaseGC(w, entry->sme_bsb.norm_gc);
+ XtReleaseGC(w, entry->sme_bsb.norm_gray_gc);
+ XtReleaseGC(w, entry->sme_bsb.rev_gc);
+ XtReleaseGC(w, entry->sme_bsb.invert_gc);
+}
+
+#ifdef apollo
+
+/*
+ * The apollo compiler that we have optomizes out my code for
+ * FlipColors() since it is static. and no one executes it in this
+ * file. I am setting the function pointer into the class structure so
+ * that it can be called by my parent who will tell me to when to
+ * highlight and unhighlight.
+ */
+
+void _XawSmeBSBApolloHack ()
+{
+ FlipColors();
+}
+#endif /* apollo */
diff --git a/src/SmeLine.c b/src/SmeLine.c
new file mode 100644
index 0000000..e5d1f25
--- /dev/null
+++ b/src/SmeLine.c
@@ -0,0 +1,288 @@
+/* $Xorg: SmeLine.c,v 1.4 2001/02/09 02:03:45 xorgcvs Exp $ */
+
+/*
+Copyright 1989, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+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
+OPEN GROUP 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 Open Group 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 Open Group.
+ *
+ * Author: Chris D. Peterson, MIT X Consortium
+ */
+
+/*
+ * Sme.c - Source code for the generic menu entry
+ *
+ * Date: September 26, 1989
+ *
+ * By: Chris D. Peterson
+ * MIT X Consortium
+ * kit@expo.lcs.mit.edu
+ */
+
+#include <stdio.h>
+#include <X11/IntrinsicP.h>
+#include <X11/StringDefs.h>
+
+#include <X11/Xaw/XawInit.h>
+#include <X11/Xaw/SmeLineP.h>
+#include <X11/Xaw/Cardinals.h>
+
+#define offset(field) XtOffsetOf(SmeLineRec, sme_line.field)
+static XtResource resources[] = {
+ {XtNlineWidth, XtCLineWidth, XtRDimension, sizeof(Dimension),
+ offset(line_width), XtRImmediate, (XtPointer) 1},
+ {XtNstipple, XtCStipple, XtRBitmap, sizeof(Pixmap),
+ offset(stipple), XtRImmediate, (XtPointer) XtUnspecifiedPixmap},
+ {XtNforeground, XtCForeground, XtRPixel, sizeof(Pixel),
+ offset(foreground), XtRString, XtDefaultForeground},
+};
+#undef offset
+
+/*
+ * Function definitions.
+ */
+
+static void Redisplay(), Initialize();
+static void DestroyGC(), CreateGC();
+static Boolean SetValues();
+static XtGeometryResult QueryGeometry();
+
+
+#define SUPERCLASS (&smeClassRec)
+
+SmeLineClassRec smeLineClassRec = {
+ {
+ /* superclass */ (WidgetClass) SUPERCLASS,
+ /* class_name */ "SmeLine",
+ /* size */ sizeof(SmeLineRec),
+ /* class_initialize */ XawInitializeWidgetSet,
+ /* class_part_initialize*/ NULL,
+ /* Class init'ed */ FALSE,
+ /* initialize */ Initialize,
+ /* initialize_hook */ NULL,
+ /* realize */ NULL,
+ /* actions */ NULL,
+ /* num_actions */ ZERO,
+ /* resources */ resources,
+ /* resource_count */ XtNumber(resources),
+ /* xrm_class */ NULLQUARK,
+ /* compress_motion */ FALSE,
+ /* compress_exposure */ FALSE,
+ /* compress_enterleave*/ FALSE,
+ /* visible_interest */ FALSE,
+ /* destroy */ DestroyGC,
+ /* resize */ NULL,
+ /* expose */ Redisplay,
+ /* set_values */ SetValues,
+ /* set_values_hook */ NULL,
+ /* set_values_almost */ XtInheritSetValuesAlmost,
+ /* get_values_hook */ NULL,
+ /* accept_focus */ NULL,
+ /* intrinsics version */ XtVersion,
+ /* callback offsets */ NULL,
+ /* tm_table */ NULL,
+ /* query_geometry */ QueryGeometry,
+ /* display_accelerator*/ NULL,
+ /* extension */ NULL
+ },{
+ /* Menu Entry Fields */
+
+ /* highlight */ XtInheritHighlight,
+ /* unhighlight */ XtInheritUnhighlight,
+ /* notify */ XtInheritNotify,
+ /* extension */ NULL
+ },{
+ /* Line Menu Entry Fields */
+ /* extension */ NULL
+ }
+};
+
+WidgetClass smeLineObjectClass = (WidgetClass) &smeLineClassRec;
+
+/************************************************************
+ *
+ * Semi-Public Functions.
+ *
+ ************************************************************/
+
+/* Function Name: Initialize
+ * Description: Initializes the simple menu widget
+ * Arguments: request - the widget requested by the argument list.
+ * new - the new widget with both resource and non
+ * resource values.
+ * Returns: none.
+ */
+
+/* ARGSUSED */
+static void
+Initialize(request, new, args, num_args)
+Widget request, new;
+ArgList args;
+Cardinal *num_args;
+{
+ SmeLineObject entry = (SmeLineObject) new;
+
+ if (entry->rectangle.height == 0)
+ entry->rectangle.height = entry->sme_line.line_width;
+
+ CreateGC(new);
+}
+
+/* Function Name: CreateGC
+ * Description: Creates the GC for the line entry widget.
+ * Arguments: w - the Line entry widget.
+ * Returns: none
+ *
+ * We can only share the GC if there is no stipple, because
+ * we need to change the stipple origin when drawing.
+ */
+
+static void
+CreateGC(w)
+Widget w;
+{
+ SmeLineObject entry = (SmeLineObject) w;
+ XGCValues values;
+ XtGCMask mask = GCForeground | GCGraphicsExposures | GCLineWidth ;
+
+ values.foreground = entry->sme_line.foreground;
+ values.graphics_exposures = FALSE;
+ values.line_width = entry->sme_line.line_width;
+
+ if (entry->sme_line.stipple != XtUnspecifiedPixmap) {
+ values.stipple = entry->sme_line.stipple;
+ values.fill_style = FillStippled;
+ mask |= GCStipple | GCFillStyle;
+
+ entry->sme_line.gc = XCreateGC(XtDisplayOfObject(w),
+ RootWindowOfScreen(XtScreenOfObject(w)),
+ mask, &values);
+ }
+ else
+ entry->sme_line.gc = XtGetGC(w, mask, &values);
+}
+
+/* Function Name: DestroyGC
+ * Description: Destroys the GC when we are done with it.
+ * Arguments: w - the Line entry widget.
+ * Returns: none
+ */
+
+static void
+DestroyGC(w)
+Widget w;
+{
+ SmeLineObject entry = (SmeLineObject) w;
+
+ if (entry->sme_line.stipple != XtUnspecifiedPixmap)
+ XFreeGC(XtDisplayOfObject(w), entry->sme_line.gc);
+ else
+ XtReleaseGC(w, entry->sme_line.gc);
+}
+
+/* Function Name: Redisplay
+ * Description: Paints the Line
+ * Arguments: w - the menu entry.
+ * event, region - NOT USED.
+ * Returns: none
+ */
+
+/*ARGSUSED*/
+static void
+Redisplay(w, event, region)
+Widget w;
+XEvent * event;
+Region region;
+{
+ SmeLineObject entry = (SmeLineObject) w;
+ int y = entry->rectangle.y +
+ (int)(entry->rectangle.height - entry->sme_line.line_width) / 2;
+
+ if (entry->sme_line.stipple != XtUnspecifiedPixmap)
+ XSetTSOrigin(XtDisplayOfObject(w), entry->sme_line.gc, 0, y);
+
+ XFillRectangle(XtDisplayOfObject(w), XtWindowOfObject(w),
+ entry->sme_line.gc,
+ 0, y, (unsigned int) entry->rectangle.width,
+ (unsigned int) entry->sme_line.line_width );
+}
+
+/* Function Name: SetValues
+ * Description: Relayout the menu when one of the resources is changed.
+ * Arguments: current - current state of the widget.
+ * request - what was requested.
+ * new - what the widget will become.
+ * Returns: none
+ */
+
+/* ARGSUSED */
+static Boolean
+SetValues(current, request, new, args, num_args)
+Widget current, request, new;
+ArgList args;
+Cardinal *num_args;
+{
+ SmeLineObject entry = (SmeLineObject) new;
+ SmeLineObject old_entry = (SmeLineObject) current;
+
+ if ( (entry->sme_line.line_width != old_entry->sme_line.line_width) &&
+ (entry->sme_line.stipple != old_entry->sme_line.stipple) ) {
+ DestroyGC(current);
+ CreateGC(new);
+ return(TRUE);
+ }
+ return(FALSE);
+}
+
+/* Function Name: QueryGeometry.
+ * Description: Returns the preferred geometry for this widget.
+ * Arguments: w - the menu entry object.
+ * itended, return - the intended and return geometry info.
+ * Returns: A Geometry Result.
+ *
+ * See the Intrinsics manual for details on what this function is for.
+ *
+ * I just return the height and a width of 1.
+ */
+
+static XtGeometryResult
+QueryGeometry(w, intended, return_val)
+Widget w;
+XtWidgetGeometry *intended, *return_val;
+{
+ SmeObject entry = (SmeObject) w;
+ Dimension width;
+ XtGeometryResult ret_val = XtGeometryYes;
+ XtGeometryMask mode = intended->request_mode;
+
+ width = 1; /* we can be really small. */
+
+ if ( ((mode & CWWidth) && (intended->width != width)) ||
+ !(mode & CWWidth) ) {
+ return_val->request_mode |= CWWidth;
+ return_val->width = width;
+ mode = return_val->request_mode;
+
+ if ( (mode & CWWidth) && (width == entry->rectangle.width) )
+ return(XtGeometryNo);
+ return(XtGeometryAlmost);
+ }
+ return(ret_val);
+}
diff --git a/src/StripChart.c b/src/StripChart.c
new file mode 100644
index 0000000..d2cbf62
--- /dev/null
+++ b/src/StripChart.c
@@ -0,0 +1,514 @@
+/* $Xorg: StripChart.c,v 1.4 2001/02/09 02:03:46 xorgcvs Exp $ */
+
+/***********************************************************
+
+Copyright 1987, 1988, 1994, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+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
+OPEN GROUP 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 Open Group 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 Open Group.
+
+
+Copyright 1987, 1988 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+******************************************************************/
+
+#include <stdio.h>
+#include <X11/IntrinsicP.h>
+#include <X11/StringDefs.h>
+#include <X11/Xaw/XawInit.h>
+#include <X11/Xaw/StripCharP.h>
+#include <X11/Xfuncs.h>
+
+#define MS_PER_SEC 1000
+
+/* Private Data */
+
+#define offset(field) XtOffsetOf(StripChartRec, field)
+
+static XtResource resources[] = {
+ {XtNwidth, XtCWidth, XtRDimension, sizeof(Dimension),
+ offset(core.width), XtRImmediate, (XtPointer) 120},
+ {XtNheight, XtCHeight, XtRDimension, sizeof(Dimension),
+ offset(core.height), XtRImmediate, (XtPointer) 120},
+ {XtNupdate, XtCInterval, XtRInt, sizeof(int),
+ offset(strip_chart.update), XtRImmediate, (XtPointer) 10},
+ {XtNminScale, XtCScale, XtRInt, sizeof(int),
+ offset(strip_chart.min_scale), XtRImmediate, (XtPointer) 1},
+ {XtNforeground, XtCForeground, XtRPixel, sizeof(Pixel),
+ offset(strip_chart.fgpixel), XtRString, XtDefaultForeground},
+ {XtNhighlight, XtCForeground, XtRPixel, sizeof(Pixel),
+ offset(strip_chart.hipixel), XtRString, XtDefaultForeground},
+ {XtNgetValue, XtCCallback, XtRCallback, sizeof(XtPointer),
+ offset(strip_chart.get_value), XtRImmediate, (XtPointer) NULL},
+ {XtNjumpScroll, XtCJumpScroll, XtRInt, sizeof(int),
+ offset(strip_chart.jump_val), XtRImmediate, (XtPointer) DEFAULT_JUMP},
+};
+
+#undef offset
+
+static void Initialize(), Destroy(), Redisplay(), MoveChart(), SetPoints();
+static Boolean SetValues();
+static int repaint_window();
+
+StripChartClassRec stripChartClassRec = {
+ { /* core fields */
+ /* superclass */ (WidgetClass) &simpleClassRec,
+ /* class_name */ "StripChart",
+ /* size */ sizeof(StripChartRec),
+ /* class_initialize */ XawInitializeWidgetSet,
+ /* class_part_initialize */ NULL,
+ /* class_inited */ FALSE,
+ /* initialize */ Initialize,
+ /* initialize_hook */ NULL,
+ /* realize */ XtInheritRealize,
+ /* actions */ NULL,
+ /* num_actions */ 0,
+ /* resources */ resources,
+ /* num_resources */ XtNumber(resources),
+ /* xrm_class */ NULLQUARK,
+ /* compress_motion */ TRUE,
+ /* compress_exposure */ XtExposeCompressMultiple |
+ XtExposeGraphicsExposeMerged,
+ /* compress_enterleave */ TRUE,
+ /* visible_interest */ FALSE,
+ /* destroy */ Destroy,
+ /* resize */ SetPoints,
+ /* expose */ Redisplay,
+ /* set_values */ SetValues,
+ /* set_values_hook */ NULL,
+ /* set_values_almost */ NULL,
+ /* get_values_hook */ NULL,
+ /* accept_focus */ NULL,
+ /* version */ XtVersion,
+ /* callback_private */ NULL,
+ /* tm_table */ NULL,
+ /* query_geometry */ XtInheritQueryGeometry,
+ /* display_accelerator */ XtInheritDisplayAccelerator,
+ /* extension */ NULL
+ },
+ { /* Simple class fields */
+ /* change_sensitive */ XtInheritChangeSensitive
+ }
+};
+
+WidgetClass stripChartWidgetClass = (WidgetClass) &stripChartClassRec;
+
+/****************************************************************
+ *
+ * Private Procedures
+ *
+ ****************************************************************/
+
+static void draw_it();
+
+/* Function Name: CreateGC
+ * Description: Creates the GC's
+ * Arguments: w - the strip chart widget.
+ * which - which GC's to create.
+ * Returns: none
+ */
+
+static void
+CreateGC(w, which)
+StripChartWidget w;
+unsigned int which;
+{
+ XGCValues myXGCV;
+
+ if (which & FOREGROUND) {
+ myXGCV.foreground = w->strip_chart.fgpixel;
+ w->strip_chart.fgGC = XtGetGC((Widget) w, GCForeground, &myXGCV);
+ }
+
+ if (which & HIGHLIGHT) {
+ myXGCV.foreground = w->strip_chart.hipixel;
+ w->strip_chart.hiGC = XtGetGC((Widget) w, GCForeground, &myXGCV);
+ }
+}
+
+/* Function Name: DestroyGC
+ * Description: Destroys the GC's
+ * Arguments: w - the strip chart widget.
+ * which - which GC's to destroy.
+ * Returns: none
+ */
+
+static void
+DestroyGC(w, which)
+StripChartWidget w;
+unsigned int which;
+{
+ if (which & FOREGROUND)
+ XtReleaseGC((Widget) w, w->strip_chart.fgGC);
+
+ if (which & HIGHLIGHT)
+ XtReleaseGC((Widget) w, w->strip_chart.hiGC);
+}
+
+/* ARGSUSED */
+static void Initialize (greq, gnew, args, num_args)
+ Widget greq, gnew;
+ ArgList args;
+ Cardinal *num_args;
+{
+ StripChartWidget w = (StripChartWidget)gnew;
+
+ if (w->strip_chart.update > 0)
+ w->strip_chart.interval_id = XtAppAddTimeOut(
+ XtWidgetToApplicationContext(gnew),
+ w->strip_chart.update * MS_PER_SEC,
+ draw_it, (XtPointer) gnew);
+ CreateGC(w, (unsigned int) ALL_GCS);
+
+ w->strip_chart.scale = w->strip_chart.min_scale;
+ w->strip_chart.interval = 0;
+ w->strip_chart.max_value = 0.0;
+ w->strip_chart.points = NULL;
+ SetPoints(w);
+}
+
+static void Destroy (gw)
+ Widget gw;
+{
+ StripChartWidget w = (StripChartWidget)gw;
+
+ if (w->strip_chart.update > 0)
+ XtRemoveTimeOut (w->strip_chart.interval_id);
+ if (w->strip_chart.points)
+ XtFree((char *) w->strip_chart.points);
+ DestroyGC(w, (unsigned int) ALL_GCS);
+}
+
+/*
+ * NOTE: This function really needs to recieve graphics exposure
+ * events, but since this is not easily supported until R4 I am
+ * going to hold off until then.
+ */
+
+/* ARGSUSED */
+static void Redisplay(w, event, region)
+ Widget w;
+ XEvent *event;
+ Region region;
+{
+ if (event->type == GraphicsExpose)
+ (void) repaint_window ((StripChartWidget)w, event->xgraphicsexpose.x,
+ event->xgraphicsexpose.width);
+ else
+ (void) repaint_window ((StripChartWidget)w, event->xexpose.x,
+ event->xexpose.width);
+}
+
+/* ARGSUSED */
+static void
+draw_it(client_data, id)
+XtPointer client_data;
+XtIntervalId *id; /* unused */
+{
+ StripChartWidget w = (StripChartWidget)client_data;
+ double value;
+
+ if (w->strip_chart.update > 0)
+ w->strip_chart.interval_id =
+ XtAppAddTimeOut(XtWidgetToApplicationContext( (Widget) w),
+ w->strip_chart.update * MS_PER_SEC,draw_it,client_data);
+
+ if (w->strip_chart.interval >= (int)w->core.width)
+ MoveChart( (StripChartWidget) w, TRUE);
+
+ /* Get the value, stash the point and draw corresponding line. */
+
+ if (w->strip_chart.get_value == NULL)
+ return;
+
+ XtCallCallbacks( (Widget)w, XtNgetValue, (XtPointer)&value );
+
+ /*
+ * Keep w->strip_chart.max_value up to date, and if this data
+ * point is off the graph, change the scale to make it fit.
+ */
+
+ if (value > w->strip_chart.max_value) {
+ w->strip_chart.max_value = value;
+ if (XtIsRealized((Widget)w) &&
+ w->strip_chart.max_value > w->strip_chart.scale) {
+ XClearWindow( XtDisplay (w), XtWindow (w));
+ w->strip_chart.interval = repaint_window(w, 0, (int) w->core.width);
+ }
+ }
+
+ w->strip_chart.valuedata[w->strip_chart.interval] = value;
+ if (XtIsRealized((Widget)w)) {
+ int y = (int) (w->core.height
+ - (int)(w->core.height * value) / w->strip_chart.scale);
+
+ XFillRectangle(XtDisplay(w), XtWindow(w), w->strip_chart.fgGC,
+ w->strip_chart.interval, y,
+ (unsigned int) 1, w->core.height - y);
+ /*
+ * Fill in the graph lines we just painted over.
+ */
+
+ if (w->strip_chart.points != NULL) {
+ w->strip_chart.points[0].x = w->strip_chart.interval;
+ XDrawPoints(XtDisplay(w), XtWindow(w), w->strip_chart.hiGC,
+ w->strip_chart.points, w->strip_chart.scale - 1,
+ CoordModePrevious);
+ }
+
+ XFlush(XtDisplay(w)); /* Flush output buffers */
+ }
+ w->strip_chart.interval++; /* Next point */
+} /* draw_it */
+
+/* Blts data according to current size, then redraws the stripChart window.
+ * Next represents the number of valid points in data. Returns the (possibly)
+ * adjusted value of next. If next is 0, this routine draws an empty window
+ * (scale - 1 lines for graph). If next is less than the current window width,
+ * the returned value is identical to the initial value of next and data is
+ * unchanged. Otherwise keeps half a window's worth of data. If data is
+ * changed, then w->strip_chart.max_value is updated to reflect the
+ * largest data point.
+ */
+
+static int
+repaint_window(w, left, width)
+StripChartWidget w;
+int left, width;
+{
+ int i, j;
+ int next = w->strip_chart.interval;
+ int scale = w->strip_chart.scale;
+ int scalewidth = 0;
+
+ /* Compute the minimum scale required to graph the data, but don't go
+ lower than min_scale. */
+ if (w->strip_chart.interval != 0 || scale <= (int)w->strip_chart.max_value)
+ scale = ((int) (w->strip_chart.max_value)) + 1;
+ if (scale < w->strip_chart.min_scale)
+ scale = w->strip_chart.min_scale;
+
+ if (scale != w->strip_chart.scale) {
+ w->strip_chart.scale = scale;
+ left = 0;
+ width = next;
+ scalewidth = w->core.width;
+
+ SetPoints(w);
+
+ if (XtIsRealized ((Widget) w))
+ XClearWindow (XtDisplay (w), XtWindow (w));
+
+ }
+
+ if (XtIsRealized((Widget)w)) {
+ Display *dpy = XtDisplay(w);
+ Window win = XtWindow(w);
+
+ width += left - 1;
+ if (!scalewidth) scalewidth = width;
+
+ if (next < ++width) width = next;
+
+ /* Draw data point lines. */
+ for (i = left; i < width; i++) {
+ int y = (int) (w->core.height -
+ (int)(w->core.height * w->strip_chart.valuedata[i]) /
+ w->strip_chart.scale);
+
+ XFillRectangle(dpy, win, w->strip_chart.fgGC,
+ i, y, (unsigned int) 1,
+ (unsigned int) (w->core.height - y));
+ }
+
+ /* Draw graph reference lines */
+ for (i = 1; i < w->strip_chart.scale; i++) {
+ j = i * ((int)w->core.height / w->strip_chart.scale);
+ XDrawLine(dpy, win, w->strip_chart.hiGC, left, j, scalewidth, j);
+ }
+ }
+ return(next);
+}
+
+/* Function Name: MoveChart
+ * Description: moves the chart over when it would run off the end.
+ * Arguments: w - the load widget.
+ * blit - blit the bits? (TRUE/FALSE).
+ * Returns: none.
+ */
+
+static void
+MoveChart(w, blit)
+StripChartWidget w;
+Boolean blit;
+{
+ double old_max;
+ int left, i, j;
+ int next = w->strip_chart.interval;
+
+ if (!XtIsRealized((Widget) w)) return;
+
+ if (w->strip_chart.jump_val < 0) w->strip_chart.jump_val = DEFAULT_JUMP;
+ if (w->strip_chart.jump_val == DEFAULT_JUMP)
+ j = w->core.width >> 1; /* Half the window width. */
+ else {
+ j = w->core.width - w->strip_chart.jump_val;
+ if (j < 0) j = 0;
+ }
+
+ (void) memmove((char *)(w->strip_chart.valuedata),
+ (char *)(w->strip_chart.valuedata + next - j),
+ j * sizeof(double));
+ next = w->strip_chart.interval = j;
+
+ /*
+ * Since we just lost some data, recompute the
+ * w->strip_chart.max_value.
+ */
+
+ old_max = w->strip_chart.max_value;
+ w->strip_chart.max_value = 0.0;
+ for (i = 0; i < next; i++) {
+ if (w->strip_chart.valuedata[i] > w->strip_chart.max_value)
+ w->strip_chart.max_value = w->strip_chart.valuedata[i];
+ }
+
+ if (!blit) return; /* we are done... */
+
+ if ( ((int) old_max) != ( (int) w->strip_chart.max_value) ) {
+ XClearWindow(XtDisplay(w), XtWindow(w));
+ repaint_window(w, 0, (int) w->core.width);
+ return;
+ }
+
+ XCopyArea(XtDisplay((Widget)w), XtWindow((Widget)w), XtWindow((Widget)w),
+ w->strip_chart.hiGC, (int) w->core.width - j, 0,
+ (unsigned int) j, (unsigned int) w->core.height,
+ 0, 0);
+
+ XClearArea(XtDisplay((Widget)w), XtWindow((Widget)w),
+ (int) j, 0,
+ (unsigned int) w->core.width - j, (unsigned int)w->core.height,
+ FALSE);
+
+ /* Draw graph reference lines */
+ left = j;
+ for (i = 1; i < w->strip_chart.scale; i++) {
+ j = i * ((int)w->core.height / w->strip_chart.scale);
+ XDrawLine(XtDisplay((Widget) w), XtWindow( (Widget) w),
+ w->strip_chart.hiGC, left, j, (int)w->core.width, j);
+ }
+ return;
+}
+
+/* ARGSUSED */
+static Boolean SetValues (current, request, new, args, num_args)
+ Widget current, request, new;
+ ArgList args;
+ Cardinal *num_args;
+{
+ StripChartWidget old = (StripChartWidget)current;
+ StripChartWidget w = (StripChartWidget)new;
+ Boolean ret_val = FALSE;
+ unsigned int new_gc = NO_GCS;
+
+ if (w->strip_chart.update != old->strip_chart.update) {
+ if (old->strip_chart.update > 0)
+ XtRemoveTimeOut (old->strip_chart.interval_id);
+ if (w->strip_chart.update > 0)
+ w->strip_chart.interval_id =
+ XtAppAddTimeOut(XtWidgetToApplicationContext(new),
+ w->strip_chart.update * MS_PER_SEC,
+ draw_it, (XtPointer)w);
+ }
+
+ if ( w->strip_chart.min_scale > (int) ((w->strip_chart.max_value) + 1) )
+ ret_val = TRUE;
+
+ if ( w->strip_chart.fgpixel != old->strip_chart.fgpixel ) {
+ new_gc |= FOREGROUND;
+ ret_val = True;
+ }
+
+ if ( w->strip_chart.hipixel != old->strip_chart.hipixel ) {
+ new_gc |= HIGHLIGHT;
+ ret_val = True;
+ }
+
+ DestroyGC(old, new_gc);
+ CreateGC(w, new_gc);
+
+ return( ret_val );
+}
+
+/* Function Name: SetPoints
+ * Description: Sets up the polypoint that will be used to draw in
+ * the graph lines.
+ * Arguments: w - the StripChart widget.
+ * Returns: none.
+ */
+
+#define HEIGHT ( (unsigned int) w->core.height)
+
+static void
+SetPoints(widget)
+Widget widget;
+{
+ StripChartWidget w = (StripChartWidget) widget;
+ XPoint * points;
+ Cardinal size;
+ int i;
+
+ if (w->strip_chart.scale <= 1) { /* no scale lines. */
+ XtFree ((char *) w->strip_chart.points);
+ w->strip_chart.points = NULL;
+ return;
+ }
+
+ size = sizeof(XPoint) * (w->strip_chart.scale - 1);
+
+ points = (XPoint *) XtRealloc( (XtPointer) w->strip_chart.points, size);
+ w->strip_chart.points = points;
+
+ /* Draw graph reference lines into clip mask */
+
+ for (i = 1; i < w->strip_chart.scale; i++) {
+ points[i - 1].x = 0;
+ points[i - 1].y = HEIGHT / w->strip_chart.scale;
+ }
+}
diff --git a/src/Text.c b/src/Text.c
new file mode 100644
index 0000000..f5b5401
--- /dev/null
+++ b/src/Text.c
@@ -0,0 +1,3518 @@
+/* $Xorg: Text.c,v 1.4 2001/02/09 02:03:46 xorgcvs Exp $ */
+
+/***********************************************************
+
+Copyright 1987, 1988, 1994, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+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
+OPEN GROUP 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 Open Group 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 Open Group.
+
+
+Copyright 1987, 1988 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+******************************************************************/
+
+#include <X11/IntrinsicP.h>
+#include <X11/StringDefs.h>
+#include <X11/Shell.h>
+#include <X11/Xatom.h>
+#include <X11/Xutil.h>
+#include "XawI18n.h"
+#include <stdio.h>
+
+#include <X11/Xmu/Atoms.h>
+#include <X11/Xmu/CharSet.h>
+#include <X11/Xmu/Converters.h>
+#include <X11/Xmu/StdSel.h>
+#include <X11/Xmu/Misc.h>
+
+#include <X11/Xaw/XawInit.h>
+#include <X11/Xaw/Cardinals.h>
+#include <X11/Xaw/Scrollbar.h>
+#include <X11/Xaw/TextP.h>
+#include <X11/Xaw/MultiSinkP.h>
+#include <X11/Xaw/XawImP.h>
+
+#include <X11/Xfuncs.h>
+#include <ctype.h> /* for isprint() */
+
+#ifndef MAX_LEN_CT
+#define MAX_LEN_CT 6 /* for sequence: ESC $ ( A \xx \xx */
+#endif
+
+unsigned long FMT8BIT = 0L;
+unsigned long XawFmt8Bit = 0L;
+unsigned long XawFmtWide = 0L;
+
+#define SinkClearToBG XawTextSinkClearToBackground
+
+#define SrcScan XawTextSourceScan
+#define SrcRead XawTextSourceRead
+#define SrcReplace XawTextSourceReplace
+#define SrcSearch XawTextSourceSearch
+#define SrcCvtSel XawTextSourceConvertSelection
+#define SrcSetSelection XawTextSourceSetSelection
+
+#define BIGNUM ((Dimension)32023)
+#define MULTI_CLICK_TIME 500L
+
+/*
+ * Compute a the maximum length of a cut buffer that we can pass at any
+ * time. The 64 allows for the overhead of the Change Property request.
+ */
+
+#define MAX_CUT_LEN(dpy) (XMaxRequestSize(dpy) - 64)
+
+#define IsValidLine(ctx, num) ( ((num) == 0) || \
+ ((ctx)->text.lt.info[(num)].position != 0) )
+
+/*
+ * Defined in Text.c
+ */
+static void UnrealizeScrollbars();
+static void VScroll(), VJump(), HScroll(), HJump(), ClearWindow();
+static void DisplayTextWindow(), ModifySelection(), PushCopyQueue();
+static void UpdateTextInLine(), UpdateTextInRectangle(), PopCopyQueue();
+static void FlushUpdate();
+static Boolean LineAndXYForPosition(), TranslateExposeRegion();
+static XawTextPosition FindGoodPosition(), _BuildLineTable();
+
+void _XawTextAlterSelection(), _XawTextExecuteUpdate();
+void _XawTextSetScrollBars(), _XawTextPrepareToUpdate();
+
+/****************************************************************
+ *
+ * Full class record constant
+ *
+ ****************************************************************/
+
+static XawTextSelectType defaultSelectTypes[] = {
+ XawselectPosition, XawselectWord, XawselectLine, XawselectParagraph,
+ XawselectAll, XawselectNull,
+};
+
+static XPointer defaultSelectTypesPtr = (XPointer)defaultSelectTypes;
+extern char *_XawDefaultTextTranslations1, *_XawDefaultTextTranslations2,
+ *_XawDefaultTextTranslations3, *_XawDefaultTextTranslations4;
+static Dimension defWidth = 100;
+static Dimension defHeight = DEFAULT_TEXT_HEIGHT;
+
+#define offset(field) XtOffsetOf(TextRec, field)
+static XtResource resources[] = {
+ {XtNwidth, XtCWidth, XtRDimension, sizeof(Dimension),
+ offset(core.width), XtRDimension, (XtPointer)&defWidth},
+ {XtNcursor, XtCCursor, XtRCursor, sizeof(Cursor),
+ offset(simple.cursor), XtRString, "xterm"},
+ {XtNheight, XtCHeight, XtRDimension, sizeof(Dimension),
+ offset(core.height), XtRDimension, (XtPointer)&defHeight},
+ {XtNdisplayPosition, XtCTextPosition, XtRInt, sizeof(XawTextPosition),
+ offset(text.lt.top), XtRImmediate, (XtPointer)0},
+ {XtNinsertPosition, XtCTextPosition, XtRInt, sizeof(XawTextPosition),
+ offset(text.insertPos), XtRImmediate,(XtPointer)0},
+ {XtNleftMargin, XtCMargin, XtRPosition, sizeof (Position),
+ offset(text.r_margin.left), XtRImmediate, (XtPointer)2},
+ {XtNrightMargin, XtCMargin, XtRPosition, sizeof (Position),
+ offset(text.r_margin.right), XtRImmediate, (XtPointer)4},
+ {XtNtopMargin, XtCMargin, XtRPosition, sizeof (Position),
+ offset(text.r_margin.top), XtRImmediate, (XtPointer)2},
+ {XtNbottomMargin, XtCMargin, XtRPosition, sizeof (Position),
+ offset(text.r_margin.bottom), XtRImmediate, (XtPointer)2},
+ {XtNselectTypes, XtCSelectTypes, XtRPointer,
+ sizeof(XawTextSelectType*), offset(text.sarray),
+ XtRPointer, (XtPointer)&defaultSelectTypesPtr},
+ {XtNtextSource, XtCTextSource, XtRWidget, sizeof (Widget),
+ offset(text.source), XtRImmediate, NULL},
+ {XtNtextSink, XtCTextSink, XtRWidget, sizeof (Widget),
+ offset(text.sink), XtRImmediate, NULL},
+ {XtNdisplayCaret, XtCOutput, XtRBoolean, sizeof(Boolean),
+ offset(text.display_caret), XtRImmediate, (XtPointer)True},
+ {XtNscrollVertical, XtCScroll, XtRScrollMode, sizeof(XawTextScrollMode),
+ offset(text.scroll_vert), XtRImmediate, (XtPointer) XawtextScrollNever},
+ {XtNscrollHorizontal, XtCScroll, XtRScrollMode, sizeof(XawTextScrollMode),
+ offset(text.scroll_horiz), XtRImmediate, (XtPointer) XawtextScrollNever},
+ {XtNwrap, XtCWrap, XtRWrapMode, sizeof(XawTextWrapMode),
+ offset(text.wrap), XtRImmediate, (XtPointer) XawtextWrapNever},
+ {XtNresize, XtCResize, XtRResizeMode, sizeof(XawTextResizeMode),
+ offset(text.resize), XtRImmediate, (XtPointer) XawtextResizeNever},
+ {XtNautoFill, XtCAutoFill, XtRBoolean, sizeof(Boolean),
+ offset(text.auto_fill), XtRImmediate, (XtPointer) FALSE},
+ {XtNunrealizeCallback, XtCCallback, XtRCallback, sizeof(XtPointer),
+ offset(text.unrealize_callbacks), XtRCallback, (XtPointer) NULL}
+};
+#undef offset
+
+/* ARGSUSED */
+static void
+CvtStringToScrollMode(args, num_args, fromVal, toVal)
+XrmValuePtr args; /* unused */
+Cardinal *num_args; /* unused */
+XrmValuePtr fromVal;
+XrmValuePtr toVal;
+{
+ static XawTextScrollMode scrollMode;
+ static XrmQuark QScrollNever, QScrollAlways, QScrollWhenNeeded;
+ XrmQuark q;
+ char lowerName[40];
+ static Boolean inited = FALSE;
+
+ if ( !inited ) {
+ QScrollNever = XrmPermStringToQuark(XtEtextScrollNever);
+ QScrollWhenNeeded = XrmPermStringToQuark(XtEtextScrollWhenNeeded);
+ QScrollAlways = XrmPermStringToQuark(XtEtextScrollAlways);
+ inited = TRUE;
+ }
+
+ if (strlen ((char*) fromVal->addr) < sizeof lowerName) {
+ XmuCopyISOLatin1Lowered (lowerName, (char *)fromVal->addr);
+ q = XrmStringToQuark(lowerName);
+
+ if (q == QScrollNever) scrollMode = XawtextScrollNever;
+ else if (q == QScrollWhenNeeded) scrollMode = XawtextScrollWhenNeeded;
+ else if (q == QScrollAlways) scrollMode = XawtextScrollAlways;
+ else {
+ toVal->size = 0;
+ toVal->addr = NULL;
+ return;
+ }
+ toVal->size = sizeof scrollMode;
+ toVal->addr = (XPointer) &scrollMode;
+ return;
+ }
+ toVal->size = 0;
+ toVal->addr = NULL;
+}
+
+/* ARGSUSED */
+static void
+CvtStringToWrapMode(args, num_args, fromVal, toVal)
+XrmValuePtr args; /* unused */
+Cardinal *num_args; /* unused */
+XrmValuePtr fromVal;
+XrmValuePtr toVal;
+{
+ static XawTextWrapMode wrapMode;
+ static XrmQuark QWrapNever, QWrapLine, QWrapWord;
+ XrmQuark q;
+ char lowerName[BUFSIZ];
+ static Boolean inited = FALSE;
+
+ if ( !inited ) {
+ QWrapNever = XrmPermStringToQuark(XtEtextWrapNever);
+ QWrapLine = XrmPermStringToQuark(XtEtextWrapLine);
+ QWrapWord = XrmPermStringToQuark(XtEtextWrapWord);
+ inited = TRUE;
+ }
+
+ if (strlen ((char*) fromVal->addr) < sizeof lowerName) {
+ XmuCopyISOLatin1Lowered (lowerName, (char *)fromVal->addr);
+ q = XrmStringToQuark(lowerName);
+
+ if (q == QWrapNever) wrapMode = XawtextWrapNever;
+ else if (q == QWrapLine) wrapMode = XawtextWrapLine;
+ else if (q == QWrapWord) wrapMode = XawtextWrapWord;
+ else {
+ toVal->size = 0;
+ toVal->addr = NULL;
+ return;
+ }
+ toVal->size = sizeof wrapMode;
+ toVal->addr = (XPointer) &wrapMode;
+ return;
+ }
+ toVal->size = 0;
+ toVal->addr = NULL;
+}
+
+/* ARGSUSED */
+static void
+CvtStringToResizeMode(args, num_args, fromVal, toVal)
+XrmValuePtr args; /* unused */
+Cardinal *num_args; /* unused */
+XrmValuePtr fromVal;
+XrmValuePtr toVal;
+{
+ static XawTextResizeMode resizeMode;
+ static XrmQuark QResizeNever, QResizeWidth, QResizeHeight, QResizeBoth;
+ XrmQuark q;
+ char lowerName[40];
+ static Boolean inited = FALSE;
+
+ if ( !inited ) {
+ QResizeNever = XrmPermStringToQuark(XtEtextResizeNever);
+ QResizeWidth = XrmPermStringToQuark(XtEtextResizeWidth);
+ QResizeHeight = XrmPermStringToQuark(XtEtextResizeHeight);
+ QResizeBoth = XrmPermStringToQuark(XtEtextResizeBoth);
+ inited = TRUE;
+ }
+
+ if (strlen ((char*) fromVal->addr) < sizeof lowerName) {
+ XmuCopyISOLatin1Lowered (lowerName, (char *)fromVal->addr);
+ q = XrmStringToQuark(lowerName);
+
+ if (q == QResizeNever) resizeMode = XawtextResizeNever;
+ else if (q == QResizeWidth) resizeMode = XawtextResizeWidth;
+ else if (q == QResizeHeight) resizeMode = XawtextResizeHeight;
+ else if (q == QResizeBoth) resizeMode = XawtextResizeBoth;
+ else {
+ toVal->size = 0;
+ toVal->addr = NULL;
+ return;
+ }
+ toVal->size = sizeof resizeMode;
+ toVal->addr = (XPointer) &resizeMode;
+ return;
+ }
+ toVal->size = 0;
+ toVal->addr = NULL;
+}
+
+static void
+ClassInitialize()
+{
+ int len1 = strlen (_XawDefaultTextTranslations1);
+ int len2 = strlen (_XawDefaultTextTranslations2);
+ int len3 = strlen (_XawDefaultTextTranslations3);
+ int len4 = strlen (_XawDefaultTextTranslations4);
+ char *buf = XtMalloc ((unsigned)(len1 + len2 + len3 + len4 + 1));
+ char *cp = buf;
+
+ if (!XawFmt8Bit)
+ FMT8BIT = XawFmt8Bit = XrmPermStringToQuark("FMT8BIT");
+ if (!XawFmtWide)
+ XawFmtWide = XrmPermStringToQuark("FMTWIDE");
+
+ XawInitializeWidgetSet();
+
+/*
+ * Set the number of actions.
+ */
+
+ textClassRec.core_class.num_actions = _XawTextActionsTableCount;
+
+ (void) strcpy( cp, _XawDefaultTextTranslations1); cp += len1;
+ (void) strcpy( cp, _XawDefaultTextTranslations2); cp += len2;
+ (void) strcpy( cp, _XawDefaultTextTranslations3); cp += len3;
+ (void) strcpy( cp, _XawDefaultTextTranslations4);
+ textWidgetClass->core_class.tm_table = buf;
+
+ XtAddConverter(XtRString, XtRScrollMode, CvtStringToScrollMode,
+ (XtConvertArgList)NULL, (Cardinal)0 );
+ XtAddConverter(XtRString, XtRWrapMode, CvtStringToWrapMode,
+ (XtConvertArgList)NULL, (Cardinal)0 );
+ XtAddConverter(XtRString, XtRResizeMode, CvtStringToResizeMode,
+ (XtConvertArgList)NULL, (Cardinal)0 );
+}
+
+/* Function Name: PositionHScrollBar.
+ * Description: Positions the Horizontal scrollbar.
+ * Arguments: ctx - the text widget.
+ * Returns: none
+ */
+
+static void
+PositionHScrollBar(ctx)
+TextWidget ctx;
+{
+ Widget vbar = ctx->text.vbar, hbar = ctx->text.hbar;
+ Position top, left = 0;
+
+ if (ctx->text.hbar == NULL) return;
+
+ if (vbar != NULL)
+ left += (Position) (vbar->core.width + vbar->core.border_width);
+
+ XtResizeWidget( hbar, ctx->core.width - left, hbar->core.height,
+ hbar->core.border_width );
+
+ left -= (Position) hbar->core.border_width;
+
+ top = ctx->core.height - ( hbar->core.height + hbar->core.border_width);
+ XtMoveWidget( hbar, left, top);
+}
+
+/* Function Name: PositionVScrollBar.
+ * Description: Positions the Vertical scrollbar.
+ * Arguments: ctx - the text widget.
+ * Returns: none.
+ */
+
+static void
+PositionVScrollBar(ctx)
+TextWidget ctx;
+{
+ Widget vbar = ctx->text.vbar;
+ Dimension bw;
+
+ if (vbar == NULL) return;
+ bw = vbar->core.border_width;
+
+ XtResizeWidget( vbar, vbar->core.width, ctx->core.height, bw);
+ XtMoveWidget( vbar, -(Position)bw, -(Position)bw );
+}
+
+static void
+CreateVScrollBar(ctx)
+TextWidget ctx;
+{
+ Widget vbar;
+
+ if (ctx->text.vbar != NULL) return;
+
+ ctx->text.vbar = vbar =
+ XtCreateWidget("vScrollbar", scrollbarWidgetClass, (Widget)ctx,
+ (ArgList) NULL, ZERO);
+ XtAddCallback( vbar, XtNscrollProc, VScroll, (XtPointer)ctx );
+ XtAddCallback( vbar, XtNjumpProc, VJump, (XtPointer)ctx );
+ if (ctx->text.hbar == NULL)
+ XtAddCallback((Widget) ctx, XtNunrealizeCallback, UnrealizeScrollbars,
+ (XtPointer) NULL);
+
+ ctx->text.r_margin.left += vbar->core.width + vbar->core.border_width;
+ ctx->text.margin.left = ctx->text.r_margin.left;
+
+ PositionVScrollBar(ctx);
+ PositionHScrollBar(ctx); /* May modify location of Horiz. Bar. */
+
+ if (XtIsRealized((Widget)ctx)) {
+ XtRealizeWidget(vbar);
+ XtMapWidget(vbar);
+ }
+}
+
+/* Function Name: DestroyVScrollBar
+ * Description: Removes a vertical ScrollBar.
+ * Arguments: ctx - the parent text widget.
+ * Returns: none.
+ */
+
+static void
+DestroyVScrollBar(ctx)
+TextWidget ctx;
+{
+ Widget vbar = ctx->text.vbar;
+
+ if (vbar == NULL) return;
+
+ ctx->text.r_margin.left -= vbar->core.width + vbar->core.border_width;
+ ctx->text.margin.left = ctx->text.r_margin.left;
+ if (ctx->text.hbar == NULL)
+ XtRemoveCallback((Widget) ctx, XtNunrealizeCallback, UnrealizeScrollbars,
+ (XtPointer) NULL);
+ XtDestroyWidget(vbar);
+ ctx->text.vbar = NULL;
+ PositionHScrollBar(ctx);
+}
+
+static void
+CreateHScrollBar(ctx)
+TextWidget ctx;
+{
+ Arg args[1];
+ Widget hbar;
+
+ if (ctx->text.hbar != NULL) return;
+
+ XtSetArg(args[0], XtNorientation, XtorientHorizontal);
+ ctx->text.hbar = hbar =
+ XtCreateWidget("hScrollbar", scrollbarWidgetClass, (Widget)ctx, args, ONE);
+ XtAddCallback( hbar, XtNscrollProc, HScroll, (XtPointer)ctx );
+ XtAddCallback( hbar, XtNjumpProc, HJump, (XtPointer)ctx );
+ if (ctx->text.vbar == NULL)
+ XtAddCallback((Widget) ctx, XtNunrealizeCallback, UnrealizeScrollbars,
+ (XtPointer) NULL);
+
+ PositionHScrollBar(ctx);
+ if (XtIsRealized((Widget)ctx)) {
+ XtRealizeWidget(hbar);
+ XtMapWidget(hbar);
+ }
+}
+
+/* Function Name: DestroyHScrollBar
+ * Description: Removes a horizontal ScrollBar.
+ * Arguments: ctx - the parent text widget.
+ * Returns: none.
+ */
+
+static void
+DestroyHScrollBar(ctx)
+TextWidget ctx;
+{
+ Widget hbar = ctx->text.hbar;
+
+ if (hbar == NULL) return;
+
+/*
+ ctx->text.r_margin.bottom -= hbar->core.height + hbar->core.border_width;
+ ctx->text.margin.bottom = ctx->text.r_margin.bottom;
+*/
+ if (ctx->text.vbar == NULL)
+ XtRemoveCallback((Widget) ctx, XtNunrealizeCallback, UnrealizeScrollbars,
+ (XtPointer) NULL);
+ XtDestroyWidget(hbar);
+ ctx->text.hbar = NULL;
+}
+
+static void warn_msg (w, dir, desc)
+ Widget w;
+ char* dir;
+ char* desc;
+{
+ char* fmt = "Xaw Text Widget \"%s\": %s scrolling not allowed with %s.\n%s scrolling has been DEACTIVATED.";
+ char error_buf[BUFSIZ];
+ char* errorp;
+ int len;
+
+ if ((len = strlen (fmt) + strlen (w->core.name) + 2 * strlen (dir) + strlen (desc)) < sizeof error_buf)
+ errorp = error_buf;
+ else
+ errorp = XtMalloc (len + 1);
+
+ if (errorp == NULL) {
+ errorp = error_buf;
+ strcpy (errorp, "Scrolling has been DEACTIVATED");
+ } else
+ (void) sprintf (errorp, fmt, w->core.name, dir, desc, dir);
+ XtAppWarning (XtWidgetToApplicationContext (w), errorp);
+}
+
+/* ARGSUSED */
+static void
+Initialize(request, new, args, num_args)
+Widget request, new;
+ArgList args; /* unused */
+Cardinal *num_args; /* unused */
+{
+ TextWidget ctx = (TextWidget) new;
+ char* Horizontal = "Horizontal";
+
+ ctx->text.lt.lines = 0;
+ ctx->text.lt.info = NULL;
+ (void) bzero((char *) &(ctx->text.origSel), sizeof(XawTextSelection));
+ (void) bzero((char *) &(ctx->text.s), sizeof(XawTextSelection));
+ ctx->text.s.type = XawselectPosition;
+ ctx->text.salt = NULL;
+ ctx->text.hbar = ctx->text.vbar = (Widget) NULL;
+ ctx->text.lasttime = 0; /* ||| correct? */
+ ctx->text.time = 0; /* ||| correct? */
+ ctx->text.showposition = TRUE;
+ ctx->text.lastPos = (ctx->text.source != NULL) ? GETLASTPOS : 0;
+ ctx->text.file_insert = NULL;
+ ctx->text.search = NULL;
+ ctx->text.updateFrom = (XawTextPosition *) XtMalloc((unsigned) ONE);
+ ctx->text.updateTo = (XawTextPosition *) XtMalloc((unsigned) ONE);
+ ctx->text.numranges = ctx->text.maxranges = 0;
+ ctx->text.gc = DefaultGCOfScreen(XtScreen(ctx));
+ ctx->text.hasfocus = FALSE;
+ ctx->text.margin = ctx->text.r_margin; /* Strucure copy. */
+ ctx->text.update_disabled = FALSE;
+ ctx->text.old_insert = -1;
+ ctx->text.mult = 1;
+ ctx->text.single_char = FALSE;
+ ctx->text.copy_area_offsets = NULL;
+ ctx->text.salt2 = NULL;
+
+ if (ctx->core.height == DEFAULT_TEXT_HEIGHT) {
+ ctx->core.height = VMargins(ctx);
+ if (ctx->text.sink != NULL)
+ ctx->core.height += XawTextSinkMaxHeight(ctx->text.sink, 1);
+ }
+
+ if (ctx->text.scroll_vert != XawtextScrollNever)
+ if ( (ctx->text.resize == XawtextResizeHeight) ||
+ (ctx->text.resize == XawtextResizeBoth) ) {
+ warn_msg (ctx, "Vertical", "height resize");
+ ctx->text.scroll_vert = XawtextScrollNever;
+ }
+ else if (ctx->text.scroll_vert == XawtextScrollAlways)
+ CreateVScrollBar(ctx);
+
+ if (ctx->text.scroll_horiz != XawtextScrollNever)
+ if (ctx->text.wrap != XawtextWrapNever) {
+ warn_msg (ctx, Horizontal, "wrapping active");
+ ctx->text.scroll_horiz = XawtextScrollNever;
+ }
+ else if ( (ctx->text.resize == XawtextResizeWidth) ||
+ (ctx->text.resize == XawtextResizeBoth) ) {
+ warn_msg (ctx, Horizontal, "width resize");
+ ctx->text.scroll_horiz = XawtextScrollNever;
+ }
+ else if (ctx->text.scroll_horiz == XawtextScrollAlways)
+ CreateHScrollBar(ctx);
+}
+
+static void
+Realize( w, valueMask, attributes )
+Widget w;
+Mask *valueMask;
+XSetWindowAttributes *attributes;
+{
+ TextWidget ctx = (TextWidget)w;
+ void _XawTextCheckResize();
+
+ (*textClassRec.core_class.superclass->core_class.realize)
+ (w, valueMask, attributes);
+
+ if (ctx->text.hbar != NULL) { /* Put up Hbar -- Must be first. */
+ XtRealizeWidget(ctx->text.hbar);
+ XtMapWidget(ctx->text.hbar);
+ }
+
+ if (ctx->text.vbar != NULL) { /* Put up Vbar. */
+ XtRealizeWidget(ctx->text.vbar);
+ XtMapWidget(ctx->text.vbar);
+ }
+
+ _XawTextBuildLineTable(ctx, ctx->text.lt.top, TRUE);
+ _XawTextSetScrollBars(ctx);
+ _XawTextCheckResize(ctx);
+}
+
+/*ARGSUSED*/
+static void UnrealizeScrollbars(widget, client, call)
+Widget widget; /* Text widget */
+XtPointer client; /* unused */
+XtPointer call; /* unused */
+{
+ TextWidget ctx = (TextWidget) widget;
+
+ if (ctx->text.hbar)
+ XtUnrealizeWidget(ctx->text.hbar);
+ if (ctx->text.vbar)
+ XtUnrealizeWidget(ctx->text.vbar);
+}
+
+/* Utility routines for support of Text */
+
+static void
+_CreateCutBuffers(d)
+Display *d;
+{
+ static struct _DisplayRec {
+ struct _DisplayRec *next;
+ Display *dpy;
+ } *dpy_list = NULL;
+ struct _DisplayRec *dpy_ptr;
+
+ for (dpy_ptr = dpy_list; dpy_ptr != NULL; dpy_ptr = dpy_ptr->next)
+ if (dpy_ptr->dpy == d) return;
+
+ dpy_ptr = XtNew(struct _DisplayRec);
+ dpy_ptr->next = dpy_list;
+ dpy_ptr->dpy = d;
+ dpy_list = dpy_ptr;
+
+#define Create(buffer) \
+ XChangeProperty(d, RootWindow(d, 0), buffer, XA_STRING, 8, \
+ PropModeAppend, NULL, 0 );
+
+ Create( XA_CUT_BUFFER0 );
+ Create( XA_CUT_BUFFER1 );
+ Create( XA_CUT_BUFFER2 );
+ Create( XA_CUT_BUFFER3 );
+ Create( XA_CUT_BUFFER4 );
+ Create( XA_CUT_BUFFER5 );
+ Create( XA_CUT_BUFFER6 );
+ Create( XA_CUT_BUFFER7 );
+
+#undef Create
+}
+
+/*
+ * Procedure to manage insert cursor visibility for editable text. It uses
+ * the value of ctx->insertPos and an implicit argument. In the event that
+ * position is immediately preceded by an eol graphic, then the insert cursor
+ * is displayed at the beginning of the next line.
+*/
+static void
+InsertCursor (w, state)
+Widget w;
+XawTextInsertState state;
+{
+ TextWidget ctx = (TextWidget)w;
+ Position x, y;
+ int line;
+
+ if (ctx->text.lt.lines < 1) return;
+
+ if ( LineAndXYForPosition(ctx, ctx->text.insertPos, &line, &x, &y) ) {
+ if (line < ctx->text.lt.lines)
+ y += (ctx->text.lt.info[line + 1].y - ctx->text.lt.info[line].y) + 1;
+ else
+ y += (ctx->text.lt.info[line].y - ctx->text.lt.info[line - 1].y) + 1;
+
+ if (ctx->text.display_caret)
+ XawTextSinkInsertCursor(ctx->text.sink, x, y, state);
+ }
+ ctx->text.ev_x = x;
+ ctx->text.ev_y = y;
+
+ /* Keep Input Method up to speed */
+
+ if ( ctx->simple.international ) {
+ Arg list[1];
+
+ XtSetArg (list[0], XtNinsertPosition, ctx->text.insertPos);
+ _XawImSetValues (w, list, 1);
+ }
+}
+
+/*
+ * Procedure to register a span of text that is no longer valid on the display
+ * It is used to avoid a number of small, and potentially overlapping, screen
+ * updates.
+*/
+
+void
+_XawTextNeedsUpdating(ctx, left, right)
+TextWidget ctx;
+XawTextPosition left, right;
+{
+ int i;
+ if (left < right) {
+ for (i = 0; i < ctx->text.numranges; i++) {
+ if (left <= ctx->text.updateTo[i] && right >= ctx->text.updateFrom[i]) {
+ ctx->text.updateFrom[i] = Min(left, ctx->text.updateFrom[i]);
+ ctx->text.updateTo[i] = Max(right, ctx->text.updateTo[i]);
+ return;
+ }
+ }
+ ctx->text.numranges++;
+ if (ctx->text.numranges > ctx->text.maxranges) {
+ ctx->text.maxranges = ctx->text.numranges;
+ i = ctx->text.maxranges * sizeof(XawTextPosition);
+ ctx->text.updateFrom = (XawTextPosition *)
+ XtRealloc((char *)ctx->text.updateFrom, (unsigned) i);
+ ctx->text.updateTo = (XawTextPosition *)
+ XtRealloc((char *)ctx->text.updateTo, (unsigned) i);
+ }
+ ctx->text.updateFrom[ctx->text.numranges - 1] = left;
+ ctx->text.updateTo[ctx->text.numranges - 1] = right;
+ }
+}
+
+/*
+ * Procedure to read a span of text in Ascii form. This is purely a hack and
+ * we probably need to add a function to sources to provide this functionality.
+ * [note: this is really a private procedure but is used in multiple modules].
+ */
+
+char *
+_XawTextGetText(ctx, left, right)
+TextWidget ctx;
+XawTextPosition left, right;
+{
+ char *result, *tempResult;
+ XawTextBlock text;
+ int bytes;
+
+ if (_XawTextFormat(ctx) == XawFmt8Bit)
+ bytes = sizeof(unsigned char);
+ else if (_XawTextFormat(ctx) == XawFmtWide)
+ bytes = sizeof(wchar_t);
+ else /* if there is another fomat, add here */
+ bytes = 1;
+
+ /* leave space for ZERO */
+ tempResult=result=XtMalloc( (unsigned)(((Cardinal)(right-left))+ONE )* bytes);
+ while (left < right) {
+ left = SrcRead(ctx->text.source, left, &text, (int)(right - left));
+ if (!text.length)
+ break;
+ memmove(tempResult, text.ptr, text.length * bytes);
+ tempResult += text.length * bytes;
+ }
+
+ if (bytes == sizeof(wchar_t))
+ *((wchar_t*)tempResult) = (wchar_t)0;
+ else
+ *tempResult = '\0';
+ return(result);
+}
+
+/* Like _XawTextGetText, but enforces ICCCM STRING type encoding. This
+routine is currently used to put just the ASCII chars in the selection into a
+cut buffer. */
+
+char *
+_XawTextGetSTRING(ctx, left, right)
+TextWidget ctx;
+XawTextPosition left, right;
+{
+ unsigned char *s;
+ unsigned char c;
+ long i, j, n;
+ wchar_t *ws, wc;
+
+ /* allow ESC in accordance with ICCCM */
+ if (_XawTextFormat(ctx) == XawFmtWide) {
+ MultiSinkObject sink = (MultiSinkObject) ctx->text.sink;
+ ws = (wchar_t *)_XawTextGetText(ctx, left, right);
+ n = wcslen(ws);
+ for (j = 0, i = 0; j < n; j++) {
+ wc = ws[j];
+ if (XwcTextEscapement (sink->multi_sink.fontset, &wc, 1) ||
+ (wc == _Xaw_atowc(XawTAB)) || (wc == _Xaw_atowc(XawLF)) || (wc == _Xaw_atowc(XawESC)))
+ ws[i++] = wc;
+ }
+ ws[i] = (wchar_t)0;
+ return (char *)ws;
+ } else {
+ s = (unsigned char *)_XawTextGetText(ctx, left, right);
+ /* only HT and NL control chars are allowed, strip out others */
+ n = strlen((char *)s);
+ i = 0;
+ for (j = 0; j < n; j++) {
+ c = s[j];
+ if (((c >= 0x20) && c <= 0x7f) ||
+ (c >= 0xa0) || (c == XawTAB) || (c == XawLF) || (c == XawESC)) {
+ s[i] = c;
+ i++;
+ }
+ }
+ s[i] = 0;
+ return (char *)s;
+ }
+#undef ESC
+
+}
+
+/*
+ * This routine maps an x and y position in a window that is displaying text
+ * into the corresponding position in the source.
+ *
+ * NOTE: it is illegal to call this routine unless there is a valid line table!
+ */
+
+/*** figure out what line it is on ***/
+
+static XawTextPosition
+PositionForXY (ctx, x, y)
+TextWidget ctx;
+Position x,y;
+{
+ int fromx, line, width, height;
+ XawTextPosition position;
+
+ if (ctx->text.lt.lines == 0) return 0;
+
+ for (line = 0; line < ctx->text.lt.lines - 1; line++) {
+ if (y <= ctx->text.lt.info[line + 1].y)
+ break;
+ }
+ position = ctx->text.lt.info[line].position;
+ if (position >= ctx->text.lastPos)
+ return(ctx->text.lastPos);
+ fromx = (int) ctx->text.margin.left;
+ XawTextSinkFindPosition( ctx->text.sink, position, fromx, x - fromx,
+ FALSE, &position, &width, &height);
+ if (position > ctx->text.lastPos) return(ctx->text.lastPos);
+ if (position >= ctx->text.lt.info[line + 1].position)
+ position = SrcScan(ctx->text.source, ctx->text.lt.info[line + 1].position,
+ XawstPositions, XawsdLeft, 1, TRUE);
+ return(position);
+}
+
+/*
+ * This routine maps a source position in to the corresponding line number
+ * of the text that is displayed in the window.
+ *
+ * NOTE: It is illegal to call this routine unless there is a valid line table!
+ */
+
+static int
+LineForPosition (ctx, position)
+TextWidget ctx;
+XawTextPosition position;
+{
+ int line;
+
+ for (line = 0; line < ctx->text.lt.lines; line++)
+ if (position < ctx->text.lt.info[line + 1].position)
+ break;
+ return(line);
+}
+
+/*
+ * This routine maps a source position into the corresponding line number
+ * and the x, y coordinates of the text that is displayed in the window.
+ *
+ * NOTE: It is illegal to call this routine unless there is a valid line table!
+ */
+
+static Boolean
+LineAndXYForPosition (ctx, pos, line, x, y)
+TextWidget ctx;
+XawTextPosition pos;
+int *line;
+Position *x, *y;
+{
+ XawTextPosition linePos, endPos;
+ Boolean visible;
+ int realW, realH;
+
+ *line = 0;
+ *x = ctx->text.margin.left;
+ *y = ctx->text.margin.top;
+ if (visible = IsPositionVisible(ctx, pos)) {
+ *line = LineForPosition(ctx, pos);
+ *y = ctx->text.lt.info[*line].y;
+ *x = ctx->text.margin.left;
+ linePos = ctx->text.lt.info[*line].position;
+ XawTextSinkFindDistance( ctx->text.sink, linePos,
+ *x, pos, &realW, &endPos, &realH);
+ *x += realW;
+ }
+ return(visible);
+}
+
+/*
+ * This routine builds a line table. It does this by starting at the
+ * specified position and measuring text to determine the staring position
+ * of each line to be displayed. It also determines and saves in the
+ * linetable all the required metrics for displaying a given line (e.g.
+ * x offset, y offset, line length, etc.).
+ */
+
+void
+#if NeedFunctionPrototypes
+_XawTextBuildLineTable (
+ TextWidget ctx,
+ XawTextPosition position,
+ _XtBoolean force_rebuild)
+#else
+_XawTextBuildLineTable (ctx, position, force_rebuild)
+ TextWidget ctx;
+ XawTextPosition position;
+ Boolean force_rebuild;
+#endif
+{
+ Dimension height = 0;
+ int lines = 0;
+ Cardinal size;
+
+ if ((int)ctx->core.height > VMargins(ctx)) {
+ height = ctx->core.height - VMargins(ctx);
+ lines = XawTextSinkMaxLines(ctx->text.sink, height);
+ }
+ size = sizeof(XawTextLineTableEntry) * (lines + 1);
+
+ if ( (lines != ctx->text.lt.lines) || (ctx->text.lt.info == NULL) ) {
+ ctx->text.lt.info = (XawTextLineTableEntry *) XtRealloc((char *) ctx->text.
+ lt.info, size);
+ ctx->text.lt.lines = lines;
+ force_rebuild = TRUE;
+ }
+
+ if ( force_rebuild || (position != ctx->text.lt.top) ) {
+ (void) bzero((char *) ctx->text.lt.info, size);
+ (void) _BuildLineTable(ctx, ctx->text.lt.top = position, zeroPosition, 0);
+ }
+}
+
+/*
+ * This assumes that the line table does not change size.
+ */
+
+static XawTextPosition
+_BuildLineTable(ctx, position, min_pos, line)
+TextWidget ctx;
+XawTextPosition position, min_pos;
+int line;
+{
+ XawTextLineTableEntry * lt = ctx->text.lt.info + line;
+ XawTextPosition endPos;
+ Position y;
+ int count, width, realW, realH;
+ Widget src = ctx->text.source;
+
+ if ( ((ctx->text.resize == XawtextResizeWidth) ||
+ (ctx->text.resize == XawtextResizeBoth) ) ||
+ (ctx->text.wrap == XawtextWrapNever) )
+ width = BIGNUM;
+ else
+ width = Max(0, ((int)ctx->core.width - (int)HMargins(ctx)));
+
+ y = ( (line == 0) ? ctx->text.margin.top : lt->y );
+
+ /* CONSTCOND */
+ while ( TRUE ) {
+ lt->y = y;
+ lt->position = position;
+
+ XawTextSinkFindPosition( ctx->text.sink, position, ctx->text.margin.left,
+ width, ctx->text.wrap == XawtextWrapWord,
+ &endPos, &realW, &realH);
+ lt->textWidth = realW;
+ y += realH;
+
+ if (ctx->text.wrap == XawtextWrapNever)
+ endPos = SrcScan(src, position, XawstEOL, XawsdRight, 1, TRUE);
+
+ if ( endPos == ctx->text.lastPos) { /* We have reached the end. */
+ if(SrcScan(src, position, XawstEOL, XawsdRight, 1, FALSE) == endPos)
+ break;
+ }
+
+ ++lt;
+ ++line;
+ if ( (line > ctx->text.lt.lines) ||
+ ((lt->position == (position = endPos)) && (position > min_pos)) )
+ return(position);
+ }
+
+/*
+ * If we are at the end of the buffer put two special lines in the table.
+ *
+ * a) Both have position > text.lastPos and lt->textWidth = 0.
+ * b) The first has a real height, and the second has a height that
+ * is the rest of the screen.
+ *
+ * I could fill in the rest of the table with valid heights and a large
+ * lastPos, but this method keeps the number of fill regions down to a
+ * minimum.
+ *
+ * One valid entry is needed at the end of the table so that the cursor
+ * does not jump off the bottom of the window.
+ */
+
+ for ( count = 0; count < 2 ; count++)
+ if (line++ < ctx->text.lt.lines) { /* make sure not to run of the end. */
+ (++lt)->y = (count == 0) ? y : ctx->core.height;
+ lt->textWidth = 0;
+ lt->position = ctx->text.lastPos + 100;
+ }
+
+ if (line < ctx->text.lt.lines) /* Clear out rest of table. */
+ (void) bzero( (char *) (lt + 1),
+ (ctx->text.lt.lines - line) * sizeof(XawTextLineTableEntry) );
+
+ ctx->text.lt.info[ctx->text.lt.lines].position = lt->position;
+
+ return(endPos);
+}
+
+/* Function Name: GetWidestLine
+ * Description: Returns the width (in pixels) of the widest line that
+ * is currently visable.
+ * Arguments: ctx - the text widget.
+ * Returns: the width of the widest line.
+ *
+ * NOTE: This function requires a valid line table.
+ */
+
+static Dimension
+GetWidestLine(ctx)
+TextWidget ctx;
+{
+ int i;
+ Dimension widest;
+ XawTextLineTablePtr lt = &(ctx->text.lt);
+
+ for (i = 0, widest = 1 ; i < lt->lines ; i++)
+ if (widest < lt->info[i].textWidth)
+ widest = lt->info[i].textWidth;
+
+ return(widest);
+}
+
+static void
+CheckVBarScrolling(ctx)
+TextWidget ctx;
+{
+ float first, last;
+ Boolean temp = (ctx->text.vbar == NULL);
+
+ if (ctx->text.scroll_vert == XawtextScrollNever) return;
+
+ if ( (ctx->text.lastPos > 0) && (ctx->text.lt.lines > 0)) {
+ first = ctx->text.lt.top;
+ first /= (float) ctx->text.lastPos;
+ last = ctx->text.lt.info[ctx->text.lt.lines].position;
+ if ( ctx->text.lt.info[ctx->text.lt.lines].position < ctx->text.lastPos )
+ last /= (float) ctx->text.lastPos;
+ else
+ last = 1.0;
+
+ if (ctx->text.scroll_vert == XawtextScrollWhenNeeded) {
+ int line;
+ XawTextPosition last_pos;
+ Position y = ctx->core.height - ctx->text.margin.bottom;
+
+ if (ctx->text.hbar != NULL)
+ y -= (ctx->text.hbar->core.height +
+ 2 * ctx->text.hbar->core.border_width);
+
+ last_pos = PositionForXY(ctx, (Position) ctx->core.width, y);
+ line = LineForPosition(ctx, last_pos);
+
+ if ( (y < ctx->text.lt.info[line + 1].y) || ((last - first) < 1.0) )
+ CreateVScrollBar(ctx);
+ else
+ DestroyVScrollBar(ctx);
+ }
+
+ if (ctx->text.vbar != NULL)
+ XawScrollbarSetThumb(ctx->text.vbar, first, last - first);
+
+ if ( (ctx->text.vbar == NULL) != temp) {
+ _XawTextNeedsUpdating(ctx, zeroPosition, ctx->text.lastPos);
+ if (ctx->text.vbar == NULL)
+ _XawTextBuildLineTable (ctx, zeroPosition, FALSE);
+ }
+ }
+ else if (ctx->text.vbar != NULL)
+ if (ctx->text.scroll_vert == XawtextScrollWhenNeeded)
+ DestroyVScrollBar(ctx);
+ else if (ctx->text.scroll_vert == XawtextScrollAlways)
+ XawScrollbarSetThumb(ctx->text.vbar, 0.0, 1.0);
+}
+
+/*
+ * This routine is used by Text to notify an associated scrollbar of the
+ * correct metrics (position and shown fraction) for the text being currently
+ * displayed in the window.
+ */
+
+void
+_XawTextSetScrollBars(ctx)
+TextWidget ctx;
+{
+ float first, last, widest;
+ Boolean temp = (ctx->text.hbar == NULL);
+ Boolean vtemp = (ctx->text.vbar == NULL);
+
+ CheckVBarScrolling(ctx);
+
+ if (ctx->text.scroll_horiz == XawtextScrollNever) return;
+
+ if (ctx->text.vbar != NULL)
+ widest = (int)(ctx->core.width - ctx->text.vbar->core.width -
+ ctx->text.vbar->core.border_width);
+ else
+ widest = ctx->core.width;
+ widest /= (last = GetWidestLine(ctx));
+ if (ctx->text.scroll_horiz == XawtextScrollWhenNeeded)
+ if (widest < 1.0)
+ CreateHScrollBar(ctx);
+ else
+ DestroyHScrollBar(ctx);
+
+ if ( (ctx->text.hbar == NULL) != temp ) {
+ _XawTextBuildLineTable (ctx, ctx->text.lt.top, TRUE);
+ CheckVBarScrolling(ctx); /* Recheck need for vbar, now that we added
+ or removed the hbar.*/
+ }
+
+ if (ctx->text.hbar != NULL) {
+ first = ctx->text.r_margin.left - ctx->text.margin.left;
+ first /= last;
+ XawScrollbarSetThumb(ctx->text.hbar, first, widest);
+ }
+
+ if (((ctx->text.hbar == NULL) && (ctx->text.margin.left !=
+ ctx->text.r_margin.left)) ||
+ (ctx->text.vbar == NULL) != vtemp)
+ {
+ ctx->text.margin.left = ctx->text.r_margin.left;
+ _XawTextNeedsUpdating(ctx, zeroPosition, ctx->text.lastPos);
+ FlushUpdate(ctx);
+ }
+}
+
+/*
+ * The routine will scroll the displayed text by lines. If the arg is
+ * positive, move up; otherwise, move down. [note: this is really a private
+ * procedure but is used in multiple modules].
+ */
+
+void
+_XawTextVScroll(ctx, n)
+TextWidget ctx;
+int n;
+{
+ XawTextPosition top, target;
+ int y;
+ Arg list[1];
+ XawTextLineTable * lt = &(ctx->text.lt);
+
+ if (abs(n) > ctx->text.lt.lines)
+ n = (n > 0) ? ctx->text.lt.lines : -ctx->text.lt.lines;
+
+ if (n == 0) return;
+
+ if (n > 0) {
+ if ( IsValidLine(ctx, n) )
+ top = Min(lt->info[n].position, ctx->text.lastPos);
+ else
+ top = ctx->text.lastPos;
+
+ y = IsValidLine(ctx, n) ? lt->info[n].y : ctx->core.height;
+ _XawTextBuildLineTable(ctx, top, FALSE);
+ if (top >= ctx->text.lastPos)
+ DisplayTextWindow( (Widget) ctx);
+ else {
+ XCopyArea(XtDisplay(ctx), XtWindow(ctx), XtWindow(ctx), ctx->text.gc,
+ 0, y, (int)ctx->core.width, (int)ctx->core.height - y,
+ 0, ctx->text.margin.top);
+
+ PushCopyQueue(ctx, 0, (int) -y);
+ SinkClearToBG(ctx->text.sink,
+ (Position) 0,
+ (Position) (ctx->text.margin.top + ctx->core.height - y),
+ (Dimension) ctx->core.width, (Dimension) ctx->core.height);
+
+ if (n < lt->lines) n++; /* update descenders at bottom */
+ _XawTextNeedsUpdating(ctx, lt->info[lt->lines - n].position,
+ ctx->text.lastPos);
+ _XawTextSetScrollBars(ctx);
+ }
+ }
+ else {
+ XawTextPosition updateTo;
+ unsigned int height, clear_height;
+
+ n = -n;
+ target = lt->top;
+ top = SrcScan(ctx->text.source, target, XawstEOL,
+ XawsdLeft, n+1, FALSE);
+
+ _XawTextBuildLineTable(ctx, top, FALSE);
+ y = IsValidLine(ctx, n) ? lt->info[n].y : ctx->core.height;
+ updateTo = IsValidLine(ctx, n) ? lt->info[n].position : ctx->text.lastPos;
+ if (IsValidLine(ctx, lt->lines - n))
+ height = lt->info[lt->lines-n].y - ctx->text.margin.top;
+ else if (ctx->core.height - HMargins(ctx))
+ height = ctx->core.height - HMargins(ctx);
+ else
+ height = 0;
+ if (y > (int) ctx->text.margin.top)
+ clear_height = y - ctx->text.margin.top;
+ else
+ clear_height = 0;
+
+ if ( updateTo == target ) {
+ XCopyArea(XtDisplay(ctx), XtWindow(ctx), XtWindow(ctx), ctx->text.gc,
+ 0, ctx->text.margin.top, (int) ctx->core.width, height, 0, y);
+ PushCopyQueue(ctx, 0, (int) y);
+ SinkClearToBG(ctx->text.sink, (Position) 0, ctx->text.margin.top,
+ (Dimension) ctx->core.width, (Dimension) clear_height);
+
+ _XawTextNeedsUpdating(ctx, lt->info[0].position, updateTo);
+ _XawTextSetScrollBars(ctx);
+ }
+ else if (lt->top != target)
+ DisplayTextWindow((Widget)ctx);
+ }
+ XtSetArg (list[0], XtNinsertPosition, ctx->text.lt.top+ctx->text.lt.lines);
+ _XawImSetValues ((Widget) ctx, list, 1);
+}
+
+/*ARGSUSED*/
+static void
+HScroll(w, closure, callData)
+Widget w;
+XtPointer closure; /* TextWidget */
+XtPointer callData; /* #pixels */
+{
+ TextWidget ctx = (TextWidget) closure;
+ Widget tw = (Widget) ctx;
+ Position old_left, pixels = (Position)(int) callData;
+ XRectangle rect, t_rect;
+
+ _XawTextPrepareToUpdate(ctx);
+
+ old_left = ctx->text.margin.left;
+ ctx->text.margin.left -= pixels;
+ if (ctx->text.margin.left > ctx->text.r_margin.left) {
+ ctx->text.margin.left = ctx->text.r_margin.left;
+ pixels = old_left - ctx->text.margin.left;
+ }
+
+ if (pixels > 0) {
+ rect.width = (unsigned short) pixels + ctx->text.margin.right;
+ rect.x = (short) ctx->core.width - (short) rect.width;
+ rect.y = (short) ctx->text.margin.top;
+ rect.height = (unsigned short) ctx->core.height - rect.y;
+
+ XCopyArea(XtDisplay(tw), XtWindow(tw), XtWindow(tw), ctx->text.gc,
+ pixels, (int) rect.y,
+ (unsigned int) rect.x, (unsigned int) ctx->core.height,
+ 0, (int) rect.y);
+
+ PushCopyQueue(ctx, (int) -pixels, 0);
+ }
+ else if (pixels < 0) {
+ rect.x = 0;
+
+ if (ctx->text.vbar != NULL)
+ rect.x += (short) (ctx->text.vbar->core.width +
+ ctx->text.vbar->core.border_width);
+
+ rect.width = (Position) - pixels;
+ rect.y = ctx->text.margin.top;
+ rect.height = ctx->core.height - rect.y;
+
+ XCopyArea(XtDisplay(tw), XtWindow(tw), XtWindow(tw), ctx->text.gc,
+ (int) rect.x, (int) rect.y,
+ (unsigned int) ctx->core.width - rect.width,
+ (unsigned int) rect.height,
+ (int) rect.x + rect.width, (int) rect.y);
+
+ PushCopyQueue(ctx, (int) rect.width, 0);
+
+/*
+ * Redraw the line overflow marks.
+ */
+
+ t_rect.x = ctx->core.width - ctx->text.margin.right;
+ t_rect.width = ctx->text.margin.right;
+ t_rect.y = rect.y;
+ t_rect.height = rect.height;
+
+ SinkClearToBG(ctx->text.sink, (Position) t_rect.x, (Position) t_rect.y,
+ (Dimension) t_rect.width, (Dimension) t_rect.height);
+
+ UpdateTextInRectangle(ctx, &t_rect);
+ }
+
+/*
+ * Put in the text that just became visible.
+ */
+
+ if ( pixels != 0 ) {
+ SinkClearToBG(ctx->text.sink, (Position) rect.x, (Position) rect.y,
+ (Dimension) rect.width, (Dimension) rect.height);
+
+ UpdateTextInRectangle(ctx, &rect);
+ }
+ _XawTextExecuteUpdate(ctx);
+ _XawTextSetScrollBars(ctx);
+}
+
+/*ARGSUSED*/
+static void
+HJump(w, closure, callData)
+Widget w;
+XtPointer closure, callData; /* closure = TextWidget, callData = percent. */
+{
+ TextWidget ctx = (TextWidget) closure;
+ float * percent = (float *) callData;
+ Position new_left, old_left = ctx->text.margin.left;
+
+ long move; /*difference of Positions can be bigger than Position; lint err */
+
+ new_left = ctx->text.r_margin.left;
+ new_left -= (Position) (*percent * GetWidestLine(ctx));
+ move = old_left - new_left;
+
+ if (abs(move) < (int)ctx->core.width) {
+ HScroll(w, (XtPointer) ctx, (XtPointer) move);
+ return;
+ }
+ _XawTextPrepareToUpdate(ctx);
+ ctx->text.margin.left = new_left;
+ if (XtIsRealized((Widget) ctx)) DisplayTextWindow((Widget) ctx);
+ _XawTextExecuteUpdate(ctx);
+}
+
+/* Function Name: UpdateTextInLine
+ * Description: Updates some text in a given line.
+ * Arguments: ctx - the text widget.
+ * line - the line number (in the line table) of this line.
+ * left, right - left and right pixel offsets of the
+ * area to update.
+ * Returns: none.
+ */
+
+static void
+UpdateTextInLine(ctx, line, left, right)
+TextWidget ctx;
+int line;
+Position left, right;
+{
+ XawTextPosition pos1, pos2;
+ int width, height, local_left, local_width;
+ XawTextLineTableEntry * lt = ctx->text.lt.info + line;
+
+ if ( ((int)(lt->textWidth + ctx->text.margin.left) < left) ||
+ ( ctx->text.margin.left > right ) )
+ return; /* no need to update. */
+
+ local_width = left - ctx->text.margin.left;
+ XawTextSinkFindPosition(ctx->text.sink, lt->position,
+ (int) ctx->text.margin.left,
+ local_width, FALSE, &pos1, &width, &height);
+
+ if (right >= (Position) lt->textWidth - ctx->text.margin.left)
+ if ( (IsValidLine(ctx, line + 1)) &&
+ (ctx->text.lt.info[line + 1].position <= ctx->text.lastPos) )
+ pos2 = SrcScan( ctx->text.source, (lt + 1)->position, XawstPositions,
+ XawsdLeft, 1, TRUE);
+ else
+ pos2 = GETLASTPOS;
+ else {
+ XawTextPosition t_pos;
+
+ local_left = ctx->text.margin.left + width;
+ local_width = right - local_left;
+ XawTextSinkFindPosition(ctx->text.sink, pos1, local_left,
+ local_width, FALSE, &pos2, &width, &height);
+
+ t_pos = SrcScan( ctx->text.source, pos2,
+ XawstPositions, XawsdRight, 1, TRUE);
+ if (t_pos < (lt + 1)->position)
+ pos2 = t_pos;
+ }
+
+ _XawTextNeedsUpdating(ctx, pos1, pos2);
+}
+
+/*
+ * The routine will scroll the displayed text by pixels. If the calldata is
+ * positive, move up; otherwise, move down.
+ */
+
+/*ARGSUSED*/
+static void
+VScroll(w, closure, callData)
+Widget w;
+XtPointer closure; /* TextWidget */
+XtPointer callData; /* #pixels */
+{
+ TextWidget ctx = (TextWidget)closure;
+ int height, lines = (int) callData;
+
+ height = ctx->core.height - VMargins(ctx);
+ if (height < 1)
+ height = 1;
+ lines = (int) (lines * (int) ctx->text.lt.lines) / height;
+ _XawTextPrepareToUpdate(ctx);
+ _XawTextVScroll(ctx, lines);
+ _XawTextExecuteUpdate(ctx);
+}
+
+/*
+ * The routine "thumbs" the displayed text. Thumbing means reposition the
+ * displayed view of the source to a new position determined by a fraction
+ * of the way from beginning to end. Ideally, this should be determined by
+ * the number of displayable lines in the source. This routine does it as a
+ * fraction of the first position and last position and then normalizes to
+ * the start of the line containing the position.
+ *
+ * BUG/deficiency: The normalize to line portion of this routine will
+ * cause thumbing to always position to the start of the source.
+ */
+
+/*ARGSUSED*/
+static void
+VJump(w, closure, callData)
+Widget w;
+XtPointer closure, callData; /* closuer = TextWidget, callData = percent. */
+{
+ float * percent = (float *) callData;
+ TextWidget ctx = (TextWidget)closure;
+ XawTextPosition position, old_top, old_bot;
+ XawTextLineTable * lt = &(ctx->text.lt);
+
+ _XawTextPrepareToUpdate(ctx);
+ old_top = lt->top;
+ if ( (lt->lines > 0) && (IsValidLine(ctx, lt->lines - 1)) )
+ old_bot = lt->info[lt->lines - 1].position;
+ else
+ old_bot = ctx->text.lastPos;
+
+ position = (long) (*percent * (float) ctx->text.lastPos);
+ position= SrcScan(ctx->text.source, position, XawstEOL, XawsdLeft, 1, FALSE);
+ if ( (position >= old_top) && (position <= old_bot) ) {
+ int line = 0;
+ for (;(line < lt->lines) && (position > lt->info[line].position) ; line++);
+ _XawTextVScroll(ctx, line);
+ }
+ else {
+ XawTextPosition new_bot;
+ _XawTextBuildLineTable(ctx, position, FALSE);
+ new_bot = IsValidLine(ctx, lt->lines-1) ? lt->info[lt->lines-1].position
+ : ctx->text.lastPos;
+
+ if ((old_top >= lt->top) && (old_top <= new_bot)) {
+ int line = 0;
+ for (;(line < lt->lines) && (old_top > lt->info[line].position); line++);
+ _XawTextBuildLineTable(ctx, old_top, FALSE);
+ _XawTextVScroll(ctx, -line);
+ }
+ else
+ DisplayTextWindow( (Widget) ctx);
+ }
+ _XawTextExecuteUpdate(ctx);
+}
+
+static Boolean
+MatchSelection(selection, s)
+Atom selection;
+XawTextSelection *s;
+{
+ Atom *match;
+ int count;
+
+ for (count = 0, match = s->selections; count < s->atom_count; match++, count++)
+ if (*match == selection)
+ return True;
+ return False;
+}
+
+static Boolean
+ConvertSelection(w, selection, target, type, value, length, format)
+Widget w;
+Atom *selection, *target, *type;
+XtPointer *value;
+unsigned long *length;
+int *format;
+{
+ Display* d = XtDisplay(w);
+ TextWidget ctx = (TextWidget)w;
+ Widget src = ctx->text.source;
+ XawTextEditType edit_mode;
+ Arg args[1];
+
+ XawTextSelectionSalt *salt = NULL;
+ XawTextSelection *s;
+
+ if (*target == XA_TARGETS(d)) {
+ Atom* targetP, * std_targets;
+ unsigned long std_length;
+
+ if ( SrcCvtSel(src, selection, target, type, value, length, format) )
+ return True;
+
+ XmuConvertStandardSelection(w, ctx->text.time, selection,
+ target, type, (XPointer*)&std_targets,
+ &std_length, format);
+
+ *value = XtMalloc((unsigned) sizeof(Atom)*(std_length + 7));
+ targetP = *(Atom**)value;
+ *length = std_length + 6;
+ *targetP++ = XA_STRING;
+ *targetP++ = XA_TEXT(d);
+ *targetP++ = XA_COMPOUND_TEXT(d);
+ *targetP++ = XA_LENGTH(d);
+ *targetP++ = XA_LIST_LENGTH(d);
+ *targetP++ = XA_CHARACTER_POSITION(d);
+
+ XtSetArg(args[0], XtNeditType,&edit_mode);
+ XtGetValues(src, args, ONE);
+
+ if (edit_mode == XawtextEdit) {
+ *targetP++ = XA_DELETE(d);
+ (*length)++;
+ }
+ (void) memmove((char*)targetP, (char*)std_targets, sizeof(Atom)*std_length);
+ XtFree((char*)std_targets);
+ *type = XA_ATOM;
+ *format = 32;
+ return True;
+ }
+
+ if ( SrcCvtSel(src, selection, target, type, value, length, format) )
+ return True;
+
+ if (MatchSelection (*selection, &ctx->text.s))
+ s = &ctx->text.s;
+ else
+ {
+ for (salt = ctx->text.salt; salt; salt = salt->next)
+ if (MatchSelection (*selection, &salt->s))
+ break;
+ if (!salt)
+ return False;
+ s = &salt->s;
+ }
+ if (*target == XA_STRING ||
+ *target == XA_TEXT(d) ||
+ *target == XA_COMPOUND_TEXT(d)) {
+ if (*target == XA_TEXT(d)) {
+ if (_XawTextFormat(ctx) == XawFmtWide)
+ *type = XA_COMPOUND_TEXT(d);
+ else
+ *type = XA_STRING;
+ } else {
+ *type = *target;
+ }
+ /*
+ * If salt is True, the salt->contents stores CT string,
+ * its length is measured in bytes.
+ * Refer to _XawTextSaltAwaySelection().
+ *
+ * by Li Yuhong, Mar. 20, 1991.
+ */
+ if (!salt) {
+ *value = _XawTextGetSTRING(ctx, s->left, s->right);
+ if (_XawTextFormat(ctx) == XawFmtWide) {
+ XTextProperty textprop;
+ if (XwcTextListToTextProperty(d, (wchar_t **)value, 1,
+ XCompoundTextStyle, &textprop)
+ < Success) {
+ XtFree(*value);
+ return False;
+ }
+ XtFree(*value);
+ *value = (XtPointer)textprop.value;
+ *length = textprop.nitems;
+ } else {
+ *length = strlen(*value);
+ }
+ } else {
+ *value = XtMalloc((salt->length + 1) * sizeof(unsigned char));
+ strcpy (*value, salt->contents);
+ *length = salt->length;
+ }
+ if (_XawTextFormat(ctx) == XawFmtWide && *type == XA_STRING) {
+ XTextProperty textprop;
+ wchar_t **wlist;
+ int count;
+ textprop.encoding = XA_COMPOUND_TEXT(d);
+ textprop.value = (unsigned char *)*value;
+ textprop.nitems = strlen(*value);
+ textprop.format = 8;
+ if (XwcTextPropertyToTextList(d, &textprop, (wchar_t ***)&wlist, &count)
+ < Success) {
+ XtFree(*value);
+ return False;
+ }
+ XtFree(*value);
+ if (XwcTextListToTextProperty( d, (wchar_t **)wlist, 1,
+ XStringStyle, &textprop) < Success) {
+ XwcFreeStringList( (wchar_t**) wlist );
+ return False;
+ }
+ *value = (XtPointer) textprop.value;
+ *length = textprop.nitems;
+ XwcFreeStringList( (wchar_t**) wlist );
+ }
+ *format = 8;
+ return True;
+ }
+
+ if ( (*target == XA_LIST_LENGTH(d)) || (*target == XA_LENGTH(d)) ) {
+ long * temp;
+
+ temp = (long *) XtMalloc( (unsigned) sizeof(long) );
+ if (*target == XA_LIST_LENGTH(d))
+ *temp = 1L;
+ else /* *target == XA_LENGTH(d) */
+ *temp = (long) (s->right - s->left);
+
+ *value = (XPointer) temp;
+ *type = XA_INTEGER;
+ *length = 1L;
+ *format = 32;
+ return True;
+ }
+
+ if (*target == XA_CHARACTER_POSITION(d)) {
+ long * temp;
+
+ temp = (long *) XtMalloc( (unsigned)( 2 * sizeof(long) ) );
+ temp[0] = (long) (s->left + 1);
+ temp[1] = s->right;
+ *value = (XPointer) temp;
+ *type = XA_SPAN(d);
+ *length = 2L;
+ *format = 32;
+ return True;
+ }
+
+ if (*target == XA_DELETE(d)) {
+ void _XawTextZapSelection(); /* From TextAction.c */
+
+ if (!salt)
+ _XawTextZapSelection( ctx, (XEvent *) NULL, TRUE);
+ *value = NULL;
+ *type = XA_NULL(d);
+ *length = 0;
+ *format = 32;
+ return True;
+ }
+
+ if (XmuConvertStandardSelection(w, ctx->text.time, selection, target, type,
+ (XPointer *)value, length, format))
+ return True;
+
+ /* else */
+ return False;
+}
+
+/* Function Name: GetCutBuffferNumber
+ * Description: Returns the number of the cut buffer.
+ * Arguments: atom - the atom to check.
+ * Returns: the number of the cut buffer representing this atom or
+ * NOT_A_CUT_BUFFER.
+ */
+
+#define NOT_A_CUT_BUFFER -1
+
+static int
+GetCutBufferNumber(atom)
+Atom atom;
+{
+ if (atom == XA_CUT_BUFFER0) return(0);
+ if (atom == XA_CUT_BUFFER1) return(1);
+ if (atom == XA_CUT_BUFFER2) return(2);
+ if (atom == XA_CUT_BUFFER3) return(3);
+ if (atom == XA_CUT_BUFFER4) return(4);
+ if (atom == XA_CUT_BUFFER5) return(5);
+ if (atom == XA_CUT_BUFFER6) return(6);
+ if (atom == XA_CUT_BUFFER7) return(7);
+ return(NOT_A_CUT_BUFFER);
+}
+
+static void
+LoseSelection(w, selection)
+Widget w;
+Atom *selection;
+{
+ TextWidget ctx = (TextWidget) w;
+ Atom* atomP;
+ int i;
+ XawTextSelectionSalt *salt, *prevSalt, *nextSalt;
+
+ _XawTextPrepareToUpdate(ctx);
+
+ atomP = ctx->text.s.selections;
+ for (i = 0 ; i < ctx->text.s.atom_count; i++, atomP++)
+ if ( (*selection == *atomP) ||
+ (GetCutBufferNumber(*atomP) != NOT_A_CUT_BUFFER) )/* is a cut buffer */
+ *atomP = (Atom)0;
+
+ while (ctx->text.s.atom_count &&
+ ctx->text.s.selections[ctx->text.s.atom_count-1] == 0)
+ ctx->text.s.atom_count--;
+
+/*
+ * Must walk the selection list in opposite order from UnsetSelection.
+ */
+
+ atomP = ctx->text.s.selections;
+ for (i = 0 ; i < ctx->text.s.atom_count; i++, atomP++)
+ if (*atomP == (Atom)0) {
+ *atomP = ctx->text.s.selections[--ctx->text.s.atom_count];
+ while (ctx->text.s.atom_count &&
+ ctx->text.s.selections[ctx->text.s.atom_count-1] == 0)
+ ctx->text.s.atom_count--;
+ }
+
+ if (ctx->text.s.atom_count == 0)
+ ModifySelection(ctx, ctx->text.insertPos, ctx->text.insertPos);
+
+ if (ctx->text.old_insert >= 0) /* Update in progress. */
+ _XawTextExecuteUpdate(ctx);
+
+ prevSalt = 0;
+ for (salt = ctx->text.salt; salt; salt = nextSalt)
+ {
+ atomP = salt->s.selections;
+ nextSalt = salt->next;
+ for (i = 0 ; i < salt->s.atom_count; i++, atomP++)
+ if (*selection == *atomP)
+ *atomP = (Atom)0;
+
+ while (salt->s.atom_count &&
+ salt->s.selections[salt->s.atom_count-1] == 0)
+ {
+ salt->s.atom_count--;
+ }
+
+ /*
+ * Must walk the selection list in opposite order from UnsetSelection.
+ */
+
+ atomP = salt->s.selections;
+ for (i = 0 ; i < salt->s.atom_count; i++, atomP++)
+ if (*atomP == (Atom)0)
+ {
+ *atomP = salt->s.selections[--salt->s.atom_count];
+ while (salt->s.atom_count &&
+ salt->s.selections[salt->s.atom_count-1] == 0)
+ salt->s.atom_count--;
+ }
+ if (salt->s.atom_count == 0)
+ {
+ XtFree ((char *) salt->s.selections);
+ XtFree (salt->contents);
+ if (prevSalt)
+ prevSalt->next = nextSalt;
+ else
+ ctx->text.salt = nextSalt;
+ XtFree ((char *) salt);
+ }
+ else
+ prevSalt = salt;
+ }
+}
+
+void
+_XawTextSaltAwaySelection (ctx, selections, num_atoms)
+TextWidget ctx;
+Atom* selections;
+int num_atoms;
+{
+ XawTextSelectionSalt *salt;
+ int i, j;
+
+ for (i = 0; i < num_atoms; i++)
+ LoseSelection ((Widget) ctx, selections + i);
+ if (num_atoms == 0)
+ return;
+ salt = (XawTextSelectionSalt *)
+ XtMalloc( (unsigned) sizeof(XawTextSelectionSalt) );
+ if (!salt)
+ return;
+ salt->s.selections = (Atom *)
+ XtMalloc( (unsigned) ( num_atoms * sizeof (Atom) ) );
+ if (!salt->s.selections)
+ {
+ XtFree ((char *) salt);
+ return;
+ }
+ salt->s.left = ctx->text.s.left;
+ salt->s.right = ctx->text.s.right;
+ salt->s.type = ctx->text.s.type;
+ salt->contents = _XawTextGetSTRING(ctx, ctx->text.s.left, ctx->text.s.right);
+ if (_XawTextFormat(ctx) == XawFmtWide) {
+ XTextProperty textprop;
+ if (XwcTextListToTextProperty(XtDisplay((Widget)ctx),
+ (wchar_t**)(&(salt->contents)), 1, XCompoundTextStyle,
+ &textprop) < Success) {
+ XtFree(salt->contents);
+ salt->length = 0;
+ return;
+ }
+ XtFree(salt->contents);
+ salt->contents = (char *)textprop.value;
+ salt->length = textprop.nitems;
+ } else
+ salt->length = strlen (salt->contents);
+ salt->next = ctx->text.salt;
+ ctx->text.salt = salt;
+ j = 0;
+ for (i = 0; i < num_atoms; i++)
+ {
+ if (GetCutBufferNumber (selections[i]) == NOT_A_CUT_BUFFER)
+ {
+ salt->s.selections[j++] = selections[i];
+ XtOwnSelection ((Widget) ctx, selections[i], ctx->text.time,
+ ConvertSelection, LoseSelection, (XtSelectionDoneProc)NULL);
+ }
+ }
+ salt->s.atom_count = j;
+}
+
+static void
+_SetSelection(ctx, left, right, selections, count)
+TextWidget ctx;
+XawTextPosition left, right;
+Atom *selections;
+Cardinal count;
+{
+ XawTextPosition pos;
+
+ if (left < ctx->text.s.left) {
+ pos = Min(right, ctx->text.s.left);
+ _XawTextNeedsUpdating(ctx, left, pos);
+ }
+ if (left > ctx->text.s.left) {
+ pos = Min(left, ctx->text.s.right);
+ _XawTextNeedsUpdating(ctx, ctx->text.s.left, pos);
+ }
+ if (right < ctx->text.s.right) {
+ pos = Max(right, ctx->text.s.left);
+ _XawTextNeedsUpdating(ctx, pos, ctx->text.s.right);
+ }
+ if (right > ctx->text.s.right) {
+ pos = Max(left, ctx->text.s.right);
+ _XawTextNeedsUpdating(ctx, pos, right);
+ }
+
+ ctx->text.s.left = left;
+ ctx->text.s.right = right;
+
+ SrcSetSelection(ctx->text.source, left, right,
+ (count == 0) ? None : selections[0]);
+
+ if (left < right) {
+ Widget w = (Widget) ctx;
+ int buffer;
+
+ while (count) {
+ Atom selection = selections[--count];
+
+/*
+ * If this is a cut buffer.
+ */
+
+ if ((buffer = GetCutBufferNumber(selection)) != NOT_A_CUT_BUFFER) {
+ unsigned char *ptr, *tptr;
+ unsigned int amount, max_len = MAX_CUT_LEN(XtDisplay(w));
+ unsigned long len;
+
+ tptr= ptr= (unsigned char *) _XawTextGetSTRING(ctx, ctx->text.s.left,
+ ctx->text.s.right);
+ if (_XawTextFormat(ctx) == XawFmtWide) {
+ /*
+ * Only XA_STRING(Latin 1) is allowed in CUT_BUFFER,
+ * so we get it from wchar string, then free the wchar string.
+ */
+ XTextProperty textprop;
+ if (XwcTextListToTextProperty(XtDisplay(w), (wchar_t**)&ptr, 1,
+ XStringStyle, &textprop) < Success) {
+ XtFree((char *)ptr);
+ return;
+ }
+ XtFree((char *)ptr);
+ tptr = ptr = textprop.value;
+ }
+ if (buffer == 0) {
+ _CreateCutBuffers(XtDisplay(w));
+ XRotateBuffers(XtDisplay(w), 1);
+ }
+ amount = Min ( (len = strlen((char *)ptr)), max_len);
+ XChangeProperty(XtDisplay(w), RootWindow(XtDisplay(w), 0), selection,
+ XA_STRING, 8, PropModeReplace, ptr, amount);
+
+ while (len > max_len) {
+ len -= max_len;
+ tptr += max_len;
+ amount = Min (len, max_len);
+ XChangeProperty(XtDisplay(w), RootWindow(XtDisplay(w), 0),
+ selection, XA_STRING, 8, PropModeAppend,
+ tptr, amount);
+ }
+ XtFree ((char *)ptr);
+ }
+ else /* This is a real selection */
+ XtOwnSelection(w, selection, ctx->text.time, ConvertSelection,
+ LoseSelection, (XtSelectionDoneProc)NULL);
+ }
+ }
+ else
+ XawTextUnsetSelection((Widget)ctx);
+}
+
+/*
+ * This internal routine deletes the text from pos1 to pos2 in a source and
+ * then inserts, at pos1, the text that was passed. As a side effect it
+ * "invalidates" that portion of the displayed text (if any).
+ *
+ * NOTE: It is illegal to call this routine unless there is a valid line table!
+ */
+
+int
+_XawTextReplace (ctx, pos1, pos2, text)
+TextWidget ctx;
+XawTextPosition pos1, pos2;
+XawTextBlock *text;
+{
+ int i, line1, delta, error;
+ XawTextPosition updateFrom, updateTo;
+ Widget src = ctx->text.source;
+ XawTextEditType edit_mode;
+ Arg args[1];
+ Boolean tmp = ctx->text.update_disabled;
+
+ ctx->text.update_disabled = True; /* No redisplay during replacement. */
+
+/*
+ * The insertPos may not always be set to the right spot in XawtextAppend
+ */
+
+ XtSetArg(args[0], XtNeditType, &edit_mode);
+ XtGetValues(src, args, ONE);
+
+ if ((pos1 == ctx->text.insertPos) && (edit_mode == XawtextAppend)) {
+ ctx->text.insertPos = ctx->text.lastPos;
+ pos2 = SrcScan(src, ctx->text.insertPos, XawstPositions, XawsdRight,
+ (int)(ctx->text.insertPos - pos1), (Boolean)TRUE);
+ pos1 = ctx->text.insertPos;
+ if ( (pos1 == pos2) && (text->length == 0) ) {
+ ctx->text.update_disabled = FALSE; /* rearm redisplay. */
+ return( XawEditError );
+ }
+ }
+
+ updateFrom = SrcScan(src, pos1, XawstWhiteSpace, XawsdLeft, 1, FALSE);
+ updateFrom = Max(updateFrom, ctx->text.lt.top);
+
+ line1 = LineForPosition(ctx, updateFrom);
+ if ( (error = SrcReplace(src, pos1, pos2, text)) != 0) {
+ ctx->text.update_disabled = tmp; /* restore redisplay */
+ return(error);
+ }
+
+ XawTextUnsetSelection((Widget)ctx);
+
+ ctx->text.lastPos = GETLASTPOS;
+ if (ctx->text.lt.top >= ctx->text.lastPos) {
+ _XawTextBuildLineTable(ctx, ctx->text.lastPos, FALSE);
+ ClearWindow( (Widget) ctx);
+ ctx->text.update_disabled = tmp; /* restore redisplay */
+ return(0); /* Things are fine. */
+ }
+
+ ctx->text.single_char = (text->length <= 1 && pos2 - pos1 <= 1);
+
+ delta = text->length - (pos2 - pos1);
+
+ if (delta < ctx->text.lastPos) {
+ for (pos2 += delta, i = 0; i < ctx->text.numranges; i++) {
+ if (ctx->text.updateFrom[i] > pos1)
+ ctx->text.updateFrom[i] += delta;
+ if (ctx->text.updateTo[i] >= pos1)
+ ctx->text.updateTo[i] += delta;
+ }
+ }
+
+ /*
+ * fixup all current line table entries to reflect edit.
+ * %%% it is not legal to do arithmetic on positions.
+ * using Scan would be more proper.
+ */
+ if (delta != 0) {
+ XawTextLineTableEntry *lineP;
+ i = LineForPosition(ctx, pos1) + 1;
+ for (lineP = ctx->text.lt.info + i; i <= ctx->text.lt.lines; i++, lineP++)
+ lineP->position += delta;
+ }
+
+ /*
+ * Now process the line table and fixup in case edits caused
+ * changes in line breaks. If we are breaking on word boundaries,
+ * this code checks for moving words to and from lines.
+ */
+
+ if (IsPositionVisible(ctx, updateFrom)) {
+ updateTo = _BuildLineTable(ctx,
+ ctx->text.lt.info[line1].position, pos1, line1);
+ _XawTextNeedsUpdating(ctx, updateFrom, updateTo);
+ }
+
+ ctx->text.update_disabled = tmp; /* restore redisplay */
+ return(0); /* Things are fine. */
+}
+
+/*
+ * This routine will display text between two arbitrary source positions.
+ * In the event that this span contains highlighted text for the selection,
+ * only that portion will be displayed highlighted.
+ *
+ * NOTE: it is illegal to call this routine unless there
+ * is a valid line table!
+ */
+
+static void
+DisplayText(w, pos1, pos2)
+Widget w;
+XawTextPosition pos1, pos2;
+{
+ TextWidget ctx = (TextWidget)w;
+ Position x, y;
+ int height, line, i, lastPos = ctx->text.lastPos;
+ XawTextPosition startPos, endPos;
+ Boolean clear_eol, done_painting;
+
+ pos1 = (pos1 < ctx->text.lt.top) ? ctx->text.lt.top : pos1;
+ pos2 = FindGoodPosition(ctx, pos2);
+ if ( (pos1 >= pos2) || !LineAndXYForPosition(ctx, pos1, &line, &x, &y) )
+ return; /* line not visible, or pos1 >= pos2. */
+
+ for ( startPos = pos1, i = line; IsValidLine(ctx, i) &&
+ (i < ctx->text.lt.lines) ; i++) {
+
+
+ if ( (endPos = ctx->text.lt.info[i + 1].position) > pos2 ) {
+ clear_eol = ((endPos = pos2) >= lastPos);
+ done_painting = (!clear_eol || ctx->text.single_char);
+ }
+ else {
+ clear_eol = TRUE;
+ done_painting = FALSE;
+ }
+
+ height = ctx->text.lt.info[i + 1].y - ctx->text.lt.info[i].y;
+
+ if ( (endPos > startPos) ) {
+ if ( (x == (Position) ctx->text.margin.left) && (x > 0) )
+ SinkClearToBG (ctx->text.sink,
+ (Position) 0, y,
+ (Dimension) ctx->text.margin.left, (Dimension)height);
+
+ if ( (startPos >= ctx->text.s.right) || (endPos <= ctx->text.s.left) )
+ XawTextSinkDisplayText(ctx->text.sink, x, y, startPos, endPos, FALSE);
+ else if ((startPos >= ctx->text.s.left) && (endPos <= ctx->text.s.right))
+ XawTextSinkDisplayText(ctx->text.sink, x, y, startPos, endPos, TRUE);
+ else {
+ DisplayText(w, startPos, ctx->text.s.left);
+ DisplayText(w, Max(startPos, ctx->text.s.left),
+ Min(endPos, ctx->text.s.right));
+ DisplayText(w, ctx->text.s.right, endPos);
+ }
+ }
+ startPos = endPos;
+ if (clear_eol) {
+ SinkClearToBG(ctx->text.sink,
+ (Position) (ctx->text.lt.info[i].textWidth +
+ ctx->text.margin.left),
+ (Position) y, w->core.width, (Dimension) height);
+
+ /*
+ * We only get here if single character is true, and we need
+ * to clear to the end of the screen. We know that since there
+ * was only one character deleted that this is the same
+ * as clearing an extra line, so we do this, and are done.
+ *
+ * This a performance hack, and a pretty gross one, but it works.
+ *
+ * Chris Peterson 11/13/89.
+ */
+
+ if (done_painting) {
+ y += height;
+ SinkClearToBG(ctx->text.sink,
+ (Position) ctx->text.margin.left, (Position) y,
+ w->core.width, (Dimension) height);
+
+ break; /* set single_char to FALSE and return. */
+ }
+ }
+
+ x = (Position) ctx->text.margin.left;
+ y = ctx->text.lt.info[i + 1].y;
+ if ( done_painting
+ || (y >= (int)(ctx->core.height - ctx->text.margin.bottom)) )
+ break;
+ }
+ ctx->text.single_char = FALSE;
+}
+
+/*
+ * This routine implements multi-click selection in a hardwired manner.
+ * It supports multi-click entity cycling (char, word, line, file) and mouse
+ * motion adjustment of the selected entitie (i.e. select a word then, with
+ * button still down, adjust wich word you really meant by moving the mouse).
+ * [NOTE: This routine is to be replaced by a set of procedures that
+ * will allows clients to implements a wide class of draw through and
+ * multi-click selection user interfaces.]
+ */
+
+static void
+DoSelection (ctx, pos, time, motion)
+TextWidget ctx;
+XawTextPosition pos;
+Time time;
+Boolean motion;
+{
+ XawTextPosition newLeft, newRight;
+ XawTextSelectType newType, *sarray;
+ Widget src = ctx->text.source;
+
+ if (motion)
+ newType = ctx->text.s.type;
+ else {
+ if ( (abs((long) time - (long) ctx->text.lasttime) < MULTI_CLICK_TIME) &&
+ ((pos >= ctx->text.s.left) && (pos <= ctx->text.s.right))) {
+ sarray = ctx->text.sarray;
+ for (;*sarray != XawselectNull && *sarray != ctx->text.s.type; sarray++);
+
+ if (*sarray == XawselectNull)
+ newType = *(ctx->text.sarray);
+ else {
+ newType = *(sarray + 1);
+ if (newType == XawselectNull)
+ newType = *(ctx->text.sarray);
+ }
+ }
+ else /* single-click event */
+ newType = *(ctx->text.sarray);
+
+ ctx->text.lasttime = time;
+ }
+ switch (newType) {
+ case XawselectPosition:
+ newLeft = newRight = pos;
+ break;
+ case XawselectChar:
+ newLeft = pos;
+ newRight = SrcScan(src, pos, XawstPositions, XawsdRight, 1, FALSE);
+ break;
+ case XawselectWord:
+ case XawselectParagraph:
+ {
+ XawTextScanType stype;
+
+ if (newType == XawselectWord)
+ stype = XawstWhiteSpace;
+ else
+ stype = XawstParagraph;
+
+ /*
+ * Somewhat complicated, but basically I treat the space between
+ * two objects as another object. The object that I am currently
+ * in then becomes the end of the selection.
+ *
+ * Chris Peterson - 4/19/90.
+ */
+
+ newRight = SrcScan(ctx->text.source, pos, stype, XawsdRight, 1, FALSE);
+ newRight =SrcScan(ctx->text.source, newRight,stype,XawsdLeft,1, FALSE);
+
+ if (pos != newRight)
+ newLeft = SrcScan(ctx->text.source, pos, stype, XawsdLeft, 1, FALSE);
+ else
+ newLeft = pos;
+
+ newLeft =SrcScan(ctx->text.source, newLeft, stype, XawsdRight,1,FALSE);
+
+ if (newLeft > newRight) {
+ XawTextPosition temp = newLeft;
+ newLeft = newRight;
+ newRight = temp;
+ }
+ }
+ break;
+ case XawselectLine:
+ newLeft = SrcScan(src, pos, XawstEOL, XawsdLeft, 1, FALSE);
+ newRight = SrcScan(src, pos, XawstEOL, XawsdRight, 1, FALSE);
+ break;
+ case XawselectAll:
+ newLeft = SrcScan(src, pos, XawstAll, XawsdLeft, 1, FALSE);
+ newRight = SrcScan(src, pos, XawstAll, XawsdRight, 1, FALSE);
+ break;
+ default:
+ XtAppWarning(XtWidgetToApplicationContext((Widget) ctx),
+ "Text Widget: empty selection array.");
+ return;
+ }
+
+ if ( (newLeft != ctx->text.s.left) || (newRight != ctx->text.s.right)
+ || (newType != ctx->text.s.type)) {
+ ModifySelection(ctx, newLeft, newRight);
+ if (pos - ctx->text.s.left < ctx->text.s.right - pos)
+ ctx->text.insertPos = newLeft;
+ else
+ ctx->text.insertPos = newRight;
+ ctx->text.s.type = newType;
+ }
+ if (!motion) { /* setup so we can freely mix select extend calls*/
+ ctx->text.origSel.type = ctx->text.s.type;
+ ctx->text.origSel.left = ctx->text.s.left;
+ ctx->text.origSel.right = ctx->text.s.right;
+
+ if (pos >= ctx->text.s.left + ((ctx->text.s.right - ctx->text.s.left) / 2))
+ ctx->text.extendDir = XawsdRight;
+ else
+ ctx->text.extendDir = XawsdLeft;
+ }
+}
+
+/*
+ * This routine implements extension of the currently selected text in
+ * the "current" mode (i.e. char word, line, etc.). It worries about
+ * extending from either end of the selection and handles the case when you
+ * cross through the "center" of the current selection (e.g. switch which
+ * end you are extending!).
+ */
+
+static void
+ExtendSelection (ctx, pos, motion)
+TextWidget ctx;
+XawTextPosition pos;
+Boolean motion;
+{
+ XawTextScanDirection dir;
+
+ if (!motion) { /* setup for extending selection */
+ if (ctx->text.s.left == ctx->text.s.right) /* no current selection. */
+ ctx->text.s.left = ctx->text.s.right = ctx->text.insertPos;
+ else {
+ ctx->text.origSel.left = ctx->text.s.left;
+ ctx->text.origSel.right = ctx->text.s.right;
+ }
+
+ ctx->text.origSel.type = ctx->text.s.type;
+
+ if (pos >= ctx->text.s.left + ((ctx->text.s.right - ctx->text.s.left) / 2))
+ ctx->text.extendDir = XawsdRight;
+ else
+ ctx->text.extendDir = XawsdLeft;
+ }
+ else /* check for change in extend direction */
+ if ((ctx->text.extendDir == XawsdRight && pos <= ctx->text.origSel.left) ||
+ (ctx->text.extendDir == XawsdLeft && pos >= ctx->text.origSel.right)) {
+ ctx->text.extendDir = (ctx->text.extendDir == XawsdRight) ?
+ XawsdLeft : XawsdRight;
+ ModifySelection(ctx, ctx->text.origSel.left, ctx->text.origSel.right);
+ }
+
+ dir = ctx->text.extendDir;
+ switch (ctx->text.s.type) {
+ case XawselectWord:
+ case XawselectParagraph:
+ {
+ XawTextPosition left_pos, right_pos;
+ XawTextScanType stype;
+
+ if (ctx->text.s.type == XawselectWord)
+ stype = XawstWhiteSpace;
+ else
+ stype = XawstParagraph;
+
+ /*
+ * Somewhat complicated, but basically I treat the space between
+ * two objects as another object. The object that I am currently
+ * in then becomes the end of the selection.
+ *
+ * Chris Peterson - 4/19/90.
+ */
+
+ right_pos = SrcScan(ctx->text.source, pos, stype, XawsdRight, 1, FALSE);
+ right_pos =SrcScan(ctx->text.source, right_pos,stype,XawsdLeft,1, FALSE);
+
+ if (pos != right_pos)
+ left_pos = SrcScan(ctx->text.source, pos, stype, XawsdLeft, 1, FALSE);
+ else
+ left_pos = pos;
+
+ left_pos =SrcScan(ctx->text.source, left_pos, stype, XawsdRight,1,FALSE);
+
+ if (dir == XawsdLeft)
+ pos = Min(left_pos, right_pos);
+ else /* dir == XawsdRight */
+ pos = Max(left_pos, right_pos);
+ }
+ break;
+ case XawselectLine:
+ pos = SrcScan(ctx->text.source, pos, XawstEOL, dir, 1, dir == XawsdRight);
+ break;
+ case XawselectAll:
+ pos = ctx->text.insertPos;
+ case XawselectPosition: /* fall through. */
+ default:
+ break;
+ }
+
+ if (dir == XawsdRight)
+ ModifySelection(ctx, ctx->text.s.left, pos);
+ else
+ ModifySelection(ctx, pos, ctx->text.s.right);
+
+ ctx->text.insertPos = pos;
+}
+
+/*
+ * Clear the window to background color.
+ */
+
+static void
+ClearWindow (w)
+Widget w;
+{
+ TextWidget ctx = (TextWidget) w;
+
+ if (XtIsRealized(w))
+ SinkClearToBG(ctx->text.sink,
+ (Position) 0, (Position) 0,
+ w->core.width, w->core.height);
+}
+
+/* Function Name: _XawTextClearAndCenterDisplay
+ * Description: Redraws the display with the cursor in insert point
+ * centered vertically.
+ * Arguments: ctx - the text widget.
+ * Returns: none.
+ */
+
+void
+_XawTextClearAndCenterDisplay(ctx)
+TextWidget ctx;
+{
+ int insert_line = LineForPosition(ctx, ctx->text.insertPos);
+ int scroll_by = insert_line - ctx->text.lt.lines/2;
+
+ _XawTextVScroll(ctx, scroll_by);
+ DisplayTextWindow( (Widget) ctx);
+}
+
+/*
+ * Internal redisplay entire window.
+ * Legal to call only if widget is realized.
+ */
+
+static void
+DisplayTextWindow (w)
+Widget w;
+{
+ TextWidget ctx = (TextWidget) w;
+ ClearWindow(w);
+ _XawTextBuildLineTable(ctx, ctx->text.lt.top, FALSE);
+ _XawTextNeedsUpdating(ctx, zeroPosition, ctx->text.lastPos);
+ _XawTextSetScrollBars(ctx);
+}
+
+/*
+ * This routine checks to see if the window should be resized (grown or
+ * shrunk) when text to be painted overflows to the right or
+ * the bottom of the window. It is used by the keyboard input routine.
+ */
+
+void
+_XawTextCheckResize(ctx)
+TextWidget ctx;
+{
+ Widget w = (Widget) ctx;
+ int line = 0, old_height;
+ XtWidgetGeometry rbox, return_geom;
+
+ if ( (ctx->text.resize == XawtextResizeWidth) ||
+ (ctx->text.resize == XawtextResizeBoth) ) {
+ XawTextLineTableEntry *lt;
+ rbox.width = 0;
+ for (lt = ctx->text.lt.info;
+ IsValidLine(ctx, line) && (line < ctx->text.lt.lines);
+ line++, lt++) {
+ if ((int)(lt->textWidth + ctx->text.margin.left) > (int)rbox.width)
+ rbox.width = lt->textWidth + ctx->text.margin.left;
+ }
+
+ rbox.width += ctx->text.margin.right;
+ if (rbox.width > ctx->core.width) { /* Only get wider. */
+ rbox.request_mode = CWWidth;
+ if (XtMakeGeometryRequest(w, &rbox, &return_geom) == XtGeometryAlmost)
+ (void) XtMakeGeometryRequest(w, &return_geom, (XtWidgetGeometry*) NULL);
+ }
+ }
+
+ if ( !((ctx->text.resize == XawtextResizeHeight) ||
+ (ctx->text.resize == XawtextResizeBoth)) )
+ return;
+
+ if (IsPositionVisible(ctx, ctx->text.lastPos))
+ line = LineForPosition(ctx, ctx->text.lastPos);
+ else
+ line = ctx->text.lt.lines;
+
+ if ( (line + 1) == ctx->text.lt.lines ) return;
+
+ old_height = ctx->core.height;
+ rbox.request_mode = CWHeight;
+ rbox.height = XawTextSinkMaxHeight(ctx->text.sink, line + 1) + VMargins(ctx);
+
+ if ((int)rbox.height < old_height) return; /* It will only get taller. */
+
+ if (XtMakeGeometryRequest(w, &rbox, &return_geom) == XtGeometryAlmost)
+ if (XtMakeGeometryRequest(w, &return_geom, (XtWidgetGeometry*)NULL) != XtGeometryYes)
+ return;
+
+ _XawTextBuildLineTable(ctx, ctx->text.lt.top, TRUE);
+}
+
+/*
+ * Converts (params, num_params) to a list of atoms & caches the
+ * list in the TextWidget instance.
+ */
+
+Atom*
+_XawTextSelectionList(ctx, list, nelems)
+TextWidget ctx;
+String *list;
+Cardinal nelems;
+{
+ Atom * sel = ctx->text.s.selections;
+ Display *dpy = XtDisplay((Widget) ctx);
+ int n;
+
+ if (nelems > ctx->text.s.array_size) {
+ sel = (Atom *) XtRealloc((char *) sel, sizeof(Atom) * nelems);
+ ctx->text.s.array_size = nelems;
+ ctx->text.s.selections = sel;
+ }
+ for (n=nelems; --n >= 0; sel++, list++)
+ *sel = XInternAtom(dpy, *list, False);
+ ctx->text.s.atom_count = nelems;
+ return ctx->text.s.selections;
+}
+
+/* Function Name: SetSelection
+ * Description: Sets the current selection.
+ * Arguments: ctx - the text widget.
+ * defaultSel - the default selection.
+ * l, r - the left and right ends of the selection.
+ * list, nelems - the selection list (as strings).
+ * Returns: none.
+ *
+ * NOTE: if (ctx->text.s.left >= ctx->text.s.right) then the selection
+ * is unset.
+ */
+
+void
+_XawTextSetSelection(ctx, l, r, list, nelems)
+TextWidget ctx;
+XawTextPosition l, r;
+String *list;
+Cardinal nelems;
+{
+ if (nelems == 1 && !strcmp (list[0], "none"))
+ return;
+ if (nelems == 0) {
+ String defaultSel = "PRIMARY";
+ list = &defaultSel;
+ nelems = 1;
+ }
+ _SetSelection(ctx, l, r, _XawTextSelectionList(ctx, list, nelems), nelems);
+}
+
+
+/* Function Name: ModifySelection
+ * Description: Modifies the current selection.
+ * Arguments: ctx - the text widget.
+ * left, right - the left and right ends of the selection.
+ * Returns: none.
+ *
+ * NOTE: if (ctx->text.s.left >= ctx->text.s.right) then the selection
+ * is unset.
+ */
+
+static void
+ModifySelection(ctx, left, right)
+TextWidget ctx;
+XawTextPosition left, right;
+{
+ if (left == right)
+ ctx->text.insertPos = left;
+ _SetSelection( ctx, left, right, (Atom*) NULL, ZERO );
+}
+
+/*
+ * This routine is used to perform various selection functions. The goal is
+ * to be able to specify all the more popular forms of draw-through and
+ * multi-click selection user interfaces from the outside.
+ */
+
+void
+_XawTextAlterSelection (ctx, mode, action, params, num_params)
+TextWidget ctx;
+XawTextSelectionMode mode; /* {XawsmTextSelect, XawsmTextExtend} */
+XawTextSelectionAction action; /* {XawactionStart,
+ XawactionAdjust, XawactionEnd} */
+String *params;
+Cardinal *num_params;
+{
+ XawTextPosition position;
+ Boolean flag;
+
+/*
+ * This flag is used by TextPop.c:DoReplace() to determine if the selection
+ * is okay to use, or if it has been modified.
+ */
+
+ if (ctx->text.search != NULL)
+ ctx->text.search->selection_changed = TRUE;
+
+ position = PositionForXY (ctx, (int) ctx->text.ev_x, (int) ctx->text.ev_y);
+
+ flag = (action != XawactionStart);
+ if (mode == XawsmTextSelect)
+ DoSelection (ctx, position, ctx->text.time, flag);
+ else /* mode == XawsmTextExtend */
+ ExtendSelection (ctx, position, flag);
+
+ if (action == XawactionEnd)
+ _XawTextSetSelection(ctx, ctx->text.s.left, ctx->text.s.right,
+ params, *num_params);
+}
+
+/* Function Name: RectanglesOverlap
+ * Description: Returns TRUE if two rectangles overlap.
+ * Arguments: rect1, rect2 - the two rectangles to check.
+ * Returns: TRUE iff these rectangles overlap.
+ */
+
+static Boolean
+RectanglesOverlap(rect1, rect2)
+XRectangle *rect1, *rect2;
+{
+ return ( (rect1->x < rect2->x + (short) rect2->width) &&
+ (rect2->x < rect1->x + (short) rect1->width) &&
+ (rect1->y < rect2->y + (short) rect2->height) &&
+ (rect2->y < rect1->y + (short) rect1->height) );
+}
+
+/* Function Name: UpdateTextInRectangle.
+ * Description: Updates the text in a rectangle.
+ * Arguments: ctx - the text widget.
+ * rect - the rectangle to update.
+ * Returns: none.
+ */
+
+static void
+UpdateTextInRectangle(ctx, rect)
+TextWidget ctx;
+XRectangle * rect;
+{
+ XawTextLineTableEntry *info = ctx->text.lt.info;
+ int line, x = rect->x, y = rect->y;
+ int right = rect->width + x, bottom = rect->height + y;
+
+ for (line = 0;( (line < ctx->text.lt.lines) &&
+ IsValidLine(ctx, line) && (info->y < bottom)); line++, info++)
+ if ( (info + 1)->y >= y )
+ UpdateTextInLine(ctx, line, x, right);
+}
+
+/*
+ * This routine processes all "expose region" XEvents. In general, its job
+ * is to the best job at minimal re-paint of the text, displayed in the
+ * window, that it can.
+ */
+
+/* ARGSUSED */
+static void
+ProcessExposeRegion(w, event, region)
+Widget w;
+XEvent *event;
+Region region; /* Unused. */
+{
+ TextWidget ctx = (TextWidget) w;
+ XRectangle expose, cursor;
+ Boolean need_to_draw;
+
+ if (event->type == Expose) {
+ expose.x = event->xexpose.x;
+ expose.y = event->xexpose.y;
+ expose.width = event->xexpose.width;
+ expose.height = event->xexpose.height;
+ }
+ else if (event->type == GraphicsExpose) {
+ expose.x = event->xgraphicsexpose.x;
+ expose.y = event->xgraphicsexpose.y;
+ expose.width = event->xgraphicsexpose.width;
+ expose.height = event->xgraphicsexpose.height;
+ }
+ else { /* No Expose */
+ PopCopyQueue(ctx);
+ return; /* no more processing necessary. */
+ }
+
+ need_to_draw = TranslateExposeRegion(ctx, &expose);
+ if ((event->type == GraphicsExpose) && (event->xgraphicsexpose.count == 0))
+ PopCopyQueue(ctx);
+
+ if (!need_to_draw)
+ return; /* don't draw if we don't need to. */
+
+ _XawTextPrepareToUpdate(ctx);
+ UpdateTextInRectangle(ctx, &expose);
+ XawTextSinkGetCursorBounds(ctx->text.sink, &cursor);
+ if (RectanglesOverlap(&cursor, &expose)) {
+ SinkClearToBG(ctx->text.sink, (Position) cursor.x, (Position) cursor.y,
+ (Dimension) cursor.width, (Dimension) cursor.height);
+ UpdateTextInRectangle(ctx, &cursor);
+ }
+ _XawTextExecuteUpdate(ctx);
+}
+
+/*
+ * This routine does all setup required to syncronize batched screen updates
+ */
+
+void
+_XawTextPrepareToUpdate(ctx)
+TextWidget ctx;
+{
+ if (ctx->text.old_insert < 0) {
+ InsertCursor((Widget)ctx, XawisOff);
+ ctx->text.numranges = 0;
+ ctx->text.showposition = FALSE;
+ ctx->text.old_insert = ctx->text.insertPos;
+ }
+}
+
+/*
+ * This is a private utility routine used by _XawTextExecuteUpdate. It
+ * processes all the outstanding update requests and merges update
+ * ranges where possible.
+ */
+
+static
+void FlushUpdate(ctx)
+TextWidget ctx;
+{
+ int i, w;
+ XawTextPosition updateFrom, updateTo;
+ if (!XtIsRealized((Widget)ctx)) {
+ ctx->text.numranges = 0;
+ return;
+ }
+ while (ctx->text.numranges > 0) {
+ updateFrom = ctx->text.updateFrom[0];
+ w = 0;
+ for (i = 1 ; i < ctx->text.numranges ; i++) {
+ if (ctx->text.updateFrom[i] < updateFrom) {
+ updateFrom = ctx->text.updateFrom[i];
+ w = i;
+ }
+ }
+ updateTo = ctx->text.updateTo[w];
+ ctx->text.numranges--;
+ ctx->text.updateFrom[w] = ctx->text.updateFrom[ctx->text.numranges];
+ ctx->text.updateTo[w] = ctx->text.updateTo[ctx->text.numranges];
+ for (i = ctx->text.numranges - 1 ; i >= 0 ; i--) {
+ while (ctx->text.updateFrom[i] <= updateTo && i < ctx->text.numranges) {
+ updateTo = ctx->text.updateTo[i];
+ ctx->text.numranges--;
+ ctx->text.updateFrom[i] = ctx->text.updateFrom[ctx->text.numranges];
+ ctx->text.updateTo[i] = ctx->text.updateTo[ctx->text.numranges];
+ }
+ }
+ DisplayText((Widget)ctx, updateFrom, updateTo);
+ }
+}
+
+/*
+ * This is a private utility routine used by _XawTextExecuteUpdate. This
+ * routine worries about edits causing new data or the insertion point becoming
+ * invisible (off the screen, or under the horiz. scrollbar). Currently
+ * it always makes it visible by scrolling. It probably needs
+ * generalization to allow more options.
+ */
+
+void
+_XawTextShowPosition(ctx)
+TextWidget ctx;
+{
+ int x, y, lines, number;
+ Boolean no_scroll;
+ XawTextPosition max_pos, top, first;
+
+ if ( (!XtIsRealized((Widget)ctx)) || (ctx->text.lt.lines <= 0) )
+ return;
+
+/*
+ * Find out the bottom the visable window, and make sure that the
+ * cursor does not go past the end of this space.
+ *
+ * This makes sure that the cursor does not go past the end of the
+ * visable window.
+ */
+
+ x = ctx->core.width;
+ y = ctx->core.height - ctx->text.margin.bottom;
+ if (ctx->text.hbar != NULL)
+ y -= ctx->text.hbar->core.height + 2 * ctx->text.hbar->core.border_width;
+
+ max_pos = PositionForXY (ctx, x, y);
+ lines = LineForPosition(ctx, max_pos) + 1; /* number of visable lines. */
+
+ if ( (ctx->text.insertPos >= ctx->text.lt.top) &&
+ (ctx->text.insertPos < max_pos))
+ return;
+
+ first = ctx->text.lt.top;
+ no_scroll = FALSE;
+
+ if (ctx->text.insertPos < first) { /* We need to scroll down. */
+ top = SrcScan(ctx->text.source, ctx->text.insertPos,
+ XawstEOL, XawsdLeft, 1, FALSE);
+
+ /* count the number of lines we have to scroll */
+
+ number = 0;
+ while (first > top) {
+ first = SrcScan(ctx->text.source, first,
+ XawstEOL, XawsdLeft, 1, TRUE);
+
+ if ( - number > lines )
+ break;
+
+ number--;
+ }
+
+ if (first <= top) { /* If we found the proper number
+ of lines. */
+
+ /* Back up to just before the last CR. */
+
+ first = SrcScan(ctx->text.source, first,
+ XawstPositions, XawsdRight, 1, TRUE);
+
+ /* Check to make sure the cursor is visable. */
+
+ if (first <= top)
+ number++;
+
+ lines = number;
+ }
+ else
+ no_scroll = TRUE;
+ }
+ else { /* We need to Scroll up */
+ top = SrcScan(ctx->text.source, ctx->text.insertPos,
+ XawstEOL, XawsdLeft, lines, FALSE);
+
+ if (top < max_pos)
+ lines = LineForPosition(ctx, top);
+ else
+ no_scroll = TRUE;
+ }
+
+ if (no_scroll) {
+ _XawTextBuildLineTable(ctx, top, FALSE);
+ DisplayTextWindow((Widget)ctx);
+ }
+ else
+ _XawTextVScroll(ctx, lines);
+
+ _XawTextSetScrollBars(ctx);
+}
+
+/*
+ * This routine causes all batched screen updates to be performed
+ */
+
+void
+_XawTextExecuteUpdate(ctx)
+TextWidget ctx;
+{
+ if ( ctx->text.update_disabled || (ctx->text.old_insert < 0) )
+ return;
+
+ if((ctx->text.old_insert != ctx->text.insertPos) || (ctx->text.showposition))
+ _XawTextShowPosition(ctx);
+ FlushUpdate(ctx);
+ InsertCursor((Widget)ctx, XawisOn);
+ ctx->text.old_insert = -1;
+}
+
+
+static void
+TextDestroy(w)
+Widget w;
+{
+ TextWidget ctx = (TextWidget)w;
+
+ DestroyHScrollBar(ctx);
+ DestroyVScrollBar(ctx);
+
+ XtFree((char *)ctx->text.s.selections);
+ XtFree((char *)ctx->text.lt.info);
+ XtFree((char *)ctx->text.search);
+ XtFree((char *)ctx->text.updateFrom);
+ XtFree((char *)ctx->text.updateTo);
+}
+
+/*
+ * by the time we are managed (and get this far) we had better
+ * have both a source and a sink
+ */
+
+static void
+Resize(w)
+Widget w;
+{
+ TextWidget ctx = (TextWidget) w;
+
+ PositionVScrollBar(ctx);
+ PositionHScrollBar(ctx);
+
+ _XawTextBuildLineTable(ctx, ctx->text.lt.top, TRUE);
+ _XawTextSetScrollBars(ctx);
+}
+
+/*
+ * This routine allow the application program to Set attributes.
+ */
+
+/*ARGSUSED*/
+static Boolean
+SetValues(current, request, new, args, num_args)
+Widget current, request, new;
+ArgList args;
+Cardinal *num_args;
+{
+ TextWidget oldtw = (TextWidget) current;
+ TextWidget newtw = (TextWidget) new;
+ Boolean redisplay = FALSE;
+ Boolean display_caret = newtw->text.display_caret;
+
+
+ newtw->text.display_caret = oldtw->text.display_caret;
+ _XawTextPrepareToUpdate(newtw);
+ newtw->text.display_caret = display_caret;
+
+ if (oldtw->text.r_margin.left != newtw->text.r_margin.left) {
+ newtw->text.margin.left = newtw->text.r_margin.left;
+ if (newtw->text.vbar != NULL)
+ newtw->text.margin.left += newtw->text.vbar->core.width +
+ newtw->text.vbar->core.border_width;
+ redisplay = TRUE;
+ }
+
+ if (oldtw->text.scroll_vert != newtw->text.scroll_vert) {
+ if (newtw->text.scroll_vert == XawtextScrollNever)
+ DestroyVScrollBar(newtw);
+ else if (newtw->text.scroll_vert == XawtextScrollAlways)
+ CreateVScrollBar(newtw);
+ redisplay = TRUE;
+ }
+
+ if (oldtw->text.r_margin.bottom != newtw->text.r_margin.bottom) {
+ newtw->text.margin.bottom = newtw->text.r_margin.bottom;
+ if (newtw->text.hbar != NULL)
+ newtw->text.margin.bottom += newtw->text.hbar->core.height +
+ newtw->text.hbar->core.border_width;
+ redisplay = TRUE;
+ }
+
+ if (oldtw->text.scroll_horiz != newtw->text.scroll_horiz) {
+ if (newtw->text.scroll_horiz == XawtextScrollNever)
+ DestroyHScrollBar(newtw);
+ else if (newtw->text.scroll_horiz == XawtextScrollAlways)
+ CreateHScrollBar(newtw);
+ redisplay = TRUE;
+ }
+
+ if ( oldtw->text.source != newtw->text.source )
+ XawTextSetSource( (Widget) newtw, newtw->text.source, newtw->text.lt.top);
+
+ newtw->text.redisplay_needed = False;
+ XtSetValues( (Widget)newtw->text.source, args, *num_args );
+ XtSetValues( (Widget)newtw->text.sink, args, *num_args );
+
+ if ( oldtw->text.wrap != newtw->text.wrap ||
+ oldtw->text.lt.top != newtw->text.lt.top ||
+ oldtw->text.r_margin.right != newtw->text.r_margin.right ||
+ oldtw->text.r_margin.top != newtw->text.r_margin.top ||
+ oldtw->text.sink != newtw->text.sink ||
+ newtw->text.redisplay_needed )
+ {
+ _XawTextBuildLineTable(newtw, newtw->text.lt.top, TRUE);
+ redisplay = TRUE;
+ }
+
+ if (oldtw->text.insertPos != newtw->text.insertPos) {
+ newtw->text.showposition = TRUE;
+ redisplay = TRUE;
+ }
+
+ _XawTextExecuteUpdate(newtw);
+ if (redisplay)
+ _XawTextSetScrollBars(newtw);
+
+ return redisplay;
+}
+
+/* invoked by the Simple widget's SetValues */
+static Boolean ChangeSensitive(w)
+ Widget w; /* the new widget */
+{
+ Arg args[1];
+ TextWidget tw = (TextWidget) w;
+
+ (*(&simpleClassRec)->simple_class.change_sensitive)(w);
+
+ XtSetArg(args[0], XtNancestorSensitive,
+ (tw->core.ancestor_sensitive && tw->core.sensitive));
+ if (tw->text.vbar)
+ XtSetValues(tw->text.vbar, args, ONE);
+ if (tw->text.hbar)
+ XtSetValues(tw->text.hbar, args, ONE);
+ return False;
+}
+
+/* Function Name: GetValuesHook
+ * Description: This is a get values hook routine that gets the
+ * values in the text source and sink.
+ * Arguments: w - the Text Widget.
+ * args - the argument list.
+ * num_args - the number of args.
+ * Returns: none.
+ */
+
+static void
+GetValuesHook(w, args, num_args)
+Widget w;
+ArgList args;
+Cardinal * num_args;
+{
+ XtGetValues( ((TextWidget) w)->text.source, args, *num_args );
+ XtGetValues( ((TextWidget) w)->text.sink, args, *num_args );
+}
+
+/* Function Name: FindGoodPosition
+ * Description: Returns a valid position given any postition
+ * Arguments: pos - any position.
+ * Returns: a position between (0 and lastPos);
+ */
+
+static XawTextPosition
+FindGoodPosition(ctx, pos)
+TextWidget ctx;
+XawTextPosition pos;
+{
+ if (pos < 0) return(0);
+ return ( ((pos > ctx->text.lastPos) ? ctx->text.lastPos : pos) );
+}
+
+/************************************************************
+ *
+ * Routines for handling the copy area expose queue.
+ *
+ ************************************************************/
+
+/* Function Name: PushCopyQueue
+ * Description: Pushes a value onto the copy queue.
+ * Arguments: ctx - the text widget.
+ * h, v - amount of offset in the horiz and vert directions.
+ * Returns: none
+ */
+
+static void
+PushCopyQueue(ctx, h, v)
+TextWidget ctx;
+int h, v;
+{
+ struct text_move * offsets = XtNew(struct text_move);
+
+ offsets->h = h;
+ offsets->v = v;
+ offsets->next = NULL;
+
+ if (ctx->text.copy_area_offsets == NULL)
+ ctx->text.copy_area_offsets = offsets;
+ else {
+ struct text_move * end = ctx->text.copy_area_offsets;
+ for ( ; end->next != NULL; end = end->next) {}
+ end->next = offsets;
+ }
+}
+
+/* Function Name: PopCopyQueue
+ * Description: Pops the top value off of the copy queue.
+ * Arguments: ctx - the text widget.
+ * Returns: none.
+ */
+
+static void
+PopCopyQueue(ctx)
+TextWidget ctx;
+{
+ struct text_move * offsets = ctx->text.copy_area_offsets;
+
+ if (offsets == NULL)
+ (void) printf( "Xaw Text widget %s: empty copy queue\n",
+ XtName( (Widget) ctx ) );
+ else {
+ ctx->text.copy_area_offsets = offsets->next;
+ XtFree((char *) offsets); /* free what you allocate. */
+ }
+}
+
+/* Function Name: TranslateExposeRegion
+ * Description: Translates the expose that came into
+ * the cordinates that now exist in the Text widget.
+ * Arguments: ctx - the text widget.
+ * expose - a Rectangle, who's region currently
+ * contains the expose event location.
+ * this region will be returned containing
+ * the new rectangle.
+ * Returns: True if there is drawing that needs to be done.
+ */
+
+static Boolean
+TranslateExposeRegion(ctx, expose)
+TextWidget ctx;
+XRectangle * expose;
+{
+ struct text_move * offsets = ctx->text.copy_area_offsets;
+ int value;
+ int x, y, width, height;
+
+ /*
+ * Skip over the first one, this has already been taken into account.
+ */
+
+ if (!offsets || !(offsets = offsets->next))
+ return(TRUE);
+
+ x = expose->x;
+ y = expose->y;
+ width = expose->width;
+ height = expose->height;
+
+ while (offsets) {
+ x += offsets->h;
+ y += offsets->v;
+ offsets = offsets->next;
+ }
+
+ /*
+ * remove that area of the region that is now outside the window.
+ */
+
+ if (y < 0) {
+ height += y;
+ y = 0;
+ }
+
+ value = y + height - ctx->core.height;
+ if (value > 0)
+ height -= value;
+
+ if (height <= 0)
+ return(FALSE); /* no need to draw outside the window. */
+
+ /*
+ * and now in the horiz direction...
+ */
+
+ if (x < 0) {
+ width += x;
+ x = 0;
+ }
+
+ value = x + width - ctx->core.width;
+ if (value > 0)
+ width -= value;
+
+ if (width <= 0)
+ return(FALSE); /* no need to draw outside the window. */
+
+ expose->x = x;
+ expose->y = y;
+ expose->width = width;
+ expose->height = height;
+ return(TRUE);
+}
+
+/* Li wrote this so the IM can find a given text position's screen position. */
+
+void
+#if NeedFunctionPrototypes
+_XawTextPosToXY(
+ Widget w,
+ XawTextPosition pos,
+ Position* x,
+ Position* y )
+#else
+_XawTextPosToXY( w, pos, x, y )
+ Widget w;
+ XawTextPosition pos;
+ Position *x, *y;
+#endif
+{
+ int line;
+ LineAndXYForPosition( (TextWidget)w, pos, &line, x, y );
+}
+
+/*******************************************************************
+The following routines provide procedural interfaces to Text window state
+setting and getting. They need to be redone so than the args code can use
+them. I suggest we create a complete set that takes the context as an
+argument and then have the public version lookup the context and call the
+internal one. The major value of this set is that they have actual application
+clients and therefore the functionality provided is required for any future
+version of Text.
+********************************************************************/
+
+void
+#if NeedFunctionPrototypes
+XawTextDisplay (Widget w)
+#else
+XawTextDisplay (w)
+Widget w;
+#endif
+{
+ if (!XtIsRealized(w)) return;
+
+ _XawTextPrepareToUpdate( (TextWidget) w);
+ DisplayTextWindow(w);
+ _XawTextExecuteUpdate( (TextWidget) w);
+}
+
+void
+#if NeedFunctionPrototypes
+XawTextSetSelectionArray(Widget w, XawTextSelectType *sarray)
+#else
+XawTextSetSelectionArray(w, sarray)
+Widget w;
+XawTextSelectType *sarray;
+#endif
+{
+ ((TextWidget)w)->text.sarray = sarray;
+}
+
+void
+#if NeedFunctionPrototypes
+XawTextGetSelectionPos(Widget w, XawTextPosition *left, XawTextPosition *right)
+#else
+XawTextGetSelectionPos(w, left, right)
+Widget w;
+XawTextPosition* left,* right;
+#endif
+{
+ *left = ((TextWidget) w)->text.s.left;
+ *right = ((TextWidget) w)->text.s.right;
+}
+
+
+void
+#if NeedFunctionPrototypes
+XawTextSetSource(Widget w, Widget source, XawTextPosition startPos)
+#else
+XawTextSetSource(w, source, startPos)
+Widget w, source;
+XawTextPosition startPos;
+#endif
+{
+ TextWidget ctx = (TextWidget) w;
+
+ ctx->text.source = source;
+ ctx->text.lt.top = startPos;
+ ctx->text.s.left = ctx->text.s.right = 0;
+ ctx->text.insertPos = startPos;
+ ctx->text.lastPos = GETLASTPOS;
+
+ _XawTextBuildLineTable(ctx, ctx->text.lt.top, TRUE);
+ XawTextDisplay(w);
+}
+
+/*
+ * This public routine deletes the text from startPos to endPos in a source and
+ * then inserts, at startPos, the text that was passed. As a side effect it
+ * "invalidates" that portion of the displayed text (if any), so that things
+ * will be repainted properly.
+ */
+
+int
+#if NeedFunctionPrototypes
+XawTextReplace(Widget w, XawTextPosition startPos, XawTextPosition endPos,
+ XawTextBlock *text)
+#else
+XawTextReplace(w, startPos, endPos, text)
+Widget w;
+XawTextPosition startPos, endPos;
+XawTextBlock *text;
+#endif
+{
+ TextWidget ctx = (TextWidget) w;
+ int result;
+
+ _XawTextPrepareToUpdate(ctx);
+ endPos = FindGoodPosition(ctx, endPos);
+ startPos = FindGoodPosition(ctx, startPos);
+ if ((result = _XawTextReplace(ctx, startPos, endPos, text)) == XawEditDone) {
+ int delta = text->length - (endPos - startPos);
+ if (ctx->text.insertPos >= (endPos + delta)) {
+ XawTextScanDirection sd = (delta < 0) ? XawsdLeft : XawsdRight;
+ ctx->text.insertPos = SrcScan(ctx->text.source, ctx->text.insertPos,
+ XawstPositions, sd, abs(delta), TRUE);
+ }
+ }
+
+ _XawTextCheckResize(ctx);
+ _XawTextExecuteUpdate(ctx);
+ _XawTextSetScrollBars(ctx);
+
+ return result;
+}
+
+XawTextPosition
+#if NeedFunctionPrototypes
+XawTextTopPosition(Widget w)
+#else
+XawTextTopPosition(w)
+Widget w;
+#endif
+{
+ return( ((TextWidget) w)->text.lt.top );
+}
+
+void
+#if NeedFunctionPrototypes
+XawTextSetInsertionPoint(Widget w, XawTextPosition position)
+#else
+XawTextSetInsertionPoint(w, position)
+Widget w;
+XawTextPosition position;
+#endif
+{
+ TextWidget ctx = (TextWidget) w;
+
+ _XawTextPrepareToUpdate(ctx);
+ ctx->text.insertPos = FindGoodPosition(ctx, position);
+ ctx->text.showposition = TRUE;
+
+ _XawTextExecuteUpdate(ctx);
+}
+
+XawTextPosition
+#if NeedFunctionPrototypes
+XawTextGetInsertionPoint(Widget w)
+#else
+XawTextGetInsertionPoint(w)
+Widget w;
+#endif
+{
+ return( ((TextWidget) w)->text.insertPos);
+}
+
+/*
+ * NOTE: Must walk the selection list in opposite order from LoseSelection.
+ */
+
+void
+#if NeedFunctionPrototypes
+XawTextUnsetSelection(Widget w)
+#else
+XawTextUnsetSelection(w)
+Widget w;
+#endif
+{
+ TextWidget ctx = (TextWidget)w;
+
+ while (ctx->text.s.atom_count != 0) {
+ Atom sel = ctx->text.s.selections[ctx->text.s.atom_count - 1];
+ if ( sel != (Atom) 0 ) {
+/*
+ * As selections are lost the atom_count will decrement.
+ */
+ if (GetCutBufferNumber(sel) == NOT_A_CUT_BUFFER)
+ XtDisownSelection(w, sel, ctx->text.time);
+ LoseSelection(w, &sel); /* In case this is a cut buffer, or
+ XtDisownSelection failed to call us. */
+ }
+ }
+}
+
+void
+#if NeedFunctionPrototypes
+XawTextSetSelection (Widget w, XawTextPosition left, XawTextPosition right)
+#else
+XawTextSetSelection (w, left, right)
+Widget w;
+XawTextPosition left, right;
+#endif
+{
+ TextWidget ctx = (TextWidget) w;
+
+ _XawTextPrepareToUpdate(ctx);
+ _XawTextSetSelection(ctx, FindGoodPosition(ctx, left),
+ FindGoodPosition(ctx, right), (String*)NULL, ZERO);
+ _XawTextExecuteUpdate(ctx);
+}
+
+void
+#if NeedFunctionPrototypes
+XawTextInvalidate(Widget w, XawTextPosition from, XawTextPosition to)
+#else
+XawTextInvalidate(w, from, to)
+Widget w;
+XawTextPosition from,to;
+#endif
+{
+ TextWidget ctx = (TextWidget) w;
+
+ from = FindGoodPosition(ctx, from);
+ to = FindGoodPosition(ctx, to);
+ ctx->text.lastPos = GETLASTPOS;
+ _XawTextPrepareToUpdate(ctx);
+ _XawTextNeedsUpdating(ctx, from, to);
+ _XawTextBuildLineTable(ctx, ctx->text.lt.top, TRUE);
+ _XawTextExecuteUpdate(ctx);
+}
+
+/*ARGSUSED*/
+void
+#if NeedFunctionPrototypes
+XawTextDisableRedisplay(Widget w)
+#else
+XawTextDisableRedisplay(w)
+Widget w;
+#endif
+{
+ ((TextWidget) w)->text.update_disabled = True;
+ _XawTextPrepareToUpdate( (TextWidget) w);
+}
+
+void
+#if NeedFunctionPrototypes
+XawTextEnableRedisplay(Widget w)
+#else
+XawTextEnableRedisplay(w)
+Widget w;
+#endif
+{
+ TextWidget ctx = (TextWidget)w;
+ XawTextPosition lastPos;
+
+ if (!ctx->text.update_disabled) return;
+
+ ctx->text.update_disabled = False;
+ lastPos = ctx->text.lastPos = GETLASTPOS;
+ ctx->text.lt.top = FindGoodPosition(ctx, ctx->text.lt.top);
+ ctx->text.insertPos = FindGoodPosition(ctx, ctx->text.insertPos);
+ if ( (ctx->text.s.left > lastPos) || (ctx->text.s.right > lastPos) )
+ ctx->text.s.left = ctx->text.s.right = 0;
+
+ _XawTextBuildLineTable(ctx, ctx->text.lt.top, TRUE);
+ if (XtIsRealized(w))
+ DisplayTextWindow(w);
+ _XawTextExecuteUpdate(ctx);
+}
+
+Widget
+#if NeedFunctionPrototypes
+XawTextGetSource(Widget w)
+#else
+XawTextGetSource(w)
+Widget w;
+#endif
+{
+ return ((TextWidget)w)->text.source;
+}
+
+void
+#if NeedFunctionPrototypes
+XawTextDisplayCaret (Widget w,
+#if NeedWidePrototypes
+ /* Boolean */ int display_caret)
+#else
+ Boolean display_caret)
+#endif
+#else
+XawTextDisplayCaret (w, display_caret)
+Widget w;
+Boolean display_caret;
+#endif
+{
+ TextWidget ctx = (TextWidget) w;
+
+ if (ctx->text.display_caret == display_caret) return;
+
+ if (XtIsRealized(w)) {
+ _XawTextPrepareToUpdate(ctx);
+ ctx->text.display_caret = display_caret;
+ _XawTextExecuteUpdate(ctx);
+ }
+ else
+ ctx->text.display_caret = display_caret;
+}
+
+/* Function Name: XawTextSearch(w, dir, text).
+ * Description: searches for the given text block.
+ * Arguments: w - The text widget.
+ * dir - The direction to search.
+ * text - The text block containing info about the string
+ * to search for.
+ * Returns: The position of the text found, or XawTextSearchError on
+ * an error.
+ */
+
+XawTextPosition
+#if NeedFunctionPrototypes
+XawTextSearch(Widget w,
+#if NeedWidePrototypes
+ /* XawTextScanDirection */ int dir,
+#else
+ XawTextScanDirection dir,
+#endif
+ XawTextBlock *text)
+#else
+XawTextSearch(w, dir, text)
+Widget w;
+XawTextScanDirection dir;
+XawTextBlock * text;
+#endif
+{
+ TextWidget ctx = (TextWidget) w;
+
+ return(SrcSearch(ctx->text.source, ctx->text.insertPos, dir, text));
+}
+
+TextClassRec textClassRec = {
+ { /* core fields */
+ /* superclass */ (WidgetClass) &simpleClassRec,
+ /* class_name */ "Text",
+ /* widget_size */ sizeof(TextRec),
+ /* class_initialize */ ClassInitialize,
+ /* class_part_init */ NULL,
+ /* class_inited */ FALSE,
+ /* initialize */ Initialize,
+ /* initialize_hook */ NULL,
+ /* realize */ Realize,
+ /* actions */ _XawTextActionsTable,
+ /* num_actions */ 0, /* Set in ClassInitialize. */
+ /* resources */ resources,
+ /* num_ resource */ XtNumber(resources),
+ /* xrm_class */ NULLQUARK,
+ /* compress_motion */ TRUE,
+ /* compress_exposure*/ XtExposeGraphicsExpose | XtExposeNoExpose,
+ /* compress_enterleave*/ TRUE,
+ /* visible_interest */ FALSE,
+ /* destroy */ TextDestroy,
+ /* resize */ Resize,
+ /* expose */ ProcessExposeRegion,
+ /* set_values */ SetValues,
+ /* set_values_hook */ NULL,
+ /* set_values_almost*/ XtInheritSetValuesAlmost,
+ /* get_values_hook */ GetValuesHook,
+ /* accept_focus */ NULL,
+ /* version */ XtVersion,
+ /* callback_private */ NULL,
+ /* tm_table */ NULL, /* set in ClassInitialize */
+ /* query_geometry */ XtInheritQueryGeometry,
+ /* display_accelerator*/ XtInheritDisplayAccelerator,
+ /* extension */ NULL
+ },
+ { /* Simple fields */
+ /* change_sensitive */ ChangeSensitive
+ },
+ { /* text fields */
+ /* empty */ 0
+ }
+};
+
+WidgetClass textWidgetClass = (WidgetClass)&textClassRec;
diff --git a/src/TextAction.c b/src/TextAction.c
new file mode 100644
index 0000000..a6a8c17
--- /dev/null
+++ b/src/TextAction.c
@@ -0,0 +1,2259 @@
+/* $Xorg: TextAction.c,v 1.4 2001/02/09 02:03:46 xorgcvs Exp $ */
+
+/*
+
+Copyright 1989, 1994, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+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
+OPEN GROUP 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 Open Group 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 Open Group.
+
+*/
+#include <X11/IntrinsicP.h>
+#include <X11/StringDefs.h>
+#include <X11/Xutil.h>
+#include <X11/Xatom.h>
+#include <X11/Xmu/Misc.h>
+#include <X11/Xmu/StdSel.h> /* for XmuConvertStandardSelection */
+#include <X11/Xmu/Atoms.h> /* for XA_COMPOUND_TEXT */
+#include <X11/Xaw/TextP.h>
+#include <X11/Xaw/MultiSrcP.h>
+#include <X11/Xaw/XawImP.h>
+#include <X11/Xfuncs.h>
+#include "XawI18n.h"
+#include <stdio.h>
+#include <ctype.h>
+
+#define SrcScan XawTextSourceScan
+#define FindDist XawTextSinkFindDistance
+#define FindPos XawTextSinkFindPosition
+
+#define XawTextActionMaxHexChars 100
+
+/*
+ * These are defined in TextPop.c
+ */
+
+void _XawTextInsertFileAction(), _XawTextInsertFile(), _XawTextSearch();
+void _XawTextSearch(), _XawTextDoSearchAction(), _XawTextDoReplaceAction();
+void _XawTextSetField(), _XawTextPopdownSearchAction();
+
+/*
+ * These are defined in Text.c
+ */
+
+char * _XawTextGetText();
+void _XawTextAlterSelection(), _XawTextVScroll();
+void _XawTextSetSelection(), _XawTextCheckResize(), _XawTextExecuteUpdate();
+void _XawTextSetScrollBars(), _XawTextClearAndCenterDisplay();
+Atom * _XawTextSelectionList();
+void _XawTextPrepareToUpdate();
+int _XawTextReplace();
+
+static void ParameterError(w, param)
+ Widget w;
+ String param;
+{
+ String params[2];
+ Cardinal num_params = 2;
+ params[0] = XtName(w);
+ params[1] = param;
+
+ XtAppWarningMsg( XtWidgetToApplicationContext(w),
+ "parameterError", "textAction", "XawError",
+ "Widget: %s Parameter: %s",
+ params, &num_params);
+ XBell( XtDisplay( w ), 50 );
+}
+
+static void
+StartAction(ctx, event)
+TextWidget ctx;
+XEvent *event;
+{
+ _XawTextPrepareToUpdate(ctx);
+ if (event != NULL) {
+ switch (event->type) {
+ case ButtonPress:
+ case ButtonRelease:
+ ctx->text.time = event->xbutton.time;
+ break;
+ case KeyPress:
+ case KeyRelease:
+ ctx->text.time = event->xkey.time;
+ break;
+ case MotionNotify:
+ ctx->text.time = event->xmotion.time;
+ break;
+ case EnterNotify:
+ case LeaveNotify:
+ ctx->text.time = event->xcrossing.time;
+ }
+ }
+}
+
+static void
+NotePosition(ctx, event)
+TextWidget ctx;
+XEvent* event;
+{
+ switch (event->type) {
+ case ButtonPress:
+ case ButtonRelease:
+ ctx->text.ev_x = event->xbutton.x;
+ ctx->text.ev_y = event->xbutton.y;
+ break;
+ case KeyPress:
+ case KeyRelease:
+ {
+ XRectangle cursor;
+ XawTextSinkGetCursorBounds(ctx->text.sink, &cursor);
+ ctx->text.ev_x = cursor.x + cursor.width / 2;;
+ ctx->text.ev_y = cursor.y + cursor.height / 2;;
+ }
+ break;
+ case MotionNotify:
+ ctx->text.ev_x = event->xmotion.x;
+ ctx->text.ev_y = event->xmotion.y;
+ break;
+ case EnterNotify:
+ case LeaveNotify:
+ ctx->text.ev_x = event->xcrossing.x;
+ ctx->text.ev_y = event->xcrossing.y;
+ }
+}
+
+static void
+EndAction(ctx)
+TextWidget ctx;
+{
+ _XawTextCheckResize(ctx);
+ _XawTextExecuteUpdate(ctx);
+ ctx->text.mult = 1;
+}
+
+
+struct _SelectionList {
+ String* params;
+ Cardinal count;
+ Time time;
+ Boolean CT_asked; /* flag if asked XA_COMPOUND_TEXT */
+ Atom selection; /* selection atom when asking XA_COMPOUND_TEXT */
+};
+
+static int ProbablyMB(s)
+ char* s;
+{
+ int escapes = 0;
+ int has_hi_bit = False;
+
+ /* if it has more than one ESC char, I assume it is COMPOUND_TEXT.
+ If it has at least one hi bit set character, I pretend it is multibyte. */
+
+ while ( (*s) != (wchar_t)0 ) {
+ if ( *s & 128 )
+ has_hi_bit = True;
+ if ( *s++ == '\033' )
+ escapes++;
+ if ( escapes >= 2 )
+ return( 0 );
+ }
+ return( has_hi_bit );
+}
+static void GetSelection();
+
+/* ARGSUSED */
+static void
+_SelectionReceived(w, client_data, selection, type, value, length, format)
+Widget w;
+XtPointer client_data;
+Atom *selection, *type;
+XtPointer value;
+unsigned long *length;
+int* format;
+{
+ TextWidget ctx = (TextWidget)w;
+ XawTextBlock text;
+
+ if (*type == 0 /*XT_CONVERT_FAIL*/ || *length == 0) {
+ struct _SelectionList* list = (struct _SelectionList*)client_data;
+ if (list != NULL) {
+ if (list->CT_asked) {
+
+ /* If we just asked for a XA_COMPOUND_TEXT and got a null
+ response, we'll ask again, this time for an XA_STRING. */
+
+ list->CT_asked = False;
+ XtGetSelectionValue(w, list->selection, XA_STRING, _SelectionReceived,
+ (XtPointer)list, list->time);
+ } else {
+ GetSelection(w, list->time, list->params, list->count);
+ XtFree(client_data);
+ }
+ }
+ return;
+ }
+
+ /* Many programs, especially old terminal emulators, give us multibyte text
+but tell us it is COMPOUND_TEXT :( The following routine checks to see if the
+string is a legal multibyte string in our locale using a spooky heuristic :O
+and if it is we can only assume the sending client is using the same locale as
+we are, and convert it. I also warn the user that the other client is evil. */
+
+ StartAction( ctx, (XEvent*) NULL );
+ if (_XawTextFormat(ctx) == XawFmtWide) {
+ XTextProperty textprop;
+ Display *d = XtDisplay((Widget)ctx);
+ wchar_t **wlist;
+ int count;
+ int try_CT = 1;
+
+ /* IS THE SELECTION IN MULTIBYTE FORMAT? */
+
+ if ( ProbablyMB( (char *) value ) ) {
+ char * list[1];
+ list[0] = (char *) value;
+ if ( XmbTextListToTextProperty( d, (char**) list, 1,
+ XCompoundTextStyle, &textprop ) == Success )
+ try_CT = 0;
+ }
+
+ /* OR IN COMPOUND TEXT FORMAT? */
+
+ if ( try_CT ) {
+ textprop.encoding = XA_COMPOUND_TEXT(d);
+ textprop.value = (unsigned char *)value;
+ textprop.nitems = strlen(value);
+ textprop.format = 8;
+ }
+
+ if ( XwcTextPropertyToTextList( d, &textprop, (wchar_t***) &wlist, &count )
+ != Success) {
+ XwcFreeStringList( (wchar_t**) wlist );
+
+ /* Notify the user on strerr and in the insertion :) */
+ textprop.value = (unsigned char *) " >> ILLEGAL SELECTION << ";
+ count = 1;
+ fprintf( stderr, "Xaw Text Widget: An attempt was made to insert an illegal selection.\n" );
+
+ if ( XwcTextPropertyToTextList( d, &textprop, (wchar_t***) &wlist, &count )
+ != Success) return;
+ }
+
+ XFree(value);
+ value = (XPointer)wlist[0];
+
+ *length = wcslen(wlist[0]);
+ XtFree((XtPointer)wlist);
+ text.format = XawFmtWide;
+ } else
+ text.format = XawFmt8Bit;
+ text.ptr = (char*)value;
+ text.firstPos = 0;
+ text.length = *length;
+ if (_XawTextReplace(ctx, ctx->text.insertPos, ctx->text.insertPos, &text)) {
+ XBell(XtDisplay(ctx), 0);
+ return;
+ }
+ ctx->text.insertPos = SrcScan(ctx->text.source, ctx->text.insertPos,
+ XawstPositions, XawsdRight, text.length, TRUE);
+
+ _XawTextSetScrollBars(ctx);
+ EndAction(ctx);
+ XtFree(client_data);
+ XFree(value); /* the selection value should be freed with XFree */
+}
+
+static void
+GetSelection(w, time, params, num_params)
+Widget w;
+Time time;
+String* params; /* selections in precedence order */
+Cardinal num_params;
+{
+ Atom selection;
+ int buffer;
+
+ selection = XInternAtom(XtDisplay(w), *params, False);
+ switch (selection) {
+ case XA_CUT_BUFFER0: buffer = 0; break;
+ case XA_CUT_BUFFER1: buffer = 1; break;
+ case XA_CUT_BUFFER2: buffer = 2; break;
+ case XA_CUT_BUFFER3: buffer = 3; break;
+ case XA_CUT_BUFFER4: buffer = 4; break;
+ case XA_CUT_BUFFER5: buffer = 5; break;
+ case XA_CUT_BUFFER6: buffer = 6; break;
+ case XA_CUT_BUFFER7: buffer = 7; break;
+ default: buffer = -1;
+ }
+ if (buffer >= 0) {
+ int nbytes;
+ unsigned long length;
+ int fmt8 = 8;
+ Atom type = XA_STRING;
+ char *line = XFetchBuffer(XtDisplay(w), &nbytes, buffer);
+ if (length = nbytes)
+ _SelectionReceived(w, (XtPointer) NULL, &selection, &type, (XPointer)line,
+ &length, &fmt8);
+ else if (num_params > 1)
+ GetSelection(w, time, params+1, num_params-1);
+ } else {
+ struct _SelectionList* list;
+ if (--num_params) {
+ list = XtNew(struct _SelectionList);
+ list->params = params + 1;
+ list->count = num_params;
+ list->time = time;
+ list->CT_asked = True;
+ list->selection = selection;
+ } else list = NULL;
+ XtGetSelectionValue(w, selection, XA_COMPOUND_TEXT(XtDisplay(w)),
+ _SelectionReceived, (XtPointer)list, time);
+ }
+}
+
+static void
+InsertSelection(w, event, params, num_params)
+Widget w;
+XEvent* event;
+String* params; /* precedence list of selections to try */
+Cardinal* num_params;
+{
+ StartAction((TextWidget)w, event); /* Get Time. */
+ GetSelection(w, ((TextWidget)w)->text.time, params, *num_params);
+ EndAction((TextWidget)w);
+}
+
+/************************************************************
+ *
+ * Routines for Moving Around.
+ *
+ ************************************************************/
+
+static void
+Move(ctx, event, dir, type, include)
+TextWidget ctx;
+XEvent* event;
+XawTextScanDirection dir;
+XawTextScanType type;
+Boolean include;
+{
+ StartAction(ctx, event);
+ ctx->text.insertPos = SrcScan(ctx->text.source, ctx->text.insertPos,
+ type, dir, ctx->text.mult, include);
+ EndAction(ctx);
+}
+
+/*ARGSUSED*/
+static void
+MoveForwardChar(w, event, p, n)
+Widget w;
+XEvent* event;
+String* p;
+Cardinal* n;
+{
+ Move((TextWidget) w, event, XawsdRight, XawstPositions, TRUE);
+}
+
+/*ARGSUSED*/
+static void
+MoveBackwardChar(w, event, p, n)
+Widget w;
+XEvent* event;
+String* p;
+Cardinal* n;
+{
+ Move((TextWidget) w, event, XawsdLeft, XawstPositions, TRUE);
+}
+
+/*ARGSUSED*/
+static void
+MoveForwardWord(w, event, p, n)
+Widget w;
+XEvent* event;
+String* p;
+Cardinal* n;
+{
+ Move((TextWidget) w, event, XawsdRight, XawstWhiteSpace, FALSE);
+}
+
+/*ARGSUSED*/
+static void
+MoveBackwardWord(w, event, p, n)
+Widget w;
+XEvent* event;
+String* p;
+Cardinal* n;
+{
+ Move((TextWidget) w, event, XawsdLeft, XawstWhiteSpace, FALSE);
+}
+
+/*ARGSUSED*/
+static void MoveForwardParagraph(w, event, p, n)
+Widget w;
+XEvent* event;
+String* p;
+Cardinal* n;
+{
+ Move((TextWidget) w, event, XawsdRight, XawstParagraph, FALSE);
+}
+
+/*ARGSUSED*/
+static void MoveBackwardParagraph(w, event, p, n)
+Widget w;
+XEvent* event;
+String* p;
+Cardinal* n;
+{
+ Move((TextWidget) w, event, XawsdLeft, XawstParagraph, FALSE);
+}
+
+/*ARGSUSED*/
+static void
+MoveToLineEnd(w, event, p, n)
+Widget w;
+XEvent* event;
+String* p;
+Cardinal* n;
+{
+ Move((TextWidget) w, event, XawsdRight, XawstEOL, FALSE);
+}
+
+/*ARGSUSED*/
+static void
+MoveToLineStart(w, event, p, n)
+Widget w;
+XEvent* event;
+String* p;
+Cardinal* n;
+{
+ Move((TextWidget) w, event, XawsdLeft, XawstEOL, FALSE);
+}
+
+
+static void
+MoveLine(ctx, event, dir)
+TextWidget ctx;
+XEvent* event;
+XawTextScanDirection dir;
+{
+ XawTextPosition new, next_line, junk;
+ int from_left, garbage;
+
+ StartAction(ctx, event);
+
+ if (dir == XawsdLeft)
+ ctx->text.mult++;
+
+ new = SrcScan(ctx->text.source, ctx->text.insertPos,
+ XawstEOL, XawsdLeft, 1, FALSE);
+
+ FindDist(ctx->text.sink, new, ctx->text.margin.left, ctx->text.insertPos,
+ &from_left, &junk, &garbage);
+
+ new = SrcScan(ctx->text.source, ctx->text.insertPos, XawstEOL, dir,
+ ctx->text.mult, (dir == XawsdRight));
+
+ next_line = SrcScan(ctx->text.source, new, XawstEOL, XawsdRight, 1, FALSE);
+
+ FindPos(ctx->text.sink, new, ctx->text.margin.left, from_left, FALSE,
+ &(ctx->text.insertPos), &garbage, &garbage);
+
+ if (ctx->text.insertPos > next_line)
+ ctx->text.insertPos = next_line;
+
+ EndAction(ctx);
+}
+
+/*ARGSUSED*/
+static void
+MoveNextLine(w, event, p, n)
+Widget w;
+XEvent* event;
+String* p;
+Cardinal* n;
+{
+ MoveLine( (TextWidget) w, event, XawsdRight);
+}
+
+/*ARGSUSED*/
+static void
+MovePreviousLine(w, event, p, n)
+Widget w;
+XEvent* event;
+String* p;
+Cardinal* n;
+{
+ MoveLine( (TextWidget) w, event, XawsdLeft);
+}
+
+/*ARGSUSED*/
+static void
+MoveBeginningOfFile(w, event, p, n)
+Widget w;
+XEvent* event;
+String* p;
+Cardinal* n;
+{
+ Move((TextWidget) w, event, XawsdLeft, XawstAll, TRUE);
+}
+
+/*ARGSUSED*/
+static void
+MoveEndOfFile(w, event, p, n)
+Widget w;
+XEvent* event;
+String* p;
+Cardinal* n;
+{
+ Move((TextWidget) w, event, XawsdRight, XawstAll, TRUE);
+}
+
+static void
+Scroll(ctx, event, dir)
+TextWidget ctx;
+XEvent* event;
+XawTextScanDirection dir;
+{
+ StartAction(ctx, event);
+
+ if (dir == XawsdLeft)
+ _XawTextVScroll(ctx, ctx->text.mult);
+ else
+ _XawTextVScroll(ctx, -ctx->text.mult);
+
+ EndAction(ctx);
+}
+
+/*ARGSUSED*/
+static void
+ScrollOneLineUp(w, event, p, n)
+Widget w;
+XEvent* event;
+String* p;
+Cardinal* n;
+{
+ Scroll( (TextWidget) w, event, XawsdLeft);
+}
+
+/*ARGSUSED*/
+static void
+ScrollOneLineDown(w, event, p, n)
+Widget w;
+XEvent* event;
+String* p;
+Cardinal* n;
+{
+ Scroll( (TextWidget) w, event, XawsdRight);
+}
+
+static void
+MovePage(ctx, event, dir)
+TextWidget ctx;
+XEvent* event;
+XawTextScanDirection dir;
+{
+ int scroll_val = Max(1, ctx->text.lt.lines - 2);
+
+ if (dir == XawsdLeft)
+ scroll_val = -scroll_val;
+
+ StartAction(ctx, event);
+ _XawTextVScroll(ctx, scroll_val);
+ ctx->text.insertPos = ctx->text.lt.top;
+ EndAction(ctx);
+}
+
+/*ARGSUSED*/
+static void
+MoveNextPage(w, event, p, n)
+Widget w;
+XEvent* event;
+String* p;
+Cardinal* n;
+{
+ MovePage((TextWidget) w, event, XawsdRight);
+}
+
+/*ARGSUSED*/
+static void
+MovePreviousPage(w, event, p, n)
+Widget w;
+XEvent* event;
+String* p;
+Cardinal* n;
+{
+ MovePage((TextWidget) w, event, XawsdLeft);
+}
+
+/************************************************************
+ *
+ * Delete Routines.
+ *
+ ************************************************************/
+
+static Boolean
+MatchSelection(selection, s)
+ Atom selection;
+ XawTextSelection* s;
+{
+ Atom *match;
+ int count;
+
+ for (count = 0, match = s->selections; count < s->atom_count; match++, count++)
+ if (*match == selection)
+ return True;
+ return False;
+}
+
+#define SrcCvtSel XawTextSourceConvertSelection
+
+static Boolean
+ConvertSelection(w, selection, target, type, value, length, format)
+ Widget w;
+ Atom *selection, *target, *type;
+ XtPointer* value;
+ unsigned long* length;
+ int* format;
+{
+ Display* d = XtDisplay(w);
+ TextWidget ctx = (TextWidget)w;
+ Widget src = ctx->text.source;
+ XawTextEditType edit_mode;
+ Arg args[1];
+ XawTextSelectionSalt *salt = NULL;
+ XawTextSelection *s;
+
+ if (*target == XA_TARGETS(d)) {
+ Atom* targetP, * std_targets;
+ unsigned long std_length;
+
+ if ( SrcCvtSel(src, selection, target, type, value, length, format) )
+ return True;
+
+ XmuConvertStandardSelection(w, ctx->text.time, selection,
+ target, type, (XPointer*)&std_targets,
+ &std_length, format);
+
+ *value = XtMalloc((unsigned) sizeof(Atom)*(std_length + 7));
+ targetP = *(Atom**)value;
+
+ *length = std_length + 6;
+ *targetP++ = XA_STRING;
+ *targetP++ = XA_TEXT(d);
+ *targetP++ = XA_COMPOUND_TEXT(d);
+ *targetP++ = XA_LENGTH(d);
+ *targetP++ = XA_LIST_LENGTH(d);
+ *targetP++ = XA_CHARACTER_POSITION(d);
+
+ XtSetArg(args[0], XtNeditType,&edit_mode);
+ XtGetValues(src, args, 1);
+
+ if (edit_mode == XawtextEdit) {
+ *targetP++ = XA_DELETE(d);
+ (*length)++;
+ }
+ memcpy((char*)targetP, (char*)std_targets, sizeof(Atom)*std_length);
+ XtFree((char*)std_targets);
+ *type = XA_ATOM;
+ *format = 32;
+ return True;
+ }
+
+ if ( SrcCvtSel(src, selection, target, type, value, length, format) )
+ return True;
+
+ for (salt = ctx->text.salt2; salt; salt = salt->next)
+ if (MatchSelection (*selection, &salt->s))
+ break;
+ if (!salt)
+ return False;
+ s = &salt->s;
+ if (*target == XA_STRING ||
+ *target == XA_TEXT(d) ||
+ *target == XA_COMPOUND_TEXT(d)) {
+ if (*target == XA_TEXT(d)) {
+ if (_XawTextFormat(ctx) == XawFmtWide)
+ *type = XA_COMPOUND_TEXT(d);
+ else
+ *type = XA_STRING;
+ } else {
+ *type = *target;
+ }
+ /*
+ * If salt is True, the salt->contents stores CT string,
+ * its length is measured in bytes.
+ * Refer to _XawTextSaltAwaySelection().
+ *
+ * by Li Yuhong, Mar. 20, 1991.
+ */
+ if (!salt) {
+ *value = (char *)_XawTextGetSTRING(ctx, s->left, s->right);
+ if (_XawTextFormat(ctx) == XawFmtWide) {
+ XTextProperty textprop;
+ if (XwcTextListToTextProperty(d, (wchar_t**)value, 1,
+ XCompoundTextStyle, &textprop)
+ < Success) {
+ XtFree(*value);
+ return False;
+ }
+ XtFree(*value);
+ *value = (XtPointer)textprop.value;
+ *length = textprop.nitems;
+ } else {
+ *length = strlen(*value);
+ }
+ } else {
+ *value = XtMalloc((salt->length + 1) * sizeof(unsigned char));
+ strcpy (*value, salt->contents);
+ *length = salt->length;
+ }
+ if (_XawTextFormat(ctx) == XawFmtWide && *type == XA_STRING) {
+ XTextProperty textprop;
+ wchar_t** wlist;
+ int count;
+ textprop.encoding = XA_COMPOUND_TEXT(d);
+ textprop.value = (unsigned char *)*value;
+ textprop.nitems = strlen(*value);
+ textprop.format = 8;
+ if (XwcTextPropertyToTextList(d, &textprop, (wchar_t***)&wlist, &count)
+ < Success) {
+ XtFree(*value);
+ return False;
+ }
+ XtFree(*value);
+ if (XwcTextListToTextProperty(d, (wchar_t**)wlist, 1,
+ XStringStyle, &textprop) < Success) {
+ XwcFreeStringList( (wchar_t**) wlist );
+ return False;
+ }
+ *value = (XtPointer)textprop.value;
+ *length = textprop.nitems;
+ XwcFreeStringList( (wchar_t**) wlist );
+ }
+ *format = 8;
+ return True;
+ }
+
+ if ( (*target == XA_LIST_LENGTH(d)) || (*target == XA_LENGTH(d)) ) {
+ long * temp;
+
+ temp = (long *) XtMalloc(sizeof(long));
+ if (*target == XA_LIST_LENGTH(d))
+ *temp = 1L;
+ else /* *target == XA_LENGTH(d) */
+ *temp = (long) (s->right - s->left);
+
+ *value = (XPointer) temp;
+ *type = XA_INTEGER;
+ *length = 1L;
+ *format = 32;
+ return True;
+ }
+
+ if (*target == XA_CHARACTER_POSITION(d)) {
+ long * temp;
+
+ temp = (long *) XtMalloc(2 * sizeof(long));
+ temp[0] = (long) (s->left + 1);
+ temp[1] = s->right;
+ *value = (XPointer) temp;
+ *type = XA_SPAN(d);
+ *length = 2L;
+ *format = 32;
+ return True;
+ }
+
+ if (*target == XA_DELETE(d)) {
+ void _XawTextZapSelection(); /* From TextAction.c */
+
+ if (!salt)
+ _XawTextZapSelection( ctx, (XEvent *) NULL, TRUE);
+ *value = NULL;
+ *type = XA_NULL(d);
+ *length = 0;
+ *format = 32;
+ return True;
+ }
+
+ if (XmuConvertStandardSelection(w, ctx->text.time, selection, target, type,
+ (XPointer *)value, length, format))
+ return True;
+
+ /* else */
+ return False;
+}
+
+static void
+LoseSelection(w, selection)
+ Widget w;
+ Atom* selection;
+{
+ TextWidget ctx = (TextWidget) w;
+ Atom* atomP;
+ int i;
+ XawTextSelectionSalt *salt, *prevSalt, *nextSalt;
+
+ prevSalt = 0;
+ for (salt = ctx->text.salt2; salt; salt = nextSalt)
+ {
+ atomP = salt->s.selections;
+ nextSalt = salt->next;
+ for (i = 0 ; i < salt->s.atom_count; i++, atomP++)
+ if (*selection == *atomP)
+ *atomP = (Atom)0;
+
+ while (salt->s.atom_count &&
+ salt->s.selections[salt->s.atom_count-1] == 0)
+ {
+ salt->s.atom_count--;
+ }
+
+ /*
+ * Must walk the selection list in opposite order from UnsetSelection.
+ */
+
+ atomP = salt->s.selections;
+ for (i = 0 ; i < salt->s.atom_count; i++, atomP++)
+ if (*atomP == (Atom)0)
+ {
+ *atomP = salt->s.selections[--salt->s.atom_count];
+ while (salt->s.atom_count &&
+ salt->s.selections[salt->s.atom_count-1] == 0)
+ salt->s.atom_count--;
+ }
+ if (salt->s.atom_count == 0)
+ {
+ XtFree ((char *) salt->s.selections);
+
+ /* WARNING: the next line frees memory not allocated in Xaw. */
+ /* Could be a serious bug. Someone look into it. */
+ XtFree (salt->contents);
+ if (prevSalt)
+ prevSalt->next = nextSalt;
+ else
+ ctx->text.salt2 = nextSalt;
+ XtFree ((char *) salt);
+ }
+ else
+ prevSalt = salt;
+ }
+}
+
+static void
+_DeleteOrKill(ctx, from, to, kill)
+TextWidget ctx;
+XawTextPosition from, to;
+Boolean kill;
+{
+ XawTextBlock text;
+
+ if (kill && from < to) {
+ XawTextSelectionSalt *salt;
+ Atom selection = XInternAtom(XtDisplay(ctx), "SECONDARY", False);
+
+ LoseSelection ((Widget) ctx, &selection);
+ salt = (XawTextSelectionSalt *) XtMalloc (sizeof (XawTextSelectionSalt));
+ if (!salt)
+ return;
+ salt->s.selections = (Atom *) XtMalloc (sizeof (Atom));
+ if (!salt->s.selections)
+ {
+ XtFree ((char *) salt);
+ return;
+ }
+ salt->s.left = from;
+ salt->s.right = to;
+ salt->contents = (char *)_XawTextGetSTRING(ctx, from, to);
+ if (_XawTextFormat(ctx) == XawFmtWide) {
+ XTextProperty textprop;
+ if (XwcTextListToTextProperty(XtDisplay((Widget)ctx),
+ (wchar_t**)(&(salt->contents)), 1, XCompoundTextStyle,
+ &textprop) < Success) {
+ XtFree(salt->contents);
+ salt->length = 0;
+ return;
+ }
+ XtFree(salt->contents);
+ salt->contents = (char *)textprop.value;
+ salt->length = textprop.nitems;
+ } else
+ salt->length = strlen (salt->contents);
+ salt->next = ctx->text.salt2;
+ ctx->text.salt2 = salt;
+ salt->s.selections[0] = selection;
+ XtOwnSelection ((Widget) ctx, selection, ctx->text.time,
+ ConvertSelection, LoseSelection, NULL);
+ salt->s.atom_count = 1;
+/*
+ XStoreBuffer(XtDisplay(ctx), ptr, strlen(ptr), 1);
+ XtFree(ptr);
+*/
+ }
+ text.length = 0;
+ text.firstPos = 0;
+
+ text.format = _XawTextFormat(ctx);
+ text.ptr = ""; /* These two lines needed to make legal TextBlock */
+
+ if (_XawTextReplace(ctx, from, to, &text)) {
+ XBell(XtDisplay(ctx), 50);
+ return;
+ }
+ ctx->text.insertPos = from;
+ ctx->text.showposition = TRUE;
+}
+
+static void
+DeleteOrKill(ctx, event, dir, type, include, kill)
+TextWidget ctx;
+XEvent* event;
+XawTextScanDirection dir;
+XawTextScanType type;
+Boolean include, kill;
+{
+ XawTextPosition from, to;
+
+ StartAction(ctx, event);
+ to = SrcScan(ctx->text.source, ctx->text.insertPos,
+ type, dir, ctx->text.mult, include);
+
+/*
+ * If no movement actually happened, then bump the count and try again.
+ * This causes the character position at the very beginning and end of
+ * a boundary to act correctly.
+ */
+
+ if (to == ctx->text.insertPos)
+ to = SrcScan(ctx->text.source, ctx->text.insertPos,
+ type, dir, ctx->text.mult + 1, include);
+
+ if (dir == XawsdLeft) {
+ from = to;
+ to = ctx->text.insertPos;
+ }
+ else
+ from = ctx->text.insertPos;
+
+ _DeleteOrKill(ctx, from, to, kill);
+ _XawTextSetScrollBars(ctx);
+ EndAction(ctx);
+}
+
+/*ARGSUSED*/
+static void
+DeleteForwardChar(w, event, p, n)
+Widget w;
+XEvent* event;
+String* p;
+Cardinal* n;
+{
+ DeleteOrKill((TextWidget) w, event, XawsdRight, XawstPositions, TRUE, FALSE);
+}
+
+/*ARGSUSED*/
+static void
+DeleteBackwardChar(w, event, p, n)
+Widget w;
+XEvent* event;
+String* p;
+Cardinal* n;
+{
+ DeleteOrKill((TextWidget) w, event, XawsdLeft, XawstPositions, TRUE, FALSE);
+}
+
+/*ARGSUSED*/
+static void
+DeleteForwardWord(w, event, p, n)
+Widget w;
+XEvent* event;
+String* p;
+Cardinal* n;
+{
+ DeleteOrKill((TextWidget) w, event,
+ XawsdRight, XawstWhiteSpace, FALSE, FALSE);
+}
+
+/*ARGSUSED*/
+static void
+DeleteBackwardWord(w, event, p, n)
+Widget w;
+XEvent* event;
+String* p;
+Cardinal* n;
+{
+ DeleteOrKill((TextWidget) w, event,
+ XawsdLeft, XawstWhiteSpace, FALSE, FALSE);
+}
+
+/*ARGSUSED*/
+static void
+KillForwardWord(w, event, p, n)
+Widget w;
+XEvent* event;
+String* p;
+Cardinal* n;
+{
+ DeleteOrKill((TextWidget) w, event,
+ XawsdRight, XawstWhiteSpace, FALSE, TRUE);
+}
+
+/*ARGSUSED*/
+static void
+KillBackwardWord(w, event, p, n)
+Widget w;
+XEvent* event;
+String* p;
+Cardinal* n;
+{
+ DeleteOrKill((TextWidget) w, event,
+ XawsdLeft, XawstWhiteSpace, FALSE, TRUE);
+}
+
+/*ARGSUSED*/
+static void
+KillToEndOfLine(w, event, p, n)
+Widget w;
+XEvent* event;
+String* p;
+Cardinal* n;
+{
+ TextWidget ctx = (TextWidget) w;
+ XawTextPosition end_of_line;
+
+ StartAction(ctx, event);
+ end_of_line = SrcScan(ctx->text.source, ctx->text.insertPos, XawstEOL,
+ XawsdRight, ctx->text.mult, FALSE);
+ if (end_of_line == ctx->text.insertPos)
+ end_of_line = SrcScan(ctx->text.source, ctx->text.insertPos, XawstEOL,
+ XawsdRight, ctx->text.mult, TRUE);
+
+ _DeleteOrKill(ctx, ctx->text.insertPos, end_of_line, TRUE);
+ _XawTextSetScrollBars(ctx);
+ EndAction(ctx);
+}
+
+/*ARGSUSED*/
+static void
+KillToEndOfParagraph(w, event, p, n)
+Widget w;
+XEvent* event;
+String* p;
+Cardinal* n;
+{
+ DeleteOrKill((TextWidget) w, event, XawsdRight, XawstParagraph, FALSE, TRUE);
+}
+
+void
+_XawTextZapSelection(ctx, event, kill)
+TextWidget ctx;
+XEvent* event;
+Boolean kill;
+{
+ StartAction(ctx, event);
+ _DeleteOrKill(ctx, ctx->text.s.left, ctx->text.s.right, kill);
+ _XawTextSetScrollBars(ctx);
+ EndAction(ctx);
+}
+
+/*ARGSUSED*/
+static void
+KillCurrentSelection(w, event, p, n)
+Widget w;
+XEvent* event;
+String* p;
+Cardinal* n;
+{
+ _XawTextZapSelection( (TextWidget) w, event, TRUE);
+}
+
+/*ARGSUSED*/
+static void
+DeleteCurrentSelection(w, event, p, n)
+Widget w;
+XEvent* event;
+String* p;
+Cardinal* n;
+{
+ _XawTextZapSelection( (TextWidget) w, event, FALSE);
+}
+
+/************************************************************
+ *
+ * Insertion Routines.
+ *
+ ************************************************************/
+
+static int
+InsertNewLineAndBackupInternal(ctx)
+TextWidget ctx;
+{
+ int count, error = XawEditDone;
+ XawTextBlock text;
+
+ text.format = _XawTextFormat(ctx);
+ text.length = ctx->text.mult;
+ text.firstPos = 0;
+
+ if ( text.format == XawFmtWide ) {
+ wchar_t* wptr;
+ text.ptr = XtMalloc(sizeof(wchar_t) * ctx->text.mult);
+ wptr = (wchar_t *)text.ptr;
+ for (count = 0; count < ctx->text.mult; count++ )
+ wptr[count] = _Xaw_atowc(XawLF);
+ }
+ else {
+ text.ptr = XtMalloc(sizeof(char) * ctx->text.mult);
+ for (count = 0; count < ctx->text.mult; count++ )
+ text.ptr[count] = XawLF;
+ }
+
+ if (_XawTextReplace(ctx, ctx->text.insertPos, ctx->text.insertPos, &text)) {
+ XBell( XtDisplay(ctx), 50);
+ error = XawEditError;
+ }
+ else
+ ctx->text.showposition = TRUE;
+
+ XtFree( text.ptr );
+ return( error );
+}
+
+/*ARGSUSED*/
+static void
+InsertNewLineAndBackup(w, event, p, n)
+Widget w;
+XEvent* event;
+String* p;
+Cardinal* n;
+{
+ StartAction( (TextWidget) w, event );
+ (void) InsertNewLineAndBackupInternal( (TextWidget) w );
+ _XawTextSetScrollBars( (TextWidget) w);
+ EndAction( (TextWidget) w );
+}
+
+static int
+LocalInsertNewLine(ctx, event)
+ TextWidget ctx;
+ XEvent* event;
+{
+ StartAction(ctx, event);
+ if (InsertNewLineAndBackupInternal(ctx) == XawEditError)
+ return(XawEditError);
+ ctx->text.insertPos = SrcScan(ctx->text.source, ctx->text.insertPos,
+ XawstPositions, XawsdRight, ctx->text.mult, TRUE);
+ _XawTextSetScrollBars(ctx);
+ EndAction(ctx);
+ return(XawEditDone);
+}
+
+/*ARGSUSED*/
+static void
+InsertNewLine(w, event, p, n)
+Widget w;
+XEvent* event;
+String* p;
+Cardinal* n;
+{
+ (void) LocalInsertNewLine( (TextWidget) w, event);
+}
+
+/*ARGSUSED*/
+static void
+InsertNewLineAndIndent(w, event, p, n)
+Widget w;
+XEvent *event;
+String *p;
+Cardinal *n;
+{
+ XawTextBlock text;
+ XawTextPosition pos1;
+ int length;
+ TextWidget ctx = (TextWidget) w;
+ String line_to_ip;
+
+ StartAction(ctx, event);
+ pos1 = SrcScan(ctx->text.source, ctx->text.insertPos,
+ XawstEOL, XawsdLeft, 1, FALSE);
+
+ line_to_ip = _XawTextGetText(ctx, pos1, ctx->text.insertPos);
+
+ text.format = _XawTextFormat(ctx);
+ text.firstPos = 0;
+
+ if ( text.format == XawFmtWide ) {
+ wchar_t* ptr;
+ text.ptr = XtMalloc( ( 2 + wcslen((wchar_t*)line_to_ip) ) * sizeof(wchar_t) );
+
+ ptr = (wchar_t*)text.ptr;
+ ptr[0] = _Xaw_atowc( XawLF );
+ wcscpy( (wchar_t*) ++ptr, (wchar_t*) line_to_ip );
+
+ length = wcslen((wchar_t*)text.ptr);
+ while ( length && ( iswspace(*ptr) || ( *ptr == _Xaw_atowc(XawTAB) ) ) )
+ ptr++, length--;
+ *ptr = (wchar_t)0;
+ text.length = wcslen((wchar_t*)text.ptr);
+
+ } else {
+ char *ptr;
+ length = strlen(line_to_ip);
+ text.ptr = XtMalloc( ( 2 + length ) * sizeof( char ) );
+ ptr = text.ptr;
+ ptr[0] = XawLF;
+ strcpy( ++ptr, line_to_ip );
+
+ length++;
+ while ( length && ( isspace(*ptr) || ( *ptr == XawTAB ) ) )
+ ptr++, length--;
+ *ptr = '\0';
+ text.length = strlen(text.ptr);
+ }
+ XtFree( line_to_ip );
+
+ if (_XawTextReplace(ctx,ctx->text.insertPos, ctx->text.insertPos, &text)) {
+ XBell(XtDisplay(ctx), 50);
+ XtFree(text.ptr);
+ EndAction(ctx);
+ return;
+ }
+ XtFree(text.ptr);
+ ctx->text.insertPos = SrcScan(ctx->text.source, ctx->text.insertPos,
+ XawstPositions, XawsdRight, text.length, TRUE);
+ _XawTextSetScrollBars(ctx);
+ EndAction(ctx);
+}
+
+/************************************************************
+ *
+ * Selection Routines.
+ *
+ *************************************************************/
+
+static void
+SelectWord(w, event, params, num_params)
+Widget w;
+XEvent* event;
+String* params;
+Cardinal* num_params;
+{
+ TextWidget ctx = (TextWidget) w;
+ XawTextPosition l, r;
+
+ StartAction(ctx, event);
+ l = SrcScan(ctx->text.source, ctx->text.insertPos,
+ XawstWhiteSpace, XawsdLeft, 1, FALSE);
+ r = SrcScan(ctx->text.source, l, XawstWhiteSpace, XawsdRight, 1, FALSE);
+ _XawTextSetSelection(ctx, l, r, params, *num_params);
+ EndAction(ctx);
+}
+
+static void
+SelectAll(w, event, params, num_params)
+Widget w;
+XEvent* event;
+String* params;
+Cardinal* num_params;
+{
+ TextWidget ctx = (TextWidget) w;
+
+ StartAction(ctx, event);
+ _XawTextSetSelection(ctx,zeroPosition,ctx->text.lastPos,params,*num_params);
+ EndAction(ctx);
+}
+
+static void
+ModifySelection(ctx, event, mode, action, params, num_params)
+TextWidget ctx;
+XEvent* event;
+XawTextSelectionMode mode;
+XawTextSelectionAction action;
+String* params; /* unused */
+Cardinal* num_params; /* unused */
+{
+ StartAction(ctx, event);
+ NotePosition(ctx, event);
+ _XawTextAlterSelection(ctx, mode, action, params, num_params);
+ EndAction(ctx);
+}
+
+/* ARGSUSED */
+static void
+SelectStart(w, event, params, num_params)
+Widget w;
+XEvent* event;
+String* params; /* unused */
+Cardinal* num_params; /* unused */
+{
+ ModifySelection((TextWidget) w, event,
+ XawsmTextSelect, XawactionStart, params, num_params);
+}
+
+/* ARGSUSED */
+static void
+SelectAdjust(w, event, params, num_params)
+Widget w;
+XEvent* event;
+String* params; /* unused */
+Cardinal* num_params; /* unused */
+{
+ ModifySelection((TextWidget) w, event,
+ XawsmTextSelect, XawactionAdjust, params, num_params);
+}
+
+static void
+SelectEnd(w, event, params, num_params)
+Widget w;
+XEvent* event;
+String* params;
+Cardinal* num_params;
+{
+ ModifySelection((TextWidget) w, event,
+ XawsmTextSelect, XawactionEnd, params, num_params);
+}
+
+/* ARGSUSED */
+static void
+ExtendStart(w, event, params, num_params)
+Widget w;
+XEvent* event;
+String* params; /* unused */
+Cardinal* num_params; /* unused */
+{
+ ModifySelection((TextWidget) w, event,
+ XawsmTextExtend, XawactionStart, params, num_params);
+}
+
+/* ARGSUSED */
+static void
+ExtendAdjust(w, event, params, num_params)
+Widget w;
+XEvent* event;
+String* params; /* unused */
+Cardinal* num_params; /* unused */
+{
+ ModifySelection((TextWidget) w, event,
+ XawsmTextExtend, XawactionAdjust, params, num_params);
+}
+
+static void
+ExtendEnd(w, event, params, num_params)
+Widget w;
+XEvent* event;
+String* params;
+Cardinal* num_params;
+{
+ ModifySelection((TextWidget) w, event,
+ XawsmTextExtend, XawactionEnd, params, num_params);
+}
+
+static void
+SelectSave(w, event, params, num_params)
+Widget w;
+XEvent* event;
+String* params;
+Cardinal* num_params;
+{
+ int num_atoms;
+ Atom* sel;
+ Display* dpy = XtDisplay(w);
+ Atom selections[256];
+
+ StartAction( (TextWidget) w, event );
+ num_atoms = *num_params;
+ if (num_atoms > 256)
+ num_atoms = 256;
+ for (sel=selections; --num_atoms >= 0; sel++, params++)
+ *sel = XInternAtom(dpy, *params, False);
+ num_atoms = *num_params;
+ _XawTextSaltAwaySelection( (TextWidget) w, selections, num_atoms );
+ EndAction( (TextWidget) w );
+}
+
+/************************************************************
+ *
+ * Misc. Routines.
+ *
+ ************************************************************/
+
+/* ARGSUSED */
+static void
+RedrawDisplay(w, event, p, n)
+Widget w;
+XEvent* event;
+String* p;
+Cardinal* n;
+{
+ StartAction( (TextWidget) w, event);
+ _XawTextClearAndCenterDisplay((TextWidget) w);
+ EndAction( (TextWidget) w);
+}
+
+/*ARGSUSED*/
+static void
+TextFocusIn (w, event, p, n)
+Widget w;
+XEvent* event;
+String* p;
+Cardinal* n;
+{
+ TextWidget ctx = (TextWidget) w;
+
+ /* Let the input method know focus has arrived. */
+ _XawImSetFocusValues (w, NULL, 0);
+ if ( event->xfocus.detail == NotifyPointer ) return;
+
+ ctx->text.hasfocus = TRUE;
+}
+
+/*ARGSUSED*/
+static void
+TextFocusOut(w, event, p, n)
+Widget w;
+XEvent* event;
+String* p;
+Cardinal* n;
+{
+ TextWidget ctx = (TextWidget) w;
+
+ /* Let the input method know focus has left.*/
+ _XawImUnsetFocus(w);
+ if ( event->xfocus.detail == NotifyPointer ) return;
+ ctx->text.hasfocus = FALSE;
+}
+
+/*ARGSUSED*/
+static void
+TextEnterWindow( w, event, params, num_params )
+ Widget w;
+ XEvent* event;
+ String* params;
+ Cardinal* num_params;
+{
+ TextWidget ctx = (TextWidget) w;
+
+ if ((event->xcrossing.detail != NotifyInferior) && event->xcrossing.focus &&
+ !ctx->text.hasfocus) {
+ _XawImSetFocusValues(w, NULL, 0);
+ }
+}
+
+/*ARGSUSED*/
+static void
+TextLeaveWindow( w, event, params, num_params )
+ Widget w;
+ XEvent* event;
+ String* params;
+ Cardinal* num_params;
+{
+ TextWidget ctx = (TextWidget) w;
+
+ if ((event->xcrossing.detail != NotifyInferior) && event->xcrossing.focus &&
+ !ctx->text.hasfocus) {
+ _XawImUnsetFocus(w);
+ }
+}
+
+static XComposeStatus compose_status = {NULL, 0};
+
+/* Function Name: AutoFill
+ * Description: Breaks the line at the previous word boundry when
+ * called inside InsertChar.
+ * Arguments: ctx - The text widget.
+ * Returns: none
+ */
+
+static void
+AutoFill(ctx)
+TextWidget ctx;
+{
+ int width, height, x, line_num, max_width;
+ XawTextPosition ret_pos;
+ XawTextBlock text;
+
+ if ( !((ctx->text.auto_fill) && (ctx->text.mult == 1)) )
+ return;
+
+ for ( line_num = 0; line_num < ctx->text.lt.lines ; line_num++)
+ if ( ctx->text.lt.info[line_num].position >= ctx->text.insertPos )
+ break;
+ line_num--; /* backup a line. */
+
+ max_width = Max(0, (int)(ctx->core.width - HMargins(ctx)));
+
+ x = ctx->text.margin.left;
+ XawTextSinkFindPosition( ctx->text.sink,ctx->text.lt.info[line_num].position,
+ x, max_width, TRUE, &ret_pos, &width, &height);
+
+ if ( ret_pos >= ctx->text.insertPos )
+ return;
+
+ text.format = XawFmt8Bit;
+ if (_XawTextFormat(ctx) == XawFmtWide) {
+ text.format = XawFmtWide;
+ text.ptr = (char *)XtMalloc(sizeof(wchar_t) * 2);
+ ((wchar_t*)text.ptr)[0] = _Xaw_atowc(XawLF);
+ ((wchar_t*)text.ptr)[1] = 0;
+ } else
+ text.ptr = "\n";
+ text.length = 1;
+ text.firstPos = 0;
+
+ if (_XawTextReplace(ctx, ret_pos - 1, ret_pos, &text))
+ XBell(XtDisplay((Widget) ctx), 0); /* Unable to edit, complain. */
+}
+
+/*ARGSUSED*/
+static void
+InsertChar(w, event, p, n)
+Widget w;
+XEvent* event;
+String* p;
+Cardinal* n;
+{
+ TextWidget ctx = (TextWidget) w;
+ char *ptr, strbuf[BUFSIZ];
+ int count, error;
+ KeySym keysym;
+ XawTextBlock text;
+
+ if (XtIsSubclass (ctx->text.source, (WidgetClass) multiSrcObjectClass))
+ text.length = _XawImWcLookupString (w, &event->xkey,
+ (wchar_t*) strbuf, BUFSIZ, &keysym, (Status*) &compose_status);
+ else
+ text.length = XLookupString ((XKeyEvent*)event, strbuf, BUFSIZ, &keysym, &compose_status);
+
+ if (text.length == 0)
+ return;
+
+ text.format = _XawTextFormat( ctx );
+ if ( text.format == XawFmtWide ) {
+ text.ptr = ptr = XtMalloc(sizeof(wchar_t) * text.length * ctx->text.mult );
+ for (count = 0; count < ctx->text.mult; count++ ) {
+ memcpy((char*) ptr, (char *)strbuf, sizeof(wchar_t) * text.length );
+ ptr += sizeof(wchar_t) * text.length;
+ }
+
+ } else { /* == XawFmt8Bit */
+ text.ptr = ptr = XtMalloc( sizeof(char) * text.length * ctx->text.mult );
+ for ( count = 0; count < ctx->text.mult; count++ ) {
+ strncpy( ptr, strbuf, text.length );
+ ptr += text.length;
+ }
+ }
+
+ text.length = text.length * ctx->text.mult;
+ text.firstPos = 0;
+
+ StartAction(ctx, event);
+
+ error = _XawTextReplace(ctx, ctx->text.insertPos,ctx->text.insertPos, &text);
+
+ if (error == XawEditDone) {
+ ctx->text.insertPos = SrcScan(ctx->text.source, ctx->text.insertPos,
+ XawstPositions, XawsdRight, text.length, TRUE);
+ AutoFill(ctx);
+ }
+ else
+ XBell(XtDisplay(ctx), 50);
+
+ XtFree(text.ptr);
+ _XawTextSetScrollBars(ctx);
+ EndAction(ctx);
+}
+
+
+/* IfHexConvertHexElseReturnParam() - called by InsertString
+ *
+ * i18n requires the ability to specify multiple characters in a hexa-
+ * decimal string at once. Since Insert was already too long, I made
+ * this a seperate routine.
+ *
+ * A legal hex string in MBNF: '0' 'x' ( HEX-DIGIT HEX-DIGIT )+ '\0'
+ *
+ * WHEN: the passed param is a legal hex string
+ * RETURNS: a pointer to that converted, null terminated hex string;
+ * len_return holds the character count of conversion result
+ *
+ * WHEN: the passed param is not a legal hex string:
+ * RETURNS: the parameter passed;
+ * len_return holds the char count of param.
+ *
+ * NOTE: In neither case will there be strings to free. */
+
+static char*
+IfHexConvertHexElseReturnParam(param, len_return)
+ char* param;
+ int* len_return;
+{
+ char *p; /* steps through param char by char */
+ char c; /* holds the character pointed to by p */
+
+ int ind; /* steps through hexval buffer char by char */
+ static char hexval[ XawTextActionMaxHexChars ];
+ Boolean first_digit;
+
+ /* reject if it doesn't begin with 0x and at least one more character. */
+
+ if ( ( param[0] != '0' ) || ( param[1] != 'x' ) || ( param[2] == '\0' ) ) {
+ *len_return = strlen( param );
+ return( param );
+ }
+
+ /* Skip the 0x; go character by character shifting and adding. */
+
+ first_digit = True;
+ ind = 0;
+ hexval[ ind ] = '\0';
+
+ for ( p = param+2; ( c = *p ); p++ ) {
+ hexval[ ind ] *= 16;
+ if (c >= '0' && c <= '9')
+ hexval[ ind ] += c - '0';
+ else if (c >= 'a' && c <= 'f')
+ hexval[ ind ] += c - 'a' + 10;
+ else if (c >= 'A' && c <= 'F')
+ hexval[ ind ] += c - 'A' + 10;
+ else break;
+
+ /* If we didn't break in preceding line, it was a good hex char. */
+
+ if ( first_digit )
+ first_digit = False;
+ else {
+ first_digit = True;
+ if ( ++ind < XawTextActionMaxHexChars )
+ hexval[ ind ] = '\0';
+ else {
+ *len_return = strlen( param );
+ return( param );
+ }
+ }
+ }
+
+ /* We quit the above loop becasue we hit a non hex. If that char is \0... */
+
+ if ( ( c == '\0' ) && first_digit ) {
+ *len_return = strlen( hexval );
+ return( hexval ); /* ...it was a legal hex string, so return it.*/
+ }
+
+ /* Else, there were non-hex chars or odd digit count, so... */
+
+ *len_return = strlen( param );
+ return( param ); /* ...return the verbatim string. */
+}
+
+
+/* InsertString() - action
+ *
+ * Mostly rewritten for R6 i18n.
+ *
+ * Each parameter, in turn, will be insert at the inputPos
+ * and the inputPos advances to the insertion's end.
+ *
+ * The exception is that parameters composed of the two
+ * characters 0x, followed only by an even number of
+ * hexadecimal digits will be converted to characters. */
+
+/*ARGSUSED*/
+static void
+InsertString(w, event, params, num_params)
+Widget w;
+XEvent* event;
+String* params;
+Cardinal* num_params;
+{
+ TextWidget ctx = (TextWidget) w;
+ XtAppContext app_con = XtWidgetToApplicationContext(w);
+ XawTextBlock text;
+ int i;
+
+ text.firstPos = 0;
+ text.format = _XawTextFormat( ctx );
+
+ StartAction(ctx, event);
+ for ( i = *num_params; i; i--, params++ ) { /* DO FOR EACH PARAMETER */
+
+ text.ptr = IfHexConvertHexElseReturnParam( *params, &text.length );
+
+ if ( text.length == 0 ) continue;
+
+ if ( _XawTextFormat( ctx ) == XawFmtWide ) { /* convert to WC */
+
+ int temp_len;
+ text.ptr = (char*) _XawTextMBToWC( XtDisplay(w), text.ptr,
+ &text.length );
+
+ if ( text.ptr == NULL ) { /* conversion error */
+ XtAppWarningMsg( app_con,
+ "insertString", "textAction", "XawError",
+ "insert-string()'s parameter contents not legal in this locale.",
+ NULL, NULL );
+ ParameterError( w, *params );
+ continue;
+ }
+
+ /* Double check that the new input is legal: try to convert to MB. */
+
+ temp_len = text.length; /* _XawTextWCToMB's 3rd arg is in_out */
+ if ( _XawTextWCToMB( XtDisplay(w), (wchar_t*)text.ptr, &temp_len ) == NULL ) {
+ XtAppWarningMsg( app_con,
+ "insertString", "textAction", "XawError",
+ "insert-string()'s parameter contents not legal in this locale.",
+ NULL, NULL );
+ ParameterError( w, *params );
+ continue;
+ }
+ } /* convert to WC */
+
+ if ( _XawTextReplace( ctx, ctx->text.insertPos,
+ ctx->text.insertPos, &text ) ) {
+ XBell( XtDisplay( ctx ), 50 );
+ EndAction( ctx );
+ return;
+ }
+
+ /* Advance insertPos to the end of the string we just inserted. */
+ ctx->text.insertPos = SrcScan( ctx->text.source, ctx->text.insertPos,
+ XawstPositions, XawsdRight, text.length, TRUE );
+
+ } /* DO FOR EACH PARAMETER */
+
+ EndAction( ctx );
+}
+
+
+/* DisplayCaret() - action
+ *
+ * The parameter list should contain one boolean value. If the
+ * argument is true, the cursor will be displayed. If false, not.
+ *
+ * The exception is that EnterNotify and LeaveNotify events may
+ * have a second argument, "always". If they do not, the cursor
+ * is only affected if the focus member of the event is true. */
+
+static void
+DisplayCaret(w, event, params, num_params)
+Widget w;
+XEvent* event; /* CrossingNotify special-cased */
+String* params; /* Off, False, No, On, True, Yes, etc. */
+Cardinal* num_params; /* 0, 1 or 2 */
+{
+ TextWidget ctx = (TextWidget)w;
+ Boolean display_caret = True;
+
+ if ( ( event->type == EnterNotify || event->type == LeaveNotify ) &&
+ ( ( *num_params >= 2 ) && ( strcmp( params[1], "always" ) == 0 ) ) &&
+ ( !event->xcrossing.focus ) )
+ return;
+
+ if (*num_params > 0) { /* default arg is "True" */
+ XrmValue from, to;
+ from.size = strlen(from.addr = params[0]);
+ XtConvert( w, XtRString, &from, XtRBoolean, &to );
+
+ if ( to.addr != NULL )
+ display_caret = *(Boolean*)to.addr;
+ if ( ctx->text.display_caret == display_caret )
+ return;
+ }
+ StartAction(ctx, event);
+ ctx->text.display_caret = display_caret;
+ EndAction(ctx);
+}
+
+
+/* Multiply() - action
+ *
+ * The parameter list may contain either a number or the string 'Reset'.
+ *
+ * A number will multiply the current multiplication factor by that number.
+ * Many of the text widget actions will will perform n actions, where n is
+ * the multiplication factor.
+ *
+ * The string reset will reset the mutiplication factor to 1. */
+
+/* ARGSUSED */
+static void
+Multiply(w, event, params, num_params)
+Widget w;
+XEvent* event;
+String* params;
+Cardinal* num_params;
+{
+ TextWidget ctx = (TextWidget) w;
+ int mult;
+
+ if (*num_params != 1) {
+ XtAppError( XtWidgetToApplicationContext( w ),
+ "Xaw Text Widget: multiply() takes exactly one argument.");
+ XBell( XtDisplay( w ), 0 );
+ return;
+ }
+
+ if ( ( params[0][0] == 'r' ) || ( params[0][0] == 'R' ) ) {
+ XBell( XtDisplay( w ), 0 );
+ ctx->text.mult = 1;
+ return;
+ }
+
+ if ( ( mult = atoi( params[0] ) ) == 0 ) {
+ char buf[ BUFSIZ ];
+ sprintf(buf, "%s %s", "Xaw Text Widget: multiply() argument",
+ "must be a number greater than zero, or 'Reset'." );
+ XtAppError( XtWidgetToApplicationContext( w ), buf );
+ XBell( XtDisplay( w ), 50 );
+ return;
+ }
+
+ ctx->text.mult *= mult;
+}
+
+
+/* StripOutOldCRs() - called from FormRegion
+ *
+ * removes CRs in widget ctx, from from to to.
+ *
+ * RETURNS: the new ending location (we may add some characters),
+ * or XawReplaceError if the widget can't be written to. */
+
+static XawTextPosition
+StripOutOldCRs(ctx, from, to)
+TextWidget ctx;
+XawTextPosition from, to;
+{
+ XawTextPosition startPos, endPos, eop_begin, eop_end, temp;
+ Widget src = ctx->text.source;
+ XawTextBlock text;
+ char *buf;
+ static wchar_t wc_two_spaces[ 3 ];
+
+ /* Initialize our TextBlock with two spaces. */
+
+ text.firstPos = 0;
+ text.format = _XawTextFormat(ctx);
+ if ( text.format == XawFmt8Bit )
+ text.ptr= " ";
+ else {
+ wc_two_spaces[0] = _Xaw_atowc(XawSP);
+ wc_two_spaces[1] = _Xaw_atowc(XawSP);
+ wc_two_spaces[2] = 0;
+ text.ptr = (char*) wc_two_spaces;
+ }
+
+ /* Strip out CR's. */
+
+ eop_begin = eop_end = startPos = endPos = from;
+ /* CONSTCOND */
+ while (TRUE) {
+ endPos=SrcScan(src, startPos, XawstEOL, XawsdRight, 1, FALSE);
+
+ temp = SrcScan(src, endPos, XawstWhiteSpace, XawsdLeft, 1, FALSE);
+ temp = SrcScan(src, temp, XawstWhiteSpace, XawsdRight,1, FALSE);
+
+ if (temp > startPos)
+ endPos = temp;
+
+ if (endPos >= to)
+ break;
+
+ if (endPos >= eop_begin) {
+ startPos = eop_end;
+ eop_begin=SrcScan(src, startPos, XawstParagraph, XawsdRight, 1,FALSE);
+ eop_end = SrcScan(src, startPos, XawstParagraph, XawsdRight, 1, TRUE);
+ }
+ else {
+ XawTextPosition periodPos, next_word;
+ int i, len;
+
+ periodPos= SrcScan(src, endPos, XawstPositions, XawsdLeft, 1, TRUE);
+ next_word = SrcScan(src, endPos, XawstWhiteSpace, XawsdRight, 1, FALSE);
+
+ len = next_word - periodPos;
+
+ text.length = 1;
+ buf = _XawTextGetText(ctx, periodPos, next_word);
+ if (text.format == XawFmtWide) {
+ if ( (periodPos < endPos) && (((wchar_t*)buf)[0] == _Xaw_atowc('.')))
+ text.length++;
+ } else
+ if ( (periodPos < endPos) && (buf[0] == '.') )
+ text.length++; /* Put in two spaces. */
+
+ /*
+ * Remove all extra spaces.
+ */
+
+ for (i = 1 ; i < len; i++)
+ if (text.format == XawFmtWide) {
+ if ( !iswspace(((wchar_t*)buf)[i]) || ((periodPos + i) >= to) ) {
+ break;
+ }
+ } else
+ if ( !isspace(buf[i]) || ((periodPos + i) >= to) ) {
+ break;
+ }
+
+ XtFree(buf);
+
+ to -= (i - text.length - 1);
+ startPos = SrcScan(src, periodPos, XawstPositions, XawsdRight, i, TRUE);
+ if (_XawTextReplace(ctx, endPos, startPos, &text) != XawEditDone)
+ return XawReplaceError;
+ startPos -= i - text.length;
+ }
+ }
+ return(to);
+}
+
+
+/* InsertNewCRs() - called from FormRegion
+ *
+ * inserts new CRs for FormRegion, thus for FormParagraph action */
+
+static void
+InsertNewCRs(ctx, from, to)
+TextWidget ctx;
+XawTextPosition from, to;
+{
+ XawTextPosition startPos, endPos, space, eol;
+ XawTextBlock text;
+ int i, width, height, len;
+ char * buf;
+ static wchar_t wide_CR[ 2 ];
+
+ text.firstPos = 0;
+ text.length = 1;
+ text.format = _XawTextFormat( ctx );
+
+ if ( text.format == XawFmt8Bit )
+ text.ptr = "\n";
+ else {
+ wide_CR[0] = _Xaw_atowc(XawLF);
+ wide_CR[1] = 0;
+ text.ptr = (char*) wide_CR;
+ }
+
+ startPos = from;
+ /* CONSTCOND */
+ while (TRUE) {
+ XawTextSinkFindPosition( ctx->text.sink, startPos,
+ (int) ctx->text.margin.left,
+ (int) (ctx->core.width - HMargins(ctx)),
+ TRUE, &eol, &width, &height);
+ if (eol >= to)
+ break;
+
+ eol = SrcScan(ctx->text.source, eol, XawstPositions, XawsdLeft, 1, TRUE);
+ space= SrcScan(ctx->text.source, eol, XawstWhiteSpace,XawsdRight,1, TRUE);
+
+ startPos = endPos = eol;
+ if (eol == space)
+ return;
+
+ len = (int) (space - eol);
+ buf = _XawTextGetText(ctx, eol, space);
+ for ( i = 0 ; i < len ; i++)
+ if (text.format == XawFmtWide) {
+ if (!iswspace(((wchar_t*)buf)[i]))
+ break;
+ } else
+ if (!isspace(buf[i]))
+ break;
+
+ to -= (i - 1);
+ endPos = SrcScan(ctx->text.source, endPos,
+ XawstPositions, XawsdRight, i, TRUE);
+ XtFree(buf);
+
+ if (_XawTextReplace(ctx, startPos, endPos, &text))
+ return;
+
+ startPos = SrcScan(ctx->text.source, startPos,
+ XawstPositions, XawsdRight, 1, TRUE);
+ }
+}
+
+
+/* FormRegion() - called by FormParagraph
+ *
+ * oversees the work of paragraph-forming a region
+ *
+ * RETURNS: XawEditDone if successful, or XawReplaceError. */
+
+static int
+FormRegion(ctx, from, to)
+TextWidget ctx;
+XawTextPosition from, to;
+{
+ if ( from >= to ) return XawEditDone;
+
+ if ( ( to = StripOutOldCRs( ctx, from, to ) ) == XawReplaceError )
+ return XawReplaceError;
+
+ /* insure that the insertion point is within legal bounds */
+ if ( ctx->text.insertPos > SrcScan( ctx->text.source, 0,
+ XawstAll, XawsdRight, 1, TRUE ) )
+ ctx->text.insertPos = to;
+
+ InsertNewCRs(ctx, from, to);
+ _XawTextBuildLineTable(ctx, ctx->text.lt.top, TRUE);
+ return XawEditDone;
+}
+
+
+/* FormParagraph() - action
+ *
+ * removes and reinserts CRs to maximize line length without clipping */
+
+/* ARGSUSED */
+static void
+FormParagraph(w, event, params, num_params)
+Widget w;
+XEvent* event;
+String* params;
+Cardinal* num_params;
+{
+ TextWidget ctx = (TextWidget) w;
+ XawTextPosition from, to;
+
+ StartAction(ctx, event);
+
+ from = SrcScan( ctx->text.source, ctx->text.insertPos,
+ XawstParagraph, XawsdLeft, 1, FALSE );
+ to = SrcScan( ctx->text.source, from,
+ XawstParagraph, XawsdRight, 1, FALSE );
+
+ if ( FormRegion( ctx, from, to ) == XawReplaceError )
+ XBell( XtDisplay( w ), 0 );
+ _XawTextSetScrollBars( ctx );
+ EndAction( ctx );
+}
+
+
+/* TransposeCharacters() - action
+ *
+ * Swaps the character to the left of the mark
+ * with the character to the right of the mark. */
+
+/* ARGSUSED */
+static void
+TransposeCharacters(w, event, params, num_params)
+Widget w;
+XEvent* event;
+String* params;
+Cardinal* num_params;
+{
+ TextWidget ctx = (TextWidget) w;
+ XawTextPosition start, end;
+ XawTextBlock text;
+ char* buf;
+ int i;
+
+ StartAction(ctx, event);
+
+ /* Get bounds. */
+
+ start = SrcScan( ctx->text.source, ctx->text.insertPos, XawstPositions,
+ XawsdLeft, 1, TRUE );
+ end = SrcScan( ctx->text.source, ctx->text.insertPos, XawstPositions,
+ XawsdRight, ctx->text.mult, TRUE );
+
+ /* Make sure we aren't at the very beginning or end of the buffer. */
+
+ if ( ( start == ctx->text.insertPos ) || ( end == ctx->text.insertPos ) ) {
+ XBell( XtDisplay( w ), 0 ); /* complain. */
+ EndAction( ctx );
+ return;
+ }
+
+ ctx->text.insertPos = end;
+
+ text.firstPos = 0;
+ text.format = _XawTextFormat(ctx);
+
+ /* Retrieve text and swap the characters. */
+
+ if ( text.format == XawFmtWide) {
+ wchar_t wc;
+ wchar_t* wbuf;
+
+ wbuf = (wchar_t*) _XawTextGetText(ctx, start, end);
+ text.length = wcslen( wbuf );
+ wc = wbuf[ 0 ];
+ for ( i = 1; i < text.length; i++ )
+ wbuf[ i-1 ] = wbuf[ i ];
+ wbuf[ i-1 ] = wc;
+ buf = (char*) wbuf; /* so that it gets assigned and freed */
+
+ } else { /* thus text.format == XawFmt8Bit */
+ char c;
+ buf = _XawTextGetText( ctx, start, end );
+ text.length = strlen( buf );
+ c = buf[ 0 ];
+ for ( i = 1; i < text.length; i++ )
+ buf[ i-1 ] = buf[ i ];
+ buf[ i-1 ] = c;
+ }
+
+ text.ptr = buf;
+
+ /* Store new text in source. */
+
+ if (_XawTextReplace (ctx, start, end, &text)) /* Unable to edit, complain. */
+ XBell(XtDisplay(w), 0);
+ XtFree((char *) buf);
+ EndAction(ctx);
+}
+
+
+/* NoOp() - action
+ * This action performs no action, and allows the user or
+ * application programmer to unbind a translation.
+ *
+ * Note: If the parameter list contains the string "RingBell" then
+ * this action will ring the bell.
+ */
+
+/*ARGSUSED*/
+static void
+NoOp(w, event, params, num_params)
+Widget w;
+XEvent* event;
+String* params;
+Cardinal* num_params;
+{
+ if (*num_params != 1)
+ return;
+
+ switch(params[0][0]) {
+ case 'R':
+ case 'r':
+ XBell(XtDisplay(w), 0);
+ default: /* Fall Through */
+ break;
+ }
+}
+
+/* Reconnect() - action
+ * This reconnects to the input method. The user will typically call
+ * this action if/when connection has been severed, or when the app
+ * was started up before an IM was started up.
+ */
+
+/*ARGSUSED*/
+static void
+Reconnect( w, event, params, num_params )
+ Widget w;
+ XEvent* event;
+ String* params;
+ Cardinal* num_params;
+{
+ _XawImReconnect( w );
+}
+
+
+XtActionsRec _XawTextActionsTable[] = {
+
+/* motion bindings */
+
+ {"forward-character", MoveForwardChar},
+ {"backward-character", MoveBackwardChar},
+ {"forward-word", MoveForwardWord},
+ {"backward-word", MoveBackwardWord},
+ {"forward-paragraph", MoveForwardParagraph},
+ {"backward-paragraph", MoveBackwardParagraph},
+ {"beginning-of-line", MoveToLineStart},
+ {"end-of-line", MoveToLineEnd},
+ {"next-line", MoveNextLine},
+ {"previous-line", MovePreviousLine},
+ {"next-page", MoveNextPage},
+ {"previous-page", MovePreviousPage},
+ {"beginning-of-file", MoveBeginningOfFile},
+ {"end-of-file", MoveEndOfFile},
+ {"scroll-one-line-up", ScrollOneLineUp},
+ {"scroll-one-line-down", ScrollOneLineDown},
+
+/* delete bindings */
+
+ {"delete-next-character", DeleteForwardChar},
+ {"delete-previous-character", DeleteBackwardChar},
+ {"delete-next-word", DeleteForwardWord},
+ {"delete-previous-word", DeleteBackwardWord},
+ {"delete-selection", DeleteCurrentSelection},
+
+/* kill bindings */
+
+ {"kill-word", KillForwardWord},
+ {"backward-kill-word", KillBackwardWord},
+ {"kill-selection", KillCurrentSelection},
+ {"kill-to-end-of-line", KillToEndOfLine},
+ {"kill-to-end-of-paragraph", KillToEndOfParagraph},
+
+/* new line stuff */
+
+ {"newline-and-indent", InsertNewLineAndIndent},
+ {"newline-and-backup", InsertNewLineAndBackup},
+ {"newline", InsertNewLine},
+
+/* Selection stuff */
+
+ {"select-word", SelectWord},
+ {"select-all", SelectAll},
+ {"select-start", SelectStart},
+ {"select-adjust", SelectAdjust},
+ {"select-end", SelectEnd},
+ {"select-save", SelectSave},
+ {"extend-start", ExtendStart},
+ {"extend-adjust", ExtendAdjust},
+ {"extend-end", ExtendEnd},
+ {"insert-selection", InsertSelection},
+
+/* Miscellaneous */
+
+ {"redraw-display", RedrawDisplay},
+ {"insert-file", _XawTextInsertFile},
+ {"search", _XawTextSearch},
+ {"insert-char", InsertChar},
+ {"insert-string", InsertString},
+ {"focus-in", TextFocusIn},
+ {"focus-out", TextFocusOut},
+ {"enter-window", TextEnterWindow},
+ {"leave-window", TextLeaveWindow},
+ {"display-caret", DisplayCaret},
+ {"multiply", Multiply},
+ {"form-paragraph", FormParagraph},
+ {"transpose-characters", TransposeCharacters},
+ {"no-op", NoOp},
+
+/* Action to bind special translations for text Dialogs. */
+
+ {"InsertFileAction", _XawTextInsertFileAction},
+ {"DoSearchAction", _XawTextDoSearchAction},
+ {"DoReplaceAction", _XawTextDoReplaceAction},
+ {"SetField", _XawTextSetField},
+ {"PopdownSearchAction", _XawTextPopdownSearchAction},
+
+/* Reconnect to Input Method */
+ {"reconnect-im", Reconnect} /* Li Yuhong, Omron KK, 1991 */
+};
+
+Cardinal _XawTextActionsTableCount = XtNumber(_XawTextActionsTable);
diff --git a/src/TextPop.c b/src/TextPop.c
new file mode 100644
index 0000000..694be4c
--- /dev/null
+++ b/src/TextPop.c
@@ -0,0 +1,1455 @@
+/* $Xorg: TextPop.c,v 1.4 2001/02/09 02:03:46 xorgcvs Exp $ */
+
+/*
+
+Copyright 1989, 1994, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+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
+OPEN GROUP 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 Open Group 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 Open Group.
+
+*/
+
+/************************************************************
+ *
+ * This file is broken up into three sections one dealing with
+ * each of the three popups created here:
+ *
+ * FileInsert, Search, and Replace.
+ *
+ * There is also a section at the end for utility functions
+ * used by all more than one of these dialogs.
+ *
+ * The following functions are the only non-static ones defined
+ * in this module. They are located at the begining of the
+ * section that contains this dialog box that uses them.
+ *
+ * void _XawTextInsertFileAction(w, event, params, num_params);
+ * void _XawTextDoSearchAction(w, event, params, num_params);
+ * void _XawTextDoReplaceAction(w, event, params, num_params);
+ * void _XawTextInsertFile(w, event, params, num_params);
+ *
+ *************************************************************/
+
+#include <X11/IntrinsicP.h>
+#include <X11/StringDefs.h>
+#include <X11/Shell.h>
+
+#include <X11/Xaw/TextP.h>
+#include <X11/Xaw/AsciiText.h>
+#include <X11/Xaw/Cardinals.h>
+#include <X11/Xaw/Command.h>
+#include <X11/Xaw/Form.h>
+#include <X11/Xaw/Toggle.h>
+#include <X11/Xmu/CharSet.h>
+#include "XawI18n.h"
+#include <stdio.h>
+#include <X11/Xos.h> /* for O_RDONLY */
+#include <errno.h>
+
+#ifdef X_NOT_STDC_ENV
+extern int errno;
+#endif
+
+static char* INSERT_FILE = "Enter Filename:";
+static char* SEARCH_LABEL_1 = "Use <Tab> to change fields.";
+static char* SEARCH_LABEL_2 = "Use ^q<Tab> for <Tab>.";
+static char* DISMISS_NAME = "cancel";
+#define DISMISS_NAME_LEN 6
+static char* FORM_NAME = "form";
+static char* LABEL_NAME = "label";
+static char* TEXT_NAME = "text";
+
+#define R_OFFSET 1
+
+static void CenterWidgetOnPoint(), PopdownSearch(), DoInsert(), _SetField();
+static void InitializeSearchWidget(), SetResource(), SetSearchLabels();
+static void DoReplaceOne(), DoReplaceAll();
+static Widget CreateDialog(), GetShell();
+static void SetWMProtocolTranslations();
+static Boolean DoSearch(), SetResourceByName(), Replace();
+static String GetString();
+
+static String GetStringRaw();
+
+static void AddInsertFileChildren();
+static Boolean InsertFileNamed();
+static void AddSearchChildren();
+
+static char radio_trans_string[] =
+ "<Btn1Down>,<Btn1Up>: set() notify()";
+
+static char search_text_trans[] =
+ "~Shift<Key>Return: DoSearchAction(Popdown) \n\
+ Shift<Key>Return: DoSearchAction() SetField(Replace) \n\
+ Ctrl<Key>q,<Key>Tab: insert-char() \n\
+ Ctrl<Key>c: PopdownSearchAction() \n\
+ <Btn1Down>: select-start() SetField(Search) \n\
+ <Key>Tab: DoSearchAction() SetField(Replace)";
+
+static char rep_text_trans[] =
+ "~Shift<Key>Return: DoReplaceAction(Popdown) \n\
+ Shift<Key>Return: SetField(Search) \n\
+ Ctrl<Key>q,<Key>Tab: insert-char() \n\
+ Ctrl<Key>c: PopdownSearchAction() \n\
+ <Btn1Down>: select-start() DoSearchAction() SetField(Replace)\n\
+ <Key>Tab: SetField(Search)";
+
+/************************************************************
+ *
+ * This section of the file contains all the functions that
+ * the file insert dialog box uses.
+ *
+ ************************************************************/
+
+/* Function Name: _XawTextInsertFileAction
+ * Description: Action routine that can be bound to dialog box's
+ * Text Widget that will insert a file into the main
+ * Text Widget.
+ * Arguments: (Standard Action Routine args)
+ * Returns: none.
+ */
+
+/* ARGSUSED */
+void
+_XawTextInsertFileAction(w, event, params, num_params)
+Widget w;
+XEvent *event;
+String * params;
+Cardinal * num_params;
+{
+ DoInsert(w, (XtPointer) XtParent(XtParent(XtParent(w))), (XtPointer)NULL);
+}
+
+/* Function Name: _XawTextInsertFile
+ * Description: Action routine that can be bound to the text widget
+ * it will popup the insert file dialog box.
+ * Arguments: w - the text widget.
+ * event - X Event (used to get x and y location).
+ * params, num_params - the parameter list.
+ * Returns: none.
+ *
+ * NOTE:
+ *
+ * The parameter list may contain one entry.
+ *
+ * Entry: This entry is optional and contains the value of the default
+ * file to insert.
+ */
+
+void
+_XawTextInsertFile(w, event, params, num_params)
+Widget w;
+XEvent *event;
+String * params;
+Cardinal * num_params;
+{
+ TextWidget ctx = (TextWidget)w;
+ char * ptr;
+ XawTextEditType edit_mode;
+ Arg args[1];
+
+ XtSetArg(args[0], XtNeditType,&edit_mode);
+ XtGetValues(ctx->text.source, args, ONE);
+
+ if (edit_mode != XawtextEdit) {
+ XBell(XtDisplay(w), 0);
+ return;
+ }
+
+ if (*num_params == 0)
+ ptr = "";
+ else
+ ptr = params[0];
+
+ if (!ctx->text.file_insert) {
+ ctx->text.file_insert = CreateDialog(w, ptr, "insertFile",
+ AddInsertFileChildren);
+ XtRealizeWidget(ctx->text.file_insert);
+ SetWMProtocolTranslations(ctx->text.file_insert);
+ }
+
+ CenterWidgetOnPoint(ctx->text.file_insert, event);
+ XtPopup(ctx->text.file_insert, XtGrabNone);
+}
+
+/* Function Name: PopdownFileInsert
+ * Description: Pops down the file insert button.
+ * Arguments: w - the widget that caused this action.
+ * closure - a pointer to the main text widget that
+ * popped up this dialog.
+ * call_data - *** NOT USED ***.
+ * Returns: none.
+ */
+
+/* ARGSUSED */
+static void
+PopdownFileInsert(w, closure, call_data)
+Widget w; /* The Dialog Button Pressed. */
+XtPointer closure; /* Text Widget. */
+XtPointer call_data; /* unused */
+{
+ TextWidget ctx = (TextWidget) closure;
+
+ XtPopdown( ctx->text.file_insert );
+ (void) SetResourceByName( ctx->text.file_insert, LABEL_NAME,
+ XtNlabel, (XtArgVal) INSERT_FILE);
+}
+
+/* Function Name: DoInsert
+ * Description: Actually insert the file named in the text widget
+ * of the file dialog.
+ * Arguments: w - the widget that activated this callback.
+ * closure - a pointer to the text widget to insert the
+ * file into.
+ * Returns: none.
+ */
+
+/* ARGSUSED */
+static void
+DoInsert(w, closure, call_data)
+Widget w; /* The Dialog Button Pressed. */
+XtPointer closure; /* Text Widget */
+XtPointer call_data; /* unused */
+{
+ TextWidget ctx = (TextWidget) closure;
+ char buf[BUFSIZ], msg[BUFSIZ];
+ Widget temp_widget;
+
+ (void) sprintf(buf, "%s.%s", FORM_NAME, TEXT_NAME);
+ if ( (temp_widget = XtNameToWidget(ctx->text.file_insert, buf)) == NULL ) {
+ (void) strcpy(msg,
+ "*** Error: Could not get text widget from file insert popup");
+ }
+ else
+ if (InsertFileNamed( (Widget) ctx, GetString( temp_widget ))) {
+ PopdownFileInsert(w, closure, call_data);
+ return;
+ }
+ else
+ (void) sprintf( msg, "*** Error: %s ***", strerror(errno));
+
+ (void)SetResourceByName(ctx->text.file_insert,
+ LABEL_NAME, XtNlabel, (XtArgVal) msg);
+ XBell(XtDisplay(w), 0);
+}
+
+/* Function Name: InsertFileNamed
+ * Description: Inserts a file into the text widget.
+ * Arguments: tw - The text widget to insert this file into.
+ * str - name of the file to insert.
+ * Returns: TRUE if the insert was sucessful, FALSE otherwise.
+ */
+
+
+static Boolean
+InsertFileNamed(tw, str)
+Widget tw;
+char *str;
+{
+ FILE *file;
+ XawTextBlock text;
+ XawTextPosition pos;
+
+ if ( (str == NULL) || (strlen(str) == 0) ||
+ ((file = fopen(str, "r")) == NULL))
+ return(FALSE);
+
+ pos = XawTextGetInsertionPoint(tw);
+
+ fseek(file, 0L, 2);
+
+
+ text.firstPos = 0;
+ text.length = (ftell(file))/sizeof(unsigned char);
+ text.ptr = XtMalloc((text.length + 1) * sizeof(unsigned char));
+ text.format = XawFmt8Bit;
+
+ fseek(file, 0L, 0);
+ if (fread(text.ptr, sizeof(unsigned char), text.length, file) != text.length)
+ XtErrorMsg("readError", "insertFileNamed", "XawError",
+ "fread returned error.", NULL, NULL);
+
+ /* DELETE if (text.format == XawFmtWide) {
+ wchar_t* _XawTextMBToWC();
+ wchar_t* wstr;
+ wstr = _XawTextMBToWC(XtDisplay(tw), text.ptr, &(text.length));
+ wstr[text.length] = NULL;
+ XtFree(text.ptr);
+ text.ptr = (char *)wstr;
+ } else {
+ (text.ptr)[text.length] = '\0';
+ }*/
+
+ if (XawTextReplace(tw, pos, pos, &text) != XawEditDone) {
+ XtFree(text.ptr);
+ fclose(file);
+ return(FALSE);
+ }
+ pos += text.length;
+ XtFree(text.ptr);
+ fclose(file);
+ XawTextSetInsertionPoint(tw, pos);
+ return(TRUE);
+}
+
+
+/* Function Name: AddInsertFileChildren
+ * Description: Adds all children to the InsertFile dialog widget.
+ * Arguments: form - the form widget for the insert dialog widget.
+ * ptr - a pointer to the initial string for the Text Widget.
+ * tw - the main text widget.
+ * Returns: none
+ */
+
+static void
+AddInsertFileChildren(form, ptr, tw)
+Widget form, tw;
+char * ptr;
+{
+ Arg args[10];
+ Cardinal num_args;
+ Widget label, text, cancel, insert;
+ XtTranslations trans;
+
+ num_args = 0;
+ XtSetArg(args[num_args], XtNlabel, INSERT_FILE);num_args++;
+ XtSetArg(args[num_args], XtNleft, XtChainLeft); num_args++;
+ XtSetArg(args[num_args], XtNright, XtChainLeft); num_args++;
+ XtSetArg(args[num_args], XtNresizable, TRUE ); num_args++;
+ XtSetArg(args[num_args], XtNborderWidth, 0 ); num_args++;
+ label = XtCreateManagedWidget (LABEL_NAME, labelWidgetClass, form,
+ args, num_args);
+
+ num_args = 0;
+ XtSetArg(args[num_args], XtNfromVert, label); num_args++;
+ XtSetArg(args[num_args], XtNleft, XtChainLeft); num_args++;
+ XtSetArg(args[num_args], XtNright, XtChainRight); num_args++;
+ XtSetArg(args[num_args], XtNeditType, XawtextEdit); num_args++;
+ XtSetArg(args[num_args], XtNresizable, TRUE); num_args++;
+ XtSetArg(args[num_args], XtNresize, XawtextResizeWidth); num_args++;
+ XtSetArg(args[num_args], XtNstring, ptr); num_args++;
+ text = XtCreateManagedWidget(TEXT_NAME, asciiTextWidgetClass, form,
+ args, num_args);
+
+ num_args = 0;
+ XtSetArg(args[num_args], XtNlabel, "Insert File"); num_args++;
+ XtSetArg(args[num_args], XtNfromVert, text); num_args++;
+ XtSetArg(args[num_args], XtNleft, XtChainLeft); num_args++;
+ XtSetArg(args[num_args], XtNright, XtChainLeft); num_args++;
+ insert = XtCreateManagedWidget("insert", commandWidgetClass, form,
+ args, num_args);
+
+ num_args = 0;
+ XtSetArg(args[num_args], XtNlabel, "Cancel"); num_args++;
+ XtSetArg(args[num_args], XtNfromVert, text); num_args++;
+ XtSetArg(args[num_args], XtNfromHoriz, insert); num_args++;
+ XtSetArg(args[num_args], XtNleft, XtChainLeft); num_args++;
+ XtSetArg(args[num_args], XtNright, XtChainLeft); num_args++;
+ cancel = XtCreateManagedWidget(DISMISS_NAME, commandWidgetClass, form,
+ args, num_args);
+
+ XtAddCallback(cancel, XtNcallback, PopdownFileInsert, (XtPointer) tw);
+ XtAddCallback(insert, XtNcallback, DoInsert, (XtPointer) tw);
+
+ XtSetKeyboardFocus(form, text);
+
+/*
+ * Bind <CR> to insert file.
+ */
+
+ trans = XtParseTranslationTable("<Key>Return: InsertFileAction()");
+ XtOverrideTranslations(text, trans);
+
+}
+
+/************************************************************
+ *
+ * This section of the file contains all the functions that
+ * the search dialog box uses.
+ *
+ ************************************************************/
+
+/* Function Name: _XawTextDoSearchAction
+ * Description: Action routine that can be bound to dialog box's
+ * Text Widget that will search for a string in the main
+ * Text Widget.
+ * Arguments: (Standard Action Routine args)
+ * Returns: none.
+ *
+ * Note:
+ *
+ * If the search was sucessful and the argument popdown is passed to
+ * this action routine then the widget will automatically popdown the
+ * search widget.
+ */
+
+/* ARGSUSED */
+void
+_XawTextDoSearchAction(w, event, params, num_params)
+Widget w;
+XEvent *event;
+String * params;
+Cardinal * num_params;
+{
+ TextWidget tw = (TextWidget) XtParent(XtParent(XtParent(w)));
+ Boolean popdown = FALSE;
+
+ if ( (*num_params == 1) &&
+ ((params[0][0] == 'p') || (params[0][0] == 'P')) )
+ popdown = TRUE;
+
+ if (DoSearch(tw->text.search) && popdown)
+ PopdownSearch(w, (XtPointer) tw->text.search, (XtPointer)NULL);
+}
+
+/* Function Name: _XawTextPopdownSearchAction
+ * Description: Action routine that can be bound to dialog box's
+ * Text Widget that will popdown the search widget.
+ * Arguments: (Standard Action Routine args)
+ * Returns: none.
+ */
+
+/* ARGSUSED */
+void
+_XawTextPopdownSearchAction(w, event, params, num_params)
+Widget w;
+XEvent *event;
+String * params;
+Cardinal * num_params;
+{
+ TextWidget tw = (TextWidget) XtParent(XtParent(XtParent(w)));
+
+ PopdownSearch(w, (XtPointer) tw->text.search, (XtPointer)NULL);
+}
+
+/* Function Name: PopdownSeach
+ * Description: Pops down the search widget and resets it.
+ * Arguments: w - *** NOT USED ***.
+ * closure - a pointer to the search structure.
+ * call_data - *** NOT USED ***.
+ * Returns: none
+ */
+
+/* ARGSUSED */
+static void
+PopdownSearch(w, closure, call_data)
+Widget w;
+XtPointer closure;
+XtPointer call_data;
+{
+ struct SearchAndReplace * search = (struct SearchAndReplace *) closure;
+
+ XtPopdown( search->search_popup );
+ SetSearchLabels(search, SEARCH_LABEL_1, SEARCH_LABEL_2, FALSE);
+}
+
+/* Function Name: SearchButton
+ * Description: Performs a search when the button is clicked.
+ * Arguments: w - *** NOT USED **.
+ * closure - a pointer to the search info.
+ * call_data - *** NOT USED ***.
+ * Returns:
+ */
+
+/* ARGSUSED */
+static void
+SearchButton(w, closure, call_data)
+Widget w;
+XtPointer closure;
+XtPointer call_data;
+{
+ (void) DoSearch( (struct SearchAndReplace *) closure );
+}
+
+/* Function Name: _XawTextSearch
+ * Description: Action routine that can be bound to the text widget
+ * it will popup the search dialog box.
+ * Arguments: w - the text widget.
+ * event - X Event (used to get x and y location).
+ * params, num_params - the parameter list.
+ * Returns: none.
+ *
+ * NOTE:
+ *
+ * The parameter list contains one or two entries that may be the following.
+ *
+ * First Entry: The first entry is the direction to search by default.
+ * This arguement must be specified and may have a value of
+ * "left" or "right".
+ *
+ * Second Entry: This entry is optional and contains the value of the default
+ * string to search for.
+ */
+
+#define SEARCH_HEADER ("Text Widget - Search():")
+
+void
+_XawTextSearch(w, event, params, num_params)
+Widget w;
+XEvent *event;
+String * params;
+Cardinal * num_params;
+{
+ TextWidget ctx = (TextWidget)w;
+ XawTextScanDirection dir;
+ char * ptr, buf[BUFSIZ];
+ XawTextEditType edit_mode;
+ Arg args[1];
+
+#ifdef notdef
+ if (ctx->text.source->Search == NULL) {
+ XBell(XtDisplay(w), 0);
+ return;
+ }
+#endif
+
+ if ( (*num_params < 1) || (*num_params > 2) ) {
+ (void) sprintf(buf, "%s %s\n%s", SEARCH_HEADER,
+ "This action must have only",
+ "one or two parameters");
+ XtAppWarning(XtWidgetToApplicationContext(w), buf);
+ return;
+ }
+
+ if (*num_params == 2 )
+ ptr = params[1];
+ else
+ if (_XawTextFormat(ctx) == XawFmtWide) {
+ /*This just does the equivalent of ptr = ""L, a waste because params[1] isnt W aligned.*/
+ ptr = (char *)XtMalloc(sizeof(wchar_t));
+ *((wchar_t*)ptr) = (wchar_t)0;
+ } else
+ ptr = "";
+
+ switch(params[0][0]) {
+ case 'b': /* Left. */
+ case 'B':
+ dir = XawsdLeft;
+ break;
+ case 'f': /* Right. */
+ case 'F':
+ dir = XawsdRight;
+ break;
+ default:
+ (void) sprintf(buf, "%s %s\n%s", SEARCH_HEADER,
+ "The first parameter must be",
+ "Either 'backward' or 'forward'");
+ XtAppWarning(XtWidgetToApplicationContext(w), buf);
+ return;
+ }
+
+ if (ctx->text.search== NULL) {
+ ctx->text.search = XtNew(struct SearchAndReplace);
+ ctx->text.search->search_popup = CreateDialog(w, ptr, "search",
+ AddSearchChildren);
+ XtRealizeWidget(ctx->text.search->search_popup);
+ SetWMProtocolTranslations(ctx->text.search->search_popup);
+ }
+ else if (*num_params > 1) {
+ XtVaSetValues(ctx->text.search->search_text, XtNstring, ptr, NULL);
+ }
+
+ XtSetArg(args[0], XtNeditType,&edit_mode);
+ XtGetValues(ctx->text.source, args, ONE);
+
+ InitializeSearchWidget(ctx->text.search, dir, (edit_mode == XawtextEdit));
+
+ CenterWidgetOnPoint(ctx->text.search->search_popup, event);
+ XtPopup(ctx->text.search->search_popup, XtGrabNone);
+}
+
+/* Function Name: InitializeSearchWidget
+ * Description: This function initializes the search widget and
+ * is called each time the search widget is poped up.
+ * Arguments: search - the search widget structure.
+ * dir - direction to search.
+ * replace_active - state of the sensitivity for the
+ * replace button.
+ * Returns: none.
+ */
+
+static void
+InitializeSearchWidget(search, dir, replace_active)
+struct SearchAndReplace * search;
+XawTextScanDirection dir;
+Boolean replace_active;
+{
+ SetResource(search->rep_one, XtNsensitive, (XtArgVal) replace_active);
+ SetResource(search->rep_all, XtNsensitive, (XtArgVal) replace_active);
+ SetResource(search->rep_label, XtNsensitive, (XtArgVal) replace_active);
+ SetResource(search->rep_text, XtNsensitive, (XtArgVal) replace_active);
+
+ switch (dir) {
+ case XawsdLeft:
+ SetResource(search->left_toggle, XtNstate, (XtArgVal) TRUE);
+ break;
+ case XawsdRight:
+ SetResource(search->right_toggle, XtNstate, (XtArgVal) TRUE);
+ break;
+ default:
+ break;
+ }
+}
+
+/* Function Name: AddSearchChildren
+ * Description: Adds all children to the Search Dialog Widget.
+ * Arguments: form - the form widget for the search widget.
+ * ptr - a pointer to the initial string for the Text Widget.
+ * tw - the main text widget.
+ * Returns: none.
+ */
+
+static void
+AddSearchChildren(form, ptr, tw)
+Widget form, tw;
+char * ptr;
+{
+ Arg args[10];
+ Cardinal num_args;
+ Widget cancel, search_button, s_label, s_text, r_text;
+ XtTranslations trans;
+ struct SearchAndReplace * search = ((TextWidget) tw)->text.search;
+
+ num_args = 0;
+ XtSetArg(args[num_args], XtNleft, XtChainLeft); num_args++;
+ XtSetArg(args[num_args], XtNright, XtChainLeft); num_args++;
+ XtSetArg(args[num_args], XtNresizable, TRUE ); num_args++;
+ XtSetArg(args[num_args], XtNborderWidth, 0 ); num_args++;
+ search->label1 = XtCreateManagedWidget("label1", labelWidgetClass, form,
+ args, num_args);
+
+ num_args = 0;
+ XtSetArg(args[num_args], XtNfromVert, search->label1); num_args++;
+ XtSetArg(args[num_args], XtNleft, XtChainLeft); num_args++;
+ XtSetArg(args[num_args], XtNright, XtChainLeft); num_args++;
+ XtSetArg(args[num_args], XtNresizable, TRUE ); num_args++;
+ XtSetArg(args[num_args], XtNborderWidth, 0 ); num_args++;
+ search->label2 = XtCreateManagedWidget("label2", labelWidgetClass, form,
+ args, num_args);
+
+/*
+ * We need to add R_OFFSET to the radio_data, because the value zero (0)
+ * has special meaning.
+ */
+
+ num_args = 0;
+ XtSetArg(args[num_args], XtNlabel, "Backward"); num_args++;
+ XtSetArg(args[num_args], XtNfromVert, search->label2); num_args++;
+ XtSetArg(args[num_args], XtNleft, XtChainLeft); num_args++;
+ XtSetArg(args[num_args], XtNright, XtChainLeft); num_args++;
+ XtSetArg(args[num_args], XtNradioData, (XPointer) XawsdLeft + R_OFFSET);
+ num_args++;
+ search->left_toggle = XtCreateManagedWidget("backwards", toggleWidgetClass,
+ form, args, num_args);
+
+ num_args = 0;
+ XtSetArg(args[num_args], XtNlabel, "Forward"); num_args++;
+ XtSetArg(args[num_args], XtNfromVert, search->label2); num_args++;
+ XtSetArg(args[num_args], XtNfromHoriz, search->left_toggle); num_args++;
+ XtSetArg(args[num_args], XtNleft, XtChainLeft); num_args++;
+ XtSetArg(args[num_args], XtNright, XtChainLeft); num_args++;
+ XtSetArg(args[num_args], XtNradioGroup, search->left_toggle); num_args++;
+ XtSetArg(args[num_args], XtNradioData, (XPointer) XawsdRight + R_OFFSET);
+ num_args++;
+ search->right_toggle = XtCreateManagedWidget("forwards", toggleWidgetClass,
+ form, args, num_args);
+
+ {
+ XtTranslations radio_translations;
+
+ radio_translations = XtParseTranslationTable(radio_trans_string);
+ XtOverrideTranslations(search->left_toggle, radio_translations);
+ XtOverrideTranslations(search->right_toggle, radio_translations);
+ }
+
+ num_args = 0;
+ XtSetArg(args[num_args], XtNfromVert, search->left_toggle); num_args++;
+ XtSetArg(args[num_args], XtNlabel, "Search for: ");num_args++;
+ XtSetArg(args[num_args], XtNleft, XtChainLeft); num_args++;
+ XtSetArg(args[num_args], XtNright, XtChainLeft); num_args++;
+ XtSetArg(args[num_args], XtNborderWidth, 0 ); num_args++;
+ s_label = XtCreateManagedWidget("searchLabel", labelWidgetClass, form,
+ args, num_args);
+
+ num_args = 0;
+ XtSetArg(args[num_args], XtNfromVert, search->left_toggle); num_args++;
+ XtSetArg(args[num_args], XtNfromHoriz, s_label); num_args++;
+ XtSetArg(args[num_args], XtNleft, XtChainLeft); num_args++;
+ XtSetArg(args[num_args], XtNright, XtChainRight); num_args++;
+ XtSetArg(args[num_args], XtNeditType, XawtextEdit); num_args++;
+ XtSetArg(args[num_args], XtNresizable, TRUE); num_args++;
+ XtSetArg(args[num_args], XtNresize, XawtextResizeWidth); num_args++;
+ XtSetArg(args[num_args], XtNstring, ptr); num_args++;
+ s_text = XtCreateManagedWidget("searchText", asciiTextWidgetClass, form,
+ args, num_args);
+ search->search_text = s_text;
+
+ num_args = 0;
+ XtSetArg(args[num_args], XtNfromVert, s_text); num_args++;
+ XtSetArg(args[num_args], XtNlabel, "Replace with:");num_args++;
+ XtSetArg(args[num_args], XtNleft, XtChainLeft); num_args++;
+ XtSetArg(args[num_args], XtNright, XtChainLeft); num_args++;
+ XtSetArg(args[num_args], XtNborderWidth, 0 ); num_args++;
+ search->rep_label = XtCreateManagedWidget("replaceLabel", labelWidgetClass,
+ form, args, num_args);
+
+ num_args = 0;
+ XtSetArg(args[num_args], XtNfromHoriz, s_label); num_args++;
+ XtSetArg(args[num_args], XtNfromVert, s_text); num_args++;
+ XtSetArg(args[num_args], XtNleft, XtChainLeft); num_args++;
+ XtSetArg(args[num_args], XtNright, XtChainRight); num_args++;
+ XtSetArg(args[num_args], XtNeditType, XawtextEdit); num_args++;
+ XtSetArg(args[num_args], XtNresizable, TRUE); num_args++;
+ XtSetArg(args[num_args], XtNresize, XawtextResizeWidth); num_args++;
+ XtSetArg(args[num_args], XtNstring, ""); num_args++;
+ r_text = XtCreateManagedWidget("replaceText", asciiTextWidgetClass,
+ form, args, num_args);
+ search->rep_text = r_text;
+
+ num_args = 0;
+ XtSetArg(args[num_args], XtNlabel, "Search"); num_args++;
+ XtSetArg(args[num_args], XtNfromVert, r_text); num_args++;
+ XtSetArg(args[num_args], XtNleft, XtChainLeft); num_args++;
+ XtSetArg(args[num_args], XtNright, XtChainLeft); num_args++;
+ search_button = XtCreateManagedWidget("search", commandWidgetClass, form,
+ args, num_args);
+
+ num_args = 0;
+ XtSetArg(args[num_args], XtNlabel, "Replace"); num_args++;
+ XtSetArg(args[num_args], XtNfromVert, r_text); num_args++;
+ XtSetArg(args[num_args], XtNfromHoriz, search_button); num_args++;
+ XtSetArg(args[num_args], XtNleft, XtChainLeft); num_args++;
+ XtSetArg(args[num_args], XtNright, XtChainLeft); num_args++;
+ search->rep_one = XtCreateManagedWidget("replaceOne", commandWidgetClass,
+ form, args, num_args);
+
+ num_args = 0;
+ XtSetArg(args[num_args], XtNlabel, "Replace All"); num_args++;
+ XtSetArg(args[num_args], XtNfromVert, r_text); num_args++;
+ XtSetArg(args[num_args], XtNfromHoriz, search->rep_one); num_args++;
+ XtSetArg(args[num_args], XtNleft, XtChainLeft); num_args++;
+ XtSetArg(args[num_args], XtNright, XtChainLeft); num_args++;
+ search->rep_all = XtCreateManagedWidget("replaceAll", commandWidgetClass,
+ form, args, num_args);
+
+ num_args = 0;
+ XtSetArg(args[num_args], XtNlabel, "Cancel"); num_args++;
+ XtSetArg(args[num_args], XtNfromVert, r_text); num_args++;
+ XtSetArg(args[num_args], XtNfromHoriz, search->rep_all); num_args++;
+ XtSetArg(args[num_args], XtNleft, XtChainLeft); num_args++;
+ XtSetArg(args[num_args], XtNright, XtChainLeft); num_args++;
+ cancel = XtCreateManagedWidget(DISMISS_NAME, commandWidgetClass, form,
+ args, num_args);
+
+ XtAddCallback(search_button, XtNcallback, SearchButton, (XtPointer) search);
+ XtAddCallback(search->rep_one, XtNcallback, DoReplaceOne, (XtPointer) search);
+ XtAddCallback(search->rep_all, XtNcallback, DoReplaceAll, (XtPointer) search);
+ XtAddCallback(cancel, XtNcallback, PopdownSearch, (XtPointer) search);
+
+/*
+ * Initialize the text entry fields.
+ */
+
+ {
+ Pixel color;
+ num_args = 0;
+ XtSetArg(args[num_args], XtNbackground, &color); num_args++;
+ XtGetValues(search->rep_text, args, num_args);
+ num_args = 0;
+ XtSetArg(args[num_args], XtNborderColor, color); num_args++;
+ XtSetValues(search->rep_text, args, num_args);
+ XtSetKeyboardFocus(form, search->search_text);
+ }
+
+ SetSearchLabels(search, SEARCH_LABEL_1, SEARCH_LABEL_2, FALSE);
+
+/*
+ * Bind Extra translations.
+ */
+
+ trans = XtParseTranslationTable(search_text_trans);
+ XtOverrideTranslations(search->search_text, trans);
+
+ trans = XtParseTranslationTable(rep_text_trans);
+ XtOverrideTranslations(search->rep_text, trans);
+}
+
+/* Function Name: DoSearch
+ * Description: Performs a search.
+ * Arguments: search - the serach structure.
+ * Returns: TRUE if sucessful.
+ */
+
+/* ARGSUSED */
+static Boolean
+DoSearch(search)
+struct SearchAndReplace * search;
+{
+ Widget tw = XtParent(search->search_popup);
+ XawTextPosition pos;
+ XawTextScanDirection dir;
+ XawTextBlock text;
+
+ TextWidget ctx = (TextWidget)tw;
+
+ text.ptr = GetStringRaw(search->search_text);
+ if ((text.format = _XawTextFormat(ctx)) == XawFmtWide)
+ text.length = wcslen((wchar_t*)text.ptr);
+ else
+ text.length = strlen(text.ptr);
+ text.firstPos = 0;
+
+ dir = (XawTextScanDirection)(int) ((XPointer)XawToggleGetCurrent(search->left_toggle) -
+ R_OFFSET);
+
+ pos = XawTextSearch( tw, dir, &text);
+
+
+ /* The Raw string in find.ptr may be WC I can't use here, so I re - call
+ GetString to get a tame version. */
+
+ if (pos == XawTextSearchError) {
+ char msgbuf[BUFSIZ];
+ char* msg;
+ char* fmt = "Could not find string \"%s\"";
+ int len = strlen (fmt) + strlen (GetString (search->search_text));
+
+ if (len < sizeof msgbuf) msg = msgbuf;
+ else msg = XtMalloc (len + 1);
+ if (msg == NULL) {
+ msg = msgbuf;
+ strcpy (msg, "Could not find string.");
+ } else
+ (void) sprintf (msg, fmt, GetString (search->search_text));
+ XawTextUnsetSelection(tw);
+ SetSearchLabels(search, msg, "", TRUE);
+ if (msg != msgbuf) XtFree (msg);
+ return FALSE;
+ }
+ if (dir == XawsdRight)
+ XawTextSetInsertionPoint( tw, pos + text.length);
+ else
+ XawTextSetInsertionPoint( tw, pos);
+
+ XawTextSetSelection( tw, pos, pos + text.length);
+ search->selection_changed = FALSE; /* selection is good. */
+ return TRUE;
+}
+
+/************************************************************
+ *
+ * This section of the file contains all the functions that
+ * the replace dialog box uses.
+ *
+ ************************************************************/
+
+/* Function Name: _XawTextDoReplaceAction
+ * Description: Action routine that can be bound to dialog box's
+ * Text Widget that will replace a string in the main
+ * Text Widget.
+ * Arguments: (Standard Action Routine args)
+ * Returns: none.
+ */
+
+/* ARGSUSED */
+void
+_XawTextDoReplaceAction(w, event, params, num_params)
+Widget w;
+XEvent *event;
+String * params;
+Cardinal * num_params;
+{
+ TextWidget ctx = (TextWidget) XtParent(XtParent(XtParent(w)));
+ Boolean popdown = FALSE;
+
+ if ( (*num_params == 1) &&
+ ((params[0][0] == 'p') || (params[0][0] == 'P')) )
+ popdown = TRUE;
+
+ if (Replace( ctx->text.search, TRUE, popdown) && popdown)
+ PopdownSearch(w, (XtPointer) ctx->text.search, (XtPointer)NULL);
+}
+
+/* Function Name: DoReplaceOne
+ * Description: Replaces the first instance of the string
+ * in the search dialog's text widget
+ * with the one in the replace dialog's text widget.
+ * Arguments: w - *** Not Used ***.
+ * closure - a pointer to the search structure.
+ * call_data - *** Not Used ***.
+ * Returns: none.
+ */
+
+/* ARGSUSED */
+static void
+DoReplaceOne(w, closure, call_data)
+Widget w; /* The Button Pressed. */
+XtPointer closure; /* Text Widget. */
+XtPointer call_data; /* unused */
+{
+ Replace( (struct SearchAndReplace *) closure, TRUE, FALSE);
+}
+
+/* Function Name: DoReplaceOne
+ * Description: Replaces every instance of the string
+ * in the search dialog's text widget
+ * with the one in the replace dialog's text widget.
+ * Arguments: w - *** Not Used ***.
+ * closure - a pointer to the search structure.
+ * call_data - *** Not Used ***.
+ * Returns: none.
+ */
+
+/* ARGSUSED */
+static void
+DoReplaceAll(w, closure, call_data)
+Widget w; /* The Button Pressed. */
+XtPointer closure; /* Text Widget. */
+XtPointer call_data; /* unused */
+{
+ Replace( (struct SearchAndReplace *) closure, FALSE, FALSE);
+}
+
+/* Function Name: Replace
+ * Description: This is the function that does the real work of
+ * replacing strings in the main text widget.
+ * Arguments: tw - the Text Widget to replce the string in.
+ * once_only - If TRUE then only replace the first one found.
+ * other replace all of them.
+ * show_current - If true then leave the selection on the
+ * string that was just replaced, otherwise
+ * move it onto the next one.
+ * Returns: none.
+ */
+
+static Boolean
+Replace(search, once_only, show_current)
+struct SearchAndReplace * search;
+Boolean once_only, show_current;
+{
+ XawTextPosition pos, new_pos, end_pos;
+ XawTextScanDirection dir;
+ XawTextBlock find, replace;
+ Widget tw = XtParent(search->search_popup);
+ int count = 0;
+
+ TextWidget ctx = (TextWidget)tw;
+
+ find.ptr = GetStringRaw( search->search_text);
+ if ((find.format = _XawTextFormat(ctx)) == XawFmtWide)
+ find.length = wcslen((wchar_t*)find.ptr);
+ else
+ find.length = strlen(find.ptr);
+ find.firstPos = 0;
+
+ replace.ptr = GetStringRaw(search->rep_text);
+ replace.firstPos = 0;
+ if ((replace.format = _XawTextFormat(ctx)) == XawFmtWide)
+ replace.length = wcslen((wchar_t*)replace.ptr);
+ else
+ replace.length = strlen(replace.ptr);
+
+ dir = (XawTextScanDirection)(int) ((XPointer)XawToggleGetCurrent(search->left_toggle) -
+ R_OFFSET);
+ /* CONSTCOND */
+ while (TRUE) {
+ if (count != 0) {
+ new_pos = XawTextSearch( tw, dir, &find);
+
+ if ( (new_pos == XawTextSearchError) ) {
+ if (count == 0) {
+ char msgbuf[BUFSIZ];
+ char* msg;
+ int len;
+ char* fmt = "*** Error: Could not find string \"%s\" ***";
+
+ len = strlen (fmt) + strlen (GetString (search->search_text));
+ if (len < sizeof msgbuf) msg = msgbuf;
+ else msg = XtMalloc (len + 1);
+ if (msg == NULL) {
+ msg = msgbuf;
+ strcpy (msg, "*** Error: Could not find string. ***");
+ } else
+ (void) sprintf (msg, fmt, GetString (search->search_text));
+ SetSearchLabels(search, msg, "", TRUE);
+ if (msg != msgbuf) XtFree (msg);
+ return FALSE;
+ }
+ else
+ break;
+ }
+ pos = new_pos;
+ end_pos = pos + find.length;
+ }
+ else {
+ XawTextGetSelectionPos(tw, &pos, &end_pos);
+
+ if (search->selection_changed) {
+ SetSearchLabels(search, "Selection has been modified, aborting.",
+ "", TRUE);
+ return(FALSE);
+ }
+ if (pos == end_pos)
+ return(FALSE);
+ }
+
+ if (XawTextReplace(tw, pos, end_pos, &replace) != XawEditDone) {
+ char msgbuf[BUFSIZ];
+ char* msg;
+ int len;
+ char* fmt = "'%s' with '%s'. ***";
+
+ len = strlen (fmt) + strlen (find.ptr) + strlen (replace.ptr);
+ if (len < sizeof msgbuf) msg = msgbuf;
+ else msg = XtMalloc (len + 1);
+ if (msg == NULL) {
+ msg = msgbuf;
+ strcpy (msg, "long strings");
+ } else
+ (void) sprintf( msg, fmt, find.ptr, replace.ptr);
+ SetSearchLabels(search, "*** Error while replacing", msg, TRUE);
+ if (msg != msgbuf) XtFree (msg);
+ return FALSE;
+ }
+
+ if (dir == XawsdRight)
+ XawTextSetInsertionPoint( tw, pos + replace.length);
+ else
+ XawTextSetInsertionPoint( tw, pos);
+
+ if (once_only)
+ if (show_current)
+ break;
+ else {
+ DoSearch(search);
+ return(TRUE);
+ }
+ count++;
+ }
+
+ if (replace.length == 0)
+ XawTextUnsetSelection(tw);
+ else
+ XawTextSetSelection( tw, pos, pos + replace.length);
+
+ return TRUE;
+}
+
+/* Function Name: SetSearchLabels
+ * Description: Sets both the search labels, and also rings the bell
+ * Arguments: search - the search structure.
+ * msg1, msg2 - message to put in each search label.
+ * bell - if TRUE then ring bell.
+ * Returns: none.
+ */
+
+static void
+SetSearchLabels(search, msg1, msg2, bell)
+struct SearchAndReplace * search;
+String msg1, msg2;
+Boolean bell;
+{
+ (void) SetResource( search->label1, XtNlabel, (XtArgVal) msg1);
+ (void) SetResource( search->label2, XtNlabel, (XtArgVal) msg2);
+ if (bell)
+ XBell(XtDisplay(search->search_popup), 0);
+}
+
+/************************************************************
+ *
+ * This section of the file contains utility routines used by
+ * other functions in this file.
+ *
+ ************************************************************/
+
+
+/* Function Name: _XawTextSetField
+ * Description: Action routine that can be bound to dialog box's
+ * Text Widget that will send input to the field specified.
+ * Arguments: (Standard Action Routine args)
+ * Returns: none.
+ */
+
+/* ARGSUSED */
+void
+_XawTextSetField(w, event, params, num_params)
+Widget w;
+XEvent *event;
+String * params;
+Cardinal * num_params;
+{
+ struct SearchAndReplace * search;
+ Widget new, old;
+
+ search = ((TextWidget) XtParent(XtParent(XtParent(w))))->text.search;
+
+ if (*num_params != 1) {
+ SetSearchLabels(search, "*** Error: SetField Action must have",
+ "exactly one argument. ***", TRUE);
+ return;
+ }
+ switch (params[0][0]) {
+ case 's':
+ case 'S':
+ new = search->search_text;
+ old = search->rep_text;
+ break;
+ case 'r':
+ case 'R':
+ old = search->search_text;
+ new = search->rep_text;
+ break;
+ default:
+ SetSearchLabels(search, "*** Error: SetField Action's first Argument must",
+ "be either 'Search' or 'Replace'. ***", TRUE);
+ return;
+ }
+ _SetField(new, old);
+}
+
+/* Function Name: SetField
+ * Description: Sets the current text field.
+ * Arguments: new, old - new and old text fields.
+ * Returns: none
+ */
+
+static void
+_SetField(new, old)
+Widget new, old;
+{
+ Arg args[2];
+ Pixel new_border, old_border, old_bg;
+
+ if (!XtIsSensitive(new)) {
+ XBell(XtDisplay(old), 0); /* Don't set field to an inactive Widget. */
+ return;
+ }
+
+ XtSetKeyboardFocus(XtParent(new), new);
+
+ XtSetArg(args[0], XtNborderColor, &old_border);
+ XtSetArg(args[1], XtNbackground, &old_bg);
+ XtGetValues(new, args, TWO);
+
+ XtSetArg(args[0], XtNborderColor, &new_border);
+ XtGetValues(old, args, ONE);
+
+ if (old_border != old_bg) /* Colors are already correct, return. */
+ return;
+
+ SetResource(old, XtNborderColor, (XtArgVal) old_border);
+ SetResource(new, XtNborderColor, (XtArgVal) new_border);
+}
+
+/* Function Name: SetResourceByName
+ * Description: Sets a resource in any of the dialog children given
+ * name of the child and the shell widget of the dialog.
+ * Arguments: shell - shell widget of the popup.
+ * name - name of the child.
+ * res_name - name of the resource.
+ * value - the value of the resource.
+ * Returns: TRUE if sucessful.
+ */
+
+static Boolean
+SetResourceByName(shell, name, res_name, value)
+Widget shell;
+char * name, * res_name;
+XtArgVal value;
+{
+ Widget temp_widget;
+ char buf[BUFSIZ];
+ char* bufp;
+ int len = strlen (FORM_NAME) + strlen (name) + 1;
+ Boolean ret = FALSE;
+
+ if (len < sizeof buf) bufp = buf;
+ else bufp = XtMalloc (len + 1);
+
+ if (bufp == NULL) return FALSE;
+
+ (void) sprintf(bufp, "%s.%s", FORM_NAME, name);
+
+ if ( (temp_widget = XtNameToWidget(shell, bufp)) != NULL) {
+ SetResource(temp_widget, res_name, value);
+ ret = TRUE;
+ }
+ if (bufp != buf) XtFree (bufp);
+ return ret;
+}
+
+/* Function Name: SetResource
+ * Description: Sets a resource in a widget
+ * Arguments: w - the widget.
+ * res_name - name of the resource.
+ * value - the value of the resource.
+ * Returns: none.
+ */
+
+static void
+SetResource(w, res_name, value)
+Widget w;
+char * res_name;
+XtArgVal value;
+{
+ Arg args[1];
+
+ XtSetArg(args[0], res_name, value);
+ XtSetValues( w, args, ONE );
+}
+
+/* Function Name: GetString{Raw}
+ * Description: Gets the value for the string in the popup.
+ * Arguments: text - the text widget whose string we will get.
+ *
+ * GetString returns the string as a MB.
+ * GetStringRaw returns the exact buffer contents suitable for a search.
+ *
+ */
+
+static String
+GetString(text)
+Widget text;
+{
+ String string;
+ Arg args[1];
+
+ XtSetArg( args[0], XtNstring, &string );
+ XtGetValues( text, args, ONE );
+ return(string);
+}
+
+static String
+GetStringRaw(tw)
+Widget tw;
+{
+ TextWidget ctx = (TextWidget)tw;
+ XawTextPosition last;
+ char *_XawTextGetText();
+
+ last = XawTextSourceScan(ctx->text.source, 0, XawstAll, XawsdRight,
+ ctx->text.mult, TRUE);
+ return (_XawTextGetText(ctx, 0, last));
+}
+
+/* Function Name: CenterWidgetOnPoint.
+ * Description: Centers a shell widget on a point relative to
+ * the root window.
+ * Arguments: w - the shell widget.
+ * event - event containing the location of the point
+ * Returns: none.
+ *
+ * NOTE: The widget is not allowed to go off the screen.
+ */
+
+static void
+CenterWidgetOnPoint(w, event)
+Widget w;
+XEvent *event;
+{
+ Arg args[3];
+ Cardinal num_args;
+ Dimension width, height, b_width;
+ Position x, y, max_x, max_y;
+
+ if (event != NULL) {
+ switch (event->type) {
+ case ButtonPress:
+ case ButtonRelease:
+ x = event->xbutton.x_root;
+ y = event->xbutton.y_root;
+ break;
+ case KeyPress:
+ case KeyRelease:
+ x = event->xkey.x_root;
+ y = event->xkey.y_root;
+ break;
+ default:
+ return;
+ }
+ }
+
+ num_args = 0;
+ XtSetArg(args[num_args], XtNwidth, &width); num_args++;
+ XtSetArg(args[num_args], XtNheight, &height); num_args++;
+ XtSetArg(args[num_args], XtNborderWidth, &b_width); num_args++;
+ XtGetValues(w, args, num_args);
+
+ width += 2 * b_width;
+ height += 2 * b_width;
+
+ x -= ( (Position) width/2 );
+ if (x < 0) x = 0;
+ if ( x > (max_x = (Position) (XtScreen(w)->width - width)) ) x = max_x;
+
+ y -= ( (Position) height/2 );
+ if (y < 0) y = 0;
+ if ( y > (max_y = (Position) (XtScreen(w)->height - height)) ) y = max_y;
+
+ num_args = 0;
+ XtSetArg(args[num_args], XtNx, x); num_args++;
+ XtSetArg(args[num_args], XtNy, y); num_args++;
+ XtSetValues(w, args, num_args);
+}
+
+/* Function Name: CreateDialog
+ * Description: Actually creates a dialog.
+ * Arguments: parent - the parent of the dialog - the main text widget.
+ * ptr - initial_string for the dialog.
+ * name - name of the dialog.
+ * func - function to create the children of the dialog.
+ * Returns: the popup shell of the dialog.
+ *
+ * NOTE:
+ *
+ * The function argument is passed the following arguements.
+ *
+ * form - the from widget that is the dialog.
+ * ptr - the initial string for the dialog's text widget.
+ * parent - the parent of the dialog - the main text widget.
+ */
+
+static Widget
+CreateDialog(parent, ptr, name, func)
+Widget parent;
+String ptr, name;
+void (*func)();
+{
+ Widget popup, form;
+ Arg args[5];
+ Cardinal num_args;
+
+ num_args = 0;
+ XtSetArg(args[num_args], XtNiconName, name); num_args++;
+ XtSetArg(args[num_args], XtNgeometry, NULL); num_args++;
+ XtSetArg(args[num_args], XtNallowShellResize, TRUE); num_args++;
+ XtSetArg(args[num_args], XtNtransientFor, GetShell(parent)); num_args++;
+ popup = XtCreatePopupShell(name, transientShellWidgetClass,
+ parent, args, num_args);
+
+ form = XtCreateManagedWidget(FORM_NAME, formWidgetClass, popup,
+ (ArgList)NULL, ZERO);
+ XtManageChild (form);
+
+ (*func) (form, ptr, parent);
+ return(popup);
+}
+
+ /* Function Name: GetShell
+ * Description: Walks up the widget hierarchy to find the
+ * nearest shell widget.
+ * Arguments: w - the widget whose parent shell should be returned.
+ * Returns: The shell widget among the ancestors of w that is the
+ * fewest levels up in the widget hierarchy.
+ */
+
+static Widget
+GetShell(w)
+Widget w;
+{
+ while ((w != NULL) && !XtIsShell(w))
+ w = XtParent(w);
+
+ return (w);
+}
+
+static Boolean InParams(str, p, n)
+ String str;
+ String *p;
+ Cardinal n;
+{
+ int i;
+ for (i=0; i < n; p++, i++)
+ if (! XmuCompareISOLatin1(*p, str)) return True;
+ return False;
+}
+
+static char *WM_DELETE_WINDOW = "WM_DELETE_WINDOW";
+
+static void WMProtocols(w, event, params, num_params)
+ Widget w; /* popup shell */
+ XEvent *event;
+ String *params;
+ Cardinal *num_params;
+{
+ Atom wm_delete_window;
+ Atom wm_protocols;
+
+ wm_delete_window = XInternAtom(XtDisplay(w), WM_DELETE_WINDOW, True);
+ wm_protocols = XInternAtom(XtDisplay(w), "WM_PROTOCOLS", True);
+
+ /* Respond to a recognized WM protocol request iff
+ * event type is ClientMessage and no parameters are passed, or
+ * event type is ClientMessage and event data is matched to parameters, or
+ * event type isn't ClientMessage and parameters make a request.
+ */
+#define DO_DELETE_WINDOW InParams(WM_DELETE_WINDOW, params, *num_params)
+
+ if ((event->type == ClientMessage &&
+ event->xclient.message_type == wm_protocols &&
+ event->xclient.data.l[0] == wm_delete_window &&
+ (*num_params == 0 || DO_DELETE_WINDOW))
+ ||
+ (event->type != ClientMessage && DO_DELETE_WINDOW)) {
+
+#undef DO_DELETE_WINDOW
+
+ Widget cancel;
+ char descendant[DISMISS_NAME_LEN + 2];
+ (void) sprintf(descendant, "*%s", DISMISS_NAME);
+ cancel = XtNameToWidget(w, descendant);
+ if (cancel) XtCallCallbacks(cancel, XtNcallback, (XtPointer)NULL);
+ }
+}
+
+static void SetWMProtocolTranslations(w)
+ Widget w; /* realized popup shell */
+{
+ int i;
+ XtAppContext app_context;
+ Atom wm_delete_window;
+ static XtTranslations compiled_table; /* initially 0 */
+ static XtAppContext *app_context_list; /* initially 0 */
+ static Cardinal list_size; /* initially 0 */
+
+ app_context = XtWidgetToApplicationContext(w);
+
+ /* parse translation table once */
+ if (! compiled_table) compiled_table = XtParseTranslationTable
+ ("<Message>WM_PROTOCOLS: XawWMProtocols()\n");
+
+ /* add actions once per application context */
+ for (i=0; i < list_size && app_context_list[i] != app_context; i++) ;
+ if (i == list_size) {
+ XtActionsRec actions[1];
+ actions[0].string = "XawWMProtocols";
+ actions[0].proc = WMProtocols;
+ list_size++;
+ app_context_list = (XtAppContext *) XtRealloc
+ ((char *)app_context_list, list_size * sizeof(XtAppContext));
+ XtAppAddActions(app_context, actions, 1);
+ app_context_list[i] = app_context;
+ }
+
+ /* establish communication between the window manager and each shell */
+ XtAugmentTranslations(w, compiled_table);
+ wm_delete_window = XInternAtom(XtDisplay(w), WM_DELETE_WINDOW, False);
+ (void) XSetWMProtocols(XtDisplay(w), XtWindow(w), &wm_delete_window, 1);
+}
diff --git a/src/TextSink.c b/src/TextSink.c
new file mode 100644
index 0000000..1a37716
--- /dev/null
+++ b/src/TextSink.c
@@ -0,0 +1,778 @@
+/* $Xorg: TextSink.c,v 1.4 2001/02/09 02:03:46 xorgcvs Exp $ */
+/*
+
+Copyright 1989, 1994, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+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
+OPEN GROUP 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 Open Group 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 Open Group.
+
+*/
+
+/*
+ * 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>
+#include <X11/Xaw/XawInit.h>
+#include <X11/Xaw/TextSinkP.h>
+#include <X11/Xaw/TextP.h>
+
+/****************************************************************
+ *
+ * Full class record constant
+ *
+ ****************************************************************/
+
+static void ClassPartInitialize(), Initialize(), Destroy();
+static Boolean SetValues();
+
+static int MaxHeight(), MaxLines();
+static void DisplayText(), InsertCursor(), ClearToBackground(), FindPosition();
+static void FindDistance(), Resolve(), SetTabs(), GetCursorBounds();
+
+#define offset(field) XtOffsetOf(TextSinkRec, text_sink.field)
+static XtResource resources[] = {
+ {XtNforeground, XtCForeground, XtRPixel, sizeof (Pixel),
+ offset(foreground), XtRString, XtDefaultForeground},
+ {XtNbackground, XtCBackground, XtRPixel, sizeof (Pixel),
+ offset(background), XtRString, XtDefaultBackground},
+};
+#undef offset
+
+#define SuperClass (&objectClassRec)
+TextSinkClassRec textSinkClassRec = {
+ {
+/* core_class fields */
+ /* superclass */ (WidgetClass) SuperClass,
+ /* 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,
+ /* num_resources */ XtNumber(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,
+ }
+};
+
+WidgetClass textSinkObjectClass = (WidgetClass)&textSinkClassRec;
+
+static void
+ClassPartInitialize(wc)
+WidgetClass wc;
+{
+ TextSinkObjectClass t_src, superC;
+
+ t_src = (TextSinkObjectClass) wc;
+ superC = (TextSinkObjectClass) t_src->object_class.superclass;
+
+/*
+ * We don't need to check for null super since we'll get to TextSink
+ * eventually.
+ */
+
+ if (t_src->text_sink_class.DisplayText == XtInheritDisplayText)
+ t_src->text_sink_class.DisplayText = superC->text_sink_class.DisplayText;
+
+ if (t_src->text_sink_class.InsertCursor == XtInheritInsertCursor)
+ t_src->text_sink_class.InsertCursor =
+ superC->text_sink_class.InsertCursor;
+
+ if (t_src->text_sink_class.ClearToBackground== XtInheritClearToBackground)
+ t_src->text_sink_class.ClearToBackground =
+ superC->text_sink_class.ClearToBackground;
+
+ if (t_src->text_sink_class.FindPosition == XtInheritFindPosition)
+ t_src->text_sink_class.FindPosition =
+ superC->text_sink_class.FindPosition;
+
+ if (t_src->text_sink_class.FindDistance == XtInheritFindDistance)
+ t_src->text_sink_class.FindDistance =
+ superC->text_sink_class.FindDistance;
+
+ if (t_src->text_sink_class.Resolve == XtInheritResolve)
+ t_src->text_sink_class.Resolve = superC->text_sink_class.Resolve;
+
+ if (t_src->text_sink_class.MaxLines == XtInheritMaxLines)
+ t_src->text_sink_class.MaxLines = superC->text_sink_class.MaxLines;
+
+ if (t_src->text_sink_class.MaxHeight == XtInheritMaxHeight)
+ t_src->text_sink_class.MaxHeight = superC->text_sink_class.MaxHeight;
+
+ if (t_src->text_sink_class.SetTabs == XtInheritSetTabs)
+ t_src->text_sink_class.SetTabs = superC->text_sink_class.SetTabs;
+
+ if (t_src->text_sink_class.GetCursorBounds == XtInheritGetCursorBounds)
+ t_src->text_sink_class.GetCursorBounds =
+ superC->text_sink_class.GetCursorBounds;
+}
+
+/* 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
+Initialize(request, new, args, num_args)
+Widget request, new;
+ArgList args;
+Cardinal *num_args;
+{
+ TextSinkObject sink = (TextSinkObject) new;
+
+ sink->text_sink.tab_count = 0; /* Initialize the tab stops. */
+ sink->text_sink.tabs = NULL;
+ sink->text_sink.char_tabs = NULL;
+}
+
+/* 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;
+{
+ TextSinkObject sink = (TextSinkObject) w;
+
+ XtFree((char *) sink->text_sink.tabs);
+ XtFree((char *) sink->text_sink.char_tabs);
+}
+
+/* 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
+SetValues(current, request, new, args, num_args)
+Widget current, request, new;
+ArgList args;
+Cardinal *num_args;
+{
+ TextSinkObject w = (TextSinkObject) new;
+ TextSinkObject old_w = (TextSinkObject) current;
+
+ if (w->text_sink.foreground != old_w->text_sink.foreground)
+ ((TextWidget)XtParent(new))->text.redisplay_needed = True;
+
+ 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
+DisplayText(w, x, y, pos1, pos2, highlight)
+Widget w;
+Position x, y;
+Boolean highlight;
+XawTextPosition pos1, pos2;
+{
+ 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
+InsertCursor(w, x, y, state)
+Widget w;
+Position x, y;
+XawTextInsertState state;
+{
+ 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
+ClearToBackground (w, x, y, width, height)
+Widget w;
+Position x, y;
+Dimension width, height;
+{
+/*
+ * Don't clear in height or width are zero.
+ * XClearArea() has special semantic for these values.
+ */
+
+ if ( (height == 0) || (width == 0) ) return;
+ XClearArea(XtDisplayOfObject(w), XtWindowOfObject(w),
+ x, y, width, height, False);
+}
+
+/* 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
+FindPosition(w, fromPos, fromx, width, stopAtWordBreak,
+ resPos, resWidth, resHeight)
+Widget w;
+XawTextPosition fromPos;
+int fromx, width;
+Boolean stopAtWordBreak;
+XawTextPosition *resPos;
+int *resWidth, *resHeight;
+{
+ *resPos = fromPos;
+ *resHeight = *resWidth = 0;
+}
+
+/* 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
+FindDistance (w, fromPos, fromx, toPos, resWidth, resPos, resHeight)
+Widget w;
+XawTextPosition fromPos;
+int fromx;
+XawTextPosition toPos;
+int *resWidth;
+XawTextPosition *resPos;
+int *resHeight;
+{
+ *resWidth = *resHeight = 0;
+ *resPos = fromPos;
+}
+
+/* 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
+Resolve (w, pos, fromx, width, resPos)
+Widget w;
+XawTextPosition pos;
+int fromx, width;
+XawTextPosition *resPos;
+{
+ *resPos = pos;
+}
+
+/* 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
+MaxLines(w, height)
+Widget w;
+Dimension height;
+{
+ /*
+ * 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
+MaxHeight(w, lines)
+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
+SetTabs(w, tab_count, tabs)
+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
+GetCursorBounds(w, rect)
+Widget w;
+XRectangle * rect;
+{
+ rect->x = rect->y = rect->width = rect->height = 0;
+}
+/************************************************************
+ *
+ * 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
+#if NeedFunctionPrototypes
+XawTextSinkDisplayText(Widget w,
+#if NeedWidePrototypes
+ /* Position */ int x, /* Position */ int y,
+#else
+ Position x, Position y,
+#endif
+ XawTextPosition pos1, XawTextPosition pos2,
+#if NeedWidePrototypes
+ /* Boolean */ int highlight)
+#else
+ Boolean highlight)
+#endif
+#else
+XawTextSinkDisplayText(w, x, y, pos1, pos2, highlight)
+Widget w;
+Position x, y;
+Boolean highlight;
+XawTextPosition pos1, pos2;
+#endif
+{
+ TextSinkObjectClass class = (TextSinkObjectClass) w->core.widget_class;
+
+ (*class->text_sink_class.DisplayText)(w, x, y, pos1, pos2, highlight);
+}
+
+/* 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
+#if NeedFunctionPrototypes
+XawTextSinkInsertCursor(Widget w,
+#if NeedWidePrototypes
+ int x, int y, int state)
+#else
+ Position x, Position y, XawTextInsertState state)
+#endif
+#else
+XawTextSinkInsertCursor(w, x, y, state)
+Widget w;
+Position x, y;
+XawTextInsertState state;
+#endif
+{
+ TextSinkObjectClass class = (TextSinkObjectClass) w->core.widget_class;
+
+ (*class->text_sink_class.InsertCursor)(w, x, y, state);
+}
+
+
+/* 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
+#if NeedFunctionPrototypes
+XawTextSinkClearToBackground (Widget w,
+#if NeedWidePrototypes
+ int x, int y, int width, int height)
+#else
+ Position x, Position y,
+ Dimension width, Dimension height)
+#endif
+#else
+XawTextSinkClearToBackground (w, x, y, width, height)
+Widget w;
+Position x, y;
+Dimension width, height;
+#endif
+{
+ TextSinkObjectClass class = (TextSinkObjectClass) w->core.widget_class;
+
+ (*class->text_sink_class.ClearToBackground)(w, x, y, width, height);
+}
+
+/* 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
+#if NeedFunctionPrototypes
+XawTextSinkFindPosition(Widget w, XawTextPosition fromPos, int fromx,
+ int width,
+#if NeedWidePrototypes
+ /* Boolean */ int stopAtWordBreak,
+#else
+ Boolean stopAtWordBreak,
+#endif
+ XawTextPosition *resPos, int *resWidth, int *resHeight)
+#else
+XawTextSinkFindPosition(w, fromPos, fromx, width, stopAtWordBreak,
+ resPos, resWidth, resHeight)
+Widget w;
+XawTextPosition fromPos;
+int fromx, width;
+Boolean stopAtWordBreak;
+XawTextPosition *resPos;
+int *resWidth, *resHeight;
+#endif
+{
+ TextSinkObjectClass class = (TextSinkObjectClass) w->core.widget_class;
+
+ (*class->text_sink_class.FindPosition)(w, fromPos, fromx, width,
+ stopAtWordBreak,
+ resPos, resWidth, resHeight);
+}
+
+/* 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
+#if NeedFunctionPrototypes
+XawTextSinkFindDistance (Widget w, XawTextPosition fromPos, int fromx,
+ XawTextPosition toPos, int *resWidth,
+ XawTextPosition *resPos, int *resHeight)
+#else
+XawTextSinkFindDistance (w, fromPos, fromx, toPos, resWidth, resPos, resHeight)
+Widget w;
+XawTextPosition fromPos, toPos, *resPos;
+int fromx, *resWidth, *resHeight;
+#endif
+{
+ TextSinkObjectClass class = (TextSinkObjectClass) w->core.widget_class;
+
+ (*class->text_sink_class.FindDistance)(w, fromPos, fromx, toPos,
+ resWidth, resPos, resHeight);
+}
+
+/* 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
+#if NeedFunctionPrototypes
+XawTextSinkResolve(Widget w, XawTextPosition pos, int fromx, int width,
+ XawTextPosition *resPos)
+#else
+XawTextSinkResolve(w, pos, fromx, width, resPos)
+Widget w;
+XawTextPosition pos;
+int fromx, width;
+XawTextPosition *resPos;
+#endif
+{
+ TextSinkObjectClass class = (TextSinkObjectClass) w->core.widget_class;
+
+ (*class->text_sink_class.Resolve)(w, pos, fromx, width, resPos);
+}
+
+/* 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
+#if NeedFunctionPrototypes
+XawTextSinkMaxLines(Widget w,
+#if NeedWidePrototypes
+ /* Dimension */ int height)
+#else
+ Dimension height)
+#endif
+#else
+XawTextSinkMaxLines(w, height)
+Widget w;
+Dimension height;
+#endif
+{
+ TextSinkObjectClass class = (TextSinkObjectClass) w->core.widget_class;
+
+ return((*class->text_sink_class.MaxLines)(w, height));
+}
+
+/* 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
+#if NeedFunctionPrototypes
+XawTextSinkMaxHeight(Widget w, int lines)
+#else
+XawTextSinkMaxHeight(w, lines)
+Widget w;
+int lines;
+#endif
+{
+ TextSinkObjectClass class = (TextSinkObjectClass) w->core.widget_class;
+
+ return((*class->text_sink_class.MaxHeight)(w, 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.
+ * Returns: none
+ */
+
+void
+#if NeedFunctionPrototypes
+XawTextSinkSetTabs(Widget w, int tab_count, int *tabs)
+#else
+XawTextSinkSetTabs(w, tab_count, tabs)
+Widget w;
+int tab_count, *tabs;
+#endif
+{
+ if (tab_count > 0) {
+ TextSinkObjectClass class = (TextSinkObjectClass) w->core.widget_class;
+ short *char_tabs = (short*)XtMalloc( (unsigned)tab_count*sizeof(short) );
+ short *tab;
+ int i;
+
+ for (i = tab_count, tab = char_tabs; i; i--) *tab++ = (short)*tabs++;
+
+ (*class->text_sink_class.SetTabs)(w, tab_count, char_tabs);
+ XtFree((char *)char_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).
+ */
+
+/* ARGSUSED */
+void
+#if NeedFunctionPrototypes
+XawTextSinkGetCursorBounds(Widget w, XRectangle *rect)
+#else
+XawTextSinkGetCursorBounds(w, rect)
+Widget w;
+XRectangle * rect;
+#endif
+{
+ TextSinkObjectClass class = (TextSinkObjectClass) w->core.widget_class;
+
+ (*class->text_sink_class.GetCursorBounds)(w, rect);
+}
diff --git a/src/TextSrc.c b/src/TextSrc.c
new file mode 100644
index 0000000..d36040f
--- /dev/null
+++ b/src/TextSrc.c
@@ -0,0 +1,678 @@
+/* $Xorg: TextSrc.c,v 1.5 2001/02/09 02:03:47 xorgcvs Exp $ */
+/*
+
+Copyright 1989, 1994, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+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
+OPEN GROUP 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 Open Group 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 Open Group.
+
+*/
+
+/*
+ * Author: Chris Peterson, MIT X Consortium.
+ * Much code taken from X11R3 String and Disk Sources.
+ */
+
+/*
+ * TextSrc.c - TextSrc object. (For use with the text widget).
+ *
+ */
+
+#include <X11/IntrinsicP.h>
+#include <X11/StringDefs.h>
+#include <X11/Xutil.h>
+#include <X11/Xaw/XawInit.h>
+#include <X11/Xaw/TextSrcP.h>
+#include <X11/Xmu/Atoms.h>
+#include <X11/Xmu/CharSet.h>
+#include "XawI18n.h"
+#include <stdio.h>
+#include <ctype.h>
+
+/****************************************************************
+ *
+ * Full class record constant
+ *
+ ****************************************************************/
+
+/* Private Data */
+
+#define offset(field) XtOffsetOf(TextSrcRec, textSrc.field)
+static XtResource resources[] = {
+ {XtNeditType, XtCEditType, XtREditMode, sizeof(XawTextEditType),
+ offset(edit_mode), XtRString, "read"},
+};
+
+static void ClassInitialize(), ClassPartInitialize(), SetSelection();
+static void CvtStringToEditMode();
+static Boolean ConvertSelection();
+static XawTextPosition Search(), Scan(), Read();
+static int Replace();
+
+#define SuperClass (&objectClassRec)
+TextSrcClassRec textSrcClassRec = {
+ {
+/* core_class fields */
+ /* superclass */ (WidgetClass) SuperClass,
+ /* class_name */ "TextSrc",
+ /* widget_size */ sizeof(TextSrcRec),
+ /* class_initialize */ ClassInitialize,
+ /* class_part_initialize */ ClassPartInitialize,
+ /* class_inited */ FALSE,
+ /* initialize */ NULL,
+ /* initialize_hook */ NULL,
+ /* realize */ NULL,
+ /* actions */ NULL,
+ /* num_actions */ 0,
+ /* resources */ resources,
+ /* num_resources */ XtNumber(resources),
+ /* xrm_class */ NULLQUARK,
+ /* compress_motion */ FALSE,
+ /* compress_exposure */ FALSE,
+ /* compress_enterleave */ FALSE,
+ /* visible_interest */ FALSE,
+ /* destroy */ NULL,
+ /* resize */ NULL,
+ /* expose */ NULL,
+ /* set_values */ NULL,
+ /* set_values_hook */ NULL,
+ /* set_values_almost */ NULL,
+ /* get_values_hook */ NULL,
+ /* accept_focus */ NULL,
+ /* version */ XtVersion,
+ /* callback_private */ NULL,
+ /* tm_table */ NULL,
+ /* query_geometry */ NULL,
+ /* display_accelerator */ NULL,
+ /* extension */ NULL,
+ },
+/* textSrc_class fields */
+ {
+ /* Read */ Read,
+ /* Replace */ Replace,
+ /* Scan */ Scan,
+ /* Search */ Search,
+ /* SetSelection */ SetSelection,
+ /* ConvertSelection */ ConvertSelection
+ }
+};
+
+WidgetClass textSrcObjectClass = (WidgetClass)&textSrcClassRec;
+
+static void
+ClassInitialize ()
+{
+ XawInitializeWidgetSet ();
+ XtAddConverter(XtRString, XtREditMode, CvtStringToEditMode, NULL, 0);
+}
+
+
+static void
+ClassPartInitialize(wc)
+WidgetClass wc;
+{
+ TextSrcObjectClass t_src, superC;
+
+ t_src = (TextSrcObjectClass) wc;
+ superC = (TextSrcObjectClass) t_src->object_class.superclass;
+
+/*
+ * We don't need to check for null super since we'll get to TextSrc
+ * eventually.
+ */
+ if (t_src->textSrc_class.Read == XtInheritRead)
+ t_src->textSrc_class.Read = superC->textSrc_class.Read;
+
+ if (t_src->textSrc_class.Replace == XtInheritReplace)
+ t_src->textSrc_class.Replace = superC->textSrc_class.Replace;
+
+ if (t_src->textSrc_class.Scan == XtInheritScan)
+ t_src->textSrc_class.Scan = superC->textSrc_class.Scan;
+
+ if (t_src->textSrc_class.Search == XtInheritSearch)
+ t_src->textSrc_class.Search = superC->textSrc_class.Search;
+
+ if (t_src->textSrc_class.SetSelection == XtInheritSetSelection)
+ t_src->textSrc_class.SetSelection = superC->textSrc_class.SetSelection;
+
+ if (t_src->textSrc_class.ConvertSelection == XtInheritConvertSelection)
+ t_src->textSrc_class.ConvertSelection =
+ superC->textSrc_class.ConvertSelection;
+}
+
+/************************************************************
+ *
+ * Class specific methods.
+ *
+ ************************************************************/
+
+/* Function Name: Read
+ * Description: This function reads the source.
+ * Arguments: w - the TextSrc Object.
+ * pos - position of the text to retreive.
+ * RETURNED text - text block that will contain returned text.
+ * length - maximum number of characters to read.
+ * Returns: The number of characters read into the buffer.
+ */
+
+/* ARGSUSED */
+static XawTextPosition
+Read(w, pos, text, length)
+Widget w;
+XawTextPosition pos;
+XawTextBlock *text;
+int length;
+{
+ XtAppError(XtWidgetToApplicationContext(w),
+ "TextSrc Object: No read function is defined.");
+
+ return( (XawTextPosition) 0 ); /* for gcc -Wall and lint */
+}
+
+/* Function Name: Replace.
+ * Description: Replaces a block of text with new text.
+ * Arguments: src - the Text Source Object.
+ * startPos, endPos - ends of text that will be removed.
+ * text - new text to be inserted into buffer at startPos.
+ * Returns: XawEditError.
+ */
+
+/*ARGSUSED*/
+static int
+Replace (w, startPos, endPos, text)
+Widget w;
+XawTextPosition startPos, endPos;
+XawTextBlock *text;
+{
+ return(XawEditError);
+}
+
+/* Function Name: Scan
+ * Description: Scans the text source for the number and type
+ * of item specified.
+ * Arguments: w - the TextSrc Object.
+ * position - the position to start scanning.
+ * type - type of thing to scan for.
+ * dir - direction to scan.
+ * count - which occurance if this thing to search for.
+ * include - whether or not to include the character found in
+ * the position that is returned.
+ * Returns: EXITS WITH AN ERROR MESSAGE.
+ *
+ */
+
+/* ARGSUSED */
+static
+XawTextPosition
+Scan (w, position, type, dir, count, include)
+Widget w;
+XawTextPosition position;
+XawTextScanType type;
+XawTextScanDirection dir;
+int count;
+Boolean include;
+{
+ XtAppError(XtWidgetToApplicationContext(w),
+ "TextSrc Object: No SCAN function is defined.");
+
+ return( (XawTextPosition) 0 ); /* for gcc -Wall and lint */
+}
+
+/* Function Name: Search
+ * Description: Searchs the text source for the text block passed
+ * Arguments: w - the TextSource Object.
+ * position - the position to start scanning.
+ * dir - direction to scan.
+ * text - the text block to search for.
+ * Returns: XawTextSearchError.
+ */
+
+/* ARGSUSED */
+static XawTextPosition
+Search(w, position, dir, text)
+Widget w;
+XawTextPosition position;
+XawTextScanDirection dir;
+XawTextBlock * text;
+{
+ return(XawTextSearchError);
+}
+
+/* Function Name: ConvertSelection
+ * Description: Dummy selection converter.
+ * Arguments: w - the TextSrc object.
+ * selection - the current selection atom.
+ * target - the current target atom.
+ * type - the type to conver the selection to.
+ * RETURNED value, length - the return value that has been converted.
+ * RETURNED format - the format of the returned value.
+ * Returns: TRUE if the selection has been converted.
+ *
+ */
+
+/* ARGSUSED */
+static Boolean
+ConvertSelection(w, selection, target, type, value, length, format)
+Widget w;
+Atom * selection, * target, * type;
+XtPointer * value;
+unsigned long * length;
+int * format;
+{
+ return(FALSE);
+}
+
+/* Function Name: SetSelection
+ * Description: allows special setting of the selection.
+ * Arguments: w - the TextSrc object.
+ * left, right - bounds of the selection.
+ * selection - the selection atom.
+ * Returns: none
+ */
+
+/* ARGSUSED */
+static void
+SetSelection(w, left, right, selection)
+Widget w;
+XawTextPosition left, right;
+Atom selection;
+{
+ /* This space intentionally left blank. */
+}
+
+
+/* ARGSUSED */
+static void
+CvtStringToEditMode(args, num_args, fromVal, toVal)
+XrmValuePtr args; /* unused */
+Cardinal *num_args; /* unused */
+XrmValuePtr fromVal;
+XrmValuePtr toVal;
+{
+ static XawTextEditType editType;
+ static XrmQuark QRead, QAppend, QEdit;
+ XrmQuark q;
+ char lowerName[40];
+ static Boolean inited = FALSE;
+
+ if ( !inited ) {
+ QRead = XrmPermStringToQuark(XtEtextRead);
+ QAppend = XrmPermStringToQuark(XtEtextAppend);
+ QEdit = XrmPermStringToQuark(XtEtextEdit);
+ inited = TRUE;
+ }
+
+ if (strlen ((char*) fromVal->addr) < sizeof lowerName) {
+ XmuCopyISOLatin1Lowered (lowerName, (char *)fromVal->addr);
+ q = XrmStringToQuark(lowerName);
+
+ if (q == QRead) editType = XawtextRead;
+ else if (q == QAppend) editType = XawtextAppend;
+ else if (q == QEdit) editType = XawtextEdit;
+ else {
+ toVal->size = 0;
+ toVal->addr = NULL;
+ return;
+ }
+ toVal->size = sizeof editType;
+ toVal->addr = (XPointer) &editType;
+ return;
+ }
+ toVal->size = 0;
+ toVal->addr = NULL;
+}
+
+
+
+/************************************************************
+ *
+ * Public Functions.
+ *
+ ************************************************************/
+
+/* Function Name: XawTextSourceRead
+ * Description: This function reads the source.
+ * Arguments: w - the TextSrc Object.
+ * pos - position of the text to retreive.
+ * RETURNED text - text block that will contain returned text.
+ * length - maximum number of characters to read.
+ * Returns: The number of characters read into the buffer.
+ */
+
+XawTextPosition
+#if NeedFunctionPrototypes
+XawTextSourceRead(Widget w, XawTextPosition pos, XawTextBlock *text,
+ int length)
+#else
+XawTextSourceRead(w, pos, text, length)
+Widget w;
+XawTextPosition pos;
+XawTextBlock *text;
+int length;
+#endif
+{
+ TextSrcObjectClass class = (TextSrcObjectClass) w->core.widget_class;
+
+ if ( !XtIsSubclass( w, textSrcObjectClass ) )
+ XtErrorMsg("bad argument", "textSource", "XawError",
+ "XawTextSourceRead's 1st parameter must be subclass of asciiSrc.",
+ NULL, NULL);
+
+ return((*class->textSrc_class.Read)(w, pos, text, length));
+}
+
+/* Function Name: XawTextSourceReplace.
+ * Description: Replaces a block of text with new text.
+ * Arguments: src - the Text Source Object.
+ * startPos, endPos - ends of text that will be removed.
+ * text - new text to be inserted into buffer at startPos.
+ * Returns: XawEditError or XawEditDone.
+ */
+
+/*ARGSUSED*/
+int
+#if NeedFunctionPrototypes
+XawTextSourceReplace (Widget w, XawTextPosition startPos,
+ XawTextPosition endPos, XawTextBlock *text)
+#else
+XawTextSourceReplace (w, startPos, endPos, text)
+Widget w;
+XawTextPosition startPos, endPos;
+XawTextBlock *text;
+#endif
+{
+ TextSrcObjectClass class = (TextSrcObjectClass) w->core.widget_class;
+
+ if ( !XtIsSubclass( w, textSrcObjectClass ) )
+ XtErrorMsg("bad argument", "textSource", "XawError",
+ "XawTextSourceReplace's 1st parameter must be subclass of asciiSrc.",
+ NULL, NULL);
+
+ return((*class->textSrc_class.Replace)(w, startPos, endPos, text));
+}
+
+/* Function Name: XawTextSourceScan
+ * Description: Scans the text source for the number and type
+ * of item specified.
+ * Arguments: w - the TextSrc Object.
+ * position - the position to start scanning.
+ * type - type of thing to scan for.
+ * dir - direction to scan.
+ * count - which occurance if this thing to search for.
+ * include - whether or not to include the character found in
+ * the position that is returned.
+ * Returns: The position of the text.
+ *
+ */
+
+XawTextPosition
+#if NeedFunctionPrototypes
+XawTextSourceScan(Widget w, XawTextPosition position,
+#if NeedWidePrototypes
+ int type, int dir,
+#else
+ XawTextScanType type, XawTextScanDirection dir,
+#endif
+ int count,
+#if NeedWidePrototypes
+ int include)
+#else
+ Boolean include)
+#endif
+#else
+XawTextSourceScan(w, position, type, dir, count, include)
+Widget w;
+XawTextPosition position;
+XawTextScanType type;
+XawTextScanDirection dir;
+int count;
+Boolean include;
+#endif
+{
+ TextSrcObjectClass class = (TextSrcObjectClass) w->core.widget_class;
+
+ if ( !XtIsSubclass( w, textSrcObjectClass ) )
+ XtErrorMsg("bad argument", "textSource", "XawError",
+ "XawTextSourceScan's 1st parameter must be subclass of asciiSrc.",
+ NULL, NULL);
+
+ return((*class->textSrc_class.Scan)(w, position, type, dir, count, include));
+}
+
+/* Function Name: XawTextSourceSearch
+ * Description: Searchs the text source for the text block passed
+ * Arguments: w - the TextSource Object.
+ * position - the position to start scanning.
+ * dir - direction to scan.
+ * text - the text block to search for.
+ * Returns: The position of the text we are searching for or
+ * XawTextSearchError.
+ */
+
+XawTextPosition
+#if NeedFunctionPrototypes
+XawTextSourceSearch(Widget w, XawTextPosition position,
+#if NeedWidePrototypes
+ int dir,
+#else
+ XawTextScanDirection dir,
+#endif
+ XawTextBlock *text)
+#else
+XawTextSourceSearch(w, position, dir, text)
+Widget w;
+XawTextPosition position;
+XawTextScanDirection dir;
+XawTextBlock * text;
+#endif
+{
+ TextSrcObjectClass class = (TextSrcObjectClass) w->core.widget_class;
+
+ if ( !XtIsSubclass( w, textSrcObjectClass ) )
+ XtErrorMsg("bad argument", "textSource", "XawError",
+ "XawTextSourceSearch's 1st parameter must be subclass of asciiSrc.",
+ NULL, NULL);
+
+ return((*class->textSrc_class.Search)(w, position, dir, text));
+}
+
+/* Function Name: XawTextSourceConvertSelection
+ * Description: Dummy selection converter.
+ * Arguments: w - the TextSrc object.
+ * selection - the current selection atom.
+ * target - the current target atom.
+ * type - the type to conver the selection to.
+ * RETURNED value, length - the return value that has been converted.
+ * RETURNED format - the format of the returned value.
+ * Returns: TRUE if the selection has been converted.
+ *
+ */
+
+Boolean
+#if NeedFunctionPrototypes
+XawTextSourceConvertSelection(Widget w, Atom *selection, Atom *target,
+ Atom *type, XtPointer *value,
+ unsigned long *length, int *format)
+#else
+XawTextSourceConvertSelection(w, selection,
+ target, type, value, length, format)
+Widget w;
+Atom * selection, * target, * type;
+XtPointer * value;
+unsigned long * length;
+int * format;
+#endif
+{
+ TextSrcObjectClass class = (TextSrcObjectClass) w->core.widget_class;
+
+ if ( !XtIsSubclass( w, textSrcObjectClass ) )
+ XtErrorMsg("bad argument", "textSource", "XawError",
+ "XawTextSourceConvertSelectionXawTextSourceConvertSelection's 1st parameter must be subclass of asciiSrc.",
+ NULL, NULL);
+
+ return((*class->textSrc_class.ConvertSelection)(w, selection, target, type,
+ value, length, format));
+}
+
+/* Function Name: XawTextSourceSetSelection
+ * Description: allows special setting of the selection.
+ * Arguments: w - the TextSrc object.
+ * left, right - bounds of the selection.
+ * selection - the selection atom.
+ * Returns: none
+ */
+
+void
+#if NeedFunctionPrototypes
+XawTextSourceSetSelection(Widget w, XawTextPosition left,
+ XawTextPosition right, Atom selection)
+#else
+XawTextSourceSetSelection(w, left, right, selection)
+Widget w;
+XawTextPosition left, right;
+Atom selection;
+#endif
+{
+ TextSrcObjectClass class = (TextSrcObjectClass) w->core.widget_class;
+
+ if ( !XtIsSubclass( w, textSrcObjectClass ) )
+ XtErrorMsg("bad argument", "textSource", "XawError",
+ "'s 1st parameter must be subclass of asciiSrc.",
+ NULL, NULL);
+
+ (*class->textSrc_class.SetSelection)(w, left, right, selection);
+}
+
+/********************************************************************
+ *
+ * External Functions for Multi Text.
+ *
+ ********************************************************************/
+
+/*
+ * TextFormat():
+ * returns the format of text: FMT8BIT or FMTWIDE.
+ *
+ */
+XrmQuark
+#if NeedFunctionPrototypes
+_XawTextFormat(TextWidget tw)
+#else
+_XawTextFormat(tw)
+ TextWidget tw;
+#endif
+{
+ return (((TextSrcObject)(tw->text.source))->textSrc.text_format);
+}
+
+
+/* _XawTextWCToMB():
+ * convert the wchar string to external encoding.
+ * The caller is responsible for freeing both the source and ret string.
+ *
+ * wstr - source wchar string.
+ * len_in_out - lengh of string.
+ * As In, length of source wchar string, measured in wchar.
+ * As Out, length of returned string.
+ */
+
+
+char *
+_XawTextWCToMB( d, wstr, len_in_out )
+ Display* d;
+ wchar_t* wstr;
+ int* len_in_out;
+
+{
+ XTextProperty textprop;
+ if (XwcTextListToTextProperty(d, (wchar_t**)&wstr, 1,
+ XTextStyle, &textprop) < Success) {
+ XtWarningMsg("convertError", "textSource", "XawError",
+ "Non-character code(s) in buffer.", NULL, NULL);
+ *len_in_out = 0;
+ return( NULL );
+ }
+ *len_in_out = textprop.nitems;
+ return((char *)textprop.value);
+}
+
+
+/* _XawTextMBToWC():
+ * convert the string to internal processing codeset WC.
+ * The caller is responsible for freeing both the source and ret string.
+ *
+ * str - source string.
+ * len_in_out - lengh of string.
+ * As In, it is length of source string.
+ * As Out, it is length of returned string, measured in wchar.
+ */
+
+wchar_t* _XawTextMBToWC( d, str, len_in_out )
+Display *d;
+char *str;
+int *len_in_out;
+{
+ if (*len_in_out == 0) {
+ return(NULL);
+ } else {
+ XTextProperty textprop;
+ char *buf;
+ wchar_t **wlist, *wstr;
+ int count;
+ buf = XtMalloc(*len_in_out + 1);
+ if (!buf) {
+ XtErrorMsg("convertError", "multiSourceCreate", "XawError",
+ "No Memory", NULL, NULL);
+ *len_in_out = 0;
+ return (NULL); /* The above function doesn't really return. */
+ }
+ strncpy(buf, str, *len_in_out);
+ *(buf + *len_in_out) = '\0';
+ if (XmbTextListToTextProperty(d, &buf, 1, XTextStyle, &textprop)
+ != Success) {
+ XtWarningMsg("convertError", "textSource", "XawError",
+ "No Memory, or Locale not supported.", NULL, NULL);
+ XtFree(buf);
+ *len_in_out = 0;
+ return (NULL);
+ }
+ XtFree(buf);
+ if (XwcTextPropertyToTextList(d, &textprop,
+ (wchar_t***)&wlist, &count) != Success) {
+ XtWarningMsg("convertError", "multiSourceCreate", "XawError",
+ "Non-character code(s) in source.", NULL, NULL);
+ *len_in_out = 0;
+ return (NULL);
+ }
+ wstr = (wchar_t *) XtMalloc((wcslen(wlist[0]) + 1) * sizeof(wchar_t));
+ if (wstr == (wchar_t *) NULL) {
+ XwcFreeStringList(wlist);
+ XtErrorMsg("convertError", "multiSourceCreate", "XawError",
+ "No Memory", NULL, NULL);
+ *len_in_out = 0;
+ return (NULL); /* The above function doesn't really return. */
+ }
+ wcscpy(wstr, wlist[0]);
+ *len_in_out = wcslen(wstr);
+ XwcFreeStringList(wlist);
+ return(wstr);
+ }
+}
+
diff --git a/src/TextTr.c b/src/TextTr.c
new file mode 100644
index 0000000..333853d
--- /dev/null
+++ b/src/TextTr.c
@@ -0,0 +1,129 @@
+/* $Xorg: TextTr.c,v 1.4 2001/02/09 02:03:47 xorgcvs Exp $ */
+
+/*
+
+Copyright 1991, 1994, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+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
+OPEN GROUP 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 Open Group 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 Open Group.
+
+*/
+
+/* INTERNATIONALIZATION:
+
+The OMRON R5 contrib added the following action to the old TextTr:
+
+ Ctrl<Key>backslash: reconnect-im()
+
+This is needed when the im is killed or otherwise becomes unreachable.
+This keystroke is evil (inconvenient, hard-to-remember, not obvious)
+so I am adding one more translation:
+
+ <Key>Kanji: reconnect-im()
+
+The Japanese user typically hits their Kanji key when they want to do
+input. This merely makes sure the input is connected.
+*/
+
+char *_XawDefaultTextTranslations1 =
+"\
+Ctrl<Key>A: beginning-of-line() \n\
+Ctrl<Key>B: backward-character() \n\
+Ctrl<Key>C: insert-selection(CUT_BUFFER0) \n\
+Ctrl<Key>D: delete-next-character() \n\
+Ctrl<Key>E: end-of-line() \n\
+Ctrl<Key>F: forward-character() \n\
+Ctrl<Key>G: multiply(Reset) \n\
+Ctrl<Key>H: delete-previous-character() \n\
+Ctrl<Key>J: newline-and-indent() \n\
+Ctrl<Key>K: kill-to-end-of-line() \n\
+Ctrl<Key>L: redraw-display() \n\
+Ctrl<Key>M: newline() \n\
+Ctrl<Key>N: next-line() \n\
+Ctrl<Key>O: newline-and-backup() \n\
+Ctrl<Key>P: previous-line() \n\
+Ctrl<Key>R: search(backward) \n\
+Ctrl<Key>S: search(forward) \n\
+Ctrl<Key>T: transpose-characters() \n\
+Ctrl<Key>U: multiply(4) \n\
+Ctrl<Key>V: next-page() \n\
+Ctrl<Key>W: kill-selection() \n\
+Ctrl<Key>Y: insert-selection(SECONDARY) \n\
+Ctrl<Key>Z: scroll-one-line-up() \n\
+", *_XawDefaultTextTranslations2 = "\
+Meta<Key>B: backward-word() \n\
+Meta<Key>F: forward-word() \n\
+Meta<Key>I: insert-file() \n\
+Meta<Key>K: kill-to-end-of-paragraph() \n\
+Meta<Key>Q: form-paragraph() \n\
+Meta<Key>V: previous-page() \n\
+Meta<Key>Y: insert-selection(PRIMARY, CUT_BUFFER0) \n\
+Meta<Key>Z: scroll-one-line-down() \n\
+:Meta<Key>d: delete-next-word() \n\
+:Meta<Key>D: kill-word() \n\
+:Meta<Key>h: delete-previous-word() \n\
+:Meta<Key>H: backward-kill-word() \n\
+:Meta<Key>\\<: beginning-of-file() \n\
+:Meta<Key>\\>: end-of-file() \n\
+:Meta<Key>]: forward-paragraph() \n\
+:Meta<Key>[: backward-paragraph() \n\
+~Shift Meta<Key>Delete: delete-previous-word() \n\
+ Shift Meta<Key>Delete: backward-kill-word() \n\
+~Shift Meta<Key>BackSpace: delete-previous-word() \n\
+ Shift Meta<Key>BackSpace: backward-kill-word() \n\
+", *_XawDefaultTextTranslations3 = "\
+<Key>Home: beginning-of-file() \n\
+:<Key>KP_Home: beginning-of-file() \n\
+<Key>End: end-of-file() \n\
+:<Key>KP_End: end-of-file() \n\
+<Key>Next: next-page() \n\
+:<Key>KP_Next: next-page() \n\
+<Key>Prior: previous-page() \n\
+:<Key>KP_Prior: previous-page() \n\
+<Key>Right: forward-character() \n\
+:<Key>KP_Right: forward-character() \n\
+<Key>Left: backward-character() \n\
+:<Key>KP_Left: backward-character() \n\
+<Key>Down: next-line() \n\
+:<Key>KP_Down: next-line() \n\
+<Key>Up: previous-line() \n\
+:<Key>KP_Up: previous-line() \n\
+<Key>Delete: delete-previous-character() \n\
+:<Key>KP_Delete: delete-previous-character() \n\
+<Key>BackSpace: delete-previous-character() \n\
+<Key>Linefeed: newline-and-indent() \n\
+<Key>Return: newline() \n\
+:<Key>KP_Enter: newline() \n\
+Ctrl<Key>backslash: reconnect-im() \n\
+<Key>Kanji: reconnect-im()\n\
+<Key>: insert-char() \n\
+", *_XawDefaultTextTranslations4 = "\
+<EnterWindow>: enter-window() \n\
+<LeaveWindow>: leave-window() \n\
+<FocusIn>: focus-in() \n\
+<FocusOut>: focus-out() \n\
+<Btn1Down>: select-start() \n\
+<Btn1Motion>: extend-adjust() \n\
+<Btn1Up>: extend-end(PRIMARY, CUT_BUFFER0) \n\
+<Btn2Down>: insert-selection(PRIMARY, CUT_BUFFER0) \n\
+<Btn3Down>: extend-start() \n\
+<Btn3Motion>: extend-adjust() \n\
+<Btn3Up>: extend-end(PRIMARY, CUT_BUFFER0) \
+";
diff --git a/src/Toggle.c b/src/Toggle.c
new file mode 100644
index 0000000..988d9e1
--- /dev/null
+++ b/src/Toggle.c
@@ -0,0 +1,615 @@
+/* $Xorg: Toggle.c,v 1.4 2001/02/09 02:03:47 xorgcvs Exp $ */
+
+/*
+
+Copyright 1989, 1994, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+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
+OPEN GROUP 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 Open Group 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 Open Group.
+
+*/
+
+/*
+ * Toggle.c - Toggle button widget
+ *
+ * Author: Chris D. Peterson
+ * MIT X Consortium
+ * kit@expo.lcs.mit.edu
+ *
+ * Date: January 12, 1989
+ *
+ */
+
+#include <stdio.h>
+
+#include <X11/IntrinsicP.h>
+#include <X11/StringDefs.h>
+#include <X11/Xaw/XawInit.h>
+#include <X11/Xmu/Converters.h>
+#include <X11/Xmu/Misc.h>
+#include <X11/Xaw/ToggleP.h>
+
+/****************************************************************
+ *
+ * Full class record constant
+ *
+ ****************************************************************/
+
+/* Private Data */
+
+/*
+ * The order of toggle and notify are important, as the state has
+ * to be set when we call the notify proc.
+ */
+
+static char defaultTranslations[] =
+ "<EnterWindow>: highlight(Always) \n\
+ <LeaveWindow>: unhighlight() \n\
+ <Btn1Down>,<Btn1Up>: toggle() notify()";
+
+#define offset(field) XtOffsetOf(ToggleRec, field)
+
+static XtResource resources[] = {
+ {XtNstate, XtCState, XtRBoolean, sizeof(Boolean),
+ offset(command.set), XtRString, "off"},
+ {XtNradioGroup, XtCWidget, XtRWidget, sizeof(Widget),
+ offset(toggle.widget), XtRWidget, (XtPointer) NULL },
+ {XtNradioData, XtCRadioData, XtRPointer, sizeof(XtPointer),
+ offset(toggle.radio_data), XtRPointer, (XtPointer) NULL },
+};
+
+#undef offset
+
+
+static void Toggle(), Initialize(), Notify(), ToggleSet();
+static void ToggleDestroy(), ClassInit();
+static Boolean SetValues();
+
+/* Functions for handling the Radio Group. */
+
+static RadioGroup * GetRadioGroup();
+static void CreateRadioGroup(), AddToRadioGroup(), TurnOffRadioSiblings();
+static void RemoveFromRadioGroup();
+
+static XtActionsRec actionsList[] =
+{
+ {"toggle", Toggle},
+ {"notify", Notify},
+ {"set", ToggleSet},
+};
+
+#define SuperClass ((CommandWidgetClass)&commandClassRec)
+
+ToggleClassRec toggleClassRec = {
+ {
+ (WidgetClass) SuperClass, /* superclass */
+ "Toggle", /* class_name */
+ sizeof(ToggleRec), /* size */
+ ClassInit, /* class_initialize */
+ NULL, /* class_part_initialize */
+ FALSE, /* class_inited */
+ Initialize, /* initialize */
+ NULL, /* initialize_hook */
+ XtInheritRealize, /* realize */
+ actionsList, /* actions */
+ XtNumber(actionsList), /* num_actions */
+ resources, /* resources */
+ XtNumber(resources), /* resource_count */
+ NULLQUARK, /* xrm_class */
+ FALSE, /* compress_motion */
+ TRUE, /* compress_exposure */
+ TRUE, /* compress_enterleave */
+ FALSE, /* visible_interest */
+ NULL, /* destroy */
+ XtInheritResize, /* resize */
+ XtInheritExpose, /* expose */
+ SetValues, /* set_values */
+ NULL, /* set_values_hook */
+ XtInheritSetValuesAlmost, /* set_values_almost */
+ NULL, /* get_values_hook */
+ NULL, /* accept_focus */
+ XtVersion, /* version */
+ NULL, /* callback_private */
+ defaultTranslations, /* tm_table */
+ XtInheritQueryGeometry, /* query_geometry */
+ XtInheritDisplayAccelerator, /* display_accelerator */
+ NULL /* extension */
+ }, /* CoreClass fields initialization */
+ {
+ XtInheritChangeSensitive /* change_sensitive */
+ }, /* SimpleClass fields initialization */
+ {
+ 0 /* field not used */
+ }, /* LabelClass fields initialization */
+ {
+ 0 /* field not used */
+ }, /* CommandClass fields initialization */
+ {
+ NULL, /* Set Procedure. */
+ NULL, /* Unset Procedure. */
+ NULL /* extension. */
+ } /* ToggleClass fields initialization */
+};
+
+ /* for public consumption */
+WidgetClass toggleWidgetClass = (WidgetClass) &toggleClassRec;
+
+/****************************************************************
+ *
+ * Private Procedures
+ *
+ ****************************************************************/
+
+static void
+ClassInit()
+{
+ XtActionList actions;
+ Cardinal num_actions;
+ Cardinal i;
+ ToggleWidgetClass class = (ToggleWidgetClass) toggleWidgetClass;
+ static XtConvertArgRec parentCvtArgs[] = {
+ {XtBaseOffset, (XtPointer)XtOffsetOf(WidgetRec, core.parent),
+ sizeof(Widget)}
+ };
+
+ XawInitializeWidgetSet();
+ XtSetTypeConverter(XtRString, XtRWidget, XmuNewCvtStringToWidget,
+ parentCvtArgs, XtNumber(parentCvtArgs), XtCacheNone,
+ (XtDestructor)NULL);
+/*
+ * Find the set and unset actions in the command widget's action table.
+ */
+
+ XtGetActionList(commandWidgetClass, &actions, &num_actions);
+
+ for (i = 0 ; i < num_actions ; i++) {
+ if (streq(actions[i].string, "set"))
+ class->toggle_class.Set = actions[i].proc;
+ if (streq(actions[i].string, "unset"))
+ class->toggle_class.Unset = actions[i].proc;
+
+ if ( (class->toggle_class.Set != NULL) &&
+ (class->toggle_class.Unset != NULL) ) {
+ XtFree((char *) actions);
+ return;
+ }
+ }
+
+/* We should never get here. */
+ XtError("Aborting, due to errors resolving bindings in the Toggle widget.");
+}
+
+/*ARGSUSED*/
+static void Initialize(request, new, args, num_args)
+ Widget request, new;
+ ArgList args;
+ Cardinal *num_args;
+{
+ ToggleWidget tw = (ToggleWidget) new;
+ ToggleWidget tw_req = (ToggleWidget) request;
+
+ tw->toggle.radio_group = NULL;
+
+ if (tw->toggle.radio_data == NULL)
+ tw->toggle.radio_data = (XtPointer) new->core.name;
+
+ if (tw->toggle.widget != NULL) {
+ if ( GetRadioGroup(tw->toggle.widget) == NULL)
+ CreateRadioGroup(new, tw->toggle.widget);
+ else
+ AddToRadioGroup( GetRadioGroup(tw->toggle.widget), new);
+ }
+ XtAddCallback(new, XtNdestroyCallback, ToggleDestroy, (XtPointer)NULL);
+
+/*
+ * Command widget assumes that the widget is unset, so we only
+ * have to handle the case where it needs to be set.
+ *
+ * If this widget is in a radio group then it may cause another
+ * widget to be unset, thus calling the notify proceedure.
+ *
+ * I want to set the toggle if the user set the state to "On" in
+ * the resource group, reguardless of what my ancestors did.
+ */
+
+ if (tw_req->command.set)
+ ToggleSet(new, (XEvent *)NULL, (String *)NULL, (Cardinal *)0);
+}
+
+/************************************************************
+ *
+ * Action Procedures
+ *
+ ************************************************************/
+
+/* ARGSUSED */
+static void
+ToggleSet(w,event,params,num_params)
+Widget w;
+XEvent *event;
+String *params; /* unused */
+Cardinal *num_params; /* unused */
+{
+ ToggleWidgetClass class = (ToggleWidgetClass) w->core.widget_class;
+
+ TurnOffRadioSiblings(w);
+ class->toggle_class.Set(w, event, NULL, 0);
+}
+
+/* ARGSUSED */
+static void
+Toggle(w,event,params,num_params)
+Widget w;
+XEvent *event;
+String *params; /* unused */
+Cardinal *num_params; /* unused */
+{
+ ToggleWidget tw = (ToggleWidget)w;
+ ToggleWidgetClass class = (ToggleWidgetClass) w->core.widget_class;
+
+ if (tw->command.set)
+ class->toggle_class.Unset(w, event, NULL, 0);
+ else
+ ToggleSet(w, event, params, num_params);
+}
+
+/* ARGSUSED */
+static void Notify(w,event,params,num_params)
+Widget w;
+XEvent *event;
+String *params; /* unused */
+Cardinal *num_params; /* unused */
+{
+ ToggleWidget tw = (ToggleWidget) w;
+ long antilint = tw->command.set;
+
+ XtCallCallbacks( w, XtNcallback, (XtPointer) antilint );
+}
+
+/************************************************************
+ *
+ * Set specified arguments into widget
+ *
+ ***********************************************************/
+
+/* ARGSUSED */
+static Boolean
+SetValues (current, request, new, args, num_args)
+Widget current, request, new;
+ArgList args;
+Cardinal *num_args;
+{
+ ToggleWidget oldtw = (ToggleWidget) current;
+ ToggleWidget tw = (ToggleWidget) new;
+ ToggleWidget rtw = (ToggleWidget) request;
+
+ if (oldtw->toggle.widget != tw->toggle.widget)
+ XawToggleChangeRadioGroup(new, tw->toggle.widget);
+
+ if (!tw->core.sensitive && oldtw->core.sensitive && rtw->command.set)
+ tw->command.set = True;
+
+ if (oldtw->command.set != tw->command.set) {
+ tw->command.set = oldtw->command.set;
+ Toggle(new, (XEvent *)NULL, (String *)NULL, (Cardinal *)0);
+ }
+ return(FALSE);
+}
+
+/* Function Name: ToggleDestroy
+ * Description: Destroy Callback for toggle widget.
+ * Arguments: w - the toggle widget that is being destroyed.
+ * junk, grabage - not used.
+ * Returns: none.
+ */
+
+/* ARGSUSED */
+static void
+ToggleDestroy(w, junk, garbage)
+Widget w;
+XtPointer junk, garbage;
+{
+ RemoveFromRadioGroup(w);
+}
+
+/************************************************************
+ *
+ * Below are all the private procedures that handle
+ * radio toggle buttons.
+ *
+ ************************************************************/
+
+/* Function Name: GetRadioGroup
+ * Description: Gets the radio group associated with a give toggle
+ * widget.
+ * Arguments: w - the toggle widget who's radio group we are getting.
+ * Returns: the radio group associated with this toggle group.
+ */
+
+static RadioGroup *
+GetRadioGroup(w)
+Widget w;
+{
+ ToggleWidget tw = (ToggleWidget) w;
+
+ if (tw == NULL) return(NULL);
+ return( tw->toggle.radio_group );
+}
+
+/* Function Name: CreateRadioGroup
+ * Description: Creates a radio group. give two widgets.
+ * Arguments: w1, w2 - the toggle widgets to add to the radio group.
+ * Returns: none.
+ *
+ * NOTE: A pointer to the group is added to each widget's radio_group
+ * field.
+ */
+
+static void
+CreateRadioGroup(w1, w2)
+Widget w1, w2;
+{
+ char error_buf[BUFSIZ];
+ ToggleWidget tw1 = (ToggleWidget) w1;
+ ToggleWidget tw2 = (ToggleWidget) w2;
+
+ if ( (tw1->toggle.radio_group != NULL) || (tw2->toggle.radio_group != NULL) ) {
+ (void) sprintf(error_buf, "%s %s", "Toggle Widget Error - Attempting",
+ "to create a new toggle group, when one already exists.");
+ XtWarning(error_buf);
+ }
+
+ AddToRadioGroup( (RadioGroup *)NULL, w1 );
+ AddToRadioGroup( GetRadioGroup(w1), w2 );
+}
+
+/* Function Name: AddToRadioGroup
+ * Description: Adds a toggle to the radio group.
+ * Arguments: group - any element of the radio group the we are adding to.
+ * w - the new toggle widget to add to the group.
+ * Returns: none.
+ */
+
+static void
+AddToRadioGroup(group, w)
+RadioGroup * group;
+Widget w;
+{
+ ToggleWidget tw = (ToggleWidget) w;
+ RadioGroup * local;
+
+ local = (RadioGroup *) XtMalloc( sizeof(RadioGroup) );
+ local->widget = w;
+ tw->toggle.radio_group = local;
+
+ if (group == NULL) { /* Creating new group. */
+ group = local;
+ group->next = NULL;
+ group->prev = NULL;
+ return;
+ }
+ local->prev = group; /* Adding to previous group. */
+ if ((local->next = group->next) != NULL)
+ local->next->prev = local;
+ group->next = local;
+}
+
+/* Function Name: TurnOffRadioSiblings
+ * Description: Deactivates all radio siblings.
+ * Arguments: widget - a toggle widget.
+ * Returns: none.
+ */
+
+static void
+TurnOffRadioSiblings(w)
+Widget w;
+{
+ RadioGroup * group;
+ ToggleWidgetClass class = (ToggleWidgetClass) w->core.widget_class;
+
+ if ( (group = GetRadioGroup(w)) == NULL) /* Punt if there is no group */
+ return;
+
+ /* Go to the top of the group. */
+
+ for ( ; group->prev != NULL ; group = group->prev );
+
+ while ( group != NULL ) {
+ ToggleWidget local_tog = (ToggleWidget) group->widget;
+ if ( local_tog->command.set ) {
+ class->toggle_class.Unset(group->widget, NULL, NULL, 0);
+ Notify( group->widget, (XEvent *)NULL, (String *)NULL, (Cardinal *)0);
+ }
+ group = group->next;
+ }
+}
+
+/* Function Name: RemoveFromRadioGroup
+ * Description: Removes a toggle from a RadioGroup.
+ * Arguments: w - the toggle widget to remove.
+ * Returns: none.
+ */
+
+static void
+RemoveFromRadioGroup(w)
+Widget w;
+{
+ RadioGroup * group = GetRadioGroup(w);
+ if (group != NULL) {
+ if (group->prev != NULL)
+ (group->prev)->next = group->next;
+ if (group->next != NULL)
+ (group->next)->prev = group->prev;
+ XtFree((char *) group);
+ }
+}
+
+/************************************************************
+ *
+ * Public Routines
+ *
+ ************************************************************/
+
+/* Function Name: XawToggleChangeRadioGroup
+ * Description: Allows a toggle widget to change radio groups.
+ * Arguments: w - The toggle widget to change groups.
+ * radio_group - any widget in the new group.
+ * Returns: none.
+ */
+
+void
+#if NeedFunctionPrototypes
+XawToggleChangeRadioGroup(Widget w, Widget radio_group)
+#else
+XawToggleChangeRadioGroup(w, radio_group)
+Widget w, radio_group;
+#endif
+{
+ ToggleWidget tw = (ToggleWidget) w;
+ RadioGroup * group;
+
+ RemoveFromRadioGroup(w);
+
+/*
+ * If the toggle that we are about to add is set then we will
+ * unset all toggles in the new radio group.
+ */
+
+ if ( tw->command.set && radio_group != NULL )
+ XawToggleUnsetCurrent(radio_group);
+
+ if (radio_group != NULL)
+ if ((group = GetRadioGroup(radio_group)) == NULL)
+ CreateRadioGroup(w, radio_group);
+ else AddToRadioGroup(group, w);
+}
+
+/* Function Name: XawToggleGetCurrent
+ * Description: Returns the RadioData associated with the toggle
+ * widget that is currently active in a toggle group.
+ * Arguments: w - any toggle widget in the toggle group.
+ * Returns: The XtNradioData associated with the toggle widget.
+ */
+
+XtPointer
+#if NeedFunctionPrototypes
+XawToggleGetCurrent(Widget w)
+#else
+XawToggleGetCurrent(w)
+Widget w;
+#endif
+{
+ RadioGroup * group;
+
+ if ( (group = GetRadioGroup(w)) == NULL) return(NULL);
+ for ( ; group->prev != NULL ; group = group->prev);
+
+ while ( group != NULL ) {
+ ToggleWidget local_tog = (ToggleWidget) group->widget;
+ if ( local_tog->command.set )
+ return( local_tog->toggle.radio_data );
+ group = group->next;
+ }
+ return(NULL);
+}
+
+/* Function Name: XawToggleSetCurrent
+ * Description: Sets the Toggle widget associated with the
+ * radio_data specified.
+ * Arguments: radio_group - any toggle widget in the toggle group.
+ * radio_data - radio data of the toggle widget to set.
+ * Returns: none.
+ */
+
+void
+#if NeedFunctionPrototypes
+XawToggleSetCurrent(Widget radio_group, XtPointer radio_data)
+#else
+XawToggleSetCurrent(radio_group, radio_data)
+Widget radio_group;
+XtPointer radio_data;
+#endif
+{
+ RadioGroup * group;
+ ToggleWidget local_tog;
+
+/* Special case of no radio group. */
+
+ if ( (group = GetRadioGroup(radio_group)) == NULL) {
+ local_tog = (ToggleWidget) radio_group;
+ if ( (local_tog->toggle.radio_data == radio_data) )
+ if (!local_tog->command.set) {
+ ToggleSet((Widget) local_tog, (XEvent *)NULL, (String *)NULL, (Cardinal *)0);
+ Notify((Widget) local_tog, (XEvent *)NULL, (String *)NULL, (Cardinal *)0);
+ }
+ return;
+ }
+
+/*
+ * find top of radio_roup
+ */
+
+ for ( ; group->prev != NULL ; group = group->prev);
+
+/*
+ * search for matching radio data.
+ */
+
+ while ( group != NULL ) {
+ local_tog = (ToggleWidget) group->widget;
+ if ( (local_tog->toggle.radio_data == radio_data) ) {
+ if (!local_tog->command.set) { /* if not already set. */
+ ToggleSet((Widget) local_tog, (XEvent *)NULL, (String *)NULL, (Cardinal *)0);
+ Notify((Widget) local_tog, (XEvent *)NULL, (String *)NULL, (Cardinal *)0);
+ }
+ return; /* found it, done */
+ }
+ group = group->next;
+ }
+}
+
+/* Function Name: XawToggleUnsetCurrent
+ * Description: Unsets all Toggles in the radio_group specified.
+ * Arguments: radio_group - any toggle widget in the toggle group.
+ * Returns: none.
+ */
+
+void
+#if NeedFunctionPrototypes
+XawToggleUnsetCurrent(Widget radio_group)
+#else
+XawToggleUnsetCurrent(radio_group)
+Widget radio_group;
+#endif
+{
+ ToggleWidgetClass class;
+ ToggleWidget local_tog = (ToggleWidget) radio_group;
+
+ /* Special Case no radio group. */
+
+ if (local_tog->command.set) {
+ class = (ToggleWidgetClass) local_tog->core.widget_class;
+ class->toggle_class.Unset(radio_group, NULL, NULL, 0);
+ Notify(radio_group, (XEvent *)NULL, (String *)NULL, (Cardinal *)0);
+ }
+ if ( GetRadioGroup(radio_group) == NULL) return;
+ TurnOffRadioSiblings(radio_group);
+}
+
diff --git a/src/Tree.c b/src/Tree.c
new file mode 100644
index 0000000..d0e34d2
--- /dev/null
+++ b/src/Tree.c
@@ -0,0 +1,1007 @@
+/*
+ * $Xorg: Tree.c,v 1.4 2001/02/09 02:03:47 xorgcvs Exp $
+ *
+
+Copyright 1990, 1994, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+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
+OPEN GROUP 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 Open Group 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 Open Group.
+
+ * Copyright 1989 Prentice Hall
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose and without fee is hereby granted, provided that the above
+ * copyright notice appear in all copies and that both the copyright notice
+ * and this permission notice appear in supporting documentation.
+ *
+ * Prentice Hall and the authors disclaim all warranties with regard
+ * to this software, including all implied warranties of merchantability and
+ * fitness. In no event shall Prentice Hall or the authors be liable
+ * for any special, indirect or cosequential damages or any damages whatsoever
+ * resulting from loss of use, data or profits, whether in an action of
+ * contract, negligence or other tortious action, arising out of or in
+ * connection with the use or performance of this software.
+ *
+ * Authors: Jim Fulton, MIT X Consortium,
+ * based on a version by Douglas Young, Prentice Hall
+ *
+ * This widget is based on the Tree widget described on pages 397-419 of
+ * Douglas Young's book "The X Window System, Programming and Applications
+ * with Xt OSF/Motif Edition." The layout code has been rewritten to use
+ * additional blank space to make the structure of the graph easier to see
+ * as well as to support vertical trees.
+ */
+
+#include <X11/IntrinsicP.h>
+#include <X11/StringDefs.h>
+#include <X11/Xaw/XawInit.h>
+#include <X11/Xaw/Cardinals.h>
+#include <X11/Xaw/TreeP.h>
+
+#define IsHorizontal(tw) ((tw)->tree.gravity == WestGravity || \
+ (tw)->tree.gravity == EastGravity)
+
+
+ /* widget class method */
+static void ClassInitialize();
+static void Initialize();
+static void ConstraintInitialize();
+static void ConstraintDestroy();
+static Boolean ConstraintSetValues();
+static void Destroy();
+static Boolean SetValues();
+static XtGeometryResult GeometryManager();
+static void ChangeManaged();
+static void Redisplay();
+static XtGeometryResult QueryGeometry();
+
+ /* utility routines */
+static void insert_node();
+static void delete_node();
+static void layout_tree();
+
+
+/*
+ * resources of the tree itself
+ */
+static XtResource resources[] = {
+ { XtNautoReconfigure, XtCAutoReconfigure, XtRBoolean, sizeof (Boolean),
+ XtOffsetOf(TreeRec, tree.auto_reconfigure), XtRImmediate,
+ (XtPointer) FALSE },
+ { XtNhSpace, XtCHSpace, XtRDimension, sizeof (Dimension),
+ XtOffsetOf(TreeRec, tree.hpad), XtRImmediate, (XtPointer) 0 },
+ { XtNvSpace, XtCVSpace, XtRDimension, sizeof (Dimension),
+ XtOffsetOf(TreeRec, tree.vpad), XtRImmediate, (XtPointer) 0 },
+ { XtNforeground, XtCForeground, XtRPixel, sizeof (Pixel),
+ XtOffsetOf(TreeRec, tree.foreground), XtRString,
+ XtDefaultForeground},
+ { XtNlineWidth, XtCLineWidth, XtRDimension, sizeof (Dimension),
+ XtOffsetOf(TreeRec, tree.line_width), XtRImmediate, (XtPointer) 0 },
+ { XtNgravity, XtCGravity, XtRGravity, sizeof (XtGravity),
+ XtOffsetOf(TreeRec, tree.gravity), XtRImmediate,
+ (XtPointer) WestGravity },
+};
+
+
+/*
+ * resources that are attached to all children of the tree
+ */
+static XtResource treeConstraintResources[] = {
+ { XtNtreeParent, XtCTreeParent, XtRWidget, sizeof (Widget),
+ XtOffsetOf(TreeConstraintsRec, tree.parent), XtRImmediate, NULL },
+ { XtNtreeGC, XtCTreeGC, XtRGC, sizeof(GC),
+ XtOffsetOf(TreeConstraintsRec, tree.gc), XtRImmediate, NULL },
+};
+
+
+TreeClassRec treeClassRec = {
+ {
+ /* core_class fields */
+ (WidgetClass) &constraintClassRec, /* superclass */
+ "Tree", /* class_name */
+ sizeof(TreeRec), /* widget_size */
+ ClassInitialize, /* class_init */
+ NULL, /* class_part_init */
+ FALSE, /* class_inited */
+ Initialize, /* initialize */
+ NULL, /* initialize_hook */
+ XtInheritRealize, /* realize */
+ NULL, /* actions */
+ 0, /* num_actions */
+ resources, /* resources */
+ XtNumber(resources), /* num_resources */
+ NULLQUARK, /* xrm_class */
+ TRUE, /* compress_motion */
+ TRUE, /* compress_exposure */
+ TRUE, /* compress_enterleave*/
+ TRUE, /* visible_interest */
+ Destroy, /* destroy */
+ NULL, /* resize */
+ Redisplay, /* expose */
+ SetValues, /* set_values */
+ NULL, /* set_values_hook */
+ XtInheritSetValuesAlmost, /* set_values_almost */
+ NULL, /* get_values_hook */
+ NULL, /* accept_focus */
+ XtVersion, /* version */
+ NULL, /* callback_private */
+ NULL, /* tm_table */
+ QueryGeometry, /* query_geometry */
+ NULL, /* display_accelerator*/
+ NULL, /* extension */
+ },
+ {
+ /* composite_class fields */
+ GeometryManager, /* geometry_manager */
+ ChangeManaged, /* change_managed */
+ XtInheritInsertChild, /* insert_child */
+ XtInheritDeleteChild, /* delete_child */
+ NULL, /* extension */
+ },
+ {
+ /* constraint_class fields */
+ treeConstraintResources, /* subresources */
+ XtNumber(treeConstraintResources), /* subresource_count */
+ sizeof(TreeConstraintsRec), /* constraint_size */
+ ConstraintInitialize, /* initialize */
+ ConstraintDestroy, /* destroy */
+ ConstraintSetValues, /* set_values */
+ NULL, /* extension */
+ },
+ {
+ /* Tree class fields */
+ 0, /* ignore */
+ }
+};
+
+WidgetClass treeWidgetClass = (WidgetClass) &treeClassRec;
+
+
+/*****************************************************************************
+ * *
+ * tree utility routines *
+ * *
+ *****************************************************************************/
+
+static void initialize_dimensions (listp, sizep, n)
+ Dimension **listp;
+ int *sizep;
+ int n;
+{
+ int i;
+ Dimension *l;
+
+ if (!*listp) {
+ *listp = (Dimension *) XtCalloc ((unsigned int) n,
+ (unsigned int) sizeof(Dimension));
+ *sizep = ((*listp) ? n : 0);
+ return;
+ }
+ if (n > *sizep) {
+ *listp = (Dimension *) XtRealloc((char *) *listp,
+ (unsigned int) (n*sizeof(Dimension)));
+ if (!*listp) {
+ *sizep = 0;
+ return;
+ }
+ for (i = *sizep, l = (*listp) + i; i < n; i++, l++) *l = 0;
+ *sizep = n;
+ }
+ return;
+}
+
+static GC get_tree_gc (w)
+ TreeWidget w;
+{
+ XtGCMask valuemask = GCBackground | GCForeground;
+ XGCValues values;
+
+ values.background = w->core.background_pixel;
+ values.foreground = w->tree.foreground;
+ if (w->tree.line_width != 0) {
+ valuemask |= GCLineWidth;
+ values.line_width = w->tree.line_width;
+ }
+
+ return XtGetGC ((Widget) w, valuemask, &values);
+}
+
+static void insert_node (parent, node)
+ Widget parent, node;
+{
+ TreeConstraints pc;
+ TreeConstraints nc = TREE_CONSTRAINT(node);
+ int nindex;
+
+ nc->tree.parent = parent;
+
+ if (parent == NULL) return;
+
+ /*
+ * If there isn't more room in the children array,
+ * allocate additional space.
+ */
+ pc = TREE_CONSTRAINT(parent);
+ nindex = pc->tree.n_children;
+
+ if (pc->tree.n_children == pc->tree.max_children) {
+ pc->tree.max_children += (pc->tree.max_children / 2) + 2;
+ pc->tree.children = (WidgetList) XtRealloc ((char *)pc->tree.children,
+ (unsigned int)
+ ((pc->tree.max_children) *
+ sizeof(Widget)));
+ }
+
+ /*
+ * Add the sub_node in the next available slot and
+ * increment the counter.
+ */
+ pc->tree.children[nindex] = node;
+ pc->tree.n_children++;
+}
+
+static void delete_node (parent, node)
+ Widget parent, node;
+{
+ TreeConstraints pc;
+ int pos, i;
+
+ /*
+ * Make sure the parent exists.
+ */
+ if (!parent) return;
+
+ pc = TREE_CONSTRAINT(parent);
+
+ /*
+ * Find the sub_node on its parent's list.
+ */
+ for (pos = 0; pos < pc->tree.n_children; pos++)
+ if (pc->tree.children[pos] == node) break;
+
+ if (pos == pc->tree.n_children) return;
+
+ /*
+ * Decrement the number of children
+ */
+ pc->tree.n_children--;
+
+ /*
+ * Fill in the gap left by the sub_node.
+ * Zero the last slot for good luck.
+ */
+ for (i = pos; i < pc->tree.n_children; i++)
+ pc->tree.children[i] = pc->tree.children[i+1];
+
+ pc->tree.children[pc->tree.n_children]=0;
+}
+
+static void check_gravity (tw, grav)
+ TreeWidget tw;
+ XtGravity grav;
+{
+ switch (tw->tree.gravity) {
+ case WestGravity: case NorthGravity: case EastGravity: case SouthGravity:
+ break;
+ default:
+ tw->tree.gravity = grav;
+ break;
+ }
+}
+
+
+/*****************************************************************************
+ * *
+ * tree class methods *
+ * *
+ *****************************************************************************/
+
+static void ClassInitialize ()
+{
+ XawInitializeWidgetSet();
+ XtAddConverter (XtRString, XtRGravity, XmuCvtStringToGravity,
+ (XtConvertArgList) NULL, (Cardinal) 0);
+}
+
+
+/*ARGSUSED*/
+static void Initialize (grequest, gnew, args, num_args)
+ Widget grequest, gnew;
+ ArgList args;
+ Cardinal *num_args;
+{
+ TreeWidget request = (TreeWidget) grequest, new = (TreeWidget) gnew;
+ Arg arglist[2];
+
+ /*
+ * Make sure the widget's width and height are
+ * greater than zero.
+ */
+ if (request->core.width <= 0) new->core.width = 5;
+ if (request->core.height <= 0) new->core.height = 5;
+
+ /*
+ * Set the padding according to the orientation
+ */
+ if (request->tree.hpad == 0 && request->tree.vpad == 0) {
+ if (IsHorizontal (request)) {
+ new->tree.hpad = TREE_HORIZONTAL_DEFAULT_SPACING;
+ new->tree.vpad = TREE_VERTICAL_DEFAULT_SPACING;
+ } else {
+ new->tree.hpad = TREE_VERTICAL_DEFAULT_SPACING;
+ new->tree.vpad = TREE_HORIZONTAL_DEFAULT_SPACING;
+ }
+ }
+
+ /*
+ * Create a graphics context for the connecting lines.
+ */
+ new->tree.gc = get_tree_gc (new);
+
+ /*
+ * Create the hidden root widget.
+ */
+ new->tree.tree_root = (Widget) NULL;
+ XtSetArg(arglist[0], XtNwidth, 1);
+ XtSetArg(arglist[1], XtNheight, 1);
+ new->tree.tree_root = XtCreateWidget ("root", widgetClass, gnew,
+ arglist,TWO);
+
+ /*
+ * Allocate the array used to hold the widest values per depth
+ */
+ new->tree.largest = NULL;
+ new->tree.n_largest = 0;
+ initialize_dimensions (&new->tree.largest, &new->tree.n_largest,
+ TREE_INITIAL_DEPTH);
+
+ /*
+ * make sure that our gravity is one of the acceptable values
+ */
+ check_gravity (new, WestGravity);
+}
+
+
+/* ARGSUSED */
+static void ConstraintInitialize (request, new, args, num_args)
+ Widget request, new;
+ ArgList args;
+ Cardinal *num_args;
+{
+ TreeConstraints tc = TREE_CONSTRAINT(new);
+ TreeWidget tw = (TreeWidget) new->core.parent;
+
+ /*
+ * Initialize the widget to have no sub-nodes.
+ */
+ tc->tree.n_children = 0;
+ tc->tree.max_children = 0;
+ tc->tree.children = (Widget *) NULL;
+ tc->tree.x = tc->tree.y = 0;
+ tc->tree.bbsubwidth = 0;
+ tc->tree.bbsubheight = 0;
+
+
+ /*
+ * If this widget has a super-node, add it to that
+ * widget' sub-nodes list. Otherwise make it a sub-node of
+ * the tree_root widget.
+ */
+ if (tc->tree.parent)
+ insert_node (tc->tree.parent, new);
+ else if (tw->tree.tree_root)
+ insert_node (tw->tree.tree_root, new);
+}
+
+
+/* ARGSUSED */
+static Boolean SetValues (gcurrent, grequest, gnew, args, num_args)
+ Widget gcurrent, grequest, gnew;
+ ArgList args;
+ Cardinal *num_args;
+{
+ TreeWidget current = (TreeWidget) gcurrent, new = (TreeWidget) gnew;
+ Boolean redraw = FALSE;
+
+ /*
+ * If the foreground color has changed, redo the GC's
+ * and indicate a redraw.
+ */
+ if (new->tree.foreground != current->tree.foreground ||
+ new->core.background_pixel != current->core.background_pixel ||
+ new->tree.line_width != current->tree.line_width) {
+ XtReleaseGC (gnew, new->tree.gc);
+ new->tree.gc = get_tree_gc (new);
+ redraw = TRUE;
+ }
+
+ /*
+ * If the minimum spacing has changed, recalculate the
+ * tree layout. layout_tree() does a redraw, so we don't
+ * need SetValues to do another one.
+ */
+ if (new->tree.gravity != current->tree.gravity) {
+ check_gravity (new, current->tree.gravity);
+ }
+
+ if (IsHorizontal(new) != IsHorizontal(current)) {
+ if (new->tree.vpad == current->tree.vpad &&
+ new->tree.hpad == current->tree.hpad) {
+ new->tree.vpad = current->tree.hpad;
+ new->tree.hpad = current->tree.vpad;
+ }
+ }
+
+ if (new->tree.vpad != current->tree.vpad ||
+ new->tree.hpad != current->tree.hpad ||
+ new->tree.gravity != current->tree.gravity) {
+ layout_tree (new, TRUE);
+ redraw = FALSE;
+ }
+ return redraw;
+}
+
+
+/* ARGSUSED */
+static Boolean ConstraintSetValues (current, request, new, args, num_args)
+ Widget current, request, new;
+ ArgList args;
+ Cardinal *num_args;
+{
+ TreeConstraints newc = TREE_CONSTRAINT(new);
+ TreeConstraints curc = TREE_CONSTRAINT(current);
+ TreeWidget tw = (TreeWidget) new->core.parent;
+
+ /*
+ * If the parent field has changed, remove the widget
+ * from the old widget's children list and add it to the
+ * new one.
+ */
+ if (curc->tree.parent != newc->tree.parent){
+ if (curc->tree.parent)
+ delete_node (curc->tree.parent, new);
+ if (newc->tree.parent)
+ insert_node(newc->tree.parent, new);
+
+ /*
+ * If the Tree widget has been realized,
+ * compute new layout.
+ */
+ if (XtIsRealized((Widget)tw))
+ layout_tree (tw, FALSE);
+ }
+ return False;
+}
+
+
+static void ConstraintDestroy (w)
+ Widget w;
+{
+ TreeConstraints tc = TREE_CONSTRAINT(w);
+ TreeWidget tw = (TreeWidget) XtParent(w);
+ int i;
+
+ /*
+ * Remove the widget from its parent's sub-nodes list and
+ * make all this widget's sub-nodes sub-nodes of the parent.
+ */
+
+ if (tw->tree.tree_root == w) {
+ if (tc->tree.n_children > 0)
+ tw->tree.tree_root = tc->tree.children[0];
+ else
+ tw->tree.tree_root = NULL;
+ }
+
+ delete_node (tc->tree.parent, (Widget) w);
+ for (i = 0; i< tc->tree.n_children; i++)
+ insert_node (tc->tree.parent, tc->tree.children[i]);
+
+ layout_tree ((TreeWidget) (w->core.parent), FALSE);
+}
+
+/* ARGSUSED */
+static XtGeometryResult GeometryManager (w, request, reply)
+ Widget w;
+ XtWidgetGeometry *request;
+ XtWidgetGeometry *reply;
+{
+
+ TreeWidget tw = (TreeWidget) w->core.parent;
+
+ /*
+ * No position changes allowed!.
+ */
+ if ((request->request_mode & CWX && request->x!=w->core.x)
+ ||(request->request_mode & CWY && request->y!=w->core.y))
+ return (XtGeometryNo);
+
+ /*
+ * Allow all resize requests.
+ */
+
+ if (request->request_mode & CWWidth)
+ w->core.width = request->width;
+ if (request->request_mode & CWHeight)
+ w->core.height = request->height;
+ if (request->request_mode & CWBorderWidth)
+ w->core.border_width = request->border_width;
+
+ if (tw->tree.auto_reconfigure) layout_tree (tw, FALSE);
+ return (XtGeometryYes);
+}
+
+static void ChangeManaged (gw)
+ Widget gw;
+{
+ layout_tree ((TreeWidget) gw, FALSE);
+}
+
+
+static void Destroy (gw)
+ Widget gw;
+{
+ TreeWidget w = (TreeWidget) gw;
+
+ XtReleaseGC (gw, w->tree.gc);
+ if (w->tree.largest) XtFree ((char *) w->tree.largest);
+}
+
+
+/* ARGSUSED */
+static void Redisplay (gw, event, region)
+ Widget gw;
+ XEvent *event;
+ Region region;
+{
+ TreeWidget tw = (TreeWidget) gw;
+
+ /*
+ * If the Tree widget is visible, visit each managed child.
+ */
+ if (tw->core.visible) {
+ int i, j;
+ Display *dpy = XtDisplay (tw);
+ Window w = XtWindow (tw);
+
+ for (i = 0; i < tw->composite.num_children; i++) {
+ Widget child = tw->composite.children[i];
+ TreeConstraints tc = TREE_CONSTRAINT(child);
+
+ /*
+ * Don't draw lines from the fake tree_root.
+ */
+ if (child != tw->tree.tree_root && tc->tree.n_children) {
+ int srcx = child->core.x + child->core.border_width;
+ int srcy = child->core.y + child->core.border_width;
+
+ switch (tw->tree.gravity) {
+ case WestGravity:
+ srcx += child->core.width + child->core.border_width;
+ /* fall through */
+ case EastGravity:
+ srcy += child->core.height / 2;
+ break;
+
+ case NorthGravity:
+ srcy += child->core.height + child->core.border_width;
+ /* fall through */
+ case SouthGravity:
+ srcx += child->core.width / 2;
+ break;
+ }
+
+ for (j = 0; j < tc->tree.n_children; j++) {
+ Widget k = tc->tree.children[j];
+ GC gc = (tc->tree.gc ? tc->tree.gc : tw->tree.gc);
+
+ switch (tw->tree.gravity) {
+ case WestGravity:
+ /*
+ * right center to left center
+ */
+ XDrawLine (dpy, w, gc, srcx, srcy,
+ (int) k->core.x,
+ (k->core.y + ((int) k->core.border_width) +
+ ((int) k->core.height) / 2));
+ break;
+
+ case NorthGravity:
+ /*
+ * bottom center to top center
+ */
+ XDrawLine (dpy, w, gc, srcx, srcy,
+ (k->core.x + ((int) k->core.border_width) +
+ ((int) k->core.width) / 2),
+ (int) k->core.y);
+ break;
+
+ case EastGravity:
+ /*
+ * left center to right center
+ */
+ XDrawLine (dpy, w, gc, srcx, srcy,
+ (k->core.x +
+ (((int) k->core.border_width) << 1) +
+ (int) k->core.width),
+ (k->core.y + ((int) k->core.border_width) +
+ ((int) k->core.height) / 2));
+ break;
+
+ case SouthGravity:
+ /*
+ * top center to bottom center
+ */
+ XDrawLine (dpy, w, gc, srcx, srcy,
+ (k->core.x + ((int) k->core.border_width) +
+ ((int) k->core.width) / 2),
+ (k->core.y +
+ (((int) k->core.border_width) << 1) +
+ (int) k->core.height));
+ break;
+ }
+ }
+ }
+ }
+ }
+}
+
+static XtGeometryResult QueryGeometry (w, intended, preferred)
+ Widget w;
+ XtWidgetGeometry *intended, *preferred;
+{
+ TreeWidget tw = (TreeWidget) w;
+
+ preferred->request_mode = (CWWidth | CWHeight);
+ preferred->width = tw->tree.maxwidth;
+ preferred->height = tw->tree.maxheight;
+
+ if (((intended->request_mode & (CWWidth | CWHeight)) ==
+ (CWWidth | CWHeight)) &&
+ intended->width == preferred->width &&
+ intended->height == preferred->height)
+ return XtGeometryYes;
+ else if (preferred->width == w->core.width &&
+ preferred->height == w->core.height)
+ return XtGeometryNo;
+ else
+ return XtGeometryAlmost;
+}
+
+
+/*****************************************************************************
+ * *
+ * tree layout algorithm *
+ * *
+ * Each node in the tree is "shrink-wrapped" with a minimal bounding *
+ * rectangle, laid next to its siblings (with a small about of padding in *
+ * between) and then wrapped with their parent. Parents are centered about *
+ * their children (or vice versa if the parent is larger than the children). *
+ * *
+ *****************************************************************************/
+
+static void compute_bounding_box_subtree (tree, w, depth)
+ TreeWidget tree;
+ Widget w;
+ int depth;
+{
+ TreeConstraints tc = TREE_CONSTRAINT(w); /* info attached to all kids */
+ int i;
+ Bool horiz = IsHorizontal (tree);
+ Dimension newwidth, newheight;
+ Dimension bw2 = w->core.border_width * 2;
+
+ /*
+ * Set the max-size per level.
+ */
+ if (depth >= tree->tree.n_largest) {
+ initialize_dimensions (&tree->tree.largest,
+ &tree->tree.n_largest, depth + 1);
+ }
+ newwidth = ((horiz ? w->core.width : w->core.height) + bw2);
+ if (tree->tree.largest[depth] < newwidth)
+ tree->tree.largest[depth] = newwidth;
+
+
+ /*
+ * initialize
+ */
+ tc->tree.bbwidth = w->core.width + bw2;
+ tc->tree.bbheight = w->core.height + bw2;
+
+ if (tc->tree.n_children == 0) return;
+
+ /*
+ * Figure the size of the opposite dimension (vertical if tree is
+ * horizontal, else vice versa). The other dimension will be set
+ * in the second pass once we know the maximum dimensions.
+ */
+ newwidth = 0;
+ newheight = 0;
+ for (i = 0; i < tc->tree.n_children; i++) {
+ Widget child = tc->tree.children[i];
+ TreeConstraints cc = TREE_CONSTRAINT(child);
+
+ compute_bounding_box_subtree (tree, child, depth + 1);
+
+ if (horiz) {
+ if (newwidth < cc->tree.bbwidth) newwidth = cc->tree.bbwidth;
+ newheight += tree->tree.vpad + cc->tree.bbheight;
+ } else {
+ if (newheight < cc->tree.bbheight) newheight = cc->tree.bbheight;
+ newwidth += tree->tree.hpad + cc->tree.bbwidth;
+ }
+ }
+
+
+ tc->tree.bbsubwidth = newwidth;
+ tc->tree.bbsubheight = newheight;
+
+ /*
+ * Now fit parent onto side (or top) of bounding box and correct for
+ * extra padding. Be careful of unsigned arithmetic.
+ */
+ if (horiz) {
+ tc->tree.bbwidth += tree->tree.hpad + newwidth;
+ newheight -= tree->tree.vpad;
+ if (newheight > tc->tree.bbheight) tc->tree.bbheight = newheight;
+ } else {
+ tc->tree.bbheight += tree->tree.vpad + newheight;
+ newwidth -= tree->tree.hpad;
+ if (newwidth > tc->tree.bbwidth) tc->tree.bbwidth = newwidth;
+ }
+}
+
+
+static void set_positions (tw, w, level)
+ TreeWidget tw;
+ Widget w;
+ int level;
+{
+ int i;
+
+ if (w) {
+ TreeConstraints tc = TREE_CONSTRAINT(w);
+
+ if (level > 0) {
+ /*
+ * mirror if necessary
+ */
+ switch (tw->tree.gravity) {
+ case EastGravity:
+ tc->tree.x = (((Position) tw->tree.maxwidth) -
+ ((Position) w->core.width) - tc->tree.x);
+ break;
+
+ case SouthGravity:
+ tc->tree.y = (((Position) tw->tree.maxheight) -
+ ((Position) w->core.height) - tc->tree.y);
+ break;
+ }
+
+ /*
+ * Move the widget into position.
+ */
+ XtMoveWidget (w, tc->tree.x, tc->tree.y);
+ }
+
+ /*
+ * Set the positions of all children.
+ */
+ for (i = 0; i < tc->tree.n_children; i++)
+ set_positions (tw, tc->tree.children[i], level + 1);
+ }
+}
+
+
+static void arrange_subtree (tree, w, depth, x, y)
+ TreeWidget tree;
+ Widget w;
+ int depth;
+ Position x, y;
+{
+ TreeConstraints tc = TREE_CONSTRAINT(w); /* info attached to all kids */
+ TreeConstraints firstcc, lastcc;
+ int i;
+ int newx, newy;
+ Bool horiz = IsHorizontal (tree);
+ Widget child = NULL;
+ Dimension tmp;
+ Dimension bw2 = w->core.border_width * 2;
+ Bool relayout = True;
+
+
+ /*
+ * If no children, then just lay out where requested.
+ */
+ tc->tree.x = x;
+ tc->tree.y = y;
+
+ if (horiz) {
+ int myh = (w->core.height + bw2);
+
+ if (myh > (int)tc->tree.bbsubheight) {
+ y += (myh - (int)tc->tree.bbsubheight) / 2;
+ relayout = False;
+ }
+ } else {
+ int myw = (w->core.width + bw2);
+
+ if (myw > (int)tc->tree.bbsubwidth) {
+ x += (myw - (int)tc->tree.bbsubwidth) / 2;
+ relayout = False;
+ }
+ }
+
+ if ((tmp = ((Dimension) x) + tc->tree.bbwidth) > tree->tree.maxwidth)
+ tree->tree.maxwidth = tmp;
+ if ((tmp = ((Dimension) y) + tc->tree.bbheight) > tree->tree.maxheight)
+ tree->tree.maxheight = tmp;
+
+ if (tc->tree.n_children == 0) return;
+
+
+ /*
+ * Have children, so walk down tree laying out children, then laying
+ * out parents.
+ */
+ if (horiz) {
+ newx = x + tree->tree.largest[depth];
+ if (depth > 0) newx += tree->tree.hpad;
+ newy = y;
+ } else {
+ newx = x;
+ newy = y + tree->tree.largest[depth];
+ if (depth > 0) newy += tree->tree.vpad;
+ }
+
+ for (i = 0; i < tc->tree.n_children; i++) {
+ TreeConstraints cc;
+
+ child = tc->tree.children[i]; /* last value is used outside loop */
+ cc = TREE_CONSTRAINT(child);
+
+ arrange_subtree (tree, child, depth + 1, newx, newy);
+ if (horiz) {
+ newy += tree->tree.vpad + cc->tree.bbheight;
+ } else {
+ newx += tree->tree.hpad + cc->tree.bbwidth;
+ }
+ }
+
+ /*
+ * now layout parent between first and last children
+ */
+ if (relayout) {
+ Position adjusted;
+ firstcc = TREE_CONSTRAINT (tc->tree.children[0]);
+ lastcc = TREE_CONSTRAINT (child);
+
+ /* Adjustments are disallowed if they result in a position above
+ * or to the left of the originally requested position, because
+ * this could collide with the position of the previous sibling.
+ */
+ if (horiz) {
+ tc->tree.x = x;
+ adjusted = firstcc->tree.y +
+ ((lastcc->tree.y + (Position) child->core.height +
+ (Position) child->core.border_width * 2 -
+ firstcc->tree.y - (Position) w->core.height -
+ (Position) w->core.border_width * 2 + 1) / 2);
+ if (adjusted > tc->tree.y) tc->tree.y = adjusted;
+ } else {
+ adjusted = firstcc->tree.x +
+ ((lastcc->tree.x + (Position) child->core.width +
+ (Position) child->core.border_width * 2 -
+ firstcc->tree.x - (Position) w->core.width -
+ (Position) w->core.border_width * 2 + 1) / 2);
+ if (adjusted > tc->tree.x) tc->tree.x = adjusted;
+ tc->tree.y = y;
+ }
+ }
+}
+
+static void set_tree_size (tw, insetvalues, width, height)
+ TreeWidget tw;
+ Boolean insetvalues;
+ Dimension width, height;
+{
+ if (insetvalues) {
+ tw->core.width = width;
+ tw->core.height = height;
+ } else {
+ Dimension replyWidth = 0, replyHeight = 0;
+ XtGeometryResult result = XtMakeResizeRequest ((Widget) tw,
+ width, height,
+ &replyWidth,
+ &replyHeight);
+ /*
+ * Accept any compromise.
+ */
+ if (result == XtGeometryAlmost)
+ XtMakeResizeRequest ((Widget) tw, replyWidth, replyHeight,
+ (Dimension *) NULL, (Dimension *) NULL);
+ }
+ return;
+}
+
+static void layout_tree (tw, insetvalues)
+ TreeWidget tw;
+ Boolean insetvalues;
+{
+ int i;
+ Dimension *dp;
+
+ /*
+ * Do a depth-first search computing the width and height of the bounding
+ * box for the tree at that position (and below). Then, walk again using
+ * this information to layout the children at each level.
+ */
+
+ if (tw->tree.tree_root == NULL)
+ return;
+
+ tw->tree.maxwidth = tw->tree.maxheight = 0;
+ for (i = 0, dp = tw->tree.largest; i < tw->tree.n_largest; i++, dp++)
+ *dp = 0;
+ initialize_dimensions (&tw->tree.largest, &tw->tree.n_largest,
+ tw->tree.n_largest);
+ compute_bounding_box_subtree (tw, tw->tree.tree_root, 0);
+
+ /*
+ * Second pass to do final layout. Each child's bounding box is stacked
+ * on top of (if horizontal, else next to) on top of its siblings. The
+ * parent is centered between the first and last children.
+ */
+ arrange_subtree (tw, tw->tree.tree_root, 0, 0, 0);
+
+ /*
+ * Move each widget into place.
+ */
+ set_tree_size (tw, insetvalues, tw->tree.maxwidth, tw->tree.maxheight);
+ set_positions (tw, tw->tree.tree_root, 0);
+
+ /*
+ * And redisplay.
+ */
+ if (XtIsRealized ((Widget) tw)) {
+ XClearArea (XtDisplay(tw), XtWindow((Widget)tw), 0, 0, 0, 0, True);
+ }
+}
+
+
+
+/*****************************************************************************
+ * *
+ * Public Routines *
+ * *
+ *****************************************************************************/
+
+void
+#if NeedFunctionPrototypes
+XawTreeForceLayout (Widget tree)
+#else
+XawTreeForceLayout (tree)
+ Widget tree;
+#endif
+{
+ layout_tree ((TreeWidget) tree, FALSE);
+}
+
diff --git a/src/Vendor.c b/src/Vendor.c
new file mode 100644
index 0000000..17cd17b
--- /dev/null
+++ b/src/Vendor.c
@@ -0,0 +1,460 @@
+/* $Xorg: Vendor.c,v 1.4 2001/02/09 02:03:47 xorgcvs Exp $ */
+
+/***********************************************************
+
+Copyright 1987, 1988, 1994, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+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
+OPEN GROUP 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 Open Group 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 Open Group.
+
+
+Copyright 1987, 1988 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+******************************************************************/
+
+/*
+ * This is a copy of Xt/Vendor.c with an additional ClassInitialize
+ * procedure to register Xmu resource type converters, and all the
+ * monkey business associated with input methods...
+ *
+ */
+
+/* Make sure all wm properties can make it out of the resource manager */
+
+#include <stdio.h>
+#include <X11/IntrinsicP.h>
+#include <X11/StringDefs.h>
+#include <X11/ShellP.h>
+#include <X11/VendorP.h>
+#include <X11/Xmu/Converters.h>
+#include <X11/Xmu/Atoms.h>
+#include <X11/Xmu/Editres.h>
+#include <X11/Xmu/ExtAgent.h>
+
+/* The following two headers are for the input method. */
+
+#include <X11/Xaw/VendorEP.h>
+#include <X11/Xaw/XawImP.h>
+
+
+static XtResource resources[] = {
+ {XtNinput, XtCInput, XtRBool, sizeof(Bool),
+ XtOffsetOf(VendorShellRec, wm.wm_hints.input),
+ XtRImmediate, (XtPointer)True}
+};
+
+/***************************************************************************
+ *
+ * Vendor shell class record
+ *
+ ***************************************************************************/
+
+static void XawVendorShellClassInitialize();
+static void XawVendorShellClassPartInit();
+static void XawVendorShellInitialize();
+static Boolean XawVendorShellSetValues();
+static void Realize(), ChangeManaged();
+static XtGeometryResult GeometryManager();
+void XawVendorShellExtResize();
+
+static CompositeClassExtensionRec vendorCompositeExt = {
+ /* next_extension */ NULL,
+ /* record_type */ NULLQUARK,
+ /* version */ XtCompositeExtensionVersion,
+ /* record_size */ sizeof (CompositeClassExtensionRec),
+ /* accepts_objects */ TRUE,
+ /* allows_change_managed_set */ FALSE
+};
+
+#define SuperClass (&wmShellClassRec)
+externaldef(vendorshellclassrec) VendorShellClassRec vendorShellClassRec = {
+ {
+ /* superclass */ (WidgetClass)SuperClass,
+ /* class_name */ "VendorShell",
+ /* size */ sizeof(VendorShellRec),
+ /* class_initialize */ XawVendorShellClassInitialize,
+ /* class_part_init */ XawVendorShellClassPartInit,
+ /* Class init'ed ? */ FALSE,
+ /* initialize */ XawVendorShellInitialize,
+ /* initialize_hook */ NULL,
+ /* realize */ Realize,
+ /* actions */ NULL,
+ /* num_actions */ 0,
+ /* resources */ resources,
+ /* resource_count */ XtNumber(resources),
+ /* xrm_class */ NULLQUARK,
+ /* compress_motion */ FALSE,
+ /* compress_exposure */ TRUE,
+ /* compress_enterleave*/ FALSE,
+ /* visible_interest */ FALSE,
+ /* destroy */ NULL,
+ /* resize */ XawVendorShellExtResize,
+ /* expose */ NULL,
+ /* set_values */ XawVendorShellSetValues,
+ /* set_values_hook */ NULL,
+ /* set_values_almost */ XtInheritSetValuesAlmost,
+ /* get_values_hook */ NULL,
+ /* accept_focus */ NULL,
+ /* intrinsics version */ XtVersion,
+ /* callback offsets */ NULL,
+ /* tm_table */ NULL,
+ /* query_geometry */ NULL,
+ /* display_accelerator*/ NULL,
+ /* extension */ NULL
+ },{
+ /* geometry_manager */ GeometryManager,
+ /* change_managed */ ChangeManaged,
+ /* insert_child */ XtInheritInsertChild,
+ /* delete_child */ XtInheritDeleteChild,
+ /* extension */ (XtPointer) &vendorCompositeExt
+ },{
+ /* extension */ NULL
+ },{
+ /* extension */ NULL
+ },{
+ /* extension */ NULL
+ }
+};
+
+externaldef(vendorshellwidgetclass) WidgetClass vendorShellWidgetClass =
+ (WidgetClass) (&vendorShellClassRec);
+
+
+/***************************************************************************
+ *
+ * The following section is for the Vendor shell Extension class record
+ *
+ ***************************************************************************/
+
+static XtResource ext_resources[] = {
+ {XtNinputMethod, XtCInputMethod, XtRString, sizeof(String),
+ XtOffsetOf(XawVendorShellExtRec, vendor_ext.im.input_method),
+ XtRString, (XtPointer)NULL},
+ {XtNpreeditType, XtCPreeditType, XtRString, sizeof(String),
+ XtOffsetOf(XawVendorShellExtRec, vendor_ext.im.preedit_type),
+ XtRString, (XtPointer)"OverTheSpot,OffTheSpot,Root"},
+ {XtNopenIm, XtCOpenIm, XtRBoolean, sizeof(Boolean),
+ XtOffsetOf(XawVendorShellExtRec, vendor_ext.im.open_im),
+ XtRImmediate, (XtPointer)TRUE},
+ {XtNsharedIc, XtCSharedIc, XtRBoolean, sizeof(Boolean),
+ XtOffsetOf(XawVendorShellExtRec, vendor_ext.ic.shared_ic),
+ XtRImmediate, (XtPointer)FALSE}
+};
+
+static void XawVendorShellExtClassInitialize();
+static void XawVendorShellExtInitialize();
+static void XawVendorShellExtDestroy();
+static Boolean XawVendorShellExtSetValues();
+
+externaldef(vendorshellextclassrec) XawVendorShellExtClassRec
+ xawvendorShellExtClassRec = {
+ {
+ /* superclass */ (WidgetClass)&objectClassRec,
+ /* class_name */ "VendorShellExt",
+ /* size */ sizeof(XawVendorShellExtRec),
+ /* class_initialize */ XawVendorShellExtClassInitialize,
+ /* class_part_initialize*/ NULL,
+ /* Class init'ed ? */ FALSE,
+ /* initialize */ XawVendorShellExtInitialize,
+ /* initialize_hook */ NULL,
+ /* pad */ NULL,
+ /* pad */ NULL,
+ /* pad */ 0,
+ /* resources */ ext_resources,
+ /* resource_count */ XtNumber(ext_resources),
+ /* xrm_class */ NULLQUARK,
+ /* pad */ FALSE,
+ /* pad */ FALSE,
+ /* pad */ FALSE,
+ /* pad */ FALSE,
+ /* destroy */ XawVendorShellExtDestroy,
+ /* pad */ NULL,
+ /* pad */ NULL,
+ /* set_values */ XawVendorShellExtSetValues,
+ /* set_values_hook */ NULL,
+ /* pad */ NULL,
+ /* get_values_hook */ NULL,
+ /* pad */ NULL,
+ /* version */ XtVersion,
+ /* callback_offsets */ NULL,
+ /* pad */ NULL,
+ /* pad */ NULL,
+ /* pad */ NULL,
+ /* extension */ NULL
+ },{
+ /* extension */ NULL
+ }
+};
+
+externaldef(xawvendorshellwidgetclass) WidgetClass
+ xawvendorShellExtWidgetClass = (WidgetClass) (&xawvendorShellExtClassRec);
+
+
+/*ARGSUSED*/
+static Boolean
+XawCvtCompoundTextToString(dpy, args, num_args, fromVal, toVal, cvt_data)
+Display *dpy;
+XrmValuePtr args;
+Cardinal *num_args;
+XrmValue *fromVal;
+XrmValue *toVal;
+XtPointer *cvt_data;
+{
+ XTextProperty prop;
+ char **list;
+ int count;
+ static char *mbs = NULL;
+ int len;
+
+ prop.value = (unsigned char *)fromVal->addr;
+ prop.encoding = XA_COMPOUND_TEXT(dpy);
+ prop.format = 8;
+ prop.nitems = fromVal->size;
+
+ if(XmbTextPropertyToTextList(dpy, &prop, &list, &count) < Success) {
+ XtAppWarningMsg(XtDisplayToApplicationContext(dpy),
+ "converter", "XmbTextPropertyToTextList", "XawError",
+ "conversion from CT to MB failed.", NULL, 0);
+ return False;
+ }
+ len = strlen(*list);
+ toVal->size = len;
+ mbs = XtRealloc(mbs, len + 1); /* keep buffer because no one call free :( */
+ strcpy(mbs, *list);
+ XFreeStringList(list);
+ toVal->addr = (XtPointer)mbs;
+ return True;
+}
+
+static void XawVendorShellClassInitialize()
+{
+ static XtConvertArgRec screenConvertArg[] = {
+ {XtWidgetBaseOffset, (XtPointer) XtOffsetOf(WidgetRec, core.screen),
+ sizeof(Screen *)}
+ };
+
+ XtAddConverter(XtRString, XtRCursor, XmuCvtStringToCursor,
+ screenConvertArg, XtNumber(screenConvertArg));
+
+ XtAddConverter(XtRString, XtRBitmap, XmuCvtStringToBitmap,
+ screenConvertArg, XtNumber(screenConvertArg));
+
+ XtSetTypeConverter("CompoundText", XtRString, XawCvtCompoundTextToString,
+ NULL, 0, XtCacheNone, NULL);
+}
+
+static void XawVendorShellClassPartInit(class)
+ WidgetClass class;
+{
+ CompositeClassExtension ext;
+ VendorShellWidgetClass vsclass = (VendorShellWidgetClass) class;
+
+ if ((ext = (CompositeClassExtension)
+ XtGetClassExtension (class,
+ XtOffsetOf(CompositeClassRec,
+ composite_class.extension),
+ NULLQUARK, 1L, (Cardinal) 0)) == NULL) {
+ ext = (CompositeClassExtension) XtNew (CompositeClassExtensionRec);
+ if (ext != NULL) {
+ ext->next_extension = vsclass->composite_class.extension;
+ ext->record_type = NULLQUARK;
+ ext->version = XtCompositeExtensionVersion;
+ ext->record_size = sizeof (CompositeClassExtensionRec);
+ ext->accepts_objects = TRUE;
+ ext->allows_change_managed_set = FALSE;
+ vsclass->composite_class.extension = (XtPointer) ext;
+ }
+ }
+}
+
+#ifdef __osf__
+/* stupid OSF/1 shared libraries have the wrong semantics */
+/* symbols do not get resolved external to the shared library */
+void _XawFixupVendorShell()
+{
+ transientShellWidgetClass->core_class.superclass =
+ (WidgetClass) &vendorShellClassRec;
+ topLevelShellWidgetClass->core_class.superclass =
+ (WidgetClass) &vendorShellClassRec;
+}
+#endif
+
+/* ARGSUSED */
+static void XawVendorShellInitialize(req, new, args, num_args)
+ Widget req, new;
+ ArgList args;
+ Cardinal *num_args;
+{
+ XtAddEventHandler(new, (EventMask) 0, TRUE, _XEditResCheckMessages, NULL);
+ XtAddEventHandler(new, (EventMask) 0, TRUE, XmuRegisterExternalAgent, NULL);
+ XtCreateWidget("shellext", xawvendorShellExtWidgetClass,
+ new, args, *num_args);
+}
+
+/* ARGSUSED */
+static Boolean XawVendorShellSetValues(old, ref, new)
+ Widget old, ref, new;
+{
+ return FALSE;
+}
+
+static void Realize(wid, vmask, attr)
+ Widget wid;
+ Mask *vmask;
+ XSetWindowAttributes *attr;
+{
+ WidgetClass super = wmShellWidgetClass;
+
+ /* Make my superclass do all the dirty work */
+
+ (*super->core_class.realize) (wid, vmask, attr);
+ _XawImRealize(wid);
+}
+
+
+static void XawVendorShellExtClassInitialize()
+{
+}
+
+/* ARGSUSED */
+static void XawVendorShellExtInitialize(req, new)
+ Widget req, new;
+{
+ _XawImInitialize(new->core.parent, new);
+}
+
+/* ARGSUSED */
+static void XawVendorShellExtDestroy( w )
+ Widget w;
+{
+ _XawImDestroy( w->core.parent, w );
+}
+
+/* ARGSUSED */
+static Boolean XawVendorShellExtSetValues(old, ref, new)
+ Widget old, ref, new;
+{
+ return FALSE;
+}
+
+void XawVendorShellExtResize( w )
+ Widget w;
+{
+ ShellWidget sw = (ShellWidget) w;
+ Widget childwid;
+ int i;
+ int core_height;
+
+ _XawImResizeVendorShell( w );
+ core_height = _XawImGetShellHeight( w );
+ for( i = 0; i < sw->composite.num_children; i++ ) {
+ if( XtIsManaged( sw->composite.children[ i ] ) ) {
+ childwid = sw->composite.children[ i ];
+ XtResizeWidget( childwid, sw->core.width, core_height,
+ childwid->core.border_width );
+ }
+ }
+}
+
+/*ARGSUSED*/
+static XtGeometryResult GeometryManager( wid, request, reply )
+ Widget wid;
+ XtWidgetGeometry *request;
+ XtWidgetGeometry *reply;
+{
+ ShellWidget shell = (ShellWidget)(wid->core.parent);
+ XtWidgetGeometry my_request;
+
+ if(shell->shell.allow_shell_resize == FALSE && XtIsRealized(wid))
+ return(XtGeometryNo);
+
+ if (request->request_mode & (CWX | CWY))
+ return(XtGeometryNo);
+
+ /* %%% worry about XtCWQueryOnly */
+ my_request.request_mode = 0;
+ if (request->request_mode & CWWidth) {
+ my_request.width = request->width;
+ my_request.request_mode |= CWWidth;
+ }
+ if (request->request_mode & CWHeight) {
+ my_request.height = request->height
+ + _XawImGetImAreaHeight( wid );
+ my_request.request_mode |= CWHeight;
+ }
+ if (request->request_mode & CWBorderWidth) {
+ my_request.border_width = request->border_width;
+ my_request.request_mode |= CWBorderWidth;
+ }
+ if (XtMakeGeometryRequest((Widget)shell, &my_request, NULL)
+ == XtGeometryYes) {
+ /* assert: if (request->request_mode & CWWidth) then
+ * shell->core.width == request->width
+ * assert: if (request->request_mode & CWHeight) then
+ * shell->core.height == request->height
+ *
+ * so, whatever the WM sized us to (if the Shell requested
+ * only one of the two) is now the correct child size
+ */
+
+ wid->core.width = shell->core.width;
+ wid->core.height = shell->core.height;
+ if (request->request_mode & CWBorderWidth) {
+ wid->core.x = wid->core.y = -request->border_width;
+ }
+ _XawImCallVendorShellExtResize(wid);
+ return XtGeometryYes;
+ } else return XtGeometryNo;
+}
+
+static void ChangeManaged(wid)
+ Widget wid;
+{
+ ShellWidget w = (ShellWidget) wid;
+ Widget* childP;
+ int i;
+
+ (*SuperClass->composite_class.change_managed)(wid);
+ for (i = w->composite.num_children, childP = w->composite.children;
+ i; i--, childP++) {
+ if (XtIsManaged(*childP)) {
+ XtSetKeyboardFocus(wid, *childP);
+ break;
+ }
+ }
+}
diff --git a/src/Viewport.c b/src/Viewport.c
new file mode 100644
index 0000000..02182e0
--- /dev/null
+++ b/src/Viewport.c
@@ -0,0 +1,1083 @@
+/* $Xorg: Viewport.c,v 1.4 2001/02/09 02:03:47 xorgcvs Exp $ */
+
+/***********************************************************
+
+Copyright 1987, 1988, 1994, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+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
+OPEN GROUP 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 Open Group 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 Open Group.
+
+
+Copyright 1987, 1988 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+******************************************************************/
+
+#include <X11/IntrinsicP.h>
+#include <X11/StringDefs.h>
+
+#include <X11/Xaw/XawInit.h>
+#include <X11/Xmu/Misc.h>
+#include <X11/Xaw/Scrollbar.h>
+#include <X11/Xaw/ViewportP.h>
+
+static void ScrollUpDownProc(), ThumbProc();
+static Boolean GetGeometry();
+
+static void ComputeWithForceBars();
+
+#define offset(field) XtOffsetOf(ViewportRec, viewport.field)
+static XtResource resources[] = {
+ {XtNforceBars, XtCBoolean, XtRBoolean, sizeof(Boolean),
+ offset(forcebars), XtRImmediate, (XtPointer)False},
+ {XtNallowHoriz, XtCBoolean, XtRBoolean, sizeof(Boolean),
+ offset(allowhoriz), XtRImmediate, (XtPointer)False},
+ {XtNallowVert, XtCBoolean, XtRBoolean, sizeof(Boolean),
+ offset(allowvert), XtRImmediate, (XtPointer)False},
+ {XtNuseBottom, XtCBoolean, XtRBoolean, sizeof(Boolean),
+ offset(usebottom), XtRImmediate, (XtPointer)False},
+ {XtNuseRight, XtCBoolean, XtRBoolean, sizeof(Boolean),
+ offset(useright), XtRImmediate, (XtPointer)False},
+ {XtNreportCallback, XtCReportCallback, XtRCallback, sizeof(XtPointer),
+ offset(report_callbacks), XtRImmediate, (XtPointer) NULL},
+};
+#undef offset
+
+static void Initialize(), ConstraintInitialize(),
+ Realize(), Resize(), ChangeManaged();
+static Boolean SetValues(), Layout();
+static XtGeometryResult GeometryManager(), PreferredGeometry();
+
+#define superclass (&formClassRec)
+ViewportClassRec viewportClassRec = {
+ { /* core_class fields */
+ /* superclass */ (WidgetClass) superclass,
+ /* class_name */ "Viewport",
+ /* widget_size */ sizeof(ViewportRec),
+ /* class_initialize */ XawInitializeWidgetSet,
+ /* class_part_init */ NULL,
+ /* class_inited */ FALSE,
+ /* initialize */ Initialize,
+ /* initialize_hook */ NULL,
+ /* realize */ Realize,
+ /* actions */ NULL,
+ /* num_actions */ 0,
+ /* resources */ resources,
+ /* num_resources */ XtNumber(resources),
+ /* xrm_class */ NULLQUARK,
+ /* compress_motion */ TRUE,
+ /* compress_exposure */ TRUE,
+ /* compress_enterleave*/ TRUE,
+ /* visible_interest */ FALSE,
+ /* destroy */ NULL,
+ /* resize */ Resize,
+ /* expose */ XtInheritExpose,
+ /* set_values */ SetValues,
+ /* set_values_hook */ NULL,
+ /* set_values_almost */ XtInheritSetValuesAlmost,
+ /* get_values_hook */ NULL,
+ /* accept_focus */ NULL,
+ /* version */ XtVersion,
+ /* callback_private */ NULL,
+ /* tm_table */ NULL,
+ /* query_geometry */ PreferredGeometry,
+ /* display_accelerator*/ XtInheritDisplayAccelerator,
+ /* extension */ NULL
+ },
+ { /* composite_class fields */
+ /* geometry_manager */ GeometryManager,
+ /* change_managed */ ChangeManaged,
+ /* insert_child */ XtInheritInsertChild,
+ /* delete_child */ XtInheritDeleteChild,
+ /* extension */ NULL
+ },
+ { /* constraint_class fields */
+ /* subresourses */ NULL,
+ /* subresource_count */ 0,
+ /* constraint_size */ sizeof(ViewportConstraintsRec),
+ /* initialize */ ConstraintInitialize,
+ /* destroy */ NULL,
+ /* set_values */ NULL,
+ /* extension */ NULL
+ },
+ { /* form_class fields */
+ /* layout */ Layout
+ },
+ { /* viewport_class fields */
+ /* empty */ 0
+ }
+};
+
+
+WidgetClass viewportWidgetClass = (WidgetClass)&viewportClassRec;
+
+static Widget CreateScrollbar(w, horizontal)
+ ViewportWidget w;
+ Boolean horizontal;
+{
+ Widget clip = w->viewport.clip;
+ ViewportConstraints constraints =
+ (ViewportConstraints)clip->core.constraints;
+ static Arg barArgs[] = {
+ {XtNorientation, (XtArgVal) 0},
+ {XtNlength, (XtArgVal) 0},
+ {XtNleft, (XtArgVal) 0},
+ {XtNright, (XtArgVal) 0},
+ {XtNtop, (XtArgVal) 0},
+ {XtNbottom, (XtArgVal) 0},
+ {XtNmappedWhenManaged, (XtArgVal) False},
+ };
+ Widget bar;
+
+ XtSetArg(barArgs[0], XtNorientation,
+ horizontal ? XtorientHorizontal : XtorientVertical );
+ XtSetArg(barArgs[1], XtNlength,
+ horizontal ? clip->core.width : clip->core.height);
+ XtSetArg(barArgs[2], XtNleft,
+ (!horizontal && w->viewport.useright) ? XtChainRight : XtChainLeft);
+ XtSetArg(barArgs[3], XtNright,
+ (!horizontal && !w->viewport.useright) ? XtChainLeft : XtChainRight);
+ XtSetArg(barArgs[4], XtNtop,
+ (horizontal && w->viewport.usebottom) ? XtChainBottom: XtChainTop);
+ XtSetArg(barArgs[5], XtNbottom,
+ (horizontal && !w->viewport.usebottom) ? XtChainTop: XtChainBottom);
+
+ bar = XtCreateWidget((horizontal ? "horizontal" : "vertical"),
+ scrollbarWidgetClass, (Widget)w,
+ barArgs, XtNumber(barArgs) );
+ XtAddCallback( bar, XtNscrollProc, ScrollUpDownProc, (XtPointer)w );
+ XtAddCallback( bar, XtNjumpProc, ThumbProc, (XtPointer)w );
+
+ if (horizontal) {
+ w->viewport.horiz_bar = bar;
+ constraints->form.vert_base = bar;
+ }
+ else {
+ w->viewport.vert_bar = bar;
+ constraints->form.horiz_base = bar;
+ }
+
+ XtManageChild( bar );
+
+ return bar;
+}
+
+/* ARGSUSED */
+static void Initialize(request, new, args, num_args)
+ Widget request, new;
+ ArgList args;
+ Cardinal *num_args;
+{
+ ViewportWidget w = (ViewportWidget)new;
+ static Arg clip_args[8];
+ Cardinal arg_cnt;
+ Widget h_bar, v_bar;
+ Dimension clip_height, clip_width;
+
+ w->form.default_spacing = 0; /* Reset the default spacing to 0 pixels. */
+
+
+/*
+ * Initialize all widget pointers to NULL.
+ */
+
+ w->viewport.child = (Widget) NULL;
+ w->viewport.horiz_bar = w->viewport.vert_bar = (Widget)NULL;
+
+/*
+ * Create Clip Widget.
+ */
+
+ arg_cnt = 0;
+ XtSetArg(clip_args[arg_cnt], XtNbackgroundPixmap, None); arg_cnt++;
+ XtSetArg(clip_args[arg_cnt], XtNborderWidth, 0); arg_cnt++;
+ XtSetArg(clip_args[arg_cnt], XtNleft, XtChainLeft); arg_cnt++;
+ XtSetArg(clip_args[arg_cnt], XtNright, XtChainRight); arg_cnt++;
+ XtSetArg(clip_args[arg_cnt], XtNtop, XtChainTop); arg_cnt++;
+ XtSetArg(clip_args[arg_cnt], XtNbottom, XtChainBottom); arg_cnt++;
+ XtSetArg(clip_args[arg_cnt], XtNwidth, w->core.width); arg_cnt++;
+ XtSetArg(clip_args[arg_cnt], XtNheight, w->core.height); arg_cnt++;
+
+ w->viewport.clip = XtCreateManagedWidget("clip", widgetClass, new,
+ clip_args, arg_cnt);
+
+ if (!w->viewport.forcebars)
+ return; /* If we are not forcing the bars then we are done. */
+
+ if (w->viewport.allowhoriz)
+ (void) CreateScrollbar(w, True);
+ if (w->viewport.allowvert)
+ (void) CreateScrollbar(w, False);
+
+ h_bar = w->viewport.horiz_bar;
+ v_bar = w->viewport.vert_bar;
+
+/*
+ * Set the clip widget to the correct height.
+ */
+
+ clip_width = w->core.width;
+ clip_height = w->core.height;
+
+ if ( (h_bar != NULL) &&
+ ((int)w->core.width >
+ (int)(h_bar->core.width + h_bar->core.border_width)) )
+ clip_width -= h_bar->core.width + h_bar->core.border_width;
+
+ if ( (v_bar != NULL) &&
+ ((int)w->core.height >
+ (int)(v_bar->core.height + v_bar->core.border_width)) )
+ clip_height -= v_bar->core.height + v_bar->core.border_width;
+
+ arg_cnt = 0;
+ XtSetArg(clip_args[arg_cnt], XtNwidth, clip_width); arg_cnt++;
+ XtSetArg(clip_args[arg_cnt], XtNheight, clip_height); arg_cnt++;
+ XtSetValues(w->viewport.clip, clip_args, arg_cnt);
+}
+
+/* ARGSUSED */
+static void ConstraintInitialize(request, new, args, num_args)
+ Widget request, new;
+ ArgList args;
+ Cardinal *num_args;
+{
+ ((ViewportConstraints)new->core.constraints)->viewport.reparented = False;
+}
+
+static void Realize(widget, value_mask, attributes)
+ Widget widget;
+ XtValueMask *value_mask;
+ XSetWindowAttributes *attributes;
+{
+ ViewportWidget w = (ViewportWidget)widget;
+ Widget child = w->viewport.child;
+ Widget clip = w->viewport.clip;
+
+ *value_mask |= CWBitGravity;
+ attributes->bit_gravity = NorthWestGravity;
+ (*superclass->core_class.realize)(widget, value_mask, attributes);
+
+ (*w->core.widget_class->core_class.resize)(widget); /* turn on bars */
+
+ if (child != (Widget)NULL) {
+ XtMoveWidget( child, (Position)0, (Position)0 );
+ XtRealizeWidget( clip );
+ XtRealizeWidget( child );
+ XReparentWindow( XtDisplay(w), XtWindow(child), XtWindow(clip),
+ (Position)0, (Position)0 );
+ XtMapWidget( child );
+ }
+}
+
+/* ARGSUSED */
+static Boolean SetValues(current, request, new, args, num_args)
+ Widget current, request, new;
+ ArgList args;
+ Cardinal *num_args;
+{
+ ViewportWidget w = (ViewportWidget)new;
+ ViewportWidget cw = (ViewportWidget)current;
+
+ if ( (w->viewport.forcebars != cw->viewport.forcebars) ||
+ (w->viewport.allowvert != cw->viewport.allowvert) ||
+ (w->viewport.allowhoriz != cw->viewport.allowhoriz) ||
+ (w->viewport.useright != cw->viewport.useright) ||
+ (w->viewport.usebottom != cw->viewport.usebottom) )
+ {
+ (*w->core.widget_class->core_class.resize)(new); /* Recompute layout.*/
+ }
+
+ return False;
+}
+
+
+static void ChangeManaged(widget)
+ Widget widget;
+{
+ ViewportWidget w = (ViewportWidget)widget;
+ int num_children = w->composite.num_children;
+ Widget child, *childP;
+ int i;
+
+ child = (Widget)NULL;
+ for (childP=w->composite.children, i=0; i < num_children; childP++, i++) {
+ if (XtIsManaged(*childP)
+ && *childP != w->viewport.clip
+ && *childP != w->viewport.horiz_bar
+ && *childP != w->viewport.vert_bar)
+ {
+ child = *childP;
+ break;
+ }
+ }
+
+ if (child != w->viewport.child) {
+ w->viewport.child = child;
+ if (child != (Widget)NULL) {
+ XtResizeWidget( child, child->core.width,
+ child->core.height, (Dimension)0 );
+ if (XtIsRealized(widget)) {
+ ViewportConstraints constraints =
+ (ViewportConstraints)child->core.constraints;
+ if (!XtIsRealized(child)) {
+ Window window = XtWindow(w);
+ XtMoveWidget( child, (Position)0, (Position)0 );
+#ifdef notdef
+ /* this is dirty, but it saves the following code: */
+ XtRealizeWidget( child );
+ XReparentWindow( XtDisplay(w), XtWindow(child),
+ XtWindow(w->viewport.clip),
+ (Position)0, (Position)0 );
+ if (child->core.mapped_when_managed)
+ XtMapWidget( child );
+#else
+ w->core.window = XtWindow(w->viewport.clip);
+ XtRealizeWidget( child );
+ w->core.window = window;
+#endif /* notdef */
+ constraints->viewport.reparented = True;
+ }
+ else if (!constraints->viewport.reparented) {
+ XReparentWindow( XtDisplay(w), XtWindow(child),
+ XtWindow(w->viewport.clip),
+ (Position)0, (Position)0 );
+ constraints->viewport.reparented = True;
+ if (child->core.mapped_when_managed)
+ XtMapWidget( child );
+ }
+ }
+ GetGeometry( widget, child->core.width, child->core.height );
+ (*((ViewportWidgetClass)w->core.widget_class)->form_class.layout)
+ ( (FormWidget)w, w->core.width, w->core.height );
+ /* %%% do we need to hide this child from Form? */
+ }
+ }
+
+#ifdef notdef
+ (*superclass->composite_class.change_managed)( widget );
+#endif
+}
+
+
+static void SetBar(w, top, length, total)
+ Widget w;
+ Position top;
+ Dimension length, total;
+{
+ XawScrollbarSetThumb(w, (float)top/(float)total,
+ (float)length/(float)total);
+}
+
+static void RedrawThumbs(w)
+ ViewportWidget w;
+{
+ Widget child = w->viewport.child;
+ Widget clip = w->viewport.clip;
+
+ if (w->viewport.horiz_bar != (Widget)NULL)
+ SetBar( w->viewport.horiz_bar, -(child->core.x),
+ clip->core.width, child->core.width );
+
+ if (w->viewport.vert_bar != (Widget)NULL)
+ SetBar( w->viewport.vert_bar, -(child->core.y),
+ clip->core.height, child->core.height );
+}
+
+
+
+static void SendReport (w, changed)
+ ViewportWidget w;
+ unsigned int changed;
+{
+ XawPannerReport rep;
+
+ if (w->viewport.report_callbacks) {
+ Widget child = w->viewport.child;
+ Widget clip = w->viewport.clip;
+
+ rep.changed = changed;
+ rep.slider_x = -child->core.x; /* child is canvas */
+ rep.slider_y = -child->core.y; /* clip is slider */
+ rep.slider_width = clip->core.width;
+ rep.slider_height = clip->core.height;
+ rep.canvas_width = child->core.width;
+ rep.canvas_height = child->core.height;
+ XtCallCallbackList ((Widget) w, w->viewport.report_callbacks,
+ (XtPointer) &rep);
+ }
+}
+
+
+static void MoveChild(w, x, y)
+ ViewportWidget w;
+ Position x, y;
+{
+ Widget child = w->viewport.child;
+ Widget clip = w->viewport.clip;
+
+ /* make sure we never move past right/bottom borders */
+ if (-x + (int)clip->core.width > (int)child->core.width)
+ x = -(child->core.width - clip->core.width);
+
+ if (-y + (int)clip->core.height > (int)child->core.height)
+ y = -(child->core.height - clip->core.height);
+
+ /* make sure we never move past left/top borders */
+ if (x >= 0) x = 0;
+ if (y >= 0) y = 0;
+
+ XtMoveWidget(child, x, y);
+ SendReport (w, (XawPRSliderX | XawPRSliderY));
+
+ RedrawThumbs(w);
+}
+
+
+static void ComputeLayout(widget, query, destroy_scrollbars)
+ Widget widget; /* Viewport */
+ Boolean query; /* query child's preferred geom? */
+ Boolean destroy_scrollbars; /* destroy un-needed scrollbars? */
+{
+ ViewportWidget w = (ViewportWidget)widget;
+ Widget child = w->viewport.child;
+ Widget clip = w->viewport.clip;
+ ViewportConstraints constraints
+ = (ViewportConstraints)clip->core.constraints;
+ Boolean needshoriz, needsvert;
+ int clip_width, clip_height;
+ XtWidgetGeometry intended;
+
+ if (child == (Widget) NULL) return;
+
+ clip_width = w->core.width;
+ clip_height = w->core.height;
+ intended.request_mode = CWBorderWidth;
+ intended.border_width = 0;
+
+ if (w->viewport.forcebars) {
+ needsvert = w->viewport.allowvert;
+ needshoriz = w->viewport.allowhoriz;
+ ComputeWithForceBars(widget, query, &intended,
+ &clip_width, &clip_height);
+ }
+ else {
+ Dimension prev_width, prev_height;
+ XtGeometryMask prev_mode;
+ XtWidgetGeometry preferred;
+
+ needshoriz = needsvert = False;
+
+ /*
+ * intended.{width,height} caches the eventual child dimensions,
+ * but we don't set the mode bits until after we decide that the
+ * child's preferences are not acceptable.
+ */
+
+ if (!w->viewport.allowhoriz)
+ intended.request_mode |= CWWidth;
+
+ if ((int)child->core.width < clip_width)
+ intended.width = clip_width;
+ else
+ intended.width = child->core.width;
+
+ if ((int)child->core.height < clip_height)
+ intended.height = clip_height;
+ else
+ intended.height = child->core.height;
+
+ if (!w->viewport.allowvert)
+ intended.request_mode |= CWHeight;
+
+ if (!query) {
+ preferred.width = child->core.width;
+ preferred.height = child->core.height;
+ }
+ do { /* while intended != prev */
+
+ if (query) {
+ (void) XtQueryGeometry( child, &intended, &preferred );
+ if ( !(preferred.request_mode & CWWidth) )
+ preferred.width = intended.width;
+ if ( !(preferred.request_mode & CWHeight) )
+ preferred.height = intended.height;
+ }
+ prev_width = intended.width;
+ prev_height = intended.height;
+ prev_mode = intended.request_mode;
+ /*
+ * note that having once decided to turn on either bar
+ * we'll not change our mind until we're next resized,
+ * thus avoiding potential oscillations.
+ */
+#define CheckHoriz() \
+ if ( w->viewport.allowhoriz && \
+ (int)preferred.width > clip_width) { \
+ if (!needshoriz) { \
+ Widget bar; \
+ needshoriz = True; \
+ if ((bar = w->viewport.horiz_bar) == (Widget)NULL) \
+ bar = CreateScrollbar(w, True); \
+ clip_height -= bar->core.height + \
+ bar->core.border_width; \
+ if (clip_height < 1) clip_height = 1; \
+ } \
+ intended.width = preferred.width; \
+ }
+/*enddef*/
+ CheckHoriz();
+ if (w->viewport.allowvert && (int)preferred.height > clip_height) {
+ if (!needsvert) {
+ Widget bar;
+ needsvert = True;
+ if ((bar = w->viewport.vert_bar) == (Widget)NULL)
+ bar = CreateScrollbar(w, False);
+ clip_width -= bar->core.width + bar->core.border_width;
+ if (clip_width < 1) clip_width = 1;
+ CheckHoriz();
+ }
+ intended.height = preferred.height;
+ }
+ if ( !w->viewport.allowhoriz ||
+ (int)preferred.width < clip_width) {
+ intended.width = clip_width;
+ intended.request_mode |= CWWidth;
+ }
+ if ( !w->viewport.allowvert ||
+ (int)preferred.height < clip_height) {
+ intended.height = clip_height;
+ intended.request_mode |= CWHeight;
+ }
+ } while (intended.request_mode != prev_mode
+ || (intended.request_mode & CWWidth
+ && intended.width != prev_width)
+ || (intended.request_mode & CWHeight
+ && intended.height != prev_height));
+ }
+
+ if (XtIsRealized(clip))
+ XRaiseWindow( XtDisplay(clip), XtWindow(clip) );
+
+ XtMoveWidget( clip,
+ (Position) (needsvert ? (w->viewport.useright ? 0 :
+ w->viewport.vert_bar->core.width +
+ w->viewport.vert_bar->core.border_width) : 0),
+ (Position) (needshoriz ? (w->viewport.usebottom ? 0 :
+ w->viewport.horiz_bar->core.height +
+ w->viewport.horiz_bar->core.border_width) : 0));
+ XtResizeWidget( clip, (Dimension)clip_width,
+ (Dimension)clip_height, (Dimension)0 );
+
+ if (w->viewport.horiz_bar != (Widget)NULL) {
+ Widget bar = w->viewport.horiz_bar;
+ if (!needshoriz) {
+ constraints->form.vert_base = (Widget)NULL;
+ if (destroy_scrollbars) {
+ XtDestroyWidget( bar );
+ w->viewport.horiz_bar = (Widget)NULL;
+ }
+ }
+ else {
+ int bw = bar->core.border_width;
+ XtResizeWidget( bar, (Dimension) clip_width, bar->core.height, (Dimension) bw );
+ XtMoveWidget( bar,
+ (Position)((needsvert && !w->viewport.useright)
+ ? w->viewport.vert_bar->core.width
+ : -bw),
+ (Position)(w->viewport.usebottom
+ ? w->core.height - bar->core.height - bw
+ : -bw) );
+ XtSetMappedWhenManaged( bar, True );
+ }
+ }
+
+ if (w->viewport.vert_bar != (Widget)NULL) {
+ Widget bar = w->viewport.vert_bar;
+ if (!needsvert) {
+ constraints->form.horiz_base = (Widget)NULL;
+ if (destroy_scrollbars) {
+ XtDestroyWidget( bar );
+ w->viewport.vert_bar = (Widget)NULL;
+ }
+ }
+ else {
+ int bw = bar->core.border_width;
+ XtResizeWidget( bar, bar->core.width, (Dimension)clip_height, (Dimension)bw );
+ XtMoveWidget( bar,
+ (Position)(w->viewport.useright
+ ? w->core.width - bar->core.width - bw
+ : -bw),
+ (Position)((needshoriz && !w->viewport.usebottom)
+ ? w->viewport.horiz_bar->core.height
+ : -bw) );
+ XtSetMappedWhenManaged( bar, True );
+ }
+ }
+
+ if (child != (Widget)NULL) {
+ XtResizeWidget( child, (Dimension)intended.width,
+ (Dimension)intended.height, (Dimension)0 );
+ MoveChild(w,
+ needshoriz ? child->core.x : 0,
+ needsvert ? child->core.y : 0);
+ }
+
+ SendReport (w, XawPRAll);
+}
+
+/* Function Name: ComputeWithForceBars
+ * Description: Computes the layout give forcebars is set.
+ * Arguments: widget - the viewport widget.
+ * query - whether or not to query the child.
+ * intended - the cache of the childs height is
+ * stored here ( USED AND RETURNED ).
+ * clip_width, clip_height - size of clip window.
+ * (USED AND RETURNED ).
+ * Returns: none.
+ */
+
+static void
+ComputeWithForceBars(widget, query, intended, clip_width, clip_height)
+Widget widget;
+Boolean query;
+XtWidgetGeometry * intended;
+int *clip_width, *clip_height;
+{
+ ViewportWidget w = (ViewportWidget)widget;
+ Widget child = w->viewport.child;
+ XtWidgetGeometry preferred;
+
+/*
+ * If forcebars then needs = allows = has.
+ * Thus if needsvert is set it MUST have a scrollbar.
+ */
+
+ if (w->viewport.allowvert) {
+ if (w->viewport.vert_bar == NULL)
+ w->viewport.vert_bar = CreateScrollbar(w, False);
+
+ *clip_width -= w->viewport.vert_bar->core.width +
+ w->viewport.vert_bar->core.border_width;
+ }
+
+ if (w->viewport.allowhoriz) {
+ if (w->viewport.horiz_bar == NULL)
+ w->viewport.horiz_bar = CreateScrollbar(w, True);
+
+ *clip_height -= w->viewport.horiz_bar->core.height +
+ w->viewport.horiz_bar->core.border_width;
+ }
+
+ AssignMax( *clip_width, 1 );
+ AssignMax( *clip_height, 1 );
+
+ if (!w->viewport.allowvert) {
+ intended->height = *clip_height;
+ intended->request_mode = CWHeight;
+ }
+ if (!w->viewport.allowhoriz) {
+ intended->width = *clip_width;
+ intended->request_mode = CWWidth;
+ }
+
+ if ( query ) {
+ if ( (w->viewport.allowvert || w->viewport.allowhoriz) ) {
+ XtQueryGeometry( child, intended, &preferred );
+
+ if ( !(intended->request_mode & CWWidth) )
+ if ( preferred.request_mode & CWWidth )
+ intended->width = preferred.width;
+ else
+ intended->width = child->core.width;
+
+ if ( !(intended->request_mode & CWHeight) )
+ if ( preferred.request_mode & CWHeight )
+ intended->height = preferred.height;
+ else
+ intended->height = child->core.height;
+ }
+ }
+ else {
+ if (w->viewport.allowvert)
+ intended->height = child->core.height;
+ if (w->viewport.allowhoriz)
+ intended->width = child->core.width;
+ }
+
+ if (*clip_width > (int)intended->width)
+ intended->width = *clip_width;
+ if (*clip_height > (int)intended->height)
+ intended->height = *clip_height;
+}
+
+static void Resize(widget)
+ Widget widget;
+{
+ ComputeLayout( widget, /*query=*/True, /*destroy=*/True );
+}
+
+
+/* ARGSUSED */
+static Boolean Layout(w, width, height)
+ FormWidget w;
+ Dimension width, height;
+{
+ ComputeLayout( (Widget)w, /*query=*/True, /*destroy=*/True );
+ w->form.preferred_width = w->core.width;
+ w->form.preferred_height = w->core.height;
+ return False;
+}
+
+
+static void ScrollUpDownProc(widget, closure, call_data)
+ Widget widget;
+ XtPointer closure;
+ XtPointer call_data;
+{
+ ViewportWidget w = (ViewportWidget)closure;
+ Widget child = w->viewport.child;
+ int pix = (int)call_data;
+ Position x, y;
+
+ if (child == NULL) return; /* no child to scroll. */
+
+ x = child->core.x - ((widget == w->viewport.horiz_bar) ? pix : 0);
+ y = child->core.y - ((widget == w->viewport.vert_bar) ? pix : 0);
+ MoveChild(w, x, y);
+}
+
+
+/* ARGSUSED */
+static void ThumbProc(widget, closure, call_data)
+ Widget widget;
+ XtPointer closure;
+ XtPointer call_data;
+{
+ ViewportWidget w = (ViewportWidget)closure;
+ Widget child = w->viewport.child;
+ float *percent = (float *) call_data;
+ Position x, y;
+
+ if (child == NULL) return; /* no child to scroll. */
+
+ if (widget == w->viewport.horiz_bar)
+#ifdef macII /* bug in the macII A/UX 1.0 cc */
+ x = (int)(-*percent * child->core.width);
+#else /* else not macII */
+ x = -(int)(*percent * child->core.width);
+#endif /* macII */
+ else
+ x = child->core.x;
+
+ if (widget == w->viewport.vert_bar)
+#ifdef macII /* bug in the macII A/UX 1.0 cc */
+ y = (int)(-*percent * child->core.height);
+#else /* else not macII */
+ y = -(int)(*percent * child->core.height);
+#endif /* macII */
+ else
+ y = child->core.y;
+
+ MoveChild(w, x, y);
+}
+
+static XtGeometryResult
+TestSmaller(w, request, reply_return)
+ ViewportWidget w; XtWidgetGeometry *request, *reply_return;
+{
+ if (request->width < w->core.width || request->height < w->core.height)
+ return XtMakeGeometryRequest((Widget)w, request, reply_return);
+ else
+ return XtGeometryYes;
+}
+
+static XtGeometryResult
+GeometryRequestPlusScrollbar(w, horizontal, request, reply_return)
+ Boolean horizontal;
+ ViewportWidget w;
+ XtWidgetGeometry *request, *reply_return;
+{
+ Widget sb;
+ XtWidgetGeometry plusScrollbars;
+ plusScrollbars = *request;
+ if ((sb = w->viewport.horiz_bar) == (Widget)NULL)
+ sb = CreateScrollbar( w, horizontal);
+ request->width += sb->core.width;
+ request->height += sb->core.height;
+ XtDestroyWidget(sb);
+ return XtMakeGeometryRequest((Widget) w, &plusScrollbars, reply_return);
+ }
+
+#define WidthChange() (request->width != w->core.width)
+#define HeightChange() (request->height != w->core.height)
+
+static XtGeometryResult
+QueryGeometry(w, request, reply_return)
+ ViewportWidget w; XtWidgetGeometry *request, *reply_return;
+{
+ if (w->viewport.allowhoriz && w->viewport.allowvert)
+ return TestSmaller(w, request, reply_return);
+
+ else if (w->viewport.allowhoriz && !w->viewport.allowvert) {
+ if (WidthChange() && !HeightChange())
+ return TestSmaller(w, request, reply_return);
+ else if (!WidthChange() && HeightChange())
+ return XtMakeGeometryRequest((Widget) w, request, reply_return);
+ else if (WidthChange() && HeightChange()) /* hard part */
+ return GeometryRequestPlusScrollbar(w, True, request, reply_return);
+ else /* !WidthChange() && !HeightChange() */
+ return XtGeometryYes;
+ }
+ else if (!w->viewport.allowhoriz && w->viewport.allowvert) {
+ if (!WidthChange() && HeightChange())
+ return TestSmaller(w, request, reply_return);
+ else if (WidthChange() && !HeightChange())
+ return XtMakeGeometryRequest((Widget)w, request, reply_return);
+ else if (WidthChange() && HeightChange()) /* hard part */
+ return GeometryRequestPlusScrollbar(w, False, request, reply_return);
+ else /* !WidthChange() && !HeightChange() */
+ return XtGeometryYes;
+ }
+ else /* (!w->viewport.allowhoriz && !w->viewport.allowvert) */
+ return XtMakeGeometryRequest((Widget) w, request, reply_return);
+}
+
+#undef WidthChange
+#undef HeightChange
+
+static XtGeometryResult GeometryManager(child, request, reply)
+ Widget child;
+ XtWidgetGeometry *request, *reply;
+{
+ ViewportWidget w = (ViewportWidget)child->core.parent;
+ Boolean rWidth = (Boolean)(request->request_mode & CWWidth);
+ Boolean rHeight = (Boolean)(request->request_mode & CWHeight);
+ XtWidgetGeometry allowed;
+ XtGeometryResult result;
+ Boolean reconfigured;
+ Boolean child_changed_size;
+ Dimension height_remaining;
+
+ if (request->request_mode & XtCWQueryOnly)
+ return QueryGeometry(w, request, reply);
+
+ if (child != w->viewport.child
+ || request->request_mode & ~(CWWidth | CWHeight
+ | CWBorderWidth)
+ || ((request->request_mode & CWBorderWidth)
+ && request->border_width > 0))
+ return XtGeometryNo;
+
+ allowed = *request;
+
+ reconfigured = GetGeometry( (Widget)w,
+ (rWidth ? request->width : w->core.width),
+ (rHeight ? request->height : w->core.height)
+ );
+
+ child_changed_size = ((rWidth && child->core.width != request->width) ||
+ (rHeight && child->core.height != request->height));
+
+ height_remaining = w->core.height;
+ if (rWidth && w->core.width != request->width) {
+ if (w->viewport.allowhoriz && request->width > w->core.width) {
+ /* horizontal scrollbar will be needed so possibly reduce height */
+ Widget bar;
+ if ((bar = w->viewport.horiz_bar) == (Widget)NULL)
+ bar = CreateScrollbar( w, True );
+ height_remaining -= bar->core.height + bar->core.border_width;
+ reconfigured = True;
+ }
+ else {
+ allowed.width = w->core.width;
+ }
+ }
+ if (rHeight && height_remaining != request->height) {
+ if (w->viewport.allowvert && request->height > height_remaining) {
+ /* vertical scrollbar will be needed, so possibly reduce width */
+ if (!w->viewport.allowhoriz || request->width < w->core.width) {
+ Widget bar;
+ if ((bar = w->viewport.vert_bar) == (Widget)NULL)
+ bar = CreateScrollbar( w, False );
+ if (!rWidth) {
+ allowed.width = w->core.width;
+ allowed.request_mode |= CWWidth;
+ }
+ if ( (int)allowed.width >
+ (int)(bar->core.width + bar->core.border_width) )
+ allowed.width -= bar->core.width + bar->core.border_width;
+ else
+ allowed.width = 1;
+ reconfigured = True;
+ }
+ }
+ else {
+ allowed.height = height_remaining;
+ }
+ }
+
+ if (allowed.width != request->width || allowed.height != request->height) {
+ *reply = allowed;
+ result = XtGeometryAlmost;
+ }
+ else {
+ if (rWidth) child->core.width = request->width;
+ if (rHeight) child->core.height = request->height;
+ result = XtGeometryYes;
+ }
+
+ if (reconfigured || child_changed_size)
+ ComputeLayout( (Widget)w,
+ /*query=*/ False,
+ /*destroy=*/ (result == XtGeometryYes) ? True : False );
+
+ return result;
+ }
+
+
+static Boolean GetGeometry(w, width, height)
+ Widget w;
+ Dimension width, height;
+{
+ XtWidgetGeometry geometry, return_geom;
+ XtGeometryResult result;
+
+ if (width == w->core.width && height == w->core.height)
+ return False;
+
+ geometry.request_mode = CWWidth | CWHeight;
+ geometry.width = width;
+ geometry.height = height;
+
+ if (XtIsRealized(w)) {
+ if (((ViewportWidget)w)->viewport.allowhoriz && width > w->core.width)
+ geometry.width = w->core.width;
+ if (((ViewportWidget)w)->viewport.allowvert && height > w->core.height)
+ geometry.height = w->core.height;
+ } else {
+ /* This is the Realize call; we'll inherit a w&h iff none currently */
+ if (w->core.width != 0) {
+ if (w->core.height != 0) return False;
+ geometry.width = w->core.width;
+ }
+ if (w->core.height != 0) geometry.height = w->core.height;
+ }
+
+ result = XtMakeGeometryRequest(w, &geometry, &return_geom);
+ if (result == XtGeometryAlmost)
+ result = XtMakeGeometryRequest(w, &return_geom, (XtWidgetGeometry *)NULL);
+
+ return (result == XtGeometryYes);
+}
+
+static XtGeometryResult PreferredGeometry(w, constraints, reply)
+ Widget w;
+ XtWidgetGeometry *constraints, *reply;
+{
+ if (((ViewportWidget)w)->viewport.child != NULL)
+ return XtQueryGeometry( ((ViewportWidget)w)->viewport.child,
+ constraints, reply );
+ else
+ return XtGeometryYes;
+}
+
+
+void
+#if NeedFunctionPrototypes
+XawViewportSetLocation (Widget gw,
+#if NeedWidePrototypes
+ double xoff, double yoff)
+#else
+ float xoff, float yoff)
+#endif
+#else
+XawViewportSetLocation (gw, xoff, yoff)
+ Widget gw;
+ float xoff,yoff;
+#endif
+{
+ ViewportWidget w = (ViewportWidget) gw;
+ Widget child = w->viewport.child;
+ Position x, y;
+
+ if (xoff > 1.0) /* scroll to right */
+ x = child->core.width;
+ else if (xoff < 0.0) /* if the offset is < 0.0 nothing */
+ x = child->core.x;
+ else
+ x = (Position) (((float) child->core.width) * xoff);
+
+ if (yoff > 1.0)
+ y = child->core.height;
+ else if (yoff < 0.0)
+ y = child->core.y;
+ else
+ y = (Position) (((float) child->core.height) * yoff);
+
+ MoveChild (w, -x, -y);
+}
+
+void
+#if NeedFunctionPrototypes
+XawViewportSetCoordinates (Widget gw,
+#if NeedWidePrototypes
+ int x, int y)
+#else
+ Position x, Position y)
+#endif
+#else
+XawViewportSetCoordinates (gw, x, y)
+ Widget gw;
+ Position x, y;
+#endif
+{
+ ViewportWidget w = (ViewportWidget) gw;
+ Widget child = w->viewport.child;
+
+ if (x > (int)child->core.width)
+ x = child->core.width;
+ else if (x < 0)
+ x = child->core.x;
+
+ if (y > (int)child->core.height)
+ y = child->core.height;
+ else if (y < 0)
+ y = child->core.y;
+
+ MoveChild (w, -x, -y);
+}
+
diff --git a/src/XawI18n.c b/src/XawI18n.c
new file mode 100644
index 0000000..b774aec
--- /dev/null
+++ b/src/XawI18n.c
@@ -0,0 +1,87 @@
+/* $Xorg: XawI18n.c,v 1.4 2001/02/09 02:03:47 xorgcvs Exp $ */
+
+/* Copyright 1991 NCR Corporation - Dayton, Ohio, USA */
+
+/*
+ * Copyright 1990, 1991 by OMRON Corporation, NTT Software Corporation,
+ * and Nippon Telegraph and Telephone Corporation
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the names of OMRON, NTT Software, and NTT
+ * not be used in advertising or publicity pertaining to distribution of the
+ * software without specific, written prior permission. OMRON, NTT Software,
+ * and NTT make no representations about the suitability of this
+ * software for any purpose. It is provided "as is" without express or
+ * implied warranty.
+ *
+ * OMRON, NTT SOFTWARE, AND NTT, DISCLAIM ALL WARRANTIES WITH REGARD
+ * TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+ * AND FITNESS, IN NO EVENT SHALL OMRON, NTT SOFTWARE, OR NTT BE
+ * LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * Author: Li Yuhong OMRON Corporation
+ */
+
+/*
+
+Copyright 1991, 1994, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+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
+OPEN GROUP 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 Open Group 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 Open Group.
+
+*/
+
+#include <X11/IntrinsicP.h>
+#include "XawI18n.h"
+
+#if NeedFunctionPrototypes
+wchar_t _Xaw_atowc(
+ unsigned char c)
+#else
+wchar_t _Xaw_atowc(c)
+ unsigned char c;
+#endif
+{
+ wchar_t wc;
+ char str[2];
+
+ str[0] = c;
+ str[1] = '\0';
+
+ mbtowc(&wc, str, 1);
+ return wc;
+}
+
+#ifdef NCR
+int _Xaw_iswspace(wchar_t w)
+{
+ int ret = 0;
+ wchar_t s = _Xaw_atowc(' ');
+ if (s == w)
+ ret = 1;
+ return ret;
+}
+#endif
diff --git a/src/XawI18n.h b/src/XawI18n.h
new file mode 100644
index 0000000..4432553
--- /dev/null
+++ b/src/XawI18n.h
@@ -0,0 +1,77 @@
+/* $Xorg: XawI18n.h,v 1.4 2001/02/09 02:03:47 xorgcvs Exp $ */
+
+/************************************************************
+
+Copyright 1993, 1994, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+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
+OPEN GROUP 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 Open Group 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 Open Group.
+
+********************************************************/
+
+#ifdef HAS_WCTYPE_H
+#include <wctype.h>
+#include <widec.h>
+#define wcslen(c) wslen(c)
+#define wcscpy(d,s) wscpy(d,s)
+#define wcsncpy(d,s,l) wsncpy(d,s,l)
+#endif
+
+#ifdef HAS_WCHAR_H
+#include <wchar.h>
+#endif
+
+#ifdef AIXV3
+#include <ctype.h>
+#endif
+
+#ifdef NCR
+#define iswspace(c) _Xaw_iswspace(c)
+extern int _Xaw_iswspace(wchar_t);
+#endif
+
+#ifdef sony
+#ifndef SVR4
+#include <jctype.h>
+#define iswspace(c) jisspace(c)
+#endif
+#endif
+
+#ifdef USE_XWCHAR_STRING
+#define wcslen(c) _Xwcslen(c)
+#define wcscpy(d,s) _Xwcscpy(d,s)
+#define wcsncpy(d,s,l) _Xwcsncpy(d,s,l)
+#ifdef USE_XMBTOWC
+#define mbtowc(wc,s,l) _Xmbtowc(wc,s,l)
+#endif
+#endif
+
+extern wchar_t _Xaw_atowc (
+#if NeedFunctionPrototypes
+ unsigned char c
+#endif
+);
+
+#ifndef HAS_ISW_FUNCS
+#include <ctype.h>
+#ifndef iswspace
+#define iswspace(c) (isascii(c) && isspace(toascii(c)))
+#endif
+#endif
diff --git a/src/XawIm.c b/src/XawIm.c
new file mode 100644
index 0000000..e4b4bac
--- /dev/null
+++ b/src/XawIm.c
@@ -0,0 +1,1693 @@
+/* $Xorg: XawIm.c,v 1.6 2001/02/09 02:03:47 xorgcvs Exp $ */
+
+/*
+ * Copyright 1991 by OMRON Corporation
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of OMRON not be used in advertising or
+ * publicity pertaining to distribution of the software without specific,
+ * written prior permission. OMRON makes no representations about the
+ * suitability of this software for any purpose. It is provided "as is"
+ * without express or implied warranty.
+ *
+ * OMRON DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+ * OMRON BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ * ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+ * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTUOUS ACTION,
+ * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+ * SOFTWARE.
+ *
+ * Author: Seiji Kuwari OMRON Corporation
+ * kuwa@omron.co.jp
+ * kuwa%omron.co.jp@uunet.uu.net
+ */
+
+
+/*
+
+Copyright 1994, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+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
+OPEN GROUP 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 Open Group 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 Open Group.
+
+*/
+
+#include <X11/IntrinsicP.h>
+#include <X11/StringDefs.h>
+#include <X11/Xos.h>
+#include <X11/Xfuncs.h>
+#include <X11/ShellP.h>
+#include <X11/Xaw/TextP.h>
+#include <X11/Xaw/MultiSrc.h>
+#include <X11/Xaw/MultiSinkP.h>
+#include <X11/Xaw/XawImP.h>
+#include <X11/Xaw/VendorEP.h>
+#include "XawI18n.h"
+#include <ctype.h>
+
+#if NeedVarargsPrototypes
+# include <stdarg.h>
+# define Va_start(a,b) va_start(a,b)
+#else
+# include <varargs.h>
+# define Va_start(a,b) va_start(a)
+#endif
+
+#define maxAscentOfFontSet(fontset) \
+ ( - (XExtentsOfFontSet((fontset)))->max_logical_extent.y)
+
+#define maxHeightOfFontSet(fontset) \
+ ((XExtentsOfFontSet((fontset)))->max_logical_extent.height)
+
+#define maxDescentOfFontSet(fontset) \
+ (maxHeightOfFontSet(fontset) - maxAscentOfFontSet(fontset))
+
+#define Offset(field) (XtOffsetOf(XawIcTablePart, field))
+
+/*****************************************************
+ *
+ * Forward reference prototypes
+ *
+ *****************************************************/
+
+static XawIcTableList CurrentSharedIcTable(
+#if NeedFunctionPrototypes
+ XawVendorShellExtPart* /* ve */
+#endif
+);
+
+static void DestroyIC(
+#if NeedFunctionPrototypes
+ Widget /* w */,
+ XawVendorShellExtPart* /* ve */
+#endif
+);
+
+static XtResource resources[] =
+{
+ {
+ XtNfontSet, XtCFontSet, XtRFontSet, sizeof(XFontSet),
+ Offset (font_set), XtRString, XtDefaultFontSet
+ },
+ {
+ XtNforeground, XtCForeground, XtRPixel, sizeof(Pixel),
+ Offset (foreground), XtRString, (XtPointer)"XtDefaultForeground"
+ },
+ {
+ XtNbackground, XtCBackground, XtRPixel, sizeof(Pixel),
+ Offset (background), XtRString, (XtPointer)"XtDefaultBackground"
+ },
+ {
+ XtNbackgroundPixmap, XtCPixmap, XtRPixmap, sizeof(Pixmap),
+ Offset (bg_pixmap), XtRImmediate, (XtPointer) XtUnspecifiedPixmap
+ },
+ {
+ XtNinsertPosition, XtCTextPosition, XtRInt, sizeof (XawTextPosition),
+ Offset (cursor_position), XtRImmediate, (XtPointer) 0
+ }
+};
+#undef Offset
+
+
+static void SetVaArg( arg, value )
+ XPointer *arg, value;
+{
+ *arg = value;
+}
+
+static VendorShellWidget SearchVendorShell( w )
+ Widget w;
+{
+ while(w && !XtIsShell(w)) w = XtParent(w);
+ if (w && XtIsVendorShell(w)) return((VendorShellWidget)w);
+ return(NULL);
+}
+
+static XContext extContext = (XContext)NULL;
+
+static XawVendorShellExtPart *SetExtPart( w, vew )
+ VendorShellWidget w;
+ XawVendorShellExtWidget vew;
+{
+ contextDataRec *contextData;
+
+ if (extContext == (XContext)NULL) extContext = XUniqueContext();
+
+ contextData = XtNew(contextDataRec);
+ contextData->parent = (Widget)w;
+ contextData->ve = (Widget)vew;
+ if (XSaveContext(XtDisplay(w), (Window)w, extContext, (char *)contextData)) {
+ return(NULL);
+ }
+ return(&(vew->vendor_ext));
+}
+
+static XawVendorShellExtPart *GetExtPart( w )
+ VendorShellWidget w;
+{
+ contextDataRec *contextData;
+ XawVendorShellExtWidget vew;
+
+ if (XFindContext(XtDisplay(w), (Window)w, extContext,
+ (XPointer*)&contextData)) {
+ return(NULL);
+ }
+ vew = (XawVendorShellExtWidget)contextData->ve;
+ return(&(vew->vendor_ext));
+}
+
+static Boolean IsSharedIC( ve )
+ XawVendorShellExtPart * ve;
+{
+ return( ve->ic.shared_ic );
+}
+
+static XawIcTableList GetIcTableShared( w, ve )
+ Widget w;
+ XawVendorShellExtPart * ve;
+{
+ XawIcTableList p;
+
+ for (p = ve->ic.ic_table; p; p = p->next) {
+ if (p->widget == w) {
+ if (IsSharedIC(ve)) {
+ return(ve->ic.shared_ic_table);
+ } else {
+ return(p);
+ }
+ }
+ }
+ return(NULL);
+}
+
+static XawIcTableList GetIcTable( w, ve )
+ Widget w;
+ XawVendorShellExtPart * ve;
+{
+ XawIcTableList p;
+
+ for (p = ve->ic.ic_table; p; p = p->next) {
+ if (p->widget == w) {
+ return(p);
+ }
+ }
+ return(NULL);
+}
+
+static XIMStyle GetInputStyleOfIC( ve )
+ XawVendorShellExtPart * ve;
+{
+
+ if (!ve) return((XIMStyle)0);
+ return(ve->ic.input_style);
+}
+
+static void ConfigureCB( w, closure, event )
+ Widget w;
+ XtPointer closure;
+ XEvent * event;
+{
+ XawIcTableList p;
+ XawVendorShellExtPart *ve;
+ VendorShellWidget vw;
+ XVaNestedList pe_attr;
+ XRectangle pe_area;
+ XawTextMargin *margin;
+
+ if (event->type != ConfigureNotify) return;
+
+ if ((vw = SearchVendorShell(w)) == NULL) return;
+
+ if (ve = GetExtPart(vw)) {
+ if (IsSharedIC(ve)) return;
+ if ((ve->im.xim == NULL) ||
+ ((p = GetIcTableShared(w, ve)) == NULL) ||
+ (p->xic == NULL) || !(p->input_style & XIMPreeditPosition)) return;
+ pe_area.x = 0;
+ pe_area.y = 0;
+ pe_area.width = w->core.width;
+ pe_area.height = w->core.height;
+ margin = &(((TextWidget)w)->text.margin);
+ pe_area.x += margin->left;
+ pe_area.y += margin->top;
+ pe_area.width -= (margin->left + margin->right - 1);
+ pe_area.height -= (margin->top + margin->bottom - 1);
+
+ pe_attr = XVaCreateNestedList(0, XNArea, &pe_area, NULL);
+ XSetICValues(p->xic, XNPreeditAttributes, pe_attr, NULL);
+ XtFree(pe_attr);
+ }
+}
+
+static XContext errContext = (XContext)NULL;
+
+static Widget SetErrCnxt( w, xim )
+ Widget w;
+ XIM xim;
+{
+ contextErrDataRec *contextErrData;
+
+ if (errContext == (XContext)NULL) errContext = XUniqueContext();
+
+ contextErrData = XtNew(contextErrDataRec);
+ contextErrData->widget = w;
+ contextErrData->xim = xim;
+ if (XSaveContext(XtDisplay(w), (Window)xim, errContext,
+ (char *)contextErrData)) {
+ return(NULL);
+ }
+ return(contextErrData->widget);
+}
+
+static Widget GetErrCnxt( error_im )
+ XIM error_im;
+{
+ contextErrDataRec *contextErrData;
+
+ if (XFindContext(XDisplayOfIM(error_im), (Window)error_im, errContext,
+ (XPointer*)&contextErrData)) {
+ return(NULL);
+ }
+ return(contextErrData->widget);
+}
+
+static void CloseIM( ve )
+ XawVendorShellExtPart * ve;
+{
+ if (ve->im.xim)
+ XCloseIM(ve->im.xim);
+}
+
+static Dimension SetVendorShellHeight( ve, height )
+ XawVendorShellExtPart* ve;
+ Dimension height;
+{
+ Arg args[2];
+ Cardinal i = 0;
+
+ if (ve->im.area_height < height || height == 0) {
+ XtSetArg(args[i], XtNheight,
+ (ve->parent->core.height + height - ve->im.area_height));
+ ve->im.area_height = height;
+ XtSetValues(ve->parent, args, 1);
+ }
+ return(ve->im.area_height);
+}
+
+static void DestroyAllIM( ve )
+ XawVendorShellExtPart * ve;
+{
+ XawIcTableList p;
+ contextErrDataRec *contextErrData;
+
+ /*
+ * Destory all ICs
+ */
+ if (IsSharedIC(ve)) {
+ if ((p = ve->ic.shared_ic_table) && p->xic) {
+ DestroyIC(p->widget, ve);
+ p->xic = NULL;
+ p->ic_focused = FALSE;
+ }
+ } else {
+ for (p = ve->ic.ic_table; p; p = p->next) {
+ if (p->xic == NULL) continue;
+ DestroyIC(p->widget, ve);
+ p->xic = NULL;
+ p->ic_focused = FALSE;
+ }
+ }
+ if (!ve->im.xim) return;
+ /*
+ * Close Input Method
+ */
+ CloseIM(ve);
+ if (!XFindContext(XDisplayOfIM(ve->im.xim), (Window)ve->im.xim, errContext,
+ (XPointer*)&contextErrData)) {
+ if (contextErrData) XtFree((char *)contextErrData);
+ }
+ XDeleteContext(XDisplayOfIM(ve->im.xim), (Window)ve->im.xim, errContext);
+ ve->im.xim = NULL;
+
+ /*
+ * resize vendor shell to core size
+ */
+ (void) SetVendorShellHeight(ve, 0);
+ /*
+ XawVendorShellExtResize(vw);
+ */
+ return;
+}
+
+static void FreeAllDataOfVendorShell(ve, vw)
+ XawVendorShellExtPart * ve;
+ VendorShellWidget vw;
+{
+ XawIcTableList p, next;
+ contextErrDataRec *contextErrData;
+
+ if (!XFindContext(XtDisplay(vw), (Window)vw, extContext,
+ (XPointer*)&contextErrData)) {
+ if (contextErrData) XtFree((char *)contextErrData);
+ }
+ XDeleteContext(XtDisplay(vw), (Window)vw, extContext);
+ if (ve->ic.shared_ic_table)
+ XtFree((char *)ve->ic.shared_ic_table);
+ if (ve->im.resources) XtFree((char *)ve->im.resources);
+ for (p = ve->ic.ic_table; p; p = next) {
+ next = p->next;
+ XtFree((char *)p);
+ }
+}
+
+static void VendorShellDestroyed( w, cl_data, ca_data )
+ Widget w;
+ XtPointer cl_data, ca_data;
+{
+ XawVendorShellExtPart *ve;
+
+ if ( ( ve = GetExtPart( (VendorShellWidget) w ) ) == NULL ) return;
+ DestroyAllIM( ve );
+ FreeAllDataOfVendorShell( ve, (VendorShellWidget) w );
+ return;
+}
+
+static int IOErrorHandler( error_im )
+ XIM error_im;
+{
+ VendorShellWidget vw;
+ XawVendorShellExtPart * ve;
+
+ if ((vw = (VendorShellWidget)GetErrCnxt(error_im)) == NULL
+ || (ve = GetExtPart(vw)) == NULL) return(0);
+
+ DestroyAllIM(ve);
+ return(0);
+}
+
+/*
+ * Attempt to open an input method
+ */
+
+static void OpenIM(ve)
+ XawVendorShellExtPart * ve;
+{
+ int i;
+ char *p, *s, *ns, *end, *pbuf, buf[32];
+ XIM xim = NULL;
+ XIMStyles *xim_styles;
+ XIMStyle input_style = 0;
+ Boolean found;
+
+ if (ve->im.open_im == False) return;
+ ve->im.xim = NULL;
+ if (ve->im.input_method == NULL) {
+ if ((p = XSetLocaleModifiers("@im=none")) != NULL && *p)
+ xim = XOpenIM(XtDisplay(ve->parent), NULL, NULL, NULL);
+ } else {
+ /* no fragment can be longer than the whole string */
+ int len = strlen (ve->im.input_method) + 5;
+
+ if (len < sizeof buf) pbuf = buf;
+ else pbuf = XtMalloc (len);
+
+ if (pbuf == NULL) return;
+
+ for(ns=s=ve->im.input_method; ns && *s;) {
+ /* skip any leading blanks */
+ while (*s && isspace(*s)) s++;
+ if (!*s) break;
+ if ((ns = end = strchr(s, ',')) == NULL)
+ end = s + strlen(s);
+ /* strip any trailing blanks */
+ while (isspace(*end)) end--;
+
+ strcpy (pbuf, "@im=");
+ strncat (pbuf, s, end - s);
+ pbuf[end - s + 4] = '\0';
+
+ if ((p = XSetLocaleModifiers(pbuf)) != NULL && *p
+ && (xim = XOpenIM(XtDisplay(ve->parent), NULL, NULL, NULL)) != NULL)
+ break;
+
+ s = ns + 1;
+ }
+
+ if (pbuf != buf) XtFree (pbuf);
+ }
+ if (xim == NULL) {
+ if ((p = XSetLocaleModifiers("")) != NULL) {
+ xim = XOpenIM(XtDisplay(ve->parent), NULL, NULL, NULL);
+ }
+ }
+ if (xim == NULL) {
+ XtAppWarning(XtWidgetToApplicationContext(ve->parent),
+ "Input Method Open Failed");
+ return;
+ }
+ if (XGetIMValues(xim, XNQueryInputStyle, &xim_styles, NULL)
+ || !xim_styles) {
+ XtAppWarning(XtWidgetToApplicationContext(ve->parent),
+ "input method doesn't support any style");
+ XCloseIM(xim);
+ return;
+ }
+ found = False;
+ for(ns = s = ve->im.preedit_type; s && !found;) {
+ while (*s && isspace(*s)) s++;
+ if (!*s) break;
+ if ((ns = end = strchr(s, ',')) == NULL)
+ ns = end = s + strlen(s);
+ while ((end > s) && isspace(end[-1])) end--;
+
+ /*
+ * If input was degenerate, e.g. "PreeditType: , Root"
+ * Skip over the comma
+ * Don't bother checking current preedit type
+ */
+
+ if (end <= s) {
+ s = ns + 1;
+ continue;
+ }
+
+ if (!strncmp(s, "OverTheSpot", end - s)) {
+ input_style = (XIMPreeditPosition | XIMStatusArea);
+ } else if (!strncmp(s, "OffTheSpot", end - s)) {
+ input_style = (XIMPreeditArea | XIMStatusArea);
+ } else if (!strncmp(s, "Root", end - s)) {
+ input_style = (XIMPreeditNothing | XIMStatusNothing);
+ }
+ for (i = 0; (unsigned short)i < xim_styles->count_styles; i++)
+ if (input_style == xim_styles->supported_styles[i]) {
+ ve->ic.input_style = input_style;
+ SetErrCnxt(ve->parent, xim);
+ ve->im.xim = xim;
+ found = True;
+ break;
+ }
+
+ s = ns + 1;
+ }
+ XFree(xim_styles);
+
+ if (!found) {
+ XCloseIM(xim);
+ XtAppWarning(XtWidgetToApplicationContext(ve->parent),
+ "input method doesn't support my input style");
+ }
+}
+
+static Boolean ResizeVendorShell_Core(vw, ve, p)
+ VendorShellWidget vw;
+ XawVendorShellExtPart * ve;
+ XawIcTableList p;
+{
+ XVaNestedList pe_attr, st_attr;
+ XRectangle pe_area, st_area;
+ XRectangle *get_pe_area = NULL, *get_st_area = NULL;
+
+ st_area.width = 0;
+ if (p->input_style & XIMStatusArea) {
+ st_attr = XVaCreateNestedList(0, XNArea, &get_st_area, NULL);
+ XGetICValues(p->xic, XNStatusAttributes, st_attr, NULL);
+ XFree(st_attr);
+ if (p->xic == NULL) {
+ return(FALSE);
+ }
+ st_area.x = 0;
+ st_area.y = vw->core.height - ve->im.area_height;
+ st_area.width = get_st_area->width;
+ st_area.height = get_st_area->height;
+ XFree(get_st_area);
+ st_attr = XVaCreateNestedList(0, XNArea, &st_area, NULL);
+ XSetICValues(p->xic, XNStatusAttributes, st_attr, NULL);
+ XFree(st_attr);
+ if (p->xic == NULL) {
+ return(FALSE);
+ }
+ }
+ if (p->input_style & XIMPreeditArea) {
+ pe_attr = XVaCreateNestedList(0, XNArea, &get_pe_area, NULL);
+ XGetICValues(p->xic, XNPreeditAttributes, pe_attr, NULL);
+ XFree(pe_attr);
+ if (p->xic == NULL) {
+ return(FALSE);
+ }
+ pe_area.x = st_area.width;
+ pe_area.y = vw->core.height - ve->im.area_height;
+ pe_area.width = vw->core.width;
+ pe_area.height = get_pe_area->height;
+ if (p->input_style & XIMStatusArea) {
+ pe_area.width -= st_area.width;
+ }
+ XFree(get_pe_area);
+ pe_attr = XVaCreateNestedList(0, XNArea, &pe_area, NULL);
+ XSetICValues(p->xic, XNPreeditAttributes, pe_attr, NULL);
+ XFree(pe_attr);
+ }
+ return(TRUE);
+}
+
+static void ResizeVendorShell(vw, ve)
+ VendorShellWidget vw;
+ XawVendorShellExtPart * ve;
+{
+ XawIcTableList p;
+
+ if (IsSharedIC(ve)) {
+ p = ve->ic.shared_ic_table;
+ if (p->xic == NULL) return;
+ ResizeVendorShell_Core(vw, ve, p);
+ return;
+ }
+ for (p = ve->ic.ic_table; p; p = p->next) {
+ if (p->xic == NULL) continue;
+ if (ResizeVendorShell_Core(vw, ve, p) == FALSE) return;
+ }
+}
+
+static XawIcTableList CreateIcTable( w, ve )
+ Widget w;
+ XawVendorShellExtPart * ve;
+{
+ XawIcTableList table;
+
+ table = (XawIcTableList) XtMalloc(sizeof(XawIcTablePart));
+ if (table == NULL) return(NULL);
+ table->widget = w;
+ table->xic = NULL;
+ table->flg = table->prev_flg = 0;
+ table->font_set = NULL;
+ table->foreground = table->background = 0xffffffff;
+ table->bg_pixmap = 0;
+ table->cursor_position = 0xffff;
+ table->line_spacing = 0;
+ table->ic_focused = FALSE;
+ table->openic_error = FALSE;
+ return(table);
+}
+
+static Boolean RegisterToVendorShell( w, ve )
+ Widget w;
+ XawVendorShellExtPart * ve;
+{
+ XawIcTableList table;
+
+ if ((table = CreateIcTable(w, ve)) == NULL) return(FALSE);
+ table->next = ve->ic.ic_table;
+ ve->ic.ic_table = table;
+ return(TRUE);
+}
+
+static void UnregisterFromVendorShell(w, ve)
+ Widget w;
+ XawVendorShellExtPart * ve;
+{
+ XawIcTableList *prev, p;
+
+ for (prev = &ve->ic.ic_table; p = *prev; prev = &p->next) {
+ if (p->widget == w) {
+ *prev = p->next;
+ XtFree((char *)p);
+ break;
+ }
+ }
+ return;
+}
+
+static void SetICValuesShared(w, ve, p, check)
+ Widget w;
+ XawVendorShellExtPart * ve;
+ XawIcTableList p;
+ Boolean check;
+{
+ XawIcTableList pp;
+
+ if ((pp = GetIcTable(w, ve)) == NULL) return;
+ if (check == TRUE && CurrentSharedIcTable(ve) != pp) return;
+
+ if (pp->prev_flg & CICursorP && p->cursor_position != pp->cursor_position) {
+ p->cursor_position = pp->cursor_position;
+ p->flg |= CICursorP;
+ }
+ if (pp->prev_flg & CIFontSet && p->font_set != pp->font_set) {
+ p->font_set = pp->font_set;
+ p->flg |= (CIFontSet|CICursorP);
+ }
+ if (pp->prev_flg & CIFg && p->foreground != pp->foreground) {
+ p->foreground = pp->foreground;
+ p->flg |= CIFg;
+ }
+ if (pp->prev_flg & CIBg && p->background != pp->background) {
+ p->background = pp->background;
+ p->flg |= CIBg;
+ }
+ if (pp->prev_flg & CIBgPixmap && p->bg_pixmap != pp->bg_pixmap) {
+ p->bg_pixmap = pp->bg_pixmap;
+ p->flg |= CIBgPixmap;
+ }
+ if (pp->prev_flg & CILineS && p->line_spacing != pp->line_spacing) {
+ p->line_spacing = pp->line_spacing;
+ p->flg |= CILineS;
+ }
+}
+
+static Boolean IsCreatedIC(w, ve)
+ Widget w;
+ XawVendorShellExtPart * ve;
+{
+ XawIcTableList p;
+
+ if (ve->im.xim == NULL) return(FALSE);
+ if ((p = GetIcTableShared(w, ve)) == NULL) return(FALSE);
+ if (p->xic == NULL) return(FALSE);
+ return(TRUE);
+}
+
+static void SizeNegotiation(p, width, height)
+ XawIcTableList p;
+ Dimension width, height;
+{
+ XRectangle pe_area, st_area;
+ XVaNestedList pe_attr = NULL, st_attr = NULL;
+ int ic_cnt = 0, pe_cnt = 0, st_cnt = 0;
+ XRectangle *pe_area_needed = NULL, *st_area_needed = NULL;
+ XPointer ic_a[5];
+
+ if (p->input_style & XIMPreeditArea) {
+ pe_attr = XVaCreateNestedList(0, XNAreaNeeded, &pe_area_needed, NULL);
+ SetVaArg( &ic_a[ic_cnt], (XPointer) XNPreeditAttributes); ic_cnt++;
+ SetVaArg( &ic_a[ic_cnt], (XPointer) pe_attr); ic_cnt++;
+ }
+ if (p->input_style & XIMStatusArea) {
+ st_attr = XVaCreateNestedList(0, XNAreaNeeded, &st_area_needed, NULL);
+ SetVaArg( &ic_a[ic_cnt], (XPointer) XNStatusAttributes); ic_cnt++;
+ SetVaArg( &ic_a[ic_cnt], (XPointer) st_attr); ic_cnt++;
+ }
+ SetVaArg( &ic_a[ic_cnt], (XPointer) NULL);
+
+ if (ic_cnt > 0) {
+ XGetICValues(p->xic, ic_a[0], ic_a[1], ic_a[2], ic_a[3], ic_a[4]);
+ if (pe_attr) XFree(pe_attr);
+ if (st_attr) XFree(st_attr);
+ if (p->xic == NULL) {
+ p->openic_error = True;
+ return;
+ }
+ pe_attr = st_attr = NULL;
+ ic_cnt = pe_cnt = st_cnt = 0;
+ if (p->input_style & XIMStatusArea) {
+ st_area.height = st_area_needed->height;
+ st_area.x = 0;
+ st_area.y = height - st_area.height;
+ if (p->input_style & XIMPreeditArea) {
+ st_area.width = st_area_needed->width;
+ } else {
+ st_area.width = width;
+ }
+
+ XFree(st_area_needed);
+ st_attr = XVaCreateNestedList(0, XNArea, &st_area, NULL);
+ SetVaArg( &ic_a[ic_cnt], (XPointer) XNStatusAttributes); ic_cnt++;
+ SetVaArg( &ic_a[ic_cnt], (XPointer) st_attr); ic_cnt++;
+ }
+ if (p->input_style & XIMPreeditArea) {
+ if (p->input_style & XIMStatusArea) {
+ pe_area.x = st_area.width;
+ pe_area.width = width - st_area.width;
+ } else {
+ pe_area.x = 0;
+ pe_area.width = width;
+ }
+ pe_area.height = pe_area_needed->height;
+ XFree(pe_area_needed);
+ pe_area.y = height - pe_area.height;
+ pe_attr = XVaCreateNestedList(0, XNArea, &pe_area, NULL);
+ SetVaArg( &ic_a[ic_cnt], (XPointer) XNPreeditAttributes); ic_cnt++;
+ SetVaArg( &ic_a[ic_cnt], (XPointer) pe_attr); ic_cnt++;
+ }
+ SetVaArg( &ic_a[ic_cnt], (XPointer) NULL);
+ XSetICValues(p->xic, ic_a[0], ic_a[1], ic_a[2], ic_a[3], ic_a[4]);
+ if (pe_attr) XFree(pe_attr);
+ if (st_attr) XFree(st_attr);
+ if (p->xic == NULL) {
+ p->openic_error = True;
+ return;
+ }
+ }
+}
+
+static void CreateIC( w, ve )
+ Widget w;
+ XawVendorShellExtPart* ve;
+{
+ XawIcTableList p;
+ XPoint position;
+ XRectangle pe_area, st_area;
+ XVaNestedList pe_attr = NULL, st_attr = NULL;
+ XPointer ic_a[20], pe_a[20], st_a[20];
+ Dimension height = 0;
+ int ic_cnt = 0, pe_cnt = 0, st_cnt = 0;
+ XawTextMargin *margin;
+
+ if (!XtIsRealized(w)) return;
+ if (((ve->im.xim == NULL) || (p = GetIcTableShared(w, ve)) == NULL) ||
+ p->xic || (p->openic_error != FALSE)) return;
+
+ p->input_style = GetInputStyleOfIC(ve);
+
+ if (IsSharedIC(ve)) SetICValuesShared(w, ve, p, FALSE);
+ XFlush(XtDisplay(w));
+
+ if (p->input_style & (XIMPreeditArea|XIMPreeditPosition|XIMStatusArea)) {
+ if (p->flg & CIFontSet) {
+ SetVaArg( &pe_a[pe_cnt], (XPointer) XNFontSet); pe_cnt++;
+ SetVaArg( &pe_a[pe_cnt], (XPointer) p->font_set); pe_cnt++;
+ SetVaArg( &st_a[st_cnt], (XPointer) XNFontSet); st_cnt++;
+ SetVaArg( &st_a[st_cnt], (XPointer) p->font_set); st_cnt++;
+ height = maxAscentOfFontSet(p->font_set)
+ + maxDescentOfFontSet(p->font_set);
+ height = SetVendorShellHeight(ve, height);
+ }
+ if (p->flg & CIFg) {
+ SetVaArg( &pe_a[pe_cnt], (XPointer) XNForeground); pe_cnt++;
+ SetVaArg( &pe_a[pe_cnt], (XPointer) p->foreground); pe_cnt++;
+ SetVaArg( &st_a[st_cnt], (XPointer) XNForeground); st_cnt++;
+ SetVaArg( &st_a[st_cnt], (XPointer) p->foreground); st_cnt++;
+ }
+ if (p->flg & CIBg) {
+ SetVaArg( &pe_a[pe_cnt], (XPointer) XNBackground); pe_cnt++;
+ SetVaArg( &pe_a[pe_cnt], (XPointer) p->background); pe_cnt++;
+ SetVaArg( &st_a[st_cnt], (XPointer) XNBackground); st_cnt++;
+ SetVaArg( &st_a[st_cnt], (XPointer) p->background); st_cnt++;
+ }
+ if (p->flg & CIBgPixmap) {
+ SetVaArg( &pe_a[pe_cnt], (XPointer) XNBackgroundPixmap); pe_cnt++;
+ SetVaArg( &pe_a[pe_cnt], (XPointer) p->bg_pixmap); pe_cnt++;
+ SetVaArg( &st_a[st_cnt], (XPointer) XNBackgroundPixmap); st_cnt++;
+ SetVaArg( &st_a[st_cnt], (XPointer) p->bg_pixmap); st_cnt++;
+ }
+ if (p->flg & CILineS) {
+ SetVaArg( &pe_a[pe_cnt], (XPointer) XNLineSpace); pe_cnt++;
+ SetVaArg( &pe_a[pe_cnt], (XPointer) p->line_spacing); pe_cnt++;
+ SetVaArg( &st_a[st_cnt], (XPointer) XNLineSpace); st_cnt++;
+ SetVaArg( &st_a[st_cnt], (XPointer) p->line_spacing); st_cnt++;
+ }
+ }
+ if (p->input_style & XIMPreeditArea) {
+ pe_area.x = 0;
+ pe_area.y = ve->parent->core.height - height;
+ pe_area.width = ve->parent->core.width;
+ pe_area.height = height;
+ SetVaArg( &pe_a[pe_cnt], (XPointer) XNArea); pe_cnt++;
+ SetVaArg( &pe_a[pe_cnt], (XPointer) &pe_area); pe_cnt++;
+ }
+ if (p->input_style & XIMPreeditPosition) {
+ pe_area.x = 0;
+ pe_area.y = 0;
+ pe_area.width = w->core.width;
+ pe_area.height = w->core.height;
+ margin = &(((TextWidget)w)->text.margin);
+ pe_area.x += margin->left;
+ pe_area.y += margin->top;
+ pe_area.width -= (margin->left + margin->right - 1);
+ pe_area.height -= (margin->top + margin->bottom - 1);
+ SetVaArg( &pe_a[pe_cnt], (XPointer) XNArea); pe_cnt++;
+ SetVaArg( &pe_a[pe_cnt], (XPointer) &pe_area); pe_cnt++;
+ if (p->flg & CICursorP) {
+ _XawMultiSinkPosToXY(w, p->cursor_position, &position.x, &position.y);
+ } else {
+ position.x = position.y = 0;
+ }
+ SetVaArg( &pe_a[pe_cnt], (XPointer) XNSpotLocation); pe_cnt++;
+ SetVaArg( &pe_a[pe_cnt], (XPointer) &position); pe_cnt++;
+ }
+ if (p->input_style & XIMStatusArea) {
+ st_area.x = 0;
+ st_area.y = ve->parent->core.height - height;
+ st_area.width = ve->parent->core.width;
+ st_area.height = height;
+ SetVaArg( &st_a[st_cnt], (XPointer) XNArea); st_cnt++;
+ SetVaArg( &st_a[st_cnt], (XPointer) &st_area); st_cnt++;
+ }
+
+ SetVaArg( &ic_a[ic_cnt], (XPointer) XNInputStyle); ic_cnt++;
+ SetVaArg( &ic_a[ic_cnt], (XPointer) p->input_style); ic_cnt++;
+ SetVaArg( &ic_a[ic_cnt], (XPointer) XNClientWindow); ic_cnt++;
+ SetVaArg( &ic_a[ic_cnt], (XPointer) XtWindow(ve->parent)); ic_cnt++;
+ SetVaArg( &ic_a[ic_cnt], (XPointer) XNFocusWindow); ic_cnt++;
+ SetVaArg( &ic_a[ic_cnt], (XPointer) XtWindow(w)); ic_cnt++;
+
+ if (pe_cnt > 0) {
+ SetVaArg( &pe_a[pe_cnt], (XPointer) NULL);
+ pe_attr = XVaCreateNestedList(0, pe_a[0], pe_a[1], pe_a[2], pe_a[3],
+ pe_a[4], pe_a[5], pe_a[6], pe_a[7], pe_a[8],
+ pe_a[9], pe_a[10], pe_a[11], pe_a[12],
+ pe_a[13], pe_a[14], pe_a[15], pe_a[16],
+ pe_a[17], pe_a[18], pe_a[19]);
+ SetVaArg( &ic_a[ic_cnt], (XPointer) XNPreeditAttributes); ic_cnt++;
+ SetVaArg( &ic_a[ic_cnt], (XPointer) pe_attr); ic_cnt++;
+ }
+
+ if (st_cnt > 0) {
+ SetVaArg( &st_a[st_cnt], (XPointer) NULL);
+ st_attr = XVaCreateNestedList(0, st_a[0], st_a[1], st_a[2], st_a[3],
+ st_a[4], st_a[5], st_a[6], st_a[7], st_a[8],
+ st_a[9], st_a[10], st_a[11], st_a[12],
+ st_a[13], st_a[14], st_a[15], st_a[16],
+ st_a[17], st_a[18], st_a[19]);
+ SetVaArg( &ic_a[ic_cnt], (XPointer) XNStatusAttributes); ic_cnt++;
+ SetVaArg( &ic_a[ic_cnt], (XPointer) st_attr); ic_cnt++;
+ }
+ SetVaArg( &ic_a[ic_cnt], (XPointer) NULL);
+
+ p->xic = XCreateIC(ve->im.xim, ic_a[0], ic_a[1], ic_a[2], ic_a[3],
+ ic_a[4], ic_a[5], ic_a[6], ic_a[7], ic_a[8], ic_a[9],
+ ic_a[10], ic_a[11], ic_a[12], ic_a[13], ic_a[14],
+ ic_a[15], ic_a[16], ic_a[17], ic_a[18], ic_a[19]);
+ if (pe_attr) XtFree(pe_attr);
+ if (st_attr) XtFree(st_attr);
+
+ if (p->xic == NULL) {
+ p->openic_error = True;
+ return;
+ }
+
+ SizeNegotiation(p, ve->parent->core.width, ve->parent->core.height);
+
+ p->flg &= ~(CIFontSet | CIFg | CIBg | CIBgPixmap | CICursorP | CILineS);
+
+ if (!IsSharedIC(ve)) {
+ if (p->input_style & XIMPreeditPosition) {
+ XtAddEventHandler(w, (EventMask)StructureNotifyMask, FALSE,
+ (XtEventHandler)ConfigureCB, (Opaque)NULL);
+ }
+ }
+}
+
+static void SetICValues( w, ve, focus )
+ Widget w;
+ XawVendorShellExtPart *ve;
+ Boolean focus;
+{
+ XawIcTableList p;
+ XPoint position;
+ XRectangle pe_area;
+ XVaNestedList pe_attr = NULL, st_attr = NULL;
+ XPointer ic_a[20], pe_a[20], st_a[20];
+ int ic_cnt = 0, pe_cnt = 0, st_cnt = 0;
+ XawTextMargin *margin;
+ int height;
+
+ if ((ve->im.xim == NULL) || ((p = GetIcTableShared(w, ve)) == NULL) ||
+ (p->xic == NULL)) return;
+
+ if (IsSharedIC(ve)) SetICValuesShared(w, ve, p, TRUE);
+ XFlush(XtDisplay(w));
+ if (focus == FALSE &&
+ !(p->flg & (CIFontSet | CIFg | CIBg |
+ CIBgPixmap | CICursorP | CILineS))) return;
+#ifdef SPOT
+ if ((p->input_style & XIMPreeditPosition)
+ && ((!IsSharedIC(ve) && ((p->flg & ~CIICFocus) == CICursorP))
+ || (IsSharedIC(ve) && p->flg == CICursorP))) {
+ _XawMultiSinkPosToXY(w, p->cursor_position, &position.x, &position.y);
+ _XipChangeSpot(p->xic, position.x, position.y);
+ p->flg &= ~CICursorP;
+ return;
+ }
+#endif
+
+ if (p->input_style & (XIMPreeditArea|XIMPreeditPosition|XIMStatusArea)) {
+ if (p->flg & CIFontSet) {
+ SetVaArg( &pe_a[pe_cnt], (XPointer) XNFontSet); pe_cnt++;
+ SetVaArg( &pe_a[pe_cnt], (XPointer) p->font_set); pe_cnt++;
+ SetVaArg( &st_a[st_cnt], (XPointer) XNFontSet); st_cnt++;
+ SetVaArg( &st_a[st_cnt], (XPointer) p->font_set); st_cnt++;
+ height = maxAscentOfFontSet(p->font_set)
+ + maxDescentOfFontSet(p->font_set);
+ height = SetVendorShellHeight(ve, height);
+ }
+ if (p->flg & CIFg) {
+ SetVaArg( &pe_a[pe_cnt], (XPointer) XNForeground); pe_cnt++;
+ SetVaArg( &pe_a[pe_cnt], (XPointer) p->foreground); pe_cnt++;
+ SetVaArg( &st_a[st_cnt], (XPointer) XNForeground); st_cnt++;
+ SetVaArg( &st_a[st_cnt], (XPointer) p->foreground); st_cnt++;
+ }
+ if (p->flg & CIBg) {
+ SetVaArg( &pe_a[pe_cnt], (XPointer) XNBackground); pe_cnt++;
+ SetVaArg( &pe_a[pe_cnt], (XPointer) p->background); pe_cnt++;
+ SetVaArg( &st_a[st_cnt], (XPointer) XNBackground); st_cnt++;
+ SetVaArg( &st_a[st_cnt], (XPointer) p->background); st_cnt++;
+ }
+ if (p->flg & CIBgPixmap) {
+ SetVaArg( &pe_a[pe_cnt], (XPointer) XNBackgroundPixmap); pe_cnt++;
+ SetVaArg( &pe_a[pe_cnt], (XPointer) p->bg_pixmap); pe_cnt++;
+ SetVaArg( &st_a[st_cnt], (XPointer) XNBackgroundPixmap); st_cnt++;
+ SetVaArg( &st_a[st_cnt], (XPointer) p->bg_pixmap); st_cnt++;
+ }
+ if (p->flg & CILineS) {
+ SetVaArg( &pe_a[pe_cnt], (XPointer) XNLineSpace); pe_cnt++;
+ SetVaArg( &pe_a[pe_cnt], (XPointer) p->line_spacing); pe_cnt++;
+ SetVaArg( &st_a[st_cnt], (XPointer) XNLineSpace); st_cnt++;
+ SetVaArg( &st_a[st_cnt], (XPointer) p->line_spacing); st_cnt++;
+ }
+ }
+ if (p->input_style & XIMPreeditPosition) {
+ if (p->flg & CICursorP) {
+ _XawMultiSinkPosToXY(w, p->cursor_position, &position.x, &position.y);
+ SetVaArg( &pe_a[pe_cnt], (XPointer) XNSpotLocation); pe_cnt++;
+ SetVaArg( &pe_a[pe_cnt], (XPointer) &position); pe_cnt++;
+ }
+ }
+ if (IsSharedIC(ve)) {
+ if (p->input_style & XIMPreeditPosition) {
+ pe_area.x = 0;
+ pe_area.y = 0;
+ pe_area.width = w->core.width;
+ pe_area.height = w->core.height;
+ margin = &(((TextWidget)w)->text.margin);
+ pe_area.x += margin->left;
+ pe_area.y += margin->top;
+ pe_area.width -= (margin->left + margin->right - 1);
+ pe_area.height -= (margin->top + margin->bottom - 1);
+ SetVaArg( &pe_a[pe_cnt], (XPointer) XNArea); pe_cnt++;
+ SetVaArg( &pe_a[pe_cnt], (XPointer) &pe_area); pe_cnt++;
+ }
+ }
+
+ if (pe_cnt > 0) {
+ SetVaArg( &pe_a[pe_cnt], (XPointer) NULL);
+ pe_attr = XVaCreateNestedList(0, pe_a[0], pe_a[1], pe_a[2], pe_a[3],
+ pe_a[4], pe_a[5], pe_a[6], pe_a[7],
+ pe_a[8], pe_a[9], pe_a[10], pe_a[11],
+ pe_a[12], pe_a[13], pe_a[14], pe_a[15],
+ pe_a[16], pe_a[17], pe_a[18], pe_a[19]);
+ SetVaArg( &ic_a[ic_cnt], (XPointer) XNPreeditAttributes); ic_cnt++;
+ SetVaArg( &ic_a[ic_cnt], (XPointer) pe_attr); ic_cnt++;
+ }
+ if (st_cnt > 0) {
+ SetVaArg( &st_a[st_cnt], (XPointer) NULL);
+ st_attr = XVaCreateNestedList(0, st_a[0], st_a[1], st_a[2], st_a[3],
+ st_a[4], st_a[5], st_a[6], st_a[7],
+ st_a[8], st_a[9], st_a[10], st_a[11],
+ st_a[12], st_a[13], st_a[14], st_a[15],
+ st_a[16], st_a[17], st_a[18], st_a[19]);
+ SetVaArg( &ic_a[ic_cnt], (XPointer) XNStatusAttributes); ic_cnt++;
+ SetVaArg( &ic_a[ic_cnt], (XPointer) st_attr); ic_cnt++;
+ }
+ if (focus == TRUE) {
+ SetVaArg( &ic_a[ic_cnt], (XPointer) XNFocusWindow); ic_cnt++;
+ SetVaArg( &ic_a[ic_cnt], (XPointer) XtWindow(w)); ic_cnt++;
+ }
+ if (ic_cnt > 0) {
+ SetVaArg( &ic_a[ic_cnt], (XPointer) NULL);
+ XSetICValues(p->xic, ic_a[0], ic_a[1], ic_a[2], ic_a[3], ic_a[4],
+ ic_a[5], ic_a[6], ic_a[7], ic_a[8], ic_a[9], ic_a[10],
+ ic_a[11], ic_a[12], ic_a[13], ic_a[14], ic_a[15],
+ ic_a[16], ic_a[17], ic_a[18], ic_a[19]);
+ if (pe_attr) XtFree(pe_attr);
+ if (st_attr) XtFree(st_attr);
+ }
+
+ if (IsSharedIC(ve) && p->flg & CIFontSet)
+ SizeNegotiation(p, ve->parent->core.width, ve->parent->core.height);
+
+ p->flg &= ~(CIFontSet | CIFg | CIBg | CIBgPixmap | CICursorP | CILineS);
+}
+
+static void SharedICChangeFocusWindow(w, ve, p)
+ Widget w;
+ XawVendorShellExtPart *ve;
+ XawIcTableList p;
+{
+ XawIcTableList pp;
+
+ if (w == NULL) {
+ ve->ic.current_ic_table = NULL;
+ return;
+ }
+ if ((pp = GetIcTable(w, ve)) == NULL) return;
+ ve->ic.current_ic_table = pp;
+ SetICValues(w, ve, TRUE);
+}
+
+static XawIcTableList CurrentSharedIcTable( ve )
+ XawVendorShellExtPart * ve;
+{
+ return(ve->ic.current_ic_table);
+}
+
+static void SetICFocus(w, ve)
+ Widget w;
+ XawVendorShellExtPart * ve;
+{
+ XawIcTableList p, pp;
+
+ if ((ve->im.xim == NULL) || ((p = GetIcTableShared(w, ve)) == NULL) ||
+ (p->xic == NULL)) return;
+
+ if (IsSharedIC(ve)) {
+ pp = CurrentSharedIcTable(ve);
+ if (pp == NULL || pp->widget != w) {
+ SharedICChangeFocusWindow(w, ve, p);
+ }
+ }
+ if (p->flg & CIICFocus && p->ic_focused == FALSE) {
+ p->ic_focused = TRUE;
+ XSetICFocus(p->xic);
+ }
+ p->flg &= ~CIICFocus;
+}
+
+static void UnsetICFocus(w, ve)
+ Widget w;
+ XawVendorShellExtPart * ve;
+{
+ XawIcTableList p, pp;
+
+ if ((ve->im.xim == NULL) || ((p = GetIcTableShared(w, ve)) == NULL) ||
+ (p->xic == NULL)) return;
+
+ if (IsSharedIC(ve) && (pp = CurrentSharedIcTable(ve))) {
+ if (pp->widget != w) {
+ return;
+ }
+ SharedICChangeFocusWindow(NULL, ve, p);
+ }
+ if (p->ic_focused == TRUE) {
+ XUnsetICFocus(p->xic);
+ p->ic_focused = FALSE;
+ }
+}
+
+static void SetValues( w, ve, args, num_args )
+ Widget w;
+ XawVendorShellExtPart * ve;
+ ArgList args;
+ Cardinal num_args;
+{
+ ArgList arg;
+
+ XrmName argName;
+ XrmResourceList xrmres;
+ int i;
+ XawIcTablePart *p, save_tbl;
+
+ if ((p = GetIcTable(w, ve)) == NULL) return;
+
+ memcpy(&save_tbl, p, sizeof(XawIcTablePart));
+
+ for (arg = args ; num_args != 0; num_args--, arg++) {
+ argName = XrmStringToName(arg->name);
+ for (xrmres = (XrmResourceList)ve->im.resources, i = 0;
+ i < ve->im.num_resources; i++, xrmres++) {
+ if (argName == xrmres->xrm_name) {
+ _XtCopyFromArg(arg->value,
+ (char *)p - xrmres->xrm_offset - 1,
+ xrmres->xrm_size);
+ break;
+ }
+ }
+ }
+ if (p->font_set != save_tbl.font_set) {
+ p->flg |= CIFontSet;
+ }
+ if (p->foreground != save_tbl.foreground) {
+ p->flg |= CIFg;
+ }
+ if (p->background !=save_tbl.background) {
+ p->flg |= CIBg;
+ }
+ if (p->bg_pixmap != save_tbl.bg_pixmap) {
+ p->flg |= CIBgPixmap;
+ }
+ if (p->cursor_position != save_tbl.cursor_position) {
+ p->flg |= CICursorP;
+ }
+ if (p->line_spacing != save_tbl.line_spacing) {
+ p->flg |= CILineS;
+ }
+ p->prev_flg |= p->flg;
+}
+
+static void SetFocus( w, ve )
+ Widget w;
+ XawVendorShellExtPart *ve;
+{
+ XawIcTableList p;
+ if ((p = GetIcTableShared(w, ve)) == NULL) return;
+
+ if ( p->ic_focused == FALSE || IsSharedIC(ve)) {
+ p->flg |= CIICFocus;
+ }
+ p->prev_flg |= p->flg;
+}
+
+static void DestroyIC(w, ve)
+ Widget w;
+ XawVendorShellExtPart *ve;
+{
+ XawIcTableList p;
+
+ if ((ve->im.xim == NULL) || ((p = GetIcTableShared(w, ve)) == NULL) ||
+ (p->xic == NULL)) return;
+ if (IsSharedIC(ve)) {
+ if (GetIcTable(w, ve) == ve->ic.current_ic_table) {
+ UnsetICFocus(w, ve);
+ }
+ return;
+ }
+ XDestroyIC(p->xic);
+ if (!IsSharedIC(ve)) {
+ if (p->input_style & XIMPreeditPosition) {
+ XtRemoveEventHandler(w, (EventMask)StructureNotifyMask, FALSE,
+ (XtEventHandler)ConfigureCB, (Opaque)NULL);
+ }
+ }
+}
+
+static void SetFocusValues( inwidg, args, num_args, focus )
+ Widget inwidg;
+ ArgList args;
+ Cardinal num_args;
+ Boolean focus;
+{
+ XawVendorShellExtPart *ve;
+ VendorShellWidget vw;
+
+ if ((vw = SearchVendorShell(inwidg)) == NULL) return;
+ if (ve = GetExtPart(vw)) {
+ if (num_args > 0) SetValues(inwidg, ve, args, num_args);
+ if (focus) SetFocus(inwidg, ve);
+ if (XtIsRealized((Widget)vw) && ve->im.xim) {
+ if (IsCreatedIC(inwidg, ve)) {
+ SetICValues(inwidg, ve, FALSE);
+ if (focus) SetICFocus(inwidg, ve);
+ } else {
+ CreateIC(inwidg, ve);
+ SetICFocus(inwidg, ve);
+ }
+ }
+ }
+}
+
+static void UnsetFocus( inwidg )
+ Widget inwidg;
+{
+ XawVendorShellExtPart *ve;
+ VendorShellWidget vw;
+ XawIcTableList p;
+
+ if ((vw = SearchVendorShell(inwidg)) == NULL) return;
+ if (ve = GetExtPart(vw)) {
+ if ((p = GetIcTableShared(inwidg, ve)) == NULL) return;
+ if (p->flg & CIICFocus) {
+ p->flg &= ~CIICFocus;
+ }
+ p->prev_flg &= ~CIICFocus;
+ if (ve->im.xim && XtIsRealized((Widget)vw) && p->xic) {
+ UnsetICFocus(inwidg, ve);
+ }
+ }
+}
+
+static Boolean IsRegistered( w, ve )
+ Widget w;
+ XawVendorShellExtPart* ve;
+{
+ XawIcTableList p;
+
+ for (p = ve->ic.ic_table; p; p = p->next)
+ {
+ if (p->widget == w) return(TRUE);
+ }
+ return(FALSE);
+}
+
+static void Register(inwidg, ve)
+ Widget inwidg;
+ XawVendorShellExtPart* ve;
+{
+ if (ve->im.xim == NULL)
+ {
+ OpenIM(ve);
+ }
+
+ if (IsRegistered(inwidg, ve)) return;
+
+ if (RegisterToVendorShell(inwidg, ve) == FALSE) return;
+
+ if (ve->im.xim == NULL) return;
+
+ if (XtIsRealized(ve->parent))
+ {
+ CreateIC(inwidg, ve);
+ SetICFocus(inwidg, ve);
+ }
+}
+
+static Boolean NoRegistered(ve)
+ XawVendorShellExtPart* ve;
+{
+ if (ve->ic.ic_table == NULL) return(TRUE);
+ return(FALSE);
+}
+
+static void Unregister(inwidg, ve)
+ Widget inwidg;
+ XawVendorShellExtPart* ve;
+{
+ if (!IsRegistered(inwidg, ve)) return;
+
+ DestroyIC(inwidg, ve);
+
+ UnregisterFromVendorShell(inwidg, ve);
+
+ if (NoRegistered(ve))
+ {
+ CloseIM(ve);
+ ve->im.xim = NULL;
+ /*
+ * resize vendor shell to core size
+ */
+ (void) SetVendorShellHeight(ve, 0);
+ }
+}
+
+static void AllCreateIC( ve )
+ XawVendorShellExtPart* ve;
+{
+ XawIcTableList p;
+
+ if (ve->im.xim == NULL) return;
+ if (IsSharedIC(ve) && ve->ic.ic_table[0].widget) {
+ p = ve->ic.shared_ic_table;
+ if (p->xic == NULL)
+ CreateIC(ve->ic.ic_table[0].widget, ve);
+ SetICFocus(ve->ic.ic_table[0].widget, ve);
+ return;
+ }
+ for (p = ve->ic.ic_table; p; p = p->next) {
+ if (p->xic == NULL)
+ CreateIC(p->widget, ve);
+ }
+ for (p = ve->ic.ic_table; p; p = p->next) {
+ SetICFocus(p->widget, ve);
+ }
+}
+
+
+static void Reconnect(ve)
+ XawVendorShellExtPart* ve;
+{
+ XawIcTableList p;
+
+ ve->im.open_im = True;
+ if (ve->im.xim == NULL) {
+ OpenIM(ve);
+ }
+ if (ve->im.xim == NULL) return;
+
+ if (IsSharedIC(ve)) {
+ p = ve->ic.shared_ic_table;
+ p->flg = p->prev_flg;
+ p->openic_error = FALSE;
+ } else {
+ for (p = ve->ic.ic_table; p; p = p->next) {
+ p->flg = p->prev_flg;
+ p->openic_error = FALSE;
+ }
+ }
+ AllCreateIC(ve);
+}
+
+
+static void CompileResourceList( res, num_res )
+ XtResourceList res;
+ unsigned int num_res;
+{
+ unsigned int count;
+
+#define xrmres ((XrmResourceList) res)
+ for (count = 0; count < num_res; res++, count++) {
+ xrmres->xrm_name = XrmPermStringToQuark(res->resource_name);
+ xrmres->xrm_class = XrmPermStringToQuark(res->resource_class);
+ xrmres->xrm_type = XrmPermStringToQuark(res->resource_type);
+ xrmres->xrm_offset = -res->resource_offset - 1;
+ xrmres->xrm_default_type = XrmPermStringToQuark(res->default_type);
+ }
+#undef xrmres
+}
+
+static Boolean Initialize( vw, ve )
+ VendorShellWidget vw;
+ XawVendorShellExtPart* ve;
+{
+ if (!XtIsVendorShell((Widget)vw)) return(FALSE);
+ ve->parent = (Widget)vw;
+ ve->im.xim = NULL;
+ ve->im.area_height = 0;
+ ve->im.resources = (XrmResourceList)XtMalloc(sizeof(resources));
+ if (ve->im.resources == NULL) return(FALSE);
+ memcpy((char *)ve->im.resources, (char *)resources, sizeof(resources));
+ ve->im.num_resources = XtNumber(resources);
+ CompileResourceList( (XtResourceList) ve->im.resources,
+ ve->im.num_resources );
+ if ((ve->ic.shared_ic_table = CreateIcTable( (Widget)vw, ve)) == NULL)
+ return(FALSE);
+ ve->ic.current_ic_table = NULL;
+ ve->ic.ic_table = NULL;
+ return(TRUE);
+}
+
+
+/* Destroy()
+ *
+ * This frees all (most?) of the resources malloced by XawIm.
+ * It is called by _XawImDestroy, which is called by Vendor.c's
+ * VendorExt's Destroy method. Sheeran, Omron KK, 93/08/05 */
+
+static void Destroy( w, ve )
+ Widget w;
+ XawVendorShellExtPart* ve;
+{
+ contextDataRec *contextData;
+ contextErrDataRec *contextErrData;
+
+ if (!XtIsVendorShell( w ) )
+ return;
+ XtFree( (char*) ve->im.resources );
+
+ if (extContext != (XContext)NULL &&
+ !XFindContext (XtDisplay (w), (Window)w,
+ extContext, (XPointer*)&contextData))
+ XtFree( (char*) contextData );
+
+ if (errContext != (XContext)NULL &&
+ !XFindContext (XDisplayOfIM( ve->im.xim ), (Window) ve->im.xim,
+ errContext, (XPointer*) &contextErrData))
+ XtFree( (char*) contextErrData );
+}
+
+/*********************************************
+ *
+ * SEMI-PRIVATE FUNCTIONS
+ * For use by other Xaw modules
+ *
+ ********************************************/
+
+void
+#if NeedFunctionPrototypes
+_XawImResizeVendorShell(
+ Widget w )
+#else
+_XawImResizeVendorShell( w )
+ Widget w;
+#endif
+{
+ XawVendorShellExtPart *ve;
+
+ if ( ( ve = GetExtPart( (VendorShellWidget) w ) ) && ve->im.xim ) {
+ ResizeVendorShell( (VendorShellWidget) w, ve );
+ }
+}
+
+
+Dimension
+#if NeedFunctionPrototypes
+_XawImGetShellHeight(
+ Widget w )
+#else
+_XawImGetShellHeight( w )
+ Widget w;
+#endif
+{
+ XawVendorShellExtPart *ve;
+
+ if (!XtIsVendorShell( w ) ) return( w->core.height );
+ if ( ve = GetExtPart( (VendorShellWidget) w ) ) {
+ return( w->core.height - ve->im.area_height );
+ }
+ return( w->core.height );
+}
+
+void
+#if NeedFunctionPrototypes
+_XawImRealize(
+ Widget w )
+#else
+_XawImRealize( w )
+ Widget w;
+#endif
+{
+ XawVendorShellExtPart *ve;
+ extern void XawVendorShellExtResize();
+
+ if ( !XtIsRealized( w ) || !XtIsVendorShell( w ) ) return;
+ if ( ve = GetExtPart( (VendorShellWidget) w ) ) {
+ XtAddEventHandler( w, (EventMask)StructureNotifyMask, FALSE,
+ XawVendorShellExtResize, (XtPointer)NULL );
+ AllCreateIC(ve);
+ }
+}
+
+void
+#if NeedFunctionPrototypes
+_XawImInitialize(
+ Widget w,
+ Widget ext )
+#else
+_XawImInitialize( w, ext )
+ Widget w, ext;
+#endif
+{
+ XawVendorShellExtPart *ve;
+
+ if ( !XtIsVendorShell( w ) ) return;
+ if ( ve = SetExtPart( (VendorShellWidget) w, (XawVendorShellExtWidget)ext ) ) {
+ if ( Initialize( (VendorShellWidget) w, ve ) == FALSE ) return;
+ XtAddCallback( w, XtNdestroyCallback, VendorShellDestroyed,
+ (XtPointer) NULL );
+ }
+}
+
+void
+#if NeedFunctionPrototypes
+_XawImReconnect(
+ Widget inwidg )
+#else
+_XawImReconnect( inwidg )
+ Widget inwidg;
+#endif
+{
+ XawVendorShellExtPart *ve;
+ VendorShellWidget vw;
+
+ if ((vw = SearchVendorShell(inwidg)) == NULL) return;
+ if (ve = GetExtPart(vw)) {
+ Reconnect(ve);
+ }
+}
+
+void
+#if NeedFunctionPrototypes
+_XawImRegister(
+ Widget inwidg)
+#else
+_XawImRegister(inwidg)
+ Widget inwidg;
+#endif
+{
+ XawVendorShellExtPart *ve;
+ VendorShellWidget vw;
+
+ if ((vw = SearchVendorShell(inwidg)) == NULL) return;
+ if (ve = GetExtPart(vw)) {
+ Register(inwidg, ve);
+ }
+}
+
+void
+#if NeedFunctionPrototypes
+_XawImUnregister(
+ Widget inwidg)
+#else
+_XawImUnregister(inwidg)
+ Widget inwidg;
+#endif
+{
+ XawVendorShellExtPart *ve;
+ VendorShellWidget vw;
+
+ if ((vw = SearchVendorShell(inwidg)) == NULL) return;
+ if (ve = GetExtPart(vw)) {
+ Unregister(inwidg, ve);
+ }
+}
+
+void
+#if NeedFunctionPrototypes
+_XawImSetValues(
+ Widget inwidg,
+ ArgList args,
+ Cardinal num_args )
+#else
+_XawImSetValues( inwidg, args, num_args )
+ Widget inwidg;
+ ArgList args;
+ Cardinal num_args;
+#endif
+{
+ SetFocusValues( inwidg, args, num_args, FALSE );
+}
+
+void
+#if NeedFunctionPrototypes
+_XawImSetFocusValues(
+ Widget inwidg,
+ ArgList args,
+ Cardinal num_args)
+#else
+_XawImSetFocusValues(inwidg, args, num_args)
+ Widget inwidg;
+ ArgList args;
+ Cardinal num_args;
+#endif
+{
+ SetFocusValues(inwidg, args, num_args, TRUE);
+}
+
+void
+#if NeedFunctionPrototypes
+_XawImUnsetFocus(
+ Widget inwidg)
+#else
+_XawImUnsetFocus(inwidg)
+ Widget inwidg;
+#endif
+{
+ UnsetFocus(inwidg);
+}
+
+int
+#if NeedFunctionPrototypes
+_XawImWcLookupString(
+ Widget inwidg,
+ XKeyPressedEvent *event,
+ wchar_t* buffer_return,
+ int bytes_buffer,
+ KeySym *keysym_return,
+ Status *status_return)
+#else
+_XawImWcLookupString( inwidg, event, buffer_return, bytes_buffer,
+ keysym_return, status_return)
+ Widget inwidg;
+ XKeyPressedEvent* event;
+ wchar_t* buffer_return;
+ int bytes_buffer;
+ KeySym* keysym_return;
+ Status* status_return;
+#endif
+{
+ XawVendorShellExtPart* ve;
+ VendorShellWidget vw;
+ XawIcTableList p;
+ int i, ret;
+ char tmp_buf[64], *tmp_p;
+ wchar_t* buf_p;
+
+ if ((vw = SearchVendorShell(inwidg)) && (ve = GetExtPart(vw)) &&
+ ve->im.xim && (p = GetIcTableShared(inwidg, ve)) && p->xic) {
+ return(XwcLookupString(p->xic, event, buffer_return, bytes_buffer,
+ keysym_return, status_return));
+ }
+ ret = XLookupString( event, tmp_buf, 64, keysym_return,
+ (XComposeStatus*) status_return );
+ for ( i = 0, tmp_p = tmp_buf, buf_p = buffer_return; i < ret; i++ ) {
+ *buf_p++ = _Xaw_atowc(*tmp_p++);
+ }
+ return( ret );
+}
+
+int
+#if NeedFunctionPrototypes
+_XawImGetImAreaHeight(
+ Widget w)
+#else
+_XawImGetImAreaHeight( w )
+ Widget w;
+#endif
+{
+ XawVendorShellExtPart *ve;
+ VendorShellWidget vw;
+
+ if ((vw = SearchVendorShell(w)) && (ve = GetExtPart(vw))) {
+ return(ve->im.area_height);
+ }
+ return(0);
+}
+
+void
+#if NeedFunctionPrototypes
+_XawImCallVendorShellExtResize(
+ Widget w)
+#else
+_XawImCallVendorShellExtResize( w )
+ Widget w;
+#endif
+{
+ XawVendorShellExtPart *ve;
+ VendorShellWidget vw;
+ extern void XawVendorShellExtResize();
+
+ if ((vw = SearchVendorShell(w)) && (ve = GetExtPart(vw))) {
+ XawVendorShellExtResize(vw);
+ }
+}
+
+
+/* _XawImDestroy()
+ *
+ * This should be called by the VendorExt from its
+ * core Destroy method. Sheeran, Omron KK 93/08/05 */
+
+void
+#if NeedFunctionPrototypes
+_XawImDestroy(
+ Widget w,
+ Widget ext )
+#else
+_XawImDestroy( w, ext )
+ Widget w;
+ Widget ext;
+#endif
+{
+ XawVendorShellExtPart *ve;
+
+ if ( !XtIsVendorShell( w ) ) return;
+ if ( ve = GetExtPart( (VendorShellWidget) w ) )
+ Destroy( w, ve );
+}
diff --git a/src/XawInit.c b/src/XawInit.c
new file mode 100644
index 0000000..f30f49f
--- /dev/null
+++ b/src/XawInit.c
@@ -0,0 +1,48 @@
+/*
+ * $Xorg: XawInit.c,v 1.4 2001/02/09 02:03:47 xorgcvs Exp $
+ *
+Copyright 1989, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+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
+OPEN GROUP 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 Open Group 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 Open Group.
+ *
+ *
+ * XawInitializeWidgetSet
+ *
+ * This routine forces a reference to vendor shell so that the one in this
+ * widget is installed. Any other cross-widget set initialization should be
+ * done here as well. All Athena widgets should include "XawInit.h" and
+ * call this routine from their ClassInitialize procs (this routine may be
+ * used as the class init proc).
+ */
+
+#include <X11/Intrinsic.h>
+#include <X11/Vendor.h>
+#include <X11/Xaw/XawInit.h>
+
+void XawInitializeWidgetSet ()
+{
+ static int firsttime = 1;
+
+ if (firsttime) {
+ firsttime = 0;
+ XtInitializeWidgetClass (vendorShellWidgetClass);
+ }
+}
diff --git a/src/sharedlib.c b/src/sharedlib.c
new file mode 100644
index 0000000..c93e964
--- /dev/null
+++ b/src/sharedlib.c
@@ -0,0 +1,171 @@
+/* $Xorg: sharedlib.c,v 1.4 2001/02/09 02:03:47 xorgcvs Exp $ */
+/*
+
+Copyright 1991, 1994, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+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
+OPEN GROUP 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 Open Group 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 Open Group.
+
+*/
+
+#if defined(SUNSHLIB) && !defined(SHAREDCODE)
+
+#include <X11/IntrinsicP.h>
+#include <X11/Xaw/AsciiSinkP.h>
+#include <X11/Xaw/AsciiSrcP.h>
+#include <X11/Xaw/AsciiTextP.h>
+#include <X11/Xaw/MultiSinkP.h>
+#include <X11/Xaw/MultiSrcP.h>
+#include <X11/Xaw/BoxP.h>
+#include <X11/Xaw/CommandP.h>
+#include <X11/Xaw/DialogP.h>
+#include <X11/Xaw/FormP.h>
+#include <X11/Xaw/GripP.h>
+#include <X11/Xaw/LabelP.h>
+#include <X11/Xaw/ListP.h>
+#include <X11/Xaw/MenuButtoP.h>
+#include <X11/Xaw/PanedP.h>
+#include <X11/Xaw/PannerP.h>
+#include <X11/Xaw/PortholeP.h>
+#include <X11/Xaw/RepeaterP.h>
+#include <X11/Xaw/ScrollbarP.h>
+#include <X11/Xaw/SimpleP.h>
+#include <X11/Xaw/SimpleMenP.h>
+#include <X11/Xaw/SmeP.h>
+#include <X11/Xaw/SmeBSBP.h>
+#include <X11/Xaw/SmeLineP.h>
+#include <X11/Xaw/StripCharP.h>
+#include <X11/Xaw/TextP.h>
+#include <X11/Xaw/TextSinkP.h>
+#include <X11/Xaw/TextSrcP.h>
+#include <X11/Xaw/ToggleP.h>
+#include <X11/Xaw/TreeP.h>
+#include <X11/VendorP.h>
+#include <X11/Xaw/ViewportP.h>
+
+extern AsciiSinkClassRec asciiSinkClassRec;
+WidgetClass asciiSinkObjectClass = (WidgetClass)&asciiSinkClassRec;
+
+extern AsciiSrcClassRec asciiSrcClassRec;
+WidgetClass asciiSrcObjectClass = (WidgetClass)&asciiSrcClassRec;
+
+extern AsciiTextClassRec asciiTextClassRec;
+WidgetClass asciiTextWidgetClass = (WidgetClass)&asciiTextClassRec;
+
+#ifdef ASCII_STRING
+extern AsciiStringClassRec asciiStringClassRec;
+WidgetClass asciiStringWidgetClass = (WidgetClass)&asciiStringClassRec;
+#endif
+
+#ifdef ASCII_DISK
+extern AsciiDiskClassRec asciiDiskClassRec;
+WidgetClass asciiDiskWidgetClass = (WidgetClass)&asciiDiskClassRec;
+#endif
+
+extern MultiSinkClassRec multiSinkClassRec;
+WidgetClass multiSinkObjectClass = (WidgetClass)&multiSinkClassRec;
+
+extern MultiSrcClassRec multiSrcClassRec;
+WidgetClass multiSrcObjectClass = (WidgetClass)&multiSrcClassRec;
+
+extern BoxClassRec boxClassRec;
+WidgetClass boxWidgetClass = (WidgetClass)&boxClassRec;
+
+extern CommandClassRec commandClassRec;
+WidgetClass commandWidgetClass = (WidgetClass) &commandClassRec;
+
+extern DialogClassRec dialogClassRec;
+WidgetClass dialogWidgetClass = (WidgetClass)&dialogClassRec;
+
+extern FormClassRec formClassRec;
+WidgetClass formWidgetClass = (WidgetClass)&formClassRec;
+
+extern GripClassRec gripClassRec;
+WidgetClass gripWidgetClass = (WidgetClass) &gripClassRec;
+
+extern LabelClassRec labelClassRec;
+WidgetClass labelWidgetClass = (WidgetClass)&labelClassRec;
+
+extern ListClassRec listClassRec;
+WidgetClass listWidgetClass = (WidgetClass)&listClassRec;
+
+extern MenuButtonClassRec menuButtonClassRec;
+WidgetClass menuButtonWidgetClass = (WidgetClass) &menuButtonClassRec;
+
+extern PanedClassRec panedClassRec;
+WidgetClass panedWidgetClass = (WidgetClass) &panedClassRec;
+WidgetClass vPanedWidgetClass = (WidgetClass) &panedClassRec;
+
+extern PannerClassRec pannerClassRec;
+WidgetClass pannerWidgetClass = (WidgetClass) &pannerClassRec;
+
+extern PortholeClassRec portholeClassRec;
+WidgetClass portholeWidgetClass = (WidgetClass) &portholeClassRec;
+
+extern RepeaterClassRec repeaterClassRec;
+WidgetClass repeaterWidgetClass = (WidgetClass) &repeaterClassRec;
+
+extern ScrollbarClassRec scrollbarClassRec;
+WidgetClass scrollbarWidgetClass = (WidgetClass)&scrollbarClassRec;
+
+extern SimpleClassRec simpleClassRec;
+WidgetClass simpleWidgetClass = (WidgetClass)&simpleClassRec;
+
+extern SimpleMenuClassRec simpleMenuClassRec;
+WidgetClass simpleMenuWidgetClass = (WidgetClass)&simpleMenuClassRec;
+
+extern SmeClassRec smeClassRec;
+WidgetClass smeObjectClass = (WidgetClass) &smeClassRec;
+
+extern SmeBSBClassRec smeBSBClassRec;
+WidgetClass smeBSBObjectClass = (WidgetClass) &smeBSBClassRec;
+
+extern SmeLineClassRec smeLineClassRec;
+WidgetClass smeLineObjectClass = (WidgetClass) &smeLineClassRec;
+
+extern StripChartClassRec stripChartClassRec;
+WidgetClass stripChartWidgetClass = (WidgetClass) &stripChartClassRec;
+
+extern TextClassRec textClassRec;
+WidgetClass textWidgetClass = (WidgetClass)&textClassRec;
+
+unsigned long FMT8BIT = 0L;
+unsigned long XawFmt8Bit = 0L;
+unsigned long XawFmtWide = 0L;
+
+extern TextSinkClassRec textSinkClassRec;
+WidgetClass textSinkObjectClass = (WidgetClass)&textSinkClassRec;
+
+extern TextSrcClassRec textSrcClassRec;
+WidgetClass textSrcObjectClass = (WidgetClass)&textSrcClassRec;
+
+extern ToggleClassRec toggleClassRec;
+WidgetClass toggleWidgetClass = (WidgetClass) &toggleClassRec;
+
+extern TreeClassRec treeClassRec;
+WidgetClass treeWidgetClass = (WidgetClass) &treeClassRec;
+
+extern VendorShellClassRec vendorShellClassRec;
+WidgetClass vendorShellWidgetClass = (WidgetClass) &vendorShellClassRec;
+
+extern ViewportClassRec viewportClassRec;
+WidgetClass viewportWidgetClass = (WidgetClass)&viewportClassRec;
+
+#endif /* SUNSHLIB */