📄 preferences_widgets.cpp
字号:
/***************************************************************************** * preferences_widgets.cpp : WinCE gui plugin for VLC ***************************************************************************** * Copyright (C) 2000-2004 the VideoLAN team * $Id: preferences_widgets.cpp 13905 2006-01-12 23:10:04Z dionoea $ * * Authors: Marodon Cedric <cedric_marodon@yahoo.fr> * Gildas Bazin <gbazin@videolan.org> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. *****************************************************************************//***************************************************************************** * Preamble *****************************************************************************/#include <stdlib.h> /* malloc(), free() */#include <string.h> /* strerror() */#include <stdio.h>#include <vlc/vlc.h>#include <vlc/intf.h>#include "wince.h"#include <windows.h>#include <windowsx.h>#include <winuser.h>#include <commctrl.h>#include "preferences_widgets.h"/***************************************************************************** * CreateConfigControl wrapper *****************************************************************************/ConfigControl *CreateConfigControl( vlc_object_t *p_this, module_config_t *p_item, HWND parent, HINSTANCE hInst, int *py_pos ){ ConfigControl *p_control = NULL; if( p_item->psz_current ) { return NULL; } switch( p_item->i_type ) { case CONFIG_ITEM_MODULE: p_control = new ModuleConfigControl( p_this, p_item, parent, hInst, py_pos ); break; case CONFIG_ITEM_STRING: if( !p_item->i_list ) { p_control = new StringConfigControl( p_this, p_item, parent, hInst, py_pos ); } /*else { p_control = new StringListConfigControl( p_this, p_item, parent, hInst, py_pos ); }*/ break;/* case CONFIG_ITEM_FILE: case CONFIG_ITEM_DIRECTORY: p_control = new FileConfigControl( p_this, p_item, parent, hInst, py_pos ); break; case CONFIG_ITEM_INTEGER: if( p_item->i_list ) { p_control = new IntegerListConfigControl( p_this, p_item, parent, hInst, py_pos ); } else if( p_item->i_min != 0 || p_item->i_max != 0 ) { p_control = new RangedIntConfigControl( p_this, p_item, parent, hInst, py_pos ); } else { p_control = new IntegerConfigControl( p_this, p_item, parent, hInst, py_pos ); } break;*/ case CONFIG_ITEM_KEY: p_control = new KeyConfigControl( p_this, p_item, parent, hInst, py_pos ); break; case CONFIG_ITEM_FLOAT: p_control = new FloatConfigControl( p_this, p_item, parent, hInst, py_pos ); break; case CONFIG_ITEM_BOOL: p_control = new BoolConfigControl( p_this, p_item, parent, hInst, py_pos ); break; default: break; } return p_control;}/***************************************************************************** * ConfigControl implementation *****************************************************************************/ConfigControl::ConfigControl( vlc_object_t *_p_this, module_config_t *p_item, HWND parent, HINSTANCE hInst ) : p_this( _p_this ), pf_update_callback( NULL ), p_update_data( NULL ), parent( parent ), name( p_item->psz_name ), i_type( p_item->i_type ), b_advanced( p_item->b_advanced ){ /*sizer = new wxBoxSizer( wxHORIZONTAL );*/}ConfigControl::~ConfigControl(){}/*wxSizer *ConfigControl::Sizer(){ return sizer;}*/char *ConfigControl::GetName(){ return name;}int ConfigControl::GetType(){ return i_type;}vlc_bool_t ConfigControl::IsAdvanced(){ return b_advanced;}void ConfigControl::SetUpdateCallback( void (*p_callback)( void * ), void *p_data ){ pf_update_callback = p_callback; p_update_data = p_data;}void ConfigControl::OnUpdate( UINT event ){ if( pf_update_callback ) { pf_update_callback( p_update_data ); }}/***************************************************************************** * KeyConfigControl implementation *****************************************************************************/string *KeyConfigControl::m_keysList = NULL;KeyConfigControl::KeyConfigControl( vlc_object_t *p_this, module_config_t *p_item, HWND parent, HINSTANCE hInst, int * py_pos ) : ConfigControl( p_this, p_item, parent, hInst ){ // Number of keys descriptions unsigned int i_keys = sizeof(vlc_keys)/sizeof(key_descriptor_t); // Init the keys decriptions array if( m_keysList == NULL ) { m_keysList = new string[i_keys]; for( unsigned int i = 0; i < i_keys; i++ ) { m_keysList[i] = vlc_keys[i].psz_key_string; } } label = CreateWindow( _T("STATIC"), _FROMMB(p_item->psz_text), WS_CHILD | WS_VISIBLE | SS_LEFT, 5, *py_pos, 200, 15, parent, NULL, hInst, NULL ); *py_pos += 15 + 10; alt = CreateWindow( _T("BUTTON"), _T("Alt"), WS_CHILD | WS_VISIBLE | BS_AUTOCHECKBOX, 20, *py_pos, 15, 15, parent, NULL, hInst, NULL ); Button_SetCheck( alt, p_item->i_value & KEY_MODIFIER_ALT ? BST_CHECKED : BST_UNCHECKED ); alt_label = CreateWindow( _T("STATIC"), _T("Alt"), WS_CHILD | WS_VISIBLE | SS_LEFT, 20 + 15 + 5, *py_pos, 30, 15, parent, NULL, hInst, NULL ); ctrl = CreateWindow( _T("BUTTON"), _T("Ctrl"), WS_CHILD | WS_VISIBLE | BS_AUTOCHECKBOX, 20 + 15 + 5 + 30 + 5, *py_pos, 15, 15, parent, NULL, hInst, NULL ); Button_SetCheck( ctrl, p_item->i_value & KEY_MODIFIER_CTRL ? BST_CHECKED : BST_UNCHECKED ); ctrl_label = CreateWindow( _T("STATIC"), _T("Ctrl"), WS_CHILD | WS_VISIBLE | SS_LEFT, 20 + 15 + 5 + 30 + 5 + 15 + 5, *py_pos, 30, 15, parent, NULL, hInst, NULL ); shift = CreateWindow( _T("BUTTON"), _T("Shift"), WS_CHILD | WS_VISIBLE | BS_AUTOCHECKBOX, 20 + 15 + 5 + 2*(30 + 5) + 15 + 5, *py_pos, 15, 15, parent, NULL, hInst, NULL ); Button_SetCheck( shift, p_item->i_value & KEY_MODIFIER_SHIFT ? BST_CHECKED : BST_UNCHECKED ); shift_label = CreateWindow( _T("STATIC"), _T("Shift"), WS_CHILD | WS_VISIBLE | SS_LEFT, 20 + 15 + 5 + 2*(30 + 5) + 2*(15 + 5), *py_pos, 30, 15, parent, NULL, hInst, NULL ); *py_pos += 15 + 10; combo = CreateWindow( _T("COMBOBOX"), _T(""), WS_CHILD | WS_VISIBLE | CBS_AUTOHSCROLL | CBS_DROPDOWNLIST | CBS_SORT | WS_VSCROLL, 20, *py_pos, 130, 5*15 + 6, parent, NULL, hInst, NULL ); *py_pos += 15 + 10; for( unsigned int i = 0; i < i_keys ; i++ ) { ComboBox_AddString( combo, _FROMMB(m_keysList[i].c_str()) ); ComboBox_SetItemData( combo, i, (void*)vlc_keys[i].i_key_code ); if( (unsigned int)vlc_keys[i].i_key_code == ( ((unsigned int)p_item->i_value) & ~KEY_MODIFIER ) ) { ComboBox_SetCurSel( combo, i ); ComboBox_SetText( combo, _FROMMB(m_keysList[i].c_str()) ); } }}KeyConfigControl::~KeyConfigControl(){ if( m_keysList ) { delete[] m_keysList; m_keysList = NULL; }}int KeyConfigControl::GetIntValue(){ int result = 0; if( Button_GetCheck( alt ) ) { result |= KEY_MODIFIER_ALT; } if( Button_GetCheck( ctrl ) ) { result |= KEY_MODIFIER_CTRL; } if( Button_GetCheck( shift ) ) { result |= KEY_MODIFIER_SHIFT; } int selected = ComboBox_GetCurSel( combo ); if( selected != -1 ) { result |= (int)ComboBox_GetItemData( combo, selected ); } return result;}/***************************************************************************** * ModuleConfigControl implementation *****************************************************************************/ModuleConfigControl::ModuleConfigControl( vlc_object_t *p_this, module_config_t *p_item, HWND parent, HINSTANCE hInst, int * py_pos ) : ConfigControl( p_this, p_item, parent, hInst ){ vlc_list_t *p_list; module_t *p_parser; label = CreateWindow( _T("STATIC"), _FROMMB(p_item->psz_text), WS_CHILD | WS_VISIBLE | SS_LEFT, 5, *py_pos, 200, 15, parent, NULL, hInst, NULL ); *py_pos += 15 + 10; combo = CreateWindow( _T("COMBOBOX"), _T(""), WS_CHILD | WS_VISIBLE | CBS_AUTOHSCROLL | CBS_DROPDOWNLIST | CBS_SORT | WS_VSCROLL, 20, *py_pos, 180, 5*15 + 6, parent, NULL, hInst, NULL); *py_pos += 15 + 10; /* build a list of available modules */ p_list = vlc_list_find( p_this, VLC_OBJECT_MODULE, FIND_ANYWHERE ); ComboBox_AddString( combo, _T("Default") ); ComboBox_SetItemData( combo, 0, (void *)NULL ); ComboBox_SetCurSel( combo, 0 ); //ComboBox_SetText( combo, _T("Default") ); for( int i_index = 0; i_index < p_list->i_count; i_index++ ) { p_parser = (module_t *)p_list->p_values[i_index].p_object ; if( !strcmp( p_parser->psz_capability, p_item->psz_type ) ) { ComboBox_AddString( combo, _FROMMB(p_parser->psz_longname) ); ComboBox_SetItemData( combo, i_index, (void*)p_parser->psz_object_name ); if( p_item->psz_value && !strcmp(p_item->psz_value, p_parser->psz_object_name) ) { ComboBox_SetCurSel( combo, i_index ); //ComboBox_SetText( combo, _FROMMB(p_parser->psz_longname) ); } } } vlc_list_release( p_list );}ModuleConfigControl::~ModuleConfigControl(){ ;}char *ModuleConfigControl::GetPszValue(){ int selected = ComboBox_GetCurSel( combo ); if( selected != -1 ) return (char *)ComboBox_GetItemData( combo, selected ); else return NULL;}/***************************************************************************** * StringConfigControl implementation *****************************************************************************/StringConfigControl::StringConfigControl( vlc_object_t *p_this, module_config_t *p_item, HWND parent, HINSTANCE hInst, int * py_pos ) : ConfigControl( p_this, p_item, parent, hInst ){ label = CreateWindow( _T("STATIC"), _FROMMB(p_item->psz_text), WS_CHILD | WS_VISIBLE | SS_LEFT, 5, *py_pos, 200, 15, parent, NULL, hInst, NULL ); *py_pos += 15 + 10; textctrl = CreateWindow( _T("EDIT"), p_item->psz_value ? _FROMMB(p_item->psz_value) : _T(""), WS_CHILD | WS_VISIBLE | WS_BORDER | SS_LEFT | ES_AUTOHSCROLL, 20, *py_pos - 3, 180, 15 + 3, parent, NULL, hInst, NULL ); *py_pos += 15 + 10;}StringConfigControl::~StringConfigControl(){ ;}char *StringConfigControl::GetPszValue(){ int i_size; char *psz_result; TCHAR *psz_string; i_size = Edit_GetTextLength( textctrl ); psz_string = (TCHAR *)malloc( (i_size + 1) * sizeof(TCHAR) ); Edit_GetText( textctrl, psz_string, i_size + 1 ); psz_result = strdup( _TOMB(psz_string) ); free( psz_string ); return psz_result;}#if 0/***************************************************************************** * StringListConfigControl implementation *****************************************************************************/StringListConfigControl::StringListConfigControl( vlc_object_t *p_this, module_config_t *p_item, HWND parent, HINSTANCE hInst, int * py_pos )
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -