1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #ifndef INCLUDED_VCL_VCLLAYOUT_HXX
21 #define INCLUDED_VCL_VCLLAYOUT_HXX
23 #include <basegfx/polygon/b2dpolypolygon.hxx>
24 #include <tools/gen.hxx>
25 #include <vcl/devicecoordinate.hxx>
26 #include <vcl/dllapi.h>
29 class PhysicalFontFace
;
32 class SalLayoutGlyphs
;
34 // all positions/widths are in font units
35 // one exception: drawposition is in pixel units
37 // Unfortunately there is little documentation to help implementors of
38 // new classes derived from SalLayout ("layout engines"), and the code
39 // and data structures are far from obvious.
41 // For instance, I *think* the important virtual functions in the
42 // layout engines are called in this order:
46 // * AdjustLayout(), any number of times (but presumably
47 // usually not at all or just once)
48 // * Optionally, DrawText()
50 // Functions that just return information like GetTexWidth() and
51 // FillDXArray() are called after LayoutText() and before DrawText().
53 // Another important questions is which parts of an ImplLayoutArgs can
54 // be changed by callers between LayoutText() and AdjustLayout()
55 // calls. It probably makes sense only if one assumes that the "string
56 // related inputs" part are not changed after LayoutText().
58 // But why use the same ImplLayoutArgs structure as parameter for both
59 // LayoutText() and AdjustLayout() in the first place? And why
60 // duplicate some of the fields in both SalLayout and ImplLayoutArgs
61 // (mnMinCharPos, mnEndCharPos, mnLayoutFlags==mnFlags,
62 // mnOrientation)? Lost in history...
64 class VCL_DLLPUBLIC SalLayout
68 // used by upper layers
69 Point
& DrawBase() { return maDrawBase
; }
70 const Point
& DrawBase() const { return maDrawBase
; }
71 Point
& DrawOffset() { return maDrawOffset
; }
72 const Point
& DrawOffset() const { return maDrawOffset
; }
73 Point
GetDrawPosition( const Point
& rRelative
= Point(0,0) ) const;
75 virtual bool LayoutText( ImplLayoutArgs
&, const SalLayoutGlyphs
* ) = 0; // first step of layouting
76 virtual void AdjustLayout( ImplLayoutArgs
& ); // adjusting after fallback etc.
77 virtual void InitFont() const {}
78 virtual void DrawText( SalGraphics
& ) const = 0;
80 int GetUnitsPerPixel() const { return mnUnitsPerPixel
; }
81 int GetOrientation() const { return mnOrientation
; }
83 // methods using string indexing
84 virtual sal_Int32
GetTextBreak(DeviceCoordinate nMaxWidth
, DeviceCoordinate nCharExtra
, int nFactor
) const = 0;
85 virtual DeviceCoordinate
FillDXArray( DeviceCoordinate
* pDXArray
) const = 0;
86 virtual DeviceCoordinate
GetTextWidth() const { return FillDXArray( nullptr ); }
87 virtual void GetCaretPositions( int nArraySize
, long* pCaretXArray
) const = 0;
88 virtual bool IsKashidaPosValid ( int /*nCharPos*/ ) const { return true; } // i60594
90 // methods using glyph indexing
91 virtual bool GetNextGlyph(const GlyphItem
** pGlyph
, Point
& rPos
, int& nStart
,
92 const PhysicalFontFace
** pFallbackFont
= nullptr,
93 int* const pFallbackLevel
= nullptr) const = 0;
94 virtual bool GetOutline(basegfx::B2DPolyPolygonVector
&) const;
95 bool GetBoundRect(tools::Rectangle
&) const;
97 virtual const SalLayoutGlyphs
* GetGlyphs() const;
100 // used by layout engines
104 SalLayout(const SalLayout
&) = delete;
105 SalLayout
& operator=(const SalLayout
&) = delete;
114 mutable Point maDrawOffset
;
118 #endif // INCLUDED_VCL_VCLLAYOUT_HXX
120 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */