wxwidgets/src/qt/textentry.cpp
ali kettab 7ec7fe6dea Make wxTextEntry::DoSetValue() reusable under wxQt
This is a preparation for wxComboBox and wxBitmapComboBox to reuse the code
from the base class by just forwarding to wxTextEntry.
2023-10-14 17:58:53 +01:00

124 lines
2.3 KiB
C++

/////////////////////////////////////////////////////////////////////////////
// Name: src/qt/textentry.cpp
// Author: Peter Most, Mariano Reingart
// Copyright: (c) 2010 wxWidgets dev team
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
// For compilers that support precompilation, includes "wx.h".
#include "wx/wxprec.h"
#include "wx/textentry.h"
#include "wx/window.h"
#include <QtWidgets/QWidget>
wxTextEntry::wxTextEntry()
{
}
void wxTextEntry::WriteText(const wxString& WXUNUSED(text))
{
}
void wxTextEntry::Remove(long from, long to)
{
const long insertionPoint = GetInsertionPoint();
wxString string = GetValue();
string.erase(from, to - from);
SetValue(string);
SetInsertionPoint( std::min(insertionPoint, static_cast<long>(string.length())) );
}
void wxTextEntry::Copy()
{
}
void wxTextEntry::Cut()
{
}
void wxTextEntry::Paste()
{
}
void wxTextEntry::Undo()
{
}
void wxTextEntry::Redo()
{
}
bool wxTextEntry::CanUndo() const
{
return false;
}
bool wxTextEntry::CanRedo() const
{
return false;
}
void wxTextEntry::SetInsertionPoint(long WXUNUSED(pos))
{
}
long wxTextEntry::GetInsertionPoint() const
{
return 0;
}
long wxTextEntry::GetLastPosition() const
{
return GetValue().length();
}
void wxTextEntry::SetSelection(long WXUNUSED(from), long WXUNUSED(to))
{
wxFAIL_MSG("wxTextEntry::SetSelection should be overridden");
}
void wxTextEntry::GetSelection(long *from, long *to) const
{
// no unified get selection method in Qt (overridden in textctrl & combobox)
// only called if no selection
// If the return values from and to are the same, there is no
// selection.
{
*from =
*to = GetInsertionPoint();
}
}
bool wxTextEntry::IsEditable() const
{
return false;
}
void wxTextEntry::SetEditable(bool WXUNUSED(editable))
{
}
wxString wxTextEntry::DoGetValue() const
{
return wxString();
}
void wxTextEntry::DoSetValue(const wxString& value, int flags)
{
wxTextEntryBase::DoSetValue(value, flags);
}
wxWindow *wxTextEntry::GetEditableWindow()
{
return nullptr;
}
void wxTextEntry::EnableTextChangedEvents(bool enable)
{
wxWindow* const win = GetEditableWindow();
if ( win )
win->GetHandle()->blockSignals(!enable);
}