$PBExportHeader$uo_button.sru
forward
global type uo_button from userobject
end type
type pic from picture within uo_button
end type
type txt from statictext within uo_button
end type
type pb_1 from picturebutton within uo_button
end type
end forward

global type uo_button from userobject
integer width = 599
integer height = 200
long backcolor = 67108864
string text = "none"
long tabtextcolor = 33554432
long picturemaskcolor = 536870912
event helpedit ( )
event clicked pbm_bnclicked
event ue_settop ( )
event ue_canceltop ( )
pic pic
txt txt
pb_1 pb_1
end type
global uo_button uo_button

type variables
String picname
string label
string ins_msgid

String menuevent
window ins_parentwindow
Boolean ins_istop
end variables

forward prototypes
public function boolean uf_ifmenubutton ()
end prototypes

event helpedit();IF ins_msgid <> "" THEN
	s_kms_msg s_rslt
	s_rslt = kms_GetKMS_MSG(ins_msgid,"","","","","")
	IF s_rslt.doccode1 <> "" THEN
		kms_editdoc(s_rslt.doccode1)
	END IF
END IF
end event

event clicked;IF uf_ifmenubutton() AND menuevent <> "" THEN
	w_menugroup lw_mg
	lw_mg = ins_parentwindow
	lw_mg.wf_handleevent(menuevent)
END IF
end event

event ue_settop();IF uf_ifmenubutton() THEN
	w_menugroup lw_mg
	lw_mg = ins_parentwindow
	lw_mg.wf_settop(this)
END IF
end event

event ue_canceltop();IF uf_ifmenubutton() THEN
	w_menugroup lw_mg
	lw_mg = ins_parentwindow
	lw_mg.wf_canceltop(this)
END IF
end event

public function boolean uf_ifmenubutton ();IF IsValid(ins_parentwindow) AND NOT IsNull(ins_parentwindow) THEN
	IF ins_parentwindow.classname() = "w_menugroup" THEN
		RETURN TRUE
	END IF
END IF

RETURN false
end function

on uo_button.create
this.pic=create pic
this.txt=create txt
this.pb_1=create pb_1
this.Control[]={this.pic,&
this.txt,&
this.pb_1}
end on

on uo_button.destroy
destroy(this.pic)
destroy(this.txt)
destroy(this.pb_1)
end on

event constructor;Int li_picmargin
li_picmargin = 30


pb_1.width = width
pb_1.height = height

pic.picturename = picname
pic.Y = height / 4
pic.X = li_picmargin + 16
pic.height = height - 16*2
pic.height = height / 2

long ll_heightpx
ll_heightpx = unitstopixels(pic.height, yunitstopixels!)
pic.width = pixelstounits(ll_heightpx,xpixelstounits!)
IF pic.picturename = "" THEN
	pic.visible = false
END IF

Int li_textpadding
li_textpadding = 10
txt.Text = label
IF pic.visible THEN
	txt.X = pic.X+pic.width + li_picmargin
ELSE
	txt.X = 16+li_textpadding
END IF

txt.width = width - txt.x - 16 - li_textpadding
txt.Y = 16 + li_textpadding
txt.height = height - txt.Y - 16 - li_textpadding
end event

event rbuttondown;IF ins_msgid <> "" THEN
	String ls_tooltips, ls_doccode
	s_kms_msg s_rslt
	s_rslt = kms_GetKMS_MSG(ins_msgid,"","","","","")
	ls_tooltips = s_rslt.msg
	ls_doccode = s_rslt.doccode1
	
	
	string ls_help, ls_helpedit
	IF ls_doccode <> "" THEN
		ls_help = "help"
		ls_helpedit = "helpedit"
	END IF
	
	String menustr
	IF ls_tooltips <> "" THEN
		IF menustr <> "" THEN menustr += "|"
		menustr+= "Text="+ls_tooltips+"~tEvent="
	END IF
	IF menustr <> "" THEN menustr += "|"
	menustr += "Text=帮助~tEvent="+ls_help+"~tParm=ControlEvent"
	//IF f_power_ind(6431,sys_msg_pow) THEN
	//	IF menustr <> "" THEN menustr += "|"
	//	menustr +=  "Text=编辑帮助~tEvent="+ls_helpedit+"~tParm=ControlEvent"
	//END IF
END IF

IF uf_ifmenubutton() THEN
	IF menustr <> "" THEN menustr += "|"
	IF ins_istop THEN
		menustr +=  "Text=取消置顶~tEvent=ue_canceltop"
	ELSE
		menustr +=  "Text=置顶~tEvent=ue_settop"
	END IF
END IF

If Len(Trim(menustr)) <> 0 Then
	m_Dfc_Control_PopupMenu dmPopupMenu
	dmPopupMenu = Create m_Dfc_Control_PopupMenu
	dmPopupMenu.mf_BuildMenu(This, menustr)
	IF IsValid(ins_parentwindow) THEN
		dmPopupMenu.mf_PopMenu(ins_parentwindow)
	ELSE
		dmPopupMenu.mf_PopMenu()
	END IF
	Destroy dmPopupMenu
End If
end event

event help;IF ins_msgid <> "" THEN
	s_kms_msg s_rslt
	s_rslt = kms_GetKMS_MSG(ins_msgid,"","","","","")
	IF s_rslt.doccode1 <> "" THEN
		kms_showdoc(s_rslt.doccode1)
	END IF
END IF
end event

type pic from picture within uo_button
integer x = 18
integer y = 16
integer width = 201
integer height = 168
boolean focusrectangle = false
end type

event rbuttondown;parent.event post rbuttondown(flags,xpos,ypos)
end event

event clicked;parent.event post clicked()
end event

type txt from statictext within uo_button
integer x = 215
integer y = 16
integer width = 370
integer height = 168
integer textsize = -9
integer weight = 400
fontcharset fontcharset = gb2312charset!
fontpitch fontpitch = variable!
string facename = "宋体"
long textcolor = 33554432
boolean focusrectangle = false
end type

event rbuttondown;parent.event post rbuttondown(flags,xpos,ypos)
end event

event clicked;parent.event post clicked()
end event

type pb_1 from picturebutton within uo_button
integer width = 599
integer height = 200
integer taborder = 10
integer textsize = -12
integer weight = 400
fontcharset fontcharset = ansi!
fontpitch fontpitch = variable!
fontfamily fontfamily = swiss!
string facename = "Arial"
boolean originalsize = true
alignment htextalign = left!
end type

event rbuttondown;parent.event post rbuttondown(flags,xpos,ypos)
end event

event clicked;parent.event post clicked()
end event

