 |
forums.silverfrost.com Welcome to the Silverfrost forums
|
View previous topic :: View next topic |
Author |
Message |
rudnei
Joined: 29 Dec 2011 Posts: 36
|
Posted: Tue Mar 27, 2018 11:45 pm Post subject: Resizing different %gr areas in the same window |
|
|
Hi,
I am experiencing a problem with my application; I am using a single window (%ww) with three different %gr areas in the window,
rslt=winio@('%ww%ca[FLUXOVIZ]&')
rslt=winio@('%1.2ob[raised]&')
rslt=winio@('%cn%ws%nl&','Painel de Controle')
rslt=winio@('%`^gr[black,rgb_colours]&',painel%xmax-painel%xmin+1,painel%ymax-painel%ymin+1,&
id_painel_de_situacao,painel_de_situacao)
rslt=winio@('%cb&')
rslt=winio@('%`gr[white,rgb_colours]&', &
barra_cores%xmax-barra_cores%xmin+1,barra_cores%ymax-barra_cores%ymin+1,&
id_barra_cores)
rslt=winio@('%cb&')
rslt=winio@('%ob[no_border]&')
rslt=winio@('%`^gr[black,rgb_colours,full_mouse_input,box_selection]&', &
tela%xmax-tela%xmin+1,tela%ymax-tela%ymin+1,&
id_tela,trata_mouse)
rslt=winio@('%cb&')
rslt=winio@('%lw',janela_principal)
and would like to resize the one highlighted above, but if a use a %pv and the option user_resize, when I resize the window, the other two graphics areas move out of place...
I prefer to use three graphics areas since I can keep coordinates which are unique to each and can just select the desired graphics region...
Cheers
Rudnei |
|
Back to top |
|
 |
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 8210 Location: Salford, UK
|
Posted: Wed Mar 28, 2018 8:07 am Post subject: |
|
|
rudnei
I suggest that you post a simple and complete program that illustrates what you want to do. Then others can try out different strategies.
The best answer might be to do the resizing via the new design mode (which I plan to demonstrate on Youtube shortly). This provides an alternative resizing method that might do what you want.
p.s. "shortly" = about two weeks. |
|
Back to top |
|
 |
LitusSaxonicum
Joined: 23 Aug 2005 Posts: 2402 Location: Yateley, Hants, UK
|
Posted: Wed Mar 28, 2018 4:18 pm Post subject: |
|
|
If you have 3 %gr areas, then you have separate coordinate systems for each, and a different callback for each, but it is much easier to keep it all in one %gr, and simply work out which one you are ina at any time. For example, if you have 3 pseudo %gr field all top aligned, your callback only has to test for the x coordinate (and so on).
Doing things in one %gr also makes the division bars movable independently, for example with 2 areas top aligned and one below them taking the full width, then you can test the pixel position and if you are in the horizontal bar you can change the cursor to arrange resizing vertically, or do the same with the vertical bar.If nice cursors aren't already in Windows/Clearwin+, there are plenty downloadable on the web. I sometimes use the 'smooth' cursors by Vlastimil Miler - they're excellent.
Eddie |
|
Back to top |
|
 |
rudnei
Joined: 29 Dec 2011 Posts: 36
|
Posted: Tue Apr 10, 2018 9:14 pm Post subject: |
|
|
Hi,
Following Paul's request, here is an example based on the same structure my actual program is as of now:
Code: |
module defs
type vet2
real :: x,y
end type vet2
type rgb
integer :: r,g,b
end type rgb
type viewport
integer :: xmin,xmax,ymin,ymax
end type viewport
integer :: rslt,main_window,id_control_panel=1,id_rainbow=2,id_graphics=3
integer :: resolution
type(viewport) :: window_control_panel,window_rainbow,window_graphics,window_graphics_initial
end module defs
winapp
program test_windows
use defs
implicit none
include <windows.ins>
! external functions
integer, external :: mouse_control
! Viewport definitions
resolution=int(0.6*min(clearwin_info@('SCREEN_WIDTH'),clearwin_info@('SCREEN_DEPTH')))
window_control_panel=viewport(0,149,0,resolution/2)
window_rainbow=viewport(0,149,0,resolution/2)
window_graphics_initial=viewport(0,resolution-1,0,resolution-1)
window_graphics=window_graphics_initial
! GUI
rslt=winio@('%ww%ca[TEST]&')
rslt=winio@('%1.2ob[raised]&')
rslt=winio@('%cn%ws%nl&','Control Panel')
rslt=winio@('%`gr[white,rgb_colours]&',&
window_control_panel%xmax-window_control_panel%xmin+1,&
window_control_panel%ymax-window_control_panel%ymin+1,&
id_control_panel)
rslt=winio@('%cb&')
rslt=winio@('%`gr[blue,rgb_colours]&',&
window_rainbow%xmax-window_rainbow%xmin+1,&
window_rainbow%ymax-window_rainbow%ymin+1,&
id_rainbow)
rslt=winio@('%cb&')
rslt=winio@('%ob[no_border]&')
rslt=winio@('%pv%`^gr[black,rgb_colours,full_mouse_input,box_selection,user_resize]&',&
window_graphics%xmax-window_graphics%xmin+1,&
window_graphics%ymax-window_graphics%ymin+1,&
id_graphics,mouse_control)
rslt=winio@('%cb&')
rslt=winio@('%lw',main_window)
call use_approximate_colours@(0)
! show control panel
call erase_window(id_control_panel,window_control_panel)
call control_panel()
! draw rainbow
call erase_window(id_rainbow,window_rainbow)
call draw_rainbow()
! draw circles
call erase_window(id_graphics,window_graphics)
call draw_rgb_circles()
end program test_windows
| [/code] |
|
Back to top |
|
 |
rudnei
Joined: 29 Dec 2011 Posts: 36
|
Posted: Tue Apr 10, 2018 9:19 pm Post subject: |
|
|
And here is part 2 of the code:
Code: |
subroutine control_panel()
use defs
implicit none
include <windows.ins>
integer, parameter :: items=15
integer :: i
character(len=80),dimension(items) :: buffer
rslt=select_graphics_object@(id_control_panel)
write(buffer(1),'(A21)')'window_control_panel:'
write(buffer(2),'(A5,I3)')'xmin=',window_control_panel%xmin
write(buffer(3),'(A5,I3)')'xmax=',window_control_panel%xmax
write(buffer(4),'(A5,I3)')'ymin=',window_control_panel%ymin
write(buffer(5),'(A5,I3)')'ymax=',window_control_panel%ymax
write(buffer(6),'(A15)')'window_rainbow:'
write(buffer(7),'(A5,I3)')'xmin=',window_rainbow%xmin
write(buffer(8),'(A5,I3)')'xmax=',window_rainbow%xmax
write(buffer(9),'(A5,I3)')'ymin=',window_rainbow%ymin
write(buffer(10),'(A5,I3)')'ymax=',window_rainbow%ymax
write(buffer(11),'(A16)')'window_graphics:'
write(buffer(12),'(A5,I3)')'xmin=',window_graphics%xmin
write(buffer(13),'(A5,I3)')'xmax=',window_graphics%xmax
write(buffer(14),'(A5,I3)')'ymin=',window_graphics%ymin
write(buffer(15),'(A5,I3)')'ymax=',window_graphics%ymax
do i=1,items
call draw_characters@(buffer(i),2,(i-1)*10+2,rgb@(0,255,0))
end do
call perform_graphics_update@()
end subroutine control_panel
subroutine draw_rainbow()
use defs
implicit none
include <windows.ins>
type(rgb),dimension(7)::rainbow_colors
integer :: l,w,i,y
rslt=select_graphics_object@(id_rainbow)
rainbow_colors(1)=rgb(148,0,211)
rainbow_colors(2)=rgb(75,0,130)
rainbow_colors(3)=rgb(0,0,255)
rainbow_colors(4)=rgb(0,255,0)
rainbow_colors(5)=rgb(255,255,0)
rainbow_colors(6)=rgb(255,127,0)
rainbow_colors(7)=rgb(255,0,0)
l=real(window_rainbow%xmax-window_rainbow%xmin)/3
w=real(window_rainbow%ymax-window_rainbow%ymin)/8
y=ishft(w,-1)
do i=1,7
call draw_filled_rectangle@(l,y,window_rainbow%xmax-l,y+w,&
rgb@(rainbow_colors(i)%r,rainbow_colors(i)%g,rainbow_colors(i)%b))
y=y+w
end do
call perform_graphics_update@()
end subroutine draw_rainbow
|
|
|
Back to top |
|
 |
