wimp 29.1 KB
Newer Older
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
/* Copyright 1997 Acorn Computers Ltd
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
/****************************************************************************
 * This source file was written by Acorn Computers Limited. It is part of   *
 * the toolbox library for writing desktop applications in C. It may be     *
 * used freely in the creation of programs for Archimedes or Risc PC. It    *
 * should be used with Acorn's C Compiler Release 5 or later.               *
 *                                                                          *
 *                                                                          *
 * Copyright  Acorn Computers Ltd, 1994                                    *
 *                                                                          *
 ***************************************************************************/


/*
 * Name        : wimp.h
 * Description : SWI names and structures for accessing the SWIs provided by Window
 *               Manager
 */


#ifndef __wimp_h
#define __wimp_h




/***************************************************************************
 * SWI names, reason codes and flags                                       *
 ***************************************************************************/

#ifndef Wimp_Initialise

#define Wimp_Initialise                         0x400C0
#define Wimp_CreateWindow                       0x400C1
#define Wimp_CreateIcon                         0x400C2
#define Wimp_CreateIconRelative                 0x400C2
#define Wimp_CreateIconPrioritised              0x400C2
#define Wimp_DeleteWindow                       0x400C3
#define Wimp_DeleteIcon                         0x400C4
#define Wimp_OpenWindow                         0x400C5
#define Wimp_CloseWindow                        0x400C6
#define Wimp_Poll                               0x400C7
#define Wimp_RedrawWindow                       0x400C8
#define Wimp_UpdateWindow                       0x400C9
#define Wimp_GetRectangle                       0x400CA
#define Wimp_GetWindowState                     0x400CB
#define Wimp_GetWindowInfo                      0x400CC
#define Wimp_SetIconState                       0x400CD
#define Wimp_GetIconState                       0x400CE
#define Wimp_GetPointerInfo                     0x400CF
#define Wimp_DragBox                            0x400D0
#define Wimp_ForceRedraw                        0x400D1
#define Wimp_SetCaretPosition                   0x400D2
#define Wimp_GetCaretPosition                   0x400D3
#define Wimp_CreateMenu                         0x400D4
#define Wimp_DecodeMenu                         0x400D5
#define Wimp_WhichIcon                          0x400D6
#define Wimp_SetExtent                          0x400D7
#define Wimp_OpenTemplate                       0x400D9
#define Wimp_CloseTemplate                      0x400DA
#define Wimp_LoadTemplate                       0x400DB
#define Wimp_ProcessKey                         0x400DC
#define Wimp_CloseDown                          0x400DD
#define Wimp_StartTask                          0x400DE
#define Wimp_ReportError                        0x400DF
#define Wimp_GetWindowOutline                   0x400E0
#define Wimp_PollIdle                           0x400E1
#define Wimp_PlotIcon                           0x400E2
#define Wimp_SetMode                            0x400E3
#define Wimp_SetPalette                         0x400E4
#define Wimp_ReadPalette                        0x400E5
#define Wimp_ReadTruePalette                    0x400E5
#define Wimp_SetColour                          0x400E6
#define Wimp_SendMessage                        0x400E7
#define Wimp_CreateSubMenu                      0x400E8
#define Wimp_SpriteOp                           0x400E9
#define Wimp_BaseOfSprites                      0x400EA
#define Wimp_BlockCopy                          0x400EB
#define Wimp_SlotSize                           0x400EC
#define Wimp_ReadPixTrans                       0x400ED
#define Wimp_ClaimFreeMemory                    0x400EE
#define Wimp_ReleaseFreeMemory                  0x400EE
#define Wimp_CommandWindow                      0x400EF
#define Wimp_TextColour                         0x400F0
#define Wimp_TransferBlock                      0x400F1
#define Wimp_ReadSysInfo                        0x400F2
#define Wimp_SetFontColours                     0x400F3
#define Wimp_GetMenuState                       0x400F4
#define Wimp_RegisterFilter                     0x400F5
#define Wimp_AddMessages                        0x400F6
#define Wimp_RemoveMessages                     0x400F7
#define Wimp_SetColourMapping                   0x400F8

