Back to index

kdeartwork  4.3.2
Public Member Functions | Protected Member Functions | Private Slots | Private Member Functions | Private Attributes
KDE1::StdClient Class Reference

#include <kde1client.h>

List of all members.

Public Member Functions

 StdClient (KDecorationBridge *b, KDecorationFactory *f)
 ~StdClient ()
void init ()
QSize minimumSize () const
void borders (int &left, int &right, int &top, int &bottom) const
void reset (unsigned long mask)
void resize (const QSize &s)
void shadeChange ()
Position mousePosition (const QPoint &p) const

Protected Member Functions

bool eventFilter (QObject *o, QEvent *e)
void resizeEvent (QResizeEvent *)
void paintEvent (QPaintEvent *)
void mouseDoubleClickEvent (QMouseEvent *)
void captionChange ()
 
void iconChange ()
void maximizeChange ()
 
void desktopChange ()
 
void activeChange ()

Private Slots

void menuButtonPressed ()
 Indicates that the menu button has been clicked.
void maxButtonClicked (ButtonState)

Private Member Functions

void addButtons (QBoxLayout *hb, const QString &buttons)

Private Attributes

QToolButton * button [ButtonTypeCount]
QSpacerItem * titlebar

Detailed Description

Definition at line 46 of file kde1client.h.


Constructor & Destructor Documentation

KDE1::StdClient::StdClient ( KDecorationBridge *  b,
KDecorationFactory *  f 
)

Definition at line 260 of file kde1client.cpp.

    : KDecoration( b, f )
{
}

Definition at line 423 of file kde1client.cpp.

{
    for (int n=0; n<ButtonTypeCount; n++) {
        if (button[n]) delete button[n];
    }
}

Member Function Documentation

void KDE1::StdClient::activeChange ( ) [protected]

Definition at line 403 of file kde1client.cpp.

{
    bool on = isActive();
    if (button[ButtonMenu] && (icon().pixmap( QIconSet::Small, QIconSet::Normal ).isNull()))
        button[ButtonMenu]->setIconSet(on ? *menu_pix : *dis_menu_pix);
    if (button[ButtonSticky])
        button[ButtonSticky]->setIconSet(isOnAllDesktops() ? on ? *pindown_pix : *dis_pindown_pix :
                          on ? *pinup_pix : *dis_pinup_pix );
    if (button[ButtonMinimize])
        button[ButtonMinimize]->setIconSet(on ? *minimize_pix : *dis_minimize_pix);
    if (button[ButtonMaximize])
        button[ButtonMaximize]->setIconSet(on ? *maximize_pix : *dis_maximize_pix);
    if (button[ButtonClose])
        button[ButtonClose]->setIconSet(on ? *close_pix : *dis_close_pix);
    if (button[ButtonHelp])
        button[ButtonHelp]->setIconSet(on ? *question_mark_pix : *dis_question_mark_pix);
    widget()->repaint( titlebar->geometry(), false );
}
void KDE1::StdClient::addButtons ( QBoxLayout *  hb,
const QString &  buttons 
) [private]

Definition at line 318 of file kde1client.cpp.

