summaryrefslogtreecommitdiff
path: root/src/lib/preprocess/windows/WindowsSvgDC.h
blob: 5b61a56b8f06ab6136761e92a6af9a6ae975c90e (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
#ifdef WIN32 // Windows API-dependent unit


#ifndef _WINDOWS_SVG_DC_H_INCLUDED_
#define _WINDOWS_SVG_DC_H_INCLUDED_

#include "SvgDC.h"
#include "SvgFont.h"

#include <set>
#include <map>
#include <Windows.h>


class WindowsSvgFontC;

class WindowsSvgDC : public SvgDC
{
public:
  WindowsSvgDC(HDC hDC = NULL);
  ~WindowsSvgDC();

  const SvgFontC *GetFont(
    double heightInch, unsigned int weight, bool isItalic, const std::string &name) const;

  double GetFontBaseLineHeightRatio(unsigned int fontId) const;

  double GetTextPartialExtents(
    const std::wstring &text, unsigned int fontId, double offsetInch,
    std::vector<double> &extentsInch) const;

  double GetTabCharExtent(unsigned int fontId, double offsetInch) const;

private:
  typedef std::set<WindowsSvgFontC *, SvgFontCompareS> FontsTp;
  typedef FontsTp::iterator FontsItTp;

  typedef std::map<unsigned int, WindowsSvgFontC *> FontIdsTp;
  typedef FontIdsTp::iterator FontIdsItTp;

  bool GetFontMetric(unsigned int fontId, TEXTMETRIC &metric) const;
  int GetPixelsPerInchX() const;
  int GetPixelsPerInchY() const;
  double PixelsToInches(unsigned int pixels, bool horizontal) const;
  unsigned int InchesToPixels(double inches, bool horizontal) const;
  double GetConversionPrecisionFactor() const;
  unsigned int GetNextFontId() const;

  HDC m_hDC;
  bool m_ownDC;

  mutable int m_pixelPerInchX;
  mutable int m_pixelPerInchY;
  mutable FontsTp m_fonts;
  mutable FontIdsTp m_fontIds;
};


#endif // _WINDOWS_SVG_DC_H_INCLUDED_

#endif WIN32 // Windows API-dependent unit