#include "wx/dnd.h"
#endif
+#include "wx/graphics.h"
+
#if wxOSX_USE_CARBON
#include "wx/osx/uma.h"
#else
#include "wx/osx/private.h"
-// bring in themeing
-#include <Carbon/Carbon.h>
#endif
#define MAC_SCROLLBAR_SIZE 15
#endif
BEGIN_EVENT_TABLE(wxWindowMac, wxWindowBase)
- EVT_NC_PAINT(wxWindowMac::OnNcPaint)
- EVT_ERASE_BACKGROUND(wxWindowMac::OnEraseBackground)
- EVT_PAINT(wxWindowMac::OnPaint)
EVT_MOUSE_EVENTS(wxWindowMac::OnMouseEvent)
END_EVENT_TABLE()
// 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()
{
SendDestroyEvent();
- m_isBeingDeleted = true;
-
MacInvalidateBorders() ;
#ifndef __WXUNIVERSAL__
if ( frame )
{
if ( frame->GetLastFocus() == this )
- frame->SetLastFocus((wxWindow*)NULL);
+ frame->SetLastFocus(NULL);
break;
}
}
// 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 ;
WXWidget wxWindowMac::GetHandle() const
{
- return (WXWidget) m_peer->GetWXWidget() ;
+ if ( m_peer )
+ return (WXWidget) m_peer->GetWXWidget() ;
+ return NULL;
}
-//
-// TODO END move to window_osx.cpp
-//
-
// ---------------------------------------------------------------------------
// Utility Routines to move between different coordinate systems
// ---------------------------------------------------------------------------
#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)
{
wxASSERT_MSG( m_peer != NULL && m_peer->IsOk() , wxT("No valid mac control") ) ;
-#if wxOSX_USE_CARBON
- m_peer->SetReference( (URefCon) this ) ;
-#endif
-
GetParent()->AddChild( this );
-#if wxOSX_USE_CARBON
m_peer->InstallEventHandler();
+ m_peer->Embed(GetParent()->GetPeer());
- ControlRef container = (ControlRef) GetParent()->GetHandle() ;
- wxASSERT_MSG( container != NULL , wxT("No valid mac container control") ) ;
- ::EmbedControl( m_peer->GetControlRef() , container ) ;
-#endif
GetParent()->MacChildAdded() ;
// adjust font, controlsize etc
m_peer->SetLabel( wxStripMenuCodes(m_label, wxStrip_Mnemonics), GetFont().GetEncoding() ) ;
- if (!m_macIsUserPane)
+ // for controls we want to use best size for wxDefaultSize params )
+ if ( !m_macIsUserPane )
SetInitialSize(size);
SetCursor( *wxSTANDARD_CURSOR ) ;
return;
m_peer->SetControlSize( variant );
-#if wxOSX_USE_COCOA_OR_CARBON
- wxFont font ;
-
#if wxOSX_USE_CARBON
ControlSize size ;
- ThemeFontID themeFont = kThemeSystemFont ;
// we will get that from the settings later
// and make this NORMAL later, but first
{
case wxWINDOW_VARIANT_NORMAL :
size = kControlSizeNormal;
- themeFont = kThemeSystemFont ;
break ;
case wxWINDOW_VARIANT_SMALL :
size = kControlSizeSmall;
- themeFont = kThemeSmallSystemFont ;
break ;
case wxWINDOW_VARIANT_MINI :
// not always defined in the headers
size = 3 ;
- themeFont = 109 ;
break ;
case wxWINDOW_VARIANT_LARGE :
size = kControlSizeLarge;
- themeFont = kThemeSystemFont ;
break ;
default:
- wxFAIL_MSG(_T("unexpected window variant"));
+ wxFAIL_MSG(wxT("unexpected window variant"));
break ;
}
-
m_peer->SetData<ControlSize>(kControlEntireControl, kControlSizeTag, &size ) ;
- font.MacCreateFromThemeFont( themeFont ) ;
-#else
- CTFontUIFontType themeFont = kCTFontSystemFontType ;
+#endif
+
+
switch ( variant )
{
case wxWINDOW_VARIANT_NORMAL :
- themeFont = kCTFontSystemFontType;
+ static wxFont sysNormal(wxOSX_SYSTEM_FONT_NORMAL);
+ SetFont(sysNormal) ;
break ;
case wxWINDOW_VARIANT_SMALL :
- themeFont = kCTFontSmallSystemFontType;
+ static wxFont sysSmall(wxOSX_SYSTEM_FONT_SMALL);
+ SetFont(sysSmall) ;
break ;
case wxWINDOW_VARIANT_MINI :
- themeFont = kCTFontMiniSystemFontType;
+ static wxFont sysMini(wxOSX_SYSTEM_FONT_MINI);
+ SetFont(sysMini) ;
break ;
case wxWINDOW_VARIANT_LARGE :
- themeFont = kCTFontSystemFontType;
+ 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.MacCreateFromUIFont( themeFont ) ;
-#endif
-
- SetFont( font ) ;
-#endif
}
void wxWindowMac::MacUpdateControlFont()
{
-
- m_peer->SetFont( GetFont() , GetForegroundColour() , GetWindowStyle() ) ;
+ if ( m_peer )
+ m_peer->SetFont( GetFont() , GetForegroundColour() , GetWindowStyle() ) ;
// do not trigger refreshes upon invisible and possible partly created objects
if ( IsShownOnScreen() )
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 ;
return true ;
}
+static bool wxIsWindowOrParentDisabled(wxWindow* w)
+{
+ while (w && !w->IsTopLevel())
+ {
+ if (!w->IsEnabled())
+ return true;
+ w = w->GetParent();
+ }
+ return false;
+}
+
void wxWindowMac::SetFocus()
{
if ( !AcceptsFocus() )
return ;
+ if (wxIsWindowOrParentDisabled((wxWindow*) this))
+ return;
+
wxWindow* former = FindFocus() ;
if ( former == this )
return ;
void wxWindowMac::DoCaptureMouse()
{
wxApp::s_captureWindow = (wxWindow*) this ;
+ m_peer->CaptureMouse() ;
}
wxWindow * wxWindowBase::GetCapture()
void wxWindowMac::DoReleaseMouse()
{
wxApp::s_captureWindow = NULL ;
+
+ m_peer->ReleaseMouse() ;
}
#if wxUSE_DRAG_AND_DROP
void wxWindowMac::SetDropTarget(wxDropTarget *pDropTarget)
{
- if ( m_dropTarget != NULL )
- delete m_dropTarget;
+ delete m_dropTarget;
m_dropTarget = pDropTarget;
if ( m_dropTarget != NULL )
x = (int)pos.x;
y = (int)pos.y;
- // TODO: the default calls may be used as soon as PostCreateControl Is moved here
- w = wxMax(size.x, 0) ; // WidthDefault( size.x );
- h = wxMax(size.y, 0) ; // HeightDefault( size.y ) ;
+ w = WidthDefault( size.x );
+ h = HeightDefault( size.y );
x += MacGetLeftBorderSize() ;
y += MacGetTopBorderSize() ;
AdjustForParentClientOrigin( x , y ) ;
// this is in window relative coordinate, as this parent may have a border, its physical position is offset by this border
- if ( !GetParent()->IsTopLevel() )
+ if ( GetParent() && !GetParent()->IsTopLevel() )
{
x -= GetParent()->MacGetLeftBorderSize() ;
y -= GetParent()->MacGetTopBorderSize() ;
void wxWindowMac::DoGetPosition(int *x, int *y) const
{
int x1, y1;
-
+
m_peer->GetPosition( x1, y1 ) ;
// get the wx window position from the native one
int innerwidth, innerheight;
int left, top;
int outerwidth, outerheight;
-
+
m_peer->GetContentArea( left, top, innerwidth, innerheight );
m_peer->GetSize( outerwidth, outerheight );
-
- sizeTotal.x += left + (outerwidth-innerwidth);
- sizeTotal.y += top + (outerheight-innerheight);
-
+
+ sizeTotal.x += outerwidth-innerwidth;
+ sizeTotal.y += outerheight-innerheight;
+
sizeTotal.x += MacGetLeftBorderSize() + MacGetRightBorderSize() ;
sizeTotal.y += MacGetTopBorderSize() + MacGetBottomBorderSize() ;
int ww, hh;
int left, top;
-
- m_peer->GetContentArea( left, top, ww, hh );
+ 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)
wxASSERT_MSG( m_cursor.Ok(),
wxT("cursor must be valid after call to the base version"));
- wxWindowMac *mouseWin = 0 ;
-#if wxOSX_USE_CARBON
- {
- wxNonOwnedWindow *tlw = MacGetTopLevelWindow() ;
- WindowRef window = (WindowRef) ( tlw ? tlw->GetWXWindow() : 0 ) ;
-
- ControlPartCode part ;
- ControlRef control ;
- Point pt ;
- #if MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_5
- HIPoint hiPoint ;
- HIGetMousePosition(kHICoordSpaceWindow, window, &hiPoint);
- pt.h = hiPoint.x;
- pt.v = hiPoint.y;
- #else
- GetGlobalMouse( &pt );
- int x = pt.h;
- int y = pt.v;
- ScreenToClient(&x, &y);
- pt.h = x;
- pt.v = y;
-#endif
- control = FindControlUnderMouse( pt , window , &part ) ;
- if ( control )
- mouseWin = wxFindWindowFromWXWidget( (WXWidget) control ) ;
-
- }
-#endif
-
- if ( mouseWin == this && !wxIsBusy() )
- m_cursor.MacInstall() ;
+ if ( GetPeer() != NULL )
+ GetPeer()->SetCursor( m_cursor );
return true ;
}
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 ) ;
}
-#ifdef __WXOSX_CARBON__
- long menuResult = ::PopUpMenuSelect((MenuHandle) menu->GetHMenu() , y, x, 0) ;
- if ( HiWord(menuResult) != 0 )
- {
- MenuCommand macid;
- GetMenuItemCommandID( GetMenuHandle(HiWord(menuResult)) , LoWord(menuResult) , &macid );
- int id = wxMacCommandToId( macid );
- wxMenuItem* item = NULL ;
- wxMenu* realmenu ;
- item = menu->FindItem( id, &realmenu ) ;
- if ( item )
- {
- if (item->IsCheckable())
- item->Check( !item->IsChecked() ) ;
-
- menu->SendEvent( id , item->IsCheckable() ? item->IsChecked() : -1 ) ;
- }
- }
-
- menu->MacAfterDisplay( true ) ;
- menu->SetInvokingWindow( NULL );
-#else
- menu->SetInvokingWindow( NULL );
- return false;
-#endif
-
+ menu->GetPeer()->PopUp(this, x, y);
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
return ;
int outerBorder = MacGetLeftBorderSize() ;
-#if wxOSX_USE_CARBON
- if ( m_peer->NeedsFocusRect() /* && m_peer->HasFocus() */ )
+
+ if ( m_peer->NeedsFocusRect() )
outerBorder += 4 ;
-#endif
if ( outerBorder == 0 )
return ;
// now we know that we have something to do at all
-
int tx,ty,tw,th;
-
+
m_peer->GetSize( tw, th );
m_peer->GetPosition( tx, ty );
wxRect rightupdate( tx+tw, ty, outerBorder, th );
wxRect topupdate( tx-outerBorder, ty-outerBorder, tw + 2 * outerBorder, outerBorder );
wxRect bottomupdate( tx-outerBorder, ty + th, tw + 2 * outerBorder, outerBorder );
-
- GetParent()->m_peer->SetNeedsDisplay(&leftupdate);
- GetParent()->m_peer->SetNeedsDisplay(&rightupdate);
- GetParent()->m_peer->SetNeedsDisplay(&topupdate);
- GetParent()->m_peer->SetNeedsDisplay(&bottomupdate);
+
+ if (GetParent()) {
+ GetParent()->m_peer->SetNeedsDisplay(&leftupdate);
+ GetParent()->m_peer->SetNeedsDisplay(&rightupdate);
+ GetParent()->m_peer->SetNeedsDisplay(&topupdate);
+ GetParent()->m_peer->SetNeedsDisplay(&bottomupdate);
+ }
}
void wxWindowMac::DoMoveWindow(int x, int y, int width, int height)
int actualX = x;
int actualY = y;
+#if 0
+ // min and max sizes are only for sizers, not for explicit size setting
if ((m_minWidth != -1) && (actualWidth < m_minWidth))
actualWidth = m_minWidth;
if ((m_minHeight != -1) && (actualHeight < m_minHeight))
actualWidth = m_maxWidth;
if ((m_maxHeight != -1) && (actualHeight > m_maxHeight))
actualHeight = m_maxHeight;
+#endif
bool doMove = false, doResize = false ;
wxSize( actualWidth - (MacGetLeftBorderSize() + MacGetRightBorderSize()) ,
actualHeight - (MacGetTopBorderSize() + MacGetBottomBorderSize()) ) ) ;
- if ( !GetParent()->IsTopLevel() )
+ if ( parent && !parent->IsTopLevel() )
{
- bounds.Offset( -GetParent()->MacGetLeftBorderSize(), -GetParent()->MacGetTopBorderSize() );
+ bounds.Offset( -parent->MacGetLeftBorderSize(), -parent->MacGetTopBorderSize() );
}
MacInvalidateBorders() ;
m_cachedClippedRectValid = false ;
-
+
m_peer->Move( bounds.x, bounds.y, bounds.width, bounds.height);
wxWindowMac::MacSuperChangedPosition() ; // like this only children will be notified
else
{
wxRect r ;
-
+
m_peer->GetBestRect(&r);
if ( r.GetWidth() == 0 && r.GetHeight() == 0 )
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() ;
}
}
- int bestWidth = r.width + MacGetLeftBorderSize() +
+ int bestWidth = r.width + MacGetLeftBorderSize() +
MacGetRightBorderSize();
- int bestHeight = r.height + MacGetTopBorderSize() +
+ int bestHeight = r.height + MacGetTopBorderSize() +
MacGetBottomBorderSize();
if ( bestHeight < 10 )
bestHeight = 13 ;
// TODO: REMOVE
MacRepositionScrollBars() ; // we might have a real position shift
+ if (sizeFlags & wxSIZE_FORCE_EVENT)
+ {
+ wxSizeEvent event( wxSize(width,height), GetId() );
+ event.SetEventObject( this );
+ HandleWindowEvent( event );
+ }
+
return;
}
void wxWindowMac::SetLabel(const wxString& title)
{
+ if ( title == m_label )
+ return;
+
m_label = title ;
+ InvalidateBestSize();
+
if ( m_peer && m_peer->IsOk() )
m_peer->SetLabel( wxStripMenuCodes(m_label, wxStrip_Mnemonics), GetFont().GetEncoding() ) ;
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();
}
//
int wxWindowMac::GetCharHeight() const
{
- wxClientDC dc( (wxWindow*)this ) ;
+ wxCoord height;
+ GetTextExtent( wxT("g") , NULL , &height , NULL , NULL , NULL );
- return dc.GetCharHeight() ;
+ return height;
}
int wxWindowMac::GetCharWidth() const
{
- wxClientDC dc( (wxWindow*)this ) ;
+ wxCoord width;
+ GetTextExtent( wxT("g") , &width , NULL , NULL , NULL , NULL );
- return dc.GetCharWidth() ;
+ return width;
}
-void wxWindowMac::GetTextExtent(const wxString& string, int *x, int *y,
- int *descent, int *externalLeading, const wxFont *theFont ) const
+void wxWindowMac::DoGetTextExtent(const wxString& str,
+ int *x, int *y,
+ int *descent,
+ int *externalLeading,
+ const wxFont *theFont) const
{
const wxFont *fontToUse = theFont;
wxFont tempFont;
fontToUse = &tempFont;
}
- wxClientDC dc( (wxWindow*) this ) ;
- wxCoord lx,ly,ld,le ;
- dc.GetTextExtent( string , &lx , &ly , &ld, &le, (wxFont *)fontToUse ) ;
+ wxGraphicsContext* ctx = wxGraphicsContext::Create();
+ ctx->SetFont( *fontToUse, *wxBLACK );
+
+ wxDouble h , d , e , w;
+ ctx->GetTextExtent( str, &w, &h, &d, &e );
+
+ delete ctx;
+
if ( externalLeading )
- *externalLeading = le ;
+ *externalLeading = (wxCoord)(e+0.5);
if ( descent )
- *descent = ld ;
+ *descent = (wxCoord)(d+0.5);
if ( x )
- *x = lx ;
+ *x = (wxCoord)(w+0.5);
if ( y )
- *y = ly ;
+ *y = (wxCoord)(h+0.5);
}
/*
if ( !IsShownOnScreen() )
return ;
-
+
m_peer->SetNeedsDisplay( rect ) ;
}
}
// 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.
-}
-
-void wxWindowMac::OnEraseBackground(wxEraseEvent& event)
-{
- if ( MacGetTopLevelWindow() == NULL )
- return ;
-/*
-#if TARGET_API_MAC_OSX
- if ( !m_backgroundColour.Ok() || GetBackgroundStyle() == wxBG_STYLE_TRANSPARENT )
- {
- }
- else
+#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
-*/
- if ( GetBackgroundStyle() == wxBG_STYLE_COLOUR )
- {
- event.GetDC()->Clear() ;
- }
- else if ( GetBackgroundStyle() == wxBG_STYLE_CUSTOM )
- {
- // don't skip the event here, custom background means that the app
- // is drawing it itself in its OnPaint(), so don't draw it at all
- // now to avoid flicker
- }
- else
- {
- event.Skip() ;
- }
-}
-
-void wxWindowMac::OnNcPaint( wxNcPaintEvent& event )
-{
- event.Skip() ;
}
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 ) ;
int tx,ty,tw,th;
-
+
m_peer->GetSize( tw, th );
m_peer->GetPosition( tx, ty );
int size = m_hScrollBar ? m_hScrollBar->GetSize().y : ( m_vScrollBar ? m_vScrollBar->GetSize().x : MAC_SCROLLBAR_SIZE ) ;
CGRect cgrect = CGRectMake( rect.right - size , rect.bottom - size , size , size ) ;
- CGPoint cgpoint = CGPointMake( rect.right - size , rect.bottom - size ) ;
CGContextSaveGState( cgContext );
if ( m_backgroundColour.Ok() )
}
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) )
// back to the surrounding frame rectangle
int tx,ty,tw,th;
-
+
m_peer->GetSize( tw, th );
m_peer->GetPosition( tx, ty );
CGRect cgrect = CGRectMake( rect.left , rect.top , rect.right - rect.left ,
rect.bottom - rect.top ) ;
- HIThemeFrameDrawInfo info ;
- memset( &info, 0 , sizeof(info) ) ;
-
- info.version = 0 ;
- info.kind = 0 ;
- info.state = IsEnabled() ? kThemeStateActive : kThemeStateInactive ;
- info.isFocused = hasFocus ;
-
CGContextRef cgContext = (CGContextRef) GetParent()->MacGetCGContextRef() ;
wxASSERT( cgContext ) ;
- if ( HasFlag(wxRAISED_BORDER) || HasFlag(wxSUNKEN_BORDER) || HasFlag(wxDOUBLE_BORDER) )
+ if ( m_peer->NeedsFrame() )
{
- info.kind = kHIThemeFrameTextFieldSquare ;
- HIThemeDrawFrame( &cgrect , &info , cgContext , kHIThemeOrientationNormal ) ;
- }
- else if ( HasFlag(wxSIMPLE_BORDER) )
- {
- info.kind = kHIThemeFrameListBox ;
- HIThemeDrawFrame( &cgrect , &info , cgContext , kHIThemeOrientationNormal ) ;
+ HIThemeFrameDrawInfo info ;
+ memset( &info, 0 , sizeof(info) ) ;
+
+ info.version = 0 ;
+ info.kind = 0 ;
+ info.state = IsEnabled() ? kThemeStateActive : kThemeStateInactive ;
+ info.isFocused = hasFocus ;
+
+ if ( HasFlag(wxRAISED_BORDER) || HasFlag(wxSUNKEN_BORDER) || HasFlag(wxDOUBLE_BORDER) )
+ {
+ info.kind = kHIThemeFrameTextFieldSquare ;
+ HIThemeDrawFrame( &cgrect , &info , cgContext , kHIThemeOrientationNormal ) ;
+ }
+ else if ( HasFlag(wxSIMPLE_BORDER) )
+ {
+ info.kind = kHIThemeFrameListBox ;
+ HIThemeDrawFrame( &cgrect , &info , cgContext , kHIThemeOrientationNormal ) ;
+ }
}
- else if ( hasFocus )
+
+ if ( hasFocus )
{
HIThemeDrawFocusRect( &cgrect , true , cgContext , kHIThemeOrientationNormal ) ;
}
-#if 0 // TODO REMOVE now done in a separate call earlier in drawing the window itself
- m_peer->GetRect( &rect ) ;
- if ( MacHasScrollBarCorner() )
- {
- int variant = (m_hScrollBar == NULL ? m_vScrollBar : m_hScrollBar ) ->GetWindowVariant();
- int size = m_hScrollBar ? m_hScrollBar->GetSize().y : ( m_vScrollBar ? m_vScrollBar->GetSize().x : MAC_SCROLLBAR_SIZE ) ;
- CGRect cgrect = CGRectMake( rect.right - size , rect.bottom - size , size , size ) ;
- CGPoint cgpoint = CGPointMake( rect.right - size , rect.bottom - size ) ;
- HIThemeGrowBoxDrawInfo info ;
- memset( &info, 0, sizeof(info) ) ;
- info.version = 0 ;
- info.state = IsEnabled() ? kThemeStateActive : kThemeStateInactive ;
- info.kind = kHIThemeGrowBoxKindNone ;
- // contrary to the docs ...SizeSmall does not work
- info.size = kHIThemeGrowBoxSizeNormal ;
- info.direction = 0 ;
- HIThemeDrawGrowBox( &cgpoint , &info , cgContext , kHIThemeOrientationNormal ) ;
- }
-#endif
}
#endif // wxOSX_USE_COCOA_OR_CARBON
}
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
}
-// Get the window with the focus
wxWindow *wxWindowBase::DoFindFocus()
{
-#if wxOSX_USE_CARBON
- ControlRef control ;
- GetKeyboardFocus( GetUserFocusWindow() , &control ) ;
- return wxFindWindowFromWXWidget( (WXWidget) control ) ;
-#else
- return NULL;
-#endif
+ return wxFindWindowFromWXWidget(wxWidgetImpl::FindFocus());
}
void wxWindowMac::OnInternalIdle()
Rect rIncludingOuterStructures ;
int tx,ty,tw,th;
-
+
m_peer->GetSize( tw, th );
m_peer->GetPosition( tx, ty );
/*
This function must not change the updatergn !
*/
-bool wxWindowMac::MacDoRedraw( void* updatergnr , long time )
+bool wxWindowMac::MacDoRedraw( long time )
{
bool handled = false ;
-#if wxOSX_USE_CARBON
- Rect updatebounds ;
- RgnHandle updatergn = (RgnHandle) updatergnr ;
- GetRegionBounds( updatergn , &updatebounds ) ;
- // wxLogDebug(wxT("update for %s bounds %d, %d, %d, %d"), wxString(GetClassInfo()->GetClassName()).c_str(), updatebounds.left, updatebounds.top , updatebounds.right , updatebounds.bottom ) ;
+ wxRegion formerUpdateRgn = m_updateRegion;
+ wxRegion clientUpdateRgn = formerUpdateRgn;
+
+ const wxRect clientRect = GetClientRect();
- if ( !EmptyRgn(updatergn) )
+ clientUpdateRgn.Intersect(clientRect);
+
+ // first send an erase event to the entire update area
+ const wxBackgroundStyle bgStyle = GetBackgroundStyle();
+ switch ( bgStyle )
{
- RgnHandle newupdate = NewRgn() ;
- wxSize point = GetClientSize() ;
- wxPoint origin = GetClientAreaOrigin() ;
- SetRectRgn( newupdate , origin.x , origin.y , origin.x + point.x , origin.y + point.y ) ;
- SectRgn( newupdate , updatergn , newupdate ) ;
+ 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
+ // be drawing with full alpha and eg put blue into the grow-box
+ // area of a scrolled window (scroll sample)
+ wxWindowDC dc(this);
+ if ( IsTopLevel() )
+ dc.SetDeviceClippingRegion(formerUpdateRgn);
+ else
+ dc.SetDeviceClippingRegion(clientUpdateRgn);
- // first send an erase event to the entire update area
- {
- // for the toplevel window this really is the entire area
- // for all the others only their client area, otherwise they
- // might be drawing with full alpha and eg put blue into
- // the grow-box area of a scrolled window (scroll sample)
- wxDC* dc = new wxWindowDC(this);
- if ( IsTopLevel() )
- dc->SetClippingRegion(wxRegion(HIShapeCreateWithQDRgn(updatergn)));
- else
- dc->SetClippingRegion(wxRegion(HIShapeCreateWithQDRgn(newupdate)));
+ if ( bgStyle == wxBG_STYLE_ERASE )
+ {
+ wxEraseEvent eevent( GetId(), &dc );
+ eevent.SetEventObject( this );
+ if ( ProcessWindowEvent( eevent ) )
+ break;
+ }
- wxEraseEvent eevent( GetId(), dc );
- eevent.SetEventObject( this );
- HandleWindowEvent( eevent );
- delete dc ;
- }
+ 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;
- MacPaintGrowBox();
+ default:
+ wxFAIL_MSG( "unsupported background style" );
+ }
- // calculate a client-origin version of the update rgn and set m_updateRegion to that
- OffsetRgn( newupdate , -origin.x , -origin.y ) ;
- m_updateRegion = wxRegion(HIShapeCreateWithQDRgn(newupdate)) ;
- DisposeRgn( newupdate ) ;
+ // as this is a full window, shouldn't be necessary anymore
+ // MacPaintGrowBox();
- if ( !m_updateRegion.Empty() )
- {
- // paint the window itself
+ // calculate a client-origin version of the update rgn and set
+ // m_updateRegion to that
+ clientUpdateRgn.Offset(-clientRect.GetPosition());
+ m_updateRegion = clientUpdateRgn ;
- wxPaintEvent event;
- event.SetTimestamp(time);
- event.SetEventObject(this);
- HandleWindowEvent(event);
- handled = true ;
- }
+ if ( !m_updateRegion.Empty() )
+ {
+ // paint the window itself
+
+ wxPaintEvent event(GetId());
+ event.SetTimestamp(time);
+ event.SetEventObject(this);
+ handled = HandleWindowEvent(event);
+ }
+
+ m_updateRegion = formerUpdateRgn;
+ return handled;
+}
+
+void wxWindowMac::MacPaintChildrenBorders()
+{
+ // now we cannot rely on having its borders drawn by a window itself, as it does not
+ // get the updateRgn wide enough to always do so, so we do it from the parent
+ // this would also be the place to draw any custom backgrounds for native controls
+ // in Composited windowing
+ wxPoint clientOrigin = GetClientAreaOrigin() ;
+
+ wxWindowMac *child;
+ int x, y, w, h;
+ for (wxWindowList::compatibility_iterator node = GetChildren().GetFirst(); node; node = node->GetNext())
+ {
+ 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())
+ continue;
+
+ // only draw those in the update region (add a safety margin of 10 pixels for shadow effects
- // now we cannot rely on having its borders drawn by a window itself, as it does not
- // get the updateRgn wide enough to always do so, so we do it from the parent
- // this would also be the place to draw any custom backgrounds for native controls
- // in Composited windowing
- wxPoint clientOrigin = GetClientAreaOrigin() ;
+ child->GetPosition( &x, &y );
+ child->GetSize( &w, &h );
- wxWindowMac *child;
- int x, y, w, h;
- for (wxWindowList::compatibility_iterator node = GetChildren().GetFirst(); node; node = node->GetNext())
+ if ( m_updateRegion.Contains(clientOrigin.x+x-10, clientOrigin.y+y-10, w+20, h+20) )
{
- child = node->GetData();
- if (child == NULL)
- continue;
- if (child == m_vScrollBar)
- continue;
- if (child == m_hScrollBar)
- continue;
- if (child->IsTopLevel())
- continue;
- if (!child->IsShown())
- continue;
-
- // only draw those in the update region (add a safety margin of 10 pixels for shadow effects
-
- child->GetPosition( &x, &y );
- child->GetSize( &w, &h );
- Rect childRect = { y , x , y + h , x + w } ;
- OffsetRect( &childRect , clientOrigin.x , clientOrigin.y ) ;
- InsetRect( &childRect , -10 , -10) ;
-
- if ( RectInRgn( &childRect , updatergn ) )
+ // paint custom borders
+ wxNcPaintEvent eventNc( child->GetId() );
+ eventNc.SetEventObject( child );
+ if ( !child->HandleWindowEvent( eventNc ) )
{
- // paint custom borders
- wxNcPaintEvent eventNc( child->GetId() );
- eventNc.SetEventObject( child );
- if ( !child->HandleWindowEvent( eventNc ) )
- {
- child->MacPaintBorders(0, 0) ;
- }
+ child->MacPaintBorders(0, 0) ;
}
}
}
-#endif
- return handled ;
}
WXWindow wxWindowMac::MacGetTopLevelWindowRef() const
{
- wxNonOwnedWindow* tlw = MacGetTopLevelWindow();
+ wxNonOwnedWindow* tlw = MacGetTopLevelWindow();
return tlw ? tlw->GetWXWindow() : NULL ;
}
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
{
- return m_peer->CanFocus() && wxWindowBase::AcceptsFocus();
+ if ( MacIsUserPane() )
+ return wxWindowBase::AcceptsFocus();
+ else
+ return m_peer->CanFocus();
}
void wxWindowMac::MacSuperChangedPosition()
SInt32 border = 0 ;
- if (HasFlag(wxRAISED_BORDER) || HasFlag( wxSUNKEN_BORDER) || HasFlag(wxDOUBLE_BORDER))
+ if ( m_peer && m_peer->NeedsFrame() )
{
+ if (HasFlag(wxRAISED_BORDER) || HasFlag( wxSUNKEN_BORDER) || HasFlag(wxDOUBLE_BORDER))
+ {
#if wxOSX_USE_COCOA_OR_CARBON
- // this metric is only the 'outset' outside the simple frame rect
- GetThemeMetric( kThemeMetricEditTextFrameOutset , &border ) ;
- border += 1;
+ // this metric is only the 'outset' outside the simple frame rect
+ GetThemeMetric( kThemeMetricEditTextFrameOutset , &border ) ;
+ border += 1;
#else
- border += 2;
+ border += 2;
#endif
- }
- else if (HasFlag(wxSIMPLE_BORDER))
- {
+ }
+ else if (HasFlag(wxSIMPLE_BORDER))
+ {
#if wxOSX_USE_COCOA_OR_CARBON
- // this metric is only the 'outset' outside the simple frame rect
- GetThemeMetric( kThemeMetricListBoxFrameOutset , &border ) ;
- border += 1;
+ // this metric is only the 'outset' outside the simple frame rect
+ GetThemeMetric( kThemeMetricListBoxFrameOutset , &border ) ;
+ border += 1;
#else
- border += 1;
+ border += 1;
#endif
+ }
}
return border ;
}
}
-void wxWindowMac::OnPaint( wxPaintEvent & WXUNUSED(event) )
-{
-#if wxOSX_USE_COCOA_OR_CARBON
- // for native controls: call their native paint method
- if ( !MacIsUserPane() || ( IsTopLevel() && GetBackgroundStyle() == wxBG_STYLE_SYSTEM ) )
- {
- if ( wxTheApp->MacGetCurrentEvent() != NULL && wxTheApp->MacGetCurrentEventHandlerCallRef() != NULL
- && GetBackgroundStyle() != wxBG_STYLE_TRANSPARENT )
- CallNextEventHandler(
- (EventHandlerCallRef)wxTheApp->MacGetCurrentEventHandlerCallRef() ,
- (EventRef) wxTheApp->MacGetCurrentEvent() ) ;
- }
-#endif
-}
-
-void wxWindowMac::MacHandleControlClick(WXWidget WXUNUSED(control),
- wxInt16 WXUNUSED(controlpart),
- bool WXUNUSED(mouseStillDown))
+void wxWindowMac::TriggerScrollEvent( wxEventType WXUNUSED(scrollEvent) )
{
}
return bounds ;
}
-bool wxWindowMac::HandleClicked( double timestampsec )
+bool wxWindowMac::OSXHandleClicked( double WXUNUSED(timestampsec) )
{
return false;
}
wxInt32 wxWindowMac::MacControlHit(WXEVENTHANDLERREF WXUNUSED(handler) , WXEVENTREF event )
{
#if wxOSX_USE_COCOA_OR_CARBON
- if ( HandleClicked( GetEventTime((EventRef)event) ) )
+ if ( OSXHandleClicked( GetEventTime((EventRef)event) ) )
return noErr;
-
+
return eventNotHandledErr ;
#else
return 0;
m_peer->RemoveFromParent();
m_peer->Embed( GetParent()->GetPeer() );
+
+ MacChildAdded();
return true;
}
return wxWindowBase::IsShownOnScreen();
}
+bool wxWindowMac::OSXHandleKeyEvent( wxKeyEvent& event )
+{
+ bool handled = HandleWindowEvent( event ) ;
+ if ( handled && event.GetSkipped() )
+ handled = false ;
+
+#if wxUSE_ACCEL
+ if ( !handled && event.GetEventType() == wxEVT_KEY_DOWN)
+ {
+ wxWindow *ancestor = this;
+ while (ancestor)
+ {
+ int command = ancestor->GetAcceleratorTable()->GetCommand( event );
+ if (command != -1)
+ {
+ wxEvtHandler * const handler = ancestor->GetEventHandler();
+
+ wxCommandEvent command_event( wxEVT_COMMAND_MENU_SELECTED, command );
+ handled = handler->ProcessEvent( command_event );
+
+ if ( !handled )
+ {
+ // accelerators can also be used with buttons, try them too
+ command_event.SetEventType(wxEVT_COMMAND_BUTTON_CLICKED);
+ handled = handler->ProcessEvent( command_event );
+ }
+
+ break;
+ }
+
+ if (ancestor->IsTopLevel())
+ break;
+
+ ancestor = ancestor->GetParent();
+ }
+ }
+#endif // wxUSE_ACCEL
+
+ return handled ;
+}
+
//
-// wxWidgetImpl
+// wxWidgetImpl
//
+WX_DECLARE_HASH_MAP(WXWidget, wxWidgetImpl*, wxPointerHash, wxPointerEqual, MacControlMap);
+
+static MacControlMap wxWinMacControlList;
+
+wxWindowMac *wxFindWindowFromWXWidget(WXWidget inControl )
+{
+ wxWidgetImpl* impl = wxWidgetImpl::FindFromWXWidget( inControl );
+ if ( impl )
+ return impl->GetWXPeer();
+
+ return NULL;
+}
+
+wxWidgetImpl *wxWidgetImpl::FindFromWXWidget(WXWidget inControl )
+{
+ MacControlMap::iterator node = wxWinMacControlList.find(inControl);
+
+ return (node == wxWinMacControlList.end()) ? NULL : node->second;
+}
+
+void wxWidgetImpl::Associate(WXWidget inControl, wxWidgetImpl *impl)
+{
+ // adding NULL ControlRef is (first) surely a result of an error and
+ // (secondly) breaks native event processing
+ wxCHECK_RET( inControl != (WXWidget) NULL, wxT("attempt to add a NULL WXWidget to control map") );
+
+ wxWinMacControlList[inControl] = impl;
+}
+
+void wxWidgetImpl::RemoveAssociations(wxWidgetImpl* impl)
+{
+ // iterate over all the elements in the class
+ // is the iterator stable ? as we might have two associations pointing to the same wxWindow
+ // we should go on...
+
+ bool found = true ;
+ while ( found )
+ {
+ found = false ;
+ MacControlMap::iterator it;
+ for ( it = wxWinMacControlList.begin(); it != wxWinMacControlList.end(); ++it )
+ {
+ if ( it->second == impl )
+ {
+ wxWinMacControlList.erase(it);
+ found = true ;
+ break;
+ }
+ }
+ }
+}
+
IMPLEMENT_ABSTRACT_CLASS( wxWidgetImpl , wxObject )
wxWidgetImpl::wxWidgetImpl( wxWindowMac* peer , bool isRootControl )
Init();
m_isRootControl = isRootControl;
m_wxPeer = peer;
+ m_shouldSendEvents = true;
}
wxWidgetImpl::wxWidgetImpl()
m_isRootControl = false;
m_wxPeer = NULL;
m_needsFocusRect = false;
+ m_needsFrame = true;
}
void wxWidgetImpl::SetNeedsFocusRect( bool needs )
return m_needsFocusRect;
}
+void wxWidgetImpl::SetNeedsFrame( bool needs )
+{
+ m_needsFrame = needs;
+}
+
+bool wxWidgetImpl::NeedsFrame() const
+{
+ return m_needsFrame;
+}