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 *****************************************************************************/
28 #include <stdlib.h> /* malloc(), free() */
29 #include <string.h> /* strerror() */
42 /*****************************************************************************
44 *****************************************************************************/
45 FileInfo::FileInfo( intf_thread_t *_p_intf, HINSTANCE _hInst )
50 hwnd_fileinfo = hwndTV = NULL;
53 /***********************************************************************
59 Registers the TreeView control class and creates a TreeView.
61 ***********************************************************************/
62 BOOL FileInfo::CreateTreeView(HWND hwnd)
67 INITCOMMONCONTROLSEX iccex;
68 iccex.dwSize = sizeof( INITCOMMONCONTROLSEX );
69 iccex.dwICC = ICC_TREEVIEW_CLASSES;
71 // Registers Statusbar control classes from the common control dll
72 InitCommonControlsEx( &iccex );
74 // Get the coordinates of the parent window's client area
75 GetClientRect( hwnd, &rect );
77 // Assign the window styles for the tree view.
78 dwStyle = WS_VISIBLE | WS_CHILD | TVS_HASLINES | TVS_LINESATROOT |
81 // Create the tree-view control.
82 hwndTV = CreateWindowEx( 0, WC_TREEVIEW, NULL, dwStyle, 0, MENU_HEIGHT,
84 rect.bottom-rect.top-MENU_HEIGHT,
85 hwnd, NULL, hInst, NULL );
87 // Be sure that the tree view actually was created.
88 if( !hwndTV ) return FALSE;
90 UpdateFileInfo( hwndTV );
95 /***********************************************************************
101 Update the TreeView with file information.
103 ***********************************************************************/
104 void FileInfo::UpdateFileInfo(HWND hwnd)
107 TVINSERTSTRUCT tvins = {0};
108 HTREEITEM hPrev = (HTREEITEM)TVI_FIRST;
109 HTREEITEM hPrevRootItem = NULL;
110 HTREEITEM hPrevLev2Item = NULL;
112 p_intf->p_sys->p_input = (input_thread_t *)
113 vlc_object_find( p_intf, VLC_OBJECT_INPUT, FIND_ANYWHERE );
115 input_thread_t *p_input = p_intf->p_sys->p_input;
117 if( !p_input ) return;
119 tvi.mask = TVIF_TEXT | TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_PARAM;
121 // Set the text of the item.
122 tvi.pszText = _FROMMB( p_input->input.p_item->psz_name );
123 tvi.cchTextMax = _tcslen( tvi.pszText );
125 // Save the heading level in the item's application-defined data area
126 tvi.lParam = (LPARAM)1;
128 //tvins.hInsertAfter = TVI_LAST;
129 tvins.hInsertAfter = hPrev;
130 tvins.hParent = TVI_ROOT;
132 // Add the item to the tree-view control.
133 hPrev = (HTREEITEM)TreeView_InsertItem( hwnd, &tvins );
135 hPrevRootItem = hPrev;
137 vlc_mutex_lock( &p_input->input.p_item->lock );
138 for( int i = 0; i < p_input->input.p_item->i_categories; i++ )
140 info_category_t *p_cat = p_input->input.p_item->pp_categories[i];
142 // Set the text of the item.
143 tvi.pszText = _FROMMB( p_input->input.p_item->psz_name );
144 tvi.cchTextMax = _tcslen( tvi.pszText );
146 // Save the heading level in the item's application-defined data area
147 tvi.lParam = (LPARAM)2; // level 2
149 tvins.hInsertAfter = hPrev;
150 tvins.hParent = hPrevRootItem;
152 // Add the item to the tree-view control.
153 hPrev = (HTREEITEM)TreeView_InsertItem( hwnd, &tvins );
155 hPrevLev2Item = hPrev;
157 for( int j = 0; j < p_cat->i_infos; j++ )
159 info_t *p_info = p_cat->pp_infos[j];
161 // Set the text of the item.
162 string szAnsi = (string)p_info->psz_name;
164 szAnsi += p_info->psz_value;
165 tvi.pszText = _FROMMB( szAnsi.c_str() );
166 tvi.cchTextMax = _tcslen( tvi.pszText );
167 tvi.lParam = (LPARAM)3; // level 3
169 tvins.hInsertAfter = hPrev;
170 tvins.hParent = hPrevLev2Item;
172 // Add the item to the tree-view control.
173 hPrev = (HTREEITEM)TreeView_InsertItem( hwnd, &tvins );
176 TreeView_Expand( hwnd, hPrevLev2Item, TVE_EXPANDPARTIAL |TVE_EXPAND );
178 vlc_mutex_unlock( &p_input->input.p_item->lock );
180 TreeView_Expand( hwnd, hPrevRootItem, TVE_EXPANDPARTIAL |TVE_EXPAND );
185 /***********************************************************************
191 Processes messages sent to the main window.
193 ***********************************************************************/
194 LRESULT FileInfo::WndProc( HWND hwnd, UINT msg, WPARAM wp, LPARAM lp,
199 LRESULT lResult = CBaseWindow::WndProc( hwnd, msg, wp, lp, pbProcessed );
200 BOOL bWasProcessed = *pbProcessed;
206 shidi.dwMask = SHIDIM_FLAGS;
207 shidi.dwFlags = SHIDIF_DONEBUTTON | SHIDIF_SIPDOWN |
208 SHIDIF_FULLSCREENNOMENUBAR;//SHIDIF_SIZEDLGFULLSCREEN;
210 SHInitDialog( &shidi );
211 CreateTreeView( hwnd );
212 UpdateWindow( hwnd );
213 SHFullScreen( GetForegroundWindow(), SHFS_HIDESIPBUTTON );
217 if ( LOWORD(wp) == IDOK )
219 EndDialog( hwnd, LOWORD( wp ) );
222 *pbProcessed = bWasProcessed;
227 // the message was not processed
228 // indicate if the base class handled it
229 *pbProcessed = bWasProcessed;