toolbar.monkey2 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. Namespace mojox
  2. #rem monkeydoc The ToolButton class.
  3. #end
  4. Class ToolButton Extends Button
  5. Method New( action:Action )
  6. Super.New( action )
  7. Style=GetStyle( "ToolButton" )
  8. PushButtonMode=True
  9. End
  10. End
  11. #rem monkeydoc The ToolBar class.
  12. #end
  13. Class ToolBar Extends DockingView
  14. #rem monkeydoc Creates a new tool bar.
  15. #end
  16. Method New()
  17. Self.New( std.geom.Axis.X )
  18. End
  19. Method New( axis:Axis )
  20. Style=GetStyle( "ToolBar" )
  21. Layout=(axis=Axis.X ? "fill-x" Else "fill-y")
  22. Gravity=New Vec2f( 0,0 )
  23. _axis=axis
  24. _add=axis=Axis.X ? "left" Else "top"
  25. End
  26. #rem monkeydoc Toolbar axis.
  27. #end
  28. Property Axis:Axis()
  29. Return _axis
  30. End
  31. #rem monkeydoc Adds a view to the tool bar.
  32. #end
  33. Method AddView( view:View )
  34. AddView( view,_add )
  35. End
  36. #rem monkeydoc Adds a separator to the tool bar.
  37. #end
  38. Method AddSeparator()
  39. AddView( New MenuSeparator )
  40. End
  41. #rem monkeydoc Adds an action to the tool bar.
  42. #end
  43. Method AddAction( action:Action )
  44. Local button:=New ToolButton( action )
  45. AddView( button,_add )
  46. End
  47. Method AddAction:Action( label:String,icon:Image=Null )
  48. Local action:=New Action( label,icon )
  49. AddAction( action )
  50. Return action
  51. End
  52. Private
  53. Field _axis:Axis
  54. Field _add:String
  55. End