]> git.sesse.net Git - vlc/blobdiff - modules/gui/wxwidgets/interface.cpp
Put licensing terms instead of description in about boxes
[vlc] / modules / gui / wxwidgets / interface.cpp
index a9c9c1584179d14cbe96e6e8f77a314b3bc5eb27..66786c0782720a520d8e6fb979fd2d94c95a5b12 100644 (file)
 /*****************************************************************************
  * Preamble
  *****************************************************************************/
-#include <vlc/vlc.h>
-#include <vlc/aout.h>
-#include <vlc/vout.h>
-#include <vlc/input.h>
-#include <vlc/intf.h>
+#include "interface.hpp"
+#include "extrapanel.hpp"
+#include "timer.hpp"
+#include "video.hpp"
+#include <vlc_keys.h>
+
+#include "charset.h"
 
-#include "wxwidgets.h"
+#include <vlc/aout.h>
+#include "charset.h"
 
 /* include the toolbar graphics */
 #include "bitmaps/play.xpm"
@@ -157,6 +160,7 @@ enum
      * (where it is special and put into the "Apple" menu) */
     About_Event = wxID_ABOUT,
     UpdateVLC_Event,
+    VLM_Event,
 
     Iconize_Event
 };
@@ -166,6 +170,7 @@ BEGIN_EVENT_TABLE(Interface, wxFrame)
     EVT_MENU(Exit_Event, Interface::OnExit)
     EVT_MENU(About_Event, Interface::OnAbout)
     EVT_MENU(UpdateVLC_Event, Interface::OnShowDialog)
+    EVT_MENU(VLM_Event, Interface::OnShowDialog)
 
     EVT_MENU(Playlist_Event, Interface::OnShowDialog)
     EVT_MENU(Logs_Event, Interface::OnShowDialog)
@@ -329,6 +334,43 @@ Interface::Interface( intf_thread_t *_p_intf, long style ):
 
     if( ws->GetSettings( WindowSettings::ID_MAIN, b_shown, p, s ) )
         Move( p );
+
+    /* Set minimum window size to prevent user from glitching it */
+    wxSize  s2;
+    s = GetSize();
+
+    /* save smallest possible default minimum size */
+    default_size = GetSize();
+
+    /* save slider size for height only for MinSizing */
+    slider_size = slider_sizer->GetSize();
+
+    /* and save extended gui size for MinSize scheme */
+    s2 = extra_frame->GetSize();
+    s2.SetWidth( s2.GetWidth() +
+                2 * wxSystemSettings::GetMetric( wxSYS_FRAMESIZE_X ) );
+    extended_size = s2;
+
+    /* Set initial minimum window size */
+    if( config_GetInt( p_intf, "wx-embed" ) )
+    {
+        s2 = video_window->GetSize();
+        s.SetHeight( s.GetHeight() - s2.GetHeight() );
+    }
+    if( config_GetInt( p_intf, "wx-extended" ) )
+    {
+        s.SetWidth( extended_size.GetWidth() );
+        s.SetHeight( s.GetHeight() + extended_size.GetHeight() );
+    }
+#if (wxCHECK_VERSION(2,5,4))
+    SetMinSize( s );
+#else
+    frame_sizer->SetMinSize( s );
+#endif
+
+    /* Show extended GUI if requested */
+    if( ( b_extra = config_GetInt( p_intf, "wx-extended" ) ) )
+        frame_sizer->Show( extra_frame );
 }
 
 Interface::~Interface()
@@ -341,6 +383,8 @@ Interface::~Interface()
                          GetPosition(), GetSize() );
     }
 
+    PopEventHandler(true);
+
     if( video_window ) delete video_window;
 
 #ifdef wxHAS_TASK_BAR_ICON
@@ -427,6 +471,8 @@ void Interface::CreateOurMenuBar()
     view_menu->Append( Logs_Event, wxU(_("&Messages...\tCtrl-M")) );
     view_menu->Append( FileInfo_Event,
                        wxU(_("Stream and Media &info...\tCtrl-I")) );
+    view_menu->Append( VLM_Event,
+                       wxU(_("VLM Control...\tCtrl-I")) );
 
     /* Create the "Auto-generated" menus */
     p_settings_menu = SettingsMenu( p_intf, this );
@@ -470,6 +516,26 @@ void Interface::CreateOurMenuBar()
 #endif
 #endif
     }
+
+/* Patch by zcot for menu wrapping */
+#if defined(WIN32)
+    /* Find out size of msw menu bar */
+    i_size = 0;
+    SIZE sizing;
+    HDC hdc = GetDC( NULL );
+    for( unsigned int i = 0; i < menubar->GetMenuCount(); i++ )
+    {
+        GetTextExtentPoint32( hdc, menubar->GetLabelTop(i).c_str(),
+                                menubar->GetLabelTop(i).Length(), &sizing );
+
+        // [ SM_CXDLGFRAME + pixels + textextent + pixels + SM_CXDLGFRAME ]
+        i_size += sizing.cx + 2 + GetSystemMetrics( SM_CXDLGFRAME ) * 2;
+    }
+    ReleaseDC( NULL, hdc );
+    i_size += GetSystemMetrics( SM_CXSIZEFRAME ) * 2 + 4;
+#endif
+/* End patch by zcot */
+
     frame_sizer->SetMinSize( i_size, -1 );
 
     /* Intercept all menu events in our custom event handler */
