1 /* 2 * Motif 3 * 4 * Copyright (c) 1987-2012, The Open Group. All rights reserved. 5 * 6 * These libraries and programs are free software; you can 7 * redistribute them and/or modify them under the terms of the GNU 8 * Lesser General Public License as published by the Free Software 9 * Foundation; either version 2 of the License, or (at your option) 10 * any later version. 11 * 12 * These libraries and programs are distributed in the hope that 13 * they will be useful, but WITHOUT ANY WARRANTY; without even the 14 * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 15 * PURPOSE. See the GNU Lesser General Public License for more 16 * details. 17 * 18 * You should have received a copy of the GNU Lesser General Public 19 * License along with these librararies and programs; if not, write 20 * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth 21 * Floor, Boston, MA 02110-1301 USA 22 */ 23 #ifndef _XmI_h 24 #define _XmI_h 25 26 #ifndef _XmNO_BC_INCL 27 #define _XmNO_BC_INCL 28 #endif 29 30 #include <stdio.h> 31 #include <limits.h> 32 #include <Xm/XmP.h> 33 #include "XmStrDefsI.h" 34 35 #ifdef __cplusplus 36 extern "C" { 37 #endif 38 39 #define FIX_345 40 41 #ifdef FIX_345 42 extern Boolean _init_modifiers; 43 extern unsigned int NumLockMask; 44 extern unsigned int ScrollLockMask; 45 46 void _XmInitModifiers (void); 47 #define _XmCheckInitModifiers() \ 48 { \ 49 if (_init_modifiers) \ 50 { \ 51 _XmInitModifiers(); \ 52 _init_modifiers = FALSE; \ 53 } \ 54 } 55 #endif 56 57 #ifndef DEBUG 58 # define assert(assert_exp) 59 #elif (defined(__STDC__) && !defined(UNIXCPP)) || defined(ANSICPP) 60 # define assert(assert_exp) \ 61 (((assert_exp) ? (void) 0 : \ 62 (void) (fprintf(stderr, "assert(%s) failed at line %d in %s\n", \ 63 #assert_exp, __LINE__, __FILE__), abort()))) 64 #else 65 # define assert(assert_exp) \ 66 (((assert_exp) ? 0 : \ 67 (void) (fprintf(stderr, "assert(%s) failed at line %d in %s\n", \ 68 "assert_exp", __LINE__, __FILE__), abort()))) 69 #endif 70 71 72 #define ASSIGN_MAX(a, b) ((a) = ((a) > (b) ? (a) : (b))) 73 #define ASSIGN_MIN(a, b) ((a) = ((a) < (b) ? (a) : (b))) 74 75 #ifndef MAX 76 #define MAX(x,y) ((x) > (y) ? (x) : (y)) 77 #endif 78 79 #ifndef MIN 80 #define MIN(x,y) ((x) > (y) ? (y) : (x)) 81 #endif 82 83 #ifndef ABS 84 #define ABS(x) (((x) >= 0) ? (x) : -(x)) 85 #endif 86 87 #define GMode(g) ((g)->request_mode) 88 #define IsX(g) (GMode (g) & CWX) 89 #define IsY(g) (GMode (g) & CWY) 90 #define IsWidth(g) (GMode (g) & CWWidth) 91 #define IsHeight(g) (GMode (g) & CWHeight) 92 #define IsBorder(g) (GMode (g) & CWBorderWidth) 93 #define IsWidthHeight(g) (GMode (g) & (CWWidth | CWHeight)) 94 #define IsQueryOnly(g) (GMode (g) & XtCWQueryOnly) 95 96 #define XmStrlen(s) ((s) ? strlen(s) : 0) 97 98 99 #define XmStackAlloc(size, stack_cache_array) \ 100 ((((char*)(stack_cache_array) != NULL) && \ 101 ((size) <= sizeof(stack_cache_array))) \ 102 ? (char *)(stack_cache_array) \ 103 : XtMalloc((unsigned)(size))) 104 105 #define XmStackFree(pointer, stack_cache_array) \ 106 if ((pointer) != ((char*)(stack_cache_array))) XtFree(pointer); 107 108 109 /******** _XmCreateImage ********/ 110 111 #ifdef NO_XM_1_2_BC 112 113 /* The _XmCreateImage macro is used to create XImage with client 114 specific data for the bit and byte order. 115 We still have to do the following because XCreateImage 116 will stuff here display specific data and we want 117 client specific values (i.e the bit orders we used for 118 creating the bitmap data in Motif) -- BUG 4262 */ 119 /* Used in Motif 1.2 in DragIcon.c, MessageB.c, ReadImage.c and 120 ImageCache.c */ 121 122 #define _XmCreateImage(IMAGE, DISPLAY, DATA, WIDTH, HEIGHT, BYTE_ORDER) {\ 123 IMAGE = XCreateImage(DISPLAY,\ 124 DefaultVisual(DISPLAY, DefaultScreen(DISPLAY)),\ 125 1,\ 126 XYBitmap,\ 127 0,\ 128 DATA,\ 129 WIDTH, HEIGHT,\ 130 8,\ 131 (WIDTH+7) >> 3);\ 132 IMAGE->byte_order = BYTE_ORDER;\ 133 IMAGE->bitmap_unit = 8;\ 134 IMAGE->bitmap_bit_order = LSBFirst;\ 135 } 136 137 #endif /* NO_XM_1_2_BC */ 138 139 140 /**************************************************************** 141 * 142 * Macros for Right-to-left Layout 143 * 144 ****************************************************************/ 145 146 #define GetLayout(w) (_XmGetLayoutDirection((Widget)(w))) 147 #define LayoutM(w) (XmIsManager(w) ? \ 148 ((XmManagerWidget)w)->manager.string_direction : \ 149 GetLayout(w)) 150 #define LayoutP(w) (XmIsPrimitive(w) ? \ 151 XmPrim_layout_direction(((XmPrimitiveWidget)w)) :\ 152 GetLayout(w)) 153 #define LayoutG(w) (XmIsGadget(w) ? \ 154 ((XmGadget)w)->gadget.layout_direction : \ 155 GetLayout(w)) 156 157 #define LayoutIsRtoL(w) \ 158 (XmDirectionMatchPartial(GetLayout(w), XmRIGHT_TO_LEFT, XmHORIZONTAL_MASK)) 159 #define LayoutIsRtoLM(w) \ 160 (XmDirectionMatchPartial(LayoutM(w), XmRIGHT_TO_LEFT, XmHORIZONTAL_MASK)) 161 #define LayoutIsRtoLP(w) \ 162 (XmDirectionMatchPartial(LayoutP(w), XmRIGHT_TO_LEFT, XmHORIZONTAL_MASK)) 163 #define LayoutIsRtoLG(w) \ 164 (XmDirectionMatchPartial(LayoutG(w), XmRIGHT_TO_LEFT, XmHORIZONTAL_MASK)) 165 166 167 /******** Private Function Declarations for Direction.c ********/ 168 169 extern void _XmDirectionDefault(Widget widget, 170 int offset, 171 XrmValue *value ); 172 extern void _XmFromLayoutDirection( 173 Widget widget, 174 int offset, 175 XtArgVal *value) ; 176 177 extern XmImportOperator _XmToLayoutDirection( 178 Widget widget, 179 int offset, 180 XtArgVal *value) ; 181 extern XmDirection _XmGetLayoutDirection(Widget w); 182 183 184 /******** Private Function Declarations for thickness ********/ 185 extern void _XmSetThickness( 186 Widget widget, 187 int offset, 188 XrmValue *value) ; 189 extern void _XmSetThicknessDefault0( 190 Widget widget, 191 int offset, 192 XrmValue *value) ; 193 194 /******** Private Function Declarations for Xm.c ********/ 195 196 extern void _XmReOrderResourceList( 197 WidgetClass widget_class, 198 String res_name, 199 String insert_after) ; 200 extern void _XmSocorro( 201 Widget w, 202 XEvent *event, 203 String *params, 204 Cardinal *num_params) ; 205 extern Boolean _XmParentProcess( 206 Widget widget, 207 XmParentProcessData data) ; 208 extern void _XmClearShadowType( 209 Widget w, 210 #if NeedWidePrototypes 211 int old_width, 212 int old_height, 213 int old_shadow_thickness, 214 int old_highlight_thickness) ; 215 #else 216 Dimension old_width, 217 Dimension old_height, 218 Dimension old_shadow_thickness, 219 Dimension old_highlight_thickness) ; 220 #endif /* NeedWidePrototypes */ 221 #ifdef NO_XM_1_2_BC 222 extern void _XmDestroyParentCallback( 223 Widget w, 224 XtPointer client_data, 225 XtPointer call_data) ; 226 #endif 227 extern Time _XmValidTimestamp( 228 Widget w); 229 extern void _XmWarningMsg(Widget w, 230 char *type, 231 char *message, 232 char **params, 233 Cardinal num_params); 234 extern Display *_XmGetDefaultDisplay(void); 235 extern Boolean _XmIsISO10646(Display *dpy, 236 XFontStruct *font); 237 extern XChar2b* _XmUtf8ToUcs2(char *draw_text, 238 size_t seg_len, 239 size_t *ret_str_len); 240 241 /******** End Private Function Declarations ********/ 242 243 /******** Conditionally defined macros for thread_safe Motif ******/ 244 #if defined(XTHREADS) && defined(XUSE_MTSAFE_API) 245 246 # define _XmWidgetToAppContext(w) \ 247 XtAppContext app = XtWidgetToApplicationContext(w) 248 249 # define _XmDisplayToAppContext(d) \ 250 XtAppContext app = XtDisplayToApplicationContext(d) 251 252 # define _XmAppLock(app) XtAppLock(app) 253 # define _XmAppUnlock(app) XtAppUnlock(app) 254 # define _XmProcessLock() XtProcessLock() 255 # define _XmProcessUnlock() XtProcessUnlock() 256 257 /* Remove use of _XtProcessLock when Xt provides API to query its MT-status */ 258 extern void (*_XtProcessLock)(); 259 # define _XmIsThreadInitialized() (_XtProcessLock) 260 261 #else 262 263 # define _XmWidgetToAppContext(w) 264 # define _XmDisplayToAppContext(d) 265 # define _XmAppLock(app) 266 # define _XmAppUnlock(app) 267 # define _XmProcessLock() 268 # define _XmProcessUnlock() 269 # define _XmIsThreadInitialized() (FALSE) 270 271 #endif /* XTHREADS && XUSE_MTSAFE_API */ 272 273 274 #ifdef __cplusplus 275 } /* Close scope of 'extern "C"' declaration which encloses file. */ 276 #endif 277 278 #define FIX_1396 279 280 #ifdef FIX_1381 281 extern Pixel _XmAssignInsensitiveColor(Widget w); 282 #endif 283 284 #define FIX_1375 285 #define FIX_1395 286 #define FIX_1388 287 #define FIX_1398 288 #define FIX_1402 289 #define FIX_1445 290 #define FIX_1474 291 #define FIX_1501 292 #define FIX_1521 293 #define FIX_1505 294 295 #endif /* _XmI_h */ 296 /* DON'T ADD ANYTHING AFTER THIS #endif */ 297