You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
572 lines
16 KiB
572 lines
16 KiB
15 years ago
|
/* This file is part of the KDE libraries
|
||
|
Copyright (C) 1997, 1998, 1999, 2000 Sven Radej (radej@kde.org)
|
||
|
Copyright (C) 1997, 1998, 1999, 2000 Matthias Ettrich (ettrich@kde.org)
|
||
|
Copyright (C) 1999, 2000 Daniel "Mosfet" Duley (mosfet@kde.org)
|
||
|
|
||
|
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 INCLUDE_MENUITEM_DEF
|
||
|
#define INCLUDE_MENUITEM_DEF
|
||
|
#endif
|
||
|
|
||
|
#include "config.h"
|
||
15 years ago
|
#include <tqevent.h>
|
||
|
#include <tqobjectlist.h>
|
||
|
#include <tqaccel.h>
|
||
|
#include <tqpainter.h>
|
||
|
#include <tqstyle.h>
|
||
|
#include <tqtimer.h>
|
||
15 years ago
|
|
||
12 years ago
|
#include <tdeconfig.h>
|
||
12 years ago
|
#include <tdeglobalsettings.h>
|
||
|
#include <tdemenubar.h>
|
||
12 years ago
|
#include <tdeapplication.h>
|
||
12 years ago
|
#include <tdeglobal.h>
|
||
15 years ago
|
#include <kdebug.h>
|
||
|
#include <kmanagerselection.h>
|
||
|
|
||
|
#ifdef Q_WS_X11
|
||
13 years ago
|
#include <twin.h>
|
||
|
#include <twinmodule.h>
|
||
15 years ago
|
#include <qxembed.h>
|
||
|
|
||
|
#include <X11/Xlib.h>
|
||
|
#include <X11/Xutil.h>
|
||
|
#include <X11/Xatom.h>
|
||
14 years ago
|
|
||
|
#ifndef None
|
||
|
#define None 0L
|
||
|
#endif
|
||
15 years ago
|
#endif
|
||
|
|
||
|
/*
|
||
|
|
||
|
Toplevel menubar (not for the fallback size handling done by itself):
|
||
|
- should not alter position or set strut
|
||
|
- every toplevel must have at most one matching topmenu
|
||
|
- embedder won't allow shrinking below a certain size
|
||
|
- must have WM_TRANSIENT_FOR pointing the its mainwindow
|
||
|
- the exception is desktop's menubar, which can be transient for root window
|
||
|
because of using root window as the desktop window
|
||
|
- Fitts' Law
|
||
|
|
||
|
*/
|
||
|
|
||
|
class KMenuBar::KMenuBarPrivate
|
||
|
{
|
||
|
public:
|
||
|
KMenuBarPrivate()
|
||
|
: forcedTopLevel( false ),
|
||
|
topLevel( false ),
|
||
|
wasTopLevel( false ),
|
||
|
#ifdef Q_WS_X11
|
||
|
selection( NULL ),
|
||
|
#endif
|
||
|
min_size( 0, 0 )
|
||
|
{
|
||
|
}
|
||
|
~KMenuBarPrivate()
|
||
|
{
|
||
|
#ifdef Q_WS_X11
|
||
|
delete selection;
|
||
|
#endif
|
||
|
}
|
||
|
bool forcedTopLevel;
|
||
|
bool topLevel;
|
||
|
bool wasTopLevel; // when TLW is fullscreen, remember state
|
||
|
int frameStyle; // only valid in toplevel mode
|
||
|
int lineWidth; // dtto
|
||
|
int margin; // dtto
|
||
|
bool fallback_mode; // dtto
|
||
|
#ifdef Q_WS_X11
|
||
12 years ago
|
TDESelectionWatcher* selection;
|
||
15 years ago
|
#endif
|
||
15 years ago
|
TQTimer selection_timer;
|
||
|
TQSize min_size;
|
||
15 years ago
|
static Atom makeSelectionAtom();
|
||
|
};
|
||
|
|
||
|
#ifdef Q_WS_X11
|
||
|
static Atom selection_atom = None;
|
||
|
static Atom msg_type_atom = None;
|
||
|
|
||
|
static
|
||
|
void initAtoms()
|
||
|
{
|
||
|
char nm[ 100 ];
|
||
13 years ago
|
sprintf( nm, "_KDE_TOPMENU_OWNER_S%d", DefaultScreen( tqt_xdisplay()));
|
||
15 years ago
|
char nm2[] = "_KDE_TOPMENU_MINSIZE";
|
||
|
char* names[ 2 ] = { nm, nm2 };
|
||
|
Atom atoms[ 2 ];
|
||
13 years ago
|
XInternAtoms( tqt_xdisplay(), names, 2, False, atoms );
|
||
15 years ago
|
selection_atom = atoms[ 0 ];
|
||
|
msg_type_atom = atoms[ 1 ];
|
||
|
}
|
||
|
#endif
|
||
|
|
||
|
Atom KMenuBar::KMenuBarPrivate::makeSelectionAtom()
|
||
|
{
|
||
|
#ifdef Q_WS_X11
|
||
|
if( selection_atom == None )
|
||
|
initAtoms();
|
||
|
return selection_atom;
|
||
|
#else
|
||
|
return 0;
|
||
|
#endif
|
||
|
}
|
||
|
|
||
15 years ago
|
KMenuBar::KMenuBar(TQWidget *parent, const char *name)
|
||
|
: TQMenuBar(parent, name)
|
||
15 years ago
|
{
|
||
|
#ifdef Q_WS_X11
|
||
|
QXEmbed::initialize();
|
||
|
#endif
|
||
|
d = new KMenuBarPrivate;
|
||
15 years ago
|
connect( &d->selection_timer, TQT_SIGNAL( timeout()),
|
||
|
this, TQT_SLOT( selectionTimeout()));
|
||
15 years ago
|
|
||
14 years ago
|
connect( tqApp->desktop(), TQT_SIGNAL( resized( int )), TQT_SLOT( updateFallbackSize()));
|
||
15 years ago
|
|
||
|
if ( kapp )
|
||
|
// toolbarAppearanceChanged(int) is sent when changing macstyle
|
||
15 years ago
|
connect( kapp, TQT_SIGNAL(toolbarAppearanceChanged(int)),
|
||
|
this, TQT_SLOT(slotReadConfig()));
|
||
15 years ago
|
|
||
|
slotReadConfig();
|
||
|
}
|
||
|
|
||
|
KMenuBar::~KMenuBar()
|
||
|
{
|
||
|
delete d;
|
||
|
}
|
||
|
|
||
|
void KMenuBar::setTopLevelMenu(bool top_level)
|
||
|
{
|
||
|
d->forcedTopLevel = top_level;
|
||
|
setTopLevelMenuInternal( top_level );
|
||
|
}
|
||
|
|
||
|
void KMenuBar::setTopLevelMenuInternal(bool top_level)
|
||
|
{
|
||
|
if (d->forcedTopLevel)
|
||
|
top_level = true;
|
||
|
|
||
|
d->wasTopLevel = top_level;
|
||
14 years ago
|
if( parentWidget()
|
||
13 years ago
|
&& parentWidget()->topLevelWidget()->isFullScreen())
|
||
15 years ago
|
top_level = false;
|
||
|
|
||
|
if ( isTopLevelMenu() == top_level )
|
||
|
return;
|
||
|
d->topLevel = top_level;
|
||
|
if ( isTopLevelMenu() )
|
||
|
{
|
||
|
#ifdef Q_WS_X11
|
||
12 years ago
|
d->selection = new TDESelectionWatcher( KMenuBarPrivate::makeSelectionAtom(),
|
||
13 years ago
|
DefaultScreen( tqt_xdisplay()));
|
||
15 years ago
|
connect( d->selection, TQT_SIGNAL( newOwner( Window )),
|
||
|
this, TQT_SLOT( updateFallbackSize()));
|
||
|
connect( d->selection, TQT_SIGNAL( lostOwner()),
|
||
|
this, TQT_SLOT( updateFallbackSize()));
|
||
15 years ago
|
#endif
|
||
|
d->frameStyle = frameStyle();
|
||
|
d->lineWidth = lineWidth();
|
||
|
d->margin = margin();
|
||
|
d->fallback_mode = false;
|
||
|
bool wasShown = !isHidden();
|
||
14 years ago
|
reparent( parentWidget(), (WFlags)(WType_TopLevel | WStyle_Tool | WStyle_Customize | WStyle_NoBorder), TQPoint(0,0), false );
|
||
15 years ago
|
#ifdef Q_WS_X11
|
||
|
KWin::setType( winId(), NET::TopMenu );
|
||
14 years ago
|
if( parentWidget())
|
||
13 years ago
|
XSetTransientForHint( tqt_xdisplay(), winId(), parentWidget()->topLevelWidget()->winId());
|
||
15 years ago
|
#endif
|
||
15 years ago
|
TQMenuBar::setFrameStyle( NoFrame );
|
||
|
TQMenuBar::setLineWidth( 0 );
|
||
|
TQMenuBar::setMargin( 0 );
|
||
15 years ago
|
updateFallbackSize();
|
||
15 years ago
|
d->min_size = TQSize( 0, 0 );
|
||
14 years ago
|
if( parentWidget() && !parentWidget()->isTopLevel())
|
||
|
setShown( parentWidget()->isVisible());
|
||
15 years ago
|
else if ( wasShown )
|
||
|
show();
|
||
|
} else
|
||
|
{
|
||
|
#ifdef Q_WS_X11
|
||
|
delete d->selection;
|
||
|
d->selection = NULL;
|
||
|
#endif
|
||
|
setBackgroundMode( PaletteButton );
|
||
|
setFrameStyle( d->frameStyle );
|
||
|
setLineWidth( d->lineWidth );
|
||
|
setMargin( d->margin );
|
||
|
setMinimumSize( 0, 0 );
|
||
13 years ago
|
setMaximumSize( TQWIDGETSIZE_MAX, TQWIDGETSIZE_MAX );
|
||
15 years ago
|
updateMenuBarSize();
|
||
14 years ago
|
if ( parentWidget() )
|
||
|
reparent( parentWidget(), TQPoint(0,0), !isHidden());
|
||
15 years ago
|
}
|
||
|
}
|
||
|
|
||
|
bool KMenuBar::isTopLevelMenu() const
|
||
|
{
|
||
|
return d->topLevel;
|
||
|
}
|
||
|
|
||
|
// KDE4 remove
|
||
|
void KMenuBar::show()
|
||
|
{
|
||
15 years ago
|
TQMenuBar::show();
|
||
15 years ago
|
}
|
||
|
|
||
|
void KMenuBar::slotReadConfig()
|
||
|
{
|
||
12 years ago
|
TDEConfig *config = TDEGlobal::config();
|
||
|
TDEConfigGroupSaver saver( config, "KDE" );
|
||
15 years ago
|
setTopLevelMenuInternal( config->readBoolEntry( "macStyle", false ) );
|
||
|
}
|
||
|
|
||
15 years ago
|
bool KMenuBar::eventFilter(TQObject *obj, TQEvent *ev)
|
||
15 years ago
|
{
|
||
|
if ( d->topLevel )
|
||
|
{
|
||
13 years ago
|
if ( parentWidget() && TQT_BASE_OBJECT(obj) == TQT_BASE_OBJECT(parentWidget()->topLevelWidget()) )
|
||
15 years ago
|
{
|
||
15 years ago
|
if( ev->type() == TQEvent::Resize )
|
||
|
return false; // ignore resizing of parent, TQMenuBar would try to adjust size
|
||
|
if ( ev->type() == TQEvent::Accel || ev->type() == TQEvent::AccelAvailable )
|
||
15 years ago
|
{
|
||
13 years ago
|
if ( TQApplication::sendEvent( topLevelWidget(), ev ) )
|
||
15 years ago
|
return true;
|
||
|
}
|
||
15 years ago
|
if(ev->type() == TQEvent::ShowFullScreen )
|
||
15 years ago
|
// will update the state properly
|
||
|
setTopLevelMenuInternal( d->topLevel );
|
||
|
}
|
||
14 years ago
|
if( parentWidget() && TQT_BASE_OBJECT(obj) == TQT_BASE_OBJECT(parentWidget()) && ev->type() == TQEvent::Reparent )
|
||
15 years ago
|
{
|
||
|
#ifdef Q_WS_X11
|
||
13 years ago
|
XSetTransientForHint( tqt_xdisplay(), winId(), parentWidget()->topLevelWidget()->winId());
|
||
15 years ago
|
#else
|
||
|
//TODO: WIN32?
|
||
|
#endif
|
||
14 years ago
|
setShown( parentWidget()->isTopLevel() || parentWidget()->isVisible());
|
||
15 years ago
|
}
|
||
14 years ago
|
if( parentWidget() && !parentWidget()->isTopLevel() && TQT_BASE_OBJECT(obj) == TQT_BASE_OBJECT(parentWidget()))
|
||
15 years ago
|
{ // if the parent is not toplevel, KMenuBar needs to match its visibility status
|
||
15 years ago
|
if( ev->type() == TQEvent::Show )
|
||
15 years ago
|
{
|
||
|
#ifdef Q_WS_X11
|
||
13 years ago
|
XSetTransientForHint( tqt_xdisplay(), winId(), parentWidget()->topLevelWidget()->winId());
|
||
15 years ago
|
#else
|
||
|
//TODO: WIN32?
|
||
|
#endif
|
||
|
show();
|
||
|
}
|
||
15 years ago
|
if( ev->type() == TQEvent::Hide )
|
||
15 years ago
|
hide();
|
||
|
}
|
||
|
}
|
||
|
else
|
||
|
{
|
||
13 years ago
|
if( parentWidget() && TQT_BASE_OBJECT(obj) == TQT_BASE_OBJECT(parentWidget()->topLevelWidget()))
|
||
15 years ago
|
{
|
||
15 years ago
|
if( ev->type() == TQEvent::WindowStateChange
|
||
13 years ago
|
&& !parentWidget()->topLevelWidget()->isFullScreen() )
|
||
15 years ago
|
setTopLevelMenuInternal( d->wasTopLevel );
|
||
|
}
|
||
|
}
|
||
15 years ago
|
return TQMenuBar::eventFilter( obj, ev );
|
||
15 years ago
|
}
|
||
|
|
||
|
// KDE4 remove
|
||
15 years ago
|
void KMenuBar::showEvent( TQShowEvent *e )
|
||
15 years ago
|
{
|
||
15 years ago
|
TQMenuBar::showEvent(e);
|
||
15 years ago
|
}
|
||
|
|
||
|
void KMenuBar::updateFallbackSize()
|
||
|
{
|
||
|
if( !d->topLevel )
|
||
|
return;
|
||
|
#ifdef Q_WS_X11
|
||
|
if( d->selection->owner() != None )
|
||
|
#endif
|
||
|
{ // somebody is managing us, don't mess anything, undo changes
|
||
|
// done in fallback mode if needed
|
||
|
d->selection_timer.stop();
|
||
|
if( d->fallback_mode )
|
||
|
{
|
||
|
d->fallback_mode = false;
|
||
|
KWin::setStrut( winId(), 0, 0, 0, 0 );
|
||
|
setMinimumSize( 0, 0 );
|
||
13 years ago
|
setMaximumSize( TQWIDGETSIZE_MAX, TQWIDGETSIZE_MAX );
|
||
15 years ago
|
updateMenuBarSize();
|
||
|
}
|
||
|
return;
|
||
|
}
|
||
|
if( d->selection_timer.isActive())
|
||
|
return;
|
||
|
d->selection_timer.start( 100, true );
|
||
|
}
|
||
|
|
||
|
void KMenuBar::selectionTimeout()
|
||
|
{ // nobody is managing us, handle resizing
|
||
|
if ( d->topLevel )
|
||
|
{
|
||
|
d->fallback_mode = true; // KMenuBar is handling its position itself
|
||
12 years ago
|
TDEConfigGroup xineramaConfig(TDEGlobal::config(),"Xinerama");
|
||
15 years ago
|
int screen = xineramaConfig.readNumEntry("MenubarScreen",
|
||
15 years ago
|
TQApplication::desktop()->screenNumber(TQPoint(0,0)) );
|
||
|
TQRect area;
|
||
15 years ago
|
if (kapp->desktop()->numScreens() < 2)
|
||
14 years ago
|
area = kapp->desktop()->geometry();
|
||
15 years ago
|
else
|
||
|
area = kapp->desktop()->screenGeometry(screen);
|
||
15 years ago
|
int margin = 0;
|
||
|
move(area.left() - margin, area.top() - margin);
|
||
|
setFixedSize(area.width() + 2* margin , heightForWidth( area.width() + 2 * margin ) );
|
||
|
#ifdef Q_WS_X11
|
||
|
int strut_height = height() - margin;
|
||
|
if( strut_height < 0 )
|
||
|
strut_height = 0;
|
||
|
KWin::setStrut( winId(), 0, 0, strut_height, 0 );
|
||
|
#endif
|
||
|
}
|
||
|
}
|
||
|
|
||
|
int KMenuBar::block_resize = 0;
|
||
|
|
||
15 years ago
|
void KMenuBar::resizeEvent( TQResizeEvent *e )
|
||
15 years ago
|
{
|
||
|
if( e->spontaneous() && d->topLevel && !d->fallback_mode )
|
||
|
{
|
||
|
++block_resize; // do not respond with configure request to ConfigureNotify event
|
||
15 years ago
|
TQMenuBar::resizeEvent(e); // to avoid possible infinite loop
|
||
15 years ago
|
--block_resize;
|
||
|
}
|
||
|
else
|
||
15 years ago
|
TQMenuBar::resizeEvent(e);
|
||
15 years ago
|
}
|
||
|
|
||
15 years ago
|
void KMenuBar::setGeometry( const TQRect& r )
|
||
15 years ago
|
{
|
||
|
setGeometry( r.x(), r.y(), r.width(), r.height() );
|
||
|
}
|
||
|
|
||
|
void KMenuBar::setGeometry( int x, int y, int w, int h )
|
||
|
{
|
||
|
if( block_resize > 0 )
|
||
|
{
|
||
|
move( x, y );
|
||
|
return;
|
||
|
}
|
||
|
checkSize( w, h );
|
||
14 years ago
|
if( geometry() != TQRect( x, y, w, h ))
|
||
15 years ago
|
TQMenuBar::setGeometry( x, y, w, h );
|
||
15 years ago
|
}
|
||
|
|
||
|
void KMenuBar::resize( int w, int h )
|
||
|
{
|
||
|
if( block_resize > 0 )
|
||
|
return;
|
||
|
checkSize( w, h );
|
||
15 years ago
|
if( size() != TQSize( w, h ))
|
||
|
TQMenuBar::resize( w, h );
|
||
15 years ago
|
// kdDebug() << "RS:" << w << ":" << h << ":" << width() << ":" << height() << ":" << minimumWidth() << ":" << minimumHeight() << endl;
|
||
|
}
|
||
|
|
||
|
void KMenuBar::checkSize( int& w, int& h )
|
||
|
{
|
||
|
if( !d->topLevel || d->fallback_mode )
|
||
|
return;
|
||
13 years ago
|
TQSize s = sizeHint();
|
||
15 years ago
|
w = s.width();
|
||
|
h = s.height();
|
||
|
// This is not done as setMinimumSize(), because that would set the minimum
|
||
|
// size in WM_NORMAL_HINTS, and KWin would not allow changing to smaller size
|
||
|
// anymore
|
||
|
w = KMAX( w, d->min_size.width());
|
||
|
h = KMAX( h, d->min_size.height());
|
||
|
}
|
||
|
|
||
13 years ago
|
// QMenuBar's sizeHint() gives wrong size (insufficient width), which causes wrapping in the kicker applet
|
||
|
TQSize KMenuBar::sizeHint() const
|
||
15 years ago
|
{
|
||
|
if( !d->topLevel || block_resize > 0 )
|
||
13 years ago
|
return TQMenuBar::sizeHint();
|
||
|
// Since TQMenuBar::sizeHint() may indirectly call resize(),
|
||
15 years ago
|
// avoid infinite recursion.
|
||
|
++block_resize;
|
||
14 years ago
|
// find the minimum useful height, and enlarge the width until the menu fits in that height (one row)
|
||
15 years ago
|
int h = heightForWidth( 1000000 );
|
||
13 years ago
|
int w = TQMenuBar::sizeHint().width();
|
||
15 years ago
|
// optimization - don't call heightForWidth() too many times
|
||
|
while( heightForWidth( w + 12 ) > h )
|
||
|
w += 12;
|
||
|
while( heightForWidth( w + 4 ) > h )
|
||
|
w += 4;
|
||
|
while( heightForWidth( w ) > h )
|
||
|
++w;
|
||
|
--block_resize;
|
||
15 years ago
|
return TQSize( w, h );
|
||
15 years ago
|
}
|
||
|
|
||
|
#ifdef Q_WS_X11
|
||
|
bool KMenuBar::x11Event( XEvent* ev )
|
||
|
{
|
||
|
if( ev->type == ClientMessage && ev->xclient.message_type == msg_type_atom
|
||
|
&& ev->xclient.window == winId())
|
||
|
{
|
||
15 years ago
|
// TQMenuBar is trying really hard to keep the size it deems right.
|
||
15 years ago
|
// Forcing minimum size and blocking resizing to match parent size
|
||
|
// in checkResizingToParent() seem to be the only way to make
|
||
|
// KMenuBar keep the size it wants
|
||
15 years ago
|
d->min_size = TQSize( ev->xclient.data.l[ 1 ], ev->xclient.data.l[ 2 ] );
|
||
15 years ago
|
// kdDebug() << "MINSIZE:" << d->min_size << endl;
|
||
|
updateMenuBarSize();
|
||
|
return true;
|
||
|
}
|
||
15 years ago
|
return TQMenuBar::x11Event( ev );
|
||
15 years ago
|
}
|
||
|
#endif
|
||
|
|
||
|
void KMenuBar::updateMenuBarSize()
|
||
|
{
|
||
|
menuContentsChanged(); // trigger invalidating calculated size
|
||
13 years ago
|
resize( sizeHint()); // and resize to preferred size
|
||
15 years ago
|
}
|
||
|
|
||
|
void KMenuBar::setFrameStyle( int style )
|
||
|
{
|
||
|
if( d->topLevel )
|
||
|
d->frameStyle = style;
|
||
|
else
|
||
15 years ago
|
TQMenuBar::setFrameStyle( style );
|
||
15 years ago
|
}
|
||
|
|
||
|
void KMenuBar::setLineWidth( int width )
|
||
|
{
|
||
|
if( d->topLevel )
|
||
|
d->lineWidth = width;
|
||
|
else
|
||
15 years ago
|
TQMenuBar::setLineWidth( width );
|
||
15 years ago
|
}
|
||
|
|
||
|
void KMenuBar::setMargin( int margin )
|
||
|
{
|
||
|
if( d->topLevel )
|
||
|
d->margin = margin;
|
||
|
else
|
||
15 years ago
|
TQMenuBar::setMargin( margin );
|
||
15 years ago
|
}
|
||
|
|
||
15 years ago
|
void KMenuBar::closeEvent( TQCloseEvent* e )
|
||
15 years ago
|
{
|
||
|
if( d->topLevel )
|
||
|
e->ignore(); // mainly for the fallback mode
|
||
|
else
|
||
15 years ago
|
TQMenuBar::closeEvent( e );
|
||
15 years ago
|
}
|
||
|
|
||
15 years ago
|
void KMenuBar::drawContents( TQPainter* p )
|
||
15 years ago
|
{
|
||
|
// Closes the BR77113
|
||
|
// We need to overload this method to paint only the menu items
|
||
|
// This way when the KMenuBar is embedded in the menu applet it
|
||
|
// integrates correctly.
|
||
|
//
|
||
|
// Background mode and origin are set so late because of styles
|
||
|
// using the polish() method to modify these settings.
|
||
|
//
|
||
|
// Of course this hack can safely be removed when real transparency
|
||
|
// will be available
|
||
|
|
||
|
if( !d->topLevel )
|
||
|
{
|
||
15 years ago
|
TQMenuBar::drawContents(p);
|
||
15 years ago
|
}
|
||
|
else
|
||
|
{
|
||
|
bool up_enabled = isUpdatesEnabled();
|
||
|
BackgroundMode bg_mode = backgroundMode();
|
||
|
BackgroundOrigin bg_origin = backgroundOrigin();
|
||
|
|
||
13 years ago
|
setUpdatesEnabled(false);
|
||
15 years ago
|
setBackgroundMode(X11ParentRelative);
|
||
|
setBackgroundOrigin(WindowOrigin);
|
||
|
|
||
|
p->eraseRect( rect() );
|
||
|
erase();
|
||
|
|
||
13 years ago
|
TQColorGroup g = colorGroup();
|
||
15 years ago
|
bool e;
|
||
|
|
||
|
for ( int i=0; i<(int)count(); i++ )
|
||
|
{
|
||
13 years ago
|
TQMenuItem *mi = findItem( idAt( i ) );
|
||
15 years ago
|
|
||
|
if ( !mi->text().isNull() || mi->pixmap() )
|
||
|
{
|
||
13 years ago
|
TQRect r = itemRect(i);
|
||
15 years ago
|
if(r.isEmpty() || !mi->isVisible())
|
||
|
continue;
|
||
|
|
||
|
e = mi->isEnabledAndVisible();
|
||
|
if ( e )
|
||
13 years ago
|
g = isEnabled() ? ( isActiveWindow() ? palette().active() :
|
||
|
palette().inactive() ) : palette().disabled();
|
||
15 years ago
|
else
|
||
13 years ago
|
g = palette().disabled();
|
||
15 years ago
|
|
||
|
bool item_active = ( actItem == i );
|
||
|
|
||
|
p->setClipRect(r);
|
||
|
|
||
|
if( item_active )
|
||
|
{
|
||
15 years ago
|
TQStyle::SFlags flags = TQStyle::Style_Default;
|
||
15 years ago
|
if (isEnabled() && e)
|
||
15 years ago
|
flags |= TQStyle::Style_Enabled;
|
||
15 years ago
|
if ( item_active )
|
||
15 years ago
|
flags |= TQStyle::Style_Active;
|
||
15 years ago
|
if ( item_active && actItemDown )
|
||
15 years ago
|
flags |= TQStyle::Style_Down;
|
||
|
flags |= TQStyle::Style_HasFocus;
|
||
15 years ago
|
|
||
13 years ago
|
style().drawControl(TQStyle::CE_MenuBarItem, p, this,
|
||
15 years ago
|
r, g, flags, TQStyleOption(mi));
|
||
15 years ago
|
}
|
||
|
else
|
||
|
{
|
||
13 years ago
|
style().drawItem(p, r, AlignCenter | AlignVCenter | ShowPrefix,
|
||
15 years ago
|
g, e, mi->pixmap(), mi->text());
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
setBackgroundOrigin(bg_origin);
|
||
|
setBackgroundMode(bg_mode);
|
||
13 years ago
|
setUpdatesEnabled(up_enabled);
|
||
15 years ago
|
}
|
||
|
}
|
||
|
|
||
|
void KMenuBar::virtual_hook( int, void* )
|
||
|
{ /*BASE::virtual_hook( id, data );*/ }
|
||
|
|
||
12 years ago
|
#include "tdemenubar.moc"
|