1 /**************************************************************************
3 rhythmview.cpp - The RhythmView widget
4 Copyright (C) 1998 Antonio Larrosa Jimenez
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 Send comments and bug fixes to larrosa@kde.org
21 or to Antonio Larrosa, Rio Arnoya, 10 5B, 29006 Malaga, Spain
23 ***************************************************************************/
24 #include "rhythmview.h"
26 #include <QResizeEvent>
28 RhythmView::RhythmView (QWidget
*parent
, const char *name
) : QWidget(parent
)
35 RhythmView::~RhythmView()
39 for (int i
=0;i
<num
;i
++) delete lamps
[i
];
45 void RhythmView::setRhythm(int numerator
,int denominator
)
50 for (i
=0;i
<num
;i
++) delete lamps
[i
];
57 lamps
=new KLed
*[num
];
63 lamps
[i
]=new KLed(Qt::yellow
, KLed::Off
, KLed::Sunken
, KLed::Rectangular
, this);
64 // lamps[i]->setState(KLed::Off);
65 lamps
[i
]->setGeometry(x
+2,0,w
-4,height());
69 // lamps[0]->setState(KLed::On);
73 void RhythmView::Beat(int j
)
75 if (j
>num
) setRhythm(j
,4); // This is a preventive case
77 for (int i
=0;i
<num
;i
++)
84 void RhythmView::Beat(void)
89 void RhythmView::resizeEvent(QResizeEvent
*)
94 for (int i
=0;i
<num
;i
++)
96 lamps
[i
]->setGeometry(x
+2,0,w
-4,height());
101 QSize
RhythmView::sizeHint() const
106 QSizePolicy
RhythmView::sizePolicy()
108 // return QWidget::sizePolicy();
109 return QSizePolicy(QSizePolicy::Expanding
,QSizePolicy::Minimum
);