Silverfrost Forums

Welcome to our forums

Background color of window

23 Jan 2013 12:39 (Edited: 23 Jan 2013 10:08) #11448

Here are two pictures and Fortran code. Upper picture is what the code below makes. How to modify this code to get different background color like on the photoshopped bottom picture?

http://img213.imageshack.us/img213/9180/blackbkg2.jpg

use clrwin 
i=winio@('%1.2ob&')
i=winio@('%ww&') 
i=winio@('Method 1%ta%rb[Auto]%ff&',k1) 
i=winio@('%ac[esc]&','exit') 
i=winio@('%cb&')
i=winio@('Method 2%ta%rb[Auto]%ff&',k2)
i=winio@('%cn%bt[Exit]%ff&')
i=winio@('%cb')y
end 

Post modified code. With that I'd like to try to make this style GUIs with Clearwin :

http://img826.imageshack.us/img826/3306/guiscience.png

23 Jan 2013 5:56 #11449

Take a look at the %bg, %tc and %bc format codes.

23 Jan 2013 2:39 #11451

Try, the example is very simple!

23 Jan 2013 3:10 #11454

Quoted from DanRRight Try, the example is very simple!

Just tested... Got background coloured to blue using: %bg[blue] and text coloured to yellow using: %tc[yellow]. Button background colour changed to red using: %bc[red] and button text colour changed to white using: %bu[white].

Unfortunately, I could not get the box border colour changed from black to yellow...

23 Jan 2013 6:02 (Edited: 29 Mar 2013 11:41) #11455

Yes this is what i got too. Hope Paul may comment how to change ob/cb color or even the color inside ob/cb and completely ideally how to put image inside ob/cb same or separate from the image which can make background of the window. The code and image of what maximum could be achieved is here

use clrwin 
i=winio@('%tc&',rgb@(210,227,220))
i=winio@('%bg&',rgb@(11,18,79))
i=winio@('%1.2ob&')
i=winio@('%ww&') 
i=winio@('Method 1%ta%rb[Auto]%ff&',k1) 
i=winio@('%ac[esc]&','exit') 
i=winio@('%cb&')
i=winio@('Method 2%ta%rb[Auto]%ff&',k2)
i=winio@('%cn%bc%bu[white]%bt[Exit]%ff&',rgb@(104,23,9))
i=winio@('%cb')
end 

http://img20.imageshack.us/img20/7096/blackbox1.jpg

You will agree that sometimes dark colors look better. Here is what i got just in 30 min versus a bit boring and much less informative older version shown for comparison. This is why i hope some day there will be styles and templates library where you just chose the template and its style and place your code and pictures into the sockets

http://img21.imageshack.us/img21/6875/raylv.jpg

http://img839.imageshack.us/img839/7295/raylold.jpg

23 Jan 2013 8:03 #11459

The following provides a green background for the box. You can use %wp to provide a bitmap background for everything but controls drawn on top are not normally transparent.

use clrwin 
i=winio@('%ww&') 
i=winio@('%ac[esc]&','exit') 
i=winio@('%tc&',rgb@(210,227,220)) 
i=winio@('%bg&',rgb@(11,18,79)) 
i=winio@('%`bg&',rgb@(0,100,0)) 
i=winio@('%1.2ob&') 
i=winio@('Method 1%ta%rb[Auto]%ff&',k1) 
i=winio@('%cb&') 
i=winio@('Method 2%ta%rb[Auto]%ff&',k2) 
i=winio@('%cn%bc%bu[white]%bt[Exit]%ff&',rgb@(104,23,9)) 
i=winio@('%cb') 
end
23 Jan 2013 8:44 #11461

Yes, it's also useful trick.

But is there possibility to make just the %ob/cb border of different color what we've tried to achieve?

Also less important but good to ask - if we put the texture with %wp it only changes background around ob/cb box while adding different texture with %wp inside the box does not change its background - see the same example with these %wp (one can make the whole area inside and outside %ob/cb box with the same texture adding i=winio@('%sy[3d_raised]&') though)

use clrwin 
 i=winio@('%ww&') 
 i=winio@('%ac[esc]&','exit') 
 i=winio@('%tc&',rgb@(210,227,220)) 
 i=winio@('%bg&',rgb@(11,18,79)) 
 i=winio@('%wp[bkgray05]&')
 i=winio@('%1.2ob&') 

 i=winio@('%wp[bkgray06]&')  !  <---- NO EFFECT INSIDE

 i=winio@('Method 1%ta%rb[Auto]%ff&',k1) 
 i=winio@('%cb&') 
 i=winio@('Method 2%ta%rb[Auto]%ff&',k2) 
 i=winio@('%cn%bc%bu[white]%bt[Exit]%ff&',rgb@(104,23,9)) 
 i=winio@('%cb') 
 end
resources
bkgray05  BITMAP bkgray05.bmp

bkgray06 BITMAP bkgray06.bmp[/code]

http://img822.imageshack.us/img822/1108/wpbitmap.jpg

23 Jan 2013 10:30 #11465

Dan,

If you change the Windows theme, then all the styling changes with it. Clearwin only offers a small set of changes relative to the current windows defaults.

You could use a bitmap background which included all the boxes drawn however you want them, then make the %ob - %cb arrangements in your Clearwin code [invisible].

Eddie

23 Jan 2013 10:33 #11466

The box for %ob is drawn directly by ClearWin+ so I guess it would be possible to allow users to select the colour but it seems that you cannot do this at the moment.

Perhaps %ob[line_colour] should be added to ClearWin+ in order to ask for an rgb argument after the optional box title.

24 Jan 2013 5:11 (Edited: 24 Jan 2013 6:57) #11468

Paul - that would be great.

Eddie - i mostly use texture backgrounds and very rarely anything is plotted on them. Graphical GUIs where everything is on %gr or %og window are the next level of complexity (require mostly artistic design, like here below). Do you have something eye-catching? Please post, will be glad to learn, even small thing counts (remember Motorola RAZR? The only new in this dumbphone was its fresh pinky color getting it out of gray crowd and it took States like a hurricane)!

http://img849.imageshack.us/img849/7743/gui6.jpg

24 Jan 2013 6:48 #11473

The box for %ob is drawn directly by ClearWin+

By the way if this is in complete control can the analog of 'no-slide, no-down, no-right' %nd and %nr specifically for %ob be created too? Overall, the %ob is implemented surprisingly good but the look is completely ruined when you resize the window and all controls stay still but the %ob moves over them

24 Jan 2013 8:39 #11474

I guess so but it always helps if sample code is supplied.

25 Jan 2013 12:12 #11477

Here is animated gif

http://i46.tinypic.com/2njwz91.gif

25 Jan 2013 8:00 #11484

Thanks but the text of a short working program would be preferred.

27 Jan 2013 9:37 (Edited: 29 Mar 2013 9:23) #11494

Here is one, when you resize the window you see this effect. Please take some bitmap as a texture for example this one (to emphasize one more time the under-text background issue). Ignore large callback functions, they are shown just for fun

The common sense tells that %ob/cb by its purpose should not slide if controls it is wrapping around do not slide. Or if everything slides when resizing then %ob/cb should follow controls like programmer intended and not run over controls independently. If we wrote %cb after some control

i=winio@('%bt[Exit]&') i=winio@('%cb')

then this %cb defines the bottom line where %ob/cb can go when sliding. That's very annoying and obvious defect of otherwise very useful %ob/cb

http://img210.imageshack.us/img210/8776/moon0.png

integer  cbMouse, cbRun
external cbMouse, cbRun
real*8 Time_1, Time_2, Time_3 

 Time_1=1; Time_2=2; Time_3=3 
 ix=400; iy =300 
 ia=1;ib=0;ic=0;id=0 

 i=winio@('%ww[no_border,casts_shadow]&')    
 i=winio@('%sy[3d_raised]&') 
 I=WINIO@('%wp[moon0]&') 
 i=winio@('%mn[&File[E&xit]]&','EXIT') 
 i=winio@('%ac[esc]&','EXIT') 

 i=winio@('%nr%nd&') 
 i=winio@('%1.3ob&') 
 i=winio@('%rb[1]%rb[2]%rb[3]%rb[4]%ff&', ia,ib,ic,id) 
 i=winio@('%cb&') 

 i=winio@('Time_1, s %ta%`bg[white]%10rf%ff&', Time_1) 
 i=winio@('%cb&') 

 i=WINIO@('%cn%^tt[&Run]%ff&', cbRun) 

 i=winio@('Time_2, cm %ta%`bg[white]%10rf%ff&',Time_2) 
 i=winio@('%cb &') 
 i=winio@('%ob&') 

 i=winio@('%pv%`^gr[full_mouse_input,box_selection,user_resize,rgb_colours,black]&',ix, iy, ihw, cbMouse) 
 i=winio@('%cb') 

END

integer function cbMouse()
use clrwin
character*20 text20
real*8 FontSize1
common iwin_width_, iwin_DEPTH_

text20 = 'ClearWin+'
FontSize1 = 14

LL = len_trim(text20)
call get_graphical_resolution@(iwin_width_, iwin_DEPTH_ )
call clear_screen@()

111 call SELECT_FONT@('Courier New')
    call scale_font@(FontSize1)
    call BOLD_FONT@( 1 )

    call get_text_size@ (text20(1:ll), i_leng, ifontHight)

    if(i_leng.gt.iwin_width_)then
    FontSize1=FontSize1-0.1
    if(FontSize1.le.0.1) goto 100
    goto 111
    endif
    if(ifontHight.gt.iwin_DEPTH_)then
    FontSize1=FontSize1-0.1
    if(FontSize1.le.0.1) goto 100
    goto 111
    endif

100 iPosX = (iwin_width_ - i_leng)/2 
    if(iPosX.lt.0) iPosX = 0

    iPosY = (iwin_DEPTH_ + ifontHight)/2  
    if(iPosY.lt.0) iPosY = 0
  
    icolorSh  = rgb@(255,255,255)
    ix0 = iPosX+1 
    iy0 = iPosY+1  
    call draw_text@ (text20(1:LL), ix0, iy0, icolorSh)

    icolorSh  = rgb@(255,55,55)
    ix0 = iPosX   
    iy0 = iPosY   

    call draw_text@ (text20(1:LL), ix0, iy0, icolorSh)
cbMouse=1
end

integer function cbRun()
use clrwin	
common iwin_width_, iwin_DEPTH_
call draw_text@('Good job,',20,iwin_DEPTH_/3, rgb@(255,55,55))
cbRun=1
end

resources
moon0  BITMAP moon0.bmp
27 Mar 2013 5:18 #11897

I have now added a new option %ob[line_colour] to provide the rgb colour for simple boxes (not panelled etc). Don't get excited because the effect is not that brilliant.

The rgb colour is to be provided as an argument to winio@, after any string argument for a name to the box.

I uploaded a beta version of salflibc.dll to http://www.silverfrost.com/beta/salflibc.exe

This is a self-extracting archive and this DLL supersedes the latest release.

29 Mar 2013 3:14 (Edited: 31 Mar 2013 12:16) #11909

Works. Thanks! I understand it is much harder to make this to plot shadowed lines this option creates i=winio@('%sy[3d_raised]&') because shadows could be darker or lighter then the main line depending on what color scheme user wants...But that's for future

More urgent are two options no_down/no_right to prevent %ob from sliding when user resizes window otherwise %ob can not be used at all or only used with the 'invisible' option which is almost as no use! This is very clearly emphasized in the above code if remove the line

i=winio@('%sy[3d_raised]&')

and change the %1.3ob to

i=winio@('%1.3ob[line_colour]&',rgb@(255,1,1) )

UPDATE You are probably still working on this but just in case i will note about one small fault. I've got the case when %ob behaves without mentioned above sliding over controls but shows another problem: when you open several stacked %ob (like two for example with %1.2ob) and inside one of them open resizable with %pv graphics or Simpleplot window then one part of %ob is resizing (increases and decreases like it should) and another remains of the same size

   use clrwin
  parameter(n=15)
  real*8 x(n),y(n)
  integer wid, heig

  do i=1,n
    x(i)=i-1
    y(i)=sin(3.*i/n)**2
  enddo

  wid =400
  heig=250

 i=winio@('%ww%ca[plot]&')
 i=winio@('%1.2ob&')
 i=winio@('%pv%pl[x_array]&', wid, heig, N, x, y)
 i=winio@('%cb&')
 i=winio@('%gr[rgb_colours,red]%ff&', wid, heig)
 i=winio@('%cn%bt[OK]&')
 i=winio@('%cb')
   end		
Please login to reply.