• Skip to content
  • Skip to link menu
Trinity API Reference
  • Trinity API Reference
  • twin/lib
 

twin/lib

  • twin
  • lib
kcommondecoration.h
1 /*
2  This file is part of the KDE project.
3 
4  Copyright (C) 2005 Sandro Giessl <sandro@giessl.com>
5 
6  Permission is hereby granted, free of charge, to any person obtaining a
7  copy of this software and associated documentation files (the "Software"),
8  to deal in the Software without restriction, including without limitation
9  the rights to use, copy, modify, merge, publish, distribute, sublicense,
10  and/or sell copies of the Software, and to permit persons to whom the
11  Software is furnished to do so, subject to the following conditions:
12 
13  The above copyright notice and this permission notice shall be included in
14  all copies or substantial portions of the Software.
15 
16  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19  THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21  FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22  DEALINGS IN THE SOFTWARE.
23  */
24 
25 #ifndef KCOMMONDECORATION_H
26 #define KCOMMONDECORATION_H
27 
28 #include <tqbutton.h>
29 #include <tqvaluevector.h>
30 
31 #include "kdecoration.h"
32 
33 class KDecorationBridge;
34 class KDecorationFactory;
35 
36 enum ButtonType {
37  HelpButton=0,
38  MaxButton,
39  MinButton,
40  CloseButton,
41  MenuButton,
42  OnAllDesktopsButton,
43  AboveButton,
44  BelowButton,
45  ShadeButton,
46  NumButtons
47 };
48 
49 class KCommonDecorationButton;
50 
51 class KCommonDecorationButtonPrivate;
52 class KCommonDecorationPrivate;
53 
59 class KWIN_EXPORT KCommonDecoration : public KDecoration
60 {
61  TQ_OBJECT
62 
63  public:
64  KCommonDecoration(KDecorationBridge* bridge, KDecorationFactory* factory);
65  virtual ~KCommonDecoration();
66 
100  enum LayoutMetric
101  {
102  LM_BorderLeft,
103  LM_BorderRight,
104  LM_BorderBottom,
105  LM_TitleHeight,
106  LM_TitleBorderLeft,
107  LM_TitleBorderRight,
108  LM_TitleEdgeLeft,
109  LM_TitleEdgeRight,
110  LM_TitleEdgeTop,
111  LM_TitleEdgeBottom,
112  LM_ButtonWidth,
113  LM_ButtonHeight,
114  LM_ButtonSpacing,
115  LM_ExplicitButtonSpacer,
116  LM_ButtonMarginTop,
117  LM_RightButtonsMarginTop
118  };
119 
120  enum DecorationBehaviour
121  {
122  DB_MenuClose,
123  DB_WindowMask,
124  DB_ButtonHide
125  };
126 
127  enum WindowCorner
128  {
129  WC_TopLeft,
130  WC_TopRight,
131  WC_BottomLeft,
132  WC_BottomRight
133  };
134 
138  virtual TQString visibleName() const = 0;
144  virtual TQString defaultButtonsLeft() const = 0;
150  virtual TQString defaultButtonsRight() const = 0;
151 
156  virtual bool decorationBehaviour(DecorationBehaviour behaviour) const;
157 
165  virtual int layoutMetric(LayoutMetric lm, bool respectWindowState = true, const KCommonDecorationButton *button = 0) const;
166 
171  virtual KCommonDecorationButton *createButton(ButtonType type) = 0;
172 
176  virtual TQRegion cornerShape(WindowCorner corner);
177 
185  virtual void updateWindowShape();
186 
190  virtual void paintEvent(TQPaintEvent *e) = 0;
191 
196  virtual void updateCaption();
197 
198  int buttonsLeftWidth() const;
199  int buttonsRightWidth() const;
200 
204  void updateLayout() const;
208  void updateButtons() const;
212  void resetButtons() const;
213 
218  bool isToolWindow() const;
223  TQRect titleRect() const;
224 
225  public:
229  virtual void init();
233  virtual void reset( unsigned long changed );
234  virtual void borders( int& left, int& right, int& top, int& bottom ) const;
235  virtual void show();
236  virtual void resize(const TQSize& s);
237  virtual TQSize minimumSize() const;
238  virtual void maximizeChange();
239  virtual void desktopChange();
240  virtual void shadeChange();
241  virtual void iconChange();
242  virtual void activeChange();
243  virtual void captionChange();
244  public slots:
245  void keepAboveChange(bool above);
246  void keepBelowChange(bool below);
247  void slotMaximize();
248  void slotShade();
249  void slotKeepAbove();
250  void slotKeepBelow();
251  void menuButtonPressed();
252  void menuButtonReleased();
253  public:
254  virtual Position mousePosition(const TQPoint &point) const;
255 
256  virtual bool eventFilter( TQObject* o, TQEvent* e );
257  virtual void resizeEvent(TQResizeEvent *e);
258  virtual void mouseDoubleClickEvent(TQMouseEvent *e);
259  virtual void wheelEvent(TQWheelEvent *e);
260 
261  private:
262  void resetLayout();
263 
264  void moveWidget(int x, int y, TQWidget *widget) const;
265  void resizeWidget(int w, int h, TQWidget *widget) const;
266 
267  typedef TQValueVector <KCommonDecorationButton*> ButtonContainer;
268  int buttonContainerWidth(const ButtonContainer &btnContainer, bool countHidden = false) const;
269  bool isModalSystemNotification();
270  void addButtons(ButtonContainer &btnContainer, const TQString& buttons, bool isLeft);
271 
272  KCommonDecorationButton *m_button[NumButtons];
273 
274  ButtonContainer m_buttonsLeft;
275  ButtonContainer m_buttonsRight;
276 
277  TQWidget *m_previewWidget;
278 
279  // button hiding for small windows
280  void calcHiddenButtons();
281  int btnHideMinWidth;
282  int btnHideLastWidth;
283 
284  bool closing; // for menu doubleclick closing...
285 
286  KCommonDecorationPrivate *d;
287 };
288 
292 class KWIN_EXPORT KCommonDecorationButton : public TQButton
293 {
294  friend class KCommonDecoration;
295 
296  TQ_OBJECT
297 
298 
299  public:
300  KCommonDecorationButton(ButtonType type, KCommonDecoration *parent, const char *name);
301  virtual ~KCommonDecorationButton();
302 
306  enum
307  {
308  ManualReset = 1 << 0,
309  SizeChange = 1 << 1,
310  ToggleChange = 1 << 2,
311  StateChange = 1 << 3,
312  IconChange = 1 << 4,
313  DecorationReset = 1 << 5
314  };
318  virtual void reset(unsigned long changed) = 0;
322  KCommonDecoration *decoration() const;
327  ButtonType type() const;
328 
332  bool isLeft() const;
333 
337  void setRealizeButtons(int btns);
341  void setSize(const TQSize &s);
345  void setTipText(const TQString &tip);
349  ButtonState lastMousePress() const { return m_lastMouse; }
350 
351  TQSize sizeHint() const;
352 
353  protected:
354  void setToggleButton(bool toggle);
355  void setOn(bool on);
356  void setLeft(bool left);
357  void mousePressEvent(TQMouseEvent *e);
358  void mouseReleaseEvent(TQMouseEvent *e);
359 
360  private:
361  KCommonDecoration *m_decoration;
362  ButtonType m_type;
363  int m_realizeButtons;
364  TQSize m_size;
365  ButtonState m_lastMouse;
366 
367  bool m_isLeft;
368 
369  KCommonDecorationButtonPrivate *d;
370 };
371 
372 #endif // KCOMMONDECORATION_H
KCommonDecoration::LayoutMetric
LayoutMetric
Used to calculate the decoration layout.
Definition: kcommondecoration.h:100
KDecoration::captionChange
virtual void captionChange()=0
This function is called whenever the caption changes.
KCommonDecorationButton
Title bar buttons of KCommonDecoration need to inherit this class.
Definition: kcommondecoration.h:292
KDecoration::activeChange
virtual void activeChange()=0
This function is called whenever the window either becomes or stops being active. ...
KDecoration
This is the base class for a decoration object.
Definition: kdecoration.h:313
KDecoration::minimumSize
virtual TQSize minimumSize() const =0
This function should return the minimum required size for the decoration.
KCommonDecoration::DecorationBehaviour
DecorationBehaviour
Definition: kcommondecoration.h:120
KDecoration::maximizeChange
virtual void maximizeChange()=0
This function is called whenever the maximalization state of the window changes.
KCommonDecorationButton::lastMousePress
ButtonState lastMousePress() const
The mouse button that has been clicked last time.
Definition: kcommondecoration.h:349
KDecoration::reset
virtual void reset(unsigned long changed)
This function is called to reset the decoration on settings changes.
Definition: kdecoration.cpp:317
KCommonDecoration::reset
virtual void reset(unsigned long changed)
Handles SettingButtons, call the base implementation when subclassing this member.
Definition: kcommondecoration.cpp:131
KDecoration::desktopChange
virtual void desktopChange()=0
This function is called whenever the desktop for the window changes.
KDecoration::init
virtual void init()=0
This function is called immediately after the decoration object is created.
KDecoration::borders
virtual void borders(int &left, int &right, int &top, int &bottom) const =0
This function should return the distance from each window side to the inner window.
KDecorationDefines::Position
Position
These values represent positions inside an area.
Definition: kdecoration.h:53
KCommonDecoration
This class eases development of decorations by implementing parts of KDecoration which are error pron...
Definition: kcommondecoration.h:59
KDecoration::resize
virtual void resize(const TQSize &s)=0
This method is called by twin when the style should resize the decoration window. ...
KCommonDecoration::DB_WindowMask
Set a mask on the window.
Definition: kcommondecoration.h:123
KDecoration::shadeChange
virtual void shadeChange()=0
This function is called whenever the window is shaded or unshaded.
KDecoration::iconChange
virtual void iconChange()=0
This function is called whenever the window icon changes.
KDecoration::mousePosition
virtual Position mousePosition(const TQPoint &p) const =0
This function should return mouse cursor position in the decoration.
Definition: kdecoration.cpp:331
KCommonDecoration::DB_MenuClose
Close window on double clicking the menu.
Definition: kcommondecoration.h:122

twin/lib

Skip menu "twin/lib"
  • Main Page
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Class Members
  • Related Pages

twin/lib

Skip menu "twin/lib"
  • kate
  • libkonq
  • twin
  •   lib
Generated for twin/lib by doxygen 1.8.13
This website is maintained by Timothy Pearson.