summaryrefslogtreecommitdiffstats
path: root/tdemid/kdisptext.h
blob: 04a25f278bebbeb4e46c678af08b5e046fa1f4c3 (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
/**************************************************************************

    kdisptext.h  - The widget that displays the karaoke/lyrics text
    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 _kdisptext_h_
#define _kdisptext_h_

#include <tqwidget.h>
#include <tqscrollview.h>
#include <libtdemid/player.h>

struct kdispt_ev 
{
    SpecialEvent *spev;
    int xpos;
    class TQRect r;
    kdispt_ev *next;
};

struct kdispt_line
{
    kdispt_ev *ev;
    int num;
    int ypos;
    kdispt_line *next;
};

class TQFont;
class TQFontMetrics;
class TQScrollBar;

class KDisplayText : public TQScrollView 
{
    Q_OBJECT
  
private:
    TQTextCodec *lyrics_codec;    

    TQFontMetrics *qfmetr;
    TQFont *qtextfont;
    
    int typeoftextevents;
    
    kdispt_line *linked_list_[2];
    int nlines_[2];
    kdispt_line *first_line_[2];
    kdispt_line *cursor_line_[2];
    kdispt_ev *cursor_[2];
    
    kdispt_line *linked_list; 
    kdispt_line *cursor_line;
    kdispt_ev *cursor;
    
    kdispt_line *first_line; // Pointer to first text at first visible line
    
    int nlines;     // Total number of lines
    int nvisiblelines; // Number of visible lines
    
    void RemoveLine(kdispt_line *tmpl);
    void RemoveLinkedList(void);
    
    int IsLineFeed(char c,int type=0);
    virtual void drawContents(TQPainter *qpaint,int clipx,int clipy,int clipw,int cliph);

    kdispt_line * searchYOffset(int y, kdispt_line *start);
    
    int maxX[2];
    int maxY[2];
    int autoscrollv;

protected:
    virtual void resizeEvent(TQResizeEvent *qre);
    virtual void timerEvent(TQTimerEvent *e);
    
public:
    KDisplayText(TQWidget *parent,const char *name);
    virtual ~KDisplayText();
    
    void ClearEv(bool totally=true);
    void AddEv(SpecialEvent *ev);
    void calculatePositions(void);
    
    void CursorToHome(void);
    
    void ChangeTypeOfTextEvents(int type); 
    int ChooseTypeOfTextEvents(void);
    void PaintIn(int type);
    void gotomsec(ulong i);
    
    TQFont *getFont(void);
    void fontChanged(void);
    
    void saveLyrics(FILE *fh);
    
    void setLyricsEncoding(const TQString &enc);

//    TQSize sizeHint();
 
public slots:
    void ScrollDown();
    void ScrollUp();
    void ScrollPageDown();
    void ScrollPageUp();
    
};

#endif