107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122
#ifndef Service_Memory
#define Service_Memory                           (0x11)
#define Service_StartWimp                        (0x49)
#define Service_StartedWimp                      (0x4a)
#define Service_PremodeChange                    (0x4d)
#define Service_MouseTrap                        (0x52)
#define Service_WimpCloseDown                    (0x53)
#define Service_WimpReportError                  (0x57)
#define Service_WimpSaveDesktop                  (0x5c)
#define Service_WimpPalette                      (0x5d)
#define Service_DesktopWelcome                   (0x7c)
#define Service_ShutDown                         (0x7e)
#define Service_ShutDownComplete                 (0x80)
#define Service_WimpSpritesMoved                 (0x85)
#define Service_WimpRegisterFilters              (0x86)
#endif
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

#endif

/* flags passed in r0 to SWI Wimp_Poll */

#define Wimp_Poll_NullMask                   (1u << 0)
#define Wimp_Poll_RedrawWindowRequestMask    (1u << 1)
#define Wimp_Poll_PointerLeavingWindowMask   (1u << 4)
#define Wimp_Poll_PointerEnteringWindowMask  (1u << 5)
#define Wimp_Poll_MouseClickMask             (1u << 6)
#define Wimp_Poll_KeyPressedMask             (1u << 8)
#define Wimp_Poll_LoseCaretMask              (1u << 11)
#define Wimp_Poll_GainCaretMask              (1u << 12)
#define Wimp_Poll_PollWordNonZeroMask        (1u << 13)
#define Wimp_Poll_UserMessageMask            (1u << 17)
#define Wimp_Poll_UserMessageRecordedMask    (1u << 18)
#define Wimp_Poll_UserMessageAcknowledgeMask (1u << 19)
#define Wimp_Poll_PollWord                   (1u << 22)
#define Wimp_Poll_PollWordHighPriority       (1u << 23)
#define Wimp_Poll_SaveFPRegs                 (1u << 24)


/* flags passed in r1 to SWI Wimp_ReportError */

#define Wimp_ReportError_OK                  (1u << 0)
#define Wimp_ReportError_Cancel              (1u << 1)
#define Wimp_ReportError_HighlightCancel     (1u << 2)
#define Wimp_ReportError_NoPrompt            (1u << 3)
#define Wimp_ReportError_NoAppName           (1u << 4)
#define Wimp_ReportError_LeaveOpen           (1u << 5)
#define Wimp_ReportError_Close               (1u << 6)
#define Wimp_ReportError_NoBeep              (1u << 7)





/***************************************************************************
 *                    Globally useful fundamental types                    *
 ***************************************************************************/

/*-- bounding box --*/

typedef struct
{
    int xmin, ymin, xmax, ymax;

} BBox;


/*-- caret -- */

typedef struct
{
    int     window_handle;
    int     icon_handle;
    int     xoffset;
    int     yoffset;
    int     height;
    int     index;

} WimpCaret;



/***************************************************************************
 *                                 Icons                                   *
 ***************************************************************************/


/***************************************************************************
 *                      Fundamental types for icons                        *
 ***************************************************************************/

typedef union
{
    char t[12];
    char s[12];
    char st[12];

    struct
    {
        char *buffer;
        char *validation;
        int   buffer_size;
    } it;

    struct
    {
        void *sprite;
        void *sprite_area;
        int   sprite_name_length;
    } is;

    struct
    {
        char *buffer;
        char *validation;
        int   buffer_size;
    } ist;

} WimpIconData;



typedef struct
{
    BBox         bbox;
    unsigned int flags;
    WimpIconData data;

} WimpIconBlock;


/* icon description flags */

