|
forums.silverfrost.com Welcome to the Silverfrost forums
|
View previous topic :: View next topic |
Author |
Message |
IanLambley
Joined: 17 Dec 2006 Posts: 490 Location: Sunderland
|
Posted: Mon Aug 12, 2013 12:12 pm Post subject: Callbacks for re-sizable controls |
|
|
I have been trying to use the %bv and %lv to make an arrangement which looks like an explorer type window. I want this to be re-sizable and have tried adding a %pv to either of the two controls. After re-sizing, there does not appear to be a callback issued. In the case of graphic controls a callback is issued so I have contemplated adding the %pv to a %dw control and overlaying the %bv and %lv. The re-size callback of the %dw could then adjust the sizes of the other controls.
I also would like to change the size of the individual %bv and %lv within the overall window.
Any suggestions?
Regards
Ian |
|
Back to top |
|
|
LitusSaxonicum
Joined: 23 Aug 2005 Posts: 2388 Location: Yateley, Hants, UK
|
Posted: Mon Aug 12, 2013 8:24 pm Post subject: |
|
|
Hi Ian,
My answer to the problem of only having one control with a pivot is to try and do it all in a big %gr taking over the client area. In the following code, the screen is separated into the 4 areas as an Explorer screen is. These are resized when the whole window resizes. I leave it to you to sense when the mouse is over a dividing line, and change to the appropriate cursor (using the concepts in the stretchy box example, but only up/down and left/right) and to apply the resulting coordinates to the divisions between the 4 areas - I have oversimplified the algorithm for sizing these.
At some point you would need to flesh out the different areas with icons and text, using IMPORT_IMAGE@ with GIFs if you want transparency, or with BMPs if your icons are rectangular.
Code: | WINAPP
OPTIONS (INTL, DREAL)
PROGRAM IAN
COMMON /MAINWINDOW/ iHandle, IXRES, IYRES
COMMON /BORDERS/ JX, JY1, JY2
INCLUDE <WINDOWS.INS>
INTEGER, EXTERNAL :: KALLBACK, SCREENPLOT
iHANDLE = 99; IXRES = 600; IYRES = 400
JX = 80; JY1 = 40; JY2 = 360
IA=WINIO@('%ca[Extendible]&')
IA=WINIO@('%sc&', SCREENPLOT)
IA=WINIO@('%ww[no_border]&')
IA=WINIO@('%pv%`^gr[white,user_resize,full_mouse_input]',
& IXRES, IYRES, iHANDLE, KALLBACK)
STOP; END
INTEGER FUNCTION SCREENPLOT()
COMMON /MAINWINDOW/ iHandle, IXRES, IYRES
COMMON /BORDERS/ JX, JY1, JY2
INCLUDE <WINDOWS.INS>
CALL DRAW_FILLED_RECTANGLE@ (0,0, IXRES,IYRES, RGB@(255,255,255))
CALL DRAW_FILLED_RECTANGLE@ (0,0, IXRES,JY1, RGB@(192,192,192))
CALL DRAW_FILLED_RECTANGLE@ (0,0, JX,IYRES, RGB@(200,200,255))
CALL DRAW_FILLED_RECTANGLE@ (0,JY2, IXRES,IYRES,
& RGB@(255,200,200))
C ... and fill the bars with icons and text, icons from RESOURCES
C placed with IMPORT_IMAGE@ using GIF (for transparency reason)
SCREENPLOT = 1
RETURN; END
INTEGER FUNCTION KALLBACK()
CHARACTER*(25) CBR
COMMON /MAINWINDOW/ iHandle, IXRES, IYRES
COMMON /BORDERS/ JX, JY1, JY2
INCLUDE <WINDOWS.INS>
INTEGER, EXTERNAL :: SCREENPLOT
KALLBACK = 1
CBR = CLEARWIN_STRING@('CALLBACK_REASON')
IF (CBR .EQ. 'RESIZE') THEN
IXRES0 = CLEARWIN_INFO@ ('GRAPHICS_WIDTH')
IYRES0 = CLEARWIN_INFO@ ('GRAPHICS_DEPTH')
IXRES = MAX (1, IXRES0)
IYRES = MAX (1, IYRES0)
JX = MIN(60, IXRES*80/600) !maybe MAX
JY1 = MIN(30, IYRES*40/400) !maybe MAX
JY2 = MAX(IYRES-30, IYRES*360/400)
IA=SCREENPLOT()
RETURN
ENDIF
C ... now get mouse coords, change cursors, allow blocks to be resized
C maybe have limit on block width, height as above
END |
|
|
Back to top |
|
|
LitusSaxonicum
Joined: 23 Aug 2005 Posts: 2388 Location: Yateley, Hants, UK
|
Posted: Mon Aug 12, 2013 8:24 pm Post subject: |
|
|
... I'm working on something similar to allow files to be previewed before being selected.
Eddie |
|
Back to top |
|
|
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 7925 Location: Salford, UK
|
Posted: Tue Aug 13, 2013 10:03 am Post subject: |
|
|
I don't have a simple answer to this at the moment.
It would be nice to have horizontal and vertical splitter bars but that would be a big undertaking. |
|
Back to top |
|
|
IanLambley
Joined: 17 Dec 2006 Posts: 490 Location: Sunderland
|
Posted: Tue Aug 13, 2013 11:46 am Post subject: |
|
|
Thanks Eddie, I'll have a go at something like that.
Paul,
For me although, not perfect, if resize callbacks were issued for %bv and %lv, it would be a great help.
Regards
Ian |
|
Back to top |
|
|
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 7925 Location: Salford, UK
|
Posted: Tue Aug 13, 2013 12:22 pm Post subject: |
|
|
Try using %`mv on the main window.
This takes a callback function and the callback reason is "WINDOW_MOVEMENT". |
|
Back to top |
|
|
IanLambley
Joined: 17 Dec 2006 Posts: 490 Location: Sunderland
|
Posted: Tue Aug 13, 2013 12:48 pm Post subject: |
|
|
Thanks Paul,
I'll give that a go tonight.
Regards
Ian |
|
Back to top |
|
|
LitusSaxonicum
Joined: 23 Aug 2005 Posts: 2388 Location: Yateley, Hants, UK
|
Posted: Tue Aug 13, 2013 12:50 pm Post subject: |
|
|
After a bit of thought, splitter bars included:
Code: | WINAPP
OPTIONS (INTL, DREAL)
PROGRAM IAN
COMMON /MAINWINDOW/ iHandle, IXRES, IYRES
COMMON /BORDERS/ JX, JY1, JY2
COMMON /CURSOR/ NCURS, MOVING, iBAR
INCLUDE <WINDOWS.INS>
INTEGER, EXTERNAL :: KALLBACK, SCREENPLOT
iHANDLE = 99; IXRES = 600; IYRES = 400
JX = 80; JY1 = 40; JY2 = 360; NCURS = 1; MOVING = 0
IA=WINIO@('%ca[Extendible]&')
IA=WINIO@('%sc&', SCREENPLOT)
IA=WINIO@('%ww[no_border]&')
IA=WINIO@('%3cu[arrow][updown][leftright]&', NCURS)
IA=WINIO@('%pv%`^gr[white,user_resize,full_mouse_input]',
& IXRES, IYRES, iHANDLE, KALLBACK)
STOP; END
INTEGER FUNCTION SCREENPLOT()
COMMON /MAINWINDOW/ iHandle, IXRES, IYRES
COMMON /BORDERS/ JX, JY1, JY2
INCLUDE <WINDOWS.INS>
CALL DRAW_FILLED_RECTANGLE@ (0,0, IXRES,IYRES, RGB@(255,255,255))
CALL DRAW_FILLED_RECTANGLE@ (0,0, IXRES,JY1, RGB@(192,192,192))
CALL DRAW_LINE_BETWEEN@ (0,JY1,IXRES,JY1, RGB@(0,0,0))
CALL DRAW_FILLED_RECTANGLE@ (0,0, JX,IYRES, RGB@(200,200,255))
CALL DRAW_LINE_BETWEEN@ (JX,0,JX,IYRES, RGB@(0,0,0))
CALL DRAW_FILLED_RECTANGLE@ (0,JY2, IXRES,IYRES,
& RGB@(255,200,200))
CALL DRAW_LINE_BETWEEN@ (0,JY2,IXRES,JY2, RGB@(0,0,0))
C ... and fill the bars with icons and text, icons from RESOURCES
C placed with IMPORT_IMAGE@ using GIF (for transparency reason)
SCREENPLOT = 1
RETURN; END
INTEGER FUNCTION KALLBACK()
CHARACTER*(25) CBR
COMMON /MAINWINDOW/ iHandle, IXRES, IYRES
COMMON /BORDERS/ JX, JY1, JY2
COMMON /CURSOR/ NCURS
INCLUDE <WINDOWS.INS>
INTEGER, EXTERNAL :: SCREENPLOT
KALLBACK = 1
CBR = CLEARWIN_STRING@('CALLBACK_REASON')
IF (CBR .EQ. 'RESIZE') THEN
IYRES_OLD = IYRES
IXRES0 = CLEARWIN_INFO@ ('GRAPHICS_WIDTH')
IYRES0 = CLEARWIN_INFO@ ('GRAPHICS_DEPTH')
IXRES = MAX (1, IXRES0)
IYRES = MAX (1, IYRES0)
JY2 = IYRES - (IYRES_OLD - JY2)
IA=SCREENPLOT()
RETURN
ENDIF
CALL GET_MOUSE_INFO@ (kX, kY, jFLAGS)
IF (ABS(kx-jx) .LE. 8) THEN
NCURS = 3; iBAR = 2; MOVING = 1
ELSE IF (ABS(ky-JY1) .LE. 8) THEN
NCURS = 2; iBAR = 1; MOVING = 1
ELSE IF (ABS(ky-JY2) .LE. 8) THEN
NCURS = 2; iBAR = 3; MOVING = 1
ELSE
NCURS = 1; IBAR = 0
ENDIF
IF (JFLAGS .EQ. 0) RETURN
IF (JFLAGS .EQ. 1) THEN
IF (IBAR .EQ. 1 .AND. MOVING .EQ. 1) JY1=KY
IF (IBAR .EQ. 2 .AND. MOVING .EQ. 1) JX =KX
IF (IBAR .EQ. 3 .AND. MOVING .EQ. 1) JY2=KY
IA=SCREENPLOT()
RETURN
ENDIF
END
RESOURCES
arrow CURSOR "SmoothArrow.cur"
updown CURSOR "SmoothVerticalSize.cur"
leftright CURSOR "SmoothHorizontalSize.cur" |
|
|
Back to top |
|
|
LitusSaxonicum
Joined: 23 Aug 2005 Posts: 2388 Location: Yateley, Hants, UK
|
Posted: Tue Aug 13, 2013 12:59 pm Post subject: |
|
|
... and the strategy to work out where you are is:
Code: | IF (ky .GT. JY2) THEN ! you are in bottom bar
! ... now consider x position, i.e. kx
IF (kx .LT. JX) THEN ! you are in left bar
! ... now consider y position, i.e. ky
IF (ky .LT. JY1) THEN ! you are in top bar
! ... now consider x position, i.e. kx-JX
ELSE ! you are in the remaining area
! ... so relative position is (kx-JX), (ky-JY1) |
in order to work out which icon you are over you will need to know the sizes and spacings, and to select what to do you will need to consider the mouse states (e.g. mouseover, down, up, selected, etc) and IMPORT_IMAGE@ the right image in the right position, including greyed out states!
The splitter bars are the least of your worries!
On the other hand, it would be nice to see them in Clearwin!
Eddie |
|
Back to top |
|
|
jalih
Joined: 30 Jul 2012 Posts: 196
|
Posted: Wed Aug 14, 2013 7:28 pm Post subject: Re: Callbacks for re-sizable controls |
|
|
IanLambley wrote: |
I also would like to change the size of the individual %bv and %lv within the overall window.
Any suggestions?
|
How about using WINAPI and %mg callback to process the WM_SIZE message? You can get the client rectangle size of the controls parent window using GetClientRect() function. Size and location of the child control can be figured out using GetWindowRect() and MapWindowPoints() functions. Window or child control can be resized using MoveWindow() function.
LitusSaxonicum wrote: |
The splitter bars are the least of your worries!
On the other hand, it would be nice to see them in Clearwin! |
Any ideas, how to present splitter bar control in ClearWin+ syntax? I have some working demo code for splitter bars in MiniBASIC. |
|
Back to top |
|
|
LitusSaxonicum
Joined: 23 Aug 2005 Posts: 2388 Location: Yateley, Hants, UK
|
Posted: Wed Aug 14, 2013 9:11 pm Post subject: |
|
|
Hi Jalih,
It's now some years since I struggled with %bv and %tv when trying to construct a help system. In the end, I gave up (as I do sometimes - easily defeated). I was having trouble with keypresses. There is probably something in the forum in the archives of long ago. More recently, I struggled and gave up on %lv - this time after a second or third attempt. I come to the conclusion that there is something I don't understand, despite reading and rereading the ENH and CHM files, and sometimes the PDF manual!
I eventually solved the Help issue by learning how to create CHM files, and the problem with %lv (whatever it was) by programming a grid in %gr, and editing the values outside the grid - in-grid editing wasn't present in early versions of Excel, for example!
I have found that anything like a splitter bar that doesn't seem to be present in Clearwin and is incomprehensible in MSDN is often programmable within a %gr region (as in my example) that fills the entire client area of the application. If you divide the %gr into rectangular areas, and fill each with pre-drawn icons and text, everything happens so quickly you never see the redraw. This is as true of a low-spec laptop as on a hi-spec desktop with an expensive graphics card. Then, provided things are laid out in a regular layout, you can interrogate the mouse pointer coordinates and work out which icon or text to highlight or select - again, it happens too quickly to see the update. What doesn't work for me is to have editable numeric or text entry in a %gr area - I can imagine how it is done but it is easier in a Clearwin dialog so I don't attempt it. Anything you can draw in the %gr area, you can resize individually or on a whole screen basis, and although my example's splitters are single pixel black lines they can be shaded and made several pixels wide very easily.
Paul thinks implementing splitter bars within Clearwin would be difficult, and I concur - you would need multiple controls with pivots, and some way of deciding what the hierarchy is ... something you can decide for yourself in a %gr area redraw.
Programming these effects in a single %gr area is what I used to do on graphical VDUs attached to a mainframe 30 years ago, but in those days you could see everything redraw after every change. Also in the early days of PCs.
Eddie |
|
Back to top |
|
|
LitusSaxonicum
Joined: 23 Aug 2005 Posts: 2388 Location: Yateley, Hants, UK
|
Posted: Wed Aug 14, 2013 9:56 pm Post subject: |
|
|
.... and in Clearwin+ syntax, what about:
%sb[horizontal] and %sb[vertical]? Or %sb for vertical and %`sb for horizontal?
or to set a minimum size to left or right of a vertical splitter bar, supply an appropriate keyword and some parameters. However, as Clearwin+ seems to operate in average character size steps, then these limits would not be terribly intitive.
Was this what you meant?
Eddie |
|
Back to top |
|
|
jalih
Joined: 30 Jul 2012 Posts: 196
|
Posted: Thu Aug 15, 2013 7:53 am Post subject: Re: |
|
|
LitusSaxonicum wrote: |
Paul thinks implementing splitter bars within Clearwin would be difficult, and I concur - you would need multiple controls with pivots, and some way of deciding what the hierarchy is ... something you can decide for yourself in a %gr area redraw. |
Splitter bar control is just a child window that processes mouse and paint events and sends some user messages to it's parent window.
All needed properties like min value, max value, color, size and location information for the splitter can be put into property list of the window using SetPropA() function and queried using GetPropA() function.
When splitter is moved, it sends a message to the parent window. Parent window must then handle the message and resize the splitted controls based on splitter location.
Should ClearWin+ syntax define the controls to be splitted, rectangular area for those controls and the split ratio? |
|
Back to top |
|
|
IanLambley
Joined: 17 Dec 2006 Posts: 490 Location: Sunderland
|
Posted: Thu Aug 15, 2013 12:43 pm Post subject: |
|
|
Here is a simple resize only for a combined %bv and %lv window.
You will need to invent some 16x16 bmp files for the %bv icons.
I have added a splitter system, but it drops the bar if moved too fast I'll keep trying on that one but for now the simple code.
Code: |
WINAPP
include <windows.ins>
INTEGER i,iget_offsets
external iget_offsets, mv_callback, lv_callback
common/window_things/ihandle_window
common/window_offset/ixoffset,iyoffset
common/handles/ibv_handle,ilv_handle
CHARACTER*80 bv_items(4)
INTEGER bv_sel
character*300 items(0:100)
integer*4 sel(100)
items = ' '
items(0)='|col1_|col2_|col3_|'
items(1)='|col1kl|col2suifhshf|col3kldgjdlkgj|'
!dummy window
i=winio@('%ca[dummy]&')
i=winio@('%mn[File[Exit]]&','EXIT') !include this line only if real window is to contain a menu
i=winio@('%rd%lc%sc',i,ihandle_window,iget_offsets)
ixsize = 400
iysize = 350
num_item = 100
iview = 1
bv_items(1)='AEBBook'
bv_items(2)='BCAChapter 1'
bv_items(3)='CCASection 1.1'
bv_items(4)='CCASection 1.2'
bv_sel=1
! real window
i=winio@('%ca[Resizable bv-lv controls]%ww%bg[btnface]%hw&',ihandle_window)
i=winio@('%bd&',0.0D0,0.0D0,0.0D0,0.0D0)
i=winio@('%mn[File[Exit]]&','EXIT')
i=winio@('%`mv&',mv_callback)
i=winio@('%ff%`bv[has_buttons,show_selection_always,has_lines]&',200,iysize,bv_items,4,bv_sel,'cut,paste')
i=winio@('%lc&',ibv_handle)
i=winio@(' %pv%^lv[full_row_select]&', &
ixsize,iysize,items,num_item,sel,iview,lv_callback)
i=winio@('%lc',ilv_handle)
END
integer*4 function mv_callback()
include <windows.ins>
character*100 cb_reason
common/handles/ibv_handle,ilv_handle
cb_reason = clearwin_string@('CALLBACK_REASON')
! print*,trim(cb_reason)
if(cb_reason .eq. 'WINDOW_MOVEMENT')then
call get_real_control_location(ilv_handle,ix,iy,ilv_w,ilv_h)
call get_real_control_location(ibv_handle,ix,iy,ibv_w,ibv_h)
call resize_window@(ibv_handle,ibv_w,ilv_h)
! print*,ilv_w,ilv_h,ibv_w,ibv_h
endif
mv_callback = 1
end
integer*4 function lv_callback()
include <windows.ins>
! dummy for now
lv_callback = 1
end
! get initial offsets using dummy window
integer*4 function iget_offsets()
include <windows.ins>
common/window_things/ihandle_window
common/window_offset/ixoffset,iyoffset
! set the %rd pixel location to zero,zero
call MOVE_WINDOW@( ihandle_window, 0,0)
call GET_WINDOW_LOCATION@( ihandle_window, ixoffset, iyoffset, iw, ih)
ixoffset = ixoffset + 1
iyoffset = iyoffset + 1
iget_offsets = 0
end
!fix returned locations
subroutine get_real_control_location(ihandle,ix,iy,iw,ih)
include <windows.ins>
common/window_offset/ixoffset,iyoffset
call GET_WINDOW_LOCATION@( ihandle, ix, iy, iw,ih)
ix = ix - ixoffset
iy = iy - iyoffset
end
RESOURCES
cut BITMAP asset.bmp
copy BITMAP platform.bmp
|
|
|
Back to top |
|
|
LitusSaxonicum
Joined: 23 Aug 2005 Posts: 2388 Location: Yateley, Hants, UK
|
Posted: Thu Aug 15, 2013 7:02 pm Post subject: |
|
|
You guys beat me every time! I read all that stuff on MSDN, and it might as well be in a local dialect of the least-spoken language on planet Zog!
E |
|
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
|