summaryrefslogtreecommitdiffstats
path: root/examples/showimg/showimg.h
blob: 362b1c2dbd5ca5374d2763a1fece00eec0f646fd (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
/****************************************************************************
**
** Copyright (C) 1992-2008 Trolltech ASA.  All rights reserved.
**
** This file is part of an example program for TQt.  This example
** program may be used, distributed and modified without limitation.
**
*****************************************************************************/

#ifndef SHOWIMG_H
#define SHOWIMG_H

#include <ntqwidget.h>
#include <ntqimage.h>


class TQLabel;
class TQMenuBar;
class TQPopupMenu;

class ImageViewer : public TQWidget
{
    Q_OBJECT
public:
    ImageViewer( TQWidget *parent=0, const char *name=0, int wFlags=0 );
    ~ImageViewer();
    bool	loadImage( const TQString& );
protected:
    void	paintEvent( TQPaintEvent * );
    void	resizeEvent( TQResizeEvent * );
    void	mousePressEvent( TQMouseEvent * );
    void	mouseReleaseEvent( TQMouseEvent * );
    void	mouseMoveEvent( TQMouseEvent * );

private:
    void	scale();
    int		conversion_flags;
    bool	smooth() const;
    bool	useColorContext() const;
    int		alloc_context;
    bool	convertEvent( TQMouseEvent* e, int& x, int& y );
    TQString     filename;
    TQImage	image;			// the loaded image
    TQPixmap	pm;			// the converted pixmap
    TQPixmap	pmScaled;		// the scaled pixmap

    TQMenuBar   *menubar;
    TQPopupMenu  *file;
    TQPopupMenu   *saveimage;
    TQPopupMenu   *savepixmap;
    TQPopupMenu  *edit;
    TQPopupMenu  *options;

    TQWidget    *helpmsg;
    TQLabel     *status;
    int         si, sp, ac, co, mo, fd, bd, // Menu item ids
		td, ta, ba, fa, au, ad, dd,
		ss, cc, t1, t8, t32;
    void	updateStatus();
    void	setMenuItemFlags();
    bool 	reconvertImage();
    int		pickx, picky;
    int		clickx, clicky;
    bool	may_be_other;
    static ImageViewer* other;
    void	setImage(const TQImage& newimage);

private slots:
    void	to1Bit();
    void	to8Bit();
    void	to32Bit();
    void	toBitDepth(int);

    void	copy();
    void	paste();

    void	hFlip();
    void	vFlip();
    void	rot180();

    void	editText();

    void	newWindow();
    void	openFile();
    void	saveImage(int);
    void	savePixmap(int);
    void	giveHelp();
    void	doOption(int);
    void	copyFrom(ImageViewer*);
};


#endif // SHOWIMG_H