uo_tlbar.sru 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367
  1. $PBExportHeader$uo_tlbar.sru
  2. $PBExportComments$ToolBar 用户对象
  3. forward
  4. global type uo_tlbar from UserObject
  5. end type
  6. type uo_topline from uo_tlbar_menuseperator within uo_tlbar
  7. end type
  8. type uo_bottomline from uo_tlbar_menuseperator within uo_tlbar
  9. end type
  10. type ln_2 from line within uo_tlbar
  11. end type
  12. type ln_4 from line within uo_tlbar
  13. end type
  14. type ln_3 from line within uo_tlbar
  15. end type
  16. type ln_1 from line within uo_tlbar
  17. end type
  18. end forward
  19. global type uo_tlbar from UserObject
  20. int Width=2386
  21. int Height=200
  22. boolean Border=true
  23. long BackColor=67108864
  24. long PictureMaskColor=536870912
  25. long TabTextColor=33554432
  26. long TabBackColor=67108864
  27. event ue_paint pbm_paint
  28. uo_topline uo_topline
  29. uo_bottomline uo_bottomline
  30. ln_2 ln_2
  31. ln_4 ln_4
  32. ln_3 ln_3
  33. ln_1 ln_1
  34. end type
  35. global uo_tlbar uo_tlbar
  36. type variables
  37. Public:
  38. string TextAlign ='Right' //Right,None
  39. integer Picture_Size = 16
  40. protectedwrite uo_tlbar_button iuo_buttons[]
  41. Protected:
  42. uo_tlbar_space iuo_spaces[]
  43. window iw_parent
  44. long ButtonHeight
  45. long Minwidth
  46. long il_space = 3
  47. end variables
  48. forward prototypes
  49. public subroutine of_readmenu (readonly menu am_menu)
  50. public subroutine of_getparentwin ()
  51. public subroutine of_setalign (string as_align)
  52. public subroutine of_setsize ()
  53. public subroutine of_setposition ()
  54. public subroutine of_draw ()
  55. public subroutine of_showbottom ()
  56. public subroutine of_minwidth ()
  57. public subroutine of_hidebottom ()
  58. public subroutine of_redraw ()
  59. public subroutine of_setbuttonsize (integer ai_size)
  60. public subroutine of_setpicturesize (integer ai_size)
  61. public subroutine of_resize ()
  62. public subroutine of_bott ()
  63. public subroutine of_read (string s_align)
  64. end prototypes
  65. event ue_paint;integer li_loop
  66. FOR li_loop = 1 TO upperbound(iuo_buttons)
  67. IF NOT iuo_buttons[li_loop].enabled THEN
  68. iuo_buttons[li_loop].of_drawdisabled()
  69. END IF
  70. NEXT
  71. end event
  72. public subroutine of_readmenu (readonly menu am_menu);long ll_beginx,ll_btnheight
  73. integer li_btnpos,li_spacepos
  74. menu lm_submenu,lm_menu
  75. IF isvalid (am_menu) = false THEN
  76. //Not a valid menu , hide toolbar.
  77. this.hide()
  78. RETURN
  79. ELSE
  80. setredraw(false)
  81. integer li_menucnt,li_loop,li_loop2
  82. li_menucnt = UpperBound(am_menu.item)
  83. ll_beginx =this.x+ 40
  84. FOR li_loop = 1 TO li_menucnt
  85. lm_submenu = am_menu.item[li_loop] //sub menu
  86. FOR li_loop2 =1 TO UpperBound(lm_submenu.item)
  87. lm_menu = lm_submenu.item[li_loop2] //menu
  88. IF lm_menu.text = '-' THEN CONTINUE
  89. if trim(String(lm_menu.ToolbarItemName))='' or lm_menu.toolbaritemvisible=false then
  90. continue
  91. end if
  92. IF lm_menu.ToolbarItemSpace > 0 then
  93. li_spacepos = upperbound(iuo_spaces) + 1
  94. iw_parent.openuserobject(iuo_spaces[li_spacepos],ll_beginx, this.y + 10)
  95. iw_parent.control[Upperbound(iw_parent.control)+1] = iuo_spaces[li_spacepos]
  96. ll_beginx = ll_beginx + iuo_spaces[li_spacepos].width + il_space
  97. END IF
  98. li_btnpos = Upperbound(iuo_buttons)+1
  99. iw_parent.openuserobject(iuo_buttons[li_btnpos],ll_beginx,this.y + 10)
  100. iuo_buttons[li_btnpos].ButtonText = trim(lm_menu.ToolbarItemText)
  101. iuo_buttons[li_btnpos].TextAlign = TextAlign
  102. iuo_buttons[li_btnpos].ToolTip = trim(lm_menu.MicroHelp)
  103. iuo_buttons[li_btnpos].enabled = lm_menu.Enabled
  104. iuo_buttons[li_btnpos].Picture_Name = String(lm_menu.ToolbarItemName)
  105. iuo_buttons[li_btnpos].Picture_size = Picture_size
  106. iuo_buttons[li_btnpos].Bringtotop = true
  107. iuo_buttons[li_btnpos].visible = this.visible
  108. iuo_buttons[li_btnpos].of_setparent(this)
  109. iuo_buttons[li_btnpos].of_setmenu(lm_menu)
  110. iuo_buttons[li_btnpos].triggerevent('Constructor')
  111. ll_beginx = ll_beginx + iuo_buttons[li_btnpos].width + il_space
  112. IF iuo_buttons[li_btnpos].height>ll_btnheight THEN ll_btnheight = iuo_buttons[li_btnpos].height
  113. IF lower(lm_menu.tag) = 'checked' THEN
  114. // IF lm_menu.checked = true THEN
  115. iuo_buttons[li_btnpos].ButtonType = 'Checked'
  116. IF lm_menu.checked THEN iuo_buttons[li_btnpos].of_checked()
  117. ELSEIF left(lower(lm_menu.tag),10) = 'radiogroup' THEN
  118. iuo_buttons[li_btnpos].ButtonType = 'RadioButton'
  119. iuo_buttons[li_btnpos].of_setgroup(integer(mid(lm_menu.tag,11)))
  120. IF lm_menu.checked THEN iuo_buttons[li_btnpos].of_checked()
  121. END IF
  122. IF lm_menu.ToolbarItemSpace > 0 THEN
  123. iuo_spaces[li_spacepos].height = iuo_buttons[li_btnpos].height - 10
  124. iuo_spaces[li_spacepos].bringtotop = true
  125. END IF
  126. iw_parent.control[Upperbound(iw_parent.control)+1] = iuo_buttons[li_btnpos]
  127. NEXT
  128. NEXT
  129. setredraw(true)
  130. END IF
  131. ButtonHeight = ll_btnheight
  132. MinWidth = ll_beginx - this.x
  133. of_setsize()
  134. of_setposition()
  135. end subroutine
  136. public subroutine of_getparentwin ();powerobject lpo_tmp
  137. userobject luo_tmp
  138. lpo_tmp = this.getparent()
  139. DO While lpo_tmp.typeof() <> Window!
  140. luo_tmp = lpo_tmp
  141. lpo_tmp= luo_tmp.getparent()
  142. LOOP
  143. iw_parent = lpo_tmp
  144. end subroutine
  145. public subroutine of_setalign (string as_align);IF TextAlign = as_align THEN RETURN
  146. IF pos('Right;None;',as_align)>0 THEN
  147. TextAlign = as_align
  148. IF TextAlign='None' THEN uo_bottomline.visible = false
  149. ELSE
  150. TextAlign = 'Bottom'
  151. END IF
  152. integer li_loop,li_loop2
  153. long ll_beginx
  154. ll_beginx = this.x + 40
  155. IF upperbound(iuo_buttons)>0 THEN
  156. ButtonHeight = 0
  157. Minwidth = 0
  158. FOR li_loop = 1 TO upperbound(iuo_buttons)
  159. iuo_buttons[li_loop].of_setalign(TextAlign)
  160. iuo_buttons[li_loop].y = this.y + 10
  161. IF iuo_buttons[li_loop].of_getmenu().ToolbarItemSpace>0 THEN
  162. li_loop2 ++
  163. iuo_spaces[li_loop2].x = ll_beginx
  164. iuo_spaces[li_loop2].y = this.y + 10
  165. iuo_spaces[li_loop2].height = iuo_buttons[li_loop].height - 10
  166. ll_beginx = ll_beginx + iuo_spaces[li_loop2].width + il_space
  167. END IF
  168. iuo_buttons[li_loop].x = ll_beginx
  169. ll_beginx = ll_beginx + iuo_buttons[li_loop].width + il_space
  170. IF iuo_buttons[li_loop].height>ButtonHeight THEN ButtonHeight = iuo_buttons[li_loop].height
  171. NEXT
  172. Minwidth = ll_beginx - this.x
  173. END IF
  174. of_SetSize()
  175. of_SetPosition()
  176. end subroutine
  177. public subroutine of_setsize ();IF upperbound(iuo_buttons)=0 THEN RETURN
  178. IF this.width < minwidth THEN this.width = minwidth
  179. CHOOSE CASE TextAlign
  180. CASE 'Bottom'
  181. this.height = ButtonHeight + 25
  182. uo_Bottomline.visible = true
  183. CASE 'Right'
  184. this.height = ButtonHeight + 25
  185. uo_Bottomline.visible = true
  186. CASE 'None'
  187. this.height = ButtonHeight + 25
  188. END CHOOSE
  189. ln_1.endy = height - 20
  190. ln_2.endy = height - 20
  191. ln_3.endy = height - 20
  192. ln_4.endy = height - 20
  193. //uo_topline.width = width+900//+900 zkl加上
  194. //uo_bottomline.width = width+900
  195. end subroutine
  196. public subroutine of_setposition ();IF upperbound(iuo_buttons)=0 THEN RETURN
  197. uo_bottomline.y = this.height - 10
  198. end subroutine
  199. public subroutine of_draw ();of_setalign(TextAlign)
  200. of_setsize()
  201. of_setposition()
  202. end subroutine
  203. public subroutine of_showbottom ();of_setsize()
  204. of_setposition()
  205. uo_bottomline.visible = true
  206. end subroutine
  207. public subroutine of_minwidth ();this.width = minwidth
  208. end subroutine
  209. public subroutine of_hidebottom ();uo_bottomline.visible = false
  210. end subroutine
  211. public subroutine of_redraw ();
  212. end subroutine
  213. public subroutine of_setbuttonsize (integer ai_size);IF ai_size = 24 THEN
  214. Picture_Size = 24
  215. ELSE
  216. picture_size = 16
  217. END IF
  218. end subroutine
  219. public subroutine of_setpicturesize (integer ai_size);IF ai_size = 24 THEN
  220. Picture_Size = 24
  221. ELSE
  222. picture_size = 16
  223. END IF
  224. end subroutine
  225. public subroutine of_resize ();IF iw_parent.windowstate <> Minimized! THEN
  226. this.width = iw_parent.width -20
  227. of_setsize()
  228. END IF
  229. end subroutine
  230. public subroutine of_bott ();of_read('Bottom')
  231. end subroutine
  232. public subroutine of_read (string s_align);of_setalign(s_align)
  233. of_readmenu(iw_parent.menuid)
  234. end subroutine
  235. on uo_tlbar.create
  236. this.uo_topline=create uo_topline
  237. this.uo_bottomline=create uo_bottomline
  238. this.ln_2=create ln_2
  239. this.ln_4=create ln_4
  240. this.ln_3=create ln_3
  241. this.ln_1=create ln_1
  242. this.Control[]={this.uo_topline,&
  243. this.uo_bottomline,&
  244. this.ln_2,&
  245. this.ln_4,&
  246. this.ln_3,&
  247. this.ln_1}
  248. end on
  249. on uo_tlbar.destroy
  250. destroy(this.uo_topline)
  251. destroy(this.uo_bottomline)
  252. destroy(this.ln_2)
  253. destroy(this.ln_4)
  254. destroy(this.ln_3)
  255. destroy(this.ln_1)
  256. end on
  257. event constructor;of_getparentwin()
  258. backcolor=iw_parent.backcolor
  259. width=6000
  260. end event
  261. type uo_topline from uo_tlbar_menuseperator within uo_tlbar
  262. int X=0
  263. int Y=0
  264. int Width=5207
  265. int TabOrder=10
  266. long BackColor=80269524
  267. end type
  268. on uo_topline.destroy
  269. call uo_tlbar_menuseperator::destroy
  270. end on
  271. type uo_bottomline from uo_tlbar_menuseperator within uo_tlbar
  272. int X=0
  273. int Y=176
  274. int Width=5202
  275. int TabOrder=20
  276. boolean Visible=false
  277. end type
  278. on uo_bottomline.destroy
  279. call uo_tlbar_menuseperator::destroy
  280. end on
  281. type ln_2 from line within uo_tlbar
  282. boolean Enabled=false
  283. int BeginX=14
  284. int BeginY=20
  285. int EndX=14
  286. int EndY=168
  287. int LineThickness=4
  288. long LineColor=8421504
  289. end type
  290. type ln_4 from line within uo_tlbar
  291. boolean Enabled=false
  292. int BeginX=27
  293. int BeginY=20
  294. int EndX=27
  295. int EndY=168
  296. int LineThickness=4
  297. long LineColor=8421504
  298. end type
  299. type ln_3 from line within uo_tlbar
  300. boolean Enabled=false
  301. int BeginX=23
  302. int BeginY=20
  303. int EndX=23
  304. int EndY=168
  305. int LineThickness=4
  306. long LineColor=16777215
  307. end type
  308. type ln_1 from line within uo_tlbar
  309. boolean Enabled=false
  310. int BeginX=9
  311. int BeginY=20
  312. int EndX=9
  313. int EndY=168
  314. int LineThickness=8
  315. long LineColor=31910120
  316. end type