@@ -533,11 +599,13 @@ void Interface::CreateOurToolBar()
                       wxU(_(HELP_PLO)) );
     }
 
+#if !( (wxMAJOR_VERSION <= 2) && (wxMINOR_VERSION <= 6) && (wxRELEASE_NUMBER < 2) )
     wxControl *p_dummy_ctrl =
         new wxControl( toolbar, -1, wxDefaultPosition,
                        wxSize(35, 16 ), wxBORDER_NONE );
 
     toolbar->AddControl( p_dummy_ctrl );
+#endif
 
     volctrl = new VLCVolCtrl( p_intf, toolbar );
     toolbar->AddControl( volctrl );
@@ -705,11 +773,27 @@ void Interface::ShowSlider( bool show, bool layout )
 
         //prevent continuous layout
         if( slider_frame->IsShown() ) return;
+        
+        wxSize ms = GetMinSize();
+        ms.SetHeight( ms.GetHeight() + slider_size.GetHeight() );
+#if ( wxCHECK_VERSION( 2,5,4 ) )
+        SetMinSize( ms );
+#else
+        frame_sizer->SetMinSize( ms );
+#endif
     }
     else
     {
         //prevent continuous layout
         if( !slider_frame->IsShown() ) return;
+        
+        wxSize ms = GetMinSize();
+        ms.SetHeight( ms.GetHeight() - slider_size.GetHeight() );
+#if ( wxCHECK_VERSION( 2,5,4 ) )
+        SetMinSize( ms );
+#else
+        frame_sizer->SetMinSize( ms );
+#endif
     }
 
     if( layout && p_intf->p_sys->b_video_autosize )
@@ -868,9 +952,9 @@ void Interface::OnAbout( wxCommandEvent& WXUNUSED(event) )
        wxU(_("Compiler: "))+ wxU(VLC_Compiler())+wxT( ".\n") +
        wxU(_("Based on SVN revision: "))+wxU(VLC_Changeset())+wxT(".\n\n") +
 #ifdef __WXMSW__
-        wxU( vlc_wraptext(INTF_ABOUT_MSG,WRAPCOUNT,VLC_TRUE) ) + wxT("\n\n") +
+        wxU( vlc_wraptext(LICENSE_MSG,WRAPCOUNT,VLC_TRUE) ) + wxT("\n\n") +
 #else
-        wxU( INTF_ABOUT_MSG ) + wxT("\n\n") +
+        wxU( LICENSE_MSG ) + wxT("\n\n") +
 #endif
         wxU(_("The VideoLAN team <videolan@videolan.org>\n"
               "http://www.videolan.org/\n\n")) );
@@ -892,6 +976,7 @@ void Interface::OnShowDialog( wxCommandEvent& event )
             break;
         case OpenAdv_Event:
             i_id = INTF_DIALOG_FILE;
+            break;
         case OpenFile_Event:
             i_id = INTF_DIALOG_FILE;
             break;
@@ -931,6 +1016,9 @@ void Interface::OnShowDialog( wxCommandEvent& event )
         case UpdateVLC_Event:
             i_id = INTF_DIALOG_UPDATEVLC;
             break;
+        case VLM_Event:
+            i_id = INTF_DIALOG_VLM;
+            break;
         default:
             i_id = INTF_DIALOG_FILE;
             break;