#define WimpIcon_Text                          (1u << 0)
#define WimpIcon_Sprite                        (1u << 1)
#define WimpIcon_Border                        (1u << 2)
#define WimpIcon_HCentred                      (1u << 3)
#define WimpIcon_VCentred                      (1u << 4)
#define WimpIcon_Filled                        (1u << 5)
#define WimpIcon_AntiAliased                   (1u << 6)
#define WimpIcon_NeedsHelp                     (1u << 7)
#define WimpIcon_Indirected                    (1u << 8)
#define WimpIcon_RJustified                    (1u << 9)
#define WimpIcon_AllowAdjust                   (1u << 10)
#define WimpIcon_HalfSize                      (1u << 11)
#define WimpIcon_ButtonType                    (1u << 12)
#define WimpIcon_ESG                           (1u << 16)
#define WimpIcon_Selected                      (1u << 21)
#define WimpIcon_Shaded                        (1u << 22)
#define WimpIcon_Deleted                       (1u << 23)
#define WimpIcon_FGColour                      (1u << 24)
#define WimpIcon_BGColour                      (1u << 28)
#define WimpIcon_FontHandle                    (1u << 24)


/* The following are icon button types.  To set the button type in an
 * icon's flags you should multiply by the constant Icon_ButtonType
 * eg,
 *
 *     WimpIcon i;
 *
 *        i.flags |= WimpIcon_ButtonType * ButtonType_Never;
 *
 */

#define ButtonType_Never                      0
#define ButtonType_Always                     1
#define ButtonType_Repeat                     2
#define ButtonType_Click                      3
#define ButtonType_Release                    4
#define ButtonType_DoubleClick                5
#define ButtonType_ClickDrag                  6
#define ButtonType_ReleaseDrag                7
#define ButtonType_DoubleDrag                 8
#define ButtonType_MenuIcon                   9
#define ButtonType_DoubleClickDrag           10
#define ButtonType_Radio                     11
#define ButtonType_WriteClickDrag            14
#define ButtonType_Writable                  15



/***************************************************************************
 *   The following structures define data types for blocks of memory which *
 *   are passed to Wimp SWIs which manipulate or interrogate icons.        *
 *                                                                         *
 ***************************************************************************/

/* structure for creating an icon using SWI Wimp_CreateIcon */

typedef struct
{
    int      window_handle;
    WimpIconBlock icon;

} WimpCreateIconBlock;



/* structure for getting an icon's state using SWI Wimp_GetIconState */

typedef struct
{
    int       window_handle;
    int       icon_handle;
    WimpIconBlock  icon;

} WimpGetIconStateBlock;



/* structure for setting an icon's state using SWI Wimp_SetIconState */

typedef struct
{
    int       window_handle;
    int       icon_handle;
    int       EOR_word;
    int       clear_word;

} WimpSetIconStateBlock;

/* --- wimp pointer info --- */

typedef struct
{
        int x;
        int y;
        int button_state;
        int window_handle;
        int icon_handle;
} WimpGetPointerInfoBlock;

/* Wimp_DragBox SWI */

typedef struct {
        int wimp_window;
        int drag_type;
        BBox dragging_box;
        BBox parent_box;
        int *workspace;
        void (*draw)();
        void (*remove)();
        void (*move)();
} WimpDragBox;

#define Wimp_DragBox_DragWindow         1
#define Wimp_DragBox_DragSize           2
#define Wimp_DragBox_DragHorizontal     3
#define Wimp_DragBox_DragVertical       4
#define Wimp_DragBox_DragFixedDash      5
#define Wimp_DragBox_DragRubberDash     6
#define Wimp_DragBox_DragPoint          7
#define Wimp_DragBox_DragFixedUserBox   8
#define Wimp_DragBox_DragRubberUserBox  9
#define Wimp_DragBox_DragBoth           12

#define Wimp_DragBox_DontCancel         0x00000002

/* structure for plotting an icon using SWI Wimp_PlotIcon */

typedef WimpIconBlock WimpPlotIconBlock;




/***************************************************************************
 *                               Windows                                   *
 ***************************************************************************/


/***************************************************************************
 *                     Fundamental types for windows                       *
 ***************************************************************************/

