Diffstat (limited to 'noncore/games/zlines/prompt.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/games/zlines/prompt.cpp | 89 |
1 files changed, 89 insertions, 0 deletions
diff --git a/noncore/games/zlines/prompt.cpp b/noncore/games/zlines/prompt.cpp new file mode 100644 index 0000000..2834937 --- a/dev/null +++ b/noncore/games/zlines/prompt.cpp | |||
@@ -0,0 +1,89 @@ | |||
1 | /*************************************************************************** | ||
2 | prompt.cpp - description | ||
3 | ------------------- | ||
4 | begin : Fri May 19 2000 | ||
5 | copyright : (C) 2000 by Roman Merzlyakov | ||
6 | email : roman@sbrf.barrt.ru | ||
7 | copyright : (C) 2000 by Roman Razilov | ||
8 | email : Roman.Razilov@gmx.de | ||
9 | ***************************************************************************/ | ||
10 | |||
11 | /*************************************************************************** | ||
12 | * * | ||
13 | * This program is free software; you can redistribute it and/or modify * | ||
14 | * it under the terms of the GNU General Public License as published by * | ||
15 | * the Free Software Foundation; either version 2 of the License, or * | ||
16 | * (at your option) any later version. * | ||
17 | * * | ||
18 | ***************************************************************************/ | ||
19 | #include <qpainter.h> | ||
20 | #include "prompt.h" | ||
21 | |||
22 | LinesPrompt::LinesPrompt( BallPainter * abPainter, QWidget* parent, const char* name ) | ||
23 | : QWidget( parent, name ) | ||
24 | { | ||
25 | |||
26 | bPainter = abPainter; | ||
27 | |||
28 | setFocusPolicy( NoFocus ); | ||
29 | setBackgroundColor( gray ); | ||
30 | |||
31 | setMouseTracking( FALSE ); | ||
32 | setFixedSize(wPrompt(), hPrompt()); | ||
33 | |||
34 | PromptEnabled = true; | ||
35 | cb[0]=NOBALL; | ||
36 | cb[1]=NOBALL; | ||
37 | cb[2]=NOBALL; | ||
38 | } | ||
39 | |||
40 | LinesPrompt::~LinesPrompt() | ||
41 | { | ||
42 | } | ||
43 | |||
44 | int LinesPrompt::width() { return CELLSIZE * 3 ; } | ||
45 | int LinesPrompt::height() { return CELLSIZE ; } | ||
46 | |||
47 | int LinesPrompt::wPrompt() { return CELLSIZE * 3 ; } | ||
48 | int LinesPrompt::hPrompt() { return CELLSIZE ; } | ||
49 | |||
50 | void LinesPrompt::paintEvent( QPaintEvent* ) | ||
51 | { | ||
52 | QPainter paint( this ); | ||
53 | if(PromptEnabled){ | ||
54 | paint.drawPixmap(0, 0, *(bPainter->GetNormalBall(cb[0])) ); | ||
55 | paint.drawPixmap(CELLSIZE, 0, *(bPainter->GetNormalBall(cb[1])) ); | ||
56 | paint.drawPixmap(2*CELLSIZE, 0, *(bPainter->GetNormalBall(cb[2])) ); | ||
57 | } | ||
58 | else{ | ||
59 | paint.drawPixmap(0, 0, *(bPainter->GetBackgroundPix()) ); | ||
60 | paint.drawPixmap(CELLSIZE, 0, *(bPainter->GetBackgroundPix()) ); | ||
61 | paint.drawPixmap(2*CELLSIZE, 0, *(bPainter->GetBackgroundPix()) ); | ||
62 | } | ||
63 | } | ||
64 | |||
65 | /* | ||
66 | Handles mouse press events for the LinesPrompt widget. | ||
67 | */ | ||
68 | void LinesPrompt::mousePressEvent( QMouseEvent* e ) | ||
69 | { | ||
70 | emit PromptPressed(); | ||
71 | } | ||
72 | |||
73 | void LinesPrompt::SetBalls( int *pcb ) | ||
74 | { | ||
75 | for (int i = 0; i<BALLSDROP; i++) | ||
76 | cb[i] = pcb[i]; | ||
77 | |||
78 | update(); | ||
79 | } | ||
80 | |||
81 | bool LinesPrompt::getState() | ||
82 | { | ||
83 | return PromptEnabled; | ||
84 | } | ||
85 | void LinesPrompt::setPrompt(bool enabled) | ||
86 | { | ||
87 | PromptEnabled = enabled; | ||
88 | update(); | ||
89 | } | ||