• Main Page
  • Related Pages
  • Namespaces
  • Classes
  • Files
  • File List
  • File Members

LoadBindings.h

Go to the documentation of this file.
00001 /*
00002  * LoadBindings - Simple parser to read keybindings for AbiWord
00003  * Copyright (C) 2007 by Martin Sevior
00004  *
00005  * This program is free software; you can redistribute it and/or
00006  * modify it under the terms of the GNU General Public License
00007  * as published by the Free Software Foundation; either version 2
00008  * of the License, or (at your option) any later version.
00009  *
00010  * This program is distributed in the hope that it will be useful,
00011  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013  * GNU General Public License for more details.
00014  *
00015  * You should have received a copy of the GNU General Public License
00016  * along with this program; if not, write to the Free Software
00017  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
00018  * 02110-1301 USA.
00019  */
00020 
00021 #ifndef PLUGIN_LOADBINDINGS_H
00022 #define PLUGIN_LOADBINDINGS_H
00023 #include "ut_string_class.h"
00024 #include "ev_EditEventMapper.h"
00025 #include "ev_EditEventMapper.h"
00026 #include "ev_EditBinding.h"
00027 
00028 class AV_View;
00029 class FL_DocLayout;
00030 class XAP_App;
00031 class EV_EditMethodCallData;
00032 
00033 enum {
00034     DONT_UNBIND_MOUSECONTEXTS   = 0x01,
00035     DONT_UNBIND_KEYSTROKES      = 0x02,
00036 
00037     DONT_UNBIND_ANYTHING        = 0x03
00038 };
00039 
00040 enum _FROM_URI { FROM_URI };
00041 enum _FROM_MEMORY { FROM_MEMORY };
00042 
00043 typedef std::map<std::string,UT_uint8> UnbindMap;
00044 typedef std::map<UT_uint32,std::string> BindingMap;
00045 
00046 class LoadBindings
00047 {
00048     public:
00049         LoadBindings(EV_EditMethodCallData * d, _FROM_URI);
00050         LoadBindings(EV_EditMethodCallData * d, _FROM_MEMORY);
00051         ~LoadBindings();
00052         bool Load();
00053         bool Set() const;
00054         const std::string& GetName() const { return m_sName; }
00055 
00056     protected:
00057         XAP_App*            m_pApp;
00058         xmlDocPtr           m_pXMLDoc;
00059         std::string         m_sName;
00060         bool                m_bReplace;
00061         BindingMap          m_BindMap;
00062         UnbindMap           m_UnbindMap;
00063 
00064 
00065         int strcmp( const char* s1, const char* s2 ) {          return ::strcmp( s1, s2 ); }
00066         int strcmp( const char* s1, const xmlChar* s2 ) {       return ::strcmp( s1, reinterpret_cast<const char*>(s2) ); }
00067         int strcmp( const xmlChar* s1, const xmlChar* s2 ) {    return ::strcmp( reinterpret_cast<const char*>(s1), reinterpret_cast<const char*>(s2) ); }
00068         int strcmp( const xmlChar* s1, const char* s2 ) {       return ::strcmp( reinterpret_cast<const char*>(s1), s2 ); }
00069 
00073         EV_EditModifierState GetModifiers( xmlNodePtr node );
00074 
00078         const char* FindAttribute( xmlNodePtr node, const char* name );
00079 
00081         bool AddMapping( UT_uint32 binding, const char* command );
00082 
00084         bool RemoveMapping( const char* command, UT_uint8 unbinding );
00085 
00087         void ReportError( const char* format, ... ) const;
00088 
00090         void ReportWarning( const char* format, ... ) const;
00091 };
00092 
00093 class EV_NamedVirtualKey
00094 {
00095 public:
00096     static const char * getName(EV_EditBits eb);
00097     static EV_EditBits  getEB(const char * szName);
00098 };
00099 
00100 #endif /* PLUGIN_LOADBINDINGS_H */

Generated on Sun Feb 14 2021 for AbiWord by  doxygen 1.7.1