Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.sys.acorn.programmer > #459 > unrolled thread

Changing indirected data address

Started byMartin Bazley <martin.bazley@blueyonder.co.uk>
First post2011-06-19 23:41 +0100
Last post2011-06-20 19:08 +0100
Articles 17 — 7 participants

Back to article view | Back to comp.sys.acorn.programmer


Contents

  Changing indirected data address Martin Bazley <martin.bazley@blueyonder.co.uk> - 2011-06-19 23:41 +0100
    Re: Changing indirected data address Steve Fryatt <news@stevefryatt.org.uk> - 2011-06-20 00:04 +0100
      Re: Changing indirected data address Paul Sprangers <Paul@sprie.nl> - 2011-06-20 10:16 +0200
        Re: Changing indirected data address Martin Wuerthner <spamtrap@mw-software.com> - 2011-06-20 23:04 +0200
          Re: Changing indirected data address Paul Sprangers <Paul@sprie.nl> - 2011-06-20 23:29 +0200
            Re: Changing indirected data address Martin Wuerthner <spamtrap@mw-software.com> - 2011-06-21 01:20 +0200
              Re: Changing indirected data address Paul Sprangers <Paul@sprie.nl> - 2011-06-21 11:27 +0200
                Re: Changing indirected data address Martin Wuerthner <spamtrap@mw-software.com> - 2011-06-21 11:40 +0200
                  Re: Changing indirected data address Paul Sprangers <Paul@sprie.nl> - 2011-06-21 12:15 +0200
                    Re: Changing indirected data address Martin Wuerthner <spamtrap@mw-software.com> - 2011-06-21 12:41 +0200
                      Re: Changing indirected data address Paul Sprangers <Paul@sprie.nl> - 2011-06-21 13:37 +0200
      Re: Changing indirected data address Theo Markettos <theom+news@chiark.greenend.org.uk> - 2011-06-20 14:18 +0100
        Re: Changing indirected data address cferris@freeRemoveuk.com.invalid - 2011-06-20 14:55 +0100
          Re: Changing indirected data address Martin Bazley <martin.bazley@blueyonder.co.uk> - 2011-06-20 18:10 +0100
        Re: Changing indirected data address Martin Bazley <martin.bazley@blueyonder.co.uk> - 2011-06-20 18:13 +0100
      Re: Changing indirected data address Martin Bazley <martin.bazley@blueyonder.co.uk> - 2011-06-20 18:18 +0100
        Re: Changing indirected data address Alan Adams <alan@adamshome.org.uk> - 2011-06-20 19:08 +0100

#459 — Changing indirected data address

FromMartin Bazley <martin.bazley@blueyonder.co.uk>
Date2011-06-19 23:41 +0100
SubjectChanging indirected data address
Message-ID<7a8601e651.martin@blueyonder.co.uk>
In a Wimp icon with indirected data and a validation string, is there a
way to change the address to which these two fields point to, without
deleting and recreating the icon?

Wimp_SetIconState alters the flags field, and Wimp_ResizeIcon alters the
four position fields.  The existence of these two SWIs rather suggests
there's no way to alter the icon data fields.

I'm not interested in changing the text - I want to physically move it
to another memory location.

-- 
  __<^>__   === RISC OS is a work of art.  Some people adore it,  ===
 / _   _ \  === others can't see the point of it, and it's really ===
( ( |_| ) ) === expensive.                                        ===
 \_>   <_/  ======================= Martin Bazley ===================

[toc] | [next] | [standalone]


#461

FromSteve Fryatt <news@stevefryatt.org.uk>
Date2011-06-20 00:04 +0100
Message-ID<mpro.ln283k0nm950g01jm.news@stevefryatt.org.uk>
In reply to#459
On 19 Jun, Martin Bazley wrote in message
    <7a8601e651.martin@blueyonder.co.uk>:

> In a Wimp icon with indirected data and a validation string, is there a
> way to change the address to which these two fields point to, without
> deleting and recreating the icon?