@@ -948,102 +1036,31 @@ void Interface::OnExtended(wxCommandEvent& event)
     {
         extra_frame->Hide();
         frame_sizer->Hide( extra_frame );
+        wxSize ms = GetMinSize();
+        ms.SetHeight( ms.GetHeight() - extended_size.GetHeight() );
+        ms.SetWidth( default_size.GetWidth() );
+#if ( wxCHECK_VERSION( 2,5,4 ) )
+        SetMinSize( ms );
+#else
+        frame_sizer->SetMinSize( ms );
+#endif
     }
     else
     {
         extra_frame->Show();
         frame_sizer->Show( extra_frame );
-    }
-    frame_sizer->Layout();
-    frame_sizer->Fit(this);
-}
-
-#if 0
-        if( b_undock == VLC_TRUE )
-        {
-                fprintf(stderr,"Deleting window\n");
-            if( extra_window )
-            {
-                delete extra_window;
-                extra_window = NULL;
-            }
-        }
-        else
-        {
-            extra_frame->Hide();
-            frame_sizer->Hide( extra_frame );
-            frame_sizer->Layout();
-            frame_sizer->Fit(this);
-        }
-    }
-    else
-    {
-        if( b_undock == VLC_TRUE )
-        {
-                fprintf(stderr,"Creating window\n");
-            extra_frame->Hide();
-            frame_sizer->Hide( extra_frame );
-#if (wxCHECK_VERSION(2,5,0))
-            frame_sizer->Detach( extra_frame );
+        wxSize ms = GetMinSize();
+        ms.SetHeight( ms.GetHeight() + extended_size.GetHeight() );
+        ms.SetWidth( extended_size.GetWidth() );
+#if ( wxCHECK_VERSION( 2,5,4 ) )
+        SetMinSize( ms );
 #else
-            frame_sizer->Remove( extra_frame );
+        frame_sizer->SetMinSize( ms );
 #endif
-            frame_sizer->Layout();
-            frame_sizer->Fit(this);
-            extra_window = new ExtraWindow( p_intf, this, extra_frame );
-        }
-        else
-        {
-                fprintf(stderr,"Deleting window\n");
-            if( extra_window )
-            {
-                delete extra_window;
-            }
-            extra_frame->Show();
-            frame_sizer->Show( extra_frame );
-            frame_sizer->Layout();
-            frame_sizer->Fit(this);
-        }
-    }
-}
-
-void Interface::OnUndock(wxCommandEvent& event)
-{
-    b_undock = (b_undock == VLC_TRUE ? VLC_FALSE : VLC_TRUE );
-
-    if( b_extra == VLC_TRUE )
-    {
-        if( b_undock == VLC_FALSE )
-        {
-                fprintf(stderr,"Deleting window\n");
-            if( extra_window )
-            {
-                delete extra_window;
-                extra_window = NULL;
-            }
-            extra_frame->Show();
-            frame_sizer->Show( extra_frame );
-            frame_sizer->Layout();
-            frame_sizer->Fit(this);
-        }
-        else
-        {
-                fprintf(stderr,"Creating window\n");
-            extra_frame->Hide();
-            frame_sizer->Hide( extra_frame );
-#if (wxCHECK_VERSION(2,5,0))
-            frame_sizer->Detach( extra_frame );
-#else
-            frame_sizer->Remove( extra_frame );
-#endif
-            frame_sizer->Layout();
-            frame_sizer->Fit(this);
-            extra_window = new ExtraWindow( p_intf, this, extra_frame );
-        }
     }
+    frame_sizer->Layout();
+    frame_sizer->Fit(this);
 }
-#endif
-
 
 void Interface::OnPlayStream( wxCommandEvent& WXUNUSED(event) )
 {
@@ -1183,22 +1200,6 @@ void Interface::PrevStream()
         return;
     }
 
-    /* FIXME --fenrir */
-#if 0
-    if( p_playlist->p_input != NULL )
-    {
-        vlc_mutex_lock( &p_playlist->p_input->stream.stream_lock );
-        if( p_playlist->p_input->stream.p_selected_area->i_id > 1 )
-        {
-            vlc_value_t val; val.b_bool = VLC_TRUE;
-            vlc_mutex_unlock( &p_playlist->p_input->stream.stream_lock );
-            var_Set( p_playlist->p_input, "prev-title", val );
-        } else
-            vlc_mutex_unlock( &p_playlist->p_input->stream.stream_lock );
-    }
-    vlc_mutex_unlock( &p_playlist->object_lock );
-#endif
-
     playlist_Prev( p_playlist );
     vlc_object_release( p_playlist );
 }
@@ -1217,26 +1218,6 @@ void Interface::NextStream()
     {
         return;
     }
-
-    /* FIXME --fenrir */
-#if 0
-    var_Change( p_input, "title", VLC_VAR_CHOICESCOUNT, &val, NULL );
-    vlc_mutex_lock( &p_playlist->object_lock );
-    if( p_playlist->p_input != NULL )
-    {
-        vlc_mutex_lock( &p_playlist->p_input->stream.stream_lock );
-        if( p_playlist->p_input->stream.i_area_nb > 1 &&
-            p_playlist->p_input->stream.p_selected_area->i_id <
-              p_playlist->p_input->stream.i_area_nb - 1 )
-        {
-            vlc_value_t val; val.b_bool = VLC_TRUE;
-            vlc_mutex_unlock( &p_playlist->p_input->stream.stream_lock );
-            var_Set( p_playlist->p_input, "next-title", val );
-        } else
-            vlc_mutex_unlock( &p_playlist->p_input->stream.stream_lock );
-    }
-    vlc_mutex_unlock( &p_playlist->object_lock );
-#endif
     playlist_Next( p_playlist );
     vlc_object_release( p_playlist );
 }
@@ -1371,11 +1352,12 @@ bool DragAndDrop::OnDropFiles( wxCoord, wxCoord,
 
     for( size_t i = 0; i < filenames.GetCount(); i++ )
     {
-        char *psz_utf8 = FromLocale( filenames[i].mb_str() );
+        char *psz_utf8 = wxFromLocale( filenames[i] );
+
         playlist_Add( p_playlist, psz_utf8, psz_utf8,
                       PLAYLIST_APPEND | ((i | b_enqueue) ? 0 : PLAYLIST_GO),
                       PLAYLIST_END );
-        LocaleFree( psz_utf8 );
+        wxLocaleFree( psz_utf8 );
     }
 
     vlc_object_release( p_playlist );