xref: /trunk/main/vcl/inc/aqua/saldata.hxx (revision cdf0e10c)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 #ifndef _SV_SALDATA_HXX
29 #define _SV_SALDATA_HXX
30 
31 #include "premac.h"
32 #include <Cocoa/Cocoa.h>
33 #include "postmac.h"
34 
35 #include "com/sun/star/uno/Reference.hxx"
36 
37 #include "vcl/ptrstyle.hxx"
38 
39 #include "svdata.hxx"
40 #include "salwtype.hxx"
41 
42 #include <list>
43 #include <vector>
44 #include <map>
45 #include <hash_set>
46 
47 #include <cstdio>
48 #include <cstdarg>
49 
50 #include "apple_remote/RemoteMainController.h"
51 
52 class AquaSalInstance;
53 class SalObject;
54 class SalFrame;
55 class SalVirtualDevice;
56 class SalPrinter;
57 class SystemFontList;
58 
59 // ------------------
60 // - Some constants -
61 // ------------------
62 
63 #define SAL_CLIPRECT_COUNT 16
64 
65 #define VER_TIGER   0x1040
66 #define VER_LEOPARD 0x1050
67 
68 // -----------
69 // - SalData -
70 // -----------
71 
72 class AquaSalFrame;
73 struct FrameHash : public std::hash<sal_IntPtr>
74 {
75     size_t operator()(const AquaSalFrame* frame) const
76     { return std::hash<sal_IntPtr>::operator()( reinterpret_cast<const sal_IntPtr>(frame) ); }
77 };
78 
79 #define INVALID_CURSOR_PTR (NSCursor*)0xdeadbeef
80 
81 struct SalData
82 {
83 
84 	SALTIMERPROC                                  mpTimerProc;		// timer callback proc
85 	AquaSalInstance                              *mpFirstInstance;	// pointer of first instance
86 	std::list<AquaSalFrame*>                      maFrames;	        // pointer of first frame
87     std::hash_set<const AquaSalFrame*,FrameHash>  maFrameCheck;     // for fast check of frame existance
88 	SalObject                                    *mpFirstObject;	// pointer of first object window
89 	SalVirtualDevice                             *mpFirstVD;    	// first VirDev
90 	SalPrinter                                   *mpFirstPrinter; 	// first printing printer
91     SystemFontList                               *mpFontList;
92     NSStatusItem*                                 mpStatusItem;     // one status item that draws all our stati
93                                                                     // at the moment this is only one add menu button
94 
95     CGColorSpaceRef                               mxRGBSpace;
96     CGColorSpaceRef                               mxGraySpace;
97     CGColorSpaceRef                               mxP50Space;
98     CGPatternRef                                  mxP50Pattern;
99 
100     std::vector< NSCursor* >                      maCursors;
101     std::vector< NSMenuItem* >                    maFallbackMenu;
102     std::map< NSEvent*, bool >                    maKeyEventAnswer;
103 
104     static oslThreadKey                           s_aAutoReleaseKey;
105 
106     bool			                              mbIsScrollbarDoubleMax;	// TODO: support DoubleMin and DoubleBoth too
107     SInt32                                        mnSystemVersion;          // Store System Version
108     MainController*                               mpMainController;         // Apple Remote
109 
110     NSObject*                                     mpDockIconClickHandler;
111     long                                          mnDPIX;           // #i100617# read DPI only once per office life
112     long                                          mnDPIY;           // #i100617# read DPI only once per office life
113 
114     com::sun::star::uno::Reference< com::sun::star::uno::XInterface >
115                                                   mxClipboard;
116 
117     SalData();
118     ~SalData();
119 
120     NSCursor* getCursor( PointerStyle i_eStyle );
121 
122     static void ensureThreadAutoreleasePool();
123     static void drainThreadAutoreleasePool();
124 
125     static NSStatusItem* getStatusItem();
126 };
127 
128 inline void SetSalData( SalData* pData ) { ImplGetSVData()->mpSalData = (void*)pData; }
129 inline SalData *GetSalData() { return (SalData*)ImplGetSVData()->mpSalData; }
130 inline SalData *GetAppSalData() { return (SalData*)ImplGetAppSVData()->mpSalData; }
131 
132 // --- Prototypes ---
133 
134 sal_Bool ImplSalYieldMutexTryToAcquire();
135 void ImplSalYieldMutexAcquire();
136 void ImplSalYieldMutexRelease();
137 
138 #endif	// _SV_SALDATA_HXX
139