typedef struct
{
    BBox          visible_area;
    int           xscroll;
    int           yscroll;
    int           behind;
    unsigned int  flags;
    char          title_fg;
    char          title_bg;
    char          work_fg;
    char          work_bg;
    char          scroll_outer;
    char          scroll_inner;
    char          highlight_bg;
    char          reserved;
    BBox          extent;
    unsigned int  title_flags;
    unsigned int  work_flags;
    void         *sprite_area;
    short         min_width;
    short         min_height;
    WimpIconData  title_data;
    int           nicons;

    /*-- any icons follow here in memory --*/
    /* WimpIconBlock      icons[1]; */

} WimpWindow;


/* window description flag values */
/* note: only "new-style" flags are shown */

#define WimpWindow_Moveable                    (1u << 1)
#define WimpWindow_AutoRedraw                  (1u << 4)
#define WimpWindow_Pane                        (1u << 5)
#define WimpWindow_NoBounds                    (1u << 6)
#define WimpWindow_ScrollRepeat                (1u << 8)
#define WimpWindow_Scroll                      (1u << 9)
#define WimpWindow_RealColours                 (1u << 10)
#define WimpWindow_Back                        (1u << 11)
#define WimpWindow_HotKeys                     (1u << 12)
#define WimpWindow_StayOnScreen                (1u << 13)
#define WimpWindow_IgnoreXExtent               (1u << 14)
#define WimpWindow_IgnoreYExtent               (1u << 15)
#define WimpWindow_Open                        (1u << 16)
#define WimpWindow_NotCovered                  (1u << 17)
#define WimpWindow_FullSize                    (1u << 18)
#define WimpWindow_Toggled                     (1u << 19)
#define WimpWindow_HasInputFocus               (1u << 20)
#define WimpWindow_ForceOnceOnScreen           (1u << 21)
#define WimpWindow_BackIcon                    (1u << 24)
#define WimpWindow_CloseIcon                   (1u << 25)
#define WimpWindow_TitleIcon                   (1u << 26)
#define WimpWindow_ToggleIcon                  (1u << 27)
#define WimpWindow_VScroll                     (1u << 28)
#define WimpWindow_SizeIcon                    (1u << 29)
#define WimpWindow_HScroll                     (1u << 30)
#define WimpWindow_NewFormat                   (1u << 31)


/* "special" window values */

#define WimpWindow_Background                   (-1)
#define WimpWindow_Iconbar                      (-2)
#define WimpWindow_Top                          (-1)
#define WimpWindow_Bottom                       (-2)



/***************************************************************************
 *   The following structures define data types for blocks of memory which *
 *   are passed to Wimp SWIs which manipulate or interrogate windows.      *
 *                                                                         *
 ***************************************************************************/


/* structure for creating a window using SWI Wimp_CreateWindow */

typedef WimpWindow WimpCreateWindowBlock;




/* structure for deleting a window using SWI Wimp_DeleteWindow */

typedef struct
{
    int window_handle;

} WimpDeleteWindowBlock;

typedef struct
{
    int window_handle;
    int icon_handle;

} WimpDeleteIconBlock;


/* structure for opening a window using SWI Wimp_OpenWindow */

typedef struct
{
    int   window_handle;
    BBox  visible_area;
    int   xscroll;
    int   yscroll;
    int   behind;

} WimpOpenWindowBlock;




/* structure for closing a window using SWI Wimp_CloseWindow*/

typedef struct
{
    int  window_handle;

} WimpCloseWindowBlock;




/* structure for redrawing a Window using SWI Wimp_RedrawWindow */

typedef struct
{
    int   window_handle;
    BBox  visible_area;
    int   xscroll;
    int   yscroll;
    BBox  redraw_area;

} WimpRedrawWindowBlock;




/* structure for updating a window using SWI Wimp_UpdateWindow */

typedef struct
{
    int  window_handle;
    BBox update_area;

} WimpUpdateWindowBlock;




/* structure for getting a rectangle using SWI Wimp_GetRectangle */

typedef WimpRedrawWindowBlock WimpGetRectangleBlock;




/* structure for getting a window's state using SWI Wimp_GetWindowState */

typedef struct
{
    int          window_handle;
    BBox         visible_area;
    int          xscroll;
    int          yscroll;
    int          behind;
    unsigned int flags;

} WimpGetWindowStateBlock;




/* structure for geting info for a window using SWI Wimp_GetWindowInfo */

typedef struct
{
    int     window_handle;
    WimpWindow  window_data;

} WimpGetWindowInfoBlock;




/* structure for getting a window's outline using SWI Wimp_GetWindowOutline */

typedef struct
{
    int   window_handle;
    BBox  outline;

} WimpGetWindowOutlineBlock;




/* structure for forcing a redraw on a window (or screen) using
   SWI Wimp_ForceRedraw
 */

typedef struct
{
    int  window_handle;
    BBox redraw_area;

} WimpForceRedrawBlock;




/* structures for getting the caret position using SWI
   Wimp_GetCaretPosition */

typedef WimpCaret WimpGetCaretPositionBlock;







/***************************************************************************
 *                               Menus                                     *
 ***************************************************************************/


/***************************************************************************
 *                     Fundamental types for menus                         *
 ***************************************************************************/



typedef struct
{
    unsigned int  flags;
    void         *submenu_or_window;
    unsigned int  icon_flags;
    WimpIconData  icon_data;

} WimpMenuItem;


/* menu item flags values */

#define WimpMenuItem_Ticked                       (1u << 0)
#define WimpMenuItem_DottedLine                   (1u << 1)
#define WimpMenuItem_Writable                     (1u << 2)
#define WimpMenuItem_GenerateSubWimpMenuWarning   (1u << 3)
#define WimpMenuItem_AllowWhenGreyedOut           (1u << 4)
#define WimpMenuItem_Last                         (1u << 7)
#define WimpMenuItem_IndirectedTitle              (1u << 8)


typedef struct
{
    char         title[12];
    char         title_fg;
    char         title_bg;
    char         work_fg;
    char         work_bg;
    int          item_width;
    int          item_height;
    int          gap;

    WimpMenuItem items[1];         /* menu items follow here in memory */

} WimpMenu;


typedef int WimpMenuSelections [9];    /* the wimp only allows 8-deep menu tree */



/***************************************************************************
 *   The following structures define data types for blocks of memory which *
 *   are passed to Wimp SWIs which manipulate or interrogate menus.        *
 *                                                                         *
 ***************************************************************************/


/* structure for creating a menu using SWI Wimp_CreateMenu */

typedef WimpMenu  WimpCreateMenuBlock;



/* structure for creating a submenu using SWI Wimp_CreateSubMenu */

typedef WimpMenu  WimpCreateSubMenuBlock;



/* structure for getting the current state of the menu tree using
   SWI Wimp_GetMenuState */

typedef WimpMenuSelections  WimpGetMenuStateBlock;






/***************************************************************************
 *                            Messages                                     *
 ***************************************************************************/

/*-- wimp message numbers --*/

