summaryrefslogtreecommitdiffstats
path: root/lib/kofficeui/tktoolbarbutton.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lib/kofficeui/tktoolbarbutton.cpp')
-rw-r--r--lib/kofficeui/tktoolbarbutton.cpp210
1 files changed, 105 insertions, 105 deletions
diff --git a/lib/kofficeui/tktoolbarbutton.cpp b/lib/kofficeui/tktoolbarbutton.cpp
index b6baba1a..e8040496 100644
--- a/lib/kofficeui/tktoolbarbutton.cpp
+++ b/lib/kofficeui/tktoolbarbutton.cpp
@@ -19,13 +19,13 @@
*/
#include <tktoolbarbutton.h>
-#include <qtimer.h>
-#include <qtooltip.h>
-#include <qpopupmenu.h>
-#include <qcursor.h>
-#include <qpainter.h>
-#include <qdrawutil.h>
-#include <qstyle.h>
+#include <tqtimer.h>
+#include <tqtooltip.h>
+#include <tqpopupmenu.h>
+#include <tqcursor.h>
+#include <tqpainter.h>
+#include <tqdrawutil.h>
+#include <tqstyle.h>
#include <kdeversion.h>
#include <kapplication.h>
@@ -49,14 +49,14 @@ public:
m_autoRaised = true;
ignoreNextMousePress = false;
- m_text = QString::null;
- m_iconName = QString::null;
+ m_text = TQString();
+ m_iconName = TQString();
m_arrowPressed = false;
m_delayTimer = 0L;
m_popup = 0L;
- m_disabledIconName = QString::null;
- m_defaultIconName = QString::null;
+ m_disabledIconName = TQString();
+ m_defaultIconName = TQString();
m_instance = KGlobal::instance();
}
@@ -75,33 +75,33 @@ public:
bool m_arrowPressed;
bool ignoreNextMousePress;
- QString m_text;
- QString m_iconName;
- QString m_disabledIconName;
- QString m_defaultIconName;
+ TQString m_text;
+ TQString m_iconName;
+ TQString m_disabledIconName;
+ TQString m_defaultIconName;
TK::IconMode m_iconMode;
- QTimer *m_delayTimer;
- QPopupMenu *m_popup;
+ TQTimer *m_delayTimer;
+ TQPopupMenu *m_popup;
KInstance *m_instance;
};
-TKToolBarButton::TKToolBarButton( const QString& icon, const QString& txt,
- QWidget* parent, const char* name,
+TKToolBarButton::TKToolBarButton( const TQString& icon, const TQString& txt,
+ TQWidget* tqparent, const char* name,
KInstance *instance )
-: QToolButton(parent,name)
+: TQToolButton(tqparent,name)
{
d = new TKToolBarButtonPrivate;
d->m_text = txt;
d->m_instance = instance;
- setFocusPolicy( NoFocus );
+ setFocusPolicy( TQ_NoFocus );
- connect(this, SIGNAL(clicked()), SLOT(slotClicked()) );
- connect(this, SIGNAL(pressed()), SLOT(slotPressed()) );
- connect(this, SIGNAL(released()), SLOT(slotReleased()) );
+ connect(this, TQT_SIGNAL(clicked()), TQT_SLOT(slotClicked()) );
+ connect(this, TQT_SIGNAL(pressed()), TQT_SLOT(slotPressed()) );
+ connect(this, TQT_SIGNAL(released()), TQT_SLOT(slotReleased()) );
installEventFilter(this);
@@ -109,17 +109,17 @@ TKToolBarButton::TKToolBarButton( const QString& icon, const QString& txt,
modeChange();
}
-TKToolBarButton::TKToolBarButton( const QPixmap& pixmap, const QString& txt, QWidget* parent, const char* name )
-: QToolButton(parent,name )
+TKToolBarButton::TKToolBarButton( const TQPixmap& pixmap, const TQString& txt, TQWidget* tqparent, const char* name )
+: TQToolButton(tqparent,name )
{
d = new TKToolBarButtonPrivate;
d->m_text = txt;
- setFocusPolicy( NoFocus );
+ setFocusPolicy( TQ_NoFocus );
- connect(this, SIGNAL(clicked()), SLOT(slotClicked()) );
- connect(this, SIGNAL(pressed()), SLOT(slotPressed()) );
- connect(this, SIGNAL(released()), SLOT(slotReleased()) );
+ connect(this, TQT_SIGNAL(clicked()), TQT_SLOT(slotClicked()) );
+ connect(this, TQT_SIGNAL(pressed()), TQT_SLOT(slotPressed()) );
+ connect(this, TQT_SIGNAL(released()), TQT_SLOT(slotReleased()) );
installEventFilter(this);
@@ -132,14 +132,14 @@ TKToolBarButton::~TKToolBarButton()
delete d;
}
-QString TKToolBarButton::text()
+TQString TKToolBarButton::text()
{
return d->m_text;
}
void TKToolBarButton::modeChange()
{
- QToolTip::add(this,d->m_text);
+ TQToolTip::add(this,d->m_text);
int border = 3;
int w = 2*border;
@@ -147,24 +147,24 @@ void TKToolBarButton::modeChange()
if (pixmap()) {
w += pixmap()->width();
- h = QMAX(h,pixmap()->height()+2*border);
+ h = TQMAX(h,pixmap()->height()+2*border);
if (d->m_iconMode == TK::IconAndText && !d->m_text.isEmpty())
w += border;
}
if ((d->m_iconMode==TK::IconAndText||d->m_iconMode==TK::TextOnly) && !d->m_text.isEmpty())
{
- QFont tmp_font = KGlobalSettings::toolBarFont();
- QFontMetrics fm(tmp_font);
+ TQFont tmp_font = KGlobalSettings::toolBarFont();
+ TQFontMetrics fm(tmp_font);
- h = QMAX(h,fm.lineSpacing()+2*border);
+ h = TQMAX(h,fm.lineSpacing()+2*border);
w += fm.width(d->m_text);
}
if (d->m_popup && !d->m_isToggle)
w += 11;
- QSize size(w,h);
+ TQSize size(w,h);
setMinimumSize(size);
updateGeometry();
@@ -175,17 +175,17 @@ void TKToolBarButton::setEnabled( bool enabled )
if (isEnabled()==enabled)
return;
- QToolButton::setPixmap( (enabled ? defaultPixmap : disabledPixmap) );
- QToolButton::setEnabled( enabled );
+ TQToolButton::setPixmap( (enabled ? defaultPixmap : disabledPixmap) );
+ TQToolButton::setEnabled( enabled );
}
-void TKToolBarButton::setText( const QString& text)
+void TKToolBarButton::setText( const TQString& text)
{
d->m_text = text;
- repaint(false);
+ tqrepaint(false);
}
-void TKToolBarButton::setIcon( const QString& icon )
+void TKToolBarButton::setIcon( const TQString& icon )
{
d->m_iconName = icon;
int iconSize = 16;
@@ -195,31 +195,31 @@ void TKToolBarButton::setIcon( const QString& icon )
setDefaultPixmap( BarIcon(icon, iconSize, KIcon::DefaultState, d->m_instance) );
}
-void TKToolBarButton::setDisabledIcon( const QString &icon )
+void TKToolBarButton::setDisabledIcon( const TQString &icon )
{
d->m_disabledIconName = icon;
int iconSize = 16;
setDisabledPixmap( BarIcon(icon, iconSize, KIcon::DisabledState, d->m_instance) );
}
-void TKToolBarButton::setDefaultIcon( const QString &icon )
+void TKToolBarButton::setDefaultIcon( const TQString &icon )
{
d->m_defaultIconName = icon;
int iconSize = 16;
setDefaultPixmap( BarIcon(icon, iconSize, KIcon::DefaultState, d->m_instance) );
}
-QPixmap TKToolBarButton::getActivePixmap() const
+TQPixmap TKToolBarButton::getActivePixmap() const
{
return activePixmap;
}
-void TKToolBarButton::setPixmap( const QPixmap &pixmap )
+void TKToolBarButton::setPixmap( const TQPixmap &pixmap )
{
setPixmap( pixmap, true );
}
-void TKToolBarButton::setPixmap( const QPixmap &pixmap, bool generate )
+void TKToolBarButton::setPixmap( const TQPixmap &pixmap, bool generate )
{
activePixmap = pixmap;
@@ -236,22 +236,22 @@ void TKToolBarButton::setPixmap( const QPixmap &pixmap, bool generate )
disabledPixmap = activePixmap;
}
- QToolButton::setPixmap( isEnabled() ? defaultPixmap : disabledPixmap );
+ TQToolButton::setPixmap( isEnabled() ? defaultPixmap : disabledPixmap );
}
-void TKToolBarButton::setDefaultPixmap( const QPixmap &pixmap )
+void TKToolBarButton::setDefaultPixmap( const TQPixmap &pixmap )
{
defaultPixmap = pixmap;
- QToolButton::setPixmap( isEnabled() ? defaultPixmap : disabledPixmap );
+ TQToolButton::setPixmap( isEnabled() ? defaultPixmap : disabledPixmap );
}
-void TKToolBarButton::setDisabledPixmap( const QPixmap &pixmap )
+void TKToolBarButton::setDisabledPixmap( const TQPixmap &pixmap )
{
disabledPixmap = pixmap;
- QToolButton::setPixmap( isEnabled() ? defaultPixmap : disabledPixmap );
+ TQToolButton::setPixmap( isEnabled() ? defaultPixmap : disabledPixmap );
}
-void TKToolBarButton::setPopup(QPopupMenu *p)
+void TKToolBarButton::setPopup(TQPopupMenu *p)
{
d->m_popup = p;
d->m_popup->setFont(KGlobalSettings::toolBarFont());
@@ -260,19 +260,19 @@ void TKToolBarButton::setPopup(QPopupMenu *p)
modeChange();
}
-QPopupMenu *TKToolBarButton::popup()
+TQPopupMenu *TKToolBarButton::popup()
{
return d->m_popup;
}
-void TKToolBarButton::setDelayedPopup (QPopupMenu *p, bool toggle )
+void TKToolBarButton::setDelayedPopup (TQPopupMenu *p, bool toggle )
{
d->m_isPopup = true;
setToggle(toggle);
if (!d->m_delayTimer) {
- d->m_delayTimer = new QTimer(this);
- connect(d->m_delayTimer, SIGNAL(timeout()), this, SLOT(slotDelayTimeout()));
+ d->m_delayTimer = new TQTimer(this);
+ connect(d->m_delayTimer, TQT_SIGNAL(timeout()), this, TQT_SLOT(slotDelayTimeout()));
}
setPopup(p);
@@ -281,7 +281,7 @@ void TKToolBarButton::setDelayedPopup (QPopupMenu *p, bool toggle )
void TKToolBarButton::setRaised(bool f)
{
d->m_isRaised = f;
- repaint(false);
+ tqrepaint(false);
}
void TKToolBarButton::setAutoRaised(bool f)
@@ -289,55 +289,55 @@ void TKToolBarButton::setAutoRaised(bool f)
d->m_autoRaised = f;
}
-void TKToolBarButton::leaveEvent(QEvent *)
+void TKToolBarButton::leaveEvent(TQEvent *)
{
if (!d->m_isToggle && !(d->m_popup && d->m_popup->isVisible()) ) {
- QToolButton::setPixmap(isEnabled() ? defaultPixmap : disabledPixmap);
+ TQToolButton::setPixmap(isEnabled() ? defaultPixmap : disabledPixmap);
if (d->m_autoRaised)
setRaised(false);
}
}
-void TKToolBarButton::enterEvent(QEvent *)
+void TKToolBarButton::enterEvent(TQEvent *)
{
if (!d->m_isToggle) {
if (isEnabled()) {
- QToolButton::setPixmap(activePixmap);
+ TQToolButton::setPixmap(activePixmap);
if (d->m_autoRaised)
setRaised(true);
} else {
- QToolButton::setPixmap(disabledPixmap);
+ TQToolButton::setPixmap(disabledPixmap);
}
- repaint(false);
+ tqrepaint(false);
}
}
-bool TKToolBarButton::eventFilter(QObject *o, QEvent *ev)
+bool TKToolBarButton::eventFilter(TQObject *o, TQEvent *ev)
{
- if ( o == this )
- if (ev->type() == QEvent::MouseButtonPress && d->m_popup && d->m_isPopup ) {
+ if ( TQT_BASE_OBJECT(o) == TQT_BASE_OBJECT(this) )
+ if (ev->type() == TQEvent::MouseButtonPress && d->m_popup && d->m_isPopup ) {
if (!d->m_isToggle) {
- d->m_arrowPressed = arrowPressed( mapFromGlobal(QCursor::pos()) );
+ d->m_arrowPressed = arrowPressed( mapFromGlobal(TQCursor::pos()) );
} else {
d->m_delayTimer->start(POPUP_DELAY);
}
}
- if ( o == d->m_popup) {
+ if ( TQT_BASE_OBJECT(o) == TQT_BASE_OBJECT(d->m_popup)) {
switch (ev->type())
{
- case QEvent::Show:
+ case TQEvent::Show:
on(true);
return false;
- case QEvent::Hide:
+ case TQEvent::Hide:
on(false);
setDown(false);
- if ( !geometry().contains(parentWidget()->mapFromGlobal(QCursor::pos())) )
+ if ( !tqgeometry().tqcontains(tqparentWidget()->mapFromGlobal(TQCursor::pos())) )
leaveEvent(0L);
return false;
break;
- case QEvent::MouseButtonPress: {
- d->m_arrowPressed = arrowPressed( mapFromGlobal(QCursor::pos()) );
+ case TQEvent::MouseButtonPress: {
+ d->m_arrowPressed = arrowPressed( mapFromGlobal(TQCursor::pos()) );
d->ignoreNextMousePress = d->m_arrowPressed;
break;
}
@@ -348,19 +348,19 @@ bool TKToolBarButton::eventFilter(QObject *o, QEvent *ev)
return false;
}
-void TKToolBarButton::drawButton( QPainter* p )
+void TKToolBarButton::drawButton( TQPainter* p )
{
#define DRAW_PIXMAP_AND_TEXT \
int x = 3;\
if (pixmap()) {\
- style().drawItem( p, QRect( x, 0, pixmap()->width(), height() ), AlignCenter, colorGroup(), isEnabled(), pixmap(), QString::null );\
+ tqstyle().drawItem( p, TQRect( x, 0, pixmap()->width(), height() ), AlignCenter, tqcolorGroup(), isEnabled(), pixmap(), TQString() );\
if (d->m_iconMode==TK::IconAndText && !d->m_text.isEmpty()) {\
x += pixmap()->width() + 3;\
}\
}\
if ((d->m_iconMode==TK::IconAndText||d->m_iconMode==TK::TextOnly) && !d->m_text.isEmpty()) {\
- QFontMetrics fm(KGlobalSettings::toolBarFont());\
- style().drawItem( p, QRect( x, 0, fm.width(d->m_text), height() ), AlignCenter, colorGroup(), isEnabled(), 0, d->m_text );\
+ TQFontMetrics fm(KGlobalSettings::toolBarFont());\
+ tqstyle().drawItem( p, TQRect( x, 0, fm.width(d->m_text), height() ), AlignCenter, tqcolorGroup(), isEnabled(), 0, d->m_text );\
}
const char* arrow[] = {
@@ -371,45 +371,45 @@ void TKToolBarButton::drawButton( QPainter* p )
".#####.",
"..###..",
"...#..."};
- QPixmap arrow_pix(arrow);
+ TQPixmap arrow_pix(arrow);
bool f = d->m_isOn || isDown();
if (d->m_popup && !d->m_isToggle)
{
if (d->m_isPopup)
{
- QStyle::SFlags flags = QStyle::Style_Default;
- if (isEnabled()) flags |= QStyle::Style_Enabled;
- if (isOn()) flags |= QStyle::Style_On;
- if (d->m_isRaised) flags |= QStyle::Style_Raised;
- if (hasFocus()) flags |= QStyle::Style_HasFocus;
-
- style().drawComplexControl( QStyle::CC_ToolButton, p, this, QRect( 0, 0, width()-12, height() ), colorGroup(), flags, QStyle::SC_ToolButton );
- style().drawComplexControl( QStyle::CC_ToolButton, p, this, QRect( width()-13, 0, 13, height() ), colorGroup(), flags, QStyle::SC_ToolButton );
- style().drawItem( p, QRect( width()-13, 0, 13, height() ), AlignCenter, colorGroup(), isEnabled(), &arrow_pix, QString::null );
+ TQStyle::SFlags flags = TQStyle::Style_Default;
+ if (isEnabled()) flags |= TQStyle::Style_Enabled;
+ if (isOn()) flags |= TQStyle::Style_On;
+ if (d->m_isRaised) flags |= TQStyle::Style_Raised;
+ if (hasFocus()) flags |= TQStyle::Style_HasFocus;
+
+ tqstyle().tqdrawComplexControl( TQStyle::CC_ToolButton, p, this, TQRect( 0, 0, width()-12, height() ), tqcolorGroup(), flags, TQStyle::SC_ToolButton );
+ tqstyle().tqdrawComplexControl( TQStyle::CC_ToolButton, p, this, TQRect( width()-13, 0, 13, height() ), tqcolorGroup(), flags, TQStyle::SC_ToolButton );
+ tqstyle().drawItem( p, TQRect( width()-13, 0, 13, height() ), AlignCenter, tqcolorGroup(), isEnabled(), &arrow_pix, TQString() );
if ( d->m_isRaised )
- qDrawShadeLine( p, width()-12, 0, width()-12, height(), colorGroup(), true );
+ qDrawShadeLine( p, width()-12, 0, width()-12, height(), tqcolorGroup(), true );
DRAW_PIXMAP_AND_TEXT
} else {
- style().drawControl( QStyle::CE_PushButton, p, this, QRect( 0, 0, width(), height() ), isEnabled() ? colorGroup() : palette().disabled(), f );
+ tqstyle().tqdrawControl( TQStyle::CE_PushButton, p, this, TQRect( 0, 0, width(), height() ), isEnabled() ? tqcolorGroup() : tqpalette().disabled(), f );
DRAW_PIXMAP_AND_TEXT
int z = f ? 1:0;
p->drawPixmap(width()-11+z,(height()-4)/2+z ,arrow_pix);
}
} else {
- style().drawControl( QStyle::CE_PushButton, p, this, QRect( 0, 0, width(), height() ), isEnabled() ? colorGroup() : palette().disabled(), f );
+ tqstyle().tqdrawControl( TQStyle::CE_PushButton, p, this, TQRect( 0, 0, width(), height() ), isEnabled() ? tqcolorGroup() : tqpalette().disabled(), f );
DRAW_PIXMAP_AND_TEXT
}
}
-void TKToolBarButton::paletteChange(const QPalette &)
+void TKToolBarButton::paletteChange(const TQPalette &)
{
makeDisabledPixmap();
if ( !isEnabled() )
- QToolButton::setPixmap( disabledPixmap );
+ TQToolButton::setPixmap( disabledPixmap );
else
- QToolButton::setPixmap( defaultPixmap );
- repaint(false);
+ TQToolButton::setPixmap( defaultPixmap );
+ tqrepaint(false);
}
void TKToolBarButton::makeDefaultPixmap()
@@ -430,19 +430,19 @@ void TKToolBarButton::makeDisabledPixmap()
disabledPixmap = effect.apply(activePixmap, KIcon::Toolbar, KIcon::DisabledState);
}
-QSize TKToolBarButton::sizeHint() const
+TQSize TKToolBarButton::tqsizeHint() const
{
- return minimumSize();
+ return tqminimumSize();
}
-QSize TKToolBarButton::minimumSizeHint() const
+TQSize TKToolBarButton::tqminimumSizeHint() const
{
- return minimumSize();
+ return tqminimumSize();
}
void TKToolBarButton::showMenu()
{
- QPoint p ( mapToGlobal( QPoint( 0, 0 ) ) );
+ TQPoint p ( mapToGlobal( TQPoint( 0, 0 ) ) );
const int deskHeight = KGlobalSettings::desktopGeometry(this).height();
if ( p.y() + height() + d->m_popup->height() > deskHeight )
p.setY( p.y() - d->m_popup->height() );
@@ -502,7 +502,7 @@ void TKToolBarButton::slotToggled()
void TKToolBarButton::on(bool flag)
{
d->m_isOn = flag;
- repaint();
+ tqrepaint();
}
void TKToolBarButton::toggle()
@@ -514,19 +514,19 @@ void TKToolBarButton::setToggle(bool flag)
{
d->m_isToggle = flag;
if (flag == true)
- connect(this, SIGNAL(toggled(bool)), this, SLOT(slotToggled()));
+ connect(this, TQT_SIGNAL(toggled(bool)), this, TQT_SLOT(slotToggled()));
else
- disconnect(this, SIGNAL(toggled(bool)), this, SLOT(slotToggled()));
+ disconnect(this, TQT_SIGNAL(toggled(bool)), this, TQT_SLOT(slotToggled()));
modeChange();
- repaint();
+ tqrepaint();
}
void TKToolBarButton::setIconMode( TK::IconMode m )
{
d->m_iconMode = m;
modeChange();
- repaint();
+ tqrepaint();
}
#include <tktoolbarbutton.moc>