File: wprinter.c

package info (click to toggle)
scilab 4.0-12
  • links: PTS
  • area: non-free
  • in suites: etch, etch-m68k
  • size: 100,640 kB
  • ctags: 57,333
  • sloc: ansic: 377,889; fortran: 242,862; xml: 179,819; tcl: 42,062; sh: 10,593; ml: 9,441; makefile: 4,377; cpp: 1,354; java: 621; csh: 260; yacc: 247; perl: 130; lex: 126; asm: 72; lisp: 30
file content (122 lines) | stat: -rw-r--r-- 3,608 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
/*******************************************
 * Original source : GNUPLOT - win/wprinter.c 
 * modified for Scilab 
 *******************************************
 *
 * Copyright (C) 1992   Maurice Castro, Russell Lang
 *
 * Permission to use, copy, and distribute this software and its
 * documentation for any purpose with or without fee is hereby granted, 
 * provided that the above copyright notice appear in all copies and 
 * that both that copyright notice and this permission notice appear 
 * in supporting documentation.
 *
 * Permission to modify the software is granted, but not the right to
 * distribute the modified code.  Modifications are to be distributed 
 * as patches to released version.
 *  
 * This software is provided "as is" without express or implied warranty.
 *
 * AUTHORS
 *   Maurice Castro
 *   Russell Lang
 *
 * Modifications for Scilab 
 *   Jean-Philipe Chancelier 
 *   Allan CORNET INRIA 2005
 */
/*-----------------------------------------------------------------------------------*/
#ifndef STRICT
#define STRICT
#endif
/*-----------------------------------------------------------------------------------*/
#include <memory.h>
#include "wresource.h"
#include "wcommon.h"
/*-----------------------------------------------------------------------------------*/
static LP_PRINT prlist = NULL;
/*-----------------------------------------------------------------------------------*/
/******************************
 * Deals with a list of printers 
 ******************************/
void PrintRegister (LP_PRINT lpr)
{
  LP_PRINT next;
  next = prlist;
  prlist = lpr;
  lpr->next = next;
}
/*-----------------------------------------------------------------------------------*/
LP_PRINT PrintFind (HDC hdc)
{
  LP_PRINT this;
  this = prlist;
  while (this && (this->hdcPrn != hdc))
    {
      this = this->next;
    }
  return this;
}
/*-----------------------------------------------------------------------------------*/
void PrintUnregister (LP_PRINT lpr)
{
  LP_PRINT this, prev;
  prev = (LP_PRINT) NULL;
  this = prlist;
  while (this && (this != lpr))
    {
      prev = this;
      this = this->next;
    }
  if (this && (this == lpr))
    {
      /* unhook it */
      if (prev)
	prev->next = this->next;
      else
	prlist = this->next;
    }
}
/*-----------------------------------------------------------------------------------*/
/******************************
 * PrintDialogBox 
 ******************************/
EXPORT BOOL CALLBACK PrintDlgProc (HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
{
  LP_PRINT lpr;
  HWND parent;
  parent = GetParent (hDlg);
  lpr = (LP_PRINT) GetWindowLong (parent, 4);
  switch (message)
    {
    case WM_INITDIALOG:
      lpr->hDlgPrint = hDlg;
      SetWindowText (hDlg, (LPSTR) lParam);
      EnableMenuItem (GetSystemMenu (hDlg, FALSE), SC_CLOSE, MF_GRAYED);
      return TRUE;
    case WM_COMMAND:
      lpr->bUserAbort = TRUE;
      lpr->hDlgPrint = 0;
      EnableWindow (GetParent (hDlg), TRUE);
      EndDialog (hDlg, FALSE);
      return TRUE;
    }
  return FALSE;
}
/*-----------------------------------------------------------------------------------*/
EXPORT BOOL CALLBACK PrintAbortProc (HDC hdcPrn, int code)
{
  MSG msg;
  LP_PRINT lpr;
  lpr = PrintFind (hdcPrn);
  while (!lpr->bUserAbort && PeekMessage (&msg, 0, 0, 0, PM_REMOVE))
    {
      if (!lpr->hDlgPrint || !IsDialogMessage (lpr->hDlgPrint, &msg))
	{
	  TranslateMessage (&msg);
	  DispatchMessage (&msg);
	}
    }
  return (!lpr->bUserAbort);
}
/*-----------------------------------------------------------------------------------*/