Back to index

kdeartwork  4.3.2
Public Member Functions | Protected Slots | Protected Member Functions | Private Types | Private Member Functions | Private Attributes
KStep::NextClient Class Reference

#include <nextclient.h>

Collaboration diagram for KStep::NextClient:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 NextClient (KDecorationBridge *b, KDecorationFactory *f)
 ~NextClient ()
void init ()
virtual bool drawbound (const QRect &geom, bool clear)

Protected Slots

void slotReset ()
void menuButtonPressed ()
void maximizeButtonClicked ()
void shadeClicked ()
void aboveClicked ()
void belowClicked ()
void resizePressed ()
void keepAboveChange (bool above)
void keepBelowChange (bool below)

Protected Member Functions

bool eventFilter (QObject *o, QEvent *e)
void resizeEvent (QResizeEvent *)
void paintEvent (QPaintEvent *)
void showEvent (QShowEvent *)
void mouseDoubleClickEvent (QMouseEvent *)
void captionChange ()
void desktopChange ()
void activeChange ()
void shadeChange ()
void iconChange ()
QSize minimumSize () const
void resize (const QSize &size)
void borders (int &left, int &right, int &top, int &bottom) const
void reset (unsigned long changed)
void calcHiddenButtons ()
void updateActiveBuffer ()
Position mousePosition (const QPoint &) const
void maximizeChange ()

Private Types

enum  {
  CLOSE_IDX = 0, HELP_IDX, ICONIFY_IDX, MAXIMIZE_IDX,
  MENU_IDX, SHADE_IDX, ABOVE_IDX, BELOW_IDX,
  RESIZE_IDX, STICKY_IDX, MAX_NUM_BUTTONS = STICKY_IDX + 1
}

Private Member Functions

void initializeButtonsAndTitlebar (QBoxLayout *titleLayout)
 Preconditions:
void addButtons (QBoxLayout *titleLayout, const QString &buttons)
 Adds the buttons for one side of the title bar, based on the spec string; see the KWin::KDecoration class, methods titleButtonsLeft and titleBUttonsRight.
bool mustDrawHandle () const

Private Attributes

QSpacerItem * titlebar
NextButtonbutton [MAX_NUM_BUTTONS]

Detailed Description

Definition at line 68 of file nextclient.h.


Member Enumeration Documentation

anonymous enum [private]
Enumerator:
CLOSE_IDX 
HELP_IDX 
ICONIFY_IDX 
MAXIMIZE_IDX 
MENU_IDX 
SHADE_IDX 
ABOVE_IDX 
BELOW_IDX 
RESIZE_IDX 
STICKY_IDX 
MAX_NUM_BUTTONS 

Definition at line 118 of file nextclient.h.


Constructor & Destructor Documentation

KStep::NextClient::NextClient ( KDecorationBridge *  b,
KDecorationFactory *  f 
)

Definition at line 437 of file nextclient.cpp.

    : KDecoration(b, f)
{
}

Definition at line 73 of file nextclient.h.

{;}

Member Function Documentation

void KStep::NextClient::aboveClicked ( ) [protected, slot]

Definition at line 685 of file nextclient.cpp.

{
    setKeepAbove(!keepAbove());
}

Here is the caller graph for this function:

void KStep::NextClient::activeChange ( ) [protected]

Definition at line 824 of file nextclient.cpp.

{
    widget()->repaint();
    slotReset();
}

Here is the call graph for this function:

void KStep::NextClient::addButtons ( QBoxLayout *  titleLayout,
const QString &  spec 
) [private]

Adds the buttons for one side of the title bar, based on the spec string; see the KWin::KDecoration class, methods titleButtonsLeft and titleBUttonsRight.

Definition at line 521 of file nextclient.cpp.

