Back to index

kdeartwork  4.3.2
Public Types | Public Member Functions | Protected Slots | Protected Member Functions | Protected Attributes | Private Attributes
RiscOS::Button Class Reference

#include <Button.h>

Inheritance diagram for RiscOS::Button:
Inheritance graph
[legend]

List of all members.

Public Types

enum  Type {
  Lower, Close, Iconify, Maximise,
  Sticky, Help
}
enum  Alignment { Left, Right }

Public Member Functions

 Button (QWidget *parent, const QString &tip, const Qt::MouseButtons realizeButton=Qt::LeftButton)
virtual ~Button ()
void setAlignment (Alignment)
Alignment alignment () const

Protected Slots

void setActive (bool)

Protected Member Functions

void paintEvent (QPaintEvent *)
void mousePressEvent (QMouseEvent *)
void mouseReleaseEvent (QMouseEvent *)
void mouseMoveEvent (QMouseEvent *)
void setPixmap (const QPixmap &)

Protected Attributes

Qt::MouseButtons realizeButtons_
Qt::MouseButton lastButton_

Private Attributes

Alignment alignment_
bool down_
bool active_
QPixmap aPixmap_
QPixmap iPixmap_

Detailed Description

Definition at line 37 of file Button.h.


Member Enumeration Documentation

Enumerator:
Left 
Right 

Definition at line 45 of file Button.h.

{ Left, Right };
Enumerator:
Lower 
Close 
Iconify 
Maximise 
Sticky 
Help 

Definition at line 43 of file Button.h.


Constructor & Destructor Documentation

RiscOS::Button::Button ( QWidget *  parent,
const QString &  tip,
const Qt::MouseButtons  realizeButton = Qt::LeftButton 
)

Definition at line 35 of file Button.cpp.

  : QWidget(parent, "Button", 0),
    realizeButtons_(realizeButtons),
    lastButton_(Qt::NoButton),
    alignment_(Left),
    down_     (false),
    active_   (false)
{
   this->setToolTip( tip);
   setBackgroundColor(Qt::black);

   setFixedSize(Static::instance()->titleHeight() - 1,
                Static::instance()->titleHeight());
}

Here is the call graph for this function:

RiscOS::Button::~Button ( ) [virtual]

Definition at line 51 of file Button.cpp.

{
  // Empty.
}

Member Function Documentation

Definition at line 68 of file Button.cpp.

{
   return alignment_;
}
void RiscOS::Button::mouseMoveEvent ( QMouseEvent *  ) [inline, protected]

Definition at line 65 of file Button.h.

{ /* Empty. */ }
void RiscOS::Button::mousePressEvent ( QMouseEvent *  e) [protected]

Definition at line 73 of file Button.cpp.

{
   down_ = true;
   lastButton_ = e->button();
   repaint();

   QMouseEvent me(e->type(), e->pos(), e->globalPos(),
                  (e->button()&realizeButtons_) ? Qt::LeftButton : Qt::NoButton,
                  e->state());
   QWidget::mousePressEvent(&me);
}
void RiscOS::Button::mouseReleaseEvent ( QMouseEvent *  e) [protected]

Reimplemented in RiscOS::MaximiseButton, RiscOS::StickyButton, RiscOS::AboveButton, RiscOS::CloseButton, RiscOS::HelpButton, RiscOS::IconifyButton, and RiscOS::LowerButton.

Definition at line 85 of file Button.cpp.

{
   down_ = false;
   lastButton_ = e->button();
   repaint();
   QMouseEvent me(e->type(), e->pos(), e->globalPos(),
                  (e->button()&realizeButtons_) ? Qt::LeftButton : Qt::NoButton,
                  e->state());
   QWidget::mouseReleaseEvent(&me);
}
void RiscOS::Button::paintEvent ( QPaintEvent *  ) [protected]

Definition at line 144 of file Button.cpp.

{
   bitBlt(this, alignment_ == Left ? 1 : 0, 0,
          &Static::instance()->buttonBase(active_, down_));

   int i = width() / 2 - 6;

   bitBlt(this, alignment_ == Left ? i + 1 : i,
          i + 1, active_ ? &aPixmap_ : &iPixmap_);
}

Here is the call graph for this function:

void RiscOS::Button::setActive ( bool  b) [protected, slot]

Definition at line 62 of file Button.cpp.

{
   active_ = b;
   repaint();
}

Definition at line 56 of file Button.cpp.

{
   alignment_ = a;
   repaint();
}
void RiscOS::Button::setPixmap ( const QPixmap &  p) [protected]

Definition at line 96 of file Button.cpp.

{
   if (QPixmap::defaultDepth() <= 8)
      aPixmap_ = iPixmap_ = p;
   else
   {
      QRgb light;
      QRgb* data = NULL;
      QRgb w = qRgb(255, 255, 255);

      QImage aTx(p.convertToImage());
      QImage iTx(aTx.copy());

      const KDecorationOptions* options = KDecoration::options();
      light = options->color(KDecoration::ColorButtonBg, true).light(150).rgb();

      if (light == qRgb(0, 0, 0))
         light = qRgb(228, 228, 228);

      data = (QRgb *)aTx.bits();

      for (int x = 0; x < 144; x++)
         if (data[x] == w)
            data[x] = light;

      light = options->color(KDecoration::ColorButtonBg, false).light(150).rgb();

      if (light == qRgb(0, 0, 0))
         light = qRgb(228, 228, 228);

      data = (QRgb *)iTx.bits();

      for (int x = 0; x < 144; x++)
         if (data[x] == w)
            data[x] = light;

      aPixmap_.convertFromImage(aTx);
      iPixmap_.convertFromImage(iTx);

      if (!p.mask().isNull())
      {
         aPixmap_.setMask(p.mask());
         iPixmap_.setMask(p.mask());
      }
   }
   repaint();
}

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

bool RiscOS::Button::active_ [private]

Definition at line 76 of file Button.h.

Definition at line 74 of file Button.h.

QPixmap RiscOS::Button::aPixmap_ [private]

Definition at line 77 of file Button.h.

bool RiscOS::Button::down_ [private]

Definition at line 75 of file Button.h.

QPixmap RiscOS::Button::iPixmap_ [private]

Definition at line 77 of file Button.h.

Qt::MouseButton RiscOS::Button::lastButton_ [protected]

Definition at line 70 of file Button.h.

Qt::MouseButtons RiscOS::Button::realizeButtons_ [protected]

Definition at line 69 of file Button.h.


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