Back to index

kdeartwork  4.3.2
Public Member Functions | Protected Slots | Protected Member Functions | Private Member Functions | Private Attributes
Glow::GlowClient Class Reference

#include <glowclient.h>

Collaboration diagram for Glow::GlowClient:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 GlowClient (KDecorationBridge *b, KDecorationFactory *f)
 ~GlowClient ()
virtual void init ()
virtual void borders (int &, int &, int &, int &) const
virtual void resize (const QSize &)
virtual QSize minimumSize () const

Protected Slots

void slotMaximize ()

Protected Member Functions

virtual void resizeEvent (QResizeEvent *)
virtual void paintEvent (QPaintEvent *)
virtual void showEvent (QShowEvent *)
virtual void mouseDoubleClickEvent (QMouseEvent *)
virtual void maximizeChange ()
virtual void activeChange ()
virtual void iconChange ()
virtual void desktopChange ()
virtual void shadeChange ()
virtual void captionChange ()
virtual Position mousePosition (const QPoint &) const
virtual bool eventFilter (QObject *o, QEvent *e)

Private Member Functions

void createButtons ()
void updateButtonPositions ()
void updateButtonPixmaps ()
 Before this method is called we have to update the button positions with updateButtonPositions() because the pixmaps depend on the position.
void resetLayout ()
void doShape ()
bool isLeft (GlowButton *button)
bool isRight (GlowButton *button)

Private Attributes

std::vector< GlowButton * > m_buttonList
std::vector< GlowButton * > m_leftButtonList
std::vector< GlowButton * > m_rightButtonList
GlowButtonm_stickyButton
GlowButtonm_helpButton
GlowButtonm_minimizeButton
GlowButtonm_maximizeButton
GlowButtonm_closeButton
QBoxLayout * m_leftButtonLayout
QBoxLayout * m_rightButtonLayout
QSpacerItem * _bottom_spacer
QSpacerItem * _title_spacer
QVBoxLayout * _main_layout

Detailed Description

Definition at line 156 of file glowclient.h.


Constructor & Destructor Documentation

Glow::GlowClient::GlowClient ( KDecorationBridge *  b,
KDecorationFactory *  f 
)

Definition at line 391 of file glowclient.cpp.

Definition at line 408 of file glowclient.cpp.

{
       PixmapCache::erase(QString::number(widget()->winId()));
}

Here is the call graph for this function:


Member Function Documentation

void Glow::GlowClient::activeChange ( ) [protected, virtual]

Definition at line 542 of file glowclient.cpp.

{
       updateButtonPixmaps();
       widget()->repaint(false);
}

Here is the call graph for this function:

void Glow::GlowClient::borders ( int &  left,
int &  right,
int &  top,
int &  bottom 
) const [virtual]

Definition at line 572 of file glowclient.cpp.

{
       left = right = SIDE_MARGIN;
       top = titleHeight + TITLE_MARGIN + 1;
       if (GlowClientGlobals::instance()->config()->showResizeHandle
              && isResizable())
              bottom = RESIZE_HANDLE_HEIGHT;
       else
              bottom = BOTTOM_MARGIN;
}

Here is the call graph for this function:

void Glow::GlowClient::captionChange ( ) [protected, virtual]

Definition at line 557 of file glowclient.cpp.

{
    widget()->update(_title_spacer->geometry());
}
void Glow::GlowClient::createButtons ( ) [private]

Definition at line 648 of file glowclient.cpp.

