wprinter.c

Go to the documentation of this file.
00001 /*******************************************
00002  * Original source : GNUPLOT - win/wprinter.c 
00003  * modified for Scilab 
00004  *******************************************
00005  *
00006  * Copyright (C) 1992   Maurice Castro, Russell Lang
00007  *
00008  * Permission to use, copy, and distribute this software and its
00009  * documentation for any purpose with or without fee is hereby granted, 
00010  * provided that the above copyright notice appear in all copies and 
00011  * that both that copyright notice and this permission notice appear 
00012  * in supporting documentation.
00013  *
00014  * Permission to modify the software is granted, but not the right to
00015  * distribute the modified code.  Modifications are to be distributed 
00016  * as patches to released version.
00017  *  
00018  * This software is provided "as is" without express or implied warranty.
00019  *
00020  * AUTHORS
00021  *   Maurice Castro
00022  *   Russell Lang
00023  *
00024  * Modifications for Scilab 
00025  *   Jean-Philipe Chancelier 
00026  *   Allan CORNET INRIA 2005
00027  */
00028 /*-----------------------------------------------------------------------------------*/
00029 #ifndef STRICT
00030 #define STRICT
00031 #endif
00032 /*-----------------------------------------------------------------------------------*/
00033 #include <memory.h>
00034 #include "wresource.h"
00035 #include "wcommon.h"
00036 /*-----------------------------------------------------------------------------------*/
00037 static LP_PRINT prlist = NULL;
00038 /*-----------------------------------------------------------------------------------*/
00039 /******************************
00040  * Deals with a list of printers 
00041  ******************************/
00042 void PrintRegister (LP_PRINT lpr)
00043 {
00044   LP_PRINT next;
00045   next = prlist;
00046   prlist = lpr;
00047   lpr->next = next;
00048 }
00049 /*-----------------------------------------------------------------------------------*/
00050 LP_PRINT PrintFind (HDC hdc)
00051 {
00052   LP_PRINT this;
00053   this = prlist;
00054   while (this && (this->hdcPrn != hdc))
00055     {
00056       this = this->next;
00057     }
00058   return this;
00059 }
00060 /*-----------------------------------------------------------------------------------*/
00061 void PrintUnregister (LP_PRINT lpr)
00062 {
00063   LP_PRINT this, prev;
00064   prev = (LP_PRINT) NULL;
00065   this = prlist;
00066   while (this && (this != lpr))
00067     {
00068       prev = this;
00069       this = this->next;
00070     }
00071   if (this && (this == lpr))
00072     {
00073       /* unhook it */
00074       if (prev)
00075         prev->next = this->next;
00076       else
00077         prlist = this->next;
00078     }
00079 }
00080 /*-----------------------------------------------------------------------------------*/
00081 /******************************
00082  * PrintDialogBox 
00083  ******************************/
00084 EXPORT BOOL CALLBACK PrintDlgProc (HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
00085 {
00086   LP_PRINT lpr;
00087   HWND parent;
00088   parent = GetParent (hDlg);
00089   lpr = (LP_PRINT) GetWindowLong (parent, 4);
00090   switch (message)
00091     {
00092     case WM_INITDIALOG:
00093       lpr->hDlgPrint = hDlg;
00094       SetWindowText (hDlg, (LPSTR) lParam);
00095       EnableMenuItem (GetSystemMenu (hDlg, FALSE), SC_CLOSE, MF_GRAYED);
00096       return TRUE;
00097     case WM_COMMAND:
00098       lpr->bUserAbort = TRUE;
00099       lpr->hDlgPrint = 0;
00100       EnableWindow (GetParent (hDlg), TRUE);
00101       EndDialog (hDlg, FALSE);
00102       return TRUE;
00103     }
00104   return FALSE;
00105 }
00106 /*-----------------------------------------------------------------------------------*/
00107 EXPORT BOOL CALLBACK PrintAbortProc (HDC hdcPrn, int code)
00108 {
00109   MSG msg;
00110   LP_PRINT lpr;
00111   lpr = PrintFind (hdcPrn);
00112   while (!lpr->bUserAbort && PeekMessage (&msg, 0, 0, 0, PM_REMOVE))
00113     {
00114       if (!lpr->hDlgPrint || !IsDialogMessage (lpr->hDlgPrint, &msg))
00115         {
00116           TranslateMessage (&msg);
00117           DispatchMessage (&msg);
00118         }
00119     }
00120   return (!lpr->bUserAbort);
00121 }
00122 /*-----------------------------------------------------------------------------------*/

Generated on Sun Mar 4 15:03:55 2007 for Scilab [trunk] by  doxygen 1.5.1