window 31.5 KB
Newer Older
Neil Turton's avatar
Neil Turton committed
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
/* Copyright 1996 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.
 */
/* File:    generic.h
 * Purpose: client-visible information for the Window Object class
 * Author:  Ian Johnson
 * History: 08-Dec-93: IDJ: created
 *          07-Mar-94: CSM: Added label justification mask
 *          17-Mar-94: CSM: Added LabelledBox_SpriteIsFilled flags
 *                          Allows sprite labels on boxes to be unfilled,
 *                          neater & allows tile to show through masked sprites.
 *          13-Jun-94: NK : Removed colour from slider (goes into flags)
 *
 */


#ifndef __window_h
#define __window_h

#ifndef __wimp_h
#include "twimp.h"
#endif

#ifndef __toolbox_h
#include "objects.toolbox.h"
#endif


#define Window_SWIChunkBase         0x82880
#define Window_ObjectClass          Window_SWIChunkBase
#define Window_ClassSWI             (Window_SWIChunkBase + 0)
#define Window_PostFilter           (Window_SWIChunkBase + 1)
#define Window_PreFilter            (Window_SWIChunkBase + 2)
#define Window_GetPointerInfo       (Window_SWIChunkBase + 3)
#define Window_WimpToToolbox        (Window_SWIChunkBase + 4)
#define Window_RegisterExternal     (Window_SWIChunkBase + 5)
#define Window_DeregisterExternal   (Window_SWIChunkBase + 6)
#define Window_SupportExternal      (Window_SWIChunkBase + 7)
#define Window_RegisterFilter       (Window_SWIChunkBase + 8)
#define Window_DeregisterFilter     (Window_SWIChunkBase + 9)
52 53
#define Window_EnumerateGadgets     (Window_SWIChunkBase +10)
#define Window_GadgetGetIconList    (Window_SWIChunkBase +11)
Neil Turton's avatar
Neil Turton committed
54 55 56

/* 'private ones' */

57 58
#define Window_InternalOp            (Window_SWIChunkBase + 32)
#define Window_PreSubMenuShow        (Window_SWIChunkBase + 61)
Neil Turton's avatar
Neil Turton committed
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
#define Window_ExtractGadgetInfo     (Window_SWIChunkBase + 62)
#define Window_PlotGadget            (Window_SWIChunkBase + 63)



/* --------------------------------------------- Gadgets --------------------------------------------- */

/* --------- generic gadgets -------- */

typedef struct
{
        int         flags;
        int         type;
        int         xmin,
                    ymin,
                    xmax,
                    ymax;
        ComponentID component_id;
        char       *help_message;
        int         max_help;

} GadgetHeader;

/* generic gadget flags */

#define Gadget_Faded         (1U<<31)
#define Gadget_AtBack        (1<<30)

/* generic gadget methods */

#define Gadget_Base                    64
#define Gadget_GetFlags                (Gadget_Base + 0)           /* 64 */
#define Gadget_SetFlags                (Gadget_Base + 1)           /* 65 */
#define Gadget_SetHelpMessage          (Gadget_Base + 2)           /* 66 */
#define Gadget_GetHelpMessage          (Gadget_Base + 3)           /* 67 */
#define Gadget_GetIconList             (Gadget_Base + 4)           /* 68 */
#define Gadget_SetFocus                (Gadget_Base + 5)           /* 69 */
#define Gadget_GetType                 (Gadget_Base + 6)           /* 70 */
#define Gadget_MoveGadget              (Gadget_Base + 7)           /* 71 */
#define Gadget_GetBBox                 (Gadget_Base + 8)           /* 72 */
#define Gadget_Max                     (Gadget_Base + 63)          /* 127 */



/* --------- Action Button ---------- */


/* template definition */

typedef struct
{
        char *text;
        int   max_text_len;
        char *click_show;
        int   event;

} ActionButton;

#define ActionButton_IsDefault            0x00000001
#define ActionButton_IsCancel             0x00000002
#define ActionButton_IsLocal              0x00000004
#define ActionButton_ClickShowTransient   0x00000008
Kevin Bracey's avatar
Kevin Bracey committed
121 122
#define ActionButton_ClickShowCentred     0x00000010
#define ActionButton_ClickShowAtPointer   0x00000020
Neil Turton's avatar
Neil Turton committed
123