{
       GlowClientGlobals *globals = GlowClientGlobals::instance();
       GlowButtonFactory *factory = globals->buttonFactory();
       QSize size = globals->theme()->buttonSize;

       m_stickyButton = factory->createGlowButton(widget(),
                                   "StickyButton", isOnAllDesktops()?i18n("Not on all desktops"):i18n("On all desktops"), Qt::LeftButton|Qt::RightButton);
       m_stickyButton->setFixedSize(size);
       connect(m_stickyButton, SIGNAL(clicked()), this, SLOT(toggleOnAllDesktops()));
       m_buttonList.insert(m_buttonList.end(), m_stickyButton);

       m_helpButton = factory->createGlowButton(widget(),
                                   "HelpButton", i18n("Help"));
       m_helpButton->setFixedSize(size);
       connect(m_helpButton, SIGNAL(clicked()), this, SLOT(showContextHelp()));
       m_buttonList.insert(m_buttonList.end(), m_helpButton);

       m_minimizeButton = factory->createGlowButton(widget(),
                                   "IconifyButton", i18n("Minimize"));
       m_minimizeButton->setFixedSize(size);
       connect(m_minimizeButton, SIGNAL(clicked()), this, SLOT(minimize()));
       m_buttonList.insert(m_buttonList.end(), m_minimizeButton);

       m_maximizeButton=factory->createGlowButton(widget(),
                                   "MaximizeButton", i18n("Maximize"), Qt::LeftButton|Qt::MidButton|Qt::RightButton);
       m_maximizeButton->setFixedSize(size);
       connect(m_maximizeButton, SIGNAL(clicked()), this, SLOT(slotMaximize()));
       m_buttonList.insert(m_buttonList.end(), m_maximizeButton);

       m_closeButton = factory->createGlowButton(widget(),
                                   "CloseButton", i18n("Close"));
       m_closeButton->setFixedSize(size);
       connect(m_closeButton, SIGNAL(clicked()), this, SLOT(closeWindow()));
       m_buttonList.insert(m_buttonList.end(), m_closeButton);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void Glow::GlowClient::desktopChange ( ) [protected, virtual]

Definition at line 583 of file glowclient.cpp.

{
       if (isOnAllDesktops()) {
              m_stickyButton->setPixmapName(
                     GlowClientGlobals::instance()->getPixmapName(
                            GlowClientGlobals::StickyOn, isActive()));
              m_stickyButton->setTipText(i18n("Not on all desktops"));
       } else {
              m_stickyButton->setPixmapName(
                     GlowClientGlobals::instance()->getPixmapName(
                            GlowClientGlobals::StickyOff, isActive()));
              m_stickyButton->setTipText(i18n("On all desktops"));
       }
}

Here is the call graph for this function:

void Glow::GlowClient::doShape ( ) [private]

Definition at line 829 of file glowclient.cpp.

{
       QRegion mask(widget()->rect());
       // edges

       mask -= QRegion(width()-1,0,1,1);
       mask -= QRegion(0,height()-1,1,1);
       mask -= QRegion(width()-1,height()-1,1,1);
       setMask(mask);
}

Here is the caller graph for this function:

bool Glow::GlowClient::eventFilter ( QObject *  o,
QEvent *  e 
) [protected, virtual]

Definition at line 861 of file glowclient.cpp.

{
       if( o != widget())
              return false;
       switch( e->type())
       {
       case QEvent::Resize:
           resizeEvent( static_cast< QResizeEvent* >( e ));
           return true;
       case QEvent::Paint:
           paintEvent( static_cast< QPaintEvent* >( e ));
           return true;
       case QEvent::MouseButtonDblClick:
           mouseDoubleClickEvent( static_cast< QMouseEvent* >( e ));
           return true;
       case QEvent::MouseButtonPress:
           processMousePressEvent( static_cast< QMouseEvent* >( e ));
           return true;
       case QEvent::Show:
           showEvent( static_cast< QShowEvent* >( e ));
           return true;
       default:
           break;
       }
    return false;
}

Here is the call graph for this function:

void Glow::GlowClient::iconChange ( ) [protected, virtual]

Definition at line 548 of file glowclient.cpp.

{
       // we have no (t yet an) icon button, so do nothing
}
void Glow::GlowClient::init ( ) [virtual]

Definition at line 399 of file glowclient.cpp.

{
       createMainWidget(WResizeNoErase | WStaticContents | WRepaintNoErase);
       widget()->installEventFilter(this);

       createButtons();
       resetLayout();
}

Here is the call graph for this function:

bool Glow::GlowClient::isLeft ( GlowButton button) [private]

Definition at line 840 of file glowclient.cpp.

{
       for( unsigned int i=0; i<m_leftButtonList.size(); i++ )
              if( m_leftButtonList[i] == button )
                     return true;
       return false;
}
bool Glow::GlowClient::isRight ( GlowButton button) [private]

Definition at line 848 of file glowclient.cpp.

{
       for( unsigned int i=0; i<m_rightButtonList.size(); i++ )
              if( m_rightButtonList[i] == button )
                     return true;
       return false;
}
void Glow::GlowClient::maximizeChange ( ) [protected, virtual]

Definition at line 598 of file glowclient.cpp.

{
    if (maximizeMode() == MaximizeFull) {
              m_maximizeButton->setPixmapName(
                     GlowClientGlobals::instance()->getPixmapName(
                            GlowClientGlobals::MaximizeOn, isActive()));
              m_maximizeButton->setTipText(i18n("Restore"));
       } else {
              m_maximizeButton->setPixmapName(
                     GlowClientGlobals::instance()->getPixmapName(
                            GlowClientGlobals::MaximizeOff, isActive()));
              m_maximizeButton->setTipText(i18n("Maximize"));
       }
}

Here is the call graph for this function:

QSize Glow::GlowClient::minimumSize ( ) const [virtual]

Definition at line 562 of file glowclient.cpp.

{
    return widget()->minimumSize();
}
void Glow::GlowClient::mouseDoubleClickEvent ( QMouseEvent *  e) [protected, virtual]

Definition at line 536 of file glowclient.cpp.

{
       if(e->button() == Qt::LeftButton && _title_spacer->geometry().contains(e->pos()))
              titlebarDblClickOperation();
}

Here is the caller graph for this function:

KDecoration::Position Glow::GlowClient::mousePosition ( const QPoint &  pos) const [protected, virtual]

Definition at line 613 of file glowclient.cpp.

{
       Position m = PositionCenter;

       int bottomSize
              = (GlowClientGlobals::instance()->config()->showResizeHandle)
              ? RESIZE_HANDLE_HEIGHT : BOTTOM_MARGIN;

       const int range = 14 + 3*SIDE_MARGIN/2;

       if ( ( pos.x() > SIDE_MARGIN && pos.x() < width() - SIDE_MARGIN )
              && ( pos.y() > 4 && pos.y() < height() - bottomSize ) )
              m = PositionCenter;
       else if ( pos.y() <= range && pos.x() <= range)
              m = PositionTopLeft;
       else if ( pos.y() >= height()-range && pos.x() >= width()-range)
              m = PositionBottomRight;
       else if ( pos.y() >= height()-range && pos.x() <= range)
              m = PositionBottomLeft;
       else if ( pos.y() <= range && pos.x() >= width()-range)
              m = PositionTopRight;
       else if ( pos.y() <= 4 )
              m = PositionTop;
       else if ( pos.y() >= height()-bottomSize )
              m = PositionBottom;
       else if ( pos.x() <= SIDE_MARGIN )
              m = PositionLeft;
       else if ( pos.x() >= width()-SIDE_MARGIN )
              m = PositionRight;
       else
              m = PositionCenter;

       return m;
}

Here is the call graph for this function:

void Glow::GlowClient::paintEvent ( QPaintEvent *  ) [protected, virtual]

Definition at line 419 of file glowclient.cpp.

{
       GlowClientConfig *conf = GlowClientGlobals::instance()->config();
       QRect r_this = widget()->rect();
       QRect r_title = _title_spacer->geometry();
       QColorGroup titleCg = options()->colorGroup(ColorTitleBar, isActive());
       QColorGroup titleBlendCg=options()->colorGroup(ColorTitleBlend, isActive());
       QColorGroup cg = widget()->colorGroup();
       QColor titleColor = options()->color(ColorTitleBar, isActive());
       QColor titleBlendColor = options()->color(ColorTitleBlend, isActive());
       QColor bgColor = widget()->colorGroup().background();
       QPainter p;
       Q3PointArray pArray, pArray2, pArray3, pArray4;

       // pixmap for title bar
       QSize tBSize(width(), r_title.height());
       QSize gradientPixmapSize (tBSize-QSize(3,3));
       if (! gradientPixmapSize.isValid())
              gradientPixmapSize = QSize(0,0);
       KPixmap gradientPixmap(gradientPixmapSize);
       if (! gradientPixmapSize.isNull())
              KPixmapEffect::gradient(gradientPixmap, titleColor, titleBlendColor,
                     (KPixmapEffect::GradientType) conf->titlebarGradientType);

       QPixmap  * title_buffer = new QPixmap(tBSize);
       p.begin(title_buffer);
       if (! gradientPixmap.isNull())
              p.drawPixmap(2, 2, gradientPixmap);

       if (tBSize.width()>=3 && tBSize.height()>=3)
       {
              // draw caption
              p.setFont(options()->font(isActive()));
              p.setPen(options()->color(ColorFont, isActive()));
              p.drawText(r_title.x(), 0,
                     r_title.width(), r_title.height(),
                     Qt::AlignLeft | Qt::AlignVCenter | Qt::TextSingleLine, caption());
       
              // draw split color beneath buttons top right
              pArray4 = Q3PointArray(4);
              pArray4.setPoint(0, tBSize.width()-1, tBSize.height()/2-1);
              pArray4.setPoint(1, r_title.x()+r_title.width()-1+tBSize.height()/2,
                     tBSize.height()/2-1);
              pArray4.setPoint(2, r_title.x()+r_title.width()-1, tBSize.height());
              pArray4.setPoint(3, tBSize.width()-1, tBSize.height());
              p.setPen(Qt::NoPen);
              p.setBrush(bgColor);
              p.drawPolygon(pArray4);
                            
              // draw borders
              pArray = Q3PointArray(3);
              pArray.setPoint(0, tBSize.width()-1, tBSize.height()/2-1);
              pArray.setPoint(1, r_title.x()+r_title.width()-1+tBSize.height()/2,
                     tBSize.height()/2-1);
              pArray.setPoint(2, r_title.x()+r_title.width()-1, tBSize.height()-1);
              p.setPen(titleCg.mid());
              p.drawPolyline(pArray);
              p.drawLine (0, tBSize.height()-1, r_title.x()+r_title.width()-1, tBSize.height()-1);

              pArray2 = Q3PointArray(3);
              pArray2.setPoint(0, 1, tBSize.height()-2);
              pArray2.setPoint(1, 1, 1);
              pArray2.setPoint(2, tBSize.width()-2, 1);
              p.setPen(titleCg.light());
              p.drawPolyline(pArray2);
       }

       pArray3 = Q3PointArray(4);
       pArray3.setPoint(0, 0, tBSize.height()-1);
       pArray3.setPoint(1, 0, 0);
       pArray3.setPoint(2, tBSize.width()-1, 0);
       pArray3.setPoint(3, tBSize.width()-1, tBSize.height()-1);
       p.setPen(Qt::black);
       p.drawPolyline(pArray3);
       p.end();

       // insert title buffer in cache; before that, remove old buffer
       PixmapCache::erase(QString::number(widget()->winId()));
       PixmapCache::insert(QString::number(widget()->winId()), title_buffer);

       bitBlt(widget(), 0, 0, title_buffer);
       for (unsigned int i=0; i<m_buttonList.size(); ++i)
              m_buttonList[i]->repaint(false);

       p.begin(widget());
       p.setPen(Qt::black);
       //-----
       // draw borders
       p.drawLine(0,tBSize.height(),0,r_this.height()-1);
       p.drawLine(0,r_this.height()-1,r_this.width()-1,r_this.height()-1);
       p.drawLine(r_this.width()-1,r_this.height()-1,
              r_this.width()-1,tBSize.height()/2);
       //-----
       // fill content widget
       p.fillRect(1, tBSize.height(),
              r_this.width()-2, r_this.height()-tBSize.height()-1,
              options()->colorGroup(ColorFrame, isActive()).background());
       p.end();

       // paint resize handle if necessary
       if(conf->showResizeHandle && isResizable() && ! isShade()
                     && width()>=2 && height() >= RESIZE_HANDLE_HEIGHT)
       {
              p.begin(widget());
              p.setPen (Qt::black);
              p.drawLine (1, height() - RESIZE_HANDLE_HEIGHT,
                     width()-2, height() - RESIZE_HANDLE_HEIGHT);
              p.end();
       }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void Glow::GlowClient::resetLayout ( ) [private]

Definition at line 685 of file glowclient.cpp.

{
       _main_layout = new QVBoxLayout(widget(), 0, 0);
       _main_layout->setResizeMode (QLayout::FreeResize);

       // update button positions and colors
       updateButtonPositions();
       updateButtonPixmaps();

       QBoxLayout * topLayout = new QBoxLayout(_main_layout,
                     QBoxLayout::LeftToRight, 0, 0);
       topLayout->setMargin(0);
       topLayout->setSpacing(TITLE_SPACING);
       topLayout->addSpacing(SIDE_MARGIN);
       QVBoxLayout *outerLeftLayout = new QVBoxLayout(topLayout);
       outerLeftLayout->addSpacing(TITLE_MARGIN);
       outerLeftLayout->addItem(m_leftButtonLayout);
       outerLeftLayout->addSpacing(1);
       topLayout->addSpacing(SIDE_MARGIN);

       _title_spacer = new QSpacerItem(0, titleHeight + TITLE_MARGIN + 1,
              QSizePolicy::Expanding, QSizePolicy::Fixed);
       topLayout->addItem(_title_spacer);

       topLayout->addSpacing(SIDE_MARGIN);
       QVBoxLayout *outerRightLayout = new QVBoxLayout(topLayout);
       outerRightLayout->addSpacing(TITLE_MARGIN);
       outerRightLayout->addItem(m_rightButtonLayout);
       outerRightLayout->addSpacing(1);
       topLayout->addSpacing(SIDE_MARGIN);

       QBoxLayout *midLayout = new QBoxLayout(
                     _main_layout, QBoxLayout::LeftToRight, 0, 0);
       midLayout->addSpacing(SIDE_MARGIN);
       if(isPreview())
              midLayout->addWidget(
                            new QLabel( i18n( "<b><center>Glow preview</center></b>" ), widget()));
       else
              midLayout->addItem( new QSpacerItem( 0, 0 ));
       midLayout->addSpacing(SIDE_MARGIN);

       if(GlowClientGlobals::instance()->config()->showResizeHandle
              && isResizable() ) {
              _bottom_spacer = new QSpacerItem(SIDE_MARGIN*2,
                     RESIZE_HANDLE_HEIGHT, QSizePolicy::Expanding, QSizePolicy::Minimum);
       } else {
              _bottom_spacer = new QSpacerItem(SIDE_MARGIN*2,
                     BOTTOM_MARGIN, QSizePolicy::Expanding, QSizePolicy::Minimum);
       }
       _main_layout->addItem (_bottom_spacer);
       _main_layout->setStretchFactor(topLayout, 0);
       _main_layout->setStretchFactor(midLayout, 1);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void Glow::GlowClient::resize ( const QSize &  s) [virtual]

Definition at line 567 of file glowclient.cpp.

{
    widget()->resize( s );
}
void Glow::GlowClient::resizeEvent ( QResizeEvent *  ) [protected, virtual]

Definition at line 413 of file glowclient.cpp.

{
       doShape();
       widget()->repaint(false);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void Glow::GlowClient::shadeChange ( ) [protected, virtual]

Definition at line 553 of file glowclient.cpp.

{
}
void Glow::GlowClient::showEvent ( QShowEvent *  ) [protected, virtual]

Definition at line 530 of file glowclient.cpp.

{
       doShape();
       widget()->repaint(false);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void Glow::GlowClient::slotMaximize ( ) [protected, slot]

Definition at line 856 of file glowclient.cpp.

{
       maximize(m_maximizeButton->lastButton());
}

Here is the call graph for this function:

Here is the caller graph for this function:

Before this method is called we have to update the button positions with updateButtonPositions() because the pixmaps depend on the position.

Definition at line 801 of file glowclient.cpp.

{
       GlowClientGlobals *globals = GlowClientGlobals::instance();

       if ( isOnAllDesktops() ) {
              m_stickyButton->setPixmapName(globals->getPixmapName(
                     GlowClientGlobals::StickyOn, isActive()));
       } else {
              m_stickyButton->setPixmapName(globals->getPixmapName(
                     GlowClientGlobals::StickyOff, isActive()));
       }
       m_helpButton->setPixmapName(globals->getPixmapName(
              GlowClientGlobals::Help, isActive()));

       m_minimizeButton->setPixmapName(globals->getPixmapName(
              GlowClientGlobals::Iconify, isActive()));

       if ( maximizeMode() == MaximizeFull ) {
              m_maximizeButton->setPixmapName(globals->getPixmapName(
                     GlowClientGlobals::MaximizeOn, isActive()));
       } else {
              m_maximizeButton->setPixmapName(globals->getPixmapName(
                     GlowClientGlobals::MaximizeOff, isActive()));
       }
       m_closeButton->setPixmapName(globals->getPixmapName(
              GlowClientGlobals::Close, isActive()));
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 739 of file glowclient.cpp.

{
       QString buttons = options()->titleButtonsLeft() + "|"
              + options()->titleButtonsRight();
       bool leftButtons=true;

       // hide all buttons
       for( unsigned int i=0; i<m_buttonList.size(); i++ )
              m_buttonList[i]->hide();

       m_leftButtonList.clear();
       m_rightButtonList.clear();

       // reset left and right button layout
       if(m_leftButtonLayout)
              delete m_leftButtonLayout;
       m_leftButtonLayout = new QBoxLayout(0, QBoxLayout::LeftToRight, 0, 0, 0);
       m_leftButtonLayout->setMargin(0);
       m_leftButtonLayout->setSpacing(TITLE_SPACING);
       if(m_rightButtonLayout)
              delete m_rightButtonLayout;
       m_rightButtonLayout = new QBoxLayout(0, QBoxLayout::LeftToRight, 0, 0, 0);
       m_rightButtonLayout->setMargin(0);
       m_rightButtonLayout->setSpacing(TITLE_SPACING);

       for( unsigned int i=0; i<buttons.length(); i++ )
       {
              char c = buttons[i].latin1();
              GlowButton *button = 0;
              if( c=='S' ) // sticky
                     button = m_stickyButton;
              else if( c=='H' && providesContextHelp() ) // help
                     button = m_helpButton;
              else if( c=='I' && isMinimizable() ) // iconify
                     button = m_minimizeButton;
              else if( c=='A' && isMaximizable() ) // maximize
                     button = m_maximizeButton;
              else if( c=='X' && isCloseable() ) // close
                     button= m_closeButton;
              else if( c=='_' ) // spacer item
              {
                     if(leftButtons)
                            m_leftButtonLayout->addSpacing(4);
                     else
                            m_rightButtonLayout->addSpacing(4);
              }
              else if( c=='|' )
                     leftButtons = false;

              if (button) {
                     button->show(); // show visible buttons
                     if (leftButtons) {
                            m_leftButtonList.insert(m_leftButtonList.end(), button);
                            m_leftButtonLayout->addWidget(button);
                     } else {
                            m_rightButtonList.insert(m_rightButtonList.end(), button);
                            m_rightButtonLayout->addWidget(button);
                     }
              }
       }
}

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

QSpacerItem* Glow::GlowClient::_bottom_spacer [private]

Definition at line 193 of file glowclient.h.

QVBoxLayout* Glow::GlowClient::_main_layout [private]

Definition at line 195 of file glowclient.h.

QSpacerItem* Glow::GlowClient::_title_spacer [private]

Definition at line 194 of file glowclient.h.

std::vector<GlowButton*> Glow::GlowClient::m_buttonList [private]

Definition at line 183 of file glowclient.h.

Definition at line 190 of file glowclient.h.

Definition at line 187 of file glowclient.h.

QBoxLayout* Glow::GlowClient::m_leftButtonLayout [private]

Definition at line 191 of file glowclient.h.

Definition at line 184 of file glowclient.h.

Definition at line 189 of file glowclient.h.

Definition at line 188 of file glowclient.h.

Definition at line 192 of file glowclient.h.

Definition at line 185 of file glowclient.h.

Definition at line 186 of file glowclient.h.


The documentation for this class was generated from the following files: