/*
|
|
QtCurve (C) Craig Drummond, 2003 - 2010 craig.p.drummond@gmail.com
|
|
|
|
----
|
|
|
|
Based upon B???Curve style (Copyright (c) 2002 R?d H?t, Inc)
|
|
Bernhard Rosenkrazer <bero@r?dh?t.com>
|
|
Preston Brown <pbrown@r?dh?t.com>
|
|
Than Ngo <than@r?dh?t.com>
|
|
|
|
This program is free software; you can redistribute it and/or
|
|
modify it under the terms of the GNU General Public
|
|
License version 2 as published by the Free Software Foundation.
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
General Public License for more details.
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
along with this program; see the file COPYING. If not, write to
|
|
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
|
Boston, MA 02110-1301, USA.
|
|
|
|
----
|
|
|
|
B???Curve is based on the KDE Light style, 2nd revision:
|
|
Copyright(c)2000-2001 Trolltech AS (info@trolltech.com). The light style
|
|
license is as follows:
|
|
|
|
Permission is hereby granted, free of charge, to any person obtaining a
|
|
copy of this software and associated documentation files(the "Software"),
|
|
to deal in the Software without restriction, including without limitation
|
|
the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
and/or sell copies of the Software, and to permit persons to whom the
|
|
Software is furnished to do so, subject to the following conditions:
|
|
|
|
The above copyright notice and this permission notice shall be included in
|
|
all copies or substantial portions of the Software.
|
|
|
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
|
DEALINGS IN THE SOFTWARE.
|
|
*/
|
|
|
|
/*
|
|
KHTML
|
|
-----
|
|
Srollbars:
|
|
|
|
For some reason Scrollbars in KHTML seem to lose the bottom/left pixels. As if KHTML expects
|
|
the scrollbar to be 1 pixel smaller/thinner than it actually is. To 'fix' this, the pixelMetric
|
|
function will return 1 scrollbar with 1 greater than standard for form widgets, or where widget==0L
|
|
|
|
In the CC_ScrollBar draw code, the rects used for each component are shrunk by 1, in the appropriate
|
|
dimension, so as to draw the scrollbar at the correct size.
|
|
*/
|
|
#include <tqtable.h>
|
|
|
|
#include "config.h"
|
|
#ifndef TQTC_TQT_ONLY
|
|
#include <tdeversion.h>
|
|
#endif
|
|
#include <tqsettings.h>
|
|
#include <tqmenubar.h>
|
|
#include <tqapplication.h>
|
|
#include <tqpainter.h>
|
|
#include <tqpalette.h>
|
|
#include <tqframe.h>
|
|
#include <tqpushbutton.h>
|
|
#include <tqdrawutil.h>
|
|
#include <tqscrollbar.h>
|
|
#include <tqtabbar.h>
|
|
#include <tqtabwidget.h>
|
|
#include <tqlineedit.h>
|
|
#include <tqlistview.h>
|
|
#include <tqtable.h>
|
|
#include <tqimage.h>
|
|
#include <tqcombobox.h>
|
|
#include <tqslider.h>
|
|
#include <tqcleanuphandler.h>
|
|
#include <tqcheckbox.h>
|
|
#include <tqradiobutton.h>
|
|
#include <tqtoolbutton.h>
|
|
#include <tqtoolbar.h>
|
|
#include <tqprogressbar.h>
|
|
#include <tqheader.h>
|
|
#include <tqwidgetstack.h>
|
|
#include <tqsplitter.h>
|
|
#include <tqtextedit.h>
|
|
#include <tqlabel.h>
|
|
#include <tqlistbox.h>
|
|
#include <tqhbox.h>
|
|
#include <tqvbox.h>
|
|
#include <tqtimer.h>
|
|
#include <tqdatetimeedit.h>
|
|
#include <tqobjectlist.h>
|
|
#include <tqpixmapcache.h>
|
|
#include <tqbitmap.h>
|
|
#include <tqmainwindow.h>
|
|
#include <tqstyle.h>
|
|
#include <math.h>
|
|
#include <stdlib.h>
|
|
#include <unistd.h>
|
|
#include <sys/types.h>
|
|
#include <iostream>
|
|
#define COMMON_FUNCTIONS
|
|
#include "qtcurve.h"
|
|
#define CONFIG_READ
|
|
#include "config_file.c"
|
|
#include "pixmaps.h"
|
|
#include <tqdialog.h>
|
|
#include <tqprogressdialog.h>
|
|
#include <tqstyleplugin.h>
|
|
#include <tqgroupbox.h>
|
|
#include <tqdir.h>
|
|
// Need access to classname from within TQMetaObject...
|
|
#define private public
|
|
#include <tqmetaobject.h>
|
|
#include <X11/Xlib.h>
|
|
#include <X11/Xatom.h>
|
|
#include "qtc_fixx11h.h"
|
|
|
|
#ifndef HAVE_REAL_TQT
|
|
#define TQTitleBar QTitleBar
|
|
#endif
|
|
|
|
static const Atom constNetMoveResize = XInternAtom(tqt_xdisplay(), "_NET_WM_MOVERESIZE", False);
|
|
static const TQWidget * getTopLevel(const TQWidget *widget)
|
|
{
|
|
const TQWidget *w=widget;
|
|
|
|
while(w && !w->isTopLevel())
|
|
w=w->parentWidget();
|
|
return w;
|
|
}
|
|
|
|
static void emitMenuSize(const TQWidget *widget, unsigned short size)
|
|
{
|
|
const TQWidget *w=getTopLevel(widget);
|
|
|
|
if(w)
|
|
{
|
|
static const Atom constAtom = XInternAtom(tqt_xdisplay(), MENU_SIZE_ATOM, False);
|
|
XChangeProperty(tqt_xdisplay(), w->parentWidget() ? w->parentWidget()->winId() : w->winId(),
|
|
constAtom, XA_CARDINAL, 16, PropModeReplace, (unsigned char *)&size, 1);
|
|
}
|
|
}
|
|
|
|
void setBgndProp(TQWidget *widget, unsigned short app)
|
|
{
|
|
const TQWidget *w=getTopLevel(widget);
|
|
|
|
if(w)
|
|
{
|
|
static const Atom constAtom = XInternAtom(tqt_xdisplay(), BGND_ATOM, False);
|
|
XChangeProperty(tqt_xdisplay(), w->parentWidget() ? w->parentWidget()->winId() : w->winId(),
|
|
constAtom, XA_CARDINAL, 16, PropModeReplace, (unsigned char *)&app, 1);
|
|
}
|
|
}
|
|
|
|
static void triggerWMMove(const TQWidget *w, const TQPoint &p)
|
|
{
|
|
//...Taken from bespin...
|
|
// stolen... errr "adapted!" from TQSizeGrip
|
|
XEvent xev;
|
|
xev.xclient.type = ClientMessage;
|
|
xev.xclient.message_type = constNetMoveResize;
|
|
xev.xclient.display = tqt_xdisplay();
|
|
xev.xclient.window = w->parentWidget() ? w->parentWidget()->winId() : w->winId();
|
|
xev.xclient.format = 32;
|
|
xev.xclient.data.l[0] = p.x();
|
|
xev.xclient.data.l[1] = p.y();
|
|
xev.xclient.data.l[2] = 8; // NET::Move
|
|
xev.xclient.data.l[3] = Button1;
|
|
xev.xclient.data.l[4] = 0;
|
|
XUngrabPointer(tqt_xdisplay(), CurrentTime);
|
|
XSendEvent(tqt_xdisplay(), tqt_xrootwin(), False,
|
|
SubstructureRedirectMask | SubstructureNotifyMask, &xev);
|
|
}
|
|
|
|
#define MO_ARROW_X(FLAGS, COL) (MO_NONE!=opts.coloredMouseOver && FLAGS&Style_MouseOver && FLAGS&Style_Enabled ? itsMouseOverCols[ARROW_MO_SHADE] : COL)
|
|
#define MO_ARROW(COL) MO_ARROW_X(flags, COL)
|
|
|
|
static const int constMenuPixmapWidth=22;
|
|
|
|
static bool useTQt3Settings()
|
|
{
|
|
static int ver=0;
|
|
|
|
if(0==ver)
|
|
{
|
|
const char *sessionVersion=getenv("TDE_SESSION_VERSION");
|
|
|
|
ver=sessionVersion
|
|
? atoi(sessionVersion)<4
|
|
? 3
|
|
: 4
|
|
#ifdef TQTC_DEFAULT_TO_KDE3
|
|
: 3;
|
|
#else
|
|
: getenv("TDE_FULL_SESSION")
|
|
? 3
|
|
: 4;
|
|
#endif
|
|
}
|
|
|
|
return 3==ver;
|
|
}
|
|
|
|
static TQRect adjusted(const TQRect r, int xp1, int yp1, int xp2, int yp2)
|
|
{
|
|
int x1, y1, x2, y2;
|
|
|
|
r.coords(&x1, &y1, &x2, &y2);
|
|
return TQRect(TQPoint(x1 + xp1, y1 + yp1), TQPoint(x2 + xp2, y2 + yp2));
|
|
}
|
|
|
|
static void adjust(TQRect &r, int dx1, int dy1, int dx2, int dy2)
|
|
{
|
|
int x1, y1, x2, y2;
|
|
|
|
r.coords(&x1, &y1, &x2, &y2);
|
|
x1 += dx1;
|
|
y1 += dy1;
|
|
x2 += dx2;
|
|
y2 += dy2;
|
|
r.setCoords(x1, y1, x2, y2);
|
|
}
|
|
|
|
inline bool isSpecialHover(TQWidget *w)
|
|
{
|
|
return w && (
|
|
#if 0x039999 >= 0x030200
|
|
::tqqt_cast<TQRadioButton *>(w) ||
|
|
::tqqt_cast<TQCheckBox *>(w) ||
|
|
#endif
|
|
::tqqt_cast<TQScrollBar *>(w) ||
|
|
#if defined TDE_VERSION && TDE_VERSION >= 0x30400 && TDE_VERSION < 0x30500
|
|
::tqqt_cast<TQToolButton *>(w) ||
|
|
|
|
#endif
|
|
::tqqt_cast<TQHeader *>(w) ||
|
|
::tqqt_cast<TQSpinWidget *>(w) ||
|
|
::tqqt_cast<TQComboBox *>(w) ||
|
|
::tqqt_cast<TQTabBar *>(w)
|
|
);
|
|
}
|
|
|
|
static TQString readEnvPath(const char *env)
|
|
{
|
|
TQCString path=getenv(env);
|
|
|
|
return path.isEmpty() ? TQString() : TQFile::decodeName(path);
|
|
}
|
|
|
|
static TQString kdeHome(bool trinity=false)
|
|
{
|
|
static TQString kdeHome[2];
|
|
|
|
// Execute tde-config to ascertain users TDEHOME
|
|
if(kdeHome[trinity ? 0 : 1].isEmpty())
|
|
{
|
|
FILE *fpipe;
|
|
|
|
if ((fpipe = (FILE*)popen(trinity ? "tde-config --localprefix 2> /dev/null" : "kde4-config --localprefix 2> /dev/null", "r")))
|
|
{
|
|
char line[1024];
|
|
|
|
while(fgets(line, sizeof line, fpipe))
|
|
{
|
|
kdeHome[trinity ? 0 : 1]=TQString(TQFile::decodeName(line)).replace("\n", "");
|
|
break;
|
|
}
|
|
pclose(fpipe);
|
|
}
|
|
}
|
|
|
|
// Try env vars...
|
|
if(kdeHome[trinity ? 0 : 1].isEmpty())
|
|
{
|
|
kdeHome[trinity ? 0 : 1]=readEnvPath(getuid() ? "TDEHOME" : "TDEROOTHOME");
|
|
if (kdeHome[trinity ? 0 : 1].isEmpty())
|
|
{
|
|
TQDir homeDir(TQDir::homeDirPath());
|
|
TQString kdeConfDir("/.kde");
|
|
if (!trinity && homeDir.exists(".kde4"))
|
|
kdeConfDir = TQString("/.kde4");
|
|
kdeHome[trinity ? 0 : 1] = TQDir::homeDirPath() + kdeConfDir;
|
|
}
|
|
}
|
|
return kdeHome[trinity ? 0 : 1];
|
|
}
|
|
|
|
#ifdef TQTC_STYLE_SUPPORT
|
|
static void getStyles(const TQString &dir, const char *sub, TQStringList &styles)
|
|
{
|
|
TQDir d(dir+sub);
|
|
|
|
if(d.exists())
|
|
{
|
|
d.setNameFilter(THEME_PREFIX"*"THEME_SUFFIX);
|
|
|
|
TQStringList entries(d.entryList());
|
|
TQStringList::ConstIterator it(entries.begin()),
|
|
end(entries.end());
|
|
|
|
for(; it!=end; ++it)
|
|
{
|
|
TQString style((*it).left((*it).findRev(THEME_SUFFIX)));
|
|
|
|
if(!styles.contains(style))
|
|
styles.append(style);
|
|
}
|
|
}
|
|
}
|
|
|
|
static void getStyles(const TQString &dir, TQStringList &styles)
|
|
{
|
|
getStyles(dir, THEME_DIR, styles);
|
|
getStyles(dir, THEME_DIR4, styles);
|
|
}
|
|
|
|
static TQString themeFile(const TQString &dir, const TQString &n, const char *sub)
|
|
{
|
|
TQString name(dir+sub+n+THEME_SUFFIX);
|
|
|
|
return TQFile(name).exists() ? name : TQString();
|
|
}
|
|
|
|
static TQString themeFile(const TQString &dir, const TQString &n, bool trinity=true)
|
|
{
|
|
TQString name(themeFile(dir, n, trinity ? THEME_DIR : THEME_DIR4));
|
|
|
|
if(name.isEmpty())
|
|
name=themeFile(dir, n, trinity ? THEME_DIR4 : THEME_DIR);
|
|
return name;
|
|
}
|
|
#endif
|
|
|
|
class QtCurveStylePlugin : public TQStylePlugin
|
|
{
|
|
public:
|
|
|
|
QtCurveStylePlugin() : TQStylePlugin() { }
|
|
|
|
TQStringList keys() const
|
|
{
|
|
TQStringList list;
|
|
list << "QtCurve";
|
|
|
|
#ifdef TQTC_STYLE_SUPPORT
|
|
getStyles(kdeHome(useTQt3Settings()), list);
|
|
getStyles(kdeHome(!useTQt3Settings()), list);
|
|
getStyles(KDE_PREFIX(useTQt3Settings() ? 3 : 4), list);
|
|
getStyles(KDE_PREFIX(useTQt3Settings() ? 4 : 3), list);
|
|
#endif
|
|
|
|
return list;
|
|
}
|
|
|
|
TQStyle * create(const TQString &s)
|
|
{
|
|
return "qtcurve"==s.lower()
|
|
? new QtCurveStyle
|
|
#ifdef TQTC_STYLE_SUPPORT
|
|
: 0==s.find(THEME_PREFIX)
|
|
? new QtCurveStyle(s)
|
|
#endif
|
|
: 0;
|
|
}
|
|
};
|
|
|
|
TQ_EXPORT_PLUGIN(QtCurveStylePlugin)
|
|
|
|
#define SKIP_TASKBAR (APP_SKIP_TASKBAR==itsThemedApp || APP_KPRINTER==itsThemedApp || APP_KDIALOG==itsThemedApp)
|
|
|
|
#if defined TQTC_TQT_ONLY || !defined TDE_VERSION || TDE_VERSION >= 0x30200
|
|
#include <tqfile.h>
|
|
#endif
|
|
|
|
#define NO_SECT -1
|
|
|
|
#define VERTICAL_TB_BUTTON 0x01000000
|
|
#define CHECK_BUTTON 0x02000000
|
|
#define STD_TOOLBUTTON 0x04000000
|
|
#define TOGGLE_BUTTON 0x08000000
|
|
#define NO_ETCH_BUTTON 0x10000000
|
|
#define DW_CLOSE_BUTTON 0x80000000
|
|
#define LISTVIEW_ITEM 0x20000000
|
|
#define MENU_ITEM 0x40000000
|
|
#define WINDOWTITLE_SPACER 0x10000000
|
|
|
|
#define DW_BGND 105
|
|
|
|
#if defined TQTC_TQT_ONLY || !defined TDE_VERSION || TDE_VERSION >= 0x30200
|
|
// Try to read $TDEHOME/share/config/kickerrc to find out if kicker is transparent...
|
|
|
|
static bool kickerIsTrans()
|
|
{
|
|
TQString cfgFileName(kdeHome(true)+"/share/config/kickerrc");
|
|
bool trans(false);
|
|
TQFile cfgFile(cfgFileName);
|
|
|
|
if (cfgFile.open(IO_ReadOnly))
|
|
{
|
|
TQTextStream stream(&cfgFile);
|
|
TQString line;
|
|
bool stop(false),
|
|
inGen(false);
|
|
|
|
while (!stream.atEnd() && !stop)
|
|
{
|
|
line=stream.readLine();
|
|
|
|
if(inGen)
|
|
{
|
|
if(0==line.find("Transparent=", false)) // Found it!
|
|
{
|
|
if(-1!=line.find("true", false))
|
|
trans=true;
|
|
stop=true;
|
|
}
|
|
else if(line[0]==TQChar('[')) // Then wasn't in General section...
|
|
stop=true;
|
|
}
|
|
else if(0==line.find("[General]", false))
|
|
inGen=true;
|
|
}
|
|
cfgFile.close();
|
|
}
|
|
|
|
return trans;
|
|
}
|
|
#endif
|
|
|
|
static bool isKhtmlWidget(const TQWidget *w, int level=1)
|
|
{
|
|
return w && ((w->name() && 0==strcmp(w->name(), "__khtml")) ||
|
|
(level && isKhtmlWidget(w->parentWidget(), --level)));
|
|
}
|
|
|
|
static bool isKhtmlFormWidget(const TQWidget *widget)
|
|
{
|
|
if(isKhtmlWidget(widget))
|
|
return true;
|
|
|
|
// Copied from Keramik...
|
|
|
|
//Form widgets are in the KHTMLView, but that has 2 further inner levels
|
|
//of widgets - TQClipperWidget, and outside of that, TQViewportWidget
|
|
TQWidget *potentialClipPort(widget ? widget->parentWidget() : 0L);
|
|
|
|
if (!potentialClipPort || potentialClipPort->isTopLevel())
|
|
return false;
|
|
|
|
TQWidget *potentialViewPort(potentialClipPort->parentWidget());
|
|
|
|
if (!potentialViewPort || potentialViewPort->isTopLevel() ||
|
|
qstrcmp(potentialViewPort->name(), "qt_viewport"))
|
|
return false;
|
|
|
|
TQWidget *potentialKHTML(potentialViewPort->parentWidget());
|
|
|
|
if (!potentialKHTML || potentialKHTML->isTopLevel() ||
|
|
qstrcmp(potentialKHTML->className(), "KHTMLView"))
|
|
return false;
|
|
|
|
return true;
|
|
}
|
|
|
|
static bool inStackWidget(const TQWidget *w)
|
|
{
|
|
while(w)
|
|
{
|
|
if(::tqqt_cast<const TQTabWidget *>(w))
|
|
return true;
|
|
w=w->parentWidget();
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
static void setRgb(TQColor *col, const TQStringList &rgb)
|
|
{
|
|
if(3==rgb.size())
|
|
*col=TQColor(rgb[0].toInt(), rgb[1].toInt(), rgb[2].toInt());
|
|
}
|
|
|
|
struct KDESettings
|
|
{
|
|
KDESettings()
|
|
{
|
|
inactiveHighlight=false;
|
|
}
|
|
|
|
bool inactiveHighlight;
|
|
TQColor hover,
|
|
focus;
|
|
};
|
|
|
|
static KDESettings kdeSettings;
|
|
static bool readKdeGlobals()
|
|
{
|
|
static int lastCheck=0;
|
|
|
|
int now=time(0L);
|
|
|
|
// Dont keep on reading kdeglobals file - only read if its been at least 2 seconds since the last time...
|
|
if(abs(now-lastCheck)<3)
|
|
return false;
|
|
|
|
|
|
TQColor highlight(TQApplication::palette().active().highlight());
|
|
bool inactiveEnabled(false),
|
|
changeSelectionColor(false),
|
|
useTQt3(useTQt3Settings());
|
|
TQFile f(kdeHome(useTQt3)+"/share/config/kdeglobals");
|
|
|
|
lastCheck=now;
|
|
|
|
if(useTQt3)
|
|
kdeSettings.hover=kdeSettings.focus=highlight;
|
|
else
|
|
{
|
|
kdeSettings.hover=TQColor(119, 183, 255);
|
|
kdeSettings.focus=TQColor( 43, 116, 199);
|
|
}
|
|
|
|
if(f.open(IO_ReadOnly))
|
|
{
|
|
TQTextStream in(&f);
|
|
bool inPal(false),
|
|
inInactive(false),
|
|
donePal(useTQt3),
|
|
doneInactive(false);
|
|
|
|
while (!in.atEnd() && (!donePal || !doneInactive))
|
|
{
|
|
TQString line(in.readLine());
|
|
if(inPal)
|
|
{
|
|
if(0==line.find("DecorationFocus=", false))
|
|
setRgb(&kdeSettings.focus, TQStringList::split(",", line.mid(16)));
|
|
else if(0==line.find("DecorationHover=", false))
|
|
setRgb(&kdeSettings.hover, TQStringList::split(",", line.mid(16)));
|
|
else if (-1!=line.find('['))
|
|
{
|
|
donePal=true;
|
|
inPal=false;
|
|
}
|
|
}
|
|
else if(inInactive)
|
|
{
|
|
if(0==line.find("ChangeSelectionColor=", false))
|
|
changeSelectionColor=line.find("=true");
|
|
else if(0==line.find("Enable=", false))
|
|
inactiveEnabled=line.find("=true");
|
|
else if (-1!=line.find('['))
|
|
{
|
|
doneInactive=true;
|
|
inInactive=false;
|
|
}
|
|
}
|
|
if(!inPal && !inInactive) {
|
|
if(!useTQt3 && 0==line.find("[Colors:Button]", false)) {
|
|
inPal=true;
|
|
}
|
|
else if(!useTQt3 && 0==line.find("[ColorEffects:Inactive]", false)) {
|
|
inInactive=true;
|
|
}
|
|
}
|
|
}
|
|
f.close();
|
|
}
|
|
|
|
kdeSettings.inactiveHighlight=changeSelectionColor && inactiveEnabled;
|
|
return true;
|
|
}
|
|
|
|
static void drawLines(TQPainter *p, const TQRect &r, bool horiz, int nLines, int offset,
|
|
const TQColor *cols, int startOffset, int dark, ELine type)
|
|
{
|
|
int space((nLines*2)+(LINE_DASHES!=type ? (nLines-1) : 0)),
|
|
step(LINE_DASHES!=type ? 3 : 2),
|
|
etchedDisp(LINE_SUNKEN==type ? 1 : 0),
|
|
x(horiz ? r.x(): r.x()+((r.width()-space)>>1)),
|
|
y(horiz ? r.y()+((r.height()-space)>>1): r.y()),
|
|
x2(r.x()+r.width()-1),
|
|
y2(r.y()+r.height()-1),
|
|
i;
|
|
|
|
if(horiz)
|
|
{
|
|
if(startOffset && y+startOffset>0)
|
|
y+=startOffset;
|
|
|
|
p->setPen(cols[dark]);
|
|
for(i=0; i<space; i+=step)
|
|
p->drawLine(x+offset, y+i, x2-offset, y+i);
|
|
|
|
if(LINE_FLAT!=type)
|
|
{
|
|
x+=etchedDisp;
|
|
x2+=etchedDisp;
|
|
p->setPen(cols[0]);
|
|
for(i=1; i<space; i+=step)
|
|
p->drawLine(x+offset, y+i, x2-offset, y+i);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if(startOffset && x+startOffset>0)
|
|
x+=startOffset;
|
|
|
|
p->setPen(cols[dark]);
|
|
for(i=0; i<space; i+=step)
|
|
p->drawLine(x+i, y+offset, x+i, y2-offset);
|
|
|
|
if(LINE_FLAT!=type)
|
|
{
|
|
y+=etchedDisp;
|
|
y2+=etchedDisp;
|
|
p->setPen(cols[0]);
|
|
for(i=1; i<space; i+=step)
|
|
p->drawLine(x+i, y+offset, x+i, y2-offset);
|
|
}
|
|
}
|
|
}
|
|
|
|
static void drawDots(TQPainter *p, const TQRect &r, bool horiz, int nLines, int offset,
|
|
const TQColor *cols, int startOffset, int dark)
|
|
{
|
|
int space((nLines*2)+(nLines-1)),
|
|
x(horiz ? r.x() : r.x()+((r.width()-space)>>1)),
|
|
y(horiz ? r.y()+((r.height()-space)>>1) : r.y()),
|
|
i, j,
|
|
numDots((horiz ? (r.width()-(2*offset))/3 : (r.height()-(2*offset))/3)+1);
|
|
|
|
if(horiz)
|
|
{
|
|
if(startOffset && y+startOffset>0)
|
|
y+=startOffset;
|
|
|
|
p->setPen(cols[dark]);
|
|
for(i=0; i<space; i+=3)
|
|
for(j=0; j<numDots; j++)
|
|
p->drawPoint(x+offset+(3*j), y+i);
|
|
|
|
p->setPen(cols[0]);
|
|
for(i=1; i<space; i+=3)
|
|
for(j=0; j<numDots; j++)
|
|
p->drawPoint(x+offset+1+(3*j), y+i);
|
|
}
|
|
else
|
|
{
|
|
if(startOffset && x+startOffset>0)
|
|
x+=startOffset;
|
|
|
|
p->setPen(cols[dark]);
|
|
for(i=0; i<space; i+=3)
|
|
for(j=0; j<numDots; j++)
|
|
p->drawPoint(x+i, y+offset+(3*j));
|
|
|
|
p->setPen(cols[0]);
|
|
for(i=1; i<space; i+=3)
|
|
for(j=0; j<numDots; j++)
|
|
p->drawPoint(x+i, y+offset+1+(3*j));
|
|
}
|
|
}
|
|
|
|
static bool onToolBar(TQWidget *widget, int l=0)
|
|
{
|
|
return l<3 && widget && widget->parentWidget()
|
|
? widget->parentWidget()->inherits(TQTOOLBAR_OBJECT_NAME_STRING) ||
|
|
onToolBar(widget->parentWidget(), ++l)
|
|
: false;
|
|
}
|
|
|
|
#define PIXMAP_DIMENSION 10
|
|
|
|
enum ECacheFlags
|
|
{
|
|
CACHE_STD,
|
|
CACHE_COL_SEL_TAB
|
|
};
|
|
|
|
static TQString createKey(int size, TQRgb color, bool horiz, int app, ECacheFlags flags)
|
|
{
|
|
TQString key;
|
|
|
|
TQTextOStream(&key) << size << '-' << color << '-' << horiz << '-' << app << '-' << flags;
|
|
|
|
return key;
|
|
}
|
|
|
|
static TQString createKey(TQRgb color, char type='p')
|
|
{
|
|
TQString key;
|
|
|
|
TQTextOStream(&key) << type << color;
|
|
|
|
return key;
|
|
}
|
|
|
|
static TQString createKey(TQRgb color, EPixmap p)
|
|
{
|
|
TQString key;
|
|
|
|
TQTextOStream(&key) << 'P' << color << p;
|
|
|
|
return key;
|
|
}
|
|
|
|
#ifdef SET_MDI_WINDOW_BUTTON_POSITIONS
|
|
static void parseWindowLine(const TQString &line, TQValueList<int> &data)
|
|
{
|
|
int len(line.length());
|
|
|
|
for(int i=0; i<len; ++i)
|
|
switch(line[i].latin1())
|
|
{
|
|
case 'M':
|
|
data.append(TQStyle::SC_TitleBarSysMenu);
|
|
break;
|
|
case '_':
|
|
data.append(WINDOWTITLE_SPACER);
|
|
break;
|
|
// case 'H':
|
|
// data.append(TQStyle::SC_TitleBarContextHelpButton);
|
|
// break;
|
|
case 'L':
|
|
data.append(TQStyle::SC_TitleBarShadeButton);
|
|
break;
|
|
case 'I':
|
|
data.append(TQStyle::SC_TitleBarMinButton);
|
|
break;
|
|
case 'A':
|
|
data.append(TQStyle::SC_TitleBarMaxButton);
|
|
break;
|
|
case 'X':
|
|
data.append(TQStyle::SC_TitleBarCloseButton);
|
|
default:
|
|
break;
|
|
}
|
|
}
|
|
#endif
|
|
|
|
static bool isCheckBoxOfGroupBox(const TQObject *w)
|
|
{
|
|
return w && w->parent() &&
|
|
::tqqt_cast<TQCheckBox *>(w) && ::tqqt_cast<TQGroupBox *>(w->parent()) &&
|
|
!qstrcmp(w->name(), "qt_groupbox_checkbox");
|
|
}
|
|
|
|
static void drawArrow(TQPainter *p, const TQRect &r, const TQColor &col, TQStyle::TQ_PrimitiveElement pe, const Options &opts, bool small=false)
|
|
{
|
|
TQPointArray a;
|
|
|
|
if(small)
|
|
switch(pe)
|
|
{
|
|
case TQStyle::PE_ArrowUp:
|
|
a.setPoints(opts.vArrows ? 6 : 3, 2,0, 0,-2, -2,0, -2,1, 0,-1, 2,1);
|
|
break;
|
|
case TQStyle::PE_ArrowDown:
|
|
a.setPoints(opts.vArrows ? 6 : 3, 2,0, 0,2, -2,0, -2,-1, 0,1, 2,-1);
|
|
break;
|
|
case TQStyle::PE_ArrowRight:
|
|
a.setPoints(opts.vArrows ? 6 : 3, 0,-2, 2,0, 0,2, -1,2, 1,0 -1,-2);
|
|
break;
|
|
case TQStyle::PE_ArrowLeft:
|
|
a.setPoints(opts.vArrows ? 6 : 3, 0,-2, -2,0, 0,2, 1,2, -1,0, 1,-2);
|
|
break;
|
|
default:
|
|
return;
|
|
}
|
|
else // Large arrows...
|
|
switch(pe)
|
|
{
|
|
case TQStyle::PE_ArrowUp:
|
|
a.setPoints(opts.vArrows ? 8 : 3, 3,1, 0,-2, -3,1, -3,2, -2,2, 0,0, 2,2, 3,2);
|
|
break;
|
|
case TQStyle::PE_ArrowDown:
|
|
a.setPoints(opts.vArrows ? 8 : 3, 3,-1, 0,2, -3,-1, -3,-2, -2,-2, 0,0, 2,-2, 3,-2);
|
|
break;
|
|
case TQStyle::PE_ArrowRight:
|
|
a.setPoints(opts.vArrows ? 8 : 3, -1,-3, 2,0, -1,3, -2,3, -2,2, 0,0, -2,-2, -2,-3);
|
|
break;
|
|
case TQStyle::PE_ArrowLeft:
|
|
a.setPoints(opts.vArrows ? 8 : 3, 1,-3, -2,0, 1,3, 2,3, 2,2, 0,0, 2,-2, 2,-3);
|
|
break;
|
|
default:
|
|
return;
|
|
}
|
|
|
|
if(a.isNull())
|
|
return;
|
|
|
|
p->save();
|
|
a.translate((r.x()+(r.width()>>1)),(r.y()+(r.height()>>1)));
|
|
p->setBrush(col);
|
|
p->setPen(col);
|
|
p->drawPolygon(a);
|
|
p->restore();
|
|
}
|
|
|
|
#ifdef TQTC_STYLE_SUPPORT
|
|
QtCurveStyle::QtCurveStyle(const TQString &name)
|
|
#else
|
|
QtCurveStyle::QtCurveStyle()
|
|
#endif
|
|
: BASE_STYLE(AllowMenuTransparency, WindowsStyleScrollBar),
|
|
itsSliderCols(0L),
|
|
itsDefBtnCols(0L),
|
|
itsMouseOverCols(0L),
|
|
itsComboBtnCols(0L),
|
|
itsCheckRadioSelCols(0L),
|
|
itsSortedLvColors(0L),
|
|
itsProgressCols(0L),
|
|
itsSidebarButtonsCols(0L),
|
|
itsActiveMdiColors(0L),
|
|
itsMdiColors(0L),
|
|
itsThemedApp(APP_OTHER),
|
|
itsPixmapCache(150000, 499),
|
|
#if defined TQTC_TQT_ONLY || !defined TDE_VERSION || TDE_VERSION >= 0x30200
|
|
itsIsTransKicker(false),
|
|
#endif
|
|
itsHover(HOVER_NONE),
|
|
itsOldPos(-1, -1),
|
|
itsFormMode(false),
|
|
itsHoverWidget(0L),
|
|
itsHoverSect(NO_SECT),
|
|
itsHoverTab(0L),
|
|
itsMactorPal(0L),
|
|
itsActive(true),
|
|
itsIsSpecialHover(false),
|
|
itsDragWidget(0L),
|
|
itsDragWidgetHadMouseTracking(false)
|
|
{
|
|
#ifdef TQTC_STYLE_SUPPORT
|
|
TQString rcFile;
|
|
if(!name.isEmpty())
|
|
{
|
|
rcFile=themeFile(kdeHome(), name, useTQt3Settings());
|
|
|
|
if(rcFile.isEmpty())
|
|
{
|
|
rcFile=themeFile(kdeHome(true), name);
|
|
if(rcFile.isEmpty())
|
|
{
|
|
rcFile=themeFile(KDE_PREFIX(useTQt3Settings() ? 3 : 4), name, useTQt3Settings());
|
|
if(rcFile.isEmpty())
|
|
rcFile=themeFile(KDE_PREFIX(useTQt3Settings() ? 4 : 3), name, !useTQt3Settings());
|
|
}
|
|
}
|
|
}
|
|
|
|
readConfig(rcFile, &opts);
|
|
#else
|
|
readConfig(TQString(), &opts);
|
|
#endif
|
|
|
|
if(FRAME_LINE==opts.groupBox || opts.gbLabel&GB_LBL_BOLD)
|
|
opts.groupBox=FRAME_NONE;
|
|
|
|
opts.contrast=TQSettings().readNumEntry("/TQt/KDE/contrast", DEFAULT_CONTRAST);
|
|
if(opts.contrast<0 || opts.contrast>10)
|
|
opts.contrast=DEFAULT_CONTRAST;
|
|
|
|
itsPixmapCache.setAutoDelete(true);
|
|
|
|
shadeColors(TQApplication::palette().active().highlight(), itsHighlightCols);
|
|
shadeColors(TQApplication::palette().active().background(), itsBackgroundCols);
|
|
shadeColors(TQApplication::palette().active().button(), itsButtonCols);
|
|
|
|
setDecorationColors(true);
|
|
|
|
switch(opts.shadeSliders)
|
|
{
|
|
default:
|
|
case SHADE_DARKEN:
|
|
case SHADE_NONE:
|
|
break;
|
|
case SHADE_SELECTED:
|
|
itsSliderCols=itsHighlightCols;
|
|
break;
|
|
case SHADE_BLEND_SELECTED:
|
|
case SHADE_CUSTOM:
|
|
if(!itsSliderCols)
|
|
itsSliderCols=new TQColor [TOTAL_SHADES+1];
|
|
shadeColors(SHADE_BLEND_SELECTED==opts.shadeSliders
|
|
? midColor(itsHighlightCols[ORIGINAL_SHADE],
|
|
itsButtonCols[ORIGINAL_SHADE])
|
|
: opts.customSlidersColor,
|
|
itsSliderCols);
|
|
}
|
|
|
|
switch(opts.defBtnIndicator)
|
|
{
|
|
case IND_GLOW:
|
|
case IND_SELECTED:
|
|
itsDefBtnCols=itsHighlightCols;
|
|
break;
|
|
case IND_TINT:
|
|
itsDefBtnCols=new TQColor [TOTAL_SHADES+1];
|
|
shadeColors(tint(itsButtonCols[ORIGINAL_SHADE],
|
|
itsHighlightCols[ORIGINAL_SHADE], DEF_BNT_TINT), itsDefBtnCols);
|
|
break;
|
|
default:
|
|
break;
|
|
case IND_COLORED:
|
|
if(SHADE_BLEND_SELECTED==opts.shadeSliders)
|
|
itsDefBtnCols=itsSliderCols;
|
|
else
|
|
{
|
|
itsDefBtnCols=new TQColor [TOTAL_SHADES+1];
|
|
shadeColors(midColor(itsHighlightCols[ORIGINAL_SHADE],
|
|
itsButtonCols[ORIGINAL_SHADE]), itsDefBtnCols);
|
|
}
|
|
}
|
|
|
|
switch(opts.comboBtn)
|
|
{
|
|
default:
|
|
case SHADE_DARKEN:
|
|
case SHADE_NONE:
|
|
break;
|
|
case SHADE_SELECTED:
|
|
itsComboBtnCols=itsHighlightCols;
|
|
break;
|
|
case SHADE_BLEND_SELECTED:
|
|
if(opts.shadeSliders==SHADE_BLEND_SELECTED)
|
|
{
|
|
itsComboBtnCols=itsSliderCols;
|
|
break;
|
|
}
|
|
case SHADE_CUSTOM:
|
|
if(opts.shadeSliders==SHADE_CUSTOM && opts.customSlidersColor==opts.customComboBtnColor)
|
|
{
|
|
itsComboBtnCols=itsSliderCols;
|
|
break;
|
|
}
|
|
if(!itsComboBtnCols)
|
|
itsComboBtnCols=new TQColor [TOTAL_SHADES+1];
|
|
shadeColors(SHADE_BLEND_SELECTED==opts.comboBtn
|
|
? midColor(itsHighlightCols[ORIGINAL_SHADE],
|
|
itsButtonCols[ORIGINAL_SHADE])
|
|
: opts.customComboBtnColor,
|
|
itsComboBtnCols);
|
|
}
|
|
|
|
switch(opts.sortedLv)
|
|
{
|
|
case SHADE_DARKEN:
|
|
if(!itsSortedLvColors)
|
|
itsSortedLvColors=new TQColor [TOTAL_SHADES+1];
|
|
shadeColors(shade(opts.lvButton ? itsButtonCols[ORIGINAL_SHADE] : itsBackgroundCols[ORIGINAL_SHADE], LV_HEADER_DARK_FACTOR), itsSortedLvColors);
|
|
break;
|
|
default:
|
|
case SHADE_NONE:
|
|
break;
|
|
case SHADE_SELECTED:
|
|
itsSortedLvColors=itsHighlightCols;
|
|
break;
|
|
case SHADE_BLEND_SELECTED:
|
|
if(SHADE_BLEND_SELECTED==opts.shadeSliders)
|
|
{
|
|
itsSortedLvColors=itsSliderCols;
|
|
break;
|
|
}
|
|
else if(SHADE_BLEND_SELECTED==opts.comboBtn)
|
|
{
|
|
itsSortedLvColors=itsComboBtnCols;
|
|
break;
|
|
}
|
|
case SHADE_CUSTOM:
|
|
if(opts.shadeSliders==SHADE_CUSTOM && opts.customSlidersColor==opts.customSortedLvColor)
|
|
{
|
|
itsSortedLvColors=itsSliderCols;
|
|
break;
|
|
}
|
|
if(opts.comboBtn==SHADE_CUSTOM && opts.customComboBtnColor==opts.customSortedLvColor)
|
|
{
|
|
itsSortedLvColors=itsComboBtnCols;
|
|
break;
|
|
}
|
|
if(!itsSortedLvColors)
|
|
itsSortedLvColors=new TQColor [TOTAL_SHADES+1];
|
|
shadeColors(SHADE_BLEND_SELECTED==opts.sortedLv
|
|
? midColor(itsHighlightCols[ORIGINAL_SHADE],
|
|
(opts.lvButton ? itsButtonCols[ORIGINAL_SHADE] : itsBackgroundCols[ORIGINAL_SHADE]))
|
|
: opts.customSortedLvColor,
|
|
itsSortedLvColors);
|
|
}
|
|
|
|
switch(opts.crColor)
|
|
{
|
|
default:
|
|
case SHADE_NONE:
|
|
itsCheckRadioSelCols=itsButtonCols;
|
|
break;
|
|
case SHADE_DARKEN:
|
|
if(!itsCheckRadioSelCols)
|
|
itsCheckRadioSelCols=new TQColor [TOTAL_SHADES+1];
|
|
shadeColors(shade(itsButtonCols[ORIGINAL_SHADE], LV_HEADER_DARK_FACTOR), itsCheckRadioSelCols);
|
|
break;
|
|
case SHADE_SELECTED:
|
|
itsCheckRadioSelCols=itsHighlightCols;
|
|
break;
|
|
case SHADE_CUSTOM:
|
|
if(SHADE_CUSTOM==opts.shadeSliders && opts.customSlidersColor==opts.customCrBgndColor)
|
|
itsCheckRadioSelCols=itsSliderCols;
|
|
else if(SHADE_CUSTOM==opts.comboBtn && opts.customComboBtnColor==opts.customCrBgndColor)
|
|
itsCheckRadioSelCols=itsComboBtnCols;
|
|
else if(SHADE_CUSTOM==opts.sortedLv && opts.customSortedLvColor==opts.customCrBgndColor)
|
|
itsCheckRadioSelCols=itsSortedLvColors;
|
|
else
|
|
{
|
|
if(!itsCheckRadioSelCols)
|
|
itsCheckRadioSelCols=new TQColor [TOTAL_SHADES+1];
|
|
shadeColors(opts.customCrBgndColor, itsCheckRadioSelCols);
|
|
}
|
|
break;
|
|
case SHADE_BLEND_SELECTED:
|
|
if(SHADE_BLEND_SELECTED==opts.shadeSliders)
|
|
itsCheckRadioSelCols=itsSliderCols;
|
|
else if(SHADE_BLEND_SELECTED==opts.comboBtn)
|
|
itsCheckRadioSelCols=itsComboBtnCols;
|
|
else if(SHADE_BLEND_SELECTED==opts.sortedLv)
|
|
itsCheckRadioSelCols=itsSortedLvColors;
|
|
else
|
|
{
|
|
if(!itsCheckRadioSelCols)
|
|
itsCheckRadioSelCols=new TQColor [TOTAL_SHADES+1];
|
|
shadeColors(midColor(itsHighlightCols[ORIGINAL_SHADE], itsButtonCols[ORIGINAL_SHADE]), itsCheckRadioSelCols);
|
|
}
|
|
}
|
|
|
|
switch(opts.progressColor)
|
|
{
|
|
case SHADE_NONE:
|
|
itsProgressCols=itsBackgroundCols;
|
|
break;
|
|
default:
|
|
// Not set!
|
|
break;
|
|
case SHADE_CUSTOM:
|
|
if(SHADE_CUSTOM==opts.shadeSliders && opts.customSlidersColor==opts.customProgressColor)
|
|
itsProgressCols=itsSliderCols;
|
|
else if(SHADE_CUSTOM==opts.comboBtn && opts.customComboBtnColor==opts.customProgressColor)
|
|
itsProgressCols=itsComboBtnCols;
|
|
else if(SHADE_CUSTOM==opts.sortedLv && opts.customSortedLvColor==opts.customProgressColor)
|
|
itsProgressCols=itsSortedLvColors;
|
|
else if(SHADE_CUSTOM==opts.crColor && opts.customCrBgndColor==opts.customProgressColor)
|
|
itsProgressCols=itsCheckRadioSelCols;
|
|
else
|
|
{
|
|
if(!itsProgressCols)
|
|
itsProgressCols=new TQColor [TOTAL_SHADES+1];
|
|
shadeColors(opts.customProgressColor, itsProgressCols);
|
|
}
|
|
break;
|
|
case SHADE_BLEND_SELECTED:
|
|
if(SHADE_BLEND_SELECTED==opts.shadeSliders)
|
|
itsProgressCols=itsSliderCols;
|
|
else if(SHADE_BLEND_SELECTED==opts.comboBtn)
|
|
itsProgressCols=itsComboBtnCols;
|
|
else if(SHADE_BLEND_SELECTED==opts.sortedLv)
|
|
itsProgressCols=itsSortedLvColors;
|
|
else
|
|
{
|
|
if(!itsProgressCols)
|
|
itsProgressCols=new TQColor [TOTAL_SHADES+1];
|
|
shadeColors(midColor(itsHighlightCols[ORIGINAL_SHADE], itsBackgroundCols[ORIGINAL_SHADE]), itsProgressCols);
|
|
}
|
|
}
|
|
|
|
setMenuColors(TQApplication::palette().active());
|
|
|
|
if(USE_LIGHTER_POPUP_MENU)
|
|
itsLighterPopupMenuBgndCol=shade(itsBackgroundCols[ORIGINAL_SHADE],
|
|
TO_FACTOR(opts.lighterPopupMenuBgnd));
|
|
|
|
if ((SHADE_CUSTOM==opts.shadeMenubars || SHADE_BLEND_SELECTED==opts.shadeMenubars || SHADE_SELECTED==opts.shadeMenubars) &&
|
|
"soffice.bin"==TQString(tqApp->argv()[0]) && TOO_DARK(SHADE_CUSTOM==opts.shadeMenubars
|
|
? opts.customMenubarsColor
|
|
: itsHighlightCols[ORIGINAL_SHADE]))
|
|
opts.shadeMenubars=SHADE_DARKEN;
|
|
|
|
switch(opts.shadeCheckRadio)
|
|
{
|
|
default:
|
|
itsCheckRadioCol=opts.crButton ? TQApplication::palette().active().buttonText()
|
|
: TQApplication::palette().active().text();
|
|
break;
|
|
case SHADE_BLEND_SELECTED:
|
|
case SHADE_SELECTED:
|
|
itsCheckRadioCol=TQApplication::palette().active().highlight();
|
|
break;
|
|
case SHADE_CUSTOM:
|
|
itsCheckRadioCol=opts.customCheckRadioColor;
|
|
}
|
|
|
|
if (opts.animatedProgress)
|
|
{
|
|
itsAnimationTimer = new TQTimer(this);
|
|
connect(itsAnimationTimer, TQT_SIGNAL(timeout()), this, TQT_SLOT(updateProgressPos()));
|
|
}
|
|
|
|
setSbType();
|
|
}
|
|
|
|
QtCurveStyle::~QtCurveStyle()
|
|
{
|
|
if(itsSidebarButtonsCols!=itsSliderCols &&
|
|
itsSidebarButtonsCols!=itsDefBtnCols)
|
|
delete [] itsSidebarButtonsCols;
|
|
if(itsActiveMdiColors && itsActiveMdiColors!=itsHighlightCols)
|
|
delete [] itsActiveMdiColors;
|
|
if(itsMdiColors && itsMdiColors!=itsBackgroundCols)
|
|
delete [] itsMdiColors;
|
|
if(itsMouseOverCols && itsMouseOverCols!=itsDefBtnCols &&
|
|
itsMouseOverCols!=itsSliderCols)
|
|
delete [] itsMouseOverCols;
|
|
if(itsDefBtnCols && itsDefBtnCols!=itsSliderCols && itsDefBtnCols!=itsFocusCols && itsDefBtnCols!=itsHighlightCols)
|
|
delete [] itsDefBtnCols;
|
|
if(itsProgressCols && itsProgressCols!=itsHighlightCols && itsProgressCols!=itsBackgroundCols &&
|
|
itsProgressCols!=itsSliderCols && itsProgressCols!=itsComboBtnCols && itsProgressCols!=itsCheckRadioSelCols && itsProgressCols!=itsSortedLvColors)
|
|
delete [] itsProgressCols;
|
|
if(itsCheckRadioSelCols && itsCheckRadioSelCols!=itsDefBtnCols && itsCheckRadioSelCols!=itsSliderCols &&
|
|
itsCheckRadioSelCols!=itsComboBtnCols && itsCheckRadioSelCols!=itsSortedLvColors &&
|
|
itsCheckRadioSelCols!=itsButtonCols && itsCheckRadioSelCols!=itsHighlightCols)
|
|
delete [] itsCheckRadioSelCols;
|
|
if(itsSortedLvColors && itsSortedLvColors!=itsHighlightCols && itsSortedLvColors!=itsSliderCols &&
|
|
itsSortedLvColors!=itsComboBtnCols)
|
|
delete [] itsSortedLvColors;
|
|
if(itsComboBtnCols && itsComboBtnCols!=itsHighlightCols && itsComboBtnCols!=itsSliderCols)
|
|
delete [] itsComboBtnCols;
|
|
if(itsSliderCols && itsSliderCols!=itsHighlightCols)
|
|
delete [] itsSliderCols;
|
|
delete itsMactorPal;
|
|
}
|
|
|
|
static TQString getFile(const TQString &f)
|
|
{
|
|
TQString d(f);
|
|
|
|
int slashPos(d.findRev('/'));
|
|
|
|
if(slashPos!=-1)
|
|
d.remove(0, slashPos+1);
|
|
|
|
return d;
|
|
}
|
|
|
|
void QtCurveStyle::applicationPolish(TQStyleControlElementData ceData, ControlElementFlags elementFlags, void *ptr)
|
|
{
|
|
if (ceData.widgetObjectTypes.contains(TQAPPLICATION_OBJECT_NAME_STRING)) {
|
|
TQApplication *app = reinterpret_cast<TQApplication*>(ptr);
|
|
|
|
TQString appName(getFile(app->argv()[0]));
|
|
|
|
if(NULL!=getenv("QTCURVE_DEBUG"))
|
|
std::cout << "QtCurve: Application name: \"" << appName.latin1() << "\"\n";
|
|
|
|
if ("kicker"==appName || "appletproxy"==appName)
|
|
{
|
|
itsThemedApp=APP_KICKER;
|
|
#if defined TQTC_TQT_ONLY || !defined TDE_VERSION || TDE_VERSION >= 0x30200
|
|
itsIsTransKicker=kickerIsTrans();
|
|
#endif
|
|
}
|
|
else if ("kontact"==appName)
|
|
itsThemedApp=APP_KONTACT;
|
|
else if ("konqueror"==appName)
|
|
itsThemedApp=APP_KONQUEROR;
|
|
else if ("kate"==appName)
|
|
itsThemedApp=APP_KATE;
|
|
else if ("kpresenter"==appName)
|
|
itsThemedApp=APP_KPRESENTER;
|
|
else if ("soffice.bin"==appName)
|
|
{
|
|
itsThemedApp=APP_OPENOFFICE;
|
|
opts.groupBox=FRAME_PLAIN;
|
|
opts.gbLabel=0;
|
|
}
|
|
else if ("kdefilepicker"==appName)
|
|
itsThemedApp=APP_SKIP_TASKBAR;
|
|
else if ("kprinter"==appName)
|
|
itsThemedApp=APP_KPRINTER;
|
|
else if ("kdialog"==appName)
|
|
itsThemedApp=APP_KDIALOG;
|
|
else if ("kdialogd"==appName)
|
|
itsThemedApp=APP_KDIALOGD;
|
|
else if ("tora"==appName)
|
|
itsThemedApp=APP_TORA;
|
|
else if ("opera"==appName)
|
|
itsThemedApp=APP_OPERA;
|
|
else if ("systemsettings"==appName)
|
|
itsThemedApp=APP_SYSTEMSETTINGS;
|
|
else if ("korn"==appName)
|
|
{
|
|
itsThemedApp=APP_KORN;
|
|
#if defined TQTC_TQT_ONLY || !defined TDE_VERSION || TDE_VERSION >= 0x30200
|
|
itsIsTransKicker=kickerIsTrans();
|
|
#endif
|
|
}
|
|
else if ("mactor"==appName)
|
|
{
|
|
if(!itsMactorPal)
|
|
itsMactorPal=new TQPalette(TQApplication::palette());
|
|
itsThemedApp=APP_MACTOR;
|
|
}
|
|
else
|
|
itsThemedApp=APP_OTHER;
|
|
|
|
if(APP_OPENOFFICE==itsThemedApp)
|
|
{
|
|
//
|
|
// OO.o 2.x checks to see whether the used theme "inherits" from HighContrastStyle,
|
|
// if so it uses the highlightedText color to draw highlighted menubar and popup menu
|
|
// items. Otherwise it uses the standard color. Changing the metaobject's class name
|
|
// works around this...
|
|
if(opts.useHighlightForMenu)
|
|
{
|
|
TQMetaObject *meta=(TQMetaObject *)metaObject();
|
|
|
|
#ifdef USE_QT4
|
|
#warning Qt4 does not allow the metaobject classname to be set (skipping)
|
|
#else // USE_QT4
|
|
meta->classname="HighContrastStyle";
|
|
#endif // USE_QT4
|
|
}
|
|
|
|
if(opts.scrollbarType==SCROLLBAR_NEXT)
|
|
opts.scrollbarType=SCROLLBAR_KDE;
|
|
else if(opts.scrollbarType==SCROLLBAR_NONE)
|
|
opts.scrollbarType=SCROLLBAR_WINDOWS;
|
|
setSbType();
|
|
}
|
|
|
|
if(SHADE_NONE!=opts.menuStripe && opts.noMenuStripeApps.contains(appName))
|
|
opts.menuStripe=SHADE_NONE;
|
|
#ifdef TQTC_ENABLE_PARENTLESS_DIALOG_FIX_SUPPORT
|
|
if(opts.fixParentlessDialogs && (opts.noDlgFixApps.contains(appName) || opts.noDlgFixApps.contains("kde")))
|
|
opts.fixParentlessDialogs=false;
|
|
#endif
|
|
}
|
|
}
|
|
|
|
void QtCurveStyle::polish(TQPalette &pal)
|
|
{
|
|
if(APP_MACTOR==itsThemedApp && itsMactorPal &&
|
|
pal.active().background()!=itsMactorPal->active().background())
|
|
return;
|
|
|
|
TQSettings settings;
|
|
int contrast(settings.readNumEntry("/TQt/KDE/contrast", DEFAULT_CONTRAST));
|
|
bool newContrast(false);
|
|
|
|
readKdeGlobals();
|
|
|
|
if(!kdeSettings.inactiveHighlight)// Read in TQt3 palette... Required for the inactive settings...
|
|
{
|
|
TQStringList active(settings.readListEntry("/TQt/Palette/active")),
|
|
inactive(settings.readListEntry("/TQt/Palette/inactive"));
|
|
|
|
// Only set if: the active highlight is the same, and the inactive highlight is different.
|
|
// If the user has no ~/.qt/qtrc, then TQSettings will return a default palette. However, the palette
|
|
// passed in to this ::polish function will be the KDE one - which maybe different. Hence, we need to
|
|
// check that TQt active == KDE active, before reading inactive...
|
|
if (TQColorGroup::NColorRoles==active.count() &&
|
|
TQColorGroup::NColorRoles==inactive.count() &&
|
|
TQColor(active[TQColorGroup::Highlight])==pal.color(TQPalette::Active, TQColorGroup::Highlight) &&
|
|
TQColor(active[TQColorGroup::HighlightedText])==pal.color(TQPalette::Active, TQColorGroup::HighlightedText))
|
|
{
|
|
TQColor h(inactive[TQColorGroup::Highlight]),
|
|
t(inactive[TQColorGroup::HighlightedText]);
|
|
|
|
if(h!=pal.color(TQPalette::Inactive, TQColorGroup::Highlight) || t!=TQPalette::Inactive, TQColorGroup::HighlightedText)
|
|
{
|
|
pal.setColor(TQPalette::Inactive, TQColorGroup::Highlight, h);
|
|
pal.setColor(TQPalette::Inactive, TQColorGroup::HighlightedText, t);
|
|
}
|
|
}
|
|
}
|
|
|
|
if(contrast<0 || contrast>10)
|
|
contrast=DEFAULT_CONTRAST;
|
|
|
|
if(contrast!=opts.contrast)
|
|
{
|
|
opts.contrast=contrast;
|
|
newContrast=true;
|
|
}
|
|
|
|
if(kdeSettings.inactiveHighlight)
|
|
{
|
|
pal.setColor(TQPalette::Inactive, TQColorGroup::Highlight,
|
|
tint(TQApplication::palette().active().background(),
|
|
TQApplication::palette().active().highlight(), 0.4));
|
|
// KDE4 does not set text colour :-(
|
|
//pal.setColor(TQPalette::Inactive, TQColorGroup::HighlightedText, pal.color(TQPalette::Active, TQColorGroup::Foreground));
|
|
}
|
|
|
|
bool newMenu(newContrast ||
|
|
itsHighlightCols[ORIGINAL_SHADE]!=TQApplication::palette().active().highlight()),
|
|
newGray(newContrast ||
|
|
itsBackgroundCols[ORIGINAL_SHADE]!=TQApplication::palette().active().background()),
|
|
newButton(newContrast ||
|
|
itsButtonCols[ORIGINAL_SHADE]!=TQApplication::palette().active().button()),
|
|
newSlider(itsSliderCols && SHADE_BLEND_SELECTED==opts.shadeSliders &&
|
|
(newContrast || newButton || newMenu)),
|
|
newDefBtn(itsDefBtnCols && /*( (IND_COLORED==opts.defBtnIndicator &&*/
|
|
SHADE_BLEND_SELECTED!=opts.shadeSliders/*) ||*/
|
|
/*(IND_TINT==opts.defBtnIndicator) )*/ &&
|
|
IND_SELECTED!=opts.defBtnIndicator && IND_GLOW!=opts.defBtnIndicator &&
|
|
(newContrast || newButton || newMenu)),
|
|
newComboBtn(itsComboBtnCols && itsHighlightCols!=itsComboBtnCols && itsSliderCols!=itsComboBtnCols &&
|
|
SHADE_BLEND_SELECTED==opts.comboBtn &&
|
|
(newContrast || newButton || newMenu)),
|
|
newSortedLv(itsSortedLvColors && ( (SHADE_BLEND_SELECTED==opts.sortedLv && itsHighlightCols!=itsSortedLvColors && itsSliderCols!=itsSortedLvColors &&
|
|
itsComboBtnCols!=itsSortedLvColors) ||
|
|
SHADE_DARKEN==opts.sortedLv) &&
|
|
(newContrast || (opts.lvButton ? newButton : newGray))),
|
|
newCheckRadioSelCols(itsCheckRadioSelCols && ( (SHADE_BLEND_SELECTED==opts.crColor && itsDefBtnCols!=itsCheckRadioSelCols &&
|
|
itsSliderCols!=itsCheckRadioSelCols && itsComboBtnCols!=itsCheckRadioSelCols &&
|
|
itsSortedLvColors!=itsCheckRadioSelCols) ||
|
|
SHADE_DARKEN==opts.crColor) &&
|
|
(newContrast || newButton)),
|
|
newProgressCols(itsProgressCols && SHADE_BLEND_SELECTED==opts.progressColor &&
|
|
itsSliderCols!=itsProgressCols && itsComboBtnCols!=itsProgressCols &&
|
|
itsSortedLvColors!=itsProgressCols && itsCheckRadioSelCols!=itsProgressCols && (newContrast || newButton));
|
|
|
|
if(newGray)
|
|
shadeColors(TQApplication::palette().active().background(), itsBackgroundCols);
|
|
|
|
if(newButton)
|
|
shadeColors(TQApplication::palette().active().button(), itsButtonCols);
|
|
|
|
if(newMenu)
|
|
shadeColors(TQApplication::palette().active().highlight(), itsHighlightCols);
|
|
|
|
setDecorationColors();
|
|
|
|
setMenuColors(TQApplication::palette().active());
|
|
|
|
if(newSlider)
|
|
shadeColors(midColor(itsHighlightCols[ORIGINAL_SHADE], itsButtonCols[ORIGINAL_SHADE]), itsSliderCols);
|
|
|
|
if(newComboBtn)
|
|
shadeColors(midColor(itsHighlightCols[ORIGINAL_SHADE], itsButtonCols[ORIGINAL_SHADE]), itsComboBtnCols);
|
|
|
|
if(newSortedLv) {
|
|
if(SHADE_BLEND_SELECTED==opts.sortedLv) {
|
|
shadeColors(midColor(itsHighlightCols[ORIGINAL_SHADE],
|
|
opts.lvButton ? itsButtonCols[ORIGINAL_SHADE] : itsBackgroundCols[ORIGINAL_SHADE]), itsSortedLvColors);
|
|
}
|
|
else {
|
|
shadeColors(shade(opts.lvButton ? itsButtonCols[ORIGINAL_SHADE] : itsBackgroundCols[ORIGINAL_SHADE], LV_HEADER_DARK_FACTOR), itsSortedLvColors);
|
|
}
|
|
}
|
|
|
|
if(newDefBtn) {
|
|
if(IND_TINT==opts.defBtnIndicator) {
|
|
shadeColors(tint(itsButtonCols[ORIGINAL_SHADE],
|
|
itsHighlightCols[ORIGINAL_SHADE], DEF_BNT_TINT), itsDefBtnCols);
|
|
}
|
|
else if(IND_GLOW!=opts.defBtnIndicator) {
|
|
shadeColors(midColor(itsHighlightCols[ORIGINAL_SHADE],
|
|
itsButtonCols[ORIGINAL_SHADE]), itsDefBtnCols);
|
|
}
|
|
}
|
|
|
|
if(itsSidebarButtonsCols && SHADE_BLEND_SELECTED!=opts.shadeSliders &&
|
|
IND_COLORED!=opts.defBtnIndicator)
|
|
shadeColors(midColor(itsHighlightCols[ORIGINAL_SHADE],
|
|
itsButtonCols[ORIGINAL_SHADE]), itsSidebarButtonsCols);
|
|
|
|
if(USE_LIGHTER_POPUP_MENU && newGray)
|
|
itsLighterPopupMenuBgndCol=shade(itsBackgroundCols[ORIGINAL_SHADE],
|
|
TO_FACTOR(opts.lighterPopupMenuBgnd));
|
|
|
|
if(newCheckRadioSelCols) {
|
|
if(SHADE_BLEND_SELECTED==opts.crColor) {
|
|
shadeColors(midColor(itsHighlightCols[ORIGINAL_SHADE], itsButtonCols[ORIGINAL_SHADE]), itsCheckRadioSelCols);
|
|
}
|
|
else {
|
|
shadeColors(shade(itsButtonCols[ORIGINAL_SHADE], LV_HEADER_DARK_FACTOR), itsCheckRadioSelCols);
|
|
}
|
|
}
|
|
|
|
if(newProgressCols) {
|
|
shadeColors(midColor(itsHighlightCols[ORIGINAL_SHADE], itsBackgroundCols[ORIGINAL_SHADE]), itsProgressCols);
|
|
}
|
|
|
|
pal.setActive(setColorGroup(pal.active(), pal.active()));
|
|
pal.setInactive(setColorGroup(pal.inactive(), pal.active()));
|
|
pal.setDisabled(setColorGroup(pal.disabled(), pal.active(), true));
|
|
|
|
switch(opts.shadeCheckRadio)
|
|
{
|
|
default:
|
|
itsCheckRadioCol=opts.crButton ? TQApplication::palette().active().buttonText()
|
|
: TQApplication::palette().active().text();
|
|
break;
|
|
case SHADE_SELECTED:
|
|
case SHADE_BLEND_SELECTED:
|
|
itsCheckRadioCol=TQApplication::palette().active().highlight();
|
|
break;
|
|
case SHADE_CUSTOM:
|
|
itsCheckRadioCol=opts.customCheckRadioColor;
|
|
}
|
|
|
|
if(itsMactorPal)
|
|
*itsMactorPal=pal;
|
|
// Force this to be re-generated!
|
|
if(SHADE_BLEND_SELECTED==opts.menuStripe)
|
|
opts.customMenuStripeColor=TQt::black;
|
|
|
|
if(APPEARANCE_STRIPED==opts.bgndAppearance)
|
|
pal.setBrush(TQColorGroup::Background, TQBrush(pal.active().background(), *createStripePixmap(pal.active().background(), true)));
|
|
}
|
|
|
|
static TQColor disable(const TQColor &col, const TQColor &bgnd)
|
|
{
|
|
TQColor c = col;
|
|
c = ColorUtils_darken(&c, 0.1, 1.0);
|
|
c = ColorUtils_mix(&c, &bgnd, 0.65);
|
|
return c;
|
|
}
|
|
|
|
TQColorGroup QtCurveStyle::setColorGroup(const TQColorGroup &old, const TQColorGroup &act, bool dis)
|
|
{
|
|
TQColor mid(old.mid());
|
|
|
|
if(dis)
|
|
mid=disable(act.foreground(), old.background());
|
|
|
|
const TQColor *use(backgroundColors(old));
|
|
TQColorGroup newGrp(old.foreground(), old.button(), use[0], use[STD_BORDER],
|
|
mid, old.text(), old.brightText(),
|
|
old.base(), old.background());
|
|
TQColorGroup::ColorRole roles[]={TQColorGroup::Midlight, TQColorGroup::ButtonText,
|
|
TQColorGroup::Shadow, TQColorGroup::Highlight,
|
|
TQColorGroup::HighlightedText, TQColorGroup::Link,
|
|
TQColorGroup::LinkVisited, TQColorGroup::NColorRoles };
|
|
int r(0);
|
|
|
|
for(r=0; roles[r]!=TQColorGroup::NColorRoles; ++r)
|
|
newGrp.setColor(roles[r], old.color(roles[r]));
|
|
|
|
if(dis)
|
|
{
|
|
newGrp.setColor(TQColorGroup::ButtonText, disable(act.buttonText(), old.button()));
|
|
newGrp.setColor(TQColorGroup::Text, disable(act.text(), old.background()));
|
|
}
|
|
|
|
return newGrp;
|
|
}
|
|
|
|
static const char * kdeToolbarWidget="kde toolbar widget";
|
|
|
|
void QtCurveStyle::polish(TQStyleControlElementData ceData, ControlElementFlags elementFlags, void *ptr)
|
|
{
|
|
if (ceData.widgetObjectTypes.contains(TQWIDGET_OBJECT_NAME_STRING)) {
|
|
TQWidget *widget = reinterpret_cast<TQWidget*>(ptr);
|
|
|
|
bool enableFilter(opts.highlightFactor || opts.coloredMouseOver);
|
|
|
|
if(::isKhtmlFormWidget(widget))
|
|
{
|
|
itsKhtmlWidgets[widget]=true;
|
|
connect(widget, TQT_SIGNAL(destroyed(TQObject *)), this, TQT_SLOT(khtmlWidgetDestroyed(TQObject *)));
|
|
}
|
|
|
|
if(enableFilter && isSpecialHover(widget))
|
|
connect(widget, TQT_SIGNAL(destroyed(TQObject *)), this, TQT_SLOT(hoverWidgetDestroyed(TQObject *)));
|
|
|
|
if(isWindowDragWidget(TQT_TQOBJECT(widget)))
|
|
installObjectEventHandler(ceData, elementFlags, ptr, this);
|
|
|
|
if(APPEARANCE_STRIPED==opts.bgndAppearance && (::tqqt_cast<TQDialog *>(widget) || ::tqqt_cast<TQMainWindow *>(widget)))
|
|
setBgndProp(widget, APPEARANCE_STRIPED);
|
|
|
|
if(widget->parentWidget() && ::tqqt_cast<TQScrollView *>(widget) && ::tqqt_cast<TQComboBox *>(widget->parentWidget()))
|
|
{
|
|
TQPalette pal(widget->palette());
|
|
#if 0
|
|
TQPalette orig(pal);
|
|
#endif
|
|
TQColorGroup act(pal.active());
|
|
|
|
#if 0
|
|
if(opts.gtkComboMenus)
|
|
act.setColor(TQColorGroup::Base, USE_LIGHTER_POPUP_MENU ? itsLighterPopupMenuBgndCol : itsBackgroundCols[ORIGINAL_SHADE]);
|
|
act.setColor(TQColorGroup::Background, opts.gtkComboMenus
|
|
? USE_LIGHTER_POPUP_MENU ? itsLighterPopupMenuBgndCol : itsBackgroundCols[ORIGINAL_SHADE]
|
|
: TQApplication::palette().active().base());
|
|
#endif
|
|
act.setColor(TQColorGroup::Foreground, itsBackgroundCols[STD_BORDER]);
|
|
|
|
pal.setActive(act);
|
|
widget->setPalette(pal);
|
|
#if 0
|
|
//((TQScrollView *)widget)->setMargin(1);
|
|
|
|
const TQObjectList *children(widget->children());
|
|
|
|
if(children)
|
|
{
|
|
TQObjectList::Iterator it(children->begin()),
|
|
end(children->end());
|
|
|
|
for(; it!=end; ++it)
|
|
if(::tqqt_cast<TQWidget *>(*it))
|
|
((TQWidget *)(*it))->setPalette(orig);
|
|
}
|
|
#endif
|
|
}
|
|
|
|
if (APP_MACTOR==itsThemedApp && itsMactorPal && !widget->inherits("TQTipLabel"))
|
|
widget->setPalette(*itsMactorPal);
|
|
|
|
// Get rid of Kontact's frame...
|
|
if(APP_KONTACT==itsThemedApp && ::tqqt_cast<TQHBox *>(widget) && widget->parentWidget() &&
|
|
0==qstrcmp(widget->parentWidget()->className(), "Kontact::MainWindow"))
|
|
((TQHBox *)widget)->setLineWidth(0);
|
|
|
|
if(!IS_FLAT_BGND(opts.menuBgndAppearance) && ::tqqt_cast<const TQPopupMenu *>(widget))
|
|
installObjectEventHandler(ceData, elementFlags, ptr, this);
|
|
|
|
#if 0
|
|
if(opts.menubarHiding && ::tqqt_cast<TQMainWindow *>(widget) && static_cast<TQMainWindow *>(widget)->menuBar())
|
|
installObjectEventHandler(ceData, elementFlags, ptr, this);
|
|
#endif
|
|
|
|
if ((opts.square&SQUARE_SCROLLVIEW) && widget &&
|
|
(::tqqt_cast<const TQScrollView *>(widget) ||
|
|
(widget->parentWidget() && ::tqqt_cast<const TQFrame *>(widget) &&
|
|
widget->parentWidget()->inherits("KateView"))) &&
|
|
((TQFrame *)widget)->lineWidth()>1)
|
|
((TQFrame *)widget)->setLineWidth(opts.gtkScrollViews ? 1 : 2);
|
|
else if(!opts.popupBorder && widget &&
|
|
(::tqqt_cast<const TQPopupMenu *>(widget) ||
|
|
(widget->parentWidget() && ::tqqt_cast<const TQListBox *>(widget) &&
|
|
::tqqt_cast<const TQComboBox *>(widget->parentWidget()))))
|
|
((TQFrame *)widget)->setLineWidth(0);
|
|
else if ((USE_LIGHTER_POPUP_MENU || !IS_FLAT_BGND(opts.menuBgndAppearance)) && !opts.borderMenuitems &&
|
|
widget && ::tqqt_cast<const TQPopupMenu *>(widget))
|
|
((TQFrame *)widget)->setLineWidth(1);
|
|
|
|
if (::tqqt_cast<TQRadioButton *>(widget) || ::tqqt_cast<TQCheckBox *>(widget))
|
|
{
|
|
bool framelessGroupBoxCheckBox=(NO_FRAME(opts.groupBox) && isCheckBoxOfGroupBox(TQT_TQOBJECT(widget)));
|
|
|
|
if(framelessGroupBoxCheckBox || enableFilter)
|
|
{
|
|
#if 0x039999 >= 0x030200
|
|
if(!isFormWidget(widget))
|
|
widget->setMouseTracking(true);
|
|
#endif
|
|
if(framelessGroupBoxCheckBox)
|
|
{
|
|
TQFont fnt(widget->font());
|
|
|
|
fnt.setBold(true);
|
|
widget->setFont(fnt);
|
|
}
|
|
installObjectEventHandler(ceData, elementFlags, ptr, this);
|
|
}
|
|
}
|
|
else if (::tqqt_cast<TQHeader *>(widget) || ::tqqt_cast<TQTabBar *>(widget) || ::tqqt_cast<TQSpinWidget *>(widget)/* ||
|
|
::tqqt_cast<TQDateTimeEditBase*>(widget)*/)
|
|
{
|
|
if(enableFilter)
|
|
{
|
|
widget->setMouseTracking(true);
|
|
installObjectEventHandler(ceData, elementFlags, ptr, this);
|
|
}
|
|
}
|
|
else if (::tqqt_cast<TQToolButton *>(widget))
|
|
{
|
|
if(NoBackground!=widget->backgroundMode()) // && onToolBar(widget))
|
|
widget->setBackgroundMode(PaletteBackground);
|
|
if(enableFilter)
|
|
{
|
|
installObjectEventHandler(ceData, elementFlags, ptr, this);
|
|
#if defined TDE_VERSION && TDE_VERSION >= 0x30400 && TDE_VERSION < 0x30500
|
|
widget->setMouseTracking(true);
|
|
#endif
|
|
}
|
|
}
|
|
else if (::tqqt_cast<TQButton *>(widget) || widget->inherits("TQToolBarExtensionWidget"))
|
|
{
|
|
/*if(onToolBar(widget))
|
|
widget->setBackgroundMode(NoBackground);
|
|
else*/ if(NoBackground!=widget->backgroundMode()) // && onToolBar(widget))
|
|
widget->setBackgroundMode(PaletteBackground);
|
|
if(enableFilter)
|
|
installObjectEventHandler(ceData, elementFlags, ptr, this);
|
|
}
|
|
else if (::tqqt_cast<TQComboBox *>(widget))
|
|
{
|
|
if(NoBackground!=widget->backgroundMode()) // && onToolBar(widget))
|
|
widget->setBackgroundMode(PaletteBackground);
|
|
installObjectEventHandler(ceData, elementFlags, ptr, this);
|
|
|
|
if(DO_EFFECT && onToolBar(widget))
|
|
widget->setName(kdeToolbarWidget);
|
|
|
|
if(enableFilter)
|
|
widget->setMouseTracking(true);
|
|
|
|
if(((TQComboBox *)widget)->listBox())
|
|
((TQComboBox *)widget)->listBox()->installEventFilter(this);
|
|
// FIXME
|
|
// installObjectEventHandler(ceData, elementFlags, ptr, this);
|
|
}
|
|
else if(::tqqt_cast<TQMenuBar *>(widget))
|
|
{
|
|
if(NoBackground!=widget->backgroundMode())
|
|
widget->setBackgroundMode(PaletteBackground);
|
|
if(SHADE_NONE!=opts.shadeMenubars)
|
|
installObjectEventHandler(ceData, elementFlags, ptr, this);
|
|
if(BLEND_TITLEBAR || opts.windowBorder&WINDOW_BORDER_USE_MENUBAR_COLOR_FOR_TITLEBAR)
|
|
emitMenuSize(widget, widget->rect().height());
|
|
if(SHADE_WINDOW_BORDER==opts.shadeMenubars)
|
|
{
|
|
TQPalette pal(widget->palette());
|
|
TQColorGroup act(pal.active());
|
|
TQColorGroup inact(pal.inactive());
|
|
|
|
getMdiColors(act, true);
|
|
act.setColor(TQColorGroup::Foreground, itsActiveMdiTextColor);
|
|
inact.setColor(TQColorGroup::Foreground, opts.shadeMenubarOnlyWhenActive ? itsMdiTextColor : itsActiveMdiTextColor);
|
|
pal.setInactive(inact);
|
|
pal.setActive(act);
|
|
widget->setPalette(pal);
|
|
}
|
|
else if(opts.customMenuTextColor || SHADE_BLEND_SELECTED==opts.shadeMenubars || SHADE_SELECTED==opts.shadeMenubars ||
|
|
(SHADE_CUSTOM==opts.shadeMenubars && TOO_DARK(itsMenubarCols[ORIGINAL_SHADE])))
|
|
{
|
|
TQPalette pal(widget->palette());
|
|
TQColorGroup act(pal.active());
|
|
|
|
act.setColor(TQColorGroup::Foreground, opts.customMenuTextColor
|
|
? opts.customMenuNormTextColor
|
|
: TQApplication::palette().active().highlightedText());
|
|
|
|
if(!opts.shadeMenubarOnlyWhenActive)
|
|
{
|
|
TQColorGroup inact(pal.inactive());
|
|
inact.setColor(TQColorGroup::Foreground, act.color(TQColorGroup::Foreground));
|
|
pal.setInactive(inact);
|
|
}
|
|
|
|
pal.setActive(act);
|
|
widget->setPalette(pal);
|
|
}
|
|
}
|
|
else if(::tqqt_cast<TQToolBar *>(widget))
|
|
{
|
|
if(NoBackground!=widget->backgroundMode())
|
|
widget->setBackgroundMode(PaletteBackground);
|
|
}
|
|
else if(::tqqt_cast<TQPopupMenu *>(widget))
|
|
widget->setBackgroundMode(NoBackground); // PaletteBackground);
|
|
else if (widget->inherits("KToolBarSeparator") ||
|
|
(widget->inherits("KListViewSearchLineWidget") &&
|
|
widget->parent() && ::tqqt_cast<TQToolBar *>(widget->parent())))
|
|
{
|
|
widget->setName(kdeToolbarWidget);
|
|
widget->setBackgroundMode(NoBackground);
|
|
installObjectEventHandler(ceData, elementFlags, ptr, this);
|
|
}
|
|
else if (::tqqt_cast<TQScrollBar *>(widget))
|
|
{
|
|
if(enableFilter)
|
|
{
|
|
widget->setMouseTracking(true);
|
|
installObjectEventHandler(ceData, elementFlags, ptr, this);
|
|
}
|
|
//widget->setBackgroundMode(NoBackground);
|
|
}
|
|
else if (::tqqt_cast<TQSlider *>(widget))
|
|
{
|
|
if(enableFilter)
|
|
installObjectEventHandler(ceData, elementFlags, ptr, this);
|
|
if(widget->parent() && ::tqqt_cast<TQToolBar *>(widget->parent()))
|
|
{
|
|
widget->setName(kdeToolbarWidget);
|
|
widget->setBackgroundMode(NoBackground); // We paint whole background.
|
|
|
|
if(!enableFilter)
|
|
installObjectEventHandler(ceData, elementFlags, ptr, this);
|
|
}
|
|
|
|
// This bit stolen form polyester...
|
|
connect(widget, TQT_SIGNAL(sliderMoved(int)), this, TQT_SLOT(sliderThumbMoved(int)));
|
|
connect(widget, TQT_SIGNAL(valueChanged(int)), this, TQT_SLOT(sliderThumbMoved(int)));
|
|
}
|
|
else if (::tqqt_cast<TQLineEdit*>(widget) || ::tqqt_cast<TQTextEdit*>(widget))
|
|
{
|
|
installObjectEventHandler(ceData, elementFlags, ptr, this);
|
|
if(onToolBar(widget))
|
|
widget->setName(kdeToolbarWidget);
|
|
if(widget && widget->parentWidget() &&
|
|
widget->inherits("KLineEdit") && widget->parentWidget()->inherits("KIO::DefaultProgress") &&
|
|
::tqqt_cast<TQFrame *>(widget))
|
|
((TQFrame *)widget)->setLineWidth(0);
|
|
}
|
|
else if (widget->inherits(TQSPLITTERHANDLE_OBJECT_NAME_STRING) || widget->inherits(TQDOCKWINDOWHANDLE_OBJECT_NAME_STRING) || widget->inherits("TQDockWindowResizeHandle"))
|
|
{
|
|
if(enableFilter)
|
|
installObjectEventHandler(ceData, elementFlags, ptr, this);
|
|
}
|
|
else if (0==qstrcmp(widget->name(), kdeToolbarWidget))
|
|
{
|
|
if(!widget->parent() ||
|
|
0!=qstrcmp(TQT_TQWIDGET(widget->parent())->className(),
|
|
"KListViewSearchLineWidget") ||
|
|
onToolBar(widget))
|
|
{
|
|
installObjectEventHandler(ceData, elementFlags, ptr, this);
|
|
widget->setBackgroundMode(NoBackground); // We paint whole background.
|
|
}
|
|
}
|
|
|
|
if (widget->parentWidget() && ::tqqt_cast<TQMenuBar *>(widget->parentWidget()) && !qstrcmp(widget->className(), TQFRAME_OBJECT_NAME_STRING))
|
|
{
|
|
installObjectEventHandler(ceData, elementFlags, ptr, this);
|
|
widget->setBackgroundMode(NoBackground); // We paint whole background.
|
|
}
|
|
else if (TQt::X11ParentRelative!=widget->backgroundMode() &&
|
|
(::tqqt_cast<TQLabel *>(widget) || ::tqqt_cast<TQHBox *>(widget) ||
|
|
::tqqt_cast<TQVBox *>(widget)) &&
|
|
widget->parent() &&
|
|
( 0==qstrcmp(TQT_TQWIDGET(widget->parent())->className(),
|
|
"MainWindow") || onToolBar(widget)))
|
|
{
|
|
widget->setName(kdeToolbarWidget);
|
|
installObjectEventHandler(ceData, elementFlags, ptr, this);
|
|
widget->setBackgroundMode(NoBackground); // We paint the whole background.
|
|
}
|
|
else if(::tqqt_cast<TQProgressBar *>(widget))
|
|
{
|
|
if(widget->palette().inactive().highlightedText()!=widget->palette().active().highlightedText())
|
|
{
|
|
TQPalette pal(widget->palette());
|
|
pal.setInactive(widget->palette().active());
|
|
widget->setPalette(pal);
|
|
}
|
|
|
|
if(opts.animatedProgress)
|
|
{
|
|
installObjectEventHandler(ceData, elementFlags, ptr, this);
|
|
itsProgAnimWidgets[widget] = 0;
|
|
connect(widget, TQT_SIGNAL(destroyed(TQObject *)), this, TQT_SLOT(progressBarDestroyed(TQObject *)));
|
|
if (!itsAnimationTimer->isActive())
|
|
itsAnimationTimer->start(PROGRESS_ANIMATION, false);
|
|
}
|
|
}
|
|
else if(opts.highlightScrollViews && ::tqqt_cast<TQScrollView*>(widget))
|
|
installObjectEventHandler(ceData, elementFlags, ptr, this);
|
|
else if(!qstrcmp(widget->className(), "KonqFrameStatusBar"))
|
|
{
|
|
// This disables the white background of the KonquerorFrameStatusBar.
|
|
// When the green led is shown the background is set to
|
|
// applications cg.midlight() so we override it to standard background.
|
|
// Thanks Comix! (because this was ugly from day one!)
|
|
// NOTE: Check if we can set it earlier (before painting), cause
|
|
// on slow machines we can see the repainting of the bar (from white to background...)
|
|
TQPalette pal(TQApplication::palette());
|
|
|
|
pal.setColor(TQColorGroup::Midlight, pal.active().background());
|
|
TQApplication::setPalette(pal);
|
|
}
|
|
else if(widget->inherits("KTabCtl"))
|
|
installObjectEventHandler(ceData, elementFlags, ptr, this);
|
|
else if(NO_FRAME(opts.groupBox) && ::tqqt_cast<TQGroupBox *>(widget))
|
|
{
|
|
((TQGroupBox *)widget)->setFlat(false);
|
|
((TQGroupBox *)widget)->setFrameShape(TQFrame::NoFrame);
|
|
}
|
|
#ifdef TQTC_ENABLE_PARENTLESS_DIALOG_FIX_SUPPORT
|
|
else if(opts.fixParentlessDialogs && ::tqqt_cast<TQDialog *>(widget))
|
|
{
|
|
TQDialog *dlg=(TQDialog *)widget;
|
|
|
|
// The parent->isShown is needed for KWord. It's insert picure file dialog is a child of
|
|
// the insert picture dialog - but the file dialog is shown *before* the picture dialog!
|
|
if( (SKIP_TASKBAR && !dlg->parentWidget()) ||
|
|
( (!dlg->parentWidget() || !dlg->parentWidget()->isShown())// &&
|
|
/*(dlg->isModal() || ::tqqt_cast<TQProgressDialog *>(widget))*/) )
|
|
installObjectEventHandler(ceData, elementFlags, ptr, this);
|
|
}
|
|
|
|
if(opts.fixParentlessDialogs && (APP_KPRINTER==itsThemedApp || APP_KDIALOG==itsThemedApp ||
|
|
APP_KDIALOGD==itsThemedApp))
|
|
{
|
|
TQString cap(widget->caption());
|
|
int index=-1;
|
|
|
|
// Remove horrible "Open - KDialog" titles...
|
|
if( cap.length() &&
|
|
( (APP_KPRINTER==itsThemedApp && (-1!=(index=cap.find(" - KPrinter"))) &&
|
|
(index+11)==(int)cap.length()) ||
|
|
(APP_KDIALOG==itsThemedApp && (-1!=(index=cap.find(" - KDialog"))) &&
|
|
(index+10)==(int)cap.length()) ||
|
|
(APP_KDIALOGD==itsThemedApp && (-1!=(index=cap.find(" - KDialog Daemon"))) &&
|
|
(index+17)==(int)cap.length())) )
|
|
widget->TQWidget::setCaption(cap.left(index));
|
|
}
|
|
#endif
|
|
|
|
if(APP_SYSTEMSETTINGS==itsThemedApp)
|
|
{
|
|
if(widget && widget->parentWidget() && widget->parentWidget()->parentWidget() &&
|
|
::tqqt_cast<TQFrame *>(widget) && TQFrame::NoFrame!=((TQFrame *)widget)->frameShape() &&
|
|
::tqqt_cast<TQFrame *>(widget->parentWidget()) &&
|
|
::tqqt_cast<TQTabWidget *>(widget->parentWidget()->parentWidget()))
|
|
((TQFrame *)widget)->setFrameShape(TQFrame::NoFrame);
|
|
|
|
if(widget->parentWidget() && widget->parentWidget()->parentWidget() &&
|
|
::tqqt_cast<TQScrollView *>(widget->parentWidget()->parentWidget()) &&
|
|
widget->inherits("KCMultiWidget") && widget->parentWidget()->inherits("TQViewportWidget"))
|
|
((TQScrollView *)(widget->parentWidget()->parentWidget()))->setLineWidth(0);
|
|
}
|
|
|
|
if(opts.tabBgnd && widget && widget->parentWidget() && ::tqqt_cast<TQWidgetStack *>(widget) &&
|
|
::tqqt_cast<TQTabWidget *>(widget->parentWidget()) &&
|
|
0==qstrcmp(widget->name(), "tab pages"))
|
|
{
|
|
TQPalette pal(widget->palette());
|
|
|
|
pal.setColor(TQColorGroup::Background, shade(pal.active().background(), TO_FACTOR(opts.tabBgnd)));
|
|
widget->setBackgroundMode(PaletteBackground);
|
|
widget->setPalette(pal);
|
|
}
|
|
|
|
if(APPEARANCE_STRIPED==opts.bgndAppearance)
|
|
widget->setBackgroundOrigin(TQWidget::WindowOrigin);
|
|
}
|
|
|
|
BASE_STYLE::polish(ceData, elementFlags, ptr);
|
|
}
|
|
|
|
void QtCurveStyle::unPolish(TQStyleControlElementData ceData, ControlElementFlags elementFlags, void *ptr)
|
|
{
|
|
if (ceData.widgetObjectTypes.contains(TQWIDGET_OBJECT_NAME_STRING)) {
|
|
TQWidget *widget = reinterpret_cast<TQWidget*>(ptr);
|
|
|
|
if(isFormWidget(widget))
|
|
itsKhtmlWidgets.remove(widget);
|
|
|
|
if(!IS_FLAT_BGND(opts.menuBgndAppearance) && ::tqqt_cast<const TQPopupMenu *>(widget))
|
|
removeObjectEventHandler(ceData, elementFlags, ptr, this);
|
|
|
|
#if 0
|
|
if(opts.menubarHiding && ::tqqt_cast<TQMainWindow *>(widget) && static_cast<TQMainWindow *>(widget)->menuBar())
|
|
removeObjectEventHandler(ceData, elementFlags, ptr, this);
|
|
#endif
|
|
|
|
if(isWindowDragWidget(TQT_TQOBJECT(widget)))
|
|
removeObjectEventHandler(ceData, elementFlags, ptr, this);
|
|
|
|
if (::tqqt_cast<TQRadioButton *>(widget) || ::tqqt_cast<TQCheckBox *>(widget))
|
|
{
|
|
#if 0x039999 >= 0x030200
|
|
widget->setMouseTracking(false);
|
|
#endif
|
|
removeObjectEventHandler(ceData, elementFlags, ptr, this);
|
|
}
|
|
else if (::tqqt_cast<TQHeader *>(widget) || ::tqqt_cast<TQTabBar *>(widget) || ::tqqt_cast<TQSpinWidget *>(widget) /*||
|
|
::tqqt_cast<TQDateTimeEditBase*>(widget)*/)
|
|
{
|
|
widget->setMouseTracking(false);
|
|
removeObjectEventHandler(ceData, elementFlags, ptr, this);
|
|
}
|
|
else if (::tqqt_cast<TQButton *>(widget) || widget->inherits("TQToolBarExtensionWidget"))
|
|
{
|
|
if(NoBackground!=widget->backgroundMode()) // && onToolBar(widget))
|
|
widget->setBackgroundMode(PaletteButton);
|
|
removeObjectEventHandler(ceData, elementFlags, ptr, this);
|
|
}
|
|
else if (::tqqt_cast<TQToolButton *>(widget))
|
|
{
|
|
if(NoBackground!=widget->backgroundMode()) // && onToolBar(widget))
|
|
widget->setBackgroundMode(PaletteButton);
|
|
removeObjectEventHandler(ceData, elementFlags, ptr, this);
|
|
#if defined TDE_VERSION && TDE_VERSION >= 0x30400 && TDE_VERSION < 0x30500
|
|
widget->setMouseTracking(false);
|
|
#endif
|
|
}
|
|
else if (::tqqt_cast<TQComboBox *>(widget))
|
|
{
|
|
if(NoBackground!=widget->backgroundMode()) // && onToolBar(widget))
|
|
widget->setBackgroundMode(PaletteButton);
|
|
removeObjectEventHandler(ceData, elementFlags, ptr, this);
|
|
widget->setMouseTracking(false);
|
|
if(((TQComboBox *)widget)->listBox())
|
|
((TQComboBox *)widget)->listBox()->removeEventFilter(this);
|
|
// FIXME
|
|
// removeObjectEventHandler(ceData, elementFlags, ptr, this);
|
|
}
|
|
else if (::tqqt_cast<TQToolBar *>(widget) || ::tqqt_cast<TQPopupMenu *>(widget))
|
|
{
|
|
if(NoBackground!=widget->backgroundMode())
|
|
widget->setBackgroundMode(PaletteBackground);
|
|
}
|
|
else if (::tqqt_cast<TQMenuBar *>(widget))
|
|
{
|
|
if(NoBackground!=widget->backgroundMode())
|
|
widget->setBackgroundMode(PaletteBackground);
|
|
if(SHADE_NONE!=opts.shadeMenubars)
|
|
removeObjectEventHandler(ceData, elementFlags, ptr, this);
|
|
if(SHADE_WINDOW_BORDER==opts.shadeMenubars || opts.customMenuTextColor || SHADE_BLEND_SELECTED==opts.shadeMenubars ||
|
|
SHADE_SELECTED==opts.shadeMenubars || (SHADE_CUSTOM==opts.shadeMenubars &&TOO_DARK(itsMenubarCols[ORIGINAL_SHADE])))
|
|
widget->setPalette(TQApplication::palette());
|
|
}
|
|
else if (widget->inherits("KToolBarSeparator"))
|
|
{
|
|
widget->setBackgroundMode(PaletteBackground);
|
|
removeObjectEventHandler(ceData, elementFlags, ptr, this);
|
|
}
|
|
else if (::tqqt_cast<TQScrollBar *>(widget))
|
|
{
|
|
widget->setMouseTracking(false);
|
|
removeObjectEventHandler(ceData, elementFlags, ptr, this);
|
|
widget->setBackgroundMode(PaletteButton);
|
|
}
|
|
else if (::tqqt_cast<TQSlider *>(widget))
|
|
{
|
|
removeObjectEventHandler(ceData, elementFlags, ptr, this);
|
|
if(widget->parent() && ::tqqt_cast<TQToolBar *>(widget->parent()))
|
|
widget->setBackgroundMode(PaletteBackground);
|
|
}
|
|
else if (::tqqt_cast<TQLineEdit*>(widget) || ::tqqt_cast<TQTextEdit*>(widget))
|
|
removeObjectEventHandler(ceData, elementFlags, ptr, this);
|
|
else if (widget->inherits(TQSPLITTERHANDLE_OBJECT_NAME_STRING) || widget->inherits(TQDOCKWINDOWHANDLE_OBJECT_NAME_STRING) || widget->inherits("TQDockWindowResizeHandle"))
|
|
removeObjectEventHandler(ceData, elementFlags, ptr, this);
|
|
else if (::tqqt_cast<TQProgressBar*>(widget))
|
|
{
|
|
itsProgAnimWidgets.remove(widget);
|
|
removeObjectEventHandler(ceData, elementFlags, ptr, this);
|
|
}
|
|
else if(opts.highlightScrollViews && ::tqqt_cast<TQScrollView*>(widget))
|
|
removeObjectEventHandler(ceData, elementFlags, ptr, this);
|
|
else if(0==qstrcmp(widget->name(), kdeToolbarWidget))
|
|
{
|
|
removeObjectEventHandler(ceData, elementFlags, ptr, this);
|
|
widget->setBackgroundMode(PaletteBackground);
|
|
}
|
|
if (widget->parentWidget() && ::tqqt_cast<TQMenuBar *>(widget->parentWidget()) && !qstrcmp(widget->className(), TQFRAME_OBJECT_NAME_STRING))
|
|
{
|
|
removeObjectEventHandler(ceData, elementFlags, ptr, this);
|
|
widget->setBackgroundMode(PaletteBackground); // We paint whole background.
|
|
}
|
|
else if(widget->inherits("KTabCtl"))
|
|
removeObjectEventHandler(ceData, elementFlags, ptr, this);
|
|
#ifdef TQTC_ENABLE_PARENTLESS_DIALOG_FIX_SUPPORT
|
|
else if(opts.fixParentlessDialogs && ::tqqt_cast<TQDialog *>(widget))
|
|
removeObjectEventHandler(ceData, elementFlags, ptr, this);
|
|
#endif
|
|
}
|
|
|
|
BASE_STYLE::unPolish(ceData, elementFlags, ptr);
|
|
}
|
|
|
|
static void sendXEvent(TQDialog *dlg, const char *msg)
|
|
{
|
|
static Atom msgTypeAtom = XInternAtom(tqt_xdisplay(), "_NET_WM_STATE", False);
|
|
|
|
XEvent xev;
|
|
Atom atom=XInternAtom(tqt_xdisplay(), msg, False);
|
|
|
|
xev.xclient.type = ClientMessage;
|
|
xev.xclient.serial = 0;
|
|
xev.xclient.send_event = True;
|
|
xev.xclient.window = dlg->winId();
|
|
xev.xclient.message_type = msgTypeAtom;
|
|
xev.xclient.format = 32;
|
|
xev.xclient.data.l[0] = 1;
|
|
xev.xclient.data.l[1] = atom;
|
|
xev.xclient.data.l[2] = 0;
|
|
xev.xclient.data.l[3] = 0;
|
|
xev.xclient.data.l[4] = 0;
|
|
|
|
XSendEvent(tqt_xdisplay(), tqt_xrootwin(), False,
|
|
SubstructureRedirectMask | SubstructureNotifyMask, &xev);
|
|
}
|
|
|
|
bool QtCurveStyle::appIsNotEmbedded(TQDialog *dlg)
|
|
{
|
|
Window win;
|
|
|
|
if(!XGetTransientForHint(tqt_xdisplay(), dlg->winId(), &win) || (int)win < 1000)
|
|
return true;
|
|
|
|
// OK, dialog has been set transient, so there is no need for this event filter anymore :-)
|
|
dlg->removeEventFilter(this);
|
|
return false;
|
|
}
|
|
|
|
bool QtCurveStyle::objectEventHandler( TQStyleControlElementData ceData, ControlElementFlags elementFlags, void* source, TQEvent *event )
|
|
{
|
|
if (ceData.widgetObjectTypes.contains(TQOBJECT_OBJECT_NAME_STRING)) {
|
|
TQObject* object = reinterpret_cast<TQObject*>(source);
|
|
|
|
if(itsHoverWidget && TQT_BASE_OBJECT(object)==TQT_BASE_OBJECT(itsHoverWidget) && (TQEvent::Destroy==event->type() || TQEvent::Hide==event->type()))
|
|
resetHover();
|
|
|
|
#if 0
|
|
// Works for qtconfig, but k3b hangs?
|
|
if(opts.menubarHiding && TQEvent::KeyRelease==event->type() && ::tqqt_cast<TQMainWindow *>(object))
|
|
{
|
|
TQMainWindow *window=static_cast<TQMainWindow *>(object);
|
|
|
|
if(window->isVisible() && window->menuBar())
|
|
{
|
|
TQKeyEvent *k=static_cast<TQKeyEvent *>(event);
|
|
|
|
if(k->state()&TQt::ControlButton && k->state()&TQt::AltButton && TQt::Key_M==k->key())
|
|
window->menuBar()->setHidden(window->menuBar()->isVisible());
|
|
}
|
|
}
|
|
#endif
|
|
|
|
if(object->parent() && 0==qstrcmp(object->name(), kdeToolbarWidget))
|
|
{
|
|
// Draw background for custom widgets in the toolbar that have specified a
|
|
// "kde toolbar widget" name.
|
|
if(TQEvent::Paint==event->type())
|
|
{
|
|
TQWidget *widget(TQT_TQWIDGET(object)),
|
|
*parent(TQT_TQWIDGET(object->parent()));
|
|
|
|
if(IS_FLAT(opts.toolbarAppearance))
|
|
TQPainter(widget).fillRect(widget->rect(), parent->colorGroup().background());
|
|
else
|
|
{
|
|
int y_offset(widget->y());
|
|
|
|
while(parent && parent->parent() && 0==qstrcmp(parent->name(), kdeToolbarWidget))
|
|
{
|
|
y_offset += parent->y();
|
|
parent = TQT_TQWIDGET(parent->parent());
|
|
}
|
|
|
|
TQRect r(widget->rect()),
|
|
pr(parent->rect());
|
|
bool horiz=pr.width() > pr.height();
|
|
TQPainter p(widget);
|
|
TQToolBar *tb(::tqqt_cast<TQToolBar*>(parent));
|
|
|
|
// If parent is a TQToolbar use its orientation, else just base on width>height.
|
|
if (tb)
|
|
horiz = Qt::Horizontal==tb->orientation();
|
|
|
|
TQRect bgndRect(r.x(), r.y()-y_offset, r.width(), pr.height());
|
|
|
|
if(!IS_FLAT(opts.toolbarAppearance)) {
|
|
if(horiz) {
|
|
bgndRect.addCoords(0, -1, 0, 1);
|
|
}
|
|
else {
|
|
bgndRect.addCoords(-1, 0, 1, 0);
|
|
}
|
|
}
|
|
|
|
drawMenuOrToolBarBackground(&p, bgndRect, parent->colorGroup(), false, horiz);
|
|
}
|
|
|
|
if(!::tqqt_cast<TQLineEdit*>(object) && !::tqqt_cast<TQTextEdit*>(object) &&
|
|
!(DO_EFFECT && ::tqqt_cast<TQComboBox*>(object)))
|
|
return false; // Now draw the contents
|
|
}
|
|
}
|
|
else if (NO_FRAME(opts.groupBox) && TQEvent::Move==event->type() && isCheckBoxOfGroupBox(object))
|
|
{
|
|
TQCheckBox *cb=static_cast<TQCheckBox *>(TQT_TQWIDGET(object));
|
|
TQRect r(cb->geometry());
|
|
|
|
removeObjectEventHandler(ceData, elementFlags, source, this);
|
|
if(TQApplication::reverseLayout())
|
|
r.setWidth(r.width()+8);
|
|
else
|
|
r.setX(0);
|
|
cb->setGeometry(r);
|
|
installObjectEventHandler(ceData, elementFlags, source, this);
|
|
return false;
|
|
}
|
|
else if (TQEvent::Paint==event->type())
|
|
{
|
|
if(!IS_FLAT_BGND(opts.menuBgndAppearance) && ::tqqt_cast<TQPopupMenu *>(object))
|
|
{
|
|
TQWidget *widget=(TQWidget*)object;
|
|
TQPainter painter(widget);
|
|
TQColor col(USE_LIGHTER_POPUP_MENU ? itsLighterPopupMenuBgndCol : widget->palette().active().background());
|
|
|
|
if(APPEARANCE_STRIPED==opts.menuBgndAppearance)
|
|
painter.drawTiledPixmap(widget->rect(), *createStripePixmap(col, false));
|
|
else
|
|
drawBevelGradientReal(col, &painter, widget->rect(), GT_HORIZ==opts.menuBgndGrad, false,
|
|
opts.menuBgndAppearance, WIDGET_OTHER);
|
|
return false;
|
|
}
|
|
else if (object->inherits("KToolBarSeparator"))
|
|
{
|
|
TQFrame *frame(::tqqt_cast<TQFrame *>(object));
|
|
|
|
if(frame && TQFrame::NoFrame!=frame->frameShape())
|
|
{
|
|
TQPainter painter(frame);
|
|
if (TQFrame::VLine==frame->frameShape())
|
|
drawPrimitive(PE_DockWindowSeparator, &painter, TQStyleControlElementData(), CEF_None, frame->rect(),
|
|
frame->colorGroup(), Style_Horizontal);
|
|
else if (TQFrame::HLine==frame->frameShape())
|
|
drawPrimitive(PE_DockWindowSeparator, &painter, TQStyleControlElementData(), CEF_None, frame->rect(),
|
|
frame->colorGroup());
|
|
else
|
|
return false;
|
|
return true; // been drawn!
|
|
}
|
|
}
|
|
else if(object->inherits("KTabCtl") && ::tqqt_cast<TQWidget*>(object))
|
|
{
|
|
TQWidget *widget((TQWidget*)object);
|
|
TQObject *child(object->child("_tabbar"));
|
|
TQTabBar *tb(child ? ::tqqt_cast<TQTabBar *>(child) : 0L);
|
|
TQPainter painter(widget);
|
|
TQRect r(widget->rect());
|
|
int tbHeight(tb ? tb->height()-1 : 28);
|
|
|
|
if(tb && (TQTabBar::RoundedBelow == tb->shape() ||
|
|
TQTabBar::TriangularBelow == tb->shape()))
|
|
r.addCoords(0, 0, 0, -tbHeight);
|
|
else
|
|
r.addCoords(0, tbHeight, 0, 0);
|
|
drawPrimitive(PE_PanelTabWidget, &painter, TQStyleControlElementData(), CEF_None, r, widget->colorGroup(),
|
|
Style_Horizontal|Style_Enabled);
|
|
return true;
|
|
}
|
|
}
|
|
|
|
// Fix mdi buttons in menubars...
|
|
if(::tqqt_cast<TQWidget*>(object) && ((TQWidget *)object)->parentWidget() &&
|
|
::tqqt_cast<TQMenuBar*>(((TQWidget *)object)->parentWidget()))
|
|
{
|
|
bool drawMenubar=false;
|
|
|
|
switch(event->type())
|
|
{
|
|
case TQEvent::Paint:
|
|
drawMenubar=true;
|
|
break;
|
|
case TQEvent::WindowActivate:
|
|
itsActive=true;
|
|
drawMenubar=opts.shadeMenubarOnlyWhenActive && SHADE_NONE!=opts.shadeMenubars;
|
|
break;
|
|
case TQEvent::WindowDeactivate:
|
|
itsActive=false;
|
|
drawMenubar=opts.shadeMenubarOnlyWhenActive && SHADE_NONE!=opts.shadeMenubars;
|
|
default:
|
|
break;
|
|
}
|
|
|
|
if(drawMenubar)
|
|
{
|
|
|
|
TQWidget *widget(TQT_TQWIDGET(object)),
|
|
*parent(TQT_TQWIDGET(object->parent()));
|
|
TQRect r(widget->rect());
|
|
TQPainter p(widget);
|
|
int y_offset(widget->y()+parent->y());
|
|
|
|
r.setY(r.y()-y_offset);
|
|
r.setHeight(parent->rect().height());
|
|
|
|
drawMenuOrToolBarBackground(&p, r, parent->colorGroup());
|
|
return true;
|
|
}
|
|
}
|
|
|
|
// Taken from plastik...
|
|
// focus highlight
|
|
if (::tqqt_cast<TQLineEdit*>(object) || ::tqqt_cast<TQTextEdit*>(object)/* || ::tqqt_cast<TQDateTimeEditBase*>(object)*/)
|
|
{
|
|
if(TQEvent::FocusIn==event->type() || TQEvent::FocusOut==event->type() || TQEvent::Enter==event->type() || TQEvent::Leave==event->type())
|
|
{
|
|
TQWidget *widget(TQT_TQWIDGET(object));
|
|
|
|
if (::tqqt_cast<TQSpinWidget*>(widget->parentWidget()))
|
|
{
|
|
widget->parentWidget()->repaint(false);
|
|
return false;
|
|
}
|
|
|
|
widget->repaint(false);
|
|
}
|
|
return false;
|
|
}
|
|
|
|
if(::tqqt_cast<TQMenuBar *>(object))
|
|
{
|
|
bool useWindowCols=SHADE_WINDOW_BORDER==opts.shadeMenubars;
|
|
|
|
if( (useWindowCols || opts.customMenuTextColor || SHADE_BLEND_SELECTED==opts.shadeMenubars || SHADE_SELECTED==opts.shadeMenubars ||
|
|
SHADE_CUSTOM==opts.shadeMenubars) && TQEvent::Paint==event->type())
|
|
{
|
|
const TQColor &col(((TQWidget *)object)->palette().active().color(TQColorGroup::Foreground));
|
|
|
|
// If we're relouring the menubar text, check to see if menubar palette has changed, if so set back to
|
|
// our values. This fixes opera - which seems to change the widgets palette after it is polished.
|
|
if((opts.customMenuTextColor && col!=opts.customMenuNormTextColor) ||
|
|
( (SHADE_BLEND_SELECTED==opts.shadeMenubars || SHADE_SELECTED==opts.shadeMenubars ||
|
|
(SHADE_CUSTOM==opts.shadeMenubars && TOO_DARK(itsMenubarCols[ORIGINAL_SHADE]))) &&
|
|
col!=TQApplication::palette().active().highlightedText()))
|
|
{
|
|
TQPalette pal(((TQWidget *)object)->palette());
|
|
TQColorGroup act(pal.active());
|
|
|
|
act.setColor(TQColorGroup::Foreground, useWindowCols
|
|
? itsActiveMdiTextColor
|
|
: opts.customMenuTextColor
|
|
? opts.customMenuNormTextColor
|
|
: TQApplication::palette().active().highlightedText());
|
|
|
|
if(!opts.shadeMenubarOnlyWhenActive || useWindowCols)
|
|
{
|
|
TQColorGroup inact(pal.inactive());
|
|
inact.setColor(TQColorGroup::Foreground, useWindowCols ? itsMdiTextColor : act.color(TQColorGroup::Foreground));
|
|
pal.setInactive(inact);
|
|
}
|
|
|
|
pal.setActive(act);
|
|
((TQWidget *)object)->setPalette(pal);
|
|
}
|
|
}
|
|
|
|
if(opts.shadeMenubarOnlyWhenActive && SHADE_NONE!=opts.shadeMenubars)
|
|
switch(event->type())
|
|
{
|
|
case TQEvent::WindowActivate:
|
|
itsActive=true;
|
|
((TQWidget *)object)->repaint(false);
|
|
return false;
|
|
case TQEvent::WindowDeactivate:
|
|
itsActive=false;
|
|
((TQWidget *)object)->repaint(false);
|
|
return false;
|
|
default:
|
|
break;
|
|
}
|
|
if(BLEND_TITLEBAR || opts.windowBorder&WINDOW_BORDER_USE_MENUBAR_COLOR_FOR_TITLEBAR)
|
|
switch(event->type())
|
|
{
|
|
case TQEvent::Resize:
|
|
{
|
|
TQResizeEvent *re = TQT_TQRESIZEEVENT(event);
|
|
|
|
if (re->size().height() != re->oldSize().height())
|
|
emitMenuSize((TQMenuBar *)object, re->size().height());
|
|
break;
|
|
}
|
|
default:
|
|
break;
|
|
}
|
|
}
|
|
|
|
if(dynamic_cast<TQMouseEvent*>(event))
|
|
switch(event->type())
|
|
{
|
|
case TQEvent::MouseMove: // Only occurs for widgets with mouse tracking enabled
|
|
if(itsDragWidget)
|
|
{
|
|
itsDragWidget->setMouseTracking(itsDragWidgetHadMouseTracking);
|
|
bool move=isWindowDragWidget(object);
|
|
|
|
if(move)
|
|
triggerWMMove(itsDragWidget, ((TQMouseEvent *)event)->globalPos());
|
|
itsDragWidget = 0L;
|
|
return move;
|
|
}
|
|
case TQEvent::MouseButtonPress:
|
|
{
|
|
TQMouseEvent *mev = (TQMouseEvent *)event;
|
|
|
|
if(isWindowDragWidget(object, mev->pos()))
|
|
{
|
|
|
|
if(/*TQt::NoModifier==mev->modifiers() && */ Qt::LeftButton==mev->button())
|
|
{
|
|
TQWidget *wid = TQT_TQWIDGET(object);
|
|
itsDragWidget=wid;
|
|
itsDragWidgetHadMouseTracking=itsDragWidget->hasMouseTracking();
|
|
itsDragWidget->setMouseTracking(true);
|
|
return false;
|
|
}
|
|
}
|
|
break;
|
|
}
|
|
case TQEvent::MouseButtonRelease:
|
|
if(itsDragWidget)
|
|
{
|
|
itsDragWidget->setMouseTracking(itsDragWidgetHadMouseTracking);
|
|
itsDragWidget = 0L;
|
|
return false;
|
|
}
|
|
default:
|
|
break;
|
|
}
|
|
|
|
#ifdef TQTC_ENABLE_PARENTLESS_DIALOG_FIX_SUPPORT
|
|
if(opts.fixParentlessDialogs && ::tqqt_cast<TQDialog *>(object))
|
|
{
|
|
TQDialog *dlg=(TQDialog *)object;
|
|
|
|
switch(event->type())
|
|
{
|
|
case TQEvent::ShowMinimized:
|
|
if(SKIP_TASKBAR && appIsNotEmbedded(dlg))
|
|
{
|
|
// Ugly hack :-( Cant seem to get KWin to remove the minimize button. So when
|
|
// the dialog gets minimized, restore.
|
|
dlg->setWindowState(dlg->windowState() & ~WindowMinimized | WindowActive);
|
|
return true;
|
|
}
|
|
break;
|
|
case TQEvent::WindowActivate:
|
|
if(SKIP_TASKBAR && appIsNotEmbedded(dlg))
|
|
{
|
|
// OO.o's filepicker is a spawned process - but is not set transient :-(
|
|
// --plus no reliable way of finding which widget to make it transient for...
|
|
sendXEvent(dlg, "_NET_WM_STATE_SKIP_PAGER");
|
|
sendXEvent(dlg, "_NET_WM_STATE_SKIP_TASKBAR");
|
|
sendXEvent(dlg, "_NET_WM_STATE_ABOVE");
|
|
sendXEvent(dlg, "_NET_WM_STATE_STAYS_ON_TOP");
|
|
//setActions(dlg);
|
|
}
|
|
break;
|
|
case TQEvent::Show:
|
|
// The parent->isShown is needed for KWord. It's insert picure file dialog is a
|
|
// child of the insert picture dialog - but the file dialog is shown *before* the
|
|
// picture dialog!
|
|
if((!dlg->parentWidget() || !dlg->parentWidget()->isShown())) // &&
|
|
//(dlg->isModal() || ::tqqt_cast<TQProgressDialog *>(object)))
|
|
{
|
|
TQWidget *activeWindow=tqApp->activeWindow();
|
|
|
|
if(activeWindow)
|
|
{
|
|
XWindowAttributes attr;
|
|
int rx, ry;
|
|
Window win;
|
|
|
|
if(!XGetTransientForHint(tqt_xdisplay(), dlg->winId(), &win) ||
|
|
win!=activeWindow->winId())
|
|
{
|
|
XSetTransientForHint(tqt_xdisplay(), dlg->winId(),
|
|
activeWindow->winId());
|
|
|
|
if(XGetWindowAttributes(tqt_xdisplay(), activeWindow->winId(), &attr))
|
|
{
|
|
XTranslateCoordinates(tqt_xdisplay(), activeWindow->winId(),
|
|
attr.root, -attr.border_width, -16,
|
|
&rx, &ry, &win);
|
|
|
|
rx=(rx+(attr.width/2))-(dlg->width()/2);
|
|
if(rx<0)
|
|
rx=0;
|
|
ry=(ry+(attr.height/2))-(dlg->height()/2);
|
|
if(ry<0)
|
|
ry=0;
|
|
dlg->move(rx, ry);
|
|
if(!dlg->isModal())
|
|
dlg->setModal(true);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
default:
|
|
break;
|
|
}
|
|
return false;
|
|
}
|
|
#endif
|
|
|
|
// Track show events for progress bars
|
|
if (opts.animatedProgress && ::tqqt_cast<TQProgressBar*>(object))
|
|
{
|
|
if(TQEvent::Show==event->type() && !itsAnimationTimer->isActive())
|
|
itsAnimationTimer->start(PROGRESS_ANIMATION, false);
|
|
return false;
|
|
}
|
|
|
|
switch(event->type())
|
|
{
|
|
case TQEvent::FocusIn:
|
|
case TQEvent::FocusOut:
|
|
if(opts.highlightScrollViews && object->isWidgetType() && ::tqqt_cast<TQScrollView*>(object))
|
|
((TQWidget *)object)->repaint(false);
|
|
break;
|
|
case TQEvent::Hide:
|
|
case TQEvent::Show:
|
|
if(::tqqt_cast<TQListBox *>(object) &&
|
|
(((TQListBox *)object)->parentWidget() &&
|
|
::tqqt_cast<TQComboBox *>(((TQListBox *)object)->parentWidget())))
|
|
((TQComboBox *)(((TQListBox *)object)->parentWidget()))->repaint(false);
|
|
// else if(::tqqt_cast<TQFrame *>(object) &&
|
|
// (TQFrame::Box==((TQFrame *)object)->frameShape() || TQFrame::Panel==((TQFrame *)object)->frameShape() ||
|
|
// TQFrame::WinPanel==((TQFrame *)object)->frameShape()))
|
|
// ((TQFrame *)object)->setFrameShape(TQFrame::StyledPanel);
|
|
break;
|
|
case TQEvent::Enter:
|
|
if(object->isWidgetType())
|
|
{
|
|
itsHoverWidget=(TQWidget *)object;
|
|
|
|
if(itsHoverWidget && itsHoverWidget->isEnabled())
|
|
{
|
|
if(::tqqt_cast<TQTabBar*>(object) && TQT_TQWIDGET(object)->isEnabled())
|
|
{
|
|
itsHoverTab=0L;
|
|
itsHoverWidget->repaint(false);
|
|