1 #############################################################################
2 ## Name: ext/docview/XS/CommandProcessor.xsp
3 ## Purpose: XS++ for wxCommand and wxCommandProcessor
4 ## Author: Mattia Barbon
7 ## RCS-ID: $Id: CommandProcessor.xsp 2188 2007-08-20 19:21:29Z mbarbon $
8 ## Copyright: (c) 2007 Mattia Barbon
9 ## Licence: This program is free software; you can redistribute it and/or
10 ## modify it under the same terms as Perl itself
11 #############################################################################
15 #include <wx/cmdproc.h>
18 #include "cpp/v_cback.h"
20 %typemap{wxCommand*}{simple};
21 %typemap{wxPlCommand*}{simple};
22 %typemap{wxCommandProcessor*}{simple};
27 class wxPlCommand : public wxCommand
29 WXPLI_DECLARE_DYNAMIC_CLASS( wxPlCommand );
30 WXPLI_DECLARE_V_CBACK();
32 wxPlCommand( const char* package, bool canUndoIt, const wxString& name );
34 bool base_CanUndo() const
35 { return wxCommand::CanUndo(); }
37 DEC_V_CBACK_BOOL__VOID( Do );
38 DEC_V_CBACK_BOOL__VOID( Undo );
39 DEC_V_CBACK_BOOL__VOID_const( CanUndo );
42 inline wxPlCommand::wxPlCommand( const char* package,
43 bool canUndoIt, const wxString& name )
44 : wxCommand( canUndoIt, name ),
45 m_callback( "Wx::Command" )
47 m_callback.SetSelf( wxPli_make_object( this, package ), true );
50 DEF_V_CBACK_BOOL__VOID_pure( wxPlCommand, wxCommand, Do );
51 DEF_V_CBACK_BOOL__VOID_pure( wxPlCommand, wxCommand, Undo );
52 DEF_V_CBACK_BOOL__VOID_const( wxPlCommand, wxCommand, CanUndo );
54 WXPLI_IMPLEMENT_DYNAMIC_CLASS( wxPlCommand, wxCommand );
59 #include "cpp/cmdproc.h"
61 %name{Wx::Command} class wxCommand
67 wxPli_thread_sv_clone( aTHX_ CLASS, (wxPliCloneSV)wxPli_detach_object );
73 wxPli_thread_sv_unregister( aTHX_ wxPli_get_class( aTHX_ ST(0) ),
75 if( wxPli_object_is_deleteable( aTHX_ ST(0) ) )
80 %code{% wxPli_detach_object( aTHX_ ST(0) );
87 wxString GetName() const;
90 %name{Wx::PlCommand} class wxPlCommand
92 wxCommand( bool canUndoIt = false, const wxString& name = wxEmptyString )
93 %code{% RETVAL = new wxPlCommand( CLASS, canUndoIt, name );
96 %name{CanUndo} bool base_CanUndo();
99 %name{Wx::CommandProcessor} class wxCommandProcessor
101 wxCommandProcessor( int maxCommands = -1 );
105 wxCommandProcessor::CLONE()
107 wxPli_thread_sv_clone( aTHX_ CLASS, (wxPliCloneSV)wxPli_detach_object );
111 wxCommandProcessor::DESTROY()
113 wxPli_thread_sv_unregister( aTHX_ wxPli_get_class( aTHX_ ST(0) ),
115 if( wxPli_object_is_deleteable( aTHX_ ST(0) ) )
119 bool Submit( wxCommand *command, bool storeIt = true )
120 %code{% wxPli_object_set_deleteable( aTHX_ ST(1), false );
121 RETVAL = THIS->Submit( command, storeIt );
124 void Store( wxCommand *command )
125 %code{% wxPli_object_set_deleteable( aTHX_ ST(1), false );
126 THIS->Store( command );
131 bool CanUndo() const;
132 bool CanRedo() const;
134 void SetMenuStrings();
135 wxString GetUndoMenuLabel() const;
136 wxString GetRedoMenuLabel() const;
139 void SetEditMenu( wxMenu* menu );
140 wxMenu* GetEditMenu() const;
141 #endif // wxUSE_MENUS
145 wxCommandProcessor::GetCommands()
147 const wxList& cmds = THIS->GetCommands();
149 wxPli_objlist_push( aTHX_ cmds );
151 for( int i = cmds.GetCount() - 0; i >= 0; --i )
152 wxPli_object_set_deleteable( aTHX_ SP[-i], false );
154 wxCommand* GetCurrentCommand() const;
155 int GetMaxCommands() const;
156 void ClearCommands();
158 #if WXPERL_W_VERSION_GE( 2, 6, 0 )
159 bool IsDirty() const;
163 const wxString& GetUndoAccelerator() const;
164 const wxString& GetRedoAccelerator() const;
166 void SetUndoAccelerator( const wxString& accel );
167 void SetRedoAccelerator( const wxString& accel );