![]() |
<< Index >> |
FutureBasic 5 |
appearance button | statement | |
|
appearance button
[-]
btnNum
[, [
state
][, [
value
][,¬
[
min
][, [
max
][, [
title
][,[
rect
][, [
type
]]]]]]]
appearance button
statement puts a new control in the current output window, or alters an existing control's characteristics. After you create a button using the appearance button
statement, you can use the dialog
function to determine whether the user has clicked it. You can use the button close
statement if you want to dispose of the button without closing the window.type
. If you later want to modify that button's characteristics, execute button
again with the same ID, and specify one or more of the other parameters (except type
, which cannot be altered). The button will be redrawn using the new characteristics that you specified; any parameter that you don't specify will not be altered.
btnNum |
a positive or negative integer whose absolute value is in the range 1 through 2147483647. The number you assign must be different from all other scroll bars or buttons in that window. Negative values build invisible buttons. Positive values build visible buttons. | |
state |
The state may be:_grayBtn (0/disabled)_activebtn (1/default/active)_markedBtn (2/selected) |
|
value , min , max |
generally an integer value for the initial, minimum, and maximum values of a control | |
title |
a string expression. As of FB 5.7.102 this must be a Core Foundation(CF) String. This parameter also serves to set the text of buttons defined with _kControlStaticTextProc or _kControlEditUnicodeTextProc . |
|
rect |
a rectangle in local window coordinates. You can express it in either of two forms:(x1,y1)-(x2,y2) Two diagonally opposite corner points.@rectAddr Pointer variable which points to a Rect type. |
|
type |
any of the many types listed in the following text. |
state |
_activeBtn |
|
value |
1 | |
min |
0 | |
max |
1 | |
title |
null string |
button -1
or appearance button
-1
and you can deactivate the control with either button 1
, _grayBtn
or appearance button
1
, _grayBtn
. Buttons are commonly hidden and revealed as tab panes are brought into or removed from view. The same is true of panes that are changed in response to items such as group pop-up placards.x = button( id )
orx = button( id, _FBGetCtlRawValue )
actualSize = fn ButtonDataSize( btnID, part, tagName )
pascalString = fn ButtonTextPascalString( btnID )
CFStringRef = fn ButtonCopyText( btnID )
fn ButtonSetText( btnID, @"My Button" )
![]() |
Push buttons |
/*
appearance button
[-] btnNum[, [state][, [value][,¬
[min][, [max][, [title][,[rect][, [type]]]]]]]
*/
appearance button
btnNum,_activeBtn,0,0,1,¬
"_kControlPushButtonProc",@r,_kControlPushButtonProc
appearance button
btnNum,_activeBtn,0,0,1,¬
"_kControlBevelButtonSmallBevelProc",@r,¬
_kControlBevelButtonSmallBevelProc
appearance button
btnNum,_activeBtn,0,0,1,¬
"_kControlBevelButtonNormalBevelProc",@r,¬
_kControlBevelButtonNormalBevelProc
appearance button
btnNum,_activeBtn,0,0,1,¬
"_kControlBevelButtonLargeBevelProc",@r,¬
_kControlBevelButtonLargeBevelProc
// "value" is menu ID
appearance button
btnNum,_activeBtn,101,0,1,¬
"Bevel+_kControlBevelButtonMenuOnRight",@r,¬
_kControlBevelButtonSmallBevelProc + ¬
_kControlBevelButtonMenuOnRight
// max value is cicn ID
appearance button
btnNum,_activeBtn,0,0,256,¬
"_kControlPushButRightIconProc",@r, ¬
_kControlPushButRightIconProc
appearance button
btnNum,_activeBtn,0,0,256,¬
"_kControlPushButLeftIconProc",@r,¬
_kControlPushButLeftIconProc
// get rect from pict to determine button size
h = fn GetPicture(256)
long if h
pR;8 = @h..picFrame%
OffsetRect(pR,-pR.left,-pR.top)
OffsetRect(pR,r.left,r.top)
// control "value" is pict ID
appearance button
btnNum,_activeBtn,256,0,1,¬
"_kControlPictureProc",@pR,_kControlPictureProc
end if
_kControlBevelButtonLargeBevelProc + _kControlBevelButtonMenuOnRight
_kControlIconProc
_kControlIconNoTrackProc
_kControlIconSuiteProc
_kControlIconSuiteNoTrackProc
_kControlPictureNoTrackProc
appearance button
btnNum,_activeBtn,0,0,1,¬
"_kControlGroupBoxTextTitleProc",@r,¬
_kControlGroupBoxTextTitleProc
appearance button
btnNum,_activeBtn,0,0,1,¬
"_kControlGroupBoxSecondaryTextTitleProc",@r,¬
_kControlGroupBoxSecondaryTextTitleProc
appearance button
btnNum,_activeBtn,1,0,1,¬
"_kControlGroupBoxCheckBoxProc",@r,¬
_kControlGroupBoxCheckBoxProc
appearance button
btnNum,_activeBtn,1,0,1,¬
"_kControlGroupBoxSecondaryCheckBoxProc",@r,¬
_kControlGroupBoxSecondaryCheckBoxProc
// min value is menu ID
appearance button
btnNum,_activeBtn,1,101,1,¬
"",@r,_kControlGroupBoxPopUpButtonProc
appearance button
btnNum,_activeBtn,1,101,1,¬
"",@r,_kControlGroupBoxSecondaryPopUpButtonProc
appearance button
btnNum,_activeBtn,1,0,1,¬
"",@r,_kControlPlacardProc
appearance button
btnNum,_activeBtn,1,0,1,¬
"",@r,_kControlSeparatorLineProc
![]() |
Groups and Separators in MacOS X |
button()
function) of the parent button.dim
r as Rect
dim
pR as Rect
dim
h as Handle
dim
btnNum as long
dim
err as OSStatus
// setup
_btnHt = 20
_btnWd = 80
_btnMargin = 8
btnNum = 1
// create a window
SetRect(r,0,0,_btnWd_btnMargin_btnMargin,120)
appearance window
1,,@r
err = fn SetThemeWindowBackground (window( _wndPointer ),¬
_kThemeActiveDialogBackgroundBrush,_zTrue )
// button #1 is the papa button
// note that the parent button has sufficient space so that
// it holds all embedded buttons within its own rectangle
SetRect(r,_btnMargin,_btnMargin,¬
_btnMargin_btnWd,(_btnMargin_btnHt)*3)
appearance button btnNum,_activeBtn,0,0,1,¬
"",@r,_kControlRadioGroupProc
btnNum ++
SetRect(r,_btnMargin,_btnMargin,_btnMargin_btnWd,¬
_btnMargin_btnHt)
appearance button btnNum,_activeBtn,0,0,1,¬
"Radio 1",@r,_kControlRadioButtonProc
def EmbedButton(btnNum,1)
btnNum ++ : offsetrect(r,0,_btnHt_btnMargin)
appearance button btnNum,_activeBtn,0,0,1,¬
"Radio 2",@r,_kControlRadioButtonProc
def EmbedButton(btnNum,1)
btnNum ++ : offsetrect(r,0,_btnHt_btnMargin)
appearance button btnNum,_activeBtn,0,0,1,¬
"Radio 3",@r,_kControlRadioButtonProc
def EmbedButton(btnNum,1)
local fn handleDialog
dim as long action,reference
action = dialog(0)
reference = dialog(action)
long if action = _btnclick
MoveTo(8,100)
print "Current Button "; button(1);
end if
end fn
on dialog fn handleDialog
do
HandleEvents
until gFBQuit
![]() |
Embedded Buttons |
_kControlCheckBoxMixedValue = 2
) to the control's range._kControlCheckBoxUncheckedValue
_kControlCheckBoxCheckedValue
_kControlCheckBoxMixedValue
![]() |
Check Boxes |
appearance button
btnNum,_activeBtn,¬
_kControlCheckBoxUncheckedValue,0,¬
_kControlCheckBoxMixedValue,¬
"Unchecked Check Box",@r,_kControlCheckBoxProc
appearance button
btnNum,_activeBtn,¬
_kControlCheckBoxMixedValue,0,¬
_kControlCheckBoxMixedValue,¬
"Mixed Value Check Box",@r,_kControlCheckBoxProc
appearance button
btnNum,_activeBtn,¬
_kControlCheckBoxCheckedValue,0,¬
_kControlCheckBoxMixedValue,¬
"Checked Check Box",@r,_kControlCheckBoxProc
button btnNum,state
to tick and untick group buttons of type _kControlGroupBoxCheckBoxProc
and _kControlGroupBoxSecondaryCheckBoxProc
. Use appearance button
btnNum,,state-1
instead. (button
btnNum,0
and button
btnNum,1
will however inactivate and activate the button respectively).![]() |
Wait States |
appearance button
btnNum,_activeBtn,0,0,1,,@r,¬
_kControlChasingArrowsProc
appearance button
btnNum,_activeBtn,50,0,100,,@r,¬
_kControlProgressBarProc
appearance button
btnNum,,51
appearance button
btnNum,_activeBtn,1,0,1,,@r,¬
_kControlProgressBarProc
dim b as Boolean
dim err as OSStatus
b = _true
err = fn SetControlData(btnNum, 0,¬
_kControlProgressBarIndeterminateTag,sizeof(Boolean), @b)
_kControlSliderProc
. Additional parameters are added to this constant to add features to the control. The following constants are available for slider variations:
_kControlSliderLiveFeedback
_kControlSliderHasTickMarks
_kControlSliderReverseDirection
_kControlSliderNonDirectional
_kControlSliderProc + ¬
_kControlSliderHasTickMarks + ¬
_kControlSliderReverseDirection
![]() |
Sliders and Little Arrows |
appearance button
btnNum,_activeBtn,1,1,10,,@r,¬
_kControlSliderProc
appearance button
btnNum,_activeBtn,10,1,10,,@r,¬
_kControlSliderProc_kControlSliderHasTickMarks
appearance button
btnNum,_activeBtn,1,1,10,,@r,¬
_kControlSliderProc_kControlSliderNondirectional
appearance button
btnNum,_activeBtn,1,1,10,,@r,¬
_kControlSliderProc_kcontrolSliderReverseDirection
appearance button
btnNum,_activeBtn,10,1,10,,@r,¬
_kControlSliderProc_kControlSliderHasTickMarks +¬
_kcontrolSliderReverseDirection
// vert orientation
appearance button
btnNum,_activeBtn,10,1,10,,@r,¬
_kControlSliderProc
appearance button
btnNum,_activeBtn,10,1,10,,@r,¬
_kControlSliderProc_kControlSliderNondirectional
appearance button
btnNum,_activeBtn,10,1,10,,@r,¬
_kControlSliderProc_kControlSliderHasTickMarks +¬
_kcontrolSliderReverseDirection
appearance button
btnNum,_activeBtn,0,0,1,,@r,¬
_kControlLittleArrowsProc
appearance button
btnNum,_activeBtn,menuID,0,1,¬
"Bevel+_kControlBevelButtonMenuOnRight",¬
@r,_kControlBevelButtonSmallBevelProc + ¬
_kControlBevelButtonMenuOnRight
button
function commands may be used to extract information from the control.handle = button(btnNum, _FBgetBevelControlMenuHandle)
currentItem = button(btnNum, _FBgetBevelControlMenuVal)
previousItem = button(btnNum, _FBgetBevelControlLastMenu)
![]() |
Pop-Up Menu Buttons |
def SetButtonData (btnNum, _kControlMenuPart, _kControlPopupButtonMenuHandleTag, sizeof( handle), @yourMenuHndl )
). You can pass -1 in the max
parameter to have the control calculate the width of the title on its own instead of guessing and then tweaking to get it right. It adds the appropriate amount of space between the title and the popup. A maximum value of zero means, "Don't show the title."appearance button
btnNum,,value,min,max
appearance button
btnNum,_activeBtn,0,101,-1,"Pop Title:"¬
,@r,_kControlPopUpButtonProc
button
function provides access to the menu handle. Remember: standard and beveled pop-up menus do not use the same button
function constants.menuHandle = button(btnNum, _FBgetControlMenuHandle)
mItem = button(btnNum)
button
statement with the positive version of the reference number.def SetButtonData
. Then a user pane is inserted for each tab. These are embedded in the tab shell using def EmbedButton
. Buttons that will reside in each user pane are created and embedded in the user pane.dialog
handler that maintains the buttons.![]() |
Tab Buttons |
_kControlTabLargeProc
_kControlTabSmallProc
_kControlTabLargeNorthProc
_kControlTabSmallNorthProc
_kControlTabLargeSouthProc
_kControlTabSmallSouthProc
_kControlTabLargeEastProc
_kControlTabSmallEastProc
_kControlTabLargeWestProc
_kControlTabSmallWestProc
_kControlTabSmallProc
, but you should experiment with other types to see the results.dim r as Rect
dim x as long
dim btnNum as long
dim infoRec as ControlTabInfoRec
// Names of the individual tabs
_tabCount = 3
dim as Str255 tabTitles(_tabCount)
tabTitles(1) = "One"
tabTitles(2) = "Two"
tabTitles(3) = "Three"
// create a window
SetRect( r, 0, 0, 300, 200 )
appearance window 1, "Tabs", @r, _kDocumentWindowClass
def SetWindowBackground( _kThemeActiveDialogBackgroundBrush,¬
_zTrue )
/*
Button 100 is the tab 'shell'. In this example, it is made to be the full size of the window, less a small margin. Buttons 1, 2, & 3 will be the embedded user panes that contain information to be displayed for each tab.
A tab control is usually built as invisible. This is because the information contained in the tabs will be modified as the control is being constructed. Making it visible after all modifications have been completed provides a cleaner window build.
*/
_tabBtnRef = 100
_btnMargin = 8
InsetRect( r, _btnMargin, _btnMargin )
appearance button -_tabBtnRef, 0, 0, 2, _tabCount,, @r,¬
_kControlTabSmallNorthProc
/*
Fix the tab to use a small font. This is not a requirement, but it is information which many will find useful. */
dim cfsRec as ControlFontStyleRec
cfsRec.flags = _kControlUseSizeMask
cfsRec.size = 9
def SetButtonFontStyle( _tabBtnRef, cfsRec )
/*
Adapt a rectangle that can be used for the content area of each tab.
*/
InsetRect( r, _btnMargin, _btnMargin )
r.top += 20
// Loop thru the tabs and set up individual panes
for x = 1 to _tabCount
infoRec.version = _kControlTabInfoVersionZero
infoRec.iconSuiteID = 0
infoRec.Name = tabTitles$(x)
def SetButtonData ( _tabBtnRef, x, _kControlTabInfoTag, ¬
sizeof( infoRec ), infoRec )
/*
Each of these panes is a button that is embedded in the
tab button. The first one will be visible. All others will
be invisible because information from only one tab at a time
can be viewed.
Remember: negative button reference numbers make
invisible buttons.
Once a new pane button (_kControlUserPaneProc) is created,
it is embedded into the larger tab button.
*/
if x != 1 then btnNum = -x else btnNum = x
appearance button btnNum,,¬
_kControlSupportsEmbedding,,,, @r,¬
_kControlUserPaneProc
def EmbedButton( x, _tabBtnRef )
next
/*
Now we have a tab shell (_tabBtnRef = 100) and in it we have embedded three tab panes (1,2, and 3). To demonstrate how these can contain separate info, we will place a simple button in each of the three panes.
Button 10 in pane 1
Button 20 in pane 2
Button 30 in pane 3
*/
InsetRect( r, 32, 32 )
r.bottom = r.top + 24
r.right = r.left + 128
appearance button 10, _activeBtn,,,,¬
"Pane #1", @r, _kControlPushButtonProc def EmbedButton( 10, 1 )
OffsetRect( r, 8, 8 )
appearance button 20, _activeBtn,,,,¬
"Pane #2", @r, _kControlPushButtonProc def EmbedButton( 20, 2 )
OffsetRect( r, 8, 8 )
appearance button 30, _activeBtn,,,,¬
"Pane #3", @r, _kControlPushButtonProc
def EmbedButton( 30, 3 )
button _tabBtnRef, 1 // make visible
/*
Only one event (a button click in the tab shell button)
gets a response from out dialog routine. The value returned
(1,2, or 3) corresponds to buttons 1,2, or 3 that were
embedded into the tab parent.
Our only action is to show (button j) or hide (button -j)
the proper tab pane. All controls embedded in those panes
will automatically be shown or hidden.
*/
local fn doDialog
dim as long action, reference, j
action = dialog(0)
reference = dialog(action)
long if action == _btnClick and reference == _tabBtnRef
for j = 1 to _tabCount
long if j == button(_tabBtnRef)
button j
xelse
button -j
end if
next
end if
end fn
on dialog fn doDialog
do
HandleEvents
until gFBQuit