summaryrefslogtreecommitdiffstats
path: root/kmahjongg/Preview.h
blob: 0c4b37c2a9e3d632d90f2b02d18995b1655bc296 (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
#ifndef _PreviewLoadBase_H
#define _PreviewLoadBase_H

#include <kdialogbase.h>

#include <tqframe.h>

#include "Tileset.h"
#include "BoardLayout.h"
#include "Background.h"

class TQComboBox;
class TQPixmap;

class FrameImage: public TQFrame
{
	Q_OBJECT
  TQ_OBJECT
public:
	FrameImage(TQWidget *tqparent=NULL, const char *name = NULL);
	~FrameImage();
	void setGeometry(int x, int y, int w, int h);
	TQPixmap *getPreviewPixmap() {return thePixmap;}
	void setRect(int x, int y, int w, int h, int ss, int type);
signals:
	void mousePressed(TQMouseEvent *e);
	void mouseMoved(TQMouseEvent *e);
protected:
	void mousePressEvent(TQMouseEvent *e);
	void mouseMoveEvent(TQMouseEvent *e);
	void paintEvent( TQPaintEvent* pa );
private:
	TQPixmap *thePixmap;
	int rx;
	int ry;
	int rw;
	int rh;
	int rs;
	int rt;
};



class Preview: public KDialogBase
{
    Q_OBJECT
  TQ_OBJECT

public:
	enum PreviewType {background, tileset, board, theme};

	Preview(TQWidget* tqparent);
	~Preview();

	void initialise(const PreviewType type);
	void saveTheme();

protected:
	void markUnchanged();
	void markChanged();
	bool isChanged();
	TQPixmap *getPreviewPixmap() {return m_drawFrame->getPreviewPixmap(); }
	virtual void drawPreview();
	void applyChange() ;
	void renderBackground(const TQString &bg);
	void renderTiles(const TQString &file, const TQString &tqlayout);
	void paintEvent( TQPaintEvent* pa );

signals:
	void boardRedraw(bool);
	void loadTileset(const TQString &);
	void loadBackground(const TQString &, bool);
	void loadBoard(const TQString &);
	void tqlayoutChange();

public slots:
	void selectionChanged(int which);

protected slots:
	void slotApply();
	void slotOk();
	
private slots:
	void load();

protected:
	FrameImage *m_drawFrame;
	TQComboBox *m_combo;

	TQString m_selectedFile;
	Tileset m_tiles;
	BoardLayout m_boardLayout;
	Background m_back;

private:
	TQString m_fileSelector;
	bool m_changed;
	TQStringList m_fileList;
	PreviewType m_previewType;

	TQString m_themeBack;
	TQString m_themeLayout;
	TQString m_themeTileset;
};

#endif