Silverfrost Forums

Welcome to our forums

Updating the colour of a coloured bar

19 Nov 2006 4:12 #1286

I have a number of object (MAX) of which the current one is numbered (KUR). Typically, MAX is 3 or 4, and never more than 50. Each object has a different colour with IRED, IGRN and IBLU components. I thought it might be useful to show the colour of the current object as the list was stepped through using a %dd spin control. Here's a fragment of the code. ICOL is set in a separate statement so as to avoid continuations.

  DP=1.0D0
  IA=WINIO@('Object No %il%dd&',1,MAX,1)
  IA=WINIO@('%3`rd%`il&',KUR)
  ICOL=RGB@(IRED(KUR),IGRN(KUR),IBLU(KUR))
  IA=WINIO@('%nl%cn%10br&',DP,ICOL)

I can't seem to get my head round where I call window_update@, and with which parameter, KUR, or ICOL (or DP for that matter, but as I want the bar filled, DP always needs to end up as 1.0D0, and it isn't a convenient entity to alter). I've tried most places in the code! The problem I find is that I can't get the colour of the bar to change, unless I close the window and reopen it, whereupon it is changed. I'd like it to change as I stepped through the list of objects.

I've also tried changing button colours and backgrounds etc to get the colour coding, but I'm missing something in my understanding.

Any suggestions would be gratefully received.

Eddie

20 Nov 2006 12:42 #1289

Eddie

There is currently no way to change the %br colour dynamically. You can only set the colour when the window is created.

If you really want this effect we could add the feature to ClearWin+ but we would charge you for this service or with clever programming you can open a new window with the colour change without the user being aware of this. i.e. you create a copy of the window on top of the old one and then delete the old window.

20 Nov 2006 12:59 #1290

Hi Paul,

The copy & delete is a good idea - thanks - although I may just ditch my original concept, and find a different way of indicating which object is currently selected. It's something of a 'labour of love', and not of any commercial value. Your reply was helpful, because it stops me barking up the wrong tree. I'm always puzzled about what is updated when.

I don't always find the online help useful when it comes to the finer points, such as this, although it is great for getting started.

I noted the time of your reply, and hope that you are working in a different time zone from me!

Regards

Eddie

20 Nov 2006 4:37 #1295

Eddie,

Have you considered using a graphics region (%gr) inplace of %br, as with the appropriate callback you could easily update the graphics with a different colour fill.

Regards, John

20 Nov 2006 2:45 #1306

Hi John,

I had considered it, but hadn't tried it. I had tried callbacks with %br, but as Paul said, the colour can't be 'watched for' as it is set once, and only once, when the window opens. I am still a bit confused about what updates when, and wasn't sure whether it was something I was doing wrong (in which case the graphics region wouldn't work either).

When I get a moment, I'll try it.

You caught me being lazy, again!

Eddie

21 Nov 2006 12:56 #1308

John Horspool's suggestion worked, very nicely. It was necessary to fill the %gr both on startup, and each time the object selector is altered (through the callback). I found that check_on_focus_loss inhibited the update, presumably because focus was never lost. Obvious in retrospect.

I had chosen that my objects were arranged on the screen with No. 1 at the top, and No. 'n' at the bottom, and that I needed to put the %dd parameter to -1 so that when the 'up' spin control was selected, the object number was decremented. This apparently bizarre choice makes the selector work intuitively, so that spinning 'up' or 'down' goes through the objects as laid out on the screen - their 'object number' is actually immaterial.

Thanks to John & Paul for help.

Eddie

Please login to reply.