File: ctrledit.cpp

package info (click to toggle)
muse 0.6.3-3
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 8,936 kB
  • ctags: 7,446
  • sloc: cpp: 66,262; sh: 8,355; makefile: 755; ansic: 172
file content (112 lines) | stat: -rw-r--r-- 3,453 bytes parent folder | download
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
//=========================================================
//  MusE
//  Linux Music Editor
//    $Id: ctrledit.cpp,v 1.1.1.1 2003/10/29 10:05:21 wschweer Exp $
//  (C) Copyright 1999 Werner Schweer (ws@seh.de)
//=========================================================

#include <stdio.h>
#include "ctrledit.h"
#include "ctrlcanvas.h"
#include "midieditor.h"
#include "xml.h"
#include "vscale.h"
#include "ctrlpanel.h"
#include "globals.h"

#include <qlayout.h>
#include <qpainter.h>
#include <qtoolbutton.h>
#include <qpopupmenu.h>
#include <qlabel.h>

//---------------------------------------------------------
//   setTool
//---------------------------------------------------------

void CtrlEdit::setTool(int t)
      {
      canvas->setTool(t);
      }

//---------------------------------------------------------
//   CtrlEdit
//---------------------------------------------------------

CtrlEdit::CtrlEdit(QWidget* parent, MidiEditor* e, int xmag,
   bool expand, const char* name) : QWidget(parent, name)
      {
      QHBoxLayout* hbox = new QHBoxLayout(this);
      panel             = new CtrlPanel(this, e, "panel");
      canvas            = new CtrlCanvas(e, this, xmag, "ctrlcanvas");
      QWidget* vscale   = new VScale(this);

      canvas->setOrigin(-(division/4), 0);

      canvas->setMinimumHeight(50);
      panel->setFixedWidth(40);

      hbox->addWidget(panel,  expand ? 100 : 0, AlignRight);
      hbox->addWidget(canvas, 100);
      hbox->addWidget(vscale, 0);

      connect(panel, SIGNAL(destroyPanel()), SLOT(destroy()));
      connect(panel, SIGNAL(controllerChanged(const MidiController&)),
         canvas, SLOT(setController(const MidiController&)));
      connect(canvas, SIGNAL(xposChanged(int)), SIGNAL(timeChanged(int)));
      connect(canvas, SIGNAL(yposChanged(int)), SIGNAL(yposChanged(int)));
      }

//---------------------------------------------------------
//   writeStatus
//---------------------------------------------------------

void CtrlEdit::writeStatus(int level, Xml& xml)
      {
      xml.tag(level++, "ctrledit");
      canvas->controller().write(level, xml);
      xml.tag(level, "/ctrledit");
      }

//---------------------------------------------------------
//   readStatus
//---------------------------------------------------------

void CtrlEdit::readStatus(Xml& xml)
      {
      for (;;) {
            Xml::Token token = xml.parse();
            const QString& tag = xml.s1();
            switch (token) {
                  case Xml::Error:
                  case Xml::End:
                        return;
                  case Xml::TagStart:
                        if (tag == "mctrl") {
                              MidiController ctrl;
                              ctrl.read(xml);
                              canvas->setController(ctrl);
                              }
                        else
                              xml.unknown("CtrlEdit");
                        break;
                  case Xml::TagEnd:
                        if (tag == "ctrledit")
                              return;
                  default:
                        break;
                  }
            }
      }

//---------------------------------------------------------
//   destroy
//---------------------------------------------------------

void CtrlEdit::destroy()
      {
      emit destroyedCtrl(this);
      close(true);      // close and destroy widget
      }