summaryrefslogtreecommitdiffstats
path: root/twin-styles/kde1/kde1client.h
blob: 56eb2ac595dcec87f7ae4ae739e601a1279c4d8f (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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
/*****************************************************************
twin - the TDE window manager
								
Copyright (C) 1999, 2000 Matthias Ettrich <[email protected]>
******************************************************************/
#ifndef STDCLIENT_H
#define STDCLIENT_H
#include <tqlayout.h>
#include <tqvariant.h>
#include <kdecoration.h>
#include <kdecorationfactory.h>
#include <tqtoolbutton.h>
class TQLabel;
class TQSpacerItem;

namespace TDE1 {

enum ButtonType {
    ButtonMenu=0,
    ButtonSticky,
    ButtonMinimize,
    ButtonMaximize,
    ButtonClose,
    ButtonHelp,
    ButtonTypeCount
};

class StdClient : public KDecoration
{
    TQ_OBJECT
  
public:
    StdClient( KDecorationBridge* b, KDecorationFactory* f );
    ~StdClient();
    void init();
    TQSize minimumSize() const;
    void borders( int& left, int& right, int& top, int& bottom ) const;
    void reset( unsigned long mask );
    void resize( const TQSize& s );
    void shadeChange() {};
    Position mousePosition( const TQPoint& p ) const { return KDecoration::mousePosition( p ); }
protected:
    bool eventFilter( TQObject* o, TQEvent* e );
    void resizeEvent( TQResizeEvent* );
    void paintEvent( TQPaintEvent* );

    void mouseDoubleClickEvent( TQMouseEvent * );
    void wheelEvent( TQWheelEvent * );
    void captionChange();
    void iconChange();
    void maximizeChange();
    void desktopChange();
    void activeChange();

private:
    void addButtons(TQBoxLayout* hb, const TQString& buttons);

private slots:
    void menuButtonPressed();
    void maxButtonClicked( ButtonState );

private:
    TQToolButton* button[ButtonTypeCount];
    TQSpacerItem* titlebar;
};

class StdToolClient : public KDecoration
{
    TQ_OBJECT
  
public:
    StdToolClient( KDecorationBridge* b, KDecorationFactory* f );
    ~StdToolClient();
    void init();
    TQSize minimumSize() const;
    void borders( int& left, int& right, int& top, int& bottom ) const;
    void reset( unsigned long mask );
    void resize( const TQSize& s );
    void shadeChange() {};
    void activeChange() {};
    void iconChange() {};
    void maximizeChange() {};
    void desktopChange() {};
    Position mousePosition( const TQPoint& p ) const { return KDecoration::mousePosition( p ); }
protected:
    bool eventFilter( TQObject* o, TQEvent* e );
    void resizeEvent( TQResizeEvent* );
    void paintEvent( TQPaintEvent* );

    void mouseDoubleClickEvent( TQMouseEvent * );
    void wheelEvent( TQWheelEvent * );
    void captionChange();

private:
    TQToolButton* closeBtn;
    TQSpacerItem* titlebar;
};



/*
  Like TQToolButton, but provides a clicked(ButtonState) signals that
  has the last pressed mouse button as argument
 */
class ThreeButtonButton: public TQToolButton
{
    TQ_OBJECT
  
public:
  ThreeButtonButton ( TQWidget *parent = 0, const char* name = 0 )
      : TQToolButton( parent, name )
    {
	connect( this, TQT_SIGNAL( clicked() ), this, TQT_SLOT( handleClicked() ) );
        setCursor( arrowCursor );
    }
    ~ThreeButtonButton () {}

signals:
    void clicked( ButtonState );

protected:
    void mousePressEvent( TQMouseEvent* e )
    {
	last_button = e->button();
	TQMouseEvent me ( e->type(), e->pos(), e->globalPos(), Qt::LeftButton, e->state() );
	TQToolButton::mousePressEvent( &me );
    }

    void mouseReleaseEvent( TQMouseEvent* e )
    {
	TQMouseEvent me ( e->type(), e->pos(), e->globalPos(), Qt::LeftButton, e->state() );
	TQToolButton::mouseReleaseEvent( &me );
    }

private slots:
    void handleClicked()
    {
	emit clicked( last_button );
    }

private:
    ButtonState last_button;

};

class StdFactory : public KDecorationFactory
{
public:
    StdFactory();
    ~StdFactory();
    KDecoration* createDecoration( KDecorationBridge* b );
    bool reset( unsigned long mask );
    virtual bool supports( Ability ability );
};

}

#endif