📄 winterframe.cpp
字号:
/* WinterFrame.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 "WinterApp.h"#include "WinterFrame.h"#include "WinterSetup.h"#include "MonitorPage.h"#include "StatisticsPage.h"#include "EncryptionPage.h"#include "AdvancedPage.h"#include "VersionPage.h"#include "SiteSurveyPage.h"#include "ProfilesPage.h"#include "ChoiceCtrl.h"#include "Decls.h"#include "Accessor.h"#include "WinterTimer.h"#include "WinterDebug.h"#include "WinterModel.h"#include "Profile.h"#include <wx/busyinfo.h>#ifndef __WXMSW__#include "monitor.xpm"#include "statistics.xpm"#include "cball.xpm"#include "lock.xpm"#include "beanie.xpm"#include "profile.xpm"#include "info.xpm"#include "snowman.xpm"#endif // __WXMSW__BEGIN_EVENT_TABLE( CWinterFrame, wxFrame ) EVT_NOTEBOOK_PAGE_CHANGING( ID_NB_MAINNOTEBOOK, CWinterFrame::OnPageChanging ) EVT_BUTTON( ID_BT_CLOSE, CWinterFrame::OnBtClose ) EVT_BUTTON( ID_BT_APPLY_PROFILE, CWinterFrame::OnBtApplyProfile ) EVT_CHOICE( ID_CH_WHICHDEVICE, CWinterFrame::OnDeviceSelect ) EVT_IDLE( CWinterFrame::OnIdle ) EVT_CLOSE( CWinterFrame::OnClose )END_EVENT_TABLE( )CWinterFrame::CWinterFrame( wxWindow* parent, wxWindowID id, const wxString &title, const wxPoint &pos, const wxSize &size, long style ) : wxFrame( parent, id , title ) { mExitASAP = false; mDevIndex = 0; //MainPanel setup wxSize mainpage_labelsize0( 30, -1 ); wxSize mainpage_labelsize1( 70, -1 ); wxSize mainpage_labelsize1_5( 100, -1 ); wxSize mainpage_labelsize2( 150, -1 ); int fieldone = 6; int fieldtwo = 3; SetSize( wxSize( FRAME_WIDTH, FRAME_HEIGHT ) ); SetSizeHints( FRAME_WIDTH, FRAME_HEIGHT ); wxPanel *pn_main = new wxPanel( this, ID_PN_MAINPANEL ); wxNotebook *nb_main = new wxNotebook( pn_main, ID_NB_MAINNOTEBOOK ); wxButton *bt_close = new wxButton( pn_main, ID_BT_CLOSE, _( "&Close" ) ); wxButton *bt_apply = new wxButton( pn_main, ID_BT_APPLY_PROFILE, _( "A&pply" ) ); wxBoxSizer *choice_sz = new wxBoxSizer( wxHORIZONTAL ); choice_sz->Add( 1, 10, 1, 0 ); choice_sz->Add( new wxStaticText( pn_main, -1, wxT( "Active Card : " ), wxDefaultPosition, mainpage_labelsize1_5 ), 0, wxALIGN_CENTER_VERTICAL, 0 );///////////////////////////////////////////////////// CAutoChoice *ch_dev = new CAutoChoice( pn_main, ID_CH_WHICHDEVICE ); //ch_dev->SetSelection(0); choice_sz->Add( ch_dev, fieldtwo, wxALIGN_CENTER_VERTICAL, 0 ); ( ( wxEvtHandler * ) ch_dev )->Connect( ID_CH_WHICHDEVICE, wxEVT_LEFT_DOWN, (wxObjectEventFunction) (wxEventFunction) (wxMouseEventFunction) &CWinterFrame::OnDevListClick );///////////////////////////////////////////////////// choice_sz->Add( new wxStaticText( pn_main, -1, wxT( " registered as : " ), wxDefaultPosition, mainpage_labelsize1_5 ), 0, wxALIGN_CENTER_VERTICAL, 0 ); choice_sz->Add( new wxTextCtrl( pn_main, ID_TX_MAINPANEL_CARDTYPE, wxT( "" ), wxDefaultPosition, wxDefaultSize, wxTE_READONLY | wxTE_CENTRE ), 0, wxALIGN_CENTER_VERTICAL, 0 ); choice_sz->Add( 1, 10, 1, 0 ); wxBoxSizer *profchoice_sz = new wxBoxSizer( wxHORIZONTAL ); profchoice_sz->Add( 1, 10, 1, 0 ); profchoice_sz->Add( new wxStaticText( pn_main,-1, _( "Quick-Select profile : " ), wxDefaultPosition, mainpage_labelsize2 ), 0, wxALIGN_CENTER_VERTICAL, 0 ); profchoice_sz->Add( new CAutoChoice( pn_main, ID_CH_MAINPANEL_PROFILES ), fieldtwo, wxALIGN_CENTER_VERTICAL, 0 ); profchoice_sz->Add( bt_apply, 0, wxALL | wxALIGN_BOTTOM, 5 ); profchoice_sz->Add( 1, 10, 1, 0 ); wxBoxSizer *sz_buttons = new wxBoxSizer( wxHORIZONTAL ); sz_buttons->Add( 1 , 1, wxALIGN_BOTTOM, 0 ); sz_buttons->Add( bt_close, 0, wxALL | wxALIGN_RIGHT , 5 ); wxBoxSizer *sz_top = new wxBoxSizer( wxVERTICAL ); sz_top->Add( 1, 10, 0, 1 ); sz_top->Add( choice_sz, 0, wxEXPAND, 5 ); sz_top->Add( 1, 10, 0, 1 ); sz_top->Add( profchoice_sz, 0, wxEXPAND, 5 ); sz_top->Add( 1, 10, 0, 1 ); sz_top->Add( nb_main, 1, wxEXPAND, 0 ); sz_top->Add( sz_buttons, 0, wxEXPAND, 0 ); pn_main->SetSizer( sz_top ); pn_main->SetAutoLayout( true );#ifndef __WXMSW__ wxImageList *il_nb = new wxImageList( 16, 16 ); il_nb->Add( wxBITMAP( BMP_MONITOR ) ); // 0 il_nb->Add( wxBITMAP( BMP_STATISTICS ) ); // 1 il_nb->Add( wxBITMAP( BMP_CBALL ) ); // 2 il_nb->Add( wxBITMAP( BMP_LOCK ) ); // 3 il_nb->Add( wxBITMAP( BMP_BEANIE ) ); // 4 il_nb->Add( wxBITMAP( BMP_PROFILE ) ); // 5 il_nb->Add( wxBITMAP( BMP_INFO ) ); // 6 nb_main->AssignImageList( il_nb ); nb_main->AddPage( new CMonitorPage( nb_main, ID_PN_MONITORPAGE ), _( "Monitor" ), false, 0 ); nb_main->AddPage( new CStatisticsPage( nb_main, ID_PN_STATISTICSPAGE ), _( "Statistics" ), false, 1 ); nb_main->AddPage( new CSiteSurveyPage( nb_main, ID_PN_SITESURVEYPAGE ), _( "Site Survey" ), false, 2 ); nb_main->AddPage( new CEncryptionPage( nb_main, ID_PN_ENCRYPTIONPAGE ), _( "Encryption" ), false, 3 ); nb_main->AddPage( new CAdvancedPage( nb_main, ID_PN_ADVANCEDPAGE ), _( "Advanced" ), false, 4 ); nb_main->AddPage( new CProfilesPage( nb_main, ID_PN_PROFILESPAGE ), _( "Profile" ), false, 5 ); nb_main->AddPage( new CVersionPage( nb_main, ID_PN_VERSIONPAGE ), _( "Version" ), false, 6 ); SetIcon( ( const wxIcon & ) wxBITMAP( BMP_SNOWMAN ) );#else // __WXMSW__ nb_main->AddPage( new CMonitorPage( nb_main, ID_PN_MONITORPAGE ), _( "Monitor" ) ); nb_main->AddPage( new CStatisticsPage( nb_main, ID_PN_STATISTICSPAGE ), _( "Statistics" ) ); nb_main->AddPage( new CSiteSurveyPage( nb_main, ID_PN_SITESURVEYPAGE ), _( "Site Survey" ) ); nb_main->AddPage( new CEncryptionPage( nb_main, ID_PN_ENCRYPTIONPAGE ), _( "Encryption" ) ); nb_main->AddPage( new CAdvancedPage( nb_main, ID_PN_ADVANCEDPAGE ), _( "Advanced" ) ); nb_main->AddPage( new CProfilesPage( nb_main, ID_PN_PROFILESPAGE ), _( "Profile" ) ); nb_main->AddPage( new CVersionPage( nb_main, ID_PN_VERSIONPAGE ), _( "Version" ) );#endif // __WXMSW__ pn_main->Layout(); // And after all initialization is done, start the main timer. CWinterTimer *timer = ( CWinterTimer * ) CAccessor::Access( AID_TIMER ); timer->Start( MAIN_TIMER_INTERVAL ); timer->DeActivate( ); ACTIVATE_TIMER( );}CWinterFrame::~CWinterFrame( ){ CWinterTimer *timer = ( CWinterTimer * ) CAccessor::Access( AID_TIMER ); timer->Stop( ); delete timer;}void CWinterFrame::UpdateAllPages( ){ wxTextCtrl *cardtype = ( wxTextCtrl * ) FindWindowById( ID_TX_MAINPANEL_CARDTYPE ); CVnetDeviceBase* device = ( CVnetDeviceBase * ) CAccessor::Access( AID_CURRENTDEVICE ); wxString ctype = _(device->GetDevName( )); cardtype->SetValue( ctype ); wxNotebook *nbook = ( wxNotebook * ) FindWindowById( ID_NB_MAINNOTEBOOK ); int count = nbook->GetPageCount( ); for( int c = 0; c < count; c++ ) { ( ( CWinterPage * ) nbook->GetPage( c ) )->UpdateWinterPage( ); } return;}void CWinterFrame::UpdateProfileList( ){ CWinterProfileManager *pmanager = ( CWinterProfileManager * ) CAccessor::Access( AID_PROFILEMANAGER ); CAutoChoice *profile_choice = ( ( CAutoChoice *) FindWindowById( ID_CH_MAINPANEL_PROFILES ) ); profile_choice->Clear( ); int count = pmanager->CountProfiles( ); for( int c = 0; c < count; c++ ) { profile_choice->Append( pmanager->GetProfile( c )->GetName( ) ); } return;}void CWinterFrame::OnDevListClick( wxMouseEvent &event ){ wxString str_selection; CVnetDeviceManager *devman = (CVnetDeviceManager*)CAccessor::Access( AID_DEVICEMANAGER ); CAutoChoice *iface_choice = ( ( CAutoChoice *) FindWindowById( ID_CH_WHICHDEVICE ) ); devman->Detect(); str_selection = iface_choice->GetStringSelection(); UpdateIFaceList(); //if(count >= oldcount) iface_choice->SetSelection(0); if(!iface_choice->SetStringSelection(str_selection)) iface_choice->SetSelection(0); event.Skip(); return;}void CWinterFrame::UpdateIFaceList(){ int count; CVnetDeviceManager *devman= (CVnetDeviceManager*)CAccessor::Access( AID_DEVICEMANAGER ); CAutoChoice *iface_choice = ( ( CAutoChoice *) FindWindowById( ID_CH_WHICHDEVICE ) ); count = devman->GetDeviceCount(); iface_choice->Clear( ); for( int d = 0; d < count; d++ ) { iface_choice->Append(devman->GetDevice(d)->GetUFName()); } return;}void CWinterFrame::ExitASAP( ){ mExitASAP = true; return;}void CWinterFrame::OnPageChanging( wxNotebookEvent &event ){ int index_old_page = event.GetOldSelection( ); int index_new_page = event.GetSelection( ); if( index_old_page != -1 ) { CWinterPage *old_page = ( CWinterPage * ) ( ( wxNotebook * ) FindWindowById( ID_NB_MAINNOTEBOOK ) )->GetPage( index_old_page ); if( old_page->OnPageChanging( ) != true ) { event.Veto( ); return; } } if( index_new_page == -1 ) { return; } CWinterPage *new_page = ( CWinterPage * ) ( ( wxNotebook * ) FindWindowById( ID_NB_MAINNOTEBOOK ) )->GetPage( index_new_page ); new_page->UpdateWinterPage( ); return;}void CWinterFrame::OnBtClose( wxCommandEvent &event ){ Close(); return;}void CWinterFrame::OnIdle( wxIdleEvent &event ){ if( mExitASAP == true ) { Close( ); return; } CAutoChoice *chprofiles = ( CAutoChoice * ) FindWindowById( ID_CH_MAINPANEL_PROFILES ); wxButton *btapply = ( wxButton * ) FindWindowById( ID_BT_APPLY_PROFILE ); bool enable_apply = true; if( chprofiles->GetStringSelection( ) == wxT( "" ) ) { enable_apply = false; } if( btapply->IsEnabled( ) != enable_apply ) { btapply->Enable( enable_apply ); } return;}void CWinterFrame::OnClose( wxCloseEvent &event ){ Show( false ); event.Skip( ); return;}void CWinterFrame::OnBtApplyProfile( wxCommandEvent &event ){ CWinterProfileManager *pmanager = ( CWinterProfileManager * ) CAccessor::Access( AID_PROFILEMANAGER ); CProfilesPage *prof_page = ( CProfilesPage * ) FindWindowById( ID_PN_PROFILESPAGE ); int selection = ( ( CAutoChoice *) FindWindowById( ID_CH_MAINPANEL_PROFILES ) )->GetSelection( ); if( selection != -1 ) {#if ( USE_BUSY_INFO == 1 ) wxBusyInfo info( _( "Applying profile settings..." ) );#endif // USE_BUSY_INFO CWinterProfile *profile = pmanager->GetProfile( selection ); prof_page->ActivateProfile( profile ); wxNotebook *nbmain = ( wxNotebook * ) FindWindowById( ID_NB_MAINNOTEBOOK ); ( ( CWinterPage * ) nbmain->GetPage( 0 ) )->UpdateWinterPage( ); nbmain->SetSelection( 0 ); } return;}void CWinterFrame::OnDeviceSelect( wxCommandEvent &event ){ CWinterModel *model = ( CWinterModel * ) CAccessor::Access( AID_CURRENTMODEL ); CDeviceConfigurationData *data=(CDeviceConfigurationData*)model->GetChild( MC_DEVICECONFIGURATIONDATA ); mDevIndex = ((CAutoChoice*)FindWindowById(ID_CH_WHICHDEVICE))->GetSelection(); CVnetDeviceBase* dev = (CVnetDeviceBase*)CAccessor::Access(AID_CURRENTDEVICE); CMonitorPage* monpage = (CMonitorPage*) FindWindowById(ID_PN_MONITORPAGE); //monpage->SubmitMonitorPageData(); if(!dev->GetInit()) { CWinterProfileManager *pmanager = ( CWinterProfileManager * ) CAccessor::Access( AID_PROFILEMANAGER ); CProfilesPage *prof_page = ( CProfilesPage * ) FindWindowById( ID_PN_PROFILESPAGE ); int selection = ( ( CAutoChoice *) FindWindowById( ID_CH_MAINPANEL_PROFILES ) )->GetSelection( ); if( selection != -1 ) {#if ( USE_BUSY_INFO == 1 ) wxBusyInfo info( _( "Applying profile settings..." ) );#endif // USE_BUSY_INFO CWinterProfile *profile = pmanager->GetProfile( selection ); prof_page->ActivateProfile( profile ); wxNotebook *nbmain = ( wxNotebook * ) FindWindowById( ID_NB_MAINNOTEBOOK ); ( ( CWinterPage * ) nbmain->GetPage( 0 ) )->UpdateWinterPage( ); nbmain->SetSelection( 0 ); } // wxGetApp().ApplyStartupOptions(); } UpdateAllPages(); return;}int CWinterFrame::GetDeviceIndex(){ /* int ret = ((CAutoChoice*)FindWindowById(ID_CH_WHICHDEVICE))->GetSelection(); if(ret != -1) return ret; else return 0; */ return mDevIndex;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -