• Update iconbar icon

    From Rob Hemmings@21:1/5 to All on Tue Aug 9 19:05:22 2022
    It is a long time since I've done any programming on RISC OS and I'd be
    very grateful for a quick bit of advice on something I've forgotten.

    Is it possible to change the state of an iconbar icon? I'm writing a
    very simple BASIC program to toggle the state of a system variable and
    I'd like a visual indication of which state it is in. It seems a waste
    to open a separate window just for that so it would be neater to just
    make an alteration to the iconbar icon but I can't remember if that is possible?

    Thanks in advance for any advice.

    --
    -------------------------------------------------------------
    Rob Hemmings Southport

    robnews@rgvk.co.uk

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Steve Fryatt@21:1/5 to Rob Hemmings on Tue Aug 9 19:28:36 2022
    On 9 Aug, Rob Hemmings wrote in message
    <5a1560a69erhemmings@rgvk.co.uk>:

    Is it possible to change the state of an iconbar icon? I'm writing a very simple BASIC program to toggle the state of a system variable and I'd like
    a visual indication of which state it is in. It seems a waste to open a separate window just for that so it would be neater to just make an alteration to the iconbar icon but I can't remember if that is possible?

    Yes: it's just a normal icon. Anything that you can do via Wimp_SetIconState
    or changing indirected data will work, and I assume that you'll be able to
    use Wimp_ResizeIcon on RISC OS 3.5+.

    Just collect the handle when you create the icon with Wimp_CreateIcon, and
    use it in the usual way.

    --
    Steve Fryatt - Leeds, England

    http://www.stevefryatt.org.uk/

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Harriet Bazley@21:1/5 to Rob Hemmings on Tue Aug 9 19:41:40 2022
    On 9 Aug 2022 as I do recall,
    Rob Hemmings wrote:

    Is it possible to change the state of an iconbar icon? I'm writing a
    very simple BASIC program to toggle the state of a system variable and
    I'd like a visual indication of which state it is in. It seems a waste
    to open a separate window just for that so it would be neater to just
    make an alteration to the iconbar icon but I can't remember if that is possible?

    You can change the indirected text underneath the icon in the usual way
    by poking new contents into the buffer, and call Wimp_SetIconState to
    force a redraw. (The 'window handle' for an iconbar icon is set to
    -2.)

    DEF PROCseticontext(window%,icon%,text$)
    !block%=window%:block%!4=icon%
    SYS"Wimp_GetIconState",,block%
    $(block%!28)=text$
    block%!8=0:block%!12=0
    SYS"Wimp_SetIconState",,block%
    ENDPROC


    I imagine you can do the same thing to change the contents of an
    indirected sprite icon, but I've never actually done it!


    --
    Harriet Bazley == Loyaulte me lie ==

    Down with categorical imperatives!

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Rob Hemmings@21:1/5 to Steve Fryatt on Wed Aug 10 09:32:38 2022
    In article <mpro.rgd1zj00n9svt03u0.news@stevefryatt.org.uk>,
    Steve Fryatt <news@stevefryatt.org.uk> wrote:
    On 9 Aug, Rob Hemmings wrote in message
    <5a1560a69erhemmings@rgvk.co.uk>:

    Is it possible to change the state of an iconbar icon? I'm writing a very simple BASIC program to toggle the state of a system variable and I'd like a visual indication of which state it is in. It seems a waste to open a separate window just for that so it would be neater to just make an alteration to the iconbar icon but I can't remember if that is possible?

    Yes: it's just a normal icon. Anything that you can do via Wimp_SetIconState or changing indirected data will work, and I assume that you'll be able to use Wimp_ResizeIcon on RISC OS 3.5+.

    Just collect the handle when you create the icon with Wimp_CreateIcon, and use it in the usual way.

    Thanks Steve and Harriet for the helpful advice and reminder.

    --
    -------------------------------------------------------------
    Rob Hemmings Southport

    rhnews@dsl.pipex.com

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Sebastian Barthel@21:1/5 to All on Thu Dec 15 14:55:10 2022
    Am Tue, 09 Aug 2022 19:05:22 +0100 schrieb Rob Hemmings:

    It is a long time since I've done any programming on RISC OS and I'd be
    very grateful for a quick bit of advice on something I've forgotten.

    Is it possible to change the state of an iconbar icon? I'm writing a
    very simple BASIC program to toggle the state of a system variable and
    I'd like a visual indication of which state it is in. It seems a waste
    to open a separate window just for that so it would be neater to just
    make an alteration to the iconbar icon but I can't remember if that is possible?

    Thanks in advance for any advice.


    It is a long time since You've posted this question ...

    but eventually its interesting to You and other folks how this can be done
    in a BASIC fragment, which You should be usable in this form:



    active% = TRUE

    DIM bariconname% 12 : $bariconname% = "active"

    baricon%=FNdefine_icon(bariconname%)



    wimploop

    SYS "Wimp_Poll",pollmask%,pollblock% TO pollevent%

    CASE pollevent% OF

    WHEN 6 : CASE pollblock%!8 OF

    WHEN %100:

    active%=NOT(active%) : barmenu%!52=barmenu%!52 EOR %1

    IF active% THEN $bariconname%="active" ELSE $bariconname%="nonactive"

    block%!0=-2 : block%!4=baricon%

    block%!8=0 : block%!12=0

    SYS "Wimp_SetIconState",,block%

    WHEN %010:

    SYS "Wimp_GetPointerInfo",,block%

    SYS "Wimp_CreateMenu",,barmenu%,block%!0-60,230

    ENDCASE

    loopend



    DEF FNdefine_icon(name%)

    LOCAL width%,hight%,icon%

    SYS"Wimp_SpriteOp",40,,$(name%) TO ,,,width%,hight%

    block%!0=-1

    block%!4=0

    block%!8=0

    block%!12=width%*2

    block%!16=hight%*4

    block%!20=%0011000100001010

    block%!24=name% : block%!28=1 : block%!32=12

    SYS "Wimp_CreateIcon",,block% TO icon%

    =icon%



    The only thing needed is a !Sprite File with at least two Icons in it
    named "active" and "nonactive". This File has to known by the WIMP. The
    easiest way to achieve this is by Running an "Iconsprites <Obey$Dir>.!
    Sprites" Command in the !Run Obey File.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Rob Hemmings@21:1/5 to Sebastian Barthel on Mon Dec 19 13:15:26 2022
    In article <tnfcge$13r25$1@solani.org>,
    Sebastian Barthel <naitsabes@freenet.de> wrote:
    Am Tue, 09 Aug 2022 19:05:22 +0100 schrieb Rob Hemmings:

    It is a long time since I've done any programming on RISC OS and I'd be very grateful for a quick bit of advice on something I've forgotten.

    Is it possible to change the state of an iconbar icon? I'm writing a
    very simple BASIC program to toggle the state of a system variable and
    I'd like a visual indication of which state it is in. It seems a waste
    to open a separate window just for that so it would be neater to just
    make an alteration to the iconbar icon but I can't remember if that is possible?

    Thanks in advance for any advice.


    It is a long time since You've posted this question ...

    but eventually its interesting to You and other folks how this can be done
    in a BASIC fragment, which You should be usable in this form:

    [Snip BASIC code]

    Thanks Sebastian for such a thorough and complete answer. I'd put
    something like that together myself so won't need to use it but your
    example could be very helpful to anyone else reading this thread in the
    future.

    --
    -------------------------------------------------------------
    Rob Hemmings Southport

    Tel: +44 (0)1704 573210 rhemmings@rgvk.co.uk

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)