1 //=========================================================
2 //  MusE
3 //  Linux Music Editor
4 //  $Id: cobject.h,v 1.3.2.1 2005/12/11 21:29:24 spamatica Exp $
5 //
6 //  (C) Copyright 1999/2000 Werner Schweer (ws@seh.de)
7 //
8 //  This program is free software; you can redistribute it and/or
9 //  modify it under the terms of the GNU General Public License
10 //  as published by the Free Software Foundation; version 2 of
11 //  the License, or (at your option) any later version.
12 //
13 //  This program is distributed in the hope that it will be useful,
14 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
15 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 //  GNU General Public License for more details.
17 //
18 //  You should have received a copy of the GNU General Public License
19 //  along with this program; if not, write to the Free Software
20 //  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
21 //
22 //=========================================================
23 
24 #ifndef __COBJECT_H__
25 #define __COBJECT_H__
26 
27 #include "config.h"
28 
29 #include <QMainWindow>
30 #include <list>
31 #include <QByteArray>
32 #include <QString>
33 
34 
35 // Forward declarations:
36 class QMdiSubWindow;
37 class QFocusEvent;
38 class QCloseEvent;
39 class QToolBar;
40 class QAction;
41 
42 namespace MusECore {
43 class Xml;
44 }
45 
46 namespace MusEGui {
47 
48 //---------------------------------------------------------
49 //   TopWin
50 //---------------------------------------------------------
51 
52 class TopWin : public QMainWindow
53       {
54       Q_OBJECT
55 
56    public:
57       enum ToplevelType { PIANO_ROLL=0, DRUM, MASTER, WAVE, SCORE, ARRANGER, // no gaps in the enum!
58 #ifdef PATCHBAY
59          M_PATCHBAY,
60 #endif /* PATCHBAY */
61          TOPLEVELTYPE_LAST_ENTRY //this has to be always the last entry
62          };
63 
type()64       ToplevelType type() const { return _type; }
65       static QString typeName(ToplevelType t);
66       static QIcon typeIcon(ToplevelType t);
67 
initalizing()68       bool initalizing() const { return _initalizing; }
deleting()69       bool deleting() const { return _isDeleting; }
70 
71       virtual void readStatus(MusECore::Xml&);
72       virtual void writeStatus(int, MusECore::Xml&) const;
73 
74       static void readConfiguration(ToplevelType, MusECore::Xml&);
75       static void writeConfiguration(ToplevelType, int, MusECore::Xml&);
76 
77       virtual void storeSettings();
78 
79       bool isMdiWin() const;
getMdiWin()80       QMdiSubWindow* getMdiWin() const { return mdisubwin; }
81 
82       TopWin(ToplevelType t, QWidget* parent=nullptr, const char* name=nullptr, Qt::WindowFlags f = Qt::Window);
83       virtual ~TopWin();
84 
sharesToolsAndMenu()85       bool sharesToolsAndMenu() const { return _sharesToolsAndMenu; }
toolbars()86       const std::list<QToolBar*>& toolbars() { return _toolbars; }
87 
88       virtual void addToolBar(QToolBar* toolbar);
89       virtual QToolBar* addToolBar(const QString& title);
90       virtual void addToolBarBreak(Qt::ToolBarArea area = Qt::TopToolBarArea);
91       virtual void insertToolBar(QToolBar*, QToolBar*);
92       virtual void insertToolBarBreak(QToolBar*);
93       virtual void removeToolBar(QToolBar*);
94       virtual void removeToolBarBreak(QToolBar*);
95       virtual void addToolBar(Qt::ToolBarArea, QToolBar*);
96 
97       void resize(int w, int h);
98 //      void resize(const QSize&);
99 
100 //      static bool _sharesWhenFree[TOPLEVELTYPE_LAST_ENTRY];
101 //      static bool _sharesMenusToolbars[TOPLEVELTYPE_LAST_ENTRY];
102       static bool _openTabbed[TOPLEVELTYPE_LAST_ENTRY];
103 
104   private:
105       QMdiSubWindow* mdisubwin;
106       bool _sharesToolsAndMenu;
107       std::list<QToolBar*> _toolbars;
108       bool _initalizing;
109 
110       void createMdiWrapper();
111 
112       static void initConfiguration();
113 
114   protected:
115       QAction* subwinAction;
116 //      QAction* shareAction;
117       QAction* fullscreenAction;
118 
119       ToplevelType _type;
120 
121       static int _widthInit[TOPLEVELTYPE_LAST_ENTRY];
122       static int _heightInit[TOPLEVELTYPE_LAST_ENTRY];
123       static QByteArray _toolbarNonsharedInit[TOPLEVELTYPE_LAST_ENTRY];
124       static QByteArray _toolbarSharedInit[TOPLEVELTYPE_LAST_ENTRY];
125       static bool initInited;
126 
127       QByteArray _savedToolbarState;
128 
129       // Set if close has been called on a TopWin having the WA_DeleteOnClose attribute.
130       // The TopWins and any children should ignore any signals such as songChanged
131       //  which may cause a crash while deleting.
132       bool _isDeleting;
133 
134       void finalizeInit();
135       void initTopwinState();
136 
137   private slots:
138       void setFullscreen(bool);
139 
140   public slots:
141       virtual void hide();
142       virtual void show();
143       virtual void setVisible(bool);
144       void setIsMdiWin(bool);
145       void shareToolsAndMenu(bool);
146       void restoreMainwinState();
147       void storeInitialState() const;
storeInitialViewState()148       virtual void storeInitialViewState() const { }
149       virtual void setWindowTitle (const QString&);
focusCanvas()150       virtual void focusCanvas() { }
151 //      virtual void windowStateChanged(Qt::WindowStates oldState, Qt::WindowStates newState);
152       };
153 
154 
155 //---------------------------------------------------------
156 //   ToplevelList
157 //---------------------------------------------------------
158 
159 typedef std::list<TopWin*>::iterator iToplevel;
160 typedef std::list<TopWin*>::const_iterator ciToplevel;
161 
162 class ToplevelList : public std::list<TopWin* > {
163    public:
164         TopWin* findType(TopWin::ToplevelType) const;
165       };
166 
167 } // namespace MusEGui
168 
169 #endif
170 
171