$PBExportHeader$uo_toolbar.sru $PBExportComments$Simple ToolBar forward global type uo_toolbar from userobject end type type uo_topline from uo_toolbar_menuseperator within uo_toolbar end type type uo_bottomline from uo_toolbar_menuseperator within uo_toolbar end type type ln_2 from line within uo_toolbar end type type ln_4 from line within uo_toolbar end type type ln_3 from line within uo_toolbar end type type ln_1 from line within uo_toolbar end type end forward global type uo_toolbar from userobject integer width = 2386 integer height = 200 boolean border = true long backcolor = 67108864 long tabtextcolor = 33554432 long picturemaskcolor = 536870912 event ue_paint pbm_paint uo_topline uo_topline uo_bottomline uo_bottomline ln_2 ln_2 ln_4 ln_4 ln_3 ln_3 ln_1 ln_1 end type global uo_toolbar uo_toolbar type variables Public: string TextAlign ='Right' //Right,None integer Picture_Size = 32 protectedwrite uo_toolbar_button iuo_buttons[] Protected: uo_toolbar_space iuo_spaces[] window iw_parent integer ButtonCnt long ButtonHeight long Minwidth long il_space = 3 end variables forward prototypes public subroutine of_readmenu (readonly menu am_menu) public subroutine of_getparentwin () public subroutine of_setalign (string as_align) public subroutine of_setsize () public subroutine of_setposition () public subroutine of_draw () public subroutine of_showbottom () public subroutine of_minwidth () public subroutine of_hidebottom () public subroutine of_setbuttonsize (integer ai_size) public subroutine of_setenabled (integer ai_index, boolean ab_enabled) public subroutine of_setenabled (menu am_menu, boolean ab_enabled) public subroutine of_resize () public function boolean of_getenabled (integer ai_index) public function boolean of_getenabled (menu am_menu) end prototypes event ue_paint;integer li_loop FOR li_loop = 1 TO upperbound(iuo_buttons) IF NOT iuo_buttons[li_loop].enabled THEN iuo_buttons[li_loop].of_drawdisabled() END IF NEXT end event public subroutine of_readmenu (readonly menu am_menu);long ll_beginx,ll_btnheight integer li_btnpos,li_spacepos string ls_bitmapFilename menu lm_submenu,lm_menu IF isvalid (am_menu) = false THEN //Not a valid menu , hide toolbar. this.hide() ELSE integer li_menucnt,li_loop,li_loop2 li_menucnt = UpperBound(am_menu.item) ll_beginx =this.x+ 40 FOR li_loop = 1 TO li_menucnt lm_submenu = am_menu.item[li_loop] //sub menu FOR li_loop2 =1 TO UpperBound(lm_submenu.item) lm_menu = lm_submenu.item[li_loop2] //menu ls_bitmapFilename = lm_menu.ToolbarItemName IF lm_menu.ToolbarItemSpace > 0 then li_spacepos = upperbound(iuo_spaces) + 1 iw_parent.openuserobject(iuo_spaces[li_spacepos],ll_beginx, this.y + 10) iw_parent.control[Upperbound(iw_parent.control)+1] = iuo_spaces[li_spacepos] iuo_spaces[li_spacepos].backcolor = iw_parent.backcolor ll_beginx = ll_beginx + iuo_spaces[li_spacepos].width + il_space END IF li_btnpos = Upperbound(iuo_buttons)+1 IF ls_bitmapFilename <> "" THEN iw_parent.openuserobject(iuo_buttons[li_btnpos],ll_beginx,this.y + 10) ELSE CONTINUE END IF iuo_buttons[li_btnpos].ButtonText = trim(lm_menu.ToolbarItemText) iuo_buttons[li_btnpos].TextAlign = TextAlign iuo_buttons[li_btnpos].ToolTip = trim(lm_menu.MicroHelp) iuo_buttons[li_btnpos].enabled = lm_menu.Enabled iuo_buttons[li_btnpos].Picture_Name = ls_bitmapfilename iuo_buttons[li_btnpos].Picture_size = Picture_size iuo_buttons[li_btnpos].Bringtotop = true iuo_buttons[li_btnpos].visible = this.visible iuo_buttons[li_btnpos].of_setparent(this) iuo_buttons[li_btnpos].of_setmenu(lm_menu) iuo_buttons[li_btnpos].of_setbkcolor(this.backcolor) IF UpperBound(lm_menu.item)>0 THEN iuo_buttons[li_btnpos].of_childmenu(true) END IF iuo_buttons[li_btnpos].triggerevent('Constructor') ll_beginx = ll_beginx + iuo_buttons[li_btnpos].width + il_space IF iuo_buttons[li_btnpos].height>ll_btnheight THEN ll_btnheight = iuo_buttons[li_btnpos].height IF lower(lm_menu.tag) = 'checked' THEN iuo_buttons[li_btnpos].ButtonType = 'Checked' IF lm_menu.checked THEN iuo_buttons[li_btnpos].of_checked() ELSEIF left(lower(lm_menu.tag),10) = 'radiogroup' THEN iuo_buttons[li_btnpos].ButtonType = 'RadioButton' iuo_buttons[li_btnpos].of_setgroup(integer(mid(lm_menu.tag,11))) IF lm_menu.checked THEN iuo_buttons[li_btnpos].of_checked() END IF IF lm_menu.ToolbarItemSpace > 0 THEN iuo_spaces[li_spacepos].height = iuo_buttons[li_btnpos].height - 10 iuo_spaces[li_spacepos].bringtotop = true END IF iw_parent.control[Upperbound(iw_parent.control)+1] = iuo_buttons[li_btnpos] NEXT NEXT END IF ButtonHeight = ll_btnheight MinWidth = ll_beginx - this.x of_setsize() of_setposition() end subroutine public subroutine of_getparentwin ();powerobject lpo_tmp userobject luo_tmp lpo_tmp = this.getparent() DO While lpo_tmp.typeof() <> Window! luo_tmp = lpo_tmp lpo_tmp= luo_tmp.getparent() LOOP iw_parent = lpo_tmp end subroutine public subroutine of_setalign (string as_align);IF TextAlign = as_align THEN RETURN IF pos('Right;None;',as_align)>0 THEN TextAlign = as_align IF TextAlign='None' THEN uo_bottomline.visible = false ELSE TextAlign = 'Bottom' END IF integer li_loop,li_loop2 long ll_beginx ll_beginx = this.x + 40 IF upperbound(iuo_buttons)>0 THEN ButtonHeight = 0 Minwidth = 0 FOR li_loop = 1 TO upperbound(iuo_buttons) iuo_buttons[li_loop].of_setalign(TextAlign) iuo_buttons[li_loop].y = this.y + 10 IF iuo_buttons[li_loop].of_getmenu().ToolbarItemSpace>0 THEN li_loop2 ++ iuo_spaces[li_loop2].x = ll_beginx iuo_spaces[li_loop2].y = this.y + 10 iuo_spaces[li_loop2].height = iuo_buttons[li_loop].height - 10 ll_beginx = ll_beginx + iuo_spaces[li_loop2].width + il_space END IF iuo_buttons[li_loop].x = ll_beginx ll_beginx = ll_beginx + iuo_buttons[li_loop].width + il_space IF iuo_buttons[li_loop].height>ButtonHeight THEN ButtonHeight = iuo_buttons[li_loop].height NEXT Minwidth = ll_beginx - this.x END IF of_SetSize() of_SetPosition() end subroutine public subroutine of_setsize ();IF this.width < minwidth THEN this.width = minwidth CHOOSE CASE TextAlign CASE 'Bottom' this.height = ButtonHeight + 25 uo_Bottomline.visible = true CASE 'Right' this.height = ButtonHeight + 25 uo_Bottomline.visible = true CASE 'None' this.height = ButtonHeight + 25 END CHOOSE ln_1.endy = this.height - 20 ln_2.endy = this.height - 20 ln_3.endy = this.height - 20 ln_4.endy = this.height - 20 uo_topline.width = this.width uo_bottomline.width = this.width end subroutine public subroutine of_setposition ();uo_bottomline.y = this.height - 10 end subroutine public subroutine of_draw ();of_setalign(TextAlign) of_setsize() of_setposition() end subroutine public subroutine of_showbottom ();of_setsize() of_setposition() uo_bottomline.visible = true end subroutine public subroutine of_minwidth ();this.width = minwidth end subroutine public subroutine of_hidebottom ();uo_bottomline.visible = false end subroutine public subroutine of_setbuttonsize (integer ai_size);IF ai_size = 24 THEN Picture_Size = 24 ELSE picture_size = 16 END IF end subroutine public subroutine of_setenabled (integer ai_index, boolean ab_enabled);IF ai_index > 0 THEN iuo_buttons[ai_index].of_enabled( ab_enabled ) iuo_buttons[ai_index].of_enabledmenu(ab_enabled) END IF end subroutine public subroutine of_setenabled (menu am_menu, boolean ab_enabled);integer li_index IF am_menu.enabled = ab_enabled THEN RETURN ELSE am_menu.enabled = ab_enabled FOR li_index = 1 TO upperbound(iuo_buttons) IF iuo_buttons[li_index].of_getmenu() = am_menu THEN iuo_buttons[li_index].of_enabled(ab_enabled) EXIT END IF END FOR END IF end subroutine public subroutine of_resize ();IF this.width < minwidth THEN this.width = minwidth CHOOSE CASE TextAlign CASE 'Bottom' this.height = ButtonHeight + 25 uo_Bottomline.visible = true CASE 'Right' this.height = ButtonHeight + 25 uo_Bottomline.visible = true CASE 'None' this.height = ButtonHeight + 25 END CHOOSE ln_1.endy = this.height - 20 ln_2.endy = this.height - 20 ln_3.endy = this.height - 20 ln_4.endy = this.height - 20 uo_topline.width = this.width uo_bottomline.width = this.width end subroutine public function boolean of_getenabled (integer ai_index);IF ai_index > 0 THEN return iuo_buttons[ai_index].enabled END IF return false end function public function boolean of_getenabled (menu am_menu);return am_menu.enabled end function on uo_toolbar.create this.uo_topline=create uo_topline this.uo_bottomline=create uo_bottomline this.ln_2=create ln_2 this.ln_4=create ln_4 this.ln_3=create ln_3 this.ln_1=create ln_1 this.Control[]={this.uo_topline,& this.uo_bottomline,& this.ln_2,& this.ln_4,& this.ln_3,& this.ln_1} end on on uo_toolbar.destroy destroy(this.uo_topline) destroy(this.uo_bottomline) destroy(this.ln_2) destroy(this.ln_4) destroy(this.ln_3) destroy(this.ln_1) end on event constructor;of_getparentwin() this.backcolor = iw_parent.backcolor end event type uo_topline from uo_toolbar_menuseperator within uo_toolbar integer width = 2208 integer taborder = 10 end type on uo_topline.destroy call uo_toolbar_menuseperator::destroy end on type uo_bottomline from uo_toolbar_menuseperator within uo_toolbar boolean visible = false integer y = 176 integer width = 2203 integer taborder = 20 end type on uo_bottomline.destroy call uo_toolbar_menuseperator::destroy end on type ln_2 from line within uo_toolbar long linecolor = 8421504 integer linethickness = 4 integer beginx = 14 integer beginy = 20 integer endx = 14 integer endy = 168 end type type ln_4 from line within uo_toolbar long linecolor = 8421504 integer linethickness = 4 integer beginx = 27 integer beginy = 20 integer endx = 27 integer endy = 168 end type type ln_3 from line within uo_toolbar long linecolor = 16777215 integer linethickness = 4 integer beginx = 23 integer beginy = 20 integer endx = 23 integer endy = 168 end type type ln_1 from line within uo_toolbar long linecolor = 31910120 integer linethickness = 8 integer beginx = 9 integer beginy = 20 integer endx = 9 integer endy = 168 end type