merged tag ooo/DEV300_m102
[LibreOffice.git] / fpicker / source / win32 / filepicker / dibpreview.hxx
blobab8a0793a490b442191b530a8b8d61ba7c876075
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2000, 2010 Oracle and/or its affiliates.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * This file is part of OpenOffice.org.
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.
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).
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.
26 ************************************************************************/
28 #ifndef _DIBPREVIEW_HXX_
29 #define _DIBPREVIEW_HXX_
31 //------------------------------------------------------------------------
32 // includes
33 //------------------------------------------------------------------------
35 #include "previewbase.hxx"
36 #include <osl/mutex.hxx>
38 #if defined _MSC_VER
39 #pragma warning(push, 1)
40 #endif
41 #include <windows.h>
42 #if defined _MSC_VER
43 #pragma warning(pop)
44 #endif
46 //---------------------------------------------
47 // A very simple wrapper for a window that does
48 // display DIBs.
49 // Maybe it would be better and more extensible
50 // to create another class that is responsible
51 // for rendering a specific image format into
52 // the area of the window, but for our purpose
53 // it's enough to go the simple way - KISS.
54 //---------------------------------------------
56 class CDIBPreview : public PreviewBase
58 public:
60 // ctor
61 CDIBPreview(HINSTANCE instance,HWND parent,sal_Bool bShowWindow = sal_False);
63 // dtor
64 virtual ~CDIBPreview( );
66 // preview interface implementation
68 virtual sal_Int32 SAL_CALL getTargetColorDepth()
69 throw (::com::sun::star::uno::RuntimeException);
71 virtual sal_Int32 SAL_CALL getAvailableWidth()
72 throw (::com::sun::star::uno::RuntimeException);
74 virtual sal_Int32 SAL_CALL getAvailableHeight()
75 throw (::com::sun::star::uno::RuntimeException);
77 virtual void SAL_CALL setImage(sal_Int16 aImageFormat, const ::com::sun::star::uno::Any& aImage)
78 throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException);
80 virtual sal_Bool SAL_CALL setShowState(sal_Bool bShowState)
81 throw (::com::sun::star::uno::RuntimeException);
83 virtual sal_Bool SAL_CALL getShowState()
84 throw (::com::sun::star::uno::RuntimeException);
86 virtual HWND SAL_CALL getWindowHandle() const;
88 private:
89 virtual void SAL_CALL onPaint( HWND hWnd, HDC hDC );
91 ATOM SAL_CALL RegisterDibPreviewWindowClass( );
92 void SAL_CALL UnregisterDibPreviewWindowClass( );
94 static LRESULT CALLBACK WndProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam );
96 private:
97 HINSTANCE m_Instance;
98 HWND m_Hwnd;
99 com::sun::star::uno::Sequence<sal_Int8> m_Image;
100 osl::Mutex m_PaintLock;
102 // the preview window class has to be registered only
103 // once per process, so multiple instance of this class
104 // share the registered window class
105 static ATOM s_ClassAtom;
106 static osl::Mutex s_Mutex;
107 static sal_Int32 s_RegisterDibPreviewWndCount;
109 // prevent copy and assignment
110 private:
111 CDIBPreview(const CDIBPreview&);
112 CDIBPreview& operator=(const CDIBPreview&);
116 #endif