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