itom
Loading...
Searching...
No Matches
mode.h
1/* ********************************************************************
2 itom software
3 URL: http://www.uni-stuttgart.de/ito
4 Copyright (C) 2020, Institut für Technische Optik (ITO),
5 Universität Stuttgart, Germany
6
7 This file is part of itom.
8
9 itom is free software; you can redistribute it and/or modify it
10 under the terms of the GNU Library General Public Licence as published by
11 the Free Software Foundation; either version 2 of the Licence, or (at
12 your option) any later version.
13
14 itom is distributed in the hope that it will be useful, but
15 WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library
17 General Public Licence for more details.
18
19 You should have received a copy of the GNU Library General Public License
20 along with itom. If not, see <http://www.gnu.org/licenses/>.
21
22 Further hints:
23 ------------------------
24
25 This file belongs to the code editor of itom. The code editor is
26 in major parts a fork / rewritten version of the python-based source
27 code editor PyQode from Colin Duquesnoy and others
28 (see https://github.com/pyQode). PyQode itself is licensed under
29 the MIT License (MIT).
30
31 Some parts of the code editor of itom are also inspired by the
32 source code editor of the Spyder IDE (https://github.com/spyder-ide),
33 also licensed under the MIT License and developed by the Spyder Project
34 Contributors.
35
36*********************************************************************** */
37
38#ifndef MODE_H
39#define MODE_H
40
41#include <qstring.h>
42#include <qsharedpointer.h>
43#include <qaction.h>
44#include <qlist.h>
45
46namespace ito {
47
48class CodeEditor; //forware declaration
49
50/*
51Base class for editor extensions. An extension is a "thing" that can be
52installed on an editor to add new behaviours or to modify its appearance.
53
54A mode is added to an editor by using the ModesManager/PanelsManager:
55
56 - :meth:`pyqode.core.api.CodeEdit.modes.append` or
57 - :meth:`pyqode.core.api.CodeEdit.panels.append`
58
59Subclasses may/should override the following methods:
60
61 - :meth:`pyqode.core.api.Mode.on_install`
62 - :meth:`pyqode.core.api.Mode.on_uninstall`
63 - :meth:`pyqode.core.api.Mode.on_state_changed`
64
65..warning: The mode will be identified by its class name, this means that
66
67**there cannot be two modes of the same type on the same editor instance!**
68*/
69class Mode
70{
71public:
72 typedef QSharedPointer<Mode> Ptr;
73
74 Mode();
75 Mode(const Mode &copy);
76 Mode(const QString &name, const QString &description = "");
77 virtual ~Mode();
78
79 bool operator==(const Mode &other) const;
80
81 virtual void onInstall(CodeEditor *editor);
82 virtual void onUninstall();
83 virtual void onStateChanged(bool state);
84
85 QString name() const;
86
87 bool enabled() const;
88 void setEnabled(bool enabled);
89
90 inline CodeEditor *editor() const { return m_editor; }
91 bool onClose() const { return m_onClose; }
92
93 virtual QList<QAction*> actions() const { return QList<QAction*>(); }
94
95private:
96 QString m_name;
97 QString m_description;
98 bool m_enabled;
99 CodeEditor *m_editor;
100 bool m_onClose;
101};
102
103} //end namespace ito
104
105#endif
Definition codeEditor.h:110
Definition mode.h:70
Definition apiFunctionsGraph.cpp:40