Kevin Bracey's avatar
Kevin Bracey committed
124
#define ActionButtonValidFlags            0xC000003F
Neil Turton's avatar
Neil Turton committed
125 126 127 128 129 130 131 132 133 134

/* action button methods */

#define ActionButton_Base              (Gadget_Max + 1)             /* 128 */
#define ActionButton_SetText           (ActionButton_Base + 0)      /* 128 */
#define ActionButton_GetText           (ActionButton_Base + 1)      /* 129 */
#define ActionButton_SetEvent          (ActionButton_Base + 2)      /* 130 */
#define ActionButton_GetEvent          (ActionButton_Base + 3)      /* 131 */
#define ActionButton_SetClickShow      (ActionButton_Base + 4)      /* 132 */
#define ActionButton_GetClickShow      (ActionButton_Base + 5)      /* 133 */
Kevin Bracey's avatar
Kevin Bracey committed
135
#define ActionButton_SetFont           (ActionButton_Base + 6)      /* 134 */
Neil Turton's avatar
Neil Turton committed
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
#define ActionButton_Max               (ActionButton_Base + 63)     /* 191 */
#if (ActionButton_Base % 64 != 0)
#error "Gadget codes out of sync"
#endif


/* action button events */

#define ActionButton_Selected          (Window_SWIChunkBase + 1)

typedef struct
{
        ToolboxEventHeader hdr;
} ActionButtonSelectedEvent;

#define ActionButton_Selected_Adjust      0x00000001
#define ActionButton_Selected_Select      0x00000004
#define ActionButton_Selected_Default     0x00000008
#define ActionButton_Selected_Cancel      0x00000010
#define ActionButton_Selected_Local       0x00000020


/* --------- Option Button ---------- */


/* template definition */

typedef struct
{
        char *label;
        int   max_label_len;
        int   event;

} OptionButton;

#define OptionButton_GenerateStateChange   0x00000001
#define OptionButton_On                    0x00000004
#define OptionButtonValidFlags             0xC0000005

/* option button methods */

#define OptionButton_Base              (ActionButton_Max + 1)       /* 192 */
#define OptionButton_SetLabel          (OptionButton_Base + 0)      /* 192 */
#define OptionButton_GetLabel          (OptionButton_Base + 1)      /* 193 */
#define OptionButton_SetEvent          (OptionButton_Base + 2)      /* 194 */
#define OptionButton_GetEvent          (OptionButton_Base + 3)      /* 195 */
#define OptionButton_SetState          (OptionButton_Base + 4)      /* 196 */
#define OptionButton_GetState          (OptionButton_Base + 5)      /* 197 */
Kevin Bracey's avatar
Kevin Bracey committed
184
#define OptionButton_SetFont           (OptionButton_Base + 6)      /* 198 */
Neil Turton's avatar
Neil Turton committed
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
#define OptionButton_Max               (OptionButton_Base + 63)     /* 255 */
#if (OptionButton_Base % 64 != 0)
#error "Gadget codes out of sync"
#endif


/* option button events */

#define OptionButton_StateChanged      (Window_SWIChunkBase + 2)

typedef struct
{
        ToolboxEventHeader hdr;
        int                new_state;
} OptionButtonStateChangedEvent;

#define OptionButton_StateChanged_Adjust  0x00000001
#define OptionButton_StateChanged_Select  0x00000004



/* ---------- Labelled Box ---------- */


/* template definition */

typedef struct
{
        char *label;

} LabelledBox;

#define LabelledBox_Sprite          0x00000001
#define LabelledBox_SpriteIsFilled  0x00000002

#define LabelledBoxValidFlags       0xC0000003

/* labelled box methods */

#define LabelledBox_Base               (OptionButton_Max + 1)       /* 256 */
/* none defined yet */
#define LabelledBox_Max                (LabelledBox_Base + 63)      /* 319 */
#if (LabelledBox_Base % 64 != 0)
#error "Gadget codes out of sync"
#endif



/* -------------- Label ------------- */

/* template definition */

typedef struct
{
        char *label;

} Label;

/* Flags */

#define Label_NoBox         0x00000001
#define Label_LeftJustify   0x00000000
#define Label_RightJustify  0x00000002
#define Label_Centred       0x00000004

#define LabelValidFlags     0xC0000007

/* Flags mask */

#define Label_Justification 0x00000006 /* Bits 1-2 */


/* label methods */

#define Label_Base                     (LabelledBox_Max + 1)       /* 320 */
/* none defined yet */
#define Label_Max                      (Label_Base + 63)           /* 383 */
#if (Label_Base % 64 != 0)
#error "Gadget codes out of sync"
#endif



/* ---------- Radio Button ----------- */

/* template definition */

typedef struct
{
        int   group_number;
        char *label;
        int   max_label_len;
        int   event;

} RadioButton;


#define RadioButton_GenerateUserStateChanged  0x00000001
#define RadioButton_GenerateSetStateChanged   0x00000002
#define RadioButton_On                        0x00000004

#define RadioButtonValidFlags                 0xC0000005        /* set state event not supported */

/* radio button methods */

#define RadioButton_Base               (Label_Max + 1)              /* 384 */
#define RadioButton_SetLabel           (RadioButton_Base + 0)       /* 384 */
#define RadioButton_GetLabel           (RadioButton_Base + 1)       /* 385 */
#define RadioButton_SetEvent           (RadioButton_Base + 2)       /* 386 */
#define RadioButton_GetEvent           (RadioButton_Base + 3)       /* 387 */
#define RadioButton_SetState           (RadioButton_Base + 4)       /* 388 */
#define RadioButton_GetState           (RadioButton_Base + 5)       /* 389 */
Kevin Bracey's avatar
Kevin Bracey committed
297
#define RadioButton_SetFont            (RadioButton_Base + 6)       /* 390 */
Neil Turton's avatar
Neil Turton committed
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
#define RadioButton_Max                (RadioButton_Base + 63)      /* 447 */
#if (RadioButton_Base % 64 != 0)
#error "Gadget codes out of sync"
#endif


/* radio button events */

#define RadioButton_StateChanged        (Window_SWIChunkBase + 3)

typedef struct
{
        ToolboxEventHeader hdr;
        int                state;
        ComponentID        old_on_button;
} RadioButtonStateChangedEvent;

#define RadioButton_StateChanged_Adjust    0x00000001
#define RadioButton_StateChanged_Select    0x00000004



/* --------- Display Field ---------- */


/* template definition */

typedef struct
{
        char *text;
        int   max_text_len;

} DisplayField;

#define DisplayField_GenerateValueChanged 0x00000001
#define DisplayField_LeftJustify          0x00000000
#define DisplayField_RightJustify         0x00000002
#define DisplayField_Centred              0x00000004
#define DisplayField_Justification        0x00000006

#define DisplayFieldValidFlags            0xC0000006    /* value changed not supported */

/* display field methods */

#define DisplayField_Base              (RadioButton_Max + 1)        /* 448 */
#define DisplayField_SetValue          (DisplayField_Base + 0)      /* 448 */
#define DisplayField_GetValue          (DisplayField_Base + 1)      /* 449 */
#define DisplayField_SetFont           (DisplayField_Base + 2)      /* 450 */
#define DisplayField_GetFont           (DisplayField_Base + 3)      /* 451 */
#define DisplayField_Max               (DisplayField_Base + 63)     /* 511 */
#if (DisplayField_Base % 64 != 0)
#error "Gadget codes out of sync"
#endif


/* display field events */

/* Following event is NOT to be documented as unsupported in current release */

#define DisplayField_ValueChanged      (Window_SWIChunkBase + 4)

typedef struct
{
        ToolboxEventHeader hdr;
        char               string[sizeof(ToolboxEvent)-sizeof(ToolboxEventHeader)-sizeof(int)];
} DisplayFieldValueChangedEvent;

#define DisplayField_ValueChanged_TooLong  0x00000001



/* --------- Writable Field --------- */


/* template definition */

typedef struct
{
        char        *text;
        int          max_text_len;
        char        *allowable;
        int          max_allowable_len ;
        ComponentID  before;
        ComponentID  after;

} WritableField;

#define WritableField_GenerateUserValueChanged 0x00000001
#define WritableField_GenerateSetValueChanged  0x00000002
#define WritableField_LeftJustify              0x00000000
#define WritableField_RightJustify             0x00000004
#define WritableField_Centred                  0x00000008
#define WritableField_Justification            0x0000000C
#define WritableField_Password                 0x00000010

#define WritableFieldValidFlags                0xC000001D       /* set value event not supported */

/* writable field methods */

#define WritableField_Base             (DisplayField_Max + 1)       /* 512 */
#define WritableField_SetValue         (WritableField_Base + 0)     /* 512 */
#define WritableField_GetValue         (WritableField_Base + 1)     /* 513 */
#define WritableField_SetAllowable     (WritableField_Base + 2)     /* 514 */
#define WritableField_GetAllowable     (WritableField_Base + 3)     /* 515 */
#define WritableField_SetFont          (WritableField_Base + 4)     /* 516 */
#define WritableField_GetFont          (WritableField_Base + 5)     /* 517 */
#define WritableField_Max              (WritableField_Base + 63)    /* 575 */
#if (WritableField_Base % 64 != 0)
#error "Gadget codes out of sync"
#endif


/* writable fields */

#define WritableField_ValueChanged     (Window_SWIChunkBase + 5)

typedef struct
{
        ToolboxEventHeader hdr;
        char               string[sizeof(ToolboxEvent)-sizeof(ToolboxEventHeader)];
} WritableFieldValueChangedEvent;

#define WritableField_ValueChanged_TooLong  0x00000001



/* ------------ Slider -------------- */


/* template definition */

typedef struct
{
        int lower_bound,
            upper_bound,
            step_size,
            initial_value;

} Slider;

#define Slider_GenerateValueChangedEndOfDrag  0x00000001
#define Slider_GenerateValueChangedDuringDrag 0x00000002
#define Slider_GenerateSetValueChanged        0x00000004
#define Slider_Vertical                       0x00000008
#define Slider_Draggable                      0x00000010
#define Slider_BarColour                      0x0000f000
#define Slider_BarColourShift                 12
#define Slider_BackgroundColour               0x000f0000
#define Slider_BackgroundColourShift          16

#define SliderValidFlags                      0xC00ff01b        /* set value not supported */

/* slider methods */

#define Slider_Base                    (WritableField_Max + 1)      /* 576 */
#define Slider_SetValue                (Slider_Base + 0)            /* 576 */
#define Slider_GetValue                (Slider_Base + 1)            /* 577 */
#define Slider_SetBound                (Slider_Base + 2)            /* 578 */
#define Slider_GetBound                (Slider_Base + 3)            /* 579 */
#define Slider_SetColour               (Slider_Base + 4)            /* 580 */
#define Slider_GetColour               (Slider_Base + 5)            /* 581 */
#define Slider_Max                     (Slider_Base + 63)           /* 639 */
#if (Slider_Base % 64 != 0)
#error "Gadget codes out of sync"
#endif


/* slider events */

#define Slider_ValueChanged            (Window_SWIChunkBase + 6)

typedef struct
{
        ToolboxEventHeader hdr;
        int                new_value;
} SliderValueChangedEvent;

#define Slider_ValueChanged_EndOfDrag   0x00000001
#define Slider_ValueChanged_DuringDrag  0x00000002



/* ------------ Draggable ----------- */


/* template definition */

typedef struct
{
        char *text;
        int   max_text_len;
        char *sprite;
        int   max_sprite_len;

} Draggable;

#define Draggable_GenerateDragStarted         0x00000001
#define Draggable_Sprite                      0x00000002
#define Draggable_Text                        0x00000004
#define Draggable_TypeMask                    0x00000038
#define Draggable_TypeShift                   3
#define Draggable_ToolboxIds                  0x00000040
#define Draggable_HasDropShadow               0x00000080
#define Draggable_NotDithered                 0x00000100
#define DraggableValidFlags                   0xC00001df


/* draggable methods */

