2 Copyright © 1995-2013, 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 historical 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 text data. Text data have the following layout:
75 each string is preceded by 3 bytes. The first two of them are
76 the X coordinates of the string in the alert display. This is
77 given as a big-endian value. The third byte is the Y
78 coordinate of the text's baseline. Then a NUL-terminated
79 string follows by itself. After the NUL terminator there's
80 one more byte. If it's not zero, another string starts from
81 the next byte. Zero marks the end of the sequence. The text
82 is always rendered using the topaz/8 font.
83 height - The height of alert display in pixels.
86 Always FALSE if AT_DeadEnd bit is set in alertnumber. Otherwise the
87 function returns TRUE or FALSE depending on what user chooses. In
88 AROS, alerts are presented in a requester with two gadgets: Ok and
89 Cancel. Ok returns TRUE; Cancel returns FALSE.
91 If the alert could not be posted for whatever reason, FALSE is
95 This function is obsolete and exists only for backwards compatibility
96 with AmigaOS(tm). On various modern systems this function has
97 different effects. On classic Amiga(tm) this function may not work
98 with RTG displays, so it is generally deprecated. Please don't use it
99 in new software! Use legitimate intuition requesters if you want to
100 present some message to the user.
110 *****************************************************************************/
114 struct TextAttr font
= {
120 struct IntuiText postext
= {
126 struct IntuiText negtext
= {
132 struct IntuiText
*body
= displayalert_makebody(string
, &font
);
140 struct Task
*t
= FindTask(NULL
);
143 l2
= strlen(t
->tc_Node
.ln_Name
) + 1;
144 buf
= AllocMem(l1
+ l2
, MEMF_ANY
);
147 CopyMem(title
, buf
, l1
);
148 CopyMem(t
->tc_Node
.ln_Name
, &buf
[l1
], l2
);
151 * This is actually the same as AutoRequest(), without IDCMP processing.
152 * We use internal function instead of BuildSysRequest() because the latter
153 * does not allow to specify own title for the requester. In order to stay
154 * compatible with various patches which modify system requesters look and
155 * feel we call all three functions by their internal entry points.
157 if (alertnumber
& AT_DeadEnd
)
158 req
= buildsysreq_intern(NULL
, buf
, body
, NULL
, &postext
, 0, 640, height
, IntuitionBase
);
160 req
= buildsysreq_intern(NULL
, buf
, body
, &postext
, &negtext
, 0, 640, height
, IntuitionBase
);
164 while ((ret
= sysreqhandler_intern(req
, NULL
, TRUE
, IntuitionBase
)) == -2);
165 freesysreq_intern(req
, IntuitionBase
);
168 FreeMem(buf
, l1
+ l2
);