summaryrefslogtreecommitdiffabout
path: root/microkde/kdeui/kbuttonbox.h
authorzautrix <zautrix>2004-06-26 19:01:18 (UTC)
committer zautrix <zautrix>2004-06-26 19:01:18 (UTC)
commitb9aad1f15dc600e4dbe4c62d3fcced6363188ba3 (patch) (unidiff)
tree2c3d4004fb21c72cba65793859f9bcd8ffd3a49c /microkde/kdeui/kbuttonbox.h
downloadkdepimpi-b9aad1f15dc600e4dbe4c62d3fcced6363188ba3.zip
kdepimpi-b9aad1f15dc600e4dbe4c62d3fcced6363188ba3.tar.gz
kdepimpi-b9aad1f15dc600e4dbe4c62d3fcced6363188ba3.tar.bz2
Initial revision
Diffstat (limited to 'microkde/kdeui/kbuttonbox.h') (more/less context) (ignore whitespace changes)
-rw-r--r--microkde/kdeui/kbuttonbox.h139
1 files changed, 139 insertions, 0 deletions
diff --git a/microkde/kdeui/kbuttonbox.h b/microkde/kdeui/kbuttonbox.h
new file mode 100644
index 0000000..1104366
--- a/dev/null
+++ b/microkde/kdeui/kbuttonbox.h
@@ -0,0 +1,139 @@
1/* This file is part of the KDE libraries
2 Copyright (C) 1997 Mario Weilguni (mweilguni@sime.com)
3
4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Library General Public
6 License as published by the Free Software Foundation; either
7 version 2 of the License, or (at your option) any later version.
8
9 This library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Library General Public License for more details.
13
14 You should have received a copy of the GNU Library General Public License
15 along with this library; see the file COPYING.LIB. If not, write to
16 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 Boston, MA 02111-1307, USA.
18*/
19
20#ifndef __KBUTTONBOX__H__
21#define __KBUTTONBOX__H__
22
23#include <qwidget.h>
24class QPushButton;
25
26class KButtonBoxPrivate;
27/**
28 * Container widget for buttons.
29 *
30 * This class uses Qt layout control to place the buttons; can handle
31 * both vertical and horizontal button placement. The default border
32 * is now @p 0 (making it easier to deal with layouts). The space
33 * between buttons is now more Motif compliant.
34 *
35 * @author Mario Weilguni <mweilguni@sime.com>
36 * @version $Id$
37 **/
38
39class KButtonBox : public QWidget
40{
41 Q_OBJECT
42
43public:
44 /**
45 * Create an empty container for buttons.
46 *
47 * If @p _orientation is @p Vertical, the buttons inserted with
48 * @ref addButton() are laid out from top to bottom, otherwise they
49 * are laid out from left to right.
50 */
51 KButtonBox(QWidget *parent, Orientation _orientation = Horizontal,
52 int border = 0, int _autoborder = 6);
53
54 /**
55 * Free private data field
56 */
57 ~KButtonBox();
58
59 /**
60 * @return The minimum size needed to fit all buttons.
61 *
62 * This size is
63 * calculated by the width/height of all buttons plus border/autoborder.
64 */
65 virtual QSize sizeHint() const;
66 /**
67 * @reimplemented
68 */
69 virtual QSizePolicy sizePolicy() const;
70 /**
71 * @reimplemented
72 */
73 virtual void resizeEvent(QResizeEvent *);
74
75 /**
76 * Add a new @ref QPushButton.
77 *
78 * @param noexpand If @p noexpand is @p false, the width
79 * of the button is adjusted to fit the other buttons (the maximum
80 * of all buttons is taken). If @p noexpand is @p true, the width of this
81 * button will be set to the minimum width needed for the given text).
82 *
83 * @return A pointer to the new button.
84 */
85 QPushButton *addButton(const QString& text, bool noexpand = FALSE);
86
87 /**
88 * Add a new @ref QPushButton.
89 *
90 * @param receiver An object to connect to.
91 * @param slot A Qt slot to connect the 'clicked()' signal to.
92 * @param noexpand If @p noexpand is @p false, the width
93 * of the button is adjusted to fit the other buttons (the maximum
94 * of all buttons is taken). If @p noexpand @p true, the width of this
95 * button will be set to the minimum width needed for the given text).
96 *
97 * @return A pointer to the new button.
98 */
99 QPushButton *addButton(const QString& text, QObject * receiver, const char * slot, bool noexpand = FALSE);
100
101 /**
102 * Add a stretch to the buttonbox.
103 *
104 * Can be used to separate buttons. That is, if you add the
105 * buttons OK and Cancel, add a stretch, and then add the button Help,
106 * the buttons OK and Cancel will be left-aligned (or top-aligned
107 * for vertical) whereas Help will be right-aligned (or
108 * bottom-aligned for vertical).
109 *
110 * @see QBoxLayout
111 */
112 void addStretch(int scale = 1);
113
114 /**
115 * This function must be called @em once after all buttons have been
116 * inserted.
117 *
118 * It will start layout control.
119 */
120 void layout();
121
122public: // as PrivateData needs Item, it has to be exported
123 class Item;
124protected:
125 /**
126 * @return the best size for a button. Checks all buttons and takes
127 * the maximum width/height.
128 */
129 QSize bestButtonSize() const;
130 void placeButtons();
131 QSize buttonSizeHint(QPushButton *) const;
132
133protected:
134 virtual void virtual_hook( int id, void* data );
135private:
136 KButtonBoxPrivate *data;
137};
138
139#endif