|
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 |
|
|
John-Silver
Joined: 30 Jul 2013 Posts: 1520 Location: Aerospace Valley
|
Posted: Wed Mar 28, 2018 6:17 am Post subject: |
|
|
you could set up an MDI (multi-document interface) window and define several different fixed size child windows within it and put each %gr graphics window in seperate child windows.
Thus the child windows remain unchanged while the &gr can be re-sized individually within each one without affecting the others. _________________ ''Computers (HAL and MARVIN excepted) are incredibly rigid. They question nothing. Especially input data.Human beings are incredibly trusting of computers and don't check input data. Together cocking up even the simplest calculation ... " |
|
Back to top |
|
|
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 7932 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: 2390 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 |
|
|
John-Silver
Joined: 30 Jul 2013 Posts: 1520 Location: Aerospace Valley
|
Posted: Wed Apr 11, 2018 6:15 pm Post subject: |
|
|
Rudnei,
It's good that you've put together a test progam but after running it I'm still not sure exactly what you're tryng to do.
Are you actually trying to keep a fixed-size overall window and just be able to change the size of the bigger graphics area (which was my understanding from what you wrote at the top of the post) ?
In the example that you've posted it's odd because the left hand %gr 's are 'fixed' to the bottom of the window while the larger one with the circles which re-sizes is the inverse, fixed to the top of the window - so it's like 2 ships crossing in the night - as you pull down the edge of the window the larger %gr comes down while the top of the left hand areas 'slide' off the top of the window.
I still think the use of mdi with the main window, then defining a frame, then defining 2 child windows, the one on the left containing the 2 smaller %gr 's and the one on the right containing the larger one made re-sizeable along with the %gr itself re-sizeable, will probaby work.
A couple of other observations in passing, these actions (except the first one which may be a bug or a result of some specific combination of actions) may be intentional and/or just a function of having created a test program but I mention them here just for your information in case they're unintended actions :-
1. Try maximising the window first, then move it using the caption bar ..... and the window size changes (reduces) !!! Very odd behaviour.
2. the behaviour of the mouse actions in the circles window seems a bit odd. If I select a region I intuitively expect it to enlarge so that only that area then fills the %gr area. Is that what you intended ? because it actually reduces it and sends it into the top left corner of the screen.
3. after doing as in 2, if I click with the right button in the graphics area the graphics become larger, but not to the same size as the priginal, nor do they fill the screen.
4. After right -clicking, try clicking left button and the 3 circles disappear ! _________________ ''Computers (HAL and MARVIN excepted) are incredibly rigid. They question nothing. Especially input data.Human beings are incredibly trusting of computers and don't check input data. Together cocking up even the simplest calculation ... " |
|
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 |
|
|
John-Silver
Joined: 30 Jul 2013 Posts: 1520 Location: Aerospace Valley
|
Posted: Sat Apr 14, 2018 5:15 pm Post subject: |
|
|
Hi Rudnei,
yes it's created with Clearwin+.
We need to know exactly what you are trying to s�achive which is why I asked
Quote: | Are you actually trying to keep a fixed-size overall window and just be able to change the size of the bigger graphics area (which was my understanding from what you wrote at the top of the post) ? |
... or something else ?
If yo uclarify that I'll take a look.
You can get an idea of the MDI concept here in the working code posted on 9th April.here
http://forums.silverfrost.com/viewtopic.php?t=3746
That's a simple example with a single window nested inside a frame which is defined in the main window.
It's all about working out the nesting strategy you ned and then specifying which sub-window (child-window(s) need to be pivoted so that they re-size automatically when the parent window is re-sized with the cursor. _________________ ''Computers (HAL and MARVIN excepted) are incredibly rigid. They question nothing. Especially input data.Human beings are incredibly trusting of computers and don't check input data. Together cocking up even the simplest calculation ... " |
|
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: 2826 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 |
|
|
|
|
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
|