forums.silverfrost.com Forum Index forums.silverfrost.com
Welcome to the Silverfrost forums
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Dynamic backgrounds, font colors and warning signs
Goto page 1, 2  Next
 
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> ClearWin+
View previous topic :: View next topic  
Author Message
DanRRight



Joined: 10 Mar 2008
Posts: 2813
Location: South Pole, Antarctica

PostPosted: Sat May 16, 2020 6:29 pm    Post subject: Dynamic backgrounds, font colors and warning signs Reply with quote

Paul,

As a reminders to user, or warning that something in the code needs attention i really really miss the features of dynamically changeable color of background of all the major Clearwin functions (called controls) and color of fonts. I use warning by changing fonts and backgrounds as well as add warning signs (including external like handy function POP, thanks to Eddie), but with Clearwin all the warnings you are able to see only after you close the current window and reload it again which is often impossible (like with the main graphics window of the code opening at start and controlling everything) and getting numerous popped warning windows is a bit annoying

I do change backgrounds and color of fonts for example by adding in front of %rd the %`bg%rd with control variable defining the color of future field displaying number of loaded points. If number of points is withing the limit i use white background ibkg_Limit_Violated_Or_Not=rgb@(255,255,255), if the number of points is larger than expected then background is rozy ibkg_Limit_Violated_Or_Not=rgb@(242,168,173)
Code:
i=WINIO@('Number of loaded points %ta%`bg%rd%ff&',
     *  ibkg_Limit_Violated_Or_Not, numbOfPoints)

This way the user can avoid numerous problems when your code GUI becomes very large. Eventually all GUIs starting with few simple lines become really complex, then super complex and at the end totally unmanageable in size and you stop noticing myriads of jumping numbers

Such CWP controls like %rd, %rf, %rb, fonts %fn and warning signs %si! or %si# all require ability to change them dynamically (and respect to warning signs %si - the appearance/disappearance or graying). With years i found that changing displayed background or font color or turn it to italic are very intelligent and gentle ways of reminding user about problems.

We discussed that in the past here, in what state thinking at Silverfrost got us closer to implementation of such capabilities ? Specifically I'd be already 99% happy if just the CALL WINDOW_UPDATE@(ibkg_Limit_Violated_Or_Not) changed the color of appropriate control above.

