Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ***********************************************************************/
28 : :
29 : : #ifndef VCL_TEXTLAYOUT_HXX
30 : : #define VCL_TEXTLAYOUT_HXX
31 : :
32 : : #include "vcl/outdev.hxx"
33 : :
34 : : #include <tools/solar.h>
35 : : #include <tools/string.hxx>
36 : :
37 : : #include <memory>
38 : :
39 : : class Control;
40 : :
41 : : //........................................................................
42 : : namespace vcl
43 : : {
44 : : //........................................................................
45 : :
46 : : //====================================================================
47 : : //= ITextLayout
48 : : //====================================================================
49 : 23865 : class SAL_NO_VTABLE ITextLayout
50 : : {
51 : : public:
52 : : virtual long GetTextWidth( const XubString& _rText, xub_StrLen _nStartIndex, xub_StrLen _nLength ) const = 0;
53 : : virtual void DrawText( const Point& _rStartPoint, const XubString& _rText, xub_StrLen _nStartIndex, xub_StrLen _nLength,
54 : : MetricVector* _pVector, String* _pDisplayText ) = 0;
55 : : virtual bool GetCaretPositions( const XubString& _rText, sal_Int32* _pCaretXArray, xub_StrLen _nStartIndex, xub_StrLen _nLength ) const = 0;
56 : : virtual xub_StrLen GetTextBreak( const XubString& _rText, long _nMaxTextWidth, xub_StrLen _nStartIndex, xub_StrLen _nLength ) const = 0;
57 : : virtual bool DecomposeTextRectAction() const = 0;
58 : :
59 : : protected:
60 : 23865 : ~ITextLayout() {}
61 : : };
62 : :
63 : : //====================================================================
64 : : //= DefaultTextLayout
65 : : //====================================================================
66 : : /** is an implementation of the ITextLayout interface which simply delegates its calls to the respective
67 : : methods of an OutputDevice instance, without any inbetween magic.
68 : : */
69 : : class DefaultTextLayout : public ITextLayout
70 : : {
71 : : public:
72 : 23457 : DefaultTextLayout( OutputDevice& _rTargetDevice )
73 : 23457 : :m_rTargetDevice( _rTargetDevice )
74 : : {
75 : 23457 : }
76 : : virtual ~DefaultTextLayout();
77 : :
78 : : // ITextLayout overridables
79 : : virtual long GetTextWidth(
80 : : const XubString& _rText,
81 : : xub_StrLen _nStartIndex,
82 : : xub_StrLen _nLength
83 : : ) const;
84 : : virtual void DrawText(
85 : : const Point& _rStartPoint,
86 : : const XubString& _rText,
87 : : xub_StrLen _nStartIndex,
88 : : xub_StrLen _nLength,
89 : : MetricVector* _pVector,
90 : : String* _pDisplayText
91 : : );
92 : : virtual bool GetCaretPositions(
93 : : const XubString& _rText,
94 : : sal_Int32* _pCaretXArray,
95 : : xub_StrLen _nStartIndex,
96 : : xub_StrLen _nLength
97 : : ) const;
98 : : virtual xub_StrLen GetTextBreak(
99 : : const XubString& _rText,
100 : : long _nMaxTextWidth,
101 : : xub_StrLen _nStartIndex,
102 : : xub_StrLen _nLength
103 : : ) const;
104 : : virtual bool DecomposeTextRectAction() const;
105 : :
106 : : private:
107 : : OutputDevice& m_rTargetDevice;
108 : : };
109 : :
110 : : //====================================================================
111 : : //= ControlTextRenderer
112 : : //====================================================================
113 : : class ReferenceDeviceTextLayout;
114 : : /** a class which allows rendering text of a Control onto a device, by taking into account the metrics of
115 : : a reference device.
116 : : */
117 : : class ControlTextRenderer
118 : : {
119 : : public:
120 : : ControlTextRenderer( const Control& _rControl, OutputDevice& _rTargetDevice, OutputDevice& _rReferenceDevice );
121 : : virtual ~ControlTextRenderer();
122 : :
123 : : Rectangle DrawText( const Rectangle& _rRect,
124 : : const XubString& _rText, sal_uInt16 _nStyle = 0,
125 : : MetricVector* _pVector = NULL, String* _pDisplayText = NULL );
126 : :
127 : : private:
128 : : ControlTextRenderer(); // never implemented
129 : : ControlTextRenderer( const ControlTextRenderer& ); // never implemented
130 : : ControlTextRenderer& operator=( const ControlTextRenderer& ); // never implemented
131 : :
132 : : private:
133 : : ::std::auto_ptr< ReferenceDeviceTextLayout > m_pImpl;
134 : : };
135 : :
136 : : //........................................................................
137 : : } // namespace vcl
138 : : //........................................................................
139 : :
140 : : #endif // VCL_TEXTLAYOUT_HXX
141 : :
142 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|