Back to index

kdeartwork  4.3.2
Public Slots | Signals | Public Member Functions | Protected Member Functions | Private Attributes
RiscOS::Manager Class Reference

#include <Manager.h>

List of all members.

Public Slots

void slotAbove ()
void slotLower ()
void slotMaximizeClicked (Qt::MouseButton)
void slotToggleSticky ()

Signals

void maximizeChanged (bool)
void stickyChanged (bool)
void activeChanged (bool)

Public Member Functions

 Manager (KDecorationBridge *, KDecorationFactory *)
 ~Manager ()
void init ()
bool eventFilter (QObject *, QEvent *)
void reset (unsigned long changed)
void borders (int &, int &, int &, int &) const
void resize (const QSize &)
QSize minimumSize () const
void activeChange ()
void captionChange ()
void iconChange ()
void maximizeChange ()
void desktopChange ()
void shadeChange ()

Protected Member Functions

KDecoration::Position mousePosition (const QPoint &) const
void paletteChange (const QPalette &)
void activeChange (bool)
void stickyChange (bool)
void paintEvent (QPaintEvent *)
void resizeEvent (QResizeEvent *)
void mouseDoubleClickEvent (QMouseEvent *)
bool animateMinimize (bool)
void updateButtonVisibility ()
void updateTitleBuffer ()
void createTitle ()
void resetLayout ()

Private Attributes

QVBoxLayout * topLayout_
QBoxLayout * titleLayout_
QSpacerItem * titleSpacer_
QPixmap titleBuf_
Q3PtrList< ButtonleftButtonList_
Q3PtrList< ButtonrightButtonList_

Detailed Description

Definition at line 54 of file Manager.h.


Constructor & Destructor Documentation

RiscOS::Manager::Manager ( KDecorationBridge *  bridge,
KDecorationFactory *  factory 
)

Definition at line 65 of file Manager.cpp.

  : KDecoration(bridge, factory),
    topLayout_    (NULL),
    titleLayout_  (NULL),
    titleSpacer_  (NULL)
{
}

Definition at line 74 of file Manager.cpp.

{
}

Member Function Documentation

Definition at line 147 of file Manager.cpp.

{
   updateTitleBuffer();
   widget()->repaint();
   emit(activeChanged(isActive()));
}

Here is the call graph for this function:

void RiscOS::Manager::activeChange ( bool  ) [protected]
void RiscOS::Manager::activeChanged ( bool  ) [signal]

Here is the caller graph for this function:

bool RiscOS::Manager::animateMinimize ( bool  iconify) [protected]

Definition at line 396 of file Manager.cpp.

{
   int style = Static::instance()->animationStyle();

   switch (style)
   {
      case 1:
      {
         // Double twisting double back, with pike ;)

         if (!iconify) // No animation for restore.
            return true;

         // Go away quick.
         helperShowHide(false);
         qApp->syncX();

         QRect r = iconGeometry();

         if (!r.isValid())
            return true;

         // Algorithm taken from Window Maker (http://www.windowmaker.org)

         int sx = geometry().x();
         int sy = geometry().y();
         int sw = width();
         int sh = height();
         int dx = r.x();
         int dy = r.y();
         int dw = r.width();
         int dh = r.height();

         double steps = 12;

         double xstep = double((dx-sx)/steps);
         double ystep = double((dy-sy)/steps);
         double wstep = double((dw-sw)/steps);
         double hstep = double((dh-sh)/steps);

         double cx = sx;
         double cy = sy;
         double cw = sw;
         double ch = sh;

         double finalAngle = 3.14159265358979323846;

         double delta  = finalAngle / steps;

         QPainter p(workspaceWidget());
         p.setRasterOp(Qt::NotROP);

         for (double angle = 0; ; angle += delta)
         {
            if (angle > finalAngle)
               angle = finalAngle;

            double dx = (cw / 10) - ((cw / 5) * sin(angle));
            double dch = (ch / 2) * cos(angle);
            double midy = cy + (ch / 2);

            QPoint p1(int(cx + dx), int(midy - dch));
            QPoint p2(int(cx + cw - dx), p1.y());
            QPoint p3(int(cx + dw + dx), int(midy + dch));
            QPoint p4(int(cx - dx), p3.y());

            grabXServer();

            p.drawLine(p1, p2);
            p.drawLine(p2, p3);
            p.drawLine(p3, p4);
            p.drawLine(p4, p1);

            p.flush();

            usleep(500);

            p.drawLine(p1, p2);
            p.drawLine(p2, p3);
            p.drawLine(p3, p4);
            p.drawLine(p4, p1);

            ungrabXServer();

            cx += xstep;
            cy += ystep;
            cw += wstep;
            ch += hstep;

            if (angle >= finalAngle)
               break;
         }
      }
      break;

      case 2:
      {
         // KVirc style ? Maybe. For qwertz.

         if (!iconify) // No animation for restore.
            return true;

         // Go away quick.
         helperShowHide(false);
         qApp->syncX();

         int stepCount = 12;

         QRect r(geometry());

         int dx = r.width() / (stepCount * 2);
         int dy = r.height() / (stepCount * 2);

         QPainter p(workspaceWidget());
         p.setRasterOp(Qt::NotROP);

         for (int step = 0; step < stepCount; step++)
         {
            r.moveBy(dx, dy);
            r.setWidth(r.width() - 2 * dx);
            r.setHeight(r.height() - 2 * dy);

            grabXServer();

            p.drawRect(r);
            p.flush();
            usleep(200);
            p.drawRect(r);

            ungrabXServer();
         }
      }
      break;


      default:
      {
         QRect icongeom = iconGeometry();

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

         QRect wingeom = geometry();

         QPainter p(workspaceWidget());

         p.setRasterOp(Qt::NotROP);
#if 0
         if (iconify)
            p.setClipRegion(QRegion(workspaceWidget()->rect()) - wingeom);
#endif
         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();

         qApp->syncX();

         usleep(30000);

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

         ungrabXServer();
      }
      break;
   }
   return true;
}

