summaryrefslogtreecommitdiffstats
path: root/krecipes/src/widgets/kremenu.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'krecipes/src/widgets/kremenu.cpp')
-rw-r--r--krecipes/src/widgets/kremenu.cpp168
1 files changed, 84 insertions, 84 deletions
diff --git a/krecipes/src/widgets/kremenu.cpp b/krecipes/src/widgets/kremenu.cpp
index 892ff75..ca76921 100644
--- a/krecipes/src/widgets/kremenu.cpp
+++ b/krecipes/src/widgets/kremenu.cpp
@@ -11,14 +11,14 @@
***************************************************************************/
#include "kremenu.h"
-#include <qbitmap.h>
-#include <qcursor.h>
-#include <qfont.h>
-#include <qimage.h>
-#include <qobjectlist.h>
-#include <qpainter.h>
-#include <qpixmap.h>
-#include <qsignalmapper.h>
+#include <ntqbitmap.h>
+#include <ntqcursor.h>
+#include <ntqfont.h>
+#include <ntqimage.h>
+#include <ntqobjectlist.h>
+#include <ntqpainter.h>
+#include <ntqpixmap.h>
+#include <ntqsignalmapper.h>
#include <kapplication.h>
#include <kcursor.h>
@@ -30,11 +30,11 @@
#include <kpixmap.h>
#include <kpixmapeffect.h>
-KreMenu::KreMenu( QWidget *parent, const char *name ) :
-#if QT_VERSION >= 0x030200
- QWidget( parent, name, Qt::WNoAutoErase )
+KreMenu::KreMenu( TQWidget *parent, const char *name ) :
+#if TQT_VERSION >= 0x030200
+ TQWidget( parent, name, TQt::WNoAutoErase )
#else
- QWidget( parent, name )
+ TQWidget( parent, name )
#endif
{
Menu newMenu;
@@ -45,19 +45,19 @@ KreMenu::KreMenu( QWidget *parent, const char *name ) :
m_currentMenu = &( *currentMenuId );
setMouseTracking( true );
- setFocusPolicy( QWidget::StrongFocus );
- setSizePolicy( QSizePolicy::Fixed, QSizePolicy::Preferred );
+ setFocusPolicy( TQWidget::StrongFocus );
+ setSizePolicy( TQSizePolicy::Fixed, TQSizePolicy::Preferred );
}
KreMenu::~KreMenu()
{}
-void KreMenu::childEvent ( QChildEvent *e )
+void KreMenu::childEvent ( TQChildEvent *e )
{
- if ( e->type() == QChildEvent::ChildInserted ) {
+ if ( e->type() == TQChildEvent::ChildInserted ) {
- QObject * child = e->child();
+ TQObject * child = e->child();
if ( child->inherits( "KreMenuButton" ) ) {
KreMenuButton * button = ( KreMenuButton* ) child;
@@ -81,8 +81,8 @@ void KreMenu::childEvent ( QChildEvent *e )
connect ( button, SIGNAL( clicked( KreMenuButton* ) ), this, SLOT( collectClicks( KreMenuButton* ) ) );
}
}
- else if ( e->type() == QChildEvent::ChildRemoved ) {
- QObject * child = e->child();
+ else if ( e->type() == TQChildEvent::ChildRemoved ) {
+ TQObject * child = e->child();
KreMenuButton *button = ( KreMenuButton* ) child;
if ( m_currentMenu->positionList.find( button ) != m_currentMenu->positionList.end() ) // Ensure that what was removed was a button
@@ -104,7 +104,7 @@ void KreMenu::childEvent ( QChildEvent *e )
}
}
- QWidget::childEvent( e );
+ TQWidget::childEvent( e );
}
void KreMenu::collectClicks( KreMenuButton *w )
@@ -118,7 +118,7 @@ void KreMenu::collectClicks( KreMenuButton *w )
emit clicked( panel );
}
-MenuId KreMenu::createSubMenu( const QString &title, const QString &icon )
+MenuId KreMenu::createSubMenu( const TQString &title, const TQString &icon )
{
// Create the new menu
@@ -164,40 +164,40 @@ void KreMenu::highlightButton( KreMenuButton *button )
buttonMenu->activeButton = button;
}
-void KreMenu::keyPressEvent( QKeyEvent *e )
+void KreMenu::keyPressEvent( TQKeyEvent *e )
{
switch ( e->key() ) {
- case Qt::Key_Up: {
+ case TQt::Key_Up: {
int current_index = m_currentMenu->positionList[ m_currentMenu->activeButton ];
if ( current_index > 0 ) {
highlightButton( m_currentMenu->widgetList[ current_index - 1 ] );
//simulate a mouse click
- QMouseEvent me( QEvent::MouseButtonPress, QPoint(), 0, 0 );
+ TQMouseEvent me( TQEvent::MouseButtonPress, TQPoint(), 0, 0 );
KApplication::sendEvent( m_currentMenu->activeButton, &me );
e->accept();
}
break;
}
- case Qt::Key_Down: {
+ case TQt::Key_Down: {
int current_index = m_currentMenu->positionList[ m_currentMenu->activeButton ];
if ( current_index < int( m_currentMenu->positionList.count() ) - 1 ) {
highlightButton( m_currentMenu->widgetList[ current_index + 1 ] );
//simulate a mouse click
- QMouseEvent me( QEvent::MouseButtonPress, QPoint(), 0, 0 );
+ TQMouseEvent me( TQEvent::MouseButtonPress, TQPoint(), 0, 0 );
KApplication::sendEvent( m_currentMenu->activeButton, &me );
e->accept();
}
break;
}
- case Qt::Key_Enter:
- case Qt::Key_Return:
- case Qt::Key_Space: {
+ case TQt::Key_Enter:
+ case TQt::Key_Return:
+ case TQt::Key_Space: {
//simulate a mouse click
- QMouseEvent me( QEvent::MouseButtonPress, QPoint(), 0, 0 );
+ TQMouseEvent me( TQEvent::MouseButtonPress, TQPoint(), 0, 0 );
KApplication::sendEvent( m_currentMenu->activeButton, &me );
e->accept();
@@ -208,43 +208,43 @@ void KreMenu::keyPressEvent( QKeyEvent *e )
}
}
-QSize KreMenu::sizeHint() const
+TQSize KreMenu::sizeHint() const
{
return minimumSizeHint();
}
//the minimum size hint will be the minimum size hint of the largest child
-QSize KreMenu::minimumSizeHint() const
+TQSize KreMenu::minimumSizeHint() const
{
int width = 30;
- QObjectList *childElements = queryList( 0, 0, false, false ); //only first-generation children (not recursive)
- QObjectListIterator it( *childElements );
+ TQObjectList *childElements = queryList( 0, 0, false, false ); //only first-generation children (not recursive)
+ TQObjectListIterator it( *childElements );
- QObject *obj;
+ TQObject *obj;
while ( ( obj = it.current() ) != 0 ) {
++it;
if ( obj->isWidgetType() ) {
- int obj_width_hint = ( ( QWidget* ) obj ) ->minimumSizeHint().width();
+ int obj_width_hint = ( ( TQWidget* ) obj ) ->minimumSizeHint().width();
if ( obj_width_hint > width )
width = obj_width_hint;
}
}
- return QSize( width, 150 );
+ return TQSize( width, 150 );
}
-void KreMenu::paintEvent( QPaintEvent * )
+void KreMenu::paintEvent( TQPaintEvent * )
{
// Make sure the size is bigger than the minimum necessary
//if (minimumWidth() <45) setMinimumWidth(45); // FIXME: can somehow setMinimumWidth be restricted? This may not be the best place to do this
// Get gradient colors
- QColor c = colorGroup().button();
- QColor c1 = c.dark( 130 );
- QColor c2 = c.light( 120 );
+ TQColor c = colorGroup().button();
+ TQColor c1 = c.dark( 130 );
+ TQColor c2 = c.light( 120 );
// Draw the gradient
KPixmap kpm;
@@ -252,17 +252,17 @@ void KreMenu::paintEvent( QPaintEvent * )
KPixmapEffect::unbalancedGradient ( kpm, c2, c1, KPixmapEffect::HorizontalGradient, -150, -150 );
// Draw the handle
- QPainter painter( &kpm );
+ TQPainter painter( &kpm );
painter.setPen( c1 );
painter.drawLine( width() - 5, 20, width() - 5, height() - 20 );
painter.end();
//Set the border transparent using a mask
- QBitmap mask( kpm.size() );
- mask.fill( Qt::color0 );
+ TQBitmap mask( kpm.size() );
+ mask.fill( TQt::color0 );
painter.begin( &mask );
- painter.setPen( Qt::color1 );
- painter.setBrush( Qt::color1 );
+ painter.setPen( TQt::color1 );
+ painter.setBrush( TQt::color1 );
painter.drawRoundRect( 0, 0, width(), height(), ( int ) ( 2.0 / width() * height() ), 2 );
painter.end();
kpm.setMask( mask );
@@ -288,7 +288,7 @@ void KreMenu::paintEvent( QPaintEvent * )
bitBlt( this, 0, 0, &kpm );
}
-void KreMenu::resizeEvent( QResizeEvent* e )
+void KreMenu::resizeEvent( TQResizeEvent* e )
{
emit resized( ( e->size() ).width(), ( e->size() ).height() );
}
@@ -299,10 +299,10 @@ void KreMenu::showMenu( MenuId id )
// Hide the buttons in the current menu
// and show the ones in the new menu
- QObjectList * childElements = queryList();
- QObjectListIterator it( *childElements );
+ TQObjectList * childElements = queryList();
+ TQObjectListIterator it( *childElements );
- QObject *obj;
+ TQObject *obj;
while ( ( obj = it.current() ) != 0 ) {
++it;
if ( obj->inherits( "KreMenuButton" ) ) {
@@ -325,16 +325,16 @@ void KreMenu::showMenu( MenuId id )
KreMenuButton::KreMenuButton( KreMenu *parent, KrePanel _panel, MenuId id, const char *name ) :
-#if QT_VERSION >= 0x030200
- QWidget( parent, name, Qt::WNoAutoErase ),
+#if TQT_VERSION >= 0x030200
+ TQWidget( parent, name, TQt::WNoAutoErase ),
#else
- QWidget( parent, name ),
+ TQWidget( parent, name ),
#endif
panel( _panel )
{
icon = 0;
highlighted = false;
- text = QString::null;
+ text = TQString::null;
if ( id == 0 )
menuId = parent->mainMenu();
@@ -346,7 +346,7 @@ KreMenuButton::KreMenuButton( KreMenu *parent, KrePanel _panel, MenuId id, const
resize( parent->size().width(), 55 );
connect ( parent, SIGNAL( resized( int, int ) ), this, SLOT( rescale() ) );
connect( this, SIGNAL( clicked() ), this, SLOT( forwardClicks() ) );
- setCursor( QCursor( KCursor::handCursor() ) );
+ setCursor( TQCursor( KCursor::handCursor() ) );
}
@@ -355,7 +355,7 @@ KreMenuButton::~KreMenuButton()
delete icon;
}
-void KreMenuButton::setTitle( const QString &s )
+void KreMenuButton::setTitle( const TQString &s )
{
text = s;
@@ -373,7 +373,7 @@ void KreMenuButton::setTitle( const QString &s )
update();
}
-void KreMenuButton::mousePressEvent ( QMouseEvent * )
+void KreMenuButton::mousePressEvent ( TQMouseEvent * )
{
emit clicked();
}
@@ -382,31 +382,31 @@ void KreMenuButton::rescale()
{
resize( parentWidget() ->width() - 10, height() );
}
-QSize KreMenuButton::sizeHint() const
+TQSize KreMenuButton::sizeHint() const
{
if ( parentWidget() )
- return ( QSize( parentWidget() ->size().width() - 10, 40 ) );
+ return ( TQSize( parentWidget() ->size().width() - 10, 40 ) );
else
- return QSize( 100, 30 );
+ return TQSize( 100, 30 );
}
-QSize KreMenuButton::minimumSizeHint() const
+TQSize KreMenuButton::minimumSizeHint() const
{
- int text_width = QMAX( fontMetrics().width( text.section( '\n', 0, 0 ) ), fontMetrics().width( text.section( '\n', 1, 1 ) ) );
+ int text_width = TQMAX( fontMetrics().width( text.section( '\n', 0, 0 ) ), fontMetrics().width( text.section( '\n', 1, 1 ) ) );
if ( icon )
- return QSize( 40 + icon->width() + text_width, 30 );
+ return TQSize( 40 + icon->width() + text_width, 30 );
else
- return QSize( 40 + text_width, 30 );
+ return TQSize( 40 + text_width, 30 );
}
-void KreMenuButton::paintEvent( QPaintEvent * )
+void KreMenuButton::paintEvent( TQPaintEvent * )
{
if ( !isShown() )
return ;
// First draw the gradient
int darken = 130, lighten = 120;
- QColor c1, c2, c1h, c2h; //non-highlighted and highlighted versions
+ TQColor c1, c2, c1h, c2h; //non-highlighted and highlighted versions
// Set the gradient colors
@@ -422,9 +422,9 @@ void KreMenuButton::paintEvent( QPaintEvent * )
// draw the gradient now
- QPainter painter;
+ TQPainter painter;
KPixmap kpm;
- kpm.resize( ( ( QWidget * ) parent() ) ->size() ); // use parent's same size to obtain the same gradient
+ kpm.resize( ( ( TQWidget * ) parent() ) ->size() ); // use parent's same size to obtain the same gradient
if ( !highlighted ) {
@@ -469,13 +469,13 @@ void KreMenuButton::paintEvent( QPaintEvent * )
// Make sure it fits in the area
// If not, resize and reposition horizontally to be centered
- QPixmap scaledIcon = *icon;
+ TQPixmap scaledIcon = *icon;
if ( ( icon->height() > height() ) || ( icon->width() > width() / 3 ) ) // Nice effect, make sure you take less than half in width and fit in height (try making the menu very short in width)
{
- QImage image;
+ TQImage image;
image = ( *icon );
- scaledIcon.convertFromImage( image.smoothScale( width() / 3, height(), QImage::ScaleMin ) );
+ scaledIcon.convertFromImage( image.smoothScale( width() / 3, height(), TQImage::ScaleMin ) );
}
// Calculate the icon's vertical position
@@ -525,16 +525,16 @@ void KreMenuButton::paintEvent( QPaintEvent * )
painter.begin( &area );
painter.setPen( c1h );
- painter.setBrush( Qt::NoBrush );
+ painter.setBrush( TQt::NoBrush );
painter.drawRoundRect( 0, 0, areaw, areah, roundx, roundy );
painter.end();
// Make it round
- QBitmap mask( QSize( areaw, areah ) );
- mask.fill( Qt::color0 );
+ TQBitmap mask( TQSize( areaw, areah ) );
+ mask.fill( TQt::color0 );
painter.begin( &mask );
- painter.setPen( Qt::color1 );
- painter.setBrush( Qt::color1 );
+ painter.setPen( TQt::color1 );
+ painter.setBrush( TQt::color1 );
painter.drawRoundRect( 0, 0, areaw, areah, roundx, roundy );
painter.end();
area.setMask( mask );
@@ -544,7 +544,7 @@ void KreMenuButton::paintEvent( QPaintEvent * )
}
// Finally, draw the text besides the icon
- QRect r = rect();
+ TQRect r = rect();
r.setLeft( areax + 5 );
r.setWidth( areaw - 10 );
@@ -554,7 +554,7 @@ void KreMenuButton::paintEvent( QPaintEvent * )
else
painter.setPen( KGlobalSettings::textColor() );
painter.setClipRect( r );
- painter.drawText( r, Qt::AlignVCenter, text );
+ painter.drawText( r, TQt::AlignVCenter, text );
painter.end();
// Copy the offscreen button to the widget
@@ -562,11 +562,11 @@ void KreMenuButton::paintEvent( QPaintEvent * )
}
-void KreMenuButton::setIconSet( const QIconSet &is )
+void KreMenuButton::setIconSet( const TQIconSet &is )
{
delete icon;
- icon = new QPixmap( is.pixmap( QIconSet::Small, QIconSet::Normal, QIconSet::On ) );
+ icon = new TQPixmap( is.pixmap( TQIconSet::Small, TQIconSet::Normal, TQIconSet::On ) );
setMinimumWidth( minimumSizeHint().width() );
if ( parentWidget() ->minimumWidth() < minimumSizeHint().width() )
@@ -618,18 +618,18 @@ void Menu::addButton( KreMenuButton* button )
widgetNumber++;
}
-void Menu::copyMap( QMap <int, KreMenuButton*> &destMap, const QMap <int, KreMenuButton*> &origMap )
+void Menu::copyMap( TQMap <int, KreMenuButton*> &destMap, const TQMap <int, KreMenuButton*> &origMap )
{
- QMap<int, KreMenuButton*>::ConstIterator it;
+ TQMap<int, KreMenuButton*>::ConstIterator it;
destMap.clear();
for ( it = origMap.begin(); it != origMap.end(); ++it ) {
destMap[ it.key() ] = it.data();
}
}
-void Menu::copyMap( QMap <KreMenuButton*, int> &destMap, const QMap <KreMenuButton*, int> &origMap )
+void Menu::copyMap( TQMap <KreMenuButton*, int> &destMap, const TQMap <KreMenuButton*, int> &origMap )
{
- QMap<KreMenuButton*, int>::ConstIterator it;
+ TQMap<KreMenuButton*, int>::ConstIterator it;
destMap.clear();
for ( it = origMap.begin(); it != origMap.end(); ++it ) {
destMap[ it.key() ] = it.data();