summaryrefslogtreecommitdiffstats
path: root/twin-styles/cde/cdeclient.h
blob: 402e0b3d2c3ce63a252211fc9a4026a940c69cb4 (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
107
108
109
110
111
112
113
114
115
116
117
118
119
/*
 *	CDE KWin client - emulates the look and feel
 *	of dtwm, the CDE window manager.
 *
 *	Copyright (c) 2000-2001, 2002
 *		Chris Lee       <[email protected]>
 *		Lennart Kudling <[email protected]>
 *      	Fredrik H�glund <[email protected]>
 *
 *	Copyright (c) 2003
 *		Luciano Montanaro <[email protected]>
 *
 *	Originally based on the KStep client.
 *
 *	Distributed under the terms of the BSD license.
 */

#ifndef __CDECLIENT_H
#define __CDECLIENT_H

#include <tqbutton.h>
#include <tqbitmap.h>
#include <kpixmap.h>
#include <kdecoration.h>
#include <kdecorationfactory.h>

class TQLabel;
class TQBoxLayout;
class TQVBoxLayout;
class TQSpacerItem;

namespace CDE {

class CdeClient;

enum Buttons { BtnMenu=0, BtnHelp, BtnIconify, BtnMax, BtnClose, BtnCount };

class CdeButton : public TQButton
{
public:
    CdeButton( CdeClient* parent=0, const char* name=0, int btnType=0,
               const TQString& tip=NULL, int realize_btns = Qt::LeftButton );
    void reset();
    ButtonState lastButton() { return last_button; }

protected:
    void mousePressEvent(TQMouseEvent *e);
    void mouseReleaseEvent(TQMouseEvent *e);
    virtual void drawButton(TQPainter *p);

private:
    CdeClient *m_parent;
    int m_btnType;
    int m_realize_buttons;
    ButtonState last_button;
};

class CdeClient : public KDecoration
{
    Q_OBJECT
  TQ_OBJECT
public:
    CdeClient(KDecorationBridge *b, KDecorationFactory *f);
    ~CdeClient() {};
    void init();

protected:
    bool eventFilter(TQObject *o, TQEvent *e);
    void resizeEvent( TQResizeEvent* );
    void paintEvent( TQPaintEvent* );

    void showEvent(TQShowEvent *);
    void addClientButtons( const TQString& );
    void mouseDoubleClickEvent( TQMouseEvent* );
    void wheelEvent( TQWheelEvent * );
    void captionChange();
    void desktopChange();
    void activeChange();
    void shadeChange();
    void iconChange();
    TQSize minimumSize() const;
    void resize(const TQSize &size);
    void borders(int &left, int &right, int &top, int &bottom) const;
    void mousePressEvent( TQMouseEvent* );
    void mouseReleaseEvent( TQMouseEvent* );
    void maximizeChange();
    Position mousePosition( const TQPoint& p ) const;

protected slots:
    void menuButtonPressed();
    void menuButtonReleased();
    void maximizeButtonClicked();

private:
    CdeButton* button[BtnCount];
    TQVBoxLayout* mainLayout;
    TQBoxLayout*  titleLayout;
    TQSpacerItem* titlebar;
    bool titlebarPressed;
    bool closing;
};

class CdeClientFactory: public TQObject, public KDecorationFactory
{
public:
    CdeClientFactory();
    virtual ~CdeClientFactory();
    virtual KDecoration *createDecoration(KDecorationBridge *);
    virtual bool supports( Ability ability );
    virtual bool reset(unsigned long changed);

    TQValueList< CdeClientFactory::BorderSize > borderSizes() const;

};

}

#endif