File: InfoLine.c

package info (click to toggle)
xrn 9.02-1
  • links: PTS
  • area: main
  • in suites: potato
  • size: 1,784 kB
  • ctags: 3,047
  • sloc: ansic: 24,689; makefile: 2,240; yacc: 888; sh: 274; lex: 92; perl: 35; awk: 31; csh: 13
file content (87 lines) | stat: -rw-r--r-- 1,807 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
#ifdef MOTIF
# include <Xm/Xm.h>
# include <Xm/Label.h>
#else
# include <X11/Intrinsic.h>
# include <X11/StringDefs.h>
# include <X11/Xaw/Label.h>
# include <X11/Xaw/Paned.h>
#endif

#include "config.h"
#include "InfoLine.h"

Widget InfoLineCreate(name, initial_text, parent)
    String name;
    String initial_text;
    Widget parent;
{
    Widget w;
    Dimension height;

#ifdef MOTIF
    w = XtVaCreateManagedWidget(name, xmLabelWidgetClass, parent,
				XmNskipAdjust, True,
				0);

    if (initial_text)
        InfoLineSet(w, initial_text);

    XtVaGetValues(w, XmNheight, &height, 0);

    XtVaSetValues(w,
		  XmNpaneMinimum, height,
		  XmNpaneMaximum, height,
		  0);
#else
    w = XtVaCreateManagedWidget(name, labelWidgetClass, parent,
				XtNskipAdjust, True,
				XtNshowGrip, False,
				0);

    if (initial_text)
        InfoLineSet(w, initial_text);

    XtVaGetValues(w, XtNheight, &height, 0);

    XtVaSetValues(w,
		  XtNmin, height,
		  XtNmax, height,
		  XtNpreferredPaneSize, height,
		  XtNresizeToPreferred, True,
		  0);
#endif

    return(w);
}

void InfoLineSet(w, text)
    Widget w;
    String text;
{
    char *newString = XtNewString(text), *ptr;
#ifdef MOTIF
    XmString x;
#endif

    /* Info lines are one line long, so they can't have newlines in them,
       and tabs just waste space. */
    for (ptr = strpbrk(newString, "\n\t"); ptr; ptr = strpbrk(newString, "\n\t"))
      *ptr = ' ';

#ifdef MOTIF
    /* Yes, I know this is an old function and not the preferred way, but for now...kb */
    x = XmStringCreateSimple(newString);
    XtVaSetValues(w, XmNlabelString, x, 0);
    XmStringFree(x);
#else
    XtVaSetValues(w, XtNlabel, newString, 0);
#endif
    XtFree(newString);
}

void InfoLineDestroy(widget)
    Widget widget;
{
    XtDestroyWidget(widget);
}