forked from mia/Aegisub
Add a basic "log window", this will be more polished and useful later on for now it's just something quick and dirty.
There are a few issues to fix: * Delete the pointer in frame_main from the modless dialog. * Fix string storage in the logging class. * Close button doesn't work. Originally committed to SVN as r4406.
This commit is contained in:
parent
fc9e01c68a
commit
719b7c2281
6 changed files with 205 additions and 0 deletions
|
@ -233,6 +233,7 @@ aegisub_2_2_SOURCES = \
|
||||||
dialog_fonts_collector.cpp \
|
dialog_fonts_collector.cpp \
|
||||||
dialog_jumpto.cpp \
|
dialog_jumpto.cpp \
|
||||||
dialog_kara_timing_copy.cpp \
|
dialog_kara_timing_copy.cpp \
|
||||||
|
dialog_log.cpp \
|
||||||
dialog_paste_over.cpp \
|
dialog_paste_over.cpp \
|
||||||
dialog_progress.cpp \
|
dialog_progress.cpp \
|
||||||
dialog_properties.cpp \
|
dialog_properties.cpp \
|
||||||
|
|
121
aegisub/src/dialog_log.cpp
Normal file
121
aegisub/src/dialog_log.cpp
Normal file
|
@ -0,0 +1,121 @@
|
||||||
|
// Copyright (c) 2010, Amar Takhar
|
||||||
|
// All rights reserved.
|
||||||
|
//
|
||||||
|
// Redistribution and use in source and binary forms, with or without
|
||||||
|
// modification, are permitted provided that the following conditions are met:
|
||||||
|
//
|
||||||
|
// * Redistributions of source code must retain the above copyright notice,
|
||||||
|
// this list of conditions and the following disclaimer.
|
||||||
|
// * Redistributions in binary form must reproduce the above copyright notice,
|
||||||
|
// this list of conditions and the following disclaimer in the documentation
|
||||||
|
// and/or other materials provided with the distribution.
|
||||||
|
// * Neither the name of the Aegisub Group nor the names of its contributors
|
||||||
|
// may be used to endorse or promote products derived from this software
|
||||||
|
// without specific prior written permission.
|
||||||
|
//
|
||||||
|
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||||
|
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
|
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||||
|
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||||
|
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||||
|
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||||
|
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||||
|
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||||
|
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
|
// POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
//
|
||||||
|
// Aegisub Project http://www.aegisub.org/
|
||||||
|
//
|
||||||
|
// $Id$
|
||||||
|
|
||||||
|
/// @file dialog_log.cpp
|
||||||
|
/// @brief Log window.
|
||||||
|
/// @ingroup libaegisub
|
||||||
|
///
|
||||||
|
|
||||||
|
|
||||||
|
////////////
|
||||||
|
// Includes
|
||||||
|
#include "config.h"
|
||||||
|
|
||||||
|
#ifndef AGI_PRE
|
||||||
|
#include <wx/button.h>
|
||||||
|
#include <wx/panel.h>
|
||||||
|
#include <wx/sizer.h>
|
||||||
|
#include <wx/statline.h>
|
||||||
|
#include <wx/stattext.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <time.h>
|
||||||
|
#include "dialog_log.h"
|
||||||
|
|
||||||
|
/// @brief Constructor
|
||||||
|
/// @param parent Parent frame.
|
||||||
|
LogWindow::LogWindow(wxWindow *parent)
|
||||||
|
: wxDialog (parent, -1, _("Log window"), wxDefaultPosition, wxSize(700,300), wxCAPTION | wxCLOSE_BOX | wxRESIZE_BORDER, _("Log window"))
|
||||||
|
{
|
||||||
|
// Text sizer
|
||||||
|
wxSizer *sizer_text = new wxBoxSizer(wxVERTICAL);
|
||||||
|
|
||||||
|
wxTextCtrl *text_ctrl = new wxTextCtrl(this, wxID_ANY, wxEmptyString ,wxDefaultPosition, wxSize(700,300), wxTE_MULTILINE|wxTE_READONLY);
|
||||||
|
wxTextAttr attr;
|
||||||
|
attr.SetFont(wxFont(8, wxFONTFAMILY_TELETYPE, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL));
|
||||||
|
text_ctrl->SetDefaultStyle(attr);
|
||||||
|
sizer_text->Add(text_ctrl, 1, wxEXPAND);
|
||||||
|
|
||||||
|
wxSizer *sizer_button = new wxBoxSizer(wxHORIZONTAL);
|
||||||
|
sizer_button->Add(new wxButton(this, wxID_CLOSE), 0, wxALIGN_RIGHT | wxALL, 2);
|
||||||
|
|
||||||
|
|
||||||
|
wxSizer *sizer = new wxBoxSizer(wxVERTICAL);
|
||||||
|
sizer->Add(sizer_text, 1 ,wxEXPAND|wxALL, 0);
|
||||||
|
sizer->Add(sizer_button, 0 ,wxEXPAND|wxALL, 0);
|
||||||
|
sizer->SetSizeHints(this);
|
||||||
|
SetSizer(sizer);
|
||||||
|
|
||||||
|
emit_log = new EmitLog(text_ctrl);
|
||||||
|
emit_log->Enable();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// @brief Destructor
|
||||||
|
LogWindow::~LogWindow() {
|
||||||
|
emit_log->Disable();
|
||||||
|
delete emit_log;
|
||||||
|
}
|
||||||
|
|
||||||
|
LogWindow::EmitLog::EmitLog(wxTextCtrl *t): text_ctrl(t) {
|
||||||
|
const agi::log::Sink *sink = agi::log::log->GetSink();
|
||||||
|
|
||||||
|
for (unsigned int i=0; i < sink->size(); i++) {
|
||||||
|
Write((*sink)[i]);
|
||||||
|
}
|
||||||
|
delete sink;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void LogWindow::EmitLog::Write(agi::log::SinkMessage *sm) {
|
||||||
|
tm tmtime;
|
||||||
|
localtime_r(&sm->tv.tv_sec, &tmtime);
|
||||||
|
wxString log = wxString::Format("%c %02d:%02d:%02d %ld <%-25s> [%s:%s:%d] %s\n",
|
||||||
|
agi::log::Severity_ID[sm->severity],
|
||||||
|
tmtime.tm_hour,
|
||||||
|
tmtime.tm_min,
|
||||||
|
tmtime.tm_sec,
|
||||||
|
sm->tv.tv_usec,
|
||||||
|
sm->section,
|
||||||
|
sm->file,
|
||||||
|
sm->func,
|
||||||
|
sm->line,
|
||||||
|
strndup(sm->message, sm->len));
|
||||||
|
|
||||||
|
text_ctrl->AppendText(log);
|
||||||
|
}
|
||||||
|
|
||||||
|
void LogWindow::EmitLog::log(agi::log::SinkMessage *sm) {
|
||||||
|
Write(sm);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
71
aegisub/src/dialog_log.h
Normal file
71
aegisub/src/dialog_log.h
Normal file
|
@ -0,0 +1,71 @@
|
||||||
|
// Copyright (c) 2010, Amar Takhar
|
||||||
|
// All rights reserved.
|
||||||
|
//
|
||||||
|
// Redistribution and use in source and binary forms, with or without
|
||||||
|
// modification, are permitted provided that the following conditions are met:
|
||||||
|
//
|
||||||
|
// * Redistributions of source code must retain the above copyright notice,
|
||||||
|
// this list of conditions and the following disclaimer.
|
||||||
|
// * Redistributions in binary form must reproduce the above copyright notice,
|
||||||
|
// this list of conditions and the following disclaimer in the documentation
|
||||||
|
// and/or other materials provided with the distribution.
|
||||||
|
// * Neither the name of the Aegisub Group nor the names of its contributors
|
||||||
|
// may be used to endorse or promote products derived from this software
|
||||||
|
// without specific prior written permission.
|
||||||
|
//
|
||||||
|
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||||
|
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
|
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||||
|
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||||
|
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||||
|
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||||
|
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||||
|
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||||
|
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
|
// POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
//
|
||||||
|
// Aegisub Project http://www.aegisub.org/
|
||||||
|
//
|
||||||
|
// $Id$
|
||||||
|
|
||||||
|
/// @file dialog_log.h
|
||||||
|
/// @see dialog_log.cpp
|
||||||
|
/// @ingroup libaegisub
|
||||||
|
///
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
////////////
|
||||||
|
// Includes
|
||||||
|
#ifndef AGI_PRE
|
||||||
|
#include <wx/dialog.h>
|
||||||
|
#include <wx/textctrl.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <libaegisub/log.h>
|
||||||
|
|
||||||
|
/// @class AboutScreen
|
||||||
|
/// @brief About dialogue.
|
||||||
|
|
||||||
|
class LogWindow: public wxDialog {
|
||||||
|
public:
|
||||||
|
|
||||||
|
class EmitLog: public agi::log::Emitter {
|
||||||
|
wxTextCtrl *text_ctrl;
|
||||||
|
void Write(agi::log::SinkMessage *sm);
|
||||||
|
public:
|
||||||
|
EmitLog(wxTextCtrl *t);
|
||||||
|
void Prime();
|
||||||
|
void Set(wxTextCtrl *text_ctrl_p) { text_ctrl = text_ctrl_p; }
|
||||||
|
void log(agi::log::SinkMessage *sm);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
LogWindow(wxWindow *parent);
|
||||||
|
~LogWindow();
|
||||||
|
private:
|
||||||
|
EmitLog *emit_log;
|
||||||
|
};
|
||||||
|
|
|
@ -570,6 +570,7 @@ void FrameMain::InitMenu() {
|
||||||
#endif
|
#endif
|
||||||
AppendBitmapMenuItem(helpMenu,Menu_Help_Check_Updates, _("&Check for Updates..."), _("Check to see if there is a new version of Aegisub available"),GETIMAGE(blank_button_16));
|
AppendBitmapMenuItem(helpMenu,Menu_Help_Check_Updates, _("&Check for Updates..."), _("Check to see if there is a new version of Aegisub available"),GETIMAGE(blank_button_16));
|
||||||
AppendBitmapMenuItem(helpMenu,Menu_Help_About, _("&About..."), _("About Aegisub"),GETIMAGE(about_menu_16));
|
AppendBitmapMenuItem(helpMenu,Menu_Help_About, _("&About..."), _("About Aegisub"),GETIMAGE(about_menu_16));
|
||||||
|
AppendBitmapMenuItem(helpMenu,Menu_Help_Log, _("&Log window..."), _("Aegisub event log"),GETIMAGE(about_menu_16));
|
||||||
MenuBar->Append(helpMenu, _("&Help"));
|
MenuBar->Append(helpMenu, _("&Help"));
|
||||||
|
|
||||||
// Set the bar as this frame's
|
// Set the bar as this frame's
|
||||||
|
|
|
@ -203,6 +203,7 @@ private:
|
||||||
void OnMenuOpen (wxMenuEvent &event);
|
void OnMenuOpen (wxMenuEvent &event);
|
||||||
void OnExit(wxCommandEvent &WXUNUSED(event));
|
void OnExit(wxCommandEvent &WXUNUSED(event));
|
||||||
void OnAbout (wxCommandEvent &event);
|
void OnAbout (wxCommandEvent &event);
|
||||||
|
void OnLog (wxCommandEvent &event);
|
||||||
void OnCheckUpdates (wxCommandEvent &event);
|
void OnCheckUpdates (wxCommandEvent &event);
|
||||||
void OnContents (wxCommandEvent &event);
|
void OnContents (wxCommandEvent &event);
|
||||||
void OnFiles (wxCommandEvent &event);
|
void OnFiles (wxCommandEvent &event);
|
||||||
|
@ -686,6 +687,7 @@ enum {
|
||||||
/// DOCME
|
/// DOCME
|
||||||
Menu_Help_About,
|
Menu_Help_About,
|
||||||
|
|
||||||
|
Menu_Help_Log,
|
||||||
|
|
||||||
/// DOCME
|
/// DOCME
|
||||||
Menu_Subs_Snap_Start_To_Video,
|
Menu_Subs_Snap_Start_To_Video,
|
||||||
|
|
|
@ -66,6 +66,7 @@
|
||||||
#include "dialog_fonts_collector.h"
|
#include "dialog_fonts_collector.h"
|
||||||
#include "dialog_jumpto.h"
|
#include "dialog_jumpto.h"
|
||||||
#include "dialog_kara_timing_copy.h"
|
#include "dialog_kara_timing_copy.h"
|
||||||
|
#include "dialog_log.h"
|
||||||
#include "dialog_progress.h"
|
#include "dialog_progress.h"
|
||||||
#include "dialog_properties.h"
|
#include "dialog_properties.h"
|
||||||
#include "dialog_resample.h"
|
#include "dialog_resample.h"
|
||||||
|
@ -212,6 +213,7 @@ BEGIN_EVENT_TABLE(FrameMain, wxFrame)
|
||||||
EVT_MENU(Menu_Help_IRCChannel, FrameMain::OnIRCChannel)
|
EVT_MENU(Menu_Help_IRCChannel, FrameMain::OnIRCChannel)
|
||||||
EVT_MENU(Menu_Help_Check_Updates, FrameMain::OnCheckUpdates)
|
EVT_MENU(Menu_Help_Check_Updates, FrameMain::OnCheckUpdates)
|
||||||
EVT_MENU(Menu_Help_About, FrameMain::OnAbout)
|
EVT_MENU(Menu_Help_About, FrameMain::OnAbout)
|
||||||
|
EVT_MENU(Menu_Help_Log, FrameMain::OnLog)
|
||||||
|
|
||||||
EVT_MENU(Menu_View_Language, FrameMain::OnChooseLanguage)
|
EVT_MENU(Menu_View_Language, FrameMain::OnChooseLanguage)
|
||||||
EVT_MENU(Menu_View_Standard, FrameMain::OnViewStandard)
|
EVT_MENU(Menu_View_Standard, FrameMain::OnViewStandard)
|
||||||
|
@ -612,6 +614,13 @@ void FrameMain::OnAbout(wxCommandEvent &event) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// @brief Open log window
|
||||||
|
/// @param event
|
||||||
|
void FrameMain::OnLog(wxCommandEvent &event) {
|
||||||
|
LogWindow *log = new LogWindow(this);
|
||||||
|
log->Show(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/// @brief Open check updates
|
/// @brief Open check updates
|
||||||
/// @param event
|
/// @param event
|
||||||
|
|
Loading…
Reference in a new issue