00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #include <qpainter.h>
00020 #include "prompt.h"
00021
00022 LinesPrompt::LinesPrompt( BallPainter * abPainter, QWidget* parent, const char* name )
00023 : QWidget( parent, name )
00024 {
00025
00026 bPainter = abPainter;
00027
00028 setFocusPolicy( NoFocus );
00029 setBackgroundColor( gray );
00030
00031 setMouseTracking( FALSE );
00032 setFixedSize(wPrompt(), hPrompt());
00033
00034 PromptEnabled = true;
00035 cb[0]=NOBALL;
00036 cb[1]=NOBALL;
00037 cb[2]=NOBALL;
00038 }
00039
00040 LinesPrompt::~LinesPrompt()
00041 {
00042 }
00043
00044 int LinesPrompt::width() { return CELLSIZE * 3 ; }
00045 int LinesPrompt::height() { return CELLSIZE ; }
00046
00047 int LinesPrompt::wPrompt() { return CELLSIZE * 3 ; }
00048 int LinesPrompt::hPrompt() { return CELLSIZE ; }
00049
00050 void LinesPrompt::paintEvent( QPaintEvent* )
00051 {
00052 QPainter paint( this );
00053 if(PromptEnabled){
00054 paint.drawPixmap(0, 0, *(bPainter->GetNormalBall(cb[0])) );
00055 paint.drawPixmap(CELLSIZE, 0, *(bPainter->GetNormalBall(cb[1])) );
00056 paint.drawPixmap(2*CELLSIZE, 0, *(bPainter->GetNormalBall(cb[2])) );
00057 }
00058 else{
00059 paint.drawPixmap(0, 0, *(bPainter->GetBackgroundPix()) );
00060 paint.drawPixmap(CELLSIZE, 0, *(bPainter->GetBackgroundPix()) );
00061 paint.drawPixmap(2*CELLSIZE, 0, *(bPainter->GetBackgroundPix()) );
00062 }
00063 }
00064
00065
00066
00067
00068 void LinesPrompt::mousePressEvent( QMouseEvent* e )
00069 {
00070 emit PromptPressed();
00071 }
00072
00073 void LinesPrompt::SetBalls( int *pcb )
00074 {
00075 for (int i = 0; i<BALLSDROP; i++)
00076 cb[i] = pcb[i];
00077
00078 update();
00079 }
00080
00081 bool LinesPrompt::getState()
00082 {
00083 return PromptEnabled;
00084 }
00085 void LinesPrompt::setPrompt(bool enabled)
00086 {
00087 PromptEnabled = enabled;
00088 update();
00089 }