summaryrefslogtreecommitdiffstats
path: root/wx
diff options
context:
space:
mode:
authorhandbrake <[email protected]>2006-01-14 13:40:38 +0000
committerhandbrake <[email protected]>2006-01-14 13:40:38 +0000
commit56bb6ce496b475944bb9577c7586e84be1cb831e (patch)
tree7720c135a160a34f22ce8f1f911f350e18207eaa /wx
parentd35a2a23fe450c88925128b9db7c63a5f1ed395d (diff)
HandBrake 0.7.0
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@16 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'wx')
-rw-r--r--wx/hb32x32.xpm295
-rw-r--r--wx/hbWizard.cpp1259
-rw-r--r--wx/hbWizard.h43
-rw-r--r--wx/wxHB.cpp684
-rw-r--r--wx/wxHB.h170
5 files changed, 2451 insertions, 0 deletions
diff --git a/wx/hb32x32.xpm b/wx/hb32x32.xpm
new file mode 100644
index 000000000..baa88bca4
--- /dev/null
+++ b/wx/hb32x32.xpm
@@ -0,0 +1,295 @@
+/* XPM */
+static char *hb_xpm[] = {
+/* columns rows colors chars-per-pixel */
+"32 32 257 2",
+" c #00044C",
+". c #180F3C",
+"X c #150C6A",
+"o c #171465",
+"O c #4E0A0D",
+"+ c #470D15",
+"@ c #1D1D3E",
+"# c #670501",
+"$ c #5E080A",
+"% c #10320A",
+"& c #003D04",
+"* c #770105",
+"= c #0F3412",
+"- c #511412",
+"; c #431733",
+": c #29281F",
+"> c #880001",
+", c #33261E",
+"< c #442017",
+"1 c #930000",
+"2 c #372C16",
+"3 c #6C1501",
+"4 c #9B0200",
+"5 c #52250F",
+"6 c #631D13",
+"7 c #542225",
+"8 c #432C2A",
+"9 c #005603",
+"0 c #413416",
+"q c #75124B",
+"w c #81161A",
+"e c #A6070B",
+"r c #2D4034",
+"t c #3C3837",
+"y c #144F2E",
+"u c #443B1C",
+"i c #961219",
+"p c #8F161C",
+"a c #015C2A",
+"s c #473B23",
+"d c #393E41",
+"f c #901B11",
+"g c #56362E",
+"h c #195629",
+"j c #4A3A3C",
+"k c #4F3E1F",
+"l c #6D311F",
+"z c #514118",
+"x c #3E3B71",
+"c c #45452D",
+"v c #403E62",
+"b c #792F18",
+"n c #006B27",
+"m c #3C4652",
+"M c #5B4215",
+"N c #424648",
+"B c #52452C",
+"V c #634117",
+"C c #096B33",
+"Z c #545004",
+"A c #00732E",
+"S c #57482A",
+"D c #146D1C",
+"F c #524A2F",
+"G c #007D02",
+"H c #23623A",
+"J c #41552E",
+"K c #644916",
+"L c #5F4A22",
+"P c #5D4C28",
+"I c #B92312",
+"U c #644C1E",
+"Y c #007C2F",
+"T c #59512B",
+"R c #157139",
+"E c #5F4C37",
+"W c #2D654D",
+"Q c #58523E",
+"! c #2E6744",
+"~ c #724D16",
+"^ c #515350",
+"/ c #6E501C",
+"( c #675229",
+") c #684865",
+"_ c #0F832E",
+"` c #42634F",
+"' c #485B71",
+"] c #009500",
+"[ c #685A22",
+"{ c #755523",
+"} c #535B62",
+"| c #76561E",
+" . c #16823A",
+".. c #357337",
+"X. c #CE2F03",
+"o. c #725824",
+"O. c #3C6B54",
+"+. c #575C5E",
+"@. c #71592A",
+"#. c #15882C",
+"$. c #7F571A",
+"%. c #2B7B49",
+"&. c #68595B",
+"*. c #5E5E5C",
+"=. c #7C5B1B",
+"-. c #80514C",
+";. c #00A100",
+":. c #66623F",
+">. c #357853",
+",. c #7B620E",
+"<. c #0E942C",
+"1. c #6A5F4F",
+"2. c #636449",
+"3. c #7F5D25",
+"4. c #845159",
+"5. c #8F5337",
+"6. c #7C6026",
+"7. c #64635C",
+"8. c #984D48",
+"9. c #357E52",
+"0. c #7D612D",
+"q. c #4E7061",
+"w. c #89601C",
+"e. c #717103",
+"r. c #626667",
+"t. c #7C6334",
+"y. c #7C633A",
+"u. c #786442",
+"i. c #746354",
+"p. c #6C6469",
+"a. c #856525",
+"s. c #89661F",
+"d. c #636B72",
+"f. c #836933",
+"g. c #72732F",
+"h. c #86692F",
+"j. c #716B5E",
+"k. c #766863",
+"l. c #806754",
+"z. c #5F6F84",
+"x. c #877302",
+"c. c #527C63",
+"v. c #6A6E6E",
+"b. c #5C795F",
+"n. c #637085",
+"m. c #BC4675",
+"M. c #946A26",
+"N. c #597B6C",
+"B. c #79714B",
+"V. c #956B1F",
+"C. c #8B6E2C",
+"Z. c #916C2A",
+"A. c #D64A27",
+"S. c #925F75",
+"D. c #1BAB2D",
+"F. c #C14A74",
+"G. c #84743B",
+"H. c #717678",
+"J. c #907239",
+"K. c #8C6B6C",
+"L. c #867452",
+"P. c #757773",
+"I. c #6E7882",
+"U. c #87745A",
+"Y. c #8C7644",
+"T. c #89830E",
+"R. c #867A48",
+"E. c #808329",
+"W. c #7F7A5E",
+"Q. c #6C7B8D",
+"!. c #A17522",
+"~. c #9A7730",
+"^. c #9F762A",
+"/. c #817A75",
+"(. c #6A7F99",
+"). c #88891E",
+"_. c #E45A2B",
+"`. c #20BF2A",
+"'. c #798189",
+"]. c #BD6D43",
+"[. c #A07F35",
+"{. c #81827E",
+"}. c #AA7D2A",
+"|. c #8A8074",
+" X c #AE7E25",
+".X c #987D8D",
+"XX c #AE8430",
+"oX c #AB8838",
+"OX c #868B8D",
+"+X c #998677",
+"@X c #948A7E",
+"#X c #9D8D58",
+"$X c #7D90AE",
+"%X c #A79430",
+"&X c #AC8E4A",
+"*X c #B19517",
+"=X c #BC8C2F",
+"-X c #819A86",
+";X c #7F92B7",
+":X c #7995B8",
+">X c #F76D38",
+",X c #A08E78",
+"<X c #998F8C",
+"1X c #A09B42",
+"2X c #929491",
+"3X c #9C966D",
+"4X c #919499",
+"5X c #9E9476",
+"6X c #809F91",
+"7X c #D48829",
+"8X c #FE628E",
+"9X c #FA7832",
+"0X c #8A99B8",
+"qX c #859DBA",
+"wX c #999B98",
+"eX c #74B486",
+"rX c #91A29B",
+"tX c #A8A263",
+"yX c #999FA5",
+"uX c #CC9B31",
+"iX c #CCA504",
+"pX c #D8887F",
+"aX c #FA8728",
+"sX c #E18971",
+"dX c #C99E42",
+"fX c #C4A23B",
+"gX c #CD9F3C",
+"hX c #A7A9A6",
+"jX c #9EA9C3",
+"kX c #99ACC3",
+"lX c #FB9C1A",
+"zX c #DCA645",
+"xX c #CFA39A",
+"cX c #FAAA05",
+"vX c #BAB971",
+"bX c #F29C75",
+"nX c #DAAD5E",
+"mX c #A9B7CB",
+"MX c #B1B9C1",
+"NX c #FFB904",
+"BX c #FBA873",
+"VX c #E7BE37",
+"CX c #B3C4BD",
+"ZX c #B8C4D4",
+"AX c #D1BFB4",
+"SX c #F1B49D",
+"DX c #FBBF48",
+"FX c #FECC00",
+"GX c #C5CACD",
+"HX c #FCBE8D",
+"JX c #CDCFCB",
+"KX c #C8D2DD",
+"LX c #C0DACB",
+"PX c #FBD5C2",
+"IX c #F7F698",
+"UX c gray100",
+"YX c None",
+/* pixels */
+"YXYXYXS.F.S.YXYXYXYXYXYXYXYXYX{.YXYXYXYXYXYXYXYXYXYXYXYX4XYXYXYX",
+"YXYXYXm.8Xm.YXYXYXYXYXYXYXYXW.1XYXYXYXYXYXYXYXMXYXYXYX} YXYXYXYX",
+"YXYXYX.Xq ) YXYXYXYXYXYXYXH.g.3XYXYXYXYXYXYXYXYXd.YXYXr YXYXYXYX",
+"YXYXYX{.x v j.,X/.YXYX` G 9 & = b.YXYXYXYXYXYXYXq.6XrXO.YXO.yXYX",
+"YXYX/.+X/.AX+Xj.E YXYX'.G ;.;.G ] ..YXYXYXYXH >.6XC ! 9.C q.YXYX",
+"YXYX1.U.Q U.l.i.|.YXYXYX-X% n D b.YXYXYXYXYXYXR A R n n O.LXYXYX",
+"YXYX/.+Xl.5.b &.YXYXYXYXYXT.YXwX/.YXYXYXYXYXYX6X_ <.A Y #.h +.MX",
+"YXYXYXYX-.X.X.8 H.v.H.H.2.E.2.T *X%XYXYXYXYXN.O.C D._ `.A y N.CX",
+"YXYXYXYXYX8 . <XGXyXwXwXT.c vXQ 2.FX#XYXYX6X%.D.A <.D. .a ` YXYX",
+"YXYXYXYX+.k. +.<Xv.p.*.Z t N +.x.iX5XYXYXYXv.q.#.<.<.#._ a c.LX",
+"YXYXYXd.P.<Xo @ &.j 8 , e.j t s 5 7 YXYXr.u.uXgXQ J D _ .eXYXYX",
+"YXYXYX7 xXp ; X 1 e p ,.V w g IX- $ p.U.gX[.V.^.gXXX&XY.:.6XYXYX",
+"YXYXK.8.xX# - X p i w e.+ $ B IXtX6 < { ~.( ~.0.^.=XF }.h.&XYXYX",
+"YXYX4.sXpX1 > > * * * > > 1 > l tXIXB.P [.J.=.gXP [.XX0.J.J.{.YX",
+"YXYXk.bXpXI 1 4 4 1 1 e I e 1 > f B.R.f.M t.6.oX[.}.=XB XX=XN YX",
+"YXYXYX].PX>X>X1 A.I A.>X_._.e 3 x.0 o.t.Z.C.Y.$.zX( f.dXt.y.U.YX",
+"YXYXYX+XzXBXaXA.>X>X>X>XaX9XA.SX7Xk @.( J.V.f.XXf.J.dX| 6.o.o.YX",
+"YXYXYXYXW.nXDXlXaX9XlXlXcXcXHXnXK s Z.Z.0.3.Z.P X XP ^.[.Y.h.YX",
+"YXYXYXYXYXYX5XfXFXNXFXFXFXVXG.k L =X( @.s.a. XZ.^.XX=.o.V.~.s YX",
+"YXYXYXYXYXYXYXYX7.[ R.R.T d.P.=.$.f.( !.!.=.w.Z.( a.uXs.s.6.L.YX",
+"YXYXYXYXYXYXYXYXYXI.wXOXI.YX1.| s s.XX{ [email protected].=X3.=.K =.6.U.YX",
+"YXYXYXYXYXYXYXYXYXYXH.P.YXYXd.S { Z.oXB h. X!.( w.k | / Xs.YXYX",
+"YXYXYXYXYXYXYXYXYXYXv.H.YXYX*.o.$.k 0.=Xf.Z.XXs | U uX0.w.S YXYX",
+"YXYXYXYXYXYXYXYXYXYXH.H.YXYXP./ K =Xf.~ ~.T 0.f. X6.| U s.L.YXYX",
+"YXYXYXYXYXYXYXYXYXYXH.{.YXYXYXS / ~ @.| t.C.!.0.w.L 0.( G.YXYXYX",
+"YXYXYXYXZXmXkXkXmXYXv.4X+.YXYXL.K M.o.t.3.3.a.s h.C.}.XX'.YXYXYX",
+"YXYXkX:X;X;X;X;Xn.m hX4Xr.r.YX{.3.: [email protected] C.f.~ @.0.2 kXYXYXYX",
+"mXqX;XqX:X$Xz.+.H.4XGX<X{.4XwXd d ^.k @.L ~ L z S ~.: (.jXYXYXYX",
+"0X$X;X$X:X;X} H.<X{.H.p.v.H.4X<X' P | $.k U { o.K Q ;X0XZXYXYXYX",
+"mX;X$X;X;X;X$Xn.Q.'.I.I.I.n.Q.:X$X;X*.Q P 2 B } z.;XqXZXYXYXYXYX",
+"YXZX0X;X$X;X;X;X;X;X:X;X;X;X;X;X$X$X0XkXjXmXmXmXZXKXYXYXYXYXYXYX",
+"YXYXYXGXmXjXjX0X$XqX;X$XjXjXmXMXmXKXYXYXYXYXYXYXYXYXYXYXYXYXYXYX"
+};
diff --git a/wx/hbWizard.cpp b/wx/hbWizard.cpp
new file mode 100644
index 000000000..c9473067c
--- /dev/null
+++ b/wx/hbWizard.cpp
@@ -0,0 +1,1259 @@
+/*****************************************************************************
+ * wxHB:
+ *****************************************************************************
+ * Copyright (C)
+ * $Id: hbWizard.cpp,v 1.4 2005/03/17 19:22:47 titer Exp $
+ *
+ * Authors:
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * 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.
+ *****************************************************************************/
+
+#include "wxHB.h"
+#include "hbWizard.h"
+
+#include "hb32x32.xpm"
+
+/* All IDs
+ * CB: ComboBox
+ * BT: Button
+ * RD: Radio
+ * NB: NoteBook
+ */
+enum
+{
+ /* Source page */
+ ID_SOURCE_RD_DRIVE = wxID_HIGHEST,
+ ID_SOURCE_RD_DIR,
+ ID_SOURCE_BT_DIR,
+ ID_SOURCE_CB_DRIVE,
+ ID_SOURCE_CB_DIR,
+
+ ID_SOURCE_BT_ABOUT,
+ ID_SOURCE_BT_PREFERENCES,
+
+ /* Settings page */
+ ID_SETTINGS_CB_TITLE = wxID_HIGHEST,
+ ID_SETTINGS_CB_CHAPTER_START,
+ ID_SETTINGS_CB_CHAPTER_END,
+ ID_SETTINGS_CB_AUDIO_LANGUAGE,
+ ID_SETTINGS_CB_AUDIO_QUALITY,
+ ID_SETTINGS_CB_SUBTITLE_LANGUAGE,
+ ID_SETTINGS_CB_VIDEO_QUALITY,
+ ID_SETTINGS_CB_OUTPUT_FILE,
+ ID_SETTINGS_CB_OUTPUT_SIZE,
+ ID_SETTINGS_CB_OUTPUT_BITRATE,
+ ID_SETTINGS_SC_OUTPUT_FILE_COUNT,
+
+ ID_SETTINGS_RD_OUTPUT_SIZE,
+ ID_SETTINGS_RD_OUTPUT_BITRATE,
+
+ ID_SETTINGS_CB_VIDEO_CODEC,
+ ID_SETTINGS_CB_VIDEO_FPS,
+ ID_SETTINGS_CH_VIDEO_DEINTERLACE,
+ ID_SETTINGS_CH_VIDEO_CROP,
+ ID_SETTINGS_SC_VIDEO_CROP_LEFT,
+ ID_SETTINGS_SC_VIDEO_CROP_TOP,
+ ID_SETTINGS_SC_VIDEO_CROP_RIGHT,
+ ID_SETTINGS_SC_VIDEO_CROP_BOTTOM,
+ ID_SETTINGS_SC_VIDEO_WIDTH,
+ ID_SETTINGS_SC_VIDEO_HEIGHT,
+
+ ID_SETTINGS_CB_AUDIO_SAMPLERATE,
+
+ ID_SETTINGS_CB_CPU,
+ ID_SETTINGS_CB_PRIORITY,
+
+ ID_SETTINGS_BT_FILE,
+
+ ID_SETTINGS_NB,
+
+ /* */
+ //ID_ALL_FIXME,
+};
+
+class hbImage: public wxControl
+{
+public:
+ hbImage( wxWindow *parent ) :
+ wxControl( parent, -1, wxDefaultPosition, wxSize(128,128),
+ wxBORDER_NONE )
+ {
+ }
+
+ void OnPaint(wxPaintEvent &event)
+ {
+ wxPaintDC dc(this);
+ dc.SetBrush( wxBrush(*wxGREEN, wxSOLID) );
+ dc.DrawText( wxU("Solid green"), 10, 10 );
+ }
+
+private:
+ DECLARE_EVENT_TABLE()
+};
+
+BEGIN_EVENT_TABLE( hbImage, wxControl )
+ EVT_PAINT( hbImage::OnPaint )
+END_EVENT_TABLE()
+
+/*****************************************************************************
+ * hbWizard
+ *****************************************************************************/
+static void hbWizardPageHeaders( wxWizardPageSimple *page,
+ char *psz_title,
+ char *psz_description,
+ wxSizer *sizerC )
+{
+ wxBoxSizer *sizerH = new wxBoxSizer(wxHORIZONTAL);
+
+ wxStaticBitmap *bm = new wxStaticBitmap( page, wxID_ANY,
+ wxBitmap(hb_xpm) );
+ wxBoxSizer *sizerV = new wxBoxSizer(wxVERTICAL);
+
+
+ wxStaticText *title = new wxStaticText( page, -1, wxU(psz_title) );
+ wxFont font = title->GetFont();
+ font.SetPointSize(14);
+ title->SetFont( font );
+
+ sizerV->Add( title, 0, wxALIGN_CENTER|wxALL, 5 );
+
+ sizerV->Add( new wxStaticLine(page, -1), 0, wxEXPAND|wxALL, 5 );
+
+ wxStaticText *text = new wxStaticText( page, -1,
+ wxU( psz_description ) );
+ sizerV->Add( text, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5 );
+
+ //sizerV->Add( 0, 1, 1, wxALL );
+
+ sizerV->Add( sizerC, 1, wxEXPAND|wxALIGN_CENTER|wxALL, 5 );
+
+
+ /* Add bmp */
+ sizerH->Add( bm, 0, wxALL|wxALIGN_CENTER, 5 );
+ /* Add sizer */
+ sizerH->Add( sizerV, 1, wxEXPAND|wxALIGN_CENTER|wxALL, 5 );
+
+ /* */
+ page->SetSizerAndFit( sizerH );
+
+ /* Needed ? */
+ page->SetAutoLayout( TRUE );
+ page->Layout();
+}
+
+/*****************************************************************************
+ * hbWizardPageSource:
+ *****************************************************************************/
+class hbWizardPageSource: public wxWizardPageSimple
+{
+public:
+ hbWizardPageSource( wxWizard *p_wizard );
+ virtual ~hbWizardPageSource();
+
+
+ void OnRadio( wxCommandEvent &event );
+ void OnBrowseDir( wxCommandEvent &event );
+ void OnTextDirChange( wxCommandEvent &event );
+ void OnTextDriveChange( wxCommandEvent &event );
+ void OnPageChanging( wxWizardEvent &event );
+
+private:
+
+ wxDirDialog *dlgDir;
+ wxComboBox *comboDir;
+ wxComboBox *comboDrive;
+ wxButton *buttonDir;
+
+ DECLARE_EVENT_TABLE()
+};
+
+
+hbWizardPageSource::hbWizardPageSource( wxWizard *p_wizard ) :
+ wxWizardPageSimple(p_wizard)
+{
+ wxRadioButton *radio[2];
+ wxFlexGridSizer *sizerDrive;
+ wxFlexGridSizer *sizerDir;
+ wxBoxSizer *sizerH;
+ wxButton *button;
+
+ /* Create radio and subpanel */
+ radio[0] = new wxRadioButton( this, ID_SOURCE_RD_DRIVE,
+ wxU("DVD drive" ) );
+ radio[1] = new wxRadioButton( this, ID_SOURCE_RD_DIR,
+ wxU("DVD directory" ) );
+
+ /* - Create DRIVE row */
+ sizerDrive = new wxFlexGridSizer( 1, 1, 20 );
+ /* combo */
+ wxArrayString &sD = *g_hbApp->GetSystemDrive();
+ comboDrive = new wxComboBox( this, ID_SOURCE_CB_DRIVE, sD[0],
+ wxDefaultPosition, wxDefaultSize,
+ sD );
+ sizerDrive->Add( comboDrive, 0, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
+
+ /* - Create DIR row */
+ sizerDir = new wxFlexGridSizer( 2, 1, 20 );
+ /* combo */
+ comboDir = new wxComboBox( this, ID_SOURCE_CB_DIR, wxU("") );
+ sizerDir->Add( comboDir, 0, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
+ /* button */
+ buttonDir = new wxButton( this, ID_SOURCE_BT_DIR, wxU("Browse..."));
+ sizerDir->Add( buttonDir,
+ 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL );
+
+ /* - Hop in the main */
+ wxFlexGridSizer *sizerChoice = new wxFlexGridSizer( 2, 2, 20 );
+ sizerChoice->Add( radio[0],
+ 0, wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL|wxALL, 5 );
+ sizerChoice->Add( sizerDrive, 1, wxEXPAND|wxALIGN_LEFT|
+ wxALIGN_CENTER_VERTICAL|wxALL, 5 );
+ sizerChoice->Add( radio[1],
+ 0, wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL|wxALL, 5 );
+ sizerChoice->Add( sizerDir, 1, wxEXPAND|wxALIGN_LEFT|
+ wxALIGN_CENTER_VERTICAL|wxALL, 5 );
+
+ wxBoxSizer *sizer = new wxBoxSizer( wxVERTICAL );
+ sizer->Add( sizerChoice, 1,
+ wxEXPAND|wxALIGN_CENTER|wxALL, 5 );
+
+ sizer->Add( 0, 0 );
+
+ sizerH = new wxBoxSizer( wxHORIZONTAL );
+ sizerH->Add( 0, 0, 1 );
+ button = new wxButton( this, ID_SOURCE_BT_ABOUT, wxU("About") );
+ button->Enable(FALSE);
+ sizerH->Add( button, 0, wxALL|wxALIGN_RIGHT, 5 );
+ button = new wxButton( this, ID_SOURCE_BT_PREFERENCES, wxU("Preferences"));
+ button->Enable(FALSE);
+ sizerH->Add( button, 0, wxALL|wxALIGN_RIGHT, 5 );
+
+ sizer->Add( sizerH, 0, wxALIGN_BOTTOM|wxEXPAND, 5 );
+
+ /* */
+#if 0
+ hbImage *img = new hbImage( this );
+ sizer->Add( img );
+#endif
+
+
+ hbWizardPageHeaders( this, "Source",
+ "Select the DVD (drive or a directory)", sizer );
+
+ comboDir->Enable( FALSE );
+ buttonDir->Enable( FALSE );
+
+ //SetAutoLayout( TRUE );
+ //Layout();
+
+ /* */
+ dlgDir = NULL;
+}
+
+hbWizardPageSource::~hbWizardPageSource()
+{
+}
+
+void hbWizardPageSource::OnRadio( wxCommandEvent &event )
+{
+ if( event.GetId() == ID_SOURCE_RD_DRIVE )
+ {
+ comboDrive->Enable( TRUE );
+
+ comboDir->Enable( FALSE );
+ buttonDir->Enable( FALSE );
+ }
+ else
+ {
+ comboDir->Enable( TRUE );
+ buttonDir->Enable( TRUE );
+
+ comboDrive->Enable( FALSE );
+ }
+}
+
+void hbWizardPageSource::OnBrowseDir( wxCommandEvent &event )
+{
+ if( dlgDir == NULL )
+ dlgDir = new wxDirDialog( this, wxU( "Choose a directory"),
+ wxGetCwd() );
+
+ if( dlgDir->ShowModal() == wxID_OK )
+ {
+ const wxChar *p = dlgDir->GetPath();
+
+ comboDir->SetValue( p );
+ }
+}
+
+void hbWizardPageSource::OnTextDirChange( wxCommandEvent &event )
+{
+}
+void hbWizardPageSource::OnTextDriveChange( wxCommandEvent &event )
+{
+}
+
+void hbWizardPageSource::OnPageChanging( wxWizardEvent &event )
+{
+ wxRadioButton *rdDrive = (wxRadioButton*)FindWindow( ID_SOURCE_RD_DRIVE );
+ wxString sDevice;
+
+ if( rdDrive->GetValue() )
+ {
+ wxComboBox *cbDrive = (wxComboBox*)FindWindow( ID_SOURCE_CB_DRIVE );
+ /* Get the drive value */
+ sDevice = cbDrive->GetValue();
+ }
+ else
+ {
+ wxComboBox *cbDir = (wxComboBox*)FindWindow( ID_SOURCE_CB_DIR );
+ sDevice = cbDir->GetValue();
+
+ if( sDevice.IsEmpty() )
+ {
+ hbError( this, wxU("You have to give a directory name") );
+ event.Veto();
+ return;
+ }
+ }
+
+ if( g_hbApp->Scan( sDevice ) < 0 )
+ {
+ event.Veto();
+ }
+}
+
+
+
+BEGIN_EVENT_TABLE( hbWizardPageSource, wxWizardPageSimple )
+ EVT_RADIOBUTTON( ID_SOURCE_RD_DRIVE, hbWizardPageSource::OnRadio )
+ EVT_RADIOBUTTON( ID_SOURCE_RD_DIR, hbWizardPageSource::OnRadio )
+
+ EVT_BUTTON( ID_SOURCE_BT_DIR, hbWizardPageSource::OnBrowseDir )
+
+ EVT_TEXT( ID_SOURCE_CB_DIR, hbWizardPageSource::OnTextDirChange )
+ EVT_TEXT( ID_SOURCE_CB_DRIVE, hbWizardPageSource::OnTextDriveChange )
+
+ EVT_WIZARD_PAGE_CHANGING( -1, hbWizardPageSource::OnPageChanging )
+END_EVENT_TABLE()
+
+
+/*****************************************************************************
+ * hbWizardPageSettings:
+ *****************************************************************************/
+static wxPanel *PanelSettingsGeneral( wxWindow *p_parent )
+{
+ wxPanel *panel = new wxPanel( p_parent, -1,
+ wxDefaultPosition, wxSize(200, 200));
+ wxBoxSizer *sizerV = new wxBoxSizer( wxVERTICAL );
+ wxGridSizer *sizerG;
+ wxBoxSizer *sizerS;
+ wxStaticBox *ibox;
+ wxStaticBoxSizer *sbox;
+ wxFlexGridSizer *sizerF;
+ wxComboBox *combo;
+ wxButton *button;
+ wxRadioButton *radio;
+ wxSpinCtrl *spin;
+
+ wxArrayString aQ;
+
+ /* Selection (title/chapter) */
+ ibox = new wxStaticBox( panel, -1, wxU("Selection") );
+ sbox = new wxStaticBoxSizer( ibox, wxHORIZONTAL);
+
+ sbox->Add( new wxStaticText( panel, -1, wxU("Title") ),
+ 0, wxALL, 5 );
+ combo = new wxComboBox( panel, ID_SETTINGS_CB_TITLE, wxU(""),
+ wxDefaultPosition, wxDefaultSize, 0, NULL,
+ wxCB_READONLY );
+
+ sbox->Add( combo, 1, wxEXPAND|wxALL, 5 );
+ //sbox->Add( 0, 0, 1 );
+
+ sbox->Add( new wxStaticText( panel, -1, wxU( "Chapters" ) ),
+ 0, wxALL, 5 );
+
+ combo = new wxComboBox( panel, ID_SETTINGS_CB_CHAPTER_START, wxU(""),
+ wxDefaultPosition, wxDefaultSize, 0, NULL,
+ wxCB_READONLY );
+ sbox->Add( combo, 0, wxEXPAND|wxALL, 5 );
+
+ sbox->Add( new wxStaticText( panel, -1, wxU( "to" ) ),
+ 0, wxALL, 5 );
+ combo = new wxComboBox( panel, ID_SETTINGS_CB_CHAPTER_END, wxU(""),
+ wxDefaultPosition, wxDefaultSize, 0, NULL,
+ wxCB_READONLY );
+
+ sbox->Add( combo, 0, wxEXPAND|wxALL, 5 );
+
+ sizerV->Add( sbox, 1, wxEXPAND|wxALL, 5 );
+
+ /* Sizer for audio + video box */
+ sizerG = new wxGridSizer( 1, 2, 10, 10 );
+
+ /* Audio */
+ ibox = new wxStaticBox( panel, -1, wxU("Audio") );
+ sbox = new wxStaticBoxSizer( ibox, wxHORIZONTAL);
+
+ sizerF = new wxFlexGridSizer( 2, 2, 20 );
+ sizerF->Add( new wxStaticText( panel, -1, wxU( "Language" ) ),
+ 0, wxALL|wxALIGN_LEFT, 5 );
+ //sbox->Add( 0, 0, 1 );
+ combo = new wxComboBox( panel, ID_SETTINGS_CB_AUDIO_LANGUAGE, wxU(""),
+ wxDefaultPosition, wxDefaultSize, 0, NULL,
+ wxCB_READONLY );
+ sizerF->Add( combo, 1, wxEXPAND|wxALL|wxALIGN_RIGHT, 5 );
+
+ sizerF->Add( new wxStaticText( panel, -1, wxU( "Quality" ) ),
+ 0, wxALL|wxALIGN_LEFT, 5 );
+ //sbox->Add( 0, 0, 1 );
+
+ aQ.Clear();
+ aQ.Add( wxU("Low - 64 kb/s") );
+ aQ.Add( wxU("Normal - 128 kb/s") );
+ aQ.Add( wxU("High - 160 kb/s") );
+ aQ.Add( wxU("Extra - 192 kb/s") );
+
+ combo = new wxComboBox( panel, ID_SETTINGS_CB_AUDIO_QUALITY, aQ[2],
+ wxDefaultPosition, wxDefaultSize,
+ aQ, wxCB_READONLY );
+ sizerF->Add( combo, 1, wxEXPAND|wxALL|wxALIGN_RIGHT, 5 );
+
+ sbox->Add( sizerF, 1, wxEXPAND|wxALL, 0 );
+ //sizerV->Add( sbox, 0, wxALL, 5 );
+ sizerG->Add( sbox, 1, wxEXPAND|wxALL, 0 );
+
+ /* Video */
+ ibox = new wxStaticBox( panel, -1, wxU("Video") );
+ sbox = new wxStaticBoxSizer( ibox, wxHORIZONTAL);
+
+ sizerF = new wxFlexGridSizer( 2, 2, 20 );
+
+ sizerF->Add( new wxStaticText( panel, -1, wxU( "Quality" ) ),
+ 0, wxALL|wxALIGN_LEFT, 5 );
+
+ aQ.Clear();
+ aQ.Add( wxU("Low (fast)") );
+ aQ.Add( wxU("Normal") );
+ aQ.Add( wxU("High (slow)") );
+ combo = new wxComboBox( panel, ID_SETTINGS_CB_VIDEO_QUALITY, aQ[2],
+ wxDefaultPosition, wxDefaultSize,
+ aQ, wxCB_READONLY );
+ sizerF->Add( combo, 1, wxEXPAND|wxALL|wxALIGN_RIGHT, 5 );
+
+ sizerF->Add( new wxStaticText( panel, -1, wxU( "Subtitle" ) ),
+ 0, wxALL|wxALIGN_LEFT, 5 );
+ combo = new wxComboBox( panel, ID_SETTINGS_CB_SUBTITLE_LANGUAGE, wxU(""),
+ wxDefaultPosition, wxDefaultSize, 0, NULL,
+ wxCB_READONLY );
+ sizerF->Add( combo, 1, wxEXPAND|wxALL|wxALIGN_RIGHT, 5 );
+
+ sbox->Add( sizerF, 0, wxALL, 5 );
+
+ sizerG->Add( sbox, 1, wxEXPAND|wxALL, 0 );
+
+ sizerV->Add( sizerG, 1, wxEXPAND|wxALL, 5 );
+
+ /* Output */
+ ibox = new wxStaticBox( panel, -1, wxU("Output") );
+ sbox = new wxStaticBoxSizer( ibox, wxVERTICAL);
+
+ sizerF = new wxFlexGridSizer( 3, 1, 20 );
+ sizerF->Add( new wxStaticText( panel, -1, wxU("File") ),
+ 0, wxALL|wxALIGN_LEFT, 5 );
+ combo = new wxComboBox( panel, ID_SETTINGS_CB_OUTPUT_FILE, wxU("") );
+
+ sizerF->Add( combo, 1, wxEXPAND|wxALIGN_RIGHT|
+ wxALIGN_CENTER_VERTICAL|wxALL, 5 );
+ button = new wxButton( panel, ID_SETTINGS_BT_FILE, wxU("Browse..."));
+ sizerF->Add( button, 0, wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL|wxALL, 5 );
+ sbox->Add( sizerF, 0, wxEXPAND|wxALL, 5 );
+
+
+ sizerS = new wxBoxSizer( wxHORIZONTAL );
+
+ sizerF = new wxFlexGridSizer( 2, 2, 20 );
+
+ aQ.Clear();
+ aQ.Add( wxU("800") ); aQ.Add( wxU("700") );
+ aQ.Add( wxU("650") ); aQ.Add( wxU("350") );
+ aQ.Add( wxU("250") ); aQ.Add( wxU("200") );
+ aQ.Add( wxU("150") );
+ radio = new wxRadioButton( panel, ID_SETTINGS_RD_OUTPUT_SIZE, wxU("Size") );
+ combo = new wxComboBox( panel, ID_SETTINGS_CB_OUTPUT_SIZE, wxU(""),
+ wxDefaultPosition, wxDefaultSize, aQ );
+ sizerF->Add( radio, 0, wxALL|wxALIGN_LEFT );
+ sizerF->Add( combo, 1, wxEXPAND|wxALL|wxALIGN_RIGHT );
+ radio->SetValue( FALSE );
+ combo->Enable( FALSE );
+
+ aQ.Clear();
+ aQ.Add( wxU("2500") ); aQ.Add( wxU("2000") );
+ aQ.Add( wxU("1500") ); aQ.Add( wxU("1000") );
+ aQ.Add( wxU("800") ); aQ.Add( wxU("500") );
+ aQ.Add( wxU("300") );
+ radio = new wxRadioButton( panel, ID_SETTINGS_RD_OUTPUT_BITRATE,
+ wxU("Bitrate" ) );
+ combo = new wxComboBox( panel, ID_SETTINGS_CB_OUTPUT_BITRATE, aQ[3],
+ wxDefaultPosition, wxDefaultSize, aQ );
+ sizerF->Add( radio, 0, wxALL|wxALIGN_LEFT );
+ sizerF->Add( combo, 1, wxEXPAND|wxALL|wxALIGN_RIGHT );
+ radio->SetValue( TRUE );
+ combo->Enable( TRUE );
+
+ sizerS->Add( sizerF, 0, wxALL|wxALIGN_CENTER_VERTICAL );
+
+
+ wxBoxSizer *sizerSS = new wxBoxSizer( wxHORIZONTAL );
+ sizerSS->Add( new wxStaticText( panel, -1, wxU( "x" ) ), 0, wxALL, 5 );
+ spin = new wxSpinCtrl( panel, ID_SETTINGS_SC_OUTPUT_FILE_COUNT, wxU("1"),
+ wxDefaultPosition, wxDefaultSize,
+ wxSP_ARROW_KEYS, 1, 5, 1 );
+ spin->Enable( FALSE );
+ sizerSS->Add( spin, 0, wxALL, 5 );
+
+ sizerS->Add( sizerSS, 0, wxALL|wxALIGN_CENTER_VERTICAL );
+
+ sbox->Add( sizerS, 1, wxEXPAND|wxALL, 5 );
+
+ sizerV->Add( sbox, 1, wxEXPAND|wxALL, 5 );
+
+ panel->SetSizerAndFit( sizerV );
+
+ return panel;
+}
+
+static wxPanel *PanelSettingsVideo( wxWindow *p_parent )
+{
+ wxPanel *panel = new wxPanel( p_parent, -1,
+ wxDefaultPosition, wxSize(200, 200));
+ wxFlexGridSizer *sizer = new wxFlexGridSizer( 2, 5, 20 );
+ wxBoxSizer *sizer2;
+ wxBoxSizer *sizer3;
+ wxArrayString aS;
+ wxComboBox *combo;
+ wxCheckBox *check;
+ wxSpinCtrl *spin;
+ int i;
+
+
+ /* Codec */
+ sizer->Add( new wxStaticText( panel, -1, wxU("Codec") ),
+ 1, wxEXPAND|wxALL|wxALIGN_LEFT, 5 );
+ aS.Clear();
+ aS.Add( wxU("FFmpeg") );
+ aS.Add( wxU("XviD") );
+ aS.Add( wxU("x264") );
+ combo = new wxComboBox( panel, ID_SETTINGS_CB_VIDEO_CODEC, aS[0],
+ wxDefaultPosition, wxDefaultSize,
+ aS, wxCB_READONLY );
+ sizer->Add( combo, 0, wxALL|wxALIGN_RIGHT, 5 );
+
+ /* FPS */
+ sizer->Add( new wxStaticText( panel, -1, wxU("Fps") ),
+ 1, wxEXPAND|wxALL|wxALIGN_LEFT, 5 );
+ aS.Clear();
+ for( i = 0; i < hb_video_rates_count; i++ )
+ aS.Add( wxU(hb_video_rates[i].string) );
+ combo = new wxComboBox( panel, ID_SETTINGS_CB_VIDEO_FPS, wxU(""),
+ wxDefaultPosition, wxDefaultSize,
+ aS, wxCB_READONLY );
+ sizer->Add( combo, 0, wxALL|wxALIGN_RIGHT, 5 );
+
+
+ /* Deinterlace */
+ check = new wxCheckBox( panel, ID_SETTINGS_CH_VIDEO_DEINTERLACE,
+ wxU("Deinterlace") );
+ check->SetValue( FALSE );
+
+ sizer->Add( check, 1, wxEXPAND|wxALL|wxALIGN_LEFT, 5 );
+ sizer->Add( 0, 0, 0 );
+
+ /* Crop */
+ check = new wxCheckBox( panel, ID_SETTINGS_CH_VIDEO_CROP, wxU("Crop") );
+ check->SetValue( FALSE );
+ sizer->Add( check, 0, wxTOP|wxBOTTOM|
+ wxALIGN_CENTER_VERTICAL|wxALIGN_LEFT, 5 );
+#if 0
+ sizer2 = new wxBoxSizer( wxVERTICAL );
+ radio = new wxRadioButton( panel, ID_SETTINGS_RD_VIDEO_AUTOCROP,
+ wxU("Autocrop" ) );
+ radio->SetValue( TRUE );
+ sizer2->Add( radio, 0, wxTOP|wxBOTTOM|
+ wxALIGN_CENTER_VERTICAL|wxALIGN_LEFT, 5 );
+ radio = new wxRadioButton( panel, ID_SETTINGS_RD_VIDEO_CUSTOMCROP,
+ wxU("Custom crop" ) );
+ radio->SetValue( FALSE );
+ sizer2->Add( radio, 0, wxTOP|wxBOTTOM|
+ wxALIGN_CENTER_VERTICAL|wxALIGN_LEFT, 5 );
+ sizer->Add( sizer2, 0, wxALL|wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL, 5 );
+#endif
+
+ sizer2 = new wxBoxSizer( wxVERTICAL);
+ spin = new wxSpinCtrl( panel, ID_SETTINGS_SC_VIDEO_CROP_TOP, wxU(""),
+ wxDefaultPosition, wxDefaultSize,
+ wxSP_ARROW_KEYS, 0, 2048, 2 );
+ spin->Enable( FALSE );
+ sizer2->Add( spin, 0, wxALL|wxALIGN_CENTER, 2 );
+ sizer3 = new wxBoxSizer( wxHORIZONTAL);
+ spin = new wxSpinCtrl( panel, ID_SETTINGS_SC_VIDEO_CROP_LEFT, wxU(""),
+ wxDefaultPosition, wxDefaultSize,
+ wxSP_ARROW_KEYS, 0, 2048, 2 );
+ spin->Enable( FALSE );
+ sizer3->Add( spin, 0, wxALL|wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL, 2 );
+ spin = new wxSpinCtrl( panel, ID_SETTINGS_SC_VIDEO_CROP_RIGHT, wxU(""),
+ wxDefaultPosition, wxDefaultSize,
+ wxSP_ARROW_KEYS, 0, 2048, 2 );
+ spin->Enable( FALSE );
+ sizer3->Add( spin, 0, wxALL|wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL, 2 );
+ sizer2->Add( sizer3, 0, wxALL|wxALIGN_CENTER );
+ spin = new wxSpinCtrl( panel, ID_SETTINGS_SC_VIDEO_CROP_BOTTOM, wxU(""),
+ wxDefaultPosition, wxDefaultSize,
+ wxSP_ARROW_KEYS, 0, 2048, 2 );
+ spin->Enable( FALSE );
+ sizer2->Add( spin, 0, wxALL|wxALIGN_CENTER, 2 );
+ sizer->Add( sizer2, 0, wxALL|wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL, 5 );
+
+ /* Size */
+ sizer->Add( new wxStaticText( panel, -1, wxU("Size") ),
+ 0, wxALL|wxALIGN_LEFT, 5 );
+ sizer2 = new wxBoxSizer( wxHORIZONTAL );
+ spin = new wxSpinCtrl( panel, ID_SETTINGS_SC_VIDEO_WIDTH, wxU(""),
+ wxDefaultPosition, wxDefaultSize,
+ wxSP_ARROW_KEYS, 0, 2048, 2 );
+ spin->Enable( FALSE );
+ sizer2->Add( spin, 0, wxALL, 5 );
+ sizer2->Add( new wxStaticText( panel, -1, wxU("x") ), 0, wxALL, 5 );
+ spin = new wxSpinCtrl( panel, ID_SETTINGS_SC_VIDEO_HEIGHT, wxU(""),
+ wxDefaultPosition, wxDefaultSize,
+ wxSP_ARROW_KEYS, 0, 2048, 2 );
+ spin->Enable( FALSE );
+ sizer2->Add( spin, 0, wxALL, 5 );
+
+ sizer->Add( sizer2, 0, wxALL|wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL, 5 );
+
+#if 0
+ sizer->Add( new wxStaticText( panel, -1, wxU("Autocrop: []\n"
+ "Crop: [] [] [] []\n"
+ "2 pass: []\n"
+ "Width: []\n"
+ "Height: []\n"
+ "Preview [..]" ) ),
+ 0, wxALL, 5 );
+#endif
+ panel->SetSizerAndFit( sizer );
+ panel->SetAutoLayout( TRUE );
+ panel->Layout();
+
+ return panel;
+}
+
+static wxPanel *PanelSettingsAudio( wxWindow *p_parent )
+{
+ wxPanel *panel = new wxPanel( p_parent, -1,
+ wxDefaultPosition, wxSize(200, 200));
+ wxFlexGridSizer * sizer = new wxFlexGridSizer( 2, 1, 20 );
+ wxArrayString aS;
+ wxComboBox *combo;
+ unsigned int i;
+
+#if 0
+ /* TODO in the right way (there is a few problem with file type) */
+ /* Codec */
+ sizer->Add( new wxStaticText( panel, -1, wxU("Codec") ),
+ 0, wxALL|wxALIGN_LEFT, 5 );
+ aS.Clear();
+ aS.Add( "Faac" );
+ aS.Add( "Lame" );
+ aS.Add( "Vorbis" );
+ aS.Add( "Ac3" );
+ aS.Add( "Mpga" );
+ aS.Add( "LPCM" );
+ combo = new wxComboBox( panel, ID_SETTINGS_CB_VIDEO_CODEC, aS[0],
+ wxDefaultPosition, wxDefaultSize,
+ aS, wxCB_READONLY );
+ sizer->Add( combo, 1, wxEXPAND|wxALL|wxALIGN_RIGHT, 5 );
+#endif
+ sizer->Add( new wxStaticText( panel, -1, wxU("Samplerate") ),
+ 1, wxEXPAND|wxALL|wxALIGN_LEFT, 5 );
+ aS.Clear();
+ for( i = 0; i < hb_audio_rates_count; i++ )
+ aS.Add( wxString::Format( wxU("%d"), hb_audio_rates[i].rate ) );
+ combo = new wxComboBox( panel, ID_SETTINGS_CB_AUDIO_SAMPLERATE, wxU(""),
+ wxDefaultPosition, wxDefaultSize,
+ aS, wxCB_READONLY );
+ sizer->Add( combo, 0, wxALL|wxALIGN_RIGHT, 5 );
+
+
+ panel->SetSizerAndFit( sizer );
+
+ return panel;
+}
+
+static wxPanel *PanelSettingsOthers( wxWindow *p_parent )
+{
+ wxPanel *panel = new wxPanel( p_parent, -1,
+ wxDefaultPosition, wxSize(200, 200));
+
+ wxBoxSizer *sizer_row = new wxBoxSizer( wxVERTICAL );
+ wxFlexGridSizer *sizer = new wxFlexGridSizer( 2, 2, 20 );
+ wxComboBox *combo;
+ wxArrayString aS;
+ int i;
+ int i_count;
+
+
+ /* CPU */
+ sizer->Add( new wxStaticText( panel, -1, wxU( "CPU" ) ),
+ 1, wxEXPAND|wxALL|wxALIGN_LEFT );
+
+ i_count = g_hbApp->GetSystemCpuCount();
+ aS.Clear();
+ for( i = 0; i < i_count; i++ )
+ aS.Add( wxString::Format( wxU("%d"), i+1 ) );
+
+ combo = new wxComboBox( panel, ID_SETTINGS_CB_CPU,
+ aS[g_hbApp->GetDefaultCpuCount()-1],
+ wxDefaultPosition, wxDefaultSize,
+ aS, wxCB_READONLY );
+ sizer->Add( combo, 0, wxALL|wxALIGN_RIGHT );
+
+ /* Priority */
+ sizer->Add( new wxStaticText( panel, -1, wxU( "Priority" ) ),
+ 1, wxEXPAND|wxALL|wxALIGN_LEFT );
+
+ aS.Clear();
+ aS.Add( wxU("Highest") );
+ aS.Add( wxU("Above Normal") );
+ aS.Add( wxU("Normal") );
+ aS.Add( wxU("Below Normal") );
+ aS.Add( wxU("Lowest") );
+ combo = new wxComboBox( panel, ID_SETTINGS_CB_PRIORITY,
+ aS[4-g_hbApp->GetDefaultPriority()],
+ wxDefaultPosition, wxDefaultSize,
+ aS, wxCB_READONLY );
+ sizer->Add( combo, 0, wxALL|wxALIGN_RIGHT );
+ combo->Enable( FALSE ); /* Marche pas pr le moment */
+
+ sizer_row->Add( sizer, 0, wxEXPAND|wxALL, 5 );
+
+ panel->SetSizerAndFit( sizer_row );
+
+ return panel;
+}
+
+
+class hbWizardPageSettings: public wxWizardPageSimple
+{
+public:
+ hbWizardPageSettings( wxWizard *p_wizard );
+ virtual ~hbWizardPageSettings();
+
+ void OnBrowse( wxCommandEvent &event );
+ void OnTitle( wxCommandEvent &event );
+ void OnChapter( wxCommandEvent &event );
+ void OnRadio( wxCommandEvent &event );
+ void OnAudio( wxCommandEvent &event );
+
+ void SetTitle( int i_title = -1 );
+ void OnPageChanging( wxWizardEvent &event );
+ void OnPageChanged( wxWizardEvent &event );
+
+private:
+ DECLARE_EVENT_TABLE()
+ wxFileDialog *dlgFile;
+};
+
+hbWizardPageSettings::hbWizardPageSettings( wxWizard *p_wizard ) :
+ wxWizardPageSimple(p_wizard)
+{
+ wxNotebook *nb = new wxNotebook( this, ID_SETTINGS_NB );
+ wxNotebookSizer *sizerN = new wxNotebookSizer( nb );
+
+ /* General settings */
+ nb->AddPage( PanelSettingsGeneral(nb), wxU("General"), TRUE );
+
+ /* Advanced */
+ nb->AddPage( PanelSettingsVideo(nb), wxU("Advanced Video"), FALSE );
+
+ /* Advanced */
+ nb->AddPage( PanelSettingsAudio(nb), wxU("Advanced Audio"), FALSE );
+
+ /* Others */
+ nb->AddPage( PanelSettingsOthers(nb), wxU("Others"), FALSE );
+
+
+ hbWizardPageHeaders( this, "Settings", "Set your settings ;).",
+ sizerN );
+
+ /* */
+ dlgFile = NULL;
+}
+
+hbWizardPageSettings::~hbWizardPageSettings()
+{
+}
+
+void hbWizardPageSettings::SetTitle( int i_title )
+{
+ wxArrayString &aT = *g_hbApp->GetTitles();
+ wxArrayString *p_array;
+ wxComboBox *title;
+ wxComboBox *chp;
+ wxComboBox *lg;
+ wxComboBox *fps;
+ wxComboBox *arate;
+ wxString sL;
+ bool bSetDefault = false;
+ int i;
+
+ /* Update title */
+ title = (wxComboBox*)FindWindow( ID_SETTINGS_CB_TITLE );
+ if( i_title < 0 )
+ {
+ title->Clear();
+ title->Append( aT );
+
+ i_title = g_hbApp->GetDefaultTitle();
+ title->SetValue( aT[i_title] );
+ bSetDefault = true;
+ }
+
+ g_hbApp->SetTitle( i_title );
+
+
+ /* Update chapter start/end */
+ chp = (wxComboBox*)FindWindow( ID_SETTINGS_CB_CHAPTER_START );
+ chp->Clear();
+ for( i = 0; i < g_hbApp->GetChaptersCount(); i++ )
+ chp->Append( wxString::Format( wxU("%d"), i+1 ) );
+ chp->SetValue( wxU("1") );
+
+ chp = (wxComboBox*)FindWindow( ID_SETTINGS_CB_CHAPTER_END );
+ chp->Clear();
+ for( i = 0; i < g_hbApp->GetChaptersCount(); i++ )
+ chp->Append( wxString::Format( wxU("%d"), i+1 ) );
+ chp->SetValue( wxString::Format( wxU("%d"), g_hbApp->GetChaptersCount() ) );
+
+ /* Update Audio language */
+ lg = (wxComboBox*)FindWindow( ID_SETTINGS_CB_AUDIO_LANGUAGE );
+ sL = lg->GetValue();
+ lg->Clear();
+ p_array = g_hbApp->GetTracksAudio();
+ lg->Append( *p_array );
+
+ if( bSetDefault || p_array->Index(sL) == wxNOT_FOUND )
+ {
+ sL = g_hbApp->GetDefaultAudio();
+ if( p_array->Index( sL ) == wxNOT_FOUND )
+ sL = (*p_array)[0];
+ }
+ lg->SetValue( sL );
+ g_hbApp->SetTrackAudio( p_array->Index(sL) );/* Needed for audio settings */
+
+ lg = (wxComboBox*)FindWindow( ID_SETTINGS_CB_SUBTITLE_LANGUAGE );
+ sL = lg->GetValue();
+ lg->Clear();
+ p_array = g_hbApp->GetTracksSubtitle();
+ lg->Append( *p_array );
+
+ if( bSetDefault || p_array->Index(sL) == wxNOT_FOUND )
+ {
+ sL = g_hbApp->GetDefaultSubtitle();
+ if( p_array->Index( sL ) == wxNOT_FOUND )
+ sL = p_array->Last();
+ }
+ lg->SetValue( sL );
+
+ if( bSetDefault || g_hbApp->GetDefaultVideoRateBase() != 0 )
+ {
+ int i_base = g_hbApp->GetDefaultVideoRateBase();
+
+ if( i_base == 0 || !bSetDefault )
+ i_base = g_hbApp->GetVideoRateBase();
+
+ fps = (wxComboBox*)FindWindow( ID_SETTINGS_CB_VIDEO_FPS );
+ for( i = 0; i < hb_video_rates_count; i++ )
+ {
+ if( hb_video_rates[i].rate == i_base )
+ {
+ fps->SetSelection( i );
+ break;
+ }
+ }
+ }
+
+ if( bSetDefault || g_hbApp->GetDefaultAudioSamplerate() != 0 )
+ {
+ int i_rate = g_hbApp->GetDefaultAudioSamplerate();
+
+ if( i_rate == 0 || !bSetDefault )
+ i_rate = g_hbApp->GetAudioSamplerate();
+ if( i_rate == 0 )
+ i_rate = 44100;
+
+ arate = (wxComboBox*)FindWindow( ID_SETTINGS_CB_AUDIO_SAMPLERATE );
+ arate->SetValue( wxString::Format( wxU("%d"), i_rate ) );
+ }
+
+ /* Set auto crop values and width size */
+ if( bSetDefault )
+ {
+ wxSpinCtrl *spin;
+ int crop[4];
+ int i_width, i_height;
+
+ g_hbApp->GetVideoAutocrop( crop );
+ g_hbApp->GetVideoSize( &i_width, &i_height );
+
+ /* Crop */
+ spin = (wxSpinCtrl*)FindWindow( ID_SETTINGS_SC_VIDEO_CROP_TOP );
+ spin->SetValue( crop[0] );
+ spin = (wxSpinCtrl*)FindWindow( ID_SETTINGS_SC_VIDEO_CROP_BOTTOM );
+ spin->SetValue( crop[1] );
+ spin = (wxSpinCtrl*)FindWindow( ID_SETTINGS_SC_VIDEO_CROP_LEFT );
+ spin->SetValue( crop[2] );
+ spin = (wxSpinCtrl*)FindWindow( ID_SETTINGS_SC_VIDEO_CROP_RIGHT );
+ spin->SetValue( crop[3] );
+
+ /* Size */
+ spin = (wxSpinCtrl*)FindWindow( ID_SETTINGS_SC_VIDEO_WIDTH );
+ spin->SetValue( i_width - (crop[2]+crop[3]) );
+ spin = (wxSpinCtrl*)FindWindow( ID_SETTINGS_SC_VIDEO_HEIGHT );
+ spin->SetValue( i_height - (crop[0]+crop[1]) );
+ }
+}
+
+
+void hbWizardPageSettings::OnTitle( wxCommandEvent &event )
+{
+ SetTitle( event.GetSelection() );
+}
+
+void hbWizardPageSettings::OnChapter( wxCommandEvent &event )
+{
+ wxComboBox *start = (wxComboBox*)FindWindow( ID_SETTINGS_CB_CHAPTER_START );
+ wxComboBox *end = (wxComboBox*)FindWindow( ID_SETTINGS_CB_CHAPTER_END );
+
+ if( event.GetId() == ID_SETTINGS_CB_CHAPTER_START )
+ {
+ if( start->GetSelection() > end->GetSelection() )
+ end->SetSelection( start->GetSelection() );
+ }
+ else
+ {
+ if( end->GetSelection() < start->GetSelection() )
+ start->SetSelection( end->GetSelection() );
+ }
+}
+
+void hbWizardPageSettings::OnBrowse( wxCommandEvent &event )
+{
+ if( dlgFile == NULL )
+ dlgFile = new wxFileDialog( this, wxU( "Choose a file"),
+ wxGetCwd() );
+
+ if( dlgFile->ShowModal() == wxID_OK )
+ {
+ const wxChar *p = dlgFile->GetPath();
+ wxComboBox *file = (wxComboBox*)FindWindow(ID_SETTINGS_CB_OUTPUT_FILE);
+ file->SetValue( p );
+ }
+}
+
+void hbWizardPageSettings::OnRadio( wxCommandEvent &event )
+{
+ wxRadioButton *rSize =
+ (wxRadioButton*)FindWindow( ID_SETTINGS_RD_OUTPUT_SIZE );
+ wxRadioButton *rBitrate =
+ (wxRadioButton*)FindWindow( ID_SETTINGS_RD_OUTPUT_BITRATE );
+ wxComboBox *cSize =
+ (wxComboBox*)FindWindow( ID_SETTINGS_CB_OUTPUT_SIZE );
+ wxComboBox *cBitrate =
+ (wxComboBox*)FindWindow( ID_SETTINGS_CB_OUTPUT_BITRATE );
+
+ if( event.GetId() == ID_SETTINGS_RD_OUTPUT_SIZE )
+ {
+ /* FIXME is that needed ?? */
+ rBitrate->SetValue(FALSE);
+ cBitrate->Enable(FALSE);
+ cSize->Enable(TRUE);
+ }
+ else
+ {
+ rSize->SetValue(FALSE);
+ cSize->Enable(FALSE);
+ cBitrate->Enable(TRUE);
+ }
+}
+void hbWizardPageSettings::OnAudio( wxCommandEvent &event )
+{
+ if( g_hbApp->GetDefaultAudioSamplerate() == 0 )
+ {
+ int i_rate = g_hbApp->GetAudioSamplerate();
+ wxComboBox *arate =
+ (wxComboBox*)FindWindow( ID_SETTINGS_CB_AUDIO_SAMPLERATE );
+
+ if( i_rate == 0 ) i_rate = 44100;
+ arate->SetValue( wxString::Format( wxU("%d"), i_rate ) );
+ }
+}
+
+void hbWizardPageSettings::OnPageChanging( wxWizardEvent &event )
+{
+ wxComboBox *cFile;
+ wxComboBox *cChap;
+ wxComboBox *cLang;
+ wxComboBox *cQ;
+ wxComboBox *cCombo;
+ wxCheckBox *cCheck;
+ wxRadioButton *rSize;
+ wxSpinCtrl *spin;
+ int i_bitrate_audio;
+ int crop[4];
+ int i_width, i_height;
+
+ wxString sFile;
+
+ if( !event.GetDirection() )
+ return;
+
+ /* We need to validate params and start encoding */
+
+ /* Get and Check validity of parameters */
+ cFile = (wxComboBox*)FindWindow( ID_SETTINGS_CB_OUTPUT_FILE );
+ sFile = cFile->GetValue();
+ if( sFile.IsEmpty() )
+ {
+ hbError( this, wxU("You have to give a output file name") );
+ event.Veto();
+ return;
+ }
+ g_hbApp->SetOutputFile( sFile );
+
+ /* Chapter start/end */
+ cChap = (wxComboBox*)FindWindow( ID_SETTINGS_CB_CHAPTER_START );
+ g_hbApp->SetChapterStart( cChap->GetSelection() + 1 );
+
+ cChap = (wxComboBox*)FindWindow( ID_SETTINGS_CB_CHAPTER_END );
+ g_hbApp->SetChapterEnd( cChap->GetSelection() + 1 );
+
+ /* Audio */
+ cLang = (wxComboBox*)FindWindow( ID_SETTINGS_CB_AUDIO_LANGUAGE );
+ g_hbApp->SetTrackAudio( cLang->GetSelection(), 0 );
+ /* FIXME find a better way */
+ cQ = (wxComboBox*)FindWindow( ID_SETTINGS_CB_AUDIO_QUALITY );
+ sscanf( cQ->GetValue().ToAscii(), "%*s - %d kb/s", &i_bitrate_audio );
+ g_hbApp->SetAudioBitrate( i_bitrate_audio );
+
+ long arate;
+ cCombo = (wxComboBox*)FindWindow( ID_SETTINGS_CB_AUDIO_SAMPLERATE );
+ cCombo->GetValue().ToLong( &arate );
+ g_hbApp->SetAudioSamplerate( arate );
+
+ /* Subs */
+ cLang = (wxComboBox*)FindWindow( ID_SETTINGS_CB_SUBTITLE_LANGUAGE );
+ g_hbApp->SetTrackSubtitle( cLang->GetSelection() );
+
+ /* Video/Quality */
+ cQ = (wxComboBox*)FindWindow( ID_SETTINGS_CB_VIDEO_QUALITY );
+ if( cQ->GetSelection() == 3 )
+ g_hbApp->SetVideoPass( 2 );
+ else
+ g_hbApp->SetVideoPass( 1 );
+ /* Video codec */
+ cCombo = (wxComboBox*)FindWindow( ID_SETTINGS_CB_VIDEO_CODEC );
+ g_hbApp->SetVideoCodec( cCombo->GetValue() );
+ /* Video fps */
+ cCombo = (wxComboBox*)FindWindow( ID_SETTINGS_CB_VIDEO_FPS );
+ g_hbApp->SetVideoRateBase( hb_video_rates[cCombo->GetSelection()].rate );
+ /* Deinterlace */
+ cCheck = (wxCheckBox*)FindWindow( ID_SETTINGS_CH_VIDEO_DEINTERLACE );
+ g_hbApp->SetVideoDeinterlace( cCheck->GetValue() );
+ /* Crop */
+ cCheck = (wxCheckBox*)FindWindow( ID_SETTINGS_CH_VIDEO_CROP );
+ if( cCheck->GetValue() )
+ {
+ spin = (wxSpinCtrl*)FindWindow( ID_SETTINGS_SC_VIDEO_CROP_TOP );
+ crop[0] = spin->GetValue();
+ spin = (wxSpinCtrl*)FindWindow( ID_SETTINGS_SC_VIDEO_CROP_BOTTOM );
+ crop[1] = spin->GetValue();
+ spin = (wxSpinCtrl*)FindWindow( ID_SETTINGS_SC_VIDEO_CROP_LEFT );
+ crop[2] = spin->GetValue();
+ spin = (wxSpinCtrl*)FindWindow( ID_SETTINGS_SC_VIDEO_CROP_RIGHT );
+ crop[3] = spin->GetValue();
+ g_hbApp->SetVideoCrop( crop );
+ }
+ else
+ {
+ g_hbApp->SetVideoCrop( NULL );
+ }
+ spin = (wxSpinCtrl*)FindWindow( ID_SETTINGS_SC_VIDEO_WIDTH );
+ i_width = spin->GetValue();
+ spin = (wxSpinCtrl*)FindWindow( ID_SETTINGS_SC_VIDEO_HEIGHT );
+ i_height = spin->GetValue();
+ g_hbApp->SetVideoSize( i_width, i_height );
+
+
+ rSize = (wxRadioButton*)FindWindow( ID_SETTINGS_RD_OUTPUT_SIZE );
+ if( rSize->GetValue() )
+ {
+ wxComboBox *cSize =
+ (wxComboBox*)FindWindow( ID_SETTINGS_CB_OUTPUT_SIZE );
+ long i_size;
+
+ cSize->GetValue().ToLong( &i_size );
+ if( i_size <= 0 )
+ {
+ hbError( this, wxU("Invalide file size") );
+ event.Veto();
+ return;
+ }
+ g_hbApp->SetTotalSize( i_size );
+ }
+ else
+ {
+ wxComboBox *cBitrate =
+ (wxComboBox*)FindWindow( ID_SETTINGS_CB_OUTPUT_BITRATE );
+ long i_bitrate;
+
+ cBitrate->GetValue().ToLong( &i_bitrate );
+ if( i_bitrate<= 0 )
+ {
+ hbError( this, wxU("Invalid total bitrate") );
+ event.Veto();
+ return;
+ }
+ else if( i_bitrate <= i_bitrate_audio )
+ {
+ hbError( this, wxU("Incompatible total bitrate with audio bitrate") );
+ event.Veto();
+ return;
+ }
+ g_hbApp->SetTotalBitrate( i_bitrate );
+ }
+
+ /* Other settings */
+ /* CPU */
+ cCombo = (wxComboBox*)FindWindow( ID_SETTINGS_CB_CPU );
+ g_hbApp->SetCpuCount( cCombo->GetSelection() );
+
+ cCombo = (wxComboBox*)FindWindow( ID_SETTINGS_CB_PRIORITY );
+ g_hbApp->SetPriority( cCombo->GetSelection() );
+
+ /* TODO finish */
+
+ /* Start the encode (TODO) */
+ if( g_hbApp->Encode() < 0 )
+ {
+ event.Veto(); /* Wrong */
+ return;
+ }
+}
+void hbWizardPageSettings::OnPageChanged( wxWizardEvent &event )
+{
+ /* Initialise avec le titre par d�faut */
+ SetTitle();
+}
+
+BEGIN_EVENT_TABLE( hbWizardPageSettings, wxWizardPageSimple )
+ EVT_BUTTON( ID_SETTINGS_BT_FILE, hbWizardPageSettings::OnBrowse )
+ EVT_COMBOBOX( ID_SETTINGS_CB_TITLE, hbWizardPageSettings::OnTitle )
+ EVT_COMBOBOX( ID_SETTINGS_CB_CHAPTER_START,hbWizardPageSettings::OnChapter)
+ EVT_COMBOBOX( ID_SETTINGS_CB_CHAPTER_END, hbWizardPageSettings::OnChapter )
+ EVT_COMBOBOX( ID_SETTINGS_CB_AUDIO_LANGUAGE, hbWizardPageSettings::OnAudio )
+ EVT_WIZARD_PAGE_CHANGING( -1, hbWizardPageSettings::OnPageChanging )
+ EVT_WIZARD_PAGE_CHANGED( -1, hbWizardPageSettings::OnPageChanged )
+ EVT_RADIOBUTTON( ID_SETTINGS_RD_OUTPUT_SIZE, hbWizardPageSettings::OnRadio)
+ EVT_RADIOBUTTON( ID_SETTINGS_RD_OUTPUT_BITRATE, hbWizardPageSettings::OnRadio)
+END_EVENT_TABLE()
+
+
+/*****************************************************************************
+ * hbWizardPageEncode:
+ *****************************************************************************/
+class hbWizardPageEncode: public wxWizardPageSimple
+{
+public:
+ hbWizardPageEncode( wxWizard *p_wizard );
+ virtual ~hbWizardPageEncode();
+
+private:
+ //DECLARE_EVENT_TABLE()
+};
+
+hbWizardPageEncode::hbWizardPageEncode( wxWizard *p_wizard ) :
+ wxWizardPageSimple(p_wizard)
+{
+ wxBoxSizer *sizer;
+ sizer = new wxBoxSizer( wxVERTICAL );
+#if 0
+ wxGauge * gauge;
+ sizer->Add( new wxStaticText( this, -1, wxU("Progess: x%%" ) ) );
+
+ gauge = new wxGauge( this, -1, 100 );
+ gauge->SetValue( 50 );
+
+ sizer->Add( gauge );
+#endif
+
+
+ hbWizardPageHeaders( this, "Success",
+ "The encode is finished",
+ sizer );
+
+}
+
+hbWizardPageEncode::~hbWizardPageEncode()
+{
+}
+
+/****************************************************************************
+ * hbWizard:
+ ****************************************************************************/
+hbWizard::hbWizard( wxWindow *p_parent) :
+ wxWizard( p_parent, -1, wxU("HandBrake"), wxNullBitmap, wxDefaultPosition)
+{
+ page1 = new hbWizardPageSource( this );
+ page2 = new hbWizardPageSettings( this );
+ page3 = new hbWizardPageEncode( this );
+
+ wxWizardPageSimple::Chain( page1, page2 );
+ wxWizardPageSimple::Chain( page2, page3 );
+
+ //SetPageSize( wxSize( 500, 400 ) );
+ FitToPage( page1 );
+ FitToPage( page2 );
+ FitToPage( page3 );
+}
+
+hbWizard::~hbWizard()
+{
+ Destroy();
+ /* Is that ok */
+ delete page1;
+ delete page2;
+ delete page3;
+}
+
+void hbWizard::Run()
+{
+ fprintf( stderr, "hbWizard::Run\n" );
+
+ RunWizard( page1 );
+}
+
diff --git a/wx/hbWizard.h b/wx/hbWizard.h
new file mode 100644
index 000000000..a66413abe
--- /dev/null
+++ b/wx/hbWizard.h
@@ -0,0 +1,43 @@
+/*****************************************************************************
+ * wizard.h:
+ *****************************************************************************
+ * Copyright (C)
+ * $Id: hbWizard.h,v 1.1 2005/01/16 15:59:21 titer Exp $
+ *
+ * Authors:
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * 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.
+ *****************************************************************************/
+
+class hbWizardPageSource;
+class hbWizardPageSettings;
+class hbWizardPageEncode;
+
+class hbWizard: public wxWizard
+{
+public:
+ hbWizard( wxWindow *p_parent );
+ virtual ~hbWizard();
+
+ void Run();
+
+private:
+ int i_essai;
+ hbWizardPageSource *page1;
+ hbWizardPageSettings *page2;
+ hbWizardPageEncode *page3;
+
+ //DECLARE_EVENT_TABLE()
+};
diff --git a/wx/wxHB.cpp b/wx/wxHB.cpp
new file mode 100644
index 000000000..b336290dd
--- /dev/null
+++ b/wx/wxHB.cpp
@@ -0,0 +1,684 @@
+/*****************************************************************************
+ * wxHB:
+ *****************************************************************************
+ * Copyright (C)
+ * $Id: wxHB.cpp,v 1.8 2005/03/26 23:04:17 titer Exp $
+ *
+ * Authors:
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * 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.
+ *****************************************************************************/
+
+#include "wxHB.h"
+#include "hbWizard.h"
+
+#ifdef SYS_CYGWIN
+# include <windows.h>
+#endif
+
+/****************************************************************************
+ * Definitions / Variables
+ ****************************************************************************/
+class hbApp *g_hbApp = NULL;
+
+IMPLEMENT_APP( hbApp )
+
+/****************************************************************************
+ * Helpers class
+ ****************************************************************************/
+class hbAppTimer: public wxTimer
+{
+public:
+ hbAppTimer()
+ {
+ Start( 50, wxTIMER_CONTINUOUS );
+ }
+ virtual void Notify()
+ {
+ g_hbApp->Update();
+ }
+};
+
+class hbAppProgress: public wxDialog
+{
+public:
+ hbAppProgress( wxWindow *parent, wxString title, wxString msg ) :
+ wxDialog( parent, -1, title, wxDefaultPosition, wxSize( 250, 300),
+ wxDEFAULT_DIALOG_STYLE )
+ {
+ /* Create widgets */
+ txt = new wxStaticText( this, -1, msg );
+ gauge = new wxGauge( this, -1, 100 );
+ button = new wxButton( this, wxID_CANCEL, wxU("Cancel") );
+
+ /* Add evrything in a sizer */
+ wxBoxSizer *sizer = new wxBoxSizer( wxVERTICAL );
+ sizer->Add( txt, 1, wxEXPAND|wxALIGN_CENTER|wxALL, 5 );
+
+ wxBoxSizer *sizerH = new wxBoxSizer( wxHORIZONTAL );
+ sizerH->Add( gauge, 1, wxALIGN_CENTER|wxALL, 5 );
+ sizer->Add( sizerH, 0, wxALIGN_CENTER|wxALL, 5 );
+
+ sizer->Add( button, 0, wxALIGN_CENTER_HORIZONTAL|
+ wxALIGN_BOTTOM|wxALL, 5 );
+ //SetSizerAndFit( sizer );
+ SetSizer( sizer );
+ }
+
+ void SetProgress( int i_percent, wxString msg )
+ {
+ gauge->SetValue( i_percent );
+ txt->SetLabel( msg );
+ }
+
+ void OnClose( wxCloseEvent &event )
+ {
+ EndModal( wxID_CANCEL );
+ }
+
+private:
+ wxStaticText *txt;
+ wxGauge *gauge;
+ wxButton *button;
+
+ DECLARE_EVENT_TABLE()
+};
+
+BEGIN_EVENT_TABLE( hbAppProgress, wxDialog )
+ EVT_CLOSE( hbAppProgress::OnClose )
+END_EVENT_TABLE()
+
+/****************************************************************************
+ * hbApp class
+ ****************************************************************************/
+
+/* OnInit: Call at the very start and put every in place
+ */
+bool hbApp::OnInit()
+{
+ /* Export hbApp */
+ g_hbApp = this;
+
+
+ /* Init all variables */
+ isEnd = false;
+
+ progress = NULL;
+
+ i_title = -1;
+ titles = NULL;
+ title = NULL;
+
+ audios = NULL;
+ subs = NULL;
+
+ systemDrive = NULL;
+
+ /* Start HB */
+ if( Init() )
+ return false;
+
+ /* Start out timer */
+ timer = new hbAppTimer();
+
+ /* Create and Start the wizard */
+ wizard = new hbWizard( NULL );
+ wizard->Run();
+
+ /* Special hack FIXME */
+ isEnd = true;
+
+ return true;
+}
+
+/* OnExit:
+ */
+int hbApp::OnExit()
+{
+ delete timer;
+ delete wizard;
+
+ /* End hb */
+ End();
+
+ /* Delete others FIXME */
+
+ return 0;
+}
+
+/* Init:
+ */
+int hbApp::Init()
+{
+ /* Create a hb instance */
+ hbHandle = hb_init( HB_DEBUG_NONE, 1 );
+ if( hbHandle == NULL )
+ return -1;
+
+ return 0;
+}
+/* Scan:
+ */
+int hbApp::Scan( wxString sDevice )
+{
+ if( sDevice.IsEmpty() )
+ return -1;
+
+ /* Reset state */
+ i_title = -1;
+ if( titles ) delete titles; titles = NULL;
+ if( audios ) delete audios; audios = NULL;
+ if( subs ) delete subs; subs = NULL;
+ title = NULL;
+
+ /* Append a \ if needed */
+ if( sDevice.Length() == 2 && sDevice.Last() == ':' )
+ sDevice.Append( '\\' );
+
+ /* Launch the scan (all titles) */
+ hb_scan( hbHandle, sDevice.ToAscii(), 0 );
+
+ /* Create a progress report */
+ progress = new hbAppProgress( wizard, wxU("Scanning..."), wxU("Opening ")+sDevice);
+ progress->ShowModal();
+
+ if( !hb_list_count( hb_get_titles( hbHandle ) ) )
+ {
+ hbError( wizard, wxU("Scanning failed") );
+ return -1;
+ }
+
+ /* FIXME test if the scan is complete */
+
+
+ return 0;
+}
+/* Encode:
+ */
+int hbApp::Encode()
+{
+ hb_state_t s;
+
+ /* Maybe check a few things like:
+ * - compatible muxer and codecs */
+
+ /* Start the encoding */
+ hb_add( hbHandle, title->job );
+ hb_start( hbHandle );
+
+ /* FIXME use the wizard instead */
+ /* Create a progress report */
+ progress = new hbAppProgress( wizard, wxU("Encoding..."), wxU("0%"));
+ progress->ShowModal();
+
+ hb_get_state( hbHandle, &s );
+ if( s.param.workdone.error != HB_ERROR_NONE )
+ {
+ hb_stop( hbHandle ); /* FIXME to a proper handling */
+ hbError( wizard, wxU("Encoding failed/stopped") );
+ return -1;
+ }
+
+ /* bad */
+ return 0;
+}
+
+/* End:
+ */
+void hbApp::End()
+{
+ hb_close( &hbHandle );
+}
+
+
+wxArrayString *hbApp::GetTitles()
+{
+ hb_list_t *list;
+ int i_count;
+ int i;
+
+ if( titles )
+ return titles;
+
+ /* Create the title list */
+ list = hb_get_titles( hbHandle );
+
+ i_count = hb_list_count( list );
+ if( i_count <= 0 )
+ return NULL;
+
+ titles = new wxArrayString();
+ for( i = 0; i < i_count; i++ )
+ {
+ hb_title_t *t = (hb_title_t*)hb_list_item( list, i );
+ wxString name = wxString::Format( wxU("%d - %d:%02d:%02d"),
+ t->index,
+ t->hours, t->minutes, t->seconds );
+ titles->Add( name );
+ }
+
+ return titles;
+}
+
+void hbApp::SetTitle( int _i_title )
+{
+ int i;
+
+ if( i_title == _i_title )
+ return;
+
+ i_title = _i_title;
+ title = (hb_title_t*)hb_list_item( hb_get_titles( hbHandle ), i_title );
+ if( audios ) delete audios; audios = NULL;
+ if( subs ) delete subs; subs = NULL;
+
+ for( i = 0; i < 8; i++ )
+ title->job->audios[i] = -1;
+ title->job->subtitle = -1;
+}
+
+int hbApp::GetDefaultTitle()
+{
+ hb_list_t *list;
+ int i_best = -1;
+ int i_best_length = 0;
+ int i;
+
+ list = hb_get_titles( hbHandle );
+ for( i = 0; i < hb_list_count( list ); i++ )
+ {
+ hb_title_t *t = (hb_title_t*)hb_list_item( list, i );
+ int i_length = t->hours * 3600 + t->minutes*60 + t->seconds;
+
+ if( i_best < 0 || i_length > i_best_length )
+ {
+ i_best = i;
+ i_best_length = i_length;
+ }
+ }
+
+ return i_best;
+}
+
+
+
+int hbApp::GetChaptersCount()
+{
+ if( i_title < 0 )
+ return 0;
+
+ return hb_list_count( title->list_chapter );
+}
+
+void hbApp::SetChapterStart( int i_chapter )
+{
+ title->job->chapter_start = i_chapter;
+}
+
+void hbApp::SetChapterEnd( int i_chapter )
+{
+ title->job->chapter_end = i_chapter;
+}
+
+wxArrayString *hbApp::GetTracksAudio()
+{
+ int i;
+ if( audios )
+ return audios;
+
+ audios = new wxArrayString();
+ for( i = 0; i < hb_list_count( title->list_audio ); i++ )
+ {
+ hb_audio_t *a = (hb_audio_t*)hb_list_item( title->list_audio, i );
+
+ audios->Add( wxU(a->lang) );
+ }
+ audios->Add( wxU("None") );
+
+ return audios;
+}
+void hbApp::SetTrackAudio( int i_track, int i_pos )
+{
+ if( i_pos >= 0 && i_pos < hb_list_count( title->list_audio ) )
+ title->job->audios[i_pos] = i_track;
+ else
+ title->job->audios[i_pos] = -1;
+}
+
+wxArrayString *hbApp::GetTracksSubtitle()
+{
+ int i;
+
+ if( subs )
+ return subs;
+
+ subs = new wxArrayString();
+ for( i = 0; i < hb_list_count( title->list_subtitle ); i++ )
+ {
+ hb_subtitle_t *s =
+ (hb_subtitle_t*)hb_list_item( title->list_subtitle, i );
+
+ subs->Add( wxU(s->lang) );
+ }
+ subs->Add( wxU("None") );
+
+ return subs;
+}
+
+void hbApp::SetTrackSubtitle( int i_track )
+{
+ if( i_track >= 0 && i_track < hb_list_count( title->list_subtitle ) )
+ title->job->subtitle = i_track;
+ else
+ title->job->subtitle = -1;
+}
+
+void hbApp::SetOutputFile( wxString sFile )
+{
+ char *psz;
+
+ title->job->file = strdup( sFile.ToAscii() ); /* FIXME do we need strdup ? */
+
+ psz = strrchr( title->job->file, '.' );
+ if( psz == NULL )
+ title->job->mux = HB_MUX_AVI; /* By default, FIXME */
+ else if( !strcasecmp( psz, ".avi" ) )
+ title->job->mux = HB_MUX_AVI;
+ else if( !strcasecmp( psz, ".mp4" ) || !strcasecmp( psz, ".mov") )
+ title->job->mux = HB_MUX_MP4;
+ else if( !strcasecmp( psz, ".ogg" ) || !strcasecmp( psz, ".ogm") )
+ title->job->mux = HB_MUX_OGM;
+ else
+ title->job->mux = HB_MUX_AVI; /* By default */
+
+ /* Fix acodec value */
+ switch( title->job->mux )
+ {
+ case HB_MUX_AVI:
+ title->job->acodec = HB_ACODEC_LAME;
+ break;
+ case HB_MUX_MP4:
+ title->job->acodec = HB_ACODEC_FAAC;
+ break;
+ case HB_MUX_OGM:
+ title->job->acodec = HB_ACODEC_VORBIS;
+ break;
+ }
+}
+
+void hbApp::SetAudioBitrate( int i_bitrate )
+{
+ int i_old = title->job->abitrate;
+
+ title->job->abitrate = i_bitrate;
+
+ if( title->job->vbitrate > 0 )
+ title->job->vbitrate = title->job->vbitrate + (i_old - i_bitrate);
+}
+
+void hbApp::SetTotalBitrate( int i_bitrate )
+{
+ title->job->vbitrate = i_bitrate - title->job->abitrate;
+
+ if( title->job->vbitrate <= 0 )
+ title->job->vbitrate = 1;
+}
+
+void hbApp::SetTotalSize( int i_size )
+{
+ /* XXX */
+}
+
+void hbApp::SetVideoPass( int i_pass )
+{
+ /* FIXME is 0 or 1 valid for 1 pass ? */
+ if( i_pass <= 1 )
+ title->job->pass = 0;
+ else if( i_pass == 2 )
+ title->job->pass = 2;
+}
+
+void hbApp::SetVideoCodec( wxString sCodec )
+{
+ if( sCodec.Lower() == wxU("ffmpeg") )
+ title->job->vcodec = HB_VCODEC_FFMPEG;
+ else if( sCodec.Lower() == wxU("xvid") )
+ title->job->vcodec = HB_VCODEC_XVID;
+ else if( sCodec.Lower() == wxU("x264") )
+ title->job->vcodec = HB_VCODEC_XVID;
+}
+
+void hbApp::SetVideoDeinterlace( bool b_deinterlace )
+{
+ title->job->deinterlace = b_deinterlace ? 1 : 0;
+}
+
+void hbApp::SetPriority( int i_priority )
+{
+ /* Doesn't work :(( */
+#ifdef SYS_CYGWIN
+ switch( i_priority )
+ {
+ case HB_PRIORITY_ABOVE_NORMAL:
+ i_priority = THREAD_PRIORITY_ABOVE_NORMAL;
+ break;
+ case HB_PRIORITY_BELOW_NORMAL:
+ i_priority = THREAD_PRIORITY_BELOW_NORMAL;
+ break;
+ case HB_PRIORITY_LOWEST:
+ i_priority = THREAD_PRIORITY_LOWEST;
+ break;
+ case HB_PRIORITY_HIGHEST:
+ i_priority = THREAD_PRIORITY_HIGHEST;
+ break;
+
+ case HB_PRIORITY_NORMAL:
+ default:
+ i_priority = THREAD_PRIORITY_NORMAL;
+ break;
+ }
+ ::SetThreadPriority( GetCurrentThread(), i_priority );
+#else
+ /* TODO */
+#endif
+}
+
+void hbApp::SetCpuCount( int i_cpu )
+{
+ hb_set_cpu_count( hbHandle, i_cpu );
+}
+
+int hbApp::GetVideoRateBase()
+{
+ return title->rate_base;
+}
+
+void hbApp::SetVideoRateBase( int i_base )
+{
+ title->job->vrate_base = i_base;
+ title->job->vrate = HB_VIDEO_RATE_BASE;
+}
+void hbApp::GetVideoAutocrop( int crop[4] )
+{
+ int i;
+ for( i = 0; i < 4; i++ )
+ crop[i] = title->crop[i];
+}
+void hbApp::SetVideoCrop( int crop[4] )
+{
+ int i;
+ for( i = 0; i < 4; i++ )
+ title->job->crop[i] = crop ? crop[i] : 0;
+}
+void hbApp::GetVideoSize( int *pi_width, int *pi_height )
+{
+ *pi_width = title->width;
+ *pi_height = title->height;
+}
+void hbApp::SetVideoSize( int i_width, int i_height )
+{
+ title->job->width = i_width;
+ title->job->height = i_height;
+}
+
+
+int hbApp::GetAudioSamplerate()
+{
+ int idx = title->job->audios[0];
+ if( idx >= 0 && idx < hb_list_count( title->list_audio ) )
+ {
+ hb_audio_t *a = (hb_audio_t*)hb_list_item( title->list_audio, 0 );
+ return a->rate;
+ }
+
+ /* FIXME not good */
+ return title->job->arate;
+}
+
+void hbApp::SetAudioSamplerate( int i_rate )
+{
+ title->job->arate = i_rate;
+}
+
+wxString hbApp::GetDefaultAudio()
+{
+ return wxU("English");
+}
+
+wxString hbApp::GetDefaultSubtitle()
+{
+ return wxU("None");
+}
+
+int hbApp::GetDefaultCpuCount()
+{
+ return GetSystemCpuCount();
+}
+
+int hbApp::GetDefaultPriority()
+{
+ return HB_PRIORITY_NORMAL;
+}
+
+int hbApp::GetDefaultVideoRateBase()
+{
+ return 0;
+}
+
+int hbApp::GetDefaultAudioSamplerate()
+{
+ return 0;
+}
+
+/* Drive */
+wxArrayString *hbApp::GetSystemDrive()
+{
+ if( systemDrive )
+ return systemDrive;
+
+ systemDrive = new wxArrayString();
+#ifdef SYS_CYGWIN
+ char c;
+ for( c = 'A'; c <= 'Z'; c++ )
+ {
+ char pszDrive[4];
+ pszDrive[0] = c;
+ pszDrive[1] = ':';
+ pszDrive[2] = '\\';
+ pszDrive[3] = '\0';
+
+ if( GetDriveType( pszDrive ) == DRIVE_CDROM )
+ systemDrive->Add( wxString::Format( wxU("%c:"), c ) );
+ }
+#else
+ /* TODO true detection */
+ systemDrive->Add( wxU("/dev/dvd") );
+ systemDrive->Add( wxU("/dev/cdrom") );
+#endif
+
+ return systemDrive;
+}
+
+int hbApp::GetSystemCpuCount()
+{
+ return hb_get_cpu_count();
+}
+
+void hbApp::Update()
+{
+ hb_state_t s;
+
+ /* Special hack FIXME */
+ if( isEnd )
+ {
+ g_hbApp->ExitMainLoop();
+ return;
+ }
+
+ /* */
+ hb_get_state( hbHandle, &s );
+ switch( s.state )
+ {
+ case HB_STATE_IDLE:
+ break;
+
+ case HB_STATE_SCANNING:
+ {
+ int i_cur = s.param.scanning.title_cur;
+ int i_cnt = s.param.scanning.title_count;
+
+ if( i_cnt > 0 )
+ {
+ progress->SetProgress( 100*(i_cur-1)/i_cnt,
+ wxString::Format(wxU("Scanning title %d of %d."),
+ i_cur, i_cnt) );
+ }
+ break;
+ }
+
+ case HB_STATE_SCANDONE:
+ if( progress )
+ {
+ progress->SetProgress( 100, wxU("Scanning complete.") );
+ progress->Close( TRUE );
+ //delete progress;
+ progress = NULL;
+ }
+ break;
+
+ case HB_STATE_WORKING:
+ {
+ float f_progress = s.param.working.progress;
+ float f_rate_cur = s.param.working.rate_cur;
+ float f_rate_avg = s.param.working.rate_avg;
+
+ progress->SetProgress( (int)(100 * f_progress),
+ wxString::Format(wxU("Encoding: %.2f %% (%.2f fps, avg %.2f fps)\n"),
+ 100.0 * f_progress, f_rate_cur, f_rate_avg ));
+ break;
+ }
+
+ case HB_STATE_WORKDONE:
+ if( progress )
+ {
+ progress->SetProgress( 100, wxU("Encoding complete.") );
+ progress->Close( TRUE );
+ //delete progress;
+ progress = NULL;
+ }
+ break;
+ }
+}
+
diff --git a/wx/wxHB.h b/wx/wxHB.h
new file mode 100644
index 000000000..c762305d7
--- /dev/null
+++ b/wx/wxHB.h
@@ -0,0 +1,170 @@
+/*****************************************************************************
+ * wxHB:
+ *****************************************************************************
+ * Copyright (C)
+ * $Id: wxHB.h,v 1.2 2005/01/16 17:44:56 titer Exp $
+ *
+ * Authors:
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * 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.
+ *****************************************************************************/
+
+#include "hb.h"
+
+#include <wx/wx.h>
+#include <wx/wizard.h>
+#include <wx/listctrl.h>
+#include <wx/textctrl.h>
+#include <wx/notebook.h>
+#include <wx/spinctrl.h>
+#include <wx/dnd.h>
+#include <wx/treectrl.h>
+#include <wx/gauge.h>
+#include <wx/accel.h>
+#include <wx/checkbox.h>
+#include <wx/image.h>
+#include <wx/wizard.h>
+
+#include "wx/file.h"
+#include "wx/mstream.h"
+#include "wx/wfstream.h"
+#include <wx/statline.h>
+
+#if wxUSE_UNICODE
+#define wxU(psz) wxString(psz, *wxConvCurrent)
+#else
+#define wxU(psz) psz
+#endif
+
+/* Unique global variable: our App
+ * XXX: we could use wxGetApp() instead (but it is a bit longer ;)
+ */
+extern class hbApp *g_hbApp;
+
+/* */
+class hbAppTimer;
+class hbAppProgress;
+class hbWizard;
+
+/* */
+enum
+{
+ HB_PRIORITY_LOWEST = 0,
+ HB_PRIORITY_BELOW_NORMAL,
+ HB_PRIORITY_NORMAL,
+ HB_PRIORITY_ABOVE_NORMAL,
+ HB_PRIORITY_HIGHEST,
+};
+
+/* Our wxApp */
+class hbApp: public wxApp
+{
+public:
+ virtual bool OnInit();
+ virtual int OnExit();
+
+ /* HB related */
+ int Init();
+ int Scan( wxString sDevice );
+ int Encode();
+ void End();
+
+ /* */
+ /* XXX: the wxArrayString aren't duplicated, so don't delete them */
+ wxArrayString *GetTitles();
+ void SetTitle( int i_title );
+
+ int GetChaptersCount();
+ void SetChapterStart( int i_chapter );
+ void SetChapterEnd( int i_chapter );
+
+ wxArrayString *GetTracksAudio();
+ void SetTrackAudio( int i_track, int i_pos = 0 );
+
+ wxArrayString *GetTracksSubtitle();
+ void SetTrackSubtitle( int i_track );
+
+ void SetOutputFile( wxString );
+ void SetAudioBitrate( int );
+ void SetTotalBitrate( int );
+ void SetTotalSize( int );
+ void SetVideoPass( int );
+ void SetPriority( int );
+ void SetVideoCodec( wxString );
+ void SetVideoDeinterlace( bool );
+ void SetCpuCount( int );
+
+ int GetVideoRateBase();
+ void SetVideoRateBase( int );
+
+ int GetAudioSamplerate();
+ void SetAudioSamplerate( int );
+
+ void GetVideoAutocrop( int crop[4] );
+ void SetVideoCrop( int crop[4] );
+ void GetVideoSize( int *pi_width, int *pi_height );
+ void SetVideoSize( int i_width, int i_height );
+
+
+ /* Get Default value (from config file or from logic) */
+ int GetDefaultTitle();
+ wxString GetDefaultAudio();
+ wxString GetDefaultSubtitle();
+ int GetDefaultCpuCount();
+ int GetDefaultPriority();
+ int GetDefaultVideoRateBase();
+ int GetDefaultAudioSamplerate();
+
+ /* Drive */
+ wxArrayString *GetSystemDrive();
+ int GetSystemCpuCount();
+
+
+ /* wx related */
+ /* Called regulary by a timer
+ * FIXME derive hbApp from timer too instead ? */
+ void Update();
+
+private:
+ bool isEnd;
+
+ hbAppTimer *timer;
+ hbWizard *wizard;
+ hbAppProgress *progress;
+
+ hb_handle_t *hbHandle;
+
+ /* */
+ int i_title;
+ wxArrayString *titles;
+ hb_title_t *title;
+
+ int i_chapters;
+ wxArrayString *audios;
+ wxArrayString *subs;
+
+ /* System */
+ wxArrayString *systemDrive;
+};
+
+static void hbError( wxWindow *p_parent, wxString sTitle )
+{
+ wxMessageDialog *dlg = new wxMessageDialog( p_parent,
+ sTitle,
+ wxU("Error"),
+ wxOK|wxCENTRE|wxICON_ERROR );
+ dlg->ShowModal();
+ delete dlg;
+}