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 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848
|
(*
Copyright (c) 2000
Cambridge University Technical Services Limited
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*)
(* Note that this module depends on the compiler's *representation* of
exceptions; this is absolutely disgusting, completely unnecessary, and
a source of inefficiency (all those Casts!). When I have some spare time,
I'm going to cure this. SPF 6/12/94 *)
structure MotifCore =
struct
local
open XWindows;
open XCall;
open MotifTypes;
open XmTypes;
fun fromAlignment XmALIGNMENT_BEGINNING = 0
| fromAlignment XmALIGNMENT_CENTER = 1
| fromAlignment XmALIGNMENT_END = 2;
fun toAlignment 0 = XmALIGNMENT_BEGINNING
| toAlignment 1 = XmALIGNMENT_CENTER
| toAlignment _ = XmALIGNMENT_END;
fun fromArrowDirection XmARROW_UP = 0
| fromArrowDirection XmARROW_DOWN = 1
| fromArrowDirection XmARROW_LEFT = 2
| fromArrowDirection XmARROW_RIGHT = 3;
fun toArrowDirection 0 = XmARROW_UP
| toArrowDirection 1 = XmARROW_DOWN
| toArrowDirection 2 = XmARROW_LEFT
| toArrowDirection _ = XmARROW_RIGHT;
fun fromAttachment XmATTACH_NONE = 0
| fromAttachment XmATTACH_FORM = 1
| fromAttachment XmATTACH_OPPOSITE_FORM = 2
| fromAttachment XmATTACH_WIDGET = 3
| fromAttachment XmATTACH_OPPOSITE_WIDGET = 4
| fromAttachment XmATTACH_POSITION = 5
| fromAttachment XmATTACH_SELF = 6;
fun toAttachment 0 = XmATTACH_NONE
| toAttachment 1 = XmATTACH_FORM
| toAttachment 2 = XmATTACH_OPPOSITE_FORM
| toAttachment 3 = XmATTACH_WIDGET
| toAttachment 4 = XmATTACH_OPPOSITE_WIDGET
| toAttachment 5 = XmATTACH_POSITION
| toAttachment _ = XmATTACH_SELF;
fun fromButtonType XmPUSHBUTTON = 1
| fromButtonType XmCHECKBUTTON = 2
| fromButtonType XmTOGGLEBUTTON = 2 (* same as XmCHECKBUTTON *)
| fromButtonType XmRADIOBUTTON = 3
| fromButtonType XmCASCADEBUTTON = 4
| fromButtonType XmSEPARATOR = 5
| fromButtonType XmDOUBLE_SEPARATOR = 6
| fromButtonType XmTITLE = 7;
fun toButtonType 1 = XmPUSHBUTTON
| toButtonType 2 = XmCHECKBUTTON
| toButtonType 3 = XmRADIOBUTTON
| toButtonType 4 = XmCASCADEBUTTON
| toButtonType 5 = XmSEPARATOR
| toButtonType 6 = XmDOUBLE_SEPARATOR
| toButtonType _ = XmTITLE;
fun fromCommandWindowLocation XmCOMMAND_ABOVE_WORKSPACE = 0
| fromCommandWindowLocation XmCOMMAND_BELOW_WORKSPACE = 1;
fun toCommandWindowLocation 0 = XmCOMMAND_ABOVE_WORKSPACE
| toCommandWindowLocation _ = XmCOMMAND_BELOW_WORKSPACE;
fun fromDefaultButtonType XmDIALOG_NONE = 0
| fromDefaultButtonType XmDIALOG_APPLY_BUTTON = 1
| fromDefaultButtonType XmDIALOG_CANCEL_BUTTON = 2
| fromDefaultButtonType XmDIALOG_DEFAULT_BUTTON = 3
| fromDefaultButtonType XmDIALOG_OK_BUTTON = 4
| fromDefaultButtonType XmDIALOG_FILTER_LABEL = 5
| fromDefaultButtonType XmDIALOG_FILTER_TEXT = 6
| fromDefaultButtonType XmDIALOG_HELP_BUTTON = 7
| fromDefaultButtonType XmDIALOG_LIST = 8
| fromDefaultButtonType XmDIALOG_LIST_LABEL = 9
| fromDefaultButtonType XmDIALOG_MESSAGE_LABEL = 10
| fromDefaultButtonType XmDIALOG_SELECTION_LABEL = 11
| fromDefaultButtonType XmDIALOG_SYMBOL_LABEL = 12
| fromDefaultButtonType XmDIALOG_TEXT = 13
| fromDefaultButtonType XmDIALOG_SEPARATOR = 14
| fromDefaultButtonType XmDIALOG_DIR_LIST = 15
| fromDefaultButtonType XmDIALOG_DIR_LIST_LABEL = 16;
fun toDefaultButtonType 0 = XmDIALOG_NONE
| toDefaultButtonType 1 = XmDIALOG_APPLY_BUTTON
| toDefaultButtonType 2 = XmDIALOG_CANCEL_BUTTON
| toDefaultButtonType 3 = XmDIALOG_DEFAULT_BUTTON
| toDefaultButtonType 4 = XmDIALOG_OK_BUTTON
| toDefaultButtonType 5 = XmDIALOG_FILTER_LABEL
| toDefaultButtonType 6 = XmDIALOG_FILTER_TEXT
| toDefaultButtonType 7 = XmDIALOG_HELP_BUTTON
| toDefaultButtonType 8 = XmDIALOG_LIST
| toDefaultButtonType 9 = XmDIALOG_LIST_LABEL
| toDefaultButtonType 10 = XmDIALOG_MESSAGE_LABEL
| toDefaultButtonType 11 = XmDIALOG_SELECTION_LABEL
| toDefaultButtonType 12 = XmDIALOG_SYMBOL_LABEL
| toDefaultButtonType 13 = XmDIALOG_TEXT
| toDefaultButtonType 14 = XmDIALOG_SEPARATOR
| toDefaultButtonType 15 = XmDIALOG_DIR_LIST
| toDefaultButtonType _ = XmDIALOG_DIR_LIST_LABEL;
fun fromDeleteResponse XmDESTROY = 0
| fromDeleteResponse XmUNMAP = 1
| fromDeleteResponse XmDO_NOTHING = 2;
fun toDeleteResponse 0 = XmDESTROY
| toDeleteResponse 1 = XmUNMAP
| toDeleteResponse _ = XmDO_NOTHING;
fun fromDialogStyle XmDIALOG_MODELESS = 0
| fromDialogStyle XmDIALOG_PRIMARY_APPLICATION_MODAL = 1
| fromDialogStyle XmDIALOG_FULL_APPLICATION_MODAL = 2
| fromDialogStyle XmDIALOG_SYSTEM_MODAL = 3;
fun toDialogStyle 0 = XmDIALOG_MODELESS
| toDialogStyle 1 = XmDIALOG_PRIMARY_APPLICATION_MODAL
| toDialogStyle 2 = XmDIALOG_FULL_APPLICATION_MODAL
| toDialogStyle _ = XmDIALOG_SYSTEM_MODAL;
fun fromDialogType XmDIALOG_ERROR = 1 (* XmMessageBox values *)
| fromDialogType XmDIALOG_INFORMATION = 2
| fromDialogType XmDIALOG_MESSAGE = 3
| fromDialogType XmDIALOG_QUESTION = 4
| fromDialogType XmDIALOG_WARNING = 5
| fromDialogType XmDIALOG_WORKING = 6
| fromDialogType XmDIALOG_WORK_AREA = 0 (* XmSelectionBox values *)
| fromDialogType XmDIALOG_PROMPT = 1
| fromDialogType XmDIALOG_SELECTION = 2
| fromDialogType XmDIALOG_COMMAND = 3
| fromDialogType XmDIALOG_FILE_SELECTION = 4;
fun toDialogType 0 = XmDIALOG_WORK_AREA
| toDialogType 1 = XmDIALOG_ERROR
| toDialogType 2 = XmDIALOG_INFORMATION
| toDialogType 3 = XmDIALOG_MESSAGE
| toDialogType 4 = XmDIALOG_QUESTION
| toDialogType 5 = XmDIALOG_WARNING
| toDialogType _ = XmDIALOG_WORKING;
fun fromEditMode XmMULTI_LINE_EDIT = 0
| fromEditMode XmSINGLE_LINE_EDIT = 1;
fun toEditMode 0 = XmMULTI_LINE_EDIT
| toEditMode _ = XmSINGLE_LINE_EDIT;
fun fromFileTypeMask XmFILE_REGULAR = 1
| fromFileTypeMask XmFILE_DIRECTORY = 2
| fromFileTypeMask XmFILE_ANY_TYPE = 3;
fun toFileTypeMask 1 = XmFILE_REGULAR
| toFileTypeMask 2 = XmFILE_DIRECTORY
| toFileTypeMask _ = XmFILE_ANY_TYPE;
fun fromIndicatorType XmN_OF_MANY = 1
| fromIndicatorType XmONE_OF_MANY = 2;
fun toIndicatorType 1 = XmN_OF_MANY
| toIndicatorType _ = XmONE_OF_MANY;
fun fromKeyboardFocusPolicy XmEXPLICIT = 0
| fromKeyboardFocusPolicy XmPOINTER = 1;
fun toKeyboardFocusPolicy 0 = XmEXPLICIT
| toKeyboardFocusPolicy _ = XmPOINTER;
fun fromLabelType XmPIXMAP = 1
| fromLabelType XmSTRING = 2;
fun toLabelType 1 = XmPIXMAP
| toLabelType _ = XmSTRING;
fun fromMultiClick XmMULTICLICK_DISCARD = 0
| fromMultiClick XmMULTICLICK_KEEP = 1;
fun toMultiClick 0 = XmMULTICLICK_DISCARD
| toMultiClick _ = XmMULTICLICK_KEEP;
fun fromNavigationType XmNONE = 0
| fromNavigationType XmTAB_GROUP = 1
| fromNavigationType XmSTICKY_TAB_GROUP = 2
| fromNavigationType XmEXCLUSIVE_TAB_GROUP = 3;
fun toNavigationType 0 = XmNONE
| toNavigationType 1 = XmTAB_GROUP
| toNavigationType 2 = XmSTICKY_TAB_GROUP
| toNavigationType _ = XmEXCLUSIVE_TAB_GROUP;
fun fromOrientation XmVERTICAL = 1
| fromOrientation XmHORIZONTAL = 2;
fun toOrientation 1 = XmVERTICAL
| toOrientation _ = XmHORIZONTAL;
fun fromResizePolicy XmRESIZE_NONE = 0
| fromResizePolicy XmRESIZE_GROW = 1
| fromResizePolicy XmRESIZE_ANY = 2;
fun toResizePolicy 0 = XmRESIZE_NONE
| toResizePolicy 1 = XmRESIZE_GROW
| toResizePolicy _ = XmRESIZE_ANY;
fun fromRowColumnType XmWORK_AREA = 0
| fromRowColumnType XmMENU_BAR = 1
| fromRowColumnType XmMENU_PULLDOWN = 2
| fromRowColumnType XmMENU_POPUP = 3
| fromRowColumnType XmMENU_OPTION = 4;
fun toRowColumnType 0 = XmWORK_AREA
| toRowColumnType 1 = XmMENU_BAR
| toRowColumnType 2 = XmMENU_PULLDOWN
| toRowColumnType 3 = XmMENU_POPUP
| toRowColumnType _ = XmMENU_OPTION;
fun fromPacking XmPACK_TIGHT = 1
| fromPacking XmPACK_COLUMN = 2
| fromPacking XmPACK_NONE = 3;
fun toPacking 1 = XmPACK_TIGHT
| toPacking 2 = XmPACK_COLUMN
| toPacking _ = XmPACK_NONE;
fun fromProcessingDirection XmMAX_ON_TOP = 0
| fromProcessingDirection XmMAX_ON_BOTTOM = 1
| fromProcessingDirection XmMAX_ON_LEFT = 2
| fromProcessingDirection XmMAX_ON_RIGHT = 3;
fun toProcessingDirection 0 = XmMAX_ON_TOP
| toProcessingDirection 1 = XmMAX_ON_BOTTOM
| toProcessingDirection 2 = XmMAX_ON_LEFT
| toProcessingDirection _ = XmMAX_ON_RIGHT;
fun fromScrollBarDisplayPolicy XmSTATIC = 0
| fromScrollBarDisplayPolicy XmAS_NEEDED = 1;
fun toScrollBarDisplayPolicy 0 = XmSTATIC
| toScrollBarDisplayPolicy _ = XmAS_NEEDED;
fun fromScrollBarPlacement XmBOTTOM_RIGHT = 0
| fromScrollBarPlacement XmTOP_RIGHT = 1
| fromScrollBarPlacement XmBOTTOM_LEFT = 2
| fromScrollBarPlacement XmTOP_LEFT = 3;
fun toScrollBarPlacement 0 = XmBOTTOM_RIGHT
| toScrollBarPlacement 1 = XmTOP_RIGHT
| toScrollBarPlacement 2 = XmBOTTOM_LEFT
| toScrollBarPlacement _ = XmTOP_LEFT;
fun fromScrollingPolicy XmAUTOMATIC = 0
| fromScrollingPolicy XmAPPLICATION_DEFINED = 1;
fun toScrollingPolicy 0 = XmAUTOMATIC
| toScrollingPolicy _ = XmAPPLICATION_DEFINED;
fun fromSelectionPolicy XmSINGLE_SELECT = 0
| fromSelectionPolicy XmMULTIPLE_SELECT = 1
| fromSelectionPolicy XmEXTENDED_SELECT = 2
| fromSelectionPolicy XmBROWSE_SELECT = 3;
fun toSelectionPolicy 0 = XmSINGLE_SELECT
| toSelectionPolicy 1 = XmMULTIPLE_SELECT
| toSelectionPolicy 2 = XmEXTENDED_SELECT
| toSelectionPolicy _ = XmBROWSE_SELECT;
fun fromShadowType XmNO_LINE = 0
| fromShadowType XmSINGLE_LINE = 1
| fromShadowType XmDOUBLE_LINE = 2
| fromShadowType XmSINGLE_DASHED_LINE = 3
| fromShadowType XmDOUBLE_DASHED_LINE = 4
| fromShadowType XmSHADOW_ETCHED_IN = 5
| fromShadowType XmSHADOW_ETCHED_OUT = 6
| fromShadowType XmSHADOW_IN = 7
| fromShadowType XmSHADOW_OUT = 8;
fun toShadowType 0 = XmNO_LINE
| toShadowType 1 = XmSINGLE_LINE
| toShadowType 2 = XmDOUBLE_LINE
| toShadowType 3 = XmSINGLE_DASHED_LINE
| toShadowType 4 = XmDOUBLE_DASHED_LINE
| toShadowType 5 = XmSHADOW_ETCHED_IN
| toShadowType 6 = XmSHADOW_ETCHED_OUT
| toShadowType 7 = XmSHADOW_IN
| toShadowType _ = XmSHADOW_OUT;
fun fromStringDirection XmSTRING_DIRECTION_L_TO_R = 0
| fromStringDirection XmSTRING_DIRECTION_R_TO_L = 1
| fromStringDirection XmSTRING_DIRECTION_DEFAULT = 255;
fun toStringDirection 0 = XmSTRING_DIRECTION_L_TO_R
| toStringDirection 1 = XmSTRING_DIRECTION_R_TO_L
| toStringDirection _ = XmSTRING_DIRECTION_DEFAULT;
fun fromTextScanType XmSELECT_POSITION = 0
| fromTextScanType XmSELECT_WHITESPACE = 1
| fromTextScanType XmSELECT_WORD = 2
| fromTextScanType XmSELECT_LINE = 3
| fromTextScanType XmSELECT_ALL = 4
| fromTextScanType XmSELECT_PARAGRAPH = 5;
fun toTextScanType 0 = XmSELECT_POSITION
| toTextScanType 1 = XmSELECT_WHITESPACE
| toTextScanType 2 = XmSELECT_WORD
| toTextScanType 3 = XmSELECT_LINE
| toTextScanType 4 = XmSELECT_ALL
| toTextScanType _ = XmSELECT_PARAGRAPH;
fun fromUnitType XmPIXELS = 0
| fromUnitType Xm100TH_MILLIMETERS = 1
| fromUnitType Xm1000TH_INCHES = 2
| fromUnitType Xm100TH_POINTS = 3
| fromUnitType Xm100TH_FONT_UNITS = 4;
fun toUnitType 0 = XmPIXELS
| toUnitType 1 = Xm100TH_MILLIMETERS
| toUnitType 2 = Xm1000TH_INCHES
| toUnitType 3 = Xm100TH_POINTS
| toUnitType _ = Xm100TH_FONT_UNITS;
fun fromVisualPolicy XmVARIABLE = 0
| fromVisualPolicy XmCONSTANT = 1
| fromVisualPolicy XmRESIZE_IF_POSSIBLE = 2;
fun toVisualPolicy 0 = XmVARIABLE
| toVisualPolicy 1 = XmCONSTANT
| toVisualPolicy _ = XmRESIZE_IF_POSSIBLE;
fun fromXWMStateHint DontCareState = 0
| fromXWMStateHint NormalState = 1
| fromXWMStateHint ZoomState = 2
| fromXWMStateHint IconicState = 3
| fromXWMStateHint InactiveState = 4;
fun toXWMStateHint 0 = DontCareState
| toXWMStateHint 1 = NormalState
| toXWMStateHint 2 = ZoomState
| toXWMStateHint 3 = IconicState
| toXWMStateHint _ = InactiveState;
(* When this datatype changes the runtime system must change as well. *)
(* I've removed this and replaced it simply by a tuple but making the tuple
represent the values in the same way. That makes the interface independent
of the way datatypes are represented. Note: the old representation of
datatypes put the tag in the second word. DCJM 27/3/01. *)
(*
datatype CType =
CAccelerators of XtAccelerators
| CBool of bool (* typedef char Boolean *)
| CColormap of Colormap
| CCursor of Cursor
| CDimension of int (* typedef unsigned short Dimension *)
| CFontList of (XFontStruct * string) list
| CInt of int
| CIntTable of int list
| CKeySym of int (* typedef unsigned int KeySym *)
| CPixmap of Drawable
| CPosition of int (* typedef short Position *)
| CString of string
| CStringTable of string list
| CTrans of XtTranslations
| CUnsignedChar of int
| CUnsignedTable of int list (* typedef uchar * *)
| CVisual of Visual
| CWidget of Widget
| CWidgetList of Widget list
| CXmString of string
| CXmStringTable of string list;
*)
val cAccelerators = 1
and cBool = 2
and cColormap = 3
and cCursor = 4
and cDimension = 5
and cFontList = 6
and cInt = 7
and cIntTable = 8
and cKeySym = 9
and cPixmap = 10
and cPosition = 11
and cString = 12
and cStringTable = 13
and cTrans = 14
and cUnsignedChar = 15
and cUnsignedTable = 16
and cVisual = 17
and cWidget = 18
and cWidgetList = 19
and cXmString = 20
and cXmStringTable = 21
fun I x = x;
(* This version can be inlined for greater efficiency. SPF 1/6/95 *)
val Cast : 'a -> 'b = RunCall.unsafeCast;
val toInt : 'a -> int = Cast (* we could make this any type. *)
fun CType (XmRAcceleratorTable a) = (toInt a, cAccelerators)
| CType (XmRAlignment a) = (fromAlignment a, cUnsignedChar)
| CType (XmRArrowDirection a) = (fromArrowDirection a, cUnsignedChar)
| CType (XmRAtom i) = (i, cKeySym) (* Atom = unsigned = KeySym *)
| CType (XmRAttachment a) = (fromAttachment a, cUnsignedChar)
| CType (XmRBool b) = (toInt b, cBool)
| CType (XmRButtonTypeTable L) = (toInt(map fromButtonType L), cUnsignedTable)
| CType (XmRCardinal i) = (i, cKeySym) (* Cardinal = unsigned = KeySym *)
| CType (XmRColormap c) = (toInt c, cColormap)
| CType (XmRCommandWindowLocation t) = (fromCommandWindowLocation t, cUnsignedChar)
| CType (XmRCursor c) = (toInt c, cCursor)
| CType (XmRDefaultButtonType e) = (fromDefaultButtonType e, cInt)
| CType (XmRDeleteResponse e) = (fromDeleteResponse e, cInt)
| CType (XmRDialogStyle e) = (fromDialogStyle e, cInt)
| CType (XmRDialogType e) = (fromDialogType e, cUnsignedChar)
| CType (XmRDimension d) = (d, cDimension)
| CType (XmREditMode e) = (fromEditMode e, cInt)
| CType (XmRFileTypeMask m) = (fromFileTypeMask m, cUnsignedChar)
| CType (XmRFontList L) = (toInt L, cFontList)
| CType (XmRIndicatorType t) = (fromIndicatorType t, cUnsignedChar)
| CType (XmRInitialState i) = (fromXWMStateHint i, cInt)
| CType (XmRInt i) = (i, cInt)
| CType (XmRKeySym k) = (k, cKeySym)
| CType (XmRKeySymTable k) = (toInt k, cIntTable)
| CType (XmRKeyboardFocusPolicy t) = (fromKeyboardFocusPolicy t, cUnsignedChar)
| CType (XmRLabelType t) = (fromLabelType t, cUnsignedChar)
| CType (XmRMultiClick t) = (fromMultiClick t, cUnsignedChar)
| CType (XmRNavigationType t) = (fromNavigationType t, cUnsignedChar)
| CType (XmROrientation r) = (fromOrientation r, cUnsignedChar)
| CType (XmRPacking p) = (fromPacking p, cUnsignedChar)
| CType (XmRProcessingDirection p) = (fromProcessingDirection p, cUnsignedChar)
| CType (XmRResizePolicy p) = (fromResizePolicy p, cUnsignedChar)
| CType (XmRRowColumnType p) = (fromRowColumnType p, cUnsignedChar)
| CType (XmRPixel p) = (p, cInt)
| CType (XmRPixmap p) = (toInt p, cPixmap)
| CType (XmRPosition p) = (p, cPosition)
| CType (XmRScrollBarDisplayPolicy p) = (fromScrollBarDisplayPolicy p, cUnsignedChar)
| CType (XmRScrollBarPlacement p) = (fromScrollBarPlacement p, cUnsignedChar)
| CType (XmRScrollingPolicy p) = (fromScrollingPolicy p, cUnsignedChar)
| CType (XmRSelectionPolicy p) = (fromSelectionPolicy p, cUnsignedChar)
| CType (XmRShadowType t) = (fromShadowType t, cUnsignedChar)
| CType (XmRShort i) = (i, cPosition) (* Position = short *)
| CType (XmRStringDirection t) = (fromStringDirection t, cUnsignedChar)
| CType (XmRString s) = (toInt s, cString)
| CType (XmRStringTable s) = (toInt s, cStringTable)
| CType (XmRTextScanTypeTable L) = (toInt(map fromTextScanType L), cIntTable)
| CType (XmRTranslationTable t) = (toInt t, cTrans)
| CType (XmRUnitType t) = (fromUnitType t, cUnsignedChar)
| CType (XmRVisual v) = (toInt v, cVisual)
| CType (XmRVisualPolicy p) = (fromVisualPolicy p, cUnsignedChar)
| CType (XmRWidget w) = (toInt w, cWidget)
| CType (XmRWidgetList L) = (toInt L, cWidgetList)
| CType (XmRXmString s) = (toInt s, cXmString)
| CType (XmRXmStringTable t) = (toInt t, cXmStringTable);
fun Convert (XmRAcceleratorTable _) = I
| Convert (XmRAlignment _) = Cast toAlignment
| Convert (XmRArrowDirection _) = Cast toArrowDirection
| Convert (XmRAtom _) = I
| Convert (XmRAttachment _) = Cast toAttachment
| Convert (XmRBool _) = I
| Convert (XmRButtonTypeTable _) = Cast (map toButtonType)
| Convert (XmRCardinal _) = I
| Convert (XmRColormap _) = I
| Convert (XmRCommandWindowLocation _) = Cast toCommandWindowLocation
| Convert (XmRCursor _) = I
| Convert (XmRDefaultButtonType _) = Cast toDefaultButtonType
| Convert (XmRDeleteResponse _) = Cast toDeleteResponse
| Convert (XmRDialogStyle _) = Cast toDialogStyle
| Convert (XmRDialogType _) = Cast toDialogType
| Convert (XmRDimension _) = I
| Convert (XmREditMode _) = Cast toEditMode
| Convert (XmRFileTypeMask _) = Cast toFileTypeMask
| Convert (XmRFontList _) = I
| Convert (XmRIndicatorType _) = Cast toIndicatorType
| Convert (XmRInitialState _) = Cast toXWMStateHint
| Convert (XmRInt _) = I
| Convert (XmRKeySym _) = I
| Convert (XmRKeySymTable _) = I
| Convert (XmRKeyboardFocusPolicy _) = Cast toKeyboardFocusPolicy
| Convert (XmRLabelType _) = Cast toLabelType
| Convert (XmRMultiClick _) = Cast toMultiClick
| Convert (XmRNavigationType _) = Cast toNavigationType
| Convert (XmROrientation _) = Cast toOrientation
| Convert (XmRPacking _) = Cast toPacking
| Convert (XmRProcessingDirection _) = Cast toProcessingDirection
| Convert (XmRResizePolicy _) = Cast toResizePolicy
| Convert (XmRRowColumnType _) = Cast toRowColumnType
| Convert (XmRPixel _) = I
| Convert (XmRPixmap _) = I
| Convert (XmRPosition _) = I
| Convert (XmRScrollBarDisplayPolicy _) = Cast toScrollBarDisplayPolicy
| Convert (XmRScrollBarPlacement _) = Cast toScrollBarPlacement
| Convert (XmRScrollingPolicy _) = Cast toScrollingPolicy
| Convert (XmRSelectionPolicy _) = Cast toSelectionPolicy
| Convert (XmRShadowType _) = Cast toShadowType
| Convert (XmRShort _) = I
| Convert (XmRStringDirection _) = Cast toStringDirection
| Convert (XmRString _) = I
| Convert (XmRStringTable _) = I
| Convert (XmRTextScanTypeTable _) = Cast (map toTextScanType)
| Convert (XmRTranslationTable _) = I
| Convert (XmRUnitType _) = Cast toUnitType
| Convert (XmRVisual _) = I
| Convert (XmRVisualPolicy _) = Cast toVisualPolicy
| Convert (XmRWidget _) = I
| Convert (XmRWidgetList _) = I
| Convert (XmRXmString _) = I
| Convert (XmRXmStringTable _) = I;
fun RName (XmRAcceleratorTable _) = "AcceleratorTable"
| RName (XmRAlignment _) = "Alignment"
| RName (XmRArrowDirection _) = "ArrowDirection"
| RName (XmRAtom _) = "Atom"
| RName (XmRAttachment _) = "Attachment"
| RName (XmRBool _) = "Bool"
| RName (XmRButtonTypeTable _) = "ButtonTypeTable"
| RName (XmRCardinal _) = "Cardinal"
| RName (XmRColormap _) = "Colormap"
| RName (XmRCommandWindowLocation _) = "CommandWindowLocation"
| RName (XmRCursor _) = "Cursor"
| RName (XmRDefaultButtonType _) = "DefaultButtonType"
| RName (XmRDeleteResponse _) = "DeleteResponse"
| RName (XmRDialogStyle _) = "DialogStyle"
| RName (XmRDialogType _) = "DialogType"
| RName (XmRDimension _) = "Dimension"
| RName (XmREditMode _) = "EditMode"
| RName (XmRFileTypeMask _) = "FileTypeMask"
| RName (XmRFontList _) = "FontList"
| RName (XmRIndicatorType _) = "IndicatorType"
| RName (XmRInitialState _) = "InitialState"
| RName (XmRInt _) = "Int"
| RName (XmRKeySym _) = "KeySym"
| RName (XmRKeySymTable _) = "KeySymTable"
| RName (XmRKeyboardFocusPolicy _) = "KeyboardFocusPolicy"
| RName (XmRLabelType _) = "LabelType"
| RName (XmRMultiClick _) = "MultiClick"
| RName (XmRNavigationType _) = "NavigationType"
| RName (XmROrientation _) = "Orientation"
| RName (XmRPacking _) = "Packing"
| RName (XmRProcessingDirection _) = "ProcessingDirection"
| RName (XmRResizePolicy _) = "ResizePolicy"
| RName (XmRRowColumnType _) = "RowColumnType"
| RName (XmRPixel _) = "Pixel"
| RName (XmRPixmap _) = "Pixmap"
| RName (XmRPosition _) = "Position"
| RName (XmRScrollBarDisplayPolicy _) = "ScrollBarDisplayPolicy"
| RName (XmRScrollBarPlacement _) = "ScrollBarPlacement"
| RName (XmRScrollingPolicy _) = "ScrollingPolicy"
| RName (XmRSelectionPolicy _) = "SelectionPolicy"
| RName (XmRShadowType _) = "ShadowType"
| RName (XmRShort _) = "Short"
| RName (XmRStringDirection _) = "StringDirection"
| RName (XmRString _) = "String"
| RName (XmRStringTable _) = "StringTable"
| RName (XmRTextScanTypeTable _) = "TextScanTypeTable"
| RName (XmRTranslationTable _) = "TranslationTable"
| RName (XmRUnitType _) = "UnitType"
| RName (XmRVisual _) = "Visual"
| RName (XmRVisualPolicy _) = "VisualPolicy"
| RName (XmRWidget _) = "Widget"
| RName (XmRWidgetList _) = "WidgetList"
| RName (XmRXmString _) = "XmString"
| RName (XmRXmStringTable _) = "XmStringTable";
(* Added this function to remove the dependency on datatype representation.
DCJM 28/3/01. *)
fun insertValue (XmRAcceleratorTable _) v = XmRAcceleratorTable (Cast v)
| insertValue (XmRAlignment _) v = XmRAlignment (Cast v)
| insertValue (XmRArrowDirection _) v = XmRArrowDirection (Cast v)
| insertValue (XmRAtom _) v = XmRAtom (Cast v)
| insertValue (XmRAttachment _) v = XmRAttachment (Cast v)
| insertValue (XmRBool _) v = XmRBool (Cast v)
| insertValue (XmRButtonTypeTable _) v = XmRButtonTypeTable (Cast v)
| insertValue (XmRCardinal _) v = XmRCardinal (Cast v)
| insertValue (XmRColormap _) v = XmRColormap (Cast v)
| insertValue (XmRCommandWindowLocation _) v = XmRCommandWindowLocation (Cast v)
| insertValue (XmRCursor _) v = XmRCursor (Cast v)
| insertValue (XmRDefaultButtonType _) v = XmRDefaultButtonType (Cast v)
| insertValue (XmRDeleteResponse _) v = XmRDeleteResponse (Cast v)
| insertValue (XmRDialogStyle _) v = XmRDialogStyle (Cast v)
| insertValue (XmRDialogType _) v = XmRDialogType (Cast v)
| insertValue (XmRDimension _) v = XmRDimension (Cast v)
| insertValue (XmREditMode _) v = XmREditMode (Cast v)
| insertValue (XmRFileTypeMask _) v = XmRFileTypeMask (Cast v)
| insertValue (XmRFontList _) v = XmRFontList (Cast v)
| insertValue (XmRIndicatorType _) v = XmRIndicatorType (Cast v)
| insertValue (XmRInitialState _) v = XmRInitialState (Cast v)
| insertValue (XmRInt _) v = XmRInt (Cast v)
| insertValue (XmRKeySym _) v = XmRKeySym (Cast v)
| insertValue (XmRKeySymTable _) v = XmRKeySymTable (Cast v)
| insertValue (XmRKeyboardFocusPolicy _) v = XmRKeyboardFocusPolicy (Cast v)
| insertValue (XmRLabelType _) v = XmRLabelType (Cast v)
| insertValue (XmRMultiClick _) v = XmRMultiClick (Cast v)
| insertValue (XmRNavigationType _) v = XmRNavigationType (Cast v)
| insertValue (XmROrientation _) v = XmROrientation (Cast v)
| insertValue (XmRPacking _) v = XmRPacking (Cast v)
| insertValue (XmRProcessingDirection _) v = XmRProcessingDirection (Cast v)
| insertValue (XmRResizePolicy _) v = XmRResizePolicy (Cast v)
| insertValue (XmRRowColumnType _) v = XmRRowColumnType (Cast v)
| insertValue (XmRPixel _) v = XmRPixel (Cast v)
| insertValue (XmRPixmap _) v = XmRPixmap (Cast v)
| insertValue (XmRPosition _) v = XmRPosition (Cast v)
| insertValue (XmRScrollBarDisplayPolicy _) v = XmRScrollBarDisplayPolicy (Cast v)
| insertValue (XmRScrollBarPlacement _) v = XmRScrollBarPlacement (Cast v)
| insertValue (XmRScrollingPolicy _) v = XmRScrollingPolicy (Cast v)
| insertValue (XmRSelectionPolicy _) v = XmRSelectionPolicy (Cast v)
| insertValue (XmRShadowType _) v = XmRShadowType (Cast v)
| insertValue (XmRShort _) v = XmRShort (Cast v)
| insertValue (XmRStringDirection _) v = XmRStringDirection (Cast v)
| insertValue (XmRString _) v = XmRString (Cast v)
| insertValue (XmRStringTable _) v = XmRStringTable (Cast v)
| insertValue (XmRTextScanTypeTable _) v = XmRTextScanTypeTable (Cast v)
| insertValue (XmRTranslationTable _) v = XmRTranslationTable (Cast v)
| insertValue (XmRUnitType _) v = XmRUnitType (Cast v)
| insertValue (XmRVisual _) v = XmRVisual (Cast v)
| insertValue (XmRVisualPolicy _) v = XmRVisualPolicy (Cast v)
| insertValue (XmRWidget _) v = XmRWidget (Cast v)
| insertValue (XmRWidgetList _) v = XmRWidgetList( Cast v)
| insertValue (XmRXmString _) v = XmRXmString (Cast v)
| insertValue (XmRXmStringTable _) v = XmRXmStringTable (Cast v);
datatype Exn = EXN of unit ref * string * unit;
val argTable = ref ([]:(Exn * string * XmRType) list);
val Exn: Arg -> Exn = Cast;
val Arg: Exn -> Arg = Cast;
fun ArgName (e:Arg) =
let
(* open System; *)
fun substring s i n = String.substring(s, i-1, n)
val EXN (_,s,_) = Exn e;
val n = size s;
in
if n < 3 orelse substring s 1 3 <> "XmN"
then
raise XWindows (s ^ " does not start with XmN")
else
substring s 4 (n - 3)
end;
fun FindByExn (e:Arg) =
let
val EXN (r1,n,value) = Exn e;
(* This bit of code assumes that XmRType values are pairs with the
tag in the second word and the value in the first. That's no
longer correct. I've replaced it with the insertValue function
above. DCJM 28/3/01. *)
(*fun InsertValue (r:XmRType) =
let
val (_,tag) = Cast r;
in
Cast (value,tag):XmRType
end;*)
fun InsertValue (r:XmRType) = insertValue r value
fun Find [] = raise XWindows (n ^ " has not been registered")
| Find (H::T) =
let
val (EXN (r2,_,_),s,r) = H;
in
if r1 = r2 then (s,InsertValue r) else Find T
end;
in
Find (!argTable)
end;
fun FindByString s =
let
fun Find [] = raise XWindows (s ^ " has not been registered.")
| Find (H::T) =
let
val (_,t,_) = H;
in
if s = t then H else Find T
end;
in
Find (!argTable)
end;
fun Length L =
let
fun Count [] n = n
| Count (_::T) n = Count T (n+1);
in
Count L 0
end;
in
(*type CType = CType;*)
val fromDefaultButtonType = fromDefaultButtonType;
fun XtSetExnVals [] = []
| XtSetExnVals (H::T) =
let
val (s,r) = FindByExn H;
val A = (s,CType r);
in
case H of
XmNargv L => A :: XtSetExnVals (XmNargc (Length L) :: T)
| XmNbuttonAccelerators L => A :: XtSetExnVals (XmNbuttonCount (Length L) :: T)
| XmNbuttonAcceleratorText L => A :: XtSetExnVals (XmNbuttonCount (Length L) :: T)
| XmNbuttonMnemonicCharSets L => A :: XtSetExnVals (XmNbuttonCount (Length L) :: T)
| XmNbuttonMnemonics L => A :: XtSetExnVals (XmNbuttonCount (Length L) :: T)
| XmNbuttons L => A :: XtSetExnVals (XmNbuttonCount (Length L) :: T)
| XmNbuttonType L => A :: XtSetExnVals (XmNbuttonCount (Length L) :: T)
| XmNchildren L => A :: XtSetExnVals (XmNnumChildren (Length L) :: T)
| XmNdirListItems L => A :: XtSetExnVals (XmNdirListItemCount (Length L) :: T)
| XmNfileListItems L => A :: XtSetExnVals (XmNfileListItemCount (Length L) :: T)
| XmNhistoryItems L => A :: XtSetExnVals (XmNhistoryItemCount (Length L) :: T)
| XmNitems L => A :: XtSetExnVals (XmNitemCount (Length L) :: T)
| XmNlistItems L => A :: XtSetExnVals (XmNlistItemCount (Length L) :: T)
| XmNselectedItems L => A :: XtSetExnVals (XmNselectedItemCount (Length L) :: T)
| XmNselectionArray L => A :: XtSetExnVals (XmNselectionArrayCount (Length L) :: T)
| _ => A :: XtSetExnVals T
end;
fun XtSetExceptionType (E:'a -> Arg) (R:'a -> XmRType) =
let
val a:'a = Cast 0;
val e = E a;
val r = R a;
in
argTable := (Exn e,ArgName e,r) :: !argTable
end;
fun XtGetValue (w:Widget) (s:string):Arg =
let
val (EXN (u,n,_),_,r) = FindByString s;
in
Arg (EXN (u,n,Convert r (xcall (XCALL_GetValue,w,(s,CType r)))))
end;
local
fun GetExns [] R C = (R,C)
| GetExns ((s,c,d)::T) R C =
let
val (EXN (u,n,_),_,r) = FindByString s;
val convert = Convert r;
fun MakeExn v = Arg (EXN (u,n,convert v));
in
GetExns T ((s,CType r,c,RName r,RName d,CType d) :: R) (MakeExn :: C)
end;
fun Zip [] _ acc = acc
| Zip _ [] acc = acc
| Zip (v::V) (c::C) acc = Zip V C (c v :: acc)
in
fun XtGetSubresources (w:Widget) (name:string) (class:string) (L:(string * string * XmRType) list):Arg list =
let
val (R,C) = GetExns L [] [];
val V = xcall (XCALL_GetSubresources,w,name,class,R)
in
Zip V C []
end;
fun XtGetApplicationResources (w:Widget) (L:(string * string * XmRType) list):Arg list =
let
val (R,C) = GetExns L [] [] ;
val V = xcall (XCALL_XtGetApplicationResources,w,R)
in
Zip V C []
end ;
end;
local
(* These have been copied over from the XWindows module. *)
infix 9 Or;
fun a Or b = xcall (12,a:int,b:int):int ;
fun fromEventMask list =
let
fun MaskBit KeyPressMask = 1
| MaskBit KeyReleaseMask = 2
| MaskBit ButtonPressMask = 4
| MaskBit ButtonReleaseMask = 8
| MaskBit EnterWindowMask = 16
| MaskBit LeaveWindowMask = 32
| MaskBit PointerMotionMask = 64
| MaskBit PointerMotionHintMask = 128
| MaskBit Button1MotionMask = 256
| MaskBit Button2MotionMask = 512
| MaskBit Button3MotionMask = 1024
| MaskBit Button4MotionMask = 2048
| MaskBit Button5MotionMask = 4096
| MaskBit ButtonMotionMask = 8192
| MaskBit KeymapStateMask = 16384
| MaskBit ExposureMask = 32768
| MaskBit VisibilityChangeMask = 65536
| MaskBit StructureNotifyMask = 131072
| MaskBit ResizeRedirectMask = 262144
| MaskBit SubstructureNotifyMask = 524288
| MaskBit SubstructureRedirectMask = 1048576
| MaskBit FocusChangeMask = 2097152
| MaskBit PropertyChangeMask = 4194304
| MaskBit ColormapChangeMask = 8388608
| MaskBit OwnerGrabButtonMask = 16777216
| MaskBit ButtonClickMask = 536870912 Or MaskBit ButtonPressMask Or MaskBit ButtonReleaseMask (* extra event mask *) ;
fun OrTogether [] acc = acc
| OrTogether (H::T) acc = OrTogether T (MaskBit H Or acc) ;
in
OrTogether list 0
end
in
fun XtAddEventHandler (w: Widget) (ev: EventMask list) (nonmaskable: bool)
(handler: Widget * 'a XEvent -> unit) : unit =
xcall(XCALL_XtAddEventHandler, w, fromEventMask ev, nonmaskable, handler)
end
end (* local *);
end (* struct *);
|