1 /*****************************************************************************
2 * iteminfo.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 *****************************************************************************/
46 /*****************************************************************************
48 *****************************************************************************/
49 ItemInfoDialog::ItemInfoDialog( intf_thread_t *_p_intf,
51 playlist_item_t *_p_item )
59 /***********************************************************************
65 Processes messages sent to the main window.
67 ***********************************************************************/
68 LRESULT ItemInfoDialog::WndProc( HWND hwnd, UINT msg, WPARAM wp, LPARAM lp,
73 INITCOMMONCONTROLSEX iccex;
76 LRESULT lResult = CBaseWindow::WndProc( hwnd, msg, wp, lp, pbProcessed );
77 BOOL bWasProcessed = *pbProcessed;
83 shidi.dwMask = SHIDIM_FLAGS;
84 shidi.dwFlags = SHIDIF_DONEBUTTON | SHIDIF_SIPDOWN |
85 SHIDIF_FULLSCREENNOMENUBAR;//SHIDIF_SIZEDLGFULLSCREEN;
87 SHInitDialog( &shidi );
90 memset( &mbi, 0, sizeof (SHMENUBARINFO) );
91 mbi.cbSize = sizeof (SHMENUBARINFO);
92 mbi.hwndParent = hwnd;
93 mbi.nToolBarId = IDR_DUMMYMENU;
98 if( !SHCreateMenuBar(&mbi) )
100 MessageBox( hwnd, _T("SHCreateMenuBar Failed"), _T("Error"), MB_OK );
106 // Get the client area rect to put the panels in
107 GetClientRect( hwnd, &rcClient );
110 uri_label = CreateWindow( _T("STATIC"), _T("URI:"),
111 WS_CHILD | WS_VISIBLE | SS_RIGHT,
112 0, 10, 60, 15, hwnd, NULL, hInst, NULL);
114 uri_text = CreateWindow( _T("EDIT"), _FROMMB(p_item->input.psz_uri),
115 WS_CHILD | WS_VISIBLE | WS_BORDER | SS_LEFT | ES_AUTOHSCROLL,
116 70, 10 - 3, rcClient.right - 70 - 10, 15 + 6, hwnd, 0, hInst, 0 );
119 name_label = CreateWindow( _T("STATIC"), _T("Name:"),
120 WS_CHILD | WS_VISIBLE | SS_RIGHT ,
121 0, 10 + 15 + 10, 60, 15,
122 hwnd, NULL, hInst, NULL);
124 name_text = CreateWindow( _T("EDIT"),
125 _FROMMB(p_item->input.psz_name),
126 WS_CHILD | WS_VISIBLE | WS_BORDER | SS_LEFT | ES_AUTOHSCROLL,
127 70, 10 + 15 + 10 - 3, rcClient.right - 70 - 10, 15 + 6,
128 hwnd, NULL, hInst, NULL);
131 checkbox_label = CreateWindow( _T("STATIC"), _T("Item Enabled:"),
132 WS_CHILD | WS_VISIBLE | SS_RIGHT ,
133 rcClient.right - 15 - 10 - 90 - 10, 10 + 4*( 15 + 10 ) + 5, 90, 15,
134 hwnd, NULL, hInst, NULL );
136 enabled_checkbox = CreateWindow( _T("BUTTON"), _T("Item Enabled"),
137 WS_CHILD | WS_VISIBLE | BS_AUTOCHECKBOX,
138 rcClient.right - 15 - 10, 10 + 4*( 15 + 10 ) + 5, 15, 15,
139 hwnd, NULL, hInst, NULL );
141 SendMessage( enabled_checkbox, BM_SETCHECK,
142 p_item->b_enabled ? BST_CHECKED : BST_UNCHECKED, 0 );
145 iccex.dwSize = sizeof( INITCOMMONCONTROLSEX );
146 iccex.dwICC = ICC_TREEVIEW_CLASSES;
147 InitCommonControlsEx( &iccex );
149 // Create the tree-view control.
150 info_tree = CreateWindowEx( 0, WC_TREEVIEW, NULL,
151 WS_VISIBLE | WS_CHILD | WS_BORDER | TVS_HASLINES |
152 TVS_LINESATROOT | TVS_HASBUTTONS,
153 0, rcClient.bottom/2, rcClient.right,
154 rcClient.bottom - rcClient.bottom/2 - MENU_HEIGHT + 2, // +2 to fix
155 hwnd, NULL, hInst, NULL );
161 if( LOWORD(wp) == IDOK )
164 EndDialog( hwnd, LOWORD( wp ) );
167 *pbProcessed = bWasProcessed;
172 // the message was not processed
173 // indicate if the base class handled it
174 *pbProcessed = bWasProcessed;
182 /*****************************************************************************
184 *****************************************************************************/
185 void ItemInfoDialog::UpdateInfo()
188 TVINSERTSTRUCT tvins = {0};
189 HTREEITEM hPrev = (HTREEITEM)TVI_FIRST;
190 HTREEITEM hPrevRootItem = NULL;
191 HTREEITEM hPrevLev2Item = NULL;
193 tvi.mask = TVIF_TEXT | TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_PARAM;
195 // Set the text of the item.
196 tvi.pszText = _FROMMB(p_item->input.psz_name);
197 tvi.cchTextMax = _tcslen(tvi.pszText);
199 // Save the heading level in the item's application-defined data area
200 tvi.lParam = (LPARAM)1; // root level
202 tvins.hInsertAfter = hPrev;
203 tvins.hParent = TVI_ROOT;
205 // Add the item to the tree-view control.
206 hPrev = (HTREEITEM)TreeView_InsertItem( info_tree, &tvins );
207 hPrevRootItem = hPrev;
209 /* Rebuild the tree */
210 vlc_mutex_lock( &p_item->input.lock );
211 for( int i = 0; i < p_item->input.i_categories; i++ )
213 info_category_t *p_cat = p_item->input.pp_categories[i];
215 // Set the text of the item.
216 tvi.pszText = _FROMMB( p_item->input.psz_name );
217 tvi.cchTextMax = _tcslen( tvi.pszText );
219 // Save the heading level in the item's application-defined data area
220 tvi.lParam = (LPARAM)2; // level 2
222 tvins.hInsertAfter = hPrev;
223 tvins.hParent = hPrevRootItem;
225 // Add the item to the tree-view control.
226 hPrev = (HTREEITEM)TreeView_InsertItem( info_tree, &tvins );
228 hPrevLev2Item = hPrev;
230 for( int j = 0; j < p_cat->i_infos; j++ )
232 info_t *p_info = p_cat->pp_infos[j];
234 // Set the text of the item.
235 string szAnsi = (string)p_info->psz_name;
237 szAnsi += p_info->psz_value;
238 tvi.pszText = (TCHAR *)_FROMMB( szAnsi.c_str() );
239 tvi.cchTextMax = _tcslen( tvi.pszText );
240 tvi.lParam = (LPARAM)3; // level 3
242 tvins.hInsertAfter = hPrev;
243 tvins.hParent = hPrevLev2Item;
245 // Add the item to the tree-view control.
246 hPrev = (HTREEITEM)TreeView_InsertItem( info_tree, &tvins );
249 TreeView_Expand( info_tree, hPrevLev2Item,
250 TVE_EXPANDPARTIAL |TVE_EXPAND );
252 vlc_mutex_unlock( &p_item->input.lock );
254 TreeView_Expand( info_tree, hPrevRootItem, TVE_EXPANDPARTIAL |TVE_EXPAND );
257 /*****************************************************************************
259 *****************************************************************************/
260 void ItemInfoDialog::OnOk()
262 int b_state = VLC_FALSE;
264 vlc_mutex_lock( &p_item->input.lock );
266 TCHAR psz_name[MAX_PATH];
267 Edit_GetText( name_text, psz_name, MAX_PATH );
268 if( p_item->input.psz_name ) free( p_item->input.psz_name );
269 p_item->input.psz_name = strdup( _TOMB(psz_name) );
271 TCHAR psz_uri[MAX_PATH];
272 Edit_GetText( uri_text, psz_uri, MAX_PATH );
273 if( p_item->input.psz_uri ) free( p_item->input.psz_uri );
274 p_item->input.psz_uri = strdup( _TOMB(psz_uri) );
276 vlc_bool_t b_old_enabled = p_item->b_enabled;
278 playlist_t * p_playlist = (playlist_t *)
279 vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST, FIND_ANYWHERE );
280 if( p_playlist != NULL )
282 b_state = SendMessage( enabled_checkbox, BM_GETCHECK, 0, 0 );
283 if( b_old_enabled == VLC_FALSE && (b_state & BST_CHECKED) )
284 p_playlist->i_enabled ++;
285 else if( b_old_enabled == VLC_TRUE && (b_state & BST_UNCHECKED) )
286 p_playlist->i_enabled --;
288 vlc_object_release( p_playlist );
291 p_item->b_enabled = (b_state & BST_CHECKED) ? VLC_TRUE : VLC_FALSE ;
293 vlc_mutex_unlock( &p_item->input.lock );