Back to index

kdeartwork  4.3.2
Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes
OpenLook::OpenLook Class Reference

#include <OpenLook.h>

List of all members.

Public Member Functions

 OpenLook (KDecorationBridge *b, KDecorationFactory *f)
 ~OpenLook ()
void init ()

Protected Member Functions

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

Private Member Functions

void doLayout ()
QRect titleRect () const
QRect topLeftRect () const
QRect topRightRect () const
QRect bottomLeftRect () const
QRect bottomRightRect () const
QRect buttonRect () const
void paintBorder (QPainter &) const
void paintTopLeftRect (QPainter &) const
void paintTopRightRect (QPainter &) const
void paintBottomLeftRect (QPainter &) const
void paintBottomRightRect (QPainter &) const
void paintButton (QPainter &) const
void paintArrow (QPainter &) const
bool isButtonPress (QMouseEvent *)
bool isButtonRelease (QMouseEvent *)

Private Attributes

QSpacerItem * titleSpacer_
QPoint mousePressPoint_
bool tool_
bool buttonDown_

Detailed Description

Definition at line 47 of file OpenLook.h.


Constructor & Destructor Documentation

OpenLook::OpenLook::OpenLook ( KDecorationBridge *  b,
KDecorationFactory *  f 
)

Definition at line 116 of file OpenLook.cpp.

                                                              :
    KDecoration(b, f),
    titleSpacer_    (0),
    mousePressPoint_(0, 0), // Anywhere outside button rect.
    buttonDown_     (false)
{
}

Definition at line 169 of file OpenLook.cpp.

{
  // Empty.
}

Member Function Documentation

void OpenLook::OpenLook::activeChange ( ) [protected]

Definition at line 302 of file OpenLook.cpp.

{
  widget()->repaint();
}
bool OpenLook::OpenLook::animateMinimize ( bool  ) [protected, virtual]

Definition at line 371 of file OpenLook.cpp.

{
#if 0
  QRect icongeom(iconGeometry());

  if (!icongeom.isValid())
    return false;

  QRect wingeom(geometry());

  QPainter p(workspaceWidget());

  p.setRasterOp(Qt::NotROP);

#if 0
  if (iconify)
    p.setClipRegion(
      QRegion(workspace()->desktopWidget()->rect()) - wingeom
      );
#endif

  for (uint count = 0; count < 4; count++)
  {
    grabXServer();

    p.drawLine(wingeom.bottomRight(), icongeom.bottomRight());
    p.drawLine(wingeom.bottomLeft(), icongeom.bottomLeft());
    p.drawLine(wingeom.topLeft(), icongeom.topLeft());
    p.drawLine(wingeom.topRight(), icongeom.topRight());

    p.flush();

    kapp->syncX();

    usleep(10000);

    p.drawLine(wingeom.bottomRight(), icongeom.bottomRight());
    p.drawLine(wingeom.bottomLeft(), icongeom.bottomLeft());
    p.drawLine(wingeom.topLeft(), icongeom.topLeft());
    p.drawLine(wingeom.topRight(), icongeom.topRight());

    p.flush();

    kapp->syncX();

    usleep(10000);

    ungrabXServer();
  }
#endif
  return true;
}
void OpenLook::OpenLook::borders ( int &  left,
int &  right,
int &  top,
int &  bottom 
) const [protected]

Definition at line 208 of file OpenLook.cpp.

{
    // FRAME XXX Check
    left = right = bottom = openLookMargin;
    top = titleHeight + openLookMargin;
}

Here is the caller graph for this function:

QRect OpenLook::OpenLook::bottomLeftRect ( ) const [private]

Definition at line 449 of file OpenLook.cpp.

Here is the caller graph for this function:

QRect OpenLook::OpenLook::bottomRightRect ( ) const [private]

Definition at line 461 of file OpenLook.cpp.

Here is the caller graph for this function:

QRect OpenLook::OpenLook::buttonRect ( ) const [private]

Definition at line 588 of file OpenLook.cpp.

{
  return QRect
    (
      openLookCornerSize + 3,
      titleRect().top(),
      titleRect().height(),
      titleRect().height()
    );
}

Here is the call graph for this function:

Here is the caller graph for this function:

void OpenLook::OpenLook::captionChange ( ) [protected, virtual]

