xref: /aoo41x/main/vcl/inc/aqua/saldata.hxx (revision ff005604)
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;	        // list of all frames
87     std::hash_set<const AquaSalFrame*,FrameHash>  maFrameCheck;     // for fast check of frame existance
88 	std::list<AquaSalFrame*>                      maPresentationFrames;  // list of frames in presentation mode
89 	SalObject                                    *mpFirstObject;	// pointer of first object window
90 	SalVirtualDevice                             *mpFirstVD;    	// first VirDev
91 	SalPrinter                                   *mpFirstPrinter; 	// first printing printer
92     SystemFontList                               *mpFontList;
93     NSStatusItem*                                 mpStatusItem;     // one status item that draws all our stati
94                                                                     // at the moment this is only one add menu button
95 
96     CGColorSpaceRef                               mxRGBSpace;
97     CGColorSpaceRef                               mxGraySpace;
98     CGColorSpaceRef                               mxP50Space;
99     CGPatternRef                                  mxP50Pattern;
100 
101     std::vector< NSCursor* >                      maCursors;
102     std::vector< NSMenuItem* >                    maFallbackMenu;
103     std::map< NSEvent*, bool >                    maKeyEventAnswer;
104 
105     static oslThreadKey                           s_aAutoReleaseKey;
106 
107     bool			                              mbIsScrollbarDoubleMax;	// TODO: support DoubleMin and DoubleBoth too
108     SInt32                                        mnSystemVersion;          // Store System Version
109     MainController*                               mpMainController;         // Apple Remote
110 
111     NSObject*                                     mpDockIconClickHandler;
112     long                                          mnDPIX;           // #i100617# read DPI only once per office life
113     long                                          mnDPIY;           // #i100617# read DPI only once per office life
114 
115     com::sun::star::uno::Reference< com::sun::star::uno::XInterface >
116                                                   mxClipboard;
117 
118     SalData();
119     ~SalData();
120 
121     NSCursor* getCursor( PointerStyle i_eStyle );
122 
123     static void ensureThreadAutoreleasePool();
124     static void drainThreadAutoreleasePool();
125 
126     static NSStatusItem* getStatusItem();
127 };
128 
129 inline void SetSalData( SalData* pData ) { ImplGetSVData()->mpSalData = (void*)pData; }
130 inline SalData *GetSalData() { return (SalData*)ImplGetSVData()->mpSalData; }
131 inline SalData *GetAppSalData() { return (SalData*)ImplGetAppSVData()->mpSalData; }
132 
133 // --- Prototypes ---
134 
135 sal_Bool ImplSalYieldMutexTryToAcquire();
136 void ImplSalYieldMutexAcquire();
137 void ImplSalYieldMutexRelease();
138 
139 #endif	// _SV_SALDATA_HXX
140