File: vwinprdc.cpp

package info (click to toggle)
v1 1.20-2
  • links: PTS
  • area: main
  • in suites: slink
  • size: 6,240 kB
  • ctags: 9,439
  • sloc: cpp: 48,033; ansic: 8,939; makefile: 1,369; sh: 30
file content (138 lines) | stat: -rw-r--r-- 3,557 bytes parent folder | download | duplicates (2)
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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
//===============================================================
// vWinPrinterC - a basic canvas for drawing
//
// Copyright (C) 1995,1996, 1997, 1998  Bruce E. Wampler
//
// This file is part of the V C++ GUI Framework, and is covered
// under the terms of the GNU Library General Public License,
// Version 2. This library has NO WARRANTY. See the source file
// vapp.cxx for more complete information about license terms.
//===============================================================


#include <v/vwin32.h>		// for Win 32 stuff

#include <math.h>


#include <v/vwinprdc.h>
#include <v/vapp.h>		// need access to the app

//-----------------------------------------------------------------------

//================>>> vWinPrinterDC::vWinPrinterDC <<<========================
  vWinPrinterDC::vWinPrinterDC() : vWinDC()
  {
    SysDebug(Constructor,"vWinPrinterDC::vWinPrinterDC() constructor\n")
    _isPrinterDC = 1;
  }

//================>>> vWinPrinterDC::~vWinPrinterDC <<<========================
  vWinPrinterDC::~vWinPrinterDC()
  {

    SysDebug(Destructor,"vWinPrinterDC::~vWinPrinterDC() destructor\n")

  }

//================>>> vWinPrinterDC::SetBackground <<<==========================
  void vWinPrinterDC::SetBackground(vColor& color)
  {

   _canvasBG = color.pixel();		// retrieve X pixel value

    GetHDC();
    ::SetBkColor(_hdc, _canvasBG);
    ReleaseHDC();
  }

//======================>>> vWinPrinterDC::SetFont <<<===========================
  void vWinPrinterDC::SetFont(vFont& vf)
  {
    // Change the font associated with this window.

    _font = vf;
  }

//================>>> vWinPrinterDC::BeginPrinting <<<========================
  int vWinPrinterDC::BeginPrinting()
  {

    DOCINFO docinfo;

    if (!_printer.GetHDC())		// should not happen...
      {
	return 0;
      }

    _pages = 0;

    docinfo.cbSize = sizeof(DOCINFO);	// set this size...
    docinfo.lpszDocName = "VPrintJob";
    docinfo.lpszOutput = 0;		// no file output...

    if (::StartDoc(_printer.GetHDC(), &docinfo) < 0)
	return 0;


    BeginPage();

    return 1;

  }

//================>>> vWinPrinterDC::BeginPage <<<========================
  void vWinPrinterDC::BeginPage()
  {
    HDC pHDC = _printer.GetHDC();
    if (!pHDC)
	return;
    ++_pages;		// bump number of pages so far

    // I'm not sure exactly why, but the printer DC seems
    // to have all this set again after an EndPage has been
    // done, so I will always do it now at a begin page.

    int pixw = ::GetDeviceCaps(pHDC, HORZRES);
    int pixh = ::GetDeviceCaps(pHDC, VERTRES);
    // This scaling gives about the same proportions as the X version
    int width = ::GetDeviceCaps(pHDC, HORZSIZE) * 3;
    int height = ::GetDeviceCaps(pHDC,VERTSIZE) * 3;

    ::SetMapMode(pHDC, MM_ISOTROPIC);
    ::SetWindowExt(pHDC,width,height);
    ::SetViewportExt(pHDC,pixw,pixh);

    ::StartPage(_printer.GetHDC());
  }

//================>>> vWinPrinterDC::EndPage <<<========================
  void vWinPrinterDC::EndPage()
  {
    if (!_printer.GetHDC())
	return;
    ::EndPage(_printer.GetHDC());
  }

//================>>> vWinPrinterDC::EndPrinting <<<========================
  void vWinPrinterDC::EndPrinting()
  {
    if (!_printer.GetHDC())
	return;

    EndPage();

    ::EndDoc(_printer.GetHDC());

  }

//=====================>>> vWinPrinterDC::SetPrinter <<<============================
 void vWinPrinterDC::SetPrinter(vPrinter& printer)
  {
    _printer = printer;
    _physHeight = _printer.GetHeight();
    _physWidth = _printer.GetWidth();

  }