From 365c46d9186325045feb9ba4d4e86aa7312b6272 Mon Sep 17 00:00:00 2001
From: Robert Sprowson <rsprowson@gitlab.riscosopen.org>
Date: Thu, 17 Jan 2013 21:27:52 +0000
Subject: [PATCH] Minor MousSetup improvements

* Makefile recreated from fragments
* Window size is now compared with screensize on startup and the V scroll bar turned on/off as needed
* Magic numbers changed for header defines
* Version number now inserted at build time rather than being 10 years out of date

Version 0.14. Tagged as 'MousSetup-0_14'
---
 Makefile              | 121 +++++++-----------------------------------
 Resources/UK/Messages |   3 +-
 Resources/UK/Res,fae  | Bin 6484 -> 6484 bytes
 VersionNum            |  20 +++----
 c/Main                |  42 ++++++++++++++-
 c/MouseType           |   6 ++-
 c/Settings            |   5 +-
 c/ToolboxE            |  17 ------
 8 files changed, 77 insertions(+), 137 deletions(-)

diff --git a/Makefile b/Makefile
index 31f1833..7ee4a51 100644
--- a/Makefile
+++ b/Makefile
@@ -14,119 +14,34 @@
 #
 # Makefile for MousSetup
 #
-# ***********************************
-# ***    C h a n g e   L i s t    ***
-# ***********************************
-# Date           Name   Description
-# ----           ----   -----------
-# 17-Oct-97      BJGA   Derived from InetSetup makefiles
-# 28-Oct-97      BJGA   No longer uses OSLib
-# 10-Nov-97      BJGA   Modified to use shared Common directory
-# 09-Dec-97      BJGA   Split Main.c, and modified to use shared Common library
-# 17-Dec-97      BJGA   Tidied up
-# 11-May-98      BJGA   Replaced Common directory with ConfigLib
-#
 
-#
-# Program specific options:
-#
 COMPONENT  = MousSetup
 APP        = !${COMPONENT}
-RDIR       = Resources
-LDIR       = ${RDIR}.${LOCALE}
+TARGET     = !RunImage
 INSTAPP    = ${INSTDIR}.${APP}
+INSTTYPE   = app
+MSGVERSION = ${AWK} -f Build:AwkVers
+LDIR       = Resources.${LOCALE}
+APP_OBJS   = Main.o MouseType.o Settings.o ToolboxE.o WimpE.o WimpM.o
+LIBS       = ${CONLIB} ${EVENTLIB} ${TBOXLIB} ${WIMPLIB}
+CINCLUDES  = -Itbox:,C:,<Lib$Dir>.ConfigLib.
+INSTALLAPPFILES   = !Boot !Help !Run !RunImage Res \
+                    !Sprites !Sprites11 !Sprites22 CoSprite CoSprite11 CoSprite22
+INSTALLAPP_DEPEND = GenMessage
 
-#
-# Generic options:
-#
-MKDIR   = do mkdir -p
-CC      = cc
-ATTR    = -attr
-CP      = copy
-LD      = link
-RM      = remove
-SQUEEZE = squeeze
-WIPE    = x wipe
+include CApp
 
-CFLAGS  =  -c -depend !Depend -ffa -gflv ${INCLUDES} -throwback
-CPFLAGS = ~cfr~v
-WFLAGS  = ~c~v
+C_WARNINGS = -fa
 
 #
-# Libraries
+# Patch the messages files with the version
 #
-CLIB = C:o.stubs
-ELIB = Tbox:o.eventlib
-TLIB = Tbox:o.toolboxlib
-WLIB = Tbox:o.wimplib
-CONLIB = <Lib$Dir>.ConfigLib.o.ConfigLib
-
-#
-# Include files
-#
-INCLUDES = -ITbox:,C:,<Lib$Dir>.ConfigLib.
-
-FILES=\
- ${LDIR}.!Help\
- ${RDIR}.!Boot\
- ${LDIR}.!Run\
- ${RDIR}.!RunImage\
- ${RDIR}.!Sprites\
- ${RDIR}.!Sprites11\
- ${RDIR}.!Sprites22\
- ${RDIR}.CoSprite\
- ${RDIR}.CoSprite11\
- ${RDIR}.CoSprite22\
- ${LDIR}.Messages\
- ${LDIR}.Res\
-
-OBJS = Main.o MouseType.o Settings.o ToolboxE.o WimpE.o WimpM.o
-
-#
-# Rule patterns
-#
-.c.o:;  ${CC} ${CFLAGS} -o $@ $<
-
-#
-# Main rules:
-#
-# Application
-#
-all: ${FILES}
-	@echo ${COMPONENT}: All built (Disc)
-
-install: ${FILES}
+GenMessage: ${LDIR}.Messages VersionNum
+	${MSGVERSION} ${LDIR}.Messages > GenMessage
 	${MKDIR} ${INSTAPP}
