[futurebasic] Re: [FB] Re: Scrolling a window full of buttons and edit fields

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : April 2006 : Group Archive : Group : All Groups

From: Joe Lertola <joefb@...>
Date: Mon, 3 Apr 2006 08:52:38 -0400
Ken,

Thanks so much. That seems to work very well. I really appreciate the 
help.

-Joe

On Apr 2, 2006, at 11:05 PM, Ken Shmidheiser wrote:

> Joe asked:
>
>> I have been struggling with this all afternoon. I am trying to scroll 
>> a
>> window full of buttons and edit fields. I would love to have the
>> contents of the window scroll smoothly as the scroll button is moved.
>> Failing that I would be satisfied if the contents of the window
>> remained static until the button was released and then have the
>> contents redrawn properly. I haven't even been able to get that to 
>> work
>> in a satisfying way. I am getting a lot of flashing and partially 
>> drawn
>> buttons. The example below is the best I have been able to do so far.
>> Any help would be greatly appreciated.
>
>
> Joe,
>
> Here is a workaround that may prove acceptable in a pinch, although 
> notice the agonizingly slow redraw if arrow buttons are used for the 
> scroll, which they probably should be to keep the HIG monitors happy.
>
> Ken
>
>
> _windHt       = 300
> _areaToScroll = 600
> _scrlBtn      = 1
> _upArrow      = 30
> _downArrow    = 31
> _scrollMin    = 0
> _scrollMax    = 300
>
> dim as rect  xrect
> dim as long  thumb, btnId
>
> local fn BuildWindow
> dim as long  i
> dim as rect  myRect
>
> setrect( xrect, 0, 0, _windHt, _windHt )
> window -1, "test", @xrect, _doc
> Scroll Button _scrlBtn, _scrollMin, _scrollMin, _scrollMax, 
> 75,,_scrollVert
>
> setrect( myRect, 0, 0,  _windHt, _areaToScroll)
> color _zWhite
> paintrect( myRect)
> color _zBlack
> offsetrect( myRect,  0,  0 )
> insetrect(  myRect, 30, 30 )
> framerect(  myRect )
>
> setrect( myRect, 40, 40,  260, 60 )
> offsetrect( myRect, 0, 0 )
>
> btnId = 2
> for i = 1 to 20 step 2
> button btnId, _enable, "Test button", @myRect, 3
> offsetrect( myRect, 0, 25 )
> btnId++
> edit field btnId, "some text text", @myRect, 1, _leftJust
> offsetrect( myRect, 0, 25 )
> next i
>
> window 1
>
> end fn
>
> local fn drawSomething( thumbNow as long )
> dim as long       i
> dim as rect       myRect
> dim as ControlRef c
>
> setrect( myRect, 0, 0, _windHt, _areaToScroll )
> color _zWhite
> paintrect( myRect )
> color _zBlack
> offsetrect( myRect,  0, -thumbNow )
> insetrect(  myRect, 30,        30 )
> framerect(  myRect)
>
> setrect( myRect, 40, 40,  260,  60 )
> offsetrect( myRect,   0, -thumbNow )
>
> btnId = 2
> for i = 1 to 20 step 2
> button -btnId,,,@myRect
> button btnId
> offsetrect( myRect, 0, 25 )
> btnId++
> c = fn FBFindEF( btnId, _allEFSubClasses, window( _wndRef ) )
> hidecontrol( c )
> edit field btnId,,@myRect
> showcontrol( c )
> offsetrect(myRect, 0, 25)
> next i
>
> edit field 0
>
> end fn
>
> local fn DoDialog
> dim as long   evnt, id
>
> evnt  = dialog ( 0 )
> id    = dialog ( evnt )
>
> select evnt
> case _wndClose : end
> case _btnClick
> select id
> case _scrlBtn
> thumb = Button(id)
> fn drawSomething( thumb )
> end select
> case _evKey
> select id
> case _upArrow
> thumb = Button(_scrlBtn)
> if thumb > _scrollMin then thumb--
> Scroll Button _scrlBtn, thumb
> fn drawSomething( thumb )
> case _downArrow
> thumb = Button(_scrlBtn)
> if thumb < _scrollMax then thumb++
> Scroll Button _scrlBtn, thumb
> fn drawSomething( thumb )
> end select
> case _wndRefresh : fn drawSomething( thumb )
> end select
>
> end fn
>
> on dialog fn DoDialog
>
> fn BuildWindow
>
> do
> handleevents
> until gFBQuit
>