• Skip to content
  • Skip to link menu
  • KDE API Reference
  • kdelibs-4.14.38 API Reference
  • KDE Home
  • Contact Us
 

KDE3Support

  • kde3support
  • kdeui
k3dockwidget_private.cpp
Go to the documentation of this file.
1/* This file is part of the KDE libraries
2 Copyright (C) 2000 Max Judin <novaprint@mtu-net.ru>
3 Copyright (C) 2002,2003 Joseph Wenninger <jowenn@kde.org>
4 Copyright (C) 2005 Dominik Haumann <dhdev@gmx.de>
5
6 This library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Library General Public
8 License version 2 as published by the Free Software Foundation.
9
10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details.
14
15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to
17 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 Boston, MA 02110-1301, USA.
19*/
20#include "k3dockwidget_private.h"
21#include "k3dockwidget.h"
22#include "k3dockwidget_p.h"
23
24#include <QtGui/QPainter>
25#include <QtGui/QCursor>
26#include <kdebug.h>
27#include <QtCore/QTimer>
28#include <QtGui/QApplication>
29#include <QResizeEvent>
30
31#include <math.h> // need ceil
32
33K3DockSplitter::K3DockSplitter(QWidget *parent, const char *name, Qt::Orientation orient, int pos)
34: QWidget(parent, name)
35{
36 m_dontRecalc=false;
37 divider = 0L;
38 child0 = 0L;
39 child1 = 0L;
40 fixedWidth0=-1;
41 fixedWidth1=-1;
42 fixedHeight0=-1;
43 fixedHeight1=-1;
44
45 m_orientation = orient;
46 mOpaqueResize = false;
47 mKeepSize = false;
48 setSeparatorPosInPercent( pos );
49 initialised = false;
50}
51
52void K3DockSplitter::activate(QWidget *c0, QWidget *c1)
53{
54 if ( c0 ) child0 = c0;
55 if ( c1 ) child1 = c1;
56
57 setupMinMaxSize();
58
59 delete divider;
60 divider = new QFrame(this, "pannerdivider");
61 divider->setFrameStyle(QFrame::Panel | QFrame::Raised);
62 divider->setLineWidth(1);
63 divider->raise();
64
65 if (m_orientation == Qt::Horizontal)
66 divider->setCursor(QCursor(Qt::SizeVerCursor));
67 else
68 divider->setCursor(QCursor(Qt::SizeHorCursor));
69 divider->installEventFilter(this);
70
71 initialised= true;
72
73 updateName();
74 divider->show();
75
76 // without this resize event, things will not work. why exactly? :(
77 resizeEvent(0);
78
79
80 K3DockWidget* dw0 = (K3DockWidget*) child0;
81 K3DockWidget* dw1 = (K3DockWidget*) child1;
82
83 // if fixed size is set, restore first, to restore xpos correctly
84 if( fixedWidth0 != -1 || fixedHeight0 != -1 ) restoreFromForcedFixedSize( dw0 );
85 if( fixedWidth1 != -1 || fixedHeight1 != -1 ) restoreFromForcedFixedSize( dw1 );
86
87
88 // now force fixed sizes, if they are set.
89 if( dw0->forcedFixedWidth() != -1 ) {
90 setForcedFixedWidth( dw0, dw0->forcedFixedWidth() );
91 }
92 else if( dw1->forcedFixedWidth() != -1 ) {
93 setForcedFixedWidth( dw1, dw1->forcedFixedWidth() );
94 }
95
96 if( dw0->forcedFixedHeight() != -1 ) {
97 setForcedFixedHeight (dw0, dw0->forcedFixedHeight() );
98 }
99 else if( dw1->forcedFixedHeight() != -1 ) {
100 setForcedFixedHeight( dw1, dw1->forcedFixedHeight() );
101 }
102}
103
104/*
105void K3DockSplitter::delayedResize()
106{
107 kDebug(282)<<"*********************** DELAYED RESIZE !!!!!!!!!!!!!!!";
108 resizeEvent(0);
109}*/
110
111void K3DockSplitter::setForcedFixedWidth(K3DockWidget *dw,int w)
112{
113 if (dw==child0)
114 {
115 if (fixedWidth0==-1) savedXPos=xpos;
116 if (w==fixedWidth0) return;
117 fixedWidth0=w;
118 setSeparatorPos(w*factor/width(),true);
119// kDebug(282)<<"Set forced fixed width for widget 0 :"<<w;
120 }
121 else
122 {
123 if (fixedWidth1==-1) savedXPos=xpos;
124 if (w==fixedWidth1) return;
125 fixedWidth1=w;
126 setSeparatorPos((width()-w)*factor/width(),true);
127// kDebug(282)<<"Set forced fixed width for widget 1 :"<<w;
128 }
129 setupMinMaxSize();
130 if (divider) divider->hide();
131}
132
133void K3DockSplitter::setForcedFixedHeight(K3DockWidget *dw,int h)
134{
135 if (dw==child0)
136 {
137 if (fixedHeight0==-1) savedXPos=xpos;
138 if (h==fixedHeight0) return;
139 fixedHeight0=h;
140 setSeparatorPos(h*factor/height(),true);
141// // kDebug(282)<<"Set forced fixed width for widget 0 :"<<h;
142 }
143 else
144 {
145 if (fixedHeight1==-1) savedXPos=xpos;
146 if (h==fixedHeight1) return;
147 fixedHeight1=h;
148 setSeparatorPos((height()-h)*factor/height(),true);
149// kDebug(282)<<"Set forced fixed height for widget 1 :"<<h;
150 }
151 setupMinMaxSize();
152 if (divider) divider->hide();
153}
154
155void K3DockSplitter::restoreFromForcedFixedSize(K3DockWidget *dw)
156{
157 if (divider) divider->show();
158 if (dw==child0)
159 {
160 fixedWidth0=-1;
161 fixedHeight0=-1;
162 setSeparatorPos(savedXPos,true);
163 }
164 else
165 {
166 fixedWidth1=-1;
167 fixedHeight1=-1;
168 setSeparatorPos(savedXPos,true);
169 }
170}
171
172
173void K3DockSplitter::setupMinMaxSize()
174{
175 // Set the minimum and maximum sizes for the K3DockSplitter (this)
176 int minx, maxx, miny, maxy;
177 if (m_orientation == Qt::Horizontal) {
178 miny = child0->minimumHeight() + child1->minimumHeight() + 4;
179 maxy = child0->maximumHeight() + child1->maximumHeight() + 4;
180 minx = (child0->minimumWidth() > child1->minimumWidth()) ? child0->minimumWidth() : child1->minimumWidth();
181 maxx = (child0->maximumWidth() > child1->maximumWidth()) ? child0->maximumWidth() : child1->maximumWidth();
182
183 if (miny < 4) miny = 4;
184 if (maxy > 32000) maxy = 32000;
185 if (minx < 2) minx = 2;
186 if (maxx > 32000) maxx = 32000;
187 }
188 else
189 {
190 minx = child0->minimumWidth() + child1->minimumWidth() + 4;
191 maxx = child0->maximumWidth() + child1->maximumWidth() + 4;
192 miny = (child0->minimumHeight() > child1->minimumHeight()) ? child0->minimumHeight() : child1->minimumHeight();
193 maxy = (child0->maximumHeight() > child1->maximumHeight()) ? child0->maximumHeight() : child1->maximumHeight();
194
195 if (miny < 2) miny = 2;
196 if (maxy > 32000) maxy = 32000;
197 if (minx < 4) minx = 4;
198 if (maxx > 32000) maxx = 32000;
199 }
200
201 setMinimumSize(minx, miny);
202 setMaximumSize(maxx, maxy);
203}
204
205void K3DockSplitter::deactivate()
206{
207 delete divider;
208 divider = 0L;
209 initialised= false;
210}
211
212int K3DockSplitter::separatorPosInPercent()
213{
214 return xpos / (factor/100);
215}
216
217void K3DockSplitter::setSeparatorPosInPercent(int percent)
218{
219 xpos = percent * (factor/100);
220}
221
222void K3DockSplitter::setSeparatorPos(int pos, bool do_resize)
223{
224 xpos = pos;
225 if (do_resize)
226 resizeEvent(0);
227}
228
229void K3DockSplitter::setSeparatorPosX(int pos, bool do_resize)
230{
231 savedXPos = pos;
232 setSeparatorPos( pos, do_resize );
233}
234
235int K3DockSplitter::separatorPos() const
236{
237 return xpos;
238}
239
240void K3DockSplitter::resizeEvent(QResizeEvent *ev)
241{
242 //
243 // As already stated in the .h file we always have to differentiate
244 // between 6 modes.
245 // If we can cast child0->getWidget() or child1.getWidget() to
246 // K3DockContainer* we *do* have a dockwidget around. For dockwidgets
247 // we have to take special care in the resizing routines, for example
248 // if mKeepSize is true and the dockcontainer is on the bottom or right,
249 // we always have to move the xpos splitter position. If there are no
250 // dockcontainers around, resizing is handeled like if child0 would
251 // be a dockcontainer.
252 //
253
254// kDebug(282)<<"ResizeEvent :"<< ((initialised) ? "initialised":"not initialised")<<", "<< ((ev) ? "real event":"")<<", "<<(isVisible() ?"visible":"");
255
256 if (initialised) {
257 K3DockContainer *dc = 0L;
258 K3DockWidget *c0 = (K3DockWidget*)child0;
259 K3DockWidget *c1 = (K3DockWidget*)child1;
260 bool stdHandling=false; // true: if closed or nonoverlap mode. false: overlap mode
261
262 //
263 // Check whether this is a real resize event or a pseudo resize event
264 // Real resize events occur if the width() or height() changes. ev != 0L.
265 // Pseudo resize events occur if the dockwidget mode changes (overlaped,
266 // sticky or closed). ev == 0L.
267 //
268 if (ev && isVisible() && divider->isVisible()) {
269 // real resize event.
270// kDebug(282)<<"mKeepSize : "<< ((m_orientation == Horizontal) ? "Horizontal":"Vertical");
271
272 if (mKeepSize) {
273 // keep the splitter on a fixed position. This may be a bit inaccurate, because
274 // xpos saves a proportional value, which means there might occur rounding errors.
275 // However, this works surprising well!
276 if (m_orientation == Qt::Horizontal) {
277 if (ev->oldSize().height() != ev->size().height()) {
278 if( (c1->getWidget()) && (dc=dynamic_cast<K3DockContainer*>(c1->getWidget()))) {
279 // dockwidget is on the bottom. move xpos so that the size from child1 stays
280 xpos = (int)ceil(((double)factor) * checkValue(height() - child1->height() - 4) / height());
281 } else {
282 // xpos should not change, the docking is on the top
283 // checkValue is *fuzzy* here, it leads to ugly rounding bugs
284 // In truth, it is not needed, because it is called when calculating the "position".
285 xpos = qRound(((double)xpos) * ev->oldSize().height() / height());
286 }
287 }
288 } else {
289 if (ev->oldSize().width() != width()) {
290 if( (c1->getWidget()) && (dc=dynamic_cast<K3DockContainer*>(c1->getWidget()))) {
291 xpos = (int)ceil(((double)factor) * checkValue(width() - child1->width() - 4) / width());
292 } else {
293 // xpos should not change
294 // checkValue is *fuzzy* here, it leads to ugly rounding bugs
295 xpos = qRound(((double)xpos) * ev->oldSize().width() / width());
296 }
297 }
298 }
299 } else {
300 // dockwidget size proportional!
301 // Which means, xpos is always right (ratio value). Do nothing! :)
302 }
303 }
304 else
305 {
306 //
307 // Maybe a multitabbartab was clicked, so force an update of the fixed
308 // values.
309 //
310 if ( isVisible()) {
311 if (m_orientation == Qt::Horizontal) {
312 if (fixedHeight0!=-1)
313 xpos = checkValue(fixedHeight0) * factor / height();
314 else if (fixedHeight1!=-1)
315 xpos = checkValue(height()-fixedHeight1) * factor / height();
316 }
317 else
318 {
319 if (fixedWidth0!=-1)
320 xpos = checkValue(fixedWidth0) * factor / width();
321 else if (fixedWidth1!=-1)
322 xpos = checkValue(width()-fixedWidth1) * factor / width();
323 }
324 }
325// else kDebug(282)<<"Something else happened";
326 }
327
328/*
329 // --- debugging information ---
330 kDebug(282) << "isVisible() is : " << isVisible();
331 kDebug(282) << "Orientation : " << (m_orientation==Horizontal?"Horizontal":"Vertical")
332 << endl;
333 kDebug(282) << "Splitter visibility : " << divider->isVisible();;
334 kDebug(282) << "Splitter procentual pos: " << xpos;
335 if (c0->getWidget()) {
336 dc=dynamic_cast<K3DockContainer*>(c0->getWidget());
337 kDebug(282) << "Child 0 K3DockContainer?: " << dc;
338 }
339 if (c1->getWidget()) {
340 dc=dynamic_cast<K3DockContainer*>(c1->getWidget());
341 kDebug(282) << "Child 1 K3DockContainer?: " << dc;
342 }
343 kDebug(282) << "Child0 : " << child0;
344 kDebug(282) << "child1 : " << child1;
345*/
346
347 //
348 // handle overlapped widgets only.
349 //
350 if( ( (m_orientation==Qt::Vertical) &&((fixedWidth0==-1) && (fixedWidth1==-1)) ) ||
351 ( (m_orientation==Qt::Horizontal) &&((fixedHeight0==-1) && (fixedHeight1==-1)) ) ) {
352 if ((c0->getWidget()) && (dc=dynamic_cast<K3DockContainer*>(c0->getWidget()))
353 && (dc->isOverlapMode())) {
354 // child0 is a K3DockContainer
355 int position;
356 child0->show();
357 child0->raise();
358 divider->raise();
359 if (m_orientation == Qt::Horizontal) {
360 position = checkValueOverlapped( height() * xpos / factor, child0 );
361 child0->setGeometry(0, 0, width(), position);
362 child1->setGeometry(0, dc->m_nonOverlapSize, width(), height()-dc->m_nonOverlapSize);
363 divider->setGeometry(0, position, width(), 4);
364 } else {
365 position = checkValueOverlapped( width() * xpos / factor, child0 );
366 child0->setGeometry(0, 0, position, height());
367 child1->setGeometry(dc->m_nonOverlapSize, 0, width()-dc->m_nonOverlapSize, height());
368 divider->setGeometry(position, 0, 4, height());
369 }
370 } else {
371 if ((c1->getWidget()) && (dc=dynamic_cast<K3DockContainer*>(c1->getWidget()))
372 && (dc->isOverlapMode())) {
373 // child1 is a K3DockContainer
374 int position;
375 child1->show();
376 child1->raise();
377 divider->raise();
378 if (m_orientation == Qt::Horizontal) {
379 position = checkValueOverlapped( height() * xpos / factor, child1 );
380 child0->setGeometry(0, 0, width(), height()-dc->m_nonOverlapSize);
381 child1->setGeometry(0, position+4, width(), height()-position-4);
382 divider->setGeometry(0, position, width(), 4);
383 } else {
384 position = checkValueOverlapped( width() * xpos / factor, child1 );
385 child0->setGeometry(0, 0, width()-dc->m_nonOverlapSize, height());
386 child1->setGeometry(position+4, 0, width()-position-4, height());
387 divider->setGeometry(position, 0, 4, height());
388 }
389 }
390 else // no K3DockContainer available, this means the mode cannot be overlapped
391 stdHandling=true;
392 }
393 }
394 else // no K3DockContainer available
395 stdHandling=true;
396
397 //
398 // stdHandling == true means either sticky mode (=nonoverlap mode) or
399 // closed mode. In both modes the widgets do *not* overlap, so we know
400 // the child0 and child1 adjoin.
401 //
402 if (stdHandling) {
403 int position = checkValue( (m_orientation == Qt::Vertical ? width() : height()) * xpos / factor );
404 int diff = 0;
405
406 if (m_orientation == Qt::Horizontal) {
407 if ((c1->getWidget()) && (dc=dynamic_cast<K3DockContainer*>(c1->getWidget()))) {
408 // bottom is dockcontainer
409 if( divider->isVisible() ) {
410 child0->setGeometry(0, 0, width(), position);
411 child1->setGeometry(0, position+4, width(), height()-position-4);
412 } else {
413 child0->setGeometry(0, 0, width(), height()-dc->m_nonOverlapSize);
414 child1->setGeometry(0, height()-dc->m_nonOverlapSize, width(), height());
415 }
416 } else {
417 if( divider->isVisible() ) diff = 4;
418 child0->setGeometry(0, 0, width(), position);
419 child1->setGeometry(0, position+diff, width(), height()-position-diff);
420 }
421 divider->setGeometry(0, position, width(), 4);
422 } else {
423 if ((c1->getWidget()) && (dc=dynamic_cast<K3DockContainer*>(c1->getWidget()))) {
424 // right is dockcontainer
425 if( divider->isVisible() ) {
426 child0->setGeometry(0, 0, position, height());
427 child1->setGeometry(position+4, 0, width()-position-4, height());
428 } else {
429 child0->setGeometry(0, 0, width()-dc->m_nonOverlapSize, height());
430 child1->setGeometry(width()-dc->m_nonOverlapSize, 0, width(), height());
431 }
432 } else {
433 if( divider->isVisible() ) diff = 4;
434 child0->setGeometry(0, 0, position, height());
435 child1->setGeometry(position+diff, 0, width()-position-diff, height());
436 }
437 divider->setGeometry(position, 0, 4, height());
438 }
439 }
440 }
441}
442
443int K3DockSplitter::checkValueOverlapped(int position, QWidget *overlappingWidget) const
444{
445 if (initialised) {
446 if (m_orientation == Qt::Vertical) {
447 if (child0==overlappingWidget) {
448 if (position < child0->minimumWidth() || position > width())
449 position = child0->minimumWidth();
450 } else {
451 if (position > (width()-child1->minimumWidth()-4) || position < 0)
452 position = width()-child1->minimumWidth()-4;
453 }
454 } else {// orientation == Horizontal
455 if (child0==overlappingWidget) {
456 if (position < (child0->minimumHeight()) || position > height())
457 position = child0->minimumHeight();
458 } else {
459 if (position>(height()-child1->minimumHeight()-4) || position < 0)
460 position = height()-child1->minimumHeight()-4;
461 }
462 }
463 }
464 return position;
465}
466
467int K3DockSplitter::checkValue( int position ) const
468{
469 if (initialised) {
470 if (m_orientation == Qt::Vertical) {
471 if (position < child0->minimumWidth())
472 position = child0->minimumWidth();
473 if ((width()-4-position) < (child1->minimumWidth()))
474 position = width() - (child1->minimumWidth()) - 4;
475 } else {
476 if (position < (child0->minimumHeight()))
477 position = child0->minimumHeight();
478 if ((height()-4-position) < child1->minimumHeight())
479 position = height() - (child1->minimumHeight()) - 4;
480 }
481 }
482
483 if (position < 0) position = 0;
484
485 if ((m_orientation == Qt::Vertical) && (position > width()))
486 position = width();
487 if ((m_orientation == Qt::Horizontal) && (position > height()))
488 position = height();
489
490 return position;
491}
492
493bool K3DockSplitter::eventFilter(QObject *o, QEvent *e)
494{
495 QMouseEvent *mev;
496 bool handled = false;
497
498 switch (e->type()) {
499 case QEvent::MouseMove:
500 mev= (QMouseEvent*)e;
501 child0->setUpdatesEnabled(mOpaqueResize);
502 child1->setUpdatesEnabled(mOpaqueResize);
503 if (m_orientation == Qt::Horizontal) {
504 if ((fixedHeight0!=-1) || (fixedHeight1!=-1))
505 {
506 handled=true; break;
507 }
508
509 if (!mOpaqueResize) {
510 int position = checkValue( mapFromGlobal(mev->globalPos()).y() );
511 divider->move( 0, position );
512 } else {
513 int tmp_xpos = factor * checkValue( mapFromGlobal(mev->globalPos()).y() ) / height();
514 if (tmp_xpos != xpos) {
515 xpos = tmp_xpos;
516 resizeEvent(0);
517 divider->repaint();
518 }
519 }
520 } else {
521 if ((fixedWidth0!=-1) || (fixedWidth1!=-1))
522 {
523 handled=true; break;
524 }
525 if (!mOpaqueResize) {
526 int position = checkValue( mapFromGlobal(QCursor::pos()).x() );
527 divider->move( position, 0 );
528 } else {
529 int tmp_xpos = factor * checkValue( mapFromGlobal( mev->globalPos()).x() ) / width();
530 if (tmp_xpos != xpos) {
531 xpos = tmp_xpos;
532 resizeEvent(0);
533 divider->repaint();
534 }
535 }
536 }
537 handled= true;
538 break;
539 case QEvent::MouseButtonRelease:
540 child0->setUpdatesEnabled(true);
541 child1->setUpdatesEnabled(true);
542 mev= (QMouseEvent*)e;
543 if (m_orientation == Qt::Horizontal){
544 if ((fixedHeight0!=-1) || (fixedHeight1!=-1))
545 {
546 handled=true; break;
547 }
548 xpos = factor* checkValue( mapFromGlobal(mev->globalPos()).y() ) / height();
549 resizeEvent(0);
550 divider->repaint();
551 } else {
552 if ((fixedWidth0!=-1) || (fixedWidth1!=-1))
553 {
554 handled=true; break;
555 }
556 xpos = factor* checkValue( mapFromGlobal(mev->globalPos()).x() ) / width();
557 resizeEvent(0);
558 divider->repaint();
559 }
560 handled= true;
561 break;
562 default:
563 break;
564 }
565 return (handled) ? true : QWidget::eventFilter( o, e );
566}
567
568bool K3DockSplitter::event( QEvent* e )
569{
570 if ( e->type() == QEvent::LayoutHint ){
571 // change children min/max size. This is needed, otherwise
572 // it is possible the divider get's out of bounds.
573 setupMinMaxSize();
574 resizeEvent(0);
575 }
576 return QWidget::event(e);
577}
578
579QWidget* K3DockSplitter::getAnother( QWidget* w ) const
580{
581 return ( w == child0 ) ? child1 : child0;
582}
583
584void K3DockSplitter::updateName()
585{
586 if ( !initialised ) return;
587
588 QString new_name = QString( child0->name() ) + ',' + child1->name();
589 parentWidget()->setName( new_name.toLatin1().constData() );
590 parentWidget()->setWindowTitle( child0->windowTitle() + ',' + child1->windowTitle() );
591 parentWidget()->repaint( );
592
593 ((K3DockWidget*)parentWidget())->firstName = child0->name();
594 ((K3DockWidget*)parentWidget())->lastName = child1->name();
595 ((K3DockWidget*)parentWidget())->splitterOrientation = m_orientation;
596
597 QWidget* p = parentWidget()->parentWidget();
598 if ( p && p->inherits("K3DockSplitter" ) )
599 ((K3DockSplitter*)p)->updateName();
600}
601
602void K3DockSplitter::setOpaqueResize(bool b)
603{
604 mOpaqueResize = b;
605}
606
607bool K3DockSplitter::opaqueResize() const
608{
609 return mOpaqueResize;
610}
611
612void K3DockSplitter::setKeepSize(bool b)
613{
614 mKeepSize = b;
615}
616
617bool K3DockSplitter::keepSize() const
618{
619 return mKeepSize;
620}
621
622
623
624/*************************************************************************/
625K3DockButton_Private::K3DockButton_Private( QWidget *parent, const char * name )
626:QPushButton( parent, name )
627{
628 moveMouse = false;
629 setFocusPolicy( Qt::NoFocus );
630}
631
632K3DockButton_Private::~K3DockButton_Private()
633{
634}
635
636void K3DockButton_Private::drawButton( QPainter* p )
637{
638 p->fillRect( 0,0, width(), height(), QBrush(QColorGroup(palette()).brush(QPalette::Background)) );
639#if 1
640 // ### TODO: is the centering done automatically or do we need some codelike for KDE3 (see below the #else part)
641 icon().paint( p, rect() );
642#else
643 p->drawPixmap( (width() - pixmap()->width()) / 2, (height() - pixmap()->height()) / 2, *pixmap() );
644#endif
645 if ( moveMouse && !isDown() ){
646 p->setPen( Qt::white );
647 p->drawLine( 0, height() - 1, 0, 0 );
648 p->drawLine( 0, 0, width() -1 , 0 );
649
650 p->setPen( QColorGroup(palette()).dark() );
651 p->drawLine( width() -1, 0, width() - 1, height() - 1 );
652 p->drawLine( width() - 1, height() - 1, 0, height() - 1 );
653 }
654 if ( isChecked() || isDown() ){
655 p->setPen( QColorGroup(palette()).dark() );
656 p->drawLine(0 , height() - 1, 0, 0);
657 p->drawLine(0, 0, width() -1 , 0);
658
659 p->setPen( Qt::white );
660 p->drawLine(width() - 1, height() - 1, 0, height() - 1);
661 }
662}
663
664void K3DockButton_Private::enterEvent( QEvent * )
665{
666 moveMouse = true;
667 repaint();
668}
669
670void K3DockButton_Private::leaveEvent( QEvent * )
671{
672 moveMouse = false;
673 repaint();
674}
675
676void K3DockButton_Private::paintEvent( QPaintEvent * )
677{
678 QPainter painter( this );
679 drawButton( &painter );
680}
681
682/*************************************************************************/
683K3DockWidgetPrivate::K3DockWidgetPrivate()
684 : QObject()
685 ,index(-1)
686 ,splitPosInPercent(50)
687 ,pendingFocusInEvent(false)
688 ,blockHasUndockedSignal(false)
689 ,pendingDtor(false)
690 ,forcedWidth(-1)
691 ,forcedHeight(-1)
692 ,isContainer(false)
693 ,container(0)
694 ,resizePos(0,0)
695 ,resizing(false)
696{
697#ifndef NO_KDE2
698 windowType = NET::Normal;
699#endif
700
701 _parent = 0L;
702 transient = false;
703}
704
705K3DockWidgetPrivate::~K3DockWidgetPrivate()
706{
707}
708
709void K3DockWidgetPrivate::slotFocusEmbeddedWidget(QWidget* w)
710{
711 if (w) {
712 QWidget* embeddedWdg = ((K3DockWidget*)w)->getWidget();
713 if (embeddedWdg && ((embeddedWdg->focusPolicy() == Qt::ClickFocus) || (embeddedWdg->focusPolicy() == Qt::StrongFocus))) {
714 embeddedWdg->setFocus();
715 }
716 }
717}
718
719#ifndef NO_INCLUDE_MOCFILES // for Qt-only projects, because tmake doesn't take this name
720#include "k3dockwidget_private.moc"
721#endif
K3DockButton_Private::K3DockButton_Private
K3DockButton_Private(QWidget *parent=0, const char *name=0)
Definition: k3dockwidget_private.cpp:625
K3DockButton_Private::enterEvent
virtual void enterEvent(QEvent *)
Definition: k3dockwidget_private.cpp:664
K3DockButton_Private::drawButton
virtual void drawButton(QPainter *)
Definition: k3dockwidget_private.cpp:636
K3DockButton_Private::~K3DockButton_Private
~K3DockButton_Private()
Definition: k3dockwidget_private.cpp:632
K3DockButton_Private::leaveEvent
virtual void leaveEvent(QEvent *)
Definition: k3dockwidget_private.cpp:670
K3DockButton_Private::paintEvent
virtual void paintEvent(QPaintEvent *)
Definition: k3dockwidget_private.cpp:676
K3DockContainer
Definition: k3dockwidget_p.h:44
K3DockContainer::isOverlapMode
bool isOverlapMode()
Definition: k3dockwidget.cpp:3332
K3DockSplitter
Like QSplitter but specially designed for dockwidgets stuff.
Definition: k3dockwidget_private.h:50
K3DockSplitter::K3DockSplitter
K3DockSplitter(QWidget *parent=0, const char *name=0, Qt::Orientation orient=Qt::Vertical, int pos=50)
Constructor.
Definition: k3dockwidget_private.cpp:33
K3DockSplitter::deactivate
void deactivate()
Disables the splitter.
Definition: k3dockwidget_private.cpp:205
K3DockSplitter::checkValue
int checkValue(int position) const
Make sure the splitter position is not out of bounds.
Definition: k3dockwidget_private.cpp:467
K3DockSplitter::keepSize
bool keepSize() const
Definition: k3dockwidget_private.cpp:617
K3DockSplitter::event
virtual bool event(QEvent *)
Definition: k3dockwidget_private.cpp:568
K3DockSplitter::separatorPos
int separatorPos() const
Return the separator position in the range [0..100000] To get the separator position in procent (%),...
Definition: k3dockwidget_private.cpp:235
K3DockSplitter::setSeparatorPosInPercent
void setSeparatorPosInPercent(int percent)
Set the separator position in percent (%), so the range must be [0..100].
Definition: k3dockwidget_private.cpp:217
K3DockSplitter::activate
void activate(QWidget *c0, QWidget *c1=0L)
Initialize the splitter.
Definition: k3dockwidget_private.cpp:52
K3DockSplitter::opaqueResize
bool opaqueResize() const
Definition: k3dockwidget_private.cpp:607
K3DockSplitter::getAnother
QWidget * getAnother(QWidget *w) const
If w is child0, return child1, otherwise child0.
Definition: k3dockwidget_private.cpp:579
K3DockSplitter::checkValueOverlapped
int checkValueOverlapped(int position, QWidget *child) const
Make sure the splitter position is not out of bounds.
Definition: k3dockwidget_private.cpp:443
K3DockSplitter::separatorPosInPercent
int separatorPosInPercent()
Return the separator position in percent (%), so the range is [0..100].
Definition: k3dockwidget_private.cpp:212
K3DockSplitter::setSeparatorPos
void setSeparatorPos(int pos, bool do_resize=true)
set separator position.
Definition: k3dockwidget_private.cpp:222
K3DockSplitter::restoreFromForcedFixedSize
void restoreFromForcedFixedSize(K3DockWidget *dw)
Definition: k3dockwidget_private.cpp:155
K3DockSplitter::setSeparatorPosX
void setSeparatorPosX(int pos, bool do_resize=false)
For usage from outside.
Definition: k3dockwidget_private.cpp:229
K3DockSplitter::setOpaqueResize
void setOpaqueResize(bool b=true)
Set opaque flag.
Definition: k3dockwidget_private.cpp:602
K3DockSplitter::setForcedFixedHeight
void setForcedFixedHeight(K3DockWidget *dw, int h)
Definition: k3dockwidget_private.cpp:133
K3DockSplitter::eventFilter
virtual bool eventFilter(QObject *, QEvent *)
The eventfilter installed on the divider processes all splitter resizing events.
Definition: k3dockwidget_private.cpp:493
K3DockSplitter::resizeEvent
virtual void resizeEvent(QResizeEvent *ev)
The resize event resizes child0, child1 and the divider.
Definition: k3dockwidget_private.cpp:240
K3DockSplitter::setKeepSize
void setKeepSize(bool b=true)
If b is true, the splitter will keep its size on resize events.
Definition: k3dockwidget_private.cpp:612
K3DockSplitter::setForcedFixedWidth
void setForcedFixedWidth(K3DockWidget *dw, int w)
Definition: k3dockwidget_private.cpp:111
K3DockSplitter::updateName
void updateName()
Definition: k3dockwidget_private.cpp:584
K3DockWidgetPrivate::windowType
NET::WindowType windowType
Definition: k3dockwidget_private.h:306
K3DockWidgetPrivate::K3DockWidgetPrivate
K3DockWidgetPrivate()
Definition: k3dockwidget_private.cpp:683
K3DockWidgetPrivate::slotFocusEmbeddedWidget
void slotFocusEmbeddedWidget(QWidget *w=0L)
Especially used for Tab page docking.
Definition: k3dockwidget_private.cpp:709
K3DockWidgetPrivate::transient
bool transient
Definition: k3dockwidget_private.h:310
K3DockWidgetPrivate::_parent
QWidget * _parent
Definition: k3dockwidget_private.h:309
K3DockWidgetPrivate::~K3DockWidgetPrivate
~K3DockWidgetPrivate()
Definition: k3dockwidget_private.cpp:705
K3DockWidget
Floatable widget that can be dragged around with the mouse and encapsulate the actual widgets (and me...
Definition: k3dockwidget.h:416
K3DockWidget::forcedFixedWidth
int forcedFixedWidth()
Definition: k3dockwidget.cpp:1330
K3DockWidget::getWidget
QWidget * getWidget() const
Get the embedded widget.
Definition: k3dockwidget.cpp:1569
K3DockWidget::forcedFixedHeight
int forcedFixedHeight()
Definition: k3dockwidget.cpp:1335
NET::Normal
Normal
QCursor
QEvent
QFrame
QObject
QPushButton
QWidget
k3dockwidget.h
k3dockwidget_p.h
k3dockwidget_private.h
kdebug.h
name
const char * name(StandardAction id)
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Mon Feb 20 2023 00:00:00 by doxygen 1.9.6 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

KDE3Support

Skip menu "KDE3Support"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

kdelibs-4.14.38 API Reference

Skip menu "kdelibs-4.14.38 API Reference"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDEWebKit
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUnitConversion
  • KUtils
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver
Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal