Menu/toolbar event handling now tries the window with the focus first.
wxTextCtrl processes cut, copy, paste, undo, redo commands and UI updates automatically. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@2069 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -555,3 +555,26 @@ bool wxEvtHandler::OnClose()
|
||||
}
|
||||
#endif // WXWIN_COMPATIBILITY
|
||||
|
||||
// Find a window with the focus, that is also a descendant of the given window.
|
||||
// This is used to determine the window to initially send commands to.
|
||||
wxWindow* wxFindFocusDescendant(wxWindow* ancestor)
|
||||
{
|
||||
// Process events starting with the window with the focus, if any.
|
||||
wxWindow* focusWin = wxWindow::FindFocus();
|
||||
wxWindow* win = focusWin;
|
||||
|
||||
// Check if this is a descendant of this frame.
|
||||
// If not, win will be set to NULL.
|
||||
while (win)
|
||||
{
|
||||
if (win == ancestor)
|
||||
break;
|
||||
else
|
||||
win = win->GetParent();
|
||||
}
|
||||
if (win == (wxWindow*) NULL)
|
||||
focusWin = (wxWindow*) NULL;
|
||||
|
||||
return focusWin;
|
||||
}
|
||||
|
||||
|
@@ -30,16 +30,21 @@ void wxFrame::OnIdle(wxIdleEvent& WXUNUSED(event) )
|
||||
void wxFrame::DoMenuUpdates()
|
||||
{
|
||||
wxMenuBar* bar = GetMenuBar();
|
||||
|
||||
// Process events starting with the window with the focus, if any.
|
||||
wxWindow* focusWin = wxFindFocusDescendant(this);
|
||||
|
||||
if ( bar != NULL ) {
|
||||
int nCount = bar->GetMenuCount();
|
||||
for (int n = 0; n < nCount; n++)
|
||||
DoMenuUpdates(bar->GetMenu(n));
|
||||
DoMenuUpdates(bar->GetMenu(n), focusWin);
|
||||
}
|
||||
}
|
||||
|
||||
// update a menu and all submenus recursively
|
||||
void wxFrame::DoMenuUpdates(wxMenu* menu)
|
||||
void wxFrame::DoMenuUpdates(wxMenu* menu, wxWindow* focusWin)
|
||||
{
|
||||
wxEvtHandler* evtHandler = focusWin ? focusWin->GetEventHandler() : GetEventHandler();
|
||||
wxNode* node = menu->GetItems().First();
|
||||
while (node)
|
||||
{
|
||||
@@ -50,7 +55,7 @@ void wxFrame::DoMenuUpdates(wxMenu* menu)
|
||||
wxUpdateUIEvent event(id);
|
||||
event.SetEventObject( this );
|
||||
|
||||
if (GetEventHandler()->ProcessEvent(event))
|
||||
if (evtHandler->ProcessEvent(event))
|
||||
{
|
||||
if (event.GetSetText())
|
||||
menu->SetLabel(id, event.GetText());
|
||||
@@ -61,7 +66,7 @@ void wxFrame::DoMenuUpdates(wxMenu* menu)
|
||||
}
|
||||
|
||||
if (item->GetSubMenu())
|
||||
DoMenuUpdates(item->GetSubMenu());
|
||||
DoMenuUpdates(item->GetSubMenu(), focusWin);
|
||||
}
|
||||
node = node->Next();
|
||||
}
|
||||
|
@@ -24,6 +24,8 @@
|
||||
#include "wx/wx.h"
|
||||
#endif
|
||||
|
||||
#include "wx/frame.h"
|
||||
|
||||
// For ::UpdateWindow
|
||||
#ifdef __WXMSW__
|
||||
#include <windows.h>
|
||||
@@ -147,6 +149,29 @@ bool wxToolBarBase::OnLeftClick(int toolIndex, bool toggleDown)
|
||||
event.SetEventObject(this);
|
||||
event.SetExtraLong((long) toggleDown);
|
||||
|
||||
// First try sending the command to a window that has the focus, within a frame that
|
||||
// also contains this toolbar.
|
||||
wxFrame* frame = (wxFrame*) NULL;
|
||||
wxWindow* win = this;
|
||||
wxWindow* focusWin = (wxWindow*) NULL;
|
||||
|
||||
while (win)
|
||||
{
|
||||
if (win->IsKindOf(CLASSINFO(wxFrame)))
|
||||
{
|
||||
frame = (wxFrame*) win;
|
||||
break;
|
||||
}
|
||||
else
|
||||
win = win->GetParent();
|
||||
}
|
||||
if (frame)
|
||||
focusWin = wxFindFocusDescendant(frame);
|
||||
|
||||
if (focusWin && focusWin->GetEventHandler()->ProcessEvent(event))
|
||||
return TRUE;
|
||||
|
||||
// Send events to this toolbar instead (and thence up the window hierarchy)
|
||||
GetEventHandler()->ProcessEvent(event);
|
||||
|
||||
return TRUE;
|
||||
@@ -732,6 +757,28 @@ void wxToolBarBase::OnIdle(wxIdleEvent& event)
|
||||
// Do the toolbar button updates (check for EVT_UPDATE_UI handlers)
|
||||
void wxToolBarBase::DoToolbarUpdates()
|
||||
{
|
||||
// First try sending the command to a window that has the focus, within a frame that
|
||||
// also contains this toolbar.
|
||||
wxFrame* frame = (wxFrame*) NULL;
|
||||
wxWindow* win = this;
|
||||
wxWindow* focusWin = (wxWindow*) NULL;
|
||||
|
||||
while (win)
|
||||
{
|
||||
if (win->IsKindOf(CLASSINFO(wxFrame)))
|
||||
{
|
||||
frame = (wxFrame*) win;
|
||||
break;
|
||||
}
|
||||
else
|
||||
win = win->GetParent();
|
||||
}
|
||||
if (frame)
|
||||
focusWin = wxFindFocusDescendant(frame);
|
||||
|
||||
|
||||
wxEvtHandler* evtHandler = focusWin ? focusWin->GetEventHandler() : GetEventHandler() ;
|
||||
|
||||
wxNode* node = GetTools().First();
|
||||
while (node)
|
||||
{
|
||||
@@ -740,7 +787,7 @@ void wxToolBarBase::DoToolbarUpdates()
|
||||
wxUpdateUIEvent event(tool->m_index);
|
||||
event.SetEventObject(this);
|
||||
|
||||
if (GetEventHandler()->ProcessEvent(event))
|
||||
if (evtHandler->ProcessEvent(event))
|
||||
{
|
||||
if (event.GetSetEnabled())
|
||||
EnableTool(tool->m_index, event.GetEnabled());
|
||||
|
@@ -28,6 +28,7 @@ LIB_CPP_SRC=\
|
||||
common/image.cpp \
|
||||
common/imagjpeg.cpp \
|
||||
common/imagpng.cpp \
|
||||
common/imaggif.cpp \
|
||||
common/ipcbase.cpp \
|
||||
common/layout.cpp \
|
||||
common/list.cpp \
|
||||
|
@@ -654,7 +654,13 @@ void wxFrame::Command( int id )
|
||||
{
|
||||
bar->Check(id,!bar->Checked(id)) ;
|
||||
}
|
||||
GetEventHandler()->ProcessEvent(commandEvent);
|
||||
|
||||
// Process events starting with the window with the focus, if any.
|
||||
wxWindow* focusWin = wxFindFocusDescendant(this);
|
||||
|
||||
wxEvtHandler* evtHandler = focusWin ? focusWin->GetEventHandler() : GetEventHandler();
|
||||
|
||||
evtHandler->ProcessEvent(commandEvent);
|
||||
}
|
||||
|
||||
void wxFrame::SetStatusText(const wxString& text, int number)
|
||||
|
@@ -12,6 +12,7 @@
|
||||
#endif
|
||||
|
||||
#include "wx/toolbar.h"
|
||||
#include "wx/frame.h"
|
||||
|
||||
#include "glib.h"
|
||||
#include "gdk/gdk.h"
|
||||
@@ -168,6 +169,28 @@ bool wxToolBar::OnLeftClick( int toolIndex, bool toggleDown )
|
||||
event.SetInt( toolIndex );
|
||||
event.SetExtraLong((long) toggleDown);
|
||||
|
||||
// First try sending the command to a window that has the focus, within a frame that
|
||||
// also contains this toolbar.
|
||||
wxFrame* frame = (wxFrame*) NULL;
|
||||
wxWindow* win = this;
|
||||
wxWindow* focusWin = (wxWindow*) NULL;
|
||||
|
||||
while (win)
|
||||
{
|
||||
if (win->IsKindOf(CLASSINFO(wxFrame)))
|
||||
{
|
||||
frame = (wxFrame*) win;
|
||||
break;
|
||||
}
|
||||
else
|
||||
win = win->GetParent();
|
||||
}
|
||||
if (frame)
|
||||
focusWin = wxFindFocusDescendant(frame);
|
||||
|
||||
if (focusWin && focusWin->GetEventHandler()->ProcessEvent(event))
|
||||
return TRUE;
|
||||
|
||||
GetEventHandler()->ProcessEvent(event);
|
||||
|
||||
return TRUE;
|
||||
|
@@ -65,6 +65,18 @@ IMPLEMENT_DYNAMIC_CLASS(wxTextCtrl,wxControl)
|
||||
|
||||
BEGIN_EVENT_TABLE(wxTextCtrl, wxControl)
|
||||
EVT_CHAR(wxTextCtrl::OnChar)
|
||||
|
||||
EVT_MENU(wxID_CUT, wxTextCtrl::OnCut)
|
||||
EVT_MENU(wxID_COPY, wxTextCtrl::OnCopy)
|
||||
EVT_MENU(wxID_PASTE, wxTextCtrl::OnPaste)
|
||||
EVT_MENU(wxID_UNDO, wxTextCtrl::OnUndo)
|
||||
EVT_MENU(wxID_REDO, wxTextCtrl::OnRedo)
|
||||
|
||||
EVT_UPDATE_UI(wxID_CUT, wxTextCtrl::OnUpdateCut)
|
||||
EVT_UPDATE_UI(wxID_COPY, wxTextCtrl::OnUpdateCopy)
|
||||
EVT_UPDATE_UI(wxID_PASTE, wxTextCtrl::OnUpdatePaste)
|
||||
EVT_UPDATE_UI(wxID_UNDO, wxTextCtrl::OnUpdateUndo)
|
||||
EVT_UPDATE_UI(wxID_REDO, wxTextCtrl::OnUpdateRedo)
|
||||
END_EVENT_TABLE()
|
||||
|
||||
#ifndef NO_TEXT_WINDOW_STREAM
|
||||
@@ -931,3 +943,52 @@ void wxTextCtrl::ApplyWidgetStyle()
|
||||
}
|
||||
}
|
||||
|
||||
void wxTextCtrl::OnCut(wxCommandEvent& WXUNUSED(event))
|
||||
{
|
||||
Cut();
|
||||
}
|
||||
|
||||
void wxTextCtrl::OnCopy(wxCommandEvent& WXUNUSED(event))
|
||||
{
|
||||
Copy();
|
||||
}
|
||||
|
||||
void wxTextCtrl::OnPaste(wxCommandEvent& WXUNUSED(event))
|
||||
{
|
||||
Paste();
|
||||
}
|
||||
|
||||
void wxTextCtrl::OnUndo(wxCommandEvent& WXUNUSED(event))
|
||||
{
|
||||
Undo();
|
||||
}
|
||||
|
||||
void wxTextCtrl::OnRedo(wxCommandEvent& WXUNUSED(event))
|
||||
{
|
||||
Redo();
|
||||
}
|
||||
|
||||
void wxTextCtrl::OnUpdateCut(wxUpdateUIEvent& event)
|
||||
{
|
||||
event.Enable( CanCut() );
|
||||
}
|
||||
|
||||
void wxTextCtrl::OnUpdateCopy(wxUpdateUIEvent& event)
|
||||
{
|
||||
event.Enable( CanCopy() );
|
||||
}
|
||||
|
||||
void wxTextCtrl::OnUpdatePaste(wxUpdateUIEvent& event)
|
||||
{
|
||||
event.Enable( CanPaste() );
|
||||
}
|
||||
|
||||
void wxTextCtrl::OnUpdateUndo(wxUpdateUIEvent& event)
|
||||
{
|
||||
event.Enable( CanUndo() );
|
||||
}
|
||||
|
||||
void wxTextCtrl::OnUpdateRedo(wxUpdateUIEvent& event)
|
||||
{
|
||||
event.Enable( CanRedo() );
|
||||
}
|
||||
|
@@ -654,7 +654,13 @@ void wxFrame::Command( int id )
|
||||
{
|
||||
bar->Check(id,!bar->Checked(id)) ;
|
||||
}
|
||||
GetEventHandler()->ProcessEvent(commandEvent);
|
||||
|
||||
// Process events starting with the window with the focus, if any.
|
||||
wxWindow* focusWin = wxFindFocusDescendant(this);
|
||||
|
||||
wxEvtHandler* evtHandler = focusWin ? focusWin->GetEventHandler() : GetEventHandler();
|
||||
|
||||
evtHandler->ProcessEvent(commandEvent);
|
||||
}
|
||||
|
||||
void wxFrame::SetStatusText(const wxString& text, int number)
|
||||
|
@@ -12,6 +12,7 @@
|
||||
#endif
|
||||
|
||||
#include "wx/toolbar.h"
|
||||
#include "wx/frame.h"
|
||||
|
||||
#include "glib.h"
|
||||
#include "gdk/gdk.h"
|
||||
@@ -168,6 +169,28 @@ bool wxToolBar::OnLeftClick( int toolIndex, bool toggleDown )
|
||||
event.SetInt( toolIndex );
|
||||
event.SetExtraLong((long) toggleDown);
|
||||
|
||||
// First try sending the command to a window that has the focus, within a frame that
|
||||
// also contains this toolbar.
|
||||
wxFrame* frame = (wxFrame*) NULL;
|
||||
wxWindow* win = this;
|
||||
wxWindow* focusWin = (wxWindow*) NULL;
|
||||
|
||||
while (win)
|
||||
{
|
||||
if (win->IsKindOf(CLASSINFO(wxFrame)))
|
||||
{
|
||||
frame = (wxFrame*) win;
|
||||
break;
|
||||
}
|
||||
else
|
||||
win = win->GetParent();
|
||||
}
|
||||
if (frame)
|
||||
focusWin = wxFindFocusDescendant(frame);
|
||||
|
||||
if (focusWin && focusWin->GetEventHandler()->ProcessEvent(event))
|
||||
return TRUE;
|
||||
|
||||
GetEventHandler()->ProcessEvent(event);
|
||||
|
||||
return TRUE;
|
||||
|
@@ -65,6 +65,18 @@ IMPLEMENT_DYNAMIC_CLASS(wxTextCtrl,wxControl)
|
||||
|
||||
BEGIN_EVENT_TABLE(wxTextCtrl, wxControl)
|
||||
EVT_CHAR(wxTextCtrl::OnChar)
|
||||
|
||||
EVT_MENU(wxID_CUT, wxTextCtrl::OnCut)
|
||||
EVT_MENU(wxID_COPY, wxTextCtrl::OnCopy)
|
||||
EVT_MENU(wxID_PASTE, wxTextCtrl::OnPaste)
|
||||
EVT_MENU(wxID_UNDO, wxTextCtrl::OnUndo)
|
||||
EVT_MENU(wxID_REDO, wxTextCtrl::OnRedo)
|
||||
|
||||
EVT_UPDATE_UI(wxID_CUT, wxTextCtrl::OnUpdateCut)
|
||||
EVT_UPDATE_UI(wxID_COPY, wxTextCtrl::OnUpdateCopy)
|
||||
EVT_UPDATE_UI(wxID_PASTE, wxTextCtrl::OnUpdatePaste)
|
||||
EVT_UPDATE_UI(wxID_UNDO, wxTextCtrl::OnUpdateUndo)
|
||||
EVT_UPDATE_UI(wxID_REDO, wxTextCtrl::OnUpdateRedo)
|
||||
END_EVENT_TABLE()
|
||||
|
||||
#ifndef NO_TEXT_WINDOW_STREAM
|
||||
@@ -931,3 +943,52 @@ void wxTextCtrl::ApplyWidgetStyle()
|
||||
}
|
||||
}
|
||||
|
||||
void wxTextCtrl::OnCut(wxCommandEvent& WXUNUSED(event))
|
||||
{
|
||||
Cut();
|
||||
}
|
||||
|
||||
void wxTextCtrl::OnCopy(wxCommandEvent& WXUNUSED(event))
|
||||
{
|
||||
Copy();
|
||||
}
|
||||
|
||||
void wxTextCtrl::OnPaste(wxCommandEvent& WXUNUSED(event))
|
||||
{
|
||||
Paste();
|
||||
}
|
||||
|
||||
void wxTextCtrl::OnUndo(wxCommandEvent& WXUNUSED(event))
|
||||
{
|
||||
Undo();
|
||||
}
|
||||
|
||||
void wxTextCtrl::OnRedo(wxCommandEvent& WXUNUSED(event))
|
||||
{
|
||||
Redo();
|
||||
}
|
||||
|
||||
void wxTextCtrl::OnUpdateCut(wxUpdateUIEvent& event)
|
||||
{
|
||||
event.Enable( CanCut() );
|
||||
}
|
||||
|
||||
void wxTextCtrl::OnUpdateCopy(wxUpdateUIEvent& event)
|
||||
{
|
||||
event.Enable( CanCopy() );
|
||||
}
|
||||
|
||||
void wxTextCtrl::OnUpdatePaste(wxUpdateUIEvent& event)
|
||||
{
|
||||
event.Enable( CanPaste() );
|
||||
}
|
||||
|
||||
void wxTextCtrl::OnUpdateUndo(wxUpdateUIEvent& event)
|
||||
{
|
||||
event.Enable( CanUndo() );
|
||||
}
|
||||
|
||||
void wxTextCtrl::OnUpdateRedo(wxUpdateUIEvent& event)
|
||||
{
|
||||
event.Enable( CanRedo() );
|
||||
}
|
||||
|
@@ -450,7 +450,12 @@ void wxFrame::ProcessCommand(int id)
|
||||
}
|
||||
*/
|
||||
|
||||
GetEventHandler()->ProcessEvent(commandEvent);
|
||||
// Process events starting with the window with the focus, if any.
|
||||
wxWindow* focusWin = wxFindFocusDescendant(this);
|
||||
|
||||
wxEvtHandler* evtHandler = focusWin ? focusWin->GetEventHandler() : GetEventHandler();
|
||||
|
||||
evtHandler->ProcessEvent(commandEvent);
|
||||
}
|
||||
|
||||
// Checks if there is a toolbar, and returns the first free client position
|
||||
|
@@ -450,7 +450,12 @@ void wxFrame::ProcessCommand(int id)
|
||||
}
|
||||
*/
|
||||
|
||||
GetEventHandler()->ProcessEvent(commandEvent);
|
||||
// Process events starting with the window with the focus, if any.
|
||||
wxWindow* focusWin = wxFindFocusDescendant(this);
|
||||
|
||||
wxEvtHandler* evtHandler = focusWin ? focusWin->GetEventHandler() : GetEventHandler();
|
||||
|
||||
evtHandler->ProcessEvent(commandEvent);
|
||||
}
|
||||
|
||||
// Checks if there is a toolbar, and returns the first free client position
|
||||
|
@@ -27,6 +27,7 @@ LIB_CPP_SRC=\
|
||||
common/image.cpp \
|
||||
common/imagjpeg.cpp \
|
||||
common/imagpng.cpp \
|
||||
common/imaggif.cpp \
|
||||
common/intl.cpp \
|
||||
common/ipcbase.cpp \
|
||||
common/layout.cpp \
|
||||
|
@@ -869,7 +869,12 @@ void wxFrame::ProcessCommand(int id)
|
||||
}
|
||||
*/
|
||||
|
||||
GetEventHandler()->ProcessEvent(commandEvent);
|
||||
// Process events starting with the window with the focus, if any.
|
||||
wxWindow* focusWin = wxFindFocusDescendant(this);
|
||||
|
||||
wxEvtHandler* evtHandler = focusWin ? focusWin->GetEventHandler() : GetEventHandler();
|
||||
|
||||
evtHandler->ProcessEvent(commandEvent);
|
||||
}
|
||||
|
||||
// Checks if there is a toolbar, and returns the first free client position
|
||||
|
@@ -33,6 +33,7 @@ LIB_CPP_SRC=\
|
||||
../common/image.cpp \
|
||||
../common/imagjpeg.cpp \
|
||||
../common/imagpng.cpp \
|
||||
../common/imaggif.cpp \
|
||||
../common/layout.cpp \
|
||||
../common/list.cpp \
|
||||
../common/log.cpp \
|
||||
|
@@ -57,6 +57,19 @@ static void wxTextWindowActivateProc(Widget w, XtPointer clientData, XmAnyCallba
|
||||
BEGIN_EVENT_TABLE(wxTextCtrl, wxControl)
|
||||
EVT_DROP_FILES(wxTextCtrl::OnDropFiles)
|
||||
EVT_CHAR(wxTextCtrl::OnChar)
|
||||
|
||||
EVT_MENU(wxID_CUT, wxTextCtrl::OnCut)
|
||||
EVT_MENU(wxID_COPY, wxTextCtrl::OnCopy)
|
||||
EVT_MENU(wxID_PASTE, wxTextCtrl::OnPaste)
|
||||
EVT_MENU(wxID_UNDO, wxTextCtrl::OnUndo)
|
||||
EVT_MENU(wxID_REDO, wxTextCtrl::OnRedo)
|
||||
|
||||
EVT_UPDATE_UI(wxID_CUT, wxTextCtrl::OnUpdateCut)
|
||||
EVT_UPDATE_UI(wxID_COPY, wxTextCtrl::OnUpdateCopy)
|
||||
EVT_UPDATE_UI(wxID_PASTE, wxTextCtrl::OnUpdatePaste)
|
||||
EVT_UPDATE_UI(wxID_UNDO, wxTextCtrl::OnUpdateUndo)
|
||||
EVT_UPDATE_UI(wxID_REDO, wxTextCtrl::OnUpdateRedo)
|
||||
|
||||
END_EVENT_TABLE()
|
||||
#endif
|
||||
|
||||
@@ -995,3 +1008,52 @@ static void wxTextWindowActivateProc(Widget w, XtPointer clientData,
|
||||
tw->ProcessCommand(event);
|
||||
}
|
||||
|
||||
void wxTextCtrl::OnCut(wxCommandEvent& WXUNUSED(event))
|
||||
{
|
||||
Cut();
|
||||
}
|
||||
|
||||
void wxTextCtrl::OnCopy(wxCommandEvent& WXUNUSED(event))
|
||||
{
|
||||
Copy();
|
||||
}
|
||||
|
||||
void wxTextCtrl::OnPaste(wxCommandEvent& WXUNUSED(event))
|
||||
{
|
||||
Paste();
|
||||
}
|
||||
|
||||
void wxTextCtrl::OnUndo(wxCommandEvent& WXUNUSED(event))
|
||||
{
|
||||
Undo();
|
||||
}
|
||||
|
||||
void wxTextCtrl::OnRedo(wxCommandEvent& WXUNUSED(event))
|
||||
{
|
||||
Redo();
|
||||
}
|
||||
|
||||
void wxTextCtrl::OnUpdateCut(wxUpdateUIEvent& event)
|
||||
{
|
||||
event.Enable( CanCut() );
|
||||
}
|
||||
|
||||
void wxTextCtrl::OnUpdateCopy(wxUpdateUIEvent& event)
|
||||
{
|
||||
event.Enable( CanCopy() );
|
||||
}
|
||||
|
||||
void wxTextCtrl::OnUpdatePaste(wxUpdateUIEvent& event)
|
||||
{
|
||||
event.Enable( CanPaste() );
|
||||
}
|
||||
|
||||
void wxTextCtrl::OnUpdateUndo(wxUpdateUIEvent& event)
|
||||
{
|
||||
event.Enable( CanUndo() );
|
||||
}
|
||||
|
||||
void wxTextCtrl::OnUpdateRedo(wxUpdateUIEvent& event)
|
||||
{
|
||||
event.Enable( CanRedo() );
|
||||
}
|
||||
|
@@ -916,7 +916,12 @@ void wxFrame::ProcessCommand(int id)
|
||||
{
|
||||
bar->Check(id,!bar->Checked(id)) ;
|
||||
}
|
||||
GetEventHandler()->ProcessEvent(commandEvent);
|
||||
|
||||
// Process events starting with the window with the focus, if any.
|
||||
wxWindow* focusWin = wxFindFocusDescendant(this);
|
||||
|
||||
wxEvtHandler* evtHandler = focusWin ? focusWin->GetEventHandler() : GetEventHandler();
|
||||
evtHandler->ProcessEvent(commandEvent);
|
||||
}
|
||||
|
||||
// Checks if there is a toolbar, and returns the first free client position
|
||||
|
@@ -114,6 +114,7 @@ COMMONOBJS = \
|
||||
..\common\$D\image.obj \
|
||||
..\common\$D\imagjpeg.obj \
|
||||
..\common\$D\imagpng.obj \
|
||||
..\common\$D\imaggif.obj \
|
||||
..\common\$D\intl.obj \
|
||||
..\common\$D\ipcbase.obj \
|
||||
..\common\$D\helpbase.obj \
|
||||
|
@@ -68,13 +68,27 @@
|
||||
#endif
|
||||
|
||||
#if !USE_SHARED_LIBRARY
|
||||
|
||||
IMPLEMENT_DYNAMIC_CLASS(wxTextCtrl, wxControl)
|
||||
|
||||
BEGIN_EVENT_TABLE(wxTextCtrl, wxControl)
|
||||
EVT_CHAR(wxTextCtrl::OnChar)
|
||||
EVT_DROP_FILES(wxTextCtrl::OnDropFiles)
|
||||
EVT_ERASE_BACKGROUND(wxTextCtrl::OnEraseBackground)
|
||||
|
||||
EVT_MENU(wxID_CUT, wxTextCtrl::OnCut)
|
||||
EVT_MENU(wxID_COPY, wxTextCtrl::OnCopy)
|
||||
EVT_MENU(wxID_PASTE, wxTextCtrl::OnPaste)
|
||||
EVT_MENU(wxID_UNDO, wxTextCtrl::OnUndo)
|
||||
EVT_MENU(wxID_REDO, wxTextCtrl::OnRedo)
|
||||
|
||||
EVT_UPDATE_UI(wxID_CUT, wxTextCtrl::OnUpdateCut)
|
||||
EVT_UPDATE_UI(wxID_COPY, wxTextCtrl::OnUpdateCopy)
|
||||
EVT_UPDATE_UI(wxID_PASTE, wxTextCtrl::OnUpdatePaste)
|
||||
EVT_UPDATE_UI(wxID_UNDO, wxTextCtrl::OnUpdateUndo)
|
||||
EVT_UPDATE_UI(wxID_REDO, wxTextCtrl::OnUpdateRedo)
|
||||
END_EVENT_TABLE()
|
||||
|
||||
#endif // USE_SHARED_LIBRARY
|
||||
|
||||
// Text item
|
||||
@@ -363,20 +377,29 @@ void wxTextCtrl::DoSetSize(int x, int y, int width, int height, int sizeFlags)
|
||||
// Clipboard operations
|
||||
void wxTextCtrl::Copy()
|
||||
{
|
||||
HWND hWnd = (HWND) GetHWND();
|
||||
SendMessage(hWnd, WM_COPY, 0, 0L);
|
||||
if (CanCopy())
|
||||
{
|
||||
HWND hWnd = (HWND) GetHWND();
|
||||
SendMessage(hWnd, WM_COPY, 0, 0L);
|
||||
}
|
||||
}
|
||||
|
||||
void wxTextCtrl::Cut()
|
||||
{
|
||||
HWND hWnd = (HWND) GetHWND();
|
||||
SendMessage(hWnd, WM_CUT, 0, 0L);
|
||||
if (CanCut())
|
||||
{
|
||||
HWND hWnd = (HWND) GetHWND();
|
||||
SendMessage(hWnd, WM_CUT, 0, 0L);
|
||||
}
|
||||
}
|
||||
|
||||
void wxTextCtrl::Paste()
|
||||
{
|
||||
HWND hWnd = (HWND) GetHWND();
|
||||
SendMessage(hWnd, WM_PASTE, 0, 0L);
|
||||
if (CanPaste())
|
||||
{
|
||||
HWND hWnd = (HWND) GetHWND();
|
||||
SendMessage(hWnd, WM_PASTE, 0, 0L);
|
||||
}
|
||||
}
|
||||
|
||||
void wxTextCtrl::SetEditable(bool editable)
|
||||
@@ -1235,3 +1258,53 @@ bool wxTextCtrl::MSWNotify(WXWPARAM wParam, WXLPARAM lParam)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
void wxTextCtrl::OnCut(wxCommandEvent& event)
|
||||
{
|
||||
Cut();
|
||||
}
|
||||
|
||||
void wxTextCtrl::OnCopy(wxCommandEvent& event)
|
||||
{
|
||||
Copy();
|
||||
}
|
||||
|
||||
void wxTextCtrl::OnPaste(wxCommandEvent& event)
|
||||
{
|
||||
Paste();
|
||||
}
|
||||
|
||||
void wxTextCtrl::OnUndo(wxCommandEvent& event)
|
||||
{
|
||||
Undo();
|
||||
}
|
||||
|
||||
void wxTextCtrl::OnRedo(wxCommandEvent& event)
|
||||
{
|
||||
Redo();
|
||||
}
|
||||
|
||||
void wxTextCtrl::OnUpdateCut(wxUpdateUIEvent& event)
|
||||
{
|
||||
event.Enable( CanCut() );
|
||||
}
|
||||
|
||||
void wxTextCtrl::OnUpdateCopy(wxUpdateUIEvent& event)
|
||||
{
|
||||
event.Enable( CanCopy() );
|
||||
}
|
||||
|
||||
void wxTextCtrl::OnUpdatePaste(wxUpdateUIEvent& event)
|
||||
{
|
||||
event.Enable( CanPaste() );
|
||||
}
|
||||
|
||||
void wxTextCtrl::OnUpdateUndo(wxUpdateUIEvent& event)
|
||||
{
|
||||
event.Enable( CanUndo() );
|
||||
}
|
||||
|
||||
void wxTextCtrl::OnUpdateRedo(wxUpdateUIEvent& event)
|
||||
{
|
||||
event.Enable( CanRedo() );
|
||||
}
|
||||
|
||||
|
@@ -451,7 +451,12 @@ void wxFrame::ProcessCommand(int id)
|
||||
}
|
||||
*/
|
||||
|
||||
GetEventHandler()->ProcessEvent(commandEvent);
|
||||
// Process events starting with the window with the focus, if any.
|
||||
wxWindow* focusWin = wxFindFocusDescendant(this);
|
||||
|
||||
wxEvtHandler* evtHandler = focusWin ? focusWin->GetEventHandler() : GetEventHandler();
|
||||
|
||||
evtHandler->ProcessEvent(commandEvent);
|
||||
}
|
||||
|
||||
// Checks if there is a toolbar, and returns the first free client position
|
||||
|
@@ -35,6 +35,17 @@ IMPLEMENT_DYNAMIC_CLASS(wxTextCtrl, wxControl)
|
||||
|
||||
BEGIN_EVENT_TABLE(wxTextCtrl, wxControl)
|
||||
EVT_DROP_FILES(wxTextCtrl::OnDropFiles)
|
||||
EVT_MENU(wxID_CUT, wxTextCtrl::OnCut)
|
||||
EVT_MENU(wxID_COPY, wxTextCtrl::OnCopy)
|
||||
EVT_MENU(wxID_PASTE, wxTextCtrl::OnPaste)
|
||||
EVT_MENU(wxID_UNDO, wxTextCtrl::OnUndo)
|
||||
EVT_MENU(wxID_REDO, wxTextCtrl::OnRedo)
|
||||
|
||||
EVT_UPDATE_UI(wxID_CUT, wxTextCtrl::OnUpdateCut)
|
||||
EVT_UPDATE_UI(wxID_COPY, wxTextCtrl::OnUpdateCopy)
|
||||
EVT_UPDATE_UI(wxID_PASTE, wxTextCtrl::OnUpdatePaste)
|
||||
EVT_UPDATE_UI(wxID_UNDO, wxTextCtrl::OnUpdateUndo)
|
||||
EVT_UPDATE_UI(wxID_REDO, wxTextCtrl::OnUpdateRedo)
|
||||
END_EVENT_TABLE()
|
||||
#endif
|
||||
|
||||
@@ -496,3 +507,52 @@ wxTextCtrl& wxTextCtrl::operator<<(const char c)
|
||||
return *this;
|
||||
}
|
||||
|
||||
void wxTextCtrl::OnCut(wxCommandEvent& event)
|
||||
{
|
||||
Cut();
|
||||
}
|
||||
|
||||
void wxTextCtrl::OnCopy(wxCommandEvent& event)
|
||||
{
|
||||
Copy();
|
||||
}
|
||||
|
||||
void wxTextCtrl::OnPaste(wxCommandEvent& event)
|
||||
{
|
||||
Paste();
|
||||
}
|
||||
|
||||
void wxTextCtrl::OnUndo(wxCommandEvent& event)
|
||||
{
|
||||
Undo();
|
||||
}
|
||||
|
||||
void wxTextCtrl::OnRedo(wxCommandEvent& event)
|
||||
{
|
||||
Redo();
|
||||
}
|
||||
|
||||
void wxTextCtrl::OnUpdateCut(wxUpdateUIEvent& event)
|
||||
{
|
||||
event.Enable( CanCut() );
|
||||
}
|
||||
|
||||
void wxTextCtrl::OnUpdateCopy(wxUpdateUIEvent& event)
|
||||
{
|
||||
event.Enable( CanCopy() );
|
||||
}
|
||||
|
||||
void wxTextCtrl::OnUpdatePaste(wxUpdateUIEvent& event)
|
||||
{
|
||||
event.Enable( CanPaste() );
|
||||
}
|
||||
|
||||
void wxTextCtrl::OnUpdateUndo(wxUpdateUIEvent& event)
|
||||
{
|
||||
event.Enable( CanUndo() );
|
||||
}
|
||||
|
||||
void wxTextCtrl::OnUpdateRedo(wxUpdateUIEvent& event)
|
||||
{
|
||||
event.Enable( CanRedo() );
|
||||
}
|
||||
|
Reference in New Issue
Block a user