rudnei
Joined: 29 Dec 2011 Posts: 36
|
Posted: Tue Apr 10, 2018 9:20 pm Post subject: |
|
|
and part 3...
Code: |
integer function mouse_control()
use defs
implicit none
include <windows.ins>
type(viewport) :: selection,window
type(vet2), save :: p0,p1
integer :: mouse_flags
logical, save :: lbutton_up,lbutton_down=.FALSE., &
rbutton_up,rbutton_down=.FALSE.
external :: erase_window
! seleciona �rea gr�fica
rslt=select_graphics_object@(id_graphics)
! hack para testar redesenho ao aumentar/diminuir window
if (clearwin_info@('GRAPHICS_RESIZING')==1) then
call erase_window(id_control_panel,window_control_panel)
call erase_window(id_graphics,window_graphics)
resolution=int(0.8*min(clearwin_info@('SCREEN_WIDTH'),clearwin_info@('SCREEN_DEPTH')))
window_control_panel=viewport(0,99,0,resolution/2)
window_rainbow=viewport(0,99,0,resolution/2)
window_graphics=viewport(0,resolution-1,0,resolution-1)
call control_panel()
call draw_rgb_circles()
else
! extrai os bits de controle do mouse
mouse_flags=clearwin_info@('GRAPHICS_MOUSE_FLAGS')
! trata bot�o esquerdo do mouse
lbutton_up=iand(mouse_flags,MK_LBUTTON)==0
if (lbutton_up.and.lbutton_down) then
! extrai coordenadas da �rea selecionada no SRD
call get_graphics_selected_area@(selection%xmin,selection%ymin,selection%xmax,selection%ymax)
if (selection%xmin>selection%xmax) then
call swap(selection%xmin,selection%xmax)
end if
if (selection%ymin>selection%ymax) then
call swap(selection%ymin,selection%ymax)
end if
! Zoom-in
if ((abs(selection%xmax-selection%xmin)>0).and.(abs(selection%ymax-selection%ymin)>0)) then
call set_graphics_selection@(0)
call erase_window(id_graphics,window_graphics)
resolution=int(0.8*min(selection%xmax-selection%xmin,selection%ymax-selection%ymin))
window_graphics=viewport(0,resolution-1,0,resolution-1)
call draw_rgb_circles()
! habilita sele��o
call set_graphics_selection@(1)
end if
end if
lbutton_down=.not. lbutton_up
! trata bot�o direito do mouse
rbutton_up=iand(mouse_flags,MK_RBUTTON)==0
if (rbutton_up.and.rbutton_down) then
call erase_window(id_graphics,window_graphics)
window_graphics=window_graphics_initial
call erase_window(id_graphics,window_graphics)
call draw_rgb_circles()
end if
rbutton_down=.not. rbutton_up
end if
mouse_control=1
end function mouse_control
|
|
|
Back to top |
|
 |
rudnei
Joined: 29 Dec 2011 Posts: 36
|
Posted: Tue Apr 10, 2018 9:21 pm Post subject: |
|
|
and part 4...
Code: |
subroutine draw_rgb_circles()
use defs
implicit none
include <windows.ins>
type(vet2) :: centre
integer :: radius
rslt=select_graphics_object@(id_graphics)
centre=vet2(0.5*(window_graphics%xmax-window_graphics%xmin),0.5*(window_graphics%ymax-window_graphics%ymin))
radius=0.25*min(window_graphics%xmax-window_graphics%xmin,window_graphics%ymax-window_graphics%ymin)
call draw_filled_ellipse@(int(centre%x),int(centre%y-radius),radius,radius,rgb@(255,0,0))
call draw_filled_ellipse@(int(centre%x-radius),int(centre%y+radius),radius,radius,rgb@(0,255,0))
call draw_filled_ellipse@(int(centre%x+radius),int(centre%y+radius),radius,radius,rgb@(0,0,255))
call perform_graphics_update@()
end subroutine draw_rgb_circles
subroutine erase_window(id,w)
use defs
implicit none
include <windows.ins>
integer,intent(in) :: id
type(viewport),intent(in) :: w
rslt=select_graphics_object@(id)
call draw_filled_rectangle@(w%xmin,w%ymin,w%xmax,w%ymax,rgb@(0,0,0))
call perform_graphics_update@()
end subroutine erase_window
subroutine swap(a,b)
implicit none
integer, intent(inout) :: a,b
integer :: c
c=a; a=b; b=c
end subroutine swap
|
|
|
Back to top |
|
 |
rudnei
Joined: 29 Dec 2011 Posts: 36
|
Posted: Wed Apr 11, 2018 10:53 pm Post subject: |
|
|
Dear John,
Thanks for your reply. Indeed this sample have some side-effects from trimming the actual code, as you have pointed out; item 1 specifically I have no idea at all since the only control I have is via the event GRAPHICS_RESIZING...
But the main thing is: how do I create this MDI? I don't have Visual Studio available... can I do it directly with ClearWin+ ?
Cheers
Rudnei |
|
Back to top |
|
 |
rudnei
Joined: 29 Dec 2011 Posts: 36
|
Posted: Sun Apr 15, 2018 1:11 am Post subject: |
|
|
Dear John,
I have been looking into the last code provided in the topic you mentioned.
Looks like it will do the trick; I'll try with my application and get back to you.
Cheers!
Rudnei |
|
Back to top |
|
 |
rudnei
Joined: 29 Dec 2011 Posts: 36
|
Posted: Mon Apr 16, 2018 12:03 am Post subject: |
|
|
Hi John,
I have modified the code supplied in the aforementioned topic; however, the window captioned "Simulation" is not resizable... any ideas on how to do it?
Cheers
Rudnei
winapp
program test_mdi1
implicit none
include <windows.ins>
integer :: i1,i2,i3,i4,rslt,main_window,&
control_panel=1,display_bar=2,simulation=3
i1=winio@('%ca[Main Window containing an MDI frame]&')
i1=winio@('%ww[no_frame,not_fixed_size]&')
i1=winio@('%pv%fr&',1800,1000)
i1=winio@('%lw',main_window)
i2=winio@('%ww[no_frame]%ca[Control Panel]%`gr[black,rgb_colours,metafile_resize,smooth8]&', &
200,200,control_panel)
i2=winio@('%aw',main_window)
i3=winio@('%ww[no_frame]%ca[Display Bar]%`gr[white,rgb_colours,metafile_resize,smooth8]&', &
100,400,display_bar)
i3=winio@('%aw',main_window)
i4=winio@('%ww[no_frame,not_fixed_size]%ca[Simulation]%`gr[black,rgb_colours,metafile_resize,smooth8]&', &
800,800,simulation)
i4=winio@('%aw',main_window)
! Desenha no painel de controle
rslt=select_graphics_object@(control_panel)
call draw_filled_ellipse@(100,100,80,80,rgb@(127,59,30))
! Desenha na barra de cores
rslt=select_graphics_object@(display_bar)
call draw_filled_rectangle@(2,2,398,398,rgb@(255,255,30))
! Desenha na �rea de simula��o
rslt=select_graphics_object@(simulation)
call draw_filled_rectangle@(10,10,200,200,rgb@(30,255,30))
call draw_filled_rectangle@(100,50,120,60,rgb@(255,0,30))
call draw_filled_rectangle@(400,400,600,5000,rgb@(30,0,255))
end program test_mdi1 |
|
Back to top |
|
 |
