xref: /aoo41x/main/vcl/inc/textlayout.hxx (revision 67e470da)
1*ebfcd9afSAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*ebfcd9afSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*ebfcd9afSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*ebfcd9afSAndrew Rist  * distributed with this work for additional information
6*ebfcd9afSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*ebfcd9afSAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*ebfcd9afSAndrew Rist  * "License"); you may not use this file except in compliance
9*ebfcd9afSAndrew Rist  * with the License.  You may obtain a copy of the License at
10*ebfcd9afSAndrew Rist  *
11*ebfcd9afSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*ebfcd9afSAndrew Rist  *
13*ebfcd9afSAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*ebfcd9afSAndrew Rist  * software distributed under the License is distributed on an
15*ebfcd9afSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*ebfcd9afSAndrew Rist  * KIND, either express or implied.  See the License for the
17*ebfcd9afSAndrew Rist  * specific language governing permissions and limitations
18*ebfcd9afSAndrew Rist  * under the License.
19*ebfcd9afSAndrew Rist  *
20*ebfcd9afSAndrew Rist  *************************************************************/
21*ebfcd9afSAndrew Rist 
22*ebfcd9afSAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir #ifndef VCL_TEXTLAYOUT_HXX
25cdf0e10cSrcweir #define VCL_TEXTLAYOUT_HXX
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #include "vcl/outdev.hxx"
28cdf0e10cSrcweir 
29cdf0e10cSrcweir #include <tools/solar.h>
30cdf0e10cSrcweir #include <tools/string.hxx>
31cdf0e10cSrcweir 
32cdf0e10cSrcweir #include <memory>
33cdf0e10cSrcweir 
34cdf0e10cSrcweir class Control;
35cdf0e10cSrcweir 
36cdf0e10cSrcweir //........................................................................
37cdf0e10cSrcweir namespace vcl
38cdf0e10cSrcweir {
39cdf0e10cSrcweir //........................................................................
40cdf0e10cSrcweir 
41cdf0e10cSrcweir 	//====================================================================
42cdf0e10cSrcweir 	//= ITextLayout
43cdf0e10cSrcweir 	//====================================================================
44cdf0e10cSrcweir 	class SAL_NO_VTABLE ITextLayout
45cdf0e10cSrcweir 	{
46cdf0e10cSrcweir     public:
47cdf0e10cSrcweir         virtual long        GetTextWidth( const XubString& _rText, xub_StrLen _nStartIndex, xub_StrLen _nLength ) const = 0;
48cdf0e10cSrcweir         virtual void        DrawText( const Point& _rStartPoint, const XubString& _rText, xub_StrLen _nStartIndex, xub_StrLen _nLength,
49cdf0e10cSrcweir                                 MetricVector* _pVector, String* _pDisplayText ) = 0;
50cdf0e10cSrcweir         virtual bool        GetCaretPositions( const XubString& _rText, sal_Int32* _pCaretXArray, xub_StrLen _nStartIndex, xub_StrLen _nLength ) const = 0;
51cdf0e10cSrcweir         virtual xub_StrLen  GetTextBreak( const XubString& _rText, long _nMaxTextWidth, xub_StrLen _nStartIndex, xub_StrLen _nLength ) const = 0;
52cdf0e10cSrcweir         virtual bool        DecomposeTextRectAction() const = 0;
53cdf0e10cSrcweir 	};
54cdf0e10cSrcweir 
55cdf0e10cSrcweir 	//====================================================================
56cdf0e10cSrcweir 	//= DefaultTextLayout
57cdf0e10cSrcweir 	//====================================================================
58cdf0e10cSrcweir     /** is an implementation of the ITextLayout interface which simply delegates its calls to the respective
59cdf0e10cSrcweir         methods of an OutputDevice instance, without any inbetween magic.
60cdf0e10cSrcweir     */
61cdf0e10cSrcweir     class DefaultTextLayout : public ITextLayout
62cdf0e10cSrcweir     {
63cdf0e10cSrcweir     public:
DefaultTextLayout(OutputDevice & _rTargetDevice)64cdf0e10cSrcweir         DefaultTextLayout( OutputDevice& _rTargetDevice )
65cdf0e10cSrcweir             :m_rTargetDevice( _rTargetDevice )
66cdf0e10cSrcweir         {
67cdf0e10cSrcweir         }
68cdf0e10cSrcweir         virtual ~DefaultTextLayout();
69cdf0e10cSrcweir 
70cdf0e10cSrcweir         // ITextLayout overridables
71cdf0e10cSrcweir         virtual long        GetTextWidth(
72cdf0e10cSrcweir                                 const XubString& _rText,
73cdf0e10cSrcweir                                 xub_StrLen _nStartIndex,
74cdf0e10cSrcweir                                 xub_StrLen _nLength
75cdf0e10cSrcweir                             ) const;
76cdf0e10cSrcweir         virtual void        DrawText(
77cdf0e10cSrcweir                                 const Point& _rStartPoint,
78cdf0e10cSrcweir                                 const XubString& _rText,
79cdf0e10cSrcweir                                 xub_StrLen _nStartIndex,
80cdf0e10cSrcweir                                 xub_StrLen _nLength,
81cdf0e10cSrcweir                                 MetricVector* _pVector,
82cdf0e10cSrcweir                                 String* _pDisplayText
83cdf0e10cSrcweir                             );
84cdf0e10cSrcweir         virtual bool        GetCaretPositions(
85cdf0e10cSrcweir                                 const XubString& _rText,
86cdf0e10cSrcweir                                 sal_Int32* _pCaretXArray,
87cdf0e10cSrcweir                                 xub_StrLen _nStartIndex,
88cdf0e10cSrcweir                                 xub_StrLen _nLength
89cdf0e10cSrcweir                             ) const;
90cdf0e10cSrcweir         virtual xub_StrLen  GetTextBreak(
91cdf0e10cSrcweir                                 const XubString& _rText,
92cdf0e10cSrcweir                                 long _nMaxTextWidth,
93cdf0e10cSrcweir                                 xub_StrLen _nStartIndex,
94cdf0e10cSrcweir                                 xub_StrLen _nLength
95cdf0e10cSrcweir                             ) const;
96cdf0e10cSrcweir         virtual bool        DecomposeTextRectAction() const;
97cdf0e10cSrcweir 
98cdf0e10cSrcweir     private:
99cdf0e10cSrcweir         OutputDevice&   m_rTargetDevice;
100cdf0e10cSrcweir     };
101cdf0e10cSrcweir 
102cdf0e10cSrcweir 	//====================================================================
103cdf0e10cSrcweir 	//= ControlTextRenderer
104cdf0e10cSrcweir 	//====================================================================
105cdf0e10cSrcweir     class ReferenceDeviceTextLayout;
106cdf0e10cSrcweir     /** a class which allows rendering text of a Control onto a device, by taking into account the metrics of
107cdf0e10cSrcweir         a reference device.
108cdf0e10cSrcweir     */
109cdf0e10cSrcweir     class ControlTextRenderer
110cdf0e10cSrcweir     {
111cdf0e10cSrcweir     public:
112cdf0e10cSrcweir         ControlTextRenderer( const Control& _rControl, OutputDevice& _rTargetDevice, OutputDevice& _rReferenceDevice );
113cdf0e10cSrcweir         virtual ~ControlTextRenderer();
114cdf0e10cSrcweir 
115cdf0e10cSrcweir         Rectangle   DrawText( const Rectangle& _rRect,
116cdf0e10cSrcweir                               const XubString& _rText, sal_uInt16 _nStyle = 0,
117cdf0e10cSrcweir                               MetricVector* _pVector = NULL, String* _pDisplayText = NULL );
118cdf0e10cSrcweir 
119cdf0e10cSrcweir     private:
120cdf0e10cSrcweir         ControlTextRenderer();                                                  // never implemented
121cdf0e10cSrcweir         ControlTextRenderer( const ControlTextRenderer& );              // never implemented
122cdf0e10cSrcweir         ControlTextRenderer& operator=( const ControlTextRenderer& );   // never implemented
123cdf0e10cSrcweir 
124cdf0e10cSrcweir     private:
125cdf0e10cSrcweir         ::std::auto_ptr< ReferenceDeviceTextLayout >   m_pImpl;
126cdf0e10cSrcweir     };
127cdf0e10cSrcweir 
128cdf0e10cSrcweir //........................................................................
129cdf0e10cSrcweir } // namespace vcl
130cdf0e10cSrcweir //........................................................................
131cdf0e10cSrcweir 
132cdf0e10cSrcweir #endif // VCL_TEXTLAYOUT_HXX
133