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 *****************************************************************************/
30 #include <vlc_interface.h>
40 /*****************************************************************************
42 *****************************************************************************/
43 FileInfo::FileInfo( intf_thread_t *p_intf, CBaseWindow *p_parent,
45 : CBaseWindow( p_intf, p_parent, h_inst )
48 hwnd_fileinfo = hwndTV = NULL;
51 /***********************************************************************
57 Registers the TreeView control class and creates a TreeView.
59 ***********************************************************************/
60 BOOL FileInfo::CreateTreeView(HWND hwnd)
65 INITCOMMONCONTROLSEX iccex;
66 iccex.dwSize = sizeof( INITCOMMONCONTROLSEX );
67 iccex.dwICC = ICC_TREEVIEW_CLASSES;
69 // Registers Statusbar control classes from the common control dll
70 InitCommonControlsEx( &iccex );
72 // Get the coordinates of the parent window's client area
73 GetClientRect( hwnd, &rect );
75 // Assign the window styles for the tree view.
76 dwStyle = WS_VISIBLE | WS_CHILD | TVS_HASLINES | TVS_LINESATROOT |
79 // Create the tree-view control.
80 hwndTV = CreateWindowEx( 0, WC_TREEVIEW, NULL, dwStyle, 0, MENU_HEIGHT,
82 rect.bottom-rect.top-MENU_HEIGHT,
83 hwnd, NULL, hInst, NULL );
85 // Be sure that the tree view actually was created.
86 if( !hwndTV ) return FALSE;
93 /***********************************************************************
99 Update the TreeView with file information.
101 ***********************************************************************/
102 void FileInfo::UpdateFileInfo()
105 TVINSERTSTRUCT tvins = {0};
106 HTREEITEM hPrev = (HTREEITEM)TVI_FIRST;
107 HTREEITEM hPrevRootItem = NULL;
108 HTREEITEM hPrevLev2Item = NULL;
110 p_intf->p_sys->p_input = (input_thread_t *)
111 vlc_object_find( p_intf, VLC_OBJECT_INPUT, FIND_ANYWHERE );
113 input_thread_t *p_input = p_intf->p_sys->p_input;
115 if( !p_input ) return;
117 tvi.mask = TVIF_TEXT | TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_PARAM;
119 // Set the text of the item.
120 tvi.pszText = _FROMMB( p_input->input.p_item->psz_name );
121 tvi.cchTextMax = _tcslen( tvi.pszText );
123 // Save the heading level in the item's application-defined data area
124 tvi.lParam = (LPARAM)1;
126 //tvins.hInsertAfter = TVI_LAST;
127 tvins.hInsertAfter = hPrev;
128 tvins.hParent = TVI_ROOT;
130 // Add the item to the tree-view control.
131 hPrev = (HTREEITEM)TreeView_InsertItem( hwndTV, &tvins );
133 hPrevRootItem = hPrev;
135 vlc_mutex_lock( &p_input->input.p_item->lock );
136 for( int i = 0; i < p_input->input.p_item->i_categories; i++ )
138 info_category_t *p_cat = p_input->input.p_item->pp_categories[i];
140 // Set the text of the item.
141 tvi.pszText = _FROMMB( p_input->input.p_item->psz_name );
142 tvi.cchTextMax = _tcslen( tvi.pszText );
144 // Save the heading level in the item's application-defined data area
145 tvi.lParam = (LPARAM)2; // level 2
147 tvins.hInsertAfter = hPrev;
148 tvins.hParent = hPrevRootItem;
150 // Add the item to the tree-view control.
151 hPrev = (HTREEITEM)TreeView_InsertItem( hwndTV, &tvins );
153 hPrevLev2Item = hPrev;
155 for( int j = 0; j < p_cat->i_infos; j++ )
157 info_t *p_info = p_cat->pp_infos[j];
159 // Set the text of the item.
160 string szAnsi = (string)p_info->psz_name;
162 szAnsi += p_info->psz_value;
163 tvi.pszText = (TCHAR *)_FROMMB( szAnsi.c_str() );
164 tvi.cchTextMax = _tcslen( tvi.pszText );
165 tvi.lParam = (LPARAM)3; // level 3
167 tvins.hInsertAfter = hPrev;
168 tvins.hParent = hPrevLev2Item;
170 // Add the item to the tree-view control.
171 hPrev = (HTREEITEM)TreeView_InsertItem( hwndTV, &tvins );
174 TreeView_Expand( hwndTV, hPrevLev2Item, TVE_EXPANDPARTIAL|TVE_EXPAND );
176 vlc_mutex_unlock( &p_input->input.p_item->lock );
178 TreeView_Expand( hwndTV, hPrevRootItem, TVE_EXPANDPARTIAL|TVE_EXPAND );
183 /***********************************************************************
189 Processes messages sent to the main window.
191 ***********************************************************************/
192 LRESULT FileInfo::WndProc( HWND hwnd, UINT msg, WPARAM wp, LPARAM lp )
199 shidi.dwMask = SHIDIM_FLAGS;
200 shidi.dwFlags = SHIDIF_DONEBUTTON | SHIDIF_SIPDOWN |
201 SHIDIF_FULLSCREENNOMENUBAR;//SHIDIF_SIZEDLGFULLSCREEN;
203 SHInitDialog( &shidi );
204 CreateTreeView( hwnd );
205 UpdateWindow( hwnd );
206 SHFullScreen( GetForegroundWindow(), SHFS_HIDESIPBUTTON );
210 EndDialog( hwnd, LOWORD( wp ) );
214 SHSipPreference( hwnd, SIP_DOWN );
215 SHFullScreen( hwnd, SHFS_HIDESIPBUTTON );
219 if ( LOWORD(wp) == IDOK )
221 EndDialog( hwnd, LOWORD( wp ) );