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

📄 packagesdlg.cpp

📁 ecos实时嵌入式操作系统
💻 CPP
📖 第 1 页 / 共 3 页
字号:
//####COPYRIGHTBEGIN####//// ----------------------------------------------------------------------------// Copyright (C) 1998, 1999, 2000 Red Hat, Inc.// Copyright (C) 2003 John Dallaway//// This program is part of the eCos host tools.//// 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.,// 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.//// ----------------------------------------------------------------------------////####COPYRIGHTEND####// packages :////===========================================================================//#####DESCRIPTIONBEGIN####//// Author(s):   julians, jld// Contact(s):  julians// Date:        2000/09/28// Version:     $Id: packagesdlg.cpp,v 1.9 2001/12/14 17:34:03 julians Exp $// Purpose:// Description: Implementation file for ecPackagesDialog// Requires:// Provides:// See also:// Known bugs:// Usage:////####DESCRIPTIONEND####////===========================================================================// ============================================================================// declarations// ============================================================================// ----------------------------------------------------------------------------// headers// ----------------------------------------------------------------------------#ifdef __GNUG__#pragma implementation "packagesdlg.h"#endif// Includes other headers for precompiled compilation#include "ecpch.h"#ifdef __BORLANDC__#pragma hdrstop#endif#include "wx/cshelp.h"#include "wx/valgen.h"#include "wx/tokenzr.h"#include "configtool.h"#include "packagesdlg.h"#include "configtooldoc.h"#include "ecutils.h"BEGIN_EVENT_TABLE(ecPackagesDialog, ecDialog)    EVT_BUTTON(wxID_OK, ecPackagesDialog::OnOK)    EVT_BUTTON(wxID_CANCEL, ecPackagesDialog::OnCancel)    EVT_BUTTON(ecID_PACKAGES_DIALOG_ADD, ecPackagesDialog::OnAdd)    EVT_BUTTON(ecID_PACKAGES_DIALOG_REMOVE, ecPackagesDialog::OnRemove)    EVT_LISTBOX_DCLICK(ecID_PACKAGES_DIALOG_AVAILABLE_LIST, ecPackagesDialog::OnDblClickListBox1)    EVT_LISTBOX_DCLICK(ecID_PACKAGES_DIALOG_USE_LIST, ecPackagesDialog::OnDblClickListBox2)    EVT_LISTBOX(ecID_PACKAGES_DIALOG_AVAILABLE_LIST, ecPackagesDialog::OnClickListBox1)    EVT_LISTBOX(ecID_PACKAGES_DIALOG_USE_LIST, ecPackagesDialog::OnClickListBox2)    EVT_LISTBOX(ecID_PACKAGES_DIALOG_VERSION, ecPackagesDialog::OnSelectVersion)    EVT_INIT_DIALOG(ecPackagesDialog::OnInitDialog)    EVT_BUTTON(ecID_PACKAGES_DIALOG_CLEAR, ecPackagesDialog::OnClearKeywords)    EVT_CHECKBOX(ecID_PACKAGES_DIALOG_OMIT_HARDWARE, ecPackagesDialog::OnClickOmitHardwarePackages)    EVT_CHECKBOX(ecID_PACKAGES_DIALOG_EXACT_MATCH, ecPackagesDialog::OnClickExactMatch)    EVT_TEXT(ecID_PACKAGES_DIALOG_KEYWORDS, ecPackagesDialog::OnUpdateKeywordText)    EVT_IDLE(ecPackagesDialog::OnIdle)END_EVENT_TABLE()// ----------------------------------------------------------------------------// main frame// ----------------------------------------------------------------------------// Frame constructorecPackagesDialog::ecPackagesDialog(wxWindow* parent):m_timer(this){    m_bHardwarePackageSelected = FALSE;    m_keywords = wxEmptyString;    m_updateLists = FALSE;    m_updateInterval = 600; // Milliseconds    wxStartTimer();        SetExtraStyle(wxDIALOG_EX_CONTEXTHELP);        ecDialog::Create(parent, ecID_PACKAGES_DIALOG, _("Packages"),        wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER);        CreateControls(this);        m_timer.Start(200);        Centre(wxBOTH);}ecPackagesDialog::~ecPackagesDialog(){    m_timer.Stop();}// TODO: implement wxLB_SORT style in wxGTK.void ecPackagesDialog::CreateControls(wxWindow* parent){    wxSizer *item0 = new wxBoxSizer( wxVERTICAL );        wxSizer *item1 = new wxBoxSizer( wxHORIZONTAL );        wxSizer *item2 = new wxBoxSizer( wxVERTICAL );    wxStaticText *item3 = new wxStaticText( parent, wxID_STATIC, _("Available &packages:"), wxDefaultPosition, wxDefaultSize, 0 );    item2->Add( item3, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 );        wxString *strs4 = (wxString*) NULL;    wxListBox *item4 = new wxListBox( parent, ecID_PACKAGES_DIALOG_AVAILABLE_LIST, wxDefaultPosition, wxSize(230,190), 0, strs4, wxLB_SORT|wxLB_HSCROLL );    item2->Add( item4, 1, wxGROW|wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT|wxBOTTOM, 5 );        item1->Add( item2, 1, wxGROW|wxALIGN_CENTER_HORIZONTAL|wxALL, 0 );        wxSizer *item5 = new wxBoxSizer( wxVERTICAL );        wxButton *item6 = new wxButton( parent, ecID_PACKAGES_DIALOG_ADD, _("&Add >>"), wxDefaultPosition, wxDefaultSize, 0 );    item5->Add( item6, 0, wxALIGN_CENTRE|wxALL, 5 );        wxButton *item7 = new wxButton( parent, ecID_PACKAGES_DIALOG_REMOVE, _("<< &Remove"), wxDefaultPosition, wxDefaultSize, 0 );    item5->Add( item7, 0, wxALIGN_CENTRE|wxALL, 5 );        item1->Add( item5, 0, wxALIGN_CENTRE|wxALL, 0 );        wxSizer *item8 = new wxBoxSizer( wxVERTICAL );        wxStaticText *item9 = new wxStaticText( parent, wxID_STATIC, _("&Use these packages:"), wxDefaultPosition, wxDefaultSize, 0 );    item8->Add( item9, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 );        wxString *strs10 = (wxString*) NULL;    wxListBox *item10 = new wxListBox( parent, ecID_PACKAGES_DIALOG_USE_LIST, wxDefaultPosition, wxSize(230,190), 0, strs10, wxLB_SORT|wxLB_HSCROLL );    item8->Add( item10, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT|wxBOTTOM, 5 );        item1->Add( item8, 1, wxGROW|wxALIGN_CENTER_HORIZONTAL|wxALL, 0 );        item0->Add( item1, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxALL, 5 );        wxStaticText *item11 = new wxStaticText( parent, wxID_STATIC, _("&Version:"), wxDefaultPosition, wxDefaultSize, 0 );    item0->Add( item11, 0, wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT, 10 );        wxString *strs12 = (wxString*) NULL;    wxChoice *item12 = new wxChoice( parent, ecID_PACKAGES_DIALOG_VERSION, wxDefaultPosition, wxSize(100,-1), 0, strs12, 0 );    item0->Add( item12, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxALL, 10 );        wxTextCtrl *item13 = new wxTextCtrl( parent, ecID_PACKAGES_DIALOG_DESCRIPTION, _(""), wxDefaultPosition, wxSize(80,110), wxTE_MULTILINE );    item0->Add( item13, 1, wxGROW|wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT|wxBOTTOM, 10 );        wxStaticText *item14 = new wxStaticText( parent, wxID_STATIC, _("&Keywords:"), wxDefaultPosition, wxDefaultSize, 0 );    item0->Add( item14, 0, wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT, 10 );        wxSizer *item15 = new wxBoxSizer( wxHORIZONTAL );        wxTextCtrl *item16 = new wxTextCtrl( parent, ecID_PACKAGES_DIALOG_KEYWORDS, _(""), wxDefaultPosition, wxSize(80,-1), 0 );    item15->Add( item16, 1, wxALIGN_CENTRE|wxALL, 5 );        wxButton *item17 = new wxButton( parent, ecID_PACKAGES_DIALOG_CLEAR, _("C&lear"), wxDefaultPosition, wxDefaultSize, 0 );    item15->Add( item17, 0, wxALIGN_CENTRE|wxALL, 5 );        item0->Add( item15, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT, 5 );        wxSizer *item18 = new wxBoxSizer( wxHORIZONTAL );        wxCheckBox *item19 = new wxCheckBox( parent, ecID_PACKAGES_DIALOG_OMIT_HARDWARE, _("&Omit hardware packages"), wxDefaultPosition, wxDefaultSize, 0 );    item18->Add( item19, 0, wxALIGN_CENTRE|wxALL, 5 );        wxCheckBox *item20 = new wxCheckBox( parent, ecID_PACKAGES_DIALOG_EXACT_MATCH, _("&Match exactly"), wxDefaultPosition, wxDefaultSize, 0 );    item18->Add( item20, 0, wxALIGN_CENTRE|wxALL, 5 );        item18->Add( 20, 20, 1, wxALIGN_CENTRE|wxALL, 5 );        wxButton *item21 = new wxButton( parent, wxID_OK, _("&OK"), wxDefaultPosition, wxDefaultSize, 0 );    item21->SetDefault();    item18->Add( item21, 0, wxALIGN_CENTRE|wxALL, 5 );        wxButton *item22 = new wxButton( parent, wxID_CANCEL, _("&Cancel"), wxDefaultPosition, wxDefaultSize, 0 );    item18->Add( item22, 0, wxALIGN_CENTRE|wxALL, 5 );        item0->Add( item18, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT|wxBOTTOM, 5 );    #if 0    wxSizer *item0 = new wxBoxSizer( wxVERTICAL );        wxSizer *item1 = new wxBoxSizer( wxHORIZONTAL );        wxSizer *item2 = new wxBoxSizer( wxVERTICAL );        wxStaticText *item3 = new wxStaticText( parent, wxID_STATIC, _("Available &packages:"), wxDefaultPosition, wxDefaultSize, 0 );    item2->Add( item3, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 );        wxString *strs4 = (wxString*) NULL;    wxListBox *item4 = new wxListBox( parent, ecID_PACKAGES_DIALOG_AVAILABLE_LIST, wxDefaultPosition, wxSize(230,190), 0, strs4, wxLB_SORT|wxLB_HSCROLL );    item2->Add( item4, 1, wxGROW|wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT|wxBOTTOM, 5 );        item1->Add( item2, 1, wxGROW|wxALIGN_CENTER_HORIZONTAL|wxALL, 0 );        wxSizer *item5 = new wxBoxSizer( wxVERTICAL );        wxButton *item6 = new wxButton( parent, ecID_PACKAGES_DIALOG_ADD, _("&Add >>"), wxDefaultPosition, wxDefaultSize, 0 );    item5->Add( item6, 0, wxALIGN_CENTRE|wxALL, 5 );        wxButton *item7 = new wxButton( parent, ecID_PACKAGES_DIALOG_REMOVE, _("<< &Remove"), wxDefaultPosition, wxDefaultSize, 0 );    item5->Add( item7, 0, wxALIGN_CENTRE|wxALL, 5 );    item1->Add( item5, 0, wxALIGN_CENTRE|wxALL, 0 );        wxSizer *item8 = new wxBoxSizer( wxVERTICAL );        wxStaticText *item9 = new wxStaticText( parent, wxID_STATIC, _("&Use these packages:"), wxDefaultPosition, wxDefaultSize, 0 );    item8->Add( item9, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 );        wxString *strs10 = (wxString*) NULL;    wxListBox *item10 = new wxListBox( parent, ecID_PACKAGES_DIALOG_USE_LIST, wxDefaultPosition, wxSize(230,190), 0, strs10, wxLB_SORT|wxLB_HSCROLL );    item8->Add( item10, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT|wxBOTTOM, 5 );        item1->Add( item8, 1, wxGROW|wxALIGN_CENTER_HORIZONTAL|wxALL, 0 );        item0->Add( item1, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxALL, 5 );        wxStaticText *item11 = new wxStaticText( parent, wxID_STATIC, _("&Version:"), wxDefaultPosition, wxDefaultSize, 0 );    item0->Add( item11, 0, wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT, 10 );        wxString *strs12 = (wxString*) NULL;    wxChoice *item12 = new wxChoice( parent, ecID_PACKAGES_DIALOG_VERSION, wxDefaultPosition, wxSize(100,-1), 0, strs12, 0 );    item0->Add( item12, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxALL, 10 );        wxTextCtrl *item13 = new wxTextCtrl( parent, ecID_PACKAGES_DIALOG_DESCRIPTION, _(""), wxDefaultPosition, wxSize(80,110), wxTE_MULTILINE );    item0->Add( item13, 1, wxGROW|wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT|wxBOTTOM, 10 );        wxStaticText *item14 = new wxStaticText( parent, wxID_STATIC, _("&Keywords:"), wxDefaultPosition, wxDefaultSize, 0 );    item0->Add( item14, 0, wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT, 10 );        wxSizer *item15 = new wxBoxSizer( wxHORIZONTAL );        wxTextCtrl *item16 = new wxTextCtrl( parent, ecID_PACKAGES_DIALOG_KEYWORDS, _(""), wxDefaultPosition, wxSize(80,-1), 0 );    item15->Add( item16, 1, wxALIGN_CENTRE|wxALL, 5 );        wxButton *item17 = new wxButton( parent, ecID_PACKAGES_DIALOG_CLEAR, _("C&lear"), wxDefaultPosition, wxDefaultSize, 0 );    item15->Add( item17, 0, wxALIGN_CENTRE|wxALL, 5 );        item0->Add( item15, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT, 5 );        wxSizer *item18 = new wxBoxSizer( wxHORIZONTAL );        wxCheckBox *item19 = new wxCheckBox( parent, ecID_PACKAGES_DIALOG_OMIT_HARDWARE, _("Omit hardware packages"), wxDefaultPosition, wxDefaultSize, 0 );    item18->Add( item19, 0, wxALIGN_CENTRE|wxALL, 5 );        item18->Add( 20, 20, 1, wxALIGN_CENTRE|wxALL, 5 );        wxButton *item20 = new wxButton( parent, wxID_OK, _("&OK"), wxDefaultPosition, wxDefaultSize, 0 );    item20->SetDefault();    item18->Add( item20, 0, wxALIGN_CENTRE|wxALL, 5 );    wxButton *item21 = new wxButton( parent, wxID_CANCEL, _("&Cancel"), wxDefaultPosition, wxDefaultSize, 0 );    item18->Add( item21, 0, wxALIGN_CENTRE|wxALL, 5 );        item0->Add( item18, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT|wxBOTTOM, 5 );#endif    #ifdef __WXGTK__    wxButton *contextButton = new wxContextHelpButton( parent );    item18->Add( contextButton, 0, wxALIGN_CENTRE|wxALL, 5 );#endif        parent->FindWindow( ecID_PACKAGES_DIALOG_KEYWORDS )->SetFocus();        parent->SetAutoLayout( TRUE );    parent->SetSizer( item0 );    parent->Layout();    item0->Fit( parent );    //item0->SetSizeHints( parent );        // Add context-sensitive help text    parent->FindWindow( ecID_PACKAGES_DIALOG_AVAILABLE_LIST )->SetHelpText(_("Displays the list of packages available, but not currently loaded."));    parent->FindWindow( ecID_PACKAGES_DIALOG_USE_LIST )->SetHelpText(_("Displays the list of packages currently loaded."));    parent->FindWindow( ecID_PACKAGES_DIALOG_ADD )->SetHelpText(_("Add one or more packages to the list to be loaded."));    parent->FindWindow( ecID_PACKAGES_DIALOG_REMOVE )->SetHelpText(_("Removes one or more packages from the list to be loaded."));    parent->FindWindow( ecID_PACKAGES_DIALOG_VERSION )->SetHelpText(_("Displays the version of the selected packages."));    parent->FindWindow( ecID_PACKAGES_DIALOG_DESCRIPTION )->SetHelpText(_("Displays a description of the selected package (blank if more than one package is selected)."));    parent->FindWindow( ecID_PACKAGES_DIALOG_KEYWORDS )->SetHelpText(_("Enter keywords here to restrict displayed packages."));    parent->FindWindow( ecID_PACKAGES_DIALOG_CLEAR )->SetHelpText(_("Clears the keyword field."));    parent->FindWindow( ecID_PACKAGES_DIALOG_OMIT_HARDWARE)->SetHelpText(_("Check this to omit hardware packages, uncheck to show all packages."));    parent->FindWindow( ecID_PACKAGES_DIALOG_EXACT_MATCH )->SetHelpText(_("Check this to display exact matches between keyword and aliases (case insensitive)."));    parent->FindWindow( wxID_OK )->SetHelpText(_("Closes the dialog and saves any changes you have made."));    parent->FindWindow( wxID_CANCEL )->SetHelpText(_("Closes the dialog without saving any changes you have made."));    #if __WXGTK__    parent->FindWindow( wxID_CONTEXT_HELP )->SetHelpText(_("Invokes context-sensitive help for the clicked-on window."));#endif        // Add validators    parent->FindWindow( ecID_PACKAGES_DIALOG_DESCRIPTION )->SetValidator(wxGenericValidator(& m_packageDescription));    parent->FindWindow( ecID_PACKAGES_DIALOG_KEYWORDS )->SetValidator(wxGenericValidator(& m_keywords));    parent->FindWindow( ecID_PACKAGES_DIALOG_OMIT_HARDWARE )->SetValidator(wxGenericValidator(& wxGetApp().GetSettings().m_omitHardwarePackages));    parent->FindWindow( ecID_PACKAGES_DIALOG_EXACT_MATCH )->SetValidator(wxGenericValidator(& wxGetApp().GetSettings().m_matchPackageNamesExactly));}void ecPackagesDialog::OnInitDialog(wxInitDialogEvent& event){    // Note: InitControls must be here, because data will be added    // between construction of the dialog, and OnInitDialog.    InitControls();    TransferDataToWindow();}void ecPackagesDialog::InitControls(){    Fill();}void ecPackagesDialog::OnCancel(wxCommandEvent& event){    event.Skip();}void ecPackagesDialog::OnOK(wxCommandEvent& event){    TransferDataFromWindow();    event.Skip();}// For each word in keywords, is it contained in 'str'?bool ecPackagesDialog::MatchesKeyword(wxArrayString& keywords, const wxString& str){    // _Every_ keyword must match    size_t i;    for (i = 0; i < keywords.GetCount(); i++)    {        if (str.Find(keywords[i]) == -1)            return FALSE;    }    return TRUE;}void ecPackagesDialog::Fill(){    wxListBox* availableList = (wxListBox*) FindWindow( ecID_PACKAGES_DIALOG_AVAILABLE_LIST );    wxListBox* useList = (wxListBox*) FindWindow( ecID_PACKAGES_DIALOG_USE_LIST );    ecConfigToolDoc * pDoc = wxGetApp().GetConfigToolDoc ();    // wxGTK doesn't deselect items properly when clearing, I think    int i;    for (i = 0; i < availableList->GetCount(); i++)

⌨️ 快捷键说明

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