#define Wimp_MQuit                          0
#define Wimp_MDataSave                      1
#define Wimp_MDataSaveAck                   2
#define Wimp_MDataLoad                      3
#define Wimp_MDataLoadAck                   4
#define Wimp_MDataOpen                      5
#define Wimp_MRAMFetch                      6
#define Wimp_MRAMTransmit                   7
#define Wimp_MPreQuit                       8
#define Wimp_MPaletteChange                 9
#define Wimp_MSaveDesktop                   0xa
#define Wimp_MDeviceClaim                   0xb
#define Wimp_MDeviceInUse                   0xc
#define Wimp_MDataSaved                     0xd
#define Wimp_MShutDown                      0xe
#define Wimp_MClaimEntity                   0xf
#define Wimp_MDataRequest                   0x10
#define Wimp_MDragging                      0x11
#define Wimp_MDragClaim                     0x12
#define Wimp_MAppControl                    0x15
#define Wimp_MMenuWarning                   0x400c0
#define Wimp_MModeChange                    0x400c1
#define Wimp_MTaskInitialise                0x400c2
#define Wimp_MTaskCloseDown                 0x400c3
#define Wimp_MSlotSize                      0x400c4
#define Wimp_MSetSlot                       0x400c5
#define Wimp_MTaskNameRq                    0x400c6
#define Wimp_MTaskNameIs                    0x400c7
#define Wimp_MTaskStarted                   0x400c8
#define Wimp_MMenusDeleted                  0x400c9
#define Wimp_MIconize                       0x400ca
#define Wimp_MWindowClosed                  0x400cb
#define Wimp_MWindowInfo                    0x400cc
#define Wimp_MSwap                          0x400cd
#define Wimp_MToolsChanged                  0x400ce
#define Wimp_MFontChanged                   0x400cf
#define Wimp_MPrintFile                     0x80140
#define Wimp_MWillPrint                     0x80141
#define Wimp_MPrintSave                     0x80142
#define Wimp_MPrintInit                     0x80143
#define Wimp_MPrintError                    0x80144
#define Wimp_MPrintTypeOdd                  0x80145
#define Wimp_MPrintTypeKnown                0x80146
#define Wimp_MSetPrinter                    0x80147
#define Wimp_MHelpRequest                   0x502
#define Wimp_MHelpReply                     0x503



/***************************************************************************
 *   The following are definitions of structures used to send and          *
 *   receive Wimp Messages                                                 *
 ***************************************************************************/



/* The following structures are for common Wimp messages.  This list is
 * not exhaustive, but the client application can add to these any other
 * messages which it needs.
 */


typedef struct
{
    int   destination_window;
    int   destination_icon;
    int   destination_x;
    int   destination_y;
    int   estimated_size;
    int   file_type;
    char  leaf_name [212];

} WimpDataSaveMessage,
  WimpDataSaveAckMessage,
  WimpDataLoadMessage,
  WimpDataLoadAckMessage;



typedef struct
{
    int   window_handle;
    int   padding1;
    int   x;
    int   y;
    int   padding2;
    int   file_type;
    char  path_name[212];

} WimpDataOpen;



typedef struct
{
    unsigned int version;
    unsigned int flags;
    unsigned int reason;

} WimpAppControlMessage;

/* Reason codes for the above */

796 797 798 799 800
#define Wimp_MAppControl_Stop           0
#define Wimp_MAppControl_WakeUp         1
#define Wimp_MAppControl_Freeze         2
#define Wimp_MAppControl_MinimiseMemory 3
#define Wimp_MAppControl_Configure      4
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 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070

/* Flags for the above */

#define Wimp_MAppControl_ImmediateAction (1u<<0)



typedef struct
{
    int mouse_x;
    int mouse_y;
    int buttons;
    int window_handle;
    int icon_handle;

} WimpHelpRequestMessage;



typedef struct
{
    char text [236];

} WimpHelpReplyMessage;



typedef struct
{
    void *buffer;
    int   buffer_size;

} WimpRAMFetchMessage;



typedef struct
{
    void *buffer;
    int   nbytes;

} WimpRAMTransmitMessage;



typedef struct
{
    int file_handle;

} WimpSaveDesktopMessage;



typedef struct
{
    unsigned int flags;

} WimpShutdownMessage;


typedef struct
{
    struct
    {
        int    size;
        int    sender;
        int    my_ref;
        int    your_ref;
        int    action_code;
    } hdr;

    union
    {
        int                       words[59];
        char                      bytes[236];
        WimpDataSaveMessage       data_save;
        WimpDataSaveAckMessage    data_save_ack;
        WimpDataLoadMessage       data_load;
        WimpDataLoadAckMessage    data_load_ack;
        WimpDataOpen              data_open;
        WimpAppControlMessage     app_control;
        WimpHelpRequestMessage    help_request;
        WimpHelpReplyMessage      help_reply;
        WimpRAMFetchMessage       ram_fetch;
        WimpRAMTransmitMessage    ram_transmit;
        WimpSaveDesktopMessage    save_desktop;
        WimpShutdownMessage       shutdown;

    } data;

} WimpMessage;



/* structure used to send a wimp message using SWI Wimp_SendMessage */

typedef WimpMessage WimpSendMessageBlock;






/***************************************************************************
 *                               Events                                    *
 ***************************************************************************/


/* event codes returned in r0 from SWI Wimp_Poll */

#define Wimp_ENull                    0
#define Wimp_ERedrawWindow            1
#define Wimp_EOpenWindow              2
#define Wimp_ECloseWindow             3
#define Wimp_EPointerLeavingWindow    4
#define Wimp_EPointerEnteringWindow   5
#define Wimp_EMouseClick              6
#define Wimp_EUserDrag                7
#define Wimp_EKeyPressed              8
#define Wimp_EMenuSelection           9
#define Wimp_EScrollRequest           10
#define Wimp_ELoseCaret               11
#define Wimp_EGainCaret               12
#define Wimp_EPollWordNonZero         13
#define Wimp_EUserMessage             17
#define Wimp_EUserMessageRecorded     18
#define Wimp_EUserMessageAcknowledge  19
#define Wimp_EToolboxEvent            0x200


/* structures defining the event block returned by the Wimp from SWI Wimp_Poll
   ie the block whose address was passed in r1
 */


typedef struct
{
    int window_handle;

} WimpRedrawWindowRequestEvent;



typedef WimpOpenWindowBlock WimpOpenWindowRequestEvent;



typedef struct
{
    int window_handle;

} WimpCloseWindowRequestEvent;



typedef struct
{
    int window_handle;

} WimpPointerLeavingWindowEvent, WimpPointerEnteringWindowEvent;



typedef struct
{
    int mouse_x;
    int mouse_y;
    int buttons;
    int window_handle;
    int icon_handle;

} WimpMouseClickEvent;

#define Wimp_MouseButtonAdjust          0x001
#define Wimp_MouseButtonMenu            0x002
#define Wimp_MouseButtonSelect          0x004

typedef struct
{
    BBox bbox;

} WimpUserDragBoxEvent;



typedef struct
{
    WimpCaret caret;
    int       key_code;

} WimpKeyPressedEvent;



typedef WimpMenuSelections WimpMenuSelectionEvent;



typedef struct
{
    WimpOpenWindowBlock  open;
    int                  xscroll;
    int                  yscroll;

} WimpScrollRequestEvent;



typedef WimpCaret WimpLoseCaretEvent;



typedef WimpCaret WimpGainCaretEvent;



typedef struct
{
    void  *poll_word;
    int    poll_word_contents;

} WimpPollWordNonZeroEvent;



typedef WimpMessage WimpUserMessageEvent,
                    WimpUserMessageRecordedEvent,
                    WimpUserMessageAcknowledgeEvent;




/* generic block passed to SWI Wimp_Poll in r1.  The Wimp will fill in this
 * block with event-specific data.
 */

typedef union
{
    int                             words[64];
    char                            bytes[256];
    WimpRedrawWindowRequestEvent    redraw_window_request;
    WimpOpenWindowRequestEvent      open_window_request;
    WimpCloseWindowRequestEvent     close_window_request;
    WimpPointerLeavingWindowEvent   pointer_leaving_window;
    WimpPointerEnteringWindowEvent  pointer_entering_window;
    WimpMouseClickEvent             mouse_click;
    WimpUserDragBoxEvent            user_drag_box;
    WimpKeyPressedEvent             key_pressed;
    WimpMenuSelectionEvent          menu_selection;
    WimpScrollRequestEvent          scroll_request;
    WimpLoseCaretEvent              lose_caret;
    WimpGainCaretEvent              gain_caret;
    WimpPollWordNonZeroEvent        poll_word_non_zero;
    WimpUserMessageEvent            user_message;
    WimpUserMessageRecordedEvent    user_message_recorded;
    WimpUserMessageAcknowledgeEvent user_message_acknowledge;

} WimpPollBlock;











#endif