6 /* This file is part of the KDE libraries
7 Copyright (C) 1997 Richard Moore (moorer@cs.man.ac.uk)
9 This library is free software; you can redistribute it and/or
10 modify it under the terms of the GNU Library General Public
11 License as published by the Free Software Foundation; either
12 version 2 of the License, or (at your option) any later version.
14 This library is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 Library General Public License for more details.
19 You should have received a copy of the GNU Library General Public License
20 along with this library; see the file COPYING.LIB. If not, write to
21 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
22 Boston, MA 02111-1307, USA.
33 #define KNewPanner DockWidget_KNewPanner
36 * KNewPanner is a simple widget for managing two children which
37 * are seperated by a draggable divider. The user can resize both
38 * children by moving the bar. You can also label the two children
39 * and the labels will be adjusted as the divider is moved.
41 * This widget is considerably easier to use than the old one, simply
42 * set the minimum and maximum sizes of the two children then call
43 * activate(). Note that the widgets to be panned should be children
44 * of the panner widget.
46 * This widget fixes a number of design
47 * problems in the original KPanner class which show up particularly
48 * if you try to use it under a layout manager (such as QBoxLayout).
50 * PLEASE NOTE: This panner is NOT source or binary compatable with
54 * @author Richard Moore rich@kde.org
56 class KNewPanner
: public QWidget
62 * Constants used to specify the orientation.
64 enum Orientation
{ Vertical
, Horizontal
};
67 * Constants used to choose between absolute (pixel) sizes and
70 enum Units
{ Percent
, Absolute
};
73 * Construct a KNewPanner widget.
75 * @param parent The parent widget
76 * @param name The name of the panner widget.
77 * @param orient The orientation of the panner, one of the constants
78 * Vertical or Horizontal.
79 * @param units The units in which you want to specify the seperator position. This must be one of the constants Percent or Absolute.
80 * @param pos The initial seperator position in the selected units.
82 KNewPanner(QWidget
*parent
= 0, const char *name
= 0,
83 Orientation orient
= Vertical
, Units units
= Percent
, int pos
= 50);
88 virtual ~KNewPanner();
91 * Begin managing these two widgets. If you want to set the minimum or
92 * maximum sizes of the children then you should do it before calling this
95 void activate(QWidget
*c0
, QWidget
*c1
);
98 * Call this method to restore the panner to it's initial state. This allows you
99 * to call activate() a second time with different children.
104 * This gets the current position of the separator in the current
110 * This sets the position of the seperator to the specified position.
111 * The position is specified in the currently selected units.
113 void setSeparatorPos(int pos
);
116 * This gets the current position of the separator in absolute
119 int absSeparatorPos();
122 * This sets the position of the seperator to the specified position.
123 * The position is specified in absolute units (pixels) irrespective
124 * of the the currently selected units.
126 void setAbsSeparatorPos(int pos
, bool do_resize
= true);
129 * Get the current units.
134 * Set the current units.
136 void setUnits(Units
);
140 * This returns the closest valid absolute seperator position to the
141 * position specified in the parameter.
146 * This method handles changes in the panner size, it will automatically resize
147 * the child widgets as appropriate.
149 void resizeEvent(QResizeEvent
*);
152 * Filter the events from the divider
154 bool eventFilter(QObject
*, QEvent
*);
157 // The managed children
158 QWidget
*child0
, *child1
;
160 // The height at which the children start
163 // Have we started yet?
166 // The divider widget
169 // The position in pixel units
172 Orientation orientation
;