00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028 #include <stdlib.h>
00029 #include <string.h>
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
00044
00045
00046
00047
00048
00049 ItemInfoDialog::ItemInfoDialog( intf_thread_t *p_intf, CBaseWindow *p_parent,
00050 HINSTANCE h_inst,
00051 playlist_item_t *_p_item )
00052 : CBaseWindow( p_intf, p_parent, h_inst )
00053 {
00054
00055 p_item = _p_item;
00056 }
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067 LRESULT ItemInfoDialog::WndProc( HWND hwnd, UINT msg, WPARAM wp, LPARAM lp )
00068 {
00069 SHINITDLGINFO shidi;
00070 SHMENUBARINFO mbi;
00071 INITCOMMONCONTROLSEX iccex;
00072 RECT rcClient;
00073
00074 switch( msg )
00075 {
00076 case WM_INITDIALOG:
00077 shidi.dwMask = SHIDIM_FLAGS;
00078 shidi.dwFlags = SHIDIF_DONEBUTTON | SHIDIF_SIPDOWN |
00079 SHIDIF_FULLSCREENNOMENUBAR;
00080 shidi.hDlg = hwnd;
00081 SHInitDialog( &shidi );
00082
00083
00084 memset( &mbi, 0, sizeof (SHMENUBARINFO) );
00085 mbi.cbSize = sizeof (SHMENUBARINFO);
00086 mbi.hwndParent = hwnd;
00087 mbi.dwFlags = SHCMBF_EMPTYBAR;
00088 mbi.hInstRes = hInst;
00089
00090 if( !SHCreateMenuBar(&mbi) )
00091 {
00092 MessageBox( hwnd, _T("SHCreateMenuBar Failed"), _T("Error"), MB_OK );
00093
00094 }
00095
00096 hwndCB = mbi.hwndMB;
00097
00098
00099 GetClientRect( hwnd, &rcClient );
00100
00101
00102 uri_label = CreateWindow( _T("STATIC"), _T("URI:"),
00103 WS_CHILD | WS_VISIBLE | SS_RIGHT,
00104 0, 10, 60, 15, hwnd, NULL, hInst, NULL);
00105
00106 uri_text = CreateWindow( _T("EDIT"), _FROMMB(p_item->input.psz_uri),
00107 WS_CHILD | WS_VISIBLE | WS_BORDER | SS_LEFT | ES_AUTOHSCROLL,
00108 70, 10 - 3, rcClient.right - 70 - 10, 15 + 6, hwnd, 0, hInst, 0 );
00109
00110
00111 name_label = CreateWindow( _T("STATIC"), _T("Name:"),
00112 WS_CHILD | WS_VISIBLE | SS_RIGHT ,
00113 0, 10 + 15 + 10, 60, 15,
00114 hwnd, NULL, hInst, NULL);
00115
00116 name_text = CreateWindow( _T("EDIT"),
00117 _FROMMB(p_item->input.psz_name),
00118 WS_CHILD | WS_VISIBLE | WS_BORDER | SS_LEFT | ES_AUTOHSCROLL,
00119 70, 10 + 15 + 10 - 3, rcClient.right - 70 - 10, 15 + 6,
00120 hwnd, NULL, hInst, NULL);
00121
00122
00123 checkbox_label = CreateWindow( _T("STATIC"), _T("Item Enabled:"),
00124 WS_CHILD | WS_VISIBLE | SS_RIGHT ,
00125 rcClient.right - 15 - 10 - 90 - 10, 10 + 4*( 15 + 10 ) + 5, 90, 15,
00126 hwnd, NULL, hInst, NULL );
00127
00128 enabled_checkbox = CreateWindow( _T("BUTTON"), _T("Item Enabled"),
00129 WS_CHILD | WS_VISIBLE | BS_AUTOCHECKBOX,
00130 rcClient.right - 15 - 10, 10 + 4*( 15 + 10 ) + 5, 15, 15,
00131 hwnd, NULL, hInst, NULL );
00132
00133 SendMessage( enabled_checkbox, BM_SETCHECK,
00134 p_item->b_enabled ? BST_CHECKED : BST_UNCHECKED, 0 );
00135
00136
00137 iccex.dwSize = sizeof( INITCOMMONCONTROLSEX );
00138 iccex.dwICC = ICC_TREEVIEW_CLASSES;
00139 InitCommonControlsEx( &iccex );
00140
00141
00142 info_tree = CreateWindowEx( 0, WC_TREEVIEW, NULL,
00143 WS_VISIBLE | WS_CHILD | WS_BORDER | TVS_HASLINES |
00144 TVS_LINESATROOT | TVS_HASBUTTONS,
00145 0, rcClient.bottom/2, rcClient.right,
00146 rcClient.bottom - rcClient.bottom/2 - MENU_HEIGHT + 2,
00147 hwnd, NULL, hInst, NULL );
00148
00149 UpdateInfo();
00150 break;
00151
00152 case WM_CLOSE:
00153 EndDialog( hwnd, LOWORD( wp ) );
00154 break;
00155
00156 case WM_SETFOCUS:
00157 SHSipPreference( hwnd, SIP_DOWN );
00158 SHFullScreen( hwnd, SHFS_HIDESIPBUTTON );
00159 break;
00160
00161 case WM_COMMAND:
00162 if( LOWORD(wp) == IDOK )
00163 {
00164 OnOk();
00165 EndDialog( hwnd, LOWORD( wp ) );
00166 }
00167 break;
00168
00169 default:
00170 break;
00171 }
00172
00173 return FALSE;
00174 }
00175
00176
00177
00178
00179 void ItemInfoDialog::UpdateInfo()
00180 {
00181 TVITEM tvi = {0};
00182 TVINSERTSTRUCT tvins = {0};
00183 HTREEITEM hPrev = (HTREEITEM)TVI_FIRST;
00184 HTREEITEM hPrevRootItem = NULL;
00185 HTREEITEM hPrevLev2Item = NULL;
00186
00187 tvi.mask = TVIF_TEXT | TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_PARAM;
00188
00189
00190 tvi.pszText = _FROMMB(p_item->input.psz_name);
00191 tvi.cchTextMax = _tcslen(tvi.pszText);
00192
00193
00194 tvi.lParam = (LPARAM)1;
00195 tvins.item = tvi;
00196 tvins.hInsertAfter = hPrev;
00197 tvins.hParent = TVI_ROOT;
00198
00199
00200 hPrev = (HTREEITEM)TreeView_InsertItem( info_tree, &tvins );
00201 hPrevRootItem = hPrev;
00202
00203
00204 vlc_mutex_lock( &p_item->input.lock );
00205 for( int i = 0; i < p_item->input.i_categories; i++ )
00206 {
00207 info_category_t *p_cat = p_item->input.pp_categories[i];
00208
00209
00210 tvi.pszText = _FROMMB( p_item->input.psz_name );
00211 tvi.cchTextMax = _tcslen( tvi.pszText );
00212
00213
00214 tvi.lParam = (LPARAM)2;
00215 tvins.item = tvi;
00216 tvins.hInsertAfter = hPrev;
00217 tvins.hParent = hPrevRootItem;
00218
00219
00220 hPrev = (HTREEITEM)TreeView_InsertItem( info_tree, &tvins );
00221
00222 hPrevLev2Item = hPrev;
00223
00224 for( int j = 0; j < p_cat->i_infos; j++ )
00225 {
00226 info_t *p_info = p_cat->pp_infos[j];
00227
00228
00229 string szAnsi = (string)p_info->psz_name;
00230 szAnsi += ": ";
00231 szAnsi += p_info->psz_value;
00232 tvi.pszText = (TCHAR *)_FROMMB( szAnsi.c_str() );
00233 tvi.cchTextMax = _tcslen( tvi.pszText );
00234 tvi.lParam = (LPARAM)3;
00235 tvins.item = tvi;
00236 tvins.hInsertAfter = hPrev;
00237 tvins.hParent = hPrevLev2Item;
00238
00239
00240 hPrev = (HTREEITEM)TreeView_InsertItem( info_tree, &tvins );
00241 }
00242
00243 TreeView_Expand( info_tree, hPrevLev2Item,
00244 TVE_EXPANDPARTIAL |TVE_EXPAND );
00245 }
00246 vlc_mutex_unlock( &p_item->input.lock );
00247
00248 TreeView_Expand( info_tree, hPrevRootItem, TVE_EXPANDPARTIAL |TVE_EXPAND );
00249 }
00250
00251
00252
00253
00254 void ItemInfoDialog::OnOk()
00255 {
00256 int b_state = VLC_FALSE;
00257
00258 vlc_mutex_lock( &p_item->input.lock );
00259
00260 TCHAR psz_name[MAX_PATH];
00261 Edit_GetText( name_text, psz_name, MAX_PATH );
00262 if( p_item->input.psz_name ) free( p_item->input.psz_name );
00263 p_item->input.psz_name = strdup( _TOMB(psz_name) );
00264
00265 TCHAR psz_uri[MAX_PATH];
00266 Edit_GetText( uri_text, psz_uri, MAX_PATH );
00267 if( p_item->input.psz_uri ) free( p_item->input.psz_uri );
00268 p_item->input.psz_uri = strdup( _TOMB(psz_uri) );
00269
00270 vlc_bool_t b_old_enabled = p_item->b_enabled;
00271
00272 playlist_t * p_playlist = (playlist_t *)
00273 vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST, FIND_ANYWHERE );
00274 if( p_playlist != NULL )
00275 {
00276 b_state = SendMessage( enabled_checkbox, BM_GETCHECK, 0, 0 );
00277 if( b_old_enabled == VLC_FALSE && (b_state & BST_CHECKED) )
00278 p_playlist->i_enabled ++;
00279 else if( b_old_enabled == VLC_TRUE && (b_state & BST_UNCHECKED) )
00280 p_playlist->i_enabled --;
00281
00282 vlc_object_release( p_playlist );
00283 }
00284
00285 p_item->b_enabled = (b_state & BST_CHECKED) ? VLC_TRUE : VLC_FALSE ;
00286
00287 vlc_mutex_unlock( &p_item->input.lock );
00288 }