1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168
|
#############################################################################
## Name: ext/docview/XS/CommandProcessor.xsp
## Purpose: XS++ for wxCommand and wxCommandProcessor
## Author: Mattia Barbon
## Modified by:
## Created: 20/08/2007
## RCS-ID: $Id: CommandProcessor.xsp 2927 2010-06-06 08:06:10Z mbarbon $
## Copyright: (c) 2007, 2010 Mattia Barbon
## Licence: This program is free software; you can redistribute it and/or
## modify it under the same terms as Perl itself
#############################################################################
%module{Wx};
#include <wx/cmdproc.h>
#include <wx/menu.h>
#include "cpp/v_cback.h"
%typemap{wxCommand*}{simple};
%typemap{wxPlCommand*}{simple};
%typemap{wxCommandProcessor*}{simple};
%file{xspp/cmdproc.h};
%{
class wxPlCommand : public wxCommand
{
WXPLI_DECLARE_DYNAMIC_CLASS( wxPlCommand );
WXPLI_DECLARE_V_CBACK();
public:
wxPlCommand( const char* package, bool canUndoIt, const wxString& name );
bool base_CanUndo() const
{ return wxCommand::CanUndo(); }
DEC_V_CBACK_BOOL__VOID( Do );
DEC_V_CBACK_BOOL__VOID( Undo );
DEC_V_CBACK_BOOL__VOID_const( CanUndo );
};
inline wxPlCommand::wxPlCommand( const char* package,
bool canUndoIt, const wxString& name )
: wxCommand( canUndoIt, name ),
m_callback( "Wx::Command" )
{
m_callback.SetSelf( wxPli_make_object( this, package ), true );
}
DEF_V_CBACK_BOOL__VOID_pure( wxPlCommand, wxCommand, Do );
DEF_V_CBACK_BOOL__VOID_pure( wxPlCommand, wxCommand, Undo );
DEF_V_CBACK_BOOL__VOID_const( wxPlCommand, wxCommand, CanUndo );
WXPLI_IMPLEMENT_DYNAMIC_CLASS( wxPlCommand, wxCommand );
%}
%file{-};
#include "xspp/cmdproc.h"
%name{Wx::Command} class wxCommand
{
%{
static void
wxCommand::CLONE()
CODE:
wxPli_thread_sv_clone( aTHX_ CLASS, (wxPliCloneSV)wxPli_detach_object );
## // thread OK
void
wxCommand::DESTROY()
CODE:
wxPli_thread_sv_unregister( aTHX_ wxPli_get_class( aTHX_ ST(0) ),
THIS, ST(0) );
if( wxPli_object_is_deleteable( aTHX_ ST(0) ) )
delete THIS;
%}
void Destroy()
%code{% wxPli_detach_object( aTHX_ ST(0) );
delete THIS;
%};
bool Do();
bool Undo();
bool CanUndo() const;
wxString GetName() const;
};
%name{Wx::PlCommand} class wxPlCommand
{
wxCommand( bool canUndoIt = false, const wxString& name = wxEmptyString )
%code{% RETVAL = new wxPlCommand( CLASS, canUndoIt, name );
%};
%name{CanUndo} bool base_CanUndo();
};
%name{Wx::CommandProcessor} class wxCommandProcessor
{
wxCommandProcessor( int maxCommands = -1 );
%{
static void
wxCommandProcessor::CLONE()
CODE:
wxPli_thread_sv_clone( aTHX_ CLASS, (wxPliCloneSV)wxPli_detach_object );
## // thread OK
void
wxCommandProcessor::DESTROY()
CODE:
wxPli_thread_sv_unregister( aTHX_ wxPli_get_class( aTHX_ ST(0) ),
THIS, ST(0) );
if( wxPli_object_is_deleteable( aTHX_ ST(0) ) )
delete THIS;
%}
bool Submit( wxCommand *command, bool storeIt = true )
%code{% wxPli_object_set_deleteable( aTHX_ ST(1), false );
RETVAL = THIS->Submit( command, storeIt );
%};
void Store( wxCommand *command )
%code{% wxPli_object_set_deleteable( aTHX_ ST(1), false );
THIS->Store( command );
%};
bool Undo();
bool Redo();
bool CanUndo() const;
bool CanRedo() const;
void Initialize();
void SetMenuStrings();
wxString GetUndoMenuLabel() const;
wxString GetRedoMenuLabel() const;
#if wxUSE_MENUS
void SetEditMenu( wxMenu* menu );
wxMenu* GetEditMenu() const;
#endif // wxUSE_MENUS
%{
void
wxCommandProcessor::GetCommands()
PPCODE:
const wxList& cmds = THIS->GetCommands();
PUTBACK;
wxPli_objlist_push( aTHX_ cmds );
SPAGAIN;
for( int i = cmds.GetCount() - 0; i >= 0; --i )
wxPli_object_set_deleteable( aTHX_ SP[-i], false );
%}
wxCommand* GetCurrentCommand() const;
int GetMaxCommands() const;
void ClearCommands();
#if WXPERL_W_VERSION_GE( 2, 6, 0 )
bool IsDirty() const;
void MarkAsSaved();
#endif
const wxString& GetUndoAccelerator() const;
const wxString& GetRedoAccelerator() const;
void SetUndoAccelerator( const wxString& accel );
void SetRedoAccelerator( const wxString& accel );
};
|