summaryrefslogtreecommitdiff
path: root/muse2/muse/cobject.h
blob: 6b982747d95ac7b2a571500086a956e4a603825c (plain)
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
//=========================================================
//  MusE
//  Linux Music Editor
//  $Id: cobject.h,v 1.3.2.1 2005/12/11 21:29:24 spamatica Exp $
//
//  (C) Copyright 1999/2000 Werner Schweer (ws@seh.de)
//=========================================================

#ifndef __COBJECT_H__
#define __COBJECT_H__

#include "config.h"

#include <QMainWindow>
#include <list>
#include <QByteArray>
#include <QString>

class QMdiSubWindow;
class QFocusEvent;
class QToolBar;
class Xml;
class QAction;

//---------------------------------------------------------
//   TopWin
//---------------------------------------------------------

class TopWin : public QMainWindow
      {
      Q_OBJECT

   public:
      enum ToplevelType { PIANO_ROLL=0, LISTE, DRUM, MASTER, WAVE, //there shall be no
         LMASTER, CLIPLIST, MARKER, SCORE, ARRANGER,               //gaps in the enum!
#ifdef PATCHBAY
         M_PATCHBAY,
#endif /* PATCHBAY */
         TOPLEVELTYPE_LAST_ENTRY //this has to be always the last entry
         };

      ToplevelType type() const { return _type; }
      static QString typeName(ToplevelType t);


      virtual void readStatus(Xml&);
      virtual void writeStatus(int, Xml&) const;

      static void readConfiguration(ToplevelType, Xml&);
      static void writeConfiguration(ToplevelType, int, Xml&);
      
      
      bool isMdiWin();

      TopWin(ToplevelType t, QWidget* parent=0, const char* name=0, Qt::WindowFlags f = Qt::Window);
         
      bool sharesToolsAndMenu() { return _sharesToolsAndMenu; }
      const std::list<QToolBar*>& toolbars() { return _toolbars; }
      
      void addToolBar(QToolBar* toolbar);
      QToolBar* addToolBar(const QString& title);
         
 
      static bool _sharesWhenFree[TOPLEVELTYPE_LAST_ENTRY];
      static bool _sharesWhenSubwin[TOPLEVELTYPE_LAST_ENTRY];
      static bool _defaultSubwin[TOPLEVELTYPE_LAST_ENTRY];
 
  private:
      QMdiSubWindow* mdisubwin;
      bool _sharesToolsAndMenu;
      std::list<QToolBar*> _toolbars;

      void insertToolBar(QToolBar*, QToolBar*);
      void insertToolBarBreak(QToolBar*);
      void removeToolBar(QToolBar*);
      void removeToolBarBreak(QToolBar*);
      void addToolBar(Qt::ToolBarArea, QToolBar*);

      virtual QMdiSubWindow* createMdiWrapper();
      
      static void initConfiguration();

  protected:
      QAction* subwinAction;
      QAction* shareAction;

      ToplevelType _type;

      static int _widthInit[TOPLEVELTYPE_LAST_ENTRY];
      static int _heightInit[TOPLEVELTYPE_LAST_ENTRY];
      static QByteArray _toolbarNonsharedInit[TOPLEVELTYPE_LAST_ENTRY];
      static QByteArray _toolbarSharedInit[TOPLEVELTYPE_LAST_ENTRY];
      static bool initInited;
      
      void initTopwinState();

      bool initalizing; //if true, no state is saved
  
  public slots:
      virtual void hide();
      virtual void show();
      virtual void setVisible(bool);
      void setIsMdiWin(bool);
      void shareToolsAndMenu(bool);
      void restoreMainwinState();
      void storeInitialState();
  
      };


typedef std::list <TopWin*> ToplevelList;
typedef ToplevelList::iterator iToplevel;
typedef ToplevelList::const_iterator ciToplevel;

#endif