Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : : #ifndef _VCL_GTKINST_HXX
30 : : #define _VCL_GTKINST_HXX
31 : :
32 : : #include <boost/shared_ptr.hpp>
33 : :
34 : : #include <unx/salinst.h>
35 : : #include <generic/gensys.h>
36 : : #include <headless/svpinst.hxx>
37 : : #include <gtk/gtk.h>
38 : :
39 : : namespace vcl
40 : : {
41 : : namespace unx
42 : : {
43 : : class GtkPrintWrapper;
44 : : }
45 : : }
46 : :
47 : : class GenPspGraphics;
48 : 0 : class GtkYieldMutex : public SalYieldMutex
49 : : {
50 : : public:
51 : : GtkYieldMutex();
52 : : virtual void acquire();
53 : : virtual void release();
54 : : virtual sal_Bool tryToAcquire();
55 : :
56 : : virtual int Grab();
57 : : virtual void Ungrab( int );
58 : :
59 : : class GtkYieldGuard
60 : : {
61 : : GtkYieldMutex* m_pMutex;
62 : : int m_nGrab;
63 : : public:
64 : 0 : GtkYieldGuard( GtkYieldMutex* pMutex )
65 : 0 : : m_pMutex( pMutex )
66 : : {
67 : 0 : m_nGrab = m_pMutex->Grab();
68 : 0 : }
69 : 0 : ~GtkYieldGuard()
70 : : {
71 : 0 : m_pMutex->Ungrab( m_nGrab );
72 : 0 : }
73 : : };
74 : : };
75 : :
76 : 0 : class GtkHookedYieldMutex : public GtkYieldMutex
77 : : {
78 : 0 : virtual int Grab() { return 0; };
79 : 0 : virtual void Ungrab(int ) {};
80 : : std::list<sal_uLong> aYieldStack;
81 : : public:
82 : : GtkHookedYieldMutex();
83 : : virtual void acquire();
84 : : virtual void release();
85 : 0 : virtual sal_Bool tryToAcquire() { return SalYieldMutex::tryToAcquire(); }
86 : : void ThreadsEnter();
87 : : void ThreadsLeave();
88 : : };
89 : :
90 : :
91 : : #define GTK_YIELD_GRAB() GtkYieldMutex::GtkYieldGuard aLocalGtkYieldGuard( static_cast<GtkYieldMutex*>(GetSalData()->m_pInstance->GetYieldMutex()) )
92 : :
93 : : class GtkSalTimer;
94 : : #if GTK_CHECK_VERSION(3,0,0)
95 : : class GtkInstance : public SvpSalInstance
96 : : #else
97 : : class GtkInstance : public X11SalInstance
98 : : #endif
99 : : {
100 : : #if GTK_CHECK_VERSION(3,0,0)
101 : : typedef SvpSalInstance Superclass_t;
102 : : #else
103 : : typedef X11SalInstance Superclass_t;
104 : : #endif
105 : : public:
106 : : GtkInstance( SalYieldMutex* pMutex );
107 : : virtual ~GtkInstance();
108 : : void Init();
109 : :
110 : : virtual SalFrame* CreateFrame( SalFrame* pParent, sal_uLong nStyle );
111 : : virtual SalFrame* CreateChildFrame( SystemParentData* pParent, sal_uLong nStyle );
112 : : virtual SalObject* CreateObject( SalFrame* pParent, SystemWindowData* pWindowData, sal_Bool bShow = sal_True );
113 : : virtual SalSystem* CreateSalSystem();
114 : : virtual SalInfoPrinter* CreateInfoPrinter(SalPrinterQueueInfo* pPrinterQueueInfo, ImplJobSetup* pJobSetup);
115 : : virtual SalPrinter* CreatePrinter( SalInfoPrinter* pInfoPrinter );
116 : : virtual SalTimer* CreateSalTimer();
117 : : virtual void AddToRecentDocumentList(const rtl::OUString& rFileUrl, const rtl::OUString& rMimeType);
118 : : virtual SalVirtualDevice* CreateVirtualDevice( SalGraphics*,
119 : : long nDX, long nDY,
120 : : sal_uInt16 nBitCount,
121 : : const SystemGraphicsData* );
122 : : virtual SalBitmap* CreateSalBitmap();
123 : :
124 : : virtual void Yield( bool bWait, bool bHandleAllCurrentEvents );
125 : : virtual bool AnyInput( sal_uInt16 nType );
126 : :
127 : : virtual GenPspGraphics *CreatePrintGraphics();
128 : :
129 : 0 : virtual bool hasNativeFileSelection() const { return true; }
130 : :
131 : : virtual com::sun::star::uno::Reference< com::sun::star::ui::dialogs::XFilePicker2 >
132 : : createFilePicker( const com::sun::star::uno::Reference<
133 : : com::sun::star::uno::XComponentContext >& );
134 : : virtual com::sun::star::uno::Reference< com::sun::star::ui::dialogs::XFolderPicker >
135 : : createFolderPicker( const com::sun::star::uno::Reference<
136 : : com::sun::star::uno::XComponentContext >& );
137 : :
138 : : void RemoveTimer (SalTimer *pTimer);
139 : :
140 : : // for managing a mirror of the in-flight un-dispatched gdk event queue
141 : : void addEvent( sal_uInt16 nMask );
142 : : void subtractEvent( sal_uInt16 nMask );
143 : :
144 : : boost::shared_ptr<vcl::unx::GtkPrintWrapper> getPrintWrapper() const;
145 : :
146 : : private:
147 : : std::vector<GtkSalTimer *> m_aTimers;
148 : : bool IsTimerExpired();
149 : :
150 : : mutable boost::shared_ptr<vcl::unx::GtkPrintWrapper> m_pPrintWrapper;
151 : : };
152 : :
153 : : #endif // _VCL_GTKINST_HXX
154 : :
155 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|