FigureToPrint.c File Reference

#include "FigureToPrint.h"
#include "win_mem_alloc.h"
#include "WindowList.h"
#include "../../../modules/graphics/includes/xs2file.h"

Include dependency graph for FigureToPrint.c:

Go to the source code of this file.

Defines

#define MAXSTR   255

Functions

void dos2win32 (char *filename, char *filename1)
char GetPrinterOrientation (void)
void Setscig_buzyState (BOOL state)
BOOL FigureToPrint (int figurenumber, BOOL Postscript)
int CopyPrint (struct BCG *ScilabGC)
void PrintPs (struct BCG *ScilabGC)

Variables

HINSTANCE hdllInstance
int WindowsPrintScreen
int Printer_XRes
int Printer_YRes
static char filename [MAXSTR]
static char filename1 [MAXSTR]
LS ls


Define Documentation

#define MAXSTR   255

Definition at line 18 of file FigureToPrint.c.


Function Documentation

int CopyPrint ( struct BCG ScilabGC  ) 

Definition at line 44 of file FigureToPrint.c.

References BCG::CurWindow, BCG::CWindow, FALSE, GetCurrentFigureWindows(), GetPrinterDC(), hdllInstance, HORZRES, int, L, MSG_ERROR34, MSG_SCIMSG12, MyGetProcAddress, NULL, pr, PrintAbortProc(), PrintDlgProc(), printer, Printer_XRes, Printer_YRes, PrintRegister(), PrintUnregister(), scig_replay_hdc(), sciprint(), SetCurrentFigureWindows(), Setscig_buzyState(), tagGW::Title, TRUE, TryToGetDC(), VERTRES, and WindowsPrintScreen.

Referenced by FigureToPrint(), and SendGraphMacro().

00045 {
00046         int xPage, yPage;
00047         static DOCINFO di = {sizeof (DOCINFO), MSG_SCIMSG12, NULL};
00048         BOOL bError = FALSE;
00049         HDC hDCfromhWnd=NULL;
00050         HDC printer=NULL;
00051         LPGW lpgw;
00052         ABORTPROC lpfnAbortProc;
00053         DLGPROC lpfnPrintDlgProc;
00054         static PRINTDLG pd;
00055         HWND hwnd;
00056         RECT rect,RectRestore;
00057         PRINT pr;
00058 
00059         integer SaveCurrentWindow=0;
00060 
00061         SaveCurrentWindow=GetCurrentFigureWindows();
00062 
00063         Setscig_buzyState(TRUE);
00064 
00065         SetCurrentFigureWindows (ScilabGC->CurWindow);
00066 
00067         lpgw = ScilabGC->lpgw;
00068         hwnd = ScilabGC->CWindow;
00069         hDCfromhWnd=TryToGetDC (hwnd);
00070 
00071         printer = (HDC)GetPrinterDC();
00072 
00073         if (NULL == printer)
00074         {
00075                 /* Redessine si Cancel Impression */
00076                 GetClientRect (hwnd, &RectRestore);
00077                 scig_replay_hdc ('W', ScilabGC->CurWindow, hDCfromhWnd,RectRestore.right - RectRestore.left, RectRestore.bottom - RectRestore.top, 1);
00078                 Setscig_buzyState(FALSE);
00079                 return TRUE;            /* abort */
00080         }
00081 
00082         pr.hdcPrn = printer;
00083         xPage = GetDeviceCaps (pr.hdcPrn, HORZRES);
00084         yPage = GetDeviceCaps (pr.hdcPrn, VERTRES);
00085 
00086         GetClientRect (hwnd, &rect);
00087         SetLastError (0);
00088         if (SetWindowLong (hwnd, 4, (LONG) ((LP_PRINT) & pr)) == 0 && GetLastError () != 0)
00089         {
00090                 sciprint (MSG_ERROR34);
00091                 Setscig_buzyState(FALSE);
00092                 return TRUE;
00093         }
00094         if (SetWindowLong(ScilabGC->hWndParent, 4, (LONG) ((LP_PRINT) & pr)) == 0       && GetLastError () != 0)
00095         {
00096                 sciprint (MSG_ERROR34);
00097                 Setscig_buzyState(FALSE);
00098                 return TRUE;
00099         }
00100         PrintRegister ((LP_PRINT) & pr);
00101         EnableWindow (hwnd, FALSE);
00102 
00103         pr.bUserAbort = FALSE;
00104         lpfnPrintDlgProc = (DLGPROC) MyGetProcAddress ("PrintDlgProc",PrintDlgProc);
00105         lpfnAbortProc = (ABORTPROC) MyGetProcAddress ("PrintAbortProc",PrintAbortProc);
00106         pr.hDlgPrint = CreateDialogParam (hdllInstance, "PrintDlgBox", hwnd, lpfnPrintDlgProc, (LPARAM) lpgw->Title);
00107         SetAbortProc (pr.hdcPrn, lpfnAbortProc);
00108 
00109         if (StartDoc (pr.hdcPrn, &di) > 0)
00110         {
00111                 if (StartPage (pr.hdcPrn) > 0)
00112                 {
00113                         int scalef = 1;
00114                         SetMapMode (pr.hdcPrn, MM_TEXT);
00115                         SetBkMode (pr.hdcPrn, TRANSPARENT);
00116                         SetTextAlign (pr.hdcPrn, TA_LEFT | TA_BOTTOM);
00117                         scalef = (int) (10.0 * ((double) xPage * yPage) / (6800.0 * 4725.0));
00118                         GetClientRect (hwnd, &RectRestore);
00119                         /* Evite bug lorsque l'on selectionne la fenetre & que l'on imprime apres */
00120                         scig_replay_hdc ('P', ScilabGC->CurWindow, hDCfromhWnd,RectRestore.right - RectRestore.left, RectRestore.bottom - RectRestore.top, 1);
00121                         WindowsPrintScreen = 1;
00122                         Printer_XRes = GetDeviceCaps (pr.hdcPrn, LOGPIXELSX);
00123                         Printer_YRes = GetDeviceCaps (pr.hdcPrn, LOGPIXELSY);
00124                         scig_replay_hdc ('P', ScilabGC->CurWindow, printer,xPage, yPage, scalef);
00125                         WindowsPrintScreen = 0;
00126                         /* Redessine à l'ecran apres l'impression */
00127                         scig_replay_hdc ('W', ScilabGC->CurWindow,hDCfromhWnd,RectRestore.right - RectRestore.left, RectRestore.bottom - RectRestore.top, 1);
00128                         if (EndPage (pr.hdcPrn) > 0)  EndDoc (pr.hdcPrn);
00129                         else bError = TRUE;
00130                 }
00131         }
00132         else bError = TRUE;
00133 
00134         if (!pr.bUserAbort)
00135         {
00136                 EnableWindow (hwnd, TRUE);
00137                 DestroyWindow (pr.hDlgPrint);
00138         }
00139         if (printer) {DeleteDC (printer); printer=NULL;}
00140         SetWindowLong (hwnd, 4, (LONG) (0L));
00141         SetWindowLong (ScilabGC->hWndParent, 4, (LONG) (0L));
00142         PrintUnregister ((LP_PRINT) & pr);
00143 
00144         ReleaseDC (hwnd, hDCfromhWnd);
00145         SetCurrentFigureWindows (SaveCurrentWindow);
00146 
00147         Setscig_buzyState(FALSE);
00148         InvalidateRect(hwnd,NULL,TRUE);
00149 
00150         return bError || pr.bUserAbort;
00151 }

Here is the call graph for this function:

Here is the caller graph for this function:

void dos2win32 ( char *  filename,
char *  filename1 
)

Definition at line 190 of file FigureToFile.c.

00191 {
00192 #ifdef CVT_PATH_BEG
00193   if (filename[1] == ':')
00194     {
00195       *filename1++ = '/';
00196       *filename1++ = '/';
00197       *filename1++ = *filename++;
00198       filename++;
00199     }
00200 #endif
00201   while (*filename != '\0')
00202     {
00203       *filename1++ = *filename++;
00204       if (*(filename1 - 1) == '\\')
00205         *(filename1 - 1) = '/';
00206     }
00207   *filename1 = '\0';
00208 }

BOOL FigureToPrint ( int  figurenumber,
BOOL  Postscript 
)

Definition at line 22 of file FigureToPrint.c.

References CopyPrint(), FALSE, getWindowXgcNumber(), NULL, PrintPs(), and TRUE.

Referenced by C2F().

00023 {
00024         BOOL bOK=FALSE;
00025         struct BCG *ScilabGC=NULL;
00026         ScilabGC = getWindowXgcNumber (figurenumber);
00027 
00028         if (ScilabGC)
00029         {
00030                 if (Postscript)
00031                 {
00032                          PrintPs (ScilabGC);
00033                 }
00034                 else
00035                 {
00036                         CopyPrint (ScilabGC);
00037                 }
00038                 bOK=TRUE;
00039         }
00040         else bOK=FALSE;
00041         return bOK;
00042 }

Here is the call graph for this function:

Here is the caller graph for this function:

char GetPrinterOrientation ( void   ) 

Definition at line 596 of file TextToPrint.c.

Referenced by PrintPs().

00597 {
00598         return PrinterOrientation;
00599 }

Here is the caller graph for this function:

void PrintPs ( struct BCG ScilabGC  ) 

Definition at line 153 of file FigureToPrint.c.

References tagLS::colored, BCG::CurWindow, dos2win32(), FALSE, filename, filename1, getenv(), GetPrinterDC(), GetPrinterOrientation(), gp_printfile(), hdllInstance, ls, MSG_ERROR78, MSG_WARNING15, NULL, scig_toPs(), ScilabPsToEps(), sciprint(), and tagLS::use_printer.

Referenced by FigureToPrint(), scig_print(), and SendGraphMacro().

00154 {
00155         HDC hPrinterDC=NULL;
00156         char *p1;
00157         char ori;
00159         ls.use_printer = 1;
00160         ls.colored = 1;
00161 
00162         hPrinterDC=GetPrinterDC(); // Just to Configure Printer
00163         if (hPrinterDC) {DeleteDC(hPrinterDC);hPrinterDC=NULL;}
00164 
00166         if ((p1 = getenv ("TMPDIR")) == (char *) 0)
00167         {
00168                 sciprint (MSG_WARNING15);
00169                 return;
00170         }
00171         sprintf (filename, "%s/scilab-%d", p1, (int) ScilabGC->CurWindow);
00172 
00173         dos2win32 (filename, filename1);
00174 
00175         scig_toPs (ScilabGC->CurWindow, ls.colored, filename1, "Pos");
00176 
00177         ori =GetPrinterOrientation();
00178 
00179         if (ScilabPsToEps (ori, filename1, filename) == 0)
00180         {
00181                 if (gp_printfile (hdllInstance, ScilabGC->hWndParent, filename,(char *) 0) == FALSE)    sciprint (MSG_ERROR78);
00182         }
00185 }

Here is the call graph for this function:

Here is the caller graph for this function:

void Setscig_buzyState ( BOOL  state  ) 

Definition at line 11 of file CriticalSectionGraphicWindow.c.

References init_C_S_Sync_scig_buzy, Sync_scig_buzy, and TRUE.

Referenced by CopyPrint(), CopyToClipboardBitmap(), CopyToClipboardEMF(), ExportBMP(), ExportEMF(), and ScilabPaint().

00012 {
00013         if (init_C_S_Sync_scig_buzy==0)
00014         {
00015                 InitializeCriticalSection(&Sync_scig_buzy);
00016                 init_C_S_Sync_scig_buzy++;
00017         }
00018 
00019         if (state == TRUE)
00020         {
00021                 EnterCriticalSection(&Sync_scig_buzy);
00022         }
00023         else
00024         {
00025                 LeaveCriticalSection(&Sync_scig_buzy);
00026         }
00027 }

Here is the caller graph for this function:


Variable Documentation

char filename[MAXSTR] [static]

Definition at line 19 of file FigureToPrint.c.

char filename1[MAXSTR] [static]

Definition at line 19 of file FigureToPrint.c.

Referenced by main(), PrintPs(), SavePs(), and WriteTeX().

HINSTANCE hdllInstance

Definition at line 88 of file wtext.c.

LS ls

Definition at line 20 of file ExportBox.c.

Referenced by ExportStyleDlgProc(), gentril(), gentriu(), intdgesvd(), PrintPs(), RandI(), SavePs(), sci_legendre(), and sttyp().

int Printer_XRes

Definition at line 68 of file Xcall.c.

Referenced by CopyPrint(), and GetDPIFromDriver().

int Printer_YRes

Definition at line 69 of file Xcall.c.

Referenced by CopyPrint(), and GetDPIFromDriver().

int WindowsPrintScreen

Definition at line 67 of file Xcall.c.

Referenced by CopyPrint(), and GetDPIFromDriver().


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