Changeset 510
- Timestamp:
- 10/26/08 09:48:58 (3 years ago)
- Location:
- trunk/lib/Padre/Wx
- Files:
-
- 3 edited
-
Dialog.pm (modified) (3 diffs)
-
ModuleStartDialog.pm (modified) (1 diff)
-
Preferences.pm (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/lib/Padre/Wx/Dialog.pm
r509 r510 26 26 $top_left_offset = [0, 0] if not ref($top_left_offset); 27 27 28 # TODO make sure width has enough elements to the widest row 29 # or maybe we should also check that all the rows has the same number of elements 28 30 my $box = Wx::BoxSizer->new( Wx::wxVERTICAL ); 29 31 # Add Y-offset … … 63 65 $widget = $class->new( $dialog, -1, $arg, Wx::wxDefaultPosition, [$width->[$j], -1], @params ); 64 66 $widget->SetValue($default); 67 } elsif ($class eq 'Wx::StaticText') { 68 $widget = $class->new( $dialog, -1, $arg, Wx::wxDefaultPosition, [$width->[$j], -1], @params ); 69 } elsif ($class eq 'Wx::ComboBox') { 70 $widget = $class->new( $dialog, -1, $arg, Wx::wxDefaultPosition, [$width->[$j], -1], @params ); 71 } elsif ($class eq 'Wx::Choice') { 72 $widget = $class->new( $dialog, -1, Wx::wxDefaultPosition, [$width->[$j], -1], $arg, @params ); 65 73 } else { 66 $widget = $class->new( $dialog, -1, $arg, Wx::wxDefaultPosition, [$width->[$j], -1], @params ); 74 warn "Unsupported widget $class\n"; 75 return; 67 76 } 68 77 … … 93 102 if ($class eq 'Wx::DirPickerCtrl') { 94 103 $data{$name} = $dialog->{$name}->GetPath; 104 } elsif ($class eq 'Wx::Choice') { 105 $data{$name} = $dialog->{$name}->GetSelection; 95 106 } else { 96 107 $data{$name} = $dialog->{$name}->GetValue; -
trunk/lib/Padre/Wx/ModuleStartDialog.pm
r509 r510 78 78 [ 'Wx::Button', '_ok_', Wx::wxID_OK ], 79 79 [ 'Wx::Button', '_cancel_', Wx::wxID_CANCEL ], 80 ] 80 ], 81 81 ); 82 82 return \@layout; -
trunk/lib/Padre/Wx/Preferences.pm
r468 r510 5 5 use warnings; 6 6 7 use Padre::Wx (); 7 use Padre::Wx (); 8 use Padre::Wx::Dialog (); 8 9 9 10 our $VERSION = '0.12'; 11 12 sub get_layout { 13 my ($config, $values) = @_; 14 15 return [ 16 [ 17 [ 'Wx::StaticText', undef, 'TAB display size (in spaces)'], 18 [ 'Wx::TextCtrl', 'editor_tabwidth', $config->{editor_tabwidth}], 19 ], 20 [ 21 [ 'Wx::StaticText', undef, 'Max number of modules'], 22 [ 'Wx::TextCtrl', 'pod_maxlist', $config->{pod_maxlist}], 23 ], 24 [ 25 [ 'Wx::StaticText', undef, 'Min number of modules'], 26 [ 'Wx::TextCtrl', 'pod_minlist', $config->{pod_minlist}], 27 ], 28 [ 29 [ 'Wx::StaticText', undef, 'Open files:'], 30 [ 'Wx::Choice', 'choice', $values], 31 ], 32 [ 33 [ 'Wx::Button', '_ok_', Wx::wxID_OK ], 34 [ 'Wx::Button', '_cancel_', Wx::wxID_CANCEL ], 35 ], 36 ]; 37 } 10 38 11 39 sub run { 12 40 my ( $class, $win, $config ) = @_; 13 41 14 my $dialog = Wx::Dialog->new( $win, -1, "Preferences", [-1, -1], [550, 200], Wx::wxDEFAULT_FRAME_STYLE);15 16 my $y = 10;17 my $HEIGHT = 30;18 19 Wx::StaticText->new( $dialog, -1, 'TAB display size (in spaces)', [10, $y], [-1, -1]);20 my $tabwidth = Wx::TextCtrl->new(21 $dialog,22 -1,23 $config->{editor_tabwidth},24 [ 300, $y ],25 [ -1, -1 ],26 );27 $tabwidth->SetFocus;28 29 $y += $HEIGHT;30 Wx::StaticText->new( $dialog, -1, 'Max number of modules', [10, $y], [-1, -1]);31 my $max = Wx::TextCtrl->new( $dialog, -1, $config->{pod_maxlist}, [300, $y] , [-1, -1]);32 33 $y += $HEIGHT;34 Wx::StaticText->new( $dialog, -1, 'Min number of modules', [10, $y], [-1, -1]);35 my $min = Wx::TextCtrl->new( $dialog, -1, $config->{pod_minlist}, [300, $y] , [-1, -1]);36 37 $y += $HEIGHT;38 Wx::StaticText->new( $dialog, -1, 'Open files:', [10, $y], [-1, -1]);39 42 my @values = ( 40 43 $config->{main_startup}, 41 44 grep { $_ ne $config->{main_startup} } qw( new nothing last ) 42 45 ); 43 my $choice = Wx::Choice->new( $dialog, -1, [300, $y], [-1, -1], \@values );44 46 45 $y += $HEIGHT; 46 my $ok = Wx::Button->new( $dialog, Wx::wxID_OK, '', [10, $y] ); 47 my $cancel = Wx::Button->new( $dialog, Wx::wxID_CANCEL, '', [120, $y], $ok->GetSize ); 48 Wx::Event::EVT_BUTTON( $dialog, $ok, sub { $dialog->EndModal(Wx::wxID_OK) } ); 49 Wx::Event::EVT_BUTTON( $dialog, $cancel, sub { $dialog->EndModal(Wx::wxID_CANCEL) } ); 50 $ok->SetDefault; 47 my $dialog = Wx::Dialog->new( $win, -1, "Preferences", [-1, -1], [550, 200], Wx::wxDEFAULT_FRAME_STYLE); 48 49 my $layout = get_layout($config, \@values); 50 Padre::Wx::Dialog::build_layout($dialog, $layout, [250, 200]); 51 $dialog->{editor_tabwidth}->SetFocus; 52 Wx::Event::EVT_BUTTON( $dialog, $dialog->{_ok_}, sub { $dialog->EndModal(Wx::wxID_OK) } ); 53 Wx::Event::EVT_BUTTON( $dialog, $dialog->{_cancel_}, sub { $dialog->EndModal(Wx::wxID_CANCEL) } ); 54 55 $dialog->{_ok_}->SetDefault; 51 56 if ($dialog->ShowModal == Wx::wxID_CANCEL) { 52 57 return; 53 58 } 54 $config->{pod_maxlist} = $max->GetValue; 55 $config->{pod_minlist} = $min->GetValue; 56 $config->{editor_tabwidth} = $tabwidth->GetValue; 57 $config->{main_startup} = $values[ $choice->GetSelection ]; 59 60 my $data = Padre::Wx::Dialog::get_data_from( $dialog, get_layout() ); 61 62 $config->{pod_maxlist} = $data->{pod_maxlist}; 63 $config->{pod_minlist} = $data->{pod_minlist}; 64 $config->{editor_tabwidth} = $data->{editor_tabwidth}; 65 $config->{main_startup} = $values[ $data->{choice} ]; 58 66 59 67 return;
Note: See TracChangeset
for help on using the changeset viewer.
