-
Notifications
You must be signed in to change notification settings - Fork 7
/
SGMLMarkerText.c
162 lines (139 loc) · 6.31 KB
/
SGMLMarkerText.c
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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
/*==================================================================*/
/* */
/* SGMLMarkerTextObject */
/* */
/* T.Johnson - ([email protected]) June.92 */
/* */
/* Defines a marker text segment for the SGMLHyper widget */
/* */
/*==================================================================*/
#include <X11/IntrinsicP.h>
#include <X11/StringDefs.h>
#include <X11/CoreP.h>
#include "SGMLMarkerTextP.h"
/*
Private functions
*/
/*
Widget class methods
*/
static void ComputeSize();
#define Offset(field) XtOffsetOf(SGMLMarkerTextRec,sgml_marker_text.field)
static XtResource resources[] = {
{SGMLNcolumnAlign,SGMLCColumnAlign,XtRDimension,sizeof(Dimension),
Offset (column_align),XtRImmediate,(XtPointer)0},
{SGMLNposition,SGMLCPosition,XtRPosition,sizeof(Position),
Offset (position),XtRImmediate,(XtPointer)-1},
};
#undef Offset
/*---------------------------------------------------------------*/
/* Static initialisation of the class record */
/*---------------------------------------------------------------*/
SGMLMarkerTextClassRec sGMLMarkerTextClassRec = {
{
(WidgetClass) &sGMLTextClassRec, /* superclass */
"SGMLMarkerText", /* class_name */
sizeof(SGMLMarkerTextRec), /* widget_size */
NULL, /* class_initialize */
NULL, /* class_part_initialize */
FALSE, /* class_inited */
NULL, /* initialize */
NULL, /* initialize_hook */
NULL, /* obj1 */
NULL, /* obj2 */
0, /* obj3 */
resources, /* resources */
XtNumber(resources), /* num_resources */
NULLQUARK, /* xrm_class */
0, /* obj4 */
0, /* obj5 */
0, /* obj6 */
0, /* obj7 */
NULL, /* destroy */
NULL, /* obj8 */
NULL, /* obj9 */
NULL, /* set_values */
NULL, /* set_values_hook */
NULL, /* obj10 */
NULL, /* get_values_hook */
NULL, /* obj11 */
XtVersion, /* version */
NULL, /* callback private */
NULL, /* obj12 */
NULL, /* obj13 */
NULL, /* obj14 */
NULL, /* extension */
},
{
ComputeSize, /* compute_size */
SGMLInheritAdjustSize, /* adjust_size */
SGMLInheritAdjustPosition, /* adjust_position */
SGMLInheritExpose, /* expose */
SGMLInheritActivate, /* activate */
SGMLInheritHilite, /* hilite */
SGMLInheritContains, /* contains */
SGMLInheritCallCreateCallback, /* call_create_callback */
SGMLInheritCallMapCallback, /* call_map_callback */
SGMLInheritMakeVisible, /* make_visible */
NULL, /* extension */
},
{
NULL, /* ignore */
}
};
WidgetClass sGMLMarkerTextObjectClass = (WidgetClass) &sGMLMarkerTextClassRec;
/*--------------------------------------------------------------*/
/* Compute Size: */
/*--------------------------------------------------------------*/
static void ComputeSize(w,geom)
SGMLMarkerTextObject w;
SGMLGeometry *geom;
{
Dimension left_clearance = w->sgml_text.left_margin + w->sgml_text.left_indent;
Dimension right_clearance = w->sgml_text.right_margin + w->sgml_text.right_indent;
/*
* Break?
*/
if (w->sgml_text.break_before || w->sgml_text.break_after)
{
_SGMLBreak(geom,w->sgml_text.space_before);
_SGMLBreak(geom,w->sgml_text.space_after);
}
else if (w->sgml_marker_text.column_align)
{
Dimension x = geom->coord.x;
if (x < left_clearance) x = 0;
else x -= left_clearance;
if (x%w->sgml_marker_text.column_align)
x += w->sgml_marker_text.column_align - x%w->sgml_marker_text.column_align;
x += left_clearance;
geom->coord.x = x;
geom->leave_space = FALSE;
if (x + w->sgml_marker_text.column_align + right_clearance >
geom->natural_width)
{
_SGMLBreak(geom,0);
}
}
if (w->sgml_marker_text.position >= 0)
{
if (geom->coord.x > w->sgml_text.left_margin+w->sgml_marker_text.position)
{
_SGMLBreak(geom,0);
}
geom->coord.x = w->sgml_text.left_margin+w->sgml_marker_text.position;
geom->leave_space = FALSE;
geom->broken = FALSE;
}
}
/*-----------------------------------------------------------------------*/
/* Create a new SGMLMarkerTextObject */
/*-----------------------------------------------------------------------*/
Widget SGMLCreateMarkerText(parent,name,al,ac)
Widget parent;
char *name;
ArgList al;
int ac;
{
return XtCreateWidget(name,sGMLMarkerTextObjectClass,parent,al,ac);
}