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 _SV_FIXED_HXX
21 : #define _SV_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 : Window *m_pMnemonicWindow;
42 :
43 : using Control::ImplInitSettings;
44 : using Window::ImplInit;
45 : SAL_DLLPRIVATE void ImplInit( Window* pParent, WinBits nStyle );
46 : SAL_DLLPRIVATE WinBits ImplInitStyle( WinBits nStyle );
47 : SAL_DLLPRIVATE void ImplInitSettings( sal_Bool bFont, sal_Bool bForeground, sal_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;
54 : virtual const Font&
55 : GetCanonicalFont( const StyleSettings& _rStyle ) const;
56 : virtual const Color&
57 : GetCanonicalTextColor( const StyleSettings& _rStyle ) const;
58 :
59 : virtual Window* getAccessibleRelationLabelFor() const;
60 :
61 : public:
62 : explicit FixedText( Window* pParent, WinBits nStyle = 0 );
63 : explicit FixedText( Window* pParent, const ResId& rResId );
64 : virtual ~FixedText();
65 :
66 : virtual void Paint( const Rectangle& rRect );
67 : virtual void Draw( OutputDevice* pDev, const Point& rPos, const Size& rSize, sal_uLong nFlags );
68 : virtual void Resize();
69 : virtual void StateChanged( StateChangedType nType );
70 : virtual void DataChanged( const DataChangedEvent& rDCEvt );
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;
80 : virtual bool set_property(const OString &rKey, const OString &rValue);
81 : void set_mnemonic_widget(Window *pWindow);
82 2 : Window* get_mnemonic_widget() const { return m_pMnemonicWindow; }
83 : };
84 :
85 0 : class VCL_DLLPUBLIC SelectableFixedText : public Edit
86 : {
87 : public:
88 : explicit SelectableFixedText( Window* pParent, WinBits nStyle = 0 );
89 :
90 : virtual void LoseFocus();
91 : };
92 :
93 : // -------------
94 : // - FixedLine -
95 : // -------------
96 :
97 47 : class VCL_DLLPUBLIC FixedLine : public Control
98 : {
99 : private:
100 : using Control::ImplInitSettings;
101 : using Window::ImplInit;
102 : SAL_DLLPRIVATE void ImplInit( Window* pParent, WinBits nStyle );
103 : SAL_DLLPRIVATE WinBits ImplInitStyle( WinBits nStyle );
104 : SAL_DLLPRIVATE void ImplInitSettings( sal_Bool bFont, sal_Bool bForeground, sal_Bool bBackground );
105 : SAL_DLLPRIVATE void ImplDraw( bool bLayout = false );
106 :
107 : protected:
108 : virtual void FillLayoutData() const;
109 : virtual const Font&
110 : GetCanonicalFont( const StyleSettings& _rStyle ) const;
111 : virtual const Color&
112 : GetCanonicalTextColor( const StyleSettings& _rStyle ) const;
113 :
114 : public:
115 : explicit FixedLine( Window* pParent, WinBits nStyle = WB_HORZ );
116 : explicit FixedLine( Window* pParent, const ResId& );
117 :
118 : virtual void Paint( const Rectangle& rRect );
119 : virtual void Draw( OutputDevice* pDev, const Point& rPos, const Size& rSize, sal_uLong nFlags );
120 : virtual void Resize();
121 : virtual void StateChanged( StateChangedType nType );
122 : virtual void DataChanged( const DataChangedEvent& rDCEvt );
123 :
124 : virtual Size GetOptimalSize() const;
125 : };
126 :
127 : // ---------------
128 : // - FixedBitmap -
129 : // ---------------
130 :
131 : class VCL_DLLPUBLIC FixedBitmap : public Control
132 : {
133 : private:
134 : Bitmap maBitmap;
135 :
136 : using Control::ImplInitSettings;
137 : using Window::ImplInit;
138 : SAL_DLLPRIVATE void ImplInit( Window* pParent, WinBits nStyle );
139 : SAL_DLLPRIVATE WinBits ImplInitStyle( WinBits nStyle );
140 : SAL_DLLPRIVATE void ImplInitSettings();
141 : SAL_DLLPRIVATE void ImplDraw( OutputDevice* pDev, sal_uLong nDrawFlags,
142 : const Point& rPos, const Size& rSize );
143 :
144 : protected:
145 : SAL_DLLPRIVATE void ImplLoadRes( const ResId& rResId );
146 :
147 : public:
148 : explicit FixedBitmap( Window* pParent, WinBits nStyle = 0 );
149 : explicit FixedBitmap( Window* pParent, const ResId& );
150 : virtual ~FixedBitmap();
151 :
152 : virtual void Paint( const Rectangle& rRect );
153 : virtual void Draw( OutputDevice* pDev, const Point& rPos, const Size& rSize, sal_uLong nFlags );
154 : virtual void Resize();
155 : virtual void StateChanged( StateChangedType nType );
156 : virtual void DataChanged( const DataChangedEvent& rDCEvt );
157 :
158 : void SetBitmap( const Bitmap& rBitmap );
159 : using OutputDevice::GetBitmap;
160 0 : const Bitmap& GetBitmap() const { return maBitmap; }
161 : };
162 :
163 : // --------------
164 : // - FixedImage -
165 : // --------------
166 :
167 : class VCL_DLLPUBLIC FixedImage : public Control
168 : {
169 : private:
170 : Image maImage;
171 : sal_Bool mbInUserDraw;
172 :
173 : private:
174 : using Control::ImplInitSettings;
175 : using Window::ImplInit;
176 : SAL_DLLPRIVATE void ImplInit( Window* pParent, WinBits nStyle );
177 : SAL_DLLPRIVATE WinBits ImplInitStyle( WinBits nStyle );
178 : SAL_DLLPRIVATE void ImplInitSettings();
179 :
180 : protected:
181 : SAL_DLLPRIVATE void ImplDraw( OutputDevice* pDev, sal_uLong nDrawFlags,
182 : const Point& rPos, const Size& rSize );
183 : SAL_DLLPRIVATE void ImplLoadRes( const ResId& rResId );
184 :
185 : public:
186 : explicit FixedImage( Window* pParent, WinBits nStyle = 0 );
187 : explicit FixedImage( Window* pParent, const ResId& );
188 : virtual ~FixedImage();
189 :
190 : virtual void Paint( const Rectangle& rRect );
191 : virtual void Draw( OutputDevice* pDev, const Point& rPos, const Size& rSize, sal_uLong nFlags );
192 : virtual void Resize();
193 : virtual void StateChanged( StateChangedType nType );
194 : virtual void DataChanged( const DataChangedEvent& rDCEvt );
195 : virtual void UserDraw( const UserDrawEvent& rUDEvt );
196 : virtual Size GetOptimalSize() const;
197 :
198 : void SetImage( const Image& rImage );
199 0 : const Image& GetImage() const { return maImage; }
200 :
201 : sal_Bool SetModeImage( const Image& rImage );
202 : const Image& GetModeImage( ) const;
203 : virtual bool set_property(const OString &rKey, const OString &rValue);
204 : };
205 :
206 : #endif // _SV_FIXED_HXX
207 :
208 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|