Qt 4.8
Public Functions | Protected Functions | Protected Variables | Static Private Attributes | List of all members
QDecorationDefault Class Reference

The QDecorationDefault class is a base class providing default window decorations. More...

#include <qdecorationdefault_qws.h>

Inheritance diagram for QDecorationDefault:
QDecoration QDecorationStyled QDecorationWindows

Public Functions

virtual bool paint (QPainter *painter, const QWidget *widget, int decorationRegion=All, DecorationState state=Normal)
 Paints the border and title decoration for the top-level widget using the painter provided and the decoration state. More...
 
 QDecorationDefault ()
 Default constructor. More...
 
virtual QRegion region (const QWidget *widget, const QRect &rect, int decorationRegion=All)
 Returns the region specified by decorationRegion for the top-level widget. More...
 
virtual ~QDecorationDefault ()
 The constructor deletes the static pixmaps. More...
 
- Public Functions inherited from QDecoration
virtual void buildSysMenu (QWidget *widget, QMenu *menu)
 Builds the system menu for the given top level widget, adding Restore, Move, Size, Minimize, Maximize and Close actions to the given menu. More...
 
void menuTriggered (QWidget *widget, QAction *action)
 This function is called whenever an action in a top level widget's menu is triggered, and simply calls the regionClicked() function passing the widget and action parameters as arguments. More...
 
 QDecoration ()
 Constructs a decoration object. More...
 
QRegion region (const QWidget *w, int decorationRegion=All)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. More...
 
virtual int regionAt (const QWidget *w, const QPoint &point)
 Returns the type of the first region of the specified top level widget containing the given point. More...
 
virtual void regionClicked (QWidget *widget, int region)
 Handles the event that the specified region in the given top level widget is activated by a single click (the region parameter is described using the DecorationRegion enum). More...
 
virtual void regionDoubleClicked (QWidget *widget, int region)
 Handles the event that the specified region in the given top level widget is activated by a double click (the region parameter is described using the DecorationRegion enum). More...
 
virtual ~QDecoration ()
 Destroys this decoration object. More...
 

Protected Functions

virtual void paintButton (QPainter *painter, const QWidget *widget, int buttonRegion, DecorationState state, const QPalette &pal)
 Paints a region of the top-level widget. More...
 
virtual QPixmap pixmapFor (const QWidget *widget, int decorationRegion, int &xoff, int &yoff)
 Returns a pointer to the QPixmap for the widget specified by widget and decorationRegion. More...
 
virtual int titleBarHeight (const QWidget *widget)
 Returns the title bar height in pixels for the given widget. More...
 
QString windowTitleFor (const QWidget *widget) const
 
virtual const char ** xpmForRegion (int region)
 Returns a pointer to the X pixmap for the icon specified by region. More...
 

Protected Variables

int close_width
 
int help_width
 
int maximize_width
 
int menu_width
 
int minimize_width
 
int normalize_width
 

Static Private Attributes

static QPixmapstaticClosePixmap = 0
 
static QPixmapstaticHelpPixmap = 0
 
static QPixmapstaticMaximizePixmap = 0
 
static QPixmapstaticMenuPixmap = 0
 
static QPixmapstaticMinimizePixmap = 0
 
static QPixmapstaticNormalizePixmap = 0
 

Additional Inherited Members

- Public Types inherited from QDecoration
enum  DecorationRegion {
  None = 0x0000000000, All = 0x7fffffff, TopLeft = 0x0000000001, Top = 0x0000000002,
  TopRight = 0x0000000004, Left = 0x0000000008, Right = 0x0000000010, BottomLeft = 0x0000000020,
  Bottom = 0x0000000040, BottomRight = 0x0000000080, Borders = 0x00000000ff, Menu = 0x0000000100,
  Title = 0x0000000200, Help = 0x0000000400, Minimize = 0x0000000800, Maximize = 0x0000001000,
  Normalize = 0x0000002000, Close = 0x0000004000, Move = 0x0000008000, Resize = 0x0000010000
}
 This enum describes the various regions of the window decoration. More...
 
enum  DecorationState { Normal = 0x04, Disabled = 0x08, Hover = 0x01, Pressed = 0x02 }
 This enum describes the various states of a decoration region. More...
 
- Static Public Functions inherited from QDecoration
static void startMove (QWidget *widget)
 Starts to move the given top level widget by making its Title region active and grabbing the mouse input. More...
 
static void startResize (QWidget *widget)
 Starts to resize the given top level widget by making its BottomRight region active and grabbing the mouse input. More...
 

Detailed Description

The QDecorationDefault class is a base class providing default window decorations.

Since
4.4

See the documentation for class QDecoration for a detailed description. This subclass of QDecoration provides standard icons for the decoration regions.

Note that this class is non-portable and only available in Qt for Embedded Linux.

Definition at line 59 of file qdecorationdefault_qws.h.

Constructors and Destructors

◆ QDecorationDefault()

QDecorationDefault::QDecorationDefault ( )

Default constructor.

Definition at line 229 of file qdecorationdefault_qws.cpp.

230  : QDecoration()
231 {
232  menu_width = 20;
233  help_width = 20;
234  close_width = 20;
235  minimize_width = 20;
236  maximize_width = 20;
237  normalize_width = 20;
238 }
QDecoration()
Constructs a decoration object.

◆ ~QDecorationDefault()

QDecorationDefault::~QDecorationDefault ( )
virtual

The constructor deletes the static pixmaps.

Definition at line 243 of file qdecorationdefault_qws.cpp.

244 {
245  delete staticMenuPixmap;
246  delete staticClosePixmap;
247  delete staticMinimizePixmap;
248  delete staticMaximizePixmap;
249  delete staticNormalizePixmap;
250 
251  // This makes it safe to delete and then create a QDecorationDefault
252  staticMenuPixmap = 0;
253  staticClosePixmap = 0;
257 }
static QPixmap * staticNormalizePixmap
static QPixmap * staticMenuPixmap
static QPixmap * staticMinimizePixmap
static QPixmap * staticMaximizePixmap
static QPixmap * staticClosePixmap

Functions

◆ paint()

bool QDecorationDefault::paint ( QPainter painter,
const QWidget widget,
int  decorationRegion = All,
DecorationState  state = Normal 
)
virtual

Paints the border and title decoration for the top-level widget using the painter provided and the decoration state.

The value of decorationRegion is a combination of the bitmask values of enum DecorationRegion.

Note that Qt for Embedded Linux expects this function to return true if any of the widget's decorations are repainted; otherwise it returns false.

Implements QDecoration.

Reimplemented in QDecorationStyled, and QDecorationWindows.

Definition at line 644 of file qdecorationdefault_qws.cpp.

Referenced by QDecorationWindows::paint().

648 {
649  if (decorationRegion == None)
650  return false;
651 
652  const QRect titleRect = QDecoration::region(widget, Title).boundingRect();
653  const QPalette pal = QApplication::palette();
654  int titleHeight = titleRect.height();
655  int titleWidth = titleRect.width();
656  QRegion oldClipRegion = painter->clipRegion();
657 
658 
659  Qt::WindowFlags flags = widget->windowFlags();
660  bool hasBorder = !widget->isMaximized();
661  bool hasTitle = flags & Qt::WindowTitleHint;
662  bool hasSysMenu = flags & Qt::WindowSystemMenuHint;
663  bool hasContextHelp = flags & Qt::WindowContextHelpButtonHint;
664  bool hasMinimize = flags & Qt::WindowMinimizeButtonHint;
665  bool hasMaximize = flags & Qt::WindowMaximizeButtonHint;
666 
667  bool paintAll = (decorationRegion == int(All));
668  bool handled = false;
669 
670  bool porterDuff = painter->paintEngine()->hasFeature(QPaintEngine::PorterDuff);
671 
672  if ((paintAll || decorationRegion & Borders) && state == Normal && hasBorder) {
673  if (hasTitle) { // reduce flicker
674  QRect rect(widget->rect());
675  QRect r(rect.left(), rect.top() - titleHeight,
676  rect.width(), titleHeight);
677  painter->setClipRegion(oldClipRegion - r);
678  }
679  QRect br = QDecoration::region(widget).boundingRect();
680  if (porterDuff)
682  qDrawWinPanel(painter, br.x(), br.y(), br.width(),
683  br.height(), pal, false,
684  &pal.brush(QPalette::Window));
685  if (porterDuff)
687  handled |= true;
688  }
689 
690  if ((paintAll || decorationRegion & Title && titleWidth > 0) && state == Normal && hasTitle) {
691  painter->setClipRegion(oldClipRegion);
692  QBrush titleBrush;
693  QPen titlePen;
694 
695  if (widget == qApp->activeWindow()) {
696  titleBrush = pal.brush(QPalette::Highlight);
697  titlePen = pal.color(QPalette::HighlightedText);
698  } else {
699  titleBrush = pal.brush(QPalette::Window);
700  titlePen = pal.color(QPalette::Text);
701  }
702 
703  if (porterDuff)
705  qDrawShadePanel(painter,
706  titleRect.x(), titleRect.y(), titleRect.width(), titleRect.height(),
707  pal, true, 1, &titleBrush);
708  if (porterDuff)
710 
711  painter->setPen(titlePen);
712  painter->drawText(titleRect.x() + 4, titleRect.y(),
713  titleRect.width() - 8, titleRect.height(),
715  handled |= true;
716  }
717 
718  if (state != Hover) {
719  painter->setClipRegion(oldClipRegion);
720  if ((paintAll || decorationRegion & Menu) && hasSysMenu) {
721  paintButton(painter, widget, Menu, state, pal);
722  handled |= true;
723  }
724 
725  if ((paintAll || decorationRegion & Help) && hasContextHelp) {
726  paintButton(painter, widget, Help, state, pal);
727  handled |= true;
728  }
729 
730  if ((paintAll || decorationRegion & Minimize) && hasMinimize) {
731  paintButton(painter, widget, Minimize, state, pal);
732  handled |= true;
733  }
734 
735  if ((paintAll || decorationRegion & Maximize) && hasMaximize) {
736  paintButton(painter, widget,
737  ((widget->windowState() & Qt::WindowMaximized)? Normalize : Maximize),
738  state, pal);
739  handled |= true;
740  }
741 
742  if (paintAll || decorationRegion & Close) {
743  paintButton(painter, widget, Close, state, pal);
744  handled |= true;
745  }
746  }
747  return handled;
748 }
virtual void paintButton(QPainter *painter, const QWidget *widget, int buttonRegion, DecorationState state, const QPalette &pal)
Paints a region of the top-level widget.
Qt::WindowStates windowState() const
Returns the current window state.
Definition: qwidget.cpp:3086
int width() const
Returns the width of the rectangle.
Definition: qrect.h:303
static QPalette palette()
Returns the application palette.
QRect boundingRect() const
Returns the bounding rectangle of this region.
Definition: qregion.cpp:4363
int height() const
Returns the height of the rectangle.
Definition: qrect.h:306
const QColor & color(ColorGroup cg, ColorRole cr) const
Returns the color in the specified color group, used for the given color role.
Definition: qpalette.h:107
The QPen class defines how a QPainter should draw lines and outlines of shapes.
Definition: qpen.h:64
virtual QRegion region(const QWidget *w, const QRect &rect, int decorationRegion=All)=0
Implement this function to return the region specified by decorationRegion for the given top level wi...
QRegion clipRegion() const
Returns the currently set clip region.
Definition: qpainter.cpp:2562
void drawText(const QPointF &p, const QString &s)
Draws the given text with the currently defined text direction, beginning at the given position...
Definition: qpainter.cpp:6231
void qDrawWinPanel(QPainter *p, int x, int y, int w, int h, const QPalette &pal, bool sunken, const QBrush *fill)
Definition: qdrawutil.cpp:475
#define qApp
QPaintEngine * paintEngine() const
Returns the paint engine that the painter is currently operating on if the painter is active; otherwi...
Definition: qpainter.cpp:1991
void qDrawShadePanel(QPainter *p, int x, int y, int w, int h, const QPalette &pal, bool sunken, int lineWidth, const QBrush *fill)
Definition: qdrawutil.cpp:303
The QRegion class specifies a clip region for a painter.
Definition: qregion.h:68
const QBrush & brush(ColorGroup cg, ColorRole cr) const
Returns the brush in the specified color group, used for the given color role.
Definition: qpalette.cpp:874
bool isMaximized() const
Definition: qwidget.cpp:3074
The QBrush class defines the fill pattern of shapes drawn by QPainter.
Definition: qbrush.h:76
QString windowTitleFor(const QWidget *widget) const
void setClipRegion(const QRegion &, Qt::ClipOperation op=Qt::ReplaceClip)
Sets the clip region to the given region using the specified clip operation.
Definition: qpainter.cpp:2917
void setCompositionMode(CompositionMode mode)
Sets the composition mode to the given mode.
Definition: qpainter.cpp:2422
QRect rect
the internal geometry of the widget excluding any window frame
Definition: qwidget.h:168
int y() const
Returns the y-coordinate of the rectangle&#39;s top edge.
Definition: qrect.h:255
int x() const
Returns the x-coordinate of the rectangle&#39;s left edge.
Definition: qrect.h:252
void setPen(const QColor &color)
Sets the painter&#39;s pen to have style Qt::SolidLine, width 0 and the specified color.
Definition: qpainter.cpp:4047
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
Qt::WindowFlags windowFlags() const
Window flags are a combination of a type (e.
Definition: qwidget.h:939
bool hasFeature(PaintEngineFeatures feature) const
Returns true if the paint engine supports the specified feature; otherwise returns false...
Definition: qpaintengine.h:229
The QPalette class contains color groups for each widget state.
Definition: qpalette.h:61

◆ paintButton()

void QDecorationDefault::paintButton ( QPainter painter,
const QWidget widget,
int  buttonRegion,
DecorationState  state,
const QPalette pal 
)
protectedvirtual

Paints a region of the top-level widget.

The region is painted in the specified decoration state using the painter and palette provided. The region to be painted is specified by buttonRegion, which is a combination of the bitmask values of DecorationRegion. If the value of buttonRegion is one of Help, Menu, Close, Minimize, Maximize, and Normalize, the button pixmap for that region is painted.

See also
pixmapFor()

Reimplemented in QDecorationWindows.

Definition at line 765 of file qdecorationdefault_qws.cpp.

Referenced by paint().

770 {
771  int xoff = 2;
772  int yoff = 2;
773 
774  const QPixmap pm = pixmapFor(widget, buttonRegion, xoff, yoff);
775  QRect brect(QDecoration::region(widget, buttonRegion).boundingRect());
776  bool porterDuff = painter->paintEngine()->hasFeature(QPaintEngine::PorterDuff);
777 
778  if (state & QDecoration::Pressed) {
779  if (porterDuff)
781  qDrawWinPanel(painter, brect, pal, true, &pal.brush(QPalette::Window));
782  if (porterDuff)
784  ++xoff;
785  ++yoff;
786  } else {
787  painter->fillRect(brect, pal.brush(QPalette::Window));
788  }
789 
790  if (!pm.isNull())
791  painter->drawPixmap(brect.x() + xoff, brect.y() + yoff, pm);
792 }
virtual QRegion region(const QWidget *w, const QRect &rect, int decorationRegion=All)=0
Implement this function to return the region specified by decorationRegion for the given top level wi...
static const QRectF boundingRect(const QPointF *points, int pointCount)
void qDrawWinPanel(QPainter *p, int x, int y, int w, int h, const QPalette &pal, bool sunken, const QBrush *fill)
Definition: qdrawutil.cpp:475
QPaintEngine * paintEngine() const
Returns the paint engine that the painter is currently operating on if the painter is active; otherwi...
Definition: qpainter.cpp:1991
const QBrush & brush(ColorGroup cg, ColorRole cr) const
Returns the brush in the specified color group, used for the given color role.
Definition: qpalette.cpp:874
void setCompositionMode(CompositionMode mode)
Sets the composition mode to the given mode.
Definition: qpainter.cpp:2422
virtual QPixmap pixmapFor(const QWidget *widget, int decorationRegion, int &xoff, int &yoff)
Returns a pointer to the QPixmap for the widget specified by widget and decorationRegion.
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
The QPixmap class is an off-screen image representation that can be used as a paint device...
Definition: qpixmap.h:71
void drawPixmap(const QRectF &targetRect, const QPixmap &pixmap, const QRectF &sourceRect)
Draws the rectangular portion source of the given pixmap into the given target in the paint device...
Definition: qpainter.cpp:5619
bool isNull() const
Returns true if this is a null pixmap; otherwise returns false.
Definition: qpixmap.cpp:615
void fillRect(const QRectF &, const QBrush &)
Fills the given rectangle with the brush specified.
Definition: qpainter.cpp:7420
bool hasFeature(PaintEngineFeatures feature) const
Returns true if the paint engine supports the specified feature; otherwise returns false...
Definition: qpaintengine.h:229

◆ pixmapFor()

QPixmap QDecorationDefault::pixmapFor ( const QWidget widget,
int  decorationRegion,
int &  xoff,
int &  yoff 
)
protectedvirtual

Returns a pointer to the QPixmap for the widget specified by widget and decorationRegion.

The returned QPixmap is constructed from the default X pixmap obtained from xpmForRegion().

xoff and yoff specify the offset for the pixmap.

The value of decorationRegion must be one of a subset of the values of enum DecorationRegion. The supported values are Help, Menu, Close, Minimize, Maximize, and Normalize. Other values of decorationRegion return 0.

See also
QDecoration::DecorationRegion

Definition at line 312 of file qdecorationdefault_qws.cpp.

Referenced by QDecorationWindows::paintButton(), and paintButton().

316 {
317 #ifdef QT_NO_IMAGEFORMAT_XPM
318  Q_UNUSED(widget);
319  Q_UNUSED(decorationRegion);
320  Q_UNUSED(xoff);
321  return QPixmap();
322 #else
323  static const char **staticHelpPixmapXPM = 0;
324  static const char **staticMenuPixmapXPM = 0;
325  static const char **staticClosePixmapXPM = 0;
326  static const char **staticMinimizePixmapXPM = 0;
327  static const char **staticMaximizePixmapXPM = 0;
328  static const char **staticNormalizePixmapXPM = 0;
329  const char **xpm;
330 
331  // Why don't we just use/extend the enum type...
332 
333  if (staticHelpPixmapXPM != (xpm = xpmForRegion(Help)) || !staticHelpPixmap) {
334  staticHelpPixmapXPM = xpm;
335  staticHelpPixmap = new QPixmap(xpm);
336  }
337  if (staticMenuPixmapXPM != (xpm = xpmForRegion(Menu)) || !staticMenuPixmap) {
338  staticMenuPixmapXPM = xpm;
339  staticMenuPixmap = new QPixmap(xpm);
340  }
341  if (staticClosePixmapXPM != (xpm = xpmForRegion(Close)) || !staticClosePixmap) {
342  staticClosePixmapXPM = xpm;
343  staticClosePixmap = new QPixmap(xpm);
344  }
345  if (staticMinimizePixmapXPM != (xpm = xpmForRegion(Minimize)) || !staticMinimizePixmap) {
346  staticMinimizePixmapXPM = xpm;
347  staticMinimizePixmap = new QPixmap(xpm);
348  }
349  if (staticMaximizePixmapXPM != (xpm = xpmForRegion(Maximize)) || !staticMaximizePixmap) {
350  staticMaximizePixmapXPM = xpm;
351  staticMaximizePixmap = new QPixmap(xpm);
352  }
353  if (staticNormalizePixmapXPM != (xpm = xpmForRegion(Normalize)) || !staticNormalizePixmap) {
354  staticNormalizePixmapXPM = xpm;
355  staticNormalizePixmap = new QPixmap(xpm);
356  }
357 
358  const QPixmap *pm = 0;
359 
360  switch (decorationRegion) {
361  case Help:
362  pm = staticHelpPixmap;
363  break;
364  case Menu:
365  if (!widget->windowIcon().isNull())
366  return widget->windowIcon().pixmap(16,16); //##### QIcon::pixmap() needs a size !!!!!!"
367  if (!pm) {
368  xoff = 1;
369  pm = staticMenuPixmap;
370  }
371  break;
372  case Close:
373  pm = staticClosePixmap;
374  break;
375  case Maximize:
377  break;
378  case Normalize:
380  break;
381  case Minimize:
383  break;
384  default:
385  break;
386  }
387  return *pm;
388 #endif
389 }
static QPixmap * staticNormalizePixmap
QIcon windowIcon
the widget&#39;s icon
Definition: qwidget.h:199
static QPixmap * staticMenuPixmap
static QPixmap * staticHelpPixmap
virtual const char ** xpmForRegion(int region)
Returns a pointer to the X pixmap for the icon specified by region.
bool isNull() const
Returns true if the icon is empty; otherwise returns false.
Definition: qicon.cpp:769
static QPixmap * staticMinimizePixmap
The QPixmap class is an off-screen image representation that can be used as a paint device...
Definition: qpixmap.h:71
QPixmap pixmap(const QSize &size, Mode mode=Normal, State state=Off) const
Returns a pixmap with the requested size, mode, and state, generating one if necessary.
Definition: qicon.cpp:693
static QPixmap * staticMaximizePixmap
#define Q_UNUSED(x)
Indicates to the compiler that the parameter with the specified name is not used in the body of a fun...
Definition: qglobal.h:1729
static QPixmap * staticClosePixmap

◆ region()

QRegion QDecorationDefault::region ( const QWidget widget,
const QRect rect,
int  decorationRegion = All 
)
virtual

Returns the region specified by decorationRegion for the top-level widget.

rect specifies the rectangle the decoration wraps. The value of decorationRegion is a combination of the bitmask values of enum DecorationRegion.

Implements QDecoration.

Reimplemented in QDecorationStyled, and QDecorationWindows.

Definition at line 409 of file qdecorationdefault_qws.cpp.

Referenced by QDecorationStyled::region(), and QDecorationWindows::region().

412 {
413  Qt::WindowFlags flags = widget->windowFlags();
414  bool hasBorder = !widget->isMaximized();
415  bool hasTitle = flags & Qt::WindowTitleHint;
416  bool hasSysMenu = flags & Qt::WindowSystemMenuHint;
417  bool hasContextHelp = flags & Qt::WindowContextHelpButtonHint;
418  bool hasMinimize = flags & Qt::WindowMinimizeButtonHint;
419  bool hasMaximize = flags & Qt::WindowMaximizeButtonHint;
420  int state = widget->windowState();
421  bool isMinimized = state & Qt::WindowMinimized;
422  bool isMaximized = state & Qt::WindowMaximized;
423 
424  int titleHeight = hasTitle ? titleBarHeight(widget) : 0;
425  int bw = hasBorder ? BORDER_WIDTH : 0;
426  int bbw = hasBorder ? BOTTOM_BORDER_WIDTH : 0;
427 
428  QRegion region;
429  switch (decorationRegion) {
430  case All: {
431  QRect r(rect.left() - bw,
432  rect.top() - titleHeight - bw,
433  rect.width() + 2 * bw,
434  rect.height() + titleHeight + bw + bbw);
435  region = r;
436  region -= rect;
437  }
438  break;
439 
440  case Title: {
441  QRect r(rect.left()
442  + (hasSysMenu ? menu_width : 0),
443  rect.top() - titleHeight,
444  rect.width()
445  - (hasSysMenu ? menu_width : 0)
446  - close_width
447  - (hasMaximize ? maximize_width : 0)
448  - (hasMinimize ? minimize_width : 0)
449  - (hasContextHelp ? help_width : 0),
450 
451  titleHeight);
452  if (r.width() > 0)
453  region = r;
454  }
455  break;
456 
457  case Top: {
458  QRect r(rect.left() + CORNER_GRAB,
459  rect.top() - titleHeight - bw,
460  rect.width() - 2 * CORNER_GRAB,
461  bw);
462  region = r;
463  }
464  break;
465 
466  case Left: {
467  QRect r(rect.left() - bw,
468  rect.top() - titleHeight + CORNER_GRAB,
469  bw,
470  rect.height() + titleHeight - 2 * CORNER_GRAB);
471  region = r;
472  }
473  break;
474 
475  case Right: {
476  QRect r(rect.right() + 1,
477  rect.top() - titleHeight + CORNER_GRAB,
478  bw,
479  rect.height() + titleHeight - 2 * CORNER_GRAB);
480  region = r;
481  }
482  break;
483 
484  case Bottom: {
485  QRect r(rect.left() + CORNER_GRAB,
486  rect.bottom() + 1,
487  rect.width() - 2 * CORNER_GRAB,
488  bw);
489  region = r;
490  }
491  break;
492 
493  case TopLeft: {
494  QRect r1(rect.left() - bw,
495  rect.top() - bw - titleHeight,
496  CORNER_GRAB + bw,
497  bw);
498 
499  QRect r2(rect.left() - bw,
500  rect.top() - bw - titleHeight,
501  bw,
502  CORNER_GRAB + bw);
503 
504  region = QRegion(r1) + r2;
505  }
506  break;
507 
508  case TopRight: {
509  QRect r1(rect.right() - CORNER_GRAB,
510  rect.top() - bw - titleHeight,
511  CORNER_GRAB + bw,
512  bw);
513 
514  QRect r2(rect.right() + 1,
515  rect.top() - bw - titleHeight,
516  bw,
517  CORNER_GRAB + bw);
518 
519  region = QRegion(r1) + r2;
520  }
521  break;
522 
523  case BottomLeft: {
524  QRect r1(rect.left() - bw,
525  rect.bottom() + 1,
526  CORNER_GRAB + bw,
527  bw);
528 
529  QRect r2(rect.left() - bw,
530  rect.bottom() - CORNER_GRAB,
531  bw,
532  CORNER_GRAB + bw);
533  region = QRegion(r1) + r2;
534  }
535  break;
536 
537  case BottomRight: {
538  QRect r1(rect.right() - CORNER_GRAB,
539  rect.bottom() + 1,
540  CORNER_GRAB + bw,
541  bw);
542 
543  QRect r2(rect.right() + 1,
544  rect.bottom() - CORNER_GRAB,
545  bw,
546  CORNER_GRAB + bw);
547  region = QRegion(r1) + r2;
548  }
549  break;
550 
551  case Menu: {
552  if (hasSysMenu) {
553  region = QRect(rect.left(), rect.top() - titleHeight,
554  menu_width, titleHeight);
555  }
556  }
557  break;
558 
559  case Help: {
560  if (hasContextHelp) {
561  QRect r(rect.right()
562  - close_width
563  - (hasMaximize ? maximize_width : 0)
564  - (hasMinimize ? minimize_width : 0)
565  - help_width + 1, rect.top() - titleHeight,
566  help_width, titleHeight);
567  if (r.left() > rect.left() + titleHeight)
568  region = r;
569  }
570  }
571  break;
572 
573 
574  case Minimize: {
575  if (hasMinimize && !isMinimized) {
576  QRect r(rect.right() - close_width
577  - (hasMaximize ? maximize_width : 0)
578  - minimize_width + 1, rect.top() - titleHeight,
579  minimize_width, titleHeight);
580  if (r.left() > rect.left() + titleHeight)
581  region = r;
582  }
583  }
584  break;
585 
586  case Maximize: {
587  if (hasMaximize && !isMaximized) {
588  QRect r(rect.right() - close_width - maximize_width + 1,
589  rect.top() - titleHeight, maximize_width, titleHeight);
590  if (r.left() > rect.left() + titleHeight)
591  region = r;
592  }
593  }
594  break;
595 
596  case Normalize: {
597  if (hasMinimize && isMinimized) {
598  QRect r(rect.right() - close_width
599  - (hasMaximize ? maximize_width : 0)
600  - minimize_width + 1, rect.top() - titleHeight,
601  minimize_width, titleHeight);
602  if (r.left() > rect.left() + titleHeight)
603  region = r;
604  } else if (hasMaximize && isMaximized) {
605  QRect r(rect.right() - close_width - maximize_width + 1,
606  rect.top() - titleHeight, maximize_width, titleHeight);
607  if (r.left() > rect.left() + titleHeight)
608  region = r;
609  }
610  }
611  break;
612 
613  case Close: {
614  QRect r(rect.right() - close_width + 1, rect.top() - titleHeight,
615  close_width, titleHeight);
616  if (r.left() > rect.left() + titleHeight)
617  region = r;
618  }
619  break;
620 
621  default: {
622  int i = 1;
623  while (i) {
624  if (i & decorationRegion)
625  region += this->region(widget, rect, i);
626  i <<= 1;
627  }
628  }
629  break;
630  }
631 
632  return region;
633 }
#define BORDER_WIDTH
Qt::WindowStates windowState() const
Returns the current window state.
Definition: qwidget.cpp:3086
virtual QRegion region(const QWidget *widget, const QRect &rect, int decorationRegion=All)
Returns the region specified by decorationRegion for the top-level widget.
int left() const
Returns the x-coordinate of the rectangle&#39;s left edge.
Definition: qrect.h:240
int width() const
Returns the width of the rectangle.
Definition: qrect.h:303
int height() const
Returns the height of the rectangle.
Definition: qrect.h:306
int bottom() const
Returns the y-coordinate of the rectangle&#39;s bottom edge.
Definition: qrect.h:249
virtual int titleBarHeight(const QWidget *widget)
Returns the title bar height in pixels for the given widget.
The QRegion class specifies a clip region for a painter.
Definition: qregion.h:68
bool isMaximized() const
Definition: qwidget.cpp:3074
int top() const
Returns the y-coordinate of the rectangle&#39;s top edge.
Definition: qrect.h:243
int right() const
Returns the x-coordinate of the rectangle&#39;s right edge.
Definition: qrect.h:246
#define BOTTOM_BORDER_WIDTH
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
#define CORNER_GRAB
Qt::WindowFlags windowFlags() const
Window flags are a combination of a type (e.
Definition: qwidget.h:939

◆ titleBarHeight()

int QDecorationDefault::titleBarHeight ( const QWidget widget)
protectedvirtual

Returns the title bar height in pixels for the given widget.

It is the greater of 20, or the sum of the application font's line spacing value plus a border width fudge factor.

Reimplemented in QDecorationStyled.

Definition at line 398 of file qdecorationdefault_qws.cpp.

Referenced by region().

399 {
400  return qMax(20, QApplication::fontMetrics().height() + BORDER_WIDTH);
401 }
#define BORDER_WIDTH
Q_DECL_CONSTEXPR const T & qMax(const T &a, const T &b)
Definition: qglobal.h:1217
static QFontMetrics fontMetrics()
Returns display (screen) font metrics for the application font.

◆ windowTitleFor()

QString QDecorationDefault::windowTitleFor ( const QWidget widget) const
protected
Warning
This function is not part of the public interface.

Definition at line 799 of file qdecorationdefault_qws.cpp.

Referenced by QDecorationStyled::paint(), QDecorationWindows::paint(), paint(), QDecorationStyled::region(), and QDecorationStyled::titleBarHeight().

800 {
802 }
QPointer< QWidget > widget
QString windowTitle
the window title (caption)
Definition: qwidget.h:198
QString qt_setWindowTitle_helperHelper(const QString &, const QWidget *)
Returns a modified window title with the [*] place holder replaced according to the rules described i...
Definition: qwidget.cpp:6240

◆ xpmForRegion()

const char ** QDecorationDefault::xpmForRegion ( int  region)
protectedvirtual

Returns a pointer to the X pixmap for the icon specified by region.

An X pixmap is an ASCII-text-based image. The value of region must be one of a subset of the values of enum DecorationRegion. The supported values are Help, Menu, Close, Minimize, Maximize, and Normalize. Other values of region cause zero to be returned.

See also
QDecoration::DecorationRegion

Reimplemented in QDecorationWindows.

Definition at line 271 of file qdecorationdefault_qws.cpp.

Referenced by pixmapFor(), and QDecorationWindows::xpmForRegion().

272 {
273 #ifdef QT_NO_IMAGEFORMAT_XPM
274  Q_UNUSED(reg);
275 #else
276  switch(reg)
277  {
278  case Help:
279  return (const char **)default_help_xpm;
280  case Menu:
281  return (const char **)default_menu_xpm;
282  case Close:
283  return (const char **)default_close_xpm;
284  case Minimize:
285  return (const char **)default_minimize_xpm;
286  case Maximize:
287  return (const char **)default_maximize_xpm;
288  case Normalize:
289  return (const char **)default_normalize_xpm;
290  }
291 #endif
292  return 0;
293 }
static const char *const default_maximize_xpm[]
static const char *const default_normalize_xpm[]
static const char *const default_minimize_xpm[]
static const char *const default_close_xpm[]
static const char *const default_menu_xpm[]
static const char *const default_help_xpm[]
#define Q_UNUSED(x)
Indicates to the compiler that the parameter with the specified name is not used in the body of a fun...
Definition: qglobal.h:1729

Properties

◆ close_width

int QDecorationDefault::close_width
protected

◆ help_width

int QDecorationDefault::help_width
protected

◆ maximize_width

int QDecorationDefault::maximize_width
protected

◆ menu_width

int QDecorationDefault::menu_width
protected

◆ minimize_width

int QDecorationDefault::minimize_width
protected

◆ normalize_width

int QDecorationDefault::normalize_width
protected

Definition at line 84 of file qdecorationdefault_qws.h.

Referenced by QDecorationDefault().

◆ staticClosePixmap

QPixmap * QDecorationDefault::staticClosePixmap = 0
staticprivate

Definition at line 89 of file qdecorationdefault_qws.h.

Referenced by pixmapFor(), and ~QDecorationDefault().

◆ staticHelpPixmap

QPixmap * QDecorationDefault::staticHelpPixmap = 0
staticprivate

Definition at line 87 of file qdecorationdefault_qws.h.

Referenced by pixmapFor().

◆ staticMaximizePixmap

QPixmap * QDecorationDefault::staticMaximizePixmap = 0
staticprivate

Definition at line 91 of file qdecorationdefault_qws.h.

Referenced by pixmapFor(), and ~QDecorationDefault().

◆ staticMenuPixmap

QPixmap * QDecorationDefault::staticMenuPixmap = 0
staticprivate

Definition at line 88 of file qdecorationdefault_qws.h.

Referenced by pixmapFor(), and ~QDecorationDefault().

◆ staticMinimizePixmap

QPixmap * QDecorationDefault::staticMinimizePixmap = 0
staticprivate

Definition at line 90 of file qdecorationdefault_qws.h.

Referenced by pixmapFor(), and ~QDecorationDefault().

◆ staticNormalizePixmap

QPixmap * QDecorationDefault::staticNormalizePixmap = 0
staticprivate

Definition at line 92 of file qdecorationdefault_qws.h.

Referenced by pixmapFor(), and ~QDecorationDefault().


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