123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387 |
- $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
|