]> git.sesse.net Git - vlc/blobdiff - modules/gui/wince/messages.cpp
Removes trailing spaces. Removes tabs.
[vlc] / modules / gui / wince / messages.cpp
index 3e4e863d7f0b41ee493b4648a7caa74918c785af..82a35eda50d22b0d51441c3b3509b483f57e0b2b 100644 (file)
@@ -1,7 +1,7 @@
 /*****************************************************************************
  * messages.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 <vlc/vlc.h>
-#include <vlc/intf.h>
-#include <string.h>
+#include <vlc_interface.h>
 
-#include <string>
-#include <stdio.h>
-using namespace std; 
+#include "wince.h"
 
 #include <winuser.h>
 #include <windows.h>
 #include <windowsx.h>
 #include <commctrl.h>
-#include <aygshell.h>
-
 #include <commdlg.h>
 
-#include "wince.h"
-
 #ifndef NMAXFILE
 #define NMAXFILE 512 // at least 256
 #endif
@@ -55,26 +48,27 @@ using namespace std;
  * Constructor.
  *****************************************************************************/
 
-Messages::Messages( intf_thread_t *_p_intf, HINSTANCE _hInst )
+Messages::Messages( 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;
     hListView = NULL;
-    b_verbose = VLC_FALSE;
+
+    hWnd = CreateWindow( _T("VLC WinCE"), _T("Messages"),
+                         WS_POPUP|WS_CAPTION|WS_SYSMENU|WS_SIZEBOX,
+                         0, 0, /*CW_USEDEFAULT*/300, /*CW_USEDEFAULT*/300,
+                         p_parent->GetHandle(), NULL, h_inst, (void *)this );
 }
 
 /***********************************************************************
-
-FUNCTION: 
+FUNCTION:
   WndProc
 
-PURPOSE: 
+PURPOSE:
   Processes messages sent to the main window.
-
 ***********************************************************************/