#define Draggable_Base                 (Slider_Max + 1)             /* 640 */
#define Draggable_SetSprite            (Draggable_Base + 0)         /* 640 */
#define Draggable_GetSprite            (Draggable_Base + 1)         /* 641 */
#define Draggable_SetText              (Draggable_Base + 2)         /* 642 */
#define Draggable_GetText              (Draggable_Base + 3)         /* 643 */
#define Draggable_SetState             (Draggable_Base + 4)         /* 644 */
#define Draggable_GetState             (Draggable_Base + 5)         /* 645 */
#define Draggable_Max                  (Draggable_Base + 63)        /* 703 */
#if (Draggable_Base % 64 != 0)
#error "Gadget codes out of sync"
#endif


/* draggable events */

#define Draggable_DragStarted          (Window_SWIChunkBase + 7)
#define Draggable_DragEnded            (Window_SWIChunkBase + 8)


typedef struct
{
        ToolboxEventHeader hdr;
} DraggableDragStartedEvent;

#define Draggable_DragStarted_Adjust  0x00000001
#define Draggable_DragStarted_Menu    0x00000002
#define Draggable_DragStarted_Select  0x00000004
#define Draggable_DragStarted_Shift   0x00000008
#define Draggable_DragStarted_Ctrl    0x00000010


typedef struct
{
        ToolboxEventHeader hdr;
        int                window_handle;
        int                icon_handle;
        int                x;
        int                y;
} DraggableDragEndedEvent;


/* -------------- PopUp ------------- */


/* template definition */

typedef struct
{
        char *menu;

} PopUp;

#define PopUp_GenerateAboutToBeShown          0x00000001

#define PopupMenuValidFlags                   0xC0000001

/* popup menu methods */

#define PopUp_Base                     (Draggable_Max + 1)          /* 704 */
#define PopUp_SetMenu                  (PopUp_Base + 0)             /* 704 */
#define PopUp_GetMenu                  (PopUp_Base + 1)             /* 705 */
#define PopUp_Max                      (PopUp_Base + 63)            /* 767 */
#if (PopUp_Base % 64 != 0)
#error "Gadget codes out of sync"
#endif


/* popup menu events */

#define PopUp_AboutToBeShown       (Window_SWIChunkBase + 11)

typedef struct
{
        ToolboxEventHeader hdr;
        ObjectID           menu_id;
        int                show_type;
        int                top_left_x;
        int                top_left_y;
}PopUpAboutToBeShownEvent;



/* ------------- Adjuster ----------- */


/* template definition */

typedef struct
{
        int dummy;

} Adjuster;

#define Adjuster_Increment                    0x00000000
#define Adjuster_Decrement                    0x00000001
#define Adjuster_UpDown                       0x00000002
#define Adjuster_LeftRight                    0x00000000

#define AdjusterValidFlags                    0xC0000003

/* adjuster arrow methods */

#define AdjusterArrow_Base             (PopUp_Max + 1)              /* 768 */
/* none defined yet */
#define AdjusterArrow_Max              (AdjusterArrow_Base + 63)    /* 831 */
#if (AdjusterArrow_Base % 64 != 0)
#error "Gadget codes out of sync"
#endif


/* adjuster arrow events */

#define Adjuster_Clicked           (Window_SWIChunkBase + 12)

typedef struct
{
        ToolboxEventHeader hdr;
        int                direction;
} AdjusterClickedEvent;

#define Adjuster_Clicked_Down      0x00000000
#define Adjuster_Clicked_Up        0x00000001



/* ------------ Number Range -------- */


/* template definition */

typedef struct
{
        int         lower_bound,
                    upper_bound,
                    step_size,
                    initial_value;
        int         precision;
        ComponentID before;
        ComponentID after;
        int         display_length;

} NumberRange;

#define NumberRange_GenerateUserValueChanged  0x00000001
#define NumberRange_GenerateSetValueChanged   0x00000002
#define NumberRange_Writable                  0x00000004
#define NumberRange_HasNumericalDisplay       0x00000008
#define NumberRange_Adjusters                 0x00000010
#define NumberRange_NoSlider                  0x00000000
#define NumberRange_SliderType                0x00000020
#define NumberRange_SliderRight              (NumberRange_SliderType * 1)
#define NumberRange_SliderLeft               (NumberRange_SliderType * 2)
#define NumberRange_LeftJustify               0x00000000
#define NumberRange_RightJustify              0x00000100
#define NumberRange_Centred                   0x00000200
#define NumberRange_Justification             0x00000300
#define NumberRange_SliderBarColour           0x00001000         /* multiply by desktop colour number */
#define NumberRange_SliderBackColour          0x00010000
#define NumberRange_SliderTypeMask            0x000000E0         /* room for expansion */

