Really, this should be it, for the passing income.
[capital-apms-progress.git] / win / w-report.w
blob9d68ea6e8154480a5e16c913ac649696c91e6c30
1 &ANALYZE-SUSPEND _VERSION-NUMBER UIB_v8r12 GUI ADM1
2 &ANALYZE-RESUME
3 &Scoped-define WINDOW-NAME W-ReportViewer
4 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _DEFINITIONS W-ReportViewer
5 /*------------------------------------------------------------------------
6 File:
7 Description:
8 ------------------------------------------------------------------------*/
9 CREATE WIDGET-POOL.
11 /* Local Variable Definitions --- */
13 DEFINE STREAM prnt.
15 DEF VAR os-text-name AS CHAR NO-UNDO.
16 DEF VAR os-ctrl-name AS CHAR NO-UNDO.
18 DEF VAR save-directory AS CHAR INITIAL "C:\" NO-UNDO.
19 DEF VAR search-text AS CHAR NO-UNDO INITIAL "".
20 DEF VAR search-flags AS INT NO-UNDO INITIAL 1.
22 DEF VAR window-w AS INT NO-UNDO.
23 DEF VAR window-h AS INT NO-UNDO.
25 DEF VAR display-font AS INT INITIAL 28 NO-UNDO.
26 DEF VAR printout-font AS INT INITIAL 29 NO-UNDO.
27 DEF VAR printout-dlg AS LOGICAL INITIAL No NO-UNDO.
28 DEF VAR printout-lscp AS LOGICAL INITIAL No NO-UNDO.
29 DEF VAR printout-w32 AS LOGICAL INITIAL No NO-UNDO.
31 DEF VAR CURRENT-PRINTER-PORT AS CHAR NO-UNDO.
33 DEF VAR user-name AS CHAR NO-UNDO.
34 {inc/username.i "user-name"}
35 FIND RP WHERE RP.UserName = user-name
36 AND RP.ReportID = "Report Viewer" NO-LOCK NO-ERROR.
38 /* _UIB-CODE-BLOCK-END */
39 &ANALYZE-RESUME
42 &ANALYZE-SUSPEND _UIB-PREPROCESSOR-BLOCK
44 /* ******************** Preprocessor Definitions ******************** */
46 &Scoped-define PROCEDURE-TYPE SmartWindow
47 &Scoped-define DB-AWARE no
49 &Scoped-define ADM-CONTAINER WINDOW
51 /* Name of first Frame and/or Browse and/or first Query */
52 &Scoped-define FRAME-NAME F-Main
54 /* Standard List Definitions */
55 &Scoped-Define ENABLED-OBJECTS ed-report
56 &Scoped-Define DISPLAYED-OBJECTS ed-report
58 /* Custom List Definitions */
59 /* List-1,List-2,List-3,List-4,List-5,List-6 */
61 /* _UIB-PREPROCESSOR-BLOCK-END */
62 &ANALYZE-RESUME
66 /* *********************** Control Definitions ********************** */
68 /* Define the widget handle for the window */
69 DEFINE VAR W-ReportViewer AS WIDGET-HANDLE NO-UNDO.
71 /* Menu Definitions */
72 DEFINE SUB-MENU m_File
73 MENU-ITEM m_Save LABEL "&Save" ACCELERATOR "SHIFT-F12"
74 MENU-ITEM m_Print LABEL "&Print" ACCELERATOR "CTRL-SHIFT-F12"
75 RULE
76 MENU-ITEM m_Save_Settings LABEL "Save Se&ttings"
77 RULE
78 MENU-ITEM m_Exit LABEL "E&xit" ACCELERATOR "CTRL-F4".
80 DEFINE SUB-MENU m_Edit
81 MENU-ITEM m_Copy LABEL "&Copy" ACCELERATOR "CTRL-INS"
82 MENU-ITEM m_Select_All LABEL "Select &All" ACCELERATOR "CTRL-A"
83 MENU-ITEM m_Display_Font LABEL "Display Fo&nt" ACCELERATOR "ALT-CTRL-F"
84 MENU-ITEM m_Printout_Font LABEL "&Printout Font" ACCELERATOR "ALT-CTRL-P"
85 MENU-ITEM m_Find LABEL "&Find" ACCELERATOR "CTRL-F".
87 DEFINE SUB-MENU m_Help
88 MENU-ITEM m_Contents LABEL "&Contents"
89 RULE
90 MENU-ITEM m_About LABEL "&About" .
92 DEFINE MENU MENU-BAR-W-Win MENUBAR
93 SUB-MENU m_File LABEL "&File"
94 SUB-MENU m_Edit LABEL "&Edit"
95 SUB-MENU m_Help LABEL "&Help" .
98 /* Definitions of the field level widgets */
99 DEFINE VARIABLE ed-report AS CHARACTER
100 VIEW-AS EDITOR NO-WORD-WRAP SCROLLBAR-HORIZONTAL SCROLLBAR-VERTICAL LARGE
101 SIZE 42.29 BY 6.2
102 FONT 28 NO-UNDO.
105 /* ************************ Frame Definitions *********************** */
107 DEFINE FRAME F-Main
108 ed-report AT ROW 1 COL 1 NO-LABEL
109 WITH 1 DOWN NO-BOX KEEP-TAB-ORDER OVERLAY
110 SIDE-LABELS NO-UNDERLINE THREE-D
111 AT COL 1 ROW 1 SCROLLABLE .
114 /* *********************** Procedure Settings ************************ */
116 &ANALYZE-SUSPEND _PROCEDURE-SETTINGS
117 /* Settings for THIS-PROCEDURE
118 Type: SmartWindow
119 Allow: Basic,Browse,DB-Fields,Query,Smart,Window
120 Other Settings: COMPILE
122 &ANALYZE-RESUME _END-PROCEDURE-SETTINGS
124 /* ************************* Create Window ************************** */
126 &ANALYZE-SUSPEND _CREATE-WINDOW
127 IF SESSION:DISPLAY-TYPE = "GUI":U THEN
128 CREATE WINDOW W-ReportViewer ASSIGN
129 HIDDEN = YES
130 TITLE = "Report Viewer"
131 HEIGHT = 18.95
132 WIDTH = 89.29
133 MAX-HEIGHT = 60
134 MAX-WIDTH = 150
135 VIRTUAL-HEIGHT = 60
136 VIRTUAL-WIDTH = 150
137 RESIZE = yes
138 SCROLL-BARS = no
139 STATUS-AREA = no
140 BGCOLOR = ?
141 FGCOLOR = ?
142 THREE-D = yes
143 FONT = 33
144 MESSAGE-AREA = no
145 SENSITIVE = yes.
146 ELSE {&WINDOW-NAME} = CURRENT-WINDOW.
148 ASSIGN {&WINDOW-NAME}:MENUBAR = MENU MENU-BAR-W-Win:HANDLE.
149 /* END WINDOW DEFINITION */
150 &ANALYZE-RESUME
152 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _INCLUDED-LIB W-ReportViewer
153 /* ************************* Included-Libraries *********************** */
155 {src/adm/method/containr.i}
157 /* _UIB-CODE-BLOCK-END */
158 &ANALYZE-RESUME
163 /* *********** Runtime Attributes and AppBuilder Settings *********** */
165 &ANALYZE-SUSPEND _RUN-TIME-ATTRIBUTES
166 /* SETTINGS FOR WINDOW W-ReportViewer
167 VISIBLE,,RUN-PERSISTENT */
168 /* SETTINGS FOR FRAME F-Main
169 Size-to-Fit */
170 ASSIGN
171 FRAME F-Main:SCROLLABLE = FALSE.
173 ASSIGN
174 ed-report:AUTO-RESIZE IN FRAME F-Main = TRUE
175 ed-report:RETURN-INSERTED IN FRAME F-Main = TRUE
176 ed-report:READ-ONLY IN FRAME F-Main = TRUE.
178 IF SESSION:DISPLAY-TYPE = "GUI":U AND VALID-HANDLE(W-ReportViewer)
179 THEN W-ReportViewer:HIDDEN = yes.
181 /* _RUN-TIME-ATTRIBUTES-END */
182 &ANALYZE-RESUME
188 /* ************************ Control Triggers ************************ */
190 &Scoped-define SELF-NAME W-ReportViewer
191 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL W-ReportViewer W-ReportViewer
192 ON END-ERROR OF W-ReportViewer /* Report Viewer */
193 OR ENDKEY OF {&WINDOW-NAME} ANYWHERE DO:
194 /* This case occurs when the user presses the "Esc" key.
195 In a persistently run window, just ignore this. If we did not, the
196 application would exit. */
197 APPLY 'WINDOW-CLOSE':U TO {&WINDOW-NAME}.
198 IF THIS-PROCEDURE:PERSISTENT THEN RETURN NO-APPLY.
199 END.
201 /* _UIB-CODE-BLOCK-END */
202 &ANALYZE-RESUME
205 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL W-ReportViewer W-ReportViewer
206 ON ENTRY OF W-ReportViewer /* Report Viewer */
208 APPLY 'ENTRY':U TO ed-report IN FRAME {&FRAME-NAME}.
209 RETURN NO-APPLY.
210 END.
212 /* _UIB-CODE-BLOCK-END */
213 &ANALYZE-RESUME
216 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL W-ReportViewer W-ReportViewer
217 ON WINDOW-CLOSE OF W-ReportViewer /* Report Viewer */
219 /* This ADM code must be left here in order for the SmartWindow
220 and its descendents to terminate properly on exit. */
222 OS-DELETE VALUE( os-ctrl-name ).
223 OS-DELETE VALUE( os-text-name ).
225 APPLY "CLOSE":U TO THIS-PROCEDURE.
226 RETURN NO-APPLY.
227 END.
229 /* _UIB-CODE-BLOCK-END */
230 &ANALYZE-RESUME
233 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL W-ReportViewer W-ReportViewer
234 ON WINDOW-MAXIMIZED OF W-ReportViewer /* Report Viewer */
236 RUN resize-editor.
237 END.
239 /* _UIB-CODE-BLOCK-END */
240 &ANALYZE-RESUME
243 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL W-ReportViewer W-ReportViewer
244 ON WINDOW-RESIZED OF W-ReportViewer /* Report Viewer */
246 RUN resize-editor.
247 END.
249 /* _UIB-CODE-BLOCK-END */
250 &ANALYZE-RESUME
253 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL W-ReportViewer W-ReportViewer
254 ON WINDOW-RESTORED OF W-ReportViewer /* Report Viewer */
256 RUN resize-editor.
257 END.
259 /* _UIB-CODE-BLOCK-END */
260 &ANALYZE-RESUME
263 &Scoped-define SELF-NAME m_Copy
264 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL m_Copy W-ReportViewer
265 ON CHOOSE OF MENU-ITEM m_Copy /* Copy */
267 OUTPUT TO "CLIPBOARD":U KEEP-MESSAGES.
268 PUT UNFORMATTED ed-report:SELECTION-TEXT IN FRAME {&FRAME-NAME}.
269 OUTPUT CLOSE.
270 END.
272 /* _UIB-CODE-BLOCK-END */
273 &ANALYZE-RESUME
276 &Scoped-define SELF-NAME m_Display_Font
277 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL m_Display_Font W-ReportViewer
278 ON CHOOSE OF MENU-ITEM m_Display_Font /* Display Font */
280 RUN set-display-font.
281 END.
283 /* _UIB-CODE-BLOCK-END */
284 &ANALYZE-RESUME
287 &Scoped-define SELF-NAME m_Exit
288 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL m_Exit W-ReportViewer
289 ON CHOOSE OF MENU-ITEM m_Exit /* Exit */
291 APPLY 'WINDOW-CLOSE':U TO {&WINDOW-NAME}.
292 END.
294 /* _UIB-CODE-BLOCK-END */
295 &ANALYZE-RESUME
298 &Scoped-define SELF-NAME m_Find
299 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL m_Find W-ReportViewer
300 ON CHOOSE OF MENU-ITEM m_Find /* Find */
302 RUN find-dialog.
303 END.
305 /* _UIB-CODE-BLOCK-END */
306 &ANALYZE-RESUME
309 &Scoped-define SELF-NAME m_Print
310 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL m_Print W-ReportViewer
311 ON CHOOSE OF MENU-ITEM m_Print /* Print */
313 RUN print-report.
314 END.
316 /* _UIB-CODE-BLOCK-END */
317 &ANALYZE-RESUME
320 &Scoped-define SELF-NAME m_Printout_Font
321 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL m_Printout_Font W-ReportViewer
322 ON CHOOSE OF MENU-ITEM m_Printout_Font /* Printout Font */
324 RUN set-printout-font.
325 END.
327 /* _UIB-CODE-BLOCK-END */
328 &ANALYZE-RESUME
331 &Scoped-define SELF-NAME m_Save
332 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL m_Save W-ReportViewer
333 ON CHOOSE OF MENU-ITEM m_Save /* Save */
335 RUN save-report.
336 END.
338 /* _UIB-CODE-BLOCK-END */
339 &ANALYZE-RESUME
342 &Scoped-define SELF-NAME m_Save_Settings
343 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL m_Save_Settings W-ReportViewer
344 ON CHOOSE OF MENU-ITEM m_Save_Settings /* Save Settings */
346 RUN save-settings.
347 END.
349 /* _UIB-CODE-BLOCK-END */
350 &ANALYZE-RESUME
353 &Scoped-define SELF-NAME m_Select_All
354 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL m_Select_All W-ReportViewer
355 ON CHOOSE OF MENU-ITEM m_Select_All /* Select All */
357 IF ed-report:SET-SELECTION( 1, ed-report:LENGTH ) IN FRAME {&FRAME-NAME} THEN .
358 END.
360 /* _UIB-CODE-BLOCK-END */
361 &ANALYZE-RESUME
364 &UNDEFINE SELF-NAME
366 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _MAIN-BLOCK W-ReportViewer
369 /* *************************** Main Block *************************** */
371 /* Include custom Main Block code for SmartWindows. */
372 {src/adm/template/windowmn.i}
374 /* _UIB-CODE-BLOCK-END */
375 &ANALYZE-RESUME
378 /* ********************** Internal Procedures *********************** */
380 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE adm-create-objects W-ReportViewer _ADM-CREATE-OBJECTS
381 PROCEDURE adm-create-objects :
382 /*------------------------------------------------------------------------------
383 Purpose: Create handles for all SmartObjects used in this procedure.
384 After SmartObjects are initialized, then SmartLinks are added.
385 Parameters: <none>
386 ------------------------------------------------------------------------------*/
388 END PROCEDURE.
390 /* _UIB-CODE-BLOCK-END */
391 &ANALYZE-RESUME
393 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE adm-row-available W-ReportViewer _ADM-ROW-AVAILABLE
394 PROCEDURE adm-row-available :
395 /*------------------------------------------------------------------------------
396 Purpose: Dispatched to this procedure when the Record-
397 Source has a new row available. This procedure
398 tries to get the new row (or foriegn keys) from
399 the Record-Source and process it.
400 Parameters: <none>
401 ------------------------------------------------------------------------------*/
403 /* Define variables needed by this internal procedure. */
404 {src/adm/template/row-head.i}
406 /* Process the newly available records (i.e. display fields,
407 open queries, and/or pass records on to any RECORD-TARGETS). */
408 {src/adm/template/row-end.i}
410 END PROCEDURE.
412 /* _UIB-CODE-BLOCK-END */
413 &ANALYZE-RESUME
415 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE disable_UI W-ReportViewer _DEFAULT-DISABLE
416 PROCEDURE disable_UI :
417 /*------------------------------------------------------------------------------
418 Purpose: DISABLE the User Interface
419 Parameters: <none>
420 Notes: Here we clean-up the user-interface by deleting
421 dynamic widgets we have created and/or hide
422 frames. This procedure is usually called when
423 we are ready to "clean-up" after running.
424 ------------------------------------------------------------------------------*/
425 /* Delete the WINDOW we created */
426 IF SESSION:DISPLAY-TYPE = "GUI":U AND VALID-HANDLE(W-ReportViewer)
427 THEN DELETE WIDGET W-ReportViewer.
428 IF THIS-PROCEDURE:PERSISTENT THEN DELETE PROCEDURE THIS-PROCEDURE.
429 END PROCEDURE.
431 /* _UIB-CODE-BLOCK-END */
432 &ANALYZE-RESUME
434 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE enable_UI W-ReportViewer _DEFAULT-ENABLE
435 PROCEDURE enable_UI :
436 /*------------------------------------------------------------------------------
437 Purpose: ENABLE the User Interface
438 Parameters: <none>
439 Notes: Here we display/view/enable the widgets in the
440 user-interface. In addition, OPEN all queries
441 associated with each FRAME and BROWSE.
442 These statements here are based on the "Other
443 Settings" section of the widget Property Sheets.
444 ------------------------------------------------------------------------------*/
445 DISPLAY ed-report
446 WITH FRAME F-Main IN WINDOW W-ReportViewer.
447 ENABLE ed-report
448 WITH FRAME F-Main IN WINDOW W-ReportViewer.
449 {&OPEN-BROWSERS-IN-QUERY-F-Main}
450 VIEW W-ReportViewer.
451 END PROCEDURE.
453 /* _UIB-CODE-BLOCK-END */
454 &ANALYZE-RESUME
456 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE find-dialog W-ReportViewer
457 PROCEDURE find-dialog :
458 /*------------------------------------------------------------------------------
459 Purpose:
460 ------------------------------------------------------------------------------*/
461 DEF VAR search-flags AS INT NO-UNDO INITIAL 33.
463 RUN win/d-find.w( INPUT-OUTPUT search-text, INPUT-OUTPUT search-flags ).
465 IF search-flags < 1 THEN
466 search-flags = ABS( search-flags ).
467 ELSE IF NOT( ed-report:SEARCH( search-text, search-flags ) IN FRAME {&FRAME-NAME} ) THEN
468 MESSAGE "'" + search-text + "' not found." VIEW-AS ALERT-BOX INFORMATION
469 TITLE "Search text not found" .
471 END PROCEDURE.
473 /* _UIB-CODE-BLOCK-END */
474 &ANALYZE-RESUME
476 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE get-current-printer W-ReportViewer
477 PROCEDURE get-current-printer :
478 /*------------------------------------------------------------------------------
479 Purpose: Set the value of CURRENT-PRINTER-??? to reflect the current windows
480 printer.
481 ------------------------------------------------------------------------------*/
482 DEF VAR CURRENT-PRINTER-NAME AS CHAR NO-UNDO.
484 /* Set the value of the port ( more robust than printer name for batches ) */
486 DEF BUFFER CurrPrinter FOR RP.
487 DEF VAR user-name AS CHAR NO-UNDO.
488 {inc/username.i "user-name"}
490 FIND FIRST CurrPrinter WHERE
491 CurrPrinter.UserName = user-name AND
492 CurrPrinter.ReportID = "Current Printer" NO-LOCK NO-ERROR.
494 IF NOT AVAILABLE CurrPrinter THEN
496 DEF VAR success AS LOGI NO-UNDO.
497 RUN aderb/_prdef.p ( OUTPUT CURRENT-PRINTER-NAME, OUTPUT CURRENT-PRINTER-PORT, OUTPUT success ).
499 CREATE CurrPrinter.
500 ASSIGN
501 CurrPrinter.UserName = user-name
502 CurrPrinter.ReportID = "Current Printer"
503 CurrPrinter.Char1 = CURRENT-PRINTER-NAME
504 CurrPrinter.Char2 = CURRENT-PRINTER-PORT.
505 END.
507 CURRENT-PRINTER-NAME = CurrPrinter.Char1.
508 CURRENT-PRINTER-PORT = CurrPrinter.Char2.
510 RELEASE CurrPrinter.
512 END PROCEDURE.
514 /* _UIB-CODE-BLOCK-END */
515 &ANALYZE-RESUME
517 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE load-editor W-ReportViewer
518 PROCEDURE load-editor :
519 /*------------------------------------------------------------------------------
520 Purpose: Load the editor widget from a file
521 ------------------------------------------------------------------------------*/
522 DEF INPUT PARAM text-file-name AS CHAR NO-UNDO.
523 DEF INPUT PARAM ctrl-file-name AS CHAR NO-UNDO.
524 DEF VAR success AS LOGICAL NO-UNDO.
526 IF SESSION:SET-WAIT-STATE("GENERAL") THEN .
527 ASSIGN
528 os-text-name = text-file-name
529 os-ctrl-name = ctrl-file-name
530 success = ed-report:READ-FILE( text-file-name ) IN FRAME {&FRAME-NAME}
533 IF SESSION:SET-WAIT-STATE("") THEN .
534 APPLY 'ENTRY':U TO {&WINDOW-NAME}.
536 END PROCEDURE.
538 /* _UIB-CODE-BLOCK-END */
539 &ANALYZE-RESUME
541 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE local-exit W-ReportViewer
542 PROCEDURE local-exit :
543 /* -----------------------------------------------------------
544 Purpose: Starts an "exit" by APPLYing CLOSE event, which starts "destroy".
545 Notes: If activated, should APPLY CLOSE, *not* dispatch adm-exit.
546 -------------------------------------------------------------*/
548 OS-DELETE VALUE( os-ctrl-name ).
549 OS-DELETE VALUE( os-text-name ).
551 APPLY "CLOSE":U TO THIS-PROCEDURE.
553 RETURN.
555 END PROCEDURE.
557 /* _UIB-CODE-BLOCK-END */
558 &ANALYZE-RESUME
560 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE local-initialize W-ReportViewer
561 PROCEDURE local-initialize :
562 /*------------------------------------------------------------------------------
563 Purpose: Override standard ADM method
564 Notes:
565 ------------------------------------------------------------------------------*/
567 /* Code placed here will execute PRIOR to standard behavior. */
568 {inc/username.i "user-name"}
569 FIND RP WHERE RP.UserName = user-name
570 AND RP.ReportID = "Report Viewer" NO-LOCK NO-ERROR.
571 IF AVAILABLE(RP) THEN DO:
572 window-w = (IF RP.Int1 > 200 THEN RP.Int1 ELSE ((SESSION:WIDTH-PIXELS * 4) / 5)).
573 window-h = (IF RP.Int2 > 200 THEN RP.Int2 ELSE ((SESSION:HEIGHT-PIXELS * 4) / 5)).
575 ASSIGN
576 {&WINDOW-NAME}:VIRTUAL-WIDTH-PIXELS = window-w + 50
577 {&WINDOW-NAME}:VIRTUAL-HEIGHT-PIXELS = window-h + 50
578 {&WINDOW-NAME}:WIDTH-PIXELS = window-w
579 {&WINDOW-NAME}:HEIGHT-PIXELS = window-h
580 save-directory = RP.Char1
581 search-text = RP.Char2
582 search-flags = RP.Int3
584 END.
585 RUN resize-editor.
587 /* Dispatch standard ADM method. */
588 RUN dispatch IN THIS-PROCEDURE ( INPUT 'initialize':U ) .
590 /* Code placed here will execute AFTER standard behavior. */
592 END PROCEDURE.
594 /* _UIB-CODE-BLOCK-END */
595 &ANALYZE-RESUME
597 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE print-report W-ReportViewer
598 PROCEDURE print-report :
599 /*------------------------------------------------------------------------------
600 Purpose: Print the report and close the window
601 ------------------------------------------------------------------------------*/
602 IF printout-w32 THEN DO:
603 DEF VAR success AS INT INITIAL 0 NO-UNDO.
604 DEF VAR lsuccess AS LOGICAL INITIAL No NO-UNDO.
605 DEF VAR pr-flags AS INT NO-UNDO.
607 pr-flags = (IF printout-dlg THEN 1 ELSE 0)
608 + (IF printout-lscp THEN 2 ELSE 0).
610 RUN adecomm/_osprint.p ( {&WINDOW-NAME}:HANDLE, os-text-name, printout-font,
611 pr-flags, 0, 0, OUTPUT lsuccess ).
613 END.
614 ELSE DO:
615 DEF VAR dir-name AS CHAR NO-UNDO.
616 DEF VAR control-name AS CHAR NO-UNDO.
617 DEF VAR print-name AS CHAR NO-UNDO.
618 DEF VAR cmd AS CHAR NO-UNDO.
620 RUN get-current-printer.
622 dir-name = SUBSTRING( os-text-name, 1, R-INDEX(os-text-name, "\") ).
623 control-name = SUBSTRING( os-ctrl-name, R-INDEX(os-ctrl-name, "\") + 1 ).
624 print-name = SUBSTRING( os-text-name, R-INDEX(os-text-name, "\") + 1 ).
625 cmd = "PP " + CURRENT-PRINTER-PORT + " " + dir-name + " " + control-name + " " + print-name.
626 OS-COMMAND SILENT VALUE( cmd ).
627 END.
629 APPLY 'WINDOW-CLOSE':U TO {&WINDOW-NAME}.
631 END PROCEDURE.
633 /* _UIB-CODE-BLOCK-END */
634 &ANALYZE-RESUME
636 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE resize-editor W-ReportViewer
637 PROCEDURE resize-editor :
638 /*------------------------------------------------------------------------------
639 Purpose: Resize the editor widget to match the window size
640 ------------------------------------------------------------------------------*/
641 DO WITH FRAME {&FRAME-NAME}:
644 * The error-free order of assignment depends on whether the window
645 * size is increasing or diminishing in each direction.
647 IF {&WINDOW-NAME}:WIDTH-PIXELS > ed-report:WIDTH-PIXELS THEN ASSIGN
648 FRAME {&FRAME-NAME}:WIDTH-PIXELS = {&WINDOW-NAME}:WIDTH-PIXELS + 8
649 ed-report:WIDTH-PIXELS = {&WINDOW-NAME}:WIDTH-PIXELS.
650 ELSE ASSIGN
651 ed-report:WIDTH-PIXELS = {&WINDOW-NAME}:WIDTH-PIXELS
652 FRAME {&FRAME-NAME}:WIDTH-PIXELS = {&WINDOW-NAME}:WIDTH-PIXELS + 8.
654 IF {&WINDOW-NAME}:HEIGHT-PIXELS > ed-report:HEIGHT-PIXELS THEN ASSIGN
655 FRAME {&FRAME-NAME}:HEIGHT-PIXELS = {&WINDOW-NAME}:HEIGHT-PIXELS + 8
656 ed-report:HEIGHT-PIXELS = {&WINDOW-NAME}:HEIGHT-PIXELS.
657 ELSE ASSIGN
658 ed-report:HEIGHT-PIXELS = {&WINDOW-NAME}:HEIGHT-PIXELS
659 FRAME {&FRAME-NAME}:HEIGHT-PIXELS = {&WINDOW-NAME}:HEIGHT-PIXELS + 8.
660 END.
661 END PROCEDURE.
663 /* _UIB-CODE-BLOCK-END */
664 &ANALYZE-RESUME
666 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE save-report W-ReportViewer
667 PROCEDURE save-report :
668 /*------------------------------------------------------------------------------
669 Purpose: Save the report to a file and close the window
670 ------------------------------------------------------------------------------*/
671 DEF VAR cmd-line AS CHAR NO-UNDO.
672 DEF VAR new-file-name AS CHAR NO-UNDO.
673 DEF VAR dialog-ok AS LOGI INITIAL Yes NO-UNDO.
676 SYSTEM-DIALOG GET-FILE new-file-name FILTERS "Text files" "*.TXT"
677 INITIAL-FILTER 1 ASK-OVERWRITE CREATE-TEST-FILE
678 DEFAULT-EXTENSION ".TXT" INITIAL-DIR save-directory
679 SAVE-AS RETURN-TO-START-DIR UPDATE dialog-ok.
681 IF dialog-ok THEN DO:
682 OS-COPY VALUE( os-text-name ) VALUE( new-file-name ).
683 MESSAGE '"' + new-file-name + '" saved.' VIEW-AS ALERT-BOX INFORMATION
684 TITLE "Report Viewer Action".
686 save-directory = SUBSTRING( new-file-name, 1, R-INDEX( new-file-name, "\")).
687 RUN save-settings.
688 END.
690 END PROCEDURE.
692 /* _UIB-CODE-BLOCK-END */
693 &ANALYZE-RESUME
695 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE save-settings W-ReportViewer
696 PROCEDURE save-settings :
697 /*------------------------------------------------------------------------------
698 Purpose: Save current settings of the window (x, y, save directory ).
699 ------------------------------------------------------------------------------*/
700 DEF VAR user-name AS CHAR NO-UNDO.
701 DEF VAR DisplayFontString AS CHAR FORMAT "x(128)" NO-UNDO.
702 DEF VAR PrinterFontString AS CHAR FORMAT "x(128)" NO-UNDO.
704 PUT-KEY-VALUE FONT display-font NO-ERROR.
705 PUT-KEY-VALUE FONT printout-font NO-ERROR.
706 GET-KEY-VALUE SECTION "Fonts" KEY "Font28" VALUE DisplayFontString.
707 GET-KEY-VALUE SECTION "Fonts" KEY "Font29" VALUE PrinterFontString.
709 {inc/username.i "user-name"}
710 DO TRANSACTION:
711 FIND RP WHERE RP.UserName = user-name
712 AND RP.ReportID = "Report Viewer" EXCLUSIVE-LOCK NO-ERROR.
713 IF NOT AVAILABLE(RP) THEN CREATE RP.
714 ASSIGN window-w = {&WINDOW-NAME}:WIDTH-PIXELS
715 window-h = {&WINDOW-NAME}:HEIGHT-PIXELS.
716 ASSIGN
717 RP.UserName = user-name
718 RP.ReportID = "Report Viewer"
719 RP.Int1 = window-w
720 RP.Int2 = window-h
721 RP.Char1 = save-directory
722 RP.Char2 = search-text
723 RP.Int3 = search-flags
724 RP.Char3 = DisplayFontString
725 RP.Char4 = PrinterFontString
727 END.
729 END PROCEDURE.
731 /* _UIB-CODE-BLOCK-END */
732 &ANALYZE-RESUME
734 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE send-records W-ReportViewer _ADM-SEND-RECORDS
735 PROCEDURE send-records :
736 /*------------------------------------------------------------------------------
737 Purpose: Send record ROWID's for all tables used by
738 this file.
739 Parameters: see template/snd-head.i
740 ------------------------------------------------------------------------------*/
742 /* SEND-RECORDS does nothing because there are no External
743 Tables specified for this SmartWindow, and there are no
744 tables specified in any contained Browse, Query, or Frame. */
746 END PROCEDURE.
748 /* _UIB-CODE-BLOCK-END */
749 &ANALYZE-RESUME
751 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE set-display-font W-ReportViewer
752 PROCEDURE set-display-font :
753 /*------------------------------------------------------------------------------
754 Purpose: Set the font used in the editor window
755 ------------------------------------------------------------------------------*/
756 DEF VAR dialog-ok AS LOGI INITIAL Yes NO-UNDO.
758 SYSTEM-DIALOG FONT display-font FIXED-ONLY MAX-SIZE 14 MIN-SIZE 6 UPDATE dialog-ok.
760 IF dialog-ok THEN DO:
761 ed-report:FONT IN FRAME {&FRAME-NAME} = display-font.
762 END.
764 END PROCEDURE.
766 /* _UIB-CODE-BLOCK-END */
767 &ANALYZE-RESUME
769 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE set-print-details W-ReportViewer
770 PROCEDURE set-print-details :
771 /*------------------------------------------------------------------------------
772 Purpose:
773 ------------------------------------------------------------------------------*/
774 DEF INPUT PARAMETER font-num AS INTEGER NO-UNDO.
775 DEF INPUT PARAMETER landscape AS LOGICAL NO-UNDO.
776 DEF INPUT PARAMETER show-dialog AS LOGICAL NO-UNDO.
778 ASSIGN
779 printout-font = (IF font-num <> ? THEN font-num ELSE printout-font)
780 printout-lscp = landscape
781 printout-dlg = show-dialog
782 printout-w32 = Yes
785 END PROCEDURE.
787 /* _UIB-CODE-BLOCK-END */
788 &ANALYZE-RESUME
790 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE set-printout-font W-ReportViewer
791 PROCEDURE set-printout-font :
792 /*------------------------------------------------------------------------------
793 Purpose: Set the font used in the editor window
794 ------------------------------------------------------------------------------*/
796 SYSTEM-DIALOG FONT printout-font FIXED-ONLY MAX-SIZE 14 MIN-SIZE 5.
798 END PROCEDURE.
800 /* _UIB-CODE-BLOCK-END */
801 &ANALYZE-RESUME
803 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE set-title W-ReportViewer
804 PROCEDURE set-title :
805 /*------------------------------------------------------------------------------
806 Purpose: Set the subsidiary title of the viewer
807 ------------------------------------------------------------------------------*/
808 DEF INPUT PARAMETER title-text AS CHAR NO-UNDO.
810 {&WINDOW-NAME}:TITLE = "Report Viewer - " + title-text + " - " + STRING( TIME, "HH:MM:SS").
811 APPLY 'ENTRY':U TO ed-report IN FRAME {&FRAME-NAME}.
812 END PROCEDURE.
814 /* _UIB-CODE-BLOCK-END */
815 &ANALYZE-RESUME
817 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE state-changed W-ReportViewer
818 PROCEDURE state-changed :
819 /* -----------------------------------------------------------
820 Purpose:
821 Parameters: <none>
822 Notes:
823 -------------------------------------------------------------*/
824 DEFINE INPUT PARAMETER p-issuer-hdl AS HANDLE NO-UNDO.
825 DEFINE INPUT PARAMETER p-state AS CHARACTER NO-UNDO.
826 END PROCEDURE.
828 /* _UIB-CODE-BLOCK-END */
829 &ANALYZE-RESUME