xref: /aoo41x/main/vcl/inc/salframe.hxx (revision cdf0e10c)
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_SALFRAME_HXX
29 #define _SV_SALFRAME_HXX
30 
31 #include <vcl/sv.h>
32 #include <vcl/dllapi.h>
33 
34 #ifdef __cplusplus
35 
36 #ifndef _SV_PTRSTYLE_HXX
37 #include <vcl/ptrstyle.hxx>
38 #endif
39 #include <vcl/sndstyle.hxx>
40 
41 #endif // __cplusplus
42 #include <salwtype.hxx>
43 #include <salgeom.hxx>
44 #include <tools/gen.hxx>
45 #include <vcl/region.hxx>
46 
47 #ifndef _VCL_IMPDEL_HXX
48 #include <vcl/impdel.hxx>
49 #endif
50 #include <rtl/ustring.hxx>
51 #include <vcl/keycod.hxx>
52 
53 class AllSettings;
54 class SalGraphics;
55 class SalBitmap;
56 class SalMenu;
57 class Window;
58 
59 
60 struct SalFrameState;
61 struct SalInputContext;
62 struct SystemEnvData;
63 
64 // -----------------
65 // - SalFrameTypes -
66 // -----------------
67 
68 #define SAL_FRAME_TOTOP_RESTOREWHENMIN      ((sal_uInt16)0x0001)
69 #define SAL_FRAME_TOTOP_FOREGROUNDTASK      ((sal_uInt16)0x0002)
70 #define SAL_FRAME_TOTOP_GRABFOCUS           ((sal_uInt16)0x0004)
71 #define SAL_FRAME_TOTOP_GRABFOCUS_ONLY		 ((sal_uInt16)0x0008)
72 
73 #define SAL_FRAME_ENDEXTTEXTINPUT_COMPLETE  ((sal_uInt16)0x0001)
74 #define SAL_FRAME_ENDEXTTEXTINPUT_CANCEL    ((sal_uInt16)0x0002)
75 
76 
77 // -----------------
78 // - SalFrameStyle -
79 // -----------------
80 
81 #define SAL_FRAME_STYLE_DEFAULT             ((sal_uLong)0x00000001)
82 #define SAL_FRAME_STYLE_MOVEABLE            ((sal_uLong)0x00000002)
83 #define SAL_FRAME_STYLE_SIZEABLE            ((sal_uLong)0x00000004)
84 #define SAL_FRAME_STYLE_CLOSEABLE           ((sal_uLong)0x00000008)
85 
86 // no shadow effect on WindowsXP
87 #define SAL_FRAME_STYLE_NOSHADOW            ((sal_uLong)0x00000010)
88 // indicate tooltip windows, so they can always be topmost
89 #define SAL_FRAME_STYLE_TOOLTIP             ((sal_uLong)0x00000020)
90 // windows without windowmanager decoration, this typically only applies to floating windows
91 #define SAL_FRAME_STYLE_OWNERDRAWDECORATION ((sal_uLong)0x00000040)
92 // dialogs
93 #define SAL_FRAME_STYLE_DIALOG              ((sal_uLong)0x00000080)
94 // partial fullscreen: fullscreen on one monitor of a multimonitor display
95 #define SAL_FRAME_STYLE_PARTIAL_FULLSCREEN  ((sal_uLong)0x00800000)
96 // plugged system child window
97 #define SAL_FRAME_STYLE_PLUG                ((sal_uLong)0x10000000)
98 // system child window inside another SalFrame
99 #define SAL_FRAME_STYLE_SYSTEMCHILD         ((sal_uLong)0x08000000)
100 // floating window
101 #define SAL_FRAME_STYLE_FLOAT               ((sal_uLong)0x20000000)
102 // floating window that needs to be focusable
103 #define SAL_FRAME_STYLE_FLOAT_FOCUSABLE     ((sal_uLong)0x04000000)
104 // toolwindows should be painted with a smaller decoration
105 #define SAL_FRAME_STYLE_TOOLWINDOW          ((sal_uLong)0x40000000)
106 // the window containing the intro bitmap, aka splashscreen
107 #define SAL_FRAME_STYLE_INTRO               ((sal_uLong)0x80000000)
108 
109 /*
110 #define SAL_FRAME_STYLE_MINABLE             ((sal_uLong)0x00000008)
111 #define SAL_FRAME_STYLE_MAXABLE             ((sal_uLong)0x00000010)
112 #define SAL_FRAME_STYLE_BORDER              ((sal_uLong)0x00000040)
113 #define SAL_FRAME_STYLE_DOC                 ((sal_uLong)0x00004000)
114 #define SAL_FRAME_STYLE_DIALOG              ((sal_uLong)0x00008000)
115 #define SAL_FRAME_STYLE_TOOL                ((sal_uLong)0x00010000)
116 #define SAL_FRAME_STYLE_FULLSIZE            ((sal_uLong)0x00020000)
117 */
118 
119 // ----------------------------------------
120 // - extended frame style                 -
121 // - (sal equivalent to extended WinBits) -
122 // ----------------------------------------
123 typedef sal_uInt64 SalExtStyle;
124 #define SAL_FRAME_EXT_STYLE_DOCUMENT        SalExtStyle(0x00000001)
125 #define SAL_FRAME_EXT_STYLE_DOCMODIFIED     SalExtStyle(0x00000002)
126 
127 // ------------------------
128 // - Flags for SetPosSize -
129 // ------------------------
130 
131 #define SAL_FRAME_POSSIZE_X                 ((sal_uInt16)0x0001)
132 #define SAL_FRAME_POSSIZE_Y                 ((sal_uInt16)0x0002)
133 #define SAL_FRAME_POSSIZE_WIDTH             ((sal_uInt16)0x0004)
134 #define SAL_FRAME_POSSIZE_HEIGHT            ((sal_uInt16)0x0008)
135 
136 #ifdef __cplusplus
137 
138 using namespace rtl;
139 
140 // ------------
141 // - SalFrame -
142 // ------------
143 
144 struct SystemParentData;
145 
146 class VCL_PLUGIN_PUBLIC SalFrame : public vcl::DeletionNotifier
147 {
148     // the VCL window corresponding to this frame
149     Window*					m_pWindow;
150     SALFRAMEPROC			m_pProc;
151 public:                     // public for Sal Implementation
152     SalFrame() : m_pWindow( NULL ), m_pProc( NULL ) {}
153     virtual ~SalFrame();
154 
155 public:                     // public for Sal Implementation
156     SalFrameGeometry		maGeometry;
157 
158 public:
159     // SalGraphics or NULL, but two Graphics for all SalFrames
160     // must be returned
161     virtual SalGraphics*		GetGraphics() = 0;
162     virtual void				ReleaseGraphics( SalGraphics* pGraphics ) = 0;
163 
164     // Event must be destroyed, when Frame is destroyed
165     // When Event is called, SalInstance::Yield() must be returned
166     virtual sal_Bool				PostEvent( void* pData ) = 0;
167 
168     virtual void				SetTitle( const XubString& rTitle ) = 0;
169     virtual void				SetIcon( sal_uInt16 nIcon ) = 0;
170     virtual void                SetRepresentedURL( const rtl::OUString& );
171     virtual void                    SetMenu( SalMenu *pSalMenu ) = 0;
172     virtual void                    DrawMenuBar() = 0;
173 
174     virtual void                SetExtendedFrameStyle( SalExtStyle nExtStyle ) = 0;
175 
176     // Before the window is visible, a resize event
177     // must be sent with the correct size
178     virtual void				Show( sal_Bool bVisible, sal_Bool bNoActivate = sal_False ) = 0;
179     virtual void				Enable( sal_Bool bEnable ) = 0;
180     // Set ClientSize and Center the Window to the desktop
181     // and send/post a resize message
182     virtual void                SetMinClientSize( long nWidth, long nHeight ) = 0;
183     virtual void                SetMaxClientSize( long nWidth, long nHeight ) = 0;
184     virtual void				SetPosSize( long nX, long nY, long nWidth, long nHeight, sal_uInt16 nFlags ) = 0;
185     virtual void				GetClientSize( long& rWidth, long& rHeight ) = 0;
186     virtual void				GetWorkArea( Rectangle& rRect ) = 0;
187     virtual SalFrame*			GetParent() const = 0;
188     // Note: x will be mirrored at parent if UI mirroring is active
189     SalFrameGeometry			GetGeometry();
190     const SalFrameGeometry&		GetUnmirroredGeometry() const { return maGeometry; }
191     virtual void				SetWindowState( const SalFrameState* pState ) = 0;
192     virtual sal_Bool				GetWindowState( SalFrameState* pState ) = 0;
193     virtual void				ShowFullScreen( sal_Bool bFullScreen, sal_Int32 nDisplay ) = 0;
194     // Enable/Disable ScreenSaver, SystemAgents, ...
195     virtual void				StartPresentation( sal_Bool bStart ) = 0;
196     // Show Window over all other Windows
197     virtual void				SetAlwaysOnTop( sal_Bool bOnTop ) = 0;
198 
199     // Window to top and grab focus
200     virtual void				ToTop( sal_uInt16 nFlags ) = 0;
201 
202     // this function can call with the same
203     // pointer style
204     virtual void				SetPointer( PointerStyle ePointerStyle ) = 0;
205     virtual void				CaptureMouse( sal_Bool bMouse ) = 0;
206     virtual void				SetPointerPos( long nX, long nY ) = 0;
207 
208     // flush output buffer
209     virtual void				Flush( void) = 0;
210     virtual void                Flush( const Rectangle& );
211     // flush output buffer, wait till outstanding operations are done
212     virtual void				Sync() = 0;
213 
214     virtual void				SetInputContext( SalInputContext* pContext ) = 0;
215     virtual void				EndExtTextInput( sal_uInt16 nFlags ) = 0;
216 
217     virtual String				GetKeyName( sal_uInt16 nKeyCode ) = 0;
218     virtual String				GetSymbolKeyName( const XubString& rFontName, sal_uInt16 nKeyCode ) = 0;
219 
220     // returns in 'rKeyCode' the single keycode that translates to the given unicode when using a keyboard layout of language 'aLangType'
221     // returns sal_False if no mapping exists or function not supported
222     // this is required for advanced menu support
223     virtual sal_Bool                MapUnicodeToKeyCode( sal_Unicode aUnicode, LanguageType aLangType, KeyCode& rKeyCode ) = 0;
224 
225     // returns the input language used for the last key stroke
226     // may be LANGUAGE_DONTKNOW if not supported by the OS
227     virtual LanguageType		GetInputLanguage() = 0;
228 
229     virtual SalBitmap*			SnapShot() = 0;
230 
231     virtual void				UpdateSettings( AllSettings& rSettings ) = 0;
232 
233     virtual void				Beep( SoundType eSoundType ) = 0;
234 
235     // returns system data (most prominent: window handle)
236     virtual const SystemEnvData*	GetSystemData() const = 0;
237 
238     // sets a background bitmap on the frame; the implementation
239     // must not make assumptions about the lifetime of the passed SalBitmap
240     // but should copy its contents to an own buffer
241     virtual void                SetBackgroundBitmap( SalBitmap* ) = 0;
242 
243 
244     // get current modifier, button mask and mouse position
245     struct SalPointerState
246     {
247         sal_uLong   mnState;
248         Point   maPos;      // in frame coordinates
249     };
250 
251     virtual SalPointerState		GetPointerState() = 0;
252 
253     // set new parent window
254     virtual void				SetParent( SalFrame* pNewParent ) = 0;
255     // reparent window to act as a plugin; implementation
256     // may choose to use a new system window inetrnally
257     // return false to indicate failure
258     virtual bool				SetPluginParent( SystemParentData* pNewParent ) = 0;
259 
260     // move the frame to a new screen
261     virtual void                SetScreenNumber( unsigned int nScreen ) = 0;
262 
263     // shaped system windows
264     // set clip region to none (-> rectangular windows, normal state)
265 	virtual void					ResetClipRegion() = 0;
266     // start setting the clipregion consisting of nRects rectangles
267 	virtual void					BeginSetClipRegion( sal_uLong nRects ) = 0;
268     // add a rectangle to the clip region
269 	virtual void					UnionClipRegion( long nX, long nY, long nWidth, long nHeight ) = 0;
270     // done setting up the clipregion
271 	virtual void					EndSetClipRegion() = 0;
272 
273     // Callbacks (indepent part in vcl/source/window/winproc.cxx)
274     // for default message handling return 0
275     void						SetCallback( Window* pWindow, SALFRAMEPROC pProc )
276     { m_pWindow = pWindow; m_pProc = pProc; }
277 
278     // returns the instance set
279     Window*                       GetWindow() const { return m_pWindow; }
280 
281     // Call the callback set; this sometimes necessary for implementation classes
282     // that should not now more than necessary about the SalFrame implementation
283     // (e.g. input methods, printer update handlers).
284     long						CallCallback( sal_uInt16 nEvent, const void* pEvent ) const
285     { return m_pProc ? m_pProc( m_pWindow, const_cast<SalFrame*>(this), nEvent, pEvent ) : 0; }
286 };
287 
288 
289 
290 #endif // __cplusplus
291 
292 #endif // _SV_SALFRAME_HXX
293