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