2009-08-22 08:24:06 +00:00
|
|
|
#ifndef nitrogenclient_h
|
|
|
|
#define nitrogenclient_h
|
|
|
|
|
2009-08-24 16:14:11 +00:00
|
|
|
//////////////////////////////////////////////////////////////////////////////
|
|
|
|
// nitrogenclient.h
|
|
|
|
// -------------------
|
2009-09-09 00:55:55 +00:00
|
|
|
//
|
2009-08-24 16:14:11 +00:00
|
|
|
// Copyright (c) 2009 Hugo Pereira Da Costa <hugo.pereira@free.fr>
|
2009-08-25 04:15:13 +00:00
|
|
|
// Copyright (c) 2003, 2004 David Johnson <david@usermode.org>
|
|
|
|
// Copyright (c) 2006, 2007 Riccardo Iaconelli <ruphy@fsfe.org>
|
2009-08-24 16:14:11 +00:00
|
|
|
//
|
|
|
|
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
|
|
// of this software and associated documentation files (the "Software"), to
|
|
|
|
// deal in the Software without restriction, including without limitation the
|
|
|
|
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
|
|
|
// sell copies of the Software, and to permit persons to whom the Software is
|
|
|
|
// furnished to do so, subject to the following conditions:
|
|
|
|
//
|
|
|
|
// The above copyright notice and this permission notice shall be included in
|
|
|
|
// all copies or substantial portions of the Software.
|
|
|
|
//
|
|
|
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
|
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
|
|
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
2009-09-09 00:55:55 +00:00
|
|
|
// IN THE SOFTWARE.
|
2009-08-24 16:14:11 +00:00
|
|
|
//////////////////////////////////////////////////////////////////////////////
|
2009-08-22 08:24:06 +00:00
|
|
|
|
|
|
|
#include <kcommondecoration.h>
|
|
|
|
|
|
|
|
#include "kdeversion.h"
|
|
|
|
#include "nitrogenconfiguration.h"
|
|
|
|
#include "lib/helper.h"
|
|
|
|
#include "lib/tileset.h"
|
|
|
|
|
|
|
|
|
2009-09-09 00:55:55 +00:00
|
|
|
namespace Nitrogen
|
2009-08-22 08:24:06 +00:00
|
|
|
{
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2009-08-22 08:24:06 +00:00
|
|
|
class NitrogenSizeGrip;
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2009-08-22 08:24:06 +00:00
|
|
|
class NitrogenClient : public KCommonDecorationUnstable
|
|
|
|
{
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2009-08-22 08:24:06 +00:00
|
|
|
Q_OBJECT
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2009-09-04 18:58:40 +00:00
|
|
|
public:
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2009-09-04 18:58:40 +00:00
|
|
|
//! constructor
|
|
|
|
NitrogenClient(KDecorationBridge *b, KDecorationFactory *f);
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2009-08-22 08:24:06 +00:00
|
|
|
//! destructor
|
|
|
|
virtual ~NitrogenClient();
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2009-08-22 08:24:06 +00:00
|
|
|
virtual QString visibleName() const;
|
|
|
|
virtual KCommonDecorationButton *createButton(::ButtonType type);
|
|
|
|
virtual bool decorationBehaviour(DecorationBehaviour behaviour) const;
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2009-08-22 08:24:06 +00:00
|
|
|
//! true if window is maximized
|
|
|
|
virtual bool isMaximized( void ) const;
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2009-09-07 17:26:56 +00:00
|
|
|
//! true when separator is to be drawn
|
|
|
|
virtual bool drawSeparator( void ) const
|
|
|
|
{ return isActive() && configuration().drawSeparator() && !configuration().drawTitleOutline(); }
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2009-09-07 17:26:56 +00:00
|
|
|
//! true when oxygen 'glow' shadow is to be drawn for active window
|
|
|
|
virtual bool useOxygenShadows( void ) const
|
|
|
|
{ return isActive() && configuration().useOxygenShadows(); }
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2009-08-22 08:24:06 +00:00
|
|
|
//! dimensions
|
|
|
|
virtual int layoutMetric(LayoutMetric lm, bool respectWindowState = true, const KCommonDecorationButton * = 0) const;
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2009-08-22 08:24:06 +00:00
|
|
|
//! window shape
|
|
|
|
virtual void updateWindowShape();
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2009-08-22 08:24:06 +00:00
|
|
|
//! initialization
|
|
|
|
virtual void init();
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2009-09-10 05:13:25 +00:00
|
|
|
// reset
|
|
|
|
virtual void reset( unsigned long changed );
|
|
|
|
|
2009-08-22 08:24:06 +00:00
|
|
|
//! return associated configuration
|
|
|
|
NitrogenConfiguration configuration( void ) const;
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2009-08-22 08:24:06 +00:00
|
|
|
//! helper class
|
2009-09-04 04:22:26 +00:00
|
|
|
OxygenHelper& helper( void ) const
|
2009-08-22 08:24:06 +00:00
|
|
|
{ return helper_; }
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2009-09-09 17:00:13 +00:00
|
|
|
//! palette background
|
|
|
|
QPalette backgroundPalette( const QWidget*, QPalette ) const;
|
|
|
|
|
2009-08-22 08:24:06 +00:00
|
|
|
//! window background
|
|
|
|
virtual void renderWindowBackground( QPainter*, const QRect&, const QWidget*, const QPalette& ) const;
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2009-09-04 18:58:40 +00:00
|
|
|
//! window border
|
|
|
|
// this draws a "blue" border around active window
|
|
|
|
virtual void renderWindowBorder( QPainter*, const QRect&, const QWidget*, const QPalette& ) const;
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2009-09-04 18:58:40 +00:00
|
|
|
//! title outline
|
|
|
|
virtual void renderTitleOutline( QPainter*, const QRect&, const QPalette& ) const;
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2009-08-22 08:24:06 +00:00
|
|
|
//! triggered when window activity is changed
|
|
|
|
virtual void activeChange();
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2009-09-05 17:17:57 +00:00
|
|
|
//! triggered when maximize state changed
|
|
|
|
virtual void maximizeChange();
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2009-08-29 20:04:24 +00:00
|
|
|
//! triggered when window shade is changed
|
|
|
|
virtual void shadeChange();
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2009-08-22 08:24:06 +00:00
|
|
|
public slots:
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2009-08-22 08:24:06 +00:00
|
|
|
//! reset configuration
|
|
|
|
void resetConfiguration( void );
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2009-08-22 08:24:06 +00:00
|
|
|
protected:
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2009-08-22 08:24:06 +00:00
|
|
|
//! paint
|
|
|
|
void paintEvent( QPaintEvent* );
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2009-08-22 08:24:06 +00:00
|
|
|
//! shadows
|
2009-09-14 19:21:39 +00:00
|
|
|
TileSet *shadowTiles(const QColor& color, bool active);
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2009-09-07 06:53:13 +00:00
|
|
|
//! shadows
|
2009-09-14 19:21:39 +00:00
|
|
|
QPixmap shadowPixmap( const QColor& color, bool active ) const;
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2009-08-22 08:24:06 +00:00
|
|
|
private:
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2009-09-04 18:58:40 +00:00
|
|
|
class ShadowTilesOption {
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2009-09-04 18:58:40 +00:00
|
|
|
public:
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2009-09-04 18:58:40 +00:00
|
|
|
//! constructor
|
|
|
|
ShadowTilesOption( void ):
|
|
|
|
width(0),
|
|
|
|
active(false)
|
|
|
|
{}
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2009-09-04 18:58:40 +00:00
|
|
|
//! equal to operator
|
|
|
|
bool operator == ( const ShadowTilesOption& other ) const
|
|
|
|
{
|
2009-09-09 00:55:55 +00:00
|
|
|
return
|
2009-09-04 18:58:40 +00:00
|
|
|
windowColor == other.windowColor &&
|
2009-09-14 19:21:39 +00:00
|
|
|
innerColor == other.innerColor &&
|
2009-09-04 18:58:40 +00:00
|
|
|
width == other.width &&
|
|
|
|
active == other.active;
|
|
|
|
}
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2009-09-04 18:58:40 +00:00
|
|
|
QColor windowColor;
|
2009-09-14 19:21:39 +00:00
|
|
|
QColor innerColor;
|
2009-09-04 18:58:40 +00:00
|
|
|
qreal width;
|
|
|
|
bool active;
|
2009-08-22 08:24:06 +00:00
|
|
|
};
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2009-08-22 08:24:06 +00:00
|
|
|
//! calculate mask
|
|
|
|
QRegion calcMask( void ) const;
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2009-08-22 08:24:06 +00:00
|
|
|
//! text color
|
|
|
|
QColor titlebarTextColor(const QPalette&);
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2009-08-22 08:24:06 +00:00
|
|
|
//!@name size grip
|
|
|
|
//@{
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2009-08-22 08:24:06 +00:00
|
|
|
//! create size grip
|
|
|
|
void createSizeGrip( void );
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2009-08-22 08:24:06 +00:00
|
|
|
//! delete size grip
|
|
|
|
void deleteSizeGrip( void );
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2009-08-22 08:24:06 +00:00
|
|
|
// size grip
|
|
|
|
bool hasSizeGrip( void ) const
|
|
|
|
{ return (bool)size_grip_; }
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2009-08-22 08:24:06 +00:00
|
|
|
//! size grip
|
|
|
|
NitrogenSizeGrip& sizeGrip( void ) const
|
|
|
|
{ return *size_grip_; }
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2009-08-22 08:24:06 +00:00
|
|
|
//@}
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2009-08-22 08:24:06 +00:00
|
|
|
//! configuration
|
|
|
|
NitrogenConfiguration configuration_;
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2009-08-22 08:24:06 +00:00
|
|
|
//! used to invalidate color cache
|
|
|
|
bool colorCacheInvalid_;
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2009-08-22 08:24:06 +00:00
|
|
|
//! stored color
|
|
|
|
QColor cachedTitlebarTextColor_;
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2009-08-22 08:24:06 +00:00
|
|
|
//! size grip widget
|
|
|
|
NitrogenSizeGrip* size_grip_;
|
|
|
|
|
2009-09-14 19:21:39 +00:00
|
|
|
ShadowTilesOption inactiveShadowTilesOption_;
|
|
|
|
ShadowTilesOption activeShadowTilesOption_;
|
|
|
|
TileSet *inactiveShadowTiles_;
|
|
|
|
TileSet *activeShadowTiles_;
|
2009-08-22 08:24:06 +00:00
|
|
|
|
|
|
|
//! helper
|
2009-09-09 00:55:55 +00:00
|
|
|
OxygenHelper& helper_;
|
|
|
|
|
2009-08-22 08:24:06 +00:00
|
|
|
//! true when initialized
|
|
|
|
bool initialized_;
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2009-08-22 08:24:06 +00:00
|
|
|
};
|
2009-09-09 00:55:55 +00:00
|
|
|
|
|
|
|
|
2009-08-22 08:24:06 +00:00
|
|
|
} // namespace Nitrogen
|
|
|
|
|
|
|
|
#endif // EXAMPLECLIENT_H
|