The target options are now saved in the program settings.
[kdbg.git] / DockWidget / knewpanner.h
blob9747be77c295c940e6ac773e5b13b7c835b25b31
1 // -*- c++ -*-
3 #ifndef KNEWPANNER_H
4 #define KNEWPANNER_H
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.
25 #ifdef HAVE_CONFIG_H
26 #include <config.h>
27 #endif
29 #include <qwidget.h>
30 #include <qframe.h>
31 #include <qlabel.h>
33 #define KNewPanner DockWidget_KNewPanner
35 /**
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
51 * the old one.
53 * @version $Id$
54 * @author Richard Moore rich@kde.org
56 class KNewPanner : public QWidget
58 Q_OBJECT
60 public:
61 /**
62 * Constants used to specify the orientation.
64 enum Orientation { Vertical, Horizontal };
66 /**
67 * Constants used to choose between absolute (pixel) sizes and
68 * percentages.
70 enum Units { Percent, Absolute };
72 /**
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);
85 /**
86 * Clean up
88 virtual ~KNewPanner();
90 /**
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
93 * method.
95 void activate(QWidget *c0, QWidget *c1);
97 /**
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.
101 void deactivate();
104 * This gets the current position of the separator in the current
105 * units.
107 int separatorPos();
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
117 * (pixel) units.
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.
131 Units units();
134 * Set the current units.
136 void setUnits(Units);
138 protected:
140 * This returns the closest valid absolute seperator position to the
141 * position specified in the parameter.
143 int checkValue(int);
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 *);
156 private:
157 // The managed children
158 QWidget *child0, *child1;
160 // The height at which the children start
161 int startHeight;
163 // Have we started yet?
164 bool initialised;
166 // The divider widget
167 QFrame *divider;
169 // The position in pixel units
170 int position;
171 Units currentunits;
172 Orientation orientation;
175 #endif