]> git.sesse.net Git - vlc/blobdiff - modules/gui/wxwindows/preferences_widgets.cpp
* string review
[vlc] / modules / gui / wxwindows / preferences_widgets.cpp
index 4a47dcaadf8fdccc9270a18235669986c49a9543..243cbb62c9967fa396e5be7714b95006c52e438a 100644 (file)
@@ -1,10 +1,10 @@
 /*****************************************************************************
  * preferences_widgets.cpp : wxWindows plugin for vlc
  *****************************************************************************
- * Copyright (C) 2000-2001 VideoLAN
- * $Id: preferences_widgets.cpp,v 1.13 2003/11/05 18:59:01 gbazin Exp $
+ * Copyright (C) 2000-2004 VideoLAN
+ * $Id$
  *
- * Authors: Gildas Bazin <gbazin@netcourrier.com>
+ * Authors: Gildas Bazin <gbazin@videolan.org>
  *          Sigmund Augdal <sigmunau@idi.ntnu.no>
  *
  * This program is free software; you can redistribute it and/or modify
@@ -107,8 +107,11 @@ ConfigControl *CreateConfigControl( vlc_object_t *p_this,
  *****************************************************************************/
 ConfigControl::ConfigControl( vlc_object_t *_p_this,
                               module_config_t *p_item, wxWindow *parent )
-  : wxPanel( parent ), p_this( _p_this ), name( wxU(p_item->psz_name) ),
-    i_type( p_item->i_type ), b_advanced( p_item->b_advanced )
+  : wxPanel( parent ), p_this( _p_this ),
+    pf_update_callback( NULL ), p_update_data( NULL ),
+    name( wxU(p_item->psz_name) ), i_type( p_item->i_type ),
+    b_advanced( p_item->b_advanced )
+
 {
     sizer = new wxBoxSizer( wxHORIZONTAL );
 }
@@ -137,85 +140,43 @@ vlc_bool_t ConfigControl::IsAdvanced()
     return b_advanced;
 }
 
+void ConfigControl::SetUpdateCallback( void (*p_callback)( void * ),
+                                             void *p_data )
+{
+    pf_update_callback = p_callback;
+    p_update_data = p_data;
+}
+
+void ConfigControl::OnUpdate( wxCommandEvent& WXUNUSED(event) )
+{
+    if( pf_update_callback )
+    {
+        pf_update_callback( p_update_data );
+    }
+}
+
 /*****************************************************************************
  * KeyConfigControl implementation
  *****************************************************************************/
