2 Copyright © 1995-2015, The AROS Development Team. All rights reserved.
5 Desc: Basic helpfuncs for Asl.
9 #include <proto/alib.h>
10 #include <proto/exec.h>
11 #include <proto/utility.h>
12 #include <proto/intuition.h>
13 #include <proto/iffparse.h>
14 #include <proto/diskfont.h>
15 #include <proto/graphics.h>
16 #include <proto/gadtools.h>
17 #include <proto/dos.h>
18 #include <proto/locale.h>
19 #include <proto/workbench.h>
21 #include <exec/lists.h>
22 #include <exec/memory.h>
23 #include <intuition/intuition.h>
24 #include <intuition/screens.h>
25 #include <intuition/classusr.h>
26 #include <intuition/imageclass.h>
27 #include <graphics/gfxbase.h>
28 #include <devices/rawkeycodes.h>
29 #include <prefs/prefhdr.h>
30 #include <prefs/font.h>
31 #include <libraries/iffparse.h>
35 #include "asl_intern.h"
36 #include "filereqsupport.h"
37 #include "filereqhooks.h"
43 #include <aros/debug.h>
45 /*****************************************************************************************/
47 STATIC BOOL
GetRequesterFont(struct LayoutData
*, struct AslBase_intern
*);
50 STATIC
struct FontPrefs
*GetFontPrefs(struct AslBase_intern
*);
51 STATIC VOID
FreeFontPrefs(struct FontPrefs
*, struct AslBase_intern
*);
54 /*****************************************************************************************/
56 /* Finds the internal requester data for a requester */
58 struct ReqNode
*FindReqNode(APTR req
, struct AslBase_intern
*AslBase
)
60 struct ReqNode
*reqnode
, *foundreqnode
= NULL
;
62 ObtainSemaphoreShared( &(AslBase
->ReqListSem
) );
64 ForeachNode( &(AslBase
->ReqList
), reqnode
)
66 if (reqnode
->rn_Req
== req
)
68 foundreqnode
= reqnode
;
73 ReleaseSemaphore( &(AslBase
->ReqListSem
) );
75 return (foundreqnode
);
78 /*****************************************************************************************/
82 struct IntReq
*intreq
,
83 struct TagItem
*taglist
,
84 struct AslBase_intern
*AslBase
88 struct TagItem
*tstate
= taglist
;
90 while ((tag
= NextTagItem(&tstate
)) != NULL
)
92 IPTR tidata
= tag
->ti_Data
;
94 /* The tags that are put "in a row" are defined as the same value,
95 and therefore we only use one of them, but the effect is for all of them
101 /* case ASLFO_Window:
103 case ASL_Window: */ /* Obsolete */
104 intreq
->ir_Window
= (struct Window
*)tidata
;
108 /* case ASLFO_Screen:
109 case ASLSM_Screen: */
110 intreq
->ir_Screen
= (struct Screen
*)tidata
;
113 case ASLFR_PubScreenName
:
114 /* case ASLFO_PubScreenName:
115 case ASLSM_PubScreenName: */
117 intreq
->ir_PubScreenName
= (STRPTR
)tidata
;
120 case ASLFR_PrivateIDCMP
:
121 /* case ASLFO_PrivateIDCMP:
122 case ASLSM_PrivateIDCMP: */
124 intreq
->ir_Flags
|= IF_PRIVATEIDCMP
;
126 intreq
->ir_Flags
&= ~IF_PRIVATEIDCMP
;
130 case ASLFR_IntuiMsgFunc
:
131 /* case ASLFO_IntuiMsgFunc:
132 case ASLSM_IntuiMsgFunc: */
133 intreq
->ir_IntuiMsgFunc
= (struct Hook
*)tidata
;
136 case ASLFR_SleepWindow
:
137 /* case ASLFO_SleepWindow:
138 case ASLSM_SleepWindow: */
140 intreq
->ir_Flags
|= IF_SLEEPWINDOW
;
142 intreq
->ir_Flags
&= ~IF_SLEEPWINDOW
;
145 case ASLFR_PopToFront
:
146 /* case ASLFO_PopToFront:
147 case ASLSM_PopToFront: */
149 intreq
->ir_Flags
|= IF_POPTOFRONT
;
151 intreq
->ir_Flags
&= ~IF_POPTOFRONT
;
155 /* case ASLFO_Activate:
156 case ASLSM_Activate: */
158 intreq
->ir_Flags
&= ~IF_OPENINACTIVE
;
160 intreq
->ir_Flags
|= IF_OPENINACTIVE
;
164 /* case ASLFO_TextAttr:
165 case ASLSM_TextAttr: */
166 intreq
->ir_TextAttr
= (struct TextAttr
*)tidata
;
170 /* case ASLFO_Locale:
171 case ASLSM_Locale: */
172 intreq
->ir_Locale
= (struct Locale
*)tidata
;
175 case ASLFR_TitleText
:
176 /* case ASLFO_TitleText:
177 case ASLSM_TitleText:
178 case ASL_Hail: */ /* Obsolete */
180 intreq
->ir_TitleText
= (STRPTR
)tidata
;
184 case ASLFR_PositiveText
:
185 /* case ASLFO_PositiveText:
186 case ASLSM_PositiveText:
187 case ASL_OKText: */ /* Obsolete */
190 intreq
->ir_PositiveText
= (STRPTR
)tidata
;
191 intreq
->ir_Flags
|= IF_USER_POSTEXT
;
195 case ASLFR_NegativeText
:
196 /* case ASLFO_NegativeText:
197 case ASLSM_NegativeText:
198 case ASL_CancelText: */ /* Obsolete */
201 intreq
->ir_NegativeText
= (STRPTR
)tidata
;
202 intreq
->ir_Flags
|= IF_USER_NEGTEXT
;
206 case ASLFR_InitialLeftEdge
:
207 /* case ASLFO_InitialLeftEdge:
208 case ASLSM_InitialLeftEdge:
209 case ASL_LeftEdge: */ /* Obsolete */
210 intreq
->ir_LeftEdge
= (UWORD
)tidata
;
213 case ASLFR_InitialTopEdge
:
214 /* case ASLFO_InitialTopEdge:
215 case ASLSM_InitialTopEdge:
216 case ASL_TopEdge: */ /* Obsolete */
217 intreq
->ir_TopEdge
= (UWORD
)tidata
;
220 case ASLFR_InitialWidth
:
221 /* case ASLFO_InitialWidth:
222 case ASLSM_InitialWidth:
223 case ASL_Width: */ /* Obsolete */
224 intreq
->ir_Width
= (UWORD
)tidata
;
227 case ASLFR_InitialHeight
:
228 /* case ASLFO_InitialHeight:
229 case ASLSM_InitialHeight:
230 case ASL_Height: */ /* Obsolete */
231 intreq
->ir_Height
= (UWORD
)tidata
;
237 } /* switch (tag->ti_Tag) */
239 } /* while ((tag = NextTagItem(&tstate)) != NULL) */
242 /*****************************************************************************************/
244 VOID
FreeCommon(struct LayoutData
*ld
, struct AslBase_intern
*AslBase
)
249 if (ld
->ld_IntReq
->ir_Catalog
) CloseCatalog(ld
->ld_IntReq
->ir_Catalog
);
254 ClearMenuStrip(ld
->ld_Window
);
256 FreeMenus(ld
->ld_Menu
);
261 if (ld
->ld_AppWindow
)
262 RemoveAppWindow(ld
->ld_AppWindow
);
263 if (ld
->ld_AppMsgPort
)
264 DeleteMsgPort(ld
->ld_AppMsgPort
);
266 if (ld
->ld_IntReq
->ir_Flags
& IF_POPPEDTOFRONT
)
268 ld
->ld_IntReq
->ir_Flags
&= ~IF_POPPEDTOFRONT
;
269 ScreenToBack(ld
->ld_Window
->WScreen
);
272 if ((ld
->ld_IntReq
->ir_Flags
& IF_PRIVATEIDCMP
) || (!ld
->ld_IntReq
->ir_Window
))
274 CloseWindow(ld
->ld_Window
);
278 CloseWindowSafely(ld
->ld_Window
, AslBase
);
282 D(bug("Window freed\n"));
284 if (ld
->ld_VisualInfo
) FreeVisualInfo(ld
->ld_VisualInfo
);
285 if (ld
->ld_Dri
) FreeScreenDrawInfo(ld
->ld_Screen
, ld
->ld_Dri
);
287 if (ld
->ld_ScreenLocked
)
288 UnlockPubScreen(NULL
, ld
->ld_Screen
);
291 FreeVec(ld
->ld_UserData
);
294 CloseFont(ld
->ld_Font
);
296 if (ld
->ld_TextAttr
.ta_Name
)
297 FreeVec(ld
->ld_TextAttr
.ta_Name
);
299 FreeMem(ld
, sizeof (struct LayoutData
));
303 /*****************************************************************************************/
305 struct LayoutData
*AllocCommon
308 struct IntReq
*intreq
,
310 struct AslBase_intern
*AslBase
313 struct Screen
*screen
= NULL
;
314 struct LayoutData
*ld
;
317 ld
= AllocMem(sizeof (struct LayoutData
), MEMF_ANY
|MEMF_CLEAR
);
321 /* Save the internal and public requester struct, so that the
322 requester type specific hook may find them */
323 ld
->ld_IntReq
= intreq
;
324 ld
->ld_Req
= requester
;
326 InitRastPort(&(ld
->ld_DummyRP
));
328 /* We need to lock the screen we should open on to be sure it
332 /* Find screen on which to open window */
334 screen
= intreq
->ir_Screen
;
335 if (!screen
&& intreq
->ir_PubScreenName
)
337 if ((screen
= LockPubScreen(intreq
->ir_PubScreenName
)))
339 ld
->ld_ScreenLocked
= TRUE
;
342 if (!screen
&& intreq
->ir_Window
)
344 screen
= intreq
->ir_Window
->WScreen
;
346 if (!screen
&& !intreq
->ir_PubScreenName
)
348 if ((screen
= LockPubScreen(NULL
)))
350 ld
->ld_ScreenLocked
= TRUE
;
354 if (!screen
) goto failure
;
356 ld
->ld_Screen
= screen
;
358 if (!(ld
->ld_Dri
= GetScreenDrawInfo(screen
))) goto failure
;
360 if (!(ld
->ld_VisualInfo
= GetVisualInfoA(screen
, NULL
))) goto failure
;
362 ld
->ld_WBorLeft
= screen
->WBorLeft
;
363 ld
->ld_WBorTop
= screen
->WBorTop
+ screen
->Font
->ta_YSize
+ 1;
364 ld
->ld_WBorRight
= screen
->WBorRight
;
365 ld
->ld_WBorBottom
= 16;
368 struct TagItem sysi_tags
[] =
370 {SYSIA_DrawInfo
, (IPTR
)ld
->ld_Dri
},
371 {SYSIA_Which
, SIZEIMAGE
},
377 if ((im
= NewObjectA(NULL
, SYSICLASS
, sysi_tags
)))
381 if (GetAttr(IA_Height
, im
, &height
))
383 ld
->ld_WBorBottom
= height
;
390 if(GetBitMapAttr(screen
->RastPort
.BitMap
, BMA_DEPTH
) > 8) ld
->ld_TrueColor
= TRUE
;
392 if (!(ld
->ld_UserData
= AllocVec(udatasize
, MEMF_ANY
|MEMF_CLEAR
)))
395 if (!GetRequesterFont(ld
, ASLB(AslBase
)))
398 SetFont( &(ld
->ld_DummyRP
), ld
->ld_Font
);
402 struct TagItem tags
[] =
404 {OC_BuiltInLanguage
, (IPTR
)"english"},
409 intreq
->ir_Catalog
= OpenCatalogA(intreq
->ir_Locale
, "System/Libs/asl.catalog", tags
);
415 FreeCommon(ld
, ASLB(AslBase
));
421 /*****************************************************************************************/
423 #define SKIPLONG(ptr, num) ptr += sizeof (LONG) * num
425 #define CONVBYTE(ptr, dest) dest = *ptr ++
427 #define SKIPBYTE(ptr) ptr ++;
429 #define CONVWORD(ptr, dest) dest = ptr[0] << 8 | ptr[1]; \
430 ptr += sizeof (WORD);
432 /*****************************************************************************************/
436 STATIC
struct FontPrefs
*GetFontPrefs(struct AslBase_intern
*AslBase
)
438 struct IFFHandle
*iff
;
439 struct Library
*IFFParseBase
;
441 struct StoredProperty
*sp
;
443 struct FontPrefs
*fp
= NULL
;
445 IFFParseBase
= OpenLibrary("iffparse.library", 0);
452 iff
->iff_Stream
= (IPTR
)Open("ENV:Sys/font.prefs", MODE_OLDFILE
);
457 if (OpenIFF(iff
, IFFF_READ
) == 0)
459 PropChunk(iff
, ID_PREF
, ID_FONT
);
462 if (ParseIFF(iff
, IFFPARSE_SCAN
) != 0)
465 sp
= FindProp(iff
, ID_PREF
, ID_FONT
);
469 fp
= AllocMem(sizeof (struct FontPrefs
), MEMF_ANY
);
476 /* Set ptr to start of struct FontPrefs */
479 /* Skip 4 first reserved longs */
481 CONVBYTE(ptr
, fp
->fp_FrontPen
);
482 CONVBYTE(ptr
, fp
->fp_BackPen
);
483 CONVBYTE(ptr
, fp
->fp_DrawMode
);
485 CONVWORD(ptr
, fp
->fp_TextAttr
.ta_YSize
);
486 CONVBYTE(ptr
, fp
->fp_TextAttr
.ta_Style
);
487 CONVBYTE(ptr
, fp
->fp_TextAttr
.ta_Flags
);
490 fontname
= AllocVec( strlen(ptr
) + 1, MEMF_ANY
);
493 strcpy(fontname
, ptr
);
495 fp
->fp_TextAttr
.ta_Name
= fontname
;
499 FreeMem(fp
, sizeof (struct FontPrefs
));
507 } /* if (ParseIFF(iff, IFFPARSE_SCAN) != 0) */
510 } /* if (OpenIFF(iff)) */
511 Close( (BPTR
)iff
->iff_Stream
);
513 } /* if (iff->iff_Stream) */
517 CloseLibrary(IFFParseBase
);
519 } /* if (IFFParseBase) */
523 } /* GetFontPrefs() */
527 /*****************************************************************************************/
531 STATIC VOID
FreeFontPrefs(struct FontPrefs
*fp
, struct AslBase_intern
*AslBase
)
534 FreeVec(fp
->fp_TextAttr
.ta_Name
);
535 FreeMem(fp
, sizeof (struct FontPrefs
));
541 /*****************************************************************************************/
543 BOOL
GetRequesterFont(struct LayoutData
*ld
, struct AslBase_intern
*AslBase
)
545 struct TextFont
*font
= NULL
;
547 struct TextAttr
*usedattr
, askattr
;
549 BOOL success
= FALSE
;
551 static struct TextAttr topaz8
= {"topaz.font", 8, 0, 0 };
553 /* Default to satisfy GCC */
557 Open the font we should use in the GUI.
558 First look for a user supplied TextAttr.
559 If not present, try to get the font preferences from ENV:Sys/font.prefs
560 If this fails, we fall back to topaz 8
563 /* Is there a user supplied font */
564 usedattr
= ld
->ld_IntReq
->ir_TextAttr
;
568 font
= OpenDiskFont (usedattr
);
571 /* If not, try screen font */
575 usedattr
= ld
->ld_Screen
->Font
;
578 font
= OpenDiskFont (usedattr
);
583 /* If no font has been opened yet, try the preferences one */
586 struct FontPrefs
*fprefs
;
588 fprefs
= GetFontPrefs(ASLB(AslBase
));
591 D(bug("Fontprefs found\n"));
593 D(bug("Name: %s, YSize :%d", fprefs
->fp_TextAttr
.ta_Name
, fprefs
->fp_TextAttr
.ta_YSize
));
595 usedattr
= &(fprefs
->fp_TextAttr
);
596 font
= OpenDiskFont(usedattr
);
600 FreeFontPrefs(fprefs
, ASLB(AslBase
));
606 /* No success, so try system default font */
612 SetFont(&(ld
->ld_DummyRP
), GfxBase
->DefaultFont
);
613 AskFont(&(ld
->ld_DummyRP
), usedattr
);
615 font
= OpenDiskFont(usedattr
);
618 /* Yet no font, try topaz 8 */
624 /* Here we should really use OpenDiskFont, but
625 * since AROS can't render diskfonts yet, we must use OpenFont()
628 font
= OpenFont(usedattr
);
634 /* We have to store the used textattr for later */
636 fontname
= AllocVec (strlen (usedattr
->ta_Name
) + 1, MEMF_ANY
);
640 strcpy (fontname
, usedattr
->ta_Name
);
642 ld
->ld_TextAttr
.ta_Name
= fontname
;
643 ld
->ld_TextAttr
.ta_YSize
= usedattr
->ta_YSize
;
644 ld
->ld_TextAttr
.ta_Style
= usedattr
->ta_Style
;
645 ld
->ld_TextAttr
.ta_Flags
= usedattr
->ta_Flags
;
655 /*****************************************************************************************/
657 BOOL
HandleEvents(struct LayoutData
*ld
, struct AslReqInfo
*reqinfo
, struct AslBase_intern
*AslBase
)
659 struct IntReq
*intreq
= ld
->ld_IntReq
;
660 APTR req
= ld
->ld_Req
;
661 struct IntuiMessage
*imsg
;
662 struct MsgPort
*port
;
664 BOOL terminated
= FALSE
;
666 EnterFunc(bug("HandleEvents(ld=%p, reqinfo=%p)\n", ld
, reqinfo
));
667 port
= ld
->ld_Window
->UserPort
;
671 if (ld
->ld_AppMsgPort
)
672 Wait((1L << port
->mp_SigBit
) | (1L << ld
->ld_AppMsgPort
->mp_SigBit
));
674 Wait((1L << port
->mp_SigBit
));
676 while ((imsg
= (struct IntuiMessage
*)GetMsg(port
)))
678 if ((imsg
->IDCMPWindow
== ld
->ld_Window
) ||
679 (imsg
->IDCMPWindow
== ld
->ld_Window2
))
683 case IDCMP_MOUSEMOVE
:
687 ld
->ld_Command
= LDCMD_LAYOUT
;
688 CallHookPkt(&(reqinfo
->GadgetryHook
), ld
, ASLB(AslBase
));
691 case IDCMP_REFRESHWINDOW
:
692 BeginRefresh(imsg
->IDCMPWindow
);
693 EndRefresh(imsg
->IDCMPWindow
, TRUE
);
697 /* Call the requester specific hook to handle events */
698 ld
->ld_Command
= LDCMD_HANDLEEVENTS
;
701 success
= CallHookPkt( &(reqinfo
->GadgetryHook
), ld
, ASLB(AslBase
));
702 if (success
== LDRET_FINISHED
)
715 } /* switch (imsg->Class) */
717 } /* if (imsg->IDCMPWindow is ld->ld_Window or ld->ld_Window2) */
718 else if (intreq
->ir_IntuiMsgFunc
)
721 REG_A4
= (ULONG
)intreq
->ir_BasePtr
; /* Compatability */
722 REG_A0
= (ULONG
)intreq
->ir_IntuiMsgFunc
;
724 REG_A1
= (ULONG
)imsg
;
725 (*MyEmulHandle
->EmulCallDirect68k
)(intreq
->ir_IntuiMsgFunc
->h_Entry
);
727 CallHookPkt(intreq
->ir_IntuiMsgFunc
, req
, imsg
);
730 ReplyMsg((struct Message
*)imsg
);
732 } /* while ((imsg = (struct IntuiMessage *)GetMsg(port))) */
734 while ((ld
->ld_AppMsgPort
) && (ld
->ld_AppMsg
= (struct AppMessage
*) GetMsg(ld
->ld_AppMsgPort
)))
736 ld
->ld_Command
= LDCMD_HANDLEAPPWINDOW
;
737 success
= CallHookPkt( &(reqinfo
->GadgetryHook
), ld
, ASLB(AslBase
));
738 ReplyMsg ((struct Message
*) ld
->ld_AppMsg
);
740 /* Do Intuition stuff only now, so we can have replied message quite early */
741 RefreshGadgets(((struct Gadget
*)((struct FRUserData
*)ld
->ld_UserData
)->Listview
), ld
->ld_Window
, (struct Requester
*)ld
->ld_Req
);
742 ActivateWindow(ld
->ld_Window
);
744 if (ld
->ld_ForeignerFiles
)
746 FRDropFromDifferentDrawersRequester(ld
, AslBase
);
747 MyFreeVecPooled(ld
->ld_ForeignerFiles
, AslBase
);
748 ld
->ld_ForeignerFiles
= NULL
;
751 if (success
== LDRET_FINISHED
)
761 } /* while ((ld->ld_AppMsgPort) && (ld->ld_AppMsg = (struct AppMessage *) GetMsg(ld->ld_AppMsgPort))) */
762 } /* while (!terminated) */
764 ReturnBool ("HandleEvents", success
);
766 } /* HandleEvents() */
768 /*****************************************************************************************/
770 UWORD
BiggestTextLength(STRPTR
*strarray
,
773 struct AslBase_intern
* AslBase
)
776 UWORD i
, w
= 0, new_w
;
778 for (i
= 0; strarray
[i
] && i
< numstrings
; i
++)
780 new_w
= TextLength(rp
, strarray
[i
], strlen(strarray
[i
]));
789 /*****************************************************************************************/
791 /* Strip special info from the requester structure */
793 VOID
StripRequester(APTR req
, UWORD reqtype
, struct AslBase_intern
*AslBase
)
797 case ASL_FileRequest
:
800 #define GetFR(r) ((struct FileRequester *)r)
803 * We can`t free it here, because it`s called by FreeAslRequest
804 * and AslRequest may have been overtaken by some other patch.
805 * Original FreeAslRequest doesn't free them.
806 * With MFR+mungwall it crashed here.
807 * It's freeed anyway when the Pool is deleted.
809 // dprintf("StripRequester: drawer 0x%lx\n",GetFR(req)->fr_Drawer);
810 // MyFreeVecPooled(GetFR(req)->fr_Drawer, AslBase);
811 GetFR(req
)->fr_Drawer
= NULL
;
813 // dprintf("StripRequester: file 0x%lx\n",GetFR(req)->fr_File);
814 // MyFreeVecPooled(GetFR(req)->fr_File, AslBase);
815 GetFR(req
)->fr_File
= NULL
;
817 // dprintf("StripRequester: pattern 0x%lx\n",GetFR(req)->fr_Pattern);
818 // MyFreeVecPooled(GetFR(req)->fr_Pattern, AslBase);
819 GetFR(req
)->fr_Pattern
= NULL
;
821 // dprintf("StripRequester: arglist 0x%lx\n",GetFR(req)->fr_ArgList);
822 if (GetFR(req
)->fr_ArgList
)
825 BPTR lock
= GetFR(req
)->fr_ArgList
->wa_Lock
;
827 // dprintf("StripRequester: lock 0x%lx\n",lock);
828 if (lock
) UnLock(lock
);
830 // dprintf("StripRequester: numargs 0x%lx\n",GetFR(req)->fr_NumArgs);
832 for (wbarg
= GetFR(req
)->fr_ArgList
; GetFR(req
)->fr_NumArgs
--; wbarg
++)
834 // dprintf("StripRequester: wbarg 0x%lx\n",wbarg);
835 MyFreeVecPooled(wbarg
->wa_Name
, AslBase
);
838 // dprintf("StripRequester: free arglist\n");
839 MyFreeVecPooled(GetFR(req
)->fr_ArgList
, AslBase
);
840 GetFR(req
)->fr_ArgList
= NULL
;
846 case ASL_FontRequest
:
849 #define GetFO(r) ((struct FontRequester *)r)
851 MyFreeVecPooled(GetFO(req
)->fo_TAttr
.tta_Name
, AslBase
);
852 GetFO(req
)->fo_TAttr
.tta_Name
= NULL
;
856 case ASL_ScreenModeRequest
:
862 /*****************************************************************************************/
864 WORD
CountNodes(struct List
*list
, WORD flag
)
869 ForeachNode(list
, node
)
871 if ((node
->ln_Pri
& flag
) == flag
) result
++;
877 /*****************************************************************************************/
879 struct Node
*FindListNode(struct List
*list
, WORD which
)
881 struct Node
*node
= NULL
;
885 for(node
= list
->lh_Head
; node
->ln_Succ
&& which
; node
= node
->ln_Succ
, which
--)
888 if (!node
->ln_Succ
) node
= NULL
;
894 /*****************************************************************************************/
896 void SortInNode(APTR req
, struct List
*list
, struct Node
*node
,
897 WORD (*compare
)(APTR req
, APTR node1
, APTR node2
, struct AslBase_intern
*AslBase
),
898 struct AslBase_intern
*AslBase
)
900 struct Node
*prevnode
= NULL
;
901 struct Node
*checknode
;
903 ForeachNode(list
, checknode
)
905 if (compare(req
, node
, checknode
, AslBase
) < 0) break;
907 prevnode
= checknode
;
910 Insert(list
, node
, prevnode
);
913 /*****************************************************************************************/
915 APTR
MyAllocVecPooled(APTR pool
, IPTR size
, struct AslBase_intern
*AslBase
)
919 //dprintf("MyAllocVecPooled: pool 0x%lx size %ld\n",pool,size);
921 size
+= sizeof(APTR
) * 2;
923 if ((mem
= AllocPooled(pool
, size
)))
925 //dprintf("MyAllocVecPooled: pool 0x%lx mem 0x%lx size %ld\n",pool,mem,size);
928 //dprintf("MyAllocVecPooled: mem 0x%lx\n");
934 /*****************************************************************************************/
936 void MyFreeVecPooled(APTR mem
, struct AslBase_intern
*AslBase
)
938 IPTR
*imem
= (IPTR
*)mem
;
943 APTR pool
= (APTR
)*--imem
;
945 //dprintf("MyFreeVecPooled: pool 0x%lx imem 0x%lx size %ld\n",pool,imem,size);
947 FreePooled(pool
, imem
, size
);
951 /*****************************************************************************************/
953 char *PooledCloneString(const char *name1
, const char *name2
, APTR pool
,
954 struct AslBase_intern
*AslBase
)
957 WORD len1
= strlen(name1
) + 1;
958 WORD len2
= name2
? strlen(name2
) : 0;
960 if ((clone
= AllocPooled(pool
, len1
+ len2
)))
962 CopyMem(name1
, clone
, len1
);
963 if (name2
) CopyMem(name2
, clone
+ len1
- 1, len2
+ 1);
969 /*****************************************************************************************/
971 char *PooledCloneStringLen(const char *name1
, ULONG len1
, const char *name2
, ULONG len2
, APTR pool
,
972 struct AslBase_intern
*AslBase
)
975 if ((clone
= AllocPooled(pool
, len1
+ len2
+ 1)))
977 CopyMem(name1
, clone
, len1
);
981 CopyMem(name2
, clone
+ len1
, len2
);
983 clone
[len1
+len2
] = '\0';
988 /*****************************************************************************************/
990 char *VecCloneString(const char *name1
, const char *name2
, struct AslBase_intern
*AslBase
)
993 WORD len1
= strlen(name1
) + 1;
994 WORD len2
= name2
? strlen(name2
) : 0;
996 if ((clone
= AllocVec(len1
+ len2
, MEMF_PUBLIC
)))
998 CopyMem(name1
, clone
, len1
);
999 if (name2
) CopyMem(name2
, clone
+ len1
- 1, len2
+ 1);
1005 /*****************************************************************************************/
1007 char *VecPooledCloneString(const char *name1
, const char *name2
, APTR pool
, struct AslBase_intern
*AslBase
)
1010 WORD len1
= strlen(name1
) + 1;
1011 WORD len2
= name2
? strlen(name2
) : 0;
1013 if ((clone
= MyAllocVecPooled(pool
, len1
+ len2
, AslBase
)))
1015 CopyMem(name1
, clone
, len1
);
1016 if (name2
) CopyMem(name2
, clone
+ len1
- 1, len2
+ 1);
1022 /*****************************************************************************************/
1024 AROS_UFH2 (void, puttostr
,
1025 AROS_UFHA(UBYTE
, chr
, D0
),
1026 AROS_UFHA(STRPTR
*,strPtrPtr
,A3
)
1035 /*****************************************************************************************/
1037 /* This is used for printing out fib_Size, which is why
1038 * is takes a IPTR instead of a ULONG
1040 char *PooledUIntegerToString(IPTR value
, APTR pool
, struct AslBase_intern
*AslBase
)
1047 /* Create the text */
1049 RawDoFmt("%iu", (RAWARG
)&value
, (VOID_FUNC
)AROS_ASMSYMNAME(puttostr
), &str
);
1051 len
= strlen(buffer
) + 1;
1053 if ((clone
= AllocPooled(pool
, len
)))
1055 CopyMem(buffer
, clone
, len
);
1061 /*****************************************************************************************/
1063 void CloseWindowSafely(struct Window
*window
, struct AslBase_intern
*AslBase
)
1065 struct IntuiMessage
*msg
;
1070 if(window
->UserPort
!= NULL
)
1072 msg
= (struct IntuiMessage
*)window
->UserPort
->mp_MsgList
.lh_Head
;
1074 while((succ
= msg
->ExecMessage
.mn_Node
.ln_Succ
))
1076 if(msg
->IDCMPWindow
== window
)
1078 Remove((struct Node
*)msg
);
1079 ReplyMsg((struct Message
*)msg
);
1082 msg
= (struct IntuiMessage
*)succ
;
1086 window
->UserPort
= NULL
;
1088 ModifyIDCMP(window
, 0);
1092 CloseWindow(window
);
1095 /*****************************************************************************************/
1097 AROS_UFH3(ULONG
, StringEditFunc
,
1098 AROS_UFHA(struct Hook
*, hook
, A0
),
1099 AROS_UFHA(struct SGWork
*, sgw
, A2
),
1100 AROS_UFHA(ULONG
*, command
, A1
))
1110 switch(sgw
->IEvent
->ie_Code
)
1113 case RAWKEY_PAGEDOWN
:
1117 case RAWKEY_NM_WHEEL_UP
:
1118 case RAWKEY_NM_WHEEL_DOWN
:
1119 sgw
->Code
= STRINGCODE_NOP
;
1120 sgw
->Actions
= SGA_END
| SGA_REUSE
;
1124 sgw
->EditOp
= EO_SPECIAL
;
1125 sgw
->Code
= STRINGCODE_CURSORUP
;
1126 sgw
->Actions
= SGA_END
;
1130 sgw
->EditOp
= EO_SPECIAL
;
1131 sgw
->Code
= STRINGCODE_CURSORDOWN
;
1132 sgw
->Actions
= SGA_END
;
1145 /*****************************************************************************************/
1147 void PaintInnerFrame(struct RastPort
*rp
, struct DrawInfo
*dri
, Object
*frameobj
,
1148 struct IBox
*framebox
, struct IBox
*innerbox
, ULONG pen
,
1149 struct AslBase_intern
*AslBase
)
1151 struct impFrameBox fmsg
;
1154 WORD x1
, y1
, x2
, y2
;
1155 WORD ix1
, iy1
, ix2
, iy2
;
1157 cbox
.Left
= framebox
->Left
;
1158 cbox
.Top
= framebox
->Top
;
1159 cbox
.Width
= framebox
->Width
;
1160 cbox
.Height
= framebox
->Height
;
1162 fmsg
.MethodID
= IM_FRAMEBOX
;
1163 fmsg
.imp_ContentsBox
= &cbox
;
1164 fmsg
.imp_FrameBox
= &fbox
;
1165 fmsg
.imp_DrInfo
= dri
;
1166 fmsg
.imp_FrameFlags
= 0;
1168 DoMethodA(frameobj
, (Msg
)&fmsg
);
1170 SetABPenDrMd(rp
, pen
, 0, JAM1
);
1174 x2
= x1
+ fbox
.Width
- 1;
1175 y2
= y1
+ fbox
.Height
- 1;
1179 ix2
= ix1
+ cbox
.Width
- 1;
1180 iy2
= iy1
+ cbox
.Height
- 1;
1187 x1
= innerbox
->Left
- 1;
1188 y1
= innerbox
->Top
- 1;
1189 x2
= innerbox
->Left
+ innerbox
->Width
;
1190 y2
= innerbox
->Top
+ innerbox
->Height
;
1192 RectFill(rp
, ix1
, iy1
, ix2
, y1
);
1193 RectFill(rp
, ix1
, iy1
, x1
, iy2
);
1194 RectFill(rp
, x2
, iy1
, ix2
, iy2
);
1195 RectFill(rp
, ix1
, y2
, ix2
, iy2
);
1199 /*****************************************************************************************/
1201 void PaintBoxFrame(struct RastPort
*rp
, struct IBox
*outerbox
, struct IBox
*innerbox
,
1202 ULONG pen
, struct AslBase_intern
*AslBase
)
1204 WORD x1
, y1
, x2
, y2
;
1205 WORD ix1
, iy1
, ix2
, iy2
;
1207 ix1
= outerbox
->Left
;
1208 iy1
= outerbox
->Top
- 1;
1209 ix2
= outerbox
->Left
+ outerbox
->Width
- 1;
1210 iy2
= outerbox
->Top
+ outerbox
->Height
- 1;
1212 x1
= innerbox
->Left
- 1;
1213 y1
= innerbox
->Top
- 1;
1214 x2
= innerbox
->Left
+ innerbox
->Width
;
1215 y2
= innerbox
->Top
+ innerbox
->Height
;
1217 SetABPenDrMd(rp
, pen
, 0, JAM1
);
1219 RectFill(rp
, ix1
, iy1
, ix2
, y1
);
1220 RectFill(rp
, ix1
, iy1
, x1
, iy2
);
1221 RectFill(rp
, x2
, iy1
, ix2
, iy2
);
1222 RectFill(rp
, ix1
, y2
, ix2
, iy2
);
1226 /*****************************************************************************************/