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_INC_TEXTLAYOUT_HXX
21 : #define INCLUDED_VCL_INC_TEXTLAYOUT_HXX
22 :
23 : #include <memory>
24 : #include <rtl/ustring.hxx>
25 : #include <vcl/outdev.hxx>
26 :
27 : class Control;
28 :
29 : namespace vcl
30 : {
31 0 : class SAL_NO_VTABLE ITextLayout
32 : {
33 : public:
34 : virtual long GetTextWidth( const OUString& _rText, sal_Int32 _nStartIndex, sal_Int32 _nLength ) const = 0;
35 : virtual void DrawText( const Point& _rStartPoint, const OUString& _rText, sal_Int32 _nStartIndex, sal_Int32 _nLength,
36 : MetricVector* _pVector, OUString* _pDisplayText ) = 0;
37 : virtual bool GetCaretPositions( const OUString& _rText, sal_Int32* _pCaretXArray, sal_Int32 _nStartIndex, sal_Int32 _nLength ) const = 0;
38 : virtual sal_Int32 GetTextBreak( const OUString& _rText, long _nMaxTextWidth, sal_Int32 _nStartIndex, sal_Int32 _nLength ) const = 0;
39 : virtual bool DecomposeTextRectAction() const = 0;
40 :
41 : protected:
42 0 : ~ITextLayout() {}
43 : };
44 :
45 : /** is an implementation of the ITextLayout interface which simply delegates its calls to the respective
46 : methods of an OutputDevice instance, without any inbetween magic.
47 : */
48 : class DefaultTextLayout : public ITextLayout
49 : {
50 : public:
51 0 : DefaultTextLayout( OutputDevice& _rTargetDevice )
52 0 : :m_rTargetDevice( _rTargetDevice )
53 : {
54 0 : }
55 : virtual ~DefaultTextLayout();
56 :
57 : // ITextLayout overridables
58 : virtual long GetTextWidth(
59 : const OUString& _rText,
60 : sal_Int32 _nStartIndex,
61 : sal_Int32 _nLength
62 : ) const SAL_OVERRIDE;
63 : virtual void DrawText(
64 : const Point& _rStartPoint,
65 : const OUString& _rText,
66 : sal_Int32 _nStartIndex,
67 : sal_Int32 _nLength,
68 : MetricVector* _pVector,
69 : OUString* _pDisplayText
70 : ) SAL_OVERRIDE;
71 : virtual bool GetCaretPositions(
72 : const OUString& _rText,
73 : sal_Int32* _pCaretXArray,
74 : sal_Int32 _nStartIndex,
75 : sal_Int32 _nLength
76 : ) const SAL_OVERRIDE;
77 : virtual sal_Int32 GetTextBreak(
78 : const OUString& _rText,
79 : long _nMaxTextWidth,
80 : sal_Int32 _nStartIndex,
81 : sal_Int32 _nLength
82 : ) const SAL_OVERRIDE;
83 : virtual bool DecomposeTextRectAction() const SAL_OVERRIDE;
84 :
85 : private:
86 : OutputDevice& m_rTargetDevice;
87 : };
88 :
89 : class ReferenceDeviceTextLayout;
90 : /** a class which allows rendering text of a Control onto a device, by taking into account the metrics of
91 : a reference device.
92 : */
93 : class ControlTextRenderer
94 : {
95 : public:
96 : ControlTextRenderer( const Control& _rControl, OutputDevice& _rTargetDevice, OutputDevice& _rReferenceDevice );
97 : virtual ~ControlTextRenderer();
98 :
99 : Rectangle DrawText( const Rectangle& _rRect,
100 : const OUString& _rText, sal_uInt16 _nStyle = 0,
101 : MetricVector* _pVector = NULL, OUString* _pDisplayText = NULL );
102 :
103 : private:
104 : ControlTextRenderer(); // never implemented
105 : ControlTextRenderer( const ControlTextRenderer& ); // never implemented
106 : ControlTextRenderer& operator=( const ControlTextRenderer& ); // never implemented
107 :
108 : private:
109 : ::std::auto_ptr< ReferenceDeviceTextLayout > m_pImpl;
110 : };
111 :
112 : } // namespace vcl
113 :
114 : #endif // INCLUDED_VCL_INC_TEXTLAYOUT_HXX
115 :
116 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|