DanRRight
Joined: 10 Mar 2008 Posts: 2923 Location: South Pole, Antarctica
|
Posted: Mon Apr 16, 2018 8:12 am Post subject: |
|
|
I hear in my Antarctica how you guys are swearing trying to tame this wild horse called Clearwin. Even i did when tried to fix, did you hear my french? Company must make 100000 demo examples, not 10-15 like all these 20 years. Here are all 4 windows resizable (added text window), "rgb_colours" are now redundant, %es (Escape key) makes debug easier. Used iTextUnit=2 may work only for version 8.30, before it was =0
Code: | winapp
program test_mdi1
implicit none
include <windows.ins>
integer :: i1,i2,i3,i4, ixF, iyF, rslt, main_window, control_panel, display_bar, simulation
integer iT, iTextUnit
integer, external :: empty
ixF=1100
iyF=1000
iTextUnit=2 ! was 0 before version 8.30
i1=winio@('%ww[no_border]%es&')
i1=winio@('%ca[Main Window containing an MDI frame]&')
i1=winio@('%pv%fr%lw',ixF,iyF, main_window)
iT=winio@('%aw%ww[no_border]%ca[Text Window]%pv%40.8cw', &
main_window, iTextUnit )
i2=winio@('%aw%ww[no_border]%ca[Control Panel]%pv%`^gr[black,user_resize]', &
main_window, 300,200,control_panel, empty )
i3=winio@('%aw%ww[no_border]%ca[Display Bar]%pv%`^gr[white,rgb_colours,user_resize]', &
main_window, 500,400, display_bar, empty )
!i3=winio@('%aw&',main_window)
!i3=winio@('%ww[no_frame]%ca[Display Bar]%pv%`gr[white,metafile_resize]', &
!200,400,display_bar)
i4=winio@('%aw%ww[no_border]%ca[Simulation]%pv%`^gr[black,user_resize]', &
main_window, 800,800, simulation, empty )
! Desenha no painel de controle
rslt=select_graphics_object@(control_panel)
call draw_filled_ellipse@(100,100,80,80,rgb@(127,59,30))
! Desenha na barra de cores
rslt=select_graphics_object@(display_bar)
call draw_filled_rectangle@(2,2,398,398,rgb@(255,255,30))
! Desenha na �rea de simula��o
rslt=select_graphics_object@(simulation)
call draw_filled_rectangle@(10,10,200,200,rgb@(30,255,30))
call draw_filled_rectangle@(100,50,120,60,rgb@(255,0,30))
call draw_filled_rectangle@(400,400,600,5000,rgb@(30,0,255))
!... Text window
Print*, 'This is Text window'
end program test_mdi1
!....................................
integer function empty ()
empty=2
end function |
|
|
Back to top |
|
 |
rudnei
Joined: 29 Dec 2011 Posts: 36
|
Posted: Mon Apr 16, 2018 7:03 pm Post subject: |
|
|
Thanks for your help! |
|
Back to top |
|
 |
DanRRight
Joined: 10 Mar 2008 Posts: 2923 Location: South Pole, Antarctica
|
Posted: Mon Apr 16, 2018 11:22 pm Post subject: |
|
|
Noticed that while I made windows resizable the first two windows' surprisingly lost the ability to plot (display_bar and control_panel)? This may take some more swearing to find why. |
|
Back to top |
|
 |
DanRRight
Joined: 10 Mar 2008 Posts: 2923 Location: South Pole, Antarctica
|
Posted: Thu Apr 19, 2018 1:55 pm Post subject: |
|
|
Hell knows, way to many options to try. Needs more swearing time. This is why i use word 'devilry' too often. |
|
Back to top |
|
 |
