~ubuntu-branches/ubuntu/feisty/muse/feisty

« back to all changes in this revision

Viewing changes to ctrl/ctrledit.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Daniel Kobras
  • Date: 2002-04-23 17:28:23 UTC
  • Revision ID: james.westby@ubuntu.com-20020423172823-w8yplzr81a759xa3
Tags: upstream-0.5.2
ImportĀ upstreamĀ versionĀ 0.5.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
//=========================================================
 
2
//  MusE
 
3
//  Linux Music Editor
 
4
//    $Id: ctrledit.cpp,v 1.1 2002/01/30 12:08:38 muse Exp $
 
5
//  (C) Copyright 1999 Werner Schweer (ws@seh.de)
 
6
//=========================================================
 
7
 
 
8
#include <stdio.h>
 
9
#include "ctrledit.h"
 
10
#include "ctrlcanvas.h"
 
11
#include "midieditor.h"
 
12
#include "xml.h"
 
13
#include "vscale.h"
 
14
#include "ctrlpanel.h"
 
15
 
 
16
#include <qlayout.h>
 
17
#include <qpainter.h>
 
18
#include <qtoolbutton.h>
 
19
#include <qpopupmenu.h>
 
20
#include <qlabel.h>
 
21
 
 
22
//---------------------------------------------------------
 
23
//   setTool
 
24
//---------------------------------------------------------
 
25
 
 
26
void CtrlEdit::setTool(int t)
 
27
      {
 
28
      canvas->setTool(t);
 
29
      }
 
30
 
 
31
//---------------------------------------------------------
 
32
//   CtrlEdit
 
33
//---------------------------------------------------------
 
34
 
 
35
CtrlEdit::CtrlEdit(QWidget* parent, MidiEditor* e, int xmag,
 
36
   bool expand=false, const char* name = 0) : QWidget(parent, name)
 
37
      {
 
38
      QHBoxLayout* hbox = new QHBoxLayout(this);
 
39
      panel             = new CtrlPanel(this, e, "panel");
 
40
      canvas            = new CtrlCanvas(e, this, xmag, "ctrlcanvas");
 
41
      QWidget* vscale   = new VScale(this);
 
42
 
 
43
      canvas->setOrigin(-(division/4), 0);
 
44
 
 
45
      canvas->setMinimumHeight(50);
 
46
      panel->setFixedWidth(40);
 
47
 
 
48
      hbox->addWidget(panel,  expand ? 100 : 0, AlignRight);
 
49
      hbox->addWidget(canvas, 100);
 
50
      hbox->addWidget(vscale, 0);
 
51
 
 
52
      connect(panel, SIGNAL(destroyPanel()), SLOT(destroy()));
 
53
      connect(panel, SIGNAL(controllerChanged(const MidiController&)),
 
54
         canvas, SLOT(setController(const MidiController&)));
 
55
      connect(canvas, SIGNAL(xposChanged(int)), SIGNAL(timeChanged(int)));
 
56
      connect(canvas, SIGNAL(yposChanged(int)), SIGNAL(yposChanged(int)));
 
57
      }
 
58
 
 
59
//---------------------------------------------------------
 
60
//   writeStatus
 
61
//---------------------------------------------------------
 
62
 
 
63
void CtrlEdit::writeStatus(int level, Xml& xml)
 
64
      {
 
65
      xml.tag(level++, "ctrledit");
 
66
      canvas->controller().write(level, xml);
 
67
      xml.tag(level, "/ctrledit");
 
68
      }
 
69
 
 
70
//---------------------------------------------------------
 
71
//   readStatus
 
72
//---------------------------------------------------------
 
73
 
 
74
void CtrlEdit::readStatus(Xml& xml)
 
75
      {
 
76
      for (;;) {
 
77
            Xml::Token token = xml.parse();
 
78
            const QString& tag = xml.s1();
 
79
            switch (token) {
 
80
                  case Xml::Error:
 
81
                  case Xml::End:
 
82
                        return;
 
83
                  case Xml::TagStart:
 
84
                        if (tag == "mctrl") {
 
85
                              MidiController ctrl;
 
86
                              ctrl.read(xml);
 
87
                              canvas->setController(ctrl);
 
88
                              }
 
89
                        else
 
90
                              xml.unknown("CtrlEdit");
 
91
                        break;
 
92
                  case Xml::TagEnd:
 
93
                        if (tag == "ctrledit")
 
94
                              return;
 
95
                  default:
 
96
                        break;
 
97
                  }
 
98
            }
 
99
      }
 
100
 
 
101
//---------------------------------------------------------
 
102
//   destroy
 
103
//---------------------------------------------------------
 
104
 
 
105
void CtrlEdit::destroy()
 
106
      {
 
107
      emit destroyedCtrl(this);
 
108
      close(true);      // close and destroy widget
 
109
      }
 
110
 
 
111