00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040 #include <stdio.h>
00041 #include <X11/IntrinsicP.h>
00042 #include <X11/StringDefs.h>
00043
00044 #include <X11/Xaw3d/XawInit.h>
00045 #include <X11/Xaw3d/SmeLineP.h>
00046 #include <X11/Xaw3d/Cardinals.h>
00047
00048 #define offset(field) XtOffsetOf(SmeLineRec, sme_line.field)
00049 static XtResource resources[] = {
00050 {XtNlineWidth, XtCLineWidth, XtRDimension, sizeof(Dimension),
00051 offset(line_width), XtRImmediate, (XtPointer) 1},
00052 {XtNstipple, XtCStipple, XtRBitmap, sizeof(Pixmap),
00053 offset(stipple), XtRImmediate, (XtPointer) XtUnspecifiedPixmap},
00054 {XtNforeground, XtCForeground, XtRPixel, sizeof(Pixel),
00055 offset(foreground), XtRString, XtDefaultForeground},
00056 };
00057 #undef offset
00058
00059
00060
00061
00062
00063 static void Redisplay(), Initialize();
00064 static void DestroyGC(), CreateGC();
00065 static Boolean SetValues();
00066 static XtGeometryResult QueryGeometry();
00067
00068
00069 #define SUPERCLASS (&smeClassRec)
00070
00071 SmeLineClassRec smeLineClassRec = {
00072 {
00073 (WidgetClass) SUPERCLASS,
00074 "SmeLine",
00075 sizeof(SmeLineRec),
00076 XawInitializeWidgetSet,
00077 NULL,
00078 FALSE,
00079 Initialize,
00080 NULL,
00081 NULL,
00082 NULL,
00083 ZERO,
00084 resources,
00085 XtNumber(resources),
00086 NULLQUARK,
00087 FALSE,
00088 FALSE,
00089 FALSE,
00090 FALSE,
00091 DestroyGC,
00092 NULL,
00093 Redisplay,
00094 SetValues,
00095 NULL,
00096 XtInheritSetValuesAlmost,
00097 NULL,
00098 NULL,
00099 XtVersion,
00100 NULL,
00101 NULL,
00102 QueryGeometry,
00103 NULL,
00104 NULL
00105 },{
00106
00107
00108 XtInheritHighlight,
00109 XtInheritUnhighlight,
00110 XtInheritNotify,
00111 NULL
00112 },{
00113
00114 NULL
00115 }
00116 };
00117
00118 WidgetClass smeLineObjectClass = (WidgetClass) &smeLineClassRec;
00119
00120
00121
00122
00123
00124
00125
00126
00127
00128
00129
00130
00131
00132
00133
00134
00135 static void
00136 Initialize(request, new, args, num_args)
00137 Widget request, new;
00138 ArgList args;
00139 Cardinal *num_args;
00140 {
00141 SmeLineObject entry = (SmeLineObject) new;
00142
00143 if (entry->rectangle.height == 0)
00144 entry->rectangle.height = entry->sme_line.line_width;
00145
00146 CreateGC(new);
00147 }
00148
00149
00150
00151
00152
00153
00154
00155
00156
00157
00158 static void
00159 CreateGC(w)
00160 Widget w;
00161 {
00162 SmeLineObject entry = (SmeLineObject) w;
00163 XGCValues values;
00164 XtGCMask mask = GCForeground | GCGraphicsExposures | GCLineWidth ;
00165
00166 values.foreground = entry->sme_line.foreground;
00167 values.graphics_exposures = FALSE;
00168 values.line_width = entry->sme_line.line_width;
00169
00170 if (entry->sme_line.stipple != XtUnspecifiedPixmap) {
00171 values.stipple = entry->sme_line.stipple;
00172 values.fill_style = FillStippled;
00173 mask |= GCStipple | GCFillStyle;
00174
00175 entry->sme_line.gc = XCreateGC(XtDisplayOfObject(w),
00176 RootWindowOfScreen(XtScreenOfObject(w)),
00177 mask, &values);
00178 }
00179 else
00180 entry->sme_line.gc = XtGetGC(w, mask, &values);
00181 }
00182
00183
00184
00185
00186
00187
00188
00189 static void
00190 DestroyGC(w)
00191 Widget w;
00192 {
00193 SmeLineObject entry = (SmeLineObject) w;
00194
00195 if (entry->sme_line.stipple != XtUnspecifiedPixmap)
00196 XFreeGC(XtDisplayOfObject(w), entry->sme_line.gc);
00197 else
00198 XtReleaseGC(w, entry->sme_line.gc);
00199 }
00200
00201
00202
00203
00204
00205
00206
00207
00208
00209 static void
00210 Redisplay(w, event, region)
00211 Widget w;
00212 XEvent * event;
00213 Region region;
00214 {
00215 SmeLineObject entry = (SmeLineObject) w;
00216 int y = entry->rectangle.y +
00217 (int)(entry->rectangle.height - entry->sme_line.line_width) / 2;
00218
00219 if (entry->sme_line.stipple != XtUnspecifiedPixmap)
00220 XSetTSOrigin(XtDisplayOfObject(w), entry->sme_line.gc, 0, y);
00221
00222 XFillRectangle(XtDisplayOfObject(w), XtWindowOfObject(w),
00223 entry->sme_line.gc,
00224 0, y, (unsigned int) entry->rectangle.width,
00225 (unsigned int) entry->sme_line.line_width );
00226 }
00227
00228
00229
00230
00231
00232
00233
00234
00235
00236
00237 static Boolean
00238 SetValues(current, request, new, args, num_args)
00239 Widget current, request, new;
00240 ArgList args;
00241 Cardinal *num_args;
00242 {
00243 SmeLineObject entry = (SmeLineObject) new;
00244 SmeLineObject old_entry = (SmeLineObject) current;
00245
00246 if ( (entry->sme_line.line_width != old_entry->sme_line.line_width) &&
00247 (entry->sme_line.stipple != old_entry->sme_line.stipple) ) {
00248 DestroyGC(current);
00249 CreateGC(new);
00250 return(TRUE);
00251 }
00252 return(FALSE);
00253 }
00254
00255
00256
00257
00258
00259
00260
00261
00262
00263
00264
00265
00266 static XtGeometryResult
00267 QueryGeometry(w, intended, return_val)
00268 Widget w;
00269 XtWidgetGeometry *intended, *return_val;
00270 {
00271 SmeObject entry = (SmeObject) w;
00272 Dimension width;
00273 XtGeometryResult ret_val = XtGeometryYes;
00274 XtGeometryMask mode = intended->request_mode;
00275
00276 width = 1;
00277
00278 if ( ((mode & CWWidth) && (intended->width != width)) ||
00279 !(mode & CWWidth) ) {
00280 return_val->request_mode |= CWWidth;
00281 return_val->width = width;
00282 mode = return_val->request_mode;
00283
00284 if ( (mode & CWWidth) && (width == entry->rectangle.width) )
00285 return(XtGeometryNo);
00286 return(XtGeometryAlmost);
00287 }
00288 return(ret_val);
00289 }