Google

星期五, 十二月 01, 2006

[学习]FVWM高级ButtonBar

#####
# FvwmDock Styles
###########
Style FvwmDock* Sticky, NoTitle, NoHandles, BorderWidth 0, WindowListSkip, \
CirculateSkip
Style FvwmDock-* StaysOnBottom, FixedPosition, FixedSize
Style FvwmDockA* StaysOnTop, FixedSize

################
#
# ButtonDock Functions. These collection of functions create
# single icon buttons that cause the button to hover above
# everything when the mouse is moved atop of it. To get these
# to work it should only take copying all the five functions
# CreateDock, EnterHandler, LeaveHandler, RestoreButton
# and CreateActiveButton. Then call the function 'CreateDock'
# for each button on the dock bar. The function works as follows:
#
# CreateDock '$0' '$1' '$2' '$3' '$4' '$5' '$6' '$7' '$8' '$9'
# $0 -> ButtonId
# $1 -> Geometry
# $2 -> Icon
# $3 -> LargeIcon
# $4 -> X offset (from upper left hand corner)
# $5 -> Y offset (from upper left hand corner)
# $6 -> action for Mouse 1
# $7 -> action for Mouse 2
# $8 -> action for Mouse 3
# $9 -> Size of LargeIcon
#
###################################
DestroyFunc CreateDock
AddToFunc CreateDock
+ I DestroyModuleConfig FvwmDock-$0: *
+ I *FvwmDock-$0: Geometry $1
+ I *FvwmDock-$0: Font none
+ I *FvwmDock-$0: Colorset 9
+ I *FvwmDock-$0: Frame 0
+ I *FvwmDock-$0: Padding 0 0
+ I *FvwmDock-$0: (Id D$0, Icon $2)
+ I Module FvwmButtons FvwmDock-$0
+ I AddToFunc StartFunction I Module FvwmAuto 100 -menter
'EnterHandler $0 "$2" $3 $4 $5 $6 $7 $8 $9' 'LeaveHandler $0 $2'

DestroyFunc EnterHandler
AddToFunc EnterHandler
+ I ThisWindow (FvwmDock-$0) ThisWindow (!FvwmDock-*) Deschedule 35
+ I ThisWindow (FvwmDock-$0) WindowId $[last_winid] (FvwmDockA$0) Deschedule 35
+ I ThisWindow (FvwmDockA$0) Deschedule 45
+ I ThisWindow (FvwmDock-$0) SendToModule FvwmDock-$0 ChangeButton D$0
Icon "shadow.png"
+ I ThisWindow (FvwmDock-$0) CreateActiveButton $0 '$1' $2 $3 $4 $5 $6 $7 $8

# Delay ms should be longer than delay in FvwmAuto
DestroyFunc LeaveHandler
AddToFunc LeaveHandler
+ I ThisWindow SetEnv last_winid $[w.id]
+ I ThisWindow (FvwmDockA$0) Schedule 110 35 RestoreButton $0 $1
+ I ThisWindow (FvwmDock-$0) Schedule 110 45 RestoreButton $0 $1

DestroyFunc RestoreButton
AddToFunc RestoreButton
+ I SendToModule FvwmDock-$0 ChangeButton D$0 Icon $1
+ I KillModule FvwmButtons FvwmDockA$0

DestroyFunc CreateActiveButton
AddToFunc CreateActiveButton
+ I DestroyModuleConfig FvwmDockA$0: *
+ I *FvwmDockA$0: Pixmap none
+ I *FvwmDockA$0: BoxSize fixed
+ I *FvwmDockA$0: Frame 0
+ I *FvwmDockA$0: Font none
+ I *FvwmDockA$0: Padding 0 0
+ I *FvwmDockA$0: Rows 1
+ I *FvwmDockA$0: Columns 1
+ I ThisWindow PipeRead `echo *FvwmDockA$0: Geometry
$8+$(($[w.x]$3))+$(($[w.y]$4))`
+ I *FvwmDockA$0: (Icon $2, Action(Mouse 1) '$5', Action(Mouse 2)
'$6', Action(Mouse 3) '$7')
+ I Module FvwmButtons FvwmDockA$0

How these functions work is all you need to do is call the CreateDock
function from your StartFunction (or fvwm2rc file) for each icon you
want in your dock. As seen above the CreateDock function takes 10
arguments, that tell it what size, icons, and actions you want to bind
to the button. For example say you wanted to create a two icon dock
with one icon above the other. What you would do is call the
CreateDock function twice for both docks, and then use the geometry
option to stack the two icons right next to each other. For example I
added the two lines to my StartFunction;

+ I CreateDock '10' '56x56-74+62@1' '48x48/firefox.png'
'64x64/firefox.png' '-20' '-30' 'FvwmFireFox' 'Nop' 'Nop' '64x64'
+ I CreateDock '11' '56x56-74+116@1' '48x48/xmms.png' '64x64/xmms.png'
'+20' '-30' 'FvwmXmms' 'Nop' 'FvwmMixer' '64x64'

This creates two Docks, number 10 and number 11. Then when I move my
mouse over one of the Docks, it will replace the current icon with
shadow.png and then make a temporary Dock which has the large icon in
it. The following three pictures should show how this effect works.
Depending on your cpu this may be a little choppy, but all in all I
still think it looks good.

[http://www.zensites.net/fvwm/guide/advanced_buttons.html]

0 条评论:

发表评论

<< 主页

辽ICP备05003652号
流风洄雪听天籁,轻云蔽日看落花

Powered by Blogger