File: w_report_options.srw
Size: 18614
Date: Tue, 22 Aug 2017 17:30:58 +0200
$PBExportHeader$w_report_options.srw
$PBExportComments$This window is for the number of reports and the orientation of the report to be printed.
forward
global type w_report_options from window
end type
type dw_printerinfo from datawindow within w_report_options
end type
type ddlb_printrange from dropdownlistbox within w_report_options
end type
type st_9 from statictext within w_report_options
end type
type ddlb_orientation from dropdownlistbox within w_report_options
end type
type st_8 from statictext within w_report_options
end type
type cb_options from commandbutton within w_report_options
end type
type em_copies from editmask within w_report_options
end type
type st_7 from statictext within w_report_options
end type
type st_6 from statictext within w_report_options
end type
type st_5 from statictext within w_report_options
end type
type sle_pages from singlelineedit within w_report_options
end type
type st_4 from statictext within w_report_options
end type
type em_thru from editmask within w_report_options
end type
type em_from from editmask within w_report_options
end type
type rb_pages from radiobutton within w_report_options
end type
type rb_range from radiobutton within w_report_options
end type
type rb_all from radiobutton within w_report_options
end type
type cb_printer from commandbutton within w_report_options
end type
type cb_ok from commandbutton within w_report_options
end type
type cb_cancel from commandbutton within w_report_options
end type
type gb_3 from groupbox within w_report_options
end type
type gb_2 from groupbox within w_report_options
end type
type gb_1 from groupbox within w_report_options
end type
end forward

global type w_report_options from window
integer x = 411
integer y = 416
integer width = 2094
integer height = 1136
boolean titlebar = true
string title = "Print Options"
windowtype windowtype = response!
long backcolor = 79741120
dw_printerinfo dw_printerinfo
ddlb_printrange ddlb_printrange
st_9 st_9
ddlb_orientation ddlb_orientation
st_8 st_8
cb_options cb_options
em_copies em_copies
st_7 st_7
st_6 st_6
st_5 st_5
sle_pages sle_pages
st_4 st_4
em_thru em_thru
em_from em_from
rb_pages rb_pages
rb_range rb_range
rb_all rb_all
cb_printer cb_printer
cb_ok cb_ok
cb_cancel cb_cancel
gb_3 gb_3
gb_2 gb_2
gb_1 gb_1
end type
global w_report_options w_report_options

type variables
s_print_options istr_opt
Environment ie_env
Datawindow idw_datawindow
end variables

forward prototypes
public subroutine wf_defaults ()
public subroutine wf_printer_info ()
end prototypes

public subroutine wf_defaults ();Long ll_property

// set the orientation
ll_property = Long(idw_datawindow.Describe("DataWindow.Print.Orientation"))
CHOOSE CASE ll_property
   CASE 1
      ddlb_orientation.SelectItem(2)
   CASE 2
      ddlb_orientation.SelectItem(3)
   CASE ELSE
      ddlb_orientation.SelectItem(1)
END CHOOSE

end subroutine

public subroutine wf_printer_info ();String ls_printerinfo

ls_printerinfo = PrintGetPrinter()

dw_printerinfo.Reset()
dw_printerinfo.ImportString(ls_printerinfo)

rb_all.checked = True
rb_all.Event Clicked()

end subroutine

event open;Integer li_width, li_height

// get the passed datawindow so it can be modified
idw_datawindow = Message.PowerObjectParm

GetEnvironment(ie_env)

// calculate screen width/height in PBU's
li_width = PixelsToUnits(ie_env.ScreenWidth, XPixelsToUnits!)
li_height = PixelsToUnits(ie_env.ScreenHeight, YPixelsToUnits!)

// center the window 
This.x = (li_width / 2) - (This.width / 2)
This.y = (li_height / 2) - (This.height / 2)

// get printer info
wf_printer_info()

// get datawindow defaults
wf_defaults()

end event