-LRESULT Messages::WndProc( HWND hwnd, UINT msg, WPARAM wp, LPARAM lp,
-                           PBOOL pbProcessed  )
+LRESULT Messages::WndProc( HWND hwnd, UINT msg, WPARAM wp, LPARAM lp )
 {
     SHINITDLGINFO shidi;
 
@@ -82,72 +76,78 @@ LRESULT Messages::WndProc( HWND hwnd, UINT msg, WPARAM wp, LPARAM lp,
     OPENFILENAME ofn;
     int i_dummy;
     HANDLE fichier;
-    int nList=0;
 
-
-    LRESULT lResult = CBaseWindow::WndProc( hwnd, msg, wp, lp, pbProcessed );
-    BOOL bWasProcessed = *pbProcessed;
-    *pbProcessed = TRUE;
-
-    switch (msg)
+    switch( msg )
     {
-    case WM_INITDIALOG: 
+    case WM_CREATE:
         shidi.dwMask = SHIDIM_FLAGS;
         shidi.dwFlags = SHIDIF_DONEBUTTON | SHIDIF_SIPDOWN |
             SHIDIF_FULLSCREENNOMENUBAR;//SHIDIF_SIZEDLGFULLSCREEN;
         shidi.hDlg = hwnd;
         SHInitDialog( &shidi );
 
-        RECT rect; 
-        GetClientRect( hwnd, &rect );
         hListView = CreateWindow( WC_LISTVIEW, NULL,
                                   WS_VISIBLE | WS_CHILD | LVS_REPORT |
                                   LVS_SHOWSELALWAYS | WS_VSCROLL | WS_HSCROLL |
-                                  WS_BORDER /*| LVS_NOCOLUMNHEADER */,
-                                  rect.left + 20, rect.top + 50, 
-                                  rect.right - rect.left - ( 2 * 20 ), 
-                                  rect.bottom - rect.top - 50 - 20, 
-                                  hwnd, NULL, hInst, NULL );            
+                                  WS_BORDER | LVS_NOCOLUMNHEADER, 0, 0, 0, 0,
+                                  hwnd, NULL, hInst, NULL );
         ListView_SetExtendedListViewStyle( hListView, LVS_EX_FULLROWSELECT );
 
         LVCOLUMN lv;
-        lv.mask = LVCF_WIDTH | LVCF_FMT | LVCF_TEXT;
+        lv.mask = LVCF_FMT;
         lv.fmt = LVCFMT_LEFT ;
-        GetClientRect( hwnd, &rect );
-        lv.cx = rect.right - rect.left;
-        lv.pszText = _T("Messages");
-        lv.cchTextMax = 9;
-        ListView_InsertColumn( hListView, 0, &lv);
+        ListView_InsertColumn( hListView, 0, &lv );
 
         SetTimer( hwnd, 1, 500 /*milliseconds*/, NULL );
+        break;
+
+    case WM_WINDOWPOSCHANGED:
+        {
+            RECT rect;
+            if( !GetClientRect( hwnd, &rect ) ) break;
+            SetWindowPos( hListView, 0, 0, 0,
+                          rect.right - rect.left, rect.bottom - rect.top, 0 );
+
+            LVCOLUMN lv;
+            lv.cx = rect.right - rect.left;
+            lv.mask = LVCF_WIDTH;
+            ListView_SetColumn( hListView, 0, &lv );
+        }
+        break;
 
-        SHFullScreen( GetForegroundWindow(), SHFS_HIDESIPBUTTON );
-        return lResult;
+    case WM_SETFOCUS:
+        SHSipPreference( hwnd, SIP_DOWN );
+        SHFullScreen( hwnd, SHFS_HIDESIPBUTTON );
+        break;
 
     case WM_TIMER:
         UpdateLog();
-        return lResult;
+        break;
+
+    case WM_CLOSE:
+        Show( FALSE );
+        return TRUE;
 
     case WM_COMMAND:
         switch( LOWORD(wp) )
         {
         case IDOK:
-            EndDialog( hwnd, LOWORD( wp ) );
-            return TRUE;
+            Show( FALSE );
+            break;
 
         case IDCLEAR:
             ListView_DeleteAllItems( hListView );
-            return TRUE;
+            break;
 
-        case IDSAVEAS:  
+        case IDSAVEAS:
             memset( &(ofn), 0, sizeof(ofn) );
             ofn.lStructSize = sizeof(ofn);
             ofn.hwndOwner = hwnd;
             ofn.lpstrFile = _T("");
-            ofn.nMaxFile = NMAXFILE;    
+            ofn.nMaxFile = NMAXFILE;
             ofn.lpstrFilter = _T("Text (*.txt)\0*.txt\0");
             ofn.lpstrTitle = _T("Save File As");
-            ofn.Flags = OFN_HIDEREADONLY; 
+            ofn.Flags = OFN_HIDEREADONLY;
             ofn.lpstrDefExt = _T("txt");
 
             if( GetSaveFileName( (LPOPENFILENAME)&ofn ) )
@@ -174,25 +174,17 @@ LRESULT Messages::WndProc( HWND hwnd, UINT msg, WPARAM wp, LPARAM lp,
                     CloseHandle(fichier);
                 }
             }
-
-            SHFullScreen( GetForegroundWindow(), SHFS_HIDESIPBUTTON );
-            return TRUE;
+            break;
 
         default:
-            *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 DefWindowProc( hwnd, msg, wp, lp );
 }
 
 void Messages::UpdateLog()
@@ -210,29 +202,31 @@ void Messages::UpdateLog()
         for( i_start = p_sub->i_start; i_start != i_stop;
              i_start = (i_start+1) % VLC_MSG_QSIZE )
         {
-            if( !b_verbose && VLC_MSG_ERR != p_sub->p_msg[i_start].i_type )
-                continue;
-
-            /* Append all messages to log window */
-            debug = p_sub->p_msg[i_start].psz_module;
-        
             switch( p_sub->p_msg[i_start].i_type )
             {
-            case VLC_MSG_INFO:
-                debug += ": ";
-                break;
             case VLC_MSG_ERR:
-                debug += " error: ";
+            case VLC_MSG_INFO:
+                if( p_intf->p_libvlc_global->i_verbose < 0 ) continue;
                 break;
             case VLC_MSG_WARN:
-                debug += " warning: ";
+                if( p_intf->p_libvlc_global->i_verbose < 1 ) continue;
                 break;
             case VLC_MSG_DBG:
-            default:
-                debug += " debug: ";
+                if( p_intf->p_libvlc_global->i_verbose < 2 ) continue;
                 break;
             }
 
+            /* Append all messages to log window */
+            debug = p_sub->p_msg[i_start].psz_module;
+            switch( p_sub->p_msg[i_start].i_type )
+            {
+            case VLC_MSG_INFO: debug += ": "; break;
+            case VLC_MSG_ERR: debug += " error: "; break;
+            case VLC_MSG_WARN: debug += " warning: "; break;
+            default: debug += " debug: "; break;
+            }
+
             /* Add message */
             debug += p_sub->p_msg[i_start].psz_msg;
 
@@ -244,7 +238,7 @@ void Messages::UpdateLog()
             lv.iItem = ListView_GetItemCount( hListView );
             ListView_InsertItem( hListView, &lv );
             ListView_SetItemText( hListView, lv.iItem, 0,
-                                  _FROMMB(debug.c_str()) );
+                                  (TCHAR *)_FROMMB(debug.c_str()) );
         }
 
         vlc_mutex_lock( p_sub->p_lock );