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 *****************************************************************************/
32 #include <vlc_common.h>
33 #include <vlc_interface.h>
34 #include <vlc_input.h>
44 /*****************************************************************************
46 *****************************************************************************/
47 FileInfo::FileInfo( intf_thread_t *p_intf, CBaseWindow *p_parent,
49 : CBaseWindow( p_intf, p_parent, h_inst )
52 hwnd_fileinfo = hwndTV = NULL;
55 /***********************************************************************
61 Registers the TreeView control class and creates a TreeView.
63 ***********************************************************************/
64 BOOL FileInfo::CreateTreeView(HWND hwnd)
69 INITCOMMONCONTROLSEX iccex;
70 iccex.dwSize = sizeof( INITCOMMONCONTROLSEX );
71 iccex.dwICC = ICC_TREEVIEW_CLASSES;
73 // Registers Statusbar control classes from the common control dll
74 InitCommonControlsEx( &iccex );
76 // Get the coordinates of the parent window's client area
77 GetClientRect( hwnd, &rect );
79 // Assign the window styles for the tree view.
80 dwStyle = WS_VISIBLE | WS_CHILD | TVS_HASLINES | TVS_LINESATROOT |
83 // Create the tree-view control.
84 hwndTV = CreateWindowEx( 0, WC_TREEVIEW, NULL, dwStyle, 0, MENU_HEIGHT,
86 rect.bottom-rect.top-MENU_HEIGHT,
87 hwnd, NULL, hInst, NULL );
89 // Be sure that the tree view actually was created.
90 if( !hwndTV ) return FALSE;
97 /***********************************************************************
103 Update the TreeView with file information.
105 ***********************************************************************/
106 void FileInfo::UpdateFileInfo()
109 TVINSERTSTRUCT tvins = {0};
110 HTREEITEM hPrev = (HTREEITEM)TVI_FIRST;
111 HTREEITEM hPrevRootItem = NULL;
112 HTREEITEM hPrevLev2Item = NULL;
114 p_intf->p_sys->p_input = (input_thread_t *)
115 vlc_object_find( p_intf, VLC_OBJECT_INPUT, FIND_ANYWHERE );
117 input_thread_t *p_input = p_intf->p_sys->p_input;
119 if( !p_input ) return;
121 tvi.mask = TVIF_TEXT | TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_PARAM;
123 input_item_t * inp_item = input_GetItem(p_input);
124 tvi.pszText = _FROMMB( input_item_GetName( inp_item ) );
125 tvi.cchTextMax = _tcslen( tvi.pszText );
127 // Save the heading level in the item's application-defined data area
128 tvi.lParam = (LPARAM)1;
130 //tvins.hInsertAfter = TVI_LAST;
131 tvins.hInsertAfter = hPrev;
132 tvins.hParent = TVI_ROOT;
134 // Add the item to the tree-view control.
135 hPrev = (HTREEITEM)TreeView_InsertItem( hwndTV, &tvins );
137 hPrevRootItem = hPrev;
139 vlc_mutex_lock( &inp_item->lock );
140 for( int i = 0; i < inp_item->i_categories; i++ )
142 info_category_t *p_cat = inp_item->pp_categories[i];
144 // Set the text of the item.
145 tvi.pszText = _FROMMB( inp_item->psz_name );
146 tvi.cchTextMax = _tcslen( tvi.pszText );
148 // Save the heading level in the item's application-defined data area
149 tvi.lParam = (LPARAM)2; // level 2
151 tvins.hInsertAfter = hPrev;
152 tvins.hParent = hPrevRootItem;
154 // Add the item to the tree-view control.
155 hPrev = (HTREEITEM)TreeView_InsertItem( hwndTV, &tvins );
157 hPrevLev2Item = hPrev;
159 for( int j = 0; j < p_cat->i_infos; j++ )
161 info_t *p_info = p_cat->pp_infos[j];
163 // Set the text of the item.
164 string szAnsi = (string)p_info->psz_name;
166 szAnsi += p_info->psz_value;
167 tvi.pszText = (TCHAR *)_FROMMB( szAnsi.c_str() );
168 tvi.cchTextMax = _tcslen( tvi.pszText );
169 tvi.lParam = (LPARAM)3; // level 3
171 tvins.hInsertAfter = hPrev;
172 tvins.hParent = hPrevLev2Item;
174 // Add the item to the tree-view control.
175 hPrev = (HTREEITEM)TreeView_InsertItem( hwndTV, &tvins );
178 TreeView_Expand( hwndTV, hPrevLev2Item, TVE_EXPANDPARTIAL|TVE_EXPAND );
180 vlc_mutex_unlock( &inp_item->lock );
182 TreeView_Expand( hwndTV, hPrevRootItem, TVE_EXPANDPARTIAL|TVE_EXPAND );
187 /***********************************************************************
193 Processes messages sent to the main window.
195 ***********************************************************************/
196 LRESULT FileInfo::WndProc( HWND hwnd, UINT msg, WPARAM wp, LPARAM lp )
203 shidi.dwMask = SHIDIM_FLAGS;
204 shidi.dwFlags = SHIDIF_DONEBUTTON | SHIDIF_SIPDOWN |
205 SHIDIF_FULLSCREENNOMENUBAR;//SHIDIF_SIZEDLGFULLSCREEN;
207 SHInitDialog( &shidi );
208 CreateTreeView( hwnd );
209 UpdateWindow( hwnd );
210 SHFullScreen( GetForegroundWindow(), SHFS_HIDESIPBUTTON );
214 EndDialog( hwnd, LOWORD( wp ) );
218 SHSipPreference( hwnd, SIP_DOWN );
219 SHFullScreen( hwnd, SHFS_HIDESIPBUTTON );
223 if ( LOWORD(wp) == IDOK )
225 EndDialog( hwnd, LOWORD( wp ) );