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

kwin/lib

  • kwin
  • 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 #include <kdeversion.h>
34 
35 class KDecorationOptionsPrivate;
36 class KDecorationBridge;
37 class KDecorationPrivate;
38 class KDecorationFactory;
39 
40 #define KWIN_EXPORT KDE_EXPORT
41 
47 class KWIN_EXPORT KDecorationDefines
48 {
49 public:
53  enum Position
54  { // without prefix, they'd conflict with Qt::TopLeft etc. :(
55  PositionCenter = 0x00,
56  PositionLeft = 0x01,
57  PositionRight = 0x02,
58  PositionTop = 0x04,
59  PositionBottom = 0x08,
60  PositionTopLeft = PositionLeft | PositionTop,
61  PositionTopRight = PositionRight | PositionTop,
62  PositionBottomLeft = PositionLeft | PositionBottom,
63  PositionBottomRight = PositionRight | PositionBottom
64  };
68  // these values are written to session files, don't change the order
69  enum MaximizeMode
70  {
71  MaximizeRestore = 0,
72  MaximizeVertical = 1,
73  MaximizeHorizontal = 2,
74 
75  MaximizeFull = MaximizeVertical | MaximizeHorizontal
76  };
77 
78  enum WindowOperation
79  {
80  MaximizeOp = 5000,
81  RestoreOp,
82  MinimizeOp,
83  MoveOp,
84  UnrestrictedMoveOp,
85  ResizeOp,
86  UnrestrictedResizeOp,
87  CloseOp,
88  OnAllDesktopsOp,
89  ShadeOp,
90  KeepAboveOp,
91  KeepBelowOp,
92  OperationsOp,
93  WindowRulesOp,
94  ToggleStoreSettingsOp = WindowRulesOp,
95  HMaximizeOp,
96  VMaximizeOp,
97  LowerOp,
98  FullScreenOp,
99  NoBorderOp,
100  NoOp,
101  SetupWindowShortcutOp,
102  ApplicationRulesOp,
103  ShadowOp
104  };
110  enum ColorType
111  {
112  ColorTitleBar,
113  ColorTitleBlend,
114  ColorFont,
115  ColorButtonBg,
116  ColorFrame,
117  ColorHandle,
118  NUM_COLORS
119  };
120 
125  enum
126  {
127  SettingDecoration = 1 << 0,
128  SettingColors = 1 << 1,
129  SettingFont = 1 << 2,
130  SettingButtons = 1 << 3,
131  SettingTooltips = 1 << 4,
132  SettingBorder = 1 << 5
133  };
134 
139  enum BorderSize
140  {
141  BorderTiny,
142  BorderNormal,
143  BorderLarge,
144  BorderVeryLarge,
145  BorderHuge,
146  BorderVeryHuge,
147  BorderOversized,
148  BordersCount
149  };
150 
155  enum Ability
156  {
157  AbilityAnnounceButtons = 0,
158  AbilityButtonMenu = 1000,
159  AbilityButtonOnAllDesktops = 1001,
160  AbilityButtonSpacer = 1002,
161  AbilityButtonHelp = 1003,
162  AbilityButtonMinimize = 1004,
163  AbilityButtonMaximize = 1005,
164  AbilityButtonClose = 1006,
165  AbilityButtonAboveOthers = 1007,
166  AbilityButtonBelowOthers = 1008,
167  AbilityButtonShade = 1009,
168  AbilityButtonResize = 1010,
169  ABILITY_DUMMY = 10000000
170  };
171 
172  enum Requirement { REQUIREMENT_DUMMY = 1000000 };
173 };
174 
175 class KDecorationProvides
176  : public KDecorationDefines
177  {
178  public:
179  virtual bool provides( Requirement req ) = 0;
180  };
181 
188 class KWIN_EXPORT KDecorationOptions : public KDecorationDefines
189  {
190 public:
191  KDecorationOptions();
192  virtual ~KDecorationOptions();
200  const TQColor& color(ColorType type, bool active=true) const;
208  const TQColorGroup& colorGroup(ColorType type, bool active=true) const;
216  const TQFont& font(bool active=true, bool small = false) const;
224  bool customButtonPositions() const;
246  TQString titleButtonsLeft() const;
258  TQString titleButtonsRight() const;
259 
264  bool showTooltips() const;
265 
276  BorderSize preferredBorderSize( KDecorationFactory* factory ) const;
277 
278  /*
279  * When this functions returns false, moving and resizing of maximized windows
280  * is not allowed, and therefore the decoration is allowed to turn off (some of)
281  * its borders.
282  * The changed flags for this setting is SettingButtons.
283  */
284  bool moveResizeMaximizedWindows() const;
285 
289  WindowOperation operationMaxButtonClick( TQt::ButtonState button ) const;
290 
294  virtual unsigned long updateSettings() = 0; // returns SettingXYZ mask
295 
296 protected:
300  KDecorationOptionsPrivate* d;
301  };
302 
303 
311 class KWIN_EXPORT KDecoration
312  : public TQObject, public KDecorationDefines
313  {
314  Q_OBJECT
315  public:
321  KDecoration( KDecorationBridge* bridge, KDecorationFactory* factory );
325  virtual ~KDecoration();
326 
327  // requests from decoration
328 
333  static const KDecorationOptions* options();
337  bool isActive() const;
341  bool isCloseable() const;
345  bool isMaximizable() const;
351  MaximizeMode maximizeMode() const;
355  bool isMinimizable() const;
360  bool providesContextHelp() const;
366  int desktop() const;
371  bool isOnAllDesktops() const; // convenience
375  bool isModal() const;
379  bool isShadeable() const;
388  bool isShade() const;
396  bool isSetShade() const;
400  bool keepAbove() const;
404  bool keepBelow() const;
408  bool isMovable() const;
412  bool isResizable() const;
436  NET::WindowType windowType( unsigned long supported_types ) const;
440  TQIconSet icon() const;
444  TQString caption() const;
471  void showWindowMenu( const TQRect &pos );
472 
476  void showWindowMenu( TQPoint pos );
481  void performWindowOperation( WindowOperation op );
490  void setMask( const TQRegion& reg, int mode = 0 );
494  void clearMask(); // convenience
500  bool isPreview() const;
504  TQRect geometry() const;
510  TQRect iconGeometry() const;
519  TQRegion unobscuredRegion( const TQRegion& r ) const;
524  TQWidget* workspaceWidget() const;
538  WId windowId() const;
542  int width() const; // convenience
546  int height() const; // convenience
552  void processMousePressEvent( TQMouseEvent* e );
553 
554  // requests to decoration
555 
561  virtual void init() = 0; // called once right after created
562 
568  virtual Position mousePosition( const TQPoint& p ) const = 0;
569 
582  // mustn't do any repaints, resizes or anything like that
583  virtual void borders( int& left, int& right, int& top, int& bottom ) const = 0;
591  virtual void resize( const TQSize& s ) = 0;
597  virtual TQSize minimumSize() const = 0;
602  virtual void activeChange() = 0;
606  virtual void captionChange() = 0;
610  virtual void iconChange() = 0;
615  virtual void maximizeChange() = 0;
621  virtual void desktopChange() = 0;
626  virtual void shadeChange() = 0;
627 #if KDE_IS_VERSION( 3, 90, 0 )
628 #warning Redo all the XYZChange() virtuals as signals.
629 #endif
630  signals:
635  void keepAboveChanged( bool );
640  void keepBelowChanged( bool );
641  public:
655  virtual bool drawbound( const TQRect& geom, bool clear );
666  virtual bool animateMinimize( bool minimize );
670  // TODO position will need also values for top+left+bottom etc. docking ?
671  virtual bool windowDocked( Position side );
678  virtual void reset( unsigned long changed );
679 
680  // special
681 
688  void setMainWidget( TQWidget* );
698  void createMainWidget( TQt::WFlags flags = 0 );
702  TQWidget* initialParentWidget() const;
709  TQt::WFlags initialWFlags() const;
716  void helperShowHide( bool show );
720  TQWidget* widget();
724  const TQWidget* widget() const;
728  KDecorationFactory* factory() const;
732  void grabXServer();
736  void ungrabXServer();
737  public slots:
738  // requests from decoration
739 
747  void closeWindow();
748  /*
749  * Changes the maximize mode of the decorated window. This function should
750  * be preferred to the other maximize() overload for reacting on clicks
751  * on the maximize titlebar button.
752  * NOTE: This function is new in KDE3.3. In order to support also KDE3.2,
753  * it is recommended to use code like this:
754  * \code
755  * ButtonState button = ... ;
756  * #if KDE_IS_VERSION( 3, 3, 0 )
757  * maximize( button );
758  * #else
759  * if( button == MidButton )
760  * maximize( maximizeMode() ^ MaximizeVertical );
761  * else if( button == RightButton )
762  * maximize( maximizeMode() ^ MaximizeHorizontal );
763  * else
764  * maximize( maximizeMode() == MaximizeFull ? MaximizeRestore : MaximizeFull );
765  * #endif
766  * \endcode
767  * @since 3.3
768  */
769 #if KDE_IS_VERSION( 3, 90, 0 )
770 #warning Update the docs.
771 #endif
772  void maximize( ButtonState button );
777  void maximize( MaximizeMode mode );
781  void minimize();
786  void showContextHelp();
791  void setDesktop( int desktop );
795  void toggleOnAllDesktops(); // convenience
800  void titlebarDblClickOperation();
807  void titlebarMouseWheelOperation( int delta );
812  void setShade( bool set );
817  void setKeepAbove( bool set );
822  void setKeepBelow( bool set );
826  void emitKeepAboveChanged( bool above ) { emit keepAboveChanged( above ); }
830  void emitKeepBelowChanged( bool below ) { emit keepBelowChanged( below ); }
831  private:
832  KDecorationBridge* bridge_;
833  TQWidget* w_;
834  KDecorationFactory* factory_;
835  friend class KDecorationOptions; // for options_
836  static KDecorationOptions* options_;
837  KDecorationPrivate* d;
838  };
839 
840 inline
841 KDecorationDefines::MaximizeMode operator^( KDecorationDefines::MaximizeMode m1, KDecorationDefines::MaximizeMode m2 )
842  {
843  return KDecorationDefines::MaximizeMode( int(m1) ^ int(m2) );
844  }
845 
846 inline
847 KDecorationDefines::MaximizeMode operator&( KDecorationDefines::MaximizeMode m1, KDecorationDefines::MaximizeMode m2 )
848  {
849  return KDecorationDefines::MaximizeMode( int(m1) & int(m2) );
850  }
851 
852 inline
853 KDecorationDefines::MaximizeMode operator|( KDecorationDefines::MaximizeMode m1, KDecorationDefines::MaximizeMode m2 )
854  {
855  return KDecorationDefines::MaximizeMode( int(m1) | int(m2) );
856  }
857 
858 inline TQWidget* KDecoration::widget()
859  {
860  return w_;
861  }
862 
863 inline const TQWidget* KDecoration::widget() const
864  {
865  return w_;
866  }
867 
868 inline KDecorationFactory* KDecoration::factory() const
869  {
870  return factory_;
871  }
872 
873 inline bool KDecoration::isOnAllDesktops() const
874  {
875  return desktop() == NET::OnAllDesktops;
876  }
877 
878 inline int KDecoration::width() const
879  {
880  return geometry().width();
881  }
882 
883 inline int KDecoration::height() const
884  {
885  return geometry().height();
886  }
887 
888 #endif

kwin/lib

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

kwin/lib

Skip menu "kwin/lib"
  • kate
  • kwin
  •   lib
  • libkonq
Generated for kwin/lib by doxygen 1.8.3.1
This website is maintained by Timothy Pearson.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. |