add more spacing
[personal-kdebase.git] / workspace / plasma / shells / desktop / panelview.h
blob96a44c79c09b53a49b2e0815f8ff1c7654f27bc7
1 /*
2 * Copyright 2007 by Matt Broadstone <mbroadst@kde.org>
3 * Copyright 2007 by Robert Knight <robertknight@gmail.com>
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU Library General Public License version 2,
7 * or (at your option) any later version.
9 * This program 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
12 * GNU General Public License for more details
14 * You should have received a copy of the GNU Library General Public
15 * License along with this program; if not, write to the
16 * Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 #ifndef PLASMA_PANELVIEW_H
21 #define PLASMA_PANELVIEW_H
23 #include <QList>
25 #include <KConfigGroup>
27 #include <Plasma/Plasma>
28 #include <Plasma/View>
30 #ifdef Q_WS_X11
31 #include <X11/Xlib.h>
32 #include <fixx11h.h>
33 #endif
35 #ifdef Q_WS_WIN
36 #include <windows.h>
37 #include <shellapi.h>
38 #endif
40 class QWidget;
41 class QTimeLine;
42 class QTimer;
44 class GlowBar;
46 namespace Plasma
48 class Containment;
49 class Corona;
50 class Svg;
53 class PanelController;
55 class PanelAppletOverlay;
57 class PanelView : public Plasma::View
59 Q_OBJECT
60 public:
62 enum VisibilityMode {
63 NormalPanel = 0,
64 AutoHide,
65 LetWindowsCover
68 /**
69 * Constructs a new panelview.
70 * @arg parent the QWidget this panel is parented to
72 explicit PanelView(Plasma::Containment *panel, int id = 0, QWidget *parent = 0);
73 ~PanelView();
75 /**
76 * @return the location (screen edge) where this panel is positioned.
78 Plasma::Location location() const;
80 /**
81 * @return panel behaviour
83 VisibilityMode visibilityMode() const;
85 /**
86 * @return the Corona (scene) associated with this panel.
88 Plasma::Corona *corona() const;
91 * @return the offset of the panel from the left screen edge
93 int offset() const;
95 /**
96 * @return the panel alignment
98 Qt::Alignment alignment() const;
101 * Pinches the min/max sizes of the containment to the current screen resolution
103 void pinchContainment(const QRect &screenGeometry);
104 #ifdef Q_WS_X11
106 * @return the unhide trigger window id, None if there is none
108 Window unhideTrigger() { return m_unhideTrigger; }
109 #endif
112 * Show a visual hint or perhaps even unhide, based on the position of the event
114 bool hintOrUnhide(const QPoint &point, bool dueToDnd = false);
117 * Returns the geometry of the current unhide hint window
119 QRect unhideHintGeometry() const;
122 * Hides any hide hinting
124 void unhintHide();
126 public Q_SLOTS:
128 * unhides the panel if it is hidden
130 void unhide(bool destroyTrigger);
133 * Pinches the min/max sizes of the containment to the current screen resolution
135 void pinchContainmentToCurrentScreen();
138 * Sets the offset the left border, the offset is the distance of the left
139 * border of the panel from the left border of the screen when the alignment is
140 * Qt::AlignLeft, right border and right edge if the alignment is Qt::alignRight
141 * and the distance between the center of the panel and the center of the screen if
142 * the alignment is Qt::AlignCenter.
143 * Similar way for vertical panels.
144 * @param newOffset the offset of the panel
146 void setOffset(int newOffset);
149 * Sets the edge of the screen the panel will be aligned and will grow
150 * @param align the direction (for instance Qt::AlignLeft) means the panel will start
151 * from the left of the screen and grow to the right
153 void setAlignment(Qt::Alignment align);
156 * Sets the location (screen edge) where this panel is positioned.
157 * @param location the location to place the panel at
159 void setLocation(Plasma::Location location);
162 * Sets the panel behaviour
163 * @param mode
165 void setVisibilityMode(PanelView::VisibilityMode mode);
168 * Call when there has been a change that might require changes to the unhide
169 * trigger, such as compositing changing.
171 void recreateUnhideTrigger();
173 protected:
174 void updateStruts();
175 void moveEvent(QMoveEvent *event);
176 void resizeEvent(QResizeEvent *event);
177 void leaveEvent(QEvent *event);
178 void drawBackground(QPainter * painter, const QRectF & rect);
179 void paintEvent(QPaintEvent *event);
180 bool event(QEvent *event);
181 void dragEnterEvent(QDragEnterEvent *event);
182 void dragMoveEvent(QDragMoveEvent *event);
183 void dragLeaveEvent(QDragLeaveEvent *event);
184 void dropEvent(QDropEvent *event);
186 private:
187 void createUnhideTrigger();
188 void destroyUnhideTrigger();
189 bool shouldHintHide() const;
190 Qt::Alignment alignmentFilter(Qt::Alignment align) const;
191 bool isHorizontal() const;
192 QTimeLine *timeLine();
193 void positionSpacer(const QPoint pos);
194 void startAutoHide();
195 bool hasPopup();
197 #ifdef Q_WS_WIN
198 bool registerAccessBar(bool fRegister);
199 void appBarQuerySetPos(LPRECT lprc);
200 void appBarCallback(WPARAM message, LPARAM lParam);
201 void appBarPosChanged();
202 bool winEvent(MSG *message, long *result);
203 APPBARDATA abd;
204 #endif
206 private Q_SLOTS:
207 void init();
208 void togglePanelController();
209 void edittingComplete();
210 void animateHide(qreal);
211 void panelDeleted();
212 void hideMousePoll();
213 void unhideHintMousePoll();
214 void resetTriggerEnteredSuppression();
217 * Updates the panel's position according to the screen and containment
218 * dimensions
220 void updatePanelGeometry();
222 private:
223 Plasma::Svg *m_background;
224 PanelController *m_panelController;
225 QList<PanelAppletOverlay*> m_moveOverlays;
226 GlowBar *m_glowBar;
227 QTimer *m_mousePollTimer;
228 QTimeLine *m_timeLine;
229 QGraphicsWidget *m_spacer;
230 int m_spacerIndex;
232 int m_offset;
233 Qt::Alignment m_alignment;
234 #ifdef Q_WS_X11
235 Window m_unhideTrigger;
236 QRect m_triggerZone;
237 QRect m_unhideTriggerGeom;
238 #endif
240 QSizeF m_lastMin;
241 QSizeF m_lastMax;
242 VisibilityMode m_visibilityMode;
243 int m_lastSeenSize;
244 bool m_lastHorizontal : 1;
245 bool m_init : 1;
247 bool m_editting : 1;
248 bool m_firstPaint : 1;
249 bool m_triggerEntered : 1;
252 #endif