-	|
-	${CP} ${RDIR}.!Boot      ${INSTAPP}.!Boot      ${CPFLAGS}
-	${CP} ${LDIR}.!Help      ${INSTAPP}.!Help      ${CPFLAGS}
-	${CP} ${LDIR}.!Run       ${INSTAPP}.!Run       ${CPFLAGS}
-	${CP} ${RDIR}.!RunImage  ${INSTAPP}.!RunImage  ${CPFLAGS}
-	${CP} ${RDIR}.!Sprites   ${INSTAPP}.!Sprites   ${CPFLAGS}
-	${CP} ${RDIR}.!Sprites11 ${INSTAPP}.!Sprites11 ${CPFLAGS}
-	${CP} ${RDIR}.!Sprites22 ${INSTAPP}.!Sprites22 ${CPFLAGS}
-	${CP} ${RDIR}.CoSprite   ${INSTAPP}.CoSprite   ${CPFLAGS}
-	${CP} ${RDIR}.CoSprite11 ${INSTAPP}.CoSprite11 ${CPFLAGS}
-	${CP} ${RDIR}.CoSprite22 ${INSTAPP}.CoSprite22 ${CPFLAGS}
-	${CP} ${LDIR}.Messages   ${INSTAPP}.Messages   ${CPFLAGS}
-	${CP} ${LDIR}.Res        ${INSTAPP}.Res        ${CPFLAGS}
-	|
-	${ATTR} -directories +wr -ww ${INSTAPP}
-	${ATTR} -files +or +ow +wr -ww ${INSTAPP}
-	|
-	@echo ${COMPONENT}: All installed (Disc)
-
-clean:
-	${WIPE} o.* ${WFLAGS}
-	${RM} ${RDIR}.!RunImage
-	@echo ${COMPONENT}: cleaned
+	${CP} GenMessage ${INSTAPP}.Messages ${CPFLAGS}
 
-#
-# Static dependencies:
-#
-${RDIR}.!RunImage: ${OBJS} ${CONLIB} ${ELIB} ${TLIB} ${WLIB} ${CLIB}
-	${LD} ${LDFLAGS} -o $@ ${OBJS} ${CONLIB} ${ELIB} ${TLIB} ${WLIB} ${CLIB}
-	${SQUEEZE} $@
+clean::
+	${RM} GenMessage
 
-#---------------------------------------------------------------------------
 # Dynamic dependencies:
diff --git a/Resources/UK/Messages b/Resources/UK/Messages
index 3b0daed..be37cd1 100644
--- a/Resources/UK/Messages
+++ b/Resources/UK/Messages
@@ -1,7 +1,7 @@
 _TaskName:Mouse Setup
 _Purpose:Configuring the mouse
 _Author:© Acorn Computers Ltd, 1998
-_Version:0.10 (19-Dec-02)
+_Version:Fill by awk at build time
 _ConfigText:Mouse
 _ConfigHelp:Click SELECT to open the mouse configuration window.
 _ConfigSprite:co_mouse
@@ -9,3 +9,4 @@ Mystery:Unrecognised
 NoneAvail:No mouse drivers are available
 NewType:You are about to change the mouse type to '%s'. If you do not have this sort of mouse connected the pointer will stop working. Do you want to continue with the reconfiguration?
 Err_NoDefCMOS:Cannot find default CMOS file
+Err_BadClass:Resource file is corrupt
diff --git a/Resources/UK/Res,fae b/Resources/UK/Res,fae
index a841e070f9f23307f63b024d252a003a91420ace..8862745bdb0f60e27a7e50d486eb66302347b5c0 100644
GIT binary patch
delta 17
Zcmca&bj4_b3?sut*)GPV8&|B6002Bn2DJbH

delta 17
Zcmca&bj4_b3?t)2*)GPd8&|B6002Cs2F3sY

diff --git a/VersionNum b/VersionNum
index bcee9d9..2564b81 100644
--- a/VersionNum
+++ b/VersionNum
@@ -1,23 +1,23 @@
-/* (0.13)
+/* (0.14)
  *
  * This file is automatically maintained by srccommit, do not edit manually.
  * Last processed by srccommit version: 1.1.
  *
  */
