fix compilation after recent wxTextCtrl changes
notice that it has become unfortunately impossible (or at least much more difficult) to maintain compilation when wxRICHTEXT_DERIVES_FROM_TEXTCTRLBASE is unset so I simply removed it as the code wouldn't compile anyhow git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@41755 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
parent
ee2ec18e88
commit
343ae70d4c
@ -19,15 +19,7 @@
|
||||
#include "wx/scrolwin.h"
|
||||
#include "wx/caret.h"
|
||||
|
||||
#if wxCHECK_VERSION(2,7,0)
|
||||
#define wxRICHTEXT_DERIVES_FROM_TEXTCTRLBASE 1
|
||||
#else
|
||||
#define wxRICHTEXT_DERIVES_FROM_TEXTCTRLBASE 0
|
||||
#endif
|
||||
|
||||
#if wxRICHTEXT_DERIVES_FROM_TEXTCTRLBASE
|
||||
#include "wx/textctrl.h"
|
||||
#endif
|
||||
|
||||
#if !defined(__WXGTK__) && !defined(__WXMAC__)
|
||||
#define wxRICHTEXT_BUFFERED_PAINTING 1
|
||||
@ -92,12 +84,8 @@ class WXDLLIMPEXP_RICHTEXT wxRichTextStyleDefinition;
|
||||
* wxRichTextCtrl class declaration
|
||||
*/
|
||||
|
||||
class WXDLLIMPEXP_RICHTEXT wxRichTextCtrl:
|
||||
#if wxRICHTEXT_DERIVES_FROM_TEXTCTRLBASE
|
||||
public wxTextCtrlBase, public wxScrollHelper
|
||||
#else
|
||||
public wxScrolledWindow
|
||||
#endif
|
||||
class WXDLLIMPEXP_RICHTEXT wxRichTextCtrl : public wxTextCtrlBase,
|
||||
public wxScrollHelper
|
||||
{
|
||||
DECLARE_CLASS( wxRichTextCtrl )
|
||||
DECLARE_EVENT_TABLE()
|
||||
@ -124,7 +112,6 @@ public:
|
||||
// Accessors
|
||||
|
||||
virtual wxString GetValue() const;
|
||||
virtual void SetValue(const wxString& value);
|
||||
|
||||
virtual wxString GetRange(long from, long to) const;
|
||||
|
||||
@ -163,11 +150,6 @@ public:
|
||||
virtual void Replace(long from, long to, const wxString& value);
|
||||
virtual void Remove(long from, long to);
|
||||
|
||||
#if !wxRICHTEXT_DERIVES_FROM_TEXTCTRLBASE
|
||||
bool LoadFile(const wxString& file, int fileType = wxRICHTEXT_TYPE_ANY);
|
||||
bool SaveFile(const wxString& file = wxEmptyString, int fileType = wxRICHTEXT_TYPE_ANY);
|
||||
#endif
|
||||
|
||||
// load/save the controls contents from/to the file
|
||||
virtual bool DoLoadFile(const wxString& file, int fileType);
|
||||
virtual bool DoSaveFile(const wxString& file = wxEmptyString, int fileType = wxRICHTEXT_TYPE_ANY);
|
||||
@ -641,19 +623,7 @@ public:
|
||||
virtual void DoSetSelection(long from, long to, bool scrollCaret = true);
|
||||
|
||||
/// Write text
|
||||
virtual void DoWriteText(const wxString& value, bool selectionOnly = true);
|
||||
|
||||
/// Send an update event
|
||||
virtual bool SendUpdateEvent();
|
||||
|
||||
/// Init command event
|
||||
void InitCommandEvent(wxCommandEvent& event) const;
|
||||
|
||||
/// do the window-specific processing after processing the update event
|
||||
// (duplicated code from wxTextCtrlBase)
|
||||
#if !wxRICHTEXT_DERIVES_FROM_TEXTCTRLBASE
|
||||
virtual void DoUpdateWindowUI(wxUpdateUIEvent& event);
|
||||
#endif
|
||||
virtual void DoWriteText(const wxString& value, int flags = 0);
|
||||
|
||||
/// Should we inherit colours?
|
||||
virtual bool ShouldInheritColours() const { return false; }
|
||||
@ -744,15 +714,16 @@ public:
|
||||
|
||||
// Implementation
|
||||
|
||||
#if wxRICHTEXT_DERIVES_FROM_TEXTCTRLBASE
|
||||
WX_FORWARD_TO_SCROLL_HELPER()
|
||||
#endif
|
||||
|
||||
// Overrides
|
||||
protected:
|
||||
|
||||
virtual wxSize DoGetBestSize() const ;
|
||||
|
||||
virtual void DoSetValue(const wxString& value, int flags = 0);
|
||||
|
||||
|
||||
// Data members
|
||||
private:
|
||||
|
||||
@ -767,11 +738,6 @@ private:
|
||||
/// Text buffer
|
||||
wxRichTextBuffer m_buffer;
|
||||
|
||||
#if !wxRICHTEXT_DERIVES_FROM_TEXTCTRLBASE
|
||||
/// Filename
|
||||
wxString m_filename;
|
||||
#endif
|
||||
|
||||
wxMenu* m_contextMenu;
|
||||
|
||||
/// Caret position (1 less than the character position, so -1 is the
|
||||
|
@ -5054,7 +5054,7 @@ void wxRichTextAction::UpdateAppearance(long caretPosition, bool sendUpdateEvent
|
||||
m_ctrl->Refresh(false);
|
||||
|
||||
if (sendUpdateEvent)
|
||||
m_ctrl->SendUpdateEvent();
|
||||
m_ctrl->SendTextUpdatedEvent();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -44,19 +44,11 @@ DEFINE_EVENT_TYPE(wxEVT_COMMAND_RICHTEXT_RIGHT_CLICK)
|
||||
DEFINE_EVENT_TYPE(wxEVT_COMMAND_RICHTEXT_LEFT_DCLICK)
|
||||
DEFINE_EVENT_TYPE(wxEVT_COMMAND_RICHTEXT_RETURN)
|
||||
|
||||
#if wxRICHTEXT_DERIVES_FROM_TEXTCTRLBASE
|
||||
IMPLEMENT_CLASS( wxRichTextCtrl, wxControl )
|
||||
#else
|
||||
IMPLEMENT_CLASS( wxRichTextCtrl, wxScrolledWindow )
|
||||
#endif
|
||||
|
||||
IMPLEMENT_CLASS( wxRichTextEvent, wxNotifyEvent )
|
||||
|
||||
#if wxRICHTEXT_DERIVES_FROM_TEXTCTRLBASE
|
||||
BEGIN_EVENT_TABLE( wxRichTextCtrl, wxControl )
|
||||
#else
|
||||
BEGIN_EVENT_TABLE( wxRichTextCtrl, wxScrolledWindow )
|
||||
#endif
|
||||
EVT_PAINT(wxRichTextCtrl::OnPaint)
|
||||
EVT_ERASE_BACKGROUND(wxRichTextCtrl::OnEraseBackground)
|
||||
EVT_IDLE(wxRichTextCtrl::OnIdle)
|
||||
@ -100,17 +92,18 @@ END_EVENT_TABLE()
|
||||
*/
|
||||
|
||||
wxRichTextCtrl::wxRichTextCtrl()
|
||||
#if wxRICHTEXT_DERIVES_FROM_TEXTCTRLBASE
|
||||
: wxScrollHelper(this)
|
||||
#endif
|
||||
: wxScrollHelper(this)
|
||||
{
|
||||
Init();
|
||||
}
|
||||
|
||||
wxRichTextCtrl::wxRichTextCtrl( wxWindow* parent, wxWindowID id, const wxString& value, const wxPoint& pos, const wxSize& size, long style)
|
||||
#if wxRICHTEXT_DERIVES_FROM_TEXTCTRLBASE
|
||||
: wxScrollHelper(this)
|
||||
#endif
|
||||
wxRichTextCtrl::wxRichTextCtrl(wxWindow* parent,
|
||||
wxWindowID id,
|
||||
const wxString& value,
|
||||
const wxPoint& pos,
|
||||
const wxSize& size,
|
||||
long style)
|
||||
: wxScrollHelper(this)
|
||||
{
|
||||
Init();
|
||||
Create(parent, id, value, pos, size, style);
|
||||
@ -119,15 +112,9 @@ wxRichTextCtrl::wxRichTextCtrl( wxWindow* parent, wxWindowID id, const wxString&
|
||||
/// Creation
|
||||
bool wxRichTextCtrl::Create( wxWindow* parent, wxWindowID id, const wxString& value, const wxPoint& pos, const wxSize& size, long style)
|
||||
{
|
||||
#if wxRICHTEXT_DERIVES_FROM_TEXTCTRLBASE
|
||||
if (!wxTextCtrlBase::Create(parent, id, pos, size, style|wxFULL_REPAINT_ON_RESIZE
|
||||
))
|
||||
if (!wxTextCtrlBase::Create(parent, id, pos, size,
|
||||
style|wxFULL_REPAINT_ON_RESIZE))
|
||||
return false;
|
||||
#else
|
||||
if (!wxScrolledWindow::Create(parent, id, pos, size, style|wxFULL_REPAINT_ON_RESIZE
|
||||
))
|
||||
return false;
|
||||
#endif
|
||||
|
||||
if (!GetFont().Ok())
|
||||
{
|
||||
@ -230,7 +217,7 @@ void wxRichTextCtrl::Clear()
|
||||
SetupScrollbars();
|
||||
Refresh(false);
|
||||
}
|
||||
SendUpdateEvent();
|
||||
SendTextUpdatedEvent();
|
||||
}
|
||||
|
||||
/// Painting
|
||||
@ -1652,27 +1639,6 @@ bool wxRichTextCtrl::RecreateBuffer(const wxSize& size)
|
||||
// file IO functions
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
#if !wxRICHTEXT_DERIVES_FROM_TEXTCTRLBASE
|
||||
bool wxRichTextCtrl::LoadFile(const wxString& filename, int fileType)
|
||||
{
|
||||
return DoLoadFile(filename, fileType);
|
||||
}
|
||||
|
||||
bool wxRichTextCtrl::SaveFile(const wxString& filename, int fileType)
|
||||
{
|
||||
wxString filenameToUse = filename.empty() ? m_filename : filename;
|
||||
if ( filenameToUse.empty() )
|
||||
{
|
||||
// what kind of message to give? is it an error or a program bug?
|
||||
wxLogDebug(wxT("Can't save textctrl to file without filename."));
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
return DoSaveFile(filenameToUse, fileType);
|
||||
}
|
||||
#endif
|
||||
|
||||
bool wxRichTextCtrl::DoLoadFile(const wxString& filename, int fileType)
|
||||
{
|
||||
bool success = GetBuffer().LoadFile(filename, fileType);
|
||||
@ -1685,7 +1651,7 @@ bool wxRichTextCtrl::DoLoadFile(const wxString& filename, int fileType)
|
||||
PositionCaret();
|
||||
SetupScrollbars(true);
|
||||
Refresh(false);
|
||||
SendUpdateEvent();
|
||||
SendTextUpdatedEvent();
|
||||
|
||||
if (success)
|
||||
return true;
|
||||
@ -1808,22 +1774,6 @@ wxString wxRichTextCtrl::GetStringSelection() const
|
||||
return GetRange(from, to);
|
||||
}
|
||||
|
||||
// do the window-specific processing after processing the update event
|
||||
#if !wxRICHTEXT_DERIVES_FROM_TEXTCTRLBASE
|
||||
void wxRichTextCtrl::DoUpdateWindowUI(wxUpdateUIEvent& event)
|
||||
{
|
||||
// call inherited
|
||||
wxWindowBase::DoUpdateWindowUI(event);
|
||||
|
||||
// update text
|
||||
if ( event.GetSetText() )
|
||||
{
|
||||
if ( event.GetText() != GetValue() )
|
||||
SetValue(event.GetText());
|
||||
}
|
||||
}
|
||||
#endif // !wxRICHTEXT_DERIVES_FROM_TEXTCTRLBASE
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// hit testing
|
||||
// ----------------------------------------------------------------------------
|
||||
@ -1888,7 +1838,7 @@ wxString wxRichTextCtrl::GetRange(long from, long to) const
|
||||
return GetBuffer().GetTextForRange(wxRichTextRange(from, to-1));
|
||||
}
|
||||
|
||||
void wxRichTextCtrl::SetValue(const wxString& value)
|
||||
void wxRichTextCtrl::DoSetValue(const wxString& value, int flags)
|
||||
{
|
||||
Clear();
|
||||
|
||||
@ -1898,15 +1848,18 @@ void wxRichTextCtrl::SetValue(const wxString& value)
|
||||
// edit controls mostly)
|
||||
if ( (value.length() > 0x400) || (value != GetValue()) )
|
||||
{
|
||||
DoWriteText(value, false /* not selection only */);
|
||||
DoWriteText(value);
|
||||
|
||||
// for compatibility, don't move the cursor when doing SetValue()
|
||||
SetInsertionPoint(0);
|
||||
}
|
||||
else // same text
|
||||
{
|
||||
// still send an event for consistency
|
||||
SendUpdateEvent();
|
||||
if ( flags & SetValue_SendEvent )
|
||||
{
|
||||
// still send an event for consistency
|
||||
SendTextUpdatedEvent();
|
||||
}
|
||||
}
|
||||
|
||||
// we should reset the modified flag even if the value didn't really change
|
||||
@ -1921,11 +1874,14 @@ void wxRichTextCtrl::WriteText(const wxString& value)
|
||||
DoWriteText(value);
|
||||
}
|
||||
|
||||
void wxRichTextCtrl::DoWriteText(const wxString& value, bool WXUNUSED(selectionOnly))
|
||||
void wxRichTextCtrl::DoWriteText(const wxString& value, int flags)
|
||||
{
|
||||
wxString valueUnix = wxTextFile::Translate(value, wxTextFileType_Unix);
|
||||
|
||||
GetBuffer().InsertTextWithUndo(m_caretPosition+1, valueUnix, this);
|
||||
|
||||
if ( flags & SetValue_SendEvent )
|
||||
SendTextUpdatedEvent();
|
||||
}
|
||||
|
||||
void wxRichTextCtrl::AppendText(const wxString& text)
|
||||
@ -2140,13 +2096,14 @@ void wxRichTextCtrl::DoSetSelection(long from, long to, bool WXUNUSED(scrollCare
|
||||
// Editing
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
void wxRichTextCtrl::Replace(long WXUNUSED(from), long WXUNUSED(to), const wxString& value)
|
||||
void wxRichTextCtrl::Replace(long WXUNUSED(from), long WXUNUSED(to),
|
||||
const wxString& value)
|
||||
{
|
||||
BeginBatchUndo(_("Replace"));
|
||||
|
||||
DeleteSelectedContent();
|
||||
|
||||
DoWriteText(value, true /* selection only */);
|
||||
DoWriteText(value, SetValue_SelectionOnly);
|
||||
|
||||
EndBatchUndo();
|
||||
}
|
||||
@ -2270,39 +2227,6 @@ void wxRichTextCtrl::OnDropFiles(wxDropFilesEvent& event)
|
||||
}
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// text control event processing
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
bool wxRichTextCtrl::SendUpdateEvent()
|
||||
{
|
||||
wxCommandEvent event(wxEVT_COMMAND_TEXT_UPDATED, GetId());
|
||||
InitCommandEvent(event);
|
||||
|
||||
return GetEventHandler()->ProcessEvent(event);
|
||||
}
|
||||
|
||||
void wxRichTextCtrl::InitCommandEvent(wxCommandEvent& event) const
|
||||
{
|
||||
event.SetEventObject((wxControlBase *)this); // const_cast
|
||||
|
||||
switch ( m_clientDataType )
|
||||
{
|
||||
case wxClientData_Void:
|
||||
event.SetClientData(GetClientData());
|
||||
break;
|
||||
|
||||
case wxClientData_Object:
|
||||
event.SetClientObject(GetClientObject());
|
||||
break;
|
||||
|
||||
case wxClientData_None:
|
||||
// nothing to do
|
||||
;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
wxSize wxRichTextCtrl::DoGetBestSize() const
|
||||
{
|
||||
return wxSize(10, 10);
|
||||
@ -2505,22 +2429,12 @@ bool wxRichTextCtrl::GetUncombinedStyle(long position, wxRichTextAttr& style)
|
||||
/// Set font, and also the buffer attributes
|
||||
bool wxRichTextCtrl::SetFont(const wxFont& font)
|
||||
{
|
||||
#if wxRICHTEXT_DERIVES_FROM_TEXTCTRLBASE
|
||||
wxControl::SetFont(font);
|
||||
#else
|
||||
wxScrolledWindow::SetFont(font);
|
||||
#endif
|
||||
|
||||
wxTextAttrEx attr = GetBuffer().GetAttributes();
|
||||
attr.SetFont(font);
|
||||
GetBuffer().SetBasicStyle(attr);
|
||||
|
||||
#if !wxRICHTEXT_DERIVES_FROM_TEXTCTRLBASE
|
||||
// Don't set the default style, since it will be inherited from
|
||||
// the basic style.
|
||||
GetBuffer().SetDefaultStyle(attr);
|
||||
#endif
|
||||
|
||||
GetBuffer().Invalidate(wxRICHTEXT_ALL);
|
||||
Refresh(false);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user