]> git.sesse.net Git - vlc/blobdiff - modules/gui/wince/preferences.cpp
Removes trailing spaces. Removes tabs.
[vlc] / modules / gui / wince / preferences.cpp
index 708c2253665a583bb6b1e3e2b7676df5494f7b0d..f69c7b56424744daae5041c64d920c8c46885f66 100644 (file)
@@ -1,7 +1,7 @@
 /*****************************************************************************
  * preferences.cpp : WinCE gui plugin for VLC
  *****************************************************************************
- * Copyright (C) 2000-2004 VideoLAN
+ * Copyright (C) 2000-2004 the VideoLAN team
  * $Id$
  *
  * Authors: Marodon Cedric <cedric_marodon@yahoo.fr>
  *
  * 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.
  *****************************************************************************/
 
 /*****************************************************************************
  * Preamble
  *****************************************************************************/
-#include <stdlib.h>                                      /* malloc(), free() */
-#include <string.h>                                            /* strerror() */
-#include <stdio.h>
 #include <vlc/vlc.h>
-#include <vlc/intf.h>
+#include <vlc_interface.h>
 
 #include "wince.h"
 
@@ -77,7 +74,7 @@ public:
     /*void CleanChanges();*/
 
     void OnSelectTreeItem( LPNM_TREEVIEW pnmtv, HWND parent, HINSTANCE hInst );
-        
     ConfigTreeData *FindModuleConfig( ConfigTreeData *config_data );
 
     HWND hwndTV;
@@ -87,7 +84,6 @@ private:
     PrefsDialog *p_prefs_dialog;
     vlc_bool_t b_advanced;
 
-    HTREEITEM root_item;
     HTREEITEM general_item;
     HTREEITEM plugins_item;
 };
@@ -143,20 +139,20 @@ public:
 /*****************************************************************************
  * Constructor.
  *****************************************************************************/
-PrefsDialog::PrefsDialog( intf_thread_t *_p_intf, HINSTANCE _hInst )
+PrefsDialog::PrefsDialog( intf_thread_t *p_intf, CBaseWindow *p_parent,
+                          HINSTANCE h_inst )
+  :  CBaseWindow( p_intf, p_parent, h_inst )
 {
     /* Initializations */
-    p_intf = _p_intf;
-    hInst = _hInst;
     prefs_tree = NULL;
 }
 
 /***********************************************************************
 
-FUNCTION: 
+FUNCTION:
   WndProc
 
-PURPOSE: 
+PURPOSE:
   Processes messages sent to the main window.
 
 ***********************************************************************/
@@ -193,7 +189,7 @@ LRESULT PrefsDialog::WndProc( HWND hwnd, UINT msg, WPARAM wp, LPARAM lp )
         // Get the client area rect to put the panels in
         GetClientRect(hwnd, &rcClient);
 
-        /* Create the buttons */            
+        /* Create the buttons */
         advanced_checkbox =
             CreateWindow( _T("BUTTON"), _T("Advanced options"),
                         WS_CHILD | WS_VISIBLE | BS_AUTOCHECKBOX,
@@ -227,6 +223,10 @@ LRESULT PrefsDialog::WndProc( HWND hwnd, UINT msg, WPARAM wp, LPARAM lp )
         EndDialog( hwnd, LOWORD( wp ) );
         break;
 
+    case WM_SETFOCUS:
+        SHFullScreen( hwnd, SHFS_SHOWSIPBUTTON );
+        break;
+
     case WM_COMMAND:
         if( LOWORD(wp) == IDOK )
         {
@@ -251,21 +251,24 @@ LRESULT PrefsDialog::WndProc( HWND hwnd, UINT msg, WPARAM wp, LPARAM lp )
         TVITEM tvi = {0};
         tvi.mask = TVIF_PARAM;
         tvi.hItem = TreeView_GetSelection( prefs_tree->hwndTV );
-        TreeView_GetItem( prefs_tree->hwndTV, &tvi );
+    if( !tvi.hItem ) break;
+
+        if( !TreeView_GetItem( prefs_tree->hwndTV, &tvi ) ) break;
+
         ConfigTreeData *config_data =
             prefs_tree->FindModuleConfig( (ConfigTreeData *)tvi.lParam );
-        if ( hwnd == config_data->panel->config_window ) 
+        if( config_data && hwnd == config_data->panel->config_window )
         {
             int dy;
             RECT rc;
             GetWindowRect( hwnd, &rc);
             int newvalue = config_data->panel->oldvalue;
-            switch ( GET_WM_VSCROLL_CODE(wp,lp) ) 
+            switch ( GET_WM_VSCROLL_CODE(wp,lp) )
             {
             case SB_BOTTOM       : newvalue = 0; break;
             case SB_TOP          : newvalue = config_data->panel->maxvalue; break;
             case SB_LINEDOWN     : newvalue += 10; break;
-            case SB_PAGEDOWN     : newvalue += rc.bottom - rc.top - 25; break; // faux ! une page c'est la longueur rĂ©elle de notebook
+            case SB_PAGEDOWN     : newvalue += rc.bottom - rc.top - 25; break; // wrong! one page is notebook actual length
             case SB_LINEUP       : newvalue -= 10; break;
             case SB_PAGEUP       : newvalue -= rc.bottom - rc.top - 25; break;
             case SB_THUMBPOSITION:
@@ -278,7 +281,7 @@ LRESULT PrefsDialog::WndProc( HWND hwnd, UINT msg, WPARAM wp, LPARAM lp )
             ScrollWindowEx( hwnd, 0, dy, NULL, NULL, NULL, NULL, SW_SCROLLCHILDREN );
             UpdateWindow ( hwnd);
 
-            config_data->panel->oldvalue = newvalue;                                
+            config_data->panel->oldvalue = newvalue;
         }
         break;
     }
@@ -317,8 +320,8 @@ PrefsTreeCtrl::PrefsTreeCtrl( intf_thread_t *_p_intf,
 
     INITCOMMONCONTROLSEX iccex;
     RECT rcClient;
-    TVITEM tvi = {0}; 
-    TVINSERTSTRUCT tvins = {0}; 
+    TVITEM tvi = {0};
+    TVINSERTSTRUCT tvins = {0};
     HTREEITEM hPrev;
 
     size_t i_capability_count = 0;
@@ -349,17 +352,7 @@ PrefsTreeCtrl::PrefsTreeCtrl( intf_thread_t *_p_intf,
         5, 10 + 2*(15 + 10) + 105 + 5, rcClient.right - 5 - 5, 6*15,
         hwnd, NULL, hInst, NULL );
 
-    tvi.mask = TVIF_TEXT | TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_PARAM; 
-    tvi.pszText = _T("root");
-    tvi.cchTextMax = lstrlen(_T("root"));
-    tvi.lParam = (LPARAM) 1; // root level
-    tvins.item = tvi;
-    tvins.hInsertAfter = TVI_FIRST; 
-    tvins.hParent = TVI_ROOT; 
-
-    // Add the item to the tree-view control. 
-    hPrev = (HTREEITEM) TreeView_InsertItem( hwndTV, &tvins );
-    root_item = hPrev;
+    tvi.mask = TVIF_TEXT | TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_PARAM;
 
     /* List the plugins */
     p_list = vlc_list_find( p_intf, VLC_OBJECT_MODULE, FIND_ANYWHERE );
@@ -374,10 +367,10 @@ PrefsTreeCtrl::PrefsTreeCtrl( intf_thread_t *_p_intf,
     config_data->psz_section = strdup( GENERAL_TITLE );
     tvi.pszText = _T("General settings");
     tvi.cchTextMax = lstrlen(_T("General settings"));
-    tvi.lParam = (long) config_data;
+    tvi.lParam = (long)config_data;
     tvins.item = tvi;
-    tvins.hInsertAfter = hPrev;
-    tvins.hParent = root_item; //level 2
+    tvins.hInsertAfter = TVI_FIRST;
+    tvins.hParent = TVI_ROOT;
 
     // Add the item to the tree-view control.
     hPrev = (HTREEITEM) TreeView_InsertItem( hwndTV, &tvins);
@@ -416,15 +409,15 @@ PrefsTreeCtrl::PrefsTreeCtrl( intf_thread_t *_p_intf,
                 config_data->i_object_id = p_module->i_object_id;
 
                 /* Add the category to the tree */
-                // Set the text of the item. 
-                tvi.pszText = _FROMMB(p_item->psz_text); 
+                // Set the text of the item.
+                tvi.pszText = _FROMMB(p_item->psz_text);
                 tvi.cchTextMax = _tcslen(tvi.pszText);
                 tvi.lParam = (long)config_data;
                 tvins.item = tvi;
-                tvins.hInsertAfter = hPrev; 
+                tvins.hInsertAfter = hPrev;
                 tvins.hParent = general_item; //level 3
-    
-                // Add the item to the tree-view control. 
+                // Add the item to the tree-view control.
                 hPrev = (HTREEITEM)TreeView_InsertItem( hwndTV, &tvins );
 
                 break;
@@ -434,7 +427,7 @@ PrefsTreeCtrl::PrefsTreeCtrl( intf_thread_t *_p_intf,
 
         TreeView_SortChildren( hwndTV, general_item, 0 );
     }
-        
     /*
      * Build a tree of all the plugins
      */
@@ -444,10 +437,10 @@ PrefsTreeCtrl::PrefsTreeCtrl( intf_thread_t *_p_intf,
     config_data->psz_section = strdup("nothing");//strdup( PLUGIN_TITLE );
     tvi.pszText = _T("Modules");
     tvi.cchTextMax = lstrlen(_T("Modules"));
-    tvi.lParam = (long) config_data;
+    tvi.lParam = (long)config_data;
     tvins.item = tvi;
-    tvins.hInsertAfter = hPrev;
-    tvins.hParent = root_item;// level 2
+    tvins.hInsertAfter = TVI_LAST;
+    tvins.hParent = TVI_ROOT;
 
     // Add the item to the tree-view control.
     hPrev = (HTREEITEM) TreeView_InsertItem( hwndTV, &tvins);
@@ -513,12 +506,12 @@ PrefsTreeCtrl::PrefsTreeCtrl( intf_thread_t *_p_intf,
             config_data->i_object_id = CAPABILITY_ID;
             tvi.pszText = _FROMMB(p_module->psz_capability);
             tvi.cchTextMax = _tcslen(tvi.pszText);
-            tvi.lParam = (long) config_data;
+            tvi.lParam = (long)config_data;
             tvins.item = tvi;
-            tvins.hInsertAfter = plugins_item; 
+            tvins.hInsertAfter = plugins_item;
             tvins.hParent = plugins_item;// level 3
 
-            // Add the item to the tree-view control. 
+            // Add the item to the tree-view control.
             capability_item = (HTREEITEM) TreeView_InsertItem( hwndTV, &tvins);
 
             i_capability_count++;
@@ -533,12 +526,12 @@ PrefsTreeCtrl::PrefsTreeCtrl( intf_thread_t *_p_intf,
         config_data->psz_help = NULL;
         tvi.pszText = _FROMMB(p_module->psz_object_name);
         tvi.cchTextMax = _tcslen(tvi.pszText);
-        tvi.lParam = (long) config_data;
+        tvi.lParam = (long)config_data;
         tvins.item = tvi;
-        tvins.hInsertAfter = capability_item; 
+        tvins.hInsertAfter = capability_item;
         tvins.hParent = capability_item;// level 4
 
-        // Add the item to the tree-view control. 
+        // Add the item to the tree-view control.
         TreeView_InsertItem( hwndTV, &tvins );
     }
 
@@ -555,7 +548,6 @@ PrefsTreeCtrl::PrefsTreeCtrl( intf_thread_t *_p_intf,
     /* Clean-up everything */
     vlc_list_release( p_list );
 
-    TreeView_Expand( hwndTV, root_item, TVE_EXPANDPARTIAL |TVE_EXPAND );
     TreeView_Expand( hwndTV, general_item, TVE_EXPANDPARTIAL |TVE_EXPAND );
 }
 
@@ -591,7 +583,7 @@ void PrefsTreeCtrl::ApplyChanges()
     {
         HTREEITEM item2 = TreeView_GetChild( hwndTV, item );
         while( item2 != 0 )
-        {       
+        {
             TVITEM tvi = {0};
             tvi.mask = TVIF_PARAM;
             tvi.hItem = item2;
@@ -624,7 +616,7 @@ ConfigTreeData *PrefsTreeCtrl::FindModuleConfig( ConfigTreeData *config_data )
     {
         HTREEITEM item2 = TreeView_GetChild( hwndTV, item );
         while( item2 != 0 )
-        {       
+        {
             TVITEM tvi = {0};
             tvi.mask = TVIF_PARAM;
             tvi.hItem = item2;
@@ -727,11 +719,10 @@ PrefsPanel::PrefsPanel( HWND parent, HINSTANCE hInst, intf_thread_t *_p_intf,
         /* Find the category if it has been specified */
         if( psz_section && p_item->i_type == CONFIG_HINT_CATEGORY )
         {
-            while( !p_item->i_type == CONFIG_HINT_CATEGORY ||
+            while( !(p_item->i_type == CONFIG_HINT_CATEGORY) ||
                    strcmp( psz_section, p_item->psz_text ) )
             {
-                if( p_item->i_type == CONFIG_HINT_END )
-                    break;
+                if( p_item->i_type == CONFIG_HINT_END ) break;
                 p_item++;
             }
         }
@@ -785,7 +776,7 @@ PrefsPanel::PrefsPanel( HWND parent, HINSTANCE hInst, intf_thread_t *_p_intf,
             config_array.push_back( control );
         }
         while( p_item->i_type != CONFIG_HINT_END && p_item++ );
-                
         GetWindowRect( config_window, &rc);
         maxvalue = y_pos - (rc.bottom - rc.top) + 5;
         oldvalue = 0;
@@ -825,7 +816,7 @@ void PrefsPanel::ApplyChanges()
         case CONFIG_ITEM_KEY:
             /* So you don't need to restart to have the changes take effect */
             val.i_int = control->GetIntValue();
-            var_Set( p_intf->p_vlc, control->GetName(), val );
+            var_Set( p_intf->p_libvlc, control->GetName(), val );
         case CONFIG_ITEM_INTEGER:
         case CONFIG_ITEM_BOOL:
             config_PutInt( p_intf, control->GetName(),