DanRRight
Joined: 10 Mar 2008 Posts: 2923 Location: South Pole, Antarctica
|
Posted: Sat Apr 21, 2018 11:27 am Post subject: |
|
|
I took your contribution and now it plots on each screen but still does not work right.
Why handle for each of 3 graphics windows are all the same is a good question. Due to that every time we click on any window the plotting goes to the last screen instead the current one
Here is what i changes in your code:
1) each callback calls select_graphics_object@ function before doing any drawings. And
2) the callback does have value 2 not zero at the end, this is default for Clearwin+ . Zero might be used if you want to close window on any click on it
3) i removed "implicit none" as it made me nuts and swear louder very quickly asking to declare each and every damn junk variable i introduce like i44 in each and every subroutine. Or requiring to declare each variable in common blocks in all these Functions. To avoid that requires using modules but modules have another bad property: when your code will grow one big module will eventually swallow all others making one huge monopoly which has nothing more but die
We may continue to swear...err...try some more permutations before asking Paul to comment, i have couple other demos which actually worked pretty well switching graphics windows.
Code: | winapp
program test_mdi1
include <windows.ins>
integer :: i1,i2,i3,i4, ixF, iyF, rslt, ihgw_main_window, ihgw_control_panel, ihgw_display_bar, ihgw_simulation
integer iT, iTextUnit
integer, external :: draw_control_panel, draw_display_bar, draw_simulation
common /GR_areas_ids/ihgw_main_window, ihgw_control_panel, ihgw_display_bar, ihgw_simulation
ixF=1100
iyF=1000
iTextUnit=2 ! was 0 before version 8.30
i1=winio@('%ww[no_border]%es&')
i1=winio@('%ca[Main Window containing an MDI frame]&')
i1=winio@('%pv%fr%lw',ixF,iyF, ihgw_main_window)
iT=winio@('%aw%ww[no_border]%ca[Text Window]%pv%40.8cw', &
ihgw_main_window, iTextUnit )
i2=winio@('%aw%ww[no_border]%ca[Control Panel]%pv%`^gr[black,user_resize]', &
ihgw_main_window, 300,200,ihgw_control_panel, draw_control_panel )
i3=winio@('%aw%ww[no_border]%ca[Display Bar]%pv%`^gr[white,rgb_colours,user_resize]', &
ihgw_main_window, 500,400, ihgw_display_bar, draw_display_bar )
i4=winio@('%aw%ww[no_border]%ca[ihgw_simulation]%pv%`^gr[black,user_resize]', &
ihgw_main_window, 800,800, ihgw_simulation, draw_simulation )
!... Text window
Print*, 'This is Text window'
end program test_mdi1
!..............................................................
integer function draw_control_panel ()
include <windows.ins>
common /GR_areas_ids/ihgw_main_window, ihgw_control_panel, ihgw_display_bar, ihgw_simulation
i44=select_graphics_object@(ihgw_control_panel)
call draw_filled_ellipse@(100,100,80,80,rgb@(127,59,30))
draw_control_panel=2
end function
!..............................................................
integer function draw_display_bar ()
include <windows.ins>
common /GR_areas_ids/ihgw_main_window, ihgw_control_panel, ihgw_display_bar, ihgw_simulation
i44=select_graphics_object@(ihgw_display_bar)
call draw_filled_rectangle@(2,2,398,398,rgb@(255,255,30))
draw_display_bar=2
end function
!..............................................................
integer function draw_simulation ()
include <windows.ins>
common /GR_areas_ids/ihgw_main_window, ihgw_control_panel, ihgw_display_bar, ihgw_simulation
i44=select_graphics_object@(ihgw_simulation )
call draw_filled_rectangle@(10,10,200,200,rgb@(30,255,30))
call draw_filled_rectangle@(100,50,120,60,rgb@(255,0,30))
call draw_filled_rectangle@(400,400,600,5000,rgb@(30,0,255))
draw_simulation=2
end function
|
|
|
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
|