Check for SYS/GL during library init. Reason is that
[AROS.git] / workbench / libs / gadtools / gadtools_intern.h
blobeb7c2103ecd9a474f4f942bed13a00feb8f7d2f5
1 #ifndef GADTOOLS_INTERN_H
2 #define GADTOOLS_INTERN_H
4 /*
5 Copyright © 1995-2011, The AROS Development Team. All rights reserved.
6 $Id$
8 Desc: Internal definitions for gadtools.library.
9 Lang: english
12 #ifndef EXEC_LIBRARIES_H
13 # include <exec/libraries.h>
14 #endif
15 #ifndef EXEC_SEMAPHORES_H
16 # include <exec/semaphores.h>
17 #endif
18 #ifndef DOS_DOS_H
19 # include <dos/dos.h>
20 #endif
21 #ifndef PROTO_GRAPHICS_H
22 # include <proto/graphics.h>
23 #endif
24 #ifndef GRAPHICS_GFXBASE_H
25 # include <graphics/gfxbase.h>
26 #endif
27 #ifndef PROTO_INTUITION_H
28 # include <proto/intuition.h>
29 #endif
30 #ifndef INTUITION_CLASSES_H
31 # include <intuition/classes.h>
32 #endif
33 #ifndef INTUITION_INTUITIONBASE_H
34 # include <intuition/intuitionbase.h>
35 #endif
36 #ifndef INTUITION_SCREENS_H
37 # include <intuition/screens.h>
38 #endif
39 #ifndef PROTO_UTILITY_H
40 # include <proto/utility.h>
41 #endif
42 #ifndef LIBRARIES_GADTOOLS_H
43 # include <libraries/gadtools.h>
44 #endif
45 #ifndef GADGETS_AROSMX_H
46 # include <gadgets/arosmx.h>
47 #endif
49 /* Needed for aros_print_not_implemented macro */
50 #include <aros/debug.h>
51 #include <aros/libcall.h>
52 #include <aros/asmcall.h>
54 /****************************************************************************************/
56 struct VisualInfo;
58 /* Some external stuff (gadtools_init.c) */
59 struct GadToolsBase_intern; /* prerefrence */
61 /* Internal prototypes */
62 struct IntuiText *makeitext(struct GadToolsBase_intern *GadToolsBase,
63 struct NewGadget *ng,
64 struct TagItem *taglist);
65 void freeitext(struct GadToolsBase_intern *GadToolsBase,
66 struct IntuiText *itext);
68 BOOL renderlabel(struct GadToolsBase_intern *GadToolsBase,
69 struct Gadget *gad, struct RastPort *rport, LONG labelplace);
70 void DoDisabledPattern(struct RastPort *rp, WORD x1, WORD y1, WORD x2, WORD y2,
71 WORD pen, struct GadToolsBase_intern *GadToolsBase);
73 /****************************************************************************************/
75 struct Gadget *makebutton(struct GadToolsBase_intern *GadToolsBase,
76 struct TagItem stdgadtags[],
77 struct VisualInfo *vi,
78 struct TagItem *taglist);
80 struct Gadget *makecheckbox(struct GadToolsBase_intern *GadToolsBase,
81 struct TagItem stdgadtags[],
82 struct VisualInfo *vi,
83 struct TagItem *taglist);
85 struct Gadget *makecycle(struct GadToolsBase_intern *GadToolsBase,
86 struct TagItem stdgadtags[],
87 struct VisualInfo *vi,
88 struct TextAttr *tattr,
89 struct TagItem *taglist);
91 struct Gadget *makemx(struct GadToolsBase_intern *GadToolsBase,
92 struct TagItem stdgadtags[],
93 struct VisualInfo *vi,
94 struct TextAttr *tattr,
95 struct TagItem *taglist);
97 struct Gadget *makepalette(struct GadToolsBase_intern *GadToolsBase,
98 struct TagItem stdgadtags[],
99 struct VisualInfo *vi,
100 const struct TagItem *taglist);
102 struct Gadget *maketext(struct GadToolsBase_intern *GadToolsBase,
103 struct TagItem stdgadtags[],
104 struct VisualInfo *vi,
105 struct TextAttr *tattr,
106 const struct TagItem *taglist);
108 struct Gadget *makenumber(struct GadToolsBase_intern *GadToolsBase,
109 struct TagItem stdgadtags[],
110 struct VisualInfo *vi,
111 struct TextAttr *tattr,
112 const struct TagItem *taglist);
115 struct Gadget *makeslider(struct GadToolsBase_intern *GadToolsBase,
116 struct TagItem stdgadtags[],
117 struct VisualInfo *vi,
118 struct TextAttr *tattr,
119 const struct TagItem *taglist);
121 struct Gadget *makescroller(struct GadToolsBase_intern *GadToolsBase,
122 struct TagItem stdgadtags[],
123 struct VisualInfo *vi,
124 const struct TagItem *taglist);
126 struct Gadget *makestring(struct GadToolsBase_intern *GadToolsBase,
127 struct TagItem stdgadtags[],
128 struct VisualInfo *vi,
129 struct TextAttr *tattr,
130 const struct TagItem *taglist);
132 struct Gadget *makeinteger(struct GadToolsBase_intern *GadToolsBase,
133 struct TagItem stdgadtags[],
134 struct VisualInfo *vi,
135 struct TextAttr *tattr,
136 const struct TagItem *taglist);
138 struct Gadget *makelistview(struct GadToolsBase_intern *GadToolsBase,
139 struct TagItem stdgadtags[],
140 struct VisualInfo *vi,
141 struct TextAttr *tattr,
142 const struct TagItem *taglist);
144 struct Gadget *makegeneric(struct GadToolsBase_intern *GadToolsBase,
145 struct TagItem stdgadtags[],
146 struct VisualInfo *vi,
147 struct TextAttr *tattr,
148 struct TagItem *taglist);
150 /****************************************************************************************/
152 /* Tags for the private gadtools classes */
154 #define GT_Dummy (TAG_USER)
156 #define GTA_Text_DispFunc (GT_Dummy + 1)
157 #define GTA_Text_Format (GT_Dummy + 2)
158 #define GTA_Arrow_Type (GT_Dummy + 3)
159 #define GTA_Arrow_Pulse (GT_Dummy + 4)
160 #define GTA_Arrow_Scroller (GT_Dummy + 5)
161 #define GTA_Scroller_Dec (GT_Dummy + 6)
162 #define GTA_Scroller_Inc (GT_Dummy + 7)
163 #define GTA_Listview_Scroller (GT_Dummy + 8)
164 #define GTA_GadgetKind (GT_Dummy + 9)
165 #define GTA_ChildGadgetKind (GT_Dummy + 10)
166 #define GTA_Scroller_ScrollerKind (GT_Dummy + 11)
167 #define GTA_Scroller_ArrowKind (GT_Dummy + 12)
168 #define GTA_Scroller_Arrow1 (GT_Dummy + 13)
169 #define GTA_Scroller_Arrow2 (GT_Dummy + 14)
170 #define GTA_Text_ParentGadget (GT_Dummy + 15)
172 /****************************************************************************************/
174 /* private gadget kinds */
176 #define _ARROW_KIND 100
178 /****************************************************************************************/
180 /* Some listview specific constants */
181 #define LV_BORDER_X 4
182 #define LV_BORDER_Y 3
184 #define LV_DEF_INTERNAL_SPACING 0
186 /****************************************************************************************/
188 /* Private MX tags */
190 #define GTMX_TickLabelPlace AROSMX_TickLabelPlace
191 #define GTMX_TickHeight AROSMX_TickHeight
193 /****************************************************************************************/
195 #define NEWMENUCODE TRUE
197 #if NEWMENUCODE
198 struct Menu * makemenutitle(struct NewMenu * newmenu,
199 UBYTE **MyMenuMemPtr,
200 struct TagItem * taglist);
202 struct MenuItem * makemenuitem(struct NewMenu * newmenu,
203 UBYTE **MyMenuMemPtr,
204 struct Image ***MyBarTablePtr,
205 BOOL is_image,
206 struct TagItem * taglist,
207 struct GadToolsBase_intern * GadToolsBase);
209 ULONG getmenutitlesize(struct NewMenu * newmenu,
210 struct TagItem * taglist);
211 ULONG getmenuitemsize(struct NewMenu * newmenu,
212 BOOL is_image,
213 struct TagItem * taglist,
214 struct GadToolsBase_intern * GadToolsBase);
216 #else
218 struct Menu * makemenutitle(struct NewMenu * newmenu,
219 struct TagItem * taglist);
221 struct MenuItem * makemenuitem(struct NewMenu * newmenu,
222 BOOL is_image,
223 struct TagItem * taglist,
224 struct GadToolsBase_intern * GadToolsBase);
225 #endif
226 void appendmenu(struct Menu * firstmenu,
227 struct Menu * lastmenu);
229 void appenditem(struct Menu * curmenu,
230 struct MenuItem * item);
232 void appendsubitem(struct MenuItem * curitem,
233 struct MenuItem * subitem);
235 void freeitems(struct MenuItem * mi, struct GadToolsBase_intern * GadToolsBase);
237 BOOL layoutmenuitems(struct MenuItem * menuitem,
238 struct VisualInfo * vi,
239 struct TagItem * taglist,
240 struct GadToolsBase_intern * GadToolsBase);
242 BOOL layoutsubitems(struct MenuItem * motheritem,
243 struct VisualInfo * vi,
244 struct TagItem * taglist,
245 struct GadToolsBase_intern * GadToolsBase);
247 BOOL is_menubarlabelclass_image(struct Image *im,
248 struct GadToolsBase_intern *GadToolsBase);
250 /****************************************************************************************/
252 struct GadToolsBase_intern
254 struct Library lib;
256 Class * buttonclass;
257 Class * textclass;
258 Class * sliderclass;
259 Class * scrollerclass;
260 Class * arrowclass;
261 Class * stringclass;
262 Class * listviewclass;
263 Class * checkboxclass;
264 Class * cycleclass;
265 Class * mxclass;
266 Class * paletteclass;
268 /* Semaphore to protect the bevel object. */
269 struct SignalSemaphore bevelsema;
270 /* Actually an Object *. The image used for bevel boxes. */
271 struct Image * bevel;
273 /* RenderHook for GTListView class */
274 struct Hook lv_RenderHook;
276 /* Seglist pointer */
277 BPTR gt_SegList;
279 /* Required libraies */
280 APTR gt_IntuitionBase;
281 APTR gt_UtilityBase;
282 APTR gt_GfxBase;
283 APTR gt_LayersBase;
286 /* extended intuimsg as used by GT_GetIMsg, GT_FilterIMsg, ... */
288 struct GT_ContextGadget;
290 struct GT_IntuiMessage
292 struct ExtIntuiMessage imsg;
293 struct IntuiMessage * origmsg;
294 struct GT_ContextGadget * contextgad;
295 BOOL wasalloced;
298 #define VI(x) ((struct VisualInfo *)x)
300 struct VisualInfo
302 struct Screen * vi_screen;
303 struct DrawInfo * vi_dri;
306 /* dummy gadget created by CreateContext */
308 struct GT_ContextGadget
310 struct ExtGadget gad;
311 IPTR magic;
312 IPTR magic2;
313 struct GT_IntuiMessage gtmsg;
314 struct Gadget *activegadget;
315 struct Gadget *parentgadget;
316 IPTR gadget_value;
317 IPTR gadgetkind;
318 IPTR childgadgetkind;
319 IPTR childinfo;
320 ULONG getattrtag;
321 ULONG setattrtag;
322 WORD scrollticker;
323 BOOL gtmsg_used;
324 BOOL killme;
327 struct GT_GenericGadget
329 struct ExtGadget gad;
330 IPTR magic;
331 IPTR magic2;
332 struct IntuiText *itext;
335 /****************************************************************************************/
337 #define CONTEXT_MAGIC ((IPTR)0x11223344)
338 #define CONTEXT_MAGIC2 ((IPTR)0x44332211)
340 #define GENERIC_MAGIC ((IPTR)0x11335577)
341 #define GENERIC_MAGIC2 ((IPTR)0x77553311)
343 /****************************************************************************************/
345 #define TAG_Left 0
346 #define TAG_Top 1
347 #define TAG_Width 2
348 #define TAG_Height 3
349 #define TAG_IText 4
350 #define TAG_LabelPlace 5
351 #define TAG_Previous 6
352 #define TAG_ID 7
353 #define TAG_DrawInfo 8
354 #define TAG_UserData 9
355 #define TAG_Num 10
358 #define TAG_Menu 0
359 #define TAG_TextAttr 1
360 #define TAG_NewLookMenus 2
361 #define TAG_CheckMark 3
362 #define TAG_AmigaKey 4
363 #define TAG_FrontPen 5
365 #define BORDERPROPSPACINGX 2
366 #define BORDERPROPSPACINGY 2
368 #define BORDERSTRINGSPACINGX 4
369 #define BORDERSTRINGSPACINGY 2
371 #define LV_SHOWSELECTED_NONE ((struct Gadget *)~0)
373 /****************************************************************************************/
375 #define GTB(gtb) ((struct GadToolsBase_intern *)gtb)
377 extern struct ExecBase *SysBase;
378 /* FIXME: Remove these #define xxxBase hacks
379 Do not use this in new code !
381 #define IntuitionBase (GTB(GadToolsBase)->gt_IntuitionBase)
382 #define UtilityBase (GTB(GadToolsBase)->gt_UtilityBase)
383 #define GfxBase (GTB(GadToolsBase)->gt_GfxBase)
384 #define LayersBase (GTB(GadToolsBase)->gt_LayersBase)
387 #ifdef __MORPHOS__
388 #define DeinitRastPort(x) ((void)0)
390 #define DoMethod(MyObject, tags...) \
391 ({ULONG _tags[] = { tags }; DoMethodA((MyObject), (APTR)_tags);})
393 #define CoerceMethod(MyClass, MyObject, tags...) \
394 ({ULONG _tags[] = { tags }; CoerceMethodA((MyClass), (MyObject), (APTR)_tags);})
396 #define DoSuperMethod(MyClass, MyObject, tags...) \
397 ({ULONG _tags[] = { tags }; DoSuperMethodA((MyClass), (MyObject), (APTR)_tags);})
399 /********************************************************************************/
400 /* imageclass.h AROS extensions */
402 #define SYSIA_WithBorder IA_FGPen /* default: TRUE */
403 #define SYSIA_Style IA_BGPen /* default: SYSISTYLE_NORMAL */
405 #define SYSISTYLE_NORMAL 0
406 #define SYSISTYLE_GADTOOLS 1 /* to get arrow images in gadtools look */
408 /********************************************************************************/
409 /* gadgetclass.h AROS extenstions */
411 /* This method is invoked to learn about the sizing requirements of your class,
412 before an object is created. This is AROS specific. */
413 #define GM_DOMAIN 7
414 struct gpDomain
416 STACKED ULONG MethodID; /* GM_DOMAIN */
417 STACKED struct GadgetInfo * gpd_GInfo; /* see <intuition/cghooks.h> */
418 STACKED struct RastPort * gpd_RPort; /* RastPort to calculate dimensions for. */
419 STACKED LONG gpd_Which; /* see below */
420 STACKED struct IBox gpd_Domain; /* Resulting domain. */
421 STACKED struct TagItem * gpd_Attrs; /* Additional attributes. None defined,
422 yet. */
425 /********************************************************************************/
427 /* gpd_Which */
428 #define GDOMAIN_MINIMUM 0 /* Calculate minimum size. */
429 #define GDOMAIN_NOMINAL 1 /* Calculate nominal size. */
430 #define GDOMAIN_MAXIMUM 2 /* Calculate maximum size. */
432 /********************************************************************************/
434 /* [IS.] (struct TextAttr *) TextAttr structure (see <graphics/text.h>) to
435 use for gadget rendering. This attribute is not directly supported by
436 GadgetClass. */
437 #define GA_TextAttr (GA_Dummy + 40)
439 /* [I..] (LONG) Choose the placing of the label. GadgetClass does not support
440 this directly. Its subclasses have to take care of that. For possible
441 values see below. */
442 #define GA_LabelPlace (GA_Dummy + 100)
445 /* Placetext values for GA_LabelPlace. */
446 #define GV_LabelPlace_In 1
447 #define GV_LabelPlace_Left 2
448 #define GV_LabelPlace_Right 3
449 #define GV_LabelPlace_Above 4
450 #define GV_LabelPlace_Below 5
452 /********************************************************************************/
454 #define MENUBARLABELCLASS "menubarlabelclass"
456 #define GTYP_GADTOOLS 0x0100
458 #define CORRECT_LISTVIEWHEIGHT TRUE
460 #else /*MorphOS*/
462 #define CORRECT_LISTVIEWHEIGHT FALSE
464 #endif
466 #define DEBUG_CREATECONTEXT(x) ;
467 #define DEBUG_CREATEGADGETA(x) ;
468 #define DEBUG_CREATEMENUSA(x) ;
469 #define DEBUG_CREATELISTVIEW(x) ;
470 #define DEBUG_CREATESCROLLER(x) ;
471 #define DEBUG_FREEGADGETS(x) ;
472 #define DEBUG_DUMPMENUS(x) ;
473 #define DEBUG_ALLOCMENUS(x) ;
474 #define DEBUG_FREEMENUS(x) ;
475 #define DEBUG_REFRESHWINDOW(x) ;
477 void DumpMenu(struct Menu *menu);
479 /* Structures for the class private data */
481 /* GTButton class */
482 struct ButtonData
484 struct DrawInfo *dri;
485 struct Image *frame;
488 /* GTText class */
489 struct TextData
491 struct DrawInfo *dri;
492 struct Gadget *parentgadget;
493 Object *frame;
494 STRPTR format;
495 IPTR toprint;
496 UBYTE frontpen;
497 UBYTE backpen;
498 UBYTE justification;
499 UBYTE flags;
500 struct TextFont *font;
501 UWORD maxnumberlength;
502 WORD gadgetkind;
503 IPTR (*dispfunc)(struct Gadget *, WORD);
504 UBYTE labelplace;
508 /* GTSlider class */
509 struct SliderData
511 Object *frame;
512 WORD min;
513 WORD max;
514 WORD level;
515 WORD freedom;
516 UBYTE labelplace;
519 /* GTScroller class */
520 struct ScrollerData
522 Object *frame;
523 struct Gadget *arrow1;
524 struct Gadget *arrow2;
525 WORD gadgetkind;
526 UBYTE labelplace;
529 /* GTArrow class */
530 struct ArrowData
532 Object *arrowimage;
533 Object *frame;
534 Object *scroller;
535 WORD gadgetkind;
536 WORD arrowtype;
539 /* GTString class */
540 struct StringData
542 Object *frame;
543 struct TextFont *font;
544 WORD gadgetkind;
545 UBYTE labelplace;
548 /* GTListView class */
549 struct LVData
551 struct Hook *ld_CallBack;
552 struct List *ld_Labels;
553 struct DrawInfo *ld_Dri;
554 struct TextFont *ld_Font;
555 Object *ld_Frame;
556 Object *ld_Scroller;
557 struct Gadget *ld_ShowSelected;
558 WORD ld_Top;
559 WORD ld_Selected;
560 WORD ld_Spacing;
561 WORD ld_ItemHeight;
563 /* The number of first damaged entry, counting from first visible.
564 ** A value o -1 means "nothing has to be redrawn"
566 WORD ld_FirstDamaged;
567 UWORD ld_NumDamaged;
569 /* Number of entries the listview should scroll in GM_RENDER.
570 ** Negative valu means scroll up.
572 WORD ld_ScrollEntries;
573 WORD ld_NumEntries;
575 UBYTE ld_Flags;
576 UBYTE ld_LabelPlace;
579 /* GTCheckBox class */
580 struct CheckBoxData
582 struct DrawInfo *dri;
583 LONG labelplace;
584 LONG flags;
587 /* GTCycle class */
588 struct CycleData
590 struct TextFont *font;
591 STRPTR *labels;
592 UWORD active;
593 UWORD numlabels;
594 UWORD labelplace;
597 /* GTMX class */
598 struct MXData
600 struct DrawInfo *dri;
601 struct TextAttr *tattr;
602 struct Image *mximage;
603 struct TextFont *font;
604 struct Rectangle bbox;
605 STRPTR *labels;
606 ULONG active, newactive; /* The active tick and the tick to be activated */
607 ULONG numlabels; /* The number of labels */
608 LONG labelplace, ticklabelplace;
609 UWORD fontheight;
610 UWORD spacing;
611 UWORD maxtextwidth;
614 /* GTPalette class */
615 struct PaletteData
617 UWORD pd_NumColors;
618 UBYTE *pd_ColorTable;
619 UBYTE pd_Color;
620 /* For state info, to know what selected entry to delete in GM_RENDER, GREDRAW_UPDATE */
621 UBYTE pd_OldColor;
623 UBYTE pd_ColorOffset;
624 UWORD pd_IndWidth;
625 UWORD pd_IndHeight;
627 struct IBox pd_GadgetBox; /* Box surrounding whole palette */
628 struct IBox pd_PaletteBox; /* Box surrounding palette */
629 struct IBox pd_IndicatorBox; /* Box surrounding indicator */
631 UWORD pd_ColWidth;
632 UWORD pd_RowHeight;
633 UBYTE pd_NumCols;
634 UBYTE pd_NumRows;
636 /* This one is used to backup pd_Color if left is clicked. This
637 ** way the old state can be restored if the left is released
638 ** outside the gadget.
640 UBYTE pd_ColorBackup;
641 struct TextAttr *pd_TAttr;
642 LONG pd_LabelPlace;
643 Object *pd_Frame;
647 #endif /* GADTOOLS_INTERN_H */