toolbar.monkey2 1.2 KB

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