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)
|
||||
|
||||
BEGIN_EVENT_TABLE(wxControl, wxWindow)
|
||||
EVT_MOUSE_EVENTS( wxControl::OnMouseEvent )
|
||||
// EVT_CHAR( wxControl::OnKeyDown )
|
||||
EVT_PAINT( wxControl::OnPaint )
|
||||
EVT_MOUSE_EVENTS( wxControl::OnMouseEvent )
|
||||
// EVT_CHAR( wxControl::OnKeyDown )
|
||||
EVT_PAINT( wxControl::OnPaint )
|
||||
END_EVENT_TABLE()
|
||||
#endif
|
||||
|
||||
@@ -89,7 +89,7 @@ ControlDefUPP wxMacControlActionUPP = NULL ;
|
||||
|
||||
pascal SInt32 wxMacControlDefintion(SInt16 varCode, ControlRef theControl, ControlDefProcMessage message, SInt32 param)
|
||||
{
|
||||
|
||||
|
||||
wxControl* wx = (wxControl*) wxFindControlFromMacControl( theControl ) ;
|
||||
if ( wx != NULL && wx->IsKindOf( CLASSINFO( wxControl ) ) )
|
||||
{
|
||||
@@ -129,7 +129,7 @@ pascal OSStatus wxMacSetupControlBackground( ControlRef iControl , SInt16 iMessa
|
||||
}
|
||||
return status ;
|
||||
}
|
||||
|
||||
|
||||
wxControl::wxControl()
|
||||
{
|
||||
m_macControl = NULL ;
|
||||
@@ -161,7 +161,7 @@ bool wxControl::Create(wxWindow *parent, wxWindowID id,
|
||||
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);
|
||||
if ( parent )
|
||||
{
|
||||
@@ -203,12 +203,12 @@ void wxControl::SetLabel(const wxString& title)
|
||||
{
|
||||
Str255 maclabel ;
|
||||
wxString label ;
|
||||
|
||||
|
||||
if( wxApp::s_macDefaultEncodingIsPC )
|
||||
label = wxMacMakeMacStringFromPC( m_label ) ;
|
||||
else
|
||||
label = m_label ;
|
||||
|
||||
|
||||
#if TARGET_CARBON
|
||||
c2pstrcpy( (StringPtr) maclabel , label ) ;
|
||||
#else
|
||||
@@ -239,7 +239,7 @@ wxSize wxControl::DoGetBestSize() const
|
||||
}
|
||||
else if ( IsKindOf( CLASSINFO( wxSpinButton ) ) )
|
||||
{
|
||||
bestsize.bottom = 24 ;
|
||||
bestsize.bottom = 24 ;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -255,7 +255,7 @@ wxSize wxControl::DoGetBestSize() const
|
||||
}
|
||||
else
|
||||
bestWidth = bestsize.right - bestsize.left ;
|
||||
|
||||
|
||||
bestWidth += 2 * m_macHorizontalBorder ;
|
||||
|
||||
bestHeight = bestsize.bottom - bestsize.top ;
|
||||
@@ -264,7 +264,7 @@ wxSize wxControl::DoGetBestSize() const
|
||||
|
||||
bestHeight += 2 * m_macVerticalBorder;
|
||||
|
||||
|
||||
|
||||
return wxSize(bestWidth, bestHeight);
|
||||
}
|
||||
|
||||
@@ -313,16 +313,14 @@ void wxRemoveMacControlAssociation(wxControl *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 wxSize& size, long style,
|
||||
const wxValidator& validator,
|
||||
const wxString& name , WXRECTPTR outBounds , unsigned char* maclabel )
|
||||
const wxString& name , WXRECTPTR outBounds , unsigned char* maclabel )
|
||||
{
|
||||
m_label = label ;
|
||||
SetName(name);
|
||||
if ( &validator )
|
||||
SetValidator(validator);
|
||||
|
||||
m_windowStyle = style;
|
||||
parent->AddChild(this);
|
||||
@@ -341,7 +339,7 @@ void wxControl::MacPreControlCreate( wxWindow *parent, wxWindowID id, wxString l
|
||||
m_height = size.y ;
|
||||
m_x = pos.x ;
|
||||
m_y = pos.y ;
|
||||
|
||||
|
||||
((Rect*)outBounds)->top = -10;
|
||||
((Rect*)outBounds)->left = -10;
|
||||
((Rect*)outBounds)->bottom = 0;
|
||||
@@ -365,7 +363,7 @@ void wxControl::MacPreControlCreate( wxWindow *parent, wxWindowID id, wxString l
|
||||
void wxControl::MacPostControlCreate()
|
||||
{
|
||||
wxASSERT_MSG( (ControlHandle) m_macControl != NULL , "No valid mac control" ) ;
|
||||
|
||||
|
||||
if ( IsKindOf( CLASSINFO( wxScrollBar ) ) )
|
||||
{
|
||||
// no font
|
||||
@@ -375,7 +373,7 @@ void wxControl::MacPostControlCreate()
|
||||
ControlFontStyleRec controlstyle ;
|
||||
controlstyle.flags = kControlUseFontMask ;
|
||||
controlstyle.font = kControlFontSmallBoldSystemFont ;
|
||||
|
||||
|
||||
::SetControlFontStyle( (ControlHandle) m_macControl , &controlstyle ) ;
|
||||
}
|
||||
else
|
||||
@@ -383,7 +381,7 @@ void wxControl::MacPostControlCreate()
|
||||
ControlFontStyleRec controlstyle ;
|
||||
controlstyle.flags = kControlUseFontMask ;
|
||||
controlstyle.font = kControlFontSmallSystemFont ;
|
||||
|
||||
|
||||
::SetControlFontStyle( (ControlHandle) m_macControl , &controlstyle ) ;
|
||||
}
|
||||
ControlHandle container = (ControlHandle) GetParent()->MacGetContainerForEmbedding() ;
|
||||
@@ -424,38 +422,38 @@ void wxControl::MacPostControlCreate()
|
||||
#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);
|
||||
|
||||
|
||||
UMAShowControl( (ControlHandle) m_macControl ) ;
|
||||
|
||||
|
||||
SetCursor( *wxSTANDARD_CURSOR ) ;
|
||||
|
||||
|
||||
Refresh() ;
|
||||
}
|
||||
|
||||
void wxControl::MacAdjustControlRect()
|
||||
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 ) )
|
||||
@@ -470,7 +468,7 @@ void wxControl::MacAdjustControlRect()
|
||||
}
|
||||
else if ( IsKindOf( CLASSINFO( wxSpinButton ) ) )
|
||||
{
|
||||
bestsize.bottom = 24 ;
|
||||
bestsize.bottom = 24 ;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -488,7 +486,7 @@ void wxControl::MacAdjustControlRect()
|
||||
}
|
||||
else
|
||||
m_width = bestsize.right - bestsize.left ;
|
||||
|
||||
|
||||
m_width += 2 * m_macHorizontalBorder + MacGetLeftBorderSize() + MacGetRightBorderSize() ;
|
||||
}
|
||||
if ( m_height == -1 )
|
||||
@@ -499,12 +497,12 @@ void wxControl::MacAdjustControlRect()
|
||||
|
||||
m_height += 2 * m_macVerticalBorder + MacGetTopBorderSize() + MacGetBottomBorderSize() ;
|
||||
}
|
||||
MacUpdateDimensions() ;
|
||||
MacUpdateDimensions() ;
|
||||
// UMASizeControl( (ControlHandle) m_macControl , m_width - 2 * m_macHorizontalBorder, m_height - 2 * m_macVerticalBorder ) ;
|
||||
}
|
||||
}
|
||||
|
||||
WXWidget wxControl::MacGetContainerForEmbedding()
|
||||
WXWidget wxControl::MacGetContainerForEmbedding()
|
||||
{
|
||||
if ( m_macControl )
|
||||
return m_macControl ;
|
||||
@@ -512,29 +510,29 @@ WXWidget wxControl::MacGetContainerForEmbedding()
|
||||
return wxWindow::MacGetContainerForEmbedding() ;
|
||||
}
|
||||
|
||||
void wxControl::MacUpdateDimensions()
|
||||
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 ) ;
|
||||
|
||||
|
||||
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 ;
|
||||
@@ -552,19 +550,19 @@ void wxControl::MacUpdateDimensions()
|
||||
}
|
||||
}
|
||||
|
||||
void wxControl::MacSuperChangedPosition()
|
||||
void wxControl::MacSuperChangedPosition()
|
||||
{
|
||||
MacUpdateDimensions() ;
|
||||
wxWindow::MacSuperChangedPosition() ;
|
||||
}
|
||||
|
||||
void wxControl::MacSuperEnabled( bool enabled )
|
||||
void wxControl::MacSuperEnabled( bool enabled )
|
||||
{
|
||||
Refresh(FALSE) ;
|
||||
wxWindow::MacSuperEnabled( enabled ) ;
|
||||
}
|
||||
|
||||
void wxControl::MacSuperShown( bool show )
|
||||
void wxControl::MacSuperShown( bool show )
|
||||
{
|
||||
if ( (ControlHandle) m_macControl )
|
||||
{
|
||||
@@ -585,7 +583,7 @@ void wxControl::MacSuperShown( bool show )
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
wxWindow::MacSuperShown( show ) ;
|
||||
}
|
||||
|
||||
@@ -606,12 +604,12 @@ void wxControl::DoSetSize(int x, int y,
|
||||
Rect oldbounds;
|
||||
int new_x, new_y, new_width, new_height;
|
||||
int mac_x, mac_y;
|
||||
|
||||
|
||||
new_x = m_x;
|
||||
new_y = m_y;
|
||||
new_width = m_width;
|
||||
new_height = m_height;
|
||||
|
||||
|
||||
if (sizeFlags & wxSIZE_ALLOW_MINUS_ONE)
|
||||
{
|
||||
new_x = x;
|
||||
@@ -626,7 +624,7 @@ void wxControl::DoSetSize(int x, int y,
|
||||
if (width != -1) new_width = width;
|
||||
if (height != -1) new_height = height;
|
||||
}
|
||||
|
||||
|
||||
if(sizeFlags & wxSIZE_AUTO)
|
||||
{
|
||||
wxSize size = GetBestSize();
|
||||
@@ -640,7 +638,7 @@ void wxControl::DoSetSize(int x, int y,
|
||||
}
|
||||
}
|
||||
AdjustForParentClientOrigin(new_x, new_y, sizeFlags);
|
||||
|
||||
|
||||
mac_x = new_x;
|
||||
mac_y = new_y;
|
||||
if(GetParent()) {
|
||||
@@ -649,10 +647,10 @@ void wxControl::DoSetSize(int x, int y,
|
||||
GetControlBounds( (ControlHandle) m_macControl, &oldbounds);
|
||||
oldbounds.right = oldbounds.left + m_width;
|
||||
oldbounds.bottom = oldbounds.top + m_height;
|
||||
|
||||
|
||||
bool doMove = false;
|
||||
bool doResize = false;
|
||||
|
||||
|
||||
if ( mac_x != (oldbounds.left - m_macHorizontalBorder) ||
|
||||
mac_y != (oldbounds.top - m_macVerticalBorder) )
|
||||
{
|
||||
@@ -663,11 +661,11 @@ void wxControl::DoSetSize(int x, int y,
|
||||
{
|
||||
doResize = true ;
|
||||
}
|
||||
|
||||
|
||||
if ( doMove || doResize )
|
||||
{
|
||||
Refresh() ;
|
||||
|
||||
|
||||
// Ensure resize is within constraints
|
||||
if ((m_minWidth != -1) && (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)) {
|
||||
new_height = m_maxHeight;
|
||||
}
|
||||
|
||||
|
||||
if ( doMove )
|
||||
{
|
||||
m_x = new_x;
|
||||
m_y = new_y;
|
||||
|
||||
|
||||
UMAMoveControl( (ControlHandle) m_macControl,
|
||||
mac_x + m_macHorizontalBorder, mac_y + m_macVerticalBorder);
|
||||
|
||||
@@ -698,27 +696,27 @@ void wxControl::DoSetSize(int x, int y,
|
||||
{
|
||||
m_width = new_width;
|
||||
m_height = new_height;
|
||||
|
||||
|
||||
UMASizeControl( (ControlHandle) m_macControl,
|
||||
m_width - 2 * m_macHorizontalBorder,
|
||||
m_height - 2 * m_macVerticalBorder ) ;
|
||||
|
||||
|
||||
|
||||
|
||||
wxSizeEvent event(wxSize(m_width, m_height), m_windowId);
|
||||
event.SetEventObject(this);
|
||||
GetEventHandler()->ProcessEvent(event);
|
||||
}
|
||||
|
||||
|
||||
Refresh() ;
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
bool wxControl::Show(bool show)
|
||||
bool wxControl::Show(bool show)
|
||||
{
|
||||
if ( !wxWindow::Show( show ) )
|
||||
return FALSE ;
|
||||
|
||||
|
||||
if ( (ControlHandle) m_macControl )
|
||||
{
|
||||
if ( !show )
|
||||
@@ -741,7 +739,7 @@ bool wxControl::Show(bool show)
|
||||
return TRUE ;
|
||||
}
|
||||
|
||||
bool wxControl::Enable(bool enable)
|
||||
bool wxControl::Enable(bool enable)
|
||||
{
|
||||
if ( !wxWindow::Enable(enable) )
|
||||
return FALSE;
|
||||
@@ -790,15 +788,15 @@ void wxControl::OnPaint(wxPaintEvent& 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 )
|
||||
return ;
|
||||
|
||||
|
||||
EventRecord *ev = (EventRecord*) wxTheApp->MacGetCurrentEvent() ;
|
||||
short keycode ;
|
||||
short keychar ;
|
||||
@@ -808,43 +806,43 @@ void wxControl::OnKeyDown( wxKeyEvent &event )
|
||||
::HandleControlKey( (ControlHandle) m_macControl , keycode , keychar , ev->modifiers ) ;
|
||||
}
|
||||
|
||||
void wxControl::OnMouseEvent( wxMouseEvent &event )
|
||||
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 ;
|
||||
{
|
||||
@@ -854,8 +852,8 @@ void wxControl::OnMouseEvent( wxMouseEvent &event )
|
||||
{
|
||||
controlpart = ::HandleControlClick( control , localwhere , modifiers , (ControlActionUPP) -1 ) ;
|
||||
wxTheApp->s_lastMouseDown = 0 ;
|
||||
if ( control && controlpart != kControlNoPart &&
|
||||
! IsKindOf( CLASSINFO( wxScrollBar ) )
|
||||
if ( control && controlpart != kControlNoPart &&
|
||||
! IsKindOf( CLASSINFO( wxScrollBar ) )
|
||||
) // otherwise we will get the event twice for scrollbar
|
||||
{
|
||||
MacHandleControlClick( control , controlpart ) ;
|
||||
@@ -868,14 +866,14 @@ void wxControl::OnMouseEvent( wxMouseEvent &event )
|
||||
|
||||
bool wxControl::MacCanFocus() const
|
||||
{
|
||||
{ if ( (ControlHandle) m_macControl == NULL )
|
||||
return true ;
|
||||
{ if ( (ControlHandle) m_macControl == NULL )
|
||||
return true ;
|
||||
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" ) ;
|
||||
}
|
||||
|
@@ -35,9 +35,9 @@
|
||||
IMPLEMENT_ABSTRACT_CLASS(wxControl, wxWindow)
|
||||
|
||||
BEGIN_EVENT_TABLE(wxControl, wxWindow)
|
||||
EVT_MOUSE_EVENTS( wxControl::OnMouseEvent )
|
||||
// EVT_CHAR( wxControl::OnKeyDown )
|
||||
EVT_PAINT( wxControl::OnPaint )
|
||||
EVT_MOUSE_EVENTS( wxControl::OnMouseEvent )
|
||||
// EVT_CHAR( wxControl::OnKeyDown )
|
||||
EVT_PAINT( wxControl::OnPaint )
|
||||
END_EVENT_TABLE()
|
||||
#endif
|
||||
|
||||
@@ -89,7 +89,7 @@ ControlDefUPP wxMacControlActionUPP = NULL ;
|
||||
|
||||
pascal SInt32 wxMacControlDefintion(SInt16 varCode, ControlRef theControl, ControlDefProcMessage message, SInt32 param)
|
||||
{
|
||||
|
||||
|
||||
wxControl* wx = (wxControl*) wxFindControlFromMacControl( theControl ) ;
|
||||
if ( wx != NULL && wx->IsKindOf( CLASSINFO( wxControl ) ) )
|
||||
{
|
||||
@@ -129,7 +129,7 @@ pascal OSStatus wxMacSetupControlBackground( ControlRef iControl , SInt16 iMessa
|
||||
}
|
||||
return status ;
|
||||
}
|
||||
|
||||
|
||||
wxControl::wxControl()
|
||||
{
|
||||
m_macControl = NULL ;
|
||||
@@ -161,7 +161,7 @@ bool wxControl::Create(wxWindow *parent, wxWindowID id,
|
||||
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);
|
||||
if ( parent )
|
||||
{
|
||||
@@ -203,12 +203,12 @@ void wxControl::SetLabel(const wxString& title)
|
||||
{
|
||||
Str255 maclabel ;
|
||||
wxString label ;
|
||||
|
||||
|
||||
if( wxApp::s_macDefaultEncodingIsPC )
|
||||
label = wxMacMakeMacStringFromPC( m_label ) ;
|
||||
else
|
||||
label = m_label ;
|
||||
|
||||
|
||||
#if TARGET_CARBON
|
||||
c2pstrcpy( (StringPtr) maclabel , label ) ;
|
||||
#else
|
||||
@@ -239,7 +239,7 @@ wxSize wxControl::DoGetBestSize() const
|
||||
}
|
||||
else if ( IsKindOf( CLASSINFO( wxSpinButton ) ) )
|
||||
{
|
||||
bestsize.bottom = 24 ;
|
||||
bestsize.bottom = 24 ;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -255,7 +255,7 @@ wxSize wxControl::DoGetBestSize() const
|
||||
}
|
||||
else
|
||||
bestWidth = bestsize.right - bestsize.left ;
|
||||
|
||||
|
||||
bestWidth += 2 * m_macHorizontalBorder ;
|
||||
|
||||
bestHeight = bestsize.bottom - bestsize.top ;
|
||||
@@ -264,7 +264,7 @@ wxSize wxControl::DoGetBestSize() const
|
||||
|
||||
bestHeight += 2 * m_macVerticalBorder;
|
||||
|
||||
|
||||
|
||||
return wxSize(bestWidth, bestHeight);
|
||||
}
|
||||
|
||||
@@ -313,16 +313,14 @@ void wxRemoveMacControlAssociation(wxControl *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 wxSize& size, long style,
|
||||
const wxValidator& validator,
|
||||
const wxString& name , WXRECTPTR outBounds , unsigned char* maclabel )
|
||||
const wxString& name , WXRECTPTR outBounds , unsigned char* maclabel )
|
||||
{
|
||||
m_label = label ;
|
||||
SetName(name);
|
||||
if ( &validator )
|
||||
SetValidator(validator);
|
||||
|
||||
m_windowStyle = style;
|
||||
parent->AddChild(this);
|
||||
@@ -341,7 +339,7 @@ void wxControl::MacPreControlCreate( wxWindow *parent, wxWindowID id, wxString l
|
||||
m_height = size.y ;
|
||||
m_x = pos.x ;
|
||||
m_y = pos.y ;
|
||||
|
||||
|
||||
((Rect*)outBounds)->top = -10;
|
||||
((Rect*)outBounds)->left = -10;
|
||||
((Rect*)outBounds)->bottom = 0;
|
||||
@@ -365,7 +363,7 @@ void wxControl::MacPreControlCreate( wxWindow *parent, wxWindowID id, wxString l
|
||||
void wxControl::MacPostControlCreate()
|
||||
{
|
||||
wxASSERT_MSG( (ControlHandle) m_macControl != NULL , "No valid mac control" ) ;
|
||||
|
||||
|
||||
if ( IsKindOf( CLASSINFO( wxScrollBar ) ) )
|
||||
{
|
||||
// no font
|
||||
@@ -375,7 +373,7 @@ void wxControl::MacPostControlCreate()
|
||||
ControlFontStyleRec controlstyle ;
|
||||
controlstyle.flags = kControlUseFontMask ;
|
||||
controlstyle.font = kControlFontSmallBoldSystemFont ;
|
||||
|
||||
|
||||
::SetControlFontStyle( (ControlHandle) m_macControl , &controlstyle ) ;
|
||||
}
|
||||
else
|
||||
@@ -383,7 +381,7 @@ void wxControl::MacPostControlCreate()
|
||||
ControlFontStyleRec controlstyle ;
|
||||
controlstyle.flags = kControlUseFontMask ;
|
||||
controlstyle.font = kControlFontSmallSystemFont ;
|
||||
|
||||
|
||||
::SetControlFontStyle( (ControlHandle) m_macControl , &controlstyle ) ;
|
||||
}
|
||||
ControlHandle container = (ControlHandle) GetParent()->MacGetContainerForEmbedding() ;
|
||||
@@ -424,38 +422,38 @@ void wxControl::MacPostControlCreate()
|
||||
#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);
|
||||
|
||||
|
||||
UMAShowControl( (ControlHandle) m_macControl ) ;
|
||||
|
||||
|
||||
SetCursor( *wxSTANDARD_CURSOR ) ;
|
||||
|
||||
|
||||
Refresh() ;
|
||||
}
|
||||
|
||||
void wxControl::MacAdjustControlRect()
|
||||
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 ) )
|
||||
@@ -470,7 +468,7 @@ void wxControl::MacAdjustControlRect()
|
||||
}
|
||||
else if ( IsKindOf( CLASSINFO( wxSpinButton ) ) )
|
||||
{
|
||||
bestsize.bottom = 24 ;
|
||||
bestsize.bottom = 24 ;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -488,7 +486,7 @@ void wxControl::MacAdjustControlRect()
|
||||
}
|
||||
else
|
||||
m_width = bestsize.right - bestsize.left ;
|
||||
|
||||
|
||||
m_width += 2 * m_macHorizontalBorder + MacGetLeftBorderSize() + MacGetRightBorderSize() ;
|
||||
}
|
||||
if ( m_height == -1 )
|
||||
@@ -499,12 +497,12 @@ void wxControl::MacAdjustControlRect()
|
||||
|
||||
m_height += 2 * m_macVerticalBorder + MacGetTopBorderSize() + MacGetBottomBorderSize() ;
|
||||
}
|
||||
MacUpdateDimensions() ;
|
||||
MacUpdateDimensions() ;
|
||||
// UMASizeControl( (ControlHandle) m_macControl , m_width - 2 * m_macHorizontalBorder, m_height - 2 * m_macVerticalBorder ) ;
|
||||
}
|
||||
}
|
||||
|
||||
WXWidget wxControl::MacGetContainerForEmbedding()
|
||||
WXWidget wxControl::MacGetContainerForEmbedding()
|
||||
{
|
||||
if ( m_macControl )
|
||||
return m_macControl ;
|
||||
@@ -512,29 +510,29 @@ WXWidget wxControl::MacGetContainerForEmbedding()
|
||||
return wxWindow::MacGetContainerForEmbedding() ;
|
||||
}
|
||||
|
||||
void wxControl::MacUpdateDimensions()
|
||||
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 ) ;
|
||||
|
||||
|
||||
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 ;
|
||||
@@ -552,19 +550,19 @@ void wxControl::MacUpdateDimensions()
|
||||
}
|
||||
}
|
||||
|
||||
void wxControl::MacSuperChangedPosition()
|
||||
void wxControl::MacSuperChangedPosition()
|
||||
{
|
||||
MacUpdateDimensions() ;
|
||||
wxWindow::MacSuperChangedPosition() ;
|
||||
}
|
||||
|
||||
void wxControl::MacSuperEnabled( bool enabled )
|
||||
void wxControl::MacSuperEnabled( bool enabled )
|
||||
{
|
||||
Refresh(FALSE) ;
|
||||
wxWindow::MacSuperEnabled( enabled ) ;
|
||||
}
|
||||
|
||||
void wxControl::MacSuperShown( bool show )
|
||||
void wxControl::MacSuperShown( bool show )
|
||||
{
|
||||
if ( (ControlHandle) m_macControl )
|
||||
{
|
||||
@@ -585,7 +583,7 @@ void wxControl::MacSuperShown( bool show )
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
wxWindow::MacSuperShown( show ) ;
|
||||
}
|
||||
|
||||
@@ -606,12 +604,12 @@ void wxControl::DoSetSize(int x, int y,
|
||||
Rect oldbounds;
|
||||
int new_x, new_y, new_width, new_height;
|
||||
int mac_x, mac_y;
|
||||
|
||||
|
||||
new_x = m_x;
|
||||
new_y = m_y;
|
||||
new_width = m_width;
|
||||
new_height = m_height;
|
||||
|
||||
|
||||
if (sizeFlags & wxSIZE_ALLOW_MINUS_ONE)
|
||||
{
|
||||
new_x = x;
|
||||
@@ -626,7 +624,7 @@ void wxControl::DoSetSize(int x, int y,
|
||||
if (width != -1) new_width = width;
|
||||
if (height != -1) new_height = height;
|
||||
}
|
||||
|
||||
|
||||
if(sizeFlags & wxSIZE_AUTO)
|
||||
{
|
||||
wxSize size = GetBestSize();
|
||||
@@ -640,7 +638,7 @@ void wxControl::DoSetSize(int x, int y,
|
||||
}
|
||||
}
|
||||
AdjustForParentClientOrigin(new_x, new_y, sizeFlags);
|
||||
|
||||
|
||||
mac_x = new_x;
|
||||
mac_y = new_y;
|
||||
if(GetParent()) {
|
||||
@@ -649,10 +647,10 @@ void wxControl::DoSetSize(int x, int y,
|
||||
GetControlBounds( (ControlHandle) m_macControl, &oldbounds);
|
||||
oldbounds.right = oldbounds.left + m_width;
|
||||
oldbounds.bottom = oldbounds.top + m_height;
|
||||
|
||||
|
||||
bool doMove = false;
|
||||
bool doResize = false;
|
||||
|
||||
|
||||
if ( mac_x != (oldbounds.left - m_macHorizontalBorder) ||
|
||||
mac_y != (oldbounds.top - m_macVerticalBorder) )
|
||||
{
|
||||
@@ -663,11 +661,11 @@ void wxControl::DoSetSize(int x, int y,
|
||||
{
|
||||
doResize = true ;
|
||||
}
|
||||
|
||||
|
||||
if ( doMove || doResize )
|
||||
{
|
||||
Refresh() ;
|
||||
|
||||
|
||||
// Ensure resize is within constraints
|
||||
if ((m_minWidth != -1) && (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)) {
|
||||
new_height = m_maxHeight;
|
||||
}
|
||||
|
||||
|
||||
if ( doMove )
|
||||
{
|
||||
m_x = new_x;
|
||||
m_y = new_y;
|
||||
|
||||
|
||||
UMAMoveControl( (ControlHandle) m_macControl,
|
||||
mac_x + m_macHorizontalBorder, mac_y + m_macVerticalBorder);
|
||||
|
||||
@@ -698,27 +696,27 @@ void wxControl::DoSetSize(int x, int y,
|
||||
{
|
||||
m_width = new_width;
|
||||
m_height = new_height;
|
||||
|
||||
|
||||
UMASizeControl( (ControlHandle) m_macControl,
|
||||
m_width - 2 * m_macHorizontalBorder,
|
||||
m_height - 2 * m_macVerticalBorder ) ;
|
||||
|
||||
|
||||
|
||||
|
||||
wxSizeEvent event(wxSize(m_width, m_height), m_windowId);
|
||||
event.SetEventObject(this);
|
||||
GetEventHandler()->ProcessEvent(event);
|
||||
}
|
||||
|
||||
|
||||
Refresh() ;
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
bool wxControl::Show(bool show)
|
||||
bool wxControl::Show(bool show)
|
||||
{
|
||||
if ( !wxWindow::Show( show ) )
|
||||
return FALSE ;
|
||||
|
||||
|
||||
if ( (ControlHandle) m_macControl )
|
||||
{
|
||||
if ( !show )
|
||||
@@ -741,7 +739,7 @@ bool wxControl::Show(bool show)
|
||||
return TRUE ;
|
||||
}
|
||||
|
||||
bool wxControl::Enable(bool enable)
|
||||
bool wxControl::Enable(bool enable)
|
||||
{
|
||||
if ( !wxWindow::Enable(enable) )
|
||||
return FALSE;
|
||||
@@ -790,15 +788,15 @@ void wxControl::OnPaint(wxPaintEvent& 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 )
|
||||
return ;
|
||||
|
||||
|
||||
EventRecord *ev = (EventRecord*) wxTheApp->MacGetCurrentEvent() ;
|
||||
short keycode ;
|
||||
short keychar ;
|
||||
@@ -808,43 +806,43 @@ void wxControl::OnKeyDown( wxKeyEvent &event )
|
||||
::HandleControlKey( (ControlHandle) m_macControl , keycode , keychar , ev->modifiers ) ;
|
||||
}
|
||||
|
||||
void wxControl::OnMouseEvent( wxMouseEvent &event )
|
||||
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 ;
|
||||
{
|
||||
@@ -854,8 +852,8 @@ void wxControl::OnMouseEvent( wxMouseEvent &event )
|
||||
{
|
||||
controlpart = ::HandleControlClick( control , localwhere , modifiers , (ControlActionUPP) -1 ) ;
|
||||
wxTheApp->s_lastMouseDown = 0 ;
|
||||
if ( control && controlpart != kControlNoPart &&
|
||||
! IsKindOf( CLASSINFO( wxScrollBar ) )
|
||||
if ( control && controlpart != kControlNoPart &&
|
||||
! IsKindOf( CLASSINFO( wxScrollBar ) )
|
||||
) // otherwise we will get the event twice for scrollbar
|
||||
{
|
||||
MacHandleControlClick( control , controlpart ) ;
|
||||
@@ -868,14 +866,14 @@ void wxControl::OnMouseEvent( wxMouseEvent &event )
|
||||
|
||||
bool wxControl::MacCanFocus() const
|
||||
{
|
||||
{ if ( (ControlHandle) m_macControl == NULL )
|
||||
return true ;
|
||||
{ if ( (ControlHandle) m_macControl == NULL )
|
||||
return true ;
|
||||
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" ) ;
|
||||
}
|
||||
|
Reference in New Issue
Block a user