-static wxString KeysList[] =
-{
-    wxT("Unset"),
-    wxT("Left"),
-    wxT("Right"),
-    wxT("Up"),
-    wxT("Down"),
-    wxT("Space"),
-    wxT("Enter"),
-    wxT("F1"),
-    wxT("F2"),
-    wxT("F3"),
-    wxT("F4"),
-    wxT("F5"),
-    wxT("F6"),
-    wxT("F7"),
-    wxT("F8"),
-    wxT("F9"),
-    wxT("F10"),
-    wxT("F11"),
-    wxT("F12"),
-    wxT("Home"),
-    wxT("End"),
-    wxT("Menu"),
-    wxT("Esc"),
-    wxT("Page Up"),
-    wxT("Page Down"),
-    wxT("Tab"),
-    wxT("Backspace"),
-    wxT("a"),
-    wxT("b"),
-    wxT("c"),
-    wxT("d"),
-    wxT("e"),
-    wxT("f"),
-    wxT("g"),
-    wxT("h"),
-    wxT("i"),
-    wxT("j"),
-    wxT("k"),
-    wxT("l"),
-    wxT("m"),
-    wxT("n"),
-    wxT("o"),
-    wxT("p"),
-    wxT("q"),
-    wxT("r"),
-    wxT("s"),
-    wxT("t"),
-    wxT("u"),
-    wxT("v"),
-    wxT("w"),
-    wxT("x"),
-    wxT("y"),
-    wxT("z"),
-    wxT("+"),
-    wxT("="),
-    wxT("-"),
-    wxT(","),
-    wxT("."),
-    wxT("<"),
-    wxT(">"),
-    wxT("`"),
-    wxT("/"),
-    wxT(";"),
-    wxT("'"),
-    wxT("\\"),
-    wxT("["),
-    wxT("]"),
-    wxT("*")
-};
+wxString *KeyConfigControl::m_keysList = NULL;
 
 KeyConfigControl::KeyConfigControl( vlc_object_t *p_this,
                                     module_config_t *p_item, wxWindow *parent )
   : ConfigControl( p_this, p_item, parent )
 {
+    // Number of keys descriptions
+    unsigned int i_keys = sizeof(vlc_keys)/sizeof(key_descriptor_t);
+
+    // Init the keys decriptions array
+    if( m_keysList == NULL )
+    {
+        m_keysList = new wxString[i_keys];
+        for( unsigned int i = 0; i < i_keys; i++ )
+        {
+            m_keysList[i] = wxU(vlc_keys[i].psz_key_string);
+        }
+    }
+
     label = new wxStaticText(this, -1, wxU(p_item->psz_text));
     alt = new wxCheckBox( this, -1, wxU(_("Alt")) );
     alt->SetValue( p_item->i_value & KEY_MODIFIER_ALT );
@@ -224,16 +185,16 @@ KeyConfigControl::KeyConfigControl( vlc_object_t *p_this,
     shift = new wxCheckBox( this, -1, wxU(_("Shift")) );
     shift->SetValue( p_item->i_value & KEY_MODIFIER_SHIFT );
     combo = new wxComboBox( this, -1, wxT(""), wxDefaultPosition,
-                            wxDefaultSize, WXSIZEOF(KeysList), KeysList,
+                            wxDefaultSize, i_keys, m_keysList,
                             wxCB_READONLY );
-    for( unsigned int i = 0; i < WXSIZEOF(KeysList); i++ )
+    for( unsigned int i = 0; i < i_keys; i++ )
     {
-        combo->SetClientData( i, (void*)keys[i].i_key_code );
-        if( keys[i].i_key_code ==
+        combo->SetClientData( i, (void*)vlc_keys[i].i_key_code );
+        if( (unsigned int)vlc_keys[i].i_key_code ==
             ( ((unsigned int)p_item->i_value) & ~KEY_MODIFIER ) )
         {
             combo->SetSelection( i );
-            combo->SetValue( wxU(_(keys[i].psz_key_string)) );
+            combo->SetValue( wxU(_(vlc_keys[i].psz_key_string)) );
         }
     }
 
@@ -248,7 +209,11 @@ KeyConfigControl::KeyConfigControl( vlc_object_t *p_this,
 
 KeyConfigControl::~KeyConfigControl()
 {
-    ;
+    if( m_keysList )
+    {
+        delete[] m_keysList;
+        m_keysList = NULL;
+    }
 }
 
 int KeyConfigControl::GetIntValue()
@@ -286,7 +251,7 @@ ModuleConfigControl::ModuleConfigControl( vlc_object_t *p_this,
     module_t *p_parser;
 
     label = new wxStaticText(this, -1, wxU(p_item->psz_text));
-    combo = new wxComboBox( this, -1, wxU(p_item->psz_value),
+    combo = new wxComboBox( this, -1, wxL2U(p_item->psz_value),
                             wxDefaultPosition, wxDefaultSize,
                             0, NULL, wxCB_READONLY | wxCB_SORT );
 
@@ -302,7 +267,7 @@ ModuleConfigControl::ModuleConfigControl( vlc_object_t *p_this,
         {
             combo->Append( wxU(p_parser->psz_longname),
                            p_parser->psz_object_name );
-            if( p_item->psz_value && !strcmp(p_item->psz_value, 
+            if( p_item->psz_value && !strcmp(p_item->psz_value,
                                              p_parser->psz_object_name) )
                 combo->SetValue( wxU(p_parser->psz_longname) );
         }
@@ -336,8 +301,8 @@ StringConfigControl::StringConfigControl( vlc_object_t *p_this,
 {
     label = new wxStaticText(this, -1, wxU(p_item->psz_text));
     sizer->Add( label, 1, wxALIGN_CENTER_VERTICAL | wxALL, 5 );
-    textctrl = new wxTextCtrl( this, -1, 
-                               wxU(p_item->psz_value),
+    textctrl = new wxTextCtrl( this, -1,
+                               wxL2U(p_item->psz_value),
                                wxDefaultPosition,
                                wxDefaultSize,
                                wxTE_PROCESS_ENTER);
@@ -357,14 +322,22 @@ wxString StringConfigControl::GetPszValue()
     return textctrl->GetValue();
 }
 
+BEGIN_EVENT_TABLE(StringConfigControl, wxPanel)
+    /* Text events */
+    EVT_TEXT(-1, StringConfigControl::OnUpdate)
+END_EVENT_TABLE()
+
 /*****************************************************************************
  * StringListConfigControl implementation
  *****************************************************************************/
 StringListConfigControl::StringListConfigControl( vlc_object_t *p_this,
                                                   module_config_t *p_item,
                                                   wxWindow *parent )
-  : ConfigControl( p_this, p_item, parent ), psz_name( NULL )
+  : ConfigControl( p_this, p_item, parent )
 {
+    psz_default_value = p_item->psz_value;
+    if( psz_default_value ) psz_default_value = strdup( psz_default_value );
+
     label = new wxStaticText(this, -1, wxU(p_item->psz_text));
     sizer->Add( label, 1, wxALIGN_CENTER_VERTICAL | wxALL, 5 );
     combo = new wxComboBox( this, -1, wxT(""),
@@ -373,16 +346,14 @@ StringListConfigControl::StringListConfigControl( vlc_object_t *p_this,
     UpdateCombo( p_item );
 
     combo->SetToolTip( wxU(p_item->psz_longtext) );
-    sizer->Add( combo, 1, wxALIGN_CENTER_VERTICAL | wxALL, 5 );    
+    sizer->Add( combo, 1, wxALIGN_CENTER_VERTICAL | wxALL, 5 );
 
-    if( p_item->pf_list_update )
+    for( int i = 0; i < p_item->i_action; i++ )
     {
-        wxButton *refresh =
-            new wxButton( this, wxID_HIGHEST, wxU(_("Refresh")) );
-        sizer->Add( refresh, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5);
-
-        psz_name = strdup( p_item->psz_name );
-        pf_list_update = p_item->pf_list_update;
+        wxButton *button =
+            new wxButton( this, wxID_HIGHEST+i,
+                          wxU(p_item->ppsz_action_text[i]) );
+        sizer->Add( button, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5);
     }
 
     sizer->Layout();
@@ -391,18 +362,21 @@ StringListConfigControl::StringListConfigControl( vlc_object_t *p_this,
 
 StringListConfigControl::~StringListConfigControl()
 {
-    if( psz_name ) free( psz_name );
+    if( psz_default_value ) free( psz_default_value );
 }
 
 void StringListConfigControl::UpdateCombo( module_config_t *p_item )
 {
+    vlc_bool_t b_found = VLC_FALSE;
+    int i_index;
+
     /* build a list of available options */
-    for( int i_index = 0; i_index < p_item->i_list; i_index++ )
+    for( i_index = 0; i_index < p_item->i_list; i_index++ )
     {
         combo->Append( ( p_item->ppsz_list_text &&
                          p_item->ppsz_list_text[i_index] ) ?
                        wxU(p_item->ppsz_list_text[i_index]) :
-                       wxU(p_item->ppsz_list[i_index]) );
+                       wxL2U(p_item->ppsz_list[i_index]) );
         combo->SetClientData( i_index, (void *)p_item->ppsz_list[i_index] );
         if( ( p_item->psz_value &&
               !strcmp( p_item->psz_value, p_item->ppsz_list[i_index] ) ) ||
@@ -412,28 +386,48 @@ void StringListConfigControl::UpdateCombo( module_config_t *p_item )
             combo->SetValue( ( p_item->ppsz_list_text &&
                                p_item->ppsz_list_text[i_index] ) ?
                              wxU(p_item->ppsz_list_text[i_index]) :
-                             wxU(p_item->ppsz_list[i_index]) );
+                             wxL2U(p_item->ppsz_list[i_index]) );
+            b_found = VLC_TRUE;
         }
     }
+
+    if( p_item->psz_value && !b_found )
+    {
+        /* Add custom entry to list */
+        combo->Append( wxL2U(p_item->psz_value) );
+        combo->SetClientData( i_index, (void *)psz_default_value );
+        combo->SetSelection( i_index );
+        combo->SetValue( wxL2U(p_item->psz_value) );
+    }
 }
 
 BEGIN_EVENT_TABLE(StringListConfigControl, wxPanel)
     /* Button events */
-    EVT_BUTTON(wxID_HIGHEST, StringListConfigControl::OnRefresh)
+    EVT_BUTTON(-1, StringListConfigControl::OnAction)
+
+    /* Text events */
+    EVT_TEXT(-1, StringListConfigControl::OnUpdate)
 END_EVENT_TABLE()
 
-void StringListConfigControl::OnRefresh( wxCommandEvent& event )
+void StringListConfigControl::OnAction( wxCommandEvent& event )
 {
-    if( pf_list_update )
-    {
-        vlc_value_t val;
-        module_config_t *p_item;
+    int i_action = event.GetId() - wxID_HIGHEST;
+
+    module_config_t *p_item = config_FindConfig( p_this, GetName().mb_str() );
+    if( !p_item ) return;
 
-        pf_list_update( p_this, psz_name, val, val, 0 );
-        p_item = config_FindConfig( p_this, psz_name );
+    if( i_action < 0 || i_action >= p_item->i_action ) return;
 
+    vlc_value_t val;
+    wxString value = GetPszValue();
+    *((const char **)&val.psz_string) = value.mb_str();
+    p_item->ppf_action[i_action]( p_this, GetName().mb_str(), val, val, 0 );
+
+    if( p_item->b_dirty )
+    {
         combo->Clear();
         UpdateCombo( p_item );
+        p_item->b_dirty = VLC_FALSE;
     }
 }
 
@@ -442,7 +436,7 @@ wxString StringListConfigControl::GetPszValue()
     int selected = combo->GetSelection();
     if( selected != -1 )
     {
-        return wxU((char *)combo->GetClientData( selected ));
+        return wxL2U((char *)combo->GetClientData( selected ));
     }
     return wxString();
 }
@@ -458,8 +452,8 @@ FileConfigControl::FileConfigControl( vlc_object_t *p_this,
     directory = p_item->i_type == CONFIG_ITEM_DIRECTORY;
     label = new wxStaticText(this, -1, wxU(p_item->psz_text));
     sizer->Add( label, 1, wxALIGN_CENTER_VERTICAL | wxALL, 5 );
-    textctrl = new wxTextCtrl( this, -1, 
-                               wxU(p_item->psz_value),
+    textctrl = new wxTextCtrl( this, -1,
+                               wxL2U(p_item->psz_value),
                                wxDefaultPosition,
                                wxDefaultSize,
                                wxTE_PROCESS_ENTER);
@@ -480,16 +474,16 @@ void FileConfigControl::OnBrowse( wxCommandEvent& event )
 {
     if( directory )
     {
-        wxDirDialog dialog( this, wxU(_("Choose Directory")) );
+        wxDirDialog dialog( this, wxU(_("Choose directory")) );
 
         if( dialog.ShowModal() == wxID_OK )
         {
-            textctrl->SetValue( dialog.GetPath() );      
+            textctrl->SetValue( dialog.GetPath() );
         }
     }
     else
     {
-        wxFileDialog dialog( this, wxU(_("Choose File")),
+        wxFileDialog dialog( this, wxU(_("Choose file")),
                              wxT(""), wxT(""), wxT("*.*"),
 #if defined( __WXMSW__ )
                              wxOPEN
@@ -497,6 +491,10 @@ void FileConfigControl::OnBrowse( wxCommandEvent& event )
                              wxOPEN | wxSAVE
 #endif
                            );
+        if( dialog.ShowModal() == wxID_OK )
+        {
+            textctrl->SetValue( dialog.GetPath() );
+        }
     }
 }
 
@@ -504,7 +502,7 @@ FileConfigControl::~FileConfigControl()
 {
     ;
 }
-    
+
 wxString FileConfigControl::GetPszValue()
 {
     return textctrl->GetValue();
@@ -513,6 +511,11 @@ wxString FileConfigControl::GetPszValue()
 /*****************************************************************************
  * IntegerConfigControl implementation
  *****************************************************************************/
+BEGIN_EVENT_TABLE(IntegerConfigControl, wxPanel)
+    EVT_TEXT(-1, IntegerConfigControl::OnUpdate)
+    EVT_COMMAND_SCROLL(-1, IntegerConfigControl::OnUpdate)
+END_EVENT_TABLE()
+
 IntegerConfigControl::IntegerConfigControl( vlc_object_t *p_this,
                                             module_config_t *p_item,
                                             wxWindow *parent )
@@ -524,10 +527,10 @@ IntegerConfigControl::IntegerConfigControl( vlc_object_t *p_this,
                                             p_item->i_value),
                            wxDefaultPosition, wxDefaultSize,
                            wxSP_ARROW_KEYS,
-                           -16000, 16000, p_item->i_value);
+                           -100000000, 100000000, p_item->i_value);
     spin->SetToolTip( wxU(p_item->psz_longtext) );
     sizer->Add( label, 1, wxALIGN_CENTER_VERTICAL | wxALL, 5 );
-    sizer->Add( spin, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5 );    
+    sizer->Add( spin, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5 );
     sizer->Layout();
     this->SetSizerAndFit( sizer );
 }
@@ -548,7 +551,7 @@ int IntegerConfigControl::GetIntValue()
 IntegerListConfigControl::IntegerListConfigControl( vlc_object_t *p_this,
                                                     module_config_t *p_item,
                                                     wxWindow *parent )
-  : ConfigControl( p_this, p_item, parent ), psz_name( NULL )
+  : ConfigControl( p_this, p_item, parent )
 {
     label = new wxStaticText(this, -1, wxU(p_item->psz_text));
     sizer->Add( label, 1, wxALIGN_CENTER_VERTICAL | wxALL, 5 );
@@ -559,17 +562,7 @@ IntegerListConfigControl::IntegerListConfigControl( vlc_object_t *p_this,
     UpdateCombo( p_item );
 
     combo->SetToolTip( wxU(p_item->psz_longtext) );
-    sizer->Add( combo, 1, wxALIGN_CENTER_VERTICAL | wxALL, 5 );    
-
-    if( p_item->pf_list_update )
-    {
-        wxButton *refresh =
-            new wxButton( this, wxID_HIGHEST, wxU(_("Refresh")) );
-        sizer->Add( refresh, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5);
-
-        psz_name = strdup( p_item->psz_name );
-        pf_list_update = p_item->pf_list_update;
-    }
+    sizer->Add( combo, 1, wxALIGN_CENTER_VERTICAL | wxALL, 5 );
 
     sizer->Layout();
     this->SetSizerAndFit( sizer );
@@ -577,7 +570,6 @@ IntegerListConfigControl::IntegerListConfigControl( vlc_object_t *p_this,
 
 IntegerListConfigControl::~IntegerListConfigControl()
 {
-    if( psz_name ) free( psz_name );
 }
 
 void IntegerListConfigControl::UpdateCombo( module_config_t *p_item )
@@ -585,41 +577,56 @@ void IntegerListConfigControl::UpdateCombo( module_config_t *p_item )
     /* build a list of available options */
     for( int i_index = 0; i_index < p_item->i_list; i_index++ )
     {
-        combo->Append( ( p_item->ppsz_list_text &&
-                         p_item->ppsz_list_text[i_index] ) ?
-                       wxU(p_item->ppsz_list_text[i_index]) :
-                       wxString::Format(wxT("%i"),
-                                        p_item->pi_list[i_index]) );
+        if( p_item->ppsz_list_text && p_item->ppsz_list_text[i_index] )
+        {
+            combo->Append( wxU(p_item->ppsz_list_text[i_index]) );
+        }
+        else
+        {
+            combo->Append( wxString::Format(wxT("%i"),
+                                            p_item->pi_list[i_index]) );
+        }
         combo->SetClientData( i_index, (void *)p_item->pi_list[i_index] );
         if( p_item->i_value == p_item->pi_list[i_index] )
         {
             combo->SetSelection( i_index );
-            combo->SetValue( ( p_item->ppsz_list_text &&
-                               p_item->ppsz_list_text[i_index] ) ?
-                             wxU(p_item->ppsz_list_text[i_index]) :
-                             wxString::Format(wxT("%i"),
-                                              p_item->pi_list[i_index]) );
+            if( p_item->ppsz_list_text && p_item->ppsz_list_text[i_index] )
+            {
+                combo->SetValue( wxU(p_item->ppsz_list_text[i_index]) );
+            }
+            else
+            {
+                combo->SetValue( wxString::Format(wxT("%i"),
+                                                  p_item->pi_list[i_index]) );
+            }
         }
     }
 }
 
 BEGIN_EVENT_TABLE(IntegerListConfigControl, wxPanel)
     /* Button events */
-    EVT_BUTTON(wxID_HIGHEST, IntegerListConfigControl::OnRefresh)
+    EVT_BUTTON(-1, IntegerListConfigControl::OnAction)
 END_EVENT_TABLE()
 
-void IntegerListConfigControl::OnRefresh( wxCommandEvent& event )
+void IntegerListConfigControl::OnAction( wxCommandEvent& event )
 {
-    if( pf_list_update )
-    {
-        vlc_value_t val;
-        module_config_t *p_item;
+    int i_action = event.GetId() - wxID_HIGHEST;
+
+    module_config_t *p_item;
+    p_item = config_FindConfig( p_this, GetName().mb_str() );
+    if( !p_item ) return;
 
-        pf_list_update( p_this, psz_name, val, val, 0 );
-        p_item = config_FindConfig( p_this, psz_name );
+    if( i_action < 0 || i_action >= p_item->i_action ) return;
 
+    vlc_value_t val;
+    val.i_int = GetIntValue();
+    p_item->ppf_action[i_action]( p_this, GetName().mb_str(), val, val, 0 );
+
+    if( p_item->b_dirty )
+    {
         combo->Clear();
         UpdateCombo( p_item );
+        p_item->b_dirty = VLC_FALSE;
     }
 }
 
@@ -636,6 +643,10 @@ int IntegerListConfigControl::GetIntValue()
 /*****************************************************************************
  * RangedIntConfigControl implementation
  *****************************************************************************/
+BEGIN_EVENT_TABLE(RangedIntConfigControl, wxPanel)
+    EVT_COMMAND_SCROLL(-1, RangedIntConfigControl::OnUpdate)
+END_EVENT_TABLE()
+
 RangedIntConfigControl::RangedIntConfigControl( vlc_object_t *p_this,
                                                 module_config_t *p_item,
                                                 wxWindow *parent )
@@ -647,7 +658,7 @@ RangedIntConfigControl::RangedIntConfigControl( vlc_object_t *p_this,
                            wxSL_LABELS | wxSL_HORIZONTAL );
     slider->SetToolTip( wxU(p_item->psz_longtext) );
     sizer->Add( label, 1, wxALIGN_CENTER_VERTICAL | wxALL, 5 );
-    sizer->Add( slider, 1, wxALIGN_CENTER_VERTICAL | wxALL, 5 );    
+    sizer->Add( slider, 1, wxALIGN_CENTER_VERTICAL | wxALL, 5 );
     sizer->Layout();
     this->SetSizerAndFit( sizer );
 }
@@ -665,6 +676,10 @@ int RangedIntConfigControl::GetIntValue()
 /*****************************************************************************
  * FloatConfigControl implementation
  *****************************************************************************/
+BEGIN_EVENT_TABLE(FloatConfigControl, wxPanel)
+    EVT_TEXT(-1, FloatConfigControl::OnUpdate)
+END_EVENT_TABLE()
+
 FloatConfigControl::FloatConfigControl( vlc_object_t *p_this,
                                         module_config_t *p_item,
                                         wxWindow *parent )
@@ -699,6 +714,10 @@ float FloatConfigControl::GetFloatValue()
 /*****************************************************************************
  * BoolConfigControl implementation
  *****************************************************************************/
+BEGIN_EVENT_TABLE(BoolConfigControl, wxPanel)
+    EVT_CHECKBOX(-1, BoolConfigControl::OnUpdate)
+END_EVENT_TABLE()
+
 BoolConfigControl::BoolConfigControl( vlc_object_t *p_this,
                                       module_config_t *p_item,
                                       wxWindow *parent )
@@ -719,12 +738,6 @@ BoolConfigControl::~BoolConfigControl()
 
 int BoolConfigControl::GetIntValue()
 {
-    if( checkbox->IsChecked() )
-    {
-        return 1;
-    }
-    else
-    {
-        return 0;
-    }
+    if( checkbox->IsChecked() ) return 1;
+    else return 0;
 }