2 Copyright © 1995-2001, The AROS Development Team. All rights reserved.
5 Desc: Basic helpfuncs for Asl.
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>
20 #include <exec/lists.h>
21 #include <exec/memory.h>
22 #include <intuition/intuition.h>
23 #include <intuition/screens.h>
24 #include <intuition/classusr.h>
25 #include <intuition/imageclass.h>
26 #include <graphics/gfxbase.h>
27 #include <devices/rawkeycodes.h>
28 #include <prefs/prefhdr.h>
29 #include <prefs/font.h>
30 #include <libraries/iffparse.h>
34 #include "asl_intern.h"
40 #include <aros/debug.h>
42 /*****************************************************************************************/
44 STATIC BOOL
GetRequesterFont(struct LayoutData
*, struct AslBase_intern
*);
47 STATIC
struct FontPrefs
*GetFontPrefs(struct AslBase_intern
*);
48 STATIC VOID
FreeFontPrefs(struct FontPrefs
*, struct AslBase_intern
*);
51 /*****************************************************************************************/
53 /* Finds the internal requester data for a requester */
55 struct ReqNode
*FindReqNode(APTR req
, struct AslBase_intern
*AslBase
)
57 struct ReqNode
*reqnode
, *foundreqnode
= NULL
;
59 ObtainSemaphoreShared( &(AslBase
->ReqListSem
) );
61 ForeachNode( &(AslBase
->ReqList
), reqnode
)
63 if (reqnode
->rn_Req
== req
)
65 foundreqnode
= reqnode
;
70 ReleaseSemaphore( &(AslBase
->ReqListSem
) );
72 return (foundreqnode
);
75 /*****************************************************************************************/
79 struct IntReq
*intreq
,
80 struct TagItem
*taglist
,
81 struct AslBase_intern
*AslBase
85 const struct TagItem
*tstate
= taglist
;
87 while ((tag
= NextTagItem(&tstate
)) != NULL
)
89 IPTR tidata
= tag
->ti_Data
;
91 /* The tags that are put "in a row" are defined as the same value,
92 and therefor we only use one of them, but the effect is for all of them
100 case ASL_Window: */ /* Obsolete */
101 intreq
->ir_Window
= (struct Window
*)tidata
;
105 /* case ASLFO_Screen:
106 case ASLSM_Screen: */
107 intreq
->ir_Screen
= (struct Screen
*)tidata
;
110 case ASLFR_PubScreenName
:
111 /* case ASLFO_PubScreenName:
112 case ASLSM_PubScreenName: */
114 intreq
->ir_PubScreenName
= (STRPTR
)tidata
;
117 case ASLFR_PrivateIDCMP
:
118 /* case ASLFO_PrivateIDCMP:
119 case ASLSM_PrivateIDCMP: */
121 intreq
->ir_Flags
|= IF_PRIVATEIDCMP
;
123 intreq
->ir_Flags
&= ~IF_PRIVATEIDCMP
;
127 case ASLFR_IntuiMsgFunc
:
128 /* case ASLFO_IntuiMsgFunc:
129 case ASLSM_IntuiMsgFunc: */
130 intreq
->ir_IntuiMsgFunc
= (struct Hook
*)tidata
;
133 case ASLFR_SleepWindow
:
134 /* case ASLFO_SleepWindow:
135 case ASLSM_SleepWindow: */
137 intreq
->ir_Flags
|= IF_SLEEPWINDOW
;
139 intreq
->ir_Flags
&= ~IF_SLEEPWINDOW
;
142 case ASLFR_PopToFront
:
143 /* case ASLFO_PopToFront:
144 case ASLSM_PopToFront: */
146 intreq
->ir_Flags
|= IF_POPTOFRONT
;
148 intreq
->ir_Flags
&= ~IF_POPTOFRONT
;
152 /* case ASLFO_Activate:
153 case ASLSM_Activate: */
155 intreq
->ir_Flags
&= ~IF_OPENINACTIVE
;
157 intreq
->ir_Flags
|= IF_OPENINACTIVE
;
161 /* case ASLFO_TextAttr:
162 case ASLSM_TextAttr: */
163 intreq
->ir_TextAttr
= (struct TextAttr
*)tidata
;
167 /* case ASLFO_Locale:
168 case ASLSM_Locale: */
169 intreq
->ir_Locale
= (struct Locale
*)tidata
;
172 case ASLFR_TitleText
:
173 /* case ASLFO_TitleText:
174 case ASLSM_TitleText:
175 case ASL_Hail: */ /* Obsolete */
177 intreq
->ir_TitleText
= (STRPTR
)tidata
;
181 case ASLFR_PositiveText
:
182 /* case ASLFO_PositiveText:
183 case ASLSM_PositiveText:
184 case ASL_OKText: */ /* Obsolete */
187 intreq
->ir_PositiveText
= (STRPTR
)tidata
;
188 intreq
->ir_Flags
|= IF_USER_POSTEXT
;
192 case ASLFR_NegativeText
:
193 /* case ASLFO_NegativeText:
194 case ASLSM_NegativeText:
195 case ASL_CancelText: */ /* Obsolete */
198 intreq
->ir_NegativeText
= (STRPTR
)tidata
;
199 intreq
->ir_Flags
|= IF_USER_NEGTEXT
;
203 case ASLFR_InitialLeftEdge
:
204 /* case ASLFO_InitialLeftEdge:
205 case ASLSM_InitialLeftEdge:
206 case ASL_LeftEdge: */ /* Obsolete */
207 intreq
->ir_LeftEdge
= (UWORD
)tidata
;
210 case ASLFR_InitialTopEdge
:
211 /* case ASLFO_InitialTopEdge:
212 case ASLSM_InitialTopEdge:
213 case ASL_TopEdge: */ /* Obsolete */
214 intreq
->ir_TopEdge
= (UWORD
)tidata
;
217 case ASLFR_InitialWidth
:
218 /* case ASLFO_InitialWidth:
219 case ASLSM_InitialWidth:
220 case ASL_Width: */ /* Obsolete */
221 intreq
->ir_Width
= (UWORD
)tidata
;
224 case ASLFR_InitialHeight
:
225 /* case ASLFO_InitialHeight:
226 case ASLSM_InitialHeight:
227 case ASL_Height: */ /* Obsolete */
228 intreq
->ir_Height
= (UWORD
)tidata
;
234 } /* switch (tag->ti_Tag) */
236 } /* while ((tag = NextTagItem((const struct TagItem **)&tstate)) != NULL) */
240 /*****************************************************************************************/
242 VOID
FreeCommon(struct LayoutData
*ld
, struct AslBase_intern
*AslBase
)
247 if (ld
->ld_IntReq
->ir_Catalog
) CloseCatalog(ld
->ld_IntReq
->ir_Catalog
);
252 ClearMenuStrip(ld
->ld_Window
);
254 FreeMenus(ld
->ld_Menu
);
259 if (ld
->ld_IntReq
->ir_Flags
& IF_POPPEDTOFRONT
)
261 ld
->ld_IntReq
->ir_Flags
&= ~IF_POPPEDTOFRONT
;
262 ScreenToBack(ld
->ld_Window
->WScreen
);
265 if ((ld
->ld_IntReq
->ir_Flags
& IF_PRIVATEIDCMP
) || (!ld
->ld_IntReq
->ir_Window
))
267 CloseWindow(ld
->ld_Window
);
271 CloseWindowSafely(ld
->ld_Window
, AslBase
);
275 D(bug("Window freed\n"));
277 if (ld
->ld_VisualInfo
) FreeVisualInfo(ld
->ld_VisualInfo
);
278 if (ld
->ld_Dri
) FreeScreenDrawInfo(ld
->ld_Screen
, ld
->ld_Dri
);
280 if (ld
->ld_ScreenLocked
)
281 UnlockPubScreen(NULL
, ld
->ld_Screen
);
284 FreeVec(ld
->ld_UserData
);
287 CloseFont(ld
->ld_Font
);
289 if (ld
->ld_TextAttr
.ta_Name
)
290 FreeVec(ld
->ld_TextAttr
.ta_Name
);
292 DeinitRastPort(&(ld
->ld_DummyRP
));
294 FreeMem(ld
, sizeof (struct LayoutData
));
300 /*****************************************************************************************/
302 struct LayoutData
*AllocCommon
305 struct IntReq
*intreq
,
307 struct AslBase_intern
*AslBase
310 struct Screen
*screen
= NULL
;
311 struct LayoutData
*ld
;
314 ld
= AllocMem(sizeof (struct LayoutData
), MEMF_ANY
|MEMF_CLEAR
);
318 /* Save the internal and public requester struct, so that the
319 requester type specific hook may find them */
320 ld
->ld_IntReq
= intreq
;
321 ld
->ld_Req
= requester
;
323 InitRastPort(&(ld
->ld_DummyRP
));
325 /* We need to lock the screen we should open on to be sure it
329 /* Find screen on which to open window */
331 screen
= intreq
->ir_Screen
;
332 if (!screen
&& intreq
->ir_PubScreenName
)
334 if ((screen
= LockPubScreen(intreq
->ir_PubScreenName
)))
336 ld
->ld_ScreenLocked
= TRUE
;
339 if (!screen
&& intreq
->ir_Window
)
341 screen
= intreq
->ir_Window
->WScreen
;
343 if (!screen
&& !intreq
->ir_PubScreenName
)
345 if ((screen
= LockPubScreen(NULL
)))
347 ld
->ld_ScreenLocked
= TRUE
;
351 if (!screen
) goto failure
;
353 ld
->ld_Screen
= screen
;
355 if (!(ld
->ld_Dri
= GetScreenDrawInfo(screen
))) goto failure
;
357 if (!(ld
->ld_VisualInfo
= GetVisualInfoA(screen
, NULL
))) goto failure
;
359 ld
->ld_WBorLeft
= screen
->WBorLeft
;
360 ld
->ld_WBorTop
= screen
->WBorTop
+ screen
->Font
->ta_YSize
+ 1;
361 ld
->ld_WBorRight
= screen
->WBorRight
;
362 ld
->ld_WBorBottom
= 16;
365 struct TagItem sysi_tags
[] =
367 {SYSIA_DrawInfo
, (IPTR
)ld
->ld_Dri
},
368 {SYSIA_Which
, SIZEIMAGE
},
374 if ((im
= NewObjectA(NULL
, SYSICLASS
, sysi_tags
)))
378 if (GetAttr(IA_Height
, im
, &height
))
380 ld
->ld_WBorBottom
= height
;
387 if(GetBitMapAttr(screen
->RastPort
.BitMap
, BMA_DEPTH
) > 8) ld
->ld_TrueColor
= TRUE
;
389 if (!(ld
->ld_UserData
= AllocVec(udatasize
, MEMF_ANY
|MEMF_CLEAR
)))
392 if (!GetRequesterFont(ld
, ASLB(AslBase
)))
395 SetFont( &(ld
->ld_DummyRP
), ld
->ld_Font
);
399 struct TagItem tags
[] =
401 {OC_BuiltInLanguage
, (IPTR
)"english"},
406 intreq
->ir_Catalog
= OpenCatalogA(intreq
->ir_Locale
, "System/Libs/asl.catalog", tags
);
412 FreeCommon(ld
, ASLB(AslBase
));
418 /*****************************************************************************************/
420 #define SKIPLONG(ptr, num) ptr += sizeof (LONG) * num
422 #define CONVBYTE(ptr, dest) dest = *ptr ++
424 #define SKIPBYTE(ptr) ptr ++;
426 #define CONVWORD(ptr, dest) dest = ptr[0] << 8 | ptr[1]; \
427 ptr += sizeof (WORD);
429 /*****************************************************************************************/
433 STATIC
struct FontPrefs
*GetFontPrefs(struct AslBase_intern
*AslBase
)
435 struct IFFHandle
*iff
;
436 struct Library
*IFFParseBase
;
438 struct StoredProperty
*sp
;
440 struct FontPrefs
*fp
= NULL
;
442 IFFParseBase
= OpenLibrary("iffparse.library", 0);
449 iff
->iff_Stream
= (IPTR
)Open("ENV:Sys/font.prefs", MODE_OLDFILE
);
454 if (OpenIFF(iff
, IFFF_READ
) == 0)
456 PropChunk(iff
, ID_PREF
, ID_FONT
);
459 if (ParseIFF(iff
, IFFPARSE_SCAN
) != 0)
462 sp
= FindProp(iff
, ID_PREF
, ID_FONT
);
466 fp
= AllocMem(sizeof (struct FontPrefs
), MEMF_ANY
);
473 /* Set ptr to start of struct FontPrefs */
476 /* Skip 4 first reserved longs */
478 CONVBYTE(ptr
, fp
->fp_FrontPen
);
479 CONVBYTE(ptr
, fp
->fp_BackPen
);
480 CONVBYTE(ptr
, fp
->fp_DrawMode
);
482 CONVWORD(ptr
, fp
->fp_TextAttr
.ta_YSize
);
483 CONVBYTE(ptr
, fp
->fp_TextAttr
.ta_Style
);
484 CONVBYTE(ptr
, fp
->fp_TextAttr
.ta_Flags
);
487 fontname
= AllocVec( strlen(ptr
) + 1, MEMF_ANY
);
490 strcpy(fontname
, ptr
);
492 fp
->fp_TextAttr
.ta_Name
= fontname
;
496 FreeMem(fp
, sizeof (struct FontPrefs
));
504 } /* if (ParseIFF(iff, IFFPARSE_SCAN) != 0) */
507 } /* if (OpenIFF(iff)) */
508 Close( (BPTR
)iff
->iff_Stream
);
510 } /* if (iff->iff_Stream) */
514 CloseLibrary(IFFParseBase
);
516 } /* if (IFFParseBase) */
520 } /* GetFontPrefs() */
524 /*****************************************************************************************/
528 STATIC VOID
FreeFontPrefs(struct FontPrefs
*fp
, struct AslBase_intern
*AslBase
)
531 FreeVec(fp
->fp_TextAttr
.ta_Name
);
532 FreeMem(fp
, sizeof (struct FontPrefs
));
539 /*****************************************************************************************/
541 BOOL
GetRequesterFont(struct LayoutData
*ld
, struct AslBase_intern
*AslBase
)
543 struct TextFont
*font
= NULL
;
545 struct TextAttr
*usedattr
, askattr
;
547 BOOL success
= FALSE
;
549 static struct TextAttr topaz8
= {"topaz.font", 8, 0, 0 };
551 /* Default to satisfy GCC */
555 Open the font we should use in the GUI.
556 First look for a user supplied TextAttr.
557 If not present, try to get the font preferences from ENV:Sys/font.prefs
558 If this fails, we fall back to topaz 8
561 /* Is there a user supplied font */
562 usedattr
= ld
->ld_IntReq
->ir_TextAttr
;
566 font
= OpenDiskFont (usedattr
);
569 /* If not, try screen font */
573 usedattr
= ld
->ld_Screen
->Font
;
576 font
= OpenDiskFont (usedattr
);
581 /* If no font has been opened yet, try the preferences one */
584 struct FontPrefs
*fprefs
;
586 fprefs
= GetFontPrefs(ASLB(AslBase
));
589 D(bug("Fontprefs found\n"));
591 D(bug("Name: %s, YSize :%d", fprefs
->fp_TextAttr
.ta_Name
, fprefs
->fp_TextAttr
.ta_YSize
));
593 usedattr
= &(fprefs
->fp_TextAttr
);
594 font
= OpenDiskFont(usedattr
);
598 FreeFontPrefs(fprefs
, ASLB(AslBase
));
604 /* No success, so try system default font */
610 SetFont(&(ld
->ld_DummyRP
), GfxBase
->DefaultFont
);
611 AskFont(&(ld
->ld_DummyRP
), usedattr
);
613 font
= OpenDiskFont(usedattr
);
616 /* Yet no font, try topaz 8 */
622 /* Here we should really use OpenDiskFont, but
623 * since AROS can't render diskfonts yet, we must use OpenFont()
626 font
= OpenFont(usedattr
);
632 /* We have to store the used textattr for later */
634 fontname
= AllocVec (strlen (usedattr
->ta_Name
) + 1, MEMF_ANY
);
638 strcpy (fontname
, usedattr
->ta_Name
);
640 ld
->ld_TextAttr
.ta_Name
= fontname
;
641 ld
->ld_TextAttr
.ta_YSize
= usedattr
->ta_YSize
;
642 ld
->ld_TextAttr
.ta_Style
= usedattr
->ta_Style
;
643 ld
->ld_TextAttr
.ta_Flags
= usedattr
->ta_Flags
;
653 /*****************************************************************************************/
655 BOOL
HandleEvents(struct LayoutData
*ld
, struct AslReqInfo
*reqinfo
, struct AslBase_intern
*AslBase
)
657 struct IntReq
*intreq
= ld
->ld_IntReq
;
658 APTR req
= ld
->ld_Req
;
659 struct IntuiMessage
*imsg
;
660 struct MsgPort
*port
;
662 BOOL terminated
= FALSE
;
664 EnterFunc(bug("HandleEvents(ld=%p, reqinfo=%p)\n", ld
, reqinfo
));
665 port
= ld
->ld_Window
->UserPort
;
669 if ((imsg
= (struct IntuiMessage
*)GetMsg(port
)) != NULL
)
671 if ((imsg
->IDCMPWindow
== ld
->ld_Window
) ||
672 (imsg
->IDCMPWindow
== ld
->ld_Window2
))
676 case IDCMP_MOUSEMOVE
:
680 ld
->ld_Command
= LDCMD_LAYOUT
;
681 CallHookPkt(&(reqinfo
->GadgetryHook
), ld
, ASLB(AslBase
));
684 case IDCMP_REFRESHWINDOW
:
685 BeginRefresh(imsg
->IDCMPWindow
);
686 EndRefresh(imsg
->IDCMPWindow
, TRUE
);
690 /* Call the requester specific hook to handle events */
691 ld
->ld_Command
= LDCMD_HANDLEEVENTS
;
694 success
= CallHookPkt( &(reqinfo
->GadgetryHook
), ld
, ASLB(AslBase
));
695 if (success
== LDRET_FINISHED
)
708 } /* switch (imsg->Class */
710 } /* if (imsg->IDCMPWindow is ld->ld_Window or ld->ld_Window2) */
711 else if (intreq
->ir_IntuiMsgFunc
)
714 REG_A4
= (ULONG
)intreq
->ir_BasePtr
; /* Compatability */
715 REG_A0
= (ULONG
)intreq
->ir_IntuiMsgFunc
;
717 REG_A1
= (ULONG
)imsg
;
718 (*MyEmulHandle
->EmulCallDirect68k
)(intreq
->ir_IntuiMsgFunc
->h_Entry
);
720 CallHookPkt(intreq
->ir_IntuiMsgFunc
, req
, imsg
);
723 ReplyMsg((struct Message
*)imsg
);
725 } /* if ((imsg = GetMsg(port)) != NULL) */
728 Wait(1L << port
->mp_SigBit
);
731 } /* while (!terminated) */
733 ReturnBool ("HandleEvents", success
);
735 } /* HandleEvents() */
737 /*****************************************************************************************/
739 UWORD
BiggestTextLength(STRPTR
*strarray
,
742 struct AslBase_intern
* AslBase
)
745 UWORD i
, w
= 0, new_w
;
747 for (i
= 0; strarray
[i
] && i
< numstrings
; i
++)
749 new_w
= TextLength(rp
, strarray
[i
], strlen(strarray
[i
]));
758 /*****************************************************************************************/
760 /* Strip special info from the requester structure */
762 VOID
StripRequester(APTR req
, UWORD reqtype
, struct AslBase_intern
*AslBase
)
766 case ASL_FileRequest
:
769 #define GetFR(r) ((struct FileRequester *)r)
772 * We can`t free it here, because it`s called by FreeAslRequest
773 * and AslRequest may have been overtaken by some other patch.
774 * Original FreeAslRequest doesn't free them.
775 * With MFR+mungwall it crashed here.
776 * It's freeed anyway when the Pool is deleted.
778 // dprintf("StripRequester: drawer 0x%lx\n",GetFR(req)->fr_Drawer);
779 // MyFreeVecPooled(GetFR(req)->fr_Drawer, AslBase);
780 GetFR(req
)->fr_Drawer
= NULL
;
782 // dprintf("StripRequester: file 0x%lx\n",GetFR(req)->fr_File);
783 // MyFreeVecPooled(GetFR(req)->fr_File, AslBase);
784 GetFR(req
)->fr_File
= NULL
;
786 // dprintf("StripRequester: pattern 0x%lx\n",GetFR(req)->fr_Pattern);
787 // MyFreeVecPooled(GetFR(req)->fr_Pattern, AslBase);
788 GetFR(req
)->fr_Pattern
= NULL
;
790 // dprintf("StripRequester: arglist 0x%lx\n",GetFR(req)->fr_ArgList);
791 if (GetFR(req
)->fr_ArgList
)
794 BPTR lock
= GetFR(req
)->fr_ArgList
->wa_Lock
;
796 // dprintf("StripRequester: lock 0x%lx\n",lock);
797 if (lock
) UnLock(lock
);
799 // dprintf("StripRequester: numargs 0x%lx\n",GetFR(req)->fr_NumArgs);
801 for (wbarg
= GetFR(req
)->fr_ArgList
; GetFR(req
)->fr_NumArgs
--; wbarg
++)
803 // dprintf("StripRequester: wbarg 0x%lx\n",wbarg);
804 MyFreeVecPooled(wbarg
->wa_Name
, AslBase
);
807 // dprintf("StripRequester: free arglist\n");
808 MyFreeVecPooled(GetFR(req
)->fr_ArgList
, AslBase
);
809 GetFR(req
)->fr_ArgList
= NULL
;
815 case ASL_FontRequest
:
818 #define GetFO(r) ((struct FontRequester *)r)
820 MyFreeVecPooled(GetFO(req
)->fo_TAttr
.tta_Name
, AslBase
);
821 GetFO(req
)->fo_TAttr
.tta_Name
= NULL
;
825 case ASL_ScreenModeRequest
:
832 /*****************************************************************************************/
834 WORD
CountNodes(struct List
*list
, WORD flag
)
839 ForeachNode(list
, node
)
841 if ((node
->ln_Pri
& flag
) == flag
) result
++;
847 /*****************************************************************************************/
849 struct Node
*FindListNode(struct List
*list
, WORD which
)
851 struct Node
*node
= NULL
;
855 for(node
= list
->lh_Head
; node
->ln_Succ
&& which
; node
= node
->ln_Succ
, which
--)
858 if (!node
->ln_Succ
) node
= NULL
;
864 /*****************************************************************************************/
866 void SortInNode(APTR req
, struct List
*list
, struct Node
*node
,
867 WORD (*compare
)(APTR req
, APTR node1
, APTR node2
, struct AslBase_intern
*AslBase
),
868 struct AslBase_intern
*AslBase
)
870 struct Node
*prevnode
= NULL
;
871 struct Node
*checknode
;
873 ForeachNode(list
, checknode
)
875 if (compare(req
, node
, checknode
, AslBase
) < 0) break;
877 prevnode
= checknode
;
880 Insert(list
, node
, prevnode
);
883 /*****************************************************************************************/
885 APTR
MyAllocVecPooled(APTR pool
, IPTR size
, struct AslBase_intern
*AslBase
)
889 //dprintf("MyAllocVecPooled: pool 0x%lx size %ld\n",pool,size);
891 size
+= sizeof(APTR
) * 2;
893 if ((mem
= AllocPooled(pool
, size
)))
895 //dprintf("MyAllocVecPooled: pool 0x%lx mem 0x%lx size %ld\n",pool,mem,size);
898 //dprintf("MyAllocVecPooled: mem 0x%lx\n");
904 /*****************************************************************************************/
906 void MyFreeVecPooled(APTR mem
, struct AslBase_intern
*AslBase
)
908 IPTR
*imem
= (IPTR
*)mem
;
913 APTR pool
= (APTR
)*--imem
;
915 //dprintf("MyFreeVecPooled: pool 0x%lx imem 0x%lx size %ld\n",pool,imem,size);
917 FreePooled(pool
, imem
, size
);
921 /*****************************************************************************************/
923 char *PooledCloneString(const char *name1
, const char *name2
, APTR pool
,
924 struct AslBase_intern
*AslBase
)
927 WORD len1
= strlen(name1
) + 1;
928 WORD len2
= name2
? strlen(name2
) : 0;
930 if ((clone
= AllocPooled(pool
, len1
+ len2
)))
932 CopyMem(name1
, clone
, len1
);
933 if (name2
) CopyMem(name2
, clone
+ len1
- 1, len2
+ 1);
939 /*****************************************************************************************/
941 char *PooledCloneStringLen(const char *name1
, ULONG len1
, const char *name2
, ULONG len2
, APTR pool
,
942 struct AslBase_intern
*AslBase
)
945 if ((clone
= AllocPooled(pool
, len1
+ len2
+ 1)))
947 CopyMem(name1
, clone
, len1
);
951 CopyMem(name2
, clone
+ len1
, len2
);
953 clone
[len1
+len2
] = '\0';
958 /*****************************************************************************************/
960 char *VecCloneString(const char *name1
, const char *name2
, struct AslBase_intern
*AslBase
)
963 WORD len1
= strlen(name1
) + 1;
964 WORD len2
= name2
? strlen(name2
) : 0;
966 if ((clone
= AllocVec(len1
+ len2
, MEMF_PUBLIC
)))
968 CopyMem(name1
, clone
, len1
);
969 if (name2
) CopyMem(name2
, clone
+ len1
- 1, len2
+ 1);
975 /*****************************************************************************************/
977 char *VecPooledCloneString(const char *name1
, const char *name2
, APTR pool
, struct AslBase_intern
*AslBase
)
980 WORD len1
= strlen(name1
) + 1;
981 WORD len2
= name2
? strlen(name2
) : 0;
983 if ((clone
= MyAllocVecPooled(pool
, len1
+ len2
, AslBase
)))
985 CopyMem(name1
, clone
, len1
);
986 if (name2
) CopyMem(name2
, clone
+ len1
- 1, len2
+ 1);
992 /*****************************************************************************************/
994 AROS_UFH2 (void, puttostr
,
995 AROS_UFHA(UBYTE
, chr
, D0
),
996 AROS_UFHA(STRPTR
*,strPtrPtr
,A3
)
1005 /*****************************************************************************************/
1007 char *PooledUIntegerToString(IPTR value
, APTR pool
, struct AslBase_intern
*AslBase
)
1014 /* Create the text */
1016 RawDoFmt("%lu", &value
, (VOID_FUNC
)AROS_ASMSYMNAME(puttostr
), &str
);
1018 len
= strlen(buffer
) + 1;
1020 if ((clone
= AllocPooled(pool
, len
)))
1022 CopyMem(buffer
, clone
, len
);
1028 /*****************************************************************************************/
1030 void CloseWindowSafely(struct Window
*window
, struct AslBase_intern
*AslBase
)
1032 struct IntuiMessage
*msg
;
1037 if(window
->UserPort
!= NULL
)
1039 msg
= (struct IntuiMessage
*)window
->UserPort
->mp_MsgList
.lh_Head
;
1041 while((succ
= msg
->ExecMessage
.mn_Node
.ln_Succ
))
1043 if(msg
->IDCMPWindow
== window
)
1045 Remove((struct Node
*)msg
);
1046 ReplyMsg((struct Message
*)msg
);
1049 msg
= (struct IntuiMessage
*)succ
;
1053 window
->UserPort
= NULL
;
1055 ModifyIDCMP(window
, 0);
1059 CloseWindow(window
);
1062 /*****************************************************************************************/
1064 AROS_UFH3(ULONG
, StringEditFunc
,
1065 AROS_UFHA(struct Hook
*, hook
, A0
),
1066 AROS_UFHA(struct SGWork
*, sgw
, A2
),
1067 AROS_UFHA(ULONG
*, command
, A1
))
1077 switch(sgw
->IEvent
->ie_Code
)
1080 case RAWKEY_PAGEDOWN
:
1084 case RAWKEY_NM_WHEEL_UP
:
1085 case RAWKEY_NM_WHEEL_DOWN
:
1086 sgw
->Code
= STRINGCODE_NOP
;
1087 sgw
->Actions
= SGA_END
| SGA_REUSE
;
1091 sgw
->EditOp
= EO_SPECIAL
;
1092 sgw
->Code
= STRINGCODE_CURSORUP
;
1093 sgw
->Actions
= SGA_END
;
1097 sgw
->EditOp
= EO_SPECIAL
;
1098 sgw
->Code
= STRINGCODE_CURSORDOWN
;
1099 sgw
->Actions
= SGA_END
;
1112 /*****************************************************************************************/
1114 void PaintInnerFrame(struct RastPort
*rp
, struct DrawInfo
*dri
, Object
*frameobj
,
1115 struct IBox
*framebox
, struct IBox
*innerbox
, ULONG pen
,
1116 struct AslBase_intern
*AslBase
)
1118 struct impFrameBox fmsg
;
1121 WORD x1
, y1
, x2
, y2
;
1122 WORD ix1
, iy1
, ix2
, iy2
;
1124 cbox
.Left
= framebox
->Left
;
1125 cbox
.Top
= framebox
->Top
;
1126 cbox
.Width
= framebox
->Width
;
1127 cbox
.Height
= framebox
->Height
;
1129 fmsg
.MethodID
= IM_FRAMEBOX
;
1130 fmsg
.imp_ContentsBox
= &cbox
;
1131 fmsg
.imp_FrameBox
= &fbox
;
1132 fmsg
.imp_DrInfo
= dri
;
1133 fmsg
.imp_FrameFlags
= 0;
1135 DoMethodA(frameobj
, (Msg
)&fmsg
);
1137 SetABPenDrMd(rp
, pen
, 0, JAM1
);
1141 x2
= x1
+ fbox
.Width
- 1;
1142 y2
= y1
+ fbox
.Height
- 1;
1146 ix2
= ix1
+ cbox
.Width
- 1;
1147 iy2
= iy1
+ cbox
.Height
- 1;
1154 x1
= innerbox
->Left
- 1;
1155 y1
= innerbox
->Top
- 1;
1156 x2
= innerbox
->Left
+ innerbox
->Width
;
1157 y2
= innerbox
->Top
+ innerbox
->Height
;
1159 RectFill(rp
, ix1
, iy1
, ix2
, y1
);
1160 RectFill(rp
, ix1
, iy1
, x1
, iy2
);
1161 RectFill(rp
, x2
, iy1
, ix2
, iy2
);
1162 RectFill(rp
, ix1
, y2
, ix2
, iy2
);
1166 /*****************************************************************************************/
1168 void PaintBoxFrame(struct RastPort
*rp
, struct IBox
*outerbox
, struct IBox
*innerbox
,
1169 ULONG pen
, struct AslBase_intern
*AslBase
)
1171 WORD x1
, y1
, x2
, y2
;
1172 WORD ix1
, iy1
, ix2
, iy2
;
1174 ix1
= outerbox
->Left
;
1175 iy1
= outerbox
->Top
- 1;
1176 ix2
= outerbox
->Left
+ outerbox
->Width
- 1;
1177 iy2
= outerbox
->Top
+ outerbox
->Height
- 1;
1179 x1
= innerbox
->Left
- 1;
1180 y1
= innerbox
->Top
- 1;
1181 x2
= innerbox
->Left
+ innerbox
->Width
;
1182 y2
= innerbox
->Top
+ innerbox
->Height
;
1184 SetABPenDrMd(rp
, pen
, 0, JAM1
);
1186 RectFill(rp
, ix1
, iy1
, ix2
, y1
);
1187 RectFill(rp
, ix1
, iy1
, x1
, iy2
);
1188 RectFill(rp
, x2
, iy1
, ix2
, iy2
);
1189 RectFill(rp
, ix1
, y2
, ix2
, iy2
);
1193 /*****************************************************************************************/