Here is the call graph for this function:

void RiscOS::Manager::borders ( int &  left,
int &  right,
int &  top,
int &  bottom 
) const

Definition at line 130 of file Manager.cpp.

{
   left = right = 1;
   top = Static::instance()->titleHeight();
   bottom = isResizable() ? Static::instance()->resizeHeight() : 1;
}

Here is the call graph for this function:

Definition at line 154 of file Manager.cpp.

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

Here is the call graph for this function:

void RiscOS::Manager::createTitle ( ) [protected]

Definition at line 572 of file Manager.cpp.

{
   leftButtonList_.clear();
   rightButtonList_.clear();

   QString buttons;

   if (options()->customButtonPositions())
      buttons = options()->titleButtonsLeft() + "|" +
                options()->titleButtonsRight();
   else
      buttons = "XSH|IA";

   Q3PtrList<Button> *buttonList = &leftButtonList_;

   for (unsigned int i = 0; i < buttons.length(); ++i)
   {
      Button * tb = NULL;

      switch (buttons[i].latin1())
      {
         case 'S': // Sticky
            tb = new StickyButton(widget());
            connect(this, SIGNAL(stickyChanged(bool)),
                    tb, SLOT(setOn(bool)));
            connect(tb, SIGNAL(toggleSticky()), this, SLOT(slotToggleSticky()));
            emit(stickyChanged(isOnAllDesktops()));
            break;

         case 'H': // Help
            if (providesContextHelp())
            {
               tb = new HelpButton(widget());
               connect(tb, SIGNAL(help()), this, SLOT(showContextHelp()));
            }
            break;

         case 'I': // Minimize
            if (isMinimizable())
            {
               tb = new IconifyButton(widget());
               connect(tb, SIGNAL(iconify()), this, SLOT(minimize()));
            }
            break;

         case 'A': // Maximize
            if (isMaximizable())
            {
               tb = new MaximiseButton(widget());
               connect(tb, SIGNAL(maximizeClicked(MouseButton)),
                       this, SLOT(slotMaximizeClicked(MouseButton)));
               connect(this, SIGNAL(maximizeChanged(bool)),
                       tb, SLOT(setOn(bool)));
               emit(maximizeChanged(maximizeMode() == MaximizeFull));
            }
            break;

         case 'F': // Above
            tb = new AboveButton(widget());
            connect(tb, SIGNAL(above()), this, SLOT(slotAbove()));
            break;

         case 'B': // Lower
            tb = new LowerButton(widget());
            connect(tb, SIGNAL(lower()), this, SLOT(slotLower()));
            break;

         case 'X': // Close
            if (isCloseable())
            {
               tb = new CloseButton(widget());
               connect(tb, SIGNAL(closeWindow()), this, SLOT(closeWindow()));
            }
            break;

         case '|':
            buttonList = &rightButtonList_;
            break;
      }

      if (tb != NULL)
      {
         connect(this, SIGNAL(activeChanged(bool)), tb, SLOT(setActive(bool)));
         buttonList->append(tb);
      }
   }

   for (Q3PtrListIterator<Button> it(leftButtonList_); it.current(); ++it)
   {
      it.current()->setAlignment(Button::Left);
      titleLayout_->addWidget(it.current());
   }

   titleSpacer_ = new QSpacerItem(0, Static::instance()->titleHeight(),
                                  QSizePolicy::Expanding, QSizePolicy::Fixed);

   titleLayout_->addItem(titleSpacer_);

   for (Q3PtrListIterator<Button> it(rightButtonList_); it.current(); ++it)
   {
      it.current()->setAlignment(Button::Right);
      titleLayout_->addWidget(it.current());
   }
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 169 of file Manager.cpp.

{
}
bool RiscOS::Manager::eventFilter ( QObject *  o,
QEvent *  e 
)

Definition at line 91 of file Manager.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::MouseButtonRelease:
         return false;
      case QEvent::Show:
         return false;
      case QEvent::MouseMove:
         return false;
      case QEvent::Enter:
         return false;
      case QEvent::Leave:
         return false;
      case QEvent::Move:
         return false;
      default:
         return false;
   }
}

