KCommonDecoration Class Reference
#include <kcommondecoration.h>
Inheritance diagram for KCommonDecoration:

Detailed Description
This class eases development of decorations by implementing parts of KDecoration which are error prone and common for most decorations.It takes care of the window layout, button/action handling, and window mask creation.
Definition at line 59 of file kcommondecoration.h.
Public Types | |
enum | LayoutMetric { LM_BorderLeft, LM_BorderRight, LM_BorderBottom, LM_TitleHeight, LM_TitleBorderLeft, LM_TitleBorderRight, LM_TitleEdgeLeft, LM_TitleEdgeRight, LM_TitleEdgeTop, LM_TitleEdgeBottom, LM_ButtonWidth, LM_ButtonHeight, LM_ButtonSpacing, LM_ExplicitButtonSpacer, LM_ButtonMarginTop } |
enum | DecorationBehaviour { DB_MenuClose, DB_WindowMask, DB_ButtonHide } |
enum | WindowCorner { WC_TopLeft, WC_TopRight, WC_BottomLeft, WC_BottomRight } |
Public Slots | |
void | keepAboveChange (bool above) |
void | keepBelowChange (bool below) |
void | slotMaximize () |
void | slotShade () |
void | slotKeepAbove () |
void | slotKeepBelow () |
void | menuButtonPressed () |
void | menuButtonReleased () |
Public Member Functions | |
KCommonDecoration (KDecorationBridge *bridge, KDecorationFactory *factory) | |
virtual | ~KCommonDecoration () |
virtual QString | visibleName () const=0 |
virtual QString | defaultButtonsLeft () const=0 |
virtual QString | defaultButtonsRight () const=0 |
virtual bool | decorationBehaviour (DecorationBehaviour behaviour) const |
virtual int | layoutMetric (LayoutMetric lm, bool respectWindowState=true, const KCommonDecorationButton *button=0) const |
virtual KCommonDecorationButton * | createButton (ButtonType type)=0 |
virtual QRegion | cornerShape (WindowCorner corner) |
virtual void | updateWindowShape () |
virtual void | paintEvent (QPaintEvent *e)=0 |
virtual void | updateCaption () |
int | buttonsLeftWidth () const |
int | buttonsRightWidth () const |
void | updateLayout () const |
void | updateButtons () const |
void | resetButtons () const |
bool | isToolWindow () const |
QRect | titleRect () const |
virtual void | init () |
virtual void | reset (unsigned long changed) |
virtual void | borders (int &left, int &right, int &top, int &bottom) const |
virtual void | show () |
virtual void | resize (const QSize &s) |
virtual QSize | minimumSize () const |
virtual void | maximizeChange () |
virtual void | desktopChange () |
virtual void | shadeChange () |
virtual void | iconChange () |
virtual void | activeChange () |
virtual void | captionChange () |
virtual Position | mousePosition (const QPoint &point) const |
virtual bool | eventFilter (QObject *o, QEvent *e) |
virtual void | resizeEvent (QResizeEvent *e) |
virtual void | mouseDoubleClickEvent (QMouseEvent *e) |
virtual void | wheelEvent (QWheelEvent *e) |
Member Enumeration Documentation
Used to calculate the decoration layout.
The basic layout looks like this:
Window: _______________________________________________________________ | LM_TitleEdgeTop | |_______________________________________________________________| | LM_TitleEdgeLeft | [title] | LM_TitleEdgeRight | |__________________|________________________|___________________| | LM_TitleEdgeBottom | |_______________________________________________________________| | | | | | | | | | | | | |LM_BorderLeft LM_BorderRight| |_|___________________________________________________________|_| | LM_BorderBottom | |_______________________________________________________________|
Title: ___________________________________________________________________________________ | LM_ButtonMarginTop | | LM_ButtonMarginTop | |________________________________| |_________________________________| | [Buttons] | LM_TitleBorderLeft | LM_TitleHeight | LM_TitleBorderRight | [Buttons] | |___________|____________________|________________|_____________________|___________|
Buttons: _____________________________________________________________________________________________ | button | spacing | button | spacing | explicit spacer | spacing | ... | spacing | button | |________|_________|________|_________|_________________|_________|________|_________|________|
- See also:
- layoutMetric()
Definition at line 100 of file kcommondecoration.h.
- Enumerator:
-
DB_MenuClose Close window on double clicking the menu. DB_WindowMask Set a mask on the window. DB_ButtonHide Hide buttons when there is not enough space in the titlebar.
Definition at line 119 of file kcommondecoration.h.
Member Function Documentation
virtual QString KCommonDecoration::visibleName | ( | ) | const [pure virtual] |
The name of the decoration used in the decoration preview.
virtual QString KCommonDecoration::defaultButtonsLeft | ( | ) | const [pure virtual] |
The default title button order on the left.
- See also:
- KDecoration::titleButtonsLeft()
KDecoration::titleButtonsRight()
virtual QString KCommonDecoration::defaultButtonsRight | ( | ) | const [pure virtual] |
The default title button order on the left.
- See also:
- KDecoration::titleButtonsLeft()
KDecoration::titleButtonsRight()
bool KCommonDecoration::decorationBehaviour | ( | DecorationBehaviour | behaviour | ) | const [virtual] |
This controls whether some specific behaviour should be enabled or not.
- See also:
- DecorationBehaviour
Definition at line 60 of file kcommondecoration.cpp.
int KCommonDecoration::layoutMetric | ( | LayoutMetric | lm, | |
bool | respectWindowState = true , |
|||
const KCommonDecorationButton * | button = 0 | |||
) | const [virtual] |
This controls the layout of the decoration in various ways.
It is possible to have a different layout for different window states.
- Parameters:
-
lm The layout element. respectWindowState Whether window states should be taken into account or a "default" state should be assumed. button For LM_ButtonWidth and LM_ButtonHeight, the button.
Definition at line 76 of file kcommondecoration.cpp.
virtual KCommonDecorationButton* KCommonDecoration::createButton | ( | ButtonType | type | ) | [pure virtual] |
Create a new title bar button.
KCommonDecoration takes care of memory management.
- Returns:
- a pointer to the button, or 0 if the button should not be created.
QRegion KCommonDecoration::cornerShape | ( | WindowCorner | corner | ) | [virtual] |
- Returns:
- the mask for the specific window corner.
Definition at line 135 of file kcommondecoration.cpp.
void KCommonDecoration::updateWindowShape | ( | ) | [virtual] |
This updates the window mask using the information provided by cornerShape().
Edges which are aligned to screen corners are not shaped for better usability (remember to paint these areas in paintEvent(), too). You normally don't want/need to reimplement updateWindowShape().
- See also:
- cornerShape()
Definition at line 770 of file kcommondecoration.cpp.
virtual void KCommonDecoration::paintEvent | ( | QPaintEvent * | e | ) | [pure virtual] |
Draw the window decoration.
void KCommonDecoration::updateCaption | ( | ) | [virtual] |
This is used to update the painting of the title bar after the caption has been changed.
Reimplement for a more efficient implementation (default calls update() on the whole decoration).
Definition at line 140 of file kcommondecoration.cpp.
void KCommonDecoration::updateLayout | ( | ) | const |
void KCommonDecoration::updateButtons | ( | ) | const |
void KCommonDecoration::resetButtons | ( | ) | const |
bool KCommonDecoration::isToolWindow | ( | ) | const |
Convenience method.
- Returns:
- true if the window type is NET::Toolbar, NET::Utility, or NET::Menu
Definition at line 850 of file kcommondecoration.cpp.
QRect KCommonDecoration::titleRect | ( | ) | const |
void KCommonDecoration::init | ( | ) | [virtual] |
Handles widget and layout creation, call the base implementation when subclassing this member.
Implements KDecoration.
Definition at line 110 of file kcommondecoration.cpp.
void KCommonDecoration::reset | ( | unsigned long | changed | ) | [virtual] |
Handles SettingButtons, call the base implementation when subclassing this member.
Reimplemented from KDecoration.
Definition at line 127 of file kcommondecoration.cpp.
void KCommonDecoration::borders | ( | int & | left, | |
int & | right, | |||
int & | top, | |||
int & | bottom | |||
) | const [virtual] |
This function should return the distance from each window side to the inner window.
The sizes may depend on the state of the decorated window, such as whether it's shaded. Decorations often turn off their bottom border when the window is shaded, and turn off their left/right/bottom borders when the window is maximized and moving and resizing of maximized windows is disabled. This function mustn't do any repaints or resizes. Also, if the sizes returned by this function don't match the real values, this may result in drawing errors or other problems.
Implements KDecoration.
Definition at line 146 of file kcommondecoration.cpp.
void KCommonDecoration::resize | ( | const QSize & | s | ) | [virtual] |
This method is called by kwin when the style should resize the decoration window.
The usual implementation is to resize the main widget of the decoration to the given size.
- Parameters:
-
s Specifies the new size of the decoration window.
Implements KDecoration.
Definition at line 495 of file kcommondecoration.cpp.
QSize KCommonDecoration::minimumSize | ( | ) | const [virtual] |
This function should return the minimum required size for the decoration.
Note that the returned size shouldn't be too large, because it will be used to keep the decorated window at least as large.
Implements KDecoration.
Definition at line 500 of file kcommondecoration.cpp.
void KCommonDecoration::maximizeChange | ( | ) | [virtual] |
This function is called whenever the maximalization state of the window changes.
Use maximizeMode() to get the current state.
Implements KDecoration.
Definition at line 511 of file kcommondecoration.cpp.
void KCommonDecoration::desktopChange | ( | ) | [virtual] |
This function is called whenever the desktop for the window changes.
Use desktop() or isOnAllDesktops() to find out the current desktop on which the window is.
Implements KDecoration.
Definition at line 524 of file kcommondecoration.cpp.
void KCommonDecoration::shadeChange | ( | ) | [virtual] |
This function is called whenever the window is shaded or unshaded.
Use isShade() to get the current state.
Implements KDecoration.
Definition at line 535 of file kcommondecoration.cpp.
void KCommonDecoration::iconChange | ( | ) | [virtual] |
This function is called whenever the window icon changes.
Use icon() to get it.
Implements KDecoration.
Definition at line 547 of file kcommondecoration.cpp.
void KCommonDecoration::activeChange | ( | ) | [virtual] |
This function is called whenever the window either becomes or stops being active.
Use isActive() to find out the current state.
Implements KDecoration.
Definition at line 556 of file kcommondecoration.cpp.
void KCommonDecoration::captionChange | ( | ) | [virtual] |
This function is called whenever the caption changes.
Use caption() to get it.
Implements KDecoration.
Definition at line 562 of file kcommondecoration.cpp.
KCommonDecoration::Position KCommonDecoration::mousePosition | ( | const QPoint & | point | ) | const [virtual] |
This function should return mouse cursor position in the decoration.
Positions at the edge will result in window resizing with mouse button pressed, center position will result in moving.
Implements KDecoration.
Definition at line 705 of file kcommondecoration.cpp.
The documentation for this class was generated from the following files: