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

twin/lib

  • twin
  • lib
kdecoration.h
1 /*****************************************************************
2 This file is part of the KDE project.
3 
4 Copyright (C) 2003 Lubos Lunak <l.lunak@kde.org>
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 KDECORATION_H
26 #define KDECORATION_H
27 
28 #include <tqcolor.h>
29 #include <tqfont.h>
30 #include <tqobject.h>
31 #include <tqiconset.h>
32 #include <netwm_def.h>
33 
34 class KDecorationOptionsPrivate;
35 class KDecorationBridge;
36 class KDecorationPrivate;
37 class KDecorationFactory;
38 
39 #define KWIN_EXPORT TDE_EXPORT
40 
46 class KWIN_EXPORT KDecorationDefines
47 {
48 public:
52  enum Position
53  { // without prefix, they'd conflict with TQt::TopLeft etc. :(
54  PositionCenter = 0x00,
55  PositionLeft = 0x01,
56  PositionRight = 0x02,
57  PositionTop = 0x04,
58  PositionBottom = 0x08,
59  PositionTopLeft = PositionLeft | PositionTop,
60  PositionTopRight = PositionRight | PositionTop,
61  PositionBottomLeft = PositionLeft | PositionBottom,
62  PositionBottomRight = PositionRight | PositionBottom
63  };
67  // these values are written to session files, don't change the order
68  enum MaximizeMode
69  {
70  MaximizeRestore = 0,
71  MaximizeVertical = 1,
72  MaximizeHorizontal = 2,
73  MaximizeFull = MaximizeVertical | MaximizeHorizontal
75  };
76 
77  enum WindowOperation
78  {
79  MaximizeOp = 5000,
80  RestoreOp,
81  MinimizeOp,
82  MoveOp,
83  UnrestrictedMoveOp,
84  ResizeOp,
85  UnrestrictedResizeOp,
86  CloseOp,
87  OnAllDesktopsOp,
88  ShadeOp,
89  KeepAboveOp,
90  KeepBelowOp,
91  OperationsOp,
92  WindowRulesOp,
93  ToggleStoreSettingsOp = WindowRulesOp,
94  HMaximizeOp,
95  VMaximizeOp,
96  LowerOp,
97  FullScreenOp,
98  NoBorderOp,
99  NoOp,
100  SetupWindowShortcutOp,
101  ApplicationRulesOp,
102  ShadowOp,
103  SuspendWindowOp,
104  ResumeWindowOp
105  };
111  enum ColorType
112  {
113  ColorTitleBar,
114  ColorTitleBlend,
115  ColorFont,
116  ColorButtonBg,
117  ColorFrame,
118  ColorHandle,
119  NUM_COLORS
120  };
121 
126  enum
127  {
128  SettingDecoration = 1 << 0,
129  SettingColors = 1 << 1,
130  SettingFont = 1 << 2,
131  SettingButtons = 1 << 3,
132  SettingTooltips = 1 << 4,
133  SettingBorder = 1 << 5
134  };
135 
140  enum BorderSize
141  {
142  BorderTiny,
143  BorderNormal,
144  BorderLarge,
145  BorderVeryLarge,
146  BorderHuge,
147  BorderVeryHuge,
148  BorderOversized,
149  BordersCount
150  };
151 
156  enum Ability
157  {
158  AbilityAnnounceButtons = 0,
159  AbilityButtonMenu = 1000,
160  AbilityButtonOnAllDesktops = 1001,
161  AbilityButtonSpacer = 1002,
162  AbilityButtonHelp = 1003,
163  AbilityButtonMinimize = 1004,
164  AbilityButtonMaximize = 1005,
165  AbilityButtonClose = 1006,
166  AbilityButtonAboveOthers = 1007,
167  AbilityButtonBelowOthers = 1008,
168  AbilityButtonShade = 1009,
169  AbilityButtonResize = 1010,
170  ABILITY_DUMMY = 10000000
171  };
172 
173  enum Requirement { REQUIREMENT_DUMMY = 1000000 };
174 };
175 
176 class KDecorationProvides
177  : public KDecorationDefines
178  {
179  public:
180  virtual bool provides( Requirement req ) = 0;
181  };
182 
189 class KWIN_EXPORT KDecorationOptions : public KDecorationDefines
190  {
191 public:
192  KDecorationOptions();
193  virtual ~KDecorationOptions();
201  const TQColor& color(ColorType type, bool active=true) const;
209  const TQColorGroup& colorGroup(ColorType type, bool active=true) const;
217  const TQFont& font(bool active=true, bool small = false) const;
225  bool customButtonPositions() const;
247  TQString titleButtonsLeft() const;
259  TQString titleButtonsRight() const;
260 
265  bool showTooltips() const;
266 
277  BorderSize preferredBorderSize( KDecorationFactory* factory ) const;
278 
279  /*
280  * When this functions returns false, moving and resizing of maximized windows
281  * is not allowed, and therefore the decoration is allowed to turn off (some of)
282  * its borders.
283  * The changed flags for this setting is SettingButtons.
284  */
285  bool moveResizeMaximizedWindows() const;
286 
290  WindowOperation operationMaxButtonClick( TQt::ButtonState button ) const;
291 
295  virtual unsigned long updateSettings() = 0; // returns SettingXYZ mask
296 
297 protected:
301  KDecorationOptionsPrivate* d;
302  };
303 
304 
312 class KWIN_EXPORT KDecoration
313  : public TQObject, public KDecorationDefines
314  {
315  TQ_OBJECT
316  public:
322  KDecoration( KDecorationBridge* bridge, KDecorationFactory* factory );
326  virtual ~KDecoration();
327 
328  // requests from decoration
329 
334  static const KDecorationOptions* options();
338  bool isActive() const;
342  bool isCloseable() const;
346  bool isMaximizable() const;
352  MaximizeMode maximizeMode() const;
356  bool isMinimizable() const;
361  bool providesContextHelp() const;
367  int desktop() const;
372  bool isOnAllDesktops() const; // convenience
376  bool isModal() const;
380  bool isShadeable() const;
389  bool isShade() const;
397  bool isSetShade() const;
401  bool keepAbove() const;
405  bool keepBelow() const;
409  bool isMovable() const;
413  bool isResizable() const;
437  NET::WindowType windowType( unsigned long supported_types ) const;
441  TQIconSet icon() const;
445  TQString caption() const;
472  void showWindowMenu( const TQRect &pos );
473 
477  void showWindowMenu( TQPoint pos );
482  void performWindowOperation( WindowOperation op );
491  void setMask( const TQRegion& reg, int mode = 0 );
495  void clearMask(); // convenience
501  bool isPreview() const;
505  TQRect geometry() const;
511  TQRect iconGeometry() const;
520  TQRegion unobscuredRegion( const TQRegion& r ) const;
525  TQWidget* workspaceWidget() const;
539  WId windowId() const;
543  int width() const; // convenience
547  int height() const; // convenience
553  void processMousePressEvent( TQMouseEvent* e );
554 
555  // requests to decoration
556 
562  virtual void init() = 0; // called once right after created
563 
569  virtual Position mousePosition( const TQPoint& p ) const = 0;
570 
583  // mustn't do any repaints, resizes or anything like that
584  virtual void borders( int& left, int& right, int& top, int& bottom ) const = 0;
592  virtual void resize( const TQSize& s ) = 0;
598  virtual TQSize minimumSize() const = 0;
603  virtual void activeChange() = 0;
607  virtual void captionChange() = 0;
611  virtual void iconChange() = 0;
616  virtual void maximizeChange() = 0;
622  virtual void desktopChange() = 0;
627  virtual void shadeChange() = 0;
628  // TODO: redo all the XYZChange() virtuals as signals.
629  signals:
634  void keepAboveChanged( bool );
639  void keepBelowChanged( bool );
640  public:
654  virtual bool drawbound( const TQRect& geom, bool clear );
665  virtual bool animateMinimize( bool minimize );
669  // TODO position will need also values for top+left+bottom etc. docking ?
670  virtual bool windowDocked( Position side );
677  virtual void reset( unsigned long changed );
678 
679  // special
680 
687  void setMainWidget( TQWidget* );
697  void createMainWidget( TQt::WFlags flags = 0 );
701  TQWidget* initialParentWidget() const;
708  TQt::WFlags initialWFlags() const;
715  void helperShowHide( bool show );
719  TQWidget* widget();
723  const TQWidget* widget() const;
727  KDecorationFactory* factory() const;
731  void grabXServer();
735  void ungrabXServer();
736  public slots:
737  // requests from decoration
738 
746  void closeWindow();
747  /*
748  * Changes the maximize mode of the decorated window. This function should
749  * be preferred to the other maximize() overload for reacting on clicks
750  * on the maximize titlebar button.
751  * \endcode
752  * @since 3.3
753  */
754  void maximize( ButtonState button );
759  void maximize( MaximizeMode mode );
763  void minimize();
768  void showContextHelp();
773  void setDesktop( int desktop );
777  void toggleOnAllDesktops(); // convenience
782  void titlebarDblClickOperation();
789  void titlebarMouseWheelOperation( int delta );
794  void setShade( bool set );
799  void setKeepAbove( bool set );
804  void setKeepBelow( bool set );
808  void emitKeepAboveChanged( bool above ) { emit keepAboveChanged( above ); }
812  void emitKeepBelowChanged( bool below ) { emit keepBelowChanged( below ); }
813  private:
814  KDecorationBridge* bridge_;
815  TQWidget* w_;
816  KDecorationFactory* factory_;
817  friend class KDecorationOptions; // for options_
818  static KDecorationOptions* options_;
819  KDecorationPrivate* d;
820  };
821 
822 inline
823 KDecorationDefines::MaximizeMode operator^( KDecorationDefines::MaximizeMode m1, KDecorationDefines::MaximizeMode m2 )
824  {
825  return KDecorationDefines::MaximizeMode( int(m1) ^ int(m2) );
826  }
827 
828 inline
829 KDecorationDefines::MaximizeMode operator&( KDecorationDefines::MaximizeMode m1, KDecorationDefines::MaximizeMode m2 )
830  {
831  return KDecorationDefines::MaximizeMode( int(m1) & int(m2) );
832  }
833 
834 inline
835 KDecorationDefines::MaximizeMode operator|( KDecorationDefines::MaximizeMode m1, KDecorationDefines::MaximizeMode m2 )
836  {
837  return KDecorationDefines::MaximizeMode( int(m1) | int(m2) );
838  }
839 
840 inline TQWidget* KDecoration::widget()
841  {
842  return w_;
843  }
844 
845 inline const TQWidget* KDecoration::widget() const
846  {
847  return w_;
848  }
849 
850 inline KDecorationFactory* KDecoration::factory() const
851  {
852  return factory_;
853  }
854 
855 inline bool KDecoration::isOnAllDesktops() const
856  {
857  return desktop() == NET::OnAllDesktops;
858  }
859 
860 inline int KDecoration::width() const
861  {
862  return geometry().width();
863  }
864 
865 inline int KDecoration::height() const
866  {
867  return geometry().height();
868  }
869 
870 #endif
KDecorationDefines
This class provides a namespace for all decoration related classes.
Definition: kdecoration.h:46
KDecorationDefines::ColorType
ColorType
Basic color types that should be recognized by all decoration styles.
Definition: kdecoration.h:111
KDecorationDefines::ColorFont
@ ColorFont
The titlebar text color.
Definition: kdecoration.h:115
KDecorationOptions
This class holds various configuration settings for the decoration.
Definition: kdecoration.h:189
KDecoration::desktop
int desktop() const
Returns the number of the virtual desktop the decorated window is currently on (including NET::OnAllD...
Definition: kdecoration.cpp:114
KDecoration::isOnAllDesktops
bool isOnAllDesktops() const
Convenience function that returns true if the window is on all virtual desktops.
Definition: kdecoration.h:855
KDecorationDefines::MaximizeMode
MaximizeMode
Maximize mode.
Definition: kdecoration.h:68
KDecorationDefines::BorderVeryHuge
@ BorderVeryHuge
Very huge borders.
Definition: kdecoration.h:147
KDecorationDefines::ColorFrame
@ ColorFrame
The color for the window frame (border)
Definition: kdecoration.h:117
KDecorationDefines::ShadowOp
@ ShadowOp
Definition: kdecoration.h:102
KDecorationDefines::BorderOversized
@ BorderOversized
Oversized borders.
Definition: kdecoration.h:148
KDecorationDefines::ColorHandle
@ ColorHandle
The color for the resize handle.
Definition: kdecoration.h:118
KDecorationDefines::ColorTitleBar
@ ColorTitleBar
The color for the titlebar.
Definition: kdecoration.h:113
KDecorationDefines::BorderNormal
@ BorderNormal
Standard size borders, the default setting.
Definition: kdecoration.h:143
KDecoration::widget
TQWidget * widget()
Returns the main widget for the decoration.
Definition: kdecoration.h:840
KDecorationDefines::BorderVeryLarge
@ BorderVeryLarge
Very large borders.
Definition: kdecoration.h:145
KDecorationDefines::ColorTitleBlend
@ ColorTitleBlend
The blend color for the titlebar.
Definition: kdecoration.h:114
KDecorationDefines::ColorButtonBg
@ ColorButtonBg
The color to use for the titlebar buttons.
Definition: kdecoration.h:116
KDecorationDefines::Ability
Ability
Used to find out which features the decoration supports.
Definition: kdecoration.h:156
KDecorationDefines::BorderSize
BorderSize
Border size.
Definition: kdecoration.h:140
KDecoration::height
int height() const
Convenience function that returns the height of the decoration.
Definition: kdecoration.h:865
KDecorationDefines::BorderLarge
@ BorderLarge
Larger borders.
Definition: kdecoration.h:144
KDecoration
This is the base class for a decoration object.
Definition: kdecoration.h:312
KDecorationDefines::SuspendWindowOp
@ SuspendWindowOp
Definition: kdecoration.h:103
KDecorationDefines::WindowOperation
WindowOperation
Definition: kdecoration.h:77
KDecoration::geometry
TQRect geometry() const
Returns the geometry of the decoration.
Definition: kdecoration.cpp:209
KDecoration::width
int width() const
Convenience function that returns the width of the decoration.
Definition: kdecoration.h:860
KDecorationDefines::ApplicationRulesOp
@ ApplicationRulesOp
Definition: kdecoration.h:101
KDecorationDefines::BorderHuge
@ BorderHuge
Huge borders.
Definition: kdecoration.h:146
KDecorationDefines::Position
Position
These values represent positions inside an area.
Definition: kdecoration.h:52
KDecoration::factory
KDecorationFactory * factory() const
Returns the factory that created this decoration.
Definition: kdecoration.h:850
KDecorationDefines::BorderTiny
@ BorderTiny
Minimal borders.
Definition: kdecoration.h:142

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.17
This website is maintained by Timothy Pearson.