diff options
Diffstat (limited to 'vcl/inc/osx')
-rw-r--r-- | vcl/inc/osx/a11yfactory.h | 40 | ||||
-rw-r--r-- | vcl/inc/osx/a11yfocustracker.hxx | 97 | ||||
-rw-r--r-- | vcl/inc/osx/a11ylistener.hxx | 49 | ||||
-rw-r--r-- | vcl/inc/osx/a11ywrapper.h | 121 | ||||
-rw-r--r-- | vcl/inc/osx/keyboardfocuslistener.hxx | 35 | ||||
-rw-r--r-- | vcl/inc/osx/osxvcltypes.h | 30 | ||||
-rw-r--r-- | vcl/inc/osx/printview.h | 63 | ||||
-rw-r--r-- | vcl/inc/osx/runinmain.hxx | 175 | ||||
-rw-r--r-- | vcl/inc/osx/saldata.hxx | 109 | ||||
-rw-r--r-- | vcl/inc/osx/salframe.h | 233 | ||||
-rw-r--r-- | vcl/inc/osx/salframeview.h | 278 | ||||
-rw-r--r-- | vcl/inc/osx/salinst.h | 168 | ||||
-rw-r--r-- | vcl/inc/osx/salmenu.h | 112 | ||||
-rw-r--r-- | vcl/inc/osx/salnativewidgets.h | 69 | ||||
-rw-r--r-- | vcl/inc/osx/salnsmenu.h | 53 | ||||
-rw-r--r-- | vcl/inc/osx/salnstimer.h | 35 | ||||
-rw-r--r-- | vcl/inc/osx/salobj.h | 71 | ||||
-rw-r--r-- | vcl/inc/osx/salprn.h | 156 | ||||
-rw-r--r-- | vcl/inc/osx/salsys.h | 44 | ||||
-rw-r--r-- | vcl/inc/osx/saltimer.h | 75 | ||||
-rw-r--r-- | vcl/inc/osx/svsys.h | 29 | ||||
-rw-r--r-- | vcl/inc/osx/vclnsapp.h | 68 |
22 files changed, 2110 insertions, 0 deletions
diff --git a/vcl/inc/osx/a11yfactory.h b/vcl/inc/osx/a11yfactory.h new file mode 100644 index 0000000000..9ef837dfaa --- /dev/null +++ b/vcl/inc/osx/a11yfactory.h @@ -0,0 +1,40 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#pragma once + +#include "osxvcltypes.h" +#include "a11ywrapper.h" +#include <com/sun/star/accessibility/XAccessibleContext.hpp> + +@interface AquaA11yFactory : NSObject +{ +} ++(void)insertIntoWrapperRepository: (AquaA11yWrapper *) element forAccessibleContext: (css::uno::Reference < css::accessibility::XAccessibleContext >) rxAccessibleContext; ++(AquaA11yWrapper *)wrapperForAccessible: (css::uno::Reference < css::accessibility::XAccessible >) rxAccessible; ++(AquaA11yWrapper *)wrapperForAccessibleContext: (css::uno::Reference < css::accessibility::XAccessibleContext >) rxAccessibleContext; ++(AquaA11yWrapper *)wrapperForAccessibleContext: (css::uno::Reference < css::accessibility::XAccessibleContext >) rxAccessibleContext createIfNotExists:(BOOL) bCreate; ++(AquaA11yWrapper *)wrapperForAccessibleContext: (css::uno::Reference < css::accessibility::XAccessibleContext >) rxAccessibleContext createIfNotExists:(BOOL) bCreate asRadioGroup:(BOOL) asRadioGroup; ++(void)removeFromWrapperRepositoryFor: (css::uno::Reference < css::accessibility::XAccessibleContext >) rxAccessibleContext; ++(void)registerWrapper: (AquaA11yWrapper *) theWrapper; ++(void)revokeWrapper: (AquaA11yWrapper *) theWrapper; +@end + + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/osx/a11yfocustracker.hxx b/vcl/inc/osx/a11yfocustracker.hxx new file mode 100644 index 0000000000..aafa9944de --- /dev/null +++ b/vcl/inc/osx/a11yfocustracker.hxx @@ -0,0 +1,97 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#pragma once + +#include <com/sun/star/accessibility/XAccessible.hpp> + +#include "keyboardfocuslistener.hxx" + +#include <tools/link.hxx> +#include <vcl/vclevent.hxx> +#include <set> + +namespace vcl { class Window; } +class ToolBox; +class DocumentFocusListener; + + +class AquaA11yFocusTracker +{ + +public: + AquaA11yFocusTracker(); + + ~AquaA11yFocusTracker(); + + css::uno::Reference< css::accessibility::XAccessible > const & getFocusedObject() { return m_xFocusedObject; }; + + // sets the currently focus object and notifies the FocusEventListener (if any) + void setFocusedObject(const css::uno::Reference< css::accessibility::XAccessible >& xAccessible); + + // may evolve to add/remove later + void setFocusListener(const rtl::Reference< KeyboardFocusListener >& aFocusListener) { m_aFocusListener = aFocusListener; }; + +protected: + + // received a WINDOW_GETFOCUS event for this window + void window_got_focus(vcl::Window *pWindow); + + // received a TOOLBOX_HIGHLIGHT event for this window + void toolbox_highlight_on(vcl::Window *pWindow); + + // received a TOOLBOX_HIGHLIGHTOFF event for this window + void toolbox_highlight_off(vcl::Window const *pWindow); + + // received a TABPAGE_ACTIVATE event for this window + void tabpage_activated(vcl::Window *pWindow); + + // received a MENU_HIGHLIGHT event for this window + void menu_highlighted(const ::VclMenuEvent *pEvent); + + // toolbox items are widgets in gtk+ and Cocoa + void notify_toolbox_item_focus(ToolBox *pToolBox); + + // toolbox item opened a floating window (e.g. color chooser) + void toolbox_open_floater(vcl::Window *pWindow); + + // callback function for Application::addEventListener + static void WindowEventHandler(void * pThis, VclSimpleEvent&); + +private: + // the accessible object that has the keyboard focus (if any) + css::uno::Reference< css::accessibility::XAccessible > m_xFocusedObject; + + // the listener for focus events + rtl::Reference< KeyboardFocusListener > m_aFocusListener; + + // the list of Windows that need deeper (focus) investigation + std::set<VclPtr<vcl::Window>> m_aDocumentWindowList; + + // the link object needed for Application::addEventListener + Link<VclSimpleEvent&,void> m_aWindowEventLink; + + // the UNO XAccessibilityEventListener for Documents and other non VCL objects + const rtl::Reference< DocumentFocusListener > m_xDocumentFocusListener; +}; + +AquaA11yFocusTracker& TheAquaA11yFocusTracker(); + + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/osx/a11ylistener.hxx b/vcl/inc/osx/a11ylistener.hxx new file mode 100644 index 0000000000..7211e81d46 --- /dev/null +++ b/vcl/inc/osx/a11ylistener.hxx @@ -0,0 +1,49 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#pragma once +#include <com/sun/star/accessibility/XAccessibleEventListener.hpp> +#include <cppuhelper/implbase.hxx> + +#include "a11yfocustracker.hxx" +#include "osxvcltypes.h" +#include <set> +#include <com/sun/star/awt/Rectangle.hpp> + +class AquaA11yEventListener + : public ::cppu::WeakImplHelper<css::accessibility::XAccessibleEventListener> +{ +public: + AquaA11yEventListener(id wrapperObject, sal_Int16 role); + virtual ~AquaA11yEventListener() override; + + // XEventListener + virtual void SAL_CALL disposing(const css::lang::EventObject& Source) override; + + // XAccessibleEventListener + virtual void SAL_CALL + notifyEvent(const css::accessibility::AccessibleEventObject& aEvent) override; + +private: + const id m_wrapperObject; + const sal_Int16 m_role; + css::awt::Rectangle m_oldBounds; +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/osx/a11ywrapper.h b/vcl/inc/osx/a11ywrapper.h new file mode 100644 index 0000000000..1eb4039c57 --- /dev/null +++ b/vcl/inc/osx/a11ywrapper.h @@ -0,0 +1,121 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#pragma once + +#include "osxvcltypes.h" +#include <com/sun/star/accessibility/XAccessibleAction.hpp> +#include <com/sun/star/accessibility/XAccessibleContext.hpp> +#include <com/sun/star/accessibility/XAccessibleComponent.hpp> +#include <com/sun/star/accessibility/XAccessibleExtendedComponent.hpp> +#include <com/sun/star/accessibility/XAccessibleSelection.hpp> +#include <com/sun/star/accessibility/XAccessibleTable.hpp> +#include <com/sun/star/accessibility/XAccessibleText.hpp> +#include <com/sun/star/accessibility/XAccessibleTextAttributes.hpp> +#include <com/sun/star/accessibility/XAccessibleEditableText.hpp> +#include <com/sun/star/accessibility/XAccessibleValue.hpp> +#include <com/sun/star/accessibility/XAccessibleMultiLineText.hpp> +#include <com/sun/star/accessibility/XAccessibleTextMarkup.hpp> + +// rAccessibleXYZ as a field in an Objective-C-Class would not call Con-/Destructor, so use a struct instead +struct ReferenceWrapper +{ + css::uno::Reference < css::accessibility::XAccessibleAction > rAccessibleAction; + css::uno::Reference < css::accessibility::XAccessibleContext > rAccessibleContext; + css::uno::Reference < css::accessibility::XAccessibleComponent > rAccessibleComponent; + css::uno::Reference < css::accessibility::XAccessibleExtendedComponent > rAccessibleExtendedComponent; + css::uno::Reference < css::accessibility::XAccessibleSelection > rAccessibleSelection; + css::uno::Reference < css::accessibility::XAccessibleTable > rAccessibleTable; + css::uno::Reference < css::accessibility::XAccessibleText > rAccessibleText; + css::uno::Reference < css::accessibility::XAccessibleEditableText > rAccessibleEditableText; + css::uno::Reference < css::accessibility::XAccessibleValue > rAccessibleValue; + css::uno::Reference < css::accessibility::XAccessibleTextAttributes > rAccessibleTextAttributes; + css::uno::Reference < css::accessibility::XAccessibleMultiLineText > rAccessibleMultiLineText; + css::uno::Reference < css::accessibility::XAccessibleTextMarkup > rAccessibleTextMarkup; +}; + +@interface AquaA11yWrapper : NSAccessibilityElement + <NSAccessibilityElement, + NSAccessibilityGroup, + NSAccessibilityButton, + NSAccessibilitySwitch, + NSAccessibilityRadioButton, + NSAccessibilityCheckBox, + NSAccessibilityStaticText, + NSAccessibilityNavigableStaticText, + NSAccessibilityProgressIndicator, + NSAccessibilityStepper, + NSAccessibilitySlider, + NSAccessibilityImage> +{ + ReferenceWrapper maReferenceWrapper; + BOOL mActsAsRadioGroup; + BOOL mIsTableCell; +} +// NSAccessibility Protocol +-(id)accessibilityAttributeValue:(NSString *)attribute; +-(BOOL)accessibilityIsIgnored; +-(NSArray *)accessibilityAttributeNames; +-(BOOL)accessibilityIsAttributeSettable:(NSString *)attribute; +-(NSArray *)accessibilityParameterizedAttributeNames; +-(BOOL)accessibilitySetOverrideValue:(id)value forAttribute:(NSString *)attribute; +-(void)accessibilitySetValue:(id)value forAttribute:(NSString *)attribute; +-(id)accessibilityAttributeValue:(NSString *)attribute forParameter:(id)parameter; +-(id)accessibilityFocusedUIElement; +-(NSString *)accessibilityActionDescription:(NSString *)action; +-(void)accessibilityPerformAction:(NSString *)action; +-(BOOL)performAction:(NSString *)action; +-(NSArray *)accessibilityActionNames; +-(id)accessibilityHitTest:(NSPoint)point; +// Attribute values +-(id)parentAttribute; +-(id)valueAttribute; +-(id)titleAttribute; +-(id)helpAttribute; +-(id)numberOfCharactersAttribute; +-(id)selectedTextAttribute; +-(id)selectedTextRangeAttribute; +-(id)visibleCharacterRangeAttribute; +-(id)childrenAttribute; +-(id)orientationAttribute; +-(id)windowAttribute; +// Wrapper-specific +-(void)setActsAsRadioGroup:(BOOL)actsAsRadioGroup; +-(BOOL)actsAsRadioGroup; +-(NSWindow*)windowForParent; +-(id)init; +-(id)initWithAccessibleContext: (css::uno::Reference < css::accessibility::XAccessibleContext >) anAccessibleContext; +-(void) setDefaults: (css::uno::Reference < css::accessibility::XAccessibleContext >) rxAccessibleContext; ++(void)setPopupMenuOpen:(BOOL)popupMenuOpen; +-(css::accessibility::XAccessibleAction *)accessibleAction; +-(css::accessibility::XAccessibleContext *)accessibleContext; +-(css::accessibility::XAccessibleComponent *)accessibleComponent; +-(css::accessibility::XAccessibleExtendedComponent *)accessibleExtendedComponent; +-(css::accessibility::XAccessibleSelection *)accessibleSelection; +-(css::accessibility::XAccessibleTable *)accessibleTable; +-(css::accessibility::XAccessibleText *)accessibleText; +-(css::accessibility::XAccessibleEditableText *)accessibleEditableText; +-(css::accessibility::XAccessibleValue *)accessibleValue; +-(css::accessibility::XAccessibleTextAttributes *)accessibleTextAttributes; +-(css::accessibility::XAccessibleMultiLineText *)accessibleMultiLineText; +-(css::accessibility::XAccessibleTextMarkup *)accessibleTextMarkup; +@end + + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/osx/keyboardfocuslistener.hxx b/vcl/inc/osx/keyboardfocuslistener.hxx new file mode 100644 index 0000000000..f94afaaf4f --- /dev/null +++ b/vcl/inc/osx/keyboardfocuslistener.hxx @@ -0,0 +1,35 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#pragma once + +#include <com/sun/star/accessibility/XAccessible.hpp> + +#include <rtl/ref.hxx> +#include <salhelper/simplereferenceobject.hxx> + +class KeyboardFocusListener : public salhelper::SimpleReferenceObject +{ +public: + virtual void + focusedObjectChanged(const css::uno::Reference<css::accessibility::XAccessible>& xAccessible) + = 0; +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/osx/osxvcltypes.h b/vcl/inc/osx/osxvcltypes.h new file mode 100644 index 0000000000..bf3f4ec46f --- /dev/null +++ b/vcl/inc/osx/osxvcltypes.h @@ -0,0 +1,30 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_VCL_INC_OSX_OSXVCLTYPES_H +#define INCLUDED_VCL_INC_OSX_OSXVCLTYPES_H + +#include <premac.h> +#import <Cocoa/Cocoa.h> +#import <AppKit/NSEvent.h> +#include <postmac.h> + +#endif // INCLUDED_VCL_INC_OSX_OSXVCLTYPES_H + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/osx/printview.h b/vcl/inc/osx/printview.h new file mode 100644 index 0000000000..a2a6e5454e --- /dev/null +++ b/vcl/inc/osx/printview.h @@ -0,0 +1,63 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_VCL_INC_OSX_PRINTVIEW_H +#define INCLUDED_VCL_INC_OSX_PRINTVIEW_H + +#include <premac.h> +#include <Cocoa/Cocoa.h> +#include <postmac.h> + +#include <vcl/print.hxx> + +class AquaSalInfoPrinter; + +struct PrintAccessoryViewState +{ + bool bNeedRestart; + sal_Int32 nLastPage; + + PrintAccessoryViewState() + : bNeedRestart( false ), nLastPage( 0 ) {} +}; + +@interface AquaPrintView : NSView +{ + vcl::PrinterController* mpController; + AquaSalInfoPrinter* mpInfoPrinter; +} +-(id)initWithController: (vcl::PrinterController*)pController + withInfoPrinter: (AquaSalInfoPrinter*)pInfoPrinter; +-(BOOL)knowsPageRange: (NSRangePointer)range; +-(NSRect)rectForPage: (int)page; +-(NSPoint)locationOfPrintRect: (NSRect)aRect; +-(void)drawRect: (NSRect)rect; +@end + +@interface AquaPrintAccessoryView : NSObject +{ +} ++(NSObject*)setupPrinterPanel: (NSPrintOperation*)pOp + withController: (vcl::PrinterController*)pController + withState: (PrintAccessoryViewState*)pState; +@end + +#endif // INCLUDED_VCL_INC_OSX_PRINTVIEW_H + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/osx/runinmain.hxx b/vcl/inc/osx/runinmain.hxx new file mode 100644 index 0000000000..e68bc4d350 --- /dev/null +++ b/vcl/inc/osx/runinmain.hxx @@ -0,0 +1,175 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_VCL_INC_OSX_RUNINMAIN_HXX +#define INCLUDED_VCL_INC_OSX_RUNINMAIN_HXX + +/** + * Runs a command in the main thread. + * + * These macros are always used like a recursive calls, so they work like + * a closure. + * + * Uses two conditionals for a two way communication. + * The data (code block + result) is protected by the SolarMutex. + * + * There are three main macros, which act as function initializers: + * - OSX_RUNINMAIN - for all functions without return values + * - OSX_RUNINMAIN_POINTER - for all functions returning a pointer + * - OSX_RUNINMAIN_UNION - for all other return types + * + * All types used via OSX_RUNINMAIN_UNION must implement a move constructor, + * so there is no memory leak! + */ + +#include <unordered_map> + +#include <Block.h> + +#include <osl/thread.h> + +#include "saltimer.h" +#include <salframe.hxx> +#include <tools/debug.hxx> + +union RuninmainResult +{ + void* pointer; + bool boolean; + struct SalFrame::SalPointerState state; + + RuninmainResult() {} +}; + +#define OSX_RUNINMAIN_MEMBERS \ + std::mutex m_runInMainMutex; \ + std::condition_variable m_aInMainCondition; \ + std::condition_variable m_aResultCondition; \ + bool m_wakeUpMain = false; \ + bool m_resultReady = false; \ + RuninmainBlock m_aCodeBlock; \ + RuninmainResult m_aResult; + +#define OSX_RUNINMAIN( instance, command ) \ + if ( !instance->IsMainThread() ) \ + { \ + DBG_TESTSOLARMUTEX(); \ + SalYieldMutex *aMutex = static_cast<SalYieldMutex*>(instance->GetYieldMutex()); \ + { \ + std::scoped_lock<std::mutex> g(aMutex->m_runInMainMutex); \ + assert( !aMutex->m_aCodeBlock ); \ + aMutex->m_aCodeBlock = Block_copy(^{ \ + command; \ + }); \ + aMutex->m_wakeUpMain = true; \ + aMutex->m_aInMainCondition.notify_all(); \ + } \ + dispatch_async(dispatch_get_main_queue(),^{ \ + ImplNSAppPostEvent( AquaSalInstance::YieldWakeupEvent, NO ); \ + }); \ + { \ + std::unique_lock<std::mutex> g(aMutex->m_runInMainMutex); \ + aMutex->m_aResultCondition.wait( \ + g, [&aMutex]() { return aMutex->m_resultReady; }); \ + aMutex->m_resultReady = false; \ + } \ + return; \ + } + +#define OSX_RUNINMAIN_POINTER( instance, command, type ) \ + if ( !instance->IsMainThread() ) \ + { \ + DBG_TESTSOLARMUTEX(); \ + SalYieldMutex *aMutex = static_cast<SalYieldMutex*>(instance->GetYieldMutex()); \ + { \ + std::scoped_lock<std::mutex> g(aMutex->m_runInMainMutex); \ + assert( !aMutex->m_aCodeBlock ); \ + aMutex->m_aCodeBlock = Block_copy(^{ \ + aMutex->m_aResult.pointer = static_cast<void*>( command ); \ + }); \ + aMutex->m_wakeUpMain = true; \ + aMutex->m_aInMainCondition.notify_all(); \ + } \ + dispatch_async(dispatch_get_main_queue(),^{ \ + ImplNSAppPostEvent( AquaSalInstance::YieldWakeupEvent, NO ); \ + }); \ + { \ + std::unique_lock<std::mutex> g(aMutex->m_runInMainMutex); \ + aMutex->m_aResultCondition.wait( \ + g, [&aMutex]() { return aMutex->m_resultReady; }); \ + aMutex->m_resultReady = false; \ + } \ + return static_cast<type>( aMutex->m_aResult.pointer ); \ + } + +#define OSX_RUNINMAIN_UNION( instance, command, member ) \ + if ( !instance->IsMainThread() ) \ + { \ + DBG_TESTSOLARMUTEX(); \ + SalYieldMutex *aMutex = static_cast<SalYieldMutex*>(instance->GetYieldMutex()); \ + { \ + std::scoped_lock<std::mutex> g(aMutex->m_runInMainMutex); \ + assert( !aMutex->m_aCodeBlock ); \ + aMutex->m_aCodeBlock = Block_copy(^{ \ + aMutex->m_aResult.member = command; \ + }); \ + aMutex->m_wakeUpMain = true; \ + aMutex->m_aInMainCondition.notify_all(); \ + } \ + dispatch_async(dispatch_get_main_queue(),^{ \ + ImplNSAppPostEvent( AquaSalInstance::YieldWakeupEvent, NO ); \ + }); \ + { \ + std::unique_lock<std::mutex> g(aMutex->m_runInMainMutex); \ + aMutex->m_aResultCondition.wait( \ + g, [&aMutex]() { return aMutex->m_resultReady; }); \ + aMutex->m_resultReady = false; \ + } \ + return std::move( aMutex->m_aResult.member ); \ + } + +/** + * convenience macros used from SalInstance + */ + +#define OSX_INST_RUNINMAIN( command ) \ + OSX_RUNINMAIN( this, command ) + +#define OSX_INST_RUNINMAIN_POINTER( command, type ) \ + OSX_RUNINMAIN_POINTER( this, command, type ) + +#define OSX_INST_RUNINMAIN_UNION( command, member ) \ + OSX_RUNINMAIN_UNION( this, command, member ) + +/** + * convenience macros using global SalData + */ + +#define OSX_SALDATA_RUNINMAIN( command ) \ + OSX_RUNINMAIN( GetSalData()->mpInstance, command ) + +#define OSX_SALDATA_RUNINMAIN_POINTER( command, type ) \ + OSX_RUNINMAIN_POINTER( GetSalData()->mpInstance, command, type ) + +#define OSX_SALDATA_RUNINMAIN_UNION( command, member ) \ + OSX_RUNINMAIN_UNION( GetSalData()->mpInstance, command, member ) + +#endif // INCLUDED_VCL_INC_OSX_RUNINMAIN_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/osx/saldata.hxx b/vcl/inc/osx/saldata.hxx new file mode 100644 index 0000000000..ba4d6e8c85 --- /dev/null +++ b/vcl/inc/osx/saldata.hxx @@ -0,0 +1,109 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_VCL_INC_OSX_SALDATA_HXX +#define INCLUDED_VCL_INC_OSX_SALDATA_HXX + +#include <config_features.h> + +#include <premac.h> +#include <Cocoa/Cocoa.h> +#include <postmac.h> + +#include <com/sun/star/uno/Reference.hxx> + +#include <vcl/ptrstyle.hxx> + +#include <svdata.hxx> +#include <salwtype.hxx> + +#include <functional> +#include <list> +#include <map> +#include <memory> +#include <unordered_set> +#include <vector> +#include <o3tl/enumarray.hxx> + +#include <cstdio> +#include <cstdarg> + +#include <apple_remote/RemoteMainController.h> + +class AquaSalFrame; +class AquaSalInstance; +class SalObject; +class SalFrame; +class SalVirtualDevice; +class SalPrinter; +class SystemFontList; + +#define SAL_CLIPRECT_COUNT 16 +#define INVALID_CURSOR_PTR reinterpret_cast<NSCursor*>(0xdeadbeef) + +// Singleton, instantiated from Application::Application() in +// vcl/source/app/svapp.cxx. + +class SalData +{ +public: + SALTIMERPROC mpTimerProc; // timer callback proc + AquaSalInstance *mpInstance; + std::list<AquaSalFrame*> maPresentationFrames; // list of frames in presentation mode + SalObject *mpFirstObject; // pointer of first object window + SalVirtualDevice *mpFirstVD; // first VirDev + SalPrinter *mpFirstPrinter; // first printing printer + std::unique_ptr<SystemFontList> mpFontList; + NSStatusItem* mpStatusItem; // one status item that draws all our statuses + // at the moment this is only one add menu button + CGColorSpaceRef mxRGBSpace; + CGColorSpaceRef mxGraySpace; + + o3tl::enumarray< PointerStyle, NSCursor* > maCursors; + std::vector< NSMenuItem* > maFallbackMenu; + std::map< NSEvent*, bool > maKeyEventAnswer; + + static oslThreadKey s_aAutoReleaseKey; + + bool mbIsScrollbarDoubleMax; // TODO: support DoubleMin and DoubleBoth too +#if !HAVE_FEATURE_MACOSX_SANDBOX + AppleRemoteMainController* mpAppleRemoteMainController; +#endif + NSObject* mpDockIconClickHandler; + sal_Int32 mnDPIX; // #i100617# read DPI only once per office life + sal_Int32 mnDPIY; // #i100617# read DPI only once per office life + + css::uno::Reference< css::uno::XInterface > mxClipboard; + + SalData(); + ~SalData(); + + NSCursor* getCursor( PointerStyle i_eStyle ); + + static void ensureThreadAutoreleasePool(); + + static NSStatusItem* getStatusItem(); +}; + +bool ImplSalYieldMutexTryToAcquire(); +void ImplSalYieldMutexRelease(); + +#endif // INCLUDED_VCL_INC_OSX_SALDATA_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/osx/salframe.h b/vcl/inc/osx/salframe.h new file mode 100644 index 0000000000..717e5f3101 --- /dev/null +++ b/vcl/inc/osx/salframe.h @@ -0,0 +1,233 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_VCL_INC_OSX_SALFRAME_H +#define INCLUDED_VCL_INC_OSX_SALFRAME_H + +#include <premac.h> +#include <IOKit/pwr_mgt/IOPMLib.h> +#include <postmac.h> + +#include <tools/long.hxx> +#include <vcl/sysdata.hxx> + +#include <osx/salinst.h> +#include <osx/salmenu.h> +#include <osx/saldata.hxx> +#include <osx/osxvcltypes.h> + +#include <salframe.hxx> + +#include <vector> +#include <utility> +#include <stdexcept> + +class AquaSalGraphics; +class AquaSalFrame; +class AquaSalTimer; +class AquaSalInstance; +class AquaSalMenu; + +class AquaSalFrame : public SalFrame +{ +public: + NSWindow* mpNSWindow; // Cocoa window + NSView* mpNSView; // Cocoa view (actually a custom view) + NSMenuItem* mpDockMenuEntry; // entry in the dynamic dock menu + NSRect maScreenRect; // for mirroring purposes + AquaSalGraphics* mpGraphics; // current frame graphics + AquaSalFrame* mpParent; // pointer to parent frame + SystemEnvData maSysData; // system data + int mnMinWidth; // min. client width in pixels + int mnMinHeight; // min. client height in pixels + int mnMaxWidth; // max. client width in pixels + int mnMaxHeight; // max. client height in pixels + NSRect maFullScreenRect; // old window size when in FullScreen + bool mbGraphics; // is Graphics used? + bool mbFullScreen; // is Window in FullScreen? + bool mbShown; + bool mbInitShow; + bool mbPositioned; + bool mbSized; + bool mbPresentation; + + SalFrameStyleFlags mnStyle; + unsigned int mnStyleMask; // our style mask from NSWindow creation + + sal_uInt64 mnLastEventTime; + unsigned int mnLastModifierFlags; + AquaSalMenu* mpMenu; + + SalExtStyle mnExtStyle; // currently document frames are marked this way + + PointerStyle mePointerStyle; // currently active pointer style + + NSRect maTrackingRect; + + CGMutablePathRef mrClippingPath; // used for "shaping" + std::vector< CGRect > maClippingRects; + + tools::Rectangle maInvalidRect; + + InputContextFlags mnICOptions; + + // To prevent display sleep during presentation + IOPMAssertionID mnAssertionID; + + NSRect maFrameRect; + NSRect maContentRect; + + bool mbGeometryDidChange; + + int mnBlinkCursorDelay; + + // tdf#155266 force flush after scrolling + bool mbForceFlush; + +public: + /** Constructor + + Creates a system window and connects this frame with it. + + @throws std::runtime_error in case window creation fails + */ + AquaSalFrame( SalFrame* pParent, SalFrameStyleFlags salFrameStyle ); + + virtual ~AquaSalFrame() override; + + virtual SalGraphics* AcquireGraphics() override; + virtual void ReleaseGraphics( SalGraphics* pGraphics ) override; + virtual bool PostEvent(std::unique_ptr<ImplSVEvent> pData) override; + virtual void SetTitle( const OUString& rTitle ) override; + virtual void SetIcon( sal_uInt16 nIcon ) override; + virtual void SetRepresentedURL( const OUString& ) override; + virtual void SetMenu( SalMenu* pSalMenu ) override; + virtual void Show( bool bVisible, bool bNoActivate = false ) override; + virtual void SetMinClientSize( tools::Long nWidth, tools::Long nHeight ) + override; + virtual void SetMaxClientSize( tools::Long nWidth, tools::Long nHeight ) + override; + virtual void SetPosSize( tools::Long nX, tools::Long nY, tools::Long nWidth, tools::Long nHeight, sal_uInt16 nFlags ) override; + virtual void GetClientSize( tools::Long& rWidth, tools::Long& rHeight ) override; + virtual void GetWorkArea( AbsoluteScreenPixelRectangle& rRect ) override; + virtual SalFrame* GetParent() const override; + virtual void SetWindowState(const vcl::WindowData*) override; + virtual bool GetWindowState(vcl::WindowData*) override; + virtual void ShowFullScreen( bool bFullScreen, sal_Int32 nDisplay ) override; + virtual void StartPresentation( bool bStart ) override; + virtual void SetAlwaysOnTop( bool bOnTop ) override; + virtual void ToTop( SalFrameToTop nFlags ) override; + virtual void SetPointer( PointerStyle ePointerStyle ) override; + virtual void CaptureMouse( bool bMouse ) override; + virtual void SetPointerPos( tools::Long nX, tools::Long nY ) override; + virtual void Flush( void ) override; + virtual void Flush( const tools::Rectangle& ) override; + virtual void SetInputContext( SalInputContext* pContext ) override; + virtual void EndExtTextInput( EndExtTextInputFlags nFlags ) override; + virtual OUString GetKeyName( sal_uInt16 nKeyCode ) override; + virtual bool MapUnicodeToKeyCode( sal_Unicode aUnicode, LanguageType aLangType, vcl::KeyCode& rKeyCode ) override; + virtual LanguageType GetInputLanguage() override; + virtual void UpdateSettings( AllSettings& rSettings ) override; + virtual void Beep() override; + virtual const SystemEnvData* GetSystemData() const override; + virtual SalPointerState GetPointerState() override; + virtual KeyIndicatorState GetIndicatorState() override; + virtual void SimulateKeyPress( sal_uInt16 nKeyCode ) override; + virtual void SetParent( SalFrame* pNewParent ) override; + virtual void SetPluginParent( SystemParentData* pNewParent ) override; + virtual void SetExtendedFrameStyle( SalExtStyle ) override; + virtual void SetScreenNumber(unsigned int) override; + virtual void SetApplicationID( const OUString &rApplicationID ) override; + + // shaped system windows + // set clip region to none (-> rectangular windows, normal state) + virtual void ResetClipRegion() override; + // start setting the clipregion consisting of nRects rectangles + virtual void BeginSetClipRegion( sal_uInt32 nRects ) override; + // add a rectangle to the clip region + virtual void UnionClipRegion( + tools::Long nX, tools::Long nY, tools::Long nWidth, tools::Long nHeight ) override; + // done setting up the clipregion + virtual void EndSetClipRegion() override; + virtual void UpdateDarkMode() override; + virtual bool GetUseDarkMode() const override; + virtual bool GetUseReducedAnimation() const override; + + void UpdateFrameGeometry(); + + // trigger painting of the window + void SendPaintEvent( const tools::Rectangle* pRect = nullptr ); + + static inline bool isAlive( const AquaSalFrame* pFrame ); + + static AquaSalFrame* GetCaptureFrame() { return s_pCaptureFrame; } + + NSWindow* getNSWindow() const { return mpNSWindow; } + NSView* getNSView() const { return mpNSView; } + unsigned int getStyleMask() const { return mnStyleMask; } + + void getResolution( sal_Int32& o_rDPIX, sal_Int32& o_rDPIY ); + + // actually the following methods do the same thing: flipping y coordinates + // but having two of them makes clearer what the coordinate system + // is supposed to be before and after + void VCLToCocoa( NSRect& io_rRect, bool bRelativeToScreen = true ); + void CocoaToVCL( NSRect& io_rRect, bool bRelativeToScreen = true ); + + void VCLToCocoa( NSPoint& io_rPoint, bool bRelativeToScreen = true ); + void CocoaToVCL( NSPoint& io_Point, bool bRelativeToScreen = true ); + + NSCursor* getCurrentCursor(); + + CGMutablePathRef getClipPath() const { return mrClippingPath; } + + // called by VCL_NSApplication to indicate screen settings have changed + void screenParametersChanged(); + +protected: + SalEvent PreparePosSize( + tools::Long nX, tools::Long nY, tools::Long nWidth, tools::Long nHeight, sal_uInt16 nFlags); + +private: // methods + /** do things on initial show (like centering on parent or on screen) + */ + void initShow(); + + void initWindowAndView(); + + void doShowFullScreen( bool bFullScreen, sal_Int32 nDisplay ); + + void doResetClipRegion(); + +private: // data + static AquaSalFrame* s_pCaptureFrame; + + AquaSalFrame( const AquaSalFrame& ) = delete; + AquaSalFrame& operator=(const AquaSalFrame&) = delete; +}; + +inline bool AquaSalFrame::isAlive( const AquaSalFrame* pFrame ) +{ + AquaSalInstance *pInst = GetSalData()->mpInstance; + return pInst && pInst->isFrameAlive( pFrame ); +} + +#endif // INCLUDED_VCL_INC_OSX_SALFRAME_H + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/osx/salframeview.h b/vcl/inc/osx/salframeview.h new file mode 100644 index 0000000000..2b1a3f9baa --- /dev/null +++ b/vcl/inc/osx/salframeview.h @@ -0,0 +1,278 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_VCL_INC_OSX_SALFRAMEVIEW_H +#define INCLUDED_VCL_INC_OSX_SALFRAMEVIEW_H + +#include <osx/a11ywrapper.h> + +enum class SalEvent; + +@interface SalFrameWindow : NSWindow<NSWindowDelegate> +{ + AquaSalFrame* mpFrame; + id mDraggingDestinationHandler; + BOOL mbInWindowDidResize; + NSTimer* mpLiveResizeTimer; +} +-(id)initWithSalFrame: (AquaSalFrame*)pFrame; +-(void)clearLiveResizeTimer; +-(void)dealloc; +-(BOOL)canBecomeKeyWindow; +-(void)displayIfNeeded; +-(void)windowDidBecomeKey: (NSNotification*)pNotification; +-(void)windowDidResignKey: (NSNotification*)pNotification; +-(void)windowDidChangeScreen: (NSNotification*)pNotification; +-(void)windowDidMove: (NSNotification*)pNotification; +-(void)windowDidResize: (NSNotification*)pNotification; +-(void)windowDidMiniaturize: (NSNotification*)pNotification; +-(void)windowDidDeminiaturize: (NSNotification*)pNotification; +-(BOOL)windowShouldClose: (NSNotification*)pNotification; +-(void)windowDidChangeBackingProperties:(NSNotification *)pNotification; +-(void)windowWillStartLiveResize:(NSNotification *)pNotification; +-(void)windowDidEndLiveResize:(NSNotification *)pNotification; +//-(void)willEncodeRestorableState:(NSCoder*)pCoderState; +//-(void)didDecodeRestorableState:(NSCoder*)pCoderState; +//-(void)windowWillEnterVersionBrowser:(NSNotification*)pNotification; +-(void)dockMenuItemTriggered: (id)sender; +-(AquaSalFrame*)getSalFrame; +-(BOOL)containsMouse; +-(css::uno::Reference < css::accessibility::XAccessibleContext >)accessibleContext; + +/* NSDraggingDestination protocol methods + */ +-(NSDragOperation)draggingEntered:(id <NSDraggingInfo>)sender; +-(NSDragOperation)draggingUpdated:(id <NSDraggingInfo>)sender; +-(void)draggingExited:(id <NSDraggingInfo>)sender; +-(BOOL)prepareForDragOperation:(id <NSDraggingInfo>)sender; +-(BOOL)performDragOperation:(id <NSDraggingInfo>)sender; +-(void)concludeDragOperation:(id <NSDraggingInfo>)sender; + +-(void)registerDraggingDestinationHandler:(id)theHandler; +-(void)unregisterDraggingDestinationHandler:(id)theHandler; + +-(void)endExtTextInput; +-(void)endExtTextInput:(EndExtTextInputFlags)nFlags; + +-(void)windowDidResizeWithTimer:(NSTimer *)pTimer; + +-(BOOL)isIgnoredWindow; + +// NSAccessibilityElement overrides +-(id)accessibilityApplicationFocusedUIElement; +-(id)accessibilityFocusedUIElement; +-(BOOL)accessibilityIsIgnored; +-(BOOL)isAccessibilityElement; + +@end + +@interface SalFrameView : NSView <NSTextInputClient> +{ + AquaSalFrame* mpFrame; + AquaA11yWrapper* mpChildWrapper; + BOOL mbNeedChildWrapper; + + // for NSTextInput/NSTextInputClient + NSEvent* mpLastEvent; + BOOL mbNeedSpecialKeyHandle; + BOOL mbInKeyInput; + BOOL mbKeyHandled; + NSRange mMarkedRange; + NSRange mSelectedRange; + id mpMouseEventListener; + id mDraggingDestinationHandler; + NSEvent* mpLastSuperEvent; + + // #i102807# used by magnify event handler + NSTimeInterval mfLastMagnifyTime; + float mfMagnifyDeltaSum; + + BOOL mbInEndExtTextInput; + BOOL mbInCommitMarkedText; + NSAttributedString* mpLastMarkedText; + BOOL mbTextInputWantsNonRepeatKeyDown; +} ++(void)unsetMouseFrame: (AquaSalFrame*)pFrame; +-(id)initWithSalFrame: (AquaSalFrame*)pFrame; +-(void)dealloc; +-(AquaSalFrame*)getSalFrame; +-(BOOL)acceptsFirstResponder; +-(BOOL)acceptsFirstMouse: (NSEvent *)pEvent; +-(BOOL)isOpaque; +-(void)drawRect: (NSRect)aRect; +-(void)mouseDown: (NSEvent*)pEvent; +-(void)mouseDragged: (NSEvent*)pEvent; +-(void)mouseUp: (NSEvent*)pEvent; +-(void)mouseMoved: (NSEvent*)pEvent; +-(void)mouseEntered: (NSEvent*)pEvent; +-(void)mouseExited: (NSEvent*)pEvent; +-(void)rightMouseDown: (NSEvent*)pEvent; +-(void)rightMouseDragged: (NSEvent*)pEvent; +-(void)rightMouseUp: (NSEvent*)pEvent; +-(void)otherMouseDown: (NSEvent*)pEvent; +-(void)otherMouseDragged: (NSEvent*)pEvent; +-(void)otherMouseUp: (NSEvent*)pEvent; +-(void)scrollWheel: (NSEvent*)pEvent; +-(void)magnifyWithEvent: (NSEvent*)pEvent; +-(void)rotateWithEvent: (NSEvent*)pEvent; +-(void)swipeWithEvent: (NSEvent*)pEvent; +-(void)keyDown: (NSEvent*)pEvent; +-(void)flagsChanged: (NSEvent*)pEvent; +-(void)sendMouseEventToFrame:(NSEvent*)pEvent button:(sal_uInt16)nButton eventtype:(SalEvent)nEvent; +-(BOOL)sendKeyInputAndReleaseToFrame: (sal_uInt16)nKeyCode character: (sal_Unicode)aChar; +-(BOOL)sendKeyInputAndReleaseToFrame: (sal_uInt16)nKeyCode character: (sal_Unicode)aChar modifiers: (unsigned int)nMod; +-(BOOL)sendKeyToFrameDirect: (sal_uInt16)nKeyCode character: (sal_Unicode)aChar modifiers: (unsigned int)nMod; +-(BOOL)sendSingleCharacter:(NSEvent*)pEvent; +-(BOOL)handleKeyDownException:(NSEvent*)pEvent; +-(void)clearLastEvent; +-(void)clearLastMarkedText; +/* + text action methods +*/ +-(void)insertText:(id)aString replacementRange:(NSRange)replacementRange; +-(void)insertTab: (id)aSender; +-(void)insertBacktab: (id)aSender; +-(void)moveLeft: (id)aSender; +-(void)moveLeftAndModifySelection: (id)aSender; +-(void)moveBackwardAndModifySelection: (id)aSender; +-(void)moveRight: (id)aSender; +-(void)moveRightAndModifySelection: (id)aSender; +-(void)moveForwardAndModifySelection: (id)aSender; +-(void)moveUp: (id)aSender; +-(void)moveDown: (id)aSender; +-(void)moveWordBackward: (id)aSender; +-(void)moveWordBackwardAndModifySelection: (id)aSender; +-(void)moveWordLeftAndModifySelection: (id)aSender; +-(void)moveWordForward: (id)aSender; +-(void)moveWordForwardAndModifySelection: (id)aSender; +-(void)moveWordRightAndModifySelection: (id)aSender; +-(void)moveToEndOfLine: (id)aSender; +-(void)moveToRightEndOfLine: (id)aSender; +-(void)moveToLeftEndOfLine: (id)aSender; +-(void)moveToEndOfLineAndModifySelection: (id)aSender; +-(void)moveToRightEndOfLineAndModifySelection: (id)aSender; +-(void)moveToLeftEndOfLineAndModifySelection: (id)aSender; +-(void)moveToBeginningOfLine: (id)aSender; +-(void)moveToBeginningOfLineAndModifySelection: (id)aSender; +-(void)moveToEndOfParagraph: (id)aSender; +-(void)moveToEndOfParagraphAndModifySelection: (id)aSender; +-(void)moveToBeginningOfParagraph: (id)aSender; +-(void)moveToBeginningOfParagraphAndModifySelection: (id)aSender; +-(void)moveParagraphForward: (id)aSender; +-(void)moveParagraphForwardAndModifySelection: (id)aSender; +-(void)moveParagraphBackward: (id)aSender; +-(void)moveParagraphBackwardAndModifySelection: (id)aSender; +-(void)moveToEndOfDocument: (id)aSender; +-(void)scrollToEndOfDocument: (id)aSender; +-(void)moveToEndOfDocumentAndModifySelection: (id)aSender; +-(void)moveToBeginningOfDocument: (id)aSender; +-(void)scrollToBeginningOfDocument: (id)aSender; +-(void)moveToBeginningOfDocumentAndModifySelection: (id)aSender; +-(void)insertNewline: (id)aSender; +-(void)deleteBackward: (id)aSender; +-(void)deleteForward: (id)aSender; +-(void)cancelOperation: (id)aSender; +-(void)deleteBackwardByDecomposingPreviousCharacter: (id)aSender; +-(void)deleteWordBackward: (id)aSender; +-(void)deleteWordForward: (id)aSender; +-(void)deleteToBeginningOfLine: (id)aSender; +-(void)deleteToEndOfLine: (id)aSender; +-(void)deleteToBeginningOfParagraph: (id)aSender; +-(void)deleteToEndOfParagraph: (id)aSender; +-(void)insertLineBreak: (id)aSender; +-(void)insertParagraphSeparator: (id)aSender; +-(void)selectWord: (id)aSender; +-(void)selectLine: (id)aSender; +-(void)selectParagraph: (id)aSender; +-(void)selectAll: (id)aSender; +-(void)noop: (id)aSender; +/* set the correct pointer for our view */ +-(void)resetCursorRects; +-(css::accessibility::XAccessibleContext *)accessibleContext; +-(id)parentAttribute; +-(NSWindow*)windowForParent; +/* + Event hook for D&D service. + + A drag operation will be invoked on a NSView using + the method 'dragImage'. This method requires the + actual mouse event initiating this drag operation. + Mouse events can only be received by subclassing + NSView and overriding methods like 'mouseDown' etc. + hence we implement an event hook here so that the + D&D service can register as listener for mouse + messages and use the last 'mouseDown' or + 'mouseDragged' message to initiate the drag + operation. +*/ +-(void)registerMouseEventListener: (id)theListener; +-(void)unregisterMouseEventListener: (id)theListener; + +/* NSDraggingDestination protocol methods + */ +-(NSDragOperation)draggingEntered:(id <NSDraggingInfo>)sender; +-(NSDragOperation)draggingUpdated:(id <NSDraggingInfo>)sender; +-(void)draggingExited:(id <NSDraggingInfo>)sender; +-(BOOL)prepareForDragOperation:(id <NSDraggingInfo>)sender; +-(BOOL)performDragOperation:(id <NSDraggingInfo>)sender; +-(void)concludeDragOperation:(id <NSDraggingInfo>)sender; + +-(void)registerDraggingDestinationHandler:(id)theHandler; +-(void)unregisterDraggingDestinationHandler:(id)theHandler; + +-(void)endExtTextInput; +-(void)endExtTextInput:(EndExtTextInputFlags)nFlags; +-(void)deleteTextInputWantsNonRepeatKeyDown; + +-(void)insertRegisteredWrapperIntoWrapperRepository; +-(void)registerWrapper; +-(void)revokeWrapper; + +// NSAccessibilityElement overrides +-(id)accessibilityAttributeValue:(NSString *)pAttribute; +-(BOOL)accessibilityIsIgnored; +-(NSArray *)accessibilityAttributeNames; +-(BOOL)accessibilityIsAttributeSettable:(NSString *)pAttribute; +-(NSArray *)accessibilityParameterizedAttributeNames; +-(BOOL)accessibilitySetOverrideValue:(id)pValue forAttribute:(NSString *)pAttribute; +-(void)accessibilitySetValue:(id)pValue forAttribute:(NSString *)pAttribute; +-(id)accessibilityAttributeValue:(NSString *)pAttribute forParameter:(id)pParameter; +-(id)accessibilityFocusedUIElement; +-(NSString *)accessibilityActionDescription:(NSString *)pAction; +-(void)accessibilityPerformAction:(NSString *)pAction; +-(NSArray *)accessibilityActionNames; +-(id)accessibilityHitTest:(NSPoint)aPoint; +-(NSArray *)accessibilityVisibleChildren; +-(NSArray *)accessibilitySelectedChildren; +-(NSArray *)accessibilityChildren; +-(NSArray <id<NSAccessibilityElement>> *)accessibilityChildrenInNavigationOrder; + +@end + +@interface SalFrameViewA11yWrapper : AquaA11yWrapper +{ + SalFrameView* mpParentView; +} +-(id)initWithParent:(SalFrameView*)pParentView accessibleContext:(::com::sun::star::uno::Reference<::com::sun::star::accessibility::XAccessibleContext>&)rxAccessibleContext; +-(void)dealloc; +@end + +#endif // INCLUDED_VCL_INC_OSX_SALFRAMEVIEW_H + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/osx/salinst.h b/vcl/inc/osx/salinst.h new file mode 100644 index 0000000000..8811fa3c9c --- /dev/null +++ b/vcl/inc/osx/salinst.h @@ -0,0 +1,168 @@ + +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#pragma once + +#include <sal/config.h> + +#include <condition_variable> +#include <list> +#include <mutex> + +#include <comphelper/solarmutex.hxx> +#include <osl/conditn.hxx> +#include <osl/thread.hxx> +#include <tools/long.hxx> + +#ifdef MACOSX +#include <osx/osxvcltypes.h> +#endif +#include <salinst.hxx> + +#include <osx/runinmain.hxx> + +#include <salusereventlist.hxx> + +class AquaSalFrame; +class SalFrame; +class SalObject; +class ApplicationEvent; +class Image; +enum class SalEvent; + +typedef void(^RuninmainBlock)(void); + +class SalYieldMutex : public comphelper::SolarMutex +{ +public: + OSX_RUNINMAIN_MEMBERS + +protected: + virtual void doAcquire( sal_uInt32 nLockCount ) override; + virtual sal_uInt32 doRelease( bool bUnlockAll ) override; + +public: + SalYieldMutex(); + virtual ~SalYieldMutex() override; + + virtual bool IsCurrentThread() const override; +}; + +class AquaSalInstance : public SalInstance, public SalUserEventList +{ + friend class AquaSalFrame; + + bool RunInMainYield( bool bHandleAllCurrentEvents ); + + virtual void ProcessEvent( SalUserEvent aEvent ) override; + +public: + virtual void TriggerUserEventProcessing() override; + + NSButtonCell* mpButtonCell; + NSButtonCell* mpCheckCell; + NSButtonCell* mpRadioCell; + NSTextFieldCell* mpTextFieldCell; + NSComboBoxCell* mpComboBoxCell; + NSPopUpButtonCell* mpPopUpButtonCell; + NSStepperCell* mpStepperCell; + NSButtonCell* mpListNodeCell; + OUString maDefaultPrinter; + oslThreadIdentifier maMainThread; + int mnActivePrintJobs; + osl::Mutex maUserEventListMutex; + osl::Condition maWaitingYieldCond; + bool mbNoYieldLock; + bool mbTimerProcessed; + + static std::list<const ApplicationEvent*> aAppEventList; + + AquaSalInstance(); + virtual ~AquaSalInstance() override; + + virtual void AfterAppInit() override; + virtual bool SVMainHook(int *) override; + + virtual SalFrame* CreateChildFrame( SystemParentData* pParent, SalFrameStyleFlags nStyle ) override; + virtual SalFrame* CreateFrame( SalFrame* pParent, SalFrameStyleFlags nStyle ) override; + virtual void DestroyFrame( SalFrame* pFrame ) override; + virtual SalObject* CreateObject( SalFrame* pParent, SystemWindowData* pWindowData, + bool bShow ) override; + virtual void DestroyObject( SalObject* pObject ) override; + virtual std::unique_ptr<SalVirtualDevice> + CreateVirtualDevice( SalGraphics& rGraphics, + tools::Long &nDX, tools::Long &nDY, + DeviceFormat eFormat, + const SystemGraphicsData *pData = nullptr ) override; + virtual SalInfoPrinter* CreateInfoPrinter( SalPrinterQueueInfo* pQueueInfo, + ImplJobSetup* pSetupData ) override; + virtual void DestroyInfoPrinter( SalInfoPrinter* pPrinter ) override; + virtual std::unique_ptr<SalPrinter> CreatePrinter( SalInfoPrinter* pInfoPrinter ) override; + virtual void GetPrinterQueueInfo( ImplPrnQueueList* pList ) override; + virtual void GetPrinterQueueState( SalPrinterQueueInfo* pInfo ) override; + virtual OUString GetDefaultPrinter() override; + virtual SalTimer* CreateSalTimer() override; + virtual SalSystem* CreateSalSystem() override; + virtual std::shared_ptr<SalBitmap> CreateSalBitmap() override; + virtual bool DoYield(bool bWait, bool bHandleAllCurrentEvents) override; + virtual bool AnyInput( VclInputFlags nType ) override; + virtual std::unique_ptr<SalMenu> CreateMenu( bool bMenuBar, Menu* pVCLMenu ) override; + virtual std::unique_ptr<SalMenuItem> CreateMenuItem( const SalItemParams & rItemData ) override; + virtual OpenGLContext* CreateOpenGLContext() override; + virtual OUString GetConnectionIdentifier() override; + virtual void AddToRecentDocumentList(const OUString& rFileUrl, const OUString& rMimeType, + const OUString& rDocumentService) override; + + virtual OUString getOSVersion() override; + + // dtrans implementation + virtual css::uno::Reference< css::uno::XInterface > CreateClipboard( + const css::uno::Sequence< css::uno::Any >& i_rArguments ) override; + virtual css::uno::Reference<css::uno::XInterface> ImplCreateDragSource(const SystemEnvData*) override; + virtual css::uno::Reference<css::uno::XInterface> ImplCreateDropTarget(const SystemEnvData*) override; + + static void handleAppDefinedEvent( NSEvent* pEvent ); + + // check whether a particular string is passed on the command line + // this is needed to avoid duplicate open events through a) command line and b) NSApp's openFile + static bool isOnCommandLine( const OUString& ); + + void delayedSettingsChanged( bool bInvalidate ); + + // Is this the NSAppThread? + virtual bool IsMainThread() const override; + + void startedPrintJob() { mnActivePrintJobs++; } + void endedPrintJob() { mnActivePrintJobs--; } + + // event subtypes for NSEventTypeApplicationDefined events + static const short AppExecuteSVMain = 1; + static const short AppStartTimerEvent = 10; + static const short YieldWakeupEvent = 20; + static const short DispatchTimerEvent = 30; + + static NSMenu* GetDynamicDockMenu(); +}; + +CGImageRef CreateCGImage( const Image& ); +NSImage* CreateNSImage( const Image& ); + + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/osx/salmenu.h b/vcl/inc/osx/salmenu.h new file mode 100644 index 0000000000..597180cc1a --- /dev/null +++ b/vcl/inc/osx/salmenu.h @@ -0,0 +1,112 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_VCL_INC_OSX_SALMENU_H +#define INCLUDED_VCL_INC_OSX_SALMENU_H + +#include <premac.h> +#include <Cocoa/Cocoa.h> +#include <postmac.h> + +#include <salmenu.hxx> + +#include <vector> + +class AquaSalFrame; +class AquaSalMenuItem; + +class AquaSalMenu : public SalMenu +{ + std::vector< AquaSalMenuItem* > maItems; + +public: // for OOStatusView + struct MenuBarButtonEntry + { + SalMenuButtonItem maButton; + NSImage* mpNSImage; // cached image + NSString* mpToolTipString; + + MenuBarButtonEntry() : mpNSImage( nil ), mpToolTipString( nil ) {} + MenuBarButtonEntry( const SalMenuButtonItem& i_rItem ) + : maButton( i_rItem), mpNSImage( nil ), mpToolTipString( nil ) {} + }; +private: + std::vector< MenuBarButtonEntry > maButtons; + + MenuBarButtonEntry* findButtonItem( sal_uInt16 i_nItemId ); + static void statusLayout(); +public: + AquaSalMenu( bool bMenuBar ); + virtual ~AquaSalMenu() override; + + virtual bool VisibleMenuBar() override; + + virtual void InsertItem( SalMenuItem* pSalMenuItem, unsigned nPos ) override; + virtual void RemoveItem( unsigned nPos ) override; + virtual void SetSubMenu( SalMenuItem* pSalMenuItem, SalMenu* pSubMenu, unsigned nPos ) override; + virtual void SetFrame( const SalFrame* pFrame ) override; + virtual void CheckItem( unsigned nPos, bool bCheck ) override; + virtual void EnableItem( unsigned nPos, bool bEnable ) override; + virtual void SetItemText( unsigned nPos, SalMenuItem* pSalMenuItem, const OUString& rText ) override; + virtual void SetItemImage( unsigned nPos, SalMenuItem* pSalMenuItem, const Image& rImage) override; + virtual void SetAccelerator( unsigned nPos, SalMenuItem* pSalMenuItem, const vcl::KeyCode& rKeyCode, const OUString& rKeyName ) override; + virtual void GetSystemMenuData( SystemMenuData* pData ) override; + virtual bool ShowNativePopupMenu(FloatingWindow * pWin, const tools::Rectangle& rRect, FloatWinPopupFlags nFlags) override; + virtual bool AddMenuBarButton( const SalMenuButtonItem& ) override; + virtual void RemoveMenuBarButton( sal_uInt16 nId ) override; + virtual tools::Rectangle GetMenuBarButtonRectPixel( sal_uInt16 i_nItemId, SalFrame* i_pReferenceFrame ) override; + + int getItemIndexByPos( sal_uInt16 nPos ) const; + const AquaSalFrame* getFrame() const; + + void setMainMenu(); + static void unsetMainMenu(); + static void setDefaultMenu(); + static void enableMainMenu( bool bEnable ); + static void addFallbackMenuItem( NSMenuItem* NewItem ); + static void removeFallbackMenuItem( NSMenuItem* pOldItem ); + + const std::vector< MenuBarButtonEntry >& getButtons() const { return maButtons; } + + bool mbMenuBar; // true - Menubar, false - Menu + NSMenu* mpMenu; // The Carbon reference to this menu + VclPtr<Menu> mpVCLMenu; // the corresponding vcl Menu object + const AquaSalFrame* mpFrame; // the frame to dispatch the menu events to + AquaSalMenu* mpParentSalMenu; // the parent menu that contains us (and perhaps has a frame) + + static const AquaSalMenu* pCurrentMenuBar; + +}; + +class AquaSalMenuItem : public SalMenuItem +{ +public: + AquaSalMenuItem( const SalItemParams* ); + virtual ~AquaSalMenuItem() override; + + sal_uInt16 mnId; // Item ID + VclPtr<Menu> mpVCLMenu; // VCL Menu into which this MenuItem is inserted + AquaSalMenu* mpParentMenu; // The menu in which this menu item is inserted + AquaSalMenu* mpSubMenu; // Sub menu of this item (if defined) + NSMenuItem* mpMenuItem; // The NSMenuItem +}; + +#endif // INCLUDED_VCL_INC_OSX_SALMENU_H + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/osx/salnativewidgets.h b/vcl/inc/osx/salnativewidgets.h new file mode 100644 index 0000000000..86675e0623 --- /dev/null +++ b/vcl/inc/osx/salnativewidgets.h @@ -0,0 +1,69 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_VCL_INC_OSX_SALNATIVEWIDGETS_H +#define INCLUDED_VCL_INC_OSX_SALNATIVEWIDGETS_H + +#define TAB_HEIGHT 20 // height of tab header in pixels +#define TAB_TEXT_MARGIN 12 // left/right margin of text within tab headers + +#define FOCUS_RING_WIDTH 4 // width of focus ring in pixels + +#define MEDIUM_PROGRESS_INDICATOR_HEIGHT 10 // height of medium progress indicator in pixels +#define LARGE_PROGRESS_INDICATOR_HEIGHT 16 // height of large progress indicator in pixels + +#define PUSH_BUTTON_NORMAL_HEIGHT 21 // height of normal push button without focus ring in pixels +#define PUSH_BUTTON_SMALL_HEIGHT 15 // height of small push button without focus ring in pixels + +#define RADIO_BUTTON_SMALL_SIZE 14 // width/height of small radio button without focus ring in pixels +#define RADIO_BUTTON_TEXT_SEPARATOR 3 // space between radio button and following text in pixels + +#define CHECKBOX_SMALL_SIZE 14 // width/height of checkbox without focus ring in pixels +#define CHECKBOX_TEXT_SEPARATOR 3 // space between checkbox and following text in pixels + +#define SLIDER_WIDTH 19 // width of slider in pixels +#define SLIDER_HEIGHT 18 // height of slider in pixels + +#define EDITBOX_HEIGHT 21 // height of editbox without focus ring in pixels +#define EDITBOX_BORDER_WIDTH 1 // width of editbox border in pixels +#define EDITBOX_INSET_MARGIN 1 // width of left/right as well as top/bottom editbox margin in pixels + +#define COMBOBOX_HEIGHT 20 // height of combobox without focus ring in pixels +#define COMBOBOX_BUTTON_WIDTH 18 // width of combobox button without focus ring in pixels +#define COMBOBOX_BORDER_WIDTH 1 // width of combobox border in pixels +#define COMBOBOX_TEXT_MARGIN 1 // left/right margin of text in pixels + +#define LISTBOX_HEIGHT 20 // height of listbox without focus ring in pixels +#define LISTBOX_BUTTON_WIDTH 18 // width of listbox button without focus ring in pixels +#define LISTBOX_BORDER_WIDTH 1 // width of listbox border in pixels +#define LISTBOX_TEXT_MARGIN 1 // left/right margin of text in pixels + +#define SPIN_BUTTON_WIDTH 13 // width of spin button without focus ring in pixels +#define SPIN_UPPER_BUTTON_HEIGHT 11 // height of upper spin button without focus ring in pixels +#define SPIN_LOWER_BUTTON_HEIGHT 11 // height of lower spin button without focus ring in pixels + +// FIXME: spinboxes are positioned one pixel shifted to the right by VCL. As positioning as well as size should be equal to +// corresponding editboxes, comboboxes or listboxes, positioning of spinboxes should by equal too. Issue cannot be fixed within +// native widget drawing code. As a workaround, an offset is considered for spinboxes to align spinboxes correctly. + +#define SPINBOX_OFFSET 1 // left offset for alignment with editboxes, comboboxes, and listboxes + +#endif // INCLUDED_VCL_INC_OSX_SALNATIVEWIDGETS_H + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/osx/salnsmenu.h b/vcl/inc/osx/salnsmenu.h new file mode 100644 index 0000000000..696abca2fc --- /dev/null +++ b/vcl/inc/osx/salnsmenu.h @@ -0,0 +1,53 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_VCL_INC_OSX_SALNSMENU_H +#define INCLUDED_VCL_INC_OSX_SALNSMENU_H + +class AquaSalMenu; +class AquaSalMenuItem; + +@interface OOStatusItemView : NSView +{ +} +- (void)drawRect:(NSRect)aRect; +- (void)layout; +- (void)mouseUp:(NSEvent*)pEvent; +@end + +@interface SalNSMenu : NSMenu +{ + AquaSalMenu* mpMenu; +} +- (id)initWithMenu:(AquaSalMenu*)pMenu; +- (void)menuNeedsUpdate:(NSMenu*)pMenu; +- (void)setSalMenu:(AquaSalMenu*)pMenu; +@end + +@interface SalNSMenuItem : NSMenuItem +{ + AquaSalMenuItem* mpMenuItem; +} +- (id)initWithMenuItem:(AquaSalMenuItem*)pMenuItem; +- (void)menuItemTriggered:(id)aSender; +@end + +#endif // INCLUDED_VCL_INC_OSX_SALNSMENU_H + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/osx/salnstimer.h b/vcl/inc/osx/salnstimer.h new file mode 100644 index 0000000000..5c831cdf45 --- /dev/null +++ b/vcl/inc/osx/salnstimer.h @@ -0,0 +1,35 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_VCL_INC_OSX_SALNSTIMER_H +#define INCLUDED_VCL_INC_OSX_SALNSTIMER_H + +#include <premac.h> +#include <Cocoa/Cocoa.h> +#include <postmac.h> + +@interface TimerCallbackCaller : NSObject +{ +} +- (void)timerElapsed:(NSTimer*)pTimer; +@end + +#endif // INCLUDED_VCL_INC_OSX_SALNSTIMER_H + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/osx/salobj.h b/vcl/inc/osx/salobj.h new file mode 100644 index 0000000000..4c2ac88be6 --- /dev/null +++ b/vcl/inc/osx/salobj.h @@ -0,0 +1,71 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_VCL_INC_OSX_SALOBJ_H +#define INCLUDED_VCL_INC_OSX_SALOBJ_H + +#include <sal/config.h> + +#include <tools/long.hxx> +#include <vcl/sysdata.hxx> +#include <salobj.hxx> + +class AquaSalFrame; +class AquaSalObject; + + +struct SalObjectData +{ +}; + +class AquaSalObject : public SalObject +{ +public: + AquaSalFrame* mpFrame; // parent frame + NSClipView* mpClipView; + SystemEnvData maSysData; + + CGFloat mnClipX; + CGFloat mnClipY; + CGFloat mnClipWidth; + CGFloat mnClipHeight; + bool mbClip; + + CGFloat mnX; + CGFloat mnY; + CGFloat mnWidth; + CGFloat mnHeight; + + void setClippedPosSize(); + + AquaSalObject( AquaSalFrame* pFrame, SystemWindowData const * pWinData ); + virtual ~AquaSalObject() override; + + virtual void ResetClipRegion() override; + virtual void BeginSetClipRegion( sal_uInt32 nRects ) override; + virtual void UnionClipRegion( tools::Long nX, tools::Long nY, tools::Long nWidth, tools::Long nHeight ) override; + virtual void EndSetClipRegion() override; + virtual void SetPosSize( tools::Long nX, tools::Long nY, tools::Long nWidth, tools::Long nHeight ) override; + virtual void Show( bool bVisible ) override; + virtual const SystemEnvData* GetSystemData() const override; +}; + +#endif // INCLUDED_VCL_INC_OSX_SALOBJ_H + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/osx/salprn.h b/vcl/inc/osx/salprn.h new file mode 100644 index 0000000000..7bfd41787e --- /dev/null +++ b/vcl/inc/osx/salprn.h @@ -0,0 +1,156 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_VCL_INC_OSX_SALPRN_H +#define INCLUDED_VCL_INC_OSX_SALPRN_H + +#include <sal/config.h> + +#include <tools/long.hxx> + +#include <osx/osxvcltypes.h> + +#include <salprn.hxx> + +#include <memory> + +class AquaSalGraphics; + +class AquaSalInfoPrinter : public SalInfoPrinter +{ + /// Printer graphics + AquaSalGraphics* mpGraphics; + /// is Graphics used + bool mbGraphics; + /// job active ? + bool mbJob; + + /// cocoa printer object + NSPrinter* mpPrinter; + /// cocoa print info object + NSPrintInfo* mpPrintInfo; + + /// FIXME: get real printer context for infoprinter if possible + /// fake context for info printer + /// graphics context for Quartz 2D + CGContextRef mrContext; + /// memory for graphics bitmap context for querying metrics + std::unique_ptr<sal_uInt8[]> mpContextMemory; + + // since changes to NSPrintInfo during a job are ignored + // we have to care for some settings ourselves + // currently we do this for orientation; + // really needed however is a solution for paper formats + Orientation mePageOrientation; + + int mnStartPageOffsetX; + int mnStartPageOffsetY; + sal_Int32 mnCurPageRangeStart; + sal_Int32 mnCurPageRangeCount; + + public: + AquaSalInfoPrinter( const SalPrinterQueueInfo& pInfo ); + virtual ~AquaSalInfoPrinter() override; + + void SetupPrinterGraphics( CGContextRef i_xContext ) const; + + virtual SalGraphics* AcquireGraphics() override; + virtual void ReleaseGraphics( SalGraphics* i_pGraphics ) override; + virtual bool Setup( weld::Window* i_pFrame, ImplJobSetup* i_pSetupData ) override; + virtual bool SetPrinterData( ImplJobSetup* pSetupData ) override; + virtual bool SetData( JobSetFlags i_nFlags, ImplJobSetup* i_pSetupData ) override; + virtual void GetPageInfo( const ImplJobSetup* i_pSetupData, + tools::Long& o_rOutWidth, tools::Long& o_rOutHeight, + Point& rPageOffset, + Size& rPaperSize ) override; + virtual sal_uInt32 GetCapabilities( const ImplJobSetup* i_pSetupData, PrinterCapType i_nType ) override; + virtual sal_uInt16 GetPaperBinCount( const ImplJobSetup* i_pSetupData ) override; + virtual OUString GetPaperBinName( const ImplJobSetup* i_pSetupData, sal_uInt16 i_nPaperBin ) override; + virtual void InitPaperFormats( const ImplJobSetup* i_pSetupData ) override; + virtual int GetLandscapeAngle( const ImplJobSetup* i_pSetupData ) override; + + // the artificial separation between InfoPrinter and Printer + // is not really useful for us + // so let's make AquaSalPrinter just a forwarder to AquaSalInfoPrinter + // and concentrate the real work in one class + // implement pull model print system + bool StartJob( const OUString* i_pFileName, + const OUString& rJobName, + ImplJobSetup* i_pSetupData, + vcl::PrinterController& i_rController ); + bool EndJob(); + bool AbortJob(); + SalGraphics* StartPage( ImplJobSetup* i_pSetupData, bool i_bNewJobData ); + bool EndPage(); + + NSPrintInfo* getPrintInfo() const { return mpPrintInfo; } + void setStartPageOffset( int nOffsetX, int nOffsetY ) { mnStartPageOffsetX = nOffsetX; mnStartPageOffsetY = nOffsetY; } + sal_Int32 getCurPageRangeStart() const { return mnCurPageRangeStart; } + sal_Int32 getCurPageRangeCount() const { return mnCurPageRangeCount; } + + // match width/height against known paper formats, possibly switching orientation + const PaperInfo* matchPaper( + tools::Long i_nWidth, tools::Long i_nHeight, Orientation& o_rOrientation ) const; + void setPaperSize( tools::Long i_nWidth, tools::Long i_nHeight, Orientation i_eSetOrientation ); + + private: + AquaSalInfoPrinter( const AquaSalInfoPrinter& ) = delete; + AquaSalInfoPrinter& operator=(const AquaSalInfoPrinter&) = delete; +}; + + +class AquaSalPrinter : public SalPrinter +{ + AquaSalInfoPrinter* mpInfoPrinter; // pointer to the compatible InfoPrinter + public: + AquaSalPrinter( AquaSalInfoPrinter* i_pInfoPrinter ); + virtual ~AquaSalPrinter() override; + + virtual bool StartJob( const OUString* i_pFileName, + const OUString& i_rJobName, + const OUString& i_rAppName, + sal_uInt32 i_nCopies, + bool i_bCollate, + bool i_bDirect, + ImplJobSetup* i_pSetupData ) override; + // implement pull model print system + virtual bool StartJob( const OUString* i_pFileName, + const OUString& rJobName, + const OUString& i_rAppName, + ImplJobSetup* i_pSetupData, + vcl::PrinterController& i_rListener ) override; + + virtual bool EndJob() override; + virtual SalGraphics* StartPage( ImplJobSetup* i_pSetupData, bool i_bNewJobData ) override; + virtual void EndPage() override; + + private: + AquaSalPrinter( const AquaSalPrinter& ) = delete; + AquaSalPrinter& operator=(const AquaSalPrinter&) = delete; +}; + +const double fPtTo100thMM = 35.27777778; + +inline int PtTo10Mu( double nPoints ) { return static_cast<int>((nPoints*fPtTo100thMM)+0.5); } + +inline double TenMuToPt( double nUnits ) { return floor((nUnits/fPtTo100thMM)+0.5); } + +#endif // INCLUDED_VCL_INC_OSX_SALPRN_H + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/osx/salsys.h b/vcl/inc/osx/salsys.h new file mode 100644 index 0000000000..4b8b077088 --- /dev/null +++ b/vcl/inc/osx/salsys.h @@ -0,0 +1,44 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_VCL_INC_OSX_SALSYS_H +#define INCLUDED_VCL_INC_OSX_SALSYS_H + +#include <salsys.hxx> + +#include <list> + + +class VCL_DLLPUBLIC AquaSalSystem : public SalSystem +{ +public: + AquaSalSystem() {} + virtual ~AquaSalSystem() override; + + // get info about the display + virtual unsigned int GetDisplayScreenCount() override; + virtual AbsoluteScreenPixelRectangle GetDisplayScreenPosSizePixel( unsigned int nScreen ) override; + + virtual int ShowNativeMessageBox( const OUString& rTitle, + const OUString& rMessage) override; +}; + +#endif // INCLUDED_VCL_INC_OSX_SALSYS_H + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/osx/saltimer.h b/vcl/inc/osx/saltimer.h new file mode 100644 index 0000000000..cdde3ec847 --- /dev/null +++ b/vcl/inc/osx/saltimer.h @@ -0,0 +1,75 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_VCL_INC_OSX_SALTIMER_H +#define INCLUDED_VCL_INC_OSX_SALTIMER_H + +#include <premac.h> +#include <Cocoa/Cocoa.h> +#include <postmac.h> + +#include <saltimer.hxx> + +/** + * if NO == bAtStart, then it has to be run in the main thread, + * e.g. via performSelectorOnMainThread! + **/ +void ImplNSAppPostEvent( short nEventId, BOOL bAtStart, int nUserData = 0 ); + +class ReleasePoolHolder +{ + NSAutoreleasePool* mpPool; + +public: + ReleasePoolHolder() : mpPool( [[NSAutoreleasePool alloc] init] ) {} + ~ReleasePoolHolder() { [mpPool release]; } +}; + +class AquaSalTimer final : public SalTimer, protected VersionedEvent +{ + NSTimer *m_pRunningTimer; + bool m_bDirectTimeout; ///< timeout can be processed directly + + void queueDispatchTimerEvent( bool bAtStart ); + void callTimerCallback(); + +public: + AquaSalTimer(); + virtual ~AquaSalTimer() override; + + void Start( sal_uInt64 nMS ) override; + void Stop() override; + + void handleStartTimerEvent( NSEvent* pEvent ); + bool handleDispatchTimerEvent( NSEvent* pEvent ); + void handleTimerElapsed(); + void handleWindowShouldClose(); + + bool IsTimerElapsed() const; + inline bool IsDirectTimeout() const; +}; + +inline bool AquaSalTimer::IsDirectTimeout() const +{ + return m_bDirectTimeout; +} + +#endif // INCLUDED_VCL_INC_OSX_SALTIMER_H + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/osx/svsys.h b/vcl/inc/osx/svsys.h new file mode 100644 index 0000000000..9fcabe074f --- /dev/null +++ b/vcl/inc/osx/svsys.h @@ -0,0 +1,29 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_VCL_INC_OSX_SVSYS_H +#define INCLUDED_VCL_INC_OSX_SVSYS_H + +#include <premac.h> +#include <Cocoa/Cocoa.h> +#include <postmac.h> + +#endif // INCLUDED_VCL_INC_OSX_SVSYS_H + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/osx/vclnsapp.h b/vcl/inc/osx/vclnsapp.h new file mode 100644 index 0000000000..e3329f554c --- /dev/null +++ b/vcl/inc/osx/vclnsapp.h @@ -0,0 +1,68 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#pragma once + +#include <config_features.h> + +#include <premac.h> +#include <Cocoa/Cocoa.h> +#include <postmac.h> + +class AquaSalFrame; + +@interface CocoaThreadEnabler : NSObject +{ +} +-(void)enableCocoaThreads:(id)param; +@end + +// our very own application +@interface VCL_NSApplication : NSApplication +{ +} +-(void)applicationDidFinishLaunching:(NSNotification*)pNotification; +-(void)sendEvent:(NSEvent*)pEvent; +-(void)sendSuperEvent:(NSEvent*)pEvent; +-(NSMenu*)applicationDockMenu:(NSApplication *)sender; +-(BOOL)application: (NSApplication*) app openFile: (NSString*)file; +-(void)application: (NSApplication*) app openFiles: (NSArray*)files; +-(BOOL)application: (NSApplication*) app printFile: (NSString*)file; +-(NSApplicationPrintReply)application: (NSApplication *) app printFiles:(NSArray *)files withSettings: (NSDictionary *)printSettings showPrintPanels:(BOOL)bShowPrintPanels; +-(NSApplicationTerminateReply)applicationShouldTerminate: (NSApplication *) app; +-(void)applicationWillTerminate: (NSNotification *) aNotification; +-(void)observeValueForKeyPath: (NSString*) keyPath ofObject:(id)object + change: (NSDictionary<NSKeyValueChangeKey, id>*)change + context: (void*)context; +-(void)systemColorsChanged: (NSNotification*) pNotification; +-(void)screenParametersChanged: (NSNotification*) pNotification; +-(void)scrollbarVariantChanged: (NSNotification*) pNotification; +-(void)scrollbarSettingsChanged: (NSNotification*) pNotification; +-(void)addFallbackMenuItem: (NSMenuItem*)pNewItem; +-(void)removeFallbackMenuItem: (NSMenuItem*)pOldItem; +-(void)addDockMenuItem: (NSMenuItem*)pNewItem; +#if !HAVE_FEATURE_MACOSX_SANDBOX +-(void)applicationWillBecomeActive: (NSNotification *)pNotification; +-(void)applicationWillResignActive: (NSNotification *)pNotification; +#endif +-(BOOL)applicationShouldHandleReopen: (NSApplication*)pApp hasVisibleWindows: (BOOL)bWinVisible; +-(void)setDockIconClickHandler: (NSObject*)pHandler; +@end + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |