LibreOffice Module vcl (master)  1
vcllayout.hxx
Go to the documentation of this file.
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_VCLLAYOUT_HXX
21 #define INCLUDED_VCL_VCLLAYOUT_HXX
22 
24 #include <tools/gen.hxx>
25 #include <tools/degree.hxx>
26 #include <vcl/devicecoordinate.hxx>
27 #include <vcl/dllapi.h>
28 
29 class ImplLayoutArgs;
30 class PhysicalFontFace;
31 class SalGraphics;
32 class GlyphItem;
33 class SalLayoutGlyphs;
34 
35 // all positions/widths are in font units
36 // one exception: drawposition is in pixel units
37 
38 // Unfortunately there is little documentation to help implementors of
39 // new classes derived from SalLayout ("layout engines"), and the code
40 // and data structures are far from obvious.
41 
42 // For instance, I *think* the important virtual functions in the
43 // layout engines are called in this order:
44 
45 // * InitFont()
46 // * LayoutText()
47 // * AdjustLayout(), any number of times (but presumably
48 // usually not at all or just once)
49 // * Optionally, DrawText()
50 
51 // Functions that just return information like GetTexWidth() and
52 // FillDXArray() are called after LayoutText() and before DrawText().
53 
54 // Another important questions is which parts of an ImplLayoutArgs can
55 // be changed by callers between LayoutText() and AdjustLayout()
56 // calls. It probably makes sense only if one assumes that the "string
57 // related inputs" part are not changed after LayoutText().
58 
59 // But why use the same ImplLayoutArgs structure as parameter for both
60 // LayoutText() and AdjustLayout() in the first place? And why
61 // duplicate some of the fields in both SalLayout and ImplLayoutArgs
62 // (mnMinCharPos, mnEndCharPos, mnLayoutFlags==mnFlags,
63 // mnOrientation)? Lost in history...
64 
66 {
67 public:
68  virtual ~SalLayout();
69  // used by upper layers
70  Point& DrawBase() { return maDrawBase; }
71  const Point& DrawBase() const { return maDrawBase; }
72  Point& DrawOffset() { return maDrawOffset; }
73  const Point& DrawOffset() const { return maDrawOffset; }
74  Point GetDrawPosition( const Point& rRelative = Point(0,0) ) const;
75 
76  virtual bool LayoutText( ImplLayoutArgs&, const SalLayoutGlyphs* ) = 0; // first step of layouting
77  virtual void AdjustLayout( ImplLayoutArgs& ); // adjusting after fallback etc.
78  virtual void InitFont() const {}
79  virtual void DrawText( SalGraphics& ) const = 0;
80 
81  int GetUnitsPerPixel() const { return mnUnitsPerPixel; }
82  Degree10 GetOrientation() const { return mnOrientation; }
83 
84  // methods using string indexing
85  virtual sal_Int32 GetTextBreak(DeviceCoordinate nMaxWidth, DeviceCoordinate nCharExtra, int nFactor) const = 0;
86  virtual DeviceCoordinate FillDXArray( DeviceCoordinate* pDXArray ) const = 0;
87  virtual DeviceCoordinate GetTextWidth() const { return FillDXArray( nullptr ); }
88  virtual void GetCaretPositions( int nArraySize, tools::Long* pCaretXArray ) const = 0;
89  virtual bool IsKashidaPosValid ( int /*nCharPos*/ ) const { return true; } // i60594
90 
91  // methods using glyph indexing
92  virtual bool GetNextGlyph(const GlyphItem** pGlyph, Point& rPos, int& nStart,
93  const PhysicalFontFace** pFallbackFont = nullptr) const = 0;
94  virtual bool GetOutline(basegfx::B2DPolyPolygonVector&) const;
95  bool GetBoundRect(tools::Rectangle&) const;
96 
97  virtual const SalLayoutGlyphs* GetGlyphs() const;
98 
99 protected:
100  // used by layout engines
101  SalLayout();
102 
103 private:
104  SalLayout(const SalLayout&) = delete;
105  SalLayout& operator=(const SalLayout&) = delete;
106 
107 protected:
110 
113 
116 };
117 
118 #endif // INCLUDED_VCL_VCLLAYOUT_HXX
119 
120 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
int GetUnitsPerPixel() const
Definition: vcllayout.hxx:81
#define VCL_DLLPUBLIC
Definition: dllapi.h:29
long Long
virtual DeviceCoordinate GetTextWidth() const
Definition: vcllayout.hxx:87
Point maDrawBase
Definition: vcllayout.hxx:115
const Point & DrawBase() const
Definition: vcllayout.hxx:71
abstract base class for physical font faces
int mnEndCharPos
Definition: vcllayout.hxx:109
virtual void InitFont() const
Definition: vcllayout.hxx:78
Degree10 GetOrientation() const
Definition: vcllayout.hxx:82
tools::Long DeviceCoordinate
Point & DrawBase()
Definition: vcllayout.hxx:70
int mnUnitsPerPixel
Definition: vcllayout.hxx:111
Degree10 mnOrientation
Definition: vcllayout.hxx:112
virtual bool IsKashidaPosValid(int) const
Definition: vcllayout.hxx:89
const Point & DrawOffset() const
Definition: vcllayout.hxx:73
int mnMinCharPos
Definition: vcllayout.hxx:108
Point maDrawOffset
Definition: vcllayout.hxx:114
Point & DrawOffset()
Definition: vcllayout.hxx:72
::std::vector< B2DPolyPolygon > B2DPolyPolygonVector