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 INCLUDED_VCL_FIXED_HXX
21 : #define INCLUDED_VCL_FIXED_HXX
22 :
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>
29 :
30 : class UserDrawEvent;
31 :
32 :
33 : // - FixedText -
34 :
35 :
36 : class VCL_DLLPUBLIC FixedText : public Control
37 : {
38 : private:
39 : sal_Int32 m_nMaxWidthChars;
40 : sal_Int32 m_nMinWidthChars;
41 : vcl::Window *m_pMnemonicWindow;
42 :
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 ImplInitSettings( bool bFont, bool bForeground, bool bBackground );
48 : SAL_DLLPRIVATE void ImplDraw( OutputDevice* pDev, sal_uLong nDrawFlags,
49 : const Point& rPos, const Size& rSize, bool bFillLayout = false ) const;
50 : public:
51 : SAL_DLLPRIVATE static sal_uInt16 ImplGetTextStyle( WinBits nWinBits );
52 : protected:
53 : virtual void FillLayoutData() const SAL_OVERRIDE;
54 : virtual const vcl::Font&
55 : GetCanonicalFont( const StyleSettings& _rStyle ) const SAL_OVERRIDE;
56 : virtual const Color&
57 : GetCanonicalTextColor( const StyleSettings& _rStyle ) const SAL_OVERRIDE;
58 :
59 : virtual vcl::Window* getAccessibleRelationLabelFor() const SAL_OVERRIDE;
60 :
61 : public:
62 : explicit FixedText( vcl::Window* pParent, WinBits nStyle = 0 );
63 : explicit FixedText( vcl::Window* pParent, const ResId& rResId );
64 : virtual ~FixedText();
65 :
66 : virtual void Paint( const Rectangle& rRect ) SAL_OVERRIDE;
67 : virtual void Draw( OutputDevice* pDev, const Point& rPos, const Size& rSize, sal_uLong nFlags ) SAL_OVERRIDE;
68 : virtual void Resize() SAL_OVERRIDE;
69 : virtual void StateChanged( StateChangedType nType ) SAL_OVERRIDE;
70 : virtual void DataChanged( const DataChangedEvent& rDCEvt ) SAL_OVERRIDE;
71 :
72 : void setMaxWidthChars(sal_Int32 nWidth);
73 : sal_Int32 getMaxWidthChars() const { return m_nMaxWidthChars; }
74 : void setMinWidthChars(sal_Int32 nWidth);
75 : sal_Int32 getMinWidthChars() const { return m_nMinWidthChars; }
76 : static Size CalcMinimumTextSize(Control const* pControl, long nMaxWidth = 0x7fffffff);
77 : static Size getTextDimensions(Control const *pControl, const OUString &rTxt, long nMaxWidth);
78 : Size CalcMinimumSize(long nMaxWidth = 0x7fffffff) const;
79 : virtual Size GetOptimalSize() const SAL_OVERRIDE;
80 : virtual bool set_property(const OString &rKey, const OString &rValue) SAL_OVERRIDE;
81 : void set_mnemonic_widget(vcl::Window *pWindow);
82 12 : vcl::Window* get_mnemonic_widget() const { return m_pMnemonicWindow; }
83 : };
84 :
85 0 : class VCL_DLLPUBLIC SelectableFixedText : public Edit
86 : {
87 : public:
88 : explicit SelectableFixedText( vcl::Window* pParent, WinBits nStyle = 0 );
89 :
90 : virtual void LoseFocus() SAL_OVERRIDE;
91 : };
92 :
93 :
94 : // - FixedLine -
95 :
96 :
97 538 : class VCL_DLLPUBLIC FixedLine : public Control
98 : {
99 : private:
100 : using Control::ImplInitSettings;
101 : using Window::ImplInit;
102 : SAL_DLLPRIVATE void ImplInit( vcl::Window* pParent, WinBits nStyle );
103 : SAL_DLLPRIVATE WinBits ImplInitStyle( WinBits nStyle );
104 : SAL_DLLPRIVATE void ImplInitSettings( bool bFont, bool bForeground, bool bBackground );
105 : SAL_DLLPRIVATE void ImplDraw( bool bLayout = false );
106 :
107 : protected:
108 : virtual void FillLayoutData() const SAL_OVERRIDE;
109 : virtual const vcl::Font&
110 : GetCanonicalFont( const StyleSettings& _rStyle ) const SAL_OVERRIDE;
111 : virtual const Color&
112 : GetCanonicalTextColor( const StyleSettings& _rStyle ) const SAL_OVERRIDE;
113 :
114 : public:
115 : explicit FixedLine( vcl::Window* pParent, WinBits nStyle = WB_HORZ );
116 : explicit FixedLine( vcl::Window* pParent, const ResId& );
117 :
118 : virtual void Paint( const Rectangle& rRect ) SAL_OVERRIDE;
119 : virtual void Draw( OutputDevice* pDev, const Point& rPos, const Size& rSize, sal_uLong nFlags ) SAL_OVERRIDE;
120 : virtual void Resize() SAL_OVERRIDE;
121 : virtual void StateChanged( StateChangedType nType ) SAL_OVERRIDE;
122 : virtual void DataChanged( const DataChangedEvent& rDCEvt ) SAL_OVERRIDE;
123 :
124 : virtual Size GetOptimalSize() const SAL_OVERRIDE;
125 : };
126 :
127 : // - FixedBitmap -
128 : class VCL_DLLPUBLIC FixedBitmap : public Control
129 : {
130 : private:
131 : Bitmap maBitmap;
132 :
133 : using Control::ImplInitSettings;
134 : using Window::ImplInit;
135 : SAL_DLLPRIVATE void ImplInit( vcl::Window* pParent, WinBits nStyle );
136 : SAL_DLLPRIVATE WinBits ImplInitStyle( WinBits nStyle );
137 : SAL_DLLPRIVATE void ImplInitSettings();
138 : SAL_DLLPRIVATE void ImplDraw( OutputDevice* pDev, sal_uLong nDrawFlags,
139 : const Point& rPos, const Size& rSize );
140 :
141 : public:
142 : explicit FixedBitmap( vcl::Window* pParent, WinBits nStyle = 0 );
143 : virtual ~FixedBitmap();
144 :
145 : virtual void Paint( const Rectangle& rRect ) SAL_OVERRIDE;
146 : virtual void Draw( OutputDevice* pDev, const Point& rPos, const Size& rSize, sal_uLong nFlags ) SAL_OVERRIDE;
147 : virtual void Resize() SAL_OVERRIDE;
148 : virtual void StateChanged( StateChangedType nType ) SAL_OVERRIDE;
149 : virtual void DataChanged( const DataChangedEvent& rDCEvt ) SAL_OVERRIDE;
150 :
151 : void SetBitmap( const Bitmap& rBitmap );
152 : using OutputDevice::GetBitmap;
153 : const Bitmap& GetBitmap() const { return maBitmap; }
154 : };
155 :
156 :
157 : // - FixedImage -
158 :
159 :
160 : class VCL_DLLPUBLIC FixedImage : public Control
161 : {
162 : private:
163 : Image maImage;
164 : bool mbInUserDraw;
165 :
166 : private:
167 : using Control::ImplInitSettings;
168 : using Window::ImplInit;
169 : SAL_DLLPRIVATE void ImplInit( vcl::Window* pParent, WinBits nStyle );
170 : SAL_DLLPRIVATE WinBits ImplInitStyle( WinBits nStyle );
171 : SAL_DLLPRIVATE void ImplInitSettings();
172 :
173 : protected:
174 : SAL_DLLPRIVATE void ImplDraw( OutputDevice* pDev, sal_uLong nDrawFlags,
175 : const Point& rPos, const Size& rSize );
176 : SAL_DLLPRIVATE void ImplLoadRes( const ResId& rResId );
177 :
178 : public:
179 : explicit FixedImage( vcl::Window* pParent, WinBits nStyle = 0 );
180 : explicit FixedImage( vcl::Window* pParent, const ResId& );
181 : virtual ~FixedImage();
182 :
183 : virtual void Paint( const Rectangle& rRect ) SAL_OVERRIDE;
184 : virtual void Draw( OutputDevice* pDev, const Point& rPos, const Size& rSize, sal_uLong nFlags ) SAL_OVERRIDE;
185 : virtual void Resize() SAL_OVERRIDE;
186 : virtual void StateChanged( StateChangedType nType ) SAL_OVERRIDE;
187 : virtual void DataChanged( const DataChangedEvent& rDCEvt ) SAL_OVERRIDE;
188 : virtual void UserDraw( const UserDrawEvent& rUDEvt );
189 : virtual Size GetOptimalSize() const SAL_OVERRIDE;
190 :
191 : void SetImage( const Image& rImage );
192 20 : const Image& GetImage() const { return maImage; }
193 :
194 : bool SetModeImage( const Image& rImage );
195 166 : const Image& GetModeImage( ) const { return maImage;}
196 : virtual bool set_property(const OString &rKey, const OString &rValue) SAL_OVERRIDE;
197 :
198 : static Image loadThemeImage(const OString &rFileName);
199 : };
200 :
201 : #endif // INCLUDED_VCL_FIXED_HXX
202 :
203 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|