#define NumberRangeValidFlags                 0xC00ff37d

/* number range methods */

#define NumberRange_Base               (AdjusterArrow_Max + 1)      /* 832 */
#define NumberRange_SetValue           (NumberRange_Base + 0)       /* 832 */
#define NumberRange_GetValue           (NumberRange_Base + 1)       /* 833 */
#define NumberRange_SetBounds          (NumberRange_Base + 2)       /* 834 */
#define NumberRange_GetBounds          (NumberRange_Base + 3)       /* 835 */
#define NumberRange_GetComponents      (NumberRange_Base + 4)       /* 836 */
#define NumberRange_Max                (NumberRange_Base + 63)      /* 895 */
#if (NumberRange_Base % 64 != 0)
#error "Gadget codes out of sync"
#endif


/* number range events */

#define NumberRange_ValueChanged   (Window_SWIChunkBase + 13)

typedef struct
{
        ToolboxEventHeader hdr;
        int                new_value;
} NumberRangeValueChangedEvent;



/* ----------- String Set ----------- */


/* template definition */

typedef struct
{
        char *string_set;
        char *title;
        char *initial_selected_string;
        int   max_selected_string_len;
        char *allowable;
        int   max_allowable_len;
        ComponentID before;
        ComponentID after;

} StringSet;

#define StringSet_GenerateUserValueChanged  0x00000001
#define StringSet_GenerateSetValueChanged   0x00000002
#define StringSet_Writable                  0x00000004
#define StringSet_GenerateAboutToBeShown    0x00000008
#define StringSet_NoDisplay                 0x00000010
#define StringSet_LeftJustify               0x00000000
#define StringSet_RightJustify              0x00000020
#define StringSet_Centred                   0x00000040
#define StringSet_Justification             0x00000060

#define StringSetValidFlags                 0xC000007d


/* string set methods */

#define StringSet_Base                 (NumberRange_Max + 1)        /* 896 */
#define StringSet_SetAvailable         (StringSet_Base + 0)         /* 896 */
#define StringSet_GetAvailable         (StringSet_Base + 1)         /* 897 */
#define StringSet_SetSelected          (StringSet_Base + 2)         /* 898 */
#define StringSet_GetSelected          (StringSet_Base + 3)         /* 899 */
#define StringSet_SetAllowable         (StringSet_Base + 4)         /* 900 */
#define StringSet_GetAllowable         (StringSet_Base + 5)         /* 901 */
#define StringSet_GetComponents        (StringSet_Base + 6)         /* 902 */
Piers Wombwell's avatar
Piers Wombwell committed
736
#define StringSet_SetFont              (StringSet_Base + 7)         /* 903 */
Neil Turton's avatar
Neil Turton committed
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
#define StringSet_Max                  (StringSet_Base + 63)        /* 959 */
#if (StringSet_Base % 64 != 0)
#error "Gadget codes out of sync"
#endif


/* string set events */

#define StringSet_ValueChanged     (Window_SWIChunkBase + 14)
#define StringSet_AboutToBeShown   (Window_SWIChunkBase + 15)

typedef struct
{
        ToolboxEventHeader hdr;
        char               string[sizeof(ToolboxEvent)-sizeof(ToolboxEventHeader)];
} StringSetValueChangedEvent;

#define StringSet_ValueChanged_TooLong  0x00000001

typedef struct
{
        ToolboxEventHeader hdr;
} StringSetAboutToBeShownEvent;

/* ------------ Button Gadget ----------- */


/* template definition */

typedef struct
{
        int           button_flags;
        char          *value;
        int           max_value;
        char          *validation;
        int           max_validation;
} Button;

#define Button_TaskSpriteArea               0x00000001
#define Button_AllowMenuClicks              0x00000002

#define ButtonValidFlags                    0xC0000003

/* button methods */

