|
forums.silverfrost.com Welcome to the Silverfrost forums
|
View previous topic :: View next topic |
Author |
Message |
DanRRight
Joined: 10 Mar 2008 Posts: 2816 Location: South Pole, Antarctica
|
Posted: Mon Jan 21, 2013 10:06 pm Post subject: Ideas for dynamic warning |
|
|
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?
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)
Code: | 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
|
|
|
Back to top |
|
|
IanLambley
Joined: 17 Dec 2006 Posts: 490 Location: Sunderland
|
Posted: Mon Jan 21, 2013 11:23 pm Post subject: |
|
|
What about
set_control_back_colour@
set_control_text_colour@ |
|
Back to top |
|
|
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 7925 Location: Salford, UK
|
Posted: Mon Jan 21, 2013 11:33 pm Post subject: |
|
|
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! |
|
Back to top |
|
|
DanRRight
Joined: 10 Mar 2008 Posts: 2816 Location: South Pole, Antarctica
|
Posted: Mon Jan 21, 2013 11:44 pm Post subject: |
|
|
Thanks, yes, tried it but it does not work, here is the code text. What's wrong, am i missing something ?
Code: | 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
|
|
|
Back to top |
|
|
LitusSaxonicum
Joined: 23 Aug 2005 Posts: 2388 Location: Yateley, Hants, UK
|
Posted: Tue Jan 22, 2013 12:59 am Post subject: |
|
|
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 |
|
Back to top |
|
|
DanRRight
Joined: 10 Mar 2008 Posts: 2816 Location: South Pole, Antarctica
|
Posted: Tue Jan 22, 2013 3:38 am Post subject: |
|
|
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
Code: |
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
Or the Clerarwin windows which look like these little masterpieces
or as nice, simple and inspiring as this window
or this one
or just as simple as this little one where you substitute usual default sliders and buttons with something less boring
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.
Last edited by DanRRight on Tue Jan 22, 2013 9:16 pm; edited 3 times in total |
|
Back to top |
|
|
LitusSaxonicum
Joined: 23 Aug 2005 Posts: 2388 Location: Yateley, Hants, UK
|
Posted: Tue Jan 22, 2013 11:34 am Post subject: |
|
|
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 |
|
Back to top |
|
|
jalih
Joined: 30 Jul 2012 Posts: 196
|
Posted: Tue Jan 22, 2013 2:45 pm Post subject: Re: |
|
|
LitusSaxonicum wrote: | 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:
Code: |
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:
Code: |
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:
Code: |
call draw_image(gr_handle,sprite_handle,mask_handle,&
100,100,SPRITE_WIDTH,SPRITE_HEIGHT)
|
|
|
Back to top |
|
|
LitusSaxonicum
Joined: 23 Aug 2005 Posts: 2388 Location: Yateley, Hants, UK
|
Posted: Tue Jan 22, 2013 2:53 pm Post subject: |
|
|
Jalih,
Now that's exactly what I need to complete my floating/dockable toolbars, with customisable themes!
Eddie |
|
Back to top |
|
|
DanRRight
Joined: 10 Mar 2008 Posts: 2816 Location: South Pole, Antarctica
|
Posted: Tue Jan 22, 2013 9:16 pm Post subject: |
|
|
Thanks for the ideas. |
|
Back to top |
|
|
|
|
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
|