on w_report_options.create
this.dw_printerinfo=create dw_printerinfo
this.ddlb_printrange=create ddlb_printrange
this.st_9=create st_9
this.ddlb_orientation=create ddlb_orientation
this.st_8=create st_8
this.cb_options=create cb_options
this.em_copies=create em_copies
this.st_7=create st_7
this.st_6=create st_6
this.st_5=create st_5
this.sle_pages=create sle_pages
this.st_4=create st_4
this.em_thru=create em_thru
this.em_from=create em_from
this.rb_pages=create rb_pages
this.rb_range=create rb_range
this.rb_all=create rb_all
this.cb_printer=create cb_printer
this.cb_ok=create cb_ok
this.cb_cancel=create cb_cancel
this.gb_3=create gb_3
this.gb_2=create gb_2
this.gb_1=create gb_1
this.Control[]={this.dw_printerinfo,&
this.ddlb_printrange,&
this.st_9,&
this.ddlb_orientation,&
this.st_8,&
this.cb_options,&
this.em_copies,&
this.st_7,&
this.st_6,&
this.st_5,&
this.sle_pages,&
this.st_4,&
this.em_thru,&
this.em_from,&
this.rb_pages,&
this.rb_range,&
this.rb_all,&
this.cb_printer,&
this.cb_ok,&
this.cb_cancel,&
this.gb_3,&
this.gb_2,&
this.gb_1}
end on

on w_report_options.destroy
destroy(this.dw_printerinfo)
destroy(this.ddlb_printrange)
destroy(this.st_9)
destroy(this.ddlb_orientation)
destroy(this.st_8)
destroy(this.cb_options)
destroy(this.em_copies)
destroy(this.st_7)
destroy(this.st_6)
destroy(this.st_5)
destroy(this.sle_pages)
destroy(this.st_4)
destroy(this.em_thru)
destroy(this.em_from)
destroy(this.rb_pages)
destroy(this.rb_range)
destroy(this.rb_all)
destroy(this.cb_printer)
destroy(this.cb_ok)
destroy(this.cb_cancel)
destroy(this.gb_3)
destroy(this.gb_2)
destroy(this.gb_1)
end on

type dw_printerinfo from datawindow within w_report_options
integer x = 96
integer y = 80
integer width = 1417
integer height = 108
integer taborder = 10
string title = "none"
string dataobject = "d_printerinfo"
boolean border = false
end type

type ddlb_printrange from dropdownlistbox within w_report_options
integer x = 1257
integer y = 716
integer width = 544
integer height = 272
integer taborder = 70
integer textsize = -8
integer weight = 400
fontpitch fontpitch = variable!
fontfamily fontfamily = swiss!
string facename = "MS Sans Serif"
long textcolor = 33554432
boolean sorted = false
boolean vscrollbar = true
string item[] = {"All pages in range","Odd pages","Even pages"}
borderstyle borderstyle = stylelowered!
end type

event constructor;this.SelectItem(1)

end event

type st_9 from statictext within w_report_options
integer x = 1257
integer y = 652
integer width = 155
integer height = 64
integer textsize = -8
integer weight = 700
fontpitch fontpitch = variable!
fontfamily fontfamily = swiss!
string facename = "MS Sans Serif"
long textcolor = 33554432
long backcolor = 67108864
boolean enabled = false
string text = "Print:"
boolean focusrectangle = false
end type

type ddlb_orientation from dropdownlistbox within w_report_options
integer x = 1257
integer y = 524
integer width = 375
integer height = 272
integer taborder = 60
integer textsize = -8
integer weight = 400
fontpitch fontpitch = variable!
fontfamily fontfamily = swiss!
string facename = "MS Sans Serif"
long textcolor = 33554432
boolean sorted = false
boolean vscrollbar = true
string item[] = {"Default","Landscape","Portrait"}
borderstyle borderstyle = stylelowered!
end type