Here is the call graph for this function:

Definition at line 160 of file Manager.cpp.

{
}

Definition at line 78 of file Manager.cpp.

{
   createMainWidget(WNoAutoErase);

   widget()->installEventFilter(this);
   widget()->setBackgroundMode(NoBackground);

   leftButtonList_.setAutoDelete(true);
   rightButtonList_.setAutoDelete(true);

   resetLayout();
}

Here is the call graph for this function:

Definition at line 164 of file Manager.cpp.

{
   emit(maximizeChanged(maximizeMode() == MaximizeFull));
}

Here is the call graph for this function:

void RiscOS::Manager::maximizeChanged ( bool  ) [signal]

Here is the caller graph for this function:

Definition at line 142 of file Manager.cpp.

{
   return widget()->minimumSize();
}
void RiscOS::Manager::mouseDoubleClickEvent ( QMouseEvent *  e) [protected]

Definition at line 358 of file Manager.cpp.

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

Here is the caller graph for this function:

KDecoration::Position RiscOS::Manager::mousePosition ( const QPoint &  p) const [protected]

Definition at line 324 of file Manager.cpp.

{
   Position m = PositionCenter;

   // Look out for off-by-one errors here.

   if (isResizable())
   {
      if (p.y() > (height() - (Static::instance()->resizeHeight() + 1)))
      {
        // Keep order !

         if (p.x() >= (width() - 30))
            m = PositionBottomRight;
         else if (p.x() <= 30)
            m = PositionBottomLeft;
         else
            m = PositionBottom;
      }
      else
      {
         m = PositionCenter;
         // Client::mousePosition(p);
      }
   }
   else
   {
      m = PositionCenter;
      // Client::mousePosition(p);
   }

   return m;
}

Here is the call graph for this function:

void RiscOS::Manager::paintEvent ( QPaintEvent *  e) [protected]

Definition at line 177 of file Manager.cpp.

