[futurebasic] Pen Size still not changing...

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : March 2010 : Group Archive : Group : All Groups

From: Brian Heibert <heibert@...>
Date: Tue, 16 Mar 2010 21:32:16 -0400
Heres my program so far
Can someone look at it and tell me why the pen size is not changing

Brian


// Requires FB 5.4.1 or later
include "ApplicationSettings.incl"
include "SystemCheck.incl"
include "Constants.gbl"

Library "Carbon"


include "Welcome.incl"
fn Welcome ("Welcome to StoryTeller")


local fn BuildMenus
'~'1
apple menu "About StoryTeller..."
menu _fileMenu, 0, _enable,  "File"
menu _fileMenu, _resetMenu, _enable, "New/N"
menu _fileMenu, 2, _disable, "-"
menu _fileMenu, _printMenu, _enable, "Print.../P"
edit menu 2
end fn

local fn BuildPopMenu( id as Long )
'~'1
dim as MenuRef  mRef
dim as Str255   s

Menu id, 0, _enable, ""
s = "Black;Yellow;Green;Cyan;Blue;Magenta;Red;White;-;Eraser;-;Select another color..."
Menu id, 1, _enable, s
mRef = fn GetMenuHandle( id )
DeleteMenu( id )
InsertMenu( mRef, -1 )

end fn

local fn BuildPopMenu1( id as Long )
'~'1
dim as MenuRef  mRef
dim as Str255   s

Menu id, 0, _enable, ""
s = "1;2;3;4;5;6;7;8;9;-;Select another size..."
Menu id, 1, _enable, s
mRef = fn GetMenuHandle( id )
DeleteMenu( id )
InsertMenu( mRef, -1 )

end fn


local fn BuildHIAboutBox
'~'1
dim as CFStringRef      keys(2), values(2)
dim as CFDictionaryRef  dict

keys(0)   = fn CFSTR( "HIAboutBoxName" )
values(0) = fn CFSTR( "StoryTeller" )

keys(1)   = fn CFSTR( "HIAboutBoxVersion" )
values(1) = fn CFSTR( "2010 Release 1" )

keys(2)   = fn CFSTR( "HIAboutBoxCopyright" )
values(2) = fn CFSTR( "StoryTeller © Copyright 2010 Brian Heibert.  Paint © Copyright by Ken Shmidheiser. Used with permission." )

dict = fn CFDictionaryCreate( 0, @keys(0), @values(0), 3, @kCFCopyStringDictionaryKeyCallBacks, 0 )
fn HIAboutBox( dict )
CFRelease( dict )

end fn

local fn BuildMainWindow
'~'1
dim as Rect                r
dim as RGBColor            rgb
dim as WindowAttributes    wa

wa = _kWindowCloseBoxAttribute¬
     _kWindowCollapseBoxAttribute

rgb.red   = 65535
rgb.green = 65535
rgb.blue  = 65535

//SetRect( r, 0, 0, 850, 693 )// Optional FB auto-centre
SetRect( r, 310, 77, 1160, 770 )
appearance window -_StoryTellerWnd,"StoryTeller", @r, _kDocumentWindowClass, wa
fn SetWindowBackground( rgb, _zTrue )


window _StoryTellerWnd
Color = _zBlack


end fn



local fn BuildToolWindow
'~'1
dim as WindowAttributes    wa
dim as Rect                r
dim as Boolean           @ bool : bool = _true
wa = _kWindowCloseBoxAttribute¬
     _kWindowCollapseBoxAttribute
    

//wa = //_kWindowToolbarButtonAttribute

SetRect( @r, 20, 80, 280, 340 )
Appearance Window -_toolWnd,¬
                 "Tools", @r, _kFloatingWindowClass, wa
fn SetWindowBackground( _kThemeActiveDialogBackgroundBrush, _false )


/*SetRect( @r, 20, 18, 240, 38 )
Appearance Button _colorPop,¬
                 ,, 101, -1,¬
                 "Select a pen color:", @r,¬
                 _kControlPopupButtonProc

SetRect ( @r, 20, 48, 280, 88)
Appearance Button _pensizePop,¬
                 ,, 102, -2,¬
                 "Select a pen size:", @r,¬
                  _kControlPopupButtonProc*/

TEXT _SysFont, 12, 0 ' size=12, style=bold
EDIT FIELD 1001, "Select a Pen Color:", (10,20)-(120,36), _statNoFramed 
APPEARANCE BUTTON _colorPop, , , 101, -1, "", (10,40)-(248,60), _kControlPopupButtonProc

EDIT FIELD 1002, "Select a Pen Size:", (10, 80)-(120, 96), _statNoFramed
APPEARANCE BUTTON _PenSizePop, , , 102, -1, "", (10,100)-(248,120), _kControlPopupButtonProc


window _toolWnd

end fn

local
local fn FileNew
fn BuildMainWindow
fn BuildToolWindow
end fn

local
local fn SelectAnotherColor
shutdown "Feature not implemented yet. Goodbye."
end fn

local
local fn SelectAnotherSize
shutdown "Feature not implemented yet. Goodbye."
end fn

local fn PaintArea
'~'1
dim as Point mPt
begin globals
dim as Point sPrevPt
end globals



long if ( fn Button )
GetMouse( @mPt )
long if ( sPrevPt.h% != _minInt )
plot sPrevPt.h%, sPrevPt.v% to mPt.h%, mPt.v%
end if
sPrevPt = mPt
xelse
sPrevPt.h% = _minInt
end if

end fn

local fn PrintWindow( whichWindow as Long )
'~'1
dim as Rect    r
dim as Pointer rgn, pict

Window whichWindow
SetRect( r, 0, 0, Window( _width ) - 1, Window( _height) - 1 )
rgn = fn NewRgn
GetClip( rgn )
ClipRect( r )
pict = fn GetPict( r)
long if ( pict )
Def Page
long if ( prcancel == _false )
Def LPrint
long if ( prcancel == _false )
Route _toPrinter
DrawPicture (  pict, r )
Route _toScreen
Close LPrint
end if
end if
KillPicture( pict )
xelse
stop "GetPict error"
end if
SetClip( rgn )
DisposeRgn( rgn )

end fn

/*BEGIN GLOBALS
DIM gRGBChoice AS RGBColor
END GLOBALS

CLEAR LOCAL
local fn SelectAnotherColor
DIM RGBIn   AS RGBColor
DIM RGBOut  AS RGBColor
DIM WherePt AS POINT
DIM Msg$
DIM Picked AS BOOLEAN
'---> Pick Color
WherePt.h% = 50
WherePt.v% = 50
Msg$       = "Pick a color (any color)!"
Picked    = FN GetColor (WherePt, Msg$, RGBIn, RGBOut)
'---> Pick Anything?
LONG IF Picked
gRGBChoice = RGBOut
#IF CarbonLib
FN DisplayColorValues(gRGBChoice)
#ENDIF
END IF

end fn*/

local fn DoPopup( menuID as long )
'~'1
dim as Long     mItem
dim as Str255   txtStr
dim as MenuRef  mRef
dim as Long     outWnd

mItem = button( menuID )
mRef  = button( menuID, _FBgetControlMenuHandle )
call GetMenuItemText( mRef, mItem, @txtStr )

outWnd = window( _StoryTellerWnd )
window output _StoryTellerWnd
select case ( txtStr )
case "Black"  : Color = _zBlack
case "Yellow" : Color = _zYellow
case "Green"  : Color = _zGreen
case "Cyan"   : Color = _zCyan
case "Blue"   : Color = _zBlue
case "Magenta": Color = _zMagenta
case "Red"    : Color = _zRed
case "White"  : Color = _zWhite
case "Eraser" : Color = _zWhite
case "Select another color..." : FN SelectAnotherColor
end select

if outWnd then window output outWnd

end fn

local fn DoPopup1( menuID as long )
'~'1
dim as Long     mItem
dim as Str255   txtStr
dim as MenuRef  mRef
dim as Long     outWnd

mItem = button( menuID )
mRef  = button( menuID, _FBgetControlMenuHandle )
call GetMenuItemText( mRef, mItem, @txtStr )

outWnd = window( _StoryTellerWnd )
window output _StoryTellerWnd
select case ( txtStr )
case "1"  : PenSize(1,1)
case "2" : PenSize(2,2)
case "3"  : PenSize(3,3)
case "4"   : PenSize(4,4)
case "5"   : PenSize(5,5)
case "6": PenSize(6,6)
case "7"    : PenSize (7,7)
case "8"  : PenSize (8,8)
case "9" : PenSize (9,9)
case "Select another size..." : FN SelectAnotherSize
//case "Select another color..." : FN SelectAnotherColor
end select

if outWnd then window output outWnd

end fn


local fn DoDialog
'~'1
dim as Long evnt, id

evnt = Dialog( 0 )
id   = Dialog( evnt )

select case ( evnt )
case _wndClose
select id
case _StoryTellerWnd : window close #_StoryTellerWnd
case _toolWnd : window close #_toolWnd
end select

case _btnClick
select id
case _colorPop : fn DoPopup( _colorPop )
end select

case _wndclick
select id
long if ( id == _StoryTellerWnd )
cursor _kThemeCrossCursor, _themeCursorStatic
xelse
cursor _kThemeArrowCursor, _themeCursorStatic
end if
end select

case _cursOverBtn
cursor _kThemeArrowCursor, _themeCursorStatic

end select

Window Output _StoryTellerWnd

end fn

local fn DoMenu
'~'1
dim as Long  menuID, itemID

menuID = menu( _menuID )
itemID = menu( _itemID )

select menuID
case _appleMenu : fn BuildHIAboutBox
case 1
select itemID
case _resetMenu
fn FileNew
window output _StoryTellerWnd : cls
case _printMenu : fn PrintWindow( _StoryTellerWnd )
end select
end select
menu

end fn

on dialog fn DoDialog
on menu   fn DoMenu

fn BuildMenus
fn BuildPopMenu( 101 )
fn BuildPopMenu1( 102 )
fn BuildMainWindow
fn BuildToolWindow
window _StoryTellerWnd
window _toolWnd
window output _StoryTellerWnd

poke long event - 8, 0
do
HandleEvents
fn PaintArea
until ( gFBQuit )