1 /*****************************************************************************
2 * fileinfo.cpp : WinCE gui plugin for vlc
3 *****************************************************************************
4 * Copyright (C) 2000-2004 the VideoLAN team
7 * Authors: Marodon Cedric <cedric_marodon@yahoo.fr>
8 * Gildas Bazin <gbazin@videolan.org>
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
23 *****************************************************************************/
25 /*****************************************************************************
27 *****************************************************************************/
29 #include <vlc_interface.h>
39 /*****************************************************************************
41 *****************************************************************************/
42 FileInfo::FileInfo( intf_thread_t *p_intf, CBaseWindow *p_parent,
44 : CBaseWindow( p_intf, p_parent, h_inst )
47 hwnd_fileinfo = hwndTV = NULL;
50 /***********************************************************************
56 Registers the TreeView control class and creates a TreeView.
58 ***********************************************************************/
59 BOOL FileInfo::CreateTreeView(HWND hwnd)
64 INITCOMMONCONTROLSEX iccex;
65 iccex.dwSize = sizeof( INITCOMMONCONTROLSEX );
66 iccex.dwICC = ICC_TREEVIEW_CLASSES;
68 // Registers Statusbar control classes from the common control dll
69 InitCommonControlsEx( &iccex );
71 // Get the coordinates of the parent window's client area
72 GetClientRect( hwnd, &rect );
74 // Assign the window styles for the tree view.
75 dwStyle = WS_VISIBLE | WS_CHILD | TVS_HASLINES | TVS_LINESATROOT |
78 // Create the tree-view control.
79 hwndTV = CreateWindowEx( 0, WC_TREEVIEW, NULL, dwStyle, 0, MENU_HEIGHT,
81 rect.bottom-rect.top-MENU_HEIGHT,
82 hwnd, NULL, hInst, NULL );
84 // Be sure that the tree view actually was created.
85 if( !hwndTV ) return FALSE;
92 /***********************************************************************
98 Update the TreeView with file information.
100 ***********************************************************************/
101 void FileInfo::UpdateFileInfo()
104 TVINSERTSTRUCT tvins = {0};
105 HTREEITEM hPrev = (HTREEITEM)TVI_FIRST;
106 HTREEITEM hPrevRootItem = NULL;
107 HTREEITEM hPrevLev2Item = NULL;
109 p_intf->p_sys->p_input = (input_thread_t *)
110 vlc_object_find( p_intf, VLC_OBJECT_INPUT, FIND_ANYWHERE );
112 input_thread_t *p_input = p_intf->p_sys->p_input;
114 if( !p_input ) return;
116 tvi.mask = TVIF_TEXT | TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_PARAM;
118 // Set the text of the item.
119 tvi.pszText = _FROMMB( p_input->input.p_item->psz_name );
120 tvi.cchTextMax = _tcslen( tvi.pszText );
122 // Save the heading level in the item's application-defined data area
123 tvi.lParam = (LPARAM)1;
125 //tvins.hInsertAfter = TVI_LAST;
126 tvins.hInsertAfter = hPrev;
127 tvins.hParent = TVI_ROOT;
129 // Add the item to the tree-view control.
130 hPrev = (HTREEITEM)TreeView_InsertItem( hwndTV, &tvins );
132 hPrevRootItem = hPrev;
134 vlc_mutex_lock( &p_input->input.p_item->lock );
135 for( int i = 0; i < p_input->input.p_item->i_categories; i++ )
137 info_category_t *p_cat = p_input->input.p_item->pp_categories[i];
139 // Set the text of the item.
140 tvi.pszText = _FROMMB( p_input->input.p_item->psz_name );
141 tvi.cchTextMax = _tcslen( tvi.pszText );
143 // Save the heading level in the item's application-defined data area
144 tvi.lParam = (LPARAM)2; // level 2
146 tvins.hInsertAfter = hPrev;
147 tvins.hParent = hPrevRootItem;
149 // Add the item to the tree-view control.
150 hPrev = (HTREEITEM)TreeView_InsertItem( hwndTV, &tvins );
152 hPrevLev2Item = hPrev;
154 for( int j = 0; j < p_cat->i_infos; j++ )
156 info_t *p_info = p_cat->pp_infos[j];
158 // Set the text of the item.
159 string szAnsi = (string)p_info->psz_name;
161 szAnsi += p_info->psz_value;
162 tvi.pszText = (TCHAR *)_FROMMB( szAnsi.c_str() );
163 tvi.cchTextMax = _tcslen( tvi.pszText );
164 tvi.lParam = (LPARAM)3; // level 3
166 tvins.hInsertAfter = hPrev;
167 tvins.hParent = hPrevLev2Item;
169 // Add the item to the tree-view control.
170 hPrev = (HTREEITEM)TreeView_InsertItem( hwndTV, &tvins );
173 TreeView_Expand( hwndTV, hPrevLev2Item, TVE_EXPANDPARTIAL|TVE_EXPAND );
175 vlc_mutex_unlock( &p_input->input.p_item->lock );
177 TreeView_Expand( hwndTV, hPrevRootItem, TVE_EXPANDPARTIAL|TVE_EXPAND );
182 /***********************************************************************
188 Processes messages sent to the main window.
190 ***********************************************************************/
191 LRESULT FileInfo::WndProc( HWND hwnd, UINT msg, WPARAM wp, LPARAM lp )
198 shidi.dwMask = SHIDIM_FLAGS;
199 shidi.dwFlags = SHIDIF_DONEBUTTON | SHIDIF_SIPDOWN |
200 SHIDIF_FULLSCREENNOMENUBAR;//SHIDIF_SIZEDLGFULLSCREEN;
202 SHInitDialog( &shidi );
203 CreateTreeView( hwnd );
204 UpdateWindow( hwnd );
205 SHFullScreen( GetForegroundWindow(), SHFS_HIDESIPBUTTON );
209 EndDialog( hwnd, LOWORD( wp ) );
213 SHSipPreference( hwnd, SIP_DOWN );
214 SHFullScreen( hwnd, SHFS_HIDESIPBUTTON );
218 if ( LOWORD(wp) == IDOK )
220 EndDialog( hwnd, LOWORD( wp ) );