2
* Motif Tools Library, Version 3.1
5
* Written by David Flanagan.
6
* Copyright (c) 1992-2001 by David Flanagan.
7
* All Rights Reserved. See the file COPYRIGHT for details.
8
* This is open source software. See the file LICENSE for details.
9
* There is no warranty for this software. See NO_WARRANTY for details.
12
* Revision 1.1.1.1 2001/07/18 11:06:03 root
15
* Revision 1.2 2001/06/12 16:25:28 andre
16
* *** empty log message ***
22
* This file courtesy of Tony Hefner.
30
#include <Xmt/WidgetType.h>
31
#include <Xmt/QuarksP.h>
32
#include <Xm/CSText.h>
35
#if NeedFunctionPrototypes
36
static void setvalue(Widget w, XtPointer address, XrmQuark type, Cardinal size)
38
static void setvalue(w, address, type, size)
45
XmString xmString = NULL;
47
if (type == XmtQString) {
48
/* Convert the value to an XmString. */
49
xmString = XmtCreateLocalizedXmString(w, *(String *)address);
50
XmCSTextSetString(w, xmString);
52
else if (type == XmtQBuffer) {
53
/* Convert the value to an XmString. */
54
xmString = XmtCreateLocalizedXmString(w, (char *)address);
55
XmCSTextSetString(w, xmString);
58
XmtWarningMsg("XmtDialogSetDialogValues", "xmcstext",
59
"Type mismatch:\n\tCan't set value from resource of type '%s'. String or Buffer expected.",
60
XrmQuarkToString(type));
62
if (xmString) XmStringFree(xmString);
65
#if NeedFunctionPrototypes
66
static void getvalue(Widget w, XtPointer address, XrmQuark type, Cardinal size)
68
static void getvalue(w, address, type, size)
78
if (type == XmtQString) {
81
/* Find out how many characters are in the widget buffer. */
82
nChars = XmCSTextGetLastPosition(w);
84
/* Calculate the buffer size for the entire contents. */
85
bufferSize = (nChars * MB_CUR_MAX) + 1;
87
buffer = XtMalloc(bufferSize);
89
/* Now read out the contents. */
90
XmCSTextGetSubstring(w, 0, nChars, bufferSize, buffer);
92
*(String *)address = buffer;
94
else if (type == XmtQBuffer) {
95
/* Find out how many characters are in the widget buffer. */
96
nChars = XmCSTextGetLastPosition(w);
98
/* Calculate the buffer size for the entire contents. */
99
bufferSize = (nChars * MB_CUR_MAX) + 1;
102
XmCSTextGetSubstring(w, 0, nChars, size, (char *)address);
104
XmCSTextGetSubstring(w, 0, size, size, (char *)address);
106
XmtWarningMsg("XmtDialogGetDialogValues", "xmcstextTrunc",
107
"The input value is %d characters long\n\tand does not fit into a buffer %d characters long.\n\tThe trailing characters have been truncated.",
112
XmtWarningMsg("XmtDialogGetDialogValues", "xmtextType",
113
"Type mismatch:\n\tCan't set input value on a resource of type '%s'. String or Buffer expected.",
114
XrmQuarkToString(type));
117
static XmtWidgetType cstext = {
120
(XmtWidgetConstructor) XmCreateCSText,
125
static XmtWidgetType scstext = {
128
(XmtWidgetConstructor) XmCreateScrolledCSText,
133
#if NeedFunctionPrototypes
134
void XmtRegisterXmCSText(void)
136
void XmtRegisterXmCSText()
140
XmtRegisterWidgetTypes(&cstext, 1);
143
#if NeedFunctionPrototypes
144
void XmtRegisterXmScrolledCSText(void)
146
void XmtRegisterXmScrolledCSText()
150
XmtRegisterWidgetTypes(&scstext, 1);
153
#else /* if XmVersion = 2000 */
154
/* just so the compiler doesn't complain about an empty file. */
155
static char XmtDummy;