1 /********************************************************************
2 This program is free software; you can redistribute it and/or modify
3 it under the terms of the GNU General Public License as published by
4 the Free Software Foundation; either version 2 of the License, or
5 (at your option) any later version.
7 This program is distributed in the hope that it will be useful,
8 but WITHOUT ANY WARRANTY; without even the implied warranty of
9 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 GNU General Public License for more details.
12 You should have received a copy of the GNU General Public License
13 along with this program. If not, see <http://www.gnu.org/licenses/>.
14 *********************************************************************/
16 #include "kwmthemeclient.h"
21 #include <qdrawutil.h>
23 #include <kpixmapeffect.h>
24 #include <kstandarddirs.h>
35 /* static QPixmap stretchPixmap(QPixmap& src, bool stretchVert){
37 QBitmap *srcMask, *destMask;
41 if (src.isNull()) return src;
48 for (h2=h; h2<100; h2=h2<<1)
53 for (w2=w; w2<100; w2=w2<<1)
56 if (w2==w && h2==h) return src;
62 p.drawTiledPixmap(0, 0, w2, h2, src);
65 srcMask = (QBitmap*)src.mask();
67 destMask = (QBitmap*)dest.mask();
69 p.drawTiledPixmap(0, 0, w2, h2, *srcMask);
76 inline const KDecorationOptions
* options() { return KDecoration::options(); }
78 enum FramePixmap
{FrameTop
=0, FrameBottom
, FrameLeft
, FrameRight
, FrameTopLeft
,
79 FrameTopRight
, FrameBottomLeft
, FrameBottomRight
};
81 static QPixmap
*framePixmaps
[8];
82 static QPixmap
*menuPix
, *iconifyPix
, *closePix
, *maxPix
, *minmaxPix
,
83 *pinupPix
, *pindownPix
;
84 static QPixmap
*aTitlePix
= 0;
85 static QPixmap
*iTitlePix
= 0;
86 static KPixmapEffect::GradientType grType
;
87 static int maxExtent
, titleAlign
;
88 static bool titleGradient
= true;
89 static bool pixmaps_created
= false;
90 static bool titleSunken
= false;
91 static bool titleTransparent
;
93 static void create_pixmaps()
95 const char *keys
[] = {"wm_top", "wm_bottom", "wm_left", "wm_right",
96 "wm_topleft", "wm_topright", "wm_bottomleft", "wm_bottomright"};
100 pixmaps_created
= true;
102 KSharedConfig::Ptr _config
= KGlobal::config();
103 KConfigGroup
config(_config
, "General");
107 for(int i
=0; i
< 8; ++i
)
109 framePixmaps
[i
] = new QPixmap(locate("data",
110 "kwin/pics/"+config
.readEntry(keys
[i
], " ")));
111 if(framePixmaps
[i
]->isNull())
112 kWarning(1212) << "Unable to load frame pixmap for " << keys
[i
] ;
115 *framePixmaps[FrameTop] = stretchPixmap(*framePixmaps[FrameTop], false);
116 *framePixmaps[FrameBottom] = stretchPixmap(*framePixmaps[FrameBottom], false);
117 *framePixmaps[FrameLeft] = stretchPixmap(*framePixmaps[FrameLeft], true);
118 *framePixmaps[FrameRight] = stretchPixmap(*framePixmaps[FrameRight], true);
120 maxExtent
= framePixmaps
[FrameTop
]->height();
121 if(framePixmaps
[FrameBottom
]->height() > maxExtent
)
122 maxExtent
= framePixmaps
[FrameBottom
]->height();
123 if(framePixmaps
[FrameLeft
]->width() > maxExtent
)
124 maxExtent
= framePixmaps
[FrameLeft
]->width();
125 if(framePixmaps
[FrameRight
]->width() > maxExtent
)
126 maxExtent
= framePixmaps
[FrameRight
]->width();
130 menuPix
= new QPixmap(locate("data",
131 "kwin/pics/"+config
.readEntry("menu", " ")));
132 iconifyPix
= new QPixmap(locate("data",
133 "kwin/pics/"+config
.readEntry("iconify", " ")));
134 maxPix
= new QPixmap(locate("appdata",
135 "pics/"+config
.readEntry("maximize", " ")));
136 minmaxPix
= new QPixmap(locate("data",
137 "kwin/pics/"+config
.readEntry("maximizedown", " ")));
138 closePix
= new QPixmap(locate("data",
139 "kwin/pics/"+config
.readEntry("close", " ")));
140 pinupPix
= new QPixmap(locate("data",
141 "kwin/pics/"+config
.readEntry("pinup", " ")));
142 pindownPix
= new QPixmap(locate("data",
143 "kwin/pics/"+config
.readEntry("pindown", " ")));
144 if(menuPix
->isNull())
145 menuPix
->load(locate("data", "kwin/pics/menu.png"));
146 if(iconifyPix
->isNull())
147 iconifyPix
->load(locate("data", "kwin/pics/iconify.png"));
149 maxPix
->load(locate("data", "kwin/pics/maximize.png"));
150 if(minmaxPix
->isNull())
151 minmaxPix
->load(locate("data", "kwin/pics/maximizedown.png"));
152 if(closePix
->isNull())
153 closePix
->load(locate("data", "kwin/pics/close.png"));
154 if(pinupPix
->isNull())
155 pinupPix
->load(locate("data", "kwin/pics/pinup.png"));
156 if(pindownPix
->isNull())
157 pindownPix
->load(locate("data", "kwin/pics/pindown.png"));
159 tmpStr
= config
.readEntry("TitleAlignment");
160 if(tmpStr
== "right")
161 titleAlign
= Qt::AlignRight
| Qt::AlignVCenter
;
162 else if(tmpStr
== "middle")
163 titleAlign
= Qt::AlignCenter
;
165 titleAlign
= Qt::AlignLeft
| Qt::AlignVCenter
;
166 titleSunken
= config
.readEntry("TitleFrameShaded", true );
167 // titleSunken = true; // is this fixed?
168 titleTransparent
= config
.readEntry("PixmapUnderTitleText", true);
170 tmpStr
= config
.readEntry("TitlebarLook");
171 if(tmpStr
== "shadedVertical"){
172 aTitlePix
= new QPixmap
;
173 aTitlePix
->resize(32, 20);
174 KPixmapEffect::gradient(*aTitlePix
,
175 options()->color(KDecorationOptions::ColorTitleBar
, true),
176 options()->color(KDecorationOptions::ColorTitleBlend
, true),
177 KPixmapEffect::VerticalGradient
);
178 iTitlePix
= new QPixmap
;
179 iTitlePix
->resize(32, 20);
180 KPixmapEffect::gradient(*iTitlePix
,
181 options()->color(KDecorationOptions::ColorTitleBar
, false),
182 options()->color(KDecorationOptions::ColorTitleBlend
, false),
183 KPixmapEffect::VerticalGradient
);
184 titleGradient
= false; // we can just tile this
187 else if(tmpStr
== "shadedHorizontal")
188 grType
= KPixmapEffect::HorizontalGradient
;
189 else if(tmpStr
== "shadedDiagonal")
190 grType
= KPixmapEffect::DiagonalGradient
;
191 else if(tmpStr
== "shadedCrossDiagonal")
192 grType
= KPixmapEffect::CrossDiagonalGradient
;
193 else if(tmpStr
== "shadedPyramid")
194 grType
= KPixmapEffect::PyramidGradient
;
195 else if(tmpStr
== "shadedRectangle")
196 grType
= KPixmapEffect::RectangleGradient
;
197 else if(tmpStr
== "shadedPipeCross")
198 grType
= KPixmapEffect::PipeCrossGradient
;
199 else if(tmpStr
== "shadedElliptic")
200 grType
= KPixmapEffect::EllipticGradient
;
202 titleGradient
= false;
203 tmpStr
= config
.readEntry("TitlebarPixmapActive", "");
204 if(!tmpStr
.isEmpty()){
205 aTitlePix
= new QPixmap
;
206 aTitlePix
->load(locate("data", "kwin/pics/" + tmpStr
));
210 tmpStr
= config
.readEntry("TitlebarPixmapInactive", "");
211 if(!tmpStr
.isEmpty()){
212 iTitlePix
= new QPixmap
;
213 iTitlePix
->load(locate("data", "kwin/pics/" + tmpStr
));
220 static void delete_pixmaps()
222 for(int i
=0; i
< 8; ++i
)
223 delete framePixmaps
[i
];
237 titleGradient
= true;
238 pixmaps_created
= false;
242 void MyButton::drawButtonLabel(QPainter
*p
)
245 // If we have a theme who's button covers the entire width or
246 // entire height, we shift down/right by 1 pixel so we have
247 // some visual notification of button presses. i.e. for MGBriezh
248 int offset
= (isDown() && ((pixmap()->width() >= width()) ||
249 (pixmap()->height() >= height()))) ? 1 : 0;
250 style().drawItem(p
, QRect( offset
, offset
, width(), height() ),
251 AlignCenter
, colorGroup(),
252 true, pixmap(), QString());
256 KWMThemeClient::KWMThemeClient( KDecorationBridge
* b
, KDecorationFactory
* f
)
257 : KDecoration( b
, f
)
261 void KWMThemeClient::init()
263 createMainWidget( WResizeNoErase
| WStaticContents
);
264 widget()->installEventFilter( this );
266 stickyBtn
= maxBtn
= mnuBtn
= 0;
267 layout
= new QGridLayout(widget());
268 layout
->addColSpacing(0, maxExtent
);
269 layout
->addColSpacing(2, maxExtent
);
271 layout
->addRowSpacing(0, maxExtent
);
273 layout
->addItem(new QSpacerItem(1, 1, QSizePolicy::Fixed
,
274 QSizePolicy::Expanding
));
277 layout
->addWidget( new QLabel( i18n( "<center><b>KWMTheme</b></center>" ), widget()), 2, 1);
279 layout
->addItem( new QSpacerItem( 0, 0 ), 2, 1);
281 // Without the next line, shading flickers
282 layout
->addItem( new QSpacerItem(0, 0, QSizePolicy::Fixed
, QSizePolicy::Expanding
) );
283 layout
->addRowSpacing(3, maxExtent
);
284 layout
->setRowStretch(2, 10);
285 layout
->setColumnStretch(1, 10);
287 QBoxLayout
* hb
= new QBoxLayout(0, QBoxLayout::LeftToRight
, 0, 0, 0);
288 layout
->addLayout( hb
, 1, 1 );
290 KSharedConfig::Ptr _config
= KGlobal::config();
291 KConfigGroup
config(_config
, "Buttons");
295 static const char *defaultButtons
[]={"Menu","Sticky","Off","Iconify",
297 static const char keyOffsets
[]={"ABCDEF"};
298 for(i
=0; i
< 6; ++i
){
300 titlebar
= new QSpacerItem(10, 20, QSizePolicy::Expanding
,
301 QSizePolicy::Minimum
);
302 hb
->addItem( titlebar
);
304 QString
key("Button");
305 key
+= QChar(keyOffsets
[i
]);
306 val
= config
.readEntry(key
, defaultButtons
[i
]);
308 mnuBtn
= new MyButton(widget(), "menu");
309 mnuBtn
->setToolTip( i18n("Menu"));
311 hb
->addWidget(mnuBtn
);
312 mnuBtn
->setFixedSize(20, 20);
313 connect(mnuBtn
, SIGNAL(pressed()), this,
314 SLOT(menuButtonPressed()));
316 else if(val
== "Sticky"){
317 stickyBtn
= new MyButton(widget(), "sticky");
318 stickyBtn
->setToolTip( i18n("Sticky"));
319 if (isOnAllDesktops())
320 stickyBtn
->setPixmap(*pindownPix
);
322 stickyBtn
->setPixmap(*pinupPix
);
323 connect(stickyBtn
, SIGNAL( clicked() ), this, SLOT(toggleOnAllDesktops()));
324 hb
->addWidget(stickyBtn
);
325 stickyBtn
->setFixedSize(20, 20);
327 else if((val
== "Iconify") && isMinimizable()){
328 btn
= new MyButton(widget(), "iconify");
329 btn
->setToolTip( i18n("Minimize"));
330 btn
->setPixmap(*iconifyPix
);
331 connect(btn
, SIGNAL(clicked()), this, SLOT(minimize()));
333 btn
->setFixedSize(20, 20);
335 else if((val
== "Maximize") && isMaximizable()){
336 maxBtn
= new MyButton(widget(), "max");
337 maxBtn
->setToolTip( i18n("Maximize"));
338 maxBtn
->setPixmap(*maxPix
);
339 connect(maxBtn
, SIGNAL(clicked()), this, SLOT(maximize()));
340 hb
->addWidget(maxBtn
);
341 maxBtn
->setFixedSize(20, 20);
343 else if((val
== "Close") && isCloseable()){
344 btn
= new MyButton(widget(), "close");
345 btn
->setToolTip( i18n("Close"));
346 btn
->setPixmap(*closePix
);
347 connect(btn
, SIGNAL(clicked()), this, SLOT(closeWindow()));
349 btn
->setFixedSize(20, 20);
353 ((val
== "Iconify") && !isMinimizable()) &&
354 ((val
== "Maximize") && !isMaximizable()))
355 kWarning(1212) << "KWin: Unrecognized button value: " << val
;
360 aGradient
= new QPixmap
;
361 iGradient
= new QPixmap
;
367 widget()->setBackgroundMode(NoBackground
);
370 void KWMThemeClient::drawTitle(QPainter
&dest
)
372 QRect titleRect
= titlebar
->geometry();
373 QRect
r(0, 0, titleRect
.width(), titleRect
.height());
376 if(buffer
.width() == r
.width())
379 buffer
.resize(r
.size());
384 qDrawShadeRect(&p
, r
, options()->palette(KDecorationOptions::ColorFrame
, isActive()).active(),
386 r
.setRect(r
.x()+1, r
.y()+1, r
.width()-2, r
.height()-2);
389 QPixmap
*fill
= isActive() ? aTitlePix
: iTitlePix
;
391 p
.drawTiledPixmap(r
, *fill
);
392 else if(titleGradient
){
393 fill
= isActive() ? aGradient
: iGradient
;
394 if(fill
->width() != r
.width()){
395 fill
->resize(r
.width(), 20);
396 KPixmapEffect::gradient(*fill
,
397 options()->color(KDecorationOptions::ColorTitleBar
, isActive()),
398 options()->color(KDecorationOptions::ColorTitleBlend
, isActive()),
401 p
.drawTiledPixmap(r
, *fill
);
404 p
.fillRect(r
, options()->palette(KDecorationOptions::ColorTitleBar
, isActive()).active().
405 brush(QPalette::Button
));
407 p
.setFont(options()->font(isActive()));
408 p
.setPen(options()->color(KDecorationOptions::ColorFont
, isActive()));
409 // Add left & right margin
410 r
.setLeft(r
.left()+5);
411 r
.setRight(r
.right()-5);
412 p
.drawText(r
, titleAlign
, caption());
415 dest
.drawPixmap(titleRect
.x(), titleRect
.y(), buffer
);
419 void KWMThemeClient::resizeEvent( QResizeEvent
* )
425 void KWMThemeClient::captionChange()
427 widget()->repaint( titlebar
->geometry(), false );
430 void KWMThemeClient::paintEvent( QPaintEvent
*)
436 int w1
= framePixmaps
[FrameTopLeft
]->width();
437 int h1
= framePixmaps
[FrameTopLeft
]->height();
438 if (w1
> width()/2) w1
= width()/2;
439 if (h1
> height()/2) h1
= height()/2;
440 p
.drawPixmap(0,0,*framePixmaps
[FrameTopLeft
],
442 int w2
= framePixmaps
[FrameTopRight
]->width();
443 int h2
= framePixmaps
[FrameTopRight
]->height();
444 if (w2
> width()/2) w2
= width()/2;
445 if (h2
> height()/2) h2
= height()/2;
446 p
.drawPixmap(width()-w2
,0,*framePixmaps
[FrameTopRight
],
447 framePixmaps
[FrameTopRight
]->width()-w2
,0,w2
, h2
);
449 int w3
= framePixmaps
[FrameBottomLeft
]->width();
450 int h3
= framePixmaps
[FrameBottomLeft
]->height();
451 if (w3
> width()/2) w3
= width()/2;
452 if (h3
> height()/2) h3
= height()/2;
453 p
.drawPixmap(0,height()-h3
,*framePixmaps
[FrameBottomLeft
],
454 0,framePixmaps
[FrameBottomLeft
]->height()-h3
,w3
, h3
);
456 int w4
= framePixmaps
[FrameBottomRight
]->width();
457 int h4
= framePixmaps
[FrameBottomRight
]->height();
458 if (w4
> width()/2) w4
= width()/2;
459 if (h4
> height()/2) h4
= height()/2;
460 p
.drawPixmap(width()-w4
,height()-h4
,*(framePixmaps
[FrameBottomRight
]),
461 framePixmaps
[FrameBottomRight
]->width()-w4
,
462 framePixmaps
[FrameBottomRight
]->height()-h4
,
469 pm
= *framePixmaps
[FrameTop
];
476 m
.scale(w
/(float)pm
.width(), 1);
477 pm
= pm
.transformed(m
);
481 if (pm
.width() < width()-w2
-x
){
482 p
.drawPixmap(x
,maxExtent
-pm
.height()-1,
487 p
.drawPixmap(x
,maxExtent
-pm
.height()-1,
489 0,0,width()-w2
-x
,pm
.height());
496 pm
= *framePixmaps
[FrameBottom
];
503 m
.scale(w
/(float)pm
.width(), 1);
504 pm
= pm
.transformed(m
);
508 if (pm
.width() < width()-w4
-x
){
509 p
.drawPixmap(x
,height()-maxExtent
+1,pm
);
513 p
.drawPixmap(x
,height()-maxExtent
+1,pm
,
514 0,0,width()-w4
-x
,pm
.height());
521 pm
= *framePixmaps
[FrameLeft
];
523 if (pm
.height() > 0){
528 m
.scale(1, w
/(float)pm
.height());
529 pm
= pm
.transformed(m
);
533 if (pm
.height() < height()-h3
-y
){
534 p
.drawPixmap(maxExtent
-pm
.width()-1, y
,
539 p
.drawPixmap(maxExtent
-pm
.width()-1, y
,
549 pm
= *framePixmaps
[FrameRight
];
551 if (pm
.height() > 0){
556 m
.scale(1, w
/(float)pm
.height());
557 pm
= pm
.transformed(m
);
561 if (pm
.height() < height()-h4
-y
){
562 p
.drawPixmap(width()-maxExtent
+1, y
,
567 p
.drawPixmap(width()-maxExtent
+1, y
,
577 QColor c
= widget()->colorGroup().background();
579 // KWM evidently had a 1 pixel border around the client window. We
580 // emulate it here, but should be removed at some point in order to
581 // seamlessly mesh widget themes
583 p
.drawRect(maxExtent
-1, maxExtent
-1, width()-(maxExtent
-1)*2,
584 height()-(maxExtent
-1)*2);
586 // We fill the area behind the wrapped widget to ensure that
587 // shading animation is drawn as smoothly as possible
588 QRect
r(layout
->cellGeometry(2, 1));
589 p
.fillRect( r
.x(), r
.y(), r
.width(), r
.height(), c
);
593 void KWMThemeClient::doShape()
596 QBitmap
shapemask(width(), height());
597 shapemask
.fill(color0
);
604 int w1
= framePixmaps
[FrameTopLeft
]->width();
605 int h1
= framePixmaps
[FrameTopLeft
]->height();
606 if (w1
> width()/2) w1
= width()/2;
607 if (h1
> height()/2) h1
= height()/2;
608 if (framePixmaps
[FrameTopLeft
]->mask())
609 p
.drawPixmap(0,0,*framePixmaps
[FrameTopLeft
]->mask(),
612 p
.fillRect(0,0,w1
,h1
,color1
);
613 int w2
= framePixmaps
[FrameTopRight
]->width();
614 int h2
= framePixmaps
[FrameTopRight
]->height();
615 if (w2
> width()/2) w2
= width()/2;
616 if (h2
> height()/2) h2
= height()/2;
617 if (framePixmaps
[FrameTopRight
]->mask())
618 p
.drawPixmap(width()-w2
,0,*framePixmaps
[FrameTopRight
]->mask(),
619 framePixmaps
[FrameTopRight
]->width()-w2
,0,w2
, h2
);
621 p
.fillRect(width()-w2
,0,w2
, h2
,color1
);
623 int w3
= framePixmaps
[FrameBottomLeft
]->width();
624 int h3
= framePixmaps
[FrameBottomLeft
]->height();
625 if (w3
> width()/2) w3
= width()/2;
626 if (h3
> height()/2) h3
= height()/2;
627 if (framePixmaps
[FrameBottomLeft
]->mask())
628 p
.drawPixmap(0,height()-h3
,*framePixmaps
[FrameBottomLeft
]->mask(),
629 0,framePixmaps
[FrameBottomLeft
]->height()-h3
,w3
, h3
);
631 p
.fillRect(0,height()-h3
,w3
,h3
,color1
);
633 int w4
= framePixmaps
[FrameBottomRight
]->width();
634 int h4
= framePixmaps
[FrameBottomRight
]->height();
635 if (w4
> width()/2) w4
= width()/2;
636 if (h4
> height()/2) h4
= height()/2;
637 if (framePixmaps
[FrameBottomRight
]->mask())
638 p
.drawPixmap(width()-w4
,height()-h4
,*framePixmaps
[FrameBottomRight
]->mask(),
639 framePixmaps
[FrameBottomRight
]->width()-w4
,
640 framePixmaps
[FrameBottomRight
]->height()-h4
,
643 p
.fillRect(width()-w4
,height()-h4
,w4
,h4
,color1
);
649 if (framePixmaps
[FrameTop
]->mask())
651 pm
= *framePixmaps
[FrameTop
]->mask();
657 m
.scale(w
/(float)pm
.width(), 1);
658 pm
= pm
.transformed(m
);
662 if (pm
.width() < width()-w2
-x
){
663 p
.drawPixmap(x
,maxExtent
-pm
.height()-1,
668 p
.drawPixmap(x
,maxExtent
-pm
.height()-1,
670 0,0,width()-w2
-x
,pm
.height());
677 if (framePixmaps
[FrameBottom
]->mask())
679 pm
= *framePixmaps
[FrameBottom
]->mask();
685 m
.scale(w
/(float)pm
.width(), 1);
686 pm
= pm
.transformed(m
);
690 if (pm
.width() < width()-w4
-x
){
691 p
.drawPixmap(x
,height()-maxExtent
+1,pm
);
695 p
.drawPixmap(x
,height()-maxExtent
+1,pm
,
696 0,0,width()-w4
-x
,pm
.height());
703 if (framePixmaps
[FrameLeft
]->mask())
705 pm
= *framePixmaps
[FrameLeft
]->mask();
711 m
.scale(1, w
/(float)pm
.height());
712 pm
= pm
.transformed(m
);
716 if (pm
.height() < height()-h3
-y
){
717 p
.drawPixmap(maxExtent
-pm
.width()-1, y
,
722 p
.drawPixmap(maxExtent
-pm
.width()-1, y
,
732 if (framePixmaps
[FrameRight
]->mask())
734 pm
= *framePixmaps
[FrameRight
]->mask();
740 m
.scale(1, w
/(float)pm
.height());
741 pm
= pm
.transformed(m
);
745 if (pm
.height() < height()-h4
-y
){
746 p
.drawPixmap(width()-maxExtent
+1, y
,
751 p
.drawPixmap(width()-maxExtent
+1, y
,
759 p
.fillRect(maxExtent
-1, maxExtent
-1, width()-2*maxExtent
+2, height()-2*maxExtent
+2, color1
);
764 void KWMThemeClient::showEvent(QShowEvent
*)
767 widget()->repaint(false);
770 void KWMThemeClient::mouseDoubleClickEvent( QMouseEvent
* e
)
772 if (e
->button() == LeftButton
&& titlebar
->geometry().contains( e
->pos() ) )
773 titlebarDblClickOperation();
776 void KWMThemeClient::desktopChange()
779 bool on
= isOnAllDesktops();
780 stickyBtn
->setPixmap(on
? *pindownPix
: *pinupPix
);
781 stickyBtn
->setToolTip( on
? i18n("Unsticky") : i18n("Sticky") );
785 void KWMThemeClient::maximizeChange()
788 bool m
= maximizeMode() == MaximizeFull
;
789 maxBtn
->setPixmap(m
? *minmaxPix
: *maxPix
);
790 maxBtn
->setToolTip( m
? i18n("Restore") : i18n("Maximize"));
794 void KWMThemeClient::slotMaximize()
796 maximize( maximizeMode() == MaximizeFull
? MaximizeRestore
: MaximizeFull
);
799 void KWMThemeClient::activeChange()
804 KDecoration::Position
KWMThemeClient::mousePosition(const QPoint
&p
) const
806 Position m
= KDecoration::mousePosition(p
);
808 if(p
.y() < framePixmaps
[FrameTop
]->height() &&
809 p
.x() < framePixmaps
[FrameLeft
]->width()){
812 else if(p
.y() < framePixmaps
[FrameTop
]->height() &&
813 p
.x() > width()-framePixmaps
[FrameRight
]->width()){
814 m
= PositionTopRight
;
816 else if(p
.y() > height()-framePixmaps
[FrameBottom
]->height() &&
817 p
.x() < framePixmaps
[FrameLeft
]->width()){
818 m
= PositionBottomLeft
;
820 else if(p
.y() > height()-framePixmaps
[FrameBottom
]->height() &&
821 p
.x() > width()-framePixmaps
[FrameRight
]->width()){
822 m
= PositionBottomRight
;
824 else if(p
.y() < framePixmaps
[FrameTop
]->height())
826 else if(p
.y() > height()-framePixmaps
[FrameBottom
]->height())
828 else if(p
.x() < framePixmaps
[FrameLeft
]->width())
830 else if(p
.x() > width()-framePixmaps
[FrameRight
]->width())
835 void KWMThemeClient::menuButtonPressed()
837 mnuBtn
->setDown(false); // will stay down if I don't do this
838 QPoint pos
= mnuBtn
->mapToGlobal(mnuBtn
->rect().bottomLeft());
839 showWindowMenu( pos
);
842 void KWMThemeClient::iconChange()
845 if( icon().pixmap( QIcon::Small
, QIcon::Normal
).isNull()){
846 mnuBtn
->setPixmap(*menuPix
);
849 mnuBtn
->setPixmap(icon().pixmap( QIcon::Small
, QIcon::Normal
));
854 bool KWMThemeClient::eventFilter( QObject
* o
, QEvent
* e
)
862 resizeEvent( static_cast< QResizeEvent
* >( e
) );
866 paintEvent( static_cast< QPaintEvent
* >( e
) );
869 case QEvent::MouseButtonDblClick
:
870 mouseDoubleClickEvent( static_cast< QMouseEvent
* >( e
) );
873 case QEvent::MouseButtonPress
:
874 processMousePressEvent( static_cast< QMouseEvent
* >( e
) );
878 showEvent( static_cast< QShowEvent
* >( e
) );
886 QSize
KWMThemeClient::minimumSize() const
888 return widget()->minimumSize().expandedTo( QSize( 100, 50 ));
891 void KWMThemeClient::resize( const QSize
& s
)
893 widget()->resize( s
);
896 void KWMThemeClient::borders( int& left
, int& right
, int& top
, int& bottom
) const
906 KWMThemeFactory::KWMThemeFactory()
911 KWMThemeFactory::~KWMThemeFactory()
916 KDecoration
* KWMThemeFactory::createDecoration( KDecorationBridge
* b
)
918 return new KWMThemeClient( b
, this );
921 bool KWMThemeFactory::reset( unsigned long mask
)
923 bool needHardReset
= false;
927 // doesn't obey the Border size setting
928 if( mask
& ( SettingFont
| SettingButtons
))
929 needHardReset
= true;
931 if( mask
& ( SettingFont
| SettingColors
)) {
932 KWMTheme::delete_pixmaps();
933 KWMTheme::create_pixmaps();
937 resetDecorations( mask
);
938 return needHardReset
;
945 KDE_EXPORT KDecorationFactory
*create_factory()
947 return new KWMTheme::KWMThemeFactory();
951 #include "kwmthemeclient.moc"