#ifndef INTUITION_INTUITION_H
#define INTUITION_INTUITION_H TRUE
#ifndef EXEC_TYPES_H
#include "exec/types.h"
#endif
#ifndef GRAPHICS_GFX_H
#include "graphics/gfx.h"
#endif
#ifndef GRAPHICS_CLIP_H
#include "graphics/clip.h"
#endif
#ifndef GRAPHICS_VIEW_H
#include "graphics/view.h"
#endif
#ifndef GRAPHICS_RASTPORT_H
#include "graphics/rastport.h"
#endif
#ifndef GRAPHICS_LAYERS_H
#include "graphics/layers.h"
#endif
#ifndef GRAPHICS_TEXT_H
#include "graphics/text.h"
#endif
#ifndef EXEC_PORTS_H
#include "exec/ports.h"
#endif
#ifndef DEVICES_TIMER_H
#include "devices/timer.h"
#endif
#ifndef DEVICES_INPUTEVENT_H
#include "devices/inputevent.h"
#endif
struct Menu
{
    struct Menu *NextMenu;
    SHORT LeftEdge, TopEdge;
    SHORT Width, Height;
    USHORT Flags;
    BYTE *MenuName;
    struct MenuItem *FirstItem;
    SHORT JazzX, JazzY, BeatX, BeatY;
};
#define MENUENABLED 0x0001
#define MIDRAWN 0x0100
struct MenuItem
{
    struct MenuItem *NextItem;
    SHORT LeftEdge, TopEdge;
    SHORT Width, Height;
    USHORT Flags;
    LONG MutualExclude;
    APTR ItemFill;
    APTR SelectFill;
    BYTE Command;
    struct MenuItem *SubItem;
    USHORT NextSelect;
};
#define CHECKIT         0x0001
#define ITEMTEXT        0x0002
#define COMMSEQ         0x0004
#define MENUTOGGLE      0x0008
#define ITEMENABLED     0x0010
#define HIGHFLAGS       0x00C0
#define HIGHIMAGE       0x0000
#define HIGHCOMP        0x0040
#define HIGHBOX         0x0080
#define HIGHNONE        0x00C0
#define CHECKED         0x0100
#define ISDRAWN         0x1000
#define HIGHITEM        0x2000
#define MENUTOGGLED     0x4000

