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
25 #include <KConfigGroup>
27 #include <Plasma/Plasma>
28 #include <Plasma/View>
53 class PanelController
;
55 class PanelAppletOverlay
;
57 class PanelView
: public Plasma::View
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);
76 * @return the location (screen edge) where this panel is positioned.
78 Plasma::Location
location() const;
81 * @return panel behaviour
83 VisibilityMode
visibilityMode() const;
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
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
);
106 * @return the unhide trigger window id, None if there is none
108 Window
unhideTrigger() { return m_unhideTrigger
; }
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
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
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();
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
);
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();
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
);
208 void togglePanelController();
209 void edittingComplete();
210 void animateHide(qreal
);
212 void hideMousePoll();
213 void unhideHintMousePoll();
214 void resetTriggerEnteredSuppression();
217 * Updates the panel's position according to the screen and containment
220 void updatePanelGeometry();
223 Plasma::Svg
*m_background
;
224 PanelController
*m_panelController
;
225 QList
<PanelAppletOverlay
*> m_moveOverlays
;
227 QTimer
*m_mousePollTimer
;
228 QTimeLine
*m_timeLine
;
229 QGraphicsWidget
*m_spacer
;
233 Qt::Alignment m_alignment
;
235 Window m_unhideTrigger
;
237 QRect m_unhideTriggerGeom
;
242 VisibilityMode m_visibilityMode
;
244 bool m_lastHorizontal
: 1;
248 bool m_firstPaint
: 1;
249 bool m_triggerEntered
: 1;