wxWidgetImplType* wxWidgetImpl::CreateButton( wxWindowMac* wxpeer, wxWindowMac* parent, wxWindowID id, const wxString& label, const wxPoint& pos, const wxSize& size, long WXUNUSED(style), long WXUNUSED(extraStyle)) { OSStatus err; Rect bounds = wxMacGetBoundsForControl( wxpeer , pos , size ) ; wxMacControl* peer = new wxMacControl(wxpeer) ; if ( id == wxID_HELP ) { ControlButtonContentInfo info ; info.contentType = kControlContentIconRef ; GetIconRef(kOnSystemDisk, kSystemIconsCreator, kHelpIcon, &info.u.iconRef); err = CreateRoundButtonControl( MAC_WXHWND(parent->MacGetTopLevelWindowRef()), &bounds, kControlRoundButtonNormalSize, &info, peer->GetControlRefAddr() ); } else if ( label.Find('\n' ) == wxNOT_FOUND && label.Find('\r' ) == wxNOT_FOUND) { // Button height is static in Mac, can't be changed, so we need to force it here int maxHeight; switch (wxpeer->GetWindowVariant() ) { default: wxFAIL_MSG( "unknown window variant" ); // fall through case wxWINDOW_VARIANT_NORMAL: case wxWINDOW_VARIANT_LARGE: maxHeight = 20 ; break; case wxWINDOW_VARIANT_SMALL: maxHeight = 17; break; case wxWINDOW_VARIANT_MINI: maxHeight = 15; } bounds.bottom = bounds.top + maxHeight ; wxpeer->SetMaxSize( wxSize( wxpeer->GetMaxWidth() , maxHeight )); err = CreatePushButtonControl( MAC_WXHWND(parent->MacGetTopLevelWindowRef()), &bounds, CFSTR(""), peer->GetControlRefAddr() ); } else { ControlButtonContentInfo info ; info.contentType = kControlNoContent ; err = CreateBevelButtonControl( MAC_WXHWND(parent->MacGetTopLevelWindowRef()) , &bounds, CFSTR(""), kControlBevelButtonLargeBevel, kControlBehaviorPushbutton, &info, 0, 0, 0, peer->GetControlRefAddr() ); } verify_noerr( err ); return peer; }
// Single check box item bool wxToggleButton::Create(wxWindow *parent, wxWindowID id, const wxString& label, const wxPoint& pos, const wxSize& size, long style, const wxValidator& validator, const wxString& name) { m_macIsUserPane = FALSE ; if ( !wxControl::Create(parent, id, pos, size, style, validator, name) ) return false; m_label = label ; Rect bounds = wxMacGetBoundsForControl( this , pos , size ) ; m_peer = new wxMacControl(this) ; verify_noerr ( CreateBevelButtonControl( MAC_WXHWND(parent->MacGetTopLevelWindowRef()) , &bounds , CFSTR("") , kControlBevelButtonNormalBevel , kControlBehaviorToggles , NULL , 0 , 0 , 0 , m_peer->GetControlRefAddr() ) ); MacPostControlCreate(pos,size) ; return TRUE; }
void wxGLCanvas::SetViewport() { // viewport is initially set to entire port // adjust glViewport to just this window int x = 0 ; int y = 0 ; wxWindow* iter = this ; while( iter->GetParent() ) { iter = iter->GetParent() ; } if ( iter && iter->IsTopLevel() ) { MacClientToRootWindow( &x , &y ) ; int width, height; GetClientSize(& width, & height); Rect bounds ; GetWindowPortBounds( MAC_WXHWND(MacGetRootWindow()) , &bounds ) ; GLint parms[4] ; parms[0] = x ; parms[1] = bounds.bottom - bounds.top - ( y + height ) ; parms[2] = width ; parms[3] = height ; if ( !m_macCanvasIsShown ) parms[0] += 20000 ; aglSetInteger( m_glContext->m_glContext , AGL_BUFFER_RECT , parms ) ; } }
bool wxStaticBox::Create(wxWindow *parent, wxWindowID id, const wxString& label, const wxPoint& pos, const wxSize& size, long style, const wxString& name) { m_macIsUserPane = FALSE ; if ( !wxControl::Create(parent, id, pos, size, style, wxDefaultValidator, name) ) return false; m_label = label ; Rect bounds = wxMacGetBoundsForControl( this , pos , size ) ; m_peer = new wxMacControl(this) ; verify_noerr(CreateGroupBoxControl(MAC_WXHWND(parent->MacGetTopLevelWindowRef()),&bounds, CFSTR("") , true /*primary*/ , m_peer->GetControlRefAddr() ) ) ; MacPostControlCreate(pos,size) ; return TRUE; }
bool wxStaticText::Create(wxWindow *parent, wxWindowID id, const wxString& label, const wxPoint& pos, const wxSize& size, long style, const wxString& name) { m_macIsUserPane = FALSE ; m_label = wxStripMenuCodes(label) ; if ( !wxControl::Create( parent, id, pos, size, style, wxDefaultValidator , name ) ) { return false; } Rect bounds = wxMacGetBoundsForControl( this , pos , size ) ; wxMacCFStringHolder str(m_label,m_font.GetEncoding() ) ; m_peer = new wxMacControl(this) ; verify_noerr(CreateStaticTextControl(MAC_WXHWND(parent->MacGetTopLevelWindowRef()),&bounds, str , NULL , m_peer->GetControlRefAddr() ) ) ; MacPostControlCreate(pos,size) ; return true; }
wxWidgetImplType* wxWidgetImpl::CreateSlider( wxWindowMac* wxpeer, wxWindowMac* parent, wxWindowID WXUNUSED(id), wxInt32 value, wxInt32 minimum, wxInt32 maximum, const wxPoint& pos, const wxSize& size, long style, long WXUNUSED(extraStyle)) { Rect bounds = wxMacGetBoundsForControl( wxpeer, pos, size ); int tickMarks = 0; if ( style & wxSL_AUTOTICKS ) tickMarks = (maximum - minimum) + 1; // +1 for the 0 value // keep the number of tickmarks from becoming unwieldly, therefore below it is ok to cast // it to a UInt16 while (tickMarks > 20) tickMarks /= 5; wxMacControl* peer = new wxMacSliderCarbonControl( wxpeer ); OSStatus err = CreateSliderControl( MAC_WXHWND(parent->MacGetTopLevelWindowRef()), &bounds, value, minimum, maximum, kControlSliderPointsDownOrRight, (UInt16) tickMarks, true /* liveTracking */, GetwxMacLiveScrollbarActionProc(), peer->GetControlRefAddr() ); verify_noerr( err ); return peer; }
wxMacDataBrowserControl::wxMacDataBrowserControl( wxWindow* peer, const wxPoint& pos, const wxSize& size, long WXUNUSED(style)) : wxMacControl( peer ) { Rect bounds = wxMacGetBoundsForControl( peer, pos, size ); OSStatus err = ::CreateDataBrowserControl( MAC_WXHWND(peer->MacGetTopLevelWindowRef()), &bounds, kDataBrowserListView, &m_controlRef ); SetReferenceInNativeControl(); verify_noerr( err ); if ( gDataBrowserItemCompareUPP == NULL ) gDataBrowserItemCompareUPP = NewDataBrowserItemCompareUPP(DataBrowserCompareProc); if ( gDataBrowserItemDataUPP == NULL ) gDataBrowserItemDataUPP = NewDataBrowserItemDataUPP(DataBrowserGetSetItemDataProc); if ( gDataBrowserItemNotificationUPP == NULL ) { gDataBrowserItemNotificationUPP = (DataBrowserItemNotificationUPP) NewDataBrowserItemNotificationWithItemUPP(DataBrowserItemNotificationProc); } DataBrowserCallbacks callbacks; InitializeDataBrowserCallbacks( &callbacks, kDataBrowserLatestCallbacks ); callbacks.u.v1.itemDataCallback = gDataBrowserItemDataUPP; callbacks.u.v1.itemCompareCallback = gDataBrowserItemCompareUPP; callbacks.u.v1.itemNotificationCallback = gDataBrowserItemNotificationUPP; SetCallbacks( &callbacks ); }
wxWidgetImplType* wxWidgetImpl::CreateStaticText( wxWindowMac* wxpeer, wxWindowMac* parent, wxWindowID WXUNUSED(id), const wxString& WXUNUSED(label), const wxPoint& pos, const wxSize& size, long style, long WXUNUSED(extraStyle)) { Rect bounds = wxMacGetBoundsForControl( wxpeer, pos, size ); wxMacControl* peer = new wxMacStaticText( wxpeer ); OSStatus err = CreateStaticTextControl( MAC_WXHWND(parent->MacGetTopLevelWindowRef()), &bounds, NULL, NULL, peer->GetControlRefAddr() ); verify_noerr( err ); if ( ( style & wxST_ELLIPSIZE_END ) || ( style & wxST_ELLIPSIZE_MIDDLE ) ) { TruncCode tCode = truncEnd; if ( style & wxST_ELLIPSIZE_MIDDLE ) tCode = truncMiddle; err = peer->SetData( kControlStaticTextTruncTag, tCode ); err = peer->SetData( kControlStaticTextIsMultilineTag, (Boolean)0 ); } return peer; }
// Scrollbar bool wxScrollBar::Create(wxWindow *parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style, const wxValidator& validator, const wxString& name) { if ( !wxControl::Create(parent, id, pos, size, style, validator, name) ) return FALSE; Rect bounds ; Str255 title ; MacPreControlCreate( parent , id , wxEmptyString , pos , size ,style, validator , name , &bounds , title ) ; m_macControl = (WXWidget) ::NewControl(MAC_WXHWND(parent->MacGetRootWindow()) , &bounds , title , false , 0 , 0 , 100, kControlScrollBarLiveProc , (long) this) ; wxASSERT_MSG( (ControlHandle) m_macControl != NULL , wxT("No valid mac control") ) ; ::SetControlAction( (ControlHandle) m_macControl , wxMacLiveScrollbarActionUPP ) ; MacPostControlCreate() ; return TRUE; }
void wxToolTip::RelayEvent( wxWindow *win , wxMouseEvent &event ) { if ( s_ShowToolTips ) { if ( event.GetEventType() == wxEVT_LEAVE_WINDOW ) { s_ToolTip.Clear() ; } else if (event.GetEventType() == wxEVT_ENTER_WINDOW || event.GetEventType() == wxEVT_MOTION ) { wxPoint2DInt where( event.m_x , event.m_y ) ; if ( s_LastWindowEntered == win && s_ToolTipArea.Contains( where ) ) { } else { s_ToolTip.Clear() ; s_ToolTipArea = wxRect2DInt( event.m_x - 2 , event.m_y - 2 , 4 , 4 ) ; s_LastWindowEntered = win ; WindowRef window = MAC_WXHWND( win->MacGetTopLevelWindowRef() ) ; int x = event.m_x ; int y = event.m_y ; wxPoint local( x , y ) ; win->MacClientToRootWindow( &x, &y ) ; wxPoint windowlocal( x , y ) ; s_ToolTip.Setup( window , win->MacGetToolTipString( local ) , windowlocal ) ; } } } }
bool wxGauge::Create(wxWindow *parent, wxWindowID id, int range, const wxPoint& pos, const wxSize& s, long style, const wxValidator& validator, const wxString& name) { if ( !wxGaugeBase::Create(parent, id, range, pos, s, style, validator, name) ) return false; wxSize size = s ; Rect bounds ; Str255 title ; m_rangeMax = range ; m_gaugePos = 0 ; if ( size.x == wxDefaultCoord && size.y == wxDefaultCoord) { size = wxSize( 200 , 16 ) ; } MacPreControlCreate( parent , id , wxEmptyString , pos , size ,style & 0xE0FFFFFF /* no borders on mac */ , validator , name , &bounds , title ) ; m_macControl = (WXWidget) ::NewControl( MAC_WXHWND(parent->MacGetRootWindow()) , &bounds , title , false , 0 , 0 , range, kControlProgressBarProc , (long) this ) ; MacPostControlCreate() ; return true; }
bool wxGLContext::SetCurrent(const wxGLCanvas& win) const { if ( !m_glContext ) return false; GLint bufnummer = win.GetAglBufferName(); aglSetInteger(m_glContext, AGL_BUFFER_NAME, &bufnummer); //win.SetLastContext(m_glContext); const_cast<wxGLCanvas&>(win).SetViewport(); #if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5 if ( UMAGetSystemVersion() >= 0x1050 ) { aglSetWindowRef(m_glContext, win.MacGetTopLevelWindowRef()); } else #endif { AGLDrawable drawable = (AGLDrawable)GetWindowPort( MAC_WXHWND(win.MacGetTopLevelWindowRef())); if ( !aglSetDrawable(m_glContext, drawable) ) { wxLogAGLError("aglSetDrawable"); return false; } } return WXGLSetCurrentContext(m_glContext); }
wxGLContext::wxGLContext( AGLPixelFormat fmt, wxGLCanvas *win, const wxPalette& palette, const wxGLContext *other /* for sharing display lists */ ) { m_window = win; #ifndef __LP64__ m_drawable = (AGLDrawable) UMAGetWindowPort(MAC_WXHWND(win->MacGetTopLevelWindowRef())); #endif m_glContext = aglCreateContext(fmt, other ? other->m_glContext : NULL); wxCHECK_RET( m_glContext, wxT("Couldn't create OpenGl context") ); GLboolean b; #ifndef __LP64__ b = aglSetDrawable(m_glContext, m_drawable); aglEnable(m_glContext , AGL_BUFFER_RECT ) ; #else b = aglSetHIViewRef(m_glContext, (HIViewRef) win->GetHandle()); #endif wxCHECK_RET( b, wxT("Couldn't bind OpenGl context") ); b = aglSetCurrentContext(m_glContext); wxCHECK_RET( b, wxT("Couldn't activate OpenGl context") ); }
// Single check box item bool wxCheckBox::Create(wxWindow *parent, wxWindowID id, const wxString& label, const wxPoint& pos, const wxSize& size, long style, const wxValidator& validator, const wxString& name) { m_macIsUserPane = false ; if ( !wxCheckBoxBase::Create(parent, id, pos, size, style, validator, name) ) return false; m_label = label ; SInt32 maxValue = 1 /* kControlCheckboxCheckedValue */; if (style & wxCHK_3STATE) maxValue = 2 /* kControlCheckboxMixedValue */; Rect bounds = wxMacGetBoundsForControl( this , pos , size ) ; m_peer = new wxMacControl( this ) ; verify_noerr( CreateCheckBoxControl(MAC_WXHWND(parent->MacGetTopLevelWindowRef()), &bounds , CFSTR("") , 0 , false , m_peer->GetControlRefAddr() ) ); m_peer->SetMaximum( maxValue ) ; MacPostControlCreate(pos, size) ; return true; }
// Single check box item bool wxCheckBox::Create(wxWindow *parent, wxWindowID id, const wxString& label, const wxPoint& pos, const wxSize& size, long style, const wxValidator& validator, const wxString& name) { if ( !wxCheckBoxBase::Create(parent, id, pos, size, style, validator, name) ) return false; Rect bounds ; Str255 title ; MacPreControlCreate( parent , id , label , pos , size ,style, validator , name , &bounds , title ) ; SInt16 maxValue = 1 /* kControlCheckboxCheckedValue */; if (style & wxCHK_3STATE) { maxValue = 2 /* kControlCheckboxMixedValue */; } m_macControl = (WXWidget) ::NewControl( MAC_WXHWND(parent->MacGetRootWindow()) , &bounds , title , false , 0 , 0 , maxValue, kControlCheckBoxProc , (long) this ) ; MacPostControlCreate() ; return TRUE; }
bool wxGLCanvas::Create(wxWindow *parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style, const wxString& name, const int *attribList, const wxPalette& WXUNUSED(palette)) { m_needsUpdate = false; m_macCanvasIsShown = false; m_glFormat = WXGLChoosePixelFormat(attribList); if ( !m_glFormat ) return false; if ( !wxWindow::Create(parent, id, pos, size, style, name) ) return false; m_dummyContext = WXGLCreateContext(m_glFormat, NULL); static GLint gCurrentBufferName = 1; m_bufferName = gCurrentBufferName++; aglSetInteger (m_dummyContext, AGL_BUFFER_NAME, &m_bufferName); AGLDrawable drawable = (AGLDrawable)GetWindowPort(MAC_WXHWND(MacGetTopLevelWindowRef())); aglSetDrawable(m_dummyContext, drawable); m_macCanvasIsShown = true; return true; }
void wxStatusBarMac::DrawFieldText(wxDC& dc, int i) { int leftMargin = 2; wxRect rect; GetFieldRect(i, rect); if ( !IsWindowHilited( MAC_WXHWND( MacGetRootWindow() ) ) ) { dc.SetTextForeground( wxColour( 0x80 , 0x80 , 0x80 ) ) ; } wxString text(GetStatusText(i)); long x, y; dc.GetTextExtent(text, &x, &y); int xpos = rect.x + leftMargin + 1 ; int ypos = 1 ; dc.SetClippingRegion(rect.x, 0, rect.width, m_height); dc.DrawText(text, xpos, ypos); dc.DestroyClippingRegion(); }
bool wxGauge::Create(wxWindow *parent, wxWindowID id, int range, const wxPoint& pos, const wxSize& s, long style, const wxValidator& validator, const wxString& name) { m_macIsUserPane = FALSE ; if ( !wxGaugeBase::Create(parent, id, range, pos, s, style & 0xE0FFFFFF, validator, name) ) return false; wxSize size = s ; /* if ( size.x == wxDefaultCoord && size.y == wxDefaultCoord) { size = wxSize( 200 , 16 ) ; } */ Rect bounds = wxMacGetBoundsForControl( this , pos , size ) ; m_peer = new wxMacControl(this) ; verify_noerr ( CreateProgressBarControl( MAC_WXHWND(parent->MacGetTopLevelWindowRef()) , &bounds , GetValue() , 0 , GetRange() , false /* not indeterminate */ , m_peer->GetControlRefAddr() ) ); if ( GetValue() == 0 ) m_peer->SetData<Boolean>( kControlEntireControl , kControlProgressBarAnimatingTag , (Boolean) false ) ; MacPostControlCreate(pos,size) ; return TRUE; }
bool wxSpinButton::Create(wxWindow *parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style, const wxString& name) { if ( !wxSpinButtonBase::Create(parent, id, pos, size, style, wxDefaultValidator, name) ) return false; m_min = 0; m_max = 100; if (!parent) return false; Rect bounds ; Str255 title ; MacPreControlCreate( parent , id , wxEmptyString , pos , size ,style,*( (wxValidator*) NULL ) , name , &bounds , title ) ; m_macControl = (WXWidget) ::NewControl( MAC_WXHWND(parent->MacGetRootWindow()) , &bounds , title , false , 0 , 0 , 100, kControlLittleArrowsProc , (long) this ) ; wxASSERT_MSG( (ControlHandle) m_macControl != NULL , wxT("No valid mac control") ) ; MacPostControlCreate() ; return true; }
bool wxGLContext::SetCurrent(const wxGLCanvas& win) const { if ( !m_glContext ) return false; AGLDrawable drawable = (AGLDrawable)GetWindowPort( MAC_WXHWND(win.MacGetTopLevelWindowRef())); GLint bufnummer = win.GetAglBufferName(); aglSetInteger(m_glContext, AGL_BUFFER_NAME, &bufnummer); //win.SetLastContext(m_glContext); const_cast<wxGLCanvas&>(win).SetViewport(); if ( !aglSetDrawable(m_glContext, drawable) ) { wxLogAGLError("aglSetDrawable"); return false; } if ( !aglSetCurrentContext(m_glContext) ) { wxLogAGLError("aglSetCurrentContext"); return false; } return true; }
bool wxSpinButton::Create(wxWindow *parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style, const wxString& name) { m_macIsUserPane = false ; if ( !wxSpinButtonBase::Create(parent, id, pos, size, style, wxDefaultValidator, name) ) return false; m_min = 0; m_max = 100; if (!parent) return false; Rect bounds = wxMacGetBoundsForControl( this , pos , size ) ; m_peer = new wxMacControl(this) ; verify_noerr ( CreateLittleArrowsControl( MAC_WXHWND(parent->MacGetTopLevelWindowRef()) , &bounds , 0 , m_min , m_max , 1 , m_peer->GetControlRefAddr() ) ); m_peer->SetActionProc( GetwxMacLiveScrollbarActionProc() ) ; MacPostControlCreate(pos,size) ; return true; }
wxWidgetImplType* wxWidgetImpl::CreateBitmapButton( wxWindowMac* wxpeer, wxWindowMac* parent, wxWindowID WXUNUSED(id), const wxBitmap& bitmap, const wxPoint& pos, const wxSize& size, long style, long WXUNUSED(extraStyle)) { OSStatus err = noErr; ControlButtonContentInfo info; Rect bounds = wxMacGetBoundsForControl( wxpeer, pos, size ); wxMacControl* peer = new wxMacBitmapButton( wxpeer ); wxBitmap bmp; if ( bitmap.Ok() && (style & wxBORDER_NONE) ) { bmp = wxMakeStdSizeBitmap(bitmap); // TODO set bitmap in peer as well } else bmp = bitmap; if ( style & wxBORDER_NONE ) { // contrary to the docs this control only works with iconrefs wxMacCreateBitmapButton( &info, bmp, kControlContentIconRef ); err = CreateIconControl( MAC_WXHWND(parent->MacGetTopLevelWindowRef()), &bounds, &info, false, peer->GetControlRefAddr() ); } else { wxMacCreateBitmapButton( &info, bmp ); err = CreateBevelButtonControl( MAC_WXHWND(parent->MacGetTopLevelWindowRef()), &bounds, CFSTR(""), ((style & wxBU_AUTODRAW) ? kControlBevelButtonSmallBevel : kControlBevelButtonNormalBevel ), kControlBehaviorOffsetContents, &info, 0, 0, 0, peer->GetControlRefAddr() ); } verify_noerr( err ); wxMacReleaseBitmapButton( &info ); return peer; }
void wxGLCanvas::SetViewport() { #ifndef __LP64__ // viewport is initially set to entire port // adjust glViewport to just this window int x = 0 ; int y = 0 ; wxWindow* iter = this ; while( iter->GetParent() ) { iter = iter->GetParent() ; } if ( iter && iter->IsTopLevel() ) { MacClientToRootWindow( &x , &y ) ; int width, height; GetClientSize(& width, & height); Rect bounds ; #if 0 // TODO in case we adopt point vs pixel coordinates, this will make the conversion GetWindowPortBounds( MAC_WXHWND(MacGetTopLevelWindowRef()) , &bounds ) ; HIRect hiRect = CGRectMake( x, y, width, height ) ; HIRectConvert( &hiRect, kHICoordSpace72DPIGlobal, NULL, kHICoordSpaceScreenPixel, NULL) ; HIRect hiBounds = CGRectMake( 0, 0, bounds.right - bounds.left , bounds.bottom - bounds.top ) ; HIRectConvert( &hiBounds, kHICoordSpace72DPIGlobal, NULL, kHICoordSpaceScreenPixel, NULL) ; GLint parms[4] ; parms[0] = hiRect.origin.x ; parms[1] = hiBounds.size.height - (hiRect.origin.y + hiRect.size.height) ; parms[2] = hiRect.size.width ; parms[3] = hiRect.size.height ; #else GetWindowPortBounds( MAC_WXHWND(MacGetTopLevelWindowRef()) , &bounds ) ; GLint parms[4] ; parms[0] = x ; parms[1] = bounds.bottom - bounds.top - ( y + height ) ; parms[2] = width ; parms[3] = height ; #endif if ( !m_macCanvasIsShown ) parms[0] += 20000 ; aglSetInteger( m_glContext->m_glContext , AGL_BUFFER_RECT , parms ) ; aglUpdateContext(m_glContext->m_glContext); } #endif }
bool wxNotebook::Create( wxWindow *parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style, const wxString& name ) { m_macIsUserPane = false ; if (! (style & wxBK_ALIGN_MASK)) style |= wxBK_TOP; if ( !wxNotebookBase::Create( parent, id, pos, size, style, name ) ) return false; Rect bounds = wxMacGetBoundsForControl( this, pos, size ); if ( bounds.right <= bounds.left ) bounds.right = bounds.left + 100; if ( bounds.bottom <= bounds.top ) bounds.bottom = bounds.top + 100; UInt16 tabstyle = kControlTabDirectionNorth; if ( HasFlag(wxBK_LEFT) ) tabstyle = kControlTabDirectionWest; else if ( HasFlag( wxBK_RIGHT ) ) tabstyle = kControlTabDirectionEast; else if ( HasFlag( wxBK_BOTTOM ) ) tabstyle = kControlTabDirectionSouth; ControlTabSize tabsize; switch (GetWindowVariant()) { case wxWINDOW_VARIANT_MINI: if ( UMAGetSystemVersion() >= 0x1030 ) tabsize = 3 ; else tabsize = kControlSizeSmall; break; case wxWINDOW_VARIANT_SMALL: tabsize = kControlTabSizeSmall; break; default: tabsize = kControlTabSizeLarge; break; } m_peer = new wxMacControl( this ); OSStatus err = CreateTabsControl( MAC_WXHWND(parent->MacGetTopLevelWindowRef()), &bounds, tabsize, tabstyle, 0, NULL, m_peer->GetControlRefAddr() ); verify_noerr( err ); MacPostControlCreate( pos, size ); return true ; }
bool wxRadioBox::Create(wxWindow *parent, wxWindowID id, const wxString& label, const wxPoint& pos, const wxSize& size, int n, const wxString choices[], int majorDim, long style, const wxValidator& val, const wxString& name) { m_macIsUserPane = false ; if ( !wxControl::Create(parent, id, pos, size, style, val, name) ) return false; int i; m_noItems = n; m_noRowsOrCols = majorDim; m_radioButtonCycle = NULL; if (majorDim==0) m_majorDim = n ; else m_majorDim = majorDim ; m_label = label ; Rect bounds = wxMacGetBoundsForControl( this , pos , size ) ; if( bounds.right <= bounds.left ) bounds.right = bounds.left + 100 ; if ( bounds.bottom <= bounds.top ) bounds.bottom = bounds.top + 100 ; m_peer = new wxMacControl(this) ; verify_noerr(CreateGroupBoxControl(MAC_WXHWND(parent->MacGetTopLevelWindowRef()),&bounds, CFSTR("") , true /*primary*/ , m_peer->GetControlRefAddr() ) ) ; for (i = 0; i < n; i++) { wxRadioButton *radBtn = new wxRadioButton ( this, wxID_ANY, wxStripMenuCodes(choices[i]), wxPoint(5,20*i+10), wxDefaultSize, i == 0 ? wxRB_GROUP : 0 ); if ( i == 0 ) m_radioButtonCycle = radBtn ; // m_radioButtonCycle=radBtn->AddInCycle(m_radioButtonCycle); } SetSelection(0); MacPostControlCreate(pos,size) ; return true; }
bool wxRadioButton::Create( wxWindow *parent, wxWindowID id, const wxString& label, const wxPoint& pos, const wxSize& size, long style, const wxValidator& validator, const wxString& name ) { m_macIsUserPane = false; if ( !wxControl::Create( parent, id, pos, size, style, validator, name ) ) return false; m_label = label; Rect bounds = wxMacGetBoundsForControl( this, pos, size ); m_peer = new wxMacControl( this ); OSStatus err = CreateRadioButtonControl( MAC_WXHWND(parent->MacGetTopLevelWindowRef()), &bounds, CFSTR(""), 0, false /* no autotoggle */, m_peer->GetControlRefAddr() ); verify_noerr( err ); MacPostControlCreate( pos, size ); m_cycle = this; if (HasFlag( wxRB_GROUP )) { AddInCycle( NULL ); } else { // search backward for last group start wxRadioButton *chief = NULL; wxWindowList::compatibility_iterator node = parent->GetChildren().GetLast(); while (node) { wxWindow *child = node->GetData(); if (child->IsKindOf( CLASSINFO( wxRadioButton ) )) { chief = (wxRadioButton*)child; if (child->HasFlag( wxRB_GROUP )) break; } node = node->GetPrevious(); } AddInCycle( chief ); } return true; }
wxWidgetImplType* wxWidgetImpl::CreateBitmapButton( wxWindowMac* wxpeer, wxWindowMac* parent, wxWindowID WXUNUSED(id), const wxBitmap& bitmap, const wxPoint& pos, const wxSize& size, long style, long WXUNUSED(extraStyle)) { wxMacBitmapButton* peer = new wxMacBitmapButton(wxpeer, bitmap, style); OSStatus err; WXWindow macParent = MAC_WXHWND(parent->MacGetTopLevelWindowRef()); Rect bounds = wxMacGetBoundsForControl( wxpeer, pos, size ); ControlButtonContentInfo info; peer->InitButtonContentInfo(info, bitmap); if ( info.contentType == kControlContentIconRef ) { err = CreateIconControl ( macParent, &bounds, &info, false, peer->GetControlRefAddr() ); } else // normal bevel button { err = CreateBevelButtonControl ( macParent, &bounds, CFSTR(""), style & wxBU_AUTODRAW ? kControlBevelButtonSmallBevel : kControlBevelButtonNormalBevel, kControlBehaviorOffsetContents, &info, 0, // menu id (no associated menu) 0, // menu behaviour (unused) 0, // menu placement (unused too) peer->GetControlRefAddr() ); } verify_noerr( err ); wxMacReleaseBitmapButton( &info ); return peer; }
wxWidgetImplType* wxWidgetImpl::CreateStaticLine( wxWindowMac* wxpeer, wxWindowMac* parent, wxWindowID WXUNUSED(id), const wxPoint& pos, const wxSize& size, long WXUNUSED(style), long WXUNUSED(extraStyle)) { Rect bounds = wxMacGetBoundsForControl( wxpeer , pos , size ) ; wxMacControl* peer = new wxMacControl(wxpeer) ; verify_noerr(CreateSeparatorControl(MAC_WXHWND(parent->MacGetTopLevelWindowRef()),&bounds, peer->GetControlRefAddr() ) ) ; return peer; }
bool wxRadioBox::Create(wxWindow *parent, wxWindowID id, const wxString& label, const wxPoint& pos, const wxSize& size, int n, const wxString choices[], int majorDim, long style, const wxValidator& val, const wxString& name) { if ( !wxControl::Create(parent, id, pos, size, style, val, name) ) return false; int i; m_noItems = n; m_noRowsOrCols = majorDim; m_radioButtonCycle = NULL; if (majorDim==0) m_majorDim = n ; else m_majorDim = majorDim ; Rect bounds ; Str255 title ; MacPreControlCreate( parent , id , wxStripMenuCodes(label) , pos , size ,style, val , name , &bounds , title ) ; m_macControl = (WXWidget) ::NewControl( MAC_WXHWND(parent->MacGetRootWindow()) , &bounds , title , false , 0 , 0 , 1, kControlGroupBoxTextTitleProc , (long) this ) ; for (i = 0; i < n; i++) { wxRadioButton *radBtn = new wxRadioButton ( this, wxID_ANY, wxStripMenuCodes(choices[i]), wxPoint(5,20*i+10), wxDefaultSize, i == 0 ? wxRB_GROUP : 0 ); if ( i == 0 ) m_radioButtonCycle = radBtn ; // m_radioButtonCycle=radBtn->AddInCycle(m_radioButtonCycle); } SetSelection(0); MacPostControlCreate() ; return true; }
bool wxChoice::Create(wxWindow *parent, wxWindowID id, const wxPoint& pos, const wxSize& size, int n, const wxString choices[], long style, const wxValidator& validator, const wxString& name ) { m_macIsUserPane = false; if ( !wxChoiceBase::Create( parent, id, pos, size, style, validator, name ) ) return false; Rect bounds = wxMacGetBoundsForControl( this , pos , size ); m_peer = new wxMacControl( this ) ; OSStatus err = CreatePopupButtonControl( MAC_WXHWND(parent->MacGetTopLevelWindowRef()) , &bounds , CFSTR("") , -12345 , false /* no variable width */ , 0 , 0 , 0 , m_peer->GetControlRefAddr() ); verify_noerr( err ); m_macPopUpMenuHandle = NewUniqueMenu() ; m_peer->SetData<MenuHandle>( kControlNoPart , kControlPopupButtonMenuHandleTag , (MenuHandle) m_macPopUpMenuHandle ) ; m_peer->SetValueAndRange( n > 0 ? 1 : 0 , 0 , 0 ); MacPostControlCreate( pos, size ); #if !wxUSE_STL if ( style & wxCB_SORT ) // autosort m_strings = wxArrayString( 1 ); #endif for ( int i = 0; i < n; i++ ) { Append( choices[i] ); } // Set the first item as being selected if (n > 0) SetSelection( 0 ); // Needed because it is a wxControlWithItems SetInitialSize( size ); return true; }