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
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
|
/*
Copyright ( C ) 2002, 2003 Arnold Krille <arnold@arnoldarts.de>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or ( at your option ) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#ifndef KPOPUPBOX_PRIVATE_H
#define KPOPUPBOX_PRIVATE_H
class HandleDrag;
class ShowButton;
class OwnButton;
class KArtsWidget;
class OwnWidget;
class TQBoxLayout;
#include <tqframe.h>
class KPopupBox_widget : public TQFrame
{
Q_OBJECT
TQ_OBJECT
public:
KPopupBox_widget( TQWidget* =0, const char* =0);
~KPopupBox_widget();
Arts::Direction direction();
void direction( Arts::Direction );
void setWidget( Arts::Widget widget );
Arts::Widget getWidget();
void name( std::string );
private slots:
void hide( bool );
void own( bool );
private:
TQBoxLayout *_layout;
TQFrame *_titlebar;
TQBoxLayout *_titlebarlayout;
HandleDrag *_drag;
ShowButton *_showbutton;
OwnButton *_ownbutton;
OwnWidget *_artswidget;
};
// See kpopupbox_impl.h - The eventmapper isn't needed at present, but perhaps in the future...
/*class KPopupBoxEventMapper : public TQObject {
Q_OBJECT
TQ_OBJECT
public:
KPopupBoxEventMapper( KPopupBox_widget *widget, Arts::KPopupBox_impl *impl )
: TQObject( widget,"" ), _widget( widget ), _impl( impl )
{}
private:
KPopupBox_widget *_widget;
Arts::KPopupBox_impl *_impl;
};*/
#include <tqpainter.h>
#include <tqstyle.h>
class HandleDrag : public TQWidget {
Q_OBJECT
TQ_OBJECT
public:
HandleDrag( TQWidget *parent, const char* name=0 ) : TQWidget( parent,name ) {}
void paintEvent( TQPaintEvent * ) {
TQPainter p( this );
TQStyle::SFlags flags = TQStyle::Style_Default;
if( width() < height() ) flags |= TQStyle::Style_Horizontal;
style().tqdrawPrimitive( TQStyle::PE_DockWindowHandle, &p, rect(), colorGroup(), flags );
}
signals:
void clicked();
protected:
virtual void mouseDoubleClickEvent( TQMouseEvent * ) {
emit clicked();
}
};
static const char* const close_xpm[] = { "5 5 2 1", "# c black", ". c None", "#...#", ".#.#.", "..#..", ".#.#.", "#...#"};
static const char* const up_xpm[] = { "5 5 2 1", "# c black", ". c None", ".....", "..#..", ".###.", "#####", "....."};
static const char* const down_xpm[] = { "5 5 2 1", "# c black", ". c None", ".....", "#####", ".###.", "..#..", "....."};
static const char* const left_xpm[] = { "5 5 2 1", "# c black", ". c None", "...#.", "..##.", ".###.", "..##.", "...#."};
static const char* const right_xpm[] = { "5 5 2 1", "# c black", ". c None", ".#...", ".##..", ".###.", ".##..", ".#..."};
static const char* const inside_xpm[] = { "5 5 2 1", "# c black", ". c None", "#####", "#...#", "#...#", "#...#", "#####"};
static const char* const own_xpm[] = { "5 5 2 1", "# c black", ". c None", "###..", "#.###", "###.#", ".#..#", ".####"};
#include <tqpushbutton.h>
#include <tqlayout.h>
class ShowButton : public TQPushButton {
Q_OBJECT
TQ_OBJECT
private:
TQBoxLayout::Direction _dir;
TQPixmap _pmleft, _pmright, _pmup, _pmdown;
public:
ShowButton( TQWidget *parent, const char* name=0 ) : TQPushButton( parent,name ), _dir( TQBoxLayout::LeftToRight )
{
connect( this, TQT_SIGNAL( toggled( bool ) ), this, TQT_SLOT( owntoggle( bool ) ) );
setToggleButton( true );
_pmleft = TQPixmap( const_cast<const char**>( left_xpm ) );
_pmright = TQPixmap( const_cast<const char**>( right_xpm ) );
_pmup = TQPixmap( const_cast<const char**>( up_xpm ) );
_pmdown = TQPixmap( const_cast<const char**>( down_xpm ) );
setPixmap( _pmright );
}
void direction( TQBoxLayout::Direction n ) { _dir=n; }
public slots:
void owntoggle( bool b ) {
switch( _dir )
{
case TQBoxLayout::BottomToTop:
if( b ) setPixmap( _pmdown );
else setPixmap( _pmup );
break;
case TQBoxLayout::TopToBottom:
if( b ) setPixmap( _pmup );
else setPixmap( _pmdown );
break;
case TQBoxLayout::LeftToRight:
if( b ) setPixmap( _pmright );
else setPixmap( _pmleft );
break;
case TQBoxLayout::RightToLeft:
if( b ) setPixmap( _pmleft );
else setPixmap( _pmright );
break;
}
}
public:
TQSize minimumSizeHint() const {
int wh = style().pixelMetric( TQStyle::PM_DockWindowHandleExtent, this );
return TQSize( wh, wh );
}
TQSizePolicy sizePolicy() const { return TQSizePolicy( TQSizePolicy::Fixed, TQSizePolicy::Fixed ); }
TQSize minimumSize() const { return minimumSizeHint(); }
TQSize sizeHint() const { return minimumSize(); }
void drawButton( TQPainter * p )
{
p->fillRect( 0,0, width(), height(), TQBrush( colorGroup().brush( TQColorGroup::Background ) ) );
p->drawPixmap( ( width() - pixmap()->width() ) / 2, ( height() - pixmap()->height() ) / 2, *pixmap() );
}
};
class OwnButton : public TQPushButton {
Q_OBJECT
TQ_OBJECT
private:
TQPixmap _pmown, _pminside;
public:
OwnButton( TQWidget *parent, const char* name=0 ) : TQPushButton( parent,name )
{
connect( this, TQT_SIGNAL( toggled( bool ) ), this, TQT_SLOT( toggle( bool ) ) );
setToggleButton( true );
_pmown = TQPixmap( const_cast<const char**>( own_xpm ) );
_pminside = TQPixmap( const_cast<const char**>( inside_xpm ) );
setPixmap( _pmown );
}
public slots:
void toggle( bool b ) {
if( b ) setPixmap( _pminside );
else setPixmap( _pmown );
}
public:
TQSize minimumSizeHint() const {
int wh = style().pixelMetric( TQStyle::PM_DockWindowHandleExtent, this );
return TQSize( wh, wh );
}
TQSizePolicy sizePolicy() const { return TQSizePolicy( TQSizePolicy::Fixed, TQSizePolicy::Fixed ); }
TQSize minimumSize() const { return minimumSizeHint(); }
TQSize sizeHint() const { return minimumSize(); }
void drawButton( TQPainter * p )
{
p->fillRect( 0,0, width(), height(), TQBrush( colorGroup().brush( TQColorGroup::Background ) ) );
p->drawPixmap( ( width() - pixmap()->width() ) / 2, ( height() - pixmap()->height() ) / 2, *pixmap() );
}
};
#include <kartswidget.h>
class OwnWidget : public KArtsWidget
{
Q_OBJECT
TQ_OBJECT
ShowButton *_b;
public:
OwnWidget( ShowButton* b, TQWidget* p, const char* n=0, WFlags f=0 ) : KArtsWidget( p,n,f ) { _b = b; }
~OwnWidget() {}
public slots:
void closeEvent( TQCloseEvent * ) { _b->toggle(); }
};
#endif
// vim: sw=4 ts=4
|