summaryrefslogtreecommitdiffstats
path: root/arts/gui/kde/kpopupbox_impl.cpp
blob: 5438d131a6f58a01c9047cded7409507082c0951 (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
    /*

    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.

    */

#include "kpopupbox_impl.h"
#include "kpopupbox_private.h"

#include <tqlayout.h>

using namespace Arts;

KPopupBox_impl::KPopupBox_impl( KPopupBox_widget *w ) : KFrame_impl( w ? w : new KPopupBox_widget )
{
	self().framestyle( Box ); self().margin( 1 ); self().linewidth( 1 );
	self().vSizePolicy( spFixed ); self().hSizePolicy( spFixed );

	if( !w ) w = static_cast<KPopupBox_widget *>( _qframe );

	_widget = w;
//	_mapper = new KPopupBoxEventMapper( _widget, this );
}
KPopupBox_impl::~KPopupBox_impl() {
}

Direction KPopupBox_impl::direction() { return _widget->direction(); }
void KPopupBox_impl::direction( Direction n ) { _widget->direction( n ); }

void KPopupBox_impl::widget( Arts::Widget widget ) {
	widget.tqparent( self() );
	this->_addChild( widget, "PopupBox_child" );
	_widget->setWidget( widget );
}
Arts::Widget KPopupBox_impl::widget() { return _widget->getWidget(); }

std::string KPopupBox_impl::name() { return _name; }
void KPopupBox_impl::name( const std::string& n ) { _name = ""; _name = n; _widget->name( n ); }

// Following the private class:

KPopupBox_widget::KPopupBox_widget( TQWidget *tqparent, const char* name ) : TQFrame( tqparent,name )
{
	this->setFrameShape( TQFrame::Box );
	this->setMargin( 1 ); this->setLineWidth( 1 );

	_titlebar = new TQFrame( this );
	_titlebartqlayout = new TQBoxLayout( _titlebar, TQBoxLayout::BottomToTop );
	_titlebartqlayout->setAutoAdd( true );

	_showbutton = new ShowButton( _titlebar );
	connect( _showbutton, TQT_SIGNAL( toggled( bool ) ), this, TQT_SLOT( hide( bool ) ) );
	_drag = new HandleDrag( _titlebar );
	connect( _drag, TQT_SIGNAL( clicked() ), _showbutton, TQT_SLOT( toggle() ) );
	_ownbutton = new OwnButton( _titlebar );
	connect( _ownbutton, TQT_SIGNAL( toggled( bool ) ), this, TQT_SLOT( own( bool ) ) );

	_artswidget = new OwnWidget( _showbutton, this );

	_layout = new TQBoxLayout( this, TQBoxLayout::LeftToRight );
	_layout->addWidget( _titlebar , -1 );
	_layout->addWidget( _artswidget, 20 );
	_layout->addStretch( 0 );
}
KPopupBox_widget::~KPopupBox_widget() {
}

Arts::Direction KPopupBox_widget::direction() {
	return Arts::Direction( _layout->direction() );
}

void KPopupBox_widget::direction( Arts::Direction n ) {
	_layout->setDirection( TQBoxLayout::Direction( n ) );
	_showbutton->direction( TQBoxLayout::Direction( n ) );
	switch( n ) {
		case LeftToRight:
		case RightToLeft:
			_titlebartqlayout->setDirection( TQBoxLayout::BottomToTop );
			_drag->setMinimumHeight( 30 );
			_drag->setMinimumWidth( 0 );
			break;
		case TopToBottom:
		case BottomToTop:
			_titlebartqlayout->setDirection( TQBoxLayout::RightToLeft );
			_drag->setMinimumHeight( 0 );
			_drag->setMinimumWidth( 30 );
	}
}

void KPopupBox_widget::setWidget( Arts::Widget widget ) { _artswidget->setContent( widget ); }
Arts::Widget KPopupBox_widget::getWidget() { return _artswidget->content(); }

void KPopupBox_widget::hide( bool n ) {
	if( n )
		_artswidget->hide();
	else
		_artswidget->show();
}

void KPopupBox_widget::own( bool n ) {
	if ( n )
		_artswidget->reparent( 0, _artswidget->mapToGlobal( _artswidget->pos() ), !( _artswidget->isHidden() ) );
	else
	{
		_artswidget->reparent( this, TQPoint( 0,0 ), !( _artswidget->isHidden() ) );
		_layout->insertWidget( 1, _artswidget, 20 );
	}
}

void KPopupBox_widget::name( std::string n ) {
	_artswidget->setCaption( n.c_str() );
}

REGISTER_IMPLEMENTATION( KPopupBox_impl );

#include "kpopupbox_private.moc"

// vim: sw=4 ts=4