No.

> Wimp_SetIconState alters the flags field, and Wimp_ResizeIcon alters the
> four position fields.  The existence of these two SWIs rather suggests
> there's no way to alter the icon data fields.

Correct: you can't change them without deleting the icon.

-- 
Steve Fryatt - Leeds, England

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

[toc] | [prev] | [next] | [standalone]


#462

FromPaul Sprangers <Paul@sprie.nl>
Date2011-06-20 10:16 +0200
Message-ID<51e6362bf1Paul@sprie.nl>
In reply to#461
In article <mpro.ln283k0nm950g01jm.news@stevefryatt.org.uk>,
   Steve Fryatt <news@stevefryatt.org.uk> wrote:

> > In a Wimp icon with indirected data and a validation string, is there a
> > way to change the address to which these two fields point to, without
> > deleting and recreating the icon?

> No.

And what about changing the Outline font of an icon that has been created
in a Template file?
Is there a way to do this in Basic?

Kind regards,
Paul Sprangers

[toc] | [prev] | [next] | [standalone]


#473

FromMartin Wuerthner <spamtrap@mw-software.com>
Date2011-06-20 23:04 +0200
Message-ID<ec757ce651.martin@bach.planiverse.com>
In reply to#462
In message <51e6362bf1Paul@sprie.nl>
          Paul Sprangers <Paul@sprie.nl> wrote:

> In article <mpro.ln283k0nm950g01jm.news@stevefryatt.org.uk>,
>    Steve Fryatt <news@stevefryatt.org.uk> wrote:

>>> In a Wimp icon with indirected data and a validation string, is there a
>>> way to change the address to which these two fields point to, without
>>> deleting and recreating the icon?

>> No.

> And what about changing the Outline font of an icon that has been created
> in a Template file?
> Is there a way to do this in Basic?

Yes, that is easy. The font handle is stored in the icon flags word, 
so Wimp_SetIconState allows you to change it.

-- 
Martin
---------------------------------------------------------------------
Martin Wuerthner         MW Software      http://www.mw-software.com/
        RISC OS Software for Design, Printing and Publishing
---------------------------------------------------------------------

[toc] | [prev] | [next] | [standalone]


#474

FromPaul Sprangers <Paul@sprie.nl>
Date2011-06-20 23:29 +0200
Message-ID<51e67eb2f7Paul@sprie.nl>
In reply to#473
In article <ec757ce651.martin@bach.planiverse.com>,
   Martin Wuerthner <spamtrap@mw-software.com> wrote:

> > And what about changing the Outline font of an icon that has been
> > created in a Template file? Is there a way to do this in Basic?

> Yes, that is easy. 

Thank you for rubbing the salt into the wound (Dutch expression).


> The font handle is stored in the icon flags word, 
> so Wimp_SetIconState allows you to change it.

As far as I understand the Stronghelp file on this topic, bit 6 of the icon
flags has to be set, after which bit 24-31 contain the fonthandle.
But how should I set those bits if I want to change the original font to,
say, GillSans.Medium?

Kind regards,
Paul Sprangers

[toc] | [prev] | [next] | [standalone]


#475

FromMartin Wuerthner <spamtrap@mw-software.com>
Date2011-06-21 01:20 +0200
Message-ID<addd88e651.martin@bach.planiverse.com>
In reply to#474
In message <51e67eb2f7Paul@sprie.nl>
          Paul Sprangers <Paul@sprie.nl> wrote:

> In article <ec757ce651.martin@bach.planiverse.com>,
>    Martin Wuerthner <spamtrap@mw-software.com> wrote:

>>> And what about changing the Outline font of an icon that has been
>>> created in a Template file? Is there a way to do this in Basic?

>> Yes, that is easy.

> Thank you for rubbing the salt into the wound (Dutch expression).

Surely, that must be good news - I do not suppose you would have 
preferred me telling you that it is very difficult? :-)

