summaryrefslogtreecommitdiffstats
path: root/src/kvirc/ui/kvi_toolwindows_container.cpp
blob: 270a7063a7175a4682ac4682ded0c0e8ea101496 (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
#define __KVIRC__


#include <qlayout.h> 
#include <qtoolbutton.h> 
#include <qobjectcleanuphandler.h> 
#include <qpushbutton.h> 
#include "kvi_tal_vbox.h"
#include <qpainter.h>
#include <qapplication.h>

#include "kvi_toolwindows_container.h"
#include "kvi_iconmanager.h"


KviWindowToolWidget::KviWindowToolWidget(QWidget * parent, KviWindowToolPageButton* button/*, const char * name, WFlags f*/ )
:QWidget(parent/*,name,f*/)
{
//	m_pContainer=parent;
	m_pButton=button;
	m_bAutoDelete=1;
	m_bHidden=0;
	if(m_pButton) m_pButton->setOn(!isHidden());
//	m_ObjectHandler.add(button);
//	setMinimumWidth(0);
}

KviWindowToolWidget::~KviWindowToolWidget()
{
//	unregisterSelf();
//	m_ObjectHandler.remove(m_pButton);

}

void KviWindowToolWidget::registerSelf()
{
/*	m_pContainer->registerWidget(this);
	if(!m_ObjectHandler.isEmpty())
	{
		if(m_pButton)
			m_pButton->setOn(true);
	} else {
		m_pButton=0;
	}*/
}

void KviWindowToolWidget::unregisterSelf()
{
/*	if(!m_bHidden)
		m_pContainer->unregisterWidget(this);
	if(!m_ObjectHandler.isEmpty())
	{
		if(m_pButton)
			m_pButton->setOn(false);
	} else {
		m_pButton=0;
	}*/
}

/*void KviWindowToolWidget::hide()
{
	if(m_bAutoDelete==0)
	{
		unregisterSelf();
		m_bHidden=1;
	}
	QWidget::hide();
}*/

/*void KviWindowToolWidget::show()
{
	if(m_bHidden)
	{
		registerSelf();
	}
	QWidget::show();
	m_bHidden=0;
}*/

KviWindowToolPageButton::KviWindowToolPageButton ( int pixon,int pixoff, const QString & text, QWidget * parent,bool bOn, const char * name )
:TOOL_PAGE_PARENT(parent)
{
#ifdef COMPILE_USE_QT4
	setFlat(true);
	setObjectName("kvi_window_tool_button");
	setIcon(QIcon(*(g_pIconManager->getSmallIcon(pixon))));
#else
	QIconSet is1;
	is1.setPixmap(*(g_pIconManager->getSmallIcon(pixon)),QIconSet::Small,QIconSet::Normal,QIconSet::On);
	is1.setPixmap(*(g_pIconManager->getSmallIcon(pixoff)),QIconSet::Small,QIconSet::Normal,QIconSet::Off);
	setIconSet(is1);
	setUsesBigPixmap(false);
#endif
	setToggleButton(true);
	setOn(bOn);

//	setSizePolicy(QSizePolicy(QSizePolicy::Fixed,QSizePolicy::Ignored));
}

KviWindowToolPageButton::~KviWindowToolPageButton()
{

}

/*void KviWindowToolPageButton::drawButton ( QPainter * p)
{
	QPixmap pixmap( height(), width() );
	if(isOn())
		pixmap.fill(colorGroup().mid());
	else
    		pixmap.fill(colorGroup().button()); 
    	QPainter painter( &pixmap );
    	
	QPixmap icon;
	if(isOn())
		icon=iconSet()->pixmap(QIconSet::Small,QIconSet::Normal,QIconSet::On);
	else
		icon=iconSet()->pixmap(QIconSet::Small,QIconSet::Normal,QIconSet::Off);
		
	// Draw the frame
	//painter.setPen( colorGroup().mid() );
	//if ( m_id != NUM_TABS - 1 ) painter.drawLine( 0, 0, 0, pixmap.height() - 1 );
	//painter.drawLine( 0, pixmap.height() - 1, pixmap.width() - 1, pixmap.height() - 1 );
	
	// Draw the text
	QFont font;
	QString str = text();
	str.remove("&");
	const int textX = pixmap.width() / 2 - QFontMetrics( font ).width( str ) / 2;
	painter.setPen( colorGroup().buttonText() );
	const QRect rect( textX + icon.width() / 2 + 2, 0, pixmap.width(), pixmap.height() );
	painter.drawText( rect, Qt::AlignLeft | Qt::AlignVCenter, str );
	
	// Draw the icon
	painter.drawPixmap( textX - icon.width() / 2 - 2, pixmap.height() / 2 - icon.height() / 2, icon );
	
	// Paint to widget
	p->rotate( -90 );
	p->drawPixmap( 1 - pixmap.width(), 0, pixmap );
}*/