Definition at line 216 of file OpenLook.cpp.

{
  widget()->update(titleRect());
}

Here is the call graph for this function:

void OpenLook::OpenLook::desktopChange ( ) [protected]

Definition at line 328 of file OpenLook.cpp.

{
}
void OpenLook::OpenLook::doLayout ( ) [private]

Definition at line 339 of file OpenLook.cpp.

{
  QVBoxLayout * layout = new QVBoxLayout(widget(), openLookMargin);

  titleSpacer_ =
    new QSpacerItem
    (
     0,
     titleHeight,
     QSizePolicy::Expanding,
     QSizePolicy::Fixed
    );

  layout->addItem(titleSpacer_);

  layout->addSpacing(2);

  QBoxLayout * midLayout =
    new QBoxLayout(layout, QBoxLayout::LeftToRight, 0, 0);

  if (isPreview()) {
    midLayout->addWidget(new QLabel(
          i18n("<center><b>OpenLook preview</b></center>"),
          widget()),
        1);
  } else {
    midLayout->addItem( new QSpacerItem( 0, 0 ));
  }

}

Here is the caller graph for this function:

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

Definition at line 174 of file OpenLook.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:
    if (!isButtonPress(static_cast< QMouseEvent* >(e))) {
      processMousePressEvent(static_cast< QMouseEvent* >(e));
    }
    return true;
  case QEvent::MouseButtonRelease:
    if (isButtonRelease(static_cast< QMouseEvent* >(e))) {
      return true;
    } else {
      return false;
    }
  case QEvent::Show:
    showEvent(static_cast< QShowEvent* >(e));
    return true;
  default:
    break;
  }
  return false;
}

Here is the call graph for this function:

void OpenLook::OpenLook::iconChange ( ) [protected]

Definition at line 323 of file OpenLook.cpp.

{
}

Definition at line 124 of file OpenLook.cpp.

{
  static const int SUPPORTED_WINDOW_TYPES_MASK = NET::NormalMask |
    NET::DesktopMask | NET::DockMask | NET::ToolbarMask | NET::MenuMask |
    NET::DialogMask | NET::OverrideMask | NET::TopMenuMask |
    NET::UtilityMask | NET::SplashMask;

  createMainWidget( Qt::WResizeNoErase);
  widget()->setAttribute( Qt::WA_StaticContents);
  widget()->setAttribute( Qt::WA_NoBackground );
  widget()->installEventFilter(this);
  widget()->setBackgroundMode(NoBackground);
  NET::WindowType type = windowType(SUPPORTED_WINDOW_TYPES_MASK);
  tool_ = (type == NET::Toolbar || type == NET::Utility || type == NET::Menu);
  QFontMetrics fm(options()->font(isActive(), tool_));

  titleHeight = fm.height() + openLookTextVMargin * 2;

  switch(KDecoration::options()->preferredBorderSize(factory())) {
      case KDecoration::BorderLarge:
          openLookMargin = 9;
          break;
      case KDecoration::BorderVeryLarge:
          openLookMargin = 13;
          break;
      case KDecoration::BorderHuge:
          openLookMargin = 18;
          break;
      case KDecoration::BorderVeryHuge:
          openLookMargin = 27;
          break;
      case KDecoration::BorderOversized:
          openLookMargin = 40;
          break;
      case KDecoration::BorderNormal:
      default:
          openLookMargin = 5;
  }
  openLookCornerSize = 2*openLookMargin + 1;
  if (titleHeight <= openLookMargin)
      titleHeight = openLookMargin+1;

  doLayout();
}

Here is the call graph for this function:

bool OpenLook::OpenLook::isButtonPress ( QMouseEvent *  e) [private]

Definition at line 700 of file OpenLook.cpp.

{
  mousePressPoint_ = e->pos();

  buttonDown_ = buttonRect().contains(mousePressPoint_);

  widget()->repaint(buttonRect());
  return buttonDown_;
}

Here is the call graph for this function:

Here is the caller graph for this function:

bool OpenLook::OpenLook::isButtonRelease ( QMouseEvent *  e) [private]

Definition at line 711 of file OpenLook.cpp.