>> The font handle is stored in the icon flags word,
>> so Wimp_SetIconState allows you to change it.

> As far as I understand the Stronghelp file on this topic, bit 6 of the icon
> flags has to be set, after which bit 24-31 contain the fonthandle.
> But how should I set those bits if I want to change the original font to,
> say, GillSans.Medium?

You need to set the bits to a font handle, which is a number for a 
font at a particular size that you can get from the FontManager via 
Font_FindFont. Your program needs to keep track of which handles it 
owns and release them before quitting (otherwise they are lost to the 
system and there are not too many available). If there is a screen 
mode change you need to renew the handles.

That sounds like quite a lot of work, but that is just the general 
administration work any program has to do that wants to deal with 
outline fonts. If you use outline fonts in your template file your 
program already has to deal with all of that anyway (except the very 
first Font_FindFont step), otherwise it cannot work correctly, no 
matter whether you want to change the font or not.

-- 
Martin
---------------------------------------------------------------------
Martin Wuerthner         MW Software      http://www.mw-software.com/
        RISC OS Software for Design, Printing and Publishing
---------------------------------------------------------------------

[toc] | [prev] | [next] | [standalone]


#478

FromPaul Sprangers <Paul@sprie.nl>
Date2011-06-21 11:27 +0200
Message-ID<51e6c06fd6Paul@sprie.nl>
In reply to#475
In article <addd88e651.martin@bach.planiverse.com>,
   Martin Wuerthner <spamtrap@mw-software.com> wrote:

> You need to set the bits to a font handle, which is a number for a 
> font at a particular size that you can get from the FontManager via 
> Font_FindFont. [etc.]

Thank you very much. With this explanation, together with the StrongHelp
files, the Dr. Wimp source code, Reporter and a lot of trial and error,
I've now created a routine that  can change fonts in an existing icon
indeed, without freezing the machine. I'm getting closer all the time!

Here's a new one: how can I change a font AS WELL AS its colour in an icon?
I already managed to write a routine that can change foreground and
background colours, but when I call both routines, it will - depending on
the order of the calls - either colour the icon properly but with the
system font set, or it will change the font properly, but always with black
foreground and a white background colour, How can I have both?

Very curious about your reply,
Paul Sprangers

[toc] | [prev] | [next] | [standalone]


#479

FromMartin Wuerthner <spamtrap@mw-software.com>
Date2011-06-21 11:40 +0200
Message-ID<cea8c1e651.martin@bach.planiverse.com>
In reply to#478
In message <51e6c06fd6Paul@sprie.nl>
          Paul Sprangers <Paul@sprie.nl> wrote:

> In article <addd88e651.martin@bach.planiverse.com>,
>    Martin Wuerthner <spamtrap@mw-software.com> wrote:

>> You need to set the bits to a font handle, which is a number for a
>> font at a particular size that you can get from the FontManager via
>> Font_FindFont. [etc.]

> Thank you very much. With this explanation, together with the StrongHelp
> files, the Dr. Wimp source code, Reporter and a lot of trial and error,
> I've now created a routine that  can change fonts in an existing icon
> indeed, without freezing the machine. I'm getting closer all the time!

There are two things you need to check before relasing your program:
1) issue *FontList in a TaskWindow
   run the program, cause it to change font a few times, quit the
   program and do that a few times
   issue *FontList again and the Use counts should be as before
2) change screen mode from a square pixel mode to a rectangular pixel
   mode (one above the divider line in the Display manager, e.g., 1280
   by 480)
   do the fonts still look correct?

> Here's a new one: how can I change a font AS WELL AS its colour in an icon?
> I already managed to write a routine that can change foreground and
> background colours, but when I call both routines, it will - depending on
> the order of the calls - either colour the icon properly but with the
> system font set, or it will change the font properly, but always with black
> foreground and a white background colour, How can I have both?

