Added some missing wxTextCtrl functions: Undo, Redo, CanUndo, CanRedo,

CanCopy, CanCut, CanPaste, GetSelection, IsEditable.
Also added wxNotebook::SetTabSize (only implemented on wxMSW but necessary
when using just an icon).


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@2054 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Julian Smart
1999-04-06 16:32:33 +00:00
parent 49d5d881d4
commit ca8b28f2ef
19 changed files with 522 additions and 27 deletions

View File

@@ -601,6 +601,11 @@ wxRect wxNotebook::GetAvailableClientSize()
return rect;
}
void wxNotebook::SetTabSize(const wxSize& sz)
{
// TODO
}
/*
* wxNotebookTabView
*/

View File

@@ -509,6 +509,11 @@ void wxNotebook::SetPadding( const wxSize &WXUNUSED(padding) )
wxFAIL_MSG( "wxNotebook::SetPadding not implemented" );
}
void wxNotebook::SetTabSize(const wxSize& sz)
{
wxFAIL_MSG( "wxNotebook::SetTabSize not implemented" );
}
bool wxNotebook::DeleteAllPages()
{
wxCHECK_MSG( m_widget != NULL, FALSE, "invalid notebook" );

View File

@@ -703,6 +703,71 @@ void wxTextCtrl::Paste()
#endif
}
bool wxTextCtrl::CanCopy() const
{
// Can copy if there's a selection
long from, to;
GetSelection(& from, & to);
return (from != to) ;
}
bool wxTextCtrl::CanCut() const
{
// Can cut if there's a selection
long from, to;
GetSelection(& from, & to);
return (from != to) ;
}
bool wxTextCtrl::CanPaste() const
{
return IsEditable() ;
}
// Undo/redo
void wxTextCtrl::Undo()
{
// TODO
wxFAIL_MSG( "wxTextCtrl::Undo not implemented" );
}
void wxTextCtrl::Redo()
{
// TODO
wxFAIL_MSG( "wxTextCtrl::Redo not implemented" );
}
bool wxTextCtrl::CanUndo() const
{
// TODO
wxFAIL_MSG( "wxTextCtrl::CanUndo not implemented" );
return FALSE;
}
bool wxTextCtrl::CanRedo() const
{
// TODO
wxFAIL_MSG( "wxTextCtrl::CanRedo not implemented" );
return FALSE;
}
// If the return values from and to are the same, there is no
// selection.
void wxTextCtrl::GetSelection(long* from, long* to) const
{
// TODO
*from = 0;
*to = 0;
wxFAIL_MSG( "wxTextCtrl::GetSelection not implemented" );
}
bool wxTextCtrl::IsEditable() const
{
// TODO
wxFAIL_MSG( "wxTextCtrl::IsEditable not implemented" );
return FALSE;
}
void wxTextCtrl::Clear()
{
SetValue( "" );

View File

@@ -509,6 +509,11 @@ void wxNotebook::SetPadding( const wxSize &WXUNUSED(padding) )
wxFAIL_MSG( "wxNotebook::SetPadding not implemented" );
}
void wxNotebook::SetTabSize(const wxSize& sz)
{
wxFAIL_MSG( "wxNotebook::SetTabSize not implemented" );
}
bool wxNotebook::DeleteAllPages()
{
wxCHECK_MSG( m_widget != NULL, FALSE, "invalid notebook" );

View File

@@ -703,6 +703,71 @@ void wxTextCtrl::Paste()
#endif
}
bool wxTextCtrl::CanCopy() const
{
// Can copy if there's a selection
long from, to;
GetSelection(& from, & to);
return (from != to) ;
}
bool wxTextCtrl::CanCut() const
{
// Can cut if there's a selection
long from, to;
GetSelection(& from, & to);
return (from != to) ;
}
bool wxTextCtrl::CanPaste() const
{
return IsEditable() ;
}
// Undo/redo
void wxTextCtrl::Undo()
{
// TODO
wxFAIL_MSG( "wxTextCtrl::Undo not implemented" );
}
void wxTextCtrl::Redo()
{
// TODO
wxFAIL_MSG( "wxTextCtrl::Redo not implemented" );
}
bool wxTextCtrl::CanUndo() const
{
// TODO
wxFAIL_MSG( "wxTextCtrl::CanUndo not implemented" );
return FALSE;
}
bool wxTextCtrl::CanRedo() const
{
// TODO
wxFAIL_MSG( "wxTextCtrl::CanRedo not implemented" );
return FALSE;
}
// If the return values from and to are the same, there is no
// selection.
void wxTextCtrl::GetSelection(long* from, long* to) const
{
// TODO
*from = 0;
*to = 0;
wxFAIL_MSG( "wxTextCtrl::GetSelection not implemented" );
}
bool wxTextCtrl::IsEditable() const
{
// TODO
wxFAIL_MSG( "wxTextCtrl::IsEditable not implemented" );
return FALSE;
}
void wxTextCtrl::Clear()
{
SetValue( "" );

View File

@@ -245,6 +245,67 @@ void wxTextCtrl::Paste()
XmTextPaste((Widget) m_mainWidget);
}
bool wxTextCtrl::CanCopy() const
{
// Can copy if there's a selection
long from, to;
GetSelection(& from, & to);
return (from != to) ;
}
bool wxTextCtrl::CanCut() const
{
// Can cut if there's a selection
long from, to;
GetSelection(& from, & to);
return (from != to) ;
}
bool wxTextCtrl::CanPaste() const
{
return IsEditable() ;
}
// Undo/redo
void wxTextCtrl::Undo()
{
// Not possible in Motif
}
void wxTextCtrl::Redo()
{
// Not possible in Motif
}
bool wxTextCtrl::CanUndo() const
{
// No Undo in Motif
return FALSE;
}
bool wxTextCtrl::CanRedo() const
{
// No Redo in Motif
return FALSE;
}
// If the return values from and to are the same, there is no
// selection.
void wxTextCtrl::GetSelection(long* from, long* to) const
{
XmTextPosition left, right;
XmTextGetSelectionPosition((Widget) m_mainWidget, & left, & right);
*from = (long) left;
*to = (long) right;
}
bool wxTextCtrl::IsEditable() const
{
return (XmTextGetEditable((Widget) m_mainWidget) != 0);
}
void wxTextCtrl::SetEditable(bool editable)
{
XmTextSetEditable((Widget) m_mainWidget, (Boolean) editable);

View File

@@ -729,9 +729,87 @@ wxString wxTextCtrl::GetLineText(long lineNo) const
return wxString(wxBuffer);
}
/*
* Text item
*/
bool wxTextCtrl::CanCopy() const
{
// Can copy if there's a selection
long from, to;
GetSelection(& from, & to);
return (from != to) ;
}
bool wxTextCtrl::CanCut() const
{
// Can cut if there's a selection
long from, to;
GetSelection(& from, & to);
return (from != to) ;
}
bool wxTextCtrl::CanPaste() const
{
int dataFormat = 0; // 0 == any format
return (::SendMessage( (HWND) GetHWND(), EM_CANPASTE, (WPARAM) (UINT) dataFormat, 0) != 0);
}
// Undo/redo
void wxTextCtrl::Undo()
{
if (CanUndo())
{
::SendMessage((HWND) GetHWND(), EM_UNDO, 0, 0);
}
}
void wxTextCtrl::Redo()
{
if (CanRedo())
{
// Same as Undo, since Undo undoes the undo, i.e. a redo.
::SendMessage((HWND) GetHWND(), EM_UNDO, 0, 0);
}
}
bool wxTextCtrl::CanUndo() const
{
return (::SendMessage((HWND) GetHWND(), EM_CANUNDO, 0, 0) != 0);
}
bool wxTextCtrl::CanRedo() const
{
return (::SendMessage((HWND) GetHWND(), EM_CANUNDO, 0, 0) != 0);
}
// If the return values from and to are the same, there is no
// selection.
void wxTextCtrl::GetSelection(long* from, long* to) const
{
#if wxUSE_RICHEDIT
if (m_isRich)
{
CHARRANGE charRange;
::SendMessage((HWND) GetHWND(), EM_EXGETSEL, 0, (LPARAM) (CHARRANGE*) & charRange);
*from = charRange.cpMin;
*to = charRange.cpMax;
return;
}
#endif
DWORD dwStart, dwEnd;
WPARAM wParam = (WPARAM) (DWORD*) dwStart; // receives starting position
LPARAM lParam = (LPARAM) (DWORD*) dwEnd; // receives ending position
::SendMessage((HWND) GetHWND(), EM_GETSEL, wParam, lParam);
*from = dwStart;
*to = dwEnd;
}
bool wxTextCtrl::IsEditable() const
{
long style = ::GetWindowLong((HWND) GetHWND(), GWL_STYLE);
return ((style & ES_READONLY) == 0);
}
void wxTextCtrl::Command(wxCommandEvent & event)
{

View File

@@ -375,3 +375,8 @@ void wxNotebook::ChangePage(int nOldSel, int nSel)
m_nSelection = nSel;
}
void wxNotebook::SetTabSize(const wxSize& sz)
{
// TODO
}

View File

@@ -267,10 +267,65 @@ wxString wxTextCtrl::GetLineText(long lineNo) const
return wxString("");
}
/*
* Text item
*/
bool wxTextCtrl::CanCopy() const
{
// Can copy if there's a selection
long from, to;
GetSelection(& from, & to);
return (from != to) ;
}
bool wxTextCtrl::CanCut() const
{
// Can cut if there's a selection
long from, to;
GetSelection(& from, & to);
return (from != to) ;
}
bool wxTextCtrl::CanPaste() const
{
return IsEditable() ;
}
// Undo/redo
void wxTextCtrl::Undo()
{
// TODO
}
void wxTextCtrl::Redo()
{
// TODO
}
bool wxTextCtrl::CanUndo() const
{
// TODO
return FALSE;
}
bool wxTextCtrl::CanRedo() const
{
// TODO
return FALSE;
}
// If the return values from and to are the same, there is no
// selection.
void wxTextCtrl::GetSelection(long* from, long* to) const
{
// TODO
*from = 0;
*to = 0;
}
bool wxTextCtrl::IsEditable() const
{
// TODO
return FALSE;
}
void wxTextCtrl::Command(wxCommandEvent & event)
{
SetValue (event.GetString());