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 *****************************************************************************/
28 #include <string.h> /* strerror() */
31 #include <vlc_interface.h>
41 /*****************************************************************************
43 *****************************************************************************/
44 FileInfo::FileInfo( intf_thread_t *p_intf, CBaseWindow *p_parent,
46 : CBaseWindow( p_intf, p_parent, h_inst )
49 hwnd_fileinfo = hwndTV = NULL;
52 /***********************************************************************
58 Registers the TreeView control class and creates a TreeView.
60 ***********************************************************************/
61 BOOL FileInfo::CreateTreeView(HWND hwnd)
66 INITCOMMONCONTROLSEX iccex;
67 iccex.dwSize = sizeof( INITCOMMONCONTROLSEX );
68 iccex.dwICC = ICC_TREEVIEW_CLASSES;
70 // Registers Statusbar control classes from the common control dll
71 InitCommonControlsEx( &iccex );
73 // Get the coordinates of the parent window's client area
74 GetClientRect( hwnd, &rect );
76 // Assign the window styles for the tree view.
77 dwStyle = WS_VISIBLE | WS_CHILD | TVS_HASLINES | TVS_LINESATROOT |
80 // Create the tree-view control.
81 hwndTV = CreateWindowEx( 0, WC_TREEVIEW, NULL, dwStyle, 0, MENU_HEIGHT,
83 rect.bottom-rect.top-MENU_HEIGHT,
84 hwnd, NULL, hInst, NULL );
86 // Be sure that the tree view actually was created.
87 if( !hwndTV ) return FALSE;
94 /***********************************************************************
100 Update the TreeView with file information.
102 ***********************************************************************/
103 void FileInfo::UpdateFileInfo()
106 TVINSERTSTRUCT tvins = {0};
107 HTREEITEM hPrev = (HTREEITEM)TVI_FIRST;
108 HTREEITEM hPrevRootItem = NULL;
109 HTREEITEM hPrevLev2Item = NULL;
111 p_intf->p_sys->p_input = (input_thread_t *)
112 vlc_object_find( p_intf, VLC_OBJECT_INPUT, FIND_ANYWHERE );
114 input_thread_t *p_input = p_intf->p_sys->p_input;
116 if( !p_input ) return;
118 tvi.mask = TVIF_TEXT | TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_PARAM;
120 // Set the text of the item.
121 tvi.pszText = _FROMMB( p_input->input.p_item->psz_name );
122 tvi.cchTextMax = _tcslen( tvi.pszText );
124 // Save the heading level in the item's application-defined data area
125 tvi.lParam = (LPARAM)1;
127 //tvins.hInsertAfter = TVI_LAST;
128 tvins.hInsertAfter = hPrev;
129 tvins.hParent = TVI_ROOT;
131 // Add the item to the tree-view control.
132 hPrev = (HTREEITEM)TreeView_InsertItem( hwndTV, &tvins );
134 hPrevRootItem = hPrev;
136 vlc_mutex_lock( &p_input->input.p_item->lock );
137 for( int i = 0; i < p_input->input.p_item->i_categories; i++ )
139 info_category_t *p_cat = p_input->input.p_item->pp_categories[i];
141 // Set the text of the item.
142 tvi.pszText = _FROMMB( p_input->input.p_item->psz_name );
143 tvi.cchTextMax = _tcslen( tvi.pszText );
145 // Save the heading level in the item's application-defined data area
146 tvi.lParam = (LPARAM)2; // level 2
148 tvins.hInsertAfter = hPrev;
149 tvins.hParent = hPrevRootItem;
151 // Add the item to the tree-view control.
152 hPrev = (HTREEITEM)TreeView_InsertItem( hwndTV, &tvins );
154 hPrevLev2Item = hPrev;
156 for( int j = 0; j < p_cat->i_infos; j++ )
158 info_t *p_info = p_cat->pp_infos[j];
160 // Set the text of the item.
161 string szAnsi = (string)p_info->psz_name;
163 szAnsi += p_info->psz_value;
164 tvi.pszText = (TCHAR *)_FROMMB( szAnsi.c_str() );
165 tvi.cchTextMax = _tcslen( tvi.pszText );
166 tvi.lParam = (LPARAM)3; // level 3
168 tvins.hInsertAfter = hPrev;
169 tvins.hParent = hPrevLev2Item;
171 // Add the item to the tree-view control.
172 hPrev = (HTREEITEM)TreeView_InsertItem( hwndTV, &tvins );
175 TreeView_Expand( hwndTV, hPrevLev2Item, TVE_EXPANDPARTIAL|TVE_EXPAND );
177 vlc_mutex_unlock( &p_input->input.p_item->lock );
179 TreeView_Expand( hwndTV, hPrevRootItem, TVE_EXPANDPARTIAL|TVE_EXPAND );
184 /***********************************************************************
190 Processes messages sent to the main window.
192 ***********************************************************************/
193 LRESULT FileInfo::WndProc( HWND hwnd, UINT msg, WPARAM wp, LPARAM lp )
200 shidi.dwMask = SHIDIM_FLAGS;
201 shidi.dwFlags = SHIDIF_DONEBUTTON | SHIDIF_SIPDOWN |
202 SHIDIF_FULLSCREENNOMENUBAR;//SHIDIF_SIZEDLGFULLSCREEN;
204 SHInitDialog( &shidi );
205 CreateTreeView( hwnd );
206 UpdateWindow( hwnd );
207 SHFullScreen( GetForegroundWindow(), SHFS_HIDESIPBUTTON );
211 EndDialog( hwnd, LOWORD( wp ) );
215 SHSipPreference( hwnd, SIP_DOWN );
216 SHFullScreen( hwnd, SHFS_HIDESIPBUTTON );
220 if ( LOWORD(wp) == IDOK )
222 EndDialog( hwnd, LOWORD( wp ) );