1 ///////////////////////////////////////////////////////////////////////////// 2 // Name: VobListBox.h 3 // Purpose: The list box to display information about streams in given VOB 4 // Author: Alex Thuering 5 // Created: 03.05.2009 6 // RCS-ID: $Id: VobListBox.h,v 1.15 2016/05/11 20:02:37 ntalex Exp $ 7 // Copyright: (c) Alex Thuering 8 // Licence: GPL 9 ///////////////////////////////////////////////////////////////////////////// 10 11 #ifndef VOB_LIST_BOX_H 12 #define VOB_LIST_BOX_H 13 14 #include <wx/wx.h> 15 #include <wx/vlbox.h> 16 #include <wx/choice.h> 17 #include <wx/dynarray.h> 18 #include "DVD.h" 19 #include <vector> 20 21 WX_DECLARE_OBJARRAY(wxRect, RectList); 22 WX_DECLARE_OBJARRAY(RectList, RectListOfList); 23 WX_DECLARE_OBJARRAY(wxArrayString, StringListOfList); 24 class TitlePropDlg; 25 26 /** 27 * The list box to display information about streams in given VOB. 28 */ 29 class VobListBox: public wxVListBox { 30 public: 31 /** 32 * Constructor 33 */ 34 VobListBox(wxScrolledWindow* parent, wxWindowID id, Vob* vob, PgcArray* pgcs, DVD* dvd, TitlePropDlg* titlePropDlg); 35 36 /** 37 * Returns the height of the specified item (in pixels) 38 */ 39 wxCoord OnMeasureItem(size_t n) const; 40 41 /** 42 * Draws the item with the given index on the provided DC 43 */ 44 void OnDrawItem(wxDC& dc, const wxRect& rect, size_t n) const; 45 46 /** 47 * Removes item with given index 48 */ 49 void RemoveItem(int index); 50 51 /** 52 * Adds audio file to the vob 53 */ 54 void AddAudio(wxString filename); 55 56 /** 57 * Adds subtitle file to the vob 58 */ 59 void AddSubtitle(wxString filename); 60 61 /** 62 * Disables transcoding: sets Copy for all streams and disables choice controls 63 */ 64 void SetDoNotTranscode(bool value); 65 66 /** 67 * Returns true if "do not transcode active ist" 68 */ 69 bool GetDoNotTranscode(); 70 71 /** 72 * Returns true if this VOB contains audio files 73 */ 74 bool HasAudioFiles(); 75 76 /** 77 * Updates VOB and PGC objects with values from controls 78 */ 79 void SetValues(); 80 81 /** 82 * Returns selected aspect ratio 83 */ GetAspectRatio()84 AspectRatio GetAspectRatio() { return m_aspectRatio; } 85 86 /** 87 * Shows properties dialog for selected item 88 */ 89 void ShowPropDialog(); 90 91 private: 92 /** TitlePropDlg */ 93 TitlePropDlg* m_titlePropDlg; 94 /** The DVD */ 95 DVD* m_dvd; 96 /** Copy of VOB object to edit */ 97 Vob* m_vob; 98 /** Arrays of PGCs */ 99 PgcArray* m_pgcs; 100 /** selected aspect ratio */ 101 AspectRatio m_aspectRatio; 102 /** The list of information string list for every file in VOB */ 103 StringListOfList m_info; 104 /** The list of rectangle list. Each rectangle stores coordinates and size of one information string. */ 105 RectListOfList m_infoRect; 106 /** The list of choice controls */ 107 vector<wxChoice*> m_choiceList; 108 /** The list of buttons */ 109 vector<wxButton*> m_buttonList; 110 /** The list of stream indexes for buttons */ 111 vector<int> m_buttonStreamList; 112 /** Index of first choice for audio file */ 113 int m_videoChoiceIdx; 114 /** Index of first choice for audio file */ 115 int m_audioChoiceIdx; 116 /** Index of first choice for subtitle */ 117 int m_subtitleChoiceIdx; 118 119 wxBitmap m_videoImg; 120 wxBitmap m_audioImg; 121 wxBitmap m_subtitleImg; 122 123 wxImage LoadFrame(const wxString& filename) const; 124 wxBitmap Scale(wxImage image); 125 void RefreshInfo(); 126 void UpdateDoNotTranscodeCheck(); 127 128 /** 129 * Adds given string m_info[n] and coordinates/size to m_infoRect[n] 130 * @param s The information string 131 * @param n The list item index 132 * @param dc The device context 133 * @param x The x-coordinate of info string 134 * @param y The y-coordinate of info string 135 * @returns The y-coordinate of new line 136 */ 137 int AddInfo(const wxString& s, int n, wxDC& dc, int x, int y); 138 /** Creates choice control and adds it to the list m_choiceList */ 139 void AddChoiceCtrl(wxArrayString formats, int selection, int x, int y, int& choiceIdx, bool enabled); 140 /** Increase y and height if height of control is greater that actual height */ 141 int UpdateRect(wxRect& rect, wxControl* ctrl); 142 /** Creates button and adds it to the list m_buttonList */ 143 void AddButton(int x, int y, int& buttonIdx, bool enabled, int streamIdx); 144 /** Returns index of choice control for given stream */ 145 int GetChoiceIdx(unsigned int streamIdx); 146 /** Returns index of button for given stream */ 147 int GetButtonIdx(unsigned int streamIdx); 148 /** Gets video format index */ 149 int GetVideoFormatIdx(Stream* stream, VideoFormat videoFormat); 150 /** Sets video format */ 151 void SetVideoFormat(int videoFormat); 152 /** Get video format */ 153 int GetVideoFormat(); 154 /** Get audio format */ 155 int GetAudioFormat(unsigned int streamIdx); 156 /** Sets audio format */ 157 void SetAudioFormat(unsigned int streamIdx, int audioFormat); 158 /** Get audio language code */ 159 wxString GetAudioLangCode(unsigned int streamIdx); 160 /** Sets audio language code */ 161 void SetAudioLangCode(unsigned int streamIdx, wxString langCode); 162 /** Get subtitle language code */ 163 wxString GetSubtitleLangCode(int subtitleIndex); 164 /** Sets subtitle language code */ 165 void SetSubtitleLangCode(int subtitleIndex, wxString langCode); 166 /** Shows subtitle properties dialog */ 167 void ShowPropDialog(unsigned int streamIdx); 168 169 /** Processes a double click event */ 170 void OnDoubleClick(wxMouseEvent& evt); 171 /** Processes a button event */ 172 void OnButton(wxCommandEvent& event); 173 /** Processes a format change event */ 174 void OnFormatChange(wxCommandEvent& event); 175 176 /** Event table */ 177 DECLARE_EVENT_TABLE() 178 }; 179 180 #endif // VOB_LIST_BOX_H 181