The validator is already set in CreateBase, doing it twice causes
problems for wxPython git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_4_BRANCH@18989 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -35,9 +35,9 @@
|
|||||||
IMPLEMENT_ABSTRACT_CLASS(wxControl, wxWindow)
|
IMPLEMENT_ABSTRACT_CLASS(wxControl, wxWindow)
|
||||||
|
|
||||||
BEGIN_EVENT_TABLE(wxControl, wxWindow)
|
BEGIN_EVENT_TABLE(wxControl, wxWindow)
|
||||||
EVT_MOUSE_EVENTS( wxControl::OnMouseEvent )
|
EVT_MOUSE_EVENTS( wxControl::OnMouseEvent )
|
||||||
// EVT_CHAR( wxControl::OnKeyDown )
|
// EVT_CHAR( wxControl::OnKeyDown )
|
||||||
EVT_PAINT( wxControl::OnPaint )
|
EVT_PAINT( wxControl::OnPaint )
|
||||||
END_EVENT_TABLE()
|
END_EVENT_TABLE()
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -89,7 +89,7 @@ ControlDefUPP wxMacControlActionUPP = NULL ;
|
|||||||
|
|
||||||
pascal SInt32 wxMacControlDefintion(SInt16 varCode, ControlRef theControl, ControlDefProcMessage message, SInt32 param)
|
pascal SInt32 wxMacControlDefintion(SInt16 varCode, ControlRef theControl, ControlDefProcMessage message, SInt32 param)
|
||||||
{
|
{
|
||||||
|
|
||||||
wxControl* wx = (wxControl*) wxFindControlFromMacControl( theControl ) ;
|
wxControl* wx = (wxControl*) wxFindControlFromMacControl( theControl ) ;
|
||||||
if ( wx != NULL && wx->IsKindOf( CLASSINFO( wxControl ) ) )
|
if ( wx != NULL && wx->IsKindOf( CLASSINFO( wxControl ) ) )
|
||||||
{
|
{
|
||||||
@@ -129,7 +129,7 @@ pascal OSStatus wxMacSetupControlBackground( ControlRef iControl , SInt16 iMessa
|
|||||||
}
|
}
|
||||||
return status ;
|
return status ;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxControl::wxControl()
|
wxControl::wxControl()
|
||||||
{
|
{
|
||||||
m_macControl = NULL ;
|
m_macControl = NULL ;
|
||||||
@@ -161,7 +161,7 @@ bool wxControl::Create(wxWindow *parent, wxWindowID id,
|
|||||||
m_macControl = NULL ;
|
m_macControl = NULL ;
|
||||||
m_macHorizontalBorder = 0 ; // additional pixels around the real control
|
m_macHorizontalBorder = 0 ; // additional pixels around the real control
|
||||||
m_macVerticalBorder = 0 ;
|
m_macVerticalBorder = 0 ;
|
||||||
|
|
||||||
bool rval = wxWindow::Create(parent, id, pos, size, style, name);
|
bool rval = wxWindow::Create(parent, id, pos, size, style, name);
|
||||||
if ( parent )
|
if ( parent )
|
||||||
{
|
{
|
||||||
@@ -203,12 +203,12 @@ void wxControl::SetLabel(const wxString& title)
|
|||||||
{
|
{
|
||||||
Str255 maclabel ;
|
Str255 maclabel ;
|
||||||
wxString label ;
|
wxString label ;
|
||||||
|
|
||||||
if( wxApp::s_macDefaultEncodingIsPC )
|
if( wxApp::s_macDefaultEncodingIsPC )
|
||||||
label = wxMacMakeMacStringFromPC( m_label ) ;
|
label = wxMacMakeMacStringFromPC( m_label ) ;
|
||||||
else
|
else
|
||||||
label = m_label ;
|
label = m_label ;
|
||||||
|
|
||||||
#if TARGET_CARBON
|
#if TARGET_CARBON
|
||||||
c2pstrcpy( (StringPtr) maclabel , label ) ;
|
c2pstrcpy( (StringPtr) maclabel , label ) ;
|
||||||
#else
|
#else
|
||||||
@@ -239,7 +239,7 @@ wxSize wxControl::DoGetBestSize() const
|
|||||||
}
|
}
|
||||||
else if ( IsKindOf( CLASSINFO( wxSpinButton ) ) )
|
else if ( IsKindOf( CLASSINFO( wxSpinButton ) ) )
|
||||||
{
|
{
|
||||||
bestsize.bottom = 24 ;
|
bestsize.bottom = 24 ;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -255,7 +255,7 @@ wxSize wxControl::DoGetBestSize() const
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
bestWidth = bestsize.right - bestsize.left ;
|
bestWidth = bestsize.right - bestsize.left ;
|
||||||
|
|
||||||
bestWidth += 2 * m_macHorizontalBorder ;
|
bestWidth += 2 * m_macHorizontalBorder ;
|
||||||
|
|
||||||
bestHeight = bestsize.bottom - bestsize.top ;
|
bestHeight = bestsize.bottom - bestsize.top ;
|
||||||
@@ -264,7 +264,7 @@ wxSize wxControl::DoGetBestSize() const
|
|||||||
|
|
||||||
bestHeight += 2 * m_macVerticalBorder;
|
bestHeight += 2 * m_macVerticalBorder;
|
||||||
|
|
||||||
|
|
||||||
return wxSize(bestWidth, bestHeight);
|
return wxSize(bestWidth, bestHeight);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -313,16 +313,14 @@ void wxRemoveMacControlAssociation(wxControl *control)
|
|||||||
wxWinMacControlList->DeleteObject(control);
|
wxWinMacControlList->DeleteObject(control);
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxControl::MacPreControlCreate( wxWindow *parent, wxWindowID id, wxString label ,
|
void wxControl::MacPreControlCreate( wxWindow *parent, wxWindowID id, 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 , WXRECTPTR outBounds , unsigned char* maclabel )
|
const wxString& name , WXRECTPTR outBounds , unsigned char* maclabel )
|
||||||
{
|
{
|
||||||
m_label = label ;
|
m_label = label ;
|
||||||
SetName(name);
|
SetName(name);
|
||||||
if ( &validator )
|
|
||||||
SetValidator(validator);
|
|
||||||
|
|
||||||
m_windowStyle = style;
|
m_windowStyle = style;
|
||||||
parent->AddChild(this);
|
parent->AddChild(this);
|
||||||
@@ -341,7 +339,7 @@ void wxControl::MacPreControlCreate( wxWindow *parent, wxWindowID id, wxString l
|
|||||||
m_height = size.y ;
|
m_height = size.y ;
|
||||||
m_x = pos.x ;
|
m_x = pos.x ;
|
||||||
m_y = pos.y ;
|
m_y = pos.y ;
|
||||||
|
|
||||||
((Rect*)outBounds)->top = -10;
|
((Rect*)outBounds)->top = -10;
|
||||||
((Rect*)outBounds)->left = -10;
|
((Rect*)outBounds)->left = -10;
|
||||||
((Rect*)outBounds)->bottom = 0;
|
((Rect*)outBounds)->bottom = 0;
|
||||||
@@ -365,7 +363,7 @@ void wxControl::MacPreControlCreate( wxWindow *parent, wxWindowID id, wxString l
|
|||||||
void wxControl::MacPostControlCreate()
|
void wxControl::MacPostControlCreate()
|
||||||
{
|
{
|
||||||
wxASSERT_MSG( (ControlHandle) m_macControl != NULL , "No valid mac control" ) ;
|
wxASSERT_MSG( (ControlHandle) m_macControl != NULL , "No valid mac control" ) ;
|
||||||
|
|
||||||
if ( IsKindOf( CLASSINFO( wxScrollBar ) ) )
|
if ( IsKindOf( CLASSINFO( wxScrollBar ) ) )
|
||||||
{
|
{
|
||||||
// no font
|
// no font
|
||||||
@@ -375,7 +373,7 @@ void wxControl::MacPostControlCreate()
|
|||||||
ControlFontStyleRec controlstyle ;
|
ControlFontStyleRec controlstyle ;
|
||||||
controlstyle.flags = kControlUseFontMask ;
|
controlstyle.flags = kControlUseFontMask ;
|
||||||
controlstyle.font = kControlFontSmallBoldSystemFont ;
|
controlstyle.font = kControlFontSmallBoldSystemFont ;
|
||||||
|
|
||||||
::SetControlFontStyle( (ControlHandle) m_macControl , &controlstyle ) ;
|
::SetControlFontStyle( (ControlHandle) m_macControl , &controlstyle ) ;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -383,7 +381,7 @@ void wxControl::MacPostControlCreate()
|
|||||||
ControlFontStyleRec controlstyle ;
|
ControlFontStyleRec controlstyle ;
|
||||||
controlstyle.flags = kControlUseFontMask ;
|
controlstyle.flags = kControlUseFontMask ;
|
||||||
controlstyle.font = kControlFontSmallSystemFont ;
|
controlstyle.font = kControlFontSmallSystemFont ;
|
||||||
|
|
||||||
::SetControlFontStyle( (ControlHandle) m_macControl , &controlstyle ) ;
|
::SetControlFontStyle( (ControlHandle) m_macControl , &controlstyle ) ;
|
||||||
}
|
}
|
||||||
ControlHandle container = (ControlHandle) GetParent()->MacGetContainerForEmbedding() ;
|
ControlHandle container = (ControlHandle) GetParent()->MacGetContainerForEmbedding() ;
|
||||||
@@ -424,38 +422,38 @@ void wxControl::MacPostControlCreate()
|
|||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
SetControlColorProc( (ControlHandle) m_macControl , wxMacSetupControlBackgroundUPP ) ;
|
SetControlColorProc( (ControlHandle) m_macControl , wxMacSetupControlBackgroundUPP ) ;
|
||||||
|
|
||||||
// Adjust the controls size and position
|
// Adjust the controls size and position
|
||||||
wxPoint pos(m_x, m_y);
|
wxPoint pos(m_x, m_y);
|
||||||
wxSize best_size( DoGetBestSize() );
|
wxSize best_size( DoGetBestSize() );
|
||||||
wxSize new_size( m_width, m_height );
|
wxSize new_size( m_width, m_height );
|
||||||
|
|
||||||
m_x = m_y = m_width = m_height = -1; // Forces SetSize to move/size the control
|
m_x = m_y = m_width = m_height = -1; // Forces SetSize to move/size the control
|
||||||
|
|
||||||
if (new_size.x == -1) {
|
if (new_size.x == -1) {
|
||||||
new_size.x = best_size.x;
|
new_size.x = best_size.x;
|
||||||
}
|
}
|
||||||
if (new_size.y == -1) {
|
if (new_size.y == -1) {
|
||||||
new_size.y = best_size.y;
|
new_size.y = best_size.y;
|
||||||
}
|
}
|
||||||
|
|
||||||
SetSize(pos.x, pos.y, new_size.x, new_size.y);
|
SetSize(pos.x, pos.y, new_size.x, new_size.y);
|
||||||
|
|
||||||
UMAShowControl( (ControlHandle) m_macControl ) ;
|
UMAShowControl( (ControlHandle) m_macControl ) ;
|
||||||
|
|
||||||
SetCursor( *wxSTANDARD_CURSOR ) ;
|
SetCursor( *wxSTANDARD_CURSOR ) ;
|
||||||
|
|
||||||
Refresh() ;
|
Refresh() ;
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxControl::MacAdjustControlRect()
|
void wxControl::MacAdjustControlRect()
|
||||||
{
|
{
|
||||||
wxASSERT_MSG( (ControlHandle) m_macControl != NULL , wxT("No valid mac control") ) ;
|
wxASSERT_MSG( (ControlHandle) m_macControl != NULL , wxT("No valid mac control") ) ;
|
||||||
if ( m_width == -1 || m_height == -1 )
|
if ( m_width == -1 || m_height == -1 )
|
||||||
{
|
{
|
||||||
Rect bestsize = { 0 , 0 , 0 , 0 } ;
|
Rect bestsize = { 0 , 0 , 0 , 0 } ;
|
||||||
short baselineoffset ;
|
short baselineoffset ;
|
||||||
|
|
||||||
::GetBestControlRect( (ControlHandle) m_macControl , &bestsize , &baselineoffset ) ;
|
::GetBestControlRect( (ControlHandle) m_macControl , &bestsize , &baselineoffset ) ;
|
||||||
|
|
||||||
if ( EmptyRect( &bestsize ) )
|
if ( EmptyRect( &bestsize ) )
|
||||||
@@ -470,7 +468,7 @@ void wxControl::MacAdjustControlRect()
|
|||||||
}
|
}
|
||||||
else if ( IsKindOf( CLASSINFO( wxSpinButton ) ) )
|
else if ( IsKindOf( CLASSINFO( wxSpinButton ) ) )
|
||||||
{
|
{
|
||||||
bestsize.bottom = 24 ;
|
bestsize.bottom = 24 ;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -488,7 +486,7 @@ void wxControl::MacAdjustControlRect()
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
m_width = bestsize.right - bestsize.left ;
|
m_width = bestsize.right - bestsize.left ;
|
||||||
|
|
||||||
m_width += 2 * m_macHorizontalBorder + MacGetLeftBorderSize() + MacGetRightBorderSize() ;
|
m_width += 2 * m_macHorizontalBorder + MacGetLeftBorderSize() + MacGetRightBorderSize() ;
|
||||||
}
|
}
|
||||||
if ( m_height == -1 )
|
if ( m_height == -1 )
|
||||||
@@ -499,12 +497,12 @@ void wxControl::MacAdjustControlRect()
|
|||||||
|
|
||||||
m_height += 2 * m_macVerticalBorder + MacGetTopBorderSize() + MacGetBottomBorderSize() ;
|
m_height += 2 * m_macVerticalBorder + MacGetTopBorderSize() + MacGetBottomBorderSize() ;
|
||||||
}
|
}
|
||||||
MacUpdateDimensions() ;
|
MacUpdateDimensions() ;
|
||||||
// UMASizeControl( (ControlHandle) m_macControl , m_width - 2 * m_macHorizontalBorder, m_height - 2 * m_macVerticalBorder ) ;
|
// UMASizeControl( (ControlHandle) m_macControl , m_width - 2 * m_macHorizontalBorder, m_height - 2 * m_macVerticalBorder ) ;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
WXWidget wxControl::MacGetContainerForEmbedding()
|
WXWidget wxControl::MacGetContainerForEmbedding()
|
||||||
{
|
{
|
||||||
if ( m_macControl )
|
if ( m_macControl )
|
||||||
return m_macControl ;
|
return m_macControl ;
|
||||||
@@ -512,29 +510,29 @@ WXWidget wxControl::MacGetContainerForEmbedding()
|
|||||||
return wxWindow::MacGetContainerForEmbedding() ;
|
return wxWindow::MacGetContainerForEmbedding() ;
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxControl::MacUpdateDimensions()
|
void wxControl::MacUpdateDimensions()
|
||||||
{
|
{
|
||||||
// actually in the current systems this should never be possible, but later reparenting
|
// actually in the current systems this should never be possible, but later reparenting
|
||||||
// may become a reality
|
// may become a reality
|
||||||
|
|
||||||
if ( (ControlHandle) m_macControl == NULL )
|
if ( (ControlHandle) m_macControl == NULL )
|
||||||
return ;
|
return ;
|
||||||
|
|
||||||
if ( GetParent() == NULL )
|
if ( GetParent() == NULL )
|
||||||
return ;
|
return ;
|
||||||
|
|
||||||
WindowRef rootwindow = (WindowRef) MacGetRootWindow() ;
|
WindowRef rootwindow = (WindowRef) MacGetRootWindow() ;
|
||||||
if ( rootwindow == NULL )
|
if ( rootwindow == NULL )
|
||||||
return ;
|
return ;
|
||||||
|
|
||||||
Rect oldBounds ;
|
Rect oldBounds ;
|
||||||
GetControlBounds( (ControlHandle) m_macControl , &oldBounds ) ;
|
GetControlBounds( (ControlHandle) m_macControl , &oldBounds ) ;
|
||||||
|
|
||||||
int new_x = m_x + MacGetLeftBorderSize() + m_macHorizontalBorder ;
|
int new_x = m_x + MacGetLeftBorderSize() + m_macHorizontalBorder ;
|
||||||
int new_y = m_y + MacGetTopBorderSize() + m_macVerticalBorder ;
|
int new_y = m_y + MacGetTopBorderSize() + m_macVerticalBorder ;
|
||||||
int new_width = m_width - MacGetLeftBorderSize() - MacGetRightBorderSize() - 2 * m_macHorizontalBorder ;
|
int new_width = m_width - MacGetLeftBorderSize() - MacGetRightBorderSize() - 2 * m_macHorizontalBorder ;
|
||||||
int new_height = m_height - MacGetTopBorderSize() - MacGetBottomBorderSize() - 2 * m_macVerticalBorder ;
|
int new_height = m_height - MacGetTopBorderSize() - MacGetBottomBorderSize() - 2 * m_macVerticalBorder ;
|
||||||
|
|
||||||
GetParent()->MacWindowToRootWindow( & new_x , & new_y ) ;
|
GetParent()->MacWindowToRootWindow( & new_x , & new_y ) ;
|
||||||
bool doMove = new_x != oldBounds.left || new_y != oldBounds.top ;
|
bool doMove = new_x != oldBounds.left || new_y != oldBounds.top ;
|
||||||
bool doResize = ( oldBounds.right - oldBounds.left ) != new_width || (oldBounds.bottom - oldBounds.top ) != new_height ;
|
bool doResize = ( oldBounds.right - oldBounds.left ) != new_width || (oldBounds.bottom - oldBounds.top ) != new_height ;
|
||||||
@@ -552,19 +550,19 @@ void wxControl::MacUpdateDimensions()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxControl::MacSuperChangedPosition()
|
void wxControl::MacSuperChangedPosition()
|
||||||
{
|
{
|
||||||
MacUpdateDimensions() ;
|
MacUpdateDimensions() ;
|
||||||
wxWindow::MacSuperChangedPosition() ;
|
wxWindow::MacSuperChangedPosition() ;
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxControl::MacSuperEnabled( bool enabled )
|
void wxControl::MacSuperEnabled( bool enabled )
|
||||||
{
|
{
|
||||||
Refresh(FALSE) ;
|
Refresh(FALSE) ;
|
||||||
wxWindow::MacSuperEnabled( enabled ) ;
|
wxWindow::MacSuperEnabled( enabled ) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxControl::MacSuperShown( bool show )
|
void wxControl::MacSuperShown( bool show )
|
||||||
{
|
{
|
||||||
if ( (ControlHandle) m_macControl )
|
if ( (ControlHandle) m_macControl )
|
||||||
{
|
{
|
||||||
@@ -585,7 +583,7 @@ void wxControl::MacSuperShown( bool show )
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
wxWindow::MacSuperShown( show ) ;
|
wxWindow::MacSuperShown( show ) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -606,12 +604,12 @@ void wxControl::DoSetSize(int x, int y,
|
|||||||
Rect oldbounds;
|
Rect oldbounds;
|
||||||
int new_x, new_y, new_width, new_height;
|
int new_x, new_y, new_width, new_height;
|
||||||
int mac_x, mac_y;
|
int mac_x, mac_y;
|
||||||
|
|
||||||
new_x = m_x;
|
new_x = m_x;
|
||||||
new_y = m_y;
|
new_y = m_y;
|
||||||
new_width = m_width;
|
new_width = m_width;
|
||||||
new_height = m_height;
|
new_height = m_height;
|
||||||
|
|
||||||
if (sizeFlags & wxSIZE_ALLOW_MINUS_ONE)
|
if (sizeFlags & wxSIZE_ALLOW_MINUS_ONE)
|
||||||
{
|
{
|
||||||
new_x = x;
|
new_x = x;
|
||||||
@@ -626,7 +624,7 @@ void wxControl::DoSetSize(int x, int y,
|
|||||||
if (width != -1) new_width = width;
|
if (width != -1) new_width = width;
|
||||||
if (height != -1) new_height = height;
|
if (height != -1) new_height = height;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(sizeFlags & wxSIZE_AUTO)
|
if(sizeFlags & wxSIZE_AUTO)
|
||||||
{
|
{
|
||||||
wxSize size = GetBestSize();
|
wxSize size = GetBestSize();
|
||||||
@@ -640,7 +638,7 @@ void wxControl::DoSetSize(int x, int y,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
AdjustForParentClientOrigin(new_x, new_y, sizeFlags);
|
AdjustForParentClientOrigin(new_x, new_y, sizeFlags);
|
||||||
|
|
||||||
mac_x = new_x;
|
mac_x = new_x;
|
||||||
mac_y = new_y;
|
mac_y = new_y;
|
||||||
if(GetParent()) {
|
if(GetParent()) {
|
||||||
@@ -649,10 +647,10 @@ void wxControl::DoSetSize(int x, int y,
|
|||||||
GetControlBounds( (ControlHandle) m_macControl, &oldbounds);
|
GetControlBounds( (ControlHandle) m_macControl, &oldbounds);
|
||||||
oldbounds.right = oldbounds.left + m_width;
|
oldbounds.right = oldbounds.left + m_width;
|
||||||
oldbounds.bottom = oldbounds.top + m_height;
|
oldbounds.bottom = oldbounds.top + m_height;
|
||||||
|
|
||||||
bool doMove = false;
|
bool doMove = false;
|
||||||
bool doResize = false;
|
bool doResize = false;
|
||||||
|
|
||||||
if ( mac_x != (oldbounds.left - m_macHorizontalBorder) ||
|
if ( mac_x != (oldbounds.left - m_macHorizontalBorder) ||
|
||||||
mac_y != (oldbounds.top - m_macVerticalBorder) )
|
mac_y != (oldbounds.top - m_macVerticalBorder) )
|
||||||
{
|
{
|
||||||
@@ -663,11 +661,11 @@ void wxControl::DoSetSize(int x, int y,
|
|||||||
{
|
{
|
||||||
doResize = true ;
|
doResize = true ;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( doMove || doResize )
|
if ( doMove || doResize )
|
||||||
{
|
{
|
||||||
Refresh() ;
|
Refresh() ;
|
||||||
|
|
||||||
// Ensure resize is within constraints
|
// Ensure resize is within constraints
|
||||||
if ((m_minWidth != -1) && (new_width < m_minWidth)) {
|
if ((m_minWidth != -1) && (new_width < m_minWidth)) {
|
||||||
new_width = m_minWidth;
|
new_width = m_minWidth;
|
||||||
@@ -681,12 +679,12 @@ void wxControl::DoSetSize(int x, int y,
|
|||||||
if ((m_maxHeight != -1) && (new_height > m_maxHeight)) {
|
if ((m_maxHeight != -1) && (new_height > m_maxHeight)) {
|
||||||
new_height = m_maxHeight;
|
new_height = m_maxHeight;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( doMove )
|
if ( doMove )
|
||||||
{
|
{
|
||||||
m_x = new_x;
|
m_x = new_x;
|
||||||
m_y = new_y;
|
m_y = new_y;
|
||||||
|
|
||||||
UMAMoveControl( (ControlHandle) m_macControl,
|
UMAMoveControl( (ControlHandle) m_macControl,
|
||||||
mac_x + m_macHorizontalBorder, mac_y + m_macVerticalBorder);
|
mac_x + m_macHorizontalBorder, mac_y + m_macVerticalBorder);
|
||||||
|
|
||||||
@@ -698,27 +696,27 @@ void wxControl::DoSetSize(int x, int y,
|
|||||||
{
|
{
|
||||||
m_width = new_width;
|
m_width = new_width;
|
||||||
m_height = new_height;
|
m_height = new_height;
|
||||||
|
|
||||||
UMASizeControl( (ControlHandle) m_macControl,
|
UMASizeControl( (ControlHandle) m_macControl,
|
||||||
m_width - 2 * m_macHorizontalBorder,
|
m_width - 2 * m_macHorizontalBorder,
|
||||||
m_height - 2 * m_macVerticalBorder ) ;
|
m_height - 2 * m_macVerticalBorder ) ;
|
||||||
|
|
||||||
|
|
||||||
wxSizeEvent event(wxSize(m_width, m_height), m_windowId);
|
wxSizeEvent event(wxSize(m_width, m_height), m_windowId);
|
||||||
event.SetEventObject(this);
|
event.SetEventObject(this);
|
||||||
GetEventHandler()->ProcessEvent(event);
|
GetEventHandler()->ProcessEvent(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
Refresh() ;
|
Refresh() ;
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxControl::Show(bool show)
|
bool wxControl::Show(bool show)
|
||||||
{
|
{
|
||||||
if ( !wxWindow::Show( show ) )
|
if ( !wxWindow::Show( show ) )
|
||||||
return FALSE ;
|
return FALSE ;
|
||||||
|
|
||||||
if ( (ControlHandle) m_macControl )
|
if ( (ControlHandle) m_macControl )
|
||||||
{
|
{
|
||||||
if ( !show )
|
if ( !show )
|
||||||
@@ -741,7 +739,7 @@ bool wxControl::Show(bool show)
|
|||||||
return TRUE ;
|
return TRUE ;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxControl::Enable(bool enable)
|
bool wxControl::Enable(bool enable)
|
||||||
{
|
{
|
||||||
if ( !wxWindow::Enable(enable) )
|
if ( !wxWindow::Enable(enable) )
|
||||||
return FALSE;
|
return FALSE;
|
||||||
@@ -790,15 +788,15 @@ void wxControl::OnPaint(wxPaintEvent& event)
|
|||||||
}
|
}
|
||||||
void wxControl::OnEraseBackground(wxEraseEvent& event)
|
void wxControl::OnEraseBackground(wxEraseEvent& event)
|
||||||
{
|
{
|
||||||
wxWindow::OnEraseBackground( event ) ;
|
wxWindow::OnEraseBackground( event ) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void wxControl::OnKeyDown( wxKeyEvent &event )
|
void wxControl::OnKeyDown( wxKeyEvent &event )
|
||||||
{
|
{
|
||||||
if ( (ControlHandle) m_macControl == NULL )
|
if ( (ControlHandle) m_macControl == NULL )
|
||||||
return ;
|
return ;
|
||||||
|
|
||||||
EventRecord *ev = (EventRecord*) wxTheApp->MacGetCurrentEvent() ;
|
EventRecord *ev = (EventRecord*) wxTheApp->MacGetCurrentEvent() ;
|
||||||
short keycode ;
|
short keycode ;
|
||||||
short keychar ;
|
short keychar ;
|
||||||
@@ -808,43 +806,43 @@ void wxControl::OnKeyDown( wxKeyEvent &event )
|
|||||||
::HandleControlKey( (ControlHandle) m_macControl , keycode , keychar , ev->modifiers ) ;
|
::HandleControlKey( (ControlHandle) m_macControl , keycode , keychar , ev->modifiers ) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxControl::OnMouseEvent( wxMouseEvent &event )
|
void wxControl::OnMouseEvent( wxMouseEvent &event )
|
||||||
{
|
{
|
||||||
if ( (ControlHandle) m_macControl == NULL )
|
if ( (ControlHandle) m_macControl == NULL )
|
||||||
{
|
{
|
||||||
event.Skip() ;
|
event.Skip() ;
|
||||||
return ;
|
return ;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (event.GetEventType() == wxEVT_LEFT_DOWN || event.GetEventType() == wxEVT_LEFT_DCLICK )
|
if (event.GetEventType() == wxEVT_LEFT_DOWN || event.GetEventType() == wxEVT_LEFT_DCLICK )
|
||||||
{
|
{
|
||||||
|
|
||||||
int x = event.m_x ;
|
int x = event.m_x ;
|
||||||
int y = event.m_y ;
|
int y = event.m_y ;
|
||||||
|
|
||||||
MacClientToRootWindow( &x , &y ) ;
|
MacClientToRootWindow( &x , &y ) ;
|
||||||
|
|
||||||
ControlHandle control ;
|
ControlHandle control ;
|
||||||
Point localwhere ;
|
Point localwhere ;
|
||||||
SInt16 controlpart ;
|
SInt16 controlpart ;
|
||||||
|
|
||||||
localwhere.h = x ;
|
localwhere.h = x ;
|
||||||
localwhere.v = y ;
|
localwhere.v = y ;
|
||||||
|
|
||||||
short modifiers = 0;
|
short modifiers = 0;
|
||||||
|
|
||||||
if ( !event.m_leftDown && !event.m_rightDown )
|
if ( !event.m_leftDown && !event.m_rightDown )
|
||||||
modifiers |= btnState ;
|
modifiers |= btnState ;
|
||||||
|
|
||||||
if ( event.m_shiftDown )
|
if ( event.m_shiftDown )
|
||||||
modifiers |= shiftKey ;
|
modifiers |= shiftKey ;
|
||||||
|
|
||||||
if ( event.m_controlDown )
|
if ( event.m_controlDown )
|
||||||
modifiers |= controlKey ;
|
modifiers |= controlKey ;
|
||||||
|
|
||||||
if ( event.m_altDown )
|
if ( event.m_altDown )
|
||||||
modifiers |= optionKey ;
|
modifiers |= optionKey ;
|
||||||
|
|
||||||
if ( event.m_metaDown )
|
if ( event.m_metaDown )
|
||||||
modifiers |= cmdKey ;
|
modifiers |= cmdKey ;
|
||||||
{
|
{
|
||||||
@@ -854,8 +852,8 @@ void wxControl::OnMouseEvent( wxMouseEvent &event )
|
|||||||
{
|
{
|
||||||
controlpart = ::HandleControlClick( control , localwhere , modifiers , (ControlActionUPP) -1 ) ;
|
controlpart = ::HandleControlClick( control , localwhere , modifiers , (ControlActionUPP) -1 ) ;
|
||||||
wxTheApp->s_lastMouseDown = 0 ;
|
wxTheApp->s_lastMouseDown = 0 ;
|
||||||
if ( control && controlpart != kControlNoPart &&
|
if ( control && controlpart != kControlNoPart &&
|
||||||
! IsKindOf( CLASSINFO( wxScrollBar ) )
|
! IsKindOf( CLASSINFO( wxScrollBar ) )
|
||||||
) // otherwise we will get the event twice for scrollbar
|
) // otherwise we will get the event twice for scrollbar
|
||||||
{
|
{
|
||||||
MacHandleControlClick( control , controlpart ) ;
|
MacHandleControlClick( control , controlpart ) ;
|
||||||
@@ -868,14 +866,14 @@ void wxControl::OnMouseEvent( wxMouseEvent &event )
|
|||||||
|
|
||||||
bool wxControl::MacCanFocus() const
|
bool wxControl::MacCanFocus() const
|
||||||
{
|
{
|
||||||
{ if ( (ControlHandle) m_macControl == NULL )
|
{ if ( (ControlHandle) m_macControl == NULL )
|
||||||
return true ;
|
return true ;
|
||||||
else
|
else
|
||||||
return false ;
|
return false ;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxControl::MacHandleControlClick( WXWidget control , wxInt16 controlpart )
|
void wxControl::MacHandleControlClick( WXWidget control , wxInt16 controlpart )
|
||||||
{
|
{
|
||||||
wxASSERT_MSG( (ControlHandle) m_macControl != NULL , "No valid mac control" ) ;
|
wxASSERT_MSG( (ControlHandle) m_macControl != NULL , "No valid mac control" ) ;
|
||||||
}
|
}
|
||||||
|
@@ -35,9 +35,9 @@
|
|||||||
IMPLEMENT_ABSTRACT_CLASS(wxControl, wxWindow)
|
IMPLEMENT_ABSTRACT_CLASS(wxControl, wxWindow)
|
||||||
|
|
||||||
BEGIN_EVENT_TABLE(wxControl, wxWindow)
|
BEGIN_EVENT_TABLE(wxControl, wxWindow)
|
||||||
EVT_MOUSE_EVENTS( wxControl::OnMouseEvent )
|
EVT_MOUSE_EVENTS( wxControl::OnMouseEvent )
|
||||||
// EVT_CHAR( wxControl::OnKeyDown )
|
// EVT_CHAR( wxControl::OnKeyDown )
|
||||||
EVT_PAINT( wxControl::OnPaint )
|
EVT_PAINT( wxControl::OnPaint )
|
||||||
END_EVENT_TABLE()
|
END_EVENT_TABLE()
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -89,7 +89,7 @@ ControlDefUPP wxMacControlActionUPP = NULL ;
|
|||||||
|
|
||||||
pascal SInt32 wxMacControlDefintion(SInt16 varCode, ControlRef theControl, ControlDefProcMessage message, SInt32 param)
|
pascal SInt32 wxMacControlDefintion(SInt16 varCode, ControlRef theControl, ControlDefProcMessage message, SInt32 param)
|
||||||
{
|
{
|
||||||
|
|
||||||
wxControl* wx = (wxControl*) wxFindControlFromMacControl( theControl ) ;
|
wxControl* wx = (wxControl*) wxFindControlFromMacControl( theControl ) ;
|
||||||
if ( wx != NULL && wx->IsKindOf( CLASSINFO( wxControl ) ) )
|
if ( wx != NULL && wx->IsKindOf( CLASSINFO( wxControl ) ) )
|
||||||
{
|
{
|
||||||
@@ -129,7 +129,7 @@ pascal OSStatus wxMacSetupControlBackground( ControlRef iControl , SInt16 iMessa
|
|||||||
}
|
}
|
||||||
return status ;
|
return status ;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxControl::wxControl()
|
wxControl::wxControl()
|
||||||
{
|
{
|
||||||
m_macControl = NULL ;
|
m_macControl = NULL ;
|
||||||
@@ -161,7 +161,7 @@ bool wxControl::Create(wxWindow *parent, wxWindowID id,
|
|||||||
m_macControl = NULL ;
|
m_macControl = NULL ;
|
||||||
m_macHorizontalBorder = 0 ; // additional pixels around the real control
|
m_macHorizontalBorder = 0 ; // additional pixels around the real control
|
||||||
m_macVerticalBorder = 0 ;
|
m_macVerticalBorder = 0 ;
|
||||||
|
|
||||||
bool rval = wxWindow::Create(parent, id, pos, size, style, name);
|
bool rval = wxWindow::Create(parent, id, pos, size, style, name);
|
||||||
if ( parent )
|
if ( parent )
|
||||||
{
|
{
|
||||||
@@ -203,12 +203,12 @@ void wxControl::SetLabel(const wxString& title)
|
|||||||
{
|
{
|
||||||
Str255 maclabel ;
|
Str255 maclabel ;
|
||||||
wxString label ;
|
wxString label ;
|
||||||
|
|
||||||
if( wxApp::s_macDefaultEncodingIsPC )
|
if( wxApp::s_macDefaultEncodingIsPC )
|
||||||
label = wxMacMakeMacStringFromPC( m_label ) ;
|
label = wxMacMakeMacStringFromPC( m_label ) ;
|
||||||
else
|
else
|
||||||
label = m_label ;
|
label = m_label ;
|
||||||
|
|
||||||
#if TARGET_CARBON
|
#if TARGET_CARBON
|
||||||
c2pstrcpy( (StringPtr) maclabel , label ) ;
|
c2pstrcpy( (StringPtr) maclabel , label ) ;
|
||||||
#else
|
#else
|
||||||
@@ -239,7 +239,7 @@ wxSize wxControl::DoGetBestSize() const
|
|||||||
}
|
}
|
||||||
else if ( IsKindOf( CLASSINFO( wxSpinButton ) ) )
|
else if ( IsKindOf( CLASSINFO( wxSpinButton ) ) )
|
||||||
{
|
{
|
||||||
bestsize.bottom = 24 ;
|
bestsize.bottom = 24 ;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -255,7 +255,7 @@ wxSize wxControl::DoGetBestSize() const
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
bestWidth = bestsize.right - bestsize.left ;
|
bestWidth = bestsize.right - bestsize.left ;
|
||||||
|
|
||||||
bestWidth += 2 * m_macHorizontalBorder ;
|
bestWidth += 2 * m_macHorizontalBorder ;
|
||||||
|
|
||||||
bestHeight = bestsize.bottom - bestsize.top ;
|
bestHeight = bestsize.bottom - bestsize.top ;
|
||||||
@@ -264,7 +264,7 @@ wxSize wxControl::DoGetBestSize() const
|
|||||||
|
|
||||||
bestHeight += 2 * m_macVerticalBorder;
|
bestHeight += 2 * m_macVerticalBorder;
|
||||||
|
|
||||||
|
|
||||||
return wxSize(bestWidth, bestHeight);
|
return wxSize(bestWidth, bestHeight);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -313,16 +313,14 @@ void wxRemoveMacControlAssociation(wxControl *control)
|
|||||||
wxWinMacControlList->DeleteObject(control);
|
wxWinMacControlList->DeleteObject(control);
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxControl::MacPreControlCreate( wxWindow *parent, wxWindowID id, wxString label ,
|
void wxControl::MacPreControlCreate( wxWindow *parent, wxWindowID id, 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 , WXRECTPTR outBounds , unsigned char* maclabel )
|
const wxString& name , WXRECTPTR outBounds , unsigned char* maclabel )
|
||||||
{
|
{
|
||||||
m_label = label ;
|
m_label = label ;
|
||||||
SetName(name);
|
SetName(name);
|
||||||
if ( &validator )
|
|
||||||
SetValidator(validator);
|
|
||||||
|
|
||||||
m_windowStyle = style;
|
m_windowStyle = style;
|
||||||
parent->AddChild(this);
|
parent->AddChild(this);
|
||||||
@@ -341,7 +339,7 @@ void wxControl::MacPreControlCreate( wxWindow *parent, wxWindowID id, wxString l
|
|||||||
m_height = size.y ;
|
m_height = size.y ;
|
||||||
m_x = pos.x ;
|
m_x = pos.x ;
|
||||||
m_y = pos.y ;
|
m_y = pos.y ;
|
||||||
|
|
||||||
((Rect*)outBounds)->top = -10;
|
((Rect*)outBounds)->top = -10;
|
||||||
((Rect*)outBounds)->left = -10;
|
((Rect*)outBounds)->left = -10;
|
||||||
((Rect*)outBounds)->bottom = 0;
|
((Rect*)outBounds)->bottom = 0;
|
||||||
@@ -365,7 +363,7 @@ void wxControl::MacPreControlCreate( wxWindow *parent, wxWindowID id, wxString l
|
|||||||
void wxControl::MacPostControlCreate()
|
void wxControl::MacPostControlCreate()
|
||||||
{
|
{
|
||||||
wxASSERT_MSG( (ControlHandle) m_macControl != NULL , "No valid mac control" ) ;
|
wxASSERT_MSG( (ControlHandle) m_macControl != NULL , "No valid mac control" ) ;
|
||||||
|
|
||||||
if ( IsKindOf( CLASSINFO( wxScrollBar ) ) )
|
if ( IsKindOf( CLASSINFO( wxScrollBar ) ) )
|
||||||
{
|
{
|
||||||
// no font
|
// no font
|
||||||
@@ -375,7 +373,7 @@ void wxControl::MacPostControlCreate()
|
|||||||
ControlFontStyleRec controlstyle ;
|
ControlFontStyleRec controlstyle ;
|
||||||
controlstyle.flags = kControlUseFontMask ;
|
controlstyle.flags = kControlUseFontMask ;
|
||||||
controlstyle.font = kControlFontSmallBoldSystemFont ;
|
controlstyle.font = kControlFontSmallBoldSystemFont ;
|
||||||
|
|
||||||
::SetControlFontStyle( (ControlHandle) m_macControl , &controlstyle ) ;
|
::SetControlFontStyle( (ControlHandle) m_macControl , &controlstyle ) ;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -383,7 +381,7 @@ void wxControl::MacPostControlCreate()
|
|||||||
ControlFontStyleRec controlstyle ;
|
ControlFontStyleRec controlstyle ;
|
||||||
controlstyle.flags = kControlUseFontMask ;
|
controlstyle.flags = kControlUseFontMask ;
|
||||||
controlstyle.font = kControlFontSmallSystemFont ;
|
controlstyle.font = kControlFontSmallSystemFont ;
|
||||||
|
|
||||||
::SetControlFontStyle( (ControlHandle) m_macControl , &controlstyle ) ;
|
::SetControlFontStyle( (ControlHandle) m_macControl , &controlstyle ) ;
|
||||||
}
|
}
|
||||||
ControlHandle container = (ControlHandle) GetParent()->MacGetContainerForEmbedding() ;
|
ControlHandle container = (ControlHandle) GetParent()->MacGetContainerForEmbedding() ;
|
||||||
@@ -424,38 +422,38 @@ void wxControl::MacPostControlCreate()
|
|||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
SetControlColorProc( (ControlHandle) m_macControl , wxMacSetupControlBackgroundUPP ) ;
|
SetControlColorProc( (ControlHandle) m_macControl , wxMacSetupControlBackgroundUPP ) ;
|
||||||
|
|
||||||
// Adjust the controls size and position
|
// Adjust the controls size and position
|
||||||
wxPoint pos(m_x, m_y);
|
wxPoint pos(m_x, m_y);
|
||||||
wxSize best_size( DoGetBestSize() );
|
wxSize best_size( DoGetBestSize() );
|
||||||
wxSize new_size( m_width, m_height );
|
wxSize new_size( m_width, m_height );
|
||||||
|
|
||||||
m_x = m_y = m_width = m_height = -1; // Forces SetSize to move/size the control
|
m_x = m_y = m_width = m_height = -1; // Forces SetSize to move/size the control
|
||||||
|
|
||||||
if (new_size.x == -1) {
|
if (new_size.x == -1) {
|
||||||
new_size.x = best_size.x;
|
new_size.x = best_size.x;
|
||||||
}
|
}
|
||||||
if (new_size.y == -1) {
|
if (new_size.y == -1) {
|
||||||
new_size.y = best_size.y;
|
new_size.y = best_size.y;
|
||||||
}
|
}
|
||||||
|
|
||||||
SetSize(pos.x, pos.y, new_size.x, new_size.y);
|
SetSize(pos.x, pos.y, new_size.x, new_size.y);
|
||||||
|
|
||||||
UMAShowControl( (ControlHandle) m_macControl ) ;
|
UMAShowControl( (ControlHandle) m_macControl ) ;
|
||||||
|
|
||||||
SetCursor( *wxSTANDARD_CURSOR ) ;
|
SetCursor( *wxSTANDARD_CURSOR ) ;
|
||||||
|
|
||||||
Refresh() ;
|
Refresh() ;
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxControl::MacAdjustControlRect()
|
void wxControl::MacAdjustControlRect()
|
||||||
{
|
{
|
||||||
wxASSERT_MSG( (ControlHandle) m_macControl != NULL , wxT("No valid mac control") ) ;
|
wxASSERT_MSG( (ControlHandle) m_macControl != NULL , wxT("No valid mac control") ) ;
|
||||||
if ( m_width == -1 || m_height == -1 )
|
if ( m_width == -1 || m_height == -1 )
|
||||||
{
|
{
|
||||||
Rect bestsize = { 0 , 0 , 0 , 0 } ;
|
Rect bestsize = { 0 , 0 , 0 , 0 } ;
|
||||||
short baselineoffset ;
|
short baselineoffset ;
|
||||||
|
|
||||||
::GetBestControlRect( (ControlHandle) m_macControl , &bestsize , &baselineoffset ) ;
|
::GetBestControlRect( (ControlHandle) m_macControl , &bestsize , &baselineoffset ) ;
|
||||||
|
|
||||||
if ( EmptyRect( &bestsize ) )
|
if ( EmptyRect( &bestsize ) )
|
||||||
@@ -470,7 +468,7 @@ void wxControl::MacAdjustControlRect()
|
|||||||
}
|
}
|
||||||
else if ( IsKindOf( CLASSINFO( wxSpinButton ) ) )
|
else if ( IsKindOf( CLASSINFO( wxSpinButton ) ) )
|
||||||
{
|
{
|
||||||
bestsize.bottom = 24 ;
|
bestsize.bottom = 24 ;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -488,7 +486,7 @@ void wxControl::MacAdjustControlRect()
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
m_width = bestsize.right - bestsize.left ;
|
m_width = bestsize.right - bestsize.left ;
|
||||||
|
|
||||||
m_width += 2 * m_macHorizontalBorder + MacGetLeftBorderSize() + MacGetRightBorderSize() ;
|
m_width += 2 * m_macHorizontalBorder + MacGetLeftBorderSize() + MacGetRightBorderSize() ;
|
||||||
}
|
}
|
||||||
if ( m_height == -1 )
|
if ( m_height == -1 )
|
||||||
@@ -499,12 +497,12 @@ void wxControl::MacAdjustControlRect()
|
|||||||
|
|
||||||
m_height += 2 * m_macVerticalBorder + MacGetTopBorderSize() + MacGetBottomBorderSize() ;
|
m_height += 2 * m_macVerticalBorder + MacGetTopBorderSize() + MacGetBottomBorderSize() ;
|
||||||
}
|
}
|
||||||
MacUpdateDimensions() ;
|
MacUpdateDimensions() ;
|
||||||
// UMASizeControl( (ControlHandle) m_macControl , m_width - 2 * m_macHorizontalBorder, m_height - 2 * m_macVerticalBorder ) ;
|
// UMASizeControl( (ControlHandle) m_macControl , m_width - 2 * m_macHorizontalBorder, m_height - 2 * m_macVerticalBorder ) ;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
WXWidget wxControl::MacGetContainerForEmbedding()
|
WXWidget wxControl::MacGetContainerForEmbedding()
|
||||||
{
|
{
|
||||||
if ( m_macControl )
|
if ( m_macControl )
|
||||||
return m_macControl ;
|
return m_macControl ;
|
||||||
@@ -512,29 +510,29 @@ WXWidget wxControl::MacGetContainerForEmbedding()
|
|||||||
return wxWindow::MacGetContainerForEmbedding() ;
|
return wxWindow::MacGetContainerForEmbedding() ;
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxControl::MacUpdateDimensions()
|
void wxControl::MacUpdateDimensions()
|
||||||
{
|
{
|
||||||
// actually in the current systems this should never be possible, but later reparenting
|
// actually in the current systems this should never be possible, but later reparenting
|
||||||
// may become a reality
|
// may become a reality
|
||||||
|
|
||||||
if ( (ControlHandle) m_macControl == NULL )
|
if ( (ControlHandle) m_macControl == NULL )
|
||||||
return ;
|
return ;
|
||||||
|
|
||||||
if ( GetParent() == NULL )
|
if ( GetParent() == NULL )
|
||||||
return ;
|
return ;
|
||||||
|
|
||||||
WindowRef rootwindow = (WindowRef) MacGetRootWindow() ;
|
WindowRef rootwindow = (WindowRef) MacGetRootWindow() ;
|
||||||
if ( rootwindow == NULL )
|
if ( rootwindow == NULL )
|
||||||
return ;
|
return ;
|
||||||
|
|
||||||
Rect oldBounds ;
|
Rect oldBounds ;
|
||||||
GetControlBounds( (ControlHandle) m_macControl , &oldBounds ) ;
|
GetControlBounds( (ControlHandle) m_macControl , &oldBounds ) ;
|
||||||
|
|
||||||
int new_x = m_x + MacGetLeftBorderSize() + m_macHorizontalBorder ;
|
int new_x = m_x + MacGetLeftBorderSize() + m_macHorizontalBorder ;
|
||||||
int new_y = m_y + MacGetTopBorderSize() + m_macVerticalBorder ;
|
int new_y = m_y + MacGetTopBorderSize() + m_macVerticalBorder ;
|
||||||
int new_width = m_width - MacGetLeftBorderSize() - MacGetRightBorderSize() - 2 * m_macHorizontalBorder ;
|
int new_width = m_width - MacGetLeftBorderSize() - MacGetRightBorderSize() - 2 * m_macHorizontalBorder ;
|
||||||
int new_height = m_height - MacGetTopBorderSize() - MacGetBottomBorderSize() - 2 * m_macVerticalBorder ;
|
int new_height = m_height - MacGetTopBorderSize() - MacGetBottomBorderSize() - 2 * m_macVerticalBorder ;
|
||||||
|
|
||||||
GetParent()->MacWindowToRootWindow( & new_x , & new_y ) ;
|
GetParent()->MacWindowToRootWindow( & new_x , & new_y ) ;
|
||||||
bool doMove = new_x != oldBounds.left || new_y != oldBounds.top ;
|
bool doMove = new_x != oldBounds.left || new_y != oldBounds.top ;
|
||||||
bool doResize = ( oldBounds.right - oldBounds.left ) != new_width || (oldBounds.bottom - oldBounds.top ) != new_height ;
|
bool doResize = ( oldBounds.right - oldBounds.left ) != new_width || (oldBounds.bottom - oldBounds.top ) != new_height ;
|
||||||
@@ -552,19 +550,19 @@ void wxControl::MacUpdateDimensions()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxControl::MacSuperChangedPosition()
|
void wxControl::MacSuperChangedPosition()
|
||||||
{
|
{
|
||||||
MacUpdateDimensions() ;
|
MacUpdateDimensions() ;
|
||||||
wxWindow::MacSuperChangedPosition() ;
|
wxWindow::MacSuperChangedPosition() ;
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxControl::MacSuperEnabled( bool enabled )
|
void wxControl::MacSuperEnabled( bool enabled )
|
||||||
{
|
{
|
||||||
Refresh(FALSE) ;
|
Refresh(FALSE) ;
|
||||||
wxWindow::MacSuperEnabled( enabled ) ;
|
wxWindow::MacSuperEnabled( enabled ) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxControl::MacSuperShown( bool show )
|
void wxControl::MacSuperShown( bool show )
|
||||||
{
|
{
|
||||||
if ( (ControlHandle) m_macControl )
|
if ( (ControlHandle) m_macControl )
|
||||||
{
|
{
|
||||||
@@ -585,7 +583,7 @@ void wxControl::MacSuperShown( bool show )
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
wxWindow::MacSuperShown( show ) ;
|
wxWindow::MacSuperShown( show ) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -606,12 +604,12 @@ void wxControl::DoSetSize(int x, int y,
|
|||||||
Rect oldbounds;
|
Rect oldbounds;
|
||||||
int new_x, new_y, new_width, new_height;
|
int new_x, new_y, new_width, new_height;
|
||||||
int mac_x, mac_y;
|
int mac_x, mac_y;
|
||||||
|
|
||||||
new_x = m_x;
|
new_x = m_x;
|
||||||
new_y = m_y;
|
new_y = m_y;
|
||||||
new_width = m_width;
|
new_width = m_width;
|
||||||
new_height = m_height;
|
new_height = m_height;
|
||||||
|
|
||||||
if (sizeFlags & wxSIZE_ALLOW_MINUS_ONE)
|
if (sizeFlags & wxSIZE_ALLOW_MINUS_ONE)
|
||||||
{
|
{
|
||||||
new_x = x;
|
new_x = x;
|
||||||
@@ -626,7 +624,7 @@ void wxControl::DoSetSize(int x, int y,
|
|||||||
if (width != -1) new_width = width;
|
if (width != -1) new_width = width;
|
||||||
if (height != -1) new_height = height;
|
if (height != -1) new_height = height;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(sizeFlags & wxSIZE_AUTO)
|
if(sizeFlags & wxSIZE_AUTO)
|
||||||
{
|
{
|
||||||
wxSize size = GetBestSize();
|
wxSize size = GetBestSize();
|
||||||
@@ -640,7 +638,7 @@ void wxControl::DoSetSize(int x, int y,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
AdjustForParentClientOrigin(new_x, new_y, sizeFlags);
|
AdjustForParentClientOrigin(new_x, new_y, sizeFlags);
|
||||||
|
|
||||||
mac_x = new_x;
|
mac_x = new_x;
|
||||||
mac_y = new_y;
|
mac_y = new_y;
|
||||||
if(GetParent()) {
|
if(GetParent()) {
|
||||||
@@ -649,10 +647,10 @@ void wxControl::DoSetSize(int x, int y,
|
|||||||
GetControlBounds( (ControlHandle) m_macControl, &oldbounds);
|
GetControlBounds( (ControlHandle) m_macControl, &oldbounds);
|
||||||
oldbounds.right = oldbounds.left + m_width;
|
oldbounds.right = oldbounds.left + m_width;
|
||||||
oldbounds.bottom = oldbounds.top + m_height;
|
oldbounds.bottom = oldbounds.top + m_height;
|
||||||
|
|
||||||
bool doMove = false;
|
bool doMove = false;
|
||||||
bool doResize = false;
|
bool doResize = false;
|
||||||
|
|
||||||
if ( mac_x != (oldbounds.left - m_macHorizontalBorder) ||
|
if ( mac_x != (oldbounds.left - m_macHorizontalBorder) ||
|
||||||
mac_y != (oldbounds.top - m_macVerticalBorder) )
|
mac_y != (oldbounds.top - m_macVerticalBorder) )
|
||||||
{
|
{
|
||||||
@@ -663,11 +661,11 @@ void wxControl::DoSetSize(int x, int y,
|
|||||||
{
|
{
|
||||||
doResize = true ;
|
doResize = true ;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( doMove || doResize )
|
if ( doMove || doResize )
|
||||||
{
|
{
|
||||||
Refresh() ;
|
Refresh() ;
|
||||||
|
|
||||||
// Ensure resize is within constraints
|
// Ensure resize is within constraints
|
||||||
if ((m_minWidth != -1) && (new_width < m_minWidth)) {
|
if ((m_minWidth != -1) && (new_width < m_minWidth)) {
|
||||||
new_width = m_minWidth;
|
new_width = m_minWidth;
|
||||||
@@ -681,12 +679,12 @@ void wxControl::DoSetSize(int x, int y,
|
|||||||
if ((m_maxHeight != -1) && (new_height > m_maxHeight)) {
|
if ((m_maxHeight != -1) && (new_height > m_maxHeight)) {
|
||||||
new_height = m_maxHeight;
|
new_height = m_maxHeight;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( doMove )
|
if ( doMove )
|
||||||
{
|
{
|
||||||
m_x = new_x;
|
m_x = new_x;
|
||||||
m_y = new_y;
|
m_y = new_y;
|
||||||
|
|
||||||
UMAMoveControl( (ControlHandle) m_macControl,
|
UMAMoveControl( (ControlHandle) m_macControl,
|
||||||
mac_x + m_macHorizontalBorder, mac_y + m_macVerticalBorder);
|
mac_x + m_macHorizontalBorder, mac_y + m_macVerticalBorder);
|
||||||
|
|
||||||
@@ -698,27 +696,27 @@ void wxControl::DoSetSize(int x, int y,
|
|||||||
{
|
{
|
||||||
m_width = new_width;
|
m_width = new_width;
|
||||||
m_height = new_height;
|
m_height = new_height;
|
||||||
|
|
||||||
UMASizeControl( (ControlHandle) m_macControl,
|
UMASizeControl( (ControlHandle) m_macControl,
|
||||||
m_width - 2 * m_macHorizontalBorder,
|
m_width - 2 * m_macHorizontalBorder,
|
||||||
m_height - 2 * m_macVerticalBorder ) ;
|
m_height - 2 * m_macVerticalBorder ) ;
|
||||||
|
|
||||||
|
|
||||||
wxSizeEvent event(wxSize(m_width, m_height), m_windowId);
|
wxSizeEvent event(wxSize(m_width, m_height), m_windowId);
|
||||||
event.SetEventObject(this);
|
event.SetEventObject(this);
|
||||||
GetEventHandler()->ProcessEvent(event);
|
GetEventHandler()->ProcessEvent(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
Refresh() ;
|
Refresh() ;
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxControl::Show(bool show)
|
bool wxControl::Show(bool show)
|
||||||
{
|
{
|
||||||
if ( !wxWindow::Show( show ) )
|
if ( !wxWindow::Show( show ) )
|
||||||
return FALSE ;
|
return FALSE ;
|
||||||
|
|
||||||
if ( (ControlHandle) m_macControl )
|
if ( (ControlHandle) m_macControl )
|
||||||
{
|
{
|
||||||
if ( !show )
|
if ( !show )
|
||||||
@@ -741,7 +739,7 @@ bool wxControl::Show(bool show)
|
|||||||
return TRUE ;
|
return TRUE ;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxControl::Enable(bool enable)
|
bool wxControl::Enable(bool enable)
|
||||||
{
|
{
|
||||||
if ( !wxWindow::Enable(enable) )
|
if ( !wxWindow::Enable(enable) )
|
||||||
return FALSE;
|
return FALSE;
|
||||||
@@ -790,15 +788,15 @@ void wxControl::OnPaint(wxPaintEvent& event)
|
|||||||
}
|
}
|
||||||
void wxControl::OnEraseBackground(wxEraseEvent& event)
|
void wxControl::OnEraseBackground(wxEraseEvent& event)
|
||||||
{
|
{
|
||||||
wxWindow::OnEraseBackground( event ) ;
|
wxWindow::OnEraseBackground( event ) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void wxControl::OnKeyDown( wxKeyEvent &event )
|
void wxControl::OnKeyDown( wxKeyEvent &event )
|
||||||
{
|
{
|
||||||
if ( (ControlHandle) m_macControl == NULL )
|
if ( (ControlHandle) m_macControl == NULL )
|
||||||
return ;
|
return ;
|
||||||
|
|
||||||
EventRecord *ev = (EventRecord*) wxTheApp->MacGetCurrentEvent() ;
|
EventRecord *ev = (EventRecord*) wxTheApp->MacGetCurrentEvent() ;
|
||||||
short keycode ;
|
short keycode ;
|
||||||
short keychar ;
|
short keychar ;
|
||||||
@@ -808,43 +806,43 @@ void wxControl::OnKeyDown( wxKeyEvent &event )
|
|||||||
::HandleControlKey( (ControlHandle) m_macControl , keycode , keychar , ev->modifiers ) ;
|
::HandleControlKey( (ControlHandle) m_macControl , keycode , keychar , ev->modifiers ) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxControl::OnMouseEvent( wxMouseEvent &event )
|
void wxControl::OnMouseEvent( wxMouseEvent &event )
|
||||||
{
|
{
|
||||||
if ( (ControlHandle) m_macControl == NULL )
|
if ( (ControlHandle) m_macControl == NULL )
|
||||||
{
|
{
|
||||||
event.Skip() ;
|
event.Skip() ;
|
||||||
return ;
|
return ;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (event.GetEventType() == wxEVT_LEFT_DOWN || event.GetEventType() == wxEVT_LEFT_DCLICK )
|
if (event.GetEventType() == wxEVT_LEFT_DOWN || event.GetEventType() == wxEVT_LEFT_DCLICK )
|
||||||
{
|
{
|
||||||
|
|
||||||
int x = event.m_x ;
|
int x = event.m_x ;
|
||||||
int y = event.m_y ;
|
int y = event.m_y ;
|
||||||
|
|
||||||
MacClientToRootWindow( &x , &y ) ;
|
MacClientToRootWindow( &x , &y ) ;
|
||||||
|
|
||||||
ControlHandle control ;
|
ControlHandle control ;
|
||||||
Point localwhere ;
|
Point localwhere ;
|
||||||
SInt16 controlpart ;
|
SInt16 controlpart ;
|
||||||
|
|
||||||
localwhere.h = x ;
|
localwhere.h = x ;
|
||||||
localwhere.v = y ;
|
localwhere.v = y ;
|
||||||
|
|
||||||
short modifiers = 0;
|
short modifiers = 0;
|
||||||
|
|
||||||
if ( !event.m_leftDown && !event.m_rightDown )
|
if ( !event.m_leftDown && !event.m_rightDown )
|
||||||
modifiers |= btnState ;
|
modifiers |= btnState ;
|
||||||
|
|
||||||
if ( event.m_shiftDown )
|
if ( event.m_shiftDown )
|
||||||
modifiers |= shiftKey ;
|
modifiers |= shiftKey ;
|
||||||
|
|
||||||
if ( event.m_controlDown )
|
if ( event.m_controlDown )
|
||||||
modifiers |= controlKey ;
|
modifiers |= controlKey ;
|
||||||
|
|
||||||
if ( event.m_altDown )
|
if ( event.m_altDown )
|
||||||
modifiers |= optionKey ;
|
modifiers |= optionKey ;
|
||||||
|
|
||||||
if ( event.m_metaDown )
|
if ( event.m_metaDown )
|
||||||
modifiers |= cmdKey ;
|
modifiers |= cmdKey ;
|
||||||
{
|
{
|
||||||
@@ -854,8 +852,8 @@ void wxControl::OnMouseEvent( wxMouseEvent &event )
|
|||||||
{
|
{
|
||||||
controlpart = ::HandleControlClick( control , localwhere , modifiers , (ControlActionUPP) -1 ) ;
|
controlpart = ::HandleControlClick( control , localwhere , modifiers , (ControlActionUPP) -1 ) ;
|
||||||
wxTheApp->s_lastMouseDown = 0 ;
|
wxTheApp->s_lastMouseDown = 0 ;
|
||||||
if ( control && controlpart != kControlNoPart &&
|
if ( control && controlpart != kControlNoPart &&
|
||||||
! IsKindOf( CLASSINFO( wxScrollBar ) )
|
! IsKindOf( CLASSINFO( wxScrollBar ) )
|
||||||
) // otherwise we will get the event twice for scrollbar
|
) // otherwise we will get the event twice for scrollbar
|
||||||
{
|
{
|
||||||
MacHandleControlClick( control , controlpart ) ;
|
MacHandleControlClick( control , controlpart ) ;
|
||||||
@@ -868,14 +866,14 @@ void wxControl::OnMouseEvent( wxMouseEvent &event )
|
|||||||
|
|
||||||
bool wxControl::MacCanFocus() const
|
bool wxControl::MacCanFocus() const
|
||||||
{
|
{
|
||||||
{ if ( (ControlHandle) m_macControl == NULL )
|
{ if ( (ControlHandle) m_macControl == NULL )
|
||||||
return true ;
|
return true ;
|
||||||
else
|
else
|
||||||
return false ;
|
return false ;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxControl::MacHandleControlClick( WXWidget control , wxInt16 controlpart )
|
void wxControl::MacHandleControlClick( WXWidget control , wxInt16 controlpart )
|
||||||
{
|
{
|
||||||
wxASSERT_MSG( (ControlHandle) m_macControl != NULL , "No valid mac control" ) ;
|
wxASSERT_MSG( (ControlHandle) m_macControl != NULL , "No valid mac control" ) ;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user