printPanel()
Prints a panel.
Synopsis
int printPanel( string modulName, string panelName, string spec, int options
);
Parameters
Parameters | Description |
---|---|
modulName | Module in which the panel to be printed is located |
panelName | panel to be printed |
spec |
Default = "" and means print with child panels (is printed like a screenshot), "panelOnly" = prints the panel without child panels (without screenshot of the child panels). CAUTION When using Windows child panels cannot be printed due to technical restrictions of the operating systems. NOTE For the highest print quality it is recommended to use the option "panelOnly". |
options |
With the options parameter the available printing options can be defined. Following constants (values) are available:
The background options dialog is used to define wether the background color should be replaced with white or should not be changed. |
Return value
The function printPanel() returns 0 or in the event of errors, -1.
Description
The function printPanel() prints out a panel panelName in a module modulName.
Printing
When you want to print a panel, a printer settings window opens. The printer settings window opens by default. The options parameter you can define wether all windows are opened or only the printer window/background color window.
The examples below show how to print a panel by either using the attributes of the internal data point or by using the parameter to open the printer settings window.
The associated data point elements of the internal _Ui data point are:
Data point element at the DP node _Ui_X.Print ("X" stands for the number of the UI) | Data type | Description |
---|---|---|
.PrinterName | string |
Printer name or file name. In silent mode or without print dialog, the printout can be also redirected to a local file. The supported formats are PDF (*.pdf) and Postscript (*.ps). Syntax: "file:///path/file.pdf"; Examples: Linux: "file:///tmp/file.pdf"; Windows: "file:///C:/Temp/file.ps"; |
.Landscape | bool | Landscape or Portrait |
.Background | bool | off = the background color of the panel will be printed in white. |
.Scale | float | Scaling factor |
.FitToPage | bool | Allows scaling irrespective of the printer default. |
In the following example, the available printers are first queried with the function getPrinterNames(). A panel will be printed on an available printer. The printer settings are selected through the internal UI data point.
Instead of a dpSet() a dpSetWait() should be used, as otherwise the UI may not get the new hotlink in case of a new printPanel() call and the old/previous values are taken over from the DP.
main()
{
dyn_string name, share;
getPrinterNames(name, share);
/* Function to query the names of the available printers */
DebugN(name);
DebugN(share); /*use a printer that is saved in this variable */
int PDruck;
/* Set the printer settings. The settings of the UI data point with the number 4, are set. The panel is printed on the third available printer. The landscape format is not used, the background is white and scaling is not used */
dpSetWait("_Ui_4.Print.PrinterName:_original.._value", share[3], "_Ui_4.Print.Landscape", FALSE, "_Ui_4.Print.Background", FALSE, "_Ui_4.Print.Scale", 0, "_Ui_4.Print.FitToPage", FALSE);
string modulName = myModuleName(); /* the current module is used*/
string panelName = "print_panel"; /* A panel called "print_panel" is printed */
int options = PPO_NO_DIALOGS; //No dialog is used
PDruck = printPanel(modulName,panelName,"panelOnly", options);
/* The panel "print_panel" in the current module, is printed, the print settings window is not shown
DebugN("Function successful if value=0",PDruck );
}
The following example shows how to print a panel using the printer settings window. A panel called "print_panel" will be printed in the current module.
main()
{
int panelDr;
string panelName = "print_panel";
string modulName = myModuleName();
int options = PPO_PRINTER_DIALOG; //opens the printer settings window
panelDr = printPanel (modulName,panelName,"panelOnly", ShowDialog);
DebugN("Function successful ", panelDr, modulName, panelName,options);
}
The following example prints the current panel in the current module on the default printer without special options.
main()
{
printPanel(myModuleName(), myPanelName());
}
Prints a panel from the panel topology (with naviModule, mainModule and infoModule).
#uses "pt.ctl"
main()
{
string modName;
int ModuleNumber;
string curr_mode = myModuleName();
pt_moduleNumber(curr_mode,ModuleNumber);
modName = pt_buildModuleName("mainModule", ModuleNumber);
string panelName = rootPanel(pt_buildModuleName("mainModule", ModuleNumber);
printPanel(modName,panelName);
}
Assignment
Graphics
Availability
UI