File: gcfactory.h

package info (click to toggle)
wxpython4.0 4.2.3%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 221,752 kB
  • sloc: cpp: 962,555; python: 230,573; ansic: 170,731; makefile: 51,756; sh: 9,342; perl: 1,564; javascript: 584; php: 326; xml: 200
file content (71 lines) | stat: -rw-r--r-- 2,799 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
///////////////////////////////////////////////////////////////////////////////
// Name:        tests/drawing/gcfactory.h
// Purpose:     Interface of a factory to create and destroy a wxGraphicsContext
//              and finally save the result of a rendering test
// Author:      Armel Asselin
// Created:     2014-02-26
// Copyright:   (c) 2014 ElliƩ Computing <opensource@elliecomputing.com>
///////////////////////////////////////////////////////////////////////////////

#ifndef _WX_TESTS_GCFACTORY_H_
#define _WX_TESTS_GCFACTORY_H_

// wxCairoRenderer::CreateMeasuringContext() is not implement for wxX11
#if wxUSE_GRAPHICS_CONTEXT && !defined(__WXX11__)
    #include "wx/graphics.h"
    #define wxUSE_TEST_GC_DRAWING 1
#else
    #define wxUSE_TEST_GC_DRAWING 0
#endif

#if wxUSE_TEST_GC_DRAWING

#include "wx/filename.h"

class WXDLLIMPEXP_FWD_CORE wxGraphicsContext;

// Implement a class derived from this one to let the drawing test create
//  graphics context, save them and destroy them.
class DrawingTestGCFactory
{
public:
    virtual ~DrawingTestGCFactory() {}

    // This identifier is used in the test and reference files to distinguish
    //  results produced by wxGraphicsContext generated by this factory
    //  use only lower case latin letters, '_' and '-'
    virtual wxString GetIdForFileName () const = 0;

    // This is the extension used when saving test and reference files
    virtual wxString GetExtensionForFileName () const = 0;

    // Returns true if a pixel per pixel comparison of rendered image should
    //  be used rather than a byte by byte comparison of files
    virtual bool UseImageComparison() const = 0;

    // Returns true this target is platform independent, rendering exactly
    //  the same result for whichever platform
    virtual bool PlatformIndependent() const = 0;

    // Builds a new context of @c expected_size, expecting to save it as
    //  @c target_file_name
    // NB: only one context is created as a time, so that the implementer
    //  can keep internal state if necessary
    virtual wxGraphicsContext *BuildNewContext (wxSize expectedSize,
        double pointsPerInch, const wxFileName &targetFileName) = 0;

    // Let's the opportunity to actually save the context and associated data
    // If saving requires deleting the wxGraphicsContext object the
    //  implementer is free to do it but @c gc must then be nulled
    virtual void SaveBuiltContext (wxGraphicsContext *&gc) = 0;

    // Cleans @c gc and internal data if any
    virtual void CleanUp (wxGraphicsContext *gc) = 0;
};

typedef DrawingTestGCFactory * (*CreateDrawingTestLifeCycleFunction)();
typedef void (*DestroyDrawingTestLifeCycleFunction) (DrawingTestGCFactory* lc);

#endif // wxUSE_TEST_GC_DRAWING

#endif // #ifndef _WX_TESTS_GCFACTORY_H_