summaryrefslogtreecommitdiffstats
path: root/kmid/kmidclient.h
blob: 39ecbd503e105f053147de3ed83ca82d7c9e431a (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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
/**************************************************************************

    kmidclient.h  - The main client widget of KMid
    Copyright (C) 1997,98  Antonio Larrosa Jimenez

    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.

    Send comments and bug fixes to larrosa@kde.org
    or to Antonio Larrosa, Rio Arnoya, 10 5B, 29006 Malaga, Spain

***************************************************************************/
#ifndef _KMIDCLIENT_H
#define _KMIDCLIENT_H

#include "qslidertime.h"
#include <libkmid/player.h>
#include <libkmid/track.h>
#include <libkmid/notearray.h>
#include <libkmid/libkmid.h>
#include <tqtimer.h>
#include <unistd.h>
#include <sys/time.h>
#include <sys/types.h>
#include "kdisptext.h"
#include "slman.h"
#include "version.h"
#include "kmidIface.h"

#include <kio/job.h>

class DeviceManager;


class KApplication;
class KConfig;
class KLCDNumber;
class TQLabel;
class TQComboBox;
class RhythmView;
class ChannelView;
class TQString;

class kmidClient : public TQWidget, virtual public KMidIface
{
    Q_OBJECT
  TQ_OBJECT
private:
#ifdef KMidDEBUG
    long passcount;
#endif

    DeviceManager *midi;
    MidiPlayer *player;

    struct kMidData m_kMid;

    TQTimer *timer4timebar;
    TQTimer *timer4events;

    ulong beginmillisec;
    ulong pausedatmillisec;
    double currentTempo;
    SpecialEvent *spev;
    NoteArray *noteArray;

    bool downloaded;

    int	itsme;
    bool shuttingdown;
    int visiblevolumebar;
    
    char *midifile_opened;
    int hasbeenopened;

    int typeoftextevents;

    SLManager *slman;
    int activecollection;
    TQString collectionsfile;
    SongList *currentsl;
    int initializing_songs;
    int loopsong;
    int collectionplaymode;
    int *collectionplaylist; // the list of songs ordered in the
				// user selected mode

    class KActionCollection *actionCollection;
   
    void generateCPL(void);
    int searchInCPL(int song); // Returns the index of song

    void fillInComboSongs(void);

    int openFile(const char *filename);
    void allNotesOff(void);
public:
    kmidClient(TQWidget *tqparent, KActionCollection *ac, const char *name=0);
    ~kmidClient();

    char *midiFileName(void) {return midifile_opened;};
			// If it returns NULL then there isn't any file opened

    int isPlaying(void) {return m_kMid.pctl->playing;};
    int isPaused(void) {return (m_kMid.pctl->playing)&&(m_kMid.pctl->paused);};

    int openURL(const TQString s);

    void repaintText(int typeoftextevents);
    static void kmidOutput(void);

    int ChooseTypeOfTextEvents(void);

    TQFont *getFont(void);
    void fontChanged(void); // The new font is already in KConfig

    SLManager *getSLManager(void) {return slman;};
    void setSLManager(SLManager *slm);
		// setSLManager only change the pointer, so DO NOT DELETE
		// the objectr you pass to it
    int getActiveCollection(void) {return activecollection;};
    void setActiveCollection(int i);
    int getSelectedSong(void);
    void saveCollections(void);

    void setSongType(int i);
    void setSongLoop(int i);
    void setCollectionPlayMode(int i);

    void visibleVolumeBar(int i); // 1 shows it, and 0 hides it
    //    int  isVisibleVolumeBar(void) {return visiblevolumebar;};
    void visibleChannelView(int i);

    void shuttingDown(void);

    ulong timeOfNextEvent(int *type=NULL);
    void rethinkNextEvent(void);
            // Recalculates time of next event and updates the timer4events according to it


    void moveEventPointersTo(ulong ms);

protected:
//    void resizeEvent(TQResizeEvent *qre);


public slots:
//    void help_Help();
//    void help_About();
    void slotPlay();
    void slotPause();
    void slotStop();
    void slotRewind();
    void slotForward();
    void slotPrevSong();
    void slotNextSong();

    void timebarUpdate();
    void slotSeek(int i);
    void slotSetVolume(int i);
    void slotSelectSong(int i);
    void slotSelectEncoding(int i);

    void downloadFinished( KIO::Job * );

    void processSpecialEvent();

    void channelViewDestroyed();

    void communicationFromChannelView(int *);

    void slotSetTempo(double value);
    
signals:
    void mustRechooseTextEvent();
    void stopPause();
//    void channelView_Destroyed();

public:
    void saveLyrics(FILE *fh);

    DeviceManager *devman(void) {return midi;};
    void setMidiDevice(int i);
    void setMidiMapFilename(const char *mapfilename);

    ChannelView *getChannelView(void) { return channelView; };
    KDisplayText *getKDisplayText(void) { return kdispt; };

    TQSizePolicy sizePolicy();

    TQComboBox *getComboSongs() { return comboSongs; };


    void play();
    void pause();
    void stop();
    void rewind();
    void forward();
    void seek(int ms);
    void prevSong();
    void nextSong();
    void setVolume(int i);
    void setTempo(int i);
    void setSongEncoding( int i );
    void setLyricEvents( int i );
    void setCurrentSong(int i);
    void setPlayListMode(int i);

    TQSize tqsizeHint() const;
private:
    TQSlider *timebar;
    QSliderTime *timetags;
    TQSlider *volumebar;

    KLCDNumber *tempoLCD;
    KDisplayText *kdispt;
    TQLabel *qlabelTempo;
    TQComboBox *comboSongs;
    TQComboBox *comboEncodings;
    RhythmView *rhythmview;

    
    ChannelView *channelView;

};

char *extractFilename(const char *in,char *out); // returns a pointer to out

#endif