xref: /aoo41x/main/vcl/inc/aqua/salinst.h (revision 24f6443d)
1*24f6443dSAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*24f6443dSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*24f6443dSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*24f6443dSAndrew Rist  * distributed with this work for additional information
6*24f6443dSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*24f6443dSAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*24f6443dSAndrew Rist  * "License"); you may not use this file except in compliance
9*24f6443dSAndrew Rist  * with the License.  You may obtain a copy of the License at
10*24f6443dSAndrew Rist  *
11*24f6443dSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*24f6443dSAndrew Rist  *
13*24f6443dSAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*24f6443dSAndrew Rist  * software distributed under the License is distributed on an
15*24f6443dSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*24f6443dSAndrew Rist  * KIND, either express or implied.  See the License for the
17*24f6443dSAndrew Rist  * specific language governing permissions and limitations
18*24f6443dSAndrew Rist  * under the License.
19*24f6443dSAndrew Rist  *
20*24f6443dSAndrew Rist  *************************************************************/
21*24f6443dSAndrew Rist 
22*24f6443dSAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir #ifndef _SV_SALINST_H
25cdf0e10cSrcweir #define _SV_SALINST_H
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #include "vos/mutex.hxx"
28cdf0e10cSrcweir #include "vos/thread.hxx"
29cdf0e10cSrcweir #include "osl/conditn.h"
30cdf0e10cSrcweir 
31cdf0e10cSrcweir #include "aqua/aquavcltypes.h"
32cdf0e10cSrcweir 
33cdf0e10cSrcweir #include "salinst.hxx"
34cdf0e10cSrcweir 
35cdf0e10cSrcweir #include <list>
36cdf0e10cSrcweir 
37cdf0e10cSrcweir class AquaSalFrame;
38cdf0e10cSrcweir class ApplicationEvent;
39cdf0e10cSrcweir class Image;
40cdf0e10cSrcweir 
41cdf0e10cSrcweir // -----------------
42cdf0e10cSrcweir // - SalYieldMutex -
43cdf0e10cSrcweir // -----------------
44cdf0e10cSrcweir 
45cdf0e10cSrcweir class SalYieldMutex : public vos::OMutex
46cdf0e10cSrcweir {
47cdf0e10cSrcweir 	sal_uLong										mnCount;
48cdf0e10cSrcweir 	vos::OThread::TThreadIdentifier             mnThreadId;
49cdf0e10cSrcweir 
50cdf0e10cSrcweir public:
51cdf0e10cSrcweir 												SalYieldMutex();
52cdf0e10cSrcweir 	virtual void								acquire();
53cdf0e10cSrcweir 	virtual void								release();
54cdf0e10cSrcweir 	virtual sal_Bool							tryToAcquire();
GetAcquireCount() const55cdf0e10cSrcweir 	sal_uLong										GetAcquireCount() const { return mnCount; }
GetThreadId() const56cdf0e10cSrcweir 	vos::OThread::TThreadIdentifier             GetThreadId() const { return mnThreadId; }
57cdf0e10cSrcweir };
58cdf0e10cSrcweir 
59cdf0e10cSrcweir #define YIELD_GUARD vos::OGuard aGuard( GetSalData()->mpFirstInstance->GetYieldMutex() )
60cdf0e10cSrcweir 
61cdf0e10cSrcweir 
62cdf0e10cSrcweir // -------------------
63cdf0e10cSrcweir // - SalInstanceData -
64cdf0e10cSrcweir // -------------------
65cdf0e10cSrcweir 
66cdf0e10cSrcweir //struct SalInstanceData
67cdf0e10cSrcweir //{
68cdf0e10cSrcweir //public:
69cdf0e10cSrcweir //};
70cdf0e10cSrcweir 
71cdf0e10cSrcweir // ------------------
72cdf0e10cSrcweir // - AquaSalInstance -
73cdf0e10cSrcweir // ------------------
74cdf0e10cSrcweir 
75cdf0e10cSrcweir class AquaSalInstance : public SalInstance
76cdf0e10cSrcweir {
77cdf0e10cSrcweir     struct SalUserEvent
78cdf0e10cSrcweir     {
79cdf0e10cSrcweir         AquaSalFrame*   mpFrame;
80cdf0e10cSrcweir         void*           mpData;
81cdf0e10cSrcweir         sal_uInt16          mnType;
82cdf0e10cSrcweir 
SalUserEventAquaSalInstance::SalUserEvent83cdf0e10cSrcweir         SalUserEvent( AquaSalFrame* pFrame, void* pData, sal_uInt16 nType ) :
84cdf0e10cSrcweir             mpFrame( pFrame ), mpData( pData ), mnType( nType )
85cdf0e10cSrcweir         {}
86cdf0e10cSrcweir     };
87cdf0e10cSrcweir 
88cdf0e10cSrcweir public:
89cdf0e10cSrcweir 	SalYieldMutex*		                    mpSalYieldMutex;		// Sal-Yield-Mutex
90cdf0e10cSrcweir     rtl::OUString                           maDefaultPrinter;
91cdf0e10cSrcweir     vos::OThread::TThreadIdentifier         maMainThread;
92cdf0e10cSrcweir     bool                                    mbWaitingYield;
93cdf0e10cSrcweir     int                                     mnActivePrintJobs;
94cdf0e10cSrcweir     std::list< SalUserEvent >               maUserEvents;
95cdf0e10cSrcweir     oslMutex                                maUserEventListMutex;
96cdf0e10cSrcweir     oslCondition                            maWaitingYieldCond;
97cdf0e10cSrcweir 
98cdf0e10cSrcweir     typedef std::list<const ApplicationEvent*> AppEventList;
99cdf0e10cSrcweir     static AppEventList aAppEventList;
100cdf0e10cSrcweir 
101cdf0e10cSrcweir public:
102cdf0e10cSrcweir     AquaSalInstance();
103cdf0e10cSrcweir     virtual ~AquaSalInstance();
104cdf0e10cSrcweir 
105cdf0e10cSrcweir     virtual SalSystem*      CreateSystem();
106cdf0e10cSrcweir     virtual void            DestroySystem(SalSystem*);
107cdf0e10cSrcweir     virtual SalFrame*      	CreateChildFrame( SystemParentData* pParent, sal_uLong nStyle );
108cdf0e10cSrcweir     virtual SalFrame*      	CreateFrame( SalFrame* pParent, sal_uLong nStyle );
109cdf0e10cSrcweir     virtual void			DestroyFrame( SalFrame* pFrame );
110cdf0e10cSrcweir     virtual SalObject*		CreateObject( SalFrame* pParent, SystemWindowData* pWindowData, sal_Bool bShow = sal_True );
111cdf0e10cSrcweir     virtual void			DestroyObject( SalObject* pObject );
112cdf0e10cSrcweir     virtual SalVirtualDevice*	CreateVirtualDevice( SalGraphics* pGraphics,
113cdf0e10cSrcweir                                                      long nDX, long nDY,
114cdf0e10cSrcweir                                                      sal_uInt16 nBitCount, const SystemGraphicsData *pData );
115cdf0e10cSrcweir     virtual void			DestroyVirtualDevice( SalVirtualDevice* pDevice );
116cdf0e10cSrcweir 
117cdf0e10cSrcweir     virtual SalInfoPrinter*	CreateInfoPrinter( SalPrinterQueueInfo* pQueueInfo,
118cdf0e10cSrcweir                                                ImplJobSetup* pSetupData );
119cdf0e10cSrcweir     virtual void			DestroyInfoPrinter( SalInfoPrinter* pPrinter );
120cdf0e10cSrcweir     virtual SalPrinter*		CreatePrinter( SalInfoPrinter* pInfoPrinter );
121cdf0e10cSrcweir     virtual void			DestroyPrinter( SalPrinter* pPrinter );
122cdf0e10cSrcweir     virtual void			GetPrinterQueueInfo( ImplPrnQueueList* pList );
123cdf0e10cSrcweir     virtual void			GetPrinterQueueState( SalPrinterQueueInfo* pInfo );
124cdf0e10cSrcweir     virtual void			DeletePrinterQueueInfo( SalPrinterQueueInfo* pInfo );
125cdf0e10cSrcweir     virtual String             GetDefaultPrinter();
126cdf0e10cSrcweir     virtual SalTimer*			CreateSalTimer();
127cdf0e10cSrcweir     virtual SalI18NImeStatus*	CreateI18NImeStatus();
128cdf0e10cSrcweir     virtual SalSystem*			CreateSalSystem();
129cdf0e10cSrcweir     virtual SalBitmap*			CreateSalBitmap();
130cdf0e10cSrcweir     virtual vos::IMutex*		GetYieldMutex();
131cdf0e10cSrcweir     virtual sal_uLong				ReleaseYieldMutex();
132cdf0e10cSrcweir     virtual void				AcquireYieldMutex( sal_uLong nCount );
133cdf0e10cSrcweir     virtual bool                CheckYieldMutex();
134cdf0e10cSrcweir     virtual void				Yield( bool bWait, bool bHandleAllCurrentEvents );
135cdf0e10cSrcweir     virtual bool				AnyInput( sal_uInt16 nType );
136cdf0e10cSrcweir     virtual SalMenu*			CreateMenu( sal_Bool bMenuBar, Menu* pVCLMenu );
137cdf0e10cSrcweir     virtual void				DestroyMenu( SalMenu* );
138cdf0e10cSrcweir     virtual SalMenuItem*		CreateMenuItem( const SalItemParams* pItemData );
139cdf0e10cSrcweir     virtual void				DestroyMenuItem( SalMenuItem* );
140cdf0e10cSrcweir     virtual SalSession*         CreateSalSession();
141cdf0e10cSrcweir     virtual void*				GetConnectionIdentifier( ConnectionIdentifierType& rReturnedType, int& rReturnedBytes );
142cdf0e10cSrcweir     virtual void                AddToRecentDocumentList(const rtl::OUString& rFileUrl, const rtl::OUString& rMimeType);
143cdf0e10cSrcweir     virtual void            SetEventCallback( void* pInstance, bool(*pCallback)(void*,void*,int) );
144cdf0e10cSrcweir     virtual void            SetErrorEventCallback( void* pInstance, bool(*pCallback)(void*,void*,int) );
145cdf0e10cSrcweir 
146cdf0e10cSrcweir     // dtrans implementation
147cdf0e10cSrcweir     virtual com::sun::star::uno::Reference< com::sun::star::uno::XInterface >
148cdf0e10cSrcweir         CreateClipboard( const com::sun::star::uno::Sequence< com::sun::star::uno::Any >& i_rArguments );
149cdf0e10cSrcweir     virtual com::sun::star::uno::Reference< com::sun::star::uno::XInterface > CreateDragSource();
150cdf0e10cSrcweir     virtual com::sun::star::uno::Reference< com::sun::star::uno::XInterface > CreateDropTarget();
151cdf0e10cSrcweir 
152cdf0e10cSrcweir     static void handleAppDefinedEvent( NSEvent* pEvent );
153cdf0e10cSrcweir 
154cdf0e10cSrcweir     // check whether a particular string is passed on the command line
155cdf0e10cSrcweir     // this is needed to avoid duplicate open events through a) command line and b) NSApp's openFile
156cdf0e10cSrcweir     static bool isOnCommandLine( const rtl::OUString& );
157cdf0e10cSrcweir 
158cdf0e10cSrcweir     void wakeupYield();
159cdf0e10cSrcweir 
160cdf0e10cSrcweir  public:
161cdf0e10cSrcweir     friend class AquaSalFrame;
162cdf0e10cSrcweir 
163cdf0e10cSrcweir     void PostUserEvent( AquaSalFrame* pFrame, sal_uInt16 nType, void* pData );
164cdf0e10cSrcweir     void delayedSettingsChanged( bool bInvalidate );
165cdf0e10cSrcweir 
166cdf0e10cSrcweir     bool isNSAppThread() const;
167cdf0e10cSrcweir 
startedPrintJob()168cdf0e10cSrcweir     void startedPrintJob() { mnActivePrintJobs++; }
endedPrintJob()169cdf0e10cSrcweir     void endedPrintJob() { mnActivePrintJobs--; }
170cdf0e10cSrcweir 
171cdf0e10cSrcweir     // event subtypes for NSApplicationDefined events
172cdf0e10cSrcweir     static const short AppExecuteSVMain   = 0x7fff;
173cdf0e10cSrcweir     static const short AppEndLoopEvent    = 1;
174cdf0e10cSrcweir     static const short AppStartTimerEvent = 10;
175cdf0e10cSrcweir     static const short AppleRemoteEvent   = 15;
176cdf0e10cSrcweir     static const short YieldWakeupEvent   = 20;
177cdf0e10cSrcweir 
178cdf0e10cSrcweir     static NSMenu* GetDynamicDockMenu();
179cdf0e10cSrcweir };
180cdf0e10cSrcweir 
181cdf0e10cSrcweir // helper class: inverted solar guard
182cdf0e10cSrcweir class YieldMutexReleaser
183cdf0e10cSrcweir {
184cdf0e10cSrcweir     sal_uLong mnCount;
185cdf0e10cSrcweir     public:
186cdf0e10cSrcweir     YieldMutexReleaser();
187cdf0e10cSrcweir     ~YieldMutexReleaser();
188cdf0e10cSrcweir };
189cdf0e10cSrcweir 
190cdf0e10cSrcweir // helper class
191cdf0e10cSrcweir rtl::OUString GetOUString( CFStringRef );
192cdf0e10cSrcweir rtl::OUString GetOUString( NSString* );
193cdf0e10cSrcweir CFStringRef CreateCFString( const rtl::OUString& );
194cdf0e10cSrcweir NSString* CreateNSString( const rtl::OUString& );
195cdf0e10cSrcweir 
196cdf0e10cSrcweir CGImageRef CreateCGImage( const Image& );
197cdf0e10cSrcweir NSImage*   CreateNSImage( const Image& );
198cdf0e10cSrcweir 
199cdf0e10cSrcweir #endif // _SV_SALINST_H
200