{
   QPainter p(widget());

   QRect r(e->rect());

   bool intersectsLeft = r.intersects(QRect(0, 0, 1, height()));

   bool intersectsRight =
      r.intersects(QRect(width() - 1, 0, width(), height()));

   if (intersectsLeft || intersectsRight)
   {
      p.setPen(Qt::black);

      if (intersectsLeft)
         p.drawLine(0, r.top(), 0, r.bottom());

      if (intersectsRight)
         p.drawLine(width() - 1, r.top(), width() - 1, r.bottom());
   }

   Static * s = Static::instance();

   bool active = isActive();

   // Title bar.

   QRect tr = titleSpacer_->geometry();
   bitBlt(widget(), tr.topLeft(), &titleBuf_);

   // Resize bar.

   if (isResizable())
   {
      int rbt = height() - Static::instance()->resizeHeight(); // Resize bar top

      bitBlt(widget(), 0, rbt, &(s->resize(active)));
      bitBlt(widget(), 30, rbt, &(s->resizeMidLeft(active)));

      p.drawTiledPixmap(32, rbt, width() - 34,
                        Static::instance()->resizeHeight(),
                        s->resizeMidMid(active));

      bitBlt(widget(), width() - 32, rbt, &(s->resizeMidRight(active)));
      bitBlt(widget(), width() - 30, rbt, &(s->resize(active)));
   }
   else
      p.drawLine(1, height() - 1, width() - 2, height() - 1);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void RiscOS::Manager::paletteChange ( const QPalette &  ) [protected]

Definition at line 364 of file Manager.cpp.

{
   resetLayout();
}

Here is the call graph for this function:

void RiscOS::Manager::reset ( unsigned long  changed)

Definition at line 125 of file Manager.cpp.

{
   resetLayout();
}

Here is the call graph for this function:

void RiscOS::Manager::resetLayout ( ) [protected]

Definition at line 677 of file Manager.cpp.

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

   titleLayout_ = new QBoxLayout(topLayout_, QBoxLayout::LeftToRight, 0, 0);
   titleLayout_->setResizeMode(QLayout::FreeResize);

   createTitle();

   QBoxLayout *midLayout = new QBoxLayout(topLayout_, QBoxLayout::LeftToRight,
                                          0, 0);
   midLayout->setResizeMode(QLayout::FreeResize);
   midLayout->addSpacing(1);
   if (isPreview())
      midLayout->addWidget(
         new QLabel(i18n("<center><b>RiscOS preview</b></center>"), widget()));
   midLayout->addSpacing(1);

   if (isResizable())
      topLayout_->addSpacing(Static::instance()->resizeHeight());
   else
      topLayout_->addSpacing(1);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void RiscOS::Manager::resize ( const QSize &  s)

Definition at line 137 of file Manager.cpp.

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

Definition at line 228 of file Manager.cpp.

{
   updateButtonVisibility();
   updateTitleBuffer();
   widget()->repaint();
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 173 of file Manager.cpp.

{
}
void RiscOS::Manager::slotAbove ( ) [slot]

Definition at line 380 of file Manager.cpp.

{
   setKeepAbove(!keepAbove());
}

Here is the caller graph for this function:

void RiscOS::Manager::slotLower ( ) [slot]

Definition at line 385 of file Manager.cpp.

{
   setKeepBelow(!keepBelow());
}

Here is the caller graph for this function:

void RiscOS::Manager::slotMaximizeClicked ( Qt::MouseButton  state) [slot]

Definition at line 390 of file Manager.cpp.

{
   maximize(state);
   emit(maximizeChanged(maximizeMode() == MaximizeFull));
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 374 of file Manager.cpp.

{
   toggleOnAllDesktops();
   emit(stickyChanged(isOnAllDesktops()));
}

Here is the call graph for this function:

Here is the caller graph for this function:

void RiscOS::Manager::stickyChange ( bool  b) [protected]

Definition at line 369 of file Manager.cpp.

{
   emit(stickyChanged(b));
}

Here is the call graph for this function:

void RiscOS::Manager::stickyChanged ( bool  ) [signal]

Here is the caller graph for this function:

Definition at line 235 of file Manager.cpp.

{
#if 0
   enum SizeProblem = { None, Small, Medium, Big };
   SizeProblem sizeProblem = None;

   if (width() < 80) sizeProblem = Big;
   else if (width() < 100) sizeProblem = Medium;
   else if (width() < 180) sizeProblem = Small;

   switch (sizeProblem) {

      case Small:
         above_    ->hide();
         lower_    ->hide();
         sticky_   ->hide();
         help_     ->hide();
         iconify_  ->show();
         maximise_ ->hide();
         close_    ->show();
         break;

      case Medium:
         above_    ->hide();
         lower_    ->hide();
         sticky_   ->hide();
         help_     ->hide();
         iconify_  ->hide();
         maximise_ ->hide();
         close_    ->show();
         break;

      case Big:
         above_    ->hide();
         lower_    ->hide();
         sticky_   ->hide();
         help_     ->hide();
         iconify_  ->hide();
         maximise_ ->hide();
         close_    ->hide();
         break;

      case None:
      default:
         above_    ->show();
         lower_    ->show();
         sticky_   ->show();
         if (providesContextHelp())
           help_->show();
         iconify_  ->show();
         maximise_ ->show();
         close_    ->show();
         break;
   }

   layout()->activate();
#endif
}

Here is the caller graph for this function:

void RiscOS::Manager::updateTitleBuffer ( ) [protected]

Definition at line 294 of file Manager.cpp.

{
   bool active = isActive();

   Static * s = Static::instance();

   QRect tr = titleSpacer_->geometry();

   if (tr.width() == 0 || tr.height() == 0)
      titleBuf_.resize(8, 8);
   else
      titleBuf_.resize(tr.size());

   QPainter p(&titleBuf_);

   p.drawPixmap(0, 0, s->titleTextLeft(active));

   p.drawTiledPixmap(3, 0, tr.width() - 6, Static::instance()->titleHeight(),
                     s->titleTextMid(active));

   p.setPen(options()->color(KDecorationOptions::ColorFont, active));

   p.setFont(options()->font(active));

   p.drawText(4, 2, tr.width() - 8, Static::instance()->titleHeight() - 4,
              Qt::AlignCenter, caption());

   p.drawPixmap(tr.width() - 3, 0, s->titleTextRight(active));
}

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

Definition at line 111 of file Manager.h.

Definition at line 112 of file Manager.h.

QPixmap RiscOS::Manager::titleBuf_ [private]

Definition at line 110 of file Manager.h.

QBoxLayout* RiscOS::Manager::titleLayout_ [private]

Definition at line 107 of file Manager.h.

QSpacerItem* RiscOS::Manager::titleSpacer_ [private]

Definition at line 108 of file Manager.h.

QVBoxLayout* RiscOS::Manager::topLayout_ [private]

Definition at line 106 of file Manager.h.


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