-#define Module_MajorVersion_CMHG        0.13
+#define Module_MajorVersion_CMHG        0.14
 #define Module_MinorVersion_CMHG        
-#define Module_Date_CMHG                06 Oct 2012
+#define Module_Date_CMHG                17 Jan 2013
 
-#define Module_MajorVersion             "0.13"
-#define Module_Version                  13
+#define Module_MajorVersion             "0.14"
+#define Module_Version                  14
 #define Module_MinorVersion             ""
-#define Module_Date                     "06 Oct 2012"
+#define Module_Date                     "17 Jan 2013"
 
-#define Module_ApplicationDate          "06-Oct-12"
+#define Module_ApplicationDate          "17-Jan-13"
 
 #define Module_ComponentName            "MousSetup"
 #define Module_ComponentPath            "castle/RiscOS/Sources/SystemRes/Configure2/PlugIns/MousSetup"
 
-#define Module_FullVersion              "0.13"
-#define Module_HelpVersion              "0.13 (06 Oct 2012)"
-#define Module_LibraryVersionInfo       "0:13"
+#define Module_FullVersion              "0.14"
+#define Module_HelpVersion              "0.14 (17 Jan 2013)"
+#define Module_LibraryVersionInfo       "0:14"
diff --git a/c/Main b/c/Main
index fa196c1..6507bc2 100644
--- a/c/Main
+++ b/c/Main
@@ -28,13 +28,18 @@ Date		Who	Change
 
 /* CLib */
 #include <stdlib.h>
+#include <string.h>
+#include "swis.h"
 /* Toolbox */
 #include "event.h"
 #include "toolbox.h"
+#include "window.h"
 /* Common */
 #include "error.h"
 #include "misc.h"
+#include "message.h"
 /* Local headers */
+#include "Settings.h"
 #include "Main.h"  /* includes prototypes for this file */
 #include "ToolboxE.h"
 #include "WimpE.h"
