File Coverage

blib/lib/Padre/Plugin/FormBuilder.pm
Criterion Covered Total %
statement 16 18 88.8
branch n/a
condition n/a
subroutine 6 6 100.0
pod n/a
total 22 24 91.6


line stmt bran cond sub pod time code
1             package Padre::Plugin::FormBuilder;
2            
3             =pod
4            
5             =head1 NAME
6            
7             Padre::Plugin::FormBuilder - Generate Perl for dialogs created in wxFormBuilder
8            
9             =head1 DESCRIPTION
10            
11             The Form Builder user interface design tool helps to produce user interface
12             code relatively quickly. However, it does not natively support the
13             generation of Perl code.
14            
15             B provides an interface to the
16             L module to allow the generation of Padre dialog code
17             based on wxFormBuilder designs.
18            
19             =cut
20            
21 1     1   920 use 5.008005;
  1         3  
  1         38  
22 1     1   5 use strict;
  1         2  
  1         32  
23 1     1   15 use warnings;
  1         2  
  1         37  
24            
25             # Normally we would run-time load most of these,
26             # but we happen to know Padre uses all of them itself.
27 1     1   1040 use Class::Inspector 1.22 ();
  1         4704  
  1         30  
28 1     1   1072 use Params::Util 1.00 ();
  1         9189  
  1         28  
29 1     1   559 use Padre::Plugin ();
  0            
  0            
30            
31             our $VERSION = '0.04';
32             our @ISA = 'Padre::Plugin';
33            
34             # Temporary namespace counter
35             my $COUNT = 0;
36            
37            
38            
39            
40            
41             #####################################################################
42             # Padre::Plugin Methods
43            
44             sub plugin_name {
45             'Padre Form Builder';
46             }
47            
48             sub padre_interfaces {
49             'Padre::Plugin' => 0.93,
50             'Padre::Util' => 0.93,
51             'Padre::Unload' => 0.93,
52             'Padre::Task' => 0.93,
53             'Padre::Document' => 0.93,
54             'Padre::Project' => 0.93,
55             'Padre::Wx' => 0.93,
56             'Padre::Wx::Role::Main' => 0.93,
57             'Padre::Wx::Main' => 0.93,
58             'Padre::Wx::Editor' => 0.93,
59             }
60            
61             # Clean up our classes
62             sub plugin_disable {
63             my $self = shift;
64            
65             # Remove the dialog
66             $self->clean_dialog;
67            
68             # Unload all our child classes
69             $self->unload( qw{
70             Padre::Plugin::FormBuilder::Dialog
71             Padre::Plugin::FormBuilder::FBP
72             Padre::Plugin::FormBuilder::Perl
73             Padre::Plugin::FormBuilder::Preview
74             } );
75            
76             return 1;
77             }
78            
79             sub menu_plugins {
80             my $self = shift;
81             my $main = shift;
82            
83             # Create a manual menu item
84             my $item = Wx::MenuItem->new(
85             undef,
86             -1,
87             $self->plugin_name,
88             );
89             Wx::Event::EVT_MENU(
90             $main,
91             $item,
92             sub {
93             local $@;
94             eval {
95             $self->menu_dialog($main);
96             };
97             },
98             );
99            
100             return $item;
101             }
102            
103             sub clean_dialog {
104             my $self = shift;
105            
106             # Close the formbuilder dialog if it is hanging around
107             if ( $self->{dialog} ) {
108             $self->{dialog}->clear_preview;
109             $self->{dialog}->Destroy;
110             delete $self->{dialog};
111             }
112            
113             return 1;
114             }
115            
116            
117            
118            
119            
120             ######################################################################
121             # Menu Commands
122            
123             sub menu_dialog {
124             my $self = shift;
125             my $main = $self->main;
126            
127             # Clean up any previous existing dialog
128             $self->clean_dialog;
129            
130             # Create the new dialog
131             require Padre::Plugin::FormBuilder::Dialog;
132             $self->{dialog} = Padre::Plugin::FormBuilder::Dialog->new($main);
133             $self->{dialog}->Show;
134            
135             return;
136             }
137            
138             1;
139            
140             =pod
141            
142             =head1 SUPPORT
143            
144             Bugs should be reported via the CPAN bug tracker at
145            
146             L
147            
148             For other issues, or commercial enhancement or support, contact the author.
149            
150             =head1 AUTHOR
151            
152             Adam Kennedy Eadamk@cpan.orgE
153            
154             =head1 SEE ALSO
155            
156             L
157            
158             =head1 COPYRIGHT
159            
160             Copyright 2010 - 2012 Adam Kennedy.
161            
162             This program is free software; you can redistribute
163             it and/or modify it under the same terms as Perl itself.
164            
165             The full text of the license can be found in the
166             LICENSE file included with this module.
167            
168             =cut