From 2663844828e400083825d5be7f146fd0d80219ae Mon Sep 17 00:00:00 2001
From: Andrew Hodgkinson <ahodgkin@gitlab.riscosopen.org>
Date: Tue, 7 Oct 1997 13:52:04 +0000
Subject: [PATCH] Res files had component 0x29fc in frame gadgets for Choices -
 that's meant to be the 'fake page' display. Sorted that out.

Got rid of unnecessary #define in Choices.h; the gadget autodetect
for the colour choices took its place.

Unsized objects now default to the same dimensions as unsized images.
---
 Resources/UK/Browse/Res,fae  | Bin 54752 -> 54752 bytes
 Resources/UK/Phoenix/Res,fae | Bin 47456 -> 47160 bytes
 Resources/UK/Ursula/Res,fae  | Bin 43640 -> 43640 bytes
 c/Object                     |  91 ++++++++++++++++++++++++++++++++++-
 c/Redraw                     |  62 +++++++++++++++++++++---
 c/Reformat                   |  83 +++++++++++++++-----------------
 h/Choices                    |   5 --
 h/Images                     |   3 +-
 h/Object                     |  13 +++--
 9 files changed, 195 insertions(+), 62 deletions(-)

diff --git a/Resources/UK/Browse/Res,fae b/Resources/UK/Browse/Res,fae
index 21a9fd3e5fd2c2f375443f9035cd9158b8f22241..a0f4342b5e9a5cf17169e561bcb953f6c6bc2526 100644
GIT binary patch
delta 199
zcmaE`n)$(M<_#=o`7&4-82&IbFfgz)FkE4sEOa)CQD$=P*?1s%7EJ1%1F?I-<XbT5
zdp?{~gOPz@&j0`aLng01Zw%&TfO#*Wybu3Ca;g^~a(lqML@2KV%$p14g@AcCFIY2W
wFisY`s0O0!F3R!N0Bv9Zn%Tj`!0=#l=0$DZ3ZTdzpz0o=$dk<rFWR#J07i3ALjV8(

delta 199
zcmaE`n)$(M<_#=o`Fxle7zCIY7@n{)FuY)%EOa)Can0o1v++RkESS_i2V(bv$+uwA
z_k1|#4n_usIsgCve=>RPd1Ejy1I&8~<$d@El2g3^k=q02B|>=}VBTCPF9giHdBK{g
vhiS6dMKus*cTtY_1JH&gK)DK_<5VVRUexA&0~A>R6sZA<Xl!11(VhhW+k09r

diff --git a/Resources/UK/Phoenix/Res,fae b/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7-${Sd-YCSzqtZPD^
z;T;kyns_ORJF@PSCgiNENaQ8KFB$@D75tnnn2k$#l~wGJ;m?IoTxJo>){q6<_xA_R
z<KBlu-IMNBuN}w6Rj;Kws}qTYZAT&(4aebU+cC~<myIaDA9=-<uw_`>IeOn%<loaR
z!`PAba8zMQd8Dj@_)!o|>08P{WlS08{hh#qB(i$vBPeE0xvTu8{j$!Flqbp{zHXFc
mf#SC-`;~F+Pw0G7Ipd{aS4e6gt&Oa5L-|enKb2MGKjnW09Q&I9

diff --git a/Resources/UK/Ursula/Res,fae b/Resources/UK/Ursula/Res,fae
index 4cf5ada86cc9bbb84b5b0c15c63bb09aeff453aa..4aa35b6d1022bc905a3a1b3a70a82c6c2e49bd95 100644
GIT binary patch
delta 16
Ycmexyh3Ur?rVSp87#D2zT%^wd088WttpET3

delta 16
Ycmexyh3Ur?rVSp880T#ET%^wd087jVsQ>@~

diff --git a/c/Object b/c/Object
index 0c809fc..9480f75 100644
--- a/c/Object
+++ b/c/Object
@@ -113,6 +113,13 @@ _kernel_oserror * object_new_object(browser_data * b, HStream * t)
   b->odata[b->nobjects].plugin_task_handle      = 0;
   b->odata[b->nobjects].token                   = t;
 
+  /* Until this is seen by the user, open it off-screen to avoid */
+  /* having to send out lots of reposition calls during the main */
+  /* page reformat.                                              */
+
+  b->odata[b->nobjects].x                       = -1;
+  b->odata[b->nobjects].y                       = -1;
+
   /* Width and height initially come from the token, but if this */
   /* ends up leading to a Plug-In being called, that Plug-In     */
   /* could ask for the size to change; hence the 'width' and     */
@@ -269,6 +276,14 @@ static _kernel_oserror * object_get_object_size(browser_data * b, int object, BB
     size->ymax = b->odata[object].height * 2;
   }
 
+  /* Don't allow zero in any direction */
+
+  if (size->xmax == 0 || size->ymax == 0)
+  {
+    size->xmax = ImageDefaultOSSize_X;
+    size->ymax = ImageDefaultOSSize_Y;
+  }
+
   return NULL;
 }
 
@@ -294,6 +309,80 @@ _kernel_oserror * object_get_token_object_size(browser_data * b, HStream * t, BB
   return object_get_object_size(b, object_get_token_object(b, t), size);
 }
 
+/*************************************************/
+/* object_get_token_object_position()            */
+/*                                               */
+/* Returns the x and y fields of the object_info */
+/* structure for a given Object.                 */
+/*                                               */
+/* Parameters: Pointer to a browser_data struct  */
+/*             relevant to the Object;           */
+/*                                               */
+/*             Pointer to the token representing */
+/*             the Object;                       */
+/*                                               */
+/*             Pointer to an int, in which the   */
+/*             X coordinate is returned;         */
+/*                                               */
+/*             Pointer to an int, in which the   */
+/*             Y coordinate is returned.         */
+/*                                               */
+/* Returns:    1 if the object could not be      */
+/*             found from the given token, or 0  */
+/*             for success.                      */
+/*                                               */
+/* Assumes:    Neither pointer is NULL.          */
+/*************************************************/
+
+int object_get_token_object_position(browser_data * b, HStream * t, int * x, int * y)
+{
+  int object = object_get_token_object(b, t);
+
+  if (object < 0) return 1;
+
+  *x = b->odata[object].x;
+  *y = b->odata[object].y;
+
+  return 0;
+}
+
+/*************************************************/
+/* object_set_token_object_position()            */
+/*                                               */
+/* Sets the x and y fields of the object_info    */
+/* structure for a given Object, so that it may  */
+/* be [partially] plotted during a fetch.        */
+/*                                               */
+/* Parameters: Pointer to a browser_data struct  */
+/*             relevant to the object;           */
+/*                                               */
+/*             Pointer to the token representing */
+/*             the Object;                       */
+/*                                               */
+/*             X coordinate (window coords);     */
+/*                                               */
+/*             Y coordinate (window coords).     */
+/*                                               */
+/* Returns:    Number of the Object that was     */
+/*             changed, or -1 if none could be   */
+/*             found for the given token.        */
+/*************************************************/
+
+int object_set_token_object_position(browser_data * b, HStream * t, int x, int y)
+{
+  int object = object_get_token_object(b, t);
+
+  /* If an object was found, set the x and y coordinates */
+
+  if (object >= 0)
+  {
+    b->odata[object].x = x;
+    b->odata[object].y = y;
+  }
+
+  return object;
+}
+
 /*************************************************/
 /* object_redraw()                               */
 /*                                               */
@@ -347,7 +436,7 @@ _kernel_oserror * object_redraw(browser_data * b, WimpRedrawWindowBlock * r, HSt
 
     box.xmin &= ~(wimpt_dx() - 1);
     box.ymin &= ~(wimpt_dy() - 1);
-Printf("%d, %d\n",box.xmax,box.ymax);
+
     if (box.xmax > 8 && box.ymax > 8)
     {
       /* xmin, ymin hold the bottom left hand corner coordinates, whilst */
diff --git a/c/Redraw b/c/Redraw
index f85f6f9..204ac66 100644
--- a/c/Redraw
+++ b/c/Redraw
@@ -1794,16 +1794,16 @@ do_image: /* (This code is also used for form INPUT TYPE=IMAGE tags; see above)
                   {
                     ox -= box.xmin;
 
-                    /* Draw a border of tp->maxlen * 2 OS units width around an */
-                    /* image, if it represents a link. (I.e. if 'border="3"'    */
-                    /* was specified in the document source, a 3 pixel wide     */
-                    /* border would be drawn in mode 20, say).                  */
-
                     box.xmin += ox;
                     box.ymin += oy;
                     box.xmax += ox;
                     box.ymax += oy;
 
+                    /* Draw a border of tp->maxlen * 2 OS units width around an */
+                    /* image, if it represents a link. (I.e. if 'border="3"'    */
+                    /* was specified in the document source, a 3 pixel wide     */
+                    /* border would be drawn in mode 20, say).                  */
+
                     if (ISLINK(tp))
                     {
                       o = (tp->style & IMG) ? tp->maxlen * 2 : 4;
@@ -1844,12 +1844,60 @@ do_image: /* (This code is also used for form INPUT TYPE=IMAGE tags; see above)
 
                   convert_pair_to_os(x, y + base, &ox, &oy);
 
+                  object_set_token_object_position(b,
+                                                   tp,
+                                                   coords_x_toworkarea(ox, r),
+                                                   coords_y_toworkarea(oy, r));
+
                   if (!reformat_get_object_size(b, tp, &box))
                   {
                     ox -= box.xmin;
 
-                    // Can you have borders on Objects? If so, draw them here in
-                    // the same way as for images above.
+                    box.xmin += ox;
+                    box.ymin += oy;
+                    box.xmax += ox;
+                    box.ymax += oy;
+
+// Printf("declare : %d\n", HtmlOBJECTdeclare(tp));
+// Printf("shapes  : %d\n", HtmlOBJECTshapes(tp));
+// Printf("tabindex: %d\n", HtmlOBJECTtabindex(tp));
+// Printf("type    : '%s'\n", HtmlOBJECTtype(tp));
+// Printf("usemap  : '%s'\n", HtmlOBJECTusemap(tp));
+// Printf("vspace  : %d\n", HtmlOBJECTvspace(tp));
+// Printf("hspace  : %d\n", HtmlOBJECThspace(tp));
+// Printf("align   : %d\n", HtmlOBJECTalign(tp));
+// Printf("archive : '%s'\n", HtmlOBJECTarchive(tp));
+// Printf("border  : %d\n", HtmlOBJECTborder(tp));
+// Printf("classid : '%s'\n", HtmlOBJECTclassid(tp));
+// Printf("codebase: '%s'\n", HtmlOBJECTcodebase(tp));
+// Printf("codetype: '%s'\n", HtmlOBJECTcodetype(tp));
+// Printf("data    : '%s'\n", HtmlOBJECTdata(tp));
+// Printf("stream  : %p\n", HtmlOBJECTstream(tp));
+// Printf("parent  : %p\n\n", HtmlOBJECTparent(tp));
+
+                    /* Draw a border, if required */
+
+                    if (HtmlOBJECTborder(tp))
+                    {
+                      o = HtmlOBJECTborder(tp) * 2;
+
+                      if (o)
+                      {
+                        redraw_set_colour(redraw_token_colour(b, tp));
+
+                        bbc_rectanglefill(box.xmin,     box.ymin,     box.xmax - box.xmin - 1, o - 1);
+                        bbc_rectanglefill(box.xmin,     box.ymin,     o - 1,                   box.ymax - box.ymin - 1);
+                        bbc_rectanglefill(box.xmin,     box.ymax - o, box.xmax - box.xmin - 1, o - 1);
+                        bbc_rectanglefill(box.xmax - o, box.ymin,     o - 1,                   box.ymax - box.ymin - 1);
+                      }
+
+                      // A selection mode for Objects...?
+                      //
+                      // else if (redraw_selected(b, tp))
+                      // {
+                      //   redraw_border_around_box(&box, b->selected_colour);
+                      // }
+                    }
                   }
 
                   if (nocontent != tp) RetError(object_redraw(b, r, d->cdata[cn].t, o + box.xmin, o + box.ymin));
diff --git a/c/Reformat b/c/Reformat
index 1e8c360..8df210e 100644
--- a/c/Reformat
+++ b/c/Reformat
@@ -1250,6 +1250,8 @@ _kernel_oserror * reformat_get_image_size(browser_data * b, HStream * tp, BBox *
     }
     break;
 
+    // Sort this out... Should align to top line of text, not baseline!
+
     case imgalign_TOP:
     {
       box->ymin =- box->ymax;
@@ -1299,55 +1301,48 @@ _kernel_oserror * reformat_get_image_size(browser_data * b, HStream * tp, BBox *
 _kernel_oserror * reformat_get_object_size(browser_data * b, HStream * tp, BBox * box)
 {
   _kernel_oserror * e;
-
-//  imgalign          align;
+  imgalign          align;
 
   /* Get the Object size from the Object library */
 
   RetError(object_get_token_object_size(b, tp, box));
 
-//  /* Deal with alignments */
-//
-//  if (tp->style & IMG) /* It'll either be an IMG or an INPUT TYPE=IMAGE item */
-//  {
-//    if      ((tp->type & TYPE_ALIGN_MASK) == TYPE_MIDDLE) align = imgalign_MIDDLE;
-//    else if ((tp->type & TYPE_ALIGN_MASK) == TYPE_TOP)    align = imgalign_TOP;
-//    else                                                  align = imgalign_NONE;
-//  }
-//  else align = HtmlINPUTalign(tp);
-//
-//  switch (align)
-//  {
-//    case imgalign_MIDDLE:
-//    {
-//      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 */
-//  /* of maxlen * 2 pixels width. ISLINK is defined  */
-//  /* in Fetch.h.                                    */
-//
-//  if (ISLINK(tp) && (tp->style & IMG))
-//  {
-//    int b;
-//
-//    b = tp->maxlen * 2;
-//
-//    box->xmax += b;
-//    box->ymax += b;
-//    box->xmin -= b;
-//    box->ymin -= b;
-//  }
+  /* Deal with alignments */
+
+  align = HtmlOBJECTalign(tp);
+
+  switch (align)
+  {
+    case imgalign_MIDDLE:
+    {
+      box->ymin -= box->ymax / 2;
+      box->ymax /= 2;
+    }
+    break;
+
+    // Sort this out, as with image handling
+
+    case imgalign_TOP:
+    {
+      box->ymin =- box->ymax;
+      box->ymax = 0;
+    }
+    break;
+  }
+
+  /* Account for a border */
+
+  if (HtmlOBJECTborder(tp))
+  {
+    int b;
+
+    b = HtmlOBJECTborder(tp) * 2;
+
+    box->xmax += b;
+    box->ymax += b;
+    box->xmin -= b;
+    box->ymin -= b;
+  }
 
   return NULL;
 }
diff --git a/h/Choices b/h/Choices
index e41da22..ed4431e 100644
--- a/h/Choices
+++ b/h/Choices
@@ -23,11 +23,6 @@
 /* History: 23-Sep-97: Created.                    */
 /***************************************************/
 
-/* Define this if you want to display the Selected colour */
-/* in the faked page.                                     */
-
-#define ChoiceUseSelected
-
 /* Choices main dialogue component IDs */
 
 #define CDSet              0x2600
diff --git a/h/Images b/h/Images
index 3ccb6c7..1d8980e 100644
--- a/h/Images
+++ b/h/Images
@@ -32,7 +32,8 @@
 /*                     order to aid legibility.    */
 /***************************************************/
 
-/* Size reported for an image if it's data isn't present and no other size information can be found */
+/* Size reported for an image or Object if it's data isn't */
+/* present and no other size information can be found      */
 
 #define ImageDefaultOSSize_X 48
 #define ImageDefaultOSSize_Y 48
diff --git a/h/Object b/h/Object
index 3915c18..ad0b784 100644
--- a/h/Object
+++ b/h/Object
@@ -37,6 +37,9 @@ typedef struct object_info
 
   HStream      * token;
 
+  int            x;
+  int            y;
+
   int            width;
   int            height;
   int            units;
@@ -45,9 +48,11 @@ object_info;
 
 /* Function prototypes */
 
-_kernel_oserror * object_new_object            (browser_data * b, HStream * t);
-_kernel_oserror * object_discard               (browser_data * b);
+_kernel_oserror * object_new_object                (browser_data * b, HStream * t);
+_kernel_oserror * object_discard                   (browser_data * b);
 
-_kernel_oserror * object_get_token_object_size (browser_data * b, HStream * t, BBox * size);
+_kernel_oserror * object_get_token_object_size     (browser_data * b, HStream * t, BBox * size);
+int               object_get_token_object_position (browser_data * b, HStream * t, int * x, int * y);
+int               object_set_token_object_position (browser_data * b, HStream * t, int x, int y);
 
-_kernel_oserror * object_redraw                (browser_data * b, WimpRedrawWindowBlock * r, HStream * token, int x, int y);
+_kernel_oserror * object_redraw                    (browser_data * b, WimpRedrawWindowBlock * r, HStream * token, int x, int y);
-- 
GitLab