type st_8 from statictext within w_report_options
integer x = 1257
integer y = 460
integer width = 320
integer height = 64
integer textsize = -8
integer weight = 700
fontpitch fontpitch = variable!
fontfamily fontfamily = swiss!
string facename = "MS Sans Serif"
long textcolor = 33554432
long backcolor = 67108864
boolean enabled = false
string text = "Orientation:"
boolean focusrectangle = false
end type

type cb_options from commandbutton within w_report_options
integer x = 37
integer y = 896
integer width = 407
integer height = 100
integer taborder = 80
integer textsize = -8
integer weight = 700
fontpitch fontpitch = variable!
fontfamily fontfamily = swiss!
string facename = "MS Sans Serif"
string text = "Options..."
end type

event clicked;String ls_property, ls_rtn

SetPointer(HourGlass!)

// open print option window
OpenWithParm(w_print_options, idw_datawindow)

// get changes made by other window
istr_opt = Message.PowerObjectParm

end event

type em_copies from editmask within w_report_options
integer x = 1755
integer y = 352
integer width = 201
integer height = 84
integer taborder = 50
integer textsize = -8
integer weight = 700
fontpitch fontpitch = variable!
fontfamily fontfamily = swiss!
string facename = "MS Sans Serif"
long textcolor = 33554432
string text = "1"
borderstyle borderstyle = stylelowered!
string mask = "##"
boolean spin = true
string displaydata = "~r"
string minmax = "1~~99"
end type

type st_7 from statictext within w_report_options
integer x = 1257
integer y = 360
integer width = 489
integer height = 64
integer textsize = -8
integer weight = 700
fontpitch fontpitch = variable!
fontfamily fontfamily = swiss!
string facename = "MS Sans Serif"
long textcolor = 33554432
long backcolor = 67108864
boolean enabled = false
string text = "Number of copies:"
boolean focusrectangle = false
end type

type st_6 from statictext within w_report_options
integer x = 434
integer y = 448
integer width = 160
integer height = 64
integer textsize = -8
integer weight = 700
fontpitch fontpitch = variable!
fontfamily fontfamily = swiss!
string facename = "MS Sans Serif"
long textcolor = 33554432
long backcolor = 67108864
boolean enabled = false
string text = "from:"
alignment alignment = right!
boolean focusrectangle = false
end type

type st_5 from statictext within w_report_options
integer x = 96
integer y = 668
integer width = 997
integer height = 132
integer textsize = -8
integer weight = 400
fontpitch fontpitch = variable!
fontfamily fontfamily = swiss!
string facename = "MS Sans Serif"
long textcolor = 33554432
long backcolor = 67108864
boolean enabled = false
string text = "Enter page numbers and/or page ranges separated by commas.  For example, 1,3,5-12"
boolean focusrectangle = false
end type

type sle_pages from singlelineedit within w_report_options
integer x = 453
integer y = 548
integer width = 622
integer height = 84
integer taborder = 40
integer textsize = -8
integer weight = 700
fontpitch fontpitch = variable!
fontfamily fontfamily = swiss!
string facename = "MS Sans Serif"
long textcolor = 33554432
boolean enabled = false
boolean autohscroll = false
borderstyle borderstyle = stylelowered!
end type

type st_4 from statictext within w_report_options
integer x = 800
integer y = 448
integer width = 87
integer height = 64
integer textsize = -8
integer weight = 700
fontpitch fontpitch = variable!
fontfamily fontfamily = swiss!
string facename = "MS Sans Serif"
long textcolor = 33554432
long backcolor = 67108864
boolean enabled = false
string text = "to:"
alignment alignment = right!
boolean focusrectangle = false
end type

type em_thru from editmask within w_report_options
integer x = 910
integer y = 440
integer width = 165
integer height = 84
integer taborder = 30
integer textsize = -8
integer weight = 700
fontpitch fontpitch = variable!
fontfamily fontfamily = swiss!
string facename = "MS Sans Serif"
long textcolor = 33554432
boolean enabled = false
alignment alignment = right!
borderstyle borderstyle = stylelowered!
string mask = "####"
string displaydata = "À"
end type

