Thanks, Bernie
Eugen

On Mar 30, 2017, at 15:19, Bernie <bernie.fblist@...> wrote:


Eugen wrote:

SmartTabs Example is very smart, but how can I bind, let’s say, the button in tab 1 or the edit field in tab 2 by the margins?
I have rewrite “smartTabs + RadioGroup1.bas”, thus:

Yep, I wasn’t going to mention this, but SmartTabs has a bug. It doesn’t bind the panes to the tabs control. I’ve already sent a fix to Brian. Meanwhile, here’s a workaround.

// ---------------
include "NSLog.incl"
include "Tlbx AppThings.incl"
include "Tlbx HIView.incl"

_wWindow = 1
begin enum 1
_cTabs
_cRadioGroup
_cPush
_cStat
_cEdit
end enum

LOCAL
     DIM AS HILayoutInfo   layout
LOCAL FN ViewBindToParent( view as HIViewRef, left AS BOOLEAN, top AS BOOLEAN, right AS BOOLEAN, bottom AS BOOLEAN )
'~'1
layout.version = _kHILayoutInfoVersionZero
FN HIViewGetLayoutInfo( view, @layout )
IF ( top ) THEN layout.binding.top.kind = _kHILayoutBindTop
IF ( left ) THEN layout.binding.left.kind = _kHILayoutBindLeft
IF ( bottom ) THEN layout.binding.bottom.kind = _kHILayoutBindBottom
IF ( right ) THEN layout.binding.right.kind = _kHILayoutBindRight
FN HIViewSetLayoutInfo( view, @layout )
END FN
'~'5


// bind tab panes - workaround for smart tabs bug
void local fn TabsBindPanes( tabs as long )
'~'1
dim as HIViewRef   pane

pane = fn HIViewGetFirstSubview( button&(tabs) )
while ( pane )
fn ViewBindToParent( pane, _true, _true, _true, _true )
pane = fn HIViewGetNextView( pane )
wend
end fn


local fn BuildWindow
'~'1
dim as Rect        r

SetRect( r, 144, 132, 624, 492 )
appearance window -_wWindow, @"Smart Tabs + RadioGroup", @r, _kDocumentWindowClass, _kWindowCompositingAttribute + _kWindowResizableAttribute + _kWindowLiveResizeAttribute
fn SetWindowBackground( _kThemeActiveDialogBackgroundBrush, _zTrue )

SetRect( r, 20, 20, 460, 340 )
appearance button _cTabs,,,,, @"Tab 1;Tab 2", @r, _kControlTabLargeNorthProc
FN ViewBindToParent( BUTTON&( _cTabs ), _true, _true, _true, _true )

fn TabsBindPanes( _cTabs )

SetRect( r, 10, 10, 170, 80 )
appearance button _cRadioGroup,,, 3, 2, @"Alpha;Bravo;Charlie;Delta;Echo;Foxtrot", @r, _kControlRadioGroupProc
TabsAddButtonToTab( _cTabs, _cRadioGroup, 1 )

SetRect( r, 354, 251, 424, 271 )
appearance button _cPush,,,,, @"Button", @r, _kControlPushButtonProc
TabsAddButtonToTab( _cTabs, _cPush, 1 )
FN ViewBindToParent( BUTTON&( _cPush ), _false, _false, _true, _true )

SetRect( r, 10, 20, 80, 36 )
appearance button _cStat,,,,, @"Static Text", @r, _kControlStaticTextProc
TabsAddButtonToTab( _cTabs, _cStat, 2 )

SetRect( r, 91, 20, 275, 36 )
appearance button _cEdit,,,,, @"Edit Text", @r, _kControlEditUnicodeTextProc
TabsAddButtonToTab( _cTabs, _cEdit, 2 )
FN ViewBindToParent( BUTTON&( _cEdit ), _true, _true, _true, _true )
window _wWindow
end fn

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

ev = dialog( 0 )
id = dialog( ev )
select ( ev )
case _btnClick
select ( id )
case _cTabs
NSLog(@"Tab %ld selected", button(id))
case _cRadioGroup
NSLog(@"Radio %ld selected", button(id))
end select
end select
end fn

fn BuildWindow()

on dialog fn DoDialog

RunApplicationEventLoop()



--
To unsubscribe, send ANY message to: futurebasic-unsubscribe@... To access the list archives, go to: http://freegroups.net/groups/futurebasic/




--
To unsubscribe, send ANY message to: futurebasic-unsubscribe@... To access the list archives, go to: http://freegroups.net/groups/futurebasic/