📄 wxwidgets.cpp
字号:
setlocale( LC_NUMERIC, "C" );}/* following functions are local *//***************************************************************************** * Constructors. *****************************************************************************/Instance::Instance( ){}Instance::Instance( intf_thread_t *_p_intf ){ /* Initialization */ p_intf = _p_intf;}IMPLEMENT_APP_NO_MAIN(Instance)/***************************************************************************** * Instance::OnInit: the parent interface execution starts here ***************************************************************************** * This is the "main program" equivalent, the program execution will * start here. *****************************************************************************/bool Instance::OnInit(){ /* Initialization of i18n stuff. * Usefull for things we don't have any control over, like wxWidgets * provided facilities (eg. open file dialog) */ locale.Init( wxLANGUAGE_DEFAULT, wxLOCALE_LOAD_DEFAULT ); setlocale( LC_NUMERIC, "C" ); /* Load saved window settings */ p_intf->p_sys->p_window_settings = new WindowSettings( p_intf ); /* Make an instance of your derived frame. Passing NULL (the default value * of Frame's constructor is NULL) as the frame doesn't have a parent * since it is the first window */ if( !p_intf->pf_show_dialog ) { /* The module is used in interface mode */ long style = wxDEFAULT_FRAME_STYLE; if ( ! config_GetInt( p_intf, "wx-taskbar" ) ) { style = wxDEFAULT_FRAME_STYLE|wxFRAME_NO_TASKBAR; } Interface *MainInterface = new Interface( p_intf, style ); p_intf->p_sys->p_wxwindow = MainInterface; /* Show the interface */ MainInterface->Show( TRUE ); SetTopWindow( MainInterface ); MainInterface->Raise(); } /* Creates the dialogs provider */ p_intf->p_sys->p_wxwindow = CreateDialogsProvider( p_intf, p_intf->pf_show_dialog ? NULL : p_intf->p_sys->p_wxwindow ); p_intf->p_sys->pf_show_dialog = ShowDialog; /* OK, initialization is over */ vlc_thread_ready( p_intf ); /* Check if we need to start playing */ if( !p_intf->pf_show_dialog && p_intf->b_play ) { playlist_t *p_playlist = (playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST, FIND_ANYWHERE ); if( p_playlist ) { playlist_LockControl( p_playlist, PLAYLIST_AUTOPLAY ); vlc_object_release( p_playlist ); } } /* Return TRUE to tell program to continue (FALSE would terminate) */ return TRUE;}/***************************************************************************** * Instance::OnExit: called when the interface execution stops *****************************************************************************/int Instance::OnExit(){ if( p_intf->pf_show_dialog ) { /* We need to manually clean up the dialogs class */ if( p_intf->p_sys->p_wxwindow ) delete p_intf->p_sys->p_wxwindow; }#if (wxCHECK_VERSION(2,5,0)) wxClassInfo_sm_classTable_BUGGY = wxClassInfo::sm_classTable; wxClassInfo::sm_classTable = 0;#endif return 0;}static void ShowDialog( intf_thread_t *p_intf, int i_dialog_event, int i_arg, intf_dialog_args_t *p_arg ){ wxCommandEvent event( wxEVT_DIALOG, i_dialog_event ); event.SetInt( i_arg ); event.SetClientData( p_arg );#ifdef WIN32 SendMessage( (HWND)p_intf->p_sys->p_wxwindow->GetHandle(), WM_CANCELMODE, 0, 0 );#endif if( i_dialog_event == INTF_DIALOG_POPUPMENU && i_arg == 0 ) return; /* Hack to prevent popup events to be enqueued when * one is already active */ if( i_dialog_event != INTF_DIALOG_POPUPMENU || !p_intf->p_sys->p_popup_menu ) { p_intf->p_sys->p_wxwindow->AddPendingEvent( event ); }}/***************************************************************************** * WindowSettings utility class *****************************************************************************/WindowSettings::WindowSettings( intf_thread_t *_p_intf ){ char *psz_org = NULL; char *psz; int i; /* */ p_intf = _p_intf; /* */ for( i = 0; i < ID_MAX; i++ ) { b_valid[i] = false; b_shown[i] = false; position[i] = wxDefaultPosition; size[i] = wxDefaultSize; } b_shown[ID_MAIN] = true; if( p_intf->pf_show_dialog ) return; /* Parse the configuration */ psz_org = psz = config_GetPsz( p_intf, "wx-config-last" ); if( !psz || *psz == '\0' ) return; msg_Dbg( p_intf, "Using last windows config '%s'", psz ); i_screen_w = 0; i_screen_h = 0; while( psz && *psz ) { int id, v[4]; psz = strchr( psz, '(' ); if( !psz ) break; psz++; id = strtol( psz, &psz, 0 ); if( *psz != ',' ) /* broken cfg */ { goto invalid; } psz++; for( i = 0; i < 4; i++ ) { v[i] = strtol( psz, &psz, 0 ); if( i < 3 ) { if( *psz != ',' ) { goto invalid; } psz++; } else { if( *psz != ')' ) { goto invalid; } } } if( id == ID_SCREEN ) { i_screen_w = v[2]; i_screen_h = v[3]; } else if( id >= 0 && id < ID_MAX ) { b_valid[id] = true; b_shown[id] = true; position[id] = wxPoint( v[0], v[1] ); size[id] = wxSize( v[2], v[3] ); msg_Dbg( p_intf, "id=%d p=(%d,%d) s=(%d,%d)", id, position[id].x, position[id].y, size[id].x, size[id].y ); } psz = strchr( psz, ')' ); if( psz ) psz++; } if( i_screen_w <= 0 || i_screen_h <= 0 ) { goto invalid; } for( i = 0; i < ID_MAX; i++ ) { if( !b_valid[i] ) continue; if( position[i].x < 0 || position[i].y < 0 ) { goto invalid; } if( i != ID_SMALL_PLAYLIST && (size[i].x <= 0 || size[i].y <= 0) ) { goto invalid; } } if( psz_org ) free( psz_org ); return;invalid: msg_Dbg( p_intf, "last windows config is invalid (ignored)" ); for( i = 0; i < ID_MAX; i++ ) { b_valid[i] = false; b_shown[i] = false; position[i] = wxDefaultPosition; size[i] = wxDefaultSize; } if( psz_org ) free( psz_org );}WindowSettings::~WindowSettings( ){ wxString sCfg; if( p_intf->pf_show_dialog ) return; sCfg = wxString::Format( wxT("(%d,0,0,%d,%d)"), ID_SCREEN, wxSystemSettings::GetMetric( wxSYS_SCREEN_X ), wxSystemSettings::GetMetric( wxSYS_SCREEN_Y ) ); for( int i = 0; i < ID_MAX; i++ ) { if( !b_valid[i] || !b_shown[i] ) continue; sCfg += wxString::Format( wxT("(%d,%d,%d,%d,%d)"), i, position[i].x, position[i].y, size[i].x, size[i].y ); } config_PutPsz( p_intf, "wx-config-last", sCfg.mb_str(wxConvUTF8) );}void WindowSettings::SetScreen( int i_screen_w, int i_screen_h ){ int i; for( i = 0; i < ID_MAX; i++ ) { if( !b_valid[i] ) continue; if( position[i].x >= i_screen_w || position[i].y >= i_screen_h ) goto invalid; } return;invalid: for( i = 0; i < ID_MAX; i++ ) { b_valid[i] = false; b_shown[i] = false; position[i] = wxDefaultPosition; size[i] = wxDefaultSize; }}void WindowSettings::SetSettings( int id, bool _b_shown, wxPoint p, wxSize s ){ if( id < 0 || id >= ID_MAX ) return; b_valid[id] = true; b_shown[id] = _b_shown; position[id] = p; size[id] = s;}bool WindowSettings::GetSettings( int id, bool& _b_shown, wxPoint& p, wxSize& s){ if( id < 0 || id >= ID_MAX ) return false; if( !b_valid[id] ) return false; _b_shown = b_shown[id]; p = position[id]; s = size[id]; return true;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -