2 Copyright © 1995-2010, The AROS Development Team. All rights reserved.
3 Copyright © 2001-2003, The MorphOS Development Team. All Rights Reserved.
7 #include "intuition_intern.h"
9 /* I'm too lazy to open the font and query it. Anyway this is hardcoded. */
10 #define TOPAZ_8_BASELINE 6
12 /* Perhaps this should be localized */
13 static const char title
[] = "Program alert: ";
15 static struct IntuiText
*displayalert_makebody(STRPTR string
, struct TextAttr
*font
)
17 struct IntuiText
*res
;
19 unsigned int lines
= 0;
22 /* First count number of lines */
25 s
+= 3; /* Skip coordinates */
26 while (*s
++); /* Skip text bytes including NULL terminator */
28 } while (*s
++); /* This automatically skips continuation byte */
30 res
= AllocVec(sizeof(struct IntuiText
) * lines
, MEMF_ANY
);
35 for (i
= 0; i
< lines
; i
++)
39 res
[i
].DrawMode
= JAM2
;
40 res
[i
].LeftEdge
= AROS_BE2WORD(*((UWORD
*)s
));
42 res
[i
].TopEdge
= *s
++ - TOPAZ_8_BASELINE
;
43 res
[i
].ITextFont
= font
;
46 res
[i
].NextText
= *s
++ ? &res
[i
+1] : NULL
;
52 /*****************************************************************************
55 #include <proto/intuition.h>
57 AROS_LH3(BOOL
, DisplayAlert
,
60 AROS_LHA(ULONG
, alertnumber
, D0
),
61 AROS_LHA(UBYTE
*, string
, A0
),
62 AROS_LHA(UWORD
, height
, D1
),
65 struct IntuitionBase
*, IntuitionBase
, 15, Intuition
)
68 Bring up an alert with the given message.
71 alertnumber - Value determining type of alert. For historic reasons
72 this is the same value as passed to Alert(). However
73 this functions takes into account only AT_DeadEnd bit.
74 string - A pointer to a text data. Text data have the following layout:
75 each string is preceded by 3 bytes. First two of them are X coordinate
76 of the string in alert display. This is given as bigendian value. Third
77 byte is Y coordinate of text's baseline. Then NULL-terminated string
78 follows by itself. After NULL terminator there's one more byte. If it's
79 not zero, another string starts from the next byte. Zero marks end of
81 The text is always rendered using topaz/8 font.
82 height - The height of alert display in pixels.
85 Always FALSE if AT_DeadEnd bit is set in the alertnumber. Otherwise the function
86 returns TRUE or FALSE depending on what user chooses. In AROS alerts are presented
87 in a requester with two gadgets: Ok and Cancel. Ok returns TRUE, Cancel returns FALSE.
89 If the alert could not be posted for whatever reason, FALSE is returned.
92 This function is obsolete and exists only for backwards compatibility with
93 AmigaOS(tm). On various modern systems this function has different effects.
94 On classic Amiga(tm) this function may not work with RTG displays, so it
95 is generally deprecated. Please don't use it in a new software! Use legitimate
96 intuition requesters if you want to present some message to the user.
108 *****************************************************************************/
112 struct TextAttr font
= {
118 struct IntuiText postext
= {
124 struct IntuiText negtext
= {
130 struct IntuiText
*body
= displayalert_makebody(string
, &font
);
138 struct Task
*t
= FindTask(NULL
);
141 l2
= strlen(t
->tc_Node
.ln_Name
) + 1;
142 buf
= AllocMem(l1
+ l2
, MEMF_ANY
);
145 CopyMem(title
, buf
, l1
);
146 CopyMem(t
->tc_Node
.ln_Name
, &buf
[l1
], l2
);
149 * This is actually the same as AutoRequest(), without IDCMP processing.
150 * We use internal function instead of BuildSysRequest() because the latter
151 * does not allow to specify own title for the requester. In order to stay
152 * compatible with various patches which modify system requesters look and
153 * feel we call all three functions by their internal entry points.
155 if (alertnumber
& AT_DeadEnd
)
156 req
= buildsysreq_intern(NULL
, buf
, body
, NULL
, &postext
, 0, 640, height
, IntuitionBase
);
158 req
= buildsysreq_intern(NULL
, buf
, body
, &postext
, &negtext
, 0, 640, height
, IntuitionBase
);
162 while ((ret
= sysreqhandler_intern(req
, NULL
, TRUE
, IntuitionBase
)) == -2);
163 freesysreq_intern(req
, IntuitionBase
);
166 FreeMem(buf
, l1
+ l2
);