X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/ce63f2e9eb49fb50a6dbd188f29116a670c9f922..4ae5ada038560a7fe793e9152f86d1d35b40f439:/src/osx/window_osx.cpp?ds=inline diff --git a/src/osx/window_osx.cpp b/src/osx/window_osx.cpp index bb67d1afb3..cb3e871efd 100644 --- a/src/osx/window_osx.cpp +++ b/src/osx/window_osx.cpp @@ -4,7 +4,6 @@ // Author: Stefan Csomor // Modified by: // Created: 1998-01-01 -// RCS-ID: $Id$ // Copyright: (c) Stefan Csomor // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -350,7 +349,11 @@ void wxWindowMac::SetPeer(wxOSXWidgetImpl* peer) GetParent()->MacChildAdded() ; // adjust font, controlsize etc - DoSetWindowVariant( m_windowVariant ) ; + GetPeer()->SetControlSize( m_windowVariant ); + InheritAttributes(); + // in case nothing has been set, use the variant default fonts + if ( !m_hasFont ) + DoSetWindowVariant( m_windowVariant ); GetPeer()->SetLabel( wxStripMenuCodes(m_label, wxStrip_Mnemonics), GetFont().GetEncoding() ) ; @@ -383,7 +386,7 @@ bool wxWindowMac::MacIsUserPane() const /* * Right now we have the following setup : * a border that is not part of the native control is always outside the - * control's border (otherwise we loose all native intelligence, future ways + * control's border (otherwise we lose all native intelligence, future ways * may be to have a second embedding control responsible for drawing borders * and backgrounds eventually) * so all this border calculations have to be taken into account when calling @@ -412,6 +415,9 @@ bool wxWindowMac::Create(wxWindowMac *parent, m_windowVariant = parent->GetWindowVariant() ; + m_hScrollBarAlwaysShown = + m_vScrollBarAlwaysShown = HasFlag(wxALWAYS_SHOW_SB); + if ( m_peer != kOSXNoWidgetImpl ) { SetPeer(wxWidgetImpl::CreateUserPane( this, parent, id, pos, size , style, GetExtraStyle() )); @@ -602,6 +608,27 @@ void wxWindowMac::SetFocus() GetPeer()->SetFocus() ; } +void wxWindowMac::OSXSimulateFocusEvents() +{ + wxWindow* former = FindFocus() ; + if ( former != NULL && former != this ) + { + { + wxFocusEvent event( wxEVT_KILL_FOCUS, former->GetId()); + event.SetEventObject(former); + event.SetWindow(this); + former->HandleWindowEvent(event) ; + } + + { + wxFocusEvent event(wxEVT_SET_FOCUS, former->GetId()); + event.SetEventObject(former); + event.SetWindow(this); + former->HandleWindowEvent(event); + } + } +} + void wxWindowMac::DoCaptureMouse() { wxApp::s_captureWindow = (wxWindow*) this ; @@ -847,9 +874,22 @@ void wxWindowMac::DoGetClientSize( int *x, int *y ) const #endif if (x) - *x = ww; + { + // we shouldn't return invalid width + if ( ww < 0 ) + ww = 0; + + *x = ww; + } + if (y) - *y = hh; + { + // we shouldn't return invalid height + if ( hh < 0 ) + hh = 0; + + *y = hh; + } } bool wxWindowMac::SetCursor(const wxCursor& cursor) @@ -1035,11 +1075,7 @@ void wxWindowMac::DoMoveWindow(int x, int y, int width, int height) if ( doResize ) { MacRepositionScrollBars() ; - MacOnInternalSize(); - wxSize size(actualWidth, actualHeight); - wxSizeEvent event(size, m_windowId); - event.SetEventObject(this); - HandleWindowEvent(event); + SendSizeEvent(); } } } @@ -1093,6 +1129,12 @@ wxSize wxWindowMac::DoGetBestSize() const } } +void wxWindowMac::SendSizeEvent(int flags) +{ + MacOnInternalSize(); + wxWindowBase::SendSizeEvent(flags); +} + // set the size of the window: if the dimensions are positive, just use them, // but if any of them is equal to -1, it means that we must find the value for // it ourselves (unless sizeFlags contains wxSIZE_ALLOW_MINUS_ONE flag, in @@ -1119,10 +1161,7 @@ void wxWindowMac::DoSetSize(int x, int y, int width, int height, int sizeFlags) if (sizeFlags & wxSIZE_FORCE_EVENT) { - MacOnInternalSize(); - wxSizeEvent event( wxSize(width,height), GetId() ); - event.SetEventObject( this ); - HandleWindowEvent( event ); + SendSizeEvent(); } return; @@ -1195,7 +1234,7 @@ void wxWindowMac::DoSetClientSize(int clientwidth, int clientheight) } } -float wxWindowMac::GetContentScaleFactor() const +double wxWindowMac::GetContentScaleFactor() const { return GetPeer()->GetContentScaleFactor(); } @@ -1281,7 +1320,6 @@ void wxWindowMac::MacHiliteChanged() void wxWindowMac::MacEnabledStateChanged() { - OnEnabled( GetPeer()->IsEnabled() ); } // @@ -1362,27 +1400,23 @@ void wxWindowMac::Refresh(bool WXUNUSED(eraseBack), const wxRect *rect) if ( !IsShownOnScreen() ) return ; + + if ( IsFrozen() ) + return; GetPeer()->SetNeedsDisplay( rect ) ; } void wxWindowMac::DoFreeze() { -#if wxOSX_USE_CARBON if ( GetPeer() && GetPeer()->IsOk() ) GetPeer()->SetDrawingEnabled( false ) ; -#endif } void wxWindowMac::DoThaw() { -#if wxOSX_USE_CARBON if ( GetPeer() && GetPeer()->IsOk() ) - { GetPeer()->SetDrawingEnabled( true ) ; - GetPeer()->InvalidateWithChildren() ; - } -#endif } wxWindow *wxGetActiveWindow() @@ -1658,10 +1692,7 @@ void wxWindowMac::DoUpdateScrollbarVisibility() MacRepositionScrollBars() ; if ( triggerSizeEvent ) { - MacOnInternalSize(); - wxSizeEvent event(GetSize(), m_windowId); - event.SetEventObject(this); - HandleWindowEvent(event); + SendSizeEvent(); } #endif } @@ -1795,6 +1826,8 @@ bool wxWindowMac::MacSetupCursor( const wxPoint& pt ) if ( wxRect2DInt( clientorigin.x , clientorigin.y , clientsize.x , clientsize.y ).Contains( wxPoint2DInt( pt ) ) ) { wxSetCursorEvent event( pt.x , pt.y ); + event.SetId(GetId()); + event.SetEventObject(this); bool processedEvtSetCursor = HandleWindowEvent(event); if ( processedEvtSetCursor && event.HasCursor() ) @@ -2170,7 +2203,8 @@ bool wxWindowMac::MacHasScrollBarCorner() const const wxFrame *frame = wxDynamicCast( win, wxFrame ) ; if ( frame ) { - if ( frame->GetWindowStyleFlag() & wxRESIZE_BORDER ) + // starting from 10.7 there are no resize indicators anymore + if ( (frame->GetWindowStyleFlag() & wxRESIZE_BORDER) && UMAGetSystemVersion() < 0x1070) { // Parent frame has resize handle wxPoint frameBottomRight = frame->GetScreenRect().GetBottomRight(); @@ -2602,7 +2636,7 @@ wxHotKeyHandler(EventHandlerCallRef WXUNUSED(nextHandler), UInt32 modifiers ; UInt32 when = EventTimeToTicks( GetEventTime( event ) ) ; - GetEventParameter( event, kEventParamKeyMacCharCodes, typeChar, NULL, sizeof(char), NULL, &charCode ); + GetEventParameter( event, kEventParamKeyMacCharCodes, typeChar, NULL, 1, NULL, &charCode ); GetEventParameter( event, kEventParamKeyCode, typeUInt32, NULL, sizeof(UInt32), NULL, &keyCode ); GetEventParameter( event, kEventParamKeyModifiers, typeUInt32, NULL, sizeof(UInt32), NULL, &modifiers ); @@ -2720,13 +2754,13 @@ bool wxWindowMac::OSXHandleKeyEvent( wxKeyEvent& event ) { wxEvtHandler * const handler = ancestor->GetEventHandler(); - wxCommandEvent command_event( wxEVT_COMMAND_MENU_SELECTED, command ); + wxCommandEvent command_event( wxEVT_MENU, 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); + command_event.SetEventType(wxEVT_BUTTON); handled = handler->ProcessEvent( command_event ); } @@ -2755,6 +2789,10 @@ bool wxWindowMac::OSXHandleKeyEvent( wxKeyEvent& event ) // wxWidgetImpl // +// we are maintaining a n:1 map from native controls (ControlRef / NSView*) to their wxWidgetImpl +// n:1 because we might have an embedded view eg within a scrollview, both being part of the same impl +// the impl is calling Associate with its newly created native control(s), e.g. in InstallHandler + WX_DECLARE_HASH_MAP(WXWidget, wxWidgetImpl*, wxPointerHash, wxPointerEqual, MacControlMap); static MacControlMap wxWinMacControlList; @@ -2854,3 +2892,7 @@ bool wxWidgetImpl::NeedsFrame() const { return m_needsFrame; } + +void wxWidgetImpl::SetDrawingEnabled(bool WXUNUSED(enabled)) +{ +}