| dotReader documentation | view source | Contained in the dotReader distribution. |
WxPerl::MenuMaker - create and manage linked menus and toolbars
This is not a wxMenu, only a way to hold and manage named references to the menu items and toolbar items.
my $mm = WxPerl::MenuMaker->new(
handler => $self,
nomethod => sub {warn "$_[1] cannot '$_[0]()'"},
);
$mm->create_menubar(\@menu);
# the toolbar takes a few more parameters
$mm->create_toolbar(\@toolbar,
parent => $frame, # all you really need
id => -1,
position => wxDefaultPosition,
size => wxDefaultSize,
style => wxTB_HORIZONTAL|wxTB_FLAT|wxTB_DOCKABLE,
bitmap_size => [32, 32],
);
# and you can get them back
my $menu = $mm->menubar;
my $menu_item = $mm->menu_items->file_open;
my $toolbar = $mm->toolbar;
my $toolbar_item = $mm->toolbar_items->that_button;
# and
my $associate = $mm->associated_menu->that_button;
my $mm = WxPerl::MenuMaker->new(
handler => $self,
nomethod => sub {warn "$_[1] cannot '$_[0]()'"},
);
$name = $self->_name_check($item->{name});
my @toolbar = (
{
tooltip => 'File Manager',
icon => 'file-manager.png',
auto_action => 0,
name => 'file_manager'
},
{
tooltip => 'Notes',
icon => 'tb_button_notes.png',
name => 'notes'
},
{
separator => '1'
},
{
tooltip => 'Open File',
icon => 'kedit.png',
associate => 'file_open',
name => 'file_open'
},
{
tooltip => 'Browse',
icon => 'tb_button_browse.png',
action => 'do_something',
name => 'browse'
},
{
tooltip => 'Foo',
icon => 'tb_button_foo.png',
action => sub {warn "this is foo"},
name => 'foo'
}
);
$mm->create_toolbar(\@toolbar,
parent => $frame, # all you really need
id => -1,
position => wxDefaultPosition,
size => wxDefaultSize,
style => wxTB_HORIZONTAL|wxTB_FLAT|wxTB_DOCKABLE,
bitmap_size => [32, 32],
);
If you set a handler in the constructor, you will not need to pass the parent argument to this method.
The toolbar items are connected much like in create_menu(), except that
the default method is menu_tb_name().
The associate property will cause the tool to be associated to that
menu entry. This means they will have the same ID (and thus the same
events.)
$mm->append_toolbar(%args);
my $tool = $self->_add_toolbar_item(%args);
$class->_mk_accessor($package, $method, $value);
$self->_mk_event($item, $name, $menu_item);
Eric Wilhelm <ewilhelm at cpan dot org>
http://scratchcomputing.com/
If you found this module on CPAN, please report any bugs or feature requests through the web interface at http://rt.cpan.org. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
If you pulled this development version from my /svn/, please contact me directly.
Copyright (C) 2006 Eric L. Wilhelm, All Rights Reserved.
Absolutely, positively NO WARRANTY, neither express or implied, is offered with this software. You use this software at your own risk. In case of loss, no person or entity owes you anything whatsoever. You have been warned.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
| dotReader documentation | view source | Contained in the dotReader distribution. |