type em_from from editmask within w_report_options
integer x = 617
integer y = 440
integer width = 165
integer height = 84
integer taborder = 20
integer textsize = -8
integer weight = 700
fontpitch fontpitch = variable!
fontfamily fontfamily = swiss!
string facename = "MS Sans Serif"
long textcolor = 33554432
boolean enabled = false
string text = "1"
alignment alignment = right!
borderstyle borderstyle = stylelowered!
string mask = "####"
string displaydata = "~b"
end type

type rb_pages from radiobutton within w_report_options
integer x = 96
integer y = 552
integer width = 334
integer height = 76
integer textsize = -8
integer weight = 700
fontpitch fontpitch = variable!
fontfamily fontfamily = swiss!
string facename = "MS Sans Serif"
long textcolor = 33554432
long backcolor = 67108864
string text = "Pages:"
end type

event clicked;em_from.enabled = False
em_thru.enabled = False
sle_pages.enabled = True

sle_pages.SetFocus()

end event

type rb_range from radiobutton within w_report_options
integer x = 96
integer y = 448
integer width = 334
integer height = 64
integer textsize = -8
integer weight = 700
fontpitch fontpitch = variable!
fontfamily fontfamily = swiss!
string facename = "MS Sans Serif"
long textcolor = 33554432
long backcolor = 67108864
string text = "Range:"
end type

event clicked;em_from.enabled = True
em_thru.enabled = True
sle_pages.enabled = False

em_from.SetFocus()

end event

type rb_all from radiobutton within w_report_options
integer x = 96
integer y = 348
integer width = 334
integer height = 64
integer textsize = -8
integer weight = 700
fontpitch fontpitch = variable!
fontfamily fontfamily = swiss!
string facename = "MS Sans Serif"
long textcolor = 33554432
long backcolor = 67108864
string text = "All"
boolean checked = true
end type

event clicked;em_from.enabled = False
em_thru.enabled = False
sle_pages.enabled = False

em_from.text = "1"
em_thru.text = ""

end event

type cb_printer from commandbutton within w_report_options
integer x = 1536
integer y = 80
integer width = 407
integer height = 100
integer taborder = 10
integer textsize = -8
integer weight = 700
fontpitch fontpitch = variable!
fontfamily fontfamily = swiss!
string facename = "MS Sans Serif"
string text = "Choose..."
end type

event clicked;// change printer

SetPointer(HourGlass!)

PrintSetup()

// get printer info
wf_printer_info()

end event

type cb_ok from commandbutton within w_report_options
integer x = 1134
integer y = 896
integer width = 407
integer height = 100
integer taborder = 90
integer textsize = -8
integer weight = 700
fontpitch fontpitch = variable!
fontfamily fontfamily = swiss!
string facename = "MS Sans Serif"
string text = "OK"
boolean default = true
end type

event clicked;Integer li_from, li_thru
String ls_msghdr, ls_property, ls_rtn

ls_msghdr = parent.title + " - Error"

If rb_all.checked Then
   // set page range
   ls_rtn = idw_datawindow.Modify("DataWindow.Print.Page.Range = ''")
   If Len(ls_rtn) > 0 Then
      MessageBox(ls_msghdr, ls_rtn, StopSign!)
      Return
   End If
   istr_opt.s_page_range = ""
End If

If rb_range.checked Then
   li_from = Integer(em_from.text)
   li_thru = Integer(em_thru.text)
   If li_thru = 0 Then
      li_thru = li_from
   End If
   If li_from = 0 Then
      MessageBox(ls_msghdr, "Page number zero not allowed!", StopSign!)
      em_from.SetFocus()
      Return
   End If
   If li_from > li_thru Then
      MessageBox(ls_msghdr, "From page can't be greater than to page!", StopSign!)
      em_from.SetFocus()
      Return
   End If
   // set page range
   ls_property = String(li_from) + "-" + String(li_thru)
   ls_rtn = idw_datawindow.Modify("DataWindow.Print.Page.Range = '" + ls_property + "'")
   If Len(ls_rtn) > 0 Then
      MessageBox(ls_msghdr, ls_rtn, StopSign!)
      em_from.SetFocus()
      Return
   End If
   istr_opt.s_page_range = ls_property
End If

If rb_pages.checked Then
   // set page range
   ls_property = Trim(sle_pages.text)
   ls_rtn = idw_datawindow.Modify("DataWindow.Print.Page.Range = '" + ls_property + "'")
   If Len(ls_rtn) > 0 Then
      MessageBox(ls_msghdr, ls_rtn, StopSign!)
      sle_pages.SetFocus()
      Return
   End If
   istr_opt.s_page_range = ls_property
End If

// set number of copies
ls_property = Trim(em_copies.text)
ls_rtn = idw_datawindow.Modify("DataWindow.Print.Copies = " + ls_property)
If Len(ls_rtn) > 0 Then
   MessageBox(ls_msghdr, ls_rtn, StopSign!)
   em_copies.SetFocus()
   Return
End If
istr_opt.i_copies = Integer(ls_property)

// set orientation
ls_property = Lower(Left(ddlb_orientation.text, 4))
CHOOSE CASE ls_property
   CASE "land"
      ls_property = "1"
   CASE "port"
      ls_property = "2"
   CASE ELSE
      ls_property = "0"
END CHOOSE
ls_rtn = idw_datawindow.Modify("DataWindow.Print.Orientation = " + ls_property)
If Len(ls_rtn) > 0 Then
   MessageBox(ls_msghdr, ls_rtn, StopSign!)
   ddlb_orientation.SetFocus()
   Return
End If
istr_opt.i_orientation = Integer(ls_property)

// set print range include
ls_property = Lower(Left(ddlb_printrange.text, 3))
CHOOSE CASE ls_property
   CASE "eve"
      ls_property = "1"
   CASE "odd"
      ls_property = "2"
   CASE ELSE
      ls_property = "0"
END CHOOSE
ls_rtn = idw_datawindow.Modify("DataWindow.Print.Page.RangeInclude = " + ls_property)
If Len(ls_rtn) > 0 Then
   MessageBox(ls_msghdr, ls_rtn, StopSign!)
   ddlb_orientation.SetFocus()
   Return
End If
istr_opt.i_rangeinclude = Integer(ls_property)

// close window
istr_opt.b_ok = True

// cancel window
CloseWithReturn(Parent, istr_opt)

end event

type cb_cancel from commandbutton within w_report_options
integer x = 1609
integer y = 896
integer width = 407
integer height = 100
integer taborder = 100
integer textsize = -8
integer weight = 700
fontpitch fontpitch = variable!
fontfamily fontfamily = swiss!
string facename = "MS Sans Serif"
string text = "Cancel"
boolean cancel = true
end type

event clicked;istr_opt.b_ok = False

// cancel window
CloseWithReturn(Parent, istr_opt)

end event

type gb_3 from groupbox within w_report_options
integer x = 1207
integer y = 264
integer width = 809
integer height = 572
integer textsize = -8
integer weight = 700
fontpitch fontpitch = variable!
fontfamily fontfamily = swiss!
string facename = "MS Sans Serif"
long textcolor = 33554432
long backcolor = 67108864
string text = "Paper Options"
end type

type gb_2 from groupbox within w_report_options
integer x = 37
integer y = 264
integer width = 1102
integer height = 572
integer textsize = -8
integer weight = 700
fontpitch fontpitch = variable!
fontfamily fontfamily = swiss!
string facename = "MS Sans Serif"
long textcolor = 33554432
long backcolor = 67108864
string text = "Print Range"
end type

type gb_1 from groupbox within w_report_options
integer x = 37
integer y = 8
integer width = 1979
integer height = 220
integer textsize = -8
integer weight = 700
fontpitch fontpitch = variable!
fontfamily fontfamily = swiss!
string facename = "MS Sans Serif"
long textcolor = 33554432
long backcolor = 67108864
string text = "Printer"
end type