Changing the colours is different for outline font icons. That should 
not come as a surprise since the outline font handle is stored in the 
very same bits as the foreground and background colours. At a guess, 
your routine just changes these bits, but that only works for system 
font icons (bit 6 clear) and in your case overwrites the font handle. 
For outline font icons, you need to change the font colour values 
stored in the validation string's F command.

-- 
Martin
---------------------------------------------------------------------
Martin Wuerthner         MW Software      http://www.mw-software.com/
        RISC OS Software for Design, Printing and Publishing
---------------------------------------------------------------------

[toc] | [prev] | [next] | [standalone]


#481

FromPaul Sprangers <Paul@sprie.nl>
Date2011-06-21 12:15 +0200
Message-ID<51e6c4d9dePaul@sprie.nl>
In reply to#479
In article <cea8c1e651.martin@bach.planiverse.com>,
   Martin Wuerthner <spamtrap@mw-software.com> wrote:

> There are two things you need to check before relasing your program:
> 1) issue *FontList in a TaskWindow
>    run the program, cause it to change font a few times, quit the
>    program and do that a few times
>    issue *FontList again and the Use counts should be as before

It is!
Apparently, I've done the right thing right away, which is extremely rare.


> 2) change screen mode from a square pixel mode to a rectangular pixel
>    mode (one above the divider line in the Display manager, e.g., 1280
>    by 480)
>    do the fonts still look correct?

Absolutely not, which is not a surprise because the program doesn't react
on mode changes at all. This implies a nice and brand new task for the
Sunday-programmer like me.


> For outline font icons, you need to change the font colour values 
> stored in the validation string's F command.

I see. But how do I do that? Where in the block% that is passed to
SYS"Wimp_SetIconState",,block% do I enter the validation string? As far as
I'm able to understand the StrongHelp file, it doesn't give a clue.

Even more curious about your reply,
Paul Sprangers

[toc] | [prev] | [next] | [standalone]


#482

FromMartin Wuerthner <spamtrap@mw-software.com>
Date2011-06-21 12:41 +0200
Message-ID<8136c7e651.martin@bach.planiverse.com>
In reply to#481
In message <51e6c4d9dePaul@sprie.nl>
          Paul Sprangers <Paul@sprie.nl> wrote:

> In article <cea8c1e651.martin@bach.planiverse.com>,
>    Martin Wuerthner <spamtrap@mw-software.com> wrote:

>> For outline font icons, you need to change the font colour values
>> stored in the validation string's F command.

> I see. But how do I do that? Where in the block% that is passed to
> SYS"Wimp_SetIconState",,block% do I enter the validation string? As far as
> I'm able to understand the StrongHelp file, it doesn't give a clue.

Wimp_SetIconState only changes the icon flags. The validation string 
is held in a buffer in your application's workspace. You can find its 
address via Wimp_GetIconState. You can modify it directly in memory 
(but beware of exceeding its allocated size), then force an icon 
redraw using a dummy Wimp_SetIconState call (passing 0 for EOR/BIC).

The validation string is a very basic Wimp feature. It might make 
sense to first read a book or tutorial. That will allow you to proceed 
more quickly than asking here for every little step. For instance, the 
"Beginner's Guide to WIMP programming" as published in Foundation 
RISCWorld is available online on the APDL site.

-- 
Martin
---------------------------------------------------------------------
Martin Wuerthner         MW Software      http://www.mw-software.com/
        RISC OS Software for Design, Printing and Publishing
---------------------------------------------------------------------

[toc] | [prev] | [next] | [standalone]


#483

FromPaul Sprangers <Paul@sprie.nl>
Date2011-06-21 13:37 +0200
Message-ID<51e6cc5d2aPaul@sprie.nl>
In reply to#482
In article <8136c7e651.martin@bach.planiverse.com>,
   Martin Wuerthner <spamtrap@mw-software.com> wrote:

> It might make sense to first read a book or tutorial. That will allow
> you to proceed more quickly than asking here for every little step.

