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

📄 profilespage.cpp

📁 atmel usb 无线网卡驱动程序
💻 CPP
📖 第 1 页 / 共 2 页
字号:
/* ProfilesPage.cpp *//*******************************************************************************************	Copyright 2002-2003 ATMEL Corporation.	This file is part of ATMEL Wireless LAN Drivers.	ATMEL Wireless LAN Drivers 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.	ATMEL Wireless LAN Drivers 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 ATMEL Wireless LAN Drivers; if not, write to the Free Software	Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA*******************************************************************************************/#include "ProfilesPage.h"#include "Profile.h"#include "Accessor.h"#include "WinterModel.h"#include "WinterData.h"#include "Device.h"#include "WinterLang.h"#include "WinterConfig.h"#include "WinterTimer.h"#include "HRStrings.h"#include "Decls.h"#include "ChoiceCtrl.h"#include "MonitorPage.h"#include "EncryptionPage.h"#include "WinterSetup.h"#include <wx/wx.h>#include <wx/statline.h>#include <wx/notebook.h>#include <wx/busyinfo.h>BEGIN_EVENT_TABLE( CProfilesPage, CWinterPage )	EVT_IDLE( CProfilesPage::OnIdle )	EVT_LISTBOX( ID_CL_PROFILESPAGE_PROFILES, CProfilesPage::OnLbSelected )	EVT_LISTBOX_DCLICK( ID_CL_PROFILESPAGE_PROFILES, CProfilesPage::OnLbDClicked )	EVT_CHECKLISTBOX( ID_CL_PROFILESPAGE_PROFILES, CProfilesPage::OnClProfilesToggled )	EVT_BUTTON( ID_BT_PROFILESPAGE_ADD, CProfilesPage::OnBtAdd )	EVT_BUTTON( ID_BT_PROFILESPAGE_REMOVE, CProfilesPage::OnBtRemove )	EVT_BUTTON( ID_BT_PROFILESPAGE_LOAD, CProfilesPage::OnBtLoad )	EVT_BUTTON( ID_BT_PROFILESPAGE_SAVE, CProfilesPage::OnBtSave )	EVT_CHOICE( ID_CH_PROFILESPAGE_LANG, CProfilesPage::OnChLang )END_EVENT_TABLE( )// CProfilesPage class implementation//====================================CProfilesPage::CProfilesPage( wxWindow *parent, int id, const wxPoint &pos, const wxSize &size, long style ) : CWinterPage( parent, id ){	wxBoxSizer *sz_bt1 = new wxBoxSizer( wxHORIZONTAL );	sz_bt1->Add( new wxButton( this, ID_BT_PROFILESPAGE_LOAD, _( "&Load" ) ), 1, wxEXPAND | wxALL, 5 );	sz_bt1->Add( new wxButton( this, ID_BT_PROFILESPAGE_SAVE, _( "&Save" ) ), 1, wxEXPAND | wxTOP | wxBOTTOM | wxRIGHT, 5 );	wxBoxSizer *sz_bt2 = new wxBoxSizer( wxHORIZONTAL );	sz_bt2->Add( new wxButton( this, ID_BT_PROFILESPAGE_ADD, _( "&Add" ) ), 1, wxEXPAND | wxALL, 5 );	sz_bt2->Add( new wxButton( this, ID_BT_PROFILESPAGE_REMOVE, _( "&Remove" ) ), 1, wxEXPAND | wxTOP | wxBOTTOM | wxRIGHT, 5 );	wxBoxSizer *sz_bt = new wxBoxSizer( wxVERTICAL );	sz_bt->Add( sz_bt1, 0, wxEXPAND, 0 );	sz_bt->Add( new wxStaticLine( this, -1 ), 0, wxEXPAND | wxALL, 3 );	sz_bt->Add( sz_bt2, 0, wxEXPAND, 0 );	wxBoxSizer *sz_lbbt = new wxBoxSizer( wxVERTICAL );	sz_lbbt->Add( new CRadioListBox( this, ID_CL_PROFILESPAGE_PROFILES ), 1, wxEXPAND | wxALL, 5 ); 	sz_lbbt->Add( sz_bt, 0, wxEXPAND, 0 );	wxBoxSizer *sz_profiles = new wxStaticBoxSizer( new wxStaticBox( this, -1, _( "Device profile" ) ), wxHORIZONTAL );	sz_profiles->Add( sz_lbbt, 1, wxEXPAND, 0 );	sz_profiles->Add( new CPreviewPanel( this, ID_PN_PROFILESPAGE_PREVIEW ), 2, wxEXPAND | wxBOTTOM | wxLEFT | wxRIGHT, 5 );	wxBoxSizer *sz_langline = new wxBoxSizer( wxHORIZONTAL );	sz_langline->Add( new wxStaticText( this, ID_ST_PROFILESPAGE_LANG, _( "Language : " ) ), 0, wxALL | wxALIGN_CENTER_VERTICAL, 3 );	sz_langline->Add( new CAutoChoice( this, ID_CH_PROFILESPAGE_LANG, wxDefaultPosition, wxDefaultSize, CWinterSupportedLanguages::GetAllLanguages( ) ), 1, wxALL | wxALIGN_CENTER_VERTICAL, 6 );	wxBoxSizer *sz_options = new wxStaticBoxSizer( new wxStaticBox( this, -1, _( "Startup Options" ) ), wxVERTICAL );	sz_options->Add( new wxStaticText( this, ID_ST_PROFILESPAGE_STARTUPOPTIONS, _( "Note that you will have to restart the application in order the language changes to take effect." ) ), 0, wxALL, 3 );	sz_options->Add( sz_langline, 1, wxEXPAND, 0 );	wxBoxSizer *sz_main = new wxBoxSizer( wxVERTICAL );	sz_main->Add( sz_profiles, 3, wxEXPAND | wxALL, 5 );	sz_main->Add( sz_options, 1, wxEXPAND | wxLEFT | wxRIGHT | wxBOTTOM, 5 );	SetSizer( sz_main );	SetAutoLayout( true );	Layout( );}CProfilesPage::~CProfilesPage( ){}void CProfilesPage::UpdateWinterPage( ){	CWinterProfileManager *pmanager = ( CWinterProfileManager * ) CAccessor::Access( AID_PROFILEMANAGER );	CWinterConfig *config = ( CWinterConfig * ) CAccessor::Access( AID_CONFIG );	wxCheckListBox *clprofiles = ( wxCheckListBox * ) FindWindowById( ID_CL_PROFILESPAGE_PROFILES );	CAutoChoice *chlang = ( CAutoChoice * ) FindWindowById( ID_CH_PROFILESPAGE_LANG );	wxString lang = config->GetLangName( );	wxString startup_profile = config->GetStartupProfile( );	wxString tmp;	clprofiles->Clear( );	int count = pmanager->CountProfiles( );	for( int c = 0; c < count; c++ )	{		tmp = pmanager->GetProfile( c )->GetName( );		clprofiles->Append( tmp );		if( tmp == startup_profile )		{			clprofiles->Check( c, true );		}	}	if( chlang->FindString( lang ) == -1 )	{		chlang->SetSelection( 0 );	}	else	{		chlang->SetStringSelection( lang );	}	return;}void CProfilesPage::ActivateProfile( CWinterProfile *profile ){	CWinterModel *model = new CWinterModel( );	profile->Export( model );	CMonitorPage *pgmonitor = ( CMonitorPage * ) FindWindowById( ID_PN_MONITORPAGE );	CEncryptionPage *pgencryption = ( CEncryptionPage * ) FindWindowById( ID_PN_ENCRYPTIONPAGE );	CVnetDeviceBase *device = ( CVnetDeviceBase * ) CAccessor::Access( AID_CURRENTDEVICE );	CDeviceConfigurationData *dev_data = ( CDeviceConfigurationData * ) model->GetChild( MC_DEVICECONFIGURATIONDATA );	CWepInfoData *wep_data = ( CWepInfoData * ) model->GetChild( MC_WEPINFODATA );	DEACTIVATE_TIMER( );	device->SetWepInfo( wep_data );#if ( DELAY_AFTER_SUBMIT == 1 )	::wxSleep( 1 );#endif // DELAY_AFTER_SUBMIT == 1	device->SetDeviceConfig( dev_data );#if ( DELAY_AFTER_SUBMIT == 1 )	::wxSleep( 1 );#endif // DELAY_AFTER_SUBMIT == 1	pgmonitor->UpdateWinterPage( );	pgencryption->UpdateWinterPage( );	ACTIVATE_TIMER( );	delete model;	return;}bool CProfilesPage::OnPageChanging( ){	CPreviewPanel *pnpreview = ( CPreviewPanel * ) FindWindowById( ID_PN_PROFILESPAGE_PREVIEW );	pnpreview->ClearPreview( );	return true;}void CProfilesPage::OnIdle( wxIdleEvent &event ){	int sel = ( ( wxListBox * ) FindWindowById( ID_CL_PROFILESPAGE_PROFILES ) )->GetSelection( );	bool any_selected = ( sel != -1 );	FindWindowById( ID_BT_PROFILESPAGE_REMOVE )->Enable( any_selected );	FindWindowById( ID_BT_PROFILESPAGE_LOAD )->Enable( any_selected );	FindWindowById( ID_BT_PROFILESPAGE_SAVE )->Enable( any_selected );	event.Skip( );	return;}void CProfilesPage::OnLbDClicked( wxCommandEvent &event ){	CWinterProfileManager *pmanager = ( CWinterProfileManager * ) CAccessor::Access( AID_PROFILEMANAGER );	CWinterProfile *profile = pmanager->GetProfile( event.GetSelection( ) );	ActivateProfile( profile );	if( OnPageChanging( ) == true )	{		( ( wxNotebook * ) FindWindowById( ID_NB_MAINNOTEBOOK ) )->SetSelection( 0 );	}	event.Skip( );	return;}void CProfilesPage::OnLbSelected( wxCommandEvent &event ){	CWinterProfileManager *pmanager = ( CWinterProfileManager * ) CAccessor::Access( AID_PROFILEMANAGER );	CWinterProfile *profile = pmanager->GetProfile( event.GetSelection( ) );	CPreviewPanel *pnpreview = ( CPreviewPanel * ) FindWindowById( ID_PN_PROFILESPAGE_PREVIEW );	pnpreview->DoPreview( profile );	return;}void CProfilesPage::OnBtAdd( wxCommandEvent &event ){	CProfileDialog dlg( ( wxFrame * ) CAccessor::Access( AID_FRAME ) );	dlg.CentreOnParent( );	if( dlg.ShowModal( ) == wxID_OK )	{		UpdateWinterPage( );	}	return;}void CProfilesPage::OnBtRemove( wxCommandEvent &event ){	CWinterProfileManager *pmanager = ( CWinterProfileManager * ) CAccessor::Access( AID_PROFILEMANAGER );	CWinterConfig *config = ( CWinterConfig * ) CAccessor::Access( AID_CONFIG );	CRadioListBox *clprofiles = ( CRadioListBox * ) FindWindowById( ID_CL_PROFILESPAGE_PROFILES );	CWinterProfile *current_profile;	int selection = clprofiles->GetSelection( );	if ( selection != -1 ) 	{		current_profile = pmanager->GetProfile( selection );		if( current_profile != NULL )		{			pmanager->RemoveProfile( current_profile );			if( clprofiles->GetChecked( ) == selection )			{				config->SetStartupProfile( wxT( "" ) );			}			clprofiles->Delete( selection );			( ( CAutoChoice *) FindWindowById( ID_CH_MAINPANEL_PROFILES ) )->Delete( selection );			OnPageChanging( );				}	}		return;}void CProfilesPage::OnBtLoad( wxCommandEvent &event ){#if ( USE_BUSY_CURSOR == 1 )	wxBusyInfo info( _( "Applying profile settings..." ) );#endif // USE_BUSY_CURSOR == 1	wxListBox *lbprofiles = ( wxListBox * ) FindWindowById( ID_CL_PROFILESPAGE_PROFILES );	CWinterProfileManager *pmanager = ( CWinterProfileManager * ) CAccessor::Access( AID_PROFILEMANAGER );	CWinterProfile *profile = pmanager->GetProfile( lbprofiles->GetSelection( ) );	ActivateProfile( profile );	if( OnPageChanging( ) == true )	{		( ( wxNotebook * ) FindWindowById( ID_NB_MAINNOTEBOOK ) )->SetSelection( 0 );	}	return;}void CProfilesPage::OnBtSave( wxCommandEvent &event ){	CWinterProfileManager *pmanager = ( CWinterProfileManager * ) CAccessor::Access( AID_PROFILEMANAGER );	wxListBox *lbprofiles = ( wxListBox * ) FindWindowById( ID_CL_PROFILESPAGE_PROFILES );	wxString profilename = lbprofiles->GetStringSelection( );	CWinterProfile *profile = pmanager->GetProfile( profilename );	profile->Import( );	UpdateWinterPage( );	return;}void CProfilesPage::OnChLang( wxCommandEvent &event ){	CWinterConfig *config = ( CWinterConfig * ) CAccessor::Access( AID_CONFIG );	CAutoChoice *chlang = ( CAutoChoice * ) FindWindowById( ID_CH_PROFILESPAGE_LANG );	config->SetLangName( chlang->GetStringSelection( ) );	return;}void CProfilesPage::OnClProfilesToggled( wxCommandEvent &event ){	CWinterConfig *config = ( CWinterConfig * ) CAccessor::Access( AID_CONFIG );

⌨️ 快捷键说明

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