Page 1 of 1

Scrolling

Posted: Tue Mar 12, 2013 9:13 am
by c-tec
Hello,
I have some problems to understand VSCROLL and HSCROLL of DCSTATIC. If I scroll down in my sample, the static scrolls over the button on the top of the dialog. The scrollarea should only be in the area of oStatic2.
I also would like to make the scroll buttons larger. I think I can go throug the getlist and change the size of the object, but is there an easier way to do this ?
regards
Rudolf

Code: Select all

#INCLUDE "dcdialog.CH"

function Main()
******************************************************************
local getlist := {},x,oStatic1,oStatic2
@ 0,0 DCSTATIC TYPE XBPSTATIC_TYPE_RECESSEDBOX SIZE 500,700  OBJECT oStatic1 PIXEL  RESIZE DCGUI_RESIZE_AUTORESIZE_SCALEFONT
@ 1,1 DCPUSHBUTTONXP size 500,40 caption "buttons" PIXEL PARENT oStatic1
@ 42,0 DCSTATIC TYPE XBPSTATIC_TYPE_TEXT SIZE 500,700-42 OBJECT oStatic2 PARENT oStatic1 PIXEL RESIZE DCGUI_RESIZE_AUTORESIZE_SCALEFONT;
                    VSCROLL oStatic1 RANGE 0,500 INCREMENT 10 ;
                    HSCROLL oStatic1 RANGE 0,500 INCREMENT 10

for x := 1 to 100 step 20
     @ x,20 dcsay "Test" saysize 0 parent oStatic2 PIXEL

next x
DCREAD GUI TITLE "Test" FIT EVAL {|o|SetAppWindow(o)}
return .t.

PROC appsys
return

Re: Scrolling

Posted: Tue Mar 12, 2013 9:35 am
by rdonnay
If you want more control, I suggest using DCSTATIC and DCSCROLLBAR commands.

Re: Scrolling

Posted: Tue Mar 12, 2013 11:39 am
by c-tec
Hello Roger,
thank you, got it working so far. But here I have also the problem that oStatic2 scrolls over the button on the top of the dialog.
How can I make the scroller button higher ?
regards
Rudolf

Code: Select all

#INCLUDE "dcdialog.CH"
#INCLUDE "xbp.CH"
#INCLUDE "appevent.CH"



function Main()
******************************************************************
local getlist := {},x,oStatic1,oStatic2,lTest := .t.
local aStatic  := {}
local nVertOffset := 0, nHorizOffset := 0, nVert, nHoriz, i, j, oVertScroll, oHorizScroll, GetOptions


@ 0,0 DCSTATIC TYPE XBPSTATIC_TYPE_RECESSEDBOX SIZE 500,700  OBJECT oStatic1 PIXEL  RESIZE DCGUI_RESIZE_AUTORESIZE_SCALEFONT
@ 1,1 DCPUSHBUTTONXP size 500,40 caption "buttons" PIXEL PARENT oStatic1
@ 42,0 DCSTATIC TYPE XBPSTATIC_TYPE_TEXT SIZE 500,700-42 OBJECT oStatic2 PARENT oStatic1 PIXEL RESIZE DCGUI_RESIZE_AUTORESIZE_SCALEFONT
@ 0,500 DCSCROLLBAR DATA nVertOffset  SIZE 50,700-42 TYPE XBPSCROLL_VERTICAL   RANGE 0,2000 AUTOTRACK OBJECT oVertScroll  SCROLL { |mp1,x,o| scroller(mp1,o,oStatic1,oStatic2,nVert,@nVertOffset,2) } PIXEL


for x := 1 to 100 step 20
     @ x,20 dcsay "Test" saysize 0 parent oStatic2 PIXEL
next x

DCREAD GUI TITLE "Test" FIT  EVAL {|o|nVert:=oStatic2:currentPos()[2], ;
            nHoriz:=oStatic2:currentPos()[1], ;
            o:reSize := {|a,b,x|scroll_resize(a,b,x,oStatic1,oStatic2,oVertScroll, @lStartUp )} }


return .t.


PROC appsys
return

STATIC FUNCTION scroll_resize( aOldSize, aNewSize, oDlg, oStatic1, oStatic2,oVertScroll, lStartUp )
******************************************************************
LOCAL nWidth  := aNewSize[1] - aOldSize[1]
LOCAL nHeight := aNewSize[2] - aOldSize[2]
IF !empty(lStartUp)
  lStartUp := .f.
  RETURN nil
ENDIF
oStatic1:setSize( {oStatic1:currentSize()[1]+nWidth,oStatic1:currentSize()[2]+nHeight} )
oStatic2:setSize( {oStatic2:currentSize()[1]+nWidth,oStatic2:currentSize()[2]+nHeight} )
oVertScroll:setSize( {oVertScroll:currentSize()[1],oVertScroll:currentSize()[2]+nHeight} )
oVertScroll:setPos( {oVertScroll:currentPos()[1]+nWidth,oVertScroll:currentPos()[2]} )

RETURN nil



STATIC FUNCTION scroller( a, oScroll, oStatic1, oStatic2, nStart, nOffset, nScroll )
******************************************************************
LOCAL nEvent, mp1, mp2, oXbp

nEvent := DC_NextAppEvent(@mp1,@mp2,@oXbp)
IF nEvent = xbeSB_Scroll
  RETURN nil
ENDIF

IF a[2] == XBPSB_NEXTPAGE
  nOffset += oStatic1:currentSize()[nScroll]
  oScroll:setData()
ELSEIF a[2] == XBPSB_PREVPAGE
  nOffset -= oStatic1:currentSize()[nScroll]
  oScroll:setData()
ELSE
  nOffset := a[1]
ENDIF
altd()
IF nScroll = 2
  oStatic2:setPos({oStatic2:currentPos()[1],nStart+nOffset})
ELSE
  oStatic2:setPos({nStart-nOffset,oStatic2:currentPos()[2]})
ENDIF

RETURN nil


Re: Scrolling

Posted: Wed Mar 13, 2013 5:07 pm
by Auge_Ohr
hi,

your PushButton is on same Parent oStatic1 which Size > ::drawingArea ( which give you vertical Scrollbar )

you have to put your Pushbutton on oDlg and than "resize" o:drawingArea

Code: Select all

   aTmp := oDlg:DrawingArea:Currentsize()
   // on bottom
   oStatbar := Statbar() :new( oDlg ) // oDlg !!!
   oStatbar:Caption := "myStatbar"
   oStatbar:create(,, { 0, 0 }, { aTmp[ 1 ], nHigh }, aPres )
   // new ::drawingArea Pos/Size
   oDlg:DrawingArea:SetPosAndSize( { 0, nHigh }, { aTmp[ 1 ], aTmp[ 2 ] - nHigh } )

Re: Scrolling

Posted: Thu Mar 14, 2013 12:32 am
by c-tec
Hello Jimmy,
thank you, this is a workaround I think. But how put I the buttons and other things thon on this static area. In Rogers scroll sample there are always 3 statics involved, I wanted to avoid this and do this with 2 statics and the SCROLLBAR option of DCSTATIC. The code to put a simple scrollable area on a static is rather complicated. So if I need this for more different dialogs, it becomes complicated.
regards
Rudolf