if ( m_bmpNormal.Ok() )
bmap = (wxBitmapRefData*) ( m_bmpNormal.GetRefData()) ;
+ ControlButtonContentInfo info ;
+ wxMacCreateBitmapButton( &info , m_bmpNormal ) ;
+
Rect bounds = wxMacGetBoundsForControl( this , pos , size ) ;
- m_macControl = (WXWidget) ::NewControl( MAC_WXHWND(parent->MacGetTopLevelWindowRef()) , &bounds , "\p" , true , 0 ,
- kControlBehaviorOffsetContents +
- ( bmap && bmap->m_bitmapType == kMacBitmapTypeIcon ?
- kControlContentCIconHandle : kControlContentPictHandle ) , 0,
- (( style & wxBU_AUTODRAW ) ? kControlBevelButtonSmallBevelProc : kControlBevelButtonNormalBevelProc ), (long) this ) ;
+ verify_noerr ( CreateBevelButtonControl( MAC_WXHWND(parent->MacGetTopLevelWindowRef()) , &bounds , CFSTR("") ,
+ (( style & wxBU_AUTODRAW ) ? kControlBevelButtonSmallBevel : kControlBevelButtonNormalBevel ) ,
+ kControlBehaviorOffsetContents , &info , 0 , 0 , 0 , (ControlRef*) &m_macControl ) ) ;
+
wxASSERT_MSG( (ControlRef) m_macControl != NULL , wxT("No valid mac control") ) ;
- ControlButtonContentInfo info ;
- wxMacCreateBitmapButton( &info , m_bmpNormal ) ;
- if ( info.contentType != kControlNoContent )
- {
- ::SetControlData( (ControlRef) m_macControl , kControlButtonPart , kControlBevelButtonContentTag , sizeof(info) , (char*) &info ) ;
- }
MacPostControlCreate(pos,size) ;
return TRUE;
Rect bounds = wxMacGetBoundsForControl( this , pos , size ) ;
if ( label.Find('\n' ) == wxNOT_FOUND && label.Find('\r' ) == wxNOT_FOUND)
{
- m_macControl = (WXWidget) ::NewControl( MAC_WXHWND(parent->MacGetTopLevelWindowRef()) , &bounds , "\p" , true , 0 , 0 , 1,
- kControlPushButtonProc , (long) this ) ;
+ verify_noerr ( CreatePushButtonControl( MAC_WXHWND(parent->MacGetTopLevelWindowRef()) , &bounds , CFSTR("") , (ControlRef*) &m_macControl ) ) ;
}
else
{
ProcessCommand (event);
}
-void wxButton::MacHandleControlClick( WXWidget WXUNUSED(control) , wxInt16 controlpart , bool WXUNUSED(mouseStillDown) )
+wxInt32 wxButton::MacControlHit(WXEVENTHANDLERREF WXUNUSED(handler) , WXEVENTREF WXUNUSED(event) )
{
- if ( controlpart != kControlNoPart )
- {
- wxCommandEvent event(wxEVT_COMMAND_BUTTON_CLICKED, m_windowId );
- event.SetEventObject(this);
- ProcessCommand(event);
- }
+ wxCommandEvent event(wxEVT_COMMAND_BUTTON_CLICKED, m_windowId );
+ event.SetEventObject(this);
+ ProcessCommand(event);
+ return noErr ;
}
m_label = label ;
- SInt16 maxValue = 1 /* kControlCheckboxCheckedValue */;
+ SInt32 maxValue = 1 /* kControlCheckboxCheckedValue */;
if (style & wxCHK_3STATE)
- {
maxValue = 2 /* kControlCheckboxMixedValue */;
- }
-
Rect bounds = wxMacGetBoundsForControl( this , pos , size ) ;
- m_macControl = (WXWidget) ::NewControl( MAC_WXHWND(parent->MacGetTopLevelWindowRef()) , &bounds , "\p" , true , 0 , 0 , maxValue,
- kControlCheckBoxProc , (long) this ) ;
+ verify_noerr( CreateCheckBoxControl(MAC_WXHWND(parent->MacGetTopLevelWindowRef()), &bounds ,
+ CFSTR("") , 0 , false , (ControlRef*) &m_macControl ) ) ;
+
+ SetControl32BitMaximum( (ControlRef) m_macControl , maxValue ) ;
MacPostControlCreate(pos,size) ;
MacRedrawControl() ;
}
-void wxCheckBox::MacHandleControlClick( WXWidget WXUNUSED(control), wxInt16 WXUNUSED(controlpart) , bool WXUNUSED(mouseStillDown) )
+wxInt32 wxCheckBox::MacControlHit(WXEVENTHANDLERREF WXUNUSED(handler) , WXEVENTREF WXUNUSED(event) )
{
wxCommandEvent event(wxEVT_COMMAND_CHECKBOX_CLICKED, m_windowId );
wxCheckBoxState state = Get3StateValue();
{
state = wxCHK_UNCHECKED;
}
- Set3StateValue(state);
+ Set3StateValue(state);
event.SetInt(state);
event.SetEventObject(this);
ProcessCommand(event);
+
+ return noErr ;
}
// Bitmap checkbox
}
listDef.u.userProc = macCheckListDefUPP ;
-#if TARGET_CARBON
Size asize;
SetControlReference( (ControlRef) m_macControl, (long) this);
SetControlVisibility( (ControlRef) m_macControl, false, false);
-#else
-
- long result ;
-
- wxStAppResource resload ;
- m_macControl = (WXWidget) ::NewControl( MAC_WXHWND(parent->MacGetTopLevelWindowRef()) , &bounds , "\p" , true ,
- kwxMacListWithVerticalScrollbar , 0 , 0,
- kControlListBoxProc , (long) this ) ;
- ::GetControlData( (ControlRef) m_macControl , kControlNoPart , kControlListBoxListHandleTag ,
- sizeof( ListHandle ) , (char*) &m_macList , &result ) ;
- HLock( (Handle) m_macList ) ;
- ldefHandle ldef ;
- ldef = (ldefHandle) NewHandle( sizeof(ldefRec) ) ;
- if ( (**(ListHandle)m_macList).listDefProc != NULL )
- {
- (**ldef).instruction = 0x4EF9; /* JMP instruction */
- (**ldef).function = (void(*)()) listDef.u.userProc;
- (**(ListHandle)m_macList).listDefProc = (Handle) ldef ;
- }
-
- Point pt = (**(ListHandle)m_macList).cellSize ;
- pt.v = 14 ;
- LCellSize( pt , (ListHandle)m_macList ) ;
- LAddColumn( 1 , 0 , (ListHandle)m_macList ) ;
-#endif
OptionBits options = 0;
if ( style & wxLB_MULTIPLE )
{
return false;
Rect bounds = wxMacGetBoundsForControl( this , pos , size ) ;
- m_macControl = (WXWidget) ::NewControl( MAC_WXHWND(parent->MacGetTopLevelWindowRef()) , &bounds , "\p" , true , 0 , -12345 , 0 ,
- kControlPopupButtonProc + kControlPopupFixedWidthVariant , (long) this ) ;
+
+ verify_noerr ( CreatePopupButtonControl( MAC_WXHWND(parent->MacGetTopLevelWindowRef()) , &bounds , CFSTR("") ,
+ -12345 , false /* no variable width */ , 0 , 0 , 0 , (ControlRef*) &m_macControl ) ) ;
m_macPopUpMenuHandle = NewUniqueMenu() ;
SetControlData( (ControlRef) m_macControl , kControlNoPart , kControlPopupButtonMenuHandleTag , sizeof( MenuHandle ) , (char*) &m_macPopUpMenuHandle) ;
return (wxClientData *)DoGetItemClientData(n);
}
-void wxChoice::MacHandleControlClick( WXWidget control , wxInt16 controlpart , bool WXUNUSED(mouseStillDown))
+wxInt32 wxChoice::MacControlHit(WXEVENTHANDLERREF WXUNUSED(handler) , WXEVENTREF WXUNUSED(event) )
{
wxCommandEvent event(wxEVT_COMMAND_CHOICE_SELECTED, m_windowId );
int n = GetSelection();
event.SetClientData( GetClientData(n) );
ProcessCommand(event);
}
+ return noErr ;
}
wxSize wxChoice::DoGetBestSize() const
}
-void wxComboBox::MacHandleControlClick( WXWidget WXUNUSED(control) , wxInt16 WXUNUSED(controlpart) , bool WXUNUSED(mouseStillDown))
+wxInt32 wxComboBox::MacControlHit(WXEVENTHANDLERREF WXUNUSED(handler) , WXEVENTREF WXUNUSED(event) )
{
wxCommandEvent event(wxEVT_COMMAND_COMBOBOX_SELECTED, m_windowId );
event.SetInt(GetSelection());
event.SetEventObject(this);
event.SetString(GetStringSelection());
ProcessCommand(event);
+ return noErr ;
}
}
Rect bounds = wxMacGetBoundsForControl( this , pos , size ) ;
- m_macControl = (WXWidget) ::NewControl( MAC_WXHWND(parent->MacGetTopLevelWindowRef()) , &bounds , "\p" , true , 0 , 0 , range,
- kControlProgressBarProc , (long) this ) ;
-
+ verify_noerr ( CreateProgressBarControl( MAC_WXHWND(parent->MacGetTopLevelWindowRef()) , &bounds ,
+ m_gaugePos , 0 , m_rangeMax , false /* not indeterminate */ , (ControlRef*) &m_macControl ) ) ;
+
MacPostControlCreate(pos,size) ;
return TRUE;
BEGIN_EVENT_TABLE(wxNotebook, wxControl)
EVT_NOTEBOOK_PAGE_CHANGED(-1, wxNotebook::OnSelChange)
- EVT_MOUSE_EVENTS(wxNotebook::OnMouse)
EVT_SIZE(wxNotebook::OnSize)
EVT_SET_FOCUS(wxNotebook::OnSetFocus)
tabsize = kControlSizeSmall;
}
- ::CreateTabsControl( MAC_WXHWND(parent->MacGetTopLevelWindowRef()) , &bounds , tabsize , tabstyle, 0, NULL, (ControlRef*) &m_macControl);
+ verify_noerr ( CreateTabsControl( MAC_WXHWND(parent->MacGetTopLevelWindowRef()) , &bounds ,
+ tabsize , tabstyle, 0, NULL, (ControlRef*) &m_macControl) );
MacPostControlCreate(pos,size) ;
return TRUE ;
SetControl32BitValue( (ControlRef) m_macControl , m_nSelection + 1 ) ;
}
-
-void wxNotebook::OnMouse( wxMouseEvent &event )
+wxInt32 wxNotebook::MacControlHit(WXEVENTHANDLERREF WXUNUSED(handler) , WXEVENTREF WXUNUSED(event) )
{
- if ( (ControlRef) m_macControl == NULL )
- {
- event.Skip() ;
- return ;
- }
-
- if (event.GetEventType() == wxEVT_LEFT_DOWN || event.GetEventType() == wxEVT_LEFT_DCLICK )
+ OSStatus status = eventNotHandledErr ;
+
+ SInt32 newSel = GetControl32BitValue( (ControlRef) m_macControl ) - 1 ;
+ if ( newSel != m_nSelection )
{
- int x = event.m_x ;
- int y = event.m_y ;
-
-#if TARGET_API_MAC_OSX
- // OS Needs it in window not client coordinates
- wxPoint origin = GetClientAreaOrigin() ;
- x += origin.x ;
- y += origin.y ;
-#else
- // OS Needs it in tlw content area coordinates
- MacClientToRootWindow( &x , &y ) ;
-#endif
-
- ControlRef control ;
- Point localwhere ;
- SInt16 controlpart ;
-
- localwhere.h = x ;
- localwhere.v = y ;
+ wxNotebookEvent changing(wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGING, m_windowId,
+ newSel , m_nSelection);
+ changing.SetEventObject(this);
+ GetEventHandler()->ProcessEvent(changing);
- short modifiers = 0;
-
- if ( !event.m_leftDown && !event.m_rightDown )
- modifiers |= btnState ;
-
- if ( event.m_shiftDown )
- modifiers |= shiftKey ;
-
- if ( event.m_controlDown )
- modifiers |= controlKey ;
-
- if ( event.m_altDown )
- modifiers |= optionKey ;
-
- if ( event.m_metaDown )
- modifiers |= cmdKey ;
-
- control = (ControlRef) m_macControl ;
- if ( control && ::IsControlActive( control ) )
+ if(changing.IsAllowed())
{
- {
- wxNotebookEvent changing(wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGING, m_windowId,
- ::GetControl32BitValue(control) - 1, m_nSelection);
- changing.SetEventObject(this);
- GetEventHandler()->ProcessEvent(changing);
+ wxNotebookEvent event(wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED, m_windowId,
+ newSel, m_nSelection);
+ event.SetEventObject(this);
- if(changing.IsAllowed())
- {
- controlpart = ::HandleControlClick(control, localwhere, modifiers,
- (ControlActionUPP) -1);
- wxTheApp->s_lastMouseDown = 0 ;
-
- wxNotebookEvent event(wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED, m_windowId,
- ::GetControl32BitValue(control) - 1, m_nSelection);
- event.SetEventObject(this);
-
- GetEventHandler()->ProcessEvent(event);
- }
- }
+ GetEventHandler()->ProcessEvent(event);
+ }
+ else
+ {
+ SetControl32BitValue( (ControlRef) m_macControl , m_nSelection + 1 ) ;
}
+ status = noErr ;
}
-}
-
-
-void wxNotebook::MacHandleControlClick( WXWidget control , wxInt16 controlpart , bool WXUNUSED( mouseStillDown ) )
-{
-#if 0
- wxNotebookEvent event(wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED, m_windowId , ::GetControl32BitValue((ControlRef)m_macControl) - 1, m_nSelection);
- event.SetEventObject(this);
-
- ProcessEvent(event);
-#endif
+ return status ;
}
if ( bounds.bottom <= bounds.top )
bounds.bottom = bounds.top + 100 ;
- m_macControl = (WXWidget) ::NewControl( MAC_WXHWND(parent->MacGetTopLevelWindowRef()) , &bounds , "\p" , true , 0 , 0 , 1,
- kControlGroupBoxTextTitleProc , (long) this ) ;
+ verify_noerr(CreateGroupBoxControl(MAC_WXHWND(parent->MacGetTopLevelWindowRef()),&bounds, CFSTR("") ,
+ true /*primary*/ , (ControlRef*)&m_macControl ) ) ;
for (i = 0; i < n; i++)
{
m_label = label ;
Rect bounds = wxMacGetBoundsForControl( this , pos , size ) ;
-
- m_macControl = (WXWidget) ::NewControl( MAC_WXHWND(parent->MacGetTopLevelWindowRef()) , &bounds , "\p" , true , 0 , 0 , 1,
- kControlRadioButtonProc , (long) this ) ;
+ verify_noerr ( CreateRadioButtonControl( MAC_WXHWND(parent->MacGetTopLevelWindowRef()) , &bounds , CFSTR("") ,
+ 0 , false /* no autotoggle */ , (ControlRef*) &m_macControl ) ) ;
+
MacPostControlCreate(pos,size) ;
m_cycle = this ;
ProcessCommand (event);
}
-void wxRadioButton::MacHandleControlClick( WXWidget control , wxInt16 controlpart , bool WXUNUSED(mouseStillDown))
+wxInt32 wxRadioButton::MacControlHit(WXEVENTHANDLERREF WXUNUSED(handler) , WXEVENTREF WXUNUSED(event) )
{
+ // if already set -> no action
if ( GetValue() )
- return ;
+ return noErr;
wxRadioButton *cycle, *old = NULL ;
cycle=this->NextInCycle();
event2.SetEventObject(this);
event2.SetInt( true );
ProcessCommand(event2);
+ return noErr ;
}
wxRadioButton *wxRadioButton::AddInCycle(wxRadioButton *cycle)
return FALSE;
Rect bounds = wxMacGetBoundsForControl( this , pos , size ) ;
- m_macControl = (WXWidget) ::NewControl(MAC_WXHWND(parent->MacGetTopLevelWindowRef()) ,
- &bounds , "\p" , true , 0 , 0 , 100,
- kControlScrollBarLiveProc , (long) this) ;
- wxASSERT_MSG( (ControlRef) m_macControl != NULL , wxT("No valid mac control") ) ;
-
- ::SetControlAction( (ControlRef) m_macControl , wxMacLiveScrollbarActionUPP ) ;
+ verify_noerr ( CreateScrollBarControl( MAC_WXHWND(parent->MacGetTopLevelWindowRef()) , &bounds ,
+ 0 , 0 , 100 , 1 , true /* liveTracking */ , wxMacLiveScrollbarActionUPP , (ControlRef*) &m_macControl ) ) ;
MacPostControlCreate(pos,size) ;
m_viewSize = thumbSize;
m_objectSize = range;
- int range1 = wxMax((m_objectSize - m_viewSize), 0) ;
+ int range1 = wxMax((m_objectSize - m_viewSize), 0) ;
SetControl32BitMaximum( (ControlRef) m_macControl , range1 ) ;
SetControl32BitMinimum( (ControlRef) m_macControl , 0 ) ;
SetControl32BitValue( (ControlRef) m_macControl , position ) ;
+ SetControlViewSize( (ControlRef) m_macControl , m_viewSize ) ;
- if ( UMAGetAppearanceVersion() >= 0x0110 )
- {
- if ( SetControlViewSize != (void*) kUnresolvedCFragSymbolAddress )
- {
- SetControlViewSize( (ControlRef) m_macControl , m_viewSize ) ;
- }
- }
if ( refresh )
MacRedrawControl() ;
}
void wxScrollBar::MacHandleControlClick( WXWidget control , wxInt16 controlpart , bool mouseStillDown )
{
- if ( (ControlRef) m_macControl == NULL )
- return ;
-
int position = GetControl32BitValue( (ControlRef) m_macControl) ;
int minPos = GetControl32BitMinimum( (ControlRef) m_macControl) ;
int maxPos = GetControl32BitMaximum( (ControlRef) m_macControl) ;
GetEventHandler()->ProcessEvent(event);
}
+wxInt32 wxScrollBar::MacControlHit( WXEVENTHANDLERREF handler , WXEVENTREF mevent )
+{
+ int position = GetControl32BitValue( (ControlRef) m_macControl) ;
+ int minPos = GetControl32BitMinimum( (ControlRef) m_macControl) ;
+ int maxPos = GetControl32BitMaximum( (ControlRef) m_macControl) ;
+
+ wxEventType scrollEvent = wxEVT_NULL;
+ int nScrollInc = 0;
+
+ wxMacCarbonEvent cEvent( (EventRef) mevent ) ;
+ ControlPartCode controlpart = cEvent.GetParameter<ControlPartCode>(kEventParamControlPart,typeControlPartCode) ;
+
+ // all events have already been reported during mouse down, except for THUMBRELEASE
+ if ( controlpart !=kControlIndicatorPart )
+ return eventNotHandledErr ;
+
+ switch( controlpart )
+ {
+ case kControlIndicatorPart :
+ nScrollInc = 0 ;
+ scrollEvent = wxEVT_SCROLL_THUMBRELEASE;
+ break ;
+ default :
+ wxFAIL_MSG(wxT("illegal scrollbar selector"));
+ break ;
+ }
+
+ int new_pos = position + nScrollInc;
+
+ if (new_pos < minPos)
+ new_pos = minPos;
+ if (new_pos > maxPos)
+ new_pos = maxPos;
+ if ( nScrollInc )
+ SetThumbPosition(new_pos);
+
+ wxScrollEvent event(scrollEvent, m_windowId);
+ if ( m_windowStyle & wxHORIZONTAL )
+ {
+ event.SetOrientation( wxHORIZONTAL ) ;
+ }
+ else
+ {
+ event.SetOrientation( wxVERTICAL ) ;
+ }
+ event.SetPosition(new_pos);
+ event.SetEventObject( this );
+ wxWindow* window = GetParent() ;
+ if (window && window->MacIsWindowScrollbar(this) )
+ {
+ // this is hardcoded
+ window->MacOnScroll(event);
+ }
+ else
+ GetEventHandler()->ProcessEvent(event);
+ return noErr ;
+}
+
+
Rect bounds = wxMacGetBoundsForControl( this , pos , size ) ;
- procID = kControlSliderProc + kControlSliderLiveFeedback;
- if(style & wxSL_AUTOTICKS) {
- procID += kControlSliderHasTickMarks;
- }
-
-
- m_macControl = (WXWidget) ::NewControl( MAC_WXHWND(parent->MacGetTopLevelWindowRef()), &bounds, "\p", true,
- value, minValue, maxValue, procID, (long) this);
-
- wxASSERT_MSG( (ControlRef) m_macControl != NULL , wxT("No valid mac control") ) ;
-
- ::SetControlAction( (ControlRef) m_macControl , wxMacLiveScrollbarActionUPP ) ;
+ UInt16 tickMarks = 0 ;
+ if ( style & wxSL_AUTOTICKS )
+ tickMarks = maxValue - minValue ;
+
+ verify_noerr ( CreateSliderControl( MAC_WXHWND(parent->MacGetTopLevelWindowRef()) , &bounds ,
+ value , minValue , maxValue , kControlSliderPointsDownOrRight , tickMarks , true /* liveTracking */ ,
+ wxMacLiveScrollbarActionUPP , (ControlRef*) &m_macControl ) ) ;
if(style & wxSL_VERTICAL) {
SetSizeHints(10, -1, 10, -1); // Forces SetSize to use the proper width
wxEventType scrollEvent = wxEVT_NULL ;
- if ( mouseStillDown )
- scrollEvent = wxEVT_SCROLL_THUMBTRACK;
- else
- scrollEvent = wxEVT_SCROLL_THUMBRELEASE;
+ scrollEvent = wxEVT_SCROLL_THUMBTRACK;
+
+ wxScrollEvent event(scrollEvent, m_windowId);
+ event.SetPosition(value);
+ event.SetEventObject( this );
+ GetEventHandler()->ProcessEvent(event);
+
+ wxCommandEvent cevent( wxEVT_COMMAND_SLIDER_UPDATED, m_windowId );
+ cevent.SetInt( value );
+ cevent.SetEventObject( this );
+
+ GetEventHandler()->ProcessEvent( cevent );
+}
+
+wxInt32 wxSlider::MacControlHit( WXEVENTHANDLERREF handler , WXEVENTREF mevent )
+{
+ SInt16 value = ::GetControl32BitValue( (ControlRef) m_macControl ) ;
+
+ SetValue( value ) ;
+
+ wxEventType scrollEvent = wxEVT_NULL ;
+
+ scrollEvent = wxEVT_SCROLL_THUMBRELEASE;
wxScrollEvent event(scrollEvent, m_windowId);
event.SetPosition(value);
cevent.SetEventObject( this );
GetEventHandler()->ProcessEvent( cevent );
+ return noErr ;
}
+
/* This is overloaded in wxSlider so that the proper width/height will always be used
* for the slider different values would cause redrawing and mouse detection problems */
void wxSlider::SetSizeHints( int minW, int minH,
return FALSE;
Rect bounds = wxMacGetBoundsForControl( this , pos , size ) ;
-
- m_macControl = (WXWidget) ::NewControl( MAC_WXHWND(parent->MacGetTopLevelWindowRef()) , &bounds , "\p" , true , 0 , 0 , 100,
- kControlLittleArrowsProc , (long) this ) ;
-
- wxASSERT_MSG( (ControlRef) m_macControl != NULL , wxT("No valid mac control") ) ;
+
+ verify_noerr ( CreateLittleArrowsControl( MAC_WXHWND(parent->MacGetTopLevelWindowRef()) , &bounds , 0 , m_min , m_max , 1 ,
+ (ControlRef*) &m_macControl ) ) ;
MacPostControlCreate(pos,size) ;
}
}
-void wxSpinButton::MacHandleControlClick( WXWidget control , wxInt16 controlpart , bool WXUNUSED(mouseStillDown))
+wxInt32 wxSpinButton::MacControlHit(WXEVENTHANDLERREF WXUNUSED(handler) , WXEVENTREF event )
{
- if ( (ControlRef) m_macControl == NULL )
- return ;
-
int nScrollInc = 0;
+ wxMacCarbonEvent cEvent( (EventRef) event ) ;
- switch( controlpart )
+ switch( cEvent.GetParameter<ControlPartCode>(kEventParamControlPart,typeControlPartCode) )
{
case kControlUpButtonPart :
nScrollInc = 1;
break ;
}
MacHandleValueChanged( nScrollInc ) ;
-
+ return noErr ;
}
// ----------------------------------------------------------------------------
Rect bounds = wxMacGetBoundsForControl( this , pos , size ) ;
- m_macControl = (WXWidget) ::NewControl( MAC_WXHWND(parent->MacGetTopLevelWindowRef()) , &bounds , "\p" , true , 0 , 0 , 1,
- kControlGroupBoxTextTitleProc , (long) this ) ;
-
+ verify_noerr(CreateGroupBoxControl(MAC_WXHWND(parent->MacGetTopLevelWindowRef()),&bounds, CFSTR("") ,
+ true /*primary*/ , (ControlRef*)&m_macControl ) ) ;
+
MacPostControlCreate(pos,size) ;
return TRUE;
return false;
Rect bounds = wxMacGetBoundsForControl( this , pos , size ) ;
- m_macControl = (WXWidget) ::NewControl( MAC_WXHWND(parent->MacGetTopLevelWindowRef()) , &bounds , "\p" , true , 0 , 0 , 1,
- kControlSeparatorLineProc , (long) this ) ;
-
+ verify_noerr(CreateSeparatorControl(MAC_WXHWND(parent->MacGetTopLevelWindowRef()),&bounds, (ControlRef*)&m_macControl ) ) ;
+
MacPostControlCreate(pos,size) ;
return TRUE;
m_imageList = NULL;
Rect bounds = wxMacGetBoundsForControl( this , pos , size ) ;
- m_macControl = (WXWidget) ::NewControl( MAC_WXHWND(parent->MacGetTopLevelWindowRef()) , &bounds , "\p" , true , 0 , 0 , 1,
- kControlTabSmallProc , (long) this ) ;
+
+ UInt16 tabstyle = kControlTabDirectionNorth ;
+ ControlTabSize tabsize = kControlTabSizeLarge ;
+ if ( GetWindowVariant() == wxWINDOW_VARIANT_SMALL )
+ tabsize = kControlTabSizeSmall ;
+ else if ( GetWindowVariant() == wxWINDOW_VARIANT_MINI )
+ {
+ if (UMAGetSystemVersion() >= 0x1030 )
+ tabsize = 3 ;
+ else
+ tabsize = kControlSizeSmall;
+ }
+ verify_noerr ( CreateTabsControl( MAC_WXHWND(parent->MacGetTopLevelWindowRef()) , &bounds ,
+ tabsize , tabstyle, 0, NULL, (ControlRef*) &m_macControl) );
+
MacPostControlCreate(pos,size) ;
return TRUE ;
}
m_label = label ;
Rect bounds = wxMacGetBoundsForControl( this , pos , size ) ;
- m_macControl = (WXWidget) ::NewControl( MAC_WXHWND(parent->MacGetTopLevelWindowRef()) , &bounds , "\p" , true , 0 , kControlBehaviorToggles , 1,
- kControlBevelButtonNormalBevelProc , (long) this ) ;
- wxASSERT_MSG( (ControlRef) m_macControl != NULL , wxT("No valid mac control") ) ;
+
+ verify_noerr ( CreateBevelButtonControl( MAC_WXHWND(parent->MacGetTopLevelWindowRef()) , &bounds , CFSTR("") ,
+ kControlBevelButtonNormalBevel , kControlBehaviorToggles , NULL , 0 , 0 , 0 , (ControlRef*) &m_macControl ) ) ;
MacPostControlCreate(pos,size) ;
ProcessCommand(event);
}
-void wxToggleButton::MacHandleControlClick( WXWidget WXUNUSED(control) , wxInt16 controlpart , bool WXUNUSED(mouseStillDown) )
+wxInt32 wxToggleButton::MacControlHit(WXEVENTHANDLERREF WXUNUSED(handler) , WXEVENTREF WXUNUSED(event) )
{
- if ( controlpart != kControlNoPart )
- {
- wxCommandEvent event(wxEVT_COMMAND_TOGGLEBUTTON_CLICKED, m_windowId);
- event.SetInt(GetValue());
- event.SetEventObject(this);
- ProcessCommand(event);
- }
+ wxCommandEvent event(wxEVT_COMMAND_TOGGLEBUTTON_CLICKED, m_windowId);
+ event.SetInt(GetValue());
+ event.SetEventObject(this);
+ ProcessCommand(event);
+ return noErr ;
}
#endif // wxUSE_TOGGLEBTN
IMPLEMENT_DYNAMIC_CLASS(wxToolBar, wxControl)
BEGIN_EVENT_TABLE(wxToolBar, wxToolBarBase)
- EVT_MOUSE_EVENTS( wxToolBar::OnMouse )
EVT_PAINT( wxToolBar::OnPaint )
END_EVENT_TABLE()
#endif
SInt16 behaviour = kControlBehaviorOffsetContents ;
if ( CanBeToggled() )
behaviour += kControlBehaviorToggles ;
-
- if ( info.contentType != kControlNoContent )
- {
- m_controlHandle = ::NewControl( window , &toolrect , "\p" , true , 0 ,
- behaviour + info.contentType , 0 , kControlBevelButtonNormalBevelProc , (long) this ) ;
- ::SetControlData( m_controlHandle , kControlButtonPart , kControlBevelButtonContentTag , sizeof(info) , (char*) &info ) ;
- }
- else
- {
- m_controlHandle = ::NewControl( window , &toolrect , "\p" , true , 0 ,
- behaviour , 0 , kControlBevelButtonNormalBevelProc , (long) this ) ;
- }
+ CreateBevelButtonControl( window , &toolrect , CFSTR("") , kControlBevelButtonNormalBevel , behaviour , &info ,
+ 0 , 0 , 0 , &m_controlHandle ) ;
+
InstallControlEventHandler( (ControlRef) m_controlHandle, GetwxMacToolBarToolEventHandlerUPP(),
GetEventTypeCount(eventList), eventList, this,NULL);
+
UMAShowControl( m_controlHandle ) ;
if ( !IsEnabled() )
- {
- UMADeactivateControl( m_controlHandle ) ;
- }
+ DisableControl( m_controlHandle ) ;
+
if ( CanBeToggled() && IsToggled() )
- {
::SetControl32BitValue( m_controlHandle , 1 ) ;
- }
else
- {
::SetControl32BitValue( m_controlHandle , 0 ) ;
- }
ControlRef container = (ControlRef) tbar->GetHandle() ;
wxASSERT_MSG( container != NULL , wxT("No valid mac container control") ) ;
return wxSize(m_defaultWidth + 4, m_defaultHeight + 4);
}
-void wxToolBar::MacHandleControlClick( WXWidget control , wxInt16 controlpart , bool WXUNUSED( mouseStillDown ) )
-{
- wxToolBarToolsList::Node *node;
- for ( node = m_tools.GetFirst(); node; node = node->GetNext() )
- {
- wxToolBarTool* tool = (wxToolBarTool*) node->GetData() ;
- if ( tool->IsButton() )
- {
- if( tool->GetControlHandle() == control )
- {
- if ( tool->CanBeToggled() )
- {
- tool->Toggle( GetControl32BitValue( (ControlRef) control ) ) ;
- }
- OnLeftClick( tool->GetId() , tool -> IsToggled() ) ;
- break ;
- }
- }
- }
-}
-
void wxToolBar::SetRows(int nRows)
{
if ( nRows == m_maxRows )
event.Skip() ;
}
-void wxToolBar::OnMouse( wxMouseEvent &event )
-{
- if (event.GetEventType() == wxEVT_LEFT_DOWN || event.GetEventType() == wxEVT_LEFT_DCLICK )
- {
-
- int x = event.m_x ;
- int y = event.m_y ;
-
- MacClientToRootWindow( &x , &y ) ;
-
- ControlRef control ;
- Point localwhere ;
- SInt16 controlpart ;
- WindowRef window = (WindowRef) MacGetTopLevelWindowRef() ;
-
- localwhere.h = x ;
- localwhere.v = y ;
-
- short modifiers = 0;
-
- if ( !event.m_leftDown && !event.m_rightDown )
- modifiers |= btnState ;
-
- if ( event.m_shiftDown )
- modifiers |= shiftKey ;
-
- if ( event.m_controlDown )
- modifiers |= controlKey ;
-
- if ( event.m_altDown )
- modifiers |= optionKey ;
-
- if ( event.m_metaDown )
- modifiers |= cmdKey ;
-
- controlpart = ::FindControl( localwhere , window , &control ) ;
- {
- if ( control && ::IsControlActive( control ) )
- {
- {
- controlpart = ::HandleControlClick( control , localwhere , modifiers , (ControlActionUPP) -1 ) ;
- wxTheApp->s_lastMouseDown = 0 ;
- if ( control && controlpart != kControlNoPart ) // otherwise we will get the event twice
- {
- MacHandleControlClick((WXWidget) control , controlpart , false /* not down anymore */ ) ;
- }
- }
- }
- }
- }
-}
-
#endif // wxUSE_TOOLBAR