moved kdeaccessibility kdeaddons kdeadmin kdeartwork kdebindings kdeedu kdegames...
[kdeedu.git] / khangman / khangman / khangmanview.h
blob80326e51474884f6c77c89946b7fc30a18eb048e
1 /*
2 * Copyright (C) 2001-2005 Anne-Marie Mahfouf <annma@kde.org>
4 This program is free software; you can redistribute it and/or
5 modify it under the terms of version 2 of the GNU General Public
6 License as published by the Free Software Foundation.
8 This program is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 GNU General Public License for more details.
13 You should have received a copy of the GNU General Public License
14 along with this program; if not, write to the Free Software
15 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 #ifndef KHANGMANVIEW_H
19 #define KHANGMANVIEW_H
21 class KPushButton;
22 class KHangMan;
23 #include <krandomsequence.h>
24 //from libkdeedu
25 #include <keduvocdata.h>
26 /**
27 * This is the main view class for KHangMan. Most of the non-menu,
28 * non-toolbar, and non-statusbar (e.g., non frame) GUI code should go
29 * here.
32 class KHangManView : public QWidget
34 Q_OBJECT
35 public:
37 KHangManView(KHangMan *parent=0, const char *name=0);
39 virtual ~KHangManView();
41 ///parent instance
42 KHangMan *khangman;
43 ///Paint the animated hanged K sequence
44 void paintHangman();
46 void setTheme();
48 ///true if hint exists
49 bool hintBool;
50 ///true if language = es, ca, pt or pt_BR
51 bool m_accent;
53 signals:
55 private:
57 ///The area where the user enter the letter. Upper case is transformed into lower case.
58 KLineEdit *charWrite;
59 ///After you entered a letter in the line edit click this button to see if the letter is in the word or not
60 KPushButton *guessButton;
62 QString theme;
64 protected:
66 ///Paint the texts
67 void paintEvent( QPaintEvent * );
68 ///necessary to have it all resize correctly
69 void resizeEvent(QResizeEvent *);
70 ///set the background pixmap to the QPixmap argument
71 void slotSetPixmap(QPixmap& );
72 ///Store the missed letters
73 QString missedL;
75 QString temp;
76 ///store the hint when there is one
77 QString tip;
79 QString stripWord, sword;
81 int c, d, f, g;
82 ///word is the random word to be guessed
83 QString word;
84 ///goodWord is the hidden word that is filled in
85 QString goodWord;
86 ///how many times you missed, when it reaches 10, you are hanged
87 int missedChar;
88 ///tmp is to check if not twice the same random number
89 int tmp;
90 ///true if only one instance of each letter is displayed
91 bool b_oneLetter;
92 ///true if Type accents is enabled for the languages that support it
93 bool accent_b;
94 ///allWords contains all letters already guessed
95 QStringList allWords;
96 ///If true, the word contains the QString
97 bool containsChar(const QString &);
98 void replaceLetters(const QString &);
99 ///the hanged K animation sequence
100 QPixmap px[11];
101 ///Background picture (sea or desert)
102 QPixmap bcgdPicture;
103 ///part of Sea background used to repaint word and missed letters
104 QPixmap bluePic, miss_bluePic, miss_desertPic, greenPic;
105 ///Draw the word to be guessed
106 void paintWord();
107 ///Reset everything to start a new game, missed letters is empty
108 void reset();
109 ///Play a game: look for a word to be guessed and load its tip
110 void game();
111 ///Load kvtml file and get a word and its tip in random
112 void readFile();
113 ///If true, the uppercase and lower case are disctincts (world capitals)
114 bool upperBool;
115 ///KDE random generator
116 KRandomSequence random;
117 ///Enable hints on mouse right click if Hints exist
118 virtual void mousePressEvent(QMouseEvent *mouse);
119 ///Paint an already guessed letter in red in Missed Letters
120 void paintMissedTwice();
121 ///Paint an already guessed letter in red in word
122 void paintWordTwice();
123 ///index of the already guessed letter
124 int redIndex;
125 ///load the K animated sequence depending of the theme
126 void loadAnimation();
128 QPixmap bg;
129 ///paint the Misses label
130 void paintMisses();
132 public slots:
133 ///if you want to play with a new word
134 void slotNewGame();
135 private slots:
137 ///after you click on Guess button or hit Enter when guessing a new letter, see if the letter is in the word or not
138 void slotTry();
139 ///when an already guessed letter is entered, if it is in Missed, redraw the missed letters area
140 void timerDone();
141 ///when an already guessed letter is entered, if it is in the word, redraw the word area
142 void timerWordDone();
144 signals:
146 * Use this signal to change the content of the statusbar
148 void signalChangeLanguage(int);
149 ///emit this signal to say if this is a kvtml file or not (hints enabled or not)
150 void signalKvtml(bool);
153 #endif // KHANGMANVIEW_H