#define Button_Base                  (StringSet_Max + 1)          /* 960 */
#define Button_GetFlags              (Button_Base + 0)          /* 960 */
#define Button_SetFlags              (Button_Base + 1)          /* 961 */
#define Button_SetValue              (Button_Base + 2)          /* 962 */
#define Button_GetValue              (Button_Base + 3)          /* 963 */
#define Button_SetValidation         (Button_Base + 4)          /* 964 */
#define Button_GetValidation         (Button_Base + 5)          /* 965 */
#define Button_SetFont               (Button_Base + 6)          /* 966 */
#define Button_GetFont               (Button_Base + 7)          /* 967 */
#define Button_Max                   (Button_Base + 63)         /* 1023 */
#if (Button_Base % 64 != 0)
#error "Gadget codes out of sync"
#endif

#if (Button_Base != 960)
#error "Gadgets out of sync"
#endif



/* ------------------------------------------- Windows -------------------------------------------------- */


/* template definition */

typedef struct
{
        int   flags;
        int   wimp_key_code;
        int   key_event;
        char *key_show;

} KeyBoardShortcut;


#define KeyBoardShortcut_ShowAsTransient    0x00000001
Kevin Bracey's avatar
Kevin Bracey committed
818 819
#define KeyBoardShortcut_ShowInCentre       0x00000002
#define KeyBoardShortcut_ShowAtPointer      0x00000004
Neil Turton's avatar
Neil Turton committed
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


typedef struct
{
        GadgetHeader hdr;

        union
        {
                ActionButton  action_button;
                OptionButton  option_button;
                LabelledBox   labelled_box;
                Label         label;
                RadioButton   radio_button;
                DisplayField  display_field;
                WritableField writable_field;
                Slider        slider;
                Draggable     draggable;
                PopUp         popup;
                Adjuster      adjuster;
                NumberRange   number_range;
                StringSet     string_set;
                Button        button;
        } data;

} Gadget;


typedef struct
{
        int               flags;
        char             *help_message;
        int               max_help;
        char             *pointer_shape;
        int               max_pointer_shape;
        int               pointer_x_hot;
        int               pointer_y_hot;
        char             *menu;
        int               num_keyboard_shortcuts;
        KeyBoardShortcut *keyboard_shortcuts;
        int               num_gadgets;
        Gadget           *gadgets;
        ComponentID       default_focus;
        int               show_event;
        int               hide_event;
        char             *toolbar_ibl;
        char             *toolbar_itl;
        char             *toolbar_ebl;
        char             *toolbar_etl;
        wimp_Window       window;
        /* shortcuts and gadgets are here in memory */

} WindowTemplate;


#define Window_GenerateAboutToBeShown        0x00000001
#define Window_AutoOpen                      0x00000002
#define Window_AutoClose                     0x00000004
#define Window_GenerateHasBeenHidden         0x00000008
#define Window_IsToolBar                     0x00000010

#define DontSetFocus                    -1
#define SetFocusToWindow                -2

#define Window_InternalBottomLeftToolbar      1
#define Window_InternalTopLeftToolbar         2
#define Window_ExternalBottomLeftToolbar      4
#define Window_ExternalTopLeftToolbar         8

/* Window methods */

#define Window_GetWimpHandle            0
#define Window_AddGadget                1
#define Window_RemoveGadget             2
#define Window_SetMenu                  3
#define Window_GetMenu                  4
#define Window_SetPointer               5
#define Window_GetPointer               6
#define Window_SetHelpMessage           7
#define Window_GetHelpMessage           8
#define Window_AddKeyboardShortcuts     9
#define Window_RemoveKeyboardShortcuts 10
#define Window_SetTitle                11
#define Window_GetTitle                12
#define Window_SetDefaultFocus         13
#define Window_GetDefaultFocus         14
#define Window_SetExtent               15
#define Window_GetExtent               16
#define Window_ForceRedraw             17
#define Window_SetToolBars             18
#define Window_GetToolBars             19

/* Window events */

#define Window_AboutToBeShown          (Window_SWIChunkBase + 0)


typedef struct
{
        wimp_Bbox     visible_area;          /* visible area coords */
        int           scx,
                      scy;                   /* scroll offsets */
        int           behind;                /* handle to open window behind */
Kevin Bracey's avatar
Kevin Bracey committed
922 923 924 925 926
	/* The following are only used with the extended Toolbox_ShowObject
	 * method (when Toolbox_ShowObject_AsSubWindow is set in flags) */
	unsigned int  window_flags;
	unsigned int  parent_window_handle;
	unsigned int  alignment_flags;
Neil Turton's avatar
Neil Turton committed
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
} WindowShowObjectBlock;