/* lost last 3 days of very valuable supercomputer time searching for the error in the code but in reality just did not notice that one of displaying data arrays (which was also present right in front of my eyes) was full. One more such victory and I am broke Smile. That is happening again and again in one code or another, in one place or another.
Back to top
View user's profile Send private message
PaulLaidler
Site Admin


Joined: 21 Feb 2005
Posts: 7916
Location: Salford, UK

PostPosted: Sat May 16, 2020 7:30 pm    Post subject: Reply with quote

There are already two functions SET_CONTROL_BACK_COLOUR@ and SET_CONTROL_TEXT_COLOUR@ that may do what you want.
Back to top
View user's profile Send private message AIM Address
DanRRight



Joined: 10 Mar 2008
Posts: 2813
Location: South Pole, Antarctica

PostPosted: Sun May 17, 2020 6:52 am    Post subject: Reply with quote

This is great, many thanks, Paul
Back to top
View user's profile Send private message
PaulLaidler
Site Admin


Joined: 21 Feb 2005
Posts: 7916
Location: Salford, UK

PostPosted: Sun May 17, 2020 9:00 am    Post subject: Reply with quote

One option is to use "smart" limits as illustrated here...

Code:
winapp
program main
integer n,m,iw,winio@
double precision x,y
n = 42
m = 0
x = 42.0d0
y = 0.0d0
iw = winio@("%ca[Smart Limits]&")
iw = winio@("%~il&",1,256)
iw = winio@("%tc[blue]&")
iw = winio@("Input:  %12rd&",n)
iw = winio@("  Result: %`12rd&",n)
iw = winio@("%ff&")
iw = winio@("Input:  %12rd&",m)
iw = winio@("  Result: %`12rd&",m)
iw = winio@("%ff&")
iw = winio@("%~fl&",1d0,256d0)
iw = winio@("Input:  %12rf&",x)
iw = winio@("  Result: %`12rf&",x)
iw = winio@("%ff&")
iw = winio@("Input:  %12rf&",y)
iw = winio@("  Result: %`12rf&",y)
iw = winio@(" ")
end
Back to top
View user's profile Send private message AIM Address
PaulLaidler
Site Admin


Joined: 21 Feb 2005
Posts: 7916
Location: Salford, UK

PostPosted: Sun May 17, 2020 12:09 pm    Post subject: Reply with quote

Here is a sample where toolips are initially switched off but activated when an out-of-range value is input...

Code:
module mymod
  use clrwin
  integer n,ctrl
  integer(7) hWnd
  logical bad
contains
  integer function cb()
    if(n > 256) then
      if(.not. bad) then
        call set_control_text_colour@(hWnd, 255)
        call set_control_back_colour@(hWnd, RGB@(200,200,200))
        ctrl = 1
        call window_update@(ctrl)
        bad = .true.
        call beep@()
      endif
    else 
      if(bad)then
        call set_control_text_colour@(hWnd, 0)
        call set_control_back_colour@(hWnd, RGB@(255,255,255))
        ctrl = 0
        call window_update@(ctrl)
        bad = .false.
      endif 
    endif 
    cb = 2
  end function
end module

winapp
program main
use mymod
integer iw
n = 42
ctrl = 0
bad = .false.
iw = winio@("%ca[Tooltip report]&")
iw = winio@("%th[balloon]&",ctrl)
iw = winio@("Input:  %^?12rd[Bad value]&",n, cb)
iw = winio@("%lc", hWnd)
end

Back to top
View user's profile Send private message AIM Address
PaulLaidler
Site Admin


Joined: 21 Feb 2005
Posts: 7916
Location: Salford, UK

PostPosted: Sun May 17, 2020 4:52 pm    Post subject: Reply with quote

This sample illustrates how a tooltip can be changed...

Code:
module mymod
  use clrwin
  integer n
  integer(7) hWnd
  logical bad
contains
  integer function cb()
    if(n > 256) then
      if(.not. bad) then
        call set_control_text_colour@(hWnd, 255)
        call set_control_back_colour@(hWnd, RGB@(200,200,200))
        call set_tooltip_text@(hWnd, "Bad value");
        bad = .true.
        call beep@()
      endif
    else 
      if(bad)then
        call set_control_text_colour@(hWnd, 0)
        call set_control_back_colour@(hWnd, RGB@(255,255,255))
        call set_tooltip_text@(hWnd, "Good value");
        bad = .false.
      endif 
    endif 
    cb = 2
  end function
end module

winapp
program main
use mymod
integer iw,ctrl
n = 42
bad = .false.
ctrl = 1
iw = winio@("%ca[Tooltip report]&")
iw = winio@("%th[balloon]&",ctrl)
iw = winio@("Input:  %^?12rd[Good value]&",n, cb)
iw = winio@("%lc", hWnd)
end

Back to top
View user's profile Send private message AIM Address
DanRRight



Joined: 10 Mar 2008
Posts: 2813
Location: South Pole, Antarctica

PostPosted: Tue May 19, 2020 2:57 am    Post subject: Reply with quote

And the %~il and %~fl also look very useful, flexible and easy to use. Using %il/%fl for years I somehow missed this handy and in many cases better option with tilde

Last edited by DanRRight on Tue May 19, 2020 3:29 pm; edited 1 time in total
Back to top
View user's profile Send private message
LitusSaxonicum



Joined: 23 Aug 2005
Posts: 2388
Location: Yateley, Hants, UK

PostPosted: Tue May 19, 2020 9:16 am    Post subject: Reply with quote

DAn,

You missed it because it is a fairly recent addition to the (public) version.

Eddie
Back to top
View user's profile Send private message
DanRRight



Joined: 10 Mar 2008
Posts: 2813
Location: South Pole, Antarctica

PostPosted: Wed May 20, 2020 10:09 pm    Post subject: Reply with quote

Thanks Eddie, you have eased a bit my self-blaming Smile
Back to top
View user's profile Send private message
DanRRight



Joined: 10 Mar 2008
Posts: 2813
Location: South Pole, Antarctica

PostPosted: Sun Jul 19, 2020 10:46 pm    Post subject: Reply with quote

Paul,
The way of making warnings using %~fl seems has a problem. If it is the user who changes the input manually then the red warning appears ok. But if it is the computer which changes the value using
call window_update@(x)
for the value of x outside the allowed range in this example, then the warning does not appear. And i was scratching my head all this time why the example above worked but when i placed tilde in the real code it did not... This is very pity as the way of making warnings looks extremely appealing and convenient, just add a tilde and all is done
Back to top
View user's profile Send private message
PaulLaidler
Site Admin


Joined: 21 Feb 2005
Posts: 7916
Location: Salford, UK

PostPosted: Mon Jul 20, 2020 8:46 am    Post subject: Reply with quote

Dan

If the computer sets the value out-of-range then ClearWin+ adjusts the displayed value to be in range and an error icon does not appear because the adjusted value is in range.

At this point the stored value has not been corrected by ClearWin+ and maybe ClearWin+ can be fixed in this respect. But perhaps the computer should not use values that it knows to be out-of-range.

If the user sets the value out-of-range then the icon appears, the incorrect value is displayed whilst the corrected (in range value) is stored.
Back to top
View user's profile Send private message AIM Address
DanRRight



Joined: 10 Mar 2008
Posts: 2813
Location: South Pole, Antarctica

PostPosted: Mon Jul 20, 2020 8:25 pm    Post subject: Reply with quote

Paul,

Then when the computer changes x, the %~fl%rf control behavior is not consistent with the behavior when user sets the values manually. This is why it took me more than a month to figure this out. Last what I expected was such strange anti-intuitive behavior

Logically in both cases (is it manual or computer way of setting x) the window should display x larger than xmax (or smaller than xmin) with red dot like it is doing manually. The red warning dot should be displayed if limit is broken. Otherwise what the tilde is for ? Manual and computer changing of x should have equal priority and the same behavior.

At the end all humans are the same computers just with the software which is called ideology Smile. And i envision that the future robotic society of smart gadgets and other IoT will complain about discrimination against them Smile Smile
Back to top
View user's profile Send private message
PaulLaidler
Site Admin


Joined: 21 Feb 2005
Posts: 7916
Location: Salford, UK

PostPosted: Tue Jul 21, 2020 7:55 am    Post subject: Reply with quote

Dan

I will try to find a way that works all round but for the moment if you set a variable to a value within your code then you should also get your code to test that the value is in range.
Back to top
View user's profile Send private message AIM Address
LitusSaxonicum



Joined: 23 Aug 2005
Posts: 2388
Location: Yateley, Hants, UK

PostPosted: Tue Jul 21, 2020 10:33 am    Post subject: Reply with quote

Paul,

I think that your answer is spot on, for who knows better what the program set the limits to than the programmer?

For those promiscuous programmers who like to fix their values and then forget them (akin to their treatment of partners nudge nudge wink wink), is there a way of asking CW+ what the limits are set to currently? (Via the Cotton-Eye-Joe methodology of 'Where did it come from' etc).

Someone like me will always know, because the answers will lie in a Common Block!

Eddie
Back to top
View user's profile Send private message
PaulLaidler
Site Admin


Joined: 21 Feb 2005
Posts: 7916
Location: Salford, UK

PostPosted: Tue Jul 21, 2020 10:56 am    Post subject: Reply with quote

Eddie

At the moment there is no GET_INTEGER_LIMITS@ corresponding to SET_INTEGER_LIMITS@ but it could be added if you think that it would be useful.
Back to top
View user's profile Send private message AIM Address
Display posts from previous:   
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> ClearWin+ All times are GMT + 1 Hour
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group