113
113
void bf::snapshot_frame::create_member_controls()
115
m_date_button = new wxButton( this, IDC_DATE_CTRL, _("0"));
115
m_date_button = new wxButton( this, IDC_DATE_CTRL, wxT("0"));
117
117
m_function_button = new wxButton( this, IDC_FUNCTION, wxEmptyString );
119
m_mark_choice = new wxChoice( this, IDC_MARK_CHOICE );
119
m_mark_choice = new wxChoice( this, IDC_MARK_CHOICE );
121
121
m_mark_left_spin = new spin_ctrl<double>
122
122
( this, IDC_MARK_PLACEMENT, wxDefaultPosition,
123
wxDefaultSize, 0, - std::numeric_limits<double>::infinity(),
123
wxDefaultSize, 0, - std::numeric_limits<double>::infinity(),
124
124
std::numeric_limits<double>::infinity(), 0, 1 );
125
125
m_mark_bottom_spin = new spin_ctrl<double>
126
126
( this, IDC_MARK_PLACEMENT, wxDefaultPosition,
127
wxDefaultSize, 0, - std::numeric_limits<double>::infinity(),
127
wxDefaultSize, 0, - std::numeric_limits<double>::infinity(),
128
128
std::numeric_limits<double>::infinity(), 0, 1 );
129
129
m_mark_depth_spin = new wxSpinCtrl( this, IDC_MARK_PLACEMENT );
130
130
m_mark_angle_spin = new spin_ctrl<double>
131
131
( this, IDC_MARK_PLACEMENT, wxDefaultPosition,
132
wxDefaultSize, 0, - std::numeric_limits<double>::infinity(),
132
wxDefaultSize, 0, - std::numeric_limits<double>::infinity(),
133
133
std::numeric_limits<double>::infinity(), 0, 0.01 );
135
135
m_mark_depth_spin->SetRange
136
136
( std::numeric_limits<int>::min(), std::numeric_limits<int>::max() );
137
137
m_mark_visible_box = new wxCheckBox( this, IDC_VISIBILITY,_("Visible") );
139
m_sound_button = new wxButton(this, IDC_SOUND_FILE, _("..."));
140
m_sound_path = new wxTextCtrl(this, wxID_ANY);
141
m_globally_sound_box =
139
m_sound_button = new wxButton(this, IDC_SOUND_FILE, wxT("..."));
140
m_sound_path = new wxTextCtrl(this, IDC_SOUND_TEXT);
141
m_globally_sound_box =
142
142
new wxCheckBox( this, IDC_GLOBALLY_SOUND,_("Play globally") );
144
144
m_width_spin = new spin_ctrl<double>
151
151
m_x_alignment_value_spin = new spin_ctrl<double>
152
152
( this, IDC_ALIGNMENT, wxDefaultPosition,
153
wxDefaultSize, 0, -std::numeric_limits<double>::infinity(),
153
wxDefaultSize, 0, -std::numeric_limits<double>::infinity(),
154
154
std::numeric_limits<double>::infinity(), 0, 1 );
156
156
m_y_alignment_value_spin = new spin_ctrl<double>
157
157
( this, IDC_ALIGNMENT, wxDefaultPosition,
158
wxDefaultSize, 0, -std::numeric_limits<double>::infinity(),
158
wxDefaultSize, 0, -std::numeric_limits<double>::infinity(),
159
159
std::numeric_limits<double>::infinity(), 0, 1 );
161
161
wxArrayString array;
162
array.Add(_("align_bottom"));
163
array.Add(_("align_center"));
164
array.Add(_("align_top"));
162
array.Add(wxT("align_bottom"));
163
array.Add(wxT("align_center"));
164
array.Add(wxT("align_top"));
165
165
m_y_alignment_choice = new wxChoice
166
166
( this, IDC_ALIGNMENT, wxDefaultPosition, wxDefaultSize, array );
169
array.Add(_("align_left"));
170
array.Add(_("align_center"));
171
array.Add(_("align_right"));
169
array.Add(wxT("align_left"));
170
array.Add(wxT("align_center"));
171
array.Add(wxT("align_right"));
172
172
m_x_alignment_choice = new wxChoice
173
173
( this, IDC_ALIGNMENT, wxDefaultPosition, wxDefaultSize, array );
175
enable_controls(false);
174
176
} // snapshot_frame::create_member_controls()
176
178
/*----------------------------------------------------------------------------*/
201
203
wxStaticBoxSizer* static_sizer;
202
204
static_sizer = new wxStaticBoxSizer( wxHORIZONTAL, this, _("Size") );
203
static_sizer->Add( new wxStaticText(this, wxID_ANY, _("Width: ")), 0,
205
static_sizer->Add( new wxStaticText(this, wxID_ANY, _("Width:")), 0,
204
206
wxALIGN_CENTER_VERTICAL );
205
207
static_sizer->Add( m_width_spin, 1 );
206
208
static_sizer->AddSpacer(5);
207
static_sizer->Add( new wxStaticText(this, wxID_ANY, _("Height: ")), 0,
209
static_sizer->Add( new wxStaticText(this, wxID_ANY, _("Height:")), 0,
208
210
wxALIGN_CENTER_VERTICAL );
209
211
static_sizer->Add( m_height_spin, 1 );
210
212
sizer->Add( static_sizer, 0, wxEXPAND );
213
215
new wxStaticBoxSizer( wxVERTICAL, this, _("Alignments") );
214
216
s_sizer = new wxBoxSizer( wxHORIZONTAL );
215
s_sizer->Add( new wxStaticText(this, wxID_ANY, _("X: ")), 0,
217
s_sizer->Add( new wxStaticText(this, wxID_ANY, _("X:")), 0,
216
218
wxALIGN_CENTER_VERTICAL );
217
219
s_sizer->Add( m_x_alignment_choice, 1, wxALL );
218
220
s_sizer->AddSpacer(5);
219
s_sizer->Add( new wxStaticText(this, wxID_ANY, _("Gap: ")), 0,
221
s_sizer->Add( new wxStaticText(this, wxID_ANY, _("Gap:")), 0,
220
222
wxALIGN_CENTER_VERTICAL );
221
223
s_sizer->Add( m_x_alignment_value_spin, 1 );
222
224
static_sizer->Add( s_sizer, 0, wxEXPAND );
223
225
s_sizer = new wxBoxSizer( wxHORIZONTAL );
224
s_sizer->Add( new wxStaticText(this, wxID_ANY, _("Y: ")), 0,
226
s_sizer->Add( new wxStaticText(this, wxID_ANY, _("Y:")), 0,
225
227
wxALIGN_CENTER_VERTICAL );
226
228
s_sizer->Add( m_y_alignment_choice, 1, wxALL );
227
229
s_sizer->AddSpacer(5);
228
s_sizer->Add( new wxStaticText(this, wxID_ANY, _("Gap: ")), 0,
230
s_sizer->Add( new wxStaticText(this, wxID_ANY, _("Gap:")), 0,
229
231
wxALIGN_CENTER_VERTICAL );
230
232
s_sizer->Add( m_y_alignment_value_spin, 1 );
244
246
wxStaticBoxSizer* result =
245
247
new wxStaticBoxSizer( wxVERTICAL, this, _("Marks") );
247
249
wxBoxSizer* s_sizer = new wxBoxSizer( wxHORIZONTAL );
249
251
( new wxStaticText(this, wxID_ANY, _("Mark:")),
250
252
0, wxALIGN_CENTRE_VERTICAL | wxALL, 5 );
251
s_sizer->Add( m_mark_choice, 1, wxALL, 5 );
253
s_sizer->Add( m_mark_choice, 1, wxALL, 5 );
252
254
result->Add( s_sizer, 0, wxEXPAND, 0 );
254
256
s_sizer = new wxBoxSizer( wxHORIZONTAL );
287
289
wxSizer* bf::snapshot_frame::create_sound_sizer()
289
wxStaticBoxSizer* result =
291
wxStaticBoxSizer* result =
290
292
new wxStaticBoxSizer( wxVERTICAL, this, _("Sound") );
292
294
wxBoxSizer* s_sizer = new wxBoxSizer( wxHORIZONTAL );
293
295
s_sizer = new wxBoxSizer( wxHORIZONTAL );
294
296
s_sizer->Add( m_sound_path, 1, wxEXPAND );
332
334
m_globally_sound_box->SetValue
333
335
( m_snapshot->get_sound().is_played_globally() );
335
m_width_spin->SetValue(m_snapshot->get_width());
336
m_height_spin->SetValue(m_snapshot->get_height());
337
m_x_alignment_choice->SetStringSelection
338
(std_to_wx_string(m_snapshot->get_x_alignment()));
339
m_y_alignment_choice->SetStringSelection
340
(std_to_wx_string(m_snapshot->get_y_alignment()));
341
m_x_alignment_value_spin->SetValue
342
(m_snapshot->get_x_alignment_value());
343
m_y_alignment_value_spin->SetValue
344
(m_snapshot->get_y_alignment_value());
337
m_width_spin->SetValue(m_snapshot->get_width());
338
m_height_spin->SetValue(m_snapshot->get_height());
339
m_x_alignment_choice->SetStringSelection
340
(std_to_wx_string(m_snapshot->get_x_alignment()));
341
m_y_alignment_choice->SetStringSelection
342
(std_to_wx_string(m_snapshot->get_y_alignment()));
343
m_x_alignment_value_spin->SetValue
344
(m_snapshot->get_x_alignment_value());
345
m_y_alignment_value_spin->SetValue
346
(m_snapshot->get_y_alignment_value());
348
m_date_button->Enable(enable);
349
m_mark_choice->Enable(enable);
350
m_function_button->Enable(enable);
351
m_sound_button->Enable(enable);
352
m_sound_path->Enable(enable);
353
m_globally_sound_box->Enable(enable);
354
m_width_spin->Enable(enable);
355
m_height_spin->Enable(enable);
356
m_x_alignment_choice->Enable(enable);
357
m_y_alignment_choice->Enable(enable);
358
m_x_alignment_value_spin->Enable(enable);
359
m_y_alignment_value_spin->Enable(enable);
350
enable_controls(enable);
362
353
} // snapshot_frame::fill()
364
355
/*----------------------------------------------------------------------------*/
366
* \brief Fill controls of current mark.
357
* \brief Fill controls of current mark.
368
359
void bf::snapshot_frame::fill_mark()
374
365
if ( m_model_frame != NULL )
375
366
if ( m_model_frame->get_model().has_active_action() )
376
if ( m_snapshot != NULL )
378
snapshot::const_mark_placement_iterator it;
380
for ( it = m_snapshot->mark_placement_begin();
381
it != m_snapshot->mark_placement_end(); ++it )
382
m_mark_choice->Append
383
( std_to_wx_string(it->get_mark()->get_label()) );
385
if ( m_model_frame->get_model().has_mark_selection() )
367
if ( m_snapshot != NULL )
369
snapshot::const_mark_placement_iterator it;
371
for ( it = m_snapshot->mark_placement_begin();
372
it != m_snapshot->mark_placement_end(); ++it )
373
m_mark_choice->Append
374
( std_to_wx_string(it->get_mark()->get_label()) );
376
if ( m_model_frame->get_model().has_mark_selection() )
389
380
( m_model_frame->get_model().get_main_mark_selection() );
391
m_mark_choice->SetStringSelection
382
m_mark_choice->SetStringSelection
392
383
( std_to_wx_string(m->get_label()) );
394
mark_placement p = m_snapshot->get_placement(m->get_label());
396
m_mark_left_spin->SetValue(p.get_position_x());
397
m_mark_bottom_spin->SetValue(p.get_position_y());
398
m_mark_depth_spin->SetValue(p.get_depth_position());
399
m_mark_angle_spin->SetValue(p.get_angle());
400
m_mark_visible_box->SetValue(p.is_visible());
385
mark_placement p = m_snapshot->get_placement(m->get_label());
387
m_mark_left_spin->SetValue(p.get_position_x());
388
m_mark_bottom_spin->SetValue(p.get_position_y());
389
m_mark_depth_spin->SetValue(p.get_depth_position());
390
m_mark_angle_spin->SetValue(p.get_angle());
391
m_mark_visible_box->SetValue(p.is_visible());
404
395
m_mark_left_spin->Enable(enable);
405
396
m_mark_bottom_spin->Enable(enable);
406
397
m_mark_depth_spin->Enable(enable);
411
402
/*----------------------------------------------------------------------------*/
413
* \brief The mark placement has changed.
404
* \brief The mark placement has changed.
415
406
void bf::snapshot_frame::placement_change()
417
408
mark* m( m_model_frame->get_model().get_main_mark_selection() );
419
410
m_model_frame->do_action
420
411
( new action_modify_placement
421
412
(m_snapshot, m, m_mark_left_spin->GetValue(),
426
417
/*----------------------------------------------------------------------------*/
428
* \brief The alignment has changed.
419
* \brief The alignment has changed.
430
421
void bf::snapshot_frame::alignment_change()
432
423
m_model_frame->do_action
433
424
( new action_modify_snapshot_alignment
435
wx_to_std_string(m_x_alignment_choice->GetStringSelection()),
426
wx_to_std_string(m_x_alignment_choice->GetStringSelection()),
436
427
m_x_alignment_value_spin->GetValue(),
437
wx_to_std_string(m_y_alignment_choice->GetStringSelection()),
428
wx_to_std_string(m_y_alignment_choice->GetStringSelection()),
438
429
m_y_alignment_value_spin->GetValue() ) );
439
430
} // snapshot_frame::alignment_change()
441
432
/*----------------------------------------------------------------------------*/
443
* \brief The size has changed.
434
* \brief The size has changed.
445
436
void bf::snapshot_frame::size_change()
452
443
/*----------------------------------------------------------------------------*/
454
* \brief The sound has changed.
445
* \brief The sound has changed.
456
447
void bf::snapshot_frame::sound_change()
458
449
sound_description sound;
460
sound.set_file( wx_to_std_string( m_sound_path->GetValue() ) );
451
sound.set_file( wx_to_std_string( m_sound_path->GetValue() ) );
461
452
sound.set_played_globally(m_globally_sound_box->IsChecked());
462
453
m_model_frame->do_action
463
( new action_modify_snapshot_sound(m_snapshot,sound) );
454
( new action_modify_snapshot_sound(m_snapshot, sound) );
464
455
} // snapshot_frame::sound_change()
466
457
/*----------------------------------------------------------------------------*/
459
* \brief Enable or disable the controls.
460
* \param enable Tell if the controls have to be enabled.
462
void bf::snapshot_frame::enable_controls(bool enable)
464
m_date_button->Enable(enable);
465
m_mark_choice->Enable(enable);
466
m_function_button->Enable(enable);
467
m_mark_visible_box->Enable(enable);
468
m_sound_button->Enable(enable);
469
m_sound_path->Enable(enable);
470
m_globally_sound_box->Enable(enable);
471
m_width_spin->Enable(enable);
472
m_height_spin->Enable(enable);
473
m_x_alignment_choice->Enable(enable);
474
m_y_alignment_choice->Enable(enable);
475
m_x_alignment_value_spin->Enable(enable);
476
m_y_alignment_value_spin->Enable(enable);
477
} // snapshot_frame::enable_controls()
479
/*----------------------------------------------------------------------------*/
468
481
* \brief Procedure called when closing the window.
469
482
* \param event This event occured.
482
495
* \brief The date button is pressed.
483
496
* \param event The event that occured.
485
void bf::snapshot_frame::on_date_change( wxCommandEvent& event )
498
void bf::snapshot_frame::on_date_change( wxCommandEvent& WXUNUSED(event) )
487
500
action& act = m_model_frame->get_model().get_active_action();
488
501
snapshot_date_frame dlg(this, &act);
490
503
dlg.fill_from( m_snapshot );
492
505
if ( dlg.ShowModal() == wxID_OK )
494
507
double new_date = dlg.get_date();
495
508
double initial_date = m_snapshot->get_date();
497
if ( new_date != initial_date )
510
if ( new_date != initial_date )
499
512
action_group* group = new action_group();
500
513
group->set_description(_("Move snapshot"));
502
515
if ( act.has_snapshot_date( new_date ) )
503
516
group->add_action
504
517
( new action_remove_snapshot
505
( act.get_name(), act.get_snapshot(new_date)));
519
act.get_snapshot_before_or_at_date(new_date)));
507
521
group->add_action
508
522
( new action_move_snapshot(m_snapshot, new_date) );
510
524
if ( initial_date == 0 )
512
snapshot* s = new snapshot(* act.get_snapshot(initial_date));
528
( *act.get_snapshot_before_or_at_date(initial_date));
514
530
group->add_action
515
531
( new action_add_snapshot( act.get_name(), s));
518
534
m_model_frame->do_action(group);
519
535
m_model_frame->set_date(new_date);
599
618
* \brief The function button is pressed.
600
619
* \param event The event that occured.
602
void bf::snapshot_frame::on_function_change( wxCommandEvent& event )
621
void bf::snapshot_frame::on_function_change( wxCommandEvent& WXUNUSED(event) )
604
wxTextEntryDialog dlg
605
(this, _("Function :"), _("Set function"),
623
wxTextEntryDialog dlg
624
(this, _("Function:"), _("Set function"),
606
625
std_to_wx_string(m_snapshot->get_function()) );
608
627
if ( dlg.ShowModal() == wxID_OK )
610
629
m_model_frame->do_action
611
( new action_modify_function
630
( new action_modify_function
612
631
(m_snapshot, wx_to_std_string(dlg.GetValue())) );
616
635
} // snapshot_frame::on_function_change()
630
650
* \brief The sound_file button is pressed.
631
651
* \param event The event that occured.
633
void bf::snapshot_frame::on_sound_file_edit( wxCommandEvent& event )
653
void bf::snapshot_frame::on_sound_file_edit( wxCommandEvent& WXUNUSED(event) )
635
655
std::string p = wx_to_std_string(m_sound_path->GetValue());
636
656
path_configuration::get_instance().get_full_path(p);
638
wxFileDialog dlg(this,_("Choose a sound"), wxEmptyString,
658
wxFileDialog dlg(this,_("Choose a sound"), wxEmptyString,
639
659
std_to_wx_string(p),
640
_("sound files (*.ogg;*.wav)|*.wav;*.ogg"),
660
_("Sound files (*.ogg;*.wav)|*.wav;*.ogg"),
641
661
wxFD_DEFAULT_STYLE | wxFD_FILE_MUST_EXIST );
643
663
if ( dlg.ShowModal() == wxID_OK )
645
665
std::string new_p = wx_to_std_string( dlg.GetPath() );
646
666
path_configuration::get_instance().get_relative_path(new_p);
648
668
m_sound_path->SetValue(std_to_wx_string(new_p) ) ;
654
674
/*----------------------------------------------------------------------------*/
656
* \brief The sound_path has been modified.
676
* \brief The text sound_file is edited.
657
677
* \param event The event that occured.
659
void bf::snapshot_frame::on_sound_file_change( wxCommandEvent& event )
679
void bf::snapshot_frame::on_sound_text_edit( wxCommandEvent& WXUNUSED(event) )
662
} // snapshot_frame::on_sound_file_change()
682
} // snapshot_frame::on_sound_text_edit()
664
684
/*----------------------------------------------------------------------------*/
665
685
BEGIN_EVENT_TABLE(bf::snapshot_frame, wxPanel)
666
686
EVT_CLOSE( bf::snapshot_frame::on_close )
667
687
EVT_BUTTON( bf::snapshot_frame::IDC_DATE_CTRL,
668
688
bf::snapshot_frame::on_date_change )
669
EVT_CHOICE(bf::snapshot_frame::IDC_MARK_CHOICE,
689
EVT_CHOICE(bf::snapshot_frame::IDC_MARK_CHOICE,
670
690
bf::snapshot_frame::on_mark_change)
671
EVT_CHOICE(bf::snapshot_frame::IDC_ALIGNMENT,
691
EVT_CHOICE(bf::snapshot_frame::IDC_ALIGNMENT,
672
692
bf::snapshot_frame::on_alignment_choice_change)
673
EVT_SPIN_VALUE_CHANGE(bf::snapshot_frame::IDC_MARK_PLACEMENT,
693
EVT_SPIN_VALUE_CHANGE(bf::snapshot_frame::IDC_MARK_PLACEMENT,
674
694
bf::snapshot_frame::on_placement_change,
676
EVT_SPIN_VALUE_CHANGE(bf::snapshot_frame::IDC_ALIGNMENT,
696
EVT_SPIN_VALUE_CHANGE(bf::snapshot_frame::IDC_ALIGNMENT,
677
697
bf::snapshot_frame::on_alignment_change,
679
EVT_SPIN_VALUE_CHANGE(bf::snapshot_frame::IDC_SIZE,
699
EVT_SPIN_VALUE_CHANGE(bf::snapshot_frame::IDC_SIZE,
680
700
bf::snapshot_frame::on_size_change,
682
702
EVT_SPINCTRL( bf::snapshot_frame::IDC_MARK_PLACEMENT,
689
709
bf::snapshot_frame::on_globally_sound_change )
690
710
EVT_BUTTON( bf::snapshot_frame::IDC_SOUND_FILE,
691
711
bf::snapshot_frame::on_sound_file_edit )
692
EVT_TEXT_ENTER( bf::snapshot_frame::IDC_SOUND_FILE,
693
bf::snapshot_frame::on_sound_file_change )
712
EVT_TEXT( bf::snapshot_frame::IDC_SOUND_TEXT,
713
bf::snapshot_frame::on_sound_text_edit )
694
714
END_EVENT_TABLE()