diff --git a/Chapters/ch04-column-headings.xml b/Chapters/ch04-column-headings.xml index 36abccb..39bdbbf 100644 --- a/Chapters/ch04-column-headings.xml +++ b/Chapters/ch04-column-headings.xml @@ -145,7 +145,7 @@ ENDPROC -
+
Out of alignment

Unfortunately, any satisfaction with our new example is likely to be short-lived. If the width of the main window is reduced, and then the horizontal scroll bar used to shift the work area, we can quickly see that things go out of alignment as shown in . The main window’s work area moves with the scroll bars as expected, but the toolbar’s content remains where it was.

diff --git a/Chapters/ch05-the-nested-wimp.xml b/Chapters/ch05-the-nested-wimp.xml index 41baf0d..9c5182a 100644 --- a/Chapters/ch05-the-nested-wimp.xml +++ b/Chapters/ch05-the-nested-wimp.xml @@ -56,14 +56,18 @@
-
+
Re-creating our toolbar -

To see how the Nested Wimp works, we’ll re-create our column-heading toolbar from the last chapter using its functionality – it looked as seen in . There will be no changes required to the templates, so we can launch straight in to the code –taking as our base.

+

To see how the Nested Wimp works, we’ll re-create our column-heading toolbar from the last chapter using its functionality – it looked as seen in . We will take as our base.

-

The first thing that we will need to change is our application’s !Run file. Since we will be using the Nested Wimp, we need to check that it is actually present on the system – which we do as seen in .

+

Starting with the Templates file, we will need to make a small change to the toolbar window: it is not necessary to set the ‘window is a pane’ flag for nested windows, as the behaviour is implicit in the nesting, so we will untick Pane in the Toolbar window’s flags as seen in . The Moveable flag remains unset; there are no other changes.

+ + + +

The next thing that we will need to change is our application’s !Run file. Since we will be using the Nested Wimp, we need to check that it is actually present on the system – which we do as seen in .

Set PaneDemo$Dir <Obey$Dir> @@ -366,6 +370,54 @@ ENDPROC
+ + +
+A fixed toolbar + +

If we wanted to implement the fixed ‘URL bar’ from with the Nested Wimp, how would we go about modifying the example above? The first thing to do is to fetch the old toolbar template from that chapter, returning to the bar with two action buttons and a writeable icon. As with the column heading bar above, we will need to unset the ‘window is a pane’ flag, but otherwise the template is unchanged.

+ +

If we look back at the changes required in to make the toolbar’s work area follow the work area of the main window, we can see that it was simply a case of adding a single line to keep the horizontal scroll offsets in step.

+ +toolbar%!20 = main%!20 : REM X Scroll Offset + +

We can remove this line from PROCopen_main_window, but with the Nested Wimp there’s one more change that needs to be made. In the nesting flags, we set the anchor point for the X scroll offset to %00 – for “link to the work area of the parent”. However, we no longer want the bar to scroll with the main window.

+ +

Instead, we should set the horizontal scroll anchor to %01, for “link to the left or bottom (X0 or Y0) of the parent’s visible area”. This will ensure that the left-hand end of the bar, where the two action buttons are, will remain visible as the main window changes shape.

+ +

The updated part of PROCopen_main_window to handle the opening of the toolbar pabe can be seen in .

+ +REM Get the toolbar details + +!toolbar% = ToolBarWindow% +SYS "Wimp_GetWindowState",,toolbar% + +REM Find the height of the toolbar pane's visible area. + +bar_height% = toolbar%!16 - toolbar%!8 : REM Visible Area Y1 - Y0 + +REM Move the toolbar pane so that it's in the correct X and Y position +REM relative to where the main window is to go. + +toolbar%!4 = main%!4 : REM Visible Area X0 +toolbar%!8 = main%!16 - bar_height% : REM Visible Area Y0 +toolbar%!12 = main%!12 : REM Visible Area X1 +toolbar%!16 = main%!16 : REM Visible Area Y1 + +REM Open the toolbox pane at the top of the stack, nested into the main window. + +toolbar%!28 = -1 + +SYS "Wimp_OpenWindow",,toolbar%, &4B534154, !main%, &09A90000 + +