{
    if (s.length() > 0) {
        for (unsigned n=0; n < s.length(); n++) {
            switch (s[n]) {
              case 'M': // Menu button
                  if (!button[ButtonMenu]) {
                      button[ButtonMenu] = new QToolButton( widget(), 0 );
                      button[ButtonMenu]->setToolTip( i18n("Menu") );
                      button[ButtonMenu]->setCursor(ArrowCursor);
                      if( icon().pixmap( QIconSet::Small, QIconSet::Normal ).isNull())
                          button[ButtonMenu]->setIconSet(isActive() ? *menu_pix : *dis_menu_pix);
                      else
                          button[ButtonMenu]->setIconSet( icon().pixmap( QIconSet::Small, QIconSet::Normal ));
                      connect( button[0], SIGNAL( pressed() ), this, SLOT( menuButtonPressed() ) );
                      hb->addWidget(button[ButtonMenu]);
                  }
                  break;

              case 'S': // Sticky button
                  if (!button[ButtonSticky]) {
                     button[ButtonSticky] = new QToolButton( widget(), 0 );
                     button[ButtonSticky]->setIconSet( isOnAllDesktops()?*pindown_pix:*pinup_pix );
                     button[ButtonSticky]->setToolTip( isOnAllDesktops()?i18n("Not On All Desktops"):i18n("On All Desktops")  );
                     button[ButtonSticky]->setCursor(ArrowCursor);
                     button[ButtonSticky]->setIconSet(isOnAllDesktops() ? isActive() ? *pindown_pix : *dis_pindown_pix :
                                                      isActive() ? *pinup_pix : *dis_pinup_pix );
                     connect( button[ButtonSticky], SIGNAL( clicked() ), this, ( SLOT( toggleOnAllDesktops() ) ) );
                     hb->addWidget(button[ButtonSticky]);
                  }
                  break;

              case 'H': // Help button
                  if ((!button[ButtonHelp]) && providesContextHelp()) {
                      button[ButtonHelp] = new QToolButton( widget(), 0 );
                      button[ButtonHelp]->setToolTip( i18n("Help") );
                      button[ButtonHelp]->setIconSet( isActive() ? *question_mark_pix : *dis_question_mark_pix);
                      connect( button[ButtonHelp], SIGNAL( clicked() ), this, ( SLOT( showContextHelp() ) ) );
                      button[ButtonHelp]->setCursor(ArrowCursor);
                      hb->addWidget(button[ButtonHelp]);
                  }
                  break;

              case 'I': // Minimize button
                  if ((!button[ButtonMinimize]) && isMinimizable())  {
                      button[ButtonMinimize] = new QToolButton( widget(), 0 );
                      button[ButtonMinimize]->setToolTip( i18n("Minimize") );
                      button[ButtonMinimize]->setCursor(ArrowCursor);
                      button[ButtonMinimize]->setIconSet(isActive() ? *minimize_pix : *dis_minimize_pix);
                      connect( button[ButtonMinimize], SIGNAL( clicked() ), this, ( SLOT( minimize() ) ) );
                      hb->addWidget(button[ButtonMinimize]);
                  }
                  break;

              case 'A': // Maximize button
                  if ((!button[ButtonMaximize]) && isMaximizable()) {
                      const bool max = maximizeMode()!=MaximizeRestore;
                      button[ButtonMaximize] = new ThreeButtonButton( widget(), 0 );
                      button[ButtonMaximize]->setToolTip( max?i18n("Restore"):i18n("Maximize") );
                      button[ButtonMaximize]->setCursor(ArrowCursor);
                      button[ButtonMaximize]->setIconSet( max?(isActive() ? *normalize_pix : *dis_normalize_pix):(isActive() ? *maximize_pix : *dis_maximize_pix) );
                      connect( button[ButtonMaximize], SIGNAL( clicked(ButtonState) ),
                               this, ( SLOT( maxButtonClicked(ButtonState) ) ) );
                      hb->addWidget(button[ButtonMaximize]);
                  }
                  break;

              case 'X': // Close button
                  if ((!button[ButtonClose]) && isCloseable()) {
                      button[ButtonClose] = new QToolButton( widget(), 0 );
                      button[ButtonClose]->setToolTip( i18n("Close") );
                      button[ButtonClose]->setCursor(ArrowCursor);
                      button[ButtonClose]->setIconSet(isActive() ? *close_pix : *dis_close_pix);
                      connect( button[ButtonClose], SIGNAL( clicked() ), this, ( SLOT( closeWindow() ) ) );
                      hb->addWidget(button[ButtonClose]);
                  }
                  break;

              case '_': // Spacer item
                 hb->addItem( new QSpacerItem( 5, 0, QSizePolicy::Fixed, QSizePolicy::Expanding ) );
            }
        }
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void KDE1::StdClient::borders ( int &  left,
int &  right,
int &  top,
int &  bottom 
) const

Definition at line 587 of file kde1client.cpp.

{
    left = right = bottom = 6;
    top = 6 + widget()->fontMetrics().lineSpacing()+2;
}
void KDE1::StdClient::captionChange ( ) [protected]

Definition at line 448 of file kde1client.cpp.

{
    widget()->repaint( titlebar->geometry(), FALSE );
}
void KDE1::StdClient::desktopChange ( ) [protected]

Definition at line 469 of file kde1client.cpp.

{
    bool s = isOnAllDesktops();
    if (button[ButtonSticky]) {
        button[ButtonSticky]->setIconSet( s?*pindown_pix:*pinup_pix );
        QToolTip::remove( button[ButtonSticky] );
        button[ButtonSticky]->setToolTip( s ? i18n("Not On All Desktops") : i18n("On All Desktops") );
    }
}
bool KDE1::StdClient::eventFilter ( QObject *  o,
QEvent *  e 
) [protected]

Definition at line 555 of file kde1client.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;

    default:
       return false;
    }
}

