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

📄 settingsdlg.cpp

📁 ecos实时嵌入式操作系统
💻 CPP
📖 第 1 页 / 共 4 页
字号:
//####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####// appsettings.cpp :////===========================================================================//#####DESCRIPTIONBEGIN####//// Author(s):   julians// Contact(s):  julians// Date:        2000/09/11// Version:     $Id: settingsdlg.cpp,v 1.16 2002/02/15 17:40:01 julians Exp $// Purpose:// Description: Implementation file for ecSettingsDialog// Requires:// Provides:// See also:// Known bugs:// Usage:////####DESCRIPTIONEND####////===========================================================================#ifdef __GNUG__    #pragma implementation "settingsdlg.cpp"#endif#include "ecpch.h"#ifdef __BORLANDC__    #pragma hdrstop#endif#include "wx/spinctrl.h"#include "wx/notebook.h"#include "wx/cshelp.h"#include "wx/valgen.h"#include "wx/fontdlg.h"#include "wx/mimetype.h"#include "settingsdlg.h"#include "configtool.h"#include "configtooldoc.h"#include "configtoolview.h"// For now, we're not implementing the paths page on the settings dialog,// but probably we should eventually for consistency and ease of use#define ecUSE_PATHS_PAGE 0#define ecUSE_RUN_PAGE 1/* * Settings dialog */IMPLEMENT_CLASS(ecSettingsDialog, wxDialog)BEGIN_EVENT_TABLE(ecSettingsDialog, wxDialog)    EVT_BUTTON(wxID_OK, ecSettingsDialog::OnOK)    EVT_BUTTON(wxID_HELP, ecSettingsDialog::OnHelp)    EVT_NOTEBOOK_PAGE_CHANGED(-1, ecSettingsDialog::OnPageChange)END_EVENT_TABLE()// GTK+ widgets seem to be chunkier than WIN32's, so give 'em more elbow-room#ifdef __WXMSW__#define PROPERTY_DIALOG_WIDTH   380#define PROPERTY_DIALOG_HEIGHT  420#else#define PROPERTY_DIALOG_WIDTH   550 // 460#define PROPERTY_DIALOG_HEIGHT  480#endif// For 400x400 settings dialog, size your panels to about 375x325 in dialog editor// (209 x 162 dialog units)ecSettingsDialog::ecSettingsDialog(wxWindow* parent):    wxDialog(){    SetExtraStyle(wxDIALOG_EX_CONTEXTHELP);    wxDialog::Create(parent, ecID_SETTINGS_DIALOG, wxGetApp().GetSettings().GetAppName() + wxT(" Settings"), wxPoint(0, 0), wxSize(PROPERTY_DIALOG_WIDTH, PROPERTY_DIALOG_HEIGHT));    // Under MSW, we don't seem to be able to react to a click on the dialog background (no    // event is generated).    SetHelpText(_("The settings dialog provides the ability to change a variety of settings."));    wxScreenDC dc;    wxSize ppi = dc.GetPPI();    //double scaleFactor = ((double) charH) / 13.0;    double scaleFactor = ((double) ppi.y) / 96.0;    // Fudge the scale factor to make the dialog slightly smaller,    // otherwise it's a bit big. (We're assuming that most displays    // are 96 or 120 ppi).    if (ppi.y == 120)        scaleFactor = 1.14;    int dialogWidth = (int)(PROPERTY_DIALOG_WIDTH * scaleFactor);    int dialogHeight = (int)(PROPERTY_DIALOG_HEIGHT * scaleFactor);    SetSize(dialogWidth, dialogHeight);            m_displayOptions = NULL;    m_notebook = new wxNotebook(this, ecID_SETTINGS_NOTEBOOK,         wxPoint(2, 2), wxSize(PROPERTY_DIALOG_WIDTH - 4, PROPERTY_DIALOG_HEIGHT - 4));    m_displayOptions = new ecDisplayOptionsDialog(m_notebook);    m_notebook->AddPage(m_displayOptions, wxT("Display"));    m_displayOptions->TransferDataToWindow();    m_viewerOptions = new ecViewerOptionsDialog(m_notebook);    m_notebook->AddPage(m_viewerOptions, wxT("Viewers"));    m_viewerOptions->TransferDataToWindow();#if ecUSE_PATHS_PAGE    m_pathOptions = new ecPathOptionsDialog(m_notebook);    m_notebook->AddPage(m_pathOptions, wxT("Paths"));    m_pathOptions->TransferDataToWindow();#endif    m_conflictResolutionOptions = new ecConflictResolutionOptionsDialog(m_notebook);    m_notebook->AddPage(m_conflictResolutionOptions, wxT("Conflict Resolution"));    m_conflictResolutionOptions->TransferDataToWindow();#if ecUSE_RUN_PAGE    m_runOptions = new ecRunOptionsDialog(m_notebook);    m_notebook->AddPage(m_runOptions, wxT("Run Tests"));    m_runOptions->TransferDataToWindow();#endif    wxSizer *item0 = new wxBoxSizer( wxVERTICAL );    item0->Add( m_notebook, 1, wxGROW|wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT|wxTOP, 5 );    wxSizer *item1 = new wxBoxSizer( wxHORIZONTAL );    wxButton *okButton = new wxButton( this, wxID_OK, "&OK", wxDefaultPosition, wxDefaultSize, 0 );    item1->Add( okButton, 0, wxALIGN_CENTRE|wxALL, 5 );    wxButton *cancelButton = new wxButton( this, wxID_CANCEL, "&Cancel", wxDefaultPosition, wxDefaultSize, 0 );    item1->Add( cancelButton, 0, wxALIGN_CENTRE|wxALL, 5 );    wxButton *helpButton = new wxButton( this, wxID_HELP, "&Help", wxDefaultPosition, wxDefaultSize, 0 );    item1->Add( helpButton, 0, wxALIGN_CENTRE|wxALL, 5 );#ifdef __WXGTK__    // Context-sensitive help button (question mark)    wxButton *contextButton = new wxContextHelpButton( this );    item1->Add( contextButton, 0, wxALIGN_CENTRE|wxALL, 5 );#endif    // Necessary to add a spacer or the button highlight interferes with the notebook under wxGTK    item0->Add( 4, 4, 0, wxALIGN_CENTRE|wxALL, 0 );    item0->Add( item1, 0, wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL|wxALL, 0 );    this->SetAutoLayout( TRUE );    this->SetSizer( item0 );    okButton->SetDefault();    okButton->SetFocus();    Layout();    m_displayOptions->Layout();    m_viewerOptions->Layout();#if ecUSE_PATHS_PAGE    m_pathOptions->Layout();#endif    m_conflictResolutionOptions->Layout();#if ecUSE_RUN_PAGE    m_runOptions->Layout();#endif        okButton->SetHelpText(_("Closes the dialog and saves any changes you may have made."));    cancelButton->SetHelpText(_("Closes the dialog without saving any changes you have made."));    helpButton->SetHelpText(_("Invokes help for the selected dialog."));    Centre(wxBOTH);}void ecSettingsDialog::SetSelection(int sel){    m_notebook->SetSelection(sel);}void ecSettingsDialog::OnOK(wxCommandEvent& event){    ecSettings oldSettings(wxGetApp().GetSettings());    wxDialog::OnOK(event);    if (wxGetApp().GetSettings().m_bHex != oldSettings.m_bHex)    {        // Refresh the values window and currently selected properties        ecConfigToolHint hint(NULL, ecAllSaved);        if (wxGetApp().GetConfigToolDoc())            wxGetApp().GetConfigToolDoc()->UpdateAllViews (NULL, & hint);            }    if (wxGetApp().GetSettings().m_showMacroNames != oldSettings.m_showMacroNames)    {        ecConfigToolHint hint(NULL, ecNameFormatChanged);        if (wxGetApp().GetConfigToolDoc())            wxGetApp().GetConfigToolDoc()->UpdateAllViews (NULL, & hint);            }    }void ecSettingsDialog::OnHelp(wxCommandEvent& event){    int sel = m_notebook->GetSelection();    wxASSERT_MSG( (sel != -1), wxT("A notebook tab should always be selected."));    wxWindow* page = (wxWindow*) m_notebook->GetPage(sel);    wxString helpTopic;    if (page == m_displayOptions)    {        helpTopic = wxT("Display options dialog");    }    if (!helpTopic.IsEmpty())    {        wxGetApp().GetHelpController().KeywordSearch(helpTopic);    }}// This sets the text for the selected page, but doesn't help// when trying to click on a tab: we would expect the appropriate help// for that tab. We would need to look at the tabs to do this, from within OnContextHelp -// probably not worth it.void ecSettingsDialog::OnPageChange(wxNotebookEvent& event){    event.Skip();    int sel = m_notebook->GetSelection();    if (sel < 0)        return;    wxWindow* page = m_notebook->GetPage(sel);    if (page)    {        wxString helpText;        if (page == m_displayOptions)            helpText = _("The display options dialog allows you to change display-related options.");        else if (page == m_viewerOptions)            helpText = _("The viewer options dialog allows you to configure viewers.");#if ecUSE_PATHS_PAGE        else if (page == m_pathOptions)            helpText = _("The path options dialog allows you to change tool paths.");#endif        else if (page == m_conflictResolutionOptions)            helpText = _("The conflict resolution options dialog allows you to change options related to conflict resolution.");#if ecUSE_RUN_PAGE        else if (page == m_runOptions)            helpText = _("The run options dialog allows you to change options related to running tests.");#endif        m_notebook->SetHelpText(helpText);    }}bool ecSettingsDialog::TransferDataToWindow(){    m_displayOptions->TransferDataToWindow();    m_viewerOptions->TransferDataToWindow();#if ecUSE_PATHS_PAGE    m_pathOptions->TransferDataToWindow();#endif    m_conflictResolutionOptions->TransferDataToWindow();#if ecUSE_RUN_PAGE    m_runOptions->TransferDataToWindow();#endif    return TRUE;}bool ecSettingsDialog::TransferDataFromWindow()

⌨️ 快捷键说明

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