Touché!
I've may have read Lee Calcrafts and Alan Wrigleys 'Wimp programming for
all' from cover to cover, but that's a long time ago.

The Wimp is simply too complicated for occasional programmers such as me.
The relevant part of the book is now almost chinese to me, especially since
it doesn't give a complete answer to the current problem. Rather than
reading the whole book again, I thought I post my problem to this news
group.

But I agree that recent successes of this route have made me lazy and I'm
now posting such problems too soon, without really having tried my self
first. Right, let me continue stumbling for a while.

Kind regards,
Paul Sprangers

[toc] | [prev] | [next] | [standalone]


#465

FromTheo Markettos <theom+news@chiark.greenend.org.uk>
Date2011-06-20 14:18 +0100
Message-ID<Jay*Ii9Ft@news.chiark.greenend.org.uk>
In reply to#461
Steve Fryatt <news@stevefryatt.org.uk> wrote:
> On 19 Jun, Martin Bazley wrote in message
>     <7a8601e651.martin@blueyonder.co.uk>:
> 
> > In a Wimp icon with indirected data and a validation string, is there a
> > way to change the address to which these two fields point to, without
> > deleting and recreating the icon?
> 
> No.

I'm very rusty, but I think you can in a hacky, nasty way:

Set the icon flags so that it's a non-indirected text icon
Read the 12 byte icon 'text' (which will be the pointers to the indirection
text/sprite data and validation string).
Change them and write them back
Set the icon flags back to being an indirected icon


I can't remember how you change the text in a non-indirected icon, though. 
Is that only possible by re-creating it?

And don't blame me if this falls over on some versions of RISC OS...

Theo

[toc] | [prev] | [next] | [standalone]


#466

Fromcferris@freeRemoveuk.com.invalid
Date2011-06-20 14:55 +0100
Message-ID<c12e55e651.cferris@cferris.freeuk.com>
In reply to#465
In message <Jay*Ii9Ft@news.chiark.greenend.org.uk>
          Theo Markettos <theom+news@chiark.greenend.org.uk> wrote:

> Steve Fryatt <news@stevefryatt.org.uk> wrote:
> > On 19 Jun, Martin Bazley wrote in message
> >     <7a8601e651.martin@blueyonder.co.uk>:
> > 
> > > In a Wimp icon with indirected data and a validation string, is there a
> > > way to change the address to which these two fields point to, without
> > > deleting and recreating the icon?
> > 
> > No.
> 
> I'm very rusty, but I think you can in a hacky, nasty way:
> 
[snip]
> 
> I can't remember how you change the text in a non-indirected icon,
> though.  Is that only possible by re-creating it?
> 

Adding to this - is there a way of reading a Module's version number -
ie the RO fontmanger?

Thanks
-- 
Colin Ferris Cornwall UK

[toc] | [prev] | [next] | [standalone]


#468

FromMartin Bazley <martin.bazley@blueyonder.co.uk>
Date2011-06-20 18:10 +0100
Message-ID<8f0167e651.martin@blueyonder.co.uk>
In reply to#466
The following bytes were arranged on 20 Jun 2011 by cferris@freeRemoveuk.com.invalid:

> Adding to this

"Adding" as in, not relevant at all?

>  - is there a way of reading a Module's version number -
> ie the RO fontmanger?

*RMEnsure

Or, failing that, OS_Module 18.

-- 
  __<^>__
 / _   _ \           It is written that Geeks shall inherit the Earth.
( ( |_| ) )
 \_>   <_/  ======================= Martin Bazley ==========================

[toc] | [prev] | [next] | [standalone]


#469

FromMartin Bazley <martin.bazley@blueyonder.co.uk>
Date2011-06-20 18:13 +0100
Message-ID<925867e651.martin@blueyonder.co.uk>
In reply to#465
The following bytes were arranged on 20 Jun 2011 by Theo Markettos :

> Set the icon flags so that it's a non-indirected text icon

