[futurebasic] Need GHelp

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : September 2004 : Group Archive : Group : All Groups

From: tedd <tedd@...>
Date: Thu, 23 Sep 2004 11:51:16 -0400
Hi gang:

I've reviewed every piece of code I have and this problem has got me 
stumped. The following code creates an off-screen GWorld graphic and 
should update the window as needed via scroll bars, but it don't.

Any ideas?

Thanks.

tedd

---

Dim gGWorld  as ^CGrafPort
_mapWnd = 1

end globals

'=========================================
'doGrid -- draw a graphic
'-----------------------------------------

Local Fn doit
DIM x, y, w, temp$
DIM @myRect as rect

SETRECT(myRect, 0, 0, 1000, 1000)'create a 1000 x 1000 rect
ERASERECT(myRect)'clear the drawing area

TEXTFONT (_Geneva)

PENSIZE (2,2)'frame the area in red 2pt
COLOR _zRed
FRAMERECT(myRect)


INSETRECT(myRect, 49, 50)'shrink the rect by 50
COLOR _zBlue
FRAMERECT(myRect)'frame the rect in blue
PENNORMAL
x = 0
FOR y = 50 TO 945 STEP 5'create reference grid
LONG IF x = 10
COLOR _zBlack
PRINT %(10, y+4); y;
CALL PENSIZE (2, 2)
END IF
COLOR _zGreen
MOVETO (50, y) : LINETO (950, y)
LONG IF x = 10
PRINT %(950, y+4); y;
PENNORMAL
x = 0
END IF
x = x + 1
NEXT

FOR x = 100 TO 900 STEP 50
COLOR _zMagenta
temp$ = MID$(STR$(x), 2)
w = FN STRINGWIDTH(temp$)/2
PRINT%(x-w ,45); temp$;
PRINT%(x-w ,964); temp$;
COLOR _zCyan
MOVETO(x, 48) : LINETO(x, 952)
NEXT
COLOR _zBlack

End Fn

'========================================
'upDate -- to refresh window
'----------------------------------------
LOCAL FN upDate
DIM max
dim @currPort&
dim src as rect'source rect (the "what you see" rect)
dim dest as rect'destination rect (the "where you see it" rect

LONG IF gGWorld
WINDOW OUTPUT _mapWnd'make certain it's going where I want
'
'   get destination rect (i.e., the current window)
'
SETRECT(dest, 0, 0, WINDOW(_width), WINDOW(_height))
'
'   figure the scroll bar values from the coord of the dest rect
'
max = 1000 - dest.bottom
IF max < 0 THEN max = 0
SCROLL BUTTON _scrollVert,,0,max,dest.bottom'vertical scroll bar

max = 1000 - dest.right
IF max < 0 THEN max = 0
SCROLL BUTTON _scrollHorz,,0,max,dest.right'horizontal scroll bar
'
'   set screen rect (as per thumb values, where the rect is on the GWorld)
'
src.top = BUTTON (_scrollVert)'set the top & bottom coord for source 
rect from vert scroll
src.bottom = src.top + dest.bottom

src.left = BUTTON (_scrollHorz)'set the left & right coord for source 
rect from horz scroll
src.right = src.left + dest.right
'
currPort& = WINDOW(_wndPointer)'get pointer for window (_mapWnd)
'
'  copy from offscreen gGWorld to the WINDOW via source and dest rects
'
CopyBits(gGWorld, currPort&, src, dest, _srcCopy, 0)

END IF
END FN

'=========================================
'build -- create an offscreen graphic port
'-----------------------------------------

local fn buildOffScreen
Dim @scrnGW  as ^CGrafPort
Dim @scrnDev as Handle
Dim r       as Rect
Dim i

SetRect(r,0,0,1000,1000)
Flushwindowbuffer
GetGWorld(scrnGW,scrnDev)

Long If Fn NewGWorld(gGWorld, 32, r, 0, 0, 0) = _noErr
SetGWorld(gGWorld,0)
EraseRect(r)
Long If Fn LockPixels(Fn GetGWorldPixMap(gGWorld))
Fn doit
SetGWorld(scrnGW,scrnDev)
CopyBits(gGWorld.portPixMap, scrnGW.portPixMap, r, r, _srcCopy, 0)
UnlockPixels(Fn GetGWorldPixMap(gGWorld))
FlushWindowBuffer
Xelse
SetGWorld(scrnGW,scrnDev)
DisposeGWorld(gGWorld)
Print @(0,0) "LockPixels error"
End If
Xelse
ForeColor(_BlackColor)
Print @(0,0) "Out of Memory!"
End If

end fn

'=========================================
'build window
'-----------------------------------------
Local Fn BuildWnd
Window _mapWnd,"Scrolling Window",(0,0)-(500,320),_doc
Scroll Button 1,0,0,0,1000,,_scrollVert
Scroll Button 2,0,0,0,1000,,_scrollHorz
fn buildOffScreen
End Fn

'=========================================
'dialog
'-----------------------------------------

Local Fn HandleDialog
Dim ev, id
ev = Dialog(0)
id = Dialog(ev)

Long If Window(_outputWnd) = _mapWnd
Select ev
Case _btnClick
FN upDate

Case _wndRefresh
FN upDate

Case _preview
FN upDate

End Select
End If
End Fn


'~Main Program

Fn BuildWnd

Menu 1,0,1,"File"
Menu 1,1,1,"Quit/Q"

On Dialog Fn HandleDialog

Do
Handleevents
Until gFBQuit

DisposeGWorld(gGWorld)

-- 
--------------------------------------------------------------------------------
http://sperling.com/