u_lbs_stsplitbar.sru 32 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174
  1. $PBExportHeader$u_lbs_stsplitbar.sru
  2. $PBExportComments$resize拖动条
  3. forward
  4. global type u_lbs_stsplitbar from statictext
  5. end type
  6. end forward
  7. global type u_lbs_stsplitbar from statictext
  8. integer width = 535
  9. integer height = 20
  10. integer textsize = -9
  11. integer weight = 400
  12. fontcharset fontcharset = gb2312charset!
  13. fontpitch fontpitch = variable!
  14. string facename = "宋体"
  15. long backcolor = 271938463
  16. boolean focusrectangle = false
  17. event mousemove pbm_mousemove
  18. event lbuttonup pbm_lbuttonup
  19. end type
  20. global u_lbs_stsplitbar u_lbs_stsplitbar
  21. type variables
  22. Public:
  23. //-- Define the "style" of split bar. --
  24. constant integer VERTICAL = 1
  25. constant integer HORIZONTAL = 2
  26. //-- Define the "Register" type. --
  27. constant integer LEFT=1
  28. constant integer RIGHT=2
  29. constant integer ABOVE=3
  30. constant integer BELOW=4
  31. Protected:
  32. //-- Define the "Extreme points" constants. --
  33. constant integer LEFTMOST=1
  34. constant integer RIGHTMOST=2
  35. constant integer TOPMOST=3
  36. constant integer BOTTOMMOST=4
  37. constant integer UNITIALIZED = -32000
  38. //-- Define default icons. --
  39. string is_verticalpointer ='SizeWE!'
  40. string is_horizontalpointer ='SizeNS!'
  41. // -- Registered information. --
  42. integer ii_lefttopbound
  43. dragobject idrg_lefttop[]
  44. real ir_lefttopx[]
  45. real ir_lefttopy[]
  46. real ir_lefttopwidth[]
  47. real ir_lefttopheight[]
  48. integer ii_rightbottombound
  49. dragobject idrg_rightbottom[]
  50. real ir_rightbottomx[]
  51. real ir_rightbottomy[]
  52. real ir_rightbottomwidth[]
  53. real ir_rightbottomheight[]
  54. // --Other. --
  55. integer ii_style = -1 // Default to negative value.
  56. Integer ii_barwidth = -1 // Default to negative value.
  57. long il_barcolor=78682240
  58. long il_barmovecolor=8421504
  59. integer ii_minobjectsize = 20
  60. boolean ib_performredraw=True
  61. //-- Internal attributes. --
  62. boolean ib_supported = True
  63. integer ii_prevpositionx = UNITIALIZED
  64. integer ii_prevpositiony = UNITIALIZED
  65. window iw_parent
  66. userobject iuo_parent
  67. tab itab_parent
  68. Integer ii_rounding=5
  69. //增加,定位拖动条
  70. integer il_leftspace
  71. integer il_topspace
  72. //定位对象
  73. dragobject idrg_posh //水平定位对象
  74. dragobject idrg_posv//垂直定位对象
  75. end variables
  76. forward prototypes
  77. public function integer of_setbarcolor (long al_color)
  78. public function integer of_setbarmovecolor (long al_color)
  79. protected function integer of_lbuttonup (unsignedlong aul_flags, integer ai_xpos, integer ai_ypos)
  80. protected function integer of_mousemove (unsignedlong aul_flags, integer ai_xpos, integer ai_ypos)
  81. public function integer of_register (dragobject adrg_object, integer ai_position)
  82. protected function integer of_updateobjectdata ()
  83. protected function integer of_redraw (integer ai_prevx, integer ai_prevwidth, integer ai_prevy, integer ai_prevheight)
  84. public function integer of_getextremepoint (integer ai_extremetype)
  85. public function integer of_setminobjectsize (integer ai_minsize)
  86. public function integer of_getminobjectsize ()
  87. public function integer of_getbarcolor ()
  88. public function string of_gethorizontalpointer ()
  89. public function string of_getverticalpointer ()
  90. public function integer of_sethorizontalpointer (string as_icon)
  91. public function integer of_setverticalpointer (string as_icon)
  92. public function integer of_getbarmovecolor ()
  93. protected function boolean of_issupported ()
  94. public function integer of_reset ()
  95. public function integer uf_possplitbar (dragobject adrg_object)
  96. end prototypes
  97. event mousemove;//////////////////////////////////////////////////////////////////////////////
  98. //
  99. // Event: mousemove
  100. //
  101. // Arguments:
  102. // flags
  103. // xpos
  104. // ypos
  105. //
  106. // Returns: None.
  107. //
  108. // Description: Perform the Mouse Move processing.
  109. //
  110. //////////////////////////////////////////////////////////////////////////////
  111. //
  112. // Revision History
  113. //
  114. // Version
  115. // 6.0 Initial version
  116. //
  117. //////////////////////////////////////////////////////////////////////////////
  118. //
  119. // Copyright ?1996 Sybase, Inc. and its subsidiaries. All rights reserved.
  120. // Any distribution of the PowerBuilder Foundation Classes (PFC)
  121. // source code by other than Sybase, Inc. and its subsidiaries is prohibited.
  122. //
  123. //////////////////////////////////////////////////////////////////////////////
  124. If Not KeyDown(keyLeftButton!) Then
  125. Return
  126. End If
  127. of_MouseMove(flags, xpos, ypos)
  128. end event
  129. event lbuttonup;call super::lbuttonup;//////////////////////////////////////////////////////////////////////////////
  130. //
  131. // Event: lbuttonup
  132. //
  133. // Arguments:
  134. // flags
  135. // xpos
  136. // ypos
  137. //
  138. // Returns: None.
  139. //
  140. // Description: Perform the Left Button Up processing.
  141. //
  142. //////////////////////////////////////////////////////////////////////////////
  143. //
  144. // Revision History
  145. //
  146. // Version
  147. // 6.0 Initial version
  148. //
  149. //////////////////////////////////////////////////////////////////////////////
  150. //
  151. // Copyright ?1996 Sybase, Inc. and its subsidiaries. All rights reserved.
  152. // Any distribution of the PowerBuilder Foundation Classes (PFC)
  153. // source code by other than Sybase, Inc. and its subsidiaries is prohibited.
  154. //
  155. //////////////////////////////////////////////////////////////////////////////
  156. of_lbuttonup(flags, xpos, ypos)
  157. end event
  158. public function integer of_setbarcolor (long al_color);//////////////////////////////////////////////////////////////////////////////
  159. //
  160. // Function: of_SetBarColor
  161. //
  162. // Access: Public
  163. //
  164. // Arguments:
  165. // al_color The desired color.
  166. //
  167. // Returns: Integer
  168. // Returns 1 if it succeeds and?1 if an error occurs.
  169. //
  170. // Description: Set the Non-Moving Split Bar Color.
  171. //
  172. //////////////////////////////////////////////////////////////////////////////
  173. // Validate the argument.
  174. If IsNull(al_color) Or al_color<0 Then
  175. Return -1
  176. End If
  177. // Set the color.
  178. il_barcolor = al_color
  179. // Start using the requested color.
  180. this.BackColor = il_barcolor
  181. Return 1
  182. end function
  183. public function integer of_setbarmovecolor (long al_color);//////////////////////////////////////////////////////////////////////////////
  184. //
  185. // Function: of_SetBarMoveColor
  186. //
  187. // Access: Public
  188. //
  189. // Arguments:
  190. // al_color The desired color.
  191. //
  192. // Returns: Integer
  193. // Returns 1 if it succeeds and?1 if an error occurs.
  194. //
  195. // Description: Set the Moving Split Bar Color.
  196. //
  197. //////////////////////////////////////////////////////////////////////////////
  198. // Validate the argument.
  199. If IsNull(al_color) Or al_color<0 Then
  200. Return -1
  201. End If
  202. il_barmovecolor = al_color
  203. Return 1
  204. end function
  205. protected function integer of_lbuttonup (unsignedlong aul_flags, integer ai_xpos, integer ai_ypos);//////////////////////////////////////////////////////////////////////////////
  206. //
  207. // Function: of_LButtonUp
  208. //
  209. // Access: Protected
  210. //
  211. // Arguments:
  212. // aul_flags
  213. // ai_xpos
  214. // ai_ypos
  215. //
  216. // Returns: Integer
  217. // Returns 1 if it succeeds and?1 if an error occurs.
  218. //
  219. // Description: Resize the objects according to the bar that was just moved
  220. // and other service attributes.
  221. //
  222. //////////////////////////////////////////////////////////////////////////////
  223. Integer li_cnt
  224. Integer li_deltax, li_deltay
  225. Integer li_pointerx, li_pointery
  226. Integer li_minx, li_maxx, li_miny, li_maxy
  227. Integer li_x, li_y, li_width, li_height
  228. // Validate required values.
  229. If ii_style <0 or ii_barwidth <0 Then
  230. Return -1
  231. End If
  232. // Validate that objects were registered.
  233. If UpperBound(idrg_lefttop) =0 Or UpperBound(idrg_rightbottom) =0 Then
  234. Return -1
  235. End If
  236. this.SetPosition(ToTop!)
  237. // Change to the base color.
  238. this.BackColor = il_barcolor
  239. // Validate that the bar has been moved.
  240. If ii_prevpositionx = UNITIALIZED Or ii_prevpositiony = UNITIALIZED Then
  241. Return 0
  242. End If
  243. // Get the new position.
  244. If IsValid(iuo_parent) Then
  245. li_pointerx = iuo_parent.PointerX()
  246. li_pointery = iuo_parent.PointerY()
  247. ElseIf IsValid(itab_parent) Then
  248. li_pointerx = itab_parent.PointerX()
  249. li_pointery = itab_parent.PointerY()
  250. ElseIf IsValid(iw_parent) Then
  251. li_pointerx = iw_parent.PointerX()
  252. li_pointery = iw_parent.PointerY()
  253. Else
  254. // Reset the Previous position variables to UNITIALIZED.
  255. ii_prevpositionx = UNITIALIZED
  256. ii_prevpositiony = UNITIALIZED
  257. Return -1
  258. End If
  259. // Calculate the Extreme points the split bars can be moved.
  260. If ii_style = HORIZONTAL Then
  261. li_miny = of_GetExtremePoint(TOPMOST)
  262. li_maxy = of_GetExtremePoint(BOTTOMMOST)
  263. If li_pointery < li_miny Then
  264. li_pointery = li_miny
  265. ElseIf li_pointery > li_maxy Then
  266. li_pointery = li_maxy
  267. End If
  268. ElseIf ii_style = VERTICAL Then
  269. li_minx = of_GetExtremePoint(LEFTMOST)
  270. li_maxx = of_GetExtremePoint(RIGHTMOST)
  271. If li_pointerx < li_minx Then
  272. li_pointerx = li_minx
  273. ElseIf li_pointerx > li_maxx Then
  274. li_pointerx = li_maxx
  275. End If
  276. End If
  277. // Calculate delta values.
  278. li_deltax = li_pointerx - ii_prevpositionx
  279. li_deltay = li_pointery - ii_prevpositiony
  280. // Minimize size rounding problems.
  281. of_UpdateObjectData()
  282. If ii_style = HORIZONTAL Then
  283. // Position bar on its new location.
  284. this.Y = li_pointery
  285. // Refresh the Width of the bar.
  286. this.Height = ii_barwidth
  287. // Resize the objects above the horizontal split bar.
  288. For li_cnt = 1 to UpperBound(idrg_lefttop)
  289. If IsValid(idrg_lefttop[li_cnt]) Then
  290. ir_lefttopheight[li_cnt] =ir_lefttopheight[li_cnt] + li_deltay
  291. idrg_lefttop[li_cnt].Resize(ir_lefttopwidth[li_cnt], ir_lefttopheight[li_cnt])
  292. End If
  293. Next
  294. // Resize the objects below the horizontal split bar.
  295. For li_cnt = 1 to UpperBound(idrg_rightbottom)
  296. If IsValid(idrg_rightbottom[li_cnt]) Then
  297. ir_rightbottomy[li_cnt] = ir_rightbottomy[li_cnt] + li_deltay
  298. ir_rightbottomheight[li_cnt] = ir_rightbottomheight[li_cnt] - li_deltay
  299. idrg_rightbottom[li_cnt].Move (ir_rightbottomx[li_cnt], ir_rightbottomy[li_cnt])
  300. idrg_rightbottom[li_cnt].Resize (ir_rightbottomwidth[li_cnt], ir_rightbottomheight[li_cnt])
  301. End If
  302. Next
  303. //重新定位
  304. if IsValid(idrg_posh) then
  305. this.y=idrg_posh.y + idrg_posh.height + il_topspace
  306. end if
  307. ElseIf ii_style = VERTICAL Then
  308. // Position bar on its new location.
  309. this.X = li_pointerx
  310. // Refresh the Width of the bar.
  311. this.Width = ii_barwidth
  312. // Resize the objects left of the verticalbar.
  313. For li_cnt = 1 to UpperBound(idrg_lefttop)
  314. If IsValid(idrg_lefttop[li_cnt]) Then
  315. ir_lefttopwidth[li_cnt] =ir_lefttopwidth[li_cnt] + li_deltax
  316. idrg_lefttop[li_cnt].Resize(ir_lefttopwidth[li_cnt], ir_lefttopheight[li_cnt])
  317. End If
  318. Next
  319. // Resize the objects right of the verticalbar.
  320. For li_cnt = 1 to UpperBound(idrg_rightbottom)
  321. If IsValid(idrg_rightbottom[li_cnt]) Then
  322. ir_rightbottomx[li_cnt] =ir_rightbottomx[li_cnt] + li_deltax
  323. ir_rightbottomWidth[li_cnt] =ir_rightbottomWidth[li_cnt] - li_deltax
  324. idrg_rightbottom[li_cnt].Move (ir_rightbottomx[li_cnt], ir_rightbottomy[li_cnt])
  325. idrg_rightbottom[li_cnt].Resize(ir_rightbottomWidth[li_cnt], ir_rightbottomHeight[li_cnt])
  326. End If
  327. Next
  328. //重新定位
  329. if IsValid(idrg_posv) then
  330. this.x=idrg_posv.x + idrg_posv.width + il_leftspace
  331. end if
  332. End If
  333. // Reset the Previous position variables to UNITIALIZED.
  334. ii_prevpositionx = UNITIALIZED
  335. ii_prevpositiony = UNITIALIZED
  336. Return 1
  337. end function
  338. protected function integer of_mousemove (unsignedlong aul_flags, integer ai_xpos, integer ai_ypos);//////////////////////////////////////////////////////////////////////////////
  339. //
  340. // Function: of_MouseMove
  341. //
  342. // Access: Public
  343. //
  344. // Arguments:
  345. // aul_flags
  346. // ai_xpos
  347. // ai_ypos
  348. //
  349. // Returns: Integer
  350. // Returns 1 if it succeeds and?1 if an error occurs.
  351. //
  352. // Description: One of the split bars is being moved. Refresh the location
  353. // of the appropriate splitbar(s) and perform redraws if requested.
  354. //
  355. //////////////////////////////////////////////////////////////////////////////
  356. Integer li_cnt
  357. Integer li_pointerx, li_pointery
  358. Integer li_minx, li_maxx, li_miny, li_maxy
  359. Integer li_prevx
  360. Integer li_prevwidth
  361. Integer li_prevheight
  362. Integer li_prevy
  363. Integer li_upperbound
  364. Integer li_parentx, li_parenty
  365. string ls_redraw
  366. Integer li_x, li_y, li_width, li_height
  367. // Validate required values.
  368. If ii_style < 0 Then
  369. Return -1
  370. End If
  371. // Validate that objects were registered.
  372. If UpperBound(idrg_lefttop) =0 Or UpperBound(idrg_rightbottom) =0 Then
  373. Return -1
  374. End If
  375. // Always keep the Split Bar on top of other objects.
  376. this.SetPosition(ToTop!)
  377. // Store the Begin Movement information.
  378. If ii_prevpositionx = UNITIALIZED or ii_prevpositiony = UNITIALIZED Then
  379. ii_prevpositionx = This.X
  380. ii_prevpositiony = This.Y
  381. End If
  382. // Store the previous placement information.
  383. li_prevx = this.X
  384. li_prevwidth = this.Width
  385. li_prevy = this.Y
  386. li_prevheight = this.Height
  387. // Get the new position.
  388. If IsValid(iuo_parent) Then
  389. li_pointerx = iuo_parent.PointerX()
  390. li_pointery = iuo_parent.PointerY()
  391. ElseIf IsValid(itab_parent) Then
  392. li_pointerx = itab_parent.PointerX()
  393. li_pointery = itab_parent.PointerY()
  394. ElseIf IsValid(iw_parent) Then
  395. li_pointerx = iw_parent.PointerX()
  396. li_pointery = iw_parent.PointerY()
  397. Else
  398. Return -1
  399. End If
  400. // Calculate the Extreme points the split bars can be moved.
  401. If ii_style = HORIZONTAL Then
  402. li_miny = of_GetExtremePoint(TOPMOST)
  403. li_maxy = of_GetExtremePoint(BOTTOMMOST)
  404. If li_pointery < li_miny Then
  405. li_pointery = li_miny
  406. ElseIf li_pointery > li_maxy Then
  407. li_pointery = li_maxy
  408. End If
  409. ElseIf ii_style = VERTICAL Then
  410. li_minx = of_GetExtremePoint(LEFTMOST)
  411. li_maxx = of_GetExtremePoint(RIGHTMOST)
  412. If li_pointerx < li_minx Then
  413. li_pointerx = li_minx
  414. ElseIf li_pointerx > li_maxx Then
  415. li_pointerx = li_maxx
  416. End If
  417. End If
  418. // Change to the "Moving" color.
  419. this.BackColor = il_barmovecolor
  420. If ii_style = HORIZONTAL Then
  421. // Position bar on its new location.
  422. this.Y = li_pointery
  423. // Refresh the Width of the bar.
  424. this.Height = ii_barwidth
  425. // Perform redraws when appropriate.
  426. If ib_performredraw Then
  427. If (li_prevy <> this.Y) Then
  428. of_Redraw(li_prevx, li_prevwidth, li_prevy, li_prevheight)
  429. End If
  430. End If
  431. ElseIf ii_style = VERTICAL Then
  432. // Position bar on its new location.
  433. this.X = li_pointerx
  434. // Refresh the Width of the bar.
  435. this.Width = ii_barwidth
  436. // Perform redraws when appropriate.
  437. If ib_performredraw Then
  438. If (li_prevx <> this.X) Then
  439. of_Redraw(li_prevx, li_prevwidth, li_prevy, li_prevheight)
  440. End If
  441. End If
  442. End If
  443. Return 1
  444. end function
  445. public function integer of_register (dragobject adrg_object, integer ai_position);//////////////////////////////////////////////////////////////////////////////
  446. //
  447. // Function: of_Register
  448. //
  449. // Access: public
  450. //
  451. // Arguments:
  452. // adrg_object The object to register with the service.
  453. // ai_position The position of the object in relation to the splitbar.
  454. //
  455. // Returns: integer
  456. // 1 if it succeeds
  457. // -1 if an error registering the objects occurs.
  458. //
  459. // Description: Register controls which need to either be moved and/or resized
  460. // when the split bar object is moved.
  461. //
  462. //////////////////////////////////////////////////////////////////////////////
  463. Integer li_rc
  464. Integer li_upperbound
  465. Integer li_obj
  466. // Validate required values.
  467. If ii_style <0 or ii_barwidth <0 Then
  468. Return -1
  469. End If
  470. // Validate the dragobject.
  471. If IsNull(adrg_object) Or Not IsValid(adrg_object) Then
  472. Return -1
  473. End If
  474. // Validate the position parameter.
  475. If IsNull(ai_position) Or ai_position < 0 Or ai_position > 4 Then
  476. Return -1
  477. Else
  478. If (ii_style = HORIZONTAL) And &
  479. (ai_position = LEFT Or ai_position = RIGHT) Then
  480. Return -1
  481. ElseIf (ii_style = VERTICAL) And &
  482. (ai_position = ABOVE Or ai_position = BELOW) Then
  483. Return -1
  484. End If
  485. End If
  486. // Make sure this object is not already registered on the left/top array.
  487. li_upperbound = UpperBound (idrg_lefttop)
  488. For li_obj = 1 to li_upperbound
  489. If IsValid(idrg_lefttop[li_obj]) Then
  490. If adrg_object = idrg_lefttop[li_obj] Then
  491. Return -1
  492. End If
  493. End If
  494. Next
  495. // Make sure this object is not already registered on the right/bottom array.
  496. li_upperbound = UpperBound (idrg_rightbottom)
  497. For li_obj = 1 to li_upperbound
  498. If IsValid(idrg_rightbottom[li_obj]) Then
  499. If adrg_object = idrg_rightbottom[li_obj] Then
  500. Return -1
  501. End If
  502. End If
  503. Next
  504. // Register the new object.
  505. If ai_position = LEFT Or ai_position = ABOVE Then
  506. ii_lefttopbound = UpperBound (idrg_lefttop) + 1
  507. idrg_lefttop[ii_lefttopbound] = adrg_object
  508. ir_lefttopx[ii_lefttopbound] = adrg_object.X
  509. ir_lefttopy[ii_lefttopbound] = adrg_object.Y
  510. ir_lefttopwidth[ii_lefttopbound] = adrg_object.Width
  511. ir_lefttopheight[ii_lefttopbound] = adrg_object.Height
  512. // il_leftspace=this.x - adrg_object.x - adrg_object.width
  513. // il_topspace=this.y - adrg_object.y - adrg_object.height
  514. Else
  515. ii_rightbottombound = UpperBound (idrg_rightbottom) + 1
  516. idrg_rightbottom[ii_rightbottombound] = adrg_object
  517. ir_rightbottomx[ii_rightbottombound] = adrg_object.X
  518. ir_rightbottomy[ii_rightbottombound] = adrg_object.Y
  519. ir_rightbottomwidth[ii_rightbottombound] = adrg_object.Width
  520. ir_rightbottomheight[ii_rightbottombound] = adrg_object.Height
  521. // il_leftspace=this.x - adrg_object.x - adrg_object.width
  522. // il_topspace=this.y - adrg_object.y - adrg_object.height
  523. End If
  524. Return 1
  525. end function
  526. protected function integer of_updateobjectdata ();//////////////////////////////////////////////////////////////////////////////
  527. //
  528. // Function: of_UpdateObjectData
  529. //
  530. // Access: Protected
  531. //
  532. // Arguments: None.
  533. //
  534. // Returns: Integer
  535. // Returns 1 if it succeeds and?1 if an error occurs.
  536. //
  537. // Description: Update the registered object data in order to minimize
  538. // rounding problems.
  539. //
  540. //////////////////////////////////////////////////////////////////////////////
  541. Integer li_cnt
  542. Integer li_upperbound
  543. li_upperbound = Upperbound (idrg_lefttop)
  544. For li_cnt = 1 to li_upperbound
  545. If IsValid(idrg_lefttop[li_cnt]) Then
  546. If abs(ir_lefttopx[li_cnt] - idrg_lefttop[li_cnt].X) > ii_rounding Then
  547. ir_lefttopx[li_cnt] = idrg_lefttop[li_cnt].X
  548. End If
  549. If abs(ir_lefttopy[li_cnt] - idrg_lefttop[li_cnt].Y) > ii_rounding Then
  550. ir_lefttopy[li_cnt] = idrg_lefttop[li_cnt].Y
  551. End If
  552. If abs(ir_lefttopwidth[li_cnt] - idrg_lefttop[li_cnt].Width) > ii_rounding Then
  553. ir_lefttopwidth[li_cnt] = idrg_lefttop[li_cnt].Width
  554. End If
  555. If abs(ir_lefttopheight[li_cnt] - idrg_lefttop[li_cnt].Height) > ii_rounding Then
  556. ir_lefttopheight[li_cnt] = idrg_lefttop[li_cnt].Height
  557. End If
  558. End If
  559. Next
  560. li_upperbound = Upperbound (idrg_rightbottom)
  561. For li_cnt = 1 to li_upperbound
  562. If IsValid(idrg_rightbottom[li_cnt]) Then
  563. If abs(ir_rightbottomx[li_cnt] - idrg_rightbottom[li_cnt].X) > ii_rounding Then
  564. ir_rightbottomx[li_cnt] = idrg_rightbottom[li_cnt].X
  565. End If
  566. If abs(ir_rightbottomy[li_cnt] - idrg_rightbottom[li_cnt].Y) > ii_rounding Then
  567. ir_rightbottomy[li_cnt] = idrg_rightbottom[li_cnt].Y
  568. End If
  569. If abs(ir_rightbottomwidth[li_cnt] - idrg_rightbottom[li_cnt].Width) > ii_rounding Then
  570. ir_rightbottomwidth[li_cnt] = idrg_rightbottom[li_cnt].Width
  571. End If
  572. If abs(ir_rightbottomheight[li_cnt] - idrg_rightbottom[li_cnt].Height) > ii_rounding Then
  573. ir_rightbottomheight[li_cnt] = idrg_rightbottom[li_cnt].Height
  574. End If
  575. End If
  576. Next
  577. Return 1
  578. end function
  579. protected function integer of_redraw (integer ai_prevx, integer ai_prevwidth, integer ai_prevy, integer ai_prevheight);//////////////////////////////////////////////////////////////////////////////
  580. //
  581. // Function: of_Redraw
  582. //
  583. // Access: protected
  584. //
  585. // Arguments:
  586. // ai_prevx The bar previous X location.
  587. // ai_prevwidth The bar previous Width.
  588. // ai_prevy The bar previous Y location.
  589. // ai_prevheight The bar previous Height.
  590. //
  591. // Returns: Integer
  592. // 1 if it succeeds and?1 if an error occurs.
  593. //
  594. // Description: Perform a Redraw on those object which may be still showing
  595. // the bar on its previous position.
  596. //
  597. //////////////////////////////////////////////////////////////////////////////
  598. Integer li_cnt
  599. // Validate required values.
  600. If ii_style <0 or ii_barwidth <0 Then
  601. Return -1
  602. End If
  603. If ii_style = HORIZONTAL Then
  604. // Redraw the objects above the Horizontal Split Bar.
  605. For li_cnt = 1 to ii_lefttopbound
  606. If IsValid(idrg_lefttop[li_cnt]) Then
  607. If (ai_prevy >= idrg_lefttop[li_cnt].Y Or &
  608. ai_prevy + ai_prevheight >= idrg_lefttop[li_cnt].Y) And &
  609. ai_prevy < idrg_lefttop[li_cnt].Y + idrg_lefttop[li_cnt].Height Then
  610. idrg_lefttop[li_cnt].SetRedraw(True)
  611. End If
  612. End If
  613. Next
  614. // Redraw the objects below the Horizontal Split Bar.
  615. For li_cnt = 1 to ii_rightbottombound
  616. If IsValid(idrg_rightbottom[li_cnt]) Then
  617. If (ai_prevy >= idrg_rightbottom[li_cnt].Y Or &
  618. ai_prevy + ai_prevheight >= idrg_rightbottom[li_cnt].Y ) And &
  619. ai_prevy < idrg_rightbottom[li_cnt].Y + idrg_rightbottom[li_cnt].Height Then
  620. idrg_rightbottom[li_cnt].SetRedraw(True)
  621. End If
  622. End If
  623. Next
  624. ElseIf ii_style = VERTICAL Then
  625. // Redraw the objects left of the Vertical Split Bar.
  626. For li_cnt = 1 to ii_lefttopbound
  627. If IsValid(idrg_lefttop[li_cnt]) Then
  628. If (ai_prevx >= idrg_lefttop[li_cnt].X Or &
  629. ai_prevx + ai_prevwidth >= idrg_lefttop[li_cnt].X) And &
  630. ai_prevx < idrg_lefttop[li_cnt].X + idrg_lefttop[li_cnt].Width Then
  631. idrg_lefttop[li_cnt].SetRedraw(True)
  632. End If
  633. End If
  634. Next
  635. // Redraw the objects right of the Vertical Split Bar.
  636. For li_cnt = 1 to ii_rightbottombound
  637. If IsValid(idrg_rightbottom[li_cnt]) Then
  638. If (ai_prevx >= idrg_rightbottom[li_cnt].X Or &
  639. ai_prevx + ai_prevwidth >= idrg_rightbottom[li_cnt].X) And &
  640. ai_prevx < idrg_rightbottom[li_cnt].X + idrg_rightbottom[li_cnt].Width Then
  641. idrg_rightbottom[li_cnt].SetRedraw(True)
  642. End If
  643. End If
  644. Next
  645. End If
  646. Return 1
  647. end function
  648. public function integer of_getextremepoint (integer ai_extremetype);//////////////////////////////////////////////////////////////////////////////
  649. //
  650. // Function: of_GetExtremePoint
  651. //
  652. // Access: Public
  653. //
  654. // Arguments:
  655. // ai_extremetype The extreme point desired. Valid values are:
  656. // LEFTMOST=1
  657. // RIGHTMOST=2
  658. // TOPMOST=3
  659. // BOTTOMMOST=4
  660. //
  661. // Returns: Integer
  662. // Returns the desired extreme point.
  663. //
  664. // Description: Get the desired extreme point coordinate. The coordinate is
  665. // the maximum or minimum point where the split bar can be
  666. // moved to.
  667. //
  668. //////////////////////////////////////////////////////////////////////////////
  669. Integer li_point
  670. Integer li_extremepoint
  671. Integer li_rc
  672. Integer li_cnt
  673. constant Integer LOW_VALUE = -999999
  674. constant Integer HIGH_VALUE = 999999
  675. CHOOSE CASE ai_extremetype
  676. CASE LEFTMOST
  677. // Initialize the extreme point.
  678. li_point = LOW_VALUE
  679. // Find the left most point.
  680. For li_cnt = 1 to UpperBound(idrg_lefttop)
  681. If IsValid(idrg_lefttop[li_cnt]) Then
  682. If idrg_lefttop[li_cnt].X > li_point Then
  683. li_point = idrg_lefttop[li_cnt].X
  684. End If
  685. End If
  686. Next
  687. // Take into account the the minimum object size.
  688. li_extremepoint = li_point + ii_minobjectsize
  689. CASE RIGHTMOST
  690. // Initialize the extreme point.
  691. li_point = HIGH_VALUE
  692. // Find the right most point.
  693. For li_cnt = 1 to UpperBound(idrg_rightbottom)
  694. If IsValid(idrg_rightbottom[li_cnt]) Then
  695. If idrg_rightbottom[li_cnt].X + idrg_rightbottom[li_cnt].Width < li_point Then
  696. li_point = idrg_rightbottom[li_cnt].X + idrg_rightbottom[li_cnt].Width
  697. End If
  698. End If
  699. Next
  700. // Take into account the split bar itself and the minimum object size.
  701. li_extremepoint = li_point - (ii_barwidth + ii_minobjectsize )
  702. CASE TOPMOST
  703. // Initialize the extreme point.
  704. li_point = LOW_VALUE
  705. // Find the top most point.
  706. For li_cnt = 1 to UpperBound(idrg_lefttop)
  707. If IsValid(idrg_lefttop[li_cnt]) Then
  708. If idrg_lefttop[li_cnt].Y > li_point Then
  709. li_point = idrg_lefttop[li_cnt].Y
  710. End If
  711. End If
  712. Next
  713. // Take into account the the minimum object size.
  714. li_extremepoint = li_point + ii_minobjectsize
  715. CASE BOTTOMMOST
  716. // Initialize the extreme point.
  717. li_point = HIGH_VALUE
  718. // Find the bottom most point.
  719. For li_cnt = 1 to UpperBound(idrg_rightbottom)
  720. If IsValid(idrg_rightbottom[li_cnt]) Then
  721. If idrg_rightbottom[li_cnt].Y + idrg_rightbottom[li_cnt].Height < li_point Then
  722. li_point = idrg_rightbottom[li_cnt].Y + idrg_rightbottom[li_cnt].Height
  723. End If
  724. End If
  725. Next
  726. // Take into account the split bar itself and the minimum object size.
  727. li_extremepoint = li_point - (ii_barwidth + ii_minobjectsize)
  728. CASE Else
  729. Return -1
  730. END CHOOSE
  731. // Make sure the initial value was replaced.
  732. If li_point = LOW_VALUE or li_point = HIGH_VALUE Then
  733. Return -1
  734. End If
  735. Return li_extremepoint
  736. end function
  737. public function integer of_setminobjectsize (integer ai_minsize);//////////////////////////////////////////////////////////////////////////////
  738. //
  739. // Function: of_SetMinObjectSize
  740. //
  741. // Access: Public
  742. //
  743. // Arguments:
  744. // ai_minsize The desired minimum object size for all registered objects.
  745. //
  746. // Returns: Integer
  747. // Returns 1 if it succeeds and?1 if an error occurs.
  748. //
  749. // Description:
  750. // Set the desired minimum object size for all registered objects.
  751. //
  752. //////////////////////////////////////////////////////////////////////////////
  753. // Validate the argument.
  754. If IsNull(ai_minsize) or ai_minsize < 0 Then
  755. Return -1
  756. End If
  757. ii_minobjectsize = ai_minsize
  758. Return 1
  759. end function
  760. public function integer of_getminobjectsize ();//////////////////////////////////////////////////////////////////////////////
  761. //
  762. // Function: of_GetMinObjectSize
  763. //
  764. // Access: Public
  765. //
  766. // Arguments: None
  767. //
  768. // Returns: Integer
  769. // The desired minimum object size for all registered objects.
  770. //
  771. // Description:
  772. // Gets the desired minimum object size for all registered objects.
  773. //
  774. //////////////////////////////////////////////////////////////////////////////
  775. Return ii_minobjectsize
  776. end function
  777. public function integer of_getbarcolor ();//////////////////////////////////////////////////////////////////////////////
  778. //
  779. // Function: of_GetBarColor
  780. //
  781. // Access: Public
  782. //
  783. // Arguments: None
  784. //
  785. // Returns: Integer
  786. // The non-moving Split Bar color.
  787. //
  788. // Description:
  789. // 得到分割条的值.
  790. //
  791. //////////////////////////////////////////////////////////////////////////////
  792. Return il_barcolor
  793. end function
  794. public function string of_gethorizontalpointer ();//////////////////////////////////////////////////////////////////////////////
  795. //
  796. // Function: of_GetHorizontalPointer
  797. //
  798. // Access: Public
  799. //
  800. // Arguments: None
  801. //
  802. // Returns: String
  803. // Returns the Horizontal Icon.
  804. //
  805. // Description:
  806. // Reports the Horizontal Icon.
  807. //
  808. //////////////////////////////////////////////////////////////////////////////
  809. Return is_horizontalpointer
  810. end function
  811. public function string of_getverticalpointer ();//////////////////////////////////////////////////////////////////////////////
  812. //
  813. // Function: of_GetVerticalPointer
  814. //
  815. // Access: Public
  816. //
  817. // Arguments: None
  818. //
  819. // Returns: String
  820. // Returns the Vertical Icon.
  821. //
  822. // Description:
  823. // Reports the Vertical Icon.
  824. //
  825. //////////////////////////////////////////////////////////////////////////////
  826. Return is_verticalpointer
  827. end function
  828. public function integer of_sethorizontalpointer (string as_icon);//////////////////////////////////////////////////////////////////////////////
  829. //
  830. // Function: of_SetHorizontalPointer
  831. //
  832. // Access: Public
  833. //
  834. // Arguments:
  835. // as_icon The desired icon.
  836. //
  837. // Returns: Integer
  838. // Returns 1 if it succeeds and?1 if an error occurs.
  839. //
  840. // Description: Set the Horizontal Icon.
  841. //
  842. //////////////////////////////////////////////////////////////////////////////
  843. Integer li_rc
  844. // Validate the argument.
  845. If IsNull(as_icon) Or Len(Trim(as_icon)) = 0 Then
  846. Return -1
  847. End If
  848. // Set the icon.
  849. is_horizontalpointer = as_icon
  850. If ii_style = HORIZONTAL Then
  851. this.Pointer = as_icon
  852. End If
  853. Return 1
  854. end function
  855. public function integer of_setverticalpointer (string as_icon);//////////////////////////////////////////////////////////////////////////////
  856. //
  857. // Function: of_SetVerticalPointer
  858. //
  859. // Access: Public
  860. //
  861. // Arguments:
  862. // as_icon The desired icon.
  863. //
  864. // Returns: Integer
  865. // Returns 1 if it succeeds and?1 if an error occurs.
  866. //
  867. // Description: Set the Vertical Icon.
  868. //
  869. //////////////////////////////////////////////////////////////////////////////
  870. Integer li_rc
  871. // Validate the argument.
  872. If IsNull(as_icon) Or Len(Trim(as_icon)) = 0 Then
  873. Return -1
  874. End If
  875. // Set the icon.
  876. is_verticalpointer = as_icon
  877. If ii_style = VERTICAL Then
  878. this.Pointer = as_icon
  879. End If
  880. Return 1
  881. end function
  882. public function integer of_getbarmovecolor ();//////////////////////////////////////////////////////////////////////////////
  883. //
  884. // Function: of_GetBarMoveColor
  885. //
  886. // Access: Public
  887. //
  888. // Arguments: None
  889. //
  890. // Returns: Integer
  891. // The moving Split Bar color.
  892. //
  893. // Description:
  894. // 得到移动条的背景颜色.
  895. //
  896. //////////////////////////////////////////////////////////////////////////////
  897. Return il_barmovecolor
  898. end function
  899. protected function boolean of_issupported ();//////////////////////////////////////////////////////////////////////////////
  900. //
  901. // Function: of_IsSupported
  902. //
  903. // Access: Public
  904. //
  905. // Arguments: None
  906. //
  907. // Returns: Boolean
  908. // True if running in a supported environment.
  909. //
  910. // Description:
  911. // Dtermines if object is running in a supported environment.
  912. //
  913. //////////////////////////////////////////////////////////////////////////////
  914. Environment lenv_object
  915. GetEnvironment (lenv_object)
  916. If lenv_object.ostype = Macintosh! Then
  917. Return False
  918. End If
  919. Return True
  920. end function
  921. public function integer of_reset ();Real lr_Empty[]
  922. DragObject ldo_Empty[]
  923. ii_lefttopbound = 0
  924. idrg_lefttop = ldo_Empty
  925. ir_lefttopx = lr_Empty
  926. ir_lefttopy = lr_Empty
  927. ir_lefttopwidth = lr_Empty
  928. ir_lefttopheight = lr_Empty
  929. ii_rightbottombound = 0
  930. idrg_rightbottom = ldo_Empty
  931. ir_rightbottomx = lr_Empty
  932. ir_rightbottomy = lr_Empty
  933. ir_rightbottomwidth = lr_Empty
  934. ir_rightbottomheight = lr_Empty
  935. Return 1
  936. end function
  937. public function integer uf_possplitbar (dragobject adrg_object);////////////////////////////////////////////////////
  938. //拖动条的与要定位的对象的空格
  939. //
  940. //--------------------------------------------------
  941. //
  942. //2000-3-17
  943. ////////////////////////////////////////////////////
  944. if ii_style = HORIZONTAL then
  945. if IsValid(adrg_object) then
  946. idrg_posh=adrg_object
  947. il_topspace=this.y - adrg_object.y - adrg_object.height
  948. end if
  949. elseif ii_style = VERTICAL then
  950. if IsValid(adrg_object) then
  951. idrg_posv=adrg_object
  952. il_leftspace=this.x - adrg_object.x - adrg_object.width
  953. end if
  954. end if
  955. return 1
  956. end function
  957. event constructor;//////////////////////////////////////////////////////////////////////////////
  958. //
  959. // Event: constructor
  960. //
  961. // Arguments: None.
  962. //
  963. // Returns: None.
  964. //
  965. // Description: SplitBar Object.
  966. // Initialize required information by the object.
  967. //
  968. // *Note: The Style and the Width (this.Width for a VerticalBar and this.Height
  969. // for a HorizontalBar) are not changeable past this point. For example,
  970. // an outside entity should not change this.Height for a HorizontalBar.
  971. //
  972. //////////////////////////////////////////////////////////////////////////////
  973. //
  974. // Revision History
  975. //
  976. // Version
  977. // 6.0 Initial version - Claudio J. Quant
  978. //
  979. //////////////////////////////////////////////////////////////////////////////
  980. //
  981. // Copyright ?1996 Sybase, Inc. and its subsidiaries. All rights reserved.
  982. // Any distribution of the PowerBuilder Foundation Classes (PFC)
  983. // source code by other than Sybase, Inc. and its subsidiaries is prohibited.
  984. //
  985. //////////////////////////////////////////////////////////////////////////////
  986. powerobject lpo_parent
  987. // Determine if this object is supported.
  988. ib_supported = of_IsSupported()
  989. // Defined the object to be on Top of other objects.
  990. this.SetPosition(ToTop!)
  991. // Set the object to the Non-Moving Split bar color.
  992. this.BackColor = il_barcolor
  993. // Get and store the parent object.
  994. lpo_parent = this.GetParent()
  995. CHOOSE CASE lpo_parent.TypeOf()
  996. CASE Window!
  997. iw_parent = lpo_parent
  998. CASE UserObject!
  999. iuo_parent = lpo_parent
  1000. CASE Tab!
  1001. itab_parent = lpo_parent
  1002. END CHOOSE
  1003. If ib_supported Then
  1004. // Determine object attributes by looking at the object size.
  1005. If this.Height >= this.Width Then
  1006. ii_style = VERTICAL
  1007. this.Pointer = is_verticalpointer
  1008. ii_barwidth = this.Width
  1009. Else
  1010. ii_style = HORIZONTAL
  1011. this.Pointer = is_horizontalpointer
  1012. ii_barwidth = this.Height
  1013. End If
  1014. Else
  1015. // Since it is not supported - hide the object.
  1016. this.Enabled = False
  1017. this.Visible = False
  1018. this.Resize(0,0)
  1019. End If
  1020. end event
  1021. on u_lbs_stsplitbar.create
  1022. end on
  1023. on u_lbs_stsplitbar.destroy
  1024. end on