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

 
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: 2187
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: 6334
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: 2187
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: 6334
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: 6334
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: 6334
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: 2187
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: 2105
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: 2187
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
Display posts from previous:   
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> ClearWin+ All times are GMT + 1 Hour
Page 1 of 1

 
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