struct Requester
{
    struct Requester *OlderRequest;
    SHORT LeftEdge, TopEdge;
    SHORT Width, Height;
    SHORT RelLeft, RelTop;
    struct Gadget *ReqGadget;
    struct Border *ReqBorder;
    struct IntuiText *ReqText;
    USHORT Flags;
    UBYTE BackFill;
    struct Layer *ReqLayer;
    UBYTE ReqPad1[32];
    struct BitMap *ImageBMap;
    struct Window *RWindow;
    UBYTE ReqPad2[36];
};
#define POINTREL 0x0001
#define PREDRAWN 0x0002
#define NOISYREQ 0x0004
#define REQOFFWINDOW    0x1000
#define REQACTIVE       0x2000
#define SYSREQUEST      0x4000
#define DEFERREFRESH    0x8000
struct Gadget
{
    struct Gadget *NextGadget;
    SHORT LeftEdge, TopEdge;
    SHORT Width, Height;
    USHORT Flags;
    USHORT Activation;
    USHORT GadgetType;
    APTR GadgetRender;
    APTR SelectRender;
    struct IntuiText *GadgetText;
    LONG MutualExclude;
    APTR SpecialInfo;
    USHORT GadgetID;
    APTR UserData;
};
#define GADGHIGHBITS    0x0003
#define GADGHCOMP       0x0000
#define GADGHBOX        0x0001
#define GADGHIMAGE      0x0002
#define GADGHNONE       0x0003
#define GADGIMAGE 0x0004
#define GRELBOTTOM      0x0008
#define GRELRIGHT       0x0010
#define GRELWIDTH       0x0020
#define GRELHEIGHT      0x0040
#define SELECTED        0x0080
#define GADGDISABLED    0x0100
#define RELVERIFY       0x0001
#define GADGIMMEDIATE   0x0002
#define ENDGADGET       0x0004
#define FOLLOWMOUSE     0x0008
#define RIGHTBORDER     0x0010
#define LEFTBORDER      0x0020
#define TOPBORDER       0x0040
#define BOTTOMBORDER    0x0080
#define TOGGLESELECT    0x0100
#define STRINGCENTER    0x0200
#define STRINGRIGHT     0x0400
#define LONGINT         0x0800
#define ALTKEYMAP       0x1000
#define BOOLEXTEND      0x2000
#define GADGETTYPE      0xFC00
#define SYSGADGET       0x8000
#define SCRGADGET       0x4000
#define GZZGADGET       0x2000
#define REQGADGET       0x1000
#define SIZING          0x0010
#define WDRAGGING       0x0020
#define SDRAGGING       0x0030
#define WUPFRONT        0x0040
#define SUPFRONT        0x0050
#define WDOWNBACK       0x0060
#define SDOWNBACK       0x0070
#define CLOSE           0x0080
#define BOOLGADGET      0x0001
#define GADGET0002      0x0002
#define PROPGADGET      0x0003
#define STRGADGET       0x0004
struct BoolInfo
{
    USHORT Flags;
    UWORD  *Mask;
    ULONG  Reserved;
};
#define BOOLMASK        0x0001
struct PropInfo
{
    USHORT Flags;
    USHORT HorizPot;
    USHORT VertPot;
    USHORT HorizBody;
    USHORT VertBody;
    USHORT CWidth;
    USHORT CHeight;
    USHORT HPotRes, VPotRes;
    USHORT LeftBorder;
    USHORT TopBorder;
};
#define AUTOKNOB        0x0001
#define FREEHORIZ       0x0002
#define FREEVERT        0x0004
#define PROPBORDERLESS  0x0008
#define KNOBHIT         0x0100
#define KNOBHMIN        6
#define KNOBVMIN        4
#define MAXBODY         0xFFFF
#define MAXPOT          0xFFFF
struct StringInfo
{
    UBYTE *Buffer;
    UBYTE *UndoBuffer;
    SHORT BufferPos;
    SHORT MaxChars;
    SHORT DispPos;
    SHORT UndoPos;
    SHORT NumChars;
    SHORT DispCount;
    SHORT CLeft, CTop;
    struct Layer *LayerPtr;
    LONG LongInt;
    struct KeyMap *AltKeyMap;
};
struct IntuiText
{
    UBYTE FrontPen, BackPen;
    UBYTE DrawMode;
    SHORT LeftEdge;
    SHORT TopEdge;
    struct TextAttr *ITextFont;
    UBYTE *IText;
    struct IntuiText *NextText;
};
struct Border
{
    SHORT LeftEdge, TopEdge;
    UBYTE FrontPen, BackPen;
    UBYTE DrawMode;
    BYTE Count;
    SHORT *XY;
    struct Border *NextBorder;
};
struct Image
{
    SHORT LeftEdge;
    SHORT TopEdge;
    SHORT Width;
    SHORT Height, Depth;
    USHORT *ImageData;
    UBYTE PlanePick, PlaneOnOff;
    struct Image *NextImage;
};
struct IntuiMessage
{
    struct Message ExecMessage;
    ULONG Class;
    USHORT Code;
    USHORT Qualifier;
    APTR IAddress;
    SHORT MouseX, MouseY;
    ULONG Seconds, Micros;
    struct Window *IDCMPWindow;
    struct IntuiMessage *SpecialLink;
};
#define SIZEVERIFY              0x00000001
#define NEWSIZE                 0x00000002
#define REFRESHWINDOW           0x00000004
#define MOUSEBUTTONS            0x00000008
#define MOUSEMOVE               0x00000010
#define GADGETDOWN              0x00000020
#define GADGETUP                0x00000040
#define REQSET                  0x00000080
#define MENUPICK                0x00000100
#define CLOSEWINDOW             0x00000200
#define RAWKEY                  0x00000400
#define REQVERIFY               0x00000800
#define REQCLEAR                0x00001000
#define MENUVERIFY              0x00002000
#define NEWPREFS                0x00004000
#define DISKINSERTED            0x00008000
#define DISKREMOVED             0x00010000
#define WBENCHMESSAGE           0x00020000
#define ACTIVEWINDOW            0x00040000
#define INACTIVEWINDOW          0x00080000
#define DELTAMOVE               0x00100000
#define VANILLAKEY              0x00200000
#define INTUITICKS              0x00400000
#define LONELYMESSAGE   0x80000000
#define MENUHOT         0x0001
#define MENUCANCEL      0x0002
#define MENUWAITING     0x0003
#define OKOK            MENUHOT
#define OKABORT         0x0004
#define OKCANCEL        MENUCANCEL
#define WBENCHOPEN      0x0001
#define WBENCHCLOSE     0x0002
struct Window
{
    struct Window *NextWindow;
    SHORT LeftEdge, TopEdge;
    SHORT Width, Height;
    SHORT MouseY, MouseX;
    SHORT MinWidth, MinHeight;
    USHORT MaxWidth, MaxHeight;
    ULONG Flags;
    struct Menu *MenuStrip;
    UBYTE *Title;
    struct Requester *FirstRequest;
    struct Requester *DMRequest;
    SHORT ReqCount;
    struct Screen *WScreen;
    struct RastPort *RPort;
    BYTE BorderLeft, BorderTop, BorderRight, BorderBottom;
    struct RastPort *BorderRPort;
    struct Gadget *FirstGadget;
    struct Window *Parent, *Descendant;
    USHORT *Pointer;
    BYTE PtrHeight;
    BYTE PtrWidth;
    BYTE XOffset, YOffset;
    ULONG IDCMPFlags;
    struct MsgPort *UserPort, *WindowPort;
    struct IntuiMessage *MessageKey;
    UBYTE DetailPen, BlockPen;
    struct Image *CheckMark;
    UBYTE *ScreenTitle;
    SHORT GZZMouseX;
    SHORT GZZMouseY;
    SHORT GZZWidth;
    SHORT GZZHeight;
    UBYTE *ExtData;
    BYTE *UserData;
    struct Layer *WLayer;
    struct TextFont *IFont;
};
#define WINDOWSIZING    0x0001
#define WINDOWDRAG      0x0002
#define WINDOWDEPTH     0x0004
#define WINDOWCLOSE     0x0008
#define SIZEBRIGHT      0x0010
#define SIZEBBOTTOM     0x0020
#define REFRESHBITS     0x00C0
#define SMART_REFRESH   0x0000
#define SIMPLE_REFRESH  0x0040
#define SUPER_BITMAP    0x0080
#define OTHER_REFRESH   0x00C0
#define BACKDROP        0x0100
#define REPORTMOUSE     0x0200
#define GIMMEZEROZERO   0x0400
#define BORDERLESS      0x0800
#define ACTIVATE        0x1000
#define WINDOWACTIVE  0x2000
#define INREQUEST     0x4000
#define MENUSTATE     0x8000
#define RMBTRAP         0x00010000
#define NOCAREREFRESH   0x00020000
#define WINDOWREFRESH   0x01000000
#define WBENCHWINDOW    0x02000000
#define WINDOWTICKED    0x04000000
#define SUPER_UNUSED    0xFCFC0000
struct NewWindow
{
    SHORT LeftEdge, TopEdge;
    SHORT Width, Height;
    UBYTE DetailPen, BlockPen;
    ULONG IDCMPFlags;
    ULONG Flags;
    struct Gadget *FirstGadget;
    struct Image *CheckMark;
    UBYTE *Title;
    struct Screen *Screen;
    struct BitMap *BitMap;
    SHORT MinWidth, MinHeight;
    USHORT MaxWidth, MaxHeight;
    USHORT Type;
};
struct Screen
{
    struct Screen *NextScreen;
    struct Window *FirstWindow;
    SHORT LeftEdge, TopEdge;
    SHORT Width, Height;
    SHORT MouseY, MouseX;
    USHORT Flags;
    UBYTE *Title;
    UBYTE *DefaultTitle;
    BYTE BarHeight, BarVBorder, BarHBorder, MenuVBorder, MenuHBorder;
    BYTE WBorTop, WBorLeft, WBorRight, WBorBottom;
    struct TextAttr *Font;
    struct ViewPort ViewPort;
    struct RastPort RastPort;
    struct BitMap BitMap;
    struct Layer_Info LayerInfo;
    struct Gadget *FirstGadget;
    UBYTE DetailPen, BlockPen;
    USHORT SaveColor0;
    struct Layer *BarLayer;
    UBYTE *ExtData;
    UBYTE *UserData;
};
#define SCREENTYPE      0x000F
#define WBENCHSCREEN    0x0001
#define CUSTOMSCREEN    0x000F
#define SHOWTITLE       0x0010
#define BEEPING         0x0020
#define CUSTOMBITMAP    0x0040
#define SCREENBEHIND    0x0080
#define SCREENQUIET     0x0100
#define STDSCREENHEIGHT -1
struct NewScreen
{
    SHORT LeftEdge, TopEdge, Width, Height, Depth;
    UBYTE DetailPen, BlockPen;
    USHORT ViewModes;
    USHORT Type;
    struct TextAttr *Font;
    UBYTE *DefaultTitle;
    struct Gadget *Gadgets;
    struct BitMap *CustomBitMap;
};
#define FILENAME_SIZE   30
#define POINTERSIZE (1 + 16 + 1) * 2
#define TOPAZ_EIGHTY 8
#define TOPAZ_SIXTY 9
struct Preferences
{
    BYTE FontHeight;
    UBYTE PrinterPort;
    USHORT BaudRate;
    struct timeval KeyRptSpeed;
    struct timeval KeyRptDelay;
    struct timeval DoubleClick;
    USHORT PointerMatrix[POINTERSIZE];
    BYTE XOffset;
    BYTE YOffset;
    USHORT color17;
    USHORT color18;
    USHORT color19;
    USHORT PointerTicks;
    USHORT color0;
    USHORT color1;
    USHORT color2;
    USHORT color3;
    BYTE ViewXOffset;
    BYTE ViewYOffset;
    WORD ViewInitX, ViewInitY;
    BOOL EnableCLI;
    USHORT PrinterType;
    UBYTE PrinterFilename[FILENAME_SIZE];
    USHORT PrintPitch;
    USHORT PrintQuality;
    USHORT PrintSpacing;
    UWORD PrintLeftMargin;
    UWORD PrintRightMargin;
    USHORT PrintImage;
    USHORT PrintAspect;
    USHORT PrintShade;
    WORD PrintThreshold;
    USHORT PaperSize;
    UWORD PaperLength;
    USHORT PaperType;
    UBYTE   SerRWBits;
    UBYTE   SerStopBuf;
    UBYTE   SerParShk;
    UBYTE   LaceWB;
    UBYTE   WorkName[FILENAME_SIZE];
    BYTE    RowSizeChange;
    BYTE    ColumnSizeChange;
    BYTE    padding[14];
};
#define LACEWB 0x01
#define PARALLEL_PRINTER 0x00
#define SERIAL_PRINTER  0x01
#define BAUD_110        0x00
#define BAUD_300        0x01
#define BAUD_1200       0x02
#define BAUD_2400       0x03
#define BAUD_4800       0x04
#define BAUD_9600       0x05
#define BAUD_19200      0x06
#define BAUD_MIDI       0x07
#define FANFOLD         0x00
#define SINGLE          0x80
#define PICA            0x000
#define ELITE           0x400
#define FINE            0x800
#define DRAFT           0x000
#define LETTER          0x100
#define SIX_LPI         0x000
#define EIGHT_LPI       0x200
#define IMAGE_POSITIVE  0x00
#define IMAGE_NEGATIVE  0x01
#define ASPECT_HORIZ    0x00
#define ASPECT_VERT     0x01
#define SHADE_BW        0x00
#define SHADE_GREYSCALE 0x01
#define SHADE_COLOR     0x02
#define US_LETTER       0x00
#define US_LEGAL        0x10
#define N_TRACTOR       0x20
#define W_TRACTOR       0x30
#define CUSTOM          0x40
#define CUSTOM_NAME             0x00
#define ALPHA_P_101             0x01
#define BROTHER_15XL            0x02
#define CBM_MPS1000             0x03
#define DIAB_630                0x04
#define DIAB_ADV_D25            0x05
#define DIAB_C_150              0x06
#define EPSON                   0x07
#define EPSON_JX_80             0x08
#define OKIMATE_20              0x09
#define QUME_LP_20              0x0A
#define HP_LASERJET             0x0B
#define HP_LASERJET_PLUS        0x0C
#define SBUF_512        0x00
#define SBUF_1024       0x01
#define SBUF_2048       0x02
#define SBUF_4096       0x03
#define SBUF_8000       0x04
#define SBUF_16000      0x05
#define SREAD_BITS      0xF0
#define SWRITE_BITS     0x0F
#define SSTOP_BITS      0xF0
#define SBUFSIZE_BITS   0x0F
#define SPARITY_BITS    0xF0
#define SPARITY_NONE     0
#define SPARITY_EVEN     1
#define SPARITY_ODD      2
#define SHSHAKE_XON      0
#define SHSHAKE_RTS      1
#define SHSHAKE_NONE     2
struct Remember
{
    struct Remember *NextRemember;
    ULONG RememberSize;
    UBYTE *Memory;
};
#define MENUNUM(n) (n & 0x1F)
#define ITEMNUM(n) ((n >> 5) & 0x003F)
#define SUBNUM(n) ((n >> 11) & 0x001F)
#define SHIFTMENU(n) (n & 0x1F)
#define SHIFTITEM(n) ((n & 0x3F) << 5)
#define SHIFTSUB(n) ((n & 0x1F) << 11)
#define SRBNUM(n)    (0x08 - (n >> 4))
#define SWBNUM(n)    (0x08 - (n & 0x0F))
#define SSBNUM(n)    (0x01 + (n >> 4))
#define SPARNUM(n)   (n >> 4)
#define SHAKNUM(n)   (n & 0x0F)
#define NOMENU 0x001F
#define NOITEM 0x003F
#define NOSUB  0x001F
#define MENUNULL 0xFFFF
#define FOREVER for(;;)
#define SIGN(x) ( ((x) > 0) - ((x) < 0) )
#define NOT !
#define CHECKWIDTH      19
#define COMMWIDTH       27
#define LOWCHECKWIDTH   13
#define LOWCOMMWIDTH    16
#define ALERT_TYPE      0x80000000
#define RECOVERY_ALERT  0x00000000
#define DEADEND_ALERT   0x80000000
#define AUTOFRONTPEN    0
#define AUTOBACKPEN     1
#define AUTODRAWMODE    JAM2
#define AUTOLEFTEDGE    6
#define AUTOTOPEDGE     3
#define AUTOITEXTFONT   NULL
#define AUTONEXTTEXT    NULL
#define SELECTUP        (IECODE_LBUTTON | IECODE_UP_PREFIX)
#define SELECTDOWN      (IECODE_LBUTTON)
#define MENUUP          (IECODE_RBUTTON | IECODE_UP_PREFIX)
#define MENUDOWN        (IECODE_RBUTTON)
#define ALTLEFT         (IEQUALIFIER_LALT)
#define ALTRIGHT        (IEQUALIFIER_RALT)
#define AMIGALEFT       (IEQUALIFIER_LCOMMAND)
#define AMIGARIGHT      (IEQUALIFIER_RCOMMAND)
#define AMIGAKEYS       (AMIGALEFT | AMIGARIGHT)
#define CURSORUP        0x4C
#define CURSORLEFT      0x4F
#define CURSORRIGHT     0x4E
#define CURSORDOWN      0x4D
#define KEYCODE_Q       0x10
#define KEYCODE_X       0x32
#define KEYCODE_N       0x36
#define KEYCODE_M       0x37
#define KEYCODE_V       0x34
#define KEYCODE_B       0x35
#endif
