Branch libreoffice-5-0-4
[LibreOffice.git] / include / vcl / fixed.hxx
blobfc455d82ef65198e6724ba02489761123be96c6b
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #ifndef INCLUDED_VCL_FIXED_HXX
21 #define INCLUDED_VCL_FIXED_HXX
23 #include <tools/solar.h>
24 #include <vcl/dllapi.h>
25 #include <vcl/bitmap.hxx>
26 #include <vcl/ctrl.hxx>
27 #include <vcl/edit.hxx>
28 #include <vcl/image.hxx>
30 class UserDrawEvent;
33 // - FixedText -
36 class VCL_DLLPUBLIC FixedText : public Control
38 private:
39 sal_Int32 m_nMaxWidthChars;
40 sal_Int32 m_nMinWidthChars;
41 VclPtr<vcl::Window> m_pMnemonicWindow;
43 using Control::ImplInitSettings;
44 using Window::ImplInit;
45 SAL_DLLPRIVATE void ImplInit( vcl::Window* pParent, WinBits nStyle );
46 SAL_DLLPRIVATE WinBits ImplInitStyle( WinBits nStyle );
47 SAL_DLLPRIVATE void ImplDraw( OutputDevice* pDev, sal_uLong nDrawFlags,
48 const Point& rPos, const Size& rSize, bool bFillLayout = false ) const;
49 public:
50 SAL_DLLPRIVATE static DrawTextFlags ImplGetTextStyle( WinBits nWinBits );
51 protected:
52 virtual void FillLayoutData() const SAL_OVERRIDE;
53 virtual const vcl::Font&
54 GetCanonicalFont( const StyleSettings& _rStyle ) const SAL_OVERRIDE;
55 virtual const Color&
56 GetCanonicalTextColor( const StyleSettings& _rStyle ) const SAL_OVERRIDE;
58 virtual vcl::Window* getAccessibleRelationLabelFor() const SAL_OVERRIDE;
60 public:
61 explicit FixedText( vcl::Window* pParent, WinBits nStyle = 0 );
62 explicit FixedText( vcl::Window* pParent, const ResId& rResId );
63 virtual ~FixedText();
64 virtual void dispose() SAL_OVERRIDE;
66 virtual void ApplySettings(vcl::RenderContext& rRenderContext) SAL_OVERRIDE;
68 virtual void Paint( vcl::RenderContext& rRenderContext, const Rectangle& rRect ) SAL_OVERRIDE;
69 virtual void Draw( OutputDevice* pDev, const Point& rPos, const Size& rSize, sal_uLong nFlags ) SAL_OVERRIDE;
70 virtual void Resize() SAL_OVERRIDE;
71 virtual void StateChanged( StateChangedType nType ) SAL_OVERRIDE;
72 virtual void DataChanged( const DataChangedEvent& rDCEvt ) SAL_OVERRIDE;
74 void setMaxWidthChars(sal_Int32 nWidth);
75 sal_Int32 getMaxWidthChars() const { return m_nMaxWidthChars; }
76 void setMinWidthChars(sal_Int32 nWidth);
77 sal_Int32 getMinWidthChars() const { return m_nMinWidthChars; }
78 static Size CalcMinimumTextSize(Control const* pControl, long nMaxWidth = 0x7fffffff);
79 static Size getTextDimensions(Control const *pControl, const OUString &rTxt, long nMaxWidth);
80 Size CalcMinimumSize(long nMaxWidth = 0x7fffffff) const;
81 virtual Size GetOptimalSize() const SAL_OVERRIDE;
82 virtual bool set_property(const OString &rKey, const OString &rValue) SAL_OVERRIDE;
83 void set_mnemonic_widget(vcl::Window *pWindow);
84 vcl::Window* get_mnemonic_widget() const { return m_pMnemonicWindow; }
87 class VCL_DLLPUBLIC SelectableFixedText : public Edit
89 public:
90 explicit SelectableFixedText( vcl::Window* pParent, WinBits nStyle = 0 );
92 virtual void LoseFocus() SAL_OVERRIDE;
93 virtual void ApplySettings(vcl::RenderContext&) SAL_OVERRIDE;
97 // - FixedLine -
100 class VCL_DLLPUBLIC FixedLine : public Control
102 private:
103 using Control::ImplInitSettings;
104 using Window::ImplInit;
105 SAL_DLLPRIVATE void ImplInit( vcl::Window* pParent, WinBits nStyle );
106 SAL_DLLPRIVATE WinBits ImplInitStyle( WinBits nStyle );
107 SAL_DLLPRIVATE void ImplDraw(vcl::RenderContext& rRenderContext, bool bLayout = false);
109 protected:
110 virtual void FillLayoutData() const SAL_OVERRIDE;
111 virtual const vcl::Font&
112 GetCanonicalFont( const StyleSettings& _rStyle ) const SAL_OVERRIDE;
113 virtual const Color&
114 GetCanonicalTextColor( const StyleSettings& _rStyle ) const SAL_OVERRIDE;
116 public:
117 explicit FixedLine( vcl::Window* pParent, WinBits nStyle = WB_HORZ );
118 explicit FixedLine( vcl::Window* pParent, const ResId& );
120 virtual void ApplySettings(vcl::RenderContext&) SAL_OVERRIDE;
122 virtual void Paint( vcl::RenderContext& rRenderContext, const Rectangle& rRect ) SAL_OVERRIDE;
123 virtual void Draw( OutputDevice* pDev, const Point& rPos, const Size& rSize, sal_uLong nFlags ) SAL_OVERRIDE;
124 virtual void Resize() SAL_OVERRIDE;
125 virtual void StateChanged( StateChangedType nType ) SAL_OVERRIDE;
126 virtual void DataChanged( const DataChangedEvent& rDCEvt ) SAL_OVERRIDE;
128 virtual Size GetOptimalSize() const SAL_OVERRIDE;
131 // - FixedBitmap -
132 class VCL_DLLPUBLIC FixedBitmap : public Control
134 private:
135 Bitmap maBitmap;
137 using Control::ImplInitSettings;
138 using Window::ImplInit;
139 SAL_DLLPRIVATE void ImplInit( vcl::Window* pParent, WinBits nStyle );
140 SAL_DLLPRIVATE WinBits ImplInitStyle( WinBits nStyle );
141 SAL_DLLPRIVATE void ImplDraw( OutputDevice* pDev, sal_uLong nDrawFlags,
142 const Point& rPos, const Size& rSize );
144 public:
145 explicit FixedBitmap( vcl::Window* pParent, WinBits nStyle = 0 );
147 virtual void ApplySettings(vcl::RenderContext&) SAL_OVERRIDE;
149 virtual void Paint( vcl::RenderContext& rRenderContext, const Rectangle& rRect ) SAL_OVERRIDE;
150 virtual void Draw( OutputDevice* pDev, const Point& rPos, const Size& rSize, sal_uLong nFlags ) SAL_OVERRIDE;
151 virtual void Resize() SAL_OVERRIDE;
152 virtual void StateChanged( StateChangedType nType ) SAL_OVERRIDE;
153 virtual void DataChanged( const DataChangedEvent& rDCEvt ) SAL_OVERRIDE;
155 void SetBitmap( const Bitmap& rBitmap );
156 using OutputDevice::GetBitmap;
157 const Bitmap& GetBitmap() const { return maBitmap; }
161 // - FixedImage -
164 class VCL_DLLPUBLIC FixedImage : public Control
166 private:
167 Image maImage;
168 bool mbInUserDraw;
170 private:
171 using Control::ImplInitSettings;
172 using Window::ImplInit;
173 SAL_DLLPRIVATE void ImplInit( vcl::Window* pParent, WinBits nStyle );
174 SAL_DLLPRIVATE WinBits ImplInitStyle( WinBits nStyle );
176 protected:
177 SAL_DLLPRIVATE void ImplDraw( OutputDevice* pDev, sal_uLong nDrawFlags,
178 const Point& rPos, const Size& rSize );
179 SAL_DLLPRIVATE void ImplLoadRes( const ResId& rResId );
181 public:
182 explicit FixedImage( vcl::Window* pParent, WinBits nStyle = 0 );
183 explicit FixedImage( vcl::Window* pParent, const ResId& );
185 virtual void ApplySettings(vcl::RenderContext&) SAL_OVERRIDE;
187 virtual void Paint( vcl::RenderContext& rRenderContext, const Rectangle& rRect ) SAL_OVERRIDE;
188 virtual void Draw( OutputDevice* pDev, const Point& rPos, const Size& rSize, sal_uLong nFlags ) SAL_OVERRIDE;
189 virtual void Resize() SAL_OVERRIDE;
190 virtual void StateChanged( StateChangedType nType ) SAL_OVERRIDE;
191 virtual void DataChanged( const DataChangedEvent& rDCEvt ) SAL_OVERRIDE;
192 virtual Size GetOptimalSize() const SAL_OVERRIDE;
194 void SetImage( const Image& rImage );
195 const Image& GetImage() const { return maImage; }
197 bool SetModeImage( const Image& rImage );
198 const Image& GetModeImage( ) const { return maImage;}
199 virtual bool set_property(const OString &rKey, const OString &rValue) SAL_OVERRIDE;
201 static Image loadThemeImage(const OString &rFileName);
204 #endif // INCLUDED_VCL_FIXED_HXX
206 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */