summaryrefslogtreecommitdiff
path: root/Build/source/libs/graphite/engine-2.3.1/test/RegressionTest/SimpleTextSrc.h
blob: a5d191b4ac3cd51ea5f6faa544d31601790b26fa (plain)
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
/*--------------------------------------------------------------------*//*:Ignore this sentence.
Copyright (C) 1999, 2001 SIL International. All rights reserved.

Distributable under the terms of either the Common Public License or the
GNU Lesser General Public License, as specified in the LICENSING.txt file.

File: SimpleTextSrc.h
Responsibility: Sharon Correll
Last reviewed: Not yet.

Description:
	A simple text source that shows how to use this interface within Graphite.
-------------------------------------------------------------------------------*//*:End Ignore*/
#pragma once
#ifndef GRTXTSRC_INCLUDED
#define GRTXTSRC_INCLUDED

using namespace gr;

/*----------------------------------------------------------------------------------------------
	Class: SimpleTextSrc
	This class provides a simple implementation for a text source for the Graphite engine.
	There are no paragraph properties of interest and one set of character properties that
	apply to the entire string.

	This class is a subclass of IColorTextSource so that it can be used by the
	WinSegmentPainter class, which expects the getColors method to be defined.
----------------------------------------------------------------------------------------------*/
class SimpleTextSrc : public IColorTextSource
{
public:
	// Constructor:
	SimpleTextSrc(gr::utf16 * pszText);
	~SimpleTextSrc();

/*
	virtual long IncRefCount(void)
	{
		return InterlockedIncrement(&m_cref);
	}
	virtual long DecRefCount(void)
	{
		long cref = InterlockedDecrement(&m_cref);
		if (cref == 0) {
			m_cref = 1;
			delete this;
		}
		return cref;
	}
*/
	// -------------------------------------------------------------------------------
	// Interface methods:

	virtual UtfType utfEncodingForm()
	{
		return kutf16;
	}
	virtual size_t getLength()
	{
		return m_cchLength;
	}
	virtual size_t fetch(toffset ichMin, size_t cch, utf32 * prgchBuffer)
	{
		throw;
	}
	virtual size_t fetch(toffset ichMin, size_t cch, gr::utf16 * prgchwBuffer);
	virtual size_t fetch(toffset ichMin, size_t cch, utf8  * prgchsBuffer)
	{
		throw;
	};

	virtual bool getRightToLeft(toffset ich);
	virtual unsigned int getDirectionDepth(toffset ich);
	virtual float getVerticalOffset(toffset ich);

	virtual isocode getLanguage(toffset ich)
	{
		isocode ret;
		ret.rgch[0] = 'e'; ret.rgch[1] = 'n'; ret.rgch[2] = 0; ret.rgch[3] = 0;
		return ret;
	}

	virtual std::pair<toffset, toffset> propertyRange(toffset ich)
	{
		std::pair<toffset, toffset> pairRet;
		pairRet.first = 0;
		pairRet.second = m_cchLength;
		return pairRet;
	}

	virtual size_t getFontFeatures(toffset ich, FeatureSetting * prgfset)
	{
		return 0; // no features in this simple implementation
	}
	virtual bool sameSegment(toffset ich1, toffset ich2)
	{
		return true;
	}

	virtual void getColors(toffset ich, int * pclrFore, int * pclrBack)
	{
		*pclrFore = kclrBlack;
		*pclrBack = kclrTransparent;
	}

protected:
	long m_cref;
	gr::utf16 * m_prgchText;
	int m_cchLength;
};


#endif // !GRTXTSRC_INCLUDED