#include "wx/osx/uma.h"
#else
#include "wx/osx/private.h"
-// bring in themeing
-#include <Carbon/Carbon.h>
#endif
#define MAC_SCROLLBAR_SIZE 15
// implementation
// ===========================================================================
+// the grow box has to be implemented as an inactive window, so that nothing can direct
+// the focus to it
+
+class WXDLLIMPEXP_CORE wxBlindPlateWindow : public wxWindow
+{
+public:
+ wxBlindPlateWindow() { Init(); }
+
+ // Old-style constructor (no default values for coordinates to avoid
+ // ambiguity with the new one)
+ wxBlindPlateWindow(wxWindow *parent,
+ int x, int y, int width, int height,
+ long style = wxTAB_TRAVERSAL | wxNO_BORDER,
+ const wxString& name = wxPanelNameStr)
+ {
+ Init();
+
+ Create(parent, wxID_ANY, wxPoint(x, y), wxSize(width, height), style, name);
+ }
+
+ // Constructor
+ wxBlindPlateWindow(wxWindow *parent,
+ wxWindowID winid = wxID_ANY,
+ const wxPoint& pos = wxDefaultPosition,
+ const wxSize& size = wxDefaultSize,
+ long style = wxTAB_TRAVERSAL | wxNO_BORDER,
+ const wxString& name = wxPanelNameStr)
+ {
+ Init();
+
+ Create(parent, winid, pos, size, style, name);
+ }
+
+ // Pseudo ctor
+ bool Create(wxWindow *parent,
+ wxWindowID winid = wxID_ANY,
+ const wxPoint& pos = wxDefaultPosition,
+ const wxSize& size = wxDefaultSize,
+ long style = wxTAB_TRAVERSAL | wxNO_BORDER,
+ const wxString& name = wxPanelNameStr)
+ {
+ if ( !wxWindow::Create(parent, winid, pos, size, style, name) )
+ return false;
+
+ // so that non-solid background renders correctly under GTK+:
+ SetThemeEnabled(true);
+ return true;
+ }
+
+ virtual ~wxBlindPlateWindow();
+
+ virtual bool AcceptsFocus() const
+ {
+ return false;
+ }
+
+protected:
+ // common part of all ctors
+ void Init()
+ {
+ }
+
+ DECLARE_DYNAMIC_CLASS_NO_COPY(wxBlindPlateWindow)
+ DECLARE_EVENT_TABLE()
+};
+
+wxBlindPlateWindow::~wxBlindPlateWindow()
+{
+}
+
+IMPLEMENT_DYNAMIC_CLASS(wxBlindPlateWindow, wxWindow)
+
+BEGIN_EVENT_TABLE(wxBlindPlateWindow, wxWindow)
+END_EVENT_TABLE()
+
+
// ----------------------------------------------------------------------------
// constructors and such
// ----------------------------------------------------------------------------
m_vScrollBar = NULL ;
m_hScrollBarAlwaysShown = false;
m_vScrollBarAlwaysShown = false;
+ m_growBox = NULL ;
m_macIsUserPane = true;
m_clipChildren = false ;
m_cachedClippedRectValid = false ;
+ m_isNativeWindowWrapper = false;
}
wxWindowMac::~wxWindowMac()
// delete our drop target if we've got one
#if wxUSE_DRAG_AND_DROP
- if ( m_dropTarget != NULL )
- {
- delete m_dropTarget;
- m_dropTarget = NULL;
- }
+ wxDELETE(m_dropTarget);
#endif
delete m_peer ;
#ifndef __WXUNIVERSAL__
// Don't give scrollbars to wxControls unless they ask for them
- if ( (! IsKindOf(CLASSINFO(wxControl)) && ! IsKindOf(CLASSINFO(wxStatusBar)))
+ if ( (! IsKindOf(CLASSINFO(wxControl))
+#if wxUSE_STATUSBAR
+ && ! IsKindOf(CLASSINFO(wxStatusBar))
+#endif
+ )
|| (IsKindOf(CLASSINFO(wxControl)) && ((style & wxHSCROLL) || (style & wxVSCROLL))))
{
MacCreateScrollBars( style ) ;
void wxWindowMac::MacChildAdded()
{
+#if wxUSE_SCROLLBAR
if ( m_vScrollBar )
m_vScrollBar->Raise() ;
if ( m_hScrollBar )
m_hScrollBar->Raise() ;
+ if ( m_growBox )
+ m_growBox->Raise() ;
+#endif
}
void wxWindowMac::MacPostControlCreate(const wxPoint& WXUNUSED(pos), const wxSize& size)
break ;
default:
- wxFAIL_MSG(_T("unexpected window variant"));
+ wxFAIL_MSG(wxT("unexpected window variant"));
break ;
}
m_peer->SetData<ControlSize>(kControlEntireControl, kControlSizeTag, &size ) ;
#endif
- wxFont font ;
-
- wxOSXSystemFont systemFont = wxOSX_SYSTEM_FONT_NORMAL ;
switch ( variant )
{
case wxWINDOW_VARIANT_NORMAL :
- systemFont = wxOSX_SYSTEM_FONT_NORMAL ;
+ static wxFont sysNormal(wxOSX_SYSTEM_FONT_NORMAL);
+ SetFont(sysNormal) ;
break ;
case wxWINDOW_VARIANT_SMALL :
- systemFont = wxOSX_SYSTEM_FONT_SMALL ;
+ static wxFont sysSmall(wxOSX_SYSTEM_FONT_SMALL);
+ SetFont(sysSmall) ;
break ;
case wxWINDOW_VARIANT_MINI :
- systemFont = wxOSX_SYSTEM_FONT_MINI ;
+ static wxFont sysMini(wxOSX_SYSTEM_FONT_MINI);
+ SetFont(sysMini) ;
break ;
case wxWINDOW_VARIANT_LARGE :
- systemFont = wxOSX_SYSTEM_FONT_NORMAL ;
+ static wxFont sysLarge(wxOSX_SYSTEM_FONT_NORMAL);
+ SetFont(sysLarge) ;
break ;
default:
- wxFAIL_MSG(_T("unexpected window variant"));
+ wxFAIL_MSG(wxT("unexpected window variant"));
break ;
}
-
- font.CreateSystemFont( systemFont ) ;
-
- SetFont( font ) ;
}
void wxWindowMac::MacUpdateControlFont()
return retval;
}
+bool wxWindowMac::SetBackgroundStyle(wxBackgroundStyle style)
+{
+ if ( !wxWindowBase::SetBackgroundStyle(style) )
+ return false;
+
+ if ( m_peer )
+ m_peer->SetBackgroundStyle(style);
+ return true;
+}
+
bool wxWindowMac::SetBackgroundColour(const wxColour& col )
{
+ if (m_growBox)
+ {
+ if ( m_backgroundColour.Ok() )
+ m_growBox->SetBackgroundColour(m_backgroundColour);
+ else
+ m_growBox->SetBackgroundColour(*wxWHITE);
+ }
+
if ( !wxWindowBase::SetBackgroundColour(col) && m_hasBgCol )
return false ;
int left, top;
m_peer->GetContentArea( left, top, ww, hh );
-
+#if wxUSE_SCROLLBAR
if (m_hScrollBar && m_hScrollBar->IsShown() )
hh -= m_hScrollBar->GetSize().y ;
if (m_vScrollBar && m_vScrollBar->IsShown() )
ww -= m_vScrollBar->GetSize().x ;
+#endif
if (x)
*x = ww;
if (y)
bool wxWindowMac::DoPopupMenu(wxMenu *menu, int x, int y)
{
#ifndef __WXUNIVERSAL__
- menu->SetInvokingWindow((wxWindow*)this);
menu->UpdateUI();
if ( x == wxDefaultCoord && y == wxDefaultCoord )
ClientToScreen( &x , &y ) ;
}
menu->GetPeer()->PopUp(this, x, y);
- menu->SetInvokingWindow( NULL );
return true;
#else
// actually this shouldn't be called, because universal is having its own implementation
if ( m_tooltip )
m_tooltip->SetWindow(this);
+
+ if (m_peer)
+ m_peer->SetToolTip(tooltip);
}
#endif
r.width =
r.height = 16 ;
+#if wxUSE_SCROLLBAR
if ( IsKindOf( CLASSINFO( wxScrollBar ) ) )
{
r.height = 16 ;
}
- #if wxUSE_SPINBTN
- else if ( IsKindOf( CLASSINFO( wxSpinButton ) ) )
+ else
+#endif
+#if wxUSE_SPINBTN
+ if ( IsKindOf( CLASSINFO( wxSpinButton ) ) )
{
r.height = 24 ;
}
- #endif
else
+#endif
{
// return wxWindowBase::DoGetBestSize() ;
}
void wxWindowMac::SetLabel(const wxString& title)
{
+ if ( title == m_label )
+ return;
+
m_label = title ;
- if ( m_peer && m_peer->IsOk() && !(IsKindOf( CLASSINFO(wxButton) ) && GetId() == wxID_HELP) )
+ InvalidateBestSize();
+
+ if ( m_peer && m_peer->IsOk() )
m_peer->SetLabel( wxStripMenuCodes(m_label, wxStrip_Mnemonics), GetFont().GetEncoding() ) ;
// do not trigger refreshes upon invisible and possible partly created objects
if ( m_peer )
m_peer->SetVisibility( show ) ;
+#ifdef __WXOSX_IPHONE__
+ // only when there's no native event support
+ if ( !IsTopLevel() )
+#endif
+ {
+ wxShowEvent eventShow(GetId(), show);
+ eventShow.SetEventObject(this);
+
+ HandleWindowEvent(eventShow);
+ }
+
+ return true;
+}
+
+bool wxWindowMac::OSXShowWithEffect(bool show,
+ wxShowEffect effect,
+ unsigned timeout)
+{
+ if ( effect == wxSHOW_EFFECT_NONE ||
+ !m_peer || !m_peer->ShowWithEffect(show, effect, timeout) )
+ return Show(show);
+
return true;
}
void wxWindowMac::DoEnable(bool enable)
{
m_peer->Enable( enable ) ;
+ MacInvalidateBorders();
}
//
}
// Coordinates relative to the window
-void wxWindowMac::WarpPointer(int WXUNUSED(x_pos), int WXUNUSED(y_pos))
+void wxWindowMac::WarpPointer(int x_pos, int y_pos)
{
- // We really don't move the mouse programmatically under Mac.
+#if wxOSX_USE_COCOA_OR_CARBON
+ int x = x_pos;
+ int y = y_pos;
+ DoClientToScreen(&x, &y);
+ CGPoint cgpoint = CGPointMake( x, y );
+ CGWarpMouseCursorPosition( cgpoint );
+
+ // At least GTK sends a mouse moved event after WarpMouse
+ wxMouseEvent event(wxEVT_MOTION);
+ event.m_x = x_pos;
+ event.m_y = y_pos;
+ wxMouseState mState = ::wxGetMouseState();
+
+ event.m_altDown = mState.AltDown();
+ event.m_controlDown = mState.ControlDown();
+ event.m_leftDown = mState.LeftIsDown();
+ event.m_middleDown = mState.MiddleIsDown();
+ event.m_rightDown = mState.RightIsDown();
+ event.m_metaDown = mState.MetaDown();
+ event.m_shiftDown = mState.ShiftDown();
+ event.SetId(GetId());
+ event.SetEventObject(this);
+ GetEventHandler()->ProcessEvent(event);
+#endif
}
int wxWindowMac::GetScrollPos(int orient) const
{
+#if wxUSE_SCROLLBAR
if ( orient == wxHORIZONTAL )
{
if ( m_hScrollBar )
if ( m_vScrollBar )
return m_vScrollBar->GetThumbPosition() ;
}
-
+#endif
return 0;
}
// of positions that we can scroll.
int wxWindowMac::GetScrollRange(int orient) const
{
+#if wxUSE_SCROLLBAR
if ( orient == wxHORIZONTAL )
{
if ( m_hScrollBar )
if ( m_vScrollBar )
return m_vScrollBar->GetRange() ;
}
-
+#endif
return 0;
}
int wxWindowMac::GetScrollThumb(int orient) const
{
+#if wxUSE_SCROLLBAR
if ( orient == wxHORIZONTAL )
{
if ( m_hScrollBar )
if ( m_vScrollBar )
return m_vScrollBar->GetThumbSize() ;
}
-
+#endif
return 0;
}
void wxWindowMac::SetScrollPos(int orient, int pos, bool WXUNUSED(refresh))
{
+#if wxUSE_SCROLLBAR
if ( orient == wxHORIZONTAL )
{
if ( m_hScrollBar )
if ( m_vScrollBar )
m_vScrollBar->SetThumbPosition( pos ) ;
}
+#endif
}
void
if ( IsTopLevel() )
return ;
+#if wxUSE_SCROLLBAR
if ( MacHasScrollBarCorner() )
{
+#if 0
CGContextRef cgContext = (CGContextRef) MacGetCGContextRef() ;
wxASSERT( cgContext ) ;
}
CGContextFillRect( cgContext, cgrect );
CGContextRestoreGState( cgContext );
+#else
+ if (m_growBox)
+ {
+ if ( m_backgroundColour.Ok() )
+ m_growBox->SetBackgroundColour(m_backgroundColour);
+ else
+ m_growBox->SetBackgroundColour(*wxWHITE);
+ }
+#endif
}
+
+#endif
}
void wxWindowMac::MacPaintBorders( int WXUNUSED(leftOrigin) , int WXUNUSED(rightOrigin) )
void wxWindowMac::RemoveChild( wxWindowBase *child )
{
+#if wxUSE_SCROLLBAR
if ( child == m_hScrollBar )
m_hScrollBar = NULL ;
if ( child == m_vScrollBar )
m_vScrollBar = NULL ;
-
+ if ( child == m_growBox )
+ m_growBox = NULL ;
+#endif
wxWindowBase::RemoveChild( child ) ;
}
void wxWindowMac::DoUpdateScrollbarVisibility()
{
+#if wxUSE_SCROLLBAR
bool triggerSizeEvent = false;
if ( m_hScrollBar )
event.SetEventObject(this);
HandleWindowEvent(event);
}
+#endif
}
// New function that will replace some of the above.
void wxWindowMac::SetScrollbar(int orient, int pos, int thumb,
int range, bool refresh)
{
+#if wxUSE_SCROLLBAR
if ( orient == wxHORIZONTAL && m_hScrollBar )
m_hScrollBar->SetScrollbar(pos, thumb, range, thumb, refresh);
else if ( orient == wxVERTICAL && m_vScrollBar )
m_vScrollBar->SetScrollbar(pos, thumb, range, thumb, refresh);
DoUpdateScrollbarVisibility();
+#endif
}
// Does a physical scroll
child = node->GetData();
if (child == NULL)
continue;
- if (child == m_vScrollBar)
- continue;
- if (child == m_hScrollBar)
- continue;
+
if (child->IsTopLevel())
continue;
+ if ( !IsClientAreaChild(child) )
+ continue;
+
child->GetPosition( &x, &y );
child->GetSize( &w, &h );
if (rect)
void wxWindowMac::MacOnScroll( wxScrollEvent &event )
{
+#if wxUSE_SCROLLBAR
if ( event.GetEventObject() == m_vScrollBar || event.GetEventObject() == m_hScrollBar )
{
wxScrollWinEvent wevent;
HandleWindowEvent(wevent);
}
+#endif
}
wxWindow *wxWindowBase::DoFindFocus()
{
case wxBG_STYLE_ERASE:
case wxBG_STYLE_SYSTEM:
+ case wxBG_STYLE_COLOUR:
{
// for the toplevel window this really is the entire area for
// all the others only their client area, otherwise they might
break;
}
- if ( UseBgCol() && MacGetTopLevelWindow() )
+ if ( UseBgCol() )
{
dc.SetBackground(GetBackgroundColour());
dc.Clear();
break;
case wxBG_STYLE_PAINT:
+ case wxBG_STYLE_TRANSPARENT:
// nothing to do, user-defined EVT_PAINT handler will overwrite the
// entire window client area
break;
wxFAIL_MSG( "unsupported background style" );
}
- MacPaintGrowBox();
+ // as this is a full window, shouldn't be necessary anymore
+ // MacPaintGrowBox();
// calculate a client-origin version of the update rgn and set
// m_updateRegion to that
child = node->GetData();
if (child == NULL)
continue;
+#if wxUSE_SCROLLBAR
if (child == m_vScrollBar)
continue;
if (child == m_hScrollBar)
continue;
+ if (child == m_growBox)
+ continue;
+#endif
if (child->IsTopLevel())
continue;
if (!child->IsShown())
bool wxWindowMac::MacHasScrollBarCorner() const
{
+#if wxUSE_SCROLLBAR
/* Returns whether the scroll bars in a wxScrolledWindow should be
* shortened. Scroll bars should be shortened if either:
*
// No parent frame found
return false ;
}
+#else
+ return false;
+#endif
}
void wxWindowMac::MacCreateScrollBars( long style )
{
+#if wxUSE_SCROLLBAR
wxASSERT_MSG( m_vScrollBar == NULL && m_hScrollBar == NULL , wxT("attempt to create window twice") ) ;
if ( style & ( wxVSCROLL | wxHSCROLL ) )
m_hScrollBar = new wxScrollBar((wxWindow*)this, wxID_ANY, hPoint, hSize , wxHORIZONTAL);
m_hScrollBar->SetMinSize( wxDefaultSize );
}
+
+ wxPoint gPoint(width - scrlsize, height - scrlsize);
+ wxSize gSize(scrlsize, scrlsize);
+ m_growBox = new wxBlindPlateWindow((wxWindow *)this, wxID_ANY, gPoint, gSize, 0);
}
// because the create does not take into account the client area origin
// we might have a real position shift
MacRepositionScrollBars() ;
+#endif
}
bool wxWindowMac::MacIsChildOfClientArea( const wxWindow* child ) const
{
- bool result = ((child == NULL) || ((child != m_hScrollBar) && (child != m_vScrollBar)));
+ bool result = ((child == NULL)
+#if wxUSE_SCROLLBAR
+ || ((child != m_hScrollBar) && (child != m_vScrollBar) && (child != m_growBox))
+#endif
+ );
return result ;
}
void wxWindowMac::MacRepositionScrollBars()
{
+#if wxUSE_SCROLLBAR
if ( !m_hScrollBar && !m_vScrollBar )
return ;
m_vScrollBar->SetSize( vPoint.x , vPoint.y, vSize.x, vSize.y , wxSIZE_ALLOW_MINUS_ONE );
if ( m_hScrollBar )
m_hScrollBar->SetSize( hPoint.x , hPoint.y, hSize.x, hSize.y, wxSIZE_ALLOW_MINUS_ONE );
+ if ( m_growBox )
+ {
+ if ( MacHasScrollBarCorner() )
+ {
+ m_growBox->SetSize( width - scrlsize, height - scrlsize, wxDefaultCoord, wxDefaultCoord, wxSIZE_USE_EXISTING );
+ if ( !m_growBox->IsShown() )
+ m_growBox->Show();
+ }
+ else
+ {
+ if ( m_growBox->IsShown() )
+ m_growBox->Hide();
+ }
+ }
+#endif
}
bool wxWindowMac::AcceptsFocus() const
m_peer->RemoveFromParent();
m_peer->Embed( GetParent()->GetPeer() );
+
+ MacChildAdded();
return true;
}
Init();
m_isRootControl = isRootControl;
m_wxPeer = peer;
+ m_shouldSendEvents = true;
}
wxWidgetImpl::wxWidgetImpl()