1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146
|
// GUI_Main_Easy - WxWidgets GUI for MediaInfo
// Copyright (C) 2002-2012 MediaArea.net SARL, Info@MediaArea.net
//
// This program is free software: you can redistribute it and/or modify it
// under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 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 Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//---------------------------------------------------------------------------
#include "wx/wxprec.h"
#ifndef WX_PRECOMP
#include "wx/wx.h"
#endif
#ifdef __BORLANDC__
#pragma hdrstop
#endif
#include "GUI/WxWidgets/GUI_Main_Easy.h"
#include "GUI/WxWidgets/GUI_Main_Easy_Box.h"
#include "GUI/WxWidgets/GUI_Main_FileDrop.h"
#include "Common/Core.h"
#include <wx/panel.h>
#include <wx/statbox.h>
#include <wx/stattext.h>
#include <wx/button.h>
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
BEGIN_EVENT_TABLE(GUI_Main_Easy, wxPanel)
EVT_CHOICE (26981, GUI_Main_Easy::OnChoice)
END_EVENT_TABLE()
//---------------------------------------------------------------------------
//***************************************************************************
// Constructor/Destructor
//***************************************************************************
//---------------------------------------------------------------------------
GUI_Main_Easy::GUI_Main_Easy(Core* _C, wxWindow* parent)
: wxPanel(parent, 26981, wxPoint(0, 0), wxSize(parent->GetClientSize().GetWidth()-0, parent->GetClientSize().GetHeight()-0)),
GUI_Main_Easy_Core(_C)
{
//Creation - Select
Select=new wxChoice(this, 26981);
//Creation - Other
Boxes.resize(Stream_Max);
for (size_t StreamPos=0; StreamPos<Stream_Max; StreamPos++)
{
Boxes[StreamPos].resize(Boxes_Count_Get(StreamPos));
for (size_t Pos=0; Pos<Boxes[StreamPos].size(); Pos++)
Boxes[StreamPos][Pos]=new GUI_Main_Easy_Box(C, this, Pos==0?NULL:Boxes[StreamPos][Pos-1], StreamPos==0?(wxWindow*)Select:(wxWindow*)Boxes[StreamPos-1][0], (stream_t)StreamPos, Pos);
}
//Drag and Drop
#if wxUSE_DRAG_AND_DROP && defined(__WXMAC__)
SetDropTarget(new FileDrop(C));
Select->SetDropTarget(new FileDrop(C));
#endif //wxUSE_DRAG_AND_DROP
//Update
GUI_Resize();
GUI_Refresh();
}
//---------------------------------------------------------------------------
GUI_Main_Easy::~GUI_Main_Easy()
{
for (size_t StreamPos=0; StreamPos<Stream_Max; StreamPos++)
{
Boxes[StreamPos].resize(Boxes_Count_Get(StreamPos));
for (size_t Pos=0; Pos<Boxes[StreamPos].size(); Pos++)
delete Boxes[StreamPos][Pos]; //Boxes[StreamPos][Pos]=NULL;
}
}
//***************************************************************************
// Actions
//***************************************************************************
//---------------------------------------------------------------------------
void GUI_Main_Easy::GUI_Refresh()
{
//The choice list
Select->Clear();
size_t FilesCount=FilesCount_Get();
for (File_Pos=0; File_Pos<FilesCount; File_Pos++)
Select->Append(FileName_Get().c_str());
File_Pos=0;
Select->SetSelection((int)File_Pos);
GUI_Refresh_Partial();
}
//---------------------------------------------------------------------------
void GUI_Main_Easy::GUI_Refresh_Partial()
{
//For each box
for (size_t StreamPos=0; StreamPos<Stream_Max; StreamPos++)
for (size_t Pos=0; Pos<Boxes[StreamPos].size(); Pos++)
Boxes[StreamPos][Pos]->GUI_Refresh();
//Resize some boxes if needed
GUI_Resize_Partial();
}
//---------------------------------------------------------------------------
void GUI_Main_Easy::GUI_Resize()
{
//Global and Select
SetSize(0, 0, GetParent()->GetClientSize().GetWidth()-0, GetParent()->GetClientSize().GetHeight()-0);
Select->SetSize(0, 0, GetClientSize().GetWidth(), Select->GetBestSize().GetHeight());
//Other
GUI_Resize_Partial();
}
//---------------------------------------------------------------------------
void GUI_Main_Easy::GUI_Resize_Partial()
{
//For each box
for (size_t StreamPos=0; StreamPos<Stream_Max; StreamPos++)
for (size_t Pos=0; Pos<Boxes[StreamPos].size(); Pos++)
Boxes[StreamPos][Pos]->GUI_Resize();
}
//***************************************************************************
// Events
//***************************************************************************
void GUI_Main_Easy::OnChoice(wxCommandEvent& event)
{
File_Pos=Select->GetSelection();
GUI_Refresh_Partial();
}
|