]> git.sesse.net Git - vlc/blobdiff - modules/gui/wince/timer.cpp
Removes trailing spaces. Removes tabs.
[vlc] / modules / gui / wince / timer.cpp
index 7a85340f80d015f5750bfb2de80e3787a7365d41..53d6c5cad83018d84fbd7ff382c29478d394360c 100644 (file)
@@ -1,7 +1,7 @@
 /*****************************************************************************
  * timer.cpp : WinCE gui plugin for VLC
  *****************************************************************************
- * Copyright (C) 2000-2003 VideoLAN
+ * Copyright (C) 2000-2003 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 <string>
-#include <stdio.h>
-using namespace std; 
-
 #include <vlc/vlc.h>
-#include <vlc/aout.h>
-#include <vlc/intf.h>
-
-#include <commctrl.h>
+#include <vlc_aout.h>
+#include <vlc_interface.h>
 
 #include "wince.h"
 
+#include <commctrl.h>
+
 /* Callback prototype */
 static int PopupMenuCB( vlc_object_t *p_this, const char *psz_variable,
-                        vlc_value_t old_val, vlc_value_t new_val, void *param );
+                        vlc_value_t old_val, vlc_value_t new_val, void * );
 
 /*****************************************************************************
  * Constructor.
  *****************************************************************************/
-Timer::Timer( intf_thread_t *_p_intf, HWND hwnd, Interface *_p_main_interface)//, Interface *_p_main_interface )
+Timer::Timer( intf_thread_t *_p_intf, HWND hwnd, Interface *_p_main_interface)
 {
     p_intf = _p_intf;
     p_main_interface = _p_main_interface;
@@ -93,10 +85,8 @@ Timer::~Timer()
  *****************************************************************************/
 void Timer::Notify( void )
 {
-    int size;
     vlc_value_t val;
     char *shortname;
-    LPWSTR wUnicode;
 
     vlc_mutex_lock( &p_intf->change_lock );
 
@@ -110,34 +100,21 @@ void Timer::Notify( void )
         /* Show slider */
         if( p_intf->p_sys->p_input )
         {
-            ShowWindow( p_main_interface->hwndSlider, SW_SHOW);
-            ShowWindow( p_main_interface->hwndLabel, SW_SHOW);
-            ShowWindow( p_main_interface->hwndVol, SW_SHOW);
+            ShowWindow( p_main_interface->hwndSlider, SW_SHOW );
+            ShowWindow( p_main_interface->hwndLabel, SW_SHOW );
+            ShowWindow( p_main_interface->hwndVol, SW_SHOW );
 
             // only for local file, check if works well with net url
             shortname = strrchr( p_intf->p_sys->p_input->input.p_item->psz_name, '\\' );
             if (! shortname)
                 shortname = p_intf->p_sys->p_input->input.p_item->psz_name;
-            else
-                shortname++;
-                        
-            size = MultiByteToWideChar (CP_ACP, 0, shortname, -1, NULL, 0);
-            wUnicode = new WCHAR[size+1];
-            MultiByteToWideChar (CP_ACP, 0, shortname, -1, wUnicode + 1, size) ;
-            wUnicode[0] = L'\t';
-
-            SendMessage( p_main_interface->hwndSB, SB_SETTEXT, 
-                         (WPARAM) 0, (LPARAM)(LPCTSTR) wUnicode);
-            free( wUnicode );
+            else shortname++;
+            SendMessage( p_main_interface->hwndSB, SB_SETTEXT,
+                         (WPARAM) 0, (LPARAM)_FROMMB(shortname) );
 
             p_main_interface->TogglePlayButton( PLAYING_S );
             i_old_playing_status = PLAYING_S;
-
-            /* Take care of the volume */
-            audio_volume_t i_volume;
-            aout_VolumeGet( p_intf, &i_volume );                        
-            SendMessage( p_main_interface->hwndVol, TBM_SETPOS, 1,
-                         200 - (i_volume * 200 * 2 / AOUT_VOLUME_MAX ) );
         }
     }
     else if( p_intf->p_sys->p_input->b_dead )
@@ -150,7 +127,7 @@ void Timer::Notify( void )
         p_main_interface->TogglePlayButton( PAUSE_S );
         i_old_playing_status = PAUSE_S;
 
-        SendMessage( p_main_interface->hwndSB, SB_SETTEXT, 
+        SendMessage( p_main_interface->hwndSB, SB_SETTEXT,
                      (WPARAM) 0, (LPARAM)(LPCTSTR) TEXT(""));
 
         vlc_object_release( p_intf->p_sys->p_input );
@@ -184,24 +161,22 @@ void Timer::Notify( void )
                         p_intf->p_sys->i_slider_pos =
                             (int)(SLIDER_MAX_POS * pos.f_float);
 
-                        SendMessage( p_main_interface->hwndSlider,TBM_SETPOS, 
+                        SendMessage( p_main_interface->hwndSlider, TBM_SETPOS,
                                      1, p_intf->p_sys->i_slider_pos );
 
                         var_Get( p_intf->p_sys->p_input, "time", &time );
                         i_seconds = time.i_time / 1000000;
-
                         secstotimestr ( psz_time, i_seconds );
 
-                        size = MultiByteToWideChar (CP_ACP, 0, psz_time, -1, NULL, 0);
-                        wUnicode = new WCHAR[size];
-                        MultiByteToWideChar (CP_ACP, 0, psz_time, -1, wUnicode, size) ;
-                        SendMessage( p_main_interface->hwndLabel, WM_SETTEXT, 
-                                     (WPARAM) 1, (LPARAM)(LPCTSTR) wUnicode );
-                        free( wUnicode );
+                        SendMessage( p_main_interface->hwndLabel, WM_SETTEXT,
+                                     (WPARAM)1, (LPARAM)_FROMMB(psz_time) );
                     }
                 }
             }
 
+            /* Take care of the volume, etc... */
+            p_main_interface->Update();
+
             /* Manage Playing status */
             var_Get( p_input, "state", &val );
             if( i_old_playing_status != val.i_int )
@@ -221,28 +196,25 @@ void Timer::Notify( void )
             var_Get( p_input, "rate", &val );
             if( i_old_rate != val.i_int )
             {
-                wUnicode = new WCHAR[10];
-                swprintf( wUnicode + 2, TEXT("x%.2f"), 1000.0 / val.i_int );
-                wUnicode[0] = L'\t';
-                wUnicode[1] = L'\t';
-
-                SendMessage( p_main_interface->hwndSB, SB_SETTEXT, 
-                             (WPARAM) 1, (LPARAM)(LPCTSTR) wUnicode);
+                TCHAR psz_text[15];
+                _stprintf( psz_text + 2, _T("x%.2f"), 1000.0 / val.i_int );
+                psz_text[0] = psz_text[1] = _T('\t');
 
-                free(wUnicode); 
+                SendMessage( p_main_interface->hwndSB, SB_SETTEXT,
+                             (WPARAM) 1, (LPARAM)(LPCTSTR) psz_text );
 
                 i_old_rate = val.i_int;
             }
         }
     }
-    else if( p_intf->p_sys->b_playing && !p_intf->b_die )
+    else if( p_intf->p_sys->b_playing && !intf_ShouldDie( p_intf ) )
     {
         p_intf->p_sys->b_playing = 0;
         p_main_interface->TogglePlayButton( PAUSE_S );
         i_old_playing_status = PAUSE_S;
     }
 
-    if( p_intf->b_die )
+    if( intf_ShouldDie( p_intf ) )
     {
         vlc_mutex_unlock( &p_intf->change_lock );