⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 preferences.cpp

📁 VLC Player Source Code
💻 CPP
📖 第 1 页 / 共 2 页
字号:
/***************************************************************************** * preferences.cpp : WinCE gui plugin for VLC ***************************************************************************** * Copyright (C) 2000-2004 the VideoLAN team * $Id: 3905575d03455451516d9b1bb66fb96d4fe9c8b3 $ * * 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 *****************************************************************************/#ifdef HAVE_CONFIG_H# include "config.h"#endif#include <vlc_common.h>#include <vlc_interface.h>#include "wince.h"#include <winuser.h>#include <windows.h>#include <windowsx.h>#include <commctrl.h>#include <commdlg.h>#include <vlc_config_cat.h>#include "preferences_widgets.h"#define GENERAL_ID 1242#define PLUGIN_ID 1243#define CAPABILITY_ID 1244/***************************************************************************** * Event Table. *****************************************************************************//* IDs for the controls and the menu commands */enum{    Notebook_Event,    MRL_Event,    ResetAll_Event,    Advanced_Event};/***************************************************************************** * Classes declarations. *****************************************************************************/class ConfigTreeData;class PrefsTreeCtrl{public:    PrefsTreeCtrl() { }    PrefsTreeCtrl( intf_thread_t *_p_intf, PrefsDialog *p_prefs_dialog,                   HWND hwnd, HINSTANCE _hInst );    virtual ~PrefsTreeCtrl();    void ApplyChanges();    /*void CleanChanges();*/    void OnSelectTreeItem( LPNM_TREEVIEW pnmtv, HWND parent, HINSTANCE hInst );     ConfigTreeData *FindModuleConfig( ConfigTreeData *config_data );    HWND hwndTV;private:    intf_thread_t *p_intf;    PrefsDialog *p_prefs_dialog;    bool b_advanced;    HTREEITEM general_item;    HTREEITEM plugins_item;};class PrefsPanel{public:    PrefsPanel() { }    PrefsPanel( HWND parent, HINSTANCE hInst, intf_thread_t *_p_intf,                PrefsDialog *, int i_object_id, char *, char * );    virtual ~PrefsPanel() {}    void Hide();    void Show();    HWND config_window;    int oldvalue;    int maxvalue;    void ApplyChanges();private:    intf_thread_t *p_intf;    PrefsDialog *p_prefs_dialog;    bool b_advanced;    HWND label;    vector<ConfigControl *> config_array;};class ConfigTreeData{public:    ConfigTreeData() { b_submodule = 0; panel = NULL; psz_section = NULL;                       psz_help = NULL; }    virtual ~ConfigTreeData() { delete panel;                                free( psz_section );                                free( psz_help ); }    bool b_submodule;    PrefsPanel *panel;    int i_object_id;    char *psz_section;    char *psz_help;};/***************************************************************************** * Constructor. *****************************************************************************/PrefsDialog::PrefsDialog( intf_thread_t *p_intf, CBaseWindow *p_parent,                          HINSTANCE h_inst )  :  CBaseWindow( p_intf, p_parent, h_inst ){    /* Initializations */    prefs_tree = NULL;}/***********************************************************************FUNCTION:  WndProcPURPOSE:  Processes messages sent to the main window.***********************************************************************/LRESULT PrefsDialog::WndProc( HWND hwnd, UINT msg, WPARAM wp, LPARAM lp ){    SHINITDLGINFO shidi;    SHMENUBARINFO mbi;    RECT rcClient;    switch( msg )    {    case WM_INITDIALOG:        shidi.dwMask = SHIDIM_FLAGS;        shidi.dwFlags = SHIDIF_DONEBUTTON | SHIDIF_SIPDOWN |            SHIDIF_FULLSCREENNOMENUBAR;//SHIDIF_SIZEDLGFULLSCREEN;        shidi.hDlg = hwnd;        SHInitDialog( &shidi );        //Create the menubar        memset( &mbi, 0, sizeof (SHMENUBARINFO) );        mbi.cbSize     = sizeof (SHMENUBARINFO);        mbi.hwndParent = hwnd;        mbi.dwFlags    = SHCMBF_EMPTYBAR;        mbi.hInstRes   = hInst;        if( !SHCreateMenuBar(&mbi) )        {            MessageBox(hwnd, _T("SHCreateMenuBar Failed"), _T("Error"), MB_OK);            //return -1;        }        hwndCB = mbi.hwndMB;        // Get the client area rect to put the panels in        GetClientRect(hwnd, &rcClient);        /* Create the buttons */        advanced_checkbox =            CreateWindow( _T("BUTTON"), _T("Advanced options"),                        WS_CHILD | WS_VISIBLE | BS_AUTOCHECKBOX,                        5, 10, 15, 15, hwnd, NULL, hInst, NULL );        SendMessage( advanced_checkbox, BM_SETCHECK, BST_UNCHECKED, 0 );        advanced_label = CreateWindow( _T("STATIC"), _T("Advanced options"),                        WS_CHILD | WS_VISIBLE | SS_LEFT,                        5 + 15 + 5, 10, 110, 15,                        hwnd, NULL, hInst, NULL);        if( config_GetInt( p_intf, "advanced" ) )        {            SendMessage( advanced_checkbox, BM_SETCHECK, BST_CHECKED, 0 );            /*dummy_event.SetInt(TRUE);              OnAdvanced( dummy_event );*/        }        reset_button = CreateWindow( _T("BUTTON"), _T("Reset All"),                        WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON,                        rcClient.right - 5 - 80, 10 - 3, 80, 15 + 6,                        hwnd, NULL, hInst, NULL );        /* Create the preferences tree control */        prefs_tree = new PrefsTreeCtrl( p_intf, this, hwnd, hInst );        UpdateWindow( hwnd );        break;    case WM_CLOSE:        EndDialog( hwnd, LOWORD( wp ) );        break;    case WM_SETFOCUS:        SHFullScreen( hwnd, SHFS_SHOWSIPBUTTON );        break;    case WM_COMMAND:        if( LOWORD(wp) == IDOK )        {            OnOk();            EndDialog( hwnd, LOWORD( wp ) );        }        break;    case WM_NOTIFY:        if( lp && prefs_tree &&            ((LPNMHDR)lp)->hwndFrom == prefs_tree->hwndTV &&            ((LPNMHDR)lp)->code == TVN_SELCHANGED )        {            prefs_tree->OnSelectTreeItem( (NM_TREEVIEW FAR *)(LPNMHDR)lp,                                          hwnd, hInst );        }        break;    case WM_VSCROLL:    {        TVITEM tvi = {0};        tvi.mask = TVIF_PARAM;        tvi.hItem = TreeView_GetSelection( prefs_tree->hwndTV );    if( !tvi.hItem ) break;        if( !TreeView_GetItem( prefs_tree->hwndTV, &tvi ) ) break;        ConfigTreeData *config_data =            prefs_tree->FindModuleConfig( (ConfigTreeData *)tvi.lParam );        if( config_data && hwnd == config_data->panel->config_window )        {            int dy;            RECT rc;            GetWindowRect( hwnd, &rc);            int newvalue = config_data->panel->oldvalue;            switch ( GET_WM_VSCROLL_CODE(wp,lp) )            {            case SB_BOTTOM       : newvalue = 0; break;            case SB_TOP          : newvalue = config_data->panel->maxvalue; break;            case SB_LINEDOWN     : newvalue += 10; break;            case SB_PAGEDOWN     : newvalue += rc.bottom - rc.top - 25; break; // wrong! one page is notebook actual length            case SB_LINEUP       : newvalue -= 10; break;            case SB_PAGEUP       : newvalue -= rc.bottom - rc.top - 25; break;            case SB_THUMBPOSITION:            case SB_THUMBTRACK   : newvalue = GET_WM_VSCROLL_POS(wp,lp); break;            }            newvalue = max(0,min(config_data->panel->maxvalue,newvalue));            SetScrollPos( hwnd,SB_VERT,newvalue,TRUE);//SB_CTL si hwnd=hwndScrollBar, SB_VERT si window            dy = config_data->panel->oldvalue - newvalue;            ScrollWindowEx( hwnd, 0, dy, NULL, NULL, NULL, NULL, SW_SCROLLCHILDREN );            UpdateWindow ( hwnd);            config_data->panel->oldvalue = newvalue;        }        break;    }    default:        break;    }    return FALSE;}/***************************************************************************** * Private methods. *****************************************************************************//***************************************************************************** * Events methods. *****************************************************************************/void PrefsDialog::OnOk( void ){    prefs_tree->ApplyChanges();    config_SaveConfigFile( p_intf, NULL );}/***************************************************************************** * PrefsTreeCtrl class definition. *****************************************************************************/PrefsTreeCtrl::PrefsTreeCtrl( intf_thread_t *_p_intf,                              PrefsDialog *_p_prefs_dialog, HWND hwnd,                              HINSTANCE hInst ){    vlc_list_t      *p_list;    module_t        *p_module;    module_config_t *p_item;    int i_index;    INITCOMMONCONTROLSEX iccex;    RECT rcClient;    TVITEM tvi = {0};    TVINSERTSTRUCT tvins = {0};    HTREEITEM hPrev;    size_t i_capability_count = 0;    size_t i_child_index;    HTREEITEM capability_item;    /* Initializations */    p_intf = _p_intf;    p_prefs_dialog = _p_prefs_dialog;    b_advanced = false;    /* Create a tree view */    // Initialize the INITCOMMONCONTROLSEX structure.    iccex.dwSize = sizeof( INITCOMMONCONTROLSEX );    iccex.dwICC = ICC_TREEVIEW_CLASSES;    // Registers Statusbar control classes from the common control dll    InitCommonControlsEx( &iccex );    // Get the client area rect to put the tv in    GetClientRect(hwnd, &rcClient);    // Create the tree-view control.    hwndTV = CreateWindowEx( 0, WC_TREEVIEW, NULL,        WS_VISIBLE | WS_CHILD | WS_BORDER | TVS_HASLINES |        TVS_LINESATROOT | TVS_HASBUTTONS,        5, 10 + 2*(15 + 10) + 105 + 5, rcClient.right - 5 - 5, 6*15,        hwnd, NULL, hInst, NULL );    tvi.mask = TVIF_TEXT | TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_PARAM;    /* List the plugins */    p_list = vlc_list_find( p_intf, VLC_OBJECT_MODULE, FIND_ANYWHERE );    if( !p_list ) return;    /*     * Build a tree of the main options     */    ConfigTreeData *config_data = new ConfigTreeData;    config_data->i_object_id = GENERAL_ID;    config_data->psz_help = strdup("nothing");//strdup( GENERAL_HELP );    config_data->psz_section = strdup( GENERAL_TITLE );    tvi.pszText = _T("General settings");    tvi.cchTextMax = lstrlen(_T("General settings"));    tvi.lParam = (long)config_data;    tvins.item = tvi;    tvins.hInsertAfter = TVI_FIRST;    tvins.hParent = TVI_ROOT;    // Add the item to the tree-view control.    hPrev = (HTREEITEM) TreeView_InsertItem( hwndTV, &tvins);    general_item = hPrev;    for( i_index = 0; i_index < p_list->i_count; i_index++ )    {        p_module = (module_t *)p_list->p_values[i_index].p_object;        if( !strcmp( p_module->psz_object_name, "main" ) )            break;    }    if( i_index < p_list->i_count )    {        /* We found the main module */        /* Enumerate config categories and store a reference so we can         * generate their config panel them when it is asked by the user. */        p_item = p_module->p_config;        if( p_item ) do        {            switch( p_item->i_type )            {            case CONFIG_HINT_CATEGORY:                ConfigTreeData *config_data = new ConfigTreeData;                config_data->psz_section = strdup( p_item->psz_text );                if( p_item->psz_longtext )                {                    config_data->psz_help =                        strdup( p_item->psz_longtext );                }                else                {                    config_data->psz_help = NULL;                }                config_data->i_object_id = p_module->i_object_id;                /* Add the category to the tree */                // Set the text of the item.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -