]> git.sesse.net Git - vlc/blobdiff - modules/gui/wince/subtitles.cpp
Removes trailing spaces. Removes tabs.
[vlc] / modules / gui / wince / subtitles.cpp
index d53d51f63990fb41b8fac86ddca7a327ba27680d..7a38c56b2d8ae31e7064945bfe652151e71a81a0 100644 (file)
@@ -1,7 +1,7 @@
 /*****************************************************************************
  * subtitles.cpp : WinCE gui plugin for VLC
  *****************************************************************************
- * Copyright (C) 2000-2001 VideoLAN
+ * Copyright (C) 2000-2001 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"
 
 /*****************************************************************************
  * Constructor.
  *****************************************************************************/
-SubsFileDialog::SubsFileDialog( intf_thread_t *_p_intf, HINSTANCE _hInst )
+SubsFileDialog::SubsFileDialog( 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;
 }
 
 /***********************************************************************
 
-FUNCTION: 
+FUNCTION:
   WndProc
 
-PURPOSE: 
+PURPOSE:
   Processes messages sent to the main window.
-  
 ***********************************************************************/
-LRESULT SubsFileDialog::WndProc( HWND hwnd, UINT msg, WPARAM wp, LPARAM lp,
-                                 PBOOL pbProcessed  )
+LRESULT SubsFileDialog::WndProc( HWND hwnd, UINT msg, WPARAM wp, LPARAM lp )
 {
     SHINITDLGINFO shidi;
     SHMENUBARINFO mbi;
@@ -77,10 +72,6 @@ LRESULT SubsFileDialog::WndProc( HWND hwnd, UINT msg, WPARAM wp, LPARAM lp,
 
     TCHAR psz_text[256];
 
-    LRESULT lResult = CBaseWindow::WndProc( hwnd, msg, wp, lp, pbProcessed );
-    BOOL bWasProcessed = *pbProcessed;
-    *pbProcessed = TRUE;
-
     switch( msg )
     {
     case WM_INITDIALOG:
@@ -93,10 +84,8 @@ LRESULT SubsFileDialog::WndProc( HWND hwnd, UINT msg, WPARAM wp, LPARAM lp,
         memset (&mbi, 0, sizeof (SHMENUBARINFO));
         mbi.cbSize     = sizeof (SHMENUBARINFO);
         mbi.hwndParent = hwnd;
-        mbi.nToolBarId = IDR_DUMMYMENU;
+        mbi.dwFlags    = SHCMBF_EMPTYBAR;
         mbi.hInstRes   = hInst;
-        mbi.nBmpId     = 0;
-        mbi.cBmpImages = 0;
 
         if (!SHCreateMenuBar(&mbi))
         {
@@ -224,7 +213,15 @@ LRESULT SubsFileDialog::WndProc( HWND hwnd, UINT msg, WPARAM wp, LPARAM lp,
             UDS_SETBUDDYINT | UDS_NOTHOUSANDS,
             0, 0, 0, 0, hwnd, 0, hInst, fps_edit, 16000, 0, (int)f_fps );
 
-        return lResult;
+        break;
+
+    case WM_CLOSE:
+        EndDialog( hwnd, LOWORD( wp ) );
+        break;
+
+    case WM_SETFOCUS:
+        SHFullScreen( hwnd, SHFS_SHOWSIPBUTTON );
+        break;
 
     case WM_COMMAND:
         if ( LOWORD(wp) == IDOK )
@@ -255,7 +252,7 @@ LRESULT SubsFileDialog::WndProc( HWND hwnd, UINT msg, WPARAM wp, LPARAM lp,
             subsfile_mrl.push_back( szFps );
 
             EndDialog( hwnd, LOWORD( wp ) );
-            return TRUE;
+            break;
         }
         if( HIWORD(wp) == BN_CLICKED )
         {
@@ -263,23 +260,15 @@ LRESULT SubsFileDialog::WndProc( HWND hwnd, UINT msg, WPARAM wp, LPARAM lp,
             {
                 SHFullScreen( GetForegroundWindow(), SHFS_HIDESIPBUTTON );
                 OnFileBrowse();
-                return TRUE;
-            } 
+            }
         }
-
-        *pbProcessed = bWasProcessed;
-        lResult = FALSE;
-        return lResult;
+        break;
 
     default:
-        // the message was not processed
-        // indicate if the base class handled it
-        *pbProcessed = bWasProcessed;
-        lResult = FALSE;
-        return lResult;
+        break;
     }
 
-    return lResult;
+    return FALSE;
 }
 
 /*****************************************************************************
@@ -289,38 +278,30 @@ LRESULT SubsFileDialog::WndProc( HWND hwnd, UINT msg, WPARAM wp, LPARAM lp,
 /*****************************************************************************
  * Events methods.
  *****************************************************************************/
-void SubsFileDialog::OnFileBrowse()
+static void OnOpenCB( intf_dialog_args_t *p_arg )
 {
-    OPENFILENAME ofn;
-    TCHAR DateiName[80+1] = _T("\0");
-    static TCHAR szFilter[] = _T("All (*.*)\0*.*\0");
-
-    memset(&ofn, 0, sizeof(OPENFILENAME));
-    ofn.lStructSize = sizeof (OPENFILENAME);
-    ofn.hwndOwner = NULL;
-    ofn.hInstance = hInst;
-    ofn.lpstrFilter = szFilter;
-    ofn.lpstrCustomFilter = NULL;
-    ofn.nMaxCustFilter = 0;
-    ofn.nFilterIndex = 1;
-    ofn.lpstrFile = (LPTSTR) DateiName;
-    ofn.nMaxFile = 80;
-    ofn.lpstrFileTitle = NULL;
-    ofn.nMaxFileTitle = 40;
-    ofn.lpstrInitialDir = NULL;
-    ofn.lpstrTitle = _T("Open File");
-    ofn.Flags = 0;
-    ofn.nFileOffset = 0;
-    ofn.nFileExtension = 0;
-    ofn.lpstrDefExt = NULL;
-    ofn.lCustData = 0L;
-    ofn.lpfnHook = NULL;
-    ofn.lpTemplateName = NULL;
-    if( GetOpenFileName((LPOPENFILENAME) &ofn) )
+    SubsFileDialog *p_this = (SubsFileDialog *)p_arg->p_arg;
+
+    if( p_arg->i_results && p_arg->psz_results[0] )
     {
-        SetWindowText( file_combo, ofn.lpstrFile );
-        ComboBox_AddString( file_combo, ofn.lpstrFile );
-        if( ComboBox_GetCount( file_combo ) > 10 )
-            ComboBox_DeleteString( file_combo, 0 );
+        SetWindowText( p_this->file_combo, _FROMMB(p_arg->psz_results[0]) );
+        ComboBox_AddString( p_this->file_combo,
+                            _FROMMB(p_arg->psz_results[0]) );
+        if( ComboBox_GetCount( p_this->file_combo ) > 10 )
+            ComboBox_DeleteString( p_this->file_combo, 0 );
     }
 }
+
+void SubsFileDialog::OnFileBrowse()
+{
+    intf_dialog_args_t *p_arg =
+        (intf_dialog_args_t *)malloc( sizeof(intf_dialog_args_t) );
+    memset( p_arg, 0, sizeof(intf_dialog_args_t) );
+
+    p_arg->psz_title = strdup( "Open file" );
+    p_arg->psz_extensions = strdup( "All|*.*" );
+    p_arg->p_arg = this;
+    p_arg->pf_callback = OnOpenCB;
+
+    p_intf->p_sys->pf_show_dialog( p_intf, INTF_DIALOG_FILE_GENERIC, 0, p_arg);
+}