u_lbs_stsplitbar.sru 33 KB

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