Commit e36770dc authored by Kevin Bracey's avatar Kevin Bracey
Browse files

Made INPUT type=image work

parent fe3e2b89
...@@ -1249,7 +1249,8 @@ int browser_move_selection(browser_data * b, int key) ...@@ -1249,7 +1249,8 @@ int browser_move_selection(browser_data * b, int key)
) )
form_click_field(owner, form_click_field(owner,
new, new,
key == akbd_RightK ? 1 : 2); key == akbd_RightK ? 1 : 2,
0, 0);
/* Turn the pointer off, and reset the check to see if */ /* Turn the pointer off, and reset the check to see if */
/* the user has moved it manually. */ /* the user has moved it manually. */
...@@ -1303,7 +1304,9 @@ static int browser_navigate_map(browser_data * b, int key) ...@@ -1303,7 +1304,9 @@ static int browser_navigate_map(browser_data * b, int key)
{ {
tp = browser_get_pointer_token(b, &p, NULL, NULL); tp = browser_get_pointer_token(b, &p, NULL, NULL);
if (tp && redraw_selected(b, tp) && (tp->style & IMG) && (tp->type & TYPE_ISMAP)) if (tp && redraw_selected(b, tp) &&
(((tp->style & IMG) && (tp->type & TYPE_ISMAP)) ||
((tp->style & INPUT) && HtmlINPUTtype(tp) == inputtype_IMAGE)))
{ {
int last_move = 4; int last_move = 4;
int last_key, start_key; int last_key, start_key;
...@@ -1676,7 +1679,9 @@ int browser_pointer_check(int eventcode, WimpPollBlock * b, IdBlock * idb, brows ...@@ -1676,7 +1679,9 @@ int browser_pointer_check(int eventcode, WimpPollBlock * b, IdBlock * idb, brows
if ((tp->style & IMG) && (tp->type & TYPE_ISMAP)) mouse_set_pointer_shape(Mouse_Shape_Map); if ((tp->style & IMG) && (tp->type & TYPE_ISMAP)) mouse_set_pointer_shape(Mouse_Shape_Map);
else mouse_set_pointer_shape(Mouse_Shape_Link); else mouse_set_pointer_shape(Mouse_Shape_Link);
} }
else mouse_set_pointer_shape(Mouse_Shape_Normal); else if ((tp->style & INPUT) &&
HtmlINPUTtype(tp) == inputtype_IMAGE) mouse_set_pointer_shape(Mouse_Shape_Link);
else mouse_set_pointer_shape(Mouse_Shape_Normal);
} }
/* If the mouse pointer is on, then update the status bar */ /* If the mouse pointer is on, then update the status bar */
...@@ -2010,13 +2015,14 @@ static HStream * browser_get_pointer_token_r(browser_data * b, reformat_cell * c ...@@ -2010,13 +2015,14 @@ static HStream * browser_get_pointer_token_r(browser_data * b, reformat_cell * c
/* If the token represents an image... */ /* If the token represents an image... */
else if (tp->style & IMG) else if ((tp->style & IMG) ||
((tp->style & INPUT) && HtmlINPUTtype(tp) == inputtype_IMAGE))
{ {
reformat_get_image_size(b, tp, &box); reformat_get_image_size(b, tp, &box);
/* Correct for the border size, if the image is a link */ /* Correct for the border size, if the image is a link */
if (ISLINK(tp)) if (ISLINK(tp) && (tp->style & IMG))
{ {
int b; int b;
......
...@@ -219,8 +219,9 @@ void * fetch_token_data_address(browser_data * b, HStream * token) ...@@ -219,8 +219,9 @@ void * fetch_token_data_address(browser_data * b, HStream * token)
{ {
/* No data for horizontal rules or images */ /* No data for horizontal rules or images */
if (token->style & HR) return NULL; if (token->style & HR) return NULL;
if (token->style & IMG) return NULL; if (token->style & IMG) return NULL;
if ((token->style & INPUT) && HtmlINPUTtype(token) == inputtype_IMAGE) return NULL;
/* Otherwise, return a pointer to the text */ /* Otherwise, return a pointer to the text */
...@@ -431,16 +432,16 @@ void fetch_preprocess_token(browser_data * b, HStream * tptr) ...@@ -431,16 +432,16 @@ void fetch_preprocess_token(browser_data * b, HStream * tptr)
if (tptr->style & INPUT) if (tptr->style & INPUT)
{ {
switch(tptr->type&TYPE_RESET) switch(HtmlINPUTtype(tptr))
{ {
case TYPE_TEXT: if (fetch_chkerror(b, form_new_field(b, tptr, form_text, tptr->text ))) return; break; case inputtype_TEXT: if (fetch_chkerror(b, form_new_field(b, tptr, form_text, tptr->text ))) return; break;
case TYPE_PASSWORD:if (fetch_chkerror(b, form_new_field(b, tptr, form_password, tptr->text ))) return; break; case inputtype_PASSWORD:if (fetch_chkerror(b, form_new_field(b, tptr, form_password, tptr->text ))) return; break;
case TYPE_CHECKBOX:if (fetch_chkerror(b, form_new_field(b, tptr, form_checkbox, (char *) (tptr->type & TYPE_CHECKED) ))) return; break; case inputtype_CHECKBOX:if (fetch_chkerror(b, form_new_field(b, tptr, form_checkbox, (char *) HtmlINPUTchecked(tptr) ))) return; break;
case TYPE_RADIO: if (fetch_chkerror(b, form_new_field(b, tptr, form_radio, (char *) (tptr->type & TYPE_CHECKED) ))) return; break; case inputtype_RADIO: if (fetch_chkerror(b, form_new_field(b, tptr, form_radio, (char *) HtmlINPUTchecked(tptr) ))) return; break;
case TYPE_IMAGE: if (fetch_chkerror(b, form_new_field(b, tptr, form_image, NULL ))) return; break; case inputtype_IMAGE: if (fetch_chkerror(b, form_new_field(b, tptr, form_image, NULL ))) return; break;
case TYPE_HIDDEN: if (fetch_chkerror(b, form_new_field(b, tptr, form_hidden, NULL ))) return; break; case inputtype_HIDDEN: if (fetch_chkerror(b, form_new_field(b, tptr, form_hidden, NULL ))) return; break;
case TYPE_SUBMIT: if (fetch_chkerror(b, form_new_field(b, tptr, form_submit, NULL ))) return; break; case inputtype_SUBMIT: if (fetch_chkerror(b, form_new_field(b, tptr, form_submit, NULL ))) return; break;
case TYPE_RESET: if (fetch_chkerror(b, form_new_field(b, tptr, form_reset, NULL ))) return; break; case inputtype_RESET: if (fetch_chkerror(b, form_new_field(b, tptr, form_reset, NULL ))) return; break;
} }
} }
...@@ -455,7 +456,7 @@ void fetch_preprocess_token(browser_data * b, HStream * tptr) ...@@ -455,7 +456,7 @@ void fetch_preprocess_token(browser_data * b, HStream * tptr)
if ((tptr->style) & SELECT) if ((tptr->style) & SELECT)
{ {
if (fetch_chkerror(b, form_new_field(b, tptr, form_select, tptr->value))) return; if (fetch_chkerror(b, form_new_field(b, tptr, form_select, (char *)HtmlSELECToptions(tptr)))) return;
} }
b->formflag = 1; b->formflag = 1;
......
...@@ -981,7 +981,7 @@ _kernel_oserror * fm_set_font_colour(fm_face h, int fore, int back) ...@@ -981,7 +981,7 @@ _kernel_oserror * fm_set_font_colour(fm_face h, int fore, int back)
/* Font Manager earlier than v3.37. */ /* Font Manager earlier than v3.37. */
/*************************************************/ /*************************************************/
_kernel_oserror * fm_puts(fm_face h, int x, int y,char * s, int os, int blend) _kernel_oserror * fm_puts(fm_face h, int x, int y, const char * s, int os, int blend)
{ {
#ifdef TRACE #ifdef TRACE
if (tl & (1u<<10)) Printf("\nfm_puts: Called with handle %p\n String '%s'\n",(void *) h, s); if (tl & (1u<<10)) Printf("\nfm_puts: Called with handle %p\n String '%s'\n",(void *) h, s);
...@@ -1450,7 +1450,7 @@ void fm_shutdown(void) ...@@ -1450,7 +1450,7 @@ void fm_shutdown(void)
/* Returns: See parameters list. */ /* Returns: See parameters list. */
/*************************************************/ /*************************************************/
_kernel_oserror * fm_get_string_width(fm_face h, char * s, int maxwid, int maxbytes, _kernel_oserror * fm_get_string_width(fm_face h, const char * s, int maxwid, int maxbytes,
int split, int * bytes, int * width) int split, int * bytes, int * width)
{ {
if (h >= 0) if (h >= 0)
...@@ -1464,13 +1464,13 @@ _kernel_oserror * fm_get_string_width(fm_face h, char * s, int maxwid, int maxby ...@@ -1464,13 +1464,13 @@ _kernel_oserror * fm_get_string_width(fm_face h, char * s, int maxwid, int maxby
e = _swix(Font_SetFont,_IN(0),h); e = _swix(Font_SetFont,_IN(0),h);
/* Force a terminator in the string */ // /* Force a terminator in the string */
//
if (maxbytes < strlen(s)) // if (maxbytes < strlen(s))
{ // {
c1 = s[maxbytes]; // c1 = s[maxbytes];
s[maxbytes] = 0; // s[maxbytes] = 0;
} // }
/* Get the width */ /* Get the width */
...@@ -1520,7 +1520,7 @@ _kernel_oserror * fm_get_string_width(fm_face h, char * s, int maxwid, int maxby ...@@ -1520,7 +1520,7 @@ _kernel_oserror * fm_get_string_width(fm_face h, char * s, int maxwid, int maxby
if (!e && !*width && split > 0) if (!e && !*width && split > 0)
{ {
char * p = s; const char * p = s;
/* Adjust the string length to the first split character. */ /* Adjust the string length to the first split character. */
/* (Thanks to Tony Cheal for spotting this when doing */ /* (Thanks to Tony Cheal for spotting this when doing */
...@@ -1532,13 +1532,13 @@ _kernel_oserror * fm_get_string_width(fm_face h, char * s, int maxwid, int maxby ...@@ -1532,13 +1532,13 @@ _kernel_oserror * fm_get_string_width(fm_face h, char * s, int maxwid, int maxby
while (*p && *(p++) != split); while (*p && *(p++) != split);
/* Force a terminator at the split character, if found */ // /* Force a terminator at the split character, if found */
//
if (*p) // if (*p)
{ // {
c2 = *p; // c2 = *p;
*p = 0; // *p = 0;
} // }
/* Now call the Font Manager without asking for a split, knowing that */ /* Now call the Font Manager without asking for a split, knowing that */
/* the string length only runs up to the split character. */ /* the string length only runs up to the split character. */
...@@ -1550,19 +1550,19 @@ _kernel_oserror * fm_get_string_width(fm_face h, char * s, int maxwid, int maxby ...@@ -1550,19 +1550,19 @@ _kernel_oserror * fm_get_string_width(fm_face h, char * s, int maxwid, int maxby
0x1000000, /* Maximum width if splitting is allowed */ 0x1000000, /* Maximum width if splitting is allowed */
0x1000000, /* Maximum height if splitting is allowed */ 0x1000000, /* Maximum height if splitting is allowed */
-1, /* Character to split on, or -1 for no split */ -1, /* Character to split on, or -1 for no split */
maxbytes, /* Maximum string length */ p - s /*maxbytes*/, /* Maximum string length */
width, /* Width of scanned string */ width, /* Width of scanned string */
bytes); /* Length of scanned string */ bytes); /* Length of scanned string */
/* Restore the overwritten character, if any */ /* Restore the overwritten character, if any */
if (c2) *p = c2; // if (c2) *p = c2;
} }
/* Put the character that was overwritten by a terminator (if any) back */ /* Put the character that was overwritten by a terminator (if any) back */
if (c1) s[maxbytes] = c1; // if (c1) s[maxbytes] = c1;
/* Exit if there was some error */ /* Exit if there was some error */
......
This diff is collapsed.
...@@ -1521,6 +1521,42 @@ int handle_clicks(int eventcode, WimpPollBlock * b, IdBlock * idb, browser_data ...@@ -1521,6 +1521,42 @@ int handle_clicks(int eventcode, WimpPollBlock * b, IdBlock * idb, browser_data
return 0; return 0;
} }
/*************************************************/
/* handle_calc_image_click_coords() */
/* */
/* Calculate the coordinates of a click on an */
/* image in pixels from the top left corner, as */
/* required by image maps and image input */
/* fields. */
/*************************************************/
int handle_calc_image_click_coords(HStream * p, WimpGetPointerInfoBlock * i, int * x, int * y, browser_data * handle)
{
WimpGetWindowStateBlock s;
BBox box;
/* Get the image's size and position on screen */
s.window_handle = handle->window_handle;
if (wimp_get_window_state(&s)) return 0;
if (image_get_token_image_size(handle, p, &box)) return 0;
if (image_get_token_image_position(handle, p, x, y)) return 0;
*x = coords_x_toscreen(*x, (WimpRedrawWindowBlock *) &s);
*y = coords_y_toscreen(*y, (WimpRedrawWindowBlock *) &s);
/* Get the offset of the pointer position from the top left */
/* of the image in ox and oy */
*x = i->x - *x;
*y = *y + (box.ymax - box.ymin) - i->y;
image_convert_to_pixels(handle, p, x, y);
return 1;
}
/*************************************************/ /*************************************************/
/* handle_link_clicks() */ /* handle_link_clicks() */
/* */ /* */
...@@ -1595,7 +1631,12 @@ int handle_link_clicks(int eventcode, WimpPollBlock * b, IdBlock * idb, browser_ ...@@ -1595,7 +1631,12 @@ int handle_link_clicks(int eventcode, WimpPollBlock * b, IdBlock * idb, browser_
) )
) )
{ {
ChkError(form_click_field(handle, p, 0)); int x = 0, y = 0;
if ((p->style & INPUT) && HtmlINPUTtype(p) == inputtype_IMAGE && eventcode >= 0)
handle_calc_image_click_coords(p, &i, &x, &y, handle);
ChkError(form_click_field(handle, p, 0, x, y));
used = 1; used = 1;
} }
else else
...@@ -1643,11 +1684,8 @@ int handle_link_clicks(int eventcode, WimpPollBlock * b, IdBlock * idb, browser_ ...@@ -1643,11 +1684,8 @@ int handle_link_clicks(int eventcode, WimpPollBlock * b, IdBlock * idb, browser_
if ((p->style & IMG) && (p->type & TYPE_ISMAP)) if ((p->style & IMG) && (p->type & TYPE_ISMAP))
{ {
WimpGetWindowStateBlock s;
char coords[64]; char coords[64];
browser_data * targetted; browser_data * targetted;
BBox box;
int x, y;
if (eventcode < 0) if (eventcode < 0)
{ {
...@@ -1656,27 +1694,12 @@ int handle_link_clicks(int eventcode, WimpPollBlock * b, IdBlock * idb, browser_ ...@@ -1656,27 +1694,12 @@ int handle_link_clicks(int eventcode, WimpPollBlock * b, IdBlock * idb, browser_
if (!p) return 0; if (!p) return 0;
} }
/* Get the image's size and position on screen */ /* Find out which pixel we clicked on */
handle_calc_image_click_coords(p, &i, &ox, &oy, handle);
s.window_handle = handle->window_handle;
if (wimp_get_window_state(&s)) return 0;
if (image_get_token_image_size(handle, p, &box)) return 0;
if (image_get_token_image_position(handle, p, &x, &y)) return 0;
x = coords_x_toscreen(x, (WimpRedrawWindowBlock *) &s);
y = coords_y_toscreen(y, (WimpRedrawWindowBlock *) &s);
/* Get the offset of the pointer position from the top left */
/* of the image in ox and oy */
ox = i.x - x;
oy = y + (box.ymax - box.ymin) - i.y;
if (ox >= 0 && oy >= 0) if (ox >= 0 && oy >= 0)
{ {
/* Convert the coordinate to pixels and build an appropriate */ /* Build an appropriate CGI string including this information. */
/* CGI string including this information. */
image_convert_to_pixels(handle, p, &ox, &oy); image_convert_to_pixels(handle, p, &ox, &oy);
sprintf(coords, "?%d,%d", ox, oy); sprintf(coords, "?%d,%d", ox, oy);
......
...@@ -886,7 +886,7 @@ _kernel_oserror * image_new_image(browser_data * b, const char * url, HStream * ...@@ -886,7 +886,7 @@ _kernel_oserror * image_new_image(browser_data * b, const char * url, HStream *
/* width and height fields according to any details in the */ /* width and height fields according to any details in the */
/* HTML source. */ /* HTML source. */
if (!background) if (!background && !(tp->style & INPUT))
{ {
if (tp->cols > 0) idata[nimages].currw = tp->cols * 2; if (tp->cols > 0) idata[nimages].currw = tp->cols * 2;
if (tp->rows > 0) idata[nimages].currh = tp->rows * 2; if (tp->rows > 0) idata[nimages].currh = tp->rows * 2;
...@@ -2294,7 +2294,7 @@ static _kernel_oserror * image_update_image(browser_data * b, int image, BBox * ...@@ -2294,7 +2294,7 @@ static _kernel_oserror * image_update_image(browser_data * b, int image, BBox *
/* correct its X and Y coordinates appropriately */ /* correct its X and Y coordinates appropriately */
o = 0; o = 0;
if (ISLINK(tp)) o = tp->maxlen * 2; if (ISLINK(tp) && (tp->style & IMG)) o = tp->maxlen * 2;
x += o; x += o;
y += ibox.ymin + o; y += ibox.ymin + o;
......
...@@ -1627,9 +1627,9 @@ _kernel_oserror * redraw_draw_r(int toplevel, int xorg, int yorg, browser_data * ...@@ -1627,9 +1627,9 @@ _kernel_oserror * redraw_draw_r(int toplevel, int xorg, int yorg, browser_data *
/* A text-based element */ /* A text-based element */
if ( if (
(tp->type & TYPE_RESET) == TYPE_TEXT || (tp->style & (TEXTAREA | SELECT)) ||
(tp->type & TYPE_RESET) == TYPE_PASSWORD || HtmlINPUTtype(tp) == inputtype_TEXT ||
(tp->style & (TEXTAREA | SELECT)) HtmlINPUTtype(tp) == inputtype_PASSWORD
) )
{ {
BBox box; BBox box;
...@@ -1676,7 +1676,7 @@ _kernel_oserror * redraw_draw_r(int toplevel, int xorg, int yorg, browser_data * ...@@ -1676,7 +1676,7 @@ _kernel_oserror * redraw_draw_r(int toplevel, int xorg, int yorg, browser_data *
&r->redraw_area, &r->redraw_area,
fh, fh,
!!(tp->style & TEXTAREA), !!(tp->style & TEXTAREA),
(tp->type & TYPE_RESET) == TYPE_PASSWORD); (tp->style & INPUT) && HtmlINPUTtype(tp) == inputtype_PASSWORD);
} }
/* If the element is a SELECT field, it needs a menu icon too */ /* If the element is a SELECT field, it needs a menu icon too */
...@@ -1740,37 +1740,41 @@ _kernel_oserror * redraw_draw_r(int toplevel, int xorg, int yorg, browser_data * ...@@ -1740,37 +1740,41 @@ _kernel_oserror * redraw_draw_r(int toplevel, int xorg, int yorg, browser_data *
// } // }
} }
} }
else switch(tp->type & TYPE_RESET) else switch(HtmlINPUTtype(tp))
{ {
/* Graphics-based forms elements */ /* Graphics-based forms elements */
case TYPE_CHECKBOX: if (nocontent != tp) redraw_switch(b, case inputtype_CHECKBOX:
tp, if (nocontent != tp)
x, redraw_switch(b,
y + base, tp,
form_get_field(b, x,
d->cdata[cn].t) -> checked ? "fopton" : "foptoff", y + base,
r); form_get_field(b, d->cdata[cn].t) -> checked ? "fopton" : "foptoff",
r);
break; break;
case TYPE_RADIO: if (nocontent != tp) redraw_switch(b, case inputtype_RADIO:
tp, if (nocontent != tp)
x, redraw_switch(b,
y + base, tp,
form_get_field(b, x,
d->cdata[cn].t) -> checked ? "fradioon" : "fradiooff", y + base,
r); form_get_field(b, d->cdata[cn].t) -> checked ? "fradioon" : "fradiooff",
r);
break; break;
case TYPE_IMAGE: case inputtype_IMAGE:
case TYPE_HIDDEN: break; goto do_image;
case inputtype_HIDDEN: break;
case TYPE_SUBMIT: /* SUBMIT same as RESET: no break */ case inputtype_SUBMIT: /* SUBMIT same as RESET: no break */
case TYPE_RESET: case inputtype_RESET:
{ {
BBox box; BBox box;
int fh, ox, oy, colour; int fh, ox, oy, colour;
char * p; const char * p;
p = form_button_text(tp); p = form_button_text(tp);
...@@ -1845,7 +1849,11 @@ _kernel_oserror * redraw_draw_r(int toplevel, int xorg, int yorg, browser_data * ...@@ -1845,7 +1849,11 @@ _kernel_oserror * redraw_draw_r(int toplevel, int xorg, int yorg, browser_data *
else if (tp->style & IMG) else if (tp->style & IMG)
{ {
BBox box; BBox box;
int ox, oy, o = 0; int ox, oy, o;
do_image:
o = 0;
convert_pair_to_os(x, y + base, &ox, &oy); convert_pair_to_os(x, y + base, &ox, &oy);
...@@ -1874,7 +1882,7 @@ _kernel_oserror * redraw_draw_r(int toplevel, int xorg, int yorg, browser_data * ...@@ -1874,7 +1882,7 @@ _kernel_oserror * redraw_draw_r(int toplevel, int xorg, int yorg, browser_data *
if (ISLINK(tp)) if (ISLINK(tp))
{ {
o = tp->maxlen * 2; o = (tp->style & IMG) ? tp->maxlen * 2 : 4;
if (o) if (o)
{ {
...@@ -1887,6 +1895,8 @@ _kernel_oserror * redraw_draw_r(int toplevel, int xorg, int yorg, browser_data * ...@@ -1887,6 +1895,8 @@ _kernel_oserror * redraw_draw_r(int toplevel, int xorg, int yorg, browser_data *
} }
else if (redraw_selected(b, tp)) redraw_border_around_box(&box, b->selecol); else if (redraw_selected(b, tp)) redraw_border_around_box(&box, b->selecol);
} }
else if ((tp->style & INPUT) && redraw_selected(b, tp))
redraw_border_around_box(&box, b->selecol);
/* Redraw the image itself */ /* Redraw the image itself */
......
...@@ -162,7 +162,8 @@ _kernel_oserror * reformat_stop(browser_data * b) ...@@ -162,7 +162,8 @@ _kernel_oserror * reformat_stop(browser_data * b)
static int reformat_istext(HStream * tp) static int reformat_istext(HStream * tp)
{ {
return (((tp->style) & (IMG | HR)) == 0); return (((tp->style) & (IMG | HR)) == 0 &&
!((tp->style & INPUT) && HtmlINPUTtype(tp) == inputtype_IMAGE));
} }
/*************************************************/ /*************************************************/
...@@ -194,6 +195,7 @@ static int reformat_istext(HStream * tp) ...@@ -194,6 +195,7 @@ static int reformat_istext(HStream * tp)
static _kernel_oserror * reformat_token_width(reformat_width_data * w, unsigned int flags) static _kernel_oserror * reformat_token_width(reformat_width_data * w, unsigned int flags)
{ {
_kernel_oserror * e = NULL; _kernel_oserror * e = NULL;
BBox box;
/* Deal with tables */ /* Deal with tables */
...@@ -281,13 +283,12 @@ static _kernel_oserror * reformat_token_width(reformat_width_data * w, unsigned ...@@ -281,13 +283,12 @@ static _kernel_oserror * reformat_token_width(reformat_width_data * w, unsigned
else if (w->tp->style & (INPUT | TEXTAREA | SELECT)) else if (w->tp->style & (INPUT | TEXTAREA | SELECT))
{ {
if ( if ( (w->tp->style & (TEXTAREA | SELECT) ||
(w->tp->type & TYPE_RESET) == TYPE_TEXT || HtmlINPUTtype(w->tp) == inputtype_TEXT ||
(w->tp->type & TYPE_RESET) == TYPE_PASSWORD || HtmlINPUTtype(w->tp) == inputtype_PASSWORD
(w->tp->style & (TEXTAREA | SELECT)) )
) )
{ {
BBox box;
int h, length, extra = 0; int h, length, extra = 0;
if (w->tp->style & TEXTAREA) if (w->tp->style & TEXTAREA)
...@@ -314,7 +315,7 @@ static _kernel_oserror * reformat_token_width(reformat_width_data * w, unsigned ...@@ -314,7 +315,7 @@ static _kernel_oserror * reformat_token_width(reformat_width_data * w, unsigned
width += 32; /* Account for border and gap */ width += 32; /* Account for border and gap */
convert_to_points(width, &extra); convert_to_points(width, &extra);
p = w->tp->value + 8; p = (char *) HtmlSELECToptions(w->tp) + 8;
l = 8; l = 8;
while(*p != 0xff) while(*p != 0xff)
...@@ -330,7 +331,7 @@ static _kernel_oserror * reformat_token_width(reformat_width_data * w, unsigned ...@@ -330,7 +331,7 @@ static _kernel_oserror * reformat_token_width(reformat_width_data * w, unsigned
{ {
/* One line writable */ /* One line writable */
length = w->tp->size; length = HtmlINPUTsize(w->tp);
if (length == 1) length = 2; if (length == 1) length = 2;
else if (length < 2) else if (length < 2)
...@@ -361,12 +362,12 @@ static _kernel_oserror * reformat_token_width(reformat_width_data * w, unsigned ...@@ -361,12 +362,12 @@ static _kernel_oserror * reformat_token_width(reformat_width_data * w, unsigned
return e; return e;
} }
else switch(w->tp->type & TYPE_RESET) else switch(HtmlINPUTtype(w->tp))
{ {
case TYPE_SUBMIT: /*; no break - same as RESET */ case inputtype_SUBMIT: /*; no break - same as RESET */
case TYPE_RESET: case inputtype_RESET:
{ {
char * p; const char * p;
int h, length, end; int h, length, end;
p = form_button_text(w->tp); p = form_button_text(w->tp);
...@@ -395,7 +396,7 @@ static _kernel_oserror * reformat_token_width(reformat_width_data * w, unsigned ...@@ -395,7 +396,7 @@ static _kernel_oserror * reformat_token_width(reformat_width_data * w, unsigned
} }
break; break;
case TYPE_CHECKBOX: case inputtype_CHECKBOX:
{ {
w->bytes = 0; w->bytes = 0;
...@@ -405,7 +406,7 @@ static _kernel_oserror * reformat_token_width(reformat_width_data * w, unsigned ...@@ -405,7 +406,7 @@ static _kernel_oserror * reformat_token_width(reformat_width_data * w, unsigned
} }
break; break;
case TYPE_RADIO: case inputtype_RADIO:
{ {
w->bytes = 0; w->bytes = 0;
...@@ -415,17 +416,23 @@ static _kernel_oserror * reformat_token_width(reformat_width_data * w, unsigned ...@@ -415,17 +416,23 @@ static _kernel_oserror * reformat_token_width(reformat_width_data * w, unsigned
} }
break; break;
case TYPE_IMAGE: case inputtype_HIDDEN:
case TYPE_HIDDEN:
{ {
w->width = w->bytes = 0; w->width = w->bytes = 0;
} }
break; break;
case inputtype_IMAGE:
{
goto do_image;
}
break;
} }
} }
else if (w->tp->style & IMG) else if (w->tp->style & IMG)
{ {
BBox box;
do_image:
w->bytes = 0; w->bytes = 0;
w->width = 0; w->width = 0;
...@@ -1201,27 +1208,41 @@ void reformat_free_queue(browser_data * b) ...@@ -1201,27 +1208,41 @@ void reformat_free_queue(browser_data * b)
_kernel_oserror * reformat_get_image_size(browser_data * b, HStream * tp, BBox * box) _kernel_oserror * reformat_get_image_size(browser_data * b, HStream * tp, BBox * box)
{ {
_kernel_oserror * e; _kernel_oserror * e;
imgalign al;
e = image_get_token_image_size(b, tp, box); e = image_get_token_image_size(b, tp, box);
if (e) return e; if (e) return e;
if ((tp->type & TYPE_ALIGN_MASK) == TYPE_MIDDLE) if (tp->style & IMG)
{ {
box->ymin -= box->ymax / 2; if ((tp->type & TYPE_ALIGN_MASK) == TYPE_MIDDLE)
box->ymax /= 2; al = imgalign_MIDDLE;
else if ((tp->type & TYPE_ALIGN_MASK) == TYPE_TOP)
al = imgalign_TOP;
else
al = imgalign_NONE;
} }
else
al = HtmlINPUTalign(tp);
if ((tp->type & TYPE_ALIGN_MASK) == TYPE_TOP) switch (al)
{ {
box->ymin =- box->ymax; case imgalign_MIDDLE:
box->ymax = 0; box->ymin -= box->ymax / 2;
box->ymax /= 2;
break;
case imgalign_TOP:
box->ymin =- box->ymax;
box->ymax = 0;
break;
} }
/* Deal with links - need to account for a border */ /* Deal with links - need to account for a border */
/* of maxlen * 2 pixels width. ISLINK is defined */ /* of maxlen * 2 pixels width. ISLINK is defined */
/* in Fetch.h. */ /* in Fetch.h. */
if (ISLINK(tp)) if (ISLINK(tp) && (tp->style & IMG))
{ {
int b; int b;
...@@ -1350,7 +1371,8 @@ static _kernel_oserror * reformat_check_height(int toplevel, browser_data * b, r ...@@ -1350,7 +1371,8 @@ static _kernel_oserror * reformat_check_height(int toplevel, browser_data * b, r
/* Find out the height of an image */ /* Find out the height of an image */
if (tp->style & IMG) if ((tp->style & IMG) ||
(tp->style & INPUT) && HtmlINPUTtype(tp) == inputtype_IMAGE)
{ {
BBox box; BBox box;
...@@ -1394,14 +1416,14 @@ static _kernel_oserror * reformat_check_height(int toplevel, browser_data * b, r ...@@ -1394,14 +1416,14 @@ static _kernel_oserror * reformat_check_height(int toplevel, browser_data * b, r
/* A few easy to work out forms elements */ /* A few easy to work out forms elements */
else if ((tp->style & INPUT) && (tp->type & TYPE_RESET) == TYPE_CHECKBOX) else if ((tp->style & INPUT) && HtmlINPUTtype(tp) == inputtype_CHECKBOX)
{ {
read_sprite_size("fopton", NULL, &top); read_sprite_size("fopton", NULL, &top);
top -= 8; top -= 8;
bot = 8; bot = 8;
} }
else if ((tp->style & INPUT) && (tp->type & TYPE_RESET) == TYPE_RADIO) else if ((tp->style & INPUT) && HtmlINPUTtype(tp) == inputtype_RADIO)
{ {
read_sprite_size("fradioon", NULL, &top); read_sprite_size("fradioon", NULL, &top);
top -= 8; top -= 8;
...@@ -1585,15 +1607,15 @@ static _kernel_oserror * reformat_check_height(int toplevel, browser_data * b, r ...@@ -1585,15 +1607,15 @@ static _kernel_oserror * reformat_check_height(int toplevel, browser_data * b, r
{ {
/* General input types */ /* General input types */
switch(tp->type & TYPE_RESET) switch(HtmlINPUTtype(tp))
{ {
case TYPE_TEXT: /* No break - same as PASSWORD */ case inputtype_TEXT: /* No break - same as PASSWORD */
case TYPE_PASSWORD: case inputtype_PASSWORD:
bot += 8; bot += 8;
top += 8; top += 8;
break; break;
case TYPE_SUBMIT: /* No break - same as RESET */ case inputtype_SUBMIT: /* No break - same as RESET */
case TYPE_RESET: case inputtype_RESET:
bot += 8; bot += 8;
top += 12; top += 12;
break; break;
...@@ -2430,7 +2452,9 @@ if (!tpCurr) done = 1; ...@@ -2430,7 +2452,9 @@ if (!tpCurr) done = 1;
/* moved. The new position will be set when the reformatted */ /* moved. The new position will be set when the reformatted */
/* region is next redrawn. */ /* region is next redrawn. */
if (tpCurr->style & IMG) image_set_token_image_position(b, tpCurr, -1, -1); if (tpCurr->style & IMG ||
((tpCurr->style & INPUT) && HtmlINPUTtype(tpCurr)==inputtype_IMAGE))
image_set_token_image_position(b, tpCurr, -1, -1);
/* If the image has a known width and height, the reformatter has */ /* If the image has a known width and height, the reformatter has */
/* dealt with it - so the image library can mark it as redrawable */ /* dealt with it - so the image library can mark it as redrawable */
...@@ -2882,7 +2906,7 @@ void reformat_change_text(browser_data * b, HStream * tp) ...@@ -2882,7 +2906,7 @@ void reformat_change_text(browser_data * b, HStream * tp)
/* If we have ALT text for an image, strip off any preceeding */ /* If we have ALT text for an image, strip off any preceeding */
/* spaces or [s, and any trailing spaces or ]s. */ /* spaces or [s, and any trailing spaces or ]s. */
else if (tp && tp->text && (tp->style & IMG)) else if (tp && tp->text && ((tp->style & IMG) || ((tp->style & INPUT) && HtmlINPUTtype(tp) == inputtype_IMAGE)))
{ {
char * start, * end; char * start, * end;
char last; char last;
......
...@@ -25,13 +25,13 @@ ...@@ -25,13 +25,13 @@
/* (e.g. by drawing a box around it, changing its colour, etc.) and has */ /* (e.g. by drawing a box around it, changing its colour, etc.) and has */
/* some defined action if clicked on. */ /* some defined action if clicked on. */
#define CanBeSelected(t) ( \ #define CanBeSelected(t) ( \
ISLINK(t) || \ ISLINK(t) || \
( \ ((t)->style & (TEXTAREA | SELECT)) || \
((t)->style & (INPUT | TEXTAREA | SELECT)) && \ ( \
((t)->type & TYPE_RESET) != TYPE_HIDDEN && \ ((t)->style & INPUT) && \
((t)->type & TYPE_RESET) != TYPE_IMAGE \ (HtmlINPUTtype(t) != inputtype_HIDDEN) \
) \ ) \
) )
/* Function prototypes */ /* Function prototypes */
......
...@@ -70,7 +70,7 @@ _kernel_oserror * fm_rescale_fonts (browser_data * b); ...@@ -70,7 +70,7 @@ _kernel_oserror * fm_rescale_fonts (browser_data * b);
_kernel_oserror * fm_font_box (fm_face h,BBox * box); _kernel_oserror * fm_font_box (fm_face h,BBox * box);
_kernel_oserror * fm_set_font_colour (fm_face h,int fore,int back); _kernel_oserror * fm_set_font_colour (fm_face h,int fore,int back);
_kernel_oserror * fm_puts (fm_face h,int x,int y,char * s,int os,int blend); _kernel_oserror * fm_puts (fm_face h,int x,int y,const char * s,int os,int blend);
_kernel_oserror * fm_putsl (fm_face handle,int x,int y,char * s,int chars,int os,int blend); _kernel_oserror * fm_putsl (fm_face handle,int x,int y,char * s,int chars,int os,int blend);
_kernel_oserror * fm_write_descriptor (char * name,char * buffer); _kernel_oserror * fm_write_descriptor (char * name,char * buffer);
...@@ -84,7 +84,7 @@ int fm_system_font (void); ...@@ -84,7 +84,7 @@ int fm_system_font (void);
void fm_init (int systemfont, int base_size); void fm_init (int systemfont, int base_size);
void fm_shutdown (void); void fm_shutdown (void);
_kernel_oserror * fm_get_string_width (fm_face h, char * s, int maxwid, int maxbytes, int split, int * bytes, int * width); _kernel_oserror * fm_get_string_width (fm_face h, const char * s, int maxwid, int maxbytes, int split, int * bytes, int * width);
void fm_token_font_info (HStream * t, int * facenum, int * size, int * italic, int * bold); void fm_token_font_info (HStream * t, int * facenum, int * size, int * italic, int * bold);
fm_face fm_find_token_font (browser_data * b, HStream * t); fm_face fm_find_token_font (browser_data * b, HStream * t);
......
...@@ -66,10 +66,10 @@ void form_abandon_menu (void); ...@@ -66,10 +66,10 @@ void form_abandon_menu (void);
int form_give_focus (browser_data * b); int form_give_focus (browser_data * b);
_kernel_oserror * form_click_field (browser_data * b, HStream * token, int mode); _kernel_oserror * form_click_field (browser_data * b, HStream * token, int mode, int x, int y);
_kernel_oserror * form_cancel_edit (browser_data * b); _kernel_oserror * form_cancel_edit (browser_data * b);
_kernel_oserror * form_finish_edit (browser_data * b); _kernel_oserror * form_finish_edit (browser_data * b);
char * form_button_text (HStream * tp); const char * form_button_text (HStream * tp);
int form_token_cursor_editable (browser_data * b, HStream * token); int form_token_cursor_editable (browser_data * b, HStream * token);
_kernel_oserror * form_process_key (browser_data * b, int * key); _kernel_oserror * form_process_key (browser_data * b, int * key);
void form_select_menu_event (WimpPollBlock * e); void form_select_menu_event (WimpPollBlock * e);
......
...@@ -38,7 +38,7 @@ ...@@ -38,7 +38,7 @@
/* Other tag classification masks */ /* Other tag classification masks */
#define VISUALDATA (HR | IMG) /* Does the tag contain displayable data, despite */ #define VISUALDATA (HR | IMG | INPUT) /* Does the tag contain displayable data, despite */
/* having no text inside it? If the tag's style */ /* having no text inside it? If the tag's style */
/* word contains the bit(s) defined here, it is */ /* word contains the bit(s) defined here, it is */
/* deemed to contain such data. */ /* deemed to contain such data. */
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment