home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Club Amiga de Montreal - CAM
/
CAM_CD_1.iso
/
files
/
581a.lha
/
IntuitionSupLibrary_v2.0
/
Gadgets
/
source.lzh
/
gadgets.h
< prev
next >
Wrap
C/C++ Source or Header
|
1991-10-25
|
12KB
|
304 lines
/*************************************
* *
* Gadgets v2.0 *
* by Torsten Jürgeleit in 05/91 *
* *
* Defines, structs and protos *
* *
*************************************/
#ifndef GADGET_LIST_H
#define GADGET_LIST_H
/* Defines for gadgets */
#define ISUP_ID ((ULONG)'I' << 24 | (ULONG)'S' << 16 | 'U' << 8 | 'P')
#define GADGET_DATA_TYPE_BUTTON 1 /* button gadget */
#define GADGET_DATA_TYPE_CHECK 2 /* check mark gadget */
#define GADGET_DATA_TYPE_MX 3 /* mutual exclude gadget */
#define GADGET_DATA_TYPE_STRING 4 /* string input gadget */
#define GADGET_DATA_TYPE_INTEGER 5 /* integer input gadget */
#define GADGET_DATA_TYPE_SLIDER 6 /* slider gadget */
#define GADGET_DATA_TYPE_SCROLLER 7 /* scroller gadget */
#define GADGET_DATA_TYPE_CYCLE 8 /* cycle gadget */
#define GADGET_DATA_TYPE_COUNT 9 /* count gadget */
#define GADGET_DATA_TYPE_LISTVIEW 10 /* list view gadget */
#define GADGET_DATA_TYPE_PALETTE 11 /* palette gadget */
#define MAX_GADGET_DATA_TYPE GADGET_DATA_TYPE_PALETTE
#define GADGET_DATA_FLAG_DISABLED (1L << 0) /* gadget disabled (ghosted) - default enabled */
#define GADGET_DATA_FLAG_NO_BORDER (1L << 1) /* no gadget border - default with border */
#define GADGET_DATA_FLAG_HIGH_COMP (1L << 2) /* highliting by complement - default by select border */
#define GADGET_DATA_FLAG_ORIENTATION_VERT (1L << 3) /* vertical orientation - default horizontal */
#define GADGET_DATA_FLAG_HOT_KEY (1L << 4) /* hot key given - default none */
#define GADGET_DATA_FLAG_TEXT_LEFT (1L << 5) /* place text left of gadget */
#define GADGET_DATA_FLAG_TEXT_RIGHT (1L << 6) /* place text right of gadget */
#define GADGET_DATA_FLAG_TEXT_ABOVE (1L << 7) /* place text above of gadget */
#define GADGET_DATA_FLAG_TEXT_BELOW (1L << 8) /* place text below of gadget */
#define GADGET_DATA_FLAG_TEXT_COLOR2 (1L << 9) /* use 2nd text render pen for gadget text */
#define GADGET_DATA_FLAG_BUTTON_TOGGLE (1L << 10) /* button gadgets: toggle button - default no toggle */
#define GADGET_DATA_FLAG_BUTTON_IMAGE (1L << 11) /* button gadgets: render image - default no image */
#define GADGET_DATA_FLAG_INPUT_AUTO_ACTIVATE (1L << 12) /* input gadgets: acivate after GADGETUP next or previous input gadget */
#define GADGET_DATA_FLAG_STRING_UNSIGNED_DEC (1L << 13) /* string gadgets: input default no pointer to string but an unsigned decimal number */
#define GADGET_DATA_FLAG_STRING_SIGNED_DEC (1L << 14) /* string gadgets: input default no pointer to string but an signed decimal number */
#define GADGET_DATA_FLAG_STRING_HEX (1L << 15) /* string gadgets: input default no pointer to string but an hex number */
#define GADGET_DATA_FLAG_STRING_BIN (1L << 16) /* string gadgets: input default no pointer to string but an binary number */
#define GADGET_DATA_FLAG_SCROLLER_NO_ARROWS (1L << 17) /* scroller gadget: no arrows - default with arrows */
#define GADGET_DATA_FLAG_COUNT_SIGNED_DEC (1L << 18) /* count gadget: signed dec - default unsigned dec */
#define GADGET_DATA_FLAG_LISTVIEW_READ_ONLY (1L << 19) /* list view gadget: read only - default selection enabled */
#define GADGET_DATA_FLAG_PALETTE_NO_INDICATOR (1L << 20) /* palette gadget: no current color indicator - default with indicator */
#define GADGET_DATA_FLAG_PALETTE_INDICATOR_TOP (1L << 21) /* palette gadget: place indicator at top - default at left */
#define GADGET_IDCMP_FLAGS_BUTTON (GADGETUP | VANILLAKEY)
#define GADGET_IDCMP_FLAGS_CHECK (GADGETDOWN | VANILLAKEY)
#define GADGET_IDCMP_FLAGS_MX (GADGETDOWN | VANILLAKEY)
#define GADGET_IDCMP_FLAGS_STRING (GADGETUP | VANILLAKEY)
#define GADGET_IDCMP_FLAGS_INTEGER (GADGETUP | VANILLAKEY)
#define GADGET_IDCMP_FLAGS_SLIDER (GADGETUP | MOUSEMOVE | VANILLAKEY)
#define GADGET_IDCMP_FLAGS_SCROLLER (GADGETDOWN | GADGETUP | MOUSEMOVE | INTUITICKS | VANILLAKEY)
#define GADGET_IDCMP_FLAGS_CYCLE (GADGETUP | VANILLAKEY)
#define GADGET_IDCMP_FLAGS_COUNT (GADGETDOWN | GADGETUP | MOUSEMOVE | VANILLAKEY)
#define GADGET_IDCMP_FLAGS_LISTVIEW (GADGETDOWN | GADGETUP | MOUSEMOVE | INTUITICKS | VANILLAKEY)
#define GADGET_IDCMP_FLAGS_PALETTE (GADGETUP | VANILLAKEY)
#define GADGET_IDCMP_FLAGS_ALL (GADGETDOWN | GADGETUP | MOUSEMOVE | INTUITICKS | VANILLAKEY)
#define GADGET_LIST_FLAG_DISPLAYED (1 << 0) /* gadget list currently displayed */
#define EXTENDED_GADGET_TYPE_BUTTON 1
#define EXTENDED_GADGET_TYPE_CHECK 2
#define EXTENDED_GADGET_TYPE_MX 3
#define EXTENDED_GADGET_TYPE_STRING 4
#define EXTENDED_GADGET_TYPE_INTEGER 5
#define EXTENDED_GADGET_TYPE_SLIDER_PROP 6
#define EXTENDED_GADGET_TYPE_SCROLLER_PROP 7
#define EXTENDED_GADGET_TYPE_SCROLLER_LEFT 8
#define EXTENDED_GADGET_TYPE_SCROLLER_RIGHT 9
#define EXTENDED_GADGET_TYPE_SCROLLER_UP 10
#define EXTENDED_GADGET_TYPE_SCROLLER_DOWN 11
#define EXTENDED_GADGET_TYPE_CYCLE 12
#define EXTENDED_GADGET_TYPE_COUNT 13
#define EXTENDED_GADGET_TYPE_LISTVIEW_PROP 14
#define EXTENDED_GADGET_TYPE_LISTVIEW_UP 15
#define EXTENDED_GADGET_TYPE_LISTVIEW_DOWN 16
#define EXTENDED_GADGET_TYPE_LISTVIEW_ENTRY 17
#define EXTENDED_GADGET_TYPE_PALETTE_INDICATOR 18
#define EXTENDED_GADGET_TYPE_PALETTE_COLOR 19
#define EXTENDED_GADGET_FLAG_HOT_KEY (1 << 0)
#define EXTENDED_GADGET_FLAG_RENDER_BORDER (1 << 1)
#define EXTENDED_GADGET_FLAG_RENDER_IMAGE (1 << 2)
#define EXTENDED_GADGET_FLAG_NORMAL_IMAGE_COPY (1 << 3)
#define EXTENDED_GADGET_FLAG_SELECT_IMAGE_COPY (1 << 4)
#define USE_CURRENT_VALUE ~0L /* used for set_gadget_attributes() to indicate data for which to use the current value */
/* Defines for internal use only */
#define ARROW_AUTO_REPEAT_START_DELAY 3
#define MAX_COUNT_DELAY 5
#define MAX_COUNT_STEP_SIZE 20
#define MAX_COUNT_DISTANCE (MAX_COUNT_DELAY * MAX_COUNT_STEP_SIZE)
#define MIN_COUNT_DELAY_MICROS 30000L
#define MAX_DEC_NUM_DIGITS 10
#define MAX_BIN_NUM_DIGITS 32
/* Structures */
struct VisibleGadgetLists {
struct SignalSemaphore vg_Semaphore;
struct MinList vg_MinList;
USHORT vg_Count;
};
struct GadgetList {
struct MinNode gl_MinNode; /* node to insert GadgetList into VisibleGadgetLists list */
struct RenderInfo *gl_RenderInfo;
struct Window *gl_Window;
struct GadgetData *gl_Data;
USHORT gl_DataEntries;
UBYTE gl_Flags;
UBYTE gl_AutoRepeatDelay; /* delay counter for start of auto repeat for active arrow gadget */
BYTE *gl_GadgetBuffer;
ULONG gl_GadgetBufferSize;
BYTE *gl_ImageBuffer;
ULONG gl_ImageBufferSize;
struct ExtendedGadget *gl_ActiveGadget;
struct ExtendedGadget *gl_Gadgets[1]; /* array with gl_DataEntries ptr to extended gadgets */
};
struct GadgetData {
ULONG gd_Type;
ULONG gd_Flags;
USHORT gd_LeftEdge;
USHORT gd_TopEdge;
USHORT gd_Width;
USHORT gd_Height;
BYTE *gd_Text;
struct TextAttr *gd_TextAttr;
union {
struct { /* standard data struct */
LONG gd_Data1;
LONG gd_Data2;
VOID *gd_Data3;
} gd_Data;
struct { /* for button gadgets */
ULONG gd_ButtonSelected; /* selection state for toggle buttons - ZERO = unselected, non ZERO = selected */
struct Image *gd_ButtonNormalRender; /* normal render image */
struct Image *gd_ButtonSelectRender; /* select render image */
} gd_ButtonData;
struct { /* for check gadgets */
ULONG gd_CheckSelected; /* selection state - ZERO = unselected, non ZERO = selected */
ULONG gd_CheckPad1;
ULONG gd_CheckPad2;
} gd_CheckData;
struct { /* for mutual exclude gadgets */
ULONG gd_MXSpacing; /* pixel spacing between MX gadgets */
ULONG gd_MXActiveEntry; /* num of active entry from text array */
BYTE **gd_MXTextArray; /* ptr to MX text ptr array */
} gd_MXData;
struct { /* for string and integer gadgets */
ULONG gd_InputLen; /* len of input buffer */
USHORT gd_InputActivateNext; /* num of next string/num gadget to activate */
USHORT gd_InputActivatePrev; /* num of previous string/num gadget to activate */
BYTE *gd_InputDefault; /* string: default text [syntax: "text"] */
/* integer: default number [syntax: (VOID *)num] */
} gd_InputData;
struct { /* for slider gadgets */
LONG gd_SliderMin; /* min level */
LONG gd_SliderMax; /* max level */
LONG gd_SliderLevel; /* current slider level */
} gd_SliderData;
struct { /* for scroller gadgets */
ULONG gd_ScrollerVisible; /* visible entries */
ULONG gd_ScrollerTotal; /* total entries */
ULONG gd_ScrollerTop; /* current top entry */
} gd_ScrollerData;
struct { /* for cycle gadget */
ULONG gd_CyclePad;
ULONG gd_CycleActive; /* num of current cycle text ptr array entry */
BYTE **gd_CycleTextArray; /* ptr to cycle text ptr array */
} gd_CycleData;
struct { /* for count gadget */
ULONG gd_CountMin; /* min value */
ULONG gd_CountMax; /* max value */
ULONG gd_CountValue; /* current count value */
} gd_CountData;
struct { /* for list view gadget */
ULONG gd_ListViewSpacing; /* pixel spacing between list view entries */
ULONG gd_ListViewTop; /* current top entry */
struct List *gd_ListViewList; /* current list ptr */
} gd_ListViewData;
struct { /* for palette gadget */
ULONG gd_PaletteDepth; /* num of bitplanes for palette */
ULONG gd_PaletteColorOffset; /* first color of palette */
ULONG gd_PaletteActiveColor; /* selected color */
} gd_PaletteData;
} gd_SpecialData;
};
struct MXData {
USHORT mx_TextEntries;
USHORT mx_ActiveEntry;
};
struct SliderData {
ULONG sl_Flags;
LONG sl_Min;
LONG sl_Max;
LONG sl_Level;
};
struct ScrollerData {
ULONG sc_Flags;
ULONG sc_Visible;
ULONG sc_Total;
ULONG sc_Top;
};
struct CycleData {
ULONG cy_Flags;
SHORT cy_LeftEdge;
SHORT cy_TopEdge;
USHORT cy_Width;
USHORT cy_Height;
struct TextAttr *cy_TextAttr;
BYTE **cy_TextArray;
BYTE *cy_ActiveText;
USHORT cy_TextEntries;
USHORT cy_ActiveEntry;
};
struct CountData {
ULONG co_Flags;
SHORT co_LeftEdge;
SHORT co_TopEdge;
USHORT co_Width;
USHORT co_Height;
struct TextAttr *co_TextAttr;
ULONG co_Min;
ULONG co_Max;
ULONG co_Value;
};
struct ListViewData {
ULONG lv_Flags;
SHORT lv_LeftEdge;
SHORT lv_TopEdge;
USHORT lv_Width;
USHORT lv_Height;
USHORT lv_VisibleEntries;
USHORT lv_EntryHeight;
struct TextAttr *lv_TextAttr;
struct List *lv_List;
struct Node *lv_TopNode;
USHORT lv_ListEntries;
USHORT lv_TopEntry;
};
struct PaletteData {
ULONG pd_Flags;
USHORT pd_MaxColors;
USHORT pd_ColorOffset;
ULONG pd_ActiveColor;
};
struct ExtendedGadget {
struct Gadget eg_Gadget;
USHORT eg_BorderWidth; /* needed by editor */
USHORT eg_BorderHeight; /* needed by editor */
UBYTE eg_Type; /* internal gadget type */
UBYTE eg_Flags; /* special flags, e.g render object type */
USHORT eg_DataEntry; /* ordinal number of entry in gl_Data array */
struct GadgetList *eg_GadgetList;
SHORT eg_TextLeftEdge;
SHORT eg_TextTopEdge;
BYTE *eg_Text;
USHORT eg_Hotkey; /* ASCII value of gadget hot key */
USHORT eg_HotkeyPos; /* pos of as hot key marked (underscore) char in gadget text */
APTR eg_Render; /* ptr to image or border - determined by eg_Flags */
struct ExtendedGadget *eg_NextGadget;
};
/* Global prototypes */
struct GadgetList *create_gadgets(struct RenderInfo *ri,
struct GadgetData *gd, SHORT hoffset, SHORT voffset);
VOID free_gadgets(struct GadgetList *gl);
VOID display_gadgets(struct Window *win, struct GadgetList *gl);
VOID refresh_gadgets(struct GadgetList *gl);
ULONG set_gadget_attributes(struct GadgetList *gl, USHORT data_entry,
ULONG flags, ULONG data1, ULONG data2, VOID *data3);
VOID activate_input_gadget(struct GadgetList *gl, USHORT data_entry);
struct Gadget *gadget_address(struct GadgetList *gl, USHORT data_entry);
VOID remove_gadgets(struct GadgetList *gl);
struct IntuiMessage *get_msg(struct MsgPort *uport);
VOID reply_msg(struct IntuiMessage *imsg);
/* Global pragmas */
#pragma regcall(create_gadgets(a0,a1,d0,d1))
#pragma regcall(free_gadgets(a0))
#pragma regcall(display_gadgets(a0,a1))
#pragma regcall(refresh_gadgets(a0))
#pragma regcall(set_gadget_attributes(a0,d0,d1,d2,d3,a1))
#pragma regcall(activate_input_gadget(a0,d0))
#pragma regcall(gadget_address(a0,d0))
#pragma regcall(remove_gadgets(a0))
#pragma regcall(get_msg(a0))
#pragma regcall(reply_msg(a0))
#endif