From 0a931d3f455946355b77917cbaea21ff86706f43 Mon Sep 17 00:00:00 2001 From: Rodrigo Braz Monteiro Date: Tue, 11 Mar 2008 23:58:43 +0000 Subject: [PATCH] wxSTC SUCKS. Note: never call SetWindowStyle() on it, or it'll break the keyboard handling. Originally committed to SVN as r2025. --- aegilib/aegilib.vcproj | 4 ++ aegilib/include/aegilib/section_entry.h | 4 +- .../include/aegilib/section_entry_dialogue.h | 16 +++---- aegilib/src/formats/format_ass.h | 14 +++--- aegilib/src/section_entry.cpp | 47 +++++++++++++++++++ aegisub/scintilla_text_ctrl.cpp | 2 +- 6 files changed, 70 insertions(+), 17 deletions(-) create mode 100644 aegilib/src/section_entry.cpp diff --git a/aegilib/aegilib.vcproj b/aegilib/aegilib.vcproj index 9c7d8bfef..b526eca75 100644 --- a/aegilib/aegilib.vcproj +++ b/aegilib/aegilib.vcproj @@ -304,6 +304,10 @@ RelativePath=".\src\section.cpp" > + + diff --git a/aegilib/include/aegilib/section_entry.h b/aegilib/include/aegilib/section_entry.h index cc8c95aa7..a071d3884 100644 --- a/aegilib/include/aegilib/section_entry.h +++ b/aegilib/include/aegilib/section_entry.h @@ -34,6 +34,7 @@ // #pragma once +#include "aegistring.h" namespace Aegilib { @@ -55,7 +56,8 @@ namespace Aegilib { // Section entry class class SectionEntry { - private: + protected: + const String& EmptyString() const; public: virtual ~SectionEntry() {} diff --git a/aegilib/include/aegilib/section_entry_dialogue.h b/aegilib/include/aegilib/section_entry_dialogue.h index 2a43d021e..ed0bc26eb 100644 --- a/aegilib/include/aegilib/section_entry_dialogue.h +++ b/aegilib/include/aegilib/section_entry_dialogue.h @@ -66,7 +66,7 @@ namespace Aegilib { virtual bool HasMargins() const { return false; } // Read accessors - virtual String GetText() const { ThrowUnsupported(); return L""; } + virtual const String& GetText() const { ThrowUnsupported(); return EmptyString(); } virtual Time GetStartTime() const { ThrowUnsupported(); return 0; } virtual Time GetEndTime() const { ThrowUnsupported(); return 0; } virtual int GetStartFrame() const { ThrowUnsupported(); return 0; } @@ -74,12 +74,12 @@ namespace Aegilib { virtual bool IsComment() const { ThrowUnsupported(); return false; } virtual int GetLayer() const { ThrowUnsupported(); return 0; } virtual int GetMargin(int n) const { ThrowUnsupported(); return n; } - virtual String GetStyle() const { ThrowUnsupported(); return L""; } - virtual String GetActor() const { ThrowUnsupported(); return L""; } - virtual String GetUserField() const { ThrowUnsupported(); return L""; } + virtual const String& GetStyle() const { ThrowUnsupported(); return EmptyString(); } + virtual const String& GetActor() const { ThrowUnsupported(); return EmptyString(); } + virtual const String& GetUserField() const { ThrowUnsupported(); return EmptyString(); } // Write acessors - virtual void SetText(String text) { (void) text; ThrowUnsupported(); } + virtual void SetText(const String& text) { (void) text; ThrowUnsupported(); } virtual void SetStartTime(Time start) { (void) start; ThrowUnsupported(); } virtual void SetEndTime(Time end) { (void) end; ThrowUnsupported(); } virtual void SetStartFrame(int start) { (void) start; ThrowUnsupported(); } @@ -87,9 +87,9 @@ namespace Aegilib { virtual void SetComment(bool isComment) { (void) isComment; ThrowUnsupported(); } virtual void SetLayer(int layer) { (void) layer; ThrowUnsupported(); } virtual void SetMargin(int margin,int value) { (void) margin; (void) value; ThrowUnsupported(); } - virtual void SetStyle(String style) { (void) style; ThrowUnsupported(); } - virtual void SetActor(String actor) { (void) actor; ThrowUnsupported(); } - virtual void SetUserField(String userField) { (void) userField; ThrowUnsupported(); } + virtual void SetStyle(const String& style) { (void) style; ThrowUnsupported(); } + virtual void SetActor(const String& actor) { (void) actor; ThrowUnsupported(); } + virtual void SetUserField(const String& userField) { (void) userField; ThrowUnsupported(); } }; }; diff --git a/aegilib/src/formats/format_ass.h b/aegilib/src/formats/format_ass.h index 54931df35..ffeb24a07 100644 --- a/aegilib/src/formats/format_ass.h +++ b/aegilib/src/formats/format_ass.h @@ -101,25 +101,25 @@ namespace Aegilib { bool HasMargins() const { return true; } // Read accessors - String GetText() const { return text; } + const String& GetText() const { return text; } Time GetStartTime() const { return start; } Time GetEndTime() const { return end; } bool IsComment() const { return isComment; } int GetLayer() const { return layer; } int GetMargin(int n) const { return margin[n]; } - String GetStyle() const { return style; } - String GetActor() const { return actor; } - String GetUserField() const { return effect; } + const String& GetStyle() const { return style; } + const String& GetActor() const { return actor; } + const String& GetUserField() const { return effect; } // Write acessors - void SetText(String setText) { text = setText; } + void SetText(const String &setText) { text = setText; } void SetStartTime(Time setStart) { start = setStart; } void SetEndTime(Time setEnd) { end = setEnd; } void SetComment(bool _isComment) { isComment = _isComment; } void SetLayer(int _layer) { layer = _layer; } void SetMargin(int _margin,int value) { margin[_margin] = value; } - void SetStyle(String _style) { style = _style; } - void SetUserField(String userField) { effect = userField; } + void SetStyle(const String &_style) { style = _style; } + void SetUserField(const String &userField) { effect = userField; } }; // Style diff --git a/aegilib/src/section_entry.cpp b/aegilib/src/section_entry.cpp new file mode 100644 index 000000000..23109a7b6 --- /dev/null +++ b/aegilib/src/section_entry.cpp @@ -0,0 +1,47 @@ +// Copyright (c) 2008, Rodrigo Braz Monteiro +// 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/AEGILIB +// +// Website: http://www.aegisub.net +// Contact: mailto:amz@aegisub.net +// + + +#include "section_entry.h" +using namespace Aegilib; + + +///////////////////////////////// +// Returns a static empty string +const String& SectionEntry::EmptyString() const +{ + static const String str = _T(""); + return str; +} diff --git a/aegisub/scintilla_text_ctrl.cpp b/aegisub/scintilla_text_ctrl.cpp index 33675fde9..6c2d87e0b 100644 --- a/aegisub/scintilla_text_ctrl.cpp +++ b/aegisub/scintilla_text_ctrl.cpp @@ -45,7 +45,7 @@ ScintillaTextCtrl::ScintillaTextCtrl(wxWindow* parent, wxWindowID id, const wxString& value, const wxPoint& pos, const wxSize& size, long style, const wxValidator& validator, const wxString& name) : wxStyledTextCtrl(parent, id, pos, size, 0, value) { - SetWindowStyle(style); + //SetWindowStyle(style); }