diff options
author | Pascal Viandier <[email protected]> | 2015-10-01 19:38:38 +0200 |
---|---|---|
committer | Slávek Banko <[email protected]> | 2015-10-01 19:38:38 +0200 |
commit | 1e0e72fceb542e4eb984b50f747c38314f055b8f (patch) | |
tree | 40d35ec3682c465348f8d8d73509aeda4729a8bb /src/xosd.cpp | |
parent | c9e33e7d3fcd5b21a00e13dcbb5742a6c8da6106 (diff) | |
download | kooldock-1e0e72fceb542e4eb984b50f747c38314f055b8f.tar.gz kooldock-1e0e72fceb542e4eb984b50f747c38314f055b8f.zip |
Fix remaining issues and build warnings
Cleanup code
Signed-off-by: Pascal Viandier <[email protected]>
Diffstat (limited to 'src/xosd.cpp')
-rw-r--r-- | src/xosd.cpp | 150 |
1 files changed, 59 insertions, 91 deletions
diff --git a/src/xosd.cpp b/src/xosd.cpp index aaeb4b7..c4a100f 100644 --- a/src/xosd.cpp +++ b/src/xosd.cpp @@ -15,10 +15,12 @@ #include <kdebug.h> #include <stdlib.h> -xosd::xosd(TQWidget *parent, const char *name) : TQWidget(parent, name, WStyle_Customize | WRepaintNoErase | WStyle_NoBorder | WDestructiveClose | WResizeNoErase | WMouseNoMask | WStyle_StaysOnTop | WX11BypassWM) +xosd::xosd(TQWidget* parent, const char* name) : + TQWidget(parent, name, WStyle_Customize | WRepaintNoErase | WStyle_NoBorder | + WDestructiveClose | WResizeNoErase | WMouseNoMask | WStyle_StaysOnTop | WX11BypassWM) { - info = new NETWinInfo( tqt_xdisplay(), winId(), tqt_xrootwin(), NET::WMState); - info->setDesktop( NETWinInfo::OnAllDesktops ); + info = new NETWinInfo(tqt_xdisplay(), winId(), tqt_xrootwin(), NET::WMState); + info->setDesktop(NETWinInfo::OnAllDesktops); hide(); KWin::setState(winId(), NET::SkipTaskbar | NET::SkipPager); setCaption("kooldock xosd window"); @@ -30,35 +32,33 @@ xosd::~xosd() void xosd::setColor(const TQString& color) { - fontColor=color; + fontColor = color; } void xosd::setShadowColor(const TQString& color) { - shadowColor=color; + shadowColor = color; } void xosd::setOrientation(int orientation, int w, int mh) { - fOrientation=orientation; - dw=w; - rdh=mh; - if (fCleaner==1) - { - //font is set, so program can get its height to prepare background buffer - TQFontMetrics *metrics = new TQFontMetrics(f); + fOrientation = orientation; + dw = w; + rdh = mh; + if (fCleaner == 1) { + //font is set, so program can get its height to prepare background buffer + TQFontMetrics* metrics = new TQFontMetrics(f); h = metrics->height(); bgBuffer = TQPixmap(dw, h); maskBuffer = TQPixmap(dw, h, true); bgBuffer = TQPixmap::grabWindow(tqt_xrootwin(), 0, 0, dw, h); - lastX=0; - lastY=0; + lastX = 0; + lastY = 0; } - } -//Enables/disables dynamic background +// Enable/disable dynamic background void xosd::setClear(int nClean) { fCleaner = nClean; @@ -66,18 +66,14 @@ void xosd::setClear(int nClean) void xosd::setShadowOffset(int off) { - shadowOffset=off; + shadowOffset = off; } void xosd::setText(const TQString& t) { - //setMask(TQRegion(0,0,0,0)); - // NOTICE: it appears that with WX11BypassWM, resize() doesn't flick the widget anymore :) - // so, setMask() is no more needed. - // -- Matias - resize(0,0); + resize(0, 0); text = t; - TQFontMetrics *metrics = new TQFontMetrics(f); + TQFontMetrics* metrics = new TQFontMetrics(f); w = metrics->width(text); w = w + shadowOffset + 5; // 5 pixels more h = metrics->height(); @@ -92,12 +88,12 @@ void xosd::setFont(const TQString& font) void xosd::setItalic() { - f.setItalic(TRUE); + f.setItalic(true); } void xosd::setBold() { - f.setBold(TRUE); + f.setBold(true); } void xosd::setSize(int size) @@ -106,122 +102,94 @@ void xosd::setSize(int size) fontSize = size; } -/*int xosd::w() -{ - TQFontMetrics *metrics = new TQFontMetrics(f); - return (metrics->width(text) + shadowOffset + 5); - -} - -int xosd::h() -{ - TQFontMetrics *metrics = new TQFontMetrics(f); - return metrics->height(); -}*/ - -void xosd::paintEvent(TQPaintEvent *) +void xosd::paintEvent(TQPaintEvent*) { int i, j; - resize(w,h); - + resize(w, h); TQPixmap pm(size()); TQBitmap bm(size()); TQPainter p; - //Drawing text + // Drawing text p.begin(&pm, this); - if (fCleaner==1) - { - //Dynamic background - look cleaner + if (fCleaner == 1) { + // Dynamic background - look cleaner bitBlt(&pm, 0, 0, &bgBuffer, lastX, 0, w, h); } - else - { - //One colour background - work faster - p.fillRect (rect(), TQColor(shadowColor)); + else { + // One colour background - work faster + p.fillRect(rect(), TQColor(shadowColor)); } - p.setPen( TQColor(shadowColor) ); + p.setPen(TQColor(shadowColor)); p.setFont(f); p.drawText(shadowOffset, yOffset + shadowOffset, text, AlignCenter); // draw shadow text - // now, draw normal text - p.setPen( TQColor(fontColor) ); + // Draw normal text + p.setPen(TQColor(fontColor)); p.drawText(1, yOffset, text, AlignCenter); // draw front text p.end(); - //Drawing mask + // Drawing mask p.begin(&bm, this); - // now we must draw the text with black color for making the mask - p.setPen( TQt::white ); - p.fillRect (rect(), TQt::black); + // Draw the text with black color for making the mask + p.setPen(TQt::white); + p.fillRect(rect(), TQt::black); p.setFont(f); - for (i=-fCleaner;i<=fCleaner;i++) - { - for (j=-fCleaner;j<=fCleaner;j++) - { - p.drawText(shadowOffset+i, yOffset + shadowOffset+j, text, AlignCenter); // shadow - p.drawText(1+i, yOffset+j, text, AlignCenter); // front + for (i = -fCleaner; i <= fCleaner; i++) { + for (j = -fCleaner; j <= fCleaner; j++) { + p.drawText(shadowOffset + i, yOffset + shadowOffset + j, text, AlignCenter); // shadow + p.drawText(1 + i, yOffset + j, text, AlignCenter); // front } } p.end(); bitBlt(this, 0, 0, &pm); // update the widget - if (fCleaner==1) bitBlt(&maskBuffer, 0, 0, &bm); - + if (fCleaner == 1) { + bitBlt(&maskBuffer, 0, 0, &bm); + } info->setState(NETWinInfo::SkipTaskbar | NETWinInfo::SkipPager, NETWinInfo::SkipTaskbar | NETWinInfo::SkipPager); setMask(bm); } void xosd::move2(int x, int y) { - - //bit block transfer don't work propertly with too less cursor position changes - if (abs(lastY-y)>2 || abs(lastX-x)>2) - { - if (fCleaner==1) - { + // Bit block transfer don't work propertly with too less cursor position changes + if (abs(lastY - y) > 2 || abs(lastX - x) > 2) { + if (fCleaner == 1) { TQPixmap tmpBuffer; - //window is not hidden - if (y!=rdh) - { + // Window is not hidden + if (y != rdh) { tmpBuffer = TQPixmap::grabWindow(tqt_xrootwin(), 0, y, dw, h); - if (lastY!=rdh) - { - //fill background covered with the text with cached version - if (fOrientation==0 ) //horizontal - { + if (lastY != rdh) { + // Fill background covered with the text with cached version + if (fOrientation == 0) { // horizontal bitBlt(&tmpBuffer, lastX, 0, &maskBuffer, 0, 0, w, h, TQt::AndROP);//copying part, which hides only the text bitBlt(&bgBuffer, lastX, 0, &maskBuffer, 0, 0, w, h, TQt::NotAndROP);//so the background won't be covered by bitBlt(&tmpBuffer, lastX, 0, &bgBuffer, lastX, 0, w, h, TQt::OrROP);//currently visible text. } - if (fOrientation==1) //vertical - { - if (y<lastY && (y+h)>lastY) - { + if (fOrientation==1) { //vertical + if ((y < lastY) && ((y + h) > lastY)) { bitBlt(&tmpBuffer, lastX, lastY-y, &maskBuffer, 0, 0, w, h, TQt::AndROP); bitBlt(&bgBuffer, lastX, 0, &maskBuffer, 0, 0, w, h, TQt::NotAndROP); bitBlt(&tmpBuffer, lastX, lastY-y, &bgBuffer, lastX, 0, w, h, TQt::OrROP); } - if (y>lastY && (y-lastY)<h) - { + if ((y > lastY) && ((y - lastY) < h)) { bitBlt(&tmpBuffer, lastX, 0, &maskBuffer, 0, 0, w, h, TQt::AndROP); bitBlt(&bgBuffer, lastX, y-lastY, &maskBuffer, 0, 0, w, h, TQt::NotAndROP); bitBlt(&tmpBuffer, lastX, 0, &bgBuffer, lastX, y-lastY, w, h, TQt::OrROP); } } } - } - bitBlt(&bgBuffer,0,0,&tmpBuffer); - lastX=x; + bitBlt(&bgBuffer, 0, 0, &tmpBuffer); + lastX = x; paintEvent(NULL); } - - move(x,y); - lastX=x; - lastY=y; + move(x, y); + lastX = x; + lastY = y; } } |