The problem with that is that the only valid way is via
Wimp_SetIconState, which automatically redraws the icon - producing, in
this case, garbage.

And changing it back will cause the icon to flicker during the process.

> I can't remember how you change the text in a non-indirected icon, though.

And I don't think that's possible, either - I've run into that one
before.  All program-updated icons must be indirected, thus implying
that the non-indirected bit - i.e. the data pointer - is read-only, but
the space it points to is not.

-- 
  __<^>__
 / _   _ \         You always find something in the last place you look.
( ( |_| ) )
 \_>   <_/  ======================= Martin Bazley ==========================

[toc] | [prev] | [next] | [standalone]


#467

FromMartin Bazley <martin.bazley@blueyonder.co.uk>
Date2011-06-20 18:18 +0100
Message-ID<80cd67e651.martin@blueyonder.co.uk>
In reply to#461
The following bytes were arranged on 20 Jun 2011 by Steve Fryatt :

> On 19 Jun, Martin Bazley wrote in message
>     <7a8601e651.martin@blueyonder.co.uk>:
>
> > Wimp_SetIconState alters the flags field, and Wimp_ResizeIcon alters the
> > four position fields.  The existence of these two SWIs rather suggests
> > there's no way to alter the icon data fields.
>
> Correct: you can't change them without deleting the icon.

Bollocks.  I rather thought that might happen.

OK, next question: is it safer to delete all icons in a window from the
first upwards or the last downwards, assuming each is recreated
immediately after being deleted and before the next is deleted?  Ideally
I want to avoid the "memory reallocation" the StrongHelp manuals are so
keen to emphasise happens when you delete the highest-numbered icon.

Also, do Wimp_Delete/CreateIcon force icon redraws, like
Wimp_SetIconState?  If so, the entire window will flicker and the
process will take ten times longer.

-- 
  __<^>__   === RISC OS is a work of art.  Some people adore it,  ===
 / _   _ \  === others can't see the point of it, and it's really ===
( ( |_| ) ) === expensive.                                        ===
 \_>   <_/  ======================= Martin Bazley ===================

[toc] | [prev] | [next] | [standalone]


#470

FromAlan Adams <alan@adamshome.org.uk>
Date2011-06-20 19:08 +0100
Message-ID<c15a6ce651.Alan.Adams@laptop.adamshome.org.uk>
In reply to#467
In message <80cd67e651.martin@blueyonder.co.uk>
          Martin Bazley <martin.bazley@blueyonder.co.uk> wrote:

> The following bytes were arranged on 20 Jun 2011 by Steve Fryatt :

>> On 19 Jun, Martin Bazley wrote in message
>>     <7a8601e651.martin@blueyonder.co.uk>:
>>
>>> Wimp_SetIconState alters the flags field, and Wimp_ResizeIcon alters the
>>> four position fields.  The existence of these two SWIs rather suggests
>>> there's no way to alter the icon data fields.
>>
>> Correct: you can't change them without deleting the icon.

> Bollocks.  I rather thought that might happen.

> OK, next question: is it safer to delete all icons in a window from the
> first upwards or the last downwards, assuming each is recreated
> immediately after being deleted and before the next is deleted?  Ideally
> I want to avoid the "memory reallocation" the StrongHelp manuals are so
> keen to emphasise happens when you delete the highest-numbered icon.

Deletng an icon except the last simply sets the deleted bit. It has 
to, else all subsequent icons would change icon number. Recreating it 
then retains the icon number. You could always add a dummy icon at the 
end which you don't delete.

> Also, do Wimp_Delete/CreateIcon force icon redraws, like
> Wimp_SetIconState?  If so, the entire window will flicker and the
> process will take ten times longer.

Don't know, but i don't think so.

-- 
Alan Adams, from Northamptonshire
alan@adamshome.org.uk
http://www.nckc.org.uk/

[toc] | [prev] | [standalone]


Back to top | Article view | comp.sys.acorn.programmer


csiph-web