@@ -63,17 +68,50 @@ In:		Command line option:
 
 int main (int argc, char *argv[])
 {
+  int  screeny;
+  ObjectTemplateHeader *objtemplate;
+  WindowTemplate       *wintemplate;
+  WimpWindow           *windef;
+
   error_initialise ();
   throw (toolbox_initialise (0, WimpVersion, wimpm_messages, toolboxe_events,
     "<MousSetup$Dir>", &messages, &id_block, NULL, NULL, NULL));
   misc_parsearguments (argc, argv);
   throw (event_initialise (&id_block));
   throw (event_set_mask (wimpe_mask));
-//
+
+  /* Register for messages and events */
   wimpm_register ();
   wimpe_register ();
   toolboxe_register ();
-//
+
+  /* Read the window object in by hand */
+  throw (toolbox_template_lookup (0, "Mouse", (void **)&objtemplate));
+  if (objtemplate->object_class != Window_ObjectClass) {
+    _kernel_oserror e = { 0, "" };
+
+    strcpy (e.errmess, message_lookup_direct (messages,"Err_BadClass"));
+    _swi (OS_GenerateError, _IN(0), &e);
+  }
+  wintemplate = objtemplate->body;
+  windef = &wintemplate->window;
+  screeny = _swi (OS_ReadModeVariable, _INR(0,1) | _RETURN(2), -1, 12) <<
+            _swi (OS_ReadModeVariable, _INR(0,1) | _RETURN(2), -1, 5);
+
+  /* Calculate the window height compared with the screen and
+   * turn the vertical scrollbar on if it doesn't fit
+   */
+  if ((windef->visible_area.ymax - windef->visible_area.ymin) >= screeny) {
+    windef->flags |= WimpWindow_VScroll;
+  }
+  else {
+    windef->flags &= ~WimpWindow_VScroll;
+  }
+  throw (toolbox_create_object (Toolbox_CreateObject_InCore, objtemplate, &mainwindow_id));
+  misc_openwindow (mainwindow_id, TRUE);
+  settings_read (cmos_read);
+
+  /* Go */
   error_recover_point();
   while (!quit) {
     throw (event_poll (NULL, &poll_block, NULL));
diff --git a/c/MouseType b/c/MouseType
index c21152b..4c1bbbd 100644
--- a/c/MouseType
+++ b/c/MouseType
@@ -29,6 +29,8 @@ Date		Who	Change
 #include <stdio.h>
 #include <string.h>
 #include "swis.h"
+#include "Global/ModHand.h"
+#include "Global/RISCOS.h"
 /* Toolbox */
 #include "wimplib.h"
 /* Common */
@@ -62,7 +64,7 @@ Out:		Pointer to most recently-added record
 static pointerv_record *get_pointer_list (void)
 {
   if (pointer_list != NULL) free_pointer_list ();
-  return pointer_list = (pointerv_record *) _swi (OS_CallAVector, _INR(0,1)|_IN(9)|_RETURN(1), 1, 0, 0x26);
+  return pointer_list = (pointerv_record *) _swi (OS_CallAVector, _INR(0,1)|_IN(9)|_RETURN(1), 1, 0, PointerV);
 }
 
 /******	free_pointer_list() ***********************************************\
@@ -75,7 +77,7 @@ static void free_pointer_list (void)
 {
   while (pointer_list != NULL) {
     pointerv_record *next = pointer_list->next;
-    _swi (OS_Module, _IN(0)|_IN(2), 7, (int) pointer_list);
+    _swi (OS_Module, _IN(0)|_IN(2), ModHandReason_Free, (int) pointer_list);
     pointer_list = next;
   }
 }
diff --git a/c/Settings b/c/Settings
index 7252064..4b03f14 100644
--- a/c/Settings
+++ b/c/Settings
@@ -33,6 +33,7 @@ Date		Who	Change
 /* CLib */
 #include <string.h>
 #include "swis.h"
+#include "Global/OsWords.h"
 /* Toolbox */
 #include "toolbox.h"
 #include "window.h"
@@ -148,10 +149,10 @@ BOOL settings_write (void)
 //
   throw (slider_get_value (0, mainwindow_id, mainwindow_mousespeed, &value));
   cmos_write (MouseMultiplier, value);
-  step[0] = 0x2u;
+  step[0] = OWPointerAndMouse_SetMouseFactors;
   step[1] = (unsigned char) value;
   step[2] = (unsigned char) value;
-  _swi (OS_Word, _INR(0,1), 21, step);
+  _swi (OS_Word, _INR(0,1), OsWord_DefinePointerAndMouse, step);
 //
   throw (numberrange_get_value (0, mainwindow_id, mainwindow_dragdelay, &value));
   sprintf (string, "Configure WimpDragDelay %i", value);
diff --git a/c/ToolboxE b/c/ToolboxE
index 85c80f7..6766a6b 100644
--- a/c/ToolboxE
+++ b/c/ToolboxE
@@ -41,12 +41,10 @@ Date		Who	Change
 #include "ToolboxE.h"  /* includes prototypes for this file */
 
 static int toolboxe_actionbuttonselected (int event_code, ToolboxEvent *event, IdBlock *id_block, void *handle);
-static int toolboxe_objectautocreated (int event_code, ToolboxEvent *event, IdBlock *id_block, void *handle);
 static int toolboxe_optionbuttonstatechanged (int event_code, ToolboxEvent *event, IdBlock *id_block, void *handle);
 static int toolboxe_stringsetabouttobeshown (int event_code, ToolboxEvent *event, IdBlock *id_block, void *handle);
 
 int toolboxe_events [5] =     { ActionButton_Selected,
-				Toolbox_ObjectAutoCreated,
 				OptionButton_StateChanged,
 				StringSet_AboutToBeShown,
 				0 };
@@ -54,7 +52,6 @@ int toolboxe_events [5] =     { ActionButton_Selected,
 void toolboxe_register (void)
 {
   throw (event_register_toolbox_handler (-1, ActionButton_Selected, toolboxe_actionbuttonselected, NULL));
-  throw (event_register_toolbox_handler (-1, Toolbox_ObjectAutoCreated, toolboxe_objectautocreated, NULL));
   throw (event_register_toolbox_handler (-1, OptionButton_StateChanged, toolboxe_optionbuttonstatechanged, NULL));
   throw (event_register_toolbox_handler (-1, StringSet_AboutToBeShown, toolboxe_stringsetabouttobeshown, NULL));
 }
@@ -82,20 +79,6 @@ static int toolboxe_actionbuttonselected (int event_code, ToolboxEvent *event, I
   return 1;
 }
 
-/******	toolboxe_objectautocreated() **************************************\
-
-Purpose:	Handles Toolbox_ObjectAutoCreated event
-
-\**************************************************************************/
-
-static int toolboxe_objectautocreated (int event_code, ToolboxEvent *event, IdBlock *id_block, void *handle)
-{
-  mainwindow_id = id_block->self_id;
-  misc_openwindow (mainwindow_id, TRUE);
-  settings_read (cmos_read);
-  return 1;
-}
-
 /******	toolboxe_optionbuttonstatechanged() *******************************\
 
 Purpose:	Handles OptionButton_StateChanged event
-- 
GitLab