[futurebasic] Re: pop-up bevel buttons in OS X

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : June 2003 : Group Archive : Group : All Groups

From: Ken Shmidheiser <kshmidheiser@...>
Date: Mon, 30 Jun 2003 09:36:03 -0400
Here's a more elegant rewrite of my earlier 
posted bevel button popup demo incorporating 
Robert Purves' suggestion to use the toolbox call 
SetBevelButtonMenuValue. This code also gets rid 
of the noxious global menu names.

Ken

p.s. Please watch for e-mail line breaks and lost 
constant underscores on the Associate server


'~'A
'                       Runtime : Rntm Appearance.Incl
'                           CPU : Carbon
'                      Debugger : Off
'               DIM'd Vars Only : On
'              No Re-DIM'd Vars : On
'                    CALL Req'd : Off
'                 Register Vars : On
'                MacsBug Labels : On
'           Ary Bounds Checking : On
'                     QB Labels : Off
'                 Optimize STR# : On
'         Make Line Start Table : Off
'                 Show Warnings : On
'~'B

/*

      Check bevel button item on initialization
      By Bernie Wylde
      6-20-03

      Revised by
      Ken Shmidheiser
      6-20-03

      Rewritten to incorporate Robert Purves
      suggestion to use the toolbox function
      SetBevelButtonMenuValue to set initial
      menu value, and also to eliminate the use
      of global bevel button popup menu names

      Ken Shmidheiser
      6-30-03

*/

toolbox fn SetBevelButtonMenuValue( ControlRef inButton,¬
                                          SInt16 inValue ) = OSErr

// Automatically read bevel button menu string and transfer to bevel button
local fn BevelBtn( whichBtn as long )
dim as handle @ menuTextH
dim as str255   menuTextStr
dim as long     value

menuTextH = button( whichBtn, _FBgetBevelControlMenuHandle )
     value = button( whichBtn, _FBgetBevelControlMenuVal )

GetMenuItemText( menuTextH, value, menuTextStr )

button 1,,menuTextStr

end fn

// Use this function to set menu at at item other than 1 on initialization
local mode
local fn SetBevelPopupMenuValue( btnID as long, newVal as int )
dim as OSErr  err

err = fn SetBevelButtonMenuValue( button&( btnID ), newVal )

fn BevelBtn( btnID )

end  fn

local fn BuildMenu

menu 128, 0, _enable,""
menu 128, 1, _enable, "Lily"
menu 128, 2, _enable, "Rosemary"
menu 128, 3, _enable, "Jack of Hearts"

end fn

local fn BuildWnd
dim as rect r

setrect( r, 150, 150, 400, 300 )
appearance window 1,"Bevel Test", @r, _kMovableModalWindowClass
def SetWindowBackground( _kThemeActiveDialogBackgroundBrush,_zTrue)

setrect( r, 60, 30, 190, 51 )
appearance button 1, _activeBtn, 128, 0, 1, ,¬
@r, _kControlBevelButtonLargeBevelProc

// Set newly built bevel button menu item to 3
fn SetBevelPopupMenuValue( 1, 3 )

end fn

local fn doDialog
if dialog(0) == _btnClick then fn BevelBtn( 1 )
end fn

fn BuildMenu
fn BuildWnd

on dialog fn doDialog

do
handleevents
until gFBQuit
end