home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ARM Club 1
/
ARM_CLUB_CD.iso
/
contents
/
education
/
a
/
biology1
/
!Biology1
/
c
/
YNTF
< prev
Wrap
Text File
|
1991-12-03
|
5KB
|
154 lines
/* YNTF.c */
#include <string.h>
#include "wimp.h"
#include "wimpt.h"
#include "input.h"
#include "prompts.h"
#include "keys.h"
static wimp_i ok; /* required for clearing icon button and text */
/* Functions for dealing with res type 2/3 */
static void make_icon (wimp_w wnd, int x, int line, char *str, wimp_i *result)
{ int len = strlen (str);
wimp_icreate info;
wimp_redrawstr r;
info.w = wnd;
info.i.box.x0 = 4 + x;
info.i.box.x1 = info.i.box.x0 + (len * 8 + 4) * 2;
info.i.box.y1 = - line * 32;
info.i.box.y0 = info.i.box.y1 - 40 - 16;
info.i.flags = wimp_ITEXT | wimp_IHCENTRE | wimp_IVCENTRE |
wimp_INDIRECT | 7 * wimp_IFORECOL;
info.i.data.indirecttext.buffer = str;
info.i.data.indirecttext.validstring = "";
info.i.data.indirecttext.bufflen = len + 1;
wimpt_noerr (wimp_create_icon (&info, result));
r.w = wnd;
memcpy (&r.box, &info.i.box, sizeof (wimp_box));
wimpt_noerr (wimp_force_redraw (&r));
}
static void make_button (wimp_w wnd, int x, int line, char *str, wimp_i *ic)
{ int len = strlen (str);
wimp_icreate info;
wimp_redrawstr r;
info.w = wnd;
info.i.box.x0 = x - 8;
info.i.box.x1 = x + 16 * len + 8;
info.i.box.y1 = - line * 32;
info.i.box.y0 = info.i.box.y1 - 40 - 16;
info.i.flags = wimp_ITEXT | wimp_IBORDER |
wimp_IHCENTRE | wimp_IVCENTRE | wimp_IFILLED |
wimp_IBTYPE * wimp_BCLICKDEBOUNCE |
wimp_INDIRECT | 7 * wimp_IFORECOL;
info.i.data.indirecttext.buffer = str;
info.i.data.indirecttext.validstring = "";
info.i.data.indirecttext.bufflen = len;
wimpt_noerr (wimp_create_icon (&info, ic));
r.w = wnd;
memcpy (&r.box, &info.i.box, sizeof (wimp_box));
wimpt_noerr (wimp_force_redraw (&r));
}
static void prompt (wimp_w wnd, int line, char *prompt, wimp_i *st1,
char *seperator, wimp_i *st2,
char *ic1_text, wimp_i *ic1,
char *ic2_text, wimp_i *ic2
)
{
int total_len = strlen (prompt) + strlen (seperator) +
strlen (ic1_text) + strlen (ic2_text) + 6;
int width = standard_line;
int x = (width - total_len) * 8; /* OS units, Predictive on mode */
make_icon (wnd, x, line, prompt, st1);
x += 16 * (strlen (prompt) + 2);
make_button (wnd, x, line, ic1_text, ic1);
x += 16 * (strlen (ic1_text) + 2);
make_icon (wnd, x, line, seperator, st2);
x += 16 * (strlen (seperator) + 2);
make_button (wnd, x, line, ic2_text, ic2);
}
/* Calls concat initialization, to register icons */
void *prompt_YNTF (wimp_w wnd, int line, char *corr_let)
{
wimp_i text1, text2, but1, but2;
if (strcmp (corr_let, "YN") == 0)
prompt (wnd, line, "Is the above statement correct ?", &text1,
"or", &text2,
"Yes", &but1,
"No", &but2);
else
prompt (wnd, line, "Is the above statement", &text1, "or", &text2,
"True", &but1, "False", &but2);
input_icon (wnd, but1, text1, corr_let[0]);
input_icon (wnd, but2, text2, corr_let[1]);
return (concat_YNTF_wakeup (wnd, but1, but2));
}
char *ans_YNTF (char *correct_ans)
{ static char message[29];
message[0] = '\0';
strcpy (message, "The statement is ");
switch (correct_ans[0])
{ case 'Y' :
strcat (message, "correct");
break;
case 'N' :
strcat (message, "not correct");
break;
case 'T' :
strcat (message, "True");
break;
case 'F' :
strcat (message, "False");
break;
}
return (message);
}
void *prompt_ok (wimp_w wnd, int line, char *prompt)
{ int total_len;
int x; /* OS units */
wimp_i st1; /* icon for assoc. text */
total_len = strlen (prompt) + 4 + 6;
x = (standard_line - total_len) * 8;
make_icon (wnd, x, line, prompt, &st1);
x += 16 * (strlen (prompt) + 2);
make_button (wnd, x, line, "O.K.", &ok);
input_icon (wnd, ok, st1, key_ret);
return (concat_ok_wakeup (wnd, ok));
}
void prompt_ok_delete (wimp_w wnd)
{
input_delete_icon (wnd, ok);
}