Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Update iconbar icon

36 views
Skip to first unread message

Rob Hemmings

unread,
Aug 9, 2022, 2:05:27 PM8/9/22
to
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

rob...@rgvk.co.uk

Steve Fryatt

unread,
Aug 9, 2022, 2:35:04 PM8/9/22
to
On 9 Aug, Rob Hemmings wrote in message
<5a1560a69...@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/

Harriet Bazley

unread,
Aug 9, 2022, 2:41:53 PM8/9/22
to
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!

Rob Hemmings

unread,
Aug 10, 2022, 4:49:39 AM8/10/22
to
In article <mpro.rgd1zj00...@stevefryatt.org.uk>,
Thanks Steve and Harriet for the helpful advice and reminder.

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

rhn...@dsl.pipex.com

Sebastian Barthel

unread,
Dec 15, 2022, 9:55:11 AM12/15/22
to
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.

Rob Hemmings

unread,
Dec 19, 2022, 8:15:47 AM12/19/22
to
In article <tnfcge$13r25$1...@solani.org>,
Sebastian Barthel <nait...@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 rhem...@rgvk.co.uk
0 new messages