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