Silverfrost Forums

Welcome to our forums

Ideas for dynamic warning

21 Jan 2013 9:06 #11431

I need to get a warning which pops up and disappears if conditions are met like on this pic, but neither background color change or warning signs allow dynamic changes and require the page reload.

To be more clear, say, if i change first variable to 1 the background color turns to white same time as i type. Or if i change second number to 1 the exclamation mark disappears while i type or reappears again if change this number to something not a 1. Any ideas?

http://img545.imageshack.us/img545/3509/warningl.png

Here is the code for the first variable for easier start (which does not work yet but by the idea the color must be changed when variable=1)

use clrwin
common 	ivar1, icolbkg
integer  cbChng
external cbChng	

ivar1=0
icolbkg = RGB@(255,190,255)

i=winio@('Number %ta%dd%`bg%5^rd%ff&',1,icolbkg,ivar1,cbChng)
i=winio@('%ac[esc]','exit')

end

integer function cbChng()
use clrwin
common 	ivar1, icolbkg
icolbkg = RGB@(255,190,255)
if(ivar1.eq.1) 	icolbkg = RGB@(255,255,255)
call WINDOW_update@(icolbkg)

print*,ivar1
cbChng=1
end function
21 Jan 2013 10:23 #11433

What about set_control_back_colour@ set_control_text_colour@

21 Jan 2013 10:33 #11434

Have you considered using set_control_text_colour@ or set_control_back_colour@?

I did not see Ian's reply which was posted during the 10 minutes that I was looking this up!

21 Jan 2013 10:44 #11435

Thanks, yes, tried it but it does not work, here is the code text. What's wrong, am i missing something ?

use clrwin
common 	ivar1, icolbkg, ihrd
integer  cbChng
external cbChng	

ivar1=0
icolbkg = RGB@(255,190,255)

i=winio@('%ww%fn[Times new Roman]%ts&',2.d0)
i=winio@('Number %ta%dd%`bg%5^rd%lc%ff&',1,icolbkg,ivar1,cbChng,ihrd)
i=winio@('%ac[esc]','exit')

end

integer function cbChng()
use clrwin
common 	ivar1, icolbkg, ihrd
icolbkg = RGB@(255,190,255)
if(ivar1.eq.1) 	icolbkg = RGB@(255,255,255)

call set_control_back_colour@(ihrd,icolbkg)
! call set_control_text_colour@(ihrd,icolbkg)

print*,ivar1, icolbkg, ihrd 
cbChng=1
end function
21 Jan 2013 11:59 #11436

If you include a small %gr area, you can put in it whatever you like. Forget about drawing things using graphics primitives: use IMPORT_IMAGE@. You will need to draw every image, but many of them can be captured from other software using SHIFT-PrtSc. It takes a long time to develop the skill to draw really small icons yourself.

Eddie

22 Jan 2013 2:38 (Edited: 22 Jan 2013 8:16) #11437

I found the source of the problem but have no idea why code behaves this way: it's in %dd. If remove it the code works fine. Paul probably has to look at it, i suspect the bug. Working code is here

use clrwin 
common    ivar1, icolbkg, ihrd 
integer  cbChng 
external cbChng    

ivar1=0 
i=winio@('%ww%fn[Times new Roman]%ts&',2.d0) 
i=winio@('Type number 1 here%ta%5^rd%lc%ff&',ivar1,cbChng,ihrd) 
i=winio@('%ac[esc]','exit') 

end 

integer function cbChng() 
use clrwin 
common    ivar1, icolbkg, ihrd 
icolbkg = RGB@(255,190,255) 
if(ivar1.eq.1)    icolbkg = RGB@(255,255,255) 
 call set_control_back_colour@(ihrd,icolbkg) 
! call set_control_text_colour@(ihrd,icolbkg) 
print*,ivar1, icolbkg, ihrd 
cbChng=1 
end function

Eddie - what we are doing here is completely inside the logic of Clearwin when you expect that you can update anything dynamically.

