WxWidgets: use wraptext in UTF-8 mode as that is the codeset for gettext
[vlc.git] / modules / gui / wxwidgets / dialogs / preferences.cpp
index 906e0ff..cce40e3 100644 (file)
@@ -18,7 +18,7 @@
  *
  * You should have received a copy of the GNU General Public License
  * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
  *****************************************************************************/
 
 /*****************************************************************************
@@ -84,6 +84,8 @@ private:
     wxWindow *p_parent;
     vlc_bool_t b_advanced;
 
+    wxPanel *p_current;
+
     wxTreeItemId root_item;
     wxTreeItemId plugins_item;
 };
@@ -199,11 +201,10 @@ PrefsDialog::PrefsDialog( intf_thread_t *_p_intf, wxWindow *p_parent)
     wxStaticLine *static_line = new wxStaticLine( panel, wxID_OK );
 
     /* Create the buttons */
-    wxButton *ok_button = new wxButton( panel, wxID_OK, wxU(_("OK")) );
+    wxButton *ok_button = new wxButton( panel, wxID_OK );
     ok_button->SetDefault();
-    wxButton *cancel_button = new wxButton( panel, wxID_CANCEL,
-                                            wxU(_("Cancel")) );
-    wxButton *save_button = new wxButton( panel, wxID_SAVE, wxU(_("Save")) );
+    wxButton *cancel_button = new wxButton( panel, wxID_CANCEL );
+    wxButton *save_button = new wxButton( panel, wxID_SAVE );
     wxButton *reset_button = new wxButton( panel, ResetAll_Event,
                                            wxU(_("Reset All")) );
 
@@ -375,8 +376,7 @@ PrefsTreeCtrl::PrefsTreeCtrl( wxWindow *_p_parent, intf_thread_t *_p_intf,
                 psz_help = config_CategoryHelpGet( p_item->i_value );
                 if( psz_help )
                 {
-                    config_data->psz_help = wraptext( strdup( psz_help ),
-                                                      72 , 1 );
+                    config_data->psz_help = wraptext( strdup( psz_help ), 72 );
                 }
                 else
                 {
@@ -424,8 +424,7 @@ PrefsTreeCtrl::PrefsTreeCtrl( wxWindow *_p_parent, intf_thread_t *_p_intf,
                     char *psz_help = config_CategoryHelpGet( p_item->i_value );
                     if( psz_help )
                     {
-                        cd->psz_help = wraptext( strdup( psz_help ),72 ,
-                                                 1 );
+                        cd->psz_help = wraptext( strdup( psz_help ), 72 );
                     }
                     else
                     {
@@ -441,8 +440,7 @@ PrefsTreeCtrl::PrefsTreeCtrl( wxWindow *_p_parent, intf_thread_t *_p_intf,
                 psz_help = config_CategoryHelpGet( p_item->i_value );
                 if( psz_help )
                 {
-                    config_data->psz_help = wraptext( strdup( psz_help ) ,
-                                                      72 , 1 );
+                    config_data->psz_help = wraptext( strdup( psz_help ), 72 );
                 }
                 else
                 {
@@ -605,11 +603,11 @@ PrefsTreeCtrl::PrefsTreeCtrl( wxWindow *_p_parent, intf_thread_t *_p_intf,
     }
 
     /* Sort all this mess */
-    wxTreeItemIdValue cookie; 
+    wxTreeItemIdValue cookie;
     size_t i_child_index;
     wxTreeItemId capability_item = GetFirstChild( root_item, cookie);
     for( i_child_index = 0;
-         (capability_item.IsOk() && 
+         (capability_item.IsOk() &&
           //(i_child_index < GetChildrenCount( plugins_item, FALSE )));
           (i_child_index < GetChildrenCount( root_item, FALSE )));
          i_child_index++ )
@@ -625,6 +623,8 @@ PrefsTreeCtrl::PrefsTreeCtrl( wxWindow *_p_parent, intf_thread_t *_p_intf,
     p_sizer->Add( this, 1, wxEXPAND | wxALL, 0 );
     p_sizer->Layout();
 
+    p_current = NULL;
+
     /* Update Tree Ctrl */
 #ifndef WIN32 /* Workaround a bug in win32 implementation */
     SelectItem( GetFirstChild( root_item, cookie ) );
@@ -689,6 +689,7 @@ void PrefsTreeCtrl::CleanChanges()
 #else
         p_sizer->Remove( config_data->panel );
 #endif
+        p_current = NULL;
     }
 
     wxTreeItemId category = GetFirstChild( root_item, cookie );
@@ -774,17 +775,15 @@ void PrefsTreeCtrl::OnSelectTreeItem( wxTreeEvent& event )
 {
     ConfigTreeData *config_data = NULL;
 
-    if( event.GetOldItem() )
-        config_data = FindModuleConfig( (ConfigTreeData *)GetItemData(
-                                        event.GetOldItem() ) );
-    if( config_data && config_data->panel )
+    if( p_current )
     {
-        config_data->panel->Hide();
+        p_current->Hide();
 #if (wxCHECK_VERSION(2,5,0))
-        p_sizer->Detach( config_data->panel );
+        p_sizer->Detach( p_current  );
 #else
-        p_sizer->Remove( config_data->panel );
+        p_sizer->Remove( p_current );
 #endif
+        p_current = NULL;
     }
 
     /* Don't use event.GetItem() because we also send fake events */
@@ -806,6 +805,8 @@ void PrefsTreeCtrl::OnSelectTreeItem( wxTreeEvent& event )
             config_data->panel->Show();
         }
 
+        p_current = config_data->panel;
+
         p_sizer->Add( config_data->panel, 3, wxEXPAND | wxALL, 0 );
         p_sizer->Layout();
     }
@@ -825,6 +826,7 @@ void PrefsTreeCtrl::OnAdvanced( wxCommandEvent& event )
 #else
         p_sizer->Remove( config_data->panel );
 #endif
+        p_current = NULL;
     }
 
     if( GetSelection() )