1 /** 2 * 3 * $Header: /cvsroot/lesstif/lesstif/include/Motif-2.1/XmI/XmI.h,v 1.4 2006/04/19 18:42:22 dannybackx Exp $ 4 * 5 * Copyright (C) 1995 Free Software Foundation, Inc. 6 * Copyright � 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005 LessTif Development Team 7 * 8 * This file is part of the GNU LessTif Library. 9 * 10 * This library is free software; you can redistribute it and/or 11 * modify it under the terms of the GNU Library General Public 12 * License as published by the Free Software Foundation; either 13 * version 2 of the License, or (at your option) any later version. 14 * 15 * This library is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 18 * Library General Public License for more details. 19 * 20 * You should have received a copy of the GNU Library General Public 21 * License along with this library; if not, write to the Free 22 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 23 * 24 **/ 25 26 /* 27 * LessTif-specific functions/variables. Use at the cost of incompatibility 28 * with Motif. 29 * YOU SHOULD NOT CALL CALL THESE FUNCTIONS IF YOU DON'T KNOW WHAT YOU'RE 30 * DOING!! 31 * Correction: Some of these functions are totally undocumented Motif calls. 32 WE don't know if we got them right, so you'd better not bank on them. 33 */ 34 35 #ifndef _XMI_XMI_H 36 #define _XMI_XMI_H 37 38 #include <Xm/XmP.h> 39 #include <Xm/ScreenP.h> 40 #include <Xm/ManagerP.h> 41 #include <Xm/PrimitiveP.h> 42 #include <Xm/GadgetP.h> 43 #include <Xm/DrawP.h> 44 #include <Xm/RowColumnP.h> 45 #include <Xm/SelectioB.h> 46 #include <Xm/Text.h> 47 #include <XmI/MacrosI.h> 48 49 #ifdef USE_XFT 50 #include <X11/Xft/Xft.h> 51 #endif 52 53 /* 54 * extra resources 55 */ 56 #ifndef XmNdefaultVirtualBindings 57 #define XmNdefaultVirtualBindings "defaultVirtualBindings" 58 #endif 59 60 #define _XA_MOTIF_DEFAULT_BINDINGS "_MOTIF_DEFAULT_BINDINGS" 61 62 /* 63 * STRING AND FONTLIST INTERNALS 64 */ 65 extern XmFontList __XmFontListAlloc(int numberOfEntries); 66 extern void _XmFontListEntryFree(XmFontListEntry entry); 67 XmFontListEntry _XmFontListEntryCreate(void); 68 69 /* Experimental _XmRenderTableFinalise() */ 70 void __XmRenderTableFinalise(Widget, XmFontList, _XmString); 71 void _XmRenderTableFinalise(Widget, XmFontList, XmString); 72 void _XmRenderTableFinaliseTag(Widget, XmFontList, char *); 73 74 XmRenderTable _XmRenderTablePushRendition(XmRenderTable, XmRendition); 75 XmRenderTable _XmRenderTablePopRendition(XmRenderTable, XmRendition); 76 77 typedef struct __XmRenditionRec { 78 char *tag; 79 XmFontType type; 80 XFontSet font; 81 int count; 82 Pixel rendition_background, 83 rendition_foreground; 84 char *font_name; 85 unsigned char load_model, 86 strike_thru_type, 87 underline_type; 88 XmTabList tab_list; 89 Display *dpy; 90 #ifdef USE_XFT 91 /* experimental - use of Xft, see http://fontconfig.org */ 92 char *font_style, 93 /* *family, Use font_name instead. */ 94 *font_foundry, 95 *font_encoding; 96 int font_size, 97 pixel_size, 98 font_slant, 99 font_spacing, 100 font_weight; 101 XftPattern *pattern; 102 XftFont *xft_font; 103 XftColor xft_foreground, xft_background; 104 int font_average_width, /* Calculated by LessTif, */ 105 font_average_height; /* depend only on xft_font */ 106 #endif 107 } *_XmRendition; 108 109 struct __XmRenderTableRec { 110 unsigned int count; 111 Display *dpy; 112 _XmRendition *renditions; /* An array of pointers */ 113 }; 114 115 struct _XmFontListContextRec { 116 XmFontList fontlist; 117 int current_entry; 118 }; 119 120 struct __XmStringExtRec { 121 unsigned char tag; 122 unsigned char len; 123 unsigned char data[1]; 124 }; 125 126 struct __XmStringComponentRec { 127 XmStringComponentType type; 128 int length; 129 char *data; 130 short font; 131 }; 132 typedef struct __XmStringComponentRec _XmStringComponentRec, *_XmStringComponent; 133 134 struct __XmStringRec { 135 struct __XmStringComponentRec **components; 136 int number_of_components; 137 }; 138 139 struct __XmStringContextRec { 140 struct __XmStringRec *string; 141 int current_component; 142 }; 143 144 /* 145 * NOTE: The first two fields in this structure MUST match those 146 * in struct __XmStringContextRec!!! 147 */ 148 struct _XmtStringContextRec { 149 struct __XmStringRec *string; 150 int current_component; 151 char *text; 152 short textlen; 153 char *charset; 154 XmStringDirection direction; 155 Boolean separator; 156 }; 157 158 struct __XmParseMappingRec { 159 XtPointer client_data; 160 XmIncludeStatus include_status; 161 XmParseProc invoke_parse_proc; 162 XtPointer pattern; 163 XmTextType pattern_type; 164 XmString substitute; 165 }; 166 167 /* ADDED FOR EXTERNAL FORM */ 168 #define XmSTRING_COMPONENT_XMSTRING (XmSTRING_COMPONENT_LOCALE_TEXT + 1) 169 #define XmSTRING_TAG 0xDFU 170 #define XmSTRING_LENGTH 0x80U 171 172 /* 173 * XmIm stuff 174 */ 175 typedef unsigned char XmIMInputPolicy; 176 177 #define IP_INHERIT_POLICY 0 178 #define IP_PER_WIDGET 1 179 #define IP_PER_SHELL 2 180 181 void _XmImSendSpot(Widget w); 182 183 /* 184 * GENERIC PROTOTYPES 185 */ 186 XmScreenInfo *_XmGetScreenInfo(Widget w); 187 188 String _XmMakeDialogName(String name); 189 void _XmError(Widget w, const char *message, ...); 190 191 /* 192 * Dimension variables (below) are typed as int because Dimension is 193 * unsigned. However, we need to check whether they become negative, hence 194 * the theoretically incorrect type. 195 * We don't do GetValues on them so we should be ok. 196 */ 197 typedef struct 198 { 199 /* NOTE: The next four lines ABSOLUTELY MUST MATCH the first 200 * three lines in XmMWValues!!!!!!! */ 201 Boolean ShowVSB, ShowHSB, HasHSB, HasVSB; 202 Position HsbX, HsbY, VsbX, VsbY, ClipX, ClipY, WorkX, WorkY; 203 int HsbW, HsbH, VsbW, VsbH, ClipW, ClipH, WorkW, WorkH; 204 int SwY, SwW, SwH; 205 } 206 XmSWValues; 207 208 typedef struct 209 { 210 /* NOTE: The next four lines ABSOLUTELY MUST MATCH the first 211 * three lines in XmSWValues!!!!! */ 212 Boolean ShowVSB, ShowHSB, HasHSB, HasVSB; 213 Position HsbX, HsbY, VsbX, VsbY, ClipX, ClipY, WorkX, WorkY; 214 int HsbW, HsbH, VsbW, VsbH, ClipW, ClipH, WorkW, WorkH; 215 int SwY, MwW, MwH; 216 int mbw, mbh, cww, cwh, mww, mwh, www, wwh; 217 int s1w, s1h, s2w, s2h, s3w, s3h; 218 Position mbx, mby, cwx, cwy, mwx, mwy, wwx, wwy; 219 Position s1x, s1y, s2x, s2y, s3x, s3y; 220 } 221 XmMWValues; 222 223 /* default procs */ 224 void _XmCascadePixmapDefault(Widget w, int offset, XrmValue *val); 225 226 /* Find the VendorShell Extension Object */ 227 Widget _LtFindVendorExt(Widget); 228 229 #ifdef USE_XFT 230 extern void _XmXftSetClipRectangles(Widget w, Position x, Position y, 231 XRectangle *rects, int n); 232 #endif 233 /* 234 * fontlist prototypes 235 */ 236 XmFontList _XmFontListCreateDefault(Display *disp); 237 XmFontListEntry _XmFontListEntryFromTag(XmFontList fontlist, char *tag); 238 239 /* for vendor */ 240 void _XmInitProtocols(Widget w); 241 void _XmDestroyProtocols(Widget w); 242 #ifdef LESSTIF_EDITRES 243 void _XmNSEEditResCheckMessages(Widget w, XtPointer data, 244 XEvent *event, Boolean *cont); 245 #endif 246 247 /* Things for Label/LabelG */ 248 249 void _XmLabelGetPixmapSize(Widget w, Pixmap Pix, 250 Dimension *width, Dimension *height); 251 252 /* For buttons */ 253 #define ACTIVATE_DELAY 100 254 255 /* GeomUtils : A few of these I'm not sure of*/ 256 XtGeometryResult _XmGMReplyToQueryGeometry(Widget w, 257 XtWidgetGeometry *request, 258 XtWidgetGeometry *reply); 259 XtGeometryResult _XmGMHandleQueryGeometry(Widget w, 260 XtWidgetGeometry *proposed, 261 XtWidgetGeometry *answer, 262 Dimension margin_width, 263 Dimension margin_height, 264 unsigned char resize_policy); 265 void _XmGMEnforceMargin(Widget w, 266 Dimension margin_width, 267 Dimension margin_height, 268 Boolean useSetValues); 269 void _XmGMCalcSize(Widget w, 270 Dimension margin_w, Dimension margin_h, 271 Dimension *retw, Dimension *reth); 272 void _XmGMDoLayout(Widget w, 273 Dimension margin_w, Dimension margin_h, 274 unsigned char resize_policy, short adjust); 275 XtGeometryResult _XmGMHandleGeometryManager(Widget w, 276 Widget instigator, 277 XtWidgetGeometry *desired, 278 XtWidgetGeometry *allowed, 279 Dimension margin_width, 280 Dimension margin_height, 281 unsigned char resize_policy, 282 Boolean allow_overlap); 283 Boolean _XmGMOverlap(Widget w, Widget instigator, 284 Position x, Position y, 285 Dimension width, Dimension height); 286 287 /* for DialogS.c */ 288 void _XmBbMap(Widget w); 289 void _XmBbUnmap(Widget w); 290 291 /* for ImageCache */ 292 void _XmSetupImageCache(void); 293 294 /* from MenuUtil.c */ 295 void _XmFakeExpose(Widget menu_shell); 296 Boolean _XmMenuGetInPMMode(Widget w); 297 298 /* used as the operation parameter for _XmMenuFocus. */ 299 enum { 300 XmMENU_FOCUS_SAVE=0, 301 XmMENU_FOCUS_RESTORE, 302 XmMENU_FOCUS_SET 303 }; 304 305 /* from MessageB.c */ 306 void _XmMessageBoxInstallImages(Widget w); 307 308 /* from misc (and for primitives and gadgets) */ 309 void _XmInstallStippleImages(Widget w); 310 311 #define XmEVEN_STIPPLE_IMAGE "xm_even_stipple" 312 #define XmODD_STIPPLE_IMAGE "xm_odd_stipple" 313 314 /* from RCUtils.c */ 315 void _XmRCSetMargins(Widget rc); 316 XtGeometryResult _XmRCAdjustSize(Widget rc, Widget instig, XtWidgetGeometry *instig_request); 317 void _XmRCPreferredSize(Widget rc, XtWidgetGeometry *rcg); 318 319 /* from ResInd */ 320 void _XmExportXmString(Widget w, int offset, XtArgVal *value); 321 void _XmExportString(Widget w, int offset, XtArgVal *value); 322 323 /* from Manager.c */ 324 #ifndef MCEPTR 325 #define MCEPTR(cl) \ 326 ((XmManagerClassExt *)(&(((XmManagerWidgetClass)(cl))->manager_class.extension))) 327 #endif 328 #ifndef _XmGetManagerClassExtPtr 329 #define _XmGetManagerClassExtPtr(cl, o) \ 330 ((*MCEPTR(cl) && (((*MCEPTR(cl))->record_type) == (o))) \ 331 ? MCEPTR(cl) \ 332 : ((XmManagerClassExt *)_XmGetClassExtensionPtr(((XmGenericClassExt *)MCEPTR(cl)), (o)))) 333 #endif 334 335 void _XmManagerInstallAccelerator(Widget m, Widget w, String s); 336 void _XmManagerInstallMnemonic(Widget m, Widget w, KeySym mn); 337 void _XmManagerUninstallAccelerator(Widget m, Widget w); 338 void _XmManagerUninstallMnemonic(Widget m, Widget w); 339 340 341 /* for MapEvent.c */ 342 int _XmMapKeyEvents(String str, int **eventType, KeySym **keysym, Modifiers **modifiers); 343 344 /* for ScrolledW */ 345 /* T. Straumann: */ 346 void _XmScrolledWPreferredSize(Widget w, Widget instigator, 347 XtWidgetGeometry *instigator_geom, XmSWValues * vals); 348 void _XmScrolledWLayout(Widget w, Widget instigator, 349 XtWidgetGeometry *instigator_geom, XmSWValues * vals); 350 void _XmScrolledWConfigureChildren(Widget w, Widget instigator, 351 XtWidgetGeometry *instigator_geom, XmSWValues * vals); 352 353 /* from SelectionBox.c */ 354 Boolean _XmSelectionBoxMatch(XmSelectionBoxWidget w); 355 356 357 /* for TearOff */ 358 void _XmPushButtonSetTranslation(Widget, int); 359 360 /* Text */ 361 void _XmChangeVSB(XmTextWidget w, XmTextPosition pos); 362 void _XmRedisplayHBar(XmTextWidget w, int offset); 363 int _XmFontCalculateAverageCharacterWidth(Widget w, XFontStruct *fs); 364 365 void _XmCursorOverstrike(Widget w); /* formerly: CursorOverstrike */ 366 367 /* Traversal */ 368 void _XmSetFocusResetFlag(Widget w, Boolean value); 369 Boolean _XmGetFocusResetFlag(Widget w); 370 Widget _XmGetActiveTabGroup(Widget widget); 371 Widget _XmFindTopMostShell(Widget widget); 372 373 /* VirtKeys */ 374 /* 375 * This is for handling of ALT, META, and other modifier keys when parsing 376 * the virtual binding(s). In contrast to the closed software foundation, 377 * LessTif is able to configure the current setting of modifiers and to 378 * adjust itself to the right modifier masks. 379 * USING THIS STUFF WILL MAKE YOUR APPLICATION MORE USEFUL BUT WILL BREAK 380 * THE COMPATIBILITY. THIS IS PRIMARILY FOR INTERNAL USE. 381 */ 382 typedef enum _XmModifierLevels { 383 ALTModifier = 0, 384 METAModifier, 385 SUPERModifier, 386 HYPERModifier, 387 /* This one must be the last! */ MAX_MODIFIERS 388 } XmModifierLevels; 389 390 typedef Modifiers XmModifierMaskSet[MAX_MODIFIERS]; 391 typedef Modifiers *XmModifierMaskSetReference; 392 393 XmModifierMaskSetReference _XmGetModifierMappingsForDisplay(Display *Dsp); 394 void _XmInvalidateModifierMappingsForDisplay(Display *Dsp); 395 void _XmRefreshVirtKeys(Widget w); 396 397 /* Visual */ 398 399 void _XmAddBackgroundToColorCache(Screen *screen, Colormap color_map, 400 String background_spec, 401 int rgb_fallback, XrmValue *val); 402 void _XmInvalidateColorCache(Boolean default_only); 403 void _XmPickupUnspecifiedPixmaps(Display *dpy); 404 405 /* XmString */ 406 407 void _XmStringBaselines(XmFontList fontlist, _XmString string, 408 Position y, Dimension *baselines); 409 void _XmStringUpdate(XmFontList fontlist, _XmString string); 410 /* 411 * Behaviour control for XmFormLayout, XmRowColumnLayout. 412 * This is their second parameter. 413 */ 414 #define Mode_Normal 0x00 415 #define Mode_Test 0x01 416 #define Mode_Resize 0x02 417 418 /* 419 * Extra color tools. 420 */ 421 Pixel _XmWhitePixelOfObject(Widget); 422 Pixel _XmBlackPixelOfObject(Widget); 423 424 /* 425 * Thread stuff (lib/Xm/misc.c). 426 */ 427 void _XmAppLock(XtAppContext appc); 428 void _XmAppUnlock(XtAppContext appc); 429 void _XmProcessLock(void); 430 void _XmProcessUnlock(void); 431 void _XmObjectLock(Widget w); 432 void _XmObjectUnlock(Widget w); 433 434 435 /* 436 * from LTCvt.c 437 */ 438 #ifdef NONSTANDARD_CONVERTERS 439 void _XmRegisterNSEConverters(void); 440 #endif 441 442 /* 443 * from Shadow.c 444 */ 445 /* old backward compatibility stuff */ 446 void _XmDrawSquareButton(Widget w, int x, int y, int size, 447 GC top_gc, GC bottom_gc, GC select_gc, Boolean fill); 448 void _XmDrawDiamondButton(Widget w, int x, int y, int size, 449 GC top_gc, GC bottom_gc, GC select_gc, Boolean fill); 450 451 void _XmDrawPolygonShadow(Display *display, Drawable drawable, 452 GC top_gc, GC bottom_gc, XPoint *points, int point_count, 453 Dimension shadow_thickness, unsigned char shadow_type); 454 455 456 /* 457 * From Xmos.c: private, but exported stuff from Motif 1.2 458 * which is used within LessTif, also for the 2.x libs 459 */ 460 XmString 461 _XmOSGetLocalizedString(char *reserved, Widget w, String resourceName, String value); 462 int _XmMicroSleep(long secs); 463 String _XmOSGetHomeDirName(void); 464 String _XmOSInitPath(String file_name, String env_pathname, Boolean *user_path); 465 void _XmSleep(unsigned int secs); 466 String _XmOSGetHomeDirName(void); 467 int _XmOSFileCompare(XmConst void *sp1, XmConst void *sp2); 468 void _XmOSQualifyFileSpec(String dirSpec, String filterSpec, 469 String *pQualifiedDir, String *pQualifiedPattern); 470 String _XmOSFindPatternPart(String fileSpec); 471 void _XmOSGetDirEntries(String qualifiedDir, String matchPattern, 472 unsigned char fileType, Boolean matchDotsLiterally, 473 Boolean listWithFullPath, String **pEntries, 474 unsigned int *pNumEntries, unsigned int *pNumAlloc); 475 void _XmOSBuildFileList(String dirPath, String pattern, 476 unsigned char typeMask, String **pEntries, 477 unsigned int *pNumEntries, unsigned int *pNumAlloc); 478 479 480 /* The following are definitions for 2.x stuff, work in progress. 481 Since are not public they can be changed at any time ... ?!? */ 482 struct _XmTabRec { 483 float value; 484 unsigned char units; 485 XmOffsetModel offset_model; 486 unsigned char alignment; 487 char *decimal; 488 }; 489 490 struct _XmTabListRec { 491 struct _XmTabRec **tabs; 492 int count; 493 }; 494 495 /* defined in Trait.c, but used outside; not a symbol from OSF/Motif */ 496 void _XmInitTraits(void); 497 498 #ifdef USE_XFT 499 /* 500 * XftDraw cache functions, implemented in lib/Xm/FontList.c 501 */ 502 XftDraw * _XmXftDrawCreate(Display *dpy, Window w); 503 void _XmXftDrawDestroy(Display *dpy, Window w, XftDraw *d); 504 void _XmXftDrawString(Display *dpy, Window wd, XmRendition r, int bpc, Position x, Position y, char *s, int len); 505 void _XmXftFontAverageWidth(Widget w, XtPointer f, int *wid, int *ht); 506 #endif 507 508 /* from Vendor.c */ 509 extern Boolean _LtCheckClassOfVendorShell(Widget w); 510 511 /* 512 * Some general purpose macros follow: 513 */ 514 #define _XmMin(a,b) (((a)<(b))?(a):(b)) 515 #define _XmMax(a,b) (((a)>(b))?(a):(b)) 516 517 518 #endif /* _XMI_XMI_H */ 519