• Text in a wimp window

    From Bob Latham@bob@sick-of-spam.invalid to comp.sys.acorn.programmer on Wed Aug 13 20:18:48 2025
    From Newsgroup: comp.sys.acorn.programmer

    I wish to send dozen lines of text to a wimp window without icons in
    a programme I'm writing. How do I do it?

    For literally decades I have avoided trying to place text in a window
    and have managed with icons. The reason is simple, in over 40 years I
    cannot find anywhere a simple explanation of how to do it.

    Yes, I know a bit about some thing, works_area and visible_area,
    redraw boxes etc. I'm not yet "stuck" on those things.

    But how the blazes you write the letter A to a wimp window I've never understood. I would love a clue to this.

    How do you select the window?
    What cursor is it graphics VDU5 or text and why?.
    How do you move it (I'm NOT coding in BASIC)?
    Can you then use OS_WriteC etc. ?

    It's the OS calls I need, I can then look them up.

    I've got shelves of books on RISC OS but I cannot find an answer I
    understand in any of them. I'm sure the answers are there but they
    continue to elude me.

    For all the good they do me on this, I do have the old paper PRMs,
    inc 5A.

    Would much appreciate it if someone could help, I've been defeated by
    this a very, very long time, I'm just blind to it for some reason. .

    Thanks.

    Bob.

    --- Synchronet 3.21a-Linux NewsLink 1.2
  • From druck@news@druck.org.uk to comp.sys.acorn.programmer on Thu Aug 14 09:35:10 2025
    From Newsgroup: comp.sys.acorn.programmer

    On 13/08/2025 20:18, Bob Latham wrote:
    I wish to send dozen lines of text to a wimp window without icons in
    a programme I'm writing. How do I do it?

    Why can't you use icons? It really is much easier!

    For literally decades I have avoided trying to place text in a window
    and have managed with icons. The reason is simple, in over 40 years I
    cannot find anywhere a simple explanation of how to do it.

    Yes, I know a bit about some thing, works_area and visible_area,
    redraw boxes etc. I'm not yet "stuck" on those things.

    Good.

    But how the blazes you write the letter A to a wimp window I've never understood. I would love a clue to this.

    How do you select the window?
    What cursor is it graphics VDU5 or text and why?.
    How do you move it (I'm NOT coding in BASIC)?
    Can you then use OS_WriteC etc. ?

    In a redraw loop it is using the graphics cursor, so you can move using OS_Plot 4 and write the text with OS_WriteC. But that will give you
    horrible old system font which doesn't look good compared to everything
    else the Wimp font.

    I would very much recommend reading up on the Font SWIs, yes they are
    very complicated, but then your program will look like a desktop
    application rather than a refugee from the BBC Micro.

    ---druck

    --- Synchronet 3.21a-Linux NewsLink 1.2
  • From Bob Latham@bob@sick-of-spam.invalid to comp.sys.acorn.programmer on Thu Aug 14 09:54:04 2025
    From Newsgroup: comp.sys.acorn.programmer

    In article <107k73u$cbd1$1@dont-email.me>,
    druck <news@druck.org.uk> wrote:

    In a redraw loop it is using the graphics cursor, so you can move
    using OS_Plot 4 and write the text with OS_WriteC. But that will
    give you horrible old system font which doesn't look good compared
    to everything else the Wimp font.

    Thanks Dave, a clue at last, somewhere to look.

    Cheers,

    Bob.

    --- Synchronet 3.21a-Linux NewsLink 1.2
  • From Theo@theom+news@chiark.greenend.org.uk to comp.sys.acorn.programmer on Thu Aug 14 10:03:41 2025
    From Newsgroup: comp.sys.acorn.programmer

    druck <news@druck.org.uk> wrote:
    In a redraw loop it is using the graphics cursor, so you can move using OS_Plot 4 and write the text with OS_WriteC. But that will give you
    horrible old system font which doesn't look good compared to everything
    else the Wimp font.

    Another option is to have an icon which is a sprite and occupies all of your window. Then, using VDU commands, redirect your OS_Plot, Font_Paint, etc drawing to the sprite instead of the screen.

    The advantage of doing that over a redraw loop is you don't need to worry
    about drawing fractional parts of the window as you do in a redraw loop. eg
    if the window is partially covered by one in front, you need to draw only
    the parts that are not occluded.

    That does give you certain limitations though - eg the sprite is a fixed
    size. If you allow the window to be resized you need to work out what to do about that (don't allow enlargement? delete the icon+sprite and recreate
    when resized?). Also updates may not be as fast (eg if you want to display moving text or images).

    Theo
    --- Synchronet 3.21a-Linux NewsLink 1.2
  • From Bob Latham@bob@sick-of-spam.invalid to comp.sys.acorn.programmer on Thu Aug 14 10:45:28 2025
    From Newsgroup: comp.sys.acorn.programmer

    In article <Lyl*BM2jA@news.chiark.greenend.org.uk>,
    Theo <theom+news@chiark.greenend.org.uk> wrote:

    Another option is to have an icon which is a sprite and occupies
    all of your window. Then, using VDU commands, redirect your
    OS_Plot, Font_Paint, etc drawing to the sprite instead of the
    screen.

    Thanks for that Theo, something else to look into.

    Cheers,

    Bob.

    --- Synchronet 3.21a-Linux NewsLink 1.2
  • From Sebastian Barthel@naitsabes@freenet.de to comp.sys.acorn.programmer on Thu Aug 14 14:37:12 2025
    From Newsgroup: comp.sys.acorn.programmer

    Am Thu, 14 Aug 2025 10:45:28 +0100 schrieb der Meister Bob Latham:

    In article <Lyl*BM2jA@news.chiark.greenend.org.uk>,
    Theo <theom+news@chiark.greenend.org.uk> wrote:

    Another option is to have an icon which is a sprite and occupies all of
    your window. Then, using VDU commands, redirect your OS_Plot,
    Font_Paint, etc drawing to the sprite instead of the screen.

    Thats an good and easy variant. Try this for an start.


    Otherwise You should try to find out more about whats meant with "window
    area" and espacially how the scrollbars are calculated into the position
    oft this area. The real intersting thing is the "Wimp_UpdateWindow" call.
    This works together with the "Wimp_GetRectangle" call and can be done in
    the form of nullevent for the whole window (dirty, without doing some
    extra calculations for the area rectangles)


    DIM text% 256
    $text% = "this is the text for demonstrating the fontplot !"+CHR$(0)

    DIM b% 256
    bitmask% = %0001100100110010
    finished%= FALSE


    REPEAT

    SYS "Wimp_Poll",bitmask%,b% TO pollevent%,b%
    CASE pollevent% OF
    WHEN 0 : PROCtextplot
    ENDCASE
    UNTIL finished%

    END


    DEF PROCtextplot

    winblock!0 = windowhandle%
    winblock!4 = 8 : REM left - delta x as normal (0 is area left)
    winblock!8 = -512 : REM lower - delta y but in (-) area coordinates winblock!12= 640-8: REM right - delta x as normal
    winblock!16= -8 : REM upper - delta y in (-) area coordinates
    SYS "Wimp_UpdateWindow",,winblock% TO update%

    WHILE update%
    scrollx% = winblock%!20
    scrolly% = winblock%!24

    SYS "Wimp_SetColour",1
    RECTANGLE FILL winblock%!4-scrollx%,winblock%!16-234-scrolly%,256,256

    SYS "Wimp_SetColour",6
    LINE X0%-scrollx%,Y0%-scrolly%,X1-scrollx%,Y1-scrolly%

    SYS "Wimp_TextOp",0,&1122dd00,&334455
    SYS "Wimp_TextOp",2,text%,-1,-1,256+winblock%!4-scrollx%,-256+winblock%! 16-scrolly%

    SYS "Wimp_GetRectangle",, windowblock% TO update%
    ENDWHILE

    ENDPROC



    This should point You in a manageable direction. Every String has to be
    limted by an "0" Symbol - that the CHR$(0). Otherwise the Wimp_TextOp
    will do strange things.

    TextOp with Reason Code 0 colours the text - &1122dd00 is RED (&BBGGRR00).

    TextOp with Reason Code 2 prints the text of the stringbuffer onto the
    screen. Positon is (256,-256) into the Area and the scrollcoordinates are calculated too.

    To print more than one line of text You could read every line into the
    text% buffer and print them in loop.

    To calculate the maximum length of text possible, TextOp Reasond Code 1
    allows to ask the Wimp how many characters are the length of the
    (visible) window area. The MID$ or LEFT$ operations in a loop are handy
    to find this length. Then the buffer has to be CHR$(0) coded at the
    calculated position.


    RECTANGLE FILL and LINE commands are here to demonstrate how graphics can
    be plotted the same way. The RECTANGLE FILL also allows to clean up an
    portion of the window in a "rude" way too.


    SBn
    --- Synchronet 3.21a-Linux NewsLink 1.2
  • From Theo@theom+news@chiark.greenend.org.uk to comp.sys.acorn.programmer on Thu Aug 14 16:12:56 2025
    From Newsgroup: comp.sys.acorn.programmer

    Theo <theom+news@chiark.greenend.org.uk> wrote:
    Another option is to have an icon which is a sprite and occupies all of your window. Then, using VDU commands, redirect your OS_Plot, Font_Paint, etc drawing to the sprite instead of the screen.

    I misremembered, it's not VDU commands to redirect output to a sprite but OS_SpriteOp 60: https://www.riscosopen.org/wiki/documentation/show/OS_SpriteOp%2060

    (I think it was VDU at one time - Graphics Extension Rom on the BBC Micro?)
    --- Synchronet 3.21a-Linux NewsLink 1.2
  • From Bob Latham@bob@sick-of-spam.invalid to comp.sys.acorn.programmer on Thu Aug 14 17:57:17 2025
    From Newsgroup: comp.sys.acorn.programmer

    In article <107ksao$15e1$1@solani.org>,
    Sebastian Barthel <naitsabes@freenet.de> wrote:

    [Snip]

    REPEAT

    SYS "Wimp_Poll",bitmask%,b% TO pollevent%,b%
    CASE pollevent% OF
    WHEN 0 : PROCtextplot
    ENDCASE
    UNTIL finished%

    END

    [Snip]

    Wow. Thanks Sebastian. Much to look at and read about there.
    I appreciate your help, thanks.

    Bob.

    --- Synchronet 3.21a-Linux NewsLink 1.2
  • From Richard Ashbery@basura@invalid.addr.uk to comp.sys.acorn.programmer on Thu Aug 14 21:19:41 2025
    From Newsgroup: comp.sys.acorn.programmer

    In article <5c4be2e7bbbob@sick-of-spam.invalid>, Bob Latham <bob@sick-of-spam.invalid> wrote:
    I wish to send dozen lines of text to a wimp window without icons
    in a programme I'm writing. How do I do it?

    For literally decades I have avoided trying to place text in a
    window and have managed with icons. The reason is simple, in over
    40 years I cannot find anywhere a simple explanation of how to do
    it.

    Yes, I know a bit about some thing, works_area and visible_area,
    redraw boxes etc. I'm not yet "stuck" on those things.

    But how the blazes you write the letter A to a wimp window I've
    never understood. I would love a clue to this.

    How do you select the window? What cursor is it graphics VDU5 or
    text and why?. How do you move it (I'm NOT coding in BASIC)?

    Pity as I was going to suggest The Application Tutorial and Listings
    Book by Chris Dewhurst of Drag 'n Drop fame. There is an example of
    getting text into a window but as Druck says by means of an icon(s).
    The book is written for BASIC users which I don't think is what you
    want.

    Richard

    --- Synchronet 3.21a-Linux NewsLink 1.2
  • From Bob Latham@bob@sick-of-spam.invalid to comp.sys.acorn.programmer on Fri Aug 15 16:39:56 2025
    From Newsgroup: comp.sys.acorn.programmer

    In article <5c4c6c50b0basura@invalid.addr.uk>,
    Richard Ashbery <basura@invalid.addr.uk> wrote:

    Pity as I was going to suggest The Application Tutorial and Listings
    Book by Chris Dewhurst of Drag 'n Drop fame. There is an example of
    getting text into a window but as Druck says by means of an icon(s).
    The book is written for BASIC users which I don't think is what you
    want.

    I have been looking at the possibility of using icons. The big
    disappointment with them to me is that I don't think you can change
    the pointer to text buffer *after* the icon has been created. So no
    fast and easy way to make an icon based window scroll even just a few
    lines.

    Thanks for the suggestion.

    Bob.

    --- Synchronet 3.21a-Linux NewsLink 1.2
  • From Steve Fryatt@news@stevefryatt.org.uk to comp.sys.acorn.programmer on Fri Aug 15 20:06:47 2025
    From Newsgroup: comp.sys.acorn.programmer

    On 15 Aug, Bob Latham wrote in message
    <5c4cd689e8bob@sick-of-spam.invalid>:

    I have been looking at the possibility of using icons. The big
    disappointment with them to me is that I don't think you can change the pointer to text buffer *after* the icon has been created. So no fast and
    easy way to make an icon based window scroll even just a few lines.

    Use self-redraw and Wimp_PlotIcon, plus a single icon template that you
    change the details in before each call. That way, you can also set the
    window extent and use normal Wimp scrolling.

    For an example in C, see (sorry, this is probably Iris or a non-RISC OS browser).

    https://github.com/steve-fryatt/printpdf/blob/eede3c2050353f55c0151776e187dd9bb0181696/src/convert.c#L1571

    (there's similar code in CashBook, Locate, PS2Paper, Puzzles and probably
    other places too, but I think this is the smallest and simplest example that I've got).
    --
    Steve Fryatt - Leeds, England

    http://www.stevefryatt.org.uk/
    --- Synchronet 3.21a-Linux NewsLink 1.2
  • From Bob Latham@bob@sick-of-spam.invalid to comp.sys.acorn.programmer on Sat Aug 16 16:10:07 2025
    From Newsgroup: comp.sys.acorn.programmer

    In article <mpro.t11uf400fdgng0dmf.news@stevefryatt.org.uk>,
    Steve Fryatt <news@stevefryatt.org.uk> wrote:
    On 15 Aug, Bob Latham wrote in message
    <5c4cd689e8bob@sick-of-spam.invalid>:

    I have been looking at the possibility of using icons. The big disappointment with them to me is that I don't think you can
    change the pointer to text buffer *after* the icon has been
    created. So no fast and easy way to make an icon based window
    scroll even just a few lines.

    Use self-redraw and Wimp_PlotIcon, plus a single icon template that
    you change the details in before each call. That way, you can also
    set the window extent and use normal Wimp scrolling.

    For an example in C, see (sorry, this is probably Iris or a
    non-RISC OS browser).

    https://github.com/steve-fryatt/printpdf/blob/eede3c2050353f55c0151776e187dd9bb0181696/src/convert.c#L1571

    (there's similar code in CashBook, Locate, PS2Paper, Puzzles and
    probably other places too, but I think this is the smallest and
    simplest example that I've got).

    That sounds fantastic I would love to be able to code that up. For me
    who's old and not terribly bright I have two mountains to climb.
    Firstly understanding the principal and detail of your concept and
    secondly tackling a window redraw loop which I've never done and have
    avoided for decades.

    I think it would take me a very long time to understand your C code,
    but I may be able to understand your concept.

    On your icon method, have I grasped this?..
    These icons are just temporary and in effect they place a line of
    text on the window and then the icon no longer exists, just leaving
    the text on the screen. That means you can create them as you need
    without any count?

    Wow. I had no idea that was possible.

    Is this on the right lines..
    Plot an icon for line 1 near top of screen.

    Next text line comes along...
    Plot an icon for line 2 under line 1.

    Continue until screen is filled then....
    Next line comes in.
    Plot a new bottom icon which covers the previous one.

    Plot an icon 1 line higher with the text for what was the bottom line
    last time. etc.

    As for the redraw loop..
    Can I cheat to start with? ie. rely on the clip window and redraw
    the entire window each time? Have that as a sort of base camp for
    this mountain climb.

    Fantastic. Thanks for the idea Steve.

    Not sure I'm clever enough to work all this out but I'm going to try.


    Cheers,

    Bob.

    --- Synchronet 3.21a-Linux NewsLink 1.2
  • From Jean-Michel@jmc.bruck@orange.fr to comp.sys.acorn.programmer on Sun Aug 17 18:01:48 2025
    From Newsgroup: comp.sys.acorn.programmer

    In message <5c4cd689e8bob@sick-of-spam.invalid>
    Bob Latham <bob@sick-of-spam.invalid> wrote:

    In article <5c4c6c50b0basura@invalid.addr.uk>,
    Richard Ashbery <basura@invalid.addr.uk> wrote:

    Pity as I was going to suggest The Application Tutorial and Listings
    Book by Chris Dewhurst of Drag 'n Drop fame. There is an example of
    getting text into a window but as Druck says by means of an icon(s).
    The book is written for BASIC users which I don't think is what you
    want.

    I have been looking at the possibility of using icons. The big
    disappointment with them to me is that I don't think you can change
    the pointer to text buffer *after* the icon has been created. So no
    fast and easy way to make an icon based window scroll even just a few
    lines.

    Thanks for the suggestion.

    Bob.
    I use a text-area (tool box), while waiting for reunification ...
    We can do the manipulations you ask, position of the pointer, writing and
    save etc ..

    An example, an adaptation of the Jim lesurf Readwaveheader program. http://jeanmichelb.riscos.fr/Audio/AudioJimLesurf.html

    Steve's Wimp Programs in C pages are very good,
    --
    Jean-Michel
    --- Synchronet 3.21a-Linux NewsLink 1.2
  • From Steve Fryatt@news@stevefryatt.org.uk to comp.sys.acorn.programmer on Mon Aug 18 11:50:32 2025
    From Newsgroup: comp.sys.acorn.programmer

    On 2025-08-16, Bob Latham <bob@sick-of-spam.invalid> wrote:

    These icons are just temporary and in effect they place a line of
    text on the window and then the icon no longer exists, just leaving
    the text on the screen.

    More or less. They never actually exist as icons at all.

    It might be more correct to think of it as your borrowing the Wimp's icon redraw routine to plot some text and graphics into your window.

    That means you can create them as you need without any count?

    Indeed. They never exist as an icon, as far as the Wimp is concerned.

    Is this on the right lines..
    Plot an icon for line 1 near top of screen.

    Next text line comes along...
    Plot an icon for line 2 under line 1.

    Continue until screen is filled then....
    Next line comes in.
    Plot a new bottom icon which covers the previous one.

    Plot an icon 1 line higher with the text for what was the bottom line
    last time. etc.

    More or less... Wimp redraw doesn't really work that way around.

    You'll need to have a list of all of the lines of text, which you can add
    to (or shift up if you're discarding the oldest line each time). You then invalidate the redraw state of the lines that you want to replace using Wimp_ForceRedraw and let your redraw routine handle the plotting.

    As for the redraw loop..
    Can I cheat to start with? ie. rely on the clip window and redraw
    the entire window each time? Have that as a sort of base camp for
    this mountain climb.

    Yes, that's completely fine. Modern hardware won't really notice unless
    you have a lot of lines, and you can come in to optimise things later.

    Not sure I'm clever enough to work all this out but I'm going to try.

    What language are you working in? I could probably put a quick example together in BASIC later this week, if that would help?
    --
    Steve Fryatt - Leeds, England

    http://www.stevefryatt.org.uk/
    --- Synchronet 3.21a-Linux NewsLink 1.2
  • From Bob Latham@bob@sick-of-spam.invalid to comp.sys.acorn.programmer on Mon Aug 18 12:58:35 2025
    From Newsgroup: comp.sys.acorn.programmer

    In article <slrn10a61bo.372r.news@stevefryatt.org.uk>,
    Steve Fryatt <news@stevefryatt.org.uk> wrote:
    On 2025-08-16, Bob Latham <bob@sick-of-spam.invalid> wrote:

    You'll need to have a list of all of the lines of text, which you
    can add to (or shift up if you're discarding the oldest line each
    time).

    Yes, that's my plan.

    I've plotted out the relationship between the buffer number of each
    line coming in and the print order. Until the point where line buffer
    0 gets written for the first time (a scroll) the line from the top of
    the screen start from buffer zero. But after first overwrite, the top
    line buffer number is always the same as the next buffer to be
    written to. I've now got an algorithm for that.

    You then invalidate the redraw state of the lines that you
    want to replace using Wimp_ForceRedraw

    Ah. Thanks for that, I was puzzling over that.

    and let your redraw routine handle the plotting.

    Working on it, but I find 'challenging' and I'm spending hours on it.


    [Snip]


    What language are you working in?

    I've deliberately not said.

    I've been ripped into in the past for this, so I almost feel ashamed
    to say - Basic assembler.

    I don't have any logical justification for my choice, I just like it
    and understand it more than wordy hi-level stuff. Yes, I know it's
    hard to maintain, takes ages to code etc. but it's a hobby for my
    retirement.

    I could probably put a quick example together in BASIC later this
    week, if that would help?

    Steve what a kind offer but I don't wish to burden you. However, when
    I get stuck as I'm sure I will, a bit more advice would be
    appreciated.

    I'm concerned about conversion to and from work area coords which I
    think will darken my doorstep a little. :-)

    Strangely, I don't feel 'stuck' just at the moment.

    Thanks, very much indeed.

    Bob.

    --- Synchronet 3.21a-Linux NewsLink 1.2
  • From Bob Latham@bob@sick-of-spam.invalid to comp.sys.acorn.programmer on Wed Aug 20 18:35:23 2025
    From Newsgroup: comp.sys.acorn.programmer

    In article <slrn10a61bo.372r.news@stevefryatt.org.uk>,
    Steve Fryatt <news@stevefryatt.org.uk> wrote:
    On 2025-08-16, Bob Latham <bob@sick-of-spam.invalid> wrote:

    As for the redraw loop..

    Can I cheat to start with? ie. rely on the clip window and redraw
    the entire window each time? Have that as a sort of base camp for
    this mountain climb.

    Yes, that's completely fine. Modern hardware won't really notice
    unless you have a lot of lines, and you can come in to optimise
    things later.

    To my huge surprise, I now have text scrolling in a window in an
    application I've put together. Yes, it's a bit of a hack in that I
    don't draw the individual rectangles but it's probably all I need. It
    did flicker slightly when my phantom icons had different colour
    backgrounds to the window they're sat on but it was much reduced when
    I set the same colour.

    Thanks to everyone who offered their help.

    I still can't quite believe I got it working..


    Cheers,

    Bob.

    --- Synchronet 3.21a-Linux NewsLink 1.2
  • From Sebastian Barthel@naitsabes@freenet.de to comp.sys.acorn.programmer on Thu Aug 21 13:01:57 2025
    From Newsgroup: comp.sys.acorn.programmer

    Am Wed, 20 Aug 2025 18:35:23 +0100 schrieb der Meister Bob Latham:

    In article <slrn10a61bo.372r.news@stevefryatt.org.uk>,
    Steve Fryatt <news@stevefryatt.org.uk> wrote:
    On 2025-08-16, Bob Latham <bob@sick-of-spam.invalid> wrote:

    As for the redraw loop..

    Can I cheat to start with? ie. rely on the clip window and redraw the
    entire window each time? Have that as a sort of base camp for this
    mountain climb.

    Yes, that's completely fine. Modern hardware won't really notice unless
    you have a lot of lines, and you can come in to optimise things later.

    To my huge surprise, I now have text scrolling in a window in an
    application I've put together. Yes, it's a bit of a hack in that I don't
    draw the individual rectangles but it's probably all I need. It did
    flicker slightly when my phantom icons had different colour backgrounds
    to the window they're sat on but it was much reduced when I set the same colour.

    Thanks to everyone who offered their help.

    I still can't quite believe I got it working..

    That sounds good.

    If You are interested in investing some more time into this theme You
    should give the module 'ZAPredraw' a chance. Thats - on RISC OS - the
    fastet way to plot fancy fonts and fast texts onto the screen.
    --- Synchronet 3.21a-Linux NewsLink 1.2
  • From Harriet Bazley@harriet@bazleyfamily.co.uk to comp.sys.acorn.programmer on Sat Aug 23 00:31:07 2025
    From Newsgroup: comp.sys.acorn.programmer

    On 20 Aug 2025 as I do recall,
    Bob Latham wrote:

    Thanks to everyone who offered their help.

    I still can't quite believe I got it working..

    Hurrah!
    --
    Harriet Bazley == Loyaulte me lie ==

    Cleanliness is next to impossible.
    --- Synchronet 3.21a-Linux NewsLink 1.2