u_dw.sru 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239
  1. $PBExportHeader$u_dw.sru
  2. forward
  3. global type u_dw from datawindow
  4. end type
  5. end forward
  6. global type u_dw from datawindow
  7. int Width=2176
  8. int Height=1096
  9. int TabOrder=1
  10. event refresh pbm_custom01
  11. event newrow pbm_custom02
  12. event deleterow pbm_custom03
  13. event savedata pbm_custom04
  14. event retrievedata pbm_custom05
  15. event accepttext pbm_custom06
  16. event newfirstrow pbm_custom07
  17. event newlastrow pbm_custom08
  18. event postaccepttext pbm_custom09
  19. event documentation pbm_custom75
  20. event parentresize pbm_custom10
  21. end type
  22. global u_dw u_dw
  23. type variables
  24. Public:
  25. Boolean bFailedAccept = FALSE, i_bFailedSave = FALSE
  26. Boolean i_bAutoResizeHorizontal = FALSE, i_bAutoResizeVertical = FALSE
  27. Integer i_nBottomGap, i_nRightGap, i_nMinWidth, i_nMaxWidth = -1, i_nMinHeight, i_nMaxHeight = -1
  28. Window i_wParent
  29. Private:
  30. Boolean i_bInAcceptText = FALSE
  31. end variables
  32. forward prototypes
  33. public subroutine uf_ChangeDataObject (string szdataobject, rowfocusind rfipointertype, picture ptrpointer, integer nxlocation, integer nylocation, transaction trtransaction)
  34. protected function long uf_retrievedata ()
  35. end prototypes
  36. on newrow;Long lRow
  37. lRow = this.GetRow()
  38. If lRow = -1 Then
  39. error.object = this.ClassName()
  40. error.ObjectEvent = "NewRow"
  41. error.line = 3
  42. error.number = -1
  43. error.text = "Error get row information from the datawindow."
  44. Else
  45. lRow = this.InsertRow( lRow + 1)
  46. If lRow = -1 Then
  47. error.object = this.ClassName()
  48. error.ObjectEvent = "NewRow"
  49. error.line = 12
  50. error.number = -1
  51. error.text = "Unable to insert a new row into the datawindow."
  52. Else
  53. this.SetColumn( 1)
  54. this.ScrollToRow( lRow)
  55. this.SetFocus()
  56. End If
  57. End If
  58. end on
  59. on deleterow;Long lRow
  60. lRow = this.GetRow()
  61. If lRow = -1 Then
  62. error.object = this.ClassName()
  63. error.ObjectEvent = "DeleteRow"
  64. error.line = 3
  65. error.number = -1
  66. error.text = "Error get row information from the datawindow."
  67. Else
  68. If this.DeleteRow( lRow) <> 1 Then
  69. error.object = this.ClassName()
  70. error.ObjectEvent = "DeleteRow"
  71. error.line = 12
  72. error.number = -1
  73. error.text = "Unable to Delete a new row into the datawindow."
  74. Else
  75. this.ScrollToRow( lRow - 1)
  76. this.SetFocus()
  77. End If
  78. End If
  79. end on
  80. on accepttext;If Not i_bInAcceptText Then
  81. i_bInAcceptText = TRUE
  82. If this.AcceptText() = -1 Then
  83. bFailedAccept = TRUE
  84. this.SetFocus()
  85. this.PostEvent( "PostAcceptText")
  86. Return
  87. Else
  88. bFailedAccept = FALSE
  89. End If
  90. End If
  91. i_bInAcceptText = FALSE
  92. end on
  93. on newfirstrow;Long lRow
  94. lRow = this.InsertRow( 1)
  95. If lRow = -1 Then
  96. error.object = this.ClassName()
  97. error.ObjectEvent = "NewFirstRow"
  98. error.line = 3
  99. error.number = -1
  100. error.text = "Unable to insert a new row into the datawindow."
  101. Else
  102. this.SetColumn( 1)
  103. this.ScrollToRow( lRow)
  104. this.SetFocus()
  105. End If
  106. end on
  107. on newlastrow;Long lRow
  108. lRow = this.InsertRow( 0)
  109. If lRow = -1 Then
  110. error.object = this.ClassName()
  111. error.ObjectEvent = "NewLastRow"
  112. error.line = 3
  113. error.number = -1
  114. error.text = "Unable to insert a new row into the datawindow."
  115. Else
  116. this.SetColumn( 1)
  117. this.ScrollToRow( lRow)
  118. this.SetFocus()
  119. End If
  120. end on
  121. on postaccepttext;i_bInAcceptText = FALSE
  122. end on
  123. on documentation;// Copyright Simon Gallagher 1993-1995
  124. //
  125. // This DataWindow object contains the following functionality:
  126. //
  127. // Events:
  128. // DeleteRow - Handles deleting the current row
  129. // SaveData - Handles saving the data
  130. // RetrieveData - Handles retrieving data for the dw, no parameters
  131. // NewRow - Inserts a new row after the current
  132. // NewFirstRow - Inserts a new row at the beginning of the dw
  133. // NewLastRow - Inserts a new row at the end of the dw
  134. // AcceptText - Handles the acceptance of data before focus leaves the window
  135. // ParentResize - On direction of a parent window, the datawindow will resize itself
  136. end on
  137. on parentresize;Integer nNewWidth, nNewHeight
  138. this.SetRedraw( FALSE)
  139. If i_bAutoResizeHorizontal Then
  140. nNewWidth = i_wParent.Width - this.X - i_nRightGap
  141. If nNewWidth >= i_nMinWidth And (nNewWidth <= i_nMaxWidth Or i_nMaxWidth = -1) Then
  142. this.Width = nNewWidth
  143. this.HScrollBar = TRUE
  144. ElseIf nNewWidth < i_nMinWidth Then
  145. this.Width = i_nMinWidth
  146. End If
  147. End If
  148. If i_bAutoResizeVertical Then
  149. nNewHeight = i_wParent.Height - this.Y - i_nBottomGap
  150. If nNewHeight >=i_nMinHeight And (nNewHeight <= i_nMaxHeight Or i_nMaxHeight=-1) Then
  151. this.Height = nNewHeight
  152. this.VScrollBar = TRUE
  153. ElseIf nNewHeight < i_nMinHeight Then
  154. this.Height = i_nMinHeight
  155. End If
  156. End If
  157. this.SetRedraw( TRUE)
  158. end on
  159. public subroutine uf_ChangeDataObject (string szdataobject, rowfocusind rfipointertype, picture ptrpointer, integer nxlocation, integer nylocation, transaction trtransaction);this.dataobject = szDataObject
  160. If IsValid( ptrPointer) Then
  161. this.SetRowFocusIndicator( ptrPointer, nXLocation, nYLocation)
  162. Else
  163. this.SetRowFocusIndicator( rfiPointerType, nXLocation, nYLocation)
  164. End If
  165. this.SetTransObject( trTransaction)
  166. end subroutine
  167. protected function long uf_retrievedata ();Return this.Retrieve()
  168. end function
  169. event constructor;If this.SetTransObject( SQLCA) <> 1 Then
  170. error.object = this.ClassName()
  171. error.objectevent = "Constructor"
  172. error.line = 1
  173. error.number = SQLCA.SQLDBCode
  174. error.text = SQLCA.SQLErrText
  175. End If
  176. end event
  177. on itemerror;i_bInAcceptText = TRUE
  178. end on
  179. on losefocus;this.PostEvent( "accepttext")
  180. end on
  181. event dberror;// Open the standard error window, no values can be passed from this level
  182. // any information displayed apart from error text will have to be defined
  183. // at the child level
  184. error.text = sqlerrtext
  185. error.number = sqldbcode
  186. //
  187. // Scroll to the row causing the error, if it is in the visible, PRIMARY!, buffer
  188. //
  189. If buffer = PRIMARY! Then
  190. this.ScrollToRow( row)
  191. this.SetFocus()
  192. End If
  193. // Do Not process message any further
  194. Return 1
  195. end event