Source:NetHack 3.4.3/include/qt win.h

From NetHackWiki
Jump to: navigation, search

Below is the full text to include/qt_win.h from NetHack 3.4.3. To link to a particular line, write [[qt_win.h#line123]], for example.

  1. //	SCCS Id: @(#)qt_win.h	3.4	1999/11/19
  2. // Copyright (c) Warwick Allison, 1999.
  3. // NetHack may be freely redistributed.  See license for details.
  4. //

The NetHack General Public License applies to screenshots, source code and other content from NetHack.

This content was modified from the original NetHack source code distribution (by splitting up NetHack content between wiki pages, and possibly further editing). See the page history for a list of who changed it, and on what dates.

  1. // Qt Binding for NetHack 3.4
  2. //
  3. // Unfortunately, this doesn't use Qt as well as I would like,
  4. // primarily because NetHack is fundamentally a getkey-type
  5. // program rather than being event driven (hence the ugly key
  6. // and click buffer rather), but also because this is my first
  7. // major application of Qt.
  8. //
  9.  
  10. #ifndef qt_win_h
  11. #define qt_win_h
  12.  
  13. #define QT_CLEAN_NAMESPACE
  14.  
  15. #include <qdialog.h>
  16. #include <qpushbutton.h>
  17. #include <qbuttongroup.h>
  18. #include <qlabel.h>
  19. #include <qlineedit.h> 
  20. #if defined(QWS)
  21. #include <qpe/qpeapplication.h> 
  22. #else
  23. #include <qapplication.h> 
  24. #endif
  25. #include <qspinbox.h>
  26. #include <qcheckbox.h>
  27. #include <qfile.h> 
  28. #include <qlistbox.h> 
  29. #include <qlistview.h> 
  30. #include <qmessagebox.h>
  31. #include <qpixmap.h>
  32. #include <qimage.h>
  33. #include <qarray.h>
  34. #include <qcombobox.h>
  35. #include <qscrollview.h>
  36. #if QT_VERSION >= 300
  37. #include <qttableview.h>
  38. // Should stop using QTableView
  39. #define QTableView QtTableView
  40. #else
  41. #include <qtableview.h>
  42. #endif
  43. #include <qmainwindow.h>
  44. #include <qwidgetstack.h>
  45.  
  46. #ifdef KDE
  47. #include <kapp.h>
  48. #include <ktopwidget.h>
  49. #endif 
  50.  
  51. #include "qt_clust.h"
  52.  
  53. class QVBox;
  54. class QMenuBar;
  55. class QRadioButton;
  56. class NhPSListView;
  57.  
  58. //////////////////////////////////////////////////////////////
  59. //
  60. //  The beautiful, abstracted and well-modelled classes...
  61. //
  62. //////////////////////////////////////////////////////////////
  63.  
  64. class NetHackQtGlyphs;
  65.  
  66. class NetHackQtLineEdit : public QLineEdit {
  67. public:
  68. 	NetHackQtLineEdit();
  69. 	NetHackQtLineEdit(QWidget* parent, const char* name);
  70.  
  71. 	void fakeEvent(int key, int ascii, int state);
  72. };
  73.  
  74. class NetHackQtSettings : public QDialog {
  75. 	Q_OBJECT
  76. public:
  77. 	// Size of window - used to decide default sizes
  78. 	NetHackQtSettings(int width, int height);
  79.  
  80. 	NetHackQtGlyphs& glyphs();
  81. 	const QFont& normalFont();
  82. 	const QFont& normalFixedFont();
  83. 	const QFont& largeFont();
  84.  
  85. 	bool ynInMessages();
  86.  
  87. signals:
  88. 	void fontChanged();
  89. 	void tilesChanged();
  90.  
  91. public slots:
  92. 	void toggleGlyphSize();
  93. 	void setGlyphSize(bool);
  94.  
  95. private:
  96. 	QSpinBox tilewidth;
  97. 	QSpinBox tileheight;
  98. 	QLabel widthlbl;
  99. 	QLabel heightlbl;
  100. 	QCheckBox whichsize;
  101. 	QSize othersize;
  102.  
  103. 	QComboBox fontsize;
  104.  
  105. 	QFont normal, normalfixed, large;
  106.  
  107. 	NetHackQtGlyphs* theglyphs;
  108.  
  109. private slots:
  110. 	void resizeTiles();
  111. };
  112.  
  113. class NetHackQtKeyBuffer {
  114. public:
  115. 	NetHackQtKeyBuffer();
  116.  
  117. 	bool Empty() const;
  118. 	bool Full() const;
  119.  
  120. 	void Put(int k, int ascii, int state);
  121. 	void Put(char a);
  122. 	void Put(const char* str);
  123. 	int GetKey();
  124. 	int GetAscii();
  125. 	int GetState();
  126.  
  127. 	int TopKey() const;
  128. 	int TopAscii() const;
  129. 	int TopState() const;
  130.  
  131. private:
  132. 	enum { maxkey=64 };
  133. 	int key[maxkey];
  134. 	int ascii[maxkey];
  135. 	int state[maxkey];
  136. 	int in,out;
  137. };
  138.  
  139. class NetHackQtClickBuffer {
  140. public:
  141. 	NetHackQtClickBuffer();
  142.  
  143. 	bool Empty() const;
  144. 	bool Full() const;
  145.  
  146. 	void Put(int x, int y, int mod);
  147.  
  148. 	int NextX() const;
  149. 	int NextY() const;
  150. 	int NextMod() const;
  151.  
  152. 	void Get();
  153.  
  154. private:
  155. 	enum { maxclick=64 };
  156. 	struct ClickRec {
  157. 		int x,y,mod;
  158. 	} click[maxclick];
  159. 	int in,out;
  160. };
  161.  
  162.  
  163. class NetHackQtSavedGameSelector : public QDialog {
  164. public:
  165. 	NetHackQtSavedGameSelector(const char** saved);
  166.  
  167. 	int choose();
  168. };
  169.  
  170. class NetHackQtPlayerSelector : private QDialog {
  171. 	Q_OBJECT
  172. public:
  173. 	enum { R_None=-1, R_Quit=-2, R_Rand=-3 };
  174.  
  175. 	NetHackQtPlayerSelector(NetHackQtKeyBuffer&);
  176.  
  177. protected:
  178. 	virtual void done(int);
  179.  
  180. public slots:
  181. 	void Quit();
  182. 	void Random();
  183.  
  184. 	void selectName(const QString& n);
  185. 	void selectRole();
  186. 	void selectRace();
  187. 	void setupOthers();
  188. 	void selectGender(int);
  189. 	void selectAlignment(int);
  190.  
  191. public:
  192. 	bool Choose();
  193.  
  194. private:
  195. 	NetHackQtKeyBuffer& keysource;
  196. 	NhPSListView* role;
  197. 	NhPSListView* race;
  198. 	QRadioButton **gender;
  199. 	QRadioButton **alignment;
  200. 	bool fully_specified_role;
  201. };
  202.  
  203. class NetHackQtStringRequestor : QDialog {
  204. private:
  205. 	QLabel prompt;
  206. 	NetHackQtLineEdit input;
  207. 	QPushButton* okay;
  208. 	QPushButton* cancel;
  209. 	NetHackQtKeyBuffer& keysource;
  210.  
  211. 	virtual void done(int);
  212.  
  213. public:
  214. 	NetHackQtStringRequestor(NetHackQtKeyBuffer&, const char* p,const char* cancelstr="Cancel");
  215. 	void SetDefault(const char*);
  216. 	bool Get(char* buffer, int maxchar=80);
  217. 	virtual void resizeEvent(QResizeEvent*);
  218. };
  219.  
  220. class NetHackQtExtCmdRequestor : public QDialog {
  221. Q_OBJECT
  222.  
  223. NetHackQtKeyBuffer& keysource;
  224.  
  225. public:
  226. NetHackQtExtCmdRequestor(NetHackQtKeyBuffer& ks);
  227. int get();
  228.  
  229. private slots:
  230. void cancel();
  231. void done(int i);
  232. };
  233.  
  234.  
  235. class NetHackQtWindow {
  236. public:
  237. 	NetHackQtWindow();
  238. 	virtual ~NetHackQtWindow();
  239.  
  240. 	virtual QWidget* Widget() =0;
  241.  
  242. 	virtual void Clear();
  243. 	virtual void Display(bool block);
  244. 	virtual bool Destroy();
  245. 	virtual void CursorTo(int x,int y);
  246. 	virtual void PutStr(int attr, const char* text);
  247. 	virtual void StartMenu();
  248. 	virtual void AddMenu(int glyph, const ANY_P* identifier, char ch, char gch, int attr,
  249. 			const char* str, bool presel);
  250. 	virtual void EndMenu(const char* prompt);
  251. 	virtual int SelectMenu(int how, MENU_ITEM_P **menu_list);
  252. 	virtual void ClipAround(int x,int y);
  253. 	virtual void PrintGlyph(int x,int y,int glyph);
  254. 	virtual void UseRIP(int how);
  255.  
  256. 	int nhid;
  257. };
  258.  
  259. class NetHackQtGlyphs {
  260. public:
  261. 	NetHackQtGlyphs();
  262.  
  263. 	int width() const { return size.width(); }
  264. 	int height() const { return size.height(); }
  265. 	void toggleSize();
  266. 	void setSize(int w, int h);
  267.  
  268. 	void drawGlyph(QPainter&, int glyph, int pixelx, int pixely);
  269. 	void drawCell(QPainter&, int glyph, int cellx, int celly);
  270.  
  271. private:
  272. 	QImage img;
  273. 	QPixmap pm,pm1, pm2;
  274. 	QSize size;
  275. 	int tiles_per_row;
  276. };
  277.  
  278. class BlackScrollView : public QScrollView {
  279. public:
  280. BlackScrollView()
  281. {
  282. 	viewport()->setBackgroundColor(black);
  283. }
  284. };
  285.  
  286. class NetHackQtMapWindow : public QWidget, public NetHackQtWindow {
  287. 	Q_OBJECT
  288. private:
  289. 	NetHackQtClickBuffer& clicksink;
  290. 	unsigned short glyph[ROWNO][COLNO];
  291. 	unsigned short& Glyph(int x, int y) { return glyph[y][x]; }
  292. 	QPoint cursor;
  293. 	BlackScrollView viewport;
  294. 	QPixmap pet_annotation;
  295. 	Clusterizer change;
  296. 	QFont *rogue_font;
  297. 	QString messages;
  298. 	QRect messages_rect;
  299.  
  300. 	void Changed(int x,int y);
  301.  
  302. signals:
  303. 	void resized();
  304.  
  305. private slots:
  306. 	void updateTiles();
  307. 	void moveMessages(int x, int y);
  308.  
  309. protected:
  310. 	virtual void paintEvent(QPaintEvent*);
  311. 	virtual void mousePressEvent(QMouseEvent*);
  312.  
  313. public:
  314. 	NetHackQtMapWindow(NetHackQtClickBuffer& click_sink);
  315. 	~NetHackQtMapWindow();
  316.  
  317. 	virtual QWidget* Widget();
  318. 	virtual bool Destroy();
  319.  
  320. 	virtual void Clear();
  321. 	virtual void Display(bool block);
  322. 	virtual void CursorTo(int x,int y);
  323. 	virtual void PutStr(int attr, const char* text);
  324. 	virtual void ClipAround(int x,int y);
  325. 	virtual void PrintGlyph(int x,int y,int glyph);
  326.  
  327. 	void Scroll(int dx, int dy);
  328.  
  329. 	// For messages
  330. 	void displayMessages(bool block);
  331. 	void putMessage(int attr, const char* text);
  332. 	void clearMessages();
  333.  
  334. 	void clickCursor();
  335. };
  336.  
  337. class NetHackQtScrollText;
  338. class NetHackQtMessageWindow : QObject, public NetHackQtWindow {
  339. 	Q_OBJECT
  340. public:
  341. 	NetHackQtMessageWindow();
  342. 	~NetHackQtMessageWindow();
  343.  
  344. 	virtual QWidget* Widget();
  345. 	virtual void Clear();
  346. 	virtual void Display(bool block);
  347. 	virtual void PutStr(int attr, const char* text);
  348.  
  349. 	void Scroll(int dx, int dy);
  350.  
  351. 	void setMap(NetHackQtMapWindow*);
  352.  
  353. private:
  354. 	NetHackQtScrollText* list;
  355. 	bool changed;
  356. 	NetHackQtMapWindow* map;
  357.  
  358. private slots:
  359. 	void updateFont();
  360. };
  361.  
  362. class NetHackQtLabelledIcon : public QWidget {
  363. public:
  364. 	NetHackQtLabelledIcon(QWidget* parent, const char* label);
  365. 	NetHackQtLabelledIcon(QWidget* parent, const char* label, const QPixmap& icon);
  366.  
  367. 	enum { NoNum=-99999 };
  368. 	void setLabel(const char*, bool lower=TRUE); // a string
  369. 	void setLabel(const char*, long, const char* tail=""); // a number
  370. 	void setLabel(const char*, long show_value, long comparative_value, const char* tail="");
  371. 	void setIcon(const QPixmap&);
  372. 	virtual void setFont(const QFont&);
  373.  
  374. 	void highlightWhenChanging();
  375. 	void lowIsGood();
  376. 	void dissipateHighlight();
  377.  
  378. 	virtual void show();
  379.  
  380. protected:
  381. 	void resizeEvent(QResizeEvent*);
  382.  
  383. private:
  384. 	void initHighlight();
  385. 	void setAlignments();
  386. 	void highlight(const QPalette& highlight);
  387. 	void unhighlight();
  388.  
  389. 	bool low_is_good;
  390. 	int prev_value;
  391. 	int turn_count;		/* last time the value changed */
  392. 	QPalette hl_good;
  393. 	QPalette hl_bad;
  394.  
  395. 	QLabel* label;
  396. 	QLabel* icon;
  397. };
  398.  
  399. class NetHackQtStatusWindow : QWidget, public NetHackQtWindow {
  400. 	Q_OBJECT
  401. public:
  402. 	NetHackQtStatusWindow();
  403.  
  404. 	virtual QWidget* Widget();
  405.  
  406. 	virtual void Clear();
  407. 	virtual void Display(bool block);
  408. 	virtual void CursorTo(int x,int y);
  409. 	virtual void PutStr(int attr, const char* text);
  410.  
  411. 	void fadeHighlighting();
  412.  
  413. protected:
  414. 	void resizeEvent(QResizeEvent*);
  415.  
  416. private slots:
  417. 	void doUpdate();
  418.  
  419. private:
  420. 	enum { hilight_time=1 };
  421.  
  422. 	QPixmap p_str;
  423. 	QPixmap p_dex;
  424. 	QPixmap p_con;
  425. 	QPixmap p_int;
  426. 	QPixmap p_wis;
  427. 	QPixmap p_cha;
  428.  
  429. 	QPixmap p_chaotic;
  430. 	QPixmap p_neutral;
  431. 	QPixmap p_lawful;
  432.  
  433. 	QPixmap p_satiated;
  434. 	QPixmap p_hungry;
  435.  
  436. 	QPixmap p_confused;
  437. 	QPixmap p_sick_fp;
  438. 	QPixmap p_sick_il;
  439. 	QPixmap p_blind;
  440. 	QPixmap p_stunned;
  441. 	QPixmap p_hallu;
  442.  
  443. 	QPixmap p_encumber[5];
  444.  
  445. 	NetHackQtLabelledIcon name;
  446. 	NetHackQtLabelledIcon dlevel;
  447.  
  448. 	NetHackQtLabelledIcon str;
  449. 	NetHackQtLabelledIcon dex;
  450. 	NetHackQtLabelledIcon con;
  451. 	NetHackQtLabelledIcon intel;
  452. 	NetHackQtLabelledIcon wis;
  453. 	NetHackQtLabelledIcon cha;
  454.  
  455. 	NetHackQtLabelledIcon gold;
  456. 	NetHackQtLabelledIcon hp;
  457. 	NetHackQtLabelledIcon power;
  458. 	NetHackQtLabelledIcon ac;
  459. 	NetHackQtLabelledIcon level;
  460. 	NetHackQtLabelledIcon exp;
  461. 	NetHackQtLabelledIcon align;
  462.  
  463. 	NetHackQtLabelledIcon time;
  464. 	NetHackQtLabelledIcon score;
  465.  
  466. 	NetHackQtLabelledIcon hunger;
  467. 	NetHackQtLabelledIcon confused;
  468. 	NetHackQtLabelledIcon sick_fp;
  469. 	NetHackQtLabelledIcon sick_il;
  470. 	NetHackQtLabelledIcon blind;
  471. 	NetHackQtLabelledIcon stunned;
  472. 	NetHackQtLabelledIcon hallu;
  473. 	NetHackQtLabelledIcon encumber;
  474.  
  475. 	QFrame hline1;
  476. 	QFrame hline2;
  477. 	QFrame hline3;
  478.  
  479. 	int cursy;
  480.  
  481. 	bool first_set;
  482.  
  483. 	void nullOut();
  484. 	void updateStats();
  485. 	void checkTurnEvents();
  486. };
  487.  
  488. class NetHackQtMenuDialog : public QDialog {
  489. 	Q_OBJECT
  490. public:
  491. 	NetHackQtMenuDialog();
  492.  
  493. 	void Accept();
  494. 	void Reject();
  495. 	void SetResult(int);
  496.  
  497. 	virtual void done(int);
  498.  
  499. protected:
  500. 	void resizeEvent(QResizeEvent*);
  501.  
  502. signals:
  503. 	void Resized();
  504. };
  505.  
  506.  
  507. class NetHackQtMenuWindow : public QTableView, public NetHackQtWindow {
  508. 	Q_OBJECT
  509. public:
  510. 	NetHackQtMenuWindow(NetHackQtKeyBuffer&);
  511. 	~NetHackQtMenuWindow();
  512.  
  513. 	virtual QWidget* Widget();
  514.  
  515. 	virtual void StartMenu();
  516. 	virtual void AddMenu(int glyph, const ANY_P* identifier, char ch, char gch, int attr,
  517. 			const char* str, bool presel);
  518. 	virtual void EndMenu(const char* prompt);
  519. 	virtual int SelectMenu(int how, MENU_ITEM_P **menu_list);
  520.  
  521. public slots:
  522. 	void All();
  523. 	void ChooseNone();
  524. 	void Invert();
  525. 	void Search();
  526.  
  527. 	void Layout();
  528. 	void ToggleSelect(int);
  529.  
  530. protected:
  531. 	virtual void keyPressEvent(QKeyEvent*);
  532. 	//virtual void mouseDoubleClickEvent(QMouseEvent*);
  533. 	virtual void mousePressEvent(QMouseEvent*);
  534. 	virtual void mouseReleaseEvent(QMouseEvent*);
  535. 	virtual void mouseMoveEvent(QMouseEvent*);
  536. 	virtual void focusOutEvent(QFocusEvent*);
  537. 	virtual void focusInEvent(QFocusEvent*);
  538.  
  539. 	virtual void paintCell(QPainter*, int, int);
  540. 	virtual int cellWidth(int col);
  541.  
  542. private:
  543. 	struct MenuItem {
  544. 		MenuItem();
  545. 		~MenuItem();
  546.  
  547. 		int glyph;
  548. 		ANY_P identifier;
  549. 		int attr;
  550. 		const char* str;
  551. 		int count;
  552. 		char ch;
  553. 		bool selected;
  554.  
  555. 		bool Selectable() const { return identifier.a_void!=0; }
  556. 	};
  557.  
  558. 	QArray<MenuItem> item;
  559.  
  560. 	int itemcount;
  561. 	int str_width;
  562. 	bool str_fixed;
  563. 	int next_accel;
  564.  
  565. 	NetHackQtKeyBuffer& keysource;
  566.  
  567. 	NetHackQtMenuDialog* dialog;
  568.  
  569. 	QPushButton* ok;
  570. 	QPushButton* cancel;
  571. 	QPushButton* all;
  572. 	QPushButton* none;
  573. 	QPushButton* invert;
  574. 	QPushButton* search;
  575. 	QLabel prompt;
  576.  
  577. 	int how;
  578.  
  579. 	bool has_glyphs;
  580.  
  581. 	int pressed;
  582. 	bool was_sel;
  583. };
  584.  
  585. class NetHackQtTextListBox;
  586.  
  587. class NetHackQtRIP : public QWidget {
  588. private:
  589. 	static QPixmap* pixmap;
  590. 	char** line;
  591. 	int riplines;
  592.  
  593. public:
  594. 	NetHackQtRIP(QWidget* parent);
  595.  
  596. 	void setLines(char** l, int n);
  597.  
  598. protected:
  599. 	virtual void paintEvent(QPaintEvent* event);
  600. 	QSize sizeHint() const;
  601. };
  602.  
  603.  
  604. class NetHackQtTextWindow : public QDialog, public NetHackQtWindow {
  605. 	Q_OBJECT
  606. public:
  607. 	NetHackQtTextWindow(NetHackQtKeyBuffer&);
  608. 	~NetHackQtTextWindow();
  609.  
  610. 	virtual QWidget* Widget();
  611.  
  612. 	virtual void Clear();
  613. 	virtual bool Destroy();
  614. 	virtual void Display(bool block);
  615. 	virtual void PutStr(int attr, const char* text);
  616. 	virtual void UseRIP(int how);
  617.  
  618. public slots:
  619. 	void Search();
  620.  
  621. protected:
  622. 	virtual void done(int);
  623. 	virtual void keyPressEvent(QKeyEvent*);
  624.  
  625. private slots:
  626. 	void doUpdate();
  627.  
  628. private:
  629. 	NetHackQtKeyBuffer& keysource;
  630.  
  631. 	bool use_rip;
  632. 	bool str_fixed;
  633.  
  634. 	QPushButton ok;
  635. 	QPushButton search;
  636. 	NetHackQtTextListBox* lines;
  637.  
  638. 	NetHackQtRIP rip;
  639. };
  640.  
  641. class NetHackQtMenuOrTextWindow : public NetHackQtWindow {
  642. private:
  643. 	NetHackQtWindow* actual;
  644. 	NetHackQtKeyBuffer& keysource;
  645.  
  646. public:
  647. 	NetHackQtMenuOrTextWindow(NetHackQtKeyBuffer&);
  648.  
  649. 	virtual QWidget* Widget();
  650.  
  651. 	// Text
  652. 	virtual void Clear();
  653. 	virtual bool Destroy();
  654. 	virtual void Display(bool block);
  655. 	virtual void PutStr(int attr, const char* text);
  656.  
  657. 	// Menu
  658. 	virtual void StartMenu();
  659. 	virtual void AddMenu(int glyph, const ANY_P* identifier, char ch, char gch, int attr,
  660. 			const char* str, bool presel);
  661. 	virtual void EndMenu(const char* prompt);
  662. 	virtual int SelectMenu(int how, MENU_ITEM_P **menu_list);
  663.  
  664. };
  665.  
  666. class NetHackQtDelay : QObject {
  667. private:
  668. 	int msec;
  669.  
  670. public:
  671. 	NetHackQtDelay(int ms);
  672. 	void wait();
  673. 	virtual void timerEvent(QTimerEvent* timer);
  674. };
  675.  
  676.  
  677. class NetHackQtInvUsageWindow : public QWidget {
  678. public:
  679. 	NetHackQtInvUsageWindow(QWidget* parent);
  680. 	virtual void paintEvent(QPaintEvent*);
  681. private:
  682. 	void drawWorn(QPainter& painter, obj*, int x, int y, bool canbe=TRUE);
  683. };
  684.  
  685. // This class is the main widget for NetHack
  686. //
  687. // It is a collection of Message, Map, and Status windows.  In the current
  688. // version of nethack there is only one of each, and this class makes this
  689. // assumption, not showing itself until all are inserted.
  690. //
  691. // This class simply knows how to layout such children sensibly.
  692. //
  693. // Since it is only responsible for layout, the class does not
  694. // note the actual class of the windows.
  695. //
  696. #ifndef KDE
  697. #include "qt_kde0.h"
  698. #endif
  699.  
  700. class NetHackQtMainWindow : public KTopLevelWidget {
  701. 	Q_OBJECT
  702. public:
  703. 	NetHackQtMainWindow(NetHackQtKeyBuffer&);
  704.  
  705. 	void AddMessageWindow(NetHackQtMessageWindow* window);
  706. 	void AddMapWindow(NetHackQtMapWindow* window);
  707. 	void AddStatusWindow(NetHackQtStatusWindow* window);
  708. 	void RemoveWindow(NetHackQtWindow* window);
  709. 	void updateInventory();
  710.  
  711. 	void fadeHighlighting();
  712.  
  713. public slots:
  714. 	void doMenuItem(int);
  715. 	void doKeys(const QString&);
  716.  
  717. protected:
  718. 	virtual void resizeEvent(QResizeEvent*);
  719. 	virtual void keyPressEvent(QKeyEvent*);
  720. 	virtual void keyReleaseEvent(QKeyEvent* event);
  721. 	virtual void closeEvent(QCloseEvent*);
  722.  
  723. private slots:
  724. 	void layout();
  725. 	void raiseMap();
  726. 	void zoomMap();
  727. 	void raiseMessages();
  728. 	void raiseStatus();
  729.  
  730. private:
  731. 	void ShowIfReady();
  732.  
  733. #ifdef KDE
  734. 	KMenuBar* menubar;
  735. #else
  736. 	QMenuBar* menubar;
  737. #endif
  738. 	NetHackQtMessageWindow* message;
  739. 	NetHackQtMapWindow* map;
  740. 	NetHackQtStatusWindow* status;
  741. 	NetHackQtInvUsageWindow* invusage;
  742.  
  743. 	NetHackQtKeyBuffer& keysink;
  744. 	QWidgetStack* stack;
  745. 	int dirkey;
  746.  
  747. 	const char* *macro;
  748. };
  749.  
  750. class NetHackQtYnDialog : QDialog {
  751. 	Q_OBJECT
  752. private:
  753. 	const char* question;
  754. 	const char* choices;
  755. 	char def;
  756. 	NetHackQtKeyBuffer& keysource;
  757.  
  758. protected:
  759. 	virtual void keyPressEvent(QKeyEvent*);
  760. 	virtual void done(int);
  761.  
  762. private slots:
  763. 	void doneItem(int);
  764.  
  765. public:
  766. 	NetHackQtYnDialog(NetHackQtKeyBuffer& keysource,const char*,const char*,char);
  767.  
  768. 	char Exec();
  769. };
  770.  
  771. #ifdef KDE
  772. #define NetHackQtBindBase KApplication
  773. #elif defined(QWS)
  774. #define NetHackQtBindBase QPEApplication
  775. #else
  776. #define NetHackQtBindBase QApplication
  777. #endif
  778.  
  779. class NetHackQtBind : NetHackQtBindBase {
  780. private:
  781. 	// Single-instance preservation...
  782. 	NetHackQtBind(int& argc, char** argv);
  783.  
  784. 	static NetHackQtBind* instance;
  785.  
  786. 	static NetHackQtKeyBuffer keybuffer;
  787. 	static NetHackQtClickBuffer clickbuffer;
  788.  
  789. 	static QWidget* splash;
  790. 	static NetHackQtMainWindow* main;
  791.  
  792. public:
  793. 	static void qt_init_nhwindows(int* argc, char** argv);
  794. 	static void qt_player_selection();
  795. 	static void qt_askname();
  796. 	static void qt_get_nh_event();
  797. 	static void qt_exit_nhwindows(const char *);
  798. 	static void qt_suspend_nhwindows(const char *);
  799. 	static void qt_resume_nhwindows();
  800. 	static winid qt_create_nhwindow(int type);
  801. 	static void qt_clear_nhwindow(winid wid);
  802. 	static void qt_display_nhwindow(winid wid, BOOLEAN_P block);
  803. 	static void qt_destroy_nhwindow(winid wid);
  804. 	static void qt_curs(winid wid, int x, int y);
  805. 	static void qt_putstr(winid wid, int attr, const char *text);
  806. 	static void qt_display_file(const char *filename, BOOLEAN_P must_exist);
  807. 	static void qt_start_menu(winid wid);
  808. 	static void qt_add_menu(winid wid, int glyph,
  809. 		const ANY_P * identifier, CHAR_P ch, CHAR_P gch, int attr,
  810. 		const char *str, BOOLEAN_P presel);
  811. 	static void qt_end_menu(winid wid, const char *prompt);
  812. 	static int qt_select_menu(winid wid, int how, MENU_ITEM_P **menu_list);
  813. 	static void qt_update_inventory();
  814. 	static void qt_mark_synch();
  815. 	static void qt_wait_synch();
  816.  
  817. 	static void qt_cliparound(int x, int y);
  818. 	static void qt_cliparound_window(winid wid, int x, int y);
  819. 	static void qt_print_glyph(winid wid,XCHAR_P x,XCHAR_P y,int glyph);
  820. 	static void qt_raw_print(const char *str);
  821. 	static void qt_raw_print_bold(const char *str);
  822. 	static int qt_nhgetch();
  823. 	static int qt_nh_poskey(int *x, int *y, int *mod);
  824. 	static void qt_nhbell();
  825. 	static int qt_doprev_message();
  826. 	static char qt_yn_function(const char *question, const char *choices, CHAR_P def);
  827. 	static void qt_getlin(const char *prompt, char *line);
  828. 	static int qt_get_ext_cmd();
  829. 	static void qt_number_pad(int);
  830. 	static void qt_delay_output();
  831. 	static void qt_start_screen();
  832. 	static void qt_end_screen();
  833.  
  834. 	static void qt_outrip(winid wid, int how);
  835. 	static int qt_kbhit();
  836.  
  837. private:
  838. 	virtual bool notify(QObject *receiver, QEvent *event);
  839. };
  840.  
  841. #endif