Here is the call graph for this function:

void KDE1::StdClient::iconChange ( ) [protected]

Definition at line 520 of file kde1client.cpp.

{
    if (button[ButtonMenu]) {
        if ( icon().pixmap( QIconSet::Small, QIconSet::Normal ).isNull())
            button[ButtonMenu]->setIconSet(isActive() ? *menu_pix : *dis_menu_pix);
        else
            button[ButtonMenu]->setIconSet( icon().pixmap( QIconSet::Small, QIconSet::Normal ) );
        button[ButtonMenu]->repaint( FALSE );
    }
}

Definition at line 265 of file kde1client.cpp.

{
    createMainWidget();
    widget()->installEventFilter( this );

    widget()->setFont(options()->font(isActive() ));

    QGridLayout* g = new QGridLayout( widget(), 0, 0, 3, 2 );
    g->setRowStretch( 1, 10 );
    if( isPreview())
        g->addWidget( new QLabel( i18n( "<center><b>KDE 1 preview</b></center>" ), widget()), 1, 1 );
    else
        g->addItem( new QSpacerItem( 0, 0 ), 1, 1 ); //no widget in the middle
    g->addItem( new QSpacerItem( 0, 0, QSizePolicy::Fixed, QSizePolicy::Expanding ) );

    g->addColSpacing(0, 1);
    g->addColSpacing(2, 1);
    g->addRowSpacing(2, 1);

    int fh = widget()->fontMetrics().lineSpacing();
    titlebar = new QSpacerItem(10, fh, QSizePolicy::Expanding,
                            QSizePolicy::Minimum );

    QBoxLayout* hb = new QBoxLayout(0, QBoxLayout::LeftToRight, 0, 0, 0);
    g->addLayout( hb, 0, 1 );

    // setup titlebar buttons
    for (int n=0; n<ButtonTypeCount; n++) button[n] = 0;
    addButtons(hb, options()->customButtonPositions() ? options()->titleButtonsLeft() : QString(default_left));
    hb->addItem(titlebar);
    addButtons(hb, options()->customButtonPositions() ? options()->titleButtonsRight() : QString(default_right));

    for (int n=0; n<ButtonTypeCount; n++) {
       if ( !button[n] )
           continue;
       button[n]->setBackgroundMode( PaletteBackground );
       button[n]->setMouseTracking( FALSE );
       button[n]->setAutoRaise( TRUE );
       button[n]->setFocusPolicy( QWidget::NoFocus );
       button[n]->setFixedSize( 20, 20 );
    }

#if 0 // not sure what this is supposed to mean (and why)
    if ( isTransient() ) {
       // lighter decoration for transient windows
       button[1]->hide();
//     button[2]->hide();
       button[3]->hide();
       button[4]->hide();
    }
#endif
}

Here is the call graph for this function:

void KDE1::StdClient::maxButtonClicked ( ButtonState  button) [private, slot]

Definition at line 550 of file kde1client.cpp.

{
    maximize( button );
}

Here is the caller graph for this function:

void KDE1::StdClient::maximizeChange ( ) [protected]

Definition at line 456 of file kde1client.cpp.

{
    bool m = maximizeMode() == MaximizeFull;
    if (button[ButtonMaximize]) {
        button[ButtonMaximize]->setIconSet( m?*normalize_pix:*maximize_pix  );
        QToolTip::remove( button[ButtonMaximize] );
        button[ButtonMaximize]->setToolTip( m ? i18n("Restore") : i18n("Maximize") );
    }
}
void KDE1::StdClient::menuButtonPressed ( ) [private, slot]

Indicates that the menu button has been clicked.

One press shows the window operation menu, a double click closes the window.

Definition at line 536 of file kde1client.cpp.

{
    QRect menuRect = button[ButtonMenu]->rect();
    menuRect.addCoords(-1, 0, +1, +2);
    QPoint menuTop = button[ButtonMenu]->mapToGlobal(menuRect.topLeft());
    QPoint menuBottom = button[ButtonMenu]->mapToGlobal(menuRect.bottomRight());
    KDecorationFactory* f = factory(); // needs to be saved before
    showWindowMenu( QRect(menuTop, menuBottom) );
    if( !f->exists( this )) // destroyed, return immediately
        return;
    button[ButtonMenu]->setDown(false);
}

Here is the caller graph for this function:

Definition at line 582 of file kde1client.cpp.

{
    return widget()->minimumSize().expandedTo( QSize( 100, 50 ));
}
void KDE1::StdClient::mouseDoubleClickEvent ( QMouseEvent *  e) [protected]

Definition at line 513 of file kde1client.cpp.

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

Here is the caller graph for this function:

Position KDE1::StdClient::mousePosition ( const QPoint &  p) const [inline]

Definition at line 58 of file kde1client.h.

{ return KDecoration::mousePosition( p ); }
void KDE1::StdClient::paintEvent ( QPaintEvent *  ) [protected]

Definition at line 479 of file kde1client.cpp.

{
    QPainter p( widget() );
    QRect t = titlebar->geometry();
    QRegion r = widget()->rect();
    r = r.subtract( t );
    p.setClipRegion( r );
    qDrawWinPanel( &p, widget()->rect(), widget()->colorGroup() );
//     t.setTop( 1 );
//     p.setClipRegion( t );
//     t.setTop( 0 );

    QRect titleRect( 0, 0, t.width(), t.height() );
    titleBuffer->resize( titleRect.width(), titleRect.height() );
    QPainter p2( titleBuffer );

    drawGradient(p2, titleRect, options()->color(KDecorationOptions::ColorTitleBar, isActive()),
        options()->color(KDecorationOptions::ColorTitleBlend, isActive()));
//     p.setPen( options()->color(KDecorationOptions::ColorTitleBar, isActive()).light() );
//     p.drawLine(t.left(), t.top()+1,  t.right(), t.top()+1);
    if ( isActive() )
       qDrawShadePanel( &p2, 0, 0, titleRect.width(), titleRect.height(),
                      widget()->colorGroup(), true, 1 );
    titleRect.setLeft( 4 );
    titleRect.setWidth( titleRect.width() - 2 );
    p2.setPen(options()->color(KDecorationOptions::ColorFont, isActive()));
    p2.setFont(options()->font(isActive()));
    p2.drawText( titleRect, AlignLeft|AlignVCenter|SingleLine, caption() );
    p2.end();
    p.end();
    bitBlt( widget(), t.topLeft(), titleBuffer );
}

Here is the call graph for this function:

Here is the caller graph for this function:

void KDE1::StdClient::reset ( unsigned long  mask)

Definition at line 240 of file kde1client.cpp.

{
    if (button[ButtonMenu] && (icon().pixmap( QIconSet::Small, QIconSet::Normal ).isNull()))
        button[ButtonMenu]->setIconSet(isActive() ? *menu_pix : *dis_menu_pix);
    if (button[ButtonSticky])
        button[ButtonSticky]->setIconSet(isOnAllDesktops() ? isActive() ? *pindown_pix : *dis_pindown_pix :
                                         isActive() ? *pinup_pix : *dis_pinup_pix );
    if (button[ButtonMinimize])
        button[ButtonMinimize]->setIconSet(isActive() ? *minimize_pix : *dis_minimize_pix);
    if (button[ButtonMaximize])
        button[ButtonMaximize]->setIconSet(isActive() ? *maximize_pix : *dis_maximize_pix);
    if (button[ButtonClose])
        button[ButtonClose]->setIconSet(isActive() ? *close_pix : *dis_close_pix);
    if (button[ButtonHelp])
        button[ButtonHelp]->setIconSet(isActive() ? *question_mark_pix : *dis_question_mark_pix);

    widget()->setFont(options()->font(true));
}

Here is the call graph for this function:

void KDE1::StdClient::resize ( const QSize &  s)

Definition at line 593 of file kde1client.cpp.

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

Definition at line 431 of file kde1client.cpp.

{
    QRegion rr = widget()->rect();
    QRect t = titlebar->geometry();
//     t.setTop( 0 );
//     QRegion r = rr.subtract( QRect( t.x()+1, 0, t.width()-2, 1 ) );
//     setMask( r );

    if ( widget()->isVisibleToTLW() && !widget()->testWFlags( WStaticContents )) {
       // manual clearing without the titlebar (we selected WResizeNoErase )
       QRect cr( 2, 2, width()-4, height()- 4 );
       widget()->erase( QRegion( cr ).subtract( t ) );
    }
}

Here is the caller graph for this function:

void KDE1::StdClient::shadeChange ( ) [inline]

Definition at line 57 of file kde1client.h.

{};

Member Data Documentation

QToolButton* KDE1::StdClient::button[ButtonTypeCount] [private]

Definition at line 79 of file kde1client.h.

QSpacerItem* KDE1::StdClient::titlebar [private]

Definition at line 80 of file kde1client.h.


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