xref: /aoo41x/main/vcl/inc/unx/gtk/gtkinst.hxx (revision 161f4cd1)
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 _VCL_GTKINST_HXX
25 #define _VCL_GTKINST_HXX
26 
27 #include <unx/salinst.h>
28 #include <unx/salsys.h>
29 
30 class GtkYieldMutex : public SalYieldMutex
31 {
32 public:
33 												GtkYieldMutex();
34 	virtual void								acquire();
35 	virtual void								release();
36 	virtual sal_Bool 							tryToAcquire();
37 
38     virtual int Grab();
39     virtual void Ungrab( int );
40 
41     class GtkYieldGuard
42     {
43         GtkYieldMutex*	m_pMutex;
44         int				m_nGrab;
45     public:
GtkYieldGuard(GtkYieldMutex * pMutex)46         GtkYieldGuard( GtkYieldMutex* pMutex )
47                 : m_pMutex( pMutex )
48         {
49             m_nGrab = m_pMutex->Grab();
50         }
~GtkYieldGuard()51         ~GtkYieldGuard()
52         {
53             m_pMutex->Ungrab( m_nGrab );
54         }
55     };
56 };
57 
58 class GtkHookedYieldMutex : public GtkYieldMutex
59 {
Grab()60 	virtual int		 Grab()				{ return 0; };
Ungrab(int)61 	virtual void	 Ungrab(int )		{};
62 	std::list<sal_uLong> aYieldStack;
63 public:
64 	GtkHookedYieldMutex();
65 	virtual void      acquire();
66 	virtual void      release();
tryToAcquire()67 	virtual sal_Bool  tryToAcquire() { return SalYieldMutex::tryToAcquire(); }
68 	void ThreadsEnter();
69 	void ThreadsLeave();
70 };
71 
72 
73 #define GTK_YIELD_GRAB() GtkYieldMutex::GtkYieldGuard aLocalGtkYieldGuard( static_cast<GtkYieldMutex*>(GetSalData()->m_pInstance->GetYieldMutex()) )
74 
75 class GtkInstance : public X11SalInstance
76 {
77 public:
GtkInstance(SalYieldMutex * pMutex)78     GtkInstance( SalYieldMutex* pMutex )
79             : X11SalInstance( pMutex )
80     {}
81     virtual ~GtkInstance();
82 
83     virtual SalFrame*			CreateFrame( SalFrame* pParent, sal_uLong nStyle );
84     virtual SalFrame*           CreateChildFrame( SystemParentData* pParent, sal_uLong nStyle );
85     virtual SalObject*			CreateObject( SalFrame* pParent, SystemWindowData* pWindowData, sal_Bool bShow = sal_True );
86     virtual SalSystem*			CreateSalSystem();
87     virtual void                AddToRecentDocumentList(const rtl::OUString& rFileUrl, const rtl::OUString& rMimeType);
88 };
89 
90 class GtkSalSystem : public X11SalSystem
91 {
92 public:
GtkSalSystem()93 	GtkSalSystem() : X11SalSystem() {}
94     virtual ~GtkSalSystem();
95     virtual int ShowNativeDialog( const String& rTitle,
96                                   const String& rMessage,
97                                   const std::list< String >& rButtons,
98                                   int nDefButton );
99 };
100 
101 #endif // _VCL_GTKINST_HXX
102