Module Dfwinrpt.pkg
1//****************************************************************************//
2// //
3// $File name : DFWINRPT.PKG //
4// $File title : Report_Object for Windows //
5// Notice : Copyright (c) ADB-UTVECKLING AB 1997 //
6// $Author : Janne Wassberg //
7// $System : WinPrint //
8// Created : 96-02-09 @ 16.27.20 //
9// $Last Rev : 96-07-09 @ 12.57.00 //
10// //
11// $Description //
12// //
13// //
14// $Rev History //
15// 12/15/96 JJT - Modifications to adhere to VDF printing framework //
16// Now named WinReport. //
17// 96-02-09 File header created //
18// //
19//****************************************************************************//
20
21
22
23//****************************************************************************//
24// //
25// $Module type: CLASS //
26// $Module name: WinReport //
27// $Author : Janne Wassberg //
28// Created : 96-02-09 @ 16.28.13 //
29// //
30// Description This is a sub class of Report_Object written by JT. //
31// //
32// //
33// $Rev History //
34// 97-01-15 JW - Fixed a bug in Starting_Main_Report.A ";" was missing //
35// 96-12-17 JJT - Changed to WinReport for VDF //
36// 96-02-09 Module header created //
37// //
38//****************************************************************************//
39
40//
41// Report_DS
42// BasicReport
43// WinReport
44//
45
46Use DFRpt.pkg // WinReport RO Class for VDF //JT
47Use DF_Print.pkg // WinPrint object/DLL support.
48Use DFRepKy.pkg // Key interrupt process (cancel, continue, preview) //JT
49
50{ HelpTopic=WinReport }
51Class WinReport is a BasicReport //JT
52
53 Procedure Construct_Object
54 Forward send construct_object
55
56 Date Today
57 Sysdate Today
58
59 Property Date RptToday Today
60
61 Object RptTotal is an Array
62 End_Object
63
64 //JT
65 // If true, report is output upon completion. Either preview
66 // or printer depending on output_device_mode
67 { Category=Report }
68 { PropertyType=Boolean }
69 Property Integer AutoOutput_State True
70
71 //JT
72 // When a new page is created (DFNew_Page) and the number
73 // of columns is not passed, this is used.
74 { Category=Report }
75 Property Integer Print_Columns 0
76
77 //JT
78 // This determines if a DFNew_Page should be executed when the
79 // report starts. In some rare cases, you would not want this to
80 // occur until a subheader
81 { Category=Report }
82 Property Integer AutoNew_Page_State True
83
84 //JT
85 // Output device (print or preview). Normally this is delegated to
86 // the report view.
87 //
88 { Visibility=Private }
89 Property Integer Private.Output_Device_Mode PRINT_TO_UNDEFINED
90 End_Procedure
91
92 //*** JT - Note that RptTotal_1-10 and Add_RptTotal an
93 //*** clr_rpttotal have been removed.
94
95
96 //*** JT - All subtotal commands have been modified so that they
97 //*** use the outer main report. This makes it easier to keep
98 //*** track of these numbers
99
100 Procedure Add_SubTotal Integer iCounter Number nData
101 Number nValue
102 Integer iObj
103 Move (RptTotal(Main_Report_Id(Self))) to iObj
104 Get Number_Value of iObj Item iCounter To nValue
105 Add nData To nValue
106 Set Array_Value of iObj Item iCounter To nValue
107 End_Procedure
108
109 Procedure Clr_SubTotal Integer iCounter
110 Set Array_Value of (RptTotal(Main_Report_Id(Self))) Item iCounter To 0
111 End_Procedure
112
113 Procedure Clr_AllSubTotals
114 Send Delete_Data to (RptTotal(Main_Report_Id(Self)))
115 End_Procedure
116
117 Function Sum_SubTotal Integer iTotal Returns Number
118 Number nRetVal
119 Get Number_Value of (RptTotal(Main_Report_Id(Self))) Item iTotal To nRetVal
120 Function_Return nRetVal
121 End_Function
122
123 //JT
124 //Return sub-total and clear accumulator
125 //
126 Function SubTotal Integer iTotal Returns Number
127 Number nRetVal
128 Get Sum_SubTotal iTotal to nRetVal
129 Send Clr_SubTotal iTotal
130 Function_Return nRetVal
131 End_Function
132
133
134 // Note: Cols is optional. If no argument is passed it will use
135 // the object's property Print_Columns (0 by default)
136 //
137 Procedure DFNew_Page Integer Cols
138 Integer PageNumber Columns
139 // JT
140 // If no args passed used default setting
141 If Num_Arguments eq 0 ;
142 Move (Print_Columns(Main_Report_id(Self))) to Columns
143 Else ;
144 Move Cols to Columns
145 Set Page_Feed to -2 // No FormFeed
146 If (Child_Rpt_State(self)) ;
147 Send DFNew_Page to (Main_Report_Id(Self)) Columns
148 Else Begin
149 Get DFNewPage of WinPrintId Columns To PageNumber
150 Set No_PageCheck_State to True
151
152 //Top section
153 Send Page_Top
154 If PageNumber eq 1 Send Report_Header
155 //JW 1997-04-18
156 Send Page_Header
157 Send Page_Title
158
159 Set New_Page_State to False
160 Set No_PageCheck_State to False // No longer Paging
161 End
162
163 //*** Footer section
164 //***
165 //*** DO NOT CHANGE THE ORDER OF BOTTOM SECTIONS !!!!!
166 //***
167
168 Send Page_Bottom
169
170 //*** in WinPrint it is not possible to replace Page_Footer
171 //*** with Report_Footer. If you use Report_Footer you will
172 //*** have both Page_Footer and Report_Footer
173 //***
174 //If LastTime eq 0 Send Page_Footer
175 //else Send Report_Footer
176
177 Send Page_Footer
178 Send Page_Total
179 End_Procedure
180
181 { MethodType=Event NoDoc=True }
182 Procedure Ending_Main_Report
183 Forward Send Ending_Main_Report
184 Send Report_Footer
185 // If auto-output and not canceled, print the report (could be
186 // output to printer or preview).
187 If (AutoOutput_State(Self) AND Cancelled_State(Self)=0) ; //JT
188 Send PrintReport
189 End_Procedure
190
191 //JT
192 // This uses a popup object which allows the user to cancel the report
193 // continue, or, preview current report (At which point they can still
194 // cancel or continue).
195 //
196 { MethodType=Event }
197 Function Report_Interrupt Returns Integer
198 integer iRetVal iObj
199 Move self to iObj
200 Get Halt_report of (DfPrint_Cancel_Rpt(Self)) iObj to iRetVal
201 Function_Return iRetVal
202 End_Function
203
204 //JT
205 // Does a Winprint appropriate initialize
206 // 1. Clear the DC
207 // 2. Zero DF Counters
208 //
209 { Visibility=Private }
210 Procedure Initialize_WinPrint
211 //*** Clear the DC before each report
212 Send DFClearDoc to WinPrintID
213 //You MUST always start a new report with this procedure
214 send DFZeroCounters to WinPrintID
215 End_procedure
216
217 //JT
218 // Augmented to clear subtotals before starting and do a first page
219 //
220 { MethodType=Event NoDoc=True }
221 Function Starting_Main_Report returns integer
222 integer rVal
223 Send Clr_AllSubTotals
224 Send Initialize_WinPrint
225 Forward Get Starting_Main_Report to rVal
226 If (rVal=0 AND AutoNew_Page_State(self)) ; // Added this semicolon...Works better with it... /DL 970115
227 Send DFNew_page
228 Function_Return rVal
229 End_Function
230
231 //JT
232 // Cancel RO behavior - there is no device to close
233 //
234 { Visibility=Private }
235 Procedure Close_Output_Device
236 End_Procedure
237
238 //JT
239 // Cancel RO Behavior
240 //
241 { Visibility=Private }
242 Procedure Initialize_Output_Device
243 End_procedure
244
245
246 //JT
247 // Ask WinPrint to print the report to printer
248 //
249 { Visibility=Private }
250 Procedure DFPrint
251 Send DFPrint to WinPrintID
252 End_procedure
253
254 // DL on 1997-02-10 17:17:
255 //
256 { Visibility=Private }
257 Procedure DFPrintDoc
258 Send DFPrintDoc To WinPrintID
259 End_Procedure
260
261 //JT
262 // Ask WinPrint to preview the report
263 //
264 { Visibility=Private }
265 Procedure DFPreview
266 Send DFPreview to WinPrintID
267 End_Procedure
268
269 //JT
270 // Ask WinPrint to pop up the priner setup dialog
271 //
272 { Visibility=Private }
273 Procedure DFPrintSetup
274 Send DFPrintSetup to WinPrintID
275 End_procedure
276
277 { MethodType=Property }
278 Function Output_Device_Mode Returns Integer
279 Integer Id
280 String DevMode
281 Get Private.Output_Device_Mode to DevMode
282 If DevMode eq PRINT_TO_UNDEFINED Begin
283 Get Report_View_Id to Id
284 If ID ;
285 Get OutPut_Device_Mode of ID to DevMode
286 If DevMode eq PRINT_TO_UNDEFINED ;
287 Move PRINT_TO_WINDOW to DevMode
288 End
289 Function_Return DevMode
290 End_Function // Output_Destination
291
292 { MethodType=Property }
293 { Category=Report }
294 Procedure Set Output_Device_Mode Integer DevMode
295 Set Private.Output_Device_Mode to DevMode
296 End_Procedure // Set Output_Device
297
298 //JT
299 // Print report to appropriate device (printer, preview) based
300 // on output_device_mode
301 //SF 21/8 97 - Switched order of Else If/Else
302 //
303 Procedure PrintReport
304 Integer Mode
305 Get OutPut_Device_Mode to Mode
306 If Mode EQ PRINT_TO_WINDOW ;
307 Send DFPreview
308 Else If Mode Eq PRINT_TO_PRINTER_NO_DIALOG ;
309 Send DFPrintDoc
310 Else;
311 Send DFPrint
312 End_Procedure
313
314 // displays a metric ruler in .5 increments. This can be
315 // sent to make it easy to see how fields and labels should
316 // be moved for alignment.
317 //
318 Procedure ShowRuler
319 integer i
320 number n
321 for i from 0 to 30
322 DfWritePos (String(i))i
323 Move (i+.5) to n
324 DfWritePos "." n
325 Loop
326 DFWriteLn ''
327 End_procedure
328
329End_Class
330