lokdialog: convert the show sheet dialog to async exec
[LibreOffice.git] / drawinglayer / README
blobb530ba6fedac834c9bddc223bcc43504f690b15b
1 Drawing API that can specify what to draw via a kind of display list.
3 Example of the DrawingLayer use is eg. in svx/source/xoutdev/xtabhtch.cxx:121.
4 A stripped down version with extended comments:
6      // Create a hatch primitive (here a rectangle that will be filled with
7      // the appropriate hatching, but has no border).
8      // This will not draw it yet; it's so far only constructed to add it to a
9      // display list later.
10      const drawinglayer::primitive2d::Primitive2DReference aHatchPrimitive(
11          new drawinglayer::primitive2d::PolyPolygonHatchPrimitive2D(...));
13      // Create a rectangle around the hatch, to give it a border.
14      const drawinglayer::primitive2d::Primitive2DReference aBlackRectanglePrimitive(
15          new drawinglayer::primitive2d::PolygonHairlinePrimitive2D(...));
17      // Here we want to render to a virtual device (to later obtain the bitmap
18      // out of that), so prepare it.
19      VirtualDevice aVirtualDevice;
21      // Create processor and draw primitives, to get it ready for rendering.
22      std::unique_ptr<drawinglayer::processor2d::BaseProcessor2D> pProcessor2D(
23          drawinglayer::processor2d::createPixelProcessor2DFromOutputDevice(...));
25      if (pProcessor2D)
26      {
27          // Fill-in the display list.
28          drawinglayer::primitive2d::Primitive2DSequence aSequence(2);
30          aSequence[0] = aHatchPrimitive;
31          aSequence[1] = aBlackRectanglePrimitive;
33          // Render it to the virtual device.
34          pProcessor2D->process(aSequence);
35          pProcessor2D.reset();
36      }
38      // Obtain the bitmap that was rendered from the virtual device, to re-use
39      // it in the widget.
40      aRetval = aVirtualDevice.GetBitmap(Point(0, 0), aVirtualDevice.GetOutputSizePixel());
42 == DrawingLayer glossary ==
44 Primitives - classes that represent what should be drawn.  It holds the data
45 what to draw, but does not contain any kind of the rendering.  Some of the
46 primitives are 'Basic primitives', that are primitives that cannot be
47 decomposed.  The rest of the primitives can be decomposed to the basic
48 primitives.
50 Decomposition - a way how to break down the more complicated primitives into
51 the basic primitives, and represent them via them; this logically makes the
52 plain Primitive2DSequence display list a hierarchy.
53 Eg. PolygonMarkerPrimitive2D can be decomposed to 2 hairlines
54 PolyPolygonHairlinePrimitive2D's, each with different color.
56 Processor - a class that goes through the hierarchy of the Primitives, and
57 renders it some way.  Various processors, like VclPixelProcessor2D (renders to
58 the screen), VclMetafileProcessor2D (renders to the VCL metafile, eg. for
59 printing), etc.
61 == How to Implement a new Primitive ("something new to draw") ==
63 * Create an ancestor of BasePrimitive2D
64   (or of its ancestor if it fits the purpose better)
66   * Assign it an ID [in drawinglayer_primitivetypes2d.hxx]
68   * Implement its decomposition
69     [virtual Primitive2DSequence create2DDecomposition(...)]
71 * Extend the (various) processor(s)
72   If you need more than relying on just the decomposition
74 == Where is DrawingLayer used ==
76 * SdrObject(s) (rectangles, Circles, predefined shapes etc.)
78 * Selections
80 * Various smaller cases to 'just draw something'
82   * Draw to a virtual device, and use the resulting bitmap (like the example
83     above)
85 * Custom widgets (like the Header / Footer indicator button)