[futurebasic] change what appears in popupmenu

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

From: Ken Shmidheiser <kshmidheiser@...>
Date: Wed, 27 Jan 2010 11:59:29 -0500
Brian wrote:

>I got a problem...


_storyTeller = 1

begin enum 1
_colorPop
_penPop
end enum

local fn BuildPopMenu( id as long )
'~'1
dim as MenuRef m

select ( id )
case 101
menu id, 0, _enable, ""
menu id, 1, _enable, "Black;Yellow;Green;Cyan;Blue;Magenta;Red"
case 102
menu id, 0, _enable, ""
menu id, 1, _enable, "1; 2; 3; 4; 5; 6; 7; 8; 9"
end select

m = fn GetMenuHandle( id )
DeleteMenu( id )
InsertMenu( m, -1 )

end fn

local fn BuildstoryTeller
'~'1
dim as Rect                r
dim as WindowAttributes    wa

wa = _kWindowCloseBoxAttribute¬
      _kWindowCollapseBoxAttribute¬
      _kWindowFullZoomAttribute¬
      _kWindowResizableAttribute

//SetRect( r, 0, 0, 303, 113 )// Optional FB auto-centre
SetRect( r, 0, 44, 303, 157 )
appearance window -_storyTeller, "Popup Test", @r, _kDocumentWindowClass, wa
fn SetWindowBackground( _kThemeActiveDialogBackgroundBrush, _zTrue )


SetRect( r, 30, 20, 251, 40 )
appearance button _colorPop,,, 101, -1, "Select 
Pen Color:", @r, _kControlPopupButtonProc

SetRect( r, 37, 57, 251, 77 )
appearance button _penPop,,, 102, -1, "Select Pen 
Size:", @r, _kControlPopupButtonProc

appearance window _storyTeller

end fn

local fn DoColorPopup
'~'1
dim as Long     mItem
dim as Long     outWnd

mItem = button( _colorPop )

outWnd = window( _storyteller)
window output _storyteller
select case ( mItem )
case 1 : Color = _zBlack   : cls : print "Black selected"
case 2 : Color = _zYellow  : cls : print "Yellow selected"
case 3 : Color = _zGreen   : cls : print "Green selected"
case 4 : Color = _zCyan    : cls : print "Cyan selected"
case 5 : Color = _zBlue    : cls : print "Blue selected"
case 6 : Color = _zMagenta : cls : print "Magenta selected"
case 7 : Color = _zRed     : cls : print "Red selected"
end select

if outWnd then window output outWnd

end fn

local fn DoPenPopUp
'~'1
dim as Long     mItem
dim as Long     outWnd

mItem = button( _penPop )

outWnd = window( _storyteller)
window output _storyteller
select case (mItem)
case 1: PenSize( 1,1) : cls : print "Pen 1 selected"
case 2: PenSize( 2,2) : cls : print "Pen 2 selected"
case 3: PenSize( 3,3) : cls : print "Pen 3 selected"
case 4: PenSize( 4,4) : cls : print "Pen 4 selected"
case 5: PenSize( 5,5) : cls : print "Pen 5 selected"
case 6: PenSize( 6,6) : cls : print "Pen 6 selected"
case 7: PenSize( 7,7) : cls : print "Pen 7 selected"
case 8: PenSize( 8,8) : cls : print "Pen 8 selected"
case 9: PenSize( 9,9) : cls : print "Pen 9 selected"
end select

end fn

local fn DoDialog
'~'1
dim as long ev, id

ev = dialog( 0 )
id = dialog( ev )

select ev
case _wndClick : window id
case _wndClose : end
case _btnClick
select window( _outputWnd )
case _storyTeller
select id
case _colorPop : fn DoColorPopup
case _penPop   : fn DoPenPopup
end select
end select
end select

end fn

on dialog fn DoDialog
fn BuildPopMenu( 101 )
fn BuildPopMenu( 102 )
fn BuildstoryTeller()
cls : print "Black selected"

do
HandleEvents
until gFBQuit