Replaced System by SYS because on "native" the volume name of the system partition...
[AROS-Contrib.git] / bgui / libfunc.c
blobedbd22ebeb1d1da2f929ed19a28b5732e1148874
1 /*
2 * @(#) $Header$
4 * BGUI library
5 * libfunc.c
7 * (C) Copyright 1998 Manuel Lemos.
8 * (C) Copyright 1996-1997 Ian J. Einman.
9 * (C) Copyright 1993-1996 Jaba Development.
10 * (C) Copyright 1993-1996 Jan van den Baard.
11 * All Rights Reserved.
13 * $Log$
14 * Revision 42.9 2004/06/16 20:16:48 verhaegs
15 * Use METHODPROTO, METHOD_END and REGFUNCPROTOn where needed.
17 * Revision 42.8 2003/01/18 19:09:58 chodorowski
18 * Instead of using the _AROS or __AROS preprocessor symbols, use __AROS__.
20 * Revision 42.7 2000/08/09 11:45:57 chodorowski
21 * Removed a lot of #ifdefs that disabled the AROS_LIB* macros when not building on AROS. This is now handled in contrib/bgui/include/bgui_compilerspecific.h.
23 * Revision 42.6 2000/08/08 14:08:00 chodorowski
24 * Minor fixes to make BGUI compile on Amiga.
26 * Revision 42.5 2000/07/09 03:05:07 bergers
27 * Makes the gadgets compilable.
29 * Revision 42.4 2000/06/01 01:41:37 bergers
30 * Only 2 linker problems left: stch_l & stcu_d. Somebody might want to replace them (embraced by #ifdef __AROS__), please.
32 * Revision 42.3 2000/05/29 00:40:24 bergers
33 * Update to compile with AROS now. Should also still compile with SASC etc since I only made changes that test the define __AROS__. The compilation is still very noisy but it does the trick for the main directory. Maybe members of the BGUI team should also have a look at the compiler warnings because some could also cause problems on other systems... (Comparison always TRUE due to datatype (or something like that)). And please compile it on an Amiga to see whether it still works... Thanks.
35 * Revision 42.2 2000/05/15 19:27:01 stegerg
36 * another hundreds of REG() macro replacements in func headers/protos.
38 * Revision 42.1 2000/05/14 23:32:47 stegerg
39 * changed over 200 function headers which all use register
40 * parameters (oh boy ...), because the simple REG() macro
41 * doesn't work with AROS. And there are still hundreds
42 * of headers left to be fixed :(
44 * Many of these functions would also work with stack
45 * params, but since i have fixed every single one
46 * I encountered up to now, I guess will have to do
47 * the same for the rest.
49 * Revision 42.0 2000/05/09 22:09:23 mlemos
50 * Bumped to revision 42.0 before handing BGUI to AROS team
52 * Revision 41.11 2000/05/09 19:54:33 mlemos
53 * Merged with the branch Manuel_Lemos_fixes.
55 * Revision 41.10.2.11 2000/05/04 04:39:06 mlemos
56 * Added the entries to the now built-in supported bar and layout group gadget
57 * classes.
59 * Revision 41.10.2.10 1999/08/17 19:11:24 mlemos
60 * Prevented base class from being replaced by an external library.
62 * Revision 41.10.2.9 1999/07/31 01:56:02 mlemos
63 * Added code to keep track of created objects.
65 * Revision 41.10.2.8 1999/07/29 00:43:47 mlemos
66 * Ensured that external library classes can only be freed if they get marked
67 * as such.
69 * Revision 41.10.2.7 1999/07/28 23:17:11 mlemos
70 * Allowed the library to be expunged if there no remainining classes with
71 * open subclasses but without any objects to be disposed.
73 * Revision 41.10.2.6 1999/07/28 16:38:05 mlemos
74 * Added code to detect class object leaks in FreeClasses.
75 * Made FreeClasses iterate until the number of classes subclasses that remain
76 * to be freed does not change.
78 * Revision 41.10.2.5 1999/07/18 02:58:03 mlemos
79 * Fixed problem of BGUI_CallHookPkt using the stack frame to store local
80 * variables that were pointing to the wrong address after EnsureStack was
81 * called.
83 * Revision 41.10.2.4 1999/07/03 15:16:54 mlemos
84 * Added the function BGUI_CallHookPkt.
85 * Replaced the calls to CallHookPkt to BGUI_CallHookPkt.
87 * Revision 41.10.2.3 1999/05/31 00:45:03 mlemos
88 * Added the TreeView gadget to the list of internally supported gadgets.
90 * Revision 41.10.2.2 1998/10/12 01:26:56 mlemos
91 * Made the ARexx be initialized internally whenever is needed.
93 * Revision 41.10.2.1 1998/03/02 23:51:17 mlemos
94 * Switched vector allocation functions calls to BGUI allocation functions.
96 * Revision 41.10 1998/02/25 21:12:26 mlemos
97 * Bumping to 41.10
99 * Revision 1.1 1998/02/25 17:08:50 mlemos
100 * Ian sources
105 #include "include/classdefs.h"
108 * Internal lock housekeeping.
110 typedef struct {
111 struct Requester wl_IDCMPLock; /* Requester lock. */
112 struct Window *wl_Locked; /* Locked window. */
113 UWORD wl_MinWidth, wl_MinHeight; /* Current sizes. */
114 UWORD wl_MaxWidth, wl_MaxHeight; /* " " */
115 } WINDOWLOCK;
118 #ifdef DEBUG_BGUI
120 static ULONG object_serial_number=1;
122 struct ObjectTracking
124 struct ObjectTracking *Next;
125 Object *Object;
126 ULONG SerialNumber;
127 STRPTR File;
128 ULONG Line;
131 static struct ObjectTracking *tracked_objects=NULL;
133 makeproto ULONG TrackNewObject(Object *object,struct TagItem *tags)
135 struct ObjectTracking *track;
137 if((track=BGUI_AllocPoolMem(sizeof(*track)))==NULL)
138 return(0);
139 track->Object=object;
140 Forbid();
141 track->SerialNumber=object_serial_number++;
142 track->Next=tracked_objects;
143 tracked_objects=track;
144 Permit();
145 return(track->SerialNumber);
148 makeproto BOOL TrackDisposedObject(Object *object)
150 struct ObjectTracking **track,*found;
152 Forbid();
153 for(track= &tracked_objects;(found= *track) && (*track)->Object!=object;track= &(*track)->Next);
154 if(found)
156 *track= found->Next;
157 BGUI_FreePoolMem(found);
159 else
160 bug("*** Could not track disposed object %lX\n",object);
161 Permit();
162 return((BOOL)(found!=NULL));
166 static void DumpTrackedObjects(void)
168 Forbid();
169 while(tracked_objects)
171 struct ObjectTracking *track;
173 track= tracked_objects;
174 tracked_objects=track->Next;
175 bug("*** Object %lX leaked! Serial number %lu\n",track->Object,track->SerialNumber);
176 BGUI_FreePoolMem(track);
178 Permit();
181 #endif
184 * Table for class init stuff.
186 typedef struct {
187 Class *cd_Storage;
188 Class *(*cd_InitFunc)(void);
189 UWORD cd_ClassID;
190 UBYTE *cd_ClassFile;
191 struct BGUIClassBase *cd_ClassBase;
192 struct TagItem *cd_DefTags;
193 BOOL cd_Leaking;
194 BOOL cd_LibraryClass;
195 } CLASSDEF;
197 STATIC CLASSDEF Classes[] =
199 { NULL, InitGroupNodeClass, BGUI_GROUP_NODE, NULL, NULL, FALSE, FALSE },
201 { NULL, InitDGMClass, BGUI_DGM_OBJECT, NULL, NULL, FALSE, FALSE },
202 { NULL, InitRootClass, BGUI_ROOT_OBJECT, NULL, NULL, FALSE, FALSE },
205 * Graphic classes.
207 { NULL, InitTextClass, BGUI_TEXT_GRAPHIC, NULL, NULL, FALSE, FALSE },
210 * Image classes.
212 { NULL, InitImageClass, BGUI_IMAGE_OBJECT, NULL, NULL, FALSE, FALSE },
213 { NULL, InitFrameClass, BGUI_FRAME_IMAGE, "images/bgui_frame.image", NULL, FALSE, FALSE },
214 { NULL, InitLabelClass, BGUI_LABEL_IMAGE, "images/bgui_label.image", NULL, FALSE, FALSE },
215 { NULL, InitVectorClass, BGUI_VECTOR_IMAGE, "images/bgui_vector.image", NULL, FALSE, FALSE },
216 { NULL, InitSystemClass, BGUI_SYSTEM_IMAGE, "images/bgui_system.image", NULL, FALSE, FALSE },
219 * Gadget classes.
221 { NULL, InitGadgetClass, BGUI_GADGET_OBJECT, NULL, NULL, FALSE, FALSE },
222 { NULL, InitBaseClass, BGUI_BASE_GADGET, NULL, NULL, FALSE, FALSE },
223 { NULL, InitButtonClass, BGUI_BUTTON_GADGET, "gadgets/bgui_button.gadget", NULL, FALSE, FALSE },
224 { NULL, InitGroupClass, BGUI_GROUP_GADGET, "gadgets/bgui_group.gadget", NULL, FALSE, FALSE },
225 { NULL, InitCycleClass, BGUI_CYCLE_GADGET, "gadgets/bgui_cycle.gadget", NULL, FALSE, FALSE },
226 { NULL, InitCheckBoxClass, BGUI_CHECKBOX_GADGET, "gadgets/bgui_checkbox.gadget", NULL, FALSE, FALSE },
227 { NULL, InitInfoClass, BGUI_INFO_GADGET, "gadgets/bgui_info.gadget", NULL, FALSE, FALSE },
228 { NULL, InitStringClass, BGUI_STRING_GADGET, "gadgets/bgui_string.gadget", NULL, FALSE, FALSE },
229 { NULL, InitPropClass, BGUI_PROP_GADGET, "gadgets/bgui_prop.gadget", NULL, FALSE, FALSE },
230 { NULL, InitIndicatorClass, BGUI_INDICATOR_GADGET, "gadgets/bgui_indicator.gadget", NULL, FALSE, FALSE },
231 { NULL, InitProgressClass, BGUI_PROGRESS_GADGET, "gadgets/bgui_progress.gadget", NULL, FALSE, FALSE },
232 { NULL, InitSliderClass, BGUI_SLIDER_GADGET, "gadgets/bgui_slider.gadget", NULL, FALSE, FALSE },
233 { NULL, InitPageClass, BGUI_PAGE_GADGET, "gadgets/bgui_page.gadget", NULL, FALSE, FALSE },
234 { NULL, InitMxClass, BGUI_MX_GADGET, "gadgets/bgui_mx.gadget", NULL, FALSE, FALSE },
235 { NULL, InitListClass, BGUI_LISTVIEW_GADGET, "gadgets/bgui_listview.gadget", NULL, FALSE, FALSE },
236 { NULL, InitExtClass, BGUI_EXTERNAL_GADGET, "gadgets/bgui_external.gadget", NULL, FALSE, FALSE },
237 { NULL, InitSepClass, BGUI_SEPARATOR_GADGET, "gadgets/bgui_separator.gadget", NULL, FALSE, FALSE },
238 { NULL, InitRadioButtonClass, BGUI_RADIOBUTTON_GADGET, "gadgets/bgui_radiobutton.gadget", NULL, FALSE, FALSE },
239 { NULL, InitAreaClass, BGUI_AREA_GADGET, "gadgets/bgui_area.gadget", NULL, FALSE, FALSE },
240 { NULL, InitViewClass, BGUI_VIEW_GADGET, "gadgets/bgui_view.gadget", NULL, FALSE, FALSE },
243 #ifdef __AROS__
244 { NULL, NULL, BGUI_PALETTE_GADGET, "Gadgets/bgui_palette.gadget", NULL, FALSE, FALSE },
245 { NULL, NULL, BGUI_POPBUTTON_GADGET, "Gadgets/bgui_popbutton.gadget", NULL, FALSE, FALSE },
246 { NULL, NULL, BGUI_TREEVIEW_GADGET, "Gadgets/bgui_treeview.gadget", NULL, FALSE, FALSE },
247 { NULL, NULL, BGUI_BAR_GADGET, "Gadgets/bgui_bar.gadget", NULL, FALSE, FALSE },
248 { NULL, NULL, BGUI_LAYOUTGROUP_GADGET, "Gadgets/bgui_layoutgroup.gadget", NULL, FALSE, FALSE },
249 #else
250 { NULL, NULL, BGUI_PALETTE_GADGET, "gadgets/bgui_palette.gadget", NULL, FALSE, FALSE },
251 { NULL, NULL, BGUI_POPBUTTON_GADGET, "gadgets/bgui_popbutton.gadget", NULL, FALSE, FALSE },
252 { NULL, NULL, BGUI_TREEVIEW_GADGET, "gadgets/bgui_treeview.gadget", NULL, FALSE, FALSE },
253 { NULL, NULL, BGUI_BAR_GADGET, "gadgets/bgui_bar.gadget", NULL, FALSE, FALSE },
254 { NULL, NULL, BGUI_LAYOUTGROUP_GADGET, "gadgets/bgui_layoutgroup.gadget", NULL, FALSE, FALSE },
255 #endif
257 * Misc. classes.
259 { NULL, InitWindowClass, BGUI_WINDOW_OBJECT, "bgui_window.class", NULL, FALSE, FALSE },
260 { NULL, InitCxClass, BGUI_COMMODITY_OBJECT, "bgui_commodity.class", NULL, FALSE, FALSE },
261 { NULL, InitAslReqClass, BGUI_ASLREQ_OBJECT, "bgui_aslreq.class", NULL, FALSE, FALSE },
262 { NULL, InitFileReqClass, BGUI_FILEREQ_OBJECT, "bgui_filereq.class", NULL, FALSE, FALSE },
263 { NULL, InitFontReqClass, BGUI_FONTREQ_OBJECT, "bgui_fontreq.class", NULL, FALSE, FALSE },
264 { NULL, InitScreenReqClass, BGUI_SCREENREQ_OBJECT, "bgui_screenreq.class", NULL, FALSE, FALSE },
266 #ifdef __AROS__
267 #define InitArexxClass NULL
268 #warning InitArexxClass defined as NULL
269 #endif
270 { NULL, InitArexxClass, BGUI_AREXX_OBJECT, "bgui_arexx.class", NULL, FALSE, FALSE },
271 { NULL, InitSpacingClass, BGUI_SPACING_OBJECT, NULL, NULL, FALSE, FALSE },
273 { NULL, NULL, (UWORD)~0, NULL }
277 * Free the classes. Returns FALSE if one of the classes
278 * fail to free.
280 makeproto BOOL FreeClasses(void)
282 CLASSDEF *cd;
283 BOOL rc = TRUE;
284 ULONG subclasses,last_subclasses=0,opened_classes;
286 Forbid();
289 opened_classes=subclasses=0;
290 for (cd = Classes; cd->cd_ClassID != (UWORD)~0; cd++)
292 if(last_subclasses==0)
293 cd->cd_Leaking=FALSE;
294 if (cd->cd_Storage)
296 if (cd->cd_LibraryClass)
298 if(cd->cd_ClassBase)
300 CloseLibrary((struct Library *)cd->cd_ClassBase);
301 cd->cd_ClassBase = NULL;
303 opened_classes++;
304 rc=FALSE;
306 else
309 * Return FALSE if one or more fail to free.
311 if (!BGUI_FreeClass(cd->cd_Storage))
313 rc = FALSE;
314 if(cd->cd_Storage->cl_SubclassCount)
316 subclasses+=cd->cd_Storage->cl_SubclassCount;
317 if(cd->cd_Storage->cl_ObjectCount)
318 opened_classes++;
320 else
322 if(!cd->cd_Leaking)
324 cd->cd_Leaking=TRUE;
325 D(bug("*** Object leak of class %lu: Class %lX, Object count %lu\n",cd->cd_ClassID,cd->cd_Storage,cd->cd_Storage->cl_ObjectCount));
329 else
330 cd->cd_Storage = NULL;
333 else
334 cd->cd_LibraryClass=FALSE;
336 if(last_subclasses==subclasses)
337 break;
338 last_subclasses=subclasses;
340 while(subclasses);
341 if(!rc)
343 if(opened_classes==0)
345 for (cd = Classes; cd->cd_ClassID != (UWORD)~0; cd++)
346 cd->cd_Storage = NULL;
347 #ifdef DEBUG_BGUI
348 DumpTrackedObjects();
349 #endif
350 rc=TRUE;
352 else
354 D(bug("Opened classes %lu\n",opened_classes));
357 Permit();
358 return rc;
361 makeproto void MarkFreedClass(Class *cl)
363 CLASSDEF *cd;
365 Forbid();
366 for (cd = Classes; cd->cd_ClassID != (UWORD)~0; cd++)
368 if(cl==cd->cd_Storage)
370 cd->cd_Storage = NULL;
371 break;
374 Permit();
379 * Obtain a class pointer. This routine will only fail if you pass it
380 * a non-existing class ID, or the class fails to initialize.
382 #ifdef __AROS__
383 makearosproto
384 AROS_LH1(Class *, BGUI_GetClassPtr,
385 AROS_LHA(ULONG, classID, D0),
386 struct Library *, BGUIBase, 5, BGUI)
387 #else
388 makeproto SAVEDS ASM Class *BGUI_GetClassPtr( REG(d0) ULONG classID )
389 #endif
391 AROS_LIBFUNC_INIT
393 CLASSDEF *cd;
394 Class *cl = NULL;
397 for (cd = Classes; cd->cd_ClassID != (UWORD)~0; cd++)
399 if (classID == (UWORD)cd->cd_ClassID)
401 if (!(cl = cd->cd_Storage))
403 if (cd->cd_ClassFile)
405 if (cd->cd_ClassBase = (struct BGUIClassBase *)OpenLibrary(cd->cd_ClassFile, 0))
408 * Get the class pointer.
410 cl = cd->cd_ClassBase->bcb_Class;
411 cd->cd_LibraryClass=TRUE;
414 if (!cl && cd->cd_InitFunc)
417 * Call the initialization routine.
419 cl = (cd->cd_InitFunc)();
421 cd->cd_Storage = cl;
423 break;
426 return cl;
428 AROS_LIBFUNC_EXIT
432 * Var-args stub for BGUI_NewObjectA().
434 makeproto Object *BGUI_NewObject(ULONG classID, Tag tag1, ...)
436 return BGUI_NewObjectA(classID, (struct TagItem *)&tag1);
440 * Create an object from a class.
442 #ifdef __AROS__
443 makearosproto
444 AROS_LH2(Object *, BGUI_NewObjectA,
445 AROS_LHA(ULONG, classID, D0),
446 AROS_LHA(struct TagItem *, attr, A0),
447 struct Library *, BGUIBase, 6, BGUI)
448 #else
449 makeproto SAVEDS ASM Object *BGUI_NewObjectA( REG(d0) ULONG classID, REG(a0) struct TagItem *attr )
450 #endif
452 AROS_LIBFUNC_INIT
454 Class *cl;
455 Object *obj = NULL;
457 if (cl = BGUI_GetClassPtr(classID))
458 obj = NewObjectA(cl, NULL, attr);
460 return obj;
462 AROS_LIBFUNC_EXIT
466 * Allocate a bitmap.
468 #ifdef __AROS__
469 makearosproto
470 AROS_LH5(struct BitMap *, BGUI_AllocBitMap,
471 AROS_LHA(ULONG, width, D0),
472 AROS_LHA(ULONG, height, D1),
473 AROS_LHA(ULONG, depth, D2),
474 AROS_LHA(ULONG, flags, D3),
475 AROS_LHA(struct BitMap *, fr, A0),
476 struct Library *, BGUIBase, 14, BGUI)
477 #else
478 makeproto SAVEDS ASM struct BitMap *BGUI_AllocBitMap( REG(d0) ULONG width, REG(d1) ULONG height, REG(d2) ULONG depth,
479 REG(d3) ULONG flags, REG(a0) struct BitMap *fr )
480 #endif
482 AROS_LIBFUNC_INIT
484 #ifdef ENHANCED
485 return AllocBitMap(width, height, depth, flags | BMF_MINPLANES, fr);
486 #else
487 struct BitMap *bm = NULL;
488 ULONG *b;
489 int i, rassize;
492 * Use the system routine if
493 * we are running OS 3.0 or better.
495 if (OS30)
496 return AllocBitMap(width, height, depth, flags | BMF_MINPLANES, fr);
499 * Not OS 3.0 or better?
500 * Make the bitmap ourselves.
502 if (b = (ULONG *)BGUI_AllocPoolMem(sizeof(struct BitMap) + sizeof(ULONG)))
504 *b = ID_BGUI;
505 bm = (struct BitMap *)(b + 1);
506 InitBitMap(bm, depth, width, height);
508 flags = flags & BMF_CLEAR ? MEMF_CHIP : MEMF_CHIP | MEMF_CLEAR;
509 rassize = RASSIZE(width, height);
512 * Allocate planes.
514 for (i = 0; i < depth; i++)
516 if (!(bm->Planes[i] = AllocVec(rassize, flags)))
518 BGUI_FreeBitMap(bm);
519 return NULL;
523 return bm;
524 #endif
526 AROS_LIBFUNC_EXIT
530 * Free a bitmap.
532 #ifdef __AROS__
533 makearosproto
534 AROS_LH1(VOID, BGUI_FreeBitMap,
535 AROS_LHA(struct BitMap *, bm, A0),
536 struct Library *, BGUIBase, 15, BGUI)
537 #else
538 makeproto SAVEDS ASM VOID BGUI_FreeBitMap( REG(a0) struct BitMap *bm )
539 #endif
541 AROS_LIBFUNC_INIT
543 #ifdef ENHANCED
544 WaitBlit();
545 FreeBitMap(bm);
546 #else
548 ULONG *b = ((ULONG *)bm) - 1;
549 int i;
550 UBYTE *p;
552 if (bm)
555 * Wait for the blitter.
557 WaitBlit();
560 * Under OS 3.0 we call the system routine.
562 if (*b == ID_BGUI)
564 for (i = bm->Depth - 1; i >= 0; --i)
567 * Free planes.
569 if (p = bm->Planes[i]) FreeVec(p);
572 * Free the structure.
574 BGUI_FreePoolMem(b);
576 else
578 FreeBitMap(bm);
581 #endif
583 AROS_LIBFUNC_EXIT
587 * Allocate a rastport with bitmap.
589 #ifdef __AROS__
590 makearosproto
591 AROS_LH4(struct RastPort *, BGUI_CreateRPortBitMap,
592 AROS_LHA(struct RastPort *, source, A0),
593 AROS_LHA(ULONG, width, D0),
594 AROS_LHA(ULONG, height, D1),
595 AROS_LHA(ULONG, depth, D2),
596 struct Library *, BGUIBase, 16, BGUI)
597 #else
598 makeproto SAVEDS ASM struct RastPort *BGUI_CreateRPortBitMap( REG(a0) struct RastPort *source,
599 REG(d0) ULONG width, REG(d1) ULONG height, REG(d2) ULONG depth )
600 #endif
602 AROS_LIBFUNC_INIT
604 struct RastPort *rp;
605 struct Layer_Info *li;
608 * Allocate a rastport structure.
610 if (rp = (struct RastPort *)BGUI_AllocPoolMem(sizeof(struct RastPort)))
613 * If we have a source rastport we
614 * copy it. Otherwise we initialize
615 * the rastport.
617 if (source) *rp = *source;
618 else InitRastPort(rp);
620 if (!depth && source) depth = FGetDepth(source);
623 * Add a bitmap.
625 if (rp->BitMap = BGUI_AllocBitMap(width, height, depth, BMF_CLEAR, source ? source->BitMap : NULL))
628 * NO LAYER!.
630 // rp->Layer = NULL;
632 if (li = NewLayerInfo())
634 if (rp->Layer = CreateUpfrontLayer(li, rp->BitMap, 0, 0, width - 1, height - 1, 0, NULL))
637 * Mark it as a buffered rastport.
639 // rp->RP_User = ID_BFRP;
641 return rp;
644 * No layer.
646 DisposeLayerInfo(li);
649 * No layerinfo.
651 BGUI_FreeBitMap(rp->BitMap);
654 * No bitmap.
656 BGUI_FreePoolMem(rp);
658 return NULL;
660 AROS_LIBFUNC_EXIT
664 * Free a buffer rastport and bitmap.
666 #ifdef __AROS__
667 makearosproto
668 AROS_LH1(VOID, BGUI_FreeRPortBitMap,
669 AROS_LHA(struct RastPort *, rp, A0),
670 struct Library *, BGUIBase, 17, BGUI)
671 #else
672 makeproto SAVEDS ASM VOID BGUI_FreeRPortBitMap( REG(a0) struct RastPort *rp )
673 #endif
675 AROS_LIBFUNC_INIT
677 struct Layer *l = rp->Layer;
678 struct Layer_Info *li = l->LayerInfo;
681 * Free the layer.
683 InstallClipRegion(l, NULL);
684 DeleteLayer(NULL, l);
687 * Free the layerinfo.
689 DisposeLayerInfo(li);
692 * Free the bitmap.
694 BGUI_FreeBitMap(rp->BitMap);
697 * Free the rastport.
699 BGUI_FreePoolMem(rp);
701 AROS_LIBFUNC_EXIT
705 * Show AmigaGuide file.
708 #ifdef __AROS__
709 makearosproto
710 AROS_LH4(BOOL, BGUI_Help,
711 AROS_LHA(struct Window *, win, A0),
712 AROS_LHA(UBYTE *, file, A1),
713 AROS_LHA(UBYTE *, node, A2),
714 AROS_LHA(ULONG, line, D0),
715 struct Library *, BGUIBase, 8, BGUI)
716 #else
717 makeproto SAVEDS ASM BOOL BGUI_Help( REG(a0) struct Window *win, REG(a1) UBYTE *file, REG(a2) UBYTE *node, REG(d0) ULONG line )
718 #endif
720 AROS_LIBFUNC_INIT
722 #ifdef __AROS__
723 #warning Commented a bunch of lines!!!!!!
724 #else
725 struct NewAmigaGuide nag = { NULL };
728 * Initialize structure.
730 nag.nag_Name = ( STRPTR )file;
731 nag.nag_Node = ( STRPTR )node;
732 nag.nag_Line = line;
733 nag.nag_Screen = win ? win->WScreen : NULL;
736 * Show file.
738 return( DisplayAGuideInfo( &nag, TAG_END ));
739 #endif
741 AROS_LIBFUNC_EXIT
746 * Set or clear the busy pointer.
748 //STATIC ASM VOID Busy(REG(a0) struct Window *win, REG(d0) BOOL set)
749 STATIC ASM REGFUNC2(VOID, Busy, REGPARAM(a0, struct Window *, win), REGPARAM(d0, BOOL, set))
751 #ifdef ENHANCED
753 if (set) SetWindowPointer(win, WA_BusyPointer, TRUE, WA_PointerDelay, TRUE, TAG_END);
754 else SetWindowPointer(win, TAG_END);
756 #else
759 * Must be in chip memory (busy pointer on OS 2.04 machines).
761 static __chip UWORD BusyPointer[] =
763 0x0000, 0x0000, 0x0400, 0x07c0, 0x0000, 0x07c0, 0x0100, 0x0380,
764 0x0000, 0x07e0, 0x07c0, 0x1ff8, 0x1FF0, 0x3FEC, 0x3FF8, 0x7FDE,
765 0x3FF8, 0x7FBE, 0x7FFC, 0xFF7F, 0x7EFC, 0xFFFF, 0x7FFC, 0xFFFF,
766 0x3FF8, 0x7FFE, 0x3FF8, 0x7FFE, 0x1FF0, 0x3FFC, 0x07C0, 0x1FF8,
767 0x0000, 0x07E0, 0x0000, 0x0000
770 if (OS30)
772 if (set) SetWindowPointer(win, WA_BusyPointer, TRUE, WA_PointerDelay, TRUE, TAG_END);
773 else SetWindowPointer(win, TAG_END);
775 else
777 if (set) SetPointer(win, BusyPointer, 16, 16, -6, 0 );
778 else ClearPointer(win );
781 #endif
783 REGFUNC_END
786 * Lock a window.
788 #ifdef __AROS__
789 makearosproto
790 AROS_LH1(APTR, BGUI_LockWindow,
791 AROS_LHA(struct Window *, win, A0),
792 struct Library *, BGUIBase, 9, BGUI)
793 #else
794 makeproto SAVEDS ASM APTR BGUI_LockWindow( REG(a0) struct Window *win )
795 #endif
797 AROS_LIBFUNC_INIT
799 WINDOWLOCK *wl;
802 * Allocate lock structure.
804 if ( wl = ( WINDOWLOCK * )BGUI_AllocPoolMem( sizeof( WINDOWLOCK ))) {
806 * Initialize structure.
808 wl->wl_Locked = win;
811 * Copy current min/max sizes.
813 *IBOX( &wl->wl_MinWidth ) = *IBOX( &win->MinWidth );
816 * Setup and open requester.
818 InitRequester( &wl->wl_IDCMPLock );
819 Request( &wl->wl_IDCMPLock, win );
822 * Set busy pointer.
824 Busy( win, TRUE );
827 * Disable sizing.
829 WindowLimits( win, win->Width, win->Height, win->Width, win->Height );
832 return( wl );
834 AROS_LIBFUNC_EXIT
838 * Unlock a window.
840 #ifdef __AROS__
841 makearosproto
842 AROS_LH1(VOID, BGUI_UnlockWindow,
843 AROS_LHA(APTR, lock, A0),
844 struct Library *, BGUIBase, 10, BGUI)
845 #else
846 makeproto SAVEDS ASM VOID BGUI_UnlockWindow( REG(a0) APTR lock )
847 #endif
849 AROS_LIBFUNC_INIT
851 WINDOWLOCK *wl = ( WINDOWLOCK * )lock;
854 * A NULL lock is safe.
856 if ( wl ) {
858 * Setup limits.
860 WindowLimits( wl->wl_Locked, wl->wl_MinWidth, wl->wl_MinHeight, wl->wl_MaxWidth, wl->wl_MaxHeight );
863 * End request.
865 EndRequest( &wl->wl_IDCMPLock, wl->wl_Locked );
868 * Clear busy pointer.
870 Busy( wl->wl_Locked, FALSE );
873 * Free lock.
875 BGUI_FreePoolMem( wl );
878 AROS_LIBFUNC_EXIT
881 #ifdef __AROS__
882 makearosproto
883 AROS_LH2(STRPTR, BGUI_GetLocaleStr,
884 AROS_LHA(struct bguiLocale *, bl, A0),
885 AROS_LHA(ULONG, id, D0),
886 struct Library *, BGUIBase, 20, BGUI)
887 #else
888 makeproto SAVEDS ASM STRPTR BGUI_GetLocaleStr( REG(a0) struct bguiLocale *bl, REG(d0) ULONG id )
889 #endif
891 AROS_LIBFUNC_INIT
893 STRPTR str = NULL;
895 struct bguiLocaleStr bls;
897 if (bl)
899 if (bl->bl_LocaleStrHook)
901 bls.bls_ID = id;
902 str = (STRPTR)BGUI_CallHookPkt(bl->bl_LocaleStrHook, (void *)bl, (void *)&bls);
904 else
906 if (LocaleBase) str = GetLocaleStr(bl->bl_Locale, id);
909 return str;
911 AROS_LIBFUNC_EXIT
914 #ifdef __AROS__
915 makearosproto
916 AROS_LH3(STRPTR, BGUI_GetCatalogStr,
917 AROS_LHA(struct bguiLocale *, bl, A0),
918 AROS_LHA(ULONG, id, D0),
919 AROS_LHA(STRPTR, str, A1),
920 struct Library *, BGUIBase, 21, BGUI)
921 #else
922 makeproto SAVEDS ASM STRPTR BGUI_GetCatalogStr( REG(a0) struct bguiLocale *bl, REG(d0) ULONG id, REG(a1) STRPTR str )
923 #endif
925 AROS_LIBFUNC_INIT
927 struct bguiCatalogStr bcs;
929 if (bl)
931 if (bl->bl_CatalogStrHook)
933 bcs.bcs_ID = id;
934 bcs.bcs_DefaultString = str;
935 str = (STRPTR)BGUI_CallHookPkt(bl->bl_CatalogStrHook, (void *)bl, (void *)&bcs);
937 else
939 if (LocaleBase) str = GetCatalogStr(bl->bl_Catalog, id, str);
942 return str;
944 AROS_LIBFUNC_EXIT
947 struct CallHookData
949 struct Hook *Hook;
950 APTR Object;
951 APTR Message;
954 static ULONG CallHookWithStack(struct CallHookData *call_hook_data)
956 register APTR stack;
957 register ULONG result;
959 #ifdef __AROS__
960 #warning Commented EnsureStack
961 #else
962 stack=EnsureStack();
963 #endif
964 result=CallHookPkt(call_hook_data->Hook,call_hook_data->Object,call_hook_data->Message);
965 #ifdef __AROS__
966 #else
967 RevertStack(stack);
968 #endif
969 return(result);
972 //makeproto SAVEDS ASM ULONG BGUI_CallHookPkt(REG(a0) struct Hook *hook,REG(a2) APTR object,REG(a1) APTR message)
973 makeproto SAVEDS ASM REGFUNC3(ULONG, BGUI_CallHookPkt, REGPARAM(a0, struct Hook *, hook), REGPARAM(a2, APTR, object), REGPARAM(a1, APTR, message))
975 struct CallHookData call_hook_data;
977 call_hook_data.Hook=hook;
978 call_hook_data.Object=object;
979 call_hook_data.Message=message;
980 return(CallHookWithStack(&call_hook_data));
982 REGFUNC_END