1 /*****************************************************************************
2 * fileinfo.cpp : WinCE gui plugin for vlc
3 *****************************************************************************
4 * Copyright (C) 2000-2004 VideoLAN
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., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
23 *****************************************************************************/
25 /*****************************************************************************
27 *****************************************************************************/
46 /*****************************************************************************
48 *****************************************************************************/
49 FileInfo::FileInfo( intf_thread_t *_p_intf, HINSTANCE _hInst )
54 hwnd_fileinfo = hwndTV = NULL;
57 /***********************************************************************
63 Registers the TreeView control class and creates a TreeView.
65 ***********************************************************************/
66 BOOL FileInfo::CreateTreeView(HWND hwnd)
71 INITCOMMONCONTROLSEX iccex;
72 iccex.dwSize = sizeof( INITCOMMONCONTROLSEX );
73 iccex.dwICC = ICC_TREEVIEW_CLASSES;
75 // Registers Statusbar control classes from the common control dll
76 InitCommonControlsEx( &iccex );
78 // Get the coordinates of the parent window's client area
79 GetClientRect( hwnd, &rect );
81 // Assign the window styles for the tree view.
82 dwStyle = WS_VISIBLE | WS_CHILD | TVS_HASLINES | TVS_LINESATROOT |
85 // Create the tree-view control.
86 hwndTV = CreateWindowEx( 0, WC_TREEVIEW, NULL, dwStyle, 0, MENU_HEIGHT,
88 rect.bottom-rect.top-MENU_HEIGHT,
89 hwnd, NULL, hInst, NULL );
91 // Be sure that the tree view actually was created.
92 if( !hwndTV ) return FALSE;
94 UpdateFileInfo( hwndTV );
99 /***********************************************************************
105 Update the TreeView with file information.
107 ***********************************************************************/
108 void FileInfo::UpdateFileInfo(HWND hwnd)
111 TVINSERTSTRUCT tvins = {0};
112 HTREEITEM hPrev = (HTREEITEM)TVI_FIRST;
113 HTREEITEM hPrevRootItem = NULL;
114 HTREEITEM hPrevLev2Item = NULL;
116 p_intf->p_sys->p_input = (input_thread_t *)
117 vlc_object_find( p_intf, VLC_OBJECT_INPUT, FIND_ANYWHERE );
119 input_thread_t *p_input = p_intf->p_sys->p_input;
121 if( !p_input ) return;
123 tvi.mask = TVIF_TEXT | TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_PARAM;
125 // Set the text of the item.
126 tvi.pszText = _FROMMB( p_input->input.p_item->psz_name );
127 tvi.cchTextMax = _tcslen( tvi.pszText );
129 // Save the heading level in the item's application-defined data area
130 tvi.lParam = (LPARAM)1;
132 //tvins.hInsertAfter = TVI_LAST;
133 tvins.hInsertAfter = hPrev;
134 tvins.hParent = TVI_ROOT;
136 // Add the item to the tree-view control.
137 hPrev = (HTREEITEM)TreeView_InsertItem( hwnd, &tvins );
139 hPrevRootItem = hPrev;
141 vlc_mutex_lock( &p_input->input.p_item->lock );
142 for( int i = 0; i < p_input->input.p_item->i_categories; i++ )
144 info_category_t *p_cat = p_input->input.p_item->pp_categories[i];
146 // Set the text of the item.
147 tvi.pszText = _FROMMB( p_input->input.p_item->psz_name );
148 tvi.cchTextMax = _tcslen( tvi.pszText );
150 // Save the heading level in the item's application-defined data area
151 tvi.lParam = (LPARAM)2; // level 2
153 tvins.hInsertAfter = hPrev;
154 tvins.hParent = hPrevRootItem;
156 // Add the item to the tree-view control.
157 hPrev = (HTREEITEM)TreeView_InsertItem( hwnd, &tvins );
159 hPrevLev2Item = hPrev;
161 for( int j = 0; j < p_cat->i_infos; j++ )
163 info_t *p_info = p_cat->pp_infos[j];
165 // Set the text of the item.
166 string szAnsi = (string)p_info->psz_name;
168 szAnsi += p_info->psz_value;
169 tvi.pszText = _FROMMB( szAnsi.c_str() );
170 tvi.cchTextMax = _tcslen( tvi.pszText );
171 tvi.lParam = (LPARAM)3; // level 3
173 tvins.hInsertAfter = hPrev;
174 tvins.hParent = hPrevLev2Item;
176 // Add the item to the tree-view control.
177 hPrev = (HTREEITEM)TreeView_InsertItem( hwnd, &tvins );
180 TreeView_Expand( hwnd, hPrevLev2Item, TVE_EXPANDPARTIAL |TVE_EXPAND );
182 vlc_mutex_unlock( &p_input->input.p_item->lock );
184 TreeView_Expand( hwnd, hPrevRootItem, TVE_EXPANDPARTIAL |TVE_EXPAND );
189 /***********************************************************************
195 Processes messages sent to the main window.
197 ***********************************************************************/
198 LRESULT FileInfo::WndProc( HWND hwnd, UINT msg, WPARAM wp, LPARAM lp,
203 LRESULT lResult = CBaseWindow::WndProc( hwnd, msg, wp, lp, pbProcessed );
204 BOOL bWasProcessed = *pbProcessed;
210 shidi.dwMask = SHIDIM_FLAGS;
211 shidi.dwFlags = SHIDIF_DONEBUTTON | SHIDIF_SIPDOWN |
212 SHIDIF_FULLSCREENNOMENUBAR;//SHIDIF_SIZEDLGFULLSCREEN;
214 SHInitDialog( &shidi );
215 CreateTreeView( hwnd );
216 UpdateWindow( hwnd );
217 SHFullScreen( GetForegroundWindow(), SHFS_HIDESIPBUTTON );
221 if ( LOWORD(wp) == IDOK )
223 EndDialog( hwnd, LOWORD( wp ) );
226 *pbProcessed = bWasProcessed;
231 // the message was not processed
232 // indicate if the base class handled it
233 *pbProcessed = bWasProcessed;