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

« back to all changes in this revision

Viewing changes to widgets/siglabel.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: siglabel.cpp,v 1.1 2002/01/30 14:54:04 muse Exp $
 
5
//  (C) Copyright 1999 Werner Schweer (ws@seh.de)
 
6
//=========================================================
 
7
 
 
8
#include "siglabel.h"
 
9
#include <stdio.h>
 
10
 
 
11
#define TIMER1    400
 
12
#define TIMER2    200
 
13
#define TIMEC     7
 
14
#define TIMER3    100
 
15
#define TIMEC2    20
 
16
#define TIMER4    50
 
17
 
 
18
#include "globals.h"
 
19
 
 
20
//---------------------------------------------------------
 
21
//   SigLabel
 
22
//    edit Signature Values  (4/4)
 
23
//---------------------------------------------------------
 
24
 
 
25
SigLabel::SigLabel(int a, int b, QWidget* parent) : QLabel(parent)
 
26
      {
 
27
      setFocusPolicy(NoFocus);
 
28
      setValue(a, b);
 
29
      setAlignment(AlignCenter);
 
30
      setFont(font3);
 
31
      }
 
32
 
 
33
//---------------------------------------------------------
 
34
//   mousePressEvent
 
35
//---------------------------------------------------------
 
36
 
 
37
void SigLabel::mousePressEvent(QMouseEvent* event)
 
38
      {
 
39
      int button = event->button();
 
40
      bool zaehler = event->x() < width() /2;
 
41
 
 
42
      int zz = z, nn = n;
 
43
      switch (button) {
 
44
            case QMouseEvent::LeftButton:
 
45
                  return;
 
46
            case QMouseEvent::MidButton:
 
47
                  if (zaehler) {
 
48
                        --zz;
 
49
                        if (zz < 1)
 
50
                              zz = 1;
 
51
                        }
 
52
                  else {
 
53
                        switch (nn) {
 
54
                              case 1:    break;
 
55
                              case 2:    nn = 1; break;
 
56
                              case 4:    nn = 2; break;
 
57
                              case 8:    nn = 4; break;
 
58
                              case 16:   nn = 8; break;
 
59
                              case 32:   nn = 16; break;
 
60
                              case 64:   nn = 32; break;
 
61
                              case 128:  nn = 64; break;
 
62
                              }
 
63
                        }
 
64
                  break;
 
65
            case QMouseEvent::RightButton:
 
66
                  if (zaehler) {
 
67
                        ++zz;
 
68
                        if (zz > 16)
 
69
                              zz = 16;
 
70
                        }
 
71
                  else {
 
72
                        switch (nn) {
 
73
                              case 1:     nn = 2; break;
 
74
                              case 2:     nn = 4; break;
 
75
                              case 4:     nn = 8; break;
 
76
                              case 8:     nn = 16; break;
 
77
                              case 16:    nn = 32; break;
 
78
                              case 32:    nn = 64; break;
 
79
                              case 64:    nn = 128; break;
 
80
                              case 128:   break;
 
81
                              }
 
82
                        }
 
83
                  break;
 
84
            default:
 
85
                  break;
 
86
            }
 
87
      if (zz != z || nn != n) {
 
88
            setValue(zz, nn);
 
89
            emit valueChanged(zz, nn);
 
90
            }
 
91
      }
 
92
 
 
93
//---------------------------------------------------------
 
94
//   setValue
 
95
//---------------------------------------------------------
 
96
 
 
97
void SigLabel::setValue(int a, int b)
 
98
      {
 
99
      if (a == z && b == n)
 
100
            return;
 
101
      z = a;
 
102
      n = b;
 
103
      QString sa;
 
104
      sa.setNum(a);
 
105
 
 
106
      QString sb;
 
107
      sb.setNum(b);
 
108
 
 
109
      QString s = sa + "/" + sb;
 
110
      setText(s);
 
111
      }
 
112
 
 
113
//---------------------------------------------------------
 
114
//   setFrame
 
115
//---------------------------------------------------------
 
116
 
 
117
void SigLabel::setFrame(bool flag)
 
118
      {
 
119
      setFrameStyle(flag ? Panel | Sunken : NoFrame);
 
120
      setLineWidth(2);
 
121
      }