~ubuntu-branches/ubuntu/utopic/gridengine/utopic

« back to all changes in this revision

Viewing changes to source/3rdparty/qmon/Xmt310/Xmt/XmText.c

  • Committer: Bazaar Package Importer
  • Author(s): Mark Hymers
  • Date: 2008-06-25 22:36:13 UTC
  • Revision ID: james.westby@ubuntu.com-20080625223613-tvd9xlhuoct9kyhm
Tags: upstream-6.2~beta2
ImportĀ upstreamĀ versionĀ 6.2~beta2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* 
 
2
 * Motif Tools Library, Version 3.1
 
3
 * $Id$
 
4
 * 
 
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.
 
10
 *
 
11
 * $Log$
 
12
 * Revision 1.1.1.1  2001/07/18 11:06:03  root
 
13
 * Initial checkin.
 
14
 *
 
15
 * Revision 1.2  2001/06/12 16:25:28  andre
 
16
 * *** empty log message ***
 
17
 *
 
18
 *
 
19
 */
 
20
 
 
21
#include <Xmt/Xmt.h>
 
22
#include <Xmt/WidgetType.h>
 
23
#include <Xmt/QuarksP.h>
 
24
#include <Xm/Text.h>
 
25
 
 
26
/* ARGSUSED */
 
27
#if NeedFunctionPrototypes
 
28
static void setvalue(Widget w, XtPointer address, XrmQuark type, Cardinal size)
 
29
#else
 
30
static void setvalue(w, address, type, size)
 
31
Widget w;
 
32
XtPointer address;
 
33
XrmQuark type;
 
34
Cardinal size;
 
35
#endif
 
36
{
 
37
    if (type == XmtQString)
 
38
        XmTextSetString(w, *(String *)address);
 
39
    else if (type == XmtQBuffer)
 
40
        XmTextSetString(w, (char *)address);
 
41
    else
 
42
        XmtWarningMsg("XmtDialogSetDialogValues", "xmtext",
 
43
                      "Type mismatch:\n\tCan't set value from resource of type '%s'.  String or Buffer expected.",
 
44
                   XrmQuarkToString(type));
 
45
}
 
46
 
 
47
#if NeedFunctionPrototypes
 
48
static void getvalue(Widget w, XtPointer address, XrmQuark type, Cardinal size)
 
49
#else
 
50
static void getvalue(w, address, type, size)
 
51
Widget w;
 
52
XtPointer address;
 
53
XrmQuark type;
 
54
Cardinal size;
 
55
#endif
 
56
{
 
57
    if (type == XmtQString)
 
58
        *(String *)address = XmTextGetString(w);
 
59
    else if (type == XmtQBuffer) {
 
60
        String s = XmTextGetString(w);
 
61
        int len = strlen(s);
 
62
 
 
63
        strncpy(address, s, size-1);
 
64
        ((char *)address)[size-1] = '\0';
 
65
        if (len >= size)
 
66
            XmtWarningMsg("XmtDialogGetDialogValues", "xmtextTrunc",
 
67
                          "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.",
 
68
                          len+1, size);
 
69
        XtFree(s);
 
70
    }
 
71
    else
 
72
        XmtWarningMsg("XmtDialogGetDialogValues", "xmtextType",
 
73
                      "Type mismatch:\n\tCan't set input value on a resource of type '%s'.  String or Buffer expected.",
 
74
                      XrmQuarkToString(type));
 
75
}
 
76
 
 
77
static XmtWidgetType text = {
 
78
    "XmText",
 
79
    NULL,
 
80
    XmCreateText,
 
81
    setvalue,
 
82
    getvalue,
 
83
};
 
84
 
 
85
static XmtWidgetType stext = {
 
86
    "XmScrolledText",
 
87
    NULL,
 
88
    XmCreateScrolledText,
 
89
    setvalue,
 
90
    getvalue,
 
91
};
 
92
 
 
93
#if NeedFunctionPrototypes
 
94
void XmtRegisterXmText(void)
 
95
#else
 
96
void XmtRegisterXmText()
 
97
#endif
 
98
{
 
99
    _XmtInitQuarks();
 
100
    XmtRegisterWidgetTypes(&text, 1);
 
101
}
 
102
 
 
103
#if NeedFunctionPrototypes
 
104
void XmtRegisterXmScrolledText(void)
 
105
#else
 
106
void XmtRegisterXmScrolledText()
 
107
#endif
 
108
{
 
109
    _XmtInitQuarks();
 
110
    XmtRegisterWidgetTypes(&stext, 1);
 
111
}