new control based view architecture

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@26408 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Stefan Csomor
2004-03-27 09:44:31 +00:00
parent f89d65ea8d
commit facd676487
42 changed files with 4093 additions and 5233 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -29,6 +29,8 @@ bool wxBitmapButton::Create(wxWindow *parent, wxWindowID id, const wxBitmap& bit
const wxValidator& validator, const wxValidator& validator,
const wxString& name) const wxString& name)
{ {
m_macIsUserPane = FALSE ;
// since bitmapbuttonbase is subclass of button calling wxBitmapButtonBase::Create // since bitmapbuttonbase is subclass of button calling wxBitmapButtonBase::Create
// essentially creates an additional button // essentially creates an additional button
if ( !wxControl::Create(parent, id, pos, size, if ( !wxControl::Create(parent, id, pos, size,
@@ -60,30 +62,28 @@ bool wxBitmapButton::Create(wxWindow *parent, wxWindowID id, const wxBitmap& bit
height = newSize.y; height = newSize.y;
} }
Rect bounds ;
Str255 title ;
m_bmpNormal = bitmap; m_bmpNormal = bitmap;
wxBitmapRefData * bmap = NULL ; wxBitmapRefData * bmap = NULL ;
if ( m_bmpNormal.Ok() ) if ( m_bmpNormal.Ok() )
bmap = (wxBitmapRefData*) ( m_bmpNormal.GetRefData()) ; bmap = (wxBitmapRefData*) ( m_bmpNormal.GetRefData()) ;
MacPreControlCreate( parent , id , wxEmptyString , pos , wxSize( width , height ) ,style, validator , name , &bounds , title ) ; Rect bounds = wxMacGetBoundsForControl( this , pos , size ) ;
m_macControl = (WXWidget) ::NewControl( MAC_WXHWND(parent->MacGetTopLevelWindowRef()) , &bounds , "\p" , true , 0 ,
m_macControl = ::NewControl( MAC_WXHWND(parent->MacGetRootWindow()) , &bounds , title , false , 0 ,
kControlBehaviorOffsetContents + kControlBehaviorOffsetContents +
( bmap && bmap->m_bitmapType == kMacBitmapTypeIcon ? ( bmap && bmap->m_bitmapType == kMacBitmapTypeIcon ?
kControlContentCIconHandle : kControlContentPictHandle ) , 0, kControlContentCIconHandle : kControlContentPictHandle ) , 0,
(( style & wxBU_AUTODRAW ) ? kControlBevelButtonSmallBevelProc : kControlBevelButtonNormalBevelProc ), (long) this ) ; (( style & wxBU_AUTODRAW ) ? kControlBevelButtonSmallBevelProc : kControlBevelButtonNormalBevelProc ), (long) this ) ;
wxASSERT_MSG( (ControlHandle) m_macControl != NULL , wxT("No valid mac control") ) ; wxASSERT_MSG( (ControlRef) m_macControl != NULL , wxT("No valid mac control") ) ;
ControlButtonContentInfo info ; ControlButtonContentInfo info ;
wxMacCreateBitmapButton( &info , m_bmpNormal ) ; wxMacCreateBitmapButton( &info , m_bmpNormal ) ;
if ( info.contentType != kControlNoContent ) if ( info.contentType != kControlNoContent )
{ {
::SetControlData( (ControlHandle) m_macControl , kControlButtonPart , kControlBevelButtonContentTag , sizeof(info) , (char*) &info ) ; ::SetControlData( (ControlRef) m_macControl , kControlButtonPart , kControlBevelButtonContentTag , sizeof(info) , (char*) &info ) ;
} }
MacPostControlCreate() ; MacPostControlCreate(pos,size) ;
return TRUE; return TRUE;
} }
@@ -96,7 +96,7 @@ void wxBitmapButton::SetBitmapLabel(const wxBitmap& bitmap)
wxMacCreateBitmapButton( &info , m_bmpNormal ) ; wxMacCreateBitmapButton( &info , m_bmpNormal ) ;
if ( info.contentType != kControlNoContent ) if ( info.contentType != kControlNoContent )
{ {
::SetControlData( (ControlHandle) m_macControl , kControlButtonPart , kControlBevelButtonContentTag , sizeof(info) , (char*) &info ) ; ::SetControlData( (ControlRef) m_macControl , kControlButtonPart , kControlBevelButtonContentTag , sizeof(info) , (char*) &info ) ;
} }
} }

View File

@@ -164,7 +164,7 @@ void wxBrush::SetStipple(const wxBitmap& Stipple)
RealizeResource(); RealizeResource();
} }
void wxBrush::SetMacTheme(ThemeBrush macThemeBrush) void wxBrush::MacSetTheme(ThemeBrush macThemeBrush)
{ {
Unshare(); Unshare();
@@ -174,7 +174,7 @@ void wxBrush::SetMacTheme(ThemeBrush macThemeBrush)
RealizeResource(); RealizeResource();
} }
void wxBrush::SetMacThemeBackground(unsigned long macThemeBackground, const WXRECTPTR extent) void wxBrush::MacSetThemeBackground(unsigned long macThemeBackground, const WXRECTPTR extent)
{ {
Unshare(); Unshare();
@@ -189,7 +189,7 @@ bool wxBrush::RealizeResource()
return TRUE; return TRUE;
} }
unsigned long wxBrush::GetMacThemeBackground( WXRECTPTR extent) const unsigned long wxBrush::MacGetThemeBackground( WXRECTPTR extent) const
{ {
if ( M_BRUSHDATA && M_BRUSHDATA->m_macBrushKind == kwxMacBrushThemeBackground ) if ( M_BRUSHDATA && M_BRUSHDATA->m_macBrushKind == kwxMacBrushThemeBackground )
{ {
@@ -203,7 +203,7 @@ unsigned long wxBrush::GetMacThemeBackground( WXRECTPTR extent) const
} }
} }
short wxBrush::GetMacTheme() const short wxBrush::MacGetTheme() const
{ {
return (M_BRUSHDATA ? ( M_BRUSHDATA->m_macBrushKind == kwxMacBrushTheme ? M_BRUSHDATA->m_macThemeBrush : kThemeBrushBlack) : kThemeBrushBlack); return (M_BRUSHDATA ? ( M_BRUSHDATA->m_macBrushKind == kwxMacBrushTheme ? M_BRUSHDATA->m_macThemeBrush : kThemeBrushBlack) : kThemeBrushBlack);
} }

View File

@@ -25,34 +25,25 @@ IMPLEMENT_DYNAMIC_CLASS(wxButton, wxControl)
#include "wx/mac/uma.h" #include "wx/mac/uma.h"
// Button // Button
static const int kMacOSXHorizontalBorder = 2 ;
static const int kMacOSXVerticalBorder = 4 ;
bool wxButton::Create(wxWindow *parent, wxWindowID id, const wxString& label, bool wxButton::Create(wxWindow *parent, wxWindowID id, const wxString& label,
const wxPoint& pos, const wxPoint& pos,
const wxSize& size, long style, const wxSize& size, long style,
const wxValidator& validator, const wxValidator& validator,
const wxString& name) const wxString& name)
{ {
m_macIsUserPane = FALSE ;
if ( !wxButtonBase::Create(parent, id, pos, size, style, validator, name) ) if ( !wxButtonBase::Create(parent, id, pos, size, style, validator, name) )
return false; return false;
Rect bounds ;
Str255 title ;
if ( UMAHasAquaLayout() )
{
m_macHorizontalBorder = kMacOSXHorizontalBorder;
m_macVerticalBorder = kMacOSXVerticalBorder;
}
MacPreControlCreate( parent , id , label , pos , size ,style, validator , name , &bounds , title ) ; m_label = label ;
m_macControl = ::NewControl( MAC_WXHWND(parent->MacGetRootWindow()) , &bounds , title , false , 0 , 0 , 1, Rect bounds = wxMacGetBoundsForControl( this , pos , size ) ;
m_macControl = (WXWidget) ::NewControl( MAC_WXHWND(parent->MacGetTopLevelWindowRef()) , &bounds , "\p" , true , 0 , 0 , 1,
kControlPushButtonProc , (long) this ) ; kControlPushButtonProc , (long) this ) ;
wxASSERT_MSG( (ControlHandle) m_macControl != NULL , wxT("No valid mac control") ) ; wxASSERT_MSG( (ControlRef) m_macControl != NULL , wxT("No valid mac control") ) ;
MacPostControlCreate() ; MacPostControlCreate(pos,size) ;
return TRUE; return TRUE;
} }
@@ -72,13 +63,13 @@ void wxButton::SetDefault()
if ( btnOldDefault && btnOldDefault->m_macControl ) if ( btnOldDefault && btnOldDefault->m_macControl )
{ {
inData = 0; inData = 0;
::SetControlData( (ControlHandle) btnOldDefault->m_macControl , kControlButtonPart , ::SetControlData( (ControlRef) btnOldDefault->m_macControl , kControlButtonPart ,
kControlPushButtonDefaultTag , sizeof( Boolean ) , (char*)(&inData) ) ; kControlPushButtonDefaultTag , sizeof( Boolean ) , (char*)(&inData) ) ;
} }
if ( (ControlHandle) m_macControl ) if ( (ControlRef) m_macControl )
{ {
inData = 1; inData = 1;
::SetControlData( (ControlHandle) m_macControl , kControlButtonPart , ::SetControlData( (ControlRef) m_macControl , kControlButtonPart ,
kControlPushButtonDefaultTag , sizeof( Boolean ) , (char*)(&inData) ) ; kControlPushButtonDefaultTag , sizeof( Boolean ) , (char*)(&inData) ) ;
} }
} }
@@ -87,8 +78,25 @@ wxSize wxButton::DoGetBestSize() const
{ {
wxSize sz = GetDefaultSize() ; wxSize sz = GetDefaultSize() ;
int wBtn = m_label.Length() * 8 + 12 + 2 * kMacOSXHorizontalBorder ; int charspace = 8 ;
if ( GetWindowVariant() == wxWINDOW_VARIANT_NORMAL || GetWindowVariant() == wxWINDOW_VARIANT_LARGE )
{
sz.y = 20 ;
charspace = 10 ;
}
else if ( GetWindowVariant() == wxWINDOW_VARIANT_SMALL )
{
sz.y = 17 ;
charspace = 8 ;
}
else if ( GetWindowVariant() == wxWINDOW_VARIANT_MINI )
{
sz.y = 15 ;
charspace = 8 ;
}
int wBtn = m_label.Length() * charspace + 12 ;
if (wBtn > sz.x) sz.x = wBtn; if (wBtn > sz.x) sz.x = wBtn;
return sz ; return sz ;
@@ -98,24 +106,18 @@ wxSize wxButton::GetDefaultSize()
{ {
int wBtn = 70 ; int wBtn = 70 ;
int hBtn = 20 ; int hBtn = 20 ;
if ( UMAHasAquaLayout() )
{
wBtn += 2 * kMacOSXHorizontalBorder ;
hBtn += 2 * kMacOSXVerticalBorder ;
}
return wxSize(wBtn, hBtn); return wxSize(wBtn, hBtn);
} }
void wxButton::Command (wxCommandEvent & event) void wxButton::Command (wxCommandEvent & event)
{ {
if ( (ControlHandle) m_macControl ) if ( (ControlRef) m_macControl )
{ {
HiliteControl( (ControlHandle) m_macControl , kControlButtonPart ) ; HiliteControl( (ControlRef) m_macControl , kControlButtonPart ) ;
unsigned long finalTicks ; unsigned long finalTicks ;
Delay( 8 , &finalTicks ) ; Delay( 8 , &finalTicks ) ;
HiliteControl( (ControlHandle) m_macControl , 0 ) ; HiliteControl( (ControlRef) m_macControl , 0 ) ;
} }
ProcessCommand (event); ProcessCommand (event);
} }

View File

@@ -31,13 +31,12 @@ bool wxCheckBox::Create(wxWindow *parent, wxWindowID id, const wxString& label,
const wxValidator& validator, const wxValidator& validator,
const wxString& name) const wxString& name)
{ {
m_macIsUserPane = FALSE ;
if ( !wxCheckBoxBase::Create(parent, id, pos, size, style, validator, name) ) if ( !wxCheckBoxBase::Create(parent, id, pos, size, style, validator, name) )
return false; return false;
Rect bounds ; m_label = label ;
Str255 title ;
MacPreControlCreate( parent , id , label , pos , size ,style, validator , name , &bounds , title ) ;
SInt16 maxValue = 1 /* kControlCheckboxCheckedValue */; SInt16 maxValue = 1 /* kControlCheckboxCheckedValue */;
if (style & wxCHK_3STATE) if (style & wxCHK_3STATE)
@@ -45,10 +44,12 @@ bool wxCheckBox::Create(wxWindow *parent, wxWindowID id, const wxString& label,
maxValue = 2 /* kControlCheckboxMixedValue */; maxValue = 2 /* kControlCheckboxMixedValue */;
} }
m_macControl = ::NewControl( MAC_WXHWND(parent->MacGetRootWindow()) , &bounds , title , false , 0 , 0 , maxValue,
Rect bounds = wxMacGetBoundsForControl( this , pos , size ) ;
m_macControl = (WXWidget) ::NewControl( MAC_WXHWND(parent->MacGetTopLevelWindowRef()) , &bounds , "\p" , true , 0 , 0 , maxValue,
kControlCheckBoxProc , (long) this ) ; kControlCheckBoxProc , (long) this ) ;
MacPostControlCreate() ; MacPostControlCreate(pos,size) ;
return TRUE; return TRUE;
} }
@@ -85,12 +86,12 @@ void wxCheckBox::Command (wxCommandEvent & event)
wxCheckBoxState wxCheckBox::DoGet3StateValue() const wxCheckBoxState wxCheckBox::DoGet3StateValue() const
{ {
return (wxCheckBoxState) ::GetControl32BitValue( (ControlHandle) m_macControl ); return (wxCheckBoxState) ::GetControl32BitValue( (ControlRef) m_macControl );
} }
void wxCheckBox::DoSet3StateValue(wxCheckBoxState val) void wxCheckBox::DoSet3StateValue(wxCheckBoxState val)
{ {
::SetControl32BitValue( (ControlHandle) m_macControl , (int) val) ; ::SetControl32BitValue( (ControlRef) m_macControl , (int) val) ;
MacRedrawControl() ; MacRedrawControl() ;
} }

View File

@@ -70,7 +70,7 @@ static pascal void wxMacCheckListDefinition( short message, Boolean isSelected,
ListHandle listHandle ) ListHandle listHandle )
{ {
wxCheckListBox* list; wxCheckListBox* list;
list = (wxCheckListBox*) GetControlReference( (ControlHandle) GetListRefCon(listHandle) ); list = (wxCheckListBox*) GetControlReference( (ControlRef) GetListRefCon(listHandle) );
if ( list == NULL ) if ( list == NULL )
return ; return ;
@@ -109,9 +109,9 @@ static pascal void wxMacCheckListDefinition( short message, Boolean isSelected,
const wxFont& font = list->GetFont(); const wxFont& font = list->GetFont();
if ( font.Ok() ) if ( font.Ok() )
{ {
::TextFont( font.GetMacFontNum() ) ; ::TextFont( font.MacGetFontNum() ) ;
::TextSize( font.GetMacFontSize()) ; ::TextSize( font.MacGetFontSize()) ;
::TextFace( font.GetMacFontStyle() ) ; ::TextFace( font.MacGetFontStyle() ) ;
} }
ThemeButtonDrawInfo info ; ThemeButtonDrawInfo info ;
@@ -201,6 +201,8 @@ bool wxCheckListBox::Create(wxWindow *parent,
const wxValidator& validator, const wxValidator& validator,
const wxString &name) const wxString &name)
{ {
m_macIsUserPane = FALSE ;
if ( !wxCheckListBoxBase::Create(parent, id, pos, size, if ( !wxCheckListBoxBase::Create(parent, id, pos, size,
n, choices, style, validator, name) ) n, choices, style, validator, name) )
return false; return false;
@@ -220,7 +222,7 @@ bool wxCheckListBox::Create(wxWindow *parent,
const wxFont& font = GetFont(); const wxFont& font = GetFont();
FontInfo finfo; FontInfo finfo;
FetchFontInfo(font.GetMacFontNum(),font.GetMacFontSize(),font.GetMacFontStyle(),&finfo); FetchFontInfo(font.MacGetFontNum(),font.MacGetFontSize(),font.MacGetFontStyle(),&finfo);
m_TextBaseLineOffset= finfo.leading+finfo.ascent; m_TextBaseLineOffset= finfo.leading+finfo.ascent;
m_checkBoxHeight= finfo.leading+finfo.ascent+finfo.descent; m_checkBoxHeight= finfo.leading+finfo.ascent+finfo.descent;
@@ -231,10 +233,8 @@ bool wxCheckListBox::Create(wxWindow *parent,
m_checkBoxHeight= h; m_checkBoxHeight= h;
} }
Rect bounds ;
Str255 title ; Rect bounds = wxMacGetBoundsForControl( this , pos , size ) ;
MacPreControlCreate( parent , id , wxEmptyString , pos , size ,style, validator , name , &bounds , title ) ;
ListDefSpec listDef; ListDefSpec listDef;
listDef.defType = kListDefUserProcType; listDef.defType = kListDefUserProcType;
@@ -248,24 +248,24 @@ bool wxCheckListBox::Create(wxWindow *parent,
Size asize; Size asize;
CreateListBoxControl( MAC_WXHWND(parent->MacGetRootWindow()), &bounds, false, 0, 1, false, true, CreateListBoxControl( MAC_WXHWND(parent->MacGetTopLevelWindowRef()), &bounds, false, 0, 1, false, true,
m_checkBoxHeight+2, 14, false, &listDef, (ControlRef *)&m_macControl ); m_checkBoxHeight+2, 14, false, &listDef, (ControlRef *)&m_macControl );
GetControlData( (ControlHandle) m_macControl, kControlNoPart, kControlListBoxListHandleTag, GetControlData( (ControlRef) m_macControl, kControlNoPart, kControlListBoxListHandleTag,
sizeof(ListHandle), (Ptr) &m_macList, &asize); sizeof(ListHandle), (Ptr) &m_macList, &asize);
SetControlReference( (ControlHandle) m_macControl, (long) this); SetControlReference( (ControlRef) m_macControl, (long) this);
SetControlVisibility( (ControlHandle) m_macControl, false, false); SetControlVisibility( (ControlRef) m_macControl, false, false);
#else #else
long result ; long result ;
wxStAppResource resload ; wxStAppResource resload ;
m_macControl = ::NewControl( MAC_WXHWND(parent->MacGetRootWindow()) , &bounds , title , false , m_macControl = (WXWidget) ::NewControl( MAC_WXHWND(parent->MacGetTopLevelWindowRef()) , &bounds , "\p" , true ,
kwxMacListWithVerticalScrollbar , 0 , 0, kwxMacListWithVerticalScrollbar , 0 , 0,
kControlListBoxProc , (long) this ) ; kControlListBoxProc , (long) this ) ;
::GetControlData( (ControlHandle) m_macControl , kControlNoPart , kControlListBoxListHandleTag , ::GetControlData( (ControlRef) m_macControl , kControlNoPart , kControlListBoxListHandleTag ,
sizeof( ListHandle ) , (char*) &m_macList , &result ) ; sizeof( ListHandle ) , (char*) &m_macList , &result ) ;
HLock( (Handle) m_macList ) ; HLock( (Handle) m_macList ) ;
@@ -298,7 +298,7 @@ bool wxCheckListBox::Create(wxWindow *parent,
} }
SetListSelectionFlags((ListHandle)m_macList, options); SetListSelectionFlags((ListHandle)m_macList, options);
MacPostControlCreate() ; MacPostControlCreate(pos,size) ;
for ( int i = 0 ; i < n ; i++ ) for ( int i = 0 ; i < n ; i++ )
{ {

View File

@@ -60,23 +60,22 @@ bool wxChoice::Create(wxWindow *parent, wxWindowID id,
const wxValidator& validator, const wxValidator& validator,
const wxString& name) const wxString& name)
{ {
m_macIsUserPane = FALSE ;
if ( !wxChoiceBase::Create(parent, id, pos, size, style, validator, name) ) if ( !wxChoiceBase::Create(parent, id, pos, size, style, validator, name) )
return false; return false;
Rect bounds ; Rect bounds = wxMacGetBoundsForControl( this , pos , size ) ;
Str255 title ; m_macControl = (WXWidget) ::NewControl( MAC_WXHWND(parent->MacGetTopLevelWindowRef()) , &bounds , "\p" , true , 0 , -12345 , 0 ,
MacPreControlCreate( parent , id , wxEmptyString , pos , size ,style, validator , name , &bounds , title ) ;
m_macControl = ::NewControl( MAC_WXHWND(parent->MacGetRootWindow()) , &bounds , title , false , 0 , -12345 , 0 ,
kControlPopupButtonProc + kControlPopupFixedWidthVariant , (long) this ) ; kControlPopupButtonProc + kControlPopupFixedWidthVariant , (long) this ) ;
m_macPopUpMenuHandle = NewUniqueMenu() ; m_macPopUpMenuHandle = NewUniqueMenu() ;
SetControlData( (ControlHandle) m_macControl , kControlNoPart , kControlPopupButtonMenuHandleTag , sizeof( MenuHandle ) , (char*) &m_macPopUpMenuHandle) ; SetControlData( (ControlRef) m_macControl , kControlNoPart , kControlPopupButtonMenuHandleTag , sizeof( MenuHandle ) , (char*) &m_macPopUpMenuHandle) ;
SetControl32BitMinimum( (ControlHandle) m_macControl , 0 ) ; SetControl32BitMinimum( (ControlRef) m_macControl , 0 ) ;
SetControl32BitMaximum( (ControlHandle) m_macControl , 0) ; SetControl32BitMaximum( (ControlRef) m_macControl , 0) ;
if ( n > 0 ) if ( n > 0 )
SetControl32BitValue( (ControlHandle) m_macControl , 1 ) ; SetControl32BitValue( (ControlRef) m_macControl , 1 ) ;
MacPostControlCreate() ; MacPostControlCreate(pos,size) ;
// TODO wxCB_SORT // TODO wxCB_SORT
for ( int i = 0; i < n; i++ ) for ( int i = 0; i < n; i++ )
{ {
@@ -95,7 +94,7 @@ int wxChoice::DoAppend(const wxString& item)
m_datas.Add( NULL ) ; m_datas.Add( NULL ) ;
int index = m_strings.GetCount() - 1 ; int index = m_strings.GetCount() - 1 ;
DoSetItemClientData( index , NULL ) ; DoSetItemClientData( index , NULL ) ;
SetControl32BitMaximum( (ControlHandle) m_macControl , GetCount()) ; SetControl32BitMaximum( (ControlRef) m_macControl , GetCount()) ;
return index ; return index ;
} }
@@ -111,7 +110,7 @@ int wxChoice::DoInsert(const wxString& item, int pos)
m_strings.Insert( item, pos ) ; m_strings.Insert( item, pos ) ;
m_datas.Insert( NULL, pos ) ; m_datas.Insert( NULL, pos ) ;
DoSetItemClientData( pos , NULL ) ; DoSetItemClientData( pos , NULL ) ;
SetControl32BitMaximum( (ControlHandle) m_macControl , pos) ; SetControl32BitMaximum( (ControlRef) m_macControl , pos) ;
return pos ; return pos ;
} }
@@ -125,7 +124,7 @@ void wxChoice::Delete(int n)
::DeleteMenuItem( MAC_WXHMENU(m_macPopUpMenuHandle) , n + 1) ; ::DeleteMenuItem( MAC_WXHMENU(m_macPopUpMenuHandle) , n + 1) ;
m_strings.RemoveAt( n ) ; m_strings.RemoveAt( n ) ;
m_datas.RemoveAt( n ) ; m_datas.RemoveAt( n ) ;
SetControl32BitMaximum( (ControlHandle) m_macControl , GetCount()) ; SetControl32BitMaximum( (ControlRef) m_macControl , GetCount()) ;
} }
void wxChoice::Clear() void wxChoice::Clear()
@@ -137,7 +136,7 @@ void wxChoice::Clear()
} }
m_strings.Empty() ; m_strings.Empty() ;
m_datas.Empty() ; m_datas.Empty() ;
SetControl32BitMaximum( (ControlHandle) m_macControl , 0 ) ; SetControl32BitMaximum( (ControlRef) m_macControl , 0 ) ;
} }
void wxChoice::FreeData() void wxChoice::FreeData()
@@ -157,12 +156,12 @@ void wxChoice::FreeData()
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
int wxChoice::GetSelection() const int wxChoice::GetSelection() const
{ {
return GetControl32BitValue( (ControlHandle) m_macControl ) -1 ; return GetControl32BitValue( (ControlRef) m_macControl ) -1 ;
} }
void wxChoice::SetSelection(int n) void wxChoice::SetSelection(int n)
{ {
SetControl32BitValue( (ControlHandle) m_macControl , n + 1 ) ; SetControl32BitValue( (ControlRef) m_macControl , n + 1 ) ;
} }
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
@@ -258,12 +257,12 @@ wxSize wxChoice::DoGetBestSize() const
lbHeight = metric ; lbHeight = metric ;
#endif #endif
{ {
wxMacPortStateHelper st( UMAGetWindowPort( (WindowRef) MacGetRootWindow() ) ) ; wxMacPortStateHelper st( UMAGetWindowPort( (WindowRef) MacGetTopLevelWindowRef() ) ) ;
if ( m_font.Ok() ) if ( m_font.Ok() )
{ {
::TextFont( m_font.GetMacFontNum() ) ; ::TextFont( m_font.MacGetFontNum() ) ;
::TextSize( m_font.GetMacFontSize() ) ; ::TextSize( m_font.MacGetFontSize() ) ;
::TextFace( m_font.GetMacFontStyle() ) ; ::TextFace( m_font.MacGetFontStyle() ) ;
} }
else else
{ {

View File

@@ -236,11 +236,6 @@ bool wxClipboard::AddData( wxDataObject *data )
wxT("wxClipboard now supports atom %s"), wxT("wxClipboard now supports atom %s"),
array[i].GetId().c_str() ); array[i].GetId().c_str() );
#if !TARGET_CARBON
OSErr err = noErr ;
#else
OSStatus err = noErr ;
#endif
size_t sz = data->GetDataSize( array[i] ) ; size_t sz = data->GetDataSize( array[i] ) ;
void* buf = malloc( sz + 1 ) ; void* buf = malloc( sz + 1 ) ;
if ( buf ) if ( buf )

View File

@@ -204,7 +204,9 @@ void wxComboBox::DoMoveWindow(int x, int y, int width, int height) {
if ( m_text == NULL ) if ( m_text == NULL )
{ {
m_choice->SetSize(0, 0 , width, -1); // we might not be fully constructed yet, therefore watch out...
if ( m_choice )
m_choice->SetSize(0, 0 , width, -1);
} }
else else
{ {

View File

@@ -33,11 +33,6 @@
#if !USE_SHARED_LIBRARY #if !USE_SHARED_LIBRARY
IMPLEMENT_ABSTRACT_CLASS(wxControl, wxWindow) IMPLEMENT_ABSTRACT_CLASS(wxControl, wxWindow)
BEGIN_EVENT_TABLE(wxControl, wxWindow)
EVT_MOUSE_EVENTS( wxControl::OnMouseEvent )
EVT_PAINT( wxControl::OnPaint )
END_EVENT_TABLE()
#endif #endif
#include "wx/mac/uma.h" #include "wx/mac/uma.h"
@@ -45,117 +40,8 @@ END_EVENT_TABLE()
// Item members // Item members
#if PRAGMA_STRUCT_ALIGN
#pragma options align=mac68k
#elif PRAGMA_STRUCT_PACKPUSH
#pragma pack(push, 2)
#elif PRAGMA_STRUCT_PACK
#pragma pack(2)
#endif
typedef struct {
unsigned short instruction;
void (*function)();
} cdefRec, *cdefPtr, **cdefHandle;
#if PRAGMA_STRUCT_ALIGN
#pragma options align=reset
#elif PRAGMA_STRUCT_PACKPUSH
#pragma pack(pop)
#elif PRAGMA_STRUCT_PACK
#pragma pack()
#endif
ControlActionUPP wxMacLiveScrollbarActionUPP = NULL ;
wxControl *wxFindControlFromMacControl(ControlHandle inControl ) ;
pascal void wxMacLiveScrollbarActionProc( ControlHandle control , ControlPartCode partCode ) ;
pascal void wxMacLiveScrollbarActionProc( ControlHandle control , ControlPartCode partCode )
{
if ( partCode != 0)
{
wxControl* wx = (wxControl*) GetControlReference( control ) ;
if ( wx )
{
wx->MacHandleControlClick( control , partCode , true /* stillDown */ ) ;
}
}
}
ControlColorUPP wxMacSetupControlBackgroundUPP = NULL ;
ControlDefUPP wxMacControlActionUPP = NULL ;
pascal SInt32 wxMacControlDefinition(SInt16 varCode, ControlRef theControl, ControlDefProcMessage message, SInt32 param)
{
wxControl* wx = (wxControl*) wxFindControlFromMacControl( theControl ) ;
if ( wx != NULL && wx->IsKindOf( CLASSINFO( wxControl ) ) )
{
if( message == drawCntl )
{
wxMacWindowClipper clip( wx ) ;
return InvokeControlDefUPP( varCode , theControl , message , param , (ControlDefUPP) wx->MacGetControlAction() ) ;
}
else
return InvokeControlDefUPP( varCode , theControl , message , param , (ControlDefUPP) wx->MacGetControlAction() ) ;
}
return NULL ;
}
pascal OSStatus wxMacSetupControlBackground( ControlRef iControl , SInt16 iMessage , SInt16 iDepth , Boolean iIsColor )
{
OSStatus status = noErr ;
switch( iMessage )
{
case kControlMsgSetUpBackground :
{
wxControl* wx = (wxControl*) GetControlReference( iControl ) ;
if ( wx != NULL && wx->IsKindOf( CLASSINFO( wxControl ) ) )
{
wxDC::MacSetupBackgroundForCurrentPort( wx->MacGetBackgroundBrush() ) ;
#if TARGET_CARBON
// under classic this would lead to partial redraws
RgnHandle clip = NewRgn() ;
int x = 0 , y = 0;
wx->MacWindowToRootWindow( &x,&y ) ;
CopyRgn( (RgnHandle) wx->MacGetVisibleRegion(false).GetWXHRGN() , clip ) ;
OffsetRgn( clip , x , y ) ;
SetClip( clip ) ;
DisposeRgn( clip ) ;
#endif
}
else
{
status = paramErr ;
}
}
break ;
default :
status = paramErr ;
break ;
}
return status ;
}
wxControl::wxControl() wxControl::wxControl()
{ {
m_macControl = NULL ;
m_macControlAction = NULL ;
m_macHorizontalBorder = 0 ; // additional pixels around the real control
m_macVerticalBorder = 0 ;
m_backgroundColour = *wxWHITE;
m_foregroundColour = *wxBLACK;
if ( wxMacLiveScrollbarActionUPP == NULL )
{
#if defined(UNIVERSAL_INTERFACES_VERSION) && (UNIVERSAL_INTERFACES_VERSION >= 0x0340)
wxMacLiveScrollbarActionUPP = NewControlActionUPP( wxMacLiveScrollbarActionProc );
#else
wxMacLiveScrollbarActionUPP = NewControlActionProc( wxMacLiveScrollbarActionProc ) ;
#endif
}
} }
bool wxControl::Create(wxWindow *parent, wxWindowID id, bool wxControl::Create(wxWindow *parent, wxWindowID id,
@@ -164,17 +50,19 @@ bool wxControl::Create(wxWindow *parent, wxWindowID id,
const wxValidator& validator, const wxValidator& validator,
const wxString& name) const wxString& name)
{ {
m_macControl = NULL ;
m_macHorizontalBorder = 0 ; // additional pixels around the real control
m_macVerticalBorder = 0 ;
bool rval = wxWindow::Create(parent, id, pos, size, style, name); bool rval = wxWindow::Create(parent, id, pos, size, style, name);
#if 0
// no automatic inheritance as we most often need transparent backgrounds
if ( parent ) if ( parent )
{ {
m_backgroundColour = parent->GetBackgroundColour() ; m_backgroundColour = parent->GetBackgroundColour() ;
m_foregroundColour = parent->GetForegroundColour() ; m_foregroundColour = parent->GetForegroundColour() ;
} }
if (rval) { #endif
if (rval)
{
#if wxUSE_VALIDATORS #if wxUSE_VALIDATORS
SetValidator(validator); SetValidator(validator);
#endif #endif
@@ -185,73 +73,6 @@ bool wxControl::Create(wxWindow *parent, wxWindowID id,
wxControl::~wxControl() wxControl::~wxControl()
{ {
m_isBeingDeleted = TRUE; m_isBeingDeleted = TRUE;
wxRemoveMacControlAssociation( this ) ;
// If we delete an item, we should initialize the parent panel,
// because it could now be invalid.
wxWindow *parent = GetParent() ;
if ( parent )
{
if (parent->GetDefaultItem() == (wxButton*) this)
parent->SetDefaultItem(NULL);
}
if ( (ControlHandle) m_macControl )
{
// in case the callback might be called during destruction
::SetControlColorProc( (ControlHandle) m_macControl , NULL ) ;
::DisposeControl( (ControlHandle) m_macControl ) ;
m_macControl = NULL ;
}
}
void wxControl::SetLabel(const wxString& title)
{
m_label = wxStripMenuCodes(title) ;
if ( m_macControl )
{
UMASetControlTitle( (ControlHandle) m_macControl , m_label , m_font.GetEncoding() ) ;
}
Refresh() ;
}
wxSize wxControl::DoGetBestSize() const
{
if ( (ControlHandle) m_macControl == NULL )
return wxWindow::DoGetBestSize() ;
Rect bestsize = { 0 , 0 , 0 , 0 } ;
short baselineoffset ;
int bestWidth, bestHeight ;
::GetBestControlRect( (ControlHandle) m_macControl , &bestsize , &baselineoffset ) ;
if ( EmptyRect( &bestsize ) )
{
baselineoffset = 0;
bestsize.left = bestsize.top = 0 ;
bestsize.right = 16 ;
bestsize.bottom = 16 ;
if ( IsKindOf( CLASSINFO( wxScrollBar ) ) )
{
bestsize.bottom = 16 ;
}
else if ( IsKindOf( CLASSINFO( wxSpinButton ) ) )
{
bestsize.bottom = 24 ;
}
}
bestWidth = bestsize.right - bestsize.left ;
bestWidth += 2 * m_macHorizontalBorder ;
bestHeight = bestsize.bottom - bestsize.top ;
if ( bestHeight < 10 )
bestHeight = 13 ;
bestHeight += 2 * m_macVerticalBorder;
return wxSize(bestWidth, bestHeight);
} }
bool wxControl::ProcessCommand (wxCommandEvent & event) bool wxControl::ProcessCommand (wxCommandEvent & event)
@@ -262,398 +83,9 @@ bool wxControl::ProcessCommand (wxCommandEvent & event)
return GetEventHandler()->ProcessEvent(event); return GetEventHandler()->ProcessEvent(event);
} }
// ------------------------
wxList *wxWinMacControlList = NULL;
wxControl *wxFindControlFromMacControl(ControlHandle inControl )
{
wxNode *node = wxWinMacControlList->Find((long)inControl);
if (!node)
return NULL;
return (wxControl *)node->GetData();
}
void wxAssociateControlWithMacControl(ControlHandle inControl, wxControl *control)
{
// adding NULL WindowRef is (first) surely a result of an error and
// (secondly) breaks menu command processing
wxCHECK_RET( inControl != (ControlHandle) NULL, wxT("attempt to add a NULL WindowRef to window list") );
if ( !wxWinMacControlList->Find((long)inControl) )
wxWinMacControlList->Append((long)inControl, control);
}
void wxRemoveMacControlAssociation(wxControl *control)
{
if ( wxWinMacControlList )
wxWinMacControlList->DeleteObject(control);
}
void wxControl::MacPreControlCreate( wxWindow *parent, wxWindowID id, wxString label ,
const wxPoint& pos,
const wxSize& size, long style,
const wxValidator& validator,
const wxString& name , WXRECTPTR outBounds , unsigned char* maclabel )
{
m_label = label ;
// These sizes will be adjusted in MacPostControlCreate
m_width = size.x ;
m_height = size.y ;
m_x = pos.x ;
m_y = pos.y ;
((Rect*)outBounds)->top = -10;
((Rect*)outBounds)->left = -10;
((Rect*)outBounds)->bottom = 0;
((Rect*)outBounds)->right = 0;
wxMacStringToPascal( wxStripMenuCodes(label) , maclabel ) ;
}
void wxControl::MacPostControlCreate()
{
wxASSERT_MSG( (ControlHandle) m_macControl != NULL , wxT("No valid mac control") ) ;
DoSetWindowVariant( m_windowVariant ) ;
/*
if ( IsKindOf( CLASSINFO( wxScrollBar ) ) )
{
// no font
}
else if ( !UMAHasAquaLayout() && (IsKindOf( CLASSINFO( wxStaticBox ) ) || IsKindOf( CLASSINFO( wxRadioBox ) ) || IsKindOf( CLASSINFO( wxButton ) ) ) )
{
ControlFontStyleRec controlstyle ;
controlstyle.flags = kControlUseFontMask ;
controlstyle.font = kControlFontSmallBoldSystemFont ;
::SetControlFontStyle( (ControlHandle) m_macControl , &controlstyle ) ;
}
else
{
ControlFontStyleRec controlstyle ;
controlstyle.flags = kControlUseFontMask ;
if (IsKindOf( CLASSINFO( wxButton ) ) )
controlstyle.font = kControlFontBigSystemFont ; // eventually kControlFontBigSystemFont ;
else
controlstyle.font = kControlFontSmallSystemFont ;
::SetControlFontStyle( (ControlHandle) m_macControl , &controlstyle ) ;
}
*/
ControlHandle container = (ControlHandle) GetParent()->MacGetContainerForEmbedding() ;
wxASSERT_MSG( container != NULL , wxT("No valid mac container control") ) ;
::EmbedControl( (ControlHandle) m_macControl , container ) ;
m_macControlIsShown = MacIsReallyShown() ;
wxAssociateControlWithMacControl( (ControlHandle) m_macControl , this ) ;
if ( wxMacSetupControlBackgroundUPP == NULL )
{
wxMacSetupControlBackgroundUPP = NewControlColorUPP( wxMacSetupControlBackground ) ;
}
if ( wxMacControlActionUPP == NULL )
{
wxMacControlActionUPP = NewControlDefUPP( wxMacControlDefinition ) ;
}
// The following block of code is responsible for crashes when switching
// back to windows, which can be seen in the dialogs sample.
// It is disabled until a proper solution can be found.
#if 0
#if TARGET_CARBON
/*
only working under classic carbon
m_macControlAction = *(**(ControlHandle)m_macControl).contrlDefProc ;
(**(ControlHandle)m_macControl).contrlDefProc = (Handle) &wxMacControlActionUPP ;
*/
#else
m_macControlAction = *(**(ControlHandle)m_macControl).contrlDefProc ;
cdefHandle cdef ;
cdef = (cdefHandle) NewHandle( sizeof(cdefRec) ) ;
if ( (**(ControlHandle)m_macControl).contrlDefProc != NULL )
{
(**cdef).instruction = 0x4EF9; /* JMP instruction */
(**cdef).function = (void(*)()) wxMacControlActionUPP;
(**(ControlHandle)m_macControl).contrlDefProc = (Handle) cdef ;
}
#endif
#endif
SetControlColorProc( (ControlHandle) m_macControl , wxMacSetupControlBackgroundUPP ) ;
// Adjust the controls size and position
wxPoint pos(m_x, m_y);
wxSize best_size( DoGetBestSize() );
wxSize new_size( m_width, m_height );
m_x = m_y = m_width = m_height = -1; // Forces SetSize to move/size the control
if (new_size.x == -1) {
new_size.x = best_size.x;
}
if (new_size.y == -1) {
new_size.y = best_size.y;
}
SetSize(pos.x, pos.y, new_size.x, new_size.y);
#if wxUSE_UNICODE
UMASetControlTitle( (ControlHandle) m_macControl , wxStripMenuCodes(m_label) , m_font.GetEncoding() ) ;
#endif
if ( m_macControlIsShown )
UMAShowControl( (ControlHandle) m_macControl ) ;
SetCursor( *wxSTANDARD_CURSOR ) ;
Refresh() ;
}
void wxControl::MacAdjustControlRect()
{
wxASSERT_MSG( (ControlHandle) m_macControl != NULL , wxT("No valid mac control") ) ;
if ( m_width == -1 || m_height == -1 )
{
Rect bestsize = { 0 , 0 , 0 , 0 } ;
short baselineoffset ;
::GetBestControlRect( (ControlHandle) m_macControl , &bestsize , &baselineoffset ) ;
if ( EmptyRect( &bestsize ) )
{
baselineoffset = 0;
bestsize.left = bestsize.top = 0 ;
bestsize.right = 16 ;
bestsize.bottom = 16 ;
if ( IsKindOf( CLASSINFO( wxScrollBar ) ) )
{
bestsize.bottom = 16 ;
}
else if ( IsKindOf( CLASSINFO( wxSpinButton ) ) )
{
bestsize.bottom = 24 ;
}
}
if ( m_width == -1 )
{
if ( IsKindOf( CLASSINFO( wxButton ) ) )
{
m_width = m_label.Length() * 8 + 12 ;
if ( m_width < 70 )
m_width = 70 ;
}
else if ( IsKindOf( CLASSINFO( wxStaticText ) ) )
{
m_width = m_label.Length() * 8 ;
}
else
m_width = bestsize.right - bestsize.left ;
m_width += 2 * m_macHorizontalBorder + MacGetLeftBorderSize() + MacGetRightBorderSize() ;
}
if ( m_height == -1 )
{
m_height = bestsize.bottom - bestsize.top ;
if ( m_height < 10 )
m_height = 13 ;
m_height += 2 * m_macVerticalBorder + MacGetTopBorderSize() + MacGetBottomBorderSize() ;
}
MacUpdateDimensions() ;
}
}
WXWidget wxControl::MacGetContainerForEmbedding()
{
if ( m_macControl )
return m_macControl ;
return wxWindow::MacGetContainerForEmbedding() ;
}
void wxControl::MacUpdateDimensions()
{
// actually in the current systems this should never be possible, but later reparenting
// may become a reality
if ( (ControlHandle) m_macControl == NULL )
return ;
if ( GetParent() == NULL )
return ;
WindowRef rootwindow = (WindowRef) MacGetRootWindow() ;
if ( rootwindow == NULL )
return ;
Rect oldBounds ;
GetControlBounds( (ControlHandle) m_macControl , &oldBounds ) ;
int new_x = m_x + MacGetLeftBorderSize() + m_macHorizontalBorder ;
int new_y = m_y + MacGetTopBorderSize() + m_macVerticalBorder ;
int new_width = m_width - MacGetLeftBorderSize() - MacGetRightBorderSize() - 2 * m_macHorizontalBorder ;
int new_height = m_height - MacGetTopBorderSize() - MacGetBottomBorderSize() - 2 * m_macVerticalBorder ;
GetParent()->MacWindowToRootWindow( & new_x , & new_y ) ;
bool doMove = new_x != oldBounds.left || new_y != oldBounds.top ;
bool doResize = ( oldBounds.right - oldBounds.left ) != new_width || (oldBounds.bottom - oldBounds.top ) != new_height ;
if ( doMove || doResize )
{
InvalWindowRect( rootwindow, &oldBounds ) ;
if ( doMove )
{
UMAMoveControl( (ControlHandle) m_macControl , new_x , new_y ) ;
}
if ( doResize )
{
UMASizeControl( (ControlHandle) m_macControl , new_width , new_height ) ;
}
}
}
void wxControl::MacSuperChangedPosition()
{
MacUpdateDimensions() ;
wxWindow::MacSuperChangedPosition() ;
}
void wxControl::MacSuperEnabled( bool enabled )
{
Refresh(FALSE) ;
wxWindow::MacSuperEnabled( enabled ) ;
}
void wxControl::MacSuperShown( bool show )
{
if ( (ControlHandle) m_macControl )
{
if ( !show )
{
if ( m_macControlIsShown )
{
::UMAHideControl( (ControlHandle) m_macControl ) ;
m_macControlIsShown = false ;
}
}
else
{
if ( MacIsReallyShown() && !m_macControlIsShown )
{
::UMAShowControl( (ControlHandle) m_macControl ) ;
m_macControlIsShown = true ;
}
}
}
wxWindow::MacSuperShown( show ) ;
}
void wxControl::DoSetSize(int x, int y,
int width, int height,
int sizeFlags )
{
wxWindow::DoSetSize( x , y ,width , height ,sizeFlags ) ;
#if 0
{
Rect meta , control ;
GetControlBounds( (ControlHandle) m_macControl , &control ) ;
RgnHandle rgn = NewRgn() ;
GetControlRegion( (ControlHandle) m_macControl , kControlStructureMetaPart , rgn ) ;
GetRegionBounds( rgn , &meta ) ;
if ( !EmptyRect( &meta ) )
{
wxASSERT( meta.left >= control.left - m_macHorizontalBorder ) ;
wxASSERT( meta.right <= control.right + m_macHorizontalBorder ) ;
wxASSERT( meta.top >= control.top - m_macVerticalBorder ) ;
wxASSERT( meta.bottom <= control.bottom + m_macVerticalBorder ) ;
}
DisposeRgn( rgn ) ;
}
#endif
return ;
}
bool wxControl::Show(bool show)
{
if ( !wxWindow::Show( show ) )
return FALSE ;
if ( (ControlHandle) m_macControl )
{
if ( !show )
{
if ( m_macControlIsShown )
{
::UMAHideControl( (ControlHandle) m_macControl ) ;
m_macControlIsShown = false ;
}
}
else
{
if ( MacIsReallyShown() && !m_macControlIsShown )
{
::UMAShowControl( (ControlHandle) m_macControl ) ;
m_macControlIsShown = true ;
}
}
}
return TRUE ;
}
bool wxControl::Enable(bool enable)
{
if ( !wxWindow::Enable(enable) )
return FALSE;
if ( (ControlHandle) m_macControl )
{
if ( enable )
UMAActivateControl( (ControlHandle) m_macControl ) ;
else
UMADeactivateControl( (ControlHandle) m_macControl ) ;
}
return TRUE ;
}
void wxControl::Refresh(bool eraseBack, const wxRect *rect)
{
wxWindow::Refresh( eraseBack , rect ) ;
}
void wxControl::MacRedrawControl()
{
if ( (ControlHandle) m_macControl && MacGetRootWindow() && m_macControlIsShown )
{
wxClientDC dc(this) ;
wxMacPortSetter helper(&dc) ;
wxMacWindowClipper clipper(this) ;
wxDC::MacSetupBackgroundForCurrentPort( MacGetBackgroundBrush() ) ;
UMADrawControl( (ControlHandle) m_macControl ) ;
}
}
void wxControl::OnPaint(wxPaintEvent& event)
{
if ( (ControlHandle) m_macControl )
{
wxPaintDC dc(this) ;
wxMacPortSetter helper(&dc) ;
wxMacWindowClipper clipper(this) ;
wxDC::MacSetupBackgroundForCurrentPort( MacGetBackgroundBrush() ) ;
UMADrawControl( (ControlHandle) m_macControl ) ;
}
else
{
event.Skip() ;
}
}
void wxControl::OnEraseBackground(wxEraseEvent& event)
{
wxWindow::OnEraseBackground( event ) ;
}
void wxControl::OnKeyDown( wxKeyEvent &event ) void wxControl::OnKeyDown( wxKeyEvent &event )
{ {
if ( (ControlHandle) m_macControl == NULL ) if ( (ControlRef) m_macControl == NULL )
return ; return ;
#if TARGET_CARBON #if TARGET_CARBON
@@ -666,7 +98,7 @@ void wxControl::OnKeyDown( wxKeyEvent &event )
GetEventParameter( (EventRef) wxTheApp->MacGetCurrentEvent(), kEventParamKeyCode, typeUInt32, NULL, sizeof(UInt32), NULL, &keyCode ); GetEventParameter( (EventRef) wxTheApp->MacGetCurrentEvent(), kEventParamKeyCode, typeUInt32, NULL, sizeof(UInt32), NULL, &keyCode );
GetEventParameter((EventRef) wxTheApp->MacGetCurrentEvent(), kEventParamKeyModifiers, typeUInt32, NULL, sizeof(UInt32), NULL, &modifiers); GetEventParameter((EventRef) wxTheApp->MacGetCurrentEvent(), kEventParamKeyModifiers, typeUInt32, NULL, sizeof(UInt32), NULL, &modifiers);
::HandleControlKey( (ControlHandle) m_macControl , keyCode , charCode , modifiers ) ; ::HandleControlKey( (ControlRef) m_macControl , keyCode , charCode , modifiers ) ;
#else #else
EventRecord *ev = (EventRecord*) wxTheApp->MacGetCurrentEvent() ; EventRecord *ev = (EventRecord*) wxTheApp->MacGetCurrentEvent() ;
@@ -675,140 +107,7 @@ void wxControl::OnKeyDown( wxKeyEvent &event )
keychar = short(ev->message & charCodeMask); keychar = short(ev->message & charCodeMask);
keycode = short(ev->message & keyCodeMask) >> 8 ; keycode = short(ev->message & keyCodeMask) >> 8 ;
::HandleControlKey( (ControlHandle) m_macControl , keycode , keychar , ev->modifiers ) ; ::HandleControlKey( (ControlRef) m_macControl , keycode , keychar , ev->modifiers ) ;
#endif #endif
} }
void wxControl::OnMouseEvent( wxMouseEvent &event )
{
if ( (ControlHandle) m_macControl == NULL )
{
event.Skip() ;
return ;
}
if (event.GetEventType() == wxEVT_LEFT_DOWN || event.GetEventType() == wxEVT_LEFT_DCLICK )
{
int x = event.m_x ;
int y = event.m_y ;
MacClientToRootWindow( &x , &y ) ;
ControlHandle control ;
Point localwhere ;
SInt16 controlpart ;
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 ;
{
control = (ControlHandle) m_macControl ;
if ( control && ::IsControlActive( control ) )
{
{
controlpart = ::HandleControlClick( control , localwhere , modifiers , (ControlActionUPP) -1 ) ;
wxTheApp->s_lastMouseDown = 0 ;
if ( control && controlpart != kControlNoPart )
{
MacHandleControlClick( control , controlpart , false /* mouse not down anymore */ ) ;
}
}
}
}
}
else
{
event.Skip() ;
}
}
bool wxControl::MacCanFocus() const
{
if ( (ControlHandle) m_macControl == NULL )
return true ;
else
return false ;
}
void wxControl::MacHandleControlClick( WXWidget control , wxInt16 controlpart , bool WXUNUSED( mouseStillDown ) )
{
wxASSERT_MSG( (ControlHandle) m_macControl != NULL , wxT("No valid mac control") ) ;
}
void wxControl::DoSetWindowVariant( wxWindowVariant variant )
{
if ( m_macControl == NULL )
{
wxWindow::SetWindowVariant( variant ) ;
return ;
}
m_windowVariant = variant ;
ControlSize size ;
ControlFontStyleRec fontStyle;
fontStyle.flags = kControlUseFontMask ;
// we will get that from the settings later
// and make this NORMAL later, but first
// we have a few calculations that we must fix
if ( variant == wxWINDOW_VARIANT_DEFAULT )
{
if ( IsKindOf( CLASSINFO( wxScrollBar ) ) )
variant = wxWINDOW_VARIANT_NORMAL ;
else
variant = wxWINDOW_VARIANT_SMALL ;
}
switch ( variant )
{
case wxWINDOW_VARIANT_NORMAL :
size = kControlSizeNormal;
fontStyle.font = kControlFontBigSystemFont;
break ;
case wxWINDOW_VARIANT_SMALL :
size = kControlSizeSmall;
fontStyle.font = kControlFontSmallSystemFont;
break ;
case wxWINDOW_VARIANT_MINI :
if (UMAGetSystemVersion() >= 0x1030 )
{
size = 3 ; // not always defined in the header
fontStyle.font = -5 ; // not always defined in the header
}
else
{
size = kControlSizeSmall;
fontStyle.font = kControlFontSmallSystemFont;
}
break;
break ;
case wxWINDOW_VARIANT_LARGE :
size = kControlSizeLarge;
fontStyle.font = kControlFontBigSystemFont;
break ;
default:
wxFAIL_MSG(_T("unexpected window variant"));
break ;
}
::SetControlData( (ControlHandle) m_macControl , kControlEntireControl, kControlSizeTag, sizeof( ControlSize ), &size );
::SetControlFontStyle( (ControlHandle) m_macControl , &fontStyle );
}

View File

@@ -104,31 +104,8 @@ private :
typedef wxMacPortSetter wxMacFastPortSetter ; typedef wxMacPortSetter wxMacFastPortSetter ;
#endif #endif
#if 0 wxMacWindowClipper::wxMacWindowClipper( const wxWindow* win ) :
wxMacPortSaver( (GrafPtr) GetWindowPort((WindowRef) win->MacGetTopLevelWindowRef()) )
// start moving to a dual implementation for QD and CGContextRef
class wxMacGraphicsContext
{
public :
void DrawBitmap( const wxBitmap &bmp, wxCoord x, wxCoord y, bool useMask ) = 0 ;
void SetClippingRegion( wxCoord x, wxCoord y, wxCoord width, wxCoord height ) = 0 ;
void SetClippingRegion( const wxRegion &region ) = 0 ;
void DestroyClippingRegion() = 0 ;
void SetTextForeground( const wxColour &col ) = 0 ;
void SetTextBackground( const wxColour &col ) = 0 ;
void SetLogicalScale( double x , double y ) = 0 ;
void SetUserScale( double x , double y ) = 0;
} ;
class wxMacQuickDrawContext : public wxMacGraphicsContext
{
public :
} ;
#endif
wxMacWindowClipper::wxMacWindowClipper( const wxWindow* win )
{ {
m_formerClip = NewRgn() ; m_formerClip = NewRgn() ;
m_newClip = NewRgn() ; m_newClip = NewRgn() ;
@@ -136,29 +113,14 @@ wxMacWindowClipper::wxMacWindowClipper( const wxWindow* win )
if ( win ) if ( win )
{ {
#if 0
// this clipping area was set to the parent window's drawing area, lead to problems
// with MacOSX controls drawing outside their wx' rectangle
RgnHandle insidergn = NewRgn() ;
int x = 0 , y = 0;
wxWindow *parent = win->GetParent() ;
parent->MacWindowToRootWindow( &x,&y ) ;
wxSize size = parent->GetSize() ;
SetRectRgn( insidergn , parent->MacGetLeftBorderSize() , parent->MacGetTopBorderSize() ,
size.x - parent->MacGetRightBorderSize(),
size.y - parent->MacGetBottomBorderSize()) ;
CopyRgn( (RgnHandle) parent->MacGetVisibleRegion(false).GetWXHRGN() , m_newClip ) ;
SectRgn( m_newClip , insidergn , m_newClip ) ;
OffsetRgn( m_newClip , x , y ) ;
SetClip( m_newClip ) ;
DisposeRgn( insidergn ) ;
#else
int x = 0 , y = 0; int x = 0 , y = 0;
win->MacWindowToRootWindow( &x,&y ) ; win->MacWindowToRootWindow( &x,&y ) ;
CopyRgn( (RgnHandle) ((wxWindow*)win)->MacGetVisibleRegion().GetWXHRGN() , m_newClip ) ; // get area including focus rect
OffsetRgn( m_newClip , x , y ) ; CopyRgn( (RgnHandle) ((wxWindow*)win)->MacGetVisibleRegion(true).GetWXHRGN() , m_newClip ) ;
if ( !EmptyRgn( m_newClip ) )
OffsetRgn( m_newClip , x , y ) ;
SetClip( m_newClip ) ; SetClip( m_newClip ) ;
#endif
} }
} }
@@ -617,20 +579,6 @@ void wxDC::SetDeviceOrigin( wxCoord x, wxCoord y )
ComputeScaleAndOrigin(); ComputeScaleAndOrigin();
} }
#if 0
void wxDC::SetInternalDeviceOrigin( long x, long y )
{
m_internalDeviceOriginX = x;
m_internalDeviceOriginY = y;
ComputeScaleAndOrigin();
}
void wxDC::GetInternalDeviceOrigin( long *x, long *y )
{
if (x) *x = m_internalDeviceOriginX;
if (y) *y = m_internalDeviceOriginY;
}
#endif
void wxDC::SetAxisOrientation( bool xLeftRight, bool yBottomUp ) void wxDC::SetAxisOrientation( bool xLeftRight, bool yBottomUp )
{ {
m_signX = (xLeftRight ? 1 : -1); m_signX = (xLeftRight ? 1 : -1);
@@ -1358,7 +1306,7 @@ void wxDC::DoDrawRotatedText(const wxString& str, wxCoord x, wxCoord y,
double angle) double angle)
{ {
wxCHECK_RET( Ok(), wxT("wxDC::DoDrawRotatedText Invalid window dc") ); wxCHECK_RET( Ok(), wxT("wxDC::DoDrawRotatedText Invalid window dc") );
/*
if (angle == 0.0 ) if (angle == 0.0 )
{ {
DrawText(str, x, y); DrawText(str, x, y);
@@ -1367,14 +1315,14 @@ void wxDC::DoDrawRotatedText(const wxString& str, wxCoord x, wxCoord y,
if ( str.Length() == 0 ) if ( str.Length() == 0 )
return ; return ;
*/
wxMacFastPortSetter helper(this) ; wxMacFastPortSetter helper(this) ;
MacInstallFont() ; MacInstallFont() ;
if ( 0 ) if ( 0 )
{ {
m_macFormerAliasState = IsAntiAliasedTextEnabled(&m_macFormerAliasSize); m_macFormerAliasState = IsAntiAliasedTextEnabled(&m_macFormerAliasSize);
SetAntiAliasedTextEnabled(true, SInt16(m_scaleY * m_font.GetMacFontSize())); SetAntiAliasedTextEnabled(true, SInt16(m_scaleY * m_font.MacGetFontSize()));
m_macAliasWasEnabled = true ; m_macAliasWasEnabled = true ;
} }
OSStatus status = noErr ; OSStatus status = noErr ;
@@ -1470,76 +1418,8 @@ void wxDC::DoDrawText(const wxString& strtext, wxCoord x, wxCoord y)
{ {
::TextMode( srcCopy ) ; ::TextMode( srcCopy ) ;
} }
int length = strtext.Length() ;
int laststop = 0 ;
int i = 0 ;
int line = 0 ; int line = 0 ;
{ {
#if 0 // we don't have to do all that here
while( i < length )
{
if( strtext[i] == 13 || strtext[i] == 10)
{
wxString linetext = strtext.Mid( laststop , i - laststop ) ;
#if TARGET_CARBON
if ( useDrawThemeText )
{
Rect frame = { yy + line*(fi.descent + fi.ascent + fi.leading) ,xx , yy + (line+1)*(fi.descent + fi.ascent + fi.leading) , xx + 10000 } ;
wxMacCFStringHolder mString( linetext , m_font.GetEncoding() ) ;
if ( m_backgroundMode != wxTRANSPARENT )
{
Point bounds={0,0} ;
Rect background = frame ;
SInt16 baseline ;
::GetThemeTextDimensions( mString,
kThemeCurrentPortFont,
kThemeStateActive,
false,
&bounds,
&baseline );
background.right = background.left + bounds.h ;
background.bottom = background.top + bounds.v ;
::EraseRect( &background ) ;
}
::DrawThemeTextBox( mString,
kThemeCurrentPortFont,
kThemeStateActive,
false,
&frame,
teJustLeft,
nil );
line++ ;
}
else
#endif
{
wxCharBuffer text = linetext.mb_str(wxConvLocal) ;
::DrawText( text , 0 , strlen(text) ) ;
if ( m_backgroundMode != wxTRANSPARENT )
{
Point bounds={0,0} ;
Rect background = frame ;
SInt16 baseline ;
::GetThemeTextDimensions( mString,
kThemeCurrentPortFont,
kThemeStateActive,
false,
&bounds,
&baseline );
background.right = background.left + bounds.h ;
background.bottom = background.top + bounds.v ;
::EraseRect( &background ) ;
}
line++ ;
::MoveTo( xx , yy + line*(fi.descent + fi.ascent + fi.leading) );
}
laststop = i+1 ;
}
i++ ;
}
wxString linetext = strtext.Mid( laststop , i - laststop ) ;
#endif // 0
wxString linetext = strtext ; wxString linetext = strtext ;
#if TARGET_CARBON #if TARGET_CARBON
if ( useDrawThemeText ) if ( useDrawThemeText )
@@ -1553,7 +1433,7 @@ void wxDC::DoDrawText(const wxString& strtext, wxCoord x, wxCoord y)
Rect background = frame ; Rect background = frame ;
SInt16 baseline ; SInt16 baseline ;
::GetThemeTextDimensions( mString, ::GetThemeTextDimensions( mString,
kThemeCurrentPortFont, m_font.MacGetThemeFontID() ,
kThemeStateActive, kThemeStateActive,
false, false,
&bounds, &bounds,
@@ -1563,7 +1443,7 @@ void wxDC::DoDrawText(const wxString& strtext, wxCoord x, wxCoord y)
::EraseRect( &background ) ; ::EraseRect( &background ) ;
} }
::DrawThemeTextBox( mString, ::DrawThemeTextBox( mString,
kThemeCurrentPortFont, m_font.MacGetThemeFontID() ,
kThemeStateActive, kThemeStateActive,
false, false,
&frame, &frame,
@@ -1620,60 +1500,21 @@ void wxDC::DoGetTextExtent( const wxString &strtext, wxCoord *width, wxCoord *h
*descent =YDEV2LOGREL( fi.descent ); *descent =YDEV2LOGREL( fi.descent );
if ( externalLeading ) if ( externalLeading )
*externalLeading = YDEV2LOGREL( fi.leading ) ; *externalLeading = YDEV2LOGREL( fi.leading ) ;
int length = strtext.Length() ;
int laststop = 0 ;
int i = 0 ;
int curwidth = 0 ; int curwidth = 0 ;
if ( width ) if ( width )
{ {
*width = 0 ; *width = 0 ;
#if 0 // apparently we don't have to do all that
while( i < length )
{
if( strtext[i] == 13 || strtext[i] == 10)
{
wxString linetext = strtext.Mid( laststop , i - laststop ) ;
if ( height )
*height += YDEV2LOGREL( fi.descent + fi.ascent + fi.leading ) ;
#if TARGET_CARBON
if ( useGetThemeText )
{
Point bounds={0,0} ;
SInt16 baseline ;
wxMacCFStringHolder mString( linetext , m_font.GetEncoding() ) ;
::GetThemeTextDimensions( mString,
kThemeCurrentPortFont,
kThemeStateActive,
false,
&bounds,
&baseline );
curwidth = bounds.h ;
}
else
#endif
{
wxCharBuffer text = linetext.mb_str(wxConvLocal) ;
curwidth = ::TextWidth( text , 0 , strlen(text) ) ;
}
if ( curwidth > *width )
*width = XDEV2LOGREL( curwidth ) ;
laststop = i+1 ;
}
i++ ;
}
wxString linetext = strtext.Mid( laststop , i - laststop ) ;
#endif // 0
wxString linetext = strtext ; wxString linetext = strtext ;
#if TARGET_CARBON
if ( useGetThemeText ) if ( useGetThemeText )
{ {
Point bounds={0,0} ; Point bounds={0,0} ;
SInt16 baseline ; SInt16 baseline ;
wxMacCFStringHolder mString( linetext , m_font.GetEncoding() ) ; wxMacCFStringHolder mString( linetext , m_font.GetEncoding() ) ;
ThemeFontID themeFont = m_font.MacGetThemeFontID() ;
::GetThemeTextDimensions( mString, ::GetThemeTextDimensions( mString,
kThemeCurrentPortFont, themeFont ,
kThemeStateActive, kThemeStateActive,
false, false,
&bounds, &bounds,
@@ -1681,7 +1522,6 @@ void wxDC::DoGetTextExtent( const wxString &strtext, wxCoord *width, wxCoord *h
curwidth = bounds.h ; curwidth = bounds.h ;
} }
else else
#endif
{ {
wxCharBuffer text = linetext.mb_str(wxConvLocal) ; wxCharBuffer text = linetext.mb_str(wxConvLocal) ;
curwidth = ::TextWidth( text , 0 , strlen(text) ) ; curwidth = ::TextWidth( text , 0 , strlen(text) ) ;
@@ -1729,7 +1569,7 @@ bool wxDC::DoGetPartialTextExtents(const wxString& text, wxArrayInt& widths) con
SInt16 baseline ; SInt16 baseline ;
wxMacCFStringHolder mString(str, m_font.GetEncoding()); wxMacCFStringHolder mString(str, m_font.GetEncoding());
::GetThemeTextDimensions( mString, ::GetThemeTextDimensions( mString,
kThemeCurrentPortFont, m_font.MacGetThemeFontID(),
kThemeStateActive, kThemeStateActive,
false, false,
&bounds, &bounds,
@@ -1778,7 +1618,7 @@ wxCoord wxDC::GetCharWidth(void) const
SInt16 baseline ; SInt16 baseline ;
CFStringRef mString = CFStringCreateWithBytes( NULL , (UInt8*) text , 1 , CFStringGetSystemEncoding(), false ) ; CFStringRef mString = CFStringCreateWithBytes( NULL , (UInt8*) text , 1 , CFStringGetSystemEncoding(), false ) ;
::GetThemeTextDimensions( mString, ::GetThemeTextDimensions( mString,
kThemeCurrentPortFont, m_font.MacGetThemeFontID(),
kThemeStateActive, kThemeStateActive,
false, false,
&bounds, &bounds,
@@ -1827,9 +1667,9 @@ void wxDC::MacInstallFont() const
MacSetupBackgroundForCurrentPort(m_backgroundBrush) ; MacSetupBackgroundForCurrentPort(m_backgroundBrush) ;
if ( m_font.Ok() ) if ( m_font.Ok() )
{ {
::TextFont( m_font.GetMacFontNum() ) ; ::TextFont( m_font.MacGetFontNum() ) ;
::TextSize( (short)(m_scaleY * m_font.GetMacFontSize()) ) ; ::TextSize( (short)(m_scaleY * m_font.MacGetFontSize()) ) ;
::TextFace( m_font.GetMacFontStyle() ) ; ::TextFace( m_font.MacGetFontStyle() ) ;
m_macFontInstalled = true ; m_macFontInstalled = true ;
m_macBrushInstalled = false ; m_macBrushInstalled = false ;
m_macPenInstalled = false ; m_macPenInstalled = false ;
@@ -1898,9 +1738,9 @@ void wxDC::MacInstallFont() const
} }
::PenMode( mode ) ; ::PenMode( mode ) ;
OSStatus status = noErr ; OSStatus status = noErr ;
Fixed atsuSize = IntToFixed( int(m_scaleY * m_font.GetMacFontSize()) ) ; Fixed atsuSize = IntToFixed( int(m_scaleY * m_font.MacGetFontSize()) ) ;
Style qdStyle = m_font.GetMacFontStyle() ; Style qdStyle = m_font.MacGetATSUAdditionalQDStyles() ;
ATSUFontID atsuFont = m_font.GetMacATSUFontID() ; ATSUFontID atsuFont = m_font.MacGetATSUFontID() ;
status = ::ATSUCreateStyle((ATSUStyle *)&m_macATSUIStyle) ; status = ::ATSUCreateStyle((ATSUStyle *)&m_macATSUIStyle) ;
wxASSERT_MSG( status == noErr , wxT("couldn't create ATSU style") ) ; wxASSERT_MSG( status == noErr , wxT("couldn't create ATSU style") ) ;
ATSUAttributeTag atsuTags[] = ATSUAttributeTag atsuTags[] =
@@ -2077,13 +1917,13 @@ void wxDC::MacSetupBackgroundForCurrentPort(const wxBrush& background )
{ {
case kwxMacBrushTheme : case kwxMacBrushTheme :
{ {
::SetThemeBackground( background.GetMacTheme() , wxDisplayDepth() , true ) ; ::SetThemeBackground( background.MacGetTheme() , wxDisplayDepth() , true ) ;
break ; break ;
} }
case kwxMacBrushThemeBackground : case kwxMacBrushThemeBackground :
{ {
Rect extent ; Rect extent ;
ThemeBackgroundKind bg = background.GetMacThemeBackground( &extent ) ; ThemeBackgroundKind bg = background.MacGetThemeBackground( &extent ) ;
::ApplyThemeBackground( bg , &extent ,kThemeStateActive , wxDisplayDepth() , true ) ; ::ApplyThemeBackground( bg , &extent ,kThemeStateActive , wxDisplayDepth() , true ) ;
break ; break ;
} }

View File

@@ -57,16 +57,15 @@ bool wxDialog::Create(wxWindow *parent, wxWindowID id,
long style, long style,
const wxString& name) const wxString& name)
{ {
SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE)); SetExtraStyle(GetExtraStyle() | wxTOPLEVEL_EX_DIALOG);
// All dialogs should really have this style
style |= wxTAB_TRAVERSAL;
if ( !wxTopLevelWindow::Create(parent, id, title, pos, size, style, name) ) if ( !wxTopLevelWindow::Create(parent, id, title, pos, size, style, name) )
return FALSE; return FALSE;
MacCreateRealWindow( title , pos , size , MacRemoveBordersFromStyle(style) & ~(wxYES|wxOK|wxNO|wxCANCEL) , name ) ; SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE));
m_macWindowBackgroundTheme = kThemeBrushDialogBackgroundActive ;
SetThemeWindowBackground( (WindowRef) m_macWindow , m_macWindowBackgroundTheme , false ) ;
return TRUE; return TRUE;
} }

View File

@@ -81,7 +81,6 @@ public:
void Rewind() ; void Rewind() ;
const wxString& GetName() const { return m_dirname; } const wxString& GetName() const { return m_dirname; }
bool Ok() const { return m_ok; }
private: private:
CInfoPBRec m_CPB ; CInfoPBRec m_CPB ;
@@ -94,7 +93,6 @@ private:
wxString m_filespec; wxString m_filespec;
int m_flags; int m_flags;
bool m_ok;
}; };
// ============================================================================ // ============================================================================
@@ -108,8 +106,6 @@ private:
wxDirData::wxDirData(const wxString& dirname) wxDirData::wxDirData(const wxString& dirname)
: m_dirname(dirname) : m_dirname(dirname)
{ {
m_ok = false;
OSErr err; OSErr err;
// throw away the trailing slashes // throw away the trailing slashes
@@ -137,11 +133,7 @@ wxDirData::wxDirData(const wxString& dirname)
err = FSpGetDirectoryID( &fsspec , &m_dirId , &m_isDir ) ; err = FSpGetDirectoryID( &fsspec , &m_dirId , &m_isDir ) ;
#endif #endif
//wxASSERT_MSG( (err == noErr) || (err == nsvErr) , wxT("Error accessing directory " + m_dirname)) ; wxASSERT_MSG( (err == noErr) || (err == nsvErr) , wxT("Error accessing directory " + m_dirname)) ;
if ( (err == noErr) || (err == nsvErr))
m_ok = true;
else
wxLogError(wxString(wxT("Error accessing directory ")) + m_dirname);
m_CPB.hFileInfo.ioNamePtr = m_name ; m_CPB.hFileInfo.ioNamePtr = m_name ;
m_index = 0 ; m_index = 0 ;
@@ -255,14 +247,8 @@ bool wxDir::Open(const wxString& dirname)
{ {
delete M_DIR; delete M_DIR;
m_data = new wxDirData(dirname); m_data = new wxDirData(dirname);
if (m_data->Ok())
return TRUE; return TRUE;
else
{
delete m_data;
m_data = NULL;
return FALSE;
}
} }
bool wxDir::IsOpened() const bool wxDir::IsOpened() const

View File

@@ -463,7 +463,7 @@ pascal OSErr wxMacWindowDragTrackingHandler(DragTrackingMessage theMessage, Wind
{ {
wxPoint point(localMouse.h , localMouse.v) ; wxPoint point(localMouse.h , localMouse.v) ;
wxWindow *win = NULL ; wxWindow *win = NULL ;
toplevel->MacGetWindowFromPointSub( point , &win ) ; // TODO toplevel->MacGetWindowFromPointSub( point , &win ) ;
int localx , localy ; int localx , localy ;
localx = localMouse.h ; localx = localMouse.h ;
localy = localMouse.v ; localy = localMouse.v ;

View File

@@ -119,11 +119,23 @@ protected:
bool m_noAA; // No anti-aliasing bool m_noAA; // No anti-aliasing
public: public:
short m_macFontNum; short m_macFontNum;
short m_macFontSize; short m_macFontSize;
unsigned char m_macFontStyle; Style m_macFontStyle;
wxUint32 m_macATSUFontID;
// ATSU Font Information
// this is splitted into an ATSU font id that may
// contain some styles (special bold fonts etc) and
// these are the additional qd styles that are not
// included in the ATSU font id
ATSUFontID m_macATSUFontID;
Style m_macATSUAdditionalQDStyles ;
// for true themeing support we must store the correct font
// information here, as this speeds up and optimizes rendering
ThemeFontID m_macThemeFontID ;
wxNativeFontInfo m_info; wxNativeFontInfo m_info;
public: public:
@@ -157,7 +169,10 @@ void wxFontRefData::Init(int pointSize,
m_macFontNum = 0 ; m_macFontNum = 0 ;
m_macFontSize = 0; m_macFontSize = 0;
m_macFontStyle = 0; m_macFontStyle = 0;
m_fontId = 0; m_macATSUFontID = 0;
m_macATSUAdditionalQDStyles = 0 ;
m_macThemeFontID = kThemeCurrentPortFont ;
m_noAA = FALSE; m_noAA = FALSE;
} }
@@ -167,68 +182,106 @@ wxFontRefData::~wxFontRefData()
void wxFontRefData::MacFindFont() void wxFontRefData::MacFindFont()
{ {
if( m_faceName.Length() == 0 ) if ( m_macThemeFontID != kThemeCurrentPortFont )
{ {
switch( m_family ) Str255 fontName ;
{ GetThemeFont(m_macThemeFontID , GetApplicationScript() , fontName , &m_macFontSize , &m_macFontStyle ) ;
case wxDEFAULT : m_faceName = wxMacMakeStringFromPascal( fontName ) ;
m_macFontNum = ::GetAppFont() ; if ( m_macFontStyle & bold )
break ; m_weight = wxBOLD ;
case wxDECORATIVE : else
::GetFNum( "\pTimes" , &m_macFontNum) ; m_weight = wxNORMAL ;
break ; if ( m_macFontStyle & italic )
case wxROMAN : m_style = wxITALIC ;
::GetFNum( "\pTimes" , &m_macFontNum) ; if ( m_macFontStyle & underline )
break ; m_underlined = true ;
case wxSCRIPT : ::GetFNum( fontName, &m_macFontNum);
::GetFNum( "\pTimes" , &m_macFontNum) ; m_pointSize = m_macFontSize ;
break ;
case wxSWISS :
::GetFNum( "\pGeneva" , &m_macFontNum) ;
break ;
case wxMODERN :
::GetFNum( "\pMonaco" , &m_macFontNum) ;
break ;
}
Str255 name ;
GetFontName( m_macFontNum , name ) ;
m_faceName = wxMacMakeStringFromPascal( name ) ;
} }
else else
{ {
if ( m_faceName == wxT("systemfont") ) if( m_faceName.Length() == 0 )
m_macFontNum = ::GetSysFont() ; {
else if ( m_faceName == wxT("applicationfont") ) switch( m_family )
m_macFontNum = ::GetAppFont() ; {
case wxDEFAULT :
m_macFontNum = ::GetAppFont() ;
break ;
case wxDECORATIVE :
::GetFNum( "\pTimes" , &m_macFontNum) ;
break ;
case wxROMAN :
::GetFNum( "\pTimes" , &m_macFontNum) ;
break ;
case wxSCRIPT :
::GetFNum( "\pTimes" , &m_macFontNum) ;
break ;
case wxSWISS :
::GetFNum( "\pGeneva" , &m_macFontNum) ;
break ;
case wxMODERN :
::GetFNum( "\pMonaco" , &m_macFontNum) ;
break ;
}
Str255 name ;
::GetFontName( m_macFontNum , name ) ;
m_faceName = wxMacMakeStringFromPascal( name ) ;
}
else else
{ {
Str255 fontname ; if ( m_faceName == wxT("systemfont") )
wxMacStringToPascal( m_faceName , fontname ) ; m_macFontNum = ::GetSysFont() ;
::GetFNum( fontname, &m_macFontNum); else if ( m_faceName == wxT("applicationfont") )
m_macFontNum = ::GetAppFont() ;
else
{
Str255 fontname ;
wxMacStringToPascal( m_faceName , fontname ) ;
::GetFNum( fontname, &m_macFontNum);
}
} }
m_macFontStyle = 0;
if (m_weight == wxBOLD)
m_macFontStyle |= bold;
if (m_style == wxITALIC || m_style == wxSLANT)
m_macFontStyle |= italic;
if (m_underlined)
m_macFontStyle |= underline;
m_macFontSize = m_pointSize ;
} }
m_macFontStyle = 0; // we try to get as much styles as possible into ATSU
if (m_weight == wxBOLD) Style atsuStyle = normal ;
m_macFontStyle |= bold; verify_noerr(::ATSUFONDtoFontID(m_macFontNum, atsuStyle , (UInt32*)&m_macATSUFontID) );
if (m_style == wxITALIC || m_style == wxSLANT) if ( m_macFontStyle & bold )
m_macFontStyle |= italic; {
if (m_underlined) ATSUFontID test ;
m_macFontStyle |= underline; if ( ::ATSUFONDtoFontID(m_macFontNum, atsuStyle | bold , &test) == noErr )
m_macFontSize = m_pointSize ; {
atsuStyle |= bold ;
//TODO:if we supply the style as an additional parameter we must make a testing m_macATSUFontID = test ;
//sequence in order to degrade gracefully while trying to maintain most of the style }
//information, meanwhile we just take the normal font and apply the features after }
#ifdef __WXDEBUG__ if ( m_macFontStyle & italic )
OSStatus status = {
#endif // __WXDEBUG__ ATSUFontID test ;
::ATSUFONDtoFontID(m_macFontNum, normal /*qdStyle*/, (UInt32*)&m_macATSUFontID); if ( ::ATSUFONDtoFontID(m_macFontNum, atsuStyle | italic , &test) == noErr )
/* {
status = ATSUFindFontFromName ( (Ptr) m_faceName , strlen( m_faceName ) , atsuStyle |= italic ;
kFontFullName, kFontMacintoshPlatform, kFontRomanScript , kFontNoLanguage , (UInt32*)&m_macATSUFontID ) ; m_macATSUFontID = test ;
*/ }
wxASSERT_MSG( status == noErr , wxT("couldn't retrieve font identifier") ) ; }
if ( m_macFontStyle & underline )
{
ATSUFontID test ;
if ( ::ATSUFONDtoFontID(m_macFontNum, atsuStyle | underline , &test) == noErr )
{
atsuStyle |= underline ;
m_macATSUFontID = test ;
}
}
m_macATSUAdditionalQDStyles = m_macFontStyle & (~atsuStyle ) ;
} }
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
@@ -269,6 +322,16 @@ bool wxFont::Create(int pointSize,
return TRUE; return TRUE;
} }
bool wxFont::MacCreateThemeFont(wxUint16 themeFontID )
{
UnRef();
m_refData = new wxFontRefData(12, 0, 0, wxNORMAL,false, wxEmptyString, wxFONTENCODING_DEFAULT);
M_FONTDATA->m_macThemeFontID = themeFontID ;
RealizeResource();
return TRUE;
}
wxFont::~wxFont() wxFont::~wxFont()
{ {
} }
@@ -374,69 +437,92 @@ void wxFont::SetNoAntiAliasing( bool no )
int wxFont::GetPointSize() const int wxFont::GetPointSize() const
{ {
wxCHECK_MSG( M_FONTDATA != NULL , NULL, wxT("invalid font") );
return M_FONTDATA->m_pointSize; return M_FONTDATA->m_pointSize;
} }
int wxFont::GetFamily() const int wxFont::GetFamily() const
{ {
wxCHECK_MSG( M_FONTDATA != NULL , NULL, wxT("invalid font") );
return M_FONTDATA->m_family; return M_FONTDATA->m_family;
} }
int wxFont::GetStyle() const int wxFont::GetStyle() const
{ {
wxCHECK_MSG( M_FONTDATA != NULL , NULL, wxT("invalid font") );
return M_FONTDATA->m_style; return M_FONTDATA->m_style;
} }
int wxFont::GetWeight() const int wxFont::GetWeight() const
{ {
wxCHECK_MSG( M_FONTDATA != NULL , NULL, wxT("invalid font") );
return M_FONTDATA->m_weight; return M_FONTDATA->m_weight;
} }
bool wxFont::GetUnderlined() const bool wxFont::GetUnderlined() const
{ {
wxCHECK_MSG( M_FONTDATA != NULL , NULL, wxT("invalid font") );
return M_FONTDATA->m_underlined; return M_FONTDATA->m_underlined;
} }
wxString wxFont::GetFaceName() const wxString wxFont::GetFaceName() const
{ {
wxString str; wxCHECK_MSG( M_FONTDATA != NULL , wxEmptyString , wxT("invalid font") );
if ( M_FONTDATA ) return M_FONTDATA->m_faceName;
str = M_FONTDATA->m_faceName ;
return str;
} }
wxFontEncoding wxFont::GetEncoding() const wxFontEncoding wxFont::GetEncoding() const
{ {
wxCHECK_MSG( M_FONTDATA != NULL , wxFONTENCODING_DEFAULT , wxT("invalid font") );
return M_FONTDATA->m_encoding; return M_FONTDATA->m_encoding;
} }
bool wxFont::GetNoAntiAliasing() bool wxFont::GetNoAntiAliasing()
{ {
wxCHECK_MSG( M_FONTDATA != NULL , NULL, wxT("invalid font") );
return M_FONTDATA->m_noAA; return M_FONTDATA->m_noAA;
} }
short wxFont::GetMacFontNum() const short wxFont::MacGetFontNum() const
{ {
wxCHECK_MSG( M_FONTDATA != NULL , NULL, wxT("invalid font") );
return M_FONTDATA->m_macFontNum; return M_FONTDATA->m_macFontNum;
} }
short wxFont::GetMacFontSize() const short wxFont::MacGetFontSize() const
{ {
wxCHECK_MSG( M_FONTDATA != NULL , NULL, wxT("invalid font") );
return M_FONTDATA->m_macFontSize; return M_FONTDATA->m_macFontSize;
} }
wxByte wxFont::GetMacFontStyle() const wxByte wxFont::MacGetFontStyle() const
{ {
wxCHECK_MSG( M_FONTDATA != NULL , NULL, wxT("invalid font") );
return M_FONTDATA->m_macFontStyle; return M_FONTDATA->m_macFontStyle;
} }
wxUint32 wxFont::GetMacATSUFontID() const wxUint32 wxFont::MacGetATSUFontID() const
{ {
wxCHECK_MSG( M_FONTDATA != NULL , NULL, wxT("invalid font") );
return M_FONTDATA->m_macATSUFontID; return M_FONTDATA->m_macATSUFontID;
} }
wxUint32 wxFont::MacGetATSUAdditionalQDStyles() const
{
wxCHECK_MSG( M_FONTDATA != NULL , NULL, wxT("invalid font") );
return M_FONTDATA->m_macATSUAdditionalQDStyles;
}
wxUint16 wxFont::MacGetThemeFontID() const
{
wxCHECK_MSG( M_FONTDATA != NULL , NULL, wxT("invalid font") );
return M_FONTDATA->m_macThemeFontID;
}
const wxNativeFontInfo *wxFont::GetNativeFontInfo() const const wxNativeFontInfo *wxFont::GetNativeFontInfo() const
{ {
wxCHECK_MSG( M_FONTDATA != NULL , NULL, wxT("invalid font") );
wxCHECK_MSG( Ok(), NULL, wxT("invalid font") ); wxCHECK_MSG( Ok(), NULL, wxT("invalid font") );
M_FONTDATA->m_info.InitFromFont(*this); M_FONTDATA->m_info.InitFromFont(*this);

View File

@@ -62,31 +62,6 @@ void wxFrame::Init()
#endif #endif
} }
wxPoint wxFrame::GetClientAreaOrigin() const
{
// on mac we are at position -1,-1 with the control
wxPoint pt(0, 0);
#if wxUSE_TOOLBAR
if ( GetToolBar() )
{
int w, h;
GetToolBar()->GetSize(& w, & h);
if ( GetToolBar()->GetWindowStyleFlag() & wxTB_VERTICAL )
{
pt.x += w - 1;
}
else
{
pt.y += h - 1 ;
}
}
#endif // wxUSE_TOOLBAR
return pt;
}
bool wxFrame::Create(wxWindow *parent, bool wxFrame::Create(wxWindow *parent,
wxWindowID id, wxWindowID id,
const wxString& title, const wxString& title,
@@ -95,15 +70,11 @@ bool wxFrame::Create(wxWindow *parent,
long style, long style,
const wxString& name) const wxString& name)
{ {
SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_APPWORKSPACE));
if ( !wxTopLevelWindow::Create(parent, id, title, pos, size, style, name) ) if ( !wxTopLevelWindow::Create(parent, id, title, pos, size, style, name) )
return FALSE; return FALSE;
MacCreateRealWindow( title, pos , size , MacRemoveBordersFromStyle(style) , name ) ; SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_APPWORKSPACE));
m_macWindowBackgroundTheme = kThemeBrushDocumentWindowBackground ;
SetThemeWindowBackground( (WindowRef) m_macWindow , m_macWindowBackgroundTheme , false ) ;
wxModelessWindows.Append(this); wxModelessWindows.Append(this);
@@ -254,22 +225,34 @@ void wxFrame::AttachMenuBar( wxMenuBar *menuBar )
void wxFrame::DoGetClientSize(int *x, int *y) const void wxFrame::DoGetClientSize(int *x, int *y) const
{ {
wxWindow::DoGetClientSize( x , y ) ; wxTopLevelWindow::DoGetClientSize( x , y ) ;
#if wxUSE_STATUSBAR #if wxUSE_STATUSBAR
if ( GetStatusBar() && y ) if ( GetStatusBar() && y )
{ {
int statusX, statusY; int statusX, statusY;
GetStatusBar()->GetClientSize(&statusX, &statusY); GetStatusBar()->GetSize(&statusX, &statusY);
*y -= statusY; if ( y) *y -= statusY;
} }
#endif // wxUSE_STATUSBAR #endif // wxUSE_STATUSBAR
wxPoint pt(GetClientAreaOrigin()); #if wxUSE_TOOLBAR
if ( y ) wxToolBar *toolbar = GetToolBar();
*y -= pt.y; if ( toolbar && toolbar->IsShown() )
if ( x ) {
*x -= pt.x; int w, h;
toolbar->GetSize(&w, &h);
if ( toolbar->GetWindowStyleFlag() & wxTB_VERTICAL )
{
if ( x ) *x -= w;
}
else
{
if ( y ) *y -= h;
}
}
#endif // wxUSE_TOOLBAR
} }
void wxFrame::DoSetClientSize(int clientwidth, int clientheight) void wxFrame::DoSetClientSize(int clientwidth, int clientheight)
@@ -278,6 +261,10 @@ void wxFrame::DoSetClientSize(int clientwidth, int clientheight)
int currentwidth , currentheight ; int currentwidth , currentheight ;
GetClientSize( &currentclientwidth , &currentclientheight ) ; GetClientSize( &currentclientwidth , &currentclientheight ) ;
if ( clientwidth == -1 )
clientwidth = currentclientwidth ;
if ( clientheight == -1 )
clientheight = currentclientheight ;
GetSize( &currentwidth , &currentheight ) ; GetSize( &currentwidth , &currentheight ) ;
// find the current client size // find the current client size
@@ -306,8 +293,7 @@ void wxFrame::PositionToolBar()
{ {
int cw, ch; int cw, ch;
cw = m_width ; GetSize( &cw , &ch ) ;
ch = m_height ;
if ( GetStatusBar() ) if ( GetStatusBar() )
{ {
@@ -318,20 +304,21 @@ void wxFrame::PositionToolBar()
if (GetToolBar()) if (GetToolBar())
{ {
int tw, th; int tx, ty, tw, th;
tx = ty = 0 ;
GetToolBar()->GetSize(& tw, & th); GetToolBar()->GetSize(& tw, & th);
if (GetToolBar()->GetWindowStyleFlag() & wxTB_VERTICAL) if (GetToolBar()->GetWindowStyleFlag() & wxTB_VERTICAL)
{ {
// Use the 'real' position. wxSIZE_NO_ADJUSTMENTS // Use the 'real' position. wxSIZE_NO_ADJUSTMENTS
// means, pretend we don't have toolbar/status bar, so we // means, pretend we don't have toolbar/status bar, so we
// have the original client size. // have the original client size.
GetToolBar()->SetSize(-1, -1, tw, ch + 2 , wxSIZE_NO_ADJUSTMENTS | wxSIZE_ALLOW_MINUS_ONE ); GetToolBar()->SetSize(tx , ty , tw, ch , wxSIZE_NO_ADJUSTMENTS );
} }
else else
{ {
// Use the 'real' position // Use the 'real' position
GetToolBar()->SetSize(-1, -1, cw + 2, th, wxSIZE_NO_ADJUSTMENTS | wxSIZE_ALLOW_MINUS_ONE ); GetToolBar()->SetSize(tx , ty , cw , th, wxSIZE_NO_ADJUSTMENTS );
} }
} }
} }

View File

@@ -29,12 +29,13 @@ bool wxGauge::Create(wxWindow *parent, wxWindowID id,
const wxValidator& validator, const wxValidator& validator,
const wxString& name) const wxString& name)
{ {
if ( !wxGaugeBase::Create(parent, id, range, pos, s, style, validator, name) ) m_macIsUserPane = FALSE ;
if ( !wxGaugeBase::Create(parent, id, range, pos, s, style & 0xE0FFFFFF, validator, name) )
return false; return false;
wxSize size = s ; wxSize size = s ;
Rect bounds ;
Str255 title ;
m_rangeMax = range ; m_rangeMax = range ;
m_gaugePos = 0 ; m_gaugePos = 0 ;
@@ -43,12 +44,11 @@ bool wxGauge::Create(wxWindow *parent, wxWindowID id,
size = wxSize( 200 , 16 ) ; size = wxSize( 200 , 16 ) ;
} }
MacPreControlCreate( parent , id , wxEmptyString , pos , size ,style & 0xE0FFFFFF /* no borders on mac */ , validator , name , &bounds , title ) ; Rect bounds = wxMacGetBoundsForControl( this , pos , size ) ;
m_macControl = (WXWidget) ::NewControl( MAC_WXHWND(parent->MacGetTopLevelWindowRef()) , &bounds , "\p" , true , 0 , 0 , range,
m_macControl = ::NewControl( MAC_WXHWND(parent->MacGetRootWindow()) , &bounds , title , false , 0 , 0 , range,
kControlProgressBarProc , (long) this ) ; kControlProgressBarProc , (long) this ) ;
MacPostControlCreate() ; MacPostControlCreate(pos,size) ;
return TRUE; return TRUE;
} }
@@ -64,13 +64,13 @@ void wxGauge::SetBezelFace(int w)
void wxGauge::SetRange(int r) void wxGauge::SetRange(int r)
{ {
m_rangeMax = r; m_rangeMax = r;
::SetControl32BitMaximum( (ControlHandle) m_macControl , m_rangeMax ) ; ::SetControl32BitMaximum( (ControlRef) m_macControl , m_rangeMax ) ;
} }
void wxGauge::SetValue(int pos) void wxGauge::SetValue(int pos)
{ {
m_gaugePos = pos; m_gaugePos = pos;
::SetControl32BitValue( (ControlHandle) m_macControl , m_gaugePos ) ; ::SetControl32BitValue( (ControlRef) m_macControl , m_gaugePos ) ;
} }
int wxGauge::GetShadowWidth() const int wxGauge::GetShadowWidth() const

View File

@@ -49,7 +49,7 @@ wxGLContext::wxGLContext(
{ {
m_window = win; m_window = win;
m_drawable = (AGLDrawable) UMAGetWindowPort(MAC_WXHWND(win->MacGetRootWindow())); m_drawable = (AGLDrawable) UMAGetWindowPort(MAC_WXHWND(win->MacGetTopLevelWindowRef()));
m_glContext = aglCreateContext(fmt, other ? other->m_glContext : NULL); m_glContext = aglCreateContext(fmt, other ? other->m_glContext : NULL);
wxCHECK_RET( m_glContext, wxT("Couldn't create OpenGl context") ); wxCHECK_RET( m_glContext, wxT("Couldn't create OpenGl context") );
@@ -262,7 +262,7 @@ void wxGLCanvas::SetViewport()
int width, height; int width, height;
GetClientSize(& width, & height); GetClientSize(& width, & height);
Rect bounds ; Rect bounds ;
GetWindowPortBounds( MAC_WXHWND(MacGetRootWindow()) , &bounds ) ; GetWindowPortBounds( MAC_WXHWND(MacGetTopLevelWindowRef()) , &bounds ) ;
GLint parms[4] ; GLint parms[4] ;
parms[0] = x ; parms[0] = x ;
parms[1] = bounds.bottom - bounds.top - ( y + height ) ; parms[1] = bounds.bottom - bounds.top - ( y + height ) ;
@@ -331,7 +331,7 @@ bool wxGLCanvas::Show(bool show)
} }
else else
{ {
if ( MacIsReallyShown() && !m_macCanvasIsShown ) if ( IsControlVisible( (ControlRef) m_macControl ) && !m_macCanvasIsShown )
{ {
m_macCanvasIsShown = true ; m_macCanvasIsShown = true ;
SetViewport() ; SetViewport() ;
@@ -352,7 +352,7 @@ void wxGLCanvas::MacSuperShown( bool show )
} }
else else
{ {
if ( MacIsReallyShown() && !m_macCanvasIsShown ) if ( IsControlVisible( (ControlRef) m_macControl ) && !m_macCanvasIsShown )
{ {
m_macCanvasIsShown = true ; m_macCanvasIsShown = true ;
SetViewport() ; SetViewport() ;

View File

@@ -87,7 +87,7 @@ void _GSocket_GUI_Cleanup(void)
int _GSocket_GUI_Init_Socket(GSocket *socket) int _GSocket_GUI_Init_Socket(GSocket *socket)
{ {
struct MacGSocketData *data = (struct MacGSocketData *) malloc(sizeof(struct MacGSocketData)); struct MacGSocketData *data = (struct MacGSocketData *)malloc(sizeof(struct MacGSocketData));
if (data) if (data)
{ {
socket->m_gui_dependent = (char*)data; socket->m_gui_dependent = (char*)data;

File diff suppressed because it is too large Load Diff

View File

@@ -262,9 +262,8 @@ bool wxMDIChildFrame::Create(wxMDIParentFrame *parent,
MacCreateRealWindow( title, pos , size , MacRemoveBordersFromStyle(style) , name ) ; MacCreateRealWindow( title, pos , size , MacRemoveBordersFromStyle(style) , name ) ;
m_macWindowBackgroundTheme = kThemeBrushDocumentWindowBackground ; SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_APPWORKSPACE));
SetThemeWindowBackground( (WindowRef) m_macWindow , m_macWindowBackgroundTheme , false ) ;
wxModelessWindows.Append(this); wxModelessWindows.Append(this);
return FALSE; return FALSE;
} }

View File

@@ -58,82 +58,6 @@ IMPLEMENT_DYNAMIC_CLASS(wxNotebookEvent, wxCommandEvent)
// implementation // implementation
// ============================================================================ // ============================================================================
// The Appearance Manager docs show using tab controls in either edge to edge
// mode, or inset. I think edge to edge conforms better to the other ports,
// and inset mode is better accomplished with space around the wxNotebook rather
// than within it. --Robin
// CS : had to switch off tight spacing due to 10.3 problems
#define wxMAC_EDGE_TO_EDGE 0
static inline int wxMacTabMargin(long nbStyle, long side)
{
static int tabMargin = -1;
static int otherMargin = -1;
if ( tabMargin == -1)
{
if ( UMAHasAquaLayout() )
{
tabMargin = 26; // From Appearance Manager docs for small tab control dimensions
#if wxMAC_EDGE_TO_EDGE
otherMargin = 0;
#else
// otherMargin = 20;
// JACS - this seems fine on 10.3; 20 is way too much
otherMargin = 8;
#endif
}
else
{
tabMargin = 30;
#if wxMAC_EDGE_TO_EDGE
otherMargin = 0;
#else
otherMargin = 16;
#endif
}
}
// If the style matches the side asked for then return the tab margin,
// but we have to special case wxNB_TOP since it is zero...
if ( side == wxNB_TOP)
{
if ( nbStyle != 0 && nbStyle & (wxNB_LEFT|wxNB_RIGHT|wxNB_BOTTOM))
{
return otherMargin;
}
else
{
return tabMargin;
}
}
else if ( nbStyle & side)
return tabMargin;
else
return otherMargin;
}
static inline int wxMacTabLeftMargin(long style)
{
return wxMacTabMargin(style, wxNB_LEFT);
}
static inline int wxMacTabTopMargin(long style)
{
return wxMacTabMargin(style, wxNB_TOP);
}
static inline int wxMacTabRightMargin(long style)
{
return wxMacTabMargin(style, wxNB_RIGHT);
}
static inline int wxMacTabBottomMargin(long style)
{
return wxMacTabMargin(style, wxNB_BOTTOM);
}
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// wxNotebook construction // wxNotebook construction
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
@@ -141,13 +65,6 @@ static inline int wxMacTabBottomMargin(long style)
// common part of all ctors // common part of all ctors
void wxNotebook::Init() void wxNotebook::Init()
{ {
if ( UMAHasAquaLayout() )
{
// Should these depend on wxMAC_EDGE_TO_EDGE too?
m_macHorizontalBorder = 7;
m_macVerticalBorder = 8;
}
m_nSelection = -1; m_nSelection = -1;
} }
@@ -178,27 +95,40 @@ bool wxNotebook::Create(wxWindow *parent,
long style, long style,
const wxString& name) const wxString& name)
{ {
m_macIsUserPane = FALSE ;
if ( !wxNotebookBase::Create(parent, id, pos, size, style, name) ) if ( !wxNotebookBase::Create(parent, id, pos, size, style, name) )
return false; return false;
Rect bounds ; Rect bounds = wxMacGetBoundsForControl( this , pos , size ) ;
Str255 title ;
MacPreControlCreate( parent , id , wxEmptyString , pos , size ,style, wxDefaultValidator , name , &bounds , title ) ; if( bounds.right <= bounds.left )
bounds.right = bounds.left + 100 ;
if ( bounds.bottom <= bounds.top )
bounds.bottom = bounds.top + 100 ;
int tabstyle = kControlTabSmallNorthProc ; UInt16 tabstyle = kControlTabDirectionNorth ;
if ( HasFlag(wxNB_LEFT) ) if ( HasFlag(wxNB_LEFT) )
tabstyle = kControlTabSmallWestProc ; tabstyle = kControlTabDirectionWest ;
else if ( HasFlag( wxNB_RIGHT ) ) else if ( HasFlag( wxNB_RIGHT ) )
tabstyle = kControlTabSmallEastProc ; tabstyle = kControlTabDirectionEast ;
else if ( HasFlag( wxNB_BOTTOM ) ) else if ( HasFlag( wxNB_BOTTOM ) )
tabstyle = kControlTabSmallSouthProc ; tabstyle = kControlTabDirectionSouth ;
ControlTabSize tabsize = kControlTabSizeLarge ;
if ( GetWindowVariant() == wxWINDOW_VARIANT_SMALL )
tabsize = kControlTabSizeSmall ;
else if ( GetWindowVariant() == wxWINDOW_VARIANT_MINI )
{
if (UMAGetSystemVersion() >= 0x1030 )
tabsize = 3 ;
else
tabsize = kControlSizeSmall;
}
::CreateTabsControl( MAC_WXHWND(parent->MacGetTopLevelWindowRef()) , &bounds , tabsize , tabstyle, 0, NULL, (ControlRef*) &m_macControl);
m_macControl = ::NewControl( MAC_WXHWND(parent->MacGetRootWindow()) , &bounds , title , false , 0 , 0 , 1,
tabstyle , (long) this ) ; MacPostControlCreate(pos,size) ;
MacPostControlCreate() ;
return TRUE ; return TRUE ;
} }
@@ -228,13 +158,7 @@ void wxNotebook::SetPageSize(const wxSize& size)
wxSize wxNotebook::CalcSizeFromPage(const wxSize& sizePage) const wxSize wxNotebook::CalcSizeFromPage(const wxSize& sizePage) const
{ {
wxSize sizeTotal = sizePage; return DoGetSizeFromClientSize( sizePage ) ;
sizeTotal.x += 2 * m_macHorizontalBorder + wxMacTabLeftMargin(GetWindowStyle()) +
wxMacTabRightMargin(GetWindowStyle()) ;
sizeTotal.y += 2 * m_macVerticalBorder + wxMacTabTopMargin(GetWindowStyle()) +
wxMacTabBottomMargin(GetWindowStyle()) ;
return sizeTotal;
} }
wxSize wxNotebook::DoGetBestSize() const wxSize wxNotebook::DoGetBestSize() const
@@ -405,7 +329,7 @@ bool wxNotebook::InsertPage(size_t nPage,
{ {
m_nSelection++; m_nSelection++;
// while this still is the same page showing, we need to update the tabs // while this still is the same page showing, we need to update the tabs
SetControl32BitValue( (ControlHandle) m_macControl , m_nSelection + 1 ) ; SetControl32BitValue( (ControlRef) m_macControl , m_nSelection + 1 ) ;
} }
// some page should be selected: either this one or the first one if there // some page should be selected: either this one or the first one if there
@@ -429,7 +353,7 @@ bool wxNotebook::InsertPage(size_t nPage,
*/ */
void wxNotebook::MacSetupTabs() void wxNotebook::MacSetupTabs()
{ {
SetControl32BitMaximum( (ControlHandle) m_macControl , GetPageCount() ) ; SetControl32BitMaximum( (ControlRef) m_macControl , GetPageCount() ) ;
wxNotebookPage *page; wxNotebookPage *page;
ControlTabInfoRec info; ControlTabInfoRec info;
@@ -442,9 +366,9 @@ void wxNotebook::MacSetupTabs()
info.iconSuiteID = 0; info.iconSuiteID = 0;
wxMacStringToPascal( page->GetLabel() , info.name ) ; wxMacStringToPascal( page->GetLabel() , info.name ) ;
SetControlData( (ControlHandle) m_macControl, ii+1, kControlTabInfoTag, SetControlData( (ControlRef) m_macControl, ii+1, kControlTabInfoTag,
sizeof( ControlTabInfoRec) , (char*) &info ) ; sizeof( ControlTabInfoRec) , (char*) &info ) ;
SetTabEnabled( (ControlHandle) m_macControl , ii+1 , true ) ; SetTabEnabled( (ControlRef) m_macControl , ii+1 , true ) ;
#if TARGET_CARBON #if TARGET_CARBON
if ( GetImageList() && GetPageImage(ii) >= 0 && UMAGetSystemVersion() >= 0x1020 ) if ( GetImageList() && GetPageImage(ii) >= 0 && UMAGetSystemVersion() >= 0x1020 )
{ {
@@ -473,7 +397,7 @@ void wxNotebook::MacSetupTabs()
wxASSERT_MSG( err == noErr , wxT("Error when adding bitmap") ) ; wxASSERT_MSG( err == noErr , wxT("Error when adding bitmap") ) ;
info.contentType = kControlContentIconRef ; info.contentType = kControlContentIconRef ;
info.u.iconRef = iconRef ; info.u.iconRef = iconRef ;
SetControlData( (ControlHandle) m_macControl, ii+1,kControlTabImageContentTag, SetControlData( (ControlRef) m_macControl, ii+1,kControlTabImageContentTag,
sizeof( info ), (Ptr)&info ); sizeof( info ), (Ptr)&info );
wxASSERT_MSG( err == noErr , wxT("Error when setting icon on tab") ) ; wxASSERT_MSG( err == noErr , wxT("Error when setting icon on tab") ) ;
if ( UMAGetSystemVersion() < 0x1030 ) if ( UMAGetSystemVersion() < 0x1030 )
@@ -488,21 +412,14 @@ void wxNotebook::MacSetupTabs()
#endif #endif
} }
Rect bounds; Rect bounds;
GetControlBounds((ControlHandle)m_macControl, &bounds); UMAGetControlBoundsInWindowCoords((ControlRef)m_macControl, &bounds);
InvalWindowRect((WindowRef)MacGetRootWindow(), &bounds); InvalWindowRect((WindowRef)MacGetTopLevelWindowRef(), &bounds);
} }
wxRect wxNotebook::GetPageRect() const wxRect wxNotebook::GetPageRect() const
{ {
// fit the notebook page to the tab control's display area wxSize size = GetClientSize() ;
int w, h; return wxRect( 0 , 0 , size.x , size.y ) ;
GetSize(&w, &h);
return wxRect(
wxMacTabLeftMargin(GetWindowStyle()) + m_macHorizontalBorder,
wxMacTabTopMargin(GetWindowStyle()) + m_macVerticalBorder,
w - wxMacTabLeftMargin(GetWindowStyle()) - wxMacTabRightMargin(GetWindowStyle()) - 2*m_macHorizontalBorder,
h - wxMacTabTopMargin(GetWindowStyle()) - wxMacTabBottomMargin(GetWindowStyle()) - 2*m_macVerticalBorder);
} }
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// wxNotebook callbacks // wxNotebook callbacks
@@ -647,13 +564,13 @@ void wxNotebook::ChangePage(int nOldSel, int nSel)
} }
m_nSelection = nSel; m_nSelection = nSel;
SetControl32BitValue( (ControlHandle) m_macControl , m_nSelection + 1 ) ; SetControl32BitValue( (ControlRef) m_macControl , m_nSelection + 1 ) ;
} }
void wxNotebook::OnMouse( wxMouseEvent &event ) void wxNotebook::OnMouse( wxMouseEvent &event )
{ {
if ( (ControlHandle) m_macControl == NULL ) if ( (ControlRef) m_macControl == NULL )
{ {
event.Skip() ; event.Skip() ;
return ; return ;
@@ -664,9 +581,17 @@ void wxNotebook::OnMouse( wxMouseEvent &event )
int x = event.m_x ; int x = event.m_x ;
int y = event.m_y ; int y = event.m_y ;
MacClientToRootWindow( &x , &y ) ; #if TARGET_API_MAC_ISX
// 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
ControlHandle control ; ControlRef control ;
Point localwhere ; Point localwhere ;
SInt16 controlpart ; SInt16 controlpart ;
@@ -690,7 +615,7 @@ void wxNotebook::OnMouse( wxMouseEvent &event )
if ( event.m_metaDown ) if ( event.m_metaDown )
modifiers |= cmdKey ; modifiers |= cmdKey ;
control = (ControlHandle) m_macControl ; control = (ControlRef) m_macControl ;
if ( control && ::IsControlActive( control ) ) if ( control && ::IsControlActive( control ) )
{ {
{ {
@@ -720,7 +645,7 @@ void wxNotebook::OnMouse( wxMouseEvent &event )
void wxNotebook::MacHandleControlClick( WXWidget control , wxInt16 controlpart , bool WXUNUSED( mouseStillDown ) ) void wxNotebook::MacHandleControlClick( WXWidget control , wxInt16 controlpart , bool WXUNUSED( mouseStillDown ) )
{ {
#if 0 #if 0
wxNotebookEvent event(wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED, m_windowId , ::GetControl32BitValue((ControlHandle)m_macControl) - 1, m_nSelection); wxNotebookEvent event(wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED, m_windowId , ::GetControl32BitValue((ControlRef)m_macControl) - 1, m_nSelection);
event.SetEventObject(this); event.SetEventObject(this);
ProcessEvent(event); ProcessEvent(event);

View File

@@ -112,6 +112,8 @@ bool wxRadioBox::Create(wxWindow *parent, wxWindowID id, const wxString& label,
int majorDim, long style, int majorDim, long style,
const wxValidator& val, const wxString& name) const wxValidator& val, const wxString& name)
{ {
m_macIsUserPane = FALSE ;
if ( !wxControl::Create(parent, id, pos, size, style, val, name) ) if ( !wxControl::Create(parent, id, pos, size, style, val, name) )
return false; return false;
@@ -127,12 +129,15 @@ bool wxRadioBox::Create(wxWindow *parent, wxWindowID id, const wxString& label,
m_majorDim = majorDim ; m_majorDim = majorDim ;
Rect bounds ; m_label = label ;
Str255 title ;
Rect bounds = wxMacGetBoundsForControl( this , pos , size ) ;
MacPreControlCreate( parent , id , wxStripMenuCodes(label) , pos , size ,style, val , name , &bounds , title ) ; if( bounds.right <= bounds.left )
bounds.right = bounds.left + 100 ;
m_macControl = ::NewControl( MAC_WXHWND(parent->MacGetRootWindow()) , &bounds , title , false , 0 , 0 , 1, 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 ) ; kControlGroupBoxTextTitleProc , (long) this ) ;
for (i = 0; i < n; i++) for (i = 0; i < n; i++)
@@ -152,7 +157,7 @@ bool wxRadioBox::Create(wxWindow *parent, wxWindowID id, const wxString& label,
} }
SetSelection(0); SetSelection(0);
MacPostControlCreate() ; MacPostControlCreate(pos,size) ;
return TRUE; return TRUE;
} }
@@ -421,8 +426,8 @@ void wxRadioBox::DoSetSize(int x, int y, int width, int height, int sizeFlags)
int eachWidth[128],eachHeight[128]; int eachWidth[128],eachHeight[128];
int totWidth,totHeight; int totWidth,totHeight;
SetFont(GetParent()->GetFont());
GetTextExtent(wxT("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"), &charWidth, &charHeight); GetTextExtent(wxT("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"), &charWidth, &charHeight);
charWidth/=52; charWidth/=52;
maxWidth=-1; maxWidth=-1;
@@ -436,14 +441,16 @@ void wxRadioBox::DoSetSize(int x, int y, int width, int height, int sizeFlags)
if (maxHeight<eachHeight[i]) maxHeight = eachHeight[i]; if (maxHeight<eachHeight[i]) maxHeight = eachHeight[i];
} }
totHeight = GetRowCount() * (maxHeight + charHeight/2) + charHeight ; totHeight = GetRowCount() * ( maxHeight ) ;
totWidth = GetColumnCount() * (maxWidth + charWidth) + charWidth; totWidth = GetColumnCount() * (maxWidth + charWidth) ;
wxSize sz = DoGetSizeFromClientSize( wxSize( totWidth , totHeight ) ) ;
// only change our width/height if asked for // only change our width/height if asked for
if ( width == -1 ) if ( width == -1 )
{ {
if ( sizeFlags & wxSIZE_AUTO_WIDTH ) if ( sizeFlags & wxSIZE_AUTO_WIDTH )
width = totWidth ; width = sz.x ;
else else
width = widthOld; width = widthOld;
} }
@@ -451,7 +458,7 @@ void wxRadioBox::DoSetSize(int x, int y, int width, int height, int sizeFlags)
if ( height == -1 ) if ( height == -1 )
{ {
if ( sizeFlags & wxSIZE_AUTO_HEIGHT ) if ( sizeFlags & wxSIZE_AUTO_HEIGHT )
height = totHeight ; height = sz.y ;
else else
height = heightOld; height = heightOld;
} }
@@ -463,13 +470,9 @@ void wxRadioBox::DoSetSize(int x, int y, int width, int height, int sizeFlags)
int x_start,y_start; int x_start,y_start;
x_start = charWidth; x_start = 0;
y_start = 15 ; y_start = 0 ;
if ( UMAGetSystemVersion() >= 0x1030 )
{
//need to add a few more pixels for the top border on panther
y_start = y_start + 5; //how many exactly should this be to meet the HIG?
}
x_offset = x_start; x_offset = x_start;
y_offset = y_start; y_offset = y_start;
@@ -510,6 +513,7 @@ wxSize wxRadioBox::DoGetBestSize() const
wxFont font = GetParent()->GetFont(); wxFont font = GetParent()->GetFont();
GetTextExtent(wxT("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"), GetTextExtent(wxT("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"),
&charWidth, &charHeight, NULL, NULL, &font); &charWidth, &charHeight, NULL, NULL, &font);
charWidth /= 52; charWidth /= 52;
maxWidth = -1; maxWidth = -1;
@@ -517,21 +521,20 @@ wxSize wxRadioBox::DoGetBestSize() const
for (int i = 0 ; i < m_noItems; i++) for (int i = 0 ; i < m_noItems; i++)
{ {
GetTextExtent(GetString(i), &eachWidth, &eachHeight); GetTextExtent(GetString(i), &eachWidth, &eachHeight,NULL, NULL, &font);
eachWidth = (int)(eachWidth + RADIO_SIZE) ; eachWidth = (int)(eachWidth + RADIO_SIZE) ;
eachHeight = (int)((3 * eachHeight) / 2); eachHeight = (int)((3 * eachHeight) / 2);
if (maxWidth < eachWidth) maxWidth = eachWidth; if (maxWidth < eachWidth) maxWidth = eachWidth;
if (maxHeight < eachHeight) maxHeight = eachHeight; if (maxHeight < eachHeight) maxHeight = eachHeight;
} }
totHeight = GetRowCount() * (maxHeight + charHeight/2) + charHeight ; totHeight = GetRowCount() * (maxHeight ) ;
totWidth = GetColumnCount() * (maxWidth + charWidth) + charWidth; totWidth = GetColumnCount() * (maxWidth + charWidth) ;
wxSize sz = DoGetSizeFromClientSize( wxSize( totWidth , totHeight ) ) ;
totWidth = sz.x ;
totHeight = sz.y ;
if ( UMAGetSystemVersion() >= 0x1030 )
{
//need to add a few more pixels for the static boxborder on panther
totHeight = totHeight + 10; //how many exactly should this be to meet the HIG?
}
// handle radio box title as well // handle radio box title as well
GetTextExtent(GetTitle(), &eachWidth, NULL); GetTextExtent(GetTitle(), &eachWidth, NULL);
eachWidth = (int)(eachWidth + RADIO_SIZE) + 3 * charWidth ; eachWidth = (int)(eachWidth + RADIO_SIZE) + 3 * charWidth ;

View File

@@ -30,18 +30,19 @@ bool wxRadioButton::Create(wxWindow *parent, wxWindowID id,
const wxValidator& validator, const wxValidator& validator,
const wxString& name) const wxString& name)
{ {
m_macIsUserPane = FALSE ;
if ( !wxControl::Create(parent, id, pos, size, style, validator, name) ) if ( !wxControl::Create(parent, id, pos, size, style, validator, name) )
return false; return false;
Rect bounds ;
Str255 title ;
MacPreControlCreate( parent , id , label , pos , size ,style, validator , name , &bounds , title ) ; m_label = label ;
m_macControl = ::NewControl( MAC_WXHWND(parent->MacGetRootWindow()) , &bounds , title , false , 0 , 0 , 1, Rect bounds = wxMacGetBoundsForControl( this , pos , size ) ;
m_macControl = (WXWidget) ::NewControl( MAC_WXHWND(parent->MacGetTopLevelWindowRef()) , &bounds , "\p" , true , 0 , 0 , 1,
kControlRadioButtonProc , (long) this ) ; kControlRadioButtonProc , (long) this ) ;
MacPostControlCreate() ; MacPostControlCreate(pos,size) ;
m_cycle = this ; m_cycle = this ;
@@ -72,10 +73,10 @@ bool wxRadioButton::Create(wxWindow *parent, wxWindowID id,
void wxRadioButton::SetValue(bool val) void wxRadioButton::SetValue(bool val)
{ {
wxRadioButton *cycle; wxRadioButton *cycle;
if ( GetControl32BitValue( (ControlHandle) m_macControl ) == val ) if ( GetControl32BitValue( (ControlRef) m_macControl ) == val )
return ; return ;
::SetControl32BitValue( (ControlHandle) m_macControl , val ) ; ::SetControl32BitValue( (ControlRef) m_macControl , val ) ;
if (val) if (val)
{ {
cycle=this->NextInCycle(); cycle=this->NextInCycle();
@@ -91,7 +92,7 @@ void wxRadioButton::SetValue(bool val)
bool wxRadioButton::GetValue() const bool wxRadioButton::GetValue() const
{ {
return ::GetControl32BitValue( (ControlHandle) m_macControl ) ; return ::GetControl32BitValue( (ControlRef) m_macControl ) ;
} }
void wxRadioButton::Command (wxCommandEvent & event) void wxRadioButton::Command (wxCommandEvent & event)

View File

@@ -40,23 +40,21 @@ bool wxScrollBar::Create(wxWindow *parent, wxWindowID id,
const wxValidator& validator, const wxValidator& validator,
const wxString& name) const wxString& name)
{ {
m_macIsUserPane = FALSE ;
if ( !wxControl::Create(parent, id, pos, size, style, validator, name) ) if ( !wxControl::Create(parent, id, pos, size, style, validator, name) )
return FALSE; return FALSE;
Rect bounds ; Rect bounds = wxMacGetBoundsForControl( this , pos , size ) ;
Str255 title ; m_macControl = (WXWidget) ::NewControl(MAC_WXHWND(parent->MacGetTopLevelWindowRef()) ,
&bounds , "\p" , true , 0 , 0 , 100,
MacPreControlCreate( parent , id , wxEmptyString , pos , size ,style, validator , name , &bounds , title ) ;
m_macControl = ::NewControl(MAC_WXHWND(parent->MacGetRootWindow()) ,
&bounds , title , false , 0 , 0 , 100,
kControlScrollBarLiveProc , (long) this) ; kControlScrollBarLiveProc , (long) this) ;
wxASSERT_MSG( (ControlHandle) m_macControl != NULL , wxT("No valid mac control") ) ; wxASSERT_MSG( (ControlRef) m_macControl != NULL , wxT("No valid mac control") ) ;
::SetControlAction( (ControlHandle) m_macControl , wxMacLiveScrollbarActionUPP ) ; ::SetControlAction( (ControlRef) m_macControl , wxMacLiveScrollbarActionUPP ) ;
MacPostControlCreate() ; MacPostControlCreate(pos,size) ;
return TRUE; return TRUE;
} }
@@ -67,12 +65,12 @@ wxScrollBar::~wxScrollBar()
void wxScrollBar::SetThumbPosition(int viewStart) void wxScrollBar::SetThumbPosition(int viewStart)
{ {
::SetControl32BitValue( (ControlHandle) m_macControl , viewStart ) ; ::SetControl32BitValue( (ControlRef) m_macControl , viewStart ) ;
} }
int wxScrollBar::GetThumbPosition() const int wxScrollBar::GetThumbPosition() const
{ {
return ::GetControl32BitValue( (ControlHandle) m_macControl ) ; return ::GetControl32BitValue( (ControlRef) m_macControl ) ;
} }
void wxScrollBar::SetScrollbar(int position, int thumbSize, int range, int pageSize, void wxScrollBar::SetScrollbar(int position, int thumbSize, int range, int pageSize,
@@ -84,15 +82,15 @@ void wxScrollBar::SetScrollbar(int position, int thumbSize, int range, int pageS
int range1 = wxMax((m_objectSize - m_viewSize), 0) ; int range1 = wxMax((m_objectSize - m_viewSize), 0) ;
SetControl32BitMaximum( (ControlHandle) m_macControl , range1 ) ; SetControl32BitMaximum( (ControlRef) m_macControl , range1 ) ;
SetControl32BitMinimum( (ControlHandle) m_macControl , 0 ) ; SetControl32BitMinimum( (ControlRef) m_macControl , 0 ) ;
SetControl32BitValue( (ControlHandle) m_macControl , position ) ; SetControl32BitValue( (ControlRef) m_macControl , position ) ;
if ( UMAGetAppearanceVersion() >= 0x0110 ) if ( UMAGetAppearanceVersion() >= 0x0110 )
{ {
if ( SetControlViewSize != (void*) kUnresolvedCFragSymbolAddress ) if ( SetControlViewSize != (void*) kUnresolvedCFragSymbolAddress )
{ {
SetControlViewSize( (ControlHandle) m_macControl , m_viewSize ) ; SetControlViewSize( (ControlRef) m_macControl , m_viewSize ) ;
} }
} }
if ( refresh ) if ( refresh )
@@ -108,12 +106,12 @@ void wxScrollBar::Command(wxCommandEvent& event)
void wxScrollBar::MacHandleControlClick( WXWidget control , wxInt16 controlpart , bool mouseStillDown ) void wxScrollBar::MacHandleControlClick( WXWidget control , wxInt16 controlpart , bool mouseStillDown )
{ {
if ( (ControlHandle) m_macControl == NULL ) if ( (ControlRef) m_macControl == NULL )
return ; return ;
int position = GetControl32BitValue( (ControlHandle) m_macControl) ; int position = GetControl32BitValue( (ControlRef) m_macControl) ;
int minPos = GetControl32BitMinimum( (ControlHandle) m_macControl) ; int minPos = GetControl32BitMinimum( (ControlRef) m_macControl) ;
int maxPos = GetControl32BitMaximum( (ControlHandle) m_macControl) ; int maxPos = GetControl32BitMaximum( (ControlRef) m_macControl) ;
wxEventType scrollEvent = wxEVT_NULL; wxEventType scrollEvent = wxEVT_NULL;
int nScrollInc = 0; int nScrollInc = 0;

View File

@@ -57,11 +57,11 @@ bool wxSlider::Create(wxWindow *parent, wxWindowID id,
const wxValidator& validator, const wxValidator& validator,
const wxString& name) const wxString& name)
{ {
m_macIsUserPane = FALSE ;
if ( !wxControl::Create(parent, id, pos, size, style, validator, name) ) if ( !wxControl::Create(parent, id, pos, size, style, validator, name) )
return false; return false;
Rect bounds ;
Str255 title ;
SInt16 procID; SInt16 procID;
m_macMinimumStatic = NULL ; m_macMinimumStatic = NULL ;
@@ -77,8 +77,7 @@ bool wxSlider::Create(wxWindow *parent, wxWindowID id,
m_pageSize = (int)((maxValue-minValue)/10); m_pageSize = (int)((maxValue-minValue)/10);
MacPreControlCreate( parent, id, wxEmptyString, pos, size, style, Rect bounds = wxMacGetBoundsForControl( this , pos , size ) ;
validator, name, &bounds, title );
procID = kControlSliderProc + kControlSliderLiveFeedback; procID = kControlSliderProc + kControlSliderLiveFeedback;
if(style & wxSL_AUTOTICKS) { if(style & wxSL_AUTOTICKS) {
@@ -86,28 +85,13 @@ bool wxSlider::Create(wxWindow *parent, wxWindowID id,
} }
m_macControl = ::NewControl( MAC_WXHWND(parent->MacGetRootWindow()), &bounds, title, false, m_macControl = (WXWidget) ::NewControl( MAC_WXHWND(parent->MacGetTopLevelWindowRef()), &bounds, "\p", true,
value, minValue, maxValue, procID, (long) this); value, minValue, maxValue, procID, (long) this);
wxASSERT_MSG( (ControlHandle) m_macControl != NULL , wxT("No valid mac control") ) ; wxASSERT_MSG( (ControlRef) m_macControl != NULL , wxT("No valid mac control") ) ;
::SetControlAction( (ControlHandle) m_macControl , wxMacLiveScrollbarActionUPP ) ;
if(style & wxSL_LABELS)
{
m_macMinimumStatic = new wxStaticText( this, -1, wxEmptyString );
m_macMaximumStatic = new wxStaticText( this, -1, wxEmptyString );
m_macValueStatic = new wxStaticText( this, -1, wxEmptyString );
SetRange(minValue, maxValue);
SetValue(value);
}
else {
m_macMinimumStatic = NULL ;
m_macMaximumStatic = NULL ;
m_macValueStatic = NULL ;
}
::SetControlAction( (ControlRef) m_macControl , wxMacLiveScrollbarActionUPP ) ;
if(style & wxSL_VERTICAL) { if(style & wxSL_VERTICAL) {
SetSizeHints(10, -1, 10, -1); // Forces SetSize to use the proper width SetSizeHints(10, -1, 10, -1); // Forces SetSize to use the proper width
} }
@@ -118,18 +102,30 @@ bool wxSlider::Create(wxWindow *parent, wxWindowID id,
// proper dimensions, it also means other people cannot bugger the slider with // proper dimensions, it also means other people cannot bugger the slider with
// other values // other values
MacPostControlCreate() ; if(style & wxSL_LABELS)
{
m_macMinimumStatic = new wxStaticText( parent, -1, wxEmptyString );
m_macMaximumStatic = new wxStaticText( parent, -1, wxEmptyString );
m_macValueStatic = new wxStaticText( parent, -1, wxEmptyString );
SetRange(minValue, maxValue);
SetValue(value);
}
MacPostControlCreate(pos,size) ;
return true; return true;
} }
wxSlider::~wxSlider() wxSlider::~wxSlider()
{ {
delete m_macMinimumStatic ;
delete m_macMaximumStatic ;
delete m_macValueStatic ;
} }
int wxSlider::GetValue() const int wxSlider::GetValue() const
{ {
return GetControl32BitValue( (ControlHandle) m_macControl) ; return GetControl32BitValue( (ControlRef) m_macControl) ;
} }
void wxSlider::SetValue(int value) void wxSlider::SetValue(int value)
@@ -138,7 +134,7 @@ void wxSlider::SetValue(int value)
valuestring.Printf( wxT("%d") , value ) ; valuestring.Printf( wxT("%d") , value ) ;
if ( m_macValueStatic ) if ( m_macValueStatic )
m_macValueStatic->SetLabel( valuestring ) ; m_macValueStatic->SetLabel( valuestring ) ;
SetControl32BitValue( (ControlHandle) m_macControl , value ) ; SetControl32BitValue( (ControlRef) m_macControl , value ) ;
} }
void wxSlider::SetRange(int minValue, int maxValue) void wxSlider::SetRange(int minValue, int maxValue)
@@ -148,8 +144,8 @@ void wxSlider::SetRange(int minValue, int maxValue)
m_rangeMin = minValue; m_rangeMin = minValue;
m_rangeMax = maxValue; m_rangeMax = maxValue;
SetControl32BitMinimum( (ControlHandle) m_macControl, m_rangeMin); SetControl32BitMinimum( (ControlRef) m_macControl, m_rangeMin);
SetControl32BitMaximum( (ControlHandle) m_macControl, m_rangeMax); SetControl32BitMaximum( (ControlRef) m_macControl, m_rangeMax);
if(m_macMinimumStatic) { if(m_macMinimumStatic) {
value.Printf(wxT("%d"), m_rangeMin); value.Printf(wxT("%d"), m_rangeMin);
@@ -243,7 +239,7 @@ void wxSlider::Command (wxCommandEvent & event)
void wxSlider::MacHandleControlClick( WXWidget control , wxInt16 controlpart, bool mouseStillDown ) void wxSlider::MacHandleControlClick( WXWidget control , wxInt16 controlpart, bool mouseStillDown )
{ {
SInt16 value = ::GetControl32BitValue( (ControlHandle) m_macControl ) ; SInt16 value = ::GetControl32BitValue( (ControlRef) m_macControl ) ;
SetValue( value ) ; SetValue( value ) ;
@@ -334,26 +330,8 @@ wxSize wxSlider::DoGetBestSize() const
return size; return size;
} }
void wxSlider::DoSetSize(int x, int y, int width, int height, int sizeFlags) void wxSlider::DoSetSize(int x, int y, int w, int h, int sizeFlags)
{ {
wxControl::DoSetSize( x, y , width , height ,sizeFlags ) ;
}
void wxSlider::MacUpdateDimensions()
{
// actually in the current systems this should never be possible, but later reparenting
// may become a reality
if ( (ControlHandle) m_macControl == NULL )
return ;
if ( GetParent() == NULL )
return ;
WindowRef rootwindow = (WindowRef) MacGetRootWindow() ;
if ( rootwindow == NULL )
return ;
int xborder, yborder; int xborder, yborder;
int minValWidth, maxValWidth, textwidth, textheight; int minValWidth, maxValWidth, textwidth, textheight;
int sliderBreadth; int sliderBreadth;
@@ -388,43 +366,30 @@ void wxSlider::MacUpdateDimensions()
if(GetWindowStyle() & wxSL_VERTICAL) if(GetWindowStyle() & wxSL_VERTICAL)
{ {
m_macMinimumStatic->Move(sliderBreadth + wxSLIDER_BORDERTEXT,
m_height - yborder - textheight); if ( m_macMinimumStatic )
m_macMaximumStatic->Move(sliderBreadth + wxSLIDER_BORDERTEXT, 0); m_macMinimumStatic->Move(x + sliderBreadth + wxSLIDER_BORDERTEXT,
m_macValueStatic->Move(0, m_height - textheight); y + h - yborder - textheight);
if ( m_macMaximumStatic )
m_macMaximumStatic->Move(x + sliderBreadth + wxSLIDER_BORDERTEXT, y + 0);
if ( m_macValueStatic )
m_macValueStatic->Move(0, y + h - textheight);
h = h - yborder ;
} }
else else
{ {
m_macMinimumStatic->Move(0, sliderBreadth + wxSLIDER_BORDERTEXT); if ( m_macMinimumStatic )
m_macMaximumStatic->Move(m_width - xborder - maxValWidth / 2, m_macMinimumStatic->Move(x + 0, y + sliderBreadth + wxSLIDER_BORDERTEXT);
sliderBreadth + wxSLIDER_BORDERTEXT); if ( m_macMaximumStatic )
m_macValueStatic->Move(m_width - textwidth, 0); m_macMaximumStatic->Move(x + w - xborder - maxValWidth / 2,
y + sliderBreadth + wxSLIDER_BORDERTEXT);
if ( m_macValueStatic )
m_macValueStatic->Move(x + w - textwidth, y + 0);
w = w - xborder ;
} }
} }
Rect oldBounds ; wxControl::DoSetSize( x, y , w , h ,sizeFlags ) ;
GetControlBounds( (ControlHandle) m_macControl , &oldBounds ) ;
int new_x = m_x + MacGetLeftBorderSize() + m_macHorizontalBorder ;
int new_y = m_y + MacGetTopBorderSize() + m_macVerticalBorder ;
int new_width = m_width - MacGetLeftBorderSize() - MacGetRightBorderSize() - 2 * m_macHorizontalBorder - xborder ;
int new_height = m_height - MacGetTopBorderSize() - MacGetBottomBorderSize() - 2 * m_macVerticalBorder - yborder ;
GetParent()->MacWindowToRootWindow( & new_x , & new_y ) ;
bool doMove = new_x != oldBounds.left || new_y != oldBounds.top ;
bool doResize = ( oldBounds.right - oldBounds.left ) != new_width || (oldBounds.bottom - oldBounds.top ) != new_height ;
if ( doMove || doResize )
{
InvalWindowRect( rootwindow, &oldBounds ) ;
if ( doMove )
{
UMAMoveControl( (ControlHandle) m_macControl , new_x , new_y ) ;
}
if ( doResize )
{
UMASizeControl( (ControlHandle) m_macControl , new_width , new_height ) ;
}
}
} }
void wxSlider::DoMoveWindow(int x, int y, int width, int height) void wxSlider::DoMoveWindow(int x, int y, int width, int height)

View File

@@ -38,6 +38,8 @@ wxSpinButton::wxSpinButton()
bool wxSpinButton::Create(wxWindow *parent, wxWindowID id, const wxPoint& pos, const wxSize& size, bool wxSpinButton::Create(wxWindow *parent, wxWindowID id, const wxPoint& pos, const wxSize& size,
long style, const wxString& name) long style, const wxString& name)
{ {
m_macIsUserPane = FALSE ;
if ( !wxSpinButtonBase::Create(parent, id, pos, size, if ( !wxSpinButtonBase::Create(parent, id, pos, size,
style, wxDefaultValidator, name) ) style, wxDefaultValidator, name) )
return false; return false;
@@ -48,17 +50,14 @@ bool wxSpinButton::Create(wxWindow *parent, wxWindowID id, const wxPoint& pos, c
if (!parent) if (!parent)
return FALSE; return FALSE;
Rect bounds ; Rect bounds = wxMacGetBoundsForControl( this , pos , size ) ;
Str255 title ;
MacPreControlCreate( parent , id , wxEmptyString , pos , size ,style,*( (wxValidator*) NULL ) , name , &bounds , title ) ; m_macControl = (WXWidget) ::NewControl( MAC_WXHWND(parent->MacGetTopLevelWindowRef()) , &bounds , "\p" , true , 0 , 0 , 100,
m_macControl = ::NewControl( MAC_WXHWND(parent->MacGetRootWindow()) , &bounds , title , false , 0 , 0 , 100,
kControlLittleArrowsProc , (long) this ) ; kControlLittleArrowsProc , (long) this ) ;
wxASSERT_MSG( (ControlHandle) m_macControl != NULL , wxT("No valid mac control") ) ; wxASSERT_MSG( (ControlRef) m_macControl != NULL , wxT("No valid mac control") ) ;
MacPostControlCreate() ; MacPostControlCreate(pos,size) ;
return TRUE; return TRUE;
} }
@@ -94,8 +93,8 @@ void wxSpinButton::SetRange(int minVal, int maxVal)
{ {
m_min = minVal; m_min = minVal;
m_max = maxVal; m_max = maxVal;
SetControl32BitMaximum( (ControlHandle) m_macControl , maxVal ) ; SetControl32BitMaximum( (ControlRef) m_macControl , maxVal ) ;
SetControl32BitMinimum((ControlHandle) m_macControl , minVal ) ; SetControl32BitMinimum((ControlRef) m_macControl , minVal ) ;
} }
void wxSpinButton::MacHandleValueChanged( int inc ) void wxSpinButton::MacHandleValueChanged( int inc )
@@ -138,7 +137,7 @@ void wxSpinButton::MacHandleValueChanged( int inc )
{ {
m_value = oldValue ; m_value = oldValue ;
} }
SetControl32BitValue( (ControlHandle) m_macControl , m_value ) ; SetControl32BitValue( (ControlRef) m_macControl , m_value ) ;
/* always send a thumbtrack event */ /* always send a thumbtrack event */
if (scrollEvent != wxEVT_SCROLL_THUMBTRACK) if (scrollEvent != wxEVT_SCROLL_THUMBTRACK)
@@ -153,7 +152,7 @@ void wxSpinButton::MacHandleValueChanged( int inc )
void wxSpinButton::MacHandleControlClick( WXWidget control , wxInt16 controlpart , bool WXUNUSED(mouseStillDown)) void wxSpinButton::MacHandleControlClick( WXWidget control , wxInt16 controlpart , bool WXUNUSED(mouseStillDown))
{ {
if ( (ControlHandle) m_macControl == NULL ) if ( (ControlRef) m_macControl == NULL )
return ; return ;
int nScrollInc = 0; int nScrollInc = 0;

View File

@@ -20,11 +20,6 @@
#if !USE_SHARED_LIBRARY #if !USE_SHARED_LIBRARY
IMPLEMENT_DYNAMIC_CLASS(wxStaticBox, wxControl) IMPLEMENT_DYNAMIC_CLASS(wxStaticBox, wxControl)
BEGIN_EVENT_TABLE(wxStaticBox, wxControl)
EVT_ERASE_BACKGROUND(wxStaticBox::OnEraseBackground)
END_EVENT_TABLE()
#endif #endif
/* /*
@@ -38,19 +33,20 @@ bool wxStaticBox::Create(wxWindow *parent, wxWindowID id,
long style, long style,
const wxString& name) const wxString& name)
{ {
m_macIsUserPane = FALSE ;
if ( !wxControl::Create(parent, id, pos, size, if ( !wxControl::Create(parent, id, pos, size,
style, wxDefaultValidator, name) ) style, wxDefaultValidator, name) )
return false; return false;
Rect bounds ; m_label = label ;
Str255 title ;
Rect bounds = wxMacGetBoundsForControl( this , pos , size ) ;
MacPreControlCreate( parent , id , label , pos , size ,style, wxDefaultValidator , name , &bounds , title ) ; m_macControl = (WXWidget) ::NewControl( MAC_WXHWND(parent->MacGetTopLevelWindowRef()) , &bounds , "\p" , true , 0 , 0 , 1,
m_macControl = ::NewControl( MAC_WXHWND(parent->MacGetRootWindow()) , &bounds , title , false , 0 , 0 , 1,
kControlGroupBoxTextTitleProc , (long) this ) ; kControlGroupBoxTextTitleProc , (long) this ) ;
MacPostControlCreate() ; MacPostControlCreate(pos,size) ;
return TRUE; return TRUE;
} }

View File

@@ -50,17 +50,23 @@ bool wxStatusBarMac::Create(wxWindow *parent, wxWindowID id,
long style , long style ,
const wxString& name) const wxString& name)
{ {
return wxStatusBarGeneric::Create( parent , id , style , name ) ; if( !wxStatusBarGeneric::Create( parent , id , style , name ) )
return FALSE ;
m_macBackgroundBrush.MacSetTheme( kThemeBrushDialogBackgroundActive ) ;
return TRUE ;
} }
void wxStatusBarMac::DrawFieldText(wxDC& dc, int i) void wxStatusBarMac::DrawFieldText(wxDC& dc, int i)
{ {
int leftMargin = 2; int leftMargin = 2;
int w, h ;
GetSize( &w , &h ) ;
wxRect rect; wxRect rect;
GetFieldRect(i, rect); GetFieldRect(i, rect);
if ( !IsWindowHilited( MAC_WXHWND( MacGetRootWindow() ) ) ) if ( !IsWindowHilited( MAC_WXHWND( MacGetTopLevelWindowRef() ) ) )
{ {
dc.SetTextForeground( wxColour( 0x80 , 0x80 , 0x80 ) ) ; dc.SetTextForeground( wxColour( 0x80 , 0x80 , 0x80 ) ) ;
} }
@@ -74,7 +80,7 @@ void wxStatusBarMac::DrawFieldText(wxDC& dc, int i)
int xpos = rect.x + leftMargin + 1 ; int xpos = rect.x + leftMargin + 1 ;
int ypos = 1 ; int ypos = 1 ;
dc.SetClippingRegion(rect.x, 0, rect.width, m_height); dc.SetClippingRegion(rect.x, 0, rect.width, h);
dc.DrawText(text, xpos, ypos); dc.DrawText(text, xpos, ypos);
@@ -94,8 +100,10 @@ void wxStatusBarMac::SetStatusText(const wxString& text, int number)
m_statusStrings[number] = text; m_statusStrings[number] = text;
wxRect rect; wxRect rect;
GetFieldRect(number, rect); GetFieldRect(number, rect);
int w, h ;
GetSize( &w , &h ) ;
rect.y=0; rect.y=0;
rect.height = m_height ; rect.height = h ;
Refresh( TRUE , &rect ) ; Refresh( TRUE , &rect ) ;
Update(); Update();
} }
@@ -107,8 +115,10 @@ void wxStatusBarMac::OnPaint(wxPaintEvent& WXUNUSED(event) )
int major,minor; int major,minor;
wxGetOsVersion( &major, &minor ); wxGetOsVersion( &major, &minor );
int w, h ;
GetSize( &w , &h ) ;
if ( IsWindowHilited( MAC_WXHWND( MacGetRootWindow() ) ) ) if ( IsWindowHilited( MAC_WXHWND( MacGetTopLevelWindowRef() ) ) )
{ {
wxPen white( wxWHITE , 1 , wxSOLID ) ; wxPen white( wxWHITE , 1 , wxSOLID ) ;
if (major >= 10) if (major >= 10)
@@ -122,10 +132,10 @@ void wxStatusBarMac::OnPaint(wxPaintEvent& WXUNUSED(event) )
dc.SetPen(black); dc.SetPen(black);
} }
dc.DrawLine(0, 0 , dc.DrawLine(0, 0 ,
m_width , 0); w , 0);
dc.SetPen(white); dc.SetPen(white);
dc.DrawLine(0, 1 , dc.DrawLine(0, 1 ,
m_width , 1); w , 1);
} }
else else
{ {
@@ -136,7 +146,7 @@ void wxStatusBarMac::OnPaint(wxPaintEvent& WXUNUSED(event) )
dc.SetPen(wxPen(wxColour(0x80,0x80,0x80),1,wxSOLID)); dc.SetPen(wxPen(wxColour(0x80,0x80,0x80),1,wxSOLID));
dc.DrawLine(0, 0 , dc.DrawLine(0, 0 ,
m_width , 0); w , 0);
} }
int i; int i;
@@ -147,9 +157,3 @@ void wxStatusBarMac::OnPaint(wxPaintEvent& WXUNUSED(event) )
for ( i = 0; i < m_nFields; i ++ ) for ( i = 0; i < m_nFields; i ++ )
DrawField(dc, i); DrawField(dc, i);
} }
void wxStatusBarMac::MacSuperEnabled( bool enabled )
{
Refresh(FALSE) ;
wxWindow::MacSuperEnabled( enabled ) ;
}

View File

@@ -49,19 +49,17 @@ bool wxStaticLine::Create( wxWindow *parent,
long style, long style,
const wxString &name) const wxString &name)
{ {
m_macIsUserPane = FALSE ;
if ( !wxStaticLineBase::Create(parent, id, pos, size, if ( !wxStaticLineBase::Create(parent, id, pos, size,
style, wxDefaultValidator, name) ) style, wxDefaultValidator, name) )
return false; return false;
Rect bounds ; Rect bounds = wxMacGetBoundsForControl( this , pos , size ) ;
Str255 title ; m_macControl = (WXWidget) ::NewControl( MAC_WXHWND(parent->MacGetTopLevelWindowRef()) , &bounds , "\p" , true , 0 , 0 , 1,
MacPreControlCreate( parent , id , wxEmptyString , pos , size ,style, wxDefaultValidator , name , &bounds , title ) ;
m_macControl = ::NewControl( MAC_WXHWND(parent->MacGetRootWindow()) , &bounds , title , false , 0 , 0 , 1,
kControlSeparatorLineProc , (long) this ) ; kControlSeparatorLineProc , (long) this ) ;
MacPostControlCreate() ; MacPostControlCreate(pos,size) ;
return TRUE; return TRUE;
} }

View File

@@ -30,10 +30,6 @@ IMPLEMENT_DYNAMIC_CLASS(wxStaticText, wxControl)
#include "wx/mac/uma.h" #include "wx/mac/uma.h"
BEGIN_EVENT_TABLE(wxStaticText, wxStaticTextBase)
EVT_PAINT(wxStaticText::OnPaint)
END_EVENT_TABLE()
bool wxStaticText::Create(wxWindow *parent, wxWindowID id, bool wxStaticText::Create(wxWindow *parent, wxWindowID id,
const wxString& label, const wxString& label,
const wxPoint& pos, const wxPoint& pos,
@@ -41,6 +37,8 @@ bool wxStaticText::Create(wxWindow *parent, wxWindowID id,
long style, long style,
const wxString& name) const wxString& name)
{ {
m_macIsUserPane = FALSE ;
m_label = wxStripMenuCodes(label) ; m_label = wxStripMenuCodes(label) ;
if ( !wxControl::Create( parent, id, pos, size, style, if ( !wxControl::Create( parent, id, pos, size, style,
@@ -49,196 +47,43 @@ bool wxStaticText::Create(wxWindow *parent, wxWindowID id,
return false; return false;
} }
SetBestSize( size ) ; Rect bounds = wxMacGetBoundsForControl( this , pos , size ) ;
wxMacCFStringHolder str(m_label,m_font.GetEncoding() ) ;
verify_noerr(CreateStaticTextControl(MAC_WXHWND(parent->MacGetTopLevelWindowRef()),&bounds, str ,
NULL , (ControlRef*)&m_macControl ) ) ;
MacPostControlCreate(pos,size) ;
return true; return true;
} }
const wxString punct = wxT(" ,.-;:!?");
void wxStaticText::DrawParagraph(wxDC &dc, wxString paragraph, int &y)
{
long width, height ;
if (paragraph.Length() == 0)
{
// empty line
dc.GetTextExtent( wxT("H"), &width, &height );
y += height;
return;
}
int x = 0 ;
bool linedrawn = true;
while( paragraph.Length() > 0 )
{
dc.GetTextExtent( paragraph , &width , &height ) ;
if ( width > m_width )
{
for ( size_t p = paragraph.Length() - 1 ; p > 0 ; --p )
{
if ((punct.Find(paragraph[p]) != wxNOT_FOUND) || !linedrawn)
{
int blank = (paragraph[p] == ' ') ? 0 : 1;
dc.GetTextExtent( paragraph.Left(p + blank) , &width , &height ) ;
if ( width <= m_width )
{
int pos = x ;
if ( HasFlag( wxALIGN_CENTER ) )
{
pos += ( m_width - width ) / 2 ;
}
else if ( HasFlag( wxALIGN_RIGHT ) )
{
pos += ( m_width - width ) ;
}
dc.DrawText( paragraph.Left(p + blank), pos , y) ;
y += height ;
paragraph = paragraph.Mid(p+1) ;
linedrawn = true;
break ;
}
}
}
linedrawn = false;
}
else
{
int pos = x ;
if ( HasFlag( wxALIGN_CENTER ) )
{
pos += ( m_width - width ) / 2 ;
}
else if ( HasFlag( wxALIGN_RIGHT ) )
{
pos += ( m_width - width ) ;
}
dc.DrawText( paragraph, pos , y) ;
paragraph=wxEmptyString;
y += height ;
}
}
}
void wxStaticText::OnDraw( wxDC &dc )
{
if (m_width <= 0 || m_height <= 0)
return;
/*
dc.Clear() ;
wxRect rect(0,0,m_width,m_height) ;
dc.SetFont(*wxSMALL_FONT) ;
dc.DrawRectangle(rect) ;
*/
if ( !IsWindowHilited( (WindowRef) MacGetRootWindow() ) &&
( GetBackgroundColour() == wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE )
|| GetBackgroundColour() == wxSystemSettings::GetColour(wxSYS_COLOUR_APPWORKSPACE) ) )
{
dc.SetTextForeground( wxColour( 0x80 , 0x80 , 0x80 ) ) ;
}
else
{
dc.SetTextForeground( GetForegroundColour() ) ;
}
wxString paragraph;
size_t i = 0 ;
wxString text = m_label;
int y = 0 ;
while (i < text.Length())
{
if (text[i] == 13 || text[i] == 10)
{
DrawParagraph(dc, paragraph,y);
paragraph = wxEmptyString ;
}
else
{
paragraph += text[i];
}
++i;
}
if (paragraph.Length() > 0)
DrawParagraph(dc, paragraph,y);
}
void wxStaticText::OnPaint( wxPaintEvent & WXUNUSED(event) )
{
wxPaintDC dc(this);
OnDraw( dc ) ;
}
wxSize wxStaticText::DoGetBestSize() const wxSize wxStaticText::DoGetBestSize() const
{ {
int widthTextMax = 0, widthLine, ControlFontStyleRec controlFont ;
heightTextTotal = 0, heightLineDefault = 0, heightLine = 0; Size outSize ;
verify_noerr( GetControlData( (ControlRef) m_macControl , kControlEntireControl , kControlFontStyleTag , sizeof(controlFont) , &controlFont , &outSize ) ) ;
Point bounds ;
SInt16 baseline ;
wxMacCFStringHolder str(m_label , m_font.GetEncoding() ) ;
verify_noerr( GetThemeTextDimensions( str , m_font.MacGetThemeFontID() , kThemeStateActive , false , &bounds , &baseline ) ) ;
wxString curLine; return wxSize(bounds.h, bounds.v);
for ( const wxChar *pc = m_label; ; pc++ )
{
if ( *pc == wxT('\n') || *pc == wxT('\r') || *pc == wxT('\0') )
{
if ( !curLine )
{
// we can't use GetTextExtent - it will return 0 for both width
// and height and an empty line should count in height
// calculation
if ( !heightLineDefault )
heightLineDefault = heightLine;
if ( !heightLineDefault )
GetTextExtent(_T("W"), NULL, &heightLineDefault);
heightTextTotal += heightLineDefault;
heightTextTotal++; // FIXME: why is this necessary?
}
else
{
GetTextExtent(curLine, &widthLine, &heightLine);
if ( widthLine > widthTextMax )
widthTextMax = widthLine;
heightTextTotal += heightLine;
heightTextTotal++; // FIXME: why is this necessary?
}
if ( *pc == wxT('\n') || *pc == wxT('\r')) {
curLine.Empty();
}
else {
// the end of string
break;
}
}
else {
curLine += *pc;
}
}
return wxSize(widthTextMax, heightTextTotal);
} }
void wxStaticText::SetLabel(const wxString& st ) void wxStaticText::SetLabel(const wxString& st )
{ {
SetTitle( st ) ;
m_label = st ; m_label = wxStripMenuCodes(st) ;
wxMacCFStringHolder str(m_label,m_font.GetEncoding() ) ;
CFStringRef ref = str ;
SetControlData( (ControlRef) m_macControl, kControlEntireControl , kControlStaticTextCFStringTag, sizeof( CFStringRef ),
&ref );
if ( !(GetWindowStyle() & wxST_NO_AUTORESIZE) ) if ( !(GetWindowStyle() & wxST_NO_AUTORESIZE) )
{
// temporary fix until layout measurement and drawing are in synch again
Refresh() ;
SetSize( GetBestSize() ) ; SetSize( GetBestSize() ) ;
}
Refresh() ;
Update() ; Update() ;
} }
@@ -248,14 +93,8 @@ bool wxStaticText::SetFont(const wxFont& font)
if ( ret ) if ( ret )
{ {
// adjust the size of the window to fit to the label unless autoresizing is
// disabled
if ( !(GetWindowStyle() & wxST_NO_AUTORESIZE) ) if ( !(GetWindowStyle() & wxST_NO_AUTORESIZE) )
{
// temporary fix until layout measurement and drawing are in synch again
Refresh() ;
SetSize( GetBestSize() ); SetSize( GetBestSize() );
}
} }
return ret; return ret;

View File

@@ -34,21 +34,19 @@ wxTabCtrl::wxTabCtrl()
bool wxTabCtrl::Create(wxWindow *parent, wxWindowID id, const wxPoint& pos, const wxSize& size, bool wxTabCtrl::Create(wxWindow *parent, wxWindowID id, const wxPoint& pos, const wxSize& size,
long style, const wxString& name) long style, const wxString& name)
{ {
m_macIsUserPane = FALSE ;
if ( !wxControl::Create(parent, id, pos, size, if ( !wxControl::Create(parent, id, pos, size,
style, wxDefaultValidator, name) ) style, wxDefaultValidator, name) )
return false; return false;
Rect bounds ;
Str255 title ;
m_imageList = NULL; m_imageList = NULL;
MacPreControlCreate( parent , id , wxEmptyString , pos , size ,style, wxDefaultValidator , name , &bounds , title ) ; Rect bounds = wxMacGetBoundsForControl( this , pos , size ) ;
m_macControl = (WXWidget) ::NewControl( MAC_WXHWND(parent->MacGetTopLevelWindowRef()) , &bounds , "\p" , true , 0 , 0 , 1,
m_macControl = ::NewControl( MAC_WXHWND(parent->MacGetRootWindow()) , &bounds , title , false , 0 , 0 , 1,
kControlTabSmallProc , (long) this ) ; kControlTabSmallProc , (long) this ) ;
MacPostControlCreate() ; MacPostControlCreate(pos,size) ;
return TRUE ; return TRUE ;
} }

File diff suppressed because it is too large Load Diff

View File

@@ -56,25 +56,19 @@ bool wxToggleButton::Create(wxWindow *parent, wxWindowID id,
const wxValidator& validator, const wxValidator& validator,
const wxString& name) const wxString& name)
{ {
m_macIsUserPane = FALSE ;
if ( !wxControl::Create(parent, id, pos, size, style, validator, name) ) if ( !wxControl::Create(parent, id, pos, size, style, validator, name) )
return false; return false;
Rect bounds ;
Str255 title ;
if ( UMAHasAquaLayout() )
{
m_macHorizontalBorder = kMacOSXHorizontalBorder;
m_macVerticalBorder = kMacOSXVerticalBorder;
}
MacPreControlCreate( parent , id , label , pos , size ,style, validator , name , &bounds , title ) ; m_label = label ;
m_macControl = ::NewControl( MAC_WXHWND(parent->MacGetRootWindow()) , &bounds , title , false , 0 , kControlBehaviorToggles , 1, Rect bounds = wxMacGetBoundsForControl( this , pos , size ) ;
m_macControl = (WXWidget) ::NewControl( MAC_WXHWND(parent->MacGetTopLevelWindowRef()) , &bounds , "\p" , true , 0 , kControlBehaviorToggles , 1,
kControlBevelButtonNormalBevelProc , (long) this ) ; kControlBevelButtonNormalBevelProc , (long) this ) ;
wxASSERT_MSG( (ControlHandle) m_macControl != NULL , wxT("No valid mac control") ) ; wxASSERT_MSG( (ControlRef) m_macControl != NULL , wxT("No valid mac control") ) ;
MacPostControlCreate() ; MacPostControlCreate(pos,size) ;
return TRUE; return TRUE;
} }
@@ -88,22 +82,17 @@ wxSize wxToggleButton::DoGetBestSize() const
if (lBtn > wBtn) if (lBtn > wBtn)
wBtn = lBtn; wBtn = lBtn;
if ( UMAHasAquaLayout() )
{
wBtn += 2 * kMacOSXHorizontalBorder ;
hBtn += 2 * kMacOSXVerticalBorder ;
}
return wxSize ( wBtn , hBtn ) ; return wxSize ( wBtn , hBtn ) ;
} }
void wxToggleButton::SetValue(bool val) void wxToggleButton::SetValue(bool val)
{ {
::SetControl32BitValue( (ControlHandle) m_macControl , val ) ; ::SetControl32BitValue( (ControlRef) m_macControl , val ) ;
} }
bool wxToggleButton::GetValue() const bool wxToggleButton::GetValue() const
{ {
return GetControl32BitValue( (ControlHandle) m_macControl ) ; return GetControl32BitValue( (ControlRef) m_macControl ) ;
} }
void wxToggleButton::Command(wxCommandEvent & event) void wxToggleButton::Command(wxCommandEvent & event)

View File

@@ -114,11 +114,7 @@ bool wxTimer::Start(int milliseconds,bool mode)
wxCHECK_MSG( m_milli > 0, FALSE, wxT("invalid value for timer timeout") ); wxCHECK_MSG( m_milli > 0, FALSE, wxT("invalid value for timer timeout") );
wxCHECK_MSG( m_info->m_task.tmAddr == NULL , FALSE, wxT("attempting to restart a timer") ); wxCHECK_MSG( m_info->m_task.tmAddr == NULL , FALSE, wxT("attempting to restart a timer") );
#if defined(UNIVERSAL_INTERFACES_VERSION) && (UNIVERSAL_INTERFACES_VERSION >= 0x0340)
m_info->m_task.tmAddr = NewTimerUPP( MacTimerProc ) ; m_info->m_task.tmAddr = NewTimerUPP( MacTimerProc ) ;
#else
m_info->m_task.tmAddr = NewTimerProc( MacTimerProc ) ;
#endif
m_info->m_task.tmWakeUp = 0 ; m_info->m_task.tmWakeUp = 0 ;
m_info->m_task.tmReserved = 0 ; m_info->m_task.tmReserved = 0 ;
m_info->m_task.qType = 0 ; m_info->m_task.qType = 0 ;

View File

@@ -62,8 +62,8 @@ public:
DisposeControl( m_controlHandle ) ; DisposeControl( m_controlHandle ) ;
} }
ControlHandle GetControlHandle() { return m_controlHandle ; } WXWidget GetControlHandle() { return (WXWidget) m_controlHandle ; }
void SetControlHandle( ControlHandle handle ) { m_controlHandle = handle ; } void SetControlHandle( ControlRef handle ) { m_controlHandle = handle ; }
void SetSize(const wxSize& size) ; void SetSize(const wxSize& size) ;
void SetPosition( const wxPoint& position ) ; void SetPosition( const wxPoint& position ) ;
@@ -94,12 +94,64 @@ private :
{ {
m_controlHandle = NULL ; m_controlHandle = NULL ;
} }
ControlHandle m_controlHandle ; ControlRef m_controlHandle ;
wxCoord m_x; wxCoord m_x;
wxCoord m_y; wxCoord m_y;
}; };
static const EventTypeSpec eventList[] =
{
{ kEventClassControl , kEventControlHit } ,
} ;
static pascal OSStatus wxMacToolBarToolControlEventHandler( EventHandlerCallRef handler , EventRef event , void *data )
{
OSStatus result = eventNotHandledErr ;
wxMacCarbonEvent cEvent( event ) ;
ControlRef controlRef ;
cEvent.GetParameter( kEventParamDirectObject , &controlRef ) ;
switch( GetEventKind( event ) )
{
case kEventControlHit :
{
wxToolBarTool* tbartool = (wxToolBarTool*)data ;
if ( tbartool->CanBeToggled() )
{
tbartool->Toggle( GetControl32BitValue( (ControlRef) tbartool->GetControlHandle() ) ) ;
}
((wxToolBar*)tbartool->GetToolBar())->OnLeftClick( tbartool->GetId() , tbartool -> IsToggled() ) ;
result = noErr;
}
break ;
default :
break ;
}
return result ;
}
pascal OSStatus wxMacToolBarToolEventHandler( EventHandlerCallRef handler , EventRef event , void *data )
{
OSStatus result = eventNotHandledErr ;
switch ( GetEventClass( event ) )
{
case kEventClassControl :
result = wxMacToolBarToolControlEventHandler( handler, event, data ) ;
break ;
default :
break ;
}
return result ;
}
DEFINE_ONE_SHOT_HANDLER_GETTER( wxMacToolBarToolEventHandler )
// ============================================================================ // ============================================================================
// implementation // implementation
// ============================================================================ // ============================================================================
@@ -125,12 +177,14 @@ void wxToolBarTool::SetPosition(const wxPoint& position)
{ {
int x , y ; int x , y ;
x = y = 0 ; x = y = 0 ;
WindowRef rootwindow = (WindowRef) GetToolBar()->MacGetRootWindow() ; int mac_x = position.x ;
int mac_y = position.y ;
#if !TARGET_API_MAC_OSX
WindowRef rootwindow = (WindowRef) GetToolBar()->MacGetTopLevelWindowRef() ;
GetToolBar()->MacWindowToRootWindow( &x , &y ) ; GetToolBar()->MacWindowToRootWindow( &x , &y ) ;
int mac_x = x + position.x ; mac_x += x;
int mac_y = y + position.y ; mac_y += y;
#endif
Rect contrlRect ; Rect contrlRect ;
GetControlBounds( m_controlHandle , &contrlRect ) ; GetControlBounds( m_controlHandle , &contrlRect ) ;
int former_mac_x = contrlRect.left ; int former_mac_x = contrlRect.left ;
@@ -139,15 +193,7 @@ void wxToolBarTool::SetPosition(const wxPoint& position)
if ( mac_x != former_mac_x || mac_y != former_mac_y ) if ( mac_x != former_mac_x || mac_y != former_mac_y )
{ {
{
Rect inval = { former_mac_y , former_mac_x , former_mac_y + sz.y , former_mac_x + sz.x } ;
InvalWindowRect( rootwindow , &inval ) ;
}
UMAMoveControl( m_controlHandle , mac_x , mac_y ) ; UMAMoveControl( m_controlHandle , mac_x , mac_y ) ;
{
Rect inval = { mac_y , mac_x , mac_y + sz.y , mac_x + sz.x } ;
InvalWindowRect( rootwindow , &inval ) ;
}
} }
} }
else if ( IsControl() ) else if ( IsControl() )
@@ -177,7 +223,7 @@ wxToolBarTool::wxToolBarTool(wxToolBar *tbar,
if (id == wxID_SEPARATOR) return; if (id == wxID_SEPARATOR) return;
WindowRef window = (WindowRef) tbar->MacGetRootWindow() ; WindowRef window = (WindowRef) tbar->MacGetTopLevelWindowRef() ;
wxSize toolSize = tbar->GetToolSize() ; wxSize toolSize = tbar->GetToolSize() ;
Rect toolrect = { 0, 0 , toolSize.y , toolSize.x } ; Rect toolrect = { 0, 0 , toolSize.y , toolSize.x } ;
@@ -190,16 +236,18 @@ wxToolBarTool::wxToolBarTool(wxToolBar *tbar,
if ( info.contentType != kControlNoContent ) if ( info.contentType != kControlNoContent )
{ {
m_controlHandle = ::NewControl( window , &toolrect , "\p" , false , 0 , m_controlHandle = ::NewControl( window , &toolrect , "\p" , true , 0 ,
behaviour + info.contentType , 0 , kControlBevelButtonNormalBevelProc , (long) this ) ; behaviour + info.contentType , 0 , kControlBevelButtonNormalBevelProc , (long) this ) ;
::SetControlData( m_controlHandle , kControlButtonPart , kControlBevelButtonContentTag , sizeof(info) , (char*) &info ) ; ::SetControlData( m_controlHandle , kControlButtonPart , kControlBevelButtonContentTag , sizeof(info) , (char*) &info ) ;
} }
else else
{ {
m_controlHandle = ::NewControl( window , &toolrect , "\p" , false , 0 , m_controlHandle = ::NewControl( window , &toolrect , "\p" , true , 0 ,
behaviour , 0 , kControlBevelButtonNormalBevelProc , (long) this ) ; behaviour , 0 , kControlBevelButtonNormalBevelProc , (long) this ) ;
} }
InstallControlEventHandler( (ControlRef) m_controlHandle, GetwxMacToolBarToolEventHandlerUPP(),
GetEventTypeCount(eventList), eventList, this,NULL);
UMAShowControl( m_controlHandle ) ; UMAShowControl( m_controlHandle ) ;
if ( !IsEnabled() ) if ( !IsEnabled() )
{ {
@@ -214,7 +262,7 @@ wxToolBarTool::wxToolBarTool(wxToolBar *tbar,
::SetControl32BitValue( m_controlHandle , 0 ) ; ::SetControl32BitValue( m_controlHandle , 0 ) ;
} }
ControlHandle container = (ControlHandle) tbar->MacGetContainerForEmbedding() ; ControlRef container = (ControlRef) tbar->GetHandle() ;
wxASSERT_MSG( container != NULL , wxT("No valid mac container control") ) ; wxASSERT_MSG( container != NULL , wxT("No valid mac container control") ) ;
::EmbedControl( m_controlHandle , container ) ; ::EmbedControl( m_controlHandle , container ) ;
} }
@@ -249,42 +297,8 @@ void wxToolBar::Init()
bool wxToolBar::Create(wxWindow *parent, wxWindowID id, const wxPoint& pos, const wxSize& size, bool wxToolBar::Create(wxWindow *parent, wxWindowID id, const wxPoint& pos, const wxSize& size,
long style, const wxString& name) long style, const wxString& name)
{ {
int x = pos.x; if ( !wxToolBarBase::Create( parent , id , pos , size , style ) )
int y = pos.y; return FALSE ;
int width = size.x;
int height = size.y;
if (width <= 0)
width = 100;
if (height <= 0)
height = 30;
if (x < 0)
x = 0;
if (y < 0)
y = 0;
SetName(name);
m_windowStyle = style;
parent->AddChild(this);
m_backgroundColour = parent->GetBackgroundColour() ;
m_foregroundColour = parent->GetForegroundColour() ;
if (id == -1)
m_windowId = NewControlId();
else
m_windowId = id;
{
m_width = size.x ;
m_height = size.y ;
int x = pos.x ;
int y = pos.y ;
AdjustForParentClientOrigin(x, y, wxSIZE_USE_EXISTING);
m_x = x ;
m_y = y ;
}
return TRUE; return TRUE;
} }
@@ -376,7 +390,7 @@ bool wxToolBar::Realize()
m_maxWidth = maxWidth ; m_maxWidth = maxWidth ;
} }
SetSize(maxWidth, maxHeight); SetSize( maxWidth, maxHeight );
return TRUE; return TRUE;
} }
@@ -404,7 +418,7 @@ void wxToolBar::MacHandleControlClick( WXWidget control , wxInt16 controlpart ,
{ {
if ( tool->CanBeToggled() ) if ( tool->CanBeToggled() )
{ {
tool->Toggle( GetControl32BitValue( (ControlHandle) control ) ) ; tool->Toggle( GetControl32BitValue( (ControlRef) control ) ) ;
} }
OnLeftClick( tool->GetId() , tool -> IsToggled() ) ; OnLeftClick( tool->GetId() , tool -> IsToggled() ) ;
break ; break ;
@@ -471,9 +485,9 @@ void wxToolBar::DoEnableTool(wxToolBarToolBase *t, bool enable)
else if ( tool->IsButton() ) else if ( tool->IsButton() )
{ {
if ( enable ) if ( enable )
UMAActivateControl( tool->GetControlHandle() ) ; UMAActivateControl( (ControlRef) tool->GetControlHandle() ) ;
else else
UMADeactivateControl( tool->GetControlHandle() ) ; UMADeactivateControl( (ControlRef) tool->GetControlHandle() ) ;
} }
} }
@@ -485,7 +499,7 @@ void wxToolBar::DoToggleTool(wxToolBarToolBase *t, bool toggle)
wxToolBarTool *tool = (wxToolBarTool *)t; wxToolBarTool *tool = (wxToolBarTool *)t;
if ( tool->IsButton() ) if ( tool->IsButton() )
{ {
::SetControl32BitValue( tool->GetControlHandle() , toggle ) ; ::SetControl32BitValue( (ControlRef) tool->GetControlHandle() , toggle ) ;
} }
} }
@@ -547,10 +561,19 @@ void wxToolBar::OnPaint(wxPaintEvent& event)
{ {
wxPaintDC dc(this) ; wxPaintDC dc(this) ;
wxMacPortSetter helper(&dc) ; wxMacPortSetter helper(&dc) ;
int w, h ;
GetSize( &w , &h ) ;
Rect toolbarrect = { dc.YLOG2DEVMAC(0) , dc.XLOG2DEVMAC(0) , Rect toolbarrect = { dc.YLOG2DEVMAC(0) , dc.XLOG2DEVMAC(0) ,
dc.YLOG2DEVMAC(m_height) , dc.XLOG2DEVMAC(m_width) } ; dc.YLOG2DEVMAC(h) , dc.XLOG2DEVMAC(w) } ;
/*
if( toolbarrect.left < 0 )
toolbarrect.left = 0 ;
if ( toolbarrect.top < 0 )
toolbarrect.top = 0 ;
*/
UMADrawThemePlacard( &toolbarrect , IsEnabled() ? kThemeStateActive : kThemeStateInactive) ; UMADrawThemePlacard( &toolbarrect , IsEnabled() ? kThemeStateActive : kThemeStateInactive) ;
/*
{ {
wxToolBarToolsList::Node *node; wxToolBarToolsList::Node *node;
for ( node = m_tools.GetFirst(); node; node = node->GetNext() ) for ( node = m_tools.GetFirst(); node; node = node->GetNext() )
@@ -558,10 +581,12 @@ void wxToolBar::OnPaint(wxPaintEvent& event)
wxToolBarTool* tool = (wxToolBarTool*) node->GetData() ; wxToolBarTool* tool = (wxToolBarTool*) node->GetData() ;
if ( tool->IsButton() ) if ( tool->IsButton() )
{ {
UMADrawControl( tool->GetControlHandle() ) ; UMADrawControl( (ControlRef) tool->GetControlHandle() ) ;
} }
} }
} }
*/
event.Skip() ;
} }
void wxToolBar::OnMouse( wxMouseEvent &event ) void wxToolBar::OnMouse( wxMouseEvent &event )
@@ -574,10 +599,10 @@ void wxToolBar::OnMouse( wxMouseEvent &event )
MacClientToRootWindow( &x , &y ) ; MacClientToRootWindow( &x , &y ) ;
ControlHandle control ; ControlRef control ;
Point localwhere ; Point localwhere ;
SInt16 controlpart ; SInt16 controlpart ;
WindowRef window = (WindowRef) MacGetRootWindow() ; WindowRef window = (WindowRef) MacGetTopLevelWindowRef() ;
localwhere.h = x ; localwhere.h = x ;
localwhere.v = y ; localwhere.v = y ;
@@ -608,7 +633,7 @@ void wxToolBar::OnMouse( wxMouseEvent &event )
wxTheApp->s_lastMouseDown = 0 ; wxTheApp->s_lastMouseDown = 0 ;
if ( control && controlpart != kControlNoPart ) // otherwise we will get the event twice if ( control && controlpart != kControlNoPart ) // otherwise we will get the event twice
{ {
MacHandleControlClick( control , controlpart , false /* not down anymore */ ) ; MacHandleControlClick((WXWidget) control , controlpart , false /* not down anymore */ ) ;
} }
} }
} }

View File

@@ -154,7 +154,7 @@ void wxToolTip::RelayEvent( wxWindow *win , wxMouseEvent &event )
s_ToolTipArea = wxRect2DInt( event.m_x - 2 , event.m_y - 2 , 4 , 4 ) ; s_ToolTipArea = wxRect2DInt( event.m_x - 2 , event.m_y - 2 , 4 , 4 ) ;
s_LastWindowEntered = win ; s_LastWindowEntered = win ;
WindowRef window = MAC_WXHWND( win->MacGetRootWindow() ) ; WindowRef window = MAC_WXHWND( win->MacGetTopLevelWindowRef() ) ;
int x = event.m_x ; int x = event.m_x ;
int y = event.m_y ; int y = event.m_y ;
wxPoint local( x , y ) ; wxPoint local( x , y ) ;

File diff suppressed because it is too large Load Diff

View File

@@ -165,21 +165,13 @@ void UMAInitToolbox( UInt16 inMoreMastersCalls, bool isEmbedded )
} ; } ;
int noOfFontDescriptions = sizeof( fontDescriptions ) / sizeof(TXNMacOSPreferredFontDescription) ; int noOfFontDescriptions = sizeof( fontDescriptions ) / sizeof(TXNMacOSPreferredFontDescription) ;
// kTXNAlwaysUseQuickDrawTextMask might be desirable because of speed increases but it crashes the app under OS X upon key stroke
#if 0
// leads to unexpected content for clients, TODO configurable
OptionBits options = kTXNWantMoviesMask | kTXNWantSoundMask | kTXNWantGraphicsMask ;
#else
OptionBits options = 0 ; OptionBits options = 0 ;
#endif
#if TARGET_CARBON if ( UMAGetSystemVersion() < 0x1000 )
if ( !UMAHasAquaLayout() )
#endif
{ {
options |= kTXNAlwaysUseQuickDrawTextMask ; options |= kTXNAlwaysUseQuickDrawTextMask ;
} }
TXNInitTextension(fontDescriptions, noOfFontDescriptions, options ); TXNInitTextension(fontDescriptions, noOfFontDescriptions, options );
} }
@@ -517,7 +509,7 @@ void UMASetWTitle( WindowRef inWindowRef , const wxString& title , wxFontEncodin
// appearance additions // appearance additions
void UMASetControlTitle( ControlHandle inControl , const wxString& title , wxFontEncoding encoding) void UMASetControlTitle( ControlRef inControl , const wxString& title , wxFontEncoding encoding)
{ {
#if TARGET_CARBON #if TARGET_CARBON
SetControlTitleWithCFString( inControl , wxMacCFStringHolder(title , encoding) ) ; SetControlTitleWithCFString( inControl , wxMacCFStringHolder(title , encoding) ) ;
@@ -528,8 +520,9 @@ void UMASetControlTitle( ControlHandle inControl , const wxString& title , wxFon
#endif #endif
} }
void UMAActivateControl( ControlHandle inControl ) void UMAActivateControl( ControlRef inControl )
{ {
#if !TARGET_API_MAC_OSX
// we have to add the control after again to the update rgn // we have to add the control after again to the update rgn
// otherwise updates get lost // otherwise updates get lost
if ( !IsControlActive( inControl ) ) if ( !IsControlActive( inControl ) )
@@ -537,17 +530,24 @@ void UMAActivateControl( ControlHandle inControl )
bool visible = IsControlVisible( inControl ) ; bool visible = IsControlVisible( inControl ) ;
if ( visible ) if ( visible )
SetControlVisibility( inControl , false , false ) ; SetControlVisibility( inControl , false , false ) ;
#endif
::ActivateControl( inControl ) ; ::ActivateControl( inControl ) ;
#if !TARGET_API_MAC_OSX
if ( visible ) { if ( visible ) {
SetControlVisibility( inControl , true , false ) ; SetControlVisibility( inControl , true , false ) ;
Rect ctrlBounds ; Rect ctrlBounds ;
InvalWindowRect(GetControlOwner(inControl),GetControlBounds(inControl,&ctrlBounds) ) ; InvalWindowRect(GetControlOwner(inControl),UMAGetControlBoundsInWindowCoords(inControl,&ctrlBounds) ) ;
} }
} }
#endif
} }
void UMADrawControl( ControlHandle inControl ) void UMADrawControl( ControlRef inControl )
{ {
#if TARGET_API_MAC_CARBON
::Draw1Control( inControl );
#else
WindowRef theWindow = GetControlOwner(inControl) ; WindowRef theWindow = GetControlOwner(inControl) ;
wxMacPortStateHelper help( (GrafPtr) GetWindowPort(theWindow) ) ; wxMacPortStateHelper help( (GrafPtr) GetWindowPort(theWindow) ) ;
RgnHandle updateRgn = NewRgn() ; RgnHandle updateRgn = NewRgn() ;
@@ -558,72 +558,85 @@ void UMADrawControl( ControlHandle inControl )
::DrawControlInCurrentPort( inControl ) ; ::DrawControlInCurrentPort( inControl ) ;
InvalWindowRgn( theWindow, updateRgn) ; InvalWindowRgn( theWindow, updateRgn) ;
DisposeRgn( updateRgn ) ; DisposeRgn( updateRgn ) ;
#endif
} }
void UMAMoveControl( ControlHandle inControl , short x , short y ) void UMAMoveControl( ControlRef inControl , short x , short y )
{ {
#if !TARGET_API_MAC_OSX
bool visible = IsControlVisible( inControl ) ; bool visible = IsControlVisible( inControl ) ;
if ( visible ) { if ( visible ) {
SetControlVisibility( inControl , false , false ) ; SetControlVisibility( inControl , false , false ) ;
Rect ctrlBounds ; Rect ctrlBounds ;
InvalWindowRect(GetControlOwner(inControl),GetControlBounds(inControl,&ctrlBounds) ) ; InvalWindowRect(GetControlOwner(inControl),GetControlBounds(inControl,&ctrlBounds) ) ;
} }
#endif
::MoveControl( inControl , x , y ) ; ::MoveControl( inControl , x , y ) ;
#if !TARGET_API_MAC_OSX
if ( visible ) { if ( visible ) {
SetControlVisibility( inControl , true , false ) ; SetControlVisibility( inControl , true , false ) ;
Rect ctrlBounds ; Rect ctrlBounds ;
InvalWindowRect(GetControlOwner(inControl),GetControlBounds(inControl,&ctrlBounds) ) ; InvalWindowRect(GetControlOwner(inControl),GetControlBounds(inControl,&ctrlBounds) ) ;
} }
#endif
} }
void UMASizeControl( ControlHandle inControl , short x , short y ) void UMASizeControl( ControlRef inControl , short x , short y )
{ {
#if !TARGET_API_MAC_OSX
bool visible = IsControlVisible( inControl ) ; bool visible = IsControlVisible( inControl ) ;
if ( visible ) { if ( visible ) {
SetControlVisibility( inControl , false , false ) ; SetControlVisibility( inControl , false , false ) ;
Rect ctrlBounds ; Rect ctrlBounds ;
InvalWindowRect(GetControlOwner(inControl),GetControlBounds(inControl,&ctrlBounds) ) ; InvalWindowRect(GetControlOwner(inControl),GetControlBounds(inControl,&ctrlBounds) ) ;
} }
#endif
::SizeControl( inControl , x , y ) ; ::SizeControl( inControl , x , y ) ;
#if !TARGET_API_MAC_OSX
if ( visible ) { if ( visible ) {
SetControlVisibility( inControl , true , false ) ; SetControlVisibility( inControl , true , false ) ;
Rect ctrlBounds ; Rect ctrlBounds ;
InvalWindowRect(GetControlOwner(inControl),GetControlBounds(inControl,&ctrlBounds) ) ; InvalWindowRect(GetControlOwner(inControl),GetControlBounds(inControl,&ctrlBounds) ) ;
} }
#endif
} }
void UMADeactivateControl( ControlHandle inControl ) void UMADeactivateControl( ControlRef inControl )
{ {
#if !TARGET_API_MAC_OSX
// we have to add the control after again to the update rgn // we have to add the control after again to the update rgn
// otherwise updates get lost // otherwise updates get lost
bool visible = IsControlVisible( inControl ) ; bool visible = IsControlVisible( inControl ) ;
if ( visible ) if ( visible )
SetControlVisibility( inControl , false , false ) ; SetControlVisibility( inControl , false , false ) ;
#endif
::DeactivateControl( inControl ) ; ::DeactivateControl( inControl ) ;
#if !TARGET_API_MAC_OSX
if ( visible ) { if ( visible ) {
SetControlVisibility( inControl , true , false ) ; SetControlVisibility( inControl , true , false ) ;
Rect ctrlBounds ; Rect ctrlBounds ;
InvalWindowRect(GetControlOwner(inControl),GetControlBounds(inControl,&ctrlBounds) ) ; InvalWindowRect(GetControlOwner(inControl),UMAGetControlBoundsInWindowCoords(inControl,&ctrlBounds) ) ;
} }
#endif
} }
// shows the control and adds the region to the update region // shows the control and adds the region to the update region
void UMAShowControl (ControlHandle inControl) void UMAShowControl (ControlRef inControl)
{ {
SetControlVisibility( inControl , true , false ) ; SetControlVisibility( inControl , true , false ) ;
Rect ctrlBounds ; Rect ctrlBounds ;
InvalWindowRect(GetControlOwner(inControl),GetControlBounds(inControl,&ctrlBounds) ) ; InvalWindowRect(GetControlOwner(inControl),UMAGetControlBoundsInWindowCoords(inControl,&ctrlBounds) ) ;
} }
// shows the control and adds the region to the update region // hides the control and adds the region to the update region
void UMAHideControl (ControlHandle inControl) void UMAHideControl (ControlRef inControl)
{ {
SetControlVisibility( inControl , false , false ) ; SetControlVisibility( inControl , false , false ) ;
Rect ctrlBounds ; Rect ctrlBounds ;
InvalWindowRect(GetControlOwner(inControl),GetControlBounds(inControl,&ctrlBounds) ) ; InvalWindowRect(GetControlOwner(inControl),UMAGetControlBoundsInWindowCoords(inControl,&ctrlBounds) ) ;
} }
// keyboard focus // keyboard focus
OSErr UMASetKeyboardFocus (WindowPtr inWindow, OSErr UMASetKeyboardFocus (WindowPtr inWindow,
ControlHandle inControl, ControlRef inControl,
ControlFocusPart inPart) ControlFocusPart inPart)
{ {
OSErr err = noErr; OSErr err = noErr;
@@ -637,7 +650,6 @@ OSErr UMASetKeyboardFocus (WindowPtr inWindow,
return err ; return err ;
} }
// events // events
void UMAUpdateControls( WindowPtr inWindow , RgnHandle inRgn ) void UMAUpdateControls( WindowPtr inWindow , RgnHandle inRgn )
{ {
@@ -682,7 +694,7 @@ void UMAHighlightAndActivateWindow( WindowRef inWindowRef , bool inActivate )
GetPort( &port ) ; GetPort( &port ) ;
SetPortWindowPort( inWindowRef ) ; SetPortWindowPort( inWindowRef ) ;
HiliteWindow( inWindowRef , inActivate ) ; HiliteWindow( inWindowRef , inActivate ) ;
ControlHandle control = NULL ; ControlRef control = NULL ;
::GetRootControl( inWindowRef , & control ) ; ::GetRootControl( inWindowRef , & control ) ;
if ( control ) if ( control )
{ {
@@ -795,6 +807,29 @@ OSStatus UMAPutScrap( Size size , OSType type , void *data )
return err ; return err ;
} }
Rect* UMAGetControlBoundsInWindowCoords(ControlRef theControl, Rect *bounds)
{
wxWindow* win = wxFindControlFromMacControl( theControl ) ;
GetControlBounds( theControl , bounds ) ;
#if TARGET_API_MAC_OSX
if ( win != NULL && win->MacGetTopLevelWindow() != NULL )
{
int x , y ;
x = 0 ;
y = 0 ;
win->GetParent()->MacWindowToRootWindow( &x , & y ) ;
bounds->left += x ;
bounds->right += x ;
bounds->top += y ;
bounds->bottom += y ;
}
#endif
return bounds ;
}
#endif // wxUSE_GUI #endif // wxUSE_GUI
#if wxUSE_BASE #if wxUSE_BASE

View File

@@ -456,7 +456,6 @@ void wxDisplaySizeMM(int *width, int *height)
void wxClientDisplayRect(int *x, int *y, int *width, int *height) void wxClientDisplayRect(int *x, int *y, int *width, int *height)
{ {
#if TARGET_CARBON
Rect r ; Rect r ;
GetAvailableWindowPositioningBounds( GetMainDevice() , &r ) ; GetAvailableWindowPositioningBounds( GetMainDevice() , &r ) ;
if ( x ) if ( x )
@@ -467,32 +466,6 @@ void wxClientDisplayRect(int *x, int *y, int *width, int *height)
*width = r.right - r.left ; *width = r.right - r.left ;
if ( height ) if ( height )
*height = r.bottom - r.top ; *height = r.bottom - r.top ;
#else
BitMap screenBits;
GetQDGlobalsScreenBits( &screenBits );
if (x) *x = 0;
if (y) *y = 0;
if (width != NULL) {
*width = screenBits.bounds.right - screenBits.bounds.left ;
}
if (height != NULL) {
*height = screenBits.bounds.bottom - screenBits.bounds.top ;
}
SInt16 mheight ;
#if TARGET_CARBON
GetThemeMenuBarHeight( &mheight ) ;
#else
mheight = LMGetMBarHeight() ;
#endif
if (height != NULL) {
*height -= mheight ;
}
if (y)
*y = mheight ;
#endif
} }
wxWindow* wxFindWindowAtPoint(const wxPoint& pt) wxWindow* wxFindWindowAtPoint(const wxPoint& pt)
@@ -560,6 +533,15 @@ bool wxGetDiskSpace(const wxString& path, wxLongLong *pTotal, wxLongLong *pFree)
// wxMac Specific utility functions // wxMac Specific utility functions
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
Rect wxMacGetBoundsForControl( wxWindow* window , const wxPoint& pos , const wxSize &size )
{
int x ,y , w ,h ;
window->MacGetBoundsForControl( pos , size , x , y, w, h ) ;
Rect bounds = { y , x , y+h , x+w };
return bounds ;
}
void wxMacStringToPascal( const wxString&from , StringPtr to ) void wxMacStringToPascal( const wxString&from , StringPtr to )
{ {
wxCharBuffer buf = from.mb_str( wxConvLocal ) ; wxCharBuffer buf = from.mb_str( wxConvLocal ) ;
@@ -1251,6 +1233,21 @@ void wxMacConvertNewlines10To13( wxChar * data )
} }
#endif #endif
// ----------------------------------------------------------------------------
// Carbon Event Support
// ----------------------------------------------------------------------------
OSStatus wxMacCarbonEvent::GetParameter(EventParamName inName, EventParamType inDesiredType, UInt32 inBufferSize, void * outData)
{
return ::GetEventParameter( m_eventRef , inName , inDesiredType , NULL , inBufferSize , NULL , outData ) ;
}
OSStatus wxMacCarbonEvent::SetParameter(EventParamName inName, EventParamType inType, UInt32 inBufferSize, void * inData)
{
return ::SetEventParameter( m_eventRef , inName , inType , inBufferSize , inData ) ;
}
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// debugging support // debugging support
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------

File diff suppressed because it is too large Load Diff

View File

@@ -87,7 +87,7 @@ void _GSocket_GUI_Cleanup(void)
int _GSocket_GUI_Init_Socket(GSocket *socket) int _GSocket_GUI_Init_Socket(GSocket *socket)
{ {
struct MacGSocketData *data = (struct MacGSocketData *) malloc(sizeof(struct MacGSocketData)); struct MacGSocketData *data = (struct MacGSocketData *)malloc(sizeof(struct MacGSocketData));
if (data) if (data)
{ {
socket->m_gui_dependent = (char*)data; socket->m_gui_dependent = (char*)data;