Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 :
20 : #ifndef _SVP_SALINST_HXX
21 : #define _SVP_SALINST_HXX
22 :
23 : #include <vcl/solarmutex.hxx>
24 :
25 : #include <osl/mutex.hxx>
26 : #include <osl/thread.hxx>
27 : #include <salinst.hxx>
28 : #include <salwtype.hxx>
29 : #include <saltimer.hxx>
30 : #include <generic/geninst.h>
31 : #include <generic/genprn.h>
32 :
33 : #include <list>
34 :
35 : #include <time.h>
36 :
37 : #define VIRTUAL_DESKTOP_WIDTH 1024
38 : #define VIRTUAL_DESKTOP_HEIGHT 768
39 :
40 : class SvpSalInstance;
41 : class SvpSalTimer : public SalTimer
42 : {
43 : SvpSalInstance* m_pInstance;
44 : public:
45 133 : SvpSalTimer( SvpSalInstance* pInstance ) : m_pInstance( pInstance ) {}
46 : virtual ~SvpSalTimer();
47 :
48 : // overload all pure virtual methods
49 : virtual void Start( sal_uLong nMS );
50 : virtual void Stop();
51 : };
52 :
53 : class SvpSalFrame;
54 : class GenPspGraphics;
55 :
56 : class SvpSalInstance : public SalGenericInstance
57 : {
58 : timeval m_aTimeout;
59 : sal_uLong m_nTimeoutMS;
60 : int m_pTimeoutFDS[2];
61 :
62 : // internal event queue
63 : struct SalUserEvent
64 : {
65 : const SalFrame* m_pFrame;
66 : void* m_pData;
67 : sal_uInt16 m_nEvent;
68 :
69 25365 : SalUserEvent( const SalFrame* pFrame, void* pData, sal_uInt16 nEvent = SALEVENT_USEREVENT )
70 : : m_pFrame( pFrame ),
71 : m_pData( pData ),
72 25365 : m_nEvent( nEvent )
73 25365 : {}
74 : };
75 :
76 : oslMutex m_aEventGuard;
77 : std::list< SalUserEvent > m_aUserEvents;
78 :
79 : std::list< SalFrame* > m_aFrames;
80 :
81 : bool isFrameAlive( const SalFrame* pFrame ) const;
82 :
83 : protected:
84 : virtual void DoReleaseYield( int nTimeoutMS );
85 :
86 : public:
87 : static SvpSalInstance* s_pDefaultInstance;
88 :
89 : SvpSalInstance( SalYieldMutex *pMutex );
90 : virtual ~SvpSalInstance();
91 :
92 : void PostEvent( const SalFrame* pFrame, void* pData, sal_uInt16 nEvent );
93 :
94 : bool PostedEventsInQueue();
95 :
96 : void StartTimer( sal_uLong nMS );
97 : void StopTimer();
98 : void Wakeup();
99 :
100 3505 : void registerFrame( SalFrame* pFrame ) { m_aFrames.push_back( pFrame ); }
101 : void deregisterFrame( SalFrame* pFrame );
102 : const std::list< SalFrame* >&
103 21 : getFrames() const { return m_aFrames; }
104 :
105 : bool CheckTimeout( bool bExecuteTimers = true );
106 :
107 : // Frame
108 : virtual SalFrame* CreateChildFrame( SystemParentData* pParent, sal_uLong nStyle );
109 : virtual SalFrame* CreateFrame( SalFrame* pParent, sal_uLong nStyle );
110 : virtual void DestroyFrame( SalFrame* pFrame );
111 :
112 : // Object (System Child Window)
113 : virtual SalObject* CreateObject( SalFrame* pParent, SystemWindowData* pWindowData, sal_Bool bShow = sal_True );
114 : virtual void DestroyObject( SalObject* pObject );
115 :
116 : // VirtualDevice
117 : // nDX and nDY in Pixel
118 : // nBitCount: 0 == Default(=as window) / 1 == Mono
119 : // pData allows for using a system dependent graphics or device context
120 : virtual SalVirtualDevice* CreateVirtualDevice( SalGraphics* pGraphics,
121 : long nDX, long nDY,
122 : sal_uInt16 nBitCount, const SystemGraphicsData *pData = NULL );
123 : virtual void DestroyVirtualDevice( SalVirtualDevice* pDevice );
124 :
125 : // Printer
126 : // pSetupData->mpDriverData can be 0
127 : // pSetupData must be updatet with the current
128 : // JobSetup
129 : virtual SalInfoPrinter* CreateInfoPrinter( SalPrinterQueueInfo* pQueueInfo,
130 : ImplJobSetup* pSetupData );
131 : virtual void DestroyInfoPrinter( SalInfoPrinter* pPrinter );
132 : virtual SalPrinter* CreatePrinter( SalInfoPrinter* pInfoPrinter );
133 : virtual void DestroyPrinter( SalPrinter* pPrinter );
134 :
135 : virtual void GetPrinterQueueInfo( ImplPrnQueueList* pList );
136 : virtual void GetPrinterQueueState( SalPrinterQueueInfo* pInfo );
137 : virtual void DeletePrinterQueueInfo( SalPrinterQueueInfo* pInfo );
138 : virtual OUString GetDefaultPrinter();
139 : virtual void PostPrintersChanged();
140 :
141 : // SalTimer
142 : virtual SalTimer* CreateSalTimer();
143 : // SalI18NImeStatus
144 : virtual SalI18NImeStatus* CreateI18NImeStatus();
145 : // SalSystem
146 : virtual SalSystem* CreateSalSystem();
147 : // SalBitmap
148 : virtual SalBitmap* CreateSalBitmap();
149 :
150 : // wait next event and dispatch
151 : // must returned by UserEvent (SalFrame::PostEvent)
152 : // and timer
153 : virtual void Yield( bool bWait, bool bHandleAllCurrentEvents );
154 : virtual bool AnyInput( sal_uInt16 nType );
155 :
156 : // may return NULL to disable session management
157 : virtual SalSession* CreateSalSession();
158 :
159 : virtual void* GetConnectionIdentifier( ConnectionIdentifierType& rReturnedType, int& rReturnedBytes );
160 :
161 : virtual void AddToRecentDocumentList(const OUString& rFileUrl, const OUString& rMimeType);
162 :
163 : virtual GenPspGraphics *CreatePrintGraphics();
164 : };
165 :
166 : #endif // _SV_SALINST_HXX
167 :
168 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|