{
  if (buttonDown_ && buttonRect().contains(e->pos()))
  {
    minimize();
    return true;
  }
  buttonDown_ = false;
  widget()->repaint(buttonRect());

  return false;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void OpenLook::OpenLook::maximizeChange ( ) [protected]

Definition at line 333 of file OpenLook.cpp.

{
    widget()->repaint(false);
}
QSize OpenLook::OpenLook::minimumSize ( ) const [protected]

Definition at line 226 of file OpenLook.cpp.

{
    int left, right, top, bottom;
    borders(left, right, top, bottom);
    return QSize(left  + right + 2 * titleHeight, top + bottom);
}

Here is the call graph for this function:

void OpenLook::OpenLook::mouseDoubleClickEvent ( QMouseEvent *  e) [protected, virtual]

Definition at line 287 of file OpenLook.cpp.

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

Here is the call graph for this function:

Here is the caller graph for this function:

KDecoration::Position OpenLook::OpenLook::mousePosition ( const QPoint &  p) const [protected, virtual]

Definition at line 308 of file OpenLook.cpp.

{
  if (topLeftRect().contains(p))
    return PositionTopLeft;
  else if (topRightRect().contains(p))
    return PositionTopRight;
  else if (bottomLeftRect().contains(p))
    return PositionBottomLeft;
  else if (bottomRightRect().contains(p))
    return PositionBottomRight;
  else
    return PositionCenter;
}

Here is the call graph for this function:

void OpenLook::OpenLook::paintArrow ( QPainter &  p) const [private]

Definition at line 629 of file OpenLook.cpp.

{
  QRect br(buttonRect());

  int x = br.left()   + 5;
  int y = br.top()    + 5;
  int w = br.width()  - 10;
  int h = br.height() - 10;

  Q3PointArray poly(3);

  p.setBrush(widget()->palette().mid());

  poly.setPoint(0, x, y);
  poly.setPoint(1, x + w - 1, y);
  poly.setPoint(2, x + (w / 2), y + h - 1);

  p.drawPolygon(poly);

  p.setPen(widget()->palette().dark());

  p.drawLine(x, y, x + w - 1, y);

  p.drawLine(x, y, x + (w / 2), y + h - 1);

  p.setPen(widget()->palette().light());

  p.drawLine(x + (w / 2), y + h - 1, x + w - 1, y);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void OpenLook::OpenLook::paintBorder ( QPainter &  p) const [private]

Definition at line 660 of file OpenLook.cpp.

{
  const uint cs(openLookCornerSize);

  uint x = widget()->rect().left();
  uint y = widget()->rect().top();
  uint w = widget()->rect().width();
  uint h = widget()->rect().height();
  uint r = widget()->rect().right();
  uint b = widget()->rect().bottom();

  p.fillRect(x + cs, y, w - cs - cs, 2,     widget()->palette().shadow());
  p.fillRect(x + cs, b - 1, w - cs - cs, 2, widget()->palette().shadow());
  p.fillRect(x, y + cs, 2, h - cs - cs,     widget()->palette().shadow());
  p.fillRect(r - 1, y + cs, 2, h - cs - cs, widget()->palette().shadow());

  QColor frameColour(options()->color(KDecoration::ColorFrame, isActive()));

  p.fillRect(x + cs, y + 2, w - cs - cs, openLookMargin-2, frameColour);
  p.fillRect(x + cs, b - openLookMargin + 1, w - cs - cs, openLookMargin-2, frameColour);
  p.fillRect(x + 2, y + cs, openLookMargin-2, h - cs - cs, frameColour);
  p.fillRect(r - openLookMargin + 1, y + cs, openLookMargin-2, h - cs - cs, frameColour);

  p.fillRect
    (
     openLookMargin,
     titleRect().bottom() + 1,
     width() - 2 * openLookMargin,
     2,
     widget()->palette().background()
    );
}

Here is the call graph for this function:

Here is the caller graph for this function:

void OpenLook::OpenLook::paintBottomLeftRect ( QPainter &  p) const [private]

Definition at line 532 of file OpenLook.cpp.

{
  QColor handleColour(options()->color(KDecoration::ColorHandle, isActive()));

  QRect r(bottomLeftRect());

  int x1(r.left());
  int y1(r.top());
  int x2(r.right());
  int y2(r.bottom());

  p.setPen(widget()->palette().light());

  p.drawLine(x1, y1, x1 + openLookMargin-1, y1);
  p.drawLine(x1, y1 + 1, x1, y2);
  p.drawLine(x1 + openLookMargin, y2 - openLookMargin+1, x2, y2 - openLookMargin+1);

  p.fillRect(x1 + 1, y2 - openLookMargin + 2, r.width()-2, openLookMargin-2, handleColour);
  p.fillRect(x1 + 1, y1 + 1, openLookMargin-2, r.height()-2, handleColour);

  p.setPen(widget()->palette().dark());

  p.drawLine(x1 + openLookMargin-1, y1 + 1, x1 + openLookMargin-1, y2 - openLookMargin);
  p.drawLine(x1 + 1, y2, x2, y2);
  p.drawLine(x2, y2 - openLookMargin+2, x2, y2 - 1);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void OpenLook::OpenLook::paintBottomRightRect ( QPainter &  p) const [private]

Definition at line 560 of file OpenLook.cpp.

{
  QColor handleColour(options()->color(KDecoration::ColorHandle, isActive()));

  QRect r(bottomRightRect());

  int x1(r.left());
  int y1(r.top());
  int x2(r.right());
  int y2(r.bottom());

  p.setPen(widget()->palette().light());

  p.drawLine(x1, y2 - openLookMargin+1, x1, y2);
  p.drawLine(x1 + 1, y2 - openLookMargin+1, x2 - openLookMargin+1, y2 - openLookMargin+1);
  p.drawLine(x2 - openLookMargin+1, y1 + 1, x2 - openLookMargin+1, y2 - openLookMargin);
  p.drawLine(x2 - openLookMargin+1, y1, x2, y1);

  p.fillRect(x1 + 1, y2 - openLookMargin + 2, r.width()-2, openLookMargin-2,  handleColour);
  p.fillRect(x2 - openLookMargin + 2, y1 + 1, openLookMargin-2, r.height()-2, handleColour);

  p.setPen(widget()->palette().dark());

  p.drawLine(x1 + 1, y2, x2, y2);
  p.drawLine(x2, y1 + 1, x2, y2 - 1);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void OpenLook::OpenLook::paintButton ( QPainter &  p) const [private]

Definition at line 600 of file OpenLook.cpp.

{
  QRect r(buttonRect());

  p.fillRect
    (
     r.left() + 1,
     r.top() + 1,
     r.width() - 2,
     r.height() - 2,
     buttonDown_
     ? widget()->palette().dark()
     : options()->color(KDecoration::ColorButtonBg, isActive())
    );

  p.setPen(buttonDown_ ? widget()->palette().dark() : widget()->palette().light());

  p.drawLine(r.left() + 1, r.top(), r.right() - 1, r.top());
  p.drawLine(r.left(), r.top() + 1, r.left(), r.bottom() - 1);

  p.setPen(buttonDown_ ? widget()->palette().light() : widget()->palette().dark());

  p.drawLine(r.right(), r.top() + 1, r.right(), r.bottom() - 1);
  p.drawLine(r.left() + 1, r.bottom(), r.right() - 1, r.bottom());

  paintArrow(p);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void OpenLook::OpenLook::paintEvent ( QPaintEvent *  e) [protected]

Definition at line 241 of file OpenLook.cpp.

{
  QRect tr(titleRect());

  QPainter p(widget());

  QRegion clipRegion(pe->region());

  p.setClipRegion(clipRegion);

  paintBorder(p);

  paintTopLeftRect(p);
  paintTopRightRect(p);
  paintBottomLeftRect(p);
  paintBottomRightRect(p);

  p.setClipRegion(clipRegion + buttonRect());

  QBrush titleBackground(options()->color(KDecoration::ColorTitleBar, true));

  if (isActive())
    qDrawShadePanel(&p, tr, widget()->palette(), true, 1, &titleBackground);
  else
    p.fillRect(tr, widget()->palette().brush(QPalette::Background));

  p.setClipRegion(clipRegion);

  paintButton(p);

  p.setFont(options()->font(isActive(), tool_));

  p.setPen(options()->color(KDecoration::ColorFont, isActive()));

  tr.setLeft(openLookCornerSize + 3 + buttonRect().width() + 2);

  p.drawText(tr, Qt::AlignCenter, caption());
}

Here is the call graph for this function:

Here is the caller graph for this function:

void OpenLook::OpenLook::paintTopLeftRect ( QPainter &  p) const [private]

Definition at line 473 of file OpenLook.cpp.

{
  QColor handleColour(options()->color(KDecoration::ColorHandle, isActive()));

  QRect r(topLeftRect());

  int x1(r.left());
  int y1(r.top());
  int x2(r.right());
  int y2(r.bottom());

  p.setPen(widget()->palette().light());

  p.drawLine(x1, y1, x2, y1);
  p.drawLine(x1, y1 + 1, x1, y2);

  p.fillRect(x1 + 1, y1 + 1, r.width()-2, openLookMargin-2,  handleColour);
  p.fillRect(x1 + 1, y1 + 1, openLookMargin-2, r.height()-2, handleColour);

  p.setPen(widget()->palette().dark());

  p.drawLine(x2, y1 + 1, x2, y1 + openLookMargin-1);

  p.drawLine(x1 + openLookMargin-1, y1 + openLookMargin-1, x2 - 1, y1 + openLookMargin-1);

  p.drawLine(x1 + openLookMargin-1, y1 + openLookMargin, x1 + openLookMargin-1, y2 - 1);

  p.drawLine(x1 + 1, y2, x1 + openLookMargin-1, y2);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void OpenLook::OpenLook::paintTopRightRect ( QPainter &  p) const [private]

Definition at line 504 of file OpenLook.cpp.

{
  QColor handleColour(options()->color(KDecoration::ColorHandle, isActive()));

  QRect r(topRightRect());

  int x1(r.left());
  int y1(r.top());
  int x2(r.right());
  int y2(r.bottom());

  p.setPen(widget()->palette().light());

  p.drawLine(x1, y1, x2, y1);
  p.drawLine(x1, y1 + 1, x1, y1 + openLookMargin-1);
  p.drawLine(x2 - openLookMargin+1, y1 + openLookMargin, x2 - openLookMargin+1, y2);

  p.fillRect(x1 + 1, y1 + 1, r.width()-2, openLookMargin-2, handleColour);
  p.fillRect(x2 - openLookMargin + 2, y1 + 1, openLookMargin-2, r.height()-2, handleColour);

  p.setPen(widget()->palette().dark());

  p.drawLine(x1 + 1, y1 + openLookMargin-1, x2 - openLookMargin+1, y1 + openLookMargin-1);
  p.drawLine(x2, y1 + 1, x2, y2);
  p.drawLine(x2 - openLookMargin+1, y2, x2 - 1, y2);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void OpenLook::OpenLook::resize ( const QSize &  s) [protected]

Definition at line 234 of file OpenLook.cpp.

{
    widget()->resize(s);
    widget()->repaint(); //there is some strange wrong repaint of the frame without
}
void OpenLook::OpenLook::resizeEvent ( QResizeEvent *  e) [protected]

Definition at line 296 of file OpenLook.cpp.

{
  widget()->update();
}

Here is the caller graph for this function:

void OpenLook::OpenLook::shadeChange ( ) [protected]

Definition at line 222 of file OpenLook.cpp.

{
}
void OpenLook::OpenLook::showEvent ( QShowEvent *  e) [protected]

Definition at line 281 of file OpenLook.cpp.

{
    widget()->repaint();
}

Here is the caller graph for this function:

QRect OpenLook::OpenLook::titleRect ( ) const [private]

Definition at line 694 of file OpenLook.cpp.

{
  return titleSpacer_->geometry();
}

Here is the caller graph for this function:

QRect OpenLook::OpenLook::topLeftRect ( ) const [private]

Definition at line 425 of file OpenLook.cpp.

{
  return QRect
    (
     0,
     0,
     openLookCornerSize,
     openLookCornerSize
    );
}

Here is the caller graph for this function:

QRect OpenLook::OpenLook::topRightRect ( ) const [private]

Definition at line 437 of file OpenLook.cpp.

Here is the caller graph for this function:


Member Data Documentation

Definition at line 105 of file OpenLook.h.

Definition at line 103 of file OpenLook.h.

QSpacerItem* OpenLook::OpenLook::titleSpacer_ [private]

Definition at line 102 of file OpenLook.h.

bool OpenLook::OpenLook::tool_ [private]

Definition at line 104 of file OpenLook.h.


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