itom  4.1.0
panel.h
1 /* ********************************************************************
2  itom software
3  URL: http://www.uni-stuttgart.de/ito
4  Copyright (C) 2020, Institut fuer Technische Optik (ITO),
5  Universitaet 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 PANEL_H
39 #define PANEL_H
40 
41 /*
42 This module contains the Panel API.
43 */
44 
45 
46 
47 #include <qwidget.h>
48 #include <qevent.h>
49 #include <qbrush.h>
50 #include <qpen.h>
51 #include "mode.h"
52 
53 namespace ito {
54 
55 class CodeEditor;
56 
57 /*
58 Base class for editor panels.
59 
60 A panel is a mode and a QWidget.
61 
62 .. note:: Use enabled to disable panel actions and setVisible to change the
63  visibility of the panel.
64 */
65 
66 class Panel : public QWidget, public Mode
67 {
68  Q_OBJECT
69 
70 public:
71  enum Position
72  {
73  Top = 0,
74  Left = 1,
75  Right = 2,
76  Bottom = 3,
77  Floating = 4
78  };
79 
80  typedef QSharedPointer<Panel> Ptr;
81 
82  Panel(const QString &name, bool dynamic, const QString &description = "", QWidget *parent = NULL);
83  virtual ~Panel();
84 
85  void setVisible(bool visible);
86 
87  bool scrollable() const;
88  void setScrollable(bool value);
89 
90  int orderInZone() const;
91  void setOrderInZone(int orderInZone);
92 
93  Position position() const;
94  void setPosition(Position pos);
95 
96  QBrush backgroundBrush() const { return m_backgroundBrush; }
97  QPen foregroundPen() const { return m_foregroundPen; }
98 
99  virtual void onInstall(CodeEditor *editor);
100 
101 protected:
102  virtual void paintEvent(QPaintEvent *e);
103 
104 
105 private:
106  bool m_dynamic;
107  int m_orderInZone;
108  bool m_scrollable;
109  QBrush m_backgroundBrush;
111 
113  Position m_position;
114 
115  Q_DISABLE_COPY(Panel)
116 };
117 
118 } //end namespace ito
119 
120 #endif
Definition: codeEditor.h:110
Definition: apiFunctionsGraph.cpp:39
QPen m_foregroundPen
position in the editor (top, left, right, bottom)
Definition: panel.h:110
Definition: mode.h:69
Definition: panel.h:66