xref: /AOO41X/main/fpicker/source/win32/filepicker/dibpreview.hxx (revision 10ce801889b00990ebdbcb412f4f91e2a9e6f21d)
1*10ce8018SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*10ce8018SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*10ce8018SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*10ce8018SAndrew Rist  * distributed with this work for additional information
6*10ce8018SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*10ce8018SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*10ce8018SAndrew Rist  * "License"); you may not use this file except in compliance
9*10ce8018SAndrew Rist  * with the License.  You may obtain a copy of the License at
10cdf0e10cSrcweir  *
11*10ce8018SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir  *
13*10ce8018SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*10ce8018SAndrew Rist  * software distributed under the License is distributed on an
15*10ce8018SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*10ce8018SAndrew Rist  * KIND, either express or implied.  See the License for the
17*10ce8018SAndrew Rist  * specific language governing permissions and limitations
18*10ce8018SAndrew Rist  * under the License.
19cdf0e10cSrcweir  *
20*10ce8018SAndrew Rist  *************************************************************/
21*10ce8018SAndrew Rist 
22*10ce8018SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir #ifndef _DIBPREVIEW_HXX_
25cdf0e10cSrcweir #define _DIBPREVIEW_HXX_
26cdf0e10cSrcweir 
27cdf0e10cSrcweir //------------------------------------------------------------------------
28cdf0e10cSrcweir // includes
29cdf0e10cSrcweir //------------------------------------------------------------------------
30cdf0e10cSrcweir 
31cdf0e10cSrcweir #include "previewbase.hxx"
32cdf0e10cSrcweir #include <osl/mutex.hxx>
33cdf0e10cSrcweir 
34cdf0e10cSrcweir #if defined _MSC_VER
35cdf0e10cSrcweir #pragma warning(push, 1)
36cdf0e10cSrcweir #endif
37cdf0e10cSrcweir #include <windows.h>
38cdf0e10cSrcweir #if defined _MSC_VER
39cdf0e10cSrcweir #pragma warning(pop)
40cdf0e10cSrcweir #endif
41cdf0e10cSrcweir 
42cdf0e10cSrcweir //---------------------------------------------
43cdf0e10cSrcweir // A very simple wrapper for a window that does
44cdf0e10cSrcweir // display DIBs.
45cdf0e10cSrcweir // Maybe it would be better and more extensible
46cdf0e10cSrcweir // to create another class that is responsible
47cdf0e10cSrcweir // for rendering a specific image format into
48cdf0e10cSrcweir // the area of the window, but for our purpose
49cdf0e10cSrcweir // it's enough to go the simple way - KISS.
50cdf0e10cSrcweir //---------------------------------------------
51cdf0e10cSrcweir 
52cdf0e10cSrcweir class CDIBPreview : public PreviewBase
53cdf0e10cSrcweir {
54cdf0e10cSrcweir public:
55cdf0e10cSrcweir 
56cdf0e10cSrcweir 	// ctor
57cdf0e10cSrcweir 	CDIBPreview(HINSTANCE instance,HWND parent,sal_Bool bShowWindow = sal_False);
58cdf0e10cSrcweir 
59cdf0e10cSrcweir     // dtor
60cdf0e10cSrcweir 	virtual ~CDIBPreview( );
61cdf0e10cSrcweir 
62cdf0e10cSrcweir 	// preview interface implementation
63cdf0e10cSrcweir 
64cdf0e10cSrcweir     virtual sal_Int32 SAL_CALL getTargetColorDepth()
65cdf0e10cSrcweir 		throw (::com::sun::star::uno::RuntimeException);
66cdf0e10cSrcweir 
67cdf0e10cSrcweir     virtual sal_Int32 SAL_CALL getAvailableWidth()
68cdf0e10cSrcweir 		throw (::com::sun::star::uno::RuntimeException);
69cdf0e10cSrcweir 
70cdf0e10cSrcweir     virtual sal_Int32 SAL_CALL getAvailableHeight()
71cdf0e10cSrcweir 		throw (::com::sun::star::uno::RuntimeException);
72cdf0e10cSrcweir 
73cdf0e10cSrcweir     virtual void SAL_CALL setImage(sal_Int16 aImageFormat, const ::com::sun::star::uno::Any& aImage)
74cdf0e10cSrcweir 		throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException);
75cdf0e10cSrcweir 
76cdf0e10cSrcweir     virtual sal_Bool SAL_CALL setShowState(sal_Bool bShowState)
77cdf0e10cSrcweir 		throw (::com::sun::star::uno::RuntimeException);
78cdf0e10cSrcweir 
79cdf0e10cSrcweir     virtual sal_Bool SAL_CALL getShowState()
80cdf0e10cSrcweir 		throw (::com::sun::star::uno::RuntimeException);
81cdf0e10cSrcweir 
82cdf0e10cSrcweir 	virtual HWND SAL_CALL getWindowHandle() const;
83cdf0e10cSrcweir 
84cdf0e10cSrcweir private:
85cdf0e10cSrcweir 	virtual void SAL_CALL onPaint( HWND hWnd, HDC hDC );
86cdf0e10cSrcweir 
87cdf0e10cSrcweir     ATOM SAL_CALL RegisterDibPreviewWindowClass( );
88cdf0e10cSrcweir     void SAL_CALL UnregisterDibPreviewWindowClass( );
89cdf0e10cSrcweir 
90cdf0e10cSrcweir     static LRESULT CALLBACK WndProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam );
91cdf0e10cSrcweir 
92cdf0e10cSrcweir private:
93cdf0e10cSrcweir 	HINSTANCE  m_Instance;
94cdf0e10cSrcweir 	HWND	   m_Hwnd;
95cdf0e10cSrcweir 	com::sun::star::uno::Sequence<sal_Int8> m_Image;
96cdf0e10cSrcweir 	osl::Mutex	m_PaintLock;
97cdf0e10cSrcweir 
98cdf0e10cSrcweir     // the preview window class has to be registered only
99cdf0e10cSrcweir     // once per process, so multiple instance of this class
100cdf0e10cSrcweir     // share the registered window class
101cdf0e10cSrcweir     static ATOM       s_ClassAtom;
102cdf0e10cSrcweir     static osl::Mutex s_Mutex;
103cdf0e10cSrcweir     static sal_Int32  s_RegisterDibPreviewWndCount;
104cdf0e10cSrcweir 
105cdf0e10cSrcweir // prevent copy and assignment
106cdf0e10cSrcweir private:
107cdf0e10cSrcweir     CDIBPreview(const CDIBPreview&);
108cdf0e10cSrcweir     CDIBPreview& operator=(const CDIBPreview&);
109cdf0e10cSrcweir };
110cdf0e10cSrcweir 
111cdf0e10cSrcweir 
112cdf0e10cSrcweir #endif
113