123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631 |
- $PBExportHeader$uo_tlbar_button.sru
- $PBExportComments$ToolBar 用户对象
- forward
- global type uo_tlbar_button from userobject
- end type
- type plb_1 from picturelistbox within uo_tlbar_button
- end type
- type ln_bottom from line within uo_tlbar_button
- end type
- type ln_top from line within uo_tlbar_button
- end type
- type ln_left from line within uo_tlbar_button
- end type
- type ln_right from line within uo_tlbar_button
- end type
- type st_caption from statictext within uo_tlbar_button
- end type
- type rect from structure within uo_tlbar_button
- end type
- end forward
- type rect from structure
- long left
- long top
- long right
- long bottom
- end type
- shared variables
- nvo_tltips inv_tltips
- end variables
- global type uo_tlbar_button from userobject
- integer width = 320
- integer height = 212
- long backcolor = 80269524
- long tabtextcolor = 33554432
- long picturemaskcolor = 536870912
- event ue_lbuttonup pbm_lbuttonup
- event ue_lbuttondown pbm_lbuttondown
- event ue_mousemove pbm_mousemove
- event clicked ( )
- event ue_paint pbm_paint
- plb_1 plb_1
- ln_bottom ln_bottom
- ln_top ln_top
- ln_left ln_left
- ln_right ln_right
- st_caption st_caption
- end type
- global uo_tlbar_button uo_tlbar_button
- type prototypes
- FUNCTION ulong SetCapture(ulong hwnd) library "user32.dll"
- FUNCTION boolean ReleaseCapture() library "user32.dll"
- FUNCTION ulong SleepEx(ulong dwMilliseconds,ulong bAlertable) LIBRARY "kernel32.dll"
- FUNCTION ulong DrawFocusRect(ulong hdc,ref RECT lpRect) LIBRARY "user32.dll" alias for "DrawFocusRect;Ansi"
- FUNCTION ulong SetRect(ref RECT lpRect,ulong X1,ulong Y1,ulong X2,ulong Y2) LIBRARY "user32.dll" alias for "SetRect;Ansi"
- FUNCTION ulong GetDC(ulong hwnd) LIBRARY "user32.dll"
- FUNCTION ulong DrawText(ulong hdc,ref string lpStr,ulong nCount,ref RECT lpRect,ulong wFormat) LIBRARY "user32.dll" ALIAS FOR "DrawTextA;Ansi"
- FUNCTION ulong SelectObject(ulong hdc,ulong hObject) LIBRARY "gdi32.dll"
- FUNCTION ulong SetTextColor(ulong hdc,ulong crColor) LIBRARY "gdi32.dll"
- FUNCTION ulong GetSysColor(ulong nIndex) LIBRARY "user32.dll"
- FUNCTION ulong SetBkColor(ulong hdc,ulong crColor) LIBRARY "gdi32.dll"
- FUNCTION ulong SetBkMode(ulong hdc,ulong nBkMode) LIBRARY "gdi32.dll"
- FUNCTION ulong DeleteObject(ulong hObject) LIBRARY "gdi32.dll"
- //获取整个窗口(包括边框、滚动条、标题栏、菜单等)的设备场景
- FUNCTION ulong GetWindowDC(ulong hwnd) LIBRARY "user32.dll"
- //创建一幅与设备有关位图,它与指定的设备场景兼容
- FUNCTION ulong CreateCompatibleBitmap(ulong hdc,ulong nWidth,ulong nHeight) LIBRARY "gdi32.dll"
- //创建一个与特定设备场景一致的内存设备场景
- FUNCTION ulong CreateCompatibleDC(ulong hdc) LIBRARY "gdi32.dll"
- //这个函数可为一幅图象或绘图操作应用各式各样的效果(绘图片的浮雕状态)
- FUNCTION boolean DrawState(ulong hDC,ulong hBrush,ulong lpDrawStateProc,ulong lParam,ulong wParam,ulong n1,ulong n2,ulong n3,ulong n4,ulong un) LIBRARY "user32.dll" ALIAS FOR "DrawStateA"
- //删除专用设备场景或信息场景,释放所有相关窗口资源
- FUNCTION ulong DeleteDC(ulong hdc) LIBRARY "gdi32.dll"
- //释放由调用GetDC或GetWindowDC函数获取的指定设备场景
- FUNCTION ulong ReleaseDC(ulong hwnd,ulong hdc) LIBRARY "user32.dll"
- end prototypes
- type variables
- Public:
- protectedwrite string class_name = 'uo_tlbar_button'
- string ButtonText =''
- string ButtonType='Normal' //Normal,Checked,RadioButton
- string ToolTip = ''
- string Picture_Name =''
- integer Picture_Size = 16 //16,24
- string TextAlign ='Right' //Right,Bottom,None
- integer RadioGroup = 0
- boolean Checked = False
- Protected:
- window iw_parent
- uo_tlbar iuo_parent
- boolean ib_Captured
- boolean ib_clicked
- boolean ChildMenu
- boolean ib_mousein
- menu im_menuid
- Private:
- integer ii_charwidth = 28
- integer ii_minwidth = 240
- integer ii_minheight = 110
- integer ii_poffsetx,ii_poffsety,ii_coffsetx,ii_coffsety
- integer ii_px,ii_py,ii_cx,ii_cy
- //Constant Variables
- CONSTANT LONG TRANSPARENT = 1
- CONSTANT LONG COLOR_BTNHIGHLIGHT = 20
- CONSTANT LONG COLOR_BTNSHADOW = 16
- CONSTANT ULONG DT_CENTER = 1
- constant long WM_PAINT = 15
- Constant ulong DST_BITMAP = 4 //&H4 位图
- Constant ulong DSS_DISABLED = 32 //&H20 图象具有浮雕效果
- end variables
- forward prototypes
- public subroutine of_buttontext (string as_text)
- public subroutine of_setstyle (string as_style)
- public subroutine of_settooltip (string as_tltip)
- public subroutine of_setpicture (string as_picture)
- public subroutine of_setpicturesize (integer ai_size)
- public subroutine of_setalign (string as_align)
- public subroutine of_setsize ()
- public subroutine of_checked ()
- public subroutine of_drawbutton (string as_type)
- public subroutine of_getparentwindow ()
- public subroutine of_setposition ()
- public subroutine of_enabled (boolean ab_enabled)
- public subroutine of_drawdisabled ()
- public subroutine of_setgroup (integer ai_groupid)
- public subroutine of_setmenu (menu am_menu)
- public subroutine of_setparent (readonly uo_tlbar auo_parent)
- public function menu of_getmenu ()
- end prototypes
- event ue_lbuttonup;IF NOT ib_clicked THEN RETURN
- ib_clicked = false
- ib_captured = false
- IF ((XPos<0 or YPos<0) or (XPos>=this.Width or YPos>this.Height)) THEN
- ReleaseCapture()
- of_drawbutton('Flat')
- ELSE
- IF ButtonType = 'Checked' THEN of_checked()
- IF ButtonType = 'RadioButton' AND (NOT Checked) THEN of_checked()
- of_drawbutton('Flat')
- this.triggerevent("clicked")
- END IF
- end event
- event ue_lbuttondown;IF ib_clicked THEN RETURN
- ib_clicked = true
- ib_captured = false
- of_drawbutton('Down')
- end event
- event ue_mousemove;IF NOT ib_Captured THEN
- SetCapture(handle(this))
- ib_Captured=true
- ib_mousein = true
- IF NOT ib_clicked THEN
- of_drawbutton('Up')
- END IF
- inv_tltips.relaymsg(this)
- ELSE
- IF ((XPos<0 or YPos<0) or (XPos>=this.Width or YPos>this.Height)) THEN
- IF NOT ib_clicked THEN
- ib_Captured = false
- ReleaseCapture()
- END IF
- IF ib_mousein THEN
- of_drawbutton('Flat')
- ib_mousein = false
- END IF
- ELSE
- IF NOT ib_mousein THEN
- ib_mousein =true
- IF ib_clicked THEN
- of_drawbutton('Down')
- ELSE
- of_drawbutton('Flat')
- END IF
- END IF
- inv_tltips.relaymsg(this)
- END IF
- END IF
- end event
- event clicked;IF isvalid(im_menuid) THEN
- IF ButtonType = 'Checked' THEN
- im_menuid.checked = Checked
- END IF
- im_menuid.event clicked()
- END IF
- end event
- event ue_paint;IF NOT this.enabled THEN
- of_drawdisabled()
- END IF
- end event
- public subroutine of_buttontext (string as_text);st_caption.text = as_text
- ButtonText = as_text
- end subroutine
- public subroutine of_setstyle (string as_style);IF pos('Checked;RadioButton;',as_style)>0 THEN
- ButtonType = as_style
- ELSE
- ButtonType = 'Normal'
- END IF
- end subroutine
- public subroutine of_settooltip (string as_tltip);ToolTip = as_tltip
- inv_tltips.AddTool(this,as_tltip,0)
- end subroutine
- public subroutine of_setpicture (string as_picture);IF as_picture = '' THEN RETURN
- Picture_Name = as_Picture
- plb_1.reset()
- plb_1.deletepicture(1)
- plb_1.addpicture(as_picture)
- plb_1.additem(' ',1)
- end subroutine
- public subroutine of_setpicturesize (integer ai_size);IF ai_size =24 THEN
- Picture_Size = 24
- ELSE
- Picture_Size = 16
- END IF
- end subroutine
- public subroutine of_setalign (string as_align);IF as_align = TextAlign THEN RETURN
- IF pos('None;Right;',as_align)>0 THEN
- TextAlign = as_align
- ELSE
- TextAlign = 'Bottom'
- END IF
- of_setsize()
- of_setposition()
- IF checked THEN
- of_drawbutton('Down')
- END IF
- end subroutine
- public subroutine of_setsize ();st_caption.height = 52
- st_caption.width = len(ButtonText) * ii_charwidth
- plb_1.width = PixelsToUnits(Picture_Size,XPixelstoUnits!)
- plb_1.height = PixelsToUnits(Picture_Size,YPixelstoUnits!)
- plb_1.pictureheight = Picture_Size
- plb_1.picturewidth = Picture_Size
- CHOOSE CASE TextAlign
- CASE 'Bottom'
- this.height = st_caption.height + plb_1.height + 50
- IF st_caption.width >= plb_1.width THEN
- this.width = st_caption.width + 30
- ELSE
- this.width = plb_1.width + 30
- END IF
- CASE 'Right'
- this.width = st_caption.width + plb_1.width + 90
- IF st_caption.height >= plb_1.height THEN
- this.height = st_caption.height + 30
- ELSE
- this.height = plb_1.height + 30
- END IF
- CASE 'None'
- this.width = plb_1.width + 40
- this.height = plb_1.height + 40
- RETURN
- END CHOOSE
- IF this.width < ii_minwidth THEN this.width = ii_minwidth
- IF this.height < ii_minheight THEN this.height = ii_minheight
- end subroutine
- public subroutine of_checked ();classdefinition lcd_classinfo
- variabledefinition lvd_classinfo
- userobject us_tmp
- uo_tlbar_button us_tmp_r
- IF ButtonType = 'Checked' THEN
- Checked = not Checked
- IF Checked THEN
- of_drawbutton('Down')
- ELSE
- of_drawbutton('Flat')
- END IF
- ELSE
- IF ButtonType = 'RadioButton' THEN
- IF Checked THEN
- Checked = false
- of_drawbutton('Flat')
- ELSE
- Checked = True
- integer in_loop
- FOR in_loop = 1 TO upperbound(iuo_parent.iuo_buttons)
- us_tmp_r = iuo_parent.iuo_buttons[in_loop]
- IF us_tmp_r.RadioGroup = this.RadioGroup AND us_tmp_r.Checked &
- AND handle(us_tmp_r) <> handle(this)THEN
- us_tmp_r.of_Checked()
- EXIT
- END IF
- NEXT
- END IF
- END IF
- END IF
- end subroutine
- public subroutine of_drawbutton (string as_type);CHOOSE CASE as_type
- CASE 'Down'
- ln_top.linecolor = rgb(128,128,128)
- ln_left.linecolor = rgb(128,128,128)
- ln_bottom.linecolor =rgb(255,255,255)
- ln_right.linecolor =rgb(255,255,255)
- plb_1.x = ii_poffsetx
- plb_1.y = ii_poffsety
- st_caption.x = ii_coffsetx
- st_caption.y = ii_coffsety
- CASE 'Flat'
- IF checked THEN RETURN
- ln_top.linecolor = this.backcolor
- ln_left.linecolor = this.backcolor
- ln_bottom.linecolor = this.backcolor
- ln_right.linecolor = this.backcolor
- plb_1.x = ii_px
- plb_1.y = ii_py
- st_caption.x = ii_cx
- st_caption.y = ii_cy
- CASE 'Up'
- IF checked THEN Return
- ln_top.linecolor = rgb(255,255,255)
- ln_left.linecolor = rgb(255,255,255)
- ln_bottom.linecolor =rgb(128,128,128)
- ln_right.linecolor =rgb(128,128,128)
- plb_1.x = ii_px
- plb_1.y = ii_py
- st_caption.x = ii_cx
- st_caption.y = ii_cy
- END CHOOSE
- end subroutine
- public subroutine of_getparentwindow ();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_setposition ();CHOOSE CASE TextAlign
- CASE 'None'
- st_caption.visible = false
- plb_1.x = (this.width - plb_1.width)/2 + 5
- plb_1.y = (this.height - plb_1.height)/2 + 5
- CASE 'Bottom'
- st_caption.visible = true
- plb_1.x = (this.width - plb_1.width)/2
- plb_1.y = (this.height - plb_1.height - st_caption.height)/2
- st_caption.x = (this.width - st_caption.width)/2
- st_caption.y = plb_1.y + plb_1.height + 10
- CASE 'Right'
- st_caption.visible = true
- plb_1.x = (this.width - plb_1.width)/2 - (st_caption.width/2) - 20
- plb_1.y = (this.height - plb_1.height)/2
- st_caption.x = plb_1.x + plb_1.width + 30
- st_caption.y = (this.height - st_caption.height ) / 2
- END CHOOSE
- ii_px = plb_1.x
- ii_py = plb_1.y
- ii_cx = st_caption.x
- ii_cy = st_caption.y
- ii_poffsetx = ii_px + 5
- ii_poffsety = ii_py + 5
- ii_coffsetx = ii_cx + 5
- ii_coffsety = ii_cy + 5
- ln_top.beginy = 2
- ln_top.endy = 2
- ln_top.beginx = 3
- ln_top.endx = this.width - 3
- ln_bottom.beginx = ln_top.beginx
- ln_bottom.endx = this.width - 3
- ln_bottom.beginy = this.height - 4
- ln_bottom.endy = this.height - 4
- ln_left.beginx = ln_top.beginx
- ln_left.endx = ln_top.beginx
- ln_left.beginy = ln_top.beginy
- ln_left.endy = this.height - 4
- ln_right.beginy = ln_left.beginy
- ln_right.endy = this.height
- ln_right.beginx = this.width - 4
- ln_right.endx = this.width - 4
- end subroutine
- public subroutine of_enabled (boolean ab_enabled);this.enabled = ab_enabled
- IF this.enabled THEN
- st_caption.textcolor = 0
- setredraw(true)
- ELSE
- st_caption.textcolor = rgb(128,128,128)
- of_drawdisabled()
- END IF
- end subroutine
- public subroutine of_drawdisabled ();//====================================================================
- // Function - of_drawtext for uo_tlbutton
- //--------------------------------------------------------------------
- // Description: draw normal(enabled) or gray(disabled) text
- // on the st_caption control by judging the
- // toolbutton is enabled or disabled.
- //--------------------------------------------------------------------
- // Arguments:
- //
- // string as_text menu text
- //
- // boolean ab_enabled button status
- //
- //--------------------------------------------------------------------
- // Returns: (None)
- //--------------------------------------------------------------------
- // Author: Brave_QQ Date: December, 23, 2002
- //====================================================================
- ulong ll_hdc
- long ll_newfont
- long ll_oldfont
- rect lstr_text
- ll_hdc = GetDC( handle( st_caption ) )
- lstr_text.left = 0
- lstr_text.top = 0
- lstr_text.right = UnitsToPixels( st_caption.width, XUnitsToPixels! )
- lstr_text.bottom = UnitsToPixels( st_caption.height, YUnitsToPixels! )
- ll_NewFont = Send(Handle(st_caption),49,0,0)
- ll_OldFont = SelectObject(ll_hdc , ll_NewFont)
- rect lstr_text1
- lstr_text1.left = lstr_text.left + 1
- lstr_text1.top = lstr_text.top + 1
- lstr_text1.right = lstr_text.right + 1
- lstr_text1.bottom = lstr_text.bottom + 1
- SetBKMode( ll_hdc , TRANSPARENT )
- setBKcolor( ll_hdc , st_caption.backcolor )
- SetTextColor( ll_hdc , GetSysColor( COLOR_BTNHIGHLIGHT ))
- DrawText( ll_hdc , ButtonText , len(ButtonText) , lstr_text1 , DT_CENTER )
- SetTextColor( ll_hdc,GetSysColor( COLOR_BTNSHADOW ) )
- DrawText( ll_hdc , ButtonText , len(ButtonText) , lstr_text , DT_CENTER )
- DeleteObject( ll_oldfont )
- ulong Pdc,il_mask,ll_inst,il_bmp
- Pdc = GetWindowDC(Handle(plb_1))
- SetNull( ll_inst )
- plb_1.BackColor = rgb(255,255,255)
- ulong hdc, ll_rs = 0, hwnd, ll_memdc, ll_old,lw,lh,ll_bmp
- lw = 0
- lh = 0
- hwnd = handle( plb_1 )
- lw = plb_1.picturewidth
- lh = plb_1.pictureheight
- hdc = GetDC( hwnd )
- ll_rs = CreateCompatibleBitmap( hdc, lw, lh )
- ll_memdc = CreateCompatibleDC( hdc )
- ReleaseDC( hwnd, hdc )
- ll_old = SelectObject( ll_memdc, ll_rs )
- Send( hwnd, WM_PAINT, ll_memdc, 0 )
- ll_bmp = SelectObject( ll_memdc, ll_old )
- DeleteObject(ll_old)
- Deletedc(ll_memdc)
- ReleaseDc(hwnd,hdc)
- il_mask = ll_bmp
- if il_mask = 0 then return
- il_bmp = SelectObject(Pdc,il_mask)
- plb_1.BackColor = this.backcolor
- DrawState( Pdc, 0, 0, il_mask, 0, 0, 0, 0, 0, DST_BITMAP + DSS_DISABLED)
- ReleaseDC(Handle(plb_1),Pdc)
- DeleteObject(il_bmp)
- DeleteObject(il_mask)
- end subroutine
- public subroutine of_setgroup (integer ai_groupid);RadioGroup= ai_groupid
- end subroutine
- public subroutine of_setmenu (menu am_menu);im_menuid = am_menu
- end subroutine
- public subroutine of_setparent (readonly uo_tlbar auo_parent);iuo_parent = auo_parent
- end subroutine
- public function menu of_getmenu ();return im_menuid
- end function
- on uo_tlbar_button.create
- this.plb_1=create plb_1
- this.ln_bottom=create ln_bottom
- this.ln_top=create ln_top
- this.ln_left=create ln_left
- this.ln_right=create ln_right
- this.st_caption=create st_caption
- this.Control[]={this.plb_1,&
- this.ln_bottom,&
- this.ln_top,&
- this.ln_left,&
- this.ln_right,&
- this.st_caption}
- end on
- on uo_tlbar_button.destroy
- destroy(this.plb_1)
- destroy(this.ln_bottom)
- destroy(this.ln_top)
- destroy(this.ln_left)
- destroy(this.ln_right)
- destroy(this.st_caption)
- end on
- event constructor;IF ButtonText = '' THEN
- of_Buttontext(this.tag)
- ELSE
- of_Buttontext(ButtonText)
- END IF
- of_setsize()
- of_SetPosition()
- of_settooltip(Tooltip)
- of_setpicture(Picture_name)
- of_drawbutton('Flat')
- of_getparentwindow()
- of_enabled(this.enabled)
- end event
- type plb_1 from picturelistbox within uo_tlbar_button
- integer x = 119
- integer y = 32
- integer width = 73
- integer height = 64
- integer taborder = 10
- integer textsize = -9
- integer weight = 400
- fontcharset fontcharset = ansi!
- fontpitch fontpitch = variable!
- fontfamily fontfamily = swiss!
- string facename = "Tahoma"
- long textcolor = 33554432
- long backcolor = 80269524
- boolean enabled = false
- boolean border = false
- boolean vscrollbar = true
- string picturename[] = {"Structure5!"}
- long picturemaskcolor = 12632256
- end type
- type ln_bottom from line within uo_tlbar_button
- long linecolor = 8421504
- integer linethickness = 4
- integer beginx = 9
- integer beginy = 200
- integer endx = 315
- integer endy = 200
- end type
- type ln_top from line within uo_tlbar_button
- long linecolor = 16777215
- integer linethickness = 4
- integer beginx = 5
- integer endx = 306
- end type
- type ln_left from line within uo_tlbar_button
- long linecolor = 16777215
- integer linethickness = 4
- integer endy = 200
- end type
- type ln_right from line within uo_tlbar_button
- long linecolor = 8421504
- integer linethickness = 4
- integer beginx = 306
- integer beginy = 4
- integer endx = 306
- integer endy = 200
- end type
- type st_caption from statictext within uo_tlbar_button
- event ue_paint pbm_paint
- integer x = 14
- integer y = 112
- integer width = 279
- integer height = 52
- integer textsize = -9
- integer weight = 400
- fontcharset fontcharset = gb2312charset!
- fontpitch fontpitch = variable!
- string facename = "宋体"
- long textcolor = 33554432
- long backcolor = 80269524
- boolean enabled = false
- boolean focusrectangle = false
- end type
|