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

📄 templatesdlg.cpp

📁 ecos实时嵌入式操作系统
💻 CPP
📖 第 1 页 / 共 2 页
字号:
//####COPYRIGHTBEGIN####//// ----------------------------------------------------------------------------// Copyright (C) 1998, 1999, 2000 Red Hat, Inc.//// 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####// templatesdlg.cpp :////===========================================================================//#####DESCRIPTIONBEGIN####//// Author(s):   julians// Contact(s):  julians// Date:        2000/09/27// Version:     $Id: templatesdlg.cpp,v 1.10 2001/12/03 16:05:40 julians Exp $// Purpose:// Description: Implementation file for ecTemplatesDialog// Requires:// Provides:// See also:// Known bugs:// Usage:////####DESCRIPTIONEND####////===========================================================================// ============================================================================// declarations// ============================================================================// ----------------------------------------------------------------------------// headers// ----------------------------------------------------------------------------#ifdef __GNUG__#pragma implementation "templatesdlg.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 "configtool.h"#include "configtooldoc.h"#include "templatesdlg.h"#include "ecutils.h"BEGIN_EVENT_TABLE(ecTemplatesDialog, ecDialog)    EVT_BUTTON(wxID_OK, ecTemplatesDialog::OnOK)    EVT_BUTTON(wxID_CANCEL, ecTemplatesDialog::OnCancel)    EVT_COMBOBOX(ecID_TEMPLATES_DIALOG_HARDWARE_TEMPLATES, ecTemplatesDialog::OnSelHardwareTemplates)    EVT_CHOICE(ecID_TEMPLATES_DIALOG_PACKAGE_TEMPLATES, ecTemplatesDialog::OnSelPackageTemplates)    EVT_CHOICE(ecID_TEMPLATES_DIALOG_VERSION, ecTemplatesDialog::OnSelPackageVersion)    EVT_BUTTON(ecID_TEMPLATES_DIALOG_DETAILS, ecTemplatesDialog::OnDetails)END_EVENT_TABLE()// ----------------------------------------------------------------------------// main frame// ----------------------------------------------------------------------------// Frame constructorecTemplatesDialog::ecTemplatesDialog(wxWindow* parent){    SetExtraStyle(wxDIALOG_EX_CONTEXTHELP);    ecDialog::Create(parent, ecID_TEMPLATES_DIALOG, _("Templates"),        wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER);    CreateControls(this);    Centre(wxBOTH);}ecTemplatesDialog::~ecTemplatesDialog(){}void ecTemplatesDialog::CreateControls(wxWindow* parent){    wxSizer *item0 = new wxBoxSizer( wxVERTICAL );    wxStaticBox *item2 = new wxStaticBox( parent, -1, _("Hardware") );    wxSizer *item1 = new wxStaticBoxSizer( item2, wxVERTICAL );    wxString *strs3 = (wxString*) NULL;    wxComboBox *item3 = new wxComboBox( parent, ecID_TEMPLATES_DIALOG_HARDWARE_TEMPLATES, "", wxDefaultPosition, wxSize(360,-1), 0, strs3, wxCB_DROPDOWN|wxCB_READONLY|wxCB_SORT );    item1->Add( item3, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxALL, 5 );    wxTextCtrl *item4 = new wxTextCtrl( parent, ecID_TEMPLATES_DIALOG_HARDWARE_DESCRIPTION, _(""), wxDefaultPosition, wxSize(90,60), wxTE_MULTILINE|wxTE_READONLY );    item1->Add( item4, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxALL, 5 );    item0->Add( item1, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxALL, 5 );    wxSizer *item5 = new wxBoxSizer( wxHORIZONTAL );    wxStaticBox *item7 = new wxStaticBox( parent, -1, _("Packages") );    wxSizer *item6 = new wxStaticBoxSizer( item7, wxVERTICAL );    wxSizer *item8 = new wxBoxSizer( wxHORIZONTAL );    wxString *strs9 = (wxString*) NULL;    wxChoice *item9 = new wxChoice( parent, ecID_TEMPLATES_DIALOG_PACKAGE_TEMPLATES, wxDefaultPosition, wxSize(100,-1), 0, strs9, 0 );    item8->Add( item9, 20, wxALIGN_CENTRE|wxALL, 5 );    wxString *strs10 = (wxString*) NULL;    wxChoice *item10 = new wxChoice( parent, ecID_TEMPLATES_DIALOG_VERSION, wxDefaultPosition, wxSize(90,-1), 0, strs10, 0 );    item8->Add( item10, 0, wxALIGN_CENTRE|wxALL, 5 );    item6->Add( item8, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxALL, 0 );    wxTextCtrl *item11 = new wxTextCtrl( parent, ecID_TEMPLATES_DIALOG_PACKAGE_DESCRIPTION, _(""), wxDefaultPosition, wxSize(110,70), wxTE_MULTILINE|wxTE_READONLY );    item6->Add( item11, 1, wxGROW|wxALIGN_CENTER_VERTICAL|wxALL, 5 );    item5->Add( item6, 1, wxALIGN_CENTRE|wxLEFT|wxRIGHT|wxBOTTOM, 5 );    wxSizer *item12 = new wxBoxSizer( wxVERTICAL );    wxButton *item13 = new wxButton( parent, wxID_OK, _("&OK"), wxDefaultPosition, wxDefaultSize, 0 );    item12->Add( item13, 0, wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL|wxALL, 5 );    wxButton *item14 = new wxButton( parent, wxID_CANCEL, _("&Cancel"), wxDefaultPosition, wxDefaultSize, 0 );    item12->Add( item14, 0, wxALIGN_CENTRE|wxALL, 5 );    item12->Add( 10, 10, 0, wxALIGN_CENTRE|wxALL, 0 );    wxButton *item15 = new wxButton( parent, ecID_TEMPLATES_DIALOG_DETAILS, _("&Details >>"), wxDefaultPosition, wxDefaultSize, 0 );    item12->Add( item15, 0, wxALIGN_CENTRE|wxALL, 5 );    item5->Add( item12, 0, wxALIGN_CENTRE|wxALL, 5 );    item0->Add( item5, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxALL, 0 );    wxStaticText *item16 = new wxStaticText( parent, ecID_TEMPLATES_DIALOG_PACKAGES_MSG, _("&Packages in selected template:"), wxDefaultPosition, wxDefaultSize, 0 );    wxTextCtrl *item17 = new wxTextCtrl( parent, ecID_TEMPLATES_DIALOG_PACKAGES, _(""), wxDefaultPosition, wxSize(90,100), wxTE_MULTILINE|wxTE_READONLY );    // Don't add these yet (until press Details)    //item0->Add( item16, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 );    //item0->Add( item17, 1, wxGROW|wxALIGN_CENTER_VERTICAL|wxALL, 5 );    item16->Show(FALSE);    item17->Show(FALSE);#ifdef __WXGTK__    wxButton *contextButton = new wxContextHelpButton( parent );    item12->Add( contextButton, 0, wxALIGN_CENTRE|wxALL, 5 );#endif    parent->SetAutoLayout( TRUE );    parent->SetSizer( item0 );    parent->Layout();    item0->Fit( parent );    //item0->SetSizeHints( parent );    // Add context-sensitive help text    parent->FindWindow( ecID_TEMPLATES_DIALOG_HARDWARE_TEMPLATES )->SetHelpText(_("Selects from the set of available hardware templates."));    parent->FindWindow( ecID_TEMPLATES_DIALOG_HARDWARE_DESCRIPTION )->SetHelpText(_("Gives a brief description of the currently selected hardware template."));    parent->FindWindow( ecID_TEMPLATES_DIALOG_PACKAGE_TEMPLATES )->SetHelpText(_("Selects from the set of available package templates."));    parent->FindWindow( ecID_TEMPLATES_DIALOG_VERSION )->SetHelpText(_("Selects the version of the currently selected template."));    parent->FindWindow( ecID_TEMPLATES_DIALOG_PACKAGE_DESCRIPTION )->SetHelpText(_("Gives a brief description of the currently selected package template."));    parent->FindWindow( ecID_TEMPLATES_DIALOG_PACKAGES )->SetHelpText(_("Lists the packages contained in the currently selected template."));    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."));    parent->FindWindow( ecID_TEMPLATES_DIALOG_DETAILS )->SetHelpText(_("Shows or hides a portion of the dialog that provides details of the contents of the currently selected template."));#if __WXGTK__    parent->FindWindow( wxID_CONTEXT_HELP )->SetHelpText(_("Invokes context-sensitive help for the clicked-on window."));#endif	// Add validators	parent->FindWindow( ecID_TEMPLATES_DIALOG_PACKAGE_DESCRIPTION )->SetValidator(wxGenericValidator(& m_strCdlTemplateDescription));	parent->FindWindow( ecID_TEMPLATES_DIALOG_HARDWARE_DESCRIPTION )->SetValidator(wxGenericValidator(& m_strCdlHardwareDescription));	parent->FindWindow( ecID_TEMPLATES_DIALOG_PACKAGES)->SetValidator(wxGenericValidator(& m_strCdlTemplatePackages));    PopulateControls();}// function which is called by quick sortstatic int wxStringCompareFunction(const void *first, const void *second){  wxString *strFirst = (wxString *)first;  wxString *strSecond = (wxString *)second;  return wxStricmp(strFirst->c_str(), strSecond->c_str());}void ecTemplatesDialog::PopulateControls(){    ecConfigToolDoc* doc = wxGetApp().GetConfigToolDoc();    m_hardware = doc->GetCdlConfig ()->get_hardware ().c_str();    wxComboBox* cdlHardwareCtrl = (wxComboBox*)  FindWindow( ecID_TEMPLATES_DIALOG_HARDWARE_TEMPLATES ) ;    wxChoice* cdlPackageCtrl = (wxChoice*)  FindWindow( ecID_TEMPLATES_DIALOG_PACKAGE_TEMPLATES ) ;	const std::vector<std::string> & targets = doc->GetCdlPkgData ()->get_targets ();	std::vector<std::string>::const_iterator target_i;    // Old code: let the combo box do the sorting. But not all platforms implement this.#if 0    // populate the hardware combo box    int nIndex = 0;	for (target_i = targets.begin (); target_i != targets.end (); target_i++)	{		const std::vector<std::string> & aliases = doc->GetCdlPkgData ()->get_target_aliases (* target_i);		// use the first alias (if any) as the description		wxString strTargetDescription = aliases.size () ? aliases [0].c_str () : target_i->c_str ();		cdlHardwareCtrl->Append(strTargetDescription, (void*) &(*target_i)); // store the target iterator        std::string str(* (target_i));		if (m_hardware == str.c_str())            // if current target...        {            int sel = 0;            int i;            for (i = 0; i <= nIndex; i++)                if (cdlHardwareCtrl->GetClientData(i) == (void*) &(*target_i))                    sel = i;			cdlHardwareCtrl->SetSelection (sel); // ...select the string        }        nIndex ++;	}#else    // New code: sort, then add to combobox. How do we keep track of the target iterators?    // could use hash table, assuming that each string is unique

⌨️ 快捷键说明

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