xref: /trunk/main/vcl/inc/aqua/saldata.hxx (revision ebfcd9af)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 #ifndef _SV_SALDATA_HXX
25 #define _SV_SALDATA_HXX
26 
27 #include "premac.h"
28 #include <Cocoa/Cocoa.h>
29 #include "postmac.h"
30 
31 #include "com/sun/star/uno/Reference.hxx"
32 
33 #include "vcl/ptrstyle.hxx"
34 
35 #include "svdata.hxx"
36 #include "salwtype.hxx"
37 
38 #include <list>
39 #include <vector>
40 #include <map>
41 #include <hash_set>
42 
43 #include <cstdio>
44 #include <cstdarg>
45 
46 #include "apple_remote/RemoteMainController.h"
47 
48 class AquaSalInstance;
49 class SalObject;
50 class SalFrame;
51 class SalVirtualDevice;
52 class SalPrinter;
53 class SystemFontList;
54 
55 // ------------------
56 // - Some constants -
57 // ------------------
58 
59 #define SAL_CLIPRECT_COUNT 16
60 
61 #define VER_TIGER   0x1040
62 #define VER_LEOPARD 0x1050
63 
64 // -----------
65 // - SalData -
66 // -----------
67 
68 class AquaSalFrame;
69 struct FrameHash : public std::hash<sal_IntPtr>
70 {
71     size_t operator()(const AquaSalFrame* frame) const
72     { return std::hash<sal_IntPtr>::operator()( reinterpret_cast<const sal_IntPtr>(frame) ); }
73 };
74 
75 #define INVALID_CURSOR_PTR (NSCursor*)0xdeadbeef
76 
77 struct SalData
78 {
79 
80 	SALTIMERPROC                                  mpTimerProc;		// timer callback proc
81 	AquaSalInstance                              *mpFirstInstance;	// pointer of first instance
82 	std::list<AquaSalFrame*>                      maFrames;	        // list of all frames
83     std::hash_set<const AquaSalFrame*,FrameHash>  maFrameCheck;     // for fast check of frame existance
84 	std::list<AquaSalFrame*>                      maPresentationFrames;  // list of frames in presentation mode
85 	SalObject                                    *mpFirstObject;	// pointer of first object window
86 	SalVirtualDevice                             *mpFirstVD;    	// first VirDev
87 	SalPrinter                                   *mpFirstPrinter; 	// first printing printer
88     SystemFontList                               *mpFontList;
89     NSStatusItem*                                 mpStatusItem;     // one status item that draws all our stati
90                                                                     // at the moment this is only one add menu button
91 
92     CGColorSpaceRef                               mxRGBSpace;
93     CGColorSpaceRef                               mxGraySpace;
94     CGColorSpaceRef                               mxP50Space;
95     CGPatternRef                                  mxP50Pattern;
96 
97     std::vector< NSCursor* >                      maCursors;
98     std::vector< NSMenuItem* >                    maFallbackMenu;
99     std::map< NSEvent*, bool >                    maKeyEventAnswer;
100 
101     static oslThreadKey                           s_aAutoReleaseKey;
102 
103     bool			                              mbIsScrollbarDoubleMax;	// TODO: support DoubleMin and DoubleBoth too
104     SInt32                                        mnSystemVersion;          // Store System Version
105     MainController*                               mpMainController;         // Apple Remote
106 
107     NSObject*                                     mpDockIconClickHandler;
108     long                                          mnDPIX;           // #i100617# read DPI only once per office life
109     long                                          mnDPIY;           // #i100617# read DPI only once per office life
110 
111     com::sun::star::uno::Reference< com::sun::star::uno::XInterface >
112                                                   mxClipboard;
113 
114     SalData();
115     ~SalData();
116 
117     NSCursor* getCursor( PointerStyle i_eStyle );
118 
119     static void ensureThreadAutoreleasePool();
120     static void drainThreadAutoreleasePool();
121 
122     static NSStatusItem* getStatusItem();
123 };
124 
125 inline void SetSalData( SalData* pData ) { ImplGetSVData()->mpSalData = (void*)pData; }
126 inline SalData *GetSalData() { return (SalData*)ImplGetSVData()->mpSalData; }
127 inline SalData *GetAppSalData() { return (SalData*)ImplGetAppSVData()->mpSalData; }
128 
129 // --- Prototypes ---
130 
131 sal_Bool ImplSalYieldMutexTryToAcquire();
132 void ImplSalYieldMutexAcquire();
133 void ImplSalYieldMutexRelease();
134 
135 #endif	// _SV_SALDATA_HXX
136