RectObj.c revision 444c061a
1/* $Xorg: RectObj.c,v 1.4 2001/02/09 02:03:56 xorgcvs Exp $ */ 2 3/*********************************************************** 4 5Copyright 1987, 1988, 1998 The Open Group 6 7Permission to use, copy, modify, distribute, and sell this software and its 8documentation for any purpose is hereby granted without fee, provided that 9the above copyright notice appear in all copies and that both that 10copyright notice and this permission notice appear in supporting 11documentation. 12 13The above copyright notice and this permission notice shall be included in 14all copies or substantial portions of the Software. 15 16THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN 20AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 22 23Except as contained in this notice, the name of The Open Group shall not be 24used in advertising or otherwise to promote the sale, use or other dealings 25in this Software without prior written authorization from The Open Group. 26 27 28Copyright 1987, 1988 by Digital Equipment Corporation, Maynard, Massachusetts. 29 30 All Rights Reserved 31 32Permission to use, copy, modify, and distribute this software and its 33documentation for any purpose and without fee is hereby granted, 34provided that the above copyright notice appear in all copies and that 35both that copyright notice and this permission notice appear in 36supporting documentation, and that the name of Digital not be 37used in advertising or publicity pertaining to distribution of the 38software without specific, written prior permission. 39 40DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING 41ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL 42DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR 43ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, 44WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, 45ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS 46SOFTWARE. 47 48******************************************************************/ 49/* $XFree86: xc/lib/Xt/RectObj.c,v 1.2 2001/08/22 22:52:19 dawes Exp $ */ 50 51#define RECTOBJ 52#ifdef HAVE_CONFIG_H 53#include <config.h> 54#endif 55#include "IntrinsicI.h" 56#include "StringDefs.h" 57#include "CreateI.h" 58 59/****************************************************************** 60 * 61 * Rectangle Object Resources 62 * 63 ******************************************************************/ 64 65static void XtCopyAncestorSensitive(Widget, int, XrmValue *); 66 67static XtResource resources[] = { 68 69 {XtNancestorSensitive, XtCSensitive, XtRBoolean, sizeof(Boolean), 70 XtOffsetOf(RectObjRec,rectangle.ancestor_sensitive),XtRCallProc, 71 (XtPointer)XtCopyAncestorSensitive}, 72 {XtNx, XtCPosition, XtRPosition, sizeof(Position), 73 XtOffsetOf(RectObjRec,rectangle.x), XtRImmediate, (XtPointer)0}, 74 {XtNy, XtCPosition, XtRPosition, sizeof(Position), 75 XtOffsetOf(RectObjRec,rectangle.y), XtRImmediate, (XtPointer)0}, 76 {XtNwidth, XtCWidth, XtRDimension, sizeof(Dimension), 77 XtOffsetOf(RectObjRec,rectangle.width), XtRImmediate, (XtPointer)0}, 78 {XtNheight, XtCHeight, XtRDimension, sizeof(Dimension), 79 XtOffsetOf(RectObjRec,rectangle.height), XtRImmediate, (XtPointer)0}, 80 {XtNborderWidth, XtCBorderWidth, XtRDimension, sizeof(Dimension), 81 XtOffsetOf(RectObjRec,rectangle.border_width), XtRImmediate, 82 (XtPointer)1}, 83 {XtNsensitive, XtCSensitive, XtRBoolean, sizeof(Boolean), 84 XtOffsetOf(RectObjRec,rectangle.sensitive), XtRImmediate, 85 (XtPointer)True} 86 }; 87 88static void RectClassPartInitialize(WidgetClass); 89static void RectSetValuesAlmost(Widget, Widget, XtWidgetGeometry *, XtWidgetGeometry *); 90 91externaldef(rectobjclassrec) RectObjClassRec rectObjClassRec = { 92 { 93 /* superclass */ (WidgetClass)&objectClassRec, 94 /* class_name */ "Rect", 95 /* widget_size */ sizeof(RectObjRec), 96 /* class_initialize */ NULL, 97 /* class_part_initialize*/ RectClassPartInitialize, 98 /* class_inited */ FALSE, 99 /* initialize */ NULL, 100 /* initialize_hook */ NULL, 101 /* realize */ NULL, 102 /* actions */ NULL, 103 /* num_actions */ 0, 104 /* resources */ resources, 105 /* num_resources */ XtNumber(resources), 106 /* xrm_class */ NULLQUARK, 107 /* compress_motion */ FALSE, 108 /* compress_exposure */ TRUE, 109 /* compress_enterleave*/ FALSE, 110 /* visible_interest */ FALSE, 111 /* destroy */ NULL, 112 /* resize */ NULL, 113 /* expose */ NULL, 114 /* set_values */ NULL, 115 /* set_values_hook */ NULL, 116 /* set_values_almost */ RectSetValuesAlmost, 117 /* get_values_hook */ NULL, 118 /* accept_focus */ NULL, 119 /* version */ XtVersion, 120 /* callback_offsets */ NULL, 121 /* tm_table */ NULL, 122 /* query_geometry */ NULL, 123 /* display_accelerator */ NULL, 124 /* extension */ NULL 125 } 126}; 127 128externaldef(rectObjClass) 129WidgetClass rectObjClass = (WidgetClass)&rectObjClassRec; 130 131/*ARGSUSED*/ 132static void XtCopyAncestorSensitive( 133 Widget widget, 134 int offset, 135 XrmValue *value) 136{ 137 static Boolean sensitive; 138 Widget parent = widget->core.parent; 139 140 sensitive = (parent->core.ancestor_sensitive & parent->core.sensitive); 141 value->addr = (XPointer)(&sensitive); 142} 143 144 145/* 146 * Start of rectangle object methods 147 */ 148 149 150static void RectClassPartInitialize( 151 register WidgetClass wc) 152{ 153 register RectObjClass roc = (RectObjClass)wc; 154 register RectObjClass super = ((RectObjClass)roc->rect_class.superclass); 155 156 /* We don't need to check for null super since we'll get to object 157 eventually, and it had better define them! */ 158 159 160 if (roc->rect_class.resize == XtInheritResize) { 161 roc->rect_class.resize = super->rect_class.resize; 162 } 163 164 if (roc->rect_class.expose == XtInheritExpose) { 165 roc->rect_class.expose = super->rect_class.expose; 166 } 167 168 if (roc->rect_class.set_values_almost == XtInheritSetValuesAlmost) { 169 roc->rect_class.set_values_almost = super->rect_class.set_values_almost; 170 } 171 172 173 if (roc->rect_class.query_geometry == XtInheritQueryGeometry) { 174 roc->rect_class.query_geometry = super->rect_class.query_geometry; 175 } 176} 177 178/* 179 * Why there isn't an Initialize Method: 180 * 181 * Initialization of the RectObj non-Resource field is done by the 182 * intrinsics in _XtCreateWidget in order that the field is initialized 183 * for use by converters during instance resource resolution. 184 */ 185 186/*ARGSUSED*/ 187static void RectSetValuesAlmost( 188 Widget old, 189 Widget new, 190 XtWidgetGeometry *request, 191 XtWidgetGeometry *reply) 192{ 193 *request = *reply; 194} 195