When run, the application should look as seen in – again, indistinguishable from the one that we built in from a user’s perspective.

+ + + +

The complete application can be found in .

+ + +
diff --git a/Downloads/Chapter05/NestedFixed/!PaneDemo/!Boot,feb b/Downloads/Chapter05/NestedFixed/!PaneDemo/!Boot,feb new file mode 100644 index 0000000..05fdbf5 --- /dev/null +++ b/Downloads/Chapter05/NestedFixed/!PaneDemo/!Boot,feb @@ -0,0 +1,24 @@ +| >!Boot +| +| Copyright 2021, Stephen Fryatt (info@stevefryatt.org.uk) +| +| This file is part of PaneDemo: +| +| http://www.stevefryatt.org.uk/risc-os/panes +| +| Permission is hereby granted, free of charge, to any person obtaining +| a copy of this software and associated documentation files (the +| "Software"), to deal in the Software without restriction, including +| without limitation the rights to use, copy, modify, merge, publish, +| distribute, sublicense, and/or sell copies of the Software, and to +| permit persons to whom the Software is furnished to do so. +| +| THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +| OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +| MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +| IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +| CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +| TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +| SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +If ""="" Then Set PaneDemo$Dir diff --git a/Downloads/Chapter05/NestedFixed/!PaneDemo/!Run,feb b/Downloads/Chapter05/NestedFixed/!PaneDemo/!Run,feb new file mode 100644 index 0000000..f64a031 --- /dev/null +++ b/Downloads/Chapter05/NestedFixed/!PaneDemo/!Run,feb @@ -0,0 +1,29 @@ +| >!Run +| +| Copyright 2021, Stephen Fryatt (info@stevefryatt.org.uk) +| +| This file is part of PaneDemo: +| +| http://www.stevefryatt.org.uk/risc-os/panes +| +| Permission is hereby granted, free of charge, to any person obtaining +| a copy of this software and associated documentation files (the +| "Software"), to deal in the Software without restriction, including +| without limitation the rights to use, copy, modify, merge, publish, +| distribute, sublicense, and/or sell copies of the Software, and to +| permit persons to whom the Software is furnished to do so. +| +| THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +| OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +| MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +| IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +| CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +| TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +| SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +Set PaneDemo$Dir + +RMEnsure WindowManager 3.80 Error PaneDemo requires the Nested Window Manager. + +WimpSlot -min 96K -max 96K +Run .!RunImage diff --git a/Downloads/Chapter05/NestedFixed/!PaneDemo/!RunImage,ffb b/Downloads/Chapter05/NestedFixed/!PaneDemo/!RunImage,ffb new file mode 100644 index 0000000..ce3a1e1 Binary files /dev/null and b/Downloads/Chapter05/NestedFixed/!PaneDemo/!RunImage,ffb differ diff --git a/Downloads/Chapter05/NestedFixed/!PaneDemo/Templates,fec b/Downloads/Chapter05/NestedFixed/!PaneDemo/Templates,fec new file mode 100644 index 0000000..8171425 Binary files /dev/null and b/Downloads/Chapter05/NestedFixed/!PaneDemo/Templates,fec differ diff --git a/Downloads/Chapter05/NestedScroll/!PaneDemo/Templates,fec b/Downloads/Chapter05/NestedScroll/!PaneDemo/Templates,fec index 3f3953c..cfbf398 100644 Binary files a/Downloads/Chapter05/NestedScroll/!PaneDemo/Templates,fec and b/Downloads/Chapter05/NestedScroll/!PaneDemo/Templates,fec differ diff --git a/Images/Chapter05/nest-wimp-fixed.png b/Images/Chapter05/nest-wimp-fixed.png new file mode 100644 index 0000000..c9b499d Binary files /dev/null and b/Images/Chapter05/nest-wimp-fixed.png differ diff --git a/Images/Chapter05/nest-wimp-template.png b/Images/Chapter05/nest-wimp-template.png new file mode 100644 index 0000000..9ed2e88 Binary files /dev/null and b/Images/Chapter05/nest-wimp-template.png differ