Main Page | Modules | Class Hierarchy | Class List | Directories | File List | Class Members | File Members | Related Pages

fileinfo.cpp

00001 /*****************************************************************************
00002  * fileinfo.cpp : WinCE gui plugin for vlc
00003  *****************************************************************************
00004  * Copyright (C) 2000-2004 the VideoLAN team
00005  * $Id: fileinfo.cpp 11664 2005-07-09 06:17:09Z courmisch $
00006  *
00007  * Authors: Marodon Cedric <[email protected]>
00008  *          Gildas Bazin <[email protected]>
00009  *
00010  * This program is free software; you can redistribute it and/or modify
00011  * it under the terms of the GNU General Public License as published by
00012  * the Free Software Foundation; either version 2 of the License, or
00013  * (at your option) any later version.
00014  *
00015  * This program is distributed in the hope that it will be useful,
00016  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00017  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00018  * GNU General Public License for more details.
00019  *
00020  * You should have received a copy of the GNU General Public License
00021  * along with this program; if not, write to the Free Software
00022  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
00023  *****************************************************************************/
00024 
00025 /*****************************************************************************
00026  * Preamble
00027  *****************************************************************************/
00028 #include <stdlib.h>                                      /* malloc(), free() */
00029 #include <string.h>                                            /* strerror() */
00030 #include <stdio.h>
00031 #include <vlc/vlc.h>
00032 #include <vlc/intf.h>
00033 
00034 #include "wince.h"
00035 
00036 #include <winuser.h>
00037 #include <windows.h>
00038 #include <windowsx.h>
00039 #include <commctrl.h>
00040 #include <commdlg.h>
00041 
00042 /*****************************************************************************
00043  * Constructor.
00044  *****************************************************************************/
00045 FileInfo::FileInfo( intf_thread_t *p_intf, CBaseWindow *p_parent,
00046                     HINSTANCE h_inst )
00047   :  CBaseWindow( p_intf, p_parent, h_inst )
00048 {
00049     /* Initializations */
00050     hwnd_fileinfo = hwndTV = NULL;
00051 }
00052 
00053 /***********************************************************************
00054 
00055 FUNCTION: 
00056   CreateTreeView
00057 
00058 PURPOSE: 
00059   Registers the TreeView control class and creates a TreeView.
00060 
00061 ***********************************************************************/
00062 BOOL FileInfo::CreateTreeView(HWND hwnd)
00063 {
00064     DWORD dwStyle;
00065     RECT rect;
00066 
00067     INITCOMMONCONTROLSEX iccex;
00068     iccex.dwSize = sizeof( INITCOMMONCONTROLSEX );
00069     iccex.dwICC = ICC_TREEVIEW_CLASSES;
00070 
00071     // Registers Statusbar control classes from the common control dll
00072     InitCommonControlsEx( &iccex );
00073 
00074     // Get the coordinates of the parent window's client area
00075     GetClientRect( hwnd, &rect );
00076 
00077     // Assign the window styles for the tree view.
00078     dwStyle = WS_VISIBLE | WS_CHILD | TVS_HASLINES | TVS_LINESATROOT | 
00079                           TVS_HASBUTTONS;
00080 
00081     // Create the tree-view control.
00082     hwndTV = CreateWindowEx( 0, WC_TREEVIEW, NULL, dwStyle, 0, MENU_HEIGHT,
00083                              rect.right-rect.left,
00084                              rect.bottom-rect.top-MENU_HEIGHT,
00085                              hwnd, NULL, hInst, NULL );
00086 
00087     // Be sure that the tree view actually was created.
00088     if( !hwndTV ) return FALSE;
00089 
00090     UpdateFileInfo();
00091 
00092     return TRUE;
00093 }
00094 
00095 /***********************************************************************
00096 
00097 FUNCTION: 
00098   UpdateFileInfo
00099 
00100 PURPOSE: 
00101   Update the TreeView with file information.
00102 
00103 ***********************************************************************/
00104 void FileInfo::UpdateFileInfo()
00105 {
00106     TVITEM tvi = {0}; 
00107     TVINSERTSTRUCT tvins = {0}; 
00108     HTREEITEM hPrev = (HTREEITEM)TVI_FIRST; 
00109     HTREEITEM hPrevRootItem = NULL; 
00110     HTREEITEM hPrevLev2Item = NULL; 
00111 
00112     p_intf->p_sys->p_input = (input_thread_t *)
00113         vlc_object_find( p_intf, VLC_OBJECT_INPUT, FIND_ANYWHERE );
00114 
00115     input_thread_t *p_input = p_intf->p_sys->p_input;
00116 
00117     if( !p_input ) return;
00118 
00119     tvi.mask = TVIF_TEXT | TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_PARAM; 
00120 
00121     // Set the text of the item.
00122     tvi.pszText = _FROMMB( p_input->input.p_item->psz_name );
00123     tvi.cchTextMax = _tcslen( tvi.pszText );
00124 
00125     // Save the heading level in the item's application-defined data area
00126     tvi.lParam = (LPARAM)1;
00127     tvins.item = tvi; 
00128     //tvins.hInsertAfter = TVI_LAST;
00129     tvins.hInsertAfter = hPrev; 
00130     tvins.hParent = TVI_ROOT; 
00131 
00132     // Add the item to the tree-view control. 
00133     hPrev = (HTREEITEM)TreeView_InsertItem( hwndTV, &tvins );
00134 
00135     hPrevRootItem = hPrev; 
00136 
00137     vlc_mutex_lock( &p_input->input.p_item->lock );
00138     for( int i = 0; i < p_input->input.p_item->i_categories; i++ )
00139     {
00140         info_category_t *p_cat = p_input->input.p_item->pp_categories[i];
00141 
00142         // Set the text of the item. 
00143         tvi.pszText = _FROMMB( p_input->input.p_item->psz_name );
00144         tvi.cchTextMax = _tcslen( tvi.pszText );
00145         
00146         // Save the heading level in the item's application-defined data area
00147         tvi.lParam = (LPARAM)2; // level 2
00148         tvins.item = tvi; 
00149         tvins.hInsertAfter = hPrev; 
00150         tvins.hParent = hPrevRootItem;
00151 
00152         // Add the item to the tree-view control. 
00153         hPrev = (HTREEITEM)TreeView_InsertItem( hwndTV, &tvins );
00154 
00155         hPrevLev2Item = hPrev;
00156 
00157         for( int j = 0; j < p_cat->i_infos; j++ )
00158         {
00159             info_t *p_info = p_cat->pp_infos[j];
00160 
00161             // Set the text of the item. 
00162             string szAnsi = (string)p_info->psz_name;
00163             szAnsi += ": ";
00164             szAnsi += p_info->psz_value;
00165             tvi.pszText = (TCHAR *)_FROMMB( szAnsi.c_str() );
00166             tvi.cchTextMax = _tcslen( tvi.pszText );
00167             tvi.lParam = (LPARAM)3; // level 3
00168             tvins.item = tvi; 
00169             tvins.hInsertAfter = hPrev; 
00170             tvins.hParent = hPrevLev2Item;
00171     
00172             // Add the item to the tree-view control. 
00173             hPrev = (HTREEITEM)TreeView_InsertItem( hwndTV, &tvins );
00174         }
00175 
00176         TreeView_Expand( hwndTV, hPrevLev2Item, TVE_EXPANDPARTIAL|TVE_EXPAND );
00177     }
00178     vlc_mutex_unlock( &p_input->input.p_item->lock );
00179 
00180     TreeView_Expand( hwndTV, hPrevRootItem, TVE_EXPANDPARTIAL|TVE_EXPAND );
00181 
00182     return;
00183 }
00184 
00185 /***********************************************************************
00186 
00187 FUNCTION: 
00188   WndProc
00189 
00190 PURPOSE: 
00191   Processes messages sent to the main window.
00192   
00193 ***********************************************************************/
00194 LRESULT FileInfo::WndProc( HWND hwnd, UINT msg, WPARAM wp, LPARAM lp )
00195 {
00196     SHINITDLGINFO shidi;
00197 
00198     switch( msg )
00199     {
00200     case WM_INITDIALOG: 
00201         shidi.dwMask = SHIDIM_FLAGS;
00202         shidi.dwFlags = SHIDIF_DONEBUTTON | SHIDIF_SIPDOWN |
00203             SHIDIF_FULLSCREENNOMENUBAR;//SHIDIF_SIZEDLGFULLSCREEN;
00204         shidi.hDlg = hwnd;
00205         SHInitDialog( &shidi );
00206         CreateTreeView( hwnd );
00207         UpdateWindow( hwnd );
00208         SHFullScreen( GetForegroundWindow(), SHFS_HIDESIPBUTTON );
00209         break;
00210 
00211     case WM_CLOSE:
00212         EndDialog( hwnd, LOWORD( wp ) );
00213         break;
00214 
00215     case WM_SETFOCUS:
00216         SHSipPreference( hwnd, SIP_DOWN ); 
00217         SHFullScreen( hwnd, SHFS_HIDESIPBUTTON );
00218         break;
00219 
00220     case WM_COMMAND:
00221         if ( LOWORD(wp) == IDOK )
00222         {
00223             EndDialog( hwnd, LOWORD( wp ) );
00224         }
00225         break;
00226 
00227     default:
00228         break;
00229     }
00230 
00231     return FALSE;
00232 }

Generated on Tue Dec 20 10:14:44 2005 for vlc-0.8.4a by  doxygen 1.4.2