As to making everything graphical -- that's great. And not just buttons or warnings. Specifically great would be to have templates made in OpenGL where you just supply the data and adjust the view. For example I plan already for a long time to make this template for just usual XY graph which looks simply amazing

http://img542.imageshack.us/img542/1209/xyopengl.png

Or the Clerarwin windows which look like these little masterpieces

http://img811.imageshack.us/img811/4995/gui66.jpg

or as nice, simple and inspiring as this window http://img152.imageshack.us/img152/1894/mcafee.png

or this one

http://img197.imageshack.us/img197/7612/samsunglj.png

or just as simple as this little one where you substitute usual default sliders and buttons with something less boring

http://img233.imageshack.us/img233/2577/gui65.jpg

but pity all that needs a lot of time ... time...I gathered a lot of such examples...everything like that is doable in this compiler. I still hope that many new users will come and start building Visual Clearwin templates and styles library where you just assemble the code from lego blocks by mouse.

22 Jan 2013 10:34 #11438

Hi Dan,

It depends if you like a visual style of programming or to write code. I can't get past the hurdle of ignorance in how to use .NET anyway, plus I have the investment in things done to date, so my response is always to write code.

Suppose that you have (as in your example) an input box. That has a callback function. Somewhere in the callback function, you have a test on the value input. If you have a %gr area with a handle (one of many, I suppose) which is kept in an array of i_gr_Handle values, then

if (test on validity is OK) then iret = selec_graphics_area@ (i_gr_Handle (this_area)) call draw_filled_rectangle@ (with appropriate size and colour) else iret = selec_graphics_area@ (i_gr_Handle (this_area)) call import_image@ (with appropriate image and location) endif

that doesn't seem to me to be too un-Clearwin-ish. (The %gr in which your message pops up need only be 16 pix high and 40 or 50 pix wide, and doesn't include the other controls on the form - it has to be in free space anyway.)

With reference to an earlier post, Paul mentioned that Clearwin was a basic set of controls, and didn't set out to offer every single effect possible in Windows (my wording, not a direct quote). I think that for some things you have to put in the extra effort yourself. I find that I can get any effect I want with predrawn images loaded with import_image@.

My big regret with this approach is that the images cannot have an alpha channel, so must be drawn complete with background.

If you want an error message in another window, you can of course make that window no_caption, no_frame, volatile, tool_window etc.

Eddie

22 Jan 2013 1:45 #11439

Quoted from LitusSaxonicum with import_image@. My big regret with this approach is that the images cannot have an alpha channel, so must be drawn complete with background.

As an alternative, you can use image mask and create an offscreen buffers for image and it's mask.

example:

    integer function sc_func()
      integer :: i

      i = create_graphics_region@(mask_handle,SPRITE_WIDTH,SPRITE_HEIGHT)
      i = create_graphics_region@(sprite_handle,SPRITE_WIDTH,SPRITE_HEIGHT)

      i=select_graphics_object@(mask_handle)
      i=import_image@('mask',0,0)

      i=select_graphics_object@(sprite_handle)
      i=import_image@('sprite',0,0)

      sc_func=1
    end function sc_func

Now you can draw image with transparent background using mask:

  subroutine draw_image(gr_handle, img_handle, mask_handle, x, y, w, h)
    integer,intent(in) :: gr_handle, img_handle, mask_handle
    integer,intent(in) :: x, y, w, h

    i=copy_graphics_region@(gr_handle,x,y,w,h,&
	                        mask_handle,0,0,w,h,SRCAND)

    i=copy_graphics_region@(gr_handle,x,y,w,h,&
                            img_handle,0,0,w,h,SRCPAINT)

  end subroutine draw_image

example usage:

  call draw_image(gr_handle,sprite_handle,mask_handle,&
                  100,100,SPRITE_WIDTH,SPRITE_HEIGHT)
22 Jan 2013 1:53 #11440

Jalih,

Now that's exactly what I need to complete my floating/dockable toolbars, with customisable themes!

Eddie

22 Jan 2013 8:16 #11446

Thanks for the ideas.

Please login to reply.