dbgrptg.cpp
来自「A*算法 A*算法 A*算法 A*算法A*算法A*算法」· C++ 代码 · 共 516 行 · 第 1/2 页
CPP
516 行
///////////////////////////////////////////////////////////////////////////////
// Name: src/generic/dbgrptg.cpp
// Purpose: implementation of wxDebugReportPreviewStd
// Author: Vadim Zeitlin, Andrej Putrin
// Modified by:
// Created: 2005-01-21
// RCS-ID: $Id: dbgrptg.cpp,v 1.12 2005/07/21 16:22:28 ABX Exp $
// Copyright: (c) 2005 Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr>
// License: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
// ============================================================================
// declarations
// ============================================================================
// ----------------------------------------------------------------------------
// headers
// ----------------------------------------------------------------------------
#include "wx/wxprec.h"
#ifdef __BORLANDC__
#pragma hdrstop
#endif
#ifndef WX_PRECOMP
#include "wx/sizer.h"
#include "wx/checklst.h"
#include "wx/textctrl.h"
#endif // WX_PRECOMP
#if wxUSE_DEBUGREPORT && wxUSE_XML
#include "wx/debugrpt.h"
#include "wx/intl.h"
#include "wx/filename.h"
#include "wx/ffile.h"
#include "wx/mimetype.h"
#include "wx/statline.h"
#include "wx/stattext.h"
#include "wx/filedlg.h"
#include "wx/valtext.h"
#ifdef __WXMSW__
#include "wx/evtloop.h" // for SetCriticalWindow()
#endif // __WXMSW__
// ----------------------------------------------------------------------------
// wxDumpPreviewDlg: simple class for showing ASCII preview of dump files
// ----------------------------------------------------------------------------
class wxDumpPreviewDlg : public wxDialog
{
public:
wxDumpPreviewDlg(wxWindow *parent,
const wxString& title,
const wxString& text);
private:
// the text we show
wxTextCtrl *m_text;
DECLARE_NO_COPY_CLASS(wxDumpPreviewDlg)
};
wxDumpPreviewDlg::wxDumpPreviewDlg(wxWindow *parent,
const wxString& title,
const wxString& text)
: wxDialog(parent, wxID_ANY, title,
wxDefaultPosition, wxDefaultSize,
wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER)
{
// create controls
// ---------------
// use wxTE_RICH2 style to avoid 64kB limit under MSW and display big files
// faster than with wxTE_RICH
m_text = new wxTextCtrl(this, wxID_ANY, wxEmptyString,
wxPoint(0, 0), wxDefaultSize,
wxTE_MULTILINE |
wxTE_READONLY |
wxTE_NOHIDESEL |
wxTE_RICH2);
m_text->SetValue(text);
// use fixed-width font
m_text->SetFont(wxFont(12, wxFONTFAMILY_TELETYPE,
wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL));
wxButton *btnClose = new wxButton(this, wxID_CANCEL, _("Close"));
// layout them
// -----------
wxSizer *sizerTop = new wxBoxSizer(wxVERTICAL),
*sizerBtns = new wxBoxSizer(wxHORIZONTAL);
sizerBtns->Add(btnClose, 0, 0, 1);
sizerTop->Add(m_text, 1, wxEXPAND);
sizerTop->Add(sizerBtns, 0, wxALIGN_RIGHT | wxTOP | wxBOTTOM | wxRIGHT, 1);
// set the sizer &c
// ----------------
// make the text window bigger to show more contents of the file
sizerTop->SetItemMinSize(m_text, 600, 300);
SetSizer(sizerTop);
Layout();
Fit();
m_text->SetFocus();
}
// ----------------------------------------------------------------------------
// wxDumpOpenExternalDlg: choose a command for opening the given file
// ----------------------------------------------------------------------------
class wxDumpOpenExternalDlg : public wxDialog
{
public:
wxDumpOpenExternalDlg(wxWindow *parent, const wxFileName& filename);
// return the command chosed by user to open this file
const wxString& GetCommand() const { return m_command; }
wxString m_command;
private:
#if wxUSE_FILEDLG
void OnBrowse(wxCommandEvent& event);
#endif // wxUSE_FILEDLG
DECLARE_EVENT_TABLE()
DECLARE_NO_COPY_CLASS(wxDumpOpenExternalDlg)
};
BEGIN_EVENT_TABLE(wxDumpOpenExternalDlg, wxDialog)
#if wxUSE_FILEDLG
EVT_BUTTON(wxID_MORE, wxDumpOpenExternalDlg::OnBrowse)
#endif
END_EVENT_TABLE()
wxDumpOpenExternalDlg::wxDumpOpenExternalDlg(wxWindow *parent,
const wxFileName& filename)
: wxDialog(parent,
wxID_ANY,
wxString::Format
(
_("Open file \"%s\""),
filename.GetFullPath().c_str()
))
{
// create controls
// ---------------
wxSizer *sizerTop = new wxBoxSizer(wxVERTICAL);
sizerTop->Add(new wxStaticText(this, wxID_ANY,
wxString::Format
(
_("Enter command to open file \"%s\":"),
filename.GetFullName().c_str()
)),
wxSizerFlags().Border());
wxSizer *sizerH = new wxBoxSizer(wxHORIZONTAL);
wxTextCtrl *command = new wxTextCtrl
(
this,
wxID_ANY,
wxEmptyString,
wxDefaultPosition,
wxSize(250, wxDefaultCoord),
0
#if wxUSE_VALIDATORS
,wxTextValidator(wxFILTER_NONE, &m_command)
#endif
);
sizerH->Add(command,
wxSizerFlags(1).Align(wxALIGN_CENTER_VERTICAL));
#if wxUSE_FILEDLG
wxButton *browse = new wxButton(this, wxID_MORE, wxT(">>"),
wxDefaultPosition, wxDefaultSize,
wxBU_EXACTFIT);
sizerH->Add(browse,
wxSizerFlags(0).Align(wxALIGN_CENTER_VERTICAL). Border(wxLEFT));
#endif // wxUSE_FILEDLG
sizerTop->Add(sizerH, wxSizerFlags(0).Expand().Border());
sizerTop->Add(new wxStaticLine(this), wxSizerFlags().Expand().Border());
sizerTop->Add(CreateStdDialogButtonSizer(wxOK | wxCANCEL),
wxSizerFlags().Align(wxALIGN_RIGHT).Border());
// set the sizer &c
// ----------------
SetSizer(sizerTop);
Layout();
Fit();
command->SetFocus();
}
#if wxUSE_FILEDLG
void wxDumpOpenExternalDlg::OnBrowse(wxCommandEvent& )
{
wxFileName fname(m_command);
wxFileDialog dlg(this,
wxFileSelectorPromptStr,
fname.GetPathWithSep(),
fname.GetFullName()
#ifdef __WXMSW__
, _("Executable files (*.exe)|*.exe|All files (*.*)|*.*||")
#endif // __WXMSW__
);
if ( dlg.ShowModal() == wxID_OK )
{
m_command = dlg.GetPath();
TransferDataToWindow();
}
}
#endif // wxUSE_FILEDLG
// ----------------------------------------------------------------------------
// wxDebugReportDialog: class showing debug report to the user
// ----------------------------------------------------------------------------
class wxDebugReportDialog : public wxDialog
{
public:
wxDebugReportDialog(wxDebugReport& dbgrpt);
virtual bool TransferDataToWindow();
virtual bool TransferDataFromWindow();
private:
void OnView(wxCommandEvent& );
void OnViewUpdate(wxUpdateUIEvent& );
void OnOpen(wxCommandEvent& );
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?