Update ooo320-m1
[ooovba.git] / vcl / unx / headless / svpinst.hxx
blobc4c97cdc465eba4cc1628c363c85c8748c70401d
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: svpinst.hxx,v $
10 * $Revision: 1.6.116.1 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef _SVP_SALINST_HXX
32 #define _SVP_SALINST_HXX
34 #include <vcl/salinst.hxx>
35 #include <vcl/salwtype.hxx>
36 #include <vcl/saltimer.hxx>
37 #include <vos/mutex.hxx>
38 #include <vos/thread.hxx>
40 #include <list>
42 #include <time.h> // timeval
44 #define VIRTUAL_DESKTOP_WIDTH 1024
45 #define VIRTUAL_DESKTOP_HEIGHT 768
46 #define VIRTUAL_DESKTOP_DEPTH 24
48 // -------------------------------------------------------------------------
49 // SalYieldMutex
50 // -------------------------------------------------------------------------
52 class SvpSalYieldMutex : public NAMESPACE_VOS(OMutex)
54 protected:
55 ULONG mnCount;
56 NAMESPACE_VOS(OThread)::TThreadIdentifier mnThreadId;
58 public:
59 SvpSalYieldMutex();
61 virtual void acquire();
62 virtual void release();
63 virtual sal_Bool tryToAcquire();
65 ULONG GetAcquireCount() const { return mnCount; }
66 NAMESPACE_VOS(OThread)::TThreadIdentifier GetThreadId() const { return mnThreadId; }
69 // ---------------
70 // - SalTimer -
71 // ---------------
72 class SvpSalInstance;
73 class SvpSalTimer : public SalTimer
75 SvpSalInstance* m_pInstance;
76 public:
77 SvpSalTimer( SvpSalInstance* pInstance ) : m_pInstance( pInstance ) {}
78 virtual ~SvpSalTimer();
80 // overload all pure virtual methods
81 virtual void Start( ULONG nMS );
82 virtual void Stop();
85 // ---------------
86 // - SalInstance -
87 // ---------------
88 class SvpSalFrame;
89 class SvpSalInstance : public SalInstance
91 timeval m_aTimeout;
92 ULONG m_nTimeoutMS;
93 int m_pTimeoutFDS[2];
94 SvpSalYieldMutex m_aYieldMutex;
96 // internal event queue
97 struct SalUserEvent
99 const SalFrame* m_pFrame;
100 void* m_pData;
101 USHORT m_nEvent;
103 SalUserEvent( const SalFrame* pFrame, void* pData, USHORT nEvent = SALEVENT_USEREVENT )
104 : m_pFrame( pFrame ),
105 m_pData( pData ),
106 m_nEvent( nEvent )
110 oslMutex m_aEventGuard;
111 std::list< SalUserEvent > m_aUserEvents;
113 std::list< SalFrame* > m_aFrames;
114 public:
115 static SvpSalInstance* s_pDefaultInstance;
117 SvpSalInstance();
118 virtual ~SvpSalInstance();
120 void PostEvent( const SalFrame* pFrame, void* pData, USHORT nEvent );
121 void CancelEvent( const SalFrame* pFrame, void* pData, USHORT nEvent );
123 void StartTimer( ULONG nMS );
124 void StopTimer();
125 void Wakeup();
127 void registerFrame( SalFrame* pFrame ) { m_aFrames.push_back( pFrame ); }
128 void deregisterFrame( SalFrame* pFrame );
129 const std::list< SalFrame* >& getFrames() const { return m_aFrames; }
131 bool CheckTimeout( bool bExecuteTimers = true );
133 // Frame
134 virtual SalFrame* CreateChildFrame( SystemParentData* pParent, ULONG nStyle );
135 virtual SalFrame* CreateFrame( SalFrame* pParent, ULONG nStyle );
136 virtual void DestroyFrame( SalFrame* pFrame );
138 // Object (System Child Window)
139 virtual SalObject* CreateObject( SalFrame* pParent, SystemWindowData* pWindowData, BOOL bShow = TRUE );
140 virtual void DestroyObject( SalObject* pObject );
142 // VirtualDevice
143 // nDX and nDY in Pixel
144 // nBitCount: 0 == Default(=as window) / 1 == Mono
145 // pData allows for using a system dependent graphics or device context
146 virtual SalVirtualDevice* CreateVirtualDevice( SalGraphics* pGraphics,
147 long nDX, long nDY,
148 USHORT nBitCount, const SystemGraphicsData *pData = NULL );
149 virtual void DestroyVirtualDevice( SalVirtualDevice* pDevice );
151 // Printer
152 // pSetupData->mpDriverData can be 0
153 // pSetupData must be updatet with the current
154 // JobSetup
155 virtual SalInfoPrinter* CreateInfoPrinter( SalPrinterQueueInfo* pQueueInfo,
156 ImplJobSetup* pSetupData );
157 virtual void DestroyInfoPrinter( SalInfoPrinter* pPrinter );
158 virtual SalPrinter* CreatePrinter( SalInfoPrinter* pInfoPrinter );
159 virtual void DestroyPrinter( SalPrinter* pPrinter );
161 virtual void GetPrinterQueueInfo( ImplPrnQueueList* pList );
162 virtual void GetPrinterQueueState( SalPrinterQueueInfo* pInfo );
163 virtual void DeletePrinterQueueInfo( SalPrinterQueueInfo* pInfo );
164 virtual String GetDefaultPrinter();
166 // SalTimer
167 virtual SalTimer* CreateSalTimer();
168 // SalI18NImeStatus
169 virtual SalI18NImeStatus* CreateI18NImeStatus();
170 // SalSystem
171 virtual SalSystem* CreateSalSystem();
172 // SalBitmap
173 virtual SalBitmap* CreateSalBitmap();
175 // YieldMutex
176 virtual vos::IMutex* GetYieldMutex();
177 virtual ULONG ReleaseYieldMutex();
178 virtual void AcquireYieldMutex( ULONG nCount );
180 // wait next event and dispatch
181 // must returned by UserEvent (SalFrame::PostEvent)
182 // and timer
183 virtual void Yield( bool bWait, bool bHandleAllCurrentEvents );
184 virtual bool AnyInput( USHORT nType );
186 // Menues
187 virtual SalMenu* CreateMenu( BOOL bMenuBar );
188 virtual void DestroyMenu( SalMenu* pMenu);
189 virtual SalMenuItem* CreateMenuItem( const SalItemParams* pItemData );
190 virtual void DestroyMenuItem( SalMenuItem* pItem );
192 // may return NULL to disable session management
193 virtual SalSession* CreateSalSession();
195 virtual void* GetConnectionIdentifier( ConnectionIdentifierType& rReturnedType, int& rReturnedBytes );
197 virtual void AddToRecentDocumentList(const rtl::OUString& rFileUrl, const rtl::OUString& rMimeType);
200 #endif // _SV_SALINST_HXX