Changeset 5566
- Timestamp:
- Apr 2, 2010, 10:54:53 AM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
extensions/pLoader/trunk/src/Uploader/GUI/DlgCommon.pm
r5507 r5566 40 40 # to connect the right event handler to each control 41 41 my $ctrl_handlers = { 42 'Wx::SpinCtrl' => sub { my ( $ctrl ) = @_; Wx::Event::EVT_SPINCTRL( $ctrl, $ctrl, sub { $self->OnSpinCtrl(@_) } ); },43 42 'Wx::TextCtrl' => sub { my ( $ctrl ) = @_; Wx::Event::EVT_TEXT( $ctrl, $ctrl, sub { $self->OnTextCtrl(@_) } ); }, 44 'Wx::Choice' => sub { my ( $ctrl ) = @_; Wx::Event::EVT_CHOICE( $ctrl, $ctrl, sub { $self->OnChoice(@_) } ); },43 'Wx::Choice' => sub { my ( $ctrl ) = @_; Wx::Event::EVT_CHOICE( $ctrl, $ctrl, sub { $self->OnChoice(@_) } ); }, 45 44 'Wx::RadioBox' => sub { my ( $ctrl ) = @_; Wx::Event::EVT_RADIOBOX( $ctrl, $ctrl, sub { $self->OnRadioBox(@_) } ); }, 46 45 'Wx::CheckBox' => sub { my ( $ctrl ) = @_; Wx::Event::EVT_CHECKBOX( $ctrl, $ctrl, sub { $self->OnCheckBox(@_) } ); }, 47 'Wx:: DatePickerCtrl' => sub { my ( $ctrl ) = @_; Wx::Event::EVT_DATE_CHANGED( $ctrl, $ctrl, sub { $self->OnDatePicker(@_) } ); },46 'Wx::SpinCtrl' => sub { my ( $ctrl ) = @_; Wx::Event::EVT_SPINCTRL( $ctrl, $ctrl, sub { $self->OnSpinCtrl(@_) } ); }, 48 47 'Wx::ComboBox' => sub { my ( $ctrl ) = @_; 49 48 Wx::Event::EVT_COMBOBOX( $ctrl, $ctrl, sub { $self->OnComboBox(@_) } ); 50 49 Wx::Event::EVT_TEXT( $ctrl, $ctrl, sub { $self->OnComboBoxText(@_) } ); 51 50 }, 51 'Wx::DatePickerCtrl' => sub { my ( $ctrl ) = @_; Wx::Event::EVT_DATE_CHANGED( $ctrl, $ctrl, sub { $self->OnDatePicker(@_) } ); }, 52 52 'Uploader::GUI::wxCategoryTreeCtrl' => sub { my ( $ctrl ) = @_; 53 53 Wx::Event::EVT_TREE_SEL_CHANGED( … … 101 101 102 102 # text changed by user, not selection 103 if( -1 eq $ctrl->GetSelection){103 if( $ctrl->GetValue ne $ctrl->GetStringSelection){ 104 104 my $id = $ctrl->GetId; 105 105 # change the property value 106 106 $self->properties->{$id}->{value}->( 107 $ event->GetString107 $ctrl->GetValue 108 108 ) if exists $self->properties->{$id}->{value}; 109 109 … … 116 116 117 117 118 # what does happen when the text changes119 sub OnTextCtrl {120 my ( $self, $ctrl, $event ) = @_;121 122 my $id = $ctrl->GetId;123 # change the property value124 $self->properties->{$id}->{value}->(125 $event->GetString126 ) if exists $self->properties->{$id}->{value};127 128 # exec the callback129 $self->properties->{$id}->{frame_callback}->($self, $ctrl, $event) if exists130 $self->properties->{$id}->{frame_callback};131 132 }133 134 sub OnSpinCtrl {135 my ( $self, $ctrl, $event ) = @_;136 137 my $id = $ctrl->GetId;138 # change the property value139 $self->properties->{$id}->{value}->(140 $event->GetInt141 ) if exists $self->properties->{$id}->{value};142 143 # exec the callback144 $self->properties->{$id}->{frame_callback}->($self, $ctrl, $event) if exists145 $self->properties->{$id}->{frame_callback};146 147 $event->Skip;148 }149 150 sub OnRadioBox {151 my ( $self, $ctrl, $event ) = @_;152 153 my $id = $ctrl->GetId;154 155 # if a preprocess value is required156 my $value = $event->GetSelection;157 $value = $self->properties->{$id}->{pre_process}->( $value ) if exists158 $self->properties->{$id}->{pre_process};159 # change the property value. use the index selection160 $self->properties->{$id}->{selection}->(161 $value162 ) if exists $self->properties->{$id}->{selection};163 164 # exec the callback165 $self->properties->{$id}->{frame_callback}->($self, $ctrl, $event) if exists166 $self->properties->{$id}->{frame_callback};167 168 $event->Skip;169 170 }171 172 sub OnChoice {173 my ( $self, $ctrl, $event ) = @_;174 175 my $id = $ctrl->GetId;176 177 # if a preprocess value is required178 my $value = exists $self->properties->{$id}->{string_selection} ? $event->GetString : $event->GetSelection;179 $value = $self->properties->{$id}->{pre_process}->( $value ) if exists180 $self->properties->{$id}->{pre_process};181 # change the property value. use the index selection182 $self->properties->{$id}->{selection}->(183 $value184 ) if exists $self->properties->{$id}->{selection};185 186 # change the property value. use the string187 $self->properties->{$id}->{string_selection}->(188 $value189 ) if exists $self->properties->{$id}->{string_selection};190 191 # exec the callback192 $self->properties->{$id}->{frame_callback}->($self, $ctrl, $event) if exists193 $self->properties->{$id}->{frame_callback};194 195 $event->Skip;196 }197 198 199 118 sub OnComboBox { 200 119 my ( $self, $ctrl, $event ) = @_; … … 205 124 if exists $self->properties->{$id}->{multi_selection_mode}; 206 125 207 my $selection = exists $self->properties->{$id}->{string_selection} ? $ event->GetString : $event->GetSelection;126 my $selection = exists $self->properties->{$id}->{string_selection} ? $ctrl->GetValue : $ctrl->GetSelection; 208 127 209 128 my $value = $self->properties->{$id}->{pre_process}->( $selection ) if exists … … 224 143 $self->properties->{$id}->{frame_callback}->($self, $ctrl, $event) if exists 225 144 $self->properties->{$id}->{frame_callback}; 145 } 146 147 148 # what does happen when the text changes 149 sub OnTextCtrl { 150 my ( $self, $ctrl, $event ) = @_; 151 152 my $id = $ctrl->GetId; 153 # change the property value 154 $self->properties->{$id}->{value}->( 155 $event->GetString 156 ) if exists $self->properties->{$id}->{value}; 157 158 # exec the callback 159 $self->properties->{$id}->{frame_callback}->($self, $ctrl, $event) if exists 160 $self->properties->{$id}->{frame_callback}; 161 162 } 163 164 sub OnSpinCtrl { 165 my ( $self, $ctrl, $event ) = @_; 166 167 my $id = $ctrl->GetId; 168 # change the property value 169 $self->properties->{$id}->{value}->( 170 $event->GetInt 171 ) if exists $self->properties->{$id}->{value}; 172 173 # exec the callback 174 $self->properties->{$id}->{frame_callback}->($self, $ctrl, $event) if exists 175 $self->properties->{$id}->{frame_callback}; 176 177 $event->Skip; 178 } 179 180 sub OnRadioBox { 181 my ( $self, $ctrl, $event ) = @_; 182 183 my $id = $ctrl->GetId; 184 185 # if a preprocess value is required 186 my $value = $event->GetSelection; 187 $value = $self->properties->{$id}->{pre_process}->( $value ) if exists 188 $self->properties->{$id}->{pre_process}; 189 # change the property value. use the index selection 190 $self->properties->{$id}->{selection}->( 191 $value 192 ) if exists $self->properties->{$id}->{selection}; 193 194 # exec the callback 195 $self->properties->{$id}->{frame_callback}->($self, $ctrl, $event) if exists 196 $self->properties->{$id}->{frame_callback}; 197 198 $event->Skip; 199 200 } 201 202 sub OnChoice { 203 my ( $self, $ctrl, $event ) = @_; 204 205 my $id = $ctrl->GetId; 206 207 # if a preprocess value is required 208 my $value = exists $self->properties->{$id}->{string_selection} ? $event->GetString : $event->GetSelection; 209 $value = $self->properties->{$id}->{pre_process}->( $value ) if exists 210 $self->properties->{$id}->{pre_process}; 211 # change the property value. use the index selection 212 $self->properties->{$id}->{selection}->( 213 $value 214 ) if exists $self->properties->{$id}->{selection}; 215 216 # change the property value. use the string 217 $self->properties->{$id}->{string_selection}->( 218 $value 219 ) if exists $self->properties->{$id}->{string_selection}; 220 221 # exec the callback 222 $self->properties->{$id}->{frame_callback}->($self, $ctrl, $event) if exists 223 $self->properties->{$id}->{frame_callback}; 224 225 $event->Skip; 226 226 } 227 227
Note: See TracChangeset
for help on using the changeset viewer.