[futurebasic] Re: [FB] 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 Lewis Wilkins <pepetoo@...>
Date: Wed, 5 Apr 2006 14:23:31 -0700
Thanks, Brian. With my eyesight problems, I didn't even notice there  
are two spaces. (smile)

Joe Wilkins

On Apr 5, 2006, at 2:14 PM, Brian Stevens wrote:

> I had to removed invisible characters between DIM AS    and the  
> type to eliminate all these. Just needs a cleanup.
>
>
> On Apr 5, 2006, at 12:41 PM, Joe Lewis Wilkins wrote:
>
>> This was the same, only worse (32 errors,  and 2 warnings), of the  
>> same ilk as the previous Demo. Ideas anyone?
>>
>> Joe Wilkins
>>
>> On Apr 5, 2006, at 11:39 AM, SVANVOORST@... wrote:
>>
>>> '-------- Start of Code --------
>>> /*
>>>   This demo will move controls in an appearance window.
>>>   Programmer must do own control count.
>>>
>>>   MouseWheelHandler by Robert Purves.
>>>
>>>   Known problem: Form will creep downward
>>>   with heavy use of wheel.
>>>
>>>   Written by S. Van Voorst   {4/5/06}
>>> */
>>>
>>> include "Tlbx CarbonEvents.Incl"
>>>
>>> begin enum 1'Note: scroll btns are 1,2
>>> _scrlVert
>>> _scrlHorz
>>> _nameLabel
>>> _nameField
>>> _addressLabel
>>> _addressField
>>> _chekBox1
>>> _descriptionLabel
>>> _descriptionField
>>> _endLabel
>>> end enum
>>>
>>> _cntrlCount = 10'Control count by programmer.
>>>
>>> _scrlMin = 0
>>> _scrlMax = 20
>>>
>>> local fn moveControls( deltaHorz as short, deltaVert as Short )
>>> '~'1
>>> dim as rect  cntrlRect
>>> dim as ControlRef c
>>> dim as int btnID
>>>
>>> for btnID = 3 to _cntrlCount'Don't include scroll btns.
>>> c = button&(btnID)
>>> GetControlBounds( c, cntrlRect )
>>> MoveControl( c, cntrlRect.left + deltaHorz, cntrlRect.top +  
>>> deltaVert )
>>> next btnID
>>>
>>> end fn
>>>
>>> local fn InstallMouseWheelHandler( w as WindowRef )
>>> '~'1
>>> dim as EventTypeSpec  mouseEvents
>>> begin globals
>>> dim as proc  sMouseWheelEventUPP // 'static' var
>>> end globals
>>>
>>> long if ( sMouseWheelEventUPP == _nil )
>>>     sMouseWheelEventUPP = fn NewEventHandlerUPP( [Proc  
>>> "MouseWheelHandler" ¬
>>>     + _FBprocToProcPtrOffset] )
>>> end if
>>> mouseEvents.eventClass = _kEventClassMouse
>>> mouseEvents.eventKind  = _kEventMouseWheelMoved
>>>
>>> end fn = fn InstallEventHandler( fn GetWindowEventTarget( w ), ¬
>>>       sMouseWheelEventUPP, 1, @mouseEvents, #0, #0 )
>>>
>>>
>>> long if 0
>>> "MouseWheelHandler"
>>> enterproc fn MouseWheelHandler( nextHandler as  
>>> EventHandlerCallRef, ¬
>>>    theEvent as EventRef, userData as Ptr ) = OSStatus
>>> '~'1
>>> dim as OSStatus  ignore
>>> dim as long        @ delta
>>> dim as long   wnd
>>> dim as long   thumb
>>>
>>> ignore = fn GetEventParameter( theEvent,  
>>> _kEventParamMouseWheelDelta, ¬
>>>     _typeLongInteger, #0, sizeof( long ), #0, @delta )
>>>
>>> wnd = window( _wndRef )
>>> thumb = button(_scrlVert)
>>>
>>> long if wnd <> 0
>>> long if delta > 0'Up
>>> Scroll Button _scrlVert, thumb - (delta/3)
>>> If Thumb > _scrlMin then FN MoveControls( 0, 25 )
>>> xelse'Down
>>> Scroll Button _scrlVert, thumb - (delta/3)
>>> If thumb < _scrlMax then FN MoveControls( 0,-25 )
>>> end if
>>> end if
>>>
>>> exitproc = _noErr // we handled
>>> end if
>>>
>>> local fn doWndContent
>>> '~'1
>>> dim as rect r
>>> Dim as str255 tmp$
>>>
>>> setrect( r, 30, 30, 100, 48 )
>>> appearance button  
>>> #_nameLabel,_activeBtn,,,,,@r,_kControlStaticTextProc
>>> def SetButtonTextString(_nameLabel, "Name: ")
>>>
>>> Setrect( r, 110, 30, 370, 48 )
>>> appearance button  
>>> #_nameField,_activeBtn,,,,,@r,_kControlEditTextProc
>>>
>>> setrect( r, 30, 60, 100, 78 )
>>> appearance button  
>>> #_addressLabel,_activeBtn,,,,,@r,_kControlStaticTextProc
>>> def SetButtonTextString(_addressLabel, "Address: ")
>>>
>>> Setrect( r, 110, 60, 370, 78 )
>>> appearance button  
>>> #_addressField,_activeBtn,,,,,@r,_kControlEditTextProc
>>>
>>> Setrect( r, 40, 92, 370, 110 )
>>> tmp$ = " Check here if this is a new project."
>>> appearance button #_chekBox1,_activeBtn,0,0,1,tmp$,@r,¬
>>> _kControlCheckBoxAutoToggleProc
>>>
>>> Setrect( r, 30, 122, 190, 140 )
>>> appearance button  
>>> #_descriptionLabel,_activeBtn,,,,,@r,_kControlStaticTextProc
>>> def SetButtonTextString(_descriptionLabel, "Description of  
>>> project: ")
>>>
>>> Setrect( r, 30, 150, 370, 330 )
>>> appearance button  
>>> #_descriptionField,_activeBtn,,,,,@r,_kControlEditTextProc
>>>
>>> Setrect( r, 30, 870, 220, 890)
>>> appearance button  
>>> #_endLabel,_activeBtn,,,,,@r,_kControlStaticTextProc
>>> def SetButtonTextString(_endLabel, "End of Form is Down Here!!")
>>>
>>> end fn
>>>
>>> local fn BuildWindow
>>> '~'1
>>> Dim as rect r
>>>
>>> Setrect( r, 0, 0, 400, 400 )
>>>
>>> appearance WINDOW #-1,"scrollCntrl_demo",@r,_kDocumentWindowClass,¬
>>> _kWindowStandardDocumentAttributes
>>>
>>> def setwindowbackground(_kThemeActiveDialogBackgroundBrush,_true)
>>>
>>> fn InstallMouseWheelHandler( window( _wndRef ))
>>>
>>> Scroll Button #_scrlVert, 0, _scrlMin, _scrlMax, 5,,_scrollVert
>>>
>>> scroll button #_scrlHorz, 0, _scrlMin, _scrlMax, 5,,_scrollHorz
>>>
>>> fn doWndContent
>>>
>>> appearance window 1
>>>
>>> end fn
>>>
>>> local fn DoDialog
>>> '~'1
>>> dim as long   evnt, id
>>> dim as long moveDir
>>>
>>> evnt  = dialog ( 0 )
>>> id    = dialog ( evnt )
>>>
>>> select evnt
>>> case _btnClick
>>> select id
>>>
>>> case _scrlVert
>>> moveDir = ( BUTTON - BUTTON(id)) * 25
>>> fn moveControls( 0, moveDir )
>>>
>>> case _scrlHorz
>>> moveDir = ( BUTTON - BUTTON(id)) * 25
>>> fn moveControls( moveDir, 0 )
>>>
>>> end select
>>>
>>> case _wndClose
>>> end
>>> end select
>>>
>>> end fn
>>>
>>>
>>> fn BuildWindow
>>> on dialog fn DoDialog
>>>
>>> do
>>> handleevents
>>> until 0
>>>
>>> '------ End of Code ------
>>
>>
>> -- To unsubscribe, send ANY message to: futurebasic- 
>> unsubscribe@...
>
> --
>