{
    for (int i = 0; i < spec.length(); i++) {
        switch (spec[i].toLatin1()) {
        case 'A':
            if (isMaximizable()) {
                button[MAXIMIZE_IDX] =
                    new NextButton(this, maximize_bits, 10, 10,
                                   i18n("Maximize"), Qt::LeftButton|Qt::MidButton|Qt::RightButton);
                titleLayout->addWidget( button[MAXIMIZE_IDX] );
                connect( button[MAXIMIZE_IDX], SIGNAL(clicked()),
                         this, SLOT(maximizeButtonClicked()) );
            }
            break;

        case 'H':
           if (providesContextHelp()) {
              button[HELP_IDX] = new NextButton(this, question_bits, 10, 10, i18n("Help"));
              titleLayout->addWidget( button[HELP_IDX] );
              connect( button[HELP_IDX], SIGNAL(clicked()),
                      this, SLOT(showContextHelp()) );
           }
            break;

        case 'I':
            if (isMinimizable()) {
                button[ICONIFY_IDX] =
                    new NextButton(this, iconify_bits, 10, 10,
                                   i18n("Minimize"));
                titleLayout->addWidget( button[ICONIFY_IDX] );
                connect( button[ICONIFY_IDX], SIGNAL(clicked()),
                         this, SLOT(minimize()) );
            }
            break;

        case 'M':
            button[MENU_IDX] =
                new NextButton(this, NULL, 10, 10, i18n("Menu"), Qt::LeftButton|Qt::RightButton);
            titleLayout->addWidget( button[MENU_IDX] );
            // NOTE DIFFERENCE: capture pressed(), not clicked()
            connect( button[MENU_IDX], SIGNAL(pressed()),
                     this, SLOT(menuButtonPressed()) );
            break;

        case 'L':
            button[SHADE_IDX] =
                new NextButton(this, NULL, 0, 0, i18n("Shade"));
            titleLayout->addWidget( button[SHADE_IDX] );
            connect( button[SHADE_IDX], SIGNAL(clicked()),
                     this, SLOT(shadeClicked()) );
            // NOTE DIFFERENCE: set the pixmap separately (2 states)
           shadeChange();
            break;

        case 'S':
            button[STICKY_IDX] =
                new NextButton(this, NULL, 0, 0, i18n("On all desktops"));
            titleLayout->addWidget( button[STICKY_IDX] );
            connect( button[STICKY_IDX], SIGNAL(clicked()),
                     this, SLOT(toggleOnAllDesktops()) );
            // NOTE DIFFERENCE: set the pixmap separately (2 states)
           desktopChange();
            break;

       case 'F':
            button[ABOVE_IDX] = new NextButton(this, NULL, 0, 0, "");
            titleLayout->addWidget( button[ABOVE_IDX] );
            connect( button[ABOVE_IDX], SIGNAL(clicked()),
                     this, SLOT(aboveClicked()) );
           connect(this, SIGNAL(keepAboveChanged(bool)),
                  SLOT(keepAboveChange(bool)));
           keepAboveChange(keepAbove());
           break;

       case 'B':
            button[BELOW_IDX] = new NextButton(this, NULL, 0, 0, "");
            titleLayout->addWidget( button[BELOW_IDX] );
            connect( button[BELOW_IDX], SIGNAL(clicked()),
                     this, SLOT(belowClicked()) );
           connect(this, SIGNAL(keepBelowChanged(bool)),
                  SLOT(keepBelowChange(bool)));
           keepBelowChange(keepBelow());
           break;

       case 'X':
            if (isCloseable()) {
              button[CLOSE_IDX] =
                  new NextButton(this, close_bits, 10, 10,
                               i18n("Close"));
              titleLayout->addWidget(button[CLOSE_IDX]);
              connect(button[CLOSE_IDX], SIGNAL(clicked()),
                      this, SLOT(closeWindow()));
            }
            break;

       case 'R':
            if (mustDrawHandle()) {
              button[RESIZE_IDX] =
                  new NextButton(this, resize_bits, 10, 10,
                               i18n("Resize"));
              titleLayout->addWidget(button[RESIZE_IDX]);
              // NOTE DIFFERENCE: capture pressed(), not clicked()
              connect(button[RESIZE_IDX], SIGNAL(pressed()),
                      this, SLOT(resizePressed()));
            }
           break;
        case '_':
            // TODO: Add spacer handling
            break;

        default:
            kDebug() << " Can't happen: unknown button code "
                      << QString(spec[i]);
            break;
        }
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void KStep::NextClient::belowClicked ( ) [protected, slot]

Definition at line 690 of file nextclient.cpp.

{
    setKeepBelow(!keepBelow());
    keepAboveChange(keepAbove());
    keepBelowChange(keepBelow());
}

Here is the call graph for this function:

Here is the caller graph for this function:

void KStep::NextClient::borders ( int &  left,
int &  right,
int &  top,
int &  bottom 
) const [protected]

Definition at line 860 of file nextclient.cpp.

{
    left = right = 1;
    top = titleHeight; // FRAME is this ok?
    bottom = mustDrawHandle() ? handleSize : 1;
}

Here is the call graph for this function:

void KStep::NextClient::captionChange ( ) [protected]

Definition at line 720 of file nextclient.cpp.

{
    widget()->repaint(titlebar->geometry());
}
void KStep::NextClient::desktopChange ( ) [protected]

Definition at line 800 of file nextclient.cpp.

{
    bool on = isOnAllDesktops();
    if (NextButton * b = button[STICKY_IDX]) {
        b->setBitmap( on ? unsticky_bits : sticky_bits, 10, 10);
       //QToolTip::remove(b);
       b->setToolTip( on ? i18n("Not on all desktops") : i18n("On all desktops"));
    }
}

Here is the caller graph for this function:

bool KStep::NextClient::drawbound ( const QRect &  geom,
bool  clear 
) [virtual]

Definition at line 943 of file nextclient.cpp.

{
    // Let kwin draw the bounds, for now.
    return false;
#if 0
    QPainter p(workspaceWidget());
    p.setPen(QPen(Qt::white, 3));
    p.setCompositionMode(QPainter::CompositionMode_Xor);
    p.drawRect(geom);
    int leftMargin = geom.left() + 2;
    p.fillRect(leftMargin, geom.top() + titleHeight - 1,
           geom.width() - 4, 3, Qt::white);
    if (mustDrawHandle()) {
       p.fillRect(leftMargin, geom.bottom() - handleSize - 1,
              geom.width() - 4, 3, Qt::white);
    }
    return true;
#endif
}

Here is the call graph for this function:

bool KStep::NextClient::eventFilter ( QObject *  o,
QEvent *  e 
) [protected]

Definition at line 917 of file nextclient.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 KStep::NextClient::iconChange ( ) [protected]

Definition at line 649 of file nextclient.cpp.

{
    if (button[MENU_IDX] && button[MENU_IDX]->isVisible())
       button[MENU_IDX]->repaint();
}

Definition at line 442 of file nextclient.cpp.

{
    createMainWidget();
    widget()->setAttribute(Qt::WA_NoSystemBackground);
    widget()->installEventFilter(this);

    //widget()->setBackgroundMode( NoBackground );

    QVBoxLayout *mainLayout = new QVBoxLayout(widget());
    QBoxLayout *titleLayout = new QBoxLayout(QBoxLayout::LeftToRight);
    QHBoxLayout *windowLayout = new QHBoxLayout();
    mainLayout->setMargin(0);
    titleLayout->setMargin(0);
    titleLayout->setSpacing(0);
    mainLayout->addLayout(titleLayout);
    mainLayout->addLayout(windowLayout, 1);
    mainLayout->addSpacing(mustDrawHandle() ? handleSize : 1);

    windowLayout->addSpacing(1);
    if (isPreview())
        windowLayout->addWidget(new QLabel(i18n(
                     "<center><b>KStep preview</b></center>"), widget()));
    else
        windowLayout->addItem(new QSpacerItem( 0, 0 ));

    windowLayout->addSpacing(1);

    initializeButtonsAndTitlebar(titleLayout);
}

Here is the call graph for this function:

void KStep::NextClient::initializeButtonsAndTitlebar ( QBoxLayout *  titleLayout) [private]

Preconditions:

+ button is an array of length MAX_NUM_BUTTONS

Postconditions:

  • Title bar and buttons have been initialized and laid out
  • for all i in 0..(MAX_NUM_BUTTONS-1), button[i] points to either (1) a valid NextButton instance, if the corresponding button is selected in the current button scheme, or (2) null otherwise.

Definition at line 483 of file nextclient.cpp.

{
    // Null the buttons to begin with (they are not guaranteed to be null).
    for (int i=0; i<MAX_NUM_BUTTONS; i++) {
        button[i] = NULL;
    }

    // The default button positions for other styles do not match the
    // behavior of older versions of KStep, so we have to set these
    // manually when customButtonPositions isn't enabled.
    QString left, right;
    if (options()->customButtonPositions()) {
        left = options()->titleButtonsLeft();
        right = options()->titleButtonsRight();
    } else {
        left = QString("I");
        right = QString("SX");
    }

    // Do actual creation and addition to titleLayout
    addButtons(titleLayout, left);

    titlebar = new QSpacerItem(10, titleHeight, QSizePolicy::Expanding,
                               QSizePolicy::Minimum );
    titleLayout->addItem(titlebar);
    addButtons(titleLayout, right);

    // Finally, activate all live buttons
    for (int i = 0; i < MAX_NUM_BUTTONS; i++) {
        if (button[i]) {
            button[i]->setMouseTracking( TRUE );
        }
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void KStep::NextClient::keepAboveChange ( bool  above) [protected, slot]

Definition at line 876 of file nextclient.cpp.

{
    if (NextButton *b = button[ABOVE_IDX]) {
        b->setBitmap(above ? from_above_bits : keep_above_bits, 10, 10);
       //QToolTip::remove(b);
       b->setToolTip( above ?
              i18n("Do not keep above others") : i18n("Keep above others"));
       b->repaint();
    }
}

Here is the caller graph for this function:

void KStep::NextClient::keepBelowChange ( bool  below) [protected, slot]

Definition at line 887 of file nextclient.cpp.

{
    if (NextButton *b = button[BELOW_IDX]) {
        b->setBitmap(below ? from_below_bits : keep_below_bits, 10, 10);
       //QToolTip::remove(b);
       b->setToolTip( below ?
              i18n("Do not keep below others") : i18n("Keep below others"));
       b->repaint();
    }
}

Here is the caller graph for this function:

void KStep::NextClient::maximizeButtonClicked ( ) [protected, slot]

Definition at line 673 of file nextclient.cpp.

{
    if (button[MAXIMIZE_IDX]) {
        maximize(button[MAXIMIZE_IDX]->lastButton());
    }
}

Here is the caller graph for this function:

void KStep::NextClient::maximizeChange ( ) [protected]

Definition at line 810 of file nextclient.cpp.

{
    if (button[MAXIMIZE_IDX]) {
       bool m = maximizeMode() == MaximizeFull;
       //button[MAXIMIZE_IDX]->setBitmap(m ? minmax_bits : maximize_bits);
       //QToolTip::remove(button[MAXIMIZE_IDX]);
       button[MAXIMIZE_IDX]->setToolTip(
              m ? i18n("Restore") : i18n("Maximize"));
    }
    //spacer->changeSize(10, mustDrawHandle() ? handleSize : 1,
    //            QSizePolicy::Expanding, QSizePolicy::Minimum);
    //mainLayout->activate();
}
void KStep::NextClient::menuButtonPressed ( ) [protected, slot]

Definition at line 655 of file nextclient.cpp.

{
    // Probably don't need this null check, but we might as well.
    if (button[MENU_IDX]) {
       QRect menuRect = button[MENU_IDX]->rect();
        QPoint menuTop = button[MENU_IDX]->mapToGlobal(menuRect.topLeft());
        QPoint menuBottom = button[MENU_IDX]->mapToGlobal(menuRect.bottomRight());
       menuTop += QPoint(1, 1);
       menuBottom += QPoint(1, 1);
        KDecorationFactory* f = factory();
        showWindowMenu(QRect(menuTop, menuBottom));
        if( !f->exists( this )) // 'this' was deleted
            return;
       button[MENU_IDX]->setDown(false);
    }
}

Here is the caller graph for this function:

QSize KStep::NextClient::minimumSize ( ) const [protected]

Definition at line 898 of file nextclient.cpp.

{
    return QSize(titleHeight * 6 + 2, titleHeight + handleSize + 2);
}
void KStep::NextClient::mouseDoubleClickEvent ( QMouseEvent *  e) [protected]

Definition at line 789 of file nextclient.cpp.

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

Here is the caller graph for this function:

KDecoration::Position KStep::NextClient::mousePosition ( const QPoint &  p) const [protected]

Definition at line 840 of file nextclient.cpp.

{
  Position m = PositionCenter;

  if (p.y() < (height() - handleSize))
    m = KDecoration::mousePosition(p);

  else {
    int corner = 16 + 3*handleSize/2;
    if (p.x() >= (width() - corner))
      m = PositionBottomRight;
    else if (p.x() <= corner)
      m = PositionBottomLeft;
    else
      m = PositionBottom;
  }

  return m;
}
bool KStep::NextClient::mustDrawHandle ( ) const [private]

Definition at line 639 of file nextclient.cpp.

{
    bool drawSmallBorders = !options()->moveResizeMaximizedWindows();
    if (drawSmallBorders && (maximizeMode() & MaximizeVertical)) {
       return false;
    } else {
       return isResizable();
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void KStep::NextClient::paintEvent ( QPaintEvent *  ) [protected]

Definition at line 726 of file nextclient.cpp.

{
    QPainter p(widget());

    // Draw black frame
    QRect fr = widget()->rect();
    p.setPen(Qt::black);
    p.drawRect(fr);

    // Draw title bar
    QRect t = titlebar->geometry();
    t.setTop(1);
    p.drawTiledPixmap(t.x()+1, t.y()+1, t.width()-2, t.height()-2,
                      isActive() ? *aTitlePix : *iTitlePix);
    qDrawShadePanel(&p, t.x(), t.y(), t.width(), t.height()-1,
                   options()->palette(KDecoration::ColorTitleBar, isActive()));
    p.drawLine(t.x(), t.bottom(), t.right(), t.bottom());

#if 0
    // Why setting up a clipping region if it is not used? (setClipping(false))
    QRegion r = fr;
    r = r.subtract( t );
    p.setClipRegion( r );
    p.setClipping(false);
#endif

    t.setTop( 1 );
    t.setHeight(t.height()-2);
    t.setLeft( t.left() + 4 );
    t.setRight( t.right() - 2 );

    p.setPen(options()->color(KDecoration::ColorFont, isActive()));
    p.setFont(options()->font(isActive()));
    p.drawText( t, Qt::AlignCenter | Qt::AlignVCenter, caption() );

    // Draw resize handle
    if (mustDrawHandle()) {
        int corner = 16 + 3*handleSize/2;
       qDrawShadePanel(&p,
              fr.x() + 1, fr.bottom() - handleSize, corner-1, handleSize,
              options()->palette(KDecoration::ColorHandle, isActive()),
              false);
       p.drawTiledPixmap(fr.x() + 2, fr.bottom() - handleSize + 1,
              corner - 3, handleSize - 2, isActive() ? *aHandlePix : *iHandlePix);

       qDrawShadePanel(&p,
              fr.x() + corner, fr.bottom() - handleSize,
              fr.width() - 2*corner, handleSize,
              options()->palette(KDecoration::ColorFrame, isActive()),
              false);
       p.drawTiledPixmap(fr.x() + corner + 1, fr.bottom() - handleSize + 1,
              fr.width() - 2*corner - 2, handleSize - 2,
              isActive() ? *aFramePix : *iFramePix);

       qDrawShadePanel(&p,
              fr.right() - corner + 1, fr.bottom() - handleSize, corner - 1, handleSize,
              options()->palette(KDecoration::ColorHandle, isActive()),
              false);
       p.drawTiledPixmap(fr.right() - corner + 2, fr.bottom() - handleSize + 1,
              corner - 3, handleSize - 2, isActive() ? *aHandlePix : *iHandlePix);
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void KStep::NextClient::reset ( unsigned long  changed) [protected]

Definition at line 908 of file nextclient.cpp.

{
    for (int i = 0; i < MAX_NUM_BUTTONS; ++i) {
        if (button[i])
            button[i]->reset();
    }
    widget()->repaint();
}

Here is the call graph for this function:

void KStep::NextClient::resize ( const QSize &  size) [protected]

Definition at line 903 of file nextclient.cpp.

{
    widget()->resize(s);
}
void KStep::NextClient::resizeEvent ( QResizeEvent *  ) [protected]

Definition at line 702 of file nextclient.cpp.

{
    if (widget()->isVisible()) {
       // TODO ? update border area only?
        widget()->update();
#if 0
        widget()->update(titlebar->geometry());
        QPainter p(widget());
       QRect t = titlebar->geometry();
       t.setTop( 0 );
       QRegion r = widget()->rect();
       r = r.subtract( t );
       p.setClipRegion( r );
       p.eraseRect(widget()->rect());
#endif
    }
}

Here is the caller graph for this function:

void KStep::NextClient::resizePressed ( ) [protected, slot]

Definition at line 697 of file nextclient.cpp.

{
    performWindowOperation(ResizeOp);
}

Here is the caller graph for this function:

void KStep::NextClient::shadeChange ( ) [protected]

Definition at line 867 of file nextclient.cpp.

{
    if (NextButton *b = button[SHADE_IDX]) {
        b->setBitmap(isSetShade() ? unshade_bits : shade_bits, 10, 10);
       //QToolTip::remove(b);
       b->setToolTip( isSetShade() ? i18n("Unshade") : i18n("Shade"));
    }
}

Here is the caller graph for this function:

void KStep::NextClient::shadeClicked ( ) [protected, slot]

Definition at line 680 of file nextclient.cpp.

{
    setShade(!isSetShade());
}

Here is the caller graph for this function:

void KStep::NextClient::showEvent ( QShowEvent *  ) [protected]

Definition at line 795 of file nextclient.cpp.

{
    widget()->repaint();
}

Here is the caller graph for this function:

void KStep::NextClient::slotReset ( ) [protected, slot]

Definition at line 830 of file nextclient.cpp.

{
    for (int i=0; i<MAX_NUM_BUTTONS; i++) {
        if (button[i]) {
            button[i]->reset();
        }
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

Definition at line 132 of file nextclient.h.

QSpacerItem* KStep::NextClient::titlebar [private]

Definition at line 115 of file nextclient.h.


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