typedef struct
{
        ToolboxEventHeader           hdr;
        int                          r2;
        union
        {
            TopLeft                  top_left;
            WindowShowObjectBlock    full_spec;

        }                            r3;

} WindowAboutToBeShownEvent;

#define Window_HasBeenHidden          (Window_SWIChunkBase + 16)

typedef struct
{
        ToolboxEventHeader           hdr;

} WindowHasBeenHiddenEvent;

/* ----------------------------------------- Window Error Numbers ------------------------------------- */

#define Window_ErrorBase                (Program_Error | 0x0080a900)

#define Window_AllocFailed          (Window_ErrorBase+0x01)
#define Window_ShortBuffer          (Window_ErrorBase+0x02)
#define Window_BadVersion           (Window_ErrorBase+0x03)
#define Window_InvalidFlags         (Window_ErrorBase+0x04)
#define Window_TasksActive          (Window_ErrorBase+0x05)
#define Window_NoSuchTask           (Window_ErrorBase+0x11)
#define Window_NoSuchMethod         (Window_ErrorBase+0x12)
#define Window_NoSuchMiscOpMethod   (Window_ErrorBase+0x13)
#define Window_InvalidComponentID   (Window_ErrorBase+0x14)
#define Window_DuplicateComponentID (Window_ErrorBase+0x15)
#define Window_ReservedFlags        (Window_ErrorBase+0x16)
#define Window_NoGadgetsLeft        (Window_ErrorBase+0x17)
#define Window_NotToolbar           (Window_ErrorBase+0x18)
#define Window_InvalidGadgetType    (Window_ErrorBase+0x20)

/* types of gadget */

Neil Turton's avatar
Neil Turton committed
972 973 974 975 976 977 978 979 980 981 982 983 984
#define ActionButton_Type       ((sizeof(ActionButton) +sizeof(GadgetHeader)) << 16      | ActionButton_Base)
#define OptionButton_Type       ((sizeof(OptionButton) +sizeof(GadgetHeader)) << 16      | OptionButton_Base)
#define LabelledBox_Type        ((sizeof(LabelledBox) +sizeof(GadgetHeader)) << 16       | LabelledBox_Base)
#define RadioButton_Type        ((sizeof(RadioButton) +sizeof(GadgetHeader)) << 16       | RadioButton_Base)
#define DisplayField_Type       ((sizeof(DisplayField) +sizeof(GadgetHeader)) << 16      | DisplayField_Base)
#define WritableField_Type      ((sizeof(WritableField) +sizeof(GadgetHeader)) << 16     | WritableField_Base)
#define Slider_Type             ((sizeof(Slider) +sizeof(GadgetHeader)) << 16            | Slider_Base)
#define Draggable_Type          ((sizeof(Draggable) +sizeof(GadgetHeader)) << 16         | Draggable_Base)
#define PopUp_Type              ((sizeof(PopUp) +sizeof(GadgetHeader)) << 16             | PopUp_Base)
#define AdjusterArrow_Type      ((sizeof(Adjuster) +sizeof(GadgetHeader)) << 16          | AdjusterArrow_Base)
#define NumberRange_Type        ((sizeof(NumberRange) +sizeof(GadgetHeader)) << 16       | NumberRange_Base)
#define StringSet_Type          ((sizeof(StringSet) +sizeof(GadgetHeader)) << 16         | StringSet_Base)
#define Button_Type             ((sizeof(Button) +sizeof(GadgetHeader)) << 16            | Button_Base)
Neil Turton's avatar
Neil Turton committed
985 986 987 988 989 990 991 992 993 994

/* service calls */

#define Service_WindowModuleStarting    (Window_SWIChunkBase + 1)
#define Service_WindowModuleDying       (Window_SWIChunkBase + 2)
#define Service_GadgetRegistered        (Window_SWIChunkBase + 3)
#define Service_GadgetDeregistered      (Window_SWIChunkBase + 4)

#endif