u_function_button.sru 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349
  1. $PBExportHeader$u_function_button.sru
  2. $PBExportComments$By PBKiller v2.5.18(http://kivens.nease.net)
  3. forward
  4. global type u_function_button from userobject
  5. end type
  6. type st_text from statictext within u_function_button
  7. end type
  8. type ln_top from line within u_function_button
  9. end type
  10. type ln_bottom from line within u_function_button
  11. end type
  12. type ln_left from line within u_function_button
  13. end type
  14. type ln_right from line within u_function_button
  15. end type
  16. type ln_top1 from line within u_function_button
  17. end type
  18. type ln_left1 from line within u_function_button
  19. end type
  20. end forward
  21. global type u_function_button from userobject
  22. integer width = 869
  23. integer height = 76
  24. long backcolor = 79741120
  25. string pointer = "HyperLink!"
  26. event mousedown pbm_lbuttondown
  27. event mousemove pbm_mousemove
  28. event mouseup pbm_lbuttonup
  29. event ue_click ( )
  30. st_text st_text
  31. ln_top ln_top
  32. ln_bottom ln_bottom
  33. ln_left ln_left
  34. ln_right ln_right
  35. ln_top1 ln_top1
  36. ln_left1 ln_left1
  37. end type
  38. global u_function_button u_function_button
  39. type prototypes
  40. public function ulong setcapture (ulong hwnd) library "USER32.DLL" alias for "SetCapture"
  41. public function boolean releasecapture () library "USER32.DLL" alias for "ReleaseCapture"
  42. end prototypes
  43. type variables
  44. public long il_txtx
  45. public long il_txty
  46. public long il_grey = 8421504
  47. public long il_white = 16777215
  48. public long il_mousex
  49. public long il_mousey
  50. public integer ii_type = -1
  51. public integer ii_index
  52. public string is_data
  53. public boolean ib_mousecaptured = false
  54. public u_function_panel iuo_parent
  55. end variables
  56. forward prototypes
  57. private function integer of_capturemouse ()
  58. public function string of_getdata ()
  59. public subroutine of_highlight (integer ai_type)
  60. public function integer of_releasemouse ()
  61. public subroutine of_resize (integer ai_width,integer ai_height)
  62. public subroutine of_settext (string txt)
  63. end prototypes
  64. event mousedown;of_highlight(2)
  65. return
  66. end event
  67. event mousemove;boolean lb_inbounds = false
  68. of_capturemouse()
  69. if ((((xpos < 0) or (ypos < 0)) or (xpos > width)) or (ypos > height)) then
  70. lb_inbounds = false
  71. else
  72. lb_inbounds = true
  73. end if
  74. if not lb_inbounds then
  75. st_text.textcolor = 0
  76. else
  77. st_text.textcolor = 16711680
  78. end if
  79. if lb_inbounds and keydown(keyleftbutton!) then
  80. of_highlight(2)
  81. else
  82. if not lb_inbounds then
  83. of_highlight(1)
  84. of_releasemouse()
  85. else
  86. of_highlight(1)
  87. end if
  88. end if
  89. return
  90. end event
  91. event mouseup;boolean lb_inbounds = false
  92. if ((((xpos < 0) or (ypos < 0)) or (xpos > width)) or (ypos > height)) then
  93. lb_inbounds = false
  94. else
  95. lb_inbounds = true
  96. end if
  97. st_text.textcolor = 0
  98. of_highlight(1)
  99. of_releasemouse()
  100. if lb_inbounds then
  101. triggerevent("ue_click")
  102. end if
  103. return
  104. end event
  105. event ue_click();
  106. if iuo_parent.ii_curgroup <> ii_index then
  107. iuo_parent.ii_curgroup = ii_index
  108. iuo_parent.is_selectedid = is_data
  109. iuo_parent.triggerevent("ue_clickbutton")
  110. end if
  111. end event
  112. private function integer of_capturemouse ();if ib_mousecaptured then
  113. return -1
  114. end if
  115. setcapture(handle(this))
  116. ib_mousecaptured = true
  117. return 1
  118. end function
  119. public function string of_getdata ();return is_data
  120. end function
  121. public subroutine of_highlight (integer ai_type);if ai_type = ii_type then
  122. return
  123. else
  124. ii_type = ai_type
  125. end if
  126. if ai_type = 0 then
  127. st_text.move(il_txtx,il_txty)
  128. ln_top.hide()
  129. ln_bottom.hide()
  130. ln_left.hide()
  131. ln_right.hide()
  132. ln_top1.hide()
  133. ln_left1.hide()
  134. setposition(totop!)
  135. return
  136. end if
  137. if ai_type = 1 then
  138. ln_top.linecolor = il_white
  139. ln_left.linecolor = il_white
  140. ln_bottom.linecolor = il_grey
  141. ln_right.linecolor = il_grey
  142. st_text.move(il_txtx,il_txty)
  143. ln_top.show()
  144. ln_bottom.show()
  145. ln_left.show()
  146. ln_right.show()
  147. ln_top1.hide()
  148. ln_left1.hide()
  149. setposition(totop!)
  150. return
  151. end if
  152. if ai_type = 2 then
  153. ln_top.linecolor = il_grey
  154. ln_left.linecolor = il_grey
  155. ln_bottom.linecolor = il_white
  156. ln_right.linecolor = il_white
  157. ln_top1.linecolor = il_grey
  158. ln_left1.linecolor = il_grey
  159. st_text.move(il_txtx + 4,il_txty + 4)
  160. ln_top.show()
  161. ln_bottom.show()
  162. ln_left.show()
  163. ln_right.show()
  164. ln_top1.show()
  165. ln_left1.show()
  166. setposition(totop!)
  167. return
  168. end if
  169. end subroutine
  170. public function integer of_releasemouse ();if not ib_mousecaptured then
  171. return -1
  172. end if
  173. releasecapture()
  174. ib_mousecaptured = false
  175. return 1
  176. end function
  177. public subroutine of_resize (integer ai_width,integer ai_height);integer li_x
  178. integer li_y
  179. integer li_width
  180. integer li_height
  181. resize(ai_width,ai_height)
  182. li_x = 0
  183. li_y = 0
  184. li_width = unitstopixels(ai_width,xunitstopixels!) - 1
  185. li_height = unitstopixels(ai_height,yunitstopixels!) - 1
  186. ln_top.beginx = pixelstounits(li_x,xpixelstounits!)
  187. ln_top.beginy = pixelstounits(li_y,ypixelstounits!)
  188. ln_top.endx = pixelstounits(li_width,xpixelstounits!)
  189. ln_top.endy = ln_top.beginy
  190. ln_left.beginx = pixelstounits(li_x,xpixelstounits!)
  191. ln_left.beginy = pixelstounits(li_y,ypixelstounits!)
  192. ln_left.endx = ln_left.beginx
  193. ln_left.endy = pixelstounits(li_height,ypixelstounits!)
  194. ln_right.beginx = pixelstounits(li_width,xpixelstounits!)
  195. ln_right.beginy = pixelstounits(li_y,ypixelstounits!)
  196. ln_right.endx = ln_right.beginx
  197. ln_right.endy = pixelstounits(li_height,ypixelstounits!)
  198. ln_bottom.beginx = pixelstounits(li_x,xpixelstounits!)
  199. ln_bottom.beginy = pixelstounits(li_height,ypixelstounits!)
  200. ln_bottom.endx = pixelstounits(li_width + 1,xpixelstounits!)
  201. ln_bottom.endy = ln_bottom.beginy
  202. ln_top1.beginx = pixelstounits(1,xpixelstounits!)
  203. ln_top1.beginy = pixelstounits(1,ypixelstounits!)
  204. ln_top1.endx = pixelstounits(li_width,xpixelstounits!)
  205. ln_top1.endy = ln_top1.beginy
  206. ln_left1.beginx = pixelstounits(1,xpixelstounits!)
  207. ln_left1.beginy = pixelstounits(1,ypixelstounits!)
  208. ln_left1.endx = ln_left1.beginx
  209. ln_left1.endy = pixelstounits(li_height,ypixelstounits!)
  210. st_text.move(20,(ai_height - st_text.height) / 2)
  211. st_text.resize(ai_width - st_text.x - 20,st_text.height)
  212. il_txtx = st_text.x
  213. il_txty = st_text.y
  214. return
  215. end subroutine
  216. public subroutine of_settext (string txt);st_text.text = txt
  217. end subroutine
  218. event constructor;call super::constructor;
  219. hide()
  220. of_resize(width,height)
  221. of_highlight(1)
  222. return
  223. end event
  224. on u_function_button.create
  225. this.st_text=create st_text
  226. this.ln_top=create ln_top
  227. this.ln_bottom=create ln_bottom
  228. this.ln_left=create ln_left
  229. this.ln_right=create ln_right
  230. this.ln_top1=create ln_top1
  231. this.ln_left1=create ln_left1
  232. this.Control[]={this.st_text,&
  233. this.ln_top,&
  234. this.ln_bottom,&
  235. this.ln_left,&
  236. this.ln_right,&
  237. this.ln_top1,&
  238. this.ln_left1}
  239. end on
  240. on u_function_button.destroy
  241. destroy(this.st_text)
  242. destroy(this.ln_top)
  243. destroy(this.ln_bottom)
  244. destroy(this.ln_left)
  245. destroy(this.ln_right)
  246. destroy(this.ln_top1)
  247. destroy(this.ln_left1)
  248. end on
  249. type st_text from statictext within u_function_button
  250. integer x = 32
  251. integer y = 12
  252. integer width = 809
  253. integer height = 52
  254. integer textsize = -9
  255. integer weight = 400
  256. fontcharset fontcharset = gb2312charset!
  257. fontpitch fontpitch = variable!
  258. string facename = "宋体"
  259. long textcolor = 33554432
  260. long backcolor = 67108864
  261. boolean enabled = false
  262. alignment alignment = center!
  263. boolean focusrectangle = false
  264. end type
  265. type ln_top from line within u_function_button
  266. long linecolor = 16777215
  267. integer beginx = 5
  268. integer endx = 850
  269. end type
  270. type ln_bottom from line within u_function_button
  271. long linecolor = 8421504
  272. integer beginx = 9
  273. integer beginy = 68
  274. integer endx = 855
  275. integer endy = 68
  276. end type
  277. type ln_left from line within u_function_button
  278. long linecolor = 16777215
  279. integer beginx = 5
  280. integer beginy = 4
  281. integer endx = 5
  282. integer endy = 68
  283. end type
  284. type ln_right from line within u_function_button
  285. long linecolor = 8421504
  286. integer beginx = 850
  287. integer beginy = 4
  288. integer endx = 850
  289. integer endy = 68
  290. end type
  291. type ln_top1 from line within u_function_button
  292. long linecolor = 8421504
  293. integer beginx = 9
  294. integer beginy = 4
  295. integer endx = 855
  296. integer endy = 4
  297. end type
  298. type ln_left1 from line within u_function_button
  299. long linecolor = 8421504
  300. integer beginx = 9
  301. integer beginy